[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Fix encoding bug of 'svnserve -h' (was: [PATCH] svnserve -h)

From: Kobayashi Noritada <nori1_at_dolphin.c.u-tokyo.ac.jp>
Date: 2004-11-05 09:44:57 CET

Hi,

Sorry...
I sent this mail without subject describing contents correctly.

-----

svnserve -h displayed as follows in my Japanese environment.

  nori1[14:59]% svnserve -h saba:~/subversion-1.1.1/subversion/svnserve
  Usage: svnserve [options]

  Valid options:
    -d [--daemon] : daemon mode
    --listen-port arg : listen port (for daemon mode)
    --listen-host arg : listen hostname or IP address (for daemon mode)
    --foreground : run in foreground (useful for debugging)
    -h [--help] : display this help
    --version : -user arg : tunnel username (default is current uid's name)
    -T [--threads] : use threads instead of fork
    -X [--listen-once] : listen once (useful for debugging)

Provided LANG=C, it displayed correctly.
With piping to 'less', I found description of '--version' displayed in UTF-8.

This was a part of issue #1997.
The mechanism of this problem was:

* subversion/svnserve/main.c uses fprintf, which do not recode UTF-8 string,
  following svn_opt_format_option, which creates localized messages with
  dgettext inside.
* svn_opt_format_option creates localized messages even if the messages are
  not marked with N_().
* Description of 'svnserve --version' is the same as that of, say, 'svnadmin
  --version'.

So, I created a patch and made sure it works in my Japanese environment.
Please check it.
I dare say that it is only for encoding bug in displaying and its change is
minimum so that it can be merged to the 1.1.x branch.
In other words, this patch is not for localizing svnserve, which may be
treated as a new feature.
(And I'll create another patch to localize, if I can.)

Thanks in advance,

-- 
|:  Noritada KOBAYASHI
|:  Dept. of General Systems Studies,
|:  Graduate School of Arts and Sciences, Univ. of Tokyo
|:  E-mail: nori1@dolphin.c.u-tokyo.ac.jp (preferable)
|:          nori@esa.c.u-tokyo.ac.jp
Log:
Fix encoding bug of 'svnserve -h', which is part of issue #1997.
* subversion/svnserve/main.c
  (help): Use svn_cmdline_fprintf, which does UTF8->locale conversions,
  instead of fprintf because svn_opt_format_option localizes the documentation
  strings of options when formatting, even if these strings are not marked
  with N_().
* subversion/include/svn_opt.h
  (svn_opt_format_option): Add notes so that everyone may notice that
  this function localizes the documentation strings of options.
Index: subversion/include/svn_opt.h
===================================================================
--- subversion/include/svn_opt.h	(revision 11748)
+++ subversion/include/svn_opt.h	(working copy)
@@ -139,6 +139,9 @@
 /**
  * Print an option @a opt nicely into a @a string allocated in @a pool.  
  * If @a doc is set, include the generic documentation string of option.
+ *
+ * When you write @a string to stdout/stderr, note that the documentation
+ * string is localized even if it is not marked with N_() in its definition.
  */
 void
 svn_opt_format_option (const char **string,
Index: subversion/svnserve/main.c
===================================================================
--- subversion/svnserve/main.c	(revision 11748)
+++ subversion/svnserve/main.c	(working copy)
@@ -142,7 +142,7 @@
     {
       const char *optstr;
       svn_opt_format_option(&optstr, svnserve__options + i, TRUE, pool);
-      fprintf(stdout, "  %s\n", optstr);
+      svn_error_clear (svn_cmdline_fprintf(stdout, pool, "  %s\n", optstr));
     }
   fprintf(stdout, "\n");
   exit(1);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Nov 5 09:45:16 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.