diff options
author | katherine <ageha@airen-no-jikken.icu> | 2021-01-09 14:30:51 -0700 |
---|---|---|
committer | katherine <ageha@airen-no-jikken.icu> | 2021-01-09 14:30:51 -0700 |
commit | bad02f6ac0b272df131608b12b650795c0088e8f (patch) | |
tree | f58e9a00230108f66457721f0242f871090bc8dd /src | |
parent | 5113a9fd817e5df67b3b9cf9cf3a4fee715587b8 (diff) | |
download | every-master.tar.gz |
Diffstat (limited to 'src')
-rw-r--r-- | src/calendar.c | 4 | ||||
-rw-r--r-- | src/opt.c | 6 | ||||
-rw-r--r-- | src/opt.h | 2 | ||||
-rw-r--r-- | src/print.c | 13 |
4 files changed, 11 insertions, 14 deletions
diff --git a/src/calendar.c b/src/calendar.c index b852b1c..e656525 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -596,9 +596,9 @@ static char* sub_get_msg(struct state_s *s) } } - if (c == opt_line_delim() || c == opt_col_delim()) { + if (c == opt_line_term() || c == opt_col_delim()) { sub_set_pos(s, sub_get_pos(s)); - ERRP("message may not contain line or column delimiter characters"); + ERRP("message may not contain column delimiter or line terminator"); s->err_flag = true; free(msg); return NULL; @@ -17,8 +17,8 @@ static struct simple_opt options[] = { "path to calendar file", "FILE" }, { SIMPLE_OPT_STRING, 'e', "editor", true, "text editor for editing calendars", "CMD" }, - { SIMPLE_OPT_CHAR, '\0', "line-delim", true, - "line delimiter for scripting output" }, + { SIMPLE_OPT_CHAR, '\0', "line-term", true, + "line terminator for scripting output" }, { SIMPLE_OPT_CHAR, '\0', "col-delim", true, "column delimiter for scripting output" }, { SIMPLE_OPT_END } @@ -99,7 +99,7 @@ char* opt_editor(void) return getenv("EDITOR"); } -char opt_line_delim(void) +char opt_line_term(void) { if (options[4].was_seen) return options[4].val.v_char; @@ -12,7 +12,7 @@ void opt_parse(int argc, char **argv); char* opt_calpath(void); char* opt_editor(void); -char opt_line_delim(void); +char opt_line_term(void); char opt_col_delim(void); enum opt_command_e opt_command(void); diff --git a/src/print.c b/src/print.c index 02f78c6..34c1802 100644 --- a/src/print.c +++ b/src/print.c @@ -195,8 +195,7 @@ void print_script(struct calendar_s *cal) size_t i, j; struct tm t = { 0 }; time_t now = time(NULL), *rttmp; - char cd; - bool first = true; + char cd, lt; struct buf_s *buf = malloc(cal->count * sizeof(*buf)); if (buf == NULL) { @@ -205,6 +204,7 @@ void print_script(struct calendar_s *cal) } cd = opt_col_delim(); + lt = opt_line_term(); /* fill buffer with active events */ for (i = 0, j = 0; i < cal->count; i++) { @@ -223,23 +223,20 @@ void print_script(struct calendar_s *cal) for (i = 0; i < j; i++) { t = *localtime( &(buf[i].rt) ); - if (!first) - printf("%c", opt_line_delim()); - printf( "%d%c%d%c%d%c%d%c%d%c%d%c" /* date */ "%d%c" /* urgent */ "%d%c" /* local */ "%s" /* msg */ + "%c" /* line_end */ , t.tm_year + 1900, cd, t.tm_mon + 1, cd, t.tm_mday, cd, t.tm_hour, cd, t.tm_min, cd, t.tm_sec, cd, cal->entries[i].urgent, cd, cal->entries[i].local, cd, - (cal->entries[i].msg == NULL ? "" : cal->entries[i].msg) + (cal->entries[i].msg == NULL ? "" : cal->entries[i].msg), + lt ); - - first = false; } free(buf); |