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

[PATCH] callers to svn_time_to_human_cstring should expect UTF8 (issue #1534)

From: Josh Pieper <jpieper_at_andrew.cmu.edu>
Date: 2003-10-06 15:19:01 CEST

Here is a fix to part of issue #1534. What I haven't handled is the
case where the date is substituted into a working copy file via the
svn:keywords mechanism. As far as I can tell, currently other
substitutions are not translated from UTF8 before getting stuck in
working copy files. Also, the encoding of those WC files is not
tracked, so this problem may be too difficult to handle right away.

-Josh

------------------------------------------------

Fix issue #1534: Callers of svn_time_to_human_cstring should expect a
UTF8 encoded string. This does not handle the need to localize the
date when substituting keywords into working copy files.

* subversion/include/svn_time.h
   Note that svn_time_to_human_cstring returns a UTF8 encoded string.

* subversion/libsvn_subr/subst.c
   Note that date_prop_to_human returns a UTF8 encoded string

* subversion/svnlook/main.c (do_date)
* subversion/clients/cmdline/log-cmd.c (log_message_receiver)
* subversion/clients/cmdline/info-cmd.c (svn_cl__info_print_time)
   Add call to svn_utf_cstring_from_utf8 after every invocation of
   svn_time_to_human_cstring.
   

Index: subversion/include/svn_time.h
===================================================================
--- subversion/include/svn_time.h (revision 7312)
+++ subversion/include/svn_time.h (working copy)
@@ -45,7 +45,7 @@
                                     apr_pool_t *pool);
 
 /** Convert @a when to a <tt>const char *</tt> representation allocated
- * in @a pool, suitable for human display.
+ * in @a pool, suitable for human display in UTF8.
  */
 const char *svn_time_to_human_cstring (apr_time_t when, apr_pool_t *pool);
 
Index: subversion/libsvn_subr/subst.c
===================================================================
--- subversion/libsvn_subr/subst.c (revision 7312)
+++ subversion/libsvn_subr/subst.c (working copy)
@@ -88,7 +88,7 @@
 
 /* A helper function to convert the date property to something suitable for
    printing out. If LONG_P is TRUE, use the long format, otherwise use a
- shorter one. */
+ shorter one. Returns a UTF8 encoded cstring. */
 static svn_error_t *
 date_prop_to_human (const char **human, svn_boolean_t long_p, apr_time_t when,
                     apr_pool_t *pool)
Index: subversion/svnlook/main.c
===================================================================
--- subversion/svnlook/main.c (revision 7312)
+++ subversion/svnlook/main.c (working copy)
@@ -1078,9 +1078,16 @@
     {
       /* Convert the date for humans. */
       apr_time_t aprtime;
+ const char *time_native;
+ const char *time_utf8;
       
       SVN_ERR (svn_time_from_cstring (&aprtime, prop_value->data, pool));
- printf ("%s", svn_time_to_human_cstring (aprtime, pool));
+
+ time_utf8 = svn_time_to_human_cstring (aprtime, pool);
+
+ SVN_ERR (svn_utf_cstring_from_utf8 (&time_native, time_utf8, pool));
+
+ printf ("%s", time_native);
     }
 
   printf ("\n");
Index: subversion/clients/cmdline/log-cmd.c
===================================================================
--- subversion/clients/cmdline/log-cmd.c (revision 7312)
+++ subversion/clients/cmdline/log-cmd.c (working copy)
@@ -212,9 +212,11 @@
     {
       /* Convert date to a format for humans. */
       apr_time_t time_temp;
+ const char *date_utf8;
       
       SVN_ERR (svn_time_from_cstring (&time_temp, date, pool));
- date_stdout = svn_time_to_human_cstring(time_temp, pool);
+ date_utf8 = svn_time_to_human_cstring(time_temp, pool);
+ SVN_ERR (svn_utf_cstring_from_utf8 (&date_stdout, date_utf8, pool));
     }
   else
     date_stdout = "(no date)";
Index: subversion/clients/cmdline/info-cmd.c
===================================================================
--- subversion/clients/cmdline/info-cmd.c (revision 7312)
+++ subversion/clients/cmdline/info-cmd.c (working copy)
@@ -39,7 +39,12 @@
                          const char *desc,
                          apr_pool_t *pool)
 {
- printf ("%s: %s\n", desc, svn_time_to_human_cstring (atime,pool));
+ const char *time_utf8;
+ const char *time_stdout;
+
+ time_utf8 = svn_time_to_human_cstring (atime, pool);
+ SVN_ERR (svn_utf_cstring_from_utf8 (&time_stdout, time_utf8, pool));
+ printf ("%s: %s\n", desc, time_stdout);
 }
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Oct 6 15:19:53 2003

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.