diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2021-07-15 21:54:54 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2021-07-15 21:54:54 +0300 |
commit | 2db204045f8060dbe1fc09f765373c101d0aad2c (patch) | |
tree | 86f8ff9fd243115f73b4465a4209eb339d0eb968 | |
parent | cfd75e17cf2d3cbb847859e88656c051280403e4 (diff) | |
parent | f056f0a42953c9297f60335421ccd7609cba698e (diff) | |
download | egawk-2db204045f8060dbe1fc09f765373c101d0aad2c.tar.gz egawk-2db204045f8060dbe1fc09f765373c101d0aad2c.tar.bz2 egawk-2db204045f8060dbe1fc09f765373c101d0aad2c.zip |
Merge branch 'gawk-5.1-stable'
-rw-r--r-- | helpers/ChangeLog | 4 | ||||
-rw-r--r-- | helpers/testdfa.c | 14 |
2 files changed, 15 insertions, 3 deletions
diff --git a/helpers/ChangeLog b/helpers/ChangeLog index d7b94157..d8e12b46 100644 --- a/helpers/ChangeLog +++ b/helpers/ChangeLog @@ -1,3 +1,7 @@ +2021-07-15 Arnold D. Robbins <arnold@skeeve.com> + + * testdfa.c (main): Bug fix and new -b option. + 2021-05-12 Arnold D. Robbins <arnold@skeeve.com> * update-support.sh: Fix list of files to copy over. diff --git a/helpers/testdfa.c b/helpers/testdfa.c index 0f7911a1..426aab8f 100644 --- a/helpers/testdfa.c +++ b/helpers/testdfa.c @@ -25,6 +25,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include <config.h> + #include <stdio.h> #include <ctype.h> #include <errno.h> @@ -44,7 +46,7 @@ #undef _Noreturn #define _Noreturn -#define _GL_ATTRIBUTE_PURE +/*#define _GL_ATTRIBUTE_PURE */ #include "dfa.h" #include "localeinfo.h" @@ -88,6 +90,7 @@ int main(int argc, char **argv) char save; size_t count = 0; char *place; + bool not_bol = false; struct localeinfo localeinfo; if (argc < 2) @@ -100,8 +103,11 @@ int main(int argc, char **argv) syn = RE_SYNTAX_GNU_AWK; /* parse options, update syntax, ignorecase */ - while ((c = getopt(argc, argv, "pit")) != -1) { + while ((c = getopt(argc, argv, "bpit")) != -1) { switch (c) { + case 'b': + not_bol = true; + break; case 'i': ignorecase = true; break; @@ -173,6 +179,7 @@ int main(int argc, char **argv) /* gack. this must be done *after* re_compile_pattern */ pat.newline_anchor = false; /* don't get \n in middle of string */ + pat.not_bol = not_bol; dfareg = dfaalloc(); init_localeinfo(&localeinfo); @@ -185,9 +192,10 @@ int main(int argc, char **argv) data = databuf(STDIN_FILENO); + len = strlen(data); /* run the regex matcher */ - ret = re_search(& pat, data, len, 0, len, NULL); + ret = re_search(& pat, data, len, 0, len, ®s); printf("re_search returned position %d (%s)\n", ret, (ret >= 0) ? "true" : "false"); /* run the dfa matcher */ |