Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2001:
[Freeciv-Dev] [PATCH] xgettext: make c-format guessing slightly more int
Home

[Freeciv-Dev] [PATCH] xgettext: make c-format guessing slightly more int

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bug-gnu-utils@xxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] xgettext: make c-format guessing slightly more intelligent.
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: Mon, 09 Jul 2001 00:38:18 +0200

The current xgettext will guess that a string such as

  const char s[] = N_("50% is one half");

is a printf-like format string, which I found somewhat surprising.
After some digging, I found out that this is because a space actually
has a well-defined meaning in this context; but only if a
floating-point value is being printed, which is not the case above.
So I came up with the following patch, which disqualifies a string
from c-format if a space is being used with a non-floating point spec.
After applying this patch, there are precisely 10 strings in the
Freeciv source which are no longer marked (wrongly) as c-format.

--- xgettext.c  Mon May 21 22:00:56 2001
+++ xgettext.c  Sun Jul  8 23:49:58 2001
@@ -1380,7 +1380,8 @@
       size_t dummy;
 
       (void) parse_one_spec (s, 0, &spec, &dummy);
-      if (strchr ("iduoxXeEfgGcspnm%", spec.info.spec) == NULL)
+      if (strchr ("iduoxXeEfgGcspnm%", spec.info.spec) == NULL
+         || (spec.info.space && !(spec.data_arg_type & PA_DOUBLE)))
        return impossible;
     }
 
One aber is that I'm not sure if I ought to check for PA_FLOAT as
well.  The glibc manual mentions it, but it's never set in
parse_one_spec().

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
PIZZA!!


[Prev in Thread] Current Thread [Next in Thread]