cvs commit: src/sys/compat/ndis subr_ndis.c src/sys/dev/if_ndis if_ndis.c

Bruce Evans bde at zeta.org.au
Sun May 30 06:37:42 PDT 2004


On Sun, 30 May 2004, Pawel Jakub Dawidek wrote:

> On Fri, May 28, 2004 at 11:41:17PM -0700, Bill Paul wrote:
> [...]
> +> +static int
> +> +my_strcasecmp(s1, s2, len)
> +> +        const char              *s1;
> +> +        const char              *s2;
> +> +        int                     len;
> +> +{
> +> +        int                     i;
> +> +
> +> +        for (i = 0; i < len; i++) {
> +> +                if (toupper(s1[i]) != toupper(s2[i]))
> +> +                        return(1);
> +> +        }
> +> +
> +> +        return(0);
> +> +}
> +> +
>
> Could we move it to libkern? I want to use it too.

There is a better version named strncasecmp() in libc/string/strcasecmp.c.
Things it does better:
- size_t len
- knows that toupper() and tolower()'s arg must be representable as an
  unsigned char or be EOF.  This bug is harmless in the kernel, since
  only ASCII is supported and the to*() functions don't do anything
  bad with negative args.
- only has a couple of style bugs.

Bruce


More information about the cvs-all mailing list