From 48ef7704c03e7e554c05de01bf8d1d70c16cb6f4 Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Wed, 20 Dec 2017 16:34:35 -0500 Subject: add libc building to agbcc. --- libc/ctype/_tolower.c | 9 ++++++++ libc/ctype/_toupper.c | 9 ++++++++ libc/ctype/ctype_.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ libc/ctype/isalnum.c | 46 ++++++++++++++++++++++++++++++++++++++ libc/ctype/isalpha.c | 44 ++++++++++++++++++++++++++++++++++++ libc/ctype/isascii.c | 43 +++++++++++++++++++++++++++++++++++ libc/ctype/iscntrl.c | 48 +++++++++++++++++++++++++++++++++++++++ libc/ctype/isdigit.c | 43 +++++++++++++++++++++++++++++++++++ libc/ctype/islower.c | 43 +++++++++++++++++++++++++++++++++++ libc/ctype/isprint.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ libc/ctype/ispunct.c | 46 ++++++++++++++++++++++++++++++++++++++ libc/ctype/isspace.c | 44 ++++++++++++++++++++++++++++++++++++ libc/ctype/isupper.c | 43 +++++++++++++++++++++++++++++++++++ libc/ctype/isxdigit.c | 45 +++++++++++++++++++++++++++++++++++++ libc/ctype/toascii.c | 41 ++++++++++++++++++++++++++++++++++ libc/ctype/tolower.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ libc/ctype/toupper.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 17 files changed, 735 insertions(+) create mode 100644 libc/ctype/_tolower.c create mode 100644 libc/ctype/_toupper.c create mode 100644 libc/ctype/ctype_.c create mode 100644 libc/ctype/isalnum.c create mode 100644 libc/ctype/isalpha.c create mode 100644 libc/ctype/isascii.c create mode 100644 libc/ctype/iscntrl.c create mode 100644 libc/ctype/isdigit.c create mode 100644 libc/ctype/islower.c create mode 100644 libc/ctype/isprint.c create mode 100644 libc/ctype/ispunct.c create mode 100644 libc/ctype/isspace.c create mode 100644 libc/ctype/isupper.c create mode 100644 libc/ctype/isxdigit.c create mode 100644 libc/ctype/toascii.c create mode 100644 libc/ctype/tolower.c create mode 100644 libc/ctype/toupper.c (limited to 'libc/ctype') diff --git a/libc/ctype/_tolower.c b/libc/ctype/_tolower.c new file mode 100644 index 0000000..968dcf7 --- /dev/null +++ b/libc/ctype/_tolower.c @@ -0,0 +1,9 @@ +#include <_ansi.h> +#include + +#undef _tolower +int +_DEFUN(_tolower,(c),int c) +{ + return isupper(c) ? (c) - 'A' + 'a' : c; +} diff --git a/libc/ctype/_toupper.c b/libc/ctype/_toupper.c new file mode 100644 index 0000000..db4e00d --- /dev/null +++ b/libc/ctype/_toupper.c @@ -0,0 +1,9 @@ +#include <_ansi.h> +#include + +#undef _toupper +int +_DEFUN(_toupper,(c),int c) +{ + return islower(c) ? c - 'a' + 'A' : c; +} diff --git a/libc/ctype/ctype_.c b/libc/ctype/ctype_.c new file mode 100644 index 0000000..45fcaa7 --- /dev/null +++ b/libc/ctype/ctype_.c @@ -0,0 +1,62 @@ +/* + * Copyright (c) 1989 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)ctype_.c 5.6 (Berkeley) 6/1/90"; +#endif /* LIBC_SCCS and not lint */ + +#include + +#if defined(__CYGWIN__) || defined(__CYGWIN32__) +_CONST char __declspec(dllexport) _ctype_[1 + 256] = { +#else +_CONST char _ctype_[1 + 256] = { +#endif + 0, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _C, _C, _C, _C, _C, _C, _C, _C, + _S|_B, _P, _P, _P, _P, _P, _P, _P, + _P, _P, _P, _P, _P, _P, _P, _P, + _N, _N, _N, _N, _N, _N, _N, _N, + _N, _N, _P, _P, _P, _P, _P, _P, + _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _U, _U, _U, _U, _U, + _U, _U, _U, _P, _P, _P, _P, _P, + _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _L, _L, _L, _L, _L, + _L, _L, _L, _P, _P, _P, _P, _C +}; diff --git a/libc/ctype/isalnum.c b/libc/ctype/isalnum.c new file mode 100644 index 0000000..7e05bd1 --- /dev/null +++ b/libc/ctype/isalnum.c @@ -0,0 +1,46 @@ +/* +FUNCTION + <>---alphanumeric character predicate + +INDEX + isalnum + +ANSI_SYNOPSIS + #include + int isalnum(int <[c]>); + +TRAD_SYNOPSIS + #include + int isalnum(<[c]>); + + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero for alphabetic or +numeric ASCII characters, and <<0>> for other arguments. It is defined +for all integer values. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef isalnum>>'. + +RETURNS +<> returns non-zero if <[c]> is a letter (<>--<> or +<>--<>) or a digit (<<0>>--<<9>>). + +PORTABILITY +<> is ANSI C. + +No OS subroutines are required. +*/ + +#include <_ansi.h> +#include + +#undef isalnum + +int +_DEFUN(isalnum,(c),int c) +{ + return((_ctype_ + 1)[c] & (_U|_L|_N)); +} + diff --git a/libc/ctype/isalpha.c b/libc/ctype/isalpha.c new file mode 100644 index 0000000..35f14d3 --- /dev/null +++ b/libc/ctype/isalpha.c @@ -0,0 +1,44 @@ +/* +FUNCTION + <>---alphabetic character predicate + +INDEX + isalpha + +ANSI_SYNOPSIS + #include + int isalpha(int <[c]>); + +TRAD_SYNOPSIS + #include + int isalpha(<[c]>); + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero when <[c]> represents an +alphabetic ASCII character, and 0 otherwise. It is defined only when +<>(<[c]>) is true or <[c]> is EOF. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef isalpha>>'. + +RETURNS +<> returns non-zero if <[c]> is a letter (<>--<> or +<>--<>). + +PORTABILITY +<> is ANSI C. + +No supporting OS subroutines are required. +*/ + +#include <_ansi.h> +#include + +#undef isalpha +int +_DEFUN(isalpha,(c),int c) +{ + return((_ctype_ + 1)[c] & (_U|_L)); +} + diff --git a/libc/ctype/isascii.c b/libc/ctype/isascii.c new file mode 100644 index 0000000..109fd3a --- /dev/null +++ b/libc/ctype/isascii.c @@ -0,0 +1,43 @@ +/* +FUNCTION + <>---ASCII character predicate + +INDEX + isascii + +ANSI_SYNOPSIS + #include + int isascii(int <[c]>); + +TRAD_SYNOPSIS + #include + int isascii(<[c]>); + +DESCRIPTION +<> is a macro which returns non-zero when <[c]> is an ASCII +character, and 0 otherwise. It is defined for all integer values. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef isascii>>'. + +RETURNS +<> returns non-zero if the low order byte of <[c]> is in the range +0 to 127 (<<0x00>>--<<0x7F>>). + +PORTABILITY +<> is ANSI C. + +No supporting OS subroutines are required. +*/ +#include <_ansi.h> +#include + + + +#undef isascii + +int +_DEFUN(isascii,(c),int c) +{ + return c >= 0 && c< 128; +} diff --git a/libc/ctype/iscntrl.c b/libc/ctype/iscntrl.c new file mode 100644 index 0000000..7b6da34 --- /dev/null +++ b/libc/ctype/iscntrl.c @@ -0,0 +1,48 @@ + +/* +FUNCTION + <>---control character predicate + +INDEX + iscntrl + +ANSI_SYNOPSIS + #include + int iscntrl(int <[c]>); + +TRAD_SYNOPSIS + #include + int iscntrl(<[c]>); + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero for control characters, and 0 +for other characters. It is defined only when <>(<[c]>) is +true or <[c]> is EOF. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef iscntrl>>'. + +RETURNS +<> returns non-zero if <[c]> is a delete character or ordinary +control character (<<0x7F>> or <<0x00>>--<<0x1F>>). + +PORTABILITY +<> is ANSI C. + +No supporting OS subroutines are required. +*/ + +#include <_ansi.h> +#include + + + +#undef iscntrl +int +_DEFUN(iscntrl,(c),int c) +{ + return((_ctype_ + 1)[c] & _C); +} + + diff --git a/libc/ctype/isdigit.c b/libc/ctype/isdigit.c new file mode 100644 index 0000000..5c21898 --- /dev/null +++ b/libc/ctype/isdigit.c @@ -0,0 +1,43 @@ +/* +FUNCTION +<>---decimal digit predicate + +INDEX +isdigit + +ANSI_SYNOPSIS +#include +int isdigit(int <[c]>); + +TRAD_SYNOPSIS +#include +int isdigit(<[c]>); + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero for decimal digits, and 0 for +other characters. It is defined only when <>(<[c]>) is true +or <[c]> is EOF. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef isdigit>>'. + +RETURNS +<> returns non-zero if <[c]> is a decimal digit (<<0>>--<<9>>). + +PORTABILITY +<> is ANSI C. + +No supporting OS subroutines are required. +*/ + +#include <_ansi.h> +#include + + +#undef isdigit +int +_DEFUN(isdigit,(c),int c) +{ + return((_ctype_ + 1)[c] & _N); +} diff --git a/libc/ctype/islower.c b/libc/ctype/islower.c new file mode 100644 index 0000000..81ad0bb --- /dev/null +++ b/libc/ctype/islower.c @@ -0,0 +1,43 @@ + +/* +FUNCTION +<>---lower-case character predicate + +INDEX +islower + +ANSI_SYNOPSIS +#include +int islower(int <[c]>); + +TRAD_SYNOPSIS +#include +int islower(<[c]>); + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero for minuscules +(lower-case alphabetic characters), and 0 for other characters. +It is defined only when <>(<[c]>) is true or <[c]> is EOF. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef islower>>'. + +RETURNS +<> returns non-zero if <[c]> is a lower case letter (<>--<>). + +PORTABILITY +<> is ANSI C. + +No supporting OS subroutines are required. +*/ +#include <_ansi.h> +#include + +#undef islower +int +_DEFUN(islower,(c),int c) +{ + return((_ctype_ + 1)[c] & _L); +} + diff --git a/libc/ctype/isprint.c b/libc/ctype/isprint.c new file mode 100644 index 0000000..2ff00f4 --- /dev/null +++ b/libc/ctype/isprint.c @@ -0,0 +1,60 @@ + +/* +FUNCTION + <>, <>---printable character predicates + +INDEX + isprint +INDEX + isgraph + +ANSI_SYNOPSIS + #include + int isprint(int <[c]>); + int isgraph(int <[c]>); + +TRAD_SYNOPSIS + #include + int isprint(<[c]>); + int isgraph(<[c]>); + + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero for printable +characters, and 0 for other character arguments. +It is defined only when <>(<[c]>) is true or <[c]> is EOF. + +You can use a compiled subroutine instead of the macro definition by +undefining either macro using `<<#undef isprint>>' or `<<#undef isgraph>>'. + +RETURNS +<> returns non-zero if <[c]> is a printing character, +(<<0x20>>--<<0x7E>>). +<> behaves identically to <>, except that the space +character (<<0x20>>) is excluded. + +PORTABILITY +<> and <> are ANSI C. + +No supporting OS subroutines are required. +*/ + +#include <_ansi.h> +#include + +#undef isgraph +int +_DEFUN(isgraph,(c),int c) +{ + return((_ctype_ + 1)[c] & (_P|_U|_L|_N)); +} + + +#undef isprint +int +_DEFUN(isprint,(c),int c) +{ + return((_ctype_ + 1)[c] & (_P|_U|_L|_N|_B)); +} + diff --git a/libc/ctype/ispunct.c b/libc/ctype/ispunct.c new file mode 100644 index 0000000..c567932 --- /dev/null +++ b/libc/ctype/ispunct.c @@ -0,0 +1,46 @@ + +/* +FUNCTION +<>---punctuation character predicate + +INDEX +ispunct + +ANSI_SYNOPSIS +#include +int ispunct(int <[c]>); + +TRAD_SYNOPSIS +#include +int ispunct(<[c]>); + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero for printable +punctuation characters, and 0 for other characters. It is defined +only when <>(<[c]>) is true or <[c]> is EOF. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef ispunct>>'. + +RETURNS +<> returns non-zero if <[c]> is a printable punctuation character +(<) && !isalnum(<[c]>)>>). + +PORTABILITY +<> is ANSI C. + +No supporting OS subroutines are required. +*/ + +#include <_ansi.h> +#include + + +#undef ispunct +int +_DEFUN(ispunct,(c),int c) +{ + return((_ctype_ + 1)[c] & _P); +} + diff --git a/libc/ctype/isspace.c b/libc/ctype/isspace.c new file mode 100644 index 0000000..1bc0798 --- /dev/null +++ b/libc/ctype/isspace.c @@ -0,0 +1,44 @@ + +/* +FUNCTION + <>---whitespace character predicate + +INDEX + isspace + +ANSI_SYNOPSIS + #include + int isspace(int <[c]>); + +TRAD_SYNOPSIS + #include + int isspace(<[c]>); + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero for whitespace +characters, and 0 for other characters. It is defined only when <>(<[c]>) is true or <[c]> is EOF. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef isspace>>'. + +RETURNS +<> returns non-zero if <[c]> is a space, tab, carriage return, new +line, vertical tab, or formfeed (<<0x09>>--<<0x0D>>, <<0x20>>). + +PORTABILITY +<> is ANSI C. + +No supporting OS subroutines are required. +*/ +#include <_ansi.h> +#include + + +#undef isspace +int +_DEFUN(isspace,(c),int c) +{ + return((_ctype_ + 1)[c] & _S); +} + diff --git a/libc/ctype/isupper.c b/libc/ctype/isupper.c new file mode 100644 index 0000000..8127e25 --- /dev/null +++ b/libc/ctype/isupper.c @@ -0,0 +1,43 @@ + +/* +FUNCTION +<>---uppercase character predicate + +INDEX +isupper + +ANSI_SYNOPSIS +#include +int isupper(int <[c]>); + +TRAD_SYNOPSIS +#include +int isupper(<[c]>); + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero for upper-case letters +(<>--<>), and 0 for other characters. It is defined only when +<>(<[c]>) is true or <[c]> is EOF. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef isupper>>'. + +RETURNS +<> returns non-zero if <[c]> is a upper case letter (A-Z). + +PORTABILITY +<> is ANSI C. + +No supporting OS subroutines are required. +*/ +#include <_ansi.h> +#include + +#undef isupper +int +_DEFUN(isupper,(c),int c) +{ + return((_ctype_ + 1)[c] & _U); +} + diff --git a/libc/ctype/isxdigit.c b/libc/ctype/isxdigit.c new file mode 100644 index 0000000..f8a035f --- /dev/null +++ b/libc/ctype/isxdigit.c @@ -0,0 +1,45 @@ + +/* +FUNCTION +<>---hexadecimal digit predicate + +INDEX +isxdigit + +ANSI_SYNOPSIS +#include +int isxdigit(int <[c]>); + +TRAD_SYNOPSIS +#include +int isxdigit(int <[c]>); + +DESCRIPTION +<> is a macro which classifies ASCII integer values by table +lookup. It is a predicate returning non-zero for hexadecimal digits, +and <<0>> for other characters. It is defined only when +<>(<[c]>) is true or <[c]> is EOF. + +You can use a compiled subroutine instead of the macro definition by +undefining the macro using `<<#undef isxdigit>>'. + +RETURNS +<> returns non-zero if <[c]> is a hexadecimal digit +(<<0>>--<<9>>, <>--<>, or <>--<>). + +PORTABILITY +<> is ANSI C. + +No supporting OS subroutines are required. +*/ +#include <_ansi.h> +#include + + +#undef isxdigit +int +_DEFUN(isxdigit,(c),int c) +{ + return((_ctype_ + 1)[c] & ((_X)|(_N))); +} + diff --git a/libc/ctype/toascii.c b/libc/ctype/toascii.c new file mode 100644 index 0000000..4506f35 --- /dev/null +++ b/libc/ctype/toascii.c @@ -0,0 +1,41 @@ +/* +FUNCTION + <>---force integers to ASCII range + +INDEX + toascii + +ANSI_SYNOPSIS + #include + int toascii(int <[c]>); + +TRAD_SYNOPSIS + #include + int toascii(<[c]>); + int (<[c]>); + +DESCRIPTION +<> is a macro which coerces integers to the ASCII range (0--127) by zeroing any higher-order bits. + +You can use a compiled subroutine instead of the macro definition by +undefining this macro using `<<#undef toascii>>'. + +RETURNS +<> returns integers between 0 and 127. + +PORTABILITY +<> is not ANSI C. + +No supporting OS subroutines are required. +*/ + +#include <_ansi.h> +#include +#undef toascii + +int +_DEFUN(toascii,(c),int c) +{ + return (c)&0177; +} + diff --git a/libc/ctype/tolower.c b/libc/ctype/tolower.c new file mode 100644 index 0000000..e43fa6c --- /dev/null +++ b/libc/ctype/tolower.c @@ -0,0 +1,55 @@ +/* +FUNCTION + <>---translate characters to lower case + +INDEX + tolower +INDEX + _tolower + +ANSI_SYNOPSIS + #include + int tolower(int <[c]>); + int _tolower(int <[c]>); + +TRAD_SYNOPSIS + #include + int tolower(<[c]>); + int _tolower(<[c]>); + + +DESCRIPTION +<> is a macro which converts upper-case characters to lower +case, leaving all other characters unchanged. It is only defined when +<[c]> is an integer in the range <> to <<255>>. + +You can use a compiled subroutine instead of the macro definition by +undefining this macro using `<<#undef tolower>>'. + +<<_tolower>> performs the same conversion as <>, but should +only be used when <[c]> is known to be an uppercase character (<>--<>). + +RETURNS +<> returns the lower-case equivalent of <[c]> when it is a +character between <> and <>, and <[c]> otherwise. + +<<_tolower>> returns the lower-case equivalent of <[c]> when it is a +character between <> and <>. If <[c]> is not one of these +characters, the behaviour of <<_tolower>> is undefined. + +PORTABILITY +<> is ANSI C. <<_tolower>> is not recommended for portable +programs. + +No supporting OS subroutines are required. +*/ + +#include <_ansi.h> +#include + +#undef tolower +int +_DEFUN(tolower,(c),int c) +{ + return isupper(c) ? (c) - 'A' + 'a' : c; +} diff --git a/libc/ctype/toupper.c b/libc/ctype/toupper.c new file mode 100644 index 0000000..7977beb --- /dev/null +++ b/libc/ctype/toupper.c @@ -0,0 +1,54 @@ +/* +FUNCTION + <>---translate characters to upper case + +INDEX + toupper +INDEX + _toupper + +ANSI_SYNOPSIS + #include + int toupper(int <[c]>); + int _toupper(int <[c]>); + +TRAD_SYNOPSIS + #include + int toupper(<[c]>); + int _toupper(<[c]>); + + +DESCRIPTION +<> is a macro which converts lower-case characters to upper +case, leaving all other characters unchanged. It is only defined when +<[c]> is an integer in the range <> to <<255>>. + +You can use a compiled subroutine instead of the macro definition by +undefining this macro using `<<#undef toupper>>'. + +<<_toupper>> performs the same conversion as <>, but should +only be used when <[c]> is known to be a lowercase character (<>--<>). + +RETURNS +<> returns the upper-case equivalent of <[c]> when it is a +character between <> and <>, and <[c]> otherwise. + +<<_toupper>> returns the upper-case equivalent of <[c]> when it is a +character between <> and <>. If <[c]> is not one of these +characters, the behaviour of <<_toupper>> is undefined. + +PORTABILITY +<> is ANSI C. <<_toupper>> is not recommended for portable programs. + +No supporting OS subroutines are required. +*/ + +#include <_ansi.h> +#include + +#undef toupper +int +_DEFUN(toupper,(c),int c) +{ + return islower(c) ? c - 'a' + 'A' : c; +} -- cgit v1.2.3