Commit Graph

60 Commits

Author SHA1 Message Date
christos 358fc34e52 From wajap at github:
- eat whitespace in infnan checks
- set fval to 0 if we are not a floating point number
2020-11-02 22:58:51 +00:00
riastradh dd2199c16d Nix trailing whitespace. 2020-09-02 18:09:04 +00:00
christos 85da8872cb eat the sign, pointed out by uwe@ 2020-09-01 00:35:29 +00:00
christos d21092d46f check explicitly for inf and nan. We can't check if it is a number,
because awk parses 1a as 1...
2020-09-01 00:21:01 +00:00
christos 4b14471916 Add a check_number function that does what is repeated in many places in
the code, but better.
2020-08-31 23:37:55 +00:00
christos 8871000030 Don't try so hard to convert strings into numbers. Results in bogus
conversions like:

% awk 'BEGIN { print "nanotime" + 123 }'
nan
% awk 'BEGIN { print "microtime" + 123 }'
123
% awk 'BEGIN { print "inftime" + 123 }'
inf
2020-08-31 23:36:58 +00:00
ad 74ff427e71 Now that inputFS is dynamically allocated, make sure it's always non-NULL.
Fixes core dumps when building CDE.
2020-04-17 22:35:18 +00:00
christos e9bf148a44 Fix failing unittests (by restoring old changes). 2020-02-20 19:59:12 +00:00
christos ebfc71ebe2 regen 2020-02-18 21:29:39 +00:00
christos b0222858ea use the correct header name. 2020-02-18 21:29:30 +00:00
christos cdabad706d merge conflicts 2020-02-18 21:12:21 +00:00
christos 6f2cbaf607 Last import was 2010 when there was no ChangeLog yet. I've worked
with upstream to merge all our changes and this includes many other
fixes including new operator support etc. The change to pass an
extra "isnew" argument to open was not preserved as none of the
tests supplied with the PR fail.

This also adds the testsuite and all the bugs fixed since then.
2020-02-18 20:50:46 +00:00
wiz cc99a5951f Add license from https://github.com/onetrueawk/awk/blob/master/LICENSE 2019-12-21 09:11:59 +00:00
wiz 28107122fa Remove macros with no effect. 2019-12-18 10:17:48 +00:00
christos 33c14bf659 Sync with upstream. 2019-12-17 18:35:57 +00:00
christos 806ea548cf Add translators for \v and \a per posix. 2019-08-01 13:17:42 +00:00
christos efd65d89e4 remove ### error output accidentally committed. 2019-08-01 06:33:58 +00:00
christos ca889033bb PR/54424: Martijn Dekker: awk: broken character classes in UTF-8 locale:
only the first matches
Pick up some of the fixes from upstream:
	- posix paren matching
	- print \v \a
	- some more fatal handling
	- init all the character range.
2019-08-01 06:22:52 +00:00
christos a533950c00 remove trailing whitespace. 2019-08-01 06:14:45 +00:00
christos d7ebb8dfb4 PR/53885: Martijn Dekker: Add ERE support from
https://opensource.apple.com/tarballs/awk/awk-24.tar.gz
2019-01-19 00:37:41 +00:00
kamil 463be44101 Do not use index out of bounds in nawk
$ awk '{w=$1}' < /dev/null
/public/src.git/external/historical/nawk/bin/../dist/lex.c:476:16: runtime error: index -1 out of bounds for type 'const Keyword [46]'

There used to be documented a bug in the code that index ouf of bounds
can in theory fault (by daniel barrett).

Before assigning the pointer, first check for the index whether it's not
not -1. This was a suggested solution in the comment in the code.

The sanitizer is overcautious as this pointer wasn't dereferenced, but
fix is nonetheless.

Sponsored by <The NetBSD Foundation>
2018-06-12 13:24:28 +00:00
christos 77b64f0a5c PR/52516: Guy Incognito: Fix memory leak; setsymtab already calls tostring()
for the buffer, don't do it twice.
XXX: pullup-8
2017-09-01 07:01:06 +00:00
abhinav f703bc6a87 Use literal for formatting the examples
Based on OpenBSD awk(1) man page.

