Re: [PATCH] PRItime: wrap PRItime for better l10n compatibility

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2017-07-22 6:40 GMT+08:00 Junio C Hamano <gitster@xxxxxxxxx>:
> Jiang Xin <worldhello.net@xxxxxxxxx> writes:
>
>> Sorry, I'm late. I want to try a safer way to change PRItime to
>> PRInMax using a hacked version of gettext.
>
> Why?  A vanilla version of gettext tool that is fed a known PRIuMAX
> in its input would be a safer choice, I would have thought.
>
> I've already queued the patch you responded to on 'master', but
> haven't tagged -rc1 yet, so it is possible for you to update on top
> of it before -rc1 is tagged.  I do not yet understand why you think
> a modified version of gettext would be a safer way to go, though.
>
> Thanks.

A very small hack on gettext.  When extract l10n messages to pot file
with `xgettext`, will grep "PRItime", and do "sed s/PRItime/PRIuMAX"
inside `xgettext`.

See this patch:
https://github.com/jiangxin/gettext/commit/b0a726431c93b5a1ca0fe749de376b0752e75fb0

    ---
     gettext-tools/src/x-c.c      | 17 ++++++++++++++++-
     gettext-tools/src/xgettext.c |  2 +-
     2 files changed, 17 insertions(+), 2 deletions(-)

    diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c
    index 1844a5df7..51dd0a9bc 100644
    --- a/gettext-tools/src/x-c.c
    +++ b/gettext-tools/src/x-c.c
    @@ -1802,6 +1802,12 @@ phase6_unget (token_ty *tp)
     static bool
     is_inttypes_macro (const char *name)
     {
    +  /* PRItime is a maro for timestamp_t in git.git. */
    +  if (!strncmp(name, "PRItime", 7))
    +    {
    +      return true;
    +    }
    +
       /* Syntax:
          P R I { d | i | o | u | x | X }
          { { | LEAST | FAST } { 8 | 16 | 32 | 64 } | MAX | PTR }  */
    @@ -1843,8 +1849,17 @@ phase8a_get (token_ty *tp)
       phase6_get (tp);
       if (tp->type == token_type_name && is_inttypes_macro (tp->string))
         {
    +      char *new_string;
           /* Turn PRIdXXX into "<PRIdXXX>".  */
    -      char *new_string = xasprintf ("<%s>", tp->string);
    +      if (!strncmp(tp->string, "PRItime", 7))
    +        {
    +          /* Replace PRItime with PRIuMAX for git.git project */
    +          new_string = xasprintf ("<%s>", "PRIuMAX");
    +        }
    +      else
    +        {
    +          new_string = xasprintf ("<%s>", tp->string);
    +        }
           free (tp->string);
           tp->string = new_string;
           tp->comment = add_reference (savable_comment);
    diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
    index f848d76d1..0350a1bee 100644
    --- a/gettext-tools/src/xgettext.c
    +++ b/gettext-tools/src/xgettext.c
    @@ -676,7 +676,7 @@ main (int argc, char *argv[])
       /* Version information requested.  */
       if (do_version)
         {
    -      printf ("%s (GNU %s) %s\n", basename (program_name),
PACKAGE, VERSION);
    +      printf ("%s (GNU %s) %s (PRItime to PRIuMAX for
git.git)\n", basename (program_name), PACKAGE, VERSION);
           /* xgettext: no-wrap */
           printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\
     License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>\n\
    --
    2.14.0.rc0.1.g3ccfa2fb49
-- 
蒋鑫

华为技术有限公司
邮件: xin.jiang@xxxxxxxxxx, worldhello.net@xxxxxxxxx
博客: http://www.worldhello.net/
微博: http://weibo.com/gotgit/
电话: 18601196889




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux