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: [PATCH] tst-strftime2: Define the number of elements in each array


Hello Florian-san,

Thank you for your suggestion.

From: Florian Weimer <fweimer@redhat.com>
Subject: Re: [PATCH] tst-strftime2: Define the number of elements in each array
Date: Wed, 06 Feb 2019 11:10:05 +0100

> > Define the number of elements in each array (locales, formats, dates)
> > as nlocales, nformats, ndates, respectively, so that the array for
> > reference is declared using them in stead of magic numbers.
> >
> > ChangeLog:
> >
> > 	* time/tst-strftime2.c: Define the number of elements in each array
> > 	(locales, formats, dates) as nlocales, nformats, ndates, respectively,
> > 	so that the array for reference is declared using them in stead of
> > 	magic numbers.
> > ---
> >  time/tst-strftime2.c | 17 ++++++++++-------
> >  1 file changed, 10 insertions(+), 7 deletions(-)
> >
> > diff --git a/time/tst-strftime2.c b/time/tst-strftime2.c
> > index 57d2144..6c2d359 100644
> > --- a/time/tst-strftime2.c
> > +++ b/time/tst-strftime2.c
> > @@ -25,8 +25,10 @@
> >  #include <string.h>
> >  
> >  static const char *locales[] = { "ja_JP.UTF-8", "lo_LA.UTF-8", "th_TH.UTF-8" };
> > +#define nlocales array_length (locales)
> >  
> >  static const char *formats[] = { "%EY", "%_EY", "%-EY" };
> > +#define nformats array_length (formats)
> >  
> >  static const struct
> >  {
> > @@ -40,8 +42,9 @@ static const struct
> >      { 1, 3, 97 },
> >      { 1, 3, 98 }
> >    };
> > +#define ndates array_length (dates)
> >  
> > -static char ref[3][3][6][100];
> > +static char ref[nlocales][nformats][ndates][100];
> 
> I'd suggest using array_length only in this place.  It's true that
> array_length (locales) is more to type than nlocales, but I think it's
> clearer to readers because they do not have to look up the definition of
> nlocales.

That is reasonable.  I will fix it.

In regards to include/array_length.h, if it is OK, could you please
push to master.

Regards,
TAMUKI Shoichi


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