Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 96193fb

Browse files
authored
Fix ilasm managed resource lookup on Linux. (#28104)
* Fix ilasm path parsing on *nix. ILAsm did not properly parse paths on *nix systems, which notably broke the inclusion of managed resources in an assembly. This commit enables ILAsm to support both types of directory separators by relying on the DIRECTORY_SEPARATOR_CHAR_A macro where relevant. * Only consider colon as a special path character on Windows. We rely on the FEATURE_PAL macro to determine whether we are targeting a *nix platform.
1 parent 8c45b64 commit 96193fb

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/ilasm/asmman.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,10 @@ HRESULT AsmMan::EmitManifest()
965965
for(j=0; (hFile == INVALID_HANDLE_VALUE)&&(pwzInputFiles[j] != NULL); j++)
966966
{
967967
wcscpy_s(wzFileName,2048,pwzInputFiles[j]);
968-
pwz = wcsrchr(wzFileName,'\\');
968+
pwz = wcsrchr(wzFileName,DIRECTORY_SEPARATOR_CHAR_A);
969+
#ifndef FEATURE_PAL
969970
if(pwz == NULL) pwz = wcsrchr(wzFileName,':');
971+
#endif
970972
if(pwz == NULL) pwz = &wzFileName[0];
971973
else pwz++;
972974
wcscpy_s(pwz,2048-(pwz-wzFileName),wzUniBuf);

src/ilasm/grammar_after.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,11 @@ int yylex()
845845
if(wzFile != NULL)
846846
{
847847
if((parser->wzIncludePath != NULL)
848-
&&(wcschr(wzFile,'\\')==NULL)&&(wcschr(wzFile,':')==NULL))
848+
&&(wcschr(wzFile,DIRECTORY_SEPARATOR_CHAR_A)==NULL)
849+
#ifndef FEATURE_PAL
850+
&&(wcschr(wzFile,':')==NULL)
851+
#endif
852+
)
849853
{
850854
PathString wzFullName;
851855

src/ilasm/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void MakeProperSourceFileName(__in __nullterminated WCHAR* wzOrigName,
6767
{
6868
j--;
6969
if(wzProperName[j] == '.') break;
70-
if((wzProperName[j] == '\\')||(j == 0))
70+
if((wzProperName[j] == DIRECTORY_SEPARATOR_CHAR_A)||(j == 0))
7171
{
7272
wcscat_s(wzProperName,MAX_FILENAME_LENGTH,W(".il"));
7373
break;

src/ilasm/writer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,10 @@ HRESULT Assembler::CreateExportDirectory()
332332
char* szOutputFileName = new char[Ldllname];
333333
memset(szOutputFileName,0,wcslen(m_wzOutputFileName)*3+3);
334334
WszWideCharToMultiByte(CP_ACP,0,m_wzOutputFileName,-1,szOutputFileName,Ldllname,NULL,NULL);
335-
pszDllName = strrchr(szOutputFileName,'\\');
335+
pszDllName = strrchr(szOutputFileName,DIRECTORY_SEPARATOR_CHAR_A);
336+
#ifndef FEATURE_PAL
336337
if(pszDllName == NULL) pszDllName = strrchr(szOutputFileName,':');
338+
#endif
337339
if(pszDllName == NULL) pszDllName = szOutputFileName;
338340
Ldllname = (unsigned)strlen(pszDllName)+1;
339341

@@ -1100,8 +1102,10 @@ HRESULT Assembler::CreatePEFile(__in __nullterminated WCHAR *pwzOutputFilename)
11001102
else
11011103
{
11021104
WCHAR* pwc;
1103-
if ((pwc = wcsrchr(m_wzOutputFileName, '\\')) != NULL) pwc++;
1105+
if ((pwc = wcsrchr(m_wzOutputFileName, DIRECTORY_SEPARATOR_CHAR_A)) != NULL) pwc++;
1106+
#ifndef FEATURE_PAL
11041107
else if ((pwc = wcsrchr(m_wzOutputFileName, ':')) != NULL) pwc++;
1108+
#endif
11051109
else pwc = m_wzOutputFileName;
11061110

11071111
wcsncpy_s(wzScopeName, MAX_SCOPE_LENGTH, pwc, _TRUNCATE);

0 commit comments

Comments
 (0)