Browse Source

POSIX says that ffs(), strcasecmp(), strncasecmp(), r?index() and

the b* byte functions belong in strings.h, not string.h so break
them out of string.h into a new strings.h.  As long as there is no
POSIX or X/OPEN define in use string.h will pull in strings.h.
OK naddy@ deraadt@
OPENBSD_5_9
millert 9 years ago
parent
commit
8c8787aac5
2 changed files with 49 additions and 18 deletions
  1. +9
    -15
      src/include/string.h
  2. +40
    -3
      src/include/strings.h

+ 9
- 15
src/include/string.h View File

@ -1,4 +1,4 @@
/* $OpenBSD: string.h,v 1.29 2014/08/10 02:49:24 guenther Exp $ */
/* $OpenBSD: string.h,v 1.30 2015/11/20 23:40:32 millert Exp $ */
/* $NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $ */
/*-
@ -38,6 +38,14 @@
#include <sys/cdefs.h>
#include <machine/_types.h>
/*
* POSIX mandates that certain string functions not present in ISO C
* be prototyped in strings.h. Historically, we've included them here.
*/
#if __BSD_VISIBLE
#include <strings.h>
#endif
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef __size_t size_t;
@ -91,20 +99,6 @@ void *memccpy(void *__restrict, const void *__restrict, int, size_t)
__attribute__ ((__bounded__(__buffer__,1,4)));
#endif
#if __XPG_VISIBLE >= 420
int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t)
__attribute__ ((__bounded__(__buffer__,1,3)))
__attribute__ ((__bounded__(__buffer__,2,3)));
void bzero(void *, size_t)
__attribute__ ((__bounded__(__buffer__,1,2)));
int ffs(int);
char *index(const char *, int);
char *rindex(const char *, int);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
#endif
#if __POSIX_VISIBLE >= 200112
int strerror_r(int, char *, size_t)
__attribute__ ((__bounded__(__string__,2,3)));


+ 40
- 3
src/include/strings.h View File

@ -1,5 +1,4 @@
/* $OpenBSD: strings.h,v 1.3 2003/06/02 19:34:12 millert Exp $ */
/* $NetBSD: strings.h,v 1.3 1994/10/26 00:56:31 cgd Exp $ */
/* $OpenBSD: strings.h,v 1.4 2015/11/20 23:40:32 millert Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@ -32,4 +31,42 @@
* @(#)strings.h 5.8 (Berkeley) 5/15/90
*/
#include <string.h>
#ifndef _STRINGS_H_
#define _STRINGS_H_
#include <sys/cdefs.h>
#include <machine/_types.h>
/*
* POSIX mandates that certain string functions not present in ISO C
* be prototyped in strings.h.
*/
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef __size_t size_t;
#endif
__BEGIN_DECLS
#if __BSD_VISIBLE || (__XPG_VISIBLE >= 420 && __POSIX_VISIBLE <= 200112)
/*
* The following functions were removed from IEEE Std 1003.1-2008
*/
int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t)
__attribute__ ((__bounded__(__buffer__,1,3)))
__attribute__ ((__bounded__(__buffer__,2,3)));
void bzero(void *, size_t)
__attribute__ ((__bounded__(__buffer__,1,2)));
char *index(const char *, int);
char *rindex(const char *, int);
#endif
#if __XPG_VISIBLE >= 420
int ffs(int);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, size_t);
#endif
__END_DECLS
#endif /* _STRINGS_H_ */

Loading…
Cancel
Save