From 23584a584f44af28aea5943341e5344f45d88b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Sun, 9 Apr 2017 15:40:06 +0100 Subject: [PATCH] Fix __FILE__, __TIME__ and __DATE__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If they don't have quotes when passed to sym_AddString() they can't be used at all by the assembler. I suppose nobody actually used them, they seem to have been broken forever. Added a comment to the function to say how to use it correctly for strings. Signed-off-by: Antonio Niño Díaz --- src/asm/fstack.c | 4 +++- src/asm/symbol.c | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/asm/fstack.c b/src/asm/fstack.c index 15da94e7..177be84d 100644 --- a/src/asm/fstack.c +++ b/src/asm/fstack.c @@ -346,7 +346,9 @@ fstk_Init(char *s) { char tzFileName[_MAX_PATH + 1]; - sym_AddString("__FILE__", s); + char tzSymFileName[_MAX_PATH + 1 + 2]; + snprintf(tzSymFileName, sizeof(tzSymFileName), "\"%s\"", s); + sym_AddString("__FILE__", tzSymFileName); strcpy(tzFileName, s); pFileStack = NULL; diff --git a/src/asm/symbol.c b/src/asm/symbol.c index f8ad1f6b..db5f5a95 100644 --- a/src/asm/symbol.c +++ b/src/asm/symbol.c @@ -495,7 +495,16 @@ sym_AddEqu(char *tzSym, SLONG value) } /* - * Add a string equated symbol + * Add a string equated symbol. + * + * If the desired symbol is a string it needs to be passed to this function with + * quotes inside the string, like sym_AddString("name", "\"test\"), or the + * assembler won't be able to use it with DB and similar. This is equivalent as + * ``` name EQUS "\"test\"" ``` + * + * If the desired symbol is a register or a number, just the terminator quotes + * of the string are enough: sym_AddString("M_PI", "3.1415"). This is the same + * as ``` M_PI EQUS "3.1415" ``` */ void sym_AddString(char *tzSym, char *tzValue) @@ -824,8 +833,8 @@ sym_Init(void) struct tm *tptr; tptr = localtime(&tod); - strftime(SavedTIME, sizeof(SavedTIME), "%H:%M:%S", tptr); - strftime(SavedDATE, sizeof(SavedDATE), "%d %B %Y", tptr); + strftime(SavedTIME, sizeof(SavedTIME), "\"%H:%M:%S\"", tptr); + strftime(SavedDATE, sizeof(SavedDATE), "\"%d %B %Y\"", tptr); sym_AddString("__TIME__", SavedTIME); sym_AddString("__DATE__", SavedDATE); }