path
stringlengths 14
112
| content
stringlengths 0
6.32M
| size
int64 0
6.32M
| max_lines
int64 1
100k
| repo_name
stringclasses 2
values | autogenerated
bool 1
class |
---|---|---|---|---|---|
cosmopolitan/libc/stdio/funlockfile.c | /*-*- 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/thread/thread.h"
/**
* Releases lock on stdio object.
*/
void(funlockfile)(FILE *f) {
pthread_mutex_unlock((pthread_mutex_t *)f->lock);
}
| 2,062 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getentropy.c | /*-*- 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/calls/blockcancel.internal.h"
#include "libc/calls/blocksigs.internal.h"
#include "libc/calls/syscall_support-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/stdio/rand.h"
#include "libc/sysv/errfuns.h"
int sys_getentropy(void *, size_t) asm("sys_getrandom");
/**
* Returns random seeding bytes, the XNU/OpenBSD way.
*
* @return 0 on success, or -1 w/ errno
* @raise EFAULT if the `n` bytes at `p` aren't valid memory
* @raise EIO is returned if more than 256 bytes are requested
* @see getrandom()
*/
int getentropy(void *p, size_t n) {
int rc;
if (n > 256) {
rc = eio();
} else if ((!p && n) || (IsAsan() && !__asan_is_valid(p, n))) {
rc = efault();
} else if (IsXnu() || IsOpenbsd()) {
if (sys_getentropy(p, n)) notpossible;
rc = 0;
} else {
BLOCK_SIGNALS;
BLOCK_CANCELLATIONS;
if (__getrandom(p, n, 0) != n) notpossible;
ALLOW_CANCELLATIONS;
ALLOW_SIGNALS;
rc = 0;
}
STRACE("getentropy(%p, %'zu) â %'ld% m", p, n, rc);
return rc;
}
| 2,940 | 58 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/flbf.c | /*-*- 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 2021 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/stdio/stdio_ext.h"
/**
* Returns nonzero if stream is line buffered.
*/
int __flbf(FILE *f) {
return f->bufmode == _IOLBF;
}
| 2,011 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgetln.c | /*-*- 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 2021 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Retrieves line from stream, e.g.
*
* char *line;
* while ((line = _chomp(fgetln(stdin, 0)))) {
* printf("%s\n", line);
* }
*
* The returned memory is owned by the stream. It'll be reused when
* fgetln() is called again. It's free()'d upon fclose() / fflush()
*
* @param stream specifies non-null open input stream
* @param len optionally receives byte length of line
* @return nul-terminated line string, including the `\n` character
* unless a line happened before EOF without `\n`, otherwise it
* returns `NULL` and feof() and ferror() can examine the state
* @see getdelim()
*/
char *fgetln(FILE *stream, size_t *len) {
char *res;
ssize_t rc;
size_t n = 0;
flockfile(stream);
if ((rc = getdelim_unlocked(&stream->getln, &n, '\n', stream)) > 0) {
if (len) *len = rc;
res = stream->getln;
} else {
res = 0;
}
funlockfile(stream);
return res;
}
| 2,829 | 54 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/freestrlist.c | /*-*- 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/stdio/append.h"
#include "libc/stdio/strlist.internal.h"
void FreeStrList(struct StrList *sl) {
int i;
for (i = 0; i < sl->i; ++i) {
free(sl->p[i]);
}
free(sl->p);
sl->p = 0;
sl->i = 0;
sl->n = 0;
}
| 2,095 | 33 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ferror_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/errno.h"
#include "libc/stdio/stdio.h"
/**
* Returns nonzero if stream is in error state.
*
* @param f is file stream pointer
* @return non-zero w/ errno only if `f` is in error state
* @note EOF doesn't count
* @see ferror(), feof()
*/
errno_t ferror_unlocked(FILE *f) {
return f->state > 0 ? (errno = f->state) : 0;
}
| 2,181 | 33 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/__fseterr.c | /*-*- 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/errno.h"
#include "libc/stdio/stdio_ext.h"
void __fseterr(FILE *f) {
f->state |= EIO;
}
| 1,942 | 25 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/codepages.inc | // 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"
| 16,634 | 323 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/vigna.c | /*-*- 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 2021 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/stdio/rand.h"
static uint64_t g_vigna;
/**
* Returns deterministic pseudorandom data, e.g.
*
* uint64_t x = vigna();
*
* You can generate different types of numbers as follows:
*
* int64_t x = vigna() >> 1; // make positive signed integer
* double x = _real1(vigna()); // make float on [0,1]-interval
*
* You can seed this random number generator using:
*
* svigna(rdseed());
*
* You may use the reentrant version of this function:
*
* static uint64_t s = 0;
* uint64_t x = svigna_r(&s);
*
* If you want to fill a buffer with data then rngset() implements
* vigna's algorithm to do that extremely well:
*
* char buf[4096];
* rngset(buf, sizeof(buf), vigna, 0);
*
* If you want a fast pseudorandom number generator that seeds itself
* automatically on startup and fork(), then consider _rand64. If you
* want true random data then consider rdseed, rdrand, and getrandom.
*
* @return 64 bits of pseudorandom data
* @note this function is not intended for cryptography
* @note this function passes bigcrush and practrand
* @note this function takes at minimum 4 cycles
*/
uint64_t vigna(void) {
return vigna_r(&g_vigna);
}
/**
* Returns pseudorandom data.
* @see vigna() for easy api
*/
uint64_t vigna_r(uint64_t state[hasatleast 1]) {
uint64_t z = (state[0] += 0x9e3779b97f4a7c15);
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
return z ^ (z >> 31);
}
/**
* Seeds vigna() pseudorandom number generator.
* @see vigna(), vigna_r()
*/
void svigna(uint64_t seed) {
g_vigna = seed;
}
| 3,457 | 79 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/appends.c | /*-*- 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 2021 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/stdio/append.h"
#include "libc/str/str.h"
/**
* Appends string to buffer, e.g.
*
* char *b = 0;
* appends(&b, "hello");
* free(b);
*
* The resulting buffer is guaranteed to be NUL-terminated, i.e.
* `!b[appendz(b).i]` will be the case.
*
* @return bytes appended (always `strlen(s)`) or -1 if `ENOMEM`
* @see appendz(b).i to get buffer length
* @note 2x faster than appendf()
*/
ssize_t appends(char **b, const char *s) {
return appendd(b, s, strlen(s));
}
| 2,336 | 39 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fopenflags.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/calls/calls.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/o.h"
/**
* Turns stdio flags description string into bitmask.
*/
int fopenflags(const char *mode) {
unsigned omode, flags;
omode = flags = 0;
do {
if (*mode == 'r') {
omode = O_RDONLY;
} else if (*mode == 'w') {
omode = O_WRONLY;
flags |= O_CREAT | O_TRUNC;
} else if (*mode == 'a') {
omode = O_WRONLY;
flags |= O_CREAT | O_APPEND;
} else if (*mode == '+') {
omode = O_RDWR;
} else if (*mode == 'x') {
flags |= O_EXCL;
} else if (*mode == 'e') {
flags |= O_CLOEXEC;
}
} while (*mode++);
return omode | flags;
}
| 2,523 | 48 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fsetpos.c | /*-*- 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/calls/calls.h"
#include "libc/stdio/stdio.h"
int fsetpos(FILE *stream, const fpos_t *pos) {
return fseek(stream, *pos, SEEK_SET);
}
| 1,986 | 25 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/vfprintf_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/calls/calls.h"
#include "libc/fmt/fmt.h"
#include "libc/limits.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/errfuns.h"
struct state {
FILE *f;
int n;
};
static int vfprintfputchar(const char *s, struct state *t, size_t n) {
int rc;
if (n) {
if (n == 1 && *s != '\n' && t->f->beg < t->f->size &&
t->f->bufmode != _IONBF) {
t->f->buf[t->f->beg++] = *s;
t->n += n;
rc = 0;
} else if (!fwrite_unlocked(s, 1, n, t->f)) {
rc = -1;
} else {
t->n += n;
rc = 0;
}
} else {
rc = 0;
}
return rc;
}
/**
* Formats and writes text to stream.
* @see printf() for further documentation
*/
int(vfprintf_unlocked)(FILE *f, const char *fmt, va_list va) {
int rc;
struct state st[1] = {{f, 0}};
if ((rc = __fmt(vfprintfputchar, st, fmt, va)) != -1) {
rc = st->n;
}
return rc;
}
| 2,715 | 62 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fileno.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/errfuns.h"
/**
* Returns file descriptor associated with stream.
*
* @param f is file stream object pointer
* @return fd on success or -1 w/ errno;
* @threadsafe
*/
int fileno(FILE *f) {
int rc;
flockfile(f);
rc = fileno_unlocked(f);
funlockfile(f);
return rc;
}
| 2,204 | 37 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ctermid.c | /*-*- 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/nt/pedef.internal.h"
#include "libc/runtime/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
/**
* Generates path of controlling terminal.
*
* This function always returns /dev/tty since that's supported by all
* supported platforms, and polyfilled on Windows.
*
* @param s may optionally specify an outut buffer L_ctermid in size
* @return pointer to `s` (or image memory if `s` was null) which
* contains path of controlling terminal, or empty string if
* if this program is a win32 app running in gui mode
*/
char *ctermid(char *s) {
const char *tty;
if ((char)(intptr_t)v_ntsubsystem == kNtImageSubsystemWindowsGui) {
tty = "";
} else {
tty = "/dev/tty";
}
if (s) {
return strcpy(s, tty);
} else {
return tty;
}
}
| 2,637 | 48 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/iconv.c | /*-*- 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/stdio/iconv.h"
#include "libc/errno.h"
#include "libc/mem/mem.h"
#include "libc/str/locale.h"
#include "libc/str/str.h"
#include "libc/thread/tls.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 = (locale_t *)&__get_tls()->tib_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;
}
| 17,891 | 726 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getdelim.c | /*-*- 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Reads string from stream, e.g.
*
* char *line = NULL;
* size_t linesize = 0;
* while (getdelim(&line, &linesize, '\n', stdin) > 0) {
* _chomp(line);
* printf("%s\n", line);
* }
* free(line);
*
* @param s is the caller's buffer (in/out) which is extended or
* allocated automatically, also NUL-terminated is guaranteed
* @param n is the capacity of s (in/out)
* @param delim is the stop char (and NUL is implicitly too)
* @return number of bytes read >0, including delim, excluding NUL,
* or -1 w/ errno on EOF or error; see ferror() and feof()
* @note this function will ignore EINTR if it occurs mid-line
* @raises EBADF if stream isn't open for reading
* @see fgetln(), getline(), _chomp(), gettok_r()
*/
ssize_t getdelim(char **s, size_t *n, int delim, FILE *f) {
ssize_t rc;
flockfile(f);
rc = getdelim_unlocked(s, n, delim, f);
funlockfile(f);
return rc;
}
| 2,843 | 50 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fflush.c | /*-*- 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Blocks until data from stream buffer is written out.
*
* @param f is the stream handle, or 0 for all streams
* @return is 0 on success or -1 on error
* @threadsafe
*/
int fflush(FILE *f) {
int rc;
if (f) flockfile(f);
rc = fflush_unlocked(f);
if (f) funlockfile(f);
return rc;
}
| 2,206 | 36 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fpending.c | /*-*- 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 2021 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/stdio/stdio_ext.h"
/**
* Returns number of pending output bytes.
*/
size_t __fpending(FILE *f) {
return f->end - f->beg;
}
| 1,979 | 27 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/stdbuf.c | /*-*- 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/stdio/internal.h"
char g_stdoutbuf[BUFSIZ] _Hide;
char g_stderrbuf[BUFSIZ] _Hide;
| 1,934 | 23 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/system.c | /*-*- 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/calls/blockcancel.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/rusage.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/weaken.h"
#include "libc/log/log.h"
#include "libc/paths.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/ok.h"
#include "libc/sysv/consts/sig.h"
#include "libc/thread/thread.h"
/**
* Launches program with system command interpreter.
*
* This embeds the Cosmopolitan Command Interpreter which provides
* Bourne-like syntax on all platforms including Windows.
*
* @param cmdline is a unix shell script
* @return -1 if child process couldn't be created, otherwise a wait
* status that can be accessed using macros like WEXITSTATUS(s),
* WIFSIGNALED(s), WTERMSIG(s), etc.
* @threadsafe
*/
int system(const char *cmdline) {
int pid, wstatus;
sigset_t chldmask, savemask;
struct sigaction ignore, saveint, savequit;
if (!cmdline) return 1;
BLOCK_CANCELLATIONS;
ignore.sa_flags = 0;
ignore.sa_handler = SIG_IGN;
sigemptyset(&ignore.sa_mask);
sigaction(SIGINT, &ignore, &saveint);
sigaction(SIGQUIT, &ignore, &savequit);
sigemptyset(&chldmask);
sigaddset(&chldmask, SIGCHLD);
sigprocmask(SIG_BLOCK, &chldmask, &savemask);
if (!(pid = fork())) {
sigaction(SIGINT, &saveint, 0);
sigaction(SIGQUIT, &savequit, 0);
sigprocmask(SIG_SETMASK, &savemask, 0);
_Exit(_cocmd(3, (char *[]){"system", "-c", cmdline, 0}, environ));
} else if (pid != -1) {
while (wait4(pid, &wstatus, 0, 0) == -1) {
if (errno != EINTR) {
wstatus = -1;
break;
}
}
} else {
wstatus = -1;
}
sigaction(SIGINT, &saveint, 0);
sigaction(SIGQUIT, &savequit, 0);
sigprocmask(SIG_SETMASK, &savemask, 0);
ALLOW_CANCELLATIONS;
return wstatus;
}
| 3,714 | 81 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fbufsize.c | /*-*- 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 2021 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/assert.h"
#include "libc/stdio/stdio_ext.h"
/**
* Returns capacity of stdio stream buffer.
*/
size_t __fbufsize(FILE *f) {
return f->size;
}
| 1,997 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgetc_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/stdio.h"
/**
* Reads byte from stream.
*
* @param f is file object stream pointer
* @return byte in range 0..255, or -1 w/ errno
* @see fgetc()
*/
int fgetc_unlocked(FILE *f) {
unsigned char b[1];
if (f->beg < f->end) {
return f->buf[f->beg++] & 0xff;
} else {
if (!fread_unlocked(b, 1, 1, f)) return -1;
return b[0];
}
}
| 2,206 | 37 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/gcvt.c | /*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-â
âvi: set et ft=c ts=8 tw=8 fenc=utf-8 :viâ
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¡
â $OpenBSD: ecvt.c,v 1.11 2019/01/25 00:19:25 millert Exp $ â
â â
â Copyright (c) 2002, 2006, 2010 Todd C. Miller <[email protected]> â
â â
â Permission to use, copy, modify, and 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. â
â â
â Sponsored in part by the Defense Advanced Research Projects â
â Agency (DARPA) and Air Force Research Laboratory, Air Force â
â Materiel Command, USAF, under agreement number F39502-99-1-0512. â
â SUCH DAMAGE. â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ*/
#include "libc/fmt/fmt.h"
#include "libc/mem/mem.h"
#include "libc/str/str.h"
#include "libc/str/unicode.h"
#include "third_party/gdtoa/gdtoa.h"
asm(".ident\t\"\\n\\n\
OpenBSD ecvt/gcvt (MIT)\\n\
Copyright (c) 2002, 2006, 2010 Todd C. Miller <[email protected]>\"");
asm(".include \"libc/disclaimer.inc\"");
// clang-format off
#define DEFPREC 6
char *
gcvt(double value, int ndigit, char *buf)
{
char *digits, *dst, *src;
int i, decpt, sign;
struct lconv *lconv;
lconv = localeconv();
if (ndigit <= 0) {
/* Match printf(3) behavior. */
ndigit = ndigit ? DEFPREC : 1;
}
digits = dtoa(value, 2, ndigit, &decpt, &sign, NULL);
if (digits == NULL)
return (NULL);
if (decpt == 9999) {
/*
* Infinity or NaN, convert to inf or nan with sign.
* We can't infer buffer size based on ndigit.
* We have to assume it is at least 5 chars.
*/
snprintf(buf, 5, "%s%s", sign ? "-" : "",
*digits == 'I' ? "inf" : "nan");
freedtoa(digits);
return (buf);
}
dst = buf;
if (sign)
*dst++ = '-';
/* Match printf(3) behavior for exponential vs. regular fomatting. */
if (decpt <= -4 || decpt > ndigit) {
/* exponential format (e.g. 1.2345e+13) */
if (--decpt < 0) {
sign = 1;
decpt = -decpt;
} else
sign = 0;
src = digits;
*dst++ = *src++;
if (*src != '\0') {
*dst++ = *lconv->decimal_point;
do {
*dst++ = *src++;
} while (*src != '\0');
}
*dst++ = 'e';
if (sign)
*dst++ = '-';
else
*dst++ = '+';
if (decpt < 10) {
*dst++ = '0';
*dst++ = '0' + decpt;
*dst = '\0';
} else {
/* XXX - optimize */
for (sign = decpt, i = 0; (sign /= 10) != 0; i++)
continue;
dst[i + 1] = '\0';
while (decpt != 0) {
dst[i--] = '0' + decpt % 10;
decpt /= 10;
}
}
} else {
/* standard format */
for (i = 0, src = digits; i < decpt; i++) {
if (*src != '\0')
*dst++ = *src++;
else
*dst++ = '0';
}
if (*src != '\0') {
if (src == digits)
*dst++ = '0'; /* zero before decimal point */
*dst++ = *lconv->decimal_point;
while (decpt < 0) {
*dst++ = '0';
decpt++;
}
for (i = decpt; digits[i] != '\0'; i++) {
*dst++ = digits[i];
}
}
*dst = '\0';
}
freedtoa(digits);
return (buf);
}
| 4,580 | 131 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/mkstemp.c | /*-*- 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/stdio/temp.h"
int mkstemp(char *template) {
return mkostempsm(template, 0, 0, 0600);
}
| 1,941 | 24 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/freopen.c | /*-*- 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/calls/calls.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/f.h"
#include "libc/sysv/consts/fd.h"
#include "libc/sysv/consts/o.h"
/**
* Overwrites existing stream.
*
* This function can be used in two ways. The first is sort of a
* mutating assignment. The second behavior, if pathname is NULL, is
* just changing the mode of an already open file descriptor.
*
* @param pathname is the file to open or NULL
* @param mode is the mode string flags, see fopenflags()
* @param stream is the existing allocated stream memory, which is
* flushed and closed if already open
* @return stream object if successful, or NULL w/ errno
*/
FILE *freopen(const char *pathname, const char *mode, FILE *stream) {
int fd;
FILE *res;
unsigned flags;
flags = fopenflags(mode);
flockfile(stream);
fflush_unlocked(stream);
if (pathname) {
/* open new stream, overwriting existing alloc */
if ((fd = open(pathname, flags, 0666)) != -1) {
dup3(fd, stream->fd, flags & O_CLOEXEC);
close(fd);
stream->iomode = flags;
stream->beg = 0;
stream->end = 0;
res = stream;
} else {
res = NULL;
}
} else {
fcntl(stream->fd, F_SETFD, !!(flags & O_CLOEXEC));
fcntl(stream->fd, F_SETFL, flags & ~O_CLOEXEC);
res = stream;
}
funlockfile(stream);
return res;
}
| 3,231 | 66 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/rdrand.c | /*-*- 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/errno.h"
#include "libc/intrin/asmflag.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/stdio/rand.h"
#include "libc/sysv/consts/grnd.h"
STATIC_YOINK("rdrand_init");
static dontinline uint64_t rdrand_failover(void) {
int f;
size_t i;
ssize_t r;
volatile uint64_t b;
register uint64_t x;
for (f = GRND_RANDOM | GRND_NONBLOCK, i = 0; i < 8; i += r) {
if ((r = getrandom((char *)&b + i, 8 - i, f)) <= 0) {
if (r == -1 && errno == EINTR) {
r = 0;
} else if (r == -1 && errno == EAGAIN) {
r = 0;
f = 0;
} else {
return _rand64();
}
}
}
x = b;
b = 0;
return x;
}
/**
* Retrieves 64-bits of hardware random data from RDRAND instruction.
*
* If RDRAND isn't available (we check CPUID and we also disable it
* automatically for microarchitectures where it's slow or buggy) then
* we try getrandom(), RtlGenRandom(), or sysctl(KERN_ARND). If those
* aren't available then we try /dev/urandom and if that fails, we try
* getauxval(AT_RANDOM), and if not we finally use RDTSC and getpid().
*
* @note this function could block a nontrivial time on old computers
* @note this function is indeed intended for cryptography
* @note this function takes around 300 cycles
* @see rngset(), rdseed(), _rand64()
* @asyncsignalsafe
* @vforksafe
*/
uint64_t rdrand(void) {
int i;
char cf;
uint64_t x;
if (X86_HAVE(RDRND)) {
for (i = 0; i < 10; ++i) {
asm volatile(CFLAG_ASM("rdrand\t%1")
: CFLAG_CONSTRAINT(cf), "=r"(x)
: /* no inputs */
: "cc");
if (cf) return x;
asm volatile("pause");
}
}
return rdrand_failover();
}
| 3,552 | 82 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/stdio_ext.h | #ifndef COSMOPOLITAN_LIBC_STDIO_STDIO_EXT_H_
#define COSMOPOLITAN_LIBC_STDIO_STDIO_EXT_H_
#include "libc/stdio/stdio.h"
#define FSETLOCKING_QUERY 0
#define FSETLOCKING_INTERNAL 1
#define FSETLOCKING_BYCALLER 2
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
size_t __fbufsize(FILE *);
size_t __fpending(FILE *);
int __flbf(FILE *);
int __freadable(FILE *);
int __fwritable(FILE *);
int __freading(FILE *);
int __fwriting(FILE *);
int __fsetlocking(FILE *, int);
void _flushlbf(void);
void __fpurge(FILE *);
void __fseterr(FILE *);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_STDIO_EXT_H_ */
| 667 | 27 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/joinstrlist.c | /*-*- 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/stdio/append.h"
#include "libc/stdio/strlist.internal.h"
int JoinStrList(struct StrList *sl, char **buf, uint64_t sep) {
int i;
if (!*buf && !sl->i) {
return appendr(buf, 0);
}
for (i = 0; i < sl->i; ++i) {
if (i) {
if (appendw(buf, sep) == -1) {
return -1;
}
}
if (appends(buf, sl->p[i]) == -1) {
return -1;
}
}
return 0;
}
| 2,235 | 39 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/printf.c | /*-*- 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/stdio/stdio.h"
/**
* Formats and writes text to stdout.
*
* Cosmopolitan supports most of the standard formatting behaviors
* described by `man 3 printf`, in addition to the following
*
* - `%jjd`, `%jjx`, etc. are {,u}int128_t (cosmopolitan only)
*
* - `%'d` or `%,d` may be used to insert thousands separators. The prior is
* consistent with C; the latter is consistent with Python.
*
* - `%m` inserts strerror(errno) into the formatted output. This is
* consistent with glibc, musl, and uclibc.
*
* - `%hs` converts UTF-16/UCS-2 â UTF-8, which can be helpful on Windows.
* Formatting (e.g. %-10hs) will use monospace display width rather
* than string length or codepoint count.
*
* - `%ls` (or `%Ls`) converts UTF-32 â UTF-8. Formatting (e.g. %-10ls)
* will use monospace display width rather than string length.
*
* - The `%#s` and `%#c` alternate forms display values using the
* standard IBM standard 256-letter alphabet. Using `%#.*s` to specify
* length will allow true binary (i.e. with NULs) to be formatted.
*
* - The `%'s` and `%'c` alternate forms are Cosmopolitan extensions for
* escaping string literals for C/C++ and Python. The outer quotation
* marks can be added automatically using ``%`s``. If constexpr format
* strings are used, we can avoid linking cescapec() too.
*
* - The backtick modifier (``%`s`` and ``%`c``) and repr() directive
* (`%r`) both ask the formatting machine to represent values as real
* code rather than using arbitrary traditions for displaying values.
* This means it implies the quoting modifier, wraps the value with
* {,u,L}['"] quotes, displays NULL as "NULL" rather than "(null)".
*
* @see __fmt() for intuitive reference documentation
* @see {,v}{,s{,n},{,{,x}as},f,d}printf
*/
int(printf)(const char* fmt, ...) {
int rc;
va_list va;
va_start(va, fmt);
rc = (vfprintf)(stdout, fmt, va);
va_end(va);
return rc;
}
| 3,799 | 68 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getline.c | /*-*- 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/stdio/stdio.h"
/**
* Reads line from stream, e.g.
*
* char *line = NULL;
* size_t linesize = 0;
* while (getline(&line, &linesize, stdin) > 0) {
* _chomp(line);
* printf("%s\n", line);
* }
* free(line);
*
* This function delegates to getdelim(), which provides further
* documentation. Concerning lines, please note the \n or \r\n are
* included in results, and can be removed with _chomp().
*
* @param line is the caller's buffer (in/out) which is extended
* automatically. *line may be NULL but only if *n is 0;
* NUL-termination is guaranteed FTMP
* @return number of bytes read, including delim, excluding NUL, or -1
* w/ errno on EOF or error; see ferror() and feof()
* @see fgetln(), xgetline(), getdelim(), gettok_r()
*/
ssize_t getline(char **line, size_t *n, FILE *f) {
return getdelim(line, n, '\n', f);
}
| 2,735 | 46 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/mkdtemp.c | /*-*- 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/stdio/rand.h"
#include "libc/stdio/temp.h"
#include "libc/str/str.h"
#include "libc/sysv/errfuns.h"
/**
* Creates temporary directory, e.g.
*
* char path[PATH_MAX];
* snprintf(path, sizeof(path), "%s%s.XXXXXX",
* kTmpPath, program_invocation_short_name);
* printf("%s\n", mkdtemp(path));
* rmdir(path);
*
* @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) {
unsigned x;
int i, j, n;
if ((n = strlen(template)) >= 6 && !memcmp(template + n - 6, "XXXXXX", 6)) {
for (i = 0; i < 10; ++i) {
x = _rand64();
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;
}
| 3,036 | 65 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/rdseed.c | /*-*- 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/intrin/asmflag.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/stdio/rand.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/grnd.h"
/**
* Retrieves 64-bits of true random data from RDSEED instruction.
*
* If RDSEED isn't available, we'll try RDRAND (which we automatically
* disable for microarchitectures where it's known to be slow or buggy).
* If RDRAND isn't available then we try getrandom(), RtlGenRandom(), or
* sysctl(KERN_ARND). If those aren't available then we try /dev/urandom
* and if that fails, we use RDTSC and getpid().
*
* @note this function could block a nontrivial time on old computers
* @note this function is indeed intended for cryptography
* @note this function takes around 800 cycles
* @see rngset(), rdrand(), _rand64()
* @asyncsignalsafe
* @vforksafe
*/
uint64_t rdseed(void) {
int i;
char cf;
uint64_t x;
if (X86_HAVE(RDSEED)) {
for (i = 0; i < 10; ++i) {
asm volatile(CFLAG_ASM("rdseed\t%1")
: CFLAG_CONSTRAINT(cf), "=r"(x)
: /* no inputs */
: "cc");
if (cf) return x;
asm volatile("pause");
}
}
return rdrand();
}
| 3,028 | 57 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ungetc_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/stdio.h"
#include "libc/str/str.h"
/**
* Pushes byte back to stream.
*/
int ungetc_unlocked(int c, FILE *f) {
if (c == -1) return -1;
if (f->beg) {
f->buf[--f->beg] = c;
} else if (f->end < f->size) {
memmove(f->buf + 1, f->buf, f->end++);
f->buf[0] = c;
} else {
return -1;
}
return c & 255;
}
| 2,183 | 37 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/kvappendf.c | /*-*- 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 2021 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/assert.h"
#include "libc/dce.h"
#include "libc/intrin/kprintf.h"
#include "libc/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/stdio/append.h"
#define W sizeof(size_t)
/**
* Appends formatted string to buffer.
*
* This is an alternative to vappendf() that uses the kprintf()
* formatting facility. This has some advantages in terms of
* performance, code size, and memory safety. There's also
* disadvantages, such as lack of floating-point directives.
*
* @see kprintf()
*/
ssize_t kvappendf(char **b, const char *f, va_list v) {
char *p;
int r, s;
size_t n;
va_list w;
struct appendz z;
z = appendz((p = *b));
va_copy(w, v);
if ((r = kvsnprintf(p + z.i, z.n ? z.n - W - z.i : 0, f, v)) >= 0) {
n = ROUNDUP(z.i + r + 1, 8) + W;
if (n > z.n) {
if (!z.n) z.n = W * 2;
while (n > z.n) z.n += z.n >> 1;
z.n = ROUNDUP(z.n, W);
if ((p = realloc(p, z.n))) {
z.n = malloc_usable_size(p);
_unassert(!(z.n & (W - 1)));
s = kvsnprintf(p + z.i, z.n - W - z.i, f, w);
_unassert(s == r);
*b = p;
} else {
va_end(w);
return -1;
}
}
z.i += r;
if (!IsTiny() && W == 8) z.i |= (size_t)APPEND_COOKIE << 48;
*(size_t *)(p + z.n - W) = z.i;
}
va_end(w);
return r;
}
| 3,159 | 70 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getrandom.c | /*-*- 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/assert.h"
#include "libc/calls/blockcancel.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/cp.internal.h"
#include "libc/calls/internal.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/sigset.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/calls/syscall_support-nt.internal.h"
#include "libc/calls/syscall_support-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/asmflag.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/macros.internal.h"
#include "libc/nexgen32e/kcpuids.h"
#include "libc/nexgen32e/rdtsc.h"
#include "libc/nexgen32e/vendor.internal.h"
#include "libc/nexgen32e/x86feature.h"
#include "libc/nexgen32e/x86info.h"
#include "libc/nt/runtime.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/rand.h"
#include "libc/stdio/xorshift.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/at.h"
#include "libc/sysv/consts/auxv.h"
#include "libc/sysv/consts/grnd.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/sig.h"
#include "libc/sysv/errfuns.h"
#include "libc/thread/thread.h"
STATIC_YOINK("rdrand_init");
int sys_getentropy(void *, size_t) asm("sys_getrandom");
static bool have_getrandom;
static bool GetRandomRdseed(uint64_t *out) {
int i;
char cf;
uint64_t x;
for (i = 0; i < 10; ++i) {
asm volatile(CFLAG_ASM("rdseed\t%1")
: CFLAG_CONSTRAINT(cf), "=r"(x)
: /* no inputs */
: "cc");
if (cf) {
*out = x;
return true;
}
asm volatile("pause");
}
return false;
}
static bool GetRandomRdrand(uint64_t *out) {
int i;
char cf;
uint64_t x;
for (i = 0; i < 10; ++i) {
asm volatile(CFLAG_ASM("rdrand\t%1")
: CFLAG_CONSTRAINT(cf), "=r"(x)
: /* no inputs */
: "cc");
if (cf) {
*out = x;
return true;
}
asm volatile("pause");
}
return false;
}
static ssize_t GetRandomCpu(char *p, size_t n, int f, bool impl(uint64_t *)) {
uint64_t x;
size_t i, j;
for (i = 0; i < n; i += j) {
TryAgain:
if (!impl(&x)) {
if (f || i >= 256) break;
goto TryAgain;
}
for (j = 0; j < 8 && i + j < n; ++j) {
p[i + j] = x;
x >>= 8;
}
}
return n;
}
static ssize_t GetRandomMetal(char *p, size_t n, int f) {
if (f & GRND_RANDOM) {
if (X86_HAVE(RDSEED)) {
return GetRandomCpu(p, n, f, GetRandomRdseed);
} else {
return enosys();
}
} else {
if (X86_HAVE(RDRND)) {
return GetRandomCpu(p, n, f, GetRandomRdrand);
} else {
return enosys();
}
}
}
static void GetRandomEntropy(char *p, size_t n) {
_unassert(n <= 256);
if (sys_getentropy(p, n)) notpossible;
}
static void GetRandomArnd(char *p, size_t n) {
size_t m;
int cmd[2];
cmd[0] = 1; // CTL_KERN
cmd[1] = IsFreebsd() ? 37 : 81; // KERN_ARND
_unassert((m = n) <= 256);
if (sys_sysctl(cmd, 2, p, &n, 0, 0) == -1) notpossible;
if (m != n) notpossible;
}
static ssize_t GetRandomBsd(char *p, size_t n, void impl(char *, size_t)) {
errno_t e;
size_t m, i;
if (_weaken(pthread_testcancel_np) &&
(e = _weaken(pthread_testcancel_np)())) {
errno = e;
return -1;
}
for (i = 0;;) {
m = MIN(n - i, 256);
impl(p + i, m);
if ((i += m) == n) {
return n;
}
if (_weaken(pthread_testcancel)) {
_weaken(pthread_testcancel)();
}
}
}
static ssize_t GetDevUrandom(char *p, size_t n) {
int fd;
ssize_t rc;
fd = sys_openat(AT_FDCWD, "/dev/urandom", O_RDONLY | O_CLOEXEC, 0);
if (fd == -1) return -1;
pthread_cleanup_push((void *)sys_close, (void *)(intptr_t)fd);
rc = sys_read(fd, p, n);
pthread_cleanup_pop(1);
return rc;
}
ssize_t __getrandom(void *p, size_t n, unsigned f) {
ssize_t rc;
if (IsWindows()) {
if (_check_interrupts(true, 0)) return -1;
rc = RtlGenRandom(p, n) ? n : __winerr();
} else if (have_getrandom) {
if (IsXnu() || IsOpenbsd()) {
rc = GetRandomBsd(p, n, GetRandomEntropy);
} else {
BEGIN_CANCELLATION_POINT;
rc = sys_getrandom(p, n, f);
END_CANCELLATION_POINT;
}
} else if (IsFreebsd() || IsNetbsd()) {
rc = GetRandomBsd(p, n, GetRandomArnd);
} else if (IsMetal()) {
rc = GetRandomMetal(p, n, f);
} else {
BEGIN_CANCELLATION_POINT;
rc = GetDevUrandom(p, n);
END_CANCELLATION_POINT;
}
return rc;
}
/**
* Returns cryptographic random data.
*
* This random number seed generator obtains information from:
*
* - RtlGenRandom() on Windows
* - getentropy() on XNU and OpenBSD
* - getrandom() on Linux, FreeBSD, and NetBSD
* - sysctl(KERN_ARND) on older versions of FreeBSD and NetBSD
*
* Unlike getentropy() this function is interruptible. However EINTR
* shouldn't be possible if `f` is zero and `n` is no more than 256,
* noting that kernels are a bit vague with their promises here, and
* if you're willing to trade some performance for a more assurances
* that EINTR won't happen, then either consider using getentropy(),
* or using the `SA_RESTART` flag on your signal handlers.
*
* Unlike getentropy() you may specify an `n` greater than 256. When
* larger amounts are specified, the caller must be prepared for the
* case where fewer than `n` bytes are returned. In that case, it is
* likely that a signal delivery occured. Cancellations in mask mode
* also need to be suppressed while processing the bytes beyond 256.
* On BSD OSes, this entire process is uninterruptible so be careful
* when using large sizes if interruptibility is needed.
*
* Unlike getentropy() this function is a cancellation point. But it
* shouldn't be a problem, unless you're using masked mode, in which
* case extra care must be taken to consider the result.
*
* It's recommended that `f` be set to zero, although it may include
* the following flags:
*
* - `GRND_NONBLOCK` when you want to elevate the insecurity of your
* random data
*
* - `GRND_RANDOM` if you want to have the best possible chance your
* program will freeze and the system operator is paged to address
* the outage by driving to the data center and jiggling the mouse
*
* @note this function could block a nontrivial time on old computers
* @note this function is indeed intended for cryptography
* @note this function takes around 900 cycles
* @raise EINVAL if `f` is invalid
* @raise ECANCELED if thread was cancelled in masked mode
* @raise EFAULT if the `n` bytes at `p` aren't valid memory
* @raise EINTR if we needed to block and a signal was delivered instead
* @cancellationpoint
* @asyncsignalsafe
* @restartable
* @vforksafe
*/
ssize_t getrandom(void *p, size_t n, unsigned f) {
ssize_t rc;
if ((!p && n) || (IsAsan() && !__asan_is_valid(p, n))) {
rc = efault();
} else if ((f & ~(GRND_RANDOM | GRND_NONBLOCK))) {
rc = einval();
} else {
rc = __getrandom(p, n, f);
}
STRACE("getrandom(%p, %'zu, %#x) â %'ld% m", p, n, f, rc);
return rc;
}
__attribute__((__constructor__)) static textstartup void getrandom_init(void) {
int e, rc;
if (IsWindows() || IsMetal()) return;
BLOCK_CANCELLATIONS;
e = errno;
if (!(rc = sys_getrandom(0, 0, 0))) {
have_getrandom = true;
} else {
errno = e;
}
ALLOW_CANCELLATIONS;
STRACE("sys_getrandom(0,0,0) â %d% m", rc);
}
| 9,322 | 278 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fprintf_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/stdio.h"
/**
* Formats and writes text to stream.
* @see printf() for further documentation
*/
int(fprintf_unlocked)(FILE *f, const char *fmt, ...) {
int rc;
va_list va;
va_start(va, fmt);
rc = (vfprintf_unlocked)(f, fmt, va);
va_end(va);
return rc;
}
| 2,125 | 33 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fputws_unlocked.c | /*-*- 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/errno.h"
#include "libc/stdio/stdio.h"
/**
* Writes wide character string to stream.
*
* Writing stops at the NUL-terminator, which isn't included in output.
* This function blocks until the full string is written, unless an
* unrecoverable error happens.
*
* @param s is a NUL-terminated string that's non-NULL
* @param f is an open stream
* @return strlen(s), or -1 w/ errno
*/
int fputws_unlocked(const wchar_t *s, FILE *f) {
int res = 0;
while (*s) {
if (fputwc_unlocked(*s++, f) == -1) {
if (ferror_unlocked(f) == EINTR) {
continue;
}
if (feof_unlocked(f)) {
errno = f->state = EPIPE;
}
return -1;
}
++res;
}
return ++res;
}
| 2,558 | 49 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/dumphexc.c | /*-*- 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 2021 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/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/stdio/append.h"
#include "libc/stdio/hex.internal.h"
#include "libc/str/str.h"
/**
* Turns data into "\x00..." string literal.
*/
char *DumpHexc(const char *p, size_t n, size_t *z) {
long o;
int i, m;
char A[128], *q, *s = 0;
if (n == -1) n = p ? strlen(p) : 0;
appendw(&s, '"' | '\\' << 8 | '\n' << 16);
for (o = 0; (m = MIN(16, n)); p += m, n -= m) {
q = A;
for (i = 0; i < m; ++i) {
*q++ = '\\';
*q++ = 'x';
*q++ = "0123456789abcdef"[(p[i] & 0xF0) >> 4];
*q++ = "0123456789abcdef"[(p[i] & 0x0F) >> 0];
}
if (o) appendw(&s, '\\' | '\n' << 8);
appendd(&s, A, q - A);
o += m;
}
if (appendw(&s, '"') != -1) {
if (z) *z = appendz(s).i;
return s;
} else {
free(s);
return 0;
}
}
| 2,674 | 54 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/putchar_unlocked.c | /*-*- 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/stdio/stdio.h"
/**
* Writes byte to stdout.
*
* @return c (as unsigned char) if written or -1 w/ errno
*/
int putchar_unlocked(int c) {
return fputc_unlocked(c, stdout);
}
| 2,030 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fwritable.c | /*-*- 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 2021 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/stdio/stdio_ext.h"
#include "libc/sysv/consts/o.h"
/**
* Returns nonzero if stream allows reading.
*/
int __fwritable(FILE *f) {
return (f->iomode & O_ACCMODE) == O_WRONLY ||
(f->iomode & O_ACCMODE) == O_RDWR;
}
| 2,077 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/putwchar.c | /*-*- 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/stdio/stdio.h"
/**
* Writes wide character to stdout.
* @return wc if written or -1 w/ errno
* @threadsafe
*/
wint_t putwchar(wchar_t wc) {
return fputwc(wc, stdout);
}
| 2,027 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/putc_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/stdio.h"
/**
* Writes byte to stream.
*
* @param c is byte to buffer or write, which is masked
* @return c as unsigned char if written or -1 w/ errno
*/
int(putc_unlocked)(int c, FILE *f) {
return fputc_unlocked(c, f);
}
| 2,086 | 30 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/paginate.c | /*-*- 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/fmt/fmt.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
#include "libc/x/x.h"
/**
* Displays wall of text in terminal with pagination.
*/
void __paginate(int fd, const char *s) {
int tfd, pid;
char *args[3] = {0};
char tmppath[PATH_MAX];
char progpath[PATH_MAX];
if (strcmp(nulltoempty(getenv("TERM")), "dumb") && isatty(0) && isatty(1) &&
((args[0] = commandv("less", progpath, sizeof(progpath))) ||
(args[0] = commandv("more", progpath, sizeof(progpath))))) {
snprintf(tmppath, sizeof(tmppath), "%s%s-%s-%d.txt", kTmpPath,
firstnonnull(program_invocation_short_name, "unknown"), "paginate",
getpid());
if ((tfd = open(tmppath, O_WRONLY | O_CREAT | O_TRUNC, 0644)) != -1) {
write(tfd, s, strlen(s));
close(tfd);
args[1] = tmppath;
if ((pid = fork()) != -1) {
putenv("LC_ALL=C.UTF-8");
putenv("LESSCHARSET=utf-8");
putenv("LESS=-RS");
if (!pid) {
execv(args[0], args);
_Exit(127);
}
waitpid(pid, 0, 0);
unlink(tmppath);
return;
}
unlink(tmppath);
}
}
write(fd, s, strlen(s));
}
| 3,169 | 63 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fputwc.c | /*-*- 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Writes wide character to stream.
*
* @param wc has wide character
* @param f is file object stream pointer
* @return wide character if written or -1 w/ errno
* @threadsafe
*/
wint_t fputwc(wchar_t wc, FILE *f) {
wint_t rc;
flockfile(f);
rc = fputwc_unlocked(wc, f);
funlockfile(f);
return rc;
}
| 2,223 | 37 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fseek.c | /*-*- 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/stdio/stdio.h"
/**
* Repositions open file stream.
*
* This function flushes the buffer (unless it's currently in the EOF
* state) and then calls lseek() on the underlying file. If the stream
* is in the EOF state, this function can be used to restore it without
* needing to reopen the file.
*
* @param f is a non-null stream handle
* @param offset is the byte delta
* @param whence can be SEET_SET, SEEK_CUR, or SEEK_END
* @returns 0 on success or -1 on error
*/
int fseek(FILE *f, long offset, int whence) {
return fseeko(f, offset, whence);
}
| 2,413 | 37 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/posix_spawn.h | #ifndef COSMOPOLITAN_LIBC_STDIO_SPAWN_H_
#define COSMOPOLITAN_LIBC_STDIO_SPAWN_H_
#include "libc/calls/struct/sched_param.h"
#include "libc/calls/struct/sigset.h"
#define POSIX_SPAWN_RESETIDS 0x01
#define POSIX_SPAWN_SETPGROUP 0x02
#define POSIX_SPAWN_SETSIGDEF 0x04
#define POSIX_SPAWN_SETSIGMASK 0x08
#define POSIX_SPAWN_SETSCHEDPARAM 0x10
#define POSIX_SPAWN_SETSCHEDULER 0x20
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
typedef struct _posix_spawna *posix_spawnattr_t;
typedef struct _posix_faction *posix_spawn_file_actions_t;
int posix_spawn(int *, const char *, const posix_spawn_file_actions_t *,
const posix_spawnattr_t *, char *const[], char *const[]);
int posix_spawnp(int *, const char *, const posix_spawn_file_actions_t *,
const posix_spawnattr_t *, char *const[], char *const[]);
int posix_spawn_file_actions_init(posix_spawn_file_actions_t *);
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *);
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *, int,
const char *, int, unsigned);
int posix_spawnattr_init(posix_spawnattr_t *);
int posix_spawnattr_destroy(posix_spawnattr_t *);
int posix_spawnattr_getflags(const posix_spawnattr_t *, short *);
int posix_spawnattr_setflags(posix_spawnattr_t *, short);
int posix_spawnattr_getpgroup(const posix_spawnattr_t *, int *);
int posix_spawnattr_setpgroup(posix_spawnattr_t *, int);
int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *, int *);
int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int);
int posix_spawnattr_getschedparam(const posix_spawnattr_t *,
struct sched_param *);
int posix_spawnattr_setschedparam(posix_spawnattr_t *,
const struct sched_param *);
int posix_spawnattr_getsigmask(const posix_spawnattr_t *, sigset_t *);
int posix_spawnattr_setsigmask(posix_spawnattr_t *, const sigset_t *);
int posix_spawnattr_getsigdefault(const posix_spawnattr_t *, sigset_t *);
int posix_spawnattr_setsigdefault(posix_spawnattr_t *, const sigset_t *);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_SPAWN_H_ */
| 2,406 | 51 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/putwc_unlocked.c | /*-*- 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/stdio/stdio.h"
/**
* Writes wide character to stream.
*
* @return wc if written or -1 w/ errno
*/
wint_t(putwc_unlocked)(wchar_t wc, FILE *f) {
return fputwc_unlocked(wc, f);
}
| 2,035 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/revjis.inc | 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,
| 38,597 | 516 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fread.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Reads data from stream.
*
* @param stride specifies the size of individual items
* @param count is the number of strides to fetch
* @return count on success, [0,count) on eof, or 0 on error or count==0
* @threadsafe
*/
size_t fread(void *buf, size_t stride, size_t count, FILE *f) {
size_t rc;
flockfile(f);
rc = fread_unlocked(buf, stride, count, f);
STDIOTRACE("fread(%p, %'zu, %'zu, %p) â %'zu %s", buf, stride, count, f, rc,
DescribeStdioState(f->state));
funlockfile(f);
return rc;
}
| 2,557 | 42 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fpurge.c | /*-*- 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 2021 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/stdio/stdio.h"
/**
* Discards contents of stream buffer.
*/
int fpurge(FILE *f) {
f->beg = f->end = 0;
return 0;
}
| 1,973 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/rand.c | /*-*- 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/stdio/rand.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/lcg.internal.h"
/**
* Returns 31-bit linear congruential pseudorandom number, e.g.
*
* int x = rand();
* assert(x >= 0);
*
* This function always returns a positive number. If srand() isn't
* called, then it'll return the same sequence each time your program
* runs. Faster and more modern alternatives exist to this function.
*
* This function is not thread safe in the sense that multiple threads
* might simultaneously generate the same random values.
*
* @note this function does well on bigcrush and practrand
* @note this function is not intended for cryptography
* @see lemur64(), _rand64(), rdrand()
*/
int rand(void) {
return KnuthLinearCongruentialGenerator(&g_rando) >> 33;
}
| 2,633 | 43 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/hex.internal.h | #ifndef COSMOPOLITAN_LIBC_STDIO_HEX_INTERNAL_H_
#define COSMOPOLITAN_LIBC_STDIO_HEX_INTERNAL_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
char *DumpHex(const char *, size_t, size_t *);
char *DumpHexc(const char *, size_t, size_t *);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_HEX_INTERNAL_H_ */
| 373 | 12 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/feof.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Returns true if stream is in end-of-file state.
*
* @param f is file object stream pointer
* @see feof_unlocked()
* @threadsafe
*/
int feof(FILE *f) {
int rc;
flockfile(f);
rc = feof_unlocked(f);
funlockfile(f);
return rc;
}
| 2,152 | 36 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/temp.h | #ifndef COSMOPOLITAN_LIBC_STDIO_TEMP_H_
#define COSMOPOLITAN_LIBC_STDIO_TEMP_H_
#include "libc/stdio/stdio.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
FILE *tmpfile(void);
char *mkdtemp(char *);
char *mktemp(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 (*)(const char *, int, ...)) _Hide dontdiscard;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_TEMP_H_ */
| 659 | 23 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgetpos.c | /*-*- 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/stdio/stdio.h"
int fgetpos(FILE *stream, fpos_t *pos) {
long res;
if ((res = ftell(stream)) != -1) {
*pos = res;
return 0;
} else {
return -1;
}
}
| 2,019 | 30 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/hkscs.inc | 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,
| 29,478 | 391 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/feof_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/stdio.h"
/**
* Returns true if stream is in end-of-file state.
*
* @param f is file object stream pointer
* @see feof()
*/
int feof_unlocked(FILE *f) {
return f->state == -1;
}
| 2,042 | 30 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/getwc.c | /*-*- 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/stdio/stdio.h"
/**
* Reads UTF-8 character from stream.
* @return wide character or -1 on EOF or error
* @threadsafe
*/
wint_t(getwc)(FILE *f) {
return fgetwc(f);
}
| 2,023 | 29 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgetws.c | /*-*- 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Reads UTF-8 content from stream into UTF-32 buffer.
*
* This function is similar to getline() except it'll truncate lines
* exceeding size. The line ending marker is included and may be removed
* using _chomp().
*
* @param s is is nul-terminated string that's non-null
* @param size is byte length of `s`
* @param f is file stream object pointer
* @see fgetws()
* @threadsafe
*/
wchar_t *fgetws(wchar_t *s, int size, FILE *f) {
wchar_t *rc;
flockfile(f);
rc = fgetws_unlocked(s, size, f);
funlockfile(f);
return rc;
}
| 2,451 | 42 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fopen.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/calls/calls.h"
#include "libc/mem/mem.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
static const char *fixpathname(const char *pathname, int flags) {
if ((flags & O_ACCMODE) == O_RDONLY && strcmp(pathname, "-") == 0) {
return "/dev/stdin";
} else if ((flags & O_ACCMODE) == O_WRONLY && strcmp(pathname, "-") == 0) {
return "/dev/stdout";
} else {
return pathname;
}
}
static int openpathname(const char *pathname, int flags, bool *out_noclose) {
if ((flags & O_ACCMODE) == O_RDONLY && strcmp(pathname, "/dev/stdin") == 0) {
*out_noclose = true;
return fileno(stdin);
} else if ((flags & O_ACCMODE) == O_WRONLY &&
strcmp(pathname, "/dev/stdout") == 0) {
*out_noclose = true;
return fileno(stdout);
} else {
*out_noclose = false;
return open(pathname, flags, 0666);
}
}
/**
* Opens file as stream object.
*
* @param pathname is a utf-8 ideally relative filename
* @param mode is the string mode/flag DSL see fopenflags()
* @return new object to be free'd by fclose() or NULL w/ errno
* @note microsoft unilaterally deprecated this function lool
*/
FILE *fopen(const char *pathname, const char *mode) {
FILE *f = 0;
bool noclose;
int fd, flags;
if (!pathname) {
efault();
return 0;
}
flags = fopenflags(mode);
pathname = fixpathname(pathname, flags);
if ((fd = openpathname(pathname, flags, &noclose)) != -1) {
if ((f = fdopen(fd, mode)) != NULL) {
f->noclose = noclose;
} else if (!noclose) {
close(fd);
}
}
return f;
}
| 3,472 | 77 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/mktemp.c | /*-*- 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/calls/calls.h"
#include "libc/stdio/temp.h"
#include "libc/sysv/errfuns.h"
/**
* Generates unique filename.
*
* This function is usually frowned upon, since it's been known to
* create nasty opportunities for race conditions. Our implementation
* reflects that; consider using mkostemps().
*/
char *mktemp(char *template) {
int fd;
if ((fd = mkostemps(template, 0, 0)) != -1) {
close(fd);
unlink(template);
} else {
template[0] = '\0';
}
return template;
}
| 2,337 | 40 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/gb18030.inc | 19970,19972,19973,19974,19983,19986,19991,19999,20000,20001,20003,20006,20009,
20014,20015,20017,20019,20021,20023,20028,20032,20033,20034,20036,20038,20042,
20049,20053,20055,20058,20059,20066,20067,20068,20069,20071,20072,20074,20075,
20076,20077,20078,20079,20082,20084,20085,20086,20087,20088,20089,20090,20091,
20092,20093,20095,20096,20097,20098,20099,20100,20101,20103,20106,20112,20118,
20119,20121,20124,20125,20126,20131,20138,20143,20144,20145,20148,20150,20151,
20152,20153,20156,20157,20158,20168,20172,20175,20176,20178,20186,20187,20188,
20192,20194,20198,20199,20201,20205,20206,20207,20209,20212,20216,20217,20218,
20220,20222,20224,20226,20227,20228,20229,20230,20231,20232,20235,20236,20242,
20243,20244,20245,20246,20252,20253,20257,20259,20264,20265,20268,20269,20270,
20273,20275,20277,20279,20281,20283,20286,20287,20288,20289,20290,20292,20293,
20295,20296,20297,20298,20299,20300,20306,20308,20310,20321,20322,20326,20328,
20330,20331,20333,20334,20337,20338,20341,20343,20344,20345,20346,20349,20352,
20353,20354,20357,20358,20359,20362,20364,20366,20368,20370,20371,20373,20374,
20376,20377,20378,20380,20382,20383,20385,20386,20388,20395,20397,20400,20401,
20402,20403,20404,20406,20407,20408,20409,20410,20411,20412,20413,20414,20416,
20417,20418,20422,20423,20424,20425,20427,20428,20429,20434,20435,20436,20437,
20438,20441,20443,20448,20450,20452,20453,20455,20459,20460,20464,20466,20468,
20469,20470,20471,20473,20475,20476,20477,20479,20480,20481,20482,20483,20484,
20485,20486,20487,20488,20489,20490,20491,20494,
20496,20497,20499,20501,20502,20503,20507,20509,20510,20512,20514,20515,20516,
20519,20523,20527,20528,20529,20530,20531,20532,20533,20534,20535,20536,20537,
20539,20541,20543,20544,20545,20546,20548,20549,20550,20553,20554,20555,20557,
20560,20561,20562,20563,20564,20566,20567,20568,20569,20571,20573,20574,20575,
20576,20577,20578,20579,20580,20582,20583,20584,20585,20586,20587,20589,20590,
20591,20592,20593,20594,20595,20596,20597,20600,20601,20602,20604,20605,20609,
20610,20611,20612,20614,20615,20617,20618,20619,20620,20622,20623,20624,20625,
20626,20627,20628,20629,20630,20631,20632,20633,20634,20635,20636,20637,20638,
20639,20640,20641,20642,20644,20646,20650,20651,20653,20654,20655,20656,20657,
20659,20660,20661,20662,20663,20664,20665,20668,20669,20670,20671,20672,20673,
20674,20675,20676,20677,20678,20679,20680,20681,20682,20683,20684,20685,20686,
20688,20689,20690,20691,20692,20693,20695,20696,20697,20699,20700,20701,20702,
20703,20704,20705,20706,20707,20708,20709,20712,20713,20714,20715,20719,20720,
20721,20722,20724,20726,20727,20728,20729,20730,20732,20733,20734,20735,20736,
20737,20738,20739,20740,20741,20744,20745,20746,20748,20749,20750,20751,20752,
20753,20755,20756,20757,20758,20759,20760,20761,20762,20763,20764,20765,20766,
20767,20768,20770,20771,20772,20773,20774,20775,20776,20777,20778,20779,20780,
20781,20782,20783,20784,20785,20786,20787,20788,20789,20790,20791,20792,20793,
20794,20795,20796,20797,20798,20802,20807,20810,20812,20814,20815,20816,20818,
20819,20823,20824,20825,20827,20829,20830,20831,20832,
20833,20835,20836,20838,20839,20841,20842,20847,20850,20858,20862,20863,20867,
20868,20870,20871,20874,20875,20878,20879,20880,20881,20883,20884,20888,20890,
20893,20894,20895,20897,20899,20902,20903,20904,20905,20906,20909,20910,20916,
20920,20921,20922,20926,20927,20929,20930,20931,20933,20936,20938,20941,20942,
20944,20946,20947,20948,20949,20950,20951,20952,20953,20954,20956,20958,20959,
20962,20963,20965,20966,20967,20968,20969,20970,20972,20974,20977,20978,20980,
20983,20990,20996,20997,21001,21003,21004,21007,21008,21011,21012,21013,21020,
21022,21023,21025,21026,21027,21029,21030,21031,21034,21036,21039,21041,21042,
21044,21045,21052,21054,21060,21061,21062,21063,21064,21065,21067,21070,21071,
21074,21075,21077,21079,21080,21081,21082,21083,21085,21087,21088,21090,21091,
21092,21094,21096,21099,21100,21101,21102,21104,21105,21107,21108,21109,21110,
21111,21112,21113,21114,21115,21116,21118,21120,21123,21124,21125,21126,21127,
21129,21130,21131,21132,21133,21134,21135,21137,21138,21140,21141,21142,21143,
21144,21145,21146,21148,21156,21157,21158,21159,21166,21167,21168,21172,21173,
21174,21175,21176,21177,21178,21179,21180,21181,21184,21185,21186,21188,21189,
21190,21192,21194,21196,21197,21198,21199,21201,21203,21204,21205,21207,21209,
21210,21211,21212,21213,21214,21216,21217,21218,21219,21221,21222,21223,21224,
21225,21226,21227,21228,21229,21230,21231,21233,21234,21235,21236,21237,21238,
21239,21240,21243,21244,21245,21249,21250,21251,21252,21255,21257,21258,21259,
21260,21262,21265,21266,21267,21268,21272,21275,21276,
21278,21279,21282,21284,21285,21287,21288,21289,21291,21292,21293,21295,21296,
21297,21298,21299,21300,21301,21302,21303,21304,21308,21309,21312,21314,21316,
21318,21323,21324,21325,21328,21332,21336,21337,21339,21341,21349,21352,21354,
21356,21357,21362,21366,21369,21371,21372,21373,21374,21376,21377,21379,21383,
21384,21386,21390,21391,21392,21393,21394,21395,21396,21398,21399,21401,21403,
21404,21406,21408,21409,21412,21415,21418,21419,21420,21421,21423,21424,21425,
21426,21427,21428,21429,21431,21432,21433,21434,21436,21437,21438,21440,21443,
21444,21445,21446,21447,21454,21455,21456,21458,21459,21461,21466,21468,21469,
21470,21473,21474,21479,21492,21498,21502,21503,21504,21506,21509,21511,21515,
21524,21528,21529,21530,21532,21538,21540,21541,21546,21552,21555,21558,21559,
21562,21565,21567,21569,21570,21572,21573,21575,21577,21580,21581,21582,21583,
21585,21594,21597,21598,21599,21600,21601,21603,21605,21607,21609,21610,21611,
21612,21613,21614,21615,21616,21620,21625,21626,21630,21631,21633,21635,21637,
21639,21640,21641,21642,21645,21649,21651,21655,21656,21660,21662,21663,21664,
21665,21666,21669,21678,21680,21682,21685,21686,21687,21689,21690,21692,21694,
21699,21701,21706,21707,21718,21720,21723,21728,21729,21730,21731,21732,21739,
21740,21743,21744,21745,21748,21749,21750,21751,21752,21753,21755,21758,21760,
21762,21763,21764,21765,21768,21770,21771,21772,21773,21774,21778,21779,21781,
21782,21783,21784,21785,21786,21788,21789,21790,21791,21793,21797,21798,21800,
21801,21803,21805,21810,21812,21813,21814,21816,21817,
21818,21819,21821,21824,21826,21829,21831,21832,21835,21836,21837,21838,21839,
21841,21842,21843,21844,21847,21848,21849,21850,21851,21853,21854,21855,21856,
21858,21859,21864,21865,21867,21871,21872,21873,21874,21875,21876,21881,21882,
21885,21887,21893,21894,21900,21901,21902,21904,21906,21907,21909,21910,21911,
21914,21915,21918,21920,21921,21922,21923,21924,21925,21926,21928,21929,21930,
21931,21932,21933,21934,21935,21936,21938,21940,21942,21944,21946,21948,21951,
21952,21953,21954,21955,21958,21959,21960,21962,21963,21966,21967,21968,21973,
21975,21976,21977,21978,21979,21982,21984,21986,21991,21993,21997,21998,22000,
22001,22004,22006,22008,22009,22010,22011,22012,22015,22018,22019,22020,22021,
22022,22023,22026,22027,22029,22032,22033,22034,22035,22036,22037,22038,22039,
22041,22042,22044,22045,22048,22049,22050,22053,22054,22056,22057,22058,22059,
22062,22063,22064,22067,22069,22071,22072,22074,22076,22077,22078,22080,22081,
22082,22083,22084,22085,22086,22087,22088,22089,22090,22091,22095,22096,22097,
22098,22099,22101,22102,22106,22107,22109,22110,22111,22112,22113,22115,22117,
22118,22119,22125,22126,22127,22128,22130,22131,22132,22133,22135,22136,22137,
22138,22141,22142,22143,22144,22145,22146,22147,22148,22151,22152,22153,22154,
22155,22156,22157,22160,22161,22162,22164,22165,22166,22167,22168,22169,22170,
22171,22172,22173,22174,22175,22176,22177,22178,22180,22181,22182,22183,22184,
22185,22186,22187,22188,22189,22190,22192,22193,22194,22195,22196,22197,22198,
22200,22201,22202,22203,22205,22206,22207,22208,22209,
22210,22211,22212,22213,22214,22215,22216,22217,22219,22220,22221,22222,22223,
22224,22225,22226,22227,22229,22230,22232,22233,22236,22243,22245,22246,22247,
22248,22249,22250,22252,22254,22255,22258,22259,22262,22263,22264,22267,22268,
22272,22273,22274,22277,22279,22283,22284,22285,22286,22287,22288,22289,22290,
22291,22292,22293,22294,22295,22296,22297,22298,22299,22301,22302,22304,22305,
22306,22308,22309,22310,22311,22315,22321,22322,22324,22325,22326,22327,22328,
22332,22333,22335,22337,22339,22340,22341,22342,22344,22345,22347,22354,22355,
22356,22357,22358,22360,22361,22370,22371,22373,22375,22380,22382,22384,22385,
22386,22388,22389,22392,22393,22394,22397,22398,22399,22400,22401,22407,22408,
22409,22410,22413,22414,22415,22416,22417,22420,22421,22422,22423,22424,22425,
22426,22428,22429,22430,22431,22437,22440,22442,22444,22447,22448,22449,22451,
22453,22454,22455,22457,22458,22459,22460,22461,22462,22463,22464,22465,22468,
22469,22470,22471,22472,22473,22474,22476,22477,22480,22481,22483,22486,22487,
22491,22492,22494,22497,22498,22499,22501,22502,22503,22504,22505,22506,22507,
22508,22510,22512,22513,22514,22515,22517,22518,22519,22523,22524,22526,22527,
22529,22531,22532,22533,22536,22537,22538,22540,22542,22543,22544,22546,22547,
22548,22550,22551,22552,22554,22555,22556,22557,22559,22562,22563,22565,22566,
22567,22568,22569,22571,22572,22573,22574,22575,22577,22578,22579,22580,22582,
22583,22584,22585,22586,22587,22588,22589,22590,22591,22592,22593,22594,22595,
22597,22598,22599,22600,22601,22602,22603,22606,22607,
22608,22610,22611,22613,22614,22615,22617,22618,22619,22620,22621,22623,22624,
22625,22626,22627,22628,22630,22631,22632,22633,22634,22637,22638,22639,22640,
22641,22642,22643,22644,22645,22646,22647,22648,22649,22650,22651,22652,22653,
22655,22658,22660,22662,22663,22664,22666,22667,22668,22669,22670,22671,22672,
22673,22676,22677,22678,22679,22680,22683,22684,22685,22688,22689,22690,22691,
22692,22693,22694,22695,22698,22699,22700,22701,22702,22703,22704,22705,22706,
22707,22708,22709,22710,22711,22712,22713,22714,22715,22717,22718,22719,22720,
22722,22723,22724,22726,22727,22728,22729,22730,22731,22732,22733,22734,22735,
22736,22738,22739,22740,22742,22743,22744,22745,22746,22747,22748,22749,22750,
22751,22752,22753,22754,22755,22757,22758,22759,22760,22761,22762,22765,22767,
22769,22770,22772,22773,22775,22776,22778,22779,22780,22781,22782,22783,22784,
22785,22787,22789,22790,22792,22793,22794,22795,22796,22798,22800,22801,22802,
22803,22807,22808,22811,22813,22814,22816,22817,22818,22819,22822,22824,22828,
22832,22834,22835,22837,22838,22843,22845,22846,22847,22848,22851,22853,22854,
22858,22860,22861,22864,22866,22867,22873,22875,22876,22877,22878,22879,22881,
22883,22884,22886,22887,22888,22889,22890,22891,22892,22893,22894,22895,22896,
22897,22898,22901,22903,22906,22907,22908,22910,22911,22912,22917,22921,22923,
22924,22926,22927,22928,22929,22932,22933,22936,22938,22939,22940,22941,22943,
22944,22945,22946,22950,22951,22956,22957,22960,22961,22963,22964,22965,22966,
22967,22968,22970,22972,22973,22975,22976,22977,22978,
22979,22980,22981,22983,22984,22985,22988,22989,22990,22991,22997,22998,23001,
23003,23006,23007,23008,23009,23010,23012,23014,23015,23017,23018,23019,23021,
23022,23023,23024,23025,23026,23027,23028,23029,23030,23031,23032,23034,23036,
23037,23038,23040,23042,23050,23051,23053,23054,23055,23056,23058,23060,23061,
23062,23063,23065,23066,23067,23069,23070,23073,23074,23076,23078,23079,23080,
23082,23083,23084,23085,23086,23087,23088,23091,23093,23095,23096,23097,23098,
23099,23101,23102,23103,23105,23106,23107,23108,23109,23111,23112,23115,23116,
23117,23118,23119,23120,23121,23122,23123,23124,23126,23127,23128,23129,23131,
23132,23133,23134,23135,23136,23137,23139,23140,23141,23142,23144,23145,23147,
23148,23149,23150,23151,23152,23153,23154,23155,23160,23161,23163,23164,23165,
23166,23168,23169,23170,23171,23172,23173,23174,23175,23176,23177,23178,23179,
23180,23181,23182,23183,23184,23185,23187,23188,23189,23190,23191,23192,23193,
23196,23197,23198,23199,23200,23201,23202,23203,23204,23205,23206,23207,23208,
23209,23211,23212,23213,23214,23215,23216,23217,23220,23222,23223,23225,23226,
23227,23228,23229,23231,23232,23235,23236,23237,23238,23239,23240,23242,23243,
23245,23246,23247,23248,23249,23251,23253,23255,23257,23258,23259,23261,23262,
23263,23266,23268,23269,23271,23272,23274,23276,23277,23278,23279,23280,23282,
23283,23284,23285,23286,23287,23288,23289,23290,23291,23292,23293,23294,23295,
23296,23297,23298,23299,23300,23301,23302,23303,23304,23306,23307,23308,23309,
23310,23311,23312,23313,23314,23315,23316,23317,23320,
23321,23322,23323,23324,23325,23326,23327,23328,23329,23330,23331,23332,23333,
23334,23335,23336,23337,23338,23339,23340,23341,23342,23343,23344,23345,23347,
23349,23350,23352,23353,23354,23355,23356,23357,23358,23359,23361,23362,23363,
23364,23365,23366,23367,23368,23369,23370,23371,23372,23373,23374,23375,23378,
23382,23390,23392,23393,23399,23400,23403,23405,23406,23407,23410,23412,23414,
23415,23416,23417,23419,23420,23422,23423,23426,23430,23434,23437,23438,23440,
23441,23442,23444,23446,23455,23463,23464,23465,23468,23469,23470,23471,23473,
23474,23479,23482,23483,23484,23488,23489,23491,23496,23497,23498,23499,23501,
23502,23503,23505,23508,23509,23510,23511,23512,23513,23514,23515,23516,23520,
23522,23523,23526,23527,23529,23530,23531,23532,23533,23535,23537,23538,23539,
23540,23541,23542,23543,23549,23550,23552,23554,23555,23557,23559,23560,23563,
23564,23565,23566,23568,23570,23571,23575,23577,23579,23582,23583,23584,23585,
23587,23590,23592,23593,23594,23595,23597,23598,23599,23600,23602,23603,23605,
23606,23607,23619,23620,23622,23623,23628,23629,23634,23635,23636,23638,23639,
23640,23642,23643,23644,23645,23647,23650,23652,23655,23656,23657,23658,23659,
23660,23661,23664,23666,23667,23668,23669,23670,23671,23672,23675,23676,23677,
23678,23680,23683,23684,23685,23686,23687,23689,23690,23691,23694,23695,23698,
23699,23701,23709,23710,23711,23712,23713,23716,23717,23718,23719,23720,23722,
23726,23727,23728,23730,23732,23734,23737,23738,23739,23740,23742,23744,23746,
23747,23749,23750,23751,23752,23753,23754,23756,23757,
23758,23759,23760,23761,23763,23764,23765,23766,23767,23768,23770,23771,23772,
23773,23774,23775,23776,23778,23779,23783,23785,23787,23788,23790,23791,23793,
23794,23795,23796,23797,23798,23799,23800,23801,23802,23804,23805,23806,23807,
23808,23809,23812,23813,23816,23817,23818,23819,23820,23821,23823,23824,23825,
23826,23827,23829,23831,23832,23833,23834,23836,23837,23839,23840,23841,23842,
23843,23845,23848,23850,23851,23852,23855,23856,23857,23858,23859,23861,23862,
23863,23864,23865,23866,23867,23868,23871,23872,23873,23874,23875,23876,23877,
23878,23880,23881,23885,23886,23887,23888,23889,23890,23891,23892,23893,23894,
23895,23897,23898,23900,23902,23903,23904,23905,23906,23907,23908,23909,23910,
23911,23912,23914,23917,23918,23920,23921,23922,23923,23925,23926,23927,23928,
23929,23930,23931,23932,23933,23934,23935,23936,23937,23939,23940,23941,23942,
23943,23944,23945,23946,23947,23948,23949,23950,23951,23952,23953,23954,23955,
23956,23957,23958,23959,23960,23962,23963,23964,23966,23967,23968,23969,23970,
23971,23972,23973,23974,23975,23976,23977,23978,23979,23980,23981,23982,23983,
23984,23985,23986,23987,23988,23989,23990,23992,23993,23994,23995,23996,23997,
23998,23999,24000,24001,24002,24003,24004,24006,24007,24008,24009,24010,24011,
24012,24014,24015,24016,24017,24018,24019,24020,24021,24022,24023,24024,24025,
24026,24028,24031,24032,24035,24036,24042,24044,24045,24048,24053,24054,24056,
24057,24058,24059,24060,24063,24064,24068,24071,24073,24074,24075,24077,24078,
24082,24083,24087,24094,24095,24096,24097,24098,24099,
24100,24101,24104,24105,24106,24107,24108,24111,24112,24114,24115,24116,24117,
24118,24121,24122,24126,24127,24128,24129,24131,24134,24135,24136,24137,24138,
24139,24141,24142,24143,24144,24145,24146,24147,24150,24151,24152,24153,24154,
24156,24157,24159,24160,24163,24164,24165,24166,24167,24168,24169,24170,24171,
24172,24173,24174,24175,24176,24177,24181,24183,24185,24190,24193,24194,24195,
24197,24200,24201,24204,24205,24206,24210,24216,24219,24221,24225,24226,24227,
24228,24232,24233,24234,24235,24236,24238,24239,24240,24241,24242,24244,24250,
24251,24252,24253,24255,24256,24257,24258,24259,24260,24261,24262,24263,24264,
24267,24268,24269,24270,24271,24272,24276,24277,24279,24280,24281,24282,24284,
24285,24286,24287,24288,24289,24290,24291,24292,24293,24294,24295,24297,24299,
24300,24301,24302,24303,24304,24305,24306,24307,24309,24312,24313,24315,24316,
24317,24325,24326,24327,24329,24332,24333,24334,24336,24338,24340,24342,24345,
24346,24348,24349,24350,24353,24354,24355,24356,24360,24363,24364,24366,24368,
24370,24371,24372,24373,24374,24375,24376,24379,24381,24382,24383,24385,24386,
24387,24388,24389,24390,24391,24392,24393,24394,24395,24396,24397,24398,24399,
24401,24404,24409,24410,24411,24412,24414,24415,24416,24419,24421,24423,24424,
24427,24430,24431,24434,24436,24437,24438,24440,24442,24445,24446,24447,24451,
24454,24461,24462,24463,24465,24467,24468,24470,24474,24475,24477,24478,24479,
24480,24482,24483,24484,24485,24486,24487,24489,24491,24492,24495,24496,24497,
24498,24499,24500,24502,24504,24505,24506,24507,24510,
24511,24512,24513,24514,24519,24520,24522,24523,24526,24531,24532,24533,24538,
24539,24540,24542,24543,24546,24547,24549,24550,24552,24553,24556,24559,24560,
24562,24563,24564,24566,24567,24569,24570,24572,24583,24584,24585,24587,24588,
24592,24593,24595,24599,24600,24602,24606,24607,24610,24611,24612,24620,24621,
24622,24624,24625,24626,24627,24628,24630,24631,24632,24633,24634,24637,24638,
24640,24644,24645,24646,24647,24648,24649,24650,24652,24654,24655,24657,24659,
24660,24662,24663,24664,24667,24668,24670,24671,24672,24673,24677,24678,24686,
24689,24690,24692,24693,24695,24702,24704,24705,24706,24709,24710,24711,24712,
24714,24715,24718,24719,24720,24721,24723,24725,24727,24728,24729,24732,24734,
24737,24738,24740,24741,24743,24745,24746,24750,24752,24755,24757,24758,24759,
24761,24762,24765,24766,24767,24768,24769,24770,24771,24772,24775,24776,24777,
24780,24781,24782,24783,24784,24786,24787,24788,24790,24791,24793,24795,24798,
24801,24802,24803,24804,24805,24810,24817,24818,24821,24823,24824,24827,24828,
24829,24830,24831,24834,24835,24836,24837,24839,24842,24843,24844,24848,24849,
24850,24851,24852,24854,24855,24856,24857,24859,24860,24861,24862,24865,24866,
24869,24872,24873,24874,24876,24877,24878,24879,24880,24881,24882,24883,24884,
24885,24886,24887,24888,24889,24890,24891,24892,24893,24894,24896,24897,24898,
24899,24900,24901,24902,24903,24905,24907,24909,24911,24912,24914,24915,24916,
24918,24919,24920,24921,24922,24923,24924,24926,24927,24928,24929,24931,24932,
24933,24934,24937,24938,24939,24940,24941,24942,24943,
24945,24946,24947,24948,24950,24952,24953,24954,24955,24956,24957,24958,24959,
24960,24961,24962,24963,24964,24965,24966,24967,24968,24969,24970,24972,24973,
24975,24976,24977,24978,24979,24981,24982,24983,24984,24985,24986,24987,24988,
24990,24991,24992,24993,24994,24995,24996,24997,24998,25002,25003,25005,25006,
25007,25008,25009,25010,25011,25012,25013,25014,25016,25017,25018,25019,25020,
25021,25023,25024,25025,25027,25028,25029,25030,25031,25033,25036,25037,25038,
25039,25040,25043,25045,25046,25047,25048,25049,25050,25051,25052,25053,25054,
25055,25056,25057,25058,25059,25060,25061,25063,25064,25065,25066,25067,25068,
25069,25070,25071,25072,25073,25074,25075,25076,25078,25079,25080,25081,25082,
25083,25084,25085,25086,25088,25089,25090,25091,25092,25093,25095,25097,25107,
25108,25113,25116,25117,25118,25120,25123,25126,25127,25128,25129,25131,25133,
25135,25136,25137,25138,25141,25142,25144,25145,25146,25147,25148,25154,25156,
25157,25158,25162,25167,25168,25173,25174,25175,25177,25178,25180,25181,25182,
25183,25184,25185,25186,25188,25189,25192,25201,25202,25204,25205,25207,25208,
25210,25211,25213,25217,25218,25219,25221,25222,25223,25224,25227,25228,25229,
25230,25231,25232,25236,25241,25244,25245,25246,25251,25254,25255,25257,25258,
25261,25262,25263,25264,25266,25267,25268,25270,25271,25272,25274,25278,25280,
25281,25283,25291,25295,25297,25301,25309,25310,25312,25313,25316,25322,25323,
25328,25330,25333,25336,25337,25338,25339,25344,25347,25348,25349,25350,25354,
25355,25356,25357,25359,25360,25362,25363,25364,25365,
25367,25368,25369,25372,25382,25383,25385,25388,25389,25390,25392,25393,25395,
25396,25397,25398,25399,25400,25403,25404,25406,25407,25408,25409,25412,25415,
25416,25418,25425,25426,25427,25428,25430,25431,25432,25433,25434,25435,25436,
25437,25440,25444,25445,25446,25448,25450,25451,25452,25455,25456,25458,25459,
25460,25461,25464,25465,25468,25469,25470,25471,25473,25475,25476,25477,25478,
25483,25485,25489,25491,25492,25493,25495,25497,25498,25499,25500,25501,25502,
25503,25505,25508,25510,25515,25519,25521,25522,25525,25526,25529,25531,25533,
25535,25536,25537,25538,25539,25541,25543,25544,25546,25547,25548,25553,25555,
25556,25557,25559,25560,25561,25562,25563,25564,25565,25567,25570,25572,25573,
25574,25575,25576,25579,25580,25582,25583,25584,25585,25587,25589,25591,25593,
25594,25595,25596,25598,25603,25604,25606,25607,25608,25609,25610,25613,25614,
25617,25618,25621,25622,25623,25624,25625,25626,25629,25631,25634,25635,25636,
25637,25639,25640,25641,25643,25646,25647,25648,25649,25650,25651,25653,25654,
25655,25656,25657,25659,25660,25662,25664,25666,25667,25673,25675,25676,25677,
25678,25679,25680,25681,25683,25685,25686,25687,25689,25690,25691,25692,25693,
25695,25696,25697,25698,25699,25700,25701,25702,25704,25706,25707,25708,25710,
25711,25712,25713,25714,25715,25716,25717,25718,25719,25723,25724,25725,25726,
25727,25728,25729,25731,25734,25736,25737,25738,25739,25740,25741,25742,25743,
25744,25747,25748,25751,25752,25754,25755,25756,25757,25759,25760,25761,25762,
25763,25765,25766,25767,25768,25770,25771,25775,25777,
25778,25779,25780,25782,25785,25787,25789,25790,25791,25793,25795,25796,25798,
25799,25800,25801,25802,25803,25804,25807,25809,25811,25812,25813,25814,25817,
25818,25819,25820,25821,25823,25824,25825,25827,25829,25831,25832,25833,25834,
25835,25836,25837,25838,25839,25840,25841,25842,25843,25844,25845,25846,25847,
25848,25849,25850,25851,25852,25853,25854,25855,25857,25858,25859,25860,25861,
25862,25863,25864,25866,25867,25868,25869,25870,25871,25872,25873,25875,25876,
25877,25878,25879,25881,25882,25883,25884,25885,25886,25887,25888,25889,25890,
25891,25892,25894,25895,25896,25897,25898,25900,25901,25904,25905,25906,25907,
25911,25914,25916,25917,25920,25921,25922,25923,25924,25926,25927,25930,25931,
25933,25934,25936,25938,25939,25940,25943,25944,25946,25948,25951,25952,25953,
25956,25957,25959,25960,25961,25962,25965,25966,25967,25969,25971,25973,25974,
25976,25977,25978,25979,25980,25981,25982,25983,25984,25985,25986,25987,25988,
25989,25990,25992,25993,25994,25997,25998,25999,26002,26004,26005,26006,26008,
26010,26013,26014,26016,26018,26019,26022,26024,26026,26028,26030,26033,26034,
26035,26036,26037,26038,26039,26040,26042,26043,26046,26047,26048,26050,26055,
26056,26057,26058,26061,26064,26065,26067,26068,26069,26072,26073,26074,26075,
26076,26077,26078,26079,26081,26083,26084,26090,26091,26098,26099,26100,26101,
26104,26105,26107,26108,26109,26110,26111,26113,26116,26117,26119,26120,26121,
26123,26125,26128,26129,26130,26134,26135,26136,26138,26139,26140,26142,26145,
26146,26147,26148,26150,26153,26154,26155,26156,26158,
26160,26162,26163,26167,26168,26169,26170,26171,26173,26175,26176,26178,26180,
26181,26182,26183,26184,26185,26186,26189,26190,26192,26193,26200,26201,26203,
26204,26205,26206,26208,26210,26211,26213,26215,26217,26218,26219,26220,26221,
26225,26226,26227,26229,26232,26233,26235,26236,26237,26239,26240,26241,26243,
26245,26246,26248,26249,26250,26251,26253,26254,26255,26256,26258,26259,26260,
26261,26264,26265,26266,26267,26268,26270,26271,26272,26273,26274,26275,26276,
26277,26278,26281,26282,26283,26284,26285,26287,26288,26289,26290,26291,26293,
26294,26295,26296,26298,26299,26300,26301,26303,26304,26305,26306,26307,26308,
26309,26310,26311,26312,26313,26314,26315,26316,26317,26318,26319,26320,26321,
26322,26323,26324,26325,26326,26327,26328,26330,26334,26335,26336,26337,26338,
26339,26340,26341,26343,26344,26346,26347,26348,26349,26350,26351,26353,26357,
26358,26360,26362,26363,26365,26369,26370,26371,26372,26373,26374,26375,26380,
26382,26383,26385,26386,26387,26390,26392,26393,26394,26396,26398,26400,26401,
26402,26403,26404,26405,26407,26409,26414,26416,26418,26419,26422,26423,26424,
26425,26427,26428,26430,26431,26433,26436,26437,26439,26442,26443,26445,26450,
26452,26453,26455,26456,26457,26458,26459,26461,26466,26467,26468,26470,26471,
26475,26476,26478,26481,26484,26486,26488,26489,26490,26491,26493,26496,26498,
26499,26501,26502,26504,26506,26508,26509,26510,26511,26513,26514,26515,26516,
26518,26521,26523,26527,26528,26529,26532,26534,26537,26540,26542,26545,26546,
26548,26553,26554,26555,26556,26557,26558,26559,26560,
26562,26565,26566,26567,26568,26569,26570,26571,26572,26573,26574,26581,26582,
26583,26587,26591,26593,26595,26596,26598,26599,26600,26602,26603,26605,26606,
26610,26613,26614,26615,26616,26617,26618,26619,26620,26622,26625,26626,26627,
26628,26630,26637,26640,26642,26644,26645,26648,26649,26650,26651,26652,26654,
26655,26656,26658,26659,26660,26661,26662,26663,26664,26667,26668,26669,26670,
26671,26672,26673,26676,26677,26678,26682,26683,26687,26695,26699,26701,26703,
26706,26710,26711,26712,26713,26714,26715,26716,26717,26718,26719,26730,26732,
26733,26734,26735,26736,26737,26738,26739,26741,26744,26745,26746,26747,26748,
26749,26750,26751,26752,26754,26756,26759,26760,26761,26762,26763,26764,26765,
26766,26768,26769,26770,26772,26773,26774,26776,26777,26778,26779,26780,26781,
26782,26783,26784,26785,26787,26788,26789,26793,26794,26795,26796,26798,26801,
26802,26804,26806,26807,26808,26809,26810,26811,26812,26813,26814,26815,26817,
26819,26820,26821,26822,26823,26824,26826,26828,26830,26831,26832,26833,26835,
26836,26838,26839,26841,26843,26844,26845,26846,26847,26849,26850,26852,26853,
26854,26855,26856,26857,26858,26859,26860,26861,26863,26866,26867,26868,26870,
26871,26872,26875,26877,26878,26879,26880,26882,26883,26884,26886,26887,26888,
26889,26890,26892,26895,26897,26899,26900,26901,26902,26903,26904,26905,26906,
26907,26908,26909,26910,26913,26914,26915,26917,26918,26919,26920,26921,26922,
26923,26924,26926,26927,26929,26930,26931,26933,26934,26935,26936,26938,26939,
26940,26942,26944,26945,26947,26948,26949,26950,26951,
26952,26953,26954,26955,26956,26957,26958,26959,26960,26961,26962,26963,26965,
26966,26968,26969,26971,26972,26975,26977,26978,26980,26981,26983,26984,26985,
26986,26988,26989,26991,26992,26994,26995,26996,26997,26998,27002,27003,27005,
27006,27007,27009,27011,27013,27018,27019,27020,27022,27023,27024,27025,27026,
27027,27030,27031,27033,27034,27037,27038,27039,27040,27041,27042,27043,27044,
27045,27046,27049,27050,27052,27054,27055,27056,27058,27059,27061,27062,27064,
27065,27066,27068,27069,27070,27071,27072,27074,27075,27076,27077,27078,27079,
27080,27081,27083,27085,27087,27089,27090,27091,27093,27094,27095,27096,27097,
27098,27100,27101,27102,27105,27106,27107,27108,27109,27110,27111,27112,27113,
27114,27115,27116,27118,27119,27120,27121,27123,27124,27125,27126,27127,27128,
27129,27130,27131,27132,27134,27136,27137,27138,27139,27140,27141,27142,27143,
27144,27145,27147,27148,27149,27150,27151,27152,27153,27154,27155,27156,27157,
27158,27161,27162,27163,27164,27165,27166,27168,27170,27171,27172,27173,27174,
27175,27177,27179,27180,27181,27182,27184,27186,27187,27188,27190,27191,27192,
27193,27194,27195,27196,27199,27200,27201,27202,27203,27205,27206,27208,27209,
27210,27211,27212,27213,27214,27215,27217,27218,27219,27220,27221,27222,27223,
27226,27228,27229,27230,27231,27232,27234,27235,27236,27238,27239,27240,27241,
27242,27243,27244,27245,27246,27247,27248,27250,27251,27252,27253,27254,27255,
27256,27258,27259,27261,27262,27263,27265,27266,27267,27269,27270,27271,27272,
27273,27274,27275,27276,27277,27279,27282,27283,27284,
27285,27286,27288,27289,27290,27291,27292,27293,27294,27295,27297,27298,27299,
27300,27301,27302,27303,27304,27306,27309,27310,27311,27312,27313,27314,27315,
27316,27317,27318,27319,27320,27321,27322,27323,27324,27325,27326,27327,27328,
27329,27330,27331,27332,27333,27334,27335,27336,27337,27338,27339,27340,27341,
27342,27343,27344,27345,27346,27347,27348,27349,27350,27351,27352,27353,27354,
27355,27356,27357,27358,27359,27360,27361,27362,27363,27364,27365,27366,27367,
27368,27369,27370,27371,27372,27373,27374,27375,27376,27377,27378,27379,27380,
27381,27382,27383,27384,27385,27386,27387,27388,27389,27390,27391,27392,27393,
27394,27395,27396,27397,27398,27399,27400,27401,27402,27403,27404,27405,27406,
27407,27408,27409,27410,27411,27412,27413,27414,27415,27416,27417,27418,27419,
27420,27421,27422,27423,27429,27430,27432,27433,27434,27435,27436,27437,27438,
27439,27440,27441,27443,27444,27445,27446,27448,27451,27452,27453,27455,27456,
27457,27458,27460,27461,27464,27466,27467,27469,27470,27471,27472,27473,27474,
27475,27476,27477,27478,27479,27480,27482,27483,27484,27485,27486,27487,27488,
27489,27496,27497,27499,27500,27501,27502,27503,27504,27505,27506,27507,27508,
27509,27510,27511,27512,27514,27517,27518,27519,27520,27525,27528,27532,27534,
27535,27536,27537,27540,27541,27543,27544,27545,27548,27549,27550,27551,27552,
27554,27555,27556,27557,27558,27559,27560,27561,27563,27564,27565,27566,27567,
27568,27569,27570,27574,27576,27577,27578,27579,27580,27581,27582,27584,27587,
27588,27590,27591,27592,27593,27594,27596,27598,27600,
27601,27608,27610,27612,27613,27614,27615,27616,27618,27619,27620,27621,27622,
27623,27624,27625,27628,27629,27630,27632,27633,27634,27636,27638,27639,27640,
27642,27643,27644,27646,27647,27648,27649,27650,27651,27652,27656,27657,27658,
27659,27660,27662,27666,27671,27676,27677,27678,27680,27683,27685,27691,27692,
27693,27697,27699,27702,27703,27705,27706,27707,27708,27710,27711,27715,27716,
27717,27720,27723,27724,27725,27726,27727,27729,27730,27731,27734,27736,27737,
27738,27746,27747,27749,27750,27751,27755,27756,27757,27758,27759,27761,27763,
27765,27767,27768,27770,27771,27772,27775,27776,27780,27783,27786,27787,27789,
27790,27793,27794,27797,27798,27799,27800,27802,27804,27805,27806,27808,27810,
27816,27820,27823,27824,27828,27829,27830,27831,27834,27840,27841,27842,27843,
27846,27847,27848,27851,27853,27854,27855,27857,27858,27864,27865,27866,27868,
27869,27871,27876,27878,27879,27881,27884,27885,27890,27892,27897,27903,27904,
27906,27907,27909,27910,27912,27913,27914,27917,27919,27920,27921,27923,27924,
27925,27926,27928,27932,27933,27935,27936,27937,27938,27939,27940,27942,27944,
27945,27948,27949,27951,27952,27956,27958,27959,27960,27962,27967,27968,27970,
27972,27977,27980,27984,27989,27990,27991,27992,27995,27997,27999,28001,28002,
28004,28005,28007,28008,28011,28012,28013,28016,28017,28018,28019,28021,28022,
28025,28026,28027,28029,28030,28031,28032,28033,28035,28036,28038,28039,28042,
28043,28045,28047,28048,28050,28054,28055,28056,28057,28058,28060,28066,28069,
28076,28077,28080,28081,28083,28084,28086,28087,28089,
28090,28091,28092,28093,28094,28097,28098,28099,28104,28105,28106,28109,28110,
28111,28112,28114,28115,28116,28117,28119,28122,28123,28124,28127,28130,28131,
28133,28135,28136,28137,28138,28141,28143,28144,28146,28148,28149,28150,28152,
28154,28157,28158,28159,28160,28161,28162,28163,28164,28166,28167,28168,28169,
28171,28175,28178,28179,28181,28184,28185,28187,28188,28190,28191,28194,28198,
28199,28200,28202,28204,28206,28208,28209,28211,28213,28214,28215,28217,28219,
28220,28221,28222,28223,28224,28225,28226,28229,28230,28231,28232,28233,28234,
28235,28236,28239,28240,28241,28242,28245,28247,28249,28250,28252,28253,28254,
28256,28257,28258,28259,28260,28261,28262,28263,28264,28265,28266,28268,28269,
28271,28272,28273,28274,28275,28276,28277,28278,28279,28280,28281,28282,28283,
28284,28285,28288,28289,28290,28292,28295,28296,28298,28299,28300,28301,28302,
28305,28306,28307,28308,28309,28310,28311,28313,28314,28315,28317,28318,28320,
28321,28323,28324,28326,28328,28329,28331,28332,28333,28334,28336,28339,28341,
28344,28345,28348,28350,28351,28352,28355,28356,28357,28358,28360,28361,28362,
28364,28365,28366,28368,28370,28374,28376,28377,28379,28380,28381,28387,28391,
28394,28395,28396,28397,28398,28399,28400,28401,28402,28403,28405,28406,28407,
28408,28410,28411,28412,28413,28414,28415,28416,28417,28419,28420,28421,28423,
28424,28426,28427,28428,28429,28430,28432,28433,28434,28438,28439,28440,28441,
28442,28443,28444,28445,28446,28447,28449,28450,28451,28453,28454,28455,28456,
28460,28462,28464,28466,28468,28469,28471,28472,28473,
28474,28475,28476,28477,28479,28480,28481,28482,28483,28484,28485,28488,28489,
28490,28492,28494,28495,28496,28497,28498,28499,28500,28501,28502,28503,28505,
28506,28507,28509,28511,28512,28513,28515,28516,28517,28519,28520,28521,28522,
28523,28524,28527,28528,28529,28531,28533,28534,28535,28537,28539,28541,28542,
28543,28544,28545,28546,28547,28549,28550,28551,28554,28555,28559,28560,28561,
28562,28563,28564,28565,28566,28567,28568,28569,28570,28571,28573,28574,28575,
28576,28578,28579,28580,28581,28582,28584,28585,28586,28587,28588,28589,28590,
28591,28592,28593,28594,28596,28597,28599,28600,28602,28603,28604,28605,28606,
28607,28609,28611,28612,28613,28614,28615,28616,28618,28619,28620,28621,28622,
28623,28624,28627,28628,28629,28630,28631,28632,28633,28634,28635,28636,28637,
28639,28642,28643,28644,28645,28646,28647,28648,28649,28650,28651,28652,28653,
28656,28657,28658,28659,28660,28661,28662,28663,28664,28665,28666,28667,28668,
28669,28670,28671,28672,28673,28674,28675,28676,28677,28678,28679,28680,28681,
28682,28683,28684,28685,28686,28687,28688,28690,28691,28692,28693,28694,28695,
28696,28697,28700,28701,28702,28703,28704,28705,28706,28708,28709,28710,28711,
28712,28713,28714,28715,28716,28717,28718,28719,28720,28721,28722,28723,28724,
28726,28727,28728,28730,28731,28732,28733,28734,28735,28736,28737,28738,28739,
28740,28741,28742,28743,28744,28745,28746,28747,28749,28750,28752,28753,28754,
28755,28756,28757,28758,28759,28760,28761,28762,28763,28764,28765,28767,28768,
28769,28770,28771,28772,28773,28774,28775,28776,28777,
28778,28782,28785,28786,28787,28788,28791,28793,28794,28795,28797,28801,28802,
28803,28804,28806,28807,28808,28811,28812,28813,28815,28816,28817,28819,28823,
28824,28826,28827,28830,28831,28832,28833,28834,28835,28836,28837,28838,28839,
28840,28841,28842,28848,28850,28852,28853,28854,28858,28862,28863,28868,28869,
28870,28871,28873,28875,28876,28877,28878,28879,28880,28881,28882,28883,28884,
28885,28886,28887,28890,28892,28893,28894,28896,28897,28898,28899,28901,28906,
28910,28912,28913,28914,28915,28916,28917,28918,28920,28922,28923,28924,28926,
28927,28928,28929,28930,28931,28932,28933,28934,28935,28936,28939,28940,28941,
28942,28943,28945,28946,28948,28951,28955,28956,28957,28958,28959,28960,28961,
28962,28963,28964,28965,28967,28968,28969,28970,28971,28972,28973,28974,28978,
28979,28980,28981,28983,28984,28985,28986,28987,28988,28989,28990,28991,28992,
28993,28994,28995,28996,28998,28999,29000,29001,29003,29005,29007,29008,29009,
29010,29011,29012,29013,29014,29015,29016,29017,29018,29019,29021,29023,29024,
29025,29026,29027,29029,29033,29034,29035,29036,29037,29039,29040,29041,29044,
29045,29046,29047,29049,29051,29052,29054,29055,29056,29057,29058,29059,29061,
29062,29063,29064,29065,29067,29068,29069,29070,29072,29073,29074,29075,29077,
29078,29079,29082,29083,29084,29085,29086,29089,29090,29091,29092,29093,29094,
29095,29097,29098,29099,29101,29102,29103,29104,29105,29106,29108,29110,29111,
29112,29114,29115,29116,29117,29118,29119,29120,29121,29122,29124,29125,29126,
29127,29128,29129,29130,29131,29132,29133,29135,29136,
29137,29138,29139,29142,29143,29144,29145,29146,29147,29148,29149,29150,29151,
29153,29154,29155,29156,29158,29160,29161,29162,29163,29164,29165,29167,29168,
29169,29170,29171,29172,29173,29174,29175,29176,29178,29179,29180,29181,29182,
29183,29184,29185,29186,29187,29188,29189,29191,29192,29193,29194,29195,29196,
29197,29198,29199,29200,29201,29202,29203,29204,29205,29206,29207,29208,29209,
29210,29211,29212,29214,29215,29216,29217,29218,29219,29220,29221,29222,29223,
29225,29227,29229,29230,29231,29234,29235,29236,29242,29244,29246,29248,29249,
29250,29251,29252,29253,29254,29257,29258,29259,29262,29263,29264,29265,29267,
29268,29269,29271,29272,29274,29276,29278,29280,29283,29284,29285,29288,29290,
29291,29292,29293,29296,29297,29299,29300,29302,29303,29304,29307,29308,29309,
29314,29315,29317,29318,29319,29320,29321,29324,29326,29328,29329,29331,29332,
29333,29334,29335,29336,29337,29338,29339,29340,29341,29342,29344,29345,29346,
29347,29348,29349,29350,29351,29352,29353,29354,29355,29358,29361,29362,29363,
29365,29370,29371,29372,29373,29374,29375,29376,29381,29382,29383,29385,29386,
29387,29388,29391,29393,29395,29396,29397,29398,29400,29402,29403,58566,58567,
58568,58569,58570,58571,58572,58573,58574,58575,58576,58577,58578,58579,58580,
58581,58582,58583,58584,58585,58586,58587,58588,58589,58590,58591,58592,58593,
58594,58595,58596,58597,58598,58599,58600,58601,58602,58603,58604,58605,58606,
58607,58608,58609,58610,58611,58612,58613,58614,58615,58616,58617,58618,58619,
58620,58621,58622,58623,58624,58625,58626,58627,58628,
58629,58630,58631,58632,58633,58634,58635,58636,58637,58638,58639,58640,58641,
58642,58643,58644,58645,58646,58647,58648,58649,58650,58651,58652,58653,58654,
58655,58656,58657,58658,58659,58660,58661,12288,12289,12290,183,713,711,168,
12291,12293,8212,65374,8214,8230,8216,8217,8220,8221,12308,12309,12296,12297,
12298,12299,12300,12301,12302,12303,12310,12311,12304,12305,177,215,247,8758,
8743,8744,8721,8719,8746,8745,8712,8759,8730,8869,8741,8736,8978,8857,8747,
8750,8801,8780,8776,8765,8733,8800,8814,8815,8804,8805,8734,8757,8756,9794,
9792,176,8242,8243,8451,65284,164,65504,65505,8240,167,8470,9734,9733,9675,
9679,9678,9671,9670,9633,9632,9651,9650,8251,8594,8592,8593,8595,12307,58662,
58663,58664,58665,58666,58667,58668,58669,58670,58671,58672,58673,58674,58675,
58676,58677,58678,58679,58680,58681,58682,58683,58684,58685,58686,58687,58688,
58689,58690,58691,58692,58693,58694,58695,58696,58697,58698,58699,58700,58701,
58702,58703,58704,58705,58706,58707,58708,58709,58710,58711,58712,58713,58714,
58715,58716,58717,58718,58719,58720,58721,58722,58723,58724,58725,58726,58727,
58728,58729,58730,58731,58732,58733,58734,58735,58736,58737,58738,58739,58740,
58741,58742,58743,58744,58745,58746,58747,58748,58749,58750,58751,58752,58753,
58754,58755,58756,58757,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,
59238,59239,59240,59241,59242,59243,9352,9353,9354,9355,9356,9357,9358,9359,
9360,9361,9362,9363,9364,9365,9366,9367,9368,
9369,9370,9371,9332,9333,9334,9335,9336,9337,9338,9339,9340,9341,9342,9343,
9344,9345,9346,9347,9348,9349,9350,9351,9312,9313,9314,9315,9316,9317,9318,
9319,9320,9321,8364,59245,12832,12833,12834,12835,12836,12837,12838,12839,
12840,12841,59246,59247,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,
8554,8555,59248,59249,58758,58759,58760,58761,58762,58763,58764,58765,58766,
58767,58768,58769,58770,58771,58772,58773,58774,58775,58776,58777,58778,58779,
58780,58781,58782,58783,58784,58785,58786,58787,58788,58789,58790,58791,58792,
58793,58794,58795,58796,58797,58798,58799,58800,58801,58802,58803,58804,58805,
58806,58807,58808,58809,58810,58811,58812,58813,58814,58815,58816,58817,58818,
58819,58820,58821,58822,58823,58824,58825,58826,58827,58828,58829,58830,58831,
58832,58833,58834,58835,58836,58837,58838,58839,58840,58841,58842,58843,58844,
58845,58846,58847,58848,58849,58850,58851,58852,58853,65281,65282,65283,65509,
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,65340,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,58854,
58855,58856,58857,58858,
58859,58860,58861,58862,58863,58864,58865,58866,58867,58868,58869,58870,58871,
58872,58873,58874,58875,58876,58877,58878,58879,58880,58881,58882,58883,58884,
58885,58886,58887,58888,58889,58890,58891,58892,58893,58894,58895,58896,58897,
58898,58899,58900,58901,58902,58903,58904,58905,58906,58907,58908,58909,58910,
58911,58912,58913,58914,58915,58916,58917,58918,58919,58920,58921,58922,58923,
58924,58925,58926,58927,58928,58929,58930,58931,58932,58933,58934,58935,58936,
58937,58938,58939,58940,58941,58942,58943,58944,58945,58946,58947,58948,58949,
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,59250,59251,59252,59253,59254,59255,59256,59257,
59258,59259,59260,58950,58951,58952,58953,58954,58955,58956,58957,58958,58959,
58960,58961,58962,58963,58964,58965,58966,58967,58968,58969,58970,58971,58972,
58973,58974,58975,58976,58977,58978,58979,58980,58981,58982,58983,58984,58985,
58986,58987,58988,58989,58990,58991,58992,58993,58994,58995,58996,58997,58998,
58999,59000,59001,59002,59003,59004,59005,59006,59007,59008,59009,59010,59011,
59012,59013,59014,59015,59016,59017,59018,59019,59020,
59021,59022,59023,59024,59025,59026,59027,59028,59029,59030,59031,59032,59033,
59034,59035,59036,59037,59038,59039,59040,59041,59042,59043,59044,59045,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,59261,59262,59263,59264,59265,59266,
59267,59268,59046,59047,59048,59049,59050,59051,59052,59053,59054,59055,59056,
59057,59058,59059,59060,59061,59062,59063,59064,59065,59066,59067,59068,59069,
59070,59071,59072,59073,59074,59075,59076,59077,59078,59079,59080,59081,59082,
59083,59084,59085,59086,59087,59088,59089,59090,59091,59092,59093,59094,59095,
59096,59097,59098,59099,59100,59101,59102,59103,59104,59105,59106,59107,59108,
59109,59110,59111,59112,59113,59114,59115,59116,59117,59118,59119,59120,59121,
59122,59123,59124,59125,59126,59127,59128,59129,59130,59131,59132,59133,59134,
59135,59136,59137,59138,59139,59140,59141,913,914,915,916,917,918,919,920,921,
922,923,924,925,926,927,928,929,931,932,933,934,935,936,937,59269,59270,59271,
59272,59273,59274,59275,59276,945,946,947,948,949,950,951,952,953,
954,955,956,957,958,959,960,961,963,964,965,966,967,968,969,59277,59278,59279,
59280,59281,59282,59283,65077,65078,65081,65082,65087,65088,65085,65086,65089,
65090,65091,65092,59284,59285,65083,65084,65079,65080,65073,59286,65075,65076,
59287,59288,59289,59290,59291,59292,59293,59294,59295,59142,59143,59144,59145,
59146,59147,59148,59149,59150,59151,59152,59153,59154,59155,59156,59157,59158,
59159,59160,59161,59162,59163,59164,59165,59166,59167,59168,59169,59170,59171,
59172,59173,59174,59175,59176,59177,59178,59179,59180,59181,59182,59183,59184,
59185,59186,59187,59188,59189,59190,59191,59192,59193,59194,59195,59196,59197,
59198,59199,59200,59201,59202,59203,59204,59205,59206,59207,59208,59209,59210,
59211,59212,59213,59214,59215,59216,59217,59218,59219,59220,59221,59222,59223,
59224,59225,59226,59227,59228,59229,59230,59231,59232,59233,59234,59235,59236,
59237,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,59296,59297,59298,59299,59300,59301,59302,59303,59304,
59305,59306,59307,59308,59309,59310,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,59311,59312,59313,59314,
59315,59316,59317,59318,59319,59320,59321,59322,59323,714,715,729,8211,8213,
8229,8245,8453,8457,8598,8599,8600,8601,
8725,8735,8739,8786,8806,8807,8895,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,9581,9582,9583,9584,9585,9586,9587,9601,9602,
9603,9604,9605,9606,9607,9608,9609,9610,9611,9612,9613,9614,9615,9619,9620,
9621,9660,9661,9698,9699,9700,9701,9737,8853,12306,12317,12318,59324,59325,
59326,59327,59328,59329,59330,59331,59332,59333,59334,257,225,462,224,275,233,
283,232,299,237,464,236,333,243,466,242,363,250,468,249,470,472,474,476,252,
234,593,59335,324,328,505,609,59337,59338,59339,59340,12549,12550,12551,12552,
12553,12554,12555,12556,12557,12558,12559,12560,12561,12562,12563,12564,12565,
12566,12567,12568,12569,12570,12571,12572,12573,12574,12575,12576,12577,12578,
12579,12580,12581,12582,12583,12584,12585,59341,59342,59343,59344,59345,59346,
59347,59348,59349,59350,59351,59352,59353,59354,59355,59356,59357,59358,59359,
59360,59361,12321,12322,12323,12324,12325,12326,12327,12328,12329,12963,13198,
13199,13212,13213,13214,13217,13252,13262,13265,13266,13269,65072,65506,65508,
59362,8481,12849,59363,8208,59364,59365,59366,12540,12443,12444,12541,12542,
12294,12445,12446,65097,65098,65099,65100,65101,65102,65103,65104,65105,65106,
65108,65109,65110,65111,65113,65114,65115,65116,65117,65118,65119,65120,65121,
65122,65123,65124,65125,65126,65128,65129,65130,65131,12350,12272,12273,12274,
12275,12276,12277,
12278,12279,12280,12281,12282,12283,12295,59380,59381,59382,59383,59384,59385,
59386,59387,59388,59389,59390,59391,59392,9472,9473,9474,9475,9476,9477,9478,
9479,9480,9481,9482,9483,9484,9485,9486,9487,9488,9489,9490,9491,9492,9493,
9494,9495,9496,9497,9498,9499,9500,9501,9502,9503,9504,9505,9506,9507,9508,
9509,9510,9511,9512,9513,9514,9515,9516,9517,9518,9519,9520,9521,9522,9523,
9524,9525,9526,9527,9528,9529,9530,9531,9532,9533,9534,9535,9536,9537,9538,
9539,9540,9541,9542,9543,9544,9545,9546,9547,59393,59394,59395,59396,59397,
59398,59399,59400,59401,59402,59403,59404,59405,59406,59407,29404,29405,29407,
29410,29411,29412,29413,29414,29415,29418,29419,29429,29430,29433,29437,29438,
29439,29440,29442,29444,29445,29446,29447,29448,29449,29451,29452,29453,29455,
29456,29457,29458,29460,29464,29465,29466,29471,29472,29475,29476,29478,29479,
29480,29485,29487,29488,29490,29491,29493,29494,29498,29499,29500,29501,29504,
29505,29506,29507,29508,29509,29510,29511,29512,29513,29514,29515,29516,29518,
29519,29521,29523,29524,29525,29526,29528,29529,29530,29531,29532,29533,29534,
29535,29537,29538,29539,29540,29541,29542,29543,29544,29545,29546,29547,29550,
29552,29553,57344,57345,57346,57347,57348,57349,57350,57351,57352,57353,57354,
57355,57356,57357,57358,57359,57360,57361,57362,57363,57364,57365,57366,57367,
57368,57369,57370,57371,57372,57373,57374,57375,57376,57377,57378,57379,57380,
57381,57382,57383,57384,57385,57386,57387,57388,57389,57390,57391,57392,
57393,57394,57395,57396,57397,57398,57399,57400,57401,57402,57403,57404,57405,
57406,57407,57408,57409,57410,57411,57412,57413,57414,57415,57416,57417,57418,
57419,57420,57421,57422,57423,57424,57425,57426,57427,57428,57429,57430,57431,
57432,57433,57434,57435,57436,57437,29554,29555,29556,29557,29558,29559,29560,
29561,29562,29563,29564,29565,29567,29568,29569,29570,29571,29573,29574,29576,
29578,29580,29581,29583,29584,29586,29587,29588,29589,29591,29592,29593,29594,
29596,29597,29598,29600,29601,29603,29604,29605,29606,29607,29608,29610,29612,
29613,29617,29620,29621,29622,29624,29625,29628,29629,29630,29631,29633,29635,
29636,29637,29638,29639,29643,29644,29646,29650,29651,29652,29653,29654,29655,
29656,29658,29659,29660,29661,29663,29665,29666,29667,29668,29670,29672,29674,
29675,29676,29678,29679,29680,29681,29683,29684,29685,29686,29687,57438,57439,
57440,57441,57442,57443,57444,57445,57446,57447,57448,57449,57450,57451,57452,
57453,57454,57455,57456,57457,57458,57459,57460,57461,57462,57463,57464,57465,
57466,57467,57468,57469,57470,57471,57472,57473,57474,57475,57476,57477,57478,
57479,57480,57481,57482,57483,57484,57485,57486,57487,57488,57489,57490,57491,
57492,57493,57494,57495,57496,57497,57498,57499,57500,57501,57502,57503,57504,
57505,57506,57507,57508,57509,57510,57511,57512,57513,57514,57515,57516,57517,
57518,57519,57520,57521,57522,57523,57524,57525,57526,57527,57528,57529,57530,
57531,29688,29689,29690,29691,29692,29693,29694,29695,29696,29697,29698,29700,
29703,29704,29707,29708,29709,29710,29713,29714,29715,
29716,29717,29718,29719,29720,29721,29724,29725,29726,29727,29728,29729,29731,
29732,29735,29737,29739,29741,29743,29745,29746,29751,29752,29753,29754,29755,
29757,29758,29759,29760,29762,29763,29764,29765,29766,29767,29768,29769,29770,
29771,29772,29773,29774,29775,29776,29777,29778,29779,29780,29782,29784,29789,
29792,29793,29794,29795,29796,29797,29798,29799,29800,29801,29802,29803,29804,
29806,29807,29809,29810,29811,29812,29813,29816,29817,29818,57532,57533,57534,
57535,57536,57537,57538,57539,57540,57541,57542,57543,57544,57545,57546,57547,
57548,57549,57550,57551,57552,57553,57554,57555,57556,57557,57558,57559,57560,
57561,57562,57563,57564,57565,57566,57567,57568,57569,57570,57571,57572,57573,
57574,57575,57576,57577,57578,57579,57580,57581,57582,57583,57584,57585,57586,
57587,57588,57589,57590,57591,57592,57593,57594,57595,57596,57597,57598,57599,
57600,57601,57602,57603,57604,57605,57606,57607,57608,57609,57610,57611,57612,
57613,57614,57615,57616,57617,57618,57619,57620,57621,57622,57623,57624,57625,
29819,29820,29821,29823,29826,29828,29829,29830,29832,29833,29834,29836,29837,
29839,29841,29842,29843,29844,29845,29846,29847,29848,29849,29850,29851,29853,
29855,29856,29857,29858,29859,29860,29861,29862,29866,29867,29868,29869,29870,
29871,29872,29873,29874,29875,29876,29877,29878,29879,29880,29881,29883,29884,
29885,29886,29887,29888,29889,29890,29891,29892,29893,29894,29895,29896,29897,
29898,29899,29900,29901,29902,29903,29904,29905,29907,29908,29909,29910,29911,
29912,29913,29914,29915,29917,29919,29921,29925,29927,
29928,29929,29930,29931,29932,29933,29936,29937,29938,57626,57627,57628,57629,
57630,57631,57632,57633,57634,57635,57636,57637,57638,57639,57640,57641,57642,
57643,57644,57645,57646,57647,57648,57649,57650,57651,57652,57653,57654,57655,
57656,57657,57658,57659,57660,57661,57662,57663,57664,57665,57666,57667,57668,
57669,57670,57671,57672,57673,57674,57675,57676,57677,57678,57679,57680,57681,
57682,57683,57684,57685,57686,57687,57688,57689,57690,57691,57692,57693,57694,
57695,57696,57697,57698,57699,57700,57701,57702,57703,57704,57705,57706,57707,
57708,57709,57710,57711,57712,57713,57714,57715,57716,57717,57718,57719,29939,
29941,29944,29945,29946,29947,29948,29949,29950,29952,29953,29954,29955,29957,
29958,29959,29960,29961,29962,29963,29964,29966,29968,29970,29972,29973,29974,
29975,29979,29981,29982,29984,29985,29986,29987,29988,29990,29991,29994,29998,
30004,30006,30009,30012,30013,30015,30017,30018,30019,30020,30022,30023,30025,
30026,30029,30032,30033,30034,30035,30037,30038,30039,30040,30045,30046,30047,
30048,30049,30050,30051,30052,30055,30056,30057,30059,30060,30061,30062,30063,
30064,30065,30067,30069,30070,30071,30074,30075,30076,30077,30078,30080,30081,
30082,30084,30085,30087,57720,57721,57722,57723,57724,57725,57726,57727,57728,
57729,57730,57731,57732,57733,57734,57735,57736,57737,57738,57739,57740,57741,
57742,57743,57744,57745,57746,57747,57748,57749,57750,57751,57752,57753,57754,
57755,57756,57757,57758,57759,57760,57761,57762,57763,57764,57765,57766,57767,
57768,57769,57770,57771,57772,57773,57774,57775,57776,
57777,57778,57779,57780,57781,57782,57783,57784,57785,57786,57787,57788,57789,
57790,57791,57792,57793,57794,57795,57796,57797,57798,57799,57800,57801,57802,
57803,57804,57805,57806,57807,57808,57809,57810,57811,57812,57813,30088,30089,
30090,30092,30093,30094,30096,30099,30101,30104,30107,30108,30110,30114,30118,
30119,30120,30121,30122,30125,30134,30135,30138,30139,30143,30144,30145,30150,
30155,30156,30158,30159,30160,30161,30163,30167,30169,30170,30172,30173,30175,
30176,30177,30181,30185,30188,30189,30190,30191,30194,30195,30197,30198,30199,
30200,30202,30203,30205,30206,30210,30212,30214,30215,30216,30217,30219,30221,
30222,30223,30225,30226,30227,30228,30230,30234,30236,30237,30238,30241,30243,
30247,30248,30252,30254,30255,30257,30258,30262,30263,30265,30266,30267,30269,
30273,30274,30276,57814,57815,57816,57817,57818,57819,57820,57821,57822,57823,
57824,57825,57826,57827,57828,57829,57830,57831,57832,57833,57834,57835,57836,
57837,57838,57839,57840,57841,57842,57843,57844,57845,57846,57847,57848,57849,
57850,57851,57852,57853,57854,57855,57856,57857,57858,57859,57860,57861,57862,
57863,57864,57865,57866,57867,57868,57869,57870,57871,57872,57873,57874,57875,
57876,57877,57878,57879,57880,57881,57882,57883,57884,57885,57886,57887,57888,
57889,57890,57891,57892,57893,57894,57895,57896,57897,57898,57899,57900,57901,
57902,57903,57904,57905,57906,57907,30277,30278,30279,30280,30281,30282,30283,
30286,30287,30288,30289,30290,30291,30293,30295,30296,30297,30298,30299,30301,
30303,30304,30305,30306,30308,30309,30310,30311,30312,
30313,30314,30316,30317,30318,30320,30321,30322,30323,30324,30325,30326,30327,
30329,30330,30332,30335,30336,30337,30339,30341,30345,30346,30348,30349,30351,
30352,30354,30356,30357,30359,30360,30362,30363,30364,30365,30366,30367,30368,
30369,30370,30371,30373,30374,30375,30376,30377,30378,30379,30380,30381,30383,
30384,30387,30389,30390,30391,30392,30393,30394,30395,30396,30397,30398,30400,
30401,30403,21834,38463,22467,25384,21710,21769,21696,30353,30284,34108,30702,
33406,30861,29233,38552,38797,27688,23433,20474,25353,26263,23736,33018,26696,
32942,26114,30414,20985,25942,29100,32753,34948,20658,22885,25034,28595,33453,
25420,25170,21485,21543,31494,20843,30116,24052,25300,36299,38774,25226,32793,
22365,38712,32610,29240,30333,26575,30334,25670,20336,36133,25308,31255,26001,
29677,25644,25203,33324,39041,26495,29256,25198,25292,20276,29923,21322,21150,
32458,37030,24110,26758,27036,33152,32465,26834,30917,34444,38225,20621,35876,
33502,32990,21253,35090,21093,30404,30407,30409,30411,30412,30419,30421,30425,
30426,30428,30429,30430,30432,30433,30434,30435,30436,30438,30439,30440,30441,
30442,30443,30444,30445,30448,30451,30453,30454,30455,30458,30459,30461,30463,
30464,30466,30467,30469,30470,30474,30476,30478,30479,30480,30481,30482,30483,
30484,30485,30486,30487,30488,30491,30492,30493,30494,30497,30499,30500,30501,
30503,30506,30507,30508,30510,30512,30513,30514,30515,30516,30521,30523,30525,
30526,30527,30530,30532,30533,30534,30536,30537,30538,30539,30540,30541,30542,
30543,30546,30547,30548,30549,30550,30551,30552,30553,
30556,34180,38649,20445,22561,39281,23453,25265,25253,26292,35961,40077,29190,
26479,30865,24754,21329,21271,36744,32972,36125,38049,20493,29384,22791,24811,
28953,34987,22868,33519,26412,31528,23849,32503,29997,27893,36454,36856,36924,
40763,27604,37145,31508,24444,30887,34006,34109,27605,27609,27606,24065,24199,
30201,38381,25949,24330,24517,36767,22721,33218,36991,38491,38829,36793,32534,
36140,25153,20415,21464,21342,36776,36777,36779,36941,26631,24426,33176,34920,
40150,24971,21035,30250,24428,25996,28626,28392,23486,25672,20853,20912,26564,
19993,31177,39292,28851,30557,30558,30559,30560,30564,30567,30569,30570,30573,
30574,30575,30576,30577,30578,30579,30580,30581,30582,30583,30584,30586,30587,
30588,30593,30594,30595,30598,30599,30600,30601,30602,30603,30607,30608,30611,
30612,30613,30614,30615,30616,30617,30618,30619,30620,30621,30622,30625,30627,
30628,30630,30632,30635,30637,30638,30639,30641,30642,30644,30646,30647,30648,
30649,30650,30652,30654,30656,30657,30658,30659,30660,30661,30662,30663,30664,
30665,30666,30667,30668,30670,30671,30672,30673,30674,30675,30676,30677,30678,
30680,30681,30682,30685,30686,30687,30688,30689,30692,30149,24182,29627,33760,
25773,25320,38069,27874,21338,21187,25615,38082,31636,20271,24091,33334,33046,
33162,28196,27850,39539,25429,21340,21754,34917,22496,19981,24067,27493,31807,
37096,24598,25830,29468,35009,26448,25165,36130,30572,36393,37319,24425,33756,
34081,39184,21442,34453,27531,24813,24808,28799,33485,33329,20179,27815,34255,
25805,31961,27133,26361,33609,21397,31574,20391,20876,
27979,23618,36461,25554,21449,33580,33590,26597,30900,25661,23519,23700,24046,
35815,25286,26612,35962,25600,25530,34633,39307,35863,32544,38130,20135,38416,
39076,26124,29462,30694,30696,30698,30703,30704,30705,30706,30708,30709,30711,
30713,30714,30715,30716,30723,30724,30725,30726,30727,30728,30730,30731,30734,
30735,30736,30739,30741,30745,30747,30750,30752,30753,30754,30756,30760,30762,
30763,30766,30767,30769,30770,30771,30773,30774,30781,30783,30785,30786,30787,
30788,30790,30792,30793,30794,30795,30797,30799,30801,30803,30804,30808,30809,
30810,30811,30812,30814,30815,30816,30817,30818,30819,30820,30821,30822,30823,
30824,30825,30831,30832,30833,30834,30835,30836,30837,30838,30840,30841,30842,
30843,30845,30846,30847,30848,30849,30850,30851,22330,23581,24120,38271,20607,
32928,21378,25950,30021,21809,20513,36229,25220,38046,26397,22066,28526,24034,
21557,28818,36710,25199,25764,25507,24443,28552,37108,33251,36784,23576,26216,
24561,27785,38472,36225,34924,25745,31216,22478,27225,25104,21576,20056,31243,
24809,28548,35802,25215,36894,39563,31204,21507,30196,25345,21273,27744,36831,
24347,39536,32827,40831,20360,23610,36196,32709,26021,28861,20805,20914,34411,
23815,23456,25277,37228,30068,36364,31264,24833,31609,20167,32504,30597,19985,
33261,21021,20986,27249,21416,36487,38148,38607,28353,38500,26970,30852,30853,
30854,30856,30858,30859,30863,30864,30866,30868,30869,30870,30873,30877,30878,
30880,30882,30884,30886,30888,30889,30890,30891,30892,30893,30894,30895,30901,
30902,30903,30904,30906,30907,30908,30909,30911,30912,
30914,30915,30916,30918,30919,30920,30924,30925,30926,30927,30929,30930,30931,
30934,30935,30936,30938,30939,30940,30941,30942,30943,30944,30945,30946,30947,
30948,30949,30950,30951,30953,30954,30955,30957,30958,30959,30960,30961,30963,
30965,30966,30968,30969,30971,30972,30973,30974,30975,30976,30978,30979,30980,
30982,30983,30984,30985,30986,30987,30988,30784,20648,30679,25616,35302,22788,
25571,24029,31359,26941,20256,33337,21912,20018,30126,31383,24162,24202,38383,
21019,21561,28810,25462,38180,22402,26149,26943,37255,21767,28147,32431,34850,
25139,32496,30133,33576,30913,38604,36766,24904,29943,35789,27492,21050,36176,
27425,32874,33905,22257,21254,20174,19995,20945,31895,37259,31751,20419,36479,
31713,31388,25703,23828,20652,33030,30209,31929,28140,32736,26449,23384,23544,
30923,25774,25619,25514,25387,38169,25645,36798,31572,30249,25171,22823,21574,
27513,20643,25140,24102,27526,20195,36151,34955,24453,36910,30989,30990,30991,
30992,30993,30994,30996,30997,30998,30999,31000,31001,31002,31003,31004,31005,
31007,31008,31009,31010,31011,31013,31014,31015,31016,31017,31018,31019,31020,
31021,31022,31023,31024,31025,31026,31027,31029,31030,31031,31032,31033,31037,
31039,31042,31043,31044,31045,31047,31050,31051,31052,31053,31054,31055,31056,
31057,31058,31060,31061,31064,31065,31073,31075,31076,31078,31081,31082,31083,
31084,31086,31088,31089,31090,31091,31092,31093,31094,31097,31099,31100,31101,
31102,31103,31106,31107,31110,31111,31112,31113,31115,31116,31117,31118,31120,
31121,31122,24608,32829,25285,20025,21333,37112,25528,
32966,26086,27694,20294,24814,28129,35806,24377,34507,24403,25377,20826,33633,
26723,20992,25443,36424,20498,23707,31095,23548,21040,31291,24764,36947,30423,
24503,24471,30340,36460,28783,30331,31561,30634,20979,37011,22564,20302,28404,
36842,25932,31515,29380,28068,32735,23265,25269,24213,22320,33922,31532,24093,
24351,36882,32532,39072,25474,28359,30872,28857,20856,38747,22443,30005,20291,
30008,24215,24806,22880,28096,27583,30857,21500,38613,20939,20993,25481,21514,
38035,35843,36300,29241,30879,34678,36845,35853,21472,31123,31124,31125,31126,
31127,31128,31129,31131,31132,31133,31134,31135,31136,31137,31138,31139,31140,
31141,31142,31144,31145,31146,31147,31148,31149,31150,31151,31152,31153,31154,
31156,31157,31158,31159,31160,31164,31167,31170,31172,31173,31175,31176,31178,
31180,31182,31183,31184,31187,31188,31190,31191,31193,31194,31195,31196,31197,
31198,31200,31201,31202,31205,31208,31210,31212,31214,31217,31218,31219,31220,
31221,31222,31223,31225,31226,31228,31230,31231,31233,31236,31237,31239,31240,
31241,31242,31244,31247,31248,31249,31250,31251,31253,31254,31256,31257,31259,
31260,19969,30447,21486,38025,39030,40718,38189,23450,35746,20002,19996,20908,
33891,25026,21160,26635,20375,24683,20923,27934,20828,25238,26007,38497,35910,
36887,30168,37117,30563,27602,29322,29420,35835,22581,30585,36172,26460,38208,
32922,24230,28193,22930,31471,30701,38203,27573,26029,32526,22534,20817,38431,
23545,22697,21544,36466,25958,39039,22244,38045,30462,36929,25479,21702,22810,
22842,22427,36530,26421,36346,33333,21057,24816,22549,
34558,23784,40517,20420,39069,35769,23077,24694,21380,25212,36943,37122,39295,
24681,32780,20799,32819,23572,39285,27953,20108,31261,31263,31265,31266,31268,
31269,31270,31271,31272,31273,31274,31275,31276,31277,31278,31279,31280,31281,
31282,31284,31285,31286,31288,31290,31294,31296,31297,31298,31299,31300,31301,
31303,31304,31305,31306,31307,31308,31309,31310,31311,31312,31314,31315,31316,
31317,31318,31320,31321,31322,31323,31324,31325,31326,31327,31328,31329,31330,
31331,31332,31333,31334,31335,31336,31337,31338,31339,31340,31341,31342,31343,
31345,31346,31347,31349,31355,31356,31357,31358,31362,31365,31367,31369,31370,
31371,31372,31374,31375,31376,31379,31380,31385,31386,31387,31390,31393,31394,
36144,21457,32602,31567,20240,20047,38400,27861,29648,34281,24070,30058,32763,
27146,30718,38034,32321,20961,28902,21453,36820,33539,36137,29359,39277,27867,
22346,33459,26041,32938,25151,38450,22952,20223,35775,32442,25918,33778,38750,
21857,39134,32933,21290,35837,21536,32954,24223,27832,36153,33452,37210,21545,
27675,20998,32439,22367,28954,27774,31881,22859,20221,24575,24868,31914,20016,
23553,26539,34562,23792,38155,39118,30127,28925,36898,20911,32541,35773,22857,
20964,20315,21542,22827,25975,32932,23413,25206,25282,36752,24133,27679,31526,
20239,20440,26381,31395,31396,31399,31401,31402,31403,31406,31407,31408,31409,
31410,31412,31413,31414,31415,31416,31417,31418,31419,31420,31421,31422,31424,
31425,31426,31427,31428,31429,31430,31431,31432,31433,31434,31436,31437,31438,
31439,31440,31441,31442,31443,31444,31445,31447,31448,
31450,31451,31452,31453,31457,31458,31460,31463,31464,31465,31466,31467,31468,
31470,31472,31473,31474,31475,31476,31477,31478,31479,31480,31483,31484,31486,
31488,31489,31490,31493,31495,31497,31500,31501,31502,31504,31506,31507,31510,
31511,31512,31514,31516,31517,31519,31521,31522,31523,31527,31529,31533,28014,
28074,31119,34993,24343,29995,25242,36741,20463,37340,26023,33071,33105,24220,
33104,36212,21103,35206,36171,22797,20613,20184,38428,29238,33145,36127,23500,
35747,38468,22919,32538,21648,22134,22030,35813,25913,27010,38041,30422,28297,
24178,29976,26438,26577,31487,32925,36214,24863,31174,25954,36195,20872,21018,
38050,32568,32923,32434,23703,28207,26464,31705,30347,39640,33167,32660,31957,
25630,38224,31295,21578,21733,27468,25601,25096,40509,33011,30105,21106,38761,
33883,26684,34532,38401,38548,38124,20010,21508,32473,26681,36319,32789,26356,
24218,32697,31535,31536,31538,31540,31541,31542,31543,31545,31547,31549,31551,
31552,31553,31554,31555,31556,31558,31560,31562,31565,31566,31571,31573,31575,
31577,31580,31582,31583,31585,31587,31588,31589,31590,31591,31592,31593,31594,
31595,31596,31597,31599,31600,31603,31604,31606,31608,31610,31612,31613,31615,
31617,31618,31619,31620,31622,31623,31624,31625,31626,31627,31628,31630,31631,
31633,31634,31635,31638,31640,31641,31642,31643,31646,31647,31648,31651,31652,
31653,31662,31663,31664,31666,31667,31669,31670,31671,31673,31674,31675,31676,
31677,31678,31679,31680,31682,31683,31684,22466,32831,26775,24037,25915,21151,
24685,40858,20379,36524,20844,23467,24339,24041,27742,
25329,36129,20849,38057,21246,27807,33503,29399,22434,26500,36141,22815,36764,
33735,21653,31629,20272,27837,23396,22993,40723,21476,34506,39592,35895,32929,
25925,39038,22266,38599,21038,29916,21072,23521,25346,35074,20054,25296,24618,
26874,20851,23448,20896,35266,31649,39302,32592,24815,28748,36143,20809,24191,
36891,29808,35268,22317,30789,24402,40863,38394,36712,39740,35809,30328,26690,
26588,36330,36149,21053,36746,28378,26829,38149,37101,22269,26524,35065,36807,
21704,31685,31688,31689,31690,31691,31693,31694,31695,31696,31698,31700,31701,
31702,31703,31704,31707,31708,31710,31711,31712,31714,31715,31716,31719,31720,
31721,31723,31724,31725,31727,31728,31730,31731,31732,31733,31734,31736,31737,
31738,31739,31741,31743,31744,31745,31746,31747,31748,31749,31750,31752,31753,
31754,31757,31758,31760,31761,31762,31763,31764,31765,31767,31768,31769,31770,
31771,31772,31773,31774,31776,31777,31778,31779,31780,31781,31784,31785,31787,
31788,31789,31790,31791,31792,31793,31794,31795,31796,31797,31798,31799,31801,
31802,31803,31804,31805,31806,31810,39608,23401,28023,27686,20133,23475,39559,
37219,25000,37039,38889,21547,28085,23506,20989,21898,32597,32752,25788,25421,
26097,25022,24717,28938,27735,27721,22831,26477,33322,22741,22158,35946,27627,
37085,22909,32791,21495,28009,21621,21917,33655,33743,26680,31166,21644,20309,
21512,30418,35977,38402,27827,28088,36203,35088,40548,36154,22079,40657,30165,
24456,29408,24680,21756,20136,27178,34913,24658,36720,21700,28888,34425,40511,
27946,23439,24344,32418,21897,20399,29492,21564,21402,
20505,21518,21628,20046,24573,29786,22774,33899,32993,34676,29392,31946,28246,
31811,31812,31813,31814,31815,31816,31817,31818,31819,31820,31822,31823,31824,
31825,31826,31827,31828,31829,31830,31831,31832,31833,31834,31835,31836,31837,
31838,31839,31840,31841,31842,31843,31844,31845,31846,31847,31848,31849,31850,
31851,31852,31853,31854,31855,31856,31857,31858,31861,31862,31863,31864,31865,
31866,31870,31871,31872,31873,31874,31875,31876,31877,31878,31879,31880,31882,
31883,31884,31885,31886,31887,31888,31891,31892,31894,31897,31898,31899,31904,
31905,31907,31910,31911,31912,31913,31915,31916,31917,31919,31920,31924,31925,
31926,31927,31928,31930,31931,24359,34382,21804,25252,20114,27818,25143,33457,
21719,21326,29502,28369,30011,21010,21270,35805,27088,24458,24576,28142,22351,
27426,29615,26707,36824,32531,25442,24739,21796,30186,35938,28949,28067,23462,
24187,33618,24908,40644,30970,34647,31783,30343,20976,24822,29004,26179,24140,
24653,35854,28784,25381,36745,24509,24674,34516,22238,27585,24724,24935,21321,
24800,26214,36159,31229,20250,28905,27719,35763,35826,32472,33636,26127,23130,
39746,27985,28151,35905,27963,20249,28779,33719,25110,24785,38669,36135,31096,
20987,22334,22522,26426,30072,31293,31215,31637,31935,31936,31938,31939,31940,
31942,31945,31947,31950,31951,31952,31953,31954,31955,31956,31960,31962,31963,
31965,31966,31969,31970,31971,31972,31973,31974,31975,31977,31978,31979,31980,
31981,31982,31984,31985,31986,31987,31988,31989,31990,31991,31993,31994,31996,
31997,31998,31999,32000,32001,32002,32003,32004,32005,
32006,32007,32008,32009,32011,32012,32013,32014,32015,32016,32017,32018,32019,
32020,32021,32022,32023,32024,32025,32026,32027,32028,32029,32030,32031,32033,
32035,32036,32037,32038,32040,32041,32042,32044,32045,32046,32048,32049,32050,
32051,32052,32053,32054,32908,39269,36857,28608,35749,40481,23020,32489,32521,
21513,26497,26840,36753,31821,38598,21450,24613,30142,27762,21363,23241,32423,
25380,20960,33034,24049,34015,25216,20864,23395,20238,31085,21058,24760,27982,
23492,23490,35745,35760,26082,24524,38469,22931,32487,32426,22025,26551,22841,
20339,23478,21152,33626,39050,36158,30002,38078,20551,31292,20215,26550,39550,
23233,27516,30417,22362,23574,31546,38388,29006,20860,32937,33392,22904,32516,
33575,26816,26604,30897,30839,25315,25441,31616,20461,21098,20943,33616,27099,
37492,36341,36145,35265,38190,31661,20214,32055,32056,32057,32058,32059,32060,
32061,32062,32063,32064,32065,32066,32067,32068,32069,32070,32071,32072,32073,
32074,32075,32076,32077,32078,32079,32080,32081,32082,32083,32084,32085,32086,
32087,32088,32089,32090,32091,32092,32093,32094,32095,32096,32097,32098,32099,
32100,32101,32102,32103,32104,32105,32106,32107,32108,32109,32111,32112,32113,
32114,32115,32116,32117,32118,32120,32121,32122,32123,32124,32125,32126,32127,
32128,32129,32130,32131,32132,32133,32134,32135,32136,32137,32138,32139,32140,
32141,32142,32143,32144,32145,32146,32147,32148,32149,32150,32151,32152,20581,
33328,21073,39279,28176,28293,28071,24314,20725,23004,23558,27974,27743,30086,
33931,26728,22870,35762,21280,37233,38477,34121,26898,
30977,28966,33014,20132,37066,27975,39556,23047,22204,25605,38128,30699,20389,
33050,29409,35282,39290,32564,32478,21119,25945,37237,36735,36739,21483,31382,
25581,25509,30342,31224,34903,38454,25130,21163,33410,26708,26480,25463,30571,
31469,27905,32467,35299,22992,25106,34249,33445,30028,20511,20171,30117,35819,
23626,24062,31563,26020,37329,20170,27941,35167,32039,38182,20165,35880,36827,
38771,26187,31105,36817,28908,28024,32153,32154,32155,32156,32157,32158,32159,
32160,32161,32162,32163,32164,32165,32167,32168,32169,32170,32171,32172,32173,
32175,32176,32177,32178,32179,32180,32181,32182,32183,32184,32185,32186,32187,
32188,32189,32190,32191,32192,32193,32194,32195,32196,32197,32198,32199,32200,
32201,32202,32203,32204,32205,32206,32207,32208,32209,32210,32211,32212,32213,
32214,32215,32216,32217,32218,32219,32220,32221,32222,32223,32224,32225,32226,
32227,32228,32229,32230,32231,32232,32233,32234,32235,32236,32237,32238,32239,
32240,32241,32242,32243,32244,32245,32246,32247,32248,32249,32250,23613,21170,
33606,20834,33550,30555,26230,40120,20140,24778,31934,31923,32463,20117,35686,
26223,39048,38745,22659,25964,38236,24452,30153,38742,31455,31454,20928,28847,
31384,25578,31350,32416,29590,38893,20037,28792,20061,37202,21417,25937,26087,
33276,33285,21646,23601,30106,38816,25304,29401,30141,23621,39545,33738,23616,
21632,30697,20030,27822,32858,25298,25454,24040,20855,36317,36382,38191,20465,
21477,24807,28844,21095,25424,40515,23071,20518,30519,21367,32482,25733,25899,
25225,25496,20500,29237,35273,20915,35776,32477,22343,
33740,38055,20891,21531,23803,32251,32252,32253,32254,32255,32256,32257,32258,
32259,32260,32261,32262,32263,32264,32265,32266,32267,32268,32269,32270,32271,
32272,32273,32274,32275,32276,32277,32278,32279,32280,32281,32282,32283,32284,
32285,32286,32287,32288,32289,32290,32291,32292,32293,32294,32295,32296,32297,
32298,32299,32300,32301,32302,32303,32304,32305,32306,32307,32308,32309,32310,
32311,32312,32313,32314,32316,32317,32318,32319,32320,32322,32323,32324,32325,
32326,32328,32329,32330,32331,32332,32333,32334,32335,32336,32337,32338,32339,
32340,32341,32342,32343,32344,32345,32346,32347,32348,32349,20426,31459,27994,
37089,39567,21888,21654,21345,21679,24320,25577,26999,20975,24936,21002,22570,
21208,22350,30733,30475,24247,24951,31968,25179,25239,20130,28821,32771,25335,
28900,38752,22391,33499,26607,26869,30933,39063,31185,22771,21683,21487,28212,
20811,21051,23458,35838,32943,21827,22438,24691,22353,21549,31354,24656,23380,
25511,25248,21475,25187,23495,26543,21741,31391,33510,37239,24211,35044,22840,
22446,25358,36328,33007,22359,31607,20393,24555,23485,27454,21281,31568,29378,
26694,30719,30518,26103,20917,20111,30420,23743,31397,33909,22862,39745,20608,
32350,32351,32352,32353,32354,32355,32356,32357,32358,32359,32360,32361,32362,
32363,32364,32365,32366,32367,32368,32369,32370,32371,32372,32373,32374,32375,
32376,32377,32378,32379,32380,32381,32382,32383,32384,32385,32387,32388,32389,
32390,32391,32392,32393,32394,32395,32396,32397,32398,32399,32400,32401,32402,
32403,32404,32405,32406,32407,32408,32409,32410,32412,
32413,32414,32430,32436,32443,32444,32470,32484,32492,32505,32522,32528,32542,
32567,32569,32571,32572,32573,32574,32575,32576,32577,32579,32582,32583,32584,
32585,32586,32587,32588,32589,32590,32591,32594,32595,39304,24871,28291,22372,
26118,25414,22256,25324,25193,24275,38420,22403,25289,21895,34593,33098,36771,
21862,33713,26469,36182,34013,23146,26639,25318,31726,38417,20848,28572,35888,
25597,35272,25042,32518,28866,28389,29701,27028,29436,24266,37070,26391,28010,
25438,21171,29282,32769,20332,23013,37226,28889,28061,21202,20048,38647,38253,
34174,30922,32047,20769,22418,25794,32907,31867,27882,26865,26974,20919,21400,
26792,29313,40654,31729,29432,31163,28435,29702,26446,37324,40100,31036,33673,
33620,21519,26647,20029,21385,21169,30782,21382,21033,20616,20363,20432,32598,
32601,32603,32604,32605,32606,32608,32611,32612,32613,32614,32615,32619,32620,
32621,32623,32624,32627,32629,32630,32631,32632,32634,32635,32636,32637,32639,
32640,32642,32643,32644,32645,32646,32647,32648,32649,32651,32653,32655,32656,
32657,32658,32659,32661,32662,32663,32664,32665,32667,32668,32672,32674,32675,
32677,32678,32680,32681,32682,32683,32684,32685,32686,32689,32691,32692,32693,
32694,32695,32698,32699,32702,32704,32706,32707,32708,32710,32711,32712,32713,
32715,32717,32719,32720,32721,32722,32723,32726,32727,32729,32730,32731,32732,
32733,32734,32738,32739,30178,31435,31890,27813,38582,21147,29827,21737,20457,
32852,33714,36830,38256,24265,24604,28063,24088,25947,33080,38142,24651,28860,
32451,31918,20937,26753,31921,33391,20004,36742,37327,
26238,20142,35845,25769,32842,20698,30103,29134,23525,36797,28518,20102,25730,
38243,24278,26009,21015,35010,28872,21155,29454,29747,26519,30967,38678,20020,
37051,40158,28107,20955,36161,21533,25294,29618,33777,38646,40836,38083,20278,
32666,20940,28789,38517,23725,39046,21478,20196,28316,29705,27060,30827,39311,
30041,21016,30244,27969,26611,20845,40857,32843,21657,31548,31423,32740,32743,
32744,32746,32747,32748,32749,32751,32754,32756,32757,32758,32759,32760,32761,
32762,32765,32766,32767,32770,32775,32776,32777,32778,32782,32783,32785,32787,
32794,32795,32797,32798,32799,32801,32803,32804,32811,32812,32813,32814,32815,
32816,32818,32820,32825,32826,32828,32830,32832,32833,32836,32837,32839,32840,
32841,32846,32847,32848,32849,32851,32853,32854,32855,32857,32859,32860,32861,
32862,32863,32864,32865,32866,32867,32868,32869,32870,32871,32872,32875,32876,
32877,32878,32879,32880,32882,32883,32884,32885,32886,32887,32888,32889,32890,
32891,32892,32893,38534,22404,25314,38471,27004,23044,25602,31699,28431,38475,
33446,21346,39045,24208,28809,25523,21348,34383,40065,40595,30860,38706,36335,
36162,40575,28510,31108,24405,38470,25134,39540,21525,38109,20387,26053,23653,
23649,32533,34385,27695,24459,29575,28388,32511,23782,25371,23402,28390,21365,
20081,25504,30053,25249,36718,20262,20177,27814,32438,35770,33821,34746,32599,
36923,38179,31657,39585,35064,33853,27931,39558,32476,22920,40635,29595,30721,
34434,39532,39554,22043,21527,22475,20080,40614,21334,36808,33033,30610,39314,
34542,28385,34067,26364,24930,28459,32894,32897,32898,
32901,32904,32906,32909,32910,32911,32912,32913,32914,32916,32917,32919,32921,
32926,32931,32934,32935,32936,32940,32944,32947,32949,32950,32952,32953,32955,
32965,32967,32968,32969,32970,32971,32975,32976,32977,32978,32979,32980,32981,
32984,32991,32992,32994,32995,32998,33006,33013,33015,33017,33019,33022,33023,
33024,33025,33027,33028,33029,33031,33032,33035,33036,33045,33047,33049,33051,
33052,33053,33055,33056,33057,33058,33059,33060,33061,33062,33063,33064,33065,
33066,33067,33069,33070,33072,33075,33076,33077,33079,33081,33082,33083,33084,
33085,33087,35881,33426,33579,30450,27667,24537,33725,29483,33541,38170,27611,
30683,38086,21359,33538,20882,24125,35980,36152,20040,29611,26522,26757,37238,
38665,29028,27809,30473,23186,38209,27599,32654,26151,23504,22969,23194,38376,
38391,20204,33804,33945,27308,30431,38192,29467,26790,23391,30511,37274,38753,
31964,36855,35868,24357,31859,31192,35269,27852,34588,23494,24130,26825,30496,
32501,20885,20813,21193,23081,32517,38754,33495,25551,30596,34256,31186,28218,
24217,22937,34065,28781,27665,25279,30399,25935,24751,38397,26126,34719,40483,
38125,21517,21629,35884,25720,33088,33089,33090,33091,33092,33093,33095,33097,
33101,33102,33103,33106,33110,33111,33112,33115,33116,33117,33118,33119,33121,
33122,33123,33124,33126,33128,33130,33131,33132,33135,33138,33139,33141,33142,
33143,33144,33153,33155,33156,33157,33158,33159,33161,33163,33164,33165,33166,
33168,33170,33171,33172,33173,33174,33175,33177,33178,33182,33183,33184,33185,
33186,33188,33189,33191,33193,33195,33196,33197,33198,
33199,33200,33201,33202,33204,33205,33206,33207,33208,33209,33212,33213,33214,
33215,33220,33221,33223,33224,33225,33227,33229,33230,33231,33232,33233,33234,
33235,25721,34321,27169,33180,30952,25705,39764,25273,26411,33707,22696,40664,
27819,28448,23518,38476,35851,29279,26576,25287,29281,20137,22982,27597,22675,
26286,24149,21215,24917,26408,30446,30566,29287,31302,25343,21738,21584,38048,
37027,23068,32435,27670,20035,22902,32784,22856,21335,30007,38590,22218,25376,
33041,24700,38393,28118,21602,39297,20869,23273,33021,22958,38675,20522,27877,
23612,25311,20320,21311,33147,36870,28346,34091,25288,24180,30910,25781,25467,
24565,23064,37247,40479,23615,25423,32834,23421,21870,38218,38221,28037,24744,
26592,29406,20957,23425,33236,33237,33238,33239,33240,33241,33242,33243,33244,
33245,33246,33247,33248,33249,33250,33252,33253,33254,33256,33257,33259,33262,
33263,33264,33265,33266,33269,33270,33271,33272,33273,33274,33277,33279,33283,
33287,33288,33289,33290,33291,33294,33295,33297,33299,33301,33302,33303,33304,
33305,33306,33309,33312,33316,33317,33318,33319,33321,33326,33330,33338,33340,
33341,33343,33344,33345,33346,33347,33349,33350,33352,33354,33356,33357,33358,
33360,33361,33362,33363,33364,33365,33366,33367,33369,33371,33372,33373,33374,
33376,33377,33378,33379,33380,33381,33382,33383,33385,25319,27870,29275,25197,
38062,32445,33043,27987,20892,24324,22900,21162,24594,22899,26262,34384,30111,
25386,25062,31983,35834,21734,27431,40485,27572,34261,21589,20598,27812,21866,
36276,29228,24085,24597,29750,25293,25490,29260,24472,
28227,27966,25856,28504,30424,30928,30460,30036,21028,21467,20051,24222,26049,
32810,32982,25243,21638,21032,28846,34957,36305,27873,21624,32986,22521,35060,
36180,38506,37197,20329,27803,21943,30406,30768,25256,28921,28558,24429,34028,
26842,30844,31735,33192,26379,40527,25447,30896,22383,30738,38713,25209,25259,
21128,29749,27607,33386,33387,33388,33389,33393,33397,33398,33399,33400,33403,
33404,33408,33409,33411,33413,33414,33415,33417,33420,33424,33427,33428,33429,
33430,33434,33435,33438,33440,33442,33443,33447,33458,33461,33462,33466,33467,
33468,33471,33472,33474,33475,33477,33478,33481,33488,33494,33497,33498,33501,
33506,33511,33512,33513,33514,33516,33517,33518,33520,33522,33523,33525,33526,
33528,33530,33532,33533,33534,33535,33536,33546,33547,33549,33552,33554,33555,
33558,33560,33561,33565,33566,33567,33568,33569,33570,33571,33572,33573,33574,
33577,33578,33582,33584,33586,33591,33595,33597,21860,33086,30130,30382,21305,
30174,20731,23617,35692,31687,20559,29255,39575,39128,28418,29922,31080,25735,
30629,25340,39057,36139,21697,32856,20050,22378,33529,33805,24179,20973,29942,
35780,23631,22369,27900,39047,23110,30772,39748,36843,31893,21078,25169,38138,
20166,33670,33889,33769,33970,22484,26420,22275,26222,28006,35889,26333,28689,
26399,27450,26646,25114,22971,19971,20932,28422,26578,27791,20854,26827,22855,
27495,30054,23822,33040,40784,26071,31048,31041,39569,36215,23682,20062,20225,
21551,22865,30732,22120,27668,36804,24323,27773,27875,35755,25488,33598,33599,
33601,33602,33604,33605,33608,33610,33611,33612,33613,
33614,33619,33621,33622,33623,33624,33625,33629,33634,33648,33649,33650,33651,
33652,33653,33654,33657,33658,33662,33663,33664,33665,33666,33667,33668,33671,
33672,33674,33675,33676,33677,33679,33680,33681,33684,33685,33686,33687,33689,
33690,33693,33695,33697,33698,33699,33700,33701,33702,33703,33708,33709,33710,
33711,33717,33723,33726,33727,33730,33731,33732,33734,33736,33737,33739,33741,
33742,33744,33745,33746,33747,33749,33751,33753,33754,33755,33758,33762,33763,
33764,33766,33767,33768,33771,33772,33773,24688,27965,29301,25190,38030,38085,
21315,36801,31614,20191,35878,20094,40660,38065,38067,21069,28508,36963,27973,
35892,22545,23884,27424,27465,26538,21595,33108,32652,22681,34103,24378,25250,
27207,38201,25970,24708,26725,30631,20052,20392,24039,38808,25772,32728,23789,
20431,31373,20999,33540,19988,24623,31363,38054,20405,20146,31206,29748,21220,
33465,25810,31165,23517,27777,38738,36731,27682,20542,21375,28165,25806,26228,
27696,24773,39031,35831,24198,29756,31351,31179,19992,37041,29699,27714,22234,
37195,27845,36235,21306,34502,26354,36527,23624,39537,28192,33774,33775,33779,
33780,33781,33782,33783,33786,33787,33788,33790,33791,33792,33794,33797,33799,
33800,33801,33802,33808,33810,33811,33812,33813,33814,33815,33817,33818,33819,
33822,33823,33824,33825,33826,33827,33833,33834,33835,33836,33837,33838,33839,
33840,33842,33843,33844,33845,33846,33847,33849,33850,33851,33854,33855,33856,
33857,33858,33859,33860,33861,33863,33864,33865,33866,33867,33868,33869,33870,
33871,33872,33874,33875,33876,33877,33878,33880,33885,
33886,33887,33888,33890,33892,33893,33894,33895,33896,33898,33902,33903,33904,
33906,33908,33911,33913,33915,33916,21462,23094,40843,36259,21435,22280,39079,
26435,37275,27849,20840,30154,25331,29356,21048,21149,32570,28820,30264,21364,
40522,27063,30830,38592,35033,32676,28982,29123,20873,26579,29924,22756,25880,
22199,35753,39286,25200,32469,24825,28909,22764,20161,20154,24525,38887,20219,
35748,20995,22922,32427,25172,20173,26085,25102,33592,33993,33635,34701,29076,
28342,23481,32466,20887,25545,26580,32905,33593,34837,20754,23418,22914,36785,
20083,27741,20837,35109,36719,38446,34122,29790,38160,38384,28070,33509,24369,
25746,27922,33832,33134,40131,22622,36187,19977,21441,33917,33918,33919,33920,
33921,33923,33924,33925,33926,33930,33933,33935,33936,33937,33938,33939,33940,
33941,33942,33944,33946,33947,33949,33950,33951,33952,33954,33955,33956,33957,
33958,33959,33960,33961,33962,33963,33964,33965,33966,33968,33969,33971,33973,
33974,33975,33979,33980,33982,33984,33986,33987,33989,33990,33991,33992,33995,
33996,33998,33999,34002,34004,34005,34007,34008,34009,34010,34011,34012,34014,
34017,34018,34020,34023,34024,34025,34026,34027,34029,34030,34031,34033,34034,
34035,34036,34037,34038,34039,34040,34041,34042,34043,34045,34046,34048,34049,
34050,20254,25955,26705,21971,20007,25620,39578,25195,23234,29791,33394,28073,
26862,20711,33678,30722,26432,21049,27801,32433,20667,21861,29022,31579,26194,
29642,33515,26441,23665,21024,29053,34923,38378,38485,25797,36193,33203,21892,
27733,25159,32558,22674,20260,21830,36175,26188,19978,
23578,35059,26786,25422,31245,28903,33421,21242,38902,23569,21736,37045,32461,
22882,36170,34503,33292,33293,36198,25668,23556,24913,28041,31038,35774,30775,
30003,21627,20280,36523,28145,23072,32453,31070,27784,23457,23158,29978,32958,
24910,28183,22768,29983,29989,29298,21319,32499,34051,34052,34053,34054,34055,
34056,34057,34058,34059,34061,34062,34063,34064,34066,34068,34069,34070,34072,
34073,34075,34076,34077,34078,34080,34082,34083,34084,34085,34086,34087,34088,
34089,34090,34093,34094,34095,34096,34097,34098,34099,34100,34101,34102,34110,
34111,34112,34113,34114,34116,34117,34118,34119,34123,34124,34125,34126,34127,
34128,34129,34130,34131,34132,34133,34135,34136,34138,34139,34140,34141,34143,
34144,34145,34146,34147,34149,34150,34151,34153,34154,34155,34156,34157,34158,
34159,34160,34161,34163,34165,34166,34167,34168,34172,34173,34175,34176,34177,
30465,30427,21097,32988,22307,24072,22833,29422,26045,28287,35799,23608,34417,
21313,30707,25342,26102,20160,39135,34432,23454,35782,21490,30690,20351,23630,
39542,22987,24335,31034,22763,19990,26623,20107,25325,35475,36893,21183,26159,
21980,22124,36866,20181,20365,37322,39280,27663,24066,24643,23460,35270,35797,
25910,25163,39318,23432,23551,25480,21806,21463,30246,20861,34092,26530,26803,
27530,25234,36755,21460,33298,28113,30095,20070,36174,23408,29087,34223,26257,
26329,32626,34560,40653,40736,23646,26415,36848,26641,26463,25101,31446,22661,
24246,25968,28465,34178,34179,34182,34184,34185,34186,34187,34188,34189,34190,
34192,34193,34194,34195,34196,34197,34198,34199,34200,
34201,34202,34205,34206,34207,34208,34209,34210,34211,34213,34214,34215,34217,
34219,34220,34221,34225,34226,34227,34228,34229,34230,34232,34234,34235,34236,
34237,34238,34239,34240,34242,34243,34244,34245,34246,34247,34248,34250,34251,
34252,34253,34254,34257,34258,34260,34262,34263,34264,34265,34266,34267,34269,
34270,34271,34272,34273,34274,34275,34277,34278,34279,34280,34282,34283,34284,
34285,34286,34287,34288,34289,34290,34291,34292,34293,34294,34295,34296,24661,
21047,32781,25684,34928,29993,24069,26643,25332,38684,21452,29245,35841,27700,
30561,31246,21550,30636,39034,33308,35828,30805,26388,28865,26031,25749,22070,
24605,31169,21496,19997,27515,32902,23546,21987,22235,20282,20284,39282,24051,
26494,32824,24578,39042,36865,23435,35772,35829,25628,33368,25822,22013,33487,
37221,20439,32032,36895,31903,20723,22609,28335,23487,35785,32899,37240,33948,
31639,34429,38539,38543,32485,39635,30862,23681,31319,36930,38567,31071,23385,
25439,31499,34001,26797,21766,32553,29712,32034,38145,25152,22604,20182,23427,
22905,22612,34297,34298,34300,34301,34302,34304,34305,34306,34307,34308,34310,
34311,34312,34313,34314,34315,34316,34317,34318,34319,34320,34322,34323,34324,
34325,34327,34328,34329,34330,34331,34332,34333,34334,34335,34336,34337,34338,
34339,34340,34341,34342,34344,34346,34347,34348,34349,34350,34351,34352,34353,
34354,34355,34356,34357,34358,34359,34361,34362,34363,34365,34366,34367,34368,
34369,34370,34371,34372,34373,34374,34375,34376,34377,34378,34379,34380,34386,
34387,34389,34390,34391,34392,34393,34395,34396,34397,
34399,34400,34401,34403,34404,34405,34406,34407,34408,34409,34410,29549,25374,
36427,36367,32974,33492,25260,21488,27888,37214,22826,24577,27760,22349,25674,
36138,30251,28393,22363,27264,30192,28525,35885,35848,22374,27631,34962,30899,
25506,21497,28845,27748,22616,25642,22530,26848,33179,21776,31958,20504,36538,
28108,36255,28907,25487,28059,28372,32486,33796,26691,36867,28120,38518,35752,
22871,29305,34276,33150,30140,35466,26799,21076,36386,38161,25552,39064,36420,
21884,20307,26367,22159,24789,28053,21059,23625,22825,28155,22635,30000,29980,
24684,33300,33094,25361,26465,36834,30522,36339,36148,38081,24086,21381,21548,
28867,34413,34415,34416,34418,34419,34420,34421,34422,34423,34424,34435,34436,
34437,34438,34439,34440,34441,34446,34447,34448,34449,34450,34452,34454,34455,
34456,34457,34458,34459,34462,34463,34464,34465,34466,34469,34470,34475,34477,
34478,34482,34483,34487,34488,34489,34491,34492,34493,34494,34495,34497,34498,
34499,34501,34504,34508,34509,34514,34515,34517,34518,34519,34522,34524,34525,
34528,34529,34530,34531,34533,34534,34535,34536,34538,34539,34540,34543,34549,
34550,34551,34554,34555,34556,34557,34559,34561,34564,34565,34566,34571,34572,
34574,34575,34576,34577,34580,34582,27712,24311,20572,20141,24237,25402,33351,
36890,26704,37230,30643,21516,38108,24420,31461,26742,25413,31570,32479,30171,
20599,25237,22836,36879,20984,31171,31361,22270,24466,36884,28034,23648,22303,
21520,20820,28237,22242,25512,39059,33151,34581,35114,36864,21534,23663,33216,
25302,25176,33073,40501,38464,39534,39548,26925,22949,
25299,21822,25366,21703,34521,27964,23043,29926,34972,27498,22806,35916,24367,
28286,29609,39037,20024,28919,23436,30871,25405,26202,30358,24779,23451,23113,
19975,33109,27754,29579,20129,26505,32593,24448,26106,26395,24536,22916,23041,
34585,34587,34589,34591,34592,34596,34598,34599,34600,34602,34603,34604,34605,
34607,34608,34610,34611,34613,34614,34616,34617,34618,34620,34621,34624,34625,
34626,34627,34628,34629,34630,34634,34635,34637,34639,34640,34641,34642,34644,
34645,34646,34648,34650,34651,34652,34653,34654,34655,34657,34658,34662,34663,
34664,34665,34666,34667,34668,34669,34671,34673,34674,34675,34677,34679,34680,
34681,34682,34687,34688,34689,34692,34694,34695,34697,34698,34700,34702,34703,
34704,34705,34706,34708,34709,34710,34712,34713,34714,34715,34716,34717,34718,
34720,34721,34722,34723,34724,24013,24494,21361,38886,36829,26693,22260,21807,
24799,20026,28493,32500,33479,33806,22996,20255,20266,23614,32428,26410,34074,
21619,30031,32963,21890,39759,20301,28205,35859,23561,24944,21355,30239,28201,
34442,25991,38395,32441,21563,31283,32010,38382,21985,32705,29934,25373,34583,
28065,31389,25105,26017,21351,25569,27779,24043,21596,38056,20044,27745,35820,
23627,26080,33436,26791,21566,21556,27595,27494,20116,25410,21320,33310,20237,
20398,22366,25098,38654,26212,29289,21247,21153,24735,35823,26132,29081,26512,
35199,30802,30717,26224,22075,21560,38177,29306,34725,34726,34727,34729,34730,
34734,34736,34737,34738,34740,34742,34743,34744,34745,34747,34748,34750,34751,
34753,34754,34755,34756,34757,34759,34760,34761,34764,
34765,34766,34767,34768,34772,34773,34774,34775,34776,34777,34778,34780,34781,
34782,34783,34785,34786,34787,34788,34790,34791,34792,34793,34795,34796,34797,
34799,34800,34801,34802,34803,34804,34805,34806,34807,34808,34810,34811,34812,
34813,34815,34816,34817,34818,34820,34821,34822,34823,34824,34825,34827,34828,
34829,34830,34831,34832,34833,34834,34836,34839,34840,34841,34842,34844,34845,
34846,34847,34848,34851,31232,24687,24076,24713,33181,22805,24796,29060,28911,
28330,27728,29312,27268,34989,24109,20064,23219,21916,38115,27927,31995,38553,
25103,32454,30606,34430,21283,38686,36758,26247,23777,20384,29421,19979,21414,
22799,21523,25472,38184,20808,20185,40092,32420,21688,36132,34900,33335,38386,
28046,24358,23244,26174,38505,29616,29486,21439,33146,39301,32673,23466,38519,
38480,32447,30456,21410,38262,39321,31665,35140,28248,20065,32724,31077,35814,
24819,21709,20139,39033,24055,27233,20687,21521,35937,33831,30813,38660,21066,
21742,22179,38144,28040,23477,28102,26195,34852,34853,34854,34855,34856,34857,
34858,34859,34860,34861,34862,34863,34864,34865,34867,34868,34869,34870,34871,
34872,34874,34875,34877,34878,34879,34881,34882,34883,34886,34887,34888,34889,
34890,34891,34894,34895,34896,34897,34898,34899,34901,34902,34904,34906,34907,
34908,34909,34910,34911,34912,34918,34919,34922,34925,34927,34929,34931,34932,
34933,34934,34936,34937,34938,34939,34940,34944,34947,34950,34951,34953,34954,
34956,34958,34959,34960,34961,34963,34964,34965,34967,34968,34969,34970,34971,
34973,34974,34975,34976,34977,34979,34981,34982,34983,
34984,34985,34986,23567,23389,26657,32918,21880,31505,25928,26964,20123,27463,
34638,38795,21327,25375,25658,37034,26012,32961,35856,20889,26800,21368,34809,
25032,27844,27899,35874,23633,34218,33455,38156,27427,36763,26032,24571,24515,
20449,34885,26143,33125,29481,24826,20852,21009,22411,24418,37026,34892,37266,
24184,26447,24615,22995,20804,20982,33016,21256,27769,38596,29066,20241,20462,
32670,26429,21957,38152,31168,34966,32483,22687,25100,38656,34394,22040,39035,
24464,35768,33988,37207,21465,26093,24207,30044,24676,32110,23167,32490,32493,
36713,21927,23459,24748,26059,29572,34988,34990,34991,34992,34994,34995,34996,
34997,34998,35000,35001,35002,35003,35005,35006,35007,35008,35011,35012,35015,
35016,35018,35019,35020,35021,35023,35024,35025,35027,35030,35031,35034,35035,
35036,35037,35038,35040,35041,35046,35047,35049,35050,35051,35052,35053,35054,
35055,35058,35061,35062,35063,35066,35067,35069,35071,35072,35073,35075,35076,
35077,35078,35079,35080,35081,35083,35084,35085,35086,35087,35089,35092,35093,
35094,35095,35096,35100,35101,35102,35103,35104,35106,35107,35108,35110,35111,
35112,35113,35116,35117,35118,35119,35121,35122,35123,35125,35127,36873,30307,
30505,32474,38772,34203,23398,31348,38634,34880,21195,29071,24490,26092,35810,
23547,39535,24033,27529,27739,35757,35759,36874,36805,21387,25276,40486,40493,
21568,20011,33469,29273,34460,23830,34905,28079,38597,21713,20122,35766,28937,
21693,38409,28895,28153,30416,20005,30740,34578,23721,24310,35328,39068,38414,
28814,27839,22852,25513,30524,34893,28436,33395,22576,
29141,21388,30746,38593,21761,24422,28976,23476,35866,39564,27523,22830,40495,
31207,26472,25196,20335,30113,32650,27915,38451,27687,20208,30162,20859,26679,
28478,36992,33136,22934,29814,35128,35129,35130,35131,35132,35133,35134,35135,
35136,35138,35139,35141,35142,35143,35144,35145,35146,35147,35148,35149,35150,
35151,35152,35153,35154,35155,35156,35157,35158,35159,35160,35161,35162,35163,
35164,35165,35168,35169,35170,35171,35172,35173,35175,35176,35177,35178,35179,
35180,35181,35182,35183,35184,35185,35186,35187,35188,35189,35190,35191,35192,
35193,35194,35196,35197,35198,35200,35202,35204,35205,35207,35208,35209,35210,
35211,35212,35213,35214,35215,35216,35217,35218,35219,35220,35221,35222,35223,
35224,35225,35226,35227,35228,35229,35230,35231,35232,35233,25671,23591,36965,
31377,35875,23002,21676,33280,33647,35201,32768,26928,22094,32822,29239,37326,
20918,20063,39029,25494,19994,21494,26355,33099,22812,28082,19968,22777,21307,
25558,38129,20381,20234,34915,39056,22839,36951,31227,20202,33008,30097,27778,
23452,23016,24413,26885,34433,20506,24050,20057,30691,20197,33402,25233,26131,
37009,23673,20159,24441,33222,36920,32900,30123,20134,35028,24847,27589,24518,
20041,30410,28322,35811,35758,35850,35793,24322,32764,32716,32462,33589,33643,
22240,27575,38899,38452,23035,21535,38134,28139,23493,39278,23609,24341,38544,
35234,35235,35236,35237,35238,35239,35240,35241,35242,35243,35244,35245,35246,
35247,35248,35249,35250,35251,35252,35253,35254,35255,35256,35257,35258,35259,
35260,35261,35262,35263,35264,35267,35277,35283,35284,
35285,35287,35288,35289,35291,35293,35295,35296,35297,35298,35300,35303,35304,
35305,35306,35308,35309,35310,35312,35313,35314,35316,35317,35318,35319,35320,
35321,35322,35323,35324,35325,35326,35327,35329,35330,35331,35332,35333,35334,
35336,35337,35338,35339,35340,35341,35342,35343,35344,35345,35346,35347,35348,
35349,35350,35351,35352,35353,35354,35355,35356,35357,21360,33521,27185,23156,
40560,24212,32552,33721,33828,33829,33639,34631,36814,36194,30408,24433,39062,
30828,26144,21727,25317,20323,33219,30152,24248,38605,36362,34553,21647,27891,
28044,27704,24703,21191,29992,24189,20248,24736,24551,23588,30001,37038,38080,
29369,27833,28216,37193,26377,21451,21491,20305,37321,35825,21448,24188,36802,
28132,20110,30402,27014,34398,24858,33286,20313,20446,36926,40060,24841,28189,
28180,38533,20104,23089,38632,19982,23679,31161,23431,35821,32701,29577,22495,
33419,37057,21505,36935,21947,23786,24481,24840,27442,29425,32946,35465,35358,
35359,35360,35361,35362,35363,35364,35365,35366,35367,35368,35369,35370,35371,
35372,35373,35374,35375,35376,35377,35378,35379,35380,35381,35382,35383,35384,
35385,35386,35387,35388,35389,35391,35392,35393,35394,35395,35396,35397,35398,
35399,35401,35402,35403,35404,35405,35406,35407,35408,35409,35410,35411,35412,
35413,35414,35415,35416,35417,35418,35419,35420,35421,35422,35423,35424,35425,
35426,35427,35428,35429,35430,35431,35432,35433,35434,35435,35436,35437,35438,
35439,35440,35441,35442,35443,35444,35445,35446,35447,35448,35450,35451,35452,
35453,35454,35455,35456,28020,23507,35029,39044,35947,
39533,40499,28170,20900,20803,22435,34945,21407,25588,36757,22253,21592,22278,
29503,28304,32536,36828,33489,24895,24616,38498,26352,32422,36234,36291,38053,
23731,31908,26376,24742,38405,32792,20113,37095,21248,38504,20801,36816,34164,
37213,26197,38901,23381,21277,30776,26434,26685,21705,28798,23472,36733,20877,
22312,21681,25874,26242,36190,36163,33039,33900,36973,31967,20991,34299,26531,
26089,28577,34468,36481,22122,36896,30338,28790,29157,36131,25321,21017,27901,
36156,24590,22686,24974,26366,36192,25166,21939,28195,26413,36711,35457,35458,
35459,35460,35461,35462,35463,35464,35467,35468,35469,35470,35471,35472,35473,
35474,35476,35477,35478,35479,35480,35481,35482,35483,35484,35485,35486,35487,
35488,35489,35490,35491,35492,35493,35494,35495,35496,35497,35498,35499,35500,
35501,35502,35503,35504,35505,35506,35507,35508,35509,35510,35511,35512,35513,
35514,35515,35516,35517,35518,35519,35520,35521,35522,35523,35524,35525,35526,
35527,35528,35529,35530,35531,35532,35533,35534,35535,35536,35537,35538,35539,
35540,35541,35542,35543,35544,35545,35546,35547,35548,35549,35550,35551,35552,
35553,35554,35555,38113,38392,30504,26629,27048,21643,20045,28856,35784,25688,
25995,23429,31364,20538,23528,30651,27617,35449,31896,27838,30415,26025,36759,
23853,23637,34360,26632,21344,25112,31449,28251,32509,27167,31456,24432,28467,
24352,25484,28072,26454,19976,24080,36134,20183,32960,30260,38556,25307,26157,
25214,27836,36213,29031,32617,20806,32903,21484,36974,25240,21746,34544,36761,
32773,38167,34071,36825,27993,29645,26015,30495,29956,
30759,33275,36126,38024,20390,26517,30137,35786,38663,25391,38215,38453,33976,
25379,30529,24449,29424,20105,24596,25972,25327,27491,25919,35556,35557,35558,
35559,35560,35561,35562,35563,35564,35565,35566,35567,35568,35569,35570,35571,
35572,35573,35574,35575,35576,35577,35578,35579,35580,35581,35582,35583,35584,
35585,35586,35587,35588,35589,35590,35592,35593,35594,35595,35596,35597,35598,
35599,35600,35601,35602,35603,35604,35605,35606,35607,35608,35609,35610,35611,
35612,35613,35614,35615,35616,35617,35618,35619,35620,35621,35623,35624,35625,
35626,35627,35628,35629,35630,35631,35632,35633,35634,35635,35636,35637,35638,
35639,35640,35641,35642,35643,35644,35645,35646,35647,35648,35649,35650,35651,
35652,35653,24103,30151,37073,35777,33437,26525,25903,21553,34584,30693,32930,
33026,27713,20043,32455,32844,30452,26893,27542,25191,20540,20356,22336,25351,
27490,36286,21482,26088,32440,24535,25370,25527,33267,33268,32622,24092,23769,
21046,26234,31209,31258,36136,28825,30164,28382,27835,31378,20013,30405,24544,
38047,34935,32456,31181,32959,37325,20210,20247,33311,21608,24030,27954,35788,
31909,36724,32920,24090,21650,30385,23449,26172,39588,29664,26666,34523,26417,
29482,35832,35803,36880,31481,28891,29038,25284,30633,22065,20027,33879,26609,
21161,34496,36142,38136,31569,35654,35655,35656,35657,35658,35659,35660,35661,
35662,35663,35664,35665,35666,35667,35668,35669,35670,35671,35672,35673,35674,
35675,35676,35677,35678,35679,35680,35681,35682,35683,35684,35685,35687,35688,
35689,35690,35691,35693,35694,35695,35696,35697,35698,
35699,35700,35701,35702,35703,35704,35705,35706,35707,35708,35709,35710,35711,
35712,35713,35714,35715,35716,35717,35718,35719,35720,35721,35722,35723,35724,
35725,35726,35727,35728,35729,35730,35731,35732,35733,35734,35735,35736,35737,
35738,35739,35740,35741,35742,35743,35756,35761,35771,35783,35792,35818,35849,
35870,20303,27880,31069,39547,25235,29226,25341,19987,30742,36716,25776,36186,
31686,26729,24196,35013,22918,25758,22766,29366,26894,38181,36861,36184,22368,
32512,35846,20934,25417,25305,21331,26700,29730,33537,37196,21828,30528,28796,
27978,20857,21672,36164,23039,28363,28100,23388,32043,20180,31869,28371,23376,
33258,28173,23383,39683,26837,36394,23447,32508,24635,32437,37049,36208,22863,
25549,31199,36275,21330,26063,31062,35781,38459,32452,38075,32386,22068,37257,
26368,32618,23562,36981,26152,24038,20304,26590,20570,20316,22352,24231,59408,
59409,59410,59411,59412,35896,35897,35898,35899,35900,35901,35902,35903,35904,
35906,35907,35908,35909,35912,35914,35915,35917,35918,35919,35920,35921,35922,
35923,35924,35926,35927,35928,35929,35931,35932,35933,35934,35935,35936,35939,
35940,35941,35942,35943,35944,35945,35948,35949,35950,35951,35952,35953,35954,
35956,35957,35958,35959,35963,35964,35965,35966,35967,35968,35969,35971,35972,
35974,35975,35976,35979,35981,35982,35983,35984,35985,35986,35987,35989,35990,
35991,35993,35994,35995,35996,35997,35998,35999,36000,36001,36002,36003,36004,
36005,36006,36007,36008,36009,36010,36011,36012,36013,20109,19980,20800,19984,
24319,21317,19989,20120,19998,39730,23404,22121,20008,
31162,20031,21269,20039,22829,29243,21358,27664,22239,32996,39319,27603,30590,
40727,20022,20127,40720,20060,20073,20115,33416,23387,21868,22031,20164,21389,
21405,21411,21413,21422,38757,36189,21274,21493,21286,21294,21310,36188,21350,
21347,20994,21000,21006,21037,21043,21055,21056,21068,21086,21089,21084,33967,
21117,21122,21121,21136,21139,20866,32596,20155,20163,20169,20162,20200,20193,
20203,20190,20251,20211,20258,20324,20213,20261,20263,20233,20267,20318,20327,
25912,20314,20317,36014,36015,36016,36017,36018,36019,36020,36021,36022,36023,
36024,36025,36026,36027,36028,36029,36030,36031,36032,36033,36034,36035,36036,
36037,36038,36039,36040,36041,36042,36043,36044,36045,36046,36047,36048,36049,
36050,36051,36052,36053,36054,36055,36056,36057,36058,36059,36060,36061,36062,
36063,36064,36065,36066,36067,36068,36069,36070,36071,36072,36073,36074,36075,
36076,36077,36078,36079,36080,36081,36082,36083,36084,36085,36086,36087,36088,
36089,36090,36091,36092,36093,36094,36095,36096,36097,36098,36099,36100,36101,
36102,36103,36104,36105,36106,36107,36108,36109,20319,20311,20274,20285,20342,
20340,20369,20361,20355,20367,20350,20347,20394,20348,20396,20372,20454,20456,
20458,20421,20442,20451,20444,20433,20447,20472,20521,20556,20467,20524,20495,
20526,20525,20478,20508,20492,20517,20520,20606,20547,20565,20552,20558,20588,
20603,20645,20647,20649,20666,20694,20742,20717,20716,20710,20718,20743,20747,
20189,27709,20312,20325,20430,40864,27718,31860,20846,24061,40649,39320,20865,
22804,21241,21261,35335,21264,20971,22809,20821,20128,
20822,20147,34926,34980,20149,33044,35026,31104,23348,34819,32696,20907,20913,
20925,20924,36110,36111,36112,36113,36114,36115,36116,36117,36118,36119,36120,
36121,36122,36123,36124,36128,36177,36178,36183,36191,36197,36200,36201,36202,
36204,36206,36207,36209,36210,36216,36217,36218,36219,36220,36221,36222,36223,
36224,36226,36227,36230,36231,36232,36233,36236,36237,36238,36239,36240,36242,
36243,36245,36246,36247,36248,36249,36250,36251,36252,36253,36254,36256,36257,
36258,36260,36261,36262,36263,36264,36265,36266,36267,36268,36269,36270,36271,
36272,36274,36278,36279,36281,36283,36285,36288,36289,36290,36293,36295,36296,
36297,36298,36301,36304,36306,36307,36308,20935,20886,20898,20901,35744,35750,
35751,35754,35764,35765,35767,35778,35779,35787,35791,35790,35794,35795,35796,
35798,35800,35801,35804,35807,35808,35812,35816,35817,35822,35824,35827,35830,
35833,35836,35839,35840,35842,35844,35847,35852,35855,35857,35858,35860,35861,
35862,35865,35867,35864,35869,35871,35872,35873,35877,35879,35882,35883,35886,
35887,35890,35891,35893,35894,21353,21370,38429,38434,38433,38449,38442,38461,
38460,38466,38473,38484,38495,38503,38508,38514,38516,38536,38541,38551,38576,
37015,37019,37021,37017,37036,37025,37044,37043,37046,37050,36309,36312,36313,
36316,36320,36321,36322,36325,36326,36327,36329,36333,36334,36336,36337,36338,
36340,36342,36348,36350,36351,36352,36353,36354,36355,36356,36358,36359,36360,
36363,36365,36366,36368,36369,36370,36371,36373,36374,36375,36376,36377,36378,
36379,36380,36384,36385,36388,36389,36390,36391,36392,
36395,36397,36400,36402,36403,36404,36406,36407,36408,36411,36412,36414,36415,
36419,36421,36422,36428,36429,36430,36431,36432,36435,36436,36437,36438,36439,
36440,36442,36443,36444,36445,36446,36447,36448,36449,36450,36451,36452,36453,
36455,36456,36458,36459,36462,36465,37048,37040,37071,37061,37054,37072,37060,
37063,37075,37094,37090,37084,37079,37083,37099,37103,37118,37124,37154,37150,
37155,37169,37167,37177,37187,37190,21005,22850,21154,21164,21165,21182,21759,
21200,21206,21232,21471,29166,30669,24308,20981,20988,39727,21430,24321,30042,
24047,22348,22441,22433,22654,22716,22725,22737,22313,22316,22314,22323,22329,
22318,22319,22364,22331,22338,22377,22405,22379,22406,22396,22395,22376,22381,
22390,22387,22445,22436,22412,22450,22479,22439,22452,22419,22432,22485,22488,
22490,22489,22482,22456,22516,22511,22520,22500,22493,36467,36469,36471,36472,
36473,36474,36475,36477,36478,36480,36482,36483,36484,36486,36488,36489,36490,
36491,36492,36493,36494,36497,36498,36499,36501,36502,36503,36504,36505,36506,
36507,36509,36511,36512,36513,36514,36515,36516,36517,36518,36519,36520,36521,
36522,36525,36526,36528,36529,36531,36532,36533,36534,36535,36536,36537,36539,
36540,36541,36542,36543,36544,36545,36546,36547,36548,36549,36550,36551,36552,
36553,36554,36555,36556,36557,36559,36560,36561,36562,36563,36564,36565,36566,
36567,36568,36569,36570,36571,36572,36573,36574,36575,36576,36577,36578,36579,
36580,22539,22541,22525,22509,22528,22558,22553,22596,22560,22629,22636,22657,
22665,22682,22656,39336,40729,25087,33401,33405,33407,
33423,33418,33448,33412,33422,33425,33431,33433,33451,33464,33470,33456,33480,
33482,33507,33432,33463,33454,33483,33484,33473,33449,33460,33441,33450,33439,
33476,33486,33444,33505,33545,33527,33508,33551,33543,33500,33524,33490,33496,
33548,33531,33491,33553,33562,33542,33556,33557,33504,33493,33564,33617,33627,
33628,33544,33682,33596,33588,33585,33691,33630,33583,33615,33607,33603,33631,
33600,33559,33632,33581,33594,33587,33638,33637,36581,36582,36583,36584,36585,
36586,36587,36588,36589,36590,36591,36592,36593,36594,36595,36596,36597,36598,
36599,36600,36601,36602,36603,36604,36605,36606,36607,36608,36609,36610,36611,
36612,36613,36614,36615,36616,36617,36618,36619,36620,36621,36622,36623,36624,
36625,36626,36627,36628,36629,36630,36631,36632,36633,36634,36635,36636,36637,
36638,36639,36640,36641,36642,36643,36644,36645,36646,36647,36648,36649,36650,
36651,36652,36653,36654,36655,36656,36657,36658,36659,36660,36661,36662,36663,
36664,36665,36666,36667,36668,36669,36670,36671,36672,36673,36674,36675,36676,
33640,33563,33641,33644,33642,33645,33646,33712,33656,33715,33716,33696,33706,
33683,33692,33669,33660,33718,33705,33661,33720,33659,33688,33694,33704,33722,
33724,33729,33793,33765,33752,22535,33816,33803,33757,33789,33750,33820,33848,
33809,33798,33748,33759,33807,33795,33784,33785,33770,33733,33728,33830,33776,
33761,33884,33873,33882,33881,33907,33927,33928,33914,33929,33912,33852,33862,
33897,33910,33932,33934,33841,33901,33985,33997,34000,34022,33981,34003,33994,
33983,33978,34016,33953,33977,33972,33943,34021,34019,
34060,29965,34104,34032,34105,34079,34106,36677,36678,36679,36680,36681,36682,
36683,36684,36685,36686,36687,36688,36689,36690,36691,36692,36693,36694,36695,
36696,36697,36698,36699,36700,36701,36702,36703,36704,36705,36706,36707,36708,
36709,36714,36736,36748,36754,36765,36768,36769,36770,36772,36773,36774,36775,
36778,36780,36781,36782,36783,36786,36787,36788,36789,36791,36792,36794,36795,
36796,36799,36800,36803,36806,36809,36810,36811,36812,36813,36815,36818,36822,
36823,36826,36832,36833,36835,36839,36844,36847,36849,36850,36852,36853,36854,
36858,36859,36860,36862,36863,36871,36872,36876,36878,36883,36885,36888,34134,
34107,34047,34044,34137,34120,34152,34148,34142,34170,30626,34115,34162,34171,
34212,34216,34183,34191,34169,34222,34204,34181,34233,34231,34224,34259,34241,
34268,34303,34343,34309,34345,34326,34364,24318,24328,22844,22849,32823,22869,
22874,22872,21263,23586,23589,23596,23604,25164,25194,25247,25275,25290,25306,
25303,25326,25378,25334,25401,25419,25411,25517,25590,25457,25466,25486,25524,
25453,25516,25482,25449,25518,25532,25586,25592,25568,25599,25540,25566,25550,
25682,25542,25534,25669,25665,25611,25627,25632,25612,25638,25633,25694,25732,
25709,25750,36889,36892,36899,36900,36901,36903,36904,36905,36906,36907,36908,
36912,36913,36914,36915,36916,36919,36921,36922,36925,36927,36928,36931,36933,
36934,36936,36937,36938,36939,36940,36942,36948,36949,36950,36953,36954,36956,
36957,36958,36959,36960,36961,36964,36966,36967,36969,36970,36971,36972,36975,
36976,36977,36978,36979,36982,36983,36984,36985,36986,
36987,36988,36990,36993,36996,36997,36998,36999,37001,37002,37004,37005,37006,
37007,37008,37010,37012,37014,37016,37018,37020,37022,37023,37024,37028,37029,
37031,37032,37033,37035,37037,37042,37047,37052,37053,37055,37056,25722,25783,
25784,25753,25786,25792,25808,25815,25828,25826,25865,25893,25902,24331,24530,
29977,24337,21343,21489,21501,21481,21480,21499,21522,21526,21510,21579,21586,
21587,21588,21590,21571,21537,21591,21593,21539,21554,21634,21652,21623,21617,
21604,21658,21659,21636,21622,21606,21661,21712,21677,21698,21684,21714,21671,
21670,21715,21716,21618,21667,21717,21691,21695,21708,21721,21722,21724,21673,
21674,21668,21725,21711,21726,21787,21735,21792,21757,21780,21747,21794,21795,
21775,21777,21799,21802,21863,21903,21941,21833,21869,21825,21845,21823,21840,
21820,37058,37059,37062,37064,37065,37067,37068,37069,37074,37076,37077,37078,
37080,37081,37082,37086,37087,37088,37091,37092,37093,37097,37098,37100,37102,
37104,37105,37106,37107,37109,37110,37111,37113,37114,37115,37116,37119,37120,
37121,37123,37125,37126,37127,37128,37129,37130,37131,37132,37133,37134,37135,
37136,37137,37138,37139,37140,37141,37142,37143,37144,37146,37147,37148,37149,
37151,37152,37153,37156,37157,37158,37159,37160,37161,37162,37163,37164,37165,
37166,37168,37170,37171,37172,37173,37174,37175,37176,37178,37179,37180,37181,
37182,37183,37184,37185,37186,37188,21815,21846,21877,21878,21879,21811,21808,
21852,21899,21970,21891,21937,21945,21896,21889,21919,21886,21974,21905,21883,
21983,21949,21950,21908,21913,21994,22007,21961,22047,
21969,21995,21996,21972,21990,21981,21956,21999,21989,22002,22003,21964,21965,
21992,22005,21988,36756,22046,22024,22028,22017,22052,22051,22014,22016,22055,
22061,22104,22073,22103,22060,22093,22114,22105,22108,22092,22100,22150,22116,
22129,22123,22139,22140,22149,22163,22191,22228,22231,22237,22241,22261,22251,
22265,22271,22276,22282,22281,22300,24079,24089,24084,24081,24113,24123,24124,
37189,37191,37192,37201,37203,37204,37205,37206,37208,37209,37211,37212,37215,
37216,37222,37223,37224,37227,37229,37235,37242,37243,37244,37248,37249,37250,
37251,37252,37254,37256,37258,37262,37263,37267,37268,37269,37270,37271,37272,
37273,37276,37277,37278,37279,37280,37281,37284,37285,37286,37287,37288,37289,
37291,37292,37296,37297,37298,37299,37302,37303,37304,37305,37307,37308,37309,
37310,37311,37312,37313,37314,37315,37316,37317,37318,37320,37323,37328,37330,
37331,37332,37333,37334,37335,37336,37337,37338,37339,37341,37342,37343,37344,
37345,37346,37347,37348,37349,24119,24132,24148,24155,24158,24161,23692,23674,
23693,23696,23702,23688,23704,23705,23697,23706,23708,23733,23714,23741,23724,
23723,23729,23715,23745,23735,23748,23762,23780,23755,23781,23810,23811,23847,
23846,23854,23844,23838,23814,23835,23896,23870,23860,23869,23916,23899,23919,
23901,23915,23883,23882,23913,23924,23938,23961,23965,35955,23991,24005,24435,
24439,24450,24455,24457,24460,24469,24473,24476,24488,24493,24501,24508,34914,
24417,29357,29360,29364,29367,29368,29379,29377,29390,29389,29394,29416,29423,
29417,29426,29428,29431,29441,29427,29443,29434,37350,
37351,37352,37353,37354,37355,37356,37357,37358,37359,37360,37361,37362,37363,
37364,37365,37366,37367,37368,37369,37370,37371,37372,37373,37374,37375,37376,
37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37387,37388,37389,
37390,37391,37392,37393,37394,37395,37396,37397,37398,37399,37400,37401,37402,
37403,37404,37405,37406,37407,37408,37409,37410,37411,37412,37413,37414,37415,
37416,37417,37418,37419,37420,37421,37422,37423,37424,37425,37426,37427,37428,
37429,37430,37431,37432,37433,37434,37435,37436,37437,37438,37439,37440,37441,
37442,37443,37444,37445,29435,29463,29459,29473,29450,29470,29469,29461,29474,
29497,29477,29484,29496,29489,29520,29517,29527,29536,29548,29551,29566,33307,
22821,39143,22820,22786,39267,39271,39272,39273,39274,39275,39276,39284,39287,
39293,39296,39300,39303,39306,39309,39312,39313,39315,39316,39317,24192,24209,
24203,24214,24229,24224,24249,24245,24254,24243,36179,24274,24273,24283,24296,
24298,33210,24516,24521,24534,24527,24579,24558,24580,24545,24548,24574,24581,
24582,24554,24557,24568,24601,24629,24614,24603,24591,24589,24617,24619,24586,
24639,24609,24696,24697,24699,24698,24642,37446,37447,37448,37449,37450,37451,
37452,37453,37454,37455,37456,37457,37458,37459,37460,37461,37462,37463,37464,
37465,37466,37467,37468,37469,37470,37471,37472,37473,37474,37475,37476,37477,
37478,37479,37480,37481,37482,37483,37484,37485,37486,37487,37488,37489,37490,
37491,37493,37494,37495,37496,37497,37498,37499,37500,37501,37502,37503,37504,
37505,37506,37507,37508,37509,37510,37511,37512,37513,
37514,37515,37516,37517,37519,37520,37521,37522,37523,37524,37525,37526,37527,
37528,37529,37530,37531,37532,37533,37534,37535,37536,37537,37538,37539,37540,
37541,37542,37543,24682,24701,24726,24730,24749,24733,24707,24722,24716,24731,
24812,24763,24753,24797,24792,24774,24794,24756,24864,24870,24853,24867,24820,
24832,24846,24875,24906,24949,25004,24980,24999,25015,25044,25077,24541,38579,
38377,38379,38385,38387,38389,38390,38396,38398,38403,38404,38406,38408,38410,
38411,38412,38413,38415,38418,38421,38422,38423,38425,38426,20012,29247,25109,
27701,27732,27740,27722,27811,27781,27792,27796,27788,27752,27753,27764,27766,
27782,27817,27856,27860,27821,27895,27896,27889,27863,27826,27872,27862,27898,
27883,27886,27825,27859,27887,27902,37544,37545,37546,37547,37548,37549,37551,
37552,37553,37554,37555,37556,37557,37558,37559,37560,37561,37562,37563,37564,
37565,37566,37567,37568,37569,37570,37571,37572,37573,37574,37575,37577,37578,
37579,37580,37581,37582,37583,37584,37585,37586,37587,37588,37589,37590,37591,
37592,37593,37594,37595,37596,37597,37598,37599,37600,37601,37602,37603,37604,
37605,37606,37607,37608,37609,37610,37611,37612,37613,37614,37615,37616,37617,
37618,37619,37620,37621,37622,37623,37624,37625,37626,37627,37628,37629,37630,
37631,37632,37633,37634,37635,37636,37637,37638,37639,37640,37641,27961,27943,
27916,27971,27976,27911,27908,27929,27918,27947,27981,27950,27957,27930,27983,
27986,27988,27955,28049,28015,28062,28064,27998,28051,28052,27996,28000,28028,
28003,28186,28103,28101,28126,28174,28095,28128,28177,
28134,28125,28121,28182,28075,28172,28078,28203,28270,28238,28267,28338,28255,
28294,28243,28244,28210,28197,28228,28383,28337,28312,28384,28461,28386,28325,
28327,28349,28347,28343,28375,28340,28367,28303,28354,28319,28514,28486,28487,
28452,28437,28409,28463,28470,28491,28532,28458,28425,28457,28553,28557,28556,
28536,28530,28540,28538,28625,37642,37643,37644,37645,37646,37647,37648,37649,
37650,37651,37652,37653,37654,37655,37656,37657,37658,37659,37660,37661,37662,
37663,37664,37665,37666,37667,37668,37669,37670,37671,37672,37673,37674,37675,
37676,37677,37678,37679,37680,37681,37682,37683,37684,37685,37686,37687,37688,
37689,37690,37691,37692,37693,37695,37696,37697,37698,37699,37700,37701,37702,
37703,37704,37705,37706,37707,37708,37709,37710,37711,37712,37713,37714,37715,
37716,37717,37718,37719,37720,37721,37722,37723,37724,37725,37726,37727,37728,
37729,37730,37731,37732,37733,37734,37735,37736,37737,37739,28617,28583,28601,
28598,28610,28641,28654,28638,28640,28655,28698,28707,28699,28729,28725,28751,
28766,23424,23428,23445,23443,23461,23480,29999,39582,25652,23524,23534,35120,
23536,36423,35591,36790,36819,36821,36837,36846,36836,36841,36838,36851,36840,
36869,36868,36875,36902,36881,36877,36886,36897,36917,36918,36909,36911,36932,
36945,36946,36944,36968,36952,36962,36955,26297,36980,36989,36994,37000,36995,
37003,24400,24407,24406,24408,23611,21675,23632,23641,23409,23651,23654,32700,
24362,24361,24365,33396,24380,39739,23662,22913,22915,22925,22953,22954,22947,
37740,37741,37742,37743,37744,37745,37746,37747,37748,
37749,37750,37751,37752,37753,37754,37755,37756,37757,37758,37759,37760,37761,
37762,37763,37764,37765,37766,37767,37768,37769,37770,37771,37772,37773,37774,
37776,37777,37778,37779,37780,37781,37782,37783,37784,37785,37786,37787,37788,
37789,37790,37791,37792,37793,37794,37795,37796,37797,37798,37799,37800,37801,
37802,37803,37804,37805,37806,37807,37808,37809,37810,37811,37812,37813,37814,
37815,37816,37817,37818,37819,37820,37821,37822,37823,37824,37825,37826,37827,
37828,37829,37830,37831,37832,37833,37835,37836,37837,22935,22986,22955,22942,
22948,22994,22962,22959,22999,22974,23045,23046,23005,23048,23011,23000,23033,
23052,23049,23090,23092,23057,23075,23059,23104,23143,23114,23125,23100,23138,
23157,33004,23210,23195,23159,23162,23230,23275,23218,23250,23252,23224,23264,
23267,23281,23254,23270,23256,23260,23305,23319,23318,23346,23351,23360,23573,
23580,23386,23397,23411,23377,23379,23394,39541,39543,39544,39546,39551,39549,
39552,39553,39557,39560,39562,39568,39570,39571,39574,39576,39579,39580,39581,
39583,39584,39586,39587,39589,39591,32415,32417,32419,32421,32424,32425,37838,
37839,37840,37841,37842,37843,37844,37845,37847,37848,37849,37850,37851,37852,
37853,37854,37855,37856,37857,37858,37859,37860,37861,37862,37863,37864,37865,
37866,37867,37868,37869,37870,37871,37872,37873,37874,37875,37876,37877,37878,
37879,37880,37881,37882,37883,37884,37885,37886,37887,37888,37889,37890,37891,
37892,37893,37894,37895,37896,37897,37898,37899,37900,37901,37902,37903,37904,
37905,37906,37907,37908,37909,37910,37911,37912,37913,
37914,37915,37916,37917,37918,37919,37920,37921,37922,37923,37924,37925,37926,
37927,37928,37929,37930,37931,37932,37933,37934,32429,32432,32446,32448,32449,
32450,32457,32459,32460,32464,32468,32471,32475,32480,32481,32488,32491,32494,
32495,32497,32498,32525,32502,32506,32507,32510,32513,32514,32515,32519,32520,
32523,32524,32527,32529,32530,32535,32537,32540,32539,32543,32545,32546,32547,
32548,32549,32550,32551,32554,32555,32556,32557,32559,32560,32561,32562,32563,
32565,24186,30079,24027,30014,37013,29582,29585,29614,29602,29599,29647,29634,
29649,29623,29619,29632,29641,29640,29669,29657,39036,29706,29673,29671,29662,
29626,29682,29711,29738,29787,29734,29733,29736,29744,29742,29740,37935,37936,
37937,37938,37939,37940,37941,37942,37943,37944,37945,37946,37947,37948,37949,
37951,37952,37953,37954,37955,37956,37957,37958,37959,37960,37961,37962,37963,
37964,37965,37966,37967,37968,37969,37970,37971,37972,37973,37974,37975,37976,
37977,37978,37979,37980,37981,37982,37983,37984,37985,37986,37987,37988,37989,
37990,37991,37992,37993,37994,37996,37997,37998,37999,38000,38001,38002,38003,
38004,38005,38006,38007,38008,38009,38010,38011,38012,38013,38014,38015,38016,
38017,38018,38019,38020,38033,38038,38040,38087,38095,38099,38100,38106,38118,
38139,38172,38176,29723,29722,29761,29788,29783,29781,29785,29815,29805,29822,
29852,29838,29824,29825,29831,29835,29854,29864,29865,29840,29863,29906,29882,
38890,38891,38892,26444,26451,26462,26440,26473,26533,26503,26474,26483,26520,
26535,26485,26536,26526,26541,26507,26487,26492,26608,
26633,26584,26634,26601,26544,26636,26585,26549,26586,26547,26589,26624,26563,
26552,26594,26638,26561,26621,26674,26675,26720,26721,26702,26722,26692,26724,
26755,26653,26709,26726,26689,26727,26688,26686,26698,26697,26665,26805,26767,
26740,26743,26771,26731,26818,26990,26876,26911,26912,26873,38183,38195,38205,
38211,38216,38219,38229,38234,38240,38254,38260,38261,38263,38264,38265,38266,
38267,38268,38269,38270,38272,38273,38274,38275,38276,38277,38278,38279,38280,
38281,38282,38283,38284,38285,38286,38287,38288,38289,38290,38291,38292,38293,
38294,38295,38296,38297,38298,38299,38300,38301,38302,38303,38304,38305,38306,
38307,38308,38309,38310,38311,38312,38313,38314,38315,38316,38317,38318,38319,
38320,38321,38322,38323,38324,38325,38326,38327,38328,38329,38330,38331,38332,
38333,38334,38335,38336,38337,38338,38339,38340,38341,38342,38343,38344,38345,
38346,38347,26916,26864,26891,26881,26967,26851,26896,26993,26937,26976,26946,
26973,27012,26987,27008,27032,27000,26932,27084,27015,27016,27086,27017,26982,
26979,27001,27035,27047,27067,27051,27053,27092,27057,27073,27082,27103,27029,
27104,27021,27135,27183,27117,27159,27160,27237,27122,27204,27198,27296,27216,
27227,27189,27278,27257,27197,27176,27224,27260,27281,27280,27305,27287,27307,
29495,29522,27521,27522,27527,27524,27538,27539,27533,27546,27547,27553,27562,
36715,36717,36721,36722,36723,36725,36726,36728,36727,36729,36730,36732,36734,
36737,36738,36740,36743,36747,38348,38349,38350,38351,38352,38353,38354,38355,
38356,38357,38358,38359,38360,38361,38362,38363,38364,
38365,38366,38367,38368,38369,38370,38371,38372,38373,38374,38375,38380,38399,
38407,38419,38424,38427,38430,38432,38435,38436,38437,38438,38439,38440,38441,
38443,38444,38445,38447,38448,38455,38456,38457,38458,38462,38465,38467,38474,
38478,38479,38481,38482,38483,38486,38487,38488,38489,38490,38492,38493,38494,
38496,38499,38501,38502,38507,38509,38510,38511,38512,38513,38515,38520,38521,
38522,38523,38524,38525,38526,38527,38528,38529,38530,38531,38532,38535,38537,
38538,36749,36750,36751,36760,36762,36558,25099,25111,25115,25119,25122,25121,
25125,25124,25132,33255,29935,29940,29951,29967,29969,29971,25908,26094,26095,
26096,26122,26137,26482,26115,26133,26112,28805,26359,26141,26164,26161,26166,
26165,32774,26207,26196,26177,26191,26198,26209,26199,26231,26244,26252,26279,
26269,26302,26331,26332,26342,26345,36146,36147,36150,36155,36157,36160,36165,
36166,36168,36169,36167,36173,36181,36185,35271,35274,35275,35276,35278,35279,
35280,35281,29294,29343,29277,29286,29295,29310,29311,29316,29323,29325,29327,
29330,25352,25394,25520,38540,38542,38545,38546,38547,38549,38550,38554,38555,
38557,38558,38559,38560,38561,38562,38563,38564,38565,38566,38568,38569,38570,
38571,38572,38573,38574,38575,38577,38578,38580,38581,38583,38584,38586,38587,
38591,38594,38595,38600,38602,38603,38608,38609,38611,38612,38614,38615,38616,
38617,38618,38619,38620,38621,38622,38623,38625,38626,38627,38628,38629,38630,
38631,38635,38636,38637,38638,38640,38641,38642,38644,38645,38648,38650,38651,
38652,38653,38655,38658,38659,38661,38666,38667,38668,
38672,38673,38674,38676,38677,38679,38680,38681,38682,38683,38685,38687,38688,
25663,25816,32772,27626,27635,27645,27637,27641,27653,27655,27654,27661,27669,
27672,27673,27674,27681,27689,27684,27690,27698,25909,25941,25963,29261,29266,
29270,29232,34402,21014,32927,32924,32915,32956,26378,32957,32945,32939,32941,
32948,32951,32999,33000,33001,33002,32987,32962,32964,32985,32973,32983,26384,
32989,33003,33009,33012,33005,33037,33038,33010,33020,26389,33042,35930,33078,
33054,33068,33048,33074,33096,33100,33107,33140,33113,33114,33137,33120,33129,
33148,33149,33133,33127,22605,23221,33160,33154,33169,28373,33187,33194,33228,
26406,33226,33211,38689,38690,38691,38692,38693,38694,38695,38696,38697,38699,
38700,38702,38703,38705,38707,38708,38709,38710,38711,38714,38715,38716,38717,
38719,38720,38721,38722,38723,38724,38725,38726,38727,38728,38729,38730,38731,
38732,38733,38734,38735,38736,38737,38740,38741,38743,38744,38746,38748,38749,
38751,38755,38756,38758,38759,38760,38762,38763,38764,38765,38766,38767,38768,
38769,38770,38773,38775,38776,38777,38778,38779,38781,38782,38783,38784,38785,
38786,38787,38788,38790,38791,38792,38793,38794,38796,38798,38799,38800,38803,
38805,38806,38807,38809,38810,38811,38812,38813,33217,33190,27428,27447,27449,
27459,27462,27481,39121,39122,39123,39125,39129,39130,27571,24384,27586,35315,
26000,40785,26003,26044,26054,26052,26051,26060,26062,26066,26070,28800,28828,
28822,28829,28859,28864,28855,28843,28849,28904,28874,28944,28947,28950,28975,
28977,29043,29020,29032,28997,29042,29002,29048,29050,
29080,29107,29109,29096,29088,29152,29140,29159,29177,29213,29224,28780,28952,
29030,29113,25150,25149,25155,25160,25161,31035,31040,31046,31049,31067,31068,
31059,31066,31074,31063,31072,31087,31079,31098,31109,31114,31130,31143,31155,
24529,24528,38814,38815,38817,38818,38820,38821,38822,38823,38824,38825,38826,
38828,38830,38832,38833,38835,38837,38838,38839,38840,38841,38842,38843,38844,
38845,38846,38847,38848,38849,38850,38851,38852,38853,38854,38855,38856,38857,
38858,38859,38860,38861,38862,38863,38864,38865,38866,38867,38868,38869,38870,
38871,38872,38873,38874,38875,38876,38877,38878,38879,38880,38881,38882,38883,
38884,38885,38888,38894,38895,38896,38897,38898,38900,38903,38904,38905,38906,
38907,38908,38909,38910,38911,38912,38913,38914,38915,38916,38917,38918,38919,
38920,38921,38922,38923,38924,38925,38926,24636,24669,24666,24679,24641,24665,
24675,24747,24838,24845,24925,25001,24989,25035,25041,25094,32896,32895,27795,
27894,28156,30710,30712,30720,30729,30743,30744,30737,26027,30765,30748,30749,
30777,30778,30779,30751,30780,30757,30764,30755,30761,30798,30829,30806,30807,
30758,30800,30791,30796,30826,30875,30867,30874,30855,30876,30881,30883,30898,
30905,30885,30932,30937,30921,30956,30962,30981,30964,30995,31012,31006,31028,
40859,40697,40699,40700,30449,30468,30477,30457,30471,30472,30490,30498,30489,
30509,30502,30517,30520,30544,30545,30535,30531,30554,30568,38927,38928,38929,
38930,38931,38932,38933,38934,38935,38936,38937,38938,38939,38940,38941,38942,
38943,38944,38945,38946,38947,38948,38949,38950,38951,
38952,38953,38954,38955,38956,38957,38958,38959,38960,38961,38962,38963,38964,
38965,38966,38967,38968,38969,38970,38971,38972,38973,38974,38975,38976,38977,
38978,38979,38980,38981,38982,38983,38984,38985,38986,38987,38988,38989,38990,
38991,38992,38993,38994,38995,38996,38997,38998,38999,39000,39001,39002,39003,
39004,39005,39006,39007,39008,39009,39010,39011,39012,39013,39014,39015,39016,
39017,39018,39019,39020,39021,39022,30562,30565,30591,30605,30589,30592,30604,
30609,30623,30624,30640,30645,30653,30010,30016,30030,30027,30024,30043,30066,
30073,30083,32600,32609,32607,35400,32616,32628,32625,32633,32641,32638,30413,
30437,34866,38021,38022,38023,38027,38026,38028,38029,38031,38032,38036,38039,
38037,38042,38043,38044,38051,38052,38059,38058,38061,38060,38063,38064,38066,
38068,38070,38071,38072,38073,38074,38076,38077,38079,38084,38088,38089,38090,
38091,38092,38093,38094,38096,38097,38098,38101,38102,38103,38105,38104,38107,
38110,38111,38112,38114,38116,38117,38119,38120,38122,39023,39024,39025,39026,
39027,39028,39051,39054,39058,39061,39065,39075,39080,39081,39082,39083,39084,
39085,39086,39087,39088,39089,39090,39091,39092,39093,39094,39095,39096,39097,
39098,39099,39100,39101,39102,39103,39104,39105,39106,39107,39108,39109,39110,
39111,39112,39113,39114,39115,39116,39117,39119,39120,39124,39126,39127,39131,
39132,39133,39136,39137,39138,39139,39140,39141,39142,39145,39146,39147,39148,
39149,39150,39151,39152,39153,39154,39155,39156,39157,39158,39159,39160,39161,
39162,39163,39164,39165,39166,39167,39168,39169,39170,
39171,39172,39173,39174,39175,38121,38123,38126,38127,38131,38132,38133,38135,
38137,38140,38141,38143,38147,38146,38150,38151,38153,38154,38157,38158,38159,
38162,38163,38164,38165,38166,38168,38171,38173,38174,38175,38178,38186,38187,
38185,38188,38193,38194,38196,38198,38199,38200,38204,38206,38207,38210,38197,
38212,38213,38214,38217,38220,38222,38223,38226,38227,38228,38230,38231,38232,
38233,38235,38238,38239,38237,38241,38242,38244,38245,38246,38247,38248,38249,
38250,38251,38252,38255,38257,38258,38259,38202,30695,30700,38601,31189,31213,
31203,31211,31238,23879,31235,31234,31262,31252,39176,39177,39178,39179,39180,
39182,39183,39185,39186,39187,39188,39189,39190,39191,39192,39193,39194,39195,
39196,39197,39198,39199,39200,39201,39202,39203,39204,39205,39206,39207,39208,
39209,39210,39211,39212,39213,39215,39216,39217,39218,39219,39220,39221,39222,
39223,39224,39225,39226,39227,39228,39229,39230,39231,39232,39233,39234,39235,
39236,39237,39238,39239,39240,39241,39242,39243,39244,39245,39246,39247,39248,
39249,39250,39251,39254,39255,39256,39257,39258,39259,39260,39261,39262,39263,
39264,39265,39266,39268,39270,39283,39288,39289,39291,39294,39298,39299,39305,
31289,31287,31313,40655,39333,31344,30344,30350,30355,30361,30372,29918,29920,
29996,40480,40482,40488,40489,40490,40491,40492,40498,40497,40502,40504,40503,
40505,40506,40510,40513,40514,40516,40518,40519,40520,40521,40523,40524,40526,
40529,40533,40535,40538,40539,40540,40542,40547,40550,40551,40552,40553,40554,
40555,40556,40561,40557,40563,30098,30100,30102,30112,
30109,30124,30115,30131,30132,30136,30148,30129,30128,30147,30146,30166,30157,
30179,30184,30182,30180,30187,30183,30211,30193,30204,30207,30224,30208,30213,
30220,30231,30218,30245,30232,30229,30233,39308,39310,39322,39323,39324,39325,
39326,39327,39328,39329,39330,39331,39332,39334,39335,39337,39338,39339,39340,
39341,39342,39343,39344,39345,39346,39347,39348,39349,39350,39351,39352,39353,
39354,39355,39356,39357,39358,39359,39360,39361,39362,39363,39364,39365,39366,
39367,39368,39369,39370,39371,39372,39373,39374,39375,39376,39377,39378,39379,
39380,39381,39382,39383,39384,39385,39386,39387,39388,39389,39390,39391,39392,
39393,39394,39395,39396,39397,39398,39399,39400,39401,39402,39403,39404,39405,
39406,39407,39408,39409,39410,39411,39412,39413,39414,39415,39416,39417,30235,
30268,30242,30240,30272,30253,30256,30271,30261,30275,30270,30259,30285,30302,
30292,30300,30294,30315,30319,32714,31462,31352,31353,31360,31366,31368,31381,
31398,31392,31404,31400,31405,31411,34916,34921,34930,34941,34943,34946,34978,
35014,34999,35004,35017,35042,35022,35043,35045,35057,35098,35068,35048,35070,
35056,35105,35097,35091,35099,35082,35124,35115,35126,35137,35174,35195,30091,
32997,30386,30388,30684,32786,32788,32790,32796,32800,32802,32805,32806,32807,
32809,32808,32817,32779,32821,32835,32838,32845,32850,32873,32881,35203,39032,
39040,39043,39418,39419,39420,39421,39422,39423,39424,39425,39426,39427,39428,
39429,39430,39431,39432,39433,39434,39435,39436,39437,39438,39439,39440,39441,
39442,39443,39444,39445,39446,39447,39448,39449,39450,
39451,39452,39453,39454,39455,39456,39457,39458,39459,39460,39461,39462,39463,
39464,39465,39466,39467,39468,39469,39470,39471,39472,39473,39474,39475,39476,
39477,39478,39479,39480,39481,39482,39483,39484,39485,39486,39487,39488,39489,
39490,39491,39492,39493,39494,39495,39496,39497,39498,39499,39500,39501,39502,
39503,39504,39505,39506,39507,39508,39509,39510,39511,39512,39513,39049,39052,
39053,39055,39060,39066,39067,39070,39071,39073,39074,39077,39078,34381,34388,
34412,34414,34431,34426,34428,34427,34472,34445,34443,34476,34461,34471,34467,
34474,34451,34473,34486,34500,34485,34510,34480,34490,34481,34479,34505,34511,
34484,34537,34545,34546,34541,34547,34512,34579,34526,34548,34527,34520,34513,
34563,34567,34552,34568,34570,34573,34569,34595,34619,34590,34597,34606,34586,
34622,34632,34612,34609,34601,34615,34623,34690,34594,34685,34686,34683,34656,
34672,34636,34670,34699,34643,34659,34684,34660,34649,34661,34707,34735,34728,
34770,39514,39515,39516,39517,39518,39519,39520,39521,39522,39523,39524,39525,
39526,39527,39528,39529,39530,39531,39538,39555,39561,39565,39566,39572,39573,
39577,39590,39593,39594,39595,39596,39597,39598,39599,39602,39603,39604,39605,
39609,39611,39613,39614,39615,39619,39620,39622,39623,39624,39625,39626,39629,
39630,39631,39632,39634,39636,39637,39638,39639,39641,39642,39643,39644,39645,
39646,39648,39650,39651,39652,39653,39655,39656,39657,39658,39660,39662,39664,
39665,39666,39667,39668,39669,39670,39671,39672,39674,39676,39677,39678,39679,
39680,39681,39682,39684,39685,39686,34758,34696,34693,
34733,34711,34691,34731,34789,34732,34741,34739,34763,34771,34749,34769,34752,
34762,34779,34794,34784,34798,34838,34835,34814,34826,34843,34849,34873,34876,
32566,32578,32580,32581,33296,31482,31485,31496,31491,31492,31509,31498,31531,
31503,31559,31544,31530,31513,31534,31537,31520,31525,31524,31539,31550,31518,
31576,31578,31557,31605,31564,31581,31584,31598,31611,31586,31602,31601,31632,
31654,31655,31672,31660,31645,31656,31621,31658,31644,31650,31659,31668,31697,
31681,31692,31709,31706,31717,31718,31722,31756,31742,31740,31759,31766,31755,
39687,39689,39690,39691,39692,39693,39694,39696,39697,39698,39700,39701,39702,
39703,39704,39705,39706,39707,39708,39709,39710,39712,39713,39714,39716,39717,
39718,39719,39720,39721,39722,39723,39724,39725,39726,39728,39729,39731,39732,
39733,39734,39735,39736,39737,39738,39741,39742,39743,39744,39750,39754,39755,
39756,39758,39760,39762,39763,39765,39766,39767,39768,39769,39770,39771,39772,
39773,39774,39775,39776,39777,39778,39779,39780,39781,39782,39783,39784,39785,
39786,39787,39788,39789,39790,39791,39792,39793,39794,39795,39796,39797,39798,
39799,39800,39801,39802,39803,31775,31786,31782,31800,31809,31808,33278,33281,
33282,33284,33260,34884,33313,33314,33315,33325,33327,33320,33323,33336,33339,
33331,33332,33342,33348,33353,33355,33359,33370,33375,33384,34942,34949,34952,
35032,35039,35166,32669,32671,32679,32687,32688,32690,31868,25929,31889,31901,
31900,31902,31906,31922,31932,31933,31937,31943,31948,31949,31944,31941,31959,
31976,33390,26280,32703,32718,32725,32741,32737,32742,
32745,32750,32755,31992,32119,32166,32174,32327,32411,40632,40628,36211,36228,
36244,36241,36273,36199,36205,35911,35913,37194,37200,37198,37199,37220,39804,
39805,39806,39807,39808,39809,39810,39811,39812,39813,39814,39815,39816,39817,
39818,39819,39820,39821,39822,39823,39824,39825,39826,39827,39828,39829,39830,
39831,39832,39833,39834,39835,39836,39837,39838,39839,39840,39841,39842,39843,
39844,39845,39846,39847,39848,39849,39850,39851,39852,39853,39854,39855,39856,
39857,39858,39859,39860,39861,39862,39863,39864,39865,39866,39867,39868,39869,
39870,39871,39872,39873,39874,39875,39876,39877,39878,39879,39880,39881,39882,
39883,39884,39885,39886,39887,39888,39889,39890,39891,39892,39893,39894,39895,
39896,39897,39898,39899,37218,37217,37232,37225,37231,37245,37246,37234,37236,
37241,37260,37253,37264,37261,37265,37282,37283,37290,37293,37294,37295,37301,
37300,37306,35925,40574,36280,36331,36357,36441,36457,36277,36287,36284,36282,
36292,36310,36311,36314,36318,36302,36303,36315,36294,36332,36343,36344,36323,
36345,36347,36324,36361,36349,36372,36381,36383,36396,36398,36387,36399,36410,
36416,36409,36405,36413,36401,36425,36417,36418,36433,36434,36426,36464,36470,
36476,36463,36468,36485,36495,36500,36496,36508,36510,35960,35970,35978,35973,
35992,35988,26011,35286,35294,35290,35292,39900,39901,39902,39903,39904,39905,
39906,39907,39908,39909,39910,39911,39912,39913,39914,39915,39916,39917,39918,
39919,39920,39921,39922,39923,39924,39925,39926,39927,39928,39929,39930,39931,
39932,39933,39934,39935,39936,39937,39938,39939,39940,
39941,39942,39943,39944,39945,39946,39947,39948,39949,39950,39951,39952,39953,
39954,39955,39956,39957,39958,39959,39960,39961,39962,39963,39964,39965,39966,
39967,39968,39969,39970,39971,39972,39973,39974,39975,39976,39977,39978,39979,
39980,39981,39982,39983,39984,39985,39986,39987,39988,39989,39990,39991,39992,
39993,39994,39995,35301,35307,35311,35390,35622,38739,38633,38643,38639,38662,
38657,38664,38671,38670,38698,38701,38704,38718,40832,40835,40837,40838,40839,
40840,40841,40842,40844,40702,40715,40717,38585,38588,38589,38606,38610,30655,
38624,37518,37550,37576,37694,37738,37834,37775,37950,37995,40063,40066,40069,
40070,40071,40072,31267,40075,40078,40080,40081,40082,40084,40085,40090,40091,
40094,40095,40096,40097,40098,40099,40101,40102,40103,40104,40105,40107,40109,
40110,40112,40113,40114,40115,40116,40117,40118,40119,40122,40123,40124,40125,
40132,40133,40134,40135,40138,40139,39996,39997,39998,39999,40000,40001,40002,
40003,40004,40005,40006,40007,40008,40009,40010,40011,40012,40013,40014,40015,
40016,40017,40018,40019,40020,40021,40022,40023,40024,40025,40026,40027,40028,
40029,40030,40031,40032,40033,40034,40035,40036,40037,40038,40039,40040,40041,
40042,40043,40044,40045,40046,40047,40048,40049,40050,40051,40052,40053,40054,
40055,40056,40057,40058,40059,40061,40062,40064,40067,40068,40073,40074,40076,
40079,40083,40086,40087,40088,40089,40093,40106,40108,40111,40121,40126,40127,
40128,40129,40130,40136,40137,40145,40146,40154,40155,40160,40161,40140,40141,
40142,40143,40144,40147,40148,40149,40151,40152,40153,
40156,40157,40159,40162,38780,38789,38801,38802,38804,38831,38827,38819,38834,
38836,39601,39600,39607,40536,39606,39610,39612,39617,39616,39621,39618,39627,
39628,39633,39749,39747,39751,39753,39752,39757,39761,39144,39181,39214,39253,
39252,39647,39649,39654,39663,39659,39675,39661,39673,39688,39695,39699,39711,
39715,40637,40638,32315,40578,40583,40584,40587,40594,37846,40605,40607,40667,
40668,40669,40672,40671,40674,40681,40679,40677,40682,40687,40738,40748,40751,
40761,40759,40765,40766,40772,40163,40164,40165,40166,40167,40168,40169,40170,
40171,40172,40173,40174,40175,40176,40177,40178,40179,40180,40181,40182,40183,
40184,40185,40186,40187,40188,40189,40190,40191,40192,40193,40194,40195,40196,
40197,40198,40199,40200,40201,40202,40203,40204,40205,40206,40207,40208,40209,
40210,40211,40212,40213,40214,40215,40216,40217,40218,40219,40220,40221,40222,
40223,40224,40225,40226,40227,40228,40229,40230,40231,40232,40233,40234,40235,
40236,40237,40238,40239,40240,40241,40242,40243,40244,40245,40246,40247,40248,
40249,40250,40251,40252,40253,40254,40255,40256,40257,40258,57908,57909,57910,
57911,57912,57913,57914,57915,57916,57917,57918,57919,57920,57921,57922,57923,
57924,57925,57926,57927,57928,57929,57930,57931,57932,57933,57934,57935,57936,
57937,57938,57939,57940,57941,57942,57943,57944,57945,57946,57947,57948,57949,
57950,57951,57952,57953,57954,57955,57956,57957,57958,57959,57960,57961,57962,
57963,57964,57965,57966,57967,57968,57969,57970,57971,57972,57973,57974,57975,
57976,57977,57978,57979,57980,57981,57982,57983,57984,
57985,57986,57987,57988,57989,57990,57991,57992,57993,57994,57995,57996,57997,
57998,57999,58000,58001,40259,40260,40261,40262,40263,40264,40265,40266,40267,
40268,40269,40270,40271,40272,40273,40274,40275,40276,40277,40278,40279,40280,
40281,40282,40283,40284,40285,40286,40287,40288,40289,40290,40291,40292,40293,
40294,40295,40296,40297,40298,40299,40300,40301,40302,40303,40304,40305,40306,
40307,40308,40309,40310,40311,40312,40313,40314,40315,40316,40317,40318,40319,
40320,40321,40322,40323,40324,40325,40326,40327,40328,40329,40330,40331,40332,
40333,40334,40335,40336,40337,40338,40339,40340,40341,40342,40343,40344,40345,
40346,40347,40348,40349,40350,40351,40352,40353,40354,58002,58003,58004,58005,
58006,58007,58008,58009,58010,58011,58012,58013,58014,58015,58016,58017,58018,
58019,58020,58021,58022,58023,58024,58025,58026,58027,58028,58029,58030,58031,
58032,58033,58034,58035,58036,58037,58038,58039,58040,58041,58042,58043,58044,
58045,58046,58047,58048,58049,58050,58051,58052,58053,58054,58055,58056,58057,
58058,58059,58060,58061,58062,58063,58064,58065,58066,58067,58068,58069,58070,
58071,58072,58073,58074,58075,58076,58077,58078,58079,58080,58081,58082,58083,
58084,58085,58086,58087,58088,58089,58090,58091,58092,58093,58094,58095,40355,
40356,40357,40358,40359,40360,40361,40362,40363,40364,40365,40366,40367,40368,
40369,40370,40371,40372,40373,40374,40375,40376,40377,40378,40379,40380,40381,
40382,40383,40384,40385,40386,40387,40388,40389,40390,40391,40392,40393,40394,
40395,40396,40397,40398,40399,40400,40401,40402,40403,
40404,40405,40406,40407,40408,40409,40410,40411,40412,40413,40414,40415,40416,
40417,40418,40419,40420,40421,40422,40423,40424,40425,40426,40427,40428,40429,
40430,40431,40432,40433,40434,40435,40436,40437,40438,40439,40440,40441,40442,
40443,40444,40445,40446,40447,40448,40449,40450,58096,58097,58098,58099,58100,
58101,58102,58103,58104,58105,58106,58107,58108,58109,58110,58111,58112,58113,
58114,58115,58116,58117,58118,58119,58120,58121,58122,58123,58124,58125,58126,
58127,58128,58129,58130,58131,58132,58133,58134,58135,58136,58137,58138,58139,
58140,58141,58142,58143,58144,58145,58146,58147,58148,58149,58150,58151,58152,
58153,58154,58155,58156,58157,58158,58159,58160,58161,58162,58163,58164,58165,
58166,58167,58168,58169,58170,58171,58172,58173,58174,58175,58176,58177,58178,
58179,58180,58181,58182,58183,58184,58185,58186,58187,58188,58189,40451,40452,
40453,40454,40455,40456,40457,40458,40459,40460,40461,40462,40463,40464,40465,
40466,40467,40468,40469,40470,40471,40472,40473,40474,40475,40476,40477,40478,
40484,40487,40494,40496,40500,40507,40508,40512,40525,40528,40530,40531,40532,
40534,40537,40541,40543,40544,40545,40546,40549,40558,40559,40562,40564,40565,
40566,40567,40568,40569,40570,40571,40572,40573,40576,40577,40579,40580,40581,
40582,40585,40586,40588,40589,40590,40591,40592,40593,40596,40597,40598,40599,
40600,40601,40602,40603,40604,40606,40608,40609,40610,40611,40612,40613,40615,
40616,40617,40618,58190,58191,58192,58193,58194,58195,58196,58197,58198,58199,
58200,58201,58202,58203,58204,58205,58206,58207,58208,
58209,58210,58211,58212,58213,58214,58215,58216,58217,58218,58219,58220,58221,
58222,58223,58224,58225,58226,58227,58228,58229,58230,58231,58232,58233,58234,
58235,58236,58237,58238,58239,58240,58241,58242,58243,58244,58245,58246,58247,
58248,58249,58250,58251,58252,58253,58254,58255,58256,58257,58258,58259,58260,
58261,58262,58263,58264,58265,58266,58267,58268,58269,58270,58271,58272,58273,
58274,58275,58276,58277,58278,58279,58280,58281,58282,58283,40619,40620,40621,
40622,40623,40624,40625,40626,40627,40629,40630,40631,40633,40634,40636,40639,
40640,40641,40642,40643,40645,40646,40647,40648,40650,40651,40652,40656,40658,
40659,40661,40662,40663,40665,40666,40670,40673,40675,40676,40678,40680,40683,
40684,40685,40686,40688,40689,40690,40691,40692,40693,40694,40695,40696,40698,
40701,40703,40704,40705,40706,40707,40708,40709,40710,40711,40712,40713,40714,
40716,40719,40721,40722,40724,40725,40726,40728,40730,40731,40732,40733,40734,
40735,40737,40739,40740,40741,40742,40743,40744,40745,40746,40747,40749,40750,
40752,40753,58284,58285,58286,58287,58288,58289,58290,58291,58292,58293,58294,
58295,58296,58297,58298,58299,58300,58301,58302,58303,58304,58305,58306,58307,
58308,58309,58310,58311,58312,58313,58314,58315,58316,58317,58318,58319,58320,
58321,58322,58323,58324,58325,58326,58327,58328,58329,58330,58331,58332,58333,
58334,58335,58336,58337,58338,58339,58340,58341,58342,58343,58344,58345,58346,
58347,58348,58349,58350,58351,58352,58353,58354,58355,58356,58357,58358,58359,
58360,58361,58362,58363,58364,58365,58366,58367,58368,
58369,58370,58371,58372,58373,58374,58375,58376,58377,40754,40755,40756,40757,
40758,40760,40762,40764,40767,40768,40769,40770,40771,40773,40774,40775,40776,
40777,40778,40779,40780,40781,40782,40783,40786,40787,40788,40789,40790,40791,
40792,40793,40794,40795,40796,40797,40798,40799,40800,40801,40802,40803,40804,
40805,40806,40807,40808,40809,40810,40811,40812,40813,40814,40815,40816,40817,
40818,40819,40820,40821,40822,40823,40824,40825,40826,40827,40828,40829,40830,
40833,40834,40845,40846,40847,40848,40849,40850,40851,40852,40853,40854,40855,
40856,40860,40861,40862,40865,40866,40867,40868,40869,63788,63865,63893,63975,
63985,58378,58379,58380,58381,58382,58383,58384,58385,58386,58387,58388,58389,
58390,58391,58392,58393,58394,58395,58396,58397,58398,58399,58400,58401,58402,
58403,58404,58405,58406,58407,58408,58409,58410,58411,58412,58413,58414,58415,
58416,58417,58418,58419,58420,58421,58422,58423,58424,58425,58426,58427,58428,
58429,58430,58431,58432,58433,58434,58435,58436,58437,58438,58439,58440,58441,
58442,58443,58444,58445,58446,58447,58448,58449,58450,58451,58452,58453,58454,
58455,58456,58457,58458,58459,58460,58461,58462,58463,58464,58465,58466,58467,
58468,58469,58470,58471,64012,64013,64014,64015,64017,64019,64020,64024,64031,
64032,64033,64035,64036,64039,64040,64041,11905,59414,59415,59416,11908,13427,
13383,11912,11915,59422,13726,13850,13838,11916,11927,14702,14616,59430,14799,
14815,14963,14800,59435,59436,15182,15470,15584,11943,59441,59442,11946,16470,
16735,11950,17207,11955,11958,11959,59451,17329,17324,
11963,17373,17622,18017,17996,59459,18211,18217,18300,18317,11978,18759,18810,
18813,18818,18819,18821,18822,18847,18843,18871,18870,59476,59477,19619,19615,
19616,19617,19575,19618,19731,19732,19733,19734,19735,19736,19737,19886,59492,
58472,58473,58474,58475,58476,58477,58478,58479,58480,58481,58482,58483,58484,
58485,58486,58487,58488,58489,58490,58491,58492,58493,58494,58495,58496,58497,
58498,58499,58500,58501,58502,58503,58504,58505,58506,58507,58508,58509,58510,
58511,58512,58513,58514,58515,58516,58517,58518,58519,58520,58521,58522,58523,
58524,58525,58526,58527,58528,58529,58530,58531,58532,58533,58534,58535,58536,
58537,58538,58539,58540,58541,58542,58543,58544,58545,58546,58547,58548,58549,
58550,58551,58552,58553,58554,58555,58556,58557,58558,58559,58560,58561,58562,
58563,58564,58565,
| 144,966 | 1,867 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/kappendf.c | /*-*- 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 2021 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/stdio/append.h"
/**
* Appends formatted string to buffer w/ kprintf, e.g.
*
* char *b = 0;
* kappendf(&b, "hello %d\n", 123);
* free(b);
*
* @return bytes appended or -1 if `ENOMEM`
* @see appendz(b).i to get buffer length
* @note O(1) amortized buffer growth
* @see kprintf()
*/
ssize_t kappendf(char **b, const char *fmt, ...) {
int n;
va_list va;
va_start(va, fmt);
n = kvappendf(b, fmt, va);
va_end(va);
return n;
}
| 2,307 | 41 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/appendd.c | /*-*- 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 2021 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/assert.h"
#include "libc/dce.h"
#include "libc/macros.internal.h"
#include "libc/mem/mem.h"
#include "libc/stdio/append.h"
#include "libc/str/str.h"
#define W sizeof(size_t)
/**
* Appends data to buffer, e.g.
*
* char *b = 0;
* appendd(&b, "hello", 5);
* free(b);
*
* The resulting buffer is guaranteed to be NUL-terminated, i.e.
* `!b[appendz(b).i]` will be the case.
*
* @param s may contain nul characters and may be null if `l` is zero
* @param l is byte length of `s`
* @return bytes appended (always `l`) or -1 if `ENOMEM`
* @see appendz(b).i to get buffer length
* @note 20% faster than appends()
*/
ssize_t appendd(char **b, const void *s, size_t l) {
char *p;
size_t n;
struct appendz z;
z = appendz((p = *b));
n = ROUNDUP(z.i + l + 1, 8) + W;
if (n > z.n) {
if (!z.n) z.n = W * 2;
while (n > z.n) z.n += z.n >> 1;
z.n = ROUNDUP(z.n, W);
if ((p = realloc(p, z.n))) {
z.n = malloc_usable_size(p);
_unassert(!(z.n & (W - 1)));
*b = p;
} else {
return -1;
}
}
if (l) {
*(char *)mempcpy(p + z.i, s, l) = 0;
} else {
p[z.i] = 0;
}
z.i += l;
if (!IsTiny() && W == 8) z.i |= (size_t)APPEND_COOKIE << 48;
*(size_t *)(p + z.n - W) = z.i;
return l;
}
| 3,114 | 72 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgets_unlocked.c | /*-*- 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/errno.h"
#include "libc/macros.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
/**
* Reads line from stream.
*
* This function is similar to getline() except it'll truncate lines
* exceeding size. The line ending marker is included and may be removed
* using _chomp().
*
* @param s is output buffer
* @param size is capacity of s
* @param f is non-null file object stream pointer
* @return s on success, NULL on error, or NULL if EOF happens when
* zero characters have been read
*/
char *fgets_unlocked(char *s, int size, FILE *f) {
int c, n;
char *p, *b, *t;
p = s;
if (size > 0) {
while (--size > 0) {
if (!IsTiny() && f->beg < f->end) {
b = f->buf + f->beg;
n = MIN(f->end - f->beg, size);
if ((t = memchr(b, '\n', n))) {
n = t + 1 - b;
}
memcpy(p, b, n);
f->beg += n;
size -= n - 1;
p += n;
if (t) break;
} else {
if ((c = fgetc_unlocked(f)) == -1) {
if (ferror_unlocked(f) == EINTR) {
continue;
} else {
break;
}
}
*p++ = c & 255;
if (c == '\n') break;
}
}
if (p > s || f->state != -1) {
*p = '\0';
}
}
return p > s ? s : NULL;
}
| 3,166 | 73 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ungetc.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Pushes byte back to stream.
* @threadsafe
*/
int ungetc(int c, FILE *f) {
int rc;
flockfile(f);
rc = ungetc_unlocked(c, f);
funlockfile(f);
return rc;
}
| 2,077 | 33 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/stderr.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/calls/calls.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/fileno.h"
#include "libc/sysv/consts/o.h"
#include "libc/thread/thread.h"
/**
* Pointer to standard error stream.
*/
FILE *stderr;
static FILE __stderr;
__attribute__((__constructor__)) static void __stderr_init(void) {
stderr = &__stderr;
stderr->fd = STDERR_FILENO;
stderr->bufmode = _IOLBF;
stderr->iomode = O_WRONLY;
stderr->buf = stderr->mem;
stderr->size = sizeof(stderr->mem);
((pthread_mutex_t *)stderr->lock)->_type = PTHREAD_MUTEX_RECURSIVE;
__fflush_register(stderr);
}
| 2,458 | 43 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/stdin.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/calls/calls.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/fileno.h"
#include "libc/sysv/consts/o.h"
#include "libc/thread/thread.h"
/**
* Pointer to standard input stream.
*/
FILE *stdin;
static FILE __stdin;
__attribute__((__constructor__)) static void __stdin_init(void) {
stdin = &__stdin;
stdin->fd = STDIN_FILENO;
stdin->iomode = O_RDONLY;
stdin->buf = stdin->mem;
stdin->size = sizeof(stdin->mem);
((pthread_mutex_t *)stdin->lock)->_type = PTHREAD_MUTEX_RECURSIVE;
__fflush_register(stdin);
}
| 2,416 | 42 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/vprintf.c | /*-*- 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/stdio/stdio.h"
/**
* Formats and writes text to stdout.
* @see printf() for further documentation
*/
int(vprintf)(const char* fmt, va_list va) {
return (vfprintf)(stdout, fmt, va);
}
| 2,040 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ferror.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Returns nonzero if stream is in error state.
*
* @param f is file stream pointer
* @return non-zero if and only if it's an error state
* @see ferror_unlocked(), feof()
* @note EOF doesn't count
* @threadsafe
*/
errno_t ferror(FILE *f) {
int rc;
flockfile(f);
rc = ferror_unlocked(f);
funlockfile(f);
return rc;
}
| 2,242 | 38 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/appendstrlist.c | /*-*- 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/stdio/append.h"
#include "libc/stdio/strlist.internal.h"
int AppendStrList(struct StrList *sl) {
int n2;
char **p2;
if (sl->i == sl->n) {
n2 = sl->n;
if (!n2) n2 = 2;
n2 += n2 >> 1;
if ((p2 = realloc(sl->p, n2 * sizeof(*p2)))) {
sl->p = p2;
sl->n = n2;
} else {
return -1;
}
}
sl->p[sl->i] = 0;
appendr(&sl->p[sl->i], 0);
return sl->i++;
}
| 2,274 | 41 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/iconv.h | #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_ */
| 416 | 15 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/sortstrlist.c | /*-*- 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/alg.h"
#include "libc/stdio/strlist.internal.h"
static int CompareStrings(const void *p1, const void *p2) {
const char *a = *(const char **)p1;
const char *b = *(const char **)p2;
for (; *a == *b; a++, b++) {
if (!*a) break;
}
return (*a & 0xff) - (*b & 0xff);
}
void SortStrList(struct StrList *sl) {
if (sl->i) {
qsort(sl->p, sl->i, sizeof(*sl->p), CompareStrings);
}
}
| 2,251 | 36 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/dtoa.c | /*-*- 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 (C) 1997, 1999, 2001 Lucent Technologies â
â All Rights Reserved â
â â
â Permission to use, copy, modify, and distribute this software and â
â its documentation for any purpose and without fee is hereby â
â granted, provided that the above copyright notice appear in all â
â copies and that both that the copyright notice and this â
â permission notice and warranty disclaimer appear in supporting â
â documentation, and that the name of Lucent or any of its entities â
â not be used in advertising or publicity pertaining to â
â distribution of the software without specific, written prior â
â permission. â
â â
â LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, â
â INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. â
â IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY â
â SPECIAL, 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/assert.h"
#include "libc/fmt/fmt.h"
#include "libc/fmt/fmt.internal.h"
#include "libc/fmt/internal.h"
#include "libc/intrin/bsr.h"
#include "libc/macros.internal.h"
#include "libc/math.h"
#include "libc/str/str.h"
#include "third_party/gdtoa/gdtoa.h"
/**
* @fileoverview Floating-Point Formatting
*
* This implements most of ANSI C's printf floating-point directives.
* omitting L, with %.0g and %.0G giving the shortest decimal string
* that rounds to the number being converted, and with negative
* precisions allowed for %f.
*/
struct FPBits {
uint32_t bits[4];
const FPI *fpi;
int sign;
int ex; // exponent
int kind;
};
union U {
double d;
uint64_t q;
long double ld;
uint32_t ui[4];
uint16_t us[5];
};
static const FPI kFpiDbl = {
.nbits = DBL_MANT_DIG,
.emin = 3 - DBL_MAX_EXP - DBL_MANT_DIG,
.emax = DBL_MAX_EXP - DBL_MANT_DIG,
.rounding = FPI_Round_near,
.sudden_underflow = 0,
};
static const FPI kFpiLdbl = {
.nbits = LDBL_MANT_DIG,
.emin = 3 - LDBL_MAX_EXP - LDBL_MANT_DIG,
.emax = LDBL_MAX_EXP - LDBL_MANT_DIG,
.rounding = FPI_Round_near,
.sudden_underflow = 0,
};
static const char kSpecialFloats[2][2][4] = {
{"INF", "inf"},
{"NAN", "nan"},
};
static void dfpbits(union U *u, struct FPBits *b) {
int ex, i;
b->fpi = &kFpiDbl;
b->sign = u->ui[1] & 0x80000000L;
b->bits[1] = u->ui[1] & 0xfffff;
b->bits[0] = u->ui[0];
if ((ex = (u->ui[1] & 0x7ff00000L) >> 20) != 0) {
if (ex != 0x7ff) {
i = STRTOG_Normal;
b->bits[1] |= 1 << (52 - 32); // set lowest exponent bit
} else if (b->bits[0] | b->bits[1]) {
i = STRTOG_NaN;
} else {
i = STRTOG_Infinite;
}
} else if (b->bits[0] | b->bits[1]) {
i = STRTOG_Denormal;
ex = 1;
} else {
i = STRTOG_Zero;
}
b->kind = i;
b->ex = ex - (0x3ff + 52);
}
static void ldfpbits(union U *u, struct FPBits *b) {
#if LDBL_MANT_DIG == 53
dfpbits(u, b);
#else
int ex, i;
uint16_t sex;
#if LDBL_MANT_DIG == 64
b->bits[3] = 0;
b->bits[2] = 0;
b->bits[1] = ((unsigned)u->us[3] << 16) | u->us[2];
b->bits[0] = ((unsigned)u->us[1] << 16) | u->us[0];
sex = u->us[4];
#elif LDBL_MANT_DIG == 113
b->bits[3] = u->ui[3] & 0xffff;
b->bits[2] = u->ui[2];
b->bits[1] = u->ui[1];
b->bits[0] = u->ui[0];
sex = u->ui[3] >> 16;
#else
#error "unsupported architecture"
#endif
b->fpi = &kFpiLdbl;
b->sign = sex & 0x8000;
if ((ex = sex & 0x7fff) != 0) {
if (ex != 0x7fff) {
i = STRTOG_Normal;
#if LDBL_MANT_DIG == 113
b->bits[3] |= 1 << (112 - 32 * 3); // set lowest exponent bit
#endif
} else if (b->bits[0] | b->bits[1] | b->bits[2] | b->bits[3]) {
i = STRTOG_NaN;
} else {
i = STRTOG_Infinite;
}
} else if (b->bits[0] | b->bits[1] | b->bits[2] | b->bits[3]) {
i = STRTOG_Denormal;
ex = 1;
} else {
i = STRTOG_Zero;
}
b->kind = i;
b->ex = ex - (0x3fff + (LDBL_MANT_DIG - 1));
#endif
}
// returns number of hex digits minus 1, or 0 for zero
static int fpiprec(struct FPBits *b) {
FPI *fpi;
int i, j, k, m;
uint32_t *bits;
if (b->kind == STRTOG_Zero) return (b->ex = 0);
fpi = b->fpi;
bits = b->bits;
for (k = (fpi->nbits - 1) >> 2; k > 0; --k) {
if ((bits[k >> 3] >> 4 * (k & 7)) & 0xf) {
m = k >> 3;
for (i = 0; i <= m; ++i)
if (bits[i]) {
if (i > 0) {
k -= 8 * i;
b->ex += 32 * i;
for (j = i; j <= m; ++j) {
bits[j - i] = bits[j];
}
}
break;
}
for (i = 0; i < 28 && !((bits[0] >> i) & 0xf); i += 4) donothing;
if (i) {
b->ex += i;
m = k >> 3;
k -= (i >> 2);
for (j = 0;; ++j) {
bits[j] >>= i;
if (j == m) break;
bits[j] |= bits[j + 1] << (32 - i);
}
}
break;
}
}
return k;
}
// round to prec hex digits after the "."
// prec1 = incoming precision (after ".")
static int bround(struct FPBits *b, int prec, int prec1) {
uint32_t *bits, t;
int i, inc, j, k, m, n;
m = prec1 - prec;
bits = b->bits;
inc = 0;
k = m - 1;
if ((t = bits[k >> 3] >> (j = (k & 7) * 4)) & 8) {
if (t & 7) goto inc1;
if (j && bits[k >> 3] << (32 - j)) goto inc1;
while (k >= 8) {
k -= 8;
if (bits[k >> 3]) {
inc1:
inc = 1;
goto haveinc;
}
}
}
haveinc:
b->ex += m * 4;
i = m >> 3;
k = prec1 >> 3;
j = i;
if ((n = 4 * (m & 7)))
for (;; ++j) {
bits[j - i] = bits[j] >> n;
if (j == k) break;
bits[j - i] |= bits[j + 1] << (32 - n);
}
else
for (;; ++j) {
bits[j - i] = bits[j];
if (j == k) break;
}
k = prec >> 3;
if (inc) {
for (j = 0; !(++bits[j] & 0xffffffff); ++j) donothing;
if (j > k) {
onebit:
bits[0] = 1;
b->ex += 4 * prec;
return 1;
}
if ((j = prec & 7) < 7 && bits[k] >> (j + 1) * 4) goto onebit;
}
for (i = 0; !(bits[i >> 3] & (0xf << 4 * (i & 7))); ++i) donothing;
if (i) {
b->ex += 4 * i;
prec -= i;
j = i >> 3;
i &= 7;
i *= 4;
for (m = j;; ++m) {
bits[m - j] = bits[m] >> i;
if (m == k) break;
bits[m - j] |= bits[m + 1] << (32 - i);
}
}
return prec;
}
int __fmt_dtoa(int (*out)(const char *, void *, size_t), void *arg, int d,
int flags, int prec, int sign, int width, bool longdouble,
char qchar, unsigned char signbit, const char *alphabet,
va_list va) {
double x;
union U u;
struct FPBits fpb;
char *s, *q, *se, *s0, special[8];
int c, k, i1, ui, bw, rc, bex, sgn, prec1, decpt, consumed;
x = 0;
switch (d) {
case 'F':
case 'f':
if (!(flags & FLAGS_PRECISION)) prec = 6;
if (!longdouble) {
x = va_arg(va, double);
consumed = __FMT_CONSUMED_DOUBLE;
s = s0 = dtoa(x, 3, prec, &decpt, &fpb.sign, &se);
if (decpt == 9999) {
if (s && s[0] == 'N') {
fpb.kind = STRTOG_NaN;
} else {
fpb.kind = STRTOG_Infinite;
}
}
} else {
u.ld = va_arg(va, long double);
consumed = __FMT_CONSUMED_LONG_DOUBLE;
ldfpbits(&u, &fpb);
s = s0 =
gdtoa(fpb.fpi, fpb.ex, fpb.bits, &fpb.kind, 3, prec, &decpt, &se);
}
if (decpt == 9999) {
Format9999:
if (s0) freedtoa(s0);
bzero(special, sizeof(special));
s = q = special;
if (fpb.sign) {
*q++ = '-';
} else if (flags & FLAGS_PLUS) {
*q++ = '+';
} else if (flags & FLAGS_SPACE) {
*q++ = ' ';
}
memcpy(q, kSpecialFloats[fpb.kind == STRTOG_NaN][d >= 'a'], 4);
flags &= ~(FLAGS_PRECISION | FLAGS_PLUS | FLAGS_HASH | FLAGS_SPACE);
prec = 0;
rc = __fmt_stoa(out, arg, s, flags, prec, width, signbit, qchar);
if (rc == -1) return -1;
return consumed;
}
FormatReal:
if (fpb.sign /* && (x || sign) */) sign = '-';
if (prec > 0) width -= prec;
if (width > 0) {
if (sign) --width;
if (decpt <= 0) {
--width;
if (prec > 0) --width;
} else {
if (s == se) decpt = 1;
width -= decpt;
if (prec > 0 || (flags & FLAGS_HASH)) --width;
}
}
if (width > 0 && !(flags & FLAGS_LEFT)) {
if ((flags & FLAGS_ZEROPAD)) {
if (sign) __FMT_PUT(sign);
sign = 0;
do __FMT_PUT('0');
while (--width > 0);
} else
do __FMT_PUT(' ');
while (--width > 0);
}
if (sign) __FMT_PUT(sign);
if (decpt <= 0) {
__FMT_PUT('0');
if (prec > 0 || (flags & FLAGS_HASH)) __FMT_PUT('.');
while (decpt < 0) {
__FMT_PUT('0');
prec--;
decpt++;
}
} else {
do {
if ((c = *s)) {
s++;
} else {
c = '0';
}
__FMT_PUT(c);
} while (--decpt > 0);
if (prec > 0 || (flags & FLAGS_HASH)) __FMT_PUT('.');
}
while (--prec >= 0) {
if ((c = *s)) {
s++;
} else {
c = '0';
}
__FMT_PUT(c);
}
while (--width >= 0) __FMT_PUT(' ');
if (s0) freedtoa(s0);
break;
case 'G':
case 'g':
if (!(flags & FLAGS_PRECISION)) prec = 6;
if (prec < 1) prec = 1;
if (!longdouble) {
x = va_arg(va, double);
consumed = __FMT_CONSUMED_DOUBLE;
s = s0 = dtoa(x, 2, prec, &decpt, &fpb.sign, &se);
if (decpt == 9999) {
if (s && s[0] == 'N') {
fpb.kind = STRTOG_NaN;
} else {
fpb.kind = STRTOG_Infinite;
}
}
} else {
u.ld = va_arg(va, long double);
consumed = __FMT_CONSUMED_LONG_DOUBLE;
ldfpbits(&u, &fpb);
s = s0 = gdtoa(fpb.fpi, fpb.ex, fpb.bits, &fpb.kind, prec ? 2 : 0, prec,
&decpt, &se);
}
if (decpt == 9999) goto Format9999;
c = se - s;
prec1 = prec;
if (!prec) {
prec = c;
prec1 = c + (s[1] || (flags & FLAGS_HASH) ? 5 : 4);
// %.0g gives 10 rather than 1e1
}
if (decpt > -4 && decpt <= prec1) {
if ((flags & FLAGS_HASH))
prec -= decpt;
else
prec = c - decpt;
if (prec < 0) prec = 0;
goto FormatReal;
}
d -= 2;
if (!(flags & FLAGS_HASH) && prec > c) prec = c;
--prec;
goto FormatExpo;
case 'e':
case 'E':
if (!(flags & FLAGS_PRECISION)) prec = 6;
if (prec < 0) prec = 0;
if (!longdouble) {
x = va_arg(va, double);
consumed = __FMT_CONSUMED_DOUBLE;
s = s0 = dtoa(x, 2, prec + 1, &decpt, &fpb.sign, &se);
if (decpt == 9999) {
if (s && s[0] == 'N') {
fpb.kind = STRTOG_NaN;
} else {
fpb.kind = STRTOG_Infinite;
}
}
} else {
u.ld = va_arg(va, long double);
consumed = __FMT_CONSUMED_LONG_DOUBLE;
ldfpbits(&u, &fpb);
s = s0 = gdtoa(fpb.fpi, fpb.ex, fpb.bits, &fpb.kind, prec ? 2 : 0, prec,
&decpt, &se);
}
if (decpt == 9999) goto Format9999;
FormatExpo:
if (fpb.sign /* && (x || sign) */) sign = '-';
if ((width -= prec + 5) > 0) {
if (sign) --width;
if (prec || (flags & FLAGS_HASH)) --width;
}
if ((c = --decpt) < 0) c = -c;
while (c >= 100) {
--width;
c /= 10;
}
if (width > 0 && !(flags & FLAGS_LEFT)) {
if ((flags & FLAGS_ZEROPAD)) {
if (sign) __FMT_PUT(sign);
sign = 0;
do __FMT_PUT('0');
while (--width > 0);
} else
do __FMT_PUT(' ');
while (--width > 0);
}
if (sign) __FMT_PUT(sign);
__FMT_PUT(*s++);
if (prec || (flags & FLAGS_HASH)) __FMT_PUT('.');
while (--prec >= 0) {
if ((c = *s))
s++;
else
c = '0';
__FMT_PUT(c);
}
__FMT_PUT(d);
if (decpt < 0) {
__FMT_PUT('-');
decpt = -decpt;
} else
__FMT_PUT('+');
for (c = 2, k = 10; 10 * k <= decpt; c++, k *= 10) donothing;
for (;;) {
i1 = decpt / k;
__FMT_PUT(i1 + '0');
if (--c <= 0) break;
decpt -= i1 * k;
decpt *= 10;
}
while (--width >= 0) __FMT_PUT(' ');
freedtoa(s0);
break;
case 'A':
alphabet = "0123456789ABCDEFPX";
goto FormatBinary;
case 'a':
alphabet = "0123456789abcdefpx";
FormatBinary:
if (longdouble) {
u.ld = va_arg(va, long double);
consumed = __FMT_CONSUMED_LONG_DOUBLE;
ldfpbits(&u, &fpb);
} else {
u.d = va_arg(va, double);
consumed = __FMT_CONSUMED_DOUBLE;
dfpbits(&u, &fpb);
}
if (fpb.kind == STRTOG_Infinite || fpb.kind == STRTOG_NaN) {
s0 = 0;
goto Format9999;
}
prec1 = fpiprec(&fpb);
if ((flags & FLAGS_PRECISION) && prec < prec1) {
prec1 = bround(&fpb, prec, prec1);
}
bw = 1;
bex = fpb.ex + 4 * prec1;
if (bex) {
if ((i1 = bex) < 0) i1 = -i1;
while (i1 >= 10) {
++bw;
i1 /= 10;
}
}
if (fpb.sign /* && (sign || fpb.kind != STRTOG_Zero) */) {
sign = '-';
}
if ((width -= bw + 5) > 0) {
if (sign) --width;
if (prec1 || (flags & FLAGS_HASH)) --width;
}
if ((width -= prec1) > 0 && !(flags & FLAGS_LEFT) &&
!(flags & FLAGS_ZEROPAD)) {
do __FMT_PUT(' ');
while (--width > 0);
}
if (sign) __FMT_PUT(sign);
__FMT_PUT('0');
__FMT_PUT(alphabet[17]);
if ((flags & FLAGS_ZEROPAD) && width > 0 && !(flags & FLAGS_LEFT)) {
do __FMT_PUT('0');
while (--width > 0);
}
i1 = prec1 & 7;
k = prec1 >> 3;
__FMT_PUT(alphabet[(fpb.bits[k] >> 4 * i1) & 0xf]);
if (prec1 > 0 || (flags & FLAGS_HASH)) __FMT_PUT('.');
if (prec1 > 0) {
prec -= prec1;
while (prec1 > 0) {
if (--i1 < 0) {
if (--k < 0) break;
i1 = 7;
}
__FMT_PUT(alphabet[(fpb.bits[k] >> 4 * i1) & 0xf]);
--prec1;
}
if ((flags & FLAGS_HASH) && prec > 0) {
do __FMT_PUT(0);
while (--prec > 0);
}
}
__FMT_PUT(alphabet[16]);
if (bex < 0) {
__FMT_PUT('-');
bex = -bex;
} else
__FMT_PUT('+');
for (c = 1; 10 * c <= bex; c *= 10) donothing;
for (;;) {
i1 = bex / c;
__FMT_PUT('0' + i1);
if (!--bw) break;
bex -= i1 * c;
bex *= 10;
}
while (--width >= 0) __FMT_PUT(' ');
break;
default:
unreachable;
}
return consumed;
}
| 16,476 | 568 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/stdio.h | #ifndef _STDIO_H
#define _STDIO_H
#include "libc/fmt/pflink.h"
#define L_ctermid 20
#define FILENAME_MAX PATH_MAX
#define FOPEN_MAX 1000
#define TMP_MAX 10000
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/*ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â cosmopolitan § standard i/o ââ¬âââ¼
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ*/
typedef struct FILE {
uint8_t bufmode; /* 0x00 _IOFBF, etc. (ignored if fd=-1) */
bool noclose; /* 0x01 for fake dup() todo delete! */
uint32_t iomode; /* 0x04 O_RDONLY, etc. (ignored if fd=-1) */
int32_t state; /* 0x08 0=OK, -1=EOF, >0=errno */
int fd; /* 0x0c â¥0=fd, -1=closed|buffer */
uint32_t beg; /* 0x10 */
uint32_t end; /* 0x14 */
char *buf; /* 0x18 */
uint32_t size; /* 0x20 */
uint32_t nofree; /* 0x24 */
int pid; /* 0x28 */
char *getln; /* 0x30 */
char lock[16]; /* 0x38 */
struct FILE *next; /* 0x48 */
char mem[BUFSIZ]; /* 0x50 */
} FILE;
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
errno_t ferror(FILE *) paramsnonnull();
void clearerr(FILE *) paramsnonnull();
int feof(FILE *) paramsnonnull();
int getc(FILE *) paramsnonnull();
int putc(int, FILE *) paramsnonnull();
int fflush(FILE *);
int fpurge(FILE *);
int fgetc(FILE *) paramsnonnull();
char *fgetln(FILE *, size_t *) paramsnonnull((1));
int ungetc(int, FILE *) paramsnonnull();
int fileno(FILE *) paramsnonnull() nosideeffect;
int fputc(int, FILE *) paramsnonnull();
int fputs(const char *, FILE *) paramsnonnull();
int fputws(const wchar_t *, FILE *) paramsnonnull();
void flockfile(FILE *) paramsnonnull();
void funlockfile(FILE *) paramsnonnull();
int ftrylockfile(FILE *) paramsnonnull();
char *fgets(char *, int, FILE *) paramsnonnull();
wchar_t *fgetws(wchar_t *, int, FILE *) paramsnonnull();
wint_t putwc(wchar_t, FILE *) paramsnonnull();
wint_t fputwc(wchar_t, FILE *) paramsnonnull();
wint_t putwchar(wchar_t);
wint_t getwchar(void);
wint_t getwc(FILE *) paramsnonnull();
wint_t fgetwc(FILE *) paramsnonnull();
wint_t ungetwc(wint_t, FILE *) paramsnonnull();
int getchar(void);
int putchar(int);
int puts(const char *);
ssize_t getline(char **, size_t *, FILE *) paramsnonnull();
ssize_t getdelim(char **, size_t *, int, FILE *) paramsnonnull();
FILE *fopen(const char *, const char *) paramsnonnull((2)) dontdiscard;
FILE *fdopen(int, const char *) paramsnonnull() dontdiscard;
FILE *fmemopen(void *, size_t, const char *) paramsnonnull((3)) dontdiscard;
FILE *freopen(const char *, const char *, FILE *) paramsnonnull((2, 3));
size_t fread(void *, size_t, size_t, FILE *) paramsnonnull((4));
size_t fwrite(const void *, size_t, size_t, FILE *) paramsnonnull((4));
int fclose(FILE *);
int fseek(FILE *, long, int) paramsnonnull();
long ftell(FILE *) paramsnonnull();
int fseeko(FILE *, int64_t, int) paramsnonnull();
int64_t ftello(FILE *) paramsnonnull();
void rewind(FILE *) paramsnonnull();
int fopenflags(const char *) paramsnonnull();
void setlinebuf(FILE *);
void setbuf(FILE *, char *);
void setbuffer(FILE *, char *, size_t);
int setvbuf(FILE *, char *, int, size_t);
int pclose(FILE *);
char *ctermid(char *);
void perror(const char *) relegated;
typedef uint64_t fpos_t;
char *gets(char *) paramsnonnull();
int fgetpos(FILE *, fpos_t *) paramsnonnull();
int fsetpos(FILE *, const fpos_t *) paramsnonnull();
int system(const char *);
FILE *popen(const char *, const char *);
/*ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â cosmopolitan § standard i/o » formatting ââ¬âââ¼
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ*/
int printf(const char *, ...) printfesque(1)
paramsnonnull((1)) dontthrow nocallback;
int vprintf(const char *, va_list) paramsnonnull() dontthrow nocallback;
int fprintf(FILE *, const char *, ...) printfesque(2)
paramsnonnull((1, 2)) dontthrow nocallback;
int vfprintf(FILE *, const char *, va_list)
paramsnonnull() dontthrow nocallback;
int scanf(const char *, ...) scanfesque(1);
int vscanf(const char *, va_list);
int fscanf(FILE *, const char *, ...) scanfesque(2);
int vfscanf(FILE *, const char *, va_list);
int fwprintf(FILE *, const wchar_t *, ...);
int fwscanf(FILE *, const wchar_t *, ...);
int swprintf(wchar_t *, size_t, const wchar_t *, ...);
int swscanf(const wchar_t *, const wchar_t *, ...);
int vfwprintf(FILE *, const wchar_t *, va_list);
int vfwscanf(FILE *, const wchar_t *, va_list);
int vswprintf(wchar_t *, size_t, const wchar_t *, va_list);
int vswscanf(const wchar_t *, const wchar_t *, va_list);
int vwprintf(const wchar_t *, va_list);
int vwscanf(const wchar_t *, va_list);
int wprintf(const wchar_t *, ...);
int wscanf(const wchar_t *, ...);
int fwide(FILE *, int);
/*ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â cosmopolitan § standard i/o » without mutexes ââ¬âââ¼
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ*/
int getc_unlocked(FILE *) paramsnonnull();
int getchar_unlocked(void);
int putc_unlocked(int, FILE *) paramsnonnull();
int putchar_unlocked(int);
void clearerr_unlocked(FILE *);
int feof_unlocked(FILE *);
int ferror_unlocked(FILE *);
int fileno_unlocked(FILE *);
int fflush_unlocked(FILE *);
int fgetc_unlocked(FILE *);
int fputc_unlocked(int, FILE *);
size_t fread_unlocked(void *, size_t, size_t, FILE *);
size_t fwrite_unlocked(const void *, size_t, size_t, FILE *);
char *fgets_unlocked(char *, int, FILE *);
int fputs_unlocked(const char *, FILE *);
wint_t getwc_unlocked(FILE *);
wint_t getwchar_unlocked(void);
wint_t fgetwc_unlocked(FILE *);
wint_t fputwc_unlocked(wchar_t, FILE *);
wint_t putwc_unlocked(wchar_t, FILE *);
wint_t putwchar_unlocked(wchar_t);
wchar_t *fgetws_unlocked(wchar_t *, int, FILE *);
int fputws_unlocked(const wchar_t *, FILE *);
wint_t ungetwc_unlocked(wint_t, FILE *) paramsnonnull();
int ungetc_unlocked(int, FILE *) paramsnonnull();
int fseeko_unlocked(FILE *, int64_t, int) paramsnonnull();
ssize_t getdelim_unlocked(char **, size_t *, int, FILE *) paramsnonnull();
int fprintf_unlocked(FILE *, const char *, ...) printfesque(2)
paramsnonnull((1, 2)) dontthrow nocallback;
int vfprintf_unlocked(FILE *, const char *, va_list)
paramsnonnull() dontthrow nocallback;
/*ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â cosmopolitan § standard i/o » optimizations ââ¬âââ¼
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ*/
#define getc(f) fgetc(f)
#define getwc(f) fgetwc(f)
#define putc(c, f) fputc(c, f)
#define putwc(c, f) fputwc(c, f)
#define getc_unlocked(f) fgetc_unlocked(f)
#define getwc_unlocked(f) fgetwc_unlocked(f)
#define putc_unlocked(c, f) fputc_unlocked(c, f)
#define putwc_unlocked(c, f) fputwc_unlocked(c, f)
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
/* clang-format off */
#define printf(FMT, ...) (printf)(PFLINK(FMT), ##__VA_ARGS__)
#define vprintf(FMT, VA) (vprintf)(PFLINK(FMT), VA)
#define fprintf(F, FMT, ...) (fprintf)(F, PFLINK(FMT), ##__VA_ARGS__)
#define vfprintf(F, FMT, VA) (vfprintf)(F, PFLINK(FMT), VA)
#define fprintf_unlocked(F, FMT, ...) (fprintf_unlocked)(F, PFLINK(FMT), ##__VA_ARGS__)
#define vfprintf_unlocked(F, FMT, VA) (vfprintf_unlocked)(F, PFLINK(FMT), VA)
#define vscanf(FMT, VA) (vscanf)(SFLINK(FMT), VA)
#define scanf(FMT, ...) (scanf)(SFLINK(FMT), ##__VA_ARGS__)
#define fscanf(F, FMT, ...) (fscanf)(F, SFLINK(FMT), ##__VA_ARGS__)
#define vfscanf(F, FMT, VA) (vfscanf)(F, SFLINK(FMT), VA)
/* clang-format on */
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* _STDIO_H */
| 9,203 | 197 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/setvbuf.c | /*-*- 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/intrin/weaken.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/errfuns.h"
/**
* Tunes buffering settings for an stdio stream.
*
* @param mode may be _IOFBF, _IOLBF, or _IONBF
* @param buf may optionally be non-NULL to set the stream's underlying
* buffer which the caller still owns and won't free, otherwise the
* existing buffer is used
* @param size is ignored if buf is NULL
* @return 0 on success or -1 on error
*/
int setvbuf(FILE *f, char *buf, int mode, size_t size) {
flockfile(f);
if (buf) {
if (!size) size = BUFSIZ;
if (!f->nofree && //
f->buf != buf && //
f->buf != f->mem && //
_weaken(free)) {
_weaken(free)(f->buf);
}
f->buf = buf;
f->size = size;
f->nofree = true;
}
f->bufmode = mode;
funlockfile(f);
return 0;
}
| 2,780 | 54 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/gets.c | /*-*- 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/limits.h"
#include "libc/stdio/stdio.h"
char *gets(char *s) {
return fgets(s, INT_MAX, stdin);
}
| 1,951 | 25 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fflush_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/calls/calls.h"
#include "libc/errno.h"
#include "libc/intrin/bits.h"
#include "libc/intrin/pushpop.h"
#include "libc/macros.internal.h"
#include "libc/mem/arraylist.internal.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/fflush.internal.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/o.h"
#include "libc/thread/thread.h"
void(__fflush_lock)(void) {
pthread_mutex_lock(&__fflush_lock_obj);
}
void(__fflush_unlock)(void) {
pthread_mutex_unlock(&__fflush_lock_obj);
}
static void __stdio_fork_prepare(void) {
FILE *f;
__fflush_lock();
for (int i = 0; i < __fflush.handles.i; ++i) {
if ((f = __fflush.handles.p[i])) {
pthread_mutex_lock((pthread_mutex_t *)f->lock);
}
}
}
static void __stdio_fork_parent(void) {
FILE *f;
for (int i = __fflush.handles.i; i--;) {
if ((f = __fflush.handles.p[i])) {
pthread_mutex_unlock((pthread_mutex_t *)f->lock);
}
}
__fflush_unlock();
}
static void __stdio_fork_child(void) {
FILE *f;
pthread_mutex_t *m;
for (int i = __fflush.handles.i; i--;) {
if ((f = __fflush.handles.p[i])) {
m = (pthread_mutex_t *)f->lock;
bzero(m, sizeof(*m));
m->_type = PTHREAD_MUTEX_RECURSIVE;
}
}
pthread_mutex_init(&__fflush_lock_obj, 0);
}
__attribute__((__constructor__)) static void __stdio_init(void) {
pthread_atfork(__stdio_fork_prepare, __stdio_fork_parent, __stdio_fork_child);
}
/**
* Blocks until data from stream buffer is written out.
*
* @param f is the stream handle, or 0 for all streams
* @return is 0 on success or -1 on error
*/
int fflush_unlocked(FILE *f) {
int rc = 0;
size_t i;
if (!f) {
__fflush_lock();
for (i = __fflush.handles.i; i; --i) {
if ((f = __fflush.handles.p[i - 1])) {
if (fflush(f) == -1) {
rc = -1;
}
}
}
__fflush_unlock();
} else if (f->fd != -1) {
if (__fflush_impl(f) == -1) {
rc = -1;
}
} else if (f->beg && f->beg < f->size) {
f->buf[f->beg] = 0;
}
return rc;
}
textstartup int __fflush_register(FILE *f) {
int rc;
size_t i;
struct StdioFlush *sf;
__fflush_lock();
sf = &__fflush;
if (!sf->handles.p) {
sf->handles.p = sf->handles_initmem;
pushmov(&sf->handles.n, ARRAYLEN(sf->handles_initmem));
__cxa_atexit(fflush_unlocked, 0, 0);
}
for (i = sf->handles.i; i; --i) {
if (!sf->handles.p[i - 1]) {
sf->handles.p[i - 1] = f;
__fflush_unlock();
return 0;
}
}
rc = append(&sf->handles, &f);
__fflush_unlock();
return rc;
}
void __fflush_unregister(FILE *f) {
size_t i;
struct StdioFlush *sf;
__fflush_lock();
sf = &__fflush;
sf = pushpop(sf);
for (i = sf->handles.i; i; --i) {
if (sf->handles.p[i - 1] == f) {
pushmov(&sf->handles.p[i - 1], 0);
break;
}
}
__fflush_unlock();
}
| 4,745 | 144 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/setlinebuf.c | /*-*- 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 2021 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/stdio/stdio.h"
/**
* Puts stream in line-buffering mode.
*/
void setlinebuf(FILE *f) {
setvbuf(f, NULL, _IOLBF, 0);
}
| 2,004 | 28 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/alphasort.c | /*-*- 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/struct/dirent.h"
#include "libc/str/str.h"
int alphasort(const struct dirent **a, const struct dirent **b) {
return strcoll((*a)->d_name, (*b)->d_name);
}
| 2,015 | 25 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/ungetwc_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/intrin/tpenc.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
/**
* Pushes wide character back to stream.
*/
wint_t ungetwc_unlocked(wint_t c, FILE *f) {
char b[6];
unsigned n;
uint64_t w;
if (c == -1) return -1;
n = 0;
w = _tpenc(c);
do {
b[n++] = w;
} while ((w >>= 8));
if (f->beg >= n) {
f->beg -= n;
memcpy(f->buf + f->beg, b, n);
} else if (f->beg + f->end + n <= f->size) {
memmove(f->buf + f->beg + n, f->buf + f->beg, f->end - f->beg);
memcpy(f->buf + f->beg, b, n);
f->end += n;
} else {
return -1;
}
return c;
}
| 2,441 | 48 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/puts.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
static inline int PutsImpl(const char *s, FILE *f) {
size_t n, r;
if ((n = strlen(s))) {
r = fwrite_unlocked(s, 1, n, f);
if (!r) return -1;
if (r < n) return r;
}
if (fputc_unlocked('\n', f) == -1) {
if (feof_unlocked(f)) return n;
return -1;
}
return n + 1;
}
/**
* Writes string w/ trailing newline to stdout.
*
* @return non-negative number on success, or `EOF` on error with
* `errno` set and the `ferror(stdout)` state is updated
*/
int puts(const char *s) {
FILE *f;
int bytes;
f = stdout;
flockfile(f);
bytes = PutsImpl(s, f);
funlockfile(f);
return bytes;
}
| 2,554 | 52 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fgetc.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
/**
* Reads byte from stream.
*
* @param f is non-null file object stream pointer
* @return byte in range 0..255, or -1 w/ errno
* @see fgetc_unlocked()
* @threadsafe
*/
int fgetc(FILE *f) {
int rc;
flockfile(f);
rc = fgetc_unlocked(f);
funlockfile(f);
return rc;
}
| 2,188 | 37 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/appendf.c | /*-*- 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 2021 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/stdio/append.h"
/**
* Appends formatted string to buffer, e.g.
*
* char *b = 0;
* appendf(&b, "hello %d\n", 123);
* free(b);
*
* @return bytes appended or -1 if `ENOMEM`
* @see appendz(b).i to get buffer length
* @note O(1) amortized buffer growth
*/
ssize_t(appendf)(char **b, const char *fmt, ...) {
int n;
va_list va;
va_start(va, fmt);
n = (vappendf)(b, fmt, va);
va_end(va);
return n;
}
| 2,278 | 40 | jart/cosmopolitan | false |
cosmopolitan/libc/stdio/fileno_unlocked.c | /*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-â
âvi: set net ft=c ts=8 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/stdio/stdio.h"
#include "libc/sysv/errfuns.h"
/**
* Returns file descriptor associated with stream.
*
* @param f is file stream object pointer
* @return fd on success or -1 w/ errno;
*/
int fileno_unlocked(FILE *f) {
if (f->fd != -1) {
return f->fd;
} else {
return ebadf();
}
}
| 2,150 | 35 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/basename.c | /*-*- 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/fmt/conv.h"
#include "libc/str/path.h"
#include "libc/str/str.h"
/**
* Returns pointer to last filename component in path, e.g.
*
* path â dirname() â basename()
* âââââââââââââââââââââââââââââââââ
* 0 â . â .
* . â . â .
* .. â . â ..
* / â / â /
* usr â . â usr
* /usr/ â / â usr
* /usr/lib â /usr â lib
*
* Both / and \ are are considered valid component separators on all
* platforms. Trailing slashes are ignored. We don't grant special
* consideration to things like foo/., c:/, \\?\Volume, etc.
*
* @param path is UTF-8 and may be mutated, but not expanded in length
* @return pointer to path, or inside path, or to a special r/o string
* @see dirname()
* @see SUSv2
*/
char *basename(char *path) {
size_t i;
if (path && *path) {
i = strlen(path) - 1;
for (; i && _isdirsep(path[i]); i--) {
path[i] = 0;
}
while (i && !_isdirsep(path[i - 1])) {
i--;
}
return path + i;
} else {
return ".";
}
}
| 3,048 | 60 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/strtoul.c | /*-*- 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/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/strtol.internal.h"
#include "libc/limits.h"
#include "libc/str/str.h"
#include "libc/str/tab.internal.h"
/**
* Decodes unsigned integer from ASCII string.
*
* @param s is a non-null nul-terminated string
* @param endptr if non-null will always receive a pointer to the char
* following the last one this function processed, which is usually
* the NUL byte, or in the case of invalid strings, would point to
* the first invalid character
* @param base can be anywhere between [2,36] or 0 to auto-detect based
* on the the prefixes 0 (octal), 0x (hexadecimal), 0b (binary), or
* decimal (base 10) by default
* @return decoded integer mod 2â¶â´ negated if leading `-`
* @raise ERANGE on overflow
*/
unsigned long strtoul(const char *s, char **endptr, int base) {
char t = 0;
int d, c = *s;
unsigned long x = 0;
CONSUME_SPACES(s, c);
GET_SIGN(s, c, d);
GET_RADIX(s, c, base);
if ((c = kBase36[c & 255]) && --c < base) {
t |= 1;
do {
if (__builtin_mul_overflow(x, base, &x) ||
__builtin_add_overflow(x, c, &x)) {
if (endptr) *endptr = s + 1;
errno = ERANGE;
return ULONG_MAX;
}
} while ((c = kBase36[*++s & 255]) && --c < base);
}
if (t && endptr) *endptr = s;
return d > 0 ? x : -x;
}
| 3,201 | 61 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/ldiv.c | /*-*- 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/fmt/conv.h"
ldiv_t(ldiv)(long num, long den) {
return ldiv(num, den);
}
| 1,926 | 24 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/lldiv.c | /*-*- 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/fmt/conv.h"
lldiv_t(lldiv)(long long num, long long den) {
return lldiv(num, den);
}
| 1,939 | 24 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/bing.internal.h | #ifndef COSMOPOLITAN_LIBC_FMT_BING_H_
#define COSMOPOLITAN_LIBC_FMT_BING_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
int bing(int, int) nosideeffect;
int unbing(int) nosideeffect;
void *unbingbuf(void *, size_t, const char16_t *, int);
void *unbingstr(const char16_t *) paramsnonnull() mallocesque;
void *unhexbuf(void *, size_t, const char *);
void *unhexstr(const char *) mallocesque;
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_FMT_BING_H_ */
| 476 | 14 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/ntoa.c | /*-*- 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 2021 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/assert.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/divmod10.internal.h"
#include "libc/fmt/fmt.internal.h"
#include "libc/fmt/internal.h"
#include "libc/limits.h"
#include "libc/mem/reverse.internal.h"
#define BUFFER_SIZE 144
uint128_t __udivmodti4(uint128_t, uint128_t, uint128_t *);
static int __fmt_ntoa_format(int out(const char *, void *, size_t), void *arg,
char *buf, unsigned len, bool negative,
unsigned log2base, unsigned prec, unsigned width,
unsigned char flags, const char *alphabet) {
unsigned i, prec_width_zeros;
char alternate_form_middle_char, sign_character;
unsigned actual_buf_len;
actual_buf_len = len;
prec_width_zeros = 0;
/* pad leading zeros */
if (width && (flags & FLAGS_ZEROPAD) &&
(negative || (flags & (FLAGS_PLUS | FLAGS_SPACE)))) {
width--;
}
if (len < prec) {
prec_width_zeros += (prec - len);
len = prec;
}
if ((flags & FLAGS_ZEROPAD) && (len < width)) {
prec_width_zeros += (width - len);
len = width;
}
/* handle hash */
if (flags & FLAGS_HASH) {
if ((!(flags & FLAGS_PRECISION) || log2base == 3) && len &&
((len >= prec) || (len >= width)) &&
(prec_width_zeros || buf[len - 1] == '0')) {
if (prec_width_zeros) {
--prec_width_zeros;
}
--len;
if (len < actual_buf_len) {
actual_buf_len = len;
}
if (len && (log2base == 4 || log2base == 1) &&
(prec_width_zeros || buf[len - 1] == '0')) {
if (prec_width_zeros) {
--prec_width_zeros;
}
--len;
if (len < actual_buf_len) {
actual_buf_len = len;
}
}
}
alternate_form_middle_char = '\0';
if ((log2base == 4 || log2base == 1)) {
++len;
alternate_form_middle_char =
alphabet[17]; // x, X or b (for the corresponding conversion
// specifiers)
}
++len;
}
sign_character = '\0';
if (negative) {
++len;
sign_character = '-';
} else if (flags & FLAGS_PLUS) {
++len;
sign_character = '+'; /* ignore the space if the '+' exists */
} else if (flags & FLAGS_SPACE) {
++len;
sign_character = ' ';
}
/* pad spaces up to given width */
if (!(flags & FLAGS_LEFT) && !(flags & FLAGS_ZEROPAD)) {
if (len < width) {
if (__fmt_pad(out, arg, width - len) == -1) return -1;
}
}
if (sign_character != '\0' && out(&sign_character, arg, 1) == -1) return -1;
if (flags & FLAGS_HASH) {
if (out("0", arg, 1) == -1) return -1;
if (alternate_form_middle_char != '\0' &&
out(&alternate_form_middle_char, arg, 1) == -1)
return -1;
}
for (i = 0; i < prec_width_zeros; ++i)
if (out("0", arg, 1) == -1) return -1;
reverse(buf, actual_buf_len);
if (out(buf, arg, actual_buf_len) == -1) return -1;
/* append pad spaces up to given width */
if (flags & FLAGS_LEFT) {
if (len < width) {
if (__fmt_pad(out, arg, width - len) == -1) return -1;
}
}
return 0;
}
int __fmt_ntoa2(int out(const char *, void *, size_t), void *arg,
uint128_t value, bool neg, unsigned log2base, unsigned prec,
unsigned width, unsigned flags, const char *alphabet) {
uint128_t remainder;
unsigned len, count, digit;
char buf[BUFFER_SIZE];
len = 0;
/* we check for log2base != 3 because otherwise we'll print nothing for a
* value of 0 with precision 0 when # mandates that one be printed */
if (!value && log2base != 3) flags &= ~FLAGS_HASH;
if (value || !(flags & FLAGS_PRECISION)) {
count = 0;
do {
if (!log2base) {
if (value <= UINT64_MAX) {
value = DivMod10(value, &digit);
} else {
value = __udivmodti4(value, 10, &remainder);
digit = remainder;
}
} else {
digit = value;
digit &= (1u << log2base) - 1;
value >>= log2base;
}
if ((flags & FLAGS_GROUPING) && count == 3) {
buf[len++] = ',';
count = 1;
} else {
count++;
}
buf[len++] = alphabet[digit];
} while (value);
_npassert(count <= BUFFER_SIZE);
}
return __fmt_ntoa_format(out, arg, buf, len, neg, log2base, prec, width,
flags, alphabet);
}
int __fmt_ntoa(int out(const char *, void *, size_t), void *arg,
uint128_t value, unsigned char signbit, unsigned long log2base,
unsigned long prec, unsigned long width, unsigned char flags,
const char *lang) {
bool neg;
uint128_t sign;
/* ignore '0' flag when prec or minus flag is given */
if (flags & (FLAGS_PRECISION | FLAGS_LEFT)) {
flags &= ~FLAGS_ZEROPAD;
}
/* no plus / space flag for u, x, X, o, b */
if (!(flags & FLAGS_ISSIGNED)) {
flags &= ~(FLAGS_PLUS | FLAGS_SPACE);
}
neg = 0;
sign = 1;
sign <<= signbit;
value &= sign | (sign - 1);
if (flags & FLAGS_ISSIGNED) {
if (value != sign) {
if (value & sign) {
value = ~value + 1;
value &= sign | (sign - 1);
neg = 1;
}
value &= sign - 1;
} else {
neg = 1;
}
}
return __fmt_ntoa2(out, arg, value, neg, log2base, prec, width, flags, lang);
}
| 7,135 | 197 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/uleb128.c | /*-*- 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/fmt/leb128.h"
/**
* Encodes unsigned leb128 integer.
*/
char *uleb128(char *p, uint128_t x) {
int c;
for (;;) {
c = x & 127;
if (!(x >>= 7)) {
*p++ = c;
return p;
} else {
*p++ = c | 128;
}
}
}
| 2,088 | 36 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/unuleb64.c | /*-*- 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/fmt/leb128.h"
/**
* Decodes unsigned integer from array.
*
* @param p is input array
* @param n is capacity of p
* @param x receives number number
* @return bytes decoded or -1 on error
*/
int unuleb64(char *p, size_t n, uint64_t *x) {
int k;
size_t i;
uint64_t t;
for (k = t = i = 0; i < n; ++i, k += 7) {
t |= (uint64_t)(p[i] & 127) << k;
if (~p[i] & 128) {
*x = t;
return i + 1;
}
}
return -1;
}
| 2,294 | 42 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/formatoctal32.c | /*-*- 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 2021 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/fmt/itoa.h"
/**
* Converts unsigned 32-bit integer to octal string.
*
* @param p needs at least 12 bytes
* @param z ensures it starts with zero
* @return pointer to nul byte
*/
char *FormatOctal32(char p[hasatleast 13], uint32_t x, bool z) {
char t;
size_t i, a, b;
i = 0;
z = x && z;
do {
p[i++] = x % 8 + '0';
x = x / 8;
} while (x > 0);
if (z) p[i++] = '0';
p[i] = '\0';
if (i) {
for (a = 0, b = i - 1; a < b; ++a, --b) {
t = p[a];
p[a] = p[b];
p[b] = t;
}
}
return p + i;
}
| 2,392 | 48 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/itoa64.c | /*-*- 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/fmt/conv.h"
#include "libc/fmt/itoa.h"
#include "libc/mem/reverse.internal.h"
dontinline size_t uint64toarray(uint64_t i, char *a, int r) {
size_t j;
j = 0;
do {
a[j++] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % r];
i /= r;
} while (i > 0);
a[j] = '\0';
reverse(a, j);
return j;
}
size_t int64toarray(int64_t i, char *a, int r) {
if (i < 0) {
*a++ = '-';
i = -(uint64_t)i;
}
return uint64toarray(i, a, r);
}
| 2,299 | 42 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/unsleb128.c | /*-*- 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/fmt/leb128.h"
/**
* Decodes a GNU-style varint from a buffer.
*
* The GNU Assembler is able to encode numbers this way, since it's used
* by the DWARF debug format.
*/
int unsleb128(const void *buf, size_t size, int128_t *out) {
int b;
int128_t r, w;
unsigned char c;
const unsigned char *p, *pe;
pe = (p = buf) + size;
r = b = 0;
do {
if (size && p == pe) return -1;
c = *p++;
w = c & 0x7f;
r |= w << b;
b += 7;
} while (c & 0x80);
if (c & 0x40) r |= -1ull << b;
if (out) *out = r;
return p - (const unsigned char *)buf;
}
| 2,423 | 45 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/strtoll_l.c | /*-*- 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/fmt/conv.h"
#include "libc/str/locale.h"
long long strtoll_l(const char *nptr, char **endptr, int base, locale_t l) {
return strtoll(nptr, endptr, base);
}
| 2,010 | 25 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/itoa128radix10.greg.c | /*-*- 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/fmt/conv.h"
#include "libc/fmt/itoa.h"
#include "libc/limits.h"
#include "libc/mem/reverse.internal.h"
uint128_t __udivmodti4(uint128_t, uint128_t, uint128_t *);
/**
* Converts unsigned 128-bit integer to string.
* @param a needs at least 40 bytes
* @return bytes written w/o nul
*/
dontinline size_t uint128toarray_radix10(uint128_t i, char *a) {
size_t j;
uint128_t rem;
j = 0;
do {
i = __udivmodti4(i, 10, &rem);
a[j++] = rem + '0';
} while (i > 0);
a[j] = '\0';
reverse(a, j);
return j;
}
/**
* Converts signed 128-bit integer to string.
* @param a needs at least 41 bytes
* @return bytes written w/o nul
*/
size_t int128toarray_radix10(int128_t i, char *a) {
if (i >= 0) return uint128toarray_radix10(i, a);
*a++ = '-';
return 1 + uint128toarray_radix10(-(uint128_t)i, a);
}
| 2,672 | 54 | jart/cosmopolitan | false |
cosmopolitan/libc/fmt/sleb64.c | /*-*- 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/fmt/leb128.h"
/**
* Encodes signed integer to array.
*
* uleb64 INT64_MAX l: 10ð 3ðð
* zleb64 INT64_MAX l: 13ð 4ðð
* sleb64 INT64_MAX l: 16ð 5ðð
* uleb128 INT64_MAX l: 18ð 6ðð
* zleb128 INT64_MAX l: 18ð 6ðð
* sleb128 INT64_MAX l: 24ð 8ðð
* zleb64 INT64_MIN l: 13ð 4ðð
* sleb64 INT64_MIN l: 16ð 5ðð
* zleb128 INT64_MIN l: 19ð 6ðð
* sleb128 INT64_MIN l: 24ð 8ðð
*
* @param p is output array
* @param x is number
* @return p + i
*/
char *sleb64(char *p, int64_t x) {
int c;
for (;;) {
c = x & 127;
x >>= 7;
if ((x == 0 && !(c & 64)) || (x == -1 && (c & 64))) {
*p++ = c;
return p;
} else {
*p++ = c | 64;
}
}
}
| 2,826 | 52 | jart/cosmopolitan | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.