diff options
Diffstat (limited to 'sys/libkern')
37 files changed, 316 insertions, 108 deletions
diff --git a/sys/libkern/Makefile b/sys/libkern/Makefile index 991a435..2d6bafb 100644 --- a/sys/libkern/Makefile +++ b/sys/libkern/Makefile @@ -1,4 +1,5 @@ # @(#)Makefile 7.9 (Berkeley) 6/1/93 +# $Id$ LIB= kern CFLAGS+= -I${.CURDIR} -I${.CURDIR}/.. diff --git a/sys/libkern/adddi3.c b/sys/libkern/adddi3.c index d10da47..38b9df9 100644 --- a/sys/libkern/adddi3.c +++ b/sys/libkern/adddi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)adddi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/anddi3.c b/sys/libkern/anddi3.c index 5ae45ac..9f92718 100644 --- a/sys/libkern/anddi3.c +++ b/sys/libkern/anddi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)anddi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/ashldi3.c b/sys/libkern/ashldi3.c index 72501ad..74fa0fd 100644 --- a/sys/libkern/ashldi3.c +++ b/sys/libkern/ashldi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ashldi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/ashrdi3.c b/sys/libkern/ashrdi3.c index 9ffa5ed..51b9da5 100644 --- a/sys/libkern/ashrdi3.c +++ b/sys/libkern/ashrdi3.c @@ -33,6 +33,8 @@ * 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. + * + * $Id$ */ #if defined(LIBC_SCCS) && !defined(lint) diff --git a/sys/libkern/bcmp.c b/sys/libkern/bcmp.c index 5a3ae61..de9449b 100644 --- a/sys/libkern/bcmp.c +++ b/sys/libkern/bcmp.c @@ -29,12 +29,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)bcmp.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include <string.h> /* diff --git a/sys/libkern/cmpdi2.c b/sys/libkern/cmpdi2.c index f6e4bdd..238bd4e 100644 --- a/sys/libkern/cmpdi2.c +++ b/sys/libkern/cmpdi2.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)cmpdi2.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/divdi3.c b/sys/libkern/divdi3.c index da7b2fc..f6687f9 100644 --- a/sys/libkern/divdi3.c +++ b/sys/libkern/divdi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)divdi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/ffs.c b/sys/libkern/ffs.c index 099ff8e..74e2450 100644 --- a/sys/libkern/ffs.c +++ b/sys/libkern/ffs.c @@ -29,12 +29,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include <string.h> /* diff --git a/sys/libkern/fnmatch.c b/sys/libkern/fnmatch.c new file mode 100644 index 0000000..dc7f151 --- /dev/null +++ b/sys/libkern/fnmatch.c @@ -0,0 +1,171 @@ +/* + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; +#endif /* LIBC_SCCS and not lint */ + +/* + * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. + * Compares a filename or pathname to a pattern. + */ + +#include <fnmatch.h> +#include <string.h> + +#define EOS '\0' + +static const char *rangematch __P((const char *, int, int)); + +int +fnmatch(pattern, string, flags) + const char *pattern, *string; + int flags; +{ + const char *stringstart; + char c, test; + + for (stringstart = string;;) + switch (c = *pattern++) { + case EOS: + return (*string == EOS ? 0 : FNM_NOMATCH); + case '?': + if (*string == EOS) + return (FNM_NOMATCH); + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + ++string; + break; + case '*': + c = *pattern; + /* Collapse multiple stars. */ + while (c == '*') + c = *++pattern; + + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + + /* Optimize for pattern with * at end or before /. */ + if (c == EOS) + if (flags & FNM_PATHNAME) + return (strchr(string, '/') == NULL ? + 0 : FNM_NOMATCH); + else + return (0); + else if (c == '/' && flags & FNM_PATHNAME) { + if ((string = strchr(string, '/')) == NULL) + return (FNM_NOMATCH); + break; + } + + /* General case, use recursion. */ + while ((test = *string) != EOS) { + if (!fnmatch(pattern, string, flags & ~FNM_PERIOD)) + return (0); + if (test == '/' && flags & FNM_PATHNAME) + break; + ++string; + } + return (FNM_NOMATCH); + case '[': + if (*string == EOS) + return (FNM_NOMATCH); + if (*string == '/' && flags & FNM_PATHNAME) + return (FNM_NOMATCH); + if ((pattern = + rangematch(pattern, *string, flags)) == NULL) + return (FNM_NOMATCH); + ++string; + break; + case '\\': + if (!(flags & FNM_NOESCAPE)) { + if ((c = *pattern++) == EOS) { + c = '\\'; + --pattern; + } + } + /* FALLTHROUGH */ + default: + if (c != *string++) + return (FNM_NOMATCH); + break; + } + /* NOTREACHED */ +} + +static const char * +rangematch(pattern, test, flags) + const char *pattern; + int test, flags; +{ + int negate, ok; + char c, c2; + + /* + * A bracket expression starting with an unquoted circumflex + * character produces unspecified results (IEEE 1003.2-1992, + * 3.13.2). This implementation treats it like '!', for + * consistency with the regular expression syntax. + * J.T. Conklin (conklin@ngai.kaleida.com) + */ + if (negate = (*pattern == '!' || *pattern == '^')) + ++pattern; + + for (ok = 0; (c = *pattern++) != ']';) { + if (c == '\\' && !(flags & FNM_NOESCAPE)) + c = *pattern++; + if (c == EOS) + return (NULL); + if (*pattern == '-' + && (c2 = *(pattern+1)) != EOS && c2 != ']') { + pattern += 2; + if (c2 == '\\' && !(flags & FNM_NOESCAPE)) + c2 = *pattern++; + if (c2 == EOS) + return (NULL); + if (c <= test && test <= c2) + ok = 1; + } else if (c == test) + ok = 1; + } + return (ok == negate ? NULL : pattern); +} diff --git a/sys/libkern/iordi3.c b/sys/libkern/iordi3.c index e225005..2819cf8 100644 --- a/sys/libkern/iordi3.c +++ b/sys/libkern/iordi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)iordi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/libkern.h b/sys/libkern/libkern.h index 0e465e0..d4669c7 100644 --- a/sys/libkern/libkern.h +++ b/sys/libkern/libkern.h @@ -31,6 +31,7 @@ * SUCH DAMAGE. * * @(#)libkern.h 8.1 (Berkeley) 6/10/93 + * $Id$ */ #include <sys/types.h> diff --git a/sys/libkern/locc.c b/sys/libkern/locc.c index 3767222..8a67e0f 100644 --- a/sys/libkern/locc.c +++ b/sys/libkern/locc.c @@ -31,6 +31,7 @@ * SUCH DAMAGE. * * @(#)locc.c 8.1 (Berkeley) 6/10/93 + * $Id$ */ #include <libkern/libkern.h> diff --git a/sys/libkern/lshldi3.c b/sys/libkern/lshldi3.c index 0af6051..0aba85e 100644 --- a/sys/libkern/lshldi3.c +++ b/sys/libkern/lshldi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)lshldi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/lshrdi3.c b/sys/libkern/lshrdi3.c index add2eda..b93de21 100644 --- a/sys/libkern/lshrdi3.c +++ b/sys/libkern/lshrdi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)lshrdi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/mcount.c b/sys/libkern/mcount.c index 523217d..fd8e6a3 100644 --- a/sys/libkern/mcount.c +++ b/sys/libkern/mcount.c @@ -29,12 +29,10 @@ * 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. + * + * $Id$ */ -#if !defined(lint) && !defined(KERNEL) && defined(LIBC_SCCS) -static char sccsid[] = "@(#)mcount.c 8.1 (Berkeley) 6/4/93"; -#endif - #include <sys/param.h> #include <sys/gmon.h> diff --git a/sys/libkern/moddi3.c b/sys/libkern/moddi3.c index f31c6e8..efb6f92 100644 --- a/sys/libkern/moddi3.c +++ b/sys/libkern/moddi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)moddi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/muldi3.c b/sys/libkern/muldi3.c index a8d7cfc..49adc51 100644 --- a/sys/libkern/muldi3.c +++ b/sys/libkern/muldi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)muldi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/negdi2.c b/sys/libkern/negdi2.c index bb8670d..c4065e2 100644 --- a/sys/libkern/negdi2.c +++ b/sys/libkern/negdi2.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)negdi2.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/notdi2.c b/sys/libkern/notdi2.c index d624733..f451088 100644 --- a/sys/libkern/notdi2.c +++ b/sys/libkern/notdi2.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)notdi2.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/qdivrem.c b/sys/libkern/qdivrem.c index 34b94ce..caf4d7c 100644 --- a/sys/libkern/qdivrem.c +++ b/sys/libkern/qdivrem.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)qdivrem.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - /* * Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed), * section 4.3.1, pp. 257--259. diff --git a/sys/libkern/quad.h b/sys/libkern/quad.h index bc6a2f8..dadd02c 100644 --- a/sys/libkern/quad.h +++ b/sys/libkern/quad.h @@ -35,6 +35,7 @@ * SUCH DAMAGE. * * @(#)quad.h 8.1 (Berkeley) 6/4/93 + * $Id$ */ /* diff --git a/sys/libkern/random.c b/sys/libkern/random.c index 5153124..7cdfd32 100644 --- a/sys/libkern/random.c +++ b/sys/libkern/random.c @@ -31,6 +31,7 @@ * SUCH DAMAGE. * * @(#)random.c 8.1 (Berkeley) 6/10/93 + * $Id$ */ #include <libkern/libkern.h> diff --git a/sys/libkern/rindex.c b/sys/libkern/rindex.c index 69dced4..bd661fb 100644 --- a/sys/libkern/rindex.c +++ b/sys/libkern/rindex.c @@ -29,12 +29,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)rindex.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include <stddef.h> #include <string.h> diff --git a/sys/libkern/scanc.c b/sys/libkern/scanc.c index 2d8b6a0..88bc3ff 100644 --- a/sys/libkern/scanc.c +++ b/sys/libkern/scanc.c @@ -31,6 +31,8 @@ * SUCH DAMAGE. * * @(#)scanc.c 8.1 (Berkeley) 6/10/93 + * + * $Id$ */ #include <libkern/libkern.h> diff --git a/sys/libkern/skpc.c b/sys/libkern/skpc.c index 11b269e..43894ef 100644 --- a/sys/libkern/skpc.c +++ b/sys/libkern/skpc.c @@ -31,6 +31,8 @@ * SUCH DAMAGE. * * @(#)skpc.c 8.1 (Berkeley) 6/10/93 + * + * $Id$ */ #include <libkern/libkern.h> diff --git a/sys/libkern/strcat.c b/sys/libkern/strcat.c index 3436967..07e7923 100644 --- a/sys/libkern/strcat.c +++ b/sys/libkern/strcat.c @@ -29,12 +29,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strcat.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include <string.h> char * diff --git a/sys/libkern/strcmp.c b/sys/libkern/strcmp.c index 79cfaa8..c9c397b 100644 --- a/sys/libkern/strcmp.c +++ b/sys/libkern/strcmp.c @@ -32,12 +32,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strcmp.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include <sys/cdefs.h> #include <string.h> diff --git a/sys/libkern/strcpy.c b/sys/libkern/strcpy.c index d1791dd..2715720 100644 --- a/sys/libkern/strcpy.c +++ b/sys/libkern/strcpy.c @@ -29,12 +29,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include <sys/cdefs.h> #include <string.h> diff --git a/sys/libkern/strlen.c b/sys/libkern/strlen.c index 323fbe4..1d1352c 100644 --- a/sys/libkern/strlen.c +++ b/sys/libkern/strlen.c @@ -29,12 +29,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strlen.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include <sys/cdefs.h> #include <string.h> diff --git a/sys/libkern/strncpy.c b/sys/libkern/strncpy.c index 9e72740..8aea690 100644 --- a/sys/libkern/strncpy.c +++ b/sys/libkern/strncpy.c @@ -32,12 +32,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strncpy.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include <sys/cdefs.h> #include <string.h> diff --git a/sys/libkern/strsep.c b/sys/libkern/strsep.c new file mode 100644 index 0000000..18dc398 --- /dev/null +++ b/sys/libkern/strsep.c @@ -0,0 +1,80 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. 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 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> +#include <string.h> +#include <stdio.h> + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +/* + * Get next token from string *stringp, where tokens are possibly-empty + * strings separated by characters from delim. + * + * Writes NULs into the string at *stringp to end tokens. + * delim need not remain constant from call to call. + * On return, *stringp points past the last NUL written (if there might + * be further tokens), or is NULL (if there are definitely no more tokens). + * + * If *stringp is NULL, strsep returns NULL. + */ +char * +strsep(stringp, delim) + register char **stringp; + register const char *delim; +{ + register char *s; + register const char *spanp; + register int c, sc; + char *tok; + + if ((s = *stringp) == NULL) + return (NULL); + for (tok = s;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + *stringp = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} diff --git a/sys/libkern/subdi3.c b/sys/libkern/subdi3.c index e976345..cb54477 100644 --- a/sys/libkern/subdi3.c +++ b/sys/libkern/subdi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)subdi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/ucmpdi2.c b/sys/libkern/ucmpdi2.c index e5dfc43..4aa3e50 100644 --- a/sys/libkern/ucmpdi2.c +++ b/sys/libkern/ucmpdi2.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ucmpdi2.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/udivdi3.c b/sys/libkern/udivdi3.c index 8ddd559..f9a77ec 100644 --- a/sys/libkern/udivdi3.c +++ b/sys/libkern/udivdi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)udivdi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/umoddi3.c b/sys/libkern/umoddi3.c index 2a85f76..ccd457d 100644 --- a/sys/libkern/umoddi3.c +++ b/sys/libkern/umoddi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)umoddi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* diff --git a/sys/libkern/xordi3.c b/sys/libkern/xordi3.c index e3a8588..e491909 100644 --- a/sys/libkern/xordi3.c +++ b/sys/libkern/xordi3.c @@ -33,12 +33,10 @@ * 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. + * + * $Id$ */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)xordi3.c 8.1 (Berkeley) 6/4/93"; -#endif /* LIBC_SCCS and not lint */ - #include "quad.h" /* |