add a few more Microsoft TCHAR function conversions

This commit is contained in:
Robert Reif 2011-09-27 07:29:36 -04:00
parent ec377d24eb
commit 44a926aa4d
2 changed files with 75 additions and 15 deletions

View File

@ -10583,30 +10583,62 @@ void Tokenizer::simplifyMicrosoftStringFunctions()
{ {
for (Token *tok = _tokens; tok; tok = tok->next()) for (Token *tok = _tokens; tok; tok = tok->next())
{ {
if (Token::simpleMatch(tok, "_tcscpy (")) if (Token::simpleMatch(tok, "_topen ("))
{ {
tok->str("strcpy"); tok->str("open");
}
else if (Token::simpleMatch(tok, "_tfopen ("))
{
tok->str("fopen");
} }
else if (Token::simpleMatch(tok, "_tcscat (")) else if (Token::simpleMatch(tok, "_tcscat ("))
{ {
tok->str("strcat"); tok->str("strcat");
} }
else if (Token::simpleMatch(tok, "_tcsncpy (")) else if (Token::simpleMatch(tok, "_tcschr ("))
{ {
tok->str("strncpy"); tok->str("strchr");
} }
else if (Token::simpleMatch(tok, "_tcsncat (")) else if (Token::simpleMatch(tok, "_tcscmp ("))
{ {
tok->str("strncat"); tok->str("strcmp");
}
else if (Token::simpleMatch(tok, "_tcsdup ("))
{
tok->str("strdup");
}
else if (Token::simpleMatch(tok, "_tcscpy ("))
{
tok->str("strcpy");
} }
else if (Token::simpleMatch(tok, "_tcslen (")) else if (Token::simpleMatch(tok, "_tcslen ("))
{ {
tok->str("strlen"); tok->str("strlen");
} }
else if (Token::simpleMatch(tok, "_tcsncat ("))
{
tok->str("strncat");
}
else if (Token::simpleMatch(tok, "_tcsncpy ("))
{
tok->str("strncpy");
}
else if (Token::simpleMatch(tok, "_tcsnlen (")) else if (Token::simpleMatch(tok, "_tcsnlen ("))
{ {
tok->str("strnlen"); tok->str("strnlen");
} }
else if (Token::simpleMatch(tok, "_tcsrchr ("))
{
tok->str("strrchr");
}
else if (Token::simpleMatch(tok, "_tcsstr ("))
{
tok->str("strstr");
}
else if (Token::simpleMatch(tok, "_tcstok ("))
{
tok->str("strtok");
}
else if (Token::simpleMatch(tok, "_tprintf (")) else if (Token::simpleMatch(tok, "_tprintf ("))
{ {
tok->str("printf"); tok->str("printf");
@ -10646,30 +10678,54 @@ void Tokenizer::simplifyMicrosoftStringFunctions()
{ {
for (Token *tok = _tokens; tok; tok = tok->next()) for (Token *tok = _tokens; tok; tok = tok->next())
{ {
if (Token::simpleMatch(tok, "_tcscpy (")) if (Token::simpleMatch(tok, "_tcscat ("))
{
tok->str("wcscpy");
}
else if (Token::simpleMatch(tok, "_tcscat ("))
{ {
tok->str("wcscat"); tok->str("wcscat");
} }
else if (Token::simpleMatch(tok, "_tcsncpy (")) else if (Token::simpleMatch(tok, "_tcschr ("))
{ {
tok->str("wcsncpy"); tok->str("wcschr");
} }
else if (Token::simpleMatch(tok, "_tcsncat (")) else if (Token::simpleMatch(tok, "_tcscmp ("))
{ {
tok->str("wcsncat"); tok->str("wcscmp");
}
else if (Token::simpleMatch(tok, "_tcscpy ("))
{
tok->str("wcscpy");
}
else if (Token::simpleMatch(tok, "_tcsdup ("))
{
tok->str("wcsdup");
} }
else if (Token::simpleMatch(tok, "_tcslen (")) else if (Token::simpleMatch(tok, "_tcslen ("))
{ {
tok->str("wcslen"); tok->str("wcslen");
} }
else if (Token::simpleMatch(tok, "_tcsncat ("))
{
tok->str("wcsncat");
}
else if (Token::simpleMatch(tok, "_tcsncpy ("))
{
tok->str("wcsncpy");
}
else if (Token::simpleMatch(tok, "_tcsnlen (")) else if (Token::simpleMatch(tok, "_tcsnlen ("))
{ {
tok->str("wcsnlen"); tok->str("wcsnlen");
} }
else if (Token::simpleMatch(tok, "_tcsrchr ("))
{
tok->str("wcsrchr");
}
else if (Token::simpleMatch(tok, "_tcsstr ("))
{
tok->str("wcsstr");
}
else if (Token::simpleMatch(tok, "_tcstok ("))
{
tok->str("wcstok");
}
else if (Token::simpleMatch(tok, "_tprintf (")) else if (Token::simpleMatch(tok, "_tprintf ("))
{ {
tok->str("wprintf"); tok->str("wprintf");

View File

@ -6107,6 +6107,7 @@ private:
" _tcscpy(dst, src);" " _tcscpy(dst, src);"
" dst[0] = 0;" " dst[0] = 0;"
" _tcscat(dst, src);" " _tcscat(dst, src);"
" LPTSTR d = _tcsdup(str);"
" _tprintf(_T(\"Hello world!\n\"));" " _tprintf(_T(\"Hello world!\n\"));"
" _stprintf(dst, _T(\"Hello!\n\"));" " _stprintf(dst, _T(\"Hello!\n\"));"
" _sntprintf(dst, sizeof(dst) / sizeof(TCHAR), _T(\"Hello world!\n\"));" " _sntprintf(dst, sizeof(dst) / sizeof(TCHAR), _T(\"Hello world!\n\"));"
@ -6126,6 +6127,7 @@ private:
"strcpy ( dst , src ) ; " "strcpy ( dst , src ) ; "
"dst [ 0 ] = 0 ; " "dst [ 0 ] = 0 ; "
"strcat ( dst , src ) ; " "strcat ( dst , src ) ; "
"char * d ; d = strdup ( str ) ; "
"printf ( \"Hello world!\n\" ) ; " "printf ( \"Hello world!\n\" ) ; "
"sprintf ( dst , \"Hello!\n\" ) ; " "sprintf ( dst , \"Hello!\n\" ) ; "
"snprintf ( dst , sizeof ( dst ) / sizeof ( char ) , \"Hello world!\n\" ) ; " "snprintf ( dst , sizeof ( dst ) / sizeof ( char ) , \"Hello world!\n\" ) ; "
@ -6150,6 +6152,7 @@ private:
" _tcscpy(dst, src);" " _tcscpy(dst, src);"
" dst[0] = 0;" " dst[0] = 0;"
" _tcscat(dst, src);" " _tcscat(dst, src);"
" LPTSTR d = _tcsdup(str);"
" _tprintf(_T(\"Hello world!\n\"));" " _tprintf(_T(\"Hello world!\n\"));"
" _stprintf(dst, _T(\"Hello!\n\"));" " _stprintf(dst, _T(\"Hello!\n\"));"
" _sntprintf(dst, sizeof(dst) / sizeof(TCHAR), _T(\"Hello world!\n\"));" " _sntprintf(dst, sizeof(dst) / sizeof(TCHAR), _T(\"Hello world!\n\"));"
@ -6169,6 +6172,7 @@ private:
"wcscpy ( dst , src ) ; " "wcscpy ( dst , src ) ; "
"dst [ 0 ] = 0 ; " "dst [ 0 ] = 0 ; "
"wcscat ( dst , src ) ; " "wcscat ( dst , src ) ; "
"unsigned short * d ; d = wcsdup ( str ) ; "
"wprintf ( \"Hello world!\n\" ) ; " "wprintf ( \"Hello world!\n\" ) ; "
"swprintf ( dst , \"Hello!\n\" ) ; " "swprintf ( dst , \"Hello!\n\" ) ; "
"snwprintf ( dst , sizeof ( dst ) / sizeof ( unsigned short ) , \"Hello world!\n\" ) ; " "snwprintf ( dst , sizeof ( dst ) / sizeof ( unsigned short ) , \"Hello world!\n\" ) ; "