Ok wiz@
2017-05-23 14:11:08 +00:00
shm 52ccb86d6c PR/50199 - fix for strftime called with empty string.
Patch written by Juho Salminen
2015-11-03 14:15:08 +00:00
wiz 04c27f1642 Fix important typo, from Joachim Henke on netbsd-docs.
Bump date.
2015-04-06 14:36:41 +00:00
dholland f6f4f5e81c Change the argument names in the prototypes and discussion for
sub/gsub to match those in gensub. Noted by Kai-Uwe Eckhardt in
PR 48667.
2014-03-23 01:29:12 +00:00
roy 5d74ba14e6 Fix build with clang 2014-01-17 16:31:45 +00:00
christos a2e4e15f91 PR/48448: David A. Holland: Avoid coredump by checking return code of
localtime(3)
2013-12-15 06:41:18 +00:00
mlelstv 9562031f49 Fix memory leak in gensub() 2013-10-27 10:06:01 +00:00
christos 49a7e4835b remove unused variable 2013-10-20 21:35:46 +00:00
christos 5090c2e613 PR/47553: Aleksev Cheusov: awk segfault: NULL dereference. 2013-02-11 00:32:07 +00:00
christos eeca57e31f we define HAS_ISBLANK in the Makefile 2013-01-02 13:46:17 +00:00
christos b30e7aec1f remove useless cast. 2012-12-29 14:51:41 +00:00
christos db7d489b44 merge 2012-12-20 2012-12-29 02:44:26 +00:00
christos 2616448878 from http://www.cs.princeton.edu/~bwk/btl.mirror/ 2012-12-29 02:14:50 +00:00
christos 03f2d45a25 PR/47306: Aleksey Cheusov: Don't free strings of symbols where we maintain
pointers to.
2012-12-10 19:49:05 +00:00
joerg c14f2d4ef8 Deal with optional HAVE_GCC. 2012-08-10 16:05:26 +00:00
christos a08c0283e2 don't switch back LC_NUMERIC after parsing the command line, we always want
to format numbers in the C locale.
2012-03-12 18:17:12 +00:00
christos 7fffb381da PR/46155: Miguel Piñeiro Jr: Fix RS processing. Apply the gawk-like patch
from the excellent PR. Many thanks for all the work you put on this,
explanation, tests, and patch!
2012-03-10 19:18:48 +00:00
christos 070df59c8a - make decimal conversions use the maximum width integers available on the
architecture.
- make signed and unsigned code consistent.
2011-11-22 22:30:22 +00:00
joerg ce5205bcbb Use __dead 2011-09-16 16:09:03 +00:00
christos 4036596c74 document non-literal format strings 2011-08-16 10:45:37 +00:00
joerg d745f33bcc No longer needs -Wno-array-bounds with clang. 2011-08-09 13:06:31 +00:00
mrg 75e42fa7da remove most of the remaining HAVE_GCC tests that are always true in
the modern world.
2011-06-20 07:43:56 +00:00
christos abe8ec29d9 Handle string concatenation in terms:
'{ print "foo" > "file" ".txt"; }',
2011-05-28 15:13:04 +00:00
joerg a216da57a6 Default to -Wno-sign-compare -Wno-pointer-sign for clang.
Push -Wno-array-bounds down to the cases that depend on it.
Selectively disable warnings for 3rd party software or non-trivial
issues to be reviewed later to get clang -Werror to build most of the
tree.
2011-05-26 12:56:24 +00:00
drochner eefdc5052a fix V->version flag 2011-04-20 10:10:32 +00:00
christos 305cf7b18b PR/44876: Aleksey Cheusov: awk: incorrect return value of function srand()
Make it return the value of the previous random seed as the standard mandates.
2011-04-18 15:23:28 +00:00
drochner 5a190aa53b fix bug introduced in rev. 1.3: need to set the string before
converting it into a numerical value, otherwise we might get junk or crash
2011-01-20 21:26:20 +00:00
drochner 7264233c30 avoid crash if certain operations are done before an input record is
read, ie in a BEGIN rule
2011-01-20 21:23:11 +00:00