Backported commits 5f3f392a and fb66774e from upstream. This solves upstream issues 3040.

Upstream commit message:

-----------------------------------------------------------
commit 5f3f392a3b8fc6dc334d6f688b9a57e06827579b
Author: Guy Maurel <guy.j@maurel.de>
Date:   Sat Jan 2 18:59:46 2021 +0100

    insert closing brace before the preprocessor line

M  src/braces.cpp
A  tests/config/Issue_3040.cfg
M  tests/cpp.test
A  tests/expected/cpp/34326-Issue_3040.cpp
A  tests/input/cpp/Issue_3040.cpp

commit fb66774e46b1b0f93b548ed172126619fcbd6723
Author: Guy Maurel <guy.j@maurel.de>
Date:   Sun Jan 3 18:08:13 2021 +0100

    insert after #endif

M  src/braces.cpp
M  tests/expected/cpp/34326-Issue_3040.cpp
M  tests/input/cpp/Issue_3040.cpp
-----------------------------------------------------------

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/3/head
Michele Calgaro 3 years ago
parent eaaea17529
commit bad411472a
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -1,7 +1,14 @@
uncrustify-trinity (0.72.0-0debian11.0.0+7) unstable; urgency=medium
* TDE version 0.72-0+7
* Backported commits 5f3f392a and fb66774e from upstream.
-- Michele Calgaro <michele.calgaro@yahoo.it> Thu, 05 Jan 2021 11:08:00 +0900
uncrustify-trinity (0.72.0-0debian11.0.0+6) unstable; urgency=medium
* TDE version of upstream 0.72-0+6
* Backported commits 45681e88 and 64d93e3fb.
* TDE version 0.72-0+6
* Backported commits 45681e88 and 64d93e3fb from upstream.
-- Michele Calgaro <michele.calgaro@yahoo.it> Thu, 24 Dec 2020 20:14:00 +0900

