[Libreoffice-commits] core.git: bin/update_pch

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 8 15:23:13 UTC 2021


 bin/update_pch |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit 15a0bdd32df89aa8d2e5ab49e07061f0708651e6
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Thu Apr 8 13:41:30 2021 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Thu Apr 8 17:22:14 2021 +0200

    make update_pch.sh aware of '#pragma once'
    
    Headers are allowed to have one #if block that is not ignored,
    on the assumption that it is the include guard. This shouldn't
    be the case if the header uses #pragma once, obviously.
    
    Change-Id: Ib0aa0933ce224ca4e3ecf209593852da0f4ca5ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113799
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/bin/update_pch b/bin/update_pch
index 9b541d8a87a9..974d53ab9197 100755
--- a/bin/update_pch
+++ b/bin/update_pch
@@ -727,6 +727,12 @@ def process_source(root, module, filename, maxdepth=0):
                 else:
                     lastif = '#if'
                 del allowed_ifs[ ifdepth ]
+            elif line.startswith('#pragma once'):
+                # maxdepth == 1 means we are parsing a header file
+                # and are allowed one #ifdef block (the include guard),
+                # but in the #pragma once case do not allow that
+                assert maxdepth == 1
+                maxdepth = 0
             elif line.startswith('#include'):
                 if ifdepth - ifsallowed <= maxdepth:
                     line = sanitize(line)


More information about the Libreoffice-commits mailing list