diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java index ca53a8dbf0..c5643990f6 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java @@ -403,28 +403,16 @@ public class OsMoThread { } private StringBuilder prepareCommand(String l) { - boolean addNL = true; - StringBuilder res = new StringBuilder(); - int i = 0; - while (true) { - int ni = l.indexOf('\n'); - if (ni == l.length() - 1) { - res.append(l.substring(i)); - addNL = false; - break; - } else if (ni == -1) { - res.append(l.substring(i)); - break; - } else { - res.append(l.substring(i, ni)); - res.append("\\").append("n"); + StringBuilder res = new StringBuilder(l.length()); + for(int i = 0; i < l.length(); i++) { + char c = l.charAt(i); + if(c == '\n' || c == '=' || c == '\\') { + res.append('\\') } - i = ni + 1; + res.append(c); } - if (addNL) { - l += "\n"; - } - return res; + + return res.toString().trim() +"=\n" } public long getLastCommandTime() {