From 9190f516b1a7bea97888eafdef562d8925de2701 Mon Sep 17 00:00:00 2001 From: Marcus Brummer Date: Tue, 3 Mar 2020 10:49:13 +0100 Subject: [PATCH] Improved custom Android template exports Prevent newlines from beeing appended in AndroidManifest.xml and build.gradle. Fixes #36708. --- platform/android/export/export.cpp | 48 +++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 5c44a16c8f6..884a239f7fe 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1854,6 +1854,7 @@ public: while (!f->eof_reached()) { String l = f->get_line(); + bool append_line = false; if (l.begins_with("//CHUNK_")) { String text = l.replace_first("//CHUNK_", ""); int begin_pos = text.find("_BEGIN"); @@ -1885,10 +1886,14 @@ public: new_file += E->get() + "\n"; } } - new_file += end_marker + "\n"; + if (f->eof_reached()) { + new_file += end_marker; + } else { + new_file += end_marker + "\n"; + } } } else { - new_file += l + "\n"; //pass line by + append_line = true; } } else if (l.begins_with("//DIR_")) { String text = l.replace_first("//DIR_", ""); @@ -1921,14 +1926,25 @@ public: new_file += "\n"; } } - new_file += end_marker + "\n"; + if (f->eof_reached()) { + new_file += end_marker; + } else { + new_file += end_marker + "\n"; + } } } else { - new_file += l + "\n"; //pass line by + append_line = true; } - } else { - new_file += l + "\n"; + append_line = true; + } + + if (append_line) { + if (f->eof_reached()) { + new_file += l; + } else { + new_file += l + "\n"; + } } } } @@ -1949,6 +1965,7 @@ public: while (!f->eof_reached()) { String l = f->get_line(); + bool append_line = false; if (l.begins_with(""); @@ -1979,10 +1996,14 @@ public: new_file += E->get() + "\n"; } } - new_file += end_marker + "\n"; + if (f->eof_reached()) { + new_file += end_marker; + } else { + new_file += end_marker + "\n"; + } } } else { - new_file += l + "\n"; //pass line by + append_line = true; } } else if (l.strip_edges().begins_with("eof_reached()) { + new_file += "\n"; + } } } }