mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-12-28 17:30:02 +00:00
Debugger: replace sprintf() part 2 (PR #1085)
This commit is contained in:
parent
a5e8ee31a3
commit
494aaa04c0
@ -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);
|
||||
}
|
||||
|
||||
|
@ -519,30 +519,25 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
void VerifyDebuggerCommandTable()
|
||||
{
|
||||
char sText[ CONSOLE_WIDTH * 2 ];
|
||||
|
||||
for (int iCmd = 0; iCmd < NUM_COMMANDS; iCmd++ )
|
||||
{
|
||||
if ( g_aCommands[ iCmd ].iCommand != iCmd)
|
||||
{
|
||||
sprintf( sText, "*** ERROR *** Enumerated Commands mis-matched at #%d!", iCmd );
|
||||
GetFrame().FrameMessageBox(sText, TEXT("ERROR"), MB_OK );
|
||||
std::string sText = StrFormat( "*** ERROR *** Enumerated Commands mis-matched at #%d!", iCmd );
|
||||
GetFrame().FrameMessageBox(sText.c_str(), "ERROR", MB_OK);
|
||||
PostQuitMessage( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
// _tcscmp
|
||||
if (strcmp( g_aCommands[ NUM_COMMANDS ].m_sName, DEBUGGER__COMMANDS_VERIFY_TXT__))
|
||||
{
|
||||
sprintf( sText, "*** ERROR *** Total Commands mis-matched!" );
|
||||
GetFrame().FrameMessageBox(sText, TEXT("ERROR"), MB_OK );
|
||||
GetFrame().FrameMessageBox("*** ERROR *** Total Commands mis-matched!", "ERROR", MB_OK);
|
||||
PostQuitMessage( 1 );
|
||||
}
|
||||
|
||||
if (strcmp( g_aParameters[ NUM_PARAMS ].m_sName, DEBUGGER__PARAMS_VERIFY_TXT__))
|
||||
{
|
||||
sprintf( sText, "*** ERROR *** Total Parameters mis-matched!" );
|
||||
GetFrame().FrameMessageBox(sText, TEXT("ERROR"), MB_OK );
|
||||
GetFrame().FrameMessageBox("*** ERROR *** Total Parameters mis-matched!", "ERROR", MB_OK);
|
||||
PostQuitMessage( 2 );
|
||||
}
|
||||
}
|
||||
|
@ -767,13 +767,12 @@ void DisasmCalcTopFromCurAddress(bool bUpdateTop)
|
||||
// Moving the cursor line around is not really a good idea, since we're breaking consistency paradigm for the user.
|
||||
// g_nDisasmCurLine = 0;
|
||||
#if 0 // _DEBUG
|
||||
TCHAR sText[CONSOLE_WIDTH * 2];
|
||||
sprintf(sText, TEXT("DisasmCalcTopFromCurAddress()\n"
|
||||
"\tTop: %04X\n"
|
||||
"\tLen: %04X\n"
|
||||
"\tMissed: %04X"),
|
||||
std::string sText = StrFormat("DisasmCalcTopFromCurAddress()\n"
|
||||
"\tTop: %04X\n"
|
||||
"\tLen: %04X\n"
|
||||
"\tMissed: %04X",
|
||||
g_nDisasmCurAddress - nLen, nLen, g_nDisasmCurAddress);
|
||||
GetFrame().FrameMessageBox(sText, "ERROR", MB_OK);
|
||||
GetFrame().FrameMessageBox(sText.c_str(), "ERROR", MB_OK);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -924,7 +924,7 @@ Update_t _CmdSymbolsUpdate( int nArgs, int bSymbolTables )
|
||||
bSymbolTables = SYMBOL_TABLE_USER_2; // Autogenerated symbol names go in table 2 for organization when reverse engineering. Table 1 = known, Table 2 = unknown.
|
||||
|
||||
nAddress = g_aArgs[2].nValue;
|
||||
sprintf( g_aArgs[1].sArg, "_%04X", nAddress ); // Autogenerated symbol name
|
||||
strncpy_s( g_aArgs[1].sArg, StrFormat("_%04X", nAddress).c_str(), _TRUNCATE ); // Autogenerated symbol name
|
||||
|
||||
bUpdateSymbol = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user