diff --git a/gclc/src/main/java/fr/bigeon/gclc/GCLCConstants.java b/gclc/src/main/java/fr/bigeon/gclc/GCLCConstants.java index e16977a..5045b6b 100644 --- a/gclc/src/main/java/fr/bigeon/gclc/GCLCConstants.java +++ b/gclc/src/main/java/fr/bigeon/gclc/GCLCConstants.java @@ -51,11 +51,19 @@ import fr.bigeon.gclc.exception.CommandParsingException; * @author Emmanuel Bigeon */ public class GCLCConstants { + /** The escaping character */ + private static final char ESCAPING_CHAR = getSystemEscapingChar(); + /** Hide utility class constructor */ private GCLCConstants() { // utility class } + /** @return the escaping character */ + private static char getSystemEscapingChar() { + return '\\'; + } + /** Splits a command in the diferrent arguments * * @param cmd the command to split in its parts @@ -71,7 +79,7 @@ public class GCLCConstants { while (index < cmd.length()) { char c = cmd.charAt(index); index++; - if (escaped || c == '\\') { + if (escaped || c == ESCAPING_CHAR) { escaped = !escaped; continue; } @@ -102,11 +110,11 @@ public class GCLCConstants { private static String removeEscaped(String arg) { StringBuilder builder = new StringBuilder(); int index = 0; - int endIndex = arg.indexOf('\\'); + int endIndex = arg.indexOf(ESCAPING_CHAR); while (endIndex != -1) { builder.append(arg.subSequence(index, endIndex)); index = endIndex + 1; - endIndex = arg.indexOf('\\', index + 1); + endIndex = arg.indexOf(ESCAPING_CHAR, index + 1); } builder.append(arg.substring(index)); return builder.toString();