@ -0,0 +1,183 @@
Backported commits 5f3f392a and fb66774e from upstream. This solves upstream issues 3040.
--- a/src/braces.cpp
+++ b/src/braces.cpp
@@ -1290,7 +1290,7 @@
static chunk_t *mod_case_brace_add(chunk_t *cl_colon)
{
LOG_FUNC_ENTRY();
- LOG_FMT(LMCB, "%s(%d): line %zu",
+ LOG_FMT(LMCB, "%s(%d): line %zu\n",
__func__, __LINE__, cl_colon->orig_line);
chunk_t *pc = cl_colon;
@@ -1309,7 +1309,28 @@
&& ( chunk_is_token(pc, CT_CASE)
|| chunk_is_token(pc, CT_BREAK)))
{
- last = pc;
+ // check if previous line is a preprocessor Issue #3040
+ chunk_t *prev = chunk_get_prev_ncnl(pc);
+ LOG_FMT(LMCB, "%s(%d): prev->text() is '%s', orig_line %zu\n",
+ __func__, __LINE__, prev->text(), prev->orig_line);
+
+ if ( chunk_is_preproc(prev)
+ && chunk_is_not_token(prev, CT_PP_ENDIF))
+ {
+ // previous line is a preprocessor, but NOT #endif
+ while (chunk_is_preproc(prev))
+ {
+ prev = chunk_get_prev_ncnl(prev);
+ }
+ chunk_t *next_prev = chunk_get_next_ncnl(prev);
+ LOG_FMT(LMCB, "%s(%d): next_prev->text() is '%s', orig_line %zu\n",
+ __func__, __LINE__, next_prev->text(), next_prev->orig_line);
+ last = next_prev;
+ }
+ else
+ {
+ last = pc;
+ }
break;
}
}
--- /dev/null
+++ b/tests/config/Issue_3040.cfg
@@ -0,0 +1,7 @@
+indent_columns = 2
+indent_switch_case = 2
+nl_before_case = true
+nl_after_case = true
+eat_blanks_before_close_brace = true
+mod_move_case_break = true
+mod_case_brace = force
--- a/tests/cpp.test
+++ b/tests/cpp.test
@@ -827,6 +827,7 @@
34322 issue_2623_1.cfg cpp/issue_2623.cpp
34323 issue_2623_2.cfg cpp/issue_2623.cpp
34324 issue_2623_3.cfg cpp/issue_2623.cpp
+34326 Issue_3040.cfg cpp/Issue_3040.cpp
# Adopt some UT tests
10000 empty.cfg cpp/621_this-spacing.cpp
--- /dev/null
+++ b/tests/expected/cpp/34326-Issue_3040.cpp
@@ -0,0 +1,62 @@
+void main()
+{
+ switch (opcode ) {
+
+ case LocaleCompare:
+ {
+ return Number(localeCompare(s, a0.toString(exec)));
+ }
+
+#ifndef KJS_PURE_ECMA
+ case Big:
+ {
+ result = String("<big>" + s + "</big>");
+ break;
+ }
+#endif
+ }
+
+ switch (ev->command)
+ {
+ case (MIDI_NOTEON):
+ {
+ ev->note = *ptrdata; ptrdata++; currentpos++;
+ ev->vel = *ptrdata; ptrdata++; currentpos++;
+ if (ev->vel==0)
+ note[ev->chn][ev->note]=FALSE;
+ else
+ note[ev->chn][ev->note]=TRUE;
+
+#ifdef TRACKDEBUG2
+ if (ev->chn==6) {
+ if (ev->vel==0) printfdebug("Note Onf\n");
+ else printfdebug("Note On\n");
+ };
+#endif
+ break;
+ }
+
+ case (MIDI_NOTEOFF):
+ {
+#ifdef TRACKDEBUG2
+ if (ev->chn==6) printfdebug("Note Off\n");
+#endif
+ ev->note = *ptrdata; ptrdata++; currentpos++;
+ ev->vel = *ptrdata; ptrdata++; currentpos++;
+ note[ev->chn][ev->note]=FALSE;
+
+ break;
+ }
+
+ case (MIDI_KEY_PRESSURE):
+ {
+#ifdef TRACKDEBUG2
+ if (ev->chn==6) printfdebug ("Key press\n");
+#endif
+ ev->note = *ptrdata; ptrdata++; currentpos++;
+ ev->vel = *ptrdata; ptrdata++; currentpos++;
+ break;
+ }
+ }
+}
+
--- /dev/null
+++ b/tests/input/cpp/Issue_3040.cpp
@@ -0,0 +1,52 @@
+void main()
+{
+ switch (opcode ) {
+
+ case LocaleCompare:
+ return Number(localeCompare(s, a0.toString(exec)));
+
+#ifndef KJS_PURE_ECMA
+ case Big:
+ result = String("<big>" + s + "</big>");
+ break;
+#endif
+
+ }
+
+ switch (ev->command)
+ {
+ case (MIDI_NOTEON):
+ ev->note = *ptrdata; ptrdata++; currentpos++;
+ ev->vel = *ptrdata; ptrdata++; currentpos++;
+ if (ev->vel==0)
+ note[ev->chn][ev->note]=FALSE;
+ else
+ note[ev->chn][ev->note]=TRUE;
+
+#ifdef TRACKDEBUG2
+ if (ev->chn==6) {
+ if (ev->vel==0) printfdebug("Note Onf\n");
+ else printfdebug("Note On\n");
+ };
+#endif
+ break;
+ case (MIDI_NOTEOFF) :
+#ifdef TRACKDEBUG2
+ if (ev->chn==6) printfdebug("Note Off\n");
+#endif
+ ev->note = *ptrdata;ptrdata++;currentpos++;
+ ev->vel = *ptrdata;ptrdata++;currentpos++;
+ note[ev->chn][ev->note]=FALSE;
+
+ break;
+ case (MIDI_KEY_PRESSURE) :
+#ifdef TRACKDEBUG2
+ if (ev->chn==6) printfdebug ("Key press\n");
+#endif
+ ev->note = *ptrdata;ptrdata++;currentpos++;
+ ev->vel = *ptrdata;ptrdata++;currentpos++;
+ break;
+
+ }
+}
+

@ -4,3 +4,4 @@
004_fixed_usage.diff
005_upstream_45681e88.diff
006_upstream_64d93e3fb.diff
007_issue_3040.diff

Loading…
Cancel
Save