Commit Graph

214 Commits

Author SHA1 Message Date
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
0e1bebcc09 Small fixes in the test suite. 2019-11-08 14:36:37 +02:00
Arnold D. Robbins
b73bfabb42 Typo fix in FIXES. 2019-11-08 14:31:05 +02:00
Arnold D. Robbins
2a8f1758b9 Update FIXES and main.c version. 2019-10-25 11:03:02 -04:00
Arnold D. Robbins
938b26cfae Don't use 'j' flag on %x. Remove an unnecessary cast. 2019-10-25 11:01:17 -04:00
zoulasc
0d8778bbbb more cleanups (#55)
* More cleanups:
- sprinkle const
- add a macro (setptr) that cheats const to temporarily NUL terminate strings
  remove casts from allocations
- use strdup instead of strlen+strcpy
- use x = malloc(sizeof(*x)) instead of x = malloc(sizeof(type of *x)))
- add -Wcast-qual (and casts through unitptr_t in the two macros we
  cheat (xfree, setptr)).

* More cleanups:
- add const
- use bounded sscanf
- use snprintf instead of sprintf

* More cleanup:
- use snprintf/strlcat instead of sprintf/strcat
- use %j instead of %l since we are casting to intmax_t/uintmax_t

* Merge the 3 copies of the code that evaluated array strings with separators
and convert them to keep track of lengths and use memcpy instead of strcat.
2019-10-25 10:59:09 -04:00
Arnold D. Robbins
1d6ddfd9c0 Optimize string concatenation. 2019-10-24 10:06:10 -04:00
Arnold D. Robbins
8b92a4abcb Add 'distclean' target to makefile. 2019-10-24 09:44:00 -04:00
Arnold D. Robbins
961eec1fb5 Additional fixes after merge of PR 53. 2019-10-24 09:42:51 -04:00
zoulasc
6589208eaf More cleanups: (#53)
- sprinkle const
- add a macro (setptr) that cheats const to temporarily NUL terminate strings
  remove casts from allocations
- use strdup instead of strlen+strcpy
- use x = malloc(sizeof(*x)) instead of x = malloc(sizeof(type of *x)))
- add -Wcast-qual (and casts through unitptr_t in the two macros we
  cheat (xfree, setptr)).
