aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/main.c b/main.c
index 879b4a7..0e89e0e 100644
--- a/main.c
+++ b/main.c
@@ -86,7 +86,7 @@ char *db_file_path = NULL;
char *ar_file_path = NULL;
char *string_buffer = NULL; // A temporary buffer for localized actions. Please avoid data leaks and out-of-bounds errors.
size_t string_buffer_size = 0;
-int size_x, size_y, pos_x, pos_y;
+int size_x, size_y, pos_x, pos_y; // WIP Validating usage of size_t variables.
void trigger_autosave() {
countdown_to_autosave = 13375; // ms
@@ -146,7 +146,7 @@ size_t truncate_string_utf8(char *string, size_t length) { // TODO Rename to tru
// Returns true when the string is empty or consists of white space characters.
bool is_empty_string(char *string) {
- for(int idx = 0; string[idx] != '\0'; idx++) {
+ for (int idx = 0; string[idx] != '\0'; idx++) {
switch(string[idx]) {
case ' ':
case '\t':
@@ -288,7 +288,7 @@ bool create_task(database_st *db, task_st **task) {
// If necessary, expand database capacity.
size_t current_capacity = db->capacity;
- if((db->count + 1) > current_capacity) {
+ if ((db->count + 1) > current_capacity) {
size_t new_capacity =
current_capacity == 0 ? 2 :
current_capacity > (MAX_DATABASE_TASKS >> 1) ? MAX_DATABASE_TASKS :
@@ -473,7 +473,7 @@ void update_total_times(database_st *db) {
int64_t *totals = db->total_times;
memset(totals, 0, NUM_WEEK_DAYS * SIZEOF_INT64);
- for (size_t idx = 0; idx < db->count; idx++) {
+ for (size_t idx = 0; idx < db->count; idx++) { // TODO WIP Here may be dragons because of for loop on an unsigned var.
int64_t *times = db->tasks[idx].times;
totals[0] = add_int64(totals[0], times[0]);
totals[1] = add_int64(totals[1], times[1]);
@@ -661,7 +661,7 @@ bool import_from_csv(database_st *db, const char *path) {
truncate_string_utf8(task->name, name_length);
// Parse task times.
- if(sscanf(name_delimiter + 1,
+ if (sscanf(name_delimiter + 1,
"%" SCNd64 ",%" SCNd64 ",%" SCNd64 ",%" SCNd64 ",%" SCNd64 ",%" SCNd64 ",%" SCNd64,
&task->times[0], &task->times[1], &task->times[2], &task->times[3], &task->times[4], &task->times[5], &task->times[6]
) != NUM_WEEK_DAYS
@@ -826,7 +826,7 @@ void initialize_tui() {
};
// Calculate alignment_offsets.
- for(layout_st *layout = layouts; layout < layouts + NUM_LAYOUTS; layout++) {
+ for (layout_st *layout = layouts; layout < layouts + NUM_LAYOUTS; layout++) {
for (column_st *col = layout->columns; col < layout->columns + NUM_COLUMNS; col++) {
int offset;
switch(col->alignment) {
@@ -937,7 +937,7 @@ void draw_tui(database_st *db, layout_st *layout) {
if (idx == now_week_day && active_task != NULL) {
attron(COLOR_PAIR(THEME_E) | A_BOLD);
}
- else if(idx == now_week_day) {
+ else if (idx == now_week_day) {
attron(COLOR_PAIR(THEME_D) | A_BOLD);
}
@@ -978,7 +978,7 @@ void draw_tui(database_st *db, layout_st *layout) {
else if (task == selected_task) {
attron(COLOR_PAIR(THEME_B));
}
- else if(task == active_task) {
+ else if (task == active_task) {
attron(COLOR_PAIR(THEME_A) | A_BOLD);
}
@@ -1041,7 +1041,7 @@ void draw_tui(database_st *db, layout_st *layout) {
if (idx == now_week_day && active_task != NULL) {
attron(COLOR_PAIR(THEME_E) | A_BOLD);
}
- else if(idx == now_week_day) {
+ else if (idx == now_week_day) {
attron(COLOR_PAIR(THEME_D) | A_BOLD);
}
@@ -1058,7 +1058,7 @@ void draw_tui(database_st *db, layout_st *layout) {
void *mem_alloc(size_t mem_size, const char *error_tag) {
void *mem_pointer = malloc(mem_size);
- if(mem_pointer == NULL && mem_size > 0) {
+ if (mem_pointer == NULL && mem_size > 0) {
fprintf(stderr, "Failed to allocate memory (%s): %s.\n", (error_tag == NULL ? "undefined" : error_tag), strerror(errno));
exit(EXIT_FAILURE);
}