Simplify a bit the logic for parsing non-first `"' characters, NFCI - csvtofsv - Convert CSV to FSV (`fs' (0x1c) as FS and `rs' (0x1e) as RS)
(HTM) hg clone https://bitbucket.org/iamleot/csvtofsv
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset 15cc17278b19026cf5d1688a817c1894550eedc8
(DIR) parent 1934375d22a116a1139a90874da7ffcf7d24e930
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Wed, 26 Jun 2019 01:05:46
Simplify a bit the logic for parsing non-first `"' characters, NFCI
Diffstat:
csvtofsv.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
---
diff -r 1934375d22a1 -r 15cc17278b19 csvtofsv.c
--- a/csvtofsv.c Wed Jun 26 00:24:22 2019 +0200
+++ b/csvtofsv.c Wed Jun 26 01:05:46 2019 +0200
@@ -47,19 +47,19 @@
quoted = true;
first = false;
} else if ((nc = getchar()) != EOF) {
- if (quoted && nc == '"') {
+ if (!quoted) {
+ putchar(c);
+ ungetc(nc, stdin);
+ } else if (nc == '"') {
putchar('"');
- } else if (quoted && nc == ',') {
+ } else if (nc == ',') {
putchar(FS);
first = true;
quoted = false;
- } else if (quoted && nc == '\n') {
+ } else if (nc == '\n') {
putchar(RS);
first = true;
quoted = false;
- } else {
- putchar(c);
- ungetc(nc, stdin);
}
}
break;