mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-25 08:53:55 +00:00
autodetect iterate: default-auto per format
This commit is contained in:
parent
88511733fd
commit
0e2b1e5fd4
3 changed files with 9 additions and 6 deletions
|
|
@ -384,8 +384,8 @@ static lhmss_t* get_default_rses() {
|
|||
// lhmss_put(singleton_default_rses, "nidx", "\n", NO_FREE);
|
||||
lhmss_put(singleton_default_rses, "nidx", "auto", NO_FREE);
|
||||
|
||||
// char* csv_rs = "\r\n";
|
||||
char* csv_rs = "auto";
|
||||
char* csv_rs = "\r\n";
|
||||
// char* csv_rs = "auto";
|
||||
char* env_default = getenv("MLR_CSV_DEFAULT_RS");
|
||||
if (env_default != NULL && !streq(env_default, ""))
|
||||
csv_rs = cli_sep_from_arg(env_default);
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ lrec_writer_t* lrec_writer_csv_alloc(char* ors, char* ofs, quoting_t oquoting, i
|
|||
pstate->num_header_lines_output = 0LL;
|
||||
pstate->plast_header_output = NULL;
|
||||
|
||||
plrec_writer->pvstate = (void*)pstate;
|
||||
plrec_writer->pvstate = (void*)pstate;
|
||||
plrec_writer->pprocess_func = streq(ors, "auto")
|
||||
? lrec_writer_csv_process_auto_ors
|
||||
: lrec_writer_csv_process_nonauto_ors;
|
||||
plrec_writer->pfree_func = lrec_writer_csv_free;
|
||||
plrec_writer->pfree_func = lrec_writer_csv_free;
|
||||
|
||||
return plrec_writer;
|
||||
}
|
||||
|
|
@ -87,6 +87,7 @@ static void lrec_writer_csv_process(void* pvstate, FILE* output_stream, lrec_t*
|
|||
return;
|
||||
lrec_writer_csv_state_t* pstate = pvstate;
|
||||
char *ofs = pstate->ofs;
|
||||
int orslen = strlen(ors);
|
||||
|
||||
if (pstate->plast_header_output != NULL) {
|
||||
if (!lrec_keys_equal_list(prec, pstate->plast_header_output)) {
|
||||
|
|
@ -104,7 +105,7 @@ static void lrec_writer_csv_process(void* pvstate, FILE* output_stream, lrec_t*
|
|||
if (nf > 0)
|
||||
fputs(ofs, output_stream);
|
||||
pstate->pquoted_output_func(output_stream, pe->key, pstate->ors, pstate->ofs,
|
||||
pstate->orslen, pstate->ofslen, 0);
|
||||
orslen, pstate->ofslen, 0);
|
||||
nf++;
|
||||
}
|
||||
fputs(ors, output_stream);
|
||||
|
|
@ -118,7 +119,7 @@ static void lrec_writer_csv_process(void* pvstate, FILE* output_stream, lrec_t*
|
|||
if (nf > 0)
|
||||
fputs(ofs, output_stream);
|
||||
pstate->pquoted_output_func(output_stream, pe->value, pstate->ors, pstate->ofs,
|
||||
pstate->orslen, pstate->ofslen, pe->quote_flags);
|
||||
orslen, pstate->ofslen, pe->quote_flags);
|
||||
nf++;
|
||||
}
|
||||
fputs(ors, output_stream);
|
||||
|
|
|
|||
|
|
@ -63,8 +63,10 @@ AUTOTERM
|
|||
|
||||
! input/lrec_reader_mmap_xtab.c
|
||||
- needs ifs=auto -> ifs=auto transmutate @ caller
|
||||
mlr --csv --ors auto cat reg_test/input/rfc-csv/quoted-crlf.csv
|
||||
! input/lrec_reader_stdio_xtab.c
|
||||
- needs ifs=auto -> ifs=auto transmutate @ caller
|
||||
mlr --csv --ors auto cat < reg_test/input/rfc-csv/quoted-crlf.csv
|
||||
|
||||
|
||||
k input/lrec_reader_mmap_csv.c
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue