On 4/19/19 3:38 AM, Jakub Jelinek wrote:
On Fri, Apr 19, 2019 at 11:28:41AM +0200, Christophe Lyon wrote:
--- a/contrib/check-internal-format-escaping.py
+++ b/contrib/check-internal-format-escaping.py
@@ -58,6 +58,10 @@ for i, l in enumerate(lines):
                          print('%s: %s' % (origin, text))
                      if re.search("[^%]'", p):
                          print('%s: %s' % (origin, text))
+                    # %< should not be preceded by a non-punctuation
+                    # %character.
+                    if re.search("[a-zA-Z0-9]%<", p):
+                        print('%s: %s' % (origin, text))
              j += 1

I'm not convinced we want this in check-internal-format-escaping.py
exactly because it is too fragile.

I have a patch that adds a -Wformat-diag warning that can detect
some of these kinds of problems.  For cases where the missing space
is intentional it relies on a pair of adjacent directives, as in
"%s%<%>foo" or "%s%s" with the "foo" being an argument.

Instead, we want what David Malcolm has proposed, for GCC 10 some
-Wformat-something (non-default) style warning or even a warning for
all string literals when there is
"str"
" str2"
or
"str"
"str2"

-Wformat-diag doesn't handle this because it runs as part of -Wformat

Basically require if there is a line break between two concatenated string
literals that there is a single space, either at the end of one chunk or
at the beginning of the other one.

...so that would still be a useful feature.

Martin

Reply via email to