Remove TCHAR and <tchar.h> (PR #1373)

. Replace TCHAR -> char.
. Remove <tchar.h> and related functions.
This commit is contained in:
Andrea
2025-02-08 11:09:09 +00:00
committed by GitHub
parent 1f3e253c4b
commit 168e868677
44 changed files with 271 additions and 275 deletions
+29 -29
View File
@@ -39,14 +39,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Arg_t g_aArgRaw[ MAX_ARGS ]; // pre-processing
Arg_t g_aArgs [ MAX_ARGS ]; // post-processing (cooked)
const TCHAR TCHAR_LF = TEXT('\x0D');
const TCHAR TCHAR_CR = TEXT('\x0A');
const TCHAR TCHAR_SPACE = TEXT(' ');
const TCHAR TCHAR_TAB = TEXT('\t');
// const TCHAR TCHAR_QUOTED = TEXT('"');
const TCHAR TCHAR_QUOTE_DOUBLE = TEXT('"');
const TCHAR TCHAR_QUOTE_SINGLE = TEXT('\'');
const TCHAR TCHAR_ESCAPE = TEXT('\x1B');
const char TCHAR_LF = TEXT('\x0D');
const char TCHAR_CR = TEXT('\x0A');
const char TCHAR_SPACE = TEXT(' ');
const char TCHAR_TAB = TEXT('\t');
// const char TCHAR_QUOTED = TEXT('"');
const char TCHAR_QUOTE_DOUBLE = TEXT('"');
const char TCHAR_QUOTE_SINGLE = TEXT('\'');
const char TCHAR_ESCAPE = TEXT('\x1B');
// NOTE: ArgToken_e and g_aTokens must match!
@@ -104,14 +104,14 @@ int _Arg_1( int nValue )
//===========================================================================
int _Arg_1( LPTSTR pName )
{
int nLen = _tcslen( g_aArgs[1].sArg );
int nLen = strlen( g_aArgs[1].sArg );
if (nLen < MAX_ARG_LEN)
{
_tcscpy( g_aArgs[1].sArg, pName );
strcpy( g_aArgs[1].sArg, pName );
}
else
{
_tcsncpy( g_aArgs[1].sArg, pName, MAX_ARG_LEN );
strncpy( g_aArgs[1].sArg, pName, MAX_ARG_LEN );
}
return 1;
}
@@ -205,12 +205,12 @@ bool ArgsGetValue ( Arg_t *pArg, WORD * pAddressValue_, const int nBase )
if (pArg == NULL)
return false;
TCHAR *pSrc = & (pArg->sArg[ 0 ]);
TCHAR *pEnd = NULL;
char *pSrc = & (pArg->sArg[ 0 ]);
char *pEnd = NULL;
if (pAddressValue_)
{
*pAddressValue_ = (WORD)(_tcstoul( pSrc, &pEnd, nBase) & _6502_MEM_END);
*pAddressValue_ = (WORD)(strtoul( pSrc, &pEnd, nBase) & _6502_MEM_END);
return true;
}
@@ -234,7 +234,7 @@ bool ArgsGetImmediateValue ( Arg_t *pArg, WORD * pAddressValue_ )
// Read console input, process the raw args, turning them into tokens and types.
//===========================================================================
int ArgsGet ( TCHAR * pInput )
int ArgsGet ( char * pInput )
{
LPCTSTR pSrc = pInput;
LPCTSTR pEnd = NULL;
@@ -313,7 +313,7 @@ int ArgsGet ( TCHAR * pInput )
//if (iTokenSrc == TOKEN_QUOTE_DOUBLE)
// nLen = nBuf;
nLen = MIN( nBuf, MAX_ARG_LEN ); // NOTE: see Arg_t.sArg[] // GH#481
_tcsncpy( pArg->sArg, pSrc, nLen );
strncpy( pArg->sArg, pSrc, nLen );
pArg->sArg[ nLen ] = 0;
pArg->nArgLen = nLen;
pArg->eToken = iTokenSrc;
@@ -393,7 +393,7 @@ bool ArgsGetRegisterValue ( Arg_t *pArg, WORD * pAddressValue_ )
else
if (iReg == BP_SRC_REG_PC)
{
if ((pArg->nArgLen == 2) && (_tcscmp( pArg->sArg, g_aBreakpointSource[ iReg ] ) == 0))
if ((pArg->nArgLen == 2) && (strcmp( pArg->sArg, g_aBreakpointSource[ iReg ] ) == 0))
{
*pAddressValue_ = regs.pc ; bStatus = true; break;
}
@@ -408,8 +408,8 @@ bool ArgsGetRegisterValue ( Arg_t *pArg, WORD * pAddressValue_ )
void ArgsRawParse ( void )
{
const int BASE = 16; // hex
TCHAR *pSrc = NULL;
TCHAR *pEnd = NULL;
char *pSrc = NULL;
char *pEnd = NULL;
int iArg = 1;
Arg_t *pArg = & g_aArgRaw[ iArg ];
@@ -423,7 +423,7 @@ void ArgsRawParse ( void )
{
pSrc = & (pArg->sArg[ 0 ]);
nAddressArg = (WORD)(_tcstoul( pSrc, &pEnd, BASE) & _6502_MEM_END);
nAddressArg = (WORD)(strtoul( pSrc, &pEnd, BASE) & _6502_MEM_END);
nAddressValue = nAddressArg;
bool bFound = false;
@@ -461,8 +461,8 @@ void ArgsRawParse ( void )
int ArgsCook ( const int nArgs )
{
const int BASE = 16; // hex
TCHAR *pSrc = NULL;
TCHAR *pEnd2 = NULL;
char *pSrc = NULL;
char *pEnd2 = NULL;
int nArg = nArgs;
int iArg = 1;
@@ -761,7 +761,7 @@ int ArgsCook ( const int nArgs )
}
else // not an operator, try (1) address, (2) symbol lookup
{
nAddressArg = (WORD)(_tcstoul( pSrc, &pEnd2, BASE) & _6502_MEM_END);
nAddressArg = (WORD)(strtoul( pSrc, &pEnd2, BASE) & _6502_MEM_END);
if (! (pArg->bType & TYPE_NO_REG))
{
@@ -804,7 +804,7 @@ const char * ParserFindToken( const char *pSrc, const TokenTable_t *aTokens, con
if (! pSrc)
return NULL;
const TCHAR *pName = NULL;
const char *pName = NULL;
int iToken;
// Look-ahead for <=
@@ -840,12 +840,12 @@ const char * ParserFindToken( const char *pSrc, const TokenTable_t *aTokens, con
//===========================================================================
const TCHAR * FindTokenOrAlphaNumeric ( const TCHAR *pSrc, const TokenTable_t *aTokens, const int nTokens, ArgToken_e * pToken_ )
const char * FindTokenOrAlphaNumeric ( const char *pSrc, const TokenTable_t *aTokens, const int nTokens, ArgToken_e * pToken_ )
{
if ( pToken_ )
*pToken_ = NO_TOKEN;
const TCHAR *pEnd = pSrc;
const char *pEnd = pSrc;
if (pSrc && (*pSrc))
{
@@ -866,7 +866,7 @@ const TCHAR * FindTokenOrAlphaNumeric ( const TCHAR *pSrc, const TokenTable_t *a
//===========================================================================
void TextConvertTabsToSpaces( TCHAR *pDeTabified_, LPCTSTR pText, const int nDstSize, int nTabStop )
void TextConvertTabsToSpaces( char *pDeTabified_, LPCTSTR pText, const int nDstSize, int nTabStop )
{
int TAB_SPACING = 8;
int TAB_SPACING_1 = 16;
@@ -937,9 +937,9 @@ void TextConvertTabsToSpaces( TCHAR *pDeTabified_, LPCTSTR pText, const int nDst
// @return Length of new string
//===========================================================================
int RemoveWhiteSpaceReverse ( TCHAR *pSrc )
int RemoveWhiteSpaceReverse ( char *pSrc )
{
int nLen = _tcslen( pSrc );
int nLen = strlen( pSrc );
char *pDst = pSrc + nLen;
while (nLen--)
{