diff options
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | TODO | 12 | ||||
-rw-r--r-- | awk.h | 62 | ||||
-rw-r--r-- | builtin.c | 26 | ||||
-rw-r--r-- | doc/ChangeLog | 8 | ||||
-rw-r--r-- | doc/awkcard.in | 44 | ||||
-rw-r--r-- | doc/gawk.1 | 4 | ||||
-rw-r--r-- | doc/gawk.info | 612 | ||||
-rw-r--r-- | doc/gawk.texi | 24 | ||||
-rw-r--r-- | eval.c | 1 | ||||
-rw-r--r-- | extension/ChangeLog | 5 | ||||
-rw-r--r-- | extension/filefuncs.c | 8 | ||||
-rw-r--r-- | extension/readdir.c | 8 | ||||
-rw-r--r-- | extension/revoutput.c | 14 | ||||
-rw-r--r-- | extension/revtwoway.c | 9 | ||||
-rw-r--r-- | extension/rwarray.c | 66 | ||||
-rw-r--r-- | extension/rwarray0.c | 60 | ||||
-rw-r--r-- | extension/testext.c | 2 | ||||
-rw-r--r-- | gawkapi.h | 5 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | node.c | 15 | ||||
-rw-r--r-- | regcomp.c | 15 | ||||
-rw-r--r-- | regex.c | 5 | ||||
-rw-r--r-- | regex_internal.h | 4 | ||||
-rw-r--r-- | regexec.c | 8 |
26 files changed, 560 insertions, 490 deletions
@@ -1,3 +1,30 @@ +2012-11-30 Arnold D. Robbins <arnold@skeeve.com> + + * regcomp.c, regex.c, regex_internal.h, regexec.c: Sync + with GLIBC. Why not. + + * gawkapi.c (awk_bool_t): Change into an enum with awk_false and + awk_true values. + +2012-01-30 Andrew J. Schorr <aschorr@telemetry-investments.com> + + Further cleanups of macros in awk.h + + * awk.h (_r, _t): Remove declarations. + (unref, m_force_string): Remove macros. + (r_unref): Move declaration. + (r_force_string): Remove declaration. + (DEREF, force_string, force_number, unref): Now inline functions. + (POP_STRING, TOP_STRING): Back to macros. + * eval.c (_t): Remove definition. + * main.c (_r): Remove definition. + * node.c (r_force_string): Remove. + +2012-11-27 Arnold D. Robbins <arnold@skeeve.com> + + * builtin.c (do_fflush): Make fflush() and fflush("") both + flush everything. See the comment in the code. + 2012-11-26 Arnold D. Robbins <arnold@skeeve.com> * awk.h (Node_old_ext_func, Op_old_ext_func): New enum values. @@ -28,6 +28,8 @@ Changes from 4.0.2 to 4.1 with a minimum of two. 8. New arrays: SYMTAB, FUNCTAB, and PROCINFO["identifiers"]. See the manual. + +9. fflush() and fflush("") now both flush everything. See the manual. Changes from 4.0.1 to 4.0.2 --------------------------- @@ -14,6 +14,18 @@ TODO Minor Cleanups and Code Improvements ------------------------------------ + Fix all *assoc_lookup() = xxx calls. + + Make GAWKDEBUG pass the test suite. + + API: + awk_true and awk_false ??? + DONE: Update doc to use gcc -o filefuncs.so -shared filefuncs.o + instead of ld ... + ??? #if !defined(GAWK) && !defined(GAWK_OMIT_CONVENIENCE_MACROS) + + Make fflush() and fflush("") both flush all files, as in BWK awk. + ?? Add debugger commands to reference card FIX regular field splitting to use FPAT algorithm. @@ -1049,9 +1049,6 @@ extern afunc_t str_array_func[]; extern afunc_t cint_array_func[]; extern afunc_t int_array_func[]; -extern NODE *_t; /* used as temporary in macros */ -extern NODE *_r; /* used as temporary in macros */ - extern BLOCK nextfree[]; extern bool field0_valid; @@ -1172,7 +1169,14 @@ extern STACK_ITEM *stack_top; #define UPREF(r) (void) ((r)->valref++) -#define DEREF(r) ( _r = (r), (--_r->valref == 0) ? r_unref(_r) : (void)0 ) +extern void r_unref(NODE *tmp); + +static inline void +DEREF(NODE *r) +{ + if (--r->valref == 0) + r_unref(r); +} #define POP_NUMBER() force_number(POP_SCALAR()) #define TOP_NUMBER() force_number(TOP_SCALAR()) @@ -1253,24 +1257,33 @@ extern STACK_ITEM *stack_top; #define efree(p) free(p) -#define force_string(s) (_t = (s), m_force_string(_t)) +static inline NODE * +force_string(NODE *s) +{ + if ((s->flags & STRCUR) != 0 + && (s->stfmt == -1 || s->stfmt == CONVFMTidx) + ) + return s; + return format_val(CONVFMT, CONVFMTidx, s); +} #ifdef GAWKDEBUG #define unref r_unref -#define m_force_string r_force_string -extern NODE *r_force_string(NODE *s); #define force_number str2number #else /* not GAWKDEBUG */ -#define unref(r) ( _r = (r), (_r == NULL || --_r->valref > 0) ? \ - (void)0 : r_unref(_r) ) - -#define m_force_string(_ts) (((_ts->flags & STRCUR) && \ - (_ts->stfmt == -1 || _ts->stfmt == CONVFMTidx)) ? \ - _ts : format_val(CONVFMT, CONVFMTidx, _ts)) +static inline void +unref(NODE *r) +{ + if (r != NULL && --r->valref <= 0) + r_unref(r); +} -#define force_number(n) (_t = (n), \ - (_t->flags & NUMCUR) ? _t : str2number(_t)) +static inline NODE * +force_number(NODE *n) +{ + return (n->flags & NUMCUR) ? n : str2number(n); +} #endif /* GAWKDEBUG */ @@ -1571,7 +1584,6 @@ extern NODE *r_format_val(const char *format, int index, NODE *s); extern NODE *r_dupnode(NODE *n); extern NODE *make_str_node(const char *s, size_t len, int flags); extern void *more_blocks(int id); -extern void r_unref(NODE *tmp); extern int parse_escape(const char **string_ptr); #if MBS_SUPPORT extern NODE *str2wstr(NODE *n, size_t **ptr); @@ -1733,24 +1745,10 @@ TOP_SCALAR() } /* POP_STRING --- pop the string at the top of the stack */ - -static inline NODE * -POP_STRING() -{ - NODE *s = POP_SCALAR(); - - return m_force_string(s); -} +#define POP_STRING() force_string(POP_SCALAR()) /* TOP_STRING --- get the string at the top of the stack */ - -static inline NODE * -TOP_STRING() -{ - NODE *s = TOP_SCALAR(); - - return m_force_string(s); -} +#define TOP_STRING() force_string(TOP_SCALAR()) /* in_array --- return pointer to element in array if there */ @@ -182,24 +182,40 @@ do_fflush(int nargs) int status = 0; const char *file; - /* fflush() --- flush stdout */ + /* + * November, 2012. + * It turns out that circa 2002, when BWK + * added fflush() and fflush("") to his awk, he made both of + * them flush everything. + * + * Now, with our inside agent getting ready to try to get fflush() + * standardized in POSIX, we are going to make our awk consistent + * with his. This should not really affect anyone, as flushing + * everything also flushes stdout. + * + * So. Once upon a time: + * fflush() --- flush stdout + * fflush("") --- flush everything + * Now, both calls flush everything. + */ + + /* fflush() */ if (nargs == 0) { - if (output_fp != stdout) - (void) fflush(output_fp); - status = fflush(stdout); + status = flush_io(); return make_number((AWKNUM) status); } tmp = POP_STRING(); file = tmp->stptr; - /* fflush("") --- flush all */ + /* fflush("") */ if (tmp->stlen == 0) { status = flush_io(); DEREF(tmp); return make_number((AWKNUM) status); } + /* fflush("/some/path") */ rp = getredirect(tmp->stptr, tmp->stlen); status = -1; if (rp != NULL) { diff --git a/doc/ChangeLog b/doc/ChangeLog index 4f38e319..21a1c976 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,11 @@ +2012-11-27 Arnold D. Robbins <arnold@skeeve.com> + + * gawk.texi: API chapter. Change command for making shared libs + to use gcc, not ld. Thanks to Nelson Beebe. + (I/O Functions): Document new behavior for fflush(). + * gawk.1: Update for fflush(). + * awkcard.in: Ditto. And some general cleanup. + 2012-11-24 Arnold D. Robbins <arnold@skeeve.com> * gawk.texi (Future Extensions): Point to TODO file in the diff --git a/doc/awkcard.in b/doc/awkcard.in index 9fae7cce..2d003ca2 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -316,10 +316,6 @@ Disable common and GNU extensions.\*(CB .in +4n .TI "\*(FC\-r\*(FR, \*(FC\-\^\-re\-interval\*(FR Enable \*(FIinterval expressions\*(FR. -... in regular -... expression matching (see \fHRegular -... Expressions\fP below). Useful if -... \*(FC\-\^\-traditional\*(FR is specified .TI "\*(FC\-S\*(FR, \*(FC\-\^\-sandbox\*(FR Disable the \*(FCsystem()\*(FR function, input redirection with \*(FCgetline\*(FR, @@ -551,7 +547,6 @@ variables, each element being the value of that variable. T} \*(CB\*(FCERRNO\fP T{ -... String describing the error if a String error value if a \*(FCgetline\*(FR redirection or read @@ -599,11 +594,6 @@ T} \*(CB\*(FCLINT\fP T{ Provides dynamic control of the \*(FC\-\^\-lint\fP option from within an AWK program. -... When true, \*(GK -... prints lint warnings. -... When assigned the string value \*(FC"fatal"\*(FR, -... lint warnings become fatal errors. -... Any other true value just prints warnings. T} \*(CD\*(FCNF\fP T{ Number of fields in the current input record. @@ -1298,11 +1288,16 @@ T} \*(FCgetline \*(FIv \*(FC< \*(FIfile\*(FR Set \*(FIv\fP from next record of \*(FIfile\*(FR. \*(FIcmd \*(FC| getline\*(FR Pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR. \*(FIcmd \*(FC| getline \*(FIv\*(FR Pipe into \*(FCgetline\*(FR; set \*(FIv\*(FR. -\*(CB\*(FIcmd \*(FC|& getline\*(FR Co-process pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR. +.\" \*(CB\*(FIcmd \*(FC|& getline\*(FR Co-process pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR. .TE .fi .in +.2i .ti -.2i +\*(CB\*(FIcmd \*(FC|& getline\*(FR +.br +Co-process pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR. +.br +.ti -.2i \*(FIcmd \*(FC|& getline \*(FIv\*(FR .br Co-process pipe into \*(FCgetline\*(FR; set \*(FIv\*(FR. @@ -1320,10 +1315,10 @@ execute any \*(FCEND\fP rule(s). .br Stop processing the current input file. The next input record comes from the -next input file. \*(FCFILENAME\fP \*(CBand -\*(FCARGIND\fP\*(CD are updated, \*(FCFNR\fP is reset to 1, -and processing starts over with the first -pattern in the AWK program. Upon end +next input file. Update \*(FCFILENAME\fP \*(CBand +\*(FCARGIND\fP\*(CD, reset \*(FCFNR\fP to 1, +and start over with the first +pattern. Upon end of input data, execute any \*(FCEND\fP rule(s). .in -.2i .sp .5 @@ -1332,7 +1327,7 @@ of input data, execute any \*(FCEND\fP rule(s). \*(CBUpon an error, \*(FCERRNO\*(FR contains a string describing the problem.\*(CX .EB "\s+2\f(HBINPUT CONTROL\*(FR\s0" - +.sp .6 .\" --- Output Control .ES .fi @@ -1341,9 +1336,9 @@ the problem.\*(CX \*(CL\*(FCfflush(\*(FR[\*(FIfile\^\*(FR]\*(FC)\*(FR .br Flush any buffers associated -with the open output file or pipe \*(FIfile\*(FR.\*(CD -\*(CBIf no \*(FIfile\fP, then flush standard output. -If \*(FIfile\fP is null, then flush all open output files and pipes +with the open output file or pipe \*(FIfile\*(FR. +If no \*(FIfile\fP, or if +\*(FIfile\fP is null, then flush all open output files and pipes (\*(GK and \*(NK)\*(CD. .ti -.2i \*(FCprint\fP @@ -1390,7 +1385,7 @@ Print data down a pipeline to \*(FIcmd\*(FR. Print data down a pipeline to co-process \*(FIcmd\*(FR.\*(CX .in -.2i .EB "\s+2\f(HBOUTPUT CONTROL\*(FR\s0" - +.sp .6 .\" --- Closing Redirections .ES .fi @@ -1506,8 +1501,8 @@ T} Precision. The meaning of the \*(FIprec\*(FR varies by control letter: T} - \*(FC%d\*(FR, \*(FC%o\*(FR, \*(FC%i\*(FR, - \*(FC%u\*(FR, \*(FC%x\*(FR, \*(FC%X\fP T{ + \*(FC%d\*(FR,\|\*(FC%o\*(FR,\|\*(FC%i\fP, \0 + \*(FC%u\*(FR,\|\*(FC%x\*(FR,\|\*(FC%X\fP T{ The minimum number of digits to print. T} \*(FC%e\*(FR, \*(FC%E\*(FR, \*(FC%f\*(FR T{ @@ -1613,7 +1608,7 @@ l lw(2i). \*(FCexp(\*(FIexpr\*(FC)\*(FR The exponential function (\*(FIe \*(FC^ \*(FIx\*(FR). \*(FCint(\*(FIexpr\*(FC)\*(FR Truncate to integer. \*(FClog(\*(FIexpr\*(FC)\*(FR The natural logarithm function (base \*(FIe\^\*(FR). -\*(FCrand()\fP A random number between 0 and 1 (0 \(<= \*(FIN\fP < 1). +\*(FCrand()\fP A random number \*(FIN\fP such that 0 \(<= \*(FIN\fP < 1. \*(FCsin(\*(FIexpr\*(FC)\*(FR The sine of \*(FIexpr\fP, which is in radians. \*(FCsqrt(\*(FIexpr\*(FC)\*(FR The square root function. \&\*(FCsrand(\*(FR[\*(FIexpr\^\*(FR]\*(FC)\*(FR T{ @@ -1957,9 +1952,6 @@ GCC (the GNU Compiler Collection) works well. .in -.2i .nf .sp .4 -... Host: \*(FCftp.whidbey.net\*(FR -... File: \*(FC/pub/brennan/mawk1.3.3.tar.gz\fP -... \*(FChttp://www.skeeve.com/gawk/mawk1.3.3.tar.gz\fP Host: \*(FCinvisible-island.net\*(FR File: \*(FC/mawk/mawk.tar.gz\fP .in +.2i @@ -2212,9 +2212,7 @@ Flush any buffers associated with the open output file or pipe .IR file . If .I file -is missing, then flush standard output. -If -.I file +is missing or if it is the null string, then flush all open output files and pipes. .PP diff --git a/doc/gawk.info b/doc/gawk.info index 0b7fd8cc..ca986467 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -11930,12 +11930,20 @@ parameters are enclosed in square brackets ([ ]): 1994; it is not part of the POSIX standard and is not available if `--posix' has been specified on the command line (*note Options::). - `gawk' extends the `fflush()' function in two ways. The first is - to allow no argument at all. In this case, the buffer for the - standard output is flushed. The second is to allow the null string - (`""') as the argument. In this case, the buffers for _all_ open - output files and pipes are flushed. Brian Kernighan's `awk' also - supports these extensions. + `gawk' extends the `fflush()' function, as follows: If there is no + argument, or if the argument is the null string (`""'), `gawk' + flushes the buffers for _all_ open output files and pipes. Brian + Kernighan's `awk' also works this way. + + NOTE: Prior to version *FIXME: VERSION*, `gawk' would flush + only the standard output if there was no argument, and flush + all output files and pipes if the argument was the null + string. This was changed in order to be compatible with Brian + Kernighan's `awk', in the hope that standardizing this + feature in POSIX would then be easier. + + You can use `fflush("/dev/stdout")' if you wish to flush only + the standard output. `fflush()' returns zero if the buffer is successfully flushed; otherwise, it returns -1. In the case where all buffers are @@ -24148,7 +24156,7 @@ is the location of the `gawkapi.h' header file, the following steps(1) create a GNU/Linux shared library: $ gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -IIDIR filefuncs.c - $ ld -o filefuncs.so -shared filefuncs.o -lc + $ gcc -o filefuncs.so -shared filefuncs.o Once the library exists, it is loaded by using the `@load' keyword. @@ -29116,7 +29124,7 @@ Index * --re-interval option: Options. (line 272) * --sandbox option: Options. (line 279) * --sandbox option, disabling system() function: I/O Functions. - (line 85) + (line 93) * --sandbox option, input redirection with getline: Getline. (line 19) * --sandbox option, output redirection with print, printf: Redirection. (line 6) @@ -29285,7 +29293,7 @@ Index * Ada programming language: Glossary. (line 20) * adding, features to gawk: Adding Code. (line 6) * adding, fields: Changing Fields. (line 53) -* advanced features, buffering: I/O Functions. (line 98) +* advanced features, buffering: I/O Functions. (line 106) * advanced features, close() function: Close Files And Pipes. (line 131) * advanced features, constants, values of: Nondecimal-numbers. @@ -29598,8 +29606,8 @@ Index * Buening, Andreas <2>: Contributors. (line 92) * Buening, Andreas: Acknowledgments. (line 60) * buffering, input/output <1>: Two-way I/O. (line 70) -* buffering, input/output: I/O Functions. (line 130) -* buffering, interactive vs. noninteractive: I/O Functions. (line 98) +* buffering, input/output: I/O Functions. (line 138) +* buffering, interactive vs. noninteractive: I/O Functions. (line 106) * buffers, flushing: I/O Functions. (line 29) * buffers, operators for: GNU Regexp Operators. (line 48) @@ -30628,7 +30636,7 @@ Index (line 6) * integers: General Arithmetic. (line 6) * integers, unsigned: General Arithmetic. (line 15) -* interacting with other programs: I/O Functions. (line 63) +* interacting with other programs: I/O Functions. (line 71) * internationalization <1>: I18N and L10N. (line 6) * internationalization: I18N Functions. (line 6) * internationalization, localization <1>: Internationalization. @@ -31512,7 +31520,7 @@ Index * SYMTAB array: Auto-set. (line 254) * syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) -* system() function: I/O Functions. (line 63) +* system() function: I/O Functions. (line 71) * systime() function (gawk): Time Functions. (line 64) * t debugger command (alias for tbreak): Breakpoint Control. (line 90) * tbreak debugger command: Breakpoint Control. (line 90) @@ -31578,7 +31586,7 @@ Index (line 22) * troubleshooting, fatal errors, printf format strings: Format Modifiers. (line 159) -* troubleshooting, fflush() function: I/O Functions. (line 51) +* troubleshooting, fflush() function: I/O Functions. (line 59) * troubleshooting, function call syntax: Function Calls. (line 28) * troubleshooting, gawk: Compatibility Mode. (line 6) * troubleshooting, gawk, bug reports: Bugs. (line 9) @@ -31597,7 +31605,7 @@ Index (line 38) * troubleshooting, string concatenation: Concatenation. (line 27) * troubleshooting, substr() function: String Functions. (line 499) -* troubleshooting, system() function: I/O Functions. (line 85) +* troubleshooting, system() function: I/O Functions. (line 93) * troubleshooting, typographical errors, global variables: Options. (line 112) * true, logical: Truth Values. (line 6) @@ -31984,292 +31992,292 @@ Ref: table-gensub-escapes503206 Ref: Gory Details-Footnote-1504413 Ref: Gory Details-Footnote-2504464 Node: I/O Functions504615 -Ref: I/O Functions-Footnote-1511270 -Node: Time Functions511417 -Ref: Time Functions-Footnote-1522309 -Ref: Time Functions-Footnote-2522377 -Ref: Time Functions-Footnote-3522535 -Ref: Time Functions-Footnote-4522646 -Ref: Time Functions-Footnote-5522758 -Ref: Time Functions-Footnote-6522985 -Node: Bitwise Functions523251 -Ref: table-bitwise-ops523809 -Ref: Bitwise Functions-Footnote-1528030 -Node: Type Functions528214 -Node: I18N Functions528684 -Node: User-defined530311 -Node: Definition Syntax531115 -Ref: Definition Syntax-Footnote-1536025 -Node: Function Example536094 -Node: Function Caveats538688 -Node: Calling A Function539109 -Node: Variable Scope540224 -Node: Pass By Value/Reference543187 -Node: Return Statement546627 -Node: Dynamic Typing549608 -Node: Indirect Calls550343 -Node: Library Functions560028 -Ref: Library Functions-Footnote-1563027 -Node: Library Names563198 -Ref: Library Names-Footnote-1566669 -Ref: Library Names-Footnote-2566889 -Node: General Functions566975 -Node: Strtonum Function567928 -Node: Assert Function570858 -Node: Round Function574184 -Node: Cliff Random Function575727 -Node: Ordinal Functions576743 -Ref: Ordinal Functions-Footnote-1579813 -Ref: Ordinal Functions-Footnote-2580065 -Node: Join Function580274 -Ref: Join Function-Footnote-1582045 -Node: Getlocaltime Function582245 -Node: Data File Management585960 -Node: Filetrans Function586592 -Node: Rewind Function590731 -Node: File Checking592118 -Node: Empty Files593212 -Node: Ignoring Assigns595442 -Node: Getopt Function596995 -Ref: Getopt Function-Footnote-1608299 -Node: Passwd Functions608502 -Ref: Passwd Functions-Footnote-1617477 -Node: Group Functions617565 -Node: Walking Arrays625649 -Node: Sample Programs627218 -Node: Running Examples627895 -Node: Clones628623 -Node: Cut Program629847 -Node: Egrep Program639692 -Ref: Egrep Program-Footnote-1647465 -Node: Id Program647575 -Node: Split Program651191 -Ref: Split Program-Footnote-1654710 -Node: Tee Program654838 -Node: Uniq Program657641 -Node: Wc Program665070 -Ref: Wc Program-Footnote-1669336 -Ref: Wc Program-Footnote-2669536 -Node: Miscellaneous Programs669628 -Node: Dupword Program670816 -Node: Alarm Program672847 -Node: Translate Program677596 -Ref: Translate Program-Footnote-1681983 -Ref: Translate Program-Footnote-2682211 -Node: Labels Program682345 -Ref: Labels Program-Footnote-1685716 -Node: Word Sorting685800 -Node: History Sorting689684 -Node: Extract Program691523 -Ref: Extract Program-Footnote-1699006 -Node: Simple Sed699134 -Node: Igawk Program702196 -Ref: Igawk Program-Footnote-1717353 -Ref: Igawk Program-Footnote-2717554 -Node: Anagram Program717692 -Node: Signature Program720760 -Node: Internationalization721860 -Node: I18N and L10N723292 -Node: Explaining gettext723978 -Ref: Explaining gettext-Footnote-1729044 -Ref: Explaining gettext-Footnote-2729228 -Node: Programmer i18n729393 -Node: Translator i18n733593 -Node: String Extraction734386 -Ref: String Extraction-Footnote-1735347 -Node: Printf Ordering735433 -Ref: Printf Ordering-Footnote-1738217 -Node: I18N Portability738281 -Ref: I18N Portability-Footnote-1740730 -Node: I18N Example740793 -Ref: I18N Example-Footnote-1743428 -Node: Gawk I18N743500 -Node: Advanced Features744117 -Node: Nondecimal Data745621 -Node: Array Sorting747204 -Node: Controlling Array Traversal747901 -Node: Array Sorting Functions756139 -Ref: Array Sorting Functions-Footnote-1759813 -Ref: Array Sorting Functions-Footnote-2759906 -Node: Two-way I/O760100 -Ref: Two-way I/O-Footnote-1765532 -Node: TCP/IP Networking765602 -Node: Profiling768446 -Node: Debugger775900 -Node: Debugging776868 -Node: Debugging Concepts777301 -Node: Debugging Terms779157 -Node: Awk Debugging781754 -Node: Sample Debugging Session782646 -Node: Debugger Invocation783166 -Node: Finding The Bug784495 -Node: List of Debugger Commands790983 -Node: Breakpoint Control792317 -Node: Debugger Execution Control795981 -Node: Viewing And Changing Data799341 -Node: Execution Stack802697 -Node: Debugger Info804164 -Node: Miscellaneous Debugger Commands808145 -Node: Readline Support813590 -Node: Limitations814421 -Node: Arbitrary Precision Arithmetic816673 -Ref: Arbitrary Precision Arithmetic-Footnote-1818315 -Node: General Arithmetic818463 -Node: Floating Point Issues820183 -Node: String Conversion Precision821064 -Ref: String Conversion Precision-Footnote-1822770 -Node: Unexpected Results822879 -Node: POSIX Floating Point Problems825032 -Ref: POSIX Floating Point Problems-Footnote-1828857 -Node: Integer Programming828895 -Node: Floating-point Programming830648 -Ref: Floating-point Programming-Footnote-1836957 -Node: Floating-point Representation837221 -Node: Floating-point Context838386 -Ref: table-ieee-formats839228 -Node: Rounding Mode840612 -Ref: table-rounding-modes841091 -Ref: Rounding Mode-Footnote-1844095 -Node: Gawk and MPFR844276 -Node: Arbitrary Precision Floats845518 -Ref: Arbitrary Precision Floats-Footnote-1847947 -Node: Setting Precision848258 -Node: Setting Rounding Mode850991 -Ref: table-gawk-rounding-modes851395 -Node: Floating-point Constants852575 -Node: Changing Precision853999 -Ref: Changing Precision-Footnote-1855399 -Node: Exact Arithmetic855573 -Node: Arbitrary Precision Integers858681 -Ref: Arbitrary Precision Integers-Footnote-1861681 -Node: Dynamic Extensions861828 -Node: Extension Intro863214 -Node: Plugin License864422 -Node: Extension Design865096 -Node: Old Extension Problems866167 -Ref: Old Extension Problems-Footnote-1867677 -Node: Extension New Mechanism Goals867734 -Ref: Extension New Mechanism Goals-Footnote-1870446 -Node: Extension Other Design Decisions870632 -Node: Extension Mechanism Outline872744 -Ref: load-extension873769 -Ref: load-new-function875247 -Ref: call-new-function876228 -Node: Extension Future Growth878222 -Node: Extension API Description879040 -Node: Extension API Functions Introduction880368 -Node: General Data Types885068 -Ref: General Data Types-Footnote-1890701 -Node: Requesting Values891000 -Ref: table-value-types-returned891731 -Node: Constructor Functions892685 -Node: Registration Functions895681 -Node: Extension Functions896366 -Node: Exit Callback Functions898185 -Node: Extension Version String899428 -Node: Input Parsers900078 -Node: Output Wrappers908657 -Node: Two-way processors913050 -Node: Printing Messages915172 -Ref: Printing Messages-Footnote-1916249 -Node: Updating `ERRNO'916401 -Node: Accessing Parameters917140 -Node: Symbol Table Access918370 -Node: Symbol table by name918882 -Ref: Symbol table by name-Footnote-1921052 -Node: Symbol table by cookie921132 -Ref: Symbol table by cookie-Footnote-1925261 -Node: Cached values925324 -Ref: Cached values-Footnote-1928767 -Node: Array Manipulation928858 -Ref: Array Manipulation-Footnote-1929956 -Node: Array Data Types929995 -Ref: Array Data Types-Footnote-1932698 -Node: Array Functions932790 -Node: Flattening Arrays936556 -Node: Creating Arrays943389 -Node: Extension API Variables948184 -Node: Extension Versioning948820 -Node: Extension API Informational Variables950721 -Node: Extension API Boilerplate951807 -Node: Finding Extensions955641 -Node: Extension Example956188 -Node: Internal File Description956926 -Node: Internal File Ops960614 -Ref: Internal File Ops-Footnote-1972061 -Node: Using Internal File Ops972201 -Ref: Using Internal File Ops-Footnote-1974557 -Node: Extension Samples974823 -Node: Extension Sample File Functions976266 -Node: Extension Sample Fnmatch984739 -Node: Extension Sample Fork986465 -Node: Extension Sample Ord987679 -Node: Extension Sample Readdir988455 -Node: Extension Sample Revout989959 -Node: Extension Sample Rev2way990552 -Node: Extension Sample Read write array991242 -Node: Extension Sample Readfile993125 -Node: Extension Sample API Tests993880 -Node: Extension Sample Time994405 -Node: gawkextlib995712 -Node: Language History998093 -Node: V7/SVR3.1999615 -Node: SVR41001936 -Node: POSIX1003378 -Node: BTL1004386 -Node: POSIX/GNU1005120 -Node: Common Extensions1010655 -Node: Ranges and Locales1011762 -Ref: Ranges and Locales-Footnote-11016380 -Ref: Ranges and Locales-Footnote-21016407 -Ref: Ranges and Locales-Footnote-31016667 -Node: Contributors1016888 -Node: Installation1021184 -Node: Gawk Distribution1022078 -Node: Getting1022562 -Node: Extracting1023388 -Node: Distribution contents1025080 -Node: Unix Installation1030302 -Node: Quick Installation1030919 -Node: Additional Configuration Options1032881 -Node: Configuration Philosophy1034358 -Node: Non-Unix Installation1036700 -Node: PC Installation1037158 -Node: PC Binary Installation1038457 -Node: PC Compiling1040305 -Node: PC Testing1043249 -Node: PC Using1044425 -Node: Cygwin1048610 -Node: MSYS1049610 -Node: VMS Installation1050124 -Node: VMS Compilation1050727 -Ref: VMS Compilation-Footnote-11051734 -Node: VMS Installation Details1051792 -Node: VMS Running1053427 -Node: VMS Old Gawk1055034 -Node: Bugs1055508 -Node: Other Versions1059360 -Node: Notes1064675 -Node: Compatibility Mode1065334 -Node: Additions1066117 -Node: Accessing The Source1067044 -Node: Adding Code1068647 -Node: New Ports1074689 -Node: Derived Files1078824 -Ref: Derived Files-Footnote-11084132 -Ref: Derived Files-Footnote-21084166 -Ref: Derived Files-Footnote-31084766 -Node: Future Extensions1084864 -Node: Implementation Limitations1085445 -Node: Basic Concepts1086672 -Node: Basic High Level1087353 -Ref: figure-general-flow1087624 -Ref: figure-process-flow1088223 -Ref: Basic High Level-Footnote-11091452 -Node: Basic Data Typing1091637 -Node: Glossary1094992 -Node: Copying1120303 -Node: GNU Free Documentation License1157860 -Node: Index1182997 +Ref: I/O Functions-Footnote-1511639 +Node: Time Functions511786 +Ref: Time Functions-Footnote-1522678 +Ref: Time Functions-Footnote-2522746 +Ref: Time Functions-Footnote-3522904 +Ref: Time Functions-Footnote-4523015 +Ref: Time Functions-Footnote-5523127 +Ref: Time Functions-Footnote-6523354 +Node: Bitwise Functions523620 +Ref: table-bitwise-ops524178 +Ref: Bitwise Functions-Footnote-1528399 +Node: Type Functions528583 +Node: I18N Functions529053 +Node: User-defined530680 +Node: Definition Syntax531484 +Ref: Definition Syntax-Footnote-1536394 +Node: Function Example536463 +Node: Function Caveats539057 +Node: Calling A Function539478 +Node: Variable Scope540593 +Node: Pass By Value/Reference543556 +Node: Return Statement546996 +Node: Dynamic Typing549977 +Node: Indirect Calls550712 +Node: Library Functions560397 +Ref: Library Functions-Footnote-1563396 +Node: Library Names563567 +Ref: Library Names-Footnote-1567038 +Ref: Library Names-Footnote-2567258 +Node: General Functions567344 +Node: Strtonum Function568297 +Node: Assert Function571227 +Node: Round Function574553 +Node: Cliff Random Function576096 +Node: Ordinal Functions577112 +Ref: Ordinal Functions-Footnote-1580182 +Ref: Ordinal Functions-Footnote-2580434 +Node: Join Function580643 +Ref: Join Function-Footnote-1582414 +Node: Getlocaltime Function582614 +Node: Data File Management586329 +Node: Filetrans Function586961 +Node: Rewind Function591100 +Node: File Checking592487 +Node: Empty Files593581 +Node: Ignoring Assigns595811 +Node: Getopt Function597364 +Ref: Getopt Function-Footnote-1608668 +Node: Passwd Functions608871 +Ref: Passwd Functions-Footnote-1617846 +Node: Group Functions617934 +Node: Walking Arrays626018 +Node: Sample Programs627587 +Node: Running Examples628264 +Node: Clones628992 +Node: Cut Program630216 +Node: Egrep Program640061 +Ref: Egrep Program-Footnote-1647834 +Node: Id Program647944 +Node: Split Program651560 +Ref: Split Program-Footnote-1655079 +Node: Tee Program655207 +Node: Uniq Program658010 +Node: Wc Program665439 +Ref: Wc Program-Footnote-1669705 +Ref: Wc Program-Footnote-2669905 +Node: Miscellaneous Programs669997 +Node: Dupword Program671185 +Node: Alarm Program673216 +Node: Translate Program677965 +Ref: Translate Program-Footnote-1682352 +Ref: Translate Program-Footnote-2682580 +Node: Labels Program682714 +Ref: Labels Program-Footnote-1686085 +Node: Word Sorting686169 +Node: History Sorting690053 +Node: Extract Program691892 +Ref: Extract Program-Footnote-1699375 +Node: Simple Sed699503 +Node: Igawk Program702565 +Ref: Igawk Program-Footnote-1717722 +Ref: Igawk Program-Footnote-2717923 +Node: Anagram Program718061 +Node: Signature Program721129 +Node: Internationalization722229 +Node: I18N and L10N723661 +Node: Explaining gettext724347 +Ref: Explaining gettext-Footnote-1729413 +Ref: Explaining gettext-Footnote-2729597 +Node: Programmer i18n729762 +Node: Translator i18n733962 +Node: String Extraction734755 +Ref: String Extraction-Footnote-1735716 +Node: Printf Ordering735802 +Ref: Printf Ordering-Footnote-1738586 +Node: I18N Portability738650 +Ref: I18N Portability-Footnote-1741099 +Node: I18N Example741162 +Ref: I18N Example-Footnote-1743797 +Node: Gawk I18N743869 +Node: Advanced Features744486 +Node: Nondecimal Data745990 +Node: Array Sorting747573 +Node: Controlling Array Traversal748270 +Node: Array Sorting Functions756508 +Ref: Array Sorting Functions-Footnote-1760182 +Ref: Array Sorting Functions-Footnote-2760275 +Node: Two-way I/O760469 +Ref: Two-way I/O-Footnote-1765901 +Node: TCP/IP Networking765971 +Node: Profiling768815 +Node: Debugger776269 +Node: Debugging777237 +Node: Debugging Concepts777670 +Node: Debugging Terms779526 +Node: Awk Debugging782123 +Node: Sample Debugging Session783015 +Node: Debugger Invocation783535 +Node: Finding The Bug784864 +Node: List of Debugger Commands791352 +Node: Breakpoint Control792686 +Node: Debugger Execution Control796350 +Node: Viewing And Changing Data799710 +Node: Execution Stack803066 +Node: Debugger Info804533 +Node: Miscellaneous Debugger Commands808514 +Node: Readline Support813959 +Node: Limitations814790 +Node: Arbitrary Precision Arithmetic817042 +Ref: Arbitrary Precision Arithmetic-Footnote-1818684 +Node: General Arithmetic818832 +Node: Floating Point Issues820552 +Node: String Conversion Precision821433 +Ref: String Conversion Precision-Footnote-1823139 +Node: Unexpected Results823248 +Node: POSIX Floating Point Problems825401 +Ref: POSIX Floating Point Problems-Footnote-1829226 +Node: Integer Programming829264 +Node: Floating-point Programming831017 +Ref: Floating-point Programming-Footnote-1837326 +Node: Floating-point Representation837590 +Node: Floating-point Context838755 +Ref: table-ieee-formats839597 +Node: Rounding Mode840981 +Ref: table-rounding-modes841460 +Ref: Rounding Mode-Footnote-1844464 +Node: Gawk and MPFR844645 +Node: Arbitrary Precision Floats845887 +Ref: Arbitrary Precision Floats-Footnote-1848316 +Node: Setting Precision848627 +Node: Setting Rounding Mode851360 +Ref: table-gawk-rounding-modes851764 +Node: Floating-point Constants852944 +Node: Changing Precision854368 +Ref: Changing Precision-Footnote-1855768 +Node: Exact Arithmetic855942 +Node: Arbitrary Precision Integers859050 +Ref: Arbitrary Precision Integers-Footnote-1862050 +Node: Dynamic Extensions862197 +Node: Extension Intro863583 +Node: Plugin License864791 +Node: Extension Design865465 +Node: Old Extension Problems866536 +Ref: Old Extension Problems-Footnote-1868046 +Node: Extension New Mechanism Goals868103 +Ref: Extension New Mechanism Goals-Footnote-1870815 +Node: Extension Other Design Decisions871001 +Node: Extension Mechanism Outline873113 +Ref: load-extension874138 +Ref: load-new-function875616 +Ref: call-new-function876597 +Node: Extension Future Growth878591 +Node: Extension API Description879409 +Node: Extension API Functions Introduction880737 +Node: General Data Types885437 +Ref: General Data Types-Footnote-1891070 +Node: Requesting Values891369 +Ref: table-value-types-returned892100 +Node: Constructor Functions893054 +Node: Registration Functions896050 +Node: Extension Functions896735 +Node: Exit Callback Functions898554 +Node: Extension Version String899797 +Node: Input Parsers900447 +Node: Output Wrappers909026 +Node: Two-way processors913419 +Node: Printing Messages915541 +Ref: Printing Messages-Footnote-1916618 +Node: Updating `ERRNO'916770 +Node: Accessing Parameters917509 +Node: Symbol Table Access918739 +Node: Symbol table by name919251 +Ref: Symbol table by name-Footnote-1921421 +Node: Symbol table by cookie921501 +Ref: Symbol table by cookie-Footnote-1925630 +Node: Cached values925693 +Ref: Cached values-Footnote-1929136 +Node: Array Manipulation929227 +Ref: Array Manipulation-Footnote-1930325 +Node: Array Data Types930364 +Ref: Array Data Types-Footnote-1933067 +Node: Array Functions933159 +Node: Flattening Arrays936925 +Node: Creating Arrays943758 +Node: Extension API Variables948553 +Node: Extension Versioning949189 +Node: Extension API Informational Variables951090 +Node: Extension API Boilerplate952176 +Node: Finding Extensions956010 +Node: Extension Example956557 +Node: Internal File Description957295 +Node: Internal File Ops960983 +Ref: Internal File Ops-Footnote-1972430 +Node: Using Internal File Ops972570 +Ref: Using Internal File Ops-Footnote-1974923 +Node: Extension Samples975189 +Node: Extension Sample File Functions976632 +Node: Extension Sample Fnmatch985105 +Node: Extension Sample Fork986831 +Node: Extension Sample Ord988045 +Node: Extension Sample Readdir988821 +Node: Extension Sample Revout990325 +Node: Extension Sample Rev2way990918 +Node: Extension Sample Read write array991608 +Node: Extension Sample Readfile993491 +Node: Extension Sample API Tests994246 +Node: Extension Sample Time994771 +Node: gawkextlib996078 +Node: Language History998459 +Node: V7/SVR3.1999981 +Node: SVR41002302 +Node: POSIX1003744 +Node: BTL1004752 +Node: POSIX/GNU1005486 +Node: Common Extensions1011021 +Node: Ranges and Locales1012128 +Ref: Ranges and Locales-Footnote-11016746 +Ref: Ranges and Locales-Footnote-21016773 +Ref: Ranges and Locales-Footnote-31017033 +Node: Contributors1017254 +Node: Installation1021550 +Node: Gawk Distribution1022444 +Node: Getting1022928 +Node: Extracting1023754 +Node: Distribution contents1025446 +Node: Unix Installation1030668 +Node: Quick Installation1031285 +Node: Additional Configuration Options1033247 +Node: Configuration Philosophy1034724 +Node: Non-Unix Installation1037066 +Node: PC Installation1037524 +Node: PC Binary Installation1038823 +Node: PC Compiling1040671 +Node: PC Testing1043615 +Node: PC Using1044791 +Node: Cygwin1048976 +Node: MSYS1049976 +Node: VMS Installation1050490 +Node: VMS Compilation1051093 +Ref: VMS Compilation-Footnote-11052100 +Node: VMS Installation Details1052158 +Node: VMS Running1053793 +Node: VMS Old Gawk1055400 +Node: Bugs1055874 +Node: Other Versions1059726 +Node: Notes1065041 +Node: Compatibility Mode1065700 +Node: Additions1066483 +Node: Accessing The Source1067410 +Node: Adding Code1069013 +Node: New Ports1075055 +Node: Derived Files1079190 +Ref: Derived Files-Footnote-11084498 +Ref: Derived Files-Footnote-21084532 +Ref: Derived Files-Footnote-31085132 +Node: Future Extensions1085230 +Node: Implementation Limitations1085811 +Node: Basic Concepts1087038 +Node: Basic High Level1087719 +Ref: figure-general-flow1087990 +Ref: figure-process-flow1088589 +Ref: Basic High Level-Footnote-11091818 +Node: Basic Data Typing1092003 +Node: Glossary1095358 +Node: Copying1120669 +Node: GNU Free Documentation License1158226 +Node: Index1183363 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index fb008d74..6abc337f 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -16013,12 +16013,22 @@ not available if @option{--posix} has been specified on the command line (@pxref{Options}). @cindex @command{gawk}, @code{fflush()} function in -@command{gawk} extends the @code{fflush()} function in two ways. The first -is to allow no argument at all. In this case, the buffer for the -standard output is flushed. The second is to allow the null string -(@w{@code{""}}) as the argument. In this case, the buffers for -@emph{all} open output files and pipes are flushed. -Brian Kernighan's @command{awk} also supports these extensions. +@command{gawk} extends the @code{fflush()} function, as follows: If there +is no argument, or if the argument is the null string (@w{@code{""}}), +@command{gawk} flushes the buffers for @emph{all} open output files +and pipes. Brian Kernighan's @command{awk} also works this way. + +@quotation NOTE +Prior to version @strong{FIXME: VERSION}, @command{gawk} +would flush only the standard output if there was no argument, +and flush all output files and pipes if the argument was the null +string. This was changed in order to be compatible with Brian +Kernighan's @command{awk}, in the hope that standardizing this +feature in POSIX would then be easier. + +You can use @samp{fflush("/dev/stdout")} if you wish to flush +only the standard output. +@end quotation @c @cindex automatic warnings @c @cindex warnings, automatic @@ -31255,7 +31265,7 @@ the tools.} create a GNU/Linux shared library: @example $ @kbd{gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -I@var{idir} filefuncs.c} -$ @kbd{ld -o filefuncs.so -shared filefuncs.o -lc} +$ @kbd{gcc -o filefuncs.so -shared filefuncs.o} @end example Once the library exists, it is loaded by using the @code{@@load} keyword. @@ -43,7 +43,6 @@ static Func_post_exec post_execute = NULL; extern void frame_popped(); -NODE *_t; /* used as a temporary in macros */ int OFSlen; int ORSlen; int OFMTidx; diff --git a/extension/ChangeLog b/extension/ChangeLog index 932eb3a7..5b648f5c 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,8 @@ +2012-11-30 Arnold D. Robbins <arnold@skeeve.com> + + * filefuncs.c readdir.c, revoutput.c, revtwoway.c, rwarray.c, + rwarray0.c, testext.c: Use awk_true and awk_false instead of 1 and 0. + 2012-11-26 Arnold D. Robbins <arnold@skeeve.com> * bindarr.c, fileop.c, sparr.c: Make them compile. diff --git a/extension/filefuncs.c b/extension/filefuncs.c index c8ef0534..85c05b2e 100644 --- a/extension/filefuncs.c +++ b/extension/filefuncs.c @@ -475,7 +475,7 @@ fill_error_element(awk_array_t element_array, const int errcode) /* fill_default_elements --- fill in stat and path elements */ static void -fill_default_elements(awk_array_t element_array, const FTSENT *const fentry, int bad_ret) +fill_default_elements(awk_array_t element_array, const FTSENT *const fentry, awk_bool_t bad_ret) { /* full path */ fill_path_element(element_array, fentry->fts_path); @@ -501,12 +501,12 @@ process(FTS *heirarchy, awk_array_t destarray, int seedot) FTSENT *fentry; awk_value_t index, value; awk_array_t element_array, newdir_array, dot_array; - int bad_ret = 0; + awk_bool_t bad_ret = awk_false; /* path is full path, pathlen is length thereof */ /* name is name in directory, namelen is length thereof */ while ((fentry = fts_read(heirarchy)) != NULL) { - bad_ret = 0; + bad_ret = awk_false; switch (fentry->fts_info) { case FTS_D: @@ -542,7 +542,7 @@ process(FTS *heirarchy, awk_array_t destarray, int seedot) case FTS_ERR: case FTS_NS: /* error */ - bad_ret = 1; + bad_ret = awk_true; /* fall through */ case FTS_NSOK: diff --git a/extension/readdir.c b/extension/readdir.c index 05ac8b90..6aebf091 100644 --- a/extension/readdir.c +++ b/extension/readdir.c @@ -171,7 +171,7 @@ static awk_bool_t dir_can_take_file(const awk_input_buf_t *iobuf) { if (iobuf == NULL) - return 0; + return awk_false; return (iobuf->fd != INVALID_HANDLE && S_ISDIR(iobuf->sbuf.st_mode)); } @@ -201,7 +201,7 @@ dir_take_control_of(awk_input_buf_t *iobuf) warning(ext_id, _("dir_take_control_of: opendir/fdopendir failed: %s"), strerror(errno)); update_ERRNO_int(errno); - return 0; + return awk_false; } emalloc(the_dir, open_directory_t *, sizeof(open_directory_t), "dir_take_control_of"); @@ -213,7 +213,7 @@ dir_take_control_of(awk_input_buf_t *iobuf) iobuf->get_record = dir_get_record; iobuf->close_func = dir_close; - return 1; + return awk_true; } static awk_input_parser_t readdir_parser = { @@ -242,7 +242,7 @@ init_readdir() register_input_parser(& readdir_parser2); #endif - return 1; + return awk_true; } static awk_ext_func_t func_table[] = { diff --git a/extension/revoutput.c b/extension/revoutput.c index 0366672b..0536627f 100644 --- a/extension/revoutput.c +++ b/extension/revoutput.c @@ -79,10 +79,10 @@ revoutput_can_take_file(const awk_output_buf_t *outbuf) awk_value_t value; if (outbuf == NULL) - return 0; + return awk_false; if (! sym_lookup("REVOUT", AWK_NUMBER, & value)) - return 0; + return awk_false; return (value.num_value != 0); } @@ -97,11 +97,11 @@ static awk_bool_t revoutput_take_control_of(awk_output_buf_t *outbuf) { if (outbuf == NULL) - return 0; + return awk_false; outbuf->gawk_fwrite = rev_fwrite; - outbuf->redirected = 1; - return 1; + outbuf->redirected = awk_true; + return awk_true; } static awk_output_wrapper_t output_wrapper = { @@ -124,10 +124,10 @@ init_revoutput() if (! sym_update("REVOUT", & value)) { warning(ext_id, _("revoutput: could not initialize REVOUT variable")); - return 0; + return awk_false; } - return 1; + return awk_true; } static awk_ext_func_t func_table[] = { diff --git a/extension/revtwoway.c b/extension/revtwoway.c index 0008d634..13f0e778 100644 --- a/extension/revtwoway.c +++ b/extension/revtwoway.c @@ -280,7 +280,7 @@ revtwoway_take_control_of(const char *name, awk_input_buf_t *inbuf, awk_output_b two_way_proc_data_t *proc_data; if (inbuf == NULL || outbuf == NULL) - return 0; + return awk_false; emalloc(proc_data, two_way_proc_data_t *, sizeof(two_way_proc_data_t), "revtwoway_take_control_of"); proc_data->in_use = 2; @@ -304,8 +304,9 @@ revtwoway_take_control_of(const char *name, awk_input_buf_t *inbuf, awk_output_b outbuf->gawk_fflush = rev2way_fflush; outbuf->gawk_ferror = rev2way_ferror; outbuf->gawk_fclose = rev2way_fclose; - outbuf->redirected = 1; - return 1; + outbuf->redirected = awk_true; + + return awk_true; } static awk_two_way_processor_t two_way_processor = { @@ -324,7 +325,7 @@ init_revtwoway() max_fds = getdtablesize(); - return 1; + return awk_true; } static awk_ext_func_t func_table[] = { diff --git a/extension/rwarray.c b/extension/rwarray.c index 43118282..cf76f3f0 100644 --- a/extension/rwarray.c +++ b/extension/rwarray.c @@ -178,24 +178,24 @@ write_array(FILE *fp, awk_array_t array) if (! flatten_array(array, & flat_array)) { fprintf(stderr, _("write_array: could not flatten array\n")); - return 0; + return awk_false; } count = htonl(flat_array->count); if (fwrite(& count, 1, sizeof(count), fp) != sizeof(count)) - return 0; + return awk_false; for (i = 0; i < flat_array->count; i++) { if (! write_elem(fp, & flat_array->elements[i])) - return 0; + return awk_false; } if (! release_flattened_array(array, flat_array)) { fprintf(stderr, _("write_array: could not release flattened array\n")); - return 0; + return awk_false; } - return 1; + return awk_true; } /* write_elem --- write out a single element */ @@ -208,13 +208,13 @@ write_elem(FILE *fp, awk_element_t *element) indexval_len = htonl(element->index.str_value.len); if (fwrite(& indexval_len, 1, sizeof(indexval_len), fp) != sizeof(indexval_len)) - return 0; + return awk_false; if (element->index.str_value.len > 0) { write_count = fwrite(element->index.str_value.str, 1, element->index.str_value.len, fp); if (write_count != (ssize_t) element->index.str_value.len) - return 0; + return awk_false; } return write_value(fp, & element->value); @@ -222,7 +222,7 @@ write_elem(FILE *fp, awk_element_t *element) /* write_value --- write a number or a string or a array */ -static int +static awk_bool_t write_value(FILE *fp, awk_value_t *val) { uint32_t code, len; @@ -230,32 +230,32 @@ write_value(FILE *fp, awk_value_t *val) if (val->val_type == AWK_ARRAY) { code = htonl(2); if (fwrite(& code, 1, sizeof(code), fp) != sizeof(code)) - return 0; + return awk_false; return write_array(fp, val->array_cookie); } if (val->val_type == AWK_NUMBER) { code = htonl(1); if (fwrite(& code, 1, sizeof(code), fp) != sizeof(code)) - return 0; + return awk_false; if (fwrite(& val->num_value, 1, sizeof(val->num_value), fp) != sizeof(val->num_value)) - return 0; + return awk_false; } else { code = 0; if (fwrite(& code, 1, sizeof(code), fp) != sizeof(code)) - return 0; + return awk_false; len = htonl(val->str_value.len); if (fwrite(& len, 1, sizeof(len), fp) != sizeof(len)) - return 0; + return awk_false; if (fwrite(val->str_value.str, 1, val->str_value.len, fp) != (ssize_t) val->str_value.len) - return 0; + return awk_false; } - return 1; + return awk_true; } /* do_reada --- read an array */ @@ -358,9 +358,9 @@ read_array(FILE *fp, awk_array_t array) uint32_t count; awk_element_t new_elem; - if (fread(& count, 1, sizeof(count), fp) != sizeof(count)) { - return 0; - } + if (fread(& count, 1, sizeof(count), fp) != sizeof(count)) + return awk_false; + count = ntohl(count); for (i = 0; i < count; i++) { @@ -368,16 +368,16 @@ read_array(FILE *fp, awk_array_t array) /* add to array */ if (! set_array_element_by_elem(array, & new_elem)) { fprintf(stderr, _("read_array: set_array_element failed\n")); - return 0; + return awk_false; } } else break; } if (i != count) - return 0; + return awk_false; - return 1; + return awk_true; } /* read_elem --- read in a single element */ @@ -391,7 +391,7 @@ read_elem(FILE *fp, awk_element_t *element) ssize_t ret; if ((ret = fread(& index_len, 1, sizeof(index_len), fp)) != sizeof(index_len)) { - return 0; + return awk_false; } index_len = ntohl(index_len); @@ -407,14 +407,14 @@ read_elem(FILE *fp, awk_element_t *element) char *cp = realloc(buffer, index_len); if (cp == NULL) - return 0; + return awk_false; buffer = cp; buflen = index_len; } if (fread(buffer, 1, index_len, fp) != (ssize_t) index_len) { - return 0; + return awk_false; } make_const_string(buffer, index_len, & element->index); } else { @@ -422,9 +422,9 @@ read_elem(FILE *fp, awk_element_t *element) } if (! read_value(fp, & element->value)) - return 0; + return awk_false; - return 1; + return awk_true; } /* read_value --- read a number or a string */ @@ -435,15 +435,15 @@ read_value(FILE *fp, awk_value_t *value) uint32_t code, len; if (fread(& code, 1, sizeof(code), fp) != sizeof(code)) - return 0; + return awk_false; code = ntohl(code); if (code == 2) { awk_array_t array = create_array(); - if (read_array(fp, array) != 0) - return 0; + if (! read_array(fp, array)) + return awk_false; /* hook into value */ value->val_type = AWK_ARRAY; @@ -452,14 +452,14 @@ read_value(FILE *fp, awk_value_t *value) double d; if (fread(& d, 1, sizeof(d), fp) != sizeof(d)) - return 0; + return awk_false; /* hook into value */ value->val_type = AWK_NUMBER; value->num_value = d; } else { if (fread(& len, 1, sizeof(len), fp) != sizeof(len)) { - return 0; + return awk_false; } len = ntohl(len); value->val_type = AWK_STRING; @@ -469,11 +469,11 @@ read_value(FILE *fp, awk_value_t *value) if (fread(value->str_value.str, 1, len, fp) != (ssize_t) len) { free(value->str_value.str); - return 0; + return awk_false; } } - return 1; + return awk_true; } static awk_ext_func_t func_table[] = { diff --git a/extension/rwarray0.c b/extension/rwarray0.c index c50c6a38..353fb150 100644 --- a/extension/rwarray0.c +++ b/extension/rwarray0.c @@ -167,24 +167,24 @@ write_array(int fd, awk_array_t array) if (! flatten_array(array, & flat_array)) { fprintf(stderr, _("write_array: could not flatten array\n")); - return 0; + return awk_false; } count = htonl(flat_array->count); if (write(fd, & count, sizeof(count)) != sizeof(count)) - return 0; + return awk_false; for (i = 0; i < flat_array->count; i++) { if (! write_elem(fd, & flat_array->elements[i])) - return 0; + return awk_false; } if (! release_flattened_array(array, flat_array)) { fprintf(stderr, _("write_array: could not release flattened array\n")); - return 0; + return awk_false; } - return 1; + return awk_true; } /* write_elem --- write out a single element */ @@ -197,13 +197,13 @@ write_elem(int fd, awk_element_t *element) indexval_len = htonl(element->index.str_value.len); if (write(fd, & indexval_len, sizeof(indexval_len)) != sizeof(indexval_len)) - return 0; + return awk_false; if (element->index.str_value.len > 0) { write_count = write(fd, element->index.str_value.str, element->index.str_value.len); if (write_count != (ssize_t) element->index.str_value.len) - return 0; + return awk_false; } return write_value(fd, & element->value); @@ -211,7 +211,7 @@ write_elem(int fd, awk_element_t *element) /* write_value --- write a number or a string or a array */ -static int +static awk_bool_t write_value(int fd, awk_value_t *val) { uint32_t code, len; @@ -219,32 +219,32 @@ write_value(int fd, awk_value_t *val) if (val->val_type == AWK_ARRAY) { code = htonl(2); if (write(fd, & code, sizeof(code)) != sizeof(code)) - return 0; + return awk_false; return write_array(fd, val->array_cookie); } if (val->val_type == AWK_NUMBER) { code = htonl(1); if (write(fd, & code, sizeof(code)) != sizeof(code)) - return 0; + return awk_false; if (write(fd, & val->num_value, sizeof(val->num_value)) != sizeof(val->num_value)) - return 0; + return awk_false; } else { code = 0; if (write(fd, & code, sizeof(code)) != sizeof(code)) - return 0; + return awk_false; len = htonl(val->str_value.len); if (write(fd, & len, sizeof(len)) != sizeof(len)) - return 0; + return awk_false; if (write(fd, val->str_value.str, val->str_value.len) != (ssize_t) val->str_value.len) - return 0; + return awk_false; } - return 1; + return awk_true; } /* do_reada --- read an array */ @@ -347,7 +347,7 @@ read_array(int fd, awk_array_t array) awk_element_t new_elem; if (read(fd, & count, sizeof(count)) != sizeof(count)) { - return 0; + return awk_false; } count = ntohl(count); @@ -356,16 +356,16 @@ read_array(int fd, awk_array_t array) /* add to array */ if (! set_array_element_by_elem(array, & new_elem)) { fprintf(stderr, _("read_array: set_array_element failed\n")); - return 0; + return awk_false; } } else break; } if (i != count) - return 0; + return awk_false; - return 1; + return awk_true; } /* read_elem --- read in a single element */ @@ -379,7 +379,7 @@ read_elem(int fd, awk_element_t *element) ssize_t ret; if ((ret = read(fd, & index_len, sizeof(index_len))) != sizeof(index_len)) { - return 0; + return awk_false; } index_len = ntohl(index_len); @@ -395,14 +395,14 @@ read_elem(int fd, awk_element_t *element) char *cp = realloc(buffer, index_len); if (cp == NULL) - return 0; + return awk_false; buffer = cp; buflen = index_len; } if (read(fd, buffer, index_len) != (ssize_t) index_len) { - return 0; + return awk_false; } make_const_string(buffer, index_len, & element->index); } else { @@ -410,9 +410,9 @@ read_elem(int fd, awk_element_t *element) } if (! read_value(fd, & element->value)) - return 0; + return awk_false; - return 1; + return awk_true; } /* read_value --- read a number or a string */ @@ -423,7 +423,7 @@ read_value(int fd, awk_value_t *value) uint32_t code, len; if (read(fd, & code, sizeof(code)) != sizeof(code)) - return 0; + return awk_false; code = ntohl(code); @@ -431,7 +431,7 @@ read_value(int fd, awk_value_t *value) awk_array_t array = create_array(); if (read_array(fd, array) != 0) - return 0; + return awk_false; /* hook into value */ value->val_type = AWK_ARRAY; @@ -440,14 +440,14 @@ read_value(int fd, awk_value_t *value) double d; if (read(fd, & d, sizeof(d)) != sizeof(d)) - return 0; + return awk_false; /* hook into value */ value->val_type = AWK_NUMBER; value->num_value = d; } else { if (read(fd, & len, sizeof(len)) != sizeof(len)) { - return 0; + return awk_false; } len = ntohl(len); value->val_type = AWK_STRING; @@ -457,11 +457,11 @@ read_value(int fd, awk_value_t *value) if (read(fd, value->str_value.str, len) != (ssize_t) len) { free(value->str_value.str); - return 0; + return awk_false; } } - return 1; + return awk_true; } static awk_ext_func_t func_table[] = { diff --git a/extension/testext.c b/extension/testext.c index eef62bfe..9367da77 100644 --- a/extension/testext.c +++ b/extension/testext.c @@ -819,7 +819,7 @@ BEGIN { create_new_array(); - return 1; + return awk_true; } static awk_bool_t (*init_func)(void) = init_testext; @@ -113,7 +113,10 @@ extern "C" { #define awk_const const #endif -typedef int awk_bool_t; /* we don't use <stdbool.h> on purpose */ +typedef enum awk_bool { + awk_false = 0, + awk_true +} awk_bool_t; /* we don't use <stdbool.h> on purpose */ /* The information about input files that input parsers need to know: */ typedef struct awk_input { @@ -71,8 +71,6 @@ NODE *RLENGTH_node, *RSTART_node, *RS_node, *RT_node, *SUBSEP_node; NODE *PREC_node, *ROUNDMODE_node; NODE *TEXTDOMAIN_node; -NODE *_r; /* used as temporary in stack macros */ - long NF; long NR; long FNR; @@ -86,7 +84,7 @@ char *TEXTDOMAIN; /* * CONVFMT is a convenience pointer for the current number to string format. * We must supply an initial value to avoid recursion problems of - * set_CONVFMT -> fmt_index -> r_force_string: gets NULL CONVFMT + * set_CONVFMT -> fmt_index -> force_string: gets NULL CONVFMT * Fun, fun, fun, fun. */ char *CONVFMT = "%.6g"; @@ -260,21 +260,6 @@ no_malloc: return s; } - -/* r_force_string --- force a value to be a string */ - -#ifdef GAWKDEBUG -NODE * -r_force_string(NODE *s) -{ - if ((s->flags & STRCUR) != 0 - && (s->stfmt == -1 || s->stfmt == CONVFMTidx) - ) - return s; - return format_val(CONVFMT, CONVFMTidx, s); -} -#endif - /* r_dupnode --- duplicate a node */ NODE * @@ -573,8 +573,12 @@ regerror (errcode, preg, errbuf, errbuf_size) { if (BE (msg_size > errbuf_size, 0)) { +#if defined HAVE_MEMPCPY || defined _LIBC + *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0'; +#else memcpy (errbuf, msg, errbuf_size - 1); errbuf[errbuf_size - 1] = 0; +#endif } else memcpy (errbuf, msg, msg_size); @@ -896,7 +900,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) # endif /* strcasecmp isn't a standard interface. brute force check */ -#if 0 +#ifndef GAWK if (strcasecmp (codeset_name, "UTF-8") == 0 || strcasecmp (codeset_name, "UTF8") == 0) dfa->is_utf8 = 1; @@ -978,8 +982,12 @@ init_word_char (re_dfa_t *dfa) { if (sizeof (dfa->word_char[0]) == 8) { - dfa->word_char[0] = UINT64_C (0x03ff000000000000); - dfa->word_char[1] = UINT64_C (0x07fffffe87fffffe); + /* The extra temporaries here avoid "implicitly truncated" + warnings in the case when this is dead code, i.e. 32-bit. */ + const uint64_t wc0 = UINT64_C (0x03ff000000000000); + const uint64_t wc1 = UINT64_C (0x07fffffe87fffffe); + dfa->word_char[0] = wc0; + dfa->word_char[1] = wc1; i = 2; } else if (sizeof (dfa->word_char[0]) == 4) @@ -2679,7 +2687,6 @@ build_range_exp (reg_syntax_t syntax, bitset_t sbcset, # endif /* not RE_ENABLE_I18N */ { unsigned int start_ch, end_ch; - /* Equivalence Classes and Character Classes can't be a range start/end. */ if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. @@ -56,6 +56,9 @@ #undefs RE_DUP_MAX and sets it to the right value. */ #include <limits.h> +/* This header defines the MIN and MAX macros. */ +#include <sys/param.h> + #ifdef GAWK #undef alloca #define alloca alloca_is_bad_you_should_never_use_it diff --git a/regex_internal.h b/regex_internal.h index f38a13b0..36f29e47 100644 --- a/regex_internal.h +++ b/regex_internal.h @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library. - Copyright (C) 2002-2005, 2007, 2008, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2002-2012 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. @@ -92,7 +92,7 @@ is_blank (int c) # ifdef _LIBC # undef gettext # define gettext(msgid) \ - INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES) + __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES) # endif #else # define gettext(msgid) (msgid) @@ -375,7 +375,7 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs, const char *str; int rval; int len = length1 + length2; - int free_str = 0; + char *s = NULL; if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0)) return -2; @@ -384,7 +384,7 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs, if (length2 > 0) if (length1 > 0) { - char *s = re_malloc (char, len); + s = re_malloc (char, len); if (BE (s == NULL, 0)) return -2; @@ -395,7 +395,6 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs, memcpy (s + length1, string2, length2); #endif str = s; - free_str = 1; } else str = string2; @@ -403,8 +402,7 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs, str = string1; rval = re_search_stub (bufp, str, len, start, range, stop, regs, ret_len); - if (free_str) - re_free ((char *) str); + re_free (s); return rval; } |