summaryrefslogtreecommitdiff
path: root/sys/lib
diff options
context:
space:
mode:
authordsl <dsl@NetBSD.org>2008-03-14 22:27:32 +0000
committerdsl <dsl@NetBSD.org>2008-03-14 22:27:32 +0000
commit2bb9a33a0f03d68fdbcaf07d41aceaeecc499d51 (patch)
tree8c1af1576e4cac8f3c7fa79e841dbf45ef02b08a /sys/lib
parent2694fcbd4bf229d884e4197b89e86e8493eb14db (diff)
Add a strchr() - for dosfs in particular.
The i386 asm version in src/common is rather larger than this one.
Diffstat (limited to 'sys/lib')
-rw-r--r--sys/lib/libsa/Makefile6
-rw-r--r--sys/lib/libsa/strchr.c55
2 files changed, 58 insertions, 3 deletions
diff --git a/sys/lib/libsa/Makefile b/sys/lib/libsa/Makefile
index 1b20cdc6f76..54ed63fd546 100644
--- a/sys/lib/libsa/Makefile
+++ b/sys/lib/libsa/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.62 2008/02/25 15:33:20 tsutsui Exp $
+# $NetBSD: Makefile,v 1.63 2008/03/14 22:27:32 dsl Exp $
LIB= sa
NOPIC= # defined
@@ -19,8 +19,8 @@ CPPFLAGS= -I${SADIR} ${SACPPFLAGS} ${SAMISCCPPFLAGS} \
# stand routines
SRCS+= alloc.c bcopy.c bzero.c errno.c exit.c exec.c files.c \
getfile.c gets.c globals.c memcmp.c memcpy.c memmove.c memset.c \
- panic.c printf.c qsort.c snprintf.c sprintf.c strerror.c subr_prf.c \
- twiddle.c vsprintf.c checkpasswd.c
+ panic.c printf.c qsort.c snprintf.c sprintf.c strchr.c strerror.c \
+ subr_prf.c twiddle.c vsprintf.c checkpasswd.c
# io routines
SRCS+= closeall.c dev.c disklabel.c dkcksum.c ioctl.c nullfs.c stat.c fstat.c
diff --git a/sys/lib/libsa/strchr.c b/sys/lib/libsa/strchr.c
new file mode 100644
index 00000000000..75e5dafe8b2
--- /dev/null
+++ b/sys/lib/libsa/strchr.c
@@ -0,0 +1,55 @@
+/* $NetBSD: strchr.c,v 1.1 2008/03/14 22:27:32 dsl Exp $ */
+
+/*-
+ * Copyright (c) 2008, The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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 NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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/types.h>
+#ifdef _STANDALONE
+#include <lib/libkern/libkern.h>
+#else
+#include <string.h>
+#endif
+#include "stand.h"
+
+/*
+ * Conformant strchr()
+ */
+char *
+strchr(const char *s, int c)
+{
+ char ch = c;
+
+ while (*s != 0 && *s != ch)
+ s++;
+ return __UNCONST(s);
+}