wxString DescriptorFrame::edit_partit(wxString partit)
{
	
	int erase_s=partit.Replace("<partitioning>","");
	int erase_e=partit.Replace("</partitioning>","");


	int erase_start=partit.find("<hostcollocation>");
		while (erase_start>0)
		{
			erase_start=partit.find("<hostcollocation>");
			int erase_end=partit.find("</hostcollocation>")+18;
			if (erase_end>18) 
			{
				partit.Remove(erase_start,erase_end-erase_start);
			}

		} 

		

	erase_start=0;
	erase_start=partit.find("<processcollocation");
		while (erase_start>0)
		{
			erase_start=partit.find("<processcollocation");
			int erase_end=partit.find("</processcollocation>")+21;

			if (erase_end>21)
			{
				partit.Remove(erase_start,erase_end-erase_start);
			}
			
		}	

		
	erase_start=0;
	erase_start=partit.find("<homeplacement");
		while (erase_start>0)
		{
			erase_start=1;
			erase_start=partit.find("<homeplacement");
			int erase_end=partit.find("</homeplacement>")+16;
			if (erase_end>16)
			{
				partit.Remove(erase_start,erase_end-erase_start);
			}
						
		}
		
	
	return partit;

}
Example #2
0
void Function::SetContents(wxString contents)
{
    if(contents.Left(1) == '\n')
    {
        contents.Remove(0, 1);
    }
    if(contents.Right(1) == '\n')
    {
        contents.Remove(contents.Len() -1, 1);
    }
    m_functionContents = contents;
}
Example #3
0
wxString CompressedCachePath(wxString path)
{
#if defined(__WXMSW__)
    int colon = path.find(':', 0);
    path.Remove(colon, 1);
#endif
    
    /* replace path separators with ! */
    wxChar separator = wxFileName::GetPathSeparator();
    for(unsigned int pos = 0; pos < path.size(); pos = path.find(separator, pos))
        path.replace(pos, 1, _T("!"));

    //  Obfuscate the compressed chart file name, to (slightly) protect some encrypted raster chart data.
    wxCharBuffer buf = path.ToUTF8();
    unsigned char sha1_out[20];
    sha1( (unsigned char *) buf.data(), strlen(buf.data()), sha1_out );

    wxString sha1;
    for (unsigned int i=0 ; i < 20 ; i++){
        wxString s;
        s.Printf(_T("%02X"), sha1_out[i]);
        sha1 += s;
    }
    
    return g_Platform->GetPrivateDataDir() + separator + _T("raster_texture_cache") + separator + sha1;
    
}
wxDateTime CReminderDialog::ParseSnoozeTime(wxString strTime)
{
	// Parser function to parse something like: 1 Week 3 Days 5 Minutes.
	wxDateTime dateTime = wxDateTime::Now();
	strTime = strTime.Trim(true);
	int weeks = 0, days = 0, hours = 0, minutes = 0;
	wxRegEx reExp(wxT("\\s*(\\d+)\\s*([a-zA-Z]*)\\s*"), wxRE_ADVANCED);
	wxString strNumber;
	wxString strText;
	int nNumber = 0;
	while( reExp.Matches(strTime) )
	{
		strNumber = reExp.GetMatch(strTime, 1);
		strText = reExp.GetMatch(strTime, 2);
		strTime = strTime.Remove(0, reExp.GetMatch(strTime, 0).Length());
		strText = strText.Lower();
		try
		{
			nNumber =  boost::lexical_cast<int>(strText.c_str());
		}
		catch (boost::bad_lexical_cast &)
		{			
			nNumber = 0;
		}
		if(strText.Find(wxT("minute")) == 0)
			minutes = nNumber;
		else if(strText.Find(wxT("hour")) == 0)
			hours = nNumber;
		else if(strText.Find(wxT("day")) == 0)
			days = nNumber;
		else if(strText.Find(wxT("week")) == 0)
			weeks = nNumber;
	}
	return dateTime + GetTimeSpan(weeks, days, hours, minutes);
}
void EventWatcherFrame::addEvents(wxString& s)
{
    // deselect all items so user can cleanly see what is added
    for (int ix = 0; ix < (int)listbox_monitored->GetCount(); ++ix)
    {
        if (listbox_monitored->IsSelected(ix))
            listbox_monitored->Deselect(ix);
    }
    while (true)
    {
        int p = s.Find("\n");
        wxString s2;
        if (p == -1)
            s2 = s.Strip();
        else
        {
            s2 = s.Left(p).Strip(wxString::both);
            s.Remove(0, p);
            s.Trim(false);
        }
        if (!s2.IsEmpty() && listbox_monitored->FindString(s2) == wxNOT_FOUND)
            listbox_monitored->Select(listbox_monitored->Append(s2));
        if (p == -1)
            break;
    }
    updateControls();
}
Example #6
0
void StringUtil::StripQuotes(wxString &value){
	size_t len = value.Length();
	if (len > 0 && value[0] == '"' && value[len - 1] == '"'){
		value.Remove(0,1);
		value.RemoveLast(1);
		value.Replace(STRING_DELIMITER_ESCAPE, STRING_DELIMETER, true);
	}
}
//////////////////////////////////////////////////////////////////////////////
///  private ParseFindOutput
///  This parsing can easily be broken!  But, I am pretty confident
///    in the integrity of the string I'm parsing, because I know
///    what's coming in.
///  This does both files and directories because they are structured/listed
///    the same.
///
///  @param  strng         wxString  The whole "find" output.
///  @param  includeHidden bool      Whether to include hidden things (./.foo)
///                                     in the dirlisting
///
///  @return wxArrayString return value.
///
///  @author David Czechowski @date 04-22-2004
//////////////////////////////////////////////////////////////////////////////
//Private:
wxArrayString Networking::ParseFindOutput(wxString strng, bool includeHidden)
{
	wxArrayString r;
	r.Empty();

	while(strng.Length() > 2) {

		// Get the "./"
		char c1 = strng.GetChar(0); // peek
		char c2 = strng.GetChar(1); // peek
		strng.Remove(0,2); // pop

		if(c1 == '.' && c2 == '\r') {
			// Special case for . direcrtory
			strng = "\r" + strng; // push it back on
			c2 = '/';
		}

		//if(c1 != '.' && c2 != '/') {
		//	return r; // unexpected
		//}

		// Queue-up/Initialize for the loop
		// There should be at least 2 left: \r\n
		c1 = strng.GetChar(0);
		c2 = strng.GetChar(1);
		strng.Remove(0,2);

		wxString newitem = "";

		while(c1 != '\r' && c2 != '\n') {
			newitem += c1;
			c1 = c2;
			c2 = strng.GetChar(0); // peek
			strng.Remove(0,1); // pop
		}

		if(newitem != "") {
			if(newitem.Left(1) != "." || includeHidden) {
				r.Add(newitem);
			}
		}
	}

	return r;
}
inline void RemoveBefore(wxString &str, const wxString &s)
{
    wxString::size_type pos = str.find(s);
    if (pos != wxString::npos)
    {
        str.Remove(0, pos+s.length());
        str.Trim(false);
    }
}
bool ThreadSearch::GetCursorWord(wxString& sWord)
{
    bool wordFound = false;
    sWord = wxEmptyString;

    // Gets active editor
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    if ( ed != NULL )
    {
        cbStyledTextCtrl* control = ed->GetControl();

        sWord = control->GetSelectedText();
        if (sWord != wxEmptyString)
        {
            sWord.Trim(true);
            sWord.Trim(false);

            wxString::size_type pos = sWord.find(wxT('\n'));
            if (pos != wxString::npos)
            {
                sWord.Remove(pos, sWord.length() - pos);
                sWord.Trim(true);
                sWord.Trim(false);
            }

            return !sWord.IsEmpty();
        }

        // Gets word under cursor
        int pos = control->GetCurrentPos();
        int ws  = control->WordStartPosition(pos, true);
        int we  = control->WordEndPosition(pos, true);
        const wxString word = control->GetTextRange(ws, we);
        if (!word.IsEmpty()) // Avoid empty strings
        {
            sWord.Clear();
            while (--ws > 0)
            {
                const wxChar ch = control->GetCharAt(ws);
                if (ch <= _T(' '))
                    continue;
                else if (ch == _T('~'))
                    sWord << _T("~");
                break;
            }
            // m_SearchedWord will be used if 'Find occurrences' ctx menu is clicked
            sWord << word;
            wordFound = true;
        }
    }

    return wordFound;
}
Example #10
0
wxString IniParser::ReadLineFromBuffer(wxString& buffer)
{
    int len = buffer.Length();
    int i = 0;
    while (i < len && buffer.GetChar(i) != _T('\n'))
        ++i;
    wxString str = buffer.Left(i);
    while (i < len && (buffer.GetChar(i) == _T('\n') || buffer.GetChar(i) == _T('\r')))
        ++i;
    buffer.Remove(0, i);
    buffer.Trim();
    return str;
}
bool clEditorConfig::ReadUntil(wxChar delim, wxString& strLine, wxString& output)
{
    while(!strLine.IsEmpty()) {
        wxChar ch = strLine.at(0);
        strLine.Remove(0, 1);
        if(ch == delim) {
            return true;
        } else {
            output << ch;
        }
    }
    return false;
}
//////////////////////////////////////////////////////////////////////////////
///  private SSHExecSyncCommand
///  Passes the command off to PlinkConnect after appending a boolean test to
///     know if the command completely successfully.
///
///  @param  command wxString   command to execute
///  @param  output  wxString & output from the command.
///
///  @return bool    Whether the call succeeded or not.
///
///  @author David Czechowski @date 04-22-2004
//////////////////////////////////////////////////////////////////////////////
//Private:
bool Networking::SSHExecSyncCommand(wxString command, wxString &output) {
	command += " && echo Su_CC_ess-CMD";

	output = m_plinks->executeSyncCommand(command);

	int tokenPos = output.Find("Su_CC_ess-CMD");
	if(tokenPos != -1) {
		output.Remove(tokenPos);
		return true;
	}
	// else
		return false;
}
Example #13
0
bool nsHeaderFixUp::IsInsideString(wxString& Line)
{
  int EndStringPos = Line.Find(_T('\"'));
  bool OutsideString = false;

  if ( EndStringPos == wxNOT_FOUND )
    Line.Clear(); // Multi-line string -> skip line
  else if ( EndStringPos > 0 )
  {
    if ( Line.GetChar(EndStringPos-1) == '\\' )
      // Something like "\"cbMessageBox\"" -> remove \"
      Line.Remove(0,EndStringPos+1);
    else
      OutsideString = true; // EndStringPos > 0
  }
  else
      OutsideString = true; // EndStringPos = 0

  if ( OutsideString ) // END Inside string
    Line.Remove(0,EndStringPos+1);

  return !OutsideString;
}
Example #14
0
bool nsHeaderFixUp::IsInsideMultilineComment(wxString& Line)
{
  int EndCommentPos = Line.Find(_T("*/"));
  bool OutsideMultilineComment = false;

  if ( EndCommentPos == wxNOT_FOUND )
    Line.Clear(); // skip line
  else
  {
    Line.Remove(0,EndCommentPos+2);
    OutsideMultilineComment = true; // END Multiline comment
  }

  return !OutsideMultilineComment;
}
Example #15
0
wxString RemoveWhiteSpace(wxString str)
{
    int index = 0;
    while(index < str.Len())
    {
        if(str.GetChar(index) == ' ' || str.GetChar(index) == '\t' || str.GetChar(index) == '\n')
        {
            str.Remove(index, 1);
        }
        else
        {
            index++;
        }
    }
    return str;
}
Example #16
0
File: Path.cpp Project: geekt/amule
wxString StripSeparators(wxString path, wxString::stripType type)
{
	wxASSERT((type == wxString::leading) || (type == wxString::trailing));
	const wxString seps = wxFileName::GetPathSeparators();

	while (!path.IsEmpty()) {
		size_t pos = ((type == wxString::leading) ? 0 : path.Length() - 1);

		if (seps.Contains(path.GetChar(pos))) {
			path.Remove(pos, 1);
		} else {
			break;
		}
	}

	return path;
}
Example #17
0
bool CLReplacePattern(const wxString& in, const wxString& pattern, const wxString& replaceWith, wxString &outStr)
{
	int where = pattern.Find(wxT("%0"));
	if(where != wxNOT_FOUND) {
		wxString replacement(replaceWith);

		// a patterened expression
		wxString searchFor = pattern.BeforeFirst(wxT('('));
		where = in.Find(searchFor);
		if(where == wxNOT_FOUND) {
			return false;
		}

		wxString      initList;
		wxArrayString initListArr;
		if(PPToken::readInitList(in, searchFor.Length() + where, initList, initListArr) == false)
			return false;

		outStr = in;
		// update the 'replacement' with the actual values ( replace %0..%n)
		for(size_t i=0; i<initListArr.size(); i++) {
			wxString placeHolder;
			placeHolder << wxT("%") << i;
			replacement.Replace(placeHolder, initListArr.Item(i));
		}

		outStr.Remove(where, searchFor.Length() + initList.Length());
		outStr.insert(where, replacement);
		return true;

	} else {
		if(in.Find(pattern) == wxNOT_FOUND) {
			return false;
		}
		// simple replacement
		outStr = ReplaceWord(in, pattern, replaceWith);
		return outStr != in;
	}
}
Example #18
0
/* Function to increment bus label members numbers,
 * i.e. when a text is ending with a number, adds
 * aIncrement to this number
 */
