Print an error message for negative NF values
This commit is contained in:
parent
6315525dbe
commit
179536a516
@ -25,3 +25,5 @@ and also if CONVFMT changed.
|
|||||||
Instead, it should convert the value to numeric and give that value.
|
Instead, it should convert the value to numeric and give that value.
|
||||||
|
|
||||||
X. nf-self-assign: "NF = NF" wouldn't force the record to be rebuilt.
|
X. nf-self-assign: "NF = NF" wouldn't force the record to be rebuilt.
|
||||||
|
|
||||||
|
X. negative-nf: Setting NF to a negative value caused a segmentation fault.
|
||||||
|
1
bugs-fixed/negative-nf.awk
Normal file
1
bugs-fixed/negative-nf.awk
Normal file
@ -0,0 +1 @@
|
|||||||
|
BEGIN { NF = -5; }
|
2
bugs-fixed/negative-nf.ok
Normal file
2
bugs-fixed/negative-nf.ok
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
./a.out: cannot set NF to a negative value
|
||||||
|
source line number 1
|
2
lib.c
2
lib.c
@ -390,6 +390,8 @@ void newfld(int n) /* add field n after end of existing lastfld */
|
|||||||
|
|
||||||
void setlastfld(int n) /* set lastfld cleaning fldtab cells if necessary */
|
void setlastfld(int n) /* set lastfld cleaning fldtab cells if necessary */
|
||||||
{
|
{
|
||||||
|
if (n < 0)
|
||||||
|
FATAL("cannot set NF to a negative value");
|
||||||
if (n > nfields)
|
if (n > nfields)
|
||||||
growfldtab(n);
|
growfldtab(n);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user