Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Fix trailing whitespace #960

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ charset = utf-8
[*.{c,h}]
indent_style = space
indent_size = 3
trim_trailing_whitespace = true
4 changes: 2 additions & 2 deletions Action.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Object* Action_pickFromVector(State* st, Panel* list, int x) {
Panel* panel = st->panel;
Header* header = st->header;
Settings* settings = st->settings;

int y = panel->y;
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, false);
scr->allowFocusChange = false;
Expand Down Expand Up @@ -297,7 +297,7 @@ static Htop_Reaction actionSetAffinity(State* st) {
return HTOP_OK;
#if (HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY)
Panel* panel = st->panel;

Process* p = (Process*) Panel_getSelected(panel);
if (!p) return HTOP_OK;
Affinity* affinity = Affinity_get(p, st->pl);
Expand Down
4 changes: 2 additions & 2 deletions AvailableMetersPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static inline void AvailableMetersPanel_addMeter(Header* header, Panel* panel, M
static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) {
AvailableMetersPanel* this = (AvailableMetersPanel*) super;
Header* header = this->header;

ListItem* selected = (ListItem*) Panel_getSelected(super);
int param = selected->key & 0xff;
int type = selected->key >> 16;
Expand Down Expand Up @@ -104,7 +104,7 @@ AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* heade
Panel* super = (Panel*) this;
FunctionBar* fuBar = FunctionBar_newEnterEsc("Add ", "Done ");
Panel_init(super, 1, 1, 1, 1, Class(ListItem), true, fuBar);

this->settings = settings;
this->header = header;
this->leftPanel = leftMeters;
Expand Down
2 changes: 1 addition & 1 deletion BatteryMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int BatteryMeter_attributes[] = {
static void BatteryMeter_updateValues(Meter * this, char *buffer, int len) {
ACPresence isOnAC;
double percent;

Battery_getData(&percent, &isOnAC);

if (percent == -1) {
Expand Down
14 changes: 7 additions & 7 deletions CPUMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ MeterClass CPUMeter_class = {
.defaultMode = BAR_METERMODE,
.maxItems = CPU_METER_ITEMCOUNT,
.total = 100.0,
.attributes = CPUMeter_attributes,
.attributes = CPUMeter_attributes,
.name = "CPU",
.uiName = "CPU",
.caption = "CPU",
Expand All @@ -234,7 +234,7 @@ MeterClass AllCPUsMeter_class = {
},
.defaultMode = CUSTOM_METERMODE,
.total = 100.0,
.attributes = CPUMeter_attributes,
.attributes = CPUMeter_attributes,
.name = "AllCPUs",
.uiName = "CPUs (1/1)",
.description = "CPUs (1/1): all CPUs",
Expand All @@ -253,7 +253,7 @@ MeterClass AllCPUs2Meter_class = {
},
.defaultMode = CUSTOM_METERMODE,
.total = 100.0,
.attributes = CPUMeter_attributes,
.attributes = CPUMeter_attributes,
.name = "AllCPUs2",
.uiName = "CPUs (1&2/2)",
.description = "CPUs (1&2/2): all CPUs in 2 shorter columns",
Expand All @@ -272,7 +272,7 @@ MeterClass LeftCPUsMeter_class = {
},
.defaultMode = CUSTOM_METERMODE,
.total = 100.0,
.attributes = CPUMeter_attributes,
.attributes = CPUMeter_attributes,
.name = "LeftCPUs",
.uiName = "CPUs (1/2)",
.description = "CPUs (1/2): first half of list",
Expand All @@ -291,7 +291,7 @@ MeterClass RightCPUsMeter_class = {
},
.defaultMode = CUSTOM_METERMODE,
.total = 100.0,
.attributes = CPUMeter_attributes,
.attributes = CPUMeter_attributes,
.name = "RightCPUs",
.uiName = "CPUs (2/2)",
.description = "CPUs (2/2): second half of list",
Expand All @@ -310,7 +310,7 @@ MeterClass LeftCPUs2Meter_class = {
},
.defaultMode = CUSTOM_METERMODE,
.total = 100.0,
.attributes = CPUMeter_attributes,
.attributes = CPUMeter_attributes,
.name = "LeftCPUs2",
.uiName = "CPUs (1&2/4)",
.description = "CPUs (1&2/4): first half in 2 shorter columns",
Expand All @@ -329,7 +329,7 @@ MeterClass RightCPUs2Meter_class = {
},
.defaultMode = CUSTOM_METERMODE,
.total = 100.0,
.attributes = CPUMeter_attributes,
.attributes = CPUMeter_attributes,
.name = "RightCPUs2",
.uiName = "CPUs (3&4/4)",
.description = "CPUs (3&4/4): second half in 2 shorter columns",
Expand Down
4 changes: 2 additions & 2 deletions CRT.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,12 @@ void CRT_init(int delay, int colorScheme) {
}
CRT_colors = CRT_colorSchemes[colorScheme];
CRT_colorScheme = colorScheme;

for (int i = 0; i < LAST_COLORELEMENT; i++) {
unsigned int color = CRT_colorSchemes[COLORSCHEME_DEFAULT][i];
CRT_colorSchemes[COLORSCHEME_BROKENGRAY][i] = color == (A_BOLD | ColorPairGrayBlack) ? ColorPair(White,Black) : color;
}

halfdelay(CRT_delay);
nonl();
intrflush(stdscr, false);
Expand Down
4 changes: 2 additions & 2 deletions CheckItem.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ CheckItem* CheckItem_newByVal(char* text, bool value) {
}

void CheckItem_set(CheckItem* this, bool value) {
if (this->ref)
if (this->ref)
*(this->ref) = value;
else
this->value = value;
}

bool CheckItem_get(CheckItem* this) {
if (this->ref)
if (this->ref)
return *(this->ref);
else
return this->value;
Expand Down
2 changes: 1 addition & 1 deletion ColorsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void ColorsPanel_delete(Object* object) {

static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
ColorsPanel* this = (ColorsPanel*) super;

HandlerResult result = IGNORED;
int mark = Panel_getSelectedIndex(super);

Expand Down
4 changes: 2 additions & 2 deletions ColumnsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void ColumnsPanel_delete(Object* object) {

static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
ColumnsPanel* const this = (ColumnsPanel*) super;

int selected = Panel_getSelectedIndex(super);
HandlerResult result = IGNORED;
int size = Panel_size(super);
Expand Down Expand Up @@ -87,7 +87,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
case ']':
case '+':
{
if (selected < size - 2)
if (selected < size - 2)
Panel_moveSelectedDown(super);
result = HANDLED;
break;
Expand Down
2 changes: 1 addition & 1 deletion DisplayOptionsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void DisplayOptionsPanel_delete(Object* object) {

static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) {
DisplayOptionsPanel* this = (DisplayOptionsPanel*) super;

HandlerResult result = IGNORED;
CheckItem* selected = (CheckItem*) Panel_getSelected(super);

Expand Down
2 changes: 1 addition & 1 deletion FunctionBar.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ FunctionBar* FunctionBar_new(const char* const* functions, const char* const* ke
this->functions[i] = xStrdup(functions[i]);
}
if (keys && events) {
this->staticData = false;
this->staticData = false;
this->keys = xCalloc(15, sizeof(char*));
this->events = xCalloc(15, sizeof(int));
int i = 0;
Expand Down
8 changes: 4 additions & 4 deletions Hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int Hashtable_count(Hashtable* this) {

static HashtableItem* HashtableItem_new(unsigned int key, void* value) {
HashtableItem* this;

this = xMalloc(sizeof(HashtableItem));
this->key = key;
this->value = value;
Expand All @@ -73,7 +73,7 @@ static HashtableItem* HashtableItem_new(unsigned int key, void* value) {

Hashtable* Hashtable_new(int size, bool owner) {
Hashtable* this;

this = xMalloc(sizeof(Hashtable));
this->items = 0;
this->size = size;
Expand Down Expand Up @@ -119,10 +119,10 @@ void Hashtable_put(Hashtable* this, unsigned int key, void* value) {

void* Hashtable_remove(Hashtable* this, unsigned int key) {
unsigned int index = key % this->size;

assert(Hashtable_isConsistent(this));

HashtableItem** bucket;
HashtableItem** bucket;
for (bucket = &(this->buckets[index]); *bucket; bucket = &((*bucket)->next) ) {
if ((*bucket)->key == key) {
void* value = (*bucket)->value;
Expand Down
10 changes: 5 additions & 5 deletions Header.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ void Header_populateFromSettings(Header* this) {
void Header_writeBackToSettings(const Header* this) {
Header_forEachColumn(this, col) {
MeterColumnSettings* colSettings = &this->settings->columns[col];

String_freeArray(colSettings->names);
free(colSettings->modes);

Vector* vec = this->columns[col];
int len = Vector_size(vec);

colSettings->names = xCalloc(len+1, sizeof(char*));
colSettings->modes = xCalloc(len, sizeof(int));
colSettings->len = len;

for (int i = 0; i < len; i++) {
Meter* meter = (Meter*) Vector_get(vec, i);
char* name = xCalloc(64, sizeof(char));
Expand Down Expand Up @@ -186,7 +186,7 @@ void Header_draw(const Header* this) {
}
int width = COLS / this->nrColumns - (pad * this->nrColumns - 1) - 1;
int x = pad;

Header_forEachColumn(this, col) {
Vector* meters = this->columns[col];
for (int y = (pad / 2), i = 0; i < Vector_size(meters); i++) {
Expand Down
4 changes: 2 additions & 2 deletions InfoScreen.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void InfoScreen_run(InfoScreen* this) {
}
set_escdelay(25);
int ch = getch();

if (ch == ERR) {
if (As_InfoScreen(this)->onErr) {
InfoScreen_onErr(this);
Expand All @@ -143,7 +143,7 @@ void InfoScreen_run(InfoScreen* this) {
IncSet_handleKey(this->inc, ch, panel, IncSet_getListItemValue, this->lines);
continue;
}

switch(ch) {
case ERR:
continue;
Expand Down
6 changes: 3 additions & 3 deletions MainPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
MainPanel* this = (MainPanel*) super;

HandlerResult result = IGNORED;

Htop_Reaction reaction = HTOP_OK;

if (EVENT_IS_HEADER_CLICK(ch)) {
Expand All @@ -84,7 +84,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
} else {
reaction |= Action_setSortKey(settings, field);
}
reaction |= HTOP_RECALCULATE | HTOP_REDRAW_BAR | HTOP_SAVE_SETTINGS;
reaction |= HTOP_RECALCULATE | HTOP_REDRAW_BAR | HTOP_SAVE_SETTINGS;
result = HANDLED;
} else if (ch != ERR && this->inc->active) {
bool filterChanged = IncSet_handleKey(this->inc, ch, super, (IncMode_GetPanelValue) MainPanel_getValue, NULL);
Expand Down Expand Up @@ -121,7 +121,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
}
if (reaction & HTOP_REFRESH) {
result |= REDRAW;
}
}
if (reaction & HTOP_RECALCULATE) {
result |= RESCAN;
}
Expand Down
2 changes: 1 addition & 1 deletion MemoryMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ MeterClass MemoryMeter_class = {
.delete = Meter_delete,
.display = MemoryMeter_display,
},
.updateValues = MemoryMeter_updateValues,
.updateValues = MemoryMeter_updateValues,
.defaultMode = BAR_METERMODE,
.maxItems = 3,
.total = 100.0,
Expand Down
16 changes: 8 additions & 8 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ typedef struct MeterClass_ {
struct Meter_ {
Object super;
Meter_Draw draw;

char* caption;
int mode;
int param;
Expand Down Expand Up @@ -275,7 +275,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
attrset(CRT_colors[BAR_BORDER]);
mvaddch(y, x, '[');
mvaddch(y, x + w, ']');

w--;
x++;

Expand All @@ -284,7 +284,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
return;
}
char bar[w + 1];

int blockSizes[10];

xSnprintf(bar, w + 1, "%*.*s", w, w, buffer);
Expand Down Expand Up @@ -378,7 +378,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
mvaddnstr(y, x, this->caption, captionLen);
x += captionLen;
w -= captionLen;

struct timeval now;
gettimeofday(&now, NULL);
if (!timercmp(&now, &(data->time), <)) {
Expand All @@ -387,18 +387,18 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {

for (int i = 0; i < nValues - 1; i++)
data->values[i] = data->values[i+1];

char buffer[nValues];
Meter_updateValues(this, buffer, nValues - 1);

double value = 0.0;
int items = Meter_getItems(this);
for (int i = 0; i < items; i++)
value += this->values[i];
value /= this->total;
data->values[nValues - 1] = value;
}

int i = nValues - (w*2) + 2, k = 0;
if (i < 0) {
k = -i/2;
Expand Down Expand Up @@ -459,7 +459,7 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {

char buffer[METER_BUFFER_LEN];
Meter_updateValues(this, buffer, METER_BUFFER_LEN - 1);

RichString_begin(out);
Meter_displayBuffer(this, buffer, &out);

Expand Down
2 changes: 1 addition & 1 deletion Meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef struct MeterClass_ {
struct Meter_ {
Object super;
Meter_Draw draw;

char* caption;
int mode;
int param;
Expand Down
2 changes: 1 addition & 1 deletion MetersPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static inline bool moveToNeighbor(MetersPanel* this, MetersPanel* neighbor, int

static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
MetersPanel* this = (MetersPanel*) super;

int selected = Panel_getSelectedIndex(super);
HandlerResult result = IGNORED;
bool sideMove = false;
Expand Down
2 changes: 1 addition & 1 deletion Object.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef void(*Object_Delete)(Object*);
#define Class(class_) ((ObjectClass*)(&(class_ ## _class)))

#define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_));

typedef struct ObjectClass_ {
const void* extends;
const Object_Display display;
Expand Down
Loading