Replace COSMO define with _COSMO_SOURCE

This change might cause ABI breakages for /opt/cosmos. It's needed to
help us better conform to header declaration practices.
This commit is contained in:
Justine Tunney 2023-08-13 20:31:27 -07:00
parent a033b65a33
commit c776a32f75
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
238 changed files with 858 additions and 1069 deletions

View file

@ -4,6 +4,12 @@
#define BLAKE2B256_DIGEST_LENGTH 32
#define BLAKE2B_CBLOCK 128
#define BLAKE2B256_Init __BLAKE2B256_Init
#define BLAKE2B256_Update __BLAKE2B256_Update
#define BLAKE2B256_Process __BLAKE2B256_Process
#define BLAKE2B256_Final __BLAKE2B256_Final
#define BLAKE2B256 __BLAKE2B256
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_

View file

@ -24,7 +24,7 @@
* @param line is NULL-propagating
* @see getline
*/
char *_chomp(char *line) {
char *chomp(char *line) {
size_t i;
if (line) {
for (i = strlen(line); i--;) {

View file

@ -24,7 +24,7 @@
* @param line is NULL-propagating
* @see getline
*/
char16_t *_chomp16(char16_t *line) {
char16_t *chomp16(char16_t *line) {
size_t i;
if (line) {
for (i = strlen16(line); i--;) {

View file

@ -24,7 +24,7 @@
* @param s is a NUL-terminated string
* @param suffix is also NUL-terminated
*/
bool _endswith(const char *s, const char *suffix) {
bool endswith(const char *s, const char *suffix) {
size_t n, m;
n = strlen(s);
m = strlen(suffix);

View file

@ -24,7 +24,7 @@
* @param s is a NUL-terminated string
* @param suffix is also NUL-terminated
*/
bool _endswith16(const char16_t *s, const char16_t *suffix) {
bool endswith16(const char16_t *s, const char16_t *suffix) {
size_t n, m;
n = strlen16(s);
m = strlen16(suffix);

View file

@ -1,117 +0,0 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/str/str.h"
static textwindows bool shouldescapedos(const char16_t c) {
if (c == u'"') return true;
if (c == u'&') return true;
if (c == u'%') return true;
if (c == u'^') return true;
if (c == u'<') return true;
if (c == u'>') return true;
if (c == u'|') return true;
return false;
}
static textwindows bool shouldquotedos(const char16_t c) {
if (c == u' ') return true;
if (c == u'\t') return true;
if (c == u'\n') return true;
if (c == u'\v') return true;
if (c == u'"') return true;
if (c == u'*') return true;
return shouldescapedos(c);
}
/**
* Escapes command so DOS can run it.
* @see Iain Patterson's NSSM for original code in public domain
*/
textwindows bool _escapedos(char16_t *buffer, unsigned buflen,
const char16_t *unquoted, unsigned len) {
unsigned i, j, n;
if (len > buflen - 1) return false;
bool escape = false;
bool quotes = false;
for (i = 0; i < len; i++) {
if (shouldescapedos(unquoted[i])) {
escape = quotes = true;
break;
}
if (shouldquotedos(unquoted[i])) quotes = true;
}
if (!quotes) {
memmove(buffer, unquoted, (len + 1) * sizeof(char16_t));
return true;
}
/* "" */
unsigned quoted_len = 2;
if (escape) quoted_len += 2;
for (i = 0;; i++) {
n = 0;
while (i != len && unquoted[i] == u'\\') {
i++;
n++;
}
if (i == len) {
quoted_len += n * 2;
break;
} else if (unquoted[i] == u'"')
quoted_len += n * 2 + 2;
else
quoted_len += n + 1;
if (shouldescapedos(unquoted[i])) quoted_len += n;
}
if (quoted_len > buflen - 1) return false;
char16_t *s = buffer;
if (escape) *s++ = u'^';
*s++ = u'"';
for (i = 0;; i++) {
n = 0;
while (i != len && unquoted[i] == u'\\') {
i++;
n++;
}
if (i == len) {
for (j = 0; j < n * 2; j++) {
if (escape) *s++ = u'^';
*s++ = u'\\';
}
break;
} else if (unquoted[i] == u'"') {
for (j = 0; j < n * 2 + 1; j++) {
if (escape) *s++ = u'^';
*s++ = u'\\';
}
if (escape && shouldescapedos(unquoted[i])) *s++ = u'^';
*s++ = unquoted[i];
} else {
for (j = 0; j < n; j++) {
if (escape) *s++ = u'^';
*s++ = u'\\';
}
if (escape && shouldescapedos(unquoted[i])) *s++ = u'^';
*s++ = unquoted[i];
}
}
if (escape) *s++ = u'^';
*s++ = u'"';
*s++ = u'\0';
return true;
}

View file

@ -1,35 +0,0 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/str/str.h"
/**
* Converts ASCII hexadecimal character to integer case-insensitively.
* @return integer or 0 if c [0-9A-Fa-f]
*/
int hextoint(int c) {
if ('0' <= c && c <= '9') {
return c - '0';
} else if ('a' <= c && c <= 'f') {
return c - 'a' + 10;
} else if ('A' <= c && c <= 'F') {
return c - 'A' + 10;
} else {
return 0;
}
}

View file

@ -1,31 +0,0 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/str/str.h"
const char *IndexDoubleNulString(const char *s, unsigned i) {
size_t n;
while (i--) {
if ((n = strlen(s))) {
s += n + 1;
} else {
return NULL;
}
}
return s;
}

View file

@ -19,6 +19,7 @@
#include "libc/dce.h"
#include "libc/macros.internal.h"
#include "libc/sysv/consts/nr.h"
#include "libc/nexgen32e/kompressor.h"
#include "libc/sysv/consts/madv.h"
.rodata.cst4

View file

@ -1,4 +1,5 @@
// o/$(MODE)/tool/build/lz4toasm.com -o o/$(MODE)/libc/str/EastAsianWidth.s -s kEastAsianWidth o/$(MODE)/libc/str/EastAsianWidth.bin.lz4
#include "libc/nexgen32e/kompressor.h"
#include "libc/macros.internal.h"
.rodata

View file

@ -24,7 +24,7 @@
* @param s is a NUL-terminated string
* @param prefix is also NUL-terminated
*/
bool _startswith(const char *s, const char *prefix) {
bool startswith(const char *s, const char *prefix) {
for (;;) {
if (!*prefix) return true;
if (!*s) return false;

View file

@ -24,7 +24,7 @@
* @param s is a NUL-terminated string
* @param prefix is also NUL-terminated
*/
bool _startswith16(const char16_t *s, const char16_t *prefix) {
bool startswith16(const char16_t *s, const char16_t *prefix) {
for (;;) {
if (!*prefix) return true;
if (!*s) return false;

View file

@ -19,7 +19,10 @@
#include "libc/str/str.h"
#include "libc/str/tab.internal.h"
bool _startswithi(const char *s, const char *prefix) {
/**
* Checks if string starts with prefix, case insensitively.
*/
bool startswithi(const char *s, const char *prefix) {
for (;;) {
if (!*prefix) return true;
if (!*s) return false;

View file

@ -6,42 +6,53 @@
#define _tolower(u) (0040 | (u))
#define _toupper(u) (0137 & (u))
#ifdef _COSMO_SOURCE
#define chomp _chomp
#define chomp16 _chomp16
#define wchomp _wchomp
#define tpenc _tpenc
#define startswith _startswith
#define startswithi _startswithi
#define endswith _endswith
#define wcsendswith _wcsendswith
#define wcsstartswith _wcsstartswith
#endif /* _COSMO_SOURCE */
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
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 toascii(int);
int hextoint(int);
int isascii(int) pureconst;
int isspace(int) pureconst;
int isalpha(int) pureconst;
int isdigit(int) pureconst;
int isalnum(int) pureconst;
int isxdigit(int) pureconst;
int isprint(int) pureconst;
int islower(int) pureconst;
int isupper(int) pureconst;
int isblank(int) pureconst;
int iscntrl(int) pureconst;
int isgraph(int) pureconst;
int tolower(int) pureconst;
int ispunct(int) pureconst;
int toupper(int) pureconst;
int toascii(int) pureconst;
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);
int iswseparator(wint_t);
wint_t towlower(wint_t);
wint_t towupper(wint_t);
int iswalnum(wint_t) pureconst;
int iswalpha(wint_t) pureconst;
int iswblank(wint_t) pureconst;
int iswcntrl(wint_t) pureconst;
int iswdigit(wint_t) pureconst;
int iswgraph(wint_t) pureconst;
int iswlower(wint_t) pureconst;
int iswspace(wint_t) pureconst;
int iswupper(wint_t) pureconst;
int iswxdigit(wint_t) pureconst;
int iswpunct(wint_t) pureconst;
int iswprint(wint_t) pureconst;
int iswseparator(wint_t) pureconst;
wint_t towlower(wint_t) pureconst;
wint_t towupper(wint_t) pureconst;
void bzero(void *, size_t) memcpyesque;
void *memset(void *, int, size_t) memcpyesque;
@ -66,12 +77,6 @@ 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;
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);
@ -81,69 +86,50 @@ wchar_t *wcschrnul(const wchar_t *, wchar_t)
strlenesque returnsnonnull;
char *strstr(const char *, const char *) strlenesque;
char *strcasestr(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;
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;
int memcasecmp(const void *, const void *, size_t) strlenesque;
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 *, wchar_t) strlenesque;
void *wmemrchr(const wchar_t *, 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;
char16_t *strcat16(char16_t *, const char16_t *) memcpyesque;
wchar_t *wcscat(wchar_t *, const wchar_t *) memcpyesque;
size_t strlcpy(char *, const char *, size_t);
size_t strlcat(char *, const char *, size_t);
size_t strxfrm(char *, const char *, size_t);
char *strcpy(char *, const char *) memcpyesque;
char16_t *strcpy16(char16_t *, const char16_t *) memcpyesque;
wchar_t *wcscpy(wchar_t *, const wchar_t *) memcpyesque;
char *strncat(char *, const char *, size_t) memcpyesque;
char16_t *strncat16(char16_t *, const char16_t *, size_t) memcpyesque;
wchar_t *wcsncat(wchar_t *, const wchar_t *, size_t) memcpyesque;
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));
wchar_t *wcstok(wchar_t *, const wchar_t *, wchar_t **) paramsnonnull((2, 3));
char *wstrtrunc(uint16_t *) memcpyesque;
char *wstrntrunc(uint16_t *, size_t) memcpyesque;
int strverscmp(const char *, const char *);
wchar_t *wmemset(wchar_t *, wchar_t, size_t) memcpyesque;
char16_t *memset16(char16_t *, char16_t, size_t) memcpyesque;
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;
void *tinymemccpy(void *, const void *, int, size_t) memcpyesque;
void *memmem(const void *, size_t, const void *, size_t)
libcesque nosideeffect;
ssize_t strfmon(char *, size_t, const char *, ...);
@ -154,15 +140,9 @@ char *strntolower(char *, size_t) libcesque;
char *strtolower(char *) libcesque paramsnonnull();
char *strntoupper(char *, size_t) libcesque;
char *strtoupper(char *) libcesque paramsnonnull();
char *_chomp(char *) libcesque;
char16_t *_chomp16(char16_t *) libcesque;
wchar_t *_wchomp(wchar_t *) libcesque;
typedef unsigned mbstate_t;
uint64_t _tpenc(uint32_t) pureconst;
axdx_t tprecode8to16(char16_t *, size_t, const char *);
axdx_t tprecode16to8(char *, size_t, const char16_t *);
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 *);
@ -194,28 +174,52 @@ wint_t towctrans(wint_t, wctrans_t);
int getsubopt(char **, char *const *, char **) paramsnonnull();
char *strsignal(int) returnsnonnull libcesque;
char *strsignal_r(int, char[hasatleast 15]) returnsnonnull libcesque;
char *strerror(int) returnsnonnull dontthrow nocallback;
int strerror_r(int, char *, size_t)
dontthrow nocallback;
int strerror_wr(int, uint32_t, char *, size_t)
dontthrow nocallback;
int __xpg_strerror_r(int, char *, size_t)
dontthrow nocallback;
#ifdef COSMO
bool _startswith(const char *, const char *) strlenesque;
bool _startswithi(const char *, const char *) strlenesque;
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;
const char *IndexDoubleNulString(const char *, unsigned) strlenesque;
#ifdef _COSMO_SOURCE
uint64_t tpenc(uint32_t) pureconst;
char *chomp(char *) libcesque;
wchar_t *wchomp(wchar_t *) libcesque;
bool startswith(const char *, const char *) strlenesque;
bool startswithi(const char *, const char *) strlenesque;
bool endswith(const char *, const char *) strlenesque;
bool _istext(const void *, size_t) libcesque;
bool _isutf8(const void *, size_t) libcesque;
bool _escapedos(char16_t *, unsigned, const char16_t *, unsigned) libcesque;
#endif
char *strsignal_r(int, char[hasatleast 15]) returnsnonnull libcesque;
int strerror_wr(int, uint32_t, char *, size_t)
dontthrow nocallback;
char16_t *chomp16(char16_t *) libcesque;
size_t strlen16(const char16_t *) strlenesque;
size_t strnlen16(const char16_t *, size_t) strlenesque;
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;
char16_t *strstr16(const char16_t *, const char16_t *) strlenesque;
int strcmp16(const char16_t *, const char16_t *) strlenesque;
int strncmp16(const char16_t *, const char16_t *, size_t) strlenesque;
int strcasecmp16(const char16_t *, const char16_t *) strlenesque;
int strncasecmp16(const char16_t *, const char16_t *, size_t) strlenesque;
char16_t *strrchr16(const char16_t *, int) strlenesque;
void *memrchr16(const void *, int, size_t) strlenesque;
char16_t *strpbrk16(const char16_t *, const char16_t *) strlenesque;
size_t strspn16(const char16_t *, const char16_t *) strlenesque;
size_t strcspn16(const char16_t *, const char16_t *) strlenesque;
char16_t *strcat16(char16_t *, const char16_t *) memcpyesque;
char16_t *strcpy16(char16_t *, const char16_t *) memcpyesque;
char16_t *strncat16(char16_t *, const char16_t *, size_t) memcpyesque;
char16_t *memset16(char16_t *, char16_t, size_t) memcpyesque;
bool startswith16(const char16_t *, const char16_t *) strlenesque;
bool endswith16(const char16_t *, const char16_t *) strlenesque;
axdx_t tprecode8to16(char16_t *, size_t, const char *);
axdx_t tprecode16to8(char *, size_t, const char16_t *);
bool wcsstartswith(const wchar_t *, const wchar_t *) strlenesque;
bool wcsendswith(const wchar_t *, const wchar_t *) strlenesque;
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */

View file

@ -1,5 +1,12 @@
#ifndef COSMOPOLITAN_LIBC_STR_TAB_INTERNAL_H_
#define COSMOPOLITAN_LIBC_STR_TAB_INTERNAL_H_
#define kHexToInt __kHexToInt
#define kToLower __kToLower
#define kToUpper __kToUpper
#define kBase36 __kBase36
#define kCp437 __kCp437
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_

View file

@ -18,6 +18,9 @@
*/
#include "libc/str/str.h"
/**
* Narrows number to ASCII.
*/
int toascii(int c) {
return c & 127;
}

View file

@ -73,7 +73,7 @@ axdx_t tprecode16to8(char *dst, size_t dstsize, const char16_t *src) {
if (!(y = src[r.dx++])) break;
x = MergeUtf16(x, y);
}
w = _tpenc(x);
w = tpenc(x);
while (w && r.ax + 1 < dstsize) {
dst[r.ax++] = w & 0xFF;
w >>= 8;

View file

@ -34,9 +34,9 @@ int wcwidth(wchar_t) pureconst;
int wcswidth(const wchar_t *, size_t) strlenesque;
struct lconv *localeconv(void);
#ifdef COSMO
#ifdef _COSMO_SOURCE
int wcsnwidth(const wchar_t *, size_t, size_t) strlenesque;
#endif
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */

View file

@ -24,7 +24,7 @@
* @param line is NULL-propagating
* @see getline
*/
wchar_t *_wchomp(wchar_t *line) {
wchar_t *wchomp(wchar_t *line) {
size_t i;
if (line) {
for (i = wcslen(line); i--;) {

View file

@ -24,7 +24,7 @@
* @param s is a NUL-terminated string
* @param suffix is also NUL-terminated
*/
bool _wcsendswith(const wchar_t *s, const wchar_t *suffix) {
bool wcsendswith(const wchar_t *s, const wchar_t *suffix) {
size_t n, m;
n = wcslen(s);
m = wcslen(suffix);