diff options
author | obrien <obrien@FreeBSD.org> | 2003-03-17 07:59:59 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2003-03-17 07:59:59 +0000 |
commit | 153c5b8c9d890db78d0bdbc64269ada6c08661bf (patch) | |
tree | facd06c269655e229535d79d824e01ece98982ab /contrib/one-true-awk/lib.c | |
parent | bf37c5ab938db103c46d0b6252e8e37dbf1fe008 (diff) | |
download | FreeBSD-src-153c5b8c9d890db78d0bdbc64269ada6c08661bf.zip FreeBSD-src-153c5b8c9d890db78d0bdbc64269ada6c08661bf.tar.gz |
Vendor import of bwk's 14-March-2003 release.
Diffstat (limited to 'contrib/one-true-awk/lib.c')
-rw-r--r-- | contrib/one-true-awk/lib.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/contrib/one-true-awk/lib.c b/contrib/one-true-awk/lib.c index 630bbce..9e64247 100644 --- a/contrib/one-true-awk/lib.c +++ b/contrib/one-true-awk/lib.c @@ -308,6 +308,13 @@ void fldbld(void) /* create fields from current record */ } *fr = 0; } else if (*r != 0) { /* if 0, it's a null field */ + /* subtlecase : if length(FS) == 1 && length(RS > 0) + * \n is NOT a field separator (cf awk book 61,84). + * this variable is tested in the inner while loop. + */ + int rtest = '\n'; /* normal case */ + if (strlen(*RS) > 0) + rtest = '\0'; for (;;) { i++; if (i > nfields) @@ -316,7 +323,7 @@ void fldbld(void) /* create fields from current record */ xfree(fldtab[i]->sval); fldtab[i]->sval = fr; fldtab[i]->tval = FLD | STR | DONTFREE; - while (*r != sep && *r != '\n' && *r != '\0') /* \n is always a separator */ + while (*r != sep && *r != rtest && *r != '\0') /* \n is always a separator */ *fr++ = *r++; *fr++ = 0; if (*r++ == 0) |