aboutsummaryrefslogtreecommitdiff
path: root/b.c
AgeCommit message (Collapse)Author
2021-10-09Fix https://github.com/onetrueawk/awk/issues/121Anonymous AWK fan
2021-03-02Fix size computation in replace_repeat() for special_case REPEAT_WITH_Q.Todd C. Miller
This resulted in the NUL terminator being written to the end of the buffer which was not the same as the end of the string. That in turn caused garbage bytes from malloc() to be processed. Also change the NUL termination to be less error prone by writing the NUL immediately after the last byte copied. Reproducible with the following under valgrind: echo '#!/usr/bin/awk' | awk \ '/^#! ?\/.*\/[a-z]{0,2}awk/ {sub(/^#! ?\/.*\/[a-z]{0,2}awk/,"#! awk"); print}'
2020-10-13Make it compile with g++.Arnold D. Robbins
2020-07-30Move exclusively to bison as parser generator.Arnold D. Robbins
2020-07-29Cast to uschar when storing a char in an int that will be used as an index (#88)Todd C. Miller
* Cast to uschar when storing a char in an int that will be used as an index. Fixes a heap underflow when the input char has the high bit set and FS is a regex. * Add regress test for underflow when RS is a regex and input is 8-bit.
2020-06-25Merge branch 'staging'Arnold D. Robbins
2020-06-25Fix onetrueawk#83 (#84)awkfan77
2020-06-25Rename dprintf to DPRINTF and use C99 cpp variadic arguments. (#82)Todd C. Miller
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-01-24Fix for a{0} bug.Arnold D. Robbins
2020-01-24Small fixes (#68)zoulasc
* sprinkle const, static * account for lineno in unput * Add an EMPTY string that is used when a non-const empty string is needed. * make inputFS static and dynamically allocated * Simplify and in the process avoid -Wwritable-strings * make fs const to avoid -Wwritable-strings
2020-01-06Minor fixes.Arnold D. Robbins
2020-01-01Small formatting cleanups in b.c.Arnold D. Robbins
2019-12-27Bug fix in interval expressions.Arnold D. Robbins
2019-12-09Fix memory corruption manifested on 32 bit binaries (#58)zoulasc
* Don't update gototab entries for HAT (corrupts memory)
2019-11-10Convert variables to bool and enum.Arnold D. Robbins
2019-10-24More cleanups: (#53)zoulasc
- 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-17Amended the all pull request. (#51)zoulasc
* [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-07Fix compile warnings.Arnold D. Robbins
2019-09-10Add RS as regex code, ifdefed-out, from NetBSD.Arnold D. Robbins
2019-09-10Fix out-of-bounds access in gototab array for caret character (#47)Alexander Richardson
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-07-28Remove trailing whitespace on lines in all files.Arnold D. Robbins
2019-07-26Add support for "\a" and "\v" to regex and command line args (#44)Martijn Dekker
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-16MFV r315425: one-true-awk: have calloc(3) do the multiplication.pfg
MFC after: 3 days git-svn-id: svn+ssh://svn.freebsd.org/base/head@315426 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2019-07-16MFV r300961: one-true-awk: replace 0 with NULL for pointerspfg
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-06-04Allow unmatched right paren in regexes. Fixes Issue #40.Arnold D. Robbins
2019-03-05Merge remote-tracking branch 'upstream/master' into interval-exprMartijn Dekker
main.c: bump version to 20190305
2019-02-21repeat(): add FATAL calls for errors that should be impossibleMartijn Dekker
2019-01-28Merge branch 'master' into cc_func-avoid-undefined-behaviourLeonardo Taccari
2019-01-23backport ERE interval/repetition expressions from Apple awk-24Martijn Dekker
The lack of POSIX interval expressions[*] (a.k.a. bounds, a.k.a. repetition expressions) in regular expressions is listed under BUGS in 'awk.1'. Apple's version of onetrueawk has supported these since at least 2009, judging by the date stamp on their src/b.c in: https://opensource.apple.com/tarballs/awk/awk-24.tar.gz A bug report prompted NetBSD to swiftly integrate this code into their awk. This commit is based on that NetBSD diff. http://gnats.netbsd.org/53885 https://github.com/NetBSD/src/commit/f3e4c4ca1dfcdd939a2e33ebfe708f01e25b3bae b.c: - Backport POSIX-standard interval expressions support in regular expressions via NetBSD from Apple awk-24 (20070501). main.c: - Bump version ID. FIXES: - Add note and credit for this feature. awk.1: section BUGS: - Remove line saying interval expressions are not supported. _________ [*] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04_06
2018-11-12Fix regular expressions containing [[:cntrl:]]Cody Peter Mello
2018-08-29avoid undefined behaviour when using ctype(3) functions in relex()Leonardo Taccari
Because NCHARS is (256+3) cc->cc_func(i) was called with 256, 257 and 258 as argument leading to possible undefined behaviour (at least on NetBSD with non-C locale (e.g. `en_US.UTF-8') this led to only honoring one `[:...:]' character class in bracket expressions). Fix #11
2018-08-22Fix multiple long-standing bugs, improve test suite.Arnold D. Robbins
2012-12-22initial commit for githubBrian Kernighan