On Monday 20 July 2009 16:11:34 Denys Vlasenko wrote:
> On Monday 20 July 2009 14:25, Mike Frysinger wrote:
> > On Friday 19 December 2008 08:51:39 v...@uclibc.org wrote:
> > > Changeset:
> > > Modified: trunk/uClibc/libc/string/i386/memchr.c
> > >
> > > +/* Uncomment TESTING, gcc -D__USE_GNU -m32 -Os memchr.c -o memchr
> > > + * and run ./memchr
> > > + */
> > > +int main()
> > > +{
> > > + static const char str[] = "abc.def";
> > > + printf((char*)memchr(str, '.',-2) - str == 3 ? "ok\n" : "BAD!\n");
> > > + printf((char*)memchr(str, '.',-1) - str == 3 ? "ok\n" : "BAD!\n");
> > > + printf((char*)memchr(str, '.', 0) == NULL    ? "ok\n" : "BAD!\n");
> > > + printf((char*)memchr(str, '.', 1) == NULL    ? "ok\n" : "BAD!\n");
> > > + printf((char*)memchr(str, '.', 2) == NULL    ? "ok\n" : "BAD!\n");
> > > + printf((char*)memchr(str, '.', 3) == NULL    ? "ok\n" : "BAD!\n");
> > > + printf((char*)memchr(str, '.', 4) - str == 3 ? "ok\n" : "BAD!\n");
> > > + printf((char*)memchr(str, '.', 5) - str == 3 ? "ok\n" : "BAD!\n");
> > > + printf((char*)memchr(str+3, '.', 0) == NULL    ? "ok\n" : "BAD!\n");
> > > + printf((char*)memchr(str+3, '.', 5) - str == 3 ? "ok\n" : "BAD!\n");
> > > +}
> > > +#endif
> >
> > you've got to be kidding me.  we have test/string/ for a reason.  if you
> > want to make it easier to include on the fly, that's one thing, but the
> > answer is most certainly not "let's copy & paste a whole lot of code into
> > the implementation".
>
> Well, it has one advantage over test/string: it can be built and run
> just there. Imagine that you do some Obviously Correct (tm)
> tweak in libc/string/i386/memchr.c.

i know *why* you did it (ive worked/debugged string functions myself), but 
that doesnt justify the *how*.  there's no reason the test code cant live in 
tester.c and the local code reads something like:
#ifdef TESTING
#include "../../../test/string/tester.c"
#endif

and then have all the logic in tester.c for running only the function defined 
by TESTING.  then *all* arches can utilize it without having to copy & paste 
the same code and watch it all bitrot.
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to