mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +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;
|
||||
|
||||
for (p = fmt; *p; ++p) {
|
||||
bool leftPad = false;
|
||||
bool left_pad = false;
|
||||
bool zeroPad = false;
|
||||
unsigned fieldWidth = 0;
|
||||
unsigned long_qualifiers = 0;
|
||||
|
@ -204,8 +204,8 @@ template<typename PutChFunc>
|
|||
if (*p == '%' && *(p + 1)) {
|
||||
one_more:
|
||||
++p;
|
||||
if (*p == ' ') {
|
||||
leftPad = true;
|
||||
if (*p == '-') {
|
||||
left_pad = true;
|
||||
if (*(p + 1))
|
||||
goto one_more;
|
||||
}
|
||||
|
@ -233,19 +233,19 @@ template<typename PutChFunc>
|
|||
switch (*p) {
|
||||
case 's': {
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
case 'q':
|
||||
|
@ -256,7 +256,7 @@ template<typename PutChFunc>
|
|||
case 'g':
|
||||
case 'f':
|
||||
// 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;
|
||||
#endif
|
||||
|
||||
|
@ -265,7 +265,7 @@ template<typename PutChFunc>
|
|||
putch(bufptr, '0');
|
||||
++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;
|
||||
|
||||
case 'x':
|
||||
|
|
|
@ -196,7 +196,7 @@ ByteBuffer procfs$pid_fds(InodeIdentifier identifier)
|
|||
auto* description = process.file_description(i);
|
||||
if (!description)
|
||||
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();
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ ByteBuffer procfs$pid_vm(InodeIdentifier identifier)
|
|||
flags_builder.append('R');
|
||||
if (region->is_writable())
|
||||
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().offset(region->size() - 1).get(),
|
||||
region->size(),
|
||||
|
@ -544,7 +544,7 @@ ByteBuffer procfs$summary(InodeIdentifier)
|
|||
StringBuilder builder;
|
||||
builder.appendf("PID TPG PGP SID OWNER STATE PPID NSCHED FDS TTY NAME\n");
|
||||
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->tty() ? process->tty()->pgid() : 0,
|
||||
process->pgid(),
|
||||
|
|
|
@ -231,13 +231,13 @@ bool Scheduler::pick_next()
|
|||
dbgprintf("Non-runnables:\n");
|
||||
for (auto* thread = g_nonrunnable_threads->head(); thread; thread = thread->next()) {
|
||||
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");
|
||||
for (auto* thread = g_runnable_threads->head(); thread; thread = thread->next()) {
|
||||
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
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ int main(int, char**)
|
|||
(void)total_inode_count;
|
||||
(void)free_inode_count;
|
||||
|
||||
printf("% 10s", fs.characters());
|
||||
printf("%-10s", fs.characters());
|
||||
printf("%10u ", total_block_count);
|
||||
printf("%10u ", total_block_count - 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;
|
||||
|
||||
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",
|
||||
"PRI",
|
||||
"USER",
|
||||
|
@ -118,7 +118,7 @@ int main(int, char**)
|
|||
});
|
||||
|
||||
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->priority[0],
|
||||
process->user.characters(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue