diff options
| author | Thomas Schmucker <ts@its1.de> | 2020-06-19 11:48:31 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2020-06-19 11:48:31 +0200 |
| commit | 4f23f3d2b3137ca369c5e27f833a13e329431505 (patch) | |
| tree | 96ebbda5ada049bab73aff6748a6679bfdc17892 | |
| parent | 08909bd2ef53a6110fa2210fefa6d94647f5520f (diff) | |
| download | libcsv-4f23f3d2b3137ca369c5e27f833a13e329431505.tar.gz libcsv-4f23f3d2b3137ca369c5e27f833a13e329431505.tar.bz2 libcsv-4f23f3d2b3137ca369c5e27f833a13e329431505.zip | |
Vereinfache das Interface noch weiter...
| -rw-r--r-- | csv-test.c | 5 | ||||
| -rw-r--r-- | csv.c | 5 |
2 files changed, 7 insertions, 3 deletions
| @@ -10,10 +10,9 @@ static int | |||
| 10 | test(FILE *f) | 10 | test(FILE *f) |
| 11 | { | 11 | { |
| 12 | int line = 0; | 12 | int line = 0; |
| 13 | csv_t csv[1]; | 13 | csv_t csv = { 0 }; |
| 14 | 14 | ||
| 15 | csv_init(csv); | 15 | while ( csv_read(&csv, f) != -1 ) { |
| 16 | for ( int n; (n = csv_read(csv, f)) != -1; ) { | ||
| 17 | ++line; | 16 | ++line; |
| 18 | } | 17 | } |
| 19 | 18 | ||
| @@ -257,6 +257,11 @@ csv_read(csv_t *csv, FILE *in) | |||
| 257 | assert(csv != NULL); | 257 | assert(csv != NULL); |
| 258 | assert(in != NULL); | 258 | assert(in != NULL); |
| 259 | 259 | ||
| 260 | /* initialze if needed... */ | ||
| 261 | if ( csv->csv_options == NULL ) { | ||
| 262 | csv_init(csv); | ||
| 263 | } | ||
| 264 | |||
| 260 | /* do not try to read if EOF has already been seen */ | 265 | /* do not try to read if EOF has already been seen */ |
| 261 | if ( feof(in) ) { | 266 | if ( feof(in) ) { |
| 262 | csv_cleanup(csv); | 267 | csv_cleanup(csv); |
