gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] gawk branch, master, updated. gawk-4.1.0-5388-gb488e3dc


From: Arnold Robbins
Subject: [SCM] gawk branch, master, updated. gawk-4.1.0-5388-gb488e3dc
Date: Thu, 19 Oct 2023 07:05:31 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, master has been updated
       via  b488e3dc713c2dc62f7df5f026a070361b2a0161 (commit)
      from  cd915e2556c62b4957fb8ee38674436425127d2e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=b488e3dc713c2dc62f7df5f026a070361b2a0161

commit b488e3dc713c2dc62f7df5f026a070361b2a0161
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Thu Oct 19 14:05:13 2023 +0300

    Improvements in helpers/testdfa.c.

diff --git a/helpers/ChangeLog b/helpers/ChangeLog
index 31dbf8d1..55a8557a 100644
--- a/helpers/ChangeLog
+++ b/helpers/ChangeLog
@@ -1,3 +1,8 @@
+2023-10-19         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * testdfa.c: Add printing of submatch info and -s option to
+       set starting offset.
+
 2023-05-07         Arnold D. Robbins     <arnold@skeeve.com>
 
        * 5.2.2: Release tar ball made.
diff --git a/helpers/testdfa.c b/helpers/testdfa.c
index aa5b3bb7..26df6158 100644
--- a/helpers/testdfa.c
+++ b/helpers/testdfa.c
@@ -93,6 +93,7 @@ int main(int argc, char **argv)
        char *place;
        bool not_bol = false;
        struct localeinfo localeinfo;
+       int start = 0;
 
        pma_init(1, NULL);
 
@@ -106,7 +107,7 @@ int main(int argc, char **argv)
        syn = RE_SYNTAX_GNU_AWK;
 
        /* parse options, update syntax, ignorecase */
-       while ((c = getopt(argc, argv, "bpit")) != -1) {
+       while ((c = getopt(argc, argv, "bpits:")) != -1) {
                switch (c) {
                case 'b':
                        not_bol = true;
@@ -120,6 +121,9 @@ int main(int argc, char **argv)
                case 't':
                        syn = RE_SYNTAX_AWK;
                        break;
+               case 's':
+                       sscanf(optarg, "%d", & start);
+                       break;
                case '?':
                default:
                        usage(argv[0]);
@@ -130,6 +134,11 @@ int main(int argc, char **argv)
        if (optind == argc)
                usage(argv[0]);
 
+       if (start < 0 || start > strlen(argv[optind])) {
+               fprintf(stderr, "%s: start index %d is out of range\n", 
argv[0], start);
+               exit(EXIT_FAILURE);
+       }
+
        pattern = argv[optind];
        len = strlen(pattern);
 
@@ -204,7 +213,7 @@ int main(int argc, char **argv)
        printf("data: <%s>\n", data);
 
        /* run the regex matcher */
-       ret = re_search(& pat, data, len, 0, len, NULL);
+       ret = re_search(& pat, data, len, start, len, NULL);
        printf("re_search with NULL returned position %d (%s)\n", ret, (ret >= 
0) ? "true" : "false");
 #if 0
        printf("pat.allocated = %ld\n", pat.allocated);
@@ -220,7 +229,7 @@ int main(int argc, char **argv)
        printf("pat.newline_anchor = %d\n", pat.newline_anchor);
 #endif
 
-       ret = re_search(& pat, data, len, 0, len, &regs);
+       ret = re_search(& pat, data, len, start, len, &regs);
        printf("re_search returned position %d (%s)\n", ret, (ret >= 0) ? 
"true" : "false");
 #if 0
        printf("pat.allocated = %ld\n", pat.allocated);
@@ -235,6 +244,9 @@ int main(int argc, char **argv)
        printf("pat.not_eol = %d\n", pat.not_eol);
        printf("pat.newline_anchor = %d\n", pat.newline_anchor);
 #endif
+       printf("pat.re_nsub = %d\n", pat.re_nsub);
+       for (int i = 0; i <= pat.re_nsub; i++)
+               printf("\treg[%d].so = %d, reg[%d].eo = %d\n", i, 
regs.start[i], i, regs.end[i]);
 
        /* run the dfa matcher */
        /*

-----------------------------------------------------------------------

Summary of changes:
 helpers/ChangeLog |  5 +++++
 helpers/testdfa.c | 18 +++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]