Added code to check for duplicate debug symbol names when editing the name of an existing symbol.

This commit is contained in:
harry 2023-02-05 20:44:36 -05:00
parent 130d1dcd45
commit 47530d614c
3 changed files with 46 additions and 15 deletions

View File

@ -23,11 +23,23 @@ static char dbgSymTblErrMsg[256] = {0};
//--------------------------------------------------------------
// 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)
{
@ -35,9 +47,24 @@ void debugSymbol_t::updateName( const char *name, int 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);
return 0;
}
//--------------------------------------------------------------
void debugSymbol_t::trimTrailingSpaces(void)

View File

@ -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);

View File

@ -879,7 +879,13 @@ int SymbolEditWindow::exec(void)
}
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->trimTrailingSpaces();
}
@ -990,14 +996,12 @@ void SymbolEditWindow::setSymNameWithArray(int idx)
}
// Reform with base string and new index.
sym->updateName( stmp, idx );
//sym->name.assign( stmp );
//sym->trimTrailingSpaces();
//sprintf( stmp, "[%i]", idx );
//sym->name.append( stmp );
if ( sym->updateName( stmp, idx ) )
{
if (consoleWindow)
{
consoleWindow->QueueErrorMsgWindow( debugSymbolTable.errorMessage() );
}
}
}
//--------------------------------------------------------------