diff --git a/ape/ape.S b/ape/ape.S index 0a48472f..822ef848 100644 --- a/ape/ape.S +++ b/ape/ape.S @@ -1397,19 +1397,19 @@ long: push $GDT_LONG_DATA jmp *%rax .endfn long -/* ▄▄▒▀▀▀▀▒▒▄░ +/* ▄▄▒▀▀▀▀▒▒▄ █████▓▓▄░░░░ ▒▒▄░ ▐█▓▓█▓▄█████▓░ ▀▒▄ ▓█▓▓▓▓▓▓▓▓▓█▓ ░▀▒░ - ░▀▀▓█▓▓▓▓▓▓█▓ ░▀▒▄▄▒▄▄▄▒▒▒▀▀▀▀▀▀▀▀▀▀▀▀▀▀▒▒▄▒ - ░▀▓▓█▓▓▓▓▓▄ ░ ░▀▒▄▄ ▄ - ░▀█▓▓▓▓▓▄░ ░▀▒░ ▄▓▌ + ▀▀▓█▓▓▓▓▓▓█▓ ░▀▒▄▄▒▄▄▄▒▒▒▀▀▀▀▀▀▀▀▀▀▀▀▀▀▒▒▄▒ + ▀▓▓█▓▓▓▓▓▄ ░ ░▀▒▄▄ ▄ + ▀█▓▓▓▓▓▄░ ░▀▒░ ▄▓▌ ▀█▓▓▓▓▓█▓░ ░▀▄░ ░▄▓██░ - ░▀█▓▓▓▓▓█▄ ░▀▒▄▄▄▄▄▄▄▄▒▀▓█▓█▓░ - ░▀█▓▓▓▓█▓░ ░▄▓█▓▓█▓▄▌ - ░▀█▓▓▓▓▓▄ ▄▄▄▓▓██▓▓▒▒░ ▒▒▄▓█▓▓▓▓█▓ + ▀█▓▓▓▓▓█▄ ░▀▒▄▄▄▄▄▄▄▄▒▀▓█▓█▓░ + ▀█▓▓▓▓█▓░ ░▄▓█▓▓█▓▄▌ + ▀█▓▓▓▓▓▄ ▄▄▄▓▓██▓▓▒▒░ ▒▒▄▓█▓▓▓▓█▓ ▀█▓▓▓▓▓▓▄▄░ ░▄▄▓██▓▓▓▓▓██████████████▓▓▓▓▓▓█▀ - ▐█▓▓▓▓▓▓▓██▓▓▄▄▄▄▄▄▄▄▄▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████████▓▓▀░ + ▐█▓▓▓▓▓▓▓██▓▓▄▄▄▄▄▄▄▄▄▓▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████████▓▓▀ ▀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█░ ░░░░░░ ▄░▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▌ █▓▄▀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▀▀▀▀▀▀▀▓█▓▓▓▓▓▓▓▓▓▓▓▓ diff --git a/libc/calls/nice.c b/libc/calls/nice.c index 54603634..b113ec37 100644 --- a/libc/calls/nice.c +++ b/libc/calls/nice.c @@ -16,13 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/fmt/conv.h" +#include "libc/macros.internal.h" #include "libc/sysv/consts/prio.h" static int clamp(int p) { - return max(-NZERO, min(NZERO - 1, p)); + return MAX(-NZERO, MIN(NZERO - 1, p)); } /** @@ -34,7 +34,7 @@ static int clamp(int p) { */ int nice(int delta) { int p; - if (abs(delta) >= NZERO * 2) { + if (ABS(delta) >= NZERO * 2) { p = delta; } else { delta = clamp(delta); diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 1abb8c8b..6b00f5ec 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -157,8 +157,6 @@ USAGE\n\ #define HASH_LOAD_FACTOR /* 1. / */ 4 #define DEFAULT_PORT 8080 -#define AppendHeaderName(p, s) stpcpy(stpcpy(p, s), ": ") - static const struct itimerval kHeartbeat = { {0, 500000}, {0, 500000}, @@ -1159,14 +1157,6 @@ static void *AddRange(char *content, long start, long length) { } } -static bool IsConnectionClose(void) { - int n; - char *p; - p = inbuf.p + msg.headers[kHttpConnection].a; - n = msg.headers[kHttpConnection].b - msg.headers[kHttpConnection].a; - return n == 5 && memcmp(p, "close", 5) == 0; -} - static char *AppendCrlf(char *p) { p[0] = '\r'; p[1] = '\n'; @@ -1193,11 +1183,11 @@ static char *SetStatus(int code, const char *reason) { static char *AppendHeader(char *p, const char *k, const char *v) { if (!v) return p; - return AppendCrlf(stpcpy(AppendHeaderName(p, k), v)); + return AppendCrlf(stpcpy(stpcpy(stpcpy(p, k), ": "), v)); } static char *AppendContentType(char *p, const char *ct) { - p = AppendHeaderName(p, "Content-Type"); + p = stpcpy(p, "Content-Type: "); p = stpcpy(p, ct); if (startswith(ct, "text/") && !strchr(ct, ';')) { p = stpcpy(p, "; charset=utf-8"); @@ -1223,7 +1213,7 @@ static char *ServeError(int code, const char *reason) { static char *AppendExpires(char *p, int64_t t) { struct tm tm; gmtime_r(&t, &tm); - p = AppendHeaderName(p, "Expires"); + p = stpcpy(p, "Expires: "); p = FormatHttpDateTime(p, &tm); return AppendCrlf(p); } @@ -1231,7 +1221,7 @@ static char *AppendExpires(char *p, int64_t t) { static char *AppendCache(char *p, int64_t seconds) { struct tm tm; if (seconds < 0) return p; - p = AppendHeaderName(p, "Cache-Control"); + p = stpcpy(p, "Cache-Control: "); p = stpcpy(p, "max-age="); p += uint64toarray_radix10(seconds, p); if (seconds) p = stpcpy(p, ", public"); @@ -1240,7 +1230,7 @@ static char *AppendCache(char *p, int64_t seconds) { } static char *AppendContentLength(char *p, size_t n) { - p = AppendHeaderName(p, "Content-Length"); + p = stpcpy(p, "Content-Length: "); p += uint64toarray_radix10(n, p); return AppendCrlf(p); } @@ -1252,8 +1242,7 @@ static char *AppendContentRange(char *p, long rangestart, long rangelength, CHECK_GT(rangestart + rangelength, rangestart); CHECK_LE(rangestart + rangelength, contentlength); endrange = rangestart + rangelength - 1; - p = AppendHeaderName(p, "Content-Range"); - p = stpcpy(p, "bytes "); + p = stpcpy(p, "Content-Range: bytes "); p += uint64toarray_radix10(rangestart, p); *p++ = '-'; p += uint64toarray_radix10(endrange, p); @@ -2368,7 +2357,7 @@ static char *HandleMessage(void) { } msgsize = need; /* we are now synchronized */ LogBody("received", inbuf.p + hdrsize, msgsize - hdrsize); - if (httpversion != 101 || IsConnectionClose()) { + if (httpversion != 101 || !CompareHeader(kHttpConnection, "close")) { connectionclose = true; } ParseRequestUri(); diff --git a/tool/viz/derasterize.c b/tool/viz/derasterize.c index ab1e8ed5..c5e9ae6f 100644 --- a/tool/viz/derasterize.c +++ b/tool/viz/derasterize.c @@ -104,7 +104,7 @@ int y_; /* -y HEIGHT [in flexidecimal] */ #define Mode BEST #if Mode == BEST -#define MC 9u /* log2(#) of color combos to consider */ +#define MC 9u /* log2(#) of color combos to consider */ #define GN 35u /* # of glyphs to consider */ #elif Mode == FAST #define MC 6u @@ -114,10 +114,10 @@ int y_; /* -y HEIGHT [in flexidecimal] */ #define GN 25u #endif -#define CN 3u /* # channels (rgb) */ -#define YS 8u /* row stride -or- block height */ -#define XS 4u /* column stride -or- block width */ -#define GT 44u /* total glyphs */ +#define CN 3u /* # channels (rgb) */ +#define YS 8u /* row stride -or- block height */ +#define XS 4u /* column stride -or- block width */ +#define GT 44u /* total glyphs */ #define BN (YS * XS) /* # scalars in block/glyph plane */ #define PHIPRIME 0x9E3779B1u @@ -467,7 +467,8 @@ static int ReadAll(int fd, void *data, size_t size) { n = size; do { if ((rc = read(fd, p, n)) == -1) return -1; - assert((got = rc) || !n); + got = rc; + assert(got || !n); p += got; n -= got; } while (n);