mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-03 01:38:30 +00:00
Fix ctype.h and wctype.h
This commit is contained in:
parent
e7be5a5e2b
commit
7ebaff34c6
180 changed files with 264 additions and 92 deletions
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is lower, alpha, or digit.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is upper or lower.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is ascii.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is space or tab.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is C0 ASCII control code or DEL.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is decimal digit.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is printable ascii that isn't space.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is lowercase alpha ascii character.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is printable ascii including space.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if ``c ∈ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~``
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is space, \t, \r, \n, \f, or \v.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is uppercase alpha ascii character.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is lower, alpha, or digit.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is alphabetical.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is space or tab.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is C0 or C1 control code.
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
typedef int (*isw_f)(wint_t);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is decimal digit.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is printable and not a space.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is lowercase letter.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is printable.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is punctuation mark.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
static const unsigned short kCodes[][2] = {
|
||||
{0x00aa, 0x00aa}, /* 1x English */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is space character.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is uppercase letter.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns nonzero if c is ascii hex digit.
|
||||
|
|
|
@ -16,10 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/ctype.h"
|
||||
|
||||
/**
|
||||
* Returns true if c is hexadecimal digit.
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
#define INVALID_CODEPOINT 0xfffd
|
||||
|
||||
#define _tolower(u) (0040 | (u))
|
||||
#define _toupper(u) (0137 & (u))
|
||||
|
||||
#ifdef _COSMO_SOURCE
|
||||
#define chomp _chomp
|
||||
#define chomp16 _chomp16
|
||||
|
@ -20,42 +17,13 @@
|
|||
#define wcsstartswith _wcsstartswith
|
||||
#endif /* _COSMO_SOURCE */
|
||||
|
||||
#ifndef WEOF
|
||||
#define WEOF -1u
|
||||
#endif
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int isascii(int) libcesque;
|
||||
int isspace(int) libcesque;
|
||||
int isalpha(int) libcesque;
|
||||
int isdigit(int) libcesque;
|
||||
int isalnum(int) libcesque;
|
||||
int isxdigit(int) libcesque;
|
||||
int isprint(int) libcesque;
|
||||
int islower(int) libcesque;
|
||||
int isupper(int) libcesque;
|
||||
int isblank(int) libcesque;
|
||||
int iscntrl(int) libcesque;
|
||||
int isgraph(int) libcesque;
|
||||
int tolower(int) libcesque;
|
||||
int ispunct(int) libcesque;
|
||||
int toupper(int) libcesque;
|
||||
int toascii(int) libcesque;
|
||||
|
||||
int iswalnum(wint_t) libcesque;
|
||||
int iswalpha(wint_t) libcesque;
|
||||
int iswblank(wint_t) libcesque;
|
||||
int iswcntrl(wint_t) libcesque;
|
||||
int iswdigit(wint_t) libcesque;
|
||||
int iswgraph(wint_t) libcesque;
|
||||
int iswlower(wint_t) libcesque;
|
||||
int iswspace(wint_t) libcesque;
|
||||
int iswupper(wint_t) libcesque;
|
||||
int iswxdigit(wint_t) libcesque;
|
||||
int iswpunct(wint_t) libcesque;
|
||||
int iswprint(wint_t) libcesque;
|
||||
int iswseparator(wint_t) libcesque;
|
||||
wint_t towlower(wint_t) libcesque;
|
||||
wint_t towupper(wint_t) libcesque;
|
||||
|
||||
void *memset(void *, int, size_t) memcpyesque;
|
||||
void *memmove(void *, const void *, size_t) memcpyesque;
|
||||
void *memcpy(void *restrict, const void *restrict, size_t) memcpyesque;
|
||||
|
@ -157,14 +125,6 @@ int wctomb(char *, wchar_t) libcesque;
|
|||
int wctob(wint_t) libcesque;
|
||||
wint_t btowc(int) libcesque;
|
||||
|
||||
typedef unsigned wctype_t;
|
||||
wctype_t wctype(const char *) strlenesque;
|
||||
pureconst int iswctype(wint_t, wctype_t) libcesque;
|
||||
|
||||
typedef const int *wctrans_t;
|
||||
wctrans_t wctrans(const char *) libcesque;
|
||||
wint_t towctrans(wint_t, wctrans_t) libcesque;
|
||||
|
||||
int getsubopt(char **, char *const *, char **) libcesque paramsnonnull();
|
||||
char *strsignal(int) returnsnonnull libcesque;
|
||||
char *strerror(int) returnsnonnull dontthrow dontcallback;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Compares NUL-terminated UCS-2 strings case-insensitively.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Compares NUL-terminated UCS-2 strings case-insensitively w/ limit.
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
│ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
|
||||
│ │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/ctype.h"
|
||||
#include "libc/str/str.h"
|
||||
__static_yoink("musl_libc_notice");
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
wint_t towctrans(wint_t c, wctrans_t t) {
|
||||
if (t == (wctrans_t)1)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Compares NUL-terminated wide strings case-insensitively.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Compares NUL-terminated wide strings case-insensitively w/ limit.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
wctrans_t wctrans(const char *s) {
|
||||
if (!strcmp(s, "toupper"))
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/wctype.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/serialize.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
static const char kWcTypeNames[][8] = {
|
||||
"alnum", //
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/unicode.h"
|
||||
#include "libc/str/wcwidth_osx.internal.h"
|
||||
#include "libc/wctype.h"
|
||||
|
||||
/**
|
||||
* Returns cell width of monospace character.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue