aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkatherine <ageha@airen-no-jikken.icu>2021-01-09 14:30:51 -0700
committerkatherine <ageha@airen-no-jikken.icu>2021-01-09 14:30:51 -0700
commitbad02f6ac0b272df131608b12b650795c0088e8f (patch)
treef58e9a00230108f66457721f0242f871090bc8dd
parent5113a9fd817e5df67b3b9cf9cf3a4fee715587b8 (diff)
downloadevery-bad02f6ac0b272df131608b12b650795c0088e8f.tar.gz
line-delim -> line-termHEADmaster
-rw-r--r--Readme.md4
-rw-r--r--src/calendar.c4
-rw-r--r--src/opt.c6
-rw-r--r--src/opt.h2
-rw-r--r--src/print.c13
5 files changed, 13 insertions, 16 deletions
diff --git a/Readme.md b/Readme.md
index c003495..57c5929 100644
--- a/Readme.md
+++ b/Readme.md
@@ -78,7 +78,7 @@ Usage: ./dbg_every [-c CALENDAR_FILE] [-e TEXT_EDITOR] [COMMAND]
-v --version print the version of every in use and exit
-c --calendar=FILE path to calendar file
-e --editor=CMD text editor for editing calendars
- --line-delim=CHAR line delimiter for scripting output
+ --line-term=CHAR line terminator for scripting output
--col-delim=CHAR column delimiter for scripting output
Commands
@@ -108,7 +108,7 @@ equivalent.
### script
`every s` prints the upcoming events in an easily-parseable format, for use in
-scripting. each line (by-default separated with `\n`) represents one upcoming
+scripting. each line (by-default terminated with `\n`) represents one upcoming
event, with fields (by default) delimited with `\t`.
the fields are:
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;
diff --git a/src/opt.c b/src/opt.c
index 6a958a6..40743cb 100644
--- a/src/opt.c
+++ b/src/opt.c
@@ -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;
diff --git a/src/opt.h b/src/opt.h
index 45bc0bd..461c747 100644
--- a/src/opt.h
+++ b/src/opt.h
@@ -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);