[libc-commits] [libc] [libc][stdio] Add support for the %m modifier (PR #218312)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Aug 25 16:47:52 PDT 2026


================
@@ -10,20 +10,27 @@
 #define LLVM_LIBC_SRC_STDIO_SCANF_CORE_STRING_CONVERTER_H
 
 #include "src/__support/CPP/limits.h"
+#include "src/__support/CPP/new.h"
+#include "src/__support/alloc-checker.h"
 #include "src/__support/ctype_utils.h"
+#include "src/__support/libc_errno.h"
 #include "src/__support/macros/config.h"
 #include "src/stdio/scanf_core/core_structs.h"
 #include "src/stdio/scanf_core/reader.h"
+#include "src/string/memory_utils/inline_memcpy.h"
 
 #include <stddef.h>
 
+constexpr int ALLOCATION_SCALE = 2;
+constexpr int ALLOCATION_BASE = 32;
+
 namespace LIBC_NAMESPACE_DECL {
 namespace scanf_core {
 
 template <typename T>
 int convert_string(Reader<T> *reader, const FormatSection &to_conv) {
   // %s "Matches a sequence of non-white-space characters"
-
+  // %m "Allocate max_width + 1 and null terminate"
----------------
michaelrj-google wrote:

the list up here is for the conversions, `m` is a flag. A format string of "%m" on its own doesn't have any meaning, it needs to be combined with one of the other conversions to make "%ms" or "%mc", etc.

https://github.com/llvm/llvm-project/pull/218312


More information about the libc-commits mailing list