In article <m51vh4$bcd$
2...@news.xmission.com>,
An update:
This seems to be fixed in 4.1.3. It complains about anything unexpected
(i.e., other than 1 or "G" or "g") in the third arg. See below:
('gawk4' is version 4.1.3, 'gawk41' is version 4.1.1)
% gawk4 'BEGIN { print gensub("abc","DEF",-1,"abcdefghikl")}'
gawk4: cmd. line:1: warning: gensub: third argument -1 treated as 1
DEFdefghikl
% gawk41 'BEGIN { print gensub("abc","DEF",-1,"abcdefghikl")}'
DEFdefghikl
%
Yey! It seems complaints here do get noticed (sometimes...)
Also note, I have the following script installed on various of my systems
to "comma-ize" numbers. I copied it from this board some time back:
--- Cut Here ---
function comma(num) {
if (num < 0)
return "-" comma(-num)
while (num != (num=gensub(/([0-9])([0-9][0-9][0-9])($|[,.])/,"\\1,\\2\\3","",num)));
return num
}
--- Cut Here ---
Note the use of "" as the 3rd arg to gensub(). I'm sure that was in the
original (i.e., whoever originally wrote and posted the script had that).
The funny thing is that this script worked just fine right up until I
compiled and started using 4.1.3, which as we've seen now generates a
warning for that usage. So, I had to change it to use 1 instead of "".
--
The scent of awk programmers is a lot more attractive to women than
the scent of perl programmers.
(Mike Brennan, quoted in the "GAWK" manual)