diff options
-rw-r--r-- | src/ctype/_tolower.c | 13 | ||||
-rw-r--r-- | src/ctype/_toupper.c | 13 | ||||
-rw-r--r-- | src/ctype/isalnum.c | 8 | ||||
-rw-r--r-- | src/ctype/isalpha.c | 7 | ||||
-rw-r--r-- | src/ctype/isascii.c | 14 | ||||
-rw-r--r-- | src/ctype/isblank.c | 27 | ||||
-rw-r--r-- | src/ctype/iscntrl.c | 11 | ||||
-rw-r--r-- | src/ctype/isdigit.c | 7 | ||||
-rw-r--r-- | src/ctype/isgraph.c | 7 | ||||
-rw-r--r-- | src/ctype/islower.c | 8 | ||||
-rw-r--r-- | src/ctype/isprint.c | 7 | ||||
-rw-r--r-- | src/ctype/ispunct.c | 7 | ||||
-rw-r--r-- | src/ctype/isspace.c | 7 | ||||
-rw-r--r-- | src/ctype/isupper.c | 7 | ||||
-rw-r--r-- | src/ctype/isxdigit.c | 8 | ||||
-rw-r--r-- | src/ctype/toascii.c | 14 | ||||
-rw-r--r-- | src/ctype/tolower.c | 7 | ||||
-rw-r--r-- | src/ctype/toupper.c | 7 |
18 files changed, 89 insertions, 90 deletions
diff --git a/src/ctype/_tolower.c b/src/ctype/_tolower.c index dc3ad0ae..2e656b6e 100644 --- a/src/ctype/_tolower.c +++ b/src/ctype/_tolower.c @@ -1,6 +1,19 @@ #include <ctype.h> + +/** convert an uppercase letter to lowercase **/ + #define _tolower(c) tolower(c) +/*** +converts an uppercase letter to its equivalent lowercase letter in the current +locale. +***/ + /* +ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF) +RETURN_SUCCESS(ARGUMENT(c) converted to uppercase) +UNDEFINED(ARGUMENT(c) is not an upper-case letter) +LC_CTYPE XOPEN(4) +XOBSOLETE(700, FUNCTION(tolower)) */ diff --git a/src/ctype/_toupper.c b/src/ctype/_toupper.c index d1cdc9b4..7c284981 100644 --- a/src/ctype/_toupper.c +++ b/src/ctype/_toupper.c @@ -1,6 +1,19 @@ #include <ctype.h> + +/** convert a lowercase letter to uppercase **/ + #define _toupper(c) toupper(c) +/*** +converts a lowercase letter to its equivalent uppercase letter in the current +locale. +***/ + /* +ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF) +RETURN_SUCCESS(ARGUMENT(c) converted to uppercase) +UNDEFINED(ARGUMENT(c) is not a lowercase letter) +LC_CTYPE XOPEN(4) +XOBSOLETE(700, FUNCTION(toupper)) */ diff --git a/src/ctype/isalnum.c b/src/ctype/isalnum.c index 507655ae..6b0d7388 100644 --- a/src/ctype/isalnum.c +++ b/src/ctype/isalnum.c @@ -3,13 +3,10 @@ #include "nonstd/assert.h" /** test whether a character is alphanumeric **/ + int isalnum(int c) { ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is an alpanumeric character); - RETURN(0, ARGUMENT(c) is not an alphanumeric character); - */ return isalpha(c) || isdigit(c); } @@ -17,7 +14,10 @@ int isalnum(int c) tests whether ARGUMENT(c) is a character in the class CHARACTER_CLASS(alpha) or CHARACTER_CLASS(digit) in the current locale. ***/ + /* +RETURN(NONZERO, ARGUMENT(c) is an alpanumeric character) +RETURN(0, ARGUMENT(c) is not an alphanumeric character) LC_CTYPE STDC(1) */ diff --git a/src/ctype/isalpha.c b/src/ctype/isalpha.c index 2b893425..c399dc1c 100644 --- a/src/ctype/isalpha.c +++ b/src/ctype/isalpha.c @@ -3,13 +3,10 @@ #include "nonstd/assert.h" /** test whether a character is alphabetic **/ + int isalpha(int c) { ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is an alphabetic character) - RETURN(0, ARGUMENT(c) is not an alphabetic character) - */ return islower(c) || isupper(c); } @@ -19,6 +16,8 @@ CHARACTER_CLASS(alpha) in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is an alphabetic character) +RETURN(0, ARGUMENT(c) is not an alphabetic character) LC_CTYPE C_LOCALE(`THIS() is true for characters for which FUNCTION(isupper) or FUNCTION(islower) is true') OTHER_LOCALES(`THIS is true for a set of characters for which none of FUNCTION(iscntrl), FUNCTION(isdigit), FUNCTION(ispunct), or FUNCTION(isspace) is true') diff --git a/src/ctype/isascii.c b/src/ctype/isascii.c index 30fc5a1f..fc0067d7 100644 --- a/src/ctype/isascii.c +++ b/src/ctype/isascii.c @@ -1,6 +1,7 @@ #include <ctype.h> /** test whether a character is in the ASCII range **/ + int isascii(int c) { if (0 <= c && c <= 0177) { @@ -10,17 +11,12 @@ int isascii(int c) } /*** -The fn(isascii) function tests whether arg(c) is a 7-bit US-ASCII character. +tests whether ARGUMENT(c) is a 7-bit US-ASCII character. ***/ -/* RETURN(NZ): arg(c) is between 0 and octal 0177 inclusive */ -/* RETURN(0): arg(c) is outside of the ASCII range */ - -/* UNDEFINED: - */ -/* UNSPECIFIED: - */ -/* IMPLEMENTATION: - */ -/* LOCALE: - */ - /* +RETURN(NONZERO, ARGUMENT(c) is between 0 and octal 0177 inclusive) +RETURN(ZERO, ARGUMENT(c) is outside of the ASCII range) +XOBSOLETE(700) XOPEN(4) */ diff --git a/src/ctype/isblank.c b/src/ctype/isblank.c index 2b48b67f..3693bc97 100644 --- a/src/ctype/isblank.c +++ b/src/ctype/isblank.c @@ -5,34 +5,27 @@ #include "nonstd/assert.h" /** test whether a character is blank **/ + int isblank(int c) { - ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, "unsigned char", EOF); - unsigned int *map = __libc(CTYPE); + ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, "unsigned char", EOF); + return map[c] & CT_BLANK; } /*** -The fn(isblank) functions tests whether a character is a of the character -class cclass(blank) in the current locale. - -In the locale(C) and locale(POSIX) locales, only the standard blank characters -space (char( )) horizontal tab (char(\t)) are blank. - -In other locales, fn(isblank) will return true for the standard blank characters -as well as other characters for which fn(isspace) is true and the character is -used to separate words on a line a text. +tests whether a character is a of the character class CCLASS(blank) in the +current locale. ***/ -/* RETURN(NZ): arg(c) is a blank character */ -/* RETURN(0): arg(c) is not a blank character */ - -/* UNSPECIFIED: - */ -/* IMPLEMENTATION: - */ -/* LOCALE: LC_CTYPE */ /* +C_LOCALE(only space (CHAR( )) and tab (CHAR(\t)) are blank) +OTHER_LOCALES(true for space (CHAR( )), tab (CHAR(\t)), and characters for which FUNCTION(isspace) is true and are used to separate words) +RETURN(NONZERO, arg(c) is a blank character) +RETURN(ZERO, arg(c) is not a blank character) +LC_CTYPE STDC(199901) */ diff --git a/src/ctype/iscntrl.c b/src/ctype/iscntrl.c index 9d295d26..1508f318 100644 --- a/src/ctype/iscntrl.c +++ b/src/ctype/iscntrl.c @@ -4,25 +4,24 @@ #include "nonstd/ctype.h" /** test whether a character is a control character */ + int iscntrl(int c) { unsigned int *map = __libc(CTYPE); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is a control character); - RETURN(0, ARGUMENT(c) is not a control character); - */ return map[c] & CT_CNTRL; } /*** -tests whether ARGUMENT(c) is a character in the class CHARACTER_CLASS(cntrl) in the -current locale. +tests whether ARGUMENT(c) is a character in the class CHARACTER_CLASS(cntrl) +in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is a control character) +RETURN(0, ARGUMENT(c) is not a control character) LC_CTYPE STDC(1) */ diff --git a/src/ctype/isdigit.c b/src/ctype/isdigit.c index 7a19fe19..f4f80c1b 100644 --- a/src/ctype/isdigit.c +++ b/src/ctype/isdigit.c @@ -3,13 +3,10 @@ #include "nonstd/assert.h" /** test whether a character is a digit **/ + int isdigit(int c) { ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is a digit); - RETURN(0, ARGUMENT(c) is not a digit); - */ return isxdigit(c) && !isalpha(c); } @@ -20,6 +17,8 @@ in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is a digit) +RETURN(0, ARGUMENT(c) is not a digit) LC_CTYPE C_LOCALE(`THIS() is true for characters CHAR(0), CHAR(1), CHAR(2), CHAR(3), CHAR(4), CHAR(5), CHAR(6), CHAR(7), CHAR(8), and CHAR(9)') STDC(1) diff --git a/src/ctype/isgraph.c b/src/ctype/isgraph.c index ecf88a34..7f3f0bad 100644 --- a/src/ctype/isgraph.c +++ b/src/ctype/isgraph.c @@ -4,15 +4,12 @@ #include "nonstd/ctype.h" /** test whether a character is graphic **/ + int isgraph(int c) { unsigned int *map = __libc(CTYPE); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is a graphic character); - RETURN(0, ARGUMENT(c) is not a graphic character); - */ return map[c] & CT_GRAPH; } @@ -23,6 +20,8 @@ in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is a graphic character) +RETURN(0, ARGUMENT(c) is not a graphic character) LC_CTYPE C_LOCALE(`THIS() is true for all printable characters other than SPACE()') STDC(1) diff --git a/src/ctype/islower.c b/src/ctype/islower.c index 6b4764d8..c08522a1 100644 --- a/src/ctype/islower.c +++ b/src/ctype/islower.c @@ -4,15 +4,13 @@ #include "nonstd/ctype.h" /** test whether a character is a lowercase letter **/ + int islower(int c) { unsigned int *map = __libc(CTYPE); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is a lowercase letter); - RETURN(0, ARGUMENT(c) is not a lowercase letter); - */ + return map[c] & CT_LOWER; } @@ -22,6 +20,8 @@ in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is a lowercase letter) +RETURN(0, ARGUMENT(c) is not a lowercase letter) LC_CTYPE C_LOCALE(`THIS() is true for the characters CHAR(a), CHAR(b), CHAR(c), CHAR(d), CHAR(e), CHAR(f), CHAR(g), CHAR(h), CHAR(i), CHAR(j), CHAR(k), CHAR(l), CHAR(m), CHAR(n), CHAR(o), CHAR(p), CHAR(q), CHAR(s), CHAR(t), CHAR(u), CHAR(w), CHAR(x), CHAR(y), and CHAR(z)') OTHER_LOCALES(`THIS() is true for a set of characters for which none of FUNCTION(iscntrl), FUNCTION(isdigit), FUNCTION(ispunct), or FUNCTION(isspace) is true') diff --git a/src/ctype/isprint.c b/src/ctype/isprint.c index 41ed6bcf..a71c6173 100644 --- a/src/ctype/isprint.c +++ b/src/ctype/isprint.c @@ -4,15 +4,12 @@ #include "nonstd/ctype.h" /** test whether a character is printable **/ + int isprint(int c) { unsigned int *map = __libc(CTYPE); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is a printable character); - RETURN(0, ARGUMENT(c) is not a printable character); - */ return map[c] & CT_PRINT; } @@ -23,6 +20,8 @@ in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is a printable character) +RETURN(0, ARGUMENT(c) is not a printable character) LC_CTYPE C_LOCALE(`THIS() is true for any printing character including SPACE()') STDC(1) diff --git a/src/ctype/ispunct.c b/src/ctype/ispunct.c index 8a0cd118..f092682f 100644 --- a/src/ctype/ispunct.c +++ b/src/ctype/ispunct.c @@ -4,15 +4,12 @@ #include "nonstd/ctype.h" /** test whether a character is punctuation **/ + int ispunct(int c) { unsigned int *map = __libc(CTYPE); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is a punctuation character); - RETURN(0, ARGUMENT(c) is not a punctuation character); - */ return map[c] & CT_PUNCT; } @@ -23,6 +20,8 @@ in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is a punctuation character) +RETURN(0, ARGUMENT(c) is not a punctuation character) LC_CTYPE C_LOCALE(`THIS() is true for printing characters for which neither FUNCTION(isspace) nor FUNCTION(isalnum) is true') STDC(1) diff --git a/src/ctype/isspace.c b/src/ctype/isspace.c index 79aa9673..8b8d6d09 100644 --- a/src/ctype/isspace.c +++ b/src/ctype/isspace.c @@ -4,15 +4,12 @@ #include "nonstd/ctype.h" /** test whether a character is white-space **/ + int isspace(int c) { unsigned int *map = __libc(CTYPE); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is a white-space character); - RETURN(0, ARGUMENT(c) is not a white-space character); - */ return map[c] & CT_SPACE; } @@ -23,6 +20,8 @@ in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is a white-space character) +RETURN(0, ARGUMENT(c) is not a white-space character) LC_CTYPE C_LOCALE(`THIS() is true for the standard white-space characters: SPACE, form feed (CHAR(\f)), new-line (CHAR(\n)), carriage return (CHAR(\r)), horizontal tab (CHAR(\t)), and vertical tab (CHAR(\v))') OTHER_LOCALES(`THIS() is true for the standard white-space characters and a set of characters for which FUNCTION(isalnum) is false') diff --git a/src/ctype/isupper.c b/src/ctype/isupper.c index 0d3e7240..9e9910e8 100644 --- a/src/ctype/isupper.c +++ b/src/ctype/isupper.c @@ -4,15 +4,12 @@ #include "nonstd/ctype.h" /** test whether a character is an uppercase letter **/ + int isupper(int c) { unsigned int *map = __libc(CTYPE); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is an uppercase letter); - RETURN(0, ARGUMENT(c) is not an uppercase letter); - */ return map[c] & CT_UPPER; } @@ -23,6 +20,8 @@ in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is an uppercase letter) +RETURN(0, ARGUMENT(c) is not an uppercase letter) LC_CTYPE C_LOCALE(`THIS() is true for the characters CHAR(A), CHAR(B), CHAR(C), CHAR(D), CHAR(E), CHAR(F), CHAR(G), CHAR(H), CHAR(I), CHAR(J), CHAR(K), CHAR(L), CHAR(M), CHAR(N), CHAR(O), CHAR(P), CHAR(Q), CHAR(S), CHAR(T), CHAR(U), CHAR(W), CHAR(X), CHAR(Y), and CHAR(Z)') OTHER_LOCALES(`THIS() is true for a set of characters for which none of FUNCTION(iscntrl), FUNCTION(isdigit), FUNCTION(ispunct), or FUNCTION(isspace) is true') diff --git a/src/ctype/isxdigit.c b/src/ctype/isxdigit.c index 30ddd618..a17657fa 100644 --- a/src/ctype/isxdigit.c +++ b/src/ctype/isxdigit.c @@ -4,15 +4,13 @@ #include "nonstd/ctype.h" /** test whether a character is a hexadecimal digit **/ + int isxdigit(int c) { unsigned int *map = __libc(CTYPE); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN(NONZERO, ARGUMENT(c) is a hexadecimal digit); - RETURN(0, ARGUMENT(c) is not a hexadecimal digit); - */ + return map[c] & CT_XDIGIT; } @@ -22,6 +20,8 @@ in the current locale. ***/ /* +RETURN(NONZERO, ARGUMENT(c) is a hexadecimal digit) +RETURN(0, ARGUMENT(c) is not a hexadecimal digit) LC_CTYPE C_LOCALE(`THIS() is true for the characters CHAR(0), CHAR(1), CHAR(2), CHAR(3), CHAR(4), CHAR(5), CHAR(6), CHAR(7), CHAR(8), CHAR(9), CHAR(a), CHAR(b), CHAR(c), CHAR(d), CHAR(e), CHAR(f), CHAR(A), CHAR(B), CHAR(C), CHAR(D), CHAR(E), and CHAR(F)') STDC(1) diff --git a/src/ctype/toascii.c b/src/ctype/toascii.c index 80b599df..8a625b44 100644 --- a/src/ctype/toascii.c +++ b/src/ctype/toascii.c @@ -1,24 +1,18 @@ #include <ctype.h> /** convert a character to 7-bit ASCII **/ + int toascii(int c) { return (c & 0x7f); } -#endif - /*** -The fn(toascii) function converts arg(c) to 7-bit ASCII. +converts ARGUMENT(c) to 7-bit ASCII. ***/ -/* RETURN: arg(c) & 0x7f */ - -/* UNDEFINED: - */ -/* UNSPECIFIED: - */ -/* IMPLEMENTATION: - */ -/* LOCALE: - */ - /* +RETURN(ARGUMENT(c) & 0x7f) +XOBSOLETE(700) XOPEN(4) */ diff --git a/src/ctype/tolower.c b/src/ctype/tolower.c index 7ef5057a..3464d655 100644 --- a/src/ctype/tolower.c +++ b/src/ctype/tolower.c @@ -5,15 +5,12 @@ #include "nonstd/ctype.h" /** convert an uppercase letter to lowercase **/ + int tolower(int c) { unsigned char *map = __libc(TOLOWER); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN_SUCCESS(ARGUMENT(c) converted to lowercase); - RETURN_FAILURE(ARGUMENT(c), ARGUMENT(c) was not an uppercase letter or it has no equivalent lowercase letter); - */ if (c == EOF) { return EOF; @@ -28,6 +25,8 @@ locale. ***/ /* +RETURN_SUCCESS(ARGUMENT(c) converted to lowercase) +RETURN_FAILURE(ARGUMENT(c), ARGUMENT(c) was not an uppercase letter or it has no equivalent lowercase letter) LC_CTYPE STDC(1) */ diff --git a/src/ctype/toupper.c b/src/ctype/toupper.c index 4844a702..dc9660ec 100644 --- a/src/ctype/toupper.c +++ b/src/ctype/toupper.c @@ -5,15 +5,12 @@ #include "nonstd/ctype.h" /** convert a lowercase letter to uppercase **/ + int toupper(int c) { unsigned char *map = __libc(TOUPPER); ASSERT_REPRESENTABLE(c, 0, UCHAR_MAX, unsigned char, EOF); - /* - RETURN_SUCCESS(ARGUMENT(c) converted to uppercase); - RETURN_FAILURE(ARGUMENT(c), ARGUMENT(c) was not a lowercase letter or it has no equivalent upercase letter); - */ if (c == EOF) { return EOF; @@ -28,6 +25,8 @@ locale. ***/ /* +RETURN_SUCCESS(ARGUMENT(c) converted to uppercase) +RETURN_FAILURE(ARGUMENT(c), ARGUMENT(c) was not a lowercase letter or it has no equivalent upercase letter) LC_CTYPE STDC(1) */ |