bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: misalignment in ls -l in fr_FR locale


From: Jim Meyering
Subject: Re: misalignment in ls -l in fr_FR locale
Date: Thu, 26 Mar 2009 13:21:08 +0100

Pádraig Brady wrote:
...
> +/* In the unlikely event that the abmon[] storage is not big enough
> +   an error message will be displayed, and we revert to using
> +   unmodified abbreviated month names from the locale database.  */
> +static char abmon[12][MAX_MON_WIDTH * 2 * MB_LEN_MAX + 1];
> +/* minimum width needed to align %b, 0 => don't use precomputed values.  */
> +static int required_mon_width;
> +
> +static void
> +abmon_init (void)
> +{
> +#ifdef HAVE_NL_LANGINFO
> +  required_mon_width = MAX_MON_WIDTH;
> +  int curr_max_width;
> +  do
> +    {
> +      curr_max_width = required_mon_width;
> +      required_mon_width = 0;
> +      for (int i = 0; i < 12; i++)
> +     {
> +       int width = curr_max_width;
> +
> +       int req = mbsalign (nl_langinfo (ABMON_1 + i),
> +                           abmon[i], sizeof (abmon[i]),
> +                           &width, MBS_ALIGN_LEFT);
> +
> +       if (req >= sizeof(abmon[i]))
> +         {
> +           error (0, 0, _("overflow initializing month strings"));
> +           required_mon_width = 0; /* ignore precomputed strings.  */
> +           return;

It's usually best to avoid "void" functions.
In this case, to be more library friendly, it should avoid
calling error, and simply return an indication of failure.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]