void IncrementLabelMember( wxString& name, int aIncrement )
{
    int  ii, nn;
    long number = 0;

    ii = name.Len() - 1; nn = 0;

    if( !isdigit( name.GetChar( ii ) ) )
        return;

    while( (ii >= 0) && isdigit( name.GetChar( ii ) ) )
    {
        ii--; nn++;
    }

    ii++;   /* digits are starting at ii position */
    wxString litt_number = name.Right( nn );

    if( litt_number.ToLong( &number ) )
    {
        number += aIncrement;
        name.Remove( ii ); name << number;
    }
}
Example #19
0
/****************************************************************************
PARAMETERS:
str        - text of #if statement

RETURNS:
true or false depending on how it evaluated

REMARKS:
TODO: rewrite this whole thing using regular expressions when they are done.

SEE ALSO:
wxIfElseVariable
****************************************************************************/
bool ParseIfStatementValue(
    wxString &str)
{
    // Find out if the tag has parenthesis
    // recursive to parse the text within the parenthesis,
    // replacing the text with 1 or 0, (hardcoded true or false)
    int b;
    while ((b = str.Find('(')) != -1) {
        int e;
        // Find the matching parenthesis
        int nextbeg, nextend;
        int parencount = 1, min = b+1;
        do {
            nextbeg = str.find('(', min);
            nextend = str.find(')', min);
            if (nextbeg < nextend && nextbeg != wxString::npos) {
                parencount++;
                min = nextbeg+1;
                }
            else {
                parencount--;
                min = nextend+1;
                }

            if (nextend == wxString::npos) {
#ifdef CHECKED		
                wxMessageBox("wxHTML #if\\else error: Unmatched parenthesis in #if expression.","Error",wxICON_ERROR);
#endif
                return true;
                }
            // once parencount reaches 0 again we have found our matchin )
            } while (parencount > 0);

        e = nextend;

        // Extract the expression from the parenthesis block and recurse
        // to solve it.
        wxString tag;
        tag = str.Mid(b+1, e-b-1);
        bool val = ParseIfStatementValue(tag);
        // Add extra spaces just in case of NOT(VAL)
        if (val) str = str.Mid(0, b) + " 1" + str.Mid(e+1);
        else str = str.Mid(0, b) + " 0" + str.Mid(e+1);
        }

    // Remove spaces from left and right
    str.Trim(false);
    str.Trim(true);

    // Convert text method of operators "AND" and "OR" to c style
    // this makes only one special case necessary for each later on
    str.Replace(" AND ", "&&");
    str.Replace(" OR ", "||");
    str.Replace(" EQUALS ", "==");

    // Check for equals statements
    // == statements are special because they are evaluated as a single block
    int equ;
    equ = str.find("==");
    while (equ != wxString::npos) {
        int begin, end;
        int begin2, end2; // ends of words
        begin = equ-1;
        end = equ+2;

        // remove spaces, find extents
        while (end < str.Length() && str.GetChar(end) == ' ')
            end++;
        while (begin >= 0 && str.GetChar(begin) == ' ')
            begin--;
        end2 = end;
        begin2 = begin;
        if (str.GetChar(end2) == '\'' || str.GetChar(end2) == '\"') {
            end2++;
            while (end2 < str.Length() && str.GetChar(end2) != '\'' && str.GetChar(end2) != '\"' )
                end2++;
            end2++;
            }
        else {
            while (end2 < str.Length() && IsLetter(str.GetChar(end2)))
                end2++;
            }
        while (begin >= 0 && IsLetter(str.GetChar(begin)))
            begin--;

        if (begin < 0) begin = 0;
        else begin++;
        if (end2 >= str.Length()) end2 = str.Length();

        wxString tmpeq = GetEquals(str.Mid(begin, begin2-begin+1), str.Mid(end, end2-end));
        str = str.Mid(0, begin) + wxString(" ") + tmpeq + wxString(" ") +
            str.Mid(end2);
        equ = str.find("==");

        // Remove spaces from left and right
        str.Trim(false);
        str.Trim(true);
        }

    // We use ReverseFind so that the whole left expression gets evaluated agains
    // the right single item, creating a left -> right evaluation
    // Search for || operators, recurse to solve (so we don't have to handle special cases here)
    int and, or;
    and = ReverseFind(str, "&&");
    or = ReverseFind(str, "||");
    if ( (and != -1) || (or != -1) ) {
        wxString tag1, tag2;
        // handle the rightmost first to force left->right evaluation
        if ( (and > or) ) {
            return (
                ParseIfStatementValue(tag2 = str.Mid(and+2)) &&
                ParseIfStatementValue(tag1 = str.Mid(0, and)) );
            }
        else {
            return (
                ParseIfStatementValue(tag2 = str.Mid(or+2)) ||
                ParseIfStatementValue(tag1 = str.Mid(0, or)) );
            }
        }

    // By the time we get to this place in the function we are guarenteed to have a single
    // variable operation, perhaps with a NOT or ! operator
    bool notval = false;

    // search for a NOT or ! operator
    if (str.Mid(0, 1) == "!") {
        str.Remove(0, 1);
        str.Trim(false); // trim spaces from left
        notval = true;
        }
    else if (str.Mid(0,4).CmpNoCase("NOT ") == 0) {
        str.Remove(0, 4);
        str.Trim(false); // trim any extra spaces from left
        notval = true;
        }

    // now all we have left is the name of the class or a hardcoded 0 or 1
    if (str == "") {
#ifdef CHECKED		
        wxMessageBox("wxHTML #if\\else error: Empty expression in #if\\#elif statement.","Error",wxICON_ERROR);
#endif
        return true;
        }

    // check for hardcoded 0 and 1 cases, (these are used by parenthesis catcher)
    // this just decomplicates the recursion algorithm
    if (str == "0") return notval;
    if (str == "1") return !notval;

    // Grab the value from the variable class identified by cname
    bool value = wxIfElseVariable::GetValue(str);
    if (notval) value = !value;
    return value;

}
wxArrayString clEditorConfig::ProcessSection(wxString& strLine)
{
    eEditorConfigState state = kEC_STATE_NORMAL;

    clEditorConfigTreeNode* tree = new clEditorConfigTreeNode;
    std::vector<clEditorConfigTreeNode*> trees;
    trees.push_back(tree);

    wxString curpattern;
    while(!strLine.IsEmpty()) {
        switch(state) {
        case kEC_STATE_NORMAL: {
            wxChar ch = strLine.at(0);
            strLine.Remove(0, 1);
            switch(ch) {
            case '{':
                state = kEC_STATE_IN_CURLYGRP;
                break;
            case '[':
                state = kEC_STATE_IN_SQUAREGRP;
                break;
            case ',':
                // new pattern
                if(!curpattern.IsEmpty()) {
                    tree->Add(curpattern);

                    tree = new clEditorConfigTreeNode;
                    trees.push_back(tree);
                    curpattern.clear();
                }
                break;
            default:
                curpattern << ch;
                break;
            }
            break;
        }
        case kEC_STATE_IN_CURLYGRP: {
            // if we got something so far, add it before we continue
            if(!curpattern.IsEmpty()) {
                tree->Add(curpattern);
                curpattern.clear();
            }

            // read the buffer until we hit the closing brace
            wxString buffer;
            if(!ReadUntil('}', strLine, buffer)) {
                return wxArrayString();
            }
            state = kEC_STATE_NORMAL;
            wxArrayString groupPatterns = ProcessSection(buffer);
            tree->Add(groupPatterns);
            break;
        }
        case kEC_STATE_IN_SQUAREGRP: {
            wxString buffer;
            if(!ReadUntil(']', strLine, buffer)) {
                return wxArrayString();
            }
            state = kEC_STATE_NORMAL;
            break;
        }
        }
    }

    // Remainder
    if(!curpattern.IsEmpty()) {
        tree->Add(curpattern);
    }

    wxArrayString res;
    for(size_t i = 0; i < trees.size(); ++i) {
        wxArrayString patterns;
        trees.at(i)->GetPatterns(patterns);
        res.insert(res.end(), patterns.begin(), patterns.end());
        delete trees.at(i);
    }

    // Loop over the array and change "**" => "*"
    for(size_t i = 0; i < res.size(); ++i) {
        res.Item(i).Replace("**", "*");
    }
    return res;
}
Example #21
0
int CamuleGuiBase::InitGui(bool geometry_enabled, wxString &geom_string)
{
	// Standard size is 800x600 at position (0,0)
	int geometry_x = 0;
	int geometry_y = 0;
	unsigned int geometry_width = 800;
	unsigned int geometry_height = 600;

	if ( geometry_enabled ) {
		// I plan on moving this to a separate function, as it just clutters up OnInit()
		/*
		This implementation might work with mac, provided that the
		SetSize() function works as expected.
		*/

		// Remove possible prefix
		if ( geom_string.GetChar(0) == '=' ) {
			geom_string.Remove( 0, 1 );
		}

		// Stupid ToLong functions forces me to use longs =(
		long width = geometry_width;
		long height = geometry_height;

		// Get the avilable display area
		wxRect display = wxGetClientDisplayRect();

		// We want to place aMule inside the client area by default
		long x = display.x;
		long y = display.y;

		// Tokenize the string
		wxStringTokenizer tokens(geom_string, wxT("xX+-"));

		// First part: Program width
		if ( tokens.GetNextToken().ToLong( &width ) ) {
			wxString prefix = geom_string[ tokens.GetPosition() - 1 ];
			if ( prefix == wxT("x") || prefix == wxT("X") ) {
				// Second part: Program height
				if ( tokens.GetNextToken().ToLong( &height ) ) {
					prefix = geom_string[ tokens.GetPosition() - 1 ];
					if ( prefix == wxT("+") || prefix == wxT("-") ) {
						// Third part: X-Offset
						if ( tokens.GetNextToken().ToLong( &x ) ) {
							if ( prefix == wxT("-") )
								x = display.GetRight() - ( width + x );
							prefix = geom_string[ tokens.GetPosition() - 1 ];
							if ( prefix == wxT("+") || prefix == wxT("-") ) {
								// Fourth part: Y-Offset
								if ( tokens.GetNextToken().ToLong( &y ) ) {
									if ( prefix == wxT("-") )
										y = display.GetBottom() - ( height + y );
								}
							}
						}
					}
					// We need at least height and width to override default geometry
					geometry_enabled = true;
					geometry_x = x;
					geometry_y = y;
					geometry_width = width;
					geometry_height = height;
				}
			}
		}
	}

	ResetTitle();

	// Should default/last-used position be overridden?
	if ( geometry_enabled ) {
		amuledlg = new CamuleDlg(NULL, m_FrameTitle,
		                         wxPoint(geometry_x,geometry_y),
		                         wxSize( geometry_width, geometry_height - 58 ));
	} else {
		amuledlg = new CamuleDlg(NULL, m_FrameTitle);
	}

	return 0;
}
void CDB_driver::ParseOutput(const wxString& output)
{
    m_Cursor.changed = false;
    static wxString buffer;
    buffer << output << _T('\n');

    m_pDBG->DebugLog(output);

    if (rePrompt.Matches(buffer))
    {
        int idx = buffer.First(rePrompt.GetMatch(buffer));
        cbAssert(idx != wxNOT_FOUND);
        m_ProgramIsStopped = true;
        m_QueueBusy = false;
        DebuggerCmd* cmd = CurrentCommand();
        if (cmd)
        {
            RemoveTopCommand(false);
            buffer.Remove(idx);
            if (buffer[buffer.Length() - 1] == _T('\n'))
                buffer.Remove(buffer.Length() - 1);
            cmd->ParseOutput(buffer.Left(idx));
            delete cmd;
            RunQueue();
        }
    }
    else
        return; // come back later

    bool notifyChange = false;

    // non-command messages (e.g. breakpoint hits)
    // break them up in lines
    wxArrayString lines = GetArrayFromString(buffer, _T('\n'));
    for (unsigned int i = 0; i < lines.GetCount(); ++i)
    {
//            Log(_T("DEBUG: ") + lines[i]); // write it in the full debugger log

        if (lines[i].StartsWith(_T("Cannot execute ")))
        {
            Log(lines[i]);
        }
        else if (lines[i].Contains(_T("Access violation")))
        {
            m_ProgramIsStopped = true;
            Log(lines[i]);
            m_pDBG->BringCBToFront();

            Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog();
            DoBacktrace(true);
            InfoWindow::Display(_("Access violation"), lines[i]);
            break;
        }
        else if (notifyChange)
            continue;

        // Breakpoint 0 hit
        // >   38:     if (!RegisterClassEx (&wincl))
        else if (reBP.Matches(lines[i]))
        {
            m_ProgramIsStopped = true;
            Log(lines[i]);
            // Code breakpoint / assert
            m_pDBG->BringCBToFront();
            Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog();
            DoBacktrace(true);
            break;
        }
        else if (lines[i].Contains(_T("Break instruction exception")) && !m_pDBG->IsTemporaryBreak())
        {
            m_ProgramIsStopped = true;
        	// Code breakpoint / assert
            m_pDBG->BringCBToFront();
            Manager::Get()->GetDebuggerManager()->ShowBacktraceDialog();
            DoBacktrace(true);
            break;
        }
    }

    if (notifyChange)
        NotifyCursorChanged();

    buffer.Clear();
}
Example #23
0
void DebuggerTree::ParseEntry(WatchTreeEntry& entry, Watch* watch, wxString& text, long array_index)
{
    if (text.IsEmpty())
        return;
//    Manager::Get()->GetLogManager()->DebugLog(F(_T("DebuggerTree::ParseEntry(): %s"), text.c_str()));
    while (1)
    {
        // trim the string from left and right
        text.Trim(true);
        text.Trim(false);

        // find position of '{', '}' and ',' ***outside*** of any quotes.
        // decide which is nearer to the start
        int braceOpenPos = FindCharOutsideQuotes(text, _T('{'));
        if (braceOpenPos == -1)    braceOpenPos = 0xFFFFFE;
        int braceClosePos = FindCharOutsideQuotes(text, _T('}'));
        if (braceClosePos == -1) braceClosePos = 0xFFFFFE;
        int commaPos = FindCommaPos(text);
        if (commaPos == -1) commaPos = 0xFFFFFE;
        int pos = std::min(commaPos, std::min(braceOpenPos, braceClosePos));

        if (pos == 0xFFFFFE)
        {
            // no comma, opening or closing brace
            if (text.Right(3).Matches(_T(" = ")))
                text.Truncate(text.Length() - 3);
            if (!text.IsEmpty())
            {
                entry.AddChild(text, watch);
                text.Clear();
            }
            break;
        }
        else
        {
            // display array on a single line?
            // normal (multiple lines) display is taken care below, with array indexing
            if (watch &&
                watch->is_array &&
                braceOpenPos != 0xFFFFFE &&
                braceClosePos != 0xFFFFFE)
            {
                wxString tmp = text.Left(braceClosePos + 1);
                // if more than one opening/closing brace, then it's a complex array so
                // ignore single-line
                if (text.Freq(_T('{')) == 1 && text.Freq(_T('}')) == 1)
                {
                    // array on single line for up to 8 (by default) elements
                    // if more elements, fall through to the multi-line display
                    int commas = Manager::Get()->GetConfigManager(_T("debugger"))->ReadInt(_T("/single_line_array_elem_count"), 8);
                    if (tmp.Freq(_T(',')) < commas)
                    {
                        // array watch type
                        tmp[braceOpenPos] = _T('[');
                        tmp.Last() = _T(']');
                        entry.AddChild(tmp, watch);
                        text.Remove(0, braceClosePos + 1);
                        continue;
                    }
                }
            }

            wxString tmp = text.Left(pos);
            WatchTreeEntry* newchild = 0;

            if (tmp.Right(3).Matches(_T(" = ")))
                tmp.Truncate(tmp.Length() - 3); // remove " = " if last in string
            if (!tmp.IsEmpty())
            {
                // take array indexing into account (if applicable)
                if (array_index != -1)
                {
                    tmp.Prepend(wxString::Format(_T("[%ld]: "), array_index));
                    // if array element would occur multiple times, gdb adds as default "<repeated xx times> to the output
                    // so we have to look for it and increase the array_index correctly
                    // as default we increase by 1
                    long incIndex = 1;
                    if (reRepeatedElements.Matches(tmp))
                    {
                        reRepeatedElements.GetMatch(tmp, 1).ToLong(&incIndex);
                    }
                    array_index += incIndex;
                }

                newchild = &entry.AddChild(tmp, watch);
            }
            text.Remove(0, pos + 1);

            if (pos == braceOpenPos)
            {
                if (!newchild)
                    newchild = &entry;

                // enable array indexing (if applicable)
                bool no_indexing = array_index == -1;
                if (watch && watch->is_array && no_indexing &&
                    text.Freq(_T('{')) == 0 && text.Freq(_T('}')) == 1) // don't index complex arrays
                {
                    array_index = 0;
                }

                ParseEntry(*newchild, watch, text, array_index); // proceed one level deeper

                // reset array indexing
                if (no_indexing)
                    array_index = -1;
            }
            else if (pos == braceClosePos)
                break; // return one level up
        }
    }
}