diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | README | LICENSE

commit de3843a5a39ba17e9619bcb2ba24f452c8cdba50
parent 89df94e8ac613d829fbfbea0e312bd94b99ea59d
Author: in0rdr <andreas.gruhler@uzh.ch>
Date:   Mon, 26 Dec 2016 22:13:11 +0100

Revert "less strlen"

This reverts commit 259fa59da3aa6fc9b5d78c60e1c7a791b93b2426.

Diffstat:
Mdiary.c | 14++++++--------
Mdiary.h | 2+-
2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/diary.c b/diary.c @@ -289,7 +289,7 @@ struct tm find_closest_entry(const struct tm current, int main(int argc, char** argv) { setlocale(LC_ALL, ""); - char diary_dir_init[80]; + char diary_dir[80]; char* env_var; chtype atrs; @@ -305,21 +305,19 @@ int main(int argc, char** argv) { return 1; } - if (strlen(env_var) + 1 > sizeof diary_dir_init) { + if (strlen(env_var) + 1 > sizeof diary_dir) { fprintf(stderr, "Diary directory path too long\n"); return 1; } - strcpy(diary_dir_init, env_var); + strcpy(diary_dir, env_var); } else { - if (strlen(argv[1]) + 1 > sizeof diary_dir_init) { + if (strlen(argv[1]) + 1 > sizeof diary_dir) { fprintf(stderr, "Diary directory path too long\n"); return 1; } - strcpy(diary_dir_init, argv[1]); + strcpy(diary_dir, argv[1]); } - const char* diary_dir = diary_dir_init; - // check if that directory exists DIR* diary_dir_ptr = opendir(diary_dir); if (diary_dir_ptr) { @@ -387,6 +385,7 @@ int main(int argc, char** argv) { struct tm new_date; int prev_width = COLS - ASIDE_WIDTH - CAL_WIDTH; int prev_height = LINES - 1; + size_t diary_dir_size = strlen(diary_dir); bool mv_valid = go_to(cal, aside, raw_time, &pad_pos); // mark current day @@ -397,7 +396,6 @@ int main(int argc, char** argv) { WINDOW* prev = newwin(prev_height, prev_width, 1, ASIDE_WIDTH + CAL_WIDTH); display_entry(diary_dir, strlen(diary_dir), &today, prev, prev_width); - size_t diary_dir_size = strlen(diary_dir); do { ch = wgetch(cal); diff --git a/diary.h b/diary.h @@ -25,7 +25,7 @@ static const char* WEEKDAYS[] = {"Su","Mo","Tu","We","Th","Fr","Sa"}; void setup_cal_timeframe(); void draw_wdays(WINDOW* head); -void draw_calendar(WINDOW* number_pad, WINDOW* month_pad, const char* diary_dir, size_t diary_dir_size); +void draw_calendar(WINDOW* number_pad, WINDOW* month_pad, char* diary_dir, size_t diary_dir_size); void update_date(WINDOW* header); bool go_to(WINDOW* calendar, WINDOW* aside, time_t date, int* cur_pad_pos);