Each platform defines its own long opt macro, prefer printf

Follow up on the two items of feedback from cgzones review,
and resolve a build failure picked up by CI on Mac OS X.

Related to https://github.com/htop-dev/htop/pull/564
This commit is contained in:
Nathan Scott 2021-03-18 08:23:07 +11:00
parent 0ada9f325f
commit d56d23d91a
7 changed files with 26 additions and 16 deletions

View File

@ -23,6 +23,9 @@ in the source distribution for its full text.
#include "generic/uname.h" #include "generic/uname.h"
#define PLATFORM_LONG_OPTIONS
#define PLATFORM_LONG_OPTIONS_USAGE
extern const ProcessField Platform_defaultFields[]; extern const ProcessField Platform_defaultFields[];
extern double Platform_timebaseToNS; extern double Platform_timebaseToNS;
@ -77,7 +80,7 @@ static inline void Platform_getRelease(char** string) {
*string = Generic_uname(); *string = Generic_uname();
} }
static bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
return false; return false;
} }

View File

@ -21,6 +21,9 @@ in the source distribution for its full text.
#include "generic/uname.h" #include "generic/uname.h"
#define PLATFORM_LONG_OPTIONS
#define PLATFORM_LONG_OPTIONS_USAGE
extern const ProcessField Platform_defaultFields[]; extern const ProcessField Platform_defaultFields[];
extern const SignalItem Platform_signals[]; extern const SignalItem Platform_signals[];
@ -67,7 +70,7 @@ static inline void Platform_getRelease(char** string) {
*string = Generic_uname(); *string = Generic_uname();
} }
static bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
return false; return false;
} }

View File

@ -22,6 +22,9 @@ in the source distribution for its full text.
#include "generic/uname.h" #include "generic/uname.h"
#define PLATFORM_LONG_OPTIONS
#define PLATFORM_LONG_OPTIONS_USAGE
extern const ProcessField Platform_defaultFields[]; extern const ProcessField Platform_defaultFields[];
extern const SignalItem Platform_signals[]; extern const SignalItem Platform_signals[];
@ -72,7 +75,7 @@ static inline void Platform_getRelease(char** string) {
*string = Generic_uname(); *string = Generic_uname();
} }
static bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
return false; return false;
} }

12
htop.c
View File

@ -36,20 +36,12 @@ in the source distribution for its full text.
#include "XUtils.h" #include "XUtils.h"
#ifndef PLATFORM_LONG_OPTIONS
#define PLATFORM_LONG_OPTIONS
#endif
#ifndef PLATFORM_LONG_OPTIONS_USAGE
#define PLATFORM_LONG_OPTIONS_USAGE
#endif
static void printVersionFlag(const char* name) { static void printVersionFlag(const char* name) {
fprintf(stdout, "%s " VERSION "\n", name); printf("%s " VERSION "\n", name);
} }
static void printHelpFlag(const char* name) { static void printHelpFlag(const char* name) {
fprintf(stdout, "%s " VERSION "\n" printf("%s " VERSION "\n"
COPYRIGHT "\n" COPYRIGHT "\n"
"Released under the GNU GPLv2.\n\n" "Released under the GNU GPLv2.\n\n"
"-C --no-color Use a monochrome color scheme\n" "-C --no-color Use a monochrome color scheme\n"

View File

@ -23,6 +23,9 @@ in the source distribution for its full text.
#include "generic/uname.h" #include "generic/uname.h"
#define PLATFORM_LONG_OPTIONS
#define PLATFORM_LONG_OPTIONS_USAGE
extern const ProcessField Platform_defaultFields[]; extern const ProcessField Platform_defaultFields[];
/* see /usr/include/sys/signal.h */ /* see /usr/include/sys/signal.h */
@ -70,7 +73,7 @@ static inline void Platform_getRelease(char** string) {
*string = Generic_uname(); *string = Generic_uname();
} }
static bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
return false; return false;
} }

View File

@ -26,6 +26,9 @@ in the source distribution for its full text.
#include "generic/uname.h" #include "generic/uname.h"
#define PLATFORM_LONG_OPTIONS
#define PLATFORM_LONG_OPTIONS_USAGE
#define kill(pid, signal) kill(pid / 1024, signal) #define kill(pid, signal) kill(pid / 1024, signal)
typedef struct var kvar_t; typedef struct var kvar_t;
@ -89,7 +92,7 @@ static inline void Platform_getRelease(char** string) {
*string = Generic_uname(); *string = Generic_uname();
} }
static bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
return false; return false;
} }

View File

@ -17,6 +17,9 @@ in the source distribution for its full text.
#include "UnsupportedProcess.h" #include "UnsupportedProcess.h"
#define PLATFORM_LONG_OPTIONS
#define PLATFORM_LONG_OPTIONS_USAGE
extern const SignalItem Platform_signals[]; extern const SignalItem Platform_signals[];
extern const unsigned int Platform_numberOfSignals; extern const unsigned int Platform_numberOfSignals;
@ -61,7 +64,7 @@ void Platform_getHostname(char* buffer, size_t size);
void Platform_getRelease(char** string); void Platform_getRelease(char** string);
static bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) { static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
return false; return false;
} }