From 097180e963a233d4a763bd8fc790603fb337bfc4 Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Fri, 22 Sep 2017 05:27:28 +0200 Subject: [PATCH] put some braces back --- qcsrc/lib/iter.qh | 4 ++-- qcsrc/lib/test.qh | 2 +- qcsrc/tools/unc-macro-fix.py | 4 +++- qcsrc/tools/uncrustify-unmodified.py | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/qcsrc/lib/iter.qh b/qcsrc/lib/iter.qh index 4eae6d5d3..798d85874 100644 --- a/qcsrc/lib/iter.qh +++ b/qcsrc/lib/iter.qh @@ -54,8 +54,8 @@ #define STRING_ITERATOR_GET(this) str2chr(this##_s, this##_i++) #define STRING_ITERATOR_PEEK(this) str2chr(this##_s, this##_i) -#define STRING_ITERATOR_NEXT(this) MACRO_BEGIN ++this##_i; MACRO_END -#define STRING_ITERATOR_UNGET(this) MACRO_BEGIN --this##_i; MACRO_END +#define STRING_ITERATOR_NEXT(this) MACRO_BEGIN { ++this##_i; } MACRO_END +#define STRING_ITERATOR_UNGET(this) MACRO_BEGIN { --this##_i; } MACRO_END #define STRING_ITERATOR_SAVE(this) this##_i #define STRING_ITERATOR_LOAD(this, n) MACRO_BEGIN this##_i = n; MACRO_END diff --git a/qcsrc/lib/test.qh b/qcsrc/lib/test.qh index 549c9447c..f0fef90c8 100644 --- a/qcsrc/lib/test.qh +++ b/qcsrc/lib/test.qh @@ -15,7 +15,7 @@ #define SUCCEED() (TEST_ok = true) /** Add a failure, but continue */ -#define ADD_FAILURE(msg) MACRO_BEGIN ++TEST_failed; LOG_WARN(msg); MACRO_END +#define ADD_FAILURE(msg) MACRO_BEGIN { ++TEST_failed; LOG_WARN(msg); } MACRO_END /** Add a failure and return */ #define FAIL(msg) _TEST_ASSERT(ADD_FAILURE(msg)) diff --git a/qcsrc/tools/unc-macro-fix.py b/qcsrc/tools/unc-macro-fix.py index c2ada261f..898583b02 100755 --- a/qcsrc/tools/unc-macro-fix.py +++ b/qcsrc/tools/unc-macro-fix.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 -# removes redundant { and } from macros because uncrustify is too dumb to indent them properly (or even not touch them) +# Removes redundant { and } from macros because uncrustify is too dumb to indent them properly (or even not touch them). +# Actually, after running this, you might wanna put some back, for cases like `MACRO_BEGIN { ++this##_i; } MACRO_END`, +# otherwise it ends up like MACRO_BEGIN++ ... sigh' # all those fancy unix utilities like grep, sed and awk are either woefully inadequate for this or just completely # unreadable with their arcane syntaxes - and yes, the plural is intentional because why extend existing tools diff --git a/qcsrc/tools/uncrustify-unmodified.py b/qcsrc/tools/uncrustify-unmodified.py index 91179f4f1..a346d46cb 100755 --- a/qcsrc/tools/uncrustify-unmodified.py +++ b/qcsrc/tools/uncrustify-unmodified.py @@ -22,7 +22,8 @@ def main(): # get all remote branches - those would potentially get merge conflicts if we formatted everything branches = run('git branch --list --remotes') - branches = [b.strip() for b in branches] + # strip the leading spaces and ignore branches that are presumably used for debugging uncrustify + branches = [b.strip() for b in branches if "uncrustify" not in b] branches.remove('origin/HEAD -> origin/master') branches.remove('origin/master') -- 2.39.2