[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Sample code in Gawk manual section 6.1.4
From: |
Aharon Robbins |
Subject: |
Re: [bug-gawk] Sample code in Gawk manual section 6.1.4 |
Date: |
Thu, 31 Jan 2013 20:15:25 +0200 |
User-agent: |
Heirloom mailx 12.5 6/20/10 |
Hi.
> Date: Wed, 30 Jan 2013 23:23:51 -0200
> From: Hermann Peifer <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] Sample code in Gawk manual section 6.1.4
>
> Hi,
>
> I believe that 2 examples in this section do not work as described in
> the manual. For running the tests, I changed my locale to [1].
>
> > awk 'BEGIN { printf "%g\n", 3.1415927 }'
> 3.14159 # not 3,14159, as stated in the manual
>
> > echo 4,321 | gawk '{ print $1 + 1 }'
> 5 # not 5,321, as stated in the manual
>
> The examples only work as documented after adding the --use-lc-numeric
> switch.
>
> > awk --use-lc-numeric 'BEGIN { printf "%g\n", 3.1415927 }'
> 3,14159
>
> > echo 4,321 | gawk --use-lc-numeric '{ print $1 + 1 }'
> 5,321
>
> Hermann
>
> [1]
> > locale
> LANG="da_DK.UTF-8"
> LC_COLLATE="da_DK.UTF-8"
> LC_CTYPE="da_DK.UTF-8"
> LC_MESSAGES="da_DK.UTF-8"
> LC_MONETARY="da_DK.UTF-8"
> LC_NUMERIC="da_DK.UTF-8"
> LC_TIME="da_DK.UTF-8"
> LC_ALL="da_DK.UTF-8"
>
> > gawk -V
> GNU Awk 4.0.73 (GNU MPFR 3.1.1-p2, GNU MP 5.0.5)
Thanks for the report. When that section was first written, gawk worked
as described. I later added description of --use-lc-numeric but didn't
rerun the example. I will shortly be pushing the change below to
clarify things.
Thanks,
Arnold
--------------------------
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 941d8e0..963923a 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -9585,18 +9585,19 @@ Here are some examples indicating the difference in
behavior,
on a GNU/Linux system:
@example
+$ @kbd{export POSIXLY_CORRECT=1} @ii{Force POSIX
behavior}
$ @kbd{gawk 'BEGIN @{ printf "%g\n", 3.1415927 @}'}
@print{} 3.14159
-$ @kbd{LC_ALL=en_DK gawk 'BEGIN @{ printf "%g\n", 3.1415927 @}'}
+$ @kbd{LC_ALL=en_DK.utf-8 gawk 'BEGIN @{ printf "%g\n", 3.1415927 @}'}
@print{} 3,14159
$ @kbd{echo 4,321 | gawk '@{ print $1 + 1 @}'}
@print{} 5
-$ @kbd{echo 4,321 | LC_ALL=en_DK gawk '@{ print $1 + 1 @}'}
+$ @kbd{echo 4,321 | LC_ALL=en_DK.utf-8 gawk '@{ print $1 + 1 @}'}
@print{} 5,321
@end example
@noindent
-The @samp{en_DK} locale is for English in Denmark, where the comma acts as
+The @samp{en_DK.utf-8} locale is for English in Denmark, where the comma acts
as
the decimal point separator. In the normal @code{"C"} locale, @command{gawk}
treats @samp{4,321} as @samp{4}, while in the Danish locale, it's treated
as the full number, 4.321.
@@ -9609,7 +9610,7 @@ decimal point character. You can use the
@option{--use-lc-numeric}
option (@pxref{Options}) to force @command{gawk} to use the locale's
decimal point character. (@command{gawk} also uses the locale's decimal
point character when in POSIX mode, either via @option{--posix}, or the
address@hidden environment variable.)
address@hidden environment variable, as shown previously.)
@ref{table-locale-affects} describes the cases in which the locale's decimal
point character is used and when a period is used. Some of these