mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
printf: Oops, '-' is the left padding modifier, not ' '.
It's kinda funny how I can make a mistake like this in Serenity and then get so used to it by spending lots of time using this API that I start to believe that this is how printf() always worked..
This commit is contained in:
parent
5980007e44
commit
1277d583ef
5 changed files with 17 additions and 17 deletions
|
@ -196,7 +196,7 @@ template<typename PutChFunc>
|
||||||
char* bufptr = buffer;
|
char* bufptr = buffer;
|
||||||
|
|
||||||
for (p = fmt; *p; ++p) {
|
for (p = fmt; *p; ++p) {
|
||||||
bool leftPad = false;
|
bool left_pad = false;
|
||||||
bool zeroPad = false;
|
bool zeroPad = false;
|
||||||
unsigned fieldWidth = 0;
|
unsigned fieldWidth = 0;
|
||||||
unsigned long_qualifiers = 0;
|
unsigned long_qualifiers = 0;
|
||||||
|
@ -204,8 +204,8 @@ template<typename PutChFunc>
|
||||||
if (*p == '%' && *(p + 1)) {
|
if (*p == '%' && *(p + 1)) {
|
||||||
one_more:
|
one_more:
|
||||||
++p;
|
++p;
|
||||||
if (*p == ' ') {
|
if (*p == '-') {
|
||||||
leftPad = true;
|
left_pad = true;
|
||||||
if (*(p + 1))
|
if (*(p + 1))
|
||||||
goto one_more;
|
goto one_more;
|
||||||
}
|
}
|
||||||
|
@ -233,19 +233,19 @@ template<typename PutChFunc>
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
case 's': {
|
case 's': {
|
||||||
const char* sp = va_arg(ap, const char*);
|
const char* sp = va_arg(ap, const char*);
|
||||||
ret += print_string(putch, bufptr, sp ? sp : "(null)", leftPad, fieldWidth);
|
ret += print_string(putch, bufptr, sp ? sp : "(null)", left_pad, fieldWidth);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
ret += print_signed_number(putch, bufptr, va_arg(ap, int), leftPad, zeroPad, fieldWidth);
|
ret += print_signed_number(putch, bufptr, va_arg(ap, int), left_pad, zeroPad, fieldWidth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
ret += print_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth);
|
ret += print_number(putch, bufptr, va_arg(ap, dword), left_pad, zeroPad, fieldWidth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Q':
|
case 'Q':
|
||||||
ret += print_qword(putch, bufptr, va_arg(ap, qword), leftPad, zeroPad, fieldWidth);
|
ret += print_qword(putch, bufptr, va_arg(ap, qword), left_pad, zeroPad, fieldWidth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'q':
|
case 'q':
|
||||||
|
@ -256,7 +256,7 @@ template<typename PutChFunc>
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'f':
|
case 'f':
|
||||||
// FIXME: Print as float!
|
// FIXME: Print as float!
|
||||||
ret += print_signed_qword(putch, bufptr, (qword)va_arg(ap, double), leftPad, zeroPad, fieldWidth);
|
ret += print_signed_qword(putch, bufptr, (qword)va_arg(ap, double), left_pad, zeroPad, fieldWidth);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ template<typename PutChFunc>
|
||||||
putch(bufptr, '0');
|
putch(bufptr, '0');
|
||||||
++ret;
|
++ret;
|
||||||
}
|
}
|
||||||
ret += print_octal_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth);
|
ret += print_octal_number(putch, bufptr, va_arg(ap, dword), left_pad, zeroPad, fieldWidth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
|
|
|
@ -196,7 +196,7 @@ ByteBuffer procfs$pid_fds(InodeIdentifier identifier)
|
||||||
auto* description = process.file_description(i);
|
auto* description = process.file_description(i);
|
||||||
if (!description)
|
if (!description)
|
||||||
continue;
|
continue;
|
||||||
builder.appendf("% 3u %s\n", i, description->absolute_path().characters());
|
builder.appendf("%-3u %s\n", i, description->absolute_path().characters());
|
||||||
}
|
}
|
||||||
return builder.to_byte_buffer();
|
return builder.to_byte_buffer();
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ ByteBuffer procfs$pid_vm(InodeIdentifier identifier)
|
||||||
flags_builder.append('R');
|
flags_builder.append('R');
|
||||||
if (region->is_writable())
|
if (region->is_writable())
|
||||||
flags_builder.append('W');
|
flags_builder.append('W');
|
||||||
builder.appendf("%x -- %x %x %x % 4s %s\n",
|
builder.appendf("%x -- %x %x %x %-4s %s\n",
|
||||||
region->vaddr().get(),
|
region->vaddr().get(),
|
||||||
region->vaddr().offset(region->size() - 1).get(),
|
region->vaddr().offset(region->size() - 1).get(),
|
||||||
region->size(),
|
region->size(),
|
||||||
|
@ -544,7 +544,7 @@ ByteBuffer procfs$summary(InodeIdentifier)
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.appendf("PID TPG PGP SID OWNER STATE PPID NSCHED FDS TTY NAME\n");
|
builder.appendf("PID TPG PGP SID OWNER STATE PPID NSCHED FDS TTY NAME\n");
|
||||||
for (auto* process : processes) {
|
for (auto* process : processes) {
|
||||||
builder.appendf("% 3u % 3u % 3u % 3u % 4u % 8s % 3u % 9u % 3u % 4s %s\n",
|
builder.appendf("%-3u %-3u %-3u %-3u %-4u %-8s %-3u %-9u %-3u %-4s %s\n",
|
||||||
process->pid(),
|
process->pid(),
|
||||||
process->tty() ? process->tty()->pgid() : 0,
|
process->tty() ? process->tty()->pgid() : 0,
|
||||||
process->pgid(),
|
process->pgid(),
|
||||||
|
|
|
@ -231,13 +231,13 @@ bool Scheduler::pick_next()
|
||||||
dbgprintf("Non-runnables:\n");
|
dbgprintf("Non-runnables:\n");
|
||||||
for (auto* thread = g_nonrunnable_threads->head(); thread; thread = thread->next()) {
|
for (auto* thread = g_nonrunnable_threads->head(); thread; thread = thread->next()) {
|
||||||
auto* process = &thread->process();
|
auto* process = &thread->process();
|
||||||
dbgprintf("[K%x] % 12s %s(%u:%u) @ %w:%x\n", process, to_string(thread->state()), process->name().characters(), process->pid(), thread->tid(), thread->tss().cs, thread->tss().eip);
|
dbgprintf("[K%x] %-12s %s(%u:%u) @ %w:%x\n", process, to_string(thread->state()), process->name().characters(), process->pid(), thread->tid(), thread->tss().cs, thread->tss().eip);
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgprintf("Runnables:\n");
|
dbgprintf("Runnables:\n");
|
||||||
for (auto* thread = g_runnable_threads->head(); thread; thread = thread->next()) {
|
for (auto* thread = g_runnable_threads->head(); thread; thread = thread->next()) {
|
||||||
auto* process = &thread->process();
|
auto* process = &thread->process();
|
||||||
dbgprintf("[K%x] % 12s %s(%u:%u) @ %w:%x\n", process, to_string(thread->state()), process->name().characters(), process->pid(), thread->tid(), thread->tss().cs, thread->tss().eip);
|
dbgprintf("[K%x] %-12s %s(%u:%u) @ %w:%x\n", process, to_string(thread->state()), process->name().characters(), process->pid(), thread->tid(), thread->tss().cs, thread->tss().eip);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ int main(int, char**)
|
||||||
(void)total_inode_count;
|
(void)total_inode_count;
|
||||||
(void)free_inode_count;
|
(void)free_inode_count;
|
||||||
|
|
||||||
printf("% 10s", fs.characters());
|
printf("%-10s", fs.characters());
|
||||||
printf("%10u ", total_block_count);
|
printf("%10u ", total_block_count);
|
||||||
printf("%10u ", total_block_count - free_block_count);
|
printf("%10u ", total_block_count - free_block_count);
|
||||||
printf("%10u ", free_block_count);
|
printf("%10u ", free_block_count);
|
||||||
|
|
|
@ -88,7 +88,7 @@ int main(int, char**)
|
||||||
auto sum_diff = current.sum_nsched - prev.sum_nsched;
|
auto sum_diff = current.sum_nsched - prev.sum_nsched;
|
||||||
|
|
||||||
printf("\033[3J\033[H\033[2J");
|
printf("\033[3J\033[H\033[2J");
|
||||||
printf("\033[47;30m%6s %3s % 8s % 8s %6s %6s %4s %s\033[K\033[0m\n",
|
printf("\033[47;30m%6s %3s %-8s %-8s %6s %6s %4s %s\033[K\033[0m\n",
|
||||||
"PID",
|
"PID",
|
||||||
"PRI",
|
"PRI",
|
||||||
"USER",
|
"USER",
|
||||||
|
@ -118,7 +118,7 @@ int main(int, char**)
|
||||||
});
|
});
|
||||||
|
|
||||||
for (auto* process : processes) {
|
for (auto* process : processes) {
|
||||||
printf("%6d %c % 8s % 8s %6u %6u %2u.%1u %s\n",
|
printf("%6d %c %-8s %-8s %6u %6u %2u.%1u %s\n",
|
||||||
process->pid,
|
process->pid,
|
||||||
process->priority[0],
|
process->priority[0],
|
||||||
process->user.characters(),
|
process->user.characters(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue