diff --git a/CRT.c b/CRT.c index 3c062919d..50f0c0e80 100644 --- a/CRT.c +++ b/CRT.c @@ -19,6 +19,7 @@ in the source distribution for its full text. #include #include +#include "CommandLine.h" #include "ProvideCurses.h" #include "XUtils.h" @@ -1153,10 +1154,11 @@ void CRT_handleSIGSEGV(int signal) { "============================\n" "Please check at https://htop.dev/issues whether this issue has already been reported.\n" "If no similar issue has been reported before, please create a new issue with the following information:\n" - " - Your "PACKAGE" version: '"VERSION"'\n" + " - Your %s version: '"VERSION"'\n" " - Your OS and kernel version (uname -a)\n" " - Your distribution and release (lsb_release -a)\n" - " - Likely steps to reproduce (How did it happen?)\n" + " - Likely steps to reproduce (How did it happen?)\n", + program ); #ifdef PRINT_BACKTRACE @@ -1196,15 +1198,16 @@ void CRT_handleSIGSEGV(int signal) { fprintf(stderr, "\n" "To make the above information more practical to work with, " - "please also provide a disassembly of your "PACKAGE" binary. " + "please also provide a disassembly of your %s binary. " "This can usually be done by running the following command:\n" - "\n" + "\n", + program ); #ifdef HTOP_DARWIN - fprintf(stderr, " otool -tvV `which "PACKAGE"` > ~/htop.otool\n"); + fprintf(stderr, " otool -tvV `which %s` > ~/%s.otool\n", program, program); #else - fprintf(stderr, " objdump -d -S -w `which "PACKAGE"` > ~/htop.objdump\n"); + fprintf(stderr, " objdump -d -S -w `which %s` > ~/%s.objdump\n", program, program); #endif fprintf(stderr, @@ -1216,8 +1219,9 @@ void CRT_handleSIGSEGV(int signal) { fprintf(stderr, "Running this program with debug symbols or inside a debugger may provide further insights.\n" "\n" - "Thank you for helping to improve "PACKAGE"!\n" - "\n" + "Thank you for helping to improve %s!\n" + "\n", + program ); /* Call old sigsegv handler; may be default exit or third party one (e.g. ASAN) */ diff --git a/CommandLine.c b/CommandLine.c index 833592068..2b2a68c2a 100644 --- a/CommandLine.c +++ b/CommandLine.c @@ -89,7 +89,7 @@ typedef struct CommandLineSettings_ { bool readonly; } CommandLineSettings; -static CommandLineStatus parseArguments(const char* program, int argc, char** argv, CommandLineSettings* flags) { +static CommandLineStatus parseArguments(int argc, char** argv, CommandLineSettings* flags) { *flags = (CommandLineSettings) { .pidMatchList = NULL, @@ -298,7 +298,7 @@ static void setCommFilter(State* state, char** commFilter) { *commFilter = NULL; } -int CommandLine_run(const char* name, int argc, char** argv) { +int CommandLine_run(int argc, char** argv) { /* initialize locale */ const char* lc_ctype; @@ -310,7 +310,7 @@ int CommandLine_run(const char* name, int argc, char** argv) { CommandLineStatus status = STATUS_OK; CommandLineSettings flags = { 0 }; - if ((status = parseArguments(name, argc, argv, &flags)) != STATUS_OK) + if ((status = parseArguments(argc, argv, &flags)) != STATUS_OK) return status != STATUS_OK_EXIT ? 1 : 0; if (flags.readonly) diff --git a/CommandLine.h b/CommandLine.h index fbdede84b..18395005b 100644 --- a/CommandLine.h +++ b/CommandLine.h @@ -14,6 +14,8 @@ typedef enum { STATUS_OK_EXIT } CommandLineStatus; -int CommandLine_run(const char* name, int argc, char** argv); +extern const char* program; + +int CommandLine_run(int argc, char** argv); #endif diff --git a/htop.c b/htop.c index 6b9ea48a2..715579380 100644 --- a/htop.c +++ b/htop.c @@ -11,6 +11,8 @@ in the source distribution for its full text. #include "CommandLine.h" +const char* program = PACKAGE; + int main(int argc, char** argv) { - return CommandLine_run(PACKAGE, argc, argv); + return CommandLine_run(argc, argv); } diff --git a/pcp-htop.c b/pcp-htop.c index 2713c896c..ed585ecbe 100644 --- a/pcp-htop.c +++ b/pcp-htop.c @@ -14,13 +14,14 @@ in the source distribution for its full text. #include "Platform.h" +const char* program = "pcp-htop"; + int main(int argc, char** argv) { - const char* name = "pcp-htop"; - pmSetProgname(name); + pmSetProgname(program); /* extract environment variables */ opts.flags |= PM_OPTFLAG_ENV_ONLY; (void)pmGetOptions(argc, argv, &opts); - return CommandLine_run(name, argc, argv); + return CommandLine_run(argc, argv); }