mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Do code cleanup use duff device linenoise i/o
This commit is contained in:
parent
6ff46ca373
commit
2f56ebfe78
79 changed files with 1393 additions and 1484 deletions
|
@ -83,7 +83,7 @@ void bf(int fd) {
|
|||
obuf[n++] = ';';
|
||||
obuf[n++] = '5';
|
||||
obuf[n++] = ';';
|
||||
n += int64toarray_radix10(fg, obuf + n);
|
||||
n = FormatInt64(obuf + n, fg) - (obuf + n);
|
||||
obuf[n++] = 'm';
|
||||
}
|
||||
obuf[n++] = "0123456789abcdef"[c >> 4];
|
||||
|
|
|
@ -79,7 +79,7 @@ static const char *GetStorageSpecifier(const char *type, int *out_width,
|
|||
static void EmitSection(long yn, long xn, int w, int arrayalign, int emit(),
|
||||
void *a) {
|
||||
char alignstr[21];
|
||||
uint64toarray_radix10(arrayalign, alignstr);
|
||||
FormatUint32(alignstr, arrayalign);
|
||||
if (arrayalign <= 8 && yn * xn * w == 8) {
|
||||
emit("\t.rodata.cst", a);
|
||||
emit("8\n", a);
|
||||
|
@ -108,8 +108,8 @@ void *FormatStringTableAsAssembly(long yn, long xn, const char *const T[yn][xn],
|
|||
char ynstr[21], xnstr[21];
|
||||
name = firstnonnull(name, "M");
|
||||
storage = GetStorageSpecifier(firstnonnull(type, "long"), &w, &align);
|
||||
uint64toarray_radix10(yn, ynstr);
|
||||
uint64toarray_radix10(xn, xnstr);
|
||||
FormatUint64(ynstr, yn);
|
||||
FormatUint64(xnstr, xn);
|
||||
EmitSection(yn, xn, w, GetArrayAlignment(yn, xn, w, align), emit, a);
|
||||
emit(name, a);
|
||||
emit(":", a);
|
||||
|
|
|
@ -24,8 +24,8 @@ void *FormatStringTableAsCode(long yn, long xn, const char *const T[yn][xn],
|
|||
int emit(), void *arg, const char *type,
|
||||
const char *name, const char *ignored) {
|
||||
char ynstr[21], xnstr[21];
|
||||
uint64toarray_radix10(yn, ynstr);
|
||||
uint64toarray_radix10(xn, xnstr);
|
||||
FormatUint64(ynstr, yn);
|
||||
FormatUint64(xnstr, xn);
|
||||
emit(type, arg);
|
||||
emit(" ", arg);
|
||||
emit(firstnonnull(name, "M"), arg);
|
||||
|
|
|
@ -341,7 +341,7 @@ static void AppendChar(char c) {
|
|||
|
||||
static void AppendInt(long x) {
|
||||
char ibuf[21];
|
||||
AppendData(ibuf, int64toarray_radix10(x, ibuf));
|
||||
AppendData(ibuf, FormatInt64(ibuf, x) - ibuf);
|
||||
}
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
|
|
|
@ -743,7 +743,7 @@ static void Render(void) {
|
|||
fg = InvertXtermGreyscale(fg);
|
||||
}
|
||||
p = stpcpy(p, "\e[38;5;");
|
||||
p += int64toarray_radix10(fg, p);
|
||||
p = FormatInt64(p, fg);
|
||||
*p++ = 'm';
|
||||
}
|
||||
w = tpenc(kCp437[c]);
|
||||
|
@ -769,14 +769,14 @@ static void Render(void) {
|
|||
}
|
||||
p = stpcpy(p, " memzoom\e[0m ");
|
||||
if (!pid) {
|
||||
p += uint64toarray_radix10(MIN(offset / (long double)size * 100, 100), p);
|
||||
p = FormatUint32(p, MIN(offset / (long double)size * 100, 100));
|
||||
p = stpcpy(p, "%-");
|
||||
p += uint64toarray_radix10(
|
||||
MIN((offset + ((tyn * txn) << zoom)) / (long double)size * 100, 100),
|
||||
p);
|
||||
p = FormatUint32(
|
||||
p,
|
||||
MIN((offset + ((tyn * txn) << zoom)) / (long double)size * 100, 100));
|
||||
p = stpcpy(p, "% ");
|
||||
}
|
||||
p += uint64toarray_radix10(1L << zoom, p);
|
||||
p = FormatUint32(p, 1L << zoom);
|
||||
p = stpcpy(p, "x\e[J");
|
||||
PreventBufferbloat();
|
||||
for (i = 0, n = p - buffer; i < n; i += got) {
|
||||
|
@ -910,10 +910,10 @@ static void GetOpts(int argc, char *argv[]) {
|
|||
}
|
||||
if (pid) {
|
||||
p = stpcpy(path, "/proc/");
|
||||
p += int64toarray_radix10(pid, p);
|
||||
p = FormatInt64(p, pid);
|
||||
stpcpy(p, "/mem");
|
||||
p = stpcpy(mapspath, "/proc/");
|
||||
p += int64toarray_radix10(pid, p);
|
||||
p = FormatInt64(p, pid);
|
||||
stpcpy(p, "/maps");
|
||||
} else {
|
||||
if (optind == argc) {
|
||||
|
|
|
@ -857,8 +857,8 @@ static void OpenVideo(void) {
|
|||
plm_set_video_decode_callback(plm_, OnVideo, NULL);
|
||||
plm_set_audio_decode_callback(plm_, OnAudio, NULL);
|
||||
plm_set_loop(plm_, false);
|
||||
int64toarray_radix10((chans_ = 2), chansstr_);
|
||||
int64toarray_radix10((srate_ = plm_get_samplerate(plm_)), sratestr_);
|
||||
FormatInt64(chansstr_, (chans_ = 2));
|
||||
FormatInt64(sratestr_, (srate_ = plm_get_samplerate(plm_)));
|
||||
if (plm_get_num_audio_streams(plm_) && OpenSpeaker()) {
|
||||
plm_set_audio_enabled(plm_, true, 0);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue