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

[PATCH] Fix to svn_time_to_human_cstring()

From: Nicolás Lichtmaier <nick_at_reloco.com.ar>
Date: 2004-04-04 20:34:52 CEST

    * subversion/libsvn_subr/time.c:
      (svn_time_to_human_cstring) Despite its name (cstring) it is needed
      that this function return an UTF8 string. So there's the need to
convert
      the human-readable part, which can come encoded in the current
locale's charset.

Index: subversion/libsvn_subr/time.c
===================================================================
--- subversion/libsvn_subr/time.c (revision 9284)
+++ subversion/libsvn_subr/time.c (working copy)
@@ -226,7 +226,7 @@
   apr_time_exp_t exploded_time;
   apr_size_t len, retlen;
   apr_status_t ret;
- char *datestr, *curptr;
+ char *datestr, *curptr, human_datestr[SVN_TIME__MAX_LENGTH];
 
   /* Get the time into parts */
   apr_time_exp_lt (&exploded_time, when);
@@ -255,7 +255,7 @@
   curptr = datestr + len;
 
   /* Put in human explanatory part */
- ret = apr_strftime (curptr,
+ ret = apr_strftime (human_datestr,
                       &retlen,
                       SVN_TIME__MAX_LENGTH - len,
                       human_timestamp_format_suffix,
@@ -264,7 +264,22 @@
   /* If there was an error, ensure that the string is zero-terminated. */
   if (ret || retlen == 0)
     *curptr = '\0';
+ else
+ {
+ char *utf8_string;
+ svn_error_t *err;
 
+ err = svn_utf_cstring_to_utf8(&utf8_string, human_datestr, pool);
+ if(err)
+ {
+ *curptr = '\0';
+ } else
+ {
+ strncpy(curptr, utf8_string, SVN_TIME__MAX_LENGTH - len);
+ curptr[SVN_TIME__MAX_LENGTH - len] = '\0';
+ }
+ }
+
   return datestr;
 }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Apr 4 20:35:25 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.