From 0aa09ba7cb4d7d32be4d0cc37234df5bb060b2b0 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Wed, 25 May 2022 22:08:16 -0400 Subject: [PATCH] vere: refactors macros for binary alias ($pier/.run) --- pkg/urbit/daemon/main.c | 7 ++++--- pkg/urbit/include/c/portable.h | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index 2a73e20aef..b92f169041 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -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)); diff --git a/pkg/urbit/include/c/portable.h b/pkg/urbit/include/c/portable.h index 648dfad670..eabd1a6248 100644 --- a/pkg/urbit/include/c/portable.h +++ b/pkg/urbit/include/c/portable.h @@ -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. ***