2020-06-15 14:18:57 +00:00
|
|
|
|
#ifndef COSMOPOLITAN_LIBC_STR_STR_H_
|
|
|
|
|
#define COSMOPOLITAN_LIBC_STR_STR_H_
|
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
2021-04-23 17:45:19 +00:00
|
|
|
|
│ cosmopolitan § characters » usas x3.4-1967 ─╬─│┼
|
2020-06-15 14:18:57 +00:00
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│─╝
|
|
|
|
|
fourth age telecommunications */
|
|
|
|
|
|
2021-10-08 15:11:51 +00:00
|
|
|
|
extern const int8_t kHexToInt[256];
|
2020-06-15 14:18:57 +00:00
|
|
|
|
extern const uint8_t gperf_downcase[256];
|
|
|
|
|
extern const uint8_t kToLower[256];
|
2021-08-12 07:42:14 +00:00
|
|
|
|
extern const uint8_t kToUpper[256];
|
2020-06-15 14:18:57 +00:00
|
|
|
|
extern const uint8_t kBase36[256];
|
2020-08-25 11:23:25 +00:00
|
|
|
|
extern const char16_t kCp437[256];
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
|
|
int isascii(int);
|
|
|
|
|
int isspace(int);
|
|
|
|
|
int isalpha(int);
|
|
|
|
|
int isdigit(int);
|
|
|
|
|
int isalnum(int);
|
|
|
|
|
int isxdigit(int);
|
|
|
|
|
int isprint(int);
|
|
|
|
|
int islower(int);
|
|
|
|
|
int isupper(int);
|
|
|
|
|
int isblank(int);
|
|
|
|
|
int iscntrl(int);
|
|
|
|
|
int isgraph(int);
|
|
|
|
|
int tolower(int);
|
|
|
|
|
int ispunct(int);
|
|
|
|
|
int toupper(int);
|
|
|
|
|
int hextoint(int);
|
2020-10-27 10:39:46 +00:00
|
|
|
|
int cescapec(int);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
|
│ cosmopolitan § characters » thompson-pike encoding ─╬─│┼
|
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│─╝
|
|
|
|
|
fifth age telecommunications
|
|
|
|
|
|
|
|
|
|
0123456789abcdef
|
|
|
|
|
┌0─ ☺☻♥♦♣♠•◘○◙♂♀♪♫☼┬───Control
|
|
|
|
|
└1─►◄↕‼¶§▬↨↑↓→←∟↔▲▼┘
|
|
|
|
|
┌2─ !"#$%&'()*+,-./┐
|
|
|
|
|
│3 0123456789:;<=>?│
|
|
|
|
|
│4 @ABCDEFGHIJKLMNO├───ASA x3.4-1967
|
|
|
|
|
│5 PQRSTUVWXYZ[\]^_│
|
|
|
|
|
│6 `abcdefghijklmno│
|
|
|
|
|
└7─pqrstuvwxyz{|}~⌂┘
|
|
|
|
|
┌8─ÇüéâäàåçêëèïîìÄÅ┐
|
|
|
|
|
│9 ÉæÆôöòûùÿÖÜ¢£¥€ƒ├───Thompson-Pike Continuation
|
|
|
|
|
│a á¡óúñѪº¿⌐¬½¼¡«»│ (not really characters)
|
|
|
|
|
└b─░▒▓│┤╡╢╖╕╣║╗╝╜╛┐┘
|
|
|
|
|
┌c─└┴┬├─┼╞╟╚╔╩╦╠═╬╧┬───1 Continuation will follow
|
|
|
|
|
└d─╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀┘
|
|
|
|
|
─e─αßΓπΣσμτΦΘΩδ∞φε∩────2 Continuations will follow
|
|
|
|
|
f─≡±≥≤⌠⌡÷≈°∙·√ⁿ²■λ
|
|
|
|
|
│ ││ │││└┤
|
|
|
|
|
│ ││ │└┤ └───5 Continuations follow (and is negative)
|
|
|
|
|
│ │└─┬┘ └─────5 Continuations follow (note: -1=λ┐┐┐┐┐)
|
|
|
|
|
└───┬──┘ └────────4 Continuations follow
|
|
|
|
|
└──────────────3 Continuations follow */
|
|
|
|
|
|
|
|
|
|
#define INVALID_CODEPOINT 0xfffd
|
2020-08-27 06:08:08 +00:00
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
|
int iswalnum(wint_t);
|
|
|
|
|
int iswalpha(wint_t);
|
|
|
|
|
int iswblank(wint_t);
|
|
|
|
|
int iswcntrl(wint_t);
|
|
|
|
|
int iswdigit(wint_t);
|
|
|
|
|
int iswgraph(wint_t);
|
|
|
|
|
int iswlower(wint_t);
|
|
|
|
|
int iswspace(wint_t);
|
|
|
|
|
int iswupper(wint_t);
|
|
|
|
|
int iswxdigit(wint_t);
|
|
|
|
|
int iswpunct(wint_t);
|
|
|
|
|
int iswprint(wint_t);
|
2021-09-12 05:30:37 +00:00
|
|
|
|
int iswseparator(wint_t);
|
2020-10-11 04:18:53 +00:00
|
|
|
|
wint_t towlower(wint_t);
|
|
|
|
|
wint_t towupper(wint_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
|
│ cosmopolitan § strings ─╬─│┼
|
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
|
2021-09-28 05:58:51 +00:00
|
|
|
|
void bzero(void *, size_t) memcpyesque;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
void *memset(void *, int, size_t) memcpyesque;
|
2021-09-28 05:58:51 +00:00
|
|
|
|
void *memmove(void *, const void *, size_t) memcpyesque;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
void *memcpy(void *restrict, const void *restrict, size_t) memcpyesque;
|
|
|
|
|
void *mempcpy(void *restrict, const void *restrict, size_t) memcpyesque;
|
|
|
|
|
void *memccpy(void *restrict, const void *restrict, int, size_t) memcpyesque;
|
|
|
|
|
void *memeqmask(void *, const void *, const void *, size_t) memcpyesque;
|
2021-08-12 07:42:14 +00:00
|
|
|
|
void explicit_bzero(void *, size_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
2021-09-28 05:58:51 +00:00
|
|
|
|
int bcmp(const void *, const void *, size_t) strlenesque;
|
|
|
|
|
int memcmp(const void *, const void *, size_t) strlenesque;
|
|
|
|
|
int timingsafe_bcmp(const void *, const void *, size_t);
|
|
|
|
|
int timingsafe_memcmp(const void *, const void *, size_t);
|
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
|
size_t strlen(const char *) strlenesque;
|
|
|
|
|
size_t strnlen(const char *, size_t) strlenesque;
|
|
|
|
|
size_t strnlen_s(const char *, size_t);
|
|
|
|
|
char *strchr(const char *, int) strlenesque;
|
|
|
|
|
char *index(const char *, int) strlenesque;
|
|
|
|
|
void *memchr(const void *, int, size_t) strlenesque;
|
|
|
|
|
char *strchrnul(const char *, int) strlenesque returnsnonnull;
|
|
|
|
|
void *rawmemchr(const void *, int) strlenesque returnsnonnull;
|
|
|
|
|
size_t strlen16(const char16_t *) strlenesque;
|
|
|
|
|
size_t strnlen16(const char16_t *, size_t) strlenesque;
|
|
|
|
|
size_t strnlen16_s(const char16_t *, size_t);
|
|
|
|
|
char16_t *strchr16(const char16_t *, int) strlenesque;
|
|
|
|
|
void *memchr16(const void *, int, size_t) strlenesque;
|
|
|
|
|
char16_t *strchrnul16(const char16_t *, int) strlenesque returnsnonnull;
|
|
|
|
|
void *rawmemchr16(const void *, int) strlenesque returnsnonnull;
|
|
|
|
|
size_t wcslen(const wchar_t *) strlenesque;
|
|
|
|
|
size_t wcsnlen(const wchar_t *, size_t) strlenesque;
|
|
|
|
|
size_t wcsnlen_s(const wchar_t *, size_t);
|
|
|
|
|
wchar_t *wcschr(const wchar_t *, wchar_t) strlenesque;
|
|
|
|
|
wchar_t *wmemchr(const wchar_t *, wchar_t, size_t) strlenesque;
|
|
|
|
|
wchar_t *wcschrnul(const wchar_t *, wchar_t) strlenesque returnsnonnull;
|
|
|
|
|
char *strstr(const char *, const char *) strlenesque;
|
|
|
|
|
char16_t *strstr16(const char16_t *, const char16_t *) strlenesque;
|
|
|
|
|
wchar_t *wcsstr(const wchar_t *, const wchar_t *) strlenesque;
|
|
|
|
|
void *rawwmemchr(const void *, wchar_t) strlenesque returnsnonnull;
|
|
|
|
|
int strcmp(const char *, const char *) strlenesque;
|
|
|
|
|
int strncmp(const char *, const char *, size_t) strlenesque;
|
|
|
|
|
int strcmp16(const char16_t *, const char16_t *) strlenesque;
|
|
|
|
|
int strncmp16(const char16_t *, const char16_t *, size_t) strlenesque;
|
|
|
|
|
int wcscmp(const wchar_t *, const wchar_t *) strlenesque;
|
|
|
|
|
int wcsncmp(const wchar_t *, const wchar_t *, size_t) strlenesque;
|
|
|
|
|
int wmemcmp(const wchar_t *, const wchar_t *, size_t) strlenesque;
|
|
|
|
|
int strcasecmp(const char *, const char *) strlenesque;
|
2021-03-27 14:29:55 +00:00
|
|
|
|
int memcasecmp(const void *, const void *, size_t) strlenesque;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
int strcasecmp16(const char16_t *, const char16_t *) strlenesque;
|
|
|
|
|
int wcscasecmp(const wchar_t *, const wchar_t *) strlenesque;
|
|
|
|
|
int strncasecmp(const char *, const char *, size_t) strlenesque;
|
|
|
|
|
int strncasecmp16(const char16_t *, const char16_t *, size_t) strlenesque;
|
|
|
|
|
int wcsncasecmp(const wchar_t *, const wchar_t *, size_t) strlenesque;
|
|
|
|
|
char *strrchr(const char *, int) strlenesque;
|
|
|
|
|
void *memrchr(const void *, int, size_t) strlenesque;
|
|
|
|
|
char16_t *strrchr16(const char16_t *, int) strlenesque;
|
|
|
|
|
void *memrchr16(const void *, int, size_t) strlenesque;
|
|
|
|
|
wchar_t *wcsrchr(const wchar_t *, int) strlenesque;
|
|
|
|
|
void *wmemrchr(const void *, wchar_t, size_t) strlenesque;
|
|
|
|
|
char *strpbrk(const char *, const char *) strlenesque;
|
|
|
|
|
char16_t *strpbrk16(const char16_t *, const char16_t *) strlenesque;
|
|
|
|
|
wchar_t *wcspbrk(const wchar_t *, const wchar_t *) strlenesque;
|
|
|
|
|
size_t strspn(const char *, const char *) strlenesque;
|
|
|
|
|
size_t strspn16(const char16_t *, const char16_t *) strlenesque;
|
|
|
|
|
size_t wcsspn(const wchar_t *, const wchar_t *) strlenesque;
|
|
|
|
|
size_t strcspn(const char *, const char *) strlenesque;
|
|
|
|
|
size_t strcspn16(const char16_t *, const char16_t *) strlenesque;
|
|
|
|
|
size_t wcscspn(const wchar_t *, const wchar_t *) strlenesque;
|
|
|
|
|
void *memfrob(void *, size_t) memcpyesque;
|
|
|
|
|
int strcoll(const char *, const char *) strlenesque;
|
|
|
|
|
char *strsep(char **, const char *) paramsnonnull();
|
|
|
|
|
int strcmpzbw(const uint16_t *, const char *) strlenesque;
|
|
|
|
|
int strcasecmpzbw(const uint16_t *, const char *) strlenesque;
|
|
|
|
|
char *stpcpy(char *, const char *) memcpyesque;
|
|
|
|
|
char *stpncpy(char *, const char *, size_t) memcpyesque;
|
|
|
|
|
char *strcat(char *, const char *) memcpyesque;
|
2021-01-30 16:54:12 +00:00
|
|
|
|
char16_t *strcat16(char16_t *, const char16_t *) memcpyesque;
|
|
|
|
|
wchar_t *wcscat(wchar_t *, const wchar_t *) memcpyesque;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
size_t strlcpy(char *, const char *, size_t);
|
|
|
|
|
size_t strlcat(char *, const char *, size_t);
|
2021-05-01 11:53:23 +00:00
|
|
|
|
size_t strxfrm(char *, const char *, size_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
char *strcpy(char *, const char *) memcpyesque;
|
|
|
|
|
char16_t *strcpy16(char16_t *, const char16_t *) memcpyesque;
|
2021-01-30 16:54:12 +00:00
|
|
|
|
wchar_t *wcscpy(wchar_t *, const wchar_t *) memcpyesque;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
char *strncat(char *, const char *, size_t) memcpyesque;
|
2021-08-12 07:42:14 +00:00
|
|
|
|
char16_t *strncat16(char16_t *, const char16_t *, size_t) memcpyesque;
|
|
|
|
|
wchar_t *wcsncat(wchar_t *, const wchar_t *, size_t) memcpyesque;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
char *strncpy(char *, const char *, size_t) memcpyesque;
|
|
|
|
|
char *strtok(char *, const char *) paramsnonnull((2)) libcesque;
|
|
|
|
|
char *strtok_r(char *, const char *, char **) paramsnonnull((2, 3));
|
|
|
|
|
uint16_t *strcpyzbw(uint16_t *, const char *) memcpyesque;
|
2021-06-10 02:34:27 +00:00
|
|
|
|
wchar_t *wcstok(wchar_t *, const wchar_t *, wchar_t **) paramsnonnull((2, 3));
|
2020-06-15 14:18:57 +00:00
|
|
|
|
char *wstrtrunc(uint16_t *) memcpyesque;
|
|
|
|
|
char *wstrntrunc(uint16_t *, size_t) memcpyesque;
|
|
|
|
|
bool startswith(const char *, const char *) strlenesque;
|
2021-08-14 13:17:56 +00:00
|
|
|
|
bool startswithi(const char *, const char *) strlenesque;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
bool startswith16(const char16_t *, const char16_t *) strlenesque;
|
|
|
|
|
bool wcsstartswith(const wchar_t *, const wchar_t *) strlenesque;
|
|
|
|
|
bool endswith(const char *, const char *) strlenesque;
|
|
|
|
|
bool endswith16(const char16_t *, const char16_t *) strlenesque;
|
|
|
|
|
bool wcsendswith(const wchar_t *, const wchar_t *) strlenesque;
|
2020-10-27 10:39:46 +00:00
|
|
|
|
const char *IndexDoubleNulString(const char *, unsigned) strlenesque;
|
2021-01-28 03:34:02 +00:00
|
|
|
|
int strverscmp(const char *, const char *);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
wchar_t *wmemset(wchar_t *, wchar_t, size_t) memcpyesque;
|
|
|
|
|
char16_t *memset16(char16_t *, char16_t, size_t) memcpyesque;
|
2021-09-28 05:58:51 +00:00
|
|
|
|
wchar_t *wmemcpy(wchar_t *, const wchar_t *, size_t) memcpyesque;
|
|
|
|
|
wchar_t *wmempcpy(wchar_t *, const wchar_t *, size_t) memcpyesque;
|
|
|
|
|
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t) memcpyesque;
|
2021-02-27 18:33:32 +00:00
|
|
|
|
void *tinymemccpy(void *, const void *, int, size_t) memcpyesque;
|
2021-08-12 07:42:14 +00:00
|
|
|
|
void *memmem(const void *, size_t, const void *, size_t) libcesque nosideeffect;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
char *strerror(int) returnsnonnull dontthrow nocallback;
|
2021-02-21 19:06:18 +00:00
|
|
|
|
long a64l(const char *);
|
|
|
|
|
char *l64a(long);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
2020-08-25 11:23:25 +00:00
|
|
|
|
char *strntolower(char *, size_t);
|
|
|
|
|
char *strtolower(char *) paramsnonnull();
|
|
|
|
|
char *strntoupper(char *, size_t);
|
|
|
|
|
char *strtoupper(char *) paramsnonnull();
|
|
|
|
|
char *chomp(char *);
|
|
|
|
|
char16_t *chomp16(char16_t *);
|
|
|
|
|
wchar_t *wchomp(wchar_t *);
|
Introduce --strace flag for system call tracing
This is similar to the --ftrace (c function call trace) flag, except
it's less noisy since it only logs system calls to stderr. Having this
flag is valuable because (1) system call tracing tells us a lot about
the behavior of complex programs and (2) it's usually very hard to get
system call tracing on various operating systems, e.g. strace, ktrace,
dtruss, truss, nttrace, etc. Especially on Apple platforms where even
with the special boot trick, debuggers still aren't guaranteed to work.
make -j8 o//examples
o//examples/hello.com --strace
This is enabled by default in MODE=, MODE=opt, and MODE=dbg. In MODE=dbg
extra information will be printed.
make -j8 MODE=dbg o/dbg/examples
o/dbg/examples/hello.com --strace |& less
This change also changes:
- Rename IsText() → _istext()
- Rename IsUtf8() → _isutf8()
- Fix madvise() on Windows NT
- Fix empty string case of inet_ntop()
- vfork() wrapper now saves and restores errno
- Update xsigaction() to yoink syscall support
2022-03-19 01:07:28 +00:00
|
|
|
|
bool _istext(const void *, size_t);
|
|
|
|
|
bool _isutf8(const void *, size_t);
|
Improve ZIP filesystem and change its prefix
The ZIP filesystem has a breaking change. You now need to use /zip/ to
open() / opendir() / etc. assets within the ZIP structure of your APE
binary, instead of the previous convention of using zip: or zip! URIs.
This is needed because Python likes to use absolute paths, and having
ZIP paths encoded like URIs simply broke too many things.
Many more system calls have been updated to be able to operate on ZIP
files and file descriptors. In particular fcntl() and ioctl() since
Python would do things like ask if a ZIP file is a terminal and get
confused when the old implementation mistakenly said yes, because the
fastest way to guarantee native file descriptors is to dup(2). This
change also improves the async signal safety of zipos and ensures it
doesn't maintain any open file descriptors beyond that which the user
has opened.
This change makes a lot of progress towards adding magic numbers that
are specific to platforms other than Linux. The philosophy here is that,
if you use an operating system like FreeBSD, then you should be able to
take advantage of FreeBSD exclusive features, even if we don't polyfill
them on other platforms. For example, you can now open() a file with the
O_VERIFY flag. If your program runs on other platforms, then Cosmo will
automatically set O_VERIFY to zero. This lets you safely use it without
the need for #ifdef or ifstatements which detract from readability.
One of the blindspots of the ASAN memory hardening we use to offer Rust
like assurances has always been that memory passed to the kernel via
system calls (e.g. writev) can't be checked automatically since the
kernel wasn't built with MODE=asan. This change makes more progress
ensuring that each system call will verify the soundness of memory
before it's passed to the kernel. The code for doing these checks is
fast, particularly for buffers, where it can verify 64 bytes a cycle.
- Correct O_LOOP definition on NT
- Introduce program_executable_name
- Add ASAN guards to more system calls
- Improve termios compatibility with BSDs
- Fix bug in Windows auxiliary value encoding
- Add BSD and XNU specific errnos and open flags
- Add check to ensure build doesn't talk to internet
2021-08-22 08:04:18 +00:00
|
|
|
|
bool _isabspath(const char *) strlenesque;
|
2020-10-27 10:39:46 +00:00
|
|
|
|
bool escapedos(char16_t *, unsigned, const char16_t *, unsigned);
|
2021-07-12 06:17:47 +00:00
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
|
│ cosmopolitan § strings » multibyte ─╬─│┼
|
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
|
|
|
|
|
typedef unsigned mbstate_t;
|
|
|
|
|
|
2020-12-01 11:43:40 +00:00
|
|
|
|
axdx_t tprecode8to16(char16_t *, size_t, const char *);
|
|
|
|
|
axdx_t tprecode16to8(char *, size_t, const char16_t *);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
int strcmp8to16(const char *, const char16_t *) strlenesque;
|
|
|
|
|
int strncmp8to16(const char *, const char16_t *, size_t) strlenesque;
|
|
|
|
|
int strcasecmp8to16(const char *, const char16_t *) strlenesque;
|
|
|
|
|
int strncasecmp8to16(const char *, const char16_t *, size_t) strlenesque;
|
|
|
|
|
int strcmp16to8(const char16_t *, const char *) strlenesque;
|
|
|
|
|
int strncmp16to8(const char16_t *, const char *, size_t) strlenesque;
|
|
|
|
|
int strcasecmp16to8(const char16_t *, const char *) strlenesque;
|
|
|
|
|
int strncasecmp16to8(const char16_t *, const char *, size_t) strlenesque;
|
|
|
|
|
wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t);
|
|
|
|
|
int mbtowc(wchar_t *, const char *, size_t);
|
|
|
|
|
size_t mbrtowc(wchar_t *, const char *, size_t, mbstate_t *);
|
|
|
|
|
size_t mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *);
|
|
|
|
|
size_t mbstowcs(wchar_t *, const char *, size_t);
|
2021-03-06 17:52:29 +00:00
|
|
|
|
size_t wcrtomb(char *, wchar_t, mbstate_t *);
|
|
|
|
|
size_t c32rtomb(char *, char32_t, mbstate_t *);
|
|
|
|
|
size_t mbrtoc32(char32_t *, const char *, size_t, mbstate_t *);
|
|
|
|
|
size_t c16rtomb(char *, char16_t, mbstate_t *);
|
|
|
|
|
size_t mbrtoc16(char16_t *, const char *, size_t, mbstate_t *);
|
|
|
|
|
size_t mbrlen(const char *, size_t, mbstate_t *);
|
|
|
|
|
size_t mbsnrtowcs(wchar_t *, const char **, size_t, size_t, mbstate_t *);
|
|
|
|
|
size_t wcsnrtombs(char *, const wchar_t **, size_t, size_t, mbstate_t *);
|
|
|
|
|
size_t wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *);
|
|
|
|
|
size_t wcstombs(char *, const wchar_t *, size_t);
|
|
|
|
|
int mbsinit(const mbstate_t *);
|
|
|
|
|
int mblen(const char *, size_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
int wctomb(char *, wchar_t);
|
|
|
|
|
int wctob(wint_t);
|
2021-03-06 17:52:29 +00:00
|
|
|
|
wint_t btowc(int);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
|
|
size_t strclen(const char *) nosideeffect;
|
|
|
|
|
size_t strnclen(const char *, size_t) nosideeffect;
|
|
|
|
|
size_t strclen16(const char16_t *) nosideeffect;
|
|
|
|
|
size_t strnclen16(const char16_t *, size_t) nosideeffect;
|
|
|
|
|
|
|
|
|
|
typedef unsigned wctype_t;
|
2020-08-25 11:23:25 +00:00
|
|
|
|
wctype_t wctype(const char *) strlenesque;
|
|
|
|
|
int iswctype(wint_t, wctype_t) pureconst;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
typedef const int *wctrans_t;
|
|
|
|
|
wctrans_t wctrans(const char *);
|
|
|
|
|
wint_t towctrans(wint_t, wctrans_t);
|
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
|
/*───────────────────────────────────────────────────────────────────────────│─╗
|
|
|
|
|
│ cosmopolitan § strings » system ─╬─│┼
|
|
|
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
|
|
|
|
|
|
char *strsignal(int) returnsnonnull libcesque;
|
|
|
|
|
|
2020-12-24 07:42:56 +00:00
|
|
|
|
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
2021-09-28 05:58:51 +00:00
|
|
|
|
/* gcc rewrites to memset otherwise :'( */
|
|
|
|
|
void __bzero(void *, size_t) asm("bzero") memcpyesque;
|
|
|
|
|
#define bzero(DEST, SIZE) \
|
|
|
|
|
((void)((__builtin_constant_p(SIZE)) ? memset(DEST, 0, SIZE) \
|
|
|
|
|
: __bzero(DEST, SIZE)))
|
2020-06-15 14:18:57 +00:00
|
|
|
|
#endif /* __GNUC__ && !__STRICT_ANSI__ */
|
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_STR_STR_H_ */
|