From 67033d4eb6e6f308dccc51cd45790cfce11688bf Mon Sep 17 00:00:00 2001 From: ShadelessFox Date: Wed, 16 Oct 2024 18:47:22 +0200 Subject: [PATCH] Accept additional suffixed for console launcher --- .../library/eclipseConfig.c | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipseConfig.c b/features/org.eclipse.equinox.executable.feature/library/eclipseConfig.c index ebd6abaf377..1e291de6750 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipseConfig.c +++ b/features/org.eclipse.equinox.executable.feature/library/eclipseConfig.c @@ -69,13 +69,22 @@ _TCHAR* getIniFile(_TCHAR* program, int consoleLauncher){ extension = config_file + _tcslen(config_file); } _tcscpy(extension, _T_ECLIPSE(".ini")); - if(consoleLauncher){ - /* We are the console version, if the ini file does not exist, try - * removing the 'c' from the end of the program name */ - struct _stat stats; - if (_tstat( config_file, &stats ) != 0 && *(extension - 1) == _T('c')) { - _tcscpy(extension - 1, extension); - } + struct _stat stats; + if(consoleLauncher && _tstat(config_file, &stats) != 0){ + /* We are the console version, if the ini file does not exist, try + * removing the suffix from the end of the program name */ + static const _TCHAR* consoleLauncherSuffixes[] = { + _T_ECLIPSE("c"), // eclipsec.exe + _T_ECLIPSE("-cli"), // eclipse-cli.exe + NULL + }; + for (const _TCHAR** suffix = consoleLauncherSuffixes; *suffix; suffix++) { + size_t suffixLen = _tcslen(*suffix); + if (_tcsncmp(extension - suffixLen, *suffix, suffixLen) == 0) { + _tcscpy(extension - suffixLen, extension); + break; + } + } } } #elif MACOSX