Whitespace around operators

This commit is contained in:
Benny Baumann 2021-07-14 19:18:27 +02:00 committed by BenBE
parent 458749df45
commit 0d85af2872
12 changed files with 34 additions and 34 deletions

View File

@ -378,7 +378,7 @@ static Htop_Reaction actionSetup(State* st) {
Action_runSetup(st); Action_runSetup(st);
int headerHeight = Header_calculateHeight(st->header); int headerHeight = Header_calculateHeight(st->header);
Panel_move((Panel*)st->mainPanel, 0, headerHeight); Panel_move((Panel*)st->mainPanel, 0, headerHeight);
Panel_resize((Panel*)st->mainPanel, COLS, LINES-headerHeight-1); Panel_resize((Panel*)st->mainPanel, COLS, LINES - headerHeight - 1);
return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR; return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
} }

View File

@ -118,10 +118,10 @@ static CommandLineSettings parseArguments(const char* program, int argc, char**
{"highlight-changes", optional_argument, 0, 'H'}, {"highlight-changes", optional_argument, 0, 'H'},
{"readonly", no_argument, 0, 128}, {"readonly", no_argument, 0, 128},
PLATFORM_LONG_OPTIONS PLATFORM_LONG_OPTIONS
{0,0,0,0} {0, 0, 0, 0}
}; };
int opt, opti=0; int opt, opti = 0;
/* Parse arguments */ /* Parse arguments */
while ((opt = getopt_long(argc, argv, "hVMCs:td:u::Up:F:H::", long_opts, &opti))) { while ((opt = getopt_long(argc, argv, "hVMCs:td:u::Up:F:H::", long_opts, &opti))) {
if (opt == EOF) if (opt == EOF)
@ -355,7 +355,7 @@ int CommandLine_run(const char* name, int argc, char** argv) {
ScreenManager_run(scr, NULL, NULL); ScreenManager_run(scr, NULL, NULL);
attron(CRT_colors[RESET_COLOR]); attron(CRT_colors[RESET_COLOR]);
mvhline(LINES-1, 0, ' ', COLS); mvhline(LINES - 1, 0, ' ', COLS);
attroff(CRT_colors[RESET_COLOR]); attroff(CRT_colors[RESET_COLOR]);
refresh(); refresh();

View File

@ -134,7 +134,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
Panel_add(super, (Object*) CheckItem_newByRef("Enable the mouse", &(settings->enableMouse))); Panel_add(super, (Object*) CheckItem_newByRef("Enable the mouse", &(settings->enableMouse)));
Panel_add(super, (Object*) NumberItem_newByRef("Update interval (in seconds)", &(settings->delay), -1, 1, 255)); Panel_add(super, (Object*) NumberItem_newByRef("Update interval (in seconds)", &(settings->delay), -1, 1, 255));
Panel_add(super, (Object*) CheckItem_newByRef("Highlight new and old processes", &(settings->highlightChanges))); Panel_add(super, (Object*) CheckItem_newByRef("Highlight new and old processes", &(settings->highlightChanges)));
Panel_add(super, (Object*) NumberItem_newByRef("- Highlight time (in seconds)", &(settings->highlightDelaySecs), 0, 1, 24*60*60)); Panel_add(super, (Object*) NumberItem_newByRef("- Highlight time (in seconds)", &(settings->highlightDelaySecs), 0, 1, 24 * 60 * 60));
Panel_add(super, (Object*) NumberItem_newByRef("Hide main function bar (0 - off, 1 - on ESC until next input, 2 - permanently)", &(settings->hideFunctionBar), 0, 0, 2)); Panel_add(super, (Object*) NumberItem_newByRef("Hide main function bar (0 - off, 1 - on ESC until next input, 2 - permanently)", &(settings->hideFunctionBar), 0, 0, 2));
#ifdef HAVE_LIBHWLOC #ifdef HAVE_LIBHWLOC
Panel_add(super, (Object*) CheckItem_newByRef("Show topology when selecting affinity by default", &(settings->topologyAffinity))); Panel_add(super, (Object*) CheckItem_newByRef("Show topology when selecting affinity by default", &(settings->topologyAffinity)));

View File

@ -90,7 +90,7 @@ static void DynamicMeter_getUiName(const Meter* this, char* name, size_t length)
const char* uiName = meter->caption; const char* uiName = meter->caption;
if (uiName) { if (uiName) {
int len = strlen(uiName); int len = strlen(uiName);
if (len > 2 && uiName[len-2] == ':') if (len > 2 && uiName[len - 2] == ':')
len -= 2; len -= 2;
xSnprintf(name, length, "%.*s", len, uiName); xSnprintf(name, length, "%.*s", len, uiName);
} else { } else {

View File

@ -376,7 +376,7 @@ static const char* const* LEDMeterMode_digits;
static void LEDMeterMode_drawDigit(int x, int y, int n) { static void LEDMeterMode_drawDigit(int x, int y, int n) {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
mvaddstr(y+i, x, LEDMeterMode_digits[i * 10 + n]); mvaddstr(y + i, x, LEDMeterMode_digits[i * 10 + n]);
} }
static void LEDMeterMode_draw(Meter* this, int x, int y, ATTR_UNUSED int w) { static void LEDMeterMode_draw(Meter* this, int x, int y, ATTR_UNUSED int w) {

View File

@ -454,7 +454,7 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) {
if (len < 99) { if (len < 99) {
buffer[len] = ch; buffer[len] = ch;
buffer[len+1] = '\0'; buffer[len + 1] = '\0';
} }
for (int try = 0; try < 2; try++) { for (int try = 0; try < 2; try++) {

View File

@ -75,7 +75,7 @@ void Process_printBytes(RichString* str, unsigned long long number, bool colorin
RichString_appendnAscii(str, processColor, buffer, len); RichString_appendnAscii(str, processColor, buffer, len);
} else if (number < 100000) { } else if (number < 100000) {
//2 digit MB, 3 digit KB //2 digit MB, 3 digit KB
len = xSnprintf(buffer, sizeof(buffer), "%2llu", number/1000); len = xSnprintf(buffer, sizeof(buffer), "%2llu", number / 1000);
RichString_appendnAscii(str, processMegabytesColor, buffer, len); RichString_appendnAscii(str, processMegabytesColor, buffer, len);
number %= 1000; number %= 1000;
len = xSnprintf(buffer, sizeof(buffer), "%03llu ", number); len = xSnprintf(buffer, sizeof(buffer), "%03llu ", number);
@ -88,7 +88,7 @@ void Process_printBytes(RichString* str, unsigned long long number, bool colorin
} else if (number < 10000 * ONE_K) { } else if (number < 10000 * ONE_K) {
//1 digit GB, 3 digit MB //1 digit GB, 3 digit MB
number /= ONE_K; number /= ONE_K;
len = xSnprintf(buffer, sizeof(buffer), "%1llu", number/1000); len = xSnprintf(buffer, sizeof(buffer), "%1llu", number / 1000);
RichString_appendnAscii(str, processGigabytesColor, buffer, len); RichString_appendnAscii(str, processGigabytesColor, buffer, len);
number %= 1000; number %= 1000;
len = xSnprintf(buffer, sizeof(buffer), "%03lluM ", number); len = xSnprintf(buffer, sizeof(buffer), "%03lluM ", number);
@ -96,7 +96,7 @@ void Process_printBytes(RichString* str, unsigned long long number, bool colorin
} else if (number < 100000 * ONE_K) { } else if (number < 100000 * ONE_K) {
//2 digit GB, 1 digit MB //2 digit GB, 1 digit MB
number /= 100 * ONE_K; number /= 100 * ONE_K;
len = xSnprintf(buffer, sizeof(buffer), "%2llu", number/10); len = xSnprintf(buffer, sizeof(buffer), "%2llu", number / 10);
RichString_appendnAscii(str, processGigabytesColor, buffer, len); RichString_appendnAscii(str, processGigabytesColor, buffer, len);
number %= 10; number %= 10;
len = xSnprintf(buffer, sizeof(buffer), ".%1llu", number); len = xSnprintf(buffer, sizeof(buffer), ".%1llu", number);
@ -110,7 +110,7 @@ void Process_printBytes(RichString* str, unsigned long long number, bool colorin
} else if (number < 10000ULL * ONE_M) { } else if (number < 10000ULL * ONE_M) {
//1 digit TB, 3 digit GB //1 digit TB, 3 digit GB
number /= ONE_M; number /= ONE_M;
len = xSnprintf(buffer, sizeof(buffer), "%1llu", number/1000); len = xSnprintf(buffer, sizeof(buffer), "%1llu", number / 1000);
RichString_appendnAscii(str, largeNumberColor, buffer, len); RichString_appendnAscii(str, largeNumberColor, buffer, len);
number %= 1000; number %= 1000;
len = xSnprintf(buffer, sizeof(buffer), "%03lluG ", number); len = xSnprintf(buffer, sizeof(buffer), "%03lluG ", number);
@ -118,7 +118,7 @@ void Process_printBytes(RichString* str, unsigned long long number, bool colorin
} else if (number < 100000 * ONE_M) { } else if (number < 100000 * ONE_M) {
//2 digit TB, 1 digit GB //2 digit TB, 1 digit GB
number /= 100 * ONE_M; number /= 100 * ONE_M;
len = xSnprintf(buffer, sizeof(buffer), "%2llu", number/10); len = xSnprintf(buffer, sizeof(buffer), "%2llu", number / 10);
RichString_appendnAscii(str, largeNumberColor, buffer, len); RichString_appendnAscii(str, largeNumberColor, buffer, len);
number %= 10; number %= 10;
len = xSnprintf(buffer, sizeof(buffer), ".%1llu", number); len = xSnprintf(buffer, sizeof(buffer), ".%1llu", number);
@ -131,7 +131,7 @@ void Process_printBytes(RichString* str, unsigned long long number, bool colorin
RichString_appendnAscii(str, largeNumberColor, buffer, len); RichString_appendnAscii(str, largeNumberColor, buffer, len);
} else { } else {
//2 digit PB and above //2 digit PB and above
len = xSnprintf(buffer, sizeof(buffer), "%4.1lfP ", (double)number/ONE_T); len = xSnprintf(buffer, sizeof(buffer), "%4.1lfP ", (double)number / ONE_T);
RichString_appendnAscii(str, largeNumberColor, buffer, len); RichString_appendnAscii(str, largeNumberColor, buffer, len);
} }
} }
@ -159,18 +159,18 @@ void Process_printCount(RichString* str, unsigned long long number, bool colorin
} else if (number >= 100LL * ONE_DECIMAL_T) { } else if (number >= 100LL * ONE_DECIMAL_T) {
xSnprintf(buffer, sizeof(buffer), "%11llu ", number / ONE_DECIMAL_M); xSnprintf(buffer, sizeof(buffer), "%11llu ", number / ONE_DECIMAL_M);
RichString_appendnAscii(str, largeNumberColor, buffer, 8); RichString_appendnAscii(str, largeNumberColor, buffer, 8);
RichString_appendnAscii(str, processMegabytesColor, buffer+8, 4); RichString_appendnAscii(str, processMegabytesColor, buffer + 8, 4);
} else if (number >= 10LL * ONE_DECIMAL_G) { } else if (number >= 10LL * ONE_DECIMAL_G) {
xSnprintf(buffer, sizeof(buffer), "%11llu ", number / ONE_DECIMAL_K); xSnprintf(buffer, sizeof(buffer), "%11llu ", number / ONE_DECIMAL_K);
RichString_appendnAscii(str, largeNumberColor, buffer, 5); RichString_appendnAscii(str, largeNumberColor, buffer, 5);
RichString_appendnAscii(str, processMegabytesColor, buffer+5, 3); RichString_appendnAscii(str, processMegabytesColor, buffer + 5, 3);
RichString_appendnAscii(str, processColor, buffer+8, 4); RichString_appendnAscii(str, processColor, buffer + 8, 4);
} else { } else {
xSnprintf(buffer, sizeof(buffer), "%11llu ", number); xSnprintf(buffer, sizeof(buffer), "%11llu ", number);
RichString_appendnAscii(str, largeNumberColor, buffer, 2); RichString_appendnAscii(str, largeNumberColor, buffer, 2);
RichString_appendnAscii(str, processMegabytesColor, buffer+2, 3); RichString_appendnAscii(str, processMegabytesColor, buffer + 2, 3);
RichString_appendnAscii(str, processColor, buffer+5, 3); RichString_appendnAscii(str, processColor, buffer + 5, 3);
RichString_appendnAscii(str, processShadowColor, buffer+8, 4); RichString_appendnAscii(str, processShadowColor, buffer + 8, 4);
} }
} }
@ -728,7 +728,7 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
if (indent & (1U << i)) { if (indent & (1U << i)) {
maxIndent = i+1; maxIndent = i + 1;
} }
} }
@ -1170,15 +1170,15 @@ static int skipPotentialPath(const char* cmdline, int end) {
int slash = 0; int slash = 0;
for (int i = 1; i < end; i++) { for (int i = 1; i < end; i++) {
if (cmdline[i] == '/' && cmdline[i+1] != '\0') { if (cmdline[i] == '/' && cmdline[i + 1] != '\0') {
slash = i + 1; slash = i + 1;
continue; continue;
} }
if (cmdline[i] == ' ' && cmdline[i-1] != '\\') if (cmdline[i] == ' ' && cmdline[i - 1] != '\\')
return slash; return slash;
if (cmdline[i] == ':' && cmdline[i+1] == ' ') if (cmdline[i] == ':' && cmdline[i + 1] == ' ')
return slash; return slash;
} }

View File

@ -184,7 +184,7 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
} else if (String_eq(option[0], "highlight_changes")) { } else if (String_eq(option[0], "highlight_changes")) {
this->highlightChanges = atoi(option[1]); this->highlightChanges = atoi(option[1]);
} else if (String_eq(option[0], "highlight_changes_delay_secs")) { } else if (String_eq(option[0], "highlight_changes_delay_secs")) {
this->highlightDelaySecs = CLAMP(atoi(option[1]), 1, 24*60*60); this->highlightDelaySecs = CLAMP(atoi(option[1]), 1, 24 * 60 * 60);
} else if (String_eq(option[0], "find_comm_in_cmdline")) { } else if (String_eq(option[0], "find_comm_in_cmdline")) {
this->findCommInCmdline = atoi(option[1]); this->findCommInCmdline = atoi(option[1]);
} else if (String_eq(option[0], "strip_exe_from_cmdline")) { } else if (String_eq(option[0], "strip_exe_from_cmdline")) {

View File

@ -182,8 +182,8 @@ static void NetBSDProcessList_updateProcessName(kvm_t* kd, const struct kinfo_pr
end = MINIMUM(n, len - 1); end = MINIMUM(n, len - 1);
/* check if cmdline ended earlier, e.g 'kdeinit5: Running...' */ /* check if cmdline ended earlier, e.g 'kdeinit5: Running...' */
for (int j = end; j > 0; j--) { for (int j = end; j > 0; j--) {
if (arg[0][j] == ' ' && arg[0][j-1] != '\\') { if (arg[0][j] == ' ' && arg[0][j - 1] != '\\') {
end = (arg[0][j-1] == ':') ? (j-1) : j; end = (arg[0][j - 1] == ':') ? (j - 1) : j;
} }
} }
} }

View File

@ -226,8 +226,8 @@ static void OpenBSDProcessList_updateProcessName(kvm_t* kd, const struct kinfo_p
end = MINIMUM(n, len - 1); end = MINIMUM(n, len - 1);
/* check if cmdline ended earlier, e.g 'kdeinit5: Running...' */ /* check if cmdline ended earlier, e.g 'kdeinit5: Running...' */
for (int j = end; j > 0; j--) { for (int j = end; j > 0; j--) {
if (arg[0][j] == ' ' && arg[0][j-1] != '\\') { if (arg[0][j] == ' ' && arg[0][j - 1] != '\\') {
end = (arg[0][j-1] == ':') ? (j-1) : j; end = (arg[0][j - 1] == ':') ? (j - 1) : j;
} }
} }
} }

View File

@ -36,7 +36,7 @@ static PCPDynamicMetric* PCPDynamicMeter_lookupMetric(PCPDynamicMeters* meters,
unsigned int n = meter->totalMetrics + 1; unsigned int n = meter->totalMetrics + 1;
meter->metrics = xReallocArray(meter->metrics, n, sizeof(PCPDynamicMetric)); meter->metrics = xReallocArray(meter->metrics, n, sizeof(PCPDynamicMetric));
meter->totalMetrics = n; meter->totalMetrics = n;
metric = &meter->metrics[n-1]; metric = &meter->metrics[n - 1];
memset(metric, 0, sizeof(PCPDynamicMetric)); memset(metric, 0, sizeof(PCPDynamicMetric));
metric->name = metricName; metric->name = metricName;
metric->label = String_cat(name, ": "); metric->label = String_cat(name, ": ");
@ -186,11 +186,11 @@ static void PCPDynamicMeter_parseFile(PCPDynamicMeters* meters, const char* path
char* key = String_trim(config[0]); char* key = String_trim(config[0]);
char* value = n > 1 ? String_trim(config[1]) : NULL; char* value = n > 1 ? String_trim(config[1]) : NULL;
if (key[0] == '[') { /* new section heading - i.e. new meter */ if (key[0] == '[') { /* new section heading - i.e. new meter */
ok = PCPDynamicMeter_validateMeterName(key+1, path, lineno); ok = PCPDynamicMeter_validateMeterName(key + 1, path, lineno);
if (ok) if (ok)
ok = PCPDynamicMeter_uniqueName(key+1, path, lineno, meters); ok = PCPDynamicMeter_uniqueName(key + 1, path, lineno, meters);
if (ok) if (ok)
meter = PCPDynamicMeter_new(meters, key+1); meter = PCPDynamicMeter_new(meters, key + 1);
} else if (!ok) { } else if (!ok) {
; /* skip this one, we're looking for a new header */ ; /* skip this one, we're looking for a new header */
} else if (value && meter && String_eq(key, "caption")) { } else if (value && meter && String_eq(key, "caption")) {

View File

@ -280,7 +280,7 @@ static void PCPProcessList_updateCmdline(Process* process, int pid, int offset,
} else { } else {
++command; ++command;
--length; --length;
if (command[length-1] == ')') if (command[length - 1] == ')')
command[--length] = '\0'; command[--length] = '\0';
process->isKernelThread = true; process->isKernelThread = true;
} }