import from github

This commit is contained in:
2022-05-19 17:14:13 +00:00
parent 5247c34f50
commit ab32b30591
12612 changed files with 1905035 additions and 83 deletions

View File

@ -0,0 +1,9 @@
#include <_ansi.h>
#include <ctype.h>
#undef _tolower
int
_DEFUN(_tolower,(c),int c)
{
return isupper(c) ? (c) - 'A' + 'a' : c;
}

View File

@ -0,0 +1,9 @@
#include <_ansi.h>
#include <ctype.h>
#undef _toupper
int
_DEFUN(_toupper,(c),int c)
{
return islower(c) ? c - 'a' + 'A' : c;
}

62
agbcc/libc/ctype/ctype_.c Normal file
View File

@ -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 <ctype.h>
#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
};

View File

@ -0,0 +1,46 @@
/*
FUNCTION
<<isalnum>>---alphanumeric character predicate
INDEX
isalnum
ANSI_SYNOPSIS
#include <ctype.h>
int isalnum(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int isalnum(<[c]>);
DESCRIPTION
<<isalnum>> 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
<<isalnum>> returns non-zero if <[c]> is a letter (<<a>>--<<z>> or
<<A>>--<<Z>>) or a digit (<<0>>--<<9>>).
PORTABILITY
<<isalnum>> is ANSI C.
No OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef isalnum
int
_DEFUN(isalnum,(c),int c)
{
return((_ctype_ + 1)[c] & (_U|_L|_N));
}

View File

@ -0,0 +1,44 @@
/*
FUNCTION
<<isalpha>>---alphabetic character predicate
INDEX
isalpha
ANSI_SYNOPSIS
#include <ctype.h>
int isalpha(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int isalpha(<[c]>);
DESCRIPTION
<<isalpha>> 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
<<isascii>>(<[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
<<isalpha>> returns non-zero if <[c]> is a letter (<<A>>--<<Z>> or
<<a>>--<<z>>).
PORTABILITY
<<isalpha>> is ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef isalpha
int
_DEFUN(isalpha,(c),int c)
{
return((_ctype_ + 1)[c] & (_U|_L));
}

View File

@ -0,0 +1,43 @@
/*
FUNCTION
<<isascii>>---ASCII character predicate
INDEX
isascii
ANSI_SYNOPSIS
#include <ctype.h>
int isascii(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int isascii(<[c]>);
DESCRIPTION
<<isascii>> 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
<<isascii>> returns non-zero if the low order byte of <[c]> is in the range
0 to 127 (<<0x00>>--<<0x7F>>).
PORTABILITY
<<isascii>> is ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef isascii
int
_DEFUN(isascii,(c),int c)
{
return c >= 0 && c< 128;
}

View File

@ -0,0 +1,48 @@
/*
FUNCTION
<<iscntrl>>---control character predicate
INDEX
iscntrl
ANSI_SYNOPSIS
#include <ctype.h>
int iscntrl(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int iscntrl(<[c]>);
DESCRIPTION
<<iscntrl>> 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 <<isascii>>(<[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
<<iscntrl>> returns non-zero if <[c]> is a delete character or ordinary
control character (<<0x7F>> or <<0x00>>--<<0x1F>>).
PORTABILITY
<<iscntrl>> is ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef iscntrl
int
_DEFUN(iscntrl,(c),int c)
{
return((_ctype_ + 1)[c] & _C);
}

View File

@ -0,0 +1,43 @@
/*
FUNCTION
<<isdigit>>---decimal digit predicate
INDEX
isdigit
ANSI_SYNOPSIS
#include <ctype.h>
int isdigit(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int isdigit(<[c]>);
DESCRIPTION
<<isdigit>> 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 <<isascii>>(<[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
<<isdigit>> returns non-zero if <[c]> is a decimal digit (<<0>>--<<9>>).
PORTABILITY
<<isdigit>> is ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef isdigit
int
_DEFUN(isdigit,(c),int c)
{
return((_ctype_ + 1)[c] & _N);
}

View File

@ -0,0 +1,43 @@
/*
FUNCTION
<<islower>>---lower-case character predicate
INDEX
islower
ANSI_SYNOPSIS
#include <ctype.h>
int islower(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int islower(<[c]>);
DESCRIPTION
<<islower>> 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 <<isascii>>(<[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
<<islower>> returns non-zero if <[c]> is a lower case letter (<<a>>--<<z>>).
PORTABILITY
<<islower>> is ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef islower
int
_DEFUN(islower,(c),int c)
{
return((_ctype_ + 1)[c] & _L);
}

View File

@ -0,0 +1,60 @@
/*
FUNCTION
<<isprint>>, <<isgraph>>---printable character predicates
INDEX
isprint
INDEX
isgraph
ANSI_SYNOPSIS
#include <ctype.h>
int isprint(int <[c]>);
int isgraph(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int isprint(<[c]>);
int isgraph(<[c]>);
DESCRIPTION
<<isprint>> 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 <<isascii>>(<[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
<<isprint>> returns non-zero if <[c]> is a printing character,
(<<0x20>>--<<0x7E>>).
<<isgraph>> behaves identically to <<isprint>>, except that the space
character (<<0x20>>) is excluded.
PORTABILITY
<<isprint>> and <<isgraph>> are ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#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));
}

View File

@ -0,0 +1,46 @@
/*
FUNCTION
<<ispunct>>---punctuation character predicate
INDEX
ispunct
ANSI_SYNOPSIS
#include <ctype.h>
int ispunct(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int ispunct(<[c]>);
DESCRIPTION
<<ispunct>> 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 <<isascii>>(<[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
<<ispunct>> returns non-zero if <[c]> is a printable punctuation character
(<<isgraph(<[c]>) && !isalnum(<[c]>)>>).
PORTABILITY
<<ispunct>> is ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef ispunct
int
_DEFUN(ispunct,(c),int c)
{
return((_ctype_ + 1)[c] & _P);
}

View File

@ -0,0 +1,44 @@
/*
FUNCTION
<<isspace>>---whitespace character predicate
INDEX
isspace
ANSI_SYNOPSIS
#include <ctype.h>
int isspace(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int isspace(<[c]>);
DESCRIPTION
<<isspace>> 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 <<isascii>>(<[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
<<isspace>> returns non-zero if <[c]> is a space, tab, carriage return, new
line, vertical tab, or formfeed (<<0x09>>--<<0x0D>>, <<0x20>>).
PORTABILITY
<<isspace>> is ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef isspace
int
_DEFUN(isspace,(c),int c)
{
return((_ctype_ + 1)[c] & _S);
}

View File

@ -0,0 +1,43 @@
/*
FUNCTION
<<isupper>>---uppercase character predicate
INDEX
isupper
ANSI_SYNOPSIS
#include <ctype.h>
int isupper(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int isupper(<[c]>);
DESCRIPTION
<<isupper>> is a macro which classifies ASCII integer values by table
lookup. It is a predicate returning non-zero for upper-case letters
(<<A>>--<<Z>>), and 0 for other characters. It is defined only when
<<isascii>>(<[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
<<isupper>> returns non-zero if <[c]> is a upper case letter (A-Z).
PORTABILITY
<<isupper>> is ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef isupper
int
_DEFUN(isupper,(c),int c)
{
return((_ctype_ + 1)[c] & _U);
}

View File

@ -0,0 +1,45 @@
/*
FUNCTION
<<isxdigit>>---hexadecimal digit predicate
INDEX
isxdigit
ANSI_SYNOPSIS
#include <ctype.h>
int isxdigit(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int isxdigit(int <[c]>);
DESCRIPTION
<<isxdigit>> 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
<<isascii>>(<[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
<<isxdigit>> returns non-zero if <[c]> is a hexadecimal digit
(<<0>>--<<9>>, <<a>>--<<f>>, or <<A>>--<<F>>).
PORTABILITY
<<isxdigit>> is ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef isxdigit
int
_DEFUN(isxdigit,(c),int c)
{
return((_ctype_ + 1)[c] & ((_X)|(_N)));
}

View File

@ -0,0 +1,41 @@
/*
FUNCTION
<<toascii>>---force integers to ASCII range
INDEX
toascii
ANSI_SYNOPSIS
#include <ctype.h>
int toascii(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int toascii(<[c]>);
int (<[c]>);
DESCRIPTION
<<toascii>> 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
<<toascii>> returns integers between 0 and 127.
PORTABILITY
<<toascii>> is not ANSI C.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef toascii
int
_DEFUN(toascii,(c),int c)
{
return (c)&0177;
}

View File

@ -0,0 +1,55 @@
/*
FUNCTION
<<tolower>>---translate characters to lower case
INDEX
tolower
INDEX
_tolower
ANSI_SYNOPSIS
#include <ctype.h>
int tolower(int <[c]>);
int _tolower(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int tolower(<[c]>);
int _tolower(<[c]>);
DESCRIPTION
<<tolower>> 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 <<EOF>> 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 <<tolower>>, but should
only be used when <[c]> is known to be an uppercase character (<<A>>--<<Z>>).
RETURNS
<<tolower>> returns the lower-case equivalent of <[c]> when it is a
character between <<A>> and <<Z>>, and <[c]> otherwise.
<<_tolower>> returns the lower-case equivalent of <[c]> when it is a
character between <<A>> and <<Z>>. If <[c]> is not one of these
characters, the behaviour of <<_tolower>> is undefined.
PORTABILITY
<<tolower>> is ANSI C. <<_tolower>> is not recommended for portable
programs.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef tolower
int
_DEFUN(tolower,(c),int c)
{
return isupper(c) ? (c) - 'A' + 'a' : c;
}

View File

@ -0,0 +1,54 @@
/*
FUNCTION
<<toupper>>---translate characters to upper case
INDEX
toupper
INDEX
_toupper
ANSI_SYNOPSIS
#include <ctype.h>
int toupper(int <[c]>);
int _toupper(int <[c]>);
TRAD_SYNOPSIS
#include <ctype.h>
int toupper(<[c]>);
int _toupper(<[c]>);
DESCRIPTION
<<toupper>> 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 <<EOF>> 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 <<toupper>>, but should
only be used when <[c]> is known to be a lowercase character (<<a>>--<<z>>).
RETURNS
<<toupper>> returns the upper-case equivalent of <[c]> when it is a
character between <<a>> and <<z>>, and <[c]> otherwise.
<<_toupper>> returns the upper-case equivalent of <[c]> when it is a
character between <<a>> and <<z>>. If <[c]> is not one of these
characters, the behaviour of <<_toupper>> is undefined.
PORTABILITY
<<toupper>> is ANSI C. <<_toupper>> is not recommended for portable programs.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <ctype.h>
#undef toupper
int
_DEFUN(toupper,(c),int c)
{
return islower(c) ? c - 'a' + 'A' : c;
}