[tyndur-devel] [PATCH] libc: ctype.h standardkonformer
Kevin Wolf ·
! libc: Funktionen nur als static inline im Header anbieten ist nicht erlaubt, man muss auch dagegen linken können Signed-off-by: Kevin Wolf <kevin at tyndur.org> --- src/include/ctype.h | 85 ++++++++------------------------------------ src/lib/ctype.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 70 deletions(-) create mode 100644 src/lib/ctype.c diff --git a/src/include/ctype.h b/src/include/ctype.h index 817bedb..f777511 100644 --- a/src/include/ctype.h +++ b/src/include/ctype.h @@ -29,75 +29,20 @@ #ifndef _CTYPE_H_ #define _CTYPE_H_ -static inline int isprint(int c) -{ - return (c >= 0x20); -} - -static inline int iscntrl(int c) -{ - return (c < 0x20); -} - -static inline int isspace(int c) -{ - return (c == ' ' || c== '\n' || c == '\t' || c == '\r'); -} - -static inline int isblank(int c) -{ - return (c == ' ' ||c == '\t'); -} - -static inline int isdigit(int c) -{ - return (c >= '0' && c <= '9'); -} - -static inline int isalpha(int c) -{ - return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); -} - -static inline int isalnum(int c) -{ - return (isdigit(c) || isalpha(c)); -} - -static inline int isxdigit(int c) -{ - return (isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); -} - -static inline int isupper(int c) -{ - return (c >= 'A' && c <= 'Z'); -} - -static inline int islower(int c) -{ - return (c >= 'a' && c <= 'z'); -} - -static inline int ispunct(int c) -{ - return (isprint(c) && !isspace(c) && !isalpha(c)); -} - -static inline int isgraph(int c) -{ - return (isprint(c) && !isspace(c)); -} - - -static inline int tolower(int c) -{ - return isupper(c) ? c + ('a' - 'A') : c; -} - -static inline int toupper(int c) -{ - return islower(c) ? c - ('a' - 'A') : c; -} +int isprint(int c); +int iscntrl(int c); +int isspace(int c); +int isblank(int c); +int isdigit(int c); +int isalpha(int c); +int isalnum(int c); +int isxdigit(int c); +int isupper(int c); +int islower(int c); +int ispunct(int c); +int isgraph(int c); + +int tolower(int c); +int toupper(int c); #endif /* ndef CTYPE_H */ diff --git a/src/lib/ctype.c b/src/lib/ctype.c new file mode 100644 index 0000000..d1e2928 --- /dev/null +++ b/src/lib/ctype.c @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2006-2010 The tyndur Project. All rights reserved. + * + * This code is derived from software contributed to the tyndur Project + * by Burkhard Weseloh. + * + * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDERS 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 <ctype.h> + +int isprint(int c) +{ + return (c >= 0x20); +} + +int iscntrl(int c) +{ + return (c < 0x20); +} + +int isspace(int c) +{ + return (c == ' ' || c== '\n' || c == '\t' || c == '\r'); +} + +int isblank(int c) +{ + return (c == ' ' ||c == '\t'); +} + +int isdigit(int c) +{ + return (c >= '0' && c <= '9'); +} + +int isalpha(int c) +{ + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); +} + +int isalnum(int c) +{ + return (isdigit(c) || isalpha(c)); +} + +int isxdigit(int c) +{ + return (isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')); +} + +int isupper(int c) +{ + return (c >= 'A' && c <= 'Z'); +} + +int islower(int c) +{ + return (c >= 'a' && c <= 'z'); +} + +int ispunct(int c) +{ + return (isprint(c) && !isspace(c) && !isalpha(c)); +} + +int isgraph(int c) +{ + return (isprint(c) && !isspace(c)); +} + +int tolower(int c) +{ + return isupper(c) ? c + ('a' - 'A') : c; +} + +int toupper(int c) +{ + return islower(c) ? c - ('a' - 'A') : c; +} -- 1.6.0.2
Antworten
- [tyndur-devel] [PATCH] libc: ctype.h standardkonformer · Alexander Siol