Do code cleanup use duff device linenoise i/o

This commit is contained in:
Justine Tunney 2022-04-22 18:55:28 -07:00
parent 6ff46ca373
commit 2f56ebfe78
79 changed files with 1393 additions and 1484 deletions

View file

@ -14,11 +14,11 @@
int main(int argc, char *argv[]) {
int c, n;
char a[22];
char a[22], *p;
if ((c = GetCpuCount())) {
n = int64toarray_radix10(c, a);
a[n++] = '\n';
return write(1, a, n) == n ? 0 : 1;
p = FormatInt64(a, c);
*p++ = '\n';
return write(1, a, p - a) == p - a ? 0 : 1;
} else {
return 1;
}

View file

@ -27,7 +27,7 @@ int main(int argc, char *argv[]) {
}
}
if (isprime) {
int64toarray_radix10(i, buf);
FormatInt64(buf, i);
fputs(buf, stdout);
fputc('\n', stdout);
if (k++ % 100 == 0) {

View file

@ -47,8 +47,8 @@ void PrintMetric(const char *name, long double d) {
mils = fmodl(d * 1000, 1000);
mics = fmodl(d * 1000000, 1000);
p = stpcpy(p, name), *p++ = '\t';
p += int64toarray_radix10(mins, p), *p++ = 'm';
p += int64toarray_radix10(secs, p), *p++ = '.';
p = FormatInt64(p, mins), *p++ = 'm';
p = FormatInt64(p, secs), *p++ = '.';
*p++ = '0' + mils / 100;
*p++ = '0' + mils / 10 % 10;
*p++ = '0' + mils % 10;