aboutsummaryrefslogtreecommitdiffstats
path: root/field.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2011-08-10 22:11:43 +0300
committerArnold D. Robbins <arnold@skeeve.com>2011-08-10 22:11:43 +0300
commit0d1a4f152fa45eda08b5877e4989c3250beb280e (patch)
treed253f655ee0791a348296f2886549e75b79a148f /field.c
parent9ef8db47d6ba6f91a44d5b0b31fad727eeaf122b (diff)
downloadegawk-0d1a4f152fa45eda08b5877e4989c3250beb280e.tar.gz
egawk-0d1a4f152fa45eda08b5877e4989c3250beb280e.tar.bz2
egawk-0d1a4f152fa45eda08b5877e4989c3250beb280e.zip
Fix problem with FIELDWIDTHS.
Diffstat (limited to 'field.c')
-rw-r--r--field.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/field.c b/field.c
index 0b9c1008..148f8f0b 100644
--- a/field.c
+++ b/field.c
@@ -1126,10 +1126,12 @@ set_FIELDWIDTHS()
FIELDWIDTHS[0] = 0;
for (i = 1; ; i++) {
unsigned long int tmp;
- if (i + 1 >= fw_alloc) {
+ if (i + 2 >= fw_alloc) {
fw_alloc *= 2;
erealloc(FIELDWIDTHS, int *, fw_alloc * sizeof(int), "set_FIELDWIDTHS");
}
+ /* Initialize value to be end of list */
+ FIELDWIDTHS[i] = -1;
/* Ensure that there is no leading `-' sign. Otherwise,
strtoul would accept it and return a bogus result. */
while (is_blank(*scan)) {
@@ -1163,8 +1165,6 @@ set_FIELDWIDTHS()
if (*scan == '\0')
break;
}
- if (i == 1) /* empty string! */
- i--;
FIELDWIDTHS[i+1] = -1;
update_PROCINFO_str("FS", "FIELDWIDTHS");