Re: ascii string comparison [Re: use C locale for LC_CTYPE]
Johannes Hofmann <[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Nov 08, 2011 at 05:42:26PM +0000, corvid wrote:
> Jorge wrote:
> > On Mon, Nov 07, 2011 at 10:25:39PM +0100, Johannes Hofmann wrote:
> > > On Sun, Nov 06, 2011 at 08:19:07PM +0000, corvid wrote:
> > > > Johannes wrote:
> > > > > I'd just go with the approach in your first patch.
> > > >
> > > > All right then. Do you have any thoughts on what function names
> > > > would be least unwieldy / most descriptive / best fitting in
> > > > with their surroundings?
> > > >
> > > > I'm thinking maybe dAsciiToupper() and dStrAsciiCasecmp().
> > >
> > > Let's see what others do:
> > >
> > > * KDE: kAsciiToUpper() [1]
> > > * glib: g_ascii_toupper() [2]
> > > * ffmpeg: av_toupper() [3]
> > > * libevent: evutil_ascii_strcasecmp() [4]
> > >
> > > So dAsciiToupper() and dStrAsciiCasecmp() look good to me.
> >
> > +1
>
> I think I'll go with D_ASCII_TOUPPER because the argument gets
> evaluated more than once, and we don't want nasty surprises.
Hm, not sure what you mean. An inline function should behave just as
a normal function that's the nice thing about them.
Let's test:
#include <stdio.h>
static inline int test(int i) { return i > 0 ? i - 1 : i; }
#define TEST(i) ((i) > 0 ? (i) - 1 : (i))
int main (int argc, char **argv) {
int i = atoi(argv[1]);
int j = atoi(argv[1]);
printf("%d\n", test(i++));
printf("%d\n", TEST(j++));
}
./inline 2
1
2
Cheers,
Johannes