Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

substr() strange behaviour

Status
Not open for further replies.

dpedro

Programmer
Joined
Dec 15, 2009
Messages
2
Location
PL
Hi there.
Does anyone have explanation to following awk behaviour?
Fragment of my code:

print( "value root: " $0);
print("substr: " substr($0 ,3));

awk prints:

value root: ="1177" platform="3" producer="9" wap="true"
substr: false" id="1177" platform="3" producer="9"

OS is Linux Fedora Core 6. GAWK v. 3.1.5

What is strange too, this works fine on Windows version of GNU gawk.
 
in short input was:

<phone artificial="false" id="1177" platform="3" producer="9" wap="true">
<name>Asus M530w</name>
<identifier>M530w</identifier>
<info>Asus M530w</info>
<ua>Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 6.12) ASUSM530w/1.0</ua>
</phone>

I was trying to parse whole xml with Steve Colie's parser (ftp://ftp.freefriends.org/arnold/Awkstuff/xmlparser.awk). Seems like this behaviour occurs only in gawk 3.1.5, as with newer versions everything seems ok.

Thanks anyway :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top