diff options
author | das <das@FreeBSD.org> | 2009-02-28 06:00:58 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2009-02-28 06:00:58 +0000 |
commit | a67fbaa46cbdf18a03eefb3f83e2f74f68918753 (patch) | |
tree | f258384b92d5c4bde23e95d4c44fa3547a0364cd /include | |
parent | b739b3fb48f28ef6b6e7efeeceb832d3dec3fc9c (diff) | |
download | FreeBSD-src-a67fbaa46cbdf18a03eefb3f83e2f74f68918753.zip FreeBSD-src-a67fbaa46cbdf18a03eefb3f83e2f74f68918753.tar.gz |
- Add getdelim(), getline(), stpncpy(), strnlen(), wcsnlen(),
wcscasecmp(), and wcsncasecmp().
- Make some previously non-standard extensions visible
if POSIX_VISIBLE >= 200809.
- Use restrict qualifiers in stpcpy().
- Declare off_t and size_t in stdio.h.
- Bump __FreeBSD_version in case the new symbols (particularly
getline()) cause issues with ports.
Reviewed by: standards@
Diffstat (limited to 'include')
-rw-r--r-- | include/stdio.h | 39 | ||||
-rw-r--r-- | include/string.h | 12 | ||||
-rw-r--r-- | include/wchar.h | 10 |
3 files changed, 57 insertions, 4 deletions
diff --git a/include/stdio.h b/include/stdio.h index 674a5c2..cc870a8 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -51,6 +51,17 @@ typedef __size_t size_t; #define _SIZE_T_DECLARED #endif +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +#ifndef _OFF_T_DECLARED +#define _OFF_T_DECLARED +typedef __off_t off_t; +#endif +#ifndef _SSIZE_T_DECLARED +#define _SSIZE_T_DECLARED +typedef __ssize_t ssize_t; +#endif +#endif + #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE #ifndef _VA_LIST_DECLARED typedef __va_list va_list; @@ -330,6 +341,34 @@ int putw(int, FILE *); char *tempnam(const char *, const char *); #endif +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +ssize_t getdelim(char ** __restrict, size_t * __restrict, int, + FILE * __restrict); + +/* + * Every programmer and his dog wrote functions called getline() + * before POSIX.1-2008 came along and decided to usurp the name, so we + * don't prototype getline() by default unless one of the following is true: + * a) the app has requested it specifically by defining _WITH_GETLINE + * b) the app has requested a POSIX.1-2008 environment via _POSIX_C_SOURCE + * c) the app defines a GNUism such as _BSD_SOURCE or _GNU_SOURCE + */ +#ifndef _WITH_GETLINE +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +#define _WITH_GETLINE +#elif defined(_POSIX_C_SOURCE) +#if _POSIX_C_SOURCE > 200809 +#define _WITH_GETLINE +#endif +#endif +#endif + +#ifdef _WITH_GETLINE +ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict); +#endif + +#endif /* __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 */ + /* * Routines that are purely local. */ diff --git a/include/string.h b/include/string.h index 91007f1..5923cb5 100644 --- a/include/string.h +++ b/include/string.h @@ -67,8 +67,11 @@ void *memmem(const void *, size_t, const void *, size_t) __pure; #endif void *memmove(void *, const void *, size_t); void *memset(void *, int, size_t); +#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE +char *stpcpy(char * __restrict, const char * __restrict); +char *stpncpy(char * __restrict, const char * __restrict, size_t); +#endif #if __BSD_VISIBLE -char *stpcpy(char *, const char *); char *strcasestr(const char *, const char *) __pure; #endif char *strcat(char * __restrict, const char * __restrict); @@ -95,14 +98,19 @@ void strmode(int, char *); char *strncat(char * __restrict, const char * __restrict, size_t); int strncmp(const char *, const char *, size_t) __pure; char *strncpy(char * __restrict, const char * __restrict, size_t); -#if __BSD_VISIBLE +#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE char *strndup(const char *, size_t) __malloc_like; +size_t strnlen(const char *, size_t) __pure; +#endif +#if __BSD_VISIBLE char *strnstr(const char *, const char *, size_t) __pure; #endif char *strpbrk(const char *, const char *) __pure; char *strrchr(const char *, int) __pure; #if __BSD_VISIBLE char *strsep(char **, const char *); +#endif +#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE char *strsignal(int); #endif size_t strspn(const char *, const char *) __pure; diff --git a/include/wchar.h b/include/wchar.h index 4fc6c8c..f165a5b 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -210,13 +210,19 @@ int wcwidth(wchar_t); #define wcwidth(_c) __wcwidth(_c) #endif -#if __BSD_VISIBLE -wchar_t *fgetwln(struct __sFILE * __restrict, size_t * __restrict); +#if __POSIX_VISIBLE >= 200809 || __BSD_VISIBLE size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t, size_t, mbstate_t * __restrict); wchar_t *wcsdup(const wchar_t *) __malloc_like; +int wcscasecmp(const wchar_t *, const wchar_t *); +int wcsncasecmp(const wchar_t *, const wchar_t *, size_t n); +size_t wcsnlen(const wchar_t *, size_t) __pure; size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t, size_t, mbstate_t * __restrict); +#endif + +#if __BSD_VISIBLE +wchar_t *fgetwln(struct __sFILE * __restrict, size_t * __restrict); size_t wcslcat(wchar_t *, const wchar_t *, size_t); size_t wcslcpy(wchar_t *, const wchar_t *, size_t); #endif |