Add more missing libc functionality

This commit is contained in:
Justine Tunney 2022-08-06 09:56:17 -07:00
parent cf93ecbbb2
commit a8cf0f7e89
74 changed files with 6981 additions and 105 deletions

Binary file not shown.

View file

@ -75,6 +75,8 @@ int creat(const char *, uint32_t);
int dup(int); int dup(int);
int dup2(int, int); int dup2(int, int);
int dup3(int, int, int); int dup3(int, int, int);
int eaccess(const char *, int);
int euidaccess(const char *, int);
int execl(const char *, const char *, ...) nullterminated(); int execl(const char *, const char *, ...) nullterminated();
int execle(const char *, const char *, ...) nullterminated((1)); int execle(const char *, const char *, ...) nullterminated((1));
int execlp(const char *, const char *, ...) nullterminated(); int execlp(const char *, const char *, ...) nullterminated();

27
libc/calls/eaccess.c Normal file
View file

@ -0,0 +1,27 @@
/*-*- 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 2022 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/calls/calls.h"
#include "libc/sysv/consts/at.h"
/**
* Performs access() check using effective user/group id.
*/
int eaccess(const char *filename, int amode) {
return faccessat(AT_FDCWD, filename, amode, AT_EACCESS);
}

27
libc/calls/euidaccess.c Normal file
View file

@ -0,0 +1,27 @@
/*-*- 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 2022 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/calls/calls.h"
#include "libc/sysv/consts/at.h"
/**
* Performs access() check using effective user/group id.
*/
int euidaccess(const char *filename, int amode) {
return faccessat(AT_FDCWD, filename, amode, AT_EACCESS);
}

36
libc/calls/sysparam.h Normal file
View file

@ -0,0 +1,36 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_SYSPARAM_H_
#define COSMOPOLITAN_LIBC_CALLS_SYSPARAM_H_
#define MAXSYMLINKS 20
#define MAXHOSTNAMELEN 64
#define MAXNAMLEN 255
#define MAXPATHLEN 4096
#define NBBY 8
#define NGROUPS 32
#define CANBSIZ 255
#define NOFILE 256
#define NCARGS 131072
#define DEV_BSIZE 512
#define NOGROUP (-1)
#undef MIN
#undef MAX
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#define __bitop(x, i, o) ((x)[(i) / 8] o(1 << (i) % 8))
#define setbit(x, i) __bitop(x, i, |=)
#define clrbit(x, i) __bitop(x, i, &= ~)
#define isset(x, i) __bitop(x, i, &)
#define isclr(x, i) !isset(x, i)
#define howmany(n, d) (((n) + ((d)-1)) / (d))
#define roundup(n, d) (howmany(n, d) * (d))
#define powerof2(n) !(((n)-1) & (n))
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_SYSPARAM_H_ */

19
libc/calls/typedef/u.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_TYPEDEF_U_H_
#define COSMOPOLITAN_LIBC_CALLS_TYPEDEF_U_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
typedef unsigned char u_int8_t;
typedef unsigned short u_int16_t;
typedef unsigned u_int32_t;
typedef char *caddr_t;
typedef unsigned char u_char;
typedef unsigned short u_short, ushort;
typedef unsigned u_int, uint;
typedef unsigned long u_long, ulong;
typedef long long quad_t;
typedef unsigned long long u_quad_t;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_TYPEDEF_U_H_ */

View file

