aboutsummaryrefslogtreecommitdiffstats
path: root/CommandLine.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2023-02-05 04:25:56 +0100
committerDaniel Lange <DLange@git.local>2023-02-05 04:25:56 +0100
commitf288666edc9180a2e81e6655951878124f321df6 (patch)
treeda70bf44b2423f6f8e9a070c063fed79d190b489 /CommandLine.c
parent937052b231259a47d881d539ad5748245ef55b99 (diff)
downloaddebian_htop-f288666edc9180a2e81e6655951878124f321df6.tar.gz
debian_htop-f288666edc9180a2e81e6655951878124f321df6.tar.bz2
debian_htop-f288666edc9180a2e81e6655951878124f321df6.zip
New upstream version 3.2.2upstream/3.2.2
Diffstat (limited to 'CommandLine.c')
-rw-r--r--CommandLine.c56
1 files changed, 36 insertions, 20 deletions
diff --git a/CommandLine.c b/CommandLine.c
index d21f482..682e054 100644
--- a/CommandLine.c
+++ b/CommandLine.c
@@ -66,7 +66,6 @@ static void printHelpFlag(const char* name) {
"-V --version Print version info\n");
Platform_longOptionsUsage(name);
printf("\n"
- "Long options may be passed with a single dash.\n\n"
"Press F1 inside %s for online help.\n"
"See 'man %s' for more information.\n", name, name);
}
@@ -80,7 +79,9 @@ typedef struct CommandLineSettings_ {
int sortKey;
int delay;
bool useColors;
+#ifdef HAVE_GETMOUSE
bool enableMouse;
+#endif
bool treeView;
bool allowUnicode;
bool highlightChanges;
@@ -97,7 +98,9 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar
.sortKey = 0,
.delay = -1,
.useColors = true,
+#ifdef HAVE_GETMOUSE
.enableMouse = true,
+#endif
.treeView = false,
.allowUnicode = true,
.highlightChanges = false,
@@ -143,7 +146,8 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar
for (int j = 1; j < LAST_PROCESSFIELD; j++) {
const char* name = Process_fields[j].name;
const char* description = Process_fields[j].description;
- if (name) printf("%19s %s\n", name, description);
+ if (name)
+ printf("%19s %s\n", name, description);
}
return STATUS_OK_EXIT;
}
@@ -163,8 +167,10 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar
break;
case 'd':
if (sscanf(optarg, "%16d", &(flags->delay)) == 1) {
- if (flags->delay < 1) flags->delay = 1;
- if (flags->delay > 100) flags->delay = 100;
+ if (flags->delay < 1)
+ flags->delay = 1;
+ if (flags->delay > 100)
+ flags->delay = 100;
} else {
fprintf(stderr, "Error: invalid delay value \"%s\".\n", optarg);
return STATUS_ERROR_EXIT;
@@ -172,7 +178,7 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar
break;
case 'u':
{
- const char *username = optarg;
+ const char* username = optarg;
if (!username && optind < argc && argv[optind] != NULL &&
(argv[optind][0] != '\0' && argv[optind][0] != '-')) {
username = argv[optind++];
@@ -181,7 +187,7 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar
if (!username) {
flags->userId = geteuid();
} else if (!Action_setUserOnly(username, &(flags->userId))) {
- for (const char *itr = username; *itr; ++itr)
+ for (const char* itr = username; *itr; ++itr)
if (!isdigit((unsigned char)*itr)) {
fprintf(stderr, "Error: invalid user \"%s\".\n", username);
return STATUS_ERROR_EXIT;
@@ -214,11 +220,11 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar
flags->pidMatchList = Hashtable_new(8, false);
}
- while(pid) {
- unsigned int num_pid = atoi(pid);
- // deepcode ignore CastIntegerToAddress: we just want a non-NULL pointer here
- Hashtable_put(flags->pidMatchList, num_pid, (void *) 1);
- pid = strtok_r(NULL, ",", &saveptr);
+ while (pid) {
+ unsigned int num_pid = atoi(pid);
+ // deepcode ignore CastIntegerToAddress: we just want a non-NULL pointer here
+ Hashtable_put(flags->pidMatchList, num_pid, (void*) 1);
+ pid = strtok_r(NULL, ",", &saveptr);
}
free(argCopy);
@@ -230,19 +236,19 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar
break;
}
case 'H': {
- const char *delay = optarg;
+ const char* delay = optarg;
if (!delay && optind < argc && argv[optind] != NULL &&
(argv[optind][0] != '\0' && argv[optind][0] != '-')) {
- delay = argv[optind++];
+ delay = argv[optind++];
}
if (delay) {
- if (sscanf(delay, "%16d", &(flags->highlightDelaySecs)) == 1) {
- if (flags->highlightDelaySecs < 1)
- flags->highlightDelaySecs = 1;
- } else {
- fprintf(stderr, "Error: invalid highlight delay value \"%s\".\n", delay);
- return STATUS_ERROR_EXIT;
- }
+ if (sscanf(delay, "%16d", &(flags->highlightDelaySecs)) == 1) {
+ if (flags->highlightDelaySecs < 1)
+ flags->highlightDelaySecs = 1;
+ } else {
+ fprintf(stderr, "Error: invalid highlight delay value \"%s\".\n", delay);
+ return STATUS_ERROR_EXIT;
+ }
}
flags->highlightChanges = true;
break;
@@ -259,6 +265,15 @@ static CommandLineStatus parseArguments(const char* program, int argc, char** ar
}
}
}
+
+ if (optind < argc) {
+ fprintf(stderr, "Error: unsupported non-option ARGV-elements:");
+ while (optind < argc)
+ fprintf(stderr, " %s", argv[optind++]);
+ fprintf(stderr, "\n");
+ return STATUS_ERROR_EXIT;
+ }
+
return STATUS_OK;
}
@@ -359,6 +374,7 @@ int CommandLine_run(const char* name, int argc, char** argv) {
.header = header,
.pauseProcessUpdate = false,
.hideProcessSelection = false,
+ .hideMeters = false,
};
MainPanel_setState(panel, &state);

© 2014-2024 Faster IT GmbH | imprint | privacy policy