Added code to check for duplicate debug symbol names when editing the name of an existing symbol.
This commit is contained in:
parent
130d1dcd45
commit
47530d614c
|
@ -23,11 +23,23 @@ static char dbgSymTblErrMsg[256] = {0};
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
// debugSymbol_t
|
// debugSymbol_t
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
void debugSymbol_t::updateName( const char *name, int arrayIndex )
|
int debugSymbol_t::updateName( const char *name, int arrayIndex )
|
||||||
{
|
{
|
||||||
_name.assign( name );
|
std::string newName;
|
||||||
|
|
||||||
trimTrailingSpaces();
|
newName.assign( name );
|
||||||
|
|
||||||
|
while ( newName.size() > 0 )
|
||||||
|
{
|
||||||
|
if ( isspace( newName.back() ) )
|
||||||
|
{
|
||||||
|
newName.pop_back();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (arrayIndex >= 0)
|
if (arrayIndex >= 0)
|
||||||
{
|
{
|
||||||
|
@ -35,9 +47,24 @@ void debugSymbol_t::updateName( const char *name, int arrayIndex )
|
||||||
|
|
||||||
sprintf( stmp, "[%i]", arrayIndex );
|
sprintf( stmp, "[%i]", arrayIndex );
|
||||||
|
|
||||||
_name.append(stmp);
|
newName.append(stmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (page)
|
||||||
|
{
|
||||||
|
debugSymbol_t *dupSym = debugSymbolTable.getSymbol( page->pageNum(), newName );
|
||||||
|
|
||||||
|
if (dupSym != nullptr && dupSym != this)
|
||||||
|
{
|
||||||
|
snprintf( dbgSymTblErrMsg, sizeof(dbgSymTblErrMsg), "Error: debug symbol '%s' already exists in %s page.\n", newName.c_str(), page->pageName() );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_name = newName;
|
||||||
|
|
||||||
debugSymbolTable.updateSymbol(this);
|
debugSymbolTable.updateSymbol(this);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
void debugSymbol_t::trimTrailingSpaces(void)
|
void debugSymbol_t::trimTrailingSpaces(void)
|
||||||
|
|
|
@ -68,7 +68,7 @@ class debugSymbol_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateName( const char *name, int arrayIndex = -1 );
|
int updateName( const char *name, int arrayIndex = -1 );
|
||||||
|
|
||||||
void trimTrailingSpaces(void);
|
void trimTrailingSpaces(void);
|
||||||
|
|
||||||
|
|
|
@ -879,7 +879,13 @@ int SymbolEditWindow::exec(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sym->updateName( nameEntry->text().toStdString().c_str() );
|
if ( sym->updateName( nameEntry->text().toStdString().c_str() ) )
|
||||||
|
{
|
||||||
|
if (consoleWindow)
|
||||||
|
{
|
||||||
|
consoleWindow->QueueErrorMsgWindow( debugSymbolTable.errorMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
sym->commentAssign( commentEntry->toPlainText().toStdString().c_str() );
|
sym->commentAssign( commentEntry->toPlainText().toStdString().c_str() );
|
||||||
sym->trimTrailingSpaces();
|
sym->trimTrailingSpaces();
|
||||||
}
|
}
|
||||||
|
@ -990,14 +996,12 @@ void SymbolEditWindow::setSymNameWithArray(int idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reform with base string and new index.
|
// Reform with base string and new index.
|
||||||
sym->updateName( stmp, idx );
|
if ( sym->updateName( stmp, idx ) )
|
||||||
//sym->name.assign( stmp );
|
{
|
||||||
|
if (consoleWindow)
|
||||||
//sym->trimTrailingSpaces();
|
{
|
||||||
|
consoleWindow->QueueErrorMsgWindow( debugSymbolTable.errorMessage() );
|
||||||
//sprintf( stmp, "[%i]", idx );
|
}
|
||||||
|
}
|
||||||
//sym->name.append( stmp );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue