summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-08-16 20:55:05 +0200
committerBruno Haible <bruno@clisp.org>2009-08-16 20:55:05 +0200
commit245358efa614dda16ee393ee24d723f3dc7c447c (patch)
tree90cb376b233f5b4e4dc775f4fe44af653a20a28a
parentbed750059a70c07cfe0ef5fc2f073e8bbf798406 (diff)
downloadexternal_gettext-245358efa614dda16ee393ee24d723f3dc7c447c.zip
external_gettext-245358efa614dda16ee393ee24d723f3dc7c447c.tar.gz
external_gettext-245358efa614dda16ee393ee24d723f3dc7c447c.tar.bz2
Reduce dependency on project-id heuristic.
-rw-r--r--gettext-tools/src/ChangeLog7
-rw-r--r--gettext-tools/src/msginit.c32
2 files changed, 37 insertions, 2 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index debde4d..b234ec2 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-16 Bruno Haible <bruno@clisp.org>
+
+ Reduce dependency on project-id heuristic.
+ * msginit.c (project_id): Add header argument. Return first part of
+ Project-Id-Version field if present.
+ (fill_header): Update.
+
2009-08-13 Bruno Haible <bruno@clisp.org>
* msgexec.c: Include msgl-charset.h.
diff --git a/gettext-tools/src/msginit.c b/gettext-tools/src/msginit.c
index a6e5c54..5908925 100644
--- a/gettext-tools/src/msginit.c
+++ b/gettext-tools/src/msginit.c
@@ -810,8 +810,9 @@ englishname_of_language ()
/* Construct the value for the PACKAGE name. */
static const char *
-project_id ()
+project_id (const char *header)
{
+ const char *old_field;
const char *gettextlibdir;
char *prog;
char *argv[3];
@@ -823,6 +824,33 @@ project_id ()
size_t linelen;
int exitstatus;
+ /* Return the first part of the Project-Id-Version field if present, assuming
+ it was already filled in by xgettext. */
+ old_field = get_field (header, "Project-Id-Version");
+ if (old_field != NULL && strcmp (old_field, "PACKAGE VERSION") != 0)
+ {
+ /* Remove the last word from old_field. */
+ const char *last_space;
+
+ last_space = strrchr (old_field, ' ');
+ if (last_space != NULL)
+ {
+ while (last_space > old_field && last_space[-1] == ' ')
+ last_space--;
+ if (last_space > old_field)
+ {
+ size_t package_len = last_space - old_field;
+ char *package = XNMALLOC (package_len + 1, char);
+ memcpy (package, old_field, package_len);
+ package[package_len] = '\0';
+
+ return package;
+ }
+ }
+ /* It contains no version, just a package name. */
+ return old_field;
+ }
+
gettextlibdir = getenv ("GETTEXTLIBDIR");
if (gettextlibdir == NULL || gettextlibdir[0] == '\0')
gettextlibdir = relocate (LIBDIR "/gettext");
@@ -1649,7 +1677,7 @@ fill_header (msgdomain_list_ty *mdlp)
const char *id;
time_t now;
- id = project_id ();
+ id = project_id (header);
subst[0][0] = "SOME DESCRIPTIVE TITLE";
subst[0][1] = xasprintf (get_title (), id, id);
subst[1][0] = "PACKAGE";