From cccf72ec08ce57f08bdc54af1b1c64581c85905b Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 1 Nov 2011 22:35:00 +0200 Subject: Update VMS test suite. --- vms/ChangeLog | 6 ++++ vms/vmstest.com | 87 ++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 74 insertions(+), 19 deletions(-) diff --git a/vms/ChangeLog b/vms/ChangeLog index 88a4bf88..9a3ffd74 100644 --- a/vms/ChangeLog +++ b/vms/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/vms/vmstest.com b/vms/vmstest.com index d4d3d8a9..f35a9ad1 100644 --- a/vms/vmstest.com +++ b/vms/vmstest.com @@ -47,15 +47,17 @@ $ list = "msg addcomma anchgsub argarray arrayparm arrayref" - + " clobber closebad clsflnam compare compare2 concat1" $ gosub list_of_tests $ list = "concat2 concat3 concat4 convfmt datanonl defref" - - + " delargv delarprm delarpm2 delfunc dynlj eofsplit exitval1" - - + " dfastress" - + + " 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" + + " funsemnl funsmnam funstack getline getline2 getline3" - + + " getline4" $ gosub list_of_tests $ list = "getlnbuf getnr2tb getnr2tm gsubasgn gsubtest" - - + " gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 hex" - + + " gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6" - + + " gsubtst7 gsubtst8 hex" - + " hsprint inputred intest intprec iobug1" - + " leaddig leadnl litoct longsub longwrds"- + " manglprm math membug1 messages minusstr mmap8k" - @@ -87,7 +89,7 @@ $ $unix: $unix_tests: echo "unix_tests..." $ list = "fflush getlnhd localenl pid pipeio1 pipeio2" - - + " poundbang space strftlng" + + " poundbang rtlen relen01 space strftlng" $ gosub list_of_tests $ return $ @@ -96,7 +98,8 @@ $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 fpatnull funlen fsfwfs fwtest fwtest2" - + + " 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 @@ -104,7 +107,7 @@ $ list = "indirectcall lint lintold lintwarn match1" - + " match2 match3 manyfiles mbprintf3 mbstr1" - + " nastyparm next nondec" - + " nondec2 patsplit posix profile1 procinfs printfbad1" - - + " printfbad2 regx8bit rebuf reint reint2 rsstart1" - + + " printfbad2 pty1 regx8bit rebuf reint reint2 rsstart1" - + " rsstart2 rsstart3 rstest6 shadow sortfor sortu" - + " splitarg4 strtonum strftime switch2" $ gosub list_of_tests @@ -121,7 +124,7 @@ $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 sort1 sprintfc" + + " mbprintf1 mbprintf2 rebt8b2 rtlenmb sort1 sprintfc" $ gosub list_of_tests $ return $ @@ -194,6 +197,7 @@ $fldchgnf: $fmttest: $fordel: $fpat1: +$fpat3: $fpatnull: $fsfwfs: $fsrs: @@ -201,14 +205,18 @@ $funlen: $funstack: $fwtest: $fwtest2: +$fwtest3: $gensub: $getline3: +$getline4: $getnr2tb: $getnr2tm: $gsubtest: $gsubtst2: $gsubtst4: $gsubtst5: +$gsubtst7: +$gsubtst8: $hex: $icasers: $igncfs: @@ -363,7 +371,8 @@ $ gawk -f printlang.awk $ return $ $poundbang: -$ echo "poundbang: not supported" +$pty1: +$ echo "''test': not supported" $ return $ $messages: echo "messages" @@ -1077,16 +1086,12 @@ $ igncascmp space.ok _space.tmp $ if $status then rm _space.tmp; $ return $ -$posix2008sub: echo "posix2008sub" -$ gawk --posix -f posix2008sub.awk >_posix2008sub.tmp -$ cmp posix2008sub.ok _posix2008sub.tmp -$ if $status then rm _posix2008sub.tmp; -$ return -$ -$printf0: echo "printf0" -$ gawk --posix -f printf0.awk >_printf0.tmp -$ cmp printf0.ok _printf0.tmp -$ if $status then rm _printf0.tmp; +$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" @@ -1201,6 +1206,50 @@ $ 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 -- cgit v1.2.3 From 9926f88fdfe6e489194fb1fe0e5e75774ace04ce Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 1 Nov 2011 22:35:22 +0200 Subject: Improve config.sed. --- pc/ChangeLog | 12 +++++- pc/config.sed | 120 +++++++++++++++++++++++++++++----------------------------- 2 files changed, 70 insertions(+), 62 deletions(-) diff --git a/pc/ChangeLog b/pc/ChangeLog index 9f56a20d..3d8ef415 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,4 +1,14 @@ -2011-10-27 Scott Deifik +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. diff --git a/pc/config.sed b/pc/config.sed index c0fa766a..7fe0f922 100644 --- a/pc/config.sed +++ b/pc/config.sed @@ -26,111 +26,110 @@ /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\ +/^#undef HAVE_BTOWC *$/c\ #ifdef _WIN32\ #define HAVE_BTOWC 1\ #endif -/^#undef HAVE_DECL_TZNAME$/c\ +/^#undef HAVE_DECL_TZNAME *$/c\ #ifdef __MINGW32__\ #define HAVE_DECL_TZNAME 1\ #endif -/^#undef HAVE_FCNTL_H$/c\ -#ifdef __MINGW32__\ -#define HAVE_FCNTL_H 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\ +/^#undef HAVE_INTMAX_T *$/c\ #ifdef __MINGW32__\ #define HAVE_INTMAX_T 1\ #endif -/^#undef HAVE_INTTYPES_H$/c\ +/^#undef HAVE_INTTYPES_H *$/c\ #ifdef __MINGW32__\ #define HAVE_INTTYPES_H 1\ #endif -/^#undef HAVE_INTTYPES_H_WITH_UINTMAX$/c\ +/^#undef HAVE_INTTYPES_H_WITH_UINTMAX *$/c\ #ifdef __MINGW32__\ #define HAVE_INTTYPES_H_WITH_UINTMAX 1\ #endif -/^#undef HAVE_ISASCII$/c\ +/^#undef HAVE_ISASCII *$/c\ #ifdef __MINGW32__\ #define HAVE_ISASCII 1\ #endif -/^#undef HAVE_ISWCTYPE$/c\ +/^#undef HAVE_ISWCTYPE *$/c\ #ifdef __MINGW32__\ #define HAVE_ISWCTYPE 1\ #endif -/^#undef HAVE_ISWLOWER$/c\ +/^#undef HAVE_ISWLOWER *$/c\ #ifdef __MINGW32__\ #define HAVE_ISWLOWER 1\ #endif -/^#undef HAVE_ISWUPPER$/c\ +/^#undef HAVE_ISWUPPER *$/c\ #ifdef __MINGW32__\ #define HAVE_ISWUPPER 1\ #endif s/^#undef HAVE_LIBM *$/#define HAVE_LIBM 1/ -/^#undef HAVE_LIMITS_H$/c\ -#if defined(DJGPP) || defined(__MINGW32__)\ -#define HAVE_LIMITS_H 1\ -#endif -/^#undef HAVE_LOCALE_H$/c\ +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\ +/^#undef HAVE_LONG_LONG *$/c\ #ifdef __MINGW32__\ #define HAVE_LONG_LONG 1\ #endif -/^#undef HAVE_MBRLEN$/c\ +/^#undef HAVE_MBRLEN *$/c\ #ifdef __MINGW32__\ #define HAVE_MBRLEN 1\ #endif -/^#undef HAVE_MBRTOWC$/c\ +/^#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\ +/^#undef HAVE_MEMMOVE *$/c\ #ifdef __MINGW32__\ #define HAVE_MEMMOVE 1\ #endif s/^#undef HAVE_MEMSET *$/#define HAVE_MEMSET 1/ -/^#undef HAVE_MKSTEMP$/c\ +/^#undef HAVE_MKSTEMP *$/c\ #ifdef DJGPP\ #define HAVE_MKSTEMP 1\ #endif s/^#undef HAVE_MKTIME *$/#define HAVE_MKTIME 1/ -/^#undef HAVE_SETENV$/c\ +/^#undef HAVE_SETENV *$/c\ #if defined(__MINGW32__) || defined(__DJGPP__)\ #define HAVE_SETENV 1\ #endif -/^#undef HAVE_SETLOCALE$/c\ +/^#undef HAVE_SETLOCALE *$/c\ #ifdef __MINGW32__\ #define HAVE_SETLOCALE 1\ #endif -/^#undef HAVE_SNPRINTF$/c\ +/^#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\ +/^#undef HAVE_STDDEF_H *$/c\ #ifdef __GNUC__\ #define HAVE_STDDEF_H 1\ #endif -/^#undef HAVE_STDINT_H$/c\ +/^#undef HAVE_STDINT_H *$/c\ #ifdef __MINGW32__\ #define HAVE_STDINT_H 1\ #endif -/^#undef HAVE_STDLIB_H$/c\ +/^#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\ +/^#undef HAVE_STRFTIME *$/c\ #ifdef __MINGW32__\ /* MinGW uses the replacement from missing_d, to support the %e specifier. */\ #define strftime rpl_strftime\ @@ -139,88 +138,82 @@ s/^#undef HAVE_STRERROR *$/#define HAVE_STRERROR 1/ #endif s/^#undef HAVE_STRINGIZE *$/#define HAVE_STRINGIZE 1/ s/^#undef HAVE_STRING_H *$/#define HAVE_STRING_H 1/ -/^#undef HAVE_STRNCASECMP$/c\ +/^#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\ +/^#undef HAVE_STRTOUL *$/c\ #ifdef __MINGW32__\ #define HAVE_STRTOUL 1\ #endif -/^#undef HAVE_SYSTEM$/c\ -#ifdef __MINGW32__\ -#define HAVE_SYSTEM 1\ -#endif -/^#undef HAVE_SYS_PARAM_H$/c\ +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\ +/^#undef HAVE_SYS_STAT_H *$/c\ #ifdef __MINGW32__\ #define HAVE_SYS_STAT_H 1\ #endif -/^#undef HAVE_SYS_TIME_H$/c\ +/^#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\ +/^#undef HAVE_TOWLOWER *$/c\ #ifdef __MINGW32__\ #define HAVE_TOWLOWER 1\ #endif -/^#undef HAVE_TOWUPPER$/c\ +/^#undef HAVE_TOWUPPER *$/c\ #ifdef __MINGW32__\ #define HAVE_TOWUPPER 1\ #endif s/^#undef HAVE_TZNAME *$/#define HAVE_TZNAME 1/ -/^#undef HAVE_TZSET$/c\ -#ifdef __MINGW32__\ -#define HAVE_TZSET 1\ -#endif -/^#undef HAVE_UINTMAX_T$/c\ +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\ +/^#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\ +/^#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\ +/^#undef HAVE_WCHAR_H *$/c\ #ifdef __MINGW32__\ #define HAVE_WCHAR_H 1\ #endif -/^#undef HAVE_WCRTOMB$/c\ +/^#undef HAVE_WCRTOMB *$/c\ #ifdef __MINGW32__\ #define HAVE_WCRTOMB 1\ #endif -/^#undef HAVE_WCSCOLL$/c\ +/^#undef HAVE_WCSCOLL *$/c\ #ifdef __MINGW32__\ #define HAVE_WCSCOLL 1\ #endif -/^#undef HAVE_WCTYPE$/c\ +/^#undef HAVE_WCTYPE *$/c\ #ifdef __MINGW32__\ #define HAVE_WCTYPE 1\ #endif -/^#undef HAVE_WCTYPE_H$/c\ +/^#undef HAVE_WCTYPE_H *$/c\ #ifdef __MINGW32__\ #define HAVE_WCTYPE_H 1\ #endif -/^#undef HAVE_WCTYPE_T$/c\ +/^#undef HAVE_WCTYPE_T *$/c\ #ifdef __MINGW32__\ #define HAVE_WCTYPE_T 1\ #endif -/^#undef HAVE_WINT_T$/c\ +/^#undef HAVE_WINT_T *$/c\ #ifdef __MINGW32__\ #define HAVE_WINT_T 1\ #endif @@ -231,31 +224,31 @@ s/^#undef RETSIGTYPE *$/#define RETSIGTYPE void/ #if defined(DJGPP) || defined(__MINGW32__)\ #include \ #endif -/^#undef SIZEOF_UNSIGNED_INT$/c\ +/^#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\ +/^#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\ +/^#undef inline *$/c\ #ifdef __GNUC__\ #define inline __inline__\ #endif -/^#undef intmax_t$/c\ +/^#undef intmax_t *$/c\ #ifdef DJGPP\ #define intmax_t long long\ #endif -/^#undef restrict$/c\ +/^#undef restrict *$/c\ #ifdef DJGPP\ #define restrict\ #endif -/^#undef uintmax_t$/c\ +/^#undef uintmax_t *$/c\ #ifdef DJGPP\ #define uintmax_t unsigned long long\ #endif @@ -274,6 +267,11 @@ $a\ #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 -- cgit v1.2.3 From 406189e88890a240c50cfd9f33613c4d4fb6d2bf Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 1 Nov 2011 22:56:51 +0200 Subject: Move non-MBS support glop out of dfa.c. --- ChangeLog | 8 +++++ dfa.c | 80 ------------------------------------------------ mbsupport.h | 17 +++++++++++ missing_d/ChangeLog | 4 +++ missing_d/wcmisc.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ regex_internal.h | 8 ++--- replace.c | 4 +++ 7 files changed, 125 insertions(+), 84 deletions(-) create mode 100644 missing_d/wcmisc.c diff --git a/ChangeLog b/ChangeLog index 75dc14c8..0b440a95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +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 diff --git a/dfa.c b/dfa.c index 789c6b91..cba66886 100644 --- a/dfa.c +++ b/dfa.c @@ -68,18 +68,6 @@ #define bool int #define true (1) #define false (0) -#if ! MBS_SUPPORT -#define wctype_t int -#define wint_t int -#define mbstate_t int -#define WEOF EOF -#define towupper toupper -#define towlower tolower -#define btowc(x) (x) -#define iswalnum isalnum -#define iswalpha isalpha -#define iswupper isupper -#endif /* ! MBS_SUPPORT */ #endif /* GAWK */ #include "regex.h" @@ -92,74 +80,6 @@ is_blank (int c) { return (c == ' ' || c == '\t'); } - -#if ! MBS_SUPPORT -static const char *classes[] = { - "", - "alnum", - "alpha", - "blank", - "cntrl", - "digit", - "graph", - "lower", - "print", - "punct", - "space", - "upper", - "xdigit", - NULL -}; - -static 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; -} - -static 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; - } -} - -static 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 /* ! MBS_SUPPORT */ #endif /* GAWK */ /* HPUX, define those as macros in sys/param.h */ diff --git a/mbsupport.h b/mbsupport.h index 6008da77..1a30785d 100644 --- a/mbsupport.h +++ b/mbsupport.h @@ -67,4 +67,21 @@ #if ! MBS_SUPPORT # undef MB_CUR_MAX # define MB_CUR_MAX 1 + +/* All this glop is for dfa.c. Bleah. */ + +#define wctype_t int +#define wint_t int +#define mbstate_t int +#define WEOF EOF +#define towupper toupper +#define towlower tolower +#define btowc(x) (x) +#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_d/ChangeLog b/missing_d/ChangeLog index 8aaeb418..45cc1acc 100644 --- a/missing_d/ChangeLog +++ b/missing_d/ChangeLog @@ -1,3 +1,7 @@ +2011-11-01 Arnold D. Robbins + + * wcmisc.c: New file. + 2011-06-23 Arnold D. Robbins * ChangeLog.0: Rotated ChangeLog into this file. diff --git a/missing_d/wcmisc.c b/missing_d/wcmisc.c new file mode 100644 index 00000000..e53730ea --- /dev/null +++ b/missing_d/wcmisc.c @@ -0,0 +1,88 @@ +/* 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 */ + +static const char *classes[] = { + "", + "alnum", + "alpha", + "blank", + "cntrl", + "digit", + "graph", + "lower", + "print", + "punct", + "space", + "upper", + "xdigit", + NULL +}; + +static int is_blank (int c) +{ + return (c == ' ' || c == '\t'); +} + +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; +} + +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; + } +} + +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]); +} diff --git a/regex_internal.h b/regex_internal.h index b5dc7b46..5fcab48a 100644 --- a/regex_internal.h +++ b/regex_internal.h @@ -27,16 +27,18 @@ #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 defined HAVE_WCHAR_H || defined _LIBC +#if MBS_SUPPORT && (defined HAVE_WCHAR_H || defined _LIBC) # include #endif /* HAVE_WCHAR_H || _LIBC */ -#if defined HAVE_WCTYPE_H || defined _LIBC +#if MBS_SUPPORT && (defined HAVE_WCTYPE_H || defined _LIBC) # include #endif /* HAVE_WCTYPE_H || _LIBC */ #if defined HAVE_STDBOOL_H || defined _LIBC @@ -108,8 +110,6 @@ is_blank (int c) # define SIZE_MAX ((size_t) -1) #endif -#include "mbsupport.h" /* gawk */ - #if MBS_SUPPORT || _LIBC # define RE_ENABLE_I18N #endif diff --git a/replace.c b/replace.c index d2dcbbcc..d1c05ad6 100644 --- a/replace.c +++ b/replace.c @@ -111,3 +111,7 @@ #ifndef HAVE_STRCOLL #include "missing_d/strcoll.c" #endif + +#if ! MBS_SUPPORT +#include "missing_d/wcmisc.c" +#endif -- cgit v1.2.3 From 029d61f3b4632a52679802d54e9972b1423ef805 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 1 Nov 2011 23:00:37 +0200 Subject: Bump dist version. --- configure | 20 ++++++------ configure.ac | 2 +- pc/config.h | 21 ++++++------- po/da.gmo | Bin 48739 -> 48739 bytes po/da.po | 96 ++++++++++++++++++++++++++++----------------------------- po/de.gmo | Bin 52166 -> 52166 bytes po/de.po | 96 ++++++++++++++++++++++++++++----------------------------- po/es.gmo | Bin 51471 -> 51471 bytes po/es.po | 96 ++++++++++++++++++++++++++++----------------------------- po/fi.gmo | Bin 51684 -> 51684 bytes po/fi.po | 96 ++++++++++++++++++++++++++++----------------------------- po/fr.gmo | Bin 53311 -> 53311 bytes po/fr.po | 96 ++++++++++++++++++++++++++++----------------------------- po/gawk.pot | 98 +++++++++++++++++++++++++++++------------------------------ po/it.gmo | Bin 44316 -> 44316 bytes po/it.po | 96 ++++++++++++++++++++++++++++----------------------------- po/ja.gmo | Bin 55596 -> 55596 bytes po/ja.po | 96 ++++++++++++++++++++++++++++----------------------------- po/nl.gmo | Bin 49267 -> 49267 bytes po/nl.po | 96 ++++++++++++++++++++++++++++----------------------------- po/pl.gmo | Bin 50946 -> 50946 bytes po/pl.po | 96 ++++++++++++++++++++++++++++----------------------------- po/sv.gmo | Bin 48752 -> 48752 bytes po/sv.po | 96 ++++++++++++++++++++++++++++----------------------------- version.c | 2 +- 25 files changed, 550 insertions(+), 553 deletions(-) diff --git a/configure b/configure index 64781c79..909198b4 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for GNU Awk 4.0.0c. +# Generated by GNU Autoconf 2.68 for GNU Awk 4.0.0d. # # Report bugs to . # @@ -560,8 +560,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='GNU Awk' PACKAGE_TARNAME='gawk' -PACKAGE_VERSION='4.0.0c' -PACKAGE_STRING='GNU Awk 4.0.0c' +PACKAGE_VERSION='4.0.0d' +PACKAGE_STRING='GNU Awk 4.0.0d' PACKAGE_BUGREPORT='bug-gawk@gnu.org' PACKAGE_URL='http://www.gnu.org/software/gawk/' @@ -1290,7 +1290,7 @@ 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.0c to adapt to many kinds of systems. +\`configure' configures GNU Awk 4.0.0d to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1360,7 +1360,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU Awk 4.0.0c:";; + short | recursive ) echo "Configuration of GNU Awk 4.0.0d:";; esac cat <<\_ACEOF @@ -1472,7 +1472,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU Awk configure 4.0.0c +GNU Awk configure 4.0.0d generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2176,7 +2176,7 @@ 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.0c, which was +It was created by GNU Awk $as_me 4.0.0d, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3011,7 +3011,7 @@ fi # Define the identity of the package. PACKAGE='gawk' - VERSION='4.0.0c' + VERSION='4.0.0d' cat >>confdefs.h <<_ACEOF @@ -11221,7 +11221,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # 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.0c, which was +This file was extended by GNU Awk $as_me 4.0.0d, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11289,7 +11289,7 @@ _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.0c +GNU Awk config.status 4.0.0d configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index a8bc0e14..9eacc408 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ dnl dnl Process this file with autoconf to produce a configure script. -AC_INIT([GNU Awk], 4.0.0c, bug-gawk@gnu.org, gawk) +AC_INIT([GNU Awk], 4.0.0d, 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. diff --git a/pc/config.h b/pc/config.h index 41fd895a..c0143f3d 100644 --- a/pc/config.h +++ b/pc/config.h @@ -13,7 +13,7 @@ #define GETGROUPS_T gid_t /* Define to 1 if the `getpgrp' function requires zero arguments. */ -#undef GETPGRP_VOID +#define GETPGRP_VOID 1 /* Define to 1 if you have the `alarm' function. */ #define HAVE_ALARM 1 @@ -51,9 +51,7 @@ #undef HAVE_DOPRNT /* Define to 1 if you have the header file. */ -#ifdef __MINGW32__ #define HAVE_FCNTL_H 1 -#endif /* Define to 1 if you have the `fmod' function. */ #define HAVE_FMOD 1 @@ -131,9 +129,7 @@ #undef HAVE_LIBSIGSEGV /* Define to 1 if you have the header file. */ -#if defined(DJGPP) || defined(__MINGW32__) #define HAVE_LIMITS_H 1 -#endif /* Define to 1 if you have the header file. */ #ifdef __MINGW32__ @@ -298,9 +294,7 @@ #undef HAVE_ST_BLKSIZE /* Define to 1 if you have the `system' function. */ -#ifdef __MINGW32__ #define HAVE_SYSTEM 1 -#endif /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H @@ -354,9 +348,7 @@ #define HAVE_TZNAME 1 /* Define to 1 if you have the `tzset' function. */ -#ifdef __MINGW32__ #define HAVE_TZSET 1 -#endif /* Define if you have the 'uintmax_t' type in or . */ #if defined(DJGPP) || defined(__MINGW32__) @@ -433,7 +425,7 @@ #define PACKAGE_NAME "GNU Awk" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Awk 4.0.0c" +#define PACKAGE_STRING "GNU Awk 4.0.0d" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "gawk" @@ -442,7 +434,7 @@ #define PACKAGE_URL "http://www.gnu.org/software/gawk/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "4.0.0c" +#define PACKAGE_VERSION "4.0.0d" /* Define to 1 if *printf supports %F format */ #undef PRINTF_HAS_F_FORMAT @@ -504,7 +496,7 @@ /* Version number of package */ -#define VERSION "4.0.0c" +#define VERSION "4.0.0d" /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS @@ -595,6 +587,11 @@ #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/po/da.gmo b/po/da.gmo index 6685bdb7..0b86e1b0 100644 Binary files a/po/da.gmo and b/po/da.gmo differ diff --git a/po/da.po b/po/da.po index 33c60c39..b4fb05ec 100644 --- a/po/da.po +++ b/po/da.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 3.1.83\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-05-22 10:37+0200\n" "Last-Translator: Keld Simonsen \n" "Language-Team: Danish \n" @@ -46,7 +46,7 @@ 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:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -760,205 +760,205 @@ msgstr "" "substr: længden %g ved startindeks %g overskrider længden af første argument " "(%lu)" -#: builtin.c:1655 +#: builtin.c:1656 msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" msgstr "strftime: formatværdi i PROCINFO[\"strftime\"] har numerisk type" -#: builtin.c:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime: fik et ikke-numerisk andet argument" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftime: fik et første argument som ikke er en streng" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime: fik en tom formatstreng" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime: fik et argument som ikke er en streng" -#: builtin.c:1776 +#: builtin.c:1778 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:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "'system'-funktion ikke tilladt i sandkasse-tilstand" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system: fik et argument som ikke er en streng" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 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:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "reference til ikke-initieret felt '$%d'" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower: fik et argument som ikke er en streng" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper: fik et argument som ikke er en streng" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2: fik et ikke-numerisk første argument" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2: fik et ikke-numerisk andet argument" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin: fik et ikke-numerisk argument" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos: fik et ikke-numerisk argument" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand: fik et ikke-numerisk argument" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match: tredje argument er ikke et array" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub: 0 i tredje argument behandlet som 1" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift: fik et ikke-numerisk første argument" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift: fik et ikke-numerisk andet argument" -#: builtin.c:2781 +#: builtin.c:2783 #, 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:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "lshift(%lf, %lf): kommatalsværdier vil blive trunkeret" -#: builtin.c:2785 +#: builtin.c:2787 #, 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:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift: fik et ikke-numerisk første argument" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift: fik et ikke-numerisk andet argument" -#: builtin.c:2818 +#: builtin.c:2820 #, 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:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "rshift(%lf, %lf): kommatalsværdier vil blive trunkeret" -#: builtin.c:2822 +#: builtin.c:2824 #, 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:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and: fik et ikke-numerisk første argument" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and: fik et ikke-numerisk andet argument" -#: builtin.c:2855 +#: builtin.c:2857 #, 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:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "and(%lf, %lf): kommatalsværdier vil blive trunkeret" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or: fik et ikke-numerisk første argument" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or: fik et ikke-numerisk andet argument" -#: builtin.c:2890 +#: builtin.c:2892 #, 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:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "or(%lf, %lf): kommatalsværdier vil blive trunkeret" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor: fik et ikke-numerisk første argument" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor: fik et ikke-numerisk andet argument" -#: builtin.c:2928 +#: builtin.c:2930 #, 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:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "xor(%lf, %lf): kommatalsværdier vil blive trunkeret" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl: fik et ikke-numerisk argument" -#: builtin.c:2962 +#: builtin.c:2964 #, c-format msgid "compl(%lf): negative value will give strange results" msgstr "compl(%lf): negative værdier vil give mærkelige resultater" -#: builtin.c:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf): kommatalsværdier vil blive trunkeret" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "dcgettext: '%s' er ikke en gyldig lokalitetskategori" diff --git a/po/de.gmo b/po/de.gmo index f95537b8..57013d80 100644 Binary files a/po/de.gmo and b/po/de.gmo differ diff --git a/po/de.po b/po/de.po index 3500bf2d..19785ab9 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-09-27 16:38+0200\n" "Last-Translator: Philipp Thomas \n" "Language-Team: German \n" @@ -42,7 +42,7 @@ 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:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -778,210 +778,210 @@ msgstr "" "substr: Länge %g am Start-Wert %g überschreitet die Länge des ersten " "Arguments (%lu)" -#: builtin.c:1655 +#: builtin.c:1656 msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" msgstr "strftime: Formatwert in PROCINFO[\"strftime\"] ist numerischen Typs" -#: builtin.c:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime: Das zweite Argument ist keine Zahl" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftime: Das erste Argument ist kein String" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime: Der Format-String ist leer" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime: Das Argument ist kein String" -#: builtin.c:1776 +#: builtin.c:1778 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:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "Die Funktion »system« ist im Sandbox-Modus nicht erlaubt" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system: Das Argument ist kein String" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 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:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "Referenz auf das nicht initialisierte Feld »$%d«" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower: das Argument ist kein String" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper: das Argument ist kein String" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2: das erste Argument ist keine Zahl" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2: das zweite Argument ist keine Zahl" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin: das Argument ist keine Zahl" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos: das Argument ist keine Zahl" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand: das Argument ist keine Zahl" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match: das dritte Argument ist kein Array" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub: 0 als drittes Argument wird als 1 interpretiert" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift: das erste Argument ist keine Zahl" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift: das zweite Argument ist keine Zahl" -#: builtin.c:2781 +#: builtin.c:2783 #, 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:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "lshift(%lf, %lf): Dezimalteil wird abgeschnitten" -#: builtin.c:2785 +#: builtin.c:2787 #, 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:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift: das erste Argument ist keine Zahl" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift: das zweite Argument ist keine Zahl" -#: builtin.c:2818 +#: builtin.c:2820 #, 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:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "rshift(%lf, %lf): Dezimalteil wird abgeschnitten" -#: builtin.c:2822 +#: builtin.c:2824 #, 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:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and: das erste Argument ist keine Zahl" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and: das zweite Argument ist keine Zahl" -#: builtin.c:2855 +#: builtin.c:2857 #, 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:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "and(%lf, %lf): Dezimalteil wird abgeschnitten" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or: das erste Argument ist keine Zahl" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or: das zweite Argument ist keine Zahl" -#: builtin.c:2890 +#: builtin.c:2892 #, 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:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "or(%lf, %lf): Dezimalteil wird abgeschnitten" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor: das erste Argument ist keine Zahl" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor: das zweite Argument ist keine Zahl" -#: builtin.c:2928 +#: builtin.c:2930 #, 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:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "xor(%lf, %lf): Dezimalteil wird abgeschnitten" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl: das erste Argument ist keine Zahl" -#: builtin.c:2962 +#: builtin.c:2964 #, 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:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf): Dezimalteil wird abgeschnitten" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "dcgettext: »%s« ist keine gültige Locale-Kategorie" diff --git a/po/es.gmo b/po/es.gmo index e395377a..36b57c97 100644 Binary files a/po/es.gmo and b/po/es.gmo differ diff --git a/po/es.po b/po/es.po index 676e7a8b..8f063a32 100644 --- a/po/es.po +++ b/po/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-08-14 12:02-0500\n" "Last-Translator: Cristian Othón Martínez Vera \n" "Language-Team: Spanish \n" @@ -41,7 +41,7 @@ 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:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -776,209 +776,209 @@ msgstr "" "substr: la cadena %g en el índice de inicio %g excede la longitud del primer " "argumento (%lu)" -#: builtin.c:1655 +#: builtin.c:1656 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:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime: el segundo argumento recibido no es númerico" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftime: el primer argumento recibido no es una cadena" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime: se recibió una cadena de formato vacía" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime: se recibió un argumento que no es una cadena" -#: builtin.c:1776 +#: builtin.c:1778 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:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "no se permite la función 'system' en modo sandbox" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system: se recibió un argumento que no es una cadena" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 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:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "referencia al campo sin inicializar `$%d'" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower: se recibió un argumento que no es una cadena" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper: se recibió un argumento que no es una cadena" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2: el primer argumento recibido no es númerico" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2: el segundo argumento recibido no es númerico" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin: se recibió un argumento que no es númerico" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos: se recibió un argumento que no es númerico" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand: se recibió un argumento que no es númerico" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match: el tercer argumento no es una matriz" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub: el tercer argumento de 0 se trata como 1" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift: el primer argumento recibido no es númerico" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift: el segundo argumento recibido no es númerico" -#: builtin.c:2781 +#: builtin.c:2783 #, 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:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "lshift(%lf, %lf): los valores fraccionarios se truncarán" -#: builtin.c:2785 +#: builtin.c:2787 #, 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:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift: el primer argumento recibido no es númerico" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift: el segundo argumento recibido no es númerico" -#: builtin.c:2818 +#: builtin.c:2820 #, 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:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "rshift(%lf, %lf): los valores fraccionarios serán truncados" -#: builtin.c:2822 +#: builtin.c:2824 #, 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:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and: el primer argumento recibido no es númerico" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and: el segundo argumento recibido no es númerico" -#: builtin.c:2855 +#: builtin.c:2857 #, 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:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "and(%lf, %lf): los valores fraccionarios serán truncados" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or: el primer argumento recibido no es númerico" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or: el segundo argumento recibido no es númerico" -#: builtin.c:2890 +#: builtin.c:2892 #, 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:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "or(%lf, %lf): los valores fraccionarios serán truncados" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor: el primer argumento recibido no es númerico" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor: el segundo argumento recibido no es númerico" -#: builtin.c:2928 +#: builtin.c:2930 #, 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:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "xor(%lf, %lf): los valores fraccionarios se truncarán" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl: se recibió un argumento que no es númerico" -#: builtin.c:2962 +#: builtin.c:2964 #, c-format msgid "compl(%lf): negative value will give strange results" msgstr "compl(%lf): el valor negativo dará resultados extraños" -#: builtin.c:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf): el valor fraccionario se truncará" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "dcgettext: `%s' no es una categoría local válida" diff --git a/po/fi.gmo b/po/fi.gmo index df538bcf..8f2ed4e1 100644 Binary files a/po/fi.gmo and b/po/fi.gmo differ diff --git a/po/fi.po b/po/fi.po index 442a7322..1da166b6 100644 --- a/po/fi.po +++ b/po/fi.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-09-12 12:14+0200\n" "Last-Translator: Jorma Karvonen \n" "Language-Team: Finnish \n" @@ -42,7 +42,7 @@ 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:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -763,204 +763,204 @@ msgstr "" "substr: pituus %g alkuindeksissä %g ylittää ensimmäisen argumentin pituuden " "(%lu)" -#: builtin.c:1655 +#: builtin.c:1656 msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" msgstr "" "strftime: muotoarvolla kohteessa PROCINFO[\"strftime\"] on numerotyyppi" -#: builtin.c:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime: toinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftime: ensimmäinen vastaanotettu argumentti ei ole merkkijono" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime: vastaanotettu tyhjä muotomerkkijono" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime: vastaanotettu argumentti ei ole merkkijono" -#: builtin.c:1776 +#: builtin.c:1778 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:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "”system”-funktio ei ole sallittu hiekkalaatikkotilassa" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system: vastaanotettu argumentti ei ole merkkijono" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 eval.c:1159 eval.c:1790 eval.c:1803 #, c-format msgid "reference to uninitialized variable `%s'" msgstr "viite alustamattomaan muuttujaan ”%s”" -#: builtin.c:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "viite alustamattomaan kenttään ”$%d”" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower: vastaanotettu argumentti ei ole merkkijono" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper: vastaanotettu argumentti ei ole merkkijono" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2: ensimmäinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2: toinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin: vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos: vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand: vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match: kolmas argumentti ei ole taulukko" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub: 0-arvoinen kolmas argumentti käsitellään kuin 1" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift: ensimmäinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift: toinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2781 +#: builtin.c:2783 #, c-format msgid "lshift(%lf, %lf): negative values will give strange results" msgstr "lshift(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" -#: builtin.c:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "lshift(%lf, %lf): jaosarvot typistetään" -#: builtin.c:2785 +#: builtin.c:2787 #, 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:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift: ensimmäinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift: toinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2818 +#: builtin.c:2820 #, c-format msgid "rshift(%lf, %lf): negative values will give strange results" msgstr "rshift(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" -#: builtin.c:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "rshift(%lf, %lf): jaosarvot typistetään" -#: builtin.c:2822 +#: builtin.c:2824 #, 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:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and: ensimmäinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and: toinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2855 +#: builtin.c:2857 #, c-format msgid "and(%lf, %lf): negative values will give strange results" msgstr "and(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" -#: builtin.c:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "and(%lf, %lf): jaosarvot typistetään" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or: ensimmäinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or: toinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2890 +#: builtin.c:2892 #, c-format msgid "or(%lf, %lf): negative values will give strange results" msgstr "or(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" -#: builtin.c:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "or(%lf, %lf): jaosarvot typistetään" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor: ensimmäinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor: toinen vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2928 +#: builtin.c:2930 #, c-format msgid "xor(%lf, %lf): negative values will give strange results" msgstr "xor(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" -#: builtin.c:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "xor(%lf, %lf): jaosarvot typistetään" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl: vastaanotettu argumentti ei ole numeerinen" -#: builtin.c:2962 +#: builtin.c:2964 #, c-format msgid "compl(%lf): negative value will give strange results" msgstr "compl(%lf): negatiiviset arvot antavat outoja tuloksia" -#: builtin.c:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf): jaosarvo typistetään" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "dcgettext: ”%s” ei ole kelvollinen paikallinen kategoria" diff --git a/po/fr.gmo b/po/fr.gmo index 000b9a8a..01710ef5 100644 Binary files a/po/fr.gmo and b/po/fr.gmo differ diff --git a/po/fr.po b/po/fr.po index a958491d..a590a9f5 100644 --- a/po/fr.po +++ b/po/fr.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-07-16 16:50+0200\n" "Last-Translator: Jean-Philippe Guérard \n" @@ -45,7 +45,7 @@ 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:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -767,213 +767,213 @@ 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:1655 +#: builtin.c:1656 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:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime : le second argument n'est pas numérique" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftim : le premier argument n'est pas une chaîne" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime : la chaîne de formatage est vide" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime : l'argument n'est pas une chaîne" -#: builtin.c:1776 +#: builtin.c:1778 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:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "La fonction « system » est interdite en isolement (mode sandbox)" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system : l'argument n'est pas une chaîne" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 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:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "référence à un champ non initialisé « $%d »" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower : l'argument n'est pas une chaîne" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper : l'argument n'est pas une chaîne" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2 : le premier argument n'est pas numérique" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2 : le second argument n'est pas numérique" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin : l'argument n'est pas numérique" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos : l'argument n'est pas numérique" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand : l'argument n'est pas numérique" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match : le 3e argument n'est pas un tableau" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub : le 3e argument vaut 0, il sera traité comme un 1" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift : le premier argument n'est pas numérique" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift : le second argument reçu n'est pas numérique" -#: builtin.c:2781 +#: builtin.c:2783 #, 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:2783 +#: builtin.c:2785 #, 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:2785 +#: builtin.c:2787 #, 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:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift : le premier argument n'est pas numérique" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift : le second argument reçu n'est pas numérique" -#: builtin.c:2818 +#: builtin.c:2820 #, 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:2820 +#: builtin.c:2822 #, 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:2822 +#: builtin.c:2824 #, 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:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and : le premier argument n'est pas numérique" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and : le second argument reçu n'est pas numérique" -#: builtin.c:2855 +#: builtin.c:2857 #, 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:2857 +#: builtin.c:2859 #, 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:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or : le premier argument n'est pas numérique" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or : le second argument reçu n'est pas numérique" -#: builtin.c:2890 +#: builtin.c:2892 #, 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:2892 +#: builtin.c:2894 #, 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:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor : le premier argument n'est pas numérique" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor : le second argument reçu n'est pas numérique" -#: builtin.c:2928 +#: builtin.c:2930 #, 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:2930 +#: builtin.c:2932 #, 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:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl : l'argument n'est pas numérique" -#: builtin.c:2962 +#: builtin.c:2964 #, 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:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf) : les valeurs non entières seront tronquées" -#: builtin.c:3133 +#: builtin.c:3135 #, 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" diff --git a/po/gawk.pot b/po/gawk.pot index 290ff817..3119cdc7 100644 --- a/po/gawk.pot +++ b/po/gawk.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: gawk 4.0.0c\n" +"Project-Id-Version: gawk 4.0.0d\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -42,7 +42,7 @@ msgid "attempt to use scalar `%s' as an array" msgstr "" #: array.c:302 array.c:707 builtin.c:84 builtin.c:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -734,203 +734,203 @@ msgid "" "substr: length %g at start index %g exceeds length of first argument (%lu)" msgstr "" -#: builtin.c:1655 +#: builtin.c:1656 msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" msgstr "" -#: builtin.c:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "" -#: builtin.c:1776 +#: builtin.c:1778 msgid "mktime: at least one of the values is out of the default range" msgstr "" -#: builtin.c:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 eval.c:1159 eval.c:1790 eval.c:1803 #, c-format msgid "reference to uninitialized variable `%s'" msgstr "" -#: builtin.c:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "" -#: builtin.c:2781 +#: builtin.c:2783 #, c-format msgid "lshift(%lf, %lf): negative values will give strange results" msgstr "" -#: builtin.c:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "" -#: builtin.c:2785 +#: builtin.c:2787 #, c-format msgid "lshift(%lf, %lf): too large shift value will give strange results" msgstr "" -#: builtin.c:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "" -#: builtin.c:2818 +#: builtin.c:2820 #, c-format msgid "rshift(%lf, %lf): negative values will give strange results" msgstr "" -#: builtin.c:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "" -#: builtin.c:2822 +#: builtin.c:2824 #, c-format msgid "rshift(%lf, %lf): too large shift value will give strange results" msgstr "" -#: builtin.c:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "" -#: builtin.c:2855 +#: builtin.c:2857 #, c-format msgid "and(%lf, %lf): negative values will give strange results" msgstr "" -#: builtin.c:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "" -#: builtin.c:2890 +#: builtin.c:2892 #, c-format msgid "or(%lf, %lf): negative values will give strange results" msgstr "" -#: builtin.c:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "" -#: builtin.c:2928 +#: builtin.c:2930 #, c-format msgid "xor(%lf, %lf): negative values will give strange results" msgstr "" -#: builtin.c:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "" -#: builtin.c:2962 +#: builtin.c:2964 #, c-format msgid "compl(%lf): negative value will give strange results" msgstr "" -#: builtin.c:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "" diff --git a/po/it.gmo b/po/it.gmo index ac3fa30d..93ba1d26 100644 Binary files a/po/it.gmo and b/po/it.gmo differ diff --git a/po/it.po b/po/it.po index a2005288..29cb015c 100644 --- a/po/it.po +++ b/po/it.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 3.1.81\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-03-19 16:52+0100\n" "Last-Translator: Antonio Colombo \n" "Language-Team: Italian \n" @@ -40,7 +40,7 @@ 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:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -758,204 +758,204 @@ msgstr "" "substr: lunghezza %g all'indice di partenza %g supera la lunghezza del primo " "argomento (%lu)" -#: builtin.c:1655 +#: builtin.c:1656 msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" msgstr "" "strftime: il valore del 'format' in PROCINFO[\"strftime\"] di tipo numerico" -#: builtin.c:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime: il secondo argomento non numerico" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftime: il primo argomento non una stringa" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime: 'format' una stringa nulla" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime: l'argomento non una stringa" -#: builtin.c:1776 +#: builtin.c:1778 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:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "la funzione 'system' non permessa in modo 'sandbox'" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system: l'argomento non una stringa" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 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:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "riferimento a variabile non inizializzata `$%d'" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower: l'argomento non una stringa" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper: l'argomento non una stringa" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2: il primo argomento non numerico" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2: il secondo argomento non numerico" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin: l'argomento non numerico" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos: l'argomento non numerico" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand: l'argomento non numerico" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match: il terzo argomento non un vettore" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub: il terzo argomento 0, trattato come 1" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift: il primo argomento non numerico" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift: il secondo argomento non numerico" -#: builtin.c:2781 +#: builtin.c:2783 #, c-format msgid "lshift(%lf, %lf): negative values will give strange results" msgstr "lshift(%lf, %lf): valori negativi daranno risultati strani" -#: builtin.c:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "lshift(%lf, %lf): valori con decimali verranno troncati" -#: builtin.c:2785 +#: builtin.c:2787 #, 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:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift: il primo argomento non numerico" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift: il secondo argomento non numerico" -#: builtin.c:2818 +#: builtin.c:2820 #, c-format msgid "rshift(%lf, %lf): negative values will give strange results" msgstr "rshift(%lf, %lf): valori negativi daranno risultati strani" -#: builtin.c:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "rshift(%lf, %lf): valori con decimali verranno troncati" -#: builtin.c:2822 +#: builtin.c:2824 #, 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:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and: il primo argomento non numerico" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and: il secondo argomento non numerico" -#: builtin.c:2855 +#: builtin.c:2857 #, c-format msgid "and(%lf, %lf): negative values will give strange results" msgstr "and(%lf, %lf): valori negativi daranno risultati strani" -#: builtin.c:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "and(%lf, %lf): valori con decimali verranno troncati" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or: il primo argomento non numerico" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or: il secondo argomento non numerico" -#: builtin.c:2890 +#: builtin.c:2892 #, c-format msgid "or(%lf, %lf): negative values will give strange results" msgstr "or(%lf, %lf): valori negativi daranno risultati strani" -#: builtin.c:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "or(%lf, %lf): valori con decimali verranno troncati" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor: il primo argomento non numerico" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor: il secondo argomento non numerico" -#: builtin.c:2928 +#: builtin.c:2930 #, c-format msgid "xor(%lf, %lf): negative values will give strange results" msgstr "xor(%lf, %lf): valori negativi daranno risultati strani" -#: builtin.c:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "xor(%lf, %lf): valori con decimali verranno troncati" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl: l'argomento non numerico" -#: builtin.c:2962 +#: builtin.c:2964 #, c-format msgid "compl(%lf): negative value will give strange results" msgstr "compl(%lf): valore negativo dar risultati strani" -#: builtin.c:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf): valore con decimali verr troncato" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "dcgettext: `%s' non una categoria 'locale' valida" diff --git a/po/ja.gmo b/po/ja.gmo index f00953e0..3effd202 100644 Binary files a/po/ja.gmo and b/po/ja.gmo differ diff --git a/po/ja.po b/po/ja.po index c78d3215..dc42614a 100644 --- a/po/ja.po +++ b/po/ja.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-07-17 08:28+0900\n" "Last-Translator: Yasuaki Taniguchi \n" "Language-Team: Japanese \n" @@ -43,7 +43,7 @@ msgid "attempt to use scalar `%s' as an array" msgstr "スカラー `%s' を配列として使用する試みです" #: array.c:302 array.c:707 builtin.c:84 builtin.c:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -750,203 +750,203 @@ msgstr "" "substr: 開始インデックス %2$g からの長さ %1$g は第一引数の長さを超えています " "(%3$lu)" -#: builtin.c:1655 +#: builtin.c:1656 msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" msgstr "strftime: PROCINFO[\"strftime\"] の書式の値は数値型です" -#: builtin.c:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime: 非数値の第二引数を受け取りました" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftime: 非文字列の第一引数を受け取りました" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime: 空の書式文字列を受け取りました" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime: 非文字列引数を受け取りました" -#: builtin.c:1776 +#: builtin.c:1778 msgid "mktime: at least one of the values is out of the default range" msgstr "mktime: 一つ以上の値がデフォルトの範囲を超えています" -#: builtin.c:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "サンドボックスモードでは 'system' 関数は許可されていません" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system: 文字列では無い引数を受け取りました" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 eval.c:1159 eval.c:1790 eval.c:1803 #, c-format msgid "reference to uninitialized variable `%s'" msgstr "初期化されていない変数 `%s' への参照です" -#: builtin.c:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "初期化されていないフィールド `$%d' への参照です" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower: 非文字列引数を受け取りました" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper: 非文字列引数を受け取りました" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2: 非数値の第一引数を受け取りました" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2: 非数値の第二引数を受け取りました" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin: 非数値の引数を受け取りました" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos: 非数値の引数を受け取りました" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand: 非数値の引数を受け取りました" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match: 第三引数が配列ではありません" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub: 第三引数が 0 です。1 を代わりに使用します" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift: 非数値の第一引数を受け取りました" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift: 非数値の第二引数を受け取りました" -#: builtin.c:2781 +#: builtin.c:2783 #, c-format msgid "lshift(%lf, %lf): negative values will give strange results" msgstr "lshift(%lf, %lf): 負の数値を使用すると異常な結果になります" -#: builtin.c:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "lshift(%lf, %lf): 小数点以下は切り捨てられます" -#: builtin.c:2785 +#: builtin.c:2787 #, c-format msgid "lshift(%lf, %lf): too large shift value will give strange results" msgstr "lshift(%lf, %lf): シフト値が大き過ぎると異常な結果になります" -#: builtin.c:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift: 非数値の第一引数を受け取りました" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift: 非数値の第二引数を受け取りました" -#: builtin.c:2818 +#: builtin.c:2820 #, c-format msgid "rshift(%lf, %lf): negative values will give strange results" msgstr "rshift(%lf, %lf): 負の数値を使用すると異常な結果になります" -#: builtin.c:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "rshift(%lf, %lf): 小数点以下は切り捨てられます" -#: builtin.c:2822 +#: builtin.c:2824 #, c-format msgid "rshift(%lf, %lf): too large shift value will give strange results" msgstr "rshift(%lf, %lf): シフト値が大き過ぎると異常な結果になります" -#: builtin.c:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and: 非数値の第一引数を受け取りました" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and: 非数値の第二引数を受け取りました" -#: builtin.c:2855 +#: builtin.c:2857 #, c-format msgid "and(%lf, %lf): negative values will give strange results" msgstr "and(%lf, %lf): 負の数値を使用すると異常な結果になります" -#: builtin.c:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "and(%lf, %lf): 小数点以下は切り捨てられます" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or: 非数値の第一引数を受け取りました" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or: 非数値の第二引数を受け取りました" -#: builtin.c:2890 +#: builtin.c:2892 #, c-format msgid "or(%lf, %lf): negative values will give strange results" msgstr "or(%lf, %lf): 負の数値を使用すると異常な結果になります" -#: builtin.c:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "or(%lf, %lf): 小数点以下は切り捨てられます" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor: 非数値の第一引数を受け取りました" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor: 非数値の第二引数を受け取りました" -#: builtin.c:2928 +#: builtin.c:2930 #, c-format msgid "xor(%lf, %lf): negative values will give strange results" msgstr "xor(%lf, %lf): 負の数値を使用すると異常な結果になります" -#: builtin.c:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "xor(%lf, %lf): 小数点以下は切り捨てられます" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl: 非数値の引数を受け取りました" -#: builtin.c:2962 +#: builtin.c:2964 #, c-format msgid "compl(%lf): negative value will give strange results" msgstr "compl(%lf): 負の数値を使用すると異常な結果になります" -#: builtin.c:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf): 小数点以下は切り捨てられます" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "dcgettext: `%s' は無効なロケール区分です" diff --git a/po/nl.gmo b/po/nl.gmo index 0fd9c46d..4b3fd50b 100644 Binary files a/po/nl.gmo and b/po/nl.gmo differ diff --git a/po/nl.po b/po/nl.po index 641a6bee..d47100e8 100644 --- a/po/nl.po +++ b/po/nl.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-07-17 21:44+0200\n" "Last-Translator: Benno Schulenberg \n" "Language-Team: Dutch \n" @@ -46,7 +46,7 @@ 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:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -759,203 +759,203 @@ msgstr "" "substr: lengte %g bij startindex %g is groter dan de lengte van het eerste " "argument (%lu)" -#: builtin.c:1655 +#: builtin.c:1656 msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" msgstr "strftime: opmaakwaarde in PROCINFO[\"strftime\"] is numeriek" -#: builtin.c:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime: tweede argument is geen getal" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftime: eerste argument is geen string" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime: opmaakstring is leeg" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime: argument is geen string" -#: builtin.c:1776 +#: builtin.c:1778 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:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "'system'-functie is niet toegestaan in sandbox-modus" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system: argument is geen string" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 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:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "verwijzing naar ongeïnitialiseerd veld '$%d'" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower: argument is geen string" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper: argument is geen string" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2: eerste argument is geen getal" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2: tweede argument is geen getal" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin: argument is geen getal" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos: argument is geen getal" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand: argument is geen getal" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match: derde argument is geen array" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub: derde argument is 0; wordt beschouwd als 1" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift: eerste argument is geen getal" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift: tweede argument is geen getal" -#: builtin.c:2781 +#: builtin.c:2783 #, c-format msgid "lshift(%lf, %lf): negative values will give strange results" msgstr "lshift(%lf, %lf): negatieve waarden geven rare resultaten" -#: builtin.c:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "lshift(%lf, %lf): cijfers na de komma worden afgekapt" -#: builtin.c:2785 +#: builtin.c:2787 #, 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:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift: eerste argument is geen getal" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift: tweede argument is geen getal" -#: builtin.c:2818 +#: builtin.c:2820 #, c-format msgid "rshift(%lf, %lf): negative values will give strange results" msgstr "rshift(%lf, %lf): negatieve waarden geven rare resultaten" -#: builtin.c:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "rshift(%lf, %lf): cijfers na de komma worden afgekapt" -#: builtin.c:2822 +#: builtin.c:2824 #, 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:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and: eerste argument is geen getal" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and: tweede argument is geen getal" -#: builtin.c:2855 +#: builtin.c:2857 #, c-format msgid "and(%lf, %lf): negative values will give strange results" msgstr "and(%lf, %lf): negatieve waarden geven rare resultaten" -#: builtin.c:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "and(%lf, %lf): cijfers na de komma worden afgekapt" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or: eerste argument is geen getal" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or: tweede argument is geen getal" -#: builtin.c:2890 +#: builtin.c:2892 #, c-format msgid "or(%lf, %lf): negative values will give strange results" msgstr "or(%lf, %lf): negatieve waarden geven rare resultaten" -#: builtin.c:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "or(%lf, %lf): cijfers na de komma worden afgekapt" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor: eerste argument is geen getal" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor: tweede argument is geen getal" -#: builtin.c:2928 +#: builtin.c:2930 #, c-format msgid "xor(%lf, %lf): negative values will give strange results" msgstr "xor(%lf, %lf): negatieve waarden geven rare resultaten" -#: builtin.c:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "xor(%lf, %lf): cijfers na de komma worden afgekapt" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl: argument is geen getal" -#: builtin.c:2962 +#: builtin.c:2964 #, c-format msgid "compl(%lf): negative value will give strange results" msgstr "compl(%lf): negatieve waarden geven rare resultaten" -#: builtin.c:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf): cijfers na de komma worden afgekapt" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "dcgettext: '%s' is geen geldige taalregio-deelcategorie" diff --git a/po/pl.gmo b/po/pl.gmo index c90a7959..4d109afb 100644 Binary files a/po/pl.gmo and b/po/pl.gmo differ diff --git a/po/pl.po b/po/pl.po index 33f5543f..e46cb149 100644 --- a/po/pl.po +++ b/po/pl.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 3.1.81\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-05-14 11:41-0400\n" "Last-Translator: Wojciech Polak \n" "Language-Team: Polish \n" @@ -45,7 +45,7 @@ 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:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -772,206 +772,206 @@ msgstr "" "substr: długość %g zaczynając od %g przekracza długość pierwszego argumentu " "(%lu)" -#: builtin.c:1655 +#: builtin.c:1656 msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" msgstr "" "strftime: wartość formatu w PROCINFO[\"strftime\"] posiada typ numeryczny" -#: builtin.c:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime: otrzymano drugi argument, który nie jest liczbą" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftime: otrzymano pierwszy argument, który nie jest łańcuchem" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime: otrzymano pusty łańcuch formatujący" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime: otrzymano argument, który nie jest łańcuchem" -#: builtin.c:1776 +#: builtin.c:1778 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:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "funkcja 'system' nie jest dozwolona w trybie piaskownicy" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system: otrzymano argument, który nie jest łańcuchem" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 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:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "odwołanie do niezainicjowanego pola `$%d'" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower: otrzymano argument, który nie jest łańcuchem" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper: otrzymano argument, który nie jest łańcuchem" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2: otrzymano pierwszy argument, który nie jest liczbą" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2: otrzymano drugi argument, który nie jest liczbą" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin: otrzymano argument, który nie jest liczbą" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos: otrzymano argument, który nie jest liczbą" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand: otrzymano argument, który nie jest liczbą" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match: otrzymano trzeci argument, który nie jest tablicą" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub: trzeci argument 0 potraktowany jako 1" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift: otrzymano pierwszy argument, który nie jest liczbą" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift: otrzymano drugi argument, który nie jest liczbą" -#: builtin.c:2781 +#: builtin.c:2783 #, c-format msgid "lshift(%lf, %lf): negative values will give strange results" msgstr "lshift(%lf, %lf): ujemne wartości spowodują dziwne wyniki" -#: builtin.c:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "lshift(%lf, %lf): ułamkowe wartości zostaną obcięte" -#: builtin.c:2785 +#: builtin.c:2787 #, 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:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift: otrzymano pierwszy argument, który nie jest liczbą" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift: otrzymano drugi argument, który nie jest liczbą" -#: builtin.c:2818 +#: builtin.c:2820 #, c-format msgid "rshift(%lf, %lf): negative values will give strange results" msgstr "rshift(%lf, %lf): ujemne wartości spowodują dziwne wyniki" -#: builtin.c:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "rshift(%lf, %lf): ułamkowe wartości zostaną obcięte" -#: builtin.c:2822 +#: builtin.c:2824 #, 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:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and: otrzymano pierwszy argument, który nie jest liczbą" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and: otrzymano drugi argument, który nie jest liczbą" -#: builtin.c:2855 +#: builtin.c:2857 #, c-format msgid "and(%lf, %lf): negative values will give strange results" msgstr "and(%lf, %lf): ujemne wartości spowodują dziwne wyniki" -#: builtin.c:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "and(%lf, %lf): ułamkowe wartości zostaną obcięte" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or: otrzymano pierwszy argument, który nie jest liczbą" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or: otrzymano drugi argument, który nie jest liczbą" -#: builtin.c:2890 +#: builtin.c:2892 #, c-format msgid "or(%lf, %lf): negative values will give strange results" msgstr "or(%lf, %lf): ujemne wartości spowodują dziwne wyniki" -#: builtin.c:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "or(%lf, %lf): ułamkowe wartości zostaną obcięte" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor: otrzymano pierwszy argument, który nie jest liczbą" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor: otrzymano drugi argument, który nie jest liczbą" -#: builtin.c:2928 +#: builtin.c:2930 #, c-format msgid "xor(%lf, %lf): negative values will give strange results" msgstr "xor(%lf, %lf): ujemne wartości spowodują dziwne wyniki" -#: builtin.c:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "xor(%lf, %lf): ułamkowe wartości zostaną obcięte" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl: otrzymano argument, który nie jest liczbą" -#: builtin.c:2962 +#: builtin.c:2964 #, c-format msgid "compl(%lf): negative value will give strange results" msgstr "compl(%lf): ujemne wartości spowodują dziwne wyniki" -#: builtin.c:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf): ułamkowe wartości zostaną obcięte" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "dcgettext: `%s' nie jest prawidłową kategorią lokalizacji" diff --git a/po/sv.gmo b/po/sv.gmo index 0878d1e0..1d3753ed 100644 Binary files a/po/sv.gmo and b/po/sv.gmo differ diff --git a/po/sv.po b/po/sv.po index 5a9f0161..c297e525 100644 --- a/po/sv.po +++ b/po/sv.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-10-24 05:57+0200\n" +"POT-Creation-Date: 2011-11-01 22:58+0200\n" "PO-Revision-Date: 2011-07-16 15:20+0200\n" "Last-Translator: Gran Uddeborg \n" "Language-Team: Swedish \n" @@ -44,7 +44,7 @@ msgid "attempt to use scalar `%s' as an array" msgstr "frsk att anvnda skalren \"%s\" som en vektor" #: array.c:302 array.c:707 builtin.c:84 builtin.c:1384 builtin.c:1426 -#: builtin.c:1439 builtin.c:1856 builtin.c:1868 eval.c:1135 eval.c:1139 +#: builtin.c:1439 builtin.c:1858 builtin.c:1870 eval.c:1135 eval.c:1139 #: eval.c:1495 eval.c:1812 #, c-format msgid "attempt to use array `%s' in a scalar context" @@ -765,203 +765,203 @@ msgstr "" "substr: lngden %g vid startindex %g verskrider det frsta argumentets " "lngd (%lu)" -#: builtin.c:1655 +#: builtin.c:1656 msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" msgstr "strftime: formatvrde i PROCINFO[\"strftime\"] har numerisk typ" -#: builtin.c:1678 +#: builtin.c:1679 msgid "strftime: received non-numeric second argument" msgstr "strftime: fick ett ickenumeriskt andra argument" -#: builtin.c:1681 +#: builtin.c:1682 msgid "strftime: second argument less than 0 or too big for time_t" msgstr "" -#: builtin.c:1687 +#: builtin.c:1689 msgid "strftime: received non-string first argument" msgstr "strftime: fick ett frsta argument som inte r en strng" -#: builtin.c:1693 +#: builtin.c:1695 msgid "strftime: received empty format string" msgstr "strftime: fick en tom formatstrng" -#: builtin.c:1759 +#: builtin.c:1761 msgid "mktime: received non-string argument" msgstr "mktime: fick ett argument som inte r en strng" -#: builtin.c:1776 +#: builtin.c:1778 msgid "mktime: at least one of the values is out of the default range" msgstr "mktime: tminstone ett av vrdena r utanfr standardintervallet" -#: builtin.c:1811 +#: builtin.c:1813 msgid "'system' function not allowed in sandbox mode" msgstr "funktionen \"system\" r inte tillten i sandldelge" -#: builtin.c:1816 +#: builtin.c:1818 msgid "system: received non-string argument" msgstr "system: fick ett argument som inte r en strng" -#: builtin.c:1871 eval.c:1159 eval.c:1790 eval.c:1803 +#: builtin.c:1873 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:1938 +#: builtin.c:1940 #, c-format msgid "reference to uninitialized field `$%d'" msgstr "referens till icke initierat flt \"$%d\"" -#: builtin.c:2025 +#: builtin.c:2027 msgid "tolower: received non-string argument" msgstr "tolower: fick ett argument som inte r en strng" -#: builtin.c:2059 +#: builtin.c:2061 msgid "toupper: received non-string argument" msgstr "toupper: fick ett argument som inte r en strng" -#: builtin.c:2095 +#: builtin.c:2097 msgid "atan2: received non-numeric first argument" msgstr "atan2: fick ett ickenumeriskt frsta argument" -#: builtin.c:2097 +#: builtin.c:2099 msgid "atan2: received non-numeric second argument" msgstr "atan2: fick ett ickenumeriskt andra argument" -#: builtin.c:2116 +#: builtin.c:2118 msgid "sin: received non-numeric argument" msgstr "sin: fick ett ickenumeriskt argument" -#: builtin.c:2132 +#: builtin.c:2134 msgid "cos: received non-numeric argument" msgstr "cos: fick ett ickenumeriskt argument" -#: builtin.c:2185 +#: builtin.c:2187 msgid "srand: received non-numeric argument" msgstr "srand: fick ett ickenumeriskt argument" -#: builtin.c:2216 +#: builtin.c:2218 msgid "match: third argument is not an array" msgstr "match: tredje argumentet r inte en vektor" -#: builtin.c:2480 +#: builtin.c:2482 msgid "gensub: third argument of 0 treated as 1" msgstr "gensub: nollan i tredje argumentet behandlad som en etta" -#: builtin.c:2773 +#: builtin.c:2775 msgid "lshift: received non-numeric first argument" msgstr "lshift: fick ett ickenumeriskt frsta argument" -#: builtin.c:2775 +#: builtin.c:2777 msgid "lshift: received non-numeric second argument" msgstr "lshift: fick ett ickenumeriskt andra argument" -#: builtin.c:2781 +#: builtin.c:2783 #, c-format msgid "lshift(%lf, %lf): negative values will give strange results" msgstr "lshift(%lf, %lf): negativa vrden kommer ge konstiga resultat" -#: builtin.c:2783 +#: builtin.c:2785 #, c-format msgid "lshift(%lf, %lf): fractional values will be truncated" msgstr "lshift(%lf, %lf): flyttalsvrden kommer trunkeras" -#: builtin.c:2785 +#: builtin.c:2787 #, c-format msgid "lshift(%lf, %lf): too large shift value will give strange results" msgstr "lshift(%lf, %lf): fr stora skiftvrden kommer ge konstiga resultat" -#: builtin.c:2810 +#: builtin.c:2812 msgid "rshift: received non-numeric first argument" msgstr "rshift: fick ett ickenumeriskt frsta argument" -#: builtin.c:2812 +#: builtin.c:2814 msgid "rshift: received non-numeric second argument" msgstr "rshift: fick ett ickenumeriskt andra argument" -#: builtin.c:2818 +#: builtin.c:2820 #, c-format msgid "rshift(%lf, %lf): negative values will give strange results" msgstr "rshift(%lf, %lf): negativa vrden kommer ge konstiga resultat" -#: builtin.c:2820 +#: builtin.c:2822 #, c-format msgid "rshift(%lf, %lf): fractional values will be truncated" msgstr "rshift(%lf, %lf): flyttalsvrden kommer trunkeras" -#: builtin.c:2822 +#: builtin.c:2824 #, c-format msgid "rshift(%lf, %lf): too large shift value will give strange results" msgstr "rshift(%lf, %lf): fr stora skiftvrden kommer ge konstiga resultat" -#: builtin.c:2847 +#: builtin.c:2849 msgid "and: received non-numeric first argument" msgstr "and: fick ett ickenumeriskt frsta argument" -#: builtin.c:2849 +#: builtin.c:2851 msgid "and: received non-numeric second argument" msgstr "and: fick ett ickenumeriskt andra argument" -#: builtin.c:2855 +#: builtin.c:2857 #, c-format msgid "and(%lf, %lf): negative values will give strange results" msgstr "and(%lf, %lf): negativa vrden kommer ge konstiga resultat" -#: builtin.c:2857 +#: builtin.c:2859 #, c-format msgid "and(%lf, %lf): fractional values will be truncated" msgstr "and(%lf, %lf): flyttalsvrden kommer trunkeras" -#: builtin.c:2882 +#: builtin.c:2884 msgid "or: received non-numeric first argument" msgstr "or: fick ett ickenumeriskt frsta argument" -#: builtin.c:2884 +#: builtin.c:2886 msgid "or: received non-numeric second argument" msgstr "or: fick ett ickenumeriskt andra argument" -#: builtin.c:2890 +#: builtin.c:2892 #, c-format msgid "or(%lf, %lf): negative values will give strange results" msgstr "or(%lf, %lf): negativa vrden kommer ge konstiga resultat" -#: builtin.c:2892 +#: builtin.c:2894 #, c-format msgid "or(%lf, %lf): fractional values will be truncated" msgstr "or(%lf, %lf): flyttalsvrden kommer trunkeras" -#: builtin.c:2920 +#: builtin.c:2922 msgid "xor: received non-numeric first argument" msgstr "xor: fick ett ickenumeriskt frsta argument" -#: builtin.c:2922 +#: builtin.c:2924 msgid "xor: received non-numeric second argument" msgstr "xor: fick ett ickenumeriskt andra argument" -#: builtin.c:2928 +#: builtin.c:2930 #, c-format msgid "xor(%lf, %lf): negative values will give strange results" msgstr "xor(%lf, %lf): negativa vrden kommer ge konstiga resultat" -#: builtin.c:2930 +#: builtin.c:2932 #, c-format msgid "xor(%lf, %lf): fractional values will be truncated" msgstr "xor(%lf, %lf): flyttalsvrden kommer trunkeras" -#: builtin.c:2954 builtin.c:2960 +#: builtin.c:2956 builtin.c:2962 msgid "compl: received non-numeric argument" msgstr "compl: fick ett ickenumeriskt argument" -#: builtin.c:2962 +#: builtin.c:2964 #, c-format msgid "compl(%lf): negative value will give strange results" msgstr "compl(%lf): negativa vrden kommer ge konstiga resultat" -#: builtin.c:2964 +#: builtin.c:2966 #, c-format msgid "compl(%lf): fractional value will be truncated" msgstr "compl(%lf): flyttalsvrden kommer trunkeras" -#: builtin.c:3133 +#: builtin.c:3135 #, c-format msgid "dcgettext: `%s' is not a valid locale category" msgstr "dcgettext: \"%s\" r inte en giltig lokalkategori" diff --git a/version.c b/version.c index cf56a088..1ebd3d6e 100644 --- a/version.c +++ b/version.c @@ -1,3 +1,3 @@ #include "config.h" -const char *version_string = "GNU Awk 4.0.0c"; +const char *version_string = "GNU Awk 4.0.0d"; -- cgit v1.2.3 From 2a63ca5d9af44de631e7853c8320357c6f5d6a3a Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 6 Nov 2011 22:02:31 +0200 Subject: Improve discussion of sorted for traversal. --- doc/ChangeLog | 5 + doc/gawk.info | 501 +++++++++++++++++++++++++++++++--------------------------- doc/gawk.texi | 66 ++++++-- 3 files changed, 319 insertions(+), 253 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 53ab79a9..e4855cab 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/doc/gawk.info b/doc/gawk.info index 0606273e..53fe12d8 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -10203,7 +10203,7 @@ File: gawk.info, Node: Multi-scanning, Up: Multi-dimensional -------------------------------------- There is no special `for' statement for scanning a "multidimensional" -array. There cannot be one, because, in truth, there are no +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. @@ -10223,7 +10223,7 @@ 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 + 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 @@ -10242,8 +10242,9 @@ File: gawk.info, Node: Arrays of Arrays, Prev: Multi-dimensional, Up: Arrays 8.6 Arrays of Arrays ==================== -`gawk' supports arrays of arrays. Elements of a subarray are referred -to by their own indices enclosed in square brackets, just like the +`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': @@ -13603,7 +13604,7 @@ of the previous functions: -| data[10] = one -| data[20] = two -| - -| Sort function: cmp_num_str_val Sort all numbers before all strings + -| Sort function: cmp_num_str_val Sort all numeric values before all strings -| data[one] = 10 -| data[two] = 20 -| data[100] = 100 @@ -13611,7 +13612,7 @@ of the previous functions: -| data[20] = two Consider sorting the entries of a GNU/Linux system password file -according to login names. The following program sorts records by a +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 @@ -13727,13 +13728,17 @@ based on comparing the indices in ascending order," or "sort based on comparing the values in descending order." Having to write a simple comparison function for this purpose for use in all of your programs becomes tedious. For the common simple cases, `gawk' provides the -option of supplying special names that do the requested sorting for you. +option of using special names that do the requested sorting for you. You can think of them as "predefined" sorting functions, if you like, although the names purposely include characters that are not valid in real `awk' function names. The following special values 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' @@ -13759,7 +13764,8 @@ real `awk' function names. 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) + 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. @@ -13778,12 +13784,6 @@ real `awk' function names. Element values, treated as numbers, ordered from high to low. Subarrays, if present, come out first. -`"@unsorted"' - Array elements are processed in arbitrary order, which is the - normal `awk' behavior. You can also get the normal behavior by just - deleting the `"sorted_in"' element from the `PROCINFO' array, if - it previously had a value assigned to it. - 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. @@ -13814,6 +13814,31 @@ 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 function, you should see if it's defined and save and + restore the value: + + function myfunct(p1, p2, save_sorted) + { + ... + 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. + ---------- Footnotes ---------- (1) When two elements compare as equal, the C `qsort()' function @@ -13842,7 +13867,9 @@ String Functions::) for sorting arrays. For example: 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 array elements are compared as strings. +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 @@ -25015,7 +25042,7 @@ Index * arrays, sorting: Array Sorting Functions. (line 6) * arrays, sorting, IGNORECASE variable and: Array Sorting Functions. - (line 78) + (line 80) * arrays, sparse: Array Intro. (line 71) * arrays, subscripts: Numeric Array Subscripts. (line 6) @@ -26060,7 +26087,7 @@ Index * gawk, functions, adding: Dynamic Extensions. (line 10) * gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42) * gawk, IGNORECASE variable in <1>: Array Sorting Functions. - (line 78) + (line 80) * 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) @@ -26220,13 +26247,13 @@ Index * igawk.sh program: Igawk Program. (line 124) * ignore debugger command: Breakpoint Control. (line 86) * IGNORECASE variable <1>: Array Sorting Functions. - (line 78) + (line 80) * 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 78) + (line 80) * IGNORECASE variable, array subscripts and: Array Intro. (line 92) * IGNORECASE variable, in example programs: Library Functions. (line 42) @@ -26909,7 +26936,7 @@ Index * redirection of input: Getline/File. (line 6) * redirection of output: Redirection. (line 6) * reference counting, sorting arrays: Array Sorting Functions. - (line 72) + (line 74) * regexp constants <1>: Comparison Operators. (line 103) * regexp constants <2>: Regexp Constants. (line 6) @@ -27068,7 +27095,7 @@ Index * side effects, array indexing: Reference to Elements. (line 42) * side effects, asort() function: Array Sorting Functions. - (line 22) + (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) @@ -27647,221 +27674,221 @@ Node: Numeric Array Subscripts424017 Node: Uninitialized Subscripts426200 Node: Multi-dimensional427828 Node: Multi-scanning430922 -Node: Arrays of Arrays432506 -Node: Functions437083 -Node: Built-in437905 -Node: Calling Built-in438983 -Node: Numeric Functions440971 -Ref: Numeric Functions-Footnote-1444736 -Ref: Numeric Functions-Footnote-2445093 -Ref: Numeric Functions-Footnote-3445141 -Node: String Functions445410 -Ref: String Functions-Footnote-1468907 -Ref: String Functions-Footnote-2469036 -Ref: String Functions-Footnote-3469284 -Node: Gory Details469371 -Ref: table-sub-escapes471050 -Ref: table-sub-posix-92472404 -Ref: table-sub-proposed473747 -Ref: table-posix-sub475097 -Ref: table-gensub-escapes476643 -Ref: Gory Details-Footnote-1477850 -Ref: Gory Details-Footnote-2477901 -Node: I/O Functions478052 -Ref: I/O Functions-Footnote-1484707 -Node: Time Functions484854 -Ref: Time Functions-Footnote-1495746 -Ref: Time Functions-Footnote-2495814 -Ref: Time Functions-Footnote-3495972 -Ref: Time Functions-Footnote-4496083 -Ref: Time Functions-Footnote-5496195 -Ref: Time Functions-Footnote-6496422 -Node: Bitwise Functions496688 -Ref: table-bitwise-ops497246 -Ref: Bitwise Functions-Footnote-1501406 -Node: Type Functions501590 -Node: I18N Functions502060 -Node: User-defined503687 -Node: Definition Syntax504491 -Ref: Definition Syntax-Footnote-1509401 -Node: Function Example509470 -Node: Function Caveats512064 -Node: Calling A Function512485 -Node: Variable Scope513600 -Node: Pass By Value/Reference515575 -Node: Return Statement519015 -Node: Dynamic Typing521996 -Node: Indirect Calls522731 -Node: Internationalization532416 -Node: I18N and L10N533842 -Node: Explaining gettext534528 -Ref: Explaining gettext-Footnote-1539594 -Ref: Explaining gettext-Footnote-2539778 -Node: Programmer i18n539943 -Node: Translator i18n544143 -Node: String Extraction544936 -Ref: String Extraction-Footnote-1545897 -Node: Printf Ordering545983 -Ref: Printf Ordering-Footnote-1548767 -Node: I18N Portability548831 -Ref: I18N Portability-Footnote-1551280 -Node: I18N Example551343 -Ref: I18N Example-Footnote-1553978 -Node: Gawk I18N554050 -Node: Advanced Features554667 -Node: Nondecimal Data556180 -Node: Array Sorting557763 -Node: Controlling Array Traversal558463 -Node: Controlling Scanning With A Function559210 -Node: Controlling Scanning566913 -Ref: Controlling Scanning-Footnote-1570714 -Node: Array Sorting Functions571030 -Ref: Array Sorting Functions-Footnote-1574546 -Ref: Array Sorting Functions-Footnote-2574639 -Node: Two-way I/O574833 -Ref: Two-way I/O-Footnote-1580265 -Node: TCP/IP Networking580335 -Node: Profiling583179 -Node: Library Functions590653 -Ref: Library Functions-Footnote-1593660 -Node: Library Names593831 -Ref: Library Names-Footnote-1597302 -Ref: Library Names-Footnote-2597522 -Node: General Functions597608 -Node: Strtonum Function598561 -Node: Assert Function601491 -Node: Round Function604817 -Node: Cliff Random Function606360 -Node: Ordinal Functions607376 -Ref: Ordinal Functions-Footnote-1610446 -Ref: Ordinal Functions-Footnote-2610698 -Node: Join Function610907 -Ref: Join Function-Footnote-1612678 -Node: Gettimeofday Function612878 -Node: Data File Management616593 -Node: Filetrans Function617225 -Node: Rewind Function621364 -Node: File Checking622751 -Node: Empty Files623845 -Node: Ignoring Assigns626075 -Node: Getopt Function627628 -Ref: Getopt Function-Footnote-1638932 -Node: Passwd Functions639135 -Ref: Passwd Functions-Footnote-1648110 -Node: Group Functions648198 -Node: Walking Arrays656282 -Node: Sample Programs657851 -Node: Running Examples658516 -Node: Clones659244 -Node: Cut Program660468 -Node: Egrep Program670313 -Ref: Egrep Program-Footnote-1678086 -Node: Id Program678196 -Node: Split Program681812 -Ref: Split Program-Footnote-1685331 -Node: Tee Program685459 -Node: Uniq Program688262 -Node: Wc Program695691 -Ref: Wc Program-Footnote-1699957 -Ref: Wc Program-Footnote-2700157 -Node: Miscellaneous Programs700249 -Node: Dupword Program701437 -Node: Alarm Program703468 -Node: Translate Program708217 -Ref: Translate Program-Footnote-1712604 -Ref: Translate Program-Footnote-2712832 -Node: Labels Program712966 -Ref: Labels Program-Footnote-1716337 -Node: Word Sorting716421 -Node: History Sorting720305 -Node: Extract Program722144 -Ref: Extract Program-Footnote-1729627 -Node: Simple Sed729755 -Node: Igawk Program732817 -Ref: Igawk Program-Footnote-1747974 -Ref: Igawk Program-Footnote-2748175 -Node: Anagram Program748313 -Node: Signature Program751381 -Node: Debugger752481 -Node: Debugging753392 -Node: Debugging Concepts753805 -Node: Debugging Terms755661 -Node: Awk Debugging758284 -Node: Sample dgawk session759176 -Node: dgawk invocation759668 -Node: Finding The Bug760850 -Node: List of Debugger Commands767336 -Node: Breakpoint Control768647 -Node: Dgawk Execution Control772283 -Node: Viewing And Changing Data775634 -Node: Dgawk Stack778971 -Node: Dgawk Info780431 -Node: Miscellaneous Dgawk Commands784379 -Node: Readline Support789807 -Node: Dgawk Limitations790645 -Node: Language History792834 -Node: V7/SVR3.1794346 -Node: SVR4796667 -Node: POSIX798109 -Node: BTL799117 -Node: POSIX/GNU799851 -Node: Common Extensions805002 -Node: Ranges and Locales806109 -Ref: Ranges and Locales-Footnote-1810716 -Node: Contributors810937 -Node: Installation815199 -Node: Gawk Distribution816093 -Node: Getting816577 -Node: Extracting817403 -Node: Distribution contents819095 -Node: Unix Installation824317 -Node: Quick Installation824934 -Node: Additional Configuration Options826896 -Node: Configuration Philosophy828373 -Node: Non-Unix Installation830715 -Node: PC Installation831173 -Node: PC Binary Installation832472 -Node: PC Compiling834320 -Node: PC Testing837264 -Node: PC Using838440 -Node: Cygwin842625 -Node: MSYS843625 -Node: VMS Installation844139 -Node: VMS Compilation844742 -Ref: VMS Compilation-Footnote-1845749 -Node: VMS Installation Details845807 -Node: VMS Running847442 -Node: VMS Old Gawk849049 -Node: Bugs849523 -Node: Other Versions853375 -Node: Notes858656 -Node: Compatibility Mode859348 -Node: Additions860131 -Node: Accessing The Source860943 -Node: Adding Code862368 -Node: New Ports868335 -Node: Dynamic Extensions872448 -Node: Internals873824 -Node: Plugin License882927 -Node: Sample Library883561 -Node: Internal File Description884247 -Node: Internal File Ops887962 -Ref: Internal File Ops-Footnote-1892743 -Node: Using Internal File Ops892883 -Node: Future Extensions895260 -Node: Basic Concepts897764 -Node: Basic High Level898521 -Ref: Basic High Level-Footnote-1902556 -Node: Basic Data Typing902741 -Node: Floating Point Issues907266 -Node: String Conversion Precision908349 -Ref: String Conversion Precision-Footnote-1910049 -Node: Unexpected Results910158 -Node: POSIX Floating Point Problems911984 -Ref: POSIX Floating Point Problems-Footnote-1915689 -Node: Glossary915727 -Node: Copying940703 -Node: GNU Free Documentation License978260 -Node: Index1003397 +Node: Arrays of Arrays432513 +Node: Functions437158 +Node: Built-in437980 +Node: Calling Built-in439058 +Node: Numeric Functions441046 +Ref: Numeric Functions-Footnote-1444811 +Ref: Numeric Functions-Footnote-2445168 +Ref: Numeric Functions-Footnote-3445216 +Node: String Functions445485 +Ref: String Functions-Footnote-1468982 +Ref: String Functions-Footnote-2469111 +Ref: String Functions-Footnote-3469359 +Node: Gory Details469446 +Ref: table-sub-escapes471125 +Ref: table-sub-posix-92472479 +Ref: table-sub-proposed473822 +Ref: table-posix-sub475172 +Ref: table-gensub-escapes476718 +Ref: Gory Details-Footnote-1477925 +Ref: Gory Details-Footnote-2477976 +Node: I/O Functions478127 +Ref: I/O Functions-Footnote-1484782 +Node: Time Functions484929 +Ref: Time Functions-Footnote-1495821 +Ref: Time Functions-Footnote-2495889 +Ref: Time Functions-Footnote-3496047 +Ref: Time Functions-Footnote-4496158 +Ref: Time Functions-Footnote-5496270 +Ref: Time Functions-Footnote-6496497 +Node: Bitwise Functions496763 +Ref: table-bitwise-ops497321 +Ref: Bitwise Functions-Footnote-1501481 +Node: Type Functions501665 +Node: I18N Functions502135 +Node: User-defined503762 +Node: Definition Syntax504566 +Ref: Definition Syntax-Footnote-1509476 +Node: Function Example509545 +Node: Function Caveats512139 +Node: Calling A Function512560 +Node: Variable Scope513675 +Node: Pass By Value/Reference515650 +Node: Return Statement519090 +Node: Dynamic Typing522071 +Node: Indirect Calls522806 +Node: Internationalization532491 +Node: I18N and L10N533917 +Node: Explaining gettext534603 +Ref: Explaining gettext-Footnote-1539669 +Ref: Explaining gettext-Footnote-2539853 +Node: Programmer i18n540018 +Node: Translator i18n544218 +Node: String Extraction545011 +Ref: String Extraction-Footnote-1545972 +Node: Printf Ordering546058 +Ref: Printf Ordering-Footnote-1548842 +Node: I18N Portability548906 +Ref: I18N Portability-Footnote-1551355 +Node: I18N Example551418 +Ref: I18N Example-Footnote-1554053 +Node: Gawk I18N554125 +Node: Advanced Features554742 +Node: Nondecimal Data556255 +Node: Array Sorting557838 +Node: Controlling Array Traversal558538 +Node: Controlling Scanning With A Function559285 +Node: Controlling Scanning566994 +Ref: Controlling Scanning-Footnote-1571648 +Node: Array Sorting Functions571964 +Ref: Array Sorting Functions-Footnote-1575613 +Ref: Array Sorting Functions-Footnote-2575706 +Node: Two-way I/O575900 +Ref: Two-way I/O-Footnote-1581332 +Node: TCP/IP Networking581402 +Node: Profiling584246 +Node: Library Functions591720 +Ref: Library Functions-Footnote-1594727 +Node: Library Names594898 +Ref: Library Names-Footnote-1598369 +Ref: Library Names-Footnote-2598589 +Node: General Functions598675 +Node: Strtonum Function599628 +Node: Assert Function602558 +Node: Round Function605884 +Node: Cliff Random Function607427 +Node: Ordinal Functions608443 +Ref: Ordinal Functions-Footnote-1611513 +Ref: Ordinal Functions-Footnote-2611765 +Node: Join Function611974 +Ref: Join Function-Footnote-1613745 +Node: Gettimeofday Function613945 +Node: Data File Management617660 +Node: Filetrans Function618292 +Node: Rewind Function622431 +Node: File Checking623818 +Node: Empty Files624912 +Node: Ignoring Assigns627142 +Node: Getopt Function628695 +Ref: Getopt Function-Footnote-1639999 +Node: Passwd Functions640202 +Ref: Passwd Functions-Footnote-1649177 +Node: Group Functions649265 +Node: Walking Arrays657349 +Node: Sample Programs658918 +Node: Running Examples659583 +Node: Clones660311 +Node: Cut Program661535 +Node: Egrep Program671380 +Ref: Egrep Program-Footnote-1679153 +Node: Id Program679263 +Node: Split Program682879 +Ref: Split Program-Footnote-1686398 +Node: Tee Program686526 +Node: Uniq Program689329 +Node: Wc Program696758 +Ref: Wc Program-Footnote-1701024 +Ref: Wc Program-Footnote-2701224 +Node: Miscellaneous Programs701316 +Node: Dupword Program702504 +Node: Alarm Program704535 +Node: Translate Program709284 +Ref: Translate Program-Footnote-1713671 +Ref: Translate Program-Footnote-2713899 +Node: Labels Program714033 +Ref: Labels Program-Footnote-1717404 +Node: Word Sorting717488 +Node: History Sorting721372 +Node: Extract Program723211 +Ref: Extract Program-Footnote-1730694 +Node: Simple Sed730822 +Node: Igawk Program733884 +Ref: Igawk Program-Footnote-1749041 +Ref: Igawk Program-Footnote-2749242 +Node: Anagram Program749380 +Node: Signature Program752448 +Node: Debugger753548 +Node: Debugging754459 +Node: Debugging Concepts754872 +Node: Debugging Terms756728 +Node: Awk Debugging759351 +Node: Sample dgawk session760243 +Node: dgawk invocation760735 +Node: Finding The Bug761917 +Node: List of Debugger Commands768403 +Node: Breakpoint Control769714 +Node: Dgawk Execution Control773350 +Node: Viewing And Changing Data776701 +Node: Dgawk Stack780038 +Node: Dgawk Info781498 +Node: Miscellaneous Dgawk Commands785446 +Node: Readline Support790874 +Node: Dgawk Limitations791712 +Node: Language History793901 +Node: V7/SVR3.1795413 +Node: SVR4797734 +Node: POSIX799176 +Node: BTL800184 +Node: POSIX/GNU800918 +Node: Common Extensions806069 +Node: Ranges and Locales807176 +Ref: Ranges and Locales-Footnote-1811783 +Node: Contributors812004 +Node: Installation816266 +Node: Gawk Distribution817160 +Node: Getting817644 +Node: Extracting818470 +Node: Distribution contents820162 +Node: Unix Installation825384 +Node: Quick Installation826001 +Node: Additional Configuration Options827963 +Node: Configuration Philosophy829440 +Node: Non-Unix Installation831782 +Node: PC Installation832240 +Node: PC Binary Installation833539 +Node: PC Compiling835387 +Node: PC Testing838331 +Node: PC Using839507 +Node: Cygwin843692 +Node: MSYS844692 +Node: VMS Installation845206 +Node: VMS Compilation845809 +Ref: VMS Compilation-Footnote-1846816 +Node: VMS Installation Details846874 +Node: VMS Running848509 +Node: VMS Old Gawk850116 +Node: Bugs850590 +Node: Other Versions854442 +Node: Notes859723 +Node: Compatibility Mode860415 +Node: Additions861198 +Node: Accessing The Source862010 +Node: Adding Code863435 +Node: New Ports869402 +Node: Dynamic Extensions873515 +Node: Internals874891 +Node: Plugin License883994 +Node: Sample Library884628 +Node: Internal File Description885314 +Node: Internal File Ops889029 +Ref: Internal File Ops-Footnote-1893810 +Node: Using Internal File Ops893950 +Node: Future Extensions896327 +Node: Basic Concepts898831 +Node: Basic High Level899588 +Ref: Basic High Level-Footnote-1903623 +Node: Basic Data Typing903808 +Node: Floating Point Issues908333 +Node: String Conversion Precision909416 +Ref: String Conversion Precision-Footnote-1911116 +Node: Unexpected Results911225 +Node: POSIX Floating Point Problems913051 +Ref: POSIX Floating Point Problems-Footnote-1916756 +Node: Glossary916794 +Node: Copying941770 +Node: GNU Free Documentation License979327 +Node: Index1004464  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 760340d6..fa145bb1 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -13785,8 +13785,9 @@ the program produces the following output: @subsection Scanning Multidimensional Arrays There is no special @code{for} statement for scanning a -``multidimensional'' array. There cannot be one, because, in truth, there -are no multidimensional arrays or elements---there is only 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 @@ -13813,7 +13814,7 @@ 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 +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 @@ -13833,7 +13834,8 @@ separate indices is recovered. @node Arrays of Arrays @section Arrays of Arrays -@command{gawk} supports arrays of +@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} @@ -18314,7 +18316,7 @@ $ @kbd{gawk -f compdemo.awk} @print{} data[10] = one @print{} data[20] = two @print{} -@print{} Sort function: cmp_num_str_val @ii{Sort all numbers before all strings} +@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 @@ -18323,7 +18325,7 @@ $ @kbd{gawk -f compdemo.awk} @end example Consider sorting the entries of a GNU/Linux system password file -according to login names. The following program sorts records +according to login name. The following program sorts records by a specific field position and can be used for this purpose: @example @@ -18464,7 +18466,7 @@ or ``sort based on comparing the values in descending order.'' Having to write a simple comparison function for this purpose for use in all of your programs becomes tedious. For the common simple cases, @command{gawk} provides -the option of supplying special names that do the requested +the option of using special names that do the requested sorting for you. You can think of them as ``predefined'' sorting functions, if you like, although the names purposely include characters @@ -18473,6 +18475,10 @@ that are not valid in real @command{awk} function names. The following special values 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} @@ -18498,12 +18504,13 @@ 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 +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.} +across different environments.}, which @command{gawk} uses internally +to perform the sorting. @item "@@ind_str_desc" Reverse order from the most basic sort. @@ -18521,12 +18528,6 @@ 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. - -@item "@@unsorted" -Array elements are processed in arbitrary order, which is the normal -@command{awk} behavior. You can also get the normal behavior by just -deleting the @code{"sorted_in"} element from the @code{PROCINFO} array, -if it previously had a value assigned to it. @end table The array traversal order is determined before the @code{for} loop @@ -18561,6 +18562,36 @@ 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 function, you should see if it's defined and save and restore the value: + +@example +function myfunct(p1, p2, save_sorted) +@{ + @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. +@end itemize + @node Array Sorting Functions @subsection Sorting Array Values and Indices with @command{gawk} @@ -18588,7 +18619,10 @@ 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 array elements are compared as strings. +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 -- cgit v1.2.3 From 3f6a81b5812d5f527aea23e77754732374a10c55 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 8 Nov 2011 21:20:26 +0200 Subject: More documentation changes. --- NEWS | 10 + doc/ChangeLog | 5 + doc/gawk.info | 2014 ++++++++++++++++++++++++++++----------------------------- doc/gawk.texi | 1167 ++++++++++++++++----------------- 4 files changed, 1559 insertions(+), 1637 deletions(-) diff --git a/NEWS b/NEWS index 0106f7ce..0745c32d 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,16 @@ 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. + +XXX. 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 --------------------------- diff --git a/doc/ChangeLog b/doc/ChangeLog index e4855cab..64fe7a38 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/doc/gawk.info b/doc/gawk.info index 53fe12d8..06133a6b 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -15,7 +15,7 @@ Foundation, Inc. This is Edition 4 of `GAWK: Effective AWK Programming: A User's -Guide for GNU Awk', for the 4.0.0 (or later) version of the GNU +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 @@ -47,7 +47,7 @@ Foundation, Inc. This is Edition 4 of `GAWK: Effective AWK Programming: A User's -Guide for GNU Awk', for the 4.0.0 (or later) version of the GNU +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 @@ -109,439 +109,399 @@ texts being (a) (see below), and with the Back-Cover Texts being (b) * 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. -* 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"]. -* Controlling Scanning With A Function:: Using a function to control scanning. -* Controlling Scanning:: Controlling the order in which arrays - are scanned. -* 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. +* 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. @@ -9641,6 +9601,8 @@ one at a time, and traversing all of the elements in 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 @@ -9873,7 +9835,7 @@ easy improvement to the program's `END' rule, as follows: }  -File: gawk.info, Node: Scanning an Array, Prev: Array Example, Up: Array Basics +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 --------------------------------------- @@ -9928,15 +9890,148 @@ 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. - As an extension, `gawk' makes it possible for you to loop over the -elements of an array in order, based on the value of -`PROCINFO["sorted_in"]' (*note Auto-set::). This is an advanced -feature, so discussion of it is delayed until *note Controlling Array -Traversal::. + +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 mechanims 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 @@ -13462,8 +13557,8 @@ File: gawk.info, Node: Array Sorting, Next: Two-way I/O, Prev: Nondecimal Dat 11.2 Controlling Array Traversal and Array Sorting ================================================== -`gawk' lets you control the order in which `for (i in array)' loops -will traverse an array. +`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. @@ -13487,24 +13582,17 @@ 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; this node describes how. - -* Menu: - -* Controlling Scanning With A Function:: Using a function to control scanning. -* Controlling Scanning:: Controlling the order in which arrays - are scanned. - - -File: gawk.info, Node: Controlling Scanning With A Function, Next: Controlling Scanning, Up: Controlling Array Traversal +you do this. -11.2.1.1 Array Scanning Using A User-defined Function -..................................................... + *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. -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: + 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) { @@ -13514,8 +13602,9 @@ The comparison function should be defined with at least four arguments: 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. The three possible return values are interpreted this way: +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. @@ -13642,9 +13731,8 @@ specific field position and can be used for this purpose: The first field in each entry of the password file is the user's login name, and the fields are seperated by colons. Each record -defines a subarray (*note Arrays of Arrays::), with each field as an -element in the subarray. Running the program produces the following -output: +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 @@ -13713,140 +13801,6 @@ 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: Controlling Scanning, Prev: Controlling Scanning With A Function, Up: Controlling Array Traversal - -11.2.1.2 Controlling Array Scanning Order -......................................... - -As described in *note Controlling Scanning With A Function::, you can -provide the name of a function as the value of `PROCINFO["sorted_in"]' -to specify custom sorting criteria. - - Often, though, you may wish to do something simple, such as "sort -based on comparing the indices in ascending order," or "sort based on -comparing the values in descending order." Having to write a simple -comparison function for this purpose for use in all of your programs -becomes tedious. For the common simple cases, `gawk' provides the -option of using special names that do the requested sorting for you. -You can think of them as "predefined" sorting functions, if you like, -although the names purposely include characters that are not valid in -real `awk' function names. - - The following special values 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. - -`"@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 function, you should see if it's defined and save and - restore the value: - - function myfunct(p1, p2, save_sorted) - { - ... - 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. - - ---------- 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: Array Sorting Functions, Prev: Controlling Array Traversal, Up: Array Sorting @@ -13854,10 +13808,10 @@ File: gawk.info, Node: Array Sorting Functions, Prev: Controlling Array Traver --------------------------------------------------- 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: +`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) @@ -13886,8 +13840,9 @@ 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 -the name of a user-defined function, or one of the predefined names -that `gawk' provides (*note Controlling Scanning With A Function::). +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 @@ -20418,7 +20373,7 @@ There are three ways to get GNU software: 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.0.tar.gz + 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 @@ -20437,26 +20392,26 @@ 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.0.tar.gz'), + 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.0.tar.gz | tar -xvpf - + 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.0.tar.gz + tar -xvpzf gawk-4.0.1.tar.gz -Extracting the archive creates a directory named `gawk-4.0.0' in the +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 0, but when retrieving distributions, you should get the +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 @@ -20650,7 +20605,7 @@ 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.0'. Like most GNU software, `gawk' is configured +`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 @@ -21060,8 +21015,8 @@ 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.0.tar.gz - cd gawk-4.0.0 + tar -xvpzf gawk-4.0.1.tar.gz + cd gawk-4.0.1 ./configure make @@ -25042,7 +24997,7 @@ Index * arrays, sorting: Array Sorting Functions. (line 6) * arrays, sorting, IGNORECASE variable and: Array Sorting Functions. - (line 80) + (line 81) * arrays, sparse: Array Intro. (line 71) * arrays, subscripts: Numeric Array Subscripts. (line 6) @@ -26087,7 +26042,7 @@ Index * gawk, functions, adding: Dynamic Extensions. (line 10) * gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42) * gawk, IGNORECASE variable in <1>: Array Sorting Functions. - (line 80) + (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) @@ -26247,13 +26202,13 @@ Index * igawk.sh program: Igawk Program. (line 124) * ignore debugger command: Breakpoint Control. (line 86) * IGNORECASE variable <1>: Array Sorting Functions. - (line 80) + (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 80) + (line 81) * IGNORECASE variable, array subscripts and: Array Intro. (line 92) * IGNORECASE variable, in example programs: Library Functions. (line 42) @@ -26936,7 +26891,7 @@ Index * redirection of input: Getline/File. (line 6) * redirection of output: Redirection. (line 6) * reference counting, sorting arrays: Array Sorting Functions. - (line 74) + (line 75) * regexp constants <1>: Comparison Operators. (line 103) * regexp constants <2>: Regexp Constants. (line 6) @@ -27478,417 +27433,416 @@ Index  Tag Table: Node: Top1346 -Node: Foreword33440 -Node: Preface37785 -Ref: Preface-Footnote-140838 -Ref: Preface-Footnote-240944 -Node: History41176 -Node: Names43567 -Ref: Names-Footnote-145044 -Node: This Manual45116 -Ref: This Manual-Footnote-150063 -Node: Conventions50163 -Node: Manual History52297 -Ref: Manual History-Footnote-155567 -Ref: Manual History-Footnote-255608 -Node: How To Contribute55682 -Node: Acknowledgments56826 -Node: Getting Started61157 -Node: Running gawk63536 -Node: One-shot64722 -Node: Read Terminal65947 -Ref: Read Terminal-Footnote-167597 -Ref: Read Terminal-Footnote-267873 -Node: Long68044 -Node: Executable Scripts69420 -Ref: Executable Scripts-Footnote-171289 -Ref: Executable Scripts-Footnote-271391 -Node: Comments71842 -Node: Quoting74309 -Node: DOS Quoting78932 -Node: Sample Data Files79607 -Node: Very Simple82639 -Node: Two Rules87238 -Node: More Complex89385 -Ref: More Complex-Footnote-192315 -Node: Statements/Lines92400 -Ref: Statements/Lines-Footnote-196862 -Node: Other Features97127 -Node: When98055 -Node: Invoking Gawk100202 -Node: Command Line101587 -Node: Options102370 -Ref: Options-Footnote-1115807 -Node: Other Arguments115832 -Node: Naming Standard Input118490 -Node: Environment Variables119584 -Node: AWKPATH Variable120028 -Ref: AWKPATH Variable-Footnote-1122625 -Node: Other Environment Variables122885 -Node: Exit Status125225 -Node: Include Files125900 -Node: Obsolete129385 -Node: Undocumented130071 -Node: Regexp130312 -Node: Regexp Usage131701 -Node: Escape Sequences133727 -Node: Regexp Operators139490 -Ref: Regexp Operators-Footnote-1146687 -Ref: Regexp Operators-Footnote-2146834 -Node: Bracket Expressions146932 -Ref: table-char-classes148822 -Node: GNU Regexp Operators151345 -Node: Case-sensitivity155068 -Ref: Case-sensitivity-Footnote-1158036 -Ref: Case-sensitivity-Footnote-2158271 -Node: Leftmost Longest158379 -Node: Computed Regexps159580 -Node: Reading Files162990 -Node: Records164931 -Ref: Records-Footnote-1173605 -Node: Fields173642 -Ref: Fields-Footnote-1176675 -Node: Nonconstant Fields176761 -Node: Changing Fields178963 -Node: Field Separators184941 -Node: Default Field Splitting187570 -Node: Regexp Field Splitting188687 -Node: Single Character Fields192029 -Node: Command Line Field Separator193088 -Node: Field Splitting Summary196529 -Ref: Field Splitting Summary-Footnote-1199721 -Node: Constant Size199822 -Node: Splitting By Content204406 -Ref: Splitting By Content-Footnote-1208132 -Node: Multiple Line208172 -Ref: Multiple Line-Footnote-1214019 -Node: Getline214198 -Node: Plain Getline216426 -Node: Getline/Variable218515 -Node: Getline/File219656 -Node: Getline/Variable/File220978 -Ref: Getline/Variable/File-Footnote-1222577 -Node: Getline/Pipe222664 -Node: Getline/Variable/Pipe225224 -Node: Getline/Coprocess226331 -Node: Getline/Variable/Coprocess227574 -Node: Getline Notes228288 -Node: Getline Summary230230 -Ref: table-getline-variants230573 -Node: Command line directories231429 -Node: Printing232054 -Node: Print233685 -Node: Print Examples235022 -Node: Output Separators237806 -Node: OFMT239566 -Node: Printf240924 -Node: Basic Printf241830 -Node: Control Letters243369 -Node: Format Modifiers247181 -Node: Printf Examples253190 -Node: Redirection255905 -Node: Special Files262889 -Node: Special FD263422 -Ref: Special FD-Footnote-1267047 -Node: Special Network267121 -Node: Special Caveats267971 -Node: Close Files And Pipes268767 -Ref: Close Files And Pipes-Footnote-1275790 -Ref: Close Files And Pipes-Footnote-2275938 -Node: Expressions276088 -Node: Values277220 -Node: Constants277896 -Node: Scalar Constants278576 -Ref: Scalar Constants-Footnote-1279435 -Node: Nondecimal-numbers279617 -Node: Regexp Constants282676 -Node: Using Constant Regexps283151 -Node: Variables286206 -Node: Using Variables286861 -Node: Assignment Options288585 -Node: Conversion290457 -Ref: table-locale-affects295833 -Ref: Conversion-Footnote-1296457 -Node: All Operators296566 -Node: Arithmetic Ops297196 -Node: Concatenation299701 -Ref: Concatenation-Footnote-1302494 -Node: Assignment Ops302614 -Ref: table-assign-ops307602 -Node: Increment Ops309010 -Node: Truth Values and Conditions312480 -Node: Truth Values313563 -Node: Typing and Comparison314612 -Node: Variable Typing315401 -Ref: Variable Typing-Footnote-1319298 -Node: Comparison Operators319420 -Ref: table-relational-ops319830 -Node: POSIX String Comparison323379 -Ref: POSIX String Comparison-Footnote-1324335 -Node: Boolean Ops324473 -Ref: Boolean Ops-Footnote-1328551 -Node: Conditional Exp328642 -Node: Function Calls330374 -Node: Precedence333968 -Node: Locales337637 -Node: Patterns and Actions338726 -Node: Pattern Overview339780 -Node: Regexp Patterns341446 -Node: Expression Patterns341989 -Node: Ranges345674 -Node: BEGIN/END348640 -Node: Using BEGIN/END349402 -Ref: Using BEGIN/END-Footnote-1352133 -Node: I/O And BEGIN/END352239 -Node: BEGINFILE/ENDFILE354521 -Node: Empty357414 -Node: Using Shell Variables357730 -Node: Action Overview360015 -Node: Statements362372 -Node: If Statement364226 -Node: While Statement365725 -Node: Do Statement367769 -Node: For Statement368925 -Node: Switch Statement372077 -Node: Break Statement374174 -Node: Continue Statement376164 -Node: Next Statement377951 -Node: Nextfile Statement380341 -Node: Exit Statement382886 -Node: Built-in Variables385302 -Node: User-modified386397 -Ref: User-modified-Footnote-1394423 -Node: Auto-set394485 -Ref: Auto-set-Footnote-1403776 -Node: ARGC and ARGV403981 -Node: Arrays407832 -Node: Array Basics409337 -Node: Array Intro410048 -Node: Reference to Elements414366 -Node: Assigning Elements416636 -Node: Array Example417127 -Node: Scanning an Array418859 -Node: Delete421525 -Ref: Delete-Footnote-1423960 -Node: Numeric Array Subscripts424017 -Node: Uninitialized Subscripts426200 -Node: Multi-dimensional427828 -Node: Multi-scanning430922 -Node: Arrays of Arrays432513 -Node: Functions437158 -Node: Built-in437980 -Node: Calling Built-in439058 -Node: Numeric Functions441046 -Ref: Numeric Functions-Footnote-1444811 -Ref: Numeric Functions-Footnote-2445168 -Ref: Numeric Functions-Footnote-3445216 -Node: String Functions445485 -Ref: String Functions-Footnote-1468982 -Ref: String Functions-Footnote-2469111 -Ref: String Functions-Footnote-3469359 -Node: Gory Details469446 -Ref: table-sub-escapes471125 -Ref: table-sub-posix-92472479 -Ref: table-sub-proposed473822 -Ref: table-posix-sub475172 -Ref: table-gensub-escapes476718 -Ref: Gory Details-Footnote-1477925 -Ref: Gory Details-Footnote-2477976 -Node: I/O Functions478127 -Ref: I/O Functions-Footnote-1484782 -Node: Time Functions484929 -Ref: Time Functions-Footnote-1495821 -Ref: Time Functions-Footnote-2495889 -Ref: Time Functions-Footnote-3496047 -Ref: Time Functions-Footnote-4496158 -Ref: Time Functions-Footnote-5496270 -Ref: Time Functions-Footnote-6496497 -Node: Bitwise Functions496763 -Ref: table-bitwise-ops497321 -Ref: Bitwise Functions-Footnote-1501481 -Node: Type Functions501665 -Node: I18N Functions502135 -Node: User-defined503762 -Node: Definition Syntax504566 -Ref: Definition Syntax-Footnote-1509476 -Node: Function Example509545 -Node: Function Caveats512139 -Node: Calling A Function512560 -Node: Variable Scope513675 -Node: Pass By Value/Reference515650 -Node: Return Statement519090 -Node: Dynamic Typing522071 -Node: Indirect Calls522806 -Node: Internationalization532491 -Node: I18N and L10N533917 -Node: Explaining gettext534603 -Ref: Explaining gettext-Footnote-1539669 -Ref: Explaining gettext-Footnote-2539853 -Node: Programmer i18n540018 -Node: Translator i18n544218 -Node: String Extraction545011 -Ref: String Extraction-Footnote-1545972 -Node: Printf Ordering546058 -Ref: Printf Ordering-Footnote-1548842 -Node: I18N Portability548906 -Ref: I18N Portability-Footnote-1551355 -Node: I18N Example551418 -Ref: I18N Example-Footnote-1554053 -Node: Gawk I18N554125 -Node: Advanced Features554742 -Node: Nondecimal Data556255 -Node: Array Sorting557838 -Node: Controlling Array Traversal558538 -Node: Controlling Scanning With A Function559285 -Node: Controlling Scanning566994 -Ref: Controlling Scanning-Footnote-1571648 -Node: Array Sorting Functions571964 -Ref: Array Sorting Functions-Footnote-1575613 -Ref: Array Sorting Functions-Footnote-2575706 -Node: Two-way I/O575900 -Ref: Two-way I/O-Footnote-1581332 -Node: TCP/IP Networking581402 -Node: Profiling584246 -Node: Library Functions591720 -Ref: Library Functions-Footnote-1594727 -Node: Library Names594898 -Ref: Library Names-Footnote-1598369 -Ref: Library Names-Footnote-2598589 -Node: General Functions598675 -Node: Strtonum Function599628 -Node: Assert Function602558 -Node: Round Function605884 -Node: Cliff Random Function607427 -Node: Ordinal Functions608443 -Ref: Ordinal Functions-Footnote-1611513 -Ref: Ordinal Functions-Footnote-2611765 -Node: Join Function611974 -Ref: Join Function-Footnote-1613745 -Node: Gettimeofday Function613945 -Node: Data File Management617660 -Node: Filetrans Function618292 -Node: Rewind Function622431 -Node: File Checking623818 -Node: Empty Files624912 -Node: Ignoring Assigns627142 -Node: Getopt Function628695 -Ref: Getopt Function-Footnote-1639999 -Node: Passwd Functions640202 -Ref: Passwd Functions-Footnote-1649177 -Node: Group Functions649265 -Node: Walking Arrays657349 -Node: Sample Programs658918 -Node: Running Examples659583 -Node: Clones660311 -Node: Cut Program661535 -Node: Egrep Program671380 -Ref: Egrep Program-Footnote-1679153 -Node: Id Program679263 -Node: Split Program682879 -Ref: Split Program-Footnote-1686398 -Node: Tee Program686526 -Node: Uniq Program689329 -Node: Wc Program696758 -Ref: Wc Program-Footnote-1701024 -Ref: Wc Program-Footnote-2701224 -Node: Miscellaneous Programs701316 -Node: Dupword Program702504 -Node: Alarm Program704535 -Node: Translate Program709284 -Ref: Translate Program-Footnote-1713671 -Ref: Translate Program-Footnote-2713899 -Node: Labels Program714033 -Ref: Labels Program-Footnote-1717404 -Node: Word Sorting717488 -Node: History Sorting721372 -Node: Extract Program723211 -Ref: Extract Program-Footnote-1730694 -Node: Simple Sed730822 -Node: Igawk Program733884 -Ref: Igawk Program-Footnote-1749041 -Ref: Igawk Program-Footnote-2749242 -Node: Anagram Program749380 -Node: Signature Program752448 -Node: Debugger753548 -Node: Debugging754459 -Node: Debugging Concepts754872 -Node: Debugging Terms756728 -Node: Awk Debugging759351 -Node: Sample dgawk session760243 -Node: dgawk invocation760735 -Node: Finding The Bug761917 -Node: List of Debugger Commands768403 -Node: Breakpoint Control769714 -Node: Dgawk Execution Control773350 -Node: Viewing And Changing Data776701 -Node: Dgawk Stack780038 -Node: Dgawk Info781498 -Node: Miscellaneous Dgawk Commands785446 -Node: Readline Support790874 -Node: Dgawk Limitations791712 -Node: Language History793901 -Node: V7/SVR3.1795413 -Node: SVR4797734 -Node: POSIX799176 -Node: BTL800184 -Node: POSIX/GNU800918 -Node: Common Extensions806069 -Node: Ranges and Locales807176 -Ref: Ranges and Locales-Footnote-1811783 -Node: Contributors812004 -Node: Installation816266 -Node: Gawk Distribution817160 -Node: Getting817644 -Node: Extracting818470 -Node: Distribution contents820162 -Node: Unix Installation825384 -Node: Quick Installation826001 -Node: Additional Configuration Options827963 -Node: Configuration Philosophy829440 -Node: Non-Unix Installation831782 -Node: PC Installation832240 -Node: PC Binary Installation833539 -Node: PC Compiling835387 -Node: PC Testing838331 -Node: PC Using839507 -Node: Cygwin843692 -Node: MSYS844692 -Node: VMS Installation845206 -Node: VMS Compilation845809 -Ref: VMS Compilation-Footnote-1846816 -Node: VMS Installation Details846874 -Node: VMS Running848509 -Node: VMS Old Gawk850116 -Node: Bugs850590 -Node: Other Versions854442 -Node: Notes859723 -Node: Compatibility Mode860415 -Node: Additions861198 -Node: Accessing The Source862010 -Node: Adding Code863435 -Node: New Ports869402 -Node: Dynamic Extensions873515 -Node: Internals874891 -Node: Plugin License883994 -Node: Sample Library884628 -Node: Internal File Description885314 -Node: Internal File Ops889029 -Ref: Internal File Ops-Footnote-1893810 -Node: Using Internal File Ops893950 -Node: Future Extensions896327 -Node: Basic Concepts898831 -Node: Basic High Level899588 -Ref: Basic High Level-Footnote-1903623 -Node: Basic Data Typing903808 -Node: Floating Point Issues908333 -Node: String Conversion Precision909416 -Ref: String Conversion Precision-Footnote-1911116 -Node: Unexpected Results911225 -Node: POSIX Floating Point Problems913051 -Ref: POSIX Floating Point Problems-Footnote-1916756 -Node: Glossary916794 -Node: Copying941770 -Node: GNU Free Documentation License979327 -Node: Index1004464 +Node: Foreword30270 +Node: Preface34615 +Ref: Preface-Footnote-137668 +Ref: Preface-Footnote-237774 +Node: History38006 +Node: Names40397 +Ref: Names-Footnote-141874 +Node: This Manual41946 +Ref: This Manual-Footnote-146893 +Node: Conventions46993 +Node: Manual History49127 +Ref: Manual History-Footnote-152397 +Ref: Manual History-Footnote-252438 +Node: How To Contribute52512 +Node: Acknowledgments53656 +Node: Getting Started57987 +Node: Running gawk60366 +Node: One-shot61552 +Node: Read Terminal62777 +Ref: Read Terminal-Footnote-164427 +Ref: Read Terminal-Footnote-264703 +Node: Long64874 +Node: Executable Scripts66250 +Ref: Executable Scripts-Footnote-168119 +Ref: Executable Scripts-Footnote-268221 +Node: Comments68672 +Node: Quoting71139 +Node: DOS Quoting75762 +Node: Sample Data Files76437 +Node: Very Simple79469 +Node: Two Rules84068 +Node: More Complex86215 +Ref: More Complex-Footnote-189145 +Node: Statements/Lines89230 +Ref: Statements/Lines-Footnote-193692 +Node: Other Features93957 +Node: When94885 +Node: Invoking Gawk97032 +Node: Command Line98417 +Node: Options99200 +Ref: Options-Footnote-1112637 +Node: Other Arguments112662 +Node: Naming Standard Input115320 +Node: Environment Variables116414 +Node: AWKPATH Variable116858 +Ref: AWKPATH Variable-Footnote-1119455 +Node: Other Environment Variables119715 +Node: Exit Status122055 +Node: Include Files122730 +Node: Obsolete126215 +Node: Undocumented126901 +Node: Regexp127142 +Node: Regexp Usage128531 +Node: Escape Sequences130557 +Node: Regexp Operators136320 +Ref: Regexp Operators-Footnote-1143517 +Ref: Regexp Operators-Footnote-2143664 +Node: Bracket Expressions143762 +Ref: table-char-classes145652 +Node: GNU Regexp Operators148175 +Node: Case-sensitivity151898 +Ref: Case-sensitivity-Footnote-1154866 +Ref: Case-sensitivity-Footnote-2155101 +Node: Leftmost Longest155209 +Node: Computed Regexps156410 +Node: Reading Files159820 +Node: Records161761 +Ref: Records-Footnote-1170435 +Node: Fields170472 +Ref: Fields-Footnote-1173505 +Node: Nonconstant Fields173591 +Node: Changing Fields175793 +Node: Field Separators181771 +Node: Default Field Splitting184400 +Node: Regexp Field Splitting185517 +Node: Single Character Fields188859 +Node: Command Line Field Separator189918 +Node: Field Splitting Summary193359 +Ref: Field Splitting Summary-Footnote-1196551 +Node: Constant Size196652 +Node: Splitting By Content201236 +Ref: Splitting By Content-Footnote-1204962 +Node: Multiple Line205002 +Ref: Multiple Line-Footnote-1210849 +Node: Getline211028 +Node: Plain Getline213256 +Node: Getline/Variable215345 +Node: Getline/File216486 +Node: Getline/Variable/File217808 +Ref: Getline/Variable/File-Footnote-1219407 +Node: Getline/Pipe219494 +Node: Getline/Variable/Pipe222054 +Node: Getline/Coprocess223161 +Node: Getline/Variable/Coprocess224404 +Node: Getline Notes225118 +Node: Getline Summary227060 +Ref: table-getline-variants227403 +Node: Command line directories228259 +Node: Printing228884 +Node: Print230515 +Node: Print Examples231852 +Node: Output Separators234636 +Node: OFMT236396 +Node: Printf237754 +Node: Basic Printf238660 +Node: Control Letters240199 +Node: Format Modifiers244011 +Node: Printf Examples250020 +Node: Redirection252735 +Node: Special Files259719 +Node: Special FD260252 +Ref: Special FD-Footnote-1263877 +Node: Special Network263951 +Node: Special Caveats264801 +Node: Close Files And Pipes265597 +Ref: Close Files And Pipes-Footnote-1272620 +Ref: Close Files And Pipes-Footnote-2272768 +Node: Expressions272918 +Node: Values274050 +Node: Constants274726 +Node: Scalar Constants275406 +Ref: Scalar Constants-Footnote-1276265 +Node: Nondecimal-numbers276447 +Node: Regexp Constants279506 +Node: Using Constant Regexps279981 +Node: Variables283036 +Node: Using Variables283691 +Node: Assignment Options285415 +Node: Conversion287287 +Ref: table-locale-affects292663 +Ref: Conversion-Footnote-1293287 +Node: All Operators293396 +Node: Arithmetic Ops294026 +Node: Concatenation296531 +Ref: Concatenation-Footnote-1299324 +Node: Assignment Ops299444 +Ref: table-assign-ops304432 +Node: Increment Ops305840 +Node: Truth Values and Conditions309310 +Node: Truth Values310393 +Node: Typing and Comparison311442 +Node: Variable Typing312231 +Ref: Variable Typing-Footnote-1316128 +Node: Comparison Operators316250 +Ref: table-relational-ops316660 +Node: POSIX String Comparison320209 +Ref: POSIX String Comparison-Footnote-1321165 +Node: Boolean Ops321303 +Ref: Boolean Ops-Footnote-1325381 +Node: Conditional Exp325472 +Node: Function Calls327204 +Node: Precedence330798 +Node: Locales334467 +Node: Patterns and Actions335556 +Node: Pattern Overview336610 +Node: Regexp Patterns338276 +Node: Expression Patterns338819 +Node: Ranges342504 +Node: BEGIN/END345470 +Node: Using BEGIN/END346232 +Ref: Using BEGIN/END-Footnote-1348963 +Node: I/O And BEGIN/END349069 +Node: BEGINFILE/ENDFILE351351 +Node: Empty354244 +Node: Using Shell Variables354560 +Node: Action Overview356845 +Node: Statements359202 +Node: If Statement361056 +Node: While Statement362555 +Node: Do Statement364599 +Node: For Statement365755 +Node: Switch Statement368907 +Node: Break Statement371004 +Node: Continue Statement372994 +Node: Next Statement374781 +Node: Nextfile Statement377171 +Node: Exit Statement379716 +Node: Built-in Variables382132 +Node: User-modified383227 +Ref: User-modified-Footnote-1391253 +Node: Auto-set391315 +Ref: Auto-set-Footnote-1400606 +Node: ARGC and ARGV400811 +Node: Arrays404662 +Node: Array Basics406167 +Node: Array Intro406993 +Node: Reference to Elements411311 +Node: Assigning Elements413581 +Node: Array Example414072 +Node: Scanning an Array415804 +Node: Controlling Scanning418118 +Ref: Controlling Scanning-Footnote-1423050 +Node: Delete423366 +Ref: Delete-Footnote-1425801 +Node: Numeric Array Subscripts425858 +Node: Uninitialized Subscripts428041 +Node: Multi-dimensional429669 +Node: Multi-scanning432763 +Node: Arrays of Arrays434354 +Node: Functions438999 +Node: Built-in439821 +Node: Calling Built-in440899 +Node: Numeric Functions442887 +Ref: Numeric Functions-Footnote-1446652 +Ref: Numeric Functions-Footnote-2447009 +Ref: Numeric Functions-Footnote-3447057 +Node: String Functions447326 +Ref: String Functions-Footnote-1470823 +Ref: String Functions-Footnote-2470952 +Ref: String Functions-Footnote-3471200 +Node: Gory Details471287 +Ref: table-sub-escapes472966 +Ref: table-sub-posix-92474320 +Ref: table-sub-proposed475663 +Ref: table-posix-sub477013 +Ref: table-gensub-escapes478559 +Ref: Gory Details-Footnote-1479766 +Ref: Gory Details-Footnote-2479817 +Node: I/O Functions479968 +Ref: I/O Functions-Footnote-1486623 +Node: Time Functions486770 +Ref: Time Functions-Footnote-1497662 +Ref: Time Functions-Footnote-2497730 +Ref: Time Functions-Footnote-3497888 +Ref: Time Functions-Footnote-4497999 +Ref: Time Functions-Footnote-5498111 +Ref: Time Functions-Footnote-6498338 +Node: Bitwise Functions498604 +Ref: table-bitwise-ops499162 +Ref: Bitwise Functions-Footnote-1503322 +Node: Type Functions503506 +Node: I18N Functions503976 +Node: User-defined505603 +Node: Definition Syntax506407 +Ref: Definition Syntax-Footnote-1511317 +Node: Function Example511386 +Node: Function Caveats513980 +Node: Calling A Function514401 +Node: Variable Scope515516 +Node: Pass By Value/Reference517491 +Node: Return Statement520931 +Node: Dynamic Typing523912 +Node: Indirect Calls524647 +Node: Internationalization534332 +Node: I18N and L10N535758 +Node: Explaining gettext536444 +Ref: Explaining gettext-Footnote-1541510 +Ref: Explaining gettext-Footnote-2541694 +Node: Programmer i18n541859 +Node: Translator i18n546059 +Node: String Extraction546852 +Ref: String Extraction-Footnote-1547813 +Node: Printf Ordering547899 +Ref: Printf Ordering-Footnote-1550683 +Node: I18N Portability550747 +Ref: I18N Portability-Footnote-1553196 +Node: I18N Example553259 +Ref: I18N Example-Footnote-1555894 +Node: Gawk I18N555966 +Node: Advanced Features556583 +Node: Nondecimal Data558096 +Node: Array Sorting559679 +Node: Controlling Array Traversal560376 +Node: Array Sorting Functions568613 +Ref: Array Sorting Functions-Footnote-1572287 +Ref: Array Sorting Functions-Footnote-2572380 +Node: Two-way I/O572574 +Ref: Two-way I/O-Footnote-1578006 +Node: TCP/IP Networking578076 +Node: Profiling580920 +Node: Library Functions588394 +Ref: Library Functions-Footnote-1591401 +Node: Library Names591572 +Ref: Library Names-Footnote-1595043 +Ref: Library Names-Footnote-2595263 +Node: General Functions595349 +Node: Strtonum Function596302 +Node: Assert Function599232 +Node: Round Function602558 +Node: Cliff Random Function604101 +Node: Ordinal Functions605117 +Ref: Ordinal Functions-Footnote-1608187 +Ref: Ordinal Functions-Footnote-2608439 +Node: Join Function608648 +Ref: Join Function-Footnote-1610419 +Node: Gettimeofday Function610619 +Node: Data File Management614334 +Node: Filetrans Function614966 +Node: Rewind Function619105 +Node: File Checking620492 +Node: Empty Files621586 +Node: Ignoring Assigns623816 +Node: Getopt Function625369 +Ref: Getopt Function-Footnote-1636673 +Node: Passwd Functions636876 +Ref: Passwd Functions-Footnote-1645851 +Node: Group Functions645939 +Node: Walking Arrays654023 +Node: Sample Programs655592 +Node: Running Examples656257 +Node: Clones656985 +Node: Cut Program658209 +Node: Egrep Program668054 +Ref: Egrep Program-Footnote-1675827 +Node: Id Program675937 +Node: Split Program679553 +Ref: Split Program-Footnote-1683072 +Node: Tee Program683200 +Node: Uniq Program686003 +Node: Wc Program693432 +Ref: Wc Program-Footnote-1697698 +Ref: Wc Program-Footnote-2697898 +Node: Miscellaneous Programs697990 +Node: Dupword Program699178 +Node: Alarm Program701209 +Node: Translate Program705958 +Ref: Translate Program-Footnote-1710345 +Ref: Translate Program-Footnote-2710573 +Node: Labels Program710707 +Ref: Labels Program-Footnote-1714078 +Node: Word Sorting714162 +Node: History Sorting718046 +Node: Extract Program719885 +Ref: Extract Program-Footnote-1727368 +Node: Simple Sed727496 +Node: Igawk Program730558 +Ref: Igawk Program-Footnote-1745715 +Ref: Igawk Program-Footnote-2745916 +Node: Anagram Program746054 +Node: Signature Program749122 +Node: Debugger750222 +Node: Debugging751133 +Node: Debugging Concepts751546 +Node: Debugging Terms753402 +Node: Awk Debugging756025 +Node: Sample dgawk session756917 +Node: dgawk invocation757409 +Node: Finding The Bug758591 +Node: List of Debugger Commands765077 +Node: Breakpoint Control766388 +Node: Dgawk Execution Control770024 +Node: Viewing And Changing Data773375 +Node: Dgawk Stack776712 +Node: Dgawk Info778172 +Node: Miscellaneous Dgawk Commands782120 +Node: Readline Support787548 +Node: Dgawk Limitations788386 +Node: Language History790575 +Node: V7/SVR3.1792087 +Node: SVR4794408 +Node: POSIX795850 +Node: BTL796858 +Node: POSIX/GNU797592 +Node: Common Extensions802743 +Node: Ranges and Locales803850 +Ref: Ranges and Locales-Footnote-1808457 +Node: Contributors808678 +Node: Installation812940 +Node: Gawk Distribution813834 +Node: Getting814318 +Node: Extracting815144 +Node: Distribution contents816836 +Node: Unix Installation822058 +Node: Quick Installation822675 +Node: Additional Configuration Options824637 +Node: Configuration Philosophy826114 +Node: Non-Unix Installation828456 +Node: PC Installation828914 +Node: PC Binary Installation830213 +Node: PC Compiling832061 +Node: PC Testing835005 +Node: PC Using836181 +Node: Cygwin840366 +Node: MSYS841366 +Node: VMS Installation841880 +Node: VMS Compilation842483 +Ref: VMS Compilation-Footnote-1843490 +Node: VMS Installation Details843548 +Node: VMS Running845183 +Node: VMS Old Gawk846790 +Node: Bugs847264 +Node: Other Versions851116 +Node: Notes856397 +Node: Compatibility Mode857089 +Node: Additions857872 +Node: Accessing The Source858684 +Node: Adding Code860109 +Node: New Ports866076 +Node: Dynamic Extensions870189 +Node: Internals871565 +Node: Plugin License880668 +Node: Sample Library881302 +Node: Internal File Description881988 +Node: Internal File Ops885703 +Ref: Internal File Ops-Footnote-1890484 +Node: Using Internal File Ops890624 +Node: Future Extensions893001 +Node: Basic Concepts895505 +Node: Basic High Level896262 +Ref: Basic High Level-Footnote-1900297 +Node: Basic Data Typing900482 +Node: Floating Point Issues905007 +Node: String Conversion Precision906090 +Ref: String Conversion Precision-Footnote-1907790 +Node: Unexpected Results907899 +Node: POSIX Floating Point Problems909725 +Ref: POSIX Floating Point Problems-Footnote-1913430 +Node: Glossary913468 +Node: Copying938444 +Node: GNU Free Documentation License976001 +Node: Index1001138  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index fa145bb1..dfd6dd86 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -20,9 +20,9 @@ @c applies to and all the info about who's publishing this edition @c These apply across the board. -@set UPDATE-MONTH June, 2011 +@set UPDATE-MONTH November, 2011 @set VERSION 4.0 -@set PATCHLEVEL 0 +@set PATCHLEVEL 1 @set FSF @@ -306,439 +306,399 @@ particular records in a file and perform operations upon them. * 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. -* 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"]. -* Controlling Scanning With A Function:: Using a function to control scanning. -* Controlling Scanning:: Controlling the order in which arrays - are scanned. -* 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. +* 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 @@ -13054,6 +13014,8 @@ 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 @@ -13441,11 +13403,151 @@ 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. -As an extension, @command{gawk} makes it possible for you to -loop over the elements of an array in order, based on the value of -@code{PROCINFO["sorted_in"]} (@pxref{Auto-set}). -This is an advanced feature, so discussion of it is delayed -until @ref{Controlling Array Traversal}. +@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 mechanims 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}. @@ -18164,8 +18266,8 @@ leads to less surprising results. @node Array Sorting @section Controlling Array Traversal and Array Sorting -@command{gawk} lets you control the order in which @samp{for (i in array)} loops -will traverse an array. +@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. @@ -18186,18 +18288,14 @@ 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; this @value{SUBSECTION} describes how. - -@menu -* Controlling Scanning With A Function:: Using a function to control scanning. -* Controlling Scanning:: Controlling the order in which arrays - are scanned. -@end menu +lets you do this. -@node Controlling Scanning With A Function -@subsubsection Array Scanning Using A User-defined Function +@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. -The value of @code{PROCINFO["sorted_in"]} can be a function name. +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 @@ -18214,8 +18312,9 @@ function comp_func(i1, v1, i2, v2) 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. The three possible return values -are interpreted this way: +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 @@ -18357,7 +18456,7 @@ END @{ The first field in each entry of the password file is the user's login name, and the fields are seperated by colons. -Each record defines a subarray (@pxref{Arrays of Arrays}), +Each record defines a subarray, with each field as an element in the subarray. Running the program produces the following output: @@ -18447,151 +18546,6 @@ sorted array traversal is not the default. @c maintainers believe that only the people who wish to use a @c feature should have to pay for it. -@node Controlling Scanning -@subsubsection Controlling Array Scanning Order - -As described in -@iftex -the previous subsubsection, -@end iftex -@ifnottex -@ref{Controlling Scanning With A Function}, -@end ifnottex -you can provide the name of a function as the value of -@code{PROCINFO["sorted_in"]} to specify custom sorting criteria. - -Often, though, you may wish to do something simple, such as -``sort based on comparing the indices in ascending order,'' -or ``sort based on comparing the values in descending order.'' -Having to write a simple comparison function for this purpose -for use in all of your programs becomes tedious. -For the common simple cases, @command{gawk} provides -the option of using special names that do the requested -sorting for you. -You can think of them as ``predefined'' sorting functions, -if you like, although the names purposely include characters -that are not valid in real @command{awk} function names. - -The following special values 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. - -@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 function, you should see if it's defined and save and restore the value: - -@example -function myfunct(p1, p2, save_sorted) -@{ - @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. -@end itemize - @node Array Sorting Functions @subsection Sorting Array Values and Indices with @command{gawk} @@ -18600,7 +18554,7 @@ the null string to @code{PROCINFO["sorted_in"]} or by just deleting the @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. +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()} @@ -18641,12 +18595,11 @@ 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 the -name of a user-defined function, or one of the predefined names -that @command{gawk} provides -(@pxref{Controlling Scanning With A Function}). +@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 -- cgit v1.2.3 From 8ed7ce1717bf35f9cd268e21056b0c2fc5485cf5 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 14 Nov 2011 21:41:59 +0200 Subject: VMS fixes, MBS related, sort of. --- vms/ChangeLog | 11 +++++++++++ vms/descrip.mms | 8 ++++++++ vms/vms-conf.h | 32 +++++++++++++++++++------------- vms/vmstest.com | 2 +- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/vms/ChangeLog b/vms/ChangeLog index 9a3ffd74..62db87e1 100644 --- a/vms/ChangeLog +++ b/vms/ChangeLog @@ -1,3 +1,14 @@ +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, diff --git a/vms/descrip.mms b/vms/descrip.mms index 967a312e..40b97eb1 100644 --- a/vms/descrip.mms +++ b/vms/descrip.mms @@ -48,6 +48,7 @@ # 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 @@ -226,6 +227,13 @@ 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 diff --git a/vms/vms-conf.h b/vms/vms-conf.h index cbdc9508..c42118ff 100644 --- a/vms/vms-conf.h +++ b/vms/vms-conf.h @@ -128,13 +128,13 @@ #define HAVE_ISASCII 1 /* Define to 1 if you have the `iswctype' function. */ -#undef HAVE_ISWCTYPE +#define HAVE_ISWCTYPE 1 /* Define to 1 if you have the `iswlower' function. */ -#undef HAVE_ISWLOWER +#define HAVE_ISWLOWER 1 /* Define to 1 if you have the `iswupper' function. */ -#undef HAVE_ISWUPPER +#define HAVE_ISWUPPER 1 /* Define if you have and nl_langinfo(CODESET). */ #undef HAVE_LANGINFO_CODESET @@ -167,10 +167,10 @@ #undef HAVE_LONG_LONG_INT /* Define to 1 if you have the `mbrlen' function. */ -#undef HAVE_MBRLEN +#define HAVE_MBRLEN 1 /* Define to 1 if mbrtowc and mbstate_t are properly declared. */ -#undef HAVE_MBRTOWC +#define HAVE_MBRTOWC 1 /* Define to 1 if you have the header file. */ #undef HAVE_MCHECK_H @@ -214,6 +214,9 @@ /* 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 @@ -289,6 +292,9 @@ /* 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 @@ -322,10 +328,10 @@ #undef HAVE_TM_ZONE /* Define to 1 if you have the `towlower' function. */ -#undef HAVE_TOWLOWER +#define HAVE_TOWLOWER 1 /* Define to 1 if you have the `towupper' function. */ -#undef HAVE_TOWUPPER +#define HAVE_TOWUPPER 1 /* Define to 1 if you don't have `tm_zone' but do have the external array `tzname'. */ @@ -357,22 +363,22 @@ #define HAVE_VPRINTF 1 /* Define to 1 if you have the header file. */ -#undef HAVE_WCHAR_H +#define HAVE_WCHAR_H 1 /* Define to 1 if you have the `wcrtomb' function. */ -#undef HAVE_WCRTOMB +#define HAVE_WCRTOMB 1 /* Define to 1 if you have the `wcscoll' function. */ -#undef HAVE_WCSCOLL +#define HAVE_WCSCOLL 1 /* Define to 1 if you have the `wctype' function. */ -#undef HAVE_WCTYPE +#define HAVE_WCTYPE 1 /* Define to 1 if you have the header file. */ -#undef HAVE_WCTYPE_H +#define HAVE_WCTYPE_H 1 /* systems should define this type here */ -#undef HAVE_WCTYPE_T +#define HAVE_WCTYPE_T 1 /* systems should define this type here */ #undef HAVE_WINT_T diff --git a/vms/vmstest.com b/vms/vmstest.com index f35a9ad1..146053e1 100644 --- a/vms/vmstest.com +++ b/vms/vmstest.com @@ -89,7 +89,7 @@ $ $unix: $unix_tests: echo "unix_tests..." $ list = "fflush getlnhd localenl pid pipeio1 pipeio2" - - + " poundbang rtlen relen01 space strftlng" + + " poundbang rtlen rtlen01 space strftlng" $ gosub list_of_tests $ return $ -- cgit v1.2.3 From 7e8f32c84caa4c2a99e4cea09fa25c5ae9722784 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 14 Nov 2011 21:42:42 +0200 Subject: Minor doc fixes in man page. --- doc/ChangeLog | 4 ++++ doc/gawk.1 | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 64fe7a38..dec5ddca 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +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 diff --git a/doc/gawk.1 b/doc/gawk.1 index 205eb389..e26f9a2e 100644 --- a/doc/gawk.1 +++ b/doc/gawk.1 @@ -14,7 +14,7 @@ . if \w'\(rq' .ds rq "\(rq . \} .\} -.TH GAWK 1 "May 29 2011" "Free Software Foundation" "Utility Commands" +.TH GAWK 1 "Nov 10 2011" "Free Software Foundation" "Utility Commands" .SH NAME gawk \- pattern scanning and processing language .SH SYNOPSIS @@ -782,7 +782,7 @@ 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 -.BR FS +.B FS or .B FIELDWIDTHS overrides the use of @@ -2089,7 +2089,7 @@ Sends data to a co-process or socket. below.) .PP The -.BR getline +.B getline command returns 1 on success, 0 on end of file, and \-1 on an error. Upon an error, .B ERRNO @@ -2234,9 +2234,9 @@ For and .BR %X , supply a leading -.BR 0x +.B 0x or -.BR 0X +.B 0X for a nonzero result. For @@ -2517,7 +2517,7 @@ a second array if you wish to preserve the original. The purpose of the optional string .I how is the same as described in -.BR asort() +.B asort() above. .TP \fBgensub(\fIr\fB, \fIs\fB, \fIh \fR[\fB, \fIt\fR]\fB)\fR @@ -2589,7 +2589,7 @@ to get a literal (This must be typed as \fB"\e\e&"\fP; see \*(EP for a fuller discussion of the rules for -.BR &'s +.BR & 's and backslashes in the replacement text of .BR sub() , .BR gsub() , @@ -3275,7 +3275,7 @@ the array; the .BR \ea , and -.BR \ev +.B \ev escape sequences (done originally in .I gawk and fed back into the Bell Laboratories version); the -- cgit v1.2.3 From cceacad1d367b3019a5648521d4b4c0e201297f5 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 14 Nov 2011 21:43:44 +0200 Subject: More changes for non-MBS case. --- ChangeLog | 8 ++++++++ mbsupport.h | 6 ++++-- missing_d/ChangeLog | 4 ++++ missing_d/wcmisc.c | 14 +++++++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b440a95..b8397f5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +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 ... diff --git a/mbsupport.h b/mbsupport.h index 1a30785d..57abaa60 100644 --- a/mbsupport.h +++ b/mbsupport.h @@ -40,6 +40,7 @@ #if defined(HAVE_ISWCTYPE) \ && defined(HAVE_LOCALE_H) \ + && defined(HAVE_BTOWC) \ && defined(HAVE_MBRLEN) \ && defined(HAVE_MBRTOWC) \ && defined(HAVE_WCHAR_H) \ @@ -70,10 +71,11 @@ /* All this glop is for dfa.c. Bleah. */ +#define wchar_t char #define wctype_t int -#define wint_t int +#define wint_t int #define mbstate_t int -#define WEOF EOF +#define WEOF EOF #define towupper toupper #define towlower tolower #define btowc(x) (x) diff --git a/missing_d/ChangeLog b/missing_d/ChangeLog index 45cc1acc..4a06aa60 100644 --- a/missing_d/ChangeLog +++ b/missing_d/ChangeLog @@ -1,3 +1,7 @@ +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. diff --git a/missing_d/wcmisc.c b/missing_d/wcmisc.c index e53730ea..d2b7aa08 100644 --- a/missing_d/wcmisc.c +++ b/missing_d/wcmisc.c @@ -16,8 +16,9 @@ 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", @@ -32,12 +33,16 @@ static const char *classes[] = { "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; @@ -48,7 +53,9 @@ wctype_t wctype(const char *name) return 0; } +#endif +#ifndef HAVE_ISWCTYPE int iswctype(wint_t wc, wctype_t desc) { int j = sizeof(classes) / sizeof(classes[0]); @@ -72,7 +79,9 @@ int iswctype(wint_t wc, wctype_t desc) default: return 0; } } +#endif +#ifndef HAVE_WCSCOLL int wcscoll(const wchar_t *ws1, const wchar_t *ws2) { size_t i; @@ -86,3 +95,6 @@ int wcscoll(const wchar_t *ws1, const wchar_t *ws2) return (ws1[i] - ws2[i]); } +#endif + +/*wcmisc.c*/ -- cgit v1.2.3 From 169aedcf3822c4b37b58d01ce97210839496e484 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 14 Nov 2011 21:44:06 +0200 Subject: Add a new item. --- FUTURES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FUTURES b/FUTURES index 02574107..6b570567 100644 --- a/FUTURES +++ b/FUTURES @@ -26,6 +26,9 @@ For 4.1 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 -- cgit v1.2.3 From 9af44f959b1591daf2f7d2953dbdd3e868044d27 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 14 Nov 2011 21:45:19 +0200 Subject: Bug fix in debugger - switch/case line numbers. --- ChangeLog | 6 ++++++ debug.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index b8397f5c..a7a8be63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +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. diff --git a/debug.c b/debug.c index 29ce8b1a..0a66b462 100644 --- a/debug.c +++ b/debug.c @@ -2231,6 +2231,23 @@ 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) -- cgit v1.2.3 From 1e9ffdd82158abb274eb512f53f5d1d771015751 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 14 Nov 2011 21:49:05 +0200 Subject: Bump version for test tarball. --- configure | 20 ++++++++++---------- configure.ac | 2 +- pc/config.h | 6 +++--- po/da.gmo | Bin 48739 -> 48739 bytes po/da.po | 2 +- po/de.gmo | Bin 52166 -> 52166 bytes po/de.po | 2 +- po/es.gmo | Bin 51471 -> 51471 bytes po/es.po | 2 +- po/fi.gmo | Bin 51684 -> 51684 bytes po/fi.po | 2 +- po/fr.gmo | Bin 53311 -> 53311 bytes po/fr.po | 2 +- po/gawk.pot | 4 ++-- po/it.gmo | Bin 44316 -> 44316 bytes po/it.po | 2 +- po/ja.gmo | Bin 55596 -> 55596 bytes po/ja.po | 2 +- po/nl.gmo | Bin 49267 -> 49267 bytes po/nl.po | 2 +- po/pl.gmo | Bin 50946 -> 50946 bytes po/pl.po | 2 +- po/sv.gmo | Bin 48752 -> 48752 bytes po/sv.po | 2 +- version.c | 2 +- 25 files changed, 27 insertions(+), 27 deletions(-) diff --git a/configure b/configure index 909198b4..fbd545d8 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for GNU Awk 4.0.0d. +# Generated by GNU Autoconf 2.68 for GNU Awk 4.0.0e. # # Report bugs to . # @@ -560,8 +560,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='GNU Awk' PACKAGE_TARNAME='gawk' -PACKAGE_VERSION='4.0.0d' -PACKAGE_STRING='GNU Awk 4.0.0d' +PACKAGE_VERSION='4.0.0e' +PACKAGE_STRING='GNU Awk 4.0.0e' PACKAGE_BUGREPORT='bug-gawk@gnu.org' PACKAGE_URL='http://www.gnu.org/software/gawk/' @@ -1290,7 +1290,7 @@ 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.0d to adapt to many kinds of systems. +\`configure' configures GNU Awk 4.0.0e to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1360,7 +1360,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU Awk 4.0.0d:";; + short | recursive ) echo "Configuration of GNU Awk 4.0.0e:";; esac cat <<\_ACEOF @@ -1472,7 +1472,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU Awk configure 4.0.0d +GNU Awk configure 4.0.0e generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2176,7 +2176,7 @@ 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.0d, which was +It was created by GNU Awk $as_me 4.0.0e, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3011,7 +3011,7 @@ fi # Define the identity of the package. PACKAGE='gawk' - VERSION='4.0.0d' + VERSION='4.0.0e' cat >>confdefs.h <<_ACEOF @@ -11221,7 +11221,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # 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.0d, which was +This file was extended by GNU Awk $as_me 4.0.0e, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11289,7 +11289,7 @@ _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.0d +GNU Awk config.status 4.0.0e configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 9eacc408..df7e5a02 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ dnl dnl Process this file with autoconf to produce a configure script. -AC_INIT([GNU Awk], 4.0.0d, bug-gawk@gnu.org, gawk) +AC_INIT([GNU Awk], 4.0.0e, 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. diff --git a/pc/config.h b/pc/config.h index c0143f3d..1191c174 100644 --- a/pc/config.h +++ b/pc/config.h @@ -425,7 +425,7 @@ #define PACKAGE_NAME "GNU Awk" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Awk 4.0.0d" +#define PACKAGE_STRING "GNU Awk 4.0.0e" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "gawk" @@ -434,7 +434,7 @@ #define PACKAGE_URL "http://www.gnu.org/software/gawk/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "4.0.0d" +#define PACKAGE_VERSION "4.0.0e" /* Define to 1 if *printf supports %F format */ #undef PRINTF_HAS_F_FORMAT @@ -496,7 +496,7 @@ /* Version number of package */ -#define VERSION "4.0.0d" +#define VERSION "4.0.0e" /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS diff --git a/po/da.gmo b/po/da.gmo index 0b86e1b0..0270b5ce 100644 Binary files a/po/da.gmo and b/po/da.gmo differ diff --git a/po/da.po b/po/da.po index b4fb05ec..bb9d3b9d 100644 --- a/po/da.po +++ b/po/da.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 3.1.83\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-05-22 10:37+0200\n" "Last-Translator: Keld Simonsen \n" "Language-Team: Danish \n" diff --git a/po/de.gmo b/po/de.gmo index 57013d80..f0682785 100644 Binary files a/po/de.gmo and b/po/de.gmo differ diff --git a/po/de.po b/po/de.po index 19785ab9..2c1c6265 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-09-27 16:38+0200\n" "Last-Translator: Philipp Thomas \n" "Language-Team: German \n" diff --git a/po/es.gmo b/po/es.gmo index 36b57c97..7df5fab8 100644 Binary files a/po/es.gmo and b/po/es.gmo differ diff --git a/po/es.po b/po/es.po index 8f063a32..fd28a8a8 100644 --- a/po/es.po +++ b/po/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-08-14 12:02-0500\n" "Last-Translator: Cristian Othón Martínez Vera \n" "Language-Team: Spanish \n" diff --git a/po/fi.gmo b/po/fi.gmo index 8f2ed4e1..abe20e1a 100644 Binary files a/po/fi.gmo and b/po/fi.gmo differ diff --git a/po/fi.po b/po/fi.po index 1da166b6..c698f564 100644 --- a/po/fi.po +++ b/po/fi.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-09-12 12:14+0200\n" "Last-Translator: Jorma Karvonen \n" "Language-Team: Finnish \n" diff --git a/po/fr.gmo b/po/fr.gmo index 01710ef5..49267fd7 100644 Binary files a/po/fr.gmo and b/po/fr.gmo differ diff --git a/po/fr.po b/po/fr.po index a590a9f5..b43094c4 100644 --- a/po/fr.po +++ b/po/fr.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-07-16 16:50+0200\n" "Last-Translator: Jean-Philippe Guérard \n" diff --git a/po/gawk.pot b/po/gawk.pot index 3119cdc7..aa30ff3c 100644 --- a/po/gawk.pot +++ b/po/gawk.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: gawk 4.0.0d\n" +"Project-Id-Version: gawk 4.0.0e\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/po/it.gmo b/po/it.gmo index 93ba1d26..597024e7 100644 Binary files a/po/it.gmo and b/po/it.gmo differ diff --git a/po/it.po b/po/it.po index 29cb015c..4fd09749 100644 --- a/po/it.po +++ b/po/it.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 3.1.81\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-03-19 16:52+0100\n" "Last-Translator: Antonio Colombo \n" "Language-Team: Italian \n" diff --git a/po/ja.gmo b/po/ja.gmo index 3effd202..c349e1b7 100644 Binary files a/po/ja.gmo and b/po/ja.gmo differ diff --git a/po/ja.po b/po/ja.po index dc42614a..19c654f5 100644 --- a/po/ja.po +++ b/po/ja.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-07-17 08:28+0900\n" "Last-Translator: Yasuaki Taniguchi \n" "Language-Team: Japanese \n" diff --git a/po/nl.gmo b/po/nl.gmo index 4b3fd50b..52f492d6 100644 Binary files a/po/nl.gmo and b/po/nl.gmo differ diff --git a/po/nl.po b/po/nl.po index d47100e8..ecb41655 100644 --- a/po/nl.po +++ b/po/nl.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-07-17 21:44+0200\n" "Last-Translator: Benno Schulenberg \n" "Language-Team: Dutch \n" diff --git a/po/pl.gmo b/po/pl.gmo index 4d109afb..f0b2f7c1 100644 Binary files a/po/pl.gmo and b/po/pl.gmo differ diff --git a/po/pl.po b/po/pl.po index e46cb149..68aedb4f 100644 --- a/po/pl.po +++ b/po/pl.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 3.1.81\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-05-14 11:41-0400\n" "Last-Translator: Wojciech Polak \n" "Language-Team: Polish \n" diff --git a/po/sv.gmo b/po/sv.gmo index 1d3753ed..79e809be 100644 Binary files a/po/sv.gmo and b/po/sv.gmo differ diff --git a/po/sv.po b/po/sv.po index c297e525..874798c8 100644 --- a/po/sv.po +++ b/po/sv.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: gawk 4.0.0\n" "Report-Msgid-Bugs-To: arnold@skeeve.com\n" -"POT-Creation-Date: 2011-11-01 22:58+0200\n" +"POT-Creation-Date: 2011-11-14 21:46+0200\n" "PO-Revision-Date: 2011-07-16 15:20+0200\n" "Last-Translator: Gran Uddeborg \n" "Language-Team: Swedish \n" diff --git a/version.c b/version.c index 1ebd3d6e..8187d1a6 100644 --- a/version.c +++ b/version.c @@ -1,3 +1,3 @@ #include "config.h" -const char *version_string = "GNU Awk 4.0.0d"; +const char *version_string = "GNU Awk 4.0.0e"; -- cgit v1.2.3 From fd3e8f9c332bd76e7f8fa0c61c1451f52f3b1998 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 16 Nov 2011 19:09:15 +0200 Subject: Minor doc fix. --- doc/gawk.info | 682 +++++++++++++++++++++++++++++----------------------------- doc/gawk.texi | 2 +- 2 files changed, 342 insertions(+), 342 deletions(-) diff --git a/doc/gawk.info b/doc/gawk.info index 06133a6b..877f50d3 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -4056,8 +4056,8 @@ rebuild the entire record, using the current value of the fields and $1 = $1 # force record to be reconstituted print $0 # or whatever else with $0 -This forces `awk' rebuild the record. It does help to add a comment, -as we've shown here. +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 @@ -27505,344 +27505,344 @@ Node: Fields170472 Ref: Fields-Footnote-1173505 Node: Nonconstant Fields173591 Node: Changing Fields175793 -Node: Field Separators181771 -Node: Default Field Splitting184400 -Node: Regexp Field Splitting185517 -Node: Single Character Fields188859 -Node: Command Line Field Separator189918 -Node: Field Splitting Summary193359 -Ref: Field Splitting Summary-Footnote-1196551 -Node: Constant Size196652 -Node: Splitting By Content201236 -Ref: Splitting By Content-Footnote-1204962 -Node: Multiple Line205002 -Ref: Multiple Line-Footnote-1210849 -Node: Getline211028 -Node: Plain Getline213256 -Node: Getline/Variable215345 -Node: Getline/File216486 -Node: Getline/Variable/File217808 -Ref: Getline/Variable/File-Footnote-1219407 -Node: Getline/Pipe219494 -Node: Getline/Variable/Pipe222054 -Node: Getline/Coprocess223161 -Node: Getline/Variable/Coprocess224404 -Node: Getline Notes225118 -Node: Getline Summary227060 -Ref: table-getline-variants227403 -Node: Command line directories228259 -Node: Printing228884 -Node: Print230515 -Node: Print Examples231852 -Node: Output Separators234636 -Node: OFMT236396 -Node: Printf237754 -Node: Basic Printf238660 -Node: Control Letters240199 -Node: Format Modifiers244011 -Node: Printf Examples250020 -Node: Redirection252735 -Node: Special Files259719 -Node: Special FD260252 -Ref: Special FD-Footnote-1263877 -Node: Special Network263951 -Node: Special Caveats264801 -Node: Close Files And Pipes265597 -Ref: Close Files And Pipes-Footnote-1272620 -Ref: Close Files And Pipes-Footnote-2272768 -Node: Expressions272918 -Node: Values274050 -Node: Constants274726 -Node: Scalar Constants275406 -Ref: Scalar Constants-Footnote-1276265 -Node: Nondecimal-numbers276447 -Node: Regexp Constants279506 -Node: Using Constant Regexps279981 -Node: Variables283036 -Node: Using Variables283691 -Node: Assignment Options285415 -Node: Conversion287287 -Ref: table-locale-affects292663 -Ref: Conversion-Footnote-1293287 -Node: All Operators293396 -Node: Arithmetic Ops294026 -Node: Concatenation296531 -Ref: Concatenation-Footnote-1299324 -Node: Assignment Ops299444 -Ref: table-assign-ops304432 -Node: Increment Ops305840 -Node: Truth Values and Conditions309310 -Node: Truth Values310393 -Node: Typing and Comparison311442 -Node: Variable Typing312231 -Ref: Variable Typing-Footnote-1316128 -Node: Comparison Operators316250 -Ref: table-relational-ops316660 -Node: POSIX String Comparison320209 -Ref: POSIX String Comparison-Footnote-1321165 -Node: Boolean Ops321303 -Ref: Boolean Ops-Footnote-1325381 -Node: Conditional Exp325472 -Node: Function Calls327204 -Node: Precedence330798 -Node: Locales334467 -Node: Patterns and Actions335556 -Node: Pattern Overview336610 -Node: Regexp Patterns338276 -Node: Expression Patterns338819 -Node: Ranges342504 -Node: BEGIN/END345470 -Node: Using BEGIN/END346232 -Ref: Using BEGIN/END-Footnote-1348963 -Node: I/O And BEGIN/END349069 -Node: BEGINFILE/ENDFILE351351 -Node: Empty354244 -Node: Using Shell Variables354560 -Node: Action Overview356845 -Node: Statements359202 -Node: If Statement361056 -Node: While Statement362555 -Node: Do Statement364599 -Node: For Statement365755 -Node: Switch Statement368907 -Node: Break Statement371004 -Node: Continue Statement372994 -Node: Next Statement374781 -Node: Nextfile Statement377171 -Node: Exit Statement379716 -Node: Built-in Variables382132 -Node: User-modified383227 -Ref: User-modified-Footnote-1391253 -Node: Auto-set391315 -Ref: Auto-set-Footnote-1400606 -Node: ARGC and ARGV400811 -Node: Arrays404662 -Node: Array Basics406167 -Node: Array Intro406993 -Node: Reference to Elements411311 -Node: Assigning Elements413581 -Node: Array Example414072 -Node: Scanning an Array415804 -Node: Controlling Scanning418118 -Ref: Controlling Scanning-Footnote-1423050 -Node: Delete423366 -Ref: Delete-Footnote-1425801 -Node: Numeric Array Subscripts425858 -Node: Uninitialized Subscripts428041 -Node: Multi-dimensional429669 -Node: Multi-scanning432763 -Node: Arrays of Arrays434354 -Node: Functions438999 -Node: Built-in439821 -Node: Calling Built-in440899 -Node: Numeric Functions442887 -Ref: Numeric Functions-Footnote-1446652 -Ref: Numeric Functions-Footnote-2447009 -Ref: Numeric Functions-Footnote-3447057 -Node: String Functions447326 -Ref: String Functions-Footnote-1470823 -Ref: String Functions-Footnote-2470952 -Ref: String Functions-Footnote-3471200 -Node: Gory Details471287 -Ref: table-sub-escapes472966 -Ref: table-sub-posix-92474320 -Ref: table-sub-proposed475663 -Ref: table-posix-sub477013 -Ref: table-gensub-escapes478559 -Ref: Gory Details-Footnote-1479766 -Ref: Gory Details-Footnote-2479817 -Node: I/O Functions479968 -Ref: I/O Functions-Footnote-1486623 -Node: Time Functions486770 -Ref: Time Functions-Footnote-1497662 -Ref: Time Functions-Footnote-2497730 -Ref: Time Functions-Footnote-3497888 -Ref: Time Functions-Footnote-4497999 -Ref: Time Functions-Footnote-5498111 -Ref: Time Functions-Footnote-6498338 -Node: Bitwise Functions498604 -Ref: table-bitwise-ops499162 -Ref: Bitwise Functions-Footnote-1503322 -Node: Type Functions503506 -Node: I18N Functions503976 -Node: User-defined505603 -Node: Definition Syntax506407 -Ref: Definition Syntax-Footnote-1511317 -Node: Function Example511386 -Node: Function Caveats513980 -Node: Calling A Function514401 -Node: Variable Scope515516 -Node: Pass By Value/Reference517491 -Node: Return Statement520931 -Node: Dynamic Typing523912 -Node: Indirect Calls524647 -Node: Internationalization534332 -Node: I18N and L10N535758 -Node: Explaining gettext536444 -Ref: Explaining gettext-Footnote-1541510 -Ref: Explaining gettext-Footnote-2541694 -Node: Programmer i18n541859 -Node: Translator i18n546059 -Node: String Extraction546852 -Ref: String Extraction-Footnote-1547813 -Node: Printf Ordering547899 -Ref: Printf Ordering-Footnote-1550683 -Node: I18N Portability550747 -Ref: I18N Portability-Footnote-1553196 -Node: I18N Example553259 -Ref: I18N Example-Footnote-1555894 -Node: Gawk I18N555966 -Node: Advanced Features556583 -Node: Nondecimal Data558096 -Node: Array Sorting559679 -Node: Controlling Array Traversal560376 -Node: Array Sorting Functions568613 -Ref: Array Sorting Functions-Footnote-1572287 -Ref: Array Sorting Functions-Footnote-2572380 -Node: Two-way I/O572574 -Ref: Two-way I/O-Footnote-1578006 -Node: TCP/IP Networking578076 -Node: Profiling580920 -Node: Library Functions588394 -Ref: Library Functions-Footnote-1591401 -Node: Library Names591572 -Ref: Library Names-Footnote-1595043 -Ref: Library Names-Footnote-2595263 -Node: General Functions595349 -Node: Strtonum Function596302 -Node: Assert Function599232 -Node: Round Function602558 -Node: Cliff Random Function604101 -Node: Ordinal Functions605117 -Ref: Ordinal Functions-Footnote-1608187 -Ref: Ordinal Functions-Footnote-2608439 -Node: Join Function608648 -Ref: Join Function-Footnote-1610419 -Node: Gettimeofday Function610619 -Node: Data File Management614334 -Node: Filetrans Function614966 -Node: Rewind Function619105 -Node: File Checking620492 -Node: Empty Files621586 -Node: Ignoring Assigns623816 -Node: Getopt Function625369 -Ref: Getopt Function-Footnote-1636673 -Node: Passwd Functions636876 -Ref: Passwd Functions-Footnote-1645851 -Node: Group Functions645939 -Node: Walking Arrays654023 -Node: Sample Programs655592 -Node: Running Examples656257 -Node: Clones656985 -Node: Cut Program658209 -Node: Egrep Program668054 -Ref: Egrep Program-Footnote-1675827 -Node: Id Program675937 -Node: Split Program679553 -Ref: Split Program-Footnote-1683072 -Node: Tee Program683200 -Node: Uniq Program686003 -Node: Wc Program693432 -Ref: Wc Program-Footnote-1697698 -Ref: Wc Program-Footnote-2697898 -Node: Miscellaneous Programs697990 -Node: Dupword Program699178 -Node: Alarm Program701209 -Node: Translate Program705958 -Ref: Translate Program-Footnote-1710345 -Ref: Translate Program-Footnote-2710573 -Node: Labels Program710707 -Ref: Labels Program-Footnote-1714078 -Node: Word Sorting714162 -Node: History Sorting718046 -Node: Extract Program719885 -Ref: Extract Program-Footnote-1727368 -Node: Simple Sed727496 -Node: Igawk Program730558 -Ref: Igawk Program-Footnote-1745715 -Ref: Igawk Program-Footnote-2745916 -Node: Anagram Program746054 -Node: Signature Program749122 -Node: Debugger750222 -Node: Debugging751133 -Node: Debugging Concepts751546 -Node: Debugging Terms753402 -Node: Awk Debugging756025 -Node: Sample dgawk session756917 -Node: dgawk invocation757409 -Node: Finding The Bug758591 -Node: List of Debugger Commands765077 -Node: Breakpoint Control766388 -Node: Dgawk Execution Control770024 -Node: Viewing And Changing Data773375 -Node: Dgawk Stack776712 -Node: Dgawk Info778172 -Node: Miscellaneous Dgawk Commands782120 -Node: Readline Support787548 -Node: Dgawk Limitations788386 -Node: Language History790575 -Node: V7/SVR3.1792087 -Node: SVR4794408 -Node: POSIX795850 -Node: BTL796858 -Node: POSIX/GNU797592 -Node: Common Extensions802743 -Node: Ranges and Locales803850 -Ref: Ranges and Locales-Footnote-1808457 -Node: Contributors808678 -Node: Installation812940 -Node: Gawk Distribution813834 -Node: Getting814318 -Node: Extracting815144 -Node: Distribution contents816836 -Node: Unix Installation822058 -Node: Quick Installation822675 -Node: Additional Configuration Options824637 -Node: Configuration Philosophy826114 -Node: Non-Unix Installation828456 -Node: PC Installation828914 -Node: PC Binary Installation830213 -Node: PC Compiling832061 -Node: PC Testing835005 -Node: PC Using836181 -Node: Cygwin840366 -Node: MSYS841366 -Node: VMS Installation841880 -Node: VMS Compilation842483 -Ref: VMS Compilation-Footnote-1843490 -Node: VMS Installation Details843548 -Node: VMS Running845183 -Node: VMS Old Gawk846790 -Node: Bugs847264 -Node: Other Versions851116 -Node: Notes856397 -Node: Compatibility Mode857089 -Node: Additions857872 -Node: Accessing The Source858684 -Node: Adding Code860109 -Node: New Ports866076 -Node: Dynamic Extensions870189 -Node: Internals871565 -Node: Plugin License880668 -Node: Sample Library881302 -Node: Internal File Description881988 -Node: Internal File Ops885703 -Ref: Internal File Ops-Footnote-1890484 -Node: Using Internal File Ops890624 -Node: Future Extensions893001 -Node: Basic Concepts895505 -Node: Basic High Level896262 -Ref: Basic High Level-Footnote-1900297 -Node: Basic Data Typing900482 -Node: Floating Point Issues905007 -Node: String Conversion Precision906090 -Ref: String Conversion Precision-Footnote-1907790 -Node: Unexpected Results907899 -Node: POSIX Floating Point Problems909725 -Ref: POSIX Floating Point Problems-Footnote-1913430 -Node: Glossary913468 -Node: Copying938444 -Node: GNU Free Documentation License976001 -Node: Index1001138 +Node: Field Separators181774 +Node: Default Field Splitting184403 +Node: Regexp Field Splitting185520 +Node: Single Character Fields188862 +Node: Command Line Field Separator189921 +Node: Field Splitting Summary193362 +Ref: Field Splitting Summary-Footnote-1196554 +Node: Constant Size196655 +Node: Splitting By Content201239 +Ref: Splitting By Content-Footnote-1204965 +Node: Multiple Line205005 +Ref: Multiple Line-Footnote-1210852 +Node: Getline211031 +Node: Plain Getline213259 +Node: Getline/Variable215348 +Node: Getline/File216489 +Node: Getline/Variable/File217811 +Ref: Getline/Variable/File-Footnote-1219410 +Node: Getline/Pipe219497 +Node: Getline/Variable/Pipe222057 +Node: Getline/Coprocess223164 +Node: Getline/Variable/Coprocess224407 +Node: Getline Notes225121 +Node: Getline Summary227063 +Ref: table-getline-variants227406 +Node: Command line directories228262 +Node: Printing228887 +Node: Print230518 +Node: Print Examples231855 +Node: Output Separators234639 +Node: OFMT236399 +Node: Printf237757 +Node: Basic Printf238663 +Node: Control Letters240202 +Node: Format Modifiers244014 +Node: Printf Examples250023 +Node: Redirection252738 +Node: Special Files259722 +Node: Special FD260255 +Ref: Special FD-Footnote-1263880 +Node: Special Network263954 +Node: Special Caveats264804 +Node: Close Files And Pipes265600 +Ref: Close Files And Pipes-Footnote-1272623 +Ref: Close Files And Pipes-Footnote-2272771 +Node: Expressions272921 +Node: Values274053 +Node: Constants274729 +Node: Scalar Constants275409 +Ref: Scalar Constants-Footnote-1276268 +Node: Nondecimal-numbers276450 +Node: Regexp Constants279509 +Node: Using Constant Regexps279984 +Node: Variables283039 +Node: Using Variables283694 +Node: Assignment Options285418 +Node: Conversion287290 +Ref: table-locale-affects292666 +Ref: Conversion-Footnote-1293290 +Node: All Operators293399 +Node: Arithmetic Ops294029 +Node: Concatenation296534 +Ref: Concatenation-Footnote-1299327 +Node: Assignment Ops299447 +Ref: table-assign-ops304435 +Node: Increment Ops305843 +Node: Truth Values and Conditions309313 +Node: Truth Values310396 +Node: Typing and Comparison311445 +Node: Variable Typing312234 +Ref: Variable Typing-Footnote-1316131 +Node: Comparison Operators316253 +Ref: table-relational-ops316663 +Node: POSIX String Comparison320212 +Ref: POSIX String Comparison-Footnote-1321168 +Node: Boolean Ops321306 +Ref: Boolean Ops-Footnote-1325384 +Node: Conditional Exp325475 +Node: Function Calls327207 +Node: Precedence330801 +Node: Locales334470 +Node: Patterns and Actions335559 +Node: Pattern Overview336613 +Node: Regexp Patterns338279 +Node: Expression Patterns338822 +Node: Ranges342507 +Node: BEGIN/END345473 +Node: Using BEGIN/END346235 +Ref: Using BEGIN/END-Footnote-1348966 +Node: I/O And BEGIN/END349072 +Node: BEGINFILE/ENDFILE351354 +Node: Empty354247 +Node: Using Shell Variables354563 +Node: Action Overview356848 +Node: Statements359205 +Node: If Statement361059 +Node: While Statement362558 +Node: Do Statement364602 +Node: For Statement365758 +Node: Switch Statement368910 +Node: Break Statement371007 +Node: Continue Statement372997 +Node: Next Statement374784 +Node: Nextfile Statement377174 +Node: Exit Statement379719 +Node: Built-in Variables382135 +Node: User-modified383230 +Ref: User-modified-Footnote-1391256 +Node: Auto-set391318 +Ref: Auto-set-Footnote-1400609 +Node: ARGC and ARGV400814 +Node: Arrays404665 +Node: Array Basics406170 +Node: Array Intro406996 +Node: Reference to Elements411314 +Node: Assigning Elements413584 +Node: Array Example414075 +Node: Scanning an Array415807 +Node: Controlling Scanning418121 +Ref: Controlling Scanning-Footnote-1423053 +Node: Delete423369 +Ref: Delete-Footnote-1425804 +Node: Numeric Array Subscripts425861 +Node: Uninitialized Subscripts428044 +Node: Multi-dimensional429672 +Node: Multi-scanning432766 +Node: Arrays of Arrays434357 +Node: Functions439002 +Node: Built-in439824 +Node: Calling Built-in440902 +Node: Numeric Functions442890 +Ref: Numeric Functions-Footnote-1446655 +Ref: Numeric Functions-Footnote-2447012 +Ref: Numeric Functions-Footnote-3447060 +Node: String Functions447329 +Ref: String Functions-Footnote-1470826 +Ref: String Functions-Footnote-2470955 +Ref: String Functions-Footnote-3471203 +Node: Gory Details471290 +Ref: table-sub-escapes472969 +Ref: table-sub-posix-92474323 +Ref: table-sub-proposed475666 +Ref: table-posix-sub477016 +Ref: table-gensub-escapes478562 +Ref: Gory Details-Footnote-1479769 +Ref: Gory Details-Footnote-2479820 +Node: I/O Functions479971 +Ref: I/O Functions-Footnote-1486626 +Node: Time Functions486773 +Ref: Time Functions-Footnote-1497665 +Ref: Time Functions-Footnote-2497733 +Ref: Time Functions-Footnote-3497891 +Ref: Time Functions-Footnote-4498002 +Ref: Time Functions-Footnote-5498114 +Ref: Time Functions-Footnote-6498341 +Node: Bitwise Functions498607 +Ref: table-bitwise-ops499165 +Ref: Bitwise Functions-Footnote-1503325 +Node: Type Functions503509 +Node: I18N Functions503979 +Node: User-defined505606 +Node: Definition Syntax506410 +Ref: Definition Syntax-Footnote-1511320 +Node: Function Example511389 +Node: Function Caveats513983 +Node: Calling A Function514404 +Node: Variable Scope515519 +Node: Pass By Value/Reference517494 +Node: Return Statement520934 +Node: Dynamic Typing523915 +Node: Indirect Calls524650 +Node: Internationalization534335 +Node: I18N and L10N535761 +Node: Explaining gettext536447 +Ref: Explaining gettext-Footnote-1541513 +Ref: Explaining gettext-Footnote-2541697 +Node: Programmer i18n541862 +Node: Translator i18n546062 +Node: String Extraction546855 +Ref: String Extraction-Footnote-1547816 +Node: Printf Ordering547902 +Ref: Printf Ordering-Footnote-1550686 +Node: I18N Portability550750 +Ref: I18N Portability-Footnote-1553199 +Node: I18N Example553262 +Ref: I18N Example-Footnote-1555897 +Node: Gawk I18N555969 +Node: Advanced Features556586 +Node: Nondecimal Data558099 +Node: Array Sorting559682 +Node: Controlling Array Traversal560379 +Node: Array Sorting Functions568616 +Ref: Array Sorting Functions-Footnote-1572290 +Ref: Array Sorting Functions-Footnote-2572383 +Node: Two-way I/O572577 +Ref: Two-way I/O-Footnote-1578009 +Node: TCP/IP Networking578079 +Node: Profiling580923 +Node: Library Functions588397 +Ref: Library Functions-Footnote-1591404 +Node: Library Names591575 +Ref: Library Names-Footnote-1595046 +Ref: Library Names-Footnote-2595266 +Node: General Functions595352 +Node: Strtonum Function596305 +Node: Assert Function599235 +Node: Round Function602561 +Node: Cliff Random Function604104 +Node: Ordinal Functions605120 +Ref: Ordinal Functions-Footnote-1608190 +Ref: Ordinal Functions-Footnote-2608442 +Node: Join Function608651 +Ref: Join Function-Footnote-1610422 +Node: Gettimeofday Function610622 +Node: Data File Management614337 +Node: Filetrans Function614969 +Node: Rewind Function619108 +Node: File Checking620495 +Node: Empty Files621589 +Node: Ignoring Assigns623819 +Node: Getopt Function625372 +Ref: Getopt Function-Footnote-1636676 +Node: Passwd Functions636879 +Ref: Passwd Functions-Footnote-1645854 +Node: Group Functions645942 +Node: Walking Arrays654026 +Node: Sample Programs655595 +Node: Running Examples656260 +Node: Clones656988 +Node: Cut Program658212 +Node: Egrep Program668057 +Ref: Egrep Program-Footnote-1675830 +Node: Id Program675940 +Node: Split Program679556 +Ref: Split Program-Footnote-1683075 +Node: Tee Program683203 +Node: Uniq Program686006 +Node: Wc Program693435 +Ref: Wc Program-Footnote-1697701 +Ref: Wc Program-Footnote-2697901 +Node: Miscellaneous Programs697993 +Node: Dupword Program699181 +Node: Alarm Program701212 +Node: Translate Program705961 +Ref: Translate Program-Footnote-1710348 +Ref: Translate Program-Footnote-2710576 +Node: Labels Program710710 +Ref: Labels Program-Footnote-1714081 +Node: Word Sorting714165 +Node: History Sorting718049 +Node: Extract Program719888 +Ref: Extract Program-Footnote-1727371 +Node: Simple Sed727499 +Node: Igawk Program730561 +Ref: Igawk Program-Footnote-1745718 +Ref: Igawk Program-Footnote-2745919 +Node: Anagram Program746057 +Node: Signature Program749125 +Node: Debugger750225 +Node: Debugging751136 +Node: Debugging Concepts751549 +Node: Debugging Terms753405 +Node: Awk Debugging756028 +Node: Sample dgawk session756920 +Node: dgawk invocation757412 +Node: Finding The Bug758594 +Node: List of Debugger Commands765080 +Node: Breakpoint Control766391 +Node: Dgawk Execution Control770027 +Node: Viewing And Changing Data773378 +Node: Dgawk Stack776715 +Node: Dgawk Info778175 +Node: Miscellaneous Dgawk Commands782123 +Node: Readline Support787551 +Node: Dgawk Limitations788389 +Node: Language History790578 +Node: V7/SVR3.1792090 +Node: SVR4794411 +Node: POSIX795853 +Node: BTL796861 +Node: POSIX/GNU797595 +Node: Common Extensions802746 +Node: Ranges and Locales803853 +Ref: Ranges and Locales-Footnote-1808460 +Node: Contributors808681 +Node: Installation812943 +Node: Gawk Distribution813837 +Node: Getting814321 +Node: Extracting815147 +Node: Distribution contents816839 +Node: Unix Installation822061 +Node: Quick Installation822678 +Node: Additional Configuration Options824640 +Node: Configuration Philosophy826117 +Node: Non-Unix Installation828459 +Node: PC Installation828917 +Node: PC Binary Installation830216 +Node: PC Compiling832064 +Node: PC Testing835008 +Node: PC Using836184 +Node: Cygwin840369 +Node: MSYS841369 +Node: VMS Installation841883 +Node: VMS Compilation842486 +Ref: VMS Compilation-Footnote-1843493 +Node: VMS Installation Details843551 +Node: VMS Running845186 +Node: VMS Old Gawk846793 +Node: Bugs847267 +Node: Other Versions851119 +Node: Notes856400 +Node: Compatibility Mode857092 +Node: Additions857875 +Node: Accessing The Source858687 +Node: Adding Code860112 +Node: New Ports866079 +Node: Dynamic Extensions870192 +Node: Internals871568 +Node: Plugin License880671 +Node: Sample Library881305 +Node: Internal File Description881991 +Node: Internal File Ops885706 +Ref: Internal File Ops-Footnote-1890487 +Node: Using Internal File Ops890627 +Node: Future Extensions893004 +Node: Basic Concepts895508 +Node: Basic High Level896265 +Ref: Basic High Level-Footnote-1900300 +Node: Basic Data Typing900485 +Node: Floating Point Issues905010 +Node: String Conversion Precision906093 +Ref: String Conversion Precision-Footnote-1907793 +Node: Unexpected Results907902 +Node: POSIX Floating Point Problems909728 +Ref: POSIX Floating Point Problems-Footnote-1913433 +Node: Glossary913471 +Node: Copying938447 +Node: GNU Free Documentation License976004 +Node: Index1001141  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index dfd6dd86..9cd4b74c 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -5706,7 +5706,7 @@ print $0 # or whatever else with $0 @end example @noindent -This forces @command{awk} rebuild the record. It does help +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 -- cgit v1.2.3 From 958b6cb452c88e7ba064253b6f461ebacfc1b736 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 21:30:15 +0200 Subject: Sync dfa.c with GNU grep. --- ChangeLog | 4 ++++ dfa.c | 37 +++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7a8be63..d2d677a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-11-27 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + 2011-11-14 John Haque * debug.c (set_breakpoint_at): Fix problem with setting diff --git a/dfa.c b/dfa.c index cba66886..37ddc1bc 100644 --- a/dfa.c +++ b/dfa.c @@ -608,7 +608,8 @@ setbit_c (int b, charclass c) } #else # define setbit_c setbit -static inline bool setbit_wc (wint_t wc, charclass c) +static inline bool +setbit_wc (wint_t wc, charclass c) { abort (); /*NOTREACHED*/ @@ -782,7 +783,7 @@ static const struct dfa_ctype prednames[] = { { NULL, NULL, false } }; -static const struct dfa_ctype * +static const struct dfa_ctype * _GL_ATTRIBUTE_PURE find_pred (const char *str) { unsigned int i; @@ -802,7 +803,6 @@ parse_bracket_exp (void) int invert; int c, c1, c2; charclass ccl; - wint_t wc1 = 0; /* Used to warn about [:space:]. Bit 0 = first character is a colon. @@ -813,6 +813,7 @@ parse_bracket_exp (void) wint_t wc; wint_t wc2; + wint_t wc1 = 0; /* Work area to build a mb_char_classes. */ struct mb_char_classes *work_mbc; @@ -1080,8 +1081,18 @@ parse_bracket_exp (void) return CSET + charclass_index(ccl); } +/* 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) (isalnum(C) || (C) == '_') +#define IS_WORD_CONSTITUENT(C) \ + (is_valid_unibyte_character(C) && (isalnum(C) || (C) == '_')) static token lex (void) @@ -1678,7 +1689,7 @@ atom (void) } /* Return the number of tokens in the given subexpression. */ -static int +static int _GL_ATTRIBUTE_PURE nsubtoks (int tindex) { int ntoks1; @@ -2128,9 +2139,7 @@ dfaanalyze (struct dfa *d, int searchflag) CALLOC(d->follows, d->tindex); for (i = 0; i < d->tindex; ++i) -#ifdef DEBUG - { /* Nonsyntactic #ifdef goo... */ -#endif + { switch (d->tokens[i]) { case EMPTY: @@ -2255,8 +2264,8 @@ dfaanalyze (struct dfa *d, int searchflag) 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. */ @@ -3256,7 +3265,7 @@ dfaexec (struct dfa *d, char const *begin, char *end, for (;;) { if (d->mb_cur_max > 1) - while ((t = trans[s])) + while ((t = trans[s]) != NULL) { if (p > buf_end) break; @@ -3289,10 +3298,10 @@ dfaexec (struct dfa *d, char const *begin, char *end, } else { - while ((t = trans[s]) != 0) + while ((t = trans[s]) != NULL) { s1 = t[*p++]; - if ((t = trans[s1]) == 0) + if ((t = trans[s1]) == NULL) { int tmp = s; s = s1; s1 = tmp; /* swap */ break; @@ -3603,7 +3612,7 @@ icpyalloc (char const *string) return icatalloc (NULL, string); } -static char * +static char * _GL_ATTRIBUTE_PURE istrstr (char const *lookin, char const *lookfor) { char const *cp; @@ -4015,7 +4024,7 @@ dfaalloc (void) return xmalloc (sizeof (struct dfa)); } -struct dfamust * +struct dfamust * _GL_ATTRIBUTE_PURE dfamusts (struct dfa const *d) { return d->musts; -- cgit v1.2.3 From c45c07f2825065fdeb701c5dff763b988f6d9653 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 21:35:33 +0200 Subject: Documentation updates of various sorts. --- NEWS | 10 +- README_d/README.bootstrap | 32 +++ doc/ChangeLog | 4 + doc/gawk.info | 526 +++++++++++++++++++++++----------------------- doc/gawk.texi | 14 +- 5 files changed, 311 insertions(+), 275 deletions(-) create mode 100644 README_d/README.bootstrap diff --git a/NEWS b/NEWS index 0745c32d..289ce86e 100644 --- a/NEWS +++ b/NEWS @@ -7,12 +7,12 @@ 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. +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. -XXX. Lots of minor bugs fixed and portability clean-ups along the way. See the ChangeLog - for details. +XXX. 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 --------------------------- diff --git a/README_d/README.bootstrap b/README_d/README.bootstrap new file mode 100644 index 00000000..152bbefa --- /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/doc/ChangeLog b/doc/ChangeLog index dec5ddca..2921a919 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +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. diff --git a/doc/gawk.info b/doc/gawk.info index 877f50d3..38ddd47c 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -7973,7 +7973,7 @@ summary of the types of `awk' patterns: `BEGINFILE' `ENDFILE' - Special patterns for you to supply startup or cleanup actions to + Special patterns for you to supply startup or cleanup actions to be done on a per file basis. (*Note BEGINFILE/ENDFILE::.) `EMPTY' @@ -8852,12 +8852,12 @@ the previous example with the following `while' loop: This program loops forever once `x' reaches 5. The `continue' statement has no special meaning with respect to the -`switch' statement, nor does it 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'. +`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 @@ -27588,261 +27588,261 @@ Node: Precedence330801 Node: Locales334470 Node: Patterns and Actions335559 Node: Pattern Overview336613 -Node: Regexp Patterns338279 -Node: Expression Patterns338822 -Node: Ranges342507 -Node: BEGIN/END345473 -Node: Using BEGIN/END346235 -Ref: Using BEGIN/END-Footnote-1348966 -Node: I/O And BEGIN/END349072 -Node: BEGINFILE/ENDFILE351354 -Node: Empty354247 -Node: Using Shell Variables354563 -Node: Action Overview356848 -Node: Statements359205 -Node: If Statement361059 -Node: While Statement362558 -Node: Do Statement364602 -Node: For Statement365758 -Node: Switch Statement368910 -Node: Break Statement371007 -Node: Continue Statement372997 -Node: Next Statement374784 -Node: Nextfile Statement377174 -Node: Exit Statement379719 -Node: Built-in Variables382135 -Node: User-modified383230 -Ref: User-modified-Footnote-1391256 -Node: Auto-set391318 -Ref: Auto-set-Footnote-1400609 -Node: ARGC and ARGV400814 -Node: Arrays404665 -Node: Array Basics406170 -Node: Array Intro406996 -Node: Reference to Elements411314 -Node: Assigning Elements413584 -Node: Array Example414075 -Node: Scanning an Array415807 -Node: Controlling Scanning418121 -Ref: Controlling Scanning-Footnote-1423053 -Node: Delete423369 -Ref: Delete-Footnote-1425804 -Node: Numeric Array Subscripts425861 -Node: Uninitialized Subscripts428044 -Node: Multi-dimensional429672 -Node: Multi-scanning432766 -Node: Arrays of Arrays434357 -Node: Functions439002 -Node: Built-in439824 -Node: Calling Built-in440902 -Node: Numeric Functions442890 -Ref: Numeric Functions-Footnote-1446655 -Ref: Numeric Functions-Footnote-2447012 -Ref: Numeric Functions-Footnote-3447060 -Node: String Functions447329 -Ref: String Functions-Footnote-1470826 -Ref: String Functions-Footnote-2470955 -Ref: String Functions-Footnote-3471203 -Node: Gory Details471290 -Ref: table-sub-escapes472969 -Ref: table-sub-posix-92474323 -Ref: table-sub-proposed475666 -Ref: table-posix-sub477016 -Ref: table-gensub-escapes478562 -Ref: Gory Details-Footnote-1479769 -Ref: Gory Details-Footnote-2479820 -Node: I/O Functions479971 -Ref: I/O Functions-Footnote-1486626 -Node: Time Functions486773 -Ref: Time Functions-Footnote-1497665 -Ref: Time Functions-Footnote-2497733 -Ref: Time Functions-Footnote-3497891 -Ref: Time Functions-Footnote-4498002 -Ref: Time Functions-Footnote-5498114 -Ref: Time Functions-Footnote-6498341 -Node: Bitwise Functions498607 -Ref: table-bitwise-ops499165 -Ref: Bitwise Functions-Footnote-1503325 -Node: Type Functions503509 -Node: I18N Functions503979 -Node: User-defined505606 -Node: Definition Syntax506410 -Ref: Definition Syntax-Footnote-1511320 -Node: Function Example511389 -Node: Function Caveats513983 -Node: Calling A Function514404 -Node: Variable Scope515519 -Node: Pass By Value/Reference517494 -Node: Return Statement520934 -Node: Dynamic Typing523915 -Node: Indirect Calls524650 -Node: Internationalization534335 -Node: I18N and L10N535761 -Node: Explaining gettext536447 -Ref: Explaining gettext-Footnote-1541513 -Ref: Explaining gettext-Footnote-2541697 -Node: Programmer i18n541862 -Node: Translator i18n546062 -Node: String Extraction546855 -Ref: String Extraction-Footnote-1547816 -Node: Printf Ordering547902 -Ref: Printf Ordering-Footnote-1550686 -Node: I18N Portability550750 -Ref: I18N Portability-Footnote-1553199 -Node: I18N Example553262 -Ref: I18N Example-Footnote-1555897 -Node: Gawk I18N555969 -Node: Advanced Features556586 -Node: Nondecimal Data558099 -Node: Array Sorting559682 -Node: Controlling Array Traversal560379 -Node: Array Sorting Functions568616 -Ref: Array Sorting Functions-Footnote-1572290 -Ref: Array Sorting Functions-Footnote-2572383 -Node: Two-way I/O572577 -Ref: Two-way I/O-Footnote-1578009 -Node: TCP/IP Networking578079 -Node: Profiling580923 -Node: Library Functions588397 -Ref: Library Functions-Footnote-1591404 -Node: Library Names591575 -Ref: Library Names-Footnote-1595046 -Ref: Library Names-Footnote-2595266 -Node: General Functions595352 -Node: Strtonum Function596305 -Node: Assert Function599235 -Node: Round Function602561 -Node: Cliff Random Function604104 -Node: Ordinal Functions605120 -Ref: Ordinal Functions-Footnote-1608190 -Ref: Ordinal Functions-Footnote-2608442 -Node: Join Function608651 -Ref: Join Function-Footnote-1610422 -Node: Gettimeofday Function610622 -Node: Data File Management614337 -Node: Filetrans Function614969 -Node: Rewind Function619108 -Node: File Checking620495 -Node: Empty Files621589 -Node: Ignoring Assigns623819 -Node: Getopt Function625372 -Ref: Getopt Function-Footnote-1636676 -Node: Passwd Functions636879 -Ref: Passwd Functions-Footnote-1645854 -Node: Group Functions645942 -Node: Walking Arrays654026 -Node: Sample Programs655595 -Node: Running Examples656260 -Node: Clones656988 -Node: Cut Program658212 -Node: Egrep Program668057 -Ref: Egrep Program-Footnote-1675830 -Node: Id Program675940 -Node: Split Program679556 -Ref: Split Program-Footnote-1683075 -Node: Tee Program683203 -Node: Uniq Program686006 -Node: Wc Program693435 -Ref: Wc Program-Footnote-1697701 -Ref: Wc Program-Footnote-2697901 -Node: Miscellaneous Programs697993 -Node: Dupword Program699181 -Node: Alarm Program701212 -Node: Translate Program705961 -Ref: Translate Program-Footnote-1710348 -Ref: Translate Program-Footnote-2710576 -Node: Labels Program710710 -Ref: Labels Program-Footnote-1714081 -Node: Word Sorting714165 -Node: History Sorting718049 -Node: Extract Program719888 -Ref: Extract Program-Footnote-1727371 -Node: Simple Sed727499 -Node: Igawk Program730561 -Ref: Igawk Program-Footnote-1745718 -Ref: Igawk Program-Footnote-2745919 -Node: Anagram Program746057 -Node: Signature Program749125 -Node: Debugger750225 -Node: Debugging751136 -Node: Debugging Concepts751549 -Node: Debugging Terms753405 -Node: Awk Debugging756028 -Node: Sample dgawk session756920 -Node: dgawk invocation757412 -Node: Finding The Bug758594 -Node: List of Debugger Commands765080 -Node: Breakpoint Control766391 -Node: Dgawk Execution Control770027 -Node: Viewing And Changing Data773378 -Node: Dgawk Stack776715 -Node: Dgawk Info778175 -Node: Miscellaneous Dgawk Commands782123 -Node: Readline Support787551 -Node: Dgawk Limitations788389 -Node: Language History790578 -Node: V7/SVR3.1792090 -Node: SVR4794411 -Node: POSIX795853 -Node: BTL796861 -Node: POSIX/GNU797595 -Node: Common Extensions802746 -Node: Ranges and Locales803853 -Ref: Ranges and Locales-Footnote-1808460 -Node: Contributors808681 -Node: Installation812943 -Node: Gawk Distribution813837 -Node: Getting814321 -Node: Extracting815147 -Node: Distribution contents816839 -Node: Unix Installation822061 -Node: Quick Installation822678 -Node: Additional Configuration Options824640 -Node: Configuration Philosophy826117 -Node: Non-Unix Installation828459 -Node: PC Installation828917 -Node: PC Binary Installation830216 -Node: PC Compiling832064 -Node: PC Testing835008 -Node: PC Using836184 -Node: Cygwin840369 -Node: MSYS841369 -Node: VMS Installation841883 -Node: VMS Compilation842486 -Ref: VMS Compilation-Footnote-1843493 -Node: VMS Installation Details843551 -Node: VMS Running845186 -Node: VMS Old Gawk846793 -Node: Bugs847267 -Node: Other Versions851119 -Node: Notes856400 -Node: Compatibility Mode857092 -Node: Additions857875 -Node: Accessing The Source858687 -Node: Adding Code860112 -Node: New Ports866079 -Node: Dynamic Extensions870192 -Node: Internals871568 -Node: Plugin License880671 -Node: Sample Library881305 -Node: Internal File Description881991 -Node: Internal File Ops885706 -Ref: Internal File Ops-Footnote-1890487 -Node: Using Internal File Ops890627 -Node: Future Extensions893004 -Node: Basic Concepts895508 -Node: Basic High Level896265 -Ref: Basic High Level-Footnote-1900300 -Node: Basic Data Typing900485 -Node: Floating Point Issues905010 -Node: String Conversion Precision906093 -Ref: String Conversion Precision-Footnote-1907793 -Node: Unexpected Results907902 -Node: POSIX Floating Point Problems909728 -Ref: POSIX Floating Point Problems-Footnote-1913433 -Node: Glossary913471 -Node: Copying938447 -Node: GNU Free Documentation License976004 -Node: Index1001141 +Node: Regexp Patterns338282 +Node: Expression Patterns338825 +Node: Ranges342510 +Node: BEGIN/END345476 +Node: Using BEGIN/END346238 +Ref: Using BEGIN/END-Footnote-1348969 +Node: I/O And BEGIN/END349075 +Node: BEGINFILE/ENDFILE351357 +Node: Empty354250 +Node: Using Shell Variables354566 +Node: Action Overview356851 +Node: Statements359208 +Node: If Statement361062 +Node: While Statement362561 +Node: Do Statement364605 +Node: For Statement365761 +Node: Switch Statement368913 +Node: Break Statement371010 +Node: Continue Statement373000 +Node: Next Statement374793 +Node: Nextfile Statement377183 +Node: Exit Statement379728 +Node: Built-in Variables382144 +Node: User-modified383239 +Ref: User-modified-Footnote-1391265 +Node: Auto-set391327 +Ref: Auto-set-Footnote-1400618 +Node: ARGC and ARGV400823 +Node: Arrays404674 +Node: Array Basics406179 +Node: Array Intro407005 +Node: Reference to Elements411323 +Node: Assigning Elements413593 +Node: Array Example414084 +Node: Scanning an Array415816 +Node: Controlling Scanning418130 +Ref: Controlling Scanning-Footnote-1423062 +Node: Delete423378 +Ref: Delete-Footnote-1425813 +Node: Numeric Array Subscripts425870 +Node: Uninitialized Subscripts428053 +Node: Multi-dimensional429681 +Node: Multi-scanning432775 +Node: Arrays of Arrays434366 +Node: Functions439011 +Node: Built-in439833 +Node: Calling Built-in440911 +Node: Numeric Functions442899 +Ref: Numeric Functions-Footnote-1446664 +Ref: Numeric Functions-Footnote-2447021 +Ref: Numeric Functions-Footnote-3447069 +Node: String Functions447338 +Ref: String Functions-Footnote-1470835 +Ref: String Functions-Footnote-2470964 +Ref: String Functions-Footnote-3471212 +Node: Gory Details471299 +Ref: table-sub-escapes472978 +Ref: table-sub-posix-92474332 +Ref: table-sub-proposed475675 +Ref: table-posix-sub477025 +Ref: table-gensub-escapes478571 +Ref: Gory Details-Footnote-1479778 +Ref: Gory Details-Footnote-2479829 +Node: I/O Functions479980 +Ref: I/O Functions-Footnote-1486635 +Node: Time Functions486782 +Ref: Time Functions-Footnote-1497674 +Ref: Time Functions-Footnote-2497742 +Ref: Time Functions-Footnote-3497900 +Ref: Time Functions-Footnote-4498011 +Ref: Time Functions-Footnote-5498123 +Ref: Time Functions-Footnote-6498350 +Node: Bitwise Functions498616 +Ref: table-bitwise-ops499174 +Ref: Bitwise Functions-Footnote-1503334 +Node: Type Functions503518 +Node: I18N Functions503988 +Node: User-defined505615 +Node: Definition Syntax506419 +Ref: Definition Syntax-Footnote-1511329 +Node: Function Example511398 +Node: Function Caveats513992 +Node: Calling A Function514413 +Node: Variable Scope515528 +Node: Pass By Value/Reference517503 +Node: Return Statement520943 +Node: Dynamic Typing523924 +Node: Indirect Calls524659 +Node: Internationalization534344 +Node: I18N and L10N535770 +Node: Explaining gettext536456 +Ref: Explaining gettext-Footnote-1541522 +Ref: Explaining gettext-Footnote-2541706 +Node: Programmer i18n541871 +Node: Translator i18n546071 +Node: String Extraction546864 +Ref: String Extraction-Footnote-1547825 +Node: Printf Ordering547911 +Ref: Printf Ordering-Footnote-1550695 +Node: I18N Portability550759 +Ref: I18N Portability-Footnote-1553208 +Node: I18N Example553271 +Ref: I18N Example-Footnote-1555906 +Node: Gawk I18N555978 +Node: Advanced Features556595 +Node: Nondecimal Data558108 +Node: Array Sorting559691 +Node: Controlling Array Traversal560388 +Node: Array Sorting Functions568625 +Ref: Array Sorting Functions-Footnote-1572299 +Ref: Array Sorting Functions-Footnote-2572392 +Node: Two-way I/O572586 +Ref: Two-way I/O-Footnote-1578018 +Node: TCP/IP Networking578088 +Node: Profiling580932 +Node: Library Functions588406 +Ref: Library Functions-Footnote-1591413 +Node: Library Names591584 +Ref: Library Names-Footnote-1595055 +Ref: Library Names-Footnote-2595275 +Node: General Functions595361 +Node: Strtonum Function596314 +Node: Assert Function599244 +Node: Round Function602570 +Node: Cliff Random Function604113 +Node: Ordinal Functions605129 +Ref: Ordinal Functions-Footnote-1608199 +Ref: Ordinal Functions-Footnote-2608451 +Node: Join Function608660 +Ref: Join Function-Footnote-1610431 +Node: Gettimeofday Function610631 +Node: Data File Management614346 +Node: Filetrans Function614978 +Node: Rewind Function619117 +Node: File Checking620504 +Node: Empty Files621598 +Node: Ignoring Assigns623828 +Node: Getopt Function625381 +Ref: Getopt Function-Footnote-1636685 +Node: Passwd Functions636888 +Ref: Passwd Functions-Footnote-1645863 +Node: Group Functions645951 +Node: Walking Arrays654035 +Node: Sample Programs655604 +Node: Running Examples656269 +Node: Clones656997 +Node: Cut Program658221 +Node: Egrep Program668066 +Ref: Egrep Program-Footnote-1675839 +Node: Id Program675949 +Node: Split Program679565 +Ref: Split Program-Footnote-1683084 +Node: Tee Program683212 +Node: Uniq Program686015 +Node: Wc Program693444 +Ref: Wc Program-Footnote-1697710 +Ref: Wc Program-Footnote-2697910 +Node: Miscellaneous Programs698002 +Node: Dupword Program699190 +Node: Alarm Program701221 +Node: Translate Program705970 +Ref: Translate Program-Footnote-1710357 +Ref: Translate Program-Footnote-2710585 +Node: Labels Program710719 +Ref: Labels Program-Footnote-1714090 +Node: Word Sorting714174 +Node: History Sorting718058 +Node: Extract Program719897 +Ref: Extract Program-Footnote-1727380 +Node: Simple Sed727508 +Node: Igawk Program730570 +Ref: Igawk Program-Footnote-1745727 +Ref: Igawk Program-Footnote-2745928 +Node: Anagram Program746066 +Node: Signature Program749134 +Node: Debugger750234 +Node: Debugging751145 +Node: Debugging Concepts751558 +Node: Debugging Terms753414 +Node: Awk Debugging756037 +Node: Sample dgawk session756929 +Node: dgawk invocation757421 +Node: Finding The Bug758603 +Node: List of Debugger Commands765089 +Node: Breakpoint Control766400 +Node: Dgawk Execution Control770036 +Node: Viewing And Changing Data773387 +Node: Dgawk Stack776724 +Node: Dgawk Info778184 +Node: Miscellaneous Dgawk Commands782132 +Node: Readline Support787560 +Node: Dgawk Limitations788398 +Node: Language History790587 +Node: V7/SVR3.1792099 +Node: SVR4794420 +Node: POSIX795862 +Node: BTL796870 +Node: POSIX/GNU797604 +Node: Common Extensions802755 +Node: Ranges and Locales803862 +Ref: Ranges and Locales-Footnote-1808469 +Node: Contributors808690 +Node: Installation812952 +Node: Gawk Distribution813846 +Node: Getting814330 +Node: Extracting815156 +Node: Distribution contents816848 +Node: Unix Installation822070 +Node: Quick Installation822687 +Node: Additional Configuration Options824649 +Node: Configuration Philosophy826126 +Node: Non-Unix Installation828468 +Node: PC Installation828926 +Node: PC Binary Installation830225 +Node: PC Compiling832073 +Node: PC Testing835017 +Node: PC Using836193 +Node: Cygwin840378 +Node: MSYS841378 +Node: VMS Installation841892 +Node: VMS Compilation842495 +Ref: VMS Compilation-Footnote-1843502 +Node: VMS Installation Details843560 +Node: VMS Running845195 +Node: VMS Old Gawk846802 +Node: Bugs847276 +Node: Other Versions851128 +Node: Notes856409 +Node: Compatibility Mode857101 +Node: Additions857884 +Node: Accessing The Source858696 +Node: Adding Code860121 +Node: New Ports866088 +Node: Dynamic Extensions870201 +Node: Internals871577 +Node: Plugin License880680 +Node: Sample Library881314 +Node: Internal File Description882000 +Node: Internal File Ops885715 +Ref: Internal File Ops-Footnote-1890496 +Node: Using Internal File Ops890636 +Node: Future Extensions893013 +Node: Basic Concepts895517 +Node: Basic High Level896274 +Ref: Basic High Level-Footnote-1900309 +Node: Basic Data Typing900494 +Node: Floating Point Issues905019 +Node: String Conversion Precision906102 +Ref: String Conversion Precision-Footnote-1907802 +Node: Unexpected Results907911 +Node: POSIX Floating Point Problems909737 +Ref: POSIX Floating Point Problems-Footnote-1913442 +Node: Glossary913480 +Node: Copying938456 +Node: GNU Free Documentation License976013 +Node: Index1001150  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 9cd4b74c..33e66d70 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -10908,7 +10908,7 @@ Special patterns for you to supply startup or cleanup actions for your @item BEGINFILE @itemx ENDFILE -Special patterns for you to supply startup or cleanup actions to +Special patterns for you to supply startup or cleanup actions to be done on a per file basis. (@xref{BEGINFILE/ENDFILE}.) @@ -12023,8 +12023,8 @@ This program loops forever once @code{x} reaches 5. @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 any meaning when used outside the body of -a loop. Historical versions of @command{awk} treated a @code{continue} +@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 @@ -13415,7 +13415,7 @@ 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 mechanims which give you this control. +@command{gawk} provides two mechanisms which give you this control. @itemize @bullet @item @@ -18455,7 +18455,7 @@ END @{ @end example The first field in each entry of the password file is the user's login name, -and the fields are seperated by colons. +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 @@ -27011,13 +27011,13 @@ 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 contigous. (On an EBCDIC system, the range @samp{[a-z]} +@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 the ``correct'' way to match uppercase letters. +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}). -- cgit v1.2.3 From 77620464b7805e03fcfc5de21a6e46b32426c6f0 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 21:37:17 +0200 Subject: Also need this change for dfa.h for dfa.c sync. --- ChangeLog | 1 + dfa.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index d2d677a7..4de41541 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 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 diff --git a/dfa.h b/dfa.h index 4d65ee34..d45f3139 100644 --- a/dfa.h +++ b/dfa.h @@ -22,6 +22,13 @@ # 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 -- cgit v1.2.3 From c399d8f8226bba46d34b8672ca50722605f95e37 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 21:39:57 +0200 Subject: MBS support tweaks for DJGPP and z/OS. --- ChangeLog | 6 ++++++ awk.h | 8 ++++---- io.c | 4 ++-- mbsupport.h | 7 +++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4de41541..42fe783c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +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. diff --git a/awk.h b/awk.h index 0c954723..a267d2ee 100644 --- a/awk.h +++ b/awk.h @@ -76,6 +76,10 @@ extern int errno; #endif +#ifdef STDC_HEADERS +#include +#endif /* not STDC_HEADERS */ + #include "mbsupport.h" /* defines MBS_SUPPORT */ #if MBS_SUPPORT @@ -131,10 +135,6 @@ typedef int off_t; #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif -#ifdef STDC_HEADERS -#include -#endif /* not STDC_HEADERS */ - #include "protos.h" #ifdef HAVE_STRING_H diff --git a/io.c b/io.c index e423a436..9c827eda 100644 --- a/io.c +++ b/io.c @@ -1594,7 +1594,7 @@ two_way_open(const char *str, struct redirect *rp) } #endif /* HAVE_SOCKETS */ -#ifdef HAVE_TERMIOS_H +#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; @@ -1809,7 +1809,7 @@ two_way_open(const char *str, struct redirect *rp) first_pty_letter = '\0'; /* reset for next command */ return TRUE; } -#endif /* HAVE_TERMIOS_H */ +#endif /* defined(HAVE_TERMIOS_H) && ! defined(ZOS_USS) */ use_pipes: #ifndef PIPES_SIMULATED /* real pipes */ diff --git a/mbsupport.h b/mbsupport.h index 57abaa60..f647d788 100644 --- a/mbsupport.h +++ b/mbsupport.h @@ -40,7 +40,7 @@ #if defined(HAVE_ISWCTYPE) \ && defined(HAVE_LOCALE_H) \ - && defined(HAVE_BTOWC) \ + && (defined(HAVE_BTOWC) || defined(ZOS_USS)) \ && defined(HAVE_MBRLEN) \ && defined(HAVE_MBRTOWC) \ && defined(HAVE_WCHAR_H) \ @@ -71,7 +71,10 @@ /* All this glop is for dfa.c. Bleah. */ -#define wchar_t char +#ifndef DJGPP +#define wchar_t char +#endif + #define wctype_t int #define wint_t int #define mbstate_t int -- cgit v1.2.3 From c7c362089112180c0d66f9342be4f03704adeb87 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 21:54:21 +0200 Subject: Rationalize $(CMP) calls in test/Makefile. --- test/ChangeLog | 4 ++++ test/Makefile.am | 45 +++++++++++++++++++++++---------------------- test/Makefile.in | 45 +++++++++++++++++++++++---------------------- 3 files changed, 50 insertions(+), 44 deletions(-) diff --git a/test/ChangeLog b/test/ChangeLog index 05a74f87..1ceb5b35 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +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 diff --git a/test/Makefile.am b/test/Makefile.am index 33078813..873d9844 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -976,7 +976,7 @@ argarray:: .) : ;; \ *) rm -f ./argarray.in ;; \ esac - @-$(CMP) $(srcdir)/argarray.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ regtest:: @echo 'Some of the output from regtest is very system specific, do not' @@ -991,43 +991,44 @@ manyfiles:: @$(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 _$@ + @rm -rf junk + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ compare:: @echo $@ @$(AWK) -f $(srcdir)/compare.awk 0 1 $(srcdir)/compare.in >_$@ - @-$(CMP) $(srcdir)/compare.ok _$@ && rm -f _$@ + @-$(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)/inftest.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ getline2:: @echo $@ @$(AWK) -f $(srcdir)/getline2.awk $(srcdir)/getline2.awk $(srcdir)/getline2.awk >_$@ - @-$(CMP) $(srcdir)/getline2.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ awkpath:: @echo $@ @AWKPATH="$(srcdir)$(PATH_SEPARATOR)$(srcdir)/lib" $(AWK) -f awkpath.awk >_$@ - @-$(CMP) $(srcdir)/awkpath.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ argtest:: @echo $@ @$(AWK) -f $(srcdir)/argtest.awk -x -y abc >_$@ - @-$(CMP) $(srcdir)/argtest.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ badargs:: @echo $@ @-$(AWK) -f 2>&1 | grep -v patchlevel >_$@ - @-$(CMP) $(srcdir)/badargs.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ nonl:: @echo $@ @-AWKPATH=$(srcdir) $(AWK) --lint -f nonl.awk /dev/null >_$@ 2>&1 - @-$(CMP) $(srcdir)/nonl.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ strftime:: @echo This test could fail on slow machines or on a minute boundary, @@ -1041,7 +1042,7 @@ strftime:: litoct:: @echo $@ @echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@ - @-$(CMP) $(srcdir)/litoct.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ devfd:: @echo $@ @@ -1051,23 +1052,23 @@ devfd:: fflush:: @echo $@ @$(srcdir)/fflush.sh >_$@ - @-$(CMP) $(srcdir)/fflush.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ tweakfld:: @echo $@ @$(AWK) -f $(srcdir)/tweakfld.awk $(srcdir)/tweakfld.in >_$@ @rm -f errors.cleanup - @-$(CMP) $(srcdir)/tweakfld.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ mmap8k:: @echo $@ @$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@ - @-$(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ tradanch:: @echo $@ @$(AWK) --traditional -f $(srcdir)/tradanch.awk $(srcdir)/tradanch.in >_$@ - @-$(CMP) $(srcdir)/tradanch.ok _$@ && rm -f _$@ + @-$(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. @@ -1082,12 +1083,12 @@ strftlng:: @if $(CMP) $(srcdir)/strftlng.ok _$@ >/dev/null 2>&1 ; then : ; else \ TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \ fi - @-$(CMP) $(srcdir)/strftlng.ok _$@ && rm -f _$@ + @-$(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)/nors.ok _$@ && rm -f _$@ + @-$(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 @@ -1100,18 +1101,18 @@ fmtspcl: fmtspcl.ok reint:: @echo $@ @$(AWK) --re-interval -f $(srcdir)/reint.awk $(srcdir)/reint.in >_$@ - @-$(CMP) $(srcdir)/reint.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ pipeio1:: @echo $@ @$(AWK) -f $(srcdir)/pipeio1.awk >_$@ @rm -f test1 test2 - @-$(CMP) $(srcdir)/pipeio1.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ pipeio2:: @echo $@ @$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@ - @-$(CMP) $(srcdir)/pipeio2.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ clobber:: @echo $@ @@ -1122,7 +1123,7 @@ clobber:: arynocls:: @echo $@ @-AWKPATH=$(srcdir) $(AWK) -v INPUT=$(srcdir)/arynocls.in -f arynocls.awk >_$@ - @-$(CMP) $(srcdir)/arynocls.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ getlnbuf:: @echo $@ @@ -1156,12 +1157,12 @@ inetdayt:: redfilnm:: @echo $@ @$(AWK) -f $(srcdir)/redfilnm.awk srcdir=$(srcdir) $(srcdir)/redfilnm.in >_$@ - @-$(CMP) $(srcdir)/redfilnm.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ leaddig:: @echo $@ @$(AWK) -v x=2E -f $(srcdir)/leaddig.awk >_$@ - @-$(CMP) $(srcdir)/leaddig.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ gsubtst3:: @echo $@ diff --git a/test/Makefile.in b/test/Makefile.in index 0d374293..5dbb0e5c 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1326,7 +1326,7 @@ argarray:: .) : ;; \ *) rm -f ./argarray.in ;; \ esac - @-$(CMP) $(srcdir)/argarray.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ regtest:: @echo 'Some of the output from regtest is very system specific, do not' @@ -1341,43 +1341,44 @@ manyfiles:: @$(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 _$@ + @rm -rf junk + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ compare:: @echo $@ @$(AWK) -f $(srcdir)/compare.awk 0 1 $(srcdir)/compare.in >_$@ - @-$(CMP) $(srcdir)/compare.ok _$@ && rm -f _$@ + @-$(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)/inftest.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ getline2:: @echo $@ @$(AWK) -f $(srcdir)/getline2.awk $(srcdir)/getline2.awk $(srcdir)/getline2.awk >_$@ - @-$(CMP) $(srcdir)/getline2.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ awkpath:: @echo $@ @AWKPATH="$(srcdir)$(PATH_SEPARATOR)$(srcdir)/lib" $(AWK) -f awkpath.awk >_$@ - @-$(CMP) $(srcdir)/awkpath.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ argtest:: @echo $@ @$(AWK) -f $(srcdir)/argtest.awk -x -y abc >_$@ - @-$(CMP) $(srcdir)/argtest.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ badargs:: @echo $@ @-$(AWK) -f 2>&1 | grep -v patchlevel >_$@ - @-$(CMP) $(srcdir)/badargs.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ nonl:: @echo $@ @-AWKPATH=$(srcdir) $(AWK) --lint -f nonl.awk /dev/null >_$@ 2>&1 - @-$(CMP) $(srcdir)/nonl.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ strftime:: @echo This test could fail on slow machines or on a minute boundary, @@ -1391,7 +1392,7 @@ strftime:: litoct:: @echo $@ @echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@ - @-$(CMP) $(srcdir)/litoct.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ devfd:: @echo $@ @@ -1401,23 +1402,23 @@ devfd:: fflush:: @echo $@ @$(srcdir)/fflush.sh >_$@ - @-$(CMP) $(srcdir)/fflush.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ tweakfld:: @echo $@ @$(AWK) -f $(srcdir)/tweakfld.awk $(srcdir)/tweakfld.in >_$@ @rm -f errors.cleanup - @-$(CMP) $(srcdir)/tweakfld.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ mmap8k:: @echo $@ @$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@ - @-$(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ tradanch:: @echo $@ @$(AWK) --traditional -f $(srcdir)/tradanch.awk $(srcdir)/tradanch.in >_$@ - @-$(CMP) $(srcdir)/tradanch.ok _$@ && rm -f _$@ + @-$(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. @@ -1432,12 +1433,12 @@ strftlng:: @if $(CMP) $(srcdir)/strftlng.ok _$@ >/dev/null 2>&1 ; then : ; else \ TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \ fi - @-$(CMP) $(srcdir)/strftlng.ok _$@ && rm -f _$@ + @-$(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)/nors.ok _$@ && rm -f _$@ + @-$(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 @@ -1450,18 +1451,18 @@ fmtspcl: fmtspcl.ok reint:: @echo $@ @$(AWK) --re-interval -f $(srcdir)/reint.awk $(srcdir)/reint.in >_$@ - @-$(CMP) $(srcdir)/reint.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ pipeio1:: @echo $@ @$(AWK) -f $(srcdir)/pipeio1.awk >_$@ @rm -f test1 test2 - @-$(CMP) $(srcdir)/pipeio1.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ pipeio2:: @echo $@ @$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@ - @-$(CMP) $(srcdir)/pipeio2.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ clobber:: @echo $@ @@ -1472,7 +1473,7 @@ clobber:: arynocls:: @echo $@ @-AWKPATH=$(srcdir) $(AWK) -v INPUT=$(srcdir)/arynocls.in -f arynocls.awk >_$@ - @-$(CMP) $(srcdir)/arynocls.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ getlnbuf:: @echo $@ @@ -1506,12 +1507,12 @@ inetdayt:: redfilnm:: @echo $@ @$(AWK) -f $(srcdir)/redfilnm.awk srcdir=$(srcdir) $(srcdir)/redfilnm.in >_$@ - @-$(CMP) $(srcdir)/redfilnm.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ leaddig:: @echo $@ @$(AWK) -v x=2E -f $(srcdir)/leaddig.awk >_$@ - @-$(CMP) $(srcdir)/leaddig.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ gsubtst3:: @echo $@ -- cgit v1.2.3 From fc2a0c145fdb78834c69c375144bfebe976cf2e8 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 21:58:58 +0200 Subject: Fix a problem in improving test/Makefile. --- test/Makefile.am | 2 +- test/Makefile.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 873d9844..aae30518 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1063,7 +1063,7 @@ tweakfld:: mmap8k:: @echo $@ @$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@ - @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@ tradanch:: @echo $@ diff --git a/test/Makefile.in b/test/Makefile.in index 5dbb0e5c..800c55d8 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1413,7 +1413,7 @@ tweakfld:: mmap8k:: @echo $@ @$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@ - @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@ tradanch:: @echo $@ -- cgit v1.2.3 From 1527865d3c430aa203ed23fa7ecbeea30a604724 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 22:00:01 +0200 Subject: Update doc/gawk.info too. --- doc/gawk.info | 450 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 225 insertions(+), 225 deletions(-) diff --git a/doc/gawk.info b/doc/gawk.info index 38ddd47c..8d9422f2 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -9905,7 +9905,7 @@ internal implementation of arrays and will vary from one version of 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 mechanims which give you this control. +`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. @@ -13730,7 +13730,7 @@ specific field position and can be used for this purpose: } The first field in each entry of the password file is the user's -login name, and the fields are seperated by colons. Each record +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: @@ -20127,14 +20127,14 @@ 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 contigous. (On an EBCDIC system, the range `[a-z]' includes +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 the "correct" way to match uppercase letters. And -indeed, this was true. +`[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 @@ -27624,225 +27624,225 @@ Node: Assigning Elements413593 Node: Array Example414084 Node: Scanning an Array415816 Node: Controlling Scanning418130 -Ref: Controlling Scanning-Footnote-1423062 -Node: Delete423378 -Ref: Delete-Footnote-1425813 -Node: Numeric Array Subscripts425870 -Node: Uninitialized Subscripts428053 -Node: Multi-dimensional429681 -Node: Multi-scanning432775 -Node: Arrays of Arrays434366 -Node: Functions439011 -Node: Built-in439833 -Node: Calling Built-in440911 -Node: Numeric Functions442899 -Ref: Numeric Functions-Footnote-1446664 -Ref: Numeric Functions-Footnote-2447021 -Ref: Numeric Functions-Footnote-3447069 -Node: String Functions447338 -Ref: String Functions-Footnote-1470835 -Ref: String Functions-Footnote-2470964 -Ref: String Functions-Footnote-3471212 -Node: Gory Details471299 -Ref: table-sub-escapes472978 -Ref: table-sub-posix-92474332 -Ref: table-sub-proposed475675 -Ref: table-posix-sub477025 -Ref: table-gensub-escapes478571 -Ref: Gory Details-Footnote-1479778 -Ref: Gory Details-Footnote-2479829 -Node: I/O Functions479980 -Ref: I/O Functions-Footnote-1486635 -Node: Time Functions486782 -Ref: Time Functions-Footnote-1497674 -Ref: Time Functions-Footnote-2497742 -Ref: Time Functions-Footnote-3497900 -Ref: Time Functions-Footnote-4498011 -Ref: Time Functions-Footnote-5498123 -Ref: Time Functions-Footnote-6498350 -Node: Bitwise Functions498616 -Ref: table-bitwise-ops499174 -Ref: Bitwise Functions-Footnote-1503334 -Node: Type Functions503518 -Node: I18N Functions503988 -Node: User-defined505615 -Node: Definition Syntax506419 -Ref: Definition Syntax-Footnote-1511329 -Node: Function Example511398 -Node: Function Caveats513992 -Node: Calling A Function514413 -Node: Variable Scope515528 -Node: Pass By Value/Reference517503 -Node: Return Statement520943 -Node: Dynamic Typing523924 -Node: Indirect Calls524659 -Node: Internationalization534344 -Node: I18N and L10N535770 -Node: Explaining gettext536456 -Ref: Explaining gettext-Footnote-1541522 -Ref: Explaining gettext-Footnote-2541706 -Node: Programmer i18n541871 -Node: Translator i18n546071 -Node: String Extraction546864 -Ref: String Extraction-Footnote-1547825 -Node: Printf Ordering547911 -Ref: Printf Ordering-Footnote-1550695 -Node: I18N Portability550759 -Ref: I18N Portability-Footnote-1553208 -Node: I18N Example553271 -Ref: I18N Example-Footnote-1555906 -Node: Gawk I18N555978 -Node: Advanced Features556595 -Node: Nondecimal Data558108 -Node: Array Sorting559691 -Node: Controlling Array Traversal560388 -Node: Array Sorting Functions568625 -Ref: Array Sorting Functions-Footnote-1572299 -Ref: Array Sorting Functions-Footnote-2572392 -Node: Two-way I/O572586 -Ref: Two-way I/O-Footnote-1578018 -Node: TCP/IP Networking578088 -Node: Profiling580932 -Node: Library Functions588406 -Ref: Library Functions-Footnote-1591413 -Node: Library Names591584 -Ref: Library Names-Footnote-1595055 -Ref: Library Names-Footnote-2595275 -Node: General Functions595361 -Node: Strtonum Function596314 -Node: Assert Function599244 -Node: Round Function602570 -Node: Cliff Random Function604113 -Node: Ordinal Functions605129 -Ref: Ordinal Functions-Footnote-1608199 -Ref: Ordinal Functions-Footnote-2608451 -Node: Join Function608660 -Ref: Join Function-Footnote-1610431 -Node: Gettimeofday Function610631 -Node: Data File Management614346 -Node: Filetrans Function614978 -Node: Rewind Function619117 -Node: File Checking620504 -Node: Empty Files621598 -Node: Ignoring Assigns623828 -Node: Getopt Function625381 -Ref: Getopt Function-Footnote-1636685 -Node: Passwd Functions636888 -Ref: Passwd Functions-Footnote-1645863 -Node: Group Functions645951 -Node: Walking Arrays654035 -Node: Sample Programs655604 -Node: Running Examples656269 -Node: Clones656997 -Node: Cut Program658221 -Node: Egrep Program668066 -Ref: Egrep Program-Footnote-1675839 -Node: Id Program675949 -Node: Split Program679565 -Ref: Split Program-Footnote-1683084 -Node: Tee Program683212 -Node: Uniq Program686015 -Node: Wc Program693444 -Ref: Wc Program-Footnote-1697710 -Ref: Wc Program-Footnote-2697910 -Node: Miscellaneous Programs698002 -Node: Dupword Program699190 -Node: Alarm Program701221 -Node: Translate Program705970 -Ref: Translate Program-Footnote-1710357 -Ref: Translate Program-Footnote-2710585 -Node: Labels Program710719 -Ref: Labels Program-Footnote-1714090 -Node: Word Sorting714174 -Node: History Sorting718058 -Node: Extract Program719897 -Ref: Extract Program-Footnote-1727380 -Node: Simple Sed727508 -Node: Igawk Program730570 -Ref: Igawk Program-Footnote-1745727 -Ref: Igawk Program-Footnote-2745928 -Node: Anagram Program746066 -Node: Signature Program749134 -Node: Debugger750234 -Node: Debugging751145 -Node: Debugging Concepts751558 -Node: Debugging Terms753414 -Node: Awk Debugging756037 -Node: Sample dgawk session756929 -Node: dgawk invocation757421 -Node: Finding The Bug758603 -Node: List of Debugger Commands765089 -Node: Breakpoint Control766400 -Node: Dgawk Execution Control770036 -Node: Viewing And Changing Data773387 -Node: Dgawk Stack776724 -Node: Dgawk Info778184 -Node: Miscellaneous Dgawk Commands782132 -Node: Readline Support787560 -Node: Dgawk Limitations788398 -Node: Language History790587 -Node: V7/SVR3.1792099 -Node: SVR4794420 -Node: POSIX795862 -Node: BTL796870 -Node: POSIX/GNU797604 -Node: Common Extensions802755 -Node: Ranges and Locales803862 -Ref: Ranges and Locales-Footnote-1808469 -Node: Contributors808690 -Node: Installation812952 -Node: Gawk Distribution813846 -Node: Getting814330 -Node: Extracting815156 -Node: Distribution contents816848 -Node: Unix Installation822070 -Node: Quick Installation822687 -Node: Additional Configuration Options824649 -Node: Configuration Philosophy826126 -Node: Non-Unix Installation828468 -Node: PC Installation828926 -Node: PC Binary Installation830225 -Node: PC Compiling832073 -Node: PC Testing835017 -Node: PC Using836193 -Node: Cygwin840378 -Node: MSYS841378 -Node: VMS Installation841892 -Node: VMS Compilation842495 -Ref: VMS Compilation-Footnote-1843502 -Node: VMS Installation Details843560 -Node: VMS Running845195 -Node: VMS Old Gawk846802 -Node: Bugs847276 -Node: Other Versions851128 -Node: Notes856409 -Node: Compatibility Mode857101 -Node: Additions857884 -Node: Accessing The Source858696 -Node: Adding Code860121 -Node: New Ports866088 -Node: Dynamic Extensions870201 -Node: Internals871577 -Node: Plugin License880680 -Node: Sample Library881314 -Node: Internal File Description882000 -Node: Internal File Ops885715 -Ref: Internal File Ops-Footnote-1890496 -Node: Using Internal File Ops890636 -Node: Future Extensions893013 -Node: Basic Concepts895517 -Node: Basic High Level896274 -Ref: Basic High Level-Footnote-1900309 -Node: Basic Data Typing900494 -Node: Floating Point Issues905019 -Node: String Conversion Precision906102 -Ref: String Conversion Precision-Footnote-1907802 -Node: Unexpected Results907911 -Node: POSIX Floating Point Problems909737 -Ref: POSIX Floating Point Problems-Footnote-1913442 -Node: Glossary913480 -Node: Copying938456 -Node: GNU Free Documentation License976013 -Node: Index1001150 +Ref: Controlling Scanning-Footnote-1423063 +Node: Delete423379 +Ref: Delete-Footnote-1425814 +Node: Numeric Array Subscripts425871 +Node: Uninitialized Subscripts428054 +Node: Multi-dimensional429682 +Node: Multi-scanning432776 +Node: Arrays of Arrays434367 +Node: Functions439012 +Node: Built-in439834 +Node: Calling Built-in440912 +Node: Numeric Functions442900 +Ref: Numeric Functions-Footnote-1446665 +Ref: Numeric Functions-Footnote-2447022 +Ref: Numeric Functions-Footnote-3447070 +Node: String Functions447339 +Ref: String Functions-Footnote-1470836 +Ref: String Functions-Footnote-2470965 +Ref: String Functions-Footnote-3471213 +Node: Gory Details471300 +Ref: table-sub-escapes472979 +Ref: table-sub-posix-92474333 +Ref: table-sub-proposed475676 +Ref: table-posix-sub477026 +Ref: table-gensub-escapes478572 +Ref: Gory Details-Footnote-1479779 +Ref: Gory Details-Footnote-2479830 +Node: I/O Functions479981 +Ref: I/O Functions-Footnote-1486636 +Node: Time Functions486783 +Ref: Time Functions-Footnote-1497675 +Ref: Time Functions-Footnote-2497743 +Ref: Time Functions-Footnote-3497901 +Ref: Time Functions-Footnote-4498012 +Ref: Time Functions-Footnote-5498124 +Ref: Time Functions-Footnote-6498351 +Node: Bitwise Functions498617 +Ref: table-bitwise-ops499175 +Ref: Bitwise Functions-Footnote-1503335 +Node: Type Functions503519 +Node: I18N Functions503989 +Node: User-defined505616 +Node: Definition Syntax506420 +Ref: Definition Syntax-Footnote-1511330 +Node: Function Example511399 +Node: Function Caveats513993 +Node: Calling A Function514414 +Node: Variable Scope515529 +Node: Pass By Value/Reference517504 +Node: Return Statement520944 +Node: Dynamic Typing523925 +Node: Indirect Calls524660 +Node: Internationalization534345 +Node: I18N and L10N535771 +Node: Explaining gettext536457 +Ref: Explaining gettext-Footnote-1541523 +Ref: Explaining gettext-Footnote-2541707 +Node: Programmer i18n541872 +Node: Translator i18n546072 +Node: String Extraction546865 +Ref: String Extraction-Footnote-1547826 +Node: Printf Ordering547912 +Ref: Printf Ordering-Footnote-1550696 +Node: I18N Portability550760 +Ref: I18N Portability-Footnote-1553209 +Node: I18N Example553272 +Ref: I18N Example-Footnote-1555907 +Node: Gawk I18N555979 +Node: Advanced Features556596 +Node: Nondecimal Data558109 +Node: Array Sorting559692 +Node: Controlling Array Traversal560389 +Node: Array Sorting Functions568626 +Ref: Array Sorting Functions-Footnote-1572300 +Ref: Array Sorting Functions-Footnote-2572393 +Node: Two-way I/O572587 +Ref: Two-way I/O-Footnote-1578019 +Node: TCP/IP Networking578089 +Node: Profiling580933 +Node: Library Functions588407 +Ref: Library Functions-Footnote-1591414 +Node: Library Names591585 +Ref: Library Names-Footnote-1595056 +Ref: Library Names-Footnote-2595276 +Node: General Functions595362 +Node: Strtonum Function596315 +Node: Assert Function599245 +Node: Round Function602571 +Node: Cliff Random Function604114 +Node: Ordinal Functions605130 +Ref: Ordinal Functions-Footnote-1608200 +Ref: Ordinal Functions-Footnote-2608452 +Node: Join Function608661 +Ref: Join Function-Footnote-1610432 +Node: Gettimeofday Function610632 +Node: Data File Management614347 +Node: Filetrans Function614979 +Node: Rewind Function619118 +Node: File Checking620505 +Node: Empty Files621599 +Node: Ignoring Assigns623829 +Node: Getopt Function625382 +Ref: Getopt Function-Footnote-1636686 +Node: Passwd Functions636889 +Ref: Passwd Functions-Footnote-1645864 +Node: Group Functions645952 +Node: Walking Arrays654036 +Node: Sample Programs655605 +Node: Running Examples656270 +Node: Clones656998 +Node: Cut Program658222 +Node: Egrep Program668067 +Ref: Egrep Program-Footnote-1675840 +Node: Id Program675950 +Node: Split Program679566 +Ref: Split Program-Footnote-1683085 +Node: Tee Program683213 +Node: Uniq Program686016 +Node: Wc Program693445 +Ref: Wc Program-Footnote-1697711 +Ref: Wc Program-Footnote-2697911 +Node: Miscellaneous Programs698003 +Node: Dupword Program699191 +Node: Alarm Program701222 +Node: Translate Program705971 +Ref: Translate Program-Footnote-1710358 +Ref: Translate Program-Footnote-2710586 +Node: Labels Program710720 +Ref: Labels Program-Footnote-1714091 +Node: Word Sorting714175 +Node: History Sorting718059 +Node: Extract Program719898 +Ref: Extract Program-Footnote-1727381 +Node: Simple Sed727509 +Node: Igawk Program730571 +Ref: Igawk Program-Footnote-1745728 +Ref: Igawk Program-Footnote-2745929 +Node: Anagram Program746067 +Node: Signature Program749135 +Node: Debugger750235 +Node: Debugging751146 +Node: Debugging Concepts751559 +Node: Debugging Terms753415 +Node: Awk Debugging756038 +Node: Sample dgawk session756930 +Node: dgawk invocation757422 +Node: Finding The Bug758604 +Node: List of Debugger Commands765090 +Node: Breakpoint Control766401 +Node: Dgawk Execution Control770037 +Node: Viewing And Changing Data773388 +Node: Dgawk Stack776725 +Node: Dgawk Info778185 +Node: Miscellaneous Dgawk Commands782133 +Node: Readline Support787561 +Node: Dgawk Limitations788399 +Node: Language History790588 +Node: V7/SVR3.1792100 +Node: SVR4794421 +Node: POSIX795863 +Node: BTL796871 +Node: POSIX/GNU797605 +Node: Common Extensions802756 +Node: Ranges and Locales803863 +Ref: Ranges and Locales-Footnote-1808467 +Node: Contributors808688 +Node: Installation812950 +Node: Gawk Distribution813844 +Node: Getting814328 +Node: Extracting815154 +Node: Distribution contents816846 +Node: Unix Installation822068 +Node: Quick Installation822685 +Node: Additional Configuration Options824647 +Node: Configuration Philosophy826124 +Node: Non-Unix Installation828466 +Node: PC Installation828924 +Node: PC Binary Installation830223 +Node: PC Compiling832071 +Node: PC Testing835015 +Node: PC Using836191 +Node: Cygwin840376 +Node: MSYS841376 +Node: VMS Installation841890 +Node: VMS Compilation842493 +Ref: VMS Compilation-Footnote-1843500 +Node: VMS Installation Details843558 +Node: VMS Running845193 +Node: VMS Old Gawk846800 +Node: Bugs847274 +Node: Other Versions851126 +Node: Notes856407 +Node: Compatibility Mode857099 +Node: Additions857882 +Node: Accessing The Source858694 +Node: Adding Code860119 +Node: New Ports866086 +Node: Dynamic Extensions870199 +Node: Internals871575 +Node: Plugin License880678 +Node: Sample Library881312 +Node: Internal File Description881998 +Node: Internal File Ops885713 +Ref: Internal File Ops-Footnote-1890494 +Node: Using Internal File Ops890634 +Node: Future Extensions893011 +Node: Basic Concepts895515 +Node: Basic High Level896272 +Ref: Basic High Level-Footnote-1900307 +Node: Basic Data Typing900492 +Node: Floating Point Issues905017 +Node: String Conversion Precision906100 +Ref: String Conversion Precision-Footnote-1907800 +Node: Unexpected Results907909 +Node: POSIX Floating Point Problems909735 +Ref: POSIX Floating Point Problems-Footnote-1913440 +Node: Glossary913478 +Node: Copying938454 +Node: GNU Free Documentation License976011 +Node: Index1001148  End Tag Table -- cgit v1.2.3 From 3ba2f61ff006c308a904c8b1a4bc433082ce87c8 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 22:00:44 +0200 Subject: Misc fixes from John. --- ChangeLog | 9 +++++++++ array.c | 8 ++------ debug.c | 2 +- eval.c | 8 +++++++- profile.c | 4 ++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42fe783c..660b7191 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +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 diff --git a/array.c b/array.c index 82e99a4b..e814e976 100644 --- a/array.c +++ b/array.c @@ -1509,7 +1509,6 @@ sort_user_func(const void *p1, const void *p2) NODE *idx1, *idx2, *val1, *val2; AWKNUM ret; INSTRUCTION *code; - extern int exiting; t1 = *((const NODE *const *) p1); t2 = *((const NODE *const *) p2); @@ -1534,9 +1533,6 @@ sort_user_func(const void *p1, const void *p2) /* execute the comparison function */ (void) interpret(code); - if (exiting) /* do not assume anything about the user-defined function! */ - gawk_exit(exit_val); - /* return value of the comparison function */ POP_NUMBER(ret); @@ -1672,9 +1668,9 @@ assoc_list(NODE *array, const char *sort_str, SORT_CTXT sort_ctxt) (code + 1)->expr_count = 4; /* function takes 4 arguments */ code->nexti = bcalloc(Op_stop, 1, 0); - /* make non-local jumps `next' and `nextfile' fatal in + /* make non-redirected getline, exit, `next' and `nextfile' fatal in * callback function by setting currule in interpret() - * to undefined (0). `exit' is handled in sort_user_func. + * to undefined (0). */ (code + 1)->inrule = currule; /* save current rule */ diff --git a/debug.c b/debug.c index 0a66b462..ea652478 100644 --- a/debug.c +++ b/debug.c @@ -498,8 +498,8 @@ source_find(char *src) efree(path); return s; } - efree(path); } + efree(path); } d_error(_("cannot find source file named `%s' (%s)"), src, strerror(errno_val)); diff --git a/eval.c b/eval.c index cd5a5844..22f30773 100644 --- a/eval.c +++ b/eval.c @@ -2507,7 +2507,7 @@ func_call: break; case Op_K_getline: /* no redirection */ - if (currule == BEGINFILE || currule == ENDFILE) + if (! currule || currule == BEGINFILE || currule == ENDFILE) fatal(_("non-redirected `getline' invalid inside `%s' rule"), ruletab[currule]); @@ -2654,6 +2654,12 @@ func_call: 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; diff --git a/profile.c b/profile.c index 01d1e42f..eb788377 100644 --- a/profile.c +++ b/profile.c @@ -1362,8 +1362,8 @@ redir2str(int redirtype) " >> ", /* redirect_append */ " | ", /* redirect_pipe */ " | ", /* redirect_pipein */ - " < " /* redirect_input */ - " |& " /* redirect_twoway */ + " < ", /* redirect_input */ + " |& ", /* redirect_twoway */ }; if (redirtype < 0 || redirtype > redirect_twoway) -- cgit v1.2.3 From 44892d91d048309234aebd820d312d357eb4b2df Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 6 Dec 2011 22:48:34 +0200 Subject: Revise pc/Makefile.tst. --- pc/ChangeLog | 9 +++++++++ pc/Makefile.tst | 13 ++++++++++--- pc/testoutcmp.awk | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 pc/testoutcmp.awk diff --git a/pc/ChangeLog b/pc/ChangeLog index 3d8ef415..429a88ed 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,12 @@ +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. diff --git a/pc/Makefile.tst b/pc/Makefile.tst index e63b8eb5..db214348 100644 --- a/pc/Makefile.tst +++ b/pc/Makefile.tst @@ -90,6 +90,10 @@ CMP = diff #CMP = diff -c #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 @@ -115,6 +119,7 @@ PATH_SEPARATOR = ; # ============================================================================ srcdir = . +abs_builddir = . # Get rid of core files when cleaning and generated .ok file CLEANFILES = core core.* fmtspcl.ok @@ -512,9 +517,9 @@ gsubtst3:: space:: @echo $@ - @echo Expect space to fail with DJGPP. @$(AWK) -f ' ' $(srcdir)/space.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ - @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ +# @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + @-$(TESTOUTCMP) $(srcdir)/$@.ok _$@ && rm -f _$@ printf0:: @echo $@ @@ -741,7 +746,8 @@ beginfile1:: beginfile2: @echo $@ @-( cd $(srcdir) && AWK="$(abs_builddir)/$(AWKPROG)" $(srcdir)/$@.sh $(srcdir)/$@.in ) > _$@ 2>&1 - @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ +# @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + @-$(TESTOUTCMP) $(srcdir)/$@.ok _$@ && rm -f _$@ dumpvars:: @echo $@ @@ -1876,6 +1882,7 @@ procinfs: pty1: @echo pty1 + @echo Expect pty1 to fail with DJGPP. @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ diff --git a/pc/testoutcmp.awk b/pc/testoutcmp.awk new file mode 100644 index 00000000..ff190155 --- /dev/null +++ b/pc/testoutcmp.awk @@ -0,0 +1,38 @@ +# cmp replacement program for PC where the error messages aren't +# exactly the same. should run even on old awk + +{ + 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 +} -- cgit v1.2.3 From d586094c7c4a9a412a7633a32d2b92a8e1cfea1c Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 8 Dec 2011 21:11:23 +0200 Subject: Update version for next test tar ball. --- configure | 20 ++++++++++---------- configure.ac | 2 +- pc/config.h | 6 +++--- version.c | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/configure b/configure index fbd545d8..ad85e05a 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for GNU Awk 4.0.0e. +# Generated by GNU Autoconf 2.68 for GNU Awk 4.0.0f. # # Report bugs to . # @@ -560,8 +560,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='GNU Awk' PACKAGE_TARNAME='gawk' -PACKAGE_VERSION='4.0.0e' -PACKAGE_STRING='GNU Awk 4.0.0e' +PACKAGE_VERSION='4.0.0f' +PACKAGE_STRING='GNU Awk 4.0.0f' PACKAGE_BUGREPORT='bug-gawk@gnu.org' PACKAGE_URL='http://www.gnu.org/software/gawk/' @@ -1290,7 +1290,7 @@ 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.0e to adapt to many kinds of systems. +\`configure' configures GNU Awk 4.0.0f to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1360,7 +1360,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU Awk 4.0.0e:";; + short | recursive ) echo "Configuration of GNU Awk 4.0.0f:";; esac cat <<\_ACEOF @@ -1472,7 +1472,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU Awk configure 4.0.0e +GNU Awk configure 4.0.0f generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2176,7 +2176,7 @@ 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.0e, which was +It was created by GNU Awk $as_me 4.0.0f, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3011,7 +3011,7 @@ fi # Define the identity of the package. PACKAGE='gawk' - VERSION='4.0.0e' + VERSION='4.0.0f' cat >>confdefs.h <<_ACEOF @@ -11221,7 +11221,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # 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.0e, which was +This file was extended by GNU Awk $as_me 4.0.0f, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11289,7 +11289,7 @@ _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.0e +GNU Awk config.status 4.0.0f configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index df7e5a02..d338e95c 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ dnl dnl Process this file with autoconf to produce a configure script. -AC_INIT([GNU Awk], 4.0.0e, bug-gawk@gnu.org, gawk) +AC_INIT([GNU Awk], 4.0.0f, 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. diff --git a/pc/config.h b/pc/config.h index 1191c174..a9dac512 100644 --- a/pc/config.h +++ b/pc/config.h @@ -425,7 +425,7 @@ #define PACKAGE_NAME "GNU Awk" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "GNU Awk 4.0.0e" +#define PACKAGE_STRING "GNU Awk 4.0.0f" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "gawk" @@ -434,7 +434,7 @@ #define PACKAGE_URL "http://www.gnu.org/software/gawk/" /* Define to the version of this package. */ -#define PACKAGE_VERSION "4.0.0e" +#define PACKAGE_VERSION "4.0.0f" /* Define to 1 if *printf supports %F format */ #undef PRINTF_HAS_F_FORMAT @@ -496,7 +496,7 @@ /* Version number of package */ -#define VERSION "4.0.0e" +#define VERSION "4.0.0f" /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS diff --git a/version.c b/version.c index 8187d1a6..d1bb50de 100644 --- a/version.c +++ b/version.c @@ -1,3 +1,3 @@ #include "config.h" -const char *version_string = "GNU Awk 4.0.0e"; +const char *version_string = "GNU Awk 4.0.0f"; -- cgit v1.2.3 From 732ff4b46b76601ef63162fa06cff6d0a2028a62 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 12 Dec 2011 10:16:42 +0200 Subject: Further the cause of RRI in dfa.c. --- ChangeLog | 5 +++++ dfa.c | 11 ++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3cc7661..653b0baf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-12-12 Arnold D. Robbins + + * match_mb_charset: Per Paolo Bonzini, modify range checking to + use simple comparison. Rational Range Interpretation rules! + 2011-12-06 John Haque * debug.c (source_find): Fix misplaced call to efree. diff --git a/dfa.c b/dfa.c index 37ddc1bc..eeded08e 100644 --- a/dfa.c +++ b/dfa.c @@ -2887,7 +2887,6 @@ match_mb_charset (struct dfa *d, int s, position pos, int idx) with which this operator match. */ int op_len; /* Length of the operator. */ char buffer[128]; - wchar_t wcbuf[6]; /* Pointer to the structure to which we are currently refering. */ struct mb_char_classes *work_mbc; @@ -2964,17 +2963,11 @@ match_mb_charset (struct dfa *d, int s, position pos, int idx) } } - wcbuf[0] = wc; - wcbuf[1] = wcbuf[3] = wcbuf[5] = '\0'; - /* match with a range? */ for (i = 0; inranges; i++) { - wcbuf[2] = work_mbc->range_sts[i]; - wcbuf[4] = work_mbc->range_ends[i]; - - if (wcscoll(wcbuf, wcbuf+2) >= 0 && - wcscoll(wcbuf+4, wcbuf) >= 0) + if (work_mbc->range_sts[i] <= wc && + wc <= work_mbc->range_ends[i]) goto charset_matched; } -- cgit v1.2.3 From 0130721d02a7410c3291c4704be69ccc4078ff3e Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 12 Dec 2011 10:17:07 +0200 Subject: Sync pc/makefile.tst with main test makefile. --- pc/ChangeLog | 4 ++++ pc/Makefile.tst | 43 ++++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/pc/ChangeLog b/pc/ChangeLog index 429a88ed..5f287dd8 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,7 @@ +2011-12-12 Scott Deifik + + * Makefile.tst: Sync with mainline version. + 2011-12-06 Scott Deifik * Makefile.tst: Sync with mainline version. diff --git a/pc/Makefile.tst b/pc/Makefile.tst index db214348..f14341c8 100644 --- a/pc/Makefile.tst +++ b/pc/Makefile.tst @@ -306,7 +306,7 @@ argarray:: .) : ;; \ *) rm -f ./argarray.in ;; \ esac - @-$(CMP) $(srcdir)/argarray.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ regtest:: @echo 'Some of the output from regtest is very system specific, do not' @@ -321,44 +321,45 @@ manyfiles:: @$(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 _$@ + @rm -rf junk + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ compare:: @echo $@ @$(AWK) -f $(srcdir)/compare.awk 0 1 $(srcdir)/compare.in >_$@ - @-$(CMP) $(srcdir)/compare.ok _$@ && rm -f _$@ + @-$(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)/inftest.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ getline2:: @echo $@ @$(AWK) -f $(srcdir)/getline2.awk $(srcdir)/getline2.awk $(srcdir)/getline2.awk >_$@ - @-$(CMP) $(srcdir)/getline2.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ awkpath:: @echo $@ @AWKPATH="$(srcdir)$(PATH_SEPARATOR)$(srcdir)/lib" $(AWK) -f awkpath.awk >_$@ - @-$(CMP) $(srcdir)/awkpath.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ argtest:: @echo $@ @$(AWK) -f $(srcdir)/argtest.awk -x -y abc >_$@ - @-$(CMP) $(srcdir)/argtest.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ badargs:: @echo $@ @-$(AWK) -f 2>&1 | grep -v patchlevel >_$@ - @-$(CMP) $(srcdir)/badargs.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ nonl:: @echo $@ @-AWKPATH=$(srcdir) $(AWK) --lint -f nonl.awk /dev/null >_$@ 2>&1 - @-$(CMP) $(srcdir)/nonl.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ strftime:: @echo This test could fail on slow machines or on a minute boundary, @@ -375,7 +376,7 @@ strftime:: litoct:: @echo $@ @echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@ - @-$(CMP) $(srcdir)/litoct.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ devfd:: @echo $@ @@ -386,13 +387,13 @@ devfd:: fflush:: @echo $@ @$(srcdir)/fflush.sh >_$@ - @-$(CMP) $(srcdir)/fflush.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ tweakfld:: @echo $@ @$(AWK) -f $(srcdir)/tweakfld.awk $(srcdir)/tweakfld.in >_$@ @rm -f errors.cleanup - @-$(CMP) $(srcdir)/tweakfld.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ mmap8k:: @echo $@ @@ -402,7 +403,7 @@ mmap8k:: tradanch:: @echo $@ @$(AWK) --traditional -f $(srcdir)/tradanch.awk $(srcdir)/tradanch.in >_$@ - @-$(CMP) $(srcdir)/tradanch.ok _$@ && rm -f _$@ + @-$(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. @@ -418,12 +419,12 @@ strftlng:: @if $(CMP) $(srcdir)/strftlng.ok _$@ >/dev/null 2>&1 ; then : ; else \ TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \ fi - @-$(CMP) $(srcdir)/strftlng.ok _$@ && rm -f _$@ + @-$(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)/nors.ok _$@ && rm -f _$@ + @-$(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 @@ -437,18 +438,18 @@ fmtspcl: fmtspcl.ok reint:: @echo $@ @$(AWK) --re-interval -f $(srcdir)/reint.awk $(srcdir)/reint.in >_$@ - @-$(CMP) $(srcdir)/reint.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ pipeio1:: @echo $@ @$(AWK) -f $(srcdir)/pipeio1.awk >_$@ @rm -f test1 test2 - @-$(CMP) $(srcdir)/pipeio1.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ pipeio2:: @echo $@ @$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@ - @-$(CMP) $(srcdir)/pipeio2.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ clobber:: @echo $@ @@ -459,7 +460,7 @@ clobber:: arynocls:: @echo $@ @-AWKPATH=$(srcdir) $(AWK) -v INPUT=$(srcdir)/arynocls.in -f arynocls.awk >_$@ - @-$(CMP) $(srcdir)/arynocls.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ getlnbuf:: @echo $@ @@ -503,12 +504,12 @@ inetdayt:: redfilnm:: @echo $@ @$(AWK) -f $(srcdir)/redfilnm.awk srcdir=$(srcdir) $(srcdir)/redfilnm.in >_$@ - @-$(CMP) $(srcdir)/redfilnm.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ leaddig:: @echo $@ @$(AWK) -v x=2E -f $(srcdir)/leaddig.awk >_$@ - @-$(CMP) $(srcdir)/leaddig.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ gsubtst3:: @echo $@ -- cgit v1.2.3 From 9229cd0e900ab31d1049eda623f2756670109399 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 26 Dec 2011 22:42:54 +0200 Subject: Finish RRI changes per points from Paolo Bonzini. --- ChangeLog | 10 ++++++++++ dfa.c | 11 ++--------- regexec.c | 12 ++---------- test/ChangeLog | 5 +++++ test/Makefile.am | 10 ++++++++++ test/Makefile.in | 10 ++++++++++ test/rri1.awk | 1 + test/rri1.in | 1 + test/rri1.ok | 0 9 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 test/rri1.awk create mode 100644 test/rri1.in create mode 100644 test/rri1.ok diff --git a/ChangeLog b/ChangeLog index 660b7191..075809d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +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. diff --git a/dfa.c b/dfa.c index 37ddc1bc..acd1a947 100644 --- a/dfa.c +++ b/dfa.c @@ -2887,7 +2887,6 @@ match_mb_charset (struct dfa *d, int s, position pos, int idx) with which this operator match. */ int op_len; /* Length of the operator. */ char buffer[128]; - wchar_t wcbuf[6]; /* Pointer to the structure to which we are currently refering. */ struct mb_char_classes *work_mbc; @@ -2964,17 +2963,11 @@ match_mb_charset (struct dfa *d, int s, position pos, int idx) } } - wcbuf[0] = wc; - wcbuf[1] = wcbuf[3] = wcbuf[5] = '\0'; - /* match with a range? */ for (i = 0; inranges; i++) { - wcbuf[2] = work_mbc->range_sts[i]; - wcbuf[4] = work_mbc->range_ends[i]; - - if (wcscoll(wcbuf, wcbuf+2) >= 0 && - wcscoll(wcbuf+4, wcbuf) >= 0) + if (work_mbc->range_sts[i] <= wc && + wc <= work_mbc->range_ends[i]) goto charset_matched; } diff --git a/regexec.c b/regexec.c index 97fcba00..dcd325c4 100644 --- a/regexec.c +++ b/regexec.c @@ -3963,18 +3963,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx, # endif /* _LIBC */ { /* match with range expression? */ -#if __GNUC__ >= 2 - wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'}; -#else - wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'}; - cmp_buf[2] = wc; -#endif for (i = 0; i < cset->nranges; ++i) { - cmp_buf[0] = cset->range_starts[i]; - cmp_buf[4] = cset->range_ends[i]; - if (wcscoll (cmp_buf, cmp_buf + 2) <= 0 - && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0) + if (cset->range_starts[i] <= wc + && wc <= cset->range_ends[i]) { match_len = char_len; goto check_node_accept_bytes_match; diff --git a/test/ChangeLog b/test/ChangeLog index 1ceb5b35..711d8b20 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +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. diff --git a/test/Makefile.am b/test/Makefile.am index aae30518..f7d50b28 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -625,6 +625,9 @@ EXTRA_DIST = \ resplit.awk \ resplit.in \ resplit.ok \ + rri1.awk \ + rri1.in \ + rri1.ok \ rs.awk \ rs.in \ rs.ok \ @@ -803,6 +806,7 @@ BASIC_TESTS = \ 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 \ @@ -1433,6 +1437,12 @@ exit: @-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 diff --git a/test/Makefile.in b/test/Makefile.in index 800c55d8..05946f32 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -809,6 +809,9 @@ EXTRA_DIST = \ resplit.awk \ resplit.in \ resplit.ok \ + rri1.awk \ + rri1.in \ + rri1.ok \ rs.awk \ rs.in \ rs.ok \ @@ -987,6 +990,7 @@ BASIC_TESTS = \ 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 \ @@ -1782,6 +1786,12 @@ 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: diff --git a/test/rri1.awk b/test/rri1.awk new file mode 100644 index 00000000..889dbdcb --- /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 00000000..28b6b408 --- /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 00000000..e69de29b -- cgit v1.2.3 From a32faf6354086864b55755c968f72a90e7e8f0d1 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 26 Dec 2011 22:44:33 +0200 Subject: Update version. --- configure | 20 ++++++++++---------- configure.ac | 2 +- version.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/configure b/configure index ad85e05a..859c252b 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for GNU Awk 4.0.0f. +# Generated by GNU Autoconf 2.68 for GNU Awk 4.0.0g. # # Report bugs to . # @@ -560,8 +560,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='GNU Awk' PACKAGE_TARNAME='gawk' -PACKAGE_VERSION='4.0.0f' -PACKAGE_STRING='GNU Awk 4.0.0f' +PACKAGE_VERSION='4.0.0g' +PACKAGE_STRING='GNU Awk 4.0.0g' PACKAGE_BUGREPORT='bug-gawk@gnu.org' PACKAGE_URL='http://www.gnu.org/software/gawk/' @@ -1290,7 +1290,7 @@ 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.0f to adapt to many kinds of systems. +\`configure' configures GNU Awk 4.0.0g to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1360,7 +1360,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU Awk 4.0.0f:";; + short | recursive ) echo "Configuration of GNU Awk 4.0.0g:";; esac cat <<\_ACEOF @@ -1472,7 +1472,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU Awk configure 4.0.0f +GNU Awk configure 4.0.0g generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -2176,7 +2176,7 @@ 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.0f, which was +It was created by GNU Awk $as_me 4.0.0g, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -3011,7 +3011,7 @@ fi # Define the identity of the package. PACKAGE='gawk' - VERSION='4.0.0f' + VERSION='4.0.0g' cat >>confdefs.h <<_ACEOF @@ -11221,7 +11221,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # 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.0f, which was +This file was extended by GNU Awk $as_me 4.0.0g, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11289,7 +11289,7 @@ _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.0f +GNU Awk config.status 4.0.0g configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index d338e95c..545ad10b 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ dnl dnl Process this file with autoconf to produce a configure script. -AC_INIT([GNU Awk], 4.0.0f, bug-gawk@gnu.org, gawk) +AC_INIT([GNU Awk], 4.0.0g, 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. diff --git a/version.c b/version.c index d1bb50de..4e391bba 100644 --- a/version.c +++ b/version.c @@ -1,3 +1,3 @@ #include "config.h" -const char *version_string = "GNU Awk 4.0.0f"; +const char *version_string = "GNU Awk 4.0.0g"; -- cgit v1.2.3 From 73d24cae0db6cc817db209e5e1ea93b0733d1cca Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 26 Dec 2011 23:39:48 +0200 Subject: The grand merge: dgawk and pgawk folded into gawk. --- ChangeLog | 50 ++ Makefile.am | 24 +- Makefile.in | 62 +- NEWS | 11 + array.c | 105 ++-- awk.h | 56 +- awkgram.c | 448 +++++++------- awkgram.y | 74 ++- cint_array.c | 7 +- debug.c | 25 +- doc/ChangeLog | 8 + doc/awkcard.in | 21 +- doc/gawk.1 | 126 ++-- doc/gawk.info | 1744 ++++++++++++++++++++++++++++-------------------------- doc/gawk.texi | 444 ++++++++------ eval.c | 1295 ++-------------------------------------- eval_d.c | 27 - eval_p.c | 27 - ext.c | 94 +-- int_array.c | 6 +- interpret.h | 1187 +++++++++++++++++++++++++++++++++++++ io.c | 70 ++- main.c | 84 +-- profile.c | 31 +- str_array.c | 9 +- test/ChangeLog | 4 + test/Makefile.am | 6 +- test/Makefile.in | 6 +- test/badargs.ok | 3 + 29 files changed, 3169 insertions(+), 2885 deletions(-) delete mode 100644 eval_d.c delete mode 100644 eval_p.c create mode 100644 interpret.h diff --git a/ChangeLog b/ChangeLog index 8945a6bd..9999d8b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,53 @@ +2011-12-26 John Haque + + Merge gawk, pgawk and dgawk into a single executable gawk. + + * awk.h (DO_PRETTY_PRINT, DO_PROFILE, DO_DEBUG, + do_pretty_print, do_debug): New defines. + (interpret): New variable, a pointer to an interpreter routine. + (enum exe_mode): Nuked. + * main.c (opttab): New options --pretty-print and --debug; + Remove option --command. + (usage): Update usage messages. + * interpret.h: New file. + * eval.c (r_interpret): Move to the new file. + (debug_interpret): New interpreter routine when debugging. + (init_interpret): New routine to initialize interpreter related + variables. + * eval_d.c, eval_p.c: Delete files. + * debug.c (interpret): Renamed to debug_prog. + (DEFAULT_PROMPT, DEFAULT_HISTFILE, DEFAULT_OPTFILE): Remove prefix 'd'. + * profile.c (init_profiling): Nuked. + * Makefile.am: Adjusted. + + Add command line option --load for loading extensions. + + * awk.h (srctype): Add new source type SRC_EXTLIB. + * ext.c(load_ext): New routine to load extension. + (do_ext): Adjust to use load_ext(). + * main.c (opttab): Add new option --load. + (main): Call load_ext() to load extensions. + (usage): Add usage message for the new option. + * io.c (get_cwd): New routine. + (do_find_source): Use the new routine. + (find_source): Handle new type SRC_EXTLIB. + * awkgram.y (parse_program, next_sourcefile): Skip type SRC_EXTLIB. + (add_srcfile): Adjust call to find_source. + * debug.c (source_find): Same. + + Unrelated: + + * ext.c (get_argument): Fixed argument parsing. + * array.c (null_array_func): Reworked array routines for an empty array. + * str_array.c, int_array.c: Make GCC happy, use %u instead of %lu + printf formats. + * eval.c (node_Boolean): New array for TRUE and FALSE nodes. + (init_interpret): Create the new nodes. + (eval_condition): Add test for the new nodes. + (setup_frame): Disable tail-recursion optimization when profiling. + * interpret.h (r_interpret): Use the boolean nodes instead of making + new ones when needed. + 2011-12-26 Arnold D. Robbins Finish Rational Range Interpretation (!) diff --git a/Makefile.am b/Makefile.am index e9248506..b9470617 100644 --- a/Makefile.am +++ b/Makefile.am @@ -79,18 +79,22 @@ SUBDIRS = \ test # what to make and install -bin_PROGRAMS = gawk pgawk dgawk +bin_PROGRAMS = gawk -# sources for both gawk and pgawk +# sources for both gawk and dgawk base_sources = \ array.c \ awk.h \ awkgram.y \ builtin.c \ cint_array.c \ + cmd.h \ + command.y \ custom.h \ + debug.c \ dfa.c \ dfa.h \ + eval.c \ ext.c \ field.c \ floatcomp.c \ @@ -102,11 +106,13 @@ base_sources = \ getopt_int.h \ gettext.h \ int_array.c \ + interpret.h \ io.c \ mbsupport.h \ main.c \ msg.c \ node.c \ + profile.c \ protos.h \ random.c \ random.h \ @@ -119,13 +125,10 @@ base_sources = \ 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 +gawk_SOURCES = $(base_sources) # Get extra libs as needed, Automake will supply LIBINTL and SOCKET_LIBS. -LDADD = $(LIBSIGSEGV) $(LIBINTL) $(SOCKET_LIBS) -dgawk_LDADD = $(LDADD) @LIBREADLINE@ +LDADD = $(LIBSIGSEGV) $(LIBINTL) $(SOCKET_LIBS) @LIBREADLINE@ # Directory for gawk's data files. Automake supplies datadir. pkgdatadir = $(datadir)/awk @@ -144,7 +147,6 @@ MAINTAINERCLEANFILES = version.c 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 @@ -152,7 +154,6 @@ LN= ln 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) @@ -161,12 +162,12 @@ install-exec-hook: 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) + rm -f gawk-$(VERSION)$(EXEEXT); exit 0) uninstall-recursive: uninstall-links # force there to be a gawk executable before running tests -check-local: gawk$(EXEEXT) pgawk$(EXEEXT) +check-local: gawk$(EXEEXT) # A little extra clean up when making distributions. # And additional set up for the pc directory. @@ -181,6 +182,7 @@ dist-hook: # 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 diff --git a/Makefile.in b/Makefile.in index 26d6017b..3083c4c3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -56,7 +56,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -bin_PROGRAMS = gawk$(EXEEXT) pgawk$(EXEEXT) dgawk$(EXEEXT) +bin_PROGRAMS = gawk$(EXEEXT) subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/configh.in \ @@ -88,31 +88,20 @@ CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__objects_1 = array.$(OBJEXT) awkgram.$(OBJEXT) builtin.$(OBJEXT) \ - cint_array.$(OBJEXT) dfa.$(OBJEXT) ext.$(OBJEXT) \ - field.$(OBJEXT) floatcomp.$(OBJEXT) gawkmisc.$(OBJEXT) \ - getopt.$(OBJEXT) getopt1.$(OBJEXT) int_array.$(OBJEXT) \ - io.$(OBJEXT) main.$(OBJEXT) msg.$(OBJEXT) node.$(OBJEXT) \ + cint_array.$(OBJEXT) command.$(OBJEXT) debug.$(OBJEXT) \ + dfa.$(OBJEXT) eval.$(OBJEXT) ext.$(OBJEXT) field.$(OBJEXT) \ + floatcomp.$(OBJEXT) gawkmisc.$(OBJEXT) getopt.$(OBJEXT) \ + getopt1.$(OBJEXT) int_array.$(OBJEXT) io.$(OBJEXT) \ + main.$(OBJEXT) msg.$(OBJEXT) node.$(OBJEXT) profile.$(OBJEXT) \ random.$(OBJEXT) re.$(OBJEXT) regex.$(OBJEXT) \ replace.$(OBJEXT) str_array.$(OBJEXT) symbol.$(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) +am_gawk_OBJECTS = $(am__objects_1) gawk_OBJECTS = $(am_gawk_OBJECTS) gawk_LDADD = $(LDADD) +am__DEPENDENCIES_1 = 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 @@ -123,8 +112,8 @@ 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) +SOURCES = $(gawk_SOURCES) +DIST_SOURCES = $(gawk_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ @@ -357,16 +346,20 @@ SUBDIRS = \ test -# sources for both gawk and pgawk +# sources for both gawk and dgawk base_sources = \ array.c \ awk.h \ awkgram.y \ builtin.c \ cint_array.c \ + cmd.h \ + command.y \ custom.h \ + debug.c \ dfa.c \ dfa.h \ + eval.c \ ext.c \ field.c \ floatcomp.c \ @@ -378,11 +371,13 @@ base_sources = \ getopt_int.h \ gettext.h \ int_array.c \ + interpret.h \ io.c \ mbsupport.h \ main.c \ msg.c \ node.c \ + profile.c \ protos.h \ random.c \ random.h \ @@ -395,13 +390,10 @@ base_sources = \ 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 +gawk_SOURCES = $(base_sources) # Get extra libs as needed, Automake will supply LIBINTL and SOCKET_LIBS. -LDADD = $(LIBSIGSEGV) $(LIBINTL) $(SOCKET_LIBS) -dgawk_LDADD = $(LDADD) @LIBREADLINE@ +LDADD = $(LIBSIGSEGV) $(LIBINTL) $(SOCKET_LIBS) @LIBREADLINE@ # stuff for compiling gawk/pgawk DEFPATH = '".$(PATH_SEPARATOR)$(pkgdatadir)"' @@ -505,15 +497,9 @@ uninstall-binPROGRAMS: 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) @@ -529,8 +515,6 @@ distclean-compile: @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@ @@ -543,7 +527,6 @@ distclean-compile: @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@ @@ -1017,7 +1000,6 @@ 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 @@ -1025,7 +1007,6 @@ uninstall-am: uninstall-binPROGRAMS 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) @@ -1034,12 +1015,12 @@ install-exec-hook: 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) + rm -f gawk-$(VERSION)$(EXEEXT); exit 0) uninstall-recursive: uninstall-links # force there to be a gawk executable before running tests -check-local: gawk$(EXEEXT) pgawk$(EXEEXT) +check-local: gawk$(EXEEXT) # A little extra clean up when making distributions. # And additional set up for the pc directory. @@ -1054,6 +1035,7 @@ dist-hook: # 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 diff --git a/NEWS b/NEWS index 289ce86e..14855011 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,17 @@ 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.1 to 4.1 +------------------------- +1. The three executables gawk, pgawk, and dgawk, have been merged into + one, named just gawk. As a result: + * The -R option is gone + * Use -D ... + * Use -o ... + * Use -p ... + +2. The new -l option is used for loading dynamic extensions. Changes from 4.0.0 to 4.0.1 --------------------------- diff --git a/array.c b/array.c index 90679b72..e3bdbf54 100644 --- a/array.c +++ b/array.c @@ -35,11 +35,22 @@ static size_t SUBSEPlen; static char *SUBSEP; static char indent_char[] = " "; -static NODE **e_lookup(NODE *symbol, NODE *subs); -static array_ptr empty_array_func[NUM_AFUNCS] = { +static NODE **null_lookup(NODE *symbol, NODE *subs); +static NODE **null_afunc(NODE *symbol, NODE *subs); +static NODE **null_dump(NODE *symbol, NODE *subs); +static array_ptr null_array_func[] = { (array_ptr) 0, (array_ptr) 0, - e_lookup, + null_lookup, + null_afunc, + null_afunc, + null_afunc, + null_afunc, + null_afunc, + null_dump, +#ifdef ARRAYDEBUG + null_afunc +#endif }; #define MAX_ATYPE 10 @@ -91,20 +102,20 @@ make_array() getnode(array); memset(array, '\0', sizeof(NODE)); array->type = Node_var_array; - array->array_funcs = empty_array_func; + array->array_funcs = null_array_func; /* vname, flags, and parent_array not set here */ return array; } -/* init_array --- initialize an array node */ +/* init_array --- (re)initialize an array node */ void init_array(NODE *symbol) { symbol->type = Node_var_array; - symbol->array_funcs = empty_array_func; + symbol->array_funcs = null_array_func; symbol->buckets = NULL; symbol->table_size = symbol->array_size = 0; symbol->array_capacity = 0; @@ -116,15 +127,15 @@ init_array(NODE *symbol) } -/* e_lookup: assign type to an empty array. */ +/* null_lookup: assign type to an empty array. */ static NODE ** -e_lookup(NODE *symbol, NODE *subs) +null_lookup(NODE *symbol, NODE *subs) { int i; array_ptr *afunc = NULL; - assert(array_empty(symbol) == TRUE); + assert(symbol->table_size == 0); /* Check which array type wants to accept this sub; traverse * array type list in reverse order. @@ -143,13 +154,21 @@ e_lookup(NODE *symbol, NODE *subs) } -/* assoc_clear --- flush all the values in symbol[] */ +/* null_afunc --- dummy function for an empty array */ -void -assoc_clear(NODE *symbol) +static NODE ** +null_afunc(NODE *symbol ATTRIBUTE_UNUSED, NODE *subs ATTRIBUTE_UNUSED) { - if (! array_empty(symbol)) - (void) symbol->aclear(symbol, NULL); + return NULL; +} + +/* null_dump --- dump function for an empty array */ + +static NODE ** +null_dump(NODE *symbol, NODE *subs ATTRIBUTE_UNUSED) +{ + fprintf(output_fp, "array `%s' is empty\n", array_vname(symbol)); + return NULL; } @@ -162,24 +181,11 @@ r_in_array(NODE *symbol, NODE *subs) { NODE **ret; - if (array_empty(symbol)) - return NULL; ret = symbol->aexists(symbol, subs); return (ret ? *ret : NULL); } -/* assoc_remove --- remove an index from symbol[] */ - -int -assoc_remove(NODE *symbol, NODE *subs) -{ - if (array_empty(symbol)) - return FALSE; - return (symbol->aremove(symbol, subs) != NULL); -} - - /* assoc_copy --- duplicate input array "symbol" */ NODE * @@ -188,11 +194,9 @@ assoc_copy(NODE *symbol, NODE *newsymb) assert(newsymb->vname != NULL); assoc_clear(newsymb); - if (! array_empty(symbol)) { - (void) symbol->acopy(symbol, newsymb); - newsymb->array_funcs = symbol->array_funcs; - newsymb->flags = symbol->flags; - } + (void) symbol->acopy(symbol, newsymb); + newsymb->array_funcs = symbol->array_funcs; + newsymb->flags = symbol->flags; return newsymb; } @@ -202,9 +206,7 @@ assoc_copy(NODE *symbol, NODE *newsymb) void assoc_dump(NODE *symbol, NODE *ndump) { - if (array_empty(symbol)) - fprintf(output_fp, "array `%s' is empty\n", array_vname(symbol)); - else if (symbol->adump) + if (symbol->adump) (void) symbol->adump(symbol, ndump); } @@ -806,7 +808,7 @@ asort_actual(int nargs, SORT_CTXT ctxt) { NODE *array, *dest = NULL, *result; NODE *r, *subs, *s; - NODE **list, **ptr; + NODE **list = NULL, **ptr; unsigned long num_elems, i; const char *sort_str; @@ -855,18 +857,18 @@ asort_actual(int nargs, SORT_CTXT ctxt) } } - if (array_empty(array)) { - /* source array is empty */ - if (dest != NULL && dest != array) - assoc_clear(dest); - return make_number((AWKNUM) 0); - } num_elems = array->table_size; - - /* sorting happens inside assoc_list */ - list = assoc_list(array, sort_str, ctxt); + if (num_elems > 0) /* sorting happens inside assoc_list */ + list = assoc_list(array, sort_str, ctxt); DEREF(s); + if (num_elems == 0 || list == NULL) { + /* source array is empty */ + if (dest != NULL && dest != array) + assoc_clear(dest); + return make_number((AWKNUM) 0); + } + /* * Must not assoc_clear() the source array before constructing * the output array. assoc_list() does not duplicate array values @@ -1241,7 +1243,7 @@ sort_user_func(const void *p1, const void *p2) PUSH(val2); /* execute the comparison function */ - (void) interpret(code); + (void) (*interpret)(code); /* return value of the comparison function */ POP_NUMBER(ret); @@ -1289,7 +1291,8 @@ assoc_list(NODE *symbol, const char *sort_str, SORT_CTXT sort_ctxt) int save_rule = 0; num_elems = symbol->table_size; - assert(num_elems > 0); + if (num_elems == 0) + return NULL; elem_size = 1; fl.flags = 0; @@ -1355,8 +1358,8 @@ assoc_list(NODE *symbol, const char *sort_str, SORT_CTXT sort_ctxt) list = symbol->alist(symbol, & fl); - if (! cmp_func || (fl.flags & (AASC|ADESC)) != 0) - return list; /* unsorted or list already sorted */ + if (list == NULL || ! cmp_func || (fl.flags & (AASC|ADESC)) != 0) + return list; /* empty list or unsorted, or list already sorted */ qsort(list, num_elems, elem_size * sizeof(NODE *), cmp_func); /* shazzam! */ @@ -1367,9 +1370,7 @@ assoc_list(NODE *symbol, const char *sort_str, SORT_CTXT sort_ctxt) bcfree(code); /* Op_func_call */ } - if (sort_ctxt == SORTED_IN - && (fl.flags & (AINDEX|AVALUE)) == (AINDEX|AVALUE) - ) { + if (sort_ctxt == SORTED_IN && (fl.flags & (AINDEX|AVALUE)) == (AINDEX|AVALUE)) { /* relocate all index nodes to the first half of the list. */ for (j = 1; j < num_elems; j++) list[j] = list[2 * j]; diff --git a/awk.h b/awk.h index a430111f..a7747b9c 100644 --- a/awk.h +++ b/awk.h @@ -407,7 +407,7 @@ typedef struct exp_node { # define ARRAYMAXED 0x0800 /* array is at max size */ # define HALFHAT 0x1000 /* half-capacity Hashed Array Tree; * See cint_array.c */ -# define XARRAY 0x2000 /* FIXME: Nuke */ +# define XARRAY 0x2000 } NODE; #define vname sub.nodep.name @@ -901,8 +901,8 @@ 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 */ + enum srctype { SRC_CMDLINE = 1, SRC_STDIN, SRC_FILE, SRC_INC, SRC_EXTLIB } stype; + char *src; /* name on command line or include statement */ char *fullpath; /* full path after AWKPATH search */ time_t mtime; struct stat sbuf; @@ -990,6 +990,8 @@ extern NODE *Null_field; extern NODE **fields_arr; extern int sourceline; extern char *source; +extern int (*interpret)(INSTRUCTION *); /* interpreter routine */ + #if __GNUC__ < 2 extern NODE *_t; /* used as temporary in macros */ @@ -1017,25 +1019,31 @@ extern int do_flags; #define DO_NON_DEC_DATA 0x0040 /* allow {...,...} in regexps, see resetup() */ #define DO_INTERVALS 0x0080 -/* profile and pretty print the program */ -#define DO_PROFILING 0x0100 +/* pretty print the program */ +#define DO_PRETTY_PRINT 0x0100 /* dump all global variables at end */ #define DO_DUMP_VARS 0x0200 /* release vars when done */ #define DO_TIDY_MEM 0x0400 /* sandbox mode - disable 'system' function & redirections */ #define DO_SANDBOX 0x0800 +/* profile the program */ +#define DO_PROFILE 0x1000 +/* debug the program */ +#define DO_DEBUG 0x2000 #define do_traditional (do_flags & DO_TRADITIONAL) -#define do_posix (do_flags & DO_POSIX) -#define do_intl (do_flags & DO_INTL) +#define do_posix (do_flags & DO_POSIX) +#define do_intl (do_flags & DO_INTL) #define do_non_decimal_data (do_flags & DO_NON_DEC_DATA) #define do_intervals (do_flags & DO_INTERVALS) -#define do_profiling (do_flags & DO_PROFILING) +#define do_pretty_print (do_flags & DO_PRETTY_PRINT) +#define do_profile (do_flags & DO_PROFILE) #define do_dump_vars (do_flags & DO_DUMP_VARS) #define do_tidy_mem (do_flags & DO_TIDY_MEM) #define do_sandbox (do_flags & DO_SANDBOX) +#define do_debug (do_flags & DO_DEBUG) extern int do_optimize; @@ -1073,17 +1081,10 @@ 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 *rptr; /* variable etc. */ NODE **lptr; /* address of a variable etc. */ } STACK_ITEM; @@ -1246,15 +1247,21 @@ extern int fatal_tag_valid; if (val++) \ memcpy((char *) (stack), (const char *) tag, sizeof(jmp_buf)) #define POP_BINDING(stack, tag, val) \ -if (--val) \ +if (--val) \ memcpy((char *) tag, (const char *) (stack), sizeof(jmp_buf)) #define array_empty(a) ((a)->table_size == 0) #define assoc_lookup(a, s) (a)->alookup(a, s) +/* assoc_clear --- flush all the values in symbol[] */ +#define assoc_clear(a) (void) ((a)->aclear(a, NULL)) + +/* assoc_remove --- remove an index from symbol[] */ +#define assoc_remove(a, s) ((a)->aremove(a, s) != NULL) + + #if __GNUC__ >= 2 -#define in_array(a, s) ({ NODE **_l; array_empty(a) ? NULL \ - : (_l = (a)->aexists(a, s), _l ? *_l : NULL); }) +#define in_array(a, s) ({ NODE **_l; _l = (a)->aexists(a, s); _l ? *_l : NULL; }) #else /* not __GNUC__ */ #define in_array(a, s) r_in_array(a, s) #endif /* __GNUC__ */ @@ -1284,9 +1291,7 @@ extern void array_init(void); extern int register_array_func(array_ptr *afunc); extern void set_SUBSEP(void); extern NODE *concat_exp(int nargs, int do_subsep); -extern void assoc_clear(NODE *symbol); extern NODE *r_in_array(NODE *symbol, NODE *subs); -extern int assoc_remove(NODE *symbol, NODE *subs); extern NODE *assoc_copy(NODE *symbol, NODE *newsymb); extern void assoc_dump(NODE *symbol, NODE *p); extern NODE **assoc_list(NODE *symbol, const char *sort_str, SORT_CTXT sort_ctxt); @@ -1358,7 +1363,9 @@ extern int strncasecmpmbs(const unsigned char *, /* eval.c */ extern void PUSH_CODE(INSTRUCTION *cp); extern INSTRUCTION *POP_CODE(void); -extern int interpret(INSTRUCTION *); +extern void init_interpret(void); +extern int r_interpret(INSTRUCTION *); +extern int debug_interpret(INSTRUCTION *); extern int cmp_nodes(NODE *p1, NODE *p2); extern void set_IGNORECASE(void); extern void set_OFS(void); @@ -1384,11 +1391,10 @@ 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); +NODE *load_ext(const char *lib_name, const char *init_func, NODE *obj); #ifdef DYNAMIC void make_builtin(const char *, NODE *(*)(int), int); NODE *get_argument(int); @@ -1443,7 +1449,7 @@ 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 char *find_source(const char *src, struct stat *stb, int *errcode, int is_extlib); 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); diff --git a/awkgram.c b/awkgram.c index 32a4b66c..5eff6e3f 100644 --- a/awkgram.c +++ b/awkgram.c @@ -173,6 +173,7 @@ extern int sourceline; extern SRCFILE *srcfiles; extern INSTRUCTION *rule_list; extern int max_args; +extern NODE **args_array; static INSTRUCTION *rule_block[sizeof(ruletab)]; @@ -194,7 +195,7 @@ extern double fmod(double x, double y); /* Line 268 of yacc.c */ -#line 198 "awkgram.c" +#line 199 "awkgram.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -340,7 +341,7 @@ typedef int YYSTYPE; /* Line 343 of yacc.c */ -#line 344 "awkgram.c" +#line 345 "awkgram.c" #ifdef short # undef short @@ -702,25 +703,25 @@ static const yytype_int16 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 191, 191, 193, 198, 199, 203, 215, 219, 230, - 236, 244, 252, 254, 260, 261, 263, 289, 300, 311, - 317, 326, 336, 338, 340, 346, 351, 352, 356, 375, - 374, 408, 410, 415, 416, 429, 434, 435, 439, 441, - 443, 450, 540, 582, 624, 737, 744, 751, 761, 770, - 779, 788, 803, 819, 818, 842, 854, 854, 948, 948, - 973, 996, 1002, 1003, 1009, 1010, 1017, 1022, 1034, 1048, - 1050, 1056, 1061, 1063, 1071, 1073, 1082, 1083, 1091, 1096, - 1096, 1107, 1111, 1119, 1120, 1123, 1125, 1130, 1131, 1140, - 1141, 1146, 1151, 1157, 1159, 1161, 1168, 1169, 1175, 1176, - 1181, 1183, 1188, 1190, 1192, 1194, 1200, 1207, 1209, 1211, - 1227, 1237, 1244, 1246, 1251, 1253, 1255, 1263, 1265, 1270, - 1272, 1277, 1279, 1281, 1331, 1333, 1335, 1337, 1339, 1341, - 1343, 1345, 1368, 1373, 1378, 1403, 1409, 1411, 1413, 1415, - 1417, 1419, 1424, 1428, 1459, 1461, 1467, 1473, 1486, 1487, - 1488, 1493, 1498, 1502, 1506, 1519, 1532, 1537, 1573, 1591, - 1592, 1598, 1599, 1604, 1606, 1613, 1630, 1647, 1649, 1656, - 1661, 1669, 1679, 1691, 1700, 1704, 1708, 1712, 1716, 1720, - 1723, 1725, 1729, 1733, 1737 + 0, 192, 192, 194, 199, 200, 204, 216, 220, 231, + 237, 245, 253, 255, 261, 262, 264, 290, 301, 312, + 318, 327, 337, 339, 341, 347, 352, 353, 357, 376, + 375, 409, 411, 416, 417, 430, 435, 436, 440, 442, + 444, 451, 541, 583, 625, 738, 745, 752, 762, 771, + 780, 789, 804, 820, 819, 843, 855, 855, 949, 949, + 974, 997, 1003, 1004, 1010, 1011, 1018, 1023, 1035, 1049, + 1051, 1057, 1062, 1064, 1072, 1074, 1083, 1084, 1092, 1097, + 1097, 1108, 1112, 1120, 1121, 1124, 1126, 1131, 1132, 1141, + 1142, 1147, 1152, 1158, 1160, 1162, 1169, 1170, 1176, 1177, + 1182, 1184, 1189, 1191, 1193, 1195, 1201, 1208, 1210, 1212, + 1228, 1238, 1245, 1247, 1252, 1254, 1256, 1264, 1266, 1271, + 1273, 1278, 1280, 1282, 1332, 1334, 1336, 1338, 1340, 1342, + 1344, 1346, 1369, 1374, 1379, 1404, 1410, 1412, 1414, 1416, + 1418, 1420, 1425, 1429, 1460, 1462, 1468, 1474, 1487, 1488, + 1489, 1494, 1499, 1503, 1507, 1520, 1533, 1538, 1574, 1592, + 1593, 1599, 1600, 1605, 1607, 1614, 1631, 1648, 1650, 1657, + 1662, 1670, 1680, 1692, 1701, 1705, 1709, 1713, 1717, 1721, + 1724, 1726, 1730, 1734, 1738 }; #endif @@ -2039,7 +2040,7 @@ yyreduce: case 3: /* Line 1806 of yacc.c */ -#line 194 "awkgram.y" +#line 195 "awkgram.y" { rule = 0; yyerrok; @@ -2049,7 +2050,7 @@ yyreduce: case 5: /* Line 1806 of yacc.c */ -#line 200 "awkgram.y" +#line 201 "awkgram.y" { next_sourcefile(); } @@ -2058,7 +2059,7 @@ yyreduce: case 6: /* Line 1806 of yacc.c */ -#line 204 "awkgram.y" +#line 205 "awkgram.y" { rule = 0; /* @@ -2072,7 +2073,7 @@ yyreduce: case 7: /* Line 1806 of yacc.c */ -#line 216 "awkgram.y" +#line 217 "awkgram.y" { (void) append_rule((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -2081,7 +2082,7 @@ yyreduce: case 8: /* Line 1806 of yacc.c */ -#line 220 "awkgram.y" +#line 221 "awkgram.y" { if (rule != Rule) { msg(_("%s blocks must have an action part"), ruletab[rule]); @@ -2097,7 +2098,7 @@ yyreduce: case 9: /* Line 1806 of yacc.c */ -#line 231 "awkgram.y" +#line 232 "awkgram.y" { in_function = NULL; (void) mk_function((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); @@ -2108,7 +2109,7 @@ yyreduce: case 10: /* Line 1806 of yacc.c */ -#line 237 "awkgram.y" +#line 238 "awkgram.y" { want_source = FALSE; yyerrok; @@ -2118,7 +2119,7 @@ yyreduce: case 11: /* Line 1806 of yacc.c */ -#line 245 "awkgram.y" +#line 246 "awkgram.y" { if (include_source((yyvsp[(1) - (1)])) < 0) YYABORT; @@ -2131,35 +2132,35 @@ yyreduce: case 12: /* Line 1806 of yacc.c */ -#line 253 "awkgram.y" +#line 254 "awkgram.y" { (yyval) = NULL; } break; case 13: /* Line 1806 of yacc.c */ -#line 255 "awkgram.y" +#line 256 "awkgram.y" { (yyval) = NULL; } break; case 14: /* Line 1806 of yacc.c */ -#line 260 "awkgram.y" +#line 261 "awkgram.y" { (yyval) = NULL; rule = Rule; } break; case 15: /* Line 1806 of yacc.c */ -#line 262 "awkgram.y" +#line 263 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); rule = Rule; } break; case 16: /* Line 1806 of yacc.c */ -#line 264 "awkgram.y" +#line 265 "awkgram.y" { INSTRUCTION *tp; @@ -2167,7 +2168,7 @@ yyreduce: 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)); + list_prepend((yyvsp[(1) - (4)]), bcalloc(Op_line_range, !!do_pretty_print + 1, 0)); (yyvsp[(1) - (4)])->nexti->triggered = FALSE; (yyvsp[(1) - (4)])->nexti->target_jmp = (yyvsp[(4) - (4)])->nexti; @@ -2178,7 +2179,7 @@ yyreduce: 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) { + if (do_pretty_print) { ((yyvsp[(1) - (4)])->nexti + 1)->condpair_left = (yyvsp[(1) - (4)])->lasti; ((yyvsp[(1) - (4)])->nexti + 1)->condpair_right = (yyvsp[(4) - (4)])->lasti; } @@ -2190,7 +2191,7 @@ yyreduce: case 17: /* Line 1806 of yacc.c */ -#line 290 "awkgram.y" +#line 291 "awkgram.y" { static int begin_seen = 0; if (do_lint_old && ++begin_seen == 2) @@ -2206,7 +2207,7 @@ yyreduce: case 18: /* Line 1806 of yacc.c */ -#line 301 "awkgram.y" +#line 302 "awkgram.y" { static int end_seen = 0; if (do_lint_old && ++end_seen == 2) @@ -2222,7 +2223,7 @@ yyreduce: case 19: /* Line 1806 of yacc.c */ -#line 312 "awkgram.y" +#line 313 "awkgram.y" { (yyvsp[(1) - (1)])->in_rule = rule = BEGINFILE; (yyvsp[(1) - (1)])->source_file = source; @@ -2233,7 +2234,7 @@ yyreduce: case 20: /* Line 1806 of yacc.c */ -#line 318 "awkgram.y" +#line 319 "awkgram.y" { (yyvsp[(1) - (1)])->in_rule = rule = ENDFILE; (yyvsp[(1) - (1)])->source_file = source; @@ -2244,7 +2245,7 @@ yyreduce: case 21: /* Line 1806 of yacc.c */ -#line 327 "awkgram.y" +#line 328 "awkgram.y" { if ((yyvsp[(2) - (5)]) == NULL) (yyval) = list_create(instruction(Op_no_op)); @@ -2256,21 +2257,21 @@ yyreduce: case 22: /* Line 1806 of yacc.c */ -#line 337 "awkgram.y" +#line 338 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 23: /* Line 1806 of yacc.c */ -#line 339 "awkgram.y" +#line 340 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 24: /* Line 1806 of yacc.c */ -#line 341 "awkgram.y" +#line 342 "awkgram.y" { yyerror(_("`%s' is a built-in function, it cannot be redefined"), tokstart); @@ -2281,14 +2282,14 @@ yyreduce: case 25: /* Line 1806 of yacc.c */ -#line 347 "awkgram.y" +#line 348 "awkgram.y" { (yyval) = (yyvsp[(2) - (2)]); } break; case 28: /* Line 1806 of yacc.c */ -#line 357 "awkgram.y" +#line 358 "awkgram.y" { (yyvsp[(1) - (6)])->source_file = source; if (install_function((yyvsp[(2) - (6)])->lextok, (yyvsp[(1) - (6)]), (yyvsp[(4) - (6)])) < 0) @@ -2304,14 +2305,14 @@ yyreduce: case 29: /* Line 1806 of yacc.c */ -#line 375 "awkgram.y" +#line 376 "awkgram.y" { ++want_regexp; } break; case 30: /* Line 1806 of yacc.c */ -#line 377 "awkgram.y" +#line 378 "awkgram.y" { NODE *n, *exp; char *re; @@ -2345,21 +2346,21 @@ yyreduce: case 31: /* Line 1806 of yacc.c */ -#line 409 "awkgram.y" +#line 410 "awkgram.y" { bcfree((yyvsp[(1) - (1)])); } break; case 33: /* Line 1806 of yacc.c */ -#line 415 "awkgram.y" +#line 416 "awkgram.y" { (yyval) = NULL; } break; case 34: /* Line 1806 of yacc.c */ -#line 417 "awkgram.y" +#line 418 "awkgram.y" { if ((yyvsp[(2) - (2)]) == NULL) (yyval) = (yyvsp[(1) - (2)]); @@ -2377,30 +2378,30 @@ yyreduce: case 35: /* Line 1806 of yacc.c */ -#line 430 "awkgram.y" +#line 431 "awkgram.y" { (yyval) = NULL; } break; case 38: /* Line 1806 of yacc.c */ -#line 440 "awkgram.y" +#line 441 "awkgram.y" { (yyval) = NULL; } break; case 39: /* Line 1806 of yacc.c */ -#line 442 "awkgram.y" +#line 443 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } break; case 40: /* Line 1806 of yacc.c */ -#line 444 "awkgram.y" +#line 445 "awkgram.y" { - if (do_profiling) + if (do_pretty_print) (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_exec_count)); else (yyval) = (yyvsp[(1) - (1)]); @@ -2410,7 +2411,7 @@ yyreduce: case 41: /* Line 1806 of yacc.c */ -#line 451 "awkgram.y" +#line 452 "awkgram.y" { INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; INSTRUCTION *ip, *nextc, *tbreak; @@ -2469,7 +2470,7 @@ yyreduce: else dflt->target_jmp = casestmt->nexti; - if (do_profiling) { + if (do_pretty_print) { curr->stmt_start = casestmt->nexti; curr->stmt_end = casestmt->lasti; (void) list_prepend(cexp, curr); @@ -2484,7 +2485,7 @@ yyreduce: efree(case_values); ip = (yyvsp[(3) - (9)]); - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(ip, (yyvsp[(1) - (9)])); (void) list_prepend(ip, instruction(Op_exec_count)); (yyvsp[(1) - (9)])->target_break = tbreak; @@ -2505,7 +2506,7 @@ yyreduce: case 42: /* Line 1806 of yacc.c */ -#line 541 "awkgram.y" +#line 542 "awkgram.y" { /* * ----------------- @@ -2528,7 +2529,7 @@ yyreduce: ip = list_append((yyvsp[(3) - (6)]), instruction(Op_jmp_false)); ip->lasti->target_jmp = tbreak; - if (do_profiling) { + if (do_pretty_print) { (void) list_append(ip, instruction(Op_exec_count)); (yyvsp[(1) - (6)])->target_break = tbreak; (yyvsp[(1) - (6)])->target_continue = tcont; @@ -2552,7 +2553,7 @@ yyreduce: case 43: /* Line 1806 of yacc.c */ -#line 583 "awkgram.y" +#line 584 "awkgram.y" { /* * ----------------- @@ -2575,7 +2576,7 @@ yyreduce: ip = list_merge((yyvsp[(3) - (8)]), (yyvsp[(6) - (8)])); else ip = list_prepend((yyvsp[(6) - (8)]), instruction(Op_no_op)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(ip, instruction(Op_exec_count)); (void) list_append(ip, instruction(Op_jmp_true)); ip->lasti->target_jmp = ip->nexti; @@ -2585,7 +2586,7 @@ yyreduce: continue_allowed--; fix_break_continue(ip, tbreak, tcont); - if (do_profiling) { + if (do_pretty_print) { (yyvsp[(1) - (8)])->target_break = tbreak; (yyvsp[(1) - (8)])->target_continue = tcont; ((yyvsp[(1) - (8)]) + 1)->doloop_cond = tcont; @@ -2599,7 +2600,7 @@ yyreduce: case 44: /* Line 1806 of yacc.c */ -#line 625 "awkgram.y" +#line 626 "awkgram.y" { INSTRUCTION *ip; char *var_name = (yyvsp[(3) - (8)])->lextok; @@ -2673,7 +2674,7 @@ regular_loop: (yyvsp[(3) - (8)])->target_jmp = tbreak; (void) list_append(ip, (yyvsp[(3) - (8)])); - if (do_profiling) { + if (do_pretty_print) { (yyvsp[(1) - (8)])->opcode = Op_K_arrayfor; (yyvsp[(1) - (8)])->target_continue = tcont; (yyvsp[(1) - (8)])->target_break = tbreak; @@ -2694,7 +2695,7 @@ regular_loop: ip->lasti->assign_var = (yyvsp[(4) - (8)])->array_var->var_assign; } - if (do_profiling) { + if (do_pretty_print) { (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; @@ -2717,7 +2718,7 @@ regular_loop: case 45: /* Line 1806 of yacc.c */ -#line 738 "awkgram.y" +#line 739 "awkgram.y" { (yyval) = mk_for_loop((yyvsp[(1) - (12)]), (yyvsp[(3) - (12)]), (yyvsp[(6) - (12)]), (yyvsp[(9) - (12)]), (yyvsp[(12) - (12)])); @@ -2729,7 +2730,7 @@ regular_loop: case 46: /* Line 1806 of yacc.c */ -#line 745 "awkgram.y" +#line 746 "awkgram.y" { (yyval) = mk_for_loop((yyvsp[(1) - (11)]), (yyvsp[(3) - (11)]), (INSTRUCTION *) NULL, (yyvsp[(8) - (11)]), (yyvsp[(11) - (11)])); @@ -2741,9 +2742,9 @@ regular_loop: case 47: /* Line 1806 of yacc.c */ -#line 752 "awkgram.y" +#line 753 "awkgram.y" { - if (do_profiling) + if (do_pretty_print) (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_exec_count)); else (yyval) = (yyvsp[(1) - (1)]); @@ -2753,7 +2754,7 @@ regular_loop: case 48: /* Line 1806 of yacc.c */ -#line 762 "awkgram.y" +#line 763 "awkgram.y" { if (! break_allowed) error_ln((yyvsp[(1) - (2)])->source_line, @@ -2767,7 +2768,7 @@ regular_loop: case 49: /* Line 1806 of yacc.c */ -#line 771 "awkgram.y" +#line 772 "awkgram.y" { if (! continue_allowed) error_ln((yyvsp[(1) - (2)])->source_line, @@ -2781,7 +2782,7 @@ regular_loop: case 50: /* Line 1806 of yacc.c */ -#line 780 "awkgram.y" +#line 781 "awkgram.y" { /* if inside function (rule = 0), resolve context at run-time */ if (rule && rule != Rule) @@ -2795,7 +2796,7 @@ regular_loop: case 51: /* Line 1806 of yacc.c */ -#line 789 "awkgram.y" +#line 790 "awkgram.y" { if (do_traditional) error_ln((yyvsp[(1) - (2)])->source_line, @@ -2815,7 +2816,7 @@ regular_loop: case 52: /* Line 1806 of yacc.c */ -#line 804 "awkgram.y" +#line 805 "awkgram.y" { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2835,7 +2836,7 @@ regular_loop: case 53: /* Line 1806 of yacc.c */ -#line 819 "awkgram.y" +#line 820 "awkgram.y" { if (! in_function) yyerror(_("`return' used outside function context")); @@ -2845,7 +2846,7 @@ regular_loop: case 54: /* Line 1806 of yacc.c */ -#line 822 "awkgram.y" +#line 823 "awkgram.y" { if ((yyvsp[(3) - (4)]) == NULL) { (yyval) = list_create((yyvsp[(1) - (4)])); @@ -2871,14 +2872,14 @@ regular_loop: case 56: /* Line 1806 of yacc.c */ -#line 854 "awkgram.y" +#line 855 "awkgram.y" { in_print = TRUE; in_parens = 0; } break; case 57: /* Line 1806 of yacc.c */ -#line 855 "awkgram.y" +#line 856 "awkgram.y" { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2976,14 +2977,14 @@ regular_loop: case 58: /* Line 1806 of yacc.c */ -#line 948 "awkgram.y" +#line 949 "awkgram.y" { sub_counter = 0; } break; case 59: /* Line 1806 of yacc.c */ -#line 949 "awkgram.y" +#line 950 "awkgram.y" { char *arr = (yyvsp[(2) - (4)])->lextok; @@ -3013,7 +3014,7 @@ regular_loop: case 60: /* Line 1806 of yacc.c */ -#line 978 "awkgram.y" +#line 979 "awkgram.y" { static short warned = FALSE; char *arr = (yyvsp[(3) - (4)])->lextok; @@ -3037,35 +3038,35 @@ regular_loop: case 61: /* Line 1806 of yacc.c */ -#line 997 "awkgram.y" +#line 998 "awkgram.y" { (yyval) = optimize_assignment((yyvsp[(1) - (1)])); } break; case 62: /* Line 1806 of yacc.c */ -#line 1002 "awkgram.y" +#line 1003 "awkgram.y" { (yyval) = NULL; } break; case 63: /* Line 1806 of yacc.c */ -#line 1004 "awkgram.y" +#line 1005 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 64: /* Line 1806 of yacc.c */ -#line 1009 "awkgram.y" +#line 1010 "awkgram.y" { (yyval) = NULL; } break; case 65: /* Line 1806 of yacc.c */ -#line 1011 "awkgram.y" +#line 1012 "awkgram.y" { if ((yyvsp[(1) - (2)]) == NULL) (yyval) = list_create((yyvsp[(2) - (2)])); @@ -3077,19 +3078,19 @@ regular_loop: case 66: /* Line 1806 of yacc.c */ -#line 1018 "awkgram.y" +#line 1019 "awkgram.y" { (yyval) = NULL; } break; case 67: /* Line 1806 of yacc.c */ -#line 1023 "awkgram.y" +#line 1024 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(5) - (5)]); if ((yyvsp[(5) - (5)]) == NULL) casestmt = list_create(instruction(Op_no_op)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(casestmt, instruction(Op_exec_count)); (yyvsp[(1) - (5)])->case_exp = (yyvsp[(2) - (5)]); (yyvsp[(1) - (5)])->case_stmt = casestmt; @@ -3101,12 +3102,12 @@ regular_loop: case 68: /* Line 1806 of yacc.c */ -#line 1035 "awkgram.y" +#line 1036 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(4) - (4)]); if ((yyvsp[(4) - (4)]) == NULL) casestmt = list_create(instruction(Op_no_op)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(casestmt, instruction(Op_exec_count)); bcfree((yyvsp[(2) - (4)])); (yyvsp[(1) - (4)])->case_stmt = casestmt; @@ -3117,14 +3118,14 @@ regular_loop: case 69: /* Line 1806 of yacc.c */ -#line 1049 "awkgram.y" +#line 1050 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 70: /* Line 1806 of yacc.c */ -#line 1051 "awkgram.y" +#line 1052 "awkgram.y" { (yyvsp[(2) - (2)])->memory->numbr = -(force_number((yyvsp[(2) - (2)])->memory)); bcfree((yyvsp[(1) - (2)])); @@ -3135,7 +3136,7 @@ regular_loop: case 71: /* Line 1806 of yacc.c */ -#line 1057 "awkgram.y" +#line 1058 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); @@ -3145,14 +3146,14 @@ regular_loop: case 72: /* Line 1806 of yacc.c */ -#line 1062 "awkgram.y" +#line 1063 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 73: /* Line 1806 of yacc.c */ -#line 1064 "awkgram.y" +#line 1065 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_push_re; (yyval) = (yyvsp[(1) - (1)]); @@ -3162,21 +3163,21 @@ regular_loop: case 74: /* Line 1806 of yacc.c */ -#line 1072 "awkgram.y" +#line 1073 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 75: /* Line 1806 of yacc.c */ -#line 1074 "awkgram.y" +#line 1075 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 77: /* Line 1806 of yacc.c */ -#line 1084 "awkgram.y" +#line 1085 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } @@ -3185,7 +3186,7 @@ regular_loop: case 78: /* Line 1806 of yacc.c */ -#line 1091 "awkgram.y" +#line 1092 "awkgram.y" { in_print = FALSE; in_parens = 0; @@ -3196,14 +3197,14 @@ regular_loop: case 79: /* Line 1806 of yacc.c */ -#line 1096 "awkgram.y" +#line 1097 "awkgram.y" { in_print = FALSE; in_parens = 0; } break; case 80: /* Line 1806 of yacc.c */ -#line 1097 "awkgram.y" +#line 1098 "awkgram.y" { if ((yyvsp[(1) - (3)])->redir_type == redirect_twoway && (yyvsp[(3) - (3)])->lasti->opcode == Op_K_getline_redir @@ -3216,7 +3217,7 @@ regular_loop: case 81: /* Line 1806 of yacc.c */ -#line 1108 "awkgram.y" +#line 1109 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (6)]), (yyvsp[(1) - (6)]), (yyvsp[(6) - (6)]), NULL, NULL); } @@ -3225,7 +3226,7 @@ regular_loop: case 82: /* Line 1806 of yacc.c */ -#line 1113 "awkgram.y" +#line 1114 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (9)]), (yyvsp[(1) - (9)]), (yyvsp[(6) - (9)]), (yyvsp[(7) - (9)]), (yyvsp[(9) - (9)])); } @@ -3234,14 +3235,14 @@ regular_loop: case 87: /* Line 1806 of yacc.c */ -#line 1130 "awkgram.y" +#line 1131 "awkgram.y" { (yyval) = NULL; } break; case 88: /* Line 1806 of yacc.c */ -#line 1132 "awkgram.y" +#line 1133 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); @@ -3251,21 +3252,21 @@ regular_loop: case 89: /* Line 1806 of yacc.c */ -#line 1140 "awkgram.y" +#line 1141 "awkgram.y" { (yyval) = NULL; } break; case 90: /* Line 1806 of yacc.c */ -#line 1142 "awkgram.y" +#line 1143 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]) ; } break; case 91: /* Line 1806 of yacc.c */ -#line 1147 "awkgram.y" +#line 1148 "awkgram.y" { (yyvsp[(1) - (1)])->param_count = 0; (yyval) = list_create((yyvsp[(1) - (1)])); @@ -3275,7 +3276,7 @@ regular_loop: case 92: /* Line 1806 of yacc.c */ -#line 1152 "awkgram.y" +#line 1153 "awkgram.y" { (yyvsp[(3) - (3)])->param_count = (yyvsp[(1) - (3)])->lasti->param_count + 1; (yyval) = list_append((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); @@ -3286,63 +3287,63 @@ regular_loop: case 93: /* Line 1806 of yacc.c */ -#line 1158 "awkgram.y" +#line 1159 "awkgram.y" { (yyval) = NULL; } break; case 94: /* Line 1806 of yacc.c */ -#line 1160 "awkgram.y" +#line 1161 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 95: /* Line 1806 of yacc.c */ -#line 1162 "awkgram.y" +#line 1163 "awkgram.y" { (yyval) = (yyvsp[(1) - (3)]); } break; case 96: /* Line 1806 of yacc.c */ -#line 1168 "awkgram.y" +#line 1169 "awkgram.y" { (yyval) = NULL; } break; case 97: /* Line 1806 of yacc.c */ -#line 1170 "awkgram.y" +#line 1171 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 98: /* Line 1806 of yacc.c */ -#line 1175 "awkgram.y" +#line 1176 "awkgram.y" { (yyval) = NULL; } break; case 99: /* Line 1806 of yacc.c */ -#line 1177 "awkgram.y" +#line 1178 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 100: /* Line 1806 of yacc.c */ -#line 1182 "awkgram.y" +#line 1183 "awkgram.y" { (yyval) = mk_expression_list(NULL, (yyvsp[(1) - (1)])); } break; case 101: /* Line 1806 of yacc.c */ -#line 1184 "awkgram.y" +#line 1185 "awkgram.y" { (yyval) = mk_expression_list((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); yyerrok; @@ -3352,35 +3353,35 @@ regular_loop: case 102: /* Line 1806 of yacc.c */ -#line 1189 "awkgram.y" +#line 1190 "awkgram.y" { (yyval) = NULL; } break; case 103: /* Line 1806 of yacc.c */ -#line 1191 "awkgram.y" +#line 1192 "awkgram.y" { (yyval) = NULL; } break; case 104: /* Line 1806 of yacc.c */ -#line 1193 "awkgram.y" +#line 1194 "awkgram.y" { (yyval) = NULL; } break; case 105: /* Line 1806 of yacc.c */ -#line 1195 "awkgram.y" +#line 1196 "awkgram.y" { (yyval) = NULL; } break; case 106: /* Line 1806 of yacc.c */ -#line 1201 "awkgram.y" +#line 1202 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3392,21 +3393,21 @@ regular_loop: case 107: /* Line 1806 of yacc.c */ -#line 1208 "awkgram.y" +#line 1209 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 108: /* Line 1806 of yacc.c */ -#line 1210 "awkgram.y" +#line 1211 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 109: /* Line 1806 of yacc.c */ -#line 1212 "awkgram.y" +#line 1213 "awkgram.y" { if ((yyvsp[(1) - (3)])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[(2) - (3)])->source_line, @@ -3427,7 +3428,7 @@ regular_loop: case 110: /* Line 1806 of yacc.c */ -#line 1228 "awkgram.y" +#line 1229 "awkgram.y" { if (do_lint_old) warning_ln((yyvsp[(2) - (3)])->source_line, @@ -3442,7 +3443,7 @@ regular_loop: case 111: /* Line 1806 of yacc.c */ -#line 1238 "awkgram.y" +#line 1239 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3454,35 +3455,35 @@ regular_loop: case 112: /* Line 1806 of yacc.c */ -#line 1245 "awkgram.y" +#line 1246 "awkgram.y" { (yyval) = mk_condition((yyvsp[(1) - (5)]), (yyvsp[(2) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]), (yyvsp[(5) - (5)])); } break; case 113: /* Line 1806 of yacc.c */ -#line 1247 "awkgram.y" +#line 1248 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 114: /* Line 1806 of yacc.c */ -#line 1252 "awkgram.y" +#line 1253 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 115: /* Line 1806 of yacc.c */ -#line 1254 "awkgram.y" +#line 1255 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 116: /* Line 1806 of yacc.c */ -#line 1256 "awkgram.y" +#line 1257 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_assign_quotient; (yyval) = (yyvsp[(2) - (2)]); @@ -3492,49 +3493,49 @@ regular_loop: case 117: /* Line 1806 of yacc.c */ -#line 1264 "awkgram.y" +#line 1265 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 118: /* Line 1806 of yacc.c */ -#line 1266 "awkgram.y" +#line 1267 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 119: /* Line 1806 of yacc.c */ -#line 1271 "awkgram.y" +#line 1272 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 120: /* Line 1806 of yacc.c */ -#line 1273 "awkgram.y" +#line 1274 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 121: /* Line 1806 of yacc.c */ -#line 1278 "awkgram.y" +#line 1279 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 122: /* Line 1806 of yacc.c */ -#line 1280 "awkgram.y" +#line 1281 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 123: /* Line 1806 of yacc.c */ -#line 1282 "awkgram.y" +#line 1283 "awkgram.y" { int count = 2; int is_simple_var = FALSE; @@ -3586,49 +3587,49 @@ regular_loop: case 125: /* Line 1806 of yacc.c */ -#line 1334 "awkgram.y" +#line 1335 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 126: /* Line 1806 of yacc.c */ -#line 1336 "awkgram.y" +#line 1337 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 127: /* Line 1806 of yacc.c */ -#line 1338 "awkgram.y" +#line 1339 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 128: /* Line 1806 of yacc.c */ -#line 1340 "awkgram.y" +#line 1341 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 129: /* Line 1806 of yacc.c */ -#line 1342 "awkgram.y" +#line 1343 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 130: /* Line 1806 of yacc.c */ -#line 1344 "awkgram.y" +#line 1345 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 131: /* Line 1806 of yacc.c */ -#line 1346 "awkgram.y" +#line 1347 "awkgram.y" { /* * In BEGINFILE/ENDFILE, allow `getline var < file' @@ -3656,7 +3657,7 @@ regular_loop: case 132: /* Line 1806 of yacc.c */ -#line 1369 "awkgram.y" +#line 1370 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); @@ -3666,7 +3667,7 @@ regular_loop: case 133: /* Line 1806 of yacc.c */ -#line 1374 "awkgram.y" +#line 1375 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); @@ -3676,7 +3677,7 @@ regular_loop: case 134: /* Line 1806 of yacc.c */ -#line 1379 "awkgram.y" +#line 1380 "awkgram.y" { if (do_lint_old) { warning_ln((yyvsp[(4) - (5)])->source_line, @@ -3701,7 +3702,7 @@ regular_loop: case 135: /* Line 1806 of yacc.c */ -#line 1404 "awkgram.y" +#line 1405 "awkgram.y" { (yyval) = mk_getline((yyvsp[(3) - (4)]), (yyvsp[(4) - (4)]), (yyvsp[(1) - (4)]), (yyvsp[(2) - (4)])->redir_type); bcfree((yyvsp[(2) - (4)])); @@ -3711,49 +3712,49 @@ regular_loop: case 136: /* Line 1806 of yacc.c */ -#line 1410 "awkgram.y" +#line 1411 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 137: /* Line 1806 of yacc.c */ -#line 1412 "awkgram.y" +#line 1413 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 138: /* Line 1806 of yacc.c */ -#line 1414 "awkgram.y" +#line 1415 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 139: /* Line 1806 of yacc.c */ -#line 1416 "awkgram.y" +#line 1417 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 140: /* Line 1806 of yacc.c */ -#line 1418 "awkgram.y" +#line 1419 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 141: /* Line 1806 of yacc.c */ -#line 1420 "awkgram.y" +#line 1421 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 142: /* Line 1806 of yacc.c */ -#line 1425 "awkgram.y" +#line 1426 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3762,7 +3763,7 @@ regular_loop: case 143: /* Line 1806 of yacc.c */ -#line 1429 "awkgram.y" +#line 1430 "awkgram.y" { if ((yyvsp[(2) - (2)])->opcode == Op_match_rec) { (yyvsp[(2) - (2)])->opcode = Op_nomatch; @@ -3798,14 +3799,14 @@ regular_loop: case 144: /* Line 1806 of yacc.c */ -#line 1460 "awkgram.y" +#line 1461 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } break; case 145: /* Line 1806 of yacc.c */ -#line 1462 "awkgram.y" +#line 1463 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3816,7 +3817,7 @@ regular_loop: case 146: /* Line 1806 of yacc.c */ -#line 1468 "awkgram.y" +#line 1469 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3827,7 +3828,7 @@ regular_loop: case 147: /* Line 1806 of yacc.c */ -#line 1474 "awkgram.y" +#line 1475 "awkgram.y" { static short warned1 = FALSE; @@ -3845,7 +3846,7 @@ regular_loop: case 150: /* Line 1806 of yacc.c */ -#line 1489 "awkgram.y" +#line 1490 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); @@ -3855,7 +3856,7 @@ regular_loop: case 151: /* Line 1806 of yacc.c */ -#line 1494 "awkgram.y" +#line 1495 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); @@ -3865,7 +3866,7 @@ regular_loop: case 152: /* Line 1806 of yacc.c */ -#line 1499 "awkgram.y" +#line 1500 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3874,7 +3875,7 @@ regular_loop: case 153: /* Line 1806 of yacc.c */ -#line 1503 "awkgram.y" +#line 1504 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3883,7 +3884,7 @@ regular_loop: case 154: /* Line 1806 of yacc.c */ -#line 1507 "awkgram.y" +#line 1508 "awkgram.y" { if ((yyvsp[(2) - (2)])->lasti->opcode == Op_push_i && ((yyvsp[(2) - (2)])->lasti->memory->flags & (STRCUR|STRING)) == 0 @@ -3901,7 +3902,7 @@ regular_loop: case 155: /* Line 1806 of yacc.c */ -#line 1520 "awkgram.y" +#line 1521 "awkgram.y" { /* * was: $$ = $2 @@ -3916,7 +3917,7 @@ regular_loop: case 156: /* Line 1806 of yacc.c */ -#line 1533 "awkgram.y" +#line 1534 "awkgram.y" { func_use((yyvsp[(1) - (1)])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[(1) - (1)]); @@ -3926,7 +3927,7 @@ regular_loop: case 157: /* Line 1806 of yacc.c */ -#line 1538 "awkgram.y" +#line 1539 "awkgram.y" { /* indirect function call */ INSTRUCTION *f, *t; @@ -3964,7 +3965,7 @@ regular_loop: case 158: /* Line 1806 of yacc.c */ -#line 1574 "awkgram.y" +#line 1575 "awkgram.y" { param_sanity((yyvsp[(3) - (4)])); (yyvsp[(1) - (4)])->opcode = Op_func_call; @@ -3983,42 +3984,42 @@ regular_loop: case 159: /* Line 1806 of yacc.c */ -#line 1591 "awkgram.y" +#line 1592 "awkgram.y" { (yyval) = NULL; } break; case 160: /* Line 1806 of yacc.c */ -#line 1593 "awkgram.y" +#line 1594 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 161: /* Line 1806 of yacc.c */ -#line 1598 "awkgram.y" +#line 1599 "awkgram.y" { (yyval) = NULL; } break; case 162: /* Line 1806 of yacc.c */ -#line 1600 "awkgram.y" +#line 1601 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 163: /* Line 1806 of yacc.c */ -#line 1605 "awkgram.y" +#line 1606 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 164: /* Line 1806 of yacc.c */ -#line 1607 "awkgram.y" +#line 1608 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -4027,7 +4028,7 @@ regular_loop: case 165: /* Line 1806 of yacc.c */ -#line 1614 "awkgram.y" +#line 1615 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -4046,7 +4047,7 @@ regular_loop: case 166: /* Line 1806 of yacc.c */ -#line 1631 "awkgram.y" +#line 1632 "awkgram.y" { INSTRUCTION *t = (yyvsp[(2) - (3)]); if ((yyvsp[(2) - (3)]) == NULL) { @@ -4065,14 +4066,14 @@ regular_loop: case 167: /* Line 1806 of yacc.c */ -#line 1648 "awkgram.y" +#line 1649 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 168: /* Line 1806 of yacc.c */ -#line 1650 "awkgram.y" +#line 1651 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -4081,14 +4082,14 @@ regular_loop: case 169: /* Line 1806 of yacc.c */ -#line 1657 "awkgram.y" +#line 1658 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 170: /* Line 1806 of yacc.c */ -#line 1662 "awkgram.y" +#line 1663 "awkgram.y" { char *var_name = (yyvsp[(1) - (1)])->lextok; @@ -4101,7 +4102,7 @@ regular_loop: case 171: /* Line 1806 of yacc.c */ -#line 1670 "awkgram.y" +#line 1671 "awkgram.y" { char *arr = (yyvsp[(1) - (2)])->lextok; (yyvsp[(1) - (2)])->memory = variable((yyvsp[(1) - (2)])->source_line, arr, Node_var_new); @@ -4113,7 +4114,7 @@ regular_loop: case 172: /* Line 1806 of yacc.c */ -#line 1680 "awkgram.y" +#line 1681 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->nexti; if (ip->opcode == Op_push @@ -4130,7 +4131,7 @@ regular_loop: case 173: /* Line 1806 of yacc.c */ -#line 1692 "awkgram.y" +#line 1693 "awkgram.y" { (yyval) = list_append((yyvsp[(2) - (3)]), (yyvsp[(1) - (3)])); if ((yyvsp[(3) - (3)]) != NULL) @@ -4141,7 +4142,7 @@ regular_loop: case 174: /* Line 1806 of yacc.c */ -#line 1701 "awkgram.y" +#line 1702 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postincrement; } @@ -4150,7 +4151,7 @@ regular_loop: case 175: /* Line 1806 of yacc.c */ -#line 1705 "awkgram.y" +#line 1706 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postdecrement; } @@ -4159,49 +4160,49 @@ regular_loop: case 176: /* Line 1806 of yacc.c */ -#line 1708 "awkgram.y" +#line 1709 "awkgram.y" { (yyval) = NULL; } break; case 178: /* Line 1806 of yacc.c */ -#line 1716 "awkgram.y" +#line 1717 "awkgram.y" { yyerrok; } break; case 179: /* Line 1806 of yacc.c */ -#line 1720 "awkgram.y" +#line 1721 "awkgram.y" { yyerrok; } break; case 182: /* Line 1806 of yacc.c */ -#line 1729 "awkgram.y" +#line 1730 "awkgram.y" { yyerrok; } break; case 183: /* Line 1806 of yacc.c */ -#line 1733 "awkgram.y" +#line 1734 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); yyerrok; } break; case 184: /* Line 1806 of yacc.c */ -#line 1737 "awkgram.y" +#line 1738 "awkgram.y" { yyerrok; } break; /* Line 1806 of yacc.c */ -#line 4217 "awkgram.c" +#line 4218 "awkgram.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4432,7 +4433,7 @@ yyreturn: /* Line 2067 of yacc.c */ -#line 1739 "awkgram.y" +#line 1740 "awkgram.y" struct token { @@ -4607,7 +4608,7 @@ print_included_from() line--; msg("%s %s:%d%c", s->prev == sourcefile ? "In file included from" - : " from", + : " from", (s->stype == SRC_INC || s->stype == SRC_FILE) ? s->src : "cmd. line", line, @@ -4889,7 +4890,10 @@ parse_program(INSTRUCTION **pcode) ip_atexit = instruction(Op_atexit); /* target for `exit' in END block */ } - sourcefile = srcfiles->next; + for (sourcefile = srcfiles->next; sourcefile->stype == SRC_EXTLIB; + sourcefile = sourcefile->next) + ; + lexeof = FALSE; lexptr = NULL; lasttok = 0; @@ -4906,6 +4910,11 @@ parse_program(INSTRUCTION **pcode) if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */ check_funcs(); + if (args_array == NULL) + emalloc(args_array, NODE **, (max_args + 2) * sizeof(NODE *), "parse_program"); + else + erealloc(args_array, NODE **, (max_args + 2) * sizeof(NODE *), "parse_program"); + return (ret || errcount); } @@ -4948,7 +4957,7 @@ add_srcfile(int stype, char *src, SRCFILE *thisfile, int *already_included, int if (stype == SRC_CMDLINE || stype == SRC_STDIN) return do_add_srcfile(stype, src, NULL, thisfile); - path = find_source(src, &sbuf, &errno_val); + path = find_source(src, & sbuf, &errno_val, stype == SRC_EXTLIB); if (path == NULL) { if (errcode) { *errcode = errno_val; @@ -4959,7 +4968,7 @@ add_srcfile(int stype, char *src, SRCFILE *thisfile, int *already_included, int } for (s = srcfiles->next; s != srcfiles; s = s->next) { - if ((s->stype == SRC_FILE || s->stype == SRC_INC) + if ((s->stype == SRC_FILE || s->stype == SRC_INC || s->stype == SRC_EXTLIB) && files_are_same(path, s) ) { if (do_lint) { @@ -5076,9 +5085,12 @@ next_sourcefile() sourcefile->lexptr_begin = NULL; } - sourcefile = sourcefile->next; - if (sourcefile == srcfiles) - return; + while ((sourcefile = sourcefile->next) != NULL) { + if (sourcefile == srcfiles) + return; + if (sourcefile->stype != SRC_EXTLIB) + break; + } if (sourcefile->lexptr_begin != NULL) { /* resume reading from already opened file (postponed to process '@include') */ @@ -6175,7 +6187,7 @@ retry: case LEX_WHILE: case LEX_DO: case LEX_SWITCH: - if (! do_profiling) + if (! do_pretty_print) return lasttok = class; /* fall through */ case LEX_CASE: @@ -6629,7 +6641,7 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def) def->lasti->memory = dupnode(Nnull_string); (void) list_append(def, instruction(Op_K_return)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(def, instruction(Op_exec_count)); /* fi->opcode = Op_func */ @@ -7254,7 +7266,7 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, if (false_branch == NULL) { false_branch = list_create(instruction(Op_no_op)); if (elsep != NULL) { /* else { } */ - if (do_profiling) + if (do_pretty_print) (void) list_prepend(false_branch, elsep); else bcfree(elsep); @@ -7265,7 +7277,7 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, /* 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) { + if (do_pretty_print) { (void) list_prepend(false_branch, elsep); false_branch->nexti->branch_end = false_branch->lasti; (void) list_prepend(false_branch, instruction(Op_exec_count)); @@ -7280,7 +7292,7 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, ip = list_append(cond, instruction(Op_jmp_false)); ip->lasti->target_jmp = false_branch->nexti->nexti; - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(ip, ifp); (void) list_append(ip, instruction(Op_exec_count)); ip->nexti->branch_if = ip->lasti; @@ -7342,7 +7354,7 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action) if (rule != Rule) { rp = pattern; - if (do_profiling) + if (do_pretty_print) (void) list_append(action, instruction(Op_no_op)); (rp + 1)->firsti = action->nexti; (rp + 1)->lasti = action->lasti; @@ -7358,7 +7370,7 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action) if (pattern == NULL) { /* assert(action != NULL); */ - if (do_profiling) + if (do_pretty_print) (void) list_prepend(action, instruction(Op_exec_count)); (rp + 1)->firsti = action->nexti; (rp + 1)->lasti = tp; @@ -7374,12 +7386,12 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action) if (action == NULL) { (rp + 2)->last_line = find_line(pattern, LAST_LINE); action = list_create(instruction(Op_K_print_rec)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(action, instruction(Op_exec_count)); } else (rp + 2)->last_line = lastline; - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(pattern, instruction(Op_exec_count)); (void) list_prepend(action, instruction(Op_exec_count)); } @@ -7720,7 +7732,7 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, if (init != NULL) ip = list_merge(init, ip); - if (do_profiling) { + if (do_pretty_print) { (void) list_append(ip, instruction(Op_exec_count)); (forp + 1)->forloop_cond = pp_cond; (forp + 1)->forloop_body = ip->lasti; @@ -7742,7 +7754,7 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, ret = list_append(ip, tbreak); fix_break_continue(ret, tbreak, tcont); - if (do_profiling) { + if (do_pretty_print) { forp->target_break = tbreak; forp->target_continue = tcont; ret = list_prepend(ret, forp); diff --git a/awkgram.y b/awkgram.y index 08eb9904..968bf533 100644 --- a/awkgram.y +++ b/awkgram.y @@ -129,6 +129,7 @@ extern int sourceline; extern SRCFILE *srcfiles; extern INSTRUCTION *rule_list; extern int max_args; +extern NODE **args_array; static INSTRUCTION *rule_block[sizeof(ruletab)]; @@ -268,7 +269,7 @@ pattern add_lint($4, LINT_assign_in_cond); tp = instruction(Op_no_op); - list_prepend($1, bcalloc(Op_line_range, !!do_profiling + 1, 0)); + list_prepend($1, bcalloc(Op_line_range, !!do_pretty_print + 1, 0)); $1->nexti->triggered = FALSE; $1->nexti->target_jmp = $4->nexti; @@ -279,7 +280,7 @@ pattern list_append($4, instruction(Op_cond_pair)); $4->lasti->line_range = $1->nexti; $4->lasti->target_jmp = tp; - if (do_profiling) { + if (do_pretty_print) { ($1->nexti + 1)->condpair_left = $1->lasti; ($1->nexti + 1)->condpair_right = $4->lasti; } @@ -442,7 +443,7 @@ statement { $$ = $2; } | if_statement { - if (do_profiling) + if (do_pretty_print) $$ = list_prepend($1, instruction(Op_exec_count)); else $$ = $1; @@ -506,7 +507,7 @@ statement else dflt->target_jmp = casestmt->nexti; - if (do_profiling) { + if (do_pretty_print) { curr->stmt_start = casestmt->nexti; curr->stmt_end = casestmt->lasti; (void) list_prepend(cexp, curr); @@ -521,7 +522,7 @@ statement efree(case_values); ip = $3; - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(ip, $1); (void) list_prepend(ip, instruction(Op_exec_count)); $1->target_break = tbreak; @@ -560,7 +561,7 @@ statement ip = list_append($3, instruction(Op_jmp_false)); ip->lasti->target_jmp = tbreak; - if (do_profiling) { + if (do_pretty_print) { (void) list_append(ip, instruction(Op_exec_count)); $1->target_break = tbreak; $1->target_continue = tcont; @@ -602,7 +603,7 @@ statement ip = list_merge($3, $6); else ip = list_prepend($6, instruction(Op_no_op)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(ip, instruction(Op_exec_count)); (void) list_append(ip, instruction(Op_jmp_true)); ip->lasti->target_jmp = ip->nexti; @@ -612,7 +613,7 @@ statement continue_allowed--; fix_break_continue(ip, tbreak, tcont); - if (do_profiling) { + if (do_pretty_print) { $1->target_break = tbreak; $1->target_continue = tcont; ($1 + 1)->doloop_cond = tcont; @@ -695,7 +696,7 @@ regular_loop: $3->target_jmp = tbreak; (void) list_append(ip, $3); - if (do_profiling) { + if (do_pretty_print) { $1->opcode = Op_K_arrayfor; $1->target_continue = tcont; $1->target_break = tbreak; @@ -716,7 +717,7 @@ regular_loop: ip->lasti->assign_var = $4->array_var->var_assign; } - if (do_profiling) { + if (do_pretty_print) { (void) list_append(ip, instruction(Op_exec_count)); ($1 + 1)->forloop_cond = $4; ($1 + 1)->forloop_body = ip->lasti; @@ -750,7 +751,7 @@ regular_loop: } | non_compound_stmt { - if (do_profiling) + if (do_pretty_print) $$ = list_prepend($1, instruction(Op_exec_count)); else $$ = $1; @@ -1024,7 +1025,7 @@ case_statement INSTRUCTION *casestmt = $5; if ($5 == NULL) casestmt = list_create(instruction(Op_no_op)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(casestmt, instruction(Op_exec_count)); $1->case_exp = $2; $1->case_stmt = casestmt; @@ -1036,7 +1037,7 @@ case_statement INSTRUCTION *casestmt = $4; if ($4 == NULL) casestmt = list_create(instruction(Op_no_op)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(casestmt, instruction(Op_exec_count)); bcfree($2); $1->case_stmt = casestmt; @@ -1910,7 +1911,7 @@ print_included_from() line--; msg("%s %s:%d%c", s->prev == sourcefile ? "In file included from" - : " from", + : " from", (s->stype == SRC_INC || s->stype == SRC_FILE) ? s->src : "cmd. line", line, @@ -2192,7 +2193,10 @@ parse_program(INSTRUCTION **pcode) ip_atexit = instruction(Op_atexit); /* target for `exit' in END block */ } - sourcefile = srcfiles->next; + for (sourcefile = srcfiles->next; sourcefile->stype == SRC_EXTLIB; + sourcefile = sourcefile->next) + ; + lexeof = FALSE; lexptr = NULL; lasttok = 0; @@ -2209,6 +2213,11 @@ parse_program(INSTRUCTION **pcode) if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */ check_funcs(); + if (args_array == NULL) + emalloc(args_array, NODE **, (max_args + 2) * sizeof(NODE *), "parse_program"); + else + erealloc(args_array, NODE **, (max_args + 2) * sizeof(NODE *), "parse_program"); + return (ret || errcount); } @@ -2251,7 +2260,7 @@ add_srcfile(int stype, char *src, SRCFILE *thisfile, int *already_included, int if (stype == SRC_CMDLINE || stype == SRC_STDIN) return do_add_srcfile(stype, src, NULL, thisfile); - path = find_source(src, &sbuf, &errno_val); + path = find_source(src, & sbuf, &errno_val, stype == SRC_EXTLIB); if (path == NULL) { if (errcode) { *errcode = errno_val; @@ -2262,7 +2271,7 @@ add_srcfile(int stype, char *src, SRCFILE *thisfile, int *already_included, int } for (s = srcfiles->next; s != srcfiles; s = s->next) { - if ((s->stype == SRC_FILE || s->stype == SRC_INC) + if ((s->stype == SRC_FILE || s->stype == SRC_INC || s->stype == SRC_EXTLIB) && files_are_same(path, s) ) { if (do_lint) { @@ -2379,9 +2388,12 @@ next_sourcefile() sourcefile->lexptr_begin = NULL; } - sourcefile = sourcefile->next; - if (sourcefile == srcfiles) - return; + while ((sourcefile = sourcefile->next) != NULL) { + if (sourcefile == srcfiles) + return; + if (sourcefile->stype != SRC_EXTLIB) + break; + } if (sourcefile->lexptr_begin != NULL) { /* resume reading from already opened file (postponed to process '@include') */ @@ -3478,7 +3490,7 @@ retry: case LEX_WHILE: case LEX_DO: case LEX_SWITCH: - if (! do_profiling) + if (! do_pretty_print) return lasttok = class; /* fall through */ case LEX_CASE: @@ -3932,7 +3944,7 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def) def->lasti->memory = dupnode(Nnull_string); (void) list_append(def, instruction(Op_K_return)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(def, instruction(Op_exec_count)); /* fi->opcode = Op_func */ @@ -4557,7 +4569,7 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, if (false_branch == NULL) { false_branch = list_create(instruction(Op_no_op)); if (elsep != NULL) { /* else { } */ - if (do_profiling) + if (do_pretty_print) (void) list_prepend(false_branch, elsep); else bcfree(elsep); @@ -4568,7 +4580,7 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, /* 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) { + if (do_pretty_print) { (void) list_prepend(false_branch, elsep); false_branch->nexti->branch_end = false_branch->lasti; (void) list_prepend(false_branch, instruction(Op_exec_count)); @@ -4583,7 +4595,7 @@ mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, ip = list_append(cond, instruction(Op_jmp_false)); ip->lasti->target_jmp = false_branch->nexti->nexti; - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(ip, ifp); (void) list_append(ip, instruction(Op_exec_count)); ip->nexti->branch_if = ip->lasti; @@ -4645,7 +4657,7 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action) if (rule != Rule) { rp = pattern; - if (do_profiling) + if (do_pretty_print) (void) list_append(action, instruction(Op_no_op)); (rp + 1)->firsti = action->nexti; (rp + 1)->lasti = action->lasti; @@ -4661,7 +4673,7 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action) if (pattern == NULL) { /* assert(action != NULL); */ - if (do_profiling) + if (do_pretty_print) (void) list_prepend(action, instruction(Op_exec_count)); (rp + 1)->firsti = action->nexti; (rp + 1)->lasti = tp; @@ -4677,12 +4689,12 @@ append_rule(INSTRUCTION *pattern, INSTRUCTION *action) if (action == NULL) { (rp + 2)->last_line = find_line(pattern, LAST_LINE); action = list_create(instruction(Op_K_print_rec)); - if (do_profiling) + if (do_pretty_print) (void) list_prepend(action, instruction(Op_exec_count)); } else (rp + 2)->last_line = lastline; - if (do_profiling) { + if (do_pretty_print) { (void) list_prepend(pattern, instruction(Op_exec_count)); (void) list_prepend(action, instruction(Op_exec_count)); } @@ -5023,7 +5035,7 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, if (init != NULL) ip = list_merge(init, ip); - if (do_profiling) { + if (do_pretty_print) { (void) list_append(ip, instruction(Op_exec_count)); (forp + 1)->forloop_cond = pp_cond; (forp + 1)->forloop_body = ip->lasti; @@ -5045,7 +5057,7 @@ mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, ret = list_append(ip, tbreak); fix_break_continue(ret, tbreak, tcont); - if (do_profiling) { + if (do_pretty_print) { forp->target_break = tbreak; forp->target_continue = tcont; ret = list_prepend(ret, forp); diff --git a/cint_array.c b/cint_array.c index 3d812cbb..400e91d2 100644 --- a/cint_array.c +++ b/cint_array.c @@ -316,10 +316,14 @@ cint_remove(NODE *symbol, NODE *subs) int h1; NODE *tn, *xn = symbol->xarray; - assert(symbol->nodes != NULL); + if (symbol->table_size == 0) + return NULL; + if (! ISUINT(symbol, subs)) goto xremove; + assert(symbol->nodes != NULL); + k = subs->numbr; h1 = cint_hash(k); tn = symbol->nodes[h1]; @@ -338,6 +342,7 @@ cint_remove(NODE *symbol, NODE *subs) init_array(symbol); /* re-initialize array 'symbol' */ } else if(xn != NULL && symbol->table_size == xn->table_size) { /* promote xn to symbol */ + xn->flags &= ~XARRAY; xn->parent_array = symbol->parent_array; efree(symbol->nodes); diff --git a/debug.c b/debug.c index 37418115..76c2dcb9 100644 --- a/debug.c +++ b/debug.c @@ -40,7 +40,6 @@ 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() @@ -214,9 +213,9 @@ struct dbg_option { const char *help_txt; }; -#define DEFAULT_HISTFILE "./.dgawk_history" -#define DEFAULT_OPTFILE "./.dgawkrc" -#define DEFAULT_PROMPT "dgawk> " +#define DEFAULT_HISTFILE "./.gawk_history" +#define DEFAULT_OPTFILE "./.gawkrc" +#define DEFAULT_PROMPT "gawk> " #define DEFAULT_LISTSIZE 15 #define DEFAULT_HISTSIZE 100 @@ -235,7 +234,7 @@ static const char *history_file = DEFAULT_HISTFILE; /* keep all option variables in one place */ static char *output_file = "/dev/stdout"; /* gawk output redirection */ -char *dgawk_Prompt = NULL; /* initialized in interpret */ +char *dgawk_Prompt = NULL; /* initialized in do_debug */ static int list_size = DEFAULT_LISTSIZE; /* # of lines that 'list' prints */ static int do_trace = FALSE; static int do_save_history = TRUE; @@ -485,11 +484,11 @@ source_find(char *src) return s; } - path = find_source(src, &sbuf, &errno_val); + path = find_source(src, & sbuf, & errno_val, FALSE); 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)) { + && files_are_same(path, s)) { efree(path); return s; } @@ -2722,10 +2721,10 @@ initialize_readline() #endif -/* interpret --- debugger entry point */ +/* debug_prog --- debugger entry point */ int -interpret(INSTRUCTION *pc) +debug_prog(INSTRUCTION *pc) { char *run; @@ -2775,7 +2774,7 @@ interpret(INSTRUCTION *pc) (void) do_run(NULL, 0); } else if (command_file != NULL) { - /* run commands from a file (--command=file or -R file) */ + /* run commands from a file (--debug=file or -D file) */ int fd; fd = open_readfd(command_file); if (fd == INVALID_HANDLE) { @@ -2922,7 +2921,7 @@ do_run(CMDARG *arg ATTRIBUTE_UNUSED, int cmd ATTRIBUTE_UNUSED) prog_running = TRUE; fatal_tag_valid = TRUE; if (setjmp(fatal_tag) == 0) - (void) r_interpret(code_block); + (void) interpret(code_block); fatal_tag_valid = FALSE; prog_running = FALSE; @@ -5377,7 +5376,7 @@ execute_code(volatile INSTRUCTION *code) PUSH_BINDING(fatal_tag_stack, fatal_tag, fatal_tag_valid); if (setjmp(fatal_tag) == 0) { - (void) r_interpret((INSTRUCTION *) code); + (void) interpret((INSTRUCTION *) code); r = POP_SCALAR(); } else /* fatal error */ (void) unwind_stack(save_stack_size); @@ -5517,7 +5516,7 @@ do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) } /* always destroy symbol "@eval", however destroy all newly installed - * globals only if fatal error in r_interpret (r == NULL). + * globals only if fatal error (execute_code() returing NULL). */ pop_context(); /* switch to prev context */ diff --git a/doc/ChangeLog b/doc/ChangeLog index 3a9a9912..7dda7e1d 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,11 @@ +2011-12-21 John Haque + + * gawk.texi: Updated sections on profiling and debugging + after merging the exes. Document new options --debug and + --load, and add a sub-section on loading extension library. + * gawk.1: Same. + * awkcard.in: Same. + 2011-12-06 Arnold D. Robbins * gawk.texi: Various typo fixes from mailing list. diff --git a/doc/awkcard.in b/doc/awkcard.in index 1c4d1910..862c307c 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -25,7 +25,6 @@ .\" 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 .\" @@ -253,6 +252,9 @@ their types and final values to If no \*(FIfile\*(FR is provided, \*(FCgawk\*(FR uses \*(FCawkvars.out\*(FR. +.TI "\*(FC\-D\*(FR[\*(FC\*(FIfile\*(FR], \*(FC\-\^\-debug\*(FR[\*(FC=\*(FIfile\*(FR] +Enable debugging of program. Optionally read stored commands +from \*(FIfile\*(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 @@ -268,6 +270,8 @@ 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 \*(FIlib\*(FR, \*(FC\-\^\-load \*(FIlib\*(FR +Load dynamic extension \*(FIlib\fP. .TI "\*(FC\-L \*(FR[\*(FC\*(FIvalue\*(FR], \*(FC\-\^\-lint\*(FR[\*(FC=\*(FIvalue\*(FR] Warn about dubious or non-portable constructs. If \*(FIvalue\*(FR is @@ -282,21 +286,18 @@ 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\*(FIfile\*(FR], \*(FC\-\^\-pretty-print\*(FR[\*(FC=\*(FIfile\*(FR] +Output a pretty printed version of the program to \*(FIfile\*(FR +(default: \*(FCawkprof.out\*(FR). .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 +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 @@ -382,10 +383,10 @@ The options may be abbreviated using just the first letter, e.g., and so on.\*(CB .EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(MK\f(HB)\*(FR\s0" .sp .7 -.\" --- Signals (pgawk) +.\" --- Signals (gawk --profile) .ES .fi -\*(CD\*(PK accepts two signals. +\*(CD\*(GK accepts two signals while profiling. \*(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 diff --git a/doc/gawk.1 b/doc/gawk.1 index e26f9a2e..c171acbf 100644 --- a/doc/gawk.1 +++ b/doc/gawk.1 @@ -33,30 +33,6 @@ gawk \- pattern scanning and processing language ] .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. @@ -84,27 +60,31 @@ 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 +When +.I gawk +is invoked with the +.B \-\^\-profile +option, it starts gathering profiling statistics +from the execution of the program. +.I Gawk +runs more slowly in this mode, and 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 +.I Gawk +also has an integrated debugger. An interactive debugging session can +be started by supplying the +.B \-\^\-debug +option to the command line. In this mode of execution, +.I gawk +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 +.I Gawk +can only debug AWK program source provided with the .B \-f option. The debugger is documented in \*(EP. @@ -273,6 +253,18 @@ names like and so on.) .TP .PD 0 +\fB\-D\fR[\fIfile\fR] +.TP +.PD +\fB\-\^\-debug\fR[\fB=\fIfile\fR] +Enable debugging of \*(AK programs. +By default, the debugger reads commands interactively from the terminal. +The optional +.IR file +argument can be used to specify a file with a list +of commands for the debugger to execute non-interactively. +.TP +.PD 0 .BI "\-e " program-text .TP .PD @@ -331,6 +323,21 @@ the standard output. these options cause an immediate, successful exit.) .TP .PD 0 +.BI "\-l " lib +.TP +.PD +.BI \-\^\-load " lib" +Load a shared library +.IR lib . +This searches for the library using the +.B AWKPATH +environment variable. The suffix +.I .so +in the library name is optional, and +the library initialization routine is expected to be named +.BR dlload() . +.TP +.PD 0 .BR "\-L " [ \fIvalue\fR ] .TP .PD @@ -387,12 +394,28 @@ users. .. .TP .PD 0 +\fB\-o\fR[\fIfile\fR] +.TP +.PD +\fB\-\^\-pretty-print\fR[\fB=\fIfile\fR] +Output a pretty printed version of the program to +.IR file . +If no +.I file +is provided, +.I gawk +uses a file named +.B awkprof.out +in the current directory. +.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 +Currently, this includes simple constant-folding, and tail call +elimination for recursive functions. The .I gawk maintainer hopes to add additional optimizations over time. .TP @@ -401,16 +424,11 @@ maintainer hopes to add additional optimizations over time. .TP .PD \fB\-\^\-profile\fR[\fB=\fIprof_file\fR] -Send profiling data to +Start a profiling session, and send the 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 +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 @@ -482,15 +500,6 @@ 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 @@ -3122,8 +3131,9 @@ 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. +The +.I gawk +profiler accepts two signals. .B SIGUSR1 causes it to dump a profile and function call stack to the profile file, which is either @@ -3133,7 +3143,7 @@ or whatever file was named with the option. It then continues to run. .B SIGHUP causes -.I pgawk +.I gawk to dump the profile and function call stack and then exit. .SH INTERNATIONALIZATION .PP diff --git a/doc/gawk.info b/doc/gawk.info index a8b6450b..06b8e119 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -94,7 +94,7 @@ texts being (a) (see below), and with the Back-Cover Texts being (b) * Library Functions:: A Library of `awk' Functions. * Sample Programs:: Many `awk' programs with complete explanations. -* Debugger:: The `dgawk' debugger. +* Debugger:: The `gawk' debugger. * Language History:: The evolution of the `awk' language. * Installation:: Installing `gawk' under various @@ -417,23 +417,23 @@ texts being (a) (see below), and with the Back-Cover Texts being (b) * 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:: Introduction to `gawk' Debugger. +* 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. +* Sample Debugging Session:: Sample Debugging Session. +* Debugger Invocation:: How to Start the Debugger. +* Finding The Bug:: Finding the Bug. +* List of Debugger Commands:: Main Commands. +* Breakpoint Control:: Control of Breakpoints. +* Debugger Execution Control:: Control of Execution. +* Viewing And Changing Data:: Viewing and Changing Data. +* Execution Stack:: Dealing with the Stack. +* Debugger Info:: Obtaining Information about the Program and + the Debugger State. +* Miscellaneous Debugger Commands:: Miscellaneous Commands. * Readline Support:: Readline Support. -* Dgawk Limitations:: Limitations and future plans. +* 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 @@ -489,6 +489,7 @@ texts being (a) (see below), and with the Back-Cover Texts being (b) * Internals:: A brief look at some `gawk' internals. * Plugin License:: A note about licensing. +* Loading Extensions:: How to load dynamic extensions. * 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. @@ -849,7 +850,7 @@ and profile your `awk' programs. sample `awk' programs. Reading them allows you to see `awk' solving real problems. - *note Debugger::, describes the `awk' debugger, `dgawk'. + *note Debugger::, describes the `awk' debugger. *note Language History::, describes how the `awk' language has evolved since its first release to present. It also describes how @@ -2215,6 +2216,15 @@ The following list describes options mandated by the POSIX standard: particularly easy mistake to make with simple variable names like `i', `j', etc.) +`-D[FILE]' +`--debug=[FILE]' + Enable debugging of `awk' programs (*note Debugging::). By + default, the debugger reads commands interactively from the + terminal. The optional FILE argument allows you to specify a file + with a list of commands for the debugger to execute + non-interactively. No space is allowed between the `-D' and FILE, + if FILE is supplied. + `-e PROGRAM-TEXT' `--source PROGRAM-TEXT' Provide program source code in the PROGRAM-TEXT. This option @@ -2257,6 +2267,13 @@ The following list describes options mandated by the POSIX standard: Print a "usage" message summarizing the short and long style options that `gawk' accepts and then exit. +`-l LIB' +`--load LIB' + Load a shared library LIB. This searches for the library using the + `AWKPATH' environment variable. The suffix `.so' in the library + name is optional. The library initialization routine should be + named `dlload()'. + `-L [value]' `--lint[=value]' Warn about constructs that are dubious or nonportable to other @@ -2289,6 +2306,14 @@ The following list describes options mandated by the POSIX standard: Force the use of the locale's decimal point character when parsing numeric input data (*note Locales::). +`-o[FILE]' +`--pretty-print[=FILE]' + Enable pretty-printing of `awk' programs. By default, output + program is created in a file named `awkprof.out'. The optional + FILE argument allows you to specify a different file name for the + output. No space is allowed between the `-o' and FILE, if FILE is + supplied. + `-O' `--optimize' Enable some optimizations on the internal representation of the @@ -2304,10 +2329,9 @@ The following list describes options mandated by the POSIX standard: 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. + The profile contains execution counts for each statement in the + program in the left margin, and function call counts for each + function. `-P' `--posix' @@ -2341,11 +2365,6 @@ The following list describes options mandated by the POSIX standard: 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', @@ -14115,25 +14134,22 @@ File: gawk.info, Node: Profiling, Prev: TCP/IP Networking, Up: Advanced Featu ================================== 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% +by passing the option `--profile' to `gawk'. When `gawk' 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: +used to change the name of the file where `gawk' will write the profile: - pgawk --profile=myprog.prof -f myprog.awk data1 data2 + gawk --profile=myprog.prof -f myprog.awk data1 data2 -In the above example, `pgawk' places the profile in `myprog.prof' +In the above example, `gawk' 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: +data, and the results from running `gawk' with the `--profile' option. +First, the `awk' program: BEGIN { print "First BEGIN rule" } @@ -14169,9 +14185,9 @@ data, and the results from running `pgawk'. First, the `awk' program: 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): + Here is the `awkprof.out' that results from running the `gawk' +profiler 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 @@ -14260,14 +14276,14 @@ output. They are as follows: 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. + * `gawk' 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 +you typed when you wrote it. This is because `gawk' creates the profiled version by "pretty printing" its internal representation of -the program. The advantage to this is that `pgawk' can produce a +the program. The advantage to this is that `gawk' 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: @@ -14282,21 +14298,23 @@ come out as: which is correct, but possibly surprising. - Besides creating profiles when a program has completed, `pgawk' can + Besides creating profiles when a program has completed, `gawk' 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: +executed. To use this feature, run `gawk' with the `--profile' option +in the background: - $ pgawk -f myprog & + $ gawk --profile -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': +13992. Use the `kill' command to send the `USR1' signal to `gawk': $ 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. +`awkprof.out', or to a different file if one specified with the +`--profile' option. Along with the regular profile, as shown earlier, the profile includes a trace of any active functions: @@ -14308,22 +14326,22 @@ includes a trace of any active functions: # 1. foo # -- main -- - You may send `pgawk' the `USR1' signal as many times as you like. + You may send `gawk' 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' + If you use the `HUP' signal instead of the `USR1' signal, `gawk' 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 + When `gawk' runs on MS-Windows systems, it uses the `INT' and `QUIT' +signals for producing the profile and, in the case of the `INT' signal, +`gawk' 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 + Finally, `gawk' also accepts another option `--pretty-print'. When called this way, `gawk' "pretty prints" the program into `awkprof.out', without any execution counts. @@ -18702,45 +18720,46 @@ supplies the following copyright terms:  File: gawk.info, Node: Debugger, Next: Language History, Prev: Sample Programs, Up: Top -14 `dgawk': The `awk' Debugger -****************************** +14 Debugging `awk' Programs +*************************** 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 + The `gawk' 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. +are familiar with GDB, learning how to use `gawk' for debugging your +program 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. +* Debugging:: Introduction to `gawk' debugger. +* Sample Debugging Session:: Sample debugging session. +* List of Debugger Commands:: Main debugger commands. +* Readline Support:: Readline support. +* Limitations:: Limitations and future plans.  -File: gawk.info, Node: Debugging, Next: Sample dgawk session, Up: Debugger +File: gawk.info, Node: Debugging, Next: Sample Debugging Session, Up: Debugger -14.1 Introduction to `dgawk' -============================ +14.1 Introduction to `gawk' Debugger +==================================== This minor node introduces debugging in general and begins the discussion of debugging in `gawk'. * Menu: -* Debugging Concepts:: Debugging In General. +* 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 +14.1.1 Debugging in General --------------------------- (If you have used debuggers in other languages, you may want to skip @@ -18784,9 +18803,8 @@ File: gawk.info, Node: Debugging Terms, Next: Awk Debugging, Prev: Debugging ------------------------------------ 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. +concepts that apply to just about all debuggers. The following list +defines terms used throughout the rest of this major node. "Stack Frame" Programs generally call functions during the course of their @@ -18804,11 +18822,11 @@ major node. 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). + `gawk' also follows this model, and 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 @@ -18853,54 +18871,57 @@ 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 +File: gawk.info, Node: Sample Debugging Session, Next: List of Debugger Commands, Prev: Debugging, Up: Debugger -14.2 Sample `dgawk' session -=========================== +14.2 Sample Debugging 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. +In order to illustrate the use of `gawk' as a debugger, 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. +* Debugger Invocation:: How to Start the Debugger. +* Finding The Bug:: Finding the Bug.  -File: gawk.info, Node: dgawk invocation, Next: Finding The Bug, Up: Sample dgawk session +File: gawk.info, Node: Debugger Invocation, Next: Finding The Bug, Up: Sample Debugging Session -14.2.1 `dgawk' Invocation -------------------------- +14.2.1 How to Start the Debugger +-------------------------------- -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: +Starting the debugger is almost exactly like running `awk', except you +have to pass an additional option `--debug' or the corresponding short +option `-D'. The file(s) containing the program and any supporting +code are given on the command line as arguments to one or more `-f' +options. (`gawk' is not designed to debug command-line programs, only +programs contained in files.) In our case, we invoke the debugger like +this: - $ dgawk -f getopt.awk -f join.awk -f uniq.awk inputfile + $ gawk -D -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 +slightly different from what they are used to. With `gawk' debugger, +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: +would ordinarily do, the debugger merely loads all the program source +files, compiles them internally, and then gives us a prompt: - dgawk> + gawk> 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 +File: gawk.info, Node: Finding The Bug, Prev: Debugger Invocation, Up: Sample Debugging Session -14.2.2 Finding The Bug +14.2.2 Finding the Bug ---------------------- Let's say that we are having a problem using (a faulty version of) @@ -18930,27 +18951,27 @@ 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 + gawk> 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 + gawk> 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> + gawk> 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: +(short for "backtrace"), and the debugger responds with a listing of +the current stack frames: - dgawk> bt + gawk> 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 @@ -18964,9 +18985,9 @@ 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: +Actually, the debugger gives us: - dgawk> p n + gawk> p n -| n = untyped variable In this case, `n' is an uninitialized local variable, since the @@ -18974,13 +18995,13 @@ function was called without arguments (*note Function Calls::). A more useful variable to display might be the current record: - dgawk> p $0 + gawk> 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 + gawk> p NR -| NR = number (2) So we can see that `are_equal()' was only called for the second record @@ -18994,7 +19015,7 @@ for `NR == 1': OK, let's just check that that rule worked correctly: - dgawk> p last + gawk> p last -| last = string ("awk is a wonderful program!") Everything we have done so far has verified that the program has @@ -19003,7 +19024,7 @@ 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 + gawk> n -| 67 if (fcount > 0) { This tells us that `gawk' is now ready to execute line 67, which @@ -19019,15 +19040,15 @@ was false.) Continuing to step, we now get to the splitting of the current and last records: - dgawk> n + gawk> n -| 68 n = split(last, alast) - dgawk> n + gawk> 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 + gawk> p n m alast aline -| n = number (5) -| m = number (5) -| alast = array, 5 elements @@ -19043,19 +19064,19 @@ want to see inside the array? The first choice would be to use subscripts: - dgawk> p alast[0] + gawk> p alast[0] -| "0" not in array `alast' Oops! - dgawk> p alast[1] + gawk> 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 + This would be kind of slow for a 100-member array, though, so `gawk' +provides a shortcut (reminiscent of another language not to be mentioned): - dgawk> p @alast + gawk> p @alast -| alast["1"] = string ("awk") -| alast["2"] = string ("is") -| alast["3"] = string ("a") @@ -19064,9 +19085,9 @@ mentioned): It looks like we got this far OK. Let's take another step or two: - dgawk> n + gawk> n -| 70 clast = join(alast, fcount, n) - dgawk> n + gawk> n -| 71 cline = join(aline, fcount, m) Well, here we are at our error (sorry to spoil the suspense). What @@ -19074,7 +19095,7 @@ 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 + gawk> p cline clast -| cline = string ("gawk is a wonderful program!") -| clast = string ("awk is a wonderful program!") @@ -19082,9 +19103,9 @@ zero, this would work. Let's look at what we've got: 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': + We get out of the debugger: - dgawk> q + gawk> q -| The program is running. Exit anyway (y/n)? y Then we get into an editor: @@ -19095,12 +19116,13 @@ Then we get into an editor: and problem solved!  -File: gawk.info, Node: List of Debugger Commands, Next: Readline Support, Prev: Sample dgawk session, Up: Debugger +File: gawk.info, Node: List of Debugger Commands, Next: Readline Support, Prev: Sample Debugging Session, Up: Debugger -14.3 Main `dgawk' Commands -========================== +14.3 Main Debugger Commands +=========================== -The `dgawk' command set can be divided into the following categories: +The `gawk' debugger command set can be divided into the following +categories: * Breakpoint control @@ -19116,26 +19138,26 @@ The `dgawk' command set can be divided into the following categories: 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', +abbreviation on a second description line. A debugger command name may +also be truncated if that partial name is unambiguous. The debugger 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. +* Breakpoint Control:: Control of Breakpoints. +* Debugger Execution Control:: Control of Execution. +* Viewing And Changing Data:: Viewing and Changing Data. +* Execution Stack:: Dealing with the Stack. +* Debugger Info:: Obtaining Information about the Program and + the Debugger State. +* Miscellaneous Debugger Commands:: Miscellaneous Commands.  -File: gawk.info, Node: Breakpoint Control, Next: Dgawk Execution Control, Up: List of Debugger Commands +File: gawk.info, Node: Breakpoint Control, Next: Debugger Execution Control, Up: List of Debugger Commands -14.3.1 Control Of Breakpoints +14.3.1 Control of Breakpoints ----------------------------- As we saw above, the first thing you probably want to do in a debugging @@ -19163,10 +19185,10 @@ controlling breakpoints are: 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' + `awk' expression (enclosed in double quotes) that the debugger 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. + true, then the debugger stops execution and prompts for a command. + Otherwise, it continues executing the program. `clear' [[FILENAME`:']N | FUNCTION] Without any argument, delete any breakpoint at the next instruction @@ -19188,12 +19210,13 @@ controlling breakpoints are: `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. + condition is an `awk' expression that the debugger evaluates + whenever the breakpoint or watchpoint is reached. If the condition + is true, then the debugger stops execution and prompts for a + command. Otherwise, the debugger 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] @@ -19227,7 +19250,7 @@ controlling breakpoints are: 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 +File: gawk.info, Node: Debugger Execution Control, Next: Viewing And Changing Data, Prev: Breakpoint Control, Up: List of Debugger Commands 14.3.2 Control of Execution --------------------------- @@ -19250,14 +19273,14 @@ execution of the program than we saw in our earlier example: `continue') terminates the list (an implicit `end'), and subsequent commands are ignored. For example: - dgawk> commands + gawk> commands > silent > printf "A silent breakpoint; i = %d\n", i > info locals > set i = 10 > continue > end - dgawk> + gawk> `continue' [COUNT] `c' [COUNT] @@ -19290,9 +19313,9 @@ execution of the program than we saw in our earlier example: `run' `r' - Start/restart execution of the program. When restarting, `dgawk' - retains the current breakpoints, watchpoints, command history, - automatic display variables, and debugger options. + Start/restart execution of the program. When restarting, the + debugger retains the current breakpoints, watchpoints, command + history, automatic display variables, and debugger options. `step' [COUNT] `s' [COUNT] @@ -19307,7 +19330,7 @@ execution of the program than we saw in our earlier example: 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::.) + Debugger Commands::.) `until' [[FILENAME`:']N | FUNCTION] `u' [[FILENAME`:']N | FUNCTION] @@ -19317,7 +19340,7 @@ execution of the program than we saw in our earlier example: current stack frame returns.  -File: gawk.info, Node: Viewing And Changing Data, Next: Dgawk Stack, Prev: Dgawk Execution Control, Up: List of Debugger Commands +File: gawk.info, Node: Viewing And Changing Data, Next: Execution Stack, Prev: Debugger Execution Control, Up: List of Debugger Commands 14.3.3 Viewing and Changing Data -------------------------------- @@ -19329,7 +19352,7 @@ The commands for viewing and changing variables inside of `gawk' are: 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 + gawk> display x -| 10: x = 1 displays the assigned item number, the variable name and its @@ -19357,7 +19380,7 @@ AWK STATEMENTS Print the value of a `gawk' variable or field. Fields must be referenced by constants: - dgawk> print $3 + gawk> 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 @@ -19385,16 +19408,16 @@ AWK STATEMENTS `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. + Add variable VAR (or field `$N') to the watch list. The debugger + 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' + `awk' expression (enclosed in double quotes) that the debugger 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. + true, then the debugger stops execution and prompts for a command. + Otherwise, `gawk' continues executing the program. `undisplay' [N] Remove item number N (or all items, if no argument) from the @@ -19406,9 +19429,9 @@ AWK STATEMENTS  -File: gawk.info, Node: Dgawk Stack, Next: Dgawk Info, Prev: Viewing And Changing Data, Up: List of Debugger Commands +File: gawk.info, Node: Execution Stack, Next: Debugger Info, Prev: Viewing And Changing Data, Up: List of Debugger Commands -14.3.4 Dealing With The Stack +14.3.4 Dealing with the Stack ----------------------------- Whenever you run a program which contains any function calls, `gawk' @@ -19443,16 +19466,17 @@ are: 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 +File: gawk.info, Node: Debugger Info, Next: Miscellaneous Debugger Commands, Prev: Execution Stack, Up: List of Debugger Commands -14.3.5 Obtaining Information About The Program and The Debugger State +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: +debugging environment itself. The `gawk' debugger 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 @@ -19480,10 +19504,10 @@ of a number of arguments that tell it exactly what you want to know: `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. + current instruction. When the debugger 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. @@ -19507,7 +19531,7 @@ from a file. The commands are: `history_size' The maximum number of lines to keep in the history file - `./.dgawk_history'. The default is 100. + `./.gawk_history'. The default is 100. `listsize' The number of lines that `list' prints. The default is 15. @@ -19518,14 +19542,14 @@ from a file. The commands are: standard output. `prompt' - The debugger prompt. The default is `dgawk> '. + The debugger prompt. The default is `gawk> '. `save_history [on | off]' - Save command history to file `./.dgawk_history'. The default + Save command history to file `./.gawk_history'. The default is `on'. `save_options [on | off]' - Save current options to file `./.dgawkrc' upon exit. The + Save current options to file `./.gawkrc' upon exit. The default is `on'. Options are read back in to the next session upon startup. @@ -19543,15 +19567,15 @@ from a file. The commands 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. + commands; however, the `gawk' debugger 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 + the `-D FILE' or `--debug=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 +File: gawk.info, Node: Miscellaneous Debugger Commands, Prev: Debugger Info, Up: List of Debugger Commands 14.3.6 Miscellaneous Commands ----------------------------- @@ -19567,7 +19591,7 @@ categories, as follows: partial dump of Davide Brini's obfuscated code (*note Signature Program::) demonstrates: - dgawk> dump + gawk> dump -| # BEGIN -| -| [ 2:0x89faef4] Op_rule : [in_rule = BEGIN] [source_file = brini.awk] @@ -19616,13 +19640,13 @@ categories, as follows: -| [ :0x89fa3b0] Op_after_beginfile : -| [ :0x89fa388] Op_no_op : -| [ :0x89fa3c4] Op_after_endfile : - dgawk> + gawk> `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. + Print a list of all of the `gawk' debugger 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] @@ -19656,7 +19680,7 @@ categories, as follows: 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 + if you are running a program, the debugger warns you if you accidentally type `q' or `quit', to make sure you really want to quit. @@ -19671,12 +19695,12 @@ categories, as follows:  -File: gawk.info, Node: Readline Support, Next: Dgawk Limitations, Prev: List of Debugger Commands, Up: Debugger +File: gawk.info, Node: Readline Support, Next: Limitations, Prev: List of Debugger Commands, Up: Debugger 14.4 Readline Support ===================== -If `dgawk' is compiled with the `readline' library, you can take +If `gawk' 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: @@ -19698,27 +19722,27 @@ Variable name completion  -File: gawk.info, Node: Dgawk Limitations, Prev: Readline Support, Up: Debugger +File: gawk.info, Node: 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: +We hope you find the `gawk' debugger 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 + * At this point, the debugger 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 + * If you perused the dump of opcodes in *note Miscellaneous Debugger 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. + Unfortunately, as of now, the `gawk' debugger 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 @@ -19731,13 +19755,15 @@ limitations. A few which are worth being aware of are: 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. + * The `gawk' debugger is designed to be used by running a program + (with all its parameters) on the command line, as described in + *note Debugger 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. + * The `gawk' debugger 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 @@ -20313,7 +20339,7 @@ Info file, in approximate chronological order: 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. + providing the `gawk' debugger for `awk' programs. * Efraim Yawitz contributed the original text for *note Debugger::. @@ -21330,9 +21356,10 @@ Unix `awk' `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 + is different from `gawk' with the `--profile' option. (*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 @@ -21729,6 +21756,7 @@ is necessary when reading this minor node. * Internals:: A brief look at some `gawk' internals. * Plugin License:: A note about licensing. +* Loading Extensions:: How to load dynamic extensions. * Sample Library:: A example of new functions.  @@ -21928,7 +21956,7 @@ function parameter. just blindly copy this code.  -File: gawk.info, Node: Plugin License, Next: Sample Library, Prev: Internals, Up: Dynamic Extensions +File: gawk.info, Node: Plugin License, Next: Loading Extensions, Prev: Internals, Up: Dynamic Extensions C.3.2 Extension Licensing ------------------------- @@ -21945,9 +21973,54 @@ 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 +File: gawk.info, Node: Loading Extensions, Next: Sample Library, Prev: Plugin License, Up: Dynamic Extensions + +C.3.3 Loading a Dynamic Extension +--------------------------------- + +There are two ways to load a dynamically linked library. The first is +to use the builtin `extension()': + + extension(libname, init_func) + + where `libname' is the library to load, and `init_func' is the name +of the initialization or bootstrap routine to run once loaded. + + The second method for dynamic loading of a library is to use the +command line option `-l': + + $ gawk -l libname -f myprog + + This will work only if the initialization routine is named +`dlload()'. + + If you use `extension()', the library will be loaded at run time. +This means that the functions are available only to the rest of your +script. If you use the command line option `-l' instead, the library +will be loaded before `gawk' starts compiling the actual program. The +net effect is that you can use those functions anywhere in the program. + + `gawk' has a list of directories where it searches for libraries. +By default, the list includes directories that depend upon how gawk was +built and installed (*note AWKPATH Variable::). If you want `gawk' to +look for libraries in your private directory, you have to tell it. The +way to do it is to set the `AWKPATH' environment variable (*note +AWKPATH Variable::). `gawk' supplies the default suffix `.so' if it is +not present in the name of the library. If the name of your library is +`mylib.so', you can simply type + + $ gawk -l mylib -f myprog + + and `gawk' will do everything necessary to load in your library, and +then call your `dlload()' routine. + + You can always specify the library using an absolute pathname, in +which case `gawk' will not use `AWKPATH' to search for it. + + +File: gawk.info, Node: Sample Library, Prev: Loading Extensions, Up: Dynamic Extensions -C.3.3 Example: Directory and File Operation Built-ins +C.3.4 Example: Directory and File Operation Built-ins ----------------------------------------------------- Two useful functions that are not in `awk' are `chdir()' (so that an @@ -21964,7 +22037,7 @@ implements these functions for `gawk' in an external extension library.  File: gawk.info, Node: Internal File Description, Next: Internal File Ops, Up: Sample Library -C.3.3.1 Using `chdir()' and `stat()' +C.3.4.1 Using `chdir()' and `stat()' .................................... This minor node shows how to use the new functions at the `awk' level @@ -22087,7 +22160,7 @@ Elements::):  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()' +C.3.4.2 C Code for `chdir()' and `stat()' ......................................... Here is the C code for these extensions. They were written for @@ -22237,7 +22310,7 @@ version.  File: gawk.info, Node: Using Internal File Ops, Prev: Internal File Ops, Up: Sample Library -C.3.3.3 Integrating the Extensions +C.3.4.3 Integrating the Extensions .................................. Now that the code is written, it must be possible to add it at runtime @@ -24675,8 +24748,8 @@ Index * ' (single quote): One-shot. (line 15) * ' (single quote), vs. apostrophe: Comments. (line 27) * ' (single quote), with double quotes: Quoting. (line 53) +* () (parentheses) <1>: Profiling. (line 138) * () (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. @@ -24708,71 +24781,74 @@ Index * --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) +* --debug option: Options. (line 105) * --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) +* --exec option: Options. (line 122) * --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) +* --gen-pot option: Options. (line 144) +* --help option: Options. (line 151) +* --L option: Options. (line 263) +* --lint option <1>: Options. (line 163) * --lint option: Command Line. (line 20) -* --lint-old option: Options. (line 245) +* --lint-old option: Options. (line 263) +* --load option: Options. (line 156) * --non-decimal-data option <1>: Nondecimal Data. (line 6) -* --non-decimal-data option: Options. (line 166) +* --non-decimal-data option: Options. (line 182) * --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) +* --optimize option: Options. (line 203) +* --posix option: Options. (line 222) +* --posix option, --traditional option and: Options. (line 241) +* --pretty-print option: Options. (line 195) +* --profile option <1>: Profiling. (line 12) +* --profile option: Options. (line 210) +* --re-interval option: Options. (line 247) +* --sandbox option: Options. (line 254) * --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) +* --source option: Options. (line 114) * --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) +* --traditional option, --posix option and: Options. (line 241) +* --use-lc-numeric option: Options. (line 190) +* --version option: Options. (line 268) * --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 105) * -d option: Options. (line 90) -* -E option: Options. (line 113) -* -e option: Options. (line 105) +* -E option: Options. (line 122) +* -e option: Options. (line 114) * -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) +* -F option, -Ft sets FS to TAB: Options. (line 276) +* -f option, on command line: Options. (line 281) +* -g option: Options. (line 144) +* -h option: Options. (line 151) +* -l option: Options. (line 156) +* -N option: Options. (line 190) +* -n option: Options. (line 182) +* -O option: Options. (line 203) +* -o option: Options. (line 195) +* -P option: Options. (line 222) +* -p option: Options. (line 210) +* -r option: Options. (line 247) +* -S option: Options. (line 254) +* -V option: Options. (line 268) * -v option: Options. (line 32) * -v option, variables, assigning: Assignment Options. (line 12) * -W option: Options. (line 46) @@ -25028,7 +25104,10 @@ Index * asterisk (*), *= operator: Assignment Ops. (line 129) * atan2() function: Numeric Functions. (line 11) * awf (amazingly workable formatter) program: Glossary. (line 25) +* awk debugging, enabling: Options. (line 105) +* awk enabling: Options. (line 195) * awk language, POSIX version: Assignment Ops. (line 136) +* awk profiling, enabling: Options. (line 210) * awk programs <1>: Two Rules. (line 6) * awk programs <2>: Executable Scripts. (line 6) * awk programs: Getting Started. (line 12) @@ -25044,7 +25123,6 @@ Index * 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) @@ -25084,7 +25162,7 @@ Index * 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) +* awkprof.out file: Profiling. (line 6) * awksed.awk program: Simple Sed. (line 25) * awkvars.out file: Options. (line 90) * b debugger command (alias for break): Breakpoint Control. (line 11) @@ -25138,12 +25216,13 @@ Index * backslash (\), in escape sequences, POSIX and: Escape Sequences. (line 113) * backslash (\), regexp constants: Computed Regexps. (line 28) -* backtrace debugger command: Dgawk Stack. (line 13) +* backtrace debugger command: Execution 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 <1>: Profiling. (line 62) +* BEGIN pattern <2>: BEGIN/END. (line 6) +* BEGIN pattern <3>: Field Separators. (line 44) * BEGIN pattern: Records. (line 29) * BEGIN pattern, assert() user-defined function and: Assert Function. (line 83) @@ -25158,7 +25237,6 @@ Index * 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) @@ -25187,8 +25265,8 @@ Index * 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 ({}): Profiling. (line 134) * 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) @@ -25215,7 +25293,7 @@ Index * 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) +* bt debugger command (alias for backtrace): Execution Stack. (line 13) * Buening, Andreas <1>: Bugs. (line 71) * Buening, Andreas <2>: Contributors. (line 92) * Buening, Andreas: Acknowledgments. (line 60) @@ -25233,7 +25311,7 @@ Index * 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) +* Busybox Awk: Other Versions. (line 79) * call by reference: Pass By Value/Reference. (line 47) * call by value: Pass By Value/Reference. @@ -25253,7 +25331,7 @@ Index * 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) +* CGI, awk scripts for: Options. (line 122) * 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. @@ -25307,7 +25385,7 @@ Index * 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. +* commands debugger command: Debugger Execution Control. (line 10) * commenting: Comments. (line 6) * commenting, backslash continuation and: Statements/Lines. (line 76) @@ -25384,7 +25462,7 @@ Index * cos() function: Numeric Functions. (line 14) * counting: Wc Program. (line 6) * csh utility: Statements/Lines. (line 44) -* csh utility, POSIXLY_CORRECT environment variable: Options. (line 305) +* csh utility, POSIXLY_CORRECT environment variable: Options. (line 323) * 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) @@ -25392,7 +25470,7 @@ Index (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 debugger command (alias for delete): Breakpoint Control. (line 64) * d.c., See dark corner: Conventions. (line 38) * dark corner <1>: Glossary. (line 193) * dark corner <2>: Truth Values. (line 24) @@ -25456,113 +25534,113 @@ Index (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, backtrace: Execution 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. +* debugger commands, bt (backtrace): Execution Stack. (line 13) +* debugger commands, c (continue): Debugger Execution Control. (line 33) * debugger commands, clear: Breakpoint Control. (line 36) -* debugger commands, commands: Dgawk Execution Control. +* debugger commands, commands: Debugger Execution Control. (line 10) * debugger commands, condition: Breakpoint Control. (line 54) -* debugger commands, continue: Dgawk Execution Control. +* debugger commands, continue: Debugger 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, d (delete): Breakpoint Control. (line 64) +* debugger commands, delete: Breakpoint Control. (line 64) +* debugger commands, disable: Breakpoint Control. (line 69) * debugger commands, display: Viewing And Changing Data. (line 8) -* debugger commands, down: Dgawk Stack. (line 21) -* debugger commands, dump: Miscellaneous Dgawk Commands. +* debugger commands, down: Execution Stack. (line 21) +* debugger commands, dump: Miscellaneous Debugger Commands. (line 9) -* debugger commands, e (enable): Breakpoint Control. (line 72) -* debugger commands, enable: Breakpoint Control. (line 72) -* debugger commands, end: Dgawk Execution Control. +* debugger commands, e (enable): Breakpoint Control. (line 73) +* debugger commands, enable: Breakpoint Control. (line 73) +* debugger commands, end: Debugger 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. +* debugger commands, f (frame): Execution Stack. (line 25) +* debugger commands, finish: Debugger Execution Control. (line 39) -* debugger commands, frame: Dgawk Stack. (line 25) -* debugger commands, h (help): Miscellaneous Dgawk Commands. +* debugger commands, frame: Execution Stack. (line 25) +* debugger commands, h (help): Miscellaneous Debugger Commands. (line 68) -* debugger commands, help: Miscellaneous Dgawk Commands. +* debugger commands, help: Miscellaneous Debugger 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. +* debugger commands, i (info): Debugger Info. (line 13) +* debugger commands, ignore: Breakpoint Control. (line 87) +* debugger commands, info: Debugger Info. (line 13) +* debugger commands, l (list): Miscellaneous Debugger Commands. (line 74) -* debugger commands, list: Miscellaneous Dgawk Commands. +* debugger commands, list: Miscellaneous Debugger Commands. (line 74) -* debugger commands, n (next): Dgawk Execution Control. +* debugger commands, n (next): Debugger Execution Control. (line 43) -* debugger commands, next: Dgawk Execution Control. +* debugger commands, next: Debugger Execution Control. (line 43) -* debugger commands, nexti: Dgawk Execution Control. +* debugger commands, nexti: Debugger Execution Control. (line 49) -* debugger commands, ni (nexti): Dgawk Execution Control. +* debugger commands, ni (nexti): Debugger Execution Control. (line 49) -* debugger commands, o (option): Dgawk Info. (line 56) -* debugger commands, option: Dgawk Info. (line 56) +* debugger commands, o (option): Debugger Info. (line 57) +* debugger commands, option: Debugger Info. (line 57) * 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. +* debugger commands, q (quit): Miscellaneous Debugger Commands. (line 101) -* debugger commands, quit: Miscellaneous Dgawk Commands. +* debugger commands, quit: Miscellaneous Debugger Commands. (line 101) -* debugger commands, r (run): Dgawk Execution Control. +* debugger commands, r (run): Debugger Execution Control. (line 62) -* debugger commands, return: Dgawk Execution Control. +* debugger commands, return: Debugger Execution Control. (line 54) -* debugger commands, run: Dgawk Execution Control. +* debugger commands, run: Debugger Execution Control. (line 62) -* debugger commands, s (step): Dgawk Execution Control. +* debugger commands, s (step): Debugger Execution Control. (line 68) * debugger commands, set: Viewing And Changing Data. (line 59) -* debugger commands, si (stepi): Dgawk Execution Control. +* debugger commands, si (stepi): Debugger Execution Control. (line 76) -* debugger commands, silent: Dgawk Execution Control. +* debugger commands, silent: Debugger Execution Control. (line 10) -* debugger commands, step: Dgawk Execution Control. +* debugger commands, step: Debugger Execution Control. (line 68) -* debugger commands, stepi: Dgawk Execution Control. +* debugger commands, stepi: Debugger 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. +* debugger commands, t (tbreak): Breakpoint Control. (line 90) +* debugger commands, tbreak: Breakpoint Control. (line 90) +* debugger commands, trace: Miscellaneous Debugger Commands. (line 110) -* debugger commands, u (until): Dgawk Execution Control. +* debugger commands, u (until): Debugger Execution Control. (line 83) * debugger commands, undisplay: Viewing And Changing Data. (line 80) -* debugger commands, until: Dgawk Execution Control. +* debugger commands, until: Debugger Execution Control. (line 83) * debugger commands, unwatch: Viewing And Changing Data. (line 84) -* debugger commands, up: Dgawk Stack. (line 33) +* debugger commands, up: Execution Stack. (line 33) * debugger commands, w (watch): Viewing And Changing Data. (line 67) * debugger commands, watch: Viewing And Changing Data. (line 67) +* debugging awk programs: Debugger. (line 6) * debugging gawk, bug reports: Bugs. (line 9) -* decimal point character, locale specific: Options. (line 215) +* decimal point character, locale specific: Options. (line 238) * 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 debugger command: Breakpoint Control. (line 64) * 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) @@ -25633,7 +25711,7 @@ Index (line 6) * directories, searching <1>: Igawk Program. (line 368) * directories, searching: AWKPATH Variable. (line 6) -* disable debugger command: Breakpoint Control. (line 68) +* disable debugger command: Breakpoint Control. (line 69) * display debugger command: Viewing And Changing Data. (line 8) * division: Arithmetic Ops. (line 44) @@ -25651,14 +25729,14 @@ Index * 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) +* down debugger command: Execution Stack. (line 21) * Drepper, Ulrich: Acknowledgments. (line 52) * DuBois, John: Acknowledgments. (line 60) -* dump debugger command: Miscellaneous Dgawk Commands. +* dump debugger command: Miscellaneous Debugger Commands. (line 9) * dupnode() internal function: Internals. (line 87) * dupword.awk program: Dupword Program. (line 31) -* e debugger command (alias for enable): Breakpoint Control. (line 72) +* e debugger command (alias for enable): Breakpoint Control. (line 73) * EBCDIC: Ordinal Functions. (line 45) * egrep utility <1>: Egrep Program. (line 6) * egrep utility: Bracket Expressions. (line 24) @@ -25674,9 +25752,10 @@ Index * 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. +* enable debugger command: Breakpoint Control. (line 73) +* end debugger command: Debugger Execution Control. (line 10) +* END pattern <1>: Profiling. (line 62) * END pattern: BEGIN/END. (line 6) * END pattern, assert() user-defined function and: Assert Function. (line 75) @@ -25688,7 +25767,6 @@ Index * 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) @@ -25780,7 +25858,7 @@ Index * 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) +* f debugger command (alias for frame): Execution Stack. (line 25) * false, logical: Truth Values. (line 6) * FDL (Free Documentation License): GNU Free Documentation License. (line 6) @@ -25847,7 +25925,7 @@ Index * 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, awkprof.out: Profiling. (line 6) * files, awkvars.out: Options. (line 90) * files, closing: I/O Functions. (line 10) * files, descriptors, See file descriptors: Special FD. (line 6) @@ -25876,7 +25954,7 @@ Index * 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, portable object, generating: Options. (line 144) * files, processing, ARGIND variable and: Auto-set. (line 47) * files, reading: Rewind Function. (line 6) * files, reading, multiline records: Multiple Line. (line 6) @@ -25885,7 +25963,7 @@ Index * 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. +* finish debugger command: Debugger Execution Control. (line 39) * Fish, Fred: Contributors. (line 51) * fixed-width data: Constant Size. (line 9) @@ -25920,7 +25998,7 @@ Index * FPAT variable <1>: User-modified. (line 45) * FPAT variable: Splitting By Content. (line 26) -* frame debugger command: Dgawk Stack. (line 25) +* frame debugger command: Execution Stack. (line 25) * Free Documentation License (FDL): GNU Free Documentation License. (line 6) * Free Software Foundation (FSF) <1>: Glossary. (line 301) @@ -25932,7 +26010,7 @@ Index * 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, as TAB character: Options. (line 234) * 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. @@ -25983,7 +26061,7 @@ Index (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, counts: Profiling. (line 129) * functions, user-defined, library of: Library Functions. (line 6) * functions, user-defined, next/nextfile statements and <1>: Nextfile Statement. (line 44) @@ -25991,6 +26069,7 @@ Index (line 45) * G-d: Acknowledgments. (line 81) * Garfinkle, Scott: Contributors. (line 35) +* gawk program, dynamic profiling: Profiling. (line 171) * gawk, ARGIND variable in: Other Arguments. (line 12) * gawk, awk and <1>: This Manual. (line 14) * gawk, awk and: Preface. (line 23) @@ -26017,7 +26096,7 @@ Index (line 139) * gawk, ERRNO variable in: Getline. (line 19) * gawk, escape sequences: Escape Sequences. (line 125) -* gawk, extensions, disabling: Options. (line 199) +* gawk, extensions, disabling: Options. (line 222) * gawk, features, adding: Adding Code. (line 6) * gawk, features, advanced: Advanced Features. (line 6) * gawk, fflush() function in: I/O Functions. (line 44) @@ -26031,6 +26110,7 @@ Index (line 26) * gawk, function arguments and: Calling Built-in. (line 16) * gawk, functions, adding: Dynamic Extensions. (line 10) +* gawk, functions, loading: Loading Extensions. (line 6) * gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42) * gawk, IGNORECASE variable in <1>: Array Sorting Functions. (line 81) @@ -26081,7 +26161,7 @@ Index * 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, versions of, information about, printing: Options. (line 268) * gawk, VMS version of: VMS Installation. (line 6) * gawk, word-boundary operator: GNU Regexp Operators. (line 63) @@ -26141,7 +26221,7 @@ Index * 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 long options, printing list of: Options. (line 151) * GNU Project <1>: Glossary. (line 319) * GNU Project: Manual History. (line 11) * GNU/Linux <1>: Glossary. (line 611) @@ -26160,7 +26240,7 @@ Index (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. +* h debugger command (alias for help): Miscellaneous Debugger Commands. (line 68) * Hankerson, Darrel <1>: Contributors. (line 61) * Hankerson, Darrel: Acknowledgments. (line 60) @@ -26169,13 +26249,13 @@ Index * Hartholz, Elaine: Acknowledgments. (line 38) * Hartholz, Marshall: Acknowledgments. (line 38) * Hasegawa, Isamu: Contributors. (line 94) -* help debugger command: Miscellaneous Dgawk Commands. +* help debugger command: Miscellaneous Debugger Commands. (line 68) * hexadecimal numbers: Nondecimal-numbers. (line 6) -* hexadecimal values, enabling interpretation of: Options. (line 166) +* hexadecimal values, enabling interpretation of: Options. (line 182) * histsort.awk program: History Sorting. (line 25) * Hughes, Phil: Acknowledgments. (line 43) -* HUP signal: Profiling. (line 204) +* HUP signal: Profiling. (line 203) * hyphen (-), - operator: Precedence. (line 52) * hyphen (-), -- (decrement/increment) operators: Precedence. (line 46) * hyphen (-), -- operator: Increment Ops. (line 48) @@ -26183,14 +26263,14 @@ Index * 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) +* i debugger command (alias for info): Debugger Info. (line 13) * 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) +* ignore debugger command: Breakpoint Control. (line 87) * IGNORECASE variable <1>: Array Sorting Functions. (line 81) * IGNORECASE variable <2>: String Functions. (line 29) @@ -26218,7 +26298,7 @@ Index * 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) +* info debugger command: Debugger Info. (line 13) * initialization, automatic: More Complex. (line 38) * input files: Reading Files. (line 6) * input files, closing: Close Files And Pipes. @@ -26243,7 +26323,7 @@ Index * 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 signal (MS-Windows): Profiling. (line 206) * int() function: Numeric Functions. (line 22) * integers: Basic Data Typing. (line 21) * integers, unsigned: Basic Data Typing. (line 30) @@ -26308,9 +26388,9 @@ Index * 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 implementation of awk: Other Versions. (line 97) * Java programming language: Glossary. (line 380) -* jawk: Other Versions. (line 96) +* jawk: Other Versions. (line 97) * Jedi knights: Undocumented. (line 6) * join() user-defined function: Join Function. (line 18) * Kahrs, Ju"rgen <1>: Contributors. (line 70) @@ -26325,10 +26405,10 @@ Index * Kernighan, Brian <6>: Acknowledgments. (line 75) * Kernighan, Brian <7>: Conventions. (line 34) * Kernighan, Brian: History. (line 17) -* kill command, dynamic profiling: Profiling. (line 182) +* kill command, dynamic profiling: Profiling. (line 180) * Knights, jedi: Undocumented. (line 6) * Kwok, Conrad: Contributors. (line 35) -* l debugger command (alias for list): Miscellaneous Dgawk Commands. +* l debugger command (alias for list): Miscellaneous Debugger Commands. (line 74) * labels.awk program: Labels Program. (line 51) * languages, data-driven: Basic High Level. (line 83) @@ -26354,7 +26434,7 @@ Index * 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) +* libmawk: Other Versions. (line 105) * 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. @@ -26392,20 +26472,22 @@ Index * 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, issuing warnings: Options. (line 163) * lint checking, POSIXLY_CORRECT environment variable: Options. - (line 289) + (line 307) * 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. +* list debugger command: Miscellaneous Debugger Commands. (line 74) +* loading extension: Loading Extensions. (line 6) +* loading, library: Options. (line 156) * local variables: Variable Scope. (line 6) * locale categories: Explaining gettext. (line 80) -* locale decimal point character: Options. (line 215) +* locale decimal point character: Options. (line 238) * locale, definition of: Locales. (line 6) * localization: I18N and L10N. (line 6) * localization, See internationalization, localization: I18N and L10N. @@ -26418,7 +26500,7 @@ Index * 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, count for header: Profiling. (line 123) * loops, exiting: Break Statement. (line 6) * loops, See Also while statement: While Statement. (line 6) * Lost In Space: Dynamic Extensions. (line 6) @@ -26457,7 +26539,7 @@ Index * 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. +* n debugger command (alias for next): Debugger Execution Control. (line 43) * names, arrays/variables <1>: Library Names. (line 6) * names, arrays/variables: Arrays. (line 18) @@ -26473,7 +26555,7 @@ Index * 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 <2>: Options. (line 228) * newlines: Statements/Lines. (line 6) * newlines, as field separators: Default Field Splitting. (line 6) @@ -26484,7 +26566,7 @@ Index * newlines, separating statements in actions <1>: Statements. (line 10) * newlines, separating statements in actions: Action Overview. (line 19) -* next debugger command: Dgawk Execution Control. +* next debugger command: Debugger Execution Control. (line 43) * next statement <1>: Next Statement. (line 6) * next statement: Boolean Ops. (line 85) @@ -26499,12 +26581,12 @@ Index (line 26) * nextfile statement, user-defined functions and: Nextfile Statement. (line 44) -* nexti debugger command: Dgawk Execution Control. +* nexti debugger command: Debugger 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. +* ni debugger command (alias for nexti): Debugger Execution Control. (line 49) * noassign.awk program: Ignoring Assigns. (line 15) * NODE internal type: Internals. (line 23) @@ -26549,11 +26631,11 @@ Index * 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) +* o debugger command (alias for option): Debugger Info. (line 57) * oawk utility: Names. (line 17) * obsolete features: Obsolete. (line 6) * octal numbers: Nondecimal-numbers. (line 6) -* octal values, enabling interpretation of: Options. (line 166) +* octal values, enabling interpretation of: Options. (line 182) * OFMT variable <1>: User-modified. (line 115) * OFMT variable <2>: Conversion. (line 55) * OFMT variable: OFMT. (line 15) @@ -26562,7 +26644,7 @@ Index * OFS variable <2>: Output Separators. (line 6) * OFS variable: Changing Fields. (line 64) * OpenBSD: Glossary. (line 611) -* OpenSolaris: Other Versions. (line 86) +* OpenSolaris: Other Versions. (line 87) * 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. @@ -26595,7 +26677,7 @@ Index (line 48) * operators, word-boundary (gawk): GNU Regexp Operators. (line 63) -* option debugger command: Dgawk Info. (line 56) +* option debugger command: Debugger Info. (line 57) * options, command-line <1>: Command Line Field Separator. (line 6) * options, command-line <2>: Options. (line 6) @@ -26606,7 +26688,7 @@ Index * options, deprecated: Obsolete. (line 6) * options, long <1>: Options. (line 6) * options, long: Command Line. (line 13) -* options, printing list of: Options. (line 142) +* options, printing list of: Options. (line 151) * OR bitwise operation: Bitwise Functions. (line 6) * or Boolean-logic operator: Boolean Ops. (line 6) * or() function (gawk): Bitwise Functions. (line 48) @@ -26633,14 +26715,14 @@ Index * P1003.1 POSIX standard: Glossary. (line 454) * P1003.2 POSIX standard: Glossary. (line 454) * parameters, number of: Internals. (line 42) +* parentheses () <1>: Profiling. (line 138) * 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, counts: Profiling. (line 110) * patterns, default: Very Simple. (line 34) * patterns, empty: Empty. (line 6) * patterns, expressions as: Regexp Patterns. (line 6) @@ -26658,9 +26740,6 @@ Index * 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) @@ -26701,13 +26780,13 @@ Index * 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, POSIXLY_CORRECT environment variable: Options. (line 328) * 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 files, generating: Options. (line 144) * portable object template files: Explaining gettext. (line 30) * porting gawk: New Ports. (line 6) * positional specifiers, printf statement <1>: Printf Ordering. @@ -26751,11 +26830,11 @@ Index * POSIX awk, regular expressions and: Regexp Operators. (line 157) * POSIX awk, timestamps and: Time Functions. (line 6) * POSIX awk, | I/O operator and: Getline/Pipe. (line 52) -* POSIX mode: Options. (line 199) +* POSIX mode: Options. (line 222) * 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) +* POSIXLY_CORRECT environment variable: Options. (line 307) * precedence <1>: Precedence. (line 6) * precedence: Increment Ops. (line 61) * precedence, regexp operators: Regexp Operators. (line 152) @@ -26789,7 +26868,7 @@ Index * 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, list of options: Options. (line 151) * printing, mailing labels: Labels Program. (line 6) * printing, unduplicated lines of text: Uniq Program. (line 6) * printing, user information: Id Program. (line 6) @@ -26805,8 +26884,8 @@ Index * 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) +* profiling awk programs, dynamically: Profiling. (line 171) +* profiling gawk: 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. @@ -26830,23 +26909,23 @@ Index * 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. +* q debugger command (alias for quit): Miscellaneous Debugger Commands. (line 101) -* QSE Awk: Other Versions. (line 108) +* QSE Awk: Other Versions. (line 109) * 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. +* QuikTrim Awk: Other Versions. (line 113) +* quit debugger command: Miscellaneous Debugger Commands. (line 101) -* QUIT signal (MS-Windows): Profiling. (line 207) +* QUIT signal (MS-Windows): Profiling. (line 206) * 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. +* r debugger command (alias for run): Debugger Execution Control. (line 62) * Rakitzis, Byron: History Sorting. (line 25) * rand() function: Numeric Functions. (line 33) @@ -26912,7 +26991,7 @@ Index (line 59) * regular expressions, gawk, command-line options: GNU Regexp Operators. (line 70) -* regular expressions, interval expressions and: Options. (line 224) +* regular expressions, interval expressions and: Options. (line 247) * regular expressions, leftmost longest match: Leftmost Longest. (line 6) * regular expressions, operators <1>: Regexp Operators. (line 6) @@ -26928,7 +27007,7 @@ Index * regular expressions, searching for: Egrep Program. (line 6) * relational operators, See comparison operators: Typing and Comparison. (line 9) -* return debugger command: Dgawk Execution Control. +* return debugger command: Debugger Execution Control. (line 54) * return statement, user-defined functions: Return Statement. (line 6) * return values, close() function: Close Files And Pipes. @@ -26981,12 +27060,12 @@ Index * Rubin, Paul <1>: Contributors. (line 16) * Rubin, Paul: History. (line 30) * rule, definition of: Getting Started. (line 21) -* run debugger command: Dgawk Execution Control. +* run debugger command: Debugger Execution Control. (line 62) * rvalues/lvalues: Assignment Ops. (line 32) -* s debugger command (alias for step): Dgawk Execution Control. +* s debugger command (alias for step): Debugger Execution Control. (line 68) -* sandbox mode: Options. (line 236) +* sandbox mode: Options. (line 254) * scalar values: Basic Data Typing. (line 13) * Schorr, Andrew: Acknowledgments. (line 60) * Schreiber, Bert: Acknowledgments. (line 38) @@ -27032,7 +27111,7 @@ Index (line 6) * shift, bitwise: Bitwise Functions. (line 32) * short-circuit operators: Boolean Ops. (line 57) -* si debugger command (alias for stepi): Dgawk Execution Control. +* si debugger command (alias for stepi): Debugger Execution Control. (line 76) * side effects <1>: Increment Ops. (line 11) * side effects: Concatenation. (line 42) @@ -27047,15 +27126,15 @@ Index * 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. +* SIGHUP signal: Profiling. (line 203) +* SIGINT signal (MS-Windows): Profiling. (line 206) +* signals, HUP/SIGHUP: Profiling. (line 203) +* signals, INT/SIGINT (MS-Windows): Profiling. (line 206) +* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 206) +* signals, USR1/SIGUSR1: Profiling. (line 180) +* SIGQUIT signal (MS-Windows): Profiling. (line 206) +* SIGUSR1 signal: Profiling. (line 180) +* silent debugger command: Debugger Execution Control. (line 10) * sin() function: Numeric Functions. (line 74) * single precision floating-point: Basic Data Typing. (line 36) @@ -27068,7 +27147,7 @@ Index (line 6) * Skywalker, Luke: Undocumented. (line 6) * sleep utility: Alarm Program. (line 109) -* Solaris, POSIX-compliant awk: Other Versions. (line 86) +* Solaris, POSIX-compliant awk: Other Versions. (line 87) * sort function, arrays, sorting: Array Sorting Functions. (line 6) * sort utility: Word Sorting. (line 50) @@ -27077,17 +27156,17 @@ Index (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, Busybox Awk: Other Versions. (line 79) * source code, gawk: Gawk Distribution. (line 6) -* source code, jawk: Other Versions. (line 96) -* source code, libmawk: Other Versions. (line 104) +* source code, jawk: Other Versions. (line 97) +* source code, libmawk: Other Versions. (line 105) * source code, mawk: Other Versions. (line 35) -* source code, mixing: Options. (line 105) +* source code, mixing: Options. (line 114) * 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 code, QSE Awk: Other Versions. (line 109) +* source code, QuikTrim Awk: Other Versions. (line 113) +* source code, Solaris awk: Other Versions. (line 87) +* source code, xgawk: Other Versions. (line 120) * source files, search path for: Igawk Program. (line 368) * sparse arrays: Array Intro. (line 71) * Spencer, Henry: Glossary. (line 12) @@ -27115,9 +27194,9 @@ Index * 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. +* step debugger command: Debugger Execution Control. (line 68) -* stepi debugger command: Dgawk Execution Control. +* stepi debugger command: Debugger Execution Control. (line 76) * stlen internal variable: Internals. (line 46) * stptr internal variable: Internals. (line 46) @@ -27171,8 +27250,8 @@ Index (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) +* t debugger command (alias for tbreak): Breakpoint Control. (line 90) +* tbreak debugger command: Breakpoint Control. (line 90) * Tcl: Library Names. (line 57) * TCP/IP: TCP/IP Networking. (line 6) * TCP/IP, support for: Special Network. (line 6) @@ -27218,10 +27297,10 @@ Index * tolower() function: String Functions. (line 523) * toupper() function: String Functions. (line 529) * tr utility: Translate Program. (line 6) -* trace debugger command: Miscellaneous Dgawk Commands. +* trace debugger command: Miscellaneous Debugger Commands. (line 110) * translate.awk program: Translate Program. (line 55) -* troubleshooting, --non-decimal-data option: Options. (line 166) +* troubleshooting, --non-decimal-data option: Options. (line 182) * troubleshooting, == operator: Comparison Operators. (line 37) * troubleshooting, awk uses FS not IFS: Field Separators. (line 29) @@ -27262,7 +27341,7 @@ Index * truth values: Truth Values. (line 6) * type conversion: Conversion. (line 21) * type internal variable: Internals. (line 59) -* u debugger command (alias for until): Dgawk Execution Control. +* u debugger command (alias for until): Debugger Execution Control. (line 83) * undefined functions: Pass By Value/Reference. (line 71) @@ -27289,21 +27368,21 @@ Index * UNIXROOT variable, on OS/2 systems: PC Using. (line 17) * unref() internal function: Internals. (line 92) * unsigned integers: Basic Data Typing. (line 30) -* until debugger command: Dgawk Execution Control. +* until debugger command: Debugger Execution Control. (line 83) * unwatch debugger command: Viewing And Changing Data. (line 84) -* up debugger command: Dgawk Stack. (line 33) +* up debugger command: Execution Stack. (line 33) * update_ERRNO() internal function: Internals. (line 130) * update_ERRNO_saved() internal function: Internals. (line 135) * user database, reading: Passwd Functions. (line 6) * user-defined, functions: User-defined. (line 6) -* user-defined, functions, counts: Profiling. (line 132) +* user-defined, functions, counts: Profiling. (line 129) * 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) +* USR1 signal: Profiling. (line 180) * values, numeric: Basic Data Typing. (line 13) * values, string: Basic Data Typing. (line 13) * variable typing: Typing and Comparison. @@ -27354,7 +27433,7 @@ Index * Wall, Larry <1>: Future Extensions. (line 6) * Wall, Larry: Array Intro. (line 6) * Wallin, Anders: Acknowledgments. (line 60) -* warnings, issuing: Options. (line 147) +* warnings, issuing: Options. (line 163) * watch debugger command: Viewing And Changing Data. (line 67) * wc utility: Wc Program. (line 6) @@ -27366,7 +27445,7 @@ Index * whitespace, as field separators: Default Field Splitting. (line 6) * whitespace, functions, calling: Calling Built-in. (line 10) -* whitespace, newlines as: Options. (line 205) +* whitespace, newlines as: Options. (line 228) * Williams, Kent: Contributors. (line 35) * Woehlke, Matthew: Contributors. (line 79) * Woods, John: Contributors. (line 28) @@ -27382,7 +27461,7 @@ Index * words, usage counts, generating: Word Sorting. (line 6) * wstlen internal variable: Internals. (line 54) * wstptr internal variable: Internals. (line 54) -* xgawk: Other Versions. (line 119) +* xgawk: Other Versions. (line 120) * xgettext utility: String Extraction. (line 13) * XML (eXtensible Markup Language): Internals. (line 151) * XOR bitwise operation: Bitwise Functions. (line 6) @@ -27394,8 +27473,8 @@ Index * zero, negative vs. positive: Unexpected Results. (line 28) * zerofile.awk program: Empty Files. (line 21) * Zoulas, Christos: Contributors. (line 67) +* {} (braces): Profiling. (line 134) * {} (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) @@ -27422,416 +27501,417 @@ Index  Tag Table: Node: Top1346 -Node: Foreword30270 -Node: Preface34615 -Ref: Preface-Footnote-137668 -Ref: Preface-Footnote-237774 -Node: History38006 -Node: Names40397 -Ref: Names-Footnote-141874 -Node: This Manual41946 -Ref: This Manual-Footnote-146893 -Node: Conventions46993 -Node: Manual History49127 -Ref: Manual History-Footnote-152397 -Ref: Manual History-Footnote-252438 -Node: How To Contribute52512 -Node: Acknowledgments53656 -Node: Getting Started57987 -Node: Running gawk60366 -Node: One-shot61552 -Node: Read Terminal62777 -Ref: Read Terminal-Footnote-164427 -Ref: Read Terminal-Footnote-264703 -Node: Long64874 -Node: Executable Scripts66250 -Ref: Executable Scripts-Footnote-168119 -Ref: Executable Scripts-Footnote-268221 -Node: Comments68672 -Node: Quoting71139 -Node: DOS Quoting75762 -Node: Sample Data Files76437 -Node: Very Simple79469 -Node: Two Rules84068 -Node: More Complex86215 -Ref: More Complex-Footnote-189145 -Node: Statements/Lines89230 -Ref: Statements/Lines-Footnote-193692 -Node: Other Features93957 -Node: When94885 -Node: Invoking Gawk97032 -Node: Command Line98417 -Node: Options99200 -Ref: Options-Footnote-1112637 -Node: Other Arguments112662 -Node: Naming Standard Input115320 -Node: Environment Variables116414 -Node: AWKPATH Variable116858 -Ref: AWKPATH Variable-Footnote-1119455 -Node: Other Environment Variables119715 -Node: Exit Status122055 -Node: Include Files122730 -Node: Obsolete126215 -Node: Undocumented126901 -Node: Regexp127142 -Node: Regexp Usage128531 -Node: Escape Sequences130557 -Node: Regexp Operators136320 -Ref: Regexp Operators-Footnote-1143517 -Ref: Regexp Operators-Footnote-2143664 -Node: Bracket Expressions143762 -Ref: table-char-classes145652 -Node: GNU Regexp Operators148175 -Node: Case-sensitivity151898 -Ref: Case-sensitivity-Footnote-1154866 -Ref: Case-sensitivity-Footnote-2155101 -Node: Leftmost Longest155209 -Node: Computed Regexps156410 -Node: Reading Files159820 -Node: Records161761 -Ref: Records-Footnote-1170435 -Node: Fields170472 -Ref: Fields-Footnote-1173505 -Node: Nonconstant Fields173591 -Node: Changing Fields175793 -Node: Field Separators181774 -Node: Default Field Splitting184403 -Node: Regexp Field Splitting185520 -Node: Single Character Fields188862 -Node: Command Line Field Separator189921 -Node: Field Splitting Summary193362 -Ref: Field Splitting Summary-Footnote-1196554 -Node: Constant Size196655 -Node: Splitting By Content201239 -Ref: Splitting By Content-Footnote-1204965 -Node: Multiple Line205005 -Ref: Multiple Line-Footnote-1210852 -Node: Getline211031 -Node: Plain Getline213259 -Node: Getline/Variable215348 -Node: Getline/File216489 -Node: Getline/Variable/File217811 -Ref: Getline/Variable/File-Footnote-1219410 -Node: Getline/Pipe219497 -Node: Getline/Variable/Pipe222057 -Node: Getline/Coprocess223164 -Node: Getline/Variable/Coprocess224407 -Node: Getline Notes225121 -Node: Getline Summary227063 -Ref: table-getline-variants227406 -Node: Command line directories228262 -Node: Printing228887 -Node: Print230518 -Node: Print Examples231855 -Node: Output Separators234639 -Node: OFMT236399 -Node: Printf237757 -Node: Basic Printf238663 -Node: Control Letters240202 -Node: Format Modifiers244014 -Node: Printf Examples250023 -Node: Redirection252738 -Node: Special Files259722 -Node: Special FD260255 -Ref: Special FD-Footnote-1263880 -Node: Special Network263954 -Node: Special Caveats264804 -Node: Close Files And Pipes265600 -Ref: Close Files And Pipes-Footnote-1272623 -Ref: Close Files And Pipes-Footnote-2272771 -Node: Expressions272921 -Node: Values274053 -Node: Constants274729 -Node: Scalar Constants275409 -Ref: Scalar Constants-Footnote-1276268 -Node: Nondecimal-numbers276450 -Node: Regexp Constants279509 -Node: Using Constant Regexps279984 -Node: Variables283039 -Node: Using Variables283694 -Node: Assignment Options285418 -Node: Conversion287290 -Ref: table-locale-affects292666 -Ref: Conversion-Footnote-1293290 -Node: All Operators293399 -Node: Arithmetic Ops294029 -Node: Concatenation296534 -Ref: Concatenation-Footnote-1299327 -Node: Assignment Ops299447 -Ref: table-assign-ops304435 -Node: Increment Ops305843 -Node: Truth Values and Conditions309313 -Node: Truth Values310396 -Node: Typing and Comparison311445 -Node: Variable Typing312234 -Ref: Variable Typing-Footnote-1316131 -Node: Comparison Operators316253 -Ref: table-relational-ops316663 -Node: POSIX String Comparison320212 -Ref: POSIX String Comparison-Footnote-1321168 -Node: Boolean Ops321306 -Ref: Boolean Ops-Footnote-1325384 -Node: Conditional Exp325475 -Node: Function Calls327207 -Node: Precedence330801 -Node: Locales334470 -Node: Patterns and Actions335559 -Node: Pattern Overview336613 -Node: Regexp Patterns338282 -Node: Expression Patterns338825 -Node: Ranges342510 -Node: BEGIN/END345476 -Node: Using BEGIN/END346238 -Ref: Using BEGIN/END-Footnote-1348969 -Node: I/O And BEGIN/END349075 -Node: BEGINFILE/ENDFILE351357 -Node: Empty354250 -Node: Using Shell Variables354566 -Node: Action Overview356851 -Node: Statements359208 -Node: If Statement361062 -Node: While Statement362561 -Node: Do Statement364605 -Node: For Statement365761 -Node: Switch Statement368913 -Node: Break Statement371010 -Node: Continue Statement373000 -Node: Next Statement374793 -Node: Nextfile Statement377183 -Node: Exit Statement379728 -Node: Built-in Variables382144 -Node: User-modified383239 -Ref: User-modified-Footnote-1391265 -Node: Auto-set391327 -Ref: Auto-set-Footnote-1400618 -Node: ARGC and ARGV400823 -Node: Arrays404674 -Node: Array Basics406179 -Node: Array Intro407005 -Node: Reference to Elements411323 -Node: Assigning Elements413593 -Node: Array Example414084 -Node: Scanning an Array415816 -Node: Controlling Scanning418130 -Ref: Controlling Scanning-Footnote-1423063 -Node: Delete423379 -Ref: Delete-Footnote-1425814 -Node: Numeric Array Subscripts425871 -Node: Uninitialized Subscripts428054 -Node: Multi-dimensional429682 -Node: Multi-scanning432776 -Node: Arrays of Arrays434367 -Node: Functions439012 -Node: Built-in439834 -Node: Calling Built-in440912 -Node: Numeric Functions442900 -Ref: Numeric Functions-Footnote-1446665 -Ref: Numeric Functions-Footnote-2447022 -Ref: Numeric Functions-Footnote-3447070 -Node: String Functions447339 -Ref: String Functions-Footnote-1470836 -Ref: String Functions-Footnote-2470965 -Ref: String Functions-Footnote-3471213 -Node: Gory Details471300 -Ref: table-sub-escapes472979 -Ref: table-sub-posix-92474333 -Ref: table-sub-proposed475676 -Ref: table-posix-sub477026 -Ref: table-gensub-escapes478572 -Ref: Gory Details-Footnote-1479779 -Ref: Gory Details-Footnote-2479830 -Node: I/O Functions479981 -Ref: I/O Functions-Footnote-1486636 -Node: Time Functions486783 -Ref: Time Functions-Footnote-1497675 -Ref: Time Functions-Footnote-2497743 -Ref: Time Functions-Footnote-3497901 -Ref: Time Functions-Footnote-4498012 -Ref: Time Functions-Footnote-5498124 -Ref: Time Functions-Footnote-6498351 -Node: Bitwise Functions498617 -Ref: table-bitwise-ops499175 -Ref: Bitwise Functions-Footnote-1503335 -Node: Type Functions503519 -Node: I18N Functions503989 -Node: User-defined505616 -Node: Definition Syntax506420 -Ref: Definition Syntax-Footnote-1511330 -Node: Function Example511399 -Node: Function Caveats513993 -Node: Calling A Function514414 -Node: Variable Scope515529 -Node: Pass By Value/Reference517504 -Node: Return Statement520944 -Node: Dynamic Typing523925 -Node: Indirect Calls524660 -Node: Internationalization534345 -Node: I18N and L10N535771 -Node: Explaining gettext536457 -Ref: Explaining gettext-Footnote-1541523 -Ref: Explaining gettext-Footnote-2541707 -Node: Programmer i18n541872 -Node: Translator i18n546072 -Node: String Extraction546865 -Ref: String Extraction-Footnote-1547826 -Node: Printf Ordering547912 -Ref: Printf Ordering-Footnote-1550696 -Node: I18N Portability550760 -Ref: I18N Portability-Footnote-1553209 -Node: I18N Example553272 -Ref: I18N Example-Footnote-1555907 -Node: Gawk I18N555979 -Node: Advanced Features556596 -Node: Nondecimal Data558109 -Node: Array Sorting559692 -Node: Controlling Array Traversal560389 -Node: Array Sorting Functions568626 -Ref: Array Sorting Functions-Footnote-1572300 -Ref: Array Sorting Functions-Footnote-2572393 -Node: Two-way I/O572587 -Ref: Two-way I/O-Footnote-1578019 -Node: TCP/IP Networking578089 -Node: Profiling580933 -Node: Library Functions588407 -Ref: Library Functions-Footnote-1591414 -Node: Library Names591585 -Ref: Library Names-Footnote-1595056 -Ref: Library Names-Footnote-2595276 -Node: General Functions595362 -Node: Strtonum Function596315 -Node: Assert Function599245 -Node: Round Function602571 -Node: Cliff Random Function604114 -Node: Ordinal Functions605130 -Ref: Ordinal Functions-Footnote-1608200 -Ref: Ordinal Functions-Footnote-2608452 -Node: Join Function608661 -Ref: Join Function-Footnote-1610432 -Node: Gettimeofday Function610632 -Node: Data File Management614347 -Node: Filetrans Function614979 -Node: Rewind Function619118 -Node: File Checking620505 -Node: Empty Files621599 -Node: Ignoring Assigns623829 -Node: Getopt Function625382 -Ref: Getopt Function-Footnote-1636686 -Node: Passwd Functions636889 -Ref: Passwd Functions-Footnote-1645864 -Node: Group Functions645952 -Node: Walking Arrays654036 -Node: Sample Programs655605 -Node: Running Examples656270 -Node: Clones656998 -Node: Cut Program658222 -Node: Egrep Program668067 -Ref: Egrep Program-Footnote-1675840 -Node: Id Program675950 -Node: Split Program679566 -Ref: Split Program-Footnote-1683085 -Node: Tee Program683213 -Node: Uniq Program686016 -Node: Wc Program693445 -Ref: Wc Program-Footnote-1697711 -Ref: Wc Program-Footnote-2697911 -Node: Miscellaneous Programs698003 -Node: Dupword Program699191 -Node: Alarm Program701222 -Node: Translate Program705971 -Ref: Translate Program-Footnote-1710358 -Ref: Translate Program-Footnote-2710586 -Node: Labels Program710720 -Ref: Labels Program-Footnote-1714091 -Node: Word Sorting714175 -Node: History Sorting718059 -Node: Extract Program719898 -Ref: Extract Program-Footnote-1727381 -Node: Simple Sed727509 -Node: Igawk Program730571 -Ref: Igawk Program-Footnote-1745728 -Ref: Igawk Program-Footnote-2745929 -Node: Anagram Program746067 -Node: Signature Program749135 -Node: Debugger750235 -Node: Debugging751146 -Node: Debugging Concepts751559 -Node: Debugging Terms753415 -Node: Awk Debugging756038 -Node: Sample dgawk session756930 -Node: dgawk invocation757422 -Node: Finding The Bug758604 -Node: List of Debugger Commands765090 -Node: Breakpoint Control766401 -Node: Dgawk Execution Control770037 -Node: Viewing And Changing Data773388 -Node: Dgawk Stack776725 -Node: Dgawk Info778185 -Node: Miscellaneous Dgawk Commands782133 -Node: Readline Support787561 -Node: Dgawk Limitations788399 -Node: Language History790588 -Node: V7/SVR3.1792100 -Node: SVR4794421 -Node: POSIX795863 -Node: BTL796871 -Node: POSIX/GNU797605 -Node: Common Extensions802756 -Node: Ranges and Locales803863 -Ref: Ranges and Locales-Footnote-1808467 -Node: Contributors808688 -Node: Installation812950 -Node: Gawk Distribution813844 -Node: Getting814328 -Node: Extracting815154 -Node: Distribution contents816846 -Node: Unix Installation822068 -Node: Quick Installation822685 -Node: Additional Configuration Options824647 -Node: Configuration Philosophy826124 -Node: Non-Unix Installation828466 -Node: PC Installation828924 -Node: PC Binary Installation830223 -Node: PC Compiling832071 -Node: PC Testing835015 -Node: PC Using836191 -Node: Cygwin840376 -Node: MSYS841376 -Node: VMS Installation841890 -Node: VMS Compilation842493 -Ref: VMS Compilation-Footnote-1843500 -Node: VMS Installation Details843558 -Node: VMS Running845193 -Node: VMS Old Gawk846800 -Node: Bugs847274 -Node: Other Versions851126 -Node: Notes856407 -Node: Compatibility Mode857099 -Node: Additions857882 -Node: Accessing The Source858694 -Node: Adding Code860119 -Node: New Ports866086 -Node: Dynamic Extensions870199 -Node: Internals871575 -Node: Plugin License880094 -Node: Sample Library880728 -Node: Internal File Description881414 -Node: Internal File Ops885129 -Ref: Internal File Ops-Footnote-1889853 -Node: Using Internal File Ops889993 -Node: Future Extensions892370 -Node: Basic Concepts894874 -Node: Basic High Level895631 -Ref: Basic High Level-Footnote-1899666 -Node: Basic Data Typing899851 -Node: Floating Point Issues904376 -Node: String Conversion Precision905459 -Ref: String Conversion Precision-Footnote-1907159 -Node: Unexpected Results907268 -Node: POSIX Floating Point Problems909094 -Ref: POSIX Floating Point Problems-Footnote-1912799 -Node: Glossary912837 -Node: Copying937813 -Node: GNU Free Documentation License975370 -Node: Index1000507 +Node: Foreword30346 +Node: Preface34691 +Ref: Preface-Footnote-137744 +Ref: Preface-Footnote-237850 +Node: History38082 +Node: Names40473 +Ref: Names-Footnote-141950 +Node: This Manual42022 +Ref: This Manual-Footnote-146960 +Node: Conventions47060 +Node: Manual History49194 +Ref: Manual History-Footnote-152464 +Ref: Manual History-Footnote-252505 +Node: How To Contribute52579 +Node: Acknowledgments53723 +Node: Getting Started58054 +Node: Running gawk60433 +Node: One-shot61619 +Node: Read Terminal62844 +Ref: Read Terminal-Footnote-164494 +Ref: Read Terminal-Footnote-264770 +Node: Long64941 +Node: Executable Scripts66317 +Ref: Executable Scripts-Footnote-168186 +Ref: Executable Scripts-Footnote-268288 +Node: Comments68739 +Node: Quoting71206 +Node: DOS Quoting75829 +Node: Sample Data Files76504 +Node: Very Simple79536 +Node: Two Rules84135 +Node: More Complex86282 +Ref: More Complex-Footnote-189212 +Node: Statements/Lines89297 +Ref: Statements/Lines-Footnote-193759 +Node: Other Features94024 +Node: When94952 +Node: Invoking Gawk97099 +Node: Command Line98484 +Node: Options99267 +Ref: Options-Footnote-1113412 +Node: Other Arguments113437 +Node: Naming Standard Input116095 +Node: Environment Variables117189 +Node: AWKPATH Variable117633 +Ref: AWKPATH Variable-Footnote-1120230 +Node: Other Environment Variables120490 +Node: Exit Status122830 +Node: Include Files123505 +Node: Obsolete126990 +Node: Undocumented127676 +Node: Regexp127917 +Node: Regexp Usage129306 +Node: Escape Sequences131332 +Node: Regexp Operators137095 +Ref: Regexp Operators-Footnote-1144292 +Ref: Regexp Operators-Footnote-2144439 +Node: Bracket Expressions144537 +Ref: table-char-classes146427 +Node: GNU Regexp Operators148950 +Node: Case-sensitivity152673 +Ref: Case-sensitivity-Footnote-1155641 +Ref: Case-sensitivity-Footnote-2155876 +Node: Leftmost Longest155984 +Node: Computed Regexps157185 +Node: Reading Files160595 +Node: Records162536 +Ref: Records-Footnote-1171210 +Node: Fields171247 +Ref: Fields-Footnote-1174280 +Node: Nonconstant Fields174366 +Node: Changing Fields176568 +Node: Field Separators182549 +Node: Default Field Splitting185178 +Node: Regexp Field Splitting186295 +Node: Single Character Fields189637 +Node: Command Line Field Separator190696 +Node: Field Splitting Summary194137 +Ref: Field Splitting Summary-Footnote-1197329 +Node: Constant Size197430 +Node: Splitting By Content202014 +Ref: Splitting By Content-Footnote-1205740 +Node: Multiple Line205780 +Ref: Multiple Line-Footnote-1211627 +Node: Getline211806 +Node: Plain Getline214034 +Node: Getline/Variable216123 +Node: Getline/File217264 +Node: Getline/Variable/File218586 +Ref: Getline/Variable/File-Footnote-1220185 +Node: Getline/Pipe220272 +Node: Getline/Variable/Pipe222832 +Node: Getline/Coprocess223939 +Node: Getline/Variable/Coprocess225182 +Node: Getline Notes225896 +Node: Getline Summary227838 +Ref: table-getline-variants228181 +Node: Command line directories229037 +Node: Printing229662 +Node: Print231293 +Node: Print Examples232630 +Node: Output Separators235414 +Node: OFMT237174 +Node: Printf238532 +Node: Basic Printf239438 +Node: Control Letters240977 +Node: Format Modifiers244789 +Node: Printf Examples250798 +Node: Redirection253513 +Node: Special Files260497 +Node: Special FD261030 +Ref: Special FD-Footnote-1264655 +Node: Special Network264729 +Node: Special Caveats265579 +Node: Close Files And Pipes266375 +Ref: Close Files And Pipes-Footnote-1273398 +Ref: Close Files And Pipes-Footnote-2273546 +Node: Expressions273696 +Node: Values274828 +Node: Constants275504 +Node: Scalar Constants276184 +Ref: Scalar Constants-Footnote-1277043 +Node: Nondecimal-numbers277225 +Node: Regexp Constants280284 +Node: Using Constant Regexps280759 +Node: Variables283814 +Node: Using Variables284469 +Node: Assignment Options286193 +Node: Conversion288065 +Ref: table-locale-affects293441 +Ref: Conversion-Footnote-1294065 +Node: All Operators294174 +Node: Arithmetic Ops294804 +Node: Concatenation297309 +Ref: Concatenation-Footnote-1300102 +Node: Assignment Ops300222 +Ref: table-assign-ops305210 +Node: Increment Ops306618 +Node: Truth Values and Conditions310088 +Node: Truth Values311171 +Node: Typing and Comparison312220 +Node: Variable Typing313009 +Ref: Variable Typing-Footnote-1316906 +Node: Comparison Operators317028 +Ref: table-relational-ops317438 +Node: POSIX String Comparison320987 +Ref: POSIX String Comparison-Footnote-1321943 +Node: Boolean Ops322081 +Ref: Boolean Ops-Footnote-1326159 +Node: Conditional Exp326250 +Node: Function Calls327982 +Node: Precedence331576 +Node: Locales335245 +Node: Patterns and Actions336334 +Node: Pattern Overview337388 +Node: Regexp Patterns339057 +Node: Expression Patterns339600 +Node: Ranges343285 +Node: BEGIN/END346251 +Node: Using BEGIN/END347013 +Ref: Using BEGIN/END-Footnote-1349744 +Node: I/O And BEGIN/END349850 +Node: BEGINFILE/ENDFILE352132 +Node: Empty355025 +Node: Using Shell Variables355341 +Node: Action Overview357626 +Node: Statements359983 +Node: If Statement361837 +Node: While Statement363336 +Node: Do Statement365380 +Node: For Statement366536 +Node: Switch Statement369688 +Node: Break Statement371785 +Node: Continue Statement373775 +Node: Next Statement375568 +Node: Nextfile Statement377958 +Node: Exit Statement380503 +Node: Built-in Variables382919 +Node: User-modified384014 +Ref: User-modified-Footnote-1392040 +Node: Auto-set392102 +Ref: Auto-set-Footnote-1401393 +Node: ARGC and ARGV401598 +Node: Arrays405449 +Node: Array Basics406954 +Node: Array Intro407780 +Node: Reference to Elements412098 +Node: Assigning Elements414368 +Node: Array Example414859 +Node: Scanning an Array416591 +Node: Controlling Scanning418905 +Ref: Controlling Scanning-Footnote-1423838 +Node: Delete424154 +Ref: Delete-Footnote-1426589 +Node: Numeric Array Subscripts426646 +Node: Uninitialized Subscripts428829 +Node: Multi-dimensional430457 +Node: Multi-scanning433551 +Node: Arrays of Arrays435142 +Node: Functions439787 +Node: Built-in440609 +Node: Calling Built-in441687 +Node: Numeric Functions443675 +Ref: Numeric Functions-Footnote-1447440 +Ref: Numeric Functions-Footnote-2447797 +Ref: Numeric Functions-Footnote-3447845 +Node: String Functions448114 +Ref: String Functions-Footnote-1471611 +Ref: String Functions-Footnote-2471740 +Ref: String Functions-Footnote-3471988 +Node: Gory Details472075 +Ref: table-sub-escapes473754 +Ref: table-sub-posix-92475108 +Ref: table-sub-proposed476451 +Ref: table-posix-sub477801 +Ref: table-gensub-escapes479347 +Ref: Gory Details-Footnote-1480554 +Ref: Gory Details-Footnote-2480605 +Node: I/O Functions480756 +Ref: I/O Functions-Footnote-1487411 +Node: Time Functions487558 +Ref: Time Functions-Footnote-1498450 +Ref: Time Functions-Footnote-2498518 +Ref: Time Functions-Footnote-3498676 +Ref: Time Functions-Footnote-4498787 +Ref: Time Functions-Footnote-5498899 +Ref: Time Functions-Footnote-6499126 +Node: Bitwise Functions499392 +Ref: table-bitwise-ops499950 +Ref: Bitwise Functions-Footnote-1504110 +Node: Type Functions504294 +Node: I18N Functions504764 +Node: User-defined506391 +Node: Definition Syntax507195 +Ref: Definition Syntax-Footnote-1512105 +Node: Function Example512174 +Node: Function Caveats514768 +Node: Calling A Function515189 +Node: Variable Scope516304 +Node: Pass By Value/Reference518279 +Node: Return Statement521719 +Node: Dynamic Typing524700 +Node: Indirect Calls525435 +Node: Internationalization535120 +Node: I18N and L10N536546 +Node: Explaining gettext537232 +Ref: Explaining gettext-Footnote-1542298 +Ref: Explaining gettext-Footnote-2542482 +Node: Programmer i18n542647 +Node: Translator i18n546847 +Node: String Extraction547640 +Ref: String Extraction-Footnote-1548601 +Node: Printf Ordering548687 +Ref: Printf Ordering-Footnote-1551471 +Node: I18N Portability551535 +Ref: I18N Portability-Footnote-1553984 +Node: I18N Example554047 +Ref: I18N Example-Footnote-1556682 +Node: Gawk I18N556754 +Node: Advanced Features557371 +Node: Nondecimal Data558884 +Node: Array Sorting560467 +Node: Controlling Array Traversal561164 +Node: Array Sorting Functions569401 +Ref: Array Sorting Functions-Footnote-1573075 +Ref: Array Sorting Functions-Footnote-2573168 +Node: Two-way I/O573362 +Ref: Two-way I/O-Footnote-1578794 +Node: TCP/IP Networking578864 +Node: Profiling581708 +Node: Library Functions589162 +Ref: Library Functions-Footnote-1592169 +Node: Library Names592340 +Ref: Library Names-Footnote-1595811 +Ref: Library Names-Footnote-2596031 +Node: General Functions596117 +Node: Strtonum Function597070 +Node: Assert Function600000 +Node: Round Function603326 +Node: Cliff Random Function604869 +Node: Ordinal Functions605885 +Ref: Ordinal Functions-Footnote-1608955 +Ref: Ordinal Functions-Footnote-2609207 +Node: Join Function609416 +Ref: Join Function-Footnote-1611187 +Node: Gettimeofday Function611387 +Node: Data File Management615102 +Node: Filetrans Function615734 +Node: Rewind Function619873 +Node: File Checking621260 +Node: Empty Files622354 +Node: Ignoring Assigns624584 +Node: Getopt Function626137 +Ref: Getopt Function-Footnote-1637441 +Node: Passwd Functions637644 +Ref: Passwd Functions-Footnote-1646619 +Node: Group Functions646707 +Node: Walking Arrays654791 +Node: Sample Programs656360 +Node: Running Examples657025 +Node: Clones657753 +Node: Cut Program658977 +Node: Egrep Program668822 +Ref: Egrep Program-Footnote-1676595 +Node: Id Program676705 +Node: Split Program680321 +Ref: Split Program-Footnote-1683840 +Node: Tee Program683968 +Node: Uniq Program686771 +Node: Wc Program694200 +Ref: Wc Program-Footnote-1698466 +Ref: Wc Program-Footnote-2698666 +Node: Miscellaneous Programs698758 +Node: Dupword Program699946 +Node: Alarm Program701977 +Node: Translate Program706726 +Ref: Translate Program-Footnote-1711113 +Ref: Translate Program-Footnote-2711341 +Node: Labels Program711475 +Ref: Labels Program-Footnote-1714846 +Node: Word Sorting714930 +Node: History Sorting718814 +Node: Extract Program720653 +Ref: Extract Program-Footnote-1728136 +Node: Simple Sed728264 +Node: Igawk Program731326 +Ref: Igawk Program-Footnote-1746483 +Ref: Igawk Program-Footnote-2746684 +Node: Anagram Program746822 +Node: Signature Program749890 +Node: Debugger750990 +Node: Debugging751942 +Node: Debugging Concepts752375 +Node: Debugging Terms754231 +Node: Awk Debugging756828 +Node: Sample Debugging Session757720 +Node: Debugger Invocation758240 +Node: Finding The Bug759569 +Node: List of Debugger Commands766057 +Node: Breakpoint Control767391 +Node: Debugger Execution Control771055 +Node: Viewing And Changing Data774415 +Node: Execution Stack777771 +Node: Debugger Info779238 +Node: Miscellaneous Debugger Commands783219 +Node: Readline Support788664 +Node: Limitations789495 +Node: Language History791747 +Node: V7/SVR3.1793259 +Node: SVR4795580 +Node: POSIX797022 +Node: BTL798030 +Node: POSIX/GNU798764 +Node: Common Extensions803915 +Node: Ranges and Locales805022 +Ref: Ranges and Locales-Footnote-1809626 +Node: Contributors809847 +Node: Installation814108 +Node: Gawk Distribution815002 +Node: Getting815486 +Node: Extracting816312 +Node: Distribution contents818004 +Node: Unix Installation823226 +Node: Quick Installation823843 +Node: Additional Configuration Options825805 +Node: Configuration Philosophy827282 +Node: Non-Unix Installation829624 +Node: PC Installation830082 +Node: PC Binary Installation831381 +Node: PC Compiling833229 +Node: PC Testing836173 +Node: PC Using837349 +Node: Cygwin841534 +Node: MSYS842534 +Node: VMS Installation843048 +Node: VMS Compilation843651 +Ref: VMS Compilation-Footnote-1844658 +Node: VMS Installation Details844716 +Node: VMS Running846351 +Node: VMS Old Gawk847958 +Node: Bugs848432 +Node: Other Versions852284 +Node: Notes857599 +Node: Compatibility Mode858291 +Node: Additions859074 +Node: Accessing The Source859886 +Node: Adding Code861311 +Node: New Ports867278 +Node: Dynamic Extensions871391 +Node: Internals872831 +Node: Plugin License881350 +Node: Loading Extensions881988 +Node: Sample Library883798 +Node: Internal File Description884488 +Node: Internal File Ops888203 +Ref: Internal File Ops-Footnote-1892927 +Node: Using Internal File Ops893067 +Node: Future Extensions895444 +Node: Basic Concepts897948 +Node: Basic High Level898705 +Ref: Basic High Level-Footnote-1902740 +Node: Basic Data Typing902925 +Node: Floating Point Issues907450 +Node: String Conversion Precision908533 +Ref: String Conversion Precision-Footnote-1910233 +Node: Unexpected Results910342 +Node: POSIX Floating Point Problems912168 +Ref: POSIX Floating Point Problems-Footnote-1915873 +Node: Glossary915911 +Node: Copying940887 +Node: GNU Free Documentation License978444 +Node: Index1003581  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index dfd620f6..13681850 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -290,7 +290,7 @@ particular records in a file and perform operations upon them. * Library Functions:: A Library of @command{awk} Functions. * Sample Programs:: Many @command{awk} programs with complete explanations. -* Debugger:: The @code{dgawk} debugger. +* Debugger:: The @code{gawk} debugger. * Language History:: The evolution of the @command{awk} language. * Installation:: Installing @command{gawk} under various @@ -614,23 +614,23 @@ particular records in a file and perform operations upon them. * 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:: Introduction to @command{gawk} Debugger. +* 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. +* Sample Debugging Session:: Sample Debugging Session. +* Debugger Invocation:: How to Start the Debugger. +* Finding The Bug:: Finding the Bug. +* List of Debugger Commands:: Main Commands. +* Breakpoint Control:: Control of Breakpoints. +* Debugger Execution Control:: Control of Execution. +* Viewing And Changing Data:: Viewing and Changing Data. +* Execution Stack:: Dealing with the Stack. +* Debugger Info:: Obtaining Information about the Program and + the Debugger State. +* Miscellaneous Debugger Commands:: Miscellaneous Commands. * Readline Support:: Readline Support. -* Dgawk Limitations:: Limitations and future plans. +* 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 @@ -686,6 +686,7 @@ particular records in a file and perform operations upon them. * Internals:: A brief look at some @command{gawk} internals. * Plugin License:: A note about licensing. +* Loading Extensions:: How to load dynamic extensions. * 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. @@ -1164,8 +1165,7 @@ 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{Debugger}, describes the @command{awk} debugger. @ref{Language History}, describes how the @command{awk} language has evolved since @@ -3101,6 +3101,19 @@ 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 -D@r{[}@var{file}@r{]} +@itemx --debug=@r{[}@var{file}@r{]} +@cindex @code{-D} option +@cindex @code{--debug} option +@cindex @command{awk} debugging, enabling +Enable debugging of @command{awk} programs +(@pxref{Debugging}). +By default, the debugger reads commands interactively from the terminal. +The optional @var{file} argument allows you to specify a file with a list +of commands for the debugger to execute non-interactively. +No space is allowed between the @option{-D} and @var{file}, if +@var{file} is supplied. + @item -e @var{program-text} @itemx --source @var{program-text} @cindex @code{-e} option @@ -3166,6 +3179,15 @@ for information about this option. Print a ``usage'' message summarizing the short and long style options that @command{gawk} accepts and then exit. +@item -l @var{lib} +@itemx --load @var{lib} +@cindex @code{-l} option +@cindex @code{--load} option +@cindex loading, library +Load a shared library @var{lib}. This searches for the library using the @env{AWKPATH} +environment variable. The suffix @samp{.so} in the library name is optional. +The library initialization routine should be named @code{dlload()}. + @item -L @r{[}value@r{]} @itemx --lint@r{[}=value@r{]} @cindex @code{-l} option @@ -3212,6 +3234,18 @@ Use with care. Force the use of the locale's decimal point character when parsing numeric input data (@pxref{Locales}). +@item -o@r{[}@var{file}@r{]} +@itemx --pretty-print@r{[}=@var{file}@r{]} +@cindex @code{-o} option +@cindex @code{--pretty-print} option +@cindex @command{awk} enabling +Enable pretty-printing of @command{awk} programs. +By default, output program is created in a file named @file{awkprof.out}. +The optional @var{file} argument allows you to specify a different +@value{FN} for the output. +No space is allowed between the @option{-o} and @var{file}, if +@var{file} is supplied. + @item -O @itemx --optimize @cindex @code{--optimize} option @@ -3224,7 +3258,7 @@ maintainer hopes to add more optimizations over time. @itemx --profile@r{[}=@var{file}@r{]} @cindex @code{-p} option @cindex @code{--profile} option -@cindex @command{awk} programs, profiling, enabling +@cindex @command{awk} profiling, enabling Enable profiling of @command{awk} programs (@pxref{Profiling}). By default, profiles are created in a file named @file{awkprof.out}. @@ -3233,10 +3267,8 @@ The optional @var{file} argument allows you to specify a different 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. +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 @@ -3300,14 +3332,6 @@ 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 @@ -3704,7 +3728,7 @@ into smaller, more manageable pieces, and also lets you reuse common @command{aw 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} +using the @samp{@@include} keyword in conjunction with the @env{AWKPATH} environment variable. Let's see an example. @@ -18954,40 +18978,32 @@ extensive examples. @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 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 + +You may produce execution traces of your @command{awk} programs. +This is done by passing the option @option{--profile} to @command{gawk}. +When @command{gawk} 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: +where @command{gawk} will write the profile: @example -pgawk --profile=myprog.prof -f myprog.awk data1 data2 +gawk --profile=myprog.prof -f myprog.awk data1 data2 @end example @noindent -In the above example, @command{pgawk} places the profile in +In the above example, @command{gawk} 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: +Here is a sample session showing a simple @command{awk} program, its input data, and the +results from running @command{gawk} with the @option{--profile} option. +First, the @command{awk} program: @example BEGIN @{ print "First BEGIN rule" @} @@ -19027,12 +19043,12 @@ 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} +Here is the @file{awkprof.out} that results from running the @command{gawk} +profiler 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 +@cindex @code{BEGIN} pattern +@cindex @code{END} pattern @example # gawk profile, created Sun Aug 13 00:00:15 2000 @@ -19124,15 +19140,15 @@ 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 +@cindex @code{@{@}} (braces) +@cindex braces (@code{@{@}}) @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 +@cindex @code{()} (parentheses) +@cindex parentheses @code{()} @item Parentheses are used only where needed, as indicated by the structure of the program and the precedence rules. @@ -19155,16 +19171,16 @@ Similarly, if the target of a redirection isn't a scalar, it gets parenthesized. @item -@command{pgawk} supplies leading comments in +@command{gawk} 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 +typed when you wrote it. This is because @command{gawk} creates the profiled version by ``pretty printing'' its internal representation of -the program. The advantage to this is that @command{pgawk} can produce +the program. The advantage to this is that @command{gawk} 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: @@ -19186,15 +19202,16 @@ come out as: which is correct, but possibly surprising. @cindex profiling @command{awk} programs, dynamically -@cindex @command{pgawk} program, dynamic profiling +@cindex @command{gawk} program, dynamic profiling Besides creating profiles when a program has completed, -@command{pgawk} can produce a profile while it is running. +@command{gawk} 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: +To use this feature, run @command{gawk} with the @option{--profile} +option in the background: @example -$ @kbd{pgawk -f myprog &} +$ @kbd{gawk --profile -f myprog &} [1] 13992 @end example @@ -19205,7 +19222,7 @@ $ @kbd{pgawk -f myprog &} @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}: +to @command{gawk}: @example $ @kbd{kill -USR1 13992} @@ -19213,8 +19230,8 @@ $ @kbd{kill -USR1 13992} @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. +@file{awkprof.out}, or to a different file if one specified with +the @option{--profile} option. Along with the regular profile, as shown earlier, the profile includes a trace of any active functions: @@ -19228,7 +19245,7 @@ includes a trace of any active functions: # -- main -- @end example -You may send @command{pgawk} the @code{USR1} signal as many times as you like. +You may send @command{gawk} 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. @@ -19236,7 +19253,7 @@ profile file. @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. +@command{gawk} produces the profile and the function call trace and then exits. @cindex @code{INT} signal (MS-Windows) @cindex @code{SIGINT} signal (MS-Windows) @@ -19244,21 +19261,20 @@ If you use the @code{HUP} signal instead of the @code{USR1} signal, @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 +When @command{gawk} 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 +the case of the @code{INT} signal, @command{gawk} 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. +Finally, @command{gawk} also accepts another option @option{--pretty-print}. 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 @@ -25140,41 +25156,41 @@ BEGIN { @c FIXME: Add more indexing. @node Debugger -@chapter @command{dgawk}: The @command{awk} Debugger -@cindex @command{dgawk} +@chapter Debugging @command{awk} Programs +@cindex debugging @command{awk} programs 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 +The @command{gawk} 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. +how to use @command{gawk} for debugging your program 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. +* Debugging:: Introduction to @command{gawk} debugger. +* Sample Debugging Session:: Sample debugging session. +* List of Debugger Commands:: Main debugger commands. +* Readline Support:: Readline support. +* Limitations:: Limitations and future plans. @end menu @node Debugging -@section Introduction to @command{dgawk} +@section Introduction to @command{gawk} Debugger This @value{SECTION} introduces debugging in general and begins the discussion of debugging in @command{gawk}. @menu -* Debugging Concepts:: Debugging In General. +* Debugging Concepts:: Debugging in General. * Debugging Terms:: Additional Debugging Concepts. * Awk Debugging:: Awk Debugging. @end menu @node Debugging Concepts -@subsection Debugging In General +@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} @@ -25220,8 +25236,7 @@ functional program that you or someone else wrote). @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}. +important concepts that apply to just about all debuggers. The following list defines terms used throughout the rest of this @value{CHAPTER}. @@ -25240,7 +25255,7 @@ 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 +@command{gawk} also follows this model, and 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 @@ -25285,48 +25300,48 @@ 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 +@node Sample Debugging Session +@section Sample Debugging Session -In order to illustrate the use of @command{dgawk}, let's look at a sample +In order to illustrate the use of @command{gawk} as a debugger, 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. +* Debugger Invocation:: How to Start the Debugger. +* Finding The Bug:: Finding the Bug. @end menu -@node dgawk invocation -@subsection @command{dgawk} Invocation +@node Debugger Invocation +@subsection How to Start the Debugger -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: +Starting the debugger is almost exactly like running @command{awk}, except you have to +pass an additional option @option{--debug} or the corresponding short option @option{-D}. +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{gawk} is not designed +to debug command-line programs, only programs contained in files.) In our case, +we invoke the debugger like this: @example -$ @kbd{dgawk -f getopt.awk -f join.awk -f uniq.awk inputfile} +$ @kbd{gawk -D -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 +With @command{gawk} debugger, 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 +@command{gawk} would ordinarily do, the debugger merely loads all the program source files, compiles them internally, and then gives us a prompt: @example -dgawk> +gawk> @end example @noindent @@ -25334,7 +25349,7 @@ 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 +@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 @@ -25370,7 +25385,7 @@ a breakpoint in @file{uniq.awk} is at the beginning of the function the breakpoint, use the @code{b} (breakpoint) command: @example -dgawk> @kbd{b are_equal} +gawk> @kbd{b are_equal} @print{} Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 64 @end example @@ -25379,22 +25394,22 @@ Now type @samp{r} or @samp{run} and the program runs until it hits the breakpoint for the first time: @example -dgawk> @kbd{r} +gawk> @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> +gawk> @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 +(short for ``backtrace''), and the debugger responds with a listing of the current stack frames: @example -dgawk> @kbd{bt} +gawk> @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 @@ -25409,11 +25424,11 @@ 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} +@code{n}, a parameter to @code{are_equal()}. Actually, the debugger gives us: @example -dgawk> @kbd{p n} +gawk> @kbd{p n} @print{} n = untyped variable @end example @@ -25424,7 +25439,7 @@ function was called without arguments (@pxref{Function Calls}). A more useful variable to display might be the current record: @example -dgawk> @kbd{p $0} +gawk> @kbd{p $0} @print{} $0 = string ("gawk is a wonderful program!") @end example @@ -25433,7 +25448,7 @@ 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} +gawk> @kbd{p NR} @print{} NR = number (2) @end example @@ -25452,7 +25467,7 @@ NR == 1 @{ OK, let's just check that that rule worked correctly: @example -dgawk> @kbd{p last} +gawk> @kbd{p last} @print{} last = string ("awk is a wonderful program!") @end example @@ -25463,7 +25478,7 @@ be inside this function. To investigate further, we must begin @samp{n} (for ``next''): @example -dgawk> @kbd{n} +gawk> @kbd{n} @print{} 67 if (fcount > 0) @{ @end example @@ -25483,9 +25498,9 @@ Continuing to step, we now get to the splitting of the current and last records: @example -dgawk> @kbd{n} +gawk> @kbd{n} @print{} 68 n = split(last, alast) -dgawk> @kbd{n} +gawk> @kbd{n} @print{} 69 m = split($0, aline) @end example @@ -25493,7 +25508,7 @@ 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} +gawk> @kbd{p n m alast aline} @print{} n = number (5) @print{} m = number (5) @print{} alast = array, 5 elements @@ -25512,7 +25527,7 @@ inside the array? The first choice would be to use subscripts: @example -dgawk> @kbd{p alast[0]} +gawk> @kbd{p alast[0]} @print{} "0" not in array `alast' @end example @@ -25520,16 +25535,16 @@ dgawk> @kbd{p alast[0]} Oops! @example -dgawk> @kbd{p alast[1]} +gawk> @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 +@command{gawk} provides a shortcut (reminiscent of another language not to be mentioned): @example -dgawk> @kbd{p @@alast} +gawk> @kbd{p @@alast} @print{} alast["1"] = string ("awk") @print{} alast["2"] = string ("is") @print{} alast["3"] = string ("a") @@ -25541,9 +25556,9 @@ It looks like we got this far OK. Let's take another step or two: @example -dgawk> @kbd{n} +gawk> @kbd{n} @print{} 70 clast = join(alast, fcount, n) -dgawk> @kbd{n} +gawk> @kbd{n} @print{} 71 cline = join(aline, fcount, m) @end example @@ -25553,7 +25568,7 @@ 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} +gawk> @kbd{p cline clast} @print{} cline = string ("gawk is a wonderful program!") @print{} clast = string ("awk is a wonderful program!") @end example @@ -25562,10 +25577,10 @@ 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}: +We get out of the debugger: @example -dgawk> @kbd{q} +gawk> @kbd{q} @print{} The program is running. Exit anyway (y/n)? @kbd{y} @end example @@ -25581,9 +25596,9 @@ cline = join(aline, fcount+1, m) and problem solved! @node List of Debugger Commands -@section Main @command{dgawk} Commands +@section Main Debugger Commands -The @command{dgawk} command set can be divided into the +The @command{gawk} debugger command set can be divided into the following categories: @itemize @bullet{} @@ -25610,24 +25625,24 @@ 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 @command{dgawk} command name may also be truncated if that partial -name is unambiguous. @command{dgawk} has the built-in capability to +A debugger command name may also be truncated if that partial +name is unambiguous. The debugger 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. +* Breakpoint Control:: Control of Breakpoints. +* Debugger Execution Control:: Control of Execution. +* Viewing And Changing Data:: Viewing and Changing Data. +* Execution Stack:: Dealing with the Stack. +* Debugger Info:: Obtaining Information about the Program and + the Debugger State. +* Miscellaneous Debugger Commands:: Miscellaneous Commands. @end menu @node Breakpoint Control -@subsection Control Of Breakpoints +@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 @@ -25662,10 +25677,10 @@ 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} +@command{awk} expression (enclosed in double quotes) that the debugger 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. +then the debugger stops execution and prompts for a command. Otherwise, +it continues executing the program. @cindex debugger commands, @code{clear} @cindex @code{clear} debugger command @@ -25691,10 +25706,10 @@ Delete breakpoint(s) set at entry to function @var{function}. @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 +condition is an @command{awk} expression that the debugger 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 +the debugger stops execution and prompts for a command. Otherwise, +the debugger 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. @@ -25750,7 +25765,7 @@ Set a temporary breakpoint (enabled for only one stop). The arguments are the same as for @code{break}. @end table -@node Dgawk Execution Control +@node Debugger Execution Control @subsection Control of Execution Now that your breakpoints are ready, you can start running the program @@ -25779,14 +25794,14 @@ in the list that resumes execution (e.g., @code{continue}) terminates the list For example: @example -dgawk> @kbd{commands} +gawk> @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> +gawk> @end example @cindex debugger commands, @code{c} (@code{continue}) @@ -25836,7 +25851,7 @@ and the caller of that frame becomes the innermost frame. @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} +Start/restart execution of the program. When restarting, the debugger retains the current breakpoints, watchpoints, command history, automatic display variables, and debugger options. @@ -25859,7 +25874,7 @@ stopping, unless it encounters a breakpoint or watchpoint. @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}.) +see the output shown under @code{dump} in @ref{Miscellaneous Debugger Commands}.) @cindex debugger commands, @code{u} (@code{until}) @cindex debugger commands, @code{until} @@ -25887,7 +25902,7 @@ 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} +gawk> @kbd{display x} @print{} 10: x = 1 @end example @@ -25924,7 +25939,7 @@ Print the value of a @command{gawk} variable or field. Fields must be referenced by constants: @example -dgawk> @kbd{print $3} +gawk> @kbd{print $3} @end example @noindent @@ -25966,16 +25981,16 @@ You can also set special @command{awk} variables, such as @code{FS}, @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 debugger 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} +@command{awk} expression (enclosed in double quotes) that the debugger 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. +then the debugger stops execution and prompts for a command. Otherwise, +@command{gawk} continues executing the program. @cindex debugger commands, @code{undisplay} @cindex @code{undisplay} debugger command @@ -25991,8 +26006,8 @@ watch list. @end table -@node Dgawk Stack -@subsection Dealing With The Stack +@node Execution 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 @@ -26036,12 +26051,12 @@ 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 +@node Debugger 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 +debugging environment itself. The @command{gawk} debugger 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: @@ -26079,7 +26094,7 @@ 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 +When the debugger 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. @@ -26115,7 +26130,7 @@ 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 maximum number of lines to keep in the history file @file{./.gawk_history}. The default is 100. @item listsize @@ -26127,14 +26142,14 @@ to standard output. An empty string (@code{""}) resets output to standard output. @item prompt -The debugger prompt. The default is @samp{@w{dgawk> }}. +The debugger prompt. The default is @samp{@w{gawk> }}. @item save_history @r{[}on @r{|} off@r{]} -Save command history to file @file{./.dgawk_history}. +Save command history to file @file{./.gawk_history}. The default is @code{on}. @item save_options @r{[}on @r{|} off@r{]} -Save current options to file @file{./.dgawkrc} upon exit. +Save current options to file @file{./.gawkrc} upon exit. The default is @code{on}. Options are read back in to the next session upon startup. @@ -26154,16 +26169,16 @@ 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 +@code{source} commands; however, the @command{gawk} debugger 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 +the @option{-D @var{file}} or @option{--debug=@var{file}} command-line options to execute commands from a file non-interactively (@pxref{Options}. @end table -@node Miscellaneous Dgawk Commands +@node Miscellaneous Debugger Commands @subsection Miscellaneous Commands There are a few more commands which do not fit into the @@ -26181,7 +26196,7 @@ partial dump of Davide Brini's obfuscated code (@pxref{Signature Program}) demonstrates: @smallexample -dgawk> @kbd{dump} +gawk> @kbd{dump} @print{} # BEGIN @print{} @print{} [ 2:0x89faef4] Op_rule : [in_rule = BEGIN] [source_file = brini.awk] @@ -26230,7 +26245,7 @@ dgawk> @kbd{dump} @print{} [ :0x89fa3b0] Op_after_beginfile : @print{} [ :0x89fa388] Op_no_op : @print{} [ :0x89fa3c4] Op_after_endfile : -dgawk> +gawk> @end smallexample @cindex debugger commands, @code{h} (@code{help}) @@ -26239,7 +26254,7 @@ dgawk> @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 +Print a list of all of the @command{gawk} debugger commands with a short summary of their usage. @samp{help @var{command}} prints the information about the command @var{command}. @@ -26286,7 +26301,7 @@ function @var{function}. This command may change the current source file. 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 +running a program, the debugger warns you if you accidentally type @samp{q} or @samp{quit}, to make sure you really want to quit. @cindex debugger commands, @code{trace} @@ -26305,7 +26320,7 @@ fairly self-explanatory, and using @code{stepi} and @code{nexti} while @node Readline Support @section Readline Support -If @command{dgawk} is compiled with the @code{readline} library, you +If @command{gawk} 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: @@ -26337,28 +26352,28 @@ and @end table -@node Dgawk Limitations +@node Limitations @section Limitations and Future Plans -We hope you find @command{dgawk} useful and enjoyable to work with, +We hope you find the @command{gawk} debugger 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 +At this point, the debugger 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}, +If you perused the dump of opcodes in @ref{Miscellaneous Debugger 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. +most @command{gawk} code. Unfortunately, as of now, the @command{gawk} +debugger 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 @@ -26373,14 +26388,14 @@ 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}. +The @command{gawk} debugger is designed to be used by running a program (with all its +parameters) on the command line, as described in @ref{Debugger 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. +The @command{gawk} debugger only accepts source supplied with the @option{-f} option. @end itemize Look forward to a future release when these and other missing features may @@ -27289,7 +27304,7 @@ environments. @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. +providing the @command{gawk} debugger for @command{awk} programs. @item @cindex Yawitz, Efraim @@ -28559,7 +28574,7 @@ since approximately 2003. @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} +It is different from @command{gawk} with the @option{--profile} option. (@pxref{Profiling}), in that it uses CPU-based profiling, not line-count profiling. You may find it at either @@ -29064,6 +29079,7 @@ When @option{--sandbox} is specified, extensions are disabled @menu * Internals:: A brief look at some @command{gawk} internals. * Plugin License:: A note about licensing. +* Loading Extensions:: How to load dynamic extensions. * Sample Library:: A example of new functions. @end menu @@ -29374,6 +29390,56 @@ the symbol exists in the global scope. Something like this is enough: int plugin_is_GPL_compatible; @end example +@node Loading Extensions +@appendixsubsec Loading a Dynamic Extension +@cindex loading extension +@cindex @command{gawk}, functions, loading +There are two ways to load a dynamically linked library. The first is to use the +builtin @code{extension()}: + +@example +extension(libname, init_func) +@end example + +where @file{libname} is the library to load, and @samp{init_func} is the +name of the initialization or bootstrap routine to run once loaded. + +The second method for dynamic loading of a library is to use the +command line option @option{-l}: + +@example +$ @kbd{gawk -l libname -f myprog} +@end example + +This will work only if the initialization routine is named @code{dlload()}. + +If you use @code{extension()}, the library will be loaded +at run time. This means that the functions are available only to the rest of +your script. If you use the command line option @option{-l} instead, +the library will be loaded before @command{gawk} starts compiling the +actual program. The net effect is that you can use those functions +anywhere in the program. + +@command{gawk} has a list of directories where it searches for libraries. +By default, the list includes directories that depend upon how gawk was built +and installed (@pxref{AWKPATH Variable}). If you want @command{gawk} +to look for libraries in your private directory, you have to tell it. +The way to do it is to set the @env{AWKPATH} environment variable +(@pxref{AWKPATH Variable}). +@command{gawk} supplies the default suffix @samp{.so} if it is not +present in the name of the library. +If the name of your library is @file{mylib.so}, you can simply type + +@example +$ @kbd{gawk -l mylib -f myprog} +@end example + +and @command{gawk} will do everything necessary to load in your library, +and then call your @code{dlload()} routine. + +You can always specify the library using an absolute pathname, in which +case @command{gawk} will not use @env{AWKPATH} to search for it. + @node Sample Library @appendixsubsec Example: Directory and File Operation Built-ins @c STARTOFRANGE chdirg diff --git a/eval.c b/eval.c index 2a29eb9f..78598b21 100644 --- a/eval.c +++ b/eval.c @@ -29,34 +29,17 @@ 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; +NODE **fcall_list = NULL; long fcall_count = 0; int currule = 0; IOBUF *curfile = NULL; /* current data file */ int exiting = FALSE; -#ifdef DEBUGGING +int (*interpret)(INSTRUCTION *); + 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 */ +extern void frame_popped(); #if __GNUC__ < 2 NODE *_t; /* used as a temporary in macros */ @@ -66,12 +49,7 @@ int ORSlen; int OFMTidx; int CONVFMTidx; -/* Profiling stuff */ -#ifdef PROFILING -#define INCREMENT(n) n++ -#else -#define INCREMENT(n) /* nothing */ -#endif +static NODE *node_Boolean[2]; /* This rather ugly macro is for VMS C */ #ifdef C @@ -649,8 +627,8 @@ cmp_nodes(NODE *t1, NODE *t2) return ret; } +/* push_frame --- push a frame NODE onto stack */ -#if defined(PROFILING) || defined(DEBUGGING) static void push_frame(NODE *f) { @@ -672,27 +650,20 @@ push_frame(NODE *f) fcall_list[1] = f; } + +/* pop_frame --- pop off a frame NODE*/ + 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 + if (do_debug) + frame_popped(); } -#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 */ @@ -722,7 +693,6 @@ dump_fcall_stack(FILE *fp) fprintf(fp, "\t# %3ld. -- main --\n", k); } -#endif /* PROFILING */ /* set_IGNORECASE --- update IGNORECASE as appropriate */ @@ -1098,26 +1068,6 @@ NODE **args_array = NULL; STACK_ITEM * grow_stack() { - if (stack_ptr == NULL) { - long newval; - - if ((newval = getenv_long("GAWK_STACKSIZE")) > 0) - STACK_SIZE = newval; - - 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->num_tail_calls = 0; - 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; @@ -1260,10 +1210,9 @@ setup_frame(INSTRUCTION *pc) fp = f->fparms; arg_count = (pc + 1)->expr_count; -#ifndef DEBUGGING /* tail recursion optimization */ - tail_optimize = (do_optimize > 1 && (pc + 1)->tail_call); -#endif + tail_optimize = ((pc + 1)->tail_call && do_optimize > 1 + && ! do_debug && ! do_profile); if (tail_optimize) { /* free local vars of calling frame */ @@ -1367,7 +1316,8 @@ setup_frame(INSTRUCTION *pc) frame_ptr->vname = source; /* save current source */ - push_frame(frame_ptr); + if (do_profile || do_debug) + push_frame(frame_ptr); /* save current frame in stack */ PUSH(frame_ptr); @@ -1416,7 +1366,8 @@ restore_frame(NODE *fp) * resumes from ri->nexti. */ freenode(frame_ptr); - pop_frame(); + if (do_profile || do_debug) + pop_frame(); /* restore frame */ frame_ptr = fp; @@ -1519,6 +1470,12 @@ unwind_stack(long n) static inline int eval_condition(NODE *t) { + if (t == node_Boolean[FALSE]) + return FALSE; + + if (t == node_Boolean[TRUE]) + return TRUE; + if ((t->flags & MAYBE_NUM) != 0) force_number(t); @@ -1706,1185 +1663,47 @@ pop_exec_state(int *rule, char **src, long *sz) 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) Stack operations: - * Use REPLACE[_XX] if last stack operation was TOP[_XX], - * PUSH[_XX] if last operation was POP[_XX] instead. - * 3) UPREF and DREF -- see awk.h - */ - - -int -r_interpret(INSTRUCTION *code) +void +init_interpret() { - 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; - Regexp *rp; - 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_SCALAR() : 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: - 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; - if (! do_traditional && (m->flags & INTLSTR) != 0) { - char *orig, *trans, save; - - save = m->stptr[m->stlen]; - m->stptr[m->stlen] = '\0'; - orig = m->stptr; - trans = dgettext(TEXTDOMAIN, orig); - m->stptr[m->stlen] = save; - m = make_string(trans, strlen(trans)); - } else - UPREF(m); - PUSH(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) { - 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 = dupnode(Nnull_string); - if (do_lint) - lintwarn(isparam ? - _("reference to uninitialized argument `%s'") : - _("reference to uninitialized variable `%s'"), - save_symbol->vname); - m = dupnode(Nnull_string); - PUSH(m); - 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(); - - if (do_lint && in_array(t1, t2) == NULL) { - t2 = force_string(t2); - lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"), - array_vname(t1), (int) t2->stlen, t2->stptr); - if (t2->stlen == 0) - lintwarn(_("subscript of array `%s' is null string"), array_vname(t1)); - } - - r = *assoc_lookup(t1, t2); - 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) { - r = make_array(); - r->parent_array = t1; - *assoc_lookup(t1, t2) = r; - t2 = force_string(t2); - r->vname = estrdup(t2->stptr, t2->stlen); /* the subscript in parent array */ - } else if (r->type != Node_var_array) { - t2 = force_string(t2); - 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(); - if (do_lint && in_array(t1, t2) == NULL) { - t2 = force_string(t2); - if (pc->do_reference) - lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"), - array_vname(t1), (int) t2->stlen, t2->stptr); - if (t2->stlen == 0) - lintwarn(_("subscript of array `%s' is null string"), array_vname(t1)); - } + long newval; - lhs = assoc_lookup(t1, t2); - if ((*lhs)->type == Node_var_array) { - t2 = force_string(t2); - 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); - 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: - case Op_predecrement: - x2 = pc->opcode == Op_preincrement ? 1.0 : -1.0; - lhs = TOP_ADDRESS(); - t1 = *lhs; - x1 = force_number(t1); - if (t1->valref == 1 && t1->flags == (MALLOC|NUMCUR|NUMBER)) { - /* optimization */ - t1->numbr = x1 + x2; - } else { - unref(t1); - t1 = *lhs = make_number(x1 + x2); - } - UPREF(t1); - REPLACE(t1); - break; - - case Op_postincrement: - case Op_postdecrement: - x2 = pc->opcode == Op_postincrement ? 1.0 : -1.0; - lhs = TOP_ADDRESS(); - t1 = *lhs; - x1 = force_number(t1); - if (t1->valref == 1 && t1->flags == (MALLOC|NUMCUR|NUMBER)) { - /* optimization */ - t1->numbr = x1 + x2; - } else { - unref(t1); - *lhs = make_number(x1 + x2); - } - r = make_number(x1); - REPLACE(r); - break; - - 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); - if ((*lhs)->type == Node_var_array) { - t2 = force_string(t2); - 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); - r = pc->initval; /* constant initializer */ - if (r == NULL) - *lhs = POP_SCALAR(); - else { - UPREF(r); - *lhs = r; - } - 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 != *lhs) { - unref(*lhs); - *lhs = dupnode(t1); - } - - if (t1 != t2 && t1->valref == 1) { - 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'; - t1->flags &= ~(NUMCUR|NUMBER|NUMINT); - } 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); - } - DEREF(t2); - break; - - case Op_assign: - lhs = POP_ADDRESS(); - r = TOP_SCALAR(); - unref(*lhs); - *lhs = r; - UPREF(r); - REPLACE(r); - break; + if ((newval = getenv_long("GAWK_STACKSIZE")) > 0) + STACK_SIZE = newval; - /* 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 */ - t2 = 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 */ - - t2 = POP_SCALAR(); - 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_empty(array)) - 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); - -arrayfor: - getnode(r); - r->type = Node_arrayfor; - r->for_list = list; - r->for_list_size = num_elems; /* # of elements in list */ - r->cur_idx = -1; /* current index */ - r->for_array = array; /* array */ - PUSH(r); - - if (num_elems == 0) - JUMPTO(pc->target_jmp); /* Op_arrayfor_final */ - } - break; - - case Op_arrayfor_incr: - r = TOP(); /* Node_arrayfor */ - if (++r->cur_idx == r->for_list_size) { - NODE *array; - array = r->for_array; /* actual array */ - if (do_lint && array->table_size != r->for_list_size) - lintwarn(_("for loop: array `%s' changed size from %ld to %ld during loop execution"), - array_vname(array), (long) r->for_list_size, (long) array->table_size); - JUMPTO(pc->target_jmp); /* Op_arrayfor_final */ - } - - t1 = r->for_list[r->cur_idx]; - lhs = get_lhs(pc->array_var, FALSE); - unref(*lhs); - *lhs = dupnode(t1); - 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); - PUSH(r); - break; - - case Op_ext_builtin: - { - int arg_count = pc->expr_count; - - PUSH_CODE(pc); - r = pc->builtin(arg_count); - (void) POP_CODE(); - while (arg_count-- > 0) { - t1 = POP(); - if (t1->type == Node_val) - DEREF(t1); - } - 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 */ - t1 = force_string(t1); - if (t1->stlen > 0) { - /* retrieve function definition node */ - f = pc->func_body; - if (f != NULL && STREQ(f->vname, t1->stptr)) { - /* 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 && f->type != Node_ext_func)) - fatal(_("function `%s' not defined"), pc->func_name); - pc->func_body = f; /* save for next call */ - } - - if (f->type == Node_ext_func) { - INSTRUCTION *bc; - char *fname = pc->func_name; - int arg_count = (pc + 1)->expr_count; - - bc = f->code_ptr; - assert(bc->opcode == Op_symbol); - pc->opcode = Op_ext_builtin; /* self modifying code */ - pc->builtin = bc->builtin; - pc->expr_count = arg_count; /* actual argument count */ - (pc + 1)->func_name = fname; /* name of the builtin */ - (pc + 1)->expr_count = bc->expr_count; /* defined max # of arguments */ - ni = pc; - JUMPTO(ni); - } - -func_call: - ni = setup_frame(pc); - - /* run the function instructions */ - JUMPTO(ni); /* Op_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: - 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); - } + emalloc(stack_bottom, STACK_ITEM *, STACK_SIZE * sizeof(STACK_ITEM), "grow_stack"); + stack_ptr = stack_bottom - 1; + stack_top = stack_bottom + STACK_SIZE - 1; - case Op_exec_count: - INCREMENT(pc->exec_count); - break; + /* initialize frame pointer */ + getnode(frame_ptr); + frame_ptr->type = Node_frame; + frame_ptr->stack = NULL; + frame_ptr->func_node = NULL; /* in main */ + frame_ptr->num_tail_calls = 0; + frame_ptr->vname = NULL; - 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; + /* initialize TRUE and FALSE nodes */ + node_Boolean[FALSE] = make_number(0); + node_Boolean[FALSE]->flags |= NUMINT; + node_Boolean[TRUE] = make_number(1.0); + node_Boolean[TRUE]->flags |= NUMINT; - default: - fatal(_("Sorry, don't know how to interpret `%s'"), opcode2str(pc->opcode)); - } + /* select the interpreter routine */ + if (do_debug) + interpret = debug_interpret; + else + interpret = r_interpret; +} - JUMPTO(pc->nexti); -/* } forever */ +/* interpreter routine when not debugging */ +#include "interpret.h" - /* not reached */ - return 0; +/* interpreter routine when deubugging with gawk --debug */ +#define r_interpret debug_interpret +#define DEBUGGING 1 +#include "interpret.h" +#undef DEBUGGING +#undef r_interpret -#undef mk_sub -#undef JUMPTO -} diff --git a/eval_d.c b/eval_d.c deleted file mode 100644 index 64a8e55a..00000000 --- a/eval_d.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 deleted file mode 100644 index c8afe666..00000000 --- a/eval_p.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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 index 19e0eec5..39e512fb 100644 --- a/ext.c +++ b/ext.c @@ -37,18 +37,37 @@ static unsigned long long dummy; /* fake out gcc for dynamic loading? */ #endif -/* do_ext --- load an extension */ - +/* do_ext --- load an extension at run-time: interface to load_ext */ + NODE * do_ext(int nargs) { - NODE *obj; - NODE *fun; + NODE *obj, *fun, *ret = NULL; + SRCFILE *s; + extern SRCFILE *srcfiles; + + fun = POP_STRING(); + obj = POP_STRING(); + + s = add_srcfile(SRC_EXTLIB, obj->stptr, srcfiles, NULL, NULL); + if (s != NULL) + ret = load_ext(s->fullpath, fun->stptr, obj); + DEREF(obj); + DEREF(fun); + if (ret == NULL) + ret = dupnode(Nnull_string); + return ret; +} + +/* load_ext --- load an external library */ + +NODE * +load_ext(const char *lib_name, const char *init_func, NODE *obj) +{ NODE *tmp = NULL; NODE *(*func)(NODE *, void *); void *dl; int flags = RTLD_LAZY; - int fatal_error = FALSE; int *gpl_compat; #ifdef __GNUC__ @@ -61,47 +80,36 @@ do_ext(int nargs) fatal(_("extensions are not allowed in sandbox mode")); if (do_traditional || do_posix) - error(_("`extension' is a gawk extension")); - - fun = POP_STRING(); - obj = POP_STRING(); + fatal(_("`extension' is a gawk extension")); #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, + + if ((dl = dlopen(lib_name, flags)) == NULL) + fatal(_("extension: cannot open library `%s' (%s)\n"), lib_name, 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; + if (gpl_compat == NULL) + fatal(_("extension: library `%s': does not define `plugin_is_GPL_compatible' (%s)\n"), + lib_name, dlerror()); + + func = (NODE *(*)(NODE *, void *)) dlsym(dl, init_func); + if (func == NULL) + fatal(_("extension: library `%s': cannot call function `%s' (%s)\n"), + lib_name, init_func, dlerror()); + + if (obj == NULL) { + obj = make_string(lib_name, strlen(lib_name)); + tmp = (*func)(obj, dl); + unref(tmp); + unref(obj); + return NULL; } tmp = (*func)(obj, dl); - if (tmp == NULL) - tmp = dupnode(Nnull_string); -done: - DEREF(obj); - DEREF(fun); - if (fatal_error) - gawk_exit(EXIT_FATAL); return tmp; } @@ -173,8 +181,11 @@ get_argument(int i) if (i < 0 || i >= pcount || i >= arg_count) return NULL; - i++; - t = PEEK(i); + + t = PEEK(arg_count - i); + if (t->type == Node_param_list) + t = GET_PARAM(t->param_cnt); + if (t->type == Node_array_ref) t = t->orig_array; if (t->type == Node_var) /* See Case Node_var in setup_frame(), eval.c */ @@ -247,4 +258,13 @@ do_ext(int nargs) ERRNO_node->var_value = make_string(emsg, strlen(emsg)); return make_number((AWKNUM) -1); } + +/* load_ext --- dummy version if extensions not available */ + +NODE * +load_ext(const char *lib_name, const char *init_func, NODE *obj) +{ + fatal(_("dynamic loading of library not supported")); + return NULL; +} #endif diff --git a/int_array.c b/int_array.c index fd58de26..200431f9 100644 --- a/int_array.c +++ b/int_array.c @@ -290,7 +290,8 @@ int_remove(NODE *symbol, NODE *subs) int i; NODE *xn = symbol->xarray; - assert(symbol->buckets != NULL); + if (symbol->table_size == 0 || symbol->buckets == NULL) + return NULL; if (! is_integer(symbol, subs)) { if (xn == NULL || xn->aremove(xn, subs) == NULL) @@ -462,7 +463,8 @@ int_list(NODE *symbol, NODE *t) long num; static char buf[100]; - assert(symbol->table_size > 0); + if (symbol->table_size == 0) + return NULL; num_elems = symbol->table_size; if ((t->flags & (AINDEX|AVALUE|ADELETE)) == (AINDEX|ADELETE)) diff --git a/interpret.h b/interpret.h new file mode 100644 index 00000000..66f5b0de --- /dev/null +++ b/interpret.h @@ -0,0 +1,1187 @@ +/* + * 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) Stack operations: + * Use REPLACE[_XX] if last stack operation was TOP[_XX], + * PUSH[_XX] if last operation was POP[_XX] instead. + * 3) 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; + Regexp *rp; + int stdio_problem = FALSE; + +/* array subscript */ +#define mk_sub(n) (n == 1 ? POP_SCALAR() : 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: + 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; + if (! do_traditional && (m->flags & INTLSTR) != 0) { + char *orig, *trans, save; + + save = m->stptr[m->stlen]; + m->stptr[m->stlen] = '\0'; + orig = m->stptr; + trans = dgettext(TEXTDOMAIN, orig); + m->stptr[m->stlen] = save; + m = make_string(trans, strlen(trans)); + } else + UPREF(m); + PUSH(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) { + 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 = dupnode(Nnull_string); + if (do_lint) + lintwarn(isparam ? + _("reference to uninitialized argument `%s'") : + _("reference to uninitialized variable `%s'"), + save_symbol->vname); + m = dupnode(Nnull_string); + PUSH(m); + 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(); + + if (do_lint && in_array(t1, t2) == NULL) { + t2 = force_string(t2); + lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"), + array_vname(t1), (int) t2->stlen, t2->stptr); + if (t2->stlen == 0) + lintwarn(_("subscript of array `%s' is null string"), array_vname(t1)); + } + + r = *assoc_lookup(t1, t2); + 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) { + r = make_array(); + r->parent_array = t1; + *assoc_lookup(t1, t2) = r; + t2 = force_string(t2); + r->vname = estrdup(t2->stptr, t2->stlen); /* the subscript in parent array */ + } else if (r->type != Node_var_array) { + t2 = force_string(t2); + 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(); + if (do_lint && in_array(t1, t2) == NULL) { + t2 = force_string(t2); + if (pc->do_reference) + lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"), + array_vname(t1), (int) t2->stlen, t2->stptr); + if (t2->stlen == 0) + lintwarn(_("subscript of array `%s' is null string"), array_vname(t1)); + } + + lhs = assoc_lookup(t1, t2); + if ((*lhs)->type == Node_var_array) { + t2 = force_string(t2); + 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); + 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 = node_Boolean[di]; + UPREF(r); + PUSH(r); + ni = pc->target_jmp; + JUMPTO(ni->nexti); + + case Op_and_final: + case Op_or_final: + t1 = TOP_SCALAR(); + r = node_Boolean[eval_condition(t1)]; + DEREF(t1); + UPREF(r); + REPLACE(r); + break; + + case Op_not: + t1 = TOP_SCALAR(); + r = node_Boolean[! eval_condition(t1)]; + DEREF(t1); + UPREF(r); + REPLACE(r); + break; + + case Op_equal: + r = node_Boolean[cmp_scalar() == 0]; + UPREF(r); + REPLACE(r); + break; + + case Op_notequal: + r = node_Boolean[cmp_scalar() != 0]; + UPREF(r); + REPLACE(r); + break; + + case Op_less: + r = node_Boolean[cmp_scalar() < 0]; + UPREF(r); + REPLACE(r); + break; + + case Op_greater: + r = node_Boolean[cmp_scalar() > 0]; + UPREF(r); + REPLACE(r); + break; + + case Op_leq: + r = node_Boolean[cmp_scalar() <= 0]; + UPREF(r); + REPLACE(r); + break; + + case Op_geq: + r = node_Boolean[cmp_scalar() >= 0]; + UPREF(r); + 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: + case Op_predecrement: + x2 = pc->opcode == Op_preincrement ? 1.0 : -1.0; + lhs = TOP_ADDRESS(); + t1 = *lhs; + x1 = force_number(t1); + if (t1->valref == 1 && t1->flags == (MALLOC|NUMCUR|NUMBER)) { + /* optimization */ + t1->numbr = x1 + x2; + } else { + unref(t1); + t1 = *lhs = make_number(x1 + x2); + } + UPREF(t1); + REPLACE(t1); + break; + + case Op_postincrement: + case Op_postdecrement: + x2 = pc->opcode == Op_postincrement ? 1.0 : -1.0; + lhs = TOP_ADDRESS(); + t1 = *lhs; + x1 = force_number(t1); + if (t1->valref == 1 && t1->flags == (MALLOC|NUMCUR|NUMBER)) { + /* optimization */ + t1->numbr = x1 + x2; + } else { + unref(t1); + *lhs = make_number(x1 + x2); + } + r = make_number(x1); + REPLACE(r); + break; + + 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); + if ((*lhs)->type == Node_var_array) { + t2 = force_string(t2); + 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); + r = pc->initval; /* constant initializer */ + if (r == NULL) + *lhs = POP_SCALAR(); + else { + UPREF(r); + *lhs = r; + } + 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 != *lhs) { + unref(*lhs); + *lhs = dupnode(t1); + } + + if (t1 != t2 && t1->valref == 1) { + 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'; + t1->flags &= ~(NUMCUR|NUMBER|NUMINT); + } 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); + } + 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 */ + t2 = 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 */ + + t2 = POP_SCALAR(); + 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_empty(array)) + 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); + +arrayfor: + getnode(r); + r->type = Node_arrayfor; + r->for_list = list; + r->for_list_size = num_elems; /* # of elements in list */ + r->cur_idx = -1; /* current index */ + r->for_array = array; /* array */ + PUSH(r); + + if (num_elems == 0) + JUMPTO(pc->target_jmp); /* Op_arrayfor_final */ + } + break; + + case Op_arrayfor_incr: + r = TOP(); /* Node_arrayfor */ + if (++r->cur_idx == r->for_list_size) { + NODE *array; + array = r->for_array; /* actual array */ + if (do_lint && array->table_size != r->for_list_size) + lintwarn(_("for loop: array `%s' changed size from %ld to %ld during loop execution"), + array_vname(array), (long) r->for_list_size, (long) array->table_size); + JUMPTO(pc->target_jmp); /* Op_arrayfor_final */ + } + + t1 = r->for_list[r->cur_idx]; + lhs = get_lhs(pc->array_var, FALSE); + unref(*lhs); + *lhs = dupnode(t1); + 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); + PUSH(r); + break; + + case Op_ext_builtin: + { + int arg_count = pc->expr_count; + + PUSH_CODE(pc); + r = pc->builtin(arg_count); + (void) POP_CODE(); + while (arg_count-- > 0) { + t1 = POP(); + if (t1->type == Node_val) + DEREF(t1); + } + 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 = node_Boolean[di]; + UPREF(r); + 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 */ + t1 = force_string(t1); + if (t1->stlen > 0) { + /* retrieve function definition node */ + f = pc->func_body; + if (f != NULL && STREQ(f->vname, t1->stptr)) { + /* 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 && f->type != Node_ext_func)) + fatal(_("function `%s' not defined"), pc->func_name); + pc->func_body = f; /* save for next call */ + } + + if (f->type == Node_ext_func) { + INSTRUCTION *bc; + char *fname = pc->func_name; + int arg_count = (pc + 1)->expr_count; + + bc = f->code_ptr; + assert(bc->opcode == Op_symbol); + pc->opcode = Op_ext_builtin; /* self modifying code */ + pc->builtin = bc->builtin; + pc->expr_count = arg_count; /* actual argument count */ + (pc + 1)->func_name = fname; /* name of the builtin */ + (pc + 1)->expr_count = bc->expr_count; /* defined max # of arguments */ + ni = pc; + JUMPTO(ni); + } + +func_call: + ni = setup_frame(pc); + + /* run the function instructions */ + JUMPTO(ni); /* Op_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: + 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 = node_Boolean[result]; /* final value of condition pair */ + UPREF(r); + REPLACE(r); + JUMPTO(pc->target_jmp); + } + + case Op_exec_count: + if (do_profile) + 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/io.c b/io.c index a2afeca1..e8c6d872 100644 --- a/io.c +++ b/io.c @@ -2341,6 +2341,30 @@ init_awkpath(char *path) #undef INC_PATH } +/* get_cwd -- get current working directory */ + +static char * +get_cwd () +{ +#define BSIZE 100 + char *buf; + size_t bsize = BSIZE; + + emalloc(buf, char *, bsize * sizeof(char), "get_cwd"); + while (TRUE) { + if (getcwd(buf, bsize) == buf) + return buf; + if (errno != ERANGE) { + efree(buf); + return NULL; + } + bsize *= 2; + erealloc(buf, char *, bsize * sizeof(char), "get_cwd"); + } +#undef BSIZE +} + + /* do_find_source --- search $AWKPATH for file, return NULL if not found */ static char * @@ -2362,10 +2386,16 @@ do_find_source(const char *src, struct stat *stb, int *errcode) return NULL; } - /* try current directory before path search */ + /* try current directory before $AWKPATH search */ if (stat(src, stb) == 0) { - emalloc(path, char *, strlen(src) + 1, "do_find_source"); - strcpy(path, src); + path = get_cwd(); + if (path == NULL) { + *errcode = errno; + return NULL; + } + erealloc(path, char *, strlen(path) + strlen(src) + 2, "do_find_source"); + strcat(path, "/"); + strcat(path, src); return path; } @@ -2375,6 +2405,7 @@ do_find_source(const char *src, struct stat *stb, int *errcode) emalloc(path, char *, max_pathlen + strlen(src) + 1, "do_find_source"); for (i = 0; awkpath[i] != NULL; i++) { if (STREQ(awkpath[i], "./") || STREQ(awkpath[i], ".")) { + /* FIXME: already tried CWD above; Why do it again ? */ *path = '\0'; } else strcpy(path, awkpath[i]); @@ -2392,7 +2423,7 @@ do_find_source(const char *src, struct stat *stb, int *errcode) /* find_source --- find source file with default file extension handling */ char * -find_source(const char *src, struct stat *stb, int *errcode) +find_source(const char *src, struct stat *stb, int *errcode, int is_extlib) { char *path; @@ -2401,10 +2432,36 @@ find_source(const char *src, struct stat *stb, int *errcode) return NULL; path = do_find_source(src, stb, errcode); + if (path == NULL && is_extlib) { + char *file_ext; + int save_errno; + size_t src_len; + size_t suffix_len; + +#define EXTLIB_SUFFIX ".so" + src_len = strlen(src); + suffix_len = strlen(EXTLIB_SUFFIX); + + /* check if already has the SUFFIX */ + if (src_len >= suffix_len && strcmp(& src[src_len - suffix_len], EXTLIB_SUFFIX) == 0) + return NULL; + + /* append EXTLIB_SUFFIX and try again */ + save_errno = errno; + emalloc(file_ext, char *, src_len + suffix_len + 1, "find_source"); + sprintf(file_ext, "%s%s", src, EXTLIB_SUFFIX); + path = do_find_source(file_ext, stb, errcode); + efree(file_ext); + if (path == NULL) + errno = save_errno; + return path; +#undef EXTLIB_SUFFIX + } + #ifdef DEFAULT_FILETYPE if (! do_traditional && path == NULL) { char *file_awk; - int save = errno; + int save_errno = errno; #ifdef VMS int vms_save = vaxc$errno; #endif @@ -2416,7 +2473,7 @@ find_source(const char *src, struct stat *stb, int *errcode) path = do_find_source(file_awk, stb, errcode); efree(file_awk); if (path == NULL) { - errno = save; + errno = save_errno; #ifdef VMS vaxc$errno = vms_save; #endif @@ -2427,6 +2484,7 @@ find_source(const char *src, struct stat *stb, int *errcode) return path; } + /* srcopen --- open source file */ int diff --git a/main.c b/main.c index 6b24a80b..f8b5d81b 100644 --- a/main.c +++ b/main.c @@ -58,6 +58,9 @@ static void init_groupset(void); static void save_argv(int, char **); +extern int debug_prog(INSTRUCTION *pc); /* debug.c */ + + /* 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; @@ -130,7 +133,7 @@ static int disallow_var_assigns = FALSE; /* true for --exec */ static void add_preassign(enum assign_type type, char *val); int do_flags = FALSE; -int do_optimize = TRUE; /* apply default optimizations */ +int do_optimize = TRUE; /* apply default optimizations */ static int do_nostalgia = FALSE; /* provide a blast from the past */ static int do_binary = FALSE; /* hands off my data! */ @@ -140,7 +143,7 @@ int use_lc_numeric = FALSE; /* obey locale for decimal point */ int gawk_mb_cur_max; /* MB_CUR_MAX value, see comment in main() */ #endif -FILE *output_fp; /* default output for debugger */ +FILE *output_fp; /* default gawk output, can be redirected in the debugger */ int output_is_tty = FALSE; /* control flushing of output */ /* default format for strftime(), available via PROCINFO */ @@ -155,26 +158,24 @@ int ngroups; /* size of said set */ 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, NULL, 'c' }, { "lint", optional_argument, NULL, 'L' }, { "lint-old", no_argument, NULL, 't' }, { "optimize", no_argument, NULL, 'O' }, { "posix", no_argument, NULL, 'P' }, - { "command", required_argument, NULL, 'R' }, { "nostalgia", no_argument, & do_nostalgia, 1 }, { "gen-pot", no_argument, NULL, 'g' }, { "non-decimal-data", no_argument, NULL, 'n' }, + { "pretty-print", optional_argument, NULL, 'o' }, { "profile", optional_argument, NULL, 'p' }, + { "debug", optional_argument, NULL, 'D' }, { "copyright", no_argument, NULL, 'C' }, { "field-separator", required_argument, NULL, 'F' }, { "file", required_argument, NULL, 'f' }, { "re-interval", no_argument, NULL, 'r' }, { "source", required_argument, NULL, 'e' }, + { "load", required_argument, NULL, 'l' }, { "dump-variables", optional_argument, NULL, 'd' }, { "assign", required_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, @@ -197,16 +198,17 @@ 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"; + const char *optlist = "+F:f:v:W;m:bcCd::D::e:E:gh:l:L:nNo::Op::PrStVY"; int stopped_early = FALSE; int old_optind; int i; int c; char *scan, *src; char *extra_stack; + int have_srcfile = FALSE; + SRCFILE *s; /* do these checks early */ if (getenv("TIDYMEM") != NULL) @@ -369,6 +371,12 @@ main(int argc, char **argv) varfile = optarg; break; + case 'D': + do_flags |= DO_DEBUG; + if (optarg != NULL && optarg[0] != '\0') + command_file = optarg; + break; + case 'e': if (optarg[0] == '\0') warning(_("empty argument to `-e/--source' ignored")); @@ -385,6 +393,10 @@ main(int argc, char **argv) usage(EXIT_SUCCESS, stdout); break; + case 'l': + (void) add_srcfile(SRC_EXTLIB, optarg, srcfiles, NULL, NULL); + break; + case 'L': #ifndef NO_LINT do_flags |= DO_LINT_ALL; @@ -420,7 +432,10 @@ main(int argc, char **argv) break; case 'p': - do_flags |= DO_PROFILING; + do_flags |= DO_PROFILE; + /* fall through */ + case 'o': + do_flags |= DO_PRETTY_PRINT; if (optarg != NULL) set_prof_file(optarg); else @@ -457,20 +472,13 @@ main(int argc, char **argv) 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 */ - + /* if not debugging, fall through */ case '?': default: /* @@ -550,13 +558,6 @@ out: } #endif - /* - * Force profiling if this is pgawk. - * Don't bother if the command line already set profiling up. - */ - if (! do_profiling) - init_profiling(& do_flags, DEFAULT_PROFILE); - /* load group set */ init_groupset(); @@ -572,7 +573,7 @@ out: */ resetup(); - (void) grow_stack(); + init_interpret(); /* Set up the special variables */ init_vars(); @@ -607,8 +608,17 @@ out: #endif if (os_isatty(fileno(stdout))) output_is_tty = TRUE; + + /* load extension libs */ + for (s = srcfiles->next; s != srcfiles; s = s->next) { + if (s->stype == SRC_EXTLIB) + (void) load_ext(s->fullpath, "dlload", NULL); + else + have_srcfile++; + } + /* No -f or --source options, use next arg */ - if (srcfiles->next == srcfiles) { + if (! have_srcfile) { 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); @@ -628,7 +638,7 @@ out: setlocale(LC_NUMERIC, "C"); #endif /* Read in the program */ - if (parse_program(&code_block) != 0) + if (parse_program(& code_block) != 0) exit(EXIT_FAILURE); if (do_intl) @@ -640,7 +650,8 @@ out: if (do_lint && code_block->nexti->opcode == Op_atexit) lintwarn(_("no program text at all!")); - init_profiling_signals(); + if (do_profile) + init_profiling_signals(); #if defined(LC_NUMERIC) /* @@ -663,9 +674,12 @@ out: #endif output_fp = stdout; - interpret(code_block); + if (do_debug) + debug_prog(code_block); + else + interpret(code_block); - if (do_profiling) { + if (do_pretty_print) { dump_prog(code_block); dump_funcs(); } @@ -718,8 +732,7 @@ 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); - if (which_gawk != exe_debugging) - fprintf(fp, _("Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n"), + 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. */ @@ -733,19 +746,20 @@ usage(int exitval, FILE *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-D[file]\t\t--debug[=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 library\t\t--load=library\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[file]\t\t--pretty-print[=file]\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); diff --git a/profile.c b/profile.c index c721180f..6d9db06e 100644 --- a/profile.c +++ b/profile.c @@ -43,10 +43,9 @@ const char *redir2str(int redirtype); #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 */ @@ -59,20 +58,7 @@ 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 |= DO_PROFILING; - set_prof_file(def_file); - } -#endif -} - -/* set_prof_file --- set the output file for profiling */ +/* set_prof_file --- set the output file for profiling or pretty-printing */ void set_prof_file(const char *file) @@ -87,12 +73,11 @@ set_prof_file(const char *file) } } -/* init_profiling_signals --- set up signal handling for pgawk */ +/* init_profiling_signals --- set up signal handling for gawk --profile */ void init_profiling_signals() { -#ifdef PROFILING #ifdef __DJGPP__ signal(SIGINT, dump_and_exit); signal(SIGQUIT, just_dump); @@ -104,7 +89,6 @@ init_profiling_signals() signal(SIGUSR1, just_dump); #endif #endif /* !__DJGPP__ */ -#endif /* PROFILING */ } /* indent --- print out enough tabs */ @@ -214,10 +198,10 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, int in_for_header) fprintf(prof_fp, "%s {", t1->pp_str); pp_free(t1); ip = (pc + 1)->firsti; -#ifdef PROFILING - if (ip->exec_count > 0) + + if (do_profile && ip->exec_count > 0) fprintf(prof_fp, " # %ld", ip->exec_count); -#endif + fprintf(prof_fp, "\n"); } else { fprintf(prof_fp, "{\n"); @@ -917,7 +901,7 @@ pp_string_fp(Func_print print_func, FILE *fp, const char *in_str, efree(s); } -#ifdef PROFILING + /* just_dump --- dump the profile and function stack and keep going */ static RETSIGTYPE @@ -941,7 +925,6 @@ dump_and_exit(int signum) exit(EXIT_FAILURE); } -#endif /* dump_prog --- dump the program */ diff --git a/str_array.c b/str_array.c index 8fb6ba8a..be431e5d 100644 --- a/str_array.c +++ b/str_array.c @@ -191,7 +191,8 @@ str_exists(NODE *symbol, NODE *subs) unsigned long hash1; size_t code1; - assert(symbol->table_size > 0); + if (symbol->table_size == 0) + return NULL; subs = force_string(subs); hash1 = hash(subs->stptr, subs->stlen, (unsigned long) symbol->array_size, & code1); @@ -242,7 +243,8 @@ str_remove(NODE *symbol, NODE *subs) NODE *s2; size_t s1_len; - assert(symbol->table_size > 0); + if (symbol->table_size == 0) + return NULL; s2 = force_string(subs); hash1 = hash(s2->stptr, s2->stlen, (unsigned long) symbol->array_size, NULL); @@ -358,7 +360,8 @@ str_list(NODE *symbol, NODE *t) unsigned long num_elems, list_size, i, k = 0; int elem_size = 1; - assert(symbol->table_size > 0); + if (symbol->table_size == 0) + return NULL; if ((t->flags & (AINDEX|AVALUE)) == (AINDEX|AVALUE)) elem_size = 2; diff --git a/test/ChangeLog b/test/ChangeLog index 711d8b20..c16e5ecf 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2011-12-26 John Haque + + * badargs.ok: Adjust for new and changed command line options. + 2011-12-26 Arnold D. Robbins * Makefile.am (rri1): New test. diff --git a/test/Makefile.am b/test/Makefile.am index 1bf4456e..943dbd9f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1407,19 +1407,19 @@ dumpvars:: profile1: @echo $@ - @$(AWK) --profile=ap-$@.out -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > _$@.out1 + @$(AWK) --pretty-print=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 + @$(AWK) --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 + @$(AWK) --profile=ap-$@.out -f $(srcdir)/$@.awk > /dev/null @sed 1,2d < ap-$@.out > _$@; rm ap-$@.out @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ diff --git a/test/Makefile.in b/test/Makefile.in index 6eaeb72d..a389929a 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1757,19 +1757,19 @@ dumpvars:: profile1: @echo $@ - @$(AWK) --profile=ap-$@.out -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > _$@.out1 + @$(AWK) --pretty-print=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 + @$(AWK) --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 + @$(AWK) --profile=ap-$@.out -f $(srcdir)/$@.awk > /dev/null @sed 1,2d < ap-$@.out > _$@; rm ap-$@.out @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ diff --git a/test/badargs.ok b/test/badargs.ok index 66e67b03..cb140161 100644 --- a/test/badargs.ok +++ b/test/badargs.ok @@ -10,13 +10,16 @@ Short options: GNU long options: (extensions) -c --traditional -C --copyright -d[file] --dump-variables[=file] + -D[file] --debug[=file] -e 'program-text' --source='program-text' -E file --exec=file -g --gen-pot -h --help + -l library --load=library -L [fatal] --lint[=fatal] -n --non-decimal-data -N --use-lc-numeric + -o[file] --pretty-print[=file] -O --optimize -p[file] --profile[=file] -P --posix -- cgit v1.2.3 From 23d37c1740baeaebefd8310c53b232904c1e1f77 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 28 Dec 2011 18:12:21 +0200 Subject: Fix compiler warnings on printf calls. --- ChangeLog | 5 +++++ int_array.c | 2 +- str_array.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9999d8b0..f904f7f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-12-28 Arnold D. Robbins + + * int_array.c, str_array.c: Fix some compiler warnings 32/64 + bit system differences. + 2011-12-26 John Haque Merge gawk, pgawk and dgawk into a single executable gawk. diff --git a/int_array.c b/int_array.c index 200431f9..6adb7633 100644 --- a/int_array.c +++ b/int_array.c @@ -584,7 +584,7 @@ int_dump(NODE *symbol, NODE *ndump) fprintf(output_fp, "flags: %s\n", flags2str(symbol->flags)); } indent(indent_level); - fprintf(output_fp, "INT_CHAIN_MAX: %lu\n", INT_CHAIN_MAX); + fprintf(output_fp, "INT_CHAIN_MAX: %lu\n", (unsigned long) INT_CHAIN_MAX); indent(indent_level); fprintf(output_fp, "array_size: %lu (int)\n", (unsigned long) symbol->array_size); indent(indent_level); diff --git a/str_array.c b/str_array.c index be431e5d..0b17796c 100644 --- a/str_array.c +++ b/str_array.c @@ -446,7 +446,7 @@ str_dump(NODE *symbol, NODE *ndump) fprintf(output_fp, "flags: %s\n", flags2str(symbol->flags)); } indent(indent_level); - fprintf(output_fp, "STR_CHAIN_MAX: %lu\n", STR_CHAIN_MAX); + fprintf(output_fp, "STR_CHAIN_MAX: %lu\n", (unsigned long) STR_CHAIN_MAX); indent(indent_level); fprintf(output_fp, "array_size: %lu\n", (unsigned long) symbol->array_size); indent(indent_level); -- cgit v1.2.3 From 2c8f64a8d56bcede9e1dd08859b3b235fc9bd40f Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 28 Dec 2011 18:12:52 +0200 Subject: Documentation updates. --- FUTURES | 4 ++-- NEWS | 7 ++++--- doc/ChangeLog | 4 ++++ doc/awkcard.in | 16 ++++++++-------- doc/gawk.1 | 4 ++-- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/FUTURES b/FUTURES index 6b570567..03fe71dc 100644 --- a/FUTURES +++ b/FUTURES @@ -11,14 +11,14 @@ don't bug us too much about schedules or what all this really means. For 4.1 ======= - Merge gawk/pgawk/dgawk into one executable + DONE: 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 + DONE: Merge xmlgawk -l feature Merge xmlgawk XML extensions diff --git a/NEWS b/NEWS index 14855011..803c1d52 100644 --- a/NEWS +++ b/NEWS @@ -9,9 +9,10 @@ Changes from 4.0.1 to 4.1 1. The three executables gawk, pgawk, and dgawk, have been merged into one, named just gawk. As a result: * The -R option is gone - * Use -D ... - * Use -o ... - * Use -p ... + * Use -D to run the debugger. An optional file argument is a + list of commands to run first. + * Use -o to do pretty-printing only. + * Use -p to do profiling. 2. The new -l option is used for loading dynamic extensions. diff --git a/doc/ChangeLog b/doc/ChangeLog index 7dda7e1d..eb9bbf45 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2011-12-28 Arnold D. Robbins + + * awkcard.in, gawk.1: Minor edits after merge of executables. + 2011-12-21 John Haque * gawk.texi: Updated sections on profiling and debugging diff --git a/doc/awkcard.in b/doc/awkcard.in index 862c307c..c8d41833 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -75,7 +75,7 @@ Pattern Elements 8 Printf Formats 14 Records 10 Regular Expressions 11 -Signals (\*(PK) 4 +Signals (\*(GK \*(FC\-\^\-profile\*(FR) 4 Special Filenames 12 String Functions 16 Time Functions (\*(GK) 17 @@ -302,12 +302,7 @@ Disable common and GNU extensions. 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 +\*(FC\-\^\-traditional\*(FR is specified.\*(CB .in -4n .EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(GK\f(HB)\*(FR\s0" @@ -319,6 +314,11 @@ and dynamic extensions loading.\*(CB .ES .fi .in +4n +.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. .TI "\*(FC-t\*(FR, \*(FC\-\^\-lint\-old\*(FR Warn about constructs that are not portable to the original version of @@ -390,7 +390,7 @@ and so on.\*(CB \*(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" +.EB "\s+2\f(HBSIGNALS (\*(GK \f(HB\-\^\-profile)\*(FR\s0" .\" --- Lines And Statements .ES diff --git a/doc/gawk.1 b/doc/gawk.1 index c171acbf..662ace35 100644 --- a/doc/gawk.1 +++ b/doc/gawk.1 @@ -97,8 +97,8 @@ 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. +.IR Gawk -specific +options are typically used in long-option form. Arguments to long options are either joined with the option by an .B = -- cgit v1.2.3 From a89bd16ff78c74513461af3f676d87d4eb9cfd3c Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sat, 31 Dec 2011 20:51:11 +0200 Subject: Remove ancient STREQ, STREQN macros. --- ChangeLog | 6 + awk.h | 5 - awkgram.c | 6 +- awkgram.y | 6 +- builtin.c | 4 +- command.c | 583 ++++++++++++++++++++++++++++++--------------------------- command.y | 2 +- debug.c | 25 +-- eval.c | 2 +- io.c | 31 ++- msg.c | 2 +- vms/ChangeLog | 5 + vms/vms_misc.c | 6 +- 13 files changed, 365 insertions(+), 318 deletions(-) diff --git a/ChangeLog b/ChangeLog index 075809d5..39dd5a6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +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 (!) diff --git a/awk.h b/awk.h index a267d2ee..3574e587 100644 --- a/awk.h +++ b/awk.h @@ -1110,13 +1110,8 @@ extern STACK_ITEM *stack_top; #endif /* __GNUC__ */ #endif /* GAWKDEBUG */ -#define STREQ(a,b) (*(a) == *(b) && strcmp((a), (b)) == 0) -#define STREQN(a,b,n) ((n) && *(a)== *(b) && \ - strncmp((a), (b), (size_t) (n)) == 0) - #define fatal set_loc(__FILE__, __LINE__), r_fatal - extern jmp_buf fatal_tag; extern int fatal_tag_valid; diff --git a/awkgram.c b/awkgram.c index 7a06667e..665edbdc 100644 --- a/awkgram.c +++ b/awkgram.c @@ -6675,7 +6675,7 @@ lookup(const char *name) len = strlen(name); for (bucket = variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]; bucket != NULL; bucket = bucket->hnext) - if (bucket->hlength == len && STREQN(bucket->hname, name, len)) + if (bucket->hlength == len && strncmp(bucket->hname, name, len) == 0) return bucket->hvalue; return NULL; } @@ -6961,7 +6961,7 @@ remove_symbol(char *name) len = strlen(name); save = &(variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]); for (bucket = *save; bucket != NULL; bucket = bucket->hnext) { - if (len == bucket->hlength && STREQN(bucket->hname, name, len)) { + if (len == bucket->hlength && strncmp(bucket->hname, name, len) == 0) { var_count--; *save = bucket->hnext; return bucket; @@ -7233,7 +7233,7 @@ variable(char *name, NODETYPE type) r = mk_symbol(type, (NODE *) NULL); return install_symbol(name, r); } - if (STREQ(name, dv->name)) { + if (strcmp(name, dv->name) == 0) { r = (*dv->load_func)(); break; } diff --git a/awkgram.y b/awkgram.y index 69f74cab..ce71bb27 100644 --- a/awkgram.y +++ b/awkgram.y @@ -3985,7 +3985,7 @@ lookup(const char *name) len = strlen(name); for (bucket = variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]; bucket != NULL; bucket = bucket->hnext) - if (bucket->hlength == len && STREQN(bucket->hname, name, len)) + if (bucket->hlength == len && strncmp(bucket->hname, name, len) == 0) return bucket->hvalue; return NULL; } @@ -4271,7 +4271,7 @@ remove_symbol(char *name) len = strlen(name); save = &(variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]); for (bucket = *save; bucket != NULL; bucket = bucket->hnext) { - if (len == bucket->hlength && STREQN(bucket->hname, name, len)) { + if (len == bucket->hlength && strncmp(bucket->hname, name, len) == 0) { var_count--; *save = bucket->hnext; return bucket; @@ -4543,7 +4543,7 @@ variable(char *name, NODETYPE type) r = mk_symbol(type, (NODE *) NULL); return install_symbol(name, r); } - if (STREQ(name, dv->name)) { + if (strcmp(name, dv->name) == 0) { r = (*dv->load_func)(); break; } diff --git a/builtin.c b/builtin.c index 4b4b9722..30cf9a5d 100644 --- a/builtin.c +++ b/builtin.c @@ -154,9 +154,9 @@ static FILE * stdfile(const char *name, size_t len) { if (len == 11) { - if (STREQN(name, "/dev/stderr", 11)) + if (strncmp(name, "/dev/stderr", 11) == 0) return stderr; - else if (STREQN(name, "/dev/stdout", 11)) + else if (strncmp(name, "/dev/stdout", 11) == 0) return stdout; } diff --git a/command.c b/command.c index 2b3b3494..3664eee2 100644 --- a/command.c +++ b/command.c @@ -1,9 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ +/* A Bison parser, made by GNU Bison 2.5. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. + 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 @@ -45,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.3" +#define YYBISON_VERSION "2.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -74,7 +73,7 @@ /* Copy the first part of user declarations. */ -/* Line 189 of yacc.c */ +/* Line 268 of yacc.c */ #line 26 "command.y" #include "awk.h" @@ -143,8 +142,8 @@ static int find_argument(CMDARG *arg); #define YYSTYPE CMDARG * -/* Line 189 of yacc.c */ -#line 148 "command.c" +/* Line 268 of yacc.c */ +#line 147 "command.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -281,8 +280,8 @@ typedef int YYSTYPE; /* Copy the second part of user declarations. */ -/* Line 264 of yacc.c */ -#line 286 "command.c" +/* Line 343 of yacc.c */ +#line 285 "command.c" #ifdef short # undef short @@ -384,11 +383,11 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # endif @@ -411,24 +410,24 @@ YYID (yyi) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined _STDLIB_H \ +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# 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 _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# 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 @@ -455,23 +454,7 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -/* 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 +# 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 @@ -491,6 +474,26 @@ union yyalloc #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. */ @@ -721,8 +724,8 @@ static const yytype_uint8 yyr2[] = 1, 1, 2, 1, 2, 2, 1 }; -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero +/* 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[] = { @@ -801,8 +804,7 @@ static const yytype_int16 yypgoto[] = /* 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 zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ + number is the opposite. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -148 static const yytype_int16 yytable[] = { @@ -829,6 +831,12 @@ static const yytype_int16 yytable[] = 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, @@ -914,7 +922,6 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -956,19 +963,10 @@ while (YYID (0)) #endif -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ +/* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif @@ -1156,7 +1154,6 @@ int yydebug; # define YYMAXDEPTH 10000 #endif - #if YYERROR_VERBOSE @@ -1257,115 +1254,142 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; +/* 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. - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else + 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 yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - 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 yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } + 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; + } + } + } - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - 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_ + } - if (yysize_overflow) - return YYSIZE_MAXIMUM; + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; - if (yyresult) - { - /* 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 = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; + 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. | @@ -1397,6 +1421,7 @@ yydestruct (yymsg, yytype, yyvaluep) } } + /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus @@ -1423,10 +1448,9 @@ YYSTYPE yylval; int yynerrs; - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ +/*----------. +| yyparse. | +`----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) @@ -1448,8 +1472,6 @@ yyparse () #endif #endif { - - int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; @@ -1604,7 +1626,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1635,8 +1657,8 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; + if (yytable_value_is_error (yyn)) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -1691,7 +1713,7 @@ yyreduce: { case 3: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 109 "command.y" { cmd_idx = -1; @@ -1711,7 +1733,7 @@ yyreduce: case 5: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 128 "command.y" { if (errcount == 0 && cmd_idx >= 0) { @@ -1766,7 +1788,7 @@ yyreduce: case 6: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 178 "command.y" { yyerrok; @@ -1775,14 +1797,14 @@ yyreduce: case 22: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 212 "command.y" { want_nodeval = TRUE; } break; case 23: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 217 "command.y" { if (errcount == 0) { @@ -1802,7 +1824,7 @@ yyreduce: case 24: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 235 "command.y" { (yyval) = append_statement(arg_list, (char *) start_EVAL); @@ -1815,14 +1837,14 @@ yyreduce: case 25: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 242 "command.y" { (yyval) = append_statement((yyvsp[(1) - (2)]), lexptr_begin); } break; case 26: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 243 "command.y" { (yyval) = (yyvsp[(3) - (4)]); @@ -1831,7 +1853,7 @@ yyreduce: case 27: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 250 "command.y" { arg_list = append_statement((yyvsp[(2) - (3)]), (char *) end_EVAL); @@ -1852,7 +1874,7 @@ yyreduce: case 28: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 266 "command.y" { NODE *n; @@ -1868,7 +1890,7 @@ yyreduce: case 34: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 285 "command.y" { if (cmdtab[cmd_idx].class == D_FRAME @@ -1879,7 +1901,7 @@ yyreduce: case 35: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 291 "command.y" { int idx = find_argument((yyvsp[(2) - (2)])); @@ -1896,49 +1918,49 @@ yyreduce: case 38: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 304 "command.y" { want_nodeval = TRUE; } break; case 40: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 305 "command.y" { want_nodeval = TRUE; } break; case 46: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 310 "command.y" { want_nodeval = TRUE; } break; case 49: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 312 "command.y" { want_nodeval = TRUE; } break; case 51: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 313 "command.y" { want_nodeval = TRUE; } break; case 53: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 314 "command.y" { want_nodeval = TRUE; } break; case 57: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 318 "command.y" { if (in_cmd_src((yyvsp[(2) - (2)])->a_string)) @@ -1948,7 +1970,7 @@ yyreduce: case 58: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 323 "command.y" { if (! input_from_tty) @@ -1958,7 +1980,7 @@ yyreduce: case 59: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 328 "command.y" { int type = 0; @@ -1989,7 +2011,7 @@ yyreduce: case 60: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 354 "command.y" { if (! in_commands) @@ -2004,7 +2026,7 @@ yyreduce: case 61: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 364 "command.y" { if (! in_commands) @@ -2014,7 +2036,7 @@ yyreduce: case 62: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 369 "command.y" { int idx = find_argument((yyvsp[(2) - (2)])); @@ -2031,14 +2053,14 @@ yyreduce: case 63: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 380 "command.y" { want_nodeval = TRUE; } break; case 64: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 381 "command.y" { int type; @@ -2051,7 +2073,7 @@ yyreduce: case 65: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 389 "command.y" { if (in_commands) { @@ -2067,7 +2089,7 @@ yyreduce: case 66: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 403 "command.y" { if ((yyvsp[(1) - (1)]) != NULL) { @@ -2082,42 +2104,42 @@ yyreduce: case 68: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 417 "command.y" { (yyval) = NULL; } break; case 69: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 422 "command.y" { (yyval) = NULL; } break; case 74: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 431 "command.y" { (yyval) = NULL; } break; case 75: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 436 "command.y" { (yyval) = NULL; } break; case 77: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 439 "command.y" { (yyval) = NULL; } break; case 78: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 444 "command.y" { NODE *n; @@ -2129,14 +2151,14 @@ yyreduce: case 79: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 454 "command.y" { (yyval) = NULL; } break; case 80: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 456 "command.y" { if (find_option((yyvsp[(1) - (1)])->a_string) < 0) @@ -2146,7 +2168,7 @@ yyreduce: case 81: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 461 "command.y" { if (find_option((yyvsp[(1) - (3)])->a_string) < 0) @@ -2156,7 +2178,7 @@ yyreduce: case 82: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 469 "command.y" { NODE *n; @@ -2174,56 +2196,56 @@ yyreduce: case 83: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 485 "command.y" { (yyval) = NULL; } break; case 88: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 494 "command.y" { (yyval) = NULL; } break; case 89: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 495 "command.y" { want_nodeval = TRUE; } break; case 92: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 497 "command.y" { want_nodeval = TRUE; } break; case 95: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 503 "command.y" { (yyval) = NULL; } break; case 97: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 509 "command.y" { (yyval) = NULL; } break; case 99: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 515 "command.y" { (yyval) = NULL; } break; case 104: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 527 "command.y" { int idx = find_argument((yyvsp[(1) - (2)])); @@ -2240,7 +2262,7 @@ yyreduce: case 106: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 543 "command.y" { (yyvsp[(2) - (2)])->type = D_array; /* dump all items */ @@ -2250,7 +2272,7 @@ yyreduce: case 107: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 548 "command.y" { (yyvsp[(2) - (3)])->type = D_array; @@ -2260,21 +2282,21 @@ yyreduce: case 117: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 574 "command.y" { (yyval) = NULL; } break; case 118: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 576 "command.y" { (yyval) = NULL; } break; case 119: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 578 "command.y" { CMDARG *a; @@ -2286,7 +2308,7 @@ yyreduce: case 126: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 594 "command.y" { if ((yyvsp[(1) - (3)])->a_int > (yyvsp[(3) - (3)])->a_int) @@ -2300,28 +2322,28 @@ yyreduce: case 127: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 606 "command.y" { (yyval) = NULL; } break; case 134: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 620 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 135: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 622 "command.y" { (yyval) = (yyvsp[(1) - (3)]); } break; case 137: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 628 "command.y" { CMDARG *a; @@ -2341,21 +2363,21 @@ yyreduce: case 139: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 647 "command.y" { (yyval) = (yyvsp[(1) - (1)]); num_dim = 1; } break; case 140: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 649 "command.y" { (yyval) = (yyvsp[(1) - (2)]); num_dim++; } break; case 142: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 655 "command.y" { NODE *n = (yyvsp[(2) - (2)])->a_node; @@ -2369,7 +2391,7 @@ yyreduce: case 143: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 664 "command.y" { /* a_string is array name, a_count is dimension count */ @@ -2381,14 +2403,14 @@ yyreduce: case 144: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 674 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 145: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 676 "command.y" { NODE *n = (yyvsp[(2) - (2)])->a_node; @@ -2400,7 +2422,7 @@ yyreduce: case 146: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 683 "command.y" { NODE *n = (yyvsp[(2) - (2)])->a_node; @@ -2414,35 +2436,35 @@ yyreduce: case 147: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 695 "command.y" { (yyval) = NULL; } break; case 148: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 697 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 149: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 702 "command.y" { (yyval) = NULL; } break; case 150: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 704 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 151: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 709 "command.y" { if ((yyvsp[(1) - (1)])->a_int == 0) @@ -2453,7 +2475,7 @@ yyreduce: case 152: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 715 "command.y" { if ((yyvsp[(2) - (2)])->a_int == 0) @@ -2464,21 +2486,21 @@ yyreduce: case 153: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 724 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 154: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 726 "command.y" { (yyval) = (yyvsp[(2) - (2)]); } break; case 155: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 728 "command.y" { (yyvsp[(2) - (2)])->a_int = - (yyvsp[(2) - (2)])->a_int; @@ -2488,7 +2510,7 @@ yyreduce: case 156: -/* Line 1464 of yacc.c */ +/* Line 1806 of yacc.c */ #line 736 "command.y" { if (lexptr_begin != NULL) { @@ -2502,10 +2524,21 @@ yyreduce: -/* Line 1464 of yacc.c */ -#line 2519 "command.c" +/* 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); @@ -2533,6 +2566,10 @@ yyreduce: | 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) { @@ -2540,37 +2577,36 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } + 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 } @@ -2629,7 +2665,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) + if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -2688,8 +2724,13 @@ yyexhaustedlab: yyreturn: if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); + { + /* 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); @@ -2714,7 +2755,7 @@ yyreturn: -/* Line 1684 of yacc.c */ +/* Line 2067 of yacc.c */ #line 746 "command.y" @@ -3404,7 +3445,7 @@ do_help(CMDARG *arg, int cmd) i = find_command(name, strlen(name)); if (i >= 0) { fprintf(out_fp, "%s\n", cmdtab[i].help_txt); - if (STREQ(cmdtab[i].name, "option")) + if (strcmp(cmdtab[i].name, "option") == 0) option_help(); } else fprintf(out_fp, _("undefined command: %s\n"), name); diff --git a/command.y b/command.y index bcaa74f0..676a545d 100644 --- a/command.y +++ b/command.y @@ -1431,7 +1431,7 @@ do_help(CMDARG *arg, int cmd) i = find_command(name, strlen(name)); if (i >= 0) { fprintf(out_fp, "%s\n", cmdtab[i].help_txt); - if (STREQ(cmdtab[i].name, "option")) + if (strcmp(cmdtab[i].name, "option") == 0) option_help(); } else fprintf(out_fp, _("undefined command: %s\n"), name); diff --git a/debug.c b/debug.c index ea652478..1cfbac4c 100644 --- a/debug.c +++ b/debug.c @@ -994,7 +994,7 @@ find_param(const char *name, long num, char **pname) pcount = get_param_count(func); for (i = 0; i < pcount; i++) { - if (STREQ(name, pnames[i])) { + if (strcmp(name, pnames[i]) == 0) { r = f->stack[i]; if (r->type == Node_array_ref) r = r->orig_array; @@ -4068,7 +4068,7 @@ do_save(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) */ if (strlen(line) > 1 - && STREQN(line, "sa", 2)) + && strncmp(line, "sa", 2) == 0) continue; fprintf(fp, "%s\n", line); @@ -4102,7 +4102,7 @@ do_option(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) value = arg ? arg->a_string : NULL; for (opt = option_list; opt->name; opt++) { /* linear search */ - if (STREQ(name, opt->name)) + if (strcmp(name, opt->name) == 0) break; } if (! opt->name) @@ -4651,8 +4651,9 @@ 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 (STREQN(pstr[0], opt->name, pstr_len[0])) { + if (strncmp(pstr[0], opt->name, pstr_len[0]) == 0) { char *value; + value = estrdup(pstr[1], pstr_len[1]); (*(opt->assign))(value); efree(value); @@ -5063,7 +5064,7 @@ find_option(char *name) int idx; for (idx = 0; (p = option_list[idx].name); idx++) { - if (STREQ(p, name)) + if (strcmp(p, name) == 0) return idx; } return -1; @@ -5132,19 +5133,19 @@ set_gawk_output(const char *file) if (fp == NULL) close(fd); - } else if (STREQN(file, "/dev/", 5)) { + } else if (strncmp(file, "/dev/", 5) == 0) { char *cp = (char *) file + 5; - if (STREQ(cp, "stdout")) + if (strcmp(cp, "stdout") == 0) return; - if (STREQ(cp, "stderr")) { + if (strcmp(cp, "stderr") == 0) { output_fp = stderr; output_file = "/dev/stderr"; output_is_tty = os_isatty(fileno(stderr)); return; } - if (STREQN(cp, "fd/", 3)) { + if (strncmp(cp, "fd/", 3) == 0) { cp += 3; fd = (int) strtoul(cp, NULL, 10); if (errno == 0 && fd > INVALID_HANDLE) { @@ -5198,9 +5199,9 @@ static int set_option_flag(const char *value) { long n; - if (STREQ(value, "on")) + if (strcmp(value, "on") == 0) return TRUE; - if (STREQ(value, "off")) + if (strcmp(value, "off") == 0) return FALSE; errno = 0; n = strtol(value, NULL, 0); @@ -5703,7 +5704,7 @@ in_cmd_src(const char *filename) { struct command_source *cs; for (cs = cmd_src; cs != NULL; cs = cs->next) { - if (cs->str != NULL && STREQ(cs->str, filename)) + if (cs->str != NULL && strcmp(cs->str, filename) == 0) return TRUE; } return FALSE; diff --git a/eval.c b/eval.c index 22f30773..2421aea1 100644 --- a/eval.c +++ b/eval.c @@ -2448,7 +2448,7 @@ match_re: if (t1->stlen > 0) { /* retrieve function definition node */ f = pc->func_body; - if (f != NULL && STREQ(f->vname, t1->stptr)) + if (f != NULL && strcmp(f->vname, t1->stptr) == 0) /* indirect var hasn't been reassigned */ goto func_call; f = lookup(t1->stptr); diff --git a/io.c b/io.c index 9c827eda..c57aef2a 100644 --- a/io.c +++ b/io.c @@ -618,9 +618,8 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) fatal(_("expression for `%s' redirection has null string value"), what); - if (do_lint && (STREQN(str, "0", redir_exp->stlen) - || STREQN(str, "1", redir_exp->stlen)) - ) + 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); @@ -631,7 +630,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) #ifdef HAVE_SOCKETS if (inetfile(str, & len, NULL)) { tflag |= RED_SOCKET; - if (STREQN(str + len, "tcp/", 4)) + if (strncmp(str + len, "tcp/", 4) == 0) tflag |= RED_TCP; /* use shutdown when closing */ } #endif /* HAVE_SOCKETS */ @@ -1378,7 +1377,7 @@ devopen(const char *name, const char *mode) flag = str2mode(mode); - if (STREQ(name, "-")) + if (strcmp(name, "-") == 0) return fileno(stdin); openfd = INVALID_HANDLE; @@ -1391,16 +1390,16 @@ devopen(const char *name, const char *mode) return openfd; } - if (STREQN(name, "/dev/", 5)) { + if (strncmp(name, "/dev/", 5) == 0) { cp = (char *) name + 5; - if (STREQ(cp, "stdin") && (flag & O_ACCMODE) == O_RDONLY) + if (strcmp(cp, "stdin") == 0 && (flag & O_ACCMODE) == O_RDONLY) openfd = fileno(stdin); - else if (STREQ(cp, "stdout") && (flag & O_ACCMODE) == O_WRONLY) + else if (strcmp(cp, "stdout") == 0 && (flag & O_ACCMODE) == O_WRONLY) openfd = fileno(stdout); - else if (STREQ(cp, "stderr") && (flag & O_ACCMODE) == O_WRONLY) + else if (strcmp(cp, "stderr") == 0 && (flag & O_ACCMODE) == O_WRONLY) openfd = fileno(stderr); - else if (STREQN(cp, "fd/", 3)) { + else if (strncmp(cp, "fd/", 3) == 0) { struct stat sbuf; cp += 3; @@ -1423,9 +1422,9 @@ devopen(const char *name, const char *mode) cp = (char *) name + len; /* which protocol? */ - if (STREQN(cp, "tcp/", 4)) + if (strncmp(cp, "tcp/", 4) == 0) protocol = SOCK_STREAM; - else if (STREQN(cp, "udp/", 4)) + else if (strncmp(cp, "udp/", 4) == 0) protocol = SOCK_DGRAM; else { protocol = SOCK_STREAM; /* shut up the compiler */ @@ -2374,7 +2373,7 @@ do_find_source(const char *src, struct stat *stb, int *errcode) emalloc(path, char *, max_pathlen + strlen(src) + 1, "do_find_source"); for (i = 0; awkpath[i] != NULL; i++) { - if (STREQ(awkpath[i], "./") || STREQ(awkpath[i], ".")) { + if (strcmp(awkpath[i], "./") == 0 || strcmp(awkpath[i], ".") == 0) { *path = '\0'; } else strcpy(path, awkpath[i]); @@ -3211,19 +3210,19 @@ inetfile(const char *str, int *length, int *family) { int ret = FALSE; - if (STREQN(str, "/inet/", 6)) { + if (strncmp(str, "/inet/", 6) == 0) { ret = TRUE; if (length != NULL) *length = 6; if (family != NULL) *family = AF_UNSPEC; - } else if (STREQN(str, "/inet4/", 7)) { + } else if (strncmp(str, "/inet4/", 7) == 0) { ret = TRUE; if (length != NULL) *length = 7; if (family != NULL) *family = AF_INET; - } else if (STREQN(str, "/inet6/", 7)) { + } else if (strncmp(str, "/inet6/", 7) == 0) { ret = TRUE; if (length != NULL) *length = 7; diff --git a/msg.c b/msg.c index 84a4e5cd..3ed02331 100644 --- a/msg.c +++ b/msg.c @@ -46,7 +46,7 @@ err(const char *s, const char *emsg, va_list argp) (void) fflush(output_fp); me = myname; - if (STREQN(me, "dgawk", 5)) + if (strncmp(me, "dgawk", 5) == 0) me = &myname[1]; (void) fprintf(stderr, "%s: ", me); #ifdef GAWKDEBUG diff --git a/vms/ChangeLog b/vms/ChangeLog index 62db87e1..a39f1125 100644 --- a/vms/ChangeLog +++ b/vms/ChangeLog @@ -1,3 +1,8 @@ +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. diff --git a/vms/vms_misc.c b/vms/vms_misc.c index f3650ef4..cd92d7ef 100644 --- a/vms/vms_misc.c +++ b/vms/vms_misc.c @@ -98,7 +98,7 @@ vms_open( const char *name, int mode, ... ) { int result; - if (STREQN(name, "/dev/", 5)) { + 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: */ @@ -307,7 +307,7 @@ VMS_fstat (fd, statbuf) if (result == 0 /* GAWK addition; fixup /dev/null flags */ && (statbuf->st_mode & S_IFREG) - && STREQ(statbuf->st_dev, "_NLA0:")) + && strcmp(statbuf->st_dev, "_NLA0:") == 0) { statbuf->st_mode &= ~S_IFREG; statbuf->st_mode |= S_IFCHR; @@ -354,7 +354,7 @@ VMS_stat (name, statbuf) if (result == 0 /* GAWK addition; fixup /dev/null flags */ && (statbuf->st_mode & S_IFREG) - && STREQ(statbuf->st_dev, "_NLA0:")) + && strcmp(statbuf->st_dev, "_NLA0:") == 0) { statbuf->st_mode &= ~S_IFREG; statbuf->st_mode |= S_IFCHR; -- cgit v1.2.3 From ccb220159bbbc45aac0572c7ca1d3f0f2247d1f5 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sat, 31 Dec 2011 20:53:17 +0200 Subject: Remove profile_p.c, no longer needed. --- profile_p.c | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 profile_p.c diff --git a/profile_p.c b/profile_p.c deleted file mode 100644 index 97edd367..00000000 --- a/profile_p.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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" -- cgit v1.2.3 From d84926f0d651d5f55b1be3b760b572a50197593f Mon Sep 17 00:00:00 2001 From: john haque Date: Sun, 1 Jan 2012 10:33:09 -0600 Subject: Added timeout for reading from input. --- ChangeLog | 14 +++++ awk.h | 8 ++- io.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------- main.c | 4 +- 4 files changed, 181 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 292a03ca..8fe80acf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2012-01-01 John Haque + + * awk.h (struct iobuf): New entry read_func. + * io.c (Read_can_timeout, Read_timeout, Read_default_timeout): + New variables. + (init_io): New routine to initialize the variables. + (in_PROCINFO): New "clever" routine to parse elements with indices + seperated by a SUPSEP. + (get_read_timeout): New routine to read timeout value for an IOBUF. + (read_with_timeout): New routine to read from a fd with a timeout. + (pty_vs_pipe): Use in_PROCINFO(). + (get_a_record): Set the timeout value and the read routine as necessary. + * main.c (main): Call init_io(). + 2011-12-31 Arnold D. Robbins * profile_p.c: Remove the file. diff --git a/awk.h b/awk.h index c06e2931..72593902 100644 --- a/awk.h +++ b/awk.h @@ -850,6 +850,11 @@ typedef struct iobuf { ssize_t count; /* amount read last time */ size_t scanoff; /* where we were in the buffer when we had to regrow/refill */ + /* + * No argument prototype on read_func. See get_src_buf() + * in awkgram.y. + */ + ssize_t (*read_func)(); void *opaque; /* private data for open hooks */ int (*get_record)(char **out, struct iobuf *, int *errcode); @@ -862,7 +867,7 @@ typedef struct iobuf { # define IOP_NOFREE_OBJ 2 # define IOP_AT_EOF 4 # define IOP_CLOSED 8 -# define IOP_AT_START 16 +# define IOP_AT_START 16 } IOBUF; typedef void (*Func_ptr)(void); @@ -1434,6 +1439,7 @@ extern int ispath(const char *file); extern int isdirpunct(int c); /* io.c */ +extern void init_io(void); extern void register_open_hook(void *(*open_func)(IOBUF *)); extern void set_FNR(void); extern void set_NR(void); diff --git a/io.c b/io.c index b6076eba..ca59b5c4 100644 --- a/io.c +++ b/io.c @@ -206,10 +206,18 @@ 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); +static NODE *in_PROCINFO(const char *pidx1, const char *pidx2, NODE **full_idx); +static long get_read_timeout(IOBUF *iop); +static ssize_t read_with_timeout(int fd, char *buf, size_t size); + #if defined(HAVE_POPEN_H) #include "popen.h" #endif +static int Read_can_timeout = FALSE; +static long Read_timeout; +static long Read_default_timeout; + static struct redirect *red_head = NULL; static NODE *RS = NULL; static Regexp *RS_re_yes_case; @@ -225,6 +233,31 @@ extern NODE *ARGIND_node; extern NODE *ERRNO_node; extern NODE **fields_arr; + +void +init_io() +{ + long tmout; + + /* N.B.: all these hacks are to minimize the affect + * on programs that do not care about timeout. + */ + + /* Parse the env. variable only once */ + tmout = getenv_long("GAWK_READ_TIMEOUT"); + if (tmout > 0) { + Read_default_timeout = tmout; + Read_can_timeout = TRUE; + } + + /* PROCINFO entries for timeout are dynamic; + * We can't be any more specific than this. + */ + if (PROCINFO_node != NULL) + Read_can_timeout = TRUE; +} + + #if defined(__DJGPP__) || defined(__MINGW32__) || defined(__EMX__) || defined(__CYGWIN__) /* binmode --- convert BINMODE to string for fopen */ @@ -376,6 +409,7 @@ nextfile(IOBUF **curfile, int skipping) fname = "-"; iop = *curfile = iop_alloc(fileno(stdin), fname, &mybuf, FALSE); iop->flag |= IOP_NOFREE_OBJ; + if (iop->fd == INVALID_HANDLE) { errcode = errno; errno = 0; @@ -2554,22 +2588,21 @@ iop_alloc(int fd, const char *name, IOBUF *iop, int do_openhooks) iop_malloced = TRUE; } memset(iop, '\0', sizeof(IOBUF)); - iop->flag = 0; iop->fd = fd; iop->name = name; + iop->read_func = ( ssize_t(*)() ) read; - if (do_openhooks) + if (do_openhooks) { find_open_hook(iop); - else if (iop->fd == INVALID_HANDLE) + /* tried to find open hook and could not */ + if (iop->fd == INVALID_HANDLE) { + if (iop_malloced) + efree(iop); + return NULL; + } + } 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); @@ -2983,12 +3016,15 @@ get_a_record(char **out, /* pointer to pointer to data */ if (at_eof(iop) && no_data_left(iop)) return EOF; + if (Read_can_timeout) + Read_timeout = get_read_timeout(iop); + 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); + iop->count = iop->read_func(iop->fd, iop->buf, iop->readsize); if (iop->count == 0) { iop->flag |= IOP_AT_EOF; return EOF; @@ -3054,7 +3090,7 @@ get_a_record(char **out, /* pointer to pointer to data */ amt_to_read = min(amt_to_read, SSIZE_MAX); #endif - iop->count = read(iop->fd, iop->dataend, amt_to_read); + iop->count = iop->read_func(iop->fd, iop->dataend, amt_to_read); if (iop->count == -1) { *errcode = errno; iop->flag |= IOP_AT_EOF; @@ -3192,6 +3228,7 @@ set_FS: set_FS(); } + /* pty_vs_pipe --- return true if should use pty instead of pipes for `|&' */ /* @@ -3202,26 +3239,11 @@ static int pty_vs_pipe(const char *command) { #ifdef HAVE_TERMIOS_H - char *full_index; - size_t full_len; - NODE *val, *sub; + NODE *val; 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); - + val = in_PROCINFO(command, "pty", NULL); if (val) { if (val->flags & MAYBE_NUM) (void) force_number(val); @@ -3292,3 +3314,109 @@ inetfile(const char *str, int *length, int *family) return ret; } + +/* in_PROCINFO --- return value for a PROCINFO element with + * SUBSEP seperated indices. + */ + +static NODE * +in_PROCINFO(const char *pidx1, const char *pidx2, NODE **full_idx) +{ + char *str; + size_t str_len; + NODE *r, *sub = NULL; + NODE *subsep = SUBSEP_node->var_value; + + /* full_idx is in+out parameter */ + + if (full_idx) + sub = *full_idx; + + str_len = strlen(pidx1) + subsep->stlen + strlen(pidx2); + if (sub == NULL) { + emalloc(str, char *, str_len + 1, "in_PROCINFO"); + sub = make_str_node(str, str_len, ALREADY_MALLOCED); + if (full_idx) + *full_idx = sub; + } else if (str_len != sub->stlen) { + /* *full_idx != NULL */ + + assert(sub->valref == 1); + erealloc(sub->stptr, char *, str_len + 1, "in_PROCINFO"); + sub->stlen = str_len; + } + + sprintf(sub->stptr, "%s%.*s%s", pidx1, subsep->stlen, subsep->stptr, pidx2); + r = in_array(PROCINFO_node, sub); + if (! full_idx) + unref(sub); + return r; +} + + +/* get_read_timeout --- get timeout in milliseconds for reading */ + +static long +get_read_timeout(IOBUF *iop) +{ + long tmout = 0; + char *cp; + + if (PROCINFO_node != NULL) { + const char *name = iop->name; + NODE *val = NULL; + static NODE *full_idx = NULL; + static const char *last_name = NULL; + + /* Do not re-construct the full index when last redirection string is + * the same as the current; "efficiency_hack++". + */ + if (full_idx == NULL || strcmp(name, last_name) != 0) { + val = in_PROCINFO(name, "READ_TIMEOUT", & full_idx); + last_name = name; + } else /* use cached full index */ + val = in_array(PROCINFO_node, full_idx); + if (val != NULL) + tmout = (long) force_number(val); + } else + tmout = Read_default_timeout; /* initialized from env. variable in init_io() */ + + iop->read_func = tmout > 0 ? read_with_timeout : ( ssize_t(*)() ) read; + return tmout; +} + +/* read_with_timeout --- read with a timeout, return failure + if no data is available within the timeout period. +*/ + +static ssize_t +read_with_timeout(int fd, char *buf, size_t size) +{ + fd_set readfds; + struct timeval tv; + + tv.tv_sec = Read_timeout / 1000; + tv.tv_usec = 1000 * (Read_timeout - 1000 * tv.tv_sec); + + FD_ZERO(& readfds); + FD_SET(fd, & readfds); + + errno = 0; + if (select(fd + 1, & readfds, NULL, NULL, & tv) < 0) + return -1; + + if (FD_ISSET(fd, & readfds)) + return read(fd, buf, size); + /* else + timed out */ + + /* Set a meaningful errno */ +#ifdef ETIMEDOUT + errno = ETIMEDOUT; +#else + errno = EAGAIN; +#endif + return -1; +} + + diff --git a/main.c b/main.c index f8b5d81b..8899db59 100644 --- a/main.c +++ b/main.c @@ -672,8 +672,10 @@ out: if (use_lc_numeric) setlocale(LC_NUMERIC, ""); #endif - + + init_io(); output_fp = stdout; + if (do_debug) debug_prog(code_block); else -- cgit v1.2.3 From b3dcc664da5e5234af8fbc1e2725788b614c747c Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 2 Jan 2012 21:36:16 +0200 Subject: Stylistic edits. --- ChangeLog | 6 ++++++ io.c | 49 +++++++++++++++++++++++++++---------------------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8fe80acf..f5d1a8ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-01-02 Arnold D. Robbins + + * io.c (Read_can_timeout, Read_timeout, Read_default_timeout): + Renamed to use lower case. + Other minor stylistic edits. + 2012-01-01 John Haque * awk.h (struct iobuf): New entry read_func. diff --git a/io.c b/io.c index ca59b5c4..46dba960 100644 --- a/io.c +++ b/io.c @@ -214,9 +214,9 @@ static ssize_t read_with_timeout(int fd, char *buf, size_t size); #include "popen.h" #endif -static int Read_can_timeout = FALSE; -static long Read_timeout; -static long Read_default_timeout; +static int read_can_timeout = FALSE; +static long read_timeout; +static long read_default_timeout; static struct redirect *red_head = NULL; static NODE *RS = NULL; @@ -239,22 +239,24 @@ init_io() { long tmout; - /* N.B.: all these hacks are to minimize the affect + /* + * N.B.: all these hacks are to minimize the effect * on programs that do not care about timeout. */ /* Parse the env. variable only once */ tmout = getenv_long("GAWK_READ_TIMEOUT"); if (tmout > 0) { - Read_default_timeout = tmout; - Read_can_timeout = TRUE; + read_default_timeout = tmout; + read_can_timeout = TRUE; } - /* PROCINFO entries for timeout are dynamic; + /* + * PROCINFO entries for timeout are dynamic; * We can't be any more specific than this. */ if (PROCINFO_node != NULL) - Read_can_timeout = TRUE; + read_can_timeout = TRUE; } @@ -479,7 +481,7 @@ remap_std_file(int oldfd) int ret = -1; /* - * Give OS-specific routines in gawkmisc.c chance to interpret + * Give OS-specific routines in gawkmisc.c a chance to interpret * "/dev/null" as appropriate for their platforms. */ newfd = os_devopen("/dev/null", O_RDWR); @@ -3016,8 +3018,8 @@ get_a_record(char **out, /* pointer to pointer to data */ if (at_eof(iop) && no_data_left(iop)) return EOF; - if (Read_can_timeout) - Read_timeout = get_read_timeout(iop); + if (read_can_timeout) + read_timeout = get_read_timeout(iop); if (iop->get_record != NULL) return (*iop->get_record)(out, iop, errcode); @@ -3315,7 +3317,8 @@ inetfile(const char *str, int *length, int *family) return ret; } -/* in_PROCINFO --- return value for a PROCINFO element with +/* + * in_PROCINFO --- return value for a PROCINFO element with * SUBSEP seperated indices. */ @@ -3346,7 +3349,8 @@ in_PROCINFO(const char *pidx1, const char *pidx2, NODE **full_idx) sub->stlen = str_len; } - sprintf(sub->stptr, "%s%.*s%s", pidx1, subsep->stlen, subsep->stptr, pidx2); + sprintf(sub->stptr, "%s%.*s%s", pidx1, (int)subsep->stlen, + subsep->stptr, pidx2); r = in_array(PROCINFO_node, sub); if (! full_idx) unref(sub); @@ -3360,7 +3364,6 @@ static long get_read_timeout(IOBUF *iop) { long tmout = 0; - char *cp; if (PROCINFO_node != NULL) { const char *name = iop->name; @@ -3368,8 +3371,9 @@ get_read_timeout(IOBUF *iop) static NODE *full_idx = NULL; static const char *last_name = NULL; - /* Do not re-construct the full index when last redirection string is - * the same as the current; "efficiency_hack++". + /* + * Do not re-construct the full index when last redirection + * string is the same as the current; "efficiency_hack++". */ if (full_idx == NULL || strcmp(name, last_name) != 0) { val = in_PROCINFO(name, "READ_TIMEOUT", & full_idx); @@ -3379,15 +3383,16 @@ get_read_timeout(IOBUF *iop) if (val != NULL) tmout = (long) force_number(val); } else - tmout = Read_default_timeout; /* initialized from env. variable in init_io() */ + tmout = read_default_timeout; /* initialized from env. variable in init_io() */ iop->read_func = tmout > 0 ? read_with_timeout : ( ssize_t(*)() ) read; return tmout; } -/* read_with_timeout --- read with a timeout, return failure - if no data is available within the timeout period. -*/ +/* + * read_with_timeout --- read with a timeout, return failure + * if no data is available within the timeout period. + */ static ssize_t read_with_timeout(int fd, char *buf, size_t size) @@ -3395,8 +3400,8 @@ read_with_timeout(int fd, char *buf, size_t size) fd_set readfds; struct timeval tv; - tv.tv_sec = Read_timeout / 1000; - tv.tv_usec = 1000 * (Read_timeout - 1000 * tv.tv_sec); + tv.tv_sec = read_timeout / 1000; + tv.tv_usec = 1000 * (read_timeout - 1000 * tv.tv_sec); FD_ZERO(& readfds); FD_SET(fd, & readfds); -- cgit v1.2.3 From 7ae469692932aae4a587f746dbff61c1d8b12eb9 Mon Sep 17 00:00:00 2001 From: john haque Date: Fri, 3 Feb 2012 09:20:53 -0600 Subject: Read timeout documentation and bug fix. --- doc/ChangeLog | 3 ++ doc/gawk.1 | 12 +++++++ doc/gawk.texi | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ io.c | 5 ++- 4 files changed, 131 insertions(+), 1 deletion(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index eb9bbf45..2307bde2 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,6 @@ +2021-02-03 John Haque + * gawk.texi, gawk.1: Add text on read timeout. + 2011-12-28 Arnold D. Robbins * awkcard.in, gawk.1: Minor edits after merge of executables. diff --git a/doc/gawk.1 b/doc/gawk.1 index 662ace35..eab20467 100644 --- a/doc/gawk.1 +++ b/doc/gawk.1 @@ -1129,6 +1129,14 @@ 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["input", "READ_TIMEOUT"]\fP +specifies the timeout in milliseconds for reading data from +.I input +, where +.I input +is a redirection string or a filename. A value of zero or +less than zero means no timeout. +.TP \fBPROCINFO["version"]\fP the version of .IR gawk . @@ -3587,6 +3595,10 @@ and .B \-\^\-file options. .PP +The GAWK_READ_TIMEOUT environment variable can be used to specify a timeout +in milliseconds for reading input from a terminal, pipe +or two-way communication including sockets. +.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 diff --git a/doc/gawk.texi b/doc/gawk.texi index 13681850..885bf0ef 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -393,6 +393,7 @@ particular records in a file and perform operations upon them. * Getline Notes:: Important things to know about @code{getline}. * Getline Summary:: Summary of @code{getline} Variants. +* Read Timeout:: Reading input with timeout. * Command line directories:: What happens if you put a directory on the command line. * Print:: The @code{print} statement. @@ -3655,6 +3656,11 @@ 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. + +@item GAWK_READ_TIMEOUT +Specifies the time, in milliseconds, for @command{gawk} to +wait for input before returning with error. +@xref{Read Timeout}. @end table The environment variables in the following list are meant @@ -5137,6 +5143,8 @@ used with it do not have to be named on the @command{awk} command line * Multiple Line:: Reading multi-line records. * Getline:: Reading files under explicit program control using the @code{getline} function. +* Read Timeout:: Reading input with timeout. + * Command line directories:: What happens if you put a directory on the command line. @end menu @@ -7215,6 +7223,110 @@ and whether the variant is standard or a @command{gawk} extension. @c ENDOFRANGE inex @c ENDOFRANGE infir +@node Read Timeout +@section Reading Input with Timeout +@cindex timeout, reading input + +You may specify a timeout in milliseconds for reading input from a terminal, +pipe or two-way communication including TCP/IP sockets. This can be done +on a per input, command or connection basis, by setting a special element +in the @code{PROCINFO} array: + +@example +PROCINFO["input_name", "READ_TIMEOUT"] = timeout in milliseconds +@end example + +When set, this will cause @command{gawk} to time out and return failure +if no data is available to read within the specified timeout period. +For example, a TCP client can decide to give up on receiving +any response from the server after a certain amount of time: + +@example +Service = "/inet/tcp/0/localhost/daytime" +PROCINFO[Service, "READ_TIMEOUT"] = 100 +if ((Service |& getline) > 0) + print $0 +else if (ERRNO != "") + print ERRNO +@end example + +Here is how to read interactively from the terminal without waiting +for more than 5 seconds: + +@example +PROCINFO["/dev/stdin", "READ_TIMEOUT"] = 5000 +while ((getline < "/dev/stdin") > 0) + print $0 +@end example + +@command{gawk} will terminate the read operation if input does not +arrive after waiting for the timeout period, return failure +and set the @code{ERRNO} variable to an appropriate string value. +A negative or zero value for the timeout is the same as specifying +no timeout at all. + +Timeout can also be set for reading from terminal in the implicit loop +like so: + +@example +$ @kbd{ gawk 'BEGIN @{ PROCINFO["-", "READ_TIMEOUT"] = 5000 @}} +> @kbd{@{ print "You entered: " $0 @}'} +@kbd{gawk} +@print{} You entered: gawk +@end example + +In this case, failure to respond within 5 seconds will result in the following +error message: + +@example +@error{} gawk: cmd. line:2: (FILENAME=- FNR=1) fatal: error reading input file `-': Connection timed out +@end example + +The timeout can be set or changed at any time, and will take effect on the +next attempt to read from the input device. In the following example, +we start with a timeout value of one second, and progressively +reduce it by one-tenth of a second until we wait indefinitely +for the input to arrive: + +@example +PROCINFO[Service, "READ_TIMEOUT"] = 1000 +while ((Service |& getline) > 0) @{ + print $0 + PROCINFO[S, "READ_TIMEOUT"] -= 100 +@} +@end example + +@quotation NOTE +You should not assume that the read operation will block +exactly after the 10th record has been printed. It is possible that +@command{gawk} will read and buffer more than one record +worth of data the first time. Because of this, changing the value +of timeout like in the above example has very little usefulness, +if any at all. +@end quotation + +If the @code{PROCINFO} element is not present and the environment +variable @env{GAWK_READ_TIMEOUT} exists, +gawk will use it to initialize the timeout value. +The exclusive use of the environment variable to specify timeout +has the disadvantage of not being able to control it +on a per command or connection basis. + +Gawk considers a timeout event an error even though +the attempt to read from the underlying device may +succeed in a later attempt. This is a limitation, and it also +means that you cannot use this to multiplex input from +two or more sources. + +Assigning a timeout value prevents read operations from +blocking indefinitely. But bear in mind that there are other ways +@command{gawk} can stall waiting for an input device to be ready. +A network client can sometimes take a long time to establish +a connection before it can start reading any data, +or the attempt to open a FIFO special file for reading can block +indefinitely until some other process opens it for writing. + + @node Command line directories @section Directories On The Command Line @cindex directories, command line diff --git a/io.c b/io.c index 46dba960..25f32e21 100644 --- a/io.c +++ b/io.c @@ -3377,9 +3377,12 @@ get_read_timeout(IOBUF *iop) */ if (full_idx == NULL || strcmp(name, last_name) != 0) { val = in_PROCINFO(name, "READ_TIMEOUT", & full_idx); - last_name = name; + if (last_name != NULL) + efree(last_name); + last_name = estrdup(name, strlen(name)); } else /* use cached full index */ val = in_array(PROCINFO_node, full_idx); + if (val != NULL) tmout = (long) force_number(val); } else -- cgit v1.2.3 From cd44d957787e162df4348028c22e8b9621000790 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Mon, 6 Feb 2012 21:40:45 +0200 Subject: Minor edits to John's changes. --- doc/ChangeLog | 7 ++++++- doc/gawk.1 | 8 +++++--- doc/gawk.texi | 34 +++++++++++++++++----------------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 2307bde2..2bbb982d 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,9 @@ -2021-02-03 John Haque +2012-02-06 Arnold D. Robbins + + * gawk.texi, gawk.1: And some minor edits thereunto. + +2012-02-03 John Haque + * gawk.texi, gawk.1: Add text on read timeout. 2011-12-28 Arnold D. Robbins diff --git a/doc/gawk.1 b/doc/gawk.1 index eab20467..07a8d0e3 100644 --- a/doc/gawk.1 +++ b/doc/gawk.1 @@ -1131,8 +1131,8 @@ depending on how the elements of the array are to be ordered. .TP \fBPROCINFO["input", "READ_TIMEOUT"]\fP specifies the timeout in milliseconds for reading data from -.I input -, where +.IR input , +where .I input is a redirection string or a filename. A value of zero or less than zero means no timeout. @@ -3595,7 +3595,9 @@ and .B \-\^\-file options. .PP -The GAWK_READ_TIMEOUT environment variable can be used to specify a timeout +The +.B GAWK_READ_TIMEOUT +environment variable can be used to specify a timeout in milliseconds for reading input from a terminal, pipe or two-way communication including sockets. .PP diff --git a/doc/gawk.texi b/doc/gawk.texi index 885bf0ef..5b3dd71c 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -393,7 +393,7 @@ particular records in a file and perform operations upon them. * Getline Notes:: Important things to know about @code{getline}. * Getline Summary:: Summary of @code{getline} Variants. -* Read Timeout:: Reading input with timeout. +* Read Timeout:: Reading input with a timeout. * Command line directories:: What happens if you put a directory on the command line. * Print:: The @code{print} statement. @@ -3659,7 +3659,7 @@ the value is rounded up to an integral number of seconds. @item GAWK_READ_TIMEOUT Specifies the time, in milliseconds, for @command{gawk} to -wait for input before returning with error. +wait for input before returning with an error. @xref{Read Timeout}. @end table @@ -5143,7 +5143,7 @@ used with it do not have to be named on the @command{awk} command line * Multiple Line:: Reading multi-line records. * Getline:: Reading files under explicit program control using the @code{getline} function. -* Read Timeout:: Reading input with timeout. +* Read Timeout:: Reading input with a timeout. * Command line directories:: What happens if you put a directory on the command line. @@ -7224,16 +7224,16 @@ and whether the variant is standard or a @command{gawk} extension. @c ENDOFRANGE infir @node Read Timeout -@section Reading Input with Timeout +@section Reading Input With A Timeout @cindex timeout, reading input You may specify a timeout in milliseconds for reading input from a terminal, -pipe or two-way communication including TCP/IP sockets. This can be done +pipe or two-way communication including, TCP/IP sockets. This can be done on a per input, command or connection basis, by setting a special element in the @code{PROCINFO} array: @example -PROCINFO["input_name", "READ_TIMEOUT"] = timeout in milliseconds +PROCINFO["input_name", "READ_TIMEOUT"] = @var{timeout in milliseconds} @end example When set, this will cause @command{gawk} to time out and return failure @@ -7250,8 +7250,9 @@ else if (ERRNO != "") print ERRNO @end example -Here is how to read interactively from the terminal without waiting -for more than 5 seconds: +Here is how to read interactively from the terminal@footnote{This assumes +that standard input is the keyboard} without waiting +for more than five seconds: @example PROCINFO["/dev/stdin", "READ_TIMEOUT"] = 5000 @@ -7265,7 +7266,8 @@ and set the @code{ERRNO} variable to an appropriate string value. A negative or zero value for the timeout is the same as specifying no timeout at all. -Timeout can also be set for reading from terminal in the implicit loop +A timeout can also be set for reading from the terminal in the implicit +loop that reads input records and matches them against patterns, like so: @example @@ -7275,7 +7277,7 @@ $ @kbd{ gawk 'BEGIN @{ PROCINFO["-", "READ_TIMEOUT"] = 5000 @}} @print{} You entered: gawk @end example -In this case, failure to respond within 5 seconds will result in the following +In this case, failure to respond within five seconds results in the following error message: @example @@ -7298,21 +7300,20 @@ while ((Service |& getline) > 0) @{ @quotation NOTE You should not assume that the read operation will block -exactly after the 10th record has been printed. It is possible that -@command{gawk} will read and buffer more than one record +exactly after the tenth record has been printed. It is possible that +@command{gawk} will read and buffer more than one record's worth of data the first time. Because of this, changing the value -of timeout like in the above example has very little usefulness, -if any at all. +of timeout like in the above example is not very useful. @end quotation If the @code{PROCINFO} element is not present and the environment variable @env{GAWK_READ_TIMEOUT} exists, -gawk will use it to initialize the timeout value. +@command{gawk} uses its value to initialize the timeout value. The exclusive use of the environment variable to specify timeout has the disadvantage of not being able to control it on a per command or connection basis. -Gawk considers a timeout event an error even though +@command{gawk} considers a timeout event to be an error even though the attempt to read from the underlying device may succeed in a later attempt. This is a limitation, and it also means that you cannot use this to multiplex input from @@ -7326,7 +7327,6 @@ a connection before it can start reading any data, or the attempt to open a FIFO special file for reading can block indefinitely until some other process opens it for writing. - @node Command line directories @section Directories On The Command Line @cindex directories, command line -- cgit v1.2.3