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

Re: [PATCH] Issue 2332, "$Date$" Keywords always expand with their UTF-8 content

From: Daniel Rall <dlr_at_collab.net>
Date: 2005-12-07 01:04:15 CET

On Wed, 07 Dec 2005, Hanjy wrote:
...
> > > I didn't change the function svn_time_to_human_cstring in
> > > libsvn_subr/time.c, there are several places to call the function, I don't
> > > know whether these need to change. so I only changed the keyword_printf
> > > function in libsvn_subr/subst.c, I hope who can do a full repair than me.
...

For posterity's sake, I'll mention that this patch only addresses the
Date keyword portion of issue 2332, and and not the similar problems
for other keywords like Id.

The Date portion of issue 2332, "Keyword expansion in non-UTF8
documents results in mixed charsets", is addressed by removing use of
apr_strftime(). apr_strftime() delegates to strftime() under the
covers, which -- given
libsvn_subr/time.c:human_timestamp_format_suffix -- the man page
indicates formats each element "name according to the current locale".
The patch replaces apr_strftime() with a hard-coded set of day and
month abbreviations, which are in English only.

Hanjy, what effect does this have on the encoding clash problem
(e.g. the keyword replacement text vs. the encoding of the file which
the substitution is occuring in)? I wouldn't have thought that
altering the localization would've fixed the encoding clash problems
(e.g. for a file encoded in shift_jis).

> --- subst.c (revision 17625)
> +++ subst.c (working copy)
> @@ -222,8 +222,35 @@
> break;
> case 'D': /* long format of date of this revision */
> if (date)
> - svn_stringbuf_appendcstr (value,
> - svn_time_to_human_cstring (date, pool));
> + {
> + const char human_timestamp_weekday_names [7][4] =
> + {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
> + const char human_timestamp_month_names [12][4] =
> + {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
> + "Sep", "Oct", "Nov", "Dec"};
> +
> + apr_time_exp_t exploded_time;
> + const char *human;
> +
> + apr_time_exp_lt (&exploded_time, date);
> +
> + human = apr_psprintf (pool,
> + "%04d-%02d-%02d %02d:%02d:%02d %+03d%02d (%s, %.2d %s %.4d)",
> + exploded_time.tm_year + 1900,
> + exploded_time.tm_mon + 1,
> + exploded_time.tm_mday,
> + exploded_time.tm_hour,
> + exploded_time.tm_min,
> + exploded_time.tm_sec,
> + exploded_time.tm_gmtoff / (60 * 60),
> + (abs (exploded_time.tm_gmtoff) / 60) % 60,
> + human_timestamp_weekday_names[exploded_time.tm_wday],
> + exploded_time.tm_mday,
> + human_timestamp_month_names[exploded_time.tm_mon],
> + exploded_time.tm_year + 1900);
> +
> + svn_stringbuf_appendcstr (value, human);
> + }
> break;
> case 'r': /* number of this revision */
> if (rev)

  • application/pgp-signature attachment: stored
Received on Wed Dec 7 01:02:43 2005

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