@ -62,6 +62,7 @@ forceinline char *GetEnv(const char *s, int xlat(int)) {
*/ */
char *getenv(const char *s) { char *getenv(const char *s) {
char *r; char *r;
if (!s) return 0;
if (!IsWindows()) { if (!IsWindows()) {
r = GetEnv(s, Identity); r = GetEnv(s, Identity);
} else { } else {

View file

@ -1,5 +1,6 @@
#ifndef LIBC_ISYSTEM_DIRENT_H_ #ifndef LIBC_ISYSTEM_DIRENT_H_
#define LIBC_ISYSTEM_DIRENT_H_ #define LIBC_ISYSTEM_DIRENT_H_
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/calls/struct/dirent.h"
#include "libc/sysv/consts/dt.h" #include "libc/sysv/consts/dt.h"
#endif #endif

View file

@ -1,10 +1,5 @@
#ifndef LIBC_ISYSTEM_ENDIAN_H_ #ifndef LIBC_ISYSTEM_ENDIAN_H_
#define LIBC_ISYSTEM_ENDIAN_H_ #define LIBC_ISYSTEM_ENDIAN_H_
#define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
#define __PDP_ENDIAN __ORDER_PDP_ENDIAN__
#define __BYTE_ORDER __BYTE_ORDER__
#include "libc/bits/newbie.h" #include "libc/bits/newbie.h"
#include "libc/sysv/consts/endian.h"
#endif /* LIBC_ISYSTEM_ENDIAN_H_ */ #endif /* LIBC_ISYSTEM_ENDIAN_H_ */

View file

@ -3,4 +3,6 @@
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/sysv/consts/at.h" #include "libc/sysv/consts/at.h"
#include "libc/sysv/consts/f.h" #include "libc/sysv/consts/f.h"
#include "libc/sysv/consts/fd.h"
#include "libc/sysv/consts/o.h"
#endif #endif

4
libc/isystem/fnmatch.h Normal file
View file

@ -0,0 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_FNMATCH_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_FNMATCH_H_
#include "third_party/musl/fnmatch.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_FNMATCH_H_ */

4
libc/isystem/iconv.h Normal file
View file

@ -0,0 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_ICONV_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_ICONV_H_
#include "libc/stdio/iconv.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_ICONV_H_ */

5
libc/isystem/memory.h Normal file
View file

@ -0,0 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_MEMORY_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_MEMORY_H_
#include "libc/alg/alg.h"
#include "libc/str/str.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_MEMORY_H_ */

5
libc/isystem/netdb.h Normal file
View file

@ -0,0 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NETDB_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_NETDB_H_
#include "libc/dns/dns.h"
#include "libc/dns/ent.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NETDB_H_ */

15
libc/isystem/netinet/in.h Normal file
View file

@ -0,0 +1,15 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_NETINET_IN_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_NETINET_IN_H_
#include "libc/sock/sock.h"
#include "libc/sock/struct/ip_mreq.h"
#include "libc/sock/struct/sockaddr.h"
#include "libc/sock/struct/sockaddr6.h"
#include "libc/sysv/consts/inaddr.h"
#include "libc/sysv/consts/ip.h"
#include "libc/sysv/consts/ipport.h"
#include "libc/sysv/consts/ipproto.h"
#include "libc/sysv/consts/ipv6.h"
#include "libc/sysv/consts/mcast.h"
#include "libc/sysv/consts/pf.h"
#include "libc/sysv/consts/sock.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_NETINET_IN_H_ */

4
libc/isystem/stdio_ext.h Normal file
View file

@ -0,0 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_STDIO_EXT_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_STDIO_EXT_H_
#include "libc/stdio/stdio_ext.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_STDIO_EXT_H_ */

View file

@ -1,5 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_DIR_H_ #ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_DIR_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_DIR_H_ #define COSMOPOLITAN_LIBC_ISYSTEM_SYS_DIR_H_
#include "libc/isystem/dirent.h" #include "libc/calls/calls.h"
#include "libc/sysv/consts/dt.h"
#define direct dirent #define direct dirent
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_DIR_H_ */ #endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_DIR_H_ */

View file

@ -1,4 +1,4 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_ERRNO_H_ #ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_ERRNO_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_ERRNO_H_ #define COSMOPOLITAN_LIBC_ISYSTEM_SYS_ERRNO_H_
#include "libc/isystem/errno.h" #include "libc/errno.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_ERRNO_H_ */ #endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_ERRNO_H_ */

View file

@ -1,4 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_FCNTL_H_ #ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_FCNTL_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_FCNTL_H_ #define COSMOPOLITAN_LIBC_ISYSTEM_SYS_FCNTL_H_
#include "libc/isystem/fcntl.h" #include "libc/calls/calls.h"
#include "libc/sysv/consts/at.h"
#include "libc/sysv/consts/f.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_FCNTL_H_ */ #endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_FCNTL_H_ */

View file

@ -3,9 +3,10 @@
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/calls/ioctl.h" #include "libc/calls/ioctl.h"
#include "libc/calls/struct/winsize.h" #include "libc/calls/struct/winsize.h"
#include "libc/sysv/consts/blk.h"
#include "libc/sysv/consts/fd.h" #include "libc/sysv/consts/fd.h"
#include "libc/sysv/consts/n.h" #include "libc/sysv/consts/fio.h"
#include "libc/sysv/consts/modem.h"
#include "libc/sysv/consts/pty.h" #include "libc/sysv/consts/pty.h"
#include "libc/sysv/consts/sio.h" #include "libc/sysv/consts/sio.h"
#include "libc/sysv/consts/termios.h"
#endif #endif

View file

@ -7,6 +7,7 @@
#include "libc/sysv/consts/mlock.h" #include "libc/sysv/consts/mlock.h"
#include "libc/sysv/consts/msync.h" #include "libc/sysv/consts/msync.h"
#include "libc/sysv/consts/posix.h" #include "libc/sysv/consts/posix.h"
#include "libc/sysv/consts/prot.h"
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#include "libc/sysv/consts/madv.h" #include "libc/sysv/consts/madv.h"
#endif #endif

15
libc/isystem/sys/param.h Normal file
View file

@ -0,0 +1,15 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_PARAM_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_PARAM_H_
#include "libc/bits/newbie.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/rlimit.h"
#include "libc/calls/struct/rusage.h"
#include "libc/calls/sysparam.h"
#include "libc/calls/weirdtypes.h"
#include "libc/limits.h"
#include "libc/sysv/consts/endian.h"
#include "libc/sysv/consts/prio.h"
#include "libc/sysv/consts/rlim.h"
#include "libc/sysv/consts/rlimit.h"
#include "libc/sysv/consts/rusage.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_PARAM_H_ */

View file

@ -1,4 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_POLL_H_ #ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_POLL_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_POLL_H_ #define COSMOPOLITAN_LIBC_ISYSTEM_SYS_POLL_H_
#include "libc/isystem/poll.h" #include "libc/sock/sock.h"
#include "libc/sysv/consts/poll.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_POLL_H_ */ #endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_POLL_H_ */

View file

@ -1,4 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_SIGNAL_H_ #ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_SIGNAL_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_SIGNAL_H_ #define COSMOPOLITAN_LIBC_ISYSTEM_SYS_SIGNAL_H_
#include "libc/isystem/signal.h" #include "libc/calls/calls.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/siginfo.h"
#include "libc/sysv/consts/sicode.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_SIGNAL_H_ */ #endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_SIGNAL_H_ */

View file

@ -1,4 +1,15 @@
#ifndef LIBC_ISYSTEM_SYS_SOCKET_H_ #ifndef LIBC_ISYSTEM_SYS_SOCKET_H_
#define LIBC_ISYSTEM_SYS_SOCKET_H_ #define LIBC_ISYSTEM_SYS_SOCKET_H_
#include "libc/sock/sock.h" #include "libc/sock/sock.h"
#include "libc/sock/struct/linger.h"
#include "libc/sock/struct/msghdr.h"
#include "libc/sock/struct/sockaddr.h"
#include "libc/sysv/consts/af.h"
#include "libc/sysv/consts/msg.h"
#include "libc/sysv/consts/pf.h"
#include "libc/sysv/consts/scm.h"
#include "libc/sysv/consts/shut.h"
#include "libc/sysv/consts/so.h"
#include "libc/sysv/consts/sock.h"
#include "libc/sysv/consts/sol.h"
#endif #endif

View file

@ -1,4 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_TERMIOS_H_ #ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYS_TERMIOS_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_SYS_TERMIOS_H_ #define COSMOPOLITAN_LIBC_ISYSTEM_SYS_TERMIOS_H_
#include "libc/isystem/termios.h" #include "libc/calls/termios.h"
#include "libc/sysv/consts/termios.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_TERMIOS_H_ */ #endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYS_TERMIOS_H_ */

View file

@ -4,18 +4,11 @@
#include "libc/calls/weirdtypes.h" #include "libc/calls/weirdtypes.h"
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
typedef unsigned char u_int8_t; #include "libc/bits/newbie.h"
typedef unsigned short u_int16_t; #include "libc/calls/typedef/u.h"
typedef unsigned u_int32_t; #include "libc/calls/weirdtypes.h"
typedef char *caddr_t; #include "libc/sock/select.h"
typedef unsigned char u_char; #include "libc/sysv/consts/endian.h"
typedef unsigned short u_short, ushort;
typedef unsigned u_int, uint;
typedef unsigned long u_long, ulong;
typedef long long quad_t;
typedef unsigned long long u_quad_t;
#include "libc/isystem/endian.h"
#include "libc/isystem/sys/select.h"
#endif #endif
#endif #endif

5
libc/isystem/syslog.h Normal file
View file

@ -0,0 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_SYSLOG_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_SYSLOG_H_
#include "libc/sock/syslog.h"
#include "libc/sysv/consts/log.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_SYSLOG_H_ */

View file

@ -1,5 +1,6 @@
#ifndef LIBC_ISYSTEM_TIME_H_ #ifndef LIBC_ISYSTEM_TIME_H_
#define LIBC_ISYSTEM_TIME_H_ #define LIBC_ISYSTEM_TIME_H_
#include "libc/calls/weirdtypes.h"
#include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/sched.h"
#include "libc/time/struct/tm.h" #include "libc/time/struct/tm.h"
#include "libc/time/time.h" #include "libc/time/time.h"

View file

@ -4,4 +4,6 @@
#include "libc/calls/weirdtypes.h" #include "libc/calls/weirdtypes.h"
#include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/fileno.h"
#include "libc/sysv/consts/o.h" #include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/ok.h"
#include "third_party/getopt/getopt.h"
#endif #endif

View file

@ -1,4 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_WAIT_H_ #ifndef COSMOPOLITAN_LIBC_ISYSTEM_WAIT_H_
#define COSMOPOLITAN_LIBC_ISYSTEM_WAIT_H_ #define COSMOPOLITAN_LIBC_ISYSTEM_WAIT_H_
#include "libc/isystem/sys/wait.h" #include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h"
#include "libc/sysv/consts/w.h"
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_WAIT_H_ */ #endif /* COSMOPOLITAN_LIBC_ISYSTEM_WAIT_H_ */

View file

@ -30,7 +30,7 @@ bool __grow(void *, size_t *, size_t, size_t) paramsnonnull((1, 2)) libcesque;
int malloc_trim(size_t); int malloc_trim(size_t);
size_t bulk_free(void **, size_t); size_t bulk_free(void **, size_t);
size_t malloc_usable_size(const void *); size_t malloc_usable_size(void *);
void **independent_calloc(size_t, size_t, void **); void **independent_calloc(size_t, size_t, void **);
void **independent_comalloc(size_t, size_t *, void **); void **independent_comalloc(size_t, size_t *, void **);

View file

@ -65,7 +65,7 @@ void abort(void) wontreturn noinstrument;
int __cxa_atexit(void *, void *, void *) libcesque; int __cxa_atexit(void *, void *, void *) libcesque;
int atfork(void *, void *) libcesque; int atfork(void *, void *) libcesque;
int atexit(void (*)(void)) libcesque; int atexit(void (*)(void)) libcesque;
char *getenv(const char *) paramsnonnull() nosideeffect libcesque; char *getenv(const char *) nosideeffect libcesque;
int putenv(char *) paramsnonnull(); int putenv(char *) paramsnonnull();
int setenv(const char *, const char *, int) paramsnonnull(); int setenv(const char *, const char *, int) paramsnonnull();
int unsetenv(const char *); int unsetenv(const char *);

View file

@ -123,6 +123,8 @@ ssize_t sys_sendmsg(int, const struct msghdr *, int) hidden;
ssize_t sys_recvmsg(int, struct msghdr *, int) hidden; ssize_t sys_recvmsg(int, struct msghdr *, int) hidden;
int32_t sys_select(int32_t, fd_set *, fd_set *, fd_set *, int32_t sys_select(int32_t, fd_set *, fd_set *, fd_set *,
struct timeval *) hidden; struct timeval *) hidden;
int sys_pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *,
const sigset_t *);
int sys_setsockopt(int, int, int, const void *, uint32_t) hidden; int sys_setsockopt(int, int, int, const void *, uint32_t) hidden;
int32_t sys_epoll_create(int32_t) hidden; int32_t sys_epoll_create(int32_t) hidden;
int32_t sys_epoll_ctl(int32_t, int32_t, int32_t, void *) hidden; int32_t sys_epoll_ctl(int32_t, int32_t, int32_t, void *) hidden;

40
libc/sock/pselect.c Normal file
View file

@ -0,0 +1,40 @@
/*-*- 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 2022 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/calls/strace.internal.h"
#include "libc/calls/struct/timespec.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/sock/internal.h"
#include "libc/sock/select.h"
/**
* Does what poll() does except with bitset API.
*
* This system call is supported on all platforms. It's like select()
* except that it atomically changes the sigprocmask() during the op.
*/
int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
const struct timespec *timeout, const sigset_t *sigmask) {
int rc;
sigset_t oldmask;
rc = sys_pselect(nfds, readfds, writefds, exceptfds, timeout, sigmask);
POLLTRACE("pselect(%d, %p, %p, %p, [%s], %s) → %d% m", nfds, readfds,
writefds, exceptfds, DescribeTimeval(rc, timeout),
DescribeSigset(0, sigmask), rc);
return rc;
}

View file

@ -1,5 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_SOCK_SELECT_H_ #ifndef COSMOPOLITAN_LIBC_SOCK_SELECT_H_
#define COSMOPOLITAN_LIBC_SOCK_SELECT_H_ #define COSMOPOLITAN_LIBC_SOCK_SELECT_H_
#include "libc/calls/struct/sigset.h"
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timeval.h" #include "libc/calls/struct/timeval.h"
#include "libc/str/str.h" #include "libc/str/str.h"
@ -18,6 +20,8 @@ typedef struct fd_set {
#define FD_ZERO(SET) bzero((SET)->fds_bits, sizeof((SET)->fds_bits)) #define FD_ZERO(SET) bzero((SET)->fds_bits, sizeof((SET)->fds_bits))
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *,
const sigset_t *);
COSMOPOLITAN_C_END_ COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */

View file

@ -16,12 +16,12 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/calls/struct/sockaddr6.h"
#include "libc/errno.h" #include "libc/errno.h"
#include "libc/fmt/itoa.h" #include "libc/fmt/itoa.h"
#include "libc/intrin/describeflags.internal.h" #include "libc/intrin/describeflags.internal.h"
#include "libc/macros.internal.h" #include "libc/macros.internal.h"
#include "libc/sock/sock.h" #include "libc/sock/sock.h"
#include "libc/sock/struct/sockaddr6.h"
#include "libc/str/str.h" #include "libc/str/str.h"
#include "libc/sysv/consts/af.h" #include "libc/sysv/consts/af.h"
#include "libc/sysv/consts/ipproto.h" #include "libc/sysv/consts/ipproto.h"

View file

@ -1,5 +1,6 @@
#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_ #ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_ #define COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_
#include "libc/sock/struct/sockaddr.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0) #if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_ COSMOPOLITAN_C_START_

View file

@ -3,8 +3,6 @@
#if !(__ASSEMBLER__ + __LINKER__ + 0) #if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_ COSMOPOLITAN_C_START_
#define LOG_PRI(p) (LOG_PRIMASK & (p))
int setlogmask(int); int setlogmask(int);
void openlog(const char *, int, int); void openlog(const char *, int, int);
void syslog(int, const char *, ...); void syslog(int, const char *, ...);

View file

@ -16,18 +16,11 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/unicode/locale.h" #include "libc/stdio/stdio_ext.h"
typedef void *iconv_t; /**
* Discards contents of stream buffer.
iconv_t iconv_open(const char *to, const char *from) { */
return NULL; void __fpurge(FILE *f) {
} f->beg = f->end = 0;
int iconv_close(iconv_t cd) {
return -1;
}
size_t iconv(iconv_t cd, char **in, size_t *inb, char **out, size_t *outb) {
return -1;
} }

1085
libc/stdio/big5.inc Normal file

File diff suppressed because it is too large Load diff

322
libc/stdio/codepages.inc Normal file
View file

@ -0,0 +1,322 @@
// clang-format off
"iso88591\0"
"latin1\0"
"\0\100"
"iso88592\0"
"\0\50"
"\240\20\364\127\116\244\334\364\324\51\250\124\65\125\126\156\265\42\27\134"
"\260\24\24\230\116\264\340\4\225\137\270\130\105\225\126\157\15\66\127\134"
"\111\5\43\214\100\304\314\144\320\61\14\45\143\321\62\30\65\343\214\103"
"\20\355\364\323\64\324\24\145\315\65\115\215\245\115\131\334\164\163\325\67"
"\112\205\43\316\100\344\320\164\320\71\15\245\163\321\72\31\265\343\316\103"
"\21\361\4\324\74\364\30\145\317\75\116\221\245\217\131\374\364\203\25\140"
"iso88593\0"
"\0\50"
"\240\220\364\327\50\244\0\40\322\51\250\260\64\25\107\56\265\2\0\134"
"\260\224\44\313\54\264\324\62\322\55\270\264\104\125\107\57\365\2\100\134"
"\300\4\43\14\0\304\50\204\320\61\310\44\243\314\62\314\64\343\314\63"
"\0\104\43\315\64\324\170\144\315\65\32\145\243\315\66\334\204\25\325\67"
"\340\204\43\16\0\344\54\224\320\71\350\244\243\316\72\354\264\343\316\73"
"\0\304\43\317\74\364\174\144\317\75\33\345\243\317\76\374\210\45\25\140"
"iso88594\0"
"\0\50"
"\240\20\44\323\122\244\230\124\323\51\250\124\45\21\110\133\265\42\327\53"
"\260\24\24\30\123\264\234\144\223\137\270\130\65\121\110\134\5\65\227\120"
"\0\5\43\314\60\304\24\143\214\112\14\45\143\321\62\24\65\343\14\112"
"\20\365\64\24\114\324\124\143\315\65\330\234\245\315\66\334\164\365\325\67"
"\1\205\43\316\70\344\224\143\316\112\15\245\163\321\72\25\265\343\116\112"
"\21\371\104\124\114\364\324\143\317\75\370\240\245\317\76\374\170\5\26\140"
"iso88595\0"
"\0\50"
"\240\104\47\335\164\324\125\147\335\165\330\145\247\335\166"
"\334\265\322\235\167\337\201\27\236\170\343\221\127\236\171"
"\347\241\227\236\172\353\261\327\236\173\357\301\27\237\174"
"\363\321\127\237\175\367\341\227\237\176\373\361\327\237\177\377\1\30\240\200"
"\3\22\130\240\201\7\42\230\240\202\13\62\330\240\203\17\102\30\241\204"
"\23\122\130\241\205\27\142\230\241\206\33\162\330\241\207\46\177\10\142\210"
"\42\216\110\142\211\46\236\210\142\212\52\236\262\42\213"
"iso88596\0"
"\0\50"
"\240\0\0\0\0\244\0\0\0\0\0\0\0\0\0\142\266\2\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\300\230\0\0\0\0\231\0\224\151\346\231\150\246\251\346\232"
"\154\266\351\346\233\160\306\51\347\234\164\326\151\347\235"
"\170\346\251\347\236\174\366\351\47\0\0\0\0\0\0\177\2\32\250\240"
"\203\22\132\250\241\207\42\232\250\242\213\62\332\250\243\217\102\32\51\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"iso88597\0"
"\0\50"
"\240\114\114\361\50\44\227\154\312\51\250\244\222\330\52\254\264\2\100\304"
"\260\304\42\313\54\212\55\306\330\55\215\71\366\330\56\220\365\22\231\144"
"\223\121\126\231\145\227\141\226\231\146\233\161\326\231\147"
"\237\201\26\232\150\243\221\6\100\151\246\235\206\132\152\252\255\306\132\153"
"\256\275\6\133\154\262\315\106\133\155\266\335\206\133\156\272\355\306\133\157"
"\276\375\6\134\160\302\15\107\134\161\306\35\207\134\162\312\55\307\134\163"
"\316\75\7\35\0"
"iso88598\0"
"\0\50"
"\240\0\40\312\50\244\224\142\312\51\250\244\162\315\52\254\264\342\312\53"
"\260\304\42\313\54\264\324\142\313\55\270\344\162\317\56\274\364\342\13\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\200\304\102\16\111\144\221\106\36\211\144\222\112\56\311\144\223"
"\116\76\11\145\224\122\116\111\145\225\126\136\211\145\226\132\156\311\45\0"
"\0\64\354\60\0"
"iso88599\0"
"\0\64"
"\34\105\43\315\64\324\124\143\315\65\330\144\243\315\66\334\260\64\325\67"
"\340\204\43\316\70\344\224\143\316\71\350\244\243\316\72\354\264\343\316\73"
"\35\305\43\317\74\364\324\143\317\75\370\344\243\317\76\374\264\104\325\77"
"iso885910\0"
"\0\50"
"\240\20\44\21\110\50\231\4\323\51\65\101\124\325\126\162\265\362\125\120"
"\260\24\64\121\110\51\235\24\323\55\66\105\144\25\127\163\105\14\226\120"
"\0\5\43\314\60\304\24\143\214\112\14\45\143\321\62\24\65\343\314\63"
"\320\364\64\324\64\324\124\143\115\127\330\234\245\315\66\334\164\343\315\67"
"\1\205\43\316\70\344\224\143\316\112\15\245\163\321\72\25\265\343\316\73"
"\360\370\104\324\74\364\324\143\217\127\370\240\245\317\76\374\364\343\217\114"
"iso885911\0"
"tis620\0"
"\0\50"
"\240\170\372\51\250\241\212\72\52\251\245\232\172\52\252\251\252\272\52\253"
"\255\272\372\52\254\261\312\72\53\255\265\332\172\53\256\271\352\272\53\257"
"\275\372\372\53\260\301\12\73\54\261\305\32\173\54\262\311\52\273\54\263"
"\315\72\373\54\264\321\112\73\55\265\325\132\173\55\0\0\0\0\0\266"
"\331\152\273\55\267\335\172\373\55\270\341\212\73\56\271\345\232\173\56\272"
"\351\252\273\56\273\355\272\373\56\274\361\312\73\57\275\0\0\0\0\0"
"iso885913\0"
"\0\50"
"\240\134\54\312\50\244\140\154\312\51\330\244\262\324\52\254\264\342\212\61"
"\260\304\42\313\54\26\327\142\313\55\370\344\302\324\56\274\364\342\213\71"
"\4\251\4\220\101\304\24\143\221\104\14\45\343\26\105\40\301\204\122\115"
"\125\355\324\323\64\103\125\143\315\65\147\345\364\324\127\334\300\45\327\67"
"\5\255\24\320\101\344\224\163\321\104\15\245\363\126\105\41\305\224\222\115"
"\126\361\344\323\74\104\325\143\317\75\150\351\4\25\130\374\304\65\27\305"
"iso885914\0"
"\0\50"
"\240\324\153\357\50\12\55\164\357\51\3\247\122\60\276\11\267\342\112\133"
"\371\352\353\321\107\373\362\153\113\277\4\373\153\360\277\12\37\214\60\300"
"\300\4\43\314\60\304\24\143\314\61\310\44\243\314\62\314\64\343\314\63"
"\151\105\43\315\64\324\124\143\115\300\330\144\243\315\66\334\164\263\326\67"
"\340\204\43\316\70\344\224\143\316\71\350\244\243\316\72\354\264\343\316\73"
"\152\305\43\317\74\364\324\143\217\300\370\344\243\317\76\374\364\303\326\77"
"iso885915\0"
"latin9\0"
"\0\51"
"\44\227\122\325\51\126\245\242\312\52\254\264\342\312\53\260\304\42\313\54"
"\162\325\142\313\55\163\345\242\313\56\107\41\325\326\57\300\4\43\314\60"
"\304\24\143\314\61\310\44\243\314\62\314\64\343\314\63\320\104\43\315\64"
"\324\124\143\315\65\330\144\243\315\66\334\164\343\315\67\340\204\43\316\70"
"\344\224\143\316\71\350\244\243\316\72\354\264\343\316\73\360\304\43\317\74"
"\364\324\143\317\75\370\344\243\317\76\374\364\343\317\77"
"iso885916\0"
"\0\50"
"\240\20\124\120\116\44\143\134\325\51\126\245\222\327\52\156\265\362\26\134"
"\260\304\302\220\116\162\135\154\313\55\163\65\244\327\56\107\41\325\126\134"
"\300\4\43\214\100\304\30\144\314\61\310\44\243\314\62\314\64\343\314\63"
"\20\355\44\315\64\324\24\145\315\123\145\145\243\315\66\334\130\264\327\67"
"\340\204\43\316\100\344\34\144\316\71\350\244\243\316\72\354\264\343\316\73"
"\21\361\44\317\74\364\30\145\17\124\146\345\243\317\76\374\134\304\327\77"
"cp1250\0"
"windows1250\0"
"\0\40"
"\44\3\120\61\0\30\163\234\261\306\0\164\134\225\307\117\145\45\227\133"
"\0\114\114\261\305\27\157\374\60\304\0\234\154\325\307\120\151\65\327\133"
"\240\370\365\127\116\244\20\144\312\51\250\244\62\325\52\254\264\342\12\134"
"\260\304\22\230\116\264\324\142\313\55\270\24\104\325\56\67\15\206\123\134"
"\111\5\43\214\100\304\314\144\320\61\14\45\143\321\62\30\65\343\214\103"
"\20\355\364\323\64\324\24\145\315\65\115\215\245\115\131\334\164\163\325\67"
"\112\205\43\316\100\344\320\164\320\71\15\245\163\321\72\31\265\343\316\103"
"\21\361\4\324\74\364\30\145\317\75\116\221\245\217\131\374\364\203\25\140"
"cp1251\0"
"windows1251\0"
"\0\40"
"\322\115\127\161\210\30\163\234\261\306\44\167\234\235\307\332\161\267\235\167"
"\40\116\114\261\305\27\157\374\60\304\0\234\174\342\307\50\252\230\42\213"
"\240\164\267\42\166\244\264\150\312\51\321\245\102\335\52\254\264\342\312\165"
"\260\304\142\35\211\56\326\142\313\55\37\232\54\342\56\46\126\67\142\211"
"\337\201\27\236\170\343\221\127\236\171\347\241\227\236\172"
"\353\261\327\236\173\357\301\27\237\174\363\321\127\237\175"
"\367\341\227\237\176\373\361\327\237\177\377\1\30\240\200\3\22\130\240\201"
"\7\42\230\240\202\13\62\330\240\203\17\102\30\241\204\23\122\130\241\205"
"\27\142\230\241\206\33\162\330\241\207"
"cp1252\0"
"windows1252\0"
"\0\40"
"\44\3\120\61\135\30\163\234\261\306\175\165\134\225\307\107\1\40\27\0"
"\0\114\114\261\305\27\157\374\60\304\202\235\154\325\307\110\1\60\127\133"
"\240\204\42\312\50\244\224\142\312\51\250\244\242\312\52\254\264\342\312\53"
"\260\304\42\313\54\264\324\142\313\55\270\344\242\313\56\274\364\342\313\57"
"\300\4\43\314\60\304\24\143\314\61\310\44\243\314\62\314\64\343\314\63"
"\320\104\43\315\64\324\124\143\315\65\330\144\243\315\66\334\164\343\315\67"
"\340\204\43\316\70\344\224\143\316\71\350\244\243\316\72\354\264\343\316\73"
"\360\304\43\317\74\364\324\143\317\75\370\344\243\317\76\374\364\343\317\77"
"cp1253\0"
"windows1253\0"
"\0\40"
"\44\3\120\61\135\30\163\234\261\306\0\164\14\200\307\0\0\0\0\0"
"\0\114\114\261\305\27\157\374\60\304\0\234\14\300\307\0\0\0\0\0"
"\240\54\306\330\50\244\224\142\312\51\250\244\2\300\52\254\264\342\112\304"
"\260\304\42\313\54\212\325\142\313\55\215\71\366\330\56\220\365\22\231\144"
"\223\121\126\231\145\227\141\226\231\146\233\161\326\231\147"
"\237\201\26\232\150\243\221\6\100\151\246\235\206\132\152\252\255\306\132\153"
"\256\275\6\133\154\262\315\106\133\155\266\335\206\133\156\272\355\306\133\157"
"\276\375\6\134\160\302\15\107\134\161\306\35\207\134\162\312\55\307\134\163"
"\316\75\7\35\0"
"cp1254\0"
"windows1254\0"
"\0\40"
"\44\3\120\61\135\30\163\234\261\306\175\165\134\225\307\107\1\0\0\0"
"\0\114\114\261\305\27\157\374\60\304\202\235\154\325\307\110\1\0\100\133"
"\240\204\42\312\50\244\224\142\312\51\250\244\242\312\52\254\264\342\312\53"
"\260\304\42\313\54\264\324\142\313\55\270\344\242\313\56\274\364\342\313\57"
"\300\4\43\314\60\304\24\143\314\61\310\44\243\314\62\314\64\343\314\63"
"\34\105\43\315\64\324\124\143\315\65\330\144\243\315\66\334\260\64\325\67"
"\340\204\43\316\70\344\224\143\316\71\350\244\243\316\72\354\264\343\316\73"
"\35\305\43\317\74\364\324\143\317\75\370\344\243\317\76\374\264\104\325\77"
"cp1255\0"
"windows1255\0"
"\0\40"
"\44\3\120\61\135\30\163\234\261\306\175\165\14\200\307\0\0\0\0\0"
"\0\114\114\261\305\27\157\374\60\304\202\235\14\300\307\0\0\0\0\0"
"\240\204\42\312\50\42\227\142\312\51\250\244\162\315\52\254\264\342\312\53"
"\260\304\42\313\54\264\324\142\313\55\270\344\162\317\56\274\364\342\313\57"
"\57\302\30\243\214\63\322\130\243\215\67\342\10\100\216\72\356\310\143\217"
"\76\376\10\144\220\135\172\371\45\230\141\2\0\0\0\0\0\0\0\0\102\16\111\144\221"
"\106\36\211\144\222\112\56\311\144\223\116\76\11\145\224\122\116\111\145\225"
"\126\136\211\145\226\132\156\311\45\0\0\64\354\60\0"
"cp1256\0"
"windows1256\0"
"\0\40"
"\44\117\132\61\135\30\163\234\261\306\175\165\54\251\307\107\121\172\151\245"
"\231\116\114\261\305\27\157\374\60\304\230\236\154\351\307\110\55\314\260\246"
"\240\210\51\312\50\244\224\142\312\51\250\244\262\351\52\254\264\342\312\53"
"\260\304\42\313\54\264\324\142\313\55\270\344\62\346\56\274\364\342\13\231"
"\234\226\151\346\231\150\246\251\346\232\154\266\351\346\233"
"\160\306\51\347\234\164\326\151\347\235\170\346\251\347\65\173\362\331\247\237"
"\177\2\32\250\240\340\14\52\16\241\205\32\172\350\71\350\244\243\316\72"
"\210\46\352\316\73\212\56\312\150\243\364\70\372\350\75\220\346\23\351\76"
"\374\64\354\160\247"
"cp1257\0"
"windows1257\0"
"\0\40"
"\44\3\120\61\0\30\163\234\261\306\0\164\14\200\307\0\240\342\27\56"
"\0\114\114\261\305\27\157\374\60\304\0\234\14\300\307\0\274\22\30\0"
"\240\0\40\312\50\244\0\140\312\51\330\244\262\324\52\254\264\342\212\61"
"\260\304\42\313\54\264\324\142\313\55\370\344\302\324\56\274\364\342\213\71"
"\4\251\4\220\101\304\24\143\221\104\14\45\343\26\105\40\301\204\122\115"
"\125\355\324\323\64\103\125\143\315\65\147\345\364\324\127\334\300\45\327\67"
"\5\255\24\320\101\344\224\163\321\104\15\245\363\126\105\41\305\224\222\115"
"\126\361\344\323\74\104\325\143\317\75\150\351\4\25\130\374\304\65\27\140"
"cp1258\0"
"windows1258\0"
"\0\40"
"\44\3\120\61\135\30\163\234\261\306\175\165\14\200\307\107\1\0\0\0"
"\0\114\114\261\305\27\157\374\60\304\202\235\14\300\307\110\1\0\100\133"
"\240\204\42\312\50\244\224\142\312\51\250\244\242\312\52\254\264\342\312\53"
"\260\304\42\313\54\264\324\142\313\55\270\344\242\313\56\274\364\342\313\57"
"\300\4\43\214\100\304\24\143\314\61\310\44\243\314\62\204\65\343\314\63"
"\20\105\163\330\64\324\324\145\315\65\330\144\243\315\66\334\334\145\330\67"
"\340\204\43\316\100\344\224\143\316\71\350\244\243\316\72\205\265\343\316\73"
"\21\305\203\330\74\364\330\145\317\75\370\344\243\317\76\374\340\65\362\77"
"koi8r\0"
"\0\40"
"\63\323\134\263\315\67\343\234\263\316\73\363\334\363\326\134\167\355\365\327"
"\140\207\55\166\314\143\243\234\62\313\56\277\14\212\314\260\310\162\313\75"
"\76\377\14\364\207\101\13\75\64\321\105\33\175\64\322\111\53\275\64\323"
"\115\73\375\164\164\120\107\55\365\324\124\127\155\365\325\130\147\255\165\52"
"\35\376\7\140\205\3\22\70\241\200\24\36\210\140\202\12\56\310\140\203"
"\16\172\370\40\204\21\112\130\140\200\33\152\150\340\205\34\142\150\141\206"
"\375\175\7\136\175\343\221\67\237\170\364\235\207\136\172\352\255\307\136\173"
"\356\371\367\36\174\361\311\127\136\170\373\351\147\336\175"
"\374\341\147\137\176"
"koi8u\0"
"\0\40"
"\63\323\134\263\315\67\343\234\263\316\73\363\334\363\326\134\167\355\365\327"
"\140\207\55\166\314\143\243\234\62\313\56\277\14\212\314\260\310\162\313\75"
"\76\377\14\364\207\42\12\115\142\211\105\33\175\64\322\111\273\270\64\323"
"\115\73\375\164\164\324\105\155\335\165\124\127\155\365\325\130\267\250\165\52"
"\35\376\7\140\205\3\22\70\241\200\24\36\210\140\202\12\56\310\140\203"
"\16\172\370\40\204\21\112\130\140\200\33\152\150\340\205\34\142\150\141\206"
"\375\175\7\136\175\343\221\67\237\170\364\235\207\136\172\352\255\307\136\173"
"\356\371\367\36\174\361\311\127\136\170\373\351\147\336\175"
"\374\341\147\137\176"
"cp437\0"
"\0\40"
"\307\360\223\216\70\344\200\123\316\71\352\254\203\316\73\356\260\103\114\61"
"\311\230\143\14\75\366\310\263\117\76\377\130\303\215\50\243\224\22\62\135"
"\341\264\63\217\76\361\104\243\212\56\277\300\314\112\57\274\204\262\312\56"
"\140\207\55\66\315\72\77\15\65\321\103\107\375\163\321\113\53\235\264\315"
"\67\363\274\163\316\63\367\314\164\323\110\13\175\65\325\116\373\254\165\325"
"\126\113\75\365\321\106\3\35\164\326\130\343\134\163\327\134\173\375\365\326"
"\263\175\143\231\160\245\25\127\213\161\250\155\266\232\155\52\43\167\333\312"
"\55\307\362\262\313\61\313\174\17\313\260\240\174\113\312\40\313\62\66\50"
"cp850\0"
"\0\40"
"\307\360\223\216\70\344\200\123\316\71\352\254\203\316\73\356\260\103\114\61"
"\311\230\143\14\75\366\310\263\117\76\377\130\303\15\76\243\140\163\15\135"
"\341\264\63\217\76\361\104\243\212\56\277\270\302\112\57\274\204\262\312\56"
"\140\207\55\66\315\72\7\43\14\60\251\104\375\163\321\113\213\122\212\315"
"\67\363\274\163\316\63\367\74\316\60\110\13\175\65\325\116\373\254\65\51"
"\360\100\243\314\62\310\264\324\214\63\317\340\134\163\327\134\233\302\314\326"
"\323\174\103\215\64\365\124\123\213\77\336\150\263\115\66\375\164\363\12\55"
"\255\304\42\261\57\266\234\162\17\56\260\240\162\113\56\263\310\62\66\50"
"cp866\0"
"\0\40"
"\337\201\27\236\170\343\221\127\236\171\347\241\227\236\172"
"\353\261\327\236\173\357\301\27\237\174\363\321\127\237\175"
"\367\341\227\237\176\373\361\327\237\177\377\1\30\240\200\3\22\130\240\201"
"\7\42\230\240\202\13\62\330\240\203\140\207\55\66\315\72\77\15\65\321"
"\103\107\375\163\321\113\53\235\264\315\67\363\274\163\316\63\367\314\164\323"
"\110\13\175\65\325\116\373\254\165\325\126\113\75\365\321\106\3\35\164\326"
"\130\343\134\163\327\134\173\375\365\326\17\102\30\241\204\23\122\130\241\205"
"\27\142\230\241\206\33\162\330\241\207\321\175\110\235\210\327\225\330\335\212"
"\260\240\174\113\312\46\223\62\66\50"
"ibm1047\0"
"cp1047\0"
"\0\1"
"\234\44\140\310\37\227\64\342\310\2\14\64\340\300\3\20\104\40\301\4"
"\235\24\202\300\41\30\144\40\311\43\34\164\340\301\7\200\4\42\310\40"
"\204\50\160\301\6\210\44\242\310\42\214\24\140\300\1\220\104\142\301\44"
"\224\124\142\11\1\230\144\242\311\46\24\124\340\211\6\40\200\42\16\71"
"\340\204\63\116\71\347\304\43\212\13\74\240\260\2\37\46\244\243\316\72"
"\350\264\343\316\73\354\174\23\2\11\52\244\260\203\27\55\274\40\14\61"
"\300\4\63\114\61\307\104\143\12\13\45\174\341\303\17\370\44\243\314\62"
"\310\64\343\314\63\314\200\241\303\10\100\234\320\203\10\330\204\41\306\30"
"\144\224\141\306\31\150\244\261\312\56\360\364\343\117\54\260\250\261\6\33"
"\155\270\361\6\34\161\310\241\212\56\346\340\142\14\51\265\370\61\7\35"
"\165\330\161\7\36\171\350\21\312\57\320\154\341\215\53\254\214\122\312\55"
"\251\234\142\13\57\275\370\322\15\52\257\164\101\313\65\173\4\41\304\20"
"\104\24\141\304\21\110\44\321\12\75\366\310\63\117\75\175\50\261\4\23"
"\115\70\361\4\24\121\110\221\313\76\374\344\243\317\77\134\334\63\5\25"
"\125\130\161\5\26\131\150\41\13\65\326\110\63\115\65\60\304\40\303\14"
"\64\324\140\303\15\70\344\60\313\66\334\144\243\315\47"

View file

@ -16,11 +16,12 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE. PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "libc/stdio/stdio_ext.h" #include "libc/stdio/stdio.h"
/** /**
* Discards contents of stream buffer. * Discards contents of stream buffer.
*/ */
void __fpurge(FILE *f) { int fpurge(FILE *f) {
f->beg = f->end = 0; f->beg = f->end = 0;
return 0;
} }

1866
libc/stdio/gb18030.inc Normal file

File diff suppressed because it is too large Load diff

390
libc/stdio/hkscs.inc Normal file
View file

@ -0,0 +1,390 @@
17392,19506,17923,17830,17784,29287,19831,17843,31921,19682,31941,15253,18230,
18244,19527,19520,17087,13847,29522,28299,28882,19543,41809,18255,17882,19589,
31852,19719,19108,18081,27427,29221,23124,6755,15878,16225,26189,22267,0,
32149,22813,35769,15860,38708,31727,23515,7518,23204,13861,40624,23249,23479,
23804,26478,34195,39237,29793,29853,14453,7507,13982,24609,16108,22750,15093,
31484,40855,16737,35085,12778,2698,12894,17162,33924,40854,37935,18736,34323,
22678,38730,37400,31184,31282,26208,27177,34973,29772,31685,26498,31276,21071,
36934,13542,29636,23993,29894,40903,22451,18735,21580,16689,13966,22552,31346,
31589,35727,18094,28296,16769,23961,31662,9404,40904,9409,9417,9420,40905,
34052,13755,16564,40906,17633,44543,25281,28782,40907,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12736,12737,12738,12739,12740,268,12741,
209,205,12742,12743,203,8168,12744,202,12745,12746,12747,12748,270,12749,
12750,256,193,461,192,274,201,282,200,332,211,465,210,56320,7870,56324,7872,
202,257,225,462,224,593,275,233,283,232,299,237,464,236,333,243,466,242,363,
250,468,249,470,472,474,476,252,56328,7871,56332,7873,234,609,9178,9179,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,41897,4421,0,25866,0,0,20029,28381,
40270,37343,0,0,30517,25745,20250,20264,20392,20822,20852,20892,20964,21153,
21160,21307,21326,21457,21464,22242,22768,22788,22791,22834,22836,23398,23454,
23455,23706,24198,24635,25993,26622,26628,26725,27982,28860,30005,32420,32428,
32442,32455,32463,32479,32518,32567,33402,33487,33647,35270,35774,35810,36710,
36711,36718,29713,31996,32205,26950,31433,21031,0,0,0,0,37260,30904,37214,
32956,0,36107,33014,2535,0,0,32927,40647,19661,40393,40460,19518,40438,28686,
40458,41267,13761,0,28314,33342,29977,0,18705,39532,39567,40857,31111,33900,
7626,1488,10982,20004,20097,20096,20103,20159,20203,20279,13388,20413,15944,
20483,20616,13437,13459,13477,20870,22789,20955,20988,20997,20105,21113,21136,
21287,13767,21417,13649,21424,13651,21442,21539,13677,13682,13953,21651,21667,
21684,21689,21712,21743,21784,21795,21800,13720,21823,13733,13759,21975,13765,
32132,21797,0,3138,3349,20779,21904,11462,14828,833,36422,19896,38117,16467,
32958,30586,11320,14900,18389,33117,27122,19946,25821,3452,4020,3285,4340,
25741,36478,3734,3083,3940,11433,33366,17619,0,3398,39501,33001,18420,
20135,11458,39602,14951,38388,16365,13574,21191,38868,30920,11588,40302,38933,
0,17369,24741,25780,21731,11596,11210,4215,14843,4207,26330,26390,31136,25834,
20562,3139,36456,8609,35660,1841,0,18443,425,16378,22643,11661,0,17864,1276,
24727,3916,3478,21881,16571,17338,0,19124,10854,4253,33194,39157,3484,25465,
14846,10101,36288,22177,25724,15939,0,42497,3593,10959,11465,0,4296,14786,
14738,14854,33435,13688,24137,8391,22098,3889,11442,38688,13500,27709,20027,0,
0,30068,11915,8712,42587,36045,3706,3124,26652,32659,4303,10243,10553,13819,
20963,3724,3981,3754,16275,3888,3399,4431,3660,0,3755,2985,3400,4288,4413,
16377,9878,25650,4013,13300,30265,11214,3454,3455,11345,11349,14872,3736,4295,
3886,42546,27472,36050,36249,36042,38314,21708,33476,21945,0,40643,39974,
39606,30558,11758,28992,33133,33004,23580,25970,33076,14231,21343,32957,37302,
3834,3599,3703,3835,13789,19947,13833,3286,22191,10165,4297,3600,3704,4216,
4424,33287,5205,3705,20048,11684,23124,4125,4126,4341,4342,22428,3601,30356,
33485,4021,3707,20862,14083,4022,4480,21208,41661,18906,6202,16759,33404,
22681,21096,13850,22333,31666,23400,18432,19244,40743,18919,39967,39821,23412,
12605,22011,13810,22153,20008,22786,7105,63608,38737,134,20059,20155,13630,
23587,24401,24516,14586,25164,25909,27514,27701,27706,28780,29227,20012,29357,
18665,32594,31035,31993,32595,25194,13505,0,25419,32770,32896,26130,26961,
21341,34916,35265,30898,35744,36125,38021,38264,38271,38376,
36367,38886,39029,39118,39134,39267,38928,40060,40479,40644,27503,63751,20023,
135,38429,25143,38050,0,20539,28158,40051,40870,15817,34959,16718,28791,23797,
19232,20941,13657,23856,24866,35378,36775,37366,29073,26393,29626,12929,41223,
15499,6528,19216,30948,29698,20910,34575,16393,27235,41658,16931,34319,2671,
31274,39239,35562,38741,28749,21284,8318,37876,30425,35299,40871,30685,20131,
20464,20668,20015,20247,40872,21556,32139,22674,22736,7606,24210,24217,24514,
10002,25995,13305,26905,27203,15459,27903,0,29184,17669,29580,16091,18963,
23317,29881,35715,23716,22165,31379,31724,31939,32364,33528,34199,40873,34960,
40874,36537,40875,36815,34143,39392,37409,40876,36281,5183,16497,17058,23066,
0,0,0,39016,26475,17014,22333,0,34262,18811,33471,28941,19585,28020,23931,
27413,28606,40877,40878,23446,40879,26343,32347,28247,31178,15752,17603,12886,
10134,17306,17718,0,23765,15130,35577,23672,15634,13649,23928,40882,29015,
17752,16620,7715,19575,14712,13386,420,27713,35532,20404,569,22975,33132,
38998,39162,24379,2975,0,8641,35181,16642,18107,36985,16135,40883,41397,16632,
14294,18167,27718,16764,34482,29695,17773,14548,21658,17761,17691,19849,19579,
19830,17898,16328,19215,13921,17630,17597,16877,23870,23880,23894,15868,14351,
23972,23993,14368,14392,24130,24253,24357,24451,14600,14612,14655,14669,24791,
24893,23781,14729,25015,25017,25039,14776,25132,25232,25317,25368,14840,22193,
14851,25570,25595,25607,25690,14923,25792,23829,22049,40863,14999,25990,15037,
26111,26195,15090,26258,15138,
26390,15170,26532,26624,15192,26698,26756,15218,15217,15227,26889,26947,29276,
26980,27039,27013,15292,27094,15325,27237,27252,27249,27266,15340,27289,15346,
27307,27317,27348,27382,27521,27585,27626,27765,27818,15563,27906,27910,27942,
28033,15599,28068,28081,28181,28184,28201,28294,35264,28347,28386,28378,40831,
28392,28393,28452,28468,15686,16193,28545,28606,15722,15733,29111,23705,15754,
28716,15761,28752,28756,28783,28799,28809,805,17345,13809,3800,16087,22462,
28371,28990,22496,13902,27042,35817,23412,31305,22753,38105,31333,31357,22956,
31419,31408,31426,31427,29137,25741,16842,31450,31453,31466,16879,21682,23553,
31499,31573,31529,21262,23806,31650,31599,33692,23476,27775,31696,33825,31634,
0,23840,15789,23653,33938,31738,0,31797,23745,31812,31875,18562,31910,26237,
17784,31945,31943,31974,31860,31987,31989,0,32359,17693,28228,32093,28374,
29837,32137,32171,28981,32179,0,16471,24617,32228,15635,32245,6137,32229,
33645,0,24865,24922,32366,32402,17195,37996,32295,32576,32577,32583,31030,
25296,39393,32663,25425,32675,5729,104,17756,14182,17667,33594,32762,25737,0,
32776,32797,0,32815,41095,27843,32827,32828,32865,10004,18825,26150,15843,
26344,26405,32935,35400,33031,33050,22704,9974,27775,25752,20408,25831,5258,
33304,6238,27219,19045,19093,17530,33321,2829,27218,15742,20473,5373,34018,
33634,27402,18855,13616,6003,15864,33450,26907,63892,16859,34123,33488,33562,
3606,6068,14017,12669,13658,33403,33506,33560,16011,28067,27397,27543,13774,
15807,33565,21996,33669,17675,28069,33708,
0,33747,13438,28372,27223,34138,13462,28226,12015,33880,23524,33905,15827,
17636,27303,33866,15541,31064,0,27542,28279,28227,34014,0,33681,17568,33939,
34020,23697,16960,23744,17731,34100,23282,28313,17703,34163,17686,26559,34326,
34341,34363,34241,28808,34306,5506,28877,63922,17770,34344,13896,6306,21495,
29594,34430,34673,41208,34798,11303,34737,34778,34831,22113,34412,26710,17935,
34885,34886,30176,15801,30180,34910,34972,18011,34996,34997,25537,35013,30583,
30479,35207,35210,0,0,35239,35260,35365,35303,31012,31421,35484,30611,37374,
35472,31321,31465,31546,16271,18195,31544,29052,35596,35615,21552,21861,35647,
35660,35661,35497,19066,35728,35739,35503,5855,17941,34895,35995,32084,32143,
63956,14117,32083,36054,32152,32189,36114,36099,6416,36059,28764,36113,19657,
16080,0,36265,32770,4116,18826,15228,33212,28940,31463,36525,36534,36547,
37588,36633,36653,33637,33810,36773,37635,41631,2640,36787,18730,35294,34109,
15803,24312,12898,36857,40980,34492,34049,8997,14720,28375,36919,34108,31422,
36961,34156,34315,37032,34579,37060,34534,37038,0,37223,15088,37289,37316,
31916,35123,7817,37390,27807,37441,37474,21945,0,35526,15515,35596,21979,3377,
37676,37739,35553,35819,28815,23235,35554,35557,18789,37444,35820,35897,35839,
37747,37979,36540,38277,38310,37926,38304,28662,17081,9850,34520,4732,15918,
18911,27676,38523,38550,16748,38563,28373,25050,38582,30965,35552,38589,21452,
18849,27832,628,25616,37039,37093,19153,6421,13066,38705,34370,38710,18959,
17725,17797,19177,28789,23361,38683,
0,37333,38743,23370,37355,38751,37925,20688,12471,12476,38793,38815,38833,
38846,38848,38866,38880,21612,38894,29724,37939,0,38901,37917,31098,19153,
38964,38963,38987,39014,15118,29045,15697,1584,16732,22278,39114,39095,39112,
39111,19199,27943,5843,21936,39137,39142,39148,37752,39225,18985,19314,38999,
39173,39413,39436,39483,39440,39512,22309,14020,37041,39893,39648,39650,39685,
39668,19470,39700,39725,34304,20532,39732,27048,14531,12413,39760,39744,40254,
23109,6243,39822,16971,39938,39935,39948,40552,40404,40887,41362,41387,41185,
41251,41439,40318,40323,41268,40462,26760,40388,8539,41363,41504,6459,41523,
40249,41145,41652,40592,40597,40606,40610,19764,40618,40623,17252,40641,15200,
14821,15645,20274,14270,35883,40706,40712,19350,37924,28066,40727,0,40761,
22175,22154,40773,39352,37003,38898,33919,40802,40809,31452,40846,29206,19390,
18805,18875,29047,18936,17224,19025,29598,35802,6394,31135,35198,36406,37737,
37875,35396,37612,37761,37835,35180,17593,29207,16107,30578,31299,28880,17523,
17400,29054,6127,28835,6334,13721,16071,6277,21551,6136,14114,5883,6201,14049,
6004,6353,24395,14115,5824,22363,18981,5118,4776,5062,5302,34051,13990,0,
33877,18836,29029,15921,21852,16123,28754,17652,14062,39325,28454,26617,14131,
15381,15847,22636,6434,26640,16471,14143,16609,16523,16655,27681,21707,22174,
26289,22162,4063,2984,3597,37830,35603,37788,20216,20779,14361,17462,20156,
1125,895,20299,20362,22097,23144,427,971,14745,778,1044,13365,20265,704,36531,
629,35546,524,20120,20685,
20749,20386,20227,18958,16010,20290,20526,20588,20609,20428,20453,20568,20732,
0,0,0,0,28278,13717,15929,16063,28018,6276,16009,20904,20931,1504,17629,1187,
1170,1169,36218,35484,1806,21081,21156,2163,21217,0,18042,29068,17292,3104,
18860,4324,27089,3613,0,16094,29849,29716,29782,29592,19342,19132,16525,21456,
13700,29199,16585,21940,837,21709,3014,22301,37469,38644,37734,22493,22413,
22399,13886,22731,23193,35398,5882,5999,5904,23084,22968,37519,23166,23247,
23058,22854,6643,6241,17045,14069,27909,29763,23073,24195,23169,35799,1043,
37856,29836,4867,28933,18802,37896,35323,37821,14240,23582,23710,24158,24136,
6550,6524,15086,24269,23375,6403,6404,14081,6304,14045,5886,14035,33066,35399,
7610,13426,35240,24332,24334,6439,6059,23147,5947,23364,34324,30205,34912,
24702,10336,9771,24539,16056,9647,9662,37000,28531,25024,62,70,9755,24985,
24984,24693,11419,11527,18132,37197,25713,18021,11114,14889,11042,13392,39146,
11896,25399,42075,25782,25393,25553,18915,11623,25252,11425,25659,25963,26994,
15348,12430,12973,18825,12971,21773,13024,6361,37951,26318,12937,12723,15072,
16784,21892,35618,21903,5884,21851,21541,30958,12547,6186,12852,13412,12815,
12674,17097,26254,27940,26219,19347,26160,30832,7659,26211,13010,13025,26142,
22642,14545,14394,14268,15257,14242,13310,29904,15254,26511,17962,26806,26654,
15300,27326,14435,14293,17543,27187,27218,27337,27397,6418,25873,26776,27212,
15319,27258,27479,16320,15514,37792,37618,35818,35531,37513,32798,35292,37991,
28069,28427,
18924,0,16255,15759,28164,16444,23101,28170,22599,27940,30786,28987,17178,
17014,28913,29264,29319,29332,18319,18213,20857,19108,1515,29818,16120,13919,
19018,18711,24545,16134,16049,19167,35875,16181,24743,16115,29900,29756,37767,
29751,17567,28138,17745,30083,16227,19673,19718,16216,30037,30323,42438,15129,
29800,35532,18859,18830,15099,15821,19022,16127,18885,18675,37370,22322,37698,
35555,6244,20703,21025,20967,30584,12850,30478,30479,30587,18071,14209,14942,
18672,29752,29851,16063,19130,19143,16584,19094,25006,37639,21889,30750,30861,
30856,30930,29648,31065,30529,22243,16654,0,33942,31141,27181,16122,31290,
31220,16750,5862,16690,37429,31217,3404,18828,665,15802,5998,13719,21867,
13680,13994,468,3085,31458,23129,9973,23215,23196,23053,603,30960,23082,23494,
31486,16889,31837,31853,16913,23475,24252,24230,31949,18937,6064,31886,31868,
31918,27314,32220,32263,32211,32590,25185,24924,31560,32151,24194,17002,27509,
2326,26582,78,13775,22468,25618,25592,18786,32733,31527,2092,23273,23875,
31500,24078,39398,34373,39523,27164,13375,14818,18935,26029,39455,26016,33920,
28967,27857,17642,33079,17410,32966,33033,33090,26548,39107,27202,33378,33381,
27217,33875,28071,34320,29211,23174,16767,6208,23339,6305,23268,6360,34464,
63932,15759,34861,29730,23042,34926,20293,34951,35007,35046,35173,35149,22147,
35156,30597,30596,35829,35801,35740,35321,16045,33955,18165,18127,14322,35389,
35356,37960,24397,37419,17028,26068,28969,28868,6213,40301,35999,36073,32220,
22938,30659,23024,17262,14036,36394,36519,19465,
36656,36682,17140,27736,28603,8993,18587,28537,28299,6106,39913,14005,18735,
37051,0,21873,18694,37307,37892,35403,16482,35580,37927,35869,35899,34021,
35371,38297,38311,38295,38294,36148,29765,16066,18687,19010,17386,16103,12837,
38543,36583,36454,36453,16076,18925,19064,16366,29714,29803,16124,38721,37040,
26695,18973,37011,22495,0,37736,35209,35878,35631,25534,37562,23313,35689,
18748,29689,16923,38811,38769,39224,3878,24001,35781,19122,38943,38106,37622,
38359,37349,17600,35664,19047,35684,39132,35397,16128,37418,18725,33812,39227,
39245,31494,15869,39323,19311,39338,39516,35685,22728,27279,39457,23294,39471,
39153,19344,39240,39356,19389,19351,37757,22642,4866,22562,18872,5352,30788,
10015,15800,26821,15741,37976,14631,24912,10113,10603,24839,40015,40019,40059,
39989,39952,39807,39887,40493,39839,41461,41214,40225,19630,16644,40472,19632,
40204,41396,41197,41203,39215,40357,33981,28178,28639,27522,34300,17715,28068,
28292,28144,33824,34286,28160,14295,24676,31202,13724,13888,18733,18910,15714,
37851,37566,37704,703,30905,37495,37965,20452,13376,36964,21853,30781,30804,
30902,30795,5975,12745,18753,13978,20338,28634,28633,0,28702,21524,16821,
22459,22771,22410,40214,22487,28980,13487,16812,29163,27712,20375,0,6069,
35401,24844,23246,23051,17084,17544,14124,19323,35324,37819,37816,6358,3869,
33906,27840,5139,17146,11302,17345,22932,15799,26433,32168,24923,24740,18873,
18827,35322,37605,29666,16105,29876,35683,6303,16097,19123,27352,29683,29691,
16086,19006,19092,6105,19046,935,5156,18917,29768,
18710,28837,18806,37508,29670,37727,1278,37681,35534,35350,37766,35815,21973,
18741,35458,29035,18755,3327,22180,1562,3051,3256,21762,31172,6138,32254,5826,
19024,6226,17710,37889,14090,35520,18861,22960,6335,6275,29828,23201,14050,
15707,14000,37471,23161,35457,6242,37748,15565,2740,19094,14730,20724,15721,
15692,5020,29045,17147,33304,28175,37092,17643,27991,32335,28775,27823,15574,
16365,15917,28162,28428,15727,1013,30033,14012,13512,18048,16090,18545,22980,
37486,18750,36673,35868,27584,22546,22472,14038,5202,28926,17250,19057,12259,
4784,9149,26809,26983,5016,13541,31732,14047,35459,14294,13306,19615,27162,
13997,27831,33854,17631,17614,27942,27985,27778,28638,28439,28937,33597,5946,
33773,27776,28755,6107,22921,23170,6067,23137,23153,6405,16892,14125,23023,
5948,14023,29070,37776,26266,17061,23150,23083,17043,27179,16121,30518,17499,
17098,28957,16985,35297,20400,27944,23746,17614,32333,17341,27148,16982,4868,
28838,28979,17385,15781,27871,63525,19023,32357,23019,23855,15859,24412,19037,
6111,32164,33830,21637,15098,13056,532,22398,2261,1561,16357,8094,41654,28675,
37211,23920,29583,31955,35417,37920,20424,32743,29389,29456,31476,29496,29497,
22262,29505,29512,16041,31512,36972,29173,18674,29665,33270,16074,30476,16081,
27810,22269,29721,29726,29727,16098,16112,16116,16122,29907,16142,16211,30018,
30061,30066,30093,16252,30152,30172,16320,30285,16343,30324,16348,30330,20316,
29064,22051,35200,22633,16413,30531,16441,26465,16453,13787,30616,16490,16495,
23646,30654,30667,22770,30744,28857,30748,
16552,30777,30791,30801,30822,33864,21813,31027,26627,31026,16643,16649,31121,
31129,36795,31238,36796,16743,31377,16818,31420,33401,16836,31439,31451,16847,
20001,31586,31596,31611,31762,31771,16992,17018,31867,31900,17036,31928,17044,
31981,36755,28864,3279,32207,32212,32208,32253,32686,32692,29343,17303,32800,
32805,31545,32814,32817,32852,15820,22452,28832,32951,33001,17389,33036,29482,
33038,33042,30048,33044,17409,15161,33110,33113,33114,17427,22586,33148,33156,
17445,33171,17453,33189,22511,33217,33252,33364,17551,33446,33398,33482,33496,
33535,17584,33623,38505,27018,33797,28917,33892,24803,33928,17668,33982,34017,
34040,34064,34104,34130,17723,34159,34160,34272,17783,34418,34450,34482,34543,
38469,34699,17926,17943,34990,35071,35108,35143,35217,31079,35369,35384,35476,
35508,35921,36052,36082,36124,18328,22623,36291,18413,20206,36410,21976,22356,
36465,22005,36528,18487,36558,36578,36580,36589,36594,36791,36801,36810,36812,
36915,39364,18605,39136,37395,18718,37416,37464,37483,37553,37550,37567,37603,
37611,37619,37620,37629,37699,37764,37805,18757,18769,40639,37911,21249,37917,
37933,37950,18794,37972,38009,38189,38306,18855,38388,38451,18917,26528,18980,
38720,18997,38834,38850,22100,19172,24808,39097,19225,39153,22596,39182,39193,
20916,39196,39223,39234,39261,39266,19312,39365,19357,39484,39695,31363,39785,
39809,39901,39921,39924,19565,39968,14191,7106,40265,39994,40702,22096,40339,
40381,40384,40444,38134,36790,40571,40620,40625,40637,40646,38108,40674,40689,
40696,31432,40772,148,695,928,26906,38083,22956,
1239,22592,38081,14265,1493,1557,1654,5818,22359,29043,2754,2765,3007,21610,
63547,3019,21662,3067,3131,3155,3173,3196,24807,3213,22138,3253,3293,3309,
3439,3506,3528,26965,39983,34725,3588,3598,3799,3984,3885,3699,23584,4028,
24075,4188,4175,4214,26398,4219,4232,4246,13895,4287,4307,4399,4411,21348,
33965,4835,4981,4918,35713,5495,5657,6083,6087,20088,28859,6189,6506,6701,
6725,7210,7280,7340,7880,25283,7893,7957,29080,26709,8261,27113,14024,8828,
9175,9210,10026,10353,10575,33533,10599,10643,10965,35237,10984,36768,11022,
38840,11071,38983,39613,11340,0,11400,11447,23528,11528,11538,11703,11669,
11842,12148,12236,12339,12390,13087,13278,24497,26184,26303,31353,13671,13811,
0,18874,0,13850,14102,0,838,22709,26382,26904,15015,30295,24546,15889,16057,
30206,8346,18640,19128,16665,35482,17134,17165,16443,17204,17302,19013,1482,
20946,1553,22943,7848,15294,15615,17412,17622,22408,18036,14747,18223,34280,
39369,14178,8643,35678,35662,0,18450,18683,18965,29193,19136,3192,22885,20133,
20358,1913,36570,20524,21135,22335,29041,21145,21529,16202,19111,21948,21574,
21614,27474,0,13427,21823,30258,21854,18200,21858,21862,22471,18751,22621,
20582,13563,13260,0,22787,18300,35144,23214,23433,23558,7568,22433,29009,0,
24834,31762,36950,25010,20378,35682,25602,25674,23899,27639,0,25732,6428,
35562,18934,25736,16367,25874,19392,26047,26293,10011,37989,22497,24981,23079,
63693,0,22201,17697,26364,20074,18740,38486,28047,27837,13848,35191,
26521,26734,25617,26718,0,26823,31554,37056,2577,26918,0,26937,31301,0,27130,
39462,27181,13919,25705,33,31107,27188,27483,23852,13593,0,27549,18128,27812,
30011,34917,28078,22710,14108,9613,28747,29133,15444,29312,29317,37505,8570,
29323,37680,29414,18896,27705,38047,29776,3832,34855,35061,10534,33907,6065,
28344,18986,6176,14756,14009,0,0,17727,26294,40109,39076,35139,30668,30808,
22230,16607,5642,14753,14127,33000,5061,29101,33638,31197,37288,0,19639,28847,
35243,31229,31242,31499,32102,16762,31555,31102,32777,28597,41695,27139,33560,
21410,28167,37823,26678,38749,33135,32803,27061,5101,12847,32840,23941,35888,
32899,22293,38947,35145,23979,18824,26046,27093,21458,19109,16257,15377,26422,
32912,33012,33070,8097,33103,33161,33199,33306,33542,33583,33674,13770,33896,
34474,18682,25574,35158,30728,37461,35256,17394,35303,17375,35304,35654,35796,
23032,35849,0,36805,37100,0,37136,37180,15863,37214,19146,36816,29327,22155,
38119,38377,38320,38328,38706,39121,39241,39274,39363,39464,39694,40282,40347,
32415,40696,40739,19620,38215,41619,29090,41727,19857,36882,42443,19868,3228,
36798,21953,36794,9392,36793,19091,17673,32383,28502,27313,20202,13540,35628,
30877,14138,36480,6133,32804,35692,35737,31294,26287,15851,30293,15543,22069,
22870,20122,24193,25176,22207,3693,36366,23405,16008,19614,25566,0,6134,6267,
25904,22061,23626,21530,21265,15814,40344,19581,22050,22046,32585,24280,22901,
15680,34672,19996,4074,3401,14010,33047,40286,36120,30267,40005,30286,30649,
37701,21554,
33096,33527,22053,33074,33816,32957,21994,31074,22083,21526,3741,13774,22021,
22001,26353,33506,13869,30004,22000,21946,21655,21874,3137,3222,24272,20808,
3702,11362,3746,40619,32090,21982,4213,25245,38765,21652,36045,29174,37238,
25596,25529,25598,21865,11075,40050,11955,20890,13535,3495,20903,21581,21790,
21779,30310,36397,26762,30129,32950,34820,34694,35015,33206,33820,4289,17644,
29444,18182,23440,33547,26771,22139,9972,32047,16803,32115,28368,29366,37232,
4569,37384,15612,42665,3756,3833,29286,7330,18254,20418,32761,4075,16634,
40029,25887,11680,18675,18400,40316,4076,3594,0,30115,4077,0,24648,4487,29091,
32398,40272,19994,19972,13687,23309,27826,21351,13996,14812,21373,13989,17944,
22682,19310,33325,21579,22442,23189,2425,0,14930,9317,29556,40620,19721,39917,
15614,40752,19547,20393,38302,40926,33884,15798,29362,26547,14112,25390,32037,
16119,15916,14890,36872,21196,15988,13946,17897,1166,30272,23280,3766,30842,
32558,22695,16575,22140,39819,23924,30292,42036,40581,19681,0,14331,24857,
12506,17394,0,22109,4777,22439,18787,40454,21044,28846,13741,0,40316,31830,
39737,22494,5996,23635,25811,38096,25397,29028,34477,3368,27938,19170,3441,0,
20990,7951,23950,38659,7633,40577,36940,31519,39682,23761,31651,25192,25397,
39679,31695,39722,31870,0,31810,31878,39957,31740,39689,0,39963,18750,40794,
21875,23491,20477,40600,20466,21088,15878,21201,22375,20566,22967,24082,38856,
40363,36700,21609,38836,39232,38842,21292,24880,26924,21466,39946,40194,19515,
38465,27008,20646,
30022,5997,39386,21107,0,37209,38529,37212,0,37201,36503,25471,27939,27338,
22033,37262,30074,25221,1020,29519,31856,23585,15613,0,18713,30422,39837,
20010,3284,33726,34882,0,23626,27072,0,22394,21023,24053,20174,27697,498,
20281,21660,21722,21146,36226,13822,0,13811,0,27474,37244,40869,39831,38958,
39092,39610,40616,40580,29050,31508,0,27642,34840,32632,0,22048,42570,36471,
40787,0,36308,36431,40476,36353,25218,33661,36392,36469,31443,19063,31294,
30936,27882,35431,30215,35418,40742,27854,34774,30147,41650,30803,63552,36108,
29410,29553,35629,29442,29937,36075,19131,34351,24506,34976,17591,0,6203,
28165,0,35454,9499,0,24829,30311,39639,40260,37742,39823,34805,0,0,36087,
29484,38689,39856,13782,29362,19463,31825,39242,24921,24921,19460,40598,24957,
0,22367,24943,25254,25145,0,14940,25058,21418,13301,25444,26626,13778,23895,
35778,36826,36409,0,20697,7494,30982,21298,38456,3899,16485,0,30718,0,31938,
24346,31962,31277,32870,32867,32077,29957,29938,35220,33306,26380,32866,29830,
32859,29936,33027,30500,35209,26572,30035,28369,34729,34766,33224,34700,35401,
36013,35651,30507,29944,34010,13877,27058,36262,0,35241,0,28089,34753,16401,
29927,15835,29046,24740,24988,15569,0,24695,0,32625,35629,0,24809,19326,21024,
15384,15559,24279,30294,21809,6468,4862,39171,28124,28845,23745,25005,35343,
13943,238,26694,20238,17762,23327,25420,40784,40614,25195,1351,37595,1503,
16325,34124,17077,29679,20917,13897,18754,35300,37700,6619,
33518,15560,30780,26436,25311,18739,35242,672,27571,4869,20395,9453,20488,
27945,31364,13824,19121,9491,0,894,24484,896,839,28379,1055,0,20737,13434,
20750,39020,14147,33814,18852,1159,20832,13236,20842,3071,8444,741,9520,1422,
12851,6531,23426,34685,1459,15513,20914,20920,40244,20937,20943,20945,15580,
20947,19110,20915,20962,21314,20973,33741,26942,14125,24443,21003,21030,21052,
21173,21079,21140,21177,21189,31765,34114,21216,34317,27411,0,35550,21833,
28377,16256,2388,16364,21299,0,3042,27851,5926,26651,29653,24650,16042,14540,
5864,29149,17570,21357,21364,34475,21374,0,5526,5651,30694,21395,35483,21408,
21419,21422,29607,22386,16217,29596,21441,21445,27721,20041,22526,21465,15019,
2959,21472,16363,11683,21494,3191,21523,28793,21803,26199,27995,21613,27475,
3444,21853,21647,21668,18342,5901,3805,15796,3405,35260,9880,21831,19693,
21551,29719,21894,21929,0,6359,16442,17746,17461,26291,4276,22071,26317,12938,
26276,26285,22093,22095,30961,22257,38791,21502,22272,22255,22253,35686,13859,
4687,22342,16805,27758,28811,22338,14001,27774,22502,5142,22531,5204,17251,
22566,19445,22620,22698,13665,22752,22748,4668,22779,23551,22339,41296,17016,
37843,13729,22815,26790,14019,28249,5694,23076,21843,5778,34053,22985,3406,
27777,27946,6108,23001,6139,6066,28070,28017,6184,5845,23033,28229,23211,
23139,14054,18857,0,14088,23190,29797,23251,28577,9556,15749,6417,14130,5816,
24195,21200,23414,25992,23420,31246,16388,18525,516,23509,24928,6708,22988,
1445,23539,
23453,19728,23557,6980,23571,29646,23572,7333,27432,23625,18653,23685,23785,
23791,23947,7673,7735,23824,23832,23878,7844,23738,24023,33532,14381,18689,
8265,8563,33415,14390,15298,24110,27274,0,24186,17596,3283,21414,20151,0,
21416,6001,24073,24308,33922,24313,24315,14496,24316,26686,37915,24333,449,
63636,15070,18606,4922,24378,26760,9168,0,9329,24419,38845,28270,24434,37696,
35382,24487,23990,15711,21072,8042,28920,9832,37334,670,35369,24625,26245,
6263,14691,15815,13881,22416,10164,31089,15936,24734,0,24755,18818,18831,
31315,29860,20705,23200,24932,33828,24898,63654,28370,24961,20980,1622,24967,
23466,16311,10335,25043,35741,39261,25040,14642,10624,10433,24611,24924,25886,
25483,280,25285,6000,25301,11789,25452,18911,14871,25656,25592,5006,6140,0,
28554,11830,38932,16524,22301,25825,25829,38011,14950,25658,14935,25933,28438,
18984,18979,25989,25965,25951,12414,26037,18752,19255,26065,16600,6185,26080,
26083,24543,13312,26136,12791,12792,26180,12708,12709,26187,3701,26215,20966,
26227,0,7741,12849,34292,12744,21267,30661,10487,39332,26370,17308,18977,
15147,27130,14274,0,26471,26466,16845,37101,26583,17641,26658,28240,37436,
26625,13286,28064,26717,13423,27105,27147,35551,26995,26819,13773,26881,26880,
15666,14849,13884,15232,26540,26977,35402,17148,26934,27032,15265,969,33635,
20624,27129,13913,8490,27205,14083,27293,15347,26545,27336,37276,15373,27421,
2339,24798,27445,27508,10189,28341,15067,949,6488,14144,21537,15194,27617,
16124,27612,27703,9355,18673,27473,
27738,33318,27769,15804,17605,15805,16804,18700,18688,15561,14053,15595,3378,
39811,12793,9361,32655,26679,27941,28065,28139,28054,27996,28284,28420,18815,
16517,28274,34099,28532,20935,0,0,33838,35617,0,15919,29779,16258,31180,28239,
23185,12363,28664,14093,28573,15920,28410,5271,16445,17749,37872,28484,28508,
15694,28532,37232,15675,28575,16708,28627,16529,16725,16441,16368,16308,16703,
20959,16726,16727,16704,25053,28747,28798,28839,28801,28876,28885,28886,28895,
16644,15848,29108,29078,17015,28971,28997,23176,29002,0,23708,17253,29007,
37730,17089,28972,17498,18983,18978,29114,35816,28861,29198,37954,29205,22801,
37955,29220,37697,22021,29230,29248,18804,26813,29269,29271,15957,12356,26637,
28477,29314,0,29483,18467,34859,18669,34820,29480,29486,29647,29610,3130,
27182,29641,29769,16866,5863,18980,26147,14021,18871,18829,18939,29687,29717,
26883,18982,29753,1475,16087,0,10413,29792,36530,29767,29668,29814,33721,
29804,14128,29812,37873,27180,29826,18771,19084,16735,19065,35727,23366,35843,
6302,29896,6536,29966,0,29982,36569,6731,23511,36524,37765,30029,30026,30055,
30062,20354,16132,19731,30094,29789,30110,30132,30210,30252,30289,30287,30319,
30326,25589,30352,33263,14328,26897,26894,30369,30373,30391,30412,28575,33890,
20637,20861,7708,30494,30502,30528,25775,21024,30552,12972,30639,35172,35176,
5825,30708,0,4982,18962,26826,30895,30919,30931,38565,31022,21984,30935,31028,
30897,30220,36792,34948,35627,24707,9756,31110,35072,26882,31104,22615,31133,
31545,31036,31145,28202,28966,
16040,31174,37133,31188,1312,17503,21007,47234,248,16384,43296,1102,0,0,2868,
1,0,0,0,0,0,0,0,3072,64,0,0,0,1024,88,60,0,0,23680,56493,48115,17353,60910,
4004,49446,30363,61426,64478,63482,12815,44868,61438,65277,24593,176,8448,
33049,4128,43144,8544,9321,17408,50313,0,16387,53,33859,20785,26771,514,0,0,0,
0,0,16384,256,44160,33380,35904,37025,20484,54368,53760,6186,26781,38709,
55375,8440,33476,10268,30082,660,16440,41376,4293,19825,3524,47512,23390,
17153,39327,30723,57888,2079,393,16585,775,39437,21136,20433,892,8450,49184,
4974,46467,62939,30693,20368,39447,5942,12,47726,12041,21600,7680,26744,28706,
40534,62245,46990,2839,59119,6007,7003,4289,36248,6162,53174,12545,6770,11355,
49334,57888,23747,7042,56032,34254,16598,21673,53259,18447,16452,2320,16596,
15278,7780,11076,2071,33414,6198,35232,40167,2139,900,55810,60560,34779,49029,
44450,36509,39069,9504,70,40774,58239,51669,62596,19926,58118,6326,2322,0,
1024,0,32,0,512,0,0,0,0,8192,0,0,0,0,0,0,8,36352,28280,16223,56702,63293,
39932,44796,65490,27535,59377,47807,28334,61207,42972,46654,30645,37577,42455,
19126,39790,33209,26445,21758,39921,65122,21103,14039,49150,17705,63873,26045,
17062,57,16896,36704,37888,16448,45010,53719,219,39072,31666,20998,38944,
51222,2365,0,1,0,2561,2226,128,0,34820,5152,19472,0,4,17569,16,321,
2048,61504,20447,22582,62961,32949,26613,16512,20480,16718,33992,23040,55392,
11009,20481,5793,16580,28402,44049,14624,49348,1800,2316,38552,39876,7184,
27800,10886,422,4422,58733,50379,37568,8464,4630,29341,27124,5902,41514,62593,
123,41992,36875,11280,14796,330,5872,2571,3136,59933,17420,17678,2,

726
libc/stdio/iconv.c Normal file
View file

@ -0,0 +1,726 @@
/*-*- 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
Musl Libc
Copyright © 2005-2014 Rich Felker, et al.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "libc/errno.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/gettls.h"
#include "libc/stdio/iconv.h"
#include "libc/str/str.h"
#include "libc/thread/thread.h"
#include "libc/unicode/locale.h"
// clang-format off
asm(".ident\t\"\\n\\n\
Musl libc (MIT License)\\n\
Copyright 2005-2014 Rich Felker, et. al.\"");
asm(".include \"libc/disclaimer.inc\"");
#define UTF_32BE 0300
#define UTF_16LE 0301
#define UTF_16BE 0302
#define UTF_32LE 0303
#define UCS2BE 0304
#define UCS2LE 0305
#define WCHAR_T 0306
#define US_ASCII 0307
#define UTF_8 0310
#define UTF_16 0312
#define UTF_32 0313
#define UCS2 0314
#define EUC_JP 0320
#define SHIFT_JIS 0321
#define ISO2022_JP 0322
#define GB18030 0330
#define GBK 0331
#define GB2312 0332
#define BIG5 0340
#define EUC_KR 0350
/* Definitions of charmaps. Each charmap consists of:
* 1. Empty-string-terminated list of null-terminated aliases.
* 2. Special type code or number of elided quads of entries.
* 3. Character table (size determined by field 2), consisting
* of 5 bytes for every 4 characters, interpreted as 10-bit
* indices into the legacy_chars table. */
static const unsigned char charmaps[] =
"utf8\0char\0\0\310"
"wchart\0\0\306"
"ucs2be\0\0\304"
"ucs2le\0\0\305"
"utf16be\0\0\302"
"utf16le\0\0\301"
"ucs4be\0utf32be\0\0\300"
"ucs4le\0utf32le\0\0\303"
"ascii\0usascii\0iso646\0iso646us\0\0\307"
"utf16\0\0\312"
"ucs4\0utf32\0\0\313"
"ucs2\0\0\314"
"eucjp\0\0\320"
"shiftjis\0sjis\0\0\321"
"iso2022jp\0\0\322"
"gb18030\0\0\330"
"gbk\0\0\331"
"gb2312\0\0\332"
"big5\0bigfive\0cp950\0big5hkscs\0\0\340"
"euckr\0ksc5601\0ksx1001\0cp949\0\0\350"
#include "libc/stdio/codepages.inc"
;
#pragma GCC diagnostic ignored "-Wmissing-braces"
/* Table of characters that appear in legacy 8-bit codepages,
* limited to 1024 slots (10 bit indices). The first 256 entries
* are elided since those characters are obviously all included. */
static const unsigned short legacy_chars[] = {
#include "libc/stdio/legacychars.inc"
};
static const unsigned short jis0208[84][94] = {
#include "libc/stdio/jis0208.inc"
};
static const unsigned short gb18030[126][190] = {
#include "libc/stdio/gb18030.inc"
};
static const unsigned short big5[89][157] = {
#include "libc/stdio/big5.inc"
};
static const unsigned short hkscs[] = {
#include "libc/stdio/hkscs.inc"
};
static const unsigned short ksc[93][94] = {
#include "libc/stdio/ksc.inc"
};
static const unsigned short rev_jis[] = {
#include "libc/stdio/revjis.inc"
};
static int fuzzycmp(const unsigned char *a, const unsigned char *b)
{
for (; *a && *b; a++, b++) {
while (*a && (*a|32U)-'a'>26 && *a-'0'>10U) a++;
if ((*a|32U) != *b) return 1;
}
return *a != *b;
}
static size_t find_charmap(const void *name)
{
const unsigned char *s;
if (!*(char *)name) name=charmaps; /* "utf8" */
for (s=charmaps; *s; ) {
if (!fuzzycmp(name, s)) {
for (; *s; s+=strlen((void *)s)+1);
return s+1-charmaps;
}
s += strlen((void *)s)+1;
if (!*s) {
if (s[1] > 0200) s+=2;
else s+=2+(64U-s[1])*5;
}
}
return -1;
}
struct stateful_cd {
iconv_t base_cd;
unsigned state;
};
static iconv_t combine_to_from(size_t t, size_t f)
{
return (void *)(f<<16 | t<<1 | 1);
}
static size_t extract_from(iconv_t cd)
{
return (size_t)cd >> 16;
}
static size_t extract_to(iconv_t cd)
{
return (size_t)cd >> 1 & 0x7fff;
}
iconv_t iconv_open(const char *to, const char *from)
{
size_t f, t;
struct stateful_cd *scd;
if ((t = find_charmap(to))==-1
|| (f = find_charmap(from))==-1
|| (charmaps[t] >= 0330)) {
errno = EINVAL;
return (iconv_t)-1;
}
iconv_t cd = combine_to_from(t, f);
switch (charmaps[f]) {
case UTF_16:
case UTF_32:
case UCS2:
case ISO2022_JP:
scd = malloc(sizeof *scd);
if (!scd) return (iconv_t)-1;
scd->base_cd = cd;
scd->state = 0;
cd = (iconv_t)scd;
}
return cd;
}
int iconv_close(iconv_t cd)
{
if (!((size_t)cd & 1)) free((void *)cd);
return 0;
}
static unsigned get_16(const unsigned char *s, int e)
{
e &= 1;
return s[e]<<8 | s[1-e];
}
static void put_16(unsigned char *s, unsigned c, int e)
{
e &= 1;
s[e] = c>>8;
s[1-e] = c;
}
static unsigned get_32(const unsigned char *s, int e)
{
e &= 3;
return s[e]+0U<<24 | s[e^1]<<16 | s[e^2]<<8 | s[e^3];
}
static void put_32(unsigned char *s, unsigned c, int e)
{
e &= 3;
s[e^0] = c>>24;
s[e^1] = c>>16;
s[e^2] = c>>8;
s[e^3] = c;
}
/* Adapt as needed */
#define mbrtowc_utf8 mbrtowc
#define wctomb_utf8 wctomb
static unsigned legacy_map(const unsigned char *map, unsigned c)
{
if (c < 4*map[-1]) return c;
unsigned x = c - 4*map[-1];
x = map[x*5/4]>>2*x%8 | map[x*5/4+1]<<8-2*x%8 & 1023;
return x < 256 ? x : legacy_chars[x-256];
}
static unsigned uni_to_jis(unsigned c)
{
unsigned nel = sizeof rev_jis / sizeof *rev_jis;
unsigned d, j, i, b = 0;
for (;;) {
i = nel/2;
j = rev_jis[b+i];
d = jis0208[j/256][j%256];
if (d==c) return j + 0x2121;
else if (nel == 1) return 0;
else if (c < d)
nel /= 2;
else {
b += i;
nel -= nel/2;
}
}
}
size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restrict out, size_t *restrict outb)
{
size_t x=0;
struct stateful_cd *scd=0;
if (!((size_t)cd & 1)) {
scd = (void *)cd;
cd = scd->base_cd;
}
unsigned to = extract_to(cd);
unsigned from = extract_from(cd);
const unsigned char *map = charmaps+from+1;
const unsigned char *tomap = charmaps+to+1;
mbstate_t st = {0};
wchar_t wc;
unsigned c, d;
size_t k, l;
int err;
unsigned char type = map[-1];
unsigned char totype = tomap[-1];
locale_t *ploc = &((cthread_t)__get_tls())->locale;
locale_t loc = *ploc;
if (!in || !*in || !*inb) return 0;
*ploc = 0; // TODO(jart): UTF8_LOCALE?
for (; *inb; *in+=l, *inb-=l) {
c = *(unsigned char *)*in;
l = 1;
switch (type) {
case UTF_8:
if (c < 128) break;
l = mbrtowc_utf8(&wc, *in, *inb, &st);
if (l == (size_t)-1) goto ilseq;
if (l == (size_t)-2) goto starved;
c = wc;
break;
case US_ASCII:
if (c >= 128) goto ilseq;
break;
case WCHAR_T:
l = sizeof(wchar_t);
if (*inb < l) goto starved;
c = *(wchar_t *)*in;
if (0) {
case UTF_32BE:
case UTF_32LE:
l = 4;
if (*inb < 4) goto starved;
c = get_32((void *)*in, type);
}
if (c-0xd800u < 0x800u || c >= 0x110000u) goto ilseq;
break;
case UCS2BE:
case UCS2LE:
case UTF_16BE:
case UTF_16LE:
l = 2;
if (*inb < 2) goto starved;
c = get_16((void *)*in, type);
if ((unsigned)(c-0xdc00) < 0x400) goto ilseq;
if ((unsigned)(c-0xd800) < 0x400) {
if (type-UCS2BE < 2U) goto ilseq;
l = 4;
if (*inb < 4) goto starved;
d = get_16((void *)(*in + 2), type);
if ((unsigned)(d-0xdc00) >= 0x400) goto ilseq;
c = ((c-0xd7c0)<<10) + (d-0xdc00);
}
break;
case UCS2:
case UTF_16:
l = 0;
if (!scd->state) {
if (*inb < 2) goto starved;
c = get_16((void *)*in, 0);
scd->state = type==UCS2
? c==0xfffe ? UCS2LE : UCS2BE
: c==0xfffe ? UTF_16LE : UTF_16BE;
if (c == 0xfffe || c == 0xfeff)
l = 2;
}
type = scd->state;
continue;
case UTF_32:
l = 0;
if (!scd->state) {
if (*inb < 4) goto starved;
c = get_32((void *)*in, 0);
scd->state = c==0xfffe0000 ? UTF_32LE : UTF_32BE;
if (c == 0xfffe0000 || c == 0xfeff)
l = 4;
}
type = scd->state;
continue;
case SHIFT_JIS:
if (c < 128) break;
if (c-0xa1 <= 0xdf-0xa1) {
c += 0xff61-0xa1;
break;
}
l = 2;
if (*inb < 2) goto starved;
d = *((unsigned char *)*in + 1);
if (c-129 <= 159-129) c -= 129;
else if (c-224 <= 239-224) c -= 193;
else goto ilseq;
c *= 2;
if (d-64 <= 158-64) {
if (d==127) goto ilseq;
if (d>127) d--;
d -= 64;
} else if (d-159 <= 252-159) {
c++;
d -= 159;
}
c = jis0208[c][d];
if (!c) goto ilseq;
break;
case EUC_JP:
if (c < 128) break;
l = 2;
if (*inb < 2) goto starved;
d = *((unsigned char *)*in + 1);
if (c==0x8e) {
c = d;
if (c-0xa1 > 0xdf-0xa1) goto ilseq;
c += 0xff61 - 0xa1;
break;
}
c -= 0xa1;
d -= 0xa1;
if (c >= 84 || d >= 94) goto ilseq;
c = jis0208[c][d];
if (!c) goto ilseq;
break;
case ISO2022_JP:
if (c >= 128) goto ilseq;
if (c == '\033') {
l = 3;
if (*inb < 3) goto starved;
c = *((unsigned char *)*in + 1);
d = *((unsigned char *)*in + 2);
if (c != '(' && c != '$') goto ilseq;
switch (128*(c=='$') + d) {
case 'B': scd->state=0; continue;
case 'J': scd->state=1; continue;
case 'I': scd->state=4; continue;
case 128+'@': scd->state=2; continue;
case 128+'B': scd->state=3; continue;
}
goto ilseq;
}
switch (scd->state) {
case 1:
if (c=='\\') c = 0xa5;
if (c=='~') c = 0x203e;
break;
case 2:
case 3:
l = 2;
if (*inb < 2) goto starved;
d = *((unsigned char *)*in + 1);
c -= 0x21;
d -= 0x21;
if (c >= 84 || d >= 94) goto ilseq;
c = jis0208[c][d];
if (!c) goto ilseq;
break;
case 4:
if (c-0x60 < 0x1f) goto ilseq;
if (c-0x21 < 0x5e) c += 0xff61-0x21;
break;
}
break;
case GB2312:
if (c < 128) break;
if (c < 0xa1) goto ilseq;
case GBK:
case GB18030:
if (c < 128) break;
c -= 0x81;
if (c >= 126) goto ilseq;
l = 2;
if (*inb < 2) goto starved;
d = *((unsigned char *)*in + 1);
if (d < 0xa1 && type == GB2312) goto ilseq;
if (d-0x40>=191 || d==127) {
if (d-'0'>9 || type != GB18030)
goto ilseq;
l = 4;
if (*inb < 4) goto starved;
c = (10*c + d-'0') * 1260;
d = *((unsigned char *)*in + 2);
if (d-0x81>126) goto ilseq;
c += 10*(d-0x81);
d = *((unsigned char *)*in + 3);
if (d-'0'>9) goto ilseq;
c += d-'0';
c += 128;
for (d=0; d<=c; ) {
k = 0;
for (int i=0; i<126; i++)
for (int j=0; j<190; j++)
if (gb18030[i][j]-d <= c-d)
k++;
d = c+1;
c += k;
}
break;
}
d -= 0x40;
if (d>63) d--;
c = gb18030[c][d];
break;
case BIG5:
if (c < 128) break;
l = 2;
if (*inb < 2) goto starved;
d = *((unsigned char *)*in + 1);
if (d-0x40>=0xff-0x40 || d-0x7f<0xa1-0x7f) goto ilseq;
d -= 0x40;
if (d > 0x3e) d -= 0x22;
if (c-0xa1>=0xfa-0xa1) {
if (c-0x87>=0xff-0x87) goto ilseq;
if (c < 0xa1) c -= 0x87;
else c -= 0x87 + (0xfa-0xa1);
c = (hkscs[4867+(c*157+d)/16]>>(c*157+d)%16)%2<<17
| hkscs[c*157+d];
/* A few HKSCS characters map to pairs of UCS
* characters. These are mapped to surrogate
* range in the hkscs table then hard-coded
* here. Ugly, yes. */
if (c/256 == 0xdc) {
union {
char c[8];
wchar_t wc[2];
} tmp;
char *ptmp = tmp.c;
size_t tmpx = iconv(combine_to_from(to, find_charmap("utf8")),
&(char *){"\303\212\314\204"
"\303\212\314\214"
"\303\252\314\204"
"\303\252\314\214"
+c%256}, &(size_t){4},
&ptmp, &(size_t){sizeof tmp});
size_t tmplen = ptmp - tmp.c;
if (tmplen > *outb) goto toobig;
if (tmpx) x++;
memcpy(*out, &tmp, tmplen);
*out += tmplen;
*outb -= tmplen;
continue;
}
if (!c) goto ilseq;
break;
}
c -= 0xa1;
c = big5[c][d]|(c==0x27&&(d==0x3a||d==0x3c||d==0x42))<<17;
if (!c) goto ilseq;
break;
case EUC_KR:
if (c < 128) break;
l = 2;
if (*inb < 2) goto starved;
d = *((unsigned char *)*in + 1);
c -= 0xa1;
d -= 0xa1;
if (c >= 93 || d >= 94) {
c += (0xa1-0x81);
d += 0xa1;
if (c >= 93 || c>=0xc6-0x81 && d>0x52)
goto ilseq;
if (d-'A'<26) d = d-'A';
else if (d-'a'<26) d = d-'a'+26;
else if (d-0x81<0xff-0x81) d = d-0x81+52;
else goto ilseq;
if (c < 0x20) c = 178*c + d;
else c = 178*0x20 + 84*(c-0x20) + d;
c += 0xac00;
for (d=0xac00; d<=c; ) {
k = 0;
for (int i=0; i<93; i++)
for (int j=0; j<94; j++)
if (ksc[i][j]-d <= c-d)
k++;
d = c+1;
c += k;
}
break;
}
c = ksc[c][d];
if (!c) goto ilseq;
break;
default:
if (!c) break;
c = legacy_map(map, c);
if (!c) goto ilseq;
}
switch (totype) {
case WCHAR_T:
if (*outb < sizeof(wchar_t)) goto toobig;
*(wchar_t *)*out = c;
*out += sizeof(wchar_t);
*outb -= sizeof(wchar_t);
break;
case UTF_8:
if (*outb < 4) {
char tmp[4];
k = wctomb_utf8(tmp, c);
if (*outb < k) goto toobig;
memcpy(*out, tmp, k);
} else k = wctomb_utf8(*out, c);
*out += k;
*outb -= k;
break;
case US_ASCII:
if (c > 0x7f) subst: x++, c='*';
default:
if (*outb < 1) goto toobig;
if (c<256 && c==legacy_map(tomap, c)) {
revout:
if (*outb < 1) goto toobig;
*(*out)++ = c;
*outb -= 1;
break;
}
d = c;
for (c=4*totype; c<256; c++) {
if (d == legacy_map(tomap, c)) {
goto revout;
}
}
goto subst;
case SHIFT_JIS:
if (c < 128) goto revout;
if (c == 0xa5) {
x++;
c = '\\';
goto revout;
}
if (c == 0x203e) {
x++;
c = '~';
goto revout;
}
if (c-0xff61 <= 0xdf-0xa1) {
c += 0xa1 - 0xff61;
goto revout;
}
c = uni_to_jis(c);
if (!c) goto subst;
if (*outb < 2) goto toobig;
d = c%256;
c = c/256;
*(*out)++ = (c+1)/2 + (c<95 ? 112 : 176);
*(*out)++ = c%2 ? d + 31 + d/96 : d + 126;
*outb -= 2;
break;
case EUC_JP:
if (c < 128) goto revout;
if (c-0xff61 <= 0xdf-0xa1) {
c += 0x0e00 + 0x21 - 0xff61;
} else {
c = uni_to_jis(c);
}
if (!c) goto subst;
if (*outb < 2) goto toobig;
*(*out)++ = c/256 + 0x80;
*(*out)++ = c%256 + 0x80;
*outb -= 2;
break;
case ISO2022_JP:
if (c < 128) goto revout;
if (c-0xff61 <= 0xdf-0xa1 || c==0xa5 || c==0x203e) {
if (*outb < 7) goto toobig;
*(*out)++ = '\033';
*(*out)++ = '(';
if (c==0xa5) {
*(*out)++ = 'J';
*(*out)++ = '\\';
} else if (c==0x203e) {
*(*out)++ = 'J';
*(*out)++ = '~';
} else {
*(*out)++ = 'I';
*(*out)++ = c-0xff61+0x21;
}
*(*out)++ = '\033';
*(*out)++ = '(';
*(*out)++ = 'B';
*outb -= 7;
break;
}
c = uni_to_jis(c);
if (!c) goto subst;
if (*outb < 8) goto toobig;
*(*out)++ = '\033';
*(*out)++ = '$';
*(*out)++ = 'B';
*(*out)++ = c/256;
*(*out)++ = c%256;
*(*out)++ = '\033';
*(*out)++ = '(';
*(*out)++ = 'B';
*outb -= 8;
break;
case UCS2:
totype = UCS2BE;
case UCS2BE:
case UCS2LE:
case UTF_16:
case UTF_16BE:
case UTF_16LE:
if (c < 0x10000 || totype-UCS2BE < 2U) {
if (c >= 0x10000) c = 0xFFFD;
if (*outb < 2) goto toobig;
put_16((void *)*out, c, totype);
*out += 2;
*outb -= 2;
break;
}
if (*outb < 4) goto toobig;
c -= 0x10000;
put_16((void *)*out, (c>>10)|0xd800, totype);
put_16((void *)(*out + 2), (c&0x3ff)|0xdc00, totype);
*out += 4;
*outb -= 4;
break;
case UTF_32:
totype = UTF_32BE;
case UTF_32BE:
case UTF_32LE:
if (*outb < 4) goto toobig;
put_32((void *)*out, c, totype);
*out += 4;
*outb -= 4;
break;
}
}
*ploc = loc;
return x;
ilseq:
err = EILSEQ;
x = -1;
goto end;
toobig:
err = E2BIG;
x = -1;
goto end;
starved:
err = EINVAL;
x = -1;
end:
errno = err;
*ploc = loc;
return x;
}

14
libc/stdio/iconv.h Normal file
View file

@ -0,0 +1,14 @@
#ifndef COSMOPOLITAN_LIBC_STDIO_ICONV_H_
#define COSMOPOLITAN_LIBC_STDIO_ICONV_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
typedef void *iconv_t;
iconv_t iconv_open(const char *, const char *);
size_t iconv(iconv_t, char **, size_t *, char **, size_t *);
int iconv_close(iconv_t);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_ICONV_H_ */

563
libc/stdio/jis0208.inc Normal file
View file

@ -0,0 +1,563 @@
12288,12289,12290,65292,65294,12539,65306,65307,65311,65281,12443,12444,180,
65344,168,65342,65507,65343,12541,12542,12445,12446,12291,20189,12293,12294,
12295,12540,8213,8208,65295,92,12316,8214,65372,8230,8229,8216,8217,8220,8221,
65288,65289,12308,12309,65339,65341,65371,65373,12296,12297,12298,12299,12300,
12301,12302,12303,12304,12305,65291,8722,177,215,247,65309,8800,65308,65310,
8806,8807,8734,8756,9794,9792,176,8242,8243,8451,65509,65284,162,163,65285,
65283,65286,65290,65312,167,9734,9733,9675,9679,9678,9671,9670,9633,9632,9651,
9650,9661,9660,8251,12306,8594,8592,8593,8595,12307,0,0,0,0,0,0,0,0,0,0,0,
8712,8715,8838,8839,8834,8835,8746,8745,0,0,0,0,0,0,0,0,8743,8744,172,8658,
8660,8704,8707,0,0,0,0,0,0,0,0,0,0,0,8736,8869,8978,8706,8711,8801,8786,8810,
8811,8730,8765,8733,8757,8747,8748,0,0,0,0,0,0,0,8491,8240,9839,9837,9834,
8224,8225,182,0,0,0,0,9711,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65296,65297,65298,
65299,65300,65301,65302,65303,65304,65305,0,0,0,0,0,0,0,65313,65314,65315,
65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,65326,65327,65328,
65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,0,0,0,0,0,0,65345,
65346,65347,
65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,65360,
65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,0,0,0,0,12353,
12354,12355,12356,12357,12358,12359,12360,12361,12362,12363,12364,12365,12366,
12367,12368,12369,12370,12371,12372,12373,12374,12375,12376,12377,12378,12379,
12380,12381,12382,12383,12384,12385,12386,12387,12388,12389,12390,12391,12392,
12393,12394,12395,12396,12397,12398,12399,12400,12401,12402,12403,12404,12405,
12406,12407,12408,12409,12410,12411,12412,12413,12414,12415,12416,12417,12418,
12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,12431,
12432,12433,12434,12435,0,0,0,0,0,0,0,0,0,0,0,12449,12450,12451,12452,12453,
12454,12455,12456,12457,12458,12459,12460,12461,12462,12463,12464,12465,12466,
12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,12479,
12480,12481,12482,12483,12484,12485,12486,12487,12488,12489,12490,12491,12492,
12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,
12506,12507,12508,12509,12510,12511,12512,12513,12514,12515,12516,12517,12518,
12519,12520,12521,12522,12523,12524,12525,12526,12527,12528,12529,12530,12531,
12532,12533,12534,0,0,0,0,0,0,0,0,913,914,915,916,917,918,919,920,921,922,923,
924,925,926,927,928,929,931,932,933,934,935,936,937,0,0,0,0,0,0,0,0,945,946,
947,948,949,950,951,952,953,
954,955,956,957,958,959,960,961,963,964,965,966,967,968,969,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1040,1041,1042,1043,
1044,1045,1025,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,
1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081,
1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,
1097,1098,1099,1100,1101,1102,1103,0,0,0,0,0,0,0,0,0,0,0,0,0,9472,9474,9484,
9488,9496,9492,9500,9516,9508,9524,9532,9473,9475,9487,9491,9499,9495,9507,
9523,9515,9531,9547,9504,9519,9512,9527,9535,9501,9520,9509,9528,9538,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,20124,21782,23043,38463,21696,24859,25384,23030,
36898,33909,33564,31312,24746,25569,28197,26093,33894,33446,39925,26771,22311,
26017,25201,23451,22992,34427,39156,32098,32190,39822,25110,31903,34999,23433,
24245,25353,26263,26696,38343,38797,26447,20197,20234,20301,20381,20553,22258,
22839,22996,23041,23561,24799,24847,24944,26131,26885,28858,30031,30064,31227,
32173,32239,32963,33806,34915,35586,36949,36986,21307,20117,20133,22495,32946,
37057,30959,19968,22769,28322,36920,31282,33576,33419,39983,20801,21360,21693,
21729,22240,23035,24341,39154,28139,32996,34093,38498,38512,38560,38907,21515,
21491,23431,28879,32701,36802,38632,21359,40284,31418,19985,30867,33276,28198,
22040,21764,27421,34074,39995,23013,21417,28006,29916,38287,22082,20113,36939,
38642,33615,39180,21473,21942,23344,24433,26144,26355,26628,27704,27891,27945,
29787,30408,31310,38964,33521,34907,35424,37613,28082,30123,30410,39365,24742,
35585,36234,38322,27022,21421,20870,22290,22576,22852,23476,24310,24616,25513,
25588,27839,28436,28814,28948,29017,29141,29503,32257,33398,33489,34199,36960,
37467,40219,22633,26044,27738,29989,20985,22830,22885,24448,24540,25276,26106,
27178,27431,27572,29579,32705,35158,40236,40206,40644,23713,27798,33659,20740,
23627,25014,33222,26742,29281,20057,20474,21368,24681,28201,31311,38899,19979,
21270,20206,20309,20285,20385,20339,21152,21487,22025,22799,23233,23478,23521,
31185,26247,26524,26550,27468,27827,28779,29634,31117,31166,31292,31623,33457,
33499,33540,33655,33775,33747,34662,35506,22057,36008,36838,36942,38686,34442,
20420,23784,25105,29273,30011,33253,33469,34558,36032,38597,39187,39381,20171,
20250,35299,22238,22602,22730,24315,24555,24618,24724,24674,25040,25106,25296,
25913,39745,26214,26800,28023,28784,30028,30342,32117,33445,34809,38283,38542,
35997,20977,21182,22806,21683,23475,23830,24936,27010,28079,30861,33995,34903,
35442,37799,39608,28012,39336,34521,22435,26623,34510,37390,21123,22151,21508,
24275,25313,25785,26684,26680,27579,29554,30906,31339,35226,35282,36203,36611,
37101,38307,38548,38761,23398,23731,27005,38989,38990,25499,31520,27179,27263,
26806,39949,28511,21106,21917,24688,25324,27963,28167,28369,33883,35088,36676,
19988,39993,21494,26907,27194,38788,26666,20828,31427,33970,37340,37772,22107,
40232,26658,33541,33841,31909,21000,33477,29926,20094,
20355,20896,23506,21002,21208,21223,24059,21914,22570,23014,23436,23448,23515,
24178,24185,24739,24863,24931,25022,25563,25954,26577,26707,26874,27454,27475,
27735,28450,28567,28485,29872,29976,30435,30475,31487,31649,31777,32233,32566,
32752,32925,33382,33694,35251,35532,36011,36996,37969,38291,38289,38306,38501,
38867,39208,33304,20024,21547,23736,24012,29609,30284,30524,23721,32747,36107,
38593,38929,38996,39000,20225,20238,21361,21916,22120,22522,22855,23305,23492,
23696,24076,24190,24524,25582,26426,26071,26082,26399,26827,26820,27231,24112,
27589,27671,27773,30079,31048,23395,31232,32000,24509,35215,35352,36020,36215,
36556,36637,39138,39438,39740,20096,20605,20736,22931,23452,25135,25216,25836,
27450,29344,30097,31047,32681,34811,35516,35696,25516,33738,38816,21513,21507,
21931,26708,27224,35440,30759,26485,40653,21364,23458,33050,34384,36870,19992,
20037,20167,20241,21450,21560,23470,24339,24613,25937,26429,27714,27762,27875,
28792,29699,31350,31406,31496,32026,31998,32102,26087,29275,21435,23621,24040,
25298,25312,25369,28192,34394,35377,36317,37624,28417,31142,39770,20136,20139,
20140,20379,20384,20689,20807,31478,20849,20982,21332,21281,21375,21483,21932,
22659,23777,24375,24394,24623,24656,24685,25375,25945,27211,27841,29378,29421,
30703,33016,33029,33288,34126,37111,37857,38911,39255,39514,20208,20957,23597,
26241,26989,23616,26354,26997,29577,26704,31873,20677,21220,22343,24062,37670,
26020,27427,27453,29748,31105,31165,31563,32202,33465,33740,34943,35167,35641,
36817,37329,21535,37504,20061,20534,21477,21306,29399,
29590,30697,33510,36527,39366,39368,39378,20855,24858,34398,21936,31354,20598,
23507,36935,38533,20018,27355,37351,23633,23624,25496,31391,27795,38772,36705,
31402,29066,38536,31874,26647,32368,26705,37740,21234,21531,34219,35347,32676,
36557,37089,21350,34952,31041,20418,20670,21009,20804,21843,22317,29674,22411,
22865,24418,24452,24693,24950,24935,25001,25522,25658,25964,26223,26690,28179,
30054,31293,31995,32076,32153,32331,32619,33550,33610,34509,35336,35427,35686,
36605,38938,40335,33464,36814,39912,21127,25119,25731,28608,38553,26689,20625,
27424,27770,28500,31348,32080,34880,35363,26376,20214,20537,20518,20581,20860,
21048,21091,21927,22287,22533,23244,24314,25010,25080,25331,25458,26908,27177,
29309,29356,29486,30740,30831,32121,30476,32937,35211,35609,36066,36562,36963,
37749,38522,38997,39443,40568,20803,21407,21427,24187,24358,28187,28304,29572,
29694,32067,33335,35328,35578,38480,20046,20491,21476,21628,22266,22993,23396,
24049,24235,24359,25144,25925,26543,28246,29392,31946,34996,32929,32993,33776,
34382,35463,36328,37431,38599,39015,40723,20116,20114,20237,21320,21577,21566,
23087,24460,24481,24735,26791,27278,29786,30849,35486,35492,35703,37264,20062,
39881,20132,20348,20399,20505,20502,20809,20844,21151,21177,21246,21402,21475,
21521,21518,21897,22353,22434,22909,23380,23389,23439,24037,24039,24055,24184,
24195,24218,24247,24344,24658,24908,25239,25304,25511,25915,26114,26179,26356,
26477,26657,26775,27083,27743,27946,28009,28207,28317,30002,30343,30828,31295,
31968,32005,32024,32094,32177,32789,32771,32943,32945,
33108,33167,33322,33618,34892,34913,35611,36002,36092,37066,37237,37489,30783,
37628,38308,38477,38917,39321,39640,40251,21083,21163,21495,21512,22741,25335,
28640,35946,36703,40633,20811,21051,21578,22269,31296,37239,40288,40658,29508,
28425,33136,29969,24573,24794,39592,29403,36796,27492,38915,20170,22256,22372,
22718,23130,24680,25031,26127,26118,26681,26801,28151,30165,32058,33390,39746,
20123,20304,21449,21766,23919,24038,24046,26619,27801,29811,30722,35408,37782,
35039,22352,24231,25387,20661,20652,20877,26368,21705,22622,22971,23472,24425,
25165,25505,26685,27507,28168,28797,37319,29312,30741,30758,31085,25998,32048,
33756,35009,36617,38555,21092,22312,26448,32618,36001,20916,22338,38442,22586,
27018,32948,21682,23822,22524,30869,40442,20316,21066,21643,25662,26152,26388,
26613,31364,31574,32034,37679,26716,39853,31545,21273,20874,21047,23519,25334,
25774,25830,26413,27578,34217,38609,30352,39894,25420,37638,39851,30399,26194,
19977,20632,21442,23665,24808,25746,25955,26719,29158,29642,29987,31639,32386,
34453,35715,36059,37240,39184,26028,26283,27531,20181,20180,20282,20351,21050,
21496,21490,21987,22235,22763,22987,22985,23039,23376,23629,24066,24107,24535,
24605,25351,25903,23388,26031,26045,26088,26525,27490,27515,27663,29509,31049,
31169,31992,32025,32043,32930,33026,33267,35222,35422,35433,35430,35468,35566,
36039,36060,38604,39164,27503,20107,20284,20365,20816,23383,23546,24904,25345,
26178,27425,28363,27835,29246,29885,30164,30913,31034,32780,32819,33258,33940,
36766,27728,40575,24335,35672,40235,31482,36600,23437,
38635,19971,21489,22519,22833,23241,23460,24713,28287,28422,30142,36074,23455,
34048,31712,20594,26612,33437,23649,34122,32286,33294,20889,23556,25448,36198,
26012,29038,31038,32023,32773,35613,36554,36974,34503,37034,20511,21242,23610,
26451,28796,29237,37196,37320,37675,33509,23490,24369,24825,20027,21462,23432,
25163,26417,27530,29417,29664,31278,33131,36259,37202,39318,20754,21463,21610,
23551,25480,27193,32172,38656,22234,21454,21608,23447,23601,24030,20462,24833,
25342,27954,31168,31179,32066,32333,32722,33261,33311,33936,34886,35186,35728,
36468,36655,36913,37195,37228,38598,37276,20160,20303,20805,21313,24467,25102,
26580,27713,28171,29539,32294,37325,37507,21460,22809,23487,28113,31069,32302,
31899,22654,29087,20986,34899,36848,20426,23803,26149,30636,31459,33308,39423,
20934,24490,26092,26991,27529,28147,28310,28516,30462,32020,24033,36981,37255,
38918,20966,21021,25152,26257,26329,28186,24246,32210,32626,26360,34223,34295,
35576,21161,21465,22899,24207,24464,24661,37604,38500,20663,20767,21213,21280,
21319,21484,21736,21830,21809,22039,22888,22974,23100,23477,23558,23567,23569,
23578,24196,24202,24288,24432,25215,25220,25307,25484,25463,26119,26124,26157,
26230,26494,26786,27167,27189,27836,28040,28169,28248,28988,28966,29031,30151,
30465,30813,30977,31077,31216,31456,31505,31911,32057,32918,33750,33931,34121,
34909,35059,35359,35388,35412,35443,35937,36062,37284,37478,37758,37912,38556,
38808,19978,19976,19998,20055,20887,21104,22478,22580,22732,23330,24120,24773,
25854,26465,26454,27972,29366,30067,31331,33976,35698,
37304,37664,22065,22516,39166,25325,26893,27542,29165,32340,32887,33394,35302,
39135,34645,36785,23611,20280,20449,20405,21767,23072,23517,23529,24515,24910,
25391,26032,26187,26862,27035,28024,28145,30003,30137,30495,31070,31206,32051,
33251,33455,34218,35242,35386,36523,36763,36914,37341,38663,20154,20161,20995,
22645,22764,23563,29978,23613,33102,35338,36805,38499,38765,31525,35535,38920,
37218,22259,21416,36887,21561,22402,24101,25512,27700,28810,30561,31883,32736,
34928,36930,37204,37648,37656,38543,29790,39620,23815,23913,25968,26530,36264,
38619,25454,26441,26905,33733,38935,38592,35070,28548,25722,23544,19990,28716,
30045,26159,20932,21046,21218,22995,24449,24615,25104,25919,25972,26143,26228,
26866,26646,27491,28165,29298,29983,30427,31934,32854,22768,35069,35199,35488,
35475,35531,36893,37266,38738,38745,25993,31246,33030,38587,24109,24796,25114,
26021,26132,26512,30707,31309,31821,32318,33034,36012,36196,36321,36447,30889,
20999,25305,25509,25666,25240,35373,31363,31680,35500,38634,32118,33292,34633,
20185,20808,21315,21344,23459,23554,23574,24029,25126,25159,25776,26643,26676,
27849,27973,27927,26579,28508,29006,29053,26059,31359,31661,32218,32330,32680,
33146,33307,33337,34214,35438,36046,36341,36984,36983,37549,37521,38275,39854,
21069,21892,28472,28982,20840,31109,32341,33203,31950,22092,22609,23720,25514,
26366,26365,26970,29401,30095,30094,30990,31062,31199,31895,32032,32068,34311,
35380,38459,36961,40736,20711,21109,21452,21474,20489,21930,22766,22863,29245,
23435,23652,21277,24803,24819,25436,25475,25407,25531,
25805,26089,26361,24035,27085,27133,28437,29157,20105,30185,30456,31379,31967,
32207,32156,32865,33609,33624,33900,33980,34299,35013,36208,36865,36973,37783,
38684,39442,20687,22679,24974,33235,34101,36104,36896,20419,20596,21063,21363,
24687,25417,26463,28204,36275,36895,20439,23646,36042,26063,32154,21330,34966,
20854,25539,23384,23403,23562,25613,26449,36956,20182,22810,22826,27760,35409,
21822,22549,22949,24816,25171,26561,33333,26965,38464,39364,39464,20307,22534,
23550,32784,23729,24111,24453,24608,24907,25140,26367,27888,28382,32974,33151,
33492,34955,36024,36864,36910,38538,40667,39899,20195,21488,22823,31532,37261,
38988,40441,28381,28711,21331,21828,23429,25176,25246,25299,27810,28655,29730,
35351,37944,28609,35582,33592,20967,34552,21482,21481,20294,36948,36784,22890,
33073,24061,31466,36799,26842,35895,29432,40008,27197,35504,20025,21336,22022,
22374,25285,25506,26086,27470,28129,28251,28845,30701,31471,31658,32187,32829,
32966,34507,35477,37723,22243,22727,24382,26029,26262,27264,27573,30007,35527,
20516,30693,22320,24347,24677,26234,27744,30196,31258,32622,33268,34584,36933,
39347,31689,30044,31481,31569,33988,36880,31209,31378,33590,23265,30528,20013,
20210,23449,24544,25277,26172,26609,27880,34411,34935,35387,37198,37619,39376,
27159,28710,29482,33511,33879,36015,19969,20806,20939,21899,23541,24086,24115,
24193,24340,24373,24427,24500,25074,25361,26274,26397,28526,29266,30010,30522,
32884,33081,33144,34678,35519,35548,36229,36339,37530,38263,38914,40165,21189,
25431,30452,26389,27784,29645,36035,37806,38515,27941,
22684,26894,27084,36861,37786,30171,36890,22618,26626,25524,27131,20291,28460,
26584,36795,34086,32180,37716,26943,28528,22378,22775,23340,32044,29226,21514,
37347,40372,20141,20302,20572,20597,21059,35998,21576,22564,23450,24093,24213,
24237,24311,24351,24716,25269,25402,25552,26799,27712,30855,31118,31243,32224,
33351,35330,35558,36420,36883,37048,37165,37336,40718,27877,25688,25826,25973,
28404,30340,31515,36969,37841,28346,21746,24505,25764,36685,36845,37444,20856,
22635,22825,23637,24215,28155,32399,29980,36028,36578,39003,28857,20253,27583,
28593,30000,38651,20814,21520,22581,22615,22956,23648,24466,26007,26460,28193,
30331,33759,36077,36884,37117,37709,30757,30778,21162,24230,22303,22900,24594,
20498,20826,20908,20941,20992,21776,22612,22616,22871,23445,23798,23947,24764,
25237,25645,26481,26691,26812,26847,30423,28120,28271,28059,28783,29128,24403,
30168,31095,31561,31572,31570,31958,32113,21040,33891,34153,34276,35342,35588,
35910,36367,36867,36879,37913,38518,38957,39472,38360,20685,21205,21516,22530,
23566,24999,25758,27934,30643,31461,33012,33796,36947,37509,23776,40199,21311,
24471,24499,28060,29305,30563,31167,31716,27602,29420,35501,26627,27233,20984,
31361,26932,23626,40182,33515,23493,37193,28702,22136,23663,24775,25958,27788,
35930,36929,38931,21585,26311,37389,22856,37027,20869,20045,20970,34201,35598,
28760,25466,37707,26978,39348,32260,30071,21335,26976,36575,38627,27741,20108,
23612,24336,36841,21250,36049,32905,34425,24319,26085,20083,20837,22914,23615,
38894,20219,22922,24525,35469,28641,31152,31074,23527,
33905,29483,29105,24180,24565,25467,25754,29123,31896,20035,24316,20043,22492,
22178,24745,28611,32013,33021,33075,33215,36786,35223,34468,24052,25226,25773,
35207,26487,27874,27966,29750,30772,23110,32629,33453,39340,20467,24259,25309,
25490,25943,26479,30403,29260,32972,32954,36649,37197,20493,22521,23186,26757,
26995,29028,29437,36023,22770,36064,38506,36889,34687,31204,30695,33833,20271,
21093,21338,25293,26575,27850,30333,31636,31893,33334,34180,36843,26333,28448,
29190,32283,33707,39361,40614,20989,31665,30834,31672,32903,31560,27368,24161,
32908,30033,30048,20843,37474,28300,30330,37271,39658,20240,32624,25244,31567,
38309,40169,22138,22617,34532,38588,20276,21028,21322,21453,21467,24070,25644,
26001,26495,27710,27726,29256,29359,29677,30036,32321,33324,34281,36009,31684,
37318,29033,38930,39151,25405,26217,30058,30436,30928,34115,34542,21290,21329,
21542,22915,24199,24444,24754,25161,25209,25259,26000,27604,27852,30130,30382,
30865,31192,32203,32631,32933,34987,35513,36027,36991,38750,39131,27147,31800,
20633,23614,24494,26503,27608,29749,30473,32654,40763,26570,31255,21305,30091,
39661,24422,33181,33777,32920,24380,24517,30050,31558,36924,26727,23019,23195,
32016,30334,35628,20469,24426,27161,27703,28418,29922,31080,34920,35413,35961,
24287,25551,30149,31186,33495,37672,37618,33948,34541,39981,21697,24428,25996,
27996,28693,36007,36051,38971,25935,29942,19981,20184,22496,22827,23142,23500,
20904,24067,24220,24598,25206,25975,26023,26222,28014,29238,31526,33104,33178,
33433,35676,36000,36070,36212,38428,38468,20398,25771,
27494,33310,33889,34154,37096,23553,26963,39080,33914,34135,20239,21103,24489,
24133,26381,31119,33145,35079,35206,28149,24343,25173,27832,20175,29289,39826,
20998,21563,22132,22707,24996,25198,28954,22894,31881,31966,32027,38640,25991,
32862,19993,20341,20853,22592,24163,24179,24330,26564,20006,34109,38281,38491,
31859,38913,20731,22721,30294,30887,21029,30629,34065,31622,20559,22793,29255,
31687,32232,36794,36820,36941,20415,21193,23081,24321,38829,20445,33303,37610,
22275,25429,27497,29995,35036,36628,31298,21215,22675,24917,25098,26286,27597,
31807,33769,20515,20472,21253,21574,22577,22857,23453,23792,23791,23849,24214,
25265,25447,25918,26041,26379,27861,27873,28921,30770,32299,32990,33459,33804,
34028,34562,35090,35370,35914,37030,37586,39165,40179,40300,20047,20129,20621,
21078,22346,22952,24125,24536,24537,25151,26292,26395,26576,26834,20882,32033,
32938,33192,35584,35980,36031,37502,38450,21536,38956,21271,20693,21340,22696,
25778,26420,29287,30566,31302,37350,21187,27809,27526,22528,24140,22868,26412,
32763,20961,30406,25705,30952,39764,40635,22475,22969,26151,26522,27598,21737,
27097,24149,33180,26517,39850,26622,40018,26717,20134,20451,21448,25273,26411,
27819,36804,20397,32365,40639,19975,24930,28288,28459,34067,21619,26410,39749,
24051,31637,23724,23494,34588,28234,34001,31252,33032,22937,31885,27665,30496,
21209,22818,28961,29279,30683,38695,40289,26891,23167,23064,20901,21517,21629,
26126,30431,36855,37528,40180,23018,29277,28357,20813,26825,32191,32236,38754,
40634,25720,27169,33538,22916,23391,27611,29467,30450,
32178,32791,33945,20786,26408,40665,30446,26466,21247,39173,23588,25147,31870,
36016,21839,24758,32011,38272,21249,20063,20918,22812,29242,32822,37326,24357,
30690,21380,24441,32004,34220,35379,36493,38742,26611,34222,37971,24841,24840,
27833,30290,35565,36664,21807,20305,20778,21191,21451,23461,24189,24736,24962,
25558,26377,26586,28263,28044,29494,29495,30001,31056,35029,35480,36938,37009,
37109,38596,34701,22805,20104,20313,19982,35465,36671,38928,20653,24188,22934,
23481,24248,25562,25594,25793,26332,26954,27096,27915,28342,29076,29992,31407,
32650,32768,33865,33993,35201,35617,36362,36965,38525,39178,24958,25233,27442,
27779,28020,32716,32764,28096,32645,34746,35064,26469,33713,38972,38647,27931,
32097,33853,37226,20081,21365,23888,27396,28651,34253,34349,35239,21033,21519,
23653,26446,26792,29702,29827,30178,35023,35041,37324,38626,38520,24459,29575,
31435,33870,25504,30053,21129,27969,28316,29705,30041,30827,31890,38534,31452,
40845,20406,24942,26053,34396,20102,20142,20698,20001,20940,23534,26009,26753,
28092,29471,30274,30637,31260,31975,33391,35538,36988,37327,38517,38936,21147,
32209,20523,21400,26519,28107,29136,29747,33256,36650,38563,40023,40607,29792,
22593,28057,32047,39006,20196,20278,20363,20919,21169,23994,24604,29618,31036,
33491,37428,38583,38646,38666,40599,40802,26278,27508,21015,21155,28872,35010,
24265,24651,24976,28451,29001,31806,32244,32879,34030,36899,37676,21570,39791,
27347,28809,36034,36335,38706,21172,23105,24266,24324,26391,27004,27028,28010,
28431,29282,29436,31725,32769,32894,34635,37070,20845,
40595,31108,32907,37682,35542,20525,21644,35441,27498,36036,33031,24785,26528,
40434,20121,20120,39952,35435,34241,34152,26880,28286,30871,33109,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
24332,19984,19989,20010,20017,20022,20028,20031,20034,20054,20056,20098,20101,
35947,20106,33298,24333,20110,20126,20127,20128,20130,20144,20147,20150,20174,
20173,20164,20166,20162,20183,20190,20205,20191,20215,20233,20314,20272,20315,
20317,20311,20295,20342,20360,20367,20376,20347,20329,20336,20369,20335,20358,
20374,20760,20436,20447,20430,20440,20443,20433,20442,20432,20452,20453,20506,
20520,20500,20522,20517,20485,20252,20470,20513,20521,20524,20478,20463,20497,
20486,20547,20551,26371,20565,20560,20552,20570,20566,20588,20600,20608,20634,
20613,20660,20658,20681,20682,20659,20674,20694,20702,20709,20717,20707,20718,
20729,20725,20745,20737,20738,20758,20757,20756,20762,20769,20794,20791,20796,
20795,20799,20800,20818,20812,20820,20834,31480,20841,20842,20846,20864,20866,
22232,20876,20873,20879,20881,20883,20885,20886,20900,20902,20898,20905,20906,
20907,20915,20913,20914,20912,20917,20925,20933,20937,20955,20960,34389,20969,
20973,20976,20981,20990,20996,21003,21012,21006,21031,21034,21038,21043,21049,
21071,21060,21067,21068,21086,21076,21098,21108,21097,21107,21119,21117,21133,
21140,21138,21105,21128,21137,36776,36775,
21164,21165,21180,21173,21185,21197,21207,21214,21219,21222,39149,21216,21235,
21237,21240,21241,21254,21256,30008,21261,21264,21263,21269,21274,21283,21295,
21297,21299,21304,21312,21318,21317,19991,21321,21325,20950,21342,21353,21358,
22808,21371,21367,21378,21398,21408,21414,21413,21422,21424,21430,21443,31762,
38617,21471,26364,29166,21486,21480,21485,21498,21505,21565,21568,21548,21549,
21564,21550,21558,21545,21533,21582,21647,21621,21646,21599,21617,21623,21616,
21650,21627,21632,21622,21636,21648,21638,21703,21666,21688,21669,21676,21700,
21704,21672,21675,21698,21668,21694,21692,21720,21733,21734,21775,21780,21757,
21742,21741,21754,21730,21817,21824,21859,21836,21806,21852,21829,21846,21847,
21816,21811,21853,21913,21888,21679,21898,21919,21883,21886,21912,21918,21934,
21884,21891,21929,21895,21928,21978,21957,21983,21956,21980,21988,21972,22036,
22007,22038,22014,22013,22043,22009,22094,22096,29151,22068,22070,22066,22072,
22123,22116,22063,22124,22122,22150,22144,22154,22176,22164,22159,22181,22190,
22198,22196,22210,22204,22209,22211,22208,22216,22222,22225,22227,22231,22254,
22265,22272,22271,22276,22281,22280,22283,22285,22291,22296,22294,21959,22300,
22310,22327,22328,22350,22331,22336,22351,22377,22464,22408,22369,22399,22409,
22419,22432,22451,22436,22442,22448,22467,22470,22484,22482,22483,22538,22486,
22499,22539,22553,22557,22642,22561,22626,22603,22640,27584,22610,22589,22649,
22661,22713,22687,22699,22714,22750,22715,22712,22702,22725,22739,22737,22743,
22745,22744,22757,22748,22756,22751,22767,22778,22777,
22779,22780,22781,22786,22794,22800,22811,26790,22821,22828,22829,22834,22840,
22846,31442,22869,22864,22862,22874,22872,22882,22880,22887,22892,22889,22904,
22913,22941,20318,20395,22947,22962,22982,23016,23004,22925,23001,23002,23077,
23071,23057,23068,23049,23066,23104,23148,23113,23093,23094,23138,23146,23194,
23228,23230,23243,23234,23229,23267,23255,23270,23273,23254,23290,23291,23308,
23307,23318,23346,23248,23338,23350,23358,23363,23365,23360,23377,23381,23386,
23387,23397,23401,23408,23411,23413,23416,25992,23418,23424,23427,23462,23480,
23491,23495,23497,23508,23504,23524,23526,23522,23518,23525,23531,23536,23542,
23539,23557,23559,23560,23565,23571,23584,23586,23592,23608,23609,23617,23622,
23630,23635,23632,23631,23409,23660,23662,20066,23670,23673,23692,23697,23700,
22939,23723,23739,23734,23740,23735,23749,23742,23751,23769,23785,23805,23802,
23789,23948,23786,23819,23829,23831,23900,23839,23835,23825,23828,23842,23834,
23833,23832,23884,23890,23886,23883,23916,23923,23926,23943,23940,23938,23970,
23965,23980,23982,23997,23952,23991,23996,24009,24013,24019,24018,24022,24027,
24043,24050,24053,24075,24090,24089,24081,24091,24118,24119,24132,24131,24128,
24142,24151,24148,24159,24162,24164,24135,24181,24182,24186,40636,24191,24224,
24257,24258,24264,24272,24271,24278,24291,24285,24282,24283,24290,24289,24296,
24297,24300,24305,24307,24304,24308,24312,24318,24323,24329,24413,24412,24331,
24337,24342,24361,24365,24376,24385,24392,24396,24398,24367,24401,24406,24407,
24409,24417,24429,24435,24439,24451,24450,24447,24458,
24456,24465,24455,24478,24473,24472,24480,24488,24493,24508,24534,24571,24548,
24568,24561,24541,24755,24575,24609,24672,24601,24592,24617,24590,24625,24603,
24597,24619,24614,24591,24634,24666,24641,24682,24695,24671,24650,24646,24653,
24675,24643,24676,24642,24684,24683,24665,24705,24717,24807,24707,24730,24708,
24731,24726,24727,24722,24743,24715,24801,24760,24800,24787,24756,24560,24765,
24774,24757,24792,24909,24853,24838,24822,24823,24832,24820,24826,24835,24865,
24827,24817,24845,24846,24903,24894,24872,24871,24906,24895,24892,24876,24884,
24893,24898,24900,24947,24951,24920,24921,24922,24939,24948,24943,24933,24945,
24927,24925,24915,24949,24985,24982,24967,25004,24980,24986,24970,24977,25003,
25006,25036,25034,25033,25079,25032,25027,25030,25018,25035,32633,25037,25062,
25059,25078,25082,25076,25087,25085,25084,25086,25088,25096,25097,25101,25100,
25108,25115,25118,25121,25130,25134,25136,25138,25139,25153,25166,25182,25187,
25179,25184,25192,25212,25218,25225,25214,25234,25235,25238,25300,25219,25236,
25303,25297,25275,25295,25343,25286,25812,25288,25308,25292,25290,25282,25287,
25243,25289,25356,25326,25329,25383,25346,25352,25327,25333,25424,25406,25421,
25628,25423,25494,25486,25472,25515,25462,25507,25487,25481,25503,25525,25451,
25449,25534,25577,25536,25542,25571,25545,25554,25590,25540,25622,25652,25606,
25619,25638,25654,25885,25623,25640,25615,25703,25711,25718,25678,25898,25749,
25747,25765,25769,25736,25788,25818,25810,25797,25799,25787,25816,25794,25841,
25831,33289,25824,25825,25260,25827,25839,25900,25846,
25844,25842,25850,25856,25853,25880,25884,25861,25892,25891,25899,25908,25909,
25911,25910,25912,30027,25928,25942,25941,25933,25944,25950,25949,25970,25976,
25986,25987,35722,26011,26015,26027,26039,26051,26054,26049,26052,26060,26066,
26075,26073,26080,26081,26097,26482,26122,26115,26107,26483,26165,26166,26164,
26140,26191,26180,26185,26177,26206,26205,26212,26215,26216,26207,26210,26224,
26243,26248,26254,26249,26244,26264,26269,26305,26297,26313,26302,26300,26308,
26296,26326,26330,26336,26175,26342,26345,26352,26357,26359,26383,26390,26398,
26406,26407,38712,26414,26431,26422,26433,26424,26423,26438,26462,26464,26457,
26467,26468,26505,26480,26537,26492,26474,26508,26507,26534,26529,26501,26551,
26607,26548,26604,26547,26601,26552,26596,26590,26589,26594,26606,26553,26574,
26566,26599,27292,26654,26694,26665,26688,26701,26674,26702,26803,26667,26713,
26723,26743,26751,26783,26767,26797,26772,26781,26779,26755,27310,26809,26740,
26805,26784,26810,26895,26765,26750,26881,26826,26888,26840,26914,26918,26849,
26892,26829,26836,26855,26837,26934,26898,26884,26839,26851,26917,26873,26848,
26863,26920,26922,26906,26915,26913,26822,27001,26999,26972,27000,26987,26964,
27006,26990,26937,26996,26941,26969,26928,26977,26974,26973,27009,26986,27058,
27054,27088,27071,27073,27091,27070,27086,23528,27082,27101,27067,27075,27047,
27182,27025,27040,27036,27029,27060,27102,27112,27138,27163,27135,27402,27129,
27122,27111,27141,27057,27166,27117,27156,27115,27146,27154,27329,27171,27155,
27204,27148,27250,27190,27256,27207,27234,27225,27238,
27208,27192,27170,27280,27277,27296,27268,27298,27299,27287,34327,27323,27331,
27330,27320,27315,27308,27358,27345,27359,27306,27354,27370,27387,27397,34326,
27386,27410,27414,39729,27423,27448,27447,30428,27449,39150,27463,27459,27465,
27472,27481,27476,27483,27487,27489,27512,27513,27519,27520,27524,27523,27533,
27544,27541,27550,27556,27562,27563,27567,27570,27569,27571,27575,27580,27590,
27595,27603,27615,27628,27627,27635,27631,40638,27656,27667,27668,27675,27684,
27683,27742,27733,27746,27754,27778,27789,27802,27777,27803,27774,27752,27763,
27794,27792,27844,27889,27859,27837,27863,27845,27869,27822,27825,27838,27834,
27867,27887,27865,27882,27935,34893,27958,27947,27965,27960,27929,27957,27955,
27922,27916,28003,28051,28004,27994,28025,27993,28046,28053,28644,28037,28153,
28181,28170,28085,28103,28134,28088,28102,28140,28126,28108,28136,28114,28101,
28154,28121,28132,28117,28138,28142,28205,28270,28206,28185,28274,28255,28222,
28195,28267,28203,28278,28237,28191,28227,28218,28238,28196,28415,28189,28216,
28290,28330,28312,28361,28343,28371,28349,28335,28356,28338,28372,28373,28303,
28325,28354,28319,28481,28433,28748,28396,28408,28414,28479,28402,28465,28399,
28466,28364,28478,28435,28407,28550,28538,28536,28545,28544,28527,28507,28659,
28525,28546,28540,28504,28558,28561,28610,28518,28595,28579,28577,28580,28601,
28614,28586,28639,28629,28652,28628,28632,28657,28654,28635,28681,28683,28666,
28689,28673,28687,28670,28699,28698,28532,28701,28696,28703,28720,28734,28722,
28753,28771,28825,28818,28847,28913,28844,28856,28851,
28846,28895,28875,28893,28889,28937,28925,28956,28953,29029,29013,29064,29030,
29026,29004,29014,29036,29071,29179,29060,29077,29096,29100,29143,29113,29118,
29138,29129,29140,29134,29152,29164,29159,29173,29180,29177,29183,29197,29200,
29211,29224,29229,29228,29232,29234,29243,29244,29247,29248,29254,29259,29272,
29300,29310,29314,29313,29319,29330,29334,29346,29351,29369,29362,29379,29382,
29380,29390,29394,29410,29408,29409,29433,29431,20495,29463,29450,29468,29462,
29469,29492,29487,29481,29477,29502,29518,29519,40664,29527,29546,29544,29552,
29560,29557,29563,29562,29640,29619,29646,29627,29632,29669,29678,29662,29858,
29701,29807,29733,29688,29746,29754,29781,29759,29791,29785,29761,29788,29801,
29808,29795,29802,29814,29822,29835,29854,29863,29898,29903,29908,29681,29920,
29923,29927,29929,29934,29938,29936,29937,29944,29943,29956,29955,29957,29964,
29966,29965,29973,29971,29982,29990,29996,30012,30020,30029,30026,30025,30043,
30022,30042,30057,30052,30055,30059,30061,30072,30070,30086,30087,30068,30090,
30089,30082,30100,30106,30109,30117,30115,30146,30131,30147,30133,30141,30136,
30140,30129,30157,30154,30162,30169,30179,30174,30206,30207,30204,30209,30192,
30202,30194,30195,30219,30221,30217,30239,30247,30240,30241,30242,30244,30260,
30256,30267,30279,30280,30278,30300,30296,30305,30306,30312,30313,30314,30311,
30316,30320,30322,30326,30328,30332,30336,30339,30344,30347,30350,30358,30355,
30361,30362,30384,30388,30392,30393,30394,30402,30413,30422,30418,30430,30433,
30437,30439,30442,34351,30459,30472,30471,30468,30505,
30500,30494,30501,30502,30491,30519,30520,30535,30554,30568,30571,30555,30565,
30591,30590,30585,30606,30603,30609,30624,30622,30640,30646,30649,30655,30652,
30653,30651,30663,30669,30679,30682,30684,30691,30702,30716,30732,30738,31014,
30752,31018,30789,30862,30836,30854,30844,30874,30860,30883,30901,30890,30895,
30929,30918,30923,30932,30910,30908,30917,30922,30956,30951,30938,30973,30964,
30983,30994,30993,31001,31020,31019,31040,31072,31063,31071,31066,31061,31059,
31098,31103,31114,31133,31143,40779,31146,31150,31155,31161,31162,31177,31189,
31207,31212,31201,31203,31240,31245,31256,31257,31264,31263,31104,31281,31291,
31294,31287,31299,31319,31305,31329,31330,31337,40861,31344,31353,31357,31368,
31383,31381,31384,31382,31401,31432,31408,31414,31429,31428,31423,36995,31431,
31434,31437,31439,31445,31443,31449,31450,31453,31457,31458,31462,31469,31472,
31490,31503,31498,31494,31539,31512,31513,31518,31541,31528,31542,31568,31610,
31492,31565,31499,31564,31557,31605,31589,31604,31591,31600,31601,31596,31598,
31645,31640,31647,31629,31644,31642,31627,31634,31631,31581,31641,31691,31681,
31692,31695,31668,31686,31709,31721,31761,31764,31718,31717,31840,31744,31751,
31763,31731,31735,31767,31757,31734,31779,31783,31786,31775,31799,31787,31805,
31820,31811,31828,31823,31808,31824,31832,31839,31844,31830,31845,31852,31861,
31875,31888,31908,31917,31906,31915,31905,31912,31923,31922,31921,31918,31929,
31933,31936,31941,31938,31960,31954,31964,31970,39739,31983,31986,31988,31990,
31994,32006,32002,32028,32021,32010,32069,32075,32046,
32050,32063,32053,32070,32115,32086,32078,32114,32104,32110,32079,32099,32147,
32137,32091,32143,32125,32155,32186,32174,32163,32181,32199,32189,32171,32317,
32162,32175,32220,32184,32159,32176,32216,32221,32228,32222,32251,32242,32225,
32261,32266,32291,32289,32274,32305,32287,32265,32267,32290,32326,32358,32315,
32309,32313,32323,32311,32306,32314,32359,32349,32342,32350,32345,32346,32377,
32362,32361,32380,32379,32387,32213,32381,36782,32383,32392,32393,32396,32402,
32400,32403,32404,32406,32398,32411,32412,32568,32570,32581,32588,32589,32590,
32592,32593,32597,32596,32600,32607,32608,32616,32617,32615,32632,32642,32646,
32643,32648,32647,32652,32660,32670,32669,32666,32675,32687,32690,32697,32686,
32694,32696,35697,32709,32710,32714,32725,32724,32737,32742,32745,32755,32761,
39132,32774,32772,32779,32786,32792,32793,32796,32801,32808,32831,32827,32842,
32838,32850,32856,32858,32863,32866,32872,32883,32882,32880,32886,32889,32893,
32895,32900,32902,32901,32923,32915,32922,32941,20880,32940,32987,32997,32985,
32989,32964,32986,32982,33033,33007,33009,33051,33065,33059,33071,33099,38539,
33094,33086,33107,33105,33020,33137,33134,33125,33126,33140,33155,33160,33162,
33152,33154,33184,33173,33188,33187,33119,33171,33193,33200,33205,33214,33208,
33213,33216,33218,33210,33225,33229,33233,33241,33240,33224,33242,33247,33248,
33255,33274,33275,33278,33281,33282,33285,33287,33290,33293,33296,33302,33321,
33323,33336,33331,33344,33369,33368,33373,33370,33375,33380,33378,33384,33386,
33387,33326,33393,33399,33400,33406,33421,33426,33451,
33439,33467,33452,33505,33507,33503,33490,33524,33523,33530,33683,33539,33531,
33529,33502,33542,33500,33545,33497,33589,33588,33558,33586,33585,33600,33593,
33616,33605,33583,33579,33559,33560,33669,33690,33706,33695,33698,33686,33571,
33678,33671,33674,33660,33717,33651,33653,33696,33673,33704,33780,33811,33771,
33742,33789,33795,33752,33803,33729,33783,33799,33760,33778,33805,33826,33824,
33725,33848,34054,33787,33901,33834,33852,34138,33924,33911,33899,33965,33902,
33922,33897,33862,33836,33903,33913,33845,33994,33890,33977,33983,33951,34009,
33997,33979,34010,34000,33985,33990,34006,33953,34081,34047,34036,34071,34072,
34092,34079,34069,34068,34044,34112,34147,34136,34120,34113,34306,34123,34133,
34176,34212,34184,34193,34186,34216,34157,34196,34203,34282,34183,34204,34167,
34174,34192,34249,34234,34255,34233,34256,34261,34269,34277,34268,34297,34314,
34323,34315,34302,34298,34310,34338,34330,34352,34367,34381,20053,34388,34399,
34407,34417,34451,34467,34473,34474,34443,34444,34486,34479,34500,34502,34480,
34505,34851,34475,34516,34526,34537,34540,34527,34523,34543,34578,34566,34568,
34560,34563,34555,34577,34569,34573,34553,34570,34612,34623,34615,34619,34597,
34601,34586,34656,34655,34680,34636,34638,34676,34647,34664,34670,34649,34643,
34659,34666,34821,34722,34719,34690,34735,34763,34749,34752,34768,38614,34731,
34756,34739,34759,34758,34747,34799,34802,34784,34831,34829,34814,34806,34807,
34830,34770,34833,34838,34837,34850,34849,34865,34870,34873,34855,34875,34884,
34882,34898,34905,34910,34914,34923,34945,34942,34974,
34933,34941,34997,34930,34946,34967,34962,34990,34969,34978,34957,34980,34992,
35007,34993,35011,35012,35028,35032,35033,35037,35065,35074,35068,35060,35048,
35058,35076,35084,35082,35091,35139,35102,35109,35114,35115,35137,35140,35131,
35126,35128,35148,35101,35168,35166,35174,35172,35181,35178,35183,35188,35191,
35198,35203,35208,35210,35219,35224,35233,35241,35238,35244,35247,35250,35258,
35261,35263,35264,35290,35292,35293,35303,35316,35320,35331,35350,35344,35340,
35355,35357,35365,35382,35393,35419,35410,35398,35400,35452,35437,35436,35426,
35461,35458,35460,35496,35489,35473,35493,35494,35482,35491,35524,35533,35522,
35546,35563,35571,35559,35556,35569,35604,35552,35554,35575,35550,35547,35596,
35591,35610,35553,35606,35600,35607,35616,35635,38827,35622,35627,35646,35624,
35649,35660,35663,35662,35657,35670,35675,35674,35691,35679,35692,35695,35700,
35709,35712,35724,35726,35730,35731,35734,35737,35738,35898,35905,35903,35912,
35916,35918,35920,35925,35938,35948,35960,35962,35970,35977,35973,35978,35981,
35982,35988,35964,35992,25117,36013,36010,36029,36018,36019,36014,36022,36040,
36033,36068,36067,36058,36093,36090,36091,36100,36101,36106,36103,36111,36109,
36112,40782,36115,36045,36116,36118,36199,36205,36209,36211,36225,36249,36290,
36286,36282,36303,36314,36310,36300,36315,36299,36330,36331,36319,36323,36348,
36360,36361,36351,36381,36382,36368,36383,36418,36405,36400,36404,36426,36423,
36425,36428,36432,36424,36441,36452,36448,36394,36451,36437,36470,36466,36476,
36481,36487,36485,36484,36491,36490,36499,36497,36500,
36505,36522,36513,36524,36528,36550,36529,36542,36549,36552,36555,36571,36579,
36604,36603,36587,36606,36618,36613,36629,36626,36633,36627,36636,36639,36635,
36620,36646,36659,36667,36665,36677,36674,36670,36684,36681,36678,36686,36695,
36700,36706,36707,36708,36764,36767,36771,36781,36783,36791,36826,36837,36834,
36842,36847,36999,36852,36869,36857,36858,36881,36885,36897,36877,36894,36886,
36875,36903,36918,36917,36921,36856,36943,36944,36945,36946,36878,36937,36926,
36950,36952,36958,36968,36975,36982,38568,36978,36994,36989,36993,36992,37002,
37001,37007,37032,37039,37041,37045,37090,37092,25160,37083,37122,37138,37145,
37170,37168,37194,37206,37208,37219,37221,37225,37235,37234,37259,37257,37250,
37282,37291,37295,37290,37301,37300,37306,37312,37313,37321,37323,37328,37334,
37343,37345,37339,37372,37365,37366,37406,37375,37396,37420,37397,37393,37470,
37463,37445,37449,37476,37448,37525,37439,37451,37456,37532,37526,37523,37531,
37466,37583,37561,37559,37609,37647,37626,37700,37678,37657,37666,37658,37667,
37690,37685,37691,37724,37728,37756,37742,37718,37808,37804,37805,37780,37817,
37846,37847,37864,37861,37848,37827,37853,37840,37832,37860,37914,37908,37907,
37891,37895,37904,37942,37931,37941,37921,37946,37953,37970,37956,37979,37984,
37986,37982,37994,37417,38000,38005,38007,38013,37978,38012,38014,38017,38015,
38274,38279,38282,38292,38294,38296,38297,38304,38312,38311,38317,38332,38331,
38329,38334,38346,28662,38339,38349,38348,38357,38356,38358,38364,38369,38373,
38370,38433,38440,38446,38447,38466,38476,38479,38475,
38519,38492,38494,38493,38495,38502,38514,38508,38541,38552,38549,38551,38570,
38567,38577,38578,38576,38580,38582,38584,38585,38606,38603,38601,38605,35149,
38620,38669,38613,38649,38660,38662,38664,38675,38670,38673,38671,38678,38681,
38692,38698,38704,38713,38717,38718,38724,38726,38728,38722,38729,38748,38752,
38756,38758,38760,21202,38763,38769,38777,38789,38780,38785,38778,38790,38795,
38799,38800,38812,38824,38822,38819,38835,38836,38851,38854,38856,38859,38876,
38893,40783,38898,31455,38902,38901,38927,38924,38968,38948,38945,38967,38973,
38982,38991,38987,39019,39023,39024,39025,39028,39027,39082,39087,39089,39094,
39108,39107,39110,39145,39147,39171,39177,39186,39188,39192,39201,39197,39198,
39204,39200,39212,39214,39229,39230,39234,39241,39237,39248,39243,39249,39250,
39244,39253,39319,39320,39333,39341,39342,39356,39391,39387,39389,39384,39377,
39405,39406,39409,39410,39419,39416,39425,39439,39429,39394,39449,39467,39479,
39493,39490,39488,39491,39486,39509,39501,39515,39511,39519,39522,39525,39524,
39529,39531,39530,39597,39600,39612,39616,39631,39633,39635,39636,39646,39647,
39650,39651,39654,39663,39659,39662,39668,39665,39671,39675,39686,39704,39706,
39711,39714,39715,39717,39719,39720,39721,39722,39726,39727,39730,39748,39747,
39759,39757,39758,39761,39768,39796,39827,39811,39825,39830,39831,39839,39840,
39848,39860,39872,39882,39865,39878,39887,39889,39890,39907,39906,39908,39892,
39905,39994,39922,39921,39920,39957,39956,39945,39955,39948,39942,39944,39954,
39946,39940,39982,39963,39973,39972,39969,39984,40007,
39986,40006,39998,40026,40032,40039,40054,40056,40167,40172,40176,40201,40200,
40171,40195,40198,40234,40230,40367,40227,40223,40260,40213,40210,40257,40255,
40254,40262,40264,40285,40286,40292,40273,40272,40281,40306,40329,40327,40363,
40303,40314,40346,40356,40361,40370,40388,40385,40379,40376,40378,40390,40399,
40386,40409,40403,40440,40422,40429,40431,40445,40474,40475,40478,40565,40569,
40573,40577,40584,40587,40588,40594,40597,40593,40605,40613,40617,40632,40618,
40621,38753,40652,40654,40655,40656,40660,40668,40670,40669,40672,40677,40680,
40687,40692,40694,40695,40697,40699,40700,40701,40711,40712,30391,40725,40737,
40748,40766,40778,40786,40788,40803,40799,40800,40801,40806,40807,40812,40810,
40823,40818,40822,40853,40860,40864,22575,27079,36953,29796,20956,29081,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,

650
libc/stdio/ksc.inc Normal file
View file

@ -0,0 +1,650 @@
12288,12289,12290,183,8229,8230,168,12291,173,8213,8741,65340,8764,8216,8217,
8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303,12304,
12305,177,215,247,8800,8804,8805,8734,8756,176,8242,8243,8451,8491,65504,
65505,65509,9794,9792,8736,8869,8978,8706,8711,8801,8786,167,8251,9734,9733,
9675,9679,9678,9671,9670,9633,9632,9651,9650,9661,9660,8594,8592,8593,8595,
8596,12307,8810,8811,8730,8765,8733,8757,8747,8748,8712,8715,8838,8839,8834,
8835,8746,8745,8743,8744,65506,8658,8660,8704,8707,180,65374,711,728,733,730,
729,184,731,161,191,720,8750,8721,8719,164,8457,8240,9665,9664,9655,9654,9828,
9824,9825,9829,9831,9827,8857,9672,9635,9680,9681,9618,9636,9637,9640,9639,
9638,9641,9832,9743,9742,9756,9758,182,8224,8225,8597,8599,8601,8598,8600,
9837,9833,9834,9836,12927,12828,8470,13255,8482,13250,13272,8481,8364,174,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65281,65282,65283,65284,65285,65286,
65287,65288,65289,65290,65291,65292,65293,65294,65295,65296,65297,65298,65299,
65300,65301,65302,65303,65304,65305,65306,65307,65308,65309,65310,65311,65312,
65313,65314,65315,65316,65317,65318,65319,65320,65321,65322,65323,65324,65325,
65326,65327,65328,65329,65330,65331,65332,65333,65334,65335,65336,65337,65338,
65339,65510,65341,65342,65343,65344,65345,65346,65347,
65348,65349,65350,65351,65352,65353,65354,65355,65356,65357,65358,65359,65360,
65361,65362,65363,65364,65365,65366,65367,65368,65369,65370,65371,65372,65373,
65507,12593,12594,12595,12596,12597,12598,12599,12600,12601,12602,12603,12604,
12605,12606,12607,12608,12609,12610,12611,12612,12613,12614,12615,12616,12617,
12618,12619,12620,12621,12622,12623,12624,12625,12626,12627,12628,12629,12630,
12631,12632,12633,12634,12635,12636,12637,12638,12639,12640,12641,12642,12643,
12644,12645,12646,12647,12648,12649,12650,12651,12652,12653,12654,12655,12656,
12657,12658,12659,12660,12661,12662,12663,12664,12665,12666,12667,12668,12669,
12670,12671,12672,12673,12674,12675,12676,12677,12678,12679,12680,12681,12682,
12683,12684,12685,12686,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,0,0,
0,0,0,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,0,0,0,0,0,0,0,913,914,
915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,
935,936,937,0,0,0,0,0,0,0,0,945,946,947,948,949,950,951,952,953,954,955,956,
957,958,959,960,961,963,964,965,966,967,968,969,0,0,0,0,0,0,9472,9474,9484,
9488,9496,9492,9500,9516,9508,9524,9532,9473,9475,9487,9491,9499,9495,9507,
9523,9515,9531,9547,9504,9519,9512,9527,9535,9501,9520,9509,9528,9538,9490,
9489,9498,9497,9494,9493,9486,9485,9502,
9503,9505,9506,9510,9511,9513,9514,9517,9518,9521,9522,9525,9526,9529,9530,
9533,9534,9536,9537,9539,9540,9541,9542,9543,9544,9545,9546,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13205,13206,13207,8467,13208,13252,13219,
13220,13221,13222,13209,13210,13211,13212,13213,13214,13215,13216,13217,13218,
13258,13197,13198,13199,13263,13192,13193,13256,13223,13224,13232,13233,13234,
13235,13236,13237,13238,13239,13240,13241,13184,13185,13186,13187,13188,13242,
13243,13244,13245,13246,13247,13200,13201,13202,13203,13204,8486,13248,13249,
13194,13195,13196,13270,13253,13229,13230,13231,13275,13225,13226,13227,13228,
13277,13264,13267,13251,13257,13276,13254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,198,
208,170,294,0,306,0,319,321,216,338,186,222,358,330,0,12896,12897,12898,12899,
12900,12901,12902,12903,12904,12905,12906,12907,12908,12909,12910,12911,12912,
12913,12914,12915,12916,12917,12918,12919,12920,12921,12922,12923,9424,9425,
9426,9427,9428,9429,9430,9431,9432,9433,9434,9435,9436,9437,9438,9439,9440,
9441,9442,9443,9444,9445,9446,9447,9448,9449,9312,9313,9314,9315,9316,9317,
9318,9319,9320,9321,9322,9323,9324,9325,9326,189,8531,8532,188,190,8539,8540,
8541,8542,230,273,240,295,305,307,312,320,322,248,339,223,254,359,331,
329,12800,12801,12802,12803,12804,12805,12806,12807,12808,12809,12810,12811,
12812,12813,12814,12815,12816,12817,12818,12819,12820,12821,12822,12823,12824,
12825,12826,12827,9372,9373,9374,9375,9376,9377,9378,9379,9380,9381,9382,9383,
9384,9385,9386,9387,9388,9389,9390,9391,9392,9393,9394,9395,9396,9397,9332,
9333,9334,9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345,9346,185,178,
179,8308,8319,8321,8322,8323,8324,12353,12354,12355,12356,12357,12358,12359,
12360,12361,12362,12363,12364,12365,12366,12367,12368,12369,12370,12371,12372,
12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,12383,12384,12385,
12386,12387,12388,12389,12390,12391,12392,12393,12394,12395,12396,12397,12398,
12399,12400,12401,12402,12403,12404,12405,12406,12407,12408,12409,12410,12411,
12412,12413,12414,12415,12416,12417,12418,12419,12420,12421,12422,12423,12424,
12425,12426,12427,12428,12429,12430,12431,12432,12433,12434,12435,0,0,0,0,0,0,
0,0,0,0,0,12449,12450,12451,12452,12453,12454,12455,12456,12457,12458,12459,
12460,12461,12462,12463,12464,12465,12466,12467,12468,12469,12470,12471,12472,
12473,12474,12475,12476,12477,12478,12479,12480,12481,12482,12483,12484,12485,
12486,12487,12488,12489,12490,12491,12492,12493,12494,12495,12496,12497,12498,
12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,12509,12510,12511,
12512,12513,12514,12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,
12525,12526,12527,12528,12529,12530,12531,
12532,12533,12534,0,0,0,0,0,0,0,0,1040,1041,1042,1043,1044,1045,1025,1046,
1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,
1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1072,1073,1074,1075,1076,1077,1105,1078,1079,1080,1081,1082,1083,1084,1085,
1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,
1101,1102,1103,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,44032,44033,44036,44039,44040,44041,44042,44048,
44049,44050,44051,44052,44053,44054,44055,44057,44058,44059,44060,44061,44064,
44068,44076,44077,44079,44080,44081,44088,44089,44092,44096,44107,44109,44116,
44120,44124,44144,44145,44148,44151,44152,44154,44160,44161,44163,44164,44165,
44166,44169,44170,44171,44172,44176,44180,44188,44189,44191,44192,44193,44200,
44201,44202,44204,44207,44208,44216,44217,44219,44220,44221,44225,44228,44232,
44236,44245,44247,44256,44257,44260,44263,44264,44266,44268,44271,44272,44273,
44275,44277,44278,44284,44285,44288,44292,44294,44300,44301,44303,44305,44312,
44316,44320,44329,44332,44333,44340,44341,44344,44348,44356,44357,44359,44361,
44368,44372,44376,44385,44387,44396,44397,44400,44403,44404,44405,44406,44411,
44412,44413,44415,44417,44418,44424,44425,44428,44432,44444,44445,44452,44471,
44480,44481,44484,44488,44496,44497,44499,44508,44512,44516,44536,44537,44540,
44543,44544,44545,44552,44553,44555,44557,44564,44592,44593,44596,44599,44600,
44602,44608,44609,44611,44613,44614,44618,44620,44621,44622,44624,44628,44630,
44636,44637,44639,44640,44641,44645,44648,44649,44652,44656,44664,44665,44667,
44668,44669,44676,44677,44684,44732,44733,44734,44736,44740,44748,44749,44751,
44752,44753,44760,44761,44764,44776,44779,44781,44788,44792,44796,44807,44808,
44813,44816,44844,44845,44848,44850,44852,44860,44861,44863,44865,44866,44867,
44872,44873,44880,44892,44893,44900,44901,44921,44928,44932,44936,44944,44945,
44949,44956,44984,44985,44988,44992,44999,45000,45001,45003,45005,45006,45012,
45020,45032,45033,45040,45041,45044,45048,45056,45057,45060,45068,45072,45076,
45084,45085,45096,45124,45125,45128,45130,45132,45134,45139,45140,45141,45143,
45145,45149,45180,45181,45184,45188,45196,45197,45199,45201,45208,45209,45210,
45212,45215,45216,45217,45218,45224,45225,45227,45228,45229,45230,45231,45233,
45235,45236,45237,45240,45244,45252,45253,45255,45256,45257,45264,45265,45268,
45272,45280,45285,45320,45321,45323,45324,45328,45330,45331,45336,45337,45339,
45340,45341,45347,45348,45349,45352,45356,45364,45365,45367,45368,45369,45376,
45377,45380,45384,45392,45393,45396,45397,45400,45404,45408,45432,45433,45436,
45440,45442,45448,45449,45451,45453,45458,45459,45460,45464,45468,45480,45516,
45520,45524,45532,45533,45535,45544,45545,45548,45552,
45561,45563,45565,45572,45573,45576,45579,45580,45588,45589,45591,45593,45600,
45620,45628,45656,45660,45664,45672,45673,45684,45685,45692,45700,45701,45705,
45712,45713,45716,45720,45721,45722,45728,45729,45731,45733,45734,45738,45740,
45744,45748,45768,45769,45772,45776,45778,45784,45785,45787,45789,45794,45796,
45797,45798,45800,45803,45804,45805,45806,45807,45811,45812,45813,45815,45816,
45817,45818,45819,45823,45824,45825,45828,45832,45840,45841,45843,45844,45845,
45852,45908,45909,45910,45912,45915,45916,45918,45919,45924,45925,45927,45929,
45931,45934,45936,45937,45940,45944,45952,45953,45955,45956,45957,45964,45968,
45972,45984,45985,45992,45996,46020,46021,46024,46027,46028,46030,46032,46036,
46037,46039,46041,46043,46045,46048,46052,46056,46076,46096,46104,46108,46112,
46120,46121,46123,46132,46160,46161,46164,46168,46176,46177,46179,46181,46188,
46208,46216,46237,46244,46248,46252,46261,46263,46265,46272,46276,46280,46288,
46293,46300,46301,46304,46307,46308,46310,46316,46317,46319,46321,46328,46356,
46357,46360,46363,46364,46372,46373,46375,46376,46377,46378,46384,46385,46388,
46392,46400,46401,46403,46404,46405,46411,46412,46413,46416,46420,46428,46429,
46431,46432,46433,46496,46497,46500,46504,46506,46507,46512,46513,46515,46516,
46517,46523,46524,46525,46528,46532,46540,46541,46543,46544,46545,46552,46572,
46608,46609,46612,46616,46629,46636,46644,46664,46692,46696,46748,46749,46752,
46756,46763,46764,46769,46804,46832,46836,46840,46848,46849,46853,46888,46889,
46892,46895,46896,46904,46905,46907,46916,46920,46924,
46932,46933,46944,46948,46952,46960,46961,46963,46965,46972,46973,46976,46980,
46988,46989,46991,46992,46993,46994,46998,46999,47000,47001,47004,47008,47016,
47017,47019,47020,47021,47028,47029,47032,47047,47049,47084,47085,47088,47092,
47100,47101,47103,47104,47105,47111,47112,47113,47116,47120,47128,47129,47131,
47133,47140,47141,47144,47148,47156,47157,47159,47160,47161,47168,47172,47185,
47187,47196,47197,47200,47204,47212,47213,47215,47217,47224,47228,47245,47272,
47280,47284,47288,47296,47297,47299,47301,47308,47312,47316,47325,47327,47329,
47336,47337,47340,47344,47352,47353,47355,47357,47364,47384,47392,47420,47421,
47424,47428,47436,47439,47441,47448,47449,47452,47456,47464,47465,47467,47469,
47476,47477,47480,47484,47492,47493,47495,47497,47498,47501,47502,47532,47533,
47536,47540,47548,47549,47551,47553,47560,47561,47564,47566,47567,47568,47569,
47570,47576,47577,47579,47581,47582,47585,47587,47588,47589,47592,47596,47604,
47605,47607,47608,47609,47610,47616,47617,47624,47637,47672,47673,47676,47680,
47682,47688,47689,47691,47693,47694,47699,47700,47701,47704,47708,47716,47717,
47719,47720,47721,47728,47729,47732,47736,47747,47748,47749,47751,47756,47784,
47785,47787,47788,47792,47794,47800,47801,47803,47805,47812,47816,47832,47833,
47868,47872,47876,47885,47887,47889,47896,47900,47904,47913,47915,47924,47925,
47926,47928,47931,47932,47933,47934,47940,47941,47943,47945,47949,47951,47952,
47956,47960,47969,47971,47980,48008,48012,48016,48036,48040,48044,48052,48055,
48064,48068,48072,48080,48083,48120,48121,48124,48127,
48128,48130,48136,48137,48139,48140,48141,48143,48145,48148,48149,48150,48151,
48152,48155,48156,48157,48158,48159,48164,48165,48167,48169,48173,48176,48177,
48180,48184,48192,48193,48195,48196,48197,48201,48204,48205,48208,48221,48260,
48261,48264,48267,48268,48270,48276,48277,48279,48281,48282,48288,48289,48292,
48295,48296,48304,48305,48307,48308,48309,48316,48317,48320,48324,48333,48335,
48336,48337,48341,48344,48348,48372,48373,48374,48376,48380,48388,48389,48391,
48393,48400,48404,48420,48428,48448,48456,48457,48460,48464,48472,48473,48484,
48488,48512,48513,48516,48519,48520,48521,48522,48528,48529,48531,48533,48537,
48538,48540,48548,48560,48568,48596,48597,48600,48604,48617,48624,48628,48632,
48640,48643,48645,48652,48653,48656,48660,48668,48669,48671,48708,48709,48712,
48716,48718,48724,48725,48727,48729,48730,48731,48736,48737,48740,48744,48746,
48752,48753,48755,48756,48757,48763,48764,48765,48768,48772,48780,48781,48783,
48784,48785,48792,48793,48808,48848,48849,48852,48855,48856,48864,48867,48868,
48869,48876,48897,48904,48905,48920,48921,48923,48924,48925,48960,48961,48964,
48968,48976,48977,48981,49044,49072,49093,49100,49101,49104,49108,49116,49119,
49121,49212,49233,49240,49244,49248,49256,49257,49296,49297,49300,49304,49312,
49313,49315,49317,49324,49325,49327,49328,49331,49332,49333,49334,49340,49341,
49343,49344,49345,49349,49352,49353,49356,49360,49368,49369,49371,49372,49373,
49380,49381,49384,49388,49396,49397,49399,49401,49408,49412,49416,49424,49429,
49436,49437,49438,49439,49440,49443,49444,49446,49447,
49452,49453,49455,49456,49457,49462,49464,49465,49468,49472,49480,49481,49483,
49484,49485,49492,49493,49496,49500,49508,49509,49511,49512,49513,49520,49524,
49528,49541,49548,49549,49550,49552,49556,49558,49564,49565,49567,49569,49573,
49576,49577,49580,49584,49597,49604,49608,49612,49620,49623,49624,49632,49636,
49640,49648,49649,49651,49660,49661,49664,49668,49676,49677,49679,49681,49688,
49689,49692,49695,49696,49704,49705,49707,49709,49711,49713,49714,49716,49736,
49744,49745,49748,49752,49760,49765,49772,49773,49776,49780,49788,49789,49791,
49793,49800,49801,49808,49816,49819,49821,49828,49829,49832,49836,49837,49844,
49845,49847,49849,49884,49885,49888,49891,49892,49899,49900,49901,49903,49905,
49910,49912,49913,49915,49916,49920,49928,49929,49932,49933,49939,49940,49941,
49944,49948,49956,49957,49960,49961,49989,50024,50025,50028,50032,50034,50040,
50041,50044,50045,50052,50056,50060,50112,50136,50137,50140,50143,50144,50146,
50152,50153,50157,50164,50165,50168,50184,50192,50212,50220,50224,50228,50236,
50237,50248,50276,50277,50280,50284,50292,50293,50297,50304,50324,50332,50360,
50364,50409,50416,50417,50420,50424,50426,50431,50432,50433,50444,50448,50452,
50460,50472,50473,50476,50480,50488,50489,50491,50493,50500,50501,50504,50505,
50506,50508,50509,50510,50515,50516,50517,50519,50520,50521,50525,50526,50528,
50529,50532,50536,50544,50545,50547,50548,50549,50556,50557,50560,50564,50567,
50572,50573,50575,50577,50581,50583,50584,50588,50592,50601,50612,50613,50616,
50617,50619,50620,50621,50622,50628,50629,50630,50631,
50632,50633,50634,50636,50638,50640,50641,50644,50648,50656,50657,50659,50661,
50668,50669,50670,50672,50676,50678,50679,50684,50685,50686,50687,50688,50689,
50693,50694,50695,50696,50700,50704,50712,50713,50715,50716,50724,50725,50728,
50732,50733,50734,50736,50739,50740,50741,50743,50745,50747,50752,50753,50756,
50760,50768,50769,50771,50772,50773,50780,50781,50784,50796,50799,50801,50808,
50809,50812,50816,50824,50825,50827,50829,50836,50837,50840,50844,50852,50853,
50855,50857,50864,50865,50868,50872,50873,50874,50880,50881,50883,50885,50892,
50893,50896,50900,50908,50909,50912,50913,50920,50921,50924,50928,50936,50937,
50941,50948,50949,50952,50956,50964,50965,50967,50969,50976,50977,50980,50984,
50992,50993,50995,50997,50999,51004,51005,51008,51012,51018,51020,51021,51023,
51025,51026,51027,51028,51029,51030,51031,51032,51036,51040,51048,51051,51060,
51061,51064,51068,51069,51070,51075,51076,51077,51079,51080,51081,51082,51086,
51088,51089,51092,51094,51095,51096,51098,51104,51105,51107,51108,51109,51110,
51116,51117,51120,51124,51132,51133,51135,51136,51137,51144,51145,51148,51150,
51152,51160,51165,51172,51176,51180,51200,51201,51204,51208,51210,51216,51217,
51219,51221,51222,51228,51229,51232,51236,51244,51245,51247,51249,51256,51260,
51264,51272,51273,51276,51277,51284,51312,51313,51316,51320,51322,51328,51329,
51331,51333,51334,51335,51339,51340,51341,51348,51357,51359,51361,51368,51388,
51389,51396,51400,51404,51412,51413,51415,51417,51424,51425,51428,51445,51452,
51453,51456,51460,51461,51462,51468,51469,51471,51473,
51480,51500,51508,51536,51537,51540,51544,51552,51553,51555,51564,51568,51572,
51580,51592,51593,51596,51600,51608,51609,51611,51613,51648,51649,51652,51655,
51656,51658,51664,51665,51667,51669,51670,51673,51674,51676,51677,51680,51682,
51684,51687,51692,51693,51695,51696,51697,51704,51705,51708,51712,51720,51721,
51723,51724,51725,51732,51736,51753,51788,51789,51792,51796,51804,51805,51807,
51808,51809,51816,51837,51844,51864,51900,51901,51904,51908,51916,51917,51919,
51921,51923,51928,51929,51936,51948,51956,51976,51984,51988,51992,52000,52001,
52033,52040,52041,52044,52048,52056,52057,52061,52068,52088,52089,52124,52152,
52180,52196,52199,52201,52236,52237,52240,52244,52252,52253,52257,52258,52263,
52264,52265,52268,52270,52272,52280,52281,52283,52284,52285,52286,52292,52293,
52296,52300,52308,52309,52311,52312,52313,52320,52324,52326,52328,52336,52341,
52376,52377,52380,52384,52392,52393,52395,52396,52397,52404,52405,52408,52412,
52420,52421,52423,52425,52432,52436,52452,52460,52464,52481,52488,52489,52492,
52496,52504,52505,52507,52509,52516,52520,52524,52537,52572,52576,52580,52588,
52589,52591,52593,52600,52616,52628,52629,52632,52636,52644,52645,52647,52649,
52656,52676,52684,52688,52712,52716,52720,52728,52729,52731,52733,52740,52744,
52748,52756,52761,52768,52769,52772,52776,52784,52785,52787,52789,52824,52825,
52828,52831,52832,52833,52840,52841,52843,52845,52852,52853,52856,52860,52868,
52869,52871,52873,52880,52881,52884,52888,52896,52897,52899,52900,52901,52908,
52909,52929,52964,52965,52968,52971,52972,52980,52981,
52983,52984,52985,52992,52993,52996,53000,53008,53009,53011,53013,53020,53024,
53028,53036,53037,53039,53040,53041,53048,53076,53077,53080,53084,53092,53093,
53095,53097,53104,53105,53108,53112,53120,53125,53132,53153,53160,53168,53188,
53216,53217,53220,53224,53232,53233,53235,53237,53244,53248,53252,53265,53272,
53293,53300,53301,53304,53308,53316,53317,53319,53321,53328,53332,53336,53344,
53356,53357,53360,53364,53372,53373,53377,53412,53413,53416,53420,53428,53429,
53431,53433,53440,53441,53444,53448,53449,53456,53457,53459,53460,53461,53468,
53469,53472,53476,53484,53485,53487,53488,53489,53496,53517,53552,53553,53556,
53560,53562,53568,53569,53571,53572,53573,53580,53581,53584,53588,53596,53597,
53599,53601,53608,53612,53628,53636,53640,53664,53665,53668,53672,53680,53681,
53683,53685,53690,53692,53696,53720,53748,53752,53767,53769,53776,53804,53805,
53808,53812,53820,53821,53823,53825,53832,53852,53860,53888,53889,53892,53896,
53904,53905,53909,53916,53920,53924,53932,53937,53944,53945,53948,53951,53952,
53954,53960,53961,53963,53972,53976,53980,53988,53989,54000,54001,54004,54008,
54016,54017,54019,54021,54028,54029,54030,54032,54036,54038,54044,54045,54047,
54048,54049,54053,54056,54057,54060,54064,54072,54073,54075,54076,54077,54084,
54085,54140,54141,54144,54148,54156,54157,54159,54160,54161,54168,54169,54172,
54176,54184,54185,54187,54189,54196,54200,54204,54212,54213,54216,54217,54224,
54232,54241,54243,54252,54253,54256,54260,54268,54269,54271,54273,54280,54301,
54336,54340,54364,54368,54372,54381,54383,54392,54393,
54396,54399,54400,54402,54408,54409,54411,54413,54420,54441,54476,54480,54484,
54492,54495,54504,54508,54512,54520,54523,54525,54532,54536,54540,54548,54549,
54551,54588,54589,54592,54596,54604,54605,54607,54609,54616,54617,54620,54624,
54629,54632,54633,54635,54637,54644,54645,54648,54652,54660,54661,54663,54664,
54665,54672,54693,54728,54729,54732,54736,54738,54744,54745,54747,54749,54756,
54757,54760,54764,54772,54773,54775,54777,54784,54785,54788,54792,54800,54801,
54803,54804,54805,54812,54816,54820,54829,54840,54841,54844,54848,54853,54856,
54857,54859,54861,54865,54868,54869,54872,54876,54887,54889,54896,54897,54900,
54915,54917,54924,54925,54928,54932,54941,54943,54945,54952,54956,54960,54969,
54971,54980,54981,54984,54988,54993,54996,54999,55001,55008,55012,55016,55024,
55029,55036,55037,55040,55044,55057,55064,55065,55068,55072,55080,55081,55083,
55085,55092,55093,55096,55100,55108,55111,55113,55120,55121,55124,55126,55127,
55128,55129,55136,55137,55139,55141,55145,55148,55152,55156,55164,55165,55169,
55176,55177,55180,55184,55192,55193,55195,55197,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20285,20339,20551,20729,21152,21487,21621,21733,
22025,23233,23478,26247,26550,26551,26607,27468,29634,30146,31292,33499,33540,
34903,34952,35382,36040,36303,36603,36838,39381,21051,21364,21508,24682,24932,
27580,29647,33050,35258,35282,38307,20355,21002,22718,22904,23014,24178,24185,
25031,25536,26438,26604,26751,28567,30286,30475,30965,31240,31487,31777,32925,
33390,33393,35563,38291,20075,21917,26359,28212,30883,31469,33883,35088,34638,
38824,21208,22350,22570,23884,24863,25022,25121,25954,26577,27204,28187,29976,
30131,30435,30640,32058,37039,37969,37970,40853,21283,23724,30002,32987,37440,
38296,21083,22536,23004,23713,23831,24247,24378,24394,24951,27743,30074,30086,
31968,32115,32177,32652,33108,33313,34193,35137,35611,37628,38477,40007,20171,
20215,20491,20977,22607,24887,24894,24936,25913,27114,28433,30117,30342,30422,
31623,33445,33995,63744,37799,38283,21888,23458,22353,63745,31923,32697,37301,
20520,21435,23621,24040,25298,25454,25818,25831,28192,28844,31067,36317,36382,
63746,36989,37445,37624,20094,20214,20581,24062,24314,24838,26967,33137,34388,
36423,37749,39467,20062,20625,26480,26688,20745,21133,21138,27298,30652,37392,
40660,21163,24623,36850,20552,25001,25581,25802,26684,27268,28608,33160,35233,
38548,22533,29309,29356,29956,32121,32365,32937,35211,35700,36963,40273,25225,
27770,28500,32080,32570,35363,20860,24906,31645,35609,37463,37772,20140,20435,
20510,20670,20742,21185,21197,21375,22384,22659,24218,24465,24950,25004,
25806,25964,26223,26299,26356,26775,28039,28805,28913,29855,29861,29898,30169,
30828,30956,31455,31478,32069,32147,32789,32831,33051,33686,35686,36629,36885,
37857,38915,38968,39514,39912,20418,21843,22586,22865,23395,23622,24760,25106,
26690,26800,26856,28330,30028,30328,30926,31293,31995,32363,32380,35336,35489,
35903,38542,40388,21476,21481,21578,21617,22266,22993,23396,23611,24235,25335,
25911,25925,25970,26272,26543,27073,27837,30204,30352,30590,31295,32660,32771,
32929,33167,33510,33533,33776,34241,34865,34996,35493,63747,36764,37678,38599,
39015,39640,40723,21741,26011,26354,26767,31296,35895,40288,22256,22372,23825,
26118,26801,26829,28414,29736,34974,39908,27752,63748,39592,20379,20844,20849,
21151,23380,24037,24656,24685,25329,25511,25915,29657,31354,34467,36002,38799,
20018,23521,25096,26524,29916,31185,33747,35463,35506,36328,36942,37707,38982,
24275,27112,34303,37101,63749,20896,23448,23532,24931,26874,27454,28748,29743,
29912,31649,32592,33733,35264,36011,38364,39208,21038,24669,25324,36866,20362,
20809,21281,22745,24291,26336,27960,28826,29378,29654,31568,33009,37979,21350,
25499,32619,20054,20608,22602,22750,24618,24871,25296,27088,39745,23439,32024,
32945,36703,20132,20689,21676,21932,23308,23968,24039,25898,25934,26657,27211,
29409,30350,30703,32094,32761,33184,34126,34527,36611,36686,37066,39171,39509,
39851,19992,20037,20061,20167,20465,20855,21246,21312,21475,21477,21646,22036,
22389,22434,23495,23943,24272,25084,25304,25937,26552,26601,27083,27472,27590,
27628,27714,28317,28792,29399,29590,29699,30655,30697,
31350,32127,32777,33276,33285,33290,33503,34914,35635,36092,36544,36881,37041,
37476,37558,39378,39493,40169,40407,40860,22283,23616,33738,38816,38827,40628,
21531,31384,32676,35033,36557,37089,22528,23624,25496,31391,23470,24339,31353,
31406,33422,36524,20518,21048,21240,21367,22280,25331,25458,27402,28099,30519,
21413,29527,34152,36470,38357,26426,27331,28528,35437,36556,39243,63750,26231,
27512,36020,39740,63751,21483,22317,22862,25542,27131,29674,30789,31418,31429,
31998,33909,35215,36211,36917,38312,21243,22343,30023,31584,33740,37406,63752,
27224,20811,21067,21127,25119,26840,26997,38553,20677,21156,21220,25027,26020,
26681,27135,29822,31563,33465,33771,35250,35641,36817,39241,63753,20170,22935,
25810,26129,27278,29748,31105,31165,33449,34942,34943,35167,63754,37670,20235,
21450,24613,25201,27762,32026,32102,20120,20834,30684,32943,20225,20238,20854,
20864,21980,22120,22331,22522,22524,22804,22855,22931,23492,23696,23822,24049,
24190,24524,25216,26071,26083,26398,26399,26462,26827,26820,27231,27450,27683,
27773,27778,28103,29592,29734,29738,29826,29859,30072,30079,30849,30959,31041,
31047,31048,31098,31637,32000,32186,32648,32774,32813,32908,35352,35663,35912,
36215,37665,37668,39138,39249,39438,39439,39525,40594,32202,20342,21513,25326,
26708,37329,21931,20794,63755,63756,23068,25062,63757,25295,25343,63758,63759,
63760,63761,63762,63763,37027,63764,63765,63766,63767,63768,35582,63769,63770,
63771,63772,26262,63773,29014,63774,63775,38627,63776,25423,25466,21335,63777,
26511,26976,28275,63778,30007,63779,63780,63781,32013,
63782,63783,34930,22218,23064,63784,63785,63786,63787,63788,20035,63789,20839,
22856,26608,32784,63790,22899,24180,25754,31178,24565,24684,25288,25467,23527,
23511,21162,63791,22900,24361,24594,63792,63793,63794,29785,63795,63796,63797,
63798,63799,63800,39377,63801,63802,63803,63804,63805,63806,63807,63808,63809,
63810,63811,28611,63812,63813,33215,36786,24817,63814,63815,33126,63816,63817,
23615,63818,63819,63820,63821,63822,63823,63824,63825,23273,35365,26491,32016,
63826,63827,63828,63829,63830,63831,33021,63832,63833,23612,27877,21311,28346,
22810,33590,20025,20150,20294,21934,22296,22727,24406,26039,26086,27264,27573,
28237,30701,31471,31774,32222,34507,34962,37170,37723,25787,28606,29562,30136,
36948,21846,22349,25018,25812,26311,28129,28251,28525,28601,30192,32835,33213,
34113,35203,35527,35674,37663,27795,30035,31572,36367,36957,21776,22530,22616,
24162,25095,25758,26848,30070,31958,34739,40680,20195,22408,22382,22823,23565,
23729,24118,24453,25140,25825,29619,33274,34955,36024,38538,40667,23429,24503,
24755,20498,20992,21040,22294,22581,22615,23566,23648,23798,23947,24230,24466,
24764,25361,25481,25623,26691,26873,27330,28120,28193,28372,28644,29182,30428,
30585,31153,31291,33796,35241,36077,36339,36424,36867,36884,36947,37117,37709,
38518,38876,27602,28678,29272,29346,29544,30563,31167,31716,32411,35712,22697,
24775,25958,26109,26302,27788,28958,29129,35930,38931,20077,31361,20189,20908,
20941,21205,21516,24999,26481,26704,26847,27934,28540,30140,30643,31461,33012,
33891,37509,20828,26007,26460,26515,30168,31431,33651,
63834,35910,36887,38957,23663,33216,33434,36929,36975,37389,24471,23965,27225,
29128,30331,31561,34276,35588,37159,39472,21895,25078,63835,30313,32645,34367,
34746,35064,37007,63836,27931,28889,29662,32097,33853,63837,37226,39409,63838,
20098,21365,27396,27410,28734,29211,34349,40478,21068,36771,23888,25829,25900,
27414,28651,31811,32412,34253,35172,35261,25289,33240,34847,24266,26391,28010,
29436,29701,29807,34690,37086,20358,23821,24480,33802,20919,25504,30053,20142,
20486,20841,20937,26753,27153,31918,31921,31975,33391,35538,36635,37327,20406,
20791,21237,21570,24300,24942,25150,26053,27354,28670,31018,34268,34851,38317,
39522,39530,40599,40654,21147,26310,27511,28701,31019,36706,38722,24976,25088,
25891,28451,29001,29833,32244,32879,34030,36646,36899,37706,20925,21015,21155,
27916,28872,35010,24265,25986,27566,28610,31806,29557,20196,20278,22265,63839,
23738,23994,24604,29618,31533,32666,32718,32838,36894,37428,38646,38728,38936,
40801,20363,28583,31150,37300,38583,21214,63840,25736,25796,27347,28510,28696,
29200,30439,32769,34310,34396,36335,36613,38706,39791,40442,40565,30860,31103,
32160,33737,37636,40575,40595,35542,22751,24324,26407,28711,29903,31840,32894,
20769,28712,29282,30922,36034,36058,36084,38647,20102,20698,23534,24278,26009,
29134,30274,30637,32842,34044,36988,39719,40845,22744,23105,23650,27155,28122,
28431,30267,32047,32311,34078,35128,37860,38475,21129,26066,26611,27060,27969,
28316,28687,29705,29792,30041,30244,30827,35628,39006,20845,25134,38520,20374,
20523,23833,28138,32184,36650,24459,24900,26647,63841,
38534,21202,32907,20956,20940,26974,31260,32190,33777,38517,20442,21033,21400,
21519,21774,23653,24743,26446,26792,28012,29313,29432,29702,29827,63842,30178,
31852,32633,32696,33673,35023,35041,37324,37328,38626,39881,21533,28542,29136,
29848,34298,36522,38563,40023,40607,26519,28107,29747,33256,38678,30764,31435,
31520,31890,25705,29802,30194,30908,30952,39340,39764,40635,23518,24149,28448,
33180,33707,37000,19975,21325,23081,24018,24398,24930,25405,26217,26364,28415,
28459,28771,30622,33836,34067,34875,36627,39237,39995,21788,25273,26411,27819,
33545,35178,38778,20129,22916,24536,24537,26395,32178,32596,33426,33579,33725,
36638,37017,22475,22969,23186,23504,26151,26522,26757,27599,29028,32629,36023,
36067,36993,39749,33032,35978,38476,39488,40613,23391,27667,29467,30450,30431,
33804,20906,35219,20813,20885,21193,26825,27796,30468,30496,32191,32236,38754,
40629,28357,34065,20901,21517,21629,26126,26269,26919,28319,30399,30609,33559,
33986,34719,37225,37528,40180,34946,20398,20882,21215,22982,24125,24917,25720,
25721,26286,26576,27169,27597,27611,29279,29281,29761,30520,30683,32791,33468,
33541,35584,35624,35980,26408,27792,29287,30446,30566,31302,40361,27519,27794,
22818,26406,33945,21359,22675,22937,24287,25551,26164,26483,28218,29483,31447,
33495,37672,21209,24043,25006,25035,25098,25287,25771,26080,26969,27494,27595,
28961,29687,30045,32326,33310,33538,34154,35491,36031,38695,40289,22696,40664,
20497,21006,21563,21839,25991,27766,32010,32011,32862,34442,38272,38639,21247,
27797,29289,21619,23194,23614,23883,24396,24494,26410,
26806,26979,28220,28228,30473,31859,32654,34183,35598,36855,38753,40692,23735,
24758,24845,25003,25935,26107,26108,27665,27887,29599,29641,32225,38292,23494,
34588,35600,21085,21338,25293,25615,25778,26420,27192,27850,29632,29854,31636,
31893,32283,33162,33334,34180,36843,38649,39361,20276,21322,21453,21467,25292,
25644,25856,26001,27075,27886,28504,29677,30036,30242,30436,30460,30928,30971,
31020,32070,33324,34784,36820,38930,39151,21187,25300,25765,28196,28497,30332,
36299,37297,37474,39662,39747,20515,20621,22346,22952,23592,24135,24439,25151,
25918,26041,26049,26121,26507,27036,28354,30917,32033,32938,33152,33323,33459,
33953,34444,35370,35607,37030,38450,40848,20493,20467,63843,22521,24472,25308,
25490,26479,28227,28953,30403,32972,32986,35060,35061,35097,36064,36649,37197,
38506,20271,20336,24091,26575,26658,30333,30334,39748,24161,27146,29033,29140,
30058,63844,32321,34115,34281,39132,20240,31567,32624,38309,20961,24070,26805,
27710,27726,27867,29359,31684,33539,27861,29754,20731,21128,22721,25816,27287,
29863,30294,30887,34327,38370,38713,63845,21342,24321,35722,36776,36783,37002,
21029,30629,40009,40712,19993,20482,20853,23643,24183,26142,26170,26564,26821,
28851,29953,30149,31177,31453,36647,39200,39432,20445,22561,22577,23542,26222,
27493,27921,28282,28541,29668,29995,33769,35036,35091,35676,36628,20239,20693,
21264,21340,23443,24489,26381,31119,33145,33583,34068,35079,35206,36665,36667,
39333,39954,26412,20086,20472,22857,23553,23791,23792,25447,26834,28925,29090,
29739,32299,34028,34562,36898,37586,40179,19981,20184,
20463,20613,21078,21103,21542,21648,22496,22827,23142,23386,23413,23500,24220,
63846,25206,25975,26023,28014,28325,29238,31526,31807,32566,33104,33105,33178,
33344,33433,33705,35331,36000,36070,36091,36212,36282,37096,37340,38428,38468,
39385,40167,21271,20998,21545,22132,22707,22868,22894,24575,24996,25198,26128,
27774,28954,30406,31881,31966,32027,33452,36033,38640,63847,20315,24343,24447,
25282,23849,26379,26842,30844,32323,40300,19989,20633,21269,21290,21329,22915,
23138,24199,24754,24970,25161,25209,26000,26503,27047,27604,27606,27607,27608,
27832,63848,29749,30202,30738,30865,31189,31192,31875,32203,32737,32933,33086,
33218,33778,34586,35048,35513,35692,36027,37145,38750,39131,40763,22188,23338,
24428,25996,27315,27567,27996,28657,28693,29277,29613,36007,36051,38971,24977,
27703,32856,39425,20045,20107,20123,20181,20282,20284,20351,20447,20735,21490,
21496,21766,21987,22235,22763,22882,23057,23531,23546,23556,24051,24107,24473,
24605,25448,26012,26031,26614,26619,26797,27515,27801,27863,28195,28681,29509,
30722,31038,31040,31072,31169,31721,32023,32114,32902,33293,33678,34001,34503,
35039,35408,35422,35613,36060,36198,36781,37034,39164,39391,40605,21066,63849,
26388,63850,20632,21034,23665,25955,27733,29642,29987,30109,31639,33948,37240,
38704,20087,25746,27578,29022,34217,19977,63851,26441,26862,28183,33439,34072,
34923,25591,28545,37394,39087,19978,20663,20687,20767,21830,21930,22039,23360,
23577,23776,24120,24202,24224,24258,24819,26705,27233,28248,29245,29248,29376,
30456,31077,31665,32724,35059,35316,35443,35937,36062,
38684,22622,29885,36093,21959,63852,31329,32034,33394,29298,29983,29989,63853,
31513,22661,22779,23996,24207,24246,24464,24661,25234,25471,25933,26257,26329,
26360,26646,26866,29312,29790,31598,32110,32214,32626,32997,33298,34223,35199,
35475,36893,37604,40653,40736,22805,22893,24109,24796,26132,26227,26512,27728,
28101,28511,30707,30889,33990,37323,37675,20185,20682,20808,21892,23307,23459,
25159,25982,26059,28210,29053,29697,29764,29831,29887,30316,31146,32218,32341,
32680,33146,33203,33337,34330,34796,35445,36323,36984,37521,37925,39245,39854,
21352,23633,26964,27844,27945,28203,33292,34203,35131,35373,35498,38634,40807,
21089,26297,27570,32406,34814,36109,38275,38493,25885,28041,29166,63854,22478,
22995,23468,24615,24826,25104,26143,26207,29481,29689,30427,30465,31596,32854,
32882,33125,35488,37266,19990,21218,27506,27927,31237,31545,32048,63855,36016,
21484,22063,22609,23477,23567,23569,24034,25152,25475,25620,26157,26803,27836,
28040,28335,28703,28836,29138,29990,30095,30094,30233,31505,31712,31787,32032,
32057,34092,34157,34311,35380,36877,36961,37045,37559,38902,39479,20439,23660,
26463,28049,31903,32396,35606,36118,36895,23403,24061,25613,33984,36956,39137,
29575,23435,24730,26494,28126,35359,35494,36865,38924,21047,63856,28753,30862,
37782,34928,37335,20462,21463,22013,22234,22402,22781,23234,23432,23723,23744,
24101,24833,25101,25163,25480,25628,25910,25976,27193,27530,27700,27929,28465,
29159,29417,29560,29703,29874,30246,30561,31168,31319,31466,31929,32143,32172,
32353,32670,33065,33585,33936,34010,34282,34966,35504,
35728,36664,36930,36995,37228,37526,37561,38539,38567,38568,38614,38656,38920,
39318,39635,39706,21460,22654,22809,23408,23487,28113,28506,29087,29729,29881,
32901,33789,24033,24455,24490,24642,26092,26642,26991,27219,27529,27957,28147,
29667,30462,30636,31565,32020,33059,33308,33600,34036,34147,35426,35524,37255,
37662,38918,39348,25100,34899,36848,37477,23815,23847,23913,29791,33181,34664,
28629,25342,32722,35126,35186,19998,20056,20711,21213,21319,25215,26119,32361,
34821,38494,20365,21273,22070,22987,23204,23608,23630,23629,24066,24337,24643,
26045,26159,26178,26558,26612,29468,30690,31034,32709,33940,33997,35222,35430,
35433,35553,35925,35962,22516,23508,24335,24687,25325,26893,27542,28252,29060,
31698,34645,35672,36606,39135,39166,20280,20353,20449,21627,23072,23480,24892,
26032,26216,29180,30003,31070,32051,33102,33251,33688,34218,34254,34563,35338,
36523,36763,63857,36805,22833,23460,23526,24713,23529,23563,24515,27777,63858,
28145,28683,29978,33455,35574,20160,21313,63859,38617,27663,20126,20420,20818,
21854,23077,23784,25105,29273,33469,33706,34558,34905,35357,38463,38597,39187,
40201,40285,22538,23731,23997,24132,24801,24853,25569,27138,28197,37122,37716,
38990,39952,40823,23433,23736,25353,26191,26696,30524,38593,38797,38996,39839,
26017,35585,36555,38332,21813,23721,24022,24245,26263,30284,33780,38343,22739,
25276,29390,40232,20208,22830,24591,26171,27523,31207,40230,21395,21696,22467,
23830,24859,26326,28079,30861,33406,38552,38724,21380,25212,25494,28082,32266,
33099,38989,27387,32588,40367,40474,20063,20539,20918,
22812,24825,25590,26928,29242,32822,63860,37326,24369,63861,63862,32004,33509,
33903,33979,34277,36493,63863,20335,63864,63865,22756,23363,24665,25562,25880,
25965,26264,63866,26954,27171,27915,28673,29036,30162,30221,31155,31344,63867,
32650,63868,35140,63869,35731,37312,38525,63870,39178,22276,24481,26044,28417,
30208,31142,35486,39341,39770,40812,20740,25014,25233,27277,33222,20547,22576,
24422,28937,35328,35578,23420,34326,20474,20796,22196,22852,25513,28153,23978,
26989,20870,20104,20313,63871,63872,63873,22914,63874,63875,27487,27741,63876,
29877,30998,63877,33287,33349,33593,36671,36701,63878,39192,63879,63880,63881,
20134,63882,22495,24441,26131,63883,63884,30123,32377,35695,63885,36870,39515,
22181,22567,23032,23071,23476,63886,24310,63887,63888,25424,25403,63889,26941,
27783,27839,28046,28051,28149,28436,63890,28895,28982,29017,63891,29123,29141,
63892,30799,30831,63893,31605,32227,63894,32303,63895,34893,36575,63896,63897,
63898,37467,63899,40182,63900,63901,63902,24709,28037,63903,29105,63904,63905,
38321,21421,63906,63907,63908,26579,63909,28814,28976,29744,33398,33490,63910,
38331,39653,40573,26308,63911,29121,33865,63912,63913,22603,63914,63915,23992,
24433,63916,26144,26254,27001,27054,27704,27891,28214,28481,28634,28699,28719,
29008,29151,29552,63917,29787,63918,29908,30408,31310,32403,63919,63920,33521,
35424,36814,63921,37704,63922,38681,63923,63924,20034,20522,63925,21000,21473,
26355,27757,28618,29450,30591,31330,33454,34269,34306,63926,35028,35427,35709,
35947,63927,37555,63928,38675,38928,20116,20237,20425,
20658,21320,21566,21555,21978,22626,22714,22887,23067,23524,24735,63929,25034,
25942,26111,26212,26791,27738,28595,28879,29100,29522,31613,34568,35492,39986,
40711,23627,27779,29508,29577,37434,28331,29797,30239,31337,32277,34314,20800,
22725,25793,29934,29973,30320,32705,37013,38605,39252,28198,29926,31401,31402,
33253,34521,34680,35355,23113,23436,23451,26785,26880,28003,29609,29715,29740,
30871,32233,32747,33048,33109,33694,35916,38446,38929,26352,24448,26106,26505,
27754,29579,20525,23043,27498,30702,22806,23916,24013,29477,30031,63930,63931,
20709,20985,22575,22829,22934,23002,23525,63932,63933,23970,25303,25622,25747,
25854,63934,26332,63935,27208,63936,29183,29796,63937,31368,31407,32327,32350,
32768,33136,63938,34799,35201,35616,36953,63939,36992,39250,24958,27442,28020,
32287,35109,36785,20433,20653,20887,21191,22471,22665,23481,24248,24898,27029,
28044,28263,28342,29076,29794,29992,29996,32883,33592,33993,36362,37780,37854,
63940,20110,20305,20598,20778,21448,21451,21491,23431,23507,23588,24858,24962,
26100,29275,29591,29760,30402,31056,31121,31161,32006,32701,33419,34261,34398,
36802,36935,37109,37354,38533,38632,38633,21206,24423,26093,26161,26671,29020,
31286,37057,38922,20113,63941,27218,27550,28560,29065,32792,33464,34131,36939,
38549,38642,38907,34074,39729,20112,29066,38596,20803,21407,21729,22291,22290,
22435,23195,23236,23491,24616,24895,25588,27781,27961,28274,28304,29232,29503,
29783,33489,34945,36677,36960,63942,38498,39000,40219,26376,36234,37470,20301,
20553,20702,21361,22285,22996,23041,23561,24944,26256,
28205,29234,29771,32239,32963,33806,33894,34111,34655,34907,35096,35586,36949,
38859,39759,20083,20369,20754,20842,63943,21807,21929,23418,23461,24188,24189,
24254,24736,24799,24840,24841,25540,25912,26377,63944,26580,26586,63945,26977,
26978,27833,27943,63946,28216,63947,28641,29494,29495,63948,29788,30001,63949,
30290,63950,63951,32173,33278,33848,35029,35480,35547,35565,36400,36418,36938,
36926,36986,37193,37321,37742,63952,63953,22537,63954,27603,32905,32946,63955,
63956,20801,22891,23609,63957,63958,28516,29607,32996,36103,63959,37399,38287,
63960,63961,63962,63963,32895,25102,28700,32104,34701,63964,22432,24681,24903,
27575,35518,37504,38577,20057,21535,28139,34093,38512,38899,39150,25558,27875,
37009,20957,25033,33210,40441,20381,20506,20736,23452,24847,25087,25836,26885,
27589,30097,30691,32681,33380,34191,34811,34915,35516,35696,37291,20108,20197,
20234,63965,63966,22839,23016,63967,24050,24347,24411,24609,63968,63969,63970,
63971,29246,29669,63972,30064,30157,63973,31227,63974,32780,32819,32900,33505,
33617,63975,63976,36029,36019,36999,63977,63978,39156,39180,63979,63980,28727,
30410,32714,32716,32764,35610,20154,20161,20995,21360,63981,21693,22240,23035,
23493,24341,24525,28270,63982,63983,32106,33589,63984,34451,35469,63985,38765,
38775,63986,63987,19968,20314,20350,22777,26085,28322,36920,37808,39353,20219,
22764,22922,23001,24641,63988,63989,31252,63990,33615,36035,20837,21316,63991,
63992,63993,20173,21097,23381,33471,20180,21050,21672,22985,23039,23376,23383,
23388,24675,24904,28363,28825,29038,29574,29943,30133,
30913,32043,32773,33258,33576,34071,34249,35566,36039,38604,20316,21242,22204,
26027,26152,28796,28856,29237,32189,33421,37196,38592,40306,23409,26855,27544,
28538,30430,23697,26283,28507,31668,31786,34870,38620,19976,20183,21280,22580,
22715,22767,22892,23559,24115,24196,24373,25484,26290,26454,27167,27299,27404,
28479,29254,63994,29520,29835,31456,31911,33144,33247,33255,33674,33900,34083,
34196,34255,35037,36115,37292,38263,38556,20877,21705,22312,23472,25165,26448,
26685,26771,28221,28371,28797,32289,35009,36001,36617,40779,40782,29229,31631,
35533,37658,20295,20302,20786,21632,22992,24213,25269,26485,26990,27159,27822,
28186,29401,29482,30141,31672,32053,33511,33785,33879,34295,35419,36015,36487,
36889,37048,38606,40799,21219,21514,23265,23490,25688,25973,28404,29380,63995,
30340,31309,31515,31821,32318,32735,33659,35627,36042,36196,36321,36447,36842,
36857,36969,37841,20291,20346,20659,20840,20856,21069,21098,22625,22652,22880,
23560,23637,24283,24731,25136,26643,27583,27656,28593,29006,29728,30000,30008,
30033,30322,31564,31627,31661,31686,32399,35438,36670,36681,37439,37523,37666,
37931,38651,39002,39019,39198,20999,25130,25240,27993,30308,31434,31680,32118,
21344,23742,24215,28472,28857,31896,38673,39822,40670,25509,25722,34678,19969,
20117,20141,20572,20597,21576,22979,23450,24128,24237,24311,24449,24773,25402,
25919,25972,26060,26230,26232,26622,26984,27273,27491,27712,28096,28136,28191,
28254,28702,28833,29582,29693,30010,30555,30855,31118,31243,31357,31934,32142,
33351,35330,35562,35998,37165,37194,37336,37478,37580,
37664,38662,38742,38748,38914,40718,21046,21137,21884,22564,24093,24351,24716,
25552,26799,28639,31085,31532,33229,34234,35069,35576,36420,37261,38500,38555,
38717,38988,40778,20430,20806,20939,21161,22066,24340,24427,25514,25805,26089,
26177,26362,26361,26397,26781,26839,27133,28437,28526,29031,29157,29226,29866,
30522,31062,31066,31199,31264,31381,31895,31967,32068,32368,32903,34299,34468,
35412,35519,36249,36481,36896,36973,37347,38459,38613,40165,26063,31751,36275,
37827,23384,23562,21330,25305,29469,20519,23447,24478,24752,24939,26837,28121,
29742,31278,32066,32156,32305,33131,36394,36405,37758,37912,20304,22352,24038,
24231,25387,32618,20027,20303,20367,20570,23005,32964,21610,21608,22014,22863,
23449,24030,24282,26205,26417,26609,26666,27880,27954,28234,28557,28855,29664,
30087,31820,32002,32044,32162,33311,34523,35387,35461,36208,36490,36659,36913,
37198,37202,37956,39376,31481,31909,20426,20737,20934,22472,23535,23803,26201,
27197,27994,28310,28652,28940,30063,31459,34850,36897,36981,38603,39423,33537,
20013,20210,34886,37325,21373,27355,26987,27713,33914,22686,24974,26366,25327,
28893,29969,30151,32338,33976,35657,36104,20043,21482,21675,22320,22336,24535,
25345,25351,25711,25903,26088,26234,26525,26547,27490,27744,27802,28460,30693,
30757,31049,31063,32025,32930,33026,33267,33437,33463,34584,35468,63996,36100,
36286,36978,30452,31257,31287,32340,32887,21767,21972,22645,25391,25634,26185,
26187,26733,27035,27524,27941,28337,29645,29800,29857,30043,30137,30433,30494,
30603,31206,32265,32285,33275,34095,34967,35386,36049,
36587,36784,36914,37805,38499,38515,38663,20356,21489,23018,23241,24089,26702,
29894,30142,31209,31378,33187,34541,36074,36300,36845,26015,26389,63997,22519,
28503,32221,36655,37878,38598,24501,25074,28548,19988,20376,20511,21449,21983,
23919,24046,27425,27492,30923,31642,63998,36425,36554,36974,25417,25662,30528,
31364,37679,38015,40810,25776,28591,29158,29864,29914,31428,31762,32386,31922,
32408,35738,36106,38013,39184,39244,21049,23519,25830,26413,32046,20717,21443,
22649,24920,24921,25082,26028,31449,35730,35734,20489,20513,21109,21809,23100,
24288,24432,24884,25950,26124,26166,26274,27085,28356,28466,29462,30241,31379,
33081,33369,33750,33980,20661,22512,23488,23528,24425,25505,30758,32181,33756,
34081,37319,37365,20874,26613,31574,36012,20932,22971,24765,34389,20508,63999,
21076,23610,24957,25114,25299,25842,26021,28364,30240,33034,36448,38495,38587,
20191,21315,21912,22825,24029,25797,27849,28154,29588,31359,33307,34214,36068,
36368,36983,37351,38369,38433,38854,20984,21746,21894,24505,25764,28552,32180,
36639,36685,37941,20681,23574,27838,28155,29979,30651,31805,31844,35449,35522,
22558,22974,24086,25463,29266,30090,30571,35548,36028,36626,24307,26228,28152,
32893,33729,35531,38737,39894,64000,21059,26367,28053,28399,32224,35558,36910,
36958,39636,21021,21119,21736,24980,25220,25307,26786,26898,26970,27189,28818,
28966,30813,30977,30990,31186,31245,32918,33400,33493,33609,34121,35970,36229,
37218,37259,37294,20419,22225,29165,30679,34560,35320,23544,24534,26449,37032,
21474,22618,23541,24740,24961,25696,32317,32880,34085,
37507,25774,20652,23828,26368,22684,25277,25512,26894,27000,27166,28267,30394,
31179,33467,33833,35535,36264,36861,37138,37195,37276,37648,37656,37786,38619,
39478,39949,19985,30044,31069,31482,31569,31689,32302,33988,36441,36468,36600,
36880,26149,26943,29763,20986,26414,40668,20805,24544,27798,34802,34909,34935,
24756,33205,33795,36101,21462,21561,22068,23094,23601,28810,32736,32858,33030,
33261,36259,37257,39519,40434,20596,20164,21408,24827,28204,23652,20360,20516,
21988,23769,24159,24677,26772,27835,28100,29118,30164,30196,30305,31258,31305,
32199,32251,32622,33268,34473,36636,38601,39347,40786,21063,21189,39149,35242,
19971,26578,28422,20405,23522,26517,27784,28024,29723,30759,37341,37756,34756,
31204,31281,24555,20182,21668,21822,22702,22949,24816,25171,25302,26422,26965,
33333,38464,39345,39389,20524,21331,21828,22396,64001,25176,64002,25826,26219,
26589,28609,28655,29730,29752,35351,37944,21585,22022,22374,24392,24986,27470,
28760,28845,32187,35477,22890,33067,25506,30472,32829,36010,22612,25645,27067,
23445,24081,28271,64003,34153,20812,21488,22826,24608,24907,27526,27760,27888,
31518,32974,33492,36294,37040,39089,64004,25799,28580,25745,25860,20814,21520,
22303,35342,24927,26742,64005,30171,31570,32113,36890,22534,27084,33151,35114,
36864,38969,20600,22871,22956,25237,36879,39722,24925,29305,38358,22369,23110,
24052,25226,25773,25850,26487,27874,27966,29228,29750,30772,32631,33453,36315,
38935,21028,22338,26495,29256,29923,36009,36774,37393,38442,20843,21485,25420,
20329,21764,24726,25943,27803,28031,29260,29437,31255,
35207,35997,24429,28558,28921,33192,24846,20415,20559,25153,29255,31687,32232,
32745,36941,38829,39449,36022,22378,24179,26544,33805,35413,21536,23318,24163,
24290,24330,25987,32954,34109,38281,38491,20296,21253,21261,21263,21638,21754,
22275,24067,24598,25243,25265,25429,64006,27873,28006,30129,30770,32990,33071,
33502,33889,33970,34957,35090,36875,37610,39165,39825,24133,26292,26333,28689,
29190,64007,20469,21117,24426,24915,26451,27161,28418,29922,31080,34920,35961,
39111,39108,39491,21697,31263,26963,35575,35914,39080,39342,24444,25259,30130,
30382,34987,36991,38466,21305,24380,24517,27852,29644,30050,30091,31558,33534,
39325,20047,36924,19979,20309,21414,22799,24264,26160,27827,29781,33655,34662,
36032,36944,38686,39957,22737,23416,34384,35604,40372,23506,24680,24717,26097,
27735,28450,28579,28698,32597,32752,38289,38290,38480,38867,21106,36676,20989,
21547,21688,21859,21898,27323,28085,32216,33382,37532,38519,40569,21512,21704,
30418,34532,38308,38356,38492,20130,20233,23022,23270,24055,24658,25239,26477,
26689,27782,28207,32568,32923,33322,64008,64009,38917,20133,20565,21683,22419,
22874,23401,23475,25032,26999,28023,28707,34809,35299,35442,35559,36994,39405,
39608,21182,26680,20502,24184,26447,33607,34892,20139,21521,22190,29670,37141,
38911,39177,39255,39321,22099,22687,34395,35377,25010,27382,29563,36562,27463,
38570,39511,22869,29184,36203,38761,20436,23796,24358,25080,26203,27883,28843,
29572,29625,29694,30505,30541,32067,32098,32291,33335,34898,64010,36066,37449,
39023,23377,31348,34880,38913,23244,20448,21332,22846,
23805,25406,28025,29433,33029,33031,33698,37583,38960,20136,20804,21009,22411,
24418,27842,28366,28677,28752,28847,29074,29673,29801,33610,34722,34913,36872,
37026,37795,39336,20846,24407,24800,24935,26291,34137,36426,37295,38795,20046,
20114,21628,22741,22778,22909,23733,24359,25142,25160,26122,26215,27627,28009,
28111,28246,28408,28564,28640,28649,28765,29392,29733,29786,29920,30355,31068,
31946,32286,32993,33446,33899,33983,34382,34399,34676,35703,35946,37804,38912,
39013,24785,25110,37239,23130,26127,28151,28222,29759,39746,24573,24794,31503,
21700,24344,27742,27859,27946,28888,32005,34425,35340,40251,21270,21644,23301,
27194,28779,30069,31117,31166,33457,33775,35441,35649,36008,38772,64011,25844,
25899,30906,30907,31339,20024,21914,22864,23462,24187,24739,25563,27489,26213,
26707,28185,29029,29872,32008,36996,39529,39973,27963,28369,29502,35905,38346,
20976,24140,24488,24653,24822,24880,24908,26179,26180,27045,27841,28255,28361,
28514,29004,29852,30343,31681,31783,33618,34647,36945,38541,40643,21295,22238,
24315,24458,24674,24724,25079,26214,26371,27292,28142,28590,28784,29546,32362,
33214,33588,34516,35496,36036,21123,29554,23446,27243,37892,21742,22150,23389,
25928,25989,26313,26783,28045,28102,29243,32948,37237,39501,20399,20505,21402,
21518,21564,21897,21957,24127,24460,26429,29030,29661,36869,21211,21235,22628,
22734,28932,29071,29179,34224,35347,26248,34216,21927,26244,29002,33841,21321,
21913,27585,24409,24509,25582,26249,28999,35569,36637,40638,20241,25658,28875,
30054,34407,24676,35662,40440,20807,20982,21256,27958,
33016,40657,26133,27427,28824,30165,21507,23673,32007,35350,27424,27453,27462,
21560,24688,27965,32725,33288,20694,20958,21916,22123,22221,23020,23305,24076,
24985,24984,25137,26206,26342,29081,29113,29114,29351,31143,31232,32690,35440,

View file

@ -0,0 +1,40 @@
256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,
275,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,
296,297,298,299,302,303,304,305,308,309,310,311,312,313,314,315,316,317,318,
321,322,323,324,325,326,327,328,330,331,332,333,336,337,338,339,340,341,342,
343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,
362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,
381,382,402,416,417,431,432,536,537,538,539,710,711,728,729,731,732,733,768,
769,771,777,803,890,900,901,902,904,905,906,908,910,911,912,913,914,915,916,
917,918,919,920,921,922,923,924,925,926,927,928,929,931,932,933,934,935,936,
937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,
956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,
1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1038,1039,1040,
1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,
1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,
1071,
1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,
1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,
1102,1103,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1118,
1119,1168,1169,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1467,1468,
1469,1470,1471,1472,1473,1474,1475,1488,1489,1490,1491,1492,1493,1494,1495,
1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,
1511,1512,1513,1514,1520,1521,1522,1523,1524,1548,1563,1567,1569,1570,1571,
1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,
1587,1588,1589,1590,1591,1592,1593,1594,1600,1601,1602,1603,1604,1605,1606,
1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,1617,1618,1657,1662,1670,
1672,1681,1688,1705,1711,1722,1726,1729,1746,3585,3586,3587,3588,3589,3590,
3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,
3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,
3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,
3636,3637,3638,3639,3640,3641,3642,3647,3648,3649,3650,3651,3652,3653,3654,
3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,
3670,3671,3672,3673,3674,3675,7682,7683,7690,7691,7710,7711,7744,7745,7766,
7767,
7776,7777,7786,7787,7808,7809,7810,7811,7812,7813,7922,7923,8204,8205,8206,
8207,8211,8212,8213,8215,8216,8217,8218,8220,8221,8222,8224,8225,8226,8230,
8240,8249,8250,8319,8359,8362,8363,8364,8367,8470,8482,8729,8730,8734,8745,
8776,8801,8804,8805,8976,8992,8993,9472,9474,9484,9488,9492,9496,9500,9508,
9516,9524,9532,9552,9553,9554,9555,9556,9557,9558,9559,9560,9561,9562,9563,
9564,9565,9566,9567,9568,9569,9570,9571,9572,9573,9574,9575,9576,9577,9578,
9579,9580,9600,9604,9608,9612,9616,9617,9618,9619,9632,

57
libc/stdio/mkdtemp.c Normal file
View file

@ -0,0 +1,57 @@
/*-*- 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 2022 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/calls/calls.h"
#include "libc/errno.h"
#include "libc/rand/rand.h"
#include "libc/stdio/temp.h"
#include "libc/str/str.h"
#include "libc/sysv/errfuns.h"
/**
* Creates temporary directory.
*
* @param template must end with XXXXXX which is replaced with
* nondeterministic base36 random data
* @return pointer to template on success, or NULL w/ errno
* @raise EINVAL if template didn't end with XXXXXX
*/
char *mkdtemp(char *template) {
int i, j, n, x;
if ((n = strlen(template)) >= 6 && !memcmp(template + n - 6, "XXXXXX", 6)) {
x = rand64();
for (i = 0; i < 10; ++i) {
for (j = 0; j < 6; ++j) {
template[n - 6 + j] = "0123456789abcdefghijklmnopqrstuvwxyz"[x % 36];
x /= 36;
}
if (!mkdir(template, 0700)) {
return template;
}
if (errno != EEXIST) {
break;
}
}
for (j = 0; j < 6; ++j) {
template[n - 6 + j] = 'X';
}
} else {
einval();
}
return 0;
}

515
libc/stdio/revjis.inc Normal file
View file

@ -0,0 +1,515 @@
31,80,81,87,14,299,74,61,12,344,62,63,1280,1281,1282,1283,1284,1285,1286,1287,
1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,
1303,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1325,
1326,1327,1328,1329,1330,1331,1332,1333,1334,1335,1542,1536,1537,1538,1539,
1540,1541,1543,1544,1545,1546,1547,1548,1549,1550,1551,1552,1553,1554,1555,
1556,1557,1558,1559,1560,1561,1562,1563,1564,1565,1566,1567,1568,1584,1585,
1586,1587,1588,1589,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,
1602,1603,1604,1605,1606,1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,
1590,29,28,33,37,38,39,40,342,343,36,35,338,75,76,263,77,337,266,267,265,268,
300,301,302,318,303,319,281,282,60,324,326,70,315,297,298,288,287,328,329,71,
327,325,321,65,320,68,69,322,323,285,286,283,284,316,317,1792,1803,1793,1804,
1794,1805,1795,1806,1797,1808,1796,1807,1798,1819,1814,1809,1800,1821,1816,
1811,1799,1815,1820,1810,1801,1817,1822,1812,1802,1818,1823,1813,258,257,260,
259,262,261,256,93,90,92,91,349,89,88,73,72,341,340,339,0,1,2,22,24,25,26,49,
50,51,52,53,54,55,56,57,58,264,269,43,44,32,
768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,
787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,
806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,
825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,
844,845,846,847,848,849,850,10,11,20,21,1024,1025,1026,1027,1028,1029,1030,
1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1041,1042,1043,1044,1045,
1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,
1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,
1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,
1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,
1106,1107,1108,1109,5,27,18,19,3915,8793,6934,10843,7493,6671,7492,4379,10291,
11294,12033,4110,4685,12034,7939,12577,5173,10521,7494,11549,10529,12035,8773,
12036,5465,12037,4924,8719,6982,12038,12039,12040,9748,5174,9750,9538,5922,
10770,18472,12041,7495,12042,4372,5444,5967,11080,13573,11343,9564,4868,5140,
12043,12044,11546,11292,8263,12046,6741,9554,12049,4125,5950,5949,3909,11818,
11817,6418,3840,12050,12051,12052,10771,12053,5969,3910,10833,5211,5212,5213,
9025,11547,12054,12055,12056,7724,7193,7725,12061,12059,12060,5175,6402,4431,
12058,12057,10504,6693,6692,8477,12062,10292,8006,23,12063,12065,8516,11584,
3881,12064,4381,5411,8774,5710,12066,9731,4938,12067,3882,5951,4939,10329,
10001,5176,4432,12102,9248,9803,12069,10011,11585,7692,6694,6742,4383,9008,
8705,12073,3883,9026,7194,6419,11267,8493,4382,12072,11293,12068,12070,6477,
12071,13315,12079,12082,12080,4385,10522,12074,12078,5970,6695,4869,12083,
12075,11586,6743,12076,12081,12084,12077,5376,3884,5377,4384,13316,10840,
10317,5971,7694,11542,10551,5655,8452,4419,7218,12088,12093,12091,12086,8462,
12089,12092,12090,10556,12087,7693,10834,12094,12095,7171,12108,9775,10261,
12103,10575,4373,12107,12101,12110,8241,5923,9787,16166,12109,9276,12098,5973,
5972,12096,6969,12104,10574,8748,12100,5712,12097,12105,12099,11568,12106,
11808,5445,5711,12111,12112,12116,3885,10543,12115,12114,12118,12117,9027,
5713,12119,6948,8453,9028,5461,12120,5141,12121,12123,10772,5701,6672,10070,
12122,6436,11298,12125,12290,12124,6435,7260,5656,12291,5422,12288,12289,9486,
8283,5378,10796,12292,11548,12293,12296,12294,8237,12295,12297,12299,12298,
10535,5142,12301,12302,4366,12300,6995,12305,12304,12303,12085,12306,7261,
12307,11268,11064,12309,12308,12311,12310,12312,12313,3923,5908,5658,7195,
8794,5379,8007,5974,6221,12315,11047,9253,6744,12314,12316,9277,4692,12317,
9565,8211,12319,12320,9995,5975,11802,12321,5381,10523,8469,5456,
9236,5714,12322,12323,9537,4158,12326,6492,12325,6437,12327,17741,12328,10784,
12329,12330,12331,7496,6955,4870,12334,12332,11036,12333,10297,12335,12336,
12337,9278,12341,12339,12340,12338,6466,12342,11081,11587,12343,7943,12344,
7225,12345,8795,11550,9279,12580,12346,21252,5412,12347,10813,7239,8539,12349,
9539,12350,12351,4621,12352,5382,9515,4185,7215,9984,12353,9280,7726,12354,
10507,7993,4865,4872,12355,12357,5657,12356,11602,7240,10012,10539,12358,
11351,12359,12360,9309,12361,7944,6493,5715,12362,6696,6222,9029,12364,8454,
6478,12365,12366,8207,12363,12368,10773,6211,12367,5716,6461,9804,12371,12369,
10330,7497,12378,4675,12372,12370,8238,12374,12373,4643,5695,12379,11532,
12375,12380,12377,12376,11566,5976,4386,11603,7252,9271,6212,12545,12546,
11588,11786,12548,5977,12547,4622,12549,10805,8987,11269,10552,12550,20276,
9487,12551,4873,11026,7424,12552,10566,12556,7945,12553,5423,12554,4874,5645,
12557,12558,12559,12560,6970,5978,11069,11079,9558,10576,12561,12562,12564,
12566,12565,12567,4380,10795,6491,12568,8248,7425,5384,12569,10042,12570,
12571,12572,12573,10243,5447,3908,9502,12574,7196,8008,12576,12575,7426,5952,
12578,10013,12579,10043,8467,8525,5383,9549,8720,9805,10797,12581,8009,5652,
12582,12583,4107,3924,4940,8455,5168,11344,12586,4374,12585,5385,12587,11088,
12588,11569,5979,5909,12589,12591,12590,7742,4120,4157,12592,12593,5910,12594,
5197,6673,12595,10835,6420,5177,11270,8239,10014,7004,7206,6983,
6996,7253,10015,12598,4130,8240,5980,5924,5446,12602,8704,8541,5386,7427,
12603,12601,4387,8517,6935,6698,4101,4687,6213,6697,12604,12605,5160,4645,
6214,5159,9022,4100,9488,11037,6144,11352,9254,5981,5646,12614,5442,10793,
10044,12613,4925,12608,12609,12611,12612,5178,7744,10508,12610,12606,5954,
12607,11779,10577,9031,5953,6223,12615,9532,12619,7005,6997,12622,12620,11010,
12617,12626,12621,12624,5925,11038,12625,12627,12629,6479,11809,12618,12616,
12628,12623,12631,12802,12633,12637,12800,12634,12829,6472,4624,12632,12804,
3925,12803,3844,10281,12801,12635,12630,12636,6439,12805,3926,12814,12806,
12807,7428,10824,12812,12811,9230,12813,12810,4115,6421,7695,12808,9281,12809,
3841,12819,11266,7430,12825,12824,12815,8482,12816,8526,12821,7429,12818,
11075,5659,12822,12823,12820,12826,12817,12832,12837,12833,12828,12838,8208,
12840,6145,12830,8796,12834,12827,4876,4941,4676,12835,12831,5717,12841,12839,
8242,5161,5387,12836,5459,4131,12845,12843,13062,12848,12842,12846,12844,6699,
12847,12850,12855,12853,12852,8721,4388,12849,12851,7431,4114,12854,4413,
12865,7515,12861,12859,12860,12862,4124,8216,12856,12857,4697,12864,4942,
12867,12863,12866,10509,9524,10007,12869,12868,4644,12870,12873,12872,12871,
9752,12874,12875,12877,12876,12879,12882,12880,12878,12881,12883,12884,12885,
12886,12887,12324,7003,6700,4434,3927,8739,12888,6403,3886,7741,12889,5926,
6224,12891,12890,10559,12892,13056,12893,13057,13058,5718,4159,13059,13061,
13060,
13063,9273,13064,3860,6462,5660,8750,13065,13066,13068,13069,6467,5424,10774,
13067,13070,6432,6146,13074,6404,8722,13071,9017,13075,7745,13073,13076,5662,
13077,13078,6147,4639,13080,13081,13082,13079,13072,13083,13084,10819,7498,
13086,13087,13085,13089,9751,3911,10293,13090,7516,6936,9788,4943,6474,10808,
9489,5719,8494,13088,13091,8483,13092,13093,13095,9032,4877,21248,4160,10578,
7499,9255,6469,13101,10524,11580,4435,13097,8217,13100,9282,9256,9283,10008,
9004,6440,13096,4181,9237,13098,13094,7727,13102,7213,5388,13103,10567,8284,
8997,13105,10798,13106,13111,10510,13110,13104,13107,13109,6405,10536,13112,
8740,4436,7500,13114,13113,6215,13115,13117,13116,13119,13108,13121,13120,
13118,6701,7728,8243,13122,7963,3916,9795,9018,13124,13123,13125,13126,13127,
13128,10544,13129,4389,13130,11291,4623,12584,7207,8478,13131,11082,11027,
13133,8518,9238,8479,10294,13134,13135,4186,6937,13136,3887,13137,13138,4161,
4944,9535,10579,13142,8244,13141,5663,10810,13140,9284,13144,13143,13146,
13145,4187,13147,7432,13149,8708,13148,10514,7254,9274,13312,6148,13313,9728,
10045,11056,9732,13322,5143,11300,11022,13579,13314,13317,8484,10775,9257,
13318,10820,6441,7433,13319,6703,6702,3864,5927,7946,3888,13323,13324,13321,
4119,4878,13320,11044,10256,3847,3928,6704,3889,3842,13329,13327,11035,13330,
13328,13326,7696,13325,10553,5955,13334,13335,7434,13331,11787,9771,13333,
6406,13336,10295,13337,13332,11034,9789,13338,10257,13339,13343,
13340,4390,13342,6938,13341,5720,13355,13348,13345,8771,13344,13346,13347,
13349,13350,4945,13352,13351,13353,7501,13356,9019,4132,13354,13357,13358,
13361,13359,13360,6705,13362,6149,13363,6745,8471,13364,13365,6713,6150,11057,
5127,5928,13366,4663,13367,8472,13368,13570,13369,13370,13371,13373,13374,
13375,8527,4102,6984,3873,8246,4879,6932,6151,9285,7168,4880,8775,9033,3863,
5144,10580,6945,5169,8010,6939,11271,13376,5179,6442,4625,4162,7435,4391,
13377,11301,7208,6979,13378,4946,9521,11016,13379,13380,10296,13382,4871,5462,
13381,4881,7697,13386,6656,4392,13385,13383,13387,13384,9738,15148,7698,13388,
11551,13389,13391,8797,13390,7938,6746,8495,6998,10324,8011,6956,13392,7436,
13393,13394,3890,8473,7729,13395,9490,7437,7438,13396,8012,7439,13397,13398,
11071,13399,5413,7169,13400,13401,6971,7691,9555,7731,10071,9729,5416,13402,
5198,13403,5469,9518,4367,6706,13404,13569,13568,5468,13405,9239,8463,9258,
6951,8247,11353,13571,13572,9525,6674,13574,13575,13576,4947,13577,13578,4363,
8218,4931,13580,11015,8497,4664,13582,13584,4926,13581,13583,13586,13585,
13587,13588,9500,5389,4420,13589,13594,13592,10582,10581,9286,13591,7219,
13590,7761,13595,6473,13601,13602,13596,4626,13597,13606,13605,13604,13600,
13599,13603,10583,13610,13607,13609,11345,13608,13598,7762,13611,6422,13612,
13613,13616,13615,13614,9287,13593,13622,13618,13617,13619,13620,13623,11589,
13624,13621,13625,4927,13626,13628,13627,13629,13630,8013,7170,
7235,8258,6152,6423,6153,5199,13631,6424,5929,13632,11013,9762,13633,6154,
4875,8710,5425,6707,10298,10016,13634,4948,13637,8960,13636,13635,13638,9034,
7746,6708,7977,8498,5121,8961,13639,13640,7502,10776,13643,13642,13641,10332,
13650,10809,13644,13646,10826,13645,13647,9991,13648,10525,13649,4882,10526,
9742,13651,13652,6155,4883,13653,5911,11299,11272,4949,13655,8962,6156,7440,
10046,7441,7255,9035,10584,9240,6157,10299,13656,9272,6433,5930,9036,3874,
7245,6158,11302,13657,13658,9776,13659,11606,11788,13661,13660,4646,13824,
13827,13828,13826,10271,7442,13830,13829,13825,13831,13832,13833,13836,13834,
13835,13837,4163,9037,13838,5721,4437,9749,13839,9562,10554,13840,11789,13841,
10527,13844,12032,12048,6927,9556,13845,5180,8963,3929,13846,10501,6159,8751,
9038,11086,5912,5931,13847,13848,13854,6980,8964,5390,13849,10250,8741,13850,
13851,5391,13852,13853,13855,9301,13856,13857,13858,13843,13842,13859,5664,
10246,6443,10262,8965,10282,13860,7443,4133,13861,13862,11089,10047,13865,
4188,7947,13864,13863,5665,8499,13869,13867,13866,11526,5956,7256,13868,9259,
7197,9503,13872,13871,13870,13873,5957,13874,10331,7226,13875,10072,9504,8966,
9231,13876,5130,7699,10251,4950,9733,13877,6709,10777,10778,4189,13882,8776,
13879,4438,14092,13881,9743,13880,13878,6233,13884,13890,13896,13888,9275,
13893,10300,13887,13892,11590,6710,8500,13885,5181,13895,7948,4164,13889,4439,
13894,5392,13891,13897,13899,13909,13907,13904,13903,11607,
13905,5393,6160,7257,13912,13898,13902,13886,4441,13906,13908,8752,6407,4375,
13900,13911,13910,5394,8456,4677,5666,13901,13913,13916,14080,6940,14086,9039,
13914,14084,4440,14082,14083,13917,14081,5958,11273,4884,4152,14085,9753,3852,
10048,13883,14091,14095,11076,14088,9288,14093,7503,14094,9526,11814,14090,
14096,6234,7978,3891,14089,14087,8249,13915,6675,8485,14108,8250,14103,14100,
14101,6981,14104,14107,14102,7172,14105,14099,11099,11098,14109,14110,3892,
14098,5457,3845,4885,14106,14114,14113,14118,14119,14117,14120,14112,14116,
14121,14122,14111,6747,14115,8501,6161,14097,7700,14135,10568,14125,14126,
14127,14134,14133,10844,4886,14131,5668,4627,14128,11543,14130,3893,14132,
14123,14129,14136,5667,14124,11324,11274,14139,14143,8285,11608,14144,14141,
14138,14137,14142,10511,9491,5669,14145,14140,14146,5722,4368,14154,4887,
14152,14153,6408,14151,14149,14148,14155,14147,14157,4442,14159,14158,8967,
14162,14160,14150,5723,14161,14165,14164,14166,14163,14167,14168,14169,10569,
14171,14170,7198,7949,4421,4443,14172,3870,7979,14173,19234,14336,5696,14337,
8014,14338,14339,5145,14340,14341,14342,8502,5932,11072,10779,7241,14343,8015,
19740,10049,6985,6444,14344,8486,10502,8528,14347,14345,14348,14346,14349,
10512,3862,10301,10050,14350,14353,7444,5146,14351,14358,7445,14352,9763,
11325,14354,14355,14359,9289,14356,6162,7997,14373,10003,8529,10051,14604,
10585,9040,10836,14362,4352,8777,14371,8723,14365,14372,14367,14374,14370,
14369,9806,14363,
4444,14361,5200,8530,14357,14360,6163,7994,7446,14368,9777,5201,4647,4678,
7680,14376,14381,14377,5724,14382,6657,6216,7173,14364,6748,14379,6711,14380,
3875,14375,8968,5202,5395,14378,3846,6434,7701,9041,10035,14384,8253,8457,
6666,14385,14387,14383,10560,8988,8251,10586,6957,14399,14398,7767,5725,14392,
7448,9543,9744,14390,8252,6999,14395,7447,14389,14394,9778,14388,5632,4668,
14396,11530,6445,8724,14393,7995,6164,7747,4165,8219,14391,5156,5670,9006,
14397,8254,14400,14402,8470,14408,14403,14405,10272,9042,14406,11275,11303,
4888,3853,14404,14401,4951,4166,14407,11304,14411,8474,14418,14412,14409,
14416,14386,14413,14417,10017,9290,14410,14414,5671,6480,7996,14422,9221,
14419,10815,14420,14421,11053,7937,5697,14428,6676,14425,14424,9745,9492,9232,
14426,14427,10318,9764,6658,8016,10799,4648,14596,14429,11305,14598,14594,
14595,8255,14593,14366,14597,14592,14602,14603,9222,14605,6659,14600,5147,
14606,14599,14610,14609,14608,14611,14613,7504,14612,14616,14614,14615,14415,
14618,14617,14423,14619,14607,6712,14620,14621,14623,14622,14624,4445,6165,
10587,7950,5933,14626,14629,10289,5182,14628,14627,9779,14630,5396,14632,
14631,4889,6677,9527,5672,7763,14633,7951,9223,10302,14634,14635,14636,10519,
13372,7973,10283,6455,10052,10018,9260,11552,14638,6959,14639,3861,5427,7980,
10303,14640,6689,8742,6714,7702,14641,10588,4182,6715,14644,14642,14645,11544,
14643,8026,14646,8465,14647,4953,14649,14648,14650,14651,4954,9563,
8725,5195,6716,8256,7227,3855,14652,4353,14656,6166,14655,6410,7449,14654,
7450,11039,6409,3894,7981,14661,7952,4134,7220,10821,6481,7451,7942,14660,
14658,14659,8778,14853,14665,6749,6167,14663,14664,7703,14662,6670,14667,
14666,14671,14672,14668,4609,14669,14670,10036,10304,5673,14673,7953,7452,
8753,5414,14674,14678,4394,14675,14677,14676,7242,8743,3876,14679,14680,8969,
11600,6690,10570,10780,14849,14682,14685,14684,14681,14848,9533,14683,14850,
7243,14851,11306,9815,14852,14854,14855,14856,5417,4135,6168,14857,14858,7248,
8257,12599,8221,8220,8503,6438,12113,5709,11276,10589,10333,14859,6482,8990,
14860,11790,10781,8970,14861,4955,14862,14863,11065,11011,10837,10811,6660,
14865,6986,10800,14867,14870,14869,4952,5183,14866,14868,14871,7768,11354,
3880,6463,8475,6972,7506,14874,9261,14872,8458,14873,7505,11068,14875,14876,
11335,14881,6169,9780,14878,9291,14653,14657,5166,9766,14880,7453,10019,14886,
10073,14877,14883,14882,7982,10828,11570,10822,4395,6717,11815,14885,7764,
14884,14879,5934,14891,14889,4396,14887,14893,14899,8487,10528,14901,10241,
14900,9807,10782,4890,8022,7199,9010,11277,14896,14895,14897,14894,14902,
14892,14890,14898,14888,8779,11095,6949,6483,6425,10830,4640,9005,9513,4136,
8017,7955,5641,14904,6170,4699,14906,4691,14912,14909,8018,4650,6411,4649,
6446,14907,5700,5674,9292,14905,3877,14908,14910,5420,5643,4891,5162,14913,
6488,10832,6678,14914,10255,14926,4370,14915,14932,14916,11553,14923,
9790,14931,14918,3859,14920,6171,14922,14921,14917,14928,7454,13132,5959,
11355,14919,9043,4610,6412,14911,14927,4672,14925,14929,9293,4957,15121,11048,
14934,4956,14941,10783,15104,15106,15110,14936,8713,9294,15114,14939,15111,
15105,7704,15115,7954,15113,4892,11823,14933,15109,3895,14935,11033,14940,
7681,8998,14930,15108,7769,15118,4688,5888,15120,14937,15119,15112,14938,
15116,15117,15134,9517,15107,15130,15132,9015,11307,10325,15127,8489,15133,
8222,15124,15137,15136,9550,15135,9545,15139,15126,5415,15129,7228,9791,15131,
5418,15123,15125,15122,11791,4665,15128,15138,4628,6470,4156,15155,11792,
15158,7705,15157,15156,15153,15141,15170,15140,15159,15151,15146,15143,15144,
15152,21249,15149,6172,8999,8259,15147,15142,15145,11308,10825,15150,15160,
15168,15161,15174,15172,15167,15166,9007,8260,15164,15162,15169,15175,10068,
15181,15176,15179,15173,8787,10263,15163,15171,7455,11054,15191,15178,5889,
4354,4670,15154,7456,15183,15190,7000,4689,8717,15180,15185,15189,5397,5163,
15187,5120,9514,15186,15188,15182,15184,4671,8744,15195,15193,5960,15192,
15360,14903,15194,15196,15197,15371,15367,14924,15366,15365,15362,15177,15364,
15363,15369,11781,15372,5466,15368,15370,9990,15373,15377,15374,11346,15375,
15165,15378,15379,4116,15381,5702,6912,5428,4355,11326,15383,15382,15385,5148,
5429,4893,15388,15387,15389,4397,8726,15390,4894,15392,15391,15393,15394,
15395,6718,7956,6400,10319,10561,11811,6740,6447,11601,15396,15397,6719,15398,
15399,15401,15400,10807,
7229,6987,6691,15402,15404,7682,15403,15405,15406,15407,15408,15409,15411,
15410,15412,4356,8745,15413,6661,4651,15414,9249,13099,5122,15415,15416,10571,
10823,9510,15417,10053,10074,11058,15418,15420,15419,15422,15421,15424,6720,
11024,15425,15426,5123,15427,15429,15428,7748,10264,4137,10020,9044,7200,5184,
10021,6925,15431,4895,4183,9553,15430,6173,8754,15432,15440,15433,8480,5185,
15441,5703,5124,15439,15437,15434,11327,8991,9528,15435,15443,15442,5634,4364,
6426,15436,15438,10806,8531,10838,15451,15452,4398,10503,11100,15616,6914,
7457,15447,15453,4167,5398,15444,15449,8019,9808,10054,15446,10752,15448,
15619,15617,15450,10753,9767,5186,9220,8780,15620,15618,8504,15445,4138,11309,
15631,15630,8021,15627,11339,9493,15621,8996,4139,6174,15624,7174,15629,15628,
15623,15626,4679,15625,9768,11533,7507,8020,15637,15635,10284,15632,15634,
4121,6175,11793,4636,10305,11328,4611,7706,15636,15641,7458,11279,15638,15633,
15639,11581,9298,9505,4629,4148,15645,15648,11554,11331,15655,15649,15646,
11571,15652,7209,15654,15659,9296,15657,15651,8727,15658,15647,15653,15660,
3931,15650,15661,7707,7230,10500,6413,15642,15656,9241,7957,4680,6448,7459,
15644,7201,5675,15643,15665,7244,5913,15680,15674,5203,9262,15669,15678,3854,
4113,4376,15671,8459,15662,15664,6176,15681,15676,15668,15675,11018,15673,
15677,5935,7460,8728,15667,11278,15670,15663,9297,15666,15672,11824,6941,
10845,15682,9997,15694,5914,7231,15684,11534,6177,15697,3917,15695,15683,
15689,15691,11310,15686,9229,15688,15696,15690,11046,15685,6913,15709,4681,
15687,15692,15693,8523,8505,15701,15707,15705,9224,15874,15702,15703,15679,
5208,10265,6942,6230,11794,15699,15873,4168,8261,9816,4896,11609,11008,9009,
15706,15708,8209,15872,15704,15698,4898,5704,15886,15881,8023,4674,7232,15890,
15883,8971,15880,9016,15915,15877,15876,15885,15879,15878,15884,7936,15875,
15887,15888,4897,15893,15892,15894,15897,9250,15891,15895,5698,8536,15889,
9754,15896,15901,15899,15902,15905,15898,6217,9735,15640,11347,15900,15904,
8532,15903,15882,20040,15908,15912,15910,15906,15907,15911,15909,10285,15917,
15914,15913,15916,9523,15918,8788,8524,7940,15919,15921,15920,15700,15922,
9542,15923,4399,9299,4612,5187,6973,6449,11782,7749,4169,15925,15924,15928,
8729,15931,15926,15930,15929,9247,3896,11604,15933,4103,15935,15934,15932,
15927,10754,15937,15936,4170,15939,10513,15938,11028,7462,8210,7461,11610,
15945,8024,15941,15946,4171,15944,9792,15940,15943,7463,10032,15947,6960,8025,
15950,15942,5638,15948,11311,15951,21253,7214,15952,15953,9741,15955,15956,
9746,9300,15958,15960,11572,15957,15959,4172,15954,12858,15961,8262,6679,
15963,15962,7683,12600,15964,16128,15949,15965,16129,9817,16130,16131,16132,
16133,9021,16135,16134,16136,16137,6974,10306,11083,16138,16139,8245,6915,
16140,16141,16142,10545,10022,16143,9782,8972,16144,4422,5196,11045,11029,
4371,11795,10801,10505,7958,16145,9506,5890,16146,6451,16148,16147,16149,
16150,16151,5149,16152,16153,
5891,10023,16155,7508,16154,5399,16156,16158,16157,16159,5936,16160,5448,8223,
6236,16162,16163,16161,6988,9511,5400,16165,8715,16164,11796,9793,16168,16170,
16167,11059,16169,16171,11555,16175,16174,8789,9740,5892,16173,16172,11280,
11281,16176,4173,6229,6721,16177,16178,16180,7202,16182,16181,16183,4652,
16185,16184,16187,16186,5915,11527,5419,4357,5449,4928,11591,16189,16191,
16192,4400,16188,6680,8992,16190,16195,6989,16193,5661,10024,16194,16221,
16200,5916,5188,16197,11356,11535,8533,16199,16201,11573,5430,10075,9769,
16202,16204,16207,16203,16206,5961,4140,16208,7759,16205,11579,16211,21251,
16209,16212,16198,16210,6427,16213,16214,11357,16215,16216,16196,16217,4899,
6916,16218,16219,16220,4122,16384,10266,16385,4867,16386,16387,16388,16390,
16391,16389,10290,16393,16392,16395,16394,16396,16397,16399,16398,6232,16401,
16400,4900,7730,9243,16402,7959,6681,4184,16403,11312,10562,16404,9251,11282,
6178,7708,8746,12563,8973,4423,16405,16406,16411,16409,16408,14625,4613,16407,
3897,9993,10025,11536,16412,16410,8763,7941,9994,10252,16414,11531,5676,16415,
16413,10037,16416,16417,3898,7509,16422,16419,9548,16418,5125,16425,16420,
16421,16424,16423,10244,8225,8224,5150,16426,16427,16428,16430,16429,4149,
16438,10055,16432,16434,16436,7709,16437,16435,6943,16431,16433,10273,7464,
16440,16439,16441,6917,6414,9302,16442,9002,16444,11520,16443,8264,16449,
16451,16452,8755,16450,16447,16445,16446,16448,16455,16453,16454,16456,16458,
16459,16460,16461,16457,
16463,16462,16464,11556,16467,16465,16466,4929,11101,10537,16469,16468,16470,
16471,16475,16472,16473,16474,16476,16477,16640,16641,16642,9998,9263,16643,
9809,10259,16644,16645,9225,4614,6179,16646,16647,16648,6664,16650,16649,
16651,16652,10056,16653,16654,21064,16655,16656,16657,6669,16658,9781,10814,
4141,4150,16659,16661,16660,9295,7960,15384,16662,11040,16663,4901,10038,
16664,16665,16666,11067,11060,8989,8265,16668,7233,7465,16671,16670,16669,
10076,4902,5896,16677,16674,7710,11025,16673,16675,16676,16672,16678,16679,
8974,4930,8772,16680,16681,16684,7750,9507,16685,10802,16682,16683,16688,
16687,16686,16690,16689,16691,16693,16692,10540,7221,11557,16694,9494,16695,
16696,16700,16698,16699,16697,16701,16702,16703,16704,11030,16705,11087,16706,
8749,9801,5450,8730,16707,5401,7983,16708,6428,16709,16710,5893,6452,16712,
9269,6453,5165,10755,9770,9270,6203,16714,7466,11537,6180,5894,9986,16716,
16718,5962,16717,9045,16720,4630,16715,10057,4111,6475,11825,16719,16721,
10538,7992,16723,16724,16722,4653,16730,16729,6918,16731,16726,16732,16727,
10039,16725,16728,16897,16896,10816,16733,3914,16899,16898,7467,16900,8226,
16902,16901,16903,16711,16713,16905,16904,6919,11592,6961,16906,5654,5151,
5126,6722,11283,16912,16911,8227,16908,16910,7210,7711,16909,16907,9737,7468,
10267,6454,9303,16913,16914,16936,5431,11804,8212,16915,4401,9046,10496,16916,
5209,16917,16919,16920,9736,16921,16922,16923,5432,4402,9508,7175,6723,16924,
7176,4393,10274,16925,
10058,8228,16928,16929,9800,7712,16926,8768,16927,7469,3899,5128,16930,9047,
16931,7974,11020,10242,16932,16933,8756,11558,16935,16934,6990,16937,3919,
16940,16938,4403,5677,16939,6181,6225,10565,16941,10803,16943,7984,4142,4377,
3851,16942,16944,16945,7510,16946,4654,16948,5705,5189,16949,5460,16950,8027,
9516,7999,6484,16951,8769,8266,16953,16955,16952,16954,5633,16956,5637,5190,
11313,16958,16959,4109,16962,4693,16961,16960,16964,16957,16965,11528,16966,
16967,13139,16969,16968,16970,16971,11540,16972,20302,7470,16973,16974,7222,
9495,16975,8711,16976,8731,16977,5380,12318,8764,6930,4903,16978,17153,16981,
5191,16980,17155,16979,7471,16983,16984,9226,16985,4669,7737,10307,16987,8519,
16982,16986,16988,6490,17157,10253,9989,9304,5433,17156,17154,10004,16989,
8765,9306,9305,6485,17175,17159,17161,17164,17165,17162,17163,17160,17158,
17152,10542,4404,17172,17169,17174,17173,9810,11014,6682,17167,17176,17171,
17170,17166,17168,4904,8732,8028,9985,17181,9987,8000,17178,10030,17182,10546,
8762,17177,17179,17180,17183,6947,9509,17188,17187,17184,11797,17193,17197,
17194,17190,17191,17196,17185,12596,17192,17186,17195,17201,4905,17198,17199,
17200,17203,17202,10069,17204,11611,10572,17209,17206,17205,7985,17208,17210,
17207,17214,17211,17212,17189,17213,17215,17216,10533,17217,11073,5421,5640,
17218,10515,7751,11023,17219,11538,9811,8229,9747,7212,3871,17224,17222,17220,
4864,7472,17225,17223,17221,17229,17228,17227,17226,17230,17231,7961,17232,
17234,
17233,5937,8215,17236,9307,17235,17237,10516,8267,6182,17238,11559,17240,
17241,17242,17243,6724,17244,5678,5193,5129,17408,11090,6183,17245,17411,
11077,9755,10258,7234,17410,6962,6184,6725,5192,10517,17409,8230,10785,6486,
6726,9020,17414,11582,6456,17415,7713,17417,7473,6415,17416,7177,5917,8231,
17412,17418,17413,5679,17421,17425,5706,17420,17429,6185,11340,3867,17426,
5194,17423,17424,9308,17422,17419,4615,8003,5895,17431,17428,17430,17427,5680,
8466,17432,8269,17445,17441,17435,17439,7001,3900,17434,17442,17446,6186,
11061,9013,17436,17444,17433,8733,17438,3868,11049,17437,5434,10059,8268,
11567,7246,17485,17447,8029,17443,17448,17450,9048,17453,17449,10547,4906,
11050,3901,17452,11612,17451,4174,9547,17454,17461,17455,17462,17458,9818,
6953,17460,17457,17463,17456,7203,10756,7211,17459,17471,17467,17470,17468,
17472,17466,17440,7986,10026,17469,17464,8192,5681,7178,7684,8213,17475,17477,
17478,17474,17476,17465,17473,17481,17480,10841,5642,17479,17483,17482,17486,
17488,6683,17484,17489,17490,17491,17497,9242,17493,17492,17494,17495,17496,
17498,17499,4907,17500,17501,17664,17665,17666,17667,17668,17669,17671,17670,
17672,17673,17674,17677,17675,17676,6464,5682,8757,10002,7247,9772,10060,
17678,14156,17679,17681,11332,17680,17683,17682,11314,17684,10077,17685,17688,
17687,17686,17689,5649,8193,5152,17693,17690,17691,17694,17695,17692,4104,
4358,17697,17698,17699,11329,7179,17701,17700,7752,17702,17703,17704,4932,
4908,17705,17706,10812,11330,
11315,11798,6188,17709,6963,17708,17710,6920,8496,17711,6187,11062,17712,
17713,17714,17715,17716,6921,11084,17718,8734,17717,17720,17719,17721,7962,
17722,17723,10520,17724,8270,17725,17726,11613,17729,17728,17727,8975,17730,
7685,17731,17732,11799,17733,17734,17736,17735,9988,9560,11805,9992,17738,
7474,10249,17739,17737,4909,5939,6727,10061,5897,10786,17742,17740,6189,6190,
3912,6471,9784,3902,17747,8735,9783,8506,17749,17745,17748,17743,17746,10757,
5940,3932,17744,17751,17752,9496,5402,17925,9756,6728,5403,7975,11813,11021,
17750,7987,5170,17753,17755,17754,17756,8709,9757,8976,17922,17921,17757,7732,
10308,17924,17923,6191,11826,17940,17928,17929,6991,17927,6231,17926,17930,
8977,10497,8194,8507,17934,17935,17931,17932,17933,6192,17941,17937,10309,
10827,10247,17936,17939,17938,10787,17942,17943,8214,17944,17946,17950,17947,
17945,9758,17948,17949,4369,17956,17951,17952,17953,8448,17955,17954,17957,
17958,17959,7714,4424,17960,11574,6922,7180,6729,8758,17961,17962,4112,17963,
17964,17965,17966,17967,5404,14601,17968,8004,17969,6954,17970,12047,17971,
10557,4923,8195,7223,10320,7181,17972,6193,17973,10027,17987,17975,8488,9812,
5918,17974,8196,17976,9049,17978,17977,17980,17979,17981,17983,17982,4910,
17984,17985,17986,6416,11560,17988,7686,4175,17989,17990,17991,3921,17992,
17993,10310,6950,17995,4616,3857,17994,17997,9773,7715,4405,10758,5692,5435,
17996,4425,4866,4176,18001,11593,8508,10275,18013,4406,18011,18009,18000,
17998,17999,
6978,5451,8790,9520,4144,18003,18002,18008,18004,18007,11055,18006,4407,4700,
18010,18012,5683,18178,18187,18188,3850,18195,3920,18186,18185,18180,18179,
18177,18176,8770,8538,18182,18181,18184,8271,5684,4128,18183,6194,8272,18201,
18202,4408,4365,18199,18189,18197,18204,18198,18196,18005,18194,18190,4911,
18192,18203,18193,18205,18191,9819,11336,18200,18222,18214,7770,5157,5436,
18209,4410,7475,18212,6457,9264,18217,10573,18208,4409,5941,10248,18218,18206,
18215,18225,18210,18211,9497,18216,18213,10759,18219,3903,18207,18221,18220,
9802,18227,18238,4701,18241,18223,18228,11341,18237,11316,11529,8791,4682,
10321,18243,9472,3856,18236,18232,8273,18226,18234,18239,9739,3849,18231,
18240,10327,18235,18230,7476,7182,6923,11063,10278,18246,18255,18233,4694,
7511,18244,18249,8274,18245,18252,8766,18253,11317,18242,4631,18248,18251,
11019,18254,18247,18250,10760,11776,18258,18265,18257,6946,18224,10541,11009,
18264,18263,18259,18260,4117,18262,18256,9012,18261,3933,8449,10530,18266,
18432,10040,18269,7477,6952,18434,5405,18435,10328,18268,18229,18267,11822,
9473,10322,18442,18448,18449,18436,9813,18446,18438,18440,18450,18439,18443,
4177,9540,18444,18447,18437,8197,18441,6662,7716,5647,11091,11096,7249,18454,
18452,11821,18451,11348,18453,18455,18456,18459,18457,9474,18458,10028,18445,
7250,18460,18465,8275,18464,18433,18466,8232,18461,18463,18462,15376,15361,
18468,18467,11349,16667,18469,18470,18471,5942,5171,18473,12348,5204,11545,
5458,18474,18475,8781,18476,
9561,3865,4418,18481,18482,18477,6684,18478,9761,18479,18480,18490,18484,
18487,18483,18485,18486,6967,18488,8736,5685,4641,18491,4638,18496,18492,
18495,10009,18493,18494,10279,10041,18497,8540,18507,18503,4426,18501,10761,
18502,18499,18500,18505,18508,18506,18504,18498,8759,18515,11017,18513,18514,
18509,18511,18512,18510,8005,11800,18519,18520,18688,7689,18522,18525,18517,
18516,18689,4411,18523,18690,18524,18521,8978,18518,9799,18694,11290,18693,
18692,18701,18695,18703,11333,18706,18697,18698,18702,18705,18704,18696,18699,
18716,18709,18707,18708,18713,18714,4617,5153,18712,18691,18711,18715,18710,
18717,18719,18718,18721,18720,18489,18725,18722,18723,18724,18726,5707,18728,
18727,7183,6195,15622,18729,7216,4632,18730,4145,7478,18731,6196,18732,3904,
10268,18733,7753,18740,18737,8782,18738,18735,5437,18734,18741,5653,8509,
18747,18743,8468,18742,18745,18736,18746,18748,10062,18744,18749,18751,5938,
18739,3872,18750,6458,11605,18752,18753,8276,11521,18754,11284,18755,18756,
10563,18757,6431,11522,18762,18763,7479,18761,11334,18758,18760,7964,7773,
18759,18764,10498,18766,18765,4683,10762,18767,18779,18769,18770,18771,18772,
18776,18777,18775,18773,18768,18774,18778,20246,4359,18781,5438,18780,18945,
18944,18947,18946,18948,7184,18949,18950,18951,7965,11318,18952,10499,9765,
18953,18954,5898,5131,18955,6730,9760,18956,4655,18957,18959,11350,18958,7717,
18960,18961,18962,4912,18963,18964,18965,18966,4656,18967,18968,18969,4433,
7687,18970,18971,18972,5919,9050,18973,
5686,7733,18976,9475,18975,5648,18974,8534,5132,18977,18978,7480,5708,18979,
10763,7998,5205,11092,8233,18980,7718,8783,7481,18981,18984,18985,6429,8481,
18983,7482,10269,18982,6731,4146,18989,5687,6733,6732,11820,18988,18987,8198,
5164,11810,4633,7483,18986,18991,18992,18990,5943,11295,6734,9734,18995,7967,
8737,11285,18998,5963,7966,18994,18999,5964,18996,18997,18993,8001,9512,8718,
4412,10063,5154,8979,19002,19000,8747,7968,4913,19001,7738,11561,11807,19003,
19014,8980,19013,19010,19018,19011,19007,9051,19006,19004,11264,6735,19008,
19005,19012,7251,5920,8537,10788,4153,3905,9476,19016,19015,9541,19020,19009,
19019,19021,5899,19017,6197,6964,19022,11319,19025,19028,19026,10260,19023,
5439,19027,19029,19033,19030,19032,19031,19034,6928,19036,19035,10311,19200,
5688,19037,19201,19202,5155,17696,7512,19203,5965,19204,19205,6685,14637,
19206,19207,7185,19208,19209,19210,19211,19212,8714,19213,19215,19214,9477,
19216,10764,19217,19218,19219,19220,9529,7484,19221,6218,12045,19222,19223,
10270,19224,19232,19225,19227,19226,19228,10789,19229,19230,19231,19233,4620,
9030,10312,6465,6198,10286,4414,10029,19236,4914,7988,19235,19240,8792,11074,
19238,19239,5133,19241,9794,8510,10064,9244,19237,10790,4427,19243,11783,8993,
11812,6736,19242,8464,19259,8199,9559,10287,19246,6686,6737,7485,9796,5900,
19245,19244,10313,6944,9265,19248,19249,6199,19247,19250,19251,19253,8450,
19252,4933,19255,19254,19256,19258,19260,19261,7989,6958,19262,4657,
19263,8277,19264,19265,10314,5134,19266,8981,4154,19267,6992,7765,8460,19270,
19269,19268,19276,19274,19271,19273,19272,19275,5206,19279,7990,19280,5944,
19277,19278,11784,8982,8200,19281,19284,19282,19283,11320,9478,19287,19285,
19286,19288,19464,19291,19292,19290,19289,9052,19456,19460,19457,19293,19458,
19459,19466,19461,7991,19463,19465,19462,19468,7186,19467,19469,19470,19473,
19472,19471,19475,19474,11093,19477,19476,19478,19479,19481,19480,7719,19482,
5452,19483,19485,19486,19487,19484,19488,6965,19489,5135,5650,5901,19490,9551,
9245,19491,19494,6931,19493,19492,5689,19495,4658,19497,6459,19496,19505,
19499,19501,10564,19498,19500,19504,19502,5136,19503,19506,9785,11575,7187,
19507,11265,19509,19508,19512,11296,19511,4684,19510,19515,19514,19513,9233,
19516,19517,19518,6219,5636,19519,19520,19521,7720,19522,6924,19523,19524,
12544,12381,19525,17487,19526,8707,7690,9759,19527,10548,9011,6237,8712,4105,
10839,7734,5693,5440,10549,19528,19530,19529,4415,9557,19531,9814,9234,19532,
7217,19534,11041,19549,19536,19537,9000,8511,8278,9479,19535,5172,19544,19541,
19716,9480,8767,19538,9053,9266,19539,19543,7743,9798,9003,7969,19542,8461,
8451,19540,3848,11777,19545,8512,7188,7721,19547,19546,3918,19548,10254,19718,
9530,7754,8760,5463,19717,11286,4126,10550,4416,19712,19713,19714,19715,9498,
8706,3906,19719,19720,21250,8476,19721,4178,8235,5902,11321,19722,9227,8279,
6966,19723,19726,7236,19724,8202,8201,3907,11562,19728,10065,19730,19729,
19727,16963,4915,19533,19732,19731,19733,11287,9536,10765,19734,6968,19735,
19736,19737,9216,3913,6200,11801,19741,5651,19738,19739,10323,4659,11288,5406,
9267,19742,19743,19744,9217,19746,19745,9522,19747,7189,6975,9786,8784,6993,
7755,19748,19749,7740,19750,19751,19752,11342,7190,19754,19753,6201,6226,6687,
19757,7237,19756,19755,8520,5966,7970,9999,7192,19758,7486,19761,19759,19760,
19763,19762,7513,19764,19765,19766,10031,6450,6976,19767,19768,11523,7204,
11085,11563,19769,5441,19770,9218,19773,4695,7722,19771,19772,9023,10804,5467,
19775,19776,19774,19778,9534,4642,19782,19779,19781,19777,20014,19780,11594,
5945,19790,9235,19785,19788,19786,19791,19792,19784,19797,4179,19783,9996,
19787,7487,6202,10791,5443,7205,9499,8204,19795,19789,19794,11042,8983,19796,
19793,8203,19800,19799,19798,10766,7258,19801,10558,4147,10277,8785,5207,
19803,6204,6667,19802,7756,7757,19968,19970,7514,19969,19971,5426,10276,6977,
11778,19805,6487,11806,19973,19972,19974,19804,9544,9268,9014,19979,8738,
19975,19976,5644,19978,5903,19977,7488,4696,19983,6430,8280,9001,4634,19981,
19982,8994,19980,19984,19990,19993,19992,9228,19985,19986,19989,19991,5407,
19994,19988,19987,19998,19999,20000,19997,19996,7489,9481,19995,20004,20002,
20003,20001,8535,20005,20006,20008,4916,20007,11097,20019,20009,20012,20010,
20011,20013,20015,20016,20017,20020,20018,20021,20023,20022,8984,11078,20024,
8205,20025,10531,20026,4618,4123,4918,4917,20027,20028,20029,20030,20031,4919,
4660,6205,10005,20033,20032,20034,4155,20037,20036,20035,20038,20041,3878,
20039,20043,20042,20045,20044,20046,9485,20047,20048,20050,20049,10315,20051,
20052,6468,20053,20054,10792,8234,3843,8490,20055,10316,20058,20056,6206,
20057,5921,10532,20060,20224,20061,20225,4096,7735,7259,4920,20226,9797,20228,
4097,20227,8995,11564,9482,20059,11525,5904,11322,5464,11539,5639,8513,17920,
20229,4619,7758,4661,20231,20232,20230,5699,6460,7490,4098,11576,20234,19725,
20233,20237,20235,20236,20238,20239,11595,20240,20241,7976,10010,7772,4934,
11289,4428,7191,5946,20244,20243,6738,20245,20242,6663,20249,18700,12597,7766,
20247,11524,9552,4106,8002,6933,10518,4127,11596,11338,20250,9252,7002,20251,
20252,7723,20253,11597,20248,20255,20257,20256,20254,20258,20259,8281,4417,
20260,11031,20261,20262,11785,14864,20263,20264,20265,20269,20266,20267,20268,
20270,7971,11094,7972,20271,10066,20272,21042,11051,20273,20274,20275,4662,
20277,7736,20278,5635,20279,20283,20281,20282,4690,20280,20284,20285,3879,
20286,20287,7491,20288,5158,20291,20290,20289,19024,10555,20292,20293,20294,
20295,20296,20297,4921,20298,20299,9730,20301,4378,20304,20303,4099,5408,
10534,8985,6401,6207,7238,7739,20306,20305,11297,4935,10033,9531,7771,11565,
5690,20309,20308,10794,9483,4143,20310,20307,10288,11337,20311,20312,20314,
8521,4666,4667,20313,4936,5905,4937,9246,11583,5947,20315,20316,20317,20480,
20482,20481,10326,20483,20484,20485,20486,20488,20487,20489,10067,17707,7688,
5137,20490,
20491,12555,15386,10034,3930,3866,6739,10767,7517,20492,11070,20493,11323,
4129,6688,20494,4429,20495,20496,20498,20499,20501,20497,20500,4922,20502,
20503,20504,20505,20506,20508,20507,20510,20513,20509,20511,20512,20514,5409,
6994,20515,20516,6208,20517,4637,9774,20518,20519,8761,9546,20520,9820,8491,
4151,5453,5454,8786,20525,5455,4430,20524,20522,20523,20521,20535,20526,20527,
20528,20529,20531,20530,7224,20532,20534,5138,20533,8282,5906,20536,8492,
20537,9484,20538,20543,20541,20540,20542,20539,20545,20544,20547,5410,20546,
20548,20549,20551,20550,20552,20554,20553,6235,20555,20556,4635,20557,20558,
7760,20559,20560,20561,20562,6209,20563,20564,20565,20566,20567,10000,20569,
10245,20570,20568,20572,20571,20573,20736,20737,20738,20739,20740,20741,20742,
20743,20744,20745,20746,20747,20748,20749,15380,20750,17239,5139,4608,6417,
20752,20751,11012,20754,20755,20753,20756,10817,20757,5210,11780,20758,20760,
3869,20761,10506,20759,20762,20763,20764,20765,20766,10829,6668,6489,8206,
20767,20770,20768,20771,5968,20769,20772,20773,20774,20778,6665,8515,20779,
20776,20775,20777,5694,20783,20782,20781,3858,20793,20789,20790,20786,20792,
20788,4673,11819,20791,20787,20785,20784,20795,20798,20797,20796,10280,20794,
3922,20799,20801,4686,20780,4118,20803,20802,20800,8716,10831,11577,20804,
20805,20806,20807,20808,8986,20809,10006,20814,20810,20811,10768,11043,9519,
20815,20816,9501,20813,20812,4361,20824,20823,4180,20821,20820,20818,4698,
20817,6929,4360,6210,20827,20826,20825,
20822,20828,20829,20996,20995,20997,4108,20992,20993,6227,11032,20994,10769,
21002,20998,21003,21000,20999,5691,21004,21005,21006,21001,20819,21007,9024,
21011,21012,21010,21009,21015,21008,21013,21014,21017,21016,21019,21020,21021,
11816,21018,8522,6476,21022,21023,21024,21025,21026,5907,21027,21028,6926,
21029,21030,21031,21032,21035,21033,11803,21034,11598,21036,11578,21037,9821,
21038,21040,21041,21039,6220,11052,10818,13654,15423,10842,4362,21043,5167,
21044,21045,21046,6228,21047,16179,11066,8514,21048,21050,21049,21051,21052,
21053,21054,21055,21056,21057,21058,21059,21060,21061,21062,21063,9219,5948,
21065,8236,21066,21067,10240,21068,21069,16918,19257,20300,21070,21071,21073,
21074,21075,11599,21072,21076,21077,21079,21078,21081,21082,21080,11541,21083,
21084,16947,21085,9,83,79,82,84,41,42,85,59,3,4,30,527,528,529,530,531,532,
533,534,535,536,6,7,66,64,67,8,86,544,545,546,547,548,549,550,551,552,553,554,
555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,45,46,15,17,13,
576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,
595,596,597,598,599,600,601,47,34,48,16,78,

View file

@ -42,6 +42,7 @@ int feof(FILE *) paramsnonnull();
int getc(FILE *) paramsnonnull(); int getc(FILE *) paramsnonnull();
int putc(int, FILE *) paramsnonnull(); int putc(int, FILE *) paramsnonnull();
int fflush(FILE *); int fflush(FILE *);
int fpurge(FILE *);
int fgetc(FILE *) paramsnonnull(); int fgetc(FILE *) paramsnonnull();
char *fgetln(FILE *, size_t *) paramsnonnull((1)); char *fgetln(FILE *, size_t *) paramsnonnull((1));
int ungetc(int, FILE *) paramsnonnull(); int ungetc(int, FILE *) paramsnonnull();

View file

@ -4,14 +4,15 @@
#if !(__ASSEMBLER__ + __LINKER__ + 0) #if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_ COSMOPOLITAN_C_START_
dontdiscard FILE *tmpfile(void); FILE *tmpfile(void);
dontdiscard int mkstemp(char *); char *mkdtemp(char *);
dontdiscard int mkostemp(char *, unsigned); char *mktemp(char *);
dontdiscard int mkstemps(char *, int);
dontdiscard int mkostemps(char *, int, unsigned);
dontdiscard int mkostempsm(char *, int, unsigned, int);
compatfn char *mktemp(char *);
char *tmpnam(char *); char *tmpnam(char *);
int mkostemp(char *, unsigned);
int mkostemps(char *, int, unsigned);
int mkostempsm(char *, int, unsigned, int);
int mkstemp(char *);
int mkstemps(char *, int);
int mkostempsmi(char *, int, unsigned, uint64_t *, int, int mkostempsmi(char *, int, unsigned, uint64_t *, int,
int (*)(const char *, int, ...)) hidden dontdiscard; int (*)(const char *, int, ...)) hidden dontdiscard;

View file

@ -118,6 +118,7 @@ wchar_t *wcschr(const wchar_t *, wchar_t) strlenesque;
wchar_t *wmemchr(const wchar_t *, wchar_t, size_t) strlenesque; wchar_t *wmemchr(const wchar_t *, wchar_t, size_t) strlenesque;
wchar_t *wcschrnul(const wchar_t *, wchar_t) strlenesque returnsnonnull; wchar_t *wcschrnul(const wchar_t *, wchar_t) strlenesque returnsnonnull;
char *strstr(const char *, const char *) strlenesque; char *strstr(const char *, const char *) strlenesque;
char *strcasestr(const char *, const char *) strlenesque;
char16_t *strstr16(const char16_t *, const char16_t *) strlenesque; char16_t *strstr16(const char16_t *, const char16_t *) strlenesque;
wchar_t *wcsstr(const wchar_t *, const wchar_t *) strlenesque; wchar_t *wcsstr(const wchar_t *, const wchar_t *) strlenesque;
void *rawwmemchr(const void *, wchar_t) strlenesque returnsnonnull; void *rawwmemchr(const void *, wchar_t) strlenesque returnsnonnull;

70
libc/str/strcasestr.c Normal file
View file

@ -0,0 +1,70 @@
/*-*- 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/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/str/str.h"
typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
/**
* Searches for substring case-insensitively.
*
* @param haystack is the search area, as a NUL-terminated string
* @param needle is the desired substring, also NUL-terminated
* @return pointer to first substring within haystack, or NULL
* @note this implementation goes fast in practice but isn't hardened
* against pathological cases, and therefore shouldn't be used on
* untrustworthy data
* @asyncsignalsafe
* @see strstr()
*/
noasan char *strcasestr(const char *haystack, const char *needle) {
char c;
xmm_t *p;
size_t i;
unsigned k, m;
xmm_t v, n1, n2, z = {0};
if (IsAsan()) __asan_verify(needle, 1);
if (IsAsan()) __asan_verify(haystack, 1);
if (haystack == needle || !*needle) return haystack;
c = *needle;
n1 = (xmm_t){c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
c = kToLower[c & 255];
n2 = (xmm_t){c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c};
for (;;) {
k = (uintptr_t)haystack & 15;
p = (const xmm_t *)((uintptr_t)haystack & -16);
v = *p;
m = __builtin_ia32_pmovmskb128((v == z) | (v == n1) | (v == n2));
m >>= k;
m <<= k;
while (!m) {
v = *++p;
m = __builtin_ia32_pmovmskb128((v == z) | (v == n1) | (v == n2));
}
haystack = (const char *)p + __builtin_ctzl(m);
for (i = 0;; ++i) {
if (!needle[i]) return (/*unconst*/ char *)haystack;
if (!haystack[i]) break;
if (kToLower[needle[i] & 255] != kToLower[haystack[i] & 255]) break;
}
if (!*haystack++) break;
}
return 0;
}

View file

@ -32,6 +32,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
* against pathological cases, and therefore shouldn't be used on * against pathological cases, and therefore shouldn't be used on
* untrustworthy data * untrustworthy data
* @asyncsignalsafe * @asyncsignalsafe
* @see strcasestr()
* @see memmem() * @see memmem()
*/ */
noasan char *strstr(const char *haystack, const char *needle) { noasan char *strstr(const char *haystack, const char *needle) {

View file

@ -1,2 +0,0 @@
.include "o/libc/sysv/macros.internal.inc"
.scall pselect,0x1b406e20a218a10e,globl

View file

@ -0,0 +1,2 @@
.include "o/libc/sysv/macros.internal.inc"
.scall sys_pselect,0x1b406e20a218a10e,globl,hidden

View file

@ -414,7 +414,7 @@ syscon at AT_FDCWD -100 -2 -100 -100 -100 -100 # faked nt
syscon at AT_SYMLINK_NOFOLLOW 0x0100 0x20 0x0200 2 0x200 0x0100 # faked nt syscon at AT_SYMLINK_NOFOLLOW 0x0100 0x20 0x0200 2 0x200 0x0100 # faked nt
syscon at AT_SYMLINK_FOLLOW 0x0400 0x40 0x0400 4 0x400 0 # see linkat(2) syscon at AT_SYMLINK_FOLLOW 0x0400 0x40 0x0400 4 0x400 0 # see linkat(2)
syscon at AT_REMOVEDIR 0x0200 0x80 0x0800 8 0x800 0x0200 # faked nt syscon at AT_REMOVEDIR 0x0200 0x80 0x0800 8 0x800 0x0200 # faked nt
syscon at AT_EACCESS 0x0200 0x10 0x0100 1 0x100 0 syscon at AT_EACCESS 0x0200 0x10 0x0100 1 0x100 0 # performs check using effective uid/gid; unnecessary nt
syscon at AT_EMPTY_PATH 0x1000 0 0 0 0 0 # linux 2.6.39+; see unlink, O_TMPFILE, etc. syscon at AT_EMPTY_PATH 0x1000 0 0 0 0 0 # linux 2.6.39+; see unlink, O_TMPFILE, etc.
# memfd_create() flags # memfd_create() flags
@ -1531,7 +1531,6 @@ syscon termios VERIFY 47 0 0 0 0 0
syscon termios CIBAUD 0x100f0000 0 0 0 0 0 syscon termios CIBAUD 0x100f0000 0 0 0 0 0
syscon termios CMSPAR 0x40000000 0 0 0 0 0 syscon termios CMSPAR 0x40000000 0 0 0 0 0
syscon termios BUSY 4 0 0 0 0 0 syscon termios BUSY 4 0 0 0 0 0
syscon termios CANBSIZ 255 0 0 0 0 0
syscon termios CBAUD 0x100f 0 0 0 0 0 syscon termios CBAUD 0x100f 0 0 0 0 0
syscon termios CBAUDEX 0x1000 0 0 0 0 0 syscon termios CBAUDEX 0x1000 0 0 0 0 0
syscon termios EXTA 14 0x4b00 0x4b00 0x4b00 0x4b00 0 # bsd consensus syscon termios EXTA 14 0x4b00 0x4b00 0x4b00 0x4b00 0 # bsd consensus
@ -1743,8 +1742,6 @@ syscon misc EFD_CLOEXEC 0x080000 0 0 0 0 0
syscon misc EFD_NONBLOCK 0x0800 0 0 0 0 0 syscon misc EFD_NONBLOCK 0x0800 0 0 0 0 0
syscon misc EFD_SEMAPHORE 1 0 0 0 0 0 syscon misc EFD_SEMAPHORE 1 0 0 0 0 0
syscon misc IPPORT_RESERVED 0x0400 0x0400 0x0400 0x0400 0x0400 0x0400 # consensus
syscon misc SYNC_FILE_RANGE_WAIT_AFTER 4 0 0 0 0 0 syscon misc SYNC_FILE_RANGE_WAIT_AFTER 4 0 0 0 0 0
syscon misc SYNC_FILE_RANGE_WAIT_BEFORE 1 0 0 0 0 0 syscon misc SYNC_FILE_RANGE_WAIT_BEFORE 1 0 0 0 0 0
syscon misc SYNC_FILE_RANGE_WRITE 2 0 0 0 0 0 syscon misc SYNC_FILE_RANGE_WRITE 2 0 0 0 0 0

View file

@ -0,0 +1,9 @@
#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_ENDIAN_H_
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_ENDIAN_H_
#define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
#define __PDP_ENDIAN __ORDER_PDP_ENDIAN__
#define __BYTE_ORDER __BYTE_ORDER__
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_ENDIAN_H_ */

View file

@ -4,42 +4,50 @@
#define LOG_MASK(pri) (1 << (pri)) #define LOG_MASK(pri) (1 << (pri))
#define LOG_UPTO(pri) ((1 << ((pri) + 1)) - 1) #define LOG_UPTO(pri) ((1 << ((pri) + 1)) - 1)
#define LOG_EMERG 0 #define LOG_EMERG 0
#define LOG_KERN 0 #define LOG_ALERT 1
#define LOG_ALERT 1 #define LOG_CRIT 2
#define LOG_PID 1 #define LOG_ERR 3
#define LOG_CONS 2 #define LOG_WARNING 4
#define LOG_CRIT 2 #define LOG_NOTICE 5
#define LOG_ERR 3 #define LOG_INFO 6
#define LOG_ODELAY 4 #define LOG_DEBUG 7
#define LOG_WARNING 4
#define LOG_NOTICE 5 #define LOG_KERN 0000
#define LOG_INFO 6 #define LOG_USER 0010
#define LOG_DEBUG 7 #define LOG_MAIL 0020
#define LOG_PRIMASK 7 #define LOG_DAEMON 0030
#define LOG_NDELAY 8 #define LOG_AUTH 0040
#define LOG_USER 8 #define LOG_SYSLOG 0050
#define LOG_MAIL 16 #define LOG_LPR 0060
#define LOG_NOWAIT 16 #define LOG_NEWS 0070
#define LOG_DAEMON 24 #define LOG_UUCP 0100
#define LOG_CRON 0110
#define LOG_AUTHPRIV 0120
#define LOG_FTP 0130
#define LOG_PID 1
#define LOG_CONS 2
#define LOG_ODELAY 4
#define LOG_NDELAY 8
#define LOG_NOWAIT 16
#define LOG_PERROR 32
#define LOG_LOCAL0 128
#define LOG_LOCAL1 136
#define LOG_LOCAL2 144
#define LOG_LOCAL3 152
#define LOG_LOCAL4 160
#define LOG_LOCAL5 168
#define LOG_LOCAL6 176
#define LOG_LOCAL7 184
#define LOG_NFACILITIES 24 #define LOG_NFACILITIES 24
#define LOG_AUTH 32
#define LOG_PERROR 32
#define LOG_SYSLOG 40
#define LOG_LPR 48
#define LOG_NEWS 56
#define LOG_UUCP 64
#define LOG_CRON 72
#define LOG_SELECT 76
#define LOG_SENSE 77
#define LOG_LOCAL0 128
#define LOG_LOCAL1 136
#define LOG_LOCAL2 144
#define LOG_LOCAL3 152
#define LOG_LOCAL4 160
#define LOG_LOCAL5 168
#define LOG_LOCAL6 176
#define LOG_LOCAL7 184
#define LOG_FACMASK 0x03f8 #define LOG_FACMASK 0x03f8
#define LOG_FAC(p) ((LOG_FACMASK & (p)) >> 3)
#define LOG_PRIMASK 7
#define LOG_PRI(p) (LOG_PRIMASK & (p))
#define LOG_MAKEPRI(f, p) (((f) << 3) | (p))
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_LOG_H_ */ #endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_LOG_H_ */

View file

@ -10,7 +10,6 @@ extern const uint32_t BS1;
extern const uint32_t BS2; extern const uint32_t BS2;
extern const uint32_t BSDLY; extern const uint32_t BSDLY;
extern const long BUSY; extern const long BUSY;
extern const long CANBSIZ;
extern const uint32_t CBAUD; extern const uint32_t CBAUD;
extern const uint32_t CBAUDEX; extern const uint32_t CBAUDEX;
extern const uint32_t CIBAUD; extern const uint32_t CIBAUD;
@ -228,7 +227,6 @@ COSMOPOLITAN_C_END_
#define FF2 SYMBOLIC(FF2) #define FF2 SYMBOLIC(FF2)
#define BUSY SYMBOLIC(BUSY) #define BUSY SYMBOLIC(BUSY)
#define CANBSIZ SYMBOLIC(CANBSIZ)
#define CBAUD SYMBOLIC(CBAUD) #define CBAUD SYMBOLIC(CBAUD)
#define CBAUDEX SYMBOLIC(CBAUDEX) #define CBAUDEX SYMBOLIC(CBAUDEX)
#define CIBAUD SYMBOLIC(CIBAUD) #define CIBAUD SYMBOLIC(CIBAUD)

View file

@ -58,7 +58,7 @@ scall sys_writev 0x0790790792079014 globl hidden
scall sys_access 0x0210210212021015 globl hidden scall sys_access 0x0210210212021015 globl hidden
scall __sys_pipe 0x02a10721e202a016 globl hidden # NOTE: pipe2() on FreeBSD; XNU is pipe(void)→eax:edx scall __sys_pipe 0x02a10721e202a016 globl hidden # NOTE: pipe2() on FreeBSD; XNU is pipe(void)→eax:edx
scall sys_select 0x1a104705d205d017 globl hidden scall sys_select 0x1a104705d205d017 globl hidden
scall pselect 0x1b406e20a218a10e globl # pselect6() on gnu/systemd scall sys_pselect 0x1b406e20a218a10e globl hidden # pselect6() on gnu/systemd
scall sys_sched_yield 0x15e12a14bf25d018 globl hidden # select() on XNU (previously swtch() but removed in 12.4) scall sys_sched_yield 0x15e12a14bf25d018 globl hidden # select() on XNU (previously swtch() but removed in 12.4)
scall __sys_mremap 0x19bffffffffff019 globl hidden scall __sys_mremap 0x19bffffffffff019 globl hidden
scall sys_mincore 0x04e04e04e204e01b globl hidden scall sys_mincore 0x04e04e04e204e01b globl hidden

View file

@ -3,6 +3,7 @@
#include "libc/calls/struct/timespec.h" #include "libc/calls/struct/timespec.h"
#include "libc/intrin/pthread.h" #include "libc/intrin/pthread.h"
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
#include "libc/unicode/locale.h"
#define CTHREAD_CREATE_DETACHED 1 #define CTHREAD_CREATE_DETACHED 1
#define CTHREAD_CREATE_JOINABLE 0 #define CTHREAD_CREATE_JOINABLE 0
@ -28,7 +29,7 @@ struct cthread_descriptor_t {
struct cthread_descriptor_t *self; /* 0x00 */ struct cthread_descriptor_t *self; /* 0x00 */
struct FtraceTls ftrace; /* 0x08 */ struct FtraceTls ftrace; /* 0x08 */
void *garbages; /* 0x10 */ void *garbages; /* 0x10 */
int64_t __pad1; /* 0x20 */ locale_t locale; /* 0x20 */
int64_t __pad2; /* 0x28 */ int64_t __pad2; /* 0x28 */
struct cthread_descriptor_t *self2; /* 0x30 */ struct cthread_descriptor_t *self2; /* 0x30 */
int32_t tid; /* 0x38 */ int32_t tid; /* 0x38 */

View file

@ -97,6 +97,8 @@ int extract(const char *from, const char *to, int mode) {
TEST(unveil, api_differences) { TEST(unveil, api_differences) {
SPAWN(fork); SPAWN(fork);
ASSERT_SYS(0, 0, mkdir("foo", 0755));
ASSERT_SYS(0, 0, unveil("foo", "r"));
if (IsOpenbsd()) { if (IsOpenbsd()) {
// openbsd imposes restrictions immediately // openbsd imposes restrictions immediately
ASSERT_SYS(ENOENT, -1, open("/", O_RDONLY | O_DIRECTORY)); ASSERT_SYS(ENOENT, -1, open("/", O_RDONLY | O_DIRECTORY));

View file

@ -0,0 +1,37 @@
/*-*- 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 2022 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/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/stdio/iconv.h"
#include "libc/stdio/stdio.h"
#include "libc/testlib/testlib.h"
TEST(iconv, test) {
iconv_t cd;
char buf[32] = {0};
char *in = "\xB6\xE2ʸ\xC2\xCE";
size_t inb = strlen(in);
char *out = buf;
size_t outb = sizeof(buf);
ASSERT_NE((iconv_t)-1, (cd = iconv_open("UTF-8", "EUC-JP")));
EXPECT_EQ(0, iconv(cd, &in, &inb, &out, &outb));
EXPECT_STREQ("", in);
EXPECT_STREQ("金文体", buf);
ASSERT_EQ(0, iconv_close(cd));
}

View file

@ -0,0 +1,163 @@
/*-*- 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/alg/alg.h"
#include "libc/bits/bits.h"
#include "libc/dce.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/runtime/gc.internal.h"
#include "libc/str/internal.h"
#include "libc/testlib/ezbench.h"
#include "libc/testlib/hyperion.h"
#include "libc/testlib/testlib.h"
#define MAKESTRING(NAME, VALUE) \
char *NAME = strcpy(malloc(sizeof(VALUE) + 16), VALUE)
char *strcasestr_naive(const char *haystack, const char *needle) {
size_t i;
unsigned k, m;
if (haystack == needle || !*needle) return haystack;
for (;;) {
for (i = 0;; ++i) {
if (!needle[i]) return (/*unconst*/ char *)haystack;
if (!haystack[i]) break;
if (kToLower[needle[i] & 255] != kToLower[haystack[i] & 255]) break;
}
if (!*haystack++) break;
}
return 0;
}
TEST(strcasestr, test_emptyString_isFoundAtBeginning) {
MAKESTRING(haystack, "abc123def");
ASSERT_STREQ(&haystack[0], strcasestr(haystack, gc(strdup(""))));
free(haystack);
}
TEST(strcasestr, test_notFound) {
MAKESTRING(haystack, "abc123def");
ASSERT_EQ(NULL, strcasestr(haystack, gc(strdup("xyz"))));
ASSERT_EQ(NULL, strcasestr(haystack, gc(strdup("XYZ"))));
free(haystack);
}
TEST(strcasestr, test_notFound1) {
MAKESTRING(haystack, "abc123def");
ASSERT_EQ(NULL, strcasestr(haystack, gc(strdup("x"))));
ASSERT_EQ(NULL, strcasestr(haystack, gc(strdup("X"))));
free(haystack);
}
TEST(strcasestr, test_middleOfString) {
MAKESTRING(haystack, "abc123def");
ASSERT_STREQ(&haystack[3], strcasestr(haystack, gc(strdup("123"))));
free(haystack);
}
TEST(strcasestr, test_endOfString) {
MAKESTRING(haystack, "abc123def");
ASSERT_STREQ(&haystack[8], strcasestr(haystack, gc(strdup("f"))));
ASSERT_STREQ(&haystack[8], strcasestr(haystack, gc(strdup("F"))));
free(haystack);
}
TEST(strcasestr, test_secondXmmWord) {
MAKESTRING(haystack, "eeeeeeeeeeeeeeeebbbbbbbbbbb123");
ASSERT_STREQ(&haystack[27], strcasestr(haystack, gc(strdup("123"))));
free(haystack);
}
TEST(strcasestr, test_overlapsXmmWords) {
MAKESTRING(haystack, "eeeeeeeeeeeeeeeebbbbbbbbbbbbbbb");
ASSERT_STREQ(&haystack[15], strcasestr(haystack, gc(strdup("eb"))));
ASSERT_STREQ(&haystack[15], strcasestr(haystack, gc(strdup("Eb"))));
ASSERT_STREQ(&haystack[15], strcasestr(haystack, gc(strdup("eB"))));
free(haystack);
}
TEST(strcasestr, test) {
ASSERT_EQ(NULL, strcasestr("x86_64-linux-musl-gcc", "clang"));
ASSERT_STREQ("gcc", strcasestr("x86_64-linux-musl-gcc", "gcc"));
ASSERT_EQ(NULL, strcasestr("-Wl,--gc-sections", "stack-protector"));
ASSERT_EQ(NULL, strcasestr("-Wl,--gc-sections", "sanitize"));
ASSERT_STREQ("x", strcasestr("x", "x"));
}
/*
* strstr naive l: 103,057c 33,287ns m: 47,035c 15,192ns
* strstr l: 3,186c 1,029ns m: 3,218c 1,039ns
* strstr torture 1 l: 27c 9ns m: 61c 20ns
* strstr torture 2 l: 2,322c 750ns m: 2,362c 763ns
* strstr torture 4 l: 2,407c 777ns m: 2,448c 791ns
* strstr torture 8 l: 2,803c 905ns m: 2,862c 924ns
* strstr torture 16 l: 4,559c 1,473ns m: 3,614c 1,167ns
* strstr torture 32 l: 5,324c 1,720ns m: 5,577c 1,801ns
*
* strcasestr naive l: 129,908c 41,959ns m: 155,420c 50,200ns
* strcasestr l: 33,464c 10,809ns m: 31,636c 10,218ns
* strcasestr tort 1 l: 38c 12ns m: 69c 22ns
* strcasestr tort 2 l: 2,544c 822ns m: 2,580c 833ns
* strcasestr tort 4 l: 2,745c 887ns m: 2,767c 894ns
* strcasestr tort 8 l: 4,198c 1,356ns m: 4,216c 1,362ns
* strcasestr tort 16 l: 7,402c 2,391ns m: 7,487c 2,418ns
* strcasestr tort 32 l: 13,772c 4,448ns m: 12,945c 4,181ns
*/
BENCH(strcasestr, bench) {
EZBENCH2("strcasestr naive", donothing,
EXPROPRIATE(strcasestr_naive(kHyperion, "THE END")));
EZBENCH2("strcasestr", donothing,
EXPROPRIATE(strcasestr(kHyperion, "THE END")));
EZBENCH2("strcasestr tort 1", donothing,
EXPROPRIATE(strcasestr(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
"B")));
EZBENCH2("strcasestr tort 2", donothing,
EXPROPRIATE(strcasestr(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
"ab")));
EZBENCH2("strcasestr tort 4", donothing,
EXPROPRIATE(strcasestr(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
"aaab")));
EZBENCH2("strcasestr tort 8", donothing,
EXPROPRIATE(strcasestr(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
"aaaaaaab")));
EZBENCH2("strcasestr tort 16", donothing,
EXPROPRIATE(strcasestr(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
"aaaaaaaaaaaaaaab")));
EZBENCH2("strcasestr tort 32", donothing,
EXPROPRIATE(strcasestr(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab")));
}

View file

@ -30,8 +30,19 @@
#define MAKESTRING(NAME, VALUE) \ #define MAKESTRING(NAME, VALUE) \
char *NAME = strcpy(malloc(sizeof(VALUE) + 16), VALUE) char *NAME = strcpy(malloc(sizeof(VALUE) + 16), VALUE)
char *strstr_kmp(const char *haystak, const char *needle) { char *strstr_naive(const char *haystack, const char *needle) {
return memmem(haystak, strlen(haystak), needle, strlen(needle)); size_t i;
unsigned k, m;
if (haystack == needle || !*needle) return haystack;
for (;;) {
for (i = 0;; ++i) {
if (!needle[i]) return (/*unconst*/ char *)haystack;
if (!haystack[i]) break;
if (needle[i] != haystack[i]) break;
}
if (!*haystack++) break;
}
return 0;
} }
TEST(strstr, test_emptyString_isFoundAtBeginning) { TEST(strstr, test_emptyString_isFoundAtBeginning) {
@ -84,7 +95,28 @@ TEST(strstr, test) {
ASSERT_STREQ("x", strstr("x", "x")); ASSERT_STREQ("x", strstr("x", "x"));
} }
/*
* strstr naive l: 103,057c 33,287ns m: 47,035c 15,192ns
* strstr l: 3,186c 1,029ns m: 3,218c 1,039ns
* strstr torture 1 l: 27c 9ns m: 61c 20ns
* strstr torture 2 l: 2,322c 750ns m: 2,362c 763ns
* strstr torture 4 l: 2,407c 777ns m: 2,448c 791ns
* strstr torture 8 l: 2,803c 905ns m: 2,862c 924ns
* strstr torture 16 l: 4,559c 1,473ns m: 3,614c 1,167ns
* strstr torture 32 l: 5,324c 1,720ns m: 5,577c 1,801ns
*
* strcasestr naive l: 129,908c 41,959ns m: 155,420c 50,200ns
* strcasestr l: 33,464c 10,809ns m: 31,636c 10,218ns
* strcasestr tort 1 l: 38c 12ns m: 69c 22ns
* strcasestr tort 2 l: 2,544c 822ns m: 2,580c 833ns
* strcasestr tort 4 l: 2,745c 887ns m: 2,767c 894ns
* strcasestr tort 8 l: 4,198c 1,356ns m: 4,216c 1,362ns
* strcasestr tort 16 l: 7,402c 2,391ns m: 7,487c 2,418ns
* strcasestr tort 32 l: 13,772c 4,448ns m: 12,945c 4,181ns
*/
BENCH(strstr, bench) { BENCH(strstr, bench) {
EZBENCH2("strstr naive", donothing,
EXPROPRIATE(strstr_naive(kHyperion, "THE END")));
EZBENCH2("strstr", donothing, EXPROPRIATE(strstr(kHyperion, "THE END"))); EZBENCH2("strstr", donothing, EXPROPRIATE(strstr(kHyperion, "THE END")));
EZBENCH2("strstr torture 1", donothing, EZBENCH2("strstr torture 1", donothing,
EXPROPRIATE(strstr( EXPROPRIATE(strstr(

View file

@ -36,6 +36,8 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#include "libc/bits/bits.h" #include "libc/bits/bits.h"
#include "libc/intrin/kprintf.h" #include "libc/intrin/kprintf.h"
#include "libc/intrin/kprintf.h" #include "libc/intrin/kprintf.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/runtime/runtime.h"
#include "third_party/make/dep.h" #include "third_party/make/dep.h"
#define GOTO_SLOW \ #define GOTO_SLOW \
@ -1748,13 +1750,20 @@ child_execute_job (struct childbase *child, int good_stdin, char **argv)
Unveil ("/dev/stdout", "rw"); Unveil ("/dev/stdout", "rw");
Unveil ("/dev/stderr", "rw"); Unveil ("/dev/stderr", "rw");
/* unveil cosmopolitan specific */ /* unveil cosmopolitan build specific */
Unveil ("o/tmp", "rwcx"); Unveil ("o/tmp", "rwcx");
Unveil ("libc/integral", "r"); Unveil ("libc/integral", "r");
Unveil ("libc/disclaimer.inc", "r"); Unveil ("libc/disclaimer.inc", "r");
Unveil ("build/bootstrap", "rx"); Unveil ("build/bootstrap", "rx");
Unveil ("o/third_party/gcc", "rx"); Unveil ("o/third_party/gcc", "rx");
/* unveil cosmopolitan test specific */
Unveil ("/etc/hosts", "r");
Unveil (xjoinpaths (firstnonnull (getenv ("HOME"),
"."),
".runit.psk"),
"r");
/* unveil target output directory */ /* unveil target output directory */
if (strlen(c->file->name) < PATH_MAX) if (strlen(c->file->name) < PATH_MAX)
{ {
@ -1767,7 +1776,11 @@ child_execute_job (struct childbase *child, int good_stdin, char **argv)
/* unveil target prerequisites */ /* unveil target prerequisites */
for (d = c->file->deps; d; d = d->next) for (d = c->file->deps; d; d = d->next)
Unveil (d->file->name, "rx"); {
Unveil (d->file->name, "rx");
if (endswith (d->file->name, ".com"))
Unveil (xstrcat (d->file->name, ".dbg"), "rx");
}
/* unveil explicit .UNVEIL entries */ /* unveil explicit .UNVEIL entries */
if ((var = lookup_variable_in_set (STRING_SIZE_TUPLE(".UNVEIL"), if ((var = lookup_variable_in_set (STRING_SIZE_TUPLE(".UNVEIL"),

View file

@ -18,7 +18,6 @@
#include "libc/assert.h" #include "libc/assert.h"
#include "libc/bits/bits.h" #include "libc/bits/bits.h"
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/calls/struct/sockaddr6.h"
#include "libc/calls/struct/stat.h" #include "libc/calls/struct/stat.h"
#include "libc/calls/weirdtypes.h" #include "libc/calls/weirdtypes.h"
#include "libc/errno.h" #include "libc/errno.h"
@ -27,6 +26,7 @@
#include "libc/inttypes.h" #include "libc/inttypes.h"
#include "libc/limits.h" #include "libc/limits.h"
#include "libc/mem/mem.h" #include "libc/mem/mem.h"
#include "libc/sock/struct/sockaddr6.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
#include "libc/sysv/consts/af.h" #include "libc/sysv/consts/af.h"
#include "libc/sysv/consts/map.h" #include "libc/sysv/consts/map.h"

View file

@ -17,10 +17,10 @@
*/ */
#include "libc/calls/calls.h" #include "libc/calls/calls.h"
#include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/sockaddr6.h"
#include "libc/dns/dns.h" #include "libc/dns/dns.h"
#include "libc/errno.h" #include "libc/errno.h"
#include "libc/sock/select.h" #include "libc/sock/select.h"
#include "libc/sock/struct/sockaddr6.h"
#include "libc/sysv/consts/af.h" #include "libc/sysv/consts/af.h"
#include "libc/sysv/consts/f.h" #include "libc/sysv/consts/f.h"
#include "libc/sysv/consts/ipproto.h" #include "libc/sysv/consts/ipproto.h"

89
tool/scripts/fix-third-party.py Executable file
View file

@ -0,0 +1,89 @@
#!/usr/bin/env python.com
#
# fix-third-party.py
# normalizes third party codebases to cosmopolitan style
#
# this script does the bulk of the work when it comes to fixing things
# like #include lines so they follow the local convention. this script
# won't get you all the way, but it'll get you pretty far w/ vendoring
#
# for example:
#
# cd bash-5.1.16
# mkdir ~/cosmo/third_party/bash
# cp -R *.c *.h builtins lib COPYING include/* ~/cosmo/third_party/bash
# cd ~/cosmo
# tool/scripts/fix-third-party.py third_party/bash
#
import os
import re
import sys
LIBC_ISYSTEM = 'libc/isystem/'
EXTENSIONS = ('.c', '.cc', '.cpp', '.h', '.hh', '.hpp', '.inc', 'h.in')
isystem = {}
for dirpath, dirs, files in os.walk(LIBC_ISYSTEM):
for filepath in files:
path = os.path.join(dirpath, filepath)
with open(path) as f:
code = f.read()
name = path[len(LIBC_ISYSTEM):]
deps = re.findall(r'[.#]include "([^"]+)"', code)
isystem[name] = '\n'.join('#include "%s"' % (d) for d in deps)
def FixQuotedPath(path, incl):
p2 = os.path.join(os.path.dirname(path), incl)
if os.path.exists(incl) or not os.path.exists(p2):
return incl
else:
return os.path.normpath(p2)
def FixThirdParty(path):
if not path.endswith(EXTENSIONS):
return
print(path)
with open(path) as f:
code = f.read()
start = 0
res = []
if not code.startswith('// clang-format off\n'):
res.append('// clang-format off\n')
for m in re.finditer(r'# *include *"([^"]+)"', code):
end, newstart = m.span()
res.append(code[start:end])
res.append('#include "%s"' % (FixQuotedPath(path, m.group(1))))
start = newstart
res.append(code[start:])
code = ''.join(res)
res = []
start = 0
for m in re.finditer(r'# *include *<([^>]+)>', code):
end, newstart = m.span()
res.append(code[start:end])
inc = m.group(1)
if inc in isystem:
res.append(isystem[inc])
else:
res.append('/* MISSING #include <%s> */' % (m.group(1)))
start = newstart
res.append(code[start:])
code = ''.join(res)
# print(code)
with open(path, 'wb') as f:
f.write(code.encode('utf-8'))
sys.argv = ['', 'third_party/bash']
for arg in sys.argv[1:]:
if os.path.isdir(arg):
for dirpath, dirs, files in os.walk(arg):
for filepath in files:
FixThirdParty(os.path.join(dirpath, filepath))
else:
FixThirdParty(arg)