diff options
author | ozan yigit <ozan.yigit@gmail.com> | 2023-11-27 23:13:53 -0500 |
---|---|---|
committer | ozan yigit <ozan.yigit@gmail.com> | 2023-11-27 23:13:53 -0500 |
commit | a9642137999b3cefaca03d53e6f42b0a458fa13b (patch) | |
tree | 814ec57c50b972d5f43cf2dfedb7176d71c61291 | |
parent | 0096fa60008346f24de36064930c911ced766961 (diff) | |
download | one-true-awk-a9642137999b3cefaca03d53e6f42b0a458fa13b.tar.gz |
Wilbert van der Poel's fixes to inconsistent handling of -F and --csv.
-rw-r--r-- | lib.c | 2 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rwxr-xr-x | testdir/T.csv | 4 |
3 files changed, 7 insertions, 3 deletions
@@ -399,7 +399,7 @@ void fldbld(void) /* create fields from current record */ i = 0; /* number of fields accumulated here */ if (inputFS == NULL) /* make sure we have a copy of FS */ savefs(); - if (strlen(inputFS) > 1) { /* it's a regular expression */ + if (!CSV && strlen(inputFS) > 1) { /* it's a regular expression */ i = refldbld(r, inputFS); } else if (!CSV && (sep = *inputFS) == ' ') { /* default whitespace */ for (i = 0; ; ) { @@ -157,6 +157,8 @@ int main(int argc, char *argv[]) } if (strcmp(argv[1], "--csv") == 0) { /* turn on csv input processing */ CSV = true; + if (fs) + WARNING("danger: don't set FS when --csv is in effect"); argc--; argv++; continue; @@ -178,6 +180,8 @@ int main(int argc, char *argv[]) break; case 'F': /* set field separator */ fs = setfs(getarg(&argc, &argv, "no field separator")); + if (CSV) + WARNING("danger: don't set FS when --csv is in effect"); break; case 'v': /* -v a=1 to be done NOW. one -v for each */ vn = getarg(&argc, &argv, "no variable name"); diff --git a/testdir/T.csv b/testdir/T.csv index 79c1510..40ef0c6 100755 --- a/testdir/T.csv +++ b/testdir/T.csv @@ -17,8 +17,8 @@ $1 ~ /try/ { # new test sub(/try /, "") prog = $0 printf("%3d %s\n", nt, prog) - prog = sprintf("%s -F\"\\t\" '"'"'%s'"'"'", awk, prog) - # print "prog is", prog + prog = sprintf("%s '"'"'%s'"'"'", awk, prog) + print "prog is", prog nt2 = 0 while (getline > 0) { if (NF == 0) # blank line terminates a sequence |