This patch removes the string/ and wchar/ directories.
Change-Id: Ia489904bc67047e4bc79acb1f3eec21aa3fe5f0d
netbsd/
stdio/
stdlib/
- string/
unistd/
- wchar/
# These are legacy files of unknown provenance. In the past, bionic was a
# mess of random versions of random files from all three of FreeBSD, NetBSD,
# and OpenBSD! We've been working to clean that up, but these directories
bionic/ether_aton.c \
bionic/ether_ntoa.c \
bionic/fdprintf.c \
- bionic/flockfile.c \
bionic/ftime.c \
bionic/fts.c \
bionic/getdtablesize.c \
unistd/syslog.c \
unistd/system.c \
unistd/time.c \
- wchar/wcswidth.c \
- wchar/wcsxfrm.c \
# Fortify implementations of libc functions.
libc_common_src_files += \
bionic/eventfd_read.cpp \
bionic/eventfd_write.cpp \
bionic/ffs.cpp \
+ bionic/flockfile.cpp \
bionic/fork.cpp \
bionic/futimens.cpp \
bionic/getauxval.cpp \
upstream-freebsd/lib/libc/string/wcscspn.c \
upstream-freebsd/lib/libc/string/wcsdup.c \
upstream-freebsd/lib/libc/string/wcslcat.c \
- upstream-freebsd/lib/libc/string/wcslcpy.c \
upstream-freebsd/lib/libc/string/wcsncasecmp.c \
upstream-freebsd/lib/libc/string/wcsncat.c \
upstream-freebsd/lib/libc/string/wcsncmp.c \
upstream-netbsd/lib/libc/thread-stub/__isthreaded.c \
upstream-netbsd/lib/libc/unistd/killpg.c \
+libc_upstream_openbsd_src_files := \
+ upstream-openbsd/lib/libc/gen/exec.c \
+ upstream-openbsd/lib/libc/gen/ftok.c \
+ upstream-openbsd/lib/libc/gen/fnmatch.c \
+ upstream-openbsd/lib/libc/gen/toupper_.c \
+ upstream-openbsd/lib/libc/gen/tolower_.c \
+ upstream-openbsd/lib/libc/string/strstr.c \
+ upstream-openbsd/lib/libc/string/strsep.c \
+ upstream-openbsd/lib/libc/string/wcslcpy.c \
+ upstream-openbsd/lib/libc/string/strcasecmp.c \
+ upstream-openbsd/lib/libc/string/strdup.c \
+ upstream-openbsd/lib/libc/string/strcspn.c \
+ upstream-openbsd/lib/libc/string/strtok.c \
+ upstream-openbsd/lib/libc/string/strpbrk.c \
+ upstream-openbsd/lib/libc/string/strspn.c \
+ upstream-openbsd/lib/libc/string/wcswidth.c \
+ upstream-openbsd/lib/libc/string/strndup.c \
+ upstream-openbsd/lib/libc/stdio/ungetc.c \
+ upstream-openbsd/lib/libc/stdio/vsnprintf.c \
+ upstream-openbsd/lib/libc/stdio/tmpnam.c \
+ upstream-openbsd/lib/libc/stdio/setbuffer.c \
+ upstream-openbsd/lib/libc/stdio/fsetpos.c \
+ upstream-openbsd/lib/libc/stdio/setbuf.c \
+ upstream-openbsd/lib/libc/stdio/vprintf.c \
+ upstream-openbsd/lib/libc/stdio/perror.c \
+ upstream-openbsd/lib/libc/stdio/remove.c \
+ upstream-openbsd/lib/libc/stdio/getc.c \
+ upstream-openbsd/lib/libc/stdio/funopen.c \
+ upstream-openbsd/lib/libc/stdio/ferror.c \
+ upstream-openbsd/lib/libc/stdio/putchar.c \
+ upstream-openbsd/lib/libc/stdio/vscanf.c \
+ upstream-openbsd/lib/libc/stdio/fflush.c \
+ upstream-openbsd/lib/libc/stdio/fpurge.c \
+ upstream-openbsd/lib/libc/stdio/fputs.c \
+ upstream-openbsd/lib/libc/stdio/tempnam.c \
+ upstream-openbsd/lib/libc/stdio/printf.c \
+ upstream-openbsd/lib/libc/stdio/fileno.c \
+ upstream-openbsd/lib/libc/stdio/stdio.c \
+ upstream-openbsd/lib/libc/stdio/getdelim.c \
+ upstream-openbsd/lib/libc/stdio/fseek.c \
+ upstream-openbsd/lib/libc/stdio/fputc.c \
+ upstream-openbsd/lib/libc/stdio/fgetln.c \
+ upstream-openbsd/lib/libc/stdio/fdopen.c \
+ upstream-openbsd/lib/libc/stdio/fgets.c \
+ upstream-openbsd/lib/libc/stdio/fgetc.c \
+ upstream-openbsd/lib/libc/stdio/feof.c \
+ upstream-openbsd/lib/libc/stdio/vasprintf.c \
+ upstream-openbsd/lib/libc/stdio/refill.c \
+ upstream-openbsd/lib/libc/stdio/getline.c \
+ upstream-openbsd/lib/libc/stdio/rewind.c \
+ upstream-openbsd/lib/libc/stdio/wbuf.c \
+ upstream-openbsd/lib/libc/stdio/gets.c \
+ upstream-openbsd/lib/libc/stdio/fgetpos.c \
+ upstream-openbsd/lib/libc/stdio/fscanf.c \
+ upstream-openbsd/lib/libc/stdio/putc.c \
+ upstream-openbsd/lib/libc/stdio/vsprintf.c \
+ upstream-openbsd/lib/libc/stdio/rget.c \
+ upstream-openbsd/lib/libc/stdio/clrerr.c \
+ upstream-openbsd/lib/libc/stdio/scanf.c \
+ upstream-openbsd/lib/libc/stdio/puts.c \
+ upstream-openbsd/lib/libc/stdio/getchar.c \
+ upstream-openbsd/lib/libc/stdio/ftell.c \
+ upstream-openbsd/lib/libc/stdio/fwalk.c \
+ upstream-openbsd/lib/libc/stdlib/strtoul.c \
+ upstream-openbsd/lib/libc/stdlib/strtoull.c \
+ upstream-openbsd/lib/libc/stdlib/atoi.c \
+ upstream-openbsd/lib/libc/stdlib/atoll.c \
+ upstream-openbsd/lib/libc/stdlib/atol.c \
+ upstream-openbsd/lib/libc/stdlib/strtoimax.c \
+ upstream-openbsd/lib/libc/stdlib/strtoumax.c \
+ upstream-openbsd/lib/libc/stdlib/strtoll.c \
+ upstream-openbsd/lib/libc/stdlib/strtol.c \
+ upstream-openbsd/lib/libc/locale/wcsxfrm.c \
+
libc_arch_static_src_files := \
bionic/dl_iterate_phdr_static.cpp \
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := $(call all-c-files-under,upstream-openbsd)
+LOCAL_SRC_FILES := $(libc_upstream_openbsd_src_files)
LOCAL_CFLAGS := \
$(libc_common_cflags) \
-I$(LOCAL_PATH)/upstream-openbsd \
bionic/mmap.cpp
libc_common_src_files_arm += \
+ bionic/index.cpp \
bionic/memchr.c \
bionic/memmove.c.arm \
bionic/memrchr.c \
bionic/strchr.cpp \
bionic/strnlen.c \
- string/bcopy.c \
- string/index.c \
- string/strlcat.c \
- string/strlcpy.c \
- string/strncat.c \
- string/strncmp.c \
- string/strncpy.c \
- string/strrchr.c \
+ bionic/strrchr.cpp \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
upstream-freebsd/lib/libc/string/wcslen.c \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
+ upstream-openbsd/lib/libc/string/bcopy.c \
+ upstream-openbsd/lib/libc/string/strlcat.c \
+ upstream-openbsd/lib/libc/string/strlcpy.c \
+ upstream-openbsd/lib/libc/string/strncat.c \
+ upstream-openbsd/lib/libc/string/strncmp.c \
+ upstream-openbsd/lib/libc/string/strncpy.c \
# The C++ fortify function implementations for which there is an
# arm assembler version.
libc_bionic_src_files_arm += \
arch-arm/generic/bionic/memcpy.S \
arch-arm/generic/bionic/memset.S \
- string/strcat.c \
arch-arm/generic/bionic/strcmp.S \
arch-arm/generic/bionic/strcpy.S \
arch-arm/generic/bionic/strlen.c \
bionic/__strcat_chk.cpp \
bionic/__strcpy_chk.cpp \
+ upstream-openbsd/lib/libc/string/strcat.c \
# arm64 specific configs
libc_common_src_files_arm64 := \
- bionic/memchr.c \
- bionic/memcmp.c \
- bionic/memcpy.c \
- bionic/memmove.c \
- bionic/memrchr.c \
- bionic/memset.c \
+ bionic/index.cpp \
+ bionic/memchr.c \
+ bionic/__memcmp16.cpp \
+ bionic/memcmp.c \
+ bionic/memcpy.c \
+ bionic/memmove.c \
+ bionic/memrchr.c \
+ bionic/memset.c \
bionic/strchr.cpp \
- bionic/strnlen.c \
- string/bcopy.c \
- string/index.c \
- string/memcmp16.c \
- string/strcat.c \
- string/strcmp.c \
- string/strcpy.c \
- string/strlcat.c \
- string/strlcpy.c \
- string/strlen.c \
- string/strncat.c \
- string/strncmp.c \
- string/strncpy.c \
- string/strrchr.c \
+ bionic/strnlen.c \
+ bionic/strrchr.cpp \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
upstream-freebsd/lib/libc/string/wcslen.c \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
+ upstream-openbsd/lib/libc/string/bcopy.c \
+ upstream-openbsd/lib/libc/string/strcat.c \
+ upstream-openbsd/lib/libc/string/strcmp.c \
+ upstream-openbsd/lib/libc/string/strcpy.c \
+ upstream-openbsd/lib/libc/string/strlcat.c \
+ upstream-openbsd/lib/libc/string/strlcpy.c \
+ upstream-openbsd/lib/libc/string/strlen.c \
+ upstream-openbsd/lib/libc/string/strncat.c \
+ upstream-openbsd/lib/libc/string/strncmp.c \
+ upstream-openbsd/lib/libc/string/strncpy.c \
# Fortify implementations of libc functions.
libc_common_src_files_arm64 += \
bionic/mmap.cpp
libc_common_src_files_mips += \
+ bionic/index.cpp \
bionic/memchr.c \
bionic/memcmp.c \
bionic/memmove.c \
bionic/memrchr.c \
bionic/strchr.cpp \
bionic/strnlen.c \
- string/bcopy.c \
- string/index.c \
- string/strcat.c \
- string/strcmp.c \
- string/strcpy.c \
- string/strlcat.c \
- string/strlcpy.c \
- string/strncat.c \
- string/strncmp.c \
- string/strncpy.c \
- string/strrchr.c \
+ bionic/strrchr.cpp \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
upstream-freebsd/lib/libc/string/wcslen.c \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
+ upstream-openbsd/lib/libc/string/bcopy.c \
+ upstream-openbsd/lib/libc/string/strcat.c \
+ upstream-openbsd/lib/libc/string/strcmp.c \
+ upstream-openbsd/lib/libc/string/strcpy.c \
+ upstream-openbsd/lib/libc/string/strlcat.c \
+ upstream-openbsd/lib/libc/string/strlcpy.c \
+ upstream-openbsd/lib/libc/string/strncat.c \
+ upstream-openbsd/lib/libc/string/strncmp.c \
+ upstream-openbsd/lib/libc/string/strncpy.c \
# Fortify implementations of libc functions.
libc_common_src_files_mips += \
# mips64 specific configs
libc_common_src_files_mips64 := \
- bionic/memchr.c \
- bionic/memcmp.c \
- bionic/memmove.c \
- bionic/memrchr.c \
- bionic/strchr.cpp \
- bionic/strnlen.c \
- string/bcopy.c \
- string/index.c \
- string/strcat.c \
- string/strcmp.c \
- string/strcpy.c \
- string/strlcat.c \
- string/strlcpy.c \
- string/strncat.c \
- string/strncmp.c \
- string/strncpy.c \
- string/strrchr.c \
- upstream-freebsd/lib/libc/string/wcscat.c \
- upstream-freebsd/lib/libc/string/wcschr.c \
- upstream-freebsd/lib/libc/string/wcscmp.c \
- upstream-freebsd/lib/libc/string/wcscpy.c \
- upstream-freebsd/lib/libc/string/wcslen.c \
- upstream-freebsd/lib/libc/string/wcsrchr.c \
- upstream-freebsd/lib/libc/string/wmemcmp.c \
+ bionic/index.cpp \
+ bionic/memchr.c \
+ bionic/memcmp.c \
+ bionic/memmove.c \
+ bionic/memrchr.c \
+ bionic/strchr.cpp \
+ bionic/strnlen.c \
+ bionic/strrchr.cpp \
+ upstream-freebsd/lib/libc/string/wcscat.c \
+ upstream-freebsd/lib/libc/string/wcschr.c \
+ upstream-freebsd/lib/libc/string/wcscmp.c \
+ upstream-freebsd/lib/libc/string/wcscpy.c \
+ upstream-freebsd/lib/libc/string/wcslen.c \
+ upstream-freebsd/lib/libc/string/wcsrchr.c \
+ upstream-freebsd/lib/libc/string/wmemcmp.c \
+ upstream-openbsd/lib/libc/string/bcopy.c \
+ upstream-openbsd/lib/libc/string/strcat.c \
+ upstream-openbsd/lib/libc/string/strcmp.c \
+ upstream-openbsd/lib/libc/string/strcpy.c \
+ upstream-openbsd/lib/libc/string/strlcat.c \
+ upstream-openbsd/lib/libc/string/strlcpy.c \
+ upstream-openbsd/lib/libc/string/strlen.c \
+ upstream-openbsd/lib/libc/string/strncat.c \
+ upstream-openbsd/lib/libc/string/strncmp.c \
+ upstream-openbsd/lib/libc/string/strncpy.c \
# Fortify implementations of libc functions.
libc_common_src_files_mips64 += \
# FIXME TODO
## libc_bionic_src_files_mips64 += arch-mips64/string/memcpy.S
## libc_bionic_src_files_mips64 += arch-mips64/string/memset.S
-## libc_bionic_src_files_mips64 += arch-mips64/string/mips_strlen.c
libc_bionic_src_files_mips64 += bionic/memcpy.c
libc_bionic_src_files_mips64 += bionic/memset.c
-libc_bionic_src_files_mips64 += string/strlen.c
libc_crt_target_cflags_mips64 := \
arch-x86/string/strncmp.S \
arch-x86/string/strcat.S \
arch-x86/string/memcmp.S \
- string/memcmp16.c \
- string/strcpy.c \
- string/strncat.c \
- string/strncpy.c \
- string/strlcat.c \
- string/strlcpy.c \
+ bionic/__memcmp16.cpp \
upstream-freebsd/lib/libc/string/wcscpy.c \
upstream-freebsd/lib/libc/string/wcscat.c \
- upstream-freebsd/lib/libc/string/wmemcmp.c
+ upstream-freebsd/lib/libc/string/wmemcmp.c \
+ upstream-openbsd/lib/libc/string/strcpy.c \
+ upstream-openbsd/lib/libc/string/strlcat.c \
+ upstream-openbsd/lib/libc/string/strlcpy.c \
+ upstream-openbsd/lib/libc/string/strncat.c \
+ upstream-openbsd/lib/libc/string/strncpy.c \
+
endif
libc_bionic_src_files_x86 += \
# x86_64 specific configs
libc_common_src_files_x86_64 := \
+ bionic/index.cpp \
bionic/memchr.c \
bionic/memcmp.c \
bionic/memcpy.c \
bionic/memset.c \
bionic/strchr.cpp \
bionic/strnlen.c \
- string/bcopy.c \
- string/index.c \
- string/strcat.c \
- string/strcmp.c \
- string/strcpy.c \
- string/strlcat.c \
- string/strlcpy.c \
- string/strlen.c \
- string/strncat.c \
- string/strncmp.c \
- string/strncpy.c \
- string/strrchr.c \
+ bionic/strrchr.cpp \
upstream-freebsd/lib/libc/string/wcscat.c \
upstream-freebsd/lib/libc/string/wcschr.c \
upstream-freebsd/lib/libc/string/wcscmp.c \
upstream-freebsd/lib/libc/string/wcslen.c \
upstream-freebsd/lib/libc/string/wcsrchr.c \
upstream-freebsd/lib/libc/string/wmemcmp.c \
+ upstream-openbsd/lib/libc/string/bcopy.c \
+ upstream-openbsd/lib/libc/string/strcat.c \
+ upstream-openbsd/lib/libc/string/strcmp.c \
+ upstream-openbsd/lib/libc/string/strcpy.c \
+ upstream-openbsd/lib/libc/string/strlcat.c \
+ upstream-openbsd/lib/libc/string/strlcpy.c \
+ upstream-openbsd/lib/libc/string/strlen.c \
+ upstream-openbsd/lib/libc/string/strncat.c \
+ upstream-openbsd/lib/libc/string/strncmp.c \
+ upstream-openbsd/lib/libc/string/strncpy.c \
# Fortify implementations of libc functions.
libc_common_src_files_x86_64 += \
arch-x86_64/bionic/sigsetjmp.S \
arch-x86_64/bionic/syscall.S \
arch-x86_64/bionic/vfork.S \
- string/memcmp16.c \
-
+ bionic/__memcmp16.cpp \
libc_crt_target_cflags_x86_64 += \
-m64 \
#include <stddef.h>
-/* Unoptimised version of __memcmp16 */
-int __memcmp16(const unsigned short *ptr1, const unsigned short *ptr2, size_t n)
-{
- size_t i;
+// Unoptimized version of __memcmp16.
+int __memcmp16(const unsigned short *ptr1, const unsigned short *ptr2, size_t n) {
- for (i = 0; i < n; i++) {
- if (*ptr1 != *ptr2)
+ for (size_t i = 0; i < n; i++) {
+ if (*ptr1 != *ptr2) {
return *ptr1 - *ptr2;
+ }
ptr1++;
ptr2++;
}
-/* $OpenBSD: rindex.c,v 1.6 2005/08/08 08:05:37 espie Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* SUCH DAMAGE.
*/
-/* implement flockfile(), ftrylockfile() and funlockfile()
- *
- * we can't use the OpenBSD implementation which uses kernel-specific
- * APIs not available on Linux.
- *
- * Instead, we use a pthread_mutex_t within the FILE* internal state.
- * See fileext.h for details.
- *
- * the behaviour, if fclose() is called while the corresponding
- * file is locked is totally undefined.
- */
-#include <stdio.h>
-#include <string.h>
#include <errno.h>
+#include <stdio.h>
+
#include "fileext.h"
+// We can't use the OpenBSD implementation which uses kernel-specific
+// APIs not available on Linux. Instead we use a pthread_mutex_t within
+// struct __sfileext (see fileext.h).
-void
-flockfile(FILE * fp)
-{
- if (fp != NULL) {
- _FLOCK_LOCK(fp);
- }
+void flockfile(FILE* fp) {
+ if (fp != NULL) {
+ pthread_mutex_lock(&_FLOCK(fp));
+ }
}
+int ftrylockfile(FILE* fp) {
+ // The specification for ftrylockfile() says it returns 0 on success,
+ // or non-zero on error. So return an errno code directly on error.
+ if (fp == NULL) {
+ return EINVAL;
+ }
-int
-ftrylockfile(FILE *fp)
-{
- /* The specification for ftrylockfile() says it returns 0 on success,
- * or non-zero on error. So return an errno code directly on error.
- */
- int ret = EINVAL;
-
- if (fp != NULL) {
- ret = _FLOCK_TRYLOCK(fp);
- }
- return ret;
+ return pthread_mutex_trylock(&_FLOCK(fp));
}
-void
-funlockfile(FILE * fp)
-{
- if (fp != NULL) {
- _FLOCK_UNLOCK(fp);
- }
+void funlockfile(FILE* fp) {
+ if (fp != NULL) {
+ pthread_mutex_unlock(&_FLOCK(fp));
+ }
}
-/* $OpenBSD: index.c,v 1.5 2005/08/08 08:05:37 espie Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
* SUCH DAMAGE.
*/
+#undef _FORTIFY_SOURCE
#include <string.h>
-char *
-index(const char *p, int ch)
-{
- for (;; ++p) {
- if (*p == (char) ch)
- return((char *)p);
- if (!*p)
- return((char *)NULL);
- }
- /* NOTREACHED */
+char* index(const char* p, int ch) {
+ return __strchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
}
#undef _FORTIFY_SOURCE
#include <string.h>
-extern "C" char* strchr(const char* p, int ch) {
+char* strchr(const char* p, int ch) {
return __strchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
}
-/* $OpenBSD: rindex.c,v 1.6 2005/08/08 08:05:37 espie Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
* All rights reserved.
* SUCH DAMAGE.
*/
+#undef _FORTIFY_SOURCE
#include <string.h>
-char *
-strrchr(const char *p, int ch)
-{
- return __strrchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
+char* strrchr(const char* p, int ch) {
+ return __strrchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
}
extern char* __strchr_chk(const char *, int, size_t);
extern char* strrchr(const char *, int) __purefunc;
+extern char* __strrchr_chk(const char *, int, size_t);
extern size_t strlen(const char *) __purefunc;
extern size_t __strlen_chk(const char *, size_t);
return __strchr_chk(s, c, bos);
}
-extern char* __strrchr_chk(const char *, int, size_t);
-
__BIONIC_FORTIFY_INLINE
char* strrchr(const char *s, int c) {
size_t bos = __bos(s);
extern int wprintf(const wchar_t *, ...);
extern int wscanf(const wchar_t *, ...);
+extern size_t wcslcat(wchar_t*, const wchar_t*, size_t);
+extern size_t wcslcpy(wchar_t*, const wchar_t*, size_t);
+
/* No really supported. These are just for making libstdc++-v3 happy. */
typedef void *wctrans_t;
extern wint_t towctrans(wint_t, wctrans_t);
_UB(fp)._base = NULL; \
_UB(fp)._size = 0; \
WCIO_INIT(fp); \
- _FLOCK_INIT(fp); \
+ _FLOCK(fp).value = __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE; \
} while (0)
-/* Helper macros to avoid a function call when you know that fp is not NULL.
- * Notice that we keep _FLOCK_INIT() fast by slightly breaking our pthread
- * encapsulation.
- */
-#define _FLOCK_INIT(fp) _FLOCK(fp).value = __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE
-#define _FLOCK_LOCK(fp) pthread_mutex_lock(&_FLOCK(fp))
-#define _FLOCK_TRYLOCK(fp) pthread_mutex_trylock(&_FLOCK(fp))
-#define _FLOCK_UNLOCK(fp) pthread_mutex_unlock(&_FLOCK(fp))
-
#define _FILEEXT_SETUP(f, fext) \
do { \
(f)->_ext._base = (unsigned char *)(fext); \
+++ /dev/null
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
- *
- * from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp
- */
-
-#include <sys/cdefs.h>
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcslcpy.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
-#endif /* LIBC_SCCS and not lint */
-#endif
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <wchar.h>
-
-/*
- * Copy src to string dst of size siz. At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns wcslen(src); if retval >= siz, truncation occurred.
- */
-size_t
-wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
-{
- wchar_t *d = dst;
- const wchar_t *s = src;
- size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
--- /dev/null
+/* $OpenBSD: wcsxfrm.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */
+/* $OpenBSD: wcsxfrm.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */
+/* $NetBSD: multibyte_sb.c,v 1.4 2003/08/07 16:43:04 agc Exp $ */
+
+/*
+ * Copyright (c) 1991 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. 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 <wchar.h>
+
+size_t
+wcsxfrm(wchar_t *dest, const wchar_t *src, size_t n)
+{
+ if (n == 0)
+ return wcslen(src);
+ return wcslcpy(dest, src, n);
+}
* SUCH DAMAGE.
*/
+#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <string.h>
+#else
+#include <lib/libkern/libkern.h>
+#endif
+
+#if defined(APIWARN)
+__warn_references(strcpy,
+ "warning: strcpy() is almost always misused, please use strlcpy()");
+#endif
char *
strcpy(char *to, const char *from)
int
strncmp(const char *s1, const char *s2, size_t n)
{
+
if (n == 0)
return (0);
do {
--- /dev/null
+/* $OpenBSD: wcslcpy.c,v 1.5 2011/07/24 15:21:28 millert Exp $ */
+/* $NetBSD: wcslcpy.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <wchar.h>
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns wcslen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
+{
+ wchar_t *d = dst;
+ const wchar_t *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0) {
+ while (--n != 0) {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
--- /dev/null
+/* $OpenBSD: wcswidth.c,v 1.4 2011/04/04 18:16:24 stsp Exp $ */
+/* $NetBSD: wcswidth.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */
+
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * citrus Id: wcswidth.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
+ */
+
+#include <wchar.h>
+
+int
+wcswidth(const wchar_t *s, size_t n)
+{
+ int w, q;
+
+ w = 0;
+ while (n && *s) {
+ q = wcwidth(*s);
+ if (q == -1)
+ return (-1);
+ w += q;
+ s++;
+ n--;
+ }
+
+ return w;
+}
+++ /dev/null
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * This code is derived from software contributed to Berkeley by
- * Paul Borman at Krystal Technologies.
- *
- * 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.
- * 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>
-__FBSDID("$FreeBSD$");
-
-#include <wchar.h>
-
-int
-wcswidth(const wchar_t *pwcs, size_t n)
-{
- wchar_t wc;
- int len, l;
-
- len = 0;
- while (n-- > 0 && (wc = *pwcs++) != L'\0') {
- if ((l = wcwidth(wc)) < 0)
- return (-1);
- len += l;
- }
- return (len);
-}
-
+++ /dev/null
-/*-
- * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
- * at Electronni Visti IA, Kiev, Ukraine.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <wchar.h>
-
-/*
- * Placeholder wcsxfrm() implementation. See wcscoll.c for a description of
- * the logic used.
- */
-size_t
-wcsxfrm(wchar_t * __restrict dest, const wchar_t * __restrict src, size_t len)
-{
- int prim, sec, l;
- size_t slen;
- char *mbsrc, *s, *ss;
-
- if (*src == L'\0') {
- if (len != 0)
- *dest = L'\0';
- return (0);
- }
-
- slen = wcslen(src);
- if (len > 0) {
- if (slen < len)
- wcscpy(dest, src);
- else {
- wcsncpy(dest, src, len - 1);
- dest[len - 1] = L'\0';
- }
- }
- return (slen);
-}