Replace COSMO define with _COSMO_SOURCE

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

View file

@ -59,7 +59,7 @@ int LoadZipArgsImpl(int *argc, char ***argv, char *data) {
bool founddots;
char *arg, **args, *state, *start;
assert(!g_zipargs.loaded);
if (_chomp(data)) {
if (chomp(data)) {
n = 0;
args = 0;
start = data;

View file

@ -398,8 +398,13 @@ static void Pwrite(const void *data, size_t size, uint64_t offset) {
static void LogElfPhdrs(FILE *f, Elf64_Phdr *p, size_t n) {
size_t i;
fprintf(f, "Type Offset VirtAddr PhysAddr "
"FileSiz MemSiz Flg Align\n");
fprintf(f, "Type "
"Offset "
"VirtAddr "
"PhysAddr "
"FileSiz "
"MemSiz "
"Flg Align\n");
for (i = 0; i < n; ++i) {
fprintf(f,
"%-14s 0x%06lx 0x%016lx 0x%016lx 0x%06lx 0x%06lx %c%c%c 0x%04lx\n",
@ -412,8 +417,13 @@ static void LogElfPhdrs(FILE *f, Elf64_Phdr *p, size_t n) {
static void LogPeSections(FILE *f, struct NtImageSectionHeader *p, size_t n) {
size_t i;
fprintf(f, "Name Offset RelativeVirtAddr PhysAddr "
"FileSiz MemSiz Flg\n");
fprintf(f, "Name "
"Offset "
"RelativeVirtAddr "
"PhysAddr "
"FileSiz "
"MemSiz "
"Flg\n");
for (i = 0; i < n; ++i) {
fprintf(f, "%-14.8s 0x%06lx 0x%016lx 0x%016lx 0x%06lx 0x%06lx %c%c%c\n",
p[i].Name, p[i].PointerToRawData, p[i].VirtualAddress,

View file

@ -351,8 +351,8 @@ int main(int argc, char *argv[]) {
struct stat st;
const char *arg;
if (!(arg = getargs_next(&ga))) break;
if (_endswith(arg, "/")) continue;
if (_endswith(arg, ".pkg")) continue;
if (endswith(arg, "/")) continue;
if (endswith(arg, ".pkg")) continue;
if (stat(arg, &st)) SysDie(arg, "stat");
if (S_ISDIR(st.st_mode)) continue;
if (!st.st_size) Die(arg, "file is empty");

View file

@ -412,16 +412,16 @@ bool IsGccOnlyFlag(const char *s) {
return true;
}
}
if (_startswith(s, "-ffixed-")) return true;
if (_startswith(s, "-fcall-saved")) return true;
if (_startswith(s, "-fcall-used")) return true;
if (_startswith(s, "-fgcse-")) return true;
if (_startswith(s, "-fvect-cost-model=")) return true;
if (_startswith(s, "-fsimd-cost-model=")) return true;
if (_startswith(s, "-fopt-info")) return true;
if (_startswith(s, "-mstringop-strategy=")) return true;
if (_startswith(s, "-mpreferred-stack-boundary=")) return true;
if (_startswith(s, "-Wframe-larger-than=")) return true;
if (startswith(s, "-ffixed-")) return true;
if (startswith(s, "-fcall-saved")) return true;
if (startswith(s, "-fcall-used")) return true;
if (startswith(s, "-fgcse-")) return true;
if (startswith(s, "-fvect-cost-model=")) return true;
if (startswith(s, "-fsimd-cost-model=")) return true;
if (startswith(s, "-fopt-info")) return true;
if (startswith(s, "-mstringop-strategy=")) return true;
if (startswith(s, "-mpreferred-stack-boundary=")) return true;
if (startswith(s, "-Wframe-larger-than=")) return true;
return false;
}
@ -454,7 +454,7 @@ void AddEnv(char *s) {
}
char *StripPrefix(char *s, char *p) {
if (_startswith(s, p)) {
if (startswith(s, p)) {
return s + strlen(p);
} else {
return s;
@ -478,18 +478,18 @@ void AddArg(char *actual) {
appendw(&shortened, ' ');
if ((isar || isbfd || ispkg) &&
(strcmp(args.p[args.n - 1], "-o") &&
(_endswith(s, ".o") || _endswith(s, ".pkg") ||
(_endswith(s, ".a") && !isar)))) {
(endswith(s, ".o") || endswith(s, ".pkg") ||
(endswith(s, ".a") && !isar)))) {
appends(&shortened, basename(s));
} else {
appends(&shortened, s);
}
} else if (/*
* a in ('-', '--') or
* a._startswith('-o') or
* a.startswith('-o') or
* c == 'ld' and a == '-T' or
* c == 'cc' and a._startswith('-O') or
* c == 'cc' and a._startswith('-x') or
* c == 'cc' and a.startswith('-O') or
* c == 'cc' and a.startswith('-x') or
* c == 'cc' and a in ('-c', '-E', '-S')
*/
s[0] == '-' && (!s[1] || s[1] == 'o' || (s[1] == '-' && !s[2]) ||
@ -984,7 +984,7 @@ int main(int argc, char *argv[]) {
/*
* capture flags
*/
if (_startswith(argv[i], "-o")) {
if (startswith(argv[i], "-o")) {
if (!strcmp(argv[i], "-o")) {
outpath = argv[++i];
} else {
@ -1174,27 +1174,27 @@ int main(int argc, char *argv[]) {
if (isgcc && ccversion >= 6) no_sanitize_alignment = true;
} else if (!strcmp(argv[i], "-fno-sanitize=pointer-overflow")) {
if (isgcc && ccversion >= 6) no_sanitize_pointer_overflow = true;
} else if (_startswith(argv[i], "-fsanitize=implicit") &&
} else if (startswith(argv[i], "-fsanitize=implicit") &&
strstr(argv[i], "integer")) {
if (isgcc) AddArg(argv[i]);
} else if (strstr(argv[i], "stack-protector")) {
if (isclang || (isgcc && ccversion >= 6)) {
AddArg(argv[i]);
}
} else if (_startswith(argv[i], "-fvect-cost") ||
_startswith(argv[i], "-mstringop") ||
_startswith(argv[i], "-gz") || strstr(argv[i], "sanitize") ||
_startswith(argv[i], "-fvect-cost") ||
_startswith(argv[i], "-fvect-cost")) {
} else if (startswith(argv[i], "-fvect-cost") ||
startswith(argv[i], "-mstringop") ||
startswith(argv[i], "-gz") || strstr(argv[i], "sanitize") ||
startswith(argv[i], "-fvect-cost") ||
startswith(argv[i], "-fvect-cost")) {
if (isgcc && ccversion >= 6) {
AddArg(argv[i]);
}
} else if (_startswith(argv[i], "-fdiagnostic-color=")) {
} else if (startswith(argv[i], "-fdiagnostic-color=")) {
colorflag = argv[i];
} else if (_startswith(argv[i], "-R") ||
} else if (startswith(argv[i], "-R") ||
!strcmp(argv[i], "-fsave-optimization-record")) {
if (isclang) AddArg(argv[i]);
} else if (isclang && _startswith(argv[i], "--debug-prefix-map")) {
} else if (isclang && startswith(argv[i], "--debug-prefix-map")) {
/* llvm doesn't provide a gas interface so simulate w/ clang */
AddArg(xstrcat("-f", argv[i] + 2));
} else if (isgcc && (!strcmp(argv[i], "-Os") || !strcmp(argv[i], "-O2") ||
@ -1279,7 +1279,7 @@ int main(int argc, char *argv[]) {
* scrub environment for determinism and great justice
*/
for (envp = environ; *envp; ++envp) {
if (_startswith(*envp, "MODE=")) {
if (startswith(*envp, "MODE=")) {
mode = *envp + 5;
}
if (IsSafeEnv(*envp)) {

View file

@ -27,6 +27,7 @@
#include "libc/intrin/kprintf.h"
#include "libc/mem/gc.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/ftw.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/at.h"
@ -37,7 +38,6 @@
#include "libc/sysv/consts/s.h"
#include "libc/x/x.h"
#include "third_party/getopt/getopt.internal.h"
#include "libc/stdio/ftw.h"
#define USAGE \
" SRC... DST\n\
@ -130,7 +130,7 @@ int Visit(const char *fpath, const struct stat *sb, int tflag,
strcpy(srcfile, fpath);
src = srcfile + striplen;
strcpy(dstfile, dstdir);
if (!_endswith(dstfile, "/")) {
if (!endswith(dstfile, "/")) {
strcat(dstfile, "/");
}
strcat(dstfile, src);

View file

@ -624,7 +624,7 @@ static bool ParseDllImportSymbol(const char *symbol_name,
size_t n;
char *dll_name;
const char *dolla;
if (!_startswith(symbol_name, "dll$")) return false;
if (!startswith(symbol_name, "dll$")) return false;
symbol_name += 4;
dolla = strchr(symbol_name, '$');
if (!dolla) return false;

View file

@ -54,8 +54,8 @@ int main(int argc, char *argv[]) {
if (!l1 && !l2) {
exit(0);
}
if (l1) _chomp(l1);
if (l2) _chomp(l2);
if (l1) chomp(l1);
if (l2) chomp(l2);
if (!l1 || !l2) {
printf("> %s\n", l1 ? l1 : "EOF");
printf("< %s\n", l2 ? l2 : "EOF");

View file

@ -234,7 +234,7 @@ void Decompress(const char *inpath) {
if (opt_usestdout) {
output = stdout;
outpath = "/dev/stdout";
} else if (_endswith(inpath, ".gz")) {
} else if (endswith(inpath, ".gz")) {
n = strlen(inpath);
if (n - 3 + 1 > PATH_MAX) _Exit(2);
memcpy(pathbuf, inpath, n - 3);

View file

@ -16,6 +16,7 @@
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/intrin/safemacros.internal.h"
#include "libc/macros.internal.h"
@ -24,7 +25,6 @@
#include "libc/str/str.h"
#include "libc/sysv/consts/ex.h"
#include "libc/sysv/consts/exit.h"
#include "libc/errno.h"
#include "third_party/getopt/getopt.internal.h"
#define USAGE \
@ -331,7 +331,7 @@ void HandleOperand(const char *op) {
while (*op) {
found = false;
for (i = 0; i < ARRAYLEN(kDescriptors); ++i) {
if (_startswith(op, kDescriptors[i].prefix)) {
if (startswith(op, kDescriptors[i].prefix)) {
found = true;
op += strlen(kDescriptors[i].prefix);
if (succinct_) {

View file

@ -53,7 +53,7 @@ void AppendWide(struct Buffer *b, wint_t wc) {
uint64_t wb;
char buf[8];
i = 0;
wb = _tpenc(wc);
wb = tpenc(wc);
do {
buf[i++] = wb & 0xFF;
wb >>= 8;

View file

@ -115,7 +115,7 @@ char *Demangle(char *p, const char *symbol, size_t n) {
char *r;
size_t sn;
sn = strlen(symbol);
if (_startswith(symbol, "_Z")) {
if (startswith(symbol, "_Z")) {
if ((r = DemangleCxxFilt(p, n, symbol, sn))) return r;
}
return CopySymbol(p, n, symbol, sn);

View file

@ -16,9 +16,9 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "tool/build/lib/javadown.h"
#include "libc/mem/mem.h"
#include "libc/str/str.h"
#include "tool/build/lib/javadown.h"
#define FILEOVERVIEW "@fileoverview"
@ -122,7 +122,7 @@ static void SplitLines(struct Lines *lines, char *p) {
static bool ConsumeFileOverview(struct Lines *lines) {
int i;
if (lines->n && lines->p[0].n >= strlen(FILEOVERVIEW) &&
_startswith(lines->p[0].p, FILEOVERVIEW)) {
startswith(lines->p[0].p, FILEOVERVIEW)) {
lines->p[0].p += strlen(FILEOVERVIEW);
lines->p[0].n -= strlen(FILEOVERVIEW);
while (lines->p[0].n &&

View file

@ -34,7 +34,7 @@ bool ParseSupportVector(char *str, int *out_bits) {
char *tok, *state;
const char *sep = " ,+:/|";
while ((tok = strtok_r(str, sep, &state))) {
if (_startswithi(tok, "_HOST")) {
if (startswithi(tok, "_host")) {
tok += 5;
}
if (!strcasecmp(tok, "linux")) {

View file

@ -362,7 +362,7 @@ static const char *StripExt(char pathbuf[PATH_MAX + 1], const char *s) {
static bool IsObjectSource(const char *name) {
int i;
for (i = 0; i < ARRAYLEN(kSourceExts); ++i) {
if (_endswith(name, kSourceExts[i])) return true;
if (endswith(name, kSourceExts[i])) return true;
}
return false;
}
@ -399,7 +399,7 @@ static char *Explore(void) {
path = names + sauces[i].name;
if (!IsObjectSource(path)) continue;
Appendw(&makefile, '\n');
if (!_startswith(path, "o/")) {
if (!startswith(path, "o/")) {
Appends(&makefile, buildroot);
}
Appends(&makefile, StripExt(buf, path));

View file

@ -25,6 +25,7 @@
#include "libc/fmt/magnumstrs.internal.h"
#include "libc/mem/gc.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/ftw.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/at.h"
@ -32,7 +33,6 @@
#include "libc/sysv/consts/s.h"
#include "libc/x/x.h"
#include "third_party/getopt/getopt.internal.h"
#include "libc/stdio/ftw.h"
#define USAGE \
" SRC... DST\n\
@ -126,7 +126,7 @@ int Visit(const char *fpath, const struct stat *sb, int tflag,
strcpy(srcfile, fpath);
src = srcfile + striplen;
strcpy(dstfile, dstdir);
if (!_endswith(dstfile, "/")) {
if (!endswith(dstfile, "/")) {
strcat(dstfile, "/");
}
strcat(dstfile, src);

View file

@ -97,13 +97,13 @@ void Visit(const char *path) {
char *map;
size_t size;
bool isheader;
if (!_endswith(path, ".h") && !_endswith(path, ".inc")) return;
if (_endswith(path, ".internal.h")) return;
if (_endswith(path, "/internal.h")) return;
if (_endswith(path, ".internal.inc")) return;
if (_endswith(path, "/internal.inc")) return;
if (_startswith(path, "libc/isystem/")) return;
isheader = _endswith(path, ".h");
if (!endswith(path, ".h") && !endswith(path, ".inc")) return;
if (endswith(path, ".internal.h")) return;
if (endswith(path, "/internal.h")) return;
if (endswith(path, ".internal.inc")) return;
if (endswith(path, "/internal.inc")) return;
if (startswith(path, "libc/isystem/")) return;
isheader = endswith(path, ".h");
if (isheader && isinterned(visited, path)) return;
appends(&output, "\n\f\n/*!BEGIN ");
appends(&output, path);

View file

@ -231,7 +231,7 @@ void StartTcpServer(void) {
printf("ready %hu\n", ntohs(g_servaddr.sin_port));
fflush(stdout);
fclose(stdout);
dup2(g_bogusfd, stdout->fd);
dup2(g_bogusfd, fileno(stdout));
}
}
@ -573,8 +573,8 @@ void Daemonize(void) {
if (fork() > 0) _exit(0);
setsid();
if (fork() > 0) _exit(0);
dup2(g_bogusfd, stdin->fd);
if (!g_sendready) dup2(g_bogusfd, stdout->fd);
dup2(g_bogusfd, fileno(stdin));
if (!g_sendready) dup2(g_bogusfd, fileno(stdout));
freopen(kLogFile, "ae", stderr);
if (fstat(fileno(stderr), &st) != -1 && st.st_size > kLogMaxBytes) {
ftruncate(fileno(stderr), 0);

View file

@ -151,7 +151,7 @@ static bool CheckDigests(const char *path, FILE *f) {
unsigned char wantdigest[32], gotdigest[32];
char buf[64 + 2 + PATH_MAX + 1 + 1], *p;
for (line = 0; fgets(buf, sizeof(buf), f); ++line) {
if (!*_chomp(buf)) continue;
if (!*chomp(buf)) continue;
for (p = buf, i = 0; i < 32; ++i) {
if ((a = kHexToInt[*p++ & 255]) == -1) goto InvalidLine;
if ((b = kHexToInt[*p++ & 255]) == -1) goto InvalidLine;

View file

@ -23,11 +23,11 @@
#include "libc/fmt/itoa.h"
#include "libc/fmt/magnumstrs.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/ftw.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/s.h"
#include "libc/x/x.h"
#include "libc/stdio/ftw.h"
const char *prog;
char tmpdir[PATH_MAX];
@ -59,12 +59,12 @@ void Execute(char *argv[]) {
int Visit(const char *fpath, const struct stat *sb, int tflag,
struct FTW *ftwbuf) {
if (tflag == FTW_F && _endswith(fpath, ".gz")) {
if (tflag == FTW_F && endswith(fpath, ".gz")) {
Execute((char *[]){"build/bootstrap/gzip.com", "-d", fpath, 0});
strcpy(binpath, fpath);
binpath[strlen(binpath) - 3] = 0;
chmod(binpath, 0755);
} else if (tflag == FTW_F && _endswith(fpath, ".sym")) {
} else if (tflag == FTW_F && endswith(fpath, ".sym")) {
strcpy(binpath, fpath);
binpath[strlen(binpath) - 4] = 0;
symlink(xslurp(fpath, 0), binpath);

View file

@ -20,6 +20,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/struct/stat.h"
#include "libc/elf/def.h"
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/libgen.h"
#include "libc/limits.h"
@ -40,7 +41,6 @@
#include "libc/zip.internal.h"
#include "third_party/getopt/getopt.internal.h"
#include "tool/build/lib/elfwriter.h"
#include "libc/errno.h"
#include "tool/build/lib/stripcomponents.h"
char *name_;
@ -173,7 +173,7 @@ void ProcessFile(struct ElfWriter *elf, const char *path) {
}
if (S_ISDIR(st.st_mode)) {
st.st_size = 0;
if (!_endswith(name, "/")) {
if (!endswith(name, "/")) {
name = gc(xstrcat(name, '/'));
}
}
@ -194,7 +194,7 @@ void PullEndOfCentralDirectoryIntoLinkage(struct ElfWriter *elf) {
void CheckFilenameKosher(const char *path) {
CHECK_LE(kZipCfileHdrMinSize + strlen(path), 65535);
CHECK(!_startswith(path, "/"));
CHECK(!startswith(path, "/"));
CHECK(!strstr(path, ".."));
}

View file

@ -5,8 +5,10 @@
http://unlicense.org/ │
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#include "libc/calls/calls.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/str/tab.internal.h"
/**
* @fileoverview Hex to binary converter program.
@ -15,14 +17,14 @@
*/
int main() {
int o, t = -1;
while (0 <= (o = getchar()) && o <= 255) {
if (!isxdigit(o)) continue;
int h = hextoint(o);
if (t != -1) putchar(t * 16 + h), h = -1;
t = h;
int h, o, t = -1;
while ((o = getchar()) != -1) {
if ((h = kHexToInt[o & 255]) != -1) {
if (t != -1) {
putchar(t * 16 + h);
h = -1;
}
t = h;
}
}
if (ferror(stdout)) return 1;
if (t != -1) return 2;
return 0;
}

View file

@ -22,6 +22,7 @@
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/str/tab.internal.h"
#include "libc/sysv/consts/ex.h"
#include "libc/sysv/consts/exit.h"
#include "third_party/getopt/getopt.internal.h"
@ -129,8 +130,11 @@ int main(int argc, char *argv[]) {
for (k = 0, i = optind; i < argc; ++i) {
CheckHex(argv[i]);
for (j = 0; argv[i][j]; j += 2) {
if (++k > XED_MAX_INSTRUCTION_BYTES) ShowUsage(EX_DATAERR, stderr);
buf[k - 1] = hextoint(argv[i][j + 0]) << 4 | hextoint(argv[i][j + 1]);
if (++k > XED_MAX_INSTRUCTION_BYTES) {
ShowUsage(EX_DATAERR, stderr);
}
buf[k - 1] = kHexToInt[argv[i][j + 0] & 255] << 4 |
kHexToInt[argv[i][j + 1] & 255];
}
}

View file

@ -1,38 +0,0 @@
/*─────────────────────────────────────────────────────────────────╗
To the extent possible under law, Justine Tunney has waived
all copyright and related or neighboring rights to this file,
as it is written in the following disclaimers:
http://unlicense.org/ │
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#include "libc/mem/gc.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/x/x.h"
/**
* @fileoverview Hex to binary converter program.
* Non-hex bytes are ignored. If you've got imposter syndrome you could
* call this a compiler and start coding in hex.
*/
int main(int argc, char *argv[]) {
size_t i, j, l;
uint8_t *buf;
if (argc == 1) return 1;
buf = gc(xmalloc((l = strlen(argv[1]) / 2)));
for (j = 0; j < l; ++j) {
buf[j] = 0;
}
for (i = 1; i < argc; ++i) {
for (j = 0; j < l; ++j) {
buf[j] ^= hextoint(argv[i][j + 0]) << 4 | hextoint(argv[i][j + 1]);
}
}
for (j = 0; j < l; ++j) {
putchar("0123456789abcdef"[(buf[j] >> 4) & 0xf]);
putchar("0123456789abcdef"[(buf[j] >> 0) & 0xf]);
}
putchar('\n');
return 0;
}

View file

@ -174,6 +174,7 @@
"__TIMESTAMP__"
"_GNU_SOURCE"
"_BSD_SOURCE"
"_COSMO_SOURCE"
"_XOPEN_SOURCE"))
(defconst cosmo-cpp-constants-cosmopolitan

View file

@ -2284,11 +2284,11 @@ static char *AppendHeader(char *p, const char *k, const char *v) {
static char *AppendContentType(char *p, const char *ct) {
p = stpcpy(p, "Content-Type: ");
p = stpcpy(p, ct);
if ((cpm.istext = _startswith(ct, "text/"))) {
if ((cpm.istext = startswith(ct, "text/"))) {
if (!strchr(ct + 5, ';')) {
p = stpcpy(p, "; charset=utf-8");
}
if (!cpm.referrerpolicy && _startswith(ct + 5, "html")) {
if (!cpm.referrerpolicy && startswith(ct + 5, "html")) {
cpm.referrerpolicy = "no-referrer-when-downgrade";
}
}
@ -3828,7 +3828,7 @@ static void StoreFile(char *path) {
size_t plen, tlen;
struct stat st;
char *target = path;
if (_startswith(target, "./")) target += 2;
if (startswith(target, "./")) target += 2;
tlen = strlen(target);
if (!IsReasonablePath(target, tlen))
FATALF("(cfg) error: can't store %`'s: contains '.' or '..' segments",
@ -3844,7 +3844,7 @@ static void StorePath(const char *dirpath) {
DIR *d;
char *path;
struct dirent *e;
if (!isdirectory(dirpath) && !_endswith(dirpath, "/"))
if (!isdirectory(dirpath) && !endswith(dirpath, "/"))
return StoreFile(dirpath);
if (!(d = opendir(dirpath))) FATALF("(cfg) error: can't open %`'s", dirpath);
while ((e = readdir(d))) {
@ -4730,7 +4730,7 @@ static int LuaGetZipPaths(lua_State *L) {
zcf += ZIP_CFILE_HDRSIZE(zcf)) {
CHECK_EQ(kZipCfileHdrMagic, ZIP_CFILE_MAGIC(zcf));
path = GetAssetPath(zcf, &pathlen);
if (prefixlen == 0 || _startswith(path, prefix)) {
if (prefixlen == 0 || startswith(path, prefix)) {
lua_pushlstring(L, path, pathlen);
lua_seti(L, -2, ++i);
}
@ -6184,7 +6184,7 @@ static char *ServeAsset(struct Asset *a, const char *path, size_t pathlen) {
ClientAcceptsGzip() && !ShouldAvoidGzip() &&
!(a->file &&
IsNoCompressExt(a->file->path.s, a->file->path.n)) &&
((cpm.contentlength >= 100 && _startswithi(ct, "text/")) ||
((cpm.contentlength >= 100 && startswithi(ct, "text/")) ||
(cpm.contentlength >= 1000 &&
MeasureEntropy(cpm.content, 1000) < 7))) {
VERBOSEF("serving compressed asset");
@ -6926,10 +6926,10 @@ static void MakeExecutableModifiable(void) {
if (IsWindows()) return; // TODO
if (IsOpenbsd()) return; // TODO
if (IsNetbsd()) return; // TODO
if (_endswith(zpath, ".com.dbg")) return;
if (endswith(zpath, ".com.dbg")) return;
close(zfd);
ft = ftrace_enabled(0);
if ((zfd = _OpenExecutable()) == -1) {
if ((zfd = __open_executable()) == -1) {
WARNF("(srvr) can't open executable for modification: %m");
}
if (ft > 0) {

View file

@ -40,7 +40,7 @@ static const char *GetElfSymbol(uintptr_t funcaddr) {
static const char *GetDispatchName(int x) {
const char *s;
s = GetElfSymbol(LO(GetShadow(x)));
if (_startswith(s, "Dispatch")) s += 8;
if (startswith(s, "Dispatch")) s += 8;
return s;
}

View file

@ -62,7 +62,7 @@ void bf(int fd) {
obuf[n++] = ' ';
for (i = 0; i < rc; ++i) {
c = ibuf[i] & 0xff;
w = _tpenc(kCp437[c]);
w = tpenc(kCp437[c]);
do {
obuf[n++] = w;
} while ((w >>= 8));

View file

@ -137,7 +137,7 @@ extern const char16_t kRunes[];
*/
static char *tptoa(char *p, wchar_t x) {
unsigned long w;
for (w = _tpenc(x); w; w >>= 010) *p++ = w & 0xff;
for (w = tpenc(x); w; w >>= 010) *p++ = w & 0xff;
return p;
}

View file

@ -84,7 +84,7 @@ static char *Raster(int yn, int xn, unsigned char Y[yn][xn], int *dw) {
bs = s;
}
}
appendw(&r, _tpenc(kBlocks[bi].c));
appendw(&r, tpenc(kBlocks[bi].c));
++w;
}
if (w > *dw) *dw = w;

View file

@ -705,7 +705,7 @@ static void LoadRanges(void) {
case 0:
if (isxdigit(b[i])) {
range.a <<= 4;
range.a += hextoint(b[i]);
range.a += kHexToInt[b[i] & 255];
} else if (b[i] == '-') {
t = 1;
}
@ -713,7 +713,7 @@ static void LoadRanges(void) {
case 1:
if (isxdigit(b[i])) {
range.b <<= 4;
range.b += hextoint(b[i]);
range.b += kHexToInt[b[i] & 255];
} else if (b[i] == ' ') {
t = 2;
}
@ -771,7 +771,7 @@ static void Render(void) {
p = FormatInt64(p, fg);
*p++ = 'm';
}
w = _tpenc(kCp437[c]);
w = tpenc(kCp437[c]);
do {
*p++ = w & 0xff;
w >>= 8;