For Programmers: Free Programming Magazines  


Home > Archive > AWK > March 2004 > 'FS and IGNORECASE' does GnuWin32 & *nix differ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author 'FS and IGNORECASE' does GnuWin32 & *nix differ?
Will Ganz

2004-03-19, 8:23 pm

OS - W2k Adv Server
gawk - ver 3.1.0.2
Node:Field Splitting Summary
Advanced Notes: FS and IGNORECASE

http://www.gnu.org/software/gawk/ma...awk.html#Field%
20Splitting%20Summary
The documentation states, "The IGNORECASE variable affects field
splitting only when the value of FS is a regexp." It gives the sample
*nix code of:

FS = "c"
IGNORECASE = 1
$4 = "aCa"
print

The documentation states, " aCa." But note the difference with the
GnuWin32 code:

********* test.txt **********
aCa
********* sample.awk **********
BEGIN { FS = "c"
IGNORECASE = 1
}
{ print $1 }

C:\>awk -f sample.awk test.txt
a

The output is 'a' v.s. the stated 'aCa'. Is this a difference in the
GnuWin32 implementation or what am I missing??

Regards,

Will

--
¡Microsoft delenda est!
Kenny McCormack

2004-03-19, 8:23 pm

In article <Xns949764F98A12Bwganztexomanet@129.250.170.85>,
Will Ganz <wganz__trash_MAPS¶_@texoma.net> wrote:
>OS - W2k Adv Server
>gawk - ver 3.1.0.2
>Node:Field Splitting Summary
>Advanced Notes: FS and IGNORECASE
>
>http://www.gnu.org/software/gawk/ma...awk.html#Field%
>20Splitting%20Summary
>The documentation states, "The IGNORECASE variable affects field
>splitting only when the value of FS is a regexp." It gives the sample
>*nix code of:
>
>FS = "c"
>IGNORECASE = 1
>$4 = "aCa"
>print
>
>The documentation states, " aCa." But note the difference with the
>GnuWin32 code:
>
>********* test.txt **********
>aCa
>********* sample.awk **********
>BEGIN { FS = "c"
>IGNORECASE = 1
>}
>{ print $1 }
>
>C:\>awk -f sample.awk test.txt
>a
>
>The output is 'a' v.s. the stated 'aCa'. Is this a difference in the
>GnuWin32 implementation or what am I missing??


Corroborating what you've observed under Unix, I get:

(pts/0:983) % echo aCa | gawk 'BEGIN{FS="c";IGNORECASE=1}{print $1}'
aCa
(pts/0:984) % echo aCa | gawk 'BEGIN{FS="[c]";IGNORECASE=1}{print $1}'
a
(pts/0:985) %

So, there must be something wrong with whatever DOS/Windows port you are
using, since the Unix behavior is the "gold standard".

Where did your port come from? Who compiled it?

Will Ganz

2004-03-19, 8:23 pm

> Corroborating what you've observed under Unix, I get:

Thanks for the followup.


>
> Where did your port come from? Who compiled it?


http://sourceforge.net/project/show...617&package_id=
16431

It is a the standard binary download from SourceForge. I got a response
from a posting to the HELP forum for GnuWin32 that said,

"The GnuWin32 changes to the sources are only concerned with timezones
and the declaration of setmode (see gawk-3.1.0_GNUWIN32.diffs in the
sources). So it is not very likely that this difference is related to the
GnuWin32 implementation as such."

For clarity of the output, changed the content of test.txt to:

aCb

and sample.awk to:

BEGIN { FS = "c"
IGNORECASE = 1 }
{ print $1 }
END {print "$0 :="$0" $1 :="$1" $2 :="$2 " NR :="NR" NF :="NF}

To get:

C:\>awk -f sample.awk test.txt
a
$0 :=aCb $1 :=a $2 :=b NR :=1 NF :=2

¿Can anyone independently verify this on a Win32 box?

Thanks,

Will


--
¡Microsoft delenda est!
Dan

2004-03-19, 8:23 pm

"Will Ganz" <wganz__trash_MAPS¶_@texoma.net> wrote in message
news:Xns9497881D13E2Fwganztexomanet@129.250.170.83...
> C:\>awk -f sample.awk test.txt
> a
> $0 :=aCb $1 :=a $2 :=b NR :=1 NF :=2
>
> ¿Can anyone independently verify this on a Win32 box?


I can corroborate what you're getting from the SF binaries. Gawk 3.1.3
produces the correct output, though, and builds right out of the box using
Visual Studio without any mods. Similarly, version 3.1.2g is also correct.

SF's 3.1.0-1 also reports the wrong value for NF, too, doesn't it? The
program file should not be included, should it?

Given:

test.txt----------
aCb

sample.awk-------
BEGIN { FS = "c"
IGNORECASE = 1 }
{ print $1 }
END {print "$0 :="$0" $1 :="$1" $2 :="$2 " NR :="NR" NF :="NF}

output--------

aCb
$0 :=aCb $1 :=aCb $2 := NR :=1 NF :=1


-- Dan


Will Ganz

2004-03-19, 8:23 pm

> I can corroborate what you're getting from the SF binaries. Gawk
> 3.1.3 produces the correct output, though, and builds right out of the
> box using Visual Studio without any mods. Similarly, version 3.1.2g
> is also correct.


Checked and found

"Gawk 3.1.0 pattern scanning and processing"

at

http://gnuwin32.sourceforge.net/packages.html. Did you get the 3.1.3 source
for Win32 from http://ftp.gnu.org/gnu/gawk/ ?

Regards,

Will
Aharon Robbins

2004-03-19, 8:23 pm

In article <103itc3i5mrjf5@corp.supernews.com>,
Dan <dan@nohormelmeat.com> wrote:
>"Will Ganz" <wganz__trash_MAPS¶_@texoma.net> wrote in message
>Similarly, version 3.1.2g is also correct.


Where are you getting 3.1.2g from? Any release with a letter in it is a
test release (even if a publicly announced beta) and should N E V E R be
used for production.

Arnold
--
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd. arnold AT skeeve DOT com
P.O. Box 354 Home Phone: +972 8 979-0381 Fax: +1 530 688 5518
Nof Ayalon Cell Phone: +972 51 297-545
D.N. Shimshon 99785 ISRAEL
Dan

2004-03-19, 8:23 pm

> Where are you getting 3.1.2g from? Any release with a letter in it is a
> test release (even if a publicly announced beta) and should N E V E R be
> used for production.


It's not being used for production, I just had a compiled version lying
around and gave it a try as well on the off chance it might narrow down
where the OP's problem might be.


-- Dan


Dan

2004-03-19, 8:23 pm

> http://gnuwin32.sourceforge.net/packages.html. Did you get the 3.1.3
> source for Win32 from http://ftp.gnu.org/gnu/gawk/ ?


Yep.

-- Dan




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com