]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
check-format.pl: Fix report on missing space before +/-: allow, e.g., '1e-6'
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Thu, 6 Jan 2022 21:54:20 +0000 (22:54 +0100)
committerPauli <ppzgs1@gmail.com>
Sun, 9 Jan 2022 02:19:52 +0000 (13:19 +1100)
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17434)

util/check-format-test-negatives.c
util/check-format.pl

index 8f6ed23ee72e75680e32323e654d368e71220e83..3ea792a72fcb788f48c99cec75e16f3fdc006f2c 100644 (file)
@@ -190,6 +190,11 @@ X509 *x509 = NULL;
 int y = a + 1 < b;
 int ret, was_NULL = *certs == NULL;
 
+/* should not trigger: no space before binary ... operator */
+float z = 1e-6 * (-1) * b[+6] * 1e+1 * (a)->f * (long)+1
+    - (tmstart.tv_sec + tmstart.tv_nsec * 1e-9);
+struct st = {-1, 0};
+
 const OPTIONS passwd_options[] = {
     {"aixmd5", OPT_AIXMD5, '-', "AIX MD5-based password algorithm"},
 #if !defined(OPENSSL_NO_DES) && !defined(OPENSSL_NO_DEPRECATED_3_0)
index 8861b2bd8ac886ed532f0a5de224dc75e858de0e..836fe30fa910b3aa85cf236e37d2d399bbf9d73b 100755 (executable)
@@ -691,8 +691,8 @@ while (<>) { # loop over all lines of all input files
         report("no space before '=' or '<op>='") if $intra_line =~ m/\S(=)/;   # '=' etc. without preceding space
         report("no space before '$1'")  if $intra_line =~ m/\S([|\/%<>^\?])/;  # |/%<>^? without preceding space
         # TODO ternary ':' without preceding SPC, while allowing no SPC before ':' after 'case'
-        report("no space before binary '$1'")  if $intra_line =~ m/[^\s{()\[]([+\-])/;# +/- without preceding space or {()[
-                                                                             # or ')' (which is used f type casts)
+        report("no space before binary '$2'")  if $intra_line =~ m/([^\s{()\[e])([+\-])/; # '+'/'-' without preceding space or {()[e
+        # ')' may be used for type casts or before "->", 'e' may be used for numerical literals such as "1e-6"
         report("no space before binary '$1'")  if $intra_line =~ m/[^\s{()\[*!]([*])/; # '*' without preceding space or {()[*!
         report("no space before binary '$1'")  if $intra_line =~ m/[^\s{()\[]([&])/;  # '&' without preceding space or {()[
         report("no space after ternary '$1'") if $intra_line =~ m/(:)[^\s\d]/; # ':' without following space or digit