1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

[255946] - fixing escaping for MI output, patch applied kind of

This commit is contained in:
Alena Laskavaia 2009-05-19 15:34:40 +00:00
parent 57756dcb6c
commit 593cd79862

View file

@ -237,11 +237,7 @@ public class MIParser {
stream = new MILogStreamOutput(); stream = new MILogStreamOutput();
break; break;
} }
// translateCString() assumes that the leading " is deleted stream.setCString(removeSurroundingDoubleQuotes(buffer.toString()));
if (buffer.length() > 0 && buffer.charAt(0) == '"') {
buffer.deleteCharAt(0);
}
stream.setCString(translateCString(new FSB(buffer)));
oob = stream; oob = stream;
} else { } else {
// Badly format MI line, just pass it to the user as target stream // Badly format MI line, just pass it to the user as target stream
@ -252,9 +248,22 @@ public class MIParser {
return oob; return oob;
} }
private String removeSurroundingDoubleQuotes(String str) {
String s = str;
// remove leading double quote
if (s.startsWith("\"")) { //$NON-NLS-1$
s = s.substring(1);
}
// remove trailing double quote
if (s.endsWith("\"")) { //$NON-NLS-1$
s = s.substring(0, s.length() - 1);
}
return s;
}
/** /**
* Assuming that the usual leading comma was consumed. * Assuming that the usual leading comma was consumed.
* Extract the MI Result comma seperated responses. * Extract the MI Result comma separated responses.
*/ */
private MIResult[] processMIResults(FSB buffer) { private MIResult[] processMIResults(FSB buffer) {
List aList = new ArrayList(); List aList = new ArrayList();
@ -389,12 +398,12 @@ public class MIParser {
} }
/* /*
* MI C-String rather MICOnst values are enclose in double quotes * MI C-String rather MIConst values are enclose in double quotes
* and any double quotes or backslash in the string are escaped. * and any double quotes or backslash in the string are escaped.
* Assuming the starting double quote was removed. * Assuming the starting double quote was removed.
* This method will stop at the closing double quote remove the extra * This method will stop at the closing double quote remove the extra
* backslach escaping and return the string __without__ the enclosing double quotes * backslash escaping and return the string __without__ the enclosing double quotes
* The orignal StringBuffer will move forward. * The original StringBuffer will move forward.
*/ */
private String translateCString(FSB buffer) { private String translateCString(FSB buffer) {
boolean escape = false; boolean escape = false;