summaryrefslogtreecommitdiffstats
path: root/development/uncrustify
diff options
context:
space:
mode:
Diffstat (limited to 'development/uncrustify')
-rw-r--r--development/uncrustify/nl_func_leave_one_liners.patch104
-rw-r--r--development/uncrustify/uncrustify.SlackBuild4
2 files changed, 106 insertions, 2 deletions
diff --git a/development/uncrustify/nl_func_leave_one_liners.patch b/development/uncrustify/nl_func_leave_one_liners.patch
new file mode 100644
index 0000000000..60c43119cb
--- /dev/null
+++ b/development/uncrustify/nl_func_leave_one_liners.patch
@@ -0,0 +1,104 @@
+From 06822aa69bf460b5ef0363f2a0cf69ec7a426bda Mon Sep 17 00:00:00 2001
+From: Guy Maurel <g.maurel@agwest.de>
+Date: Fri, 29 Nov 2019 18:04:25 +0100
+Subject: nl_func_leave_one_liners is now completed
+
+Ref. #2561
+
+diff --git a/src/newlines.cpp b/src/newlines.cpp
+index a7db6181..576cd874 100644
+--- a/src/newlines.cpp
++++ b/src/newlines.cpp
+@@ -2782,12 +2782,30 @@ static void newline_func_def_or_call(chunk_t *start)
+
+ if (tmp_next != nullptr && tmp_next->type != CT_FUNC_CLASS_DEF)
+ {
+- bool is_proto = ( tmp->parent_type == CT_FUNC_PROTO
+- || tmp->parent_type == CT_FUNC_CLASS_PROTO);
+- iarf_e a = (is_proto) ?
+- options::nl_func_proto_type_name() :
+- (options::nl_func_leave_one_liners()) ? // Issue #1511
+- IARF_IGNORE : options::nl_func_type_name();
++ chunk_t *closing = chunk_skip_to_match(tmp);
++ chunk_t *brace = chunk_get_next_ncnl(closing);
++ iarf_e a; // Issue #2561
++
++ if ( tmp->parent_type == CT_FUNC_PROTO
++ || tmp->parent_type == CT_FUNC_CLASS_PROTO)
++ {
++ // proto
++ a = options::nl_func_proto_type_name();
++ }
++ else
++ {
++ // def
++
++ if ( options::nl_func_leave_one_liners()
++ && brace->flags.test(PCF_ONE_LINER)) // Issue #1511
++ {
++ a = IARF_IGNORE;
++ }
++ else
++ {
++ a = options::nl_func_type_name();
++ }
++ }
+
+ if ( tmp->flags.test(PCF_IN_CLASS)
+ && (options::nl_func_type_name_class() != IARF_IGNORE))
+diff --git a/tests/config/Issue_2561.cfg b/tests/config/Issue_2561.cfg
+new file mode 100644
+index 00000000..03a40504
+--- /dev/null
++++ b/tests/config/Issue_2561.cfg
+@@ -0,0 +1,5 @@
++sp_func_def_paren = force
++indent_columns = 3
++nl_func_leave_one_liners = true
++nl_func_type_name = force
++mod_add_long_function_closebrace_comment = 1
+diff --git a/tests/cpp.test b/tests/cpp.test
+index 77797aed..39c7e421 100644
+--- a/tests/cpp.test
++++ b/tests/cpp.test
+@@ -96,6 +96,7 @@
+ 30085 nSolve.cfg cpp/align_class.cpp
+ 30086 align_class-constr.cfg cpp/align_class-constr.cpp
+ 30087 Issue_1511.cfg cpp/Issue_1511.cpp
++30088 Issue_2561.cfg cpp/Issue_2561.cpp
+
+ 30090 bug_488.cfg cpp/bug_488.cpp
+ 30091 bug_472.cfg cpp/bug_472.cpp
+diff --git a/tests/expected/cpp/30088-Issue_2561.cpp b/tests/expected/cpp/30088-Issue_2561.cpp
+new file mode 100644
+index 00000000..aa566966
+--- /dev/null
++++ b/tests/expected/cpp/30088-Issue_2561.cpp
+@@ -0,0 +1,11 @@
++#include <stdio.h>
++
++int getFoo () { return foo; }
++
++int
++main (int argc, char *argv[])
++{
++ printf("hello world!\n");
++
++ return 0;
++} // main
+diff --git a/tests/input/cpp/Issue_2561.cpp b/tests/input/cpp/Issue_2561.cpp
+new file mode 100644
+index 00000000..15232fc4
+--- /dev/null
++++ b/tests/input/cpp/Issue_2561.cpp
+@@ -0,0 +1,10 @@
++#include <stdio.h>
++
++int getFoo() { return foo; }
++
++int main (int argc, char *argv[])
++{
++ printf("hello world!\n");
++
++ return 0;
++}
diff --git a/development/uncrustify/uncrustify.SlackBuild b/development/uncrustify/uncrustify.SlackBuild
index d10882bd5d..3695cc75b8 100644
--- a/development/uncrustify/uncrustify.SlackBuild
+++ b/development/uncrustify/uncrustify.SlackBuild
@@ -6,7 +6,7 @@
PRGNAM=uncrustify
VERSION=${VERSION:-0.70.1}
-BUILD=${BUILD:-1}
+BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
@@ -46,7 +46,7 @@ find -L . \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
-
+patch -p1 < $CWD/nl_func_leave_one_liners.patch
mkdir -p build
cd build
cmake \