[tracker/sam/uncrustify] WIP: Improve Uncrustify configuration
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sam/uncrustify] WIP: Improve Uncrustify configuration
- Date: Mon, 15 Apr 2019 09:21:08 +0000 (UTC)
commit 5ce6a55248f88a4525ccfdf4400e5e4ea33b7818
Author: Sam Thursfield <sam afuera me uk>
Date: Sun Apr 14 16:41:04 2019 +0200
WIP: Improve Uncrustify configuration
This adds a utils/run-uncrustify.sh script, which can be used to fix
the indentation of the Tracker source code while ignoring certain files
(copied in from other projects) which don't match the normal style.
The uncrustify configuration is improved, but there are still at least
two major issues that make it unusuable:
* Aligning of variable definitions in function bodies is somewhat
random and I don't yet understand how the relevant configuration
options are supposed to work.
* struct initializers (specificially GOptionEntry structs) are
uglified, by moving the closing '}' character onto the same line
as the last struct value. We actually want a newline here and I
haven't yet found an option in Uncrustify to enable this behaviour.
See also: https://gitlab.gnome.org/GNOME/tracker/issues/90
utils/run-uncrustify.sh | 24 ++++++++++++++++++++++++
utils/uncrustify.cfg | 23 ++++++++++++++++++++---
2 files changed, 44 insertions(+), 3 deletions(-)
---
diff --git a/utils/run-uncrustify.sh b/utils/run-uncrustify.sh
new file mode 100755
index 000000000..100c02943
--- /dev/null
+++ b/utils/run-uncrustify.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# Adapted from Nautilus:
+# https://gitlab.gnome.org/GNOME/nautilus/blob/master/data/run-uncrustify.sh
+
+DATA=$(dirname "$BASH_SOURCE")
+UNCRUSTIFY=$(command -v uncrustify)
+
+if [ -z "$UNCRUSTIFY" ];
+then
+ echo "Uncrustify is not installed on your system."
+ exit 1
+fi
+
+for DIR in {src/libtracker-*,src/tracker,src/tracker-store}
+do
+ for FILE in $(find "$DIR" -name "*.c")
+ do
+ if [ "$FILE" != "src/libtracker-fts/fts5.c" ]; then
+ "$UNCRUSTIFY" -c "./utils/uncrustify.cfg" --no-backup "$FILE"
+ fi
+ done
+done
+
diff --git a/utils/uncrustify.cfg b/utils/uncrustify.cfg
index 433c6999a..f1b087140 100644
--- a/utils/uncrustify.cfg
+++ b/utils/uncrustify.cfg
@@ -1,13 +1,30 @@
# Configuration for formatting Tracker source code using the
# 'uncrustify' indent tool.
-align_func_params = true
+align_keep_extra_space = true
+align_keep_tabs = true
+align_with_tabs = false
+
+indent_with_tabs = 1
+align_func_params = true
+align_nl_cont = false
align_var_def_star_style = 2
-sp_after_ptr_star = remove
+sp_after_ptr_star = ignore
sp_after_semi_for = ignore
sp_after_semi_for_empty = ignore
-align_nl_cont = true
+### Trying to get struct initializers to be left alone ...
+eat_blanks_before_close_brace = false
+nl_remove_extra_newlines = 0
+nl_constr_init_args = ignore
+nl_brace_brace = ignore
+nl_collapse_empty_body = false
+
+# Align variable definitions in function bodies and at the toplevel.
+align_var_def_span = 4
+align_var_def_thresh = 8
+# Align variable definitions in structs.
+align_var_struct_span = 4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]