Handle possible FS/RS characters by exiting and printing message on stderr - 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 4e2c2f36e4096c4d84d31a4db1d8dd682aabe52a
(DIR) parent 714cfcac6912064b106651f0832082b02eb57957
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Tue, 25 Jun 2019 17:57:04
Handle possible FS/RS characters by exiting and printing message on stderr
Diffstat:
TODO.txt | 2 --
csvtofsv.c | 8 ++++++++
2 files changed, 8 insertions(+), 2 deletions(-)
---
diff -r 714cfcac6912 -r 4e2c2f36e409 TODO.txt
--- a/TODO.txt Tue Jun 25 15:49:00 2019 +0200
+++ b/TODO.txt Tue Jun 25 17:57:04 2019 +0200
@@ -1,7 +1,5 @@
Possible known todo and parsing mistakes:
-- Gracefully handle FS and RS characters are present in CSV (probably by
- returning a non-0 exit status)
- `\r' should be always ignored
- Trailing EOF without a `\n' or `\r\n' is not gracefully handled
- Add more tests and tests funny things like `","","' (according RFC
diff -r 714cfcac6912 -r 4e2c2f36e409 csvtofsv.c
--- a/csvtofsv.c Tue Jun 25 15:49:00 2019 +0200
+++ b/csvtofsv.c Tue Jun 25 17:57:04 2019 +0200
@@ -82,6 +82,14 @@
case '\r':
/* ignore */
break;
+ case FS:
+ fprintf(stderr, "FS character found, stopping.\n");
+ return 1;
+ break; /* NOTREACHED */
+ case RS:
+ fprintf(stderr, "RS character found, stopping.\n");
+ return 1;
+ break; /* NOTREACHED */
default:
putchar(c);
break;