mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-04-19 07:37:12 +00:00
Debugger: replace sprintf() part 2 (PR #1085)
This commit is contained in:
+26
-29
@@ -751,7 +751,7 @@ Update_t CmdProfile (int nArgs)
|
||||
{
|
||||
if (! nArgs)
|
||||
{
|
||||
sprintf( g_aArgs[ 1 ].sArg, "%s", g_aParameters[ PARAM_RESET ].m_sName );
|
||||
strncpy_s( g_aArgs[ 1 ].sArg, g_aParameters[ PARAM_RESET ].m_sName, _TRUNCATE );
|
||||
nArgs = 1;
|
||||
}
|
||||
|
||||
@@ -808,7 +808,7 @@ Update_t CmdProfile (int nArgs)
|
||||
ConsoleBufferPushFormat( " Saved: %s", g_FileNameProfile.c_str() );
|
||||
}
|
||||
else
|
||||
ConsoleBufferPush( TEXT(" ERROR: Couldn't save file. (In use?)" ) );
|
||||
ConsoleBufferPush( " ERROR: Couldn't save file. (In use?)" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3446,7 +3446,7 @@ bool MemoryDumpCheck (int nArgs, WORD * pAddress_ )
|
||||
if (bUpdate)
|
||||
{
|
||||
pArg->nValue = nAddress;
|
||||
sprintf( pArg->sArg, "%04X", nAddress );
|
||||
strncpy_s( pArg->sArg, WordToHexStr(nAddress).c_str(), _TRUNCATE );
|
||||
}
|
||||
|
||||
if (pAddress_)
|
||||
@@ -3863,8 +3863,7 @@ Update_t CmdMemoryLoad (int nArgs)
|
||||
if (g_aArgs[ iArgComma1 ].eToken != TOKEN_COMMA)
|
||||
return Help_Arg_1( CMD_MEMORY_SAVE );
|
||||
|
||||
TCHAR sLoadSaveFilePath[ MAX_PATH ];
|
||||
_tcscpy( sLoadSaveFilePath, g_sCurrentDir ); // TODO: g_sDebugDir
|
||||
std::string sLoadSaveFilePath = g_sCurrentDir; // TODO: g_sDebugDir
|
||||
|
||||
WORD nAddressStart;
|
||||
WORD nAddress2 = 0;
|
||||
@@ -3893,11 +3892,11 @@ Update_t CmdMemoryLoad (int nArgs)
|
||||
|
||||
if (bHaveFileName)
|
||||
{
|
||||
_tcscpy( g_sMemoryLoadSaveFileName, g_aArgs[ 1 ].sArg );
|
||||
g_sMemoryLoadSaveFileName = g_aArgs[ 1 ].sArg;
|
||||
}
|
||||
strcat( sLoadSaveFilePath, g_sMemoryLoadSaveFileName );
|
||||
sLoadSaveFilePath += g_sMemoryLoadSaveFileName;
|
||||
|
||||
FILE *hFile = fopen( sLoadSaveFilePath, "rb" );
|
||||
FILE *hFile = fopen( sLoadSaveFilePath.c_str(), "rb" );
|
||||
if (hFile)
|
||||
{
|
||||
int nFileBytes = _GetFileSize( hFile );
|
||||
@@ -3928,7 +3927,7 @@ Update_t CmdMemoryLoad (int nArgs)
|
||||
|
||||
CmdConfigGetDebugDir( 0 );
|
||||
|
||||
ConsoleBufferPushFormat( "File: %s", g_sMemoryLoadSaveFileName );
|
||||
ConsoleBufferPushFormat( "File: %s", g_sMemoryLoadSaveFileName.c_str() );
|
||||
}
|
||||
|
||||
delete [] pMemory;
|
||||
@@ -4020,9 +4019,9 @@ Update_t CmdMemoryLoad (int nArgs)
|
||||
const int nFileTypes = sizeof( aFileTypes ) / sizeof( KnownFileType_t );
|
||||
const KnownFileType_t *pFileType = NULL;
|
||||
|
||||
char *pFileName = g_aArgs[ 1 ].sArg;
|
||||
const char *pFileName = g_aArgs[ 1 ].sArg;
|
||||
int nLen = strlen( pFileName );
|
||||
char *pEnd = pFileName + nLen - 1;
|
||||
const char *pEnd = pFileName + nLen - 1;
|
||||
while ( pEnd > pFileName )
|
||||
{
|
||||
if ( *pEnd == '.' )
|
||||
@@ -4263,11 +4262,11 @@ Update_t CmdMemorySave (int nArgs)
|
||||
{
|
||||
if (! bHaveFileName)
|
||||
{
|
||||
sprintf( g_sMemoryLoadSaveFileName, "%04X.%04X.bin", nAddressStart, nAddressLen ); // nAddressEnd );
|
||||
g_sMemoryLoadSaveFileName = StrFormat( "%04X.%04X.bin", nAddressStart, nAddressLen ); // nAddressEnd );
|
||||
}
|
||||
else
|
||||
{
|
||||
_tcscpy( g_sMemoryLoadSaveFileName, g_aArgs[ 1 ].sArg );
|
||||
g_sMemoryLoadSaveFileName = g_aArgs[ 1 ].sArg;
|
||||
}
|
||||
strcat( sLoadSaveFilePath, g_sMemoryLoadSaveFileName );
|
||||
|
||||
@@ -4413,12 +4412,9 @@ Update_t CmdMemorySave (int nArgs)
|
||||
{
|
||||
if (! bHaveFileName)
|
||||
{
|
||||
TCHAR sMemoryLoadSaveFileName[MAX_PATH];
|
||||
if (! bBankSpecified)
|
||||
sprintf( sMemoryLoadSaveFileName, "%04X.%04X.bin", nAddressStart, nAddressLen );
|
||||
else
|
||||
sprintf( sMemoryLoadSaveFileName, "%04X.%04X.bank%02X.bin", nAddressStart, nAddressLen, nBank );
|
||||
g_sMemoryLoadSaveFileName = sMemoryLoadSaveFileName;
|
||||
g_sMemoryLoadSaveFileName = (bBankSpecified)
|
||||
? StrFormat( "%04X.%04X.bank%02X.bin", nAddressStart, nAddressLen, nBank )
|
||||
: StrFormat( "%04X.%04X.bin", nAddressStart, nAddressLen );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5048,7 +5044,6 @@ Update_t CmdNTSC (int nArgs)
|
||||
bool bColorTV = (GetVideo().GetVideoType() == VT_COLOR_TV);
|
||||
|
||||
uint32_t* pChromaTable = NTSC_VideoGetChromaTable( false, bColorTV );
|
||||
char aStatusText[ CONSOLE_WIDTH*2 ] = "Loaded";
|
||||
|
||||
//uint8_t* pTmp = (uint8_t*) pChromaTable;
|
||||
//*pTmp++ = 0xFF; // b
|
||||
@@ -5109,10 +5104,12 @@ Update_t CmdNTSC (int nArgs)
|
||||
else
|
||||
if (iParam == PARAM_LOAD)
|
||||
{
|
||||
std::string sStatusText;
|
||||
|
||||
FILE *pFile = fopen( sPaletteFilePath.c_str(), "rb" );
|
||||
if ( pFile )
|
||||
{
|
||||
strcpy( aStatusText, "Loaded" );
|
||||
sStatusText = "Loaded";
|
||||
|
||||
// Get File Size
|
||||
size_t nFileSize = _GetFileSize( pFile );
|
||||
@@ -5128,13 +5125,13 @@ Update_t CmdNTSC (int nArgs)
|
||||
|
||||
if (bmp.nBitsPerPixel != 32)
|
||||
{
|
||||
strcpy( aStatusText, "Bitmap not 32-bit RGBA" );
|
||||
sStatusText = "Bitmap not 32-bit RGBA";
|
||||
goto _error;
|
||||
}
|
||||
|
||||
if (bmp.nOffsetData > nFileSize)
|
||||
{
|
||||
strcpy( aStatusText, "Bad BITMAP: Data > file size !?" );
|
||||
sStatusText = "Bad BITMAP: Data > file size !?";
|
||||
goto _error;
|
||||
}
|
||||
|
||||
@@ -5144,7 +5141,7 @@ Update_t CmdNTSC (int nArgs)
|
||||
|| ((bmp.nWidthPixels == 16 ) && (bmp.nHeightPixels == 1))
|
||||
))
|
||||
{
|
||||
strcpy( aStatusText, "Bitmap not 64x256, 64x1, or 16x1" );
|
||||
sStatusText = "Bitmap not 64x256, 64x1, or 16x1";
|
||||
goto _error;
|
||||
}
|
||||
|
||||
@@ -5167,7 +5164,7 @@ Update_t CmdNTSC (int nArgs)
|
||||
else
|
||||
if ( nFileSize != g_nChromaSize )
|
||||
{
|
||||
sprintf( aStatusText, "Raw size != %d", 64*256*4 );
|
||||
sStatusText = StrFormat( "Raw size != %d", 64 * 256 * 4 );
|
||||
goto _error;
|
||||
}
|
||||
|
||||
@@ -5212,11 +5209,11 @@ _error:
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy( aStatusText, "File: " );
|
||||
ConsoleBufferPush( TEXT( "Error couldn't open file for reading." ) );
|
||||
sStatusText = "File: ";
|
||||
ConsoleBufferPush( "Error couldn't open file for reading." );
|
||||
}
|
||||
|
||||
ConsoleFilename::update( aStatusText );
|
||||
ConsoleFilename::update( sStatusText.c_str() );
|
||||
}
|
||||
else
|
||||
return HelpLastCommand();
|
||||
@@ -8635,7 +8632,7 @@ void DebugInitialize ()
|
||||
{
|
||||
doneAutoRun = true;
|
||||
std::string pathname = g_sProgramDir + "DebuggerAutoRun.txt";
|
||||
strcpy_s(g_aArgs[1].sArg, MAX_ARG_LEN, pathname.c_str());
|
||||
strncpy_s(g_aArgs[1].sArg, MAX_ARG_LEN, pathname.c_str(), _TRUNCATE);
|
||||
CmdOutputRun(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user