Date: Mon, 31 May 2004 16:31:27 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Nate Lawson <nate@root.org> Cc: cvs-src@freebsd.org Subject: Re: cvs commit: src/sys/compat/ndis subr_ndis.c src/sys/dev/if_ndis if_ndis.c Message-ID: <20040531161707.A13309@gamplex.bde.org> In-Reply-To: <20040530213504.I16510@root.org> References: <200405290641.i4T6fHhj002797@repoman.freebsd.org> <20040530213504.I16510@root.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 30 May 2004, Nate Lawson wrote:
> While we're at it, two from acpi:
> /* FreeBSD doesn't have strupr, should be fixed. (move to libkern) */
> static __inline char *
> strupr(char *str)
> {
> char *c = str;
> while(*c) {
> *c = toupper(*c);
> c++;
> }
> return(str);
> }
libc doesn't seem to have this, but if it did then it would have a version
without so many style bugs. FreeBSD userland seems to only have it in
libroken. Why would the kernel need it more than libc?
> #ifdef _KERNEL
> /* Or strstr (used in debugging mode, also move to libkern) */
> static __inline char *
> strstr(char *s, char *find)
> {
> char c, sc;
> size_t len;
>
> if ((c = *find++) != 0) {
> len = strlen(find);
> do {
> do {
> if ((sc = *s++) == 0)
> return (NULL);
> } while (sc != c);
> } while (strncmp(s, find, len) != 0);
> s--;
> }
> return ((char *)s);
> }
> #endif /* _KERNEL */
libc already has a version of this without so many bugs and style bugs.
The above is was apparently obtained from rev.1.1 of libc/string/strstr.c
(its only differences are "static __inline", de-register'ing and format
mangling). The libc version has since caught up with the 1980's and
uses "const".
Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040531161707.A13309>
