Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libkern Add strstr() to libkern. For now, it's only ...



details:   https://anonhg.NetBSD.org/src/rev/25aeac86f7ff
branches:  trunk
changeset: 537689:25aeac86f7ff
user:      junyoung <junyoung%NetBSD.org@localhost>
date:      Fri Oct 04 18:39:52 2002 +0000

description:
Add strstr() to libkern. For now, it's only used in i386 (for processor
identification).

diffstat:

 sys/lib/libkern/Makefile  |   6 +++-
 sys/lib/libkern/libkern.h |   4 +-
 sys/lib/libkern/strstr.c  |  76 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 84 insertions(+), 2 deletions(-)

diffs (118 lines):

diff -r 2a2d07f7ebea -r 25aeac86f7ff sys/lib/libkern/Makefile
--- a/sys/lib/libkern/Makefile  Fri Oct 04 18:37:19 2002 +0000
+++ b/sys/lib/libkern/Makefile  Fri Oct 04 18:39:52 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.65 2002/06/18 23:46:53 wrstuden Exp $
+#      $NetBSD: Makefile,v 1.66 2002/10/04 18:39:52 junyoung Exp $
 
 LIB=   kern
 NOPIC= # defined
@@ -39,6 +39,10 @@
 SRCS+= __cmsg_alignbytes.c inet_addr.c intoa.c md4c.c md5c.c sha1.c pmatch.c
 SRCS+= _que.c arc4random.c
 
+.if (${MACHINE_ARCH} == "i386")
+SRCS+= strstr.c
+.endif
+
 # Files to clean up
 CLEANFILES+= lib${LIB}.o lib${LIB}.po
 
diff -r 2a2d07f7ebea -r 25aeac86f7ff sys/lib/libkern/libkern.h
--- a/sys/lib/libkern/libkern.h Fri Oct 04 18:37:19 2002 +0000
+++ b/sys/lib/libkern/libkern.h Fri Oct 04 18:39:52 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libkern.h,v 1.44 2002/10/04 00:50:15 matt Exp $        */
+/*     $NetBSD: libkern.h,v 1.45 2002/10/04 18:39:52 junyoung Exp $    */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -259,6 +259,8 @@
 char   *strchr __P((const char *, int));
 char   *strrchr __P((const char *, int));
 
+char   *strstr __P((const char *, const char *));
+
 /*
  * ffs is an instruction on vax.
  */
diff -r 2a2d07f7ebea -r 25aeac86f7ff sys/lib/libkern/strstr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/lib/libkern/strstr.c  Fri Oct 04 18:39:52 2002 +0000
@@ -0,0 +1,76 @@
+/*     $NetBSD: strstr.c,v 1.1 2002/10/04 18:39:53 junyoung Exp $      */
+
+/*-
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "@(#)strstr.c   8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: strstr.c,v 1.1 2002/10/04 18:39:53 junyoung Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#include <string.h>
+#else
+#include <lib/libkern/libkern.h>
+#endif
+
+/*
+ * Find the first occurrence of find in s.
+ */
+char *
+strstr(s, find)
+       const char *s, *find;
+{
+       char c, sc;
+       size_t len;
+
+       if ((c = *find++) != 0) {
+               len = strlen(find);
+               do {
+                       do {
+                               if ((sc = *s++) == 0)
+                                       return (char *)0;
+                       } while (sc != c);
+               } while (strncmp(s, find, len) != 0);
+               s--;
+       }
+       /* LINTED interface specification */
+       return ((char *)s);
+}



Home | Main Index | Thread Index | Old Index