data_type
large_stringclasses
3 values
source
large_stringclasses
29 values
code
large_stringlengths
98
49.4M
filepath
large_stringlengths
5
161
message
large_stringclasses
234 values
commit
large_stringclasses
234 values
subject
large_stringclasses
418 values
critique
large_stringlengths
101
1.26M
metadata
dict
source
musl
#include <stdio.h> #include <stdarg.h> int snprintf(char *restrict s, size_t n, const char *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vsnprintf(s, n, fmt, ap); va_end(ap); return ret; }
src/stdio/snprintf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> int sprintf(char *restrict s, const char *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vsprintf(s, fmt, ap); va_end(ap); return ret; }
src/stdio/sprintf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> int sscanf(const char *restrict s, const char *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vsscanf(s, fmt, ap); va_end(ap); return ret; } weak_alias(sscanf,__isoc99_sscanf);
src/stdio/sscanf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #undef stderr static unsigned char buf[UNGET]; hidden FILE __stderr_FILE = { .buf = buf+UNGET, .buf_size = 0, .fd = 2, .flags = F_PERM | F_NORD, .lbf = -1, .write = __stdio_write, .seek = __stdio_seek, .close = __stdio_close, .lock = -1, }; FILE *const stderr = &__stderr_FILE; FILE *v...
src/stdio/stderr.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #undef stdin static unsigned char buf[BUFSIZ+UNGET]; hidden FILE __stdin_FILE = { .buf = buf+UNGET, .buf_size = sizeof buf-UNGET, .fd = 0, .flags = F_PERM | F_NOWR, .read = __stdio_read, .seek = __stdio_seek, .close = __stdio_close, .lock = -1, }; FILE *const stdin = &__stdin_FILE; FIL...
src/stdio/stdin.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #undef stdout static unsigned char buf[BUFSIZ+UNGET]; hidden FILE __stdout_FILE = { .buf = buf+UNGET, .buf_size = sizeof buf-UNGET, .fd = 1, .flags = F_PERM | F_NORD, .lbf = '\n', .write = __stdout_write, .seek = __stdio_seek, .close = __stdio_close, .lock = -1, }; FILE *const stdout ...
src/stdio/stdout.c
null
null
null
null
null
source
musl
#include <stdarg.h> #include <wchar.h> int swprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vswprintf(s, n, fmt, ap); va_end(ap); return ret; }
src/stdio/swprintf.c
null
null
null
null
null
source
musl
#include <stdarg.h> #include <wchar.h> int swscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vswscanf(s, fmt, ap); va_end(ap); return ret; } weak_alias(swscanf,__isoc99_swscanf);
src/stdio/swscanf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <fcntl.h> #include <errno.h> #include <sys/stat.h> #include <limits.h> #include <string.h> #include <stdlib.h> #include "syscall.h" #define MAXTRIES 100 char *tempnam(const char *dir, const char *pfx) { char s[PATH_MAX]; size_t l, dl, pl; int try; int r; if (!dir) dir = P_tmpdir; if...
src/stdio/tempnam.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <fcntl.h> #include <stdlib.h> #include "stdio_impl.h" #define MAXTRIES 100 FILE *tmpfile(void) { char s[] = "/tmp/tmpfile_XXXXXX"; int fd; FILE *f; int try; for (try=0; try<MAXTRIES; try++) { __randname(s+13); fd = sys_open(s, O_RDWR|O_CREAT|O_EXCL, 0600); if (fd >= 0) { #ifdef ...
src/stdio/tmpfile.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <fcntl.h> #include <errno.h> #include <sys/stat.h> #include <string.h> #include <stdlib.h> #include "syscall.h" #define MAXTRIES 100 char *tmpnam(char *buf) { static char internal[L_tmpnam]; char s[] = "/tmp/tmpnam_XXXXXX"; int try; int r; for (try=0; try<MAXTRIES; try++) { __randna...
src/stdio/tmpnam.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" int ungetc(int c, FILE *f) { if (c == EOF) return c; FLOCK(f); if (!f->rpos) __toread(f); if (!f->rpos || f->rpos <= f->buf - UNGET) { FUNLOCK(f); return EOF; } *--f->rpos = c; f->flags &= ~F_EOF; FUNLOCK(f); return (unsigned char)c; }
src/stdio/ungetc.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "locale_impl.h" #include <wchar.h> #include <limits.h> #include <ctype.h> #include <string.h> wint_t ungetwc(wint_t c, FILE *f) { unsigned char mbc[MB_LEN_MAX]; int l; locale_t *ploc = &CURRENT_LOCALE, loc = *ploc; FLOCK(f); if (f->mode <= 0) fwide(f, 1); *ploc = f->locale; i...
src/stdio/ungetwc.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <stdio.h> #include <stdarg.h> #include <stdlib.h> int vasprintf(char **s, const char *fmt, va_list ap) { va_list ap2; va_copy(ap2, ap); int l = vsnprintf(0, 0, fmt, ap2); va_end(ap2); if (l<0 || !(*s=malloc(l+1U))) return -1; return vsnprintf(*s, l+1U, fmt, ap); }
src/stdio/vasprintf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" int vdprintf(int fd, const char *restrict fmt, va_list ap) { FILE f = { .fd = fd, .lbf = EOF, .write = __stdio_write, .buf = (void *)fmt, .buf_size = 0, .lock = -1 }; return vfprintf(&f, fmt, ap); }
src/stdio/vdprintf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <errno.h> #include <ctype.h> #include <limits.h> #include <string.h> #include <stdarg.h> #include <stddef.h> #include <stdlib.h> #include <wchar.h> #include <inttypes.h> #include <math.h> #include <float.h> /* Some useful macros */ #define MAX(a,b) ((a)>(b) ? (a) : (b)) #define MIN(a,...
src/stdio/vfprintf.c
null
null
null
null
null
source
musl
#include <stdlib.h> #include <stdarg.h> #include <ctype.h> #include <wchar.h> #include <wctype.h> #include <limits.h> #include <string.h> #include <stdint.h> #include "stdio_impl.h" #include "shgetc.h" #include "intscan.h" #include "floatscan.h" #define SIZE_hh -2 #define SIZE_h -1 #define SIZE_def 0 #define SIZE_l ...
src/stdio/vfscanf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <errno.h> #include <ctype.h> #include <limits.h> #include <string.h> #include <stdarg.h> #include <stddef.h> #include <stdlib.h> #include <wchar.h> #include <inttypes.h> /* Convenient bit representation for modifier flags, which all fall * within 31 codepoints of the space character. ...
src/stdio/vfwprintf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <ctype.h> #include <wchar.h> #include <wctype.h> #include <limits.h> #include <string.h> #include "stdio_impl.h" #include "shgetc.h" #include "intscan.h" #include "floatscan.h" #define SIZE_hh -2 #define SIZE_h -1 #define SIZE_def 0 #define SIZE_l ...
src/stdio/vfwscanf.c
null
null
null
null
null
source
musl
#include <stdio.h> int vprintf(const char *restrict fmt, va_list ap) { return vfprintf(stdout, fmt, ap); }
src/stdio/vprintf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> int vscanf(const char *restrict fmt, va_list ap) { return vfscanf(stdin, fmt, ap); } weak_alias(vscanf,__isoc99_vscanf);
src/stdio/vscanf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <limits.h> #include <string.h> #include <errno.h> #include <stdint.h> struct cookie { char *s; size_t n; }; #define MIN(a, b) ((a) < (b) ? (a) : (b)) static size_t sn_write(FILE *f, const unsigned char *s, size_t l) { struct cookie *c = f->cookie; size_t k = MIN(c->n, f->wpos - f...
src/stdio/vsnprintf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <limits.h> int vsprintf(char *restrict s, const char *restrict fmt, va_list ap) { return vsnprintf(s, INT_MAX, fmt, ap); }
src/stdio/vsprintf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <string.h> static size_t string_read(FILE *f, unsigned char *buf, size_t len) { char *src = f->cookie; size_t k = len+256; char *end = memchr(src, 0, k); if (end) k = end-src; if (k < len) len = k; memcpy(buf, src, len); f->rpos = (void *)(src+len); f->rend = (void *)(src+k); ...
src/stdio/vsscanf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <limits.h> #include <errno.h> #include <stdint.h> #include <stdlib.h> #include <wchar.h> struct cookie { wchar_t *ws; size_t l; }; static size_t sw_write(FILE *f, const unsigned char *s, size_t l) { size_t l0 = l; int i = 0; struct cookie *c = f->cookie; if (s!=f->wbase && sw_wr...
src/stdio/vswprintf.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include <wchar.h> static size_t wstring_read(FILE *f, unsigned char *buf, size_t len) { const wchar_t *src = f->cookie; size_t k; if (!src) return 0; k = wcsrtombs((void *)f->buf, &src, f->buf_size, 0); if (k==(size_t)-1) { f->rpos = f->rend = 0; return 0; } f->rpos = f->buf; f-...
src/stdio/vswscanf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <wchar.h> int vwprintf(const wchar_t *restrict fmt, va_list ap) { return vfwprintf(stdout, fmt, ap); }
src/stdio/vwprintf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> #include <wchar.h> int vwscanf(const wchar_t *restrict fmt, va_list ap) { return vfwscanf(stdin, fmt, ap); } weak_alias(vwscanf,__isoc99_vwscanf);
src/stdio/vwscanf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> #include <wchar.h> int wprintf(const wchar_t *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vwprintf(fmt, ap); va_end(ap); return ret; }
src/stdio/wprintf.c
null
null
null
null
null
source
musl
#include <stdio.h> #include <stdarg.h> #include <wchar.h> int wscanf(const wchar_t *restrict fmt, ...) { int ret; va_list ap; va_start(ap, fmt); ret = vwscanf(fmt, ap); va_end(ap); return ret; } weak_alias(wscanf,__isoc99_wscanf);
src/stdio/wscanf.c
null
null
null
null
null
source
musl
#include <stdlib.h> #include <ctype.h> int atoi(const char *s) { int n=0, neg=0; while (isspace(*s)) s++; switch (*s) { case '-': neg=1; case '+': s++; } /* Compute n as a negative number to avoid overflow on INT_MIN */ while (isdigit(*s)) n = 10*n - (*s++ - '0'); return neg ? n : -n; }
src/stdlib/atoi.c
null
null
null
null
null
source
musl
#include <stdlib.h> #include <ctype.h> long atol(const char *s) { long n=0; int neg=0; while (isspace(*s)) s++; switch (*s) { case '-': neg=1; case '+': s++; } /* Compute n as a negative number to avoid overflow on LONG_MIN */ while (isdigit(*s)) n = 10*n - (*s++ - '0'); return neg ? n : -n; }
src/stdlib/atol.c
null
null
null
null
null
source
musl
#include <stdlib.h> #include <ctype.h> long long atoll(const char *s) { long long n=0; int neg=0; while (isspace(*s)) s++; switch (*s) { case '-': neg=1; case '+': s++; } /* Compute n as a negative number to avoid overflow on LLONG_MIN */ while (isdigit(*s)) n = 10*n - (*s++ - '0'); return neg ? n : -n; }
src/stdlib/atoll.c
null
null
null
null
null
source
musl
#include <stdlib.h> void *bsearch(const void *key, const void *base, size_t nel, size_t width, int (*cmp)(const void *, const void *)) { void *try; int sign; while (nel > 0) { try = (char *)base + width*(nel/2); sign = cmp(key, try); if (sign < 0) { nel /= 2; } else if (sign > 0) { base = (char *)try ...
src/stdlib/bsearch.c
null
null
null
null
null
source
musl
#include <inttypes.h> imaxdiv_t imaxdiv(intmax_t num, intmax_t den) { return (imaxdiv_t){ num/den, num%den }; }
src/stdlib/imaxdiv.c
null
null
null
null
null
source
musl
#include <stdlib.h> lldiv_t lldiv(long long num, long long den) { return (lldiv_t){ num/den, num%den }; }
src/stdlib/lldiv.c
null
null
null
null
null
source
musl
/* Copyright (C) 2011 by Lynn Ochs * * 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 per...
src/stdlib/qsort.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <stdlib.h> typedef int (*cmpfun)(const void *, const void *); static int wrapper_cmp(const void *v1, const void *v2, void *cmp) { return ((cmpfun)cmp)(v1, v2); } void qsort(void *base, size_t nel, size_t width, cmpfun cmp) { __qsort_r(base, nel, width, wrapper_cmp, (void *)cmp); }
src/stdlib/qsort_nr.c
null
null
null
null
null
source
musl
#include <stdlib.h> #include "shgetc.h" #include "floatscan.h" #include "stdio_impl.h" static long double strtox(const char *s, char **p, int prec) { FILE f; sh_fromstring(&f, s); shlim(&f, 0); long double y = __floatscan(&f, prec, 1); off_t cnt = shcnt(&f); if (p) *p = cnt ? (char *)s + cnt : (char *)s; return...
src/stdlib/strtod.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "intscan.h" #include "shgetc.h" #include <inttypes.h> #include <limits.h> #include <ctype.h> static unsigned long long strtox(const char *s, char **p, int base, unsigned long long lim) { FILE f; sh_fromstring(&f, s); shlim(&f, 0); unsigned long long y = __intscan(&f, base, 1, lim);...
src/stdlib/strtol.c
null
null
null
null
null
source
musl
#include "shgetc.h" #include "floatscan.h" #include "stdio_impl.h" #include <wchar.h> #include <wctype.h> /* This read function heavily cheats. It knows: * (1) len will always be 1 * (2) non-ascii characters don't matter */ static size_t do_read(FILE *f, unsigned char *buf, size_t len) { size_t i; const wchar_t...
src/stdlib/wcstod.c
null
null
null
null
null
source
musl
#include "stdio_impl.h" #include "intscan.h" #include "shgetc.h" #include <inttypes.h> #include <limits.h> #include <wctype.h> #include <wchar.h> /* This read function heavily cheats. It knows: * (1) len will always be 1 * (2) non-ascii characters don't matter */ static size_t do_read(FILE *f, unsigned char *buf,...
src/stdlib/wcstol.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <string.h> #include <strings.h> int bcmp(const void *s1, const void *s2, size_t n) { return memcmp(s1, s2, n); }
src/string/bcmp.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <string.h> #include <strings.h> void bcopy(const void *s1, void *s2, size_t n) { memmove(s2, s1, n); }
src/string/bcopy.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <string.h> #include <strings.h> void bzero(void *s, size_t n) { memset(s, 0, n); }
src/string/bzero.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <string.h> void explicit_bzero(void *d, size_t n) { d = memset(d, 0, n); __asm__ __volatile__ ("" : : "r"(d) : "memory"); }
src/string/explicit_bzero.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <string.h> #include <strings.h> char *index(const char *s, int c) { return strchr(s, c); }
src/string/index.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> #include <limits.h> #define ALIGN (sizeof(size_t)-1) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n) { unsigned char *d = dest;...
src/string/memccpy.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> #include <limits.h> #define SS (sizeof(size_t)) #define ALIGN (sizeof(size_t)-1) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) void *memchr(const void *src, int c, size_t n) { const unsigned char *s = sr...
src/string/memchr.c
null
null
null
null
null
source
musl
#include <string.h> int memcmp(const void *vl, const void *vr, size_t n) { const unsigned char *l=vl, *r=vr; for (; n && *l == *r; n--, l++, r++); return n ? *l-*r : 0; }
src/string/memcmp.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> #include <endian.h> void *memcpy(void *restrict dest, const void *restrict src, size_t n) { unsigned char *d = dest; const unsigned char *s = src; #ifdef __GNUC__ #if __BYTE_ORDER == __LITTLE_ENDIAN #define LS >> #define RS << #else #define LS << #define RS >> #endif typed...
src/string/memcpy.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <string.h> #include <stdint.h> static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) { uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++) if (hw == nw) return (char *)h-2; return hw == nw ? (char *)h-2 : 0; } ...
src/string/memmem.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> #ifdef __GNUC__ typedef __attribute__((__may_alias__)) size_t WT; #define WS (sizeof(WT)) #endif void *memmove(void *dest, const void *src, size_t n) { char *d = dest; const char *s = src; if (d==s) return d; if ((uintptr_t)s-(uintptr_t)d-n <= -2*n) return memcpy(d, s, n);...
src/string/memmove.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <string.h> void *mempcpy(void *dest, const void *src, size_t n) { return (char *)memcpy(dest, src, n) + n; }
src/string/mempcpy.c
null
null
null
null
null
source
musl
#include <string.h> void *__memrchr(const void *m, int c, size_t n) { const unsigned char *s = m; c = (unsigned char)c; while (n--) if (s[n]==c) return (void *)(s+n); return 0; } weak_alias(__memrchr, memrchr);
src/string/memrchr.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> void *memset(void *dest, int c, size_t n) { unsigned char *s = dest; size_t k; /* Fill head and tail with minimal branching. Each * conditional ensures that all the subsequently used * offsets are well-defined and in the dest region. */ if (!n) return dest; s[0] = c; ...
src/string/memset.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <string.h> #include <strings.h> char *rindex(const char *s, int c) { return strrchr(s, c); }
src/string/rindex.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> #include <limits.h> #define ALIGN (sizeof(size_t)) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) char *__stpcpy(char *restrict d, const char *restrict s) { #ifdef __GNUC__ typedef size_t __attribute__((_...
src/string/stpcpy.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> #include <limits.h> #define ALIGN (sizeof(size_t)-1) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) char *__stpncpy(char *restrict d, const char *restrict s, size_t n) { #ifdef __GNUC__ typedef size_t __a...
src/string/stpncpy.c
null
null
null
null
null
source
musl
#include <strings.h> #include <ctype.h> int strcasecmp(const char *_l, const char *_r) { const unsigned char *l=(void *)_l, *r=(void *)_r; for (; *l && *r && (*l == *r || tolower(*l) == tolower(*r)); l++, r++); return tolower(*l) - tolower(*r); } int __strcasecmp_l(const char *l, const char *r, locale_t loc) { re...
src/string/strcasecmp.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <string.h> char *strcasestr(const char *h, const char *n) { size_t l = strlen(n); if (!l) return (char *)h; for (; *h; h++) if (!strncasecmp(h, n, l)) return (char *)h; return 0; }
src/string/strcasestr.c
null
null
null
null
null
source
musl
#include <string.h> char *strcat(char *restrict dest, const char *restrict src) { strcpy(dest + strlen(dest), src); return dest; }
src/string/strcat.c
null
null
null
null
null
source
musl
#include <string.h> char *strchr(const char *s, int c) { char *r = __strchrnul(s, c); return *(unsigned char *)r == (unsigned char)c ? r : 0; }
src/string/strchr.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> #include <limits.h> #define ALIGN (sizeof(size_t)) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) char *__strchrnul(const char *s, int c) { c = (unsigned char)c; if (!c) return (char *)s + strlen(s); #i...
src/string/strchrnul.c
null
null
null
null
null
source
musl
#include <string.h> int strcmp(const char *l, const char *r) { for (; *l==*r && *l; l++, r++); return *(unsigned char *)l - *(unsigned char *)r; }
src/string/strcmp.c
null
null
null
null
null
source
musl
#include <string.h> char *strcpy(char *restrict dest, const char *restrict src) { __stpcpy(dest, src); return dest; }
src/string/strcpy.c
null
null
null
null
null
source
musl
#include <string.h> #define BITOP(a,b,op) \ ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) size_t strcspn(const char *s, const char *c) { const char *a = s; size_t byteset[32/sizeof(size_t)]; if (!c[0] || !c[1]) return __strchrnul(s, *c)-a; memset(byteset, 0, sizeof byteset); f...
src/string/strcspn.c
null
null
null
null
null
source
musl
#include <stdlib.h> #include <string.h> char *strdup(const char *s) { size_t l = strlen(s); char *d = malloc(l+1); if (!d) return NULL; return memcpy(d, s, l+1); }
src/string/strdup.c
null
null
null
null
null
source
musl
#include <string.h> #include <errno.h> int strerror_r(int err, char *buf, size_t buflen) { char *msg = strerror(err); size_t l = strlen(msg); if (l >= buflen) { if (buflen) { memcpy(buf, msg, buflen-1); buf[buflen-1] = 0; } return ERANGE; } memcpy(buf, msg, l+1); return 0; } weak_alias(strerror_r, _...
src/string/strerror_r.c
null
null
null
null
null
source
musl
#define _BSD_SOURCE #include <string.h> #include <stdint.h> #include <limits.h> #define ALIGN (sizeof(size_t)-1) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) size_t strlcpy(char *d, const char *s, size_t n) { char *d0 = d; size_t *wd; if (...
src/string/strlcpy.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> #include <limits.h> #define ALIGN (sizeof(size_t)) #define ONES ((size_t)-1/UCHAR_MAX) #define HIGHS (ONES * (UCHAR_MAX/2+1)) #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) size_t strlen(const char *s) { const char *a = s; #ifdef __GNUC__ typedef size_t __attribute__((__may_ali...
src/string/strlen.c
null
null
null
null
null
source
musl
#include <strings.h> #include <ctype.h> int strncasecmp(const char *_l, const char *_r, size_t n) { const unsigned char *l=(void *)_l, *r=(void *)_r; if (!n--) return 0; for (; *l && *r && n && (*l == *r || tolower(*l) == tolower(*r)); l++, r++, n--); return tolower(*l) - tolower(*r); } int __strncasecmp_l(const ...
src/string/strncasecmp.c
null
null
null
null
null
source
musl
#include <string.h> char *strncat(char *restrict d, const char *restrict s, size_t n) { char *a = d; d += strlen(d); while (n && *s) n--, *d++ = *s++; *d++ = 0; return a; }
src/string/strncat.c
null
null
null
null
null
source
musl
#include <string.h> int strncmp(const char *_l, const char *_r, size_t n) { const unsigned char *l=(void *)_l, *r=(void *)_r; if (!n--) return 0; for (; *l && *r && n && *l == *r ; l++, r++, n--); return *l - *r; }
src/string/strncmp.c
null
null
null
null
null
source
musl
#include <string.h> char *strncpy(char *restrict d, const char *restrict s, size_t n) { __stpncpy(d, s, n); return d; }
src/string/strncpy.c
null
null
null
null
null
source
musl
#include <stdlib.h> #include <string.h> char *strndup(const char *s, size_t n) { size_t l = strnlen(s, n); char *d = malloc(l+1); if (!d) return NULL; memcpy(d, s, l); d[l] = 0; return d; }
src/string/strndup.c
null
null
null
null
null
source
musl
#include <string.h> size_t strnlen(const char *s, size_t n) { const char *p = memchr(s, 0, n); return p ? p-s : n; }
src/string/strnlen.c
null
null
null
null
null
source
musl
#include <string.h> char *strrchr(const char *s, int c) { return __memrchr(s, c, strlen(s) + 1); }
src/string/strrchr.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <string.h> char *strsep(char **str, const char *sep) { char *s = *str, *end; if (!s) return NULL; end = s + strcspn(s, sep); if (*end) *end++ = 0; else end = 0; *str = end; return s; }
src/string/strsep.c
null
null
null
null
null
source
musl
#include <signal.h> #include <string.h> #include "locale_impl.h" #if (SIGHUP == 1) && (SIGINT == 2) && (SIGQUIT == 3) && (SIGILL == 4) \ && (SIGTRAP == 5) && (SIGABRT == 6) && (SIGBUS == 7) && (SIGFPE == 8) \ && (SIGKILL == 9) && (SIGUSR1 == 10) && (SIGSEGV == 11) && (SIGUSR2 == 12) \ && (SIGPIPE == 13) && (SIGALRM...
src/string/strsignal.c
null
null
null
null
null
source
musl
#include <string.h> #include <stdint.h> static char *twobyte_strstr(const unsigned char *h, const unsigned char *n) { uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; for (h++; *h && hw != nw; hw = hw<<8 | *++h); return *h ? (char *)h-1 : 0; } static char *threebyte_strstr(const unsigned char *h, const unsigned ...
src/string/strstr.c
null
null
null
null
null
source
musl
#include <string.h> char *strtok(char *restrict s, const char *restrict sep) { static char *p; if (!s && !(s = p)) return NULL; s += strspn(s, sep); if (!*s) return p = 0; p = s + strcspn(s, sep); if (*p) *p++ = 0; else p = 0; return s; }
src/string/strtok.c
null
null
null
null
null
source
musl
#include <string.h> char *strtok_r(char *restrict s, const char *restrict sep, char **restrict p) { if (!s && !(s = *p)) return NULL; s += strspn(s, sep); if (!*s) return *p = 0; *p = s + strcspn(s, sep); if (**p) *(*p)++ = 0; else *p = 0; return s; }
src/string/strtok_r.c
null
null
null
null
null
source
musl
#define _GNU_SOURCE #include <ctype.h> #include <string.h> int strverscmp(const char *l0, const char *r0) { const unsigned char *l = (const void *)l0; const unsigned char *r = (const void *)r0; size_t i, dp, j; int z = 1; /* Find maximal matching prefix and track its maximal digit * suffix and whether those di...
src/string/strverscmp.c
null
null
null
null
null
source
musl
#include <unistd.h> void swab(const void *restrict _src, void *restrict _dest, ssize_t n) { const char *src = _src; char *dest = _dest; for (; n>1; n-=2) { dest[0] = src[1]; dest[1] = src[0]; dest += 2; src += 2; } }
src/string/swab.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcpcpy(wchar_t *restrict d, const wchar_t *restrict s) { return wcscpy(d, s) + wcslen(s); }
src/string/wcpcpy.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcpncpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n) { return wcsncpy(d, s, n) + wcsnlen(s, n); }
src/string/wcpncpy.c
null
null
null
null
null
source
musl
#include <wchar.h> #include <wctype.h> int wcscasecmp(const wchar_t *l, const wchar_t *r) { return wcsncasecmp(l, r, -1); }
src/string/wcscasecmp.c
null
null
null
null
null
source
musl
#include <wchar.h> int wcscasecmp_l(const wchar_t *l, const wchar_t *r, locale_t locale) { return wcscasecmp(l, r); }
src/string/wcscasecmp_l.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcscat(wchar_t *restrict dest, const wchar_t *restrict src) { wcscpy(dest + wcslen(dest), src); return dest; }
src/string/wcscat.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcschr(const wchar_t *s, wchar_t c) { if (!c) return (wchar_t *)s + wcslen(s); for (; *s && *s != c; s++); return *s ? (wchar_t *)s : 0; }
src/string/wcschr.c
null
null
null
null
null
source
musl
#include <wchar.h> int wcscmp(const wchar_t *l, const wchar_t *r) { for (; *l==*r && *l && *r; l++, r++); return *l < *r ? -1 : *l > *r; }
src/string/wcscmp.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcscpy(wchar_t *restrict d, const wchar_t *restrict s) { wchar_t *a = d; while ((*d++ = *s++)); return a; }
src/string/wcscpy.c
null
null
null
null
null
source
musl
#include <wchar.h> size_t wcscspn(const wchar_t *s, const wchar_t *c) { const wchar_t *a; if (!c[0]) return wcslen(s); if (!c[1]) return (s=wcschr(a=s, *c)) ? s-a : wcslen(a); for (a=s; *s && !wcschr(c, *s); s++); return s-a; }
src/string/wcscspn.c
null
null
null
null
null
source
musl
#include <stdlib.h> #include <wchar.h> wchar_t *wcsdup(const wchar_t *s) { size_t l = wcslen(s); wchar_t *d = malloc((l+1)*sizeof(wchar_t)); if (!d) return NULL; return wmemcpy(d, s, l+1); }
src/string/wcsdup.c
null
null
null
null
null
source
musl
#include <wchar.h> size_t wcslen(const wchar_t *s) { const wchar_t *a; for (a=s; *s; s++); return s-a; }
src/string/wcslen.c
null
null
null
null
null
source
musl
#include <wchar.h> #include <wctype.h> int wcsncasecmp(const wchar_t *l, const wchar_t *r, size_t n) { if (!n--) return 0; for (; *l && *r && n && (*l == *r || towlower(*l) == towlower(*r)); l++, r++, n--); return towlower(*l) - towlower(*r); }
src/string/wcsncasecmp.c
null
null
null
null
null
source
musl
#include <wchar.h> int wcsncasecmp_l(const wchar_t *l, const wchar_t *r, size_t n, locale_t locale) { return wcsncasecmp(l, r, n); }
src/string/wcsncasecmp_l.c
null
null
null
null
null
source
musl
#include <wchar.h> wchar_t *wcsncat(wchar_t *restrict d, const wchar_t *restrict s, size_t n) { wchar_t *a = d; d += wcslen(d); while (n && *s) n--, *d++ = *s++; *d++ = 0; return a; }
src/string/wcsncat.c
null
null
null
null
null
source
musl
#include <wchar.h> int wcsncmp(const wchar_t *l, const wchar_t *r, size_t n) { for (; n && *l==*r && *l && *r; n--, l++, r++); return n ? (*l < *r ? -1 : *l > *r) : 0; }
src/string/wcsncmp.c
null
null
null
null
null