vere: refactors macros for binary alias ($pier/.run)

This commit is contained in:
Joe Bryan 2022-05-25 22:08:16 -04:00
parent 63109bdbc8
commit 0aa09ba7cb
2 changed files with 9 additions and 6 deletions

View File

@ -147,12 +147,13 @@ static c3_c*
_main_pier_run(c3_c* bin_c)
{
c3_c* dir_c = 0;
c3_w len_w = strlen(bin_c);
c3_w bin_w = strlen(bin_c);
c3_w len_w = strlen(U3_BIN_ALIAS);
// no args, argv[0] == $pier/.run
//
if ( (U3_BIN_ALIAS_LEN <= len_w)
&& (0 == strcmp(bin_c + (len_w - U3_BIN_ALIAS_LEN), U3_BIN_ALIAS)) )
if ( (len_w <= bin_w)
&& (0 == strcmp(bin_c + (bin_w - len_w), U3_BIN_ALIAS)) )
{
bin_c = strdup(bin_c); // dirname can modify
dir_c = _main_repath(dirname(bin_c));

View File

@ -131,12 +131,14 @@
/** Binary alias.
**/
# ifdef U3_OS_mingw
# define U3_BIN_ALIAS ".run.exe"
# define U3_BIN_SUFFIX ".exe"
# else
# define U3_BIN_ALIAS ".run"
# define U3_BIN_SUFFIX ""
# endif
# define U3_BIN_ALIAS_LEN (sizeof(U3_BIN_ALIAS) - 1)
# define U3_BIN_ALIAS ".run" U3_BIN_SUFFIX
/** Address space layout.
***