summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2015-08-21 14:43:30 +0900
committerDaiki Ueno <ueno@gnu.org>2015-08-21 14:43:30 +0900
commit15363cca838ff1d69f6e3bfbb47ecfe90c0f5000 (patch)
tree9d6708dcb557284bcc1e68aca600466a458321c5
parent2929cd21f36be2fb4cf1165dd2329a2715f32c87 (diff)
downloadgettext-15363cca838ff1d69f6e3bfbb47ecfe90c0f5000.tar.gz
xgettext: Allow multiple --copyright-holder
Feature requested by Francesco Poli in: <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=682580>. * xgettext.c (default_copyright_holder): New constant, renamed from copyright_holder. (copyright_holder): Define as a variable. (main): Allow multiple --copyright-holder options. (construct_header): Support multiple --copyright-holder options.
-rw-r--r--gettext-tools/src/ChangeLog11
-rw-r--r--gettext-tools/src/xgettext.c70
2 files changed, 75 insertions, 6 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 4c69e0e3f..052b61445 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,14 @@
+2015-08-21 Daiki Ueno <ueno@gnu.org>
+
+ xgettext: Allow multiple --copyright-holder
+ Feature requested by Francesco Poli in:
+ <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=682580>.
+ * xgettext.c (default_copyright_holder): New constant, renamed
+ from copyright_holder.
+ (copyright_holder): Define as a variable.
+ (main): Allow multiple --copyright-holder options.
+ (construct_header): Support multiple --copyright-holder options.
+
2015-08-15 Daiki Ueno <ueno@gnu.org>
* cldr-plurals.c (main): Close FP after use.
diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
index 9f5d300cc..8e303c74a 100644
--- a/gettext-tools/src/xgettext.c
+++ b/gettext-tools/src/xgettext.c
@@ -124,7 +124,8 @@ message_list_ty *exclude;
static int force_po;
/* Copyright holder of the output file and the translations. */
-static const char *copyright_holder = "THE PACKAGE'S COPYRIGHT HOLDER";
+static const char *default_copyright_holder = "THE PACKAGE'S COPYRIGHT HOLDER";
+static char *copyright_holder = NULL;
/* Package name. */
static const char *package_name = NULL;
@@ -540,11 +541,19 @@ main (int argc, char *argv[])
break;
case CHAR_MAX + 1: /* --copyright-holder */
- copyright_holder = optarg;
+ if (copyright_holder == NULL)
+ copyright_holder = xstrdup (optarg);
+ else
+ {
+ size_t total_len = strlen (copyright_holder) + 2 + strlen (optarg);
+ copyright_holder = xrealloc (copyright_holder, total_len);
+ strcat (copyright_holder, "\n");
+ strcat (copyright_holder, optarg);
+ }
break;
case CHAR_MAX + 2: /* --foreign-user */
- copyright_holder = "";
+ copyright_holder = xstrdup ("");
break;
case CHAR_MAX + 3: /* --from-code */
@@ -3559,13 +3568,61 @@ Content-Transfer-Encoding: 8bit\n",
mp = message_alloc (NULL, "", NULL, msgstr, strlen (msgstr) + 1, &pos);
+ if (copyright_holder == NULL)
+ copyright_holder = xstrdup (default_copyright_holder);
+
if (copyright_holder[0] != '\0')
- comment = xasprintf ("\
+ {
+ size_t copyright_comment_len;
+ char *copyright_comment;
+ const char *p;
+ char *q;
+ size_t count = 1;
+
+ p = copyright_holder;
+ while (*p != '\0')
+ {
+ p = strchr (p, '\n');
+ if (p == NULL)
+ break;
+ count++;
+ p++;
+ }
+
+ copyright_comment_len =
+ strlen (copyright_holder) + strlen ("Copyright (C) YEAR \n") * count;
+ copyright_comment = XNMALLOC (copyright_comment_len, char);
+
+ p = copyright_holder;
+ q = copyright_comment;
+ while (*p != '\0')
+ {
+ char *newline = strchr (p, '\n');
+
+ q = stpcpy (q, "Copyright (C) YEAR ");
+ if (newline != NULL)
+ {
+ *newline = '\0';
+ q = stpcpy (q, p);
+ q = stpcpy (q, "\n");
+ p = newline + 1;
+ }
+ else
+ {
+ q = stpcpy (q, p);
+ q = stpcpy (q, "\n");
+ break;
+ }
+ }
+
+ comment = xasprintf ("\
SOME DESCRIPTIVE TITLE.\n\
-Copyright (C) YEAR %s\n\
+%s\
This file is distributed under the same license as the PACKAGE package.\n\
FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.\n",
- copyright_holder);
+ copyright_comment);
+ free (copyright_comment);
+ }
else
comment = xstrdup ("\
SOME DESCRIPTIVE TITLE.\n\
@@ -3573,6 +3630,7 @@ This file is put in the public domain.\n\
FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.\n");
message_comment_append (mp, comment);
free (comment);
+ free (copyright_holder);
mp->is_fuzzy = true;