Commit Graph

71 Commits

Author SHA1 Message Date
Miguel Pineiro Jr
99f6a43296 Fix error handling in closefile and closeall
printstat and awkprintf are very clear: print statement errors
are fatal.

In Jan 2020 [1], to prevent fatal print errors from masquerading
as fclose warnings, every WARNING in closefile and closeall became
FATAL. This broke awk's close and getline functions.

close no longer returns if there's an error, unless the stream
doesn't exist.

getline read errors still return -1, but they are no longer
ignorable. Eventually, one of the closing functions will inspect the
stream with ferror and call FATAL.

In Jul 2020 [2], fatal stdout write errors which had been detectable by
closefile for a few months became invisible, a consequence of switching
standard streams from fclose (which reports flush errors) to freopen
(which ignores them). The Jan 2020 changes which broke getline and
close were themselves partially broken.

The solution is to finish printing before closing. That is to flush
and ferror every stream opened for writing before calling fclose,
pclose, or freopen. A failure to write print statement data is
fatal. A failure to close a flushed stream is a warning. They must
be handled separately.

Every redirected print statement is finished in printstat or awkprintf.

The same is not true of unredirected print statements. To finish
these, stdout must be flushed at some point after the final such
statement. Any problem with that flush is fatal.

Though only stdout needs it, let's defensively finish every stream
opened for writing, so this bug won't recur if someone changes how
redirected streams are flushed.

Write errors on stderr by the implementation are never fatal. When
closing, we only warn of them. Write errors from an application
attempting a redirected print to /dev/stderr are as immediately fatal
as every other redirected print statement.

[1] fed1a562c3
[2] b82b649aa6
2021-12-08 23:06:02 -05:00
ozan yigit
cfe6b6b99d Revert "version and FIXES updated."
This reverts commit 52fb5d07d3.
2021-11-25 13:29:16 -05:00
ozan yigit
52fb5d07d3 version and FIXES updated. 2021-11-23 16:10:27 -05:00
ozan yigit
a4ca5ea32f updated version date 2021-11-03 22:41:23 -04:00
ozan yigit
275a80ff33 Heap buffer overflow from PR #83 fixed in #121 2021-10-12 00:06:51 -04:00
ozan yigit
dfd28d2e93 Merge branch 'fs-inconsistency' of https://github.com/bsdimp/awk into bsdimp-fs-inconsistency 2021-07-26 21:50:22 -04:00
ozan yigit
aa8731ea81 PR #112, #116, #117 2021-07-25 14:37:03 -04:00
Warner Losh
45dab2a7e0 awk: Make -F '' and -v FS="" behave the same
IEEE Std 1003.1-2008 mandates that -F str be treated the same as -v
FS=str. For a null string, this was not the case. Since awk(1) documents
that a null string for FS has a specific behavior, make -F '' behave
consistently with -v FS="".

