diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2011-08-10 22:11:43 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2011-08-10 22:11:43 +0300 |
commit | 0d1a4f152fa45eda08b5877e4989c3250beb280e (patch) | |
tree | d253f655ee0791a348296f2886549e75b79a148f | |
parent | 9ef8db47d6ba6f91a44d5b0b31fad727eeaf122b (diff) | |
download | egawk-0d1a4f152fa45eda08b5877e4989c3250beb280e.tar.gz egawk-0d1a4f152fa45eda08b5877e4989c3250beb280e.tar.bz2 egawk-0d1a4f152fa45eda08b5877e4989c3250beb280e.zip |
Fix problem with FIELDWIDTHS.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | field.c | 6 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/fwtest3.awk | 1 | ||||
-rw-r--r-- | test/fwtest3.in | 1 | ||||
-rw-r--r-- | test/fwtest3.ok | 1 |
7 files changed, 22 insertions, 4 deletions
@@ -1,3 +1,10 @@ +2011-08-10 Arnold D. Robbins <arnold@skeeve.com> + + Fix (apparently long-standing) problem with FIELDWIDTHS. + Thanks to Johannes Meixner <jsmeix@suse.de>. + + * field.c (set_FIELDWIDTHS): Adjust calculations. + 2011-08-09 Arnold D. Robbins <arnold@skeeve.com> Fix pty issue reported by "T. X. G." <leopardie333@yahoo.com> @@ -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"); diff --git a/test/ChangeLog b/test/ChangeLog index 8db0443c..87b9cf12 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2011-08-10 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (fwtest3): New test. + * fwtest3.awk, fwtest3.in, fwtest3.ok: New files. + 2011-08-09 Arnold D. Robbins <arnold@skeeve.com> * pty1.awk, pty1.ok: New files. diff --git a/test/Makefile.am b/test/Makefile.am index 2d1b422b..43b26599 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -271,6 +271,9 @@ EXTRA_DIST = \ fwtest2.awk \ fwtest2.in \ fwtest2.ok \ + fwtest3.awk \ + fwtest3.in \ + fwtest3.ok \ gensub.awk \ gensub.in \ gensub.ok \ @@ -805,7 +808,7 @@ GAWK_EXT_TESTS = \ aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ backw badargs beginfile1 binmode1 clos1way delsub devfd devfd1 \ devfd2 dumpvars exit fieldwdth fpat1 fpat2 fpatnull fsfwfs funlen \ - fwtest fwtest2 gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ + fwtest fwtest2 fwtest3 gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ icasefs icasers igncdym igncfs ignrcas2 ignrcase indirectcall lint \ lintold lintwarn manyfiles match1 match2 match3 mbstr1 nastyparm \ next nondec nondec2 patsplit posix printfbad1 printfbad2 procinfs \ diff --git a/test/fwtest3.awk b/test/fwtest3.awk new file mode 100644 index 00000000..d1384eaf --- /dev/null +++ b/test/fwtest3.awk @@ -0,0 +1 @@ +BEGIN { FIELDWIDTHS="5" } { print $1 } diff --git a/test/fwtest3.in b/test/fwtest3.in new file mode 100644 index 00000000..a32a4347 --- /dev/null +++ b/test/fwtest3.in @@ -0,0 +1 @@ +1234567890 diff --git a/test/fwtest3.ok b/test/fwtest3.ok new file mode 100644 index 00000000..e56e15bb --- /dev/null +++ b/test/fwtest3.ok @@ -0,0 +1 @@ +12345 |