Merge pull request #2767 from kugelfuhr/kugelfuhr/fix-836

Remove invalid characters from labels in the VICE label file
This commit is contained in:
Bob Andrews
2025-07-03 18:32:37 +02:00
committed by GitHub
3 changed files with 37 additions and 2 deletions

View File

@@ -532,7 +532,7 @@ void PrintDbgSymLabels (FILE* F)
if (GetDbgSym (D, Val) == 0) { if (GetDbgSym (D, Val) == 0) {
/* Emit the VICE label line */ /* Emit the VICE label line */
fprintf (F, "al %06lX .%s\n", Val, GetString (D->Name)); PrintLabelLine (F, D->Name, Val);
/* Insert the symbol into the table */ /* Insert the symbol into the table */
InsertDbgSym (D, Val); InsertDbgSym (D, Val);

View File

@@ -39,6 +39,7 @@
/* common */ /* common */
#include "addrsize.h" #include "addrsize.h"
#include "chartype.h"
#include "check.h" #include "check.h"
#include "hashfunc.h" #include "hashfunc.h"
#include "lidefs.h" #include "lidefs.h"
@@ -1006,6 +1007,36 @@ void PrintImportMap (FILE* F)
void PrintLabelLine (FILE* F, unsigned NameId, long Val)
/* Output one label into a vice label file doing some cleanup on the name. */
{
/* Get the name */
const char* N = GetString (NameId);
/* Cleanup the name. It might be generated by the assembler when creating
** internally used labels. Such names contain invalid characters to avoid
** clashes with user input and cannot be read by VICE.
*/
fprintf (F, "al %06lX .", Val);
if (IsAlpha (*N) || *N == '@' || *N == '?' || *N == '_') {
putc (*N, F);
} else {
putc ('_', F);
}
++N;
while (*N) {
if (IsAlpha (*N) || IsDigit (*N) || *N == '_') {
putc (*N, F);
} else {
putc ('_', F);
}
++N;
}
putc ('\n', F);
}
void PrintExportLabels (FILE* F) void PrintExportLabels (FILE* F)
/* Print the exports in a VICE label file */ /* Print the exports in a VICE label file */
{ {
@@ -1014,7 +1045,8 @@ void PrintExportLabels (FILE* F)
/* Print all exports */ /* Print all exports */
for (I = 0; I < ExpCount; ++I) { for (I = 0; I < ExpCount; ++I) {
const Export* E = ExpPool [I]; const Export* E = ExpPool [I];
fprintf (F, "al %06lX .%s\n", GetExportVal (E), GetString (E->Name)); PrintLabelLine (F, E->Name, GetExportVal (E));
} }
} }

View File

@@ -195,6 +195,9 @@ void PrintExportMapByValue (FILE* F);
void PrintImportMap (FILE* F); void PrintImportMap (FILE* F);
/* Print an import map to the given file */ /* Print an import map to the given file */
void PrintLabelLine (FILE* F, unsigned NameId, long Val);
/* Output one label into a vice label file doing some cleanup on the name. */
void PrintExportLabels (FILE* F); void PrintExportLabels (FILE* F);
/* Print the exports in a VICE label file */ /* Print the exports in a VICE label file */