From 0d121179f819cf3b1ed355f7ea0e03b98eb205eb Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Mon, 10 Jan 2005 20:33:50 +0000 Subject: [PATCH] 2005-01-10 Alain Magloire Fix for PR 82506 * mi/org/eclipse/cdt/debug/mi/core/MISession.java * mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java --- debug/org.eclipse.cdt.debug.mi.core/ChangeLog | 5 ++++ .../eclipse/cdt/debug/mi/core/MISession.java | 2 +- .../cdt/debug/mi/core/output/MIParser.java | 26 ++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index 6b81b21dcee..21c5090a0fc 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,8 @@ +2005-01-10 Alain Magloire + Fix for PR 82506 + * mi/org/eclipse/cdt/debug/mi/core/MISession.java + * mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java + 2004-12-20 Alain Magloire Fix for PR 81019 for MacOsX * mi/org/eclipse/cdt/debug/mi/core/output/MIVarListChildrenInfo.java diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java index 0c9b0b43512..4d278fa6f5d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java @@ -175,7 +175,7 @@ public class MISession extends Observable { MIGDBShowInfo infoPrompt = prompt.getMIGDBShowInfo(); String value = infoPrompt.getValue(); if (value != null && value.length() > 0) { - parser.primaryPrompt = value.trim(); + parser.cliPrompt = value.trim(); } } catch (MIException exc) { // Kill the Transmition thread. diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java index 1ce6d75b56d..580ead2750c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/output/MIParser.java @@ -91,6 +91,7 @@ import java.util.StringTokenizer; public class MIParser { public String primaryPrompt = "(gdb)"; //$NON-NLS-1$ + public String cliPrompt = primaryPrompt; public String secondaryPrompt = ">"; //$NON-NLS-1$ /** @@ -130,7 +131,7 @@ public class MIParser { if (token.charAt(0) == '^') { token.deleteCharAt(0); rr = processMIResultRecord(token, id); - } else if (token.toString().startsWith(primaryPrompt)) { + } else if (startsWith(token, primaryPrompt)) { //break; // Do nothing. } else { MIOOBRecord band = processMIOOBRecord(token, id); @@ -414,6 +415,29 @@ public class MIParser { return sb.toString(); } + /** + * Tests if this string starts with the specified prefix beginning + * a specified index. + * + * @param value the string. + * @param prefix the prefix. + * @return true if prefix starts value. + */ + public boolean startsWith(StringBuffer value, String prefix) { + int vlen = value.length(); + int plen = prefix.length(); + + if (vlen < plen) { + return false; + } + for (int i = 0; i < plen; i++) { + if (value.charAt(i) != prefix.charAt(i)) { + return false; + } + } + return true; + } + /** * Fast String Buffer class. MIParser does a lot * of deleting off the front of a string, that's clearly