Re: locale in who(1)

2021-11-10 Thread Ingo Schwarze
Hi,

Martijn van Duren wrote on Wed, Nov 10, 2021 at 02:03:51PM +0100:

> I see no reason to keep it.
> OK martijn@ if anyone wants to commit this.

Done.

> On Wed, 2021-11-10 at 13:37 +0100, Jan Stary wrote:

>> Why does who(1) need to setlocale()?

On some systems, setlocale(LC_TIME) influences strftime(3).
But who(1) uses ctime(3) instead, and

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html

explicitly mentions that ctime(3) does not support localized date and
time formats.

Anyway, we clearly do not want localization in such a place,
neither now nor in the future.

Yours,
  Ingo


>> Index: who.c
>> ===
>> RCS file: /cvs/src/usr.bin/who/who.c,v
>> retrieving revision 1.30
>> diff -u -p -r1.30 who.c
>> --- who.c12 Jul 2021 15:09:20 -  1.30
>> +++ who.c10 Nov 2021 12:37:05 -
>> @@ -44,7 +44,6 @@
>>  #include 
>>  #include 
>>  #include 
>> -#include 
>>  
>>  void  output(struct utmp *);
>>  void  output_labels(void);
>> @@ -71,8 +70,6 @@ main(int argc, char *argv[])
>>  FILE *ufp;
>>  char *t;
>>  int c;
>> -
>> -setlocale(LC_ALL, "");
>>  
>>  if (pledge("stdio unveil rpath getpw", NULL) == -1)
>>  err(1, "pledge");



Re: locale in who(1)

2021-11-10 Thread Martijn van Duren
I see no reason to keep it.

OK martijn@ if anyone wants to commit this.

On Wed, 2021-11-10 at 13:37 +0100, Jan Stary wrote:
> Why does who(1) need to setlocale()?
> 
>   Jan
> 
> 
> Index: who.c
> ===
> RCS file: /cvs/src/usr.bin/who/who.c,v
> retrieving revision 1.30
> diff -u -p -r1.30 who.c
> --- who.c 12 Jul 2021 15:09:20 -  1.30
> +++ who.c 10 Nov 2021 12:37:05 -
> @@ -44,7 +44,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  
>  void  output(struct utmp *);
>  void  output_labels(void);
> @@ -71,8 +70,6 @@ main(int argc, char *argv[])
>   FILE *ufp;
>   char *t;
>   int c;
> -
> - setlocale(LC_ALL, "");
>  
>   if (pledge("stdio unveil rpath getpw", NULL) == -1)
>   err(1, "pledge");
> 



locale in who(1)

2021-11-10 Thread Jan Stary
Why does who(1) need to setlocale()?

Jan


Index: who.c
===
RCS file: /cvs/src/usr.bin/who/who.c,v
retrieving revision 1.30
diff -u -p -r1.30 who.c
--- who.c   12 Jul 2021 15:09:20 -  1.30
+++ who.c   10 Nov 2021 12:37:05 -
@@ -44,7 +44,6 @@
 #include 
 #include 
 #include 
-#include 
 
 void  output(struct utmp *);
 void  output_labels(void);
@@ -71,8 +70,6 @@ main(int argc, char *argv[])
FILE *ufp;
char *t;
int c;
-
-   setlocale(LC_ALL, "");
 
if (pledge("stdio unveil rpath getpw", NULL) == -1)
err(1, "pledge");