[PROPOSED] Rename asctime symbols if required in private.h

When libtz.a is built using -DRESERVE_STD_EXT_IDS (but not in other cases where TZ_TIME_T is defined) the asctime and asctime_r symbols need renaming. Note: if my assumption about "other cases" is wrong, the preprocessor guards in this patch should be omitted. --- private.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/private.h b/private.h index 1ead147..112a58c 100644 --- a/private.h +++ b/private.h @@ -409,6 +409,12 @@ static time_t sys_time(time_t *x) { return time(x); } typedef time_tz tz_time_t; +#if RESERVE_STD_EXT_IDS +# undef asctime +# define asctime tz_asctime +# undef asctime_r +# define asctime_r tz_asctime_r +#endif # undef ctime # define ctime tz_ctime # undef ctime_r @@ -478,6 +484,10 @@ typedef time_tz tz_time_t; # define altzone tz_altzone # endif +#if RESERVE_STD_EXT_IDS +char *asctime(struct tm const *timeptr); +char *asctime_r(struct tm const *restrict, char *restrict); +#endif char *ctime(time_t const *); char *ctime_r(time_t const *, char *); double difftime(time_t, time_t) ATTRIBUTE_CONST; @@ -494,7 +504,7 @@ struct tm *localtime_r(time_t const *restrict, struct tm *restrict); time_t mktime(struct tm *); time_t time(time_t *); void tzset(void); -#endif +#endif /* defined TZ_TIME_T */ #if !HAVE_DECL_ASCTIME_R && !defined asctime_r extern char *asctime_r(struct tm const *restrict, char *restrict); -- 2.7.4

On 10/15/19 4:24 AM, Roland Young wrote:
Note: if my assumption about "other cases" is wrong, the preprocessor guards in this patch should be omitted.
Thanks, I installed the patch without the preprocessor guards (see attached) since I don't see why asctime/asctime_r should be different from ctime/ctime_r etc. RESERVE_STD_EXT_IDS is not the only reason that the symbols might be renaming; it could be that the symbols are not reserved but you want to rename them anyway. If I am missing something and a fix is needed here, it can be the subject of a separate patch.
participants (2)
-
Paul Eggert
-
Roland Young