bug-texinfo
[Top][All Lists]
Advanced

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

Support for reversing argument order in messages


From: Maxime Froment
Subject: Support for reversing argument order in messages
Date: Thu, 21 Jun 2001 01:32:16 +0900
User-agent: Wanderlust/2.4.0 (Rio) SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 MULE XEmacs/21.1 (patch 10) (Capitol Reef) (i686-pc-linux)

The info program in texinfo 4.0 (and pretests up to 4.0c) apparently
does not support argument swapping in message format strings, as in:

printf("In English, the %s precedes the %s...\n",          "verb", "object");
printf("...but in Japanese, the %2$s precedes the %1$s\n", "verb", "object");

Attempting to use this kind of format string in a message map (often
needed for languages not following the same syntactic order as
English) will result in the aborting of info at message substitution.

This is caused by the way the build_message_buffer() function in
info/window.c parses the message string (it does not support explicit
argument ordering in the format string). Adding complete/correct support
for this is relatively non-trivial, but under the strong assumption
that there are at most 2 arguments (which is already made by the
build_message_buffer() function interface) and that explicit ordering
is only used for swapping the first and the second argument, it is
easy enough to come with a workaround (see following patch).

Maxime Froment

/* maxime @ turbolinux . co . jp */

--- texinfo-4.0/info/window.c.swapargs  Sat Jun 26 06:57:40 1999
+++ texinfo-4.0/info/window.c   Wed Jun 20 15:07:37 2001
@@ -1328,8 +1328,21 @@
           int fmt_len, formatted_len;
 
           i++;
-          while (format[i] && strchr ("-. +0123456789", format[i]))
-            i++;
+          while (format[i] && strchr ("-. +0123456789$", format[i]))
+            {
+              /* Swap arguments if needed */
+              if (format[i] == '$')
+                {
+                  if (args[0] == arg1)
+                    {
+                      args[0] = arg2;
+                      args[1] = arg1;
+                    }
+                  fmt_start = format + i;
+                }
+              i++;
+            }
+          
           c = format[i];
 
           if (c == '\0')
@@ -1338,6 +1351,7 @@
           fmt_len = format + i - fmt_start + 1;
           fmt = (char *) xmalloc (fmt_len + 1);
           strncpy (fmt, fmt_start, fmt_len);
+          fmt[0] = '%';
           fmt[fmt_len] = '\0';
 
           /* If we have "%-98s", maybe 98 calls for a longer string.  */



reply via email to

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