This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC][PATCH v6 06/16] Provide backward compatibility for strftime family (bug 10871).


Ping! I have got no feedback so I'll comment my own code:

20.03.2017 21:39 Rafal Luzynski <digitalfreak@lingonborough.com> wrote:
>
> [...]
> @@ -446,7 +453,7 @@ static size_t __strftime_internal (CHAR_T *, size_t, const
> CHAR_T *,
>
> size_t
> my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format,
> - const struct tm *tp ut_argument_spec LOCALE_PARAM)
> + const struct tm *tp ut_argument_spec FEATURE_OB_PARAM LOCALE_PARAM)
> {

I really don't like this hack with introducing this additional
FEATURE_OB_PARAM which may be defined to something useful or defined
to an empty string. This introduces lots of clutter to this code.
It's bad especially since the changes from glibc is occasionally applied
to gnulib, a library providing GNU features to the applications being
ported to non-GNU systems but also used by some Linux programs, for
example the date command line utility.

It would be easier if I implemented some compat_strftime() function
which would translate the format specifier so it produces the same
results as the old my_strftime() implementation and pass it to the new
my_strftime(). This would mean translating all %B to %OB and all %OB
to %%OB, of course maintaining the modifiers. But it would have to
allocate memory for the translated format specifier and I don't know
if you like allocating and freeing memory inside glibc.

> [...]
> +strong_alias (__strftime_l_internal, __strftime_l_internal_alias)
> +versioned_symbol (libc, __strftime_l_internal_alias,
> + __strftime_l, GLIBC_2_26);
> +libc_hidden_ver (__strftime_l_internal_alias, __strftime_l)
> +versioned_symbol (libc, __strftime_l_internal, strftime_l, GLIBC_2_26);
> +libc_hidden_ver (__strftime_l_internal, strftime_l)
> +
> +# if SHLIB_COMPAT (libc, GLIBC_2_3, GLIBC_2_26)
> +size_t
> +attribute_compat_text_section
> +__strftime_l_compat (char *s, size_t maxsize, const char *format,
> + const struct tm *tp, __locale_t loc)
> +{
> + return my_strftime (s, maxsize, format, tp, 0, loc);
> +}
> +strong_alias (__strftime_l_compat, __strftime_l_compat_alias)
> +compat_symbol (libc, __strftime_l_compat_alias, __strftime_l, GLIBC_2_3);
> +compat_symbol (libc, __strftime_l_compat, strftime_l, GLIBC_2_3);
> +# endif

Another dirty way to provide two versioned symbols: strftime_l
and __strftime_l pointing to the same internal function. Any tips
how to do it more correctly without introducing another alias?

Regards,

Rafal


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]