Bug 59990 - substr does not work
Summary: substr does not work
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gawk (Show other bugs)
(Show other bugs)
Version: 7.2
Hardware: i386 Linux
Target Milestone: ---
Assignee: Florian La Roche
QA Contact: Brock Organ
Depends On:
TreeView+ depends on / blocked
Reported: 2002-02-18 13:06 UTC by Andreas Luik
Modified: 2007-04-18 16:40 UTC (History)
0 users

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

Attachments (Terms of Use)

Description Andreas Luik 2002-02-18 13:06:48 UTC
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 16:31:22 UTC
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.