Re: dtrace: give %'d a chance?

2020-12-02 Thread Andriy Gapon
On 02/12/2020 18:52, Mark Johnston wrote:
> On Mon, Nov 30, 2020 at 03:50:53PM +0200, Andriy Gapon wrote:
>> On 19/11/2020 16:57, Mark Johnston wrote:
>>> On Thu, Nov 19, 2020 at 01:28:56PM +0200, Andriy Gapon wrote:

 what do people think about adding
 setlocale(LC_NUMERIC, "");
 to dtrace's main function?
>>>
>>> That seems reasonable to me.
>>>
 My primary interest is to (pretty-)print some numbers with a thousands 
 separator.

 Not sure if any other LC_ types are worth bothering.
>>>
>>> Maybe LC_TIME?  libdtrace a couple of date formatters, %T and %Y.  A
>>> locale-aware formatter might be worth having.
>>
>> FWIW, I've just discovered that despite what
>> http://dtrace.org/guide/chp-fmt.html says about %Y its output is not 
>> dependent
>> on locale settings.
>> A quick look at the code confirms that -- pfprint_time uses ctime_r.
>> But %T (undocumented at the above link) indeed depends on LC_TIME as
>> pfprint_time822 uses strftime("%a, %d %b %G %T %Z").
>>
>> Sample output in C locale:
>> 1000
>> Mon, 30 Nov 2020 13:47:24 UTC
>> 2020 Nov 30 13:47:24
>>
>> The same formats (%'d, %T, %Y) in uk_UA locale:
>> 10 000 000
>> Пн, 30 лист. 2020 13:43:11 UTC
>> 2020 Nov 30 13:43:11
> 
> So to be clear, there is nothing that needs to be done for time locales?

Sorry, it was I who was not clear.  The above output is after adding setlocale()
calls.  Stock dtrace always operates in C locale.

> In any case, I'm fine with adding the %'d formatter.

It's already there and it delegates the work to the C printf.
Hence the need for setlocale.

-- 
Andriy Gapon
___
freebsd-dtrace@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace
To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org"


Re: dtrace: give %'d a chance?

2020-11-19 Thread Mark Johnston
On Thu, Nov 19, 2020 at 01:28:56PM +0200, Andriy Gapon wrote:
> 
> what do people think about adding
> setlocale(LC_NUMERIC, "");
> to dtrace's main function?

That seems reasonable to me.

> My primary interest is to (pretty-)print some numbers with a thousands 
> separator.
> 
> Not sure if any other LC_ types are worth bothering.

Maybe LC_TIME?  libdtrace a couple of date formatters, %T and %Y.  A
locale-aware formatter might be worth having.
___
freebsd-dtrace@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace
To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org"


Re: dtrace: give %'d a chance?

2020-11-19 Thread Ash Gokhale
Oh, neat. My mistake for not understanding 'd.  Fire away.

On Thu, Nov 19, 2020 at 9:20 AM Andriy Gapon  wrote:

> On 19/11/2020 15:31, Ash Gokhale wrote:
> > I'm not a fan of reading nanosecond timestamps ; however This would add
> work to
> > downstream scripts  that have to toss the prettyprint later;
> > s|.,()||g  downstream. Think of the wee awk scripts.
> > Could we gate the behaviour behind an environment DTRACE_LOCALE or
> whatever?
> >
> > Eh It's getting harder to live in the C locale anyway, the immigration
> rules
> > seem to be tightening.
>
> Sorry, but you don't have to use %'d.
> You can keep using %d.
>
> > On Thu, Nov 19, 2020 at 6:29 AM Andriy Gapon  > > wrote:
> >
> >
> > what do people think about adding
> > setlocale(LC_NUMERIC, "");
> > to dtrace's main function?
> >
> > My primary interest is to (pretty-)print some numbers with a
> thousands
> > separator.
> >
> > Not sure if any other LC_ types are worth bothering.
> >
> > --
> > Andriy Gapon
> > ___
> > freebsd-dtrace@freebsd.org 
> mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace
> > To unsubscribe, send any mail to "
> freebsd-dtrace-unsubscr...@freebsd.org
> > "
> >
>
>
> --
> Andriy Gapon
>
___
freebsd-dtrace@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace
To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org"


Re: dtrace: give %'d a chance?

2020-11-19 Thread Andriy Gapon
On 19/11/2020 15:31, Ash Gokhale wrote:
> I'm not a fan of reading nanosecond timestamps ; however This would add work 
> to
> downstream scripts  that have to toss the prettyprint later; 
> s|.,()||g  downstream. Think of the wee awk scripts. 
> Could we gate the behaviour behind an environment DTRACE_LOCALE or whatever?
> 
> Eh It's getting harder to live in the C locale anyway, the immigration  rules
> seem to be tightening. 

Sorry, but you don't have to use %'d.
You can keep using %d.

> On Thu, Nov 19, 2020 at 6:29 AM Andriy Gapon  > wrote:
> 
> 
> what do people think about adding
>     setlocale(LC_NUMERIC, "");
> to dtrace's main function?
> 
> My primary interest is to (pretty-)print some numbers with a thousands
> separator.
> 
> Not sure if any other LC_ types are worth bothering.
> 
> -- 
> Andriy Gapon
> ___
> freebsd-dtrace@freebsd.org  mailing 
> list
> https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace
> To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org
> "
> 


-- 
Andriy Gapon
___
freebsd-dtrace@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace
To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org"


Re: dtrace: give %'d a chance?

2020-11-19 Thread Ash Gokhale
I'm not a fan of reading nanosecond timestamps ; however This would add
work to downstream scripts  that have to toss the prettyprint later;
s|.,()||g  downstream. Think of the wee awk scripts.
Could we gate the behaviour behind an environment DTRACE_LOCALE or whatever?

Eh It's getting harder to live in the C locale anyway, the immigration
rules seem to be tightening.

 -Ash

On Thu, Nov 19, 2020 at 6:29 AM Andriy Gapon  wrote:

>
> what do people think about adding
> setlocale(LC_NUMERIC, "");
> to dtrace's main function?
>
> My primary interest is to (pretty-)print some numbers with a thousands
> separator.
>
> Not sure if any other LC_ types are worth bothering.
>
> --
> Andriy Gapon
> ___
> freebsd-dtrace@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace
> To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org"
>
___
freebsd-dtrace@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace
To unsubscribe, send any mail to "freebsd-dtrace-unsubscr...@freebsd.org"