Re: awk setlocale(LC_NUMERIC)

2017-11-01 Thread Christian Weisgerber
On 2017-11-01, Jan Stary  wrote:

> Why does awk need to fiddle with LC_NUMERIC?

You don't want to parse your awk program in a locale where the
decimal separator is a comma.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: awk setlocale(LC_NUMERIC)

2017-11-01 Thread Jeremie Courreges-Anglas
On Wed, Nov 01 2017, Jan Stary  wrote:
> Why does awk need to fiddle with LC_NUMERIC?

awk is not developed in OpenBSD land[1].  Since LC_NUMERIC doesn't have
any effect on OpenBSD I'd rather just let this code be.

[1] https://www.cs.princeton.edu/~bwk/btl.mirror/

>   Jan
>
> Index: main.c
> ===
> RCS file: /cvs/src/usr.bin/awk/main.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 main.c
> --- main.c9 Oct 2017 14:51:31 -   1.21
> +++ main.c1 Nov 2017 15:50:11 -
> @@ -28,7 +28,6 @@ const char  *version = "version 20110810"
>  #define DEBUG
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -61,9 +60,6 @@ int main(int argc, char *argv[])
>  {
>   const char *fs = NULL;
>  
> - setlocale(LC_ALL, "");
> - setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
> -
>   cmdname = __progname;
>   if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) {
>   fprintf(stderr, "%s: pledge: incorrect arguments\n",
> @@ -185,7 +181,6 @@ int main(int argc, char *argv[])
>   if (!safe)
>   envinit(environ);
>   yyparse();
> - setlocale(LC_NUMERIC, ""); /* back to whatever it is locally */
>   if (fs)
>   *FS = qstring(fs, '\0');
>  DPRINTF( ("errorflag=%d\n", errorflag) );
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



awk setlocale(LC_NUMERIC)

2017-11-01 Thread Jan Stary
Why does awk need to fiddle with LC_NUMERIC?

Jan

Index: main.c
===
RCS file: /cvs/src/usr.bin/awk/main.c,v
retrieving revision 1.21
diff -u -p -r1.21 main.c
--- main.c  9 Oct 2017 14:51:31 -   1.21
+++ main.c  1 Nov 2017 15:50:11 -
@@ -28,7 +28,6 @@ const char*version = "version 20110810"
 #define DEBUG
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -61,9 +60,6 @@ int main(int argc, char *argv[])
 {
const char *fs = NULL;
 
-   setlocale(LC_ALL, "");
-   setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
-
cmdname = __progname;
if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) {
fprintf(stderr, "%s: pledge: incorrect arguments\n",
@@ -185,7 +181,6 @@ int main(int argc, char *argv[])
if (!safe)
envinit(environ);
yyparse();
-   setlocale(LC_NUMERIC, ""); /* back to whatever it is locally */
if (fs)
*FS = qstring(fs, '\0');
   DPRINTF( ("errorflag=%d\n", errorflag) );