[PATCH] D81667: [RFC, FileCheck] Add precision to format specifier

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 19 06:59:36 PDT 2020


thopre added a comment.

In D81667#2102317 <https://reviews.llvm.org/D81667#2102317>, @MaskRay wrote:

> I want to raise one point. Some people may expect format specifier to be similar to scanf, instead of printf. scanf uses similar but less powerful format specifiers than printf. For instance, `.` is not valid in scanf. `%.4u` should fail (though glibc appears to be weird things; musl is good). In scanf, `%4u` reads **at most** 4 digits, not exactly 4 digits. The only way is `%4c` plus a conversion -> this is certainly not suitable in FileCheck. Anyway `%.4u` stills looks good to me.


That's exactly the point of the second question in the description. Capturing a variable feels more like scanf but I think a unified syntax makes more sense. This is where we need to diverge from the printf/scanf analogy. Since the accepted format is defined explicitely in the documentation I don't think it's a big problem.

> If no variable is captured, is the syntax `[[#%.4u:]]`?

It would be #%.4u or simply #%.4 since u is the default format specifier.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81667/new/

https://reviews.llvm.org/D81667





More information about the llvm-commits mailing list