bug-tar
[Top][All Lists]
Advanced

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

Re: [Bug-tar] gettext 0.15 rejects \v in tar.c


From: Paul Eggert
Subject: Re: [Bug-tar] gettext 0.15 rejects \v in tar.c
Date: Mon, 07 Aug 2006 22:30:18 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

"Sergey Poznyakoff" <address@hidden> writes:

> If it does, it is a bug in gettext and should be fixed.

I'll file a bug report, but I assume the limitation was put in
for some reason....

> The proposed fix is incorrect, since argp engine outputs the part
> that follows \v *after* the option list.

Sorry, I didn't know that argp did that.  I installed the following
patch to fix this bug.

2006-08-07  Paul Eggert  <address@hidden>

        * src/tar.c: Work around limitation imposed by gettext 0.15
        by concatenating strings with "\v" after translation.
        (doc): Remove, splitting into:
        (doc0, doc1): New constants.
        (argp): Don't use doc; just initialize to NULL.
        (initialize_argp_doc): New function.
        (decode_options): Use it.

--- src/tar.c   7 Aug 2006 21:12:21 -0000       1.156
+++ src/tar.c   8 Aug 2006 05:28:32 -0000       1.157
@@ -320,13 +320,16 @@ enum
 
 const char *argp_program_version = "tar (" PACKAGE_NAME ") " VERSION;
 const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
-static char doc[] = N_("GNU `tar' saves many files together into a single tape 
or disk archive, and can restore individual files from the archive.\n\
+static char const doc0[] = N_("\
+GNU `tar' saves many files together into a single tape or disk archive, \
+and can restore individual files from the archive.\n\
 \n\
 Examples:\n\
   tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.\n\
   tar -tvf archive.tar         # List all files in archive.tar verbosely.\n\
   tar -xf archive.tar          # Extract all files from archive.tar.\n\
-\n\
+");
+static char const doc1[] = N_("\
 The backup suffix is `~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.\n\
 The version control may be set with --backup or VERSION_CONTROL, values 
are:\n\n\
   none, off       never make backups\n\
@@ -1859,12 +1862,27 @@ static struct argp argp = {
   options,
   parse_opt,
   N_("[FILE]..."),
-  doc,
+  NULL,
   NULL,
   NULL,
   NULL
 };
 
+/* Initialize the argp documentation.  gettext 0.15 dislikes doc
+   strings containing '\v', so insert '\v' after translation.  */
+
+static void
+initialize_argp_doc (void)
+{
+  char const *xdoc0 = _(doc0); size_t xlen0 = strlen (xdoc0);
+  char const *xdoc1 = _(doc1); size_t xlen1 = strlen (xdoc1);
+  char *doc = xmalloc (xlen0 + 1 + xlen1 + 1);
+  memcpy (doc, xdoc0, xlen0);
+  doc[xlen0] = '\v';
+  memcpy (doc + xlen0 + 1, doc1, xlen1 + 1);;
+  argp.doc = doc;
+}
+
 void
 usage (int status)
 {
@@ -1921,6 +1939,8 @@ decode_options (int argc, char **argv)
   owner_option = -1;
   group_option = -1;
 
+  initialize_argp_doc ();
+
   /* Convert old-style tar call by exploding option element and rearranging
      options accordingly.  */
 




reply via email to

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