Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 59990 - substr does not work
substr does not work
Product: Red Hat Linux
Classification: Retired
Component: gawk (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Florian La Roche
Brock Organ
Depends On:
  Show dependency treegraph
Reported: 2002-02-18 08:06 EST by Andreas Luik
Modified: 2007-04-18 12:40 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-02-18 11:31:27 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Andreas Luik 2002-02-18 08:06:48 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.76 [en] (X11; U; SunOS 5.6 sun4u)

Description of problem:
The attached awk script does not return the correct output, but mostly
return nothing, which seems to be a failure of the substr() function,
which returns the empty string.

        lower = "abcdefghijklmnopqrstuvwxyz";
        value = "0123456789";
        Z = index(upper, "Z") + 1;
        V = index(value, "9") + 1;
        str = ""
        for (i=1; i <= length($1); i++)
                c = substr($1, i, 1);
                if      (c == "-") a = "-"
                else if (c == ".") a = "."
                else if (c ~ /[0-9]/) a = substr(value, V-index(value,c), 1)
                else if (c ~ /[A-Z]/) a = substr(upper, Z-index(upper,c), 1)
                else  a = substr(lower, Z-index(lower,c), 1);
                str = str a;
        print str;

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.Save abovementioned test.awk to a file
    $ echo foo-bar | awk -f test.awk
3.Observe, that the output is "-z", correct output would be


Actual Results:  $ echo foo-bar | gawk-3.1.0 -f test.awk

Expected Results:  on a RedHat 6.2 platform:

$ echo foo-bar | gawk -f test.awk

Additional info:

1. the problem also exists with a gawk compiled from gawk-3.1.0 sources on
RedHat 7.2.
2. the problem does not exist with a gawk compiled from gawk-3.1.0
sources on RedHat 7.1.
3. the problem does not exist with the gawk-3.0.6 binary from
RedHat 7.1.
Comment 1 Florian La Roche 2002-02-18 11:31:22 EST
This seems to work fine for me on a 7.2 system with the current errata rpms
from ftp.redhat.com applied. Does it make a difference if the glibc update
is applied? What is set in /etc/sysconfig/i18n?


Florian La Roche

Note You need to log in before you can comment on or make changes to this bug.