From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.0 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_WEB,RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id C94BB20288 for ; Wed, 19 Jul 2017 13:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752257AbdGSNZS (ORCPT ); Wed, 19 Jul 2017 09:25:18 -0400 Received: from mout.gmx.net ([212.227.17.21]:56975 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751364AbdGSNZR (ORCPT ); Wed, 19 Jul 2017 09:25:17 -0400 Received: from virtualbox ([37.201.192.198]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MMCSP-1dYcBf3gEf-0080Ek; Wed, 19 Jul 2017 15:25:10 +0200 Date: Wed, 19 Jul 2017 15:25:09 +0200 (CEST) From: Johannes Schindelin X-X-Sender: virtualbox@virtualbox To: Jiang Xin cc: Junio C Hamano , Git List , =?UTF-8?Q?Jean-No=C3=ABl_Avila?= Subject: Re: [PATCH] PRItime: wrap PRItime for better l10n compatibility In-Reply-To: Message-ID: References: <249ac6f8-af3c-4b20-5bf0-87a82866cc7a@free.fr> <3ccfa2fb49d471f807d77d9a280e4b7cfe56faea.1500304209.git.worldhello.net@gmail.com> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K0:+KW3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zU74dPd FD7sPR03Qh3CNlBQ0CSm8j+c1411QXIPdTYsnkYSwrFk7cu3Fc= Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Jian (or is it Xin?), On Wed, 19 Jul 2017, Jiang Xin wrote: > 2017-07-19 1:35 GMT+08:00 Junio C Hamano : > > Jiang Xin writes: > > > >>> Two potential issues are: > >>> > >>> - After this patch, there still are quite a many > >>> > >>> printf("time is %"PRItime" ...\n", timestamp) > >>> > >>> so the burden on the programmers having to remember when it is > >>> required to use format_raw_time() becomes unclear, and makes the > >>> change/churn larger when an existing message needs to be marked > >>> for translation. > >>> > >>> - The static struct strbuf here is a cheap way to avoid leaks, but > >>> at the same time it is unfriendly to threaded code. We could > >>> instead do: > >>> > >>> void append_PRItime(struct strbuf *buf, timestamp_t time); > >>> > >>> to fix that trivially, but the damage to the caller obviously is > >>> much larger going this way. > >>> > >> > >> I wonder if we can replace the original %lu for timestamp with PRIuMAX > >> instead. PRIuMAX works fine with gettext utils. > > > > I think the question can better be answered if we know how gettext > > tools special case PRIuMAX. One thing that may be problematic is > > that timestamp can later become a signed type and use of one level > > of redirection in the current code via PRItime and via timestamp_t > > is a good way to keep such a transition much easier. Reverting it > > to use PRIuMAX would make such a transition much harder. > > Gettext handles macros such as PRIuMAX in commit 8b45c5df1 ("Add > support for ISO C 99 format string directive macros.", > 2002-07-23 12:33:13 +0000). Wow. This is ugly. If I understand correctly, then this will not even work correctly for PRIuMAX on Windows: I highly doubt that the gettext library will interpret %I64u in the format string correctly to be what % in the po file refers to. But there may be hope. Since the character sequence "PRItime" is highly unlikely to occur in Git's source code in any context other than the format to print/parse timestamp_t, it should be possible to automate a the string replacement git ls-files -z \*.[ch] | xargs -0r sed -i 's/PRItime/PRIuMAX/g' (assuming, of course, that you use GNU sed, not BSD sed, for which the `-i` needs to read `-i ''` instead) as part of the update? For all the reasons Junio mentioned, I, too, would be reluctant to change the source code to cull all of the PRItime mentions, as it is pleasing from a semantic point of view that we know what the heck we are talking about here. BTW *thank you so much* for your Herculean effort to keep going with the translation. Ciao, Dscho