summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonovan Baarda <abo@minkirri.apana.org.au>2018-02-20 23:51:50 +1100
committerDonovan Baarda <abo@minkirri.apana.org.au>2018-02-20 23:51:50 +1100
commitb8c0cdedffa636719c287dd14e91a3c80a8ea298 (patch)
tree0604d820ce0a4ddd8be11abbf743c5deef077ebd
parent4f992dbc8d46e42b0ff6949ef29a2c7924f5472e (diff)
downloadlibrsync-b8c0cdedffa636719c287dd14e91a3c80a8ea298.tar.gz
Make tidy target not indent librsync.h's 'extern "C" {...}' block.
It does this by hiding/restoring the enclosing brackets before/after calling indent.
-rw-r--r--CMakeLists.txt4
1 files changed, 4 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c162a5..8796e94 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -228,12 +228,16 @@ add_custom_target(tidy
# Note indent requires all userdefined types to be specified with '-T <type>' args to
# format them correctly. Rather than do that, we just postprocess with sed.
#
+ # Hide the enclosing 'extern "C" {...}' block for indenting in librsync.h
+ COMMAND sed -r -i "s:^(extern \"C\") \\{:\\1;:; s:^\\}(\\s+/\\* extern \"C\" \\*/):;\\1:" src/librsync.h
# Linux format with no tabs, indent 4, 120 wide code, 80 wide comments, format column1 comments.
COMMAND indent -linux -nut -i4 -l120 -lc80 -fc1 -fca -sob -T FILE -T Rollsum -T rs_result ${tidy_SRCS}
# Remove space between * or & and identifier after userdefined types,
# remove space after type cast for userdefined types like indent -ncs,
#and remove trailing whitespace.
COMMAND sed -r -i "s:((${TYPE_RE}|${CAST_RE}) (&|\\*+)) :\\1:g; s:(${CAST_RE}) :\\1:g; s:\\s+$::" ${tidy_SRCS}
+ # Restore the enclosing 'extern "C" {...}' block in librsync.h
+ COMMAND sed -r -i "s:^(extern \"C\");:\\1 {:; s:^;(\\s+/\\* extern \"C\" \\*/):}\\1:" src/librsync.h
VERBATIM
)
# Code tidyc target to reformat all code and comments with https://github.com/dbaarda/tidyc.