gawk-diffs
[Top][All Lists]
Advanced

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

[SCM] gawk branch, feature/csv-revamp, updated. gawk-4.1.0-5189-g9271438


From: Arnold Robbins
Subject: [SCM] gawk branch, feature/csv-revamp, updated. gawk-4.1.0-5189-g92714382
Date: Tue, 21 Mar 2023 16:03:55 -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, feature/csv-revamp has been updated
       via  927143821e5124bb30cae744e6767b4d75463d18 (commit)
      from  2ce11716fa4d03e2d8110dcafef36c7a6518c719 (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=927143821e5124bb30cae744e6767b4d75463d18

commit 927143821e5124bb30cae744e6767b4d75463d18
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Tue Mar 21 22:03:35 2023 +0200

    Add initial csvscan() routine.

diff --git a/ChangeLog b/ChangeLog
index 99d9fbf9..0f2cd3d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2023-03-21         Manuel Collado        <mcollado2011@gmail.com>
+
+       * io.c (csvscan): Real implementation.
+
 2023-03-17         Arnold D. Robbins     <arnold@skeeve.com>
 
        * field.c (do_split): Modify behavior for --csv.
diff --git a/io.c b/io.c
index 41167b58..2710db93 100644
--- a/io.c
+++ b/io.c
@@ -3835,7 +3835,43 @@ find_longest_terminator:
 static RECVALUE
 csvscan(IOBUF *iop, struct recmatch *recm, SCANSTATE *state)
 {
-       return rs1scan(iop, recm, state);       // XXX so it'll compile and run
+       char *bp;
+       char rs = '\n';
+       static bool in_quote = false;
+
+       memset(recm, '\0', sizeof(struct recmatch));
+       *(iop->dataend) = rs;   /* set sentinel */
+       recm->start = iop->off; /* beginning of record */
+
+       if (*state == NOSTATE)  /* reset in_quote at the beginning of the 
record */
+               in_quote = false;
+
+       bp = iop->off;
+       if (*state == INDATA)   /* skip over data we've already seen */
+               bp += iop->scanoff;
+
+       /* look for a newline outside quotes */
+       do {
+               while (*bp != rs) { 
+                       if (*bp == '\"')
+                               in_quote = !in_quote;
+                       bp++;
+               }
+       } while (in_quote && bp < iop->dataend && bp++);
+
+       /* set len to what we have so far, in case this is all there is */
+       recm->len = bp - recm->start;
+
+       if (bp < iop->dataend) {        /* found it in the buffer */
+               recm->rt_start = bp;
+               recm->rt_len = 1;
+               *state = NOSTATE;
+               return REC_OK;
+       } else {
+               *state = INDATA;
+               iop->scanoff = bp - iop->off;
+               return NOTERM;
+       }
 }
 
 /* retryable --- return true if PROCINFO[<filename>, "RETRY"] exists */
diff --git a/pc/ChangeLog b/pc/ChangeLog
index 12c14c72..7b998279 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+2023-03-21         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.tst: Regenerated.
+
 2023-03-17         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.tst: Regenerated.
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index 7228004b..40ba12fb 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -190,7 +190,8 @@ GAWK_EXT_TESTS = \
        aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \
        arraysort2 arraytype asortbool backw badargs beginfile1 beginfile2 \
        binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
-       clos1way5 clos1way6 colonwarn commas crlf csv1 csv2 dbugeval dbugeval2 \
+       clos1way5 clos1way6 colonwarn commas crlf csv1 csv2 csv3 \
+       dbugeval dbugeval2 \
        dbugeval3 dbugeval4 dbugtypedre1 dbugtypedre2 delsub \
        devfd devfd1 devfd2 dfacheck1 dumpvars \
        elemnew1 elemnew2 elemnew3 errno exit fieldwdth forcenum fpat1 fpat2 \
@@ -292,7 +293,7 @@ NEED_TRADITIONAL = litoct tradanch rscompat
 NEED_PMA = pma
 
 # List of tests that need --csv
-NEED_CSV = csv1 csv2
+NEED_CSV = csv1 csv2 csv3
 
 # Lists of tests that run a shell script
 RUN_SHELL = exit fflush localenl modifiers next randtest rtlen rtlen01
@@ -2732,6 +2733,11 @@ csv2:
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --csv >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+csv3:
+       @echo $@
+       @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --csv < "$(srcdir)"/$@.in >_$@ 
2>&1 || echo EXIT CODE: $$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 dbugeval2:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --debug < "$(srcdir)"/$@.in 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/ChangeLog b/test/ChangeLog
index 989d105b..8e0791a3 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2023-03-21         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.am (EXTRA_DIST, NEED_CSV, GAWK_EXT_TESTS): New test, csv3.
+       * csv3.awk, csv3.in, csv3.ok: New files.
+
 2023-03-17         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.am (EXTRA_DIST, NEED_CSV, GAWK_EXT_TESTS): New test, csv2.
diff --git a/test/Makefile.am b/test/Makefile.am
index e0be391c..d8f5ea40 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -225,8 +225,12 @@ EXTRA_DIST = \
        crlf.ok \
        csv1.awk \
        csv1.in \
+       csv1.ok \
        csv2.awk \
        csv2.ok \
+       csv3.awk \
+       csv3.in \
+       csv3.ok \
        datanonl.awk \
        datanonl.in \
        datanonl.ok \
@@ -1507,7 +1511,8 @@ GAWK_EXT_TESTS = \
        aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \
        arraysort2 arraytype asortbool backw badargs beginfile1 beginfile2 \
        binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
-       clos1way5 clos1way6 colonwarn commas crlf csv1 csv2 dbugeval dbugeval2 \
+       clos1way5 clos1way6 colonwarn commas crlf csv1 csv2 csv3 \
+       dbugeval dbugeval2 \
        dbugeval3 dbugeval4 dbugtypedre1 dbugtypedre2 delsub \
        devfd devfd1 devfd2 dfacheck1 dumpvars \
        elemnew1 elemnew2 elemnew3 errno exit fieldwdth forcenum fpat1 fpat2 \
@@ -1609,7 +1614,7 @@ NEED_TRADITIONAL = litoct tradanch rscompat
 NEED_PMA = pma
 
 # List of tests that need --csv
-NEED_CSV = csv1 csv2
+NEED_CSV = csv1 csv2 csv3
 
 # Lists of tests that run a shell script
 RUN_SHELL = exit fflush localenl modifiers next randtest rtlen rtlen01
diff --git a/test/Makefile.in b/test/Makefile.in
index ce2c7744..22f67f0a 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -489,8 +489,12 @@ EXTRA_DIST = \
        crlf.ok \
        csv1.awk \
        csv1.in \
+       csv1.ok \
        csv2.awk \
        csv2.ok \
+       csv3.awk \
+       csv3.in \
+       csv3.ok \
        datanonl.awk \
        datanonl.in \
        datanonl.ok \
@@ -1771,7 +1775,8 @@ GAWK_EXT_TESTS = \
        aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \
        arraysort2 arraytype asortbool backw badargs beginfile1 beginfile2 \
        binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
-       clos1way5 clos1way6 colonwarn commas crlf csv1 csv2 dbugeval dbugeval2 \
+       clos1way5 clos1way6 colonwarn commas crlf csv1 csv2 csv3 \
+       dbugeval dbugeval2 \
        dbugeval3 dbugeval4 dbugtypedre1 dbugtypedre2 delsub \
        devfd devfd1 devfd2 dfacheck1 dumpvars \
        elemnew1 elemnew2 elemnew3 errno exit fieldwdth forcenum fpat1 fpat2 \
@@ -1873,7 +1878,7 @@ NEED_TRADITIONAL = litoct tradanch rscompat
 NEED_PMA = pma
 
 # List of tests that need --csv
-NEED_CSV = csv1 csv2
+NEED_CSV = csv1 csv2 csv3
 
 # Lists of tests that run a shell script
 RUN_SHELL = exit fflush localenl modifiers next randtest rtlen rtlen01
@@ -4496,6 +4501,11 @@ csv2:
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --csv >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+csv3:
+       @echo $@
+       @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --csv < "$(srcdir)"/$@.in >_$@ 
2>&1 || echo EXIT CODE: $$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 dbugeval2:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --debug < "$(srcdir)"/$@.in 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index ed1a050e..6dae6a56 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1422,6 +1422,11 @@ csv2:
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --csv >_$@ 2>&1 || echo EXIT 
CODE: $$? >>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+csv3:
+       @echo $@
+       @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --csv < "$(srcdir)"/$@.in >_$@ 
2>&1 || echo EXIT CODE: $$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 dbugeval2:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --debug < "$(srcdir)"/$@.in 
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@

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

Summary of changes:
 ChangeLog        |  4 ++++
 io.c             | 38 +++++++++++++++++++++++++++++++++++++-
 pc/ChangeLog     |  4 ++++
 pc/Makefile.tst  | 10 ++++++++--
 test/ChangeLog   |  5 +++++
 test/Makefile.am |  9 +++++++--
 test/Makefile.in | 14 ++++++++++++--
 test/Maketests   |  5 +++++
 8 files changed, 82 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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