From cf7910fc1e8969e01cf006ee0000f2cc030c6811 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Thu, 5 Dec 2019 13:19:25 +0300 Subject: [PATCH] AK: Implement %n printf specifier This is a special specifier that does not output anything to the stream, but saves the number of already output chars to the provided pointer. This is apparently used by GNU Nano. --- AK/PrintfImplementation.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index 59d4f5e319..cfa68c1af0 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -358,6 +358,11 @@ template case 'p': ret += print_hex(putch, bufptr, va_arg(ap, u32), *p == 'P', true, false, true, 8); break; + + case 'n': + *va_arg(ap, int*) = ret; + break; + default: dbg() << "printf_internal: Unimplemented format specifier " << *p << " (fmt: " << fmt << ")"; }