Date: Wed, 2 Dec 2020 23:20:23 +0200 From: Andriy Gapon <avg@FreeBSD.org> To: Mark Johnston <markj@freebsd.org> Cc: FreeBSD Current <freebsd-current@freebsd.org>, freebsd-dtrace@freebsd.org Subject: Re: dtrace: give %'d a chance? Message-ID: <a4ac3a1e-7528-929a-8c20-bd95a22a3dde@FreeBSD.org> In-Reply-To: <X8fGQnn2uJ43RsNP@raichu> References: <d832ce96-c7a9-7aac-b761-27522a02d0ef@FreeBSD.org> <X7aH5suHtYUsNq0x@raichu> <5b87b1af-2c19-7f41-60f0-1e578c72e17d@FreeBSD.org> <X8fGQnn2uJ43RsNP@raichu>
next in thread | previous in thread | raw e-mail | index | archive | help
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: >> 10000000 >> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a4ac3a1e-7528-929a-8c20-bd95a22a3dde>