Hello I have a problem with an old gawk-script. I did not write that script and I do not completely understand it, lacking good source-docs and being the longest awk-script I've ever seen.
When running with gawk 3.1.4 (on Fedora Core 4), the script worked as expected, but it broke after an update to gawk 3.1.5 (FC6), and I don't know, what changed in gawk, what made the program fail now. I found a workaround, but I prefer to understand, what the problem is. So if someone can enlighten me, please... Here's some code: ----- function AddFiles (path, files, input, vars, findRoot, matchPos, findCmd, pos, inPath, out) { matchPos = length(input)+2; ... ----- The function gets lines with path/files (output from a former find-command). matchPos is then used for some string manipulation, and did correctly calculated to be the length of the contents of 'input'+2. But in the newer version this failed. I could not see the error for some time, until I tested the following: ----- print " input=" input; print " substr(input, 1)=" substr(input, 1); matchPos = length(input)+2; print "StringLength1(" input ")=" length(input) " -> +2=" \ length(tolower(input))+2; print "StringLength2(" input ")=" length(tolower(input)) " -> +2=" \ length(tolower(input))+2; ----- and the output is: ----- input=/home/ilab/ThirdParty substr(input, 1)=$INPUT /home/ilab/Thi StringLength1(/home/ilab/ThirdParty)=28 -> +2=30 StringLength2(/home/ilab/ThirdParty)=21 -> +2=23 ----- This shows, if $input is printed with print(), it seems to have other contents as what is seen by substr() and obviously by length(). But using tolower() to input first, it "casts" the value of input, to what is expected. I'm not sure, what happens here. It seems, that input has two different types of contents (list and string, or list and list[1]), depending on how it is looked at. Does anyone know what is the reason for that? Or how I can find it out? Thanks and regards Stephan _______________________________________________ help-gnu-utils mailing list help-gnu-utils@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-utils