| Always ignore `\r' - csvtofsv - Convert CSV to FSV (`fs' (0x1c) as FS and `rs' … | |
| hg clone https://bitbucket.org/iamleot/csvtofsv | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| changeset 608f7b88a31953db62b60dfc640fa9a94f4e173b | |
| parent 0f663dfebd899a84c493d50764548d64d20e08e9 | |
| Author: Leonardo Taccari <[email protected]> | |
| Date: Wed, 26 Jun 2019 01:59:21 | |
| Always ignore `\r' | |
| Diffstat: | |
| TODO.txt | 1 - | |
| csvtofsv.c | 6 +++++- | |
| 2 files changed, 5 insertions(+), 2 deletions(-) | |
| --- | |
| diff -r 0f663dfebd89 -r 608f7b88a319 TODO.txt | |
| --- a/TODO.txt Wed Jun 26 01:55:40 2019 +0200 | |
| +++ b/TODO.txt Wed Jun 26 01:59:21 2019 +0200 | |
| @@ -1,4 +1,3 @@ | |
| Possible known todo and parsing mistakes: | |
| -- `\r' should be always ignored | |
| - Add more tests and recheck RFC 4180 | |
| diff -r 0f663dfebd89 -r 608f7b88a319 csvtofsv.c | |
| --- a/csvtofsv.c Wed Jun 26 01:55:40 2019 +0200 | |
| +++ b/csvtofsv.c Wed Jun 26 01:59:21 2019 +0200 | |
| @@ -58,10 +58,14 @@ | |
| putchar(FS); | |
| first = true; | |
| quoted = false; | |
| - } else if (nc == '\n') { | |
| + } else if ((nc == '\n') || | |
| + ((nc == '\r') && | |
| + ((nc = getchar()) == '\n'))) { | |
| putchar(RS); | |
| first = true; | |
| quoted = false; | |
| + } else { | |
| + ungetc(nc, stdin); | |
| } | |
| } | |
| break; |