summaryrefslogtreecommitdiff
path: root/csv.c
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2020-06-23 21:31:17 +0200
committerThomas Schmucker <ts@its1.de>2020-06-23 21:31:17 +0200
commit6917ea6cc1747d69ba6481647c1fc0e0525e2c70 (patch)
tree8201c01a8782ba7332b142e0e16f8ca265735ecd /csv.c
parent7c525480d928e9791fc6e358a4b190b77c6181b1 (diff)
downloadlibcsv-6917ea6cc1747d69ba6481647c1fc0e0525e2c70.tar.gz
libcsv-6917ea6cc1747d69ba6481647c1fc0e0525e2c70.tar.bz2
libcsv-6917ea6cc1747d69ba6481647c1fc0e0525e2c70.zip
kleinere Überarbeitungen
Diffstat (limited to 'csv.c')
-rw-r--r--csv.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/csv.c b/csv.c
index 740dcb1..863d31d 100644
--- a/csv.c
+++ b/csv.c
@@ -479,18 +479,23 @@ csv_write(FILE *out, const csv_t * const csv)
479 479
480 const char SEP = csv->csv_options->field_separator; 480 const char SEP = csv->csv_options->field_separator;
481 481
482
482 if ( 0 < csv->csv_field.pos ) { 483 if ( 0 < csv->csv_field.pos ) {
483 csv_write_field(out, csv_field(csv, 0), csv->csv_options); 484 const char *str = csv->csv_string.str;
485 const int *field = csv->csv_field.fields;
486
487 csv_write_field(out, &str[*field++], csv->csv_options);
484 488
485 for ( int i = 1; i < csv->csv_field.pos; ++i ) { 489 for ( int i = 1; i < csv->csv_field.pos; ++i ) {
486 putc(SEP, out); 490 putc(SEP, out);
487 csv_write_field(out, csv_field(csv, i), csv->csv_options); 491 csv_write_field(out, &str[*field++], csv->csv_options);
488 } 492 }
489 } 493 }
490 fprintf(out, "\r\n"); 494 putc('\r', out);
495 putc('\n', out);
491 496
492 if ( ferror(out) ) { 497 if ( ferror(out) ) {
493 csv_fatal_error(CSV_ERR_IO_WRITE, csv_options); 498 csv_fatal_error(CSV_ERR_IO_WRITE, csv->csv_options);
494 } 499 }
495} 500}
496 501
@@ -517,7 +522,8 @@ csv_write_ex(FILE *out, int n, const char *fields[], const csv_options_t * csv_o
517 csv_write_field(out, *fields, csv_options); 522 csv_write_field(out, *fields, csv_options);
518 } 523 }
519 } 524 }
520 fprintf(out, "\r\n"); 525 putc('\r', out);
526 putc('\n', out);
521 527
522 if ( ferror(out) ) { 528 if ( ferror(out) ) {
523 csv_fatal_error(CSV_ERR_IO_WRITE, csv_options); 529 csv_fatal_error(CSV_ERR_IO_WRITE, csv_options);