chore(developer): copied contents of 3 files of commit fcfc6c698a to here to achieve state of fcfc6c698a

This commit is contained in:
Sabine 2023-02-18 10:28:06 +01:00
parent 256c8a74d2
commit c4ffe0bf02
3 changed files with 21 additions and 30 deletions

View file

@ -69,7 +69,7 @@ KMX_DWORD CheckFilenameConsistency( KMX_CHAR const * Filename, bool ReportMissin
KMX_DWORD CheckFilenameConsistency(KMX_WCHAR const * Filename, bool ReportMissingFile) {
// not ready yet: needs more attention-> e.g. common includes for non-Windows platforms to check casing of filename
// not ready yet: needs more attention-> e.g. _wfindfirst,... and common includes for non-Windows platforms
KMX_WCHAR Name[_MAX_PATH], FName[_MAX_FNAME], Ext[_MAX_EXT];
intptr_t n;
FILE* nfile;
@ -82,30 +82,26 @@ KMX_DWORD CheckFilenameConsistency(KMX_WCHAR const * Filename, bool ReportMissin
else {
u16ncpy(Name, Filename, _countof(Name)); // I3481 // _S2 wcscpy_s(Name, _countof(Name), Filename); // I3481
}
std::wstring Name_wstr = convert_pchar16T_To_std_wstring(Name);
const KMX_WCHART* Name_wchptr = Name_wstr.c_str();
#if defined(_WIN32) || defined(_WIN64)
std::wstring wstr = convert_pchar16T_To_pwcharT(Name);
const KMX_WCHART* wchptr = wstr.c_str();
nfile = _wfsopen(wchptr, L"rb", _SH_DENYNO);
nfile = _wfsopen(wchptr, L"rb", _SH_DENYWR);
_wfinddata_t fi;
n = _wfindfirst(wchptr, &fi);
_findclose(n);
#endif
if (nfile == NULL) {
if (ReportMissingFile) {
u16sprintf(ErrExtraW,256,L"referenced file %ls",Filename);
strcpy(ErrExtraLIB, wstrtostr2(ErrExtraW));
AddWarning(CWARN_MissingFile);
if (nfile == NULL) {
if (ReportMissingFile) {
u16sprintf(ErrExtraW,256,L"referenced file %ls",Filename);
strcpy(ErrExtraLIB, wstrtostr2(ErrExtraW));
AddWarning(CWARN_MissingFile);
}
return CERR_None;
}
return CERR_None;
}
fclose(nfile);
fclose(nfile);
//---------------------------------------------------------------------
#if defined(_WIN32) || defined(_WIN64)
const KMX_WCHAR* cptr1 = u16rchr(Name, '\\'); // _S2 const wchar_t* cptr1 = wcsrchr(Name, '\\');
#else
@ -113,12 +109,10 @@ fclose(nfile);
#endif
cptr1++;
//TODO: sort out how to find common includes in non-Windows platforms:
#if defined(_WIN32) || defined(_WIN64)
KMX_WCHAR fi_name_char16[260];
_wfinddata_t fi;
n = _wfindfirst(Name_wchptr, &fi);
_findclose(n);
u16sprintf(fi_name_char16,_countof(fi.name),fi.name);
KMX_WCHAR fi_name_char16[260];
u16sprintf(fi_name_char16,_countof(fi.name),fi.name);
if (u16cmp(cptr1, fi_name_char16) != 0) {
u16sprintf(ErrExtraW,256,L"reference '%ls' does not match actual filename '%ls'", cptr1, &fi.name);
@ -126,11 +120,8 @@ fclose(nfile);
AddWarning(CHINT_FilenameHasDifferingCase);
}
#else
# //TODO: sort out how to find common includes in non-Windows platforms:
# check if filename differs in case . is it possible to use
# n= access(Name_wchptr,F_OK; n = fopen(Name_wchptr, "rb"); strcasecmp(), strcmp,...?
#error Missing implementation for finding common includes
#endif
return CERR_None;
}

View file

@ -16,7 +16,7 @@
namespace kmcmp {
WCHAR conv_KMX_WCHAR__TO__WCHAR(KMX_WCHAR in) {
// char16_t -> std::u16string -> std::string -> std::wstring -> wchar_t
// char16_t -> std::u16string -> std::string -> std::wstring -> wchar_t*
std::u16string u16str(&in);
std::string stri = string_from_u16string(u16str);
std::wstring wstr = wstring_from_string(stri);
@ -28,9 +28,8 @@ namespace kmcmp {
std::wstring Context_ws = u16fmt((const PKMX_WCHAR) kp->dpContext);
Key_16 << conv_KMX_WCHAR__TO__WCHAR(kp->Key) << "," << (DWORD) kp->ShiftFlags << ",";
if ((KMX_WCHART*) Context_ws.c_str())
Key_16 << (KMX_WCHART*) Context_ws.c_str();
return Key_16.str();
if ((KMX_WCHART*) Context_ws.c_str()) Key_16 << (KMX_WCHART*) Context_ws.c_str();
return Key_16.str();
};
}
KMX_DWORD VerifyUnreachableRules(PFILE_GROUP gp) {

View file

@ -62,8 +62,8 @@ void u16sprintf(KMX_WCHAR * dst, const size_t sz, const wchar_t* fmt, ...) {
delete[] wbuf;
}
std::wstring convert_pchar16T_To_std_wstring(KMX_WCHAR Name[_MAX_PATH]){
// convert char16_t* -> std::u16string -> std::string -> std::wstring
std::wstring convert_pchar16T_To_pwcharT(KMX_WCHAR Name[_MAX_PATH]){
// convert char16_t* -> std::u16string -> std::string -> std::wstring -> wchar_t*
// char16_t* -> std::u16string
std::u16string u16str(Name);
// std::u16string -> std::string
@ -71,7 +71,8 @@ std::wstring convert_pchar16T_To_std_wstring(KMX_WCHAR Name[_MAX_PATH]){
// std::string -> std::wstring
std::wstring wstr = wstring_from_string(stri);
return wstr;
}
}
long int u16tol(const KMX_WCHAR* str, KMX_WCHAR** endptr, int base)
{