PR:
upstream issue:		https://github.com/onetrueawk/awk/issues/127
Sponsored by:		Netflix
2021-07-20 08:10:50 -06:00
Arnold D. Robbins
c0f4e97e45 Fix compiling with g++. 2021-02-15 20:33:15 +02:00
ozan s. yigit
1fd5fa38cc Fix a decision bug with trailing stuff in lib.c:is_valid_number
after dec 18 changes. updated FIXES, adjusted version date.
2021-01-06 18:37:48 -05:00
Arnold D. Robbins
8909e00b57 Inf and NaN values fixed and printing improved. "This time for sure!" 2020-12-18 11:57:48 +02:00
Arnold D. Robbins
982a574e32 Update FIXES and version. 2020-12-15 14:49:18 +02:00
Arnold D. Robbins
6535bd6c35 Update FIXES and version in main.c. 2020-12-08 09:20:58 +02:00
Arnold D. Robbins
e508d2861c Update version and FIXES. 2020-12-03 19:33:11 +02:00
Arnold D. Robbins
3b42cfaf73 Make it compile with g++. 2020-10-13 20:52:43 +03:00
Arnold D. Robbins
9804285af0 Additional fixes for DJGPP. 2020-08-16 18:48:05 +03:00
Arnold D. Robbins
9c63cb6ccd Update FIXES and version in main.c. 2020-08-07 13:15:17 +03:00
Arnold D. Robbins
1b3984634f Fix Issue #92; see FIXES. 2020-08-04 10:02:26 +03:00
Arnold D. Robbins
9b80a7c137 Update version and FIXES. 2020-07-30 17:15:58 +03:00
Arnold D. Robbins
07f0438423 Move exclusively to bison as parser generator. 2020-07-30 17:12:45 +03:00
Todd C. Miller
453ce8642b
Avoid accessing pfile[] out of bounds on syntax error at EOF. (#90)
When awk reaches EOF parsing the program file, curpfile is incremented.
However, cursource() uses curpfile without checking it against npfile
which can cause an out of bounds access of pfile[] if there is a syntax
error at the end of the program file.
2020-07-29 21:31:29 +03:00
Arnold D. Robbins
b2554a9e3d Add regression script for bugs-fixed directory. 2020-07-02 21:35:06 +03:00
Arnold D. Robbins
f232de85f6 Update FIXES and date in main.c. 2020-06-25 21:36:24 +03:00
Todd C. Miller
292d39f7b7
Rename dprintf to DPRINTF and use C99 cpp variadic arguments. (#82)
POSIX specifies a dprintf function that operates on an fd instead of
a stdio stream.  Using upper case for macros is more idiomatic too.
We no longer need to use an extra set of parentheses for debugging
printf statements.
2020-06-25 21:32:34 +03:00
Arnold D. Robbins
cef5180110 Fix Issue 78 and apply PR 80. 2020-06-12 14:30:03 +03:00
Arnold D. Robbins
754cf93645 In fldbld(), check that inputFS is set. 2020-06-05 12:25:15 +03:00
Arnold D. Robbins
1107437dce Fix test for use of noreturn. 2020-05-15 15:12:15 +03:00
Arnold D. Robbins
93e5dd87a1 Fix noreturn for old compilers. 2020-04-16 20:56:49 +03:00
Arnold D. Robbins
c3d8f9c500 Update FIXES and version date. 2020-04-05 21:14:46 +03:00
awkfan77
bb538fe67e
Replace __attribute__((__noreturn__)) with _Noreturn. (#77)
* Replace __attribute__((__noreturn__)) with _Noreturn.

* Change _Noreturn to noreturn and #include <stdnoreturn.h>
2020-04-05 21:10:52 +03:00
Arnold D. Robbins
2017c2e6ea Fixes from Christo Zoulas. 2020-02-28 13:47:42 +02:00
zoulasc
ffee7780fe
3 more fixes (#75)
* LC_NUMERIC radix issue.

According to https://pubs.opengroup.org/onlinepubs/7990989775/xcu/awk.html
The period character is the character recognized in processing awk
programs.  Make it so that during output we also print the period
character, since this is what other awk implementations do, and it
makes sense from an interoperability point of view.

* print "T.builtin" in the error message

* Fix backslash continuation line handling.

* Keep track of RS processing so we apply the regex properly only once
per record.
2020-02-28 13:23:54 +02:00
Arnold D. Robbins
e92c8e4d0e Update FIXES, version. 2020-02-19 20:47:40 +02:00
Arnold D. Robbins
ed6ff8c1cb Small cleanups before merge to master. 2020-02-18 21:26:24 +02:00
zoulasc
94e4c04561
argument parsing cleanups, dynamic program file allocation, fpe error enhancement. (#72)
* - enhance fpe handler to print the error type
- cleanup argument parsing
- dynamically allocate program filename array

* bison uses enums now, not #define's, make it work with that.

* We need to use either the enums or the defines but not both. This
is because bison -y will create both enums and #defines, while bison
without -y produces only the enums, and byacc produces just #defines.

* fix indentation

* Set the tokentype when we have a match in the scan, and reset it later
when we decide that the match was bad. Fixes nbyacc.

* - don't use pattern rules for portability
- try to move both flavors of generated names for portability

* Amend tests for the new error messages
2020-02-18 21:20:27 +02:00
Arnold D. Robbins
5068d20ef6 Restore zoulas fixes, step 1. 2020-02-06 22:27:31 +02:00
Arnold D. Robbins
d7a7e4d147 Revert zoulas changes until we can keep tests passing. 2020-02-06 22:08:20 +02:00
Arnold D. Robbins
8447cc9d47 Update version and FIXES. 2020-02-06 21:47:31 +02:00
Arnold D. Robbins
78c79c06d0 Fix a{0}, update tests. 2020-01-31 08:40:11 +02:00
Arnold D. Robbins
4d9b12969e Update version info. 2020-01-24 11:15:30 +02:00
Arnold D. Robbins
de6284e037 Fix Issue 60; sub/gsub follow POSIX if POSIXLY_CORRECT in the environment. 2020-01-19 20:37:33 +02:00
Arnold D. Robbins
3ed74525f6 Update date in version. 2020-01-17 14:03:52 +02:00
Arnold D. Robbins
c7eeb57210 Fix merging of concatenated string constants. 2020-01-05 21:18:36 +02:00
Arnold D. Robbins
7db55ba13f Bug fix in interval expressions. 2019-12-27 12:03:35 +02:00
Arnold D. Robbins
0b82bc6eb4 Small edits, update version and FIXES. 2019-12-11 09:24:38 +02:00
Arnold D. Robbins
416c6db5ee Update version and FIXES. 2019-12-08 21:43:32 +02:00
Arnold D. Robbins
108224b484 Convert variables to bool and enum. 2019-11-10 21:19:18 +02:00
Arnold D. Robbins
c879fbf013 From Ori Bernstein, ori@eigenstate.org, for FS="" in multibyte locale. 2019-11-08 14:40:18 +02:00
Arnold D. Robbins
2a8f1758b9 Update FIXES and main.c version. 2019-10-25 11:03:02 -04:00
Arnold D. Robbins
961eec1fb5 Additional fixes after merge of PR 53. 2019-10-24 09:42:51 -04:00