2019-10-24 09:40:15 -04:00
Arnold D. Robbins
1633ba1c88 Update FIXES and date in main.c. 2019-10-17 13:06:21 -04:00
zoulasc
c16e8696d7 Amended the all pull request. (#51)
* [from NetBSD]
- dynamic state allocation
- centralize vector growth
- centralize int array allocation
- no casts for void * functions

* - add missing allocation
- revert change loop in pmatch
2019-10-17 13:04:45 -04:00
Arnold D. Robbins
0ba1d0391d Small code formatting fix in run.c. 2019-10-08 10:30:09 +03:00
Arnold D. Robbins
5ff28208db Fix compile warnings. 2019-10-07 15:50:53 +03:00
Arnold D. Robbins
7cae39dfa5 Make RS as regexp work without ifdef. Add doc, bump version. 2019-10-06 22:34:20 +03:00
Arnold D. Robbins
643a5a3dad Add RS as regex code, ifdefed-out, from NetBSD. 2019-09-10 12:19:48 +03:00
Arnold D. Robbins
34a6f41cca Update FIXES and version date in main.c. 2019-09-10 09:57:07 +03:00
Alexander Richardson
ad9bd2f40a Avoid creating an out-of-bounds pointer in word() (#48)
As it is never dereferenced in the n == -1 case it shouldn't cause any
problems. However, UBSAN complains about this, so it is required to run
the tests when compiling with -fsanitize=undefined.
2019-09-10 09:54:53 +03:00
Alexander Richardson
cbf924342b Fix out-of-bounds access in gototab array for caret character (#47)
When matching a caret, the expression	`f->gototab[s][c] = f->curstat;` in
cgoto() will index the 2D-array gototab with [s][261]. However, gototab
is declared as being of size [NSTATES][NCHARS], so [32][259]. Therefore,
this assignment will write to the state for character 0x1.
I'm not sure how to create a regression test for this, but increasing the
array size to HAT+1 values fixes the error and the tests still pass.

I found this issue while running awk on a CHERI system with sub-object
protection enabled. On x86, this can be reproduced by compiling awk
with -fsanitize=undefined.
2019-09-10 09:54:11 +03:00
Sevan Janiyan
50e6962495 Drop Mac OS 9 reference (#46)
"buildmac" file is no longer supplied.
2019-08-13 20:27:51 +03:00
Arnold D. Robbins
c95b96020f Grammar optimization from NetBSD: Two adjacent string constants are merged. 2019-07-28 20:09:24 +03:00
Arnold D. Robbins
795a06b58c Remove trailing whitespace on lines in all files. 2019-07-28 05:51:52 -06:00
Arnold D. Robbins
cebda366a9 Improve cleanup of test directory upon 'make clean'. 2019-07-26 12:57:48 +03:00
Martijn Dekker
5b602ca8a2 Add support for "\a" and "\v" to regex and command line args (#44)
Support POSIX-specified C-style escape sequences "\a" (alarm)
and "\v" (vertical tab) in command line arguments and regular
expressions, further to the support for them in strings added on
Apr 9, 1989. These now no longer match as literal "a" and "v"
characters (as they don't on gawk and mawk).

IOW, lex.c already supported these (lines 390-391 as of 4e343460);
the support needed to be added to b.c and tran.c.

Relevant POSIX reference:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_04
2019-07-26 11:46:58 +03:00
Arnold D. Robbins
4e34346094 Update FIXES and main.c version. 2019-07-17 21:14:52 +03:00
M. Warner Losh
9310d452c9 Apply the following from FreeBSD / OpenBSD:
323965 | imp | 2017-09-23 23:04:06 -0600 (Sat, 23 Sep 2017) | 8 lines

Don't display empty error context.

Context extraction didn't handle this case and showed uninitialized memory.

Obtained from: OpenBSD lib.c 1.21
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D12379
2019-07-16 22:23:19 +03:00
M. Warner Losh
0939e3392b Apply r323963 from FreeBSD (pulling in the fix from OpenBSD)
| Fix uninitialized variable
|
| echo | awk 'BEGIN {i=$1; print i}' prints a boatload of stack
| garbage. NUL terminate the memory returned from malloc to prevent it.
|
| Obtained from: OpenBSD run.c 1.40
| Sponsored by: Netflix
| Differential Revision: https://reviews.freebsd.org/D12379
2019-07-16 22:23:02 +03:00
M. Warner Losh
966fdc9c29 Bring in fix from FreeBSD:
| r323964 | imp | 2017-09-23 23:04:02 -0600 (Sat, 23 Sep 2017) | 6 lines
|
| Fix %c for floating values that become 0 when coerced to int.
|
| Obtained from: OpenBSD run.c 1.36 (From Jeremy Devenport)
| Sponsored by: Netflix
| Differential Revision: https://reviews.freebsd.org/D12379
2019-07-16 22:21:33 +03:00
pfg
c70b9fe882 awk: Use random(3) instead of rand(3)
While none of them is considered even near to cryptographic
level, random(3) is a better random generator than rand(3).

Use random(3) for awk as is done in other systems.

Thanks to Chenguang Li for discussing this in the lists
and submitting the patch upstream.

PR:		193147
MFC after:	5 weeks

git-svn-id: svn+ssh://svn.freebsd.org/base/head@271879 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2019-07-16 22:19:56 +03:00
pfg
650d868ec4 MFV r315425: one-true-awk: have calloc(3) do the multiplication.
MFC after:	3 days

git-svn-id: svn+ssh://svn.freebsd.org/base/head@315426 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2019-07-16 22:12:26 +03:00
pfg
524219409a MFV r300961: one-true-awk: replace 0 with NULL for pointers
Also remove a redundant semicolon.

Also had to rebase on upstream pull.

git-svn-id: svn+ssh://svn.freebsd.org/base/head@301289 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2019-07-16 22:11:57 +03:00
Arnold D. Robbins
b8e0827095 Update FIXES and version in main.c. 2019-07-16 20:54:44 +03:00
Arnold D. Robbins
147521b831 Revise testdir/T.split per PR #42. 2019-07-16 20:50:23 +03:00
Arnold D. Robbins
891690942a Update T.split to match code changes. 2019-07-16 20:37:13 +03:00
Arnold D. Robbins
00170ba76c Merge remote-tracking branch 'melloc/posix-fs' into save-fs-fixes 2019-07-14 20:39:02 +03:00
Arnold D. Robbins
7e368c272a Update FIXES for test suite changes. 2019-06-24 01:13:10 -06:00
Arnold D. Robbins
ab911ab204 Update makefile, mainly to clean up testdir. 2019-06-24 01:10:24 -06:00
Arnold D. Robbins
4a99bd14d0 Remove awktest.tar. 2019-06-23 03:14:32 -06:00
Arnold D. Robbins
d6c466c367 Extract testdir. 2019-06-23 03:13:57 -06:00
Cody Mello
ae99b752af Disallow deleting SYMTAB and its elements (#43) 2019-06-17 22:08:54 +03:00
Cody Peter Mello
b463680594 Update field-splitting behaviour to match POSIX definition 2019-06-14 14:54:11 -07:00
Arnold D. Robbins
fabf9efece Minor fixes in the man page. 2019-06-06 11:29:20 -06:00
Arnold D. Robbins
28dacbd66b Allow unmatched right paren in regexes. Fixes Issue #40. 2019-06-04 23:53:31 -06:00
Arnold D. Robbins
4189ef5d58 Fix Issue #38 - don't require non-= after = in cmd line assignment. 2019-05-29 21:04:18 +03:00
Arnold D. Robbins
89354cc230 Update awktest.tar(p.50) to modern sort options. 2019-04-07 20:39:15 +03:00
Arnold D. Robbins
55edb1b1dd Simplify cross-compiling change. Update FIXES. 2019-03-12 21:54:57 +02:00
nee-san
c83d943830 Fix cross-build (#34)
* Fix cross-build

Fixes in make file to support cross-build because maketab is a host tool and should be compiled with host compiler

* some
2019-03-12 21:52:17 +02:00
Arnold D. Robbins
33ead6d239 Sync FIXES with GitHub repo activity. 2019-03-05 21:39:02 +02:00
Arnold Robbins
4bc685f701
Merge pull request #30 from McDutchie/interval-expr
backport ERE interval/repetition expressions from Apple awk-24
2019-03-05 21:28:45 +02:00