[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() - take 3

From: Nicolás Lichtmaier <nick_at_reloco.com.ar>
Date: 2004-04-04 21:28:17 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)
@@ -24,6 +24,7 @@
 #include <apr_time.h>
 #include <apr_strings.h>
 #include "svn_time.h"
+#include "svn_utf.h"
 
 
 
@@ -226,7 +227,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 +256,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 +265,21 @@
   /* If there was an error, ensure that the string is zero-terminated. */
   if (ret || retlen == 0)
     *curptr = '\0';
+ else
+ {
+ const char *utf8_string;
+ svn_error_t *err;
 
+ err = svn_utf_cstring_to_utf8(&utf8_string, human_datestr, pool);
+ if(err)
+ {
+ *curptr = '\0';
+ svn_error_clear(err);
+ }
+ else
+ apr_cpystrn(curptr, utf8_string, SVN_TIME__MAX_LENGTH - len);
+ }
+
   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 21:28:40 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.