[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Variable issue substr
From: |
Filimonov Vadim |
Subject: |
[bug-gawk] Variable issue substr |
Date: |
Thu, 14 May 2015 12:44:51 +0300 |
Hello!
There is some issue with using variables after substr.
Good case:
gawk 'BEGIN {a="2345";b="678";a1=substr(a,length(a),1);b1=substr(b,length(b),1);print a1,b1;for (i=a1;i<=b1;i++){print i}}'
5 8
5
6
7
8
Bad Case:
gawk 'BEGIN {a="2345";b="6789";a1=substr(a,length(a),1);b1=substr(b,length(b),1);print a1,b1;for (i=a1;i<=b1;i++){print i}}'
5 9
5
6
7
8
9
10
...
89
Another good case:
gawk 'BEGIN {a="2345";b="6789";a1=substr(a,length(a),1);b1=substr(b,length(b),1);print a1,b1;if (b1==9){b1=9};for (i=a1;i<=b1;i++){print i}}'
5 9
5
6
7
8
9
I didn't found anything unexpected in variable b1 after substr, so it should be recognized as 9, i think.
I'm rinning Ubuntu 14.04.2 LTS 3.13.0-52-generic
gawk --version
GNU Awk 4.0.1
- [bug-gawk] Variable issue substr,
Filimonov Vadim <=