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

Re: [PATCH] Human representation date format change

From: Nuutti Kotivuori <naked_at_iki.fi>
Date: 2002-07-15 22:46:58 CEST

Karl Fogel wrote:
> Nuutti Kotivuori <naked@iki.fi> writes:
>> + * This format is used whenever time is shown to the user. It
>> + consists * of a machine parseable, almost ISO-8601, part in the
>> + beginning - * and a human explanative part at the end. The
>> + machine parseable part
>
> I never heard of the word "explanative" before, but hey, English is
> a Big Tent language.

Well, you're the english speaker here, not me :)

Apparently Merriam-Webster defines it as 'explanatory'. Think that's a
better expression anyway.

>> + apr_snprintf. The * human explanative part is generated by
>> + apr_strftime, which means * that it's generation can be affected
>> + by locale, it can fail and it
>
> s/it's/its/

Ouch, thanks.

>> +/* Maximum length for the date string. */
>> +#define SVN_SUBR__DATE_MAX_LENGTH 80
>
> SVN_TIME__MAX_LENGTH, maybe? Should use "SVN_TIME__" prefix,
> anyway.

Yup, sounds good.

>> + /* Put in machine parseable part */
>> + len = apr_snprintf (datestr,
>> + SVN_SUBR__DATE_MAX_LENGTH,
>> + human_timestamp_format,
>> + 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),
>> + (exploded_time.tm_gmtoff / 60) % 60);
>> +
>> + /* If we overfilled the buffer, just return what we got. */
>> + if(len >= SVN_SUBR__DATE_MAX_LENGTH)
>> + return datestr;
>
> I got confused for a moment, but then learned that apr_snprintf()
> returns the buffer's len (i.e., its second arg) in overfill case.

Well yes - the header file claimed that it did not. Then came the
bugfixes to APR. And this is the "new" behaviour which is supposed to
be the Right Thing.

> So ">=" is okay, but equivalent to "==", right?

Yes, quite right. But from the snprintf manpage from glibc:

,----[ man snprintf ]
| Since glibc 2.1 these functions follow the C99 standard and return the
| number of characters (excluding the trailing '\0') which would have
| been written to the final string if enough space had been available.
`----

So if APR ever would decide to behave that way, it would still work.

>> + /* Calculate offset to the end of the machine parseable part. */
>> + curptr = datestr + len;
>> +
>> + /* Put in human readable part */
>> + ret = apr_strftime (curptr,
>> + &retlen,
>> + SVN_SUBR__DATE_MAX_LENGTH - len,
>> + human_timestamp_format_suffix,
>> + &exploded_time);
>
> Okay, so in case of overlong length, we sacrifice the user-formatted
> part in favor of the machine-parseable part. That seems reasonable.

Yes. We need to go through this again when doing it user-configurable
though, but for now it's fine.

> +1. If this passes "make check", commit it.

Running it now, committing after it.

There's no reason why this wouldn't work exactly the same way on
Windows as well - but I just don't trust strftime (or rather, APR)
implicitely. So someone should mention if this works on the Windows as
well.

-- Naked

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jul 15 22:48:36 2002

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.