diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Action.c | 4 | ||||
-rw-r--r-- | AvailableColumnsPanel.c | 2 | ||||
-rw-r--r-- | CategoriesPanel.c | 2 | ||||
-rw-r--r-- | ColorsPanel.c | 4 | ||||
-rw-r--r-- | ColumnsPanel.c | 2 | ||||
-rw-r--r-- | DisplayOptionsPanel.c | 2 | ||||
-rw-r--r-- | FunctionBar.c | 10 | ||||
-rw-r--r-- | FunctionBar.h | 2 | ||||
-rw-r--r-- | IncSet.c | 8 | ||||
-rw-r--r-- | InfoScreen.c | 4 | ||||
-rw-r--r-- | MainPanel.c | 2 | ||||
-rw-r--r-- | Meter.c | 16 | ||||
-rw-r--r-- | MetersPanel.c | 8 | ||||
-rw-r--r-- | Settings.c | 12 | ||||
-rw-r--r-- | TraceScreen.c | 4 | ||||
-rw-r--r-- | linux/IOPriorityPanel.c | 2 |
17 files changed, 46 insertions, 39 deletions
@@ -7,6 +7,7 @@ htop # skip all backups *.bak *~ +.*.sw? # skip coverage files *.gcda @@ -381,7 +381,7 @@ static Htop_Reaction actionRedraw() { return HTOP_REFRESH | HTOP_REDRAW_BAR; } -static struct { const char* key; const char* info; } helpLeft[] = { +static const struct { const char* key; const char* info; } helpLeft[] = { { .key = " Arrows: ", .info = "scroll process list" }, { .key = " Digits: ", .info = "incremental PID search" }, { .key = " F3 /: ", .info = "incremental name search" }, @@ -399,7 +399,7 @@ static struct { const char* key; const char* info; } helpLeft[] = { { .key = NULL, .info = NULL } }; -static struct { const char* key; const char* info; } helpRight[] = { +static const struct { const char* key; const char* info; } helpRight[] = { { .key = " Space: ", .info = "tag process" }, { .key = " c: ", .info = "tag process and its children" }, { .key = " U: ", .info = "untag all processes" }, diff --git a/AvailableColumnsPanel.c b/AvailableColumnsPanel.c index 6865b8bc..503efabe 100644 --- a/AvailableColumnsPanel.c +++ b/AvailableColumnsPanel.c @@ -26,7 +26,7 @@ typedef struct AvailableColumnsPanel_ { }*/ -static const char* AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL}; +static const char* const AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL}; static void AvailableColumnsPanel_delete(Object* object) { Panel* super = (Panel*) object; diff --git a/CategoriesPanel.c b/CategoriesPanel.c index afc32305..437f1a7b 100644 --- a/CategoriesPanel.c +++ b/CategoriesPanel.c @@ -34,7 +34,7 @@ typedef struct CategoriesPanel_ { }*/ -static const char* CategoriesFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; +static const char* const CategoriesFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; static void CategoriesPanel_delete(Object* object) { Panel* super = (Panel*) object; diff --git a/ColorsPanel.c b/ColorsPanel.c index 96199c1b..627a516a 100644 --- a/ColorsPanel.c +++ b/ColorsPanel.c @@ -34,9 +34,9 @@ typedef struct ColorsPanel_ { }*/ -static const char* ColorsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; +static const char* const ColorsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; -static const char* ColorSchemeNames[] = { +static const char* const ColorSchemeNames[] = { "Default", "Monochromatic", "Black on White", diff --git a/ColumnsPanel.c b/ColumnsPanel.c index 3ec9ee80..02d8be13 100644 --- a/ColumnsPanel.c +++ b/ColumnsPanel.c @@ -29,7 +29,7 @@ typedef struct ColumnsPanel_ { }*/ -static const char* ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL}; +static const char* const ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL}; static void ColumnsPanel_delete(Object* object) { Panel* super = (Panel*) object; diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c index 0a32c447..0ff54e33 100644 --- a/DisplayOptionsPanel.c +++ b/DisplayOptionsPanel.c @@ -28,7 +28,7 @@ typedef struct DisplayOptionsPanel_ { }*/ -static const char* DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; +static const char* const DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; static void DisplayOptionsPanel_delete(Object* object) { Panel* super = (Panel*) object; diff --git a/FunctionBar.c b/FunctionBar.c index 659f4108..4e4baaf3 100644 --- a/FunctionBar.c +++ b/FunctionBar.c @@ -28,21 +28,21 @@ typedef struct FunctionBar_ { }*/ -static const char* FunctionBar_FKeys[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", NULL}; +static const char* const FunctionBar_FKeys[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", NULL}; -static const char* FunctionBar_FLabels[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", NULL}; +static const char* const FunctionBar_FLabels[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", NULL}; static int FunctionBar_FEvents[] = {KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10)}; -static const char* FunctionBar_EnterEscKeys[] = {"Enter", "Esc", NULL}; -static int FunctionBar_EnterEscEvents[] = {13, 27}; +static const char* const FunctionBar_EnterEscKeys[] = {"Enter", "Esc", NULL}; +static const int FunctionBar_EnterEscEvents[] = {13, 27}; FunctionBar* FunctionBar_newEnterEsc(const char* enter, const char* esc) { const char* functions[] = {enter, esc, NULL}; return FunctionBar_new(functions, FunctionBar_EnterEscKeys, FunctionBar_EnterEscEvents); } -FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* events) { +FunctionBar* FunctionBar_new(const char* const* functions, const char* const* keys, const int* events) { FunctionBar* this = xCalloc(1, sizeof(FunctionBar)); this->functions = xCalloc(16, sizeof(char*)); if (!functions) { diff --git a/FunctionBar.h b/FunctionBar.h index 1975fa38..b60f6582 100644 --- a/FunctionBar.h +++ b/FunctionBar.h @@ -24,7 +24,7 @@ typedef struct FunctionBar_ { FunctionBar* FunctionBar_newEnterEsc(const char* enter, const char* esc); -FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* events); +FunctionBar* FunctionBar_new(const char* const* functions, const char* const* keys, const int* events); void FunctionBar_delete(FunctionBar* this); @@ -52,8 +52,8 @@ static void IncMode_reset(IncMode* mode) { mode->buffer[0] = 0; } -static const char* searchFunctions[] = {"Next ", "Cancel ", " Search: ", NULL}; -static const char* searchKeys[] = {"F3", "Esc", " "}; +static const char* const searchFunctions[] = {"Next ", "Cancel ", " Search: ", NULL}; +static const char* const searchKeys[] = {"F3", "Esc", " "}; static int searchEvents[] = {KEY_F(3), 27, ERR}; static inline void IncMode_initSearch(IncMode* search) { @@ -62,8 +62,8 @@ static inline void IncMode_initSearch(IncMode* search) { search->isFilter = false; } -static const char* filterFunctions[] = {"Done ", "Clear ", " Filter: ", NULL}; -static const char* filterKeys[] = {"Enter", "Esc", " "}; +static const char* const filterFunctions[] = {"Done ", "Clear ", " Filter: ", NULL}; +static const char* const filterKeys[] = {"Enter", "Esc", " "}; static int filterEvents[] = {13, 27, ERR}; static inline void IncMode_initFilter(IncMode* filter) { diff --git a/InfoScreen.c b/InfoScreen.c index e27494c7..dd5095c7 100644 --- a/InfoScreen.c +++ b/InfoScreen.c @@ -50,9 +50,9 @@ struct InfoScreen_ { }; }*/ -static const char* InfoScreenFunctions[] = {"Search ", "Filter ", "Refresh", "Done ", NULL}; +static const char* const InfoScreenFunctions[] = {"Search ", "Filter ", "Refresh", "Done ", NULL}; -static const char* InfoScreenKeys[] = {"F3", "F4", "F5", "Esc"}; +static const char* const InfoScreenKeys[] = {"F3", "F4", "F5", "Esc"}; static int InfoScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(5), 27}; diff --git a/MainPanel.c b/MainPanel.c index a62555ee..b5a7e305 100644 --- a/MainPanel.c +++ b/MainPanel.c @@ -31,7 +31,7 @@ typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t); }*/ -static const char* MainFunctions[] = {"Help ", "Setup ", "Search", "Filter", "Tree ", "SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL}; +static const char* const MainFunctions[] = {"Help ", "Setup ", "Search", "Filter", "Tree ", "SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL}; void MainPanel_updateTreeFunctions(MainPanel* this, bool mode) { FunctionBar* bar = MainPanel_getFunctionBar(this); @@ -336,7 +336,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { #ifdef HAVE_LIBNCURSESW #define PIXPERROW_UTF8 4 -static const char* GraphMeterMode_dotsUtf8[] = { +static const char* const GraphMeterMode_dotsUtf8[] = { /*00*/" ", /*01*/"⢀", /*02*/"⢠", /*03*/"⢰", /*04*/ "⢸", /*10*/"⡀", /*11*/"⣀", /*12*/"⣠", /*13*/"⣰", /*14*/ "⣸", /*20*/"⡄", /*21*/"⣄", /*22*/"⣤", /*23*/"⣴", /*24*/ "⣼", @@ -347,13 +347,13 @@ static const char* GraphMeterMode_dotsUtf8[] = { #endif #define PIXPERROW_ASCII 2 -static const char* GraphMeterMode_dotsAscii[] = { +static const char* const GraphMeterMode_dotsAscii[] = { /*00*/" ", /*01*/".", /*02*/":", /*10*/".", /*11*/".", /*12*/":", /*20*/":", /*21*/":", /*22*/":" }; -static const char** GraphMeterMode_dots; +static const char* const* GraphMeterMode_dots; static int GraphMeterMode_pixPerRow; static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { @@ -406,8 +406,8 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { } for (; i < nValues; i+=2, k++) { int pix = GraphMeterMode_pixPerRow * GRAPH_HEIGHT; - int v1 = CLAMP(data->values[i] * pix, 1, pix); - int v2 = CLAMP(data->values[i+1] * pix, 1, pix); + int v1 = CLAMP((int) lround(data->values[i] * pix), 1, pix); + int v2 = CLAMP((int) lround(data->values[i+1] * pix), 1, pix); int colorIdx = GRAPH_1; for (int line = 0; line < GRAPH_HEIGHT; line++) { @@ -424,7 +424,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { /* ---------- LEDMeterMode ---------- */ -static const char* LEDMeterMode_digitsAscii[] = { +static const char* const LEDMeterMode_digitsAscii[] = { " __ "," "," __ "," __ "," "," __ "," __ "," __ "," __ "," __ ", "| |"," |"," __|"," __|","|__|","|__ ","|__ "," |","|__|","|__|", "|__|"," |","|__ "," __|"," |"," __|","|__|"," |","|__|"," __|" @@ -432,7 +432,7 @@ static const char* LEDMeterMode_digitsAscii[] = { #ifdef HAVE_LIBNCURSESW -static const char* LEDMeterMode_digitsUtf8[] = { +static const char* const LEDMeterMode_digitsUtf8[] = { "┌──┐"," ┐ ","╶──┐","╶──┐","╷ ╷","┌──╴","┌──╴","╶──┐","┌──┐","┌──┐", "│ │"," │ ","┌──┘"," ──┤","└──┤","└──┐","├──┐"," │","├──┤","└──┤", "└──┘"," ╵ ","└──╴","╶──┘"," ╵","╶──┘","└──┘"," ╵","└──┘"," ──┘" @@ -440,7 +440,7 @@ static const char* LEDMeterMode_digitsUtf8[] = { #endif -static const char** LEDMeterMode_digits; +static const char* const* LEDMeterMode_digits; static void LEDMeterMode_drawDigit(int x, int y, int n) { for (int i = 0; i < 3; i++) diff --git a/MetersPanel.c b/MetersPanel.c index 22449f3d..47833d38 100644 --- a/MetersPanel.c +++ b/MetersPanel.c @@ -33,16 +33,16 @@ struct MetersPanel_ { // Note: In code the meters are known to have bar/text/graph "Modes", but in UI // we call them "Styles". -static const char* MetersFunctions[] = {"Style ", "Move ", " ", "Delete", "Done ", NULL}; -static const char* MetersKeys[] = {"Space", "Enter", " ", "Del", "F10"}; +static const char* const MetersFunctions[] = {"Style ", "Move ", " ", "Delete", "Done ", NULL}; +static const char* const MetersKeys[] = {"Space", "Enter", " ", "Del", "F10"}; static int MetersEvents[] = {' ', 13, ERR, KEY_DC, KEY_F(10)}; // We avoid UTF-8 arrows ← → here as they might display full-width on Chinese // terminals, breaking our aligning. // In <http://unicode.org/reports/tr11/>, arrows (U+2019..U+2199) are // considered "Ambiguous characters". -static const char* MetersMovingFunctions[] = {"Style ", "Lock ", "Up ", "Down ", "Left ", "Right ", " ", "Delete", "Done ", NULL}; -static const char* MetersMovingKeys[] = {"Space", "Enter", "Up", "Dn", "<-", "->", " ", "Del", "F10"}; +static const char* const MetersMovingFunctions[] = {"Style ", "Lock ", "Up ", "Down ", "Left ", "Right ", " ", "Delete", "Done ", NULL}; +static const char* const MetersMovingKeys[] = {"Space", "Enter", "Up", "Dn", "<-", "->", " ", "Del", "F10"}; static int MetersMovingEvents[] = {' ', 13, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, ERR, KEY_DC, KEY_F(10)}; static FunctionBar* Meters_movingBar = NULL; @@ -254,23 +254,29 @@ static bool Settings_read(Settings* this, const char* fileName) { static void writeFields(FILE* fd, ProcessField* fields, const char* name) { fprintf(fd, "%s=", name); + const char* sep = ""; for (int i = 0; fields[i]; i++) { // This "-1" is for compatibility with the older enum format. - fprintf(fd, "%d ", (int) fields[i]-1); + fprintf(fd, "%s%d", sep, (int) fields[i]-1); + sep = " "; } fprintf(fd, "\n"); } static void writeMeters(Settings* this, FILE* fd, int column) { + const char* sep = ""; for (int i = 0; i < this->columns[column].len; i++) { - fprintf(fd, "%s ", this->columns[column].names[i]); + fprintf(fd, "%s%s", sep, this->columns[column].names[i]); + sep = " "; } fprintf(fd, "\n"); } static void writeMeterModes(Settings* this, FILE* fd, int column) { + const char* sep = ""; for (int i = 0; i < this->columns[column].len; i++) { - fprintf(fd, "%d ", this->columns[column].modes[i]); + fprintf(fd, "%s%d", sep, this->columns[column].modes[i]); + sep = " "; } fprintf(fd, "\n"); } diff --git a/TraceScreen.c b/TraceScreen.c index 318b9091..5a49d5fd 100644 --- a/TraceScreen.c +++ b/TraceScreen.c @@ -43,9 +43,9 @@ typedef struct TraceScreen_ { }*/ -static const char* TraceScreenFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL}; +static const char* const TraceScreenFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL}; -static const char* TraceScreenKeys[] = {"F3", "F4", "F8", "F9", "Esc"}; +static const char* const TraceScreenKeys[] = {"F3", "F4", "F8", "F9", "Esc"}; static int TraceScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(8), KEY_F(9), 27}; diff --git a/linux/IOPriorityPanel.c b/linux/IOPriorityPanel.c index 9e12c755..3085fb02 100644 --- a/linux/IOPriorityPanel.c +++ b/linux/IOPriorityPanel.c @@ -19,7 +19,7 @@ Panel* IOPriorityPanel_new(IOPriority currPrio) { Panel_setHeader(this, "IO Priority:"); Panel_add(this, (Object*) ListItem_new("None (based on nice)", IOPriority_None)); if (currPrio == IOPriority_None) Panel_setSelected(this, 0); - struct { int klass; const char* name; } classes[] = { + static const struct { int klass; const char* name; } classes[] = { { .klass = IOPRIO_CLASS_RT, .name = "Realtime" }, { .klass = IOPRIO_CLASS_BE, .name = "Best-effort" }, { .klass = 0, .name = NULL } |