Conflicts:
	include/lib/types.h
	src/asm/symbol.c
This commit is contained in:
stag019
2014-11-02 01:00:20 -05:00
45 changed files with 1204 additions and 2148 deletions

View File

@@ -24,14 +24,38 @@ extern bool haltnop;
char *tzNewMacro;
ULONG ulNewMacroSize;
ULONG symvaluetostring( char *dest, char *sym )
size_t symvaluetostring(char *dest, size_t maxLength, char *sym)
{
if( sym_isString(sym) )
strcpy( dest, sym_GetStringValue(sym) );
else
sprintf( dest, "$%lX", sym_GetConstantValue(sym) );
size_t length;
return( strlen(dest) );
if (sym_isString(sym)) {
char *src = sym_GetStringValue(sym);
size_t i;
for (i = 0; src[i] != 0; i++) {
if (i >= maxLength) {
fatalerror("Symbol value too long to fit buffer");
}
dest[i] = src[i];
}
length = i;
} else {
ULONG value = sym_GetConstantValue(sym);
int fullLength = snprintf(dest, maxLength + 1, "$%lX", value);
if (fullLength < 0) {
fatalerror("snprintf encoding error");
} else {
length = (size_t)fullLength;
if (length > maxLength) {
fatalerror("Symbol value too long to fit buffer");
}
}
}
return length;
}
ULONG str2int( char *s )
@@ -124,8 +148,7 @@ void copyrept( void )
src=pCurrentBuffer->pBuffer;
ulNewMacroSize=len;
if( (tzNewMacro=(char *)malloc(ulNewMacroSize+1))!=NULL )
{
if ((tzNewMacro = malloc(ulNewMacroSize + 1)) != NULL) {
ULONG i;
tzNewMacro[ulNewMacroSize]=0;
@@ -134,8 +157,7 @@ void copyrept( void )
if( (tzNewMacro[i]=src[i])=='\n' )
nLineNo+=1;
}
}
else
} else
fatalerror( "No mem for REPT block" );
yyskipbytes( ulNewMacroSize+4 );
@@ -353,8 +375,8 @@ void if_skip_to_endc( void )
%union
{
char tzSym[MAXSYMLEN+1];
char tzString[256];
char tzSym[MAXSYMLEN + 1];
char tzString[MAXSTRLEN + 1];
struct Expression sVal;
SLONG nConstValue;
}