Add single comment without name with symbol naming dialog.

This commit is contained in:
owomomo 2020-12-19 14:42:29 +08:00
parent 4828b29338
commit a673805f42
1 changed files with 32 additions and 11 deletions

View File

@ -1023,7 +1023,7 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char*
break; break;
} }
if (*newName) if (*newName || *newComment)
{ {
if (!initialNode) if (!initialNode)
{ {
@ -1032,8 +1032,15 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char*
node->offset = (char*)malloc(strlen(newOffset) + 1); node->offset = (char*)malloc(strlen(newOffset) + 1);
strcpy(node->offset, newOffset); strcpy(node->offset, newOffset);
node->offsetNumeric = newAddress; node->offsetNumeric = newAddress;
node->name = (char*)malloc(strlen(newName) + 1); if (strlen(newName))
strcpy(node->name, newName); {
node->name = (char*)malloc(strlen(newName) + 1);
strcpy(node->name, newName);
}
else
{
node->name = 0;
}
if (strlen(newComment)) if (strlen(newComment))
{ {
node->comment = (char*)malloc(strlen(newComment) + 1); node->comment = (char*)malloc(strlen(newComment) + 1);
@ -1054,17 +1061,25 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char*
// found matching address - replace its name and comment // found matching address - replace its name and comment
if (node->name) if (node->name)
free(node->name); free(node->name);
node->name = (char*)malloc(strlen(newName) + 1); if (strlen(node->name))
strcpy(node->name, newName); {
node->name = (char*)malloc(strlen(newName) + 1);
strcpy(node->name, newName);
} else
{
node->name = 0;
}
if (node->comment) if (node->comment)
{ {
free(node->comment); free(node->comment);
node->comment = 0;
} }
if (strlen(newComment)) if (strlen(newComment))
{ {
node->comment = (char*)malloc(strlen(newComment) + 1); node->comment = (char*)malloc(strlen(newComment) + 1);
strcpy(node->comment, newComment); strcpy(node->comment, newComment);
} else
{
node->comment = 0;
} }
break; break;
} }
@ -1079,14 +1094,20 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char*
newNode->offset = (char*)malloc(strlen(newOffset) + 1); newNode->offset = (char*)malloc(strlen(newOffset) + 1);
strcpy(newNode->offset, newOffset); strcpy(newNode->offset, newOffset);
newNode->offsetNumeric = newAddress; newNode->offsetNumeric = newAddress;
newNode->name = (char*)malloc(strlen(newName) + 1);
strcpy(newNode->name, newName); if (strlen(newName))
{
newNode->name = (char*)malloc(strlen(newName) + 1);
strcpy(newNode->name, newName);
}
else {
newNode->name = 0;
}
if (strlen(newComment)) if (strlen(newComment))
{ {
newNode->comment = (char*)malloc(strlen(newComment) + 1); newNode->comment = (char*)malloc(strlen(newComment) + 1);
strcpy(newNode->comment, newComment); strcpy(newNode->comment, newComment);
} else } else {
{
newNode->comment = 0; newNode->comment = 0;
} }
newNode->next = 0; newNode->next = 0;
@ -1096,7 +1117,7 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char*
} }
} else } else
{ {
// name field is empty - remove the address from the list // name and comment field are all empty - remove the address from the list
Name* previousNode = 0; Name* previousNode = 0;
while (node) while (node)
{ {