mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-18 21:55:45 +00:00
Add a String::format() and use that in place of ksprintf() in the Kernel.
You're never gonna be right 100% of the time when guessing how much buffer space you need. This avoids having to make that type of decision in a bunch of cases. :^)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "AKString.h"
|
||||
#include "StdLibExtras.h"
|
||||
#include "StringBuilder.h"
|
||||
#include <LibC/stdarg.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
@@ -92,4 +94,14 @@ unsigned String::toUInt(bool& ok) const
|
||||
return value;
|
||||
}
|
||||
|
||||
String String::format(const char* fmt, ...)
|
||||
{
|
||||
StringBuilder builder;
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
builder.appendvf(fmt, ap);
|
||||
va_end(ap);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user