mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 14:28:40 +02:00
Compare commits
189 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3e32d2dc4 | ||
|
|
a8b78eff00 | ||
|
|
460db83298 | ||
|
|
4560712778 | ||
|
|
ce8803dde9 | ||
|
|
60ca5d45e3 | ||
|
|
4454613d00 | ||
|
|
0704808500 | ||
|
|
166b1ac499 | ||
|
|
e33bf4e80a | ||
|
|
b3af44d212 | ||
|
|
1e753d5209 | ||
|
|
4bf31005ea | ||
|
|
7c86bc910a | ||
|
|
4f146a99a9 | ||
|
|
a6a638e0e6 | ||
|
|
325814f5e1 | ||
|
|
5c4ea7d09e | ||
|
|
2bf73987ac | ||
|
|
3e9eeea8dc | ||
|
|
d164d72c1c | ||
|
|
632cee62d9 | ||
|
|
7a40260f0d | ||
|
|
09f043b3de | ||
|
|
c0341c8ba3 | ||
|
|
850c717803 | ||
|
|
f13f9e18bd | ||
|
|
8bdca0d684 | ||
|
|
129bf5612e | ||
|
|
829962fae1 | ||
|
|
c5f9ed8541 | ||
|
|
4a7cef4644 | ||
|
|
0e010b56ec | ||
|
|
ee179ee2f5 | ||
|
|
e28712cef3 | ||
|
|
8f0a2a7e79 | ||
|
|
ef23bba77f | ||
|
|
602086ae2d | ||
|
|
f5a170acbd | ||
|
|
8125b96f0b | ||
|
|
0bb7d89bb9 | ||
|
|
eb109bbbc0 | ||
|
|
1a0809fd31 | ||
|
|
09625b9d68 | ||
|
|
4e164c4268 | ||
|
|
691185f22c | ||
|
|
a8bfb41a9e | ||
|
|
fafb30db05 | ||
|
|
243e816523 | ||
|
|
b49c0f52bd | ||
|
|
07fca94a7f | ||
|
|
73917ee537 | ||
|
|
76f9edecf6 | ||
|
|
d77d9854d2 | ||
|
|
c2b53f95a4 | ||
|
|
caef8b80d6 | ||
|
|
5e016768af | ||
|
|
ee08ce98d7 | ||
|
|
581bd95838 | ||
|
|
bb92dab1ab | ||
|
|
83b5c52c76 | ||
|
|
93eca25141 | ||
|
|
34421cb10e | ||
|
|
29b87898aa | ||
|
|
e9e4db94bd | ||
|
|
c95ad0261a | ||
|
|
7fef456483 | ||
|
|
386131e74d | ||
|
|
824d3c88f1 | ||
|
|
18a206abd2 | ||
|
|
8dbae776c9 | ||
|
|
b78702cc53 | ||
|
|
d2b43605ad | ||
|
|
7728e09337 | ||
|
|
2666353ce6 | ||
|
|
0b8a306483 | ||
|
|
b51a0b2d08 | ||
|
|
959355b19c | ||
|
|
9c3f0f1994 | ||
|
|
dac337a65b | ||
|
|
98739dfdbc | ||
|
|
17b7a1ea84 | ||
|
|
4d45925758 | ||
|
|
8cadb23f48 | ||
|
|
63211b65c2 | ||
|
|
1be84525b1 | ||
|
|
67ae95a464 | ||
|
|
c03a95ad94 | ||
|
|
51aa7aecb9 | ||
|
|
592cfe5a20 | ||
|
|
b4cf15e73e | ||
|
|
862e143372 | ||
|
|
1f10ca49ad | ||
|
|
4a0c4ffdca | ||
|
|
27c8737f3a | ||
|
|
ecf45fc453 | ||
|
|
0a1178cfd7 | ||
|
|
20a35dc627 | ||
|
|
79887c06f0 | ||
|
|
f7ff424904 | ||
|
|
6678721fe3 | ||
|
|
496302097b | ||
|
|
fe3e2b9a20 | ||
|
|
400a6b066f | ||
|
|
76d181e7fc | ||
|
|
77373eed2d | ||
|
|
6b52be388f | ||
|
|
0518a12a91 | ||
|
|
362a02c4b8 | ||
|
|
3e3a0cde47 | ||
|
|
c16f93effd | ||
|
|
61b27c02b5 | ||
|
|
ba28eaad53 | ||
|
|
92c2d0cc9f | ||
|
|
21d5e8a095 | ||
|
|
60417d68a7 | ||
|
|
7d25387403 | ||
|
|
b454cf5b20 | ||
|
|
9ea6385b72 | ||
|
|
55b7908444 | ||
|
|
e9ff66478b | ||
|
|
d3240d711d | ||
|
|
a8d63a4199 | ||
|
|
a4807a21c3 | ||
|
|
a394ef53a0 | ||
|
|
eb8243743a | ||
|
|
8444bb15c5 | ||
|
|
b86245c4c6 | ||
|
|
499fcfad41 | ||
|
|
bddbbf061b | ||
|
|
05136f4cf0 | ||
|
|
e62e3d5d03 | ||
|
|
595fdaa4a4 | ||
|
|
133febc2c1 | ||
|
|
f8c6d7ff6c | ||
|
|
db3341db91 | ||
|
|
8cbcd3ec01 | ||
|
|
4c6512e9b6 | ||
|
|
4769789a8f | ||
|
|
b4a8cb085c | ||
|
|
4f816d52fd | ||
|
|
94b3a0248d | ||
|
|
5fbf1d82e4 | ||
|
|
55eb3ebe95 | ||
|
|
2afa3c5558 | ||
|
|
30d9a42db2 | ||
|
|
74d357b84d | ||
|
|
09c98a93ec | ||
|
|
ed89ab7c04 | ||
|
|
27c74be02b | ||
|
|
8f22ab39dc | ||
|
|
795c53f4ce | ||
|
|
3fd18a9cc0 | ||
|
|
a5afb4a87e | ||
|
|
379fc4542d | ||
|
|
538ef6c8ce | ||
|
|
95c7e8856c | ||
|
|
95523c8f10 | ||
|
|
97b53d5e40 | ||
|
|
fb688850b1 | ||
|
|
5b1bad2650 | ||
|
|
e5ff132c5e | ||
|
|
a0830ad23c | ||
|
|
9290f53466 | ||
|
|
e5711032bd | ||
|
|
08e3c1d5a2 | ||
|
|
29c579a301 | ||
|
|
61f55bceee | ||
|
|
6586fae3eb | ||
|
|
d5a86f3e4f | ||
|
|
96551ccaa4 | ||
|
|
c83ee86d10 | ||
|
|
c913306cbd | ||
|
|
03d385df97 | ||
|
|
61fcc1b275 | ||
|
|
26977a4ac0 | ||
|
|
28acd05215 | ||
|
|
be4eed8b20 | ||
|
|
cdb0850373 | ||
|
|
0d55e04284 | ||
|
|
f4cce54b70 | ||
|
|
2dc6ca44f1 | ||
|
|
d1d833f0f3 | ||
|
|
1d44577ce9 | ||
|
|
1be7c2d6d7 | ||
|
|
b1f418ee42 | ||
|
|
72b0bf96fe | ||
|
|
3388849fa5 | ||
|
|
dc9650d5fa |
@@ -1,3 +1,8 @@
|
||||
workflow:
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH =~ /wip/
|
||||
when: never
|
||||
|
||||
tests:
|
||||
image: 'debian:stable-slim'
|
||||
before_script:
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
MICROSOFT WINDOWS
|
||||
=================
|
||||
|
||||
I used to prohibit porting Remind to Microsoft Windows. However, this
|
||||
may cause problems with the GPL, so I have removed that restriction.
|
||||
|
||||
Although I cannot prevent you from porting Remind to Windows, I appeal
|
||||
to you not to do it. I am trying to encourage the growth of free
|
||||
software, not proprietary software.
|
||||
|
||||
If you port Remind to Windows, I will not provide support or answers to
|
||||
questions -- you're on your own. On the other hand, I will feel no guilt
|
||||
in taking enhancements and merging them into the UNIX stream.
|
||||
|
||||
APPLE
|
||||
=====
|
||||
|
||||
I can't prevent you from using Remind on Apple's products, but I hope
|
||||
you don't. Apple's corporate culture is the very antithesis of Free
|
||||
Software. Rather than using Mac OS X, I encourage you to switch to
|
||||
Linux or FreeBSD, two Free Software operating systems that are every
|
||||
bit as capable as Mac OS X and which are unencumbered by Apple's
|
||||
arbitrary restrictions.
|
||||
|
||||
And if you're looking to port Remind to other Apple products like the
|
||||
iPhone or iPad, please don't. Those products enforce Apple's rigorous
|
||||
controls much more stringently than Mac OS X on an Apple PC.
|
||||
|
||||
--
|
||||
Dianne Skoll
|
||||
30
build.tk
30
build.tk
@@ -15,6 +15,8 @@
|
||||
# the next line restarts using wish \
|
||||
exec wish "$0" "$@"
|
||||
|
||||
global RemindExecutable
|
||||
|
||||
#***********************************************************************
|
||||
# %PROCEDURE: SetConfigDefaults
|
||||
# %ARGUMENTS:
|
||||
@@ -40,7 +42,7 @@ proc SetConfigDefaults {} {
|
||||
set Config(WESTERN_HEMISPHERE) 1
|
||||
set Config(LANGUAGE) "English"
|
||||
set Config(INST_DIR) "/usr/local/bin"
|
||||
set Config(MAN_DIR) "/usr/local/man"
|
||||
set Config(MAN_DIR) "/usr/local/share/man"
|
||||
}
|
||||
|
||||
#***********************************************************************
|
||||
@@ -53,7 +55,7 @@ proc SetConfigDefaults {} {
|
||||
# Pops up an error dialog; then calls exit.
|
||||
#***********************************************************************
|
||||
proc Bail { msg } {
|
||||
tk_dialog .err "Remind Configuration Error" $msg error 0 "Bummer"
|
||||
tk_messageBox -message "Remind Build Error" -detail $msg -icon error -type ok
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -124,7 +126,7 @@ proc CreateMainDialog {} {
|
||||
# Creates the "installation directories" dialog.
|
||||
#***********************************************************************
|
||||
proc CreateInstallDirDialog { w } {
|
||||
global Config
|
||||
global Config RemindExecutable
|
||||
label $w.binlabel -text "Location for programs: "
|
||||
entry $w.bin -width 30
|
||||
$w.bin insert end $Config(INST_DIR)
|
||||
@@ -133,16 +135,19 @@ proc CreateInstallDirDialog { w } {
|
||||
entry $w.man -width 30
|
||||
$w.man insert end $Config(MAN_DIR)
|
||||
|
||||
text $w.blurb -width 1 -height 5 -wrap word -relief flat -takefocus 0
|
||||
$w.blurb insert end "\n(Tabbed-notebook Tcl code taken from \"Effective Tcl/Tk Programming\" by Mark Harrison and Michael McLennan, Addison-Wesley Professional Computing Series.)"
|
||||
$w.blurb configure -state disabled
|
||||
# Disable all text-window behaviour
|
||||
bindtags $w.blurb {NoSuchTag}
|
||||
text $w.blurb -width 1 -height 20 -wrap word -relief flat -takefocus 0
|
||||
if { "$RemindExecutable" != "" } {
|
||||
$w.blurb insert end "Note: Default settings were obtained by querying the existing installed version of Remind found at: $RemindExecutable\n"
|
||||
}
|
||||
$w.blurb insert end "\n(Tabbed-notebook Tcl code taken from \"Effective Tcl/Tk Programming\" by Mark Harrison and Michael McLennan, Addison-Wesley Professional Computing Series.)\n"
|
||||
grid $w.binlabel -row 0 -column 0 -sticky e
|
||||
grid $w.bin -row 0 -column 1 -sticky nsew
|
||||
grid $w.manlabel -row 1 -column 0 -sticky e
|
||||
grid $w.man -row 1 -column 1 -sticky nsew
|
||||
grid $w.blurb - -sticky nsew
|
||||
# Disable all text-window behaviour
|
||||
bindtags $w.blurb {NoSuchTag}
|
||||
$w.blurb configure -state disabled
|
||||
}
|
||||
|
||||
#***********************************************************************
|
||||
@@ -727,7 +732,7 @@ proc notebook_fix_size {win} {
|
||||
#***********************************************************************
|
||||
proc FindRemind {} {
|
||||
global env
|
||||
set path [concat [split $env(PATH) ":"] "/bin" "/usr/bin" "/usr/local/bin"]
|
||||
set path [concat [split $env(PATH) ":"] "/usr/local/bin" "/bin" "/usr/bin" ]
|
||||
foreach thing $path {
|
||||
if [file executable [file join $thing "remind"]] {
|
||||
return [file join $thing "remind"]
|
||||
@@ -745,16 +750,17 @@ proc FindRemind {} {
|
||||
# sensible defaults.
|
||||
#***********************************************************************
|
||||
proc SetConfigFromRemind {} {
|
||||
global Config
|
||||
global Config RemindExecutable
|
||||
SetConfigDefaults
|
||||
set rem [FindRemind]
|
||||
set RemindExecutable $rem
|
||||
if {"$rem" == ""} {
|
||||
return
|
||||
}
|
||||
set dir [file dirname $rem]
|
||||
set Config(INST_DIR) $dir
|
||||
if {"$dir" == "/usr/local/bin"} {
|
||||
set Config(MAN_DIR) "/usr/local/man"
|
||||
set Config(MAN_DIR) "/usr/local/share/man"
|
||||
} elseif {$dir == "/usr/bin"} {
|
||||
set Config(MAN_DIR) "/usr/share/man"
|
||||
}
|
||||
@@ -764,6 +770,8 @@ proc SetConfigFromRemind {} {
|
||||
set Config(MAN_DIR) "/usr/share/man"
|
||||
} elseif {[file readable "/usr/man/man1/remind.1"]} {
|
||||
set Config(MAN_DIR) "/usr/man"
|
||||
} elseif {[file readable "/usr/local/share/man/man1/remind.1"]} {
|
||||
set Config(MAN_DIR) "/usr/local/share/man"
|
||||
} elseif {[file readable "/usr/local/man/man1/remind.1"]} {
|
||||
set Config(MAN_DIR) "/usr/local/man"
|
||||
}
|
||||
|
||||
115
configure
vendored
115
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.71.
|
||||
# Generated by GNU Autoconf 2.71 for remind 05.00.01.
|
||||
#
|
||||
#
|
||||
# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
|
||||
@@ -606,12 +606,12 @@ MFLAGS=
|
||||
MAKEFLAGS=
|
||||
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME=''
|
||||
PACKAGE_TARNAME=''
|
||||
PACKAGE_VERSION=''
|
||||
PACKAGE_STRING=''
|
||||
PACKAGE_NAME='remind'
|
||||
PACKAGE_TARNAME='remind'
|
||||
PACKAGE_VERSION='05.00.01'
|
||||
PACKAGE_STRING='remind 05.00.01'
|
||||
PACKAGE_BUGREPORT=''
|
||||
PACKAGE_URL=''
|
||||
PACKAGE_URL='https://dianne.skoll.ca/projects/remind/'
|
||||
|
||||
ac_unique_file="src/queue.c"
|
||||
# Factoring default headers for most tests.
|
||||
@@ -757,7 +757,7 @@ localstatedir='${prefix}/var'
|
||||
runstatedir='${localstatedir}/run'
|
||||
includedir='${prefix}/include'
|
||||
oldincludedir='/usr/include'
|
||||
docdir='${datarootdir}/doc/${PACKAGE}'
|
||||
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
||||
infodir='${datarootdir}/info'
|
||||
htmldir='${docdir}'
|
||||
dvidir='${docdir}'
|
||||
@@ -1264,7 +1264,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures this package to adapt to many kinds of systems.
|
||||
\`configure' configures remind 05.00.01 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -1313,7 +1313,7 @@ Fine tuning of the installation directories:
|
||||
--infodir=DIR info documentation [DATAROOTDIR/info]
|
||||
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
|
||||
--mandir=DIR man documentation [DATAROOTDIR/man]
|
||||
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
|
||||
--docdir=DIR documentation root [DATAROOTDIR/doc/remind]
|
||||
--htmldir=DIR html documentation [DOCDIR]
|
||||
--dvidir=DIR dvi documentation [DOCDIR]
|
||||
--pdfdir=DIR pdf documentation [DOCDIR]
|
||||
@@ -1325,7 +1325,9 @@ _ACEOF
|
||||
fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of remind 05.00.01:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
Optional Features:
|
||||
@@ -1348,6 +1350,7 @@ Use these variables to override the choices made by `configure' or to help
|
||||
it to find libraries and programs with nonstandard names/locations.
|
||||
|
||||
Report bugs to the package provider.
|
||||
remind home page: <https://dianne.skoll.ca/projects/remind/>.
|
||||
_ACEOF
|
||||
ac_status=$?
|
||||
fi
|
||||
@@ -1411,7 +1414,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
configure
|
||||
remind configure 05.00.01
|
||||
generated by GNU Autoconf 2.71
|
||||
|
||||
Copyright (C) 2021 Free Software Foundation, Inc.
|
||||
@@ -1861,7 +1864,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by $as_me, which was
|
||||
It was created by remind $as_me 05.00.01, which was
|
||||
generated by GNU Autoconf 2.71. Invocation command line was
|
||||
|
||||
$ $0$ac_configure_args_raw
|
||||
@@ -2450,7 +2453,6 @@ as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"
|
||||
as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"
|
||||
as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"
|
||||
as_fn_append ac_header_c_list " sys/time.h sys_time_h HAVE_SYS_TIME_H"
|
||||
as_fn_append ac_header_c_list " utime.h utime_h HAVE_UTIME_H"
|
||||
|
||||
# Auxiliary files required by this configure script.
|
||||
ac_aux_files="install-sh"
|
||||
@@ -4004,6 +4006,12 @@ printf "%s\n" "#define SIZEOF_TIME_T $ac_cv_sizeof_time_t" >>confdefs.h
|
||||
|
||||
|
||||
|
||||
ac_fn_c_check_header_compile "$LINENO" "strings.h" "ac_cv_header_strings_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_strings_h" = xyes
|
||||
then :
|
||||
printf "%s\n" "#define HAVE_STRINGS_H 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
ac_fn_c_check_header_compile "$LINENO" "sys/types.h" "ac_cv_header_sys_types_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_sys_types_h" = xyes
|
||||
then :
|
||||
@@ -4080,60 +4088,6 @@ printf "%s\n" "#define TM_IN_SYS_TIME 1" >>confdefs.h
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether utime accepts a null argument" >&5
|
||||
printf %s "checking whether utime accepts a null argument... " >&6; }
|
||||
if test ${ac_cv_func_utime_null+y}
|
||||
then :
|
||||
printf %s "(cached) " >&6
|
||||
else $as_nop
|
||||
rm -f conftest.data; >conftest.data
|
||||
# Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
|
||||
if test "$cross_compiling" = yes
|
||||
then :
|
||||
ac_cv_func_utime_null='guessing yes'
|
||||
else $as_nop
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
$ac_includes_default
|
||||
#ifdef HAVE_UTIME_H
|
||||
# include <utime.h>
|
||||
#endif
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
struct stat s, t;
|
||||
return ! (stat ("conftest.data", &s) == 0
|
||||
&& utime ("conftest.data", 0) == 0
|
||||
&& stat ("conftest.data", &t) == 0
|
||||
&& t.st_mtime >= s.st_mtime
|
||||
&& t.st_mtime - s.st_mtime < 120);
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_run "$LINENO"
|
||||
then :
|
||||
ac_cv_func_utime_null=yes
|
||||
else $as_nop
|
||||
ac_cv_func_utime_null=no
|
||||
fi
|
||||
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
||||
conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
fi
|
||||
|
||||
fi
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_utime_null" >&5
|
||||
printf "%s\n" "$ac_cv_func_utime_null" >&6; }
|
||||
if test "x$ac_cv_func_utime_null" != xno; then
|
||||
ac_cv_func_utime_null=yes
|
||||
|
||||
printf "%s\n" "#define HAVE_UTIME_NULL 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
rm -f conftest.data
|
||||
|
||||
if test "$GCC" = yes; then
|
||||
CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes"
|
||||
# Check for link-time optimization support
|
||||
@@ -4181,6 +4135,24 @@ if test "$?" != 0 ; then
|
||||
echo "*** COULD NOT DETERMINE RELEASE DATE: docs/WHATSNEW is incorrect!"
|
||||
exit 1
|
||||
fi
|
||||
ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup"
|
||||
if test "x$ac_cv_func_strdup" = xyes
|
||||
then :
|
||||
printf "%s\n" "#define HAVE_STRDUP 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp"
|
||||
if test "x$ac_cv_func_strcasecmp" = xyes
|
||||
then :
|
||||
printf "%s\n" "#define HAVE_STRCASECMP 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
ac_fn_c_check_func "$LINENO" "strncasecmp" "ac_cv_func_strncasecmp"
|
||||
if test "x$ac_cv_func_strncasecmp" = xyes
|
||||
then :
|
||||
printf "%s\n" "#define HAVE_STRNCASECMP 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
ac_fn_c_check_func "$LINENO" "setenv" "ac_cv_func_setenv"
|
||||
if test "x$ac_cv_func_setenv" = xyes
|
||||
then :
|
||||
@@ -4225,7 +4197,7 @@ then :
|
||||
fi
|
||||
|
||||
|
||||
VERSION=04.03.00
|
||||
VERSION=$PACKAGE_VERSION
|
||||
|
||||
|
||||
|
||||
@@ -4731,7 +4703,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by $as_me, which was
|
||||
This file was extended by remind $as_me 05.00.01, which was
|
||||
generated by GNU Autoconf 2.71. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -4787,7 +4759,8 @@ $config_files
|
||||
Configuration headers:
|
||||
$config_headers
|
||||
|
||||
Report bugs to the package provider."
|
||||
Report bugs to the package provider.
|
||||
remind home page: <https://dianne.skoll.ca/projects/remind/>."
|
||||
|
||||
_ACEOF
|
||||
ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"`
|
||||
@@ -4795,7 +4768,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config='$ac_cs_config_escaped'
|
||||
ac_cs_version="\\
|
||||
config.status
|
||||
remind config.status 05.00.01
|
||||
configured by $0, generated by GNU Autoconf 2.71,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
||||
12
configure.in
12
configure.in
@@ -1,6 +1,6 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT
|
||||
AC_INIT(remind, 05.00.01, , , https://dianne.skoll.ca/projects/remind/)
|
||||
AC_CONFIG_SRCDIR([src/queue.c])
|
||||
|
||||
cat <<'EOF'
|
||||
@@ -30,7 +30,7 @@ AC_PATH_PROG([PERL], [perl])
|
||||
|
||||
dnl Checks for libraries.
|
||||
AC_CHECK_LIB(m, sqrt)
|
||||
AC_CHECK_HEADERS_ONCE([sys/time.h])
|
||||
AC_CHECK_HEADERS_ONCE([sys/time.h stdint.h])
|
||||
|
||||
dnl Integer sizes
|
||||
AC_CHECK_SIZEOF(unsigned int)
|
||||
@@ -38,13 +38,11 @@ AC_CHECK_SIZEOF(unsigned long)
|
||||
AC_CHECK_SIZEOF(time_t)
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_CHECK_HEADERS(sys/types.h glob.h wctype.h locale.h langinfo.h sys/inotify.h)
|
||||
AC_CHECK_HEADERS(strings.h sys/types.h glob.h wctype.h locale.h langinfo.h sys/inotify.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_STRUCT_TM
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_FUNC_UTIME_NULL
|
||||
if test "$GCC" = yes; then
|
||||
CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes"
|
||||
# Check for link-time optimization support
|
||||
@@ -86,9 +84,9 @@ if test "$?" != 0 ; then
|
||||
echo "*** COULD NOT DETERMINE RELEASE DATE: docs/WHATSNEW is incorrect!"
|
||||
exit 1
|
||||
fi
|
||||
AC_CHECK_FUNCS(setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1)
|
||||
AC_CHECK_FUNCS(strdup strcasecmp strncasecmp setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1)
|
||||
|
||||
VERSION=04.03.00
|
||||
VERSION=$PACKAGE_VERSION
|
||||
AC_SUBST(VERSION)
|
||||
AC_SUBST(PERL)
|
||||
AC_SUBST(PERLARTIFACTS)
|
||||
|
||||
@@ -95,7 +95,7 @@ Norman Walsh.
|
||||
#!/usr/local/bin/wish
|
||||
wm withdraw .
|
||||
after 15000 { destroy . ; exit }
|
||||
tk_dialog .d { Message } $argv warning 0 { OK }
|
||||
tk_messageBox -message Message -detail $argv -icon info -type ok
|
||||
destroy .
|
||||
exit
|
||||
-------------- Cut Here ---------- Cut Here ---------- Cut Here -------------
|
||||
|
||||
207
docs/WHATSNEW
207
docs/WHATSNEW
@@ -1,5 +1,212 @@
|
||||
CHANGES TO REMIND
|
||||
|
||||
* VERSION 5.0 Patch 1 - 2024-06-08
|
||||
|
||||
* MINOR IMPROVEMENT: Add short-circuit evaluation to the isany() function,
|
||||
which now only evaluates those arguments absolutely necessary to determine
|
||||
the result.
|
||||
|
||||
* BUG FIX: Mark weekno() as a non-constant function (the zero-argument form
|
||||
depends on external conditions.)
|
||||
|
||||
* BUG FIX: Fix a couple of memory leaks.
|
||||
|
||||
* BUG FIX: Don't rely on support for unnamed function parameters; this caused
|
||||
compilation failures with older versions of gcc.
|
||||
|
||||
* VERSION 5.0 Patch 0 - 2024-06-06
|
||||
|
||||
* MAJOR CHANGE: The expression evaluation engine has been completely replaced
|
||||
with a new one that splits parsing and evaluating into two separate steps.
|
||||
It also features short-circuit evaluation of &&, ||, iif() and choose().
|
||||
This should speed up expression-heavy reminder files.
|
||||
|
||||
NOTE INCOMPATIBILITY: In expressions with side-effects, the short-circuit
|
||||
evaluation might change the result you get. For example, consider
|
||||
running the following file through: remind file.rem 2024-06-04
|
||||
|
||||
SET a trig("Mon +7") || trig("Thu +7")
|
||||
MSG trig = [trig()]
|
||||
|
||||
Older Remind versions will output:
|
||||
|
||||
trig = 2024-06-06
|
||||
|
||||
whereas this version outputs:
|
||||
|
||||
trig = 2024-06-10
|
||||
|
||||
because the second part of the "||" expression is not evaluated. The vast
|
||||
majority of Remind expressions do not have side-effects and should yield
|
||||
the same results as before.
|
||||
|
||||
The newer expression engine also permits recursive functions, but
|
||||
these are not recommended. Still, if you want to, you can do:
|
||||
|
||||
fset factorial(n) iif(n <= 1, 1, n*factorial(n-1))
|
||||
|
||||
and it will work for values of n that don't cause integer overflow.
|
||||
|
||||
* IMPROVEMENT: If there's an unmatched PUSH-OMIT-CONTEXT, print the
|
||||
filename and line number containing it.
|
||||
|
||||
* IMPROVEMENT: If there's an IF with a missing ENDIF, print the filename
|
||||
and line number of the IF statement.
|
||||
|
||||
* NEW FEATURE: Add EXPR OFF command to completely disable expression
|
||||
evaluation. Useful if you INCLUDE files that you don't expect to
|
||||
contain expressions and may come from slightly untrustworthy sources.
|
||||
|
||||
* NEW FEATURE: Add $ExpressionTimeLimit system variable to enforce a
|
||||
maximum limit on how long evaluating an expression is allowed to take.
|
||||
|
||||
* NEW FEATURE: Add --max-execution-time=n command-line option to terminate
|
||||
Remind if it runs for more than n seconds.
|
||||
|
||||
* CHANGE: Make the command-line option "-ifoo" equivalent to "-ifoo=0"
|
||||
|
||||
* CHANGE: Permit a literal [ in a reminder by using the sequence [[
|
||||
The old ["["] still works.
|
||||
|
||||
* BUG FIX: In "purge" mode, Remind would sometimes purge reminders with
|
||||
a relative "SCANFROM" which haven't actually expired. This has been fixed.
|
||||
|
||||
* BUG FIX: Disallow something like: FSET func(x, x) expr
|
||||
which shouldn't have been allowed in the first place.
|
||||
|
||||
* BUG FIX: Replace leading spaces with tabs in Makefiles (per Emanuele Torre
|
||||
and Tim Chase)
|
||||
|
||||
* VERSION 4.3 Patch 7 - 2024-04-29
|
||||
|
||||
* IMPROVEMENT: build.tk: Add a note if build.tk obtains default settings
|
||||
from an existing Remind installation.
|
||||
|
||||
* IMPROVEMENT: configure: Pass all args to AC_INIT including the Remind
|
||||
home page. Remove some unused autoconf cruft.
|
||||
|
||||
* IMPROVEMENT: Use standard C library versions of strdup, strcasecmp and
|
||||
strncasecmp where available, rather than using our own versions.
|
||||
|
||||
* MINOR FEATURE: remind: Make $Tt a synonym for trigtime().
|
||||
|
||||
* BUG FIX: remind: Make sure shellescape() doesn't mangle UTF-8 characters
|
||||
with high-bits set.
|
||||
|
||||
* BUG FIX: remind: Don't rely on undefined behavior of "%" operator in
|
||||
the ord() built-in function.
|
||||
|
||||
* BUG FIX: remind: Do not clear out trigtime() unnecessarily. Before,
|
||||
you could not write things like the following; now you can:
|
||||
|
||||
REM Tue AT 11:30 DURATION 0:30 MSG Thing 1
|
||||
REM Tue AT [trigtime()+trigduration()] DURATION 1:00 MSG Thing 2
|
||||
REM Tue AT [trigtime()+trigduration()] DURATION 0:45 MSG Thing 3
|
||||
|
||||
for successive reminders that should be moved as a block if the time of
|
||||
the first one changes.
|
||||
|
||||
* BUG FIX: Don't update trigdate() or trigtime() while parsing a REM
|
||||
statement... only when actually computing the trigger.
|
||||
|
||||
* VERSION 4.3 Patch 6 - 2024-04-02
|
||||
|
||||
* NEW FILE: Add [$SysInclude]/holidays/pt.rem - Portuguese holidays, courtesy
|
||||
of Joop Kiefte.
|
||||
|
||||
* BUG FIX: remind: Fix compile error on systems that don't support inotify(7).
|
||||
|
||||
* BUG FIX: remind: Fix test failures on FreeBSD. On FreeBSD, you have to copy
|
||||
the result of getenv() or else a subsequent setenv() can change the stored
|
||||
value.
|
||||
|
||||
* VERSION 4.3 Patch 5 - 2024-04-01
|
||||
|
||||
* IMPROVEMENT: remind: Use inotify to detect reminder file changes
|
||||
even in regular daemon mode (-zn where n>0).
|
||||
|
||||
* INTERNAL IMPROVEMENTS: Rearrange and refactor some code.
|
||||
|
||||
* FIXES: Various fixes and improvements to man pages.
|
||||
|
||||
* BUG FIX: remind: Handle queued "SPECIAL COLOR" reminders correctly.
|
||||
|
||||
* BUG FIX: remind: Preserve the value of $DefaultColor that was in effect
|
||||
when a reminder was queued; restore it before issuing the queued reminder.
|
||||
|
||||
* VERSION 4.3 Patch 4 - 2024-03-25
|
||||
|
||||
* NEW FEATURE: remind: Add the new "multitrig" function, which is how "trig"
|
||||
should have worked in the first place. See man page for details.
|
||||
|
||||
* IMPROVEMENT: tkremind: Make errors in your reminders file stand out more
|
||||
prominently.
|
||||
|
||||
* IMPROVEMENT: tkremind: If you click on an error in the "Errors..." popup,
|
||||
tkremind will open a text editor on the offending file and line.
|
||||
|
||||
* IMPROVEMENT: tkremind: Format the "Queue..." output better and make queue
|
||||
items clickable; clicking on a queue item opens a text editor on the
|
||||
corresponding file and line.
|
||||
|
||||
* IMPROVEMENT: Add a standard [$SysInclude]/moonphases.rem file to display
|
||||
moon phases on your calendar.
|
||||
|
||||
* IMPROVEMENT: Clean up the demo code in www/ and add PDF output.
|
||||
|
||||
* BUG FIX: tkremind: Correctly handle filenames containing spaces and other
|
||||
characters that tend to confuse the shell.
|
||||
|
||||
* BUG FIX: tkremind: Raise dialog boxes after errors so that they
|
||||
remain visible.
|
||||
|
||||
* CLEANUP: tkremind: Remove some dead code.
|
||||
|
||||
* VERSION 4.3 Patch 3 - 2024-03-18
|
||||
|
||||
* IMPROVEMENT: tkremind: Update icon to include a white border so it shows
|
||||
up better on dark backgrounds.
|
||||
|
||||
* IMPROVEMENT: C code: Fix a number of cppcheck static-analysis warnings.
|
||||
|
||||
* IMPROVEMENT: remind: Update the "-zj" protocol to include a queue-id for
|
||||
each queued reminder and add the DEL client command to delete a specific
|
||||
item from the queue. Used by tkremind to implement "don't remind me about
|
||||
this again today."
|
||||
|
||||
* MINOR NEW FEATURE: Add a "-ds" debugging flag to print out expression-parsing
|
||||
stack high-water marks on exit. This esoteric feature is of no use to
|
||||
anyone but the Remind author.
|
||||
|
||||
* IMPROVEMENT: tkremind: Stop using the deprecated tk_dialog command in favor
|
||||
of the newer tk_messageBox command.
|
||||
|
||||
* IMPROVEMENT: remind: In server mode, try to minimize redraws by
|
||||
consuming inotify events until at least 0.2s elapses without an
|
||||
event appearing.
|
||||
|
||||
* BUG FIX: tkremind: The "Don't remind me about this again today" feature
|
||||
was unreliable and only worked for reminders created with TkRemind itself.
|
||||
It has been made more reliable and works with any reminder.
|
||||
|
||||
* BUG FIX: remind: Make it a syntax error if a local OMIT in a REM statement
|
||||
is not followed by at least one weekday name.
|
||||
|
||||
* VERSION 4.3 Patch 2 - 2024-03-01
|
||||
|
||||
- BUG FIX: remind: Fix a logic error when implementing the RUN command in
|
||||
server mode. As it turns out, the error is harmless, but it's best to do
|
||||
things correctly.
|
||||
|
||||
- BUG FIX: The Makefile would install the tkremind.png and tkremind.desktop
|
||||
files in the wrong location. This has been fixed.
|
||||
|
||||
* VERSION 4.3 Patch 1 - 2024-02-29
|
||||
|
||||
- BUG FIX: tests: "make test" could fail because of a bad test. This
|
||||
has been fixed. There are no actual code changes to any of the programs
|
||||
in Remind compared to 04.03.00.
|
||||
|
||||
* VERSION 4.3 Patch 0 - 2024-02-29
|
||||
|
||||
- IMPROVEMENT: remind: If Remind is compiled on a system that supports
|
||||
|
||||
@@ -106,7 +106,3 @@ IF !Reform
|
||||
[_PastSat(17, "Tamuz")] ++4 MSG %"Tzom Tammuz%" is %b.
|
||||
[_PastSat(9, "Av")] ++4 MSG %"Tish'a B'Av%" is %b.
|
||||
ENDIF
|
||||
|
||||
# Clean up
|
||||
FUNSET _h _h2 _PastSat _BackTwoFri _BackTwoSat _chan
|
||||
|
||||
|
||||
17
include/holidays/pt.rem
Normal file
17
include/holidays/pt.rem
Normal file
@@ -0,0 +1,17 @@
|
||||
# Portuguese holidays
|
||||
# Courtesy of Joop Kiefte
|
||||
|
||||
OMIT 1 Jan MSG Ano Novo
|
||||
OMIT [easterdate()-47] MSG Carnaval
|
||||
OMIT [easterdate()-2] MSG Sexta-feira Santa
|
||||
OMIT [easterdate()] MSG Domingo de Páscoa
|
||||
OMIT 25 Apr MSG Dia da Liberdade
|
||||
OMIT 1 May MSG Dia do Trabalhador
|
||||
OMIT [easterdate()+60] MSG Corpo de Deus
|
||||
OMIT 10 Jun MSG Dia de Portugal, de Camões e das Comunidades Portuguesas
|
||||
OMIT 15 Aug MSG Assunção de Nossa Senhora
|
||||
OMIT 5 Oct MSG Implantação da República
|
||||
OMIT 1 Nov MSG Dia de Todos os Santos
|
||||
OMIT 1 Dec MSG Restauração da Independência
|
||||
OMIT 8 Dec MSG Imaculada Conceição
|
||||
OMIT 25 Dec MSG Natal
|
||||
@@ -1,24 +1,28 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
SET autolang getenv("REMIND_LANG")
|
||||
if !defined("__autolang__")
|
||||
SET __autolang__ 1
|
||||
PRESERVE __autolang__
|
||||
SET autolang getenv("REMIND_LANG")
|
||||
|
||||
IF autolang == ""
|
||||
SET autolang getenv("LC_ALL")
|
||||
ENDIF
|
||||
IF autolang == ""
|
||||
SET autolang getenv("LANGUAGE")
|
||||
ENDIF
|
||||
IF autolang == ""
|
||||
SET autolang getenv("LANG")
|
||||
ENDIF
|
||||
IF autolang == ""
|
||||
SET autolang getenv("LC_ALL")
|
||||
ENDIF
|
||||
IF autolang == ""
|
||||
SET autolang getenv("LANGUAGE")
|
||||
ENDIF
|
||||
IF autolang == ""
|
||||
SET autolang getenv("LANG")
|
||||
ENDIF
|
||||
|
||||
IF autolang != ""
|
||||
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 5)) + ".rem", "r") == 0
|
||||
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 5))].rem
|
||||
ELSE
|
||||
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 2)) + ".rem", "r") == 0
|
||||
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 2))].rem
|
||||
IF autolang != ""
|
||||
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 5)) + ".rem", "r") == 0
|
||||
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 5))].rem
|
||||
ELSE
|
||||
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 2)) + ".rem", "r") == 0
|
||||
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 2))].rem
|
||||
ENDIF
|
||||
ENDIF
|
||||
ENDIF
|
||||
UNSET autolang
|
||||
ENDIF
|
||||
|
||||
UNSET autolang
|
||||
|
||||
@@ -87,3 +87,5 @@ SET daylightST_starts_str "Beginn Sommerzeit"
|
||||
|
||||
# Daylight saving time ends
|
||||
SET daylightST_ends_str "Ende Sommerzeit"
|
||||
|
||||
PRESERVE earthseasons_Perihelion_str earthseasons_EquinoxMar_str earthseasons_SolsticeJun_str earthseasons_Aphelion_str earthseasons_EquinoxSep_str earthseasons_SolsticeDec_str daylightST_starts_str daylightST_ends_str
|
||||
@@ -81,3 +81,5 @@ SET daylightST_starts_str "Έναρξη θέρους"
|
||||
|
||||
# Daylight saving time ends
|
||||
SET daylightST_ends_str "Τέλος θέρους"
|
||||
|
||||
PRESERVE earthseasons_Perihelion_str earthseasons_EquinoxMar_str earthseasons_SolsticeJun_str earthseasons_Aphelion_str earthseasons_EquinoxSep_str earthseasons_SolsticeDec_str daylightST_starts_str daylightST_ends_str
|
||||
|
||||
14
include/moonphases.rem
Normal file
14
include/moonphases.rem
Normal file
@@ -0,0 +1,14 @@
|
||||
# Moon phases
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
IF $CalMode || $PsCal
|
||||
REM [moondate(0)] SPECIAL MOON 0 -1 -1 [moontime(0)]
|
||||
REM [moondate(1)] SPECIAL MOON 1 -1 -1 [moontime(1)]
|
||||
REM [moondate(2)] SPECIAL MOON 2 -1 -1 [moontime(2)]
|
||||
REM [moondate(3)] SPECIAL MOON 3 -1 -1 [moontime(3)]
|
||||
ELSE
|
||||
REM NOQUEUE [moondatetime(0)] MSG New Moon (%2)
|
||||
REM NOQUEUE [moondatetime(1)] MSG First Quarter (%2)
|
||||
REM NOQUEUE [moondatetime(2)] MSG Full Moon (%2)
|
||||
REM NOQUEUE [moondatetime(3)] MSG Last Quarter (%2)
|
||||
ENDIF
|
||||
294
man/remind.1.in
294
man/remind.1.in
@@ -28,10 +28,6 @@ Anything after the __EOF__ marker is completely ignored.
|
||||
\fBRemind\fR has a slew of options. If you're new to the program,
|
||||
ignore them for now and skip to the section "REMINDER FILES".
|
||||
.TP
|
||||
.B \-\-version
|
||||
The \fB\-\-version\fR option causes \fBRemind\fR to print its version number
|
||||
to standard output and then exit.
|
||||
.TP
|
||||
.B \-n
|
||||
The \fB\-n\fR option causes \fBRemind\fR to print the \fBnext\fR occurrence
|
||||
of each reminder in a simple calendar format. You can sort this by
|
||||
@@ -66,7 +62,7 @@ causes \fBRemind\fR to display reminders on the calendar on the
|
||||
day they actually occur \fIas well as\fR on any preceding days
|
||||
specified by the reminder's \fIdelta\fR. This \fIalso\fR causes
|
||||
\fBRemind\fR to include text outside %"...%" sequences that would
|
||||
otherwise be removed (though the actual %" markers themselves are removed.)
|
||||
otherwise be removed (though the actual %" markers themselves are removed.) \"" Add comment to avoid Emacs highlighting problems
|
||||
.TP
|
||||
.B 'l'
|
||||
causes \fBRemind\fR to use VT100 line-drawing characters to draw
|
||||
@@ -300,6 +296,11 @@ Echo lines when displaying error messages
|
||||
.TP
|
||||
.B f
|
||||
Trace the reading of reminder files
|
||||
.TP
|
||||
.B s
|
||||
Trace expression parsing and display the internal expression node
|
||||
tree. This is unlikely to be useful unless you are working on
|
||||
\fBRemind\fR's expression evaluation engine.
|
||||
.RE
|
||||
.TP
|
||||
\fB\-g\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR]]]]
|
||||
@@ -361,13 +362,18 @@ You use both \fB\-k\fR\fIcmd1\fR and \fB\-k:\fR\fIcmd2\fR to use different
|
||||
commands for queued versus non-queued reminders.
|
||||
.RE
|
||||
.TP
|
||||
\fB\-z\fR[\fIn\fR] Runs \fBRemind\fR in the daemon mode. If \fIn\fR
|
||||
\fB\-z\fR[\fIn\fR] Runs \fBRemind\fR in "daemon mode". If \fIn\fR
|
||||
is supplied, it specifies how often (in minutes) \fBRemind\fR should
|
||||
wake up to check if the reminder script has been changed. \fIN\fR
|
||||
defaults to 1, and can range from 1 to 60. Note that the use of the
|
||||
\fB\-z\fR option also enables the \fB\-f\fR option.
|
||||
.PP
|
||||
.RS
|
||||
If \fBRemind\fR is compiled on a system that supports
|
||||
\fBinotify\fR(7), then if the reminder script supplied on the
|
||||
command-line is actually a directory, \fBRemind\fR additionally checks
|
||||
if all files within that directory have been modified since startup.
|
||||
.PP
|
||||
If you supply the option \fB\-zj\fR, \fBRemind\fR runs in a
|
||||
special mode called \fBserver mode\fR. This is documented
|
||||
in the tkremind man page; see tkremind(1). The older server mode
|
||||
@@ -410,7 +416,9 @@ TAG clause.
|
||||
\fB\-i\fR\fIvar\fR\fB=\fR\fIexpr\fR
|
||||
Sets the value of the specified \fIvar\fR to \fIexpr\fR, and \fBpreserves\fR
|
||||
\fIvar\fR. \fIExpr\fR can be any valid \fBRemind\fR expression. See the
|
||||
section "INITIALIZING VARIABLES ON THE COMMAND LINE" for more details.
|
||||
section "INITIALIZING VARIABLES ON THE COMMAND LINE" for more details. If
|
||||
you omit the \fB=\fR\fIexpr\fR part, then \fIvar\fR is initialized to 0.
|
||||
In other words, \fB\-i\fIvar\fR is exactly the same as \fB\-i\fIvar\fR\fB=\fR0.
|
||||
.TP
|
||||
\fB\-i\fR\fIfunc\fR(\fIargs\fR)=\fIdefinition\fR
|
||||
Allows you to define a function on the command line.
|
||||
@@ -441,6 +449,30 @@ with the date incrementing on each iteration. You may have to enclose
|
||||
the parameter in quotes to avoid shell expansion. See the subsection
|
||||
"Repeated Execution" in the section "CALENDAR MODE" for more
|
||||
information.
|
||||
|
||||
.SH LONG OPTIONS
|
||||
|
||||
\fBRemind\fR supports the following long options, which \fIare\fR
|
||||
case-sensitive:
|
||||
|
||||
.RP
|
||||
.B \-\-version
|
||||
The \fB\-\-version\fR option causes \fBRemind\fR to print its version number
|
||||
to standard output and then exit.
|
||||
.TP
|
||||
.B \-\-max-execution-time\fR=\fIn\fR
|
||||
Limit the total execution time (as measured by the wall clock) to
|
||||
\fIn\fR seconds. This is useful if \fBRemind\fR is invoked on
|
||||
potentially-untrustworthy files that could attempt to use a lot of
|
||||
resources. Note that the limit \fIn\fR is approximate and
|
||||
\fBRemind\fR might execute for one or two more seconds before it is
|
||||
killed. If \fIn\fR is specified as zero, then no limit is applied, just
|
||||
as if the option had not been used at all.
|
||||
.PP
|
||||
If a limit is applied, it applies only to the foreground run of \fBRemind\fR.
|
||||
If \fBRemind\fR finishes processing the script and then starts handling
|
||||
queued reminders, the time limit is reset to no limit.
|
||||
.PP
|
||||
.SH REMINDER FILES
|
||||
.PP
|
||||
\fBRemind\fR uses scripts to control its operation. You can use any
|
||||
@@ -449,14 +481,14 @@ text editor capable of creating plain-text files to create a
|
||||
very simple and almost immediately understandable:
|
||||
.PP
|
||||
.nf
|
||||
REM 6 Jan MSG Dianne's birthday
|
||||
REM Mar 31 MSG International Transgender Day of Visibility
|
||||
.fi
|
||||
.PP
|
||||
to the baroque and obscure:
|
||||
.PP
|
||||
.nf
|
||||
REM [date(thisyear, 1, 1) + 180] ++5 OMIT \\
|
||||
sat sun BEFORE MSG [ord(thisyear-1980)] payment due %b!
|
||||
REM [date(thisyear, 1, 1) + 180] ++5 OMIT \\
|
||||
sat sun BEFORE MSG [ord(thisyear-1980)] payment due %b!
|
||||
.fi
|
||||
.PP
|
||||
A reminder file consists of commands, with one command per line. Several
|
||||
@@ -1870,24 +1902,6 @@ If you run \fBRemind\fR with the \fB\-r\fR command-line option,
|
||||
regardless of any \fBRUN\fR commands in the reminder script. However,
|
||||
any command supplied with the \fB\-k\fR option will still be executed.
|
||||
.PP
|
||||
One use of the \fBRUN\fR command is to provide a secure interface
|
||||
between \fBRemind\fR and the \fBElm\fR mail system. The \fBElm\fR
|
||||
system can automatically scan incoming mail for reminder or calendar
|
||||
entries, and place them in your calendar file. To use this feature,
|
||||
you should set the calendar filename option under \fBElm\fR to be something
|
||||
like "~/.reminders.in", \fInot\fR your main reminder file! This is
|
||||
so that any \fBRUN ON\fR commands mailed to you can never be activated.
|
||||
.PP
|
||||
Then, you can use the \fBElm\fR \fIscan message for calendar entries\fR
|
||||
command to place reminders prefaced by "->" into .reminders.in. In
|
||||
your main .reminders file, include the following lines:
|
||||
.PP
|
||||
.nf
|
||||
RUN OFF # Disable RUN
|
||||
INCLUDE .reminders.in
|
||||
RUN ON # Re-enable RUN
|
||||
.fi
|
||||
.PP
|
||||
In addition, \fBRemind\fR contains a few other security
|
||||
features. It will not read a file that is group- or world-writable.
|
||||
It will not run set-uid. If it reads a file you don't own, it will
|
||||
@@ -1899,6 +1913,30 @@ attempt to check the ownership of standard input, even if it is
|
||||
coming from a file, and hence does \fInot\fR disable RUN and shell()
|
||||
in this situation.
|
||||
|
||||
.PP
|
||||
.SH THE EXPR COMMAND
|
||||
.PP
|
||||
\fBRemind\fR lets you completely disable expression evaluation. This
|
||||
could be useful if you are running Remind on a somewhat-untrustworthy
|
||||
file that is not expected to contain expressions. To disable
|
||||
expression evaluation, use:
|
||||
.PP
|
||||
.nf
|
||||
EXPR OFF
|
||||
.fi
|
||||
.PP
|
||||
If \fBRemind\fR encounters an expression while EXPR OFF is in effect, it
|
||||
returns an error
|
||||
.PP
|
||||
To re-enable expression evaluation, use:
|
||||
.PP
|
||||
.nf
|
||||
EXPR ON
|
||||
.fi
|
||||
.PP
|
||||
As with \fBRUN ON\fB, \fBEXPR ON\fR can be used only in the top-level
|
||||
script, not in an included file.
|
||||
.PP
|
||||
.SH THE INCLUDECMD COMMAND
|
||||
.PP
|
||||
\fBRemind\fR allows you to execute a shell command and evaluate the
|
||||
@@ -2151,13 +2189,13 @@ than those on higher lines. The operators approximately correspond to
|
||||
C operators.
|
||||
.PP
|
||||
.nf
|
||||
! - (unary logical negation and arithmetic negation)
|
||||
* / %
|
||||
+ -
|
||||
< <= > >=
|
||||
== !=
|
||||
&&
|
||||
||
|
||||
! - (unary logical negation and arithmetic negation)
|
||||
* / % (multiplication, division, modulus)
|
||||
+ - (addition/concatenation, subtraction)
|
||||
< <= > >= (comparisons)
|
||||
== != (equality and inequality tests)
|
||||
&& (logical AND)
|
||||
|| (logical OR)
|
||||
.fi
|
||||
.PP
|
||||
.B DESCRIPTION OF OPERATORS
|
||||
@@ -2269,16 +2307,15 @@ If the operands are not of the same type, == returns 0 and != returns
|
||||
.RE
|
||||
.TP
|
||||
.B &&
|
||||
This is the logical AND operator. Both of its operands must be of the
|
||||
same type and must not be \fBSTRING\fR type. Returns the second
|
||||
operand if both operands are non-zero. Otherwise, returns a zero
|
||||
of the same type as the operands.
|
||||
This is the logical AND operator. Neither of its operands can be
|
||||
\fBSTRING\fR type. Returns the second operand if both operands are
|
||||
non-zero. Otherwise, returns whichever operand is zero.
|
||||
.TP
|
||||
.B ||
|
||||
This is the logical OR operator. Both of its operands must be of
|
||||
the same type and must not be of \fBSTRING\fR type. It returns
|
||||
the first operand that is non-zero; if both operands are zero, then
|
||||
returns a zero of the same type as the operands.
|
||||
This is the logical OR operator. Neither of its operands can be
|
||||
\fBSTRING\fR type. It returns the first operand that is non-zero; if
|
||||
both operands are zero, then returns the second operand.
|
||||
|
||||
.PP
|
||||
.B NOTES
|
||||
.PP
|
||||
@@ -2299,15 +2336,10 @@ For example:
|
||||
12:59 + (1 + "test") yields "12:591test"
|
||||
.fi
|
||||
.PP
|
||||
The logical operators are \fInot\fR so-called short-circuit operators, as
|
||||
they are in C. Both operands are always evaluated. Thus, an expression
|
||||
such as:
|
||||
.PP
|
||||
.nf
|
||||
(f!=0) && (100/f <= 3)
|
||||
.fi
|
||||
.PP
|
||||
will cause an error if f is zero.
|
||||
The logical operators are so-called short-circuit operators, as
|
||||
they are in C. This means that if the first operand of || is true,
|
||||
then the second operand is \fInot\fR evaluated. Similarly, if the first
|
||||
operand of && is false, then the second operand is \fInot\fR evaluated.
|
||||
.PP
|
||||
.B VARIABLES
|
||||
.PP
|
||||
@@ -2389,9 +2421,9 @@ Universal Time Coordinated in the \fB$MinsFromUTC\fR system variable.
|
||||
If non-zero, then the \fB\-c\fR option was supplied on the command line.
|
||||
.TP
|
||||
.B $Daemon (read-only)
|
||||
If the daemon mode \fB\-z\fR was invoked, contains the number of
|
||||
If "daemon mode" \fB\-z\fR was invoked, contains the number of
|
||||
minutes between wakeups. If not running in daemon mode, contains
|
||||
0.
|
||||
0. In server mode (either \fB-z0\fR or \fB-zj\fR), contains -1.
|
||||
.TP
|
||||
.B $DateSep
|
||||
This variable can be set only to "/" or "-". It holds the character
|
||||
@@ -2464,6 +2496,14 @@ because the final parenthesis and quote are ignored (for the purposes
|
||||
of spacing) when they follow a period.
|
||||
.RE
|
||||
.TP
|
||||
.B $ExpressionTimeLimit
|
||||
If set to a non-zero value \fIn\fR, than any expression that takes longer than
|
||||
\fIn\fR seconds to evaluate will be aborted and an error returned. This is
|
||||
to prevent maliciously-crafted expressions for creating a denial-of-service.
|
||||
In an included file, $ExpressionTimeLimit can only be lowered from its
|
||||
current value. In the top-level file, it can be set to any value, including
|
||||
zero to disable the time limit.
|
||||
.TP
|
||||
.B $FirstIndent
|
||||
The number of spaces by which to indent the first line of a \fBMSF\fR-type
|
||||
reminder. The default is 0.
|
||||
@@ -2737,6 +2777,9 @@ Equivalent to \fBwkdaynum(trigdate())\fR.
|
||||
.B $Ty (read-only)
|
||||
Equivalent to \fByear(trigdate())\fR.
|
||||
.TP
|
||||
.B $Tt (read-only, TIME type)
|
||||
Equivalent to \fBtrigtime()\fR.
|
||||
.TP
|
||||
.B $TimeSep
|
||||
This variable can be set only to ":" or ".". It holds the character
|
||||
used to separate portions of a time when \fBRemind\fR prints a TIME or
|
||||
@@ -3350,6 +3393,62 @@ which default to \fBtoday()\fR and midnight, respectively. The returned
|
||||
value is an integer from 0 to 359, representing the phase of the moon
|
||||
in degrees. 0 is a new moon, 180 is a full moon, 90 is first-quarter, etc.
|
||||
.TP
|
||||
.B multitrig(s_trig1 [,s_trig2, [... s_trigN]])
|
||||
\fBmultitrig\fR evaluates each string as a trigger, similar to \fBevaltrig\fR,
|
||||
and returns the \fIearliest\fR trigger date that is on or after \fBtoday()\fR.
|
||||
\fBmultitrig\fR is similar to \fBtrig\fR but has the following difference:
|
||||
.RS
|
||||
.PP
|
||||
\fBtrig\fR returns the \fIfirst\fR trigger date that would have triggered today,
|
||||
whereas \fBmultitrig\fR returns the \fIearliest\fR trigger date later than
|
||||
today, regardless of whether it would have triggered today.
|
||||
.PP
|
||||
If no trigger can be computed that is later than \fBtoday()\fR, then
|
||||
\fBmultitrig\fR returns 1990-01-01.
|
||||
.PP
|
||||
Consider the following examples, assuming that today is Sunday, 24 March 2024:
|
||||
.PP
|
||||
.nf
|
||||
# Returns 1990-01-01 because neither would trigger today
|
||||
SET a trig("Mon", "Wed")
|
||||
|
||||
# Returns 2024-03-25 because it's the earlier trigger date
|
||||
SET a multitrig("Mon", "Wed")
|
||||
|
||||
# Returns 2024-03-27 because it's the first that would trigger today
|
||||
SET a trig("Wed +3", "Mon +3")
|
||||
|
||||
# Returns 2024-03-25 because it's the earlier trigger date
|
||||
SET a multitrig("Wed +3", "Mon +3")
|
||||
|
||||
# Returns 1990-01-01 because all triggers have expired
|
||||
SET a multitrig("2000", "2022", "1998", "2023")
|
||||
.fi
|
||||
.PP
|
||||
In general, \fBmultitrig\fR works better with the Remind algorithm than
|
||||
\fBtrig\fR and should be used most of the time. As an example, this
|
||||
reminder is issued at the end of each quarter:
|
||||
.PP
|
||||
.nf
|
||||
REM [multitrig("Mar 31", "Jun 30", "Sep 30", "Dec 31")] +7 MSG \\
|
||||
%"End of [ord($Tm/3)] quarter%" is %b.
|
||||
.fi
|
||||
.PP
|
||||
If you want the last working day of each quarter, you could use:
|
||||
.PP
|
||||
.nf
|
||||
PUSH-OMIT-CONTEXT
|
||||
OMIT Sat Sun
|
||||
REM [multitrig("Mar ~1", "Jun ~1", "Sep ~1", "Dec ~1")] +7 MSG \\
|
||||
%"Last working day of [ord($Tm/3)] quarter%" is %b.
|
||||
POP-OMIT-CONTEXT
|
||||
.fi
|
||||
.PP
|
||||
Note that unlike \fBevaltrig\fR, \fBmultitrig\fR always returns a \fBDATE\fR
|
||||
and never a \fBDATETIME\fR. Including an \fBAT\fR clause in a trigger
|
||||
supplied to \fBmultitrig\fR will result in an error.
|
||||
.RE
|
||||
.TP
|
||||
.B ndawn([dq_date])
|
||||
Returns the time of "nautical dawn" on the specified \fIdate\fR. If
|
||||
\fIdate\fR is omitted, defaults to \fBtoday()\fR. If a \fIdatetime\fR object
|
||||
@@ -3769,7 +3868,7 @@ function for advance warning to work properly. This is because
|
||||
\fBtrig\fR returns a date constant (the trigger date) and the
|
||||
REM command does not know the details of \fBtrig\fR's arguments.
|
||||
.PP
|
||||
Note that because \fBRemind\fR does not have short-circuit logical
|
||||
Note that because \fBRemind\fR has short-circuit logical
|
||||
operators, something like:
|
||||
.PP
|
||||
.nf
|
||||
@@ -3777,58 +3876,9 @@ operators, something like:
|
||||
.fi
|
||||
|
||||
would set the value of trig() to the date of the following
|
||||
Thursday. Even though trig("Mon +7") always returns true,
|
||||
the logical-OR operator still evaluates trig("Fri +7") which
|
||||
\fIalso\fR returns true and sets \fBtrig()\fR.
|
||||
.PP
|
||||
You can work around the lack of a short-circuit logical-OR as follows:
|
||||
If \fBtrig\fR returns a true value, the specific value it returns
|
||||
can be coerced to a DATE which is the trigger date. So the following code:
|
||||
.PP
|
||||
.nf
|
||||
SET a trig("Mon +4") || trig("Fri +4")
|
||||
IF a
|
||||
REM [a] +4 MSG [wkday($T)] %b.
|
||||
ENDIF
|
||||
.fi
|
||||
.PP
|
||||
would operate as follows:
|
||||
.PP
|
||||
.nf
|
||||
On Monday: Monday today.
|
||||
On Tuesday: Friday in 3 days' time.
|
||||
On Wednesday: Friday in 2 days' time.
|
||||
On Thursday: Monday in 4 days' time.
|
||||
On Friday: Monday in 3 days' time.
|
||||
On Saturday: Monday in 2 days' time.
|
||||
On Sunday: Monday tomorrow.
|
||||
.fi
|
||||
.PP
|
||||
Compare with the following:
|
||||
.PP
|
||||
.nf
|
||||
SET a trig("Mon +4") || trig("Fri +4")
|
||||
IF a
|
||||
REM [trig()] +4 MSG [wkday($T)] %b.
|
||||
ENDIF
|
||||
.fi
|
||||
.PP
|
||||
which yields:
|
||||
.PP
|
||||
.nf
|
||||
On Monday: Friday in 4 days' time.
|
||||
On Tuesday: Friday in 3 days' time.
|
||||
On Wednesday: Friday in 2 days' time.
|
||||
On Thursday: Friday tomorrow.
|
||||
On Friday: Friday today.
|
||||
On Saturday: Monday in 2 days' time.
|
||||
On Sunday: Monday tomorrow.
|
||||
.fi
|
||||
.PP
|
||||
That is because \fBtrig()\fR returns the trigger date of
|
||||
the \fIlast\fR trig function that returns true,
|
||||
whereas the value of \fBa\fR is the trigger date of the \fIfirst\fR
|
||||
trig function that returns true.
|
||||
Monday. Because trig("Mon +7") always returns true,
|
||||
the logical-OR operator does not bother evaluating trig("Fri +7") which
|
||||
therefore does not set \fBtrig()\fR.
|
||||
.PP
|
||||
\fBImportant Note\fR: Because \fBtrig()\fR always returns an absolute
|
||||
date, it will \fBnot\fR work properly with a \fBSATISFY\fR clause.
|
||||
@@ -4168,6 +4218,14 @@ with square brackets. For example:
|
||||
This evaluates the expression "mydate", where "mydate" is
|
||||
presumably some pre-computed variable, and then "pastes" the result
|
||||
into the command-line for the parser to process.
|
||||
.PP
|
||||
If you want a literal "[" character for some reason, simply use "[[". For
|
||||
example:
|
||||
.PP
|
||||
.nf
|
||||
REM MSG Here are [[square] brackets!
|
||||
.fi
|
||||
|
||||
.PP
|
||||
A formal description of this is: When \fBRemind\fR encounters a
|
||||
"pasted-in" expression, it evaluates the expression, and coerces the
|
||||
@@ -4715,7 +4773,7 @@ under program control. The format is:
|
||||
.PP
|
||||
\fBDEBUG\fR [+\fIflagson\fR] [\-\fIflagsoff\fR]
|
||||
.PP
|
||||
\fIFlagson\fR and \fIflagsoff\fR consist of strings of the characters "extvlf"
|
||||
\fIFlagson\fR and \fIflagsoff\fR consist of strings of the characters "extvlfs"
|
||||
that correspond to the debugging options discussed in the command-line
|
||||
options section. If preceded with a "+", the corresponding group of
|
||||
debugging options is switched on. Otherwise, they are switched off.
|
||||
@@ -5019,21 +5077,25 @@ structuring comments in your PostScript code.
|
||||
.PP
|
||||
.SH DAEMON MODE
|
||||
.PP
|
||||
If you use the \fB\-z\fR command-line option, \fBRemind\fR runs in the
|
||||
"daemon" mode. In this mode, no "normal" reminders are issued.
|
||||
If you use the \fB\-z\fR command-line option, \fBRemind\fR runs in
|
||||
"daemon mode". In this mode, no "normal" reminders are issued.
|
||||
Instead, only timed reminders are collected and queued, and are then
|
||||
issued whenever they reach their trigger time.
|
||||
.PP
|
||||
In addition, \fBRemind\fR wakes up every few minutes to check the modification
|
||||
date on the reminder script (the filename supplied on the command line.)
|
||||
If \fBRemind\fR detects that the script has changed, it re-executes itself
|
||||
in daemon mode, and interprets the changed script.
|
||||
In addition, \fBRemind\fR wakes up every few minutes to check the
|
||||
modification date on the reminder script (the filename supplied on the
|
||||
command line.) If \fBRemind\fR detects that the script has changed,
|
||||
it re-executes itself in daemon mode, and interprets the changed
|
||||
script. If \fBRemind\fR was compiled with support for
|
||||
\fBinotify\fR(7), then if the command-line reminder script is really a
|
||||
directory, \fBRemind\fR also re-executes itself if any of the files in
|
||||
the directory is changed.
|
||||
.PP
|
||||
In daemon mode, \fBRemind\fR also re-reads the remind script when it
|
||||
detects that the system date has changed.
|
||||
.PP
|
||||
In daemon mode, \fBRemind\fR acts as if the \fB\-f\fR option had been used,
|
||||
so to run in the daemon mode in the background, use:
|
||||
so to run in daemon mode in the background, use:
|
||||
.PP
|
||||
.nf
|
||||
remind \-z .reminders &
|
||||
@@ -5363,7 +5425,7 @@ as:
|
||||
.PP
|
||||
You can define your own substitution sequences in addition to the built-in
|
||||
ones as follows: If you define a function named \fBsubst_\fIname\fB(alt, date, time)\fR, then the sequence \fB%{name}\fR calls the function with \fBalt\fR
|
||||
set to 0 and \fBdate\fR and \fRtime\fR to the trigger date and time,
|
||||
set to 0 and \fBdate\fR and \fBtime\fR to the trigger date and time,
|
||||
respectively. The \fB%{name}\fR sequence is replaced with whatever the
|
||||
function returns. The sequence \fB%*{name}\fR is similar, but calls
|
||||
the function with \fBalt\fR set to 1.
|
||||
|
||||
@@ -184,7 +184,9 @@ on the reminder.
|
||||
If there are any errors in your reminder file, the "Queue..." button
|
||||
changes to "Errors...". Click on "Errors..." to see the Remind error
|
||||
output. Click "OK" to close the error window; this makes the button
|
||||
in the main TkRemind window to revert to "Queue..."
|
||||
in the main TkRemind window to revert to "Queue..." You can click on
|
||||
any error message to open an editor on the file and line number that
|
||||
caused the error.
|
||||
|
||||
.SH BACKGROUND REMINDERS
|
||||
|
||||
@@ -403,6 +405,10 @@ like this:
|
||||
The value of the \fBqueue\fR key is an array of JSON objects, each
|
||||
representing a queued reminder.
|
||||
|
||||
.TP
|
||||
DEL \fIqid\fR
|
||||
Delete the reminder with queue-id \fIqid\fR from the queue.
|
||||
|
||||
.TP
|
||||
REREAD
|
||||
Re-read the reminder file. Returns the following status line:
|
||||
@@ -419,15 +425,19 @@ Additional status lines written are as follows:
|
||||
.TP
|
||||
.nf
|
||||
|
||||
{"response":"reminder","ttime":tt,"now":now,"tags":tags,"body":body}
|
||||
{"response":"reminder","ttime":tt,"now":now,"tags":tags,"qid":qid,"body":body}
|
||||
|
||||
.fi
|
||||
In this line, \fItt\fR is the trigger time of the reminder (expressed
|
||||
as a string), \fInow\fR is the current time, \fItags\fR (if present)
|
||||
is the tag or tags associated with the reminder, and \fIbody\fR is
|
||||
the body of the reminder. This response causes \fBTkRemind\fR to
|
||||
pop up a reminder notification.
|
||||
|
||||
is the tag or tags associated with the reminder, and \fIbody\fR is the
|
||||
body of the reminder. This response causes \fBTkRemind\fR to pop up a
|
||||
reminder notification. \fIqid\fR is a unique identifier for this
|
||||
reminder. You may delete it from the queue by sending a \fBDEL\fR
|
||||
\fIqid\fR command to the server. Note that \fIqid\fRs are not stable
|
||||
across re-reads; if \fBRemind\fR restarts itself to re-read the reminder
|
||||
file, then the \fIqid\fR values are likely to change, and any reminder
|
||||
deleted with a \fBDEL\fR \fIqid\fR command is likely to be re-queued.
|
||||
.TP
|
||||
.nf
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ install:
|
||||
@if test "$(PERL)" = "" ; then \
|
||||
echo "Not installing rem2html; Perl is required"; exit 0; fi; \
|
||||
for m in $(PERLMODS_NEEDED) ; \
|
||||
do \
|
||||
do \
|
||||
$(PERL) -M$$m -e 1 > /dev/null 2>&1; \
|
||||
if test $$? != 0 ; then echo "Not installing rem2html; missing $$m"; exit 0; fi; \
|
||||
done; \
|
||||
|
||||
@@ -486,7 +486,7 @@ output for the invalid reminder.
|
||||
=head1 ABSOLUTELY-POSITIONED TEXT
|
||||
|
||||
If your B<PANGO> special reminder starts with C<@I<x>,I<y>> where I<x>
|
||||
and I<y> are floating-point numbers, then the Pango marked-up test is
|
||||
and I<y> are floating-point numbers, then the Pango marked-up text is
|
||||
positioned absolutely with respect to the day's box (and is not
|
||||
counted when calculating the box's height.)
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 4.0 KiB |
456
scripts/tkremind
456
scripts/tkremind
@@ -29,69 +29,92 @@ set Hostname [exec hostname]
|
||||
# Our icon photo
|
||||
catch {
|
||||
image create photo rpicon -data {
|
||||
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 }
|
||||
|
||||
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}
|
||||
wm iconphoto . -default rpicon
|
||||
}
|
||||
|
||||
proc die_with_error { msg } {
|
||||
tk_messageBox -message "Fatal Error" -detail $msg -icon error -type ok
|
||||
exit 1
|
||||
}
|
||||
|
||||
proc show_error { msg } {
|
||||
tk_messageBox -message "Error" -detail $msg -icon error -type ok
|
||||
}
|
||||
proc missing_tcllib { pkg } {
|
||||
catch { puts stderr "Could not find the '$pkg' package -- you must install tcllib.\nPlease see http://tcllib.sourceforge.net/" }
|
||||
tk_dialog .err "Error: tcllib not installed" "Could not find the '$pkg' package -- you must install tcllib. Please see http://tcllib.sourceforge.net/" error 0 OK
|
||||
tk_messageBox -message "Error: tcllib not installed" -detail "Could not find the '$pkg' package -- you must install tcllib. Please see http://tcllib.sourceforge.net/" -icon error -type ok
|
||||
exit 1
|
||||
}
|
||||
if {[catch {package require mime}]} {
|
||||
@@ -106,7 +129,7 @@ if {[catch {package require json}]} {
|
||||
}
|
||||
|
||||
if {$tcl_platform(platform) == "windows"} {
|
||||
tk_dialog .error Error "Please do not port Remind to Windows" error 0 OK
|
||||
tk_messageBox -message "Please do not port Remind to Windows" -icon error -type ok
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -301,14 +324,14 @@ set Option(PrintFormat) ps
|
||||
|
||||
set WarningHeaders [list "# Lines starting with REM TAG TKTAGnnn ... were created by tkremind" "# Do not edit them by hand or results may be unpredictable."]
|
||||
|
||||
# Highest tag seen so far. Array of tags is stored in ReminderTags()
|
||||
# Highest tag seen so far.
|
||||
set HighestTagSoFar 0
|
||||
|
||||
# Check Remind version
|
||||
set ver [GetRemindVersion]
|
||||
|
||||
if {"$ver" < "04.03.00"} {
|
||||
tk_dialog .error Error "This version of TkRemind requires Remind version 04.03.00 or newer; you have version $ver" error 0 OK
|
||||
if {"$ver" < "04.03.03"} {
|
||||
tk_messageBox -message "This version of TkRemind requires Remind version 04.03.03 or newer; you have version $ver" -icon error -type ok
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -338,6 +361,21 @@ proc is_warning_header { line } {
|
||||
return 0
|
||||
}
|
||||
|
||||
proc extract_tag { regex tag } {
|
||||
if {[regexp $regex $tag extracted]} {
|
||||
return $extracted
|
||||
}
|
||||
return "*"
|
||||
}
|
||||
|
||||
proc extract_tktag { tag } {
|
||||
extract_tag {TKTAG[0-9]+} $tag
|
||||
}
|
||||
|
||||
proc extract_syntag { tag } {
|
||||
extract_tag {__syn__[0-9a-f]+} $tag
|
||||
}
|
||||
|
||||
#***********************************************************************
|
||||
# %PROCEDURE: Initialize
|
||||
# %ARGUMENTS:
|
||||
@@ -350,7 +388,7 @@ proc is_warning_header { line } {
|
||||
#***********************************************************************
|
||||
proc Initialize {} {
|
||||
global DayNames argc argv CommandLine ReminderFile AppendFile Remind PSCmd
|
||||
global MondayFirst TwentyFourHourMode ReminderFileModTime
|
||||
global MondayFirst TwentyFourHourMode
|
||||
global TodayDay TodayMonth TodayYear
|
||||
|
||||
global Option ConfigFile
|
||||
@@ -362,8 +400,8 @@ proc Initialize {} {
|
||||
set TodayYear [clock format $now -format %Y]
|
||||
set TodayDay [string trim [clock format $now -format %e]]
|
||||
|
||||
set CommandLine "|$Remind -itkremind=1 -pp -y -l EXTRA"
|
||||
set PSCmd "$Remind -itkremind=1 -itkprint=1 -pp -l EXTRA"
|
||||
set CommandLine "$Remind -itkremind=1 -pp -y -l @EXTRA@"
|
||||
set PSCmd "$Remind -itkremind=1 -itkprint=1 -pp -l @EXTRA@"
|
||||
set i 0
|
||||
while {$i < $argc} {
|
||||
if {[regexp -- {-[bgxim].*} [lindex $argv $i]]} {
|
||||
@@ -404,8 +442,8 @@ proc Initialize {} {
|
||||
|
||||
# Check system sanity
|
||||
if {! [file readable $ReminderFile]} {
|
||||
set ans [tk_dialog .error "TkRemind: Warning" "Can't read reminder file `$ReminderFile'" warning 0 "Create it and continue" "Exit"]
|
||||
if {$ans != 0} {
|
||||
set ans [tk_messageBox -message "Can't read reminder file `$ReminderFile'. Create it and continue?" -type yesno -icon question]
|
||||
if {$ans != "yes"} {
|
||||
exit 1
|
||||
}
|
||||
catch {
|
||||
@@ -416,7 +454,7 @@ proc Initialize {} {
|
||||
}
|
||||
}
|
||||
if {! [file readable $ReminderFile]} {
|
||||
tk_dialog .error "TkRemind: Error" "Could not create reminder file `$ReminderFile'" error 0 "Exit"
|
||||
die_with_error "Could not create reminder file `$ReminderFile'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -426,58 +464,21 @@ proc Initialize {} {
|
||||
write_warning_headers $out
|
||||
puts $out ""
|
||||
close $out}]} {
|
||||
tk_dialog .error "Created File" "Created blank file `$AppendFile'" info 0 "OK"
|
||||
tk_messageBox -message "Created File" -detail "Created blank file `$AppendFile'" -icon info -type ok
|
||||
}
|
||||
}
|
||||
|
||||
if {! [file writable $AppendFile]} {
|
||||
tk_dialog .error Error "Can't write reminder file `$AppendFile'" error 0 Ok
|
||||
die_with_error "Can't write reminder file `$AppendFile'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
append CommandLine " $ReminderFile"
|
||||
append PSCmd " $ReminderFile"
|
||||
append CommandLine " "
|
||||
append CommandLine [posix_escape $ReminderFile]
|
||||
append PSCmd " "
|
||||
append PSCmd [posix_escape $ReminderFile]
|
||||
|
||||
# Get modification time of ReminderFile
|
||||
set ReminderFileModTime -1
|
||||
catch {
|
||||
set ReminderFileModTime [file mtime $ReminderFile]
|
||||
}
|
||||
|
||||
MonitorReminderFile
|
||||
|
||||
# puts "CommandLine: $CommandLine"
|
||||
}
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# MonitorReminderFile
|
||||
# If Reminder File modtime changes, restart daemon
|
||||
#---------------------------------------------------------------------------
|
||||
proc MonitorReminderFile {} {
|
||||
global ReminderFileModTime ReminderFile
|
||||
|
||||
if {$ReminderFileModTime < 0} {
|
||||
# Could not stat file
|
||||
return
|
||||
}
|
||||
|
||||
set mtime -1
|
||||
catch {
|
||||
set mtime [file mtime $ReminderFile]
|
||||
}
|
||||
if {$mtime < 0} {
|
||||
# Doh!
|
||||
return
|
||||
}
|
||||
|
||||
# Run ourselves again
|
||||
after 60000 MonitorReminderFile
|
||||
|
||||
# Redraw calendar and restart daemon if needed
|
||||
if {$ReminderFileModTime < $mtime} {
|
||||
set ReminderFileModTime $mtime
|
||||
ScheduleUpdateForChanges
|
||||
}
|
||||
set CommandLine "|/bin/sh -c \"$CommandLine @MONTH@ @YEAR@\""
|
||||
}
|
||||
|
||||
#***********************************************************************
|
||||
@@ -982,7 +983,7 @@ proc WriteOptionsToFile {} {
|
||||
global Option OptDescr
|
||||
set problem [catch {set f [open "$ConfigFile.tmp" "w"]} err]
|
||||
if {$problem} {
|
||||
tk_dialog .error Error "Can't write $ConfigFile.tmp: $err" 0 OK
|
||||
show_error "Can't write $ConfigFile.tmp: $err"
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1081,8 +1082,11 @@ proc FillCalWindow {} {
|
||||
set_button_to_queue
|
||||
set month [lindex $MonthNames $CurMonth]
|
||||
|
||||
set cmd [regsub EXTRA $CommandLine $Option(ExtraRemindArgs)]
|
||||
set file [open "$cmd $month $CurYear" r]
|
||||
set cmd [regsub @EXTRA@ $CommandLine $Option(ExtraRemindArgs)]
|
||||
set cmd [regsub @MONTH@ $cmd $month]
|
||||
set cmd [regsub @YEAR@ $cmd $CurYear]
|
||||
|
||||
set file [open $cmd r]
|
||||
# Look for # rem2ps2 begin line
|
||||
while { [gets $file line] >= 0 } {
|
||||
if { [string compare "$line" "# rem2ps2 begin"] == 0 } { break }
|
||||
@@ -1396,29 +1400,30 @@ proc DoPrint {} {
|
||||
WriteOptionsToFile
|
||||
if {$Option(PrintDest) == "file"} {
|
||||
if {$fname == ""} {
|
||||
tk_dialog .error Error "No filename specified" error 0 Ok
|
||||
show_error "No filename specified"
|
||||
return
|
||||
}
|
||||
if {[file isdirectory $fname]} {
|
||||
tk_dialog .error Error "$fname is a directory" error 0 Ok
|
||||
show_error "$fname is a directory"
|
||||
return
|
||||
}
|
||||
if {[file readable $fname]} {
|
||||
set ans [tk_dialog .error Overwrite? "Overwrite $fname?" question 0 No Yes]
|
||||
if {$ans == 0} {
|
||||
set ans [tk_messageBox -message "Overwrite?" -detail "Overwrite $fname?" -icon question -type yesno]
|
||||
if {$ans == no} {
|
||||
return
|
||||
}
|
||||
}
|
||||
set fname [posix_escape $fname]
|
||||
set fname "> $fname"
|
||||
} else {
|
||||
set fname "| $cmd"
|
||||
}
|
||||
|
||||
if {$HaveRem2PDF && $Option(PrintFormat) == "pdf"} {
|
||||
set p [regsub EXTRA $PSCmd "-itkpdf=1 $Option(ExtraRemindArgs)"]
|
||||
set p [regsub @EXTRA@ $PSCmd "-itkpdf=1 $Option(ExtraRemindArgs)"]
|
||||
set cmd "$p 1 [lindex $MonthNames $CurMonth] $CurYear | $Rem2PDF"
|
||||
} else {
|
||||
set p [regsub EXTRA $PSCmd $Option(ExtraRemindArgs)]
|
||||
set p [regsub @EXTRA@ $PSCmd $Option(ExtraRemindArgs)]
|
||||
set cmd "$p 1 [lindex $MonthNames $CurMonth] $CurYear | $Rem2PS"
|
||||
set Option(PrintFormat) ps
|
||||
}
|
||||
@@ -1487,7 +1492,7 @@ proc DoPrint {} {
|
||||
|
||||
append cmd " $fname"
|
||||
Status "Printing..."
|
||||
if {[catch {eval "exec $cmd"} err]} {
|
||||
if {[catch {exec /bin/sh "-c" $cmd} err]} {
|
||||
set RemindErrors [unique_lines $err]
|
||||
set_button_to_errors
|
||||
}
|
||||
@@ -1506,6 +1511,7 @@ proc PrintFileBrowse {} {
|
||||
.p.filename icursor end
|
||||
.p.filename xview end
|
||||
}
|
||||
raise .p
|
||||
}
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -1557,11 +1563,13 @@ proc DoGoto {} {
|
||||
global CurYear CurMonth MonthNames
|
||||
set year [.g.y.e get]
|
||||
if { ! [regexp {^[0-9]+$} $year] } {
|
||||
tk_dialog .error Error {Illegal year specified (1990-5990)} error 0 Ok
|
||||
show_error {Illegal year specified (1990-5990)}
|
||||
raise .g
|
||||
return
|
||||
}
|
||||
if { $year < 1990 || $year > 5990 } {
|
||||
tk_dialog .error Error {Illegal year specified (1990-5990)} error 0 Ok
|
||||
show_error {Illegal year specified (1990-5990)}
|
||||
raise .g
|
||||
return
|
||||
}
|
||||
set month [lsearch -exact $MonthNames [.g.mon cget -text]]
|
||||
@@ -1581,7 +1589,8 @@ proc Quit {} {
|
||||
StopBackgroundRemindDaemon
|
||||
exit 0
|
||||
}
|
||||
if { [tk_dialog .question "Confirm..." {Really quit?} question 0 No Yes] } {
|
||||
set ans [tk_messageBox -message "Really quit?" -icon question -type yesno]
|
||||
if { $ans == "yes" } {
|
||||
destroy .
|
||||
StopBackgroundRemindDaemon
|
||||
exit 0
|
||||
@@ -2018,7 +2027,7 @@ proc CreateYearMenu {w {every 1}} {
|
||||
# firstDay -- first weekday in month (0-6)
|
||||
#---------------------------------------------------------------------------
|
||||
proc ModifyDay {d firstDay} {
|
||||
global ModifyDialogResult AppendFile HighestTagSoFar ReminderTags
|
||||
global ModifyDialogResult AppendFile HighestTagSoFar
|
||||
catch {destroy .mod}
|
||||
toplevel .mod
|
||||
CreateModifyDialog .mod $d $firstDay "Cancel" "Add to reminder file" "Preview reminder"
|
||||
@@ -2039,7 +2048,8 @@ proc ModifyDay {d firstDay} {
|
||||
}
|
||||
set problem [catch {set rem [CreateReminder .mod]} err]
|
||||
if {$problem} {
|
||||
tk_dialog .error Error "$err" error 0 Ok
|
||||
show_error $err
|
||||
raise .mod
|
||||
} else {
|
||||
if {$ModifyDialogResult == 3} {
|
||||
set rem [EditReminder $rem Cancel "Add reminder"]
|
||||
@@ -2053,7 +2063,6 @@ proc ModifyDay {d firstDay} {
|
||||
Status "Writing reminder..."
|
||||
set f [open $AppendFile a]
|
||||
incr HighestTagSoFar
|
||||
set ReminderTags($HighestTagSoFar) 1
|
||||
|
||||
WriteReminder $f TKTAG$HighestTagSoFar $rem $opts
|
||||
close $f
|
||||
@@ -2066,7 +2075,6 @@ proc ModifyDay {d firstDay} {
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# CenterWindow -- center a window on the screen or over a parent.
|
||||
# Stolen from tk_dialog code
|
||||
# Arguments:
|
||||
# w -- window to center
|
||||
# parent -- window over which to center. Defaults to screen if not supplied.
|
||||
@@ -2581,8 +2589,9 @@ proc BrowseForFileRead {w {dir ""}} {
|
||||
if {$dir == ""} {
|
||||
set dir [$w.cwd cget -text]
|
||||
}
|
||||
if {[catch "cd $dir" err]} {
|
||||
tk_dialog .error Error "$err" error 0 Ok
|
||||
if {[catch {cd $dir} err]} {
|
||||
show_error "$err"
|
||||
raise $w
|
||||
return
|
||||
}
|
||||
$w.cwd configure -text [pwd]
|
||||
@@ -2625,13 +2634,14 @@ proc BrowseForFileRead {w {dir ""}} {
|
||||
#---------------------------------------------------------------------------
|
||||
proc StartBackgroundRemindDaemon {} {
|
||||
global Remind DaemonFile ReminderFile Option TwentyFourHourMode
|
||||
set fname [posix_escape $ReminderFile]
|
||||
if {$TwentyFourHourMode} {
|
||||
set problem [catch { set DaemonFile [open "|$Remind -b1 -zj -itkremind=1 $Option(ExtraRemindArgs) $ReminderFile" "r+"] } err]
|
||||
set problem [catch { set DaemonFile [open "|/bin/sh -c \"$Remind -b1 -zj -y -itkremind=1 $Option(ExtraRemindArgs) $fname\"" "r+"] } err]
|
||||
} else {
|
||||
set problem [catch { set DaemonFile [open "|$Remind -zj -itkremind=1 $Option(ExtraRemindArgs) $ReminderFile" "r+"] } err]
|
||||
set problem [catch { set DaemonFile [open "|/bin/sh -c \"$Remind -zj -y -itkremind=1 $Option(ExtraRemindArgs) $fname\"" "r+"] } err]
|
||||
}
|
||||
if {$problem} {
|
||||
tk_dialog .error Error "Can't start Remind daemon in background: $err" error 0 OK
|
||||
show_error "Can't start Remind daemon in background: $err"
|
||||
} else {
|
||||
fileevent $DaemonFile readable "DaemonReadable $DaemonFile"
|
||||
puts $DaemonFile "STATUS"
|
||||
@@ -2667,13 +2677,7 @@ proc StopBackgroundRemindDaemon {} {
|
||||
# Restarts the background Remind daemon
|
||||
#---------------------------------------------------------------------------
|
||||
proc RestartBackgroundRemindDaemon {} {
|
||||
global DaemonFile ReminderFile ReminderFileModTime
|
||||
|
||||
# Don't let the background handler trigger another reread
|
||||
catch {
|
||||
set mtime [file mtime $ReminderFile]
|
||||
set ReminderFileModTime $mtime
|
||||
}
|
||||
global DaemonFile ReminderFile
|
||||
|
||||
catch {
|
||||
puts $DaemonFile "REREAD"
|
||||
@@ -2715,11 +2719,30 @@ proc ShowQueue { queue } {
|
||||
if { $did > 0 } {
|
||||
$w.t insert end "\n"
|
||||
}
|
||||
foreach r $q {
|
||||
set fntag ""
|
||||
catch {
|
||||
set fname [dict get $q filename]
|
||||
set lineno [dict get $q lineno]
|
||||
set fntag [string cat "FILE_" $lineno "_" $fname]
|
||||
}
|
||||
if { "$fntag" != "" } {
|
||||
$w.t tag bind $fntag <Enter> [list $w.t tag configure $fntag -underline 1]
|
||||
$w.t tag bind $fntag <Leave> [list $w.t tag configure $fntag -underline 0]
|
||||
$w.t tag bind $fntag <ButtonPress-1> [list FireEditor $w.t $fntag]
|
||||
$w.t tag bind $fntag <ButtonPress-3> [list FireEditor $w.t $fntag]
|
||||
}
|
||||
foreach key [list time nexttime body] {
|
||||
set r [dict get $q $key]
|
||||
if { $toggle != 0 } {
|
||||
$w.t insert end "$r " grey
|
||||
$w.t insert end "$key=$r" [list grey $fntag]
|
||||
if {"$key" != "body"} {
|
||||
$w.t insert end "; " [list grey $fntag]
|
||||
}
|
||||
} else {
|
||||
$w.t insert end "$r "
|
||||
$w.t insert end "$key=$r" [list $fntag]
|
||||
if {"$key" != "body"} {
|
||||
$w.t insert end "; " [list $fntag]
|
||||
}
|
||||
}
|
||||
}
|
||||
$w.t insert end "\n"
|
||||
@@ -2728,6 +2751,8 @@ proc ShowQueue { queue } {
|
||||
}
|
||||
if { $did == 0 } {
|
||||
$w.t insert end "(Queue is empty)\n"
|
||||
} else {
|
||||
$w.t insert end "\n\nClick on a queue item to open an editor on the corresponding REM command.\n"
|
||||
}
|
||||
$w.t configure -state disabled
|
||||
}
|
||||
@@ -2764,7 +2789,7 @@ proc DaemonReadable { file } {
|
||||
if {[catch {set obj [::json::json2dict $line]}]} {
|
||||
return;
|
||||
}
|
||||
if (![dict exists $obj response]) {
|
||||
if {![dict exists $obj response]} {
|
||||
return;
|
||||
}
|
||||
set response [dict get $obj response]
|
||||
@@ -2785,7 +2810,11 @@ proc DaemonReadable { file } {
|
||||
set tag [dict get $obj tags]
|
||||
}
|
||||
set body [dict get $obj body]
|
||||
IssueBackgroundReminder $body $time $now $tag
|
||||
set qid "*"
|
||||
if {[dict exists $obj qid]} {
|
||||
set qid [dict get $obj qid]
|
||||
}
|
||||
IssueBackgroundReminder $body $time $now $tag $qid
|
||||
}
|
||||
"queue" {
|
||||
set queue [dict get $obj queue]
|
||||
@@ -2793,7 +2822,7 @@ proc DaemonReadable { file } {
|
||||
}
|
||||
"newdate" {
|
||||
# Date has rolled over -- clear "ignore" list
|
||||
catch { unset Ignore}
|
||||
catch { unset Ignore }
|
||||
Initialize
|
||||
FillCalWindow
|
||||
ShowTodaysReminders
|
||||
@@ -2821,13 +2850,14 @@ proc DaemonReadable { file } {
|
||||
# time -- time of reminder
|
||||
# now -- current time according to Remind daemon
|
||||
# tag -- tag for reminder, or "*" if no tag
|
||||
# qid -- Queue-ID for reminder, or "*" if no qid
|
||||
# Returns:
|
||||
# nothing
|
||||
# Description:
|
||||
# Reads a background reminder from daemon and pops up window.
|
||||
#---------------------------------------------------------------------------
|
||||
proc IssueBackgroundReminder { body time now tag } {
|
||||
global BgCounter Option Ignore
|
||||
proc IssueBackgroundReminder { body time now tag qid } {
|
||||
global BgCounter Option Ignore DaemonFile
|
||||
if {$Option(Deiconify)} {
|
||||
wm deiconify .
|
||||
}
|
||||
@@ -2837,9 +2867,16 @@ proc IssueBackgroundReminder { body time now tag } {
|
||||
return
|
||||
}
|
||||
|
||||
# Do nothing if user told us to ignore this reminder
|
||||
if {[info exists Ignore($tag)]} {
|
||||
return
|
||||
# If we're ignoring it because of tag, ignore and delete
|
||||
set syntag [extract_syntag $tag]
|
||||
if {$syntag != "*"} {
|
||||
if {[info exists Ignore($syntag)]} {
|
||||
if {$qid != "*"} {
|
||||
puts $DaemonFile "DEL $qid"
|
||||
flush $DaemonFile
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
incr BgCounter
|
||||
@@ -2852,20 +2889,26 @@ proc IssueBackgroundReminder { body time now tag } {
|
||||
frame $w.b
|
||||
|
||||
# Automatically shut down window after a minute if option says so
|
||||
set after_token [after 60000 [list ClosePopup $w "" $Option(MailAddr) $Option(AutoClose) "" $tag $body $time]]
|
||||
set after_token [after 60000 [list ClosePopup $w "" $Option(MailAddr) $Option(AutoClose) "" $tag $body $time $qid]]
|
||||
|
||||
wm protocol $w WM_DELETE_WINDOW [list ClosePopup $w $after_token "" 1 "" $tag $body $time]
|
||||
button $w.ok -text "OK" -command [list ClosePopup $w $after_token "" 1 "" $tag $body $time]
|
||||
if {$tag != "*"} {
|
||||
button $w.nomore -text "Don't remind me again today" -command [list ClosePopup $w $after_token "" 1 "ignore" $tag $body $time]
|
||||
button $w.kill -text "Delete this reminder completely" -command [list ClosePopup $w $after_token "" 1 "kill" $tag $body $time]
|
||||
wm protocol $w WM_DELETE_WINDOW [list ClosePopup $w $after_token "" 1 "" $tag $body $time $qid]
|
||||
button $w.ok -text "OK" -command [list ClosePopup $w $after_token "" 1 "" $tag $body $time $qid]
|
||||
set tktag [extract_tktag $tag]
|
||||
if {$tktag != "*"} {
|
||||
button $w.kill -text "Delete this reminder completely" -command [list ClosePopup $w $after_token "" 1 "kill" $tag $body $time $qid]
|
||||
}
|
||||
if {$qid != "*"} {
|
||||
button $w.nomore -text "Don't remind me again today" -command [list ClosePopup $w $after_token "" 1 "ignore" $tag $body $time $qid]
|
||||
}
|
||||
pack $w.l -side top
|
||||
pack $w.msg -side top -expand 1 -fill both
|
||||
pack $w.b -side top
|
||||
pack $w.ok -in $w.b -side left
|
||||
if {$tag != "*"} {
|
||||
pack $w.nomore $w.kill -in $w.b -side left
|
||||
if {$qid != "*"} {
|
||||
pack $w.nomore -in $w.b -side left
|
||||
}
|
||||
if {$tktag != "*"} {
|
||||
pack $w.kill -in $w.b -side left
|
||||
}
|
||||
|
||||
CenterWindow $w .
|
||||
@@ -2959,7 +3002,7 @@ proc main {} {
|
||||
# the tag array. Also adjusts HighestTagSoFar
|
||||
#***********************************************************************
|
||||
proc ScanForTags { fname } {
|
||||
global HighestTagSoFar ReminderTags
|
||||
global HighestTagSoFar
|
||||
if {[catch { set f [open $fname "r"]}]} {
|
||||
return
|
||||
}
|
||||
@@ -2970,7 +3013,6 @@ proc ScanForTags { fname } {
|
||||
if {$tagno > $HighestTagSoFar} {
|
||||
set HighestTagSoFar $tagno
|
||||
}
|
||||
set ReminderTags($tagno) 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3286,6 +3328,12 @@ proc ReadTaggedOptions { tag date } {
|
||||
}
|
||||
return $ans
|
||||
}
|
||||
|
||||
# Make a string safe for passing to shell.
|
||||
proc posix_escape { str } {
|
||||
return [string cat "'" [string map [list {'} {'\''}] $str] "'"]
|
||||
}
|
||||
|
||||
proc FireEditor { w {fntag ""}} {
|
||||
global Option
|
||||
global EditorPid
|
||||
@@ -3301,7 +3349,7 @@ proc FireEditor { w {fntag ""}} {
|
||||
return
|
||||
}
|
||||
set editor $Option(Editor)
|
||||
regsub -all "%s" $editor $file editor
|
||||
regsub -all "%s" $editor [posix_escape $file] editor
|
||||
regsub -all "%d" $editor $line editor
|
||||
|
||||
# Don't fire up a second editor if first is running
|
||||
@@ -3457,7 +3505,7 @@ proc EditTaggedReminder { w } {
|
||||
}
|
||||
set problem [catch {set rem [CreateReminder .mod]} err]
|
||||
if {$problem} {
|
||||
tk_dialog .error Error "$err" error 0 Ok
|
||||
show_error "$err"
|
||||
continue
|
||||
}
|
||||
if {$ModifyDialogResult == 4} {
|
||||
@@ -3477,7 +3525,7 @@ proc EditTaggedReminder { w } {
|
||||
}
|
||||
} err]
|
||||
if {$problem} {
|
||||
tk_dialog .error Error "Error: $err" error 0 Ok
|
||||
show_error $err
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -3540,7 +3588,7 @@ proc UniqueFileName { stem } {
|
||||
#***********************************************************************
|
||||
proc DeleteTaggedReminder { tag } {
|
||||
global AppendFile
|
||||
global HighestTagSoFar
|
||||
global HighestTagSoFar Ignore
|
||||
|
||||
set tmpfile [UniqueFileName $AppendFile]
|
||||
set out [open $tmpfile "w"]
|
||||
@@ -3549,12 +3597,14 @@ proc DeleteTaggedReminder { tag } {
|
||||
|
||||
set found 0
|
||||
|
||||
set tagno 0
|
||||
set tktag [extract_tktag $tag]
|
||||
set syntag [extract_syntag $tag]
|
||||
set h 0
|
||||
while {[gets $in line] >= 0} {
|
||||
if {[is_warning_header $line]} {
|
||||
continue
|
||||
}
|
||||
if {[string match "REM TAG $tag *" $line]} {
|
||||
if {[string match "REM TAG $tktag *" $line]} {
|
||||
set found 1
|
||||
continue
|
||||
}
|
||||
@@ -3569,13 +3619,12 @@ proc DeleteTaggedReminder { tag } {
|
||||
continue
|
||||
}
|
||||
|
||||
# Renumber tags
|
||||
if {[regexp {^REM TAG TKTAG([0-9]+) (.*)$} $line all oldtag rest]} {
|
||||
incr tagno
|
||||
puts $out "REM TAG TKTAG$tagno $rest"
|
||||
} else {
|
||||
puts $out $line
|
||||
}
|
||||
if {[regexp {^REM TAG TKTAG([0-9]+)} $line all tagno]} {
|
||||
if {$tagno > $h} {
|
||||
set h $tagno
|
||||
}
|
||||
}
|
||||
puts $out $line
|
||||
}
|
||||
|
||||
if {! $found } {
|
||||
@@ -3585,9 +3634,13 @@ proc DeleteTaggedReminder { tag } {
|
||||
error "Did not find reminder with tag $tag"
|
||||
}
|
||||
|
||||
set HighestTagSoFar $tagno
|
||||
if {$syntag != "*"} {
|
||||
catch { unset Ignore($syntag) }
|
||||
}
|
||||
|
||||
close $in
|
||||
close $out
|
||||
set HighestTagSoFar $h
|
||||
file rename -force -- $tmpfile $AppendFile
|
||||
}
|
||||
|
||||
@@ -3846,6 +3899,10 @@ proc CreateMoonWindows {} {
|
||||
#***********************************************************************
|
||||
proc DisplayTimeContinuously {} {
|
||||
DisplayTime
|
||||
|
||||
# Reap any zombies
|
||||
eval { exec true }
|
||||
|
||||
set secs [clock format [clock seconds] -format "%S"]
|
||||
# Doh -- don't interpret as an octal number if leading zero
|
||||
scan $secs "%d" decSecs
|
||||
@@ -3920,8 +3977,8 @@ proc ShowTodaysReminders {} {
|
||||
# Prompts for confirmation; then deletes reminder
|
||||
#***********************************************************************
|
||||
proc InteractiveDeleteReminder { tag } {
|
||||
set ans [tk_dialog .error "Really Delete" "Really delete reminder?" warning 0 No Yes]
|
||||
if {$ans == 1} {
|
||||
set ans [tk_messageBox -message "Really Delete" -detail "Really delete reminder?" -icon question -type yesno]
|
||||
if {$ans == yes} {
|
||||
DeleteTaggedReminder $tag
|
||||
ScheduleUpdateForChanges
|
||||
}
|
||||
@@ -3943,8 +4000,8 @@ proc SendMail { recipient subject body } {
|
||||
}
|
||||
}
|
||||
|
||||
proc ClosePopup { w after_token mail_addr close_win ignore_or_kill tag reminder rem_time } {
|
||||
global Ignore
|
||||
proc ClosePopup { w after_token mail_addr close_win ignore_or_kill tag reminder rem_time qid } {
|
||||
global DaemonFile Ignore
|
||||
if {"$after_token" != ""} {
|
||||
catch { after cancel $after_token }
|
||||
}
|
||||
@@ -3957,10 +4014,20 @@ proc ClosePopup { w after_token mail_addr close_win ignore_or_kill tag reminder
|
||||
SendMail $mail_addr "Reminder for $rem_time" "Hello,\n\nThe following reminder is scheduled for $rem_time:\n\n$reminder\nRegards,\n\nTkRemind\n"
|
||||
}
|
||||
if {"$ignore_or_kill" == "ignore"} {
|
||||
set Ignore($tag) 1
|
||||
if {$qid != "*"} {
|
||||
set syntag [extract_syntag $tag]
|
||||
if {$syntag != "*"} {
|
||||
set Ignore($syntag) 1
|
||||
}
|
||||
puts $DaemonFile "DEL $qid"
|
||||
flush $DaemonFile
|
||||
}
|
||||
}
|
||||
if {"$ignore_or_kill" == "kill"} {
|
||||
InteractiveDeleteReminder $tag
|
||||
set tktag [extract_tktag $tag]
|
||||
if {$tktag != "*"} {
|
||||
InteractiveDeleteReminder $tag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4210,12 +4277,13 @@ proc update_color_buttons { w } {
|
||||
}
|
||||
|
||||
proc set_button_to_queue {} {
|
||||
global Option
|
||||
balloon_set_help .b.queue "See the queue of pending reminders (debugging purposes only)"
|
||||
.b.queue configure -text {Queue...} -command {DoQueue}
|
||||
.b.queue configure -text {Queue...} -command {DoQueue} -foreground $Option(LabelColor) -background $Option(WinBackground)
|
||||
}
|
||||
proc set_button_to_errors {} {
|
||||
balloon_set_help .b.queue "See the list of errors from the most recent operation"
|
||||
.b.queue configure -text {Errors...} -command {ShowErrors}
|
||||
.b.queue configure -text {Errors...} -command {ShowErrors} -bg #FF5555 -fg black
|
||||
}
|
||||
|
||||
proc ShowErrors {} {
|
||||
@@ -4233,7 +4301,25 @@ proc ShowErrors {} {
|
||||
grid columnconfigure $w 1 -weight 0
|
||||
grid rowconfigure $w 0 -weight 1
|
||||
grid rowconfigure $w 1 -weight 0
|
||||
$w.t insert end $RemindErrors
|
||||
set l [split $RemindErrors "\n"]
|
||||
set i 0
|
||||
foreach line $l {
|
||||
if {[regexp {^(.*)\(([0-9]+)\)} $line dummy fname lineno]} {
|
||||
incr i
|
||||
set fntag [string cat "FILE_" $lineno "_" $fname]
|
||||
$w.t insert end $line [list ERR "ERR$i" $fntag]
|
||||
$w.t tag bind "ERR$i" <ButtonPress-1> [list FireEditor $w.t $fntag]
|
||||
$w.t tag bind "ERR$i" <ButtonPress-3> [list FireEditor $w.t $fntag]
|
||||
$w.t tag bind "ERR$i" <Enter> "$w.t tag configure ERR$i -underline 1"
|
||||
$w.t tag bind "ERR$i" <Leave> "$w.t tag configure ERR$i -underline 0"
|
||||
} else {
|
||||
$w.t insert end $line
|
||||
}
|
||||
$w.t insert end "\n"
|
||||
}
|
||||
if {$i > 0} {
|
||||
$w.t insert end "\nIf an error message is underlined when you hover over it, click button-1 to edit the offending file at the line number of the error.\n"
|
||||
}
|
||||
$w.t configure -state disabled
|
||||
CenterWindow $w .
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ REMINDSRCS= calendar.c dynbuf.c dorem.c dosubst.c expr.c files.c funcs.c \
|
||||
globals.c hbcal.c init.c main.c md5.c moon.c omit.c queue.c \
|
||||
sort.c token.c trigger.c userfns.c utils.c var.c
|
||||
|
||||
REMINDHDRS=config.h custom.h dynbuf.h err.h expr.h globals.h lang.h \
|
||||
REMINDHDRS=config.h custom.h dynbuf.h err.h globals.h lang.h \
|
||||
md5.h protos.h rem2ps.h types.h version.h
|
||||
REMINDOBJS= $(REMINDSRCS:.c=.o)
|
||||
|
||||
@@ -63,15 +63,16 @@ install: all
|
||||
done
|
||||
-mkdir -p $(DESTDIR)$(datarootdir)/remind || true
|
||||
cp -R ../include/* $(DESTDIR)$(datarootdir)/remind
|
||||
-mkdir -p $(DESTDIR)$(prefix)/icons
|
||||
-mkdir -p $(DESTDIR)$(prefix)/applications
|
||||
$(INSTALL_DATA) $(srcdir)/../resources/tkremind.png $(DESTDIR)$(prefix)/icons
|
||||
$(INSTALL_PROGRAM) $(srcdir)/../resources/tkremind.desktop $(DESTDIR)$(prefix)/applications
|
||||
chmod -R a+rX $(DESTDIR)$(datarootdir)/remind
|
||||
-mkdir -p $(DESTDIR)$(prefix)/share/pixmaps
|
||||
-mkdir -p $(DESTDIR)$(prefix)/share/applications
|
||||
$(INSTALL_DATA) $(srcdir)/../resources/tkremind.png $(DESTDIR)$(prefix)/share/pixmaps
|
||||
$(INSTALL_PROGRAM) $(srcdir)/../resources/tkremind.desktop $(DESTDIR)$(prefix)/share/applications
|
||||
-if test "$(DESTDIR)" = ""; then \
|
||||
update-desktop-database < /dev/null > /dev/null 2>&1 ; \
|
||||
xdg-icon-resource install --novendor --size 64 $(DESTDIR)$(prefix)/icons/tkremind.png < /dev/null > /dev/null 2>&1; \
|
||||
xdg-desktop-menu install --novendor $(DESTDIR)$(prefix)/applications/tkremind.desktop < /dev/null > /dev/null 2>&1 ; \
|
||||
fi
|
||||
xdg-icon-resource install --novendor --size 64 $(DESTDIR)$(prefix)/share/pixmaps/tkremind.png < /dev/null > /dev/null 2>&1 || true; \
|
||||
xdg-desktop-menu install --novendor $(DESTDIR)$(prefix)/share/applications/tkremind.desktop < /dev/null > /dev/null 2>&1 || true; \
|
||||
fi
|
||||
|
||||
install-stripped: install
|
||||
strip $(DESTDIR)$(bindir)/remind || true
|
||||
@@ -80,9 +81,6 @@ install-stripped: install
|
||||
clean:
|
||||
rm -f *.o *~ core *.bak $(PROGS)
|
||||
|
||||
cppcheck:
|
||||
cppcheck --force --enable=all --suppress=variableScope --suppress=ConfigurationNotChecked *.c
|
||||
|
||||
clobber:
|
||||
rm -f *.o *~ remind rem2ps test.out core *.bak
|
||||
|
||||
@@ -92,6 +90,9 @@ depend:
|
||||
# The next targets are not very useful to you. I use them to build
|
||||
# distributions, etc.
|
||||
|
||||
cppcheck:
|
||||
cppcheck -j`nproc` --force --enable=all --suppress=ConfigurationNotChecked --suppress=unmatchedSuppression --suppress=variableScope --inline-suppr .
|
||||
|
||||
# Build a tar file based on all files checked into git.
|
||||
distro:
|
||||
cd .. && git archive --worktree-attributes --format=tar --prefix=remind-$(VERSION)/ HEAD > src/remind-$(VERSION).tar
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "lang.h"
|
||||
#include "types.h"
|
||||
#include "protos.h"
|
||||
#include "expr.h"
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
#include "md5.h"
|
||||
@@ -1041,7 +1040,7 @@ static void DoCalendarOneMonth(void)
|
||||
printf("\"entries\":[\n");
|
||||
}
|
||||
}
|
||||
while (WriteCalendarRow()) continue;
|
||||
while (WriteCalendarRow()) /* continue */;
|
||||
|
||||
if (PsCal == PSCAL_LEVEL1) {
|
||||
printf("%s\n", PSEND);
|
||||
@@ -1670,6 +1669,7 @@ static void GenerateCalEntries(int col)
|
||||
case T_Pop: r=PopOmitContext(&p); break;
|
||||
case T_Push: r=PushOmitContext(&p); break;
|
||||
case T_Preserve: r=DoPreserve(&p); break;
|
||||
case T_Expr: r = DoExpr(&p); break;
|
||||
case T_RemType: if (tok.val == RUN_TYPE) {
|
||||
r=DoRun(&p);
|
||||
break;
|
||||
@@ -1770,7 +1770,7 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
DBufInit(&raw_buf);
|
||||
|
||||
/* Parse the trigger date and time */
|
||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) {
|
||||
if ( (r=ParseRem(p, &trig, &tim)) ) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -24,27 +24,46 @@ if (!$ARGV[0]) {
|
||||
}
|
||||
|
||||
my $lang = $ARGV[0];
|
||||
if (!exists($language_map->{$lang})) {
|
||||
print STDERR "$lang is not a valid language.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
my $flag = $language_map->{$lang};
|
||||
print STDERR "Testing for: $lang - $flag.\n";
|
||||
my_sys("make clean > /dev/null 2>&1") && die("make clean failed");
|
||||
my_sys("make -j6 all LANGDEF=-DLANG=$flag > /dev/null 2>&1") && die("make all failed");
|
||||
my_sys("./remind -q -r ../tests/tstlang.rem 2022-03-23 11:44 > test-$lang-compiled.out 2>&1");
|
||||
|
||||
my_sys("make clean > /dev/null 2>&1") && die("make clean failed");
|
||||
my_sys("make -j6 all > /dev/null 2>&1") && die("make all failed");
|
||||
my_sys("./remind -q -r -ii=\\\"../include/lang/$lang.rem\\\" ../tests/tstlang.rem 2022-03-23 11:44 > test-$lang-runtime.out 2>&1");
|
||||
|
||||
my $rc = my_sys("cmp test-$lang-compiled.out test-$lang-runtime.out > /dev/null 2>&1");
|
||||
if ($rc == 0) {
|
||||
print STDERR "Congrats! Compiled and runtime language output matches for $lang.\n";
|
||||
my $rc = 0;
|
||||
if ($lang eq 'all') {
|
||||
foreach my $l (sort(keys(%$language_map))) {
|
||||
if (check($l)) {
|
||||
$rc = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print STDERR "Whoops. Compiled and runtime language output differs for $lang.\n"
|
||||
$rc = check($lang);
|
||||
}
|
||||
|
||||
exit($rc);
|
||||
|
||||
sub check
|
||||
{
|
||||
my ($lang) = @_;
|
||||
if (!exists($language_map->{$lang})) {
|
||||
print STDERR "$lang is not a valid language.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
my $flag = $language_map->{$lang};
|
||||
print STDERR "Testing for: $lang - $flag.\n";
|
||||
my_sys("make clean > /dev/null 2>&1") && die("make clean failed");
|
||||
my_sys("make -j18 all LANGDEF=-DLANG=$flag > /dev/null 2>&1") && die("make all failed");
|
||||
my_sys("./remind -q -r ../tests/tstlang.rem 2022-03-23 11:44 > test-$lang-compiled.out 2>&1");
|
||||
|
||||
my_sys("make clean > /dev/null 2>&1") && die("make clean failed");
|
||||
my_sys("make -j18 all > /dev/null 2>&1") && die("make all failed");
|
||||
my_sys("./remind -q -r -ii=\\\"../include/lang/$lang.rem\\\" ../tests/tstlang.rem 2022-03-23 11:44 > test-$lang-runtime.out 2>&1");
|
||||
|
||||
my $rc = my_sys("cmp test-$lang-compiled.out test-$lang-runtime.out > /dev/null 2>&1");
|
||||
if ($rc == 0) {
|
||||
print STDERR "Congrats! Compiled and runtime language output matches for $lang.\n";
|
||||
} else {
|
||||
print STDERR "Whoops. Compiled and runtime language output differs for $lang.\n"
|
||||
}
|
||||
return $rc;
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
sub my_sys
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
/* Define if utime(file, NULL) sets file's timestamp to the present. */
|
||||
#undef HAVE_UTIME_NULL
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if your <sys/time.h> declares struct tm. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
@@ -16,6 +10,15 @@
|
||||
/* Define if you have the <glob.h> header file */
|
||||
#undef HAVE_GLOB_H
|
||||
|
||||
/* Define if you have <stdint.h> */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
#undef HAVE_STRDUP
|
||||
#undef HAVE_STRCASECMP
|
||||
#undef HAVE_STRNCASECMP
|
||||
|
||||
#undef HAVE_WCTYPE_H
|
||||
|
||||
#undef HAVE_LOCALE_H
|
||||
@@ -42,4 +45,8 @@
|
||||
/* The number of bytes in a unsigned long. */
|
||||
#undef SIZEOF_UNSIGNED_LONG
|
||||
|
||||
#define PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
#define PACKAGE_URL "@PACKAGE_URL@"
|
||||
|
||||
#include "custom.h"
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* VAL_STACK_SIZE: The size of the operand stack for expr. parsing */
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define VAL_STACK_SIZE 1000
|
||||
#define VAL_STACK_SIZE 100
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* INCLUDE_NEST: How many nested INCLUDES do we handle? */
|
||||
@@ -166,6 +166,10 @@
|
||||
|
||||
#define PASSTHRU_LEN 32
|
||||
|
||||
#define MAX_RECURSION_LEVEL 1000
|
||||
|
||||
#define MAX_FUNC_ARGS 64
|
||||
|
||||
#define PSBEGIN "# rem2ps begin"
|
||||
#define PSEND "# rem2ps end"
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* VAL_STACK_SIZE: The size of the operand stack for expr. parsing */
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define VAL_STACK_SIZE 1000
|
||||
#define VAL_STACK_SIZE 100
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* INCLUDE_NEST: How many nested INCLUDES do we handle? */
|
||||
@@ -166,6 +166,10 @@
|
||||
|
||||
#define PASSTHRU_LEN 32
|
||||
|
||||
#define MAX_RECURSION_LEVEL 1000
|
||||
|
||||
#define MAX_FUNC_ARGS 64
|
||||
|
||||
#define PSBEGIN "# rem2ps begin"
|
||||
#define PSEND "# rem2ps end"
|
||||
|
||||
|
||||
77
src/dorem.c
77
src/dorem.c
@@ -23,9 +23,8 @@
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
#include "protos.h"
|
||||
#include "expr.h"
|
||||
|
||||
static int ParseTimeTrig (ParsePtr s, TimeTrig *tim, int save_in_globals);
|
||||
static int ParseTimeTrig (ParsePtr s, TimeTrig *tim);
|
||||
static int ParseLocalOmit (ParsePtr s, Trigger *t);
|
||||
static int ParseScanFrom (ParsePtr s, Trigger *t, int type);
|
||||
static int ParsePriority (ParsePtr s, Trigger *t);
|
||||
@@ -63,7 +62,7 @@ int DoRem(ParsePtr p)
|
||||
DBufInit(&buf);
|
||||
|
||||
/* Parse the trigger date and time */
|
||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) {
|
||||
if ( (r=ParseRem(p, &trig, &tim)) ) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
@@ -163,6 +162,7 @@ int DoRem(ParsePtr p)
|
||||
if (p->expr_happened) {
|
||||
if (p->nonconst_expr) {
|
||||
PurgeEchoLine("%s\n", "#!P: Next line may have expired, but contains non-constant expression");
|
||||
PurgeEchoLine("%s\n", "#!P: or a relative SCANFROM clause");
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
} else {
|
||||
PurgeEchoLine("%s\n", "#!P: Next line has expired, but contains expression... please verify");
|
||||
@@ -220,7 +220,7 @@ int DoRem(ParsePtr p)
|
||||
/* trigger structure. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim)
|
||||
{
|
||||
register int r;
|
||||
DynamicBuffer buf;
|
||||
@@ -262,10 +262,6 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
trig->need_wkday = 0;
|
||||
trig->adj_for_last = 0;
|
||||
|
||||
if (save_in_globals) {
|
||||
LastTriggerTime = NO_TIME;
|
||||
}
|
||||
|
||||
int parsing = 1;
|
||||
while(parsing) {
|
||||
/* Read space-delimited string */
|
||||
@@ -315,10 +311,6 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
trig->m = m;
|
||||
trig->d = d;
|
||||
tim->ttime = (tok.val % MINUTES_PER_DAY);
|
||||
if (save_in_globals) {
|
||||
LastTriggerTime = tim->ttime;
|
||||
SaveLastTimeTrig(tim);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_WkDay:
|
||||
@@ -355,14 +347,14 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
DBufFree(&buf);
|
||||
if (tim->ttime != NO_TIME) return E_TIME_TWICE;
|
||||
tim->ttime = tok.val;
|
||||
r = ParseTimeTrig(s, tim, save_in_globals);
|
||||
r = ParseTimeTrig(s, tim);
|
||||
if (r) return r;
|
||||
trig->duration_days = ComputeTrigDuration(tim);
|
||||
break;
|
||||
|
||||
case T_At:
|
||||
DBufFree(&buf);
|
||||
r=ParseTimeTrig(s, tim, save_in_globals);
|
||||
r=ParseTimeTrig(s, tim);
|
||||
if (r) return r;
|
||||
trig->duration_days = ComputeTrigDuration(tim);
|
||||
break;
|
||||
@@ -481,10 +473,10 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
r=ParseToken(s, &buf);
|
||||
if (r) return r;
|
||||
StrnCpy(trig->omitfunc, DBufValue(&buf), VAR_NAME_LEN);
|
||||
|
||||
strtolower(trig->omitfunc);
|
||||
/* An OMITFUNC counts as a nonconst_expr! */
|
||||
s->expr_happened = 1;
|
||||
s->nonconst_expr = 1;
|
||||
s->expr_happened = 1;
|
||||
s->nonconst_expr = 1;
|
||||
DBufFree(&buf);
|
||||
break;
|
||||
|
||||
@@ -492,6 +484,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
r=ParseToken(s, &buf);
|
||||
if(r) return r;
|
||||
StrnCpy(trig->warn, DBufValue(&buf), VAR_NAME_LEN);
|
||||
strtolower(trig->warn);
|
||||
DBufFree(&buf);
|
||||
break;
|
||||
|
||||
@@ -522,9 +515,6 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
} else {
|
||||
tim->duration = NO_TIME;
|
||||
}
|
||||
if (save_in_globals) {
|
||||
SaveLastTimeTrig(tim);
|
||||
}
|
||||
trig->duration_days = ComputeTrigDuration(tim);
|
||||
break;
|
||||
default:
|
||||
@@ -536,6 +526,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
r=ParseToken(s, &buf);
|
||||
if(r) return r;
|
||||
StrnCpy(trig->sched, DBufValue(&buf), VAR_NAME_LEN);
|
||||
strtolower(trig->sched);
|
||||
DBufFree(&buf);
|
||||
break;
|
||||
|
||||
@@ -608,7 +599,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
/* ParseTimeTrig - parse the AT part of a timed reminder */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
static int ParseTimeTrig(ParsePtr s, TimeTrig *tim, int save_in_globals)
|
||||
static int ParseTimeTrig(ParsePtr s, TimeTrig *tim)
|
||||
{
|
||||
Token tok;
|
||||
int r;
|
||||
@@ -643,11 +634,6 @@ static int ParseTimeTrig(ParsePtr s, TimeTrig *tim, int save_in_globals)
|
||||
default:
|
||||
if (tim->ttime == NO_TIME) return E_EXPECT_TIME;
|
||||
|
||||
/* Save trigger time in global variable */
|
||||
if (save_in_globals) {
|
||||
LastTriggerTime = tim->ttime;
|
||||
SaveLastTimeTrig(tim);
|
||||
}
|
||||
PushToken(DBufValue(&buf), s);
|
||||
DBufFree(&buf);
|
||||
return OK;
|
||||
@@ -679,6 +665,9 @@ static int ParseLocalOmit(ParsePtr s, Trigger *t)
|
||||
break;
|
||||
|
||||
default:
|
||||
if (t->localomit == NO_WD) {
|
||||
return E_EXPECTING_WEEKDAY;
|
||||
}
|
||||
PushToken(DBufValue(&buf), s);
|
||||
DBufFree(&buf);
|
||||
return OK;
|
||||
@@ -873,6 +862,9 @@ static int ParseScanFrom(ParsePtr s, Trigger *t, int type)
|
||||
tok.val = -tok.val;
|
||||
}
|
||||
FromDSE(DSEToday - tok.val, &y, &m, &d);
|
||||
/* Don't purge reminders with a relative scanfrom */
|
||||
s->expr_happened = 1;
|
||||
s->nonconst_expr = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1281,20 +1273,28 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p)
|
||||
{
|
||||
int iter, dse, r, start;
|
||||
Value v;
|
||||
char const *s;
|
||||
char const *t;
|
||||
expr_node *sat_node;
|
||||
int nonconst = 0;
|
||||
|
||||
t = p->pos;
|
||||
sat_node = ParseExpr(p, &r);
|
||||
if (r != OK) {
|
||||
return r;
|
||||
}
|
||||
if (!sat_node) {
|
||||
return E_SWERR;
|
||||
}
|
||||
iter = 0;
|
||||
start = trig->scanfrom;
|
||||
while (iter++ < MaxSatIter) {
|
||||
dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, 0);
|
||||
if (r) {
|
||||
free_expr_tree(sat_node);
|
||||
if (r == E_CANT_TRIG) return OK; else return r;
|
||||
}
|
||||
if (dse != start && trig->duration_days) {
|
||||
dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, trig->duration_days);
|
||||
if (r) {
|
||||
free_expr_tree(sat_node);
|
||||
if (r == E_CANT_TRIG) return OK; else return r;
|
||||
}
|
||||
} else if (dse == start) {
|
||||
@@ -1307,13 +1307,18 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p)
|
||||
SaveAllTriggerInfo(trig, tt, dse, tt->ttime, 1);
|
||||
}
|
||||
if (dse == -1) {
|
||||
free_expr_tree(sat_node);
|
||||
return E_EXPIRED;
|
||||
}
|
||||
s = p->pos;
|
||||
r = EvaluateExpr(p, &v);
|
||||
t = p->pos;
|
||||
if (r) return r;
|
||||
if (v.type != INT_TYPE && v.type != STR_TYPE) return E_BAD_TYPE;
|
||||
r = evaluate_expression(sat_node, NULL, &v, &nonconst);
|
||||
if (r) {
|
||||
free_expr_tree(sat_node);
|
||||
return r;
|
||||
}
|
||||
if (v.type != INT_TYPE && v.type != STR_TYPE) {
|
||||
free_expr_tree(sat_node);
|
||||
return E_BAD_TYPE;
|
||||
}
|
||||
if ((v.type == INT_TYPE && v.v.val) ||
|
||||
(v.type == STR_TYPE && *v.v.str)) {
|
||||
AdjustTriggerForDuration(trig->scanfrom, dse, trig, tt, 1);
|
||||
@@ -1338,17 +1343,17 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p)
|
||||
}
|
||||
fprintf(ErrFp, "\n");
|
||||
}
|
||||
free_expr_tree(sat_node);
|
||||
return OK;
|
||||
}
|
||||
p->pos = s;
|
||||
if (dse+trig->duration_days < start) {
|
||||
start++;
|
||||
} else {
|
||||
start = dse+trig->duration_days+1;
|
||||
}
|
||||
}
|
||||
p->pos = t;
|
||||
LastTrigValid = 0;
|
||||
free_expr_tree(sat_node);
|
||||
return E_CANT_TRIG;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
/***************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "expr.h"
|
||||
#include "types.h"
|
||||
#define L_IN_DOSUBST
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
#include "protos.h"
|
||||
@@ -50,7 +49,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
|
||||
int err, done;
|
||||
int c;
|
||||
int d, m, y;
|
||||
int tim = tt->ttime;
|
||||
int tim = NO_TIME;
|
||||
int h, min, hh, ch, cmin, chh;
|
||||
int i;
|
||||
char const *pm, *cpm;
|
||||
@@ -72,6 +71,9 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
|
||||
|
||||
FromDSE(dse, &y, &m, &d);
|
||||
|
||||
if (tt) {
|
||||
tim = tt->ttime;
|
||||
}
|
||||
if (tim == NO_TIME) tim = curtime;
|
||||
tdiff = tim - curtime;
|
||||
adiff = ABS(tdiff);
|
||||
@@ -139,6 +141,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
|
||||
} else {
|
||||
r = -1;
|
||||
}
|
||||
DestroyValue(v);
|
||||
} else {
|
||||
Eprint("%s", ErrMsg[r]);
|
||||
}
|
||||
@@ -163,6 +166,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
|
||||
} else {
|
||||
r = -1;
|
||||
}
|
||||
DestroyValue(v);
|
||||
} else {
|
||||
Eprint("%s", ErrMsg[r]);
|
||||
}
|
||||
@@ -239,7 +243,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
|
||||
break;
|
||||
}
|
||||
if (i < 64) {
|
||||
*ss++ = c;
|
||||
*ss++ = tolower(c);
|
||||
*ss = 0;
|
||||
i++;
|
||||
}
|
||||
@@ -266,10 +270,10 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
|
||||
continue;
|
||||
}
|
||||
done = 0;
|
||||
snprintf(uf, sizeof(uf), "subst_%c", c);
|
||||
snprintf(uf, sizeof(uf), "subst_%c", tolower(c));
|
||||
if (UserFuncExists(uf) == 3) {
|
||||
snprintf(s, sizeof(s), "subst_%c(%d,'%04d-%02d-%02d',%02d:%02d)",
|
||||
c, altmode ? 1 : 0, y, m+1, d, h, min);
|
||||
tolower(c), altmode ? 1 : 0, y, m+1, d, h, min);
|
||||
expr = (char const *) s;
|
||||
r = EvalExpr(&expr, &v, NULL);
|
||||
if (r == OK) {
|
||||
@@ -341,10 +345,10 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
|
||||
|
||||
|
||||
if (!done) {
|
||||
snprintf(uf, sizeof(uf), "subst_%cx", c);
|
||||
snprintf(uf, sizeof(uf), "subst_%cx", tolower(c));
|
||||
if (UserFuncExists(uf) == 3) {
|
||||
snprintf(s, sizeof(s), "subst_%cx(%d,'%04d-%02d-%02d',%02d:%02d)",
|
||||
c, altmode ? 1 : 0, y, m+1, d, h, min);
|
||||
tolower(c), altmode ? 1 : 0, y, m+1, d, h, min);
|
||||
expr = (char const *) s;
|
||||
r = EvalExpr(&expr, &v, NULL);
|
||||
if (r == OK) {
|
||||
|
||||
@@ -124,7 +124,9 @@ int DBufPuts(DynamicBuffer *dbuf, char const *str)
|
||||
**********************************************************************/
|
||||
void DBufFree(DynamicBuffer *dbuf)
|
||||
{
|
||||
if (dbuf->buffer != dbuf->staticBuf) free(dbuf->buffer);
|
||||
if (dbuf->buffer != NULL && dbuf->buffer != dbuf->staticBuf) {
|
||||
free(dbuf->buffer);
|
||||
}
|
||||
DBufInit(dbuf);
|
||||
}
|
||||
|
||||
|
||||
217
src/err.h
217
src/err.h
@@ -121,6 +121,11 @@
|
||||
#define E_STRING_TOO_LONG 101
|
||||
#define E_TIME_TWICE 102
|
||||
#define E_DURATION_NO_AT 103
|
||||
#define E_EXPECTING_WEEKDAY 104
|
||||
#define E_REPEATED_ARG 105
|
||||
#define E_EXPR_DISABLED 106
|
||||
#define E_TIME_EXCEEDED 107
|
||||
|
||||
#ifdef MK_GLOBALS
|
||||
#undef EXTERN
|
||||
#define EXTERN
|
||||
@@ -138,110 +143,114 @@ EXTERN char *ErrMsg[]
|
||||
|
||||
#ifdef MK_GLOBALS
|
||||
= {
|
||||
"Ok",
|
||||
"Missing ']'",
|
||||
"Missing quote",
|
||||
"Expression too complex - too many operators",
|
||||
"Expression too complex - too many operands",
|
||||
"Missing ')'",
|
||||
"Undefined function",
|
||||
"Illegal character",
|
||||
"Expecting binary operator",
|
||||
"Out of memory",
|
||||
"Ill-formed number",
|
||||
"Op stack underflow - internal error",
|
||||
"Va stack underflow - internal error",
|
||||
"Can't coerce",
|
||||
"Type mismatch",
|
||||
"Date overflow",
|
||||
"Stack error - internal error",
|
||||
"Division by zero",
|
||||
"Undefined variable",
|
||||
"Unexpected end of line",
|
||||
"Unexpected end of file",
|
||||
"I/O error",
|
||||
"Line too long",
|
||||
"Internal error",
|
||||
"Bad date specification",
|
||||
"Not enough arguments",
|
||||
"Too many arguments",
|
||||
"Ill-formed time",
|
||||
"Number too high",
|
||||
"Number too low",
|
||||
"Can't open file",
|
||||
"INCLUDE nested too deeply (max. " STR(INCLUDE_NEST) ")",
|
||||
"Parse error",
|
||||
"Can't compute trigger",
|
||||
"Too many nested IFs",
|
||||
"ELSE with no matching IF",
|
||||
"ENDIF with no matching IF",
|
||||
"Can't OMIT every weekday",
|
||||
"Extraneous token(s) on line",
|
||||
"POP-OMIT-CONTEXT without matching PUSH-OMIT-CONTEXT",
|
||||
"RUN disabled",
|
||||
"Domain error",
|
||||
"Invalid identifier",
|
||||
"Recursive function call detected",
|
||||
"",
|
||||
"Cannot modify system variable",
|
||||
"C library function can't represent date/time",
|
||||
"Attempt to redefine built-in function",
|
||||
"Can't nest function definition in expression",
|
||||
"Must fully specify date to use repeat factor",
|
||||
"Year specified twice",
|
||||
"Month specified twice",
|
||||
"Day specified twice",
|
||||
"Unknown token",
|
||||
"Must specify month in OMIT command",
|
||||
"Too many partial OMITs (max. " STR(MAX_PARTIAL_OMITS) ")",
|
||||
"Too many full OMITs (max. " STR(MAX_FULL_OMITS) ")",
|
||||
"Warning: PUSH-OMIT-CONTEXT without matching POP-OMIT-CONTEXT",
|
||||
"Error reading",
|
||||
"Expecting end-of-line",
|
||||
"Invalid Hebrew date",
|
||||
"IIF needs odd number of arguments",
|
||||
"Warning: Missing ENDIF",
|
||||
"Expecting comma",
|
||||
"Weekday specified twice",
|
||||
"Only use one of BEFORE, AFTER or SKIP",
|
||||
"Can't nest MSG, MSF, RUN, etc. in expression",
|
||||
"Repeat value specified twice",
|
||||
"Delta value specified twice",
|
||||
"Back value specified twice",
|
||||
"ONCE keyword used twice. (Hah.)",
|
||||
"Expecting time after AT",
|
||||
"THROUGH/UNTIL keyword used twice",
|
||||
"Incomplete date specification",
|
||||
"FROM/SCANFROM keyword used twice",
|
||||
"Variable",
|
||||
"Value",
|
||||
"*UNDEFINED*",
|
||||
"Entering UserFN",
|
||||
"Leaving UserFN",
|
||||
"Expired",
|
||||
"fork() failed - can't do queued reminders",
|
||||
"Can't access file",
|
||||
"Illegal system date: Year is less than %d\n",
|
||||
"Unknown debug flag '%c'\n",
|
||||
"Unknown option '%c'\n",
|
||||
"Unknown user '%s'\n",
|
||||
"Could not change gid to %d\n",
|
||||
"Could not change uid to %d\n",
|
||||
"Out of memory for environment\n",
|
||||
"Missing '=' sign",
|
||||
"Missing variable name",
|
||||
"Missing expression",
|
||||
"Can't reset access date of %s\n",
|
||||
"Remind: '-i' option: %s\n",
|
||||
"No reminders.",
|
||||
"%d reminder(s) queued for later today.\n",
|
||||
"Expecting number",
|
||||
"Bad function in WARN clause",
|
||||
"Can't convert between time zones",
|
||||
"No files matching *.rem",
|
||||
"String too long",
|
||||
"Time specified twice",
|
||||
"Cannot specify DURATION without specifying AT"
|
||||
/* OK */ "Ok",
|
||||
/* E_MISS_END */ "Missing ']'",
|
||||
/* E_MISS_QUOTE */ "Missing quote",
|
||||
/* E_OP_STK_OVER */ "Expression too complex",
|
||||
/* E_VA_STK_OVER */ "Expression too complex - too many operands",
|
||||
/* E_MISS_RIGHT_PAREN */ "Missing ')'",
|
||||
/* E_UNDEF_FUNC */ "Undefined function",
|
||||
/* E_ILLEGAL_CHAR */ "Illegal character",
|
||||
/* E_EXPECTING_BINOP */ "Expecting binary operator",
|
||||
/* E_NO_MEM */ "Out of memory",
|
||||
/* E_BAD_NUMBER */ "Ill-formed number",
|
||||
/* E_OP_STK_UNDER */ "Op stack underflow - internal error",
|
||||
/* E_VA_STK_UNDER */ "Va stack underflow - internal error",
|
||||
/* E_CANT_COERCE */ "Can't coerce",
|
||||
/* E_BAD_TYPE */ "Type mismatch",
|
||||
/* E_DATE_OVER */ "Date overflow",
|
||||
/* E_STACK_ERR */ "Stack error - internal error",
|
||||
/* E_DIV_ZERO */ "Division by zero",
|
||||
/* E_NOSUCH_VAR */ "Undefined variable",
|
||||
/* E_EOLN */ "Unexpected end of line",
|
||||
/* E_EOF */ "Unexpected end of file",
|
||||
/* E_IO_ERR */ "I/O error",
|
||||
/* E_LINE_2_LONG */ "Line too long",
|
||||
/* E_SWERR */ "Internal error",
|
||||
/* E_BAD_DATE */ "Bad date specification",
|
||||
/* E_2FEW_ARGS */ "Not enough arguments",
|
||||
/* E_2MANY_ARGS */ "Too many arguments",
|
||||
/* E_BAD_TIME */ "Ill-formed time",
|
||||
/* E_2HIGH */ "Number too high",
|
||||
/* E_2LOW */ "Number too low",
|
||||
/* E_CANT_OPEN */ "Can't open file",
|
||||
/* E_NESTED_INCLUDE */ "INCLUDE nested too deeply (max. " STR(INCLUDE_NEST) ")",
|
||||
/* E_PARSE_ERR */ "Parse error",
|
||||
/* E_CANT_TRIG */ "Can't compute trigger",
|
||||
/* E_NESTED_IF */ "Too many nested IFs",
|
||||
/* E_ELSE_NO_IF */ "ELSE with no matching IF",
|
||||
/* E_ENDIF_NO_IF */ "ENDIF with no matching IF",
|
||||
/* E_2MANY_LOCALOMIT */ "Can't OMIT every weekday",
|
||||
/* E_EXTRANEOUS_TOKEN */ "Extraneous token(s) on line",
|
||||
/* E_POP_NO_PUSH */ "POP-OMIT-CONTEXT without matching PUSH-OMIT-CONTEXT",
|
||||
/* E_RUN_DISABLED */ "RUN disabled",
|
||||
/* E_DOMAIN_ERR */ "Domain error",
|
||||
/* E_BAD_ID */ "Invalid identifier",
|
||||
/* E_RECURSIVE */ "Too many recursive function calls",
|
||||
/* E_PARSE_AS_REM */ "",
|
||||
/* E_CANT_MODIFY */ "Cannot modify system variable",
|
||||
/* E_MKTIME_PROBLEM */ "C library function can't represent date/time",
|
||||
/* E_REDEF_FUNC */ "Attempt to redefine built-in function",
|
||||
/* E_CANTNEST_FDEF */ "Can't nest function definition in expression",
|
||||
/* E_REP_FULSPEC */ "Must fully specify date to use repeat factor",
|
||||
/* E_YR_TWICE */ "Year specified twice",
|
||||
/* E_MON_TWICE */ "Month specified twice",
|
||||
/* E_DAY_TWICE */ "Day specified twice",
|
||||
/* E_UNKNOWN_TOKEN */ "Unknown token",
|
||||
/* E_SPEC_MON */ "Must specify month in OMIT command",
|
||||
/* E_2MANY_PART */ "Too many partial OMITs (max. " STR(MAX_PARTIAL_OMITS) ")",
|
||||
/* E_2MANY_FULL */ "Too many full OMITs (max. " STR(MAX_FULL_OMITS) ")",
|
||||
/* E_PUSH_NOPOP */ "Warning: PUSH-OMIT-CONTEXT without matching POP-OMIT-CONTEXT",
|
||||
/* E_ERR_READING */ "Error reading",
|
||||
/* E_EXPECTING_EOL */ "Expecting end-of-line",
|
||||
/* E_BAD_HEBDATE */ "Invalid Hebrew date",
|
||||
/* E_IIF_ODD */ "IIF needs odd number of arguments",
|
||||
/* E_MISS_ENDIF */ "Warning: Missing ENDIF",
|
||||
/* E_EXPECT_COMMA */ "Expecting comma",
|
||||
/* E_WD_TWICE */ "Weekday specified twice",
|
||||
/* E_SKIP_ERR */ "Only use one of BEFORE, AFTER or SKIP",
|
||||
/* E_CANT_NEST_RTYPE */ "Can't nest MSG, MSF, RUN, etc. in expression",
|
||||
/* E_REP_TWICE */ "Repeat value specified twice",
|
||||
/* E_DELTA_TWICE */ "Delta value specified twice",
|
||||
/* E_BACK_TWICE */ "Back value specified twice",
|
||||
/* E_ONCE_TWICE */ "ONCE keyword used twice. (Hah.)",
|
||||
/* E_EXPECT_TIME */ "Expecting time after AT",
|
||||
/* E_UNTIL_TWICE */ "THROUGH/UNTIL keyword used twice",
|
||||
/* E_INCOMPLETE */ "Incomplete date specification",
|
||||
/* E_SCAN_TWICE */ "FROM/SCANFROM keyword used twice",
|
||||
/* E_VAR */ "Variable",
|
||||
/* E_VAL */ "Value",
|
||||
/* E_UNDEF */ "*UNDEFINED*",
|
||||
/* E_ENTER_FUN */ "Entering UserFN",
|
||||
/* E_LEAVE_FUN */ "Leaving UserFN",
|
||||
/* E_EXPIRED */ "Expired",
|
||||
/* E_CANTFORK */ "fork() failed - can't do queued reminders",
|
||||
/* E_CANTACCESS */ "Can't access file",
|
||||
/* M_BAD_SYS_DATE */ "Illegal system date: Year is less than %d\n",
|
||||
/* M_BAD_DB_FLAG */ "Unknown debug flag '%c'\n",
|
||||
/* M_BAD_OPTION */ "Unknown option '%c'\n",
|
||||
/* M_BAD_USER */ "Unknown user '%s'\n",
|
||||
/* M_NO_CHG_GID */ "Could not change gid to %d\n",
|
||||
/* M_NO_CHG_UID */ "Could not change uid to %d\n",
|
||||
/* M_NOMEM_ENV */ "Out of memory for environment\n",
|
||||
/* E_MISS_EQ */ "Missing '=' sign",
|
||||
/* E_MISS_VAR */ "Missing variable name",
|
||||
/* E_MISS_EXPR */ "Missing expression",
|
||||
/* M_CANTSET_ACCESS */ "Can't reset access date of %s\n",
|
||||
/* M_I_OPTION */ "Remind: '-i' option: %s\n",
|
||||
/* E_NOREMINDERS */ "No reminders.",
|
||||
/* M_QUEUED */ "%d reminder(s) queued for later today.\n",
|
||||
/* E_EXPECTING_NUMBER */ "Expecting number",
|
||||
/* M_BAD_WARN_FUNC */ "Bad function in WARN clause",
|
||||
/* E_CANT_CONVERT_TZ */ "Can't convert between time zones",
|
||||
/* E_NO_MATCHING_REMS */ "No files matching *.rem",
|
||||
/* E_STRING_TOO_LONG */ "String too long",
|
||||
/* E_TIME_TWICE */ "Time specified twice",
|
||||
/* E_DURATION_NO_AT */ "Cannot specify DURATION without specifying AT",
|
||||
/* E_EXPECTING_WEEKDAY */ "Expecting weekday name",
|
||||
/* E_REPEATED_ARG */ "Duplicate argument name",
|
||||
/* E_EXPR_DISABLED */ "Expression evaluation is disabled",
|
||||
/* E_TIME_EXCEEDED */ "Time limit for expression evaluation exceeded",
|
||||
}
|
||||
#endif /* MK_GLOBALS */
|
||||
;
|
||||
|
||||
3675
src/expr.c
3675
src/expr.c
File diff suppressed because it is too large
Load Diff
66
src/expr.h
66
src/expr.h
@@ -1,66 +0,0 @@
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* EXPR.H */
|
||||
/* */
|
||||
/* Contains a few definitions used by expression evaluator. */
|
||||
/* */
|
||||
/* This file is part of REMIND. */
|
||||
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
|
||||
/* Define the types of values */
|
||||
#define ERR_TYPE 0
|
||||
#define INT_TYPE 1
|
||||
#define TIME_TYPE 2
|
||||
#define DATE_TYPE 3
|
||||
#define STR_TYPE 4
|
||||
#define DATETIME_TYPE 5
|
||||
#define SPECIAL_TYPE 6 /* Only for system variables */
|
||||
#define CONST_INT_TYPE 7 /* Only for system variables */
|
||||
|
||||
/* Define stuff for parsing expressions */
|
||||
#define BEG_OF_EXPR '['
|
||||
#define END_OF_EXPR ']'
|
||||
#define COMMA ','
|
||||
|
||||
#define UN_OP 0 /* Unary operator */
|
||||
#define BIN_OP 1 /* Binary Operator */
|
||||
#define FUNC 2 /* Function */
|
||||
|
||||
/* Make the pushing and popping of values and operators in-line code
|
||||
for speed. BEWARE: These macros invoke return if an error happens ! */
|
||||
|
||||
#define PushOpStack(op) \
|
||||
if (OpStackPtr >= OP_STACK_SIZE) \
|
||||
return E_OP_STK_OVER; \
|
||||
else \
|
||||
OpStack[OpStackPtr++] = (op)
|
||||
|
||||
#define PopOpStack(op) \
|
||||
if (OpStackPtr <= 0) \
|
||||
return E_OP_STK_UNDER; \
|
||||
else \
|
||||
(op) = OpStack[--OpStackPtr]
|
||||
|
||||
#define PushValStack(val) \
|
||||
if (ValStackPtr >= VAL_STACK_SIZE) \
|
||||
return E_VA_STK_OVER; \
|
||||
else \
|
||||
ValStack[ValStackPtr++] = (val)
|
||||
|
||||
#define PopValStack(val) \
|
||||
if (ValStackPtr <= 0) \
|
||||
return E_VA_STK_UNDER; \
|
||||
else \
|
||||
(val) = ValStack[--ValStackPtr]
|
||||
|
||||
/* These functions are in utils.c and are used to detect overflow
|
||||
in various arithmetic operators. They have to be in separate
|
||||
functions with extern linkage to defeat compiler optimizations
|
||||
that would otherwise break the overflow checks. */
|
||||
extern int _private_mul_overflow(int a, int b);
|
||||
extern int _private_add_overflow(int a, int b);
|
||||
extern int _private_sub_overflow(int a, int b);
|
||||
|
||||
38
src/files.c
38
src/files.c
@@ -42,8 +42,8 @@
|
||||
|
||||
|
||||
/* Convenient macros for closing files */
|
||||
#define FCLOSE(fp) (((fp)&&((fp)!=stdin)) ? (fclose(fp),(fp)=NULL) : ((fp)=NULL))
|
||||
#define PCLOSE(fp) (((fp)&&((fp)!=stdin)) ? (pclose(fp),(fp)=NULL) : ((fp)=NULL))
|
||||
#define FCLOSE(fp) ((((fp)!=stdin)) ? (fclose(fp),(fp)=NULL) : ((fp)=NULL))
|
||||
#define PCLOSE(fp) ((((fp)!=stdin)) ? (pclose(fp),(fp)=NULL) : ((fp)=NULL))
|
||||
|
||||
/* Define the structures needed by the file caching system */
|
||||
typedef struct cache {
|
||||
@@ -79,6 +79,7 @@ typedef struct {
|
||||
int LineNo;
|
||||
unsigned int IfFlags;
|
||||
int NumIfs;
|
||||
int IfLinenos[IF_NEST];
|
||||
long offset;
|
||||
CachedLine *CLine;
|
||||
int ownedByMe;
|
||||
@@ -101,13 +102,17 @@ static int CheckSafetyAux (struct stat *statbuf);
|
||||
static int PopFile (void);
|
||||
static int IncludeCmd(char const *);
|
||||
|
||||
void set_cloexec(int fd)
|
||||
void set_cloexec(FILE *fp)
|
||||
{
|
||||
int flags;
|
||||
flags = fcntl(fd, F_GETFD);
|
||||
if (flags >= 0) {
|
||||
flags |= FD_CLOEXEC;
|
||||
fcntl(fd, F_SETFD, flags);
|
||||
int fd;
|
||||
if (fp) {
|
||||
fd = fileno(fp);
|
||||
flags = fcntl(fd, F_GETFD);
|
||||
if (flags >= 0) {
|
||||
flags |= FD_CLOEXEC;
|
||||
fcntl(fd, F_SETFD, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +140,7 @@ static void OpenPurgeFile(char const *fname, char const *mode)
|
||||
if (!PurgeFP) {
|
||||
fprintf(ErrFp, "Cannot open `%s' for writing: %s\n", DBufValue(&fname_buf), strerror(errno));
|
||||
}
|
||||
set_cloexec(fileno(PurgeFP));
|
||||
set_cloexec(PurgeFP);
|
||||
DBufFree(&fname_buf);
|
||||
}
|
||||
|
||||
@@ -340,7 +345,7 @@ int OpenFile(char const *fname)
|
||||
}
|
||||
} else {
|
||||
fp = fopen(fname, "r");
|
||||
if (fp) set_cloexec(fileno(fp));
|
||||
set_cloexec(fp);
|
||||
if (DebugFlag & DB_TRACE_FILES) {
|
||||
fprintf(ErrFp, "Reading `%s': Opening file on disk\n", fname);
|
||||
}
|
||||
@@ -360,7 +365,7 @@ int OpenFile(char const *fname)
|
||||
if (strcmp(fname, "-")) {
|
||||
fp = fopen(fname, "r");
|
||||
if (!fp || !CheckSafety()) return E_CANT_OPEN;
|
||||
set_cloexec(fileno(fp));
|
||||
set_cloexec(fp);
|
||||
if (PurgeMode) OpenPurgeFile(fname, "w");
|
||||
} else {
|
||||
fp = stdin;
|
||||
@@ -522,8 +527,14 @@ static int NextChainedFile(IncludeStruct *i)
|
||||
static int PopFile(void)
|
||||
{
|
||||
IncludeStruct *i;
|
||||
int j;
|
||||
|
||||
if (!Hush && NumIfs) Eprint("%s", ErrMsg[E_MISS_ENDIF]);
|
||||
if (!Hush && NumIfs) {
|
||||
Eprint("%s", ErrMsg[E_MISS_ENDIF]);
|
||||
for (j=NumIfs-1; j >=0; j--) {
|
||||
fprintf(ErrFp, "%s(%d): IF without ENDIF\n", FileName, IfLinenos[j]);
|
||||
}
|
||||
}
|
||||
if (!IStackPtr) return E_EOF;
|
||||
i = &IStack[IStackPtr-1];
|
||||
|
||||
@@ -543,6 +554,7 @@ static int PopFile(void)
|
||||
|
||||
LineNo = i->LineNo;
|
||||
IfFlags = i->IfFlags;
|
||||
memcpy(IfLinenos, i->IfLinenos, IF_NEST);
|
||||
NumIfs = i->NumIfs;
|
||||
CLine = i->CLine;
|
||||
fp = NULL;
|
||||
@@ -557,7 +569,7 @@ static int PopFile(void)
|
||||
if (strcmp(i->filename, "-")) {
|
||||
fp = fopen(i->filename, "r");
|
||||
if (!fp || !CheckSafety()) return E_CANT_OPEN;
|
||||
set_cloexec(fileno(fp));
|
||||
set_cloexec(fp);
|
||||
if (PurgeMode) OpenPurgeFile(i->filename, "a");
|
||||
} else {
|
||||
fp = stdin;
|
||||
@@ -867,6 +879,7 @@ static int IncludeCmd(char const *cmd)
|
||||
i->LineNo = LineNo;
|
||||
i->NumIfs = NumIfs;
|
||||
i->IfFlags = IfFlags;
|
||||
memcpy(i->IfLinenos, IfLinenos, IF_NEST);
|
||||
i->CLine = CLine;
|
||||
i->offset = -1L;
|
||||
i->chain = NULL;
|
||||
@@ -969,6 +982,7 @@ int IncludeFile(char const *fname)
|
||||
i->LineNo = LineNo;
|
||||
i->NumIfs = NumIfs;
|
||||
i->IfFlags = IfFlags;
|
||||
memcpy(i->IfLinenos, IfLinenos, IF_NEST);
|
||||
i->CLine = CLine;
|
||||
i->offset = -1L;
|
||||
i->chain = NULL;
|
||||
|
||||
750
src/funcs.c
750
src/funcs.c
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
||||
#define INIT(var, val) var
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
@@ -39,7 +40,7 @@ EXTERN FILE *ErrFp;
|
||||
#define IsLeapYear(y) (((y) % 4) ? 0 : ((!((y) % 100) && ((y) % 400)) ? 0 : 1 ))
|
||||
#define DaysInMonth(m, y) ((m) != 1 ? MonthDays[m] : 28 + IsLeapYear(y))
|
||||
|
||||
#define DestroyValue(x) (void) (((x).type == STR_TYPE && (x).v.str) ? (free((x).v.str),(x).v.str = NULL,(x).type = ERR_TYPE) : 0)
|
||||
#define DestroyValue(x) do { if ((x).type == STR_TYPE && (x).v.str) { free((x).v.str); (x).v.str = NULL; } (x).type = ERR_TYPE; } while (0)
|
||||
|
||||
EXTERN int DSEToday;
|
||||
EXTERN int RealToday;
|
||||
@@ -73,6 +74,9 @@ EXTERN INIT( int InfiniteDelta, 0);
|
||||
EXTERN INIT( int DefaultTDelta, 0);
|
||||
EXTERN INIT( int DeltaOverride, 0);
|
||||
EXTERN INIT( int RunDisabled, 0);
|
||||
EXTERN INIT( int ExpressionEvaluationDisabled, 0);
|
||||
EXTERN INIT( int ExpressionEvaluationTimeLimit, 0);
|
||||
EXTERN INIT( volatile sig_atomic_t ExpressionTimeLimitExceeded, 0);
|
||||
EXTERN INIT( int IgnoreOnce, 0);
|
||||
EXTERN INIT( int SortByTime, 0);
|
||||
EXTERN INIT( int SortByDate, 0);
|
||||
@@ -110,11 +114,12 @@ EXTERN INIT( int PurgeIncludeDepth, 0);
|
||||
EXTERN INIT( FILE *PurgeFP, NULL);
|
||||
EXTERN INIT( int NumIfs, 0);
|
||||
EXTERN INIT( unsigned int IfFlags, 0);
|
||||
EXTERN INIT( int IfLinenos[IF_NEST], {0});
|
||||
EXTERN INIT( int LastTrigValid, 0);
|
||||
EXTERN Trigger LastTrigger;
|
||||
EXTERN TimeTrig LastTimeTrig;
|
||||
EXTERN INIT( int LastTriggerDate, 0);
|
||||
EXTERN INIT( int LastTriggerTime, 0);
|
||||
EXTERN INIT( int LastTriggerTime, NO_TIME);
|
||||
EXTERN INIT( int ShouldCache, 0);
|
||||
EXTERN char const *CurLine;
|
||||
EXTERN INIT( int NumTriggered, 0);
|
||||
@@ -159,6 +164,9 @@ EXTERN DynamicBuffer Banner;
|
||||
EXTERN DynamicBuffer LineBuffer;
|
||||
EXTERN DynamicBuffer ExprBuf;
|
||||
|
||||
/* User-func recursion level */
|
||||
EXTERN INIT( unsigned int FuncRecursionLevel, 0);
|
||||
|
||||
extern int NumFullOmits, NumPartialOmits;
|
||||
|
||||
/* List of months */
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
#include "protos.h"
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#define HOUR 1080L
|
||||
#define DAY (24L*HOUR)
|
||||
#define WEEK (7L*DAY)
|
||||
|
||||
95
src/init.c
95
src/init.c
@@ -19,7 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "types.h"
|
||||
#include "globals.h"
|
||||
#include "protos.h"
|
||||
#include "expr.h"
|
||||
#include "err.h"
|
||||
|
||||
static int should_guess_terminal_background = 1;
|
||||
@@ -78,6 +77,7 @@ static void ProcessLongOption(char const *arg);
|
||||
* t = Display trigger dates
|
||||
* v = Dump variables at end
|
||||
* l = Display entire line in error messages
|
||||
* s = Display expression-parsing stack usage before exit
|
||||
* -e = Send messages normally sent to stderr to stdout instead
|
||||
* -z[n] = Daemon mode waking up every n (def 1) minutes.
|
||||
* -bn = Time format for cal (0, 1, or 2)
|
||||
@@ -604,6 +604,7 @@ void InitRemind(int argc, char const *argv[])
|
||||
case 'D':
|
||||
while (*arg) {
|
||||
switch(*arg++) {
|
||||
case 's': case 'S': DebugFlag |= DB_PARSE_EXPR; break;
|
||||
case 'e': case 'E': DebugFlag |= DB_ECHO_LINE; break;
|
||||
case 'x': case 'X': DebugFlag |= DB_PRTEXPR; break;
|
||||
case 't': case 'T': DebugFlag |= DB_PRTTRIG; break;
|
||||
@@ -804,6 +805,7 @@ void Usage(void)
|
||||
fprintf(ErrFp, " -m Start calendar with Monday rather than Sunday\n");
|
||||
fprintf(ErrFp, " -y Synthesize tags for tagless reminders\n");
|
||||
fprintf(ErrFp, " -j[n] Run in 'purge' mode. [n = INCLUDE depth]\n");
|
||||
fprintf(ErrFp, "\nRemind home page: %s\n", PACKAGE_URL);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif /* L_USAGE_OVERRIDE */
|
||||
@@ -923,7 +925,12 @@ static void InitializeVar(char const *str)
|
||||
r = 0;
|
||||
while (*str && *str != '=') {
|
||||
if (r < VAR_NAME_LEN) {
|
||||
varname[r++] = *str;
|
||||
if (isalpha(*str) || *str == '_' || (r > 0 && *str == '(') || (r == 0 && *str == '$') || (r > 0 && isdigit(*str))) {
|
||||
varname[r++] = *str;
|
||||
} else {
|
||||
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_ILLEGAL_CHAR]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (*str == '(') {
|
||||
/* Do a function definition if we see a paren */
|
||||
@@ -933,10 +940,28 @@ static void InitializeVar(char const *str)
|
||||
str++;
|
||||
}
|
||||
varname[r] = 0;
|
||||
if (!*str) {
|
||||
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_EQ]);
|
||||
if (!*varname) {
|
||||
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_VAR]);
|
||||
return;
|
||||
}
|
||||
if (!*str) {
|
||||
/* Setting a system var does require =expr on the commandline */
|
||||
if (*varname == '$') {
|
||||
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_EQ]);
|
||||
return;
|
||||
}
|
||||
val.type = INT_TYPE;
|
||||
val.v.val = 0;
|
||||
r = SetVar(varname, &val);
|
||||
if (!r) {
|
||||
r = PreserveVar(varname);
|
||||
}
|
||||
if (r) {
|
||||
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[r]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!*varname) {
|
||||
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_VAR]);
|
||||
return;
|
||||
@@ -989,13 +1014,65 @@ AddTrustedUser(char const *username)
|
||||
NumTrustedUsers++;
|
||||
}
|
||||
|
||||
static pid_t LimiterPid = (pid_t) -1;
|
||||
|
||||
void unlimit_execution_time(void)
|
||||
{
|
||||
if (LimiterPid != (pid_t) -1) {
|
||||
kill(LimiterPid, SIGTERM);
|
||||
LimiterPid = (pid_t) -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void limit_execution_time(int t)
|
||||
{
|
||||
pid_t parent = getpid();
|
||||
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
perror("fork");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pid > 0) {
|
||||
LimiterPid = pid;
|
||||
/* In the parent */
|
||||
return;
|
||||
}
|
||||
|
||||
/* In the child */
|
||||
time_t start = time(NULL);
|
||||
while(1) {
|
||||
sleep(1);
|
||||
if (kill(parent, 0) < 0) {
|
||||
/* Parent has probably exited */
|
||||
exit(0);
|
||||
}
|
||||
if (time(NULL) - start > t) {
|
||||
kill(parent, SIGXCPU);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ProcessLongOption(char const *arg)
|
||||
{
|
||||
int t;
|
||||
if (!strcmp(arg, "version")) {
|
||||
printf("%s\n", VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
if (sscanf(arg, "max-execution-time=%d", &t) == 1) {
|
||||
if (t < 0) {
|
||||
fprintf(ErrFp, "%s: --max-execution-time must be non-negative\n", ArgV[0]);
|
||||
return;
|
||||
}
|
||||
if (t > 0) {
|
||||
limit_execution_time(t);
|
||||
}
|
||||
return;
|
||||
}
|
||||
fprintf(ErrFp, "%s: Unknown long option --%s\n", ArgV[0], arg);
|
||||
}
|
||||
|
||||
@@ -1004,7 +1081,7 @@ guess_terminal_background(int *r, int *g, int *b)
|
||||
{
|
||||
int ttyfd;
|
||||
struct pollfd p;
|
||||
int rr, gg, bb;
|
||||
unsigned int rr, gg, bb;
|
||||
char buf[128];
|
||||
int n;
|
||||
|
||||
@@ -1070,9 +1147,9 @@ guess_terminal_background(int *r, int *g, int *b)
|
||||
/* Couldn't scan color codes */
|
||||
return;
|
||||
}
|
||||
*r = (rr >> 8) & 255;
|
||||
*g = (gg >> 8) & 255;
|
||||
*b = (bb >> 8) & 255;
|
||||
*r = (int) ((rr >> 8) & 255);
|
||||
*g = (int) ((gg >> 8) & 255);
|
||||
*b = (int) ((bb >> 8) & 255);
|
||||
}
|
||||
|
||||
static struct termios orig_termios;
|
||||
|
||||
@@ -145,7 +145,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Ok",
|
||||
"Puuttuva ']'",
|
||||
"Puuttuva lainausmerkki",
|
||||
"Liian monimutkainen lauseke - liikaa operaattoreita",
|
||||
"Liian monimutkainen lauseke",
|
||||
"Liian monimutkainen lauseke - liikaa operandeja",
|
||||
"Puuttuva ')'",
|
||||
"Määrittelemätön funktio",
|
||||
@@ -245,7 +245,11 @@ EXTERN char *ErrMsg[] =
|
||||
"No files matching *.rem",
|
||||
"String too long",
|
||||
"Time specified twice",
|
||||
"Cannot specify DURATION without specifying AT"
|
||||
"Cannot specify DURATION without specifying AT",
|
||||
"Odotettu viikonpäivän nimi",
|
||||
"Päällekkäinen argumentin nimi",
|
||||
"Lausekkeiden arviointi on poistettu käytöstä",
|
||||
|
||||
};
|
||||
#endif /* MK_GLOBALS */
|
||||
|
||||
@@ -271,12 +275,10 @@ void Usage(void)
|
||||
fprintf(ErrFp, " -o Älä noudata ONCE-lauseita\n");
|
||||
fprintf(ErrFp, " -t Laukaise kaikki viestit deltan arvosta välittämättä\n");
|
||||
fprintf(ErrFp, " -h Suppeat tulostukset\n");
|
||||
#ifdef HAVE_QUEUED
|
||||
fprintf(ErrFp, " -a Älä laukaise viestejä heti - lisää ne jonoon\n");
|
||||
fprintf(ErrFp, " -q Älä lisää viestejä jonoon\n");
|
||||
fprintf(ErrFp, " -f Laukaise viestit, pysy etualalla\n");
|
||||
fprintf(ErrFp, " -z[n] Käynnisty demonina, herätys n:n (5:n) minuutin välein\n");
|
||||
#endif
|
||||
fprintf(ErrFp, " -d... Virheenetsintä: e=echo x=expr-eval t=trig v=dumpvars l=showline\n");
|
||||
fprintf(ErrFp, " -e Ohjaa virhetulostus stdout-vuohon\n");
|
||||
fprintf(ErrFp, " -b[n] Ajan ilmaisu: 0=ap/ip, 1=24 tuntia, 2=ei aikoja\n");
|
||||
|
||||
@@ -119,7 +119,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Ok",
|
||||
"']' manquant",
|
||||
"Apostrophe manquant",
|
||||
"Expression trop complexe - trop d'opérateurs",
|
||||
"Expression trop complexe",
|
||||
"Expression trop complexe - trop d'opérandes",
|
||||
"')' manquante",
|
||||
"Fonction non-définie",
|
||||
@@ -219,7 +219,11 @@ EXTERN char *ErrMsg[] =
|
||||
"No files matching *.rem",
|
||||
"String too long",
|
||||
"Time specified twice",
|
||||
"Cannot specify DURATION without specifying AT"
|
||||
"Cannot specify DURATION without specifying AT",
|
||||
"Nom du jour de la semaine attendu",
|
||||
"Nom de l'argument en double",
|
||||
"L'évaluation de l'expression est désactivée",
|
||||
|
||||
};
|
||||
#endif /* MK_GLOBALS */
|
||||
|
||||
@@ -245,12 +249,10 @@ void Usage(void)
|
||||
fprintf(ErrFp, " -o Ignorer instructions ONCE\n");
|
||||
fprintf(ErrFp, " -t Déclencher tous les rappels peu importe le delta\n");
|
||||
fprintf(ErrFp, " -h Mode silencieux\n");
|
||||
#ifdef HAVE_QUEUED
|
||||
fprintf(ErrFp, " -a Ne pas déclencher les rappels minutés immédiatement - les mettre en file\n");
|
||||
fprintf(ErrFp, " -q Ne pas mettre les rappels minutés en file\n");
|
||||
fprintf(ErrFp, " -f Déclencher les rappels minutés immédiatement en restant en avant-plan\n");
|
||||
fprintf(ErrFp, " -z[n] Entrer en mode 'daemon', réveil chaque n (5) minutes\n");
|
||||
#endif
|
||||
fprintf(ErrFp, " -d... Debug: e=echo x=expr-eval t=trig v=dumpvars l=showline\n");
|
||||
fprintf(ErrFp, " -e Envoyer les messages de stderr à stdout\n");
|
||||
fprintf(ErrFp, " -b[n] Formats de l'heure pour le calendrier: 0=am/pm, 1=24hr, 2=aucun\n");
|
||||
|
||||
@@ -135,7 +135,7 @@ EXTERN char *ErrMsg[] =
|
||||
"OK",
|
||||
"Brakujący ']'",
|
||||
"Brakujący nawias",
|
||||
"Zbyt skomplikowane wyrażenie - za dużo operatorów",
|
||||
"Zbyt skomplikowane wyrażenie",
|
||||
"Zbyt skomplikowane wyrażenie - za dużo argumentów",
|
||||
"Brakujący ')'",
|
||||
"Nie zdefiniowana funkcja",
|
||||
@@ -235,7 +235,10 @@ EXTERN char *ErrMsg[] =
|
||||
"No files matching *.rem",
|
||||
"String too long",
|
||||
"Time specified twice",
|
||||
"Cannot specify DURATION without specifying AT"
|
||||
"Cannot specify DURATION without specifying AT",
|
||||
"Oczekiwana nazwa dnia tygodnia",
|
||||
"Zduplikowana nazwa argumentu",
|
||||
"Ocena wyrażeń jest wyłączona",
|
||||
};
|
||||
#endif /* MK_GLOBALS */
|
||||
|
||||
@@ -261,12 +264,10 @@ void Usage(void)
|
||||
fprintf(ErrFp, " -o Ignoruj instrukcje ONCE\n");
|
||||
fprintf(ErrFp, " -t Odpal wszystkie przyszłe przypomnienia niezależnie od delty\n");
|
||||
fprintf(ErrFp, " -h Praca bezszmerowa\n");
|
||||
#ifdef HAVE_QUEUED
|
||||
fprintf(ErrFp, " -a Nie odpalaj przyponień czasowych - kolejkuj je\n");
|
||||
fprintf(ErrFp, " -q Nie kolejkuj przyponień czasowych\n");
|
||||
fprintf(ErrFp, " -f Nie przechodź do pracy w tle\n");
|
||||
fprintf(ErrFp, " -z[n] Pracuj jako demon, budząc się co n (5) minut\n");
|
||||
#endif
|
||||
fprintf(ErrFp, " -d... Odpluskwianie: e=echo x=expr-eval t=trig v=dumpvars l=showline\n");
|
||||
fprintf(ErrFp, " -e Komunikaty o błędach skieruj na stdout\n");
|
||||
fprintf(ErrFp, " -b[n] Format czasu: 0=am/pm, 1=24godz., 2=żaden\n");
|
||||
|
||||
@@ -144,7 +144,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Ok",
|
||||
"Falta um ']'",
|
||||
"Falta uma aspa",
|
||||
"Expressao muito complexa - muitos operadores",
|
||||
"Expressao muito complexa",
|
||||
"Expressao muito complexa - muitos operandos",
|
||||
"Falta um ')'",
|
||||
"Funcao nao definida",
|
||||
@@ -244,7 +244,10 @@ EXTERN char *ErrMsg[] =
|
||||
"No files matching *.rem",
|
||||
"String too long",
|
||||
"Time specified twice",
|
||||
"Cannot specify DURATION without specifying AT"
|
||||
"Cannot specify DURATION without specifying AT",
|
||||
"Esperando nome do dia da semana",
|
||||
"Nome de argumento duplicado",
|
||||
"A avaliação da expressão está desabilitada",
|
||||
};
|
||||
#endif /* MK_GLOBALS */
|
||||
|
||||
@@ -270,12 +273,10 @@ void Usage(void)
|
||||
fprintf(ErrFp, " -o Ignora diretivas ONCE\n");
|
||||
fprintf(ErrFp, " -t Aciona todos os compromissos futuros, sem considerar o delta\n");
|
||||
fprintf(ErrFp, " -h Modo `Hush' - quieto\n");
|
||||
#ifdef HAVE_QUEUED
|
||||
fprintf(ErrFp, " -a Nao aciona compromissos com hora imediatamente - apenas coloca na fila\n");
|
||||
fprintf(ErrFp, " -q Nao coloca compromissos com hora na fila\n");
|
||||
fprintf(ErrFp, " -f Aciona compromissos com hora em modo foreground\n");
|
||||
fprintf(ErrFp, " -z[n] Modo `daemon', acordando a cada n (5) minutos.\n");
|
||||
#endif
|
||||
fprintf(ErrFp, " -d... Debug: e=echo x=expr-eval t=trigger v=dumpvars l=showline\n");
|
||||
fprintf(ErrFp, " -e Desvia mensagens normalmente enviadas a stderr para stdout\n");
|
||||
fprintf(ErrFp, " -b[n] Formato da hora para o cal: 0=am/pm, 1=24hr, 2=nenhum\n");
|
||||
|
||||
259
src/main.c
259
src/main.c
@@ -22,6 +22,11 @@
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
@@ -41,7 +46,6 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "protos.h"
|
||||
#include "expr.h"
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
|
||||
@@ -50,6 +54,38 @@ static void DoReminders(void);
|
||||
/* Macro for simplifying common block so as not to litter code */
|
||||
#define OUTPUT(c) do { if (output) { DBufPutc(output, c); } else { putchar(c); } } while(0)
|
||||
|
||||
void
|
||||
exitfunc(void)
|
||||
{
|
||||
/* Kill any execution-time-limiter process */
|
||||
unlimit_execution_time();
|
||||
|
||||
if (DebugFlag & DB_PARSE_EXPR) {
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
UnsetAllUserFuncs();
|
||||
print_expr_nodes_stats();
|
||||
}
|
||||
}
|
||||
|
||||
static void sigalrm(int sig)
|
||||
{
|
||||
UNUSED(sig);
|
||||
if (ExpressionEvaluationTimeLimit) {
|
||||
ExpressionTimeLimitExceeded = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void sigxcpu(int sig)
|
||||
{
|
||||
|
||||
UNUSED(sig);
|
||||
int r = write(STDERR_FILENO, "\n\nmax-execution-time exceeded.\n\n", 32);
|
||||
|
||||
/* Pretend to use r to avoid compiler warning */
|
||||
_exit(1 + (r-r));
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/***************************************************************/
|
||||
/** **/
|
||||
@@ -61,6 +97,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int pid;
|
||||
|
||||
struct sigaction act;
|
||||
|
||||
#ifdef HAVE_SETLOCALE
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
@@ -73,9 +111,30 @@ int main(int argc, char *argv[])
|
||||
ArgV = (char const **) argv;
|
||||
|
||||
InitRemind(argc, (char const **) argv);
|
||||
|
||||
act.sa_handler = sigalrm;
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_flags = SA_RESTART;
|
||||
if (sigaction(SIGALRM, &act, NULL) < 0) {
|
||||
fprintf(stderr, "%s: sigaction() failed: %s\n",
|
||||
argv[0], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
act.sa_handler = sigxcpu;
|
||||
act.sa_flags = SA_RESTART;
|
||||
sigemptyset(&act.sa_mask);
|
||||
if (sigaction(SIGXCPU, &act, NULL) < 0) {
|
||||
fprintf(stderr, "%s: sigaction() failed: %s\n",
|
||||
argv[0], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
DBufInit(&(LastTrigger.tags));
|
||||
ClearLastTriggers();
|
||||
|
||||
atexit(exitfunc);
|
||||
|
||||
if (DoCalendar || (DoSimpleCalendar && (!NextMode || PsCal))) {
|
||||
ProduceCalendar();
|
||||
return 0;
|
||||
@@ -99,7 +158,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (!Hush) {
|
||||
if (DestroyOmitContexts())
|
||||
if (DestroyOmitContexts(1))
|
||||
Eprint("%s", ErrMsg[E_PUSH_NOPOP]);
|
||||
if (!Daemon && !NextMode && !NumTriggered && !NumQueued) {
|
||||
printf("%s\n", ErrMsg[E_NOREMINDERS]);
|
||||
@@ -152,7 +211,7 @@ void
|
||||
PerIterationInit(void)
|
||||
{
|
||||
ClearGlobalOmits();
|
||||
DestroyOmitContexts();
|
||||
DestroyOmitContexts(1);
|
||||
DestroyVars(0);
|
||||
DefaultColorR = -1;
|
||||
DefaultColorG = -1;
|
||||
@@ -279,9 +338,11 @@ static void DoReminders(void)
|
||||
case T_Pop: r=PopOmitContext(&p); break;
|
||||
case T_Preserve: r=DoPreserve(&p); break;
|
||||
case T_Push: r=PushOmitContext(&p); break;
|
||||
case T_Expr: r = DoExpr(&p); break;
|
||||
case T_RemType: if (tok.val == RUN_TYPE) {
|
||||
r=DoRun(&p);
|
||||
} else {
|
||||
DestroyParser(&p);
|
||||
CreateParser(CurLine, &p);
|
||||
r=DoRem(&p);
|
||||
purge_handled = 1;
|
||||
@@ -290,10 +351,8 @@ static void DoReminders(void)
|
||||
|
||||
|
||||
/* If we don't recognize the command, do a REM by default */
|
||||
/* Note: Since the parser hasn't been used yet, we don't */
|
||||
/* need to destroy it here. */
|
||||
|
||||
default: CreateParser(CurLine, &p); purge_handled = 1; r=DoRem(&p); break;
|
||||
default: DestroyParser(&p); CreateParser(CurLine, &p); purge_handled = 1; r=DoRem(&p); break;
|
||||
|
||||
}
|
||||
if (r && (!Hush || r != E_RUN_DISABLED)) {
|
||||
@@ -451,6 +510,16 @@ int ParseChar(ParsePtr p, int *err, int peek)
|
||||
return *(p->pos++);
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert [[ to just a literal [ */
|
||||
if (*p->pos == BEG_OF_EXPR && *(p->pos+1) == BEG_OF_EXPR) {
|
||||
if (peek) {
|
||||
return *(p->pos+1);
|
||||
} else {
|
||||
p->pos++;
|
||||
return *(p->pos++);
|
||||
}
|
||||
}
|
||||
p->expr_happened = 1;
|
||||
p->pos++;
|
||||
r = EvalExpr(&(p->pos), &val, p);
|
||||
@@ -459,8 +528,15 @@ int ParseChar(ParsePtr p, int *err, int peek)
|
||||
DestroyParser(p);
|
||||
return 0;
|
||||
}
|
||||
while(*p->pos && (isempty(*p->pos))) {
|
||||
p->pos++;
|
||||
}
|
||||
if (*p->pos != END_OF_EXPR) {
|
||||
*err = E_MISS_END;
|
||||
if (*p->pos) {
|
||||
*err = E_PARSE_ERR;
|
||||
} else {
|
||||
*err = E_MISS_END;
|
||||
}
|
||||
DestroyParser(p);
|
||||
DestroyValue(val);
|
||||
return 0;
|
||||
@@ -575,6 +651,57 @@ int ParseIdentifier(ParsePtr p, DynamicBuffer *dbuf)
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* ParseExpr */
|
||||
/* */
|
||||
/* We are expecting an expression here. Parse it and return */
|
||||
/* the value node tree. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
expr_node * ParseExpr(ParsePtr p, int *r)
|
||||
{
|
||||
|
||||
int bracketed = 0;
|
||||
expr_node *node;
|
||||
|
||||
if (p->isnested) {
|
||||
*r = E_PARSE_ERR; /* Can't nest expressions */
|
||||
return NULL;
|
||||
}
|
||||
if (!p->pos) {
|
||||
*r = E_PARSE_ERR; /* Missing expression */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (isempty(*p->pos)) (p->pos)++;
|
||||
if (!*(p->pos)) {
|
||||
*r = E_EOLN;
|
||||
return NULL;
|
||||
}
|
||||
if (*p->pos == BEG_OF_EXPR) {
|
||||
(p->pos)++;
|
||||
bracketed = 1;
|
||||
}
|
||||
node = parse_expression(&(p->pos), r, NULL);
|
||||
if (*r) {
|
||||
return free_expr_tree(node);
|
||||
}
|
||||
|
||||
if (bracketed) {
|
||||
if (*p->pos != END_OF_EXPR) {
|
||||
if (*p->pos) {
|
||||
*r = E_PARSE_ERR;
|
||||
} else {
|
||||
*r = E_MISS_END;
|
||||
}
|
||||
return free_expr_tree(node);
|
||||
}
|
||||
(p->pos)++;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* EvaluateExpr */
|
||||
@@ -586,21 +713,22 @@ int ParseIdentifier(ParsePtr p, DynamicBuffer *dbuf)
|
||||
int EvaluateExpr(ParsePtr p, Value *v)
|
||||
{
|
||||
|
||||
int bracketed = 0;
|
||||
int r;
|
||||
int nonconst = 0;
|
||||
expr_node *node = ParseExpr(p, &r);
|
||||
|
||||
if (p->isnested) return E_PARSE_ERR; /* Can't nest expressions */
|
||||
while (isempty(*p->pos)) (p->pos)++;
|
||||
if (!p->pos) return E_PARSE_ERR; /* Missing expression */
|
||||
if (*p->pos == BEG_OF_EXPR) {
|
||||
(p->pos)++;
|
||||
bracketed = 1;
|
||||
if (r != OK) {
|
||||
return r;
|
||||
}
|
||||
r = EvalExpr(&(p->pos), v, p);
|
||||
if (!node) {
|
||||
return E_SWERR;
|
||||
}
|
||||
|
||||
r = evaluate_expression(node, NULL, v, &nonconst);
|
||||
free_expr_tree(node);
|
||||
if (r) return r;
|
||||
if (bracketed) {
|
||||
if (*p->pos != END_OF_EXPR) return E_MISS_END;
|
||||
(p->pos)++;
|
||||
if (nonconst) {
|
||||
p->nonconst_expr = 1;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
@@ -636,36 +764,36 @@ void Wprint(char const *fmt, ...)
|
||||
void Eprint(char const *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char const *fname;
|
||||
|
||||
/* Check if more than one error msg. from this line */
|
||||
if (!FreshLine && !ShowAllErrors) return;
|
||||
|
||||
if (FreshLine && FileName) {
|
||||
FreshLine = 0;
|
||||
if (strcmp(FileName, "-")) {
|
||||
(void) fprintf(ErrFp, "%s(%d): ", FileName, LineNo);
|
||||
if (print_callstack(ErrFp)) {
|
||||
(void) fprintf(ErrFp, ": ");
|
||||
}
|
||||
} else {
|
||||
(void) fprintf(ErrFp, "-stdin-(%d): ", LineNo);
|
||||
if (print_callstack(ErrFp)) {
|
||||
(void) fprintf(ErrFp, ": ");
|
||||
}
|
||||
}
|
||||
if (DebugFlag & DB_PRTLINE) OutputLine(ErrFp);
|
||||
} else if (FileName) {
|
||||
fprintf(ErrFp, " ");
|
||||
if (print_callstack(ErrFp)) {
|
||||
(void) fprintf(ErrFp, ": ");
|
||||
}
|
||||
if (!FileName) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(FileName, "-")) {
|
||||
fname = FileName;
|
||||
} else {
|
||||
fname = "-stdin-";
|
||||
}
|
||||
if (FreshLine) {
|
||||
(void) fprintf(ErrFp, "%s(%d): ", fname, LineNo);
|
||||
} else {
|
||||
fprintf(ErrFp, " ");
|
||||
}
|
||||
va_start(argptr, fmt);
|
||||
(void) vfprintf(ErrFp, fmt, argptr);
|
||||
(void) fputc('\n', ErrFp);
|
||||
va_end(argptr);
|
||||
return;
|
||||
if (print_callstack(ErrFp)) {
|
||||
(void) fprintf(ErrFp, "\n");
|
||||
}
|
||||
if (FreshLine) {
|
||||
if (DebugFlag & DB_PRTLINE) OutputLine(ErrFp);
|
||||
}
|
||||
FreshLine = 0;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
@@ -834,6 +962,7 @@ int DoIf(ParsePtr p)
|
||||
}
|
||||
}
|
||||
|
||||
IfLinenos[NumIfs] = LineNo;
|
||||
NumIfs++;
|
||||
IfFlags &= ~(IF_MASK << (2*NumIfs - 2));
|
||||
IfFlags |= syndrome << (2 * NumIfs - 2);
|
||||
@@ -898,7 +1027,7 @@ int DoIfTrig(ParsePtr p)
|
||||
if ((size_t) NumIfs >= IF_NEST) return E_NESTED_IF;
|
||||
if (ShouldIgnoreLine()) syndrome = IF_TRUE | BEFORE_ELSE;
|
||||
else {
|
||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) return r;
|
||||
if ( (r=ParseRem(p, &trig, &tim)) ) return r;
|
||||
if (trig.typ != NO_TYPE) return E_PARSE_ERR;
|
||||
dse = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1);
|
||||
if (r) {
|
||||
@@ -1016,6 +1145,12 @@ int DoDebug(ParsePtr p)
|
||||
else DebugFlag &= ~DB_ECHO_LINE;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
case 'S':
|
||||
if (val) DebugFlag |= DB_PARSE_EXPR;
|
||||
else DebugFlag &= ~DB_PARSE_EXPR;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
case 'X':
|
||||
if (val) DebugFlag |= DB_PRTEXPR;
|
||||
@@ -1081,7 +1216,7 @@ int DoBanner(ParsePtr p)
|
||||
}
|
||||
}
|
||||
DBufFree(&Banner);
|
||||
|
||||
|
||||
err = DBufPuts(&Banner, DBufValue(&buf));
|
||||
DBufFree(&buf);
|
||||
return err;
|
||||
@@ -1093,7 +1228,6 @@ int DoBanner(ParsePtr p)
|
||||
/* */
|
||||
/* Enable or disable the RUN command under program control */
|
||||
/* */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int DoRun(ParsePtr p)
|
||||
{
|
||||
@@ -1120,6 +1254,38 @@ int DoRun(ParsePtr p)
|
||||
return VerifyEoln(p);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* DoExpr */
|
||||
/* */
|
||||
/* Enable or disable expression evaluation */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int DoExpr(ParsePtr p)
|
||||
{
|
||||
int r;
|
||||
|
||||
DynamicBuffer buf;
|
||||
DBufInit(&buf);
|
||||
|
||||
if ( (r=ParseToken(p, &buf)) ) return r;
|
||||
|
||||
/* Only allow EXPR ON in top-level script */
|
||||
if (! StrCmpi(DBufValue(&buf), "ON")) {
|
||||
if (TopLevel()) ExpressionEvaluationDisabled = 0;
|
||||
}
|
||||
/* But allow EXPR OFF anywhere */
|
||||
else if (! StrCmpi(DBufValue(&buf), "OFF"))
|
||||
ExpressionEvaluationDisabled = 1;
|
||||
else {
|
||||
DBufFree(&buf);
|
||||
return E_PARSE_ERR;
|
||||
}
|
||||
DBufFree(&buf);
|
||||
|
||||
return VerifyEoln(p);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* DoFlush */
|
||||
@@ -1666,7 +1832,9 @@ System(char const *cmd, int is_queued)
|
||||
pid_t kid;
|
||||
int fd;
|
||||
int status;
|
||||
int do_exit = 0;
|
||||
if (is_queued && IsServerMode()) {
|
||||
do_exit = 1;
|
||||
/* Server mode... redirect stdin and stdout to /dev/null */
|
||||
kid = fork();
|
||||
if (kid == (pid_t) -1) {
|
||||
@@ -1688,14 +1856,17 @@ System(char const *cmd, int is_queued)
|
||||
}
|
||||
} else {
|
||||
/* In the parent */
|
||||
while (waitpid(kid, &status, 0) != kid) {
|
||||
continue;
|
||||
}
|
||||
while (waitpid(kid, &status, 0) != kid) /* continue */ ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* This is the child process or original if we never forked */
|
||||
r = system(cmd);
|
||||
if (do_exit) {
|
||||
/* In the child process, so exit! */
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (r == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
10
src/md5.h
10
src/md5.h
@@ -6,6 +6,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
typedef uint32_t uint32;
|
||||
#else
|
||||
#if SIZEOF_UNSIGNED_INT == 4
|
||||
typedef unsigned int uint32;
|
||||
#elif SIZEOF_UNSIGNED_LONG == 4
|
||||
@@ -13,6 +17,7 @@ typedef unsigned long uint32;
|
||||
#else
|
||||
# error Could not find a 32-bit integer type
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct MD5Context {
|
||||
uint32 buf[4];
|
||||
@@ -26,9 +31,4 @@ void MD5Update(struct MD5Context *context, unsigned char const *buf,
|
||||
void MD5Final(unsigned char digest[16], struct MD5Context *context);
|
||||
void MD5Transform(uint32 buf[4], uint32 const in[16]);
|
||||
|
||||
/*
|
||||
* This is needed to make RSAREF happy on some MS-DOS compilers.
|
||||
*/
|
||||
typedef struct MD5Context MD5_CTX;
|
||||
|
||||
#endif /* !MD5_H */
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
#include <time.h>
|
||||
#include "types.h"
|
||||
#include "protos.h"
|
||||
#include "expr.h"
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
|
||||
|
||||
32
src/omit.c
32
src/omit.c
@@ -14,15 +14,14 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "types.h"
|
||||
#include "protos.h"
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
#include "expr.h"
|
||||
|
||||
static int BexistsIntArray (int array[], int num, int key);
|
||||
static int BexistsIntArray (int const array[], int num, int key);
|
||||
static void InsertIntoSortedArray (int *array, int num, int key);
|
||||
|
||||
/* Arrays for the global omits */
|
||||
@@ -37,6 +36,8 @@ int NumFullOmits, NumPartialOmits;
|
||||
/* The structure for saving and restoring OMIT contexts */
|
||||
typedef struct omitcontext {
|
||||
struct omitcontext *next;
|
||||
char *filename;
|
||||
int lineno;
|
||||
int numfull, numpart;
|
||||
int *fullsave;
|
||||
int *partsave;
|
||||
@@ -79,19 +80,25 @@ int DoClear(ParsePtr p)
|
||||
/* */
|
||||
/* Free all the memory used by saved OMIT contexts. */
|
||||
/* As a side effect, return the number of OMIT contexts */
|
||||
/* destroyed. */
|
||||
/* destroyed. If print_unmatched is true, print an error for */
|
||||
/* each undestroyed OMIT contect */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int DestroyOmitContexts(void)
|
||||
int DestroyOmitContexts(int print_unmatched)
|
||||
{
|
||||
OmitContext *c = SavedOmitContexts;
|
||||
OmitContext *d;
|
||||
int num = 0;
|
||||
|
||||
while (c) {
|
||||
if (print_unmatched) {
|
||||
Wprint("Unmatched PUSH-OMIT-CONTEXT at %s(%d)",
|
||||
c->filename, c->lineno);
|
||||
}
|
||||
num++;
|
||||
if (c->fullsave) free(c->fullsave);
|
||||
if (c->partsave) free(c->partsave);
|
||||
if (c->filename) free(c->filename);
|
||||
d = c->next;
|
||||
free(c);
|
||||
c = d;
|
||||
@@ -116,16 +123,28 @@ int PushOmitContext(ParsePtr p)
|
||||
context = NEW(OmitContext);
|
||||
if (!context) return E_NO_MEM;
|
||||
|
||||
if (FileName) {
|
||||
context->filename = StrDup(FileName);
|
||||
} else {
|
||||
context->filename = StrDup("");
|
||||
}
|
||||
if (!context->filename) {
|
||||
free(context);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
context->lineno = LineNo;
|
||||
context->numfull = NumFullOmits;
|
||||
context->numpart = NumPartialOmits;
|
||||
context->weekdaysave = WeekdayOmits;
|
||||
context->fullsave = malloc(NumFullOmits * sizeof(int));
|
||||
if (NumFullOmits && !context->fullsave) {
|
||||
free(context->filename);
|
||||
free(context);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
context->partsave = malloc(NumPartialOmits * sizeof(int));
|
||||
if (NumPartialOmits && !context->partsave) {
|
||||
free(context->filename);
|
||||
free(context->fullsave);
|
||||
free(context);
|
||||
return E_NO_MEM;
|
||||
@@ -175,6 +194,7 @@ int PopOmitContext(ParsePtr p)
|
||||
/* Free memory used by the saved context */
|
||||
if (c->partsave) free(c->partsave);
|
||||
if (c->fullsave) free(c->fullsave);
|
||||
if (c->filename) free(c->filename);
|
||||
free(c);
|
||||
|
||||
return VerifyEoln(p);
|
||||
@@ -251,7 +271,7 @@ int IsOmitted(int dse, int localomit, char const *omitfunc, int *omit)
|
||||
/* element is found, 0 otherwise. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
static int BexistsIntArray(int array[], int num, int key)
|
||||
static int BexistsIntArray(int const array[], int num, int key)
|
||||
{
|
||||
int top=num-1, bot=0, mid;
|
||||
|
||||
|
||||
64
src/protos.h
64
src/protos.h
@@ -13,6 +13,18 @@
|
||||
/* Suppress unused variable warnings */
|
||||
#define UNUSED(x) (void) x
|
||||
|
||||
#ifdef HAVE_STRDUP
|
||||
#define StrDup strdup
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRNCASECMP
|
||||
#define StrinCmp strncasecmp
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRCASECMP
|
||||
#define StrCmpi strcasecmp
|
||||
#endif
|
||||
|
||||
/* Define a string assignment macro - be careful!!! */
|
||||
#define STRSET(x, str) { if (x) free(x); (x) = StrDup(str); }
|
||||
|
||||
@@ -31,22 +43,30 @@
|
||||
int CallUserFunc (char const *name, int nargs, ParsePtr p);
|
||||
int DoFset (ParsePtr p);
|
||||
int DoFunset (ParsePtr p);
|
||||
void UnsetAllUserFuncs(void);
|
||||
void ProduceCalendar (void);
|
||||
char const *SimpleTime (int tim);
|
||||
char const *CalendarTime (int tim, int duration);
|
||||
int DoRem (ParsePtr p);
|
||||
int DoFlush (ParsePtr p);
|
||||
void DoExit (ParsePtr p);
|
||||
int ParseRem (ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals);
|
||||
int ParseRem (ParsePtr s, Trigger *trig, TimeTrig *tim);
|
||||
int TriggerReminder (ParsePtr p, Trigger *t, TimeTrig *tim, int dse, int is_queued, DynamicBuffer *output);
|
||||
int ShouldTriggerReminder (Trigger *t, TimeTrig *tim, int dse, int *err);
|
||||
int DoSubst (ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, int mode);
|
||||
int DoSubstFromString (char const *source, DynamicBuffer *dbuf, int dse, int tim);
|
||||
int ParseLiteralDate (char const **s, int *dse, int *tim);
|
||||
int ParseLiteralTime (char const **s, int *tim);
|
||||
expr_node *parse_expression(char const **e, int *r, Var *locals);
|
||||
|
||||
int evaluate_expression(expr_node *node, Value *locals, Value *ans, int *nonconst);
|
||||
int evaluate_expr_node(expr_node *node, Value *locals, Value *ans, int *nonconst);
|
||||
void print_expr_tree(expr_node *node, FILE *fp);
|
||||
void unlimit_execution_time(void);
|
||||
expr_node *free_expr_tree(expr_node *node);
|
||||
int EvalExpr (char const **e, Value *v, ParsePtr p);
|
||||
int DoCoerce (char type, Value *v);
|
||||
void PrintValue (Value *v, FILE *fp);
|
||||
char const *PrintValue (Value *v, FILE *fp);
|
||||
int CopyValue (Value *dest, const Value *src);
|
||||
int ReadLine (void);
|
||||
int OpenFile (char const *fname);
|
||||
@@ -65,8 +85,9 @@ int JulianToGregorianOffset(int y, int m);
|
||||
int ParseChar (ParsePtr p, int *err, int peek);
|
||||
int ParseToken (ParsePtr p, DynamicBuffer *dbuf);
|
||||
int ParseIdentifier (ParsePtr p, DynamicBuffer *dbuf);
|
||||
expr_node * ParseExpr(ParsePtr p, int *r);
|
||||
void print_expr_nodes_stats(void);
|
||||
int EvaluateExpr (ParsePtr p, Value *v);
|
||||
int Evaluate (char const **s, Var *locals, ParsePtr p);
|
||||
int FnPopValStack (Value *val);
|
||||
void Eprint (char const *fmt, ...);
|
||||
void Wprint (char const *fmt, ...);
|
||||
@@ -86,10 +107,11 @@ int VerifyEoln (ParsePtr p);
|
||||
int DoDebug (ParsePtr p);
|
||||
int DoBanner (ParsePtr p);
|
||||
int DoRun (ParsePtr p);
|
||||
int DoExpr (ParsePtr p);
|
||||
int DoErrMsg (ParsePtr p);
|
||||
int ClearGlobalOmits (void);
|
||||
int DoClear (ParsePtr p);
|
||||
int DestroyOmitContexts (void);
|
||||
int DestroyOmitContexts (int print_unmatched);
|
||||
int PushOmitContext (ParsePtr p);
|
||||
int PopOmitContext (ParsePtr p);
|
||||
int IsOmitted (int dse, int localomit, char const *omitfunc, int *omit);
|
||||
@@ -103,13 +125,26 @@ int ComputeTrigger (int today, Trigger *trig, TimeTrig *tim, int *err, int save_
|
||||
int ComputeTriggerNoAdjustDuration (int today, Trigger *trig, TimeTrig *tim, int *err, int save_in_globals, int duration_days);
|
||||
int AdjustTriggerForDuration(int today, int r, Trigger *trig, TimeTrig *tim, int save_in_globals);
|
||||
char *StrnCpy (char *dest, char const *source, int n);
|
||||
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
int StrinCmp (char const *s1, char const *s2, int n);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
char *StrDup (char const *s);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
int StrCmpi (char const *s1, char const *s2);
|
||||
#endif
|
||||
|
||||
void strtolower(char *s);
|
||||
|
||||
Var *FindVar (char const *str, int create);
|
||||
SysVar *FindSysVar (char const *name);
|
||||
int DeleteVar (char const *str);
|
||||
int SetVar (char const *str, Value *val);
|
||||
int GetVarValue (char const *str, Value *val, Var *locals, ParsePtr p);
|
||||
int SetVar (char const *str, Value const *val);
|
||||
int GetVarValue (char const *str, Value *val);
|
||||
int DoSet (Parser *p);
|
||||
int DoUnset (Parser *p);
|
||||
int DoDump (ParsePtr p);
|
||||
@@ -122,10 +157,10 @@ int DoMsgCommand (char const *cmd, char const *msg, int is_queued);
|
||||
int ParseNonSpaceChar (ParsePtr p, int *err, int peek);
|
||||
unsigned int HashVal (char const *str);
|
||||
int DateOK (int y, int m, int d);
|
||||
Operator *FindOperator (char const *name, Operator where[], int num);
|
||||
BuiltinFunc *FindFunc (char const *name, BuiltinFunc where[], int num);
|
||||
BuiltinFunc *FindBuiltinFunc (char const *name);
|
||||
int InsertIntoSortBuffer (int dse, int tim, char const *body, int typ, int prio);
|
||||
void IssueSortedReminders (void);
|
||||
UserFunc *FindUserFunc(char const *name);
|
||||
int UserFuncExists (char const *fn);
|
||||
void DSEToHeb (int dse, int *hy, int *hm, int *hd);
|
||||
int HebNameToNum (char const *mname);
|
||||
@@ -174,15 +209,18 @@ int AddGlobalOmit(int dse);
|
||||
void set_lat_and_long_from_components(void);
|
||||
void set_components_from_lat_and_long(void);
|
||||
|
||||
void DebugExitFunc(void);
|
||||
|
||||
int GetTerminalBackground(void);
|
||||
|
||||
char const *get_day_name(int wkday);
|
||||
char const *get_month_name(int mon);
|
||||
|
||||
void set_cloexec(int fd);
|
||||
void set_cloexec(FILE *fp);
|
||||
int push_call(char const *filename, char const *func, int lineno);
|
||||
void clear_callstack(void);
|
||||
int print_callstack(FILE *fp);
|
||||
int have_callstack(void);
|
||||
void pop_call(void);
|
||||
void FixSpecialType(Trigger *trig);
|
||||
void WriteJSONTrigger(Trigger const *t, int include_tags, int today);
|
||||
@@ -193,3 +231,11 @@ void WriteJSONTimeTrigger(TimeTrig const *tt);
|
||||
#include <wchar.h>
|
||||
void PutWideChar(wchar_t const wc, DynamicBuffer *output);
|
||||
#endif
|
||||
|
||||
/* These functions are in utils.c and are used to detect overflow
|
||||
in various arithmetic operators. They have to be in separate
|
||||
functions with extern linkage to defeat compiler optimizations
|
||||
that would otherwise break the overflow checks. */
|
||||
extern int _private_mul_overflow(int a, int b);
|
||||
extern int _private_add_overflow(int a, int b);
|
||||
extern int _private_sub_overflow(int a, int b);
|
||||
|
||||
141
src/queue.c
141
src/queue.c
@@ -34,7 +34,6 @@
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
#include "protos.h"
|
||||
#include "expr.h"
|
||||
|
||||
#undef USE_INOTIFY
|
||||
#if defined(HAVE_SYS_INOTIFY_H) && defined(HAVE_INOTIFY_INIT1)
|
||||
@@ -66,6 +65,7 @@ typedef struct queuedrem {
|
||||
char sched[VAR_NAME_LEN+1];
|
||||
Trigger t;
|
||||
TimeTrig tt;
|
||||
int red, green, blue;
|
||||
} QueuedRem;
|
||||
|
||||
/* Global variables */
|
||||
@@ -79,7 +79,7 @@ static void CheckInitialFile (void);
|
||||
static int CalculateNextTime (QueuedRem *q);
|
||||
static QueuedRem *FindNextReminder (void);
|
||||
static int CalculateNextTimeUsingSched (QueuedRem *q);
|
||||
static void DaemonWait (struct timeval *sleep_tv);
|
||||
static void ServerWait (struct timeval *sleep_tv);
|
||||
static void reread (void);
|
||||
static void PrintQueue(void);
|
||||
static char const *QueueFilename(char const *fname);
|
||||
@@ -153,6 +153,34 @@ static char const *QueueFilename(char const *fname)
|
||||
return elem->fname;
|
||||
}
|
||||
|
||||
static void del_reminder(QueuedRem *qid)
|
||||
{
|
||||
QueuedRem *q = QueueHead;
|
||||
QueuedRem *next;
|
||||
if (!q) {
|
||||
return;
|
||||
}
|
||||
if (q == qid) {
|
||||
QueueHead = q->next;
|
||||
if (q->text) free((void *) q->text);
|
||||
free(q);
|
||||
return;
|
||||
}
|
||||
while(q->next) {
|
||||
next = q->next;
|
||||
if (q->next == qid) {
|
||||
q->next = q->next->next;
|
||||
if (next->text) free((void *) next->text);
|
||||
free(next);
|
||||
return;
|
||||
}
|
||||
q = q->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void del_reminder_ul(unsigned long qid) {
|
||||
del_reminder((QueuedRem *) qid);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
@@ -178,6 +206,9 @@ int QueueReminder(ParsePtr p, Trigger *trig,
|
||||
if (!qelem) {
|
||||
return E_NO_MEM;
|
||||
}
|
||||
qelem->red = DefaultColorR;
|
||||
qelem->green = DefaultColorG;
|
||||
qelem->blue = DefaultColorB;
|
||||
qelem->text = StrDup(p->pos); /* Guaranteed that parser is not nested. */
|
||||
if (!qelem->text) {
|
||||
free(qelem);
|
||||
@@ -277,6 +308,13 @@ void HandleQueuedReminders(void)
|
||||
struct timeval tv;
|
||||
struct timeval sleep_tv;
|
||||
struct sigaction sa;
|
||||
char qid[64];
|
||||
|
||||
/* Disable any potential pending SIGALRMs */
|
||||
alarm(0);
|
||||
|
||||
/* Un-limit execution time */
|
||||
unlimit_execution_time();
|
||||
|
||||
/* Turn off sorting -- otherwise, TriggerReminder has no effect! */
|
||||
SortByDate = 0;
|
||||
@@ -321,16 +359,15 @@ void HandleQueuedReminders(void)
|
||||
|
||||
if (ShouldFork || Daemon) {
|
||||
sa.sa_handler = SigIntHandler;
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
(void) sigaction(SIGINT, &sa, NULL);
|
||||
sa.sa_handler = SigContHandler;
|
||||
(void) sigaction(SIGCONT, &sa, NULL);
|
||||
}
|
||||
|
||||
#ifdef USE_INOTIFY
|
||||
if (IsServerMode()) {
|
||||
watch_fd = setup_inotify_watch();
|
||||
}
|
||||
watch_fd = setup_inotify_watch();
|
||||
#endif
|
||||
/* Sit in a loop, issuing reminders when necessary */
|
||||
while(1) {
|
||||
@@ -357,8 +394,6 @@ void HandleQueuedReminders(void)
|
||||
SleepTime = 60*Daemon;
|
||||
}
|
||||
|
||||
/* Wake up once a minute to recalibrate sleep time in
|
||||
case of laptop hibernation */
|
||||
if (IsServerMode()) {
|
||||
/* Wake up on the next exact minute */
|
||||
gettimeofday(&tv, NULL);
|
||||
@@ -369,7 +404,9 @@ void HandleQueuedReminders(void)
|
||||
} else {
|
||||
sleep_tv.tv_usec = 0;
|
||||
}
|
||||
DaemonWait(&sleep_tv);
|
||||
ServerWait(&sleep_tv);
|
||||
/* A DEL command might have deleted our queued reminder! */
|
||||
q = FindNextReminder();
|
||||
} else {
|
||||
sleep(SleepTime);
|
||||
}
|
||||
@@ -387,7 +424,9 @@ void HandleQueuedReminders(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (Daemon > 0 && SleepTime) CheckInitialFile();
|
||||
if (Daemon > 0 && SleepTime) {
|
||||
CheckInitialFile();
|
||||
}
|
||||
|
||||
if (Daemon && !q) {
|
||||
if (IsServerMode()) {
|
||||
@@ -417,6 +456,8 @@ void HandleQueuedReminders(void)
|
||||
if (IsServerMode() && q->typ != RUN_TYPE) {
|
||||
if (DaemonJSON) {
|
||||
printf("{\"response\":\"reminder\",");
|
||||
snprintf(qid, sizeof(qid), "%lx", (unsigned long) q);
|
||||
PrintJSONKeyPairString("qid", qid);
|
||||
PrintJSONKeyPairString("ttime", SimpleTimeNoSpace(q->tt.ttime));
|
||||
PrintJSONKeyPairString("now", SimpleTimeNoSpace(MinutesPastMidnight(1)));
|
||||
PrintJSONKeyPairString("tags", DBufValue(&q->t.tags));
|
||||
@@ -436,10 +477,15 @@ void HandleQueuedReminders(void)
|
||||
and trigtime() work correctly */
|
||||
SaveAllTriggerInfo(&(q->t), &(q->tt), DSEToday, q->tt.ttime, 1);
|
||||
FileName = (char *) q->fname;
|
||||
DefaultColorR = q->red;
|
||||
DefaultColorG = q->green;
|
||||
DefaultColorB = q->blue;
|
||||
/* Make a COPY of q->t because TriggerReminder can change q->t.typ */
|
||||
Trigger tcopy = q->t;
|
||||
if (DaemonJSON) {
|
||||
DynamicBuffer out;
|
||||
DBufInit(&out);
|
||||
(void) TriggerReminder(&p, &q->t, &q->tt, DSEToday, 1, &out);
|
||||
(void) TriggerReminder(&p, &tcopy, &q->tt, DSEToday, 1, &out);
|
||||
if (q->typ != RUN_TYPE) {
|
||||
printf("\"body\":\"");
|
||||
chomp(&out);
|
||||
@@ -448,7 +494,7 @@ void HandleQueuedReminders(void)
|
||||
}
|
||||
DBufFree(&out);
|
||||
} else {
|
||||
(void) TriggerReminder(&p, &q->t, &q->tt, DSEToday, 1, NULL);
|
||||
(void) TriggerReminder(&p, &tcopy, &q->tt, DSEToday, 1, NULL);
|
||||
}
|
||||
FileName = NULL;
|
||||
if (IsServerMode() && !DaemonJSON && q->typ != RUN_TYPE) {
|
||||
@@ -461,7 +507,6 @@ void HandleQueuedReminders(void)
|
||||
/* Calculate the next trigger time */
|
||||
q->tt.nexttime = CalculateNextTime(q);
|
||||
|
||||
/* If it's dequeued, update num_queued */
|
||||
if (q->tt.nexttime != NO_TIME) {
|
||||
/* If trigger time is way in the past because computer has been
|
||||
suspended or hibernated, remove from queue */
|
||||
@@ -471,9 +516,13 @@ void HandleQueuedReminders(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* If we have dequeued a reminder, update controlling process */
|
||||
if (q->tt.nexttime == NO_TIME && IsServerMode()) {
|
||||
print_num_queued();
|
||||
/* If queued reminder has expired, actually remove it from queue
|
||||
and update status */
|
||||
if (q->tt.nexttime == NO_TIME) {
|
||||
del_reminder(q);
|
||||
if (IsServerMode()) {
|
||||
print_num_queued();
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
@@ -594,7 +643,25 @@ static void CheckInitialFile(void)
|
||||
/* If date has rolled around, or file has changed, spawn a new version. */
|
||||
time_t tim = FileModTime;
|
||||
int y, m, d;
|
||||
#ifdef USE_INOTIFY
|
||||
char buf[sizeof(struct inotify_event) + NAME_MAX + 1];
|
||||
int n;
|
||||
#endif
|
||||
|
||||
#ifdef USE_INOTIFY
|
||||
/* If there are any inotify events, reread */
|
||||
if (watch_fd >= 0) {
|
||||
while(1) {
|
||||
n = read(watch_fd, buf, sizeof(buf));
|
||||
if (n < 0 && errno == EINTR) continue;
|
||||
if (n > 0) {
|
||||
close(watch_fd);
|
||||
reread();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (stat(InitialFile, &StatBuf) == 0) tim = StatBuf.st_mtime;
|
||||
if (tim != FileModTime ||
|
||||
RealToday != SystemDate(&y, &m, &d)) {
|
||||
@@ -676,6 +743,7 @@ json_queue(QueuedRem const *q)
|
||||
printf("{\"response\":\"queue\",\"queue\":");
|
||||
}
|
||||
printf("[");
|
||||
char idbuf[64];
|
||||
while(q) {
|
||||
if (q->tt.nexttime == NO_TIME) {
|
||||
q = q->next;
|
||||
@@ -688,6 +756,8 @@ json_queue(QueuedRem const *q)
|
||||
printf("{");
|
||||
WriteJSONTrigger(&(q->t), 1, DSEToday);
|
||||
WriteJSONTimeTrigger(&(q->tt));
|
||||
snprintf(idbuf, sizeof(idbuf), "%lx", (unsigned long) q);
|
||||
PrintJSONKeyPairString("qid", idbuf);
|
||||
PrintJSONKeyPairInt("rundisabled", q->RunDisabled);
|
||||
PrintJSONKeyPairInt("ntrig", q->ntrig);
|
||||
PrintJSONKeyPairString("filename", q->fname);
|
||||
@@ -701,7 +771,10 @@ json_queue(QueuedRem const *q)
|
||||
case PS_TYPE: PrintJSONKeyPairString("type", "PS_TYPE"); break;
|
||||
case PSF_TYPE: PrintJSONKeyPairString("type", "PSF_TYPE"); break;
|
||||
case MSF_TYPE: PrintJSONKeyPairString("type", "MSF_TYPE"); break;
|
||||
case PASSTHRU_TYPE: PrintJSONKeyPairString("type", "PASSTHRU_TYPE"); break;
|
||||
case PASSTHRU_TYPE:
|
||||
PrintJSONKeyPairString("type", "PASSTHRU_TYPE");
|
||||
PrintJSONKeyPairString("passthru", q->passthru);
|
||||
break;
|
||||
default: PrintJSONKeyPairString("type", "?"); break;
|
||||
}
|
||||
|
||||
@@ -727,12 +800,12 @@ json_queue(QueuedRem const *q)
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* DaemonWait */
|
||||
/* ServerWait */
|
||||
/* */
|
||||
/* Sleep or read command from stdin in "daemon -1" mode */
|
||||
/* Sleep or read command from stdin in server mode */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
static void DaemonWait(struct timeval *sleep_tv)
|
||||
static void ServerWait(struct timeval *sleep_tv)
|
||||
{
|
||||
fd_set readSet;
|
||||
int retval;
|
||||
@@ -849,6 +922,13 @@ static void DaemonWait(struct timeval *sleep_tv)
|
||||
}
|
||||
fflush(stdout);
|
||||
reread();
|
||||
} else if (!strncmp(cmdLine, "DEL ", 4)) {
|
||||
unsigned long qid;
|
||||
if (sscanf(cmdLine, "DEL %lx", &qid) == 1) {
|
||||
del_reminder_ul(qid);
|
||||
}
|
||||
print_num_queued();
|
||||
fflush(stdout);
|
||||
} else {
|
||||
if (DaemonJSON) {
|
||||
size_t l = strlen(cmdLine);
|
||||
@@ -884,18 +964,27 @@ static void consume_inotify_events(int fd)
|
||||
int n;
|
||||
|
||||
struct timespec sleeptime;
|
||||
/* HACK: sleep for 0.2 seconds to let multiple events queue up so we
|
||||
only do a single reread */
|
||||
sleeptime.tv_sec = 0;
|
||||
sleeptime.tv_nsec = 200000000;
|
||||
nanosleep(&sleeptime, NULL);
|
||||
|
||||
int slept = 0;
|
||||
/* Consume all the inotify events */
|
||||
while(1) {
|
||||
n = read(fd, buf, sizeof(buf));
|
||||
if (n > 0) {
|
||||
/* Something new since we slept */
|
||||
slept = 0;
|
||||
}
|
||||
if (n < 0) {
|
||||
if (errno == EINTR) continue;
|
||||
return;
|
||||
if (slept) {
|
||||
/* Nothing new since we slept */
|
||||
return;
|
||||
}
|
||||
slept = 1;
|
||||
/* HACK: sleep for 0.2 seconds to let multiple events queue up so we
|
||||
only do a single reread */
|
||||
sleeptime.tv_sec = 0;
|
||||
sleeptime.tv_nsec = 200000000;
|
||||
nanosleep(&sleeptime, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <stdlib.h>
|
||||
#include "types.h"
|
||||
#include "protos.h"
|
||||
#include "expr.h"
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ Token TokArray[] = {
|
||||
{ "endif", 5, T_EndIf, 0 },
|
||||
{ "errmsg", 6, T_ErrMsg, 0 },
|
||||
{ "exit", 4, T_Exit, 0 },
|
||||
{ "expr", 4, T_Expr, 0 },
|
||||
{ "february", 3, T_Month, 1 },
|
||||
{ "first", 5, T_Ordinal, 0 },
|
||||
{ "flush", 5, T_Flush, 0 },
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "types.h"
|
||||
#include "expr.h"
|
||||
#include "protos.h"
|
||||
#include "globals.h"
|
||||
#include "err.h"
|
||||
@@ -244,6 +243,7 @@ static int NextSimpleTrig(int startdate, Trigger *trig, int *err)
|
||||
|
||||
case GOT_WD+GOT_MON+GOT_YR:
|
||||
if (y > trig->y || (y == trig->y && m > trig->m)) return -1;
|
||||
/* cppcheck-suppress knownConditionTrueFalse */
|
||||
if (trig->y > y || (trig->y == y && trig->m > m)) {
|
||||
j = DSE(trig->y, trig->m, 1);
|
||||
ADVANCE_TO_WD(j, trig->wd);
|
||||
|
||||
91
src/types.h
91
src/types.h
@@ -13,6 +13,22 @@
|
||||
#include <limits.h>
|
||||
#include "dynbuf.h"
|
||||
|
||||
typedef struct udf_struct UserFunc;
|
||||
|
||||
/* Define the types of values */
|
||||
#define ERR_TYPE 0
|
||||
#define INT_TYPE 1
|
||||
#define TIME_TYPE 2
|
||||
#define DATE_TYPE 3
|
||||
#define STR_TYPE 4
|
||||
#define DATETIME_TYPE 5
|
||||
#define SPECIAL_TYPE 6 /* Only for system variables */
|
||||
#define CONST_INT_TYPE 7 /* Only for system variables */
|
||||
|
||||
#define BEG_OF_EXPR '['
|
||||
#define END_OF_EXPR ']'
|
||||
#define COMMA ','
|
||||
|
||||
/* Values */
|
||||
typedef struct {
|
||||
char type;
|
||||
@@ -22,29 +38,61 @@ typedef struct {
|
||||
} v;
|
||||
} Value;
|
||||
|
||||
/* Define the type of operators */
|
||||
typedef struct {
|
||||
char const *name;
|
||||
char prec;
|
||||
char type;
|
||||
int (*func)(void);
|
||||
} Operator;
|
||||
/* New-style expr_node structure and constants */
|
||||
enum expr_node_type
|
||||
{
|
||||
N_FREE,
|
||||
N_ERROR,
|
||||
N_CONSTANT,
|
||||
N_LOCAL_VAR,
|
||||
N_SHORT_VAR,
|
||||
N_VARIABLE,
|
||||
N_SHORT_SYSVAR,
|
||||
N_SYSVAR,
|
||||
N_BUILTIN_FUNC,
|
||||
N_SHORT_USER_FUNC,
|
||||
N_USER_FUNC,
|
||||
N_OPERATOR,
|
||||
};
|
||||
|
||||
/* Structure for passing in Nargs and out RetVal from functions */
|
||||
typedef struct {
|
||||
int nargs;
|
||||
Value *args;
|
||||
Value retval;
|
||||
} func_info;
|
||||
|
||||
/* Forward reference */
|
||||
typedef struct expr_node_struct expr_node;
|
||||
|
||||
/* Define the type of user-functions */
|
||||
typedef struct {
|
||||
char const *name;
|
||||
char minargs;
|
||||
char maxargs;
|
||||
char is_constant;
|
||||
/* Old-style function calling convention */
|
||||
int (*func)(func_info *);
|
||||
|
||||
/* New-style function calling convention */
|
||||
int (*newfunc)(expr_node *node, Value *locals, Value *ans, int *nonconst);
|
||||
} BuiltinFunc;
|
||||
|
||||
#define SHORT_NAME_BUF 16
|
||||
typedef struct expr_node_struct {
|
||||
struct expr_node_struct *child;
|
||||
struct expr_node_struct *sibling;
|
||||
enum expr_node_type type;
|
||||
int num_kids;
|
||||
union {
|
||||
Value value;
|
||||
int arg;
|
||||
BuiltinFunc *builtin_func;
|
||||
char name[SHORT_NAME_BUF];
|
||||
int (*operator_func) (struct expr_node_struct *node, Value *locals, Value *ans, int *nonconst);
|
||||
} u;
|
||||
} expr_node;
|
||||
|
||||
/* Define the structure of a variable */
|
||||
typedef struct var {
|
||||
struct var *next;
|
||||
@@ -142,6 +190,8 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */
|
||||
#define MSF_TYPE 7
|
||||
#define PASSTHRU_TYPE 8
|
||||
|
||||
/* For function arguments */
|
||||
#define NO_MAX 127
|
||||
|
||||
/* DEFINES for debugging flags */
|
||||
#define DB_PRTLINE 1
|
||||
@@ -150,6 +200,7 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */
|
||||
#define DB_DUMP_VARS 8
|
||||
#define DB_ECHO_LINE 16
|
||||
#define DB_TRACE_FILES 32
|
||||
#define DB_PARSE_EXPR 64
|
||||
|
||||
/* Enumeration of the tokens */
|
||||
enum TokTypes
|
||||
@@ -183,7 +234,8 @@ enum TokTypes
|
||||
T_MaybeUncomputable,
|
||||
T_Ordinal,
|
||||
T_In,
|
||||
T_LastBack
|
||||
T_LastBack,
|
||||
T_Expr
|
||||
};
|
||||
|
||||
/* The structure of a token */
|
||||
@@ -243,3 +295,26 @@ typedef struct {
|
||||
#define TERMINAL_BACKGROUND_UNKNOWN -1
|
||||
#define TERMINAL_BACKGROUND_DARK 0
|
||||
#define TERMINAL_BACKGROUND_LIGHT 1
|
||||
|
||||
typedef int (*SysVarFunc)(int, Value *);
|
||||
/* The structure of a system variable */
|
||||
typedef struct {
|
||||
char const *name;
|
||||
char modifiable;
|
||||
int type;
|
||||
void *value;
|
||||
int min; /* Or const-value */
|
||||
int max;
|
||||
} SysVar;
|
||||
|
||||
/* Define the data structure used to hold a user-defined function */
|
||||
typedef struct udf_struct {
|
||||
struct udf_struct *next;
|
||||
char name[VAR_NAME_LEN+1];
|
||||
expr_node *node;
|
||||
char **args;
|
||||
int nargs;
|
||||
char const *filename;
|
||||
int lineno;
|
||||
} UserFunc;
|
||||
|
||||
|
||||
331
src/userfns.c
331
src/userfns.c
@@ -16,43 +16,46 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "types.h"
|
||||
#include "globals.h"
|
||||
#include "protos.h"
|
||||
#include "err.h"
|
||||
#include "expr.h"
|
||||
|
||||
#define FUNC_HASH_SIZE 32 /* Size of User-defined function hash table */
|
||||
|
||||
/* Define the data structure used to hold a user-defined function */
|
||||
typedef struct udf_struct {
|
||||
struct udf_struct *next;
|
||||
char name[VAR_NAME_LEN+1];
|
||||
char const *text;
|
||||
Var *locals;
|
||||
char IsActive;
|
||||
int nargs;
|
||||
char const *filename;
|
||||
int lineno;
|
||||
} UserFunc;
|
||||
|
||||
/* The hash table */
|
||||
static UserFunc *FuncHash[FUNC_HASH_SIZE];
|
||||
|
||||
/* Access to built-in functions */
|
||||
extern int NumFuncs;
|
||||
extern BuiltinFunc Func[];
|
||||
|
||||
/* We need access to the expression evaluation stack */
|
||||
extern Value ValStack[];
|
||||
extern int ValStackPtr;
|
||||
|
||||
static void DestroyUserFunc (UserFunc *f);
|
||||
static void FUnset (char const *name);
|
||||
static void FSet (UserFunc *f);
|
||||
static int SetUpLocalVars (UserFunc *f);
|
||||
static void DestroyLocalVals (UserFunc *f);
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* HashVal */
|
||||
/* Given a string, compute the hash value. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
unsigned int HashVal_nocase(char const *str)
|
||||
{
|
||||
register unsigned int i=0;
|
||||
register unsigned int j=1;
|
||||
register unsigned int len=0;
|
||||
|
||||
while(*str && len < VAR_NAME_LEN) {
|
||||
i += j * (*str);
|
||||
str++;
|
||||
len++;
|
||||
j = 3-j;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
@@ -75,6 +78,7 @@ int DoFunset(ParsePtr p)
|
||||
break;
|
||||
}
|
||||
seen_one = 1;
|
||||
strtolower(DBufValue(&buf));
|
||||
FUnset(DBufValue(&buf));
|
||||
DBufFree(&buf);
|
||||
}
|
||||
@@ -93,8 +97,11 @@ int DoFset(ParsePtr p)
|
||||
{
|
||||
int r;
|
||||
int c;
|
||||
int i;
|
||||
UserFunc *func;
|
||||
Var *v;
|
||||
UserFunc *existing;
|
||||
Var *locals = NULL;
|
||||
Var local_array[MAX_FUNC_ARGS];
|
||||
int orig_namelen;
|
||||
|
||||
DynamicBuffer buf;
|
||||
@@ -119,6 +126,21 @@ int DoFset(ParsePtr p)
|
||||
return E_PARSE_ERR;
|
||||
}
|
||||
|
||||
/* Convert to lower-case */
|
||||
strtolower(DBufValue(&buf));
|
||||
|
||||
/* If the function exists and was defined at the same line of the same
|
||||
file, do nothing */
|
||||
existing = FindUserFunc(DBufValue(&buf));
|
||||
if (existing) {
|
||||
if (!strcmp(existing->filename, FileName) &&
|
||||
strcmp(existing->filename, "[cmdline]") &&
|
||||
existing->lineno == LineNo) {
|
||||
DBufFree(&buf);
|
||||
/* We already have it! Our work here is done. */
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
func = NEW(UserFunc);
|
||||
if (!func) {
|
||||
DBufFree(&buf);
|
||||
@@ -137,25 +159,22 @@ int DoFset(ParsePtr p)
|
||||
StrnCpy(func->name, DBufValue(&buf), VAR_NAME_LEN);
|
||||
DBufFree(&buf);
|
||||
if (!Hush) {
|
||||
if (FindFunc(func->name, Func, NumFuncs)) {
|
||||
if (FindBuiltinFunc(func->name)) {
|
||||
Eprint("%s: `%s'", ErrMsg[E_REDEF_FUNC], func->name);
|
||||
}
|
||||
}
|
||||
func->locals = NULL;
|
||||
func->text = NULL;
|
||||
func->IsActive = 0;
|
||||
func->node = NULL;
|
||||
func->nargs = 0;
|
||||
func->args = NULL;
|
||||
|
||||
/* Get the local variables - we insert the local variables in REVERSE
|
||||
order, but that's OK, because we pop them off the stack in reverse
|
||||
order, too, so everything works out just fine. */
|
||||
/* Get the local variables */
|
||||
|
||||
c=ParseNonSpaceChar(p, &r, 1);
|
||||
if (r) return r;
|
||||
if (c == ')') {
|
||||
(void) ParseNonSpaceChar(p, &r, 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
locals = local_array;
|
||||
while(1) {
|
||||
if ( (r=ParseIdentifier(p, &buf)) ) return r;
|
||||
if (*DBufValue(&buf) == '$') {
|
||||
@@ -163,18 +182,25 @@ int DoFset(ParsePtr p)
|
||||
DestroyUserFunc(func);
|
||||
return E_BAD_ID;
|
||||
}
|
||||
v = NEW(Var);
|
||||
if (!v) {
|
||||
DBufFree(&buf);
|
||||
DestroyUserFunc(func);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
/* If we've already seen this local variable, error */
|
||||
for (i=0; i<func->nargs; i++) {
|
||||
if (!StrinCmp(DBufValue(&buf), local_array[i].name, VAR_NAME_LEN)) {
|
||||
DBufFree(&buf);
|
||||
DestroyUserFunc(func);
|
||||
return E_REPEATED_ARG;
|
||||
}
|
||||
}
|
||||
i = func->nargs;
|
||||
if (i >= MAX_FUNC_ARGS-1) {
|
||||
DBufFree(&buf);
|
||||
DestroyUserFunc(func);
|
||||
return E_2MANY_ARGS;
|
||||
}
|
||||
local_array[i].v.type = ERR_TYPE;
|
||||
StrnCpy(local_array[i].name, DBufValue(&buf), VAR_NAME_LEN);
|
||||
local_array[i].next = &(local_array[i+1]);
|
||||
local_array[i+1].next = NULL;
|
||||
func->nargs++;
|
||||
v->v.type = ERR_TYPE;
|
||||
StrnCpy(v->name, DBufValue(&buf), VAR_NAME_LEN);
|
||||
DBufFree(&buf);
|
||||
v->next = func->locals;
|
||||
func->locals = v;
|
||||
c = ParseNonSpaceChar(p, &r, 0);
|
||||
if (c == ')') break;
|
||||
else if (c != ',') {
|
||||
@@ -189,17 +215,42 @@ int DoFset(ParsePtr p)
|
||||
if (c == '=') {
|
||||
(void) ParseNonSpaceChar(p, &r, 0);
|
||||
}
|
||||
/* Copy the text over */
|
||||
if (p->isnested) {
|
||||
Eprint("%s", ErrMsg[E_CANTNEST_FDEF]);
|
||||
DestroyUserFunc(func);
|
||||
return E_PARSE_ERR;
|
||||
}
|
||||
|
||||
func->text = StrDup(p->pos);
|
||||
if (!func->text) {
|
||||
DestroyUserFunc(func);
|
||||
return E_NO_MEM;
|
||||
while(*(p->pos) && isspace(*(p->pos))) {
|
||||
p->pos++;
|
||||
}
|
||||
if (!*(p->pos)) {
|
||||
DestroyUserFunc(func);
|
||||
return E_EOLN;
|
||||
}
|
||||
/* Parse the expression */
|
||||
func->node = parse_expression(&(p->pos), &r, locals);
|
||||
if (!func->node) {
|
||||
DestroyUserFunc(func);
|
||||
return r;
|
||||
}
|
||||
|
||||
c = ParseNonSpaceChar(p, &r, 1);
|
||||
if (c != 0) {
|
||||
DestroyUserFunc(func);
|
||||
return E_EXPECTING_EOL;
|
||||
}
|
||||
|
||||
/* Save the argument names */
|
||||
if (func->nargs) {
|
||||
func->args = calloc(sizeof(char *), func->nargs);
|
||||
for (i=0; i<func->nargs; i++) {
|
||||
func->args[i] = StrDup(local_array[i].name);
|
||||
if (!func->args[i]) {
|
||||
DestroyUserFunc(func);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If an old definition of this function exists, destroy it */
|
||||
@@ -223,23 +274,22 @@ int DoFset(ParsePtr p)
|
||||
/***************************************************************/
|
||||
static void DestroyUserFunc(UserFunc *f)
|
||||
{
|
||||
Var *v, *prev;
|
||||
|
||||
/* Free the local variables first */
|
||||
v = f->locals;
|
||||
while(v) {
|
||||
DestroyValue(v->v);
|
||||
prev = v;
|
||||
v = v->next;
|
||||
free(prev);
|
||||
}
|
||||
int i;
|
||||
|
||||
/* Free the function definition */
|
||||
if (f->text) free( (char *) f->text);
|
||||
if (f->node) free_expr_tree(f->node);
|
||||
|
||||
/* Free the filename */
|
||||
if (f->filename) free( (char *) f->filename);
|
||||
|
||||
/* Free arg names */
|
||||
if (f->args) {
|
||||
for (i=0; i<f->nargs; i++) {
|
||||
if (f->args[i]) free(f->args[i]);
|
||||
}
|
||||
free(f->args);
|
||||
}
|
||||
|
||||
/* Free the data structure itself */
|
||||
free(f);
|
||||
}
|
||||
@@ -257,12 +307,12 @@ static void FUnset(char const *name)
|
||||
UserFunc *cur, *prev;
|
||||
int h;
|
||||
|
||||
h = HashVal(name) % FUNC_HASH_SIZE;
|
||||
h = HashVal_nocase(name) % FUNC_HASH_SIZE;
|
||||
|
||||
cur = FuncHash[h];
|
||||
prev = NULL;
|
||||
while(cur) {
|
||||
if (! StrinCmp(name, cur->name, VAR_NAME_LEN)) break;
|
||||
if (! strncmp(name, cur->name, VAR_NAME_LEN)) break;
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
}
|
||||
@@ -280,134 +330,22 @@ static void FUnset(char const *name)
|
||||
/***************************************************************/
|
||||
static void FSet(UserFunc *f)
|
||||
{
|
||||
int h = HashVal(f->name) % FUNC_HASH_SIZE;
|
||||
int h = HashVal_nocase(f->name) % FUNC_HASH_SIZE;
|
||||
f->next = FuncHash[h];
|
||||
FuncHash[h] = f;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* CallUserFunc */
|
||||
/* */
|
||||
/* Call a user-defined function. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int CallUserFunc(char const *name, int nargs, ParsePtr p)
|
||||
UserFunc *FindUserFunc(char const *name)
|
||||
{
|
||||
UserFunc *f;
|
||||
int h = HashVal(name) % FUNC_HASH_SIZE;
|
||||
int i;
|
||||
char const *s;
|
||||
UserFunc *f;
|
||||
int h = HashVal_nocase(name) % FUNC_HASH_SIZE;
|
||||
|
||||
/* Search for the function */
|
||||
f = FuncHash[h];
|
||||
while (f && StrinCmp(name, f->name, VAR_NAME_LEN)) f = f->next;
|
||||
if (!f) {
|
||||
Eprint("%s: `%s'", ErrMsg[E_UNDEF_FUNC], name);
|
||||
return E_UNDEF_FUNC;
|
||||
}
|
||||
/* Debugging stuff */
|
||||
if (DebugFlag & DB_PRTEXPR) {
|
||||
fprintf(ErrFp, "%s %s(", ErrMsg[E_ENTER_FUN], f->name);
|
||||
for (i=0; i<nargs; i++) {
|
||||
PrintValue(&ValStack[ValStackPtr - nargs + i], ErrFp);
|
||||
if (i<nargs-1) fprintf(ErrFp, ", ");
|
||||
}
|
||||
fprintf(ErrFp, ")\n");
|
||||
}
|
||||
/* Detect illegal recursive call */
|
||||
if (f->IsActive) {
|
||||
if (DebugFlag &DB_PRTEXPR) {
|
||||
fprintf(ErrFp, "%s %s() => ", ErrMsg[E_LEAVE_FUN], name);
|
||||
fprintf(ErrFp, "%s\n", ErrMsg[E_RECURSIVE]);
|
||||
}
|
||||
return E_RECURSIVE;
|
||||
}
|
||||
|
||||
/* Check number of args */
|
||||
if (nargs != f->nargs) {
|
||||
if (DebugFlag &DB_PRTEXPR) {
|
||||
fprintf(ErrFp, "%s %s() => ", ErrMsg[E_LEAVE_FUN], name);
|
||||
fprintf(ErrFp, "%s\n",
|
||||
ErrMsg[(nargs < f->nargs) ? E_2FEW_ARGS : E_2MANY_ARGS]);
|
||||
}
|
||||
return (nargs < f->nargs) ? E_2FEW_ARGS : E_2MANY_ARGS;
|
||||
}
|
||||
/* Found the function - set up a local variable frame */
|
||||
h = SetUpLocalVars(f);
|
||||
if (h) {
|
||||
if (DebugFlag &DB_PRTEXPR) {
|
||||
fprintf(ErrFp, "%s %s() => ", ErrMsg[E_LEAVE_FUN], name);
|
||||
fprintf(ErrFp, "%s\n", ErrMsg[h]);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
/* Evaluate the expression */
|
||||
f->IsActive = 1;
|
||||
s = f->text;
|
||||
|
||||
/* Skip the opening bracket, if there's one */
|
||||
while (isempty(*s)) s++;
|
||||
if (*s == BEG_OF_EXPR) {
|
||||
s++;
|
||||
}
|
||||
push_call(f->filename, f->name, f->lineno);
|
||||
h = Evaluate(&s, f->locals, p);
|
||||
if (h == OK) {
|
||||
pop_call();
|
||||
}
|
||||
f->IsActive = 0;
|
||||
DestroyLocalVals(f);
|
||||
if (DebugFlag &DB_PRTEXPR) {
|
||||
fprintf(ErrFp, "%s %s() => ", ErrMsg[E_LEAVE_FUN], name);
|
||||
if (h) fprintf(ErrFp, "%s\n", ErrMsg[h]);
|
||||
else {
|
||||
PrintValue(&ValStack[ValStackPtr-1], ErrFp);
|
||||
fprintf(ErrFp, "\n");
|
||||
}
|
||||
}
|
||||
return h;
|
||||
/* Search for the function */
|
||||
f = FuncHash[h];
|
||||
while (f && strncmp(name, f->name, VAR_NAME_LEN)) f = f->next;
|
||||
return f;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* SetUpLocalVars */
|
||||
/* */
|
||||
/* Set up the local variables from the stack frame. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
static int SetUpLocalVars(UserFunc *f)
|
||||
{
|
||||
int i, r;
|
||||
Var *var;
|
||||
|
||||
for (i=0, var=f->locals; var && i<f->nargs; var=var->next, i++) {
|
||||
if ( (r=FnPopValStack(&(var->v))) ) {
|
||||
DestroyLocalVals(f);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* DestroyLocalVals */
|
||||
/* */
|
||||
/* Destroy the values of all local variables after evaluating */
|
||||
/* the function. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
static void DestroyLocalVals(UserFunc *f)
|
||||
{
|
||||
Var *v = f->locals;
|
||||
|
||||
while(v) {
|
||||
DestroyValue(v->v);
|
||||
v = v->next;
|
||||
}
|
||||
}
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* UserFuncExists */
|
||||
@@ -418,12 +356,33 @@ static void DestroyLocalVals(UserFunc *f)
|
||||
/***************************************************************/
|
||||
int UserFuncExists(char const *fn)
|
||||
{
|
||||
UserFunc *f;
|
||||
int h = HashVal(fn) % FUNC_HASH_SIZE;
|
||||
UserFunc *f = FindUserFunc(fn);
|
||||
|
||||
f = FuncHash[h];
|
||||
while (f && StrinCmp(fn, f->name, VAR_NAME_LEN)) f = f->next;
|
||||
if (!f) return -1;
|
||||
else return f->nargs;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* UnsetAllUserFuncs */
|
||||
/* */
|
||||
/* Call FUNSET on all user funcs. Used with -ds flag to */
|
||||
/* ensure no expr_node memory leaks. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
void
|
||||
UnsetAllUserFuncs(void)
|
||||
{
|
||||
UserFunc *f;
|
||||
UserFunc *next;
|
||||
int i;
|
||||
for (i=0; i<FUNC_HASH_SIZE; i++) {
|
||||
f = FuncHash[i];
|
||||
while(f) {
|
||||
next = f->next;
|
||||
DestroyUserFunc(f);
|
||||
f = next;
|
||||
}
|
||||
FuncHash[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
92
src/utils.c
92
src/utils.c
@@ -17,6 +17,11 @@ static char const DontEscapeMe[] =
|
||||
#include "err.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -46,6 +51,7 @@ char *StrnCpy(char *dest, char const *source, int n)
|
||||
return odest;
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRNCASECMP
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* StrinCmp - compare strings, case-insensitive */
|
||||
@@ -64,6 +70,9 @@ int StrinCmp(char const *s1, char const *s2, int n)
|
||||
if (n) return (toupper(*s1) - toupper(*s2)); else return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRDUP
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* StrDup */
|
||||
@@ -79,6 +88,9 @@ char *StrDup(char const *s)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASECMP
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* StrCmpi */
|
||||
@@ -98,6 +110,8 @@ int StrCmpi(char const *s1, char const *s2)
|
||||
return toupper(*s1) - toupper(*s2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* DateOK */
|
||||
@@ -116,6 +130,14 @@ int DateOK(int y, int m, int d)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void strtolower(char *s)
|
||||
{
|
||||
while (*s) {
|
||||
*s = tolower(*s);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Functions designed to defeat gcc optimizer */
|
||||
|
||||
int _private_mul_overflow(int a, int b)
|
||||
@@ -151,11 +173,15 @@ int _private_sub_overflow(int a, int b)
|
||||
int
|
||||
ShellEscape(char const *in, DynamicBuffer *out)
|
||||
{
|
||||
while(*in) {
|
||||
if (!strchr(DontEscapeMe, *in)) {
|
||||
if (DBufPutc(out, '\\') != OK) return E_NO_MEM;
|
||||
unsigned char const *i = (unsigned char const *) in;
|
||||
while(*i) {
|
||||
/* Don't escape chars with high bit set. That will mangle UTF-8 */
|
||||
if (! (*i & 0x80) ) {
|
||||
if (!strchr(DontEscapeMe, *i)) {
|
||||
if (DBufPutc(out, '\\') != OK) return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
if (DBufPutc(out, *in++) != OK) return E_NO_MEM;
|
||||
if (DBufPutc(out, *i++) != OK) return E_NO_MEM;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
@@ -169,31 +195,33 @@ typedef struct cs_s {
|
||||
} cs;
|
||||
|
||||
static cs *callstack = NULL;
|
||||
static cs *freecs = NULL;
|
||||
|
||||
static void
|
||||
destroy_cs(cs *entry)
|
||||
{
|
||||
if (entry->filename) free( (void *) entry->filename);
|
||||
if (entry->func) free( (void *) entry->func);
|
||||
free( (void *) entry);
|
||||
entry->next = freecs;
|
||||
freecs = entry;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
push_call(char const *filename, char const *func, int lineno)
|
||||
{
|
||||
cs *entry = NEW(cs);
|
||||
if (!entry) {
|
||||
return E_NO_MEM;
|
||||
cs *entry;
|
||||
if (freecs) {
|
||||
entry = freecs;
|
||||
freecs = freecs->next;
|
||||
} else {
|
||||
entry = NEW(cs);
|
||||
if (!entry) {
|
||||
return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
entry->next = NULL;
|
||||
entry->filename = StrDup(filename);
|
||||
entry->func = StrDup(func);
|
||||
entry->filename = filename;
|
||||
entry->func = func;
|
||||
entry->lineno = lineno;
|
||||
if (!entry->filename || !entry->func) {
|
||||
destroy_cs(entry);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
entry->next = callstack;
|
||||
callstack = entry;
|
||||
return OK;
|
||||
@@ -215,11 +243,35 @@ clear_callstack(void)
|
||||
static void
|
||||
print_callstack_aux(FILE *fp, cs *entry)
|
||||
{
|
||||
if (entry) {
|
||||
print_callstack_aux(fp, entry->next);
|
||||
fprintf(fp, "\n");
|
||||
(void) fprintf(fp, "%s(%d): In function `%s'", entry->filename, entry->lineno, entry->func);
|
||||
int i = 0;
|
||||
char const *in = "In";
|
||||
cs *prev = NULL;
|
||||
while(entry) {
|
||||
if (prev) {
|
||||
in = "Called from";
|
||||
}
|
||||
if (!prev || strcmp(prev->func, entry->func) || strcmp(prev->filename, entry->filename) || prev->lineno != entry->lineno) {
|
||||
if (prev) {
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
(void) fprintf(fp, " %s(%d): [#%d] %s function `%s'", entry->filename, entry->lineno, i, in, entry->func);
|
||||
}
|
||||
prev = entry;
|
||||
entry = entry->next;
|
||||
i++;
|
||||
if (i > 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (entry) {
|
||||
(void) fprintf(fp, "\n [remaining call frames omitted]");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
have_callstack(void)
|
||||
{
|
||||
return (callstack != NULL);
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
75
src/var.c
75
src/var.c
@@ -22,7 +22,6 @@
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include "types.h"
|
||||
#include "expr.h"
|
||||
#include "globals.h"
|
||||
#include "protos.h"
|
||||
#include "err.h"
|
||||
@@ -39,8 +38,6 @@ static int IntMax = INT_MAX;
|
||||
|
||||
static Var *VHashTbl[VAR_HASH_SIZE];
|
||||
|
||||
typedef int (*SysVarFunc)(int, Value *);
|
||||
|
||||
static double
|
||||
strtod_in_c_locale(char const *str, char **endptr)
|
||||
{
|
||||
@@ -175,6 +172,19 @@ static int terminal_bg_func(int do_set, Value *val)
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int trig_time_func(int do_set, Value *val)
|
||||
{
|
||||
UNUSED(do_set);
|
||||
if (LastTriggerTime != NO_TIME) {
|
||||
val->type = TIME_TYPE;
|
||||
val->v.val = LastTriggerTime;
|
||||
} else {
|
||||
val->type = INT_TYPE;
|
||||
val->v.val = 0;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int trig_date_func(int do_set, Value *val)
|
||||
{
|
||||
UNUSED(do_set);
|
||||
@@ -309,6 +319,29 @@ static int datetime_sep_func(int do_set, Value *val)
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int expr_time_limit_func(int do_set, Value *val)
|
||||
{
|
||||
if (!do_set) {
|
||||
val->type = INT_TYPE;
|
||||
val->v.val = ExpressionEvaluationTimeLimit;
|
||||
return OK;
|
||||
}
|
||||
if (val->type != INT_TYPE) return E_BAD_TYPE;
|
||||
if (val->v.val < 0) return E_2LOW;
|
||||
|
||||
if (!TopLevel()) {
|
||||
/* Ignore attempts to set from non-toplevel unless it's
|
||||
lower than current value */
|
||||
if (val->v.val == 0 ||
|
||||
val->v.val >= ExpressionEvaluationTimeLimit) {
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
ExpressionEvaluationTimeLimit = val->v.val;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int default_color_func(int do_set, Value *val)
|
||||
{
|
||||
int col_r, col_g, col_b;
|
||||
@@ -477,10 +510,10 @@ int DeleteVar(char const *str)
|
||||
/* */
|
||||
/* SetVar */
|
||||
/* */
|
||||
/* Set the indicate variable to the specified value. */
|
||||
/* Set the indicated variable to the specified value. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int SetVar(char const *str, Value *val)
|
||||
int SetVar(char const *str, Value const *val)
|
||||
{
|
||||
Var *v = FindVar(str, 1);
|
||||
|
||||
@@ -498,20 +531,10 @@ int SetVar(char const *str, Value *val)
|
||||
/* Get a copy of the value of the variable. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int GetVarValue(char const *str, Value *val, Var *locals, ParsePtr p)
|
||||
int GetVarValue(char const *str, Value *val)
|
||||
{
|
||||
Var *v;
|
||||
|
||||
/* Try searching local variables first */
|
||||
v = locals;
|
||||
while (v) {
|
||||
if (! StrinCmp(str, v->name, VAR_NAME_LEN))
|
||||
return CopyValue(val, &v->v);
|
||||
v = v->next;
|
||||
}
|
||||
|
||||
/* Global variable... mark expression as non-constant */
|
||||
if (p) p->nonconst_expr = 1;
|
||||
v=FindVar(str, 0);
|
||||
|
||||
if (!v) {
|
||||
@@ -544,6 +567,11 @@ int DoSet (Parser *p)
|
||||
ParseNonSpaceChar(p, &r, 0);
|
||||
}
|
||||
|
||||
if (p->isnested) {
|
||||
Eprint("%s", "Do not use [] around expression in SET command");
|
||||
return E_CANTNEST_FDEF;
|
||||
}
|
||||
|
||||
r = EvaluateExpr(p, &v);
|
||||
if (r) {
|
||||
DBufFree(&buf);
|
||||
@@ -772,16 +800,6 @@ int DoPreserve (Parser *p)
|
||||
/* */
|
||||
/***************************************************************/
|
||||
|
||||
/* The structure of a system variable */
|
||||
typedef struct {
|
||||
char const *name;
|
||||
char modifiable;
|
||||
int type;
|
||||
void *value;
|
||||
int min; /* Or const-value */
|
||||
int max;
|
||||
} SysVar;
|
||||
|
||||
/* Macro to access "min" but as a constval. Just to make source more
|
||||
readable */
|
||||
#define constval min
|
||||
@@ -818,6 +836,7 @@ static SysVar SysVarArr[] = {
|
||||
{"DontTrigAts", 0, INT_TYPE, &DontIssueAts, 0, 0 },
|
||||
{"EndSent", 1, STR_TYPE, &EndSent, 0, 0 },
|
||||
{"EndSentIg", 1, STR_TYPE, &EndSentIg, 0, 0 },
|
||||
{"ExpressionTimeLimit", 1, SPECIAL_TYPE, expr_time_limit_func, 0, 0 },
|
||||
{"February", 1, STR_TYPE, &DynamicMonthName[1], 0, 0 },
|
||||
{"FirstIndent", 1, INT_TYPE, &FirstIndent, 0, 132 },
|
||||
{"FoldYear", 1, INT_TYPE, &FoldYear, 0, 1 },
|
||||
@@ -887,6 +906,7 @@ static SysVar SysVarArr[] = {
|
||||
{"Tm", 0, SPECIAL_TYPE, trig_mon_func, 0, 0 },
|
||||
{"Today", 1, STR_TYPE, &DynamicToday, 0, 0 },
|
||||
{"Tomorrow", 1, STR_TYPE, &DynamicTomorrow, 0, 0 },
|
||||
{"Tt", 0, SPECIAL_TYPE, trig_time_func, 0, 0 },
|
||||
{"Tuesday", 1, STR_TYPE, &DynamicDayName[1], 0, 0 },
|
||||
{"Tw", 0, SPECIAL_TYPE, trig_wday_func, 0, 0 },
|
||||
{"Ty", 0, SPECIAL_TYPE, trig_year_func, 0, 0 },
|
||||
@@ -905,7 +925,6 @@ static SysVar SysVarArr[] = {
|
||||
};
|
||||
|
||||
#define NUMSYSVARS ( sizeof(SysVarArr) / sizeof(SysVar) )
|
||||
static SysVar *FindSysVar (char const *name);
|
||||
static void DumpSysVar (char const *name, const SysVar *v);
|
||||
/***************************************************************/
|
||||
/* */
|
||||
@@ -1002,7 +1021,7 @@ int GetSysVar(char const *name, Value *val)
|
||||
/* Find a system var with specified name. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
static SysVar *FindSysVar(char const *name)
|
||||
SysVar *FindSysVar(char const *name)
|
||||
{
|
||||
int top=NUMSYSVARS-1, bottom=0;
|
||||
int mid=(top + bottom) / 2;
|
||||
|
||||
@@ -35,8 +35,8 @@ set a ansicolor(-1, 0, 0)
|
||||
set a ansicolor(42, 42, 256)
|
||||
set a ansicolor("foo")
|
||||
set a ansicolor("1 1")
|
||||
set a ansicolor("-1 -1 0");
|
||||
set a ansicolor("256 1 1");
|
||||
set a ansicolor("-1 -1 0")
|
||||
set a ansicolor("256 1 1")
|
||||
set a ansicolor(128, 128, 128, 2)
|
||||
set a ansicolor(128, 128, 128, -1)
|
||||
set a ansicolor(128, 128, 128, 0, 2)
|
||||
|
||||
55
tests/expr.rem
Normal file
55
tests/expr.rem
Normal file
@@ -0,0 +1,55 @@
|
||||
debug +sx
|
||||
|
||||
set a 1
|
||||
|
||||
set a 0&&0
|
||||
set a 0&&1
|
||||
set a 1&&0
|
||||
set a 1&&1
|
||||
|
||||
set a 0||0
|
||||
set a 0||1
|
||||
set a 1||0
|
||||
set a 1||1
|
||||
|
||||
set a 2, 3
|
||||
|
||||
set a iif(0, "foo", 0, "bar", 1, "blech", 0, "quux", 1, "borhy", "wacka")
|
||||
|
||||
set a max(2*3, 4+5, min(6*7+8, 7+6*8))
|
||||
|
||||
set a max(1,,1)
|
||||
|
||||
set a 5%0
|
||||
|
||||
set a 5/0
|
||||
|
||||
set a -$IntMin
|
||||
|
||||
set a $IntMin / -1
|
||||
set a $IntMin % -1
|
||||
|
||||
set a (7+5)*(8+2)/(9-4)
|
||||
|
||||
set a "foo" * 5
|
||||
set a "foo" / 5
|
||||
set a "foo" * "five"
|
||||
set a "foo" + "bar"
|
||||
set a '2024-01-02' + 3
|
||||
set a 3 + '2024-01-02'
|
||||
set a 11:33 + 75
|
||||
set a 75 + 11:33
|
||||
set a '2024-01-01@11:33' + 1500
|
||||
set a 1500 + '2024-01-01@11:33'
|
||||
|
||||
set a '2024-03-02' - '2024-01-01'
|
||||
set a 15:00 - 14:44
|
||||
|
||||
|
||||
set a (1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+1))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
||||
|
||||
set a (1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+1)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
||||
|
||||
set a isany(1)
|
||||
set a isany(1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6)
|
||||
set a isany("foo", 1 + 1, 2:00 + 1, '2021-01-01' + 1, '2021-01-01@14:00' + 1, "f" + "oo", "fo" + "o")
|
||||
4
tests/if1.rem
Normal file
4
tests/if1.rem
Normal file
@@ -0,0 +1,4 @@
|
||||
BANNER %
|
||||
set $AddBlankLines 0
|
||||
IF 1
|
||||
INCLUDE [filedir()]/if2.rem
|
||||
5
tests/if2.rem
Normal file
5
tests/if2.rem
Normal file
@@ -0,0 +1,5 @@
|
||||
# Another unmatched IF
|
||||
IF 0
|
||||
ELSE
|
||||
IF 1
|
||||
|
||||
@@ -176,7 +176,7 @@ REM 1 Jan 2012 AT 10:00 MSG 10am: Should show up
|
||||
MSG [$DontTrigAts]
|
||||
EOF
|
||||
|
||||
# An OMITFUNC should indicate nonconst_expr
|
||||
# OMITFUNC should indicate nonconst_expr
|
||||
../src/remind -pp - 1 jan 2012 9:00 <<'EOF' >> ../tests/test.out 2>&1
|
||||
REM Mon OMITFUNC foo MSG bar
|
||||
EOF
|
||||
@@ -452,8 +452,8 @@ rm -rf include_dir/ww
|
||||
# Test queueing. Because eventstart depends on the actual system
|
||||
# date, we have to convert it to some constant (in this case,
|
||||
# VOLATILE) so that tests are not dependent on the system date.
|
||||
echo JSONQUEUE | ../src/remind -z0 ../tests/queue1.rem 2>&1 | sed -e 's/"eventstart":"................"/"eventstart":"VOLATILE"/g' >> ../tests/test.out 2>&1
|
||||
echo QUEUE | ../src/remind -zj ../tests/queue1.rem 2>&1 | sed -e 's/"eventstart":"................"/"eventstart":"VOLATILE"/g' >> ../tests/test.out 2>&1
|
||||
echo JSONQUEUE | ../src/remind -z0 ../tests/queue1.rem 2>&1 | sed -e 's/"eventstart":"................"/"eventstart":"VOLATILE"/g' | sed -e 's/"qid":"[0-9a-f]*",//g' >> ../tests/test.out 2>&1
|
||||
echo QUEUE | ../src/remind -zj ../tests/queue1.rem 2>&1 | sed -e 's/"eventstart":"................"/"eventstart":"VOLATILE"/g' | sed -e 's/"qid":"[0-9a-f]*",//g' >> ../tests/test.out 2>&1
|
||||
|
||||
# Test for leap year bug that was fixed
|
||||
../src/remind -dte - 28 Feb 2024 <<'EOF' >> ../tests/test.out 2>&1
|
||||
@@ -537,7 +537,37 @@ REM Friday 29 Feb 2025 MSG four
|
||||
EOF
|
||||
|
||||
|
||||
(echo 'BANNER %'; echo 'REM 29 MSG No bug') | ../src/remind -dt - >> ../tests/test.out 2>&1
|
||||
(echo 'BANNER %'; echo 'REM 29 MSG No bug') | ../src/remind -dt - 29 Feb 2024 >> ../tests/test.out 2>&1
|
||||
|
||||
../src/remind -ifoo - <<'EOF' >> ../tests/test.out 2>&1
|
||||
BANNER %
|
||||
DUMP
|
||||
EOF
|
||||
|
||||
../src/remind '-i$AddBlankLines' - <<'EOF' >> ../tests/test.out 2>&1
|
||||
BANNER %
|
||||
DUMP
|
||||
EOF
|
||||
|
||||
../src/remind ../tests/expr.rem >> ../tests/test.out 2>&1
|
||||
|
||||
../src/remind - <<'EOF' >> ../tests/test.out 2>&1
|
||||
PUSH
|
||||
POP
|
||||
PUSH
|
||||
PUSH
|
||||
POP
|
||||
POP
|
||||
PUSH
|
||||
PUSH
|
||||
POP
|
||||
PUSH
|
||||
POP
|
||||
PUSH
|
||||
POP
|
||||
EOF
|
||||
|
||||
../src/remind ../tests/if1.rem 2020-03-03 >> ../tests/test.out 2>&1
|
||||
|
||||
# Remove references to SysInclude, which is build-specific
|
||||
grep -F -v '$SysInclude' < ../tests/test.out > ../tests/test.out.1 && mv -f ../tests/test.out.1 ../tests/test.out
|
||||
|
||||
1971
tests/test.cmp
1971
tests/test.cmp
File diff suppressed because one or more lines are too long
@@ -329,6 +329,7 @@ set a052 time(1+2, 3+4)
|
||||
rem 10 jan 1992 AT 11:22 CAL
|
||||
set a053 trigdate()
|
||||
set a054 trigtime()
|
||||
set a054b $Tt
|
||||
set a055 trigvalid()
|
||||
set a056 upper("sdfjhsdf ksjdfh kjsdfh ksjdfh")
|
||||
set a057 value("a05"+"6")
|
||||
@@ -457,6 +458,7 @@ set a129 23:30 + '2019-02-02@16:44'
|
||||
REM 13 AT 16:00 DURATION 72:00 MSG 72-hour event
|
||||
set a130 trigdate()
|
||||
set a131 trigtime()
|
||||
set a131b $Tt
|
||||
set a132 trigdatetime()
|
||||
set a133 trigduration()
|
||||
set a134 trigeventstart()
|
||||
@@ -775,15 +777,27 @@ ENDIF
|
||||
# Trig with a good warnfunc
|
||||
FSET w(x) choose(x, 5, 3, 1, 0)
|
||||
|
||||
# Ugh. This is where short-circuit logical operators
|
||||
# would really come in handy.
|
||||
Short-circuit operators
|
||||
IF trig("sun warn w") || trig("thu warn w")
|
||||
REM [trig()] +5 MSG Foo %b
|
||||
ENDIF
|
||||
|
||||
IF trig("thu warn w") || trig("sun warn w")
|
||||
REM [trig()] +5 MSG Foo %b
|
||||
ENDIF
|
||||
|
||||
REM [trig("Mon", "Tue", "Wed", "Sat")] MSG foo
|
||||
REM [trig("Mon", "Tue", "Wed")] MSG bar
|
||||
|
||||
# Multitrig
|
||||
REM [multitrig("10", "17")] MSG multitrig-1
|
||||
REM [multitrig("Feb 15", "Mar 20")] MSG multitrig-2
|
||||
REM [multitrig("Oct 7 1992", "1991")] MSG multitrig-3
|
||||
REM [multitrig("16 Feb AFTER OMIT Sat Sun", "29 March")] MSG multitrig-4
|
||||
REM [multitrig("2", "3", "5", "7")] MSG multitrig-5
|
||||
REM [multitrig("15 SCANFROM -7", "14 SCANFROM -7")] MSG multitrig-6
|
||||
REM [multitrig("15 SCANFROM -7", "14 SCANFROM -7")] SCANFROM -7 MSG multitrig-7
|
||||
|
||||
# The new syntactic sugar
|
||||
REM First Monday January MSG x
|
||||
REM Second Tuesday in April MSG x
|
||||
@@ -910,6 +924,27 @@ set a 7 * "Cabbage! "
|
||||
# Should result in errors
|
||||
set pqxya 1+2)
|
||||
|
||||
# Should result in an error
|
||||
REM Tue OMIT 2024-01-01 MSG Wookie
|
||||
|
||||
# No error
|
||||
REM Tue OMIT Wed 2024-01-01 MSG Blort
|
||||
|
||||
# Make sure trigtime() is not reset between invocations
|
||||
REM Tue AT 16:00 DURATION 30 MSG Thing One
|
||||
REM [$T] AT [trigtime()+trigduration()] DURATION 15 MSG Thing Two
|
||||
REM [$T] AT [$Tt+trigduration()] DURATION 30 MSG Thing Three
|
||||
REM [$T] AT [trigtime()+trigduration()] DURATION 10 MSG Last Thing
|
||||
|
||||
# Make sure trigtime is not reset during parsing
|
||||
REM Tue AT 16:00 MSG blort
|
||||
REM Tue AT 10:00 DURATION [$Tt] MSG blort
|
||||
REM Tue AT 16:00 MSG blort
|
||||
REM Tue AT 10:00 DURATION [trigtime()] MSG blort
|
||||
|
||||
# Make sure shellescape does not mangle UTF-8 characters
|
||||
msg [shellescape("😆")]
|
||||
|
||||
# Don't want Remind to queue reminders
|
||||
EXIT
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ CGIDIR = /cgi-bin
|
||||
# The complete path to the directory containing the HTML file "calendar.html".
|
||||
# This is a sample file containing links to all the scripts. This path
|
||||
# should be the path as seen by the UNIX operating system
|
||||
HTMLDIR = /var/www/remind
|
||||
HTMLDIR = /var/www/html/remind
|
||||
|
||||
# Where you stick images and CSS files, as seen by UNIX
|
||||
IMAGEDIR = /var/www/remind/resources
|
||||
IMAGEDIR = /var/www/html/remind/resources
|
||||
|
||||
# Where images and CSS files are, as seen by web browsers
|
||||
IMAGEBASE = /remind/resources
|
||||
@@ -32,6 +32,7 @@ datarootdir=@datarootdir@
|
||||
# Where do Remind and Rem2PS executables live?
|
||||
REMIND = $(bindir)/remind
|
||||
REM2PS = $(bindir)/rem2ps
|
||||
REM2PDF = $(bindir)/rem2pdf
|
||||
REM2HTML = $(bindir)/rem2html
|
||||
# If your Web server requires CGI programs to have a .cgi suffix, use
|
||||
# the next line. Otherwise, comment it out
|
||||
@@ -46,6 +47,7 @@ SEDSCRIPT = -e 's@%CGIDIR%@$(CGIDIR)@g' \
|
||||
-e 's@%REMIND%@$(REMIND)@g' \
|
||||
-e 's@%IMAGEBASE%@$(IMAGEBASE)@g' \
|
||||
-e 's@%REM2PS%@$(REM2PS)@g' \
|
||||
-e 's@%REM2PDF%@$(REM2PDF)@g' \
|
||||
-e 's@%REM2HTML%@$(REM2HTML)@g' \
|
||||
-e 's@cal_dispatch@cal_dispatch$(CGISUFFIX)@g' \
|
||||
|
||||
@@ -57,7 +59,8 @@ all:
|
||||
install:
|
||||
-mkdir -p $(DESTDIR)$(SCRIPTDIR)
|
||||
-mkdir -p $(DESTDIR)$(HTMLDIR)
|
||||
cp calps hebdate hebps hebhtml moon sunrise sunset $(DESTDIR)$(SCRIPTDIR)
|
||||
cp calps calpdf hebps hebpdf hebhtml moon sunrise sunset $(DESTDIR)$(SCRIPTDIR)
|
||||
sed $(SEDSCRIPT) < hebdate > $(DESTDIR)$(SCRIPTDIR)/hebdate
|
||||
sed $(SEDSCRIPT) < cal_dispatch-DIST > $(DESTDIR)$(SCRIPTDIR)/cal_dispatch$(CGISUFFIX)
|
||||
sed $(SEDSCRIPT) < hebdate.rem-DIST > $(DESTDIR)$(SCRIPTDIR)/hebdate.rem
|
||||
sed $(SEDSCRIPT) < moon.rem-DIST > $(DESTDIR)$(SCRIPTDIR)/moon.rem
|
||||
@@ -73,14 +76,14 @@ install:
|
||||
chmod 644 $(DESTDIR)$(SCRIPTDIR)/blank.rem
|
||||
chmod 644 $(DESTDIR)$(HTMLDIR)/calendar.html
|
||||
chmod 755 $(DESTDIR)$(SCRIPTDIR)/cal_dispatch$(CGISUFFIX)
|
||||
chmod 755 $(DESTDIR)$(SCRIPTDIR)/calps $(DESTDIR)$(SCRIPTDIR)/hebdate \
|
||||
$(DESTDIR)$(SCRIPTDIR)/hebps $(DESTDIR)$(SCRIPTDIR)/moon \
|
||||
chmod 755 $(DESTDIR)$(SCRIPTDIR)/calpdf $(DESTDIR)$(SCRIPTDIR)/calps $(DESTDIR)$(SCRIPTDIR)/hebdate \
|
||||
$(DESTDIR)$(SCRIPTDIR)/hebps $(DESTDIR)$(SCRIPTDIR)/hebpdf $(DESTDIR)$(SCRIPTDIR)/moon \
|
||||
$(DESTDIR)$(SCRIPTDIR)/sunrise $(DESTDIR)$(SCRIPTDIR)/sunset \
|
||||
$(DESTDIR)$(SCRIPTDIR)/hebhtml \
|
||||
$(DESTDIR)$(SCRIPTDIR)/hebhtml \
|
||||
|
||||
-mkdir -p $(DESTDIR)$(IMAGEDIR)
|
||||
cp rem-default.css *.png $(DESTDIR)$(IMAGEDIR)
|
||||
chmod 644 $(DESTDIR)$(IMAGEDIR)/rem-default.css $(DESTDIR)$(IMAGEDIR)/*.png
|
||||
cp calendar.css rem-default.css *.png $(DESTDIR)$(IMAGEDIR)
|
||||
chmod 644 $(DESTDIR)$(IMAGEDIR)/calendar.css $(DESTDIR)$(IMAGEDIR)/rem-default.css $(DESTDIR)$(IMAGEDIR)/*.png
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,10 @@ export REMIND
|
||||
REM2PS=%REM2PS%
|
||||
export REM2PS
|
||||
|
||||
# Set REM2PDF to the full pathname of the rem2pdf executable
|
||||
REM2PDF=%REM2PDF%
|
||||
export REM2PDF
|
||||
|
||||
#########################
|
||||
#
|
||||
# Don't change anything after this.
|
||||
@@ -56,6 +60,10 @@ case "$1" in
|
||||
exec $DIR/calps
|
||||
;;
|
||||
|
||||
calpdf)
|
||||
exec $DIR/calpdf
|
||||
;;
|
||||
|
||||
moon)
|
||||
exec $DIR/moon
|
||||
;;
|
||||
@@ -64,6 +72,10 @@ case "$1" in
|
||||
exec $DIR/hebps
|
||||
;;
|
||||
|
||||
hebpdf)
|
||||
exec $DIR/hebpdf
|
||||
;;
|
||||
|
||||
hebhtml)
|
||||
if [ "$2" = "" -o "$3" = "" ] ; then
|
||||
exec $DIR/hebhtml
|
||||
|
||||
41
www/calendar.css
Normal file
41
www/calendar.css
Normal file
@@ -0,0 +1,41 @@
|
||||
html, body {
|
||||
padding: 0px;
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
font-family: "Open Sans", Arial, sans-serif
|
||||
background: #FFFFFF;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 0px;
|
||||
font-family: inherit;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
h1, .h1 {
|
||||
font-size: 1.75rem; }
|
||||
|
||||
h2, .h2 {
|
||||
font-size: 1.5rem; }
|
||||
|
||||
h3, .h3 {
|
||||
font-size: 1.25rem; }
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #1a0dab;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
text-decoration: none;
|
||||
color: #1a0dab;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<HTML>
|
||||
<!-- Sample HTML file with links to the calendar stuff -->
|
||||
<HEAD>
|
||||
<TITLE>Remind Calendar Server</TITLE>
|
||||
<TITLE>Remind Calendar Server</TITLE>
|
||||
<LINK rel="stylesheet" href="%IMAGEBASE%/calendar.css">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
@@ -15,10 +16,14 @@ Sunset Information</a><P>
|
||||
Moon Phase Information</a><P>
|
||||
<a HREF="%CGIDIR%/cal_dispatch?calps">
|
||||
Blank PostScript Calendar</a> (Approximately 20kB)<P>
|
||||
<a HREF="%CGIDIR%/cal_dispatch?calpdf">
|
||||
Blank PDF Calendar</a> (Approximately 15kB)<P>
|
||||
<a HREF="%CGIDIR%/cal_dispatch?hebdate">
|
||||
Today's Hebrew Date</a><P>
|
||||
<a HREF="%CGIDIR%/cal_dispatch?hebps">
|
||||
PostScript Calendar with Jewish Holidays</a> (Approximately 35 kB)<P>
|
||||
<a HREF="%CGIDIR%/cal_dispatch?hebpdf">
|
||||
PDF Calendar with Jewish Holidays</a> (Approximately 20 kB)<P>
|
||||
<a HREF="%CGIDIR%/cal_dispatch?hebhtml">
|
||||
HTML Calendar with Jewish Holidays</a>
|
||||
<HR>
|
||||
|
||||
11
www/calpdf
Normal file
11
www/calpdf
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# PostScript calendar shell script
|
||||
#
|
||||
# This file is part of REMIND.
|
||||
# Copyright (C) 1992-2018 by Dianne Skoll
|
||||
|
||||
echo "Content-type: application/pdf"
|
||||
echo
|
||||
|
||||
$REMIND -p $DIR/blank.rem | $REM2PDF -e -c3 -l
|
||||
exit 0
|
||||
@@ -11,6 +11,7 @@ cat <<EOM
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Hebrew date</TITLE>
|
||||
<LINK rel="stylesheet" href="%IMAGEBASE%/calendar.css">
|
||||
</HEAD>
|
||||
<BODY>
|
||||
|
||||
|
||||
@@ -165,13 +165,15 @@ ENDIF
|
||||
IF !$PSCAL
|
||||
REM 20 ++40 msg Also available: <a HREF="%CGIDIR%/cal_dispatch?hebps">a PostScript calendar</a> (about 35KB) for %m %y, complete with Hebrew dates, Jewish holidays, and moon phases for [$Location].
|
||||
REM 20 ++40 msg And: <a HREF="%CGIDIR%/cal_dispatch?hebhtml">an HTML version</a> of the above.
|
||||
REM 20 ++40 msg And: <a HREF="%CGIDIR%/cal_dispatch?hebpdf">a PDF version</a> of the above.
|
||||
ELSE
|
||||
[trigger(moondate(0))] SPECIAL MOON 0
|
||||
[trigger(moondate(1))] SPECIAL MOON 1
|
||||
[trigger(moondate(2))] SPECIAL MOON 2
|
||||
[trigger(moondate(3))] SPECIAL MOON 3
|
||||
REM PS Border Border moveto /DayFont findfont 10 scalefont setfont ([hebday(today())] [hebmon(today())]) show
|
||||
REM SPECIAL HTML <P>[hebday(today())] [hebmon(today())]</P>
|
||||
REM [moondate(0)] SPECIAL MOON 0
|
||||
REM [moondate(1)] SPECIAL MOON 1
|
||||
REM [moondate(2)] SPECIAL MOON 2
|
||||
REM [moondate(3)] SPECIAL MOON 3
|
||||
REM PS Border Border moveto /DayFont findfont 10 scalefont setfont ([hebday($U)] [hebmon($U)]) show
|
||||
REM SPECIAL HTML <P>[hebday($U)] [hebmon($U)]</P>
|
||||
REM SPECIAL PANGO @4,-1 <span size="6400"><i>[hebday($U)] [hebmon($U)]</i></span>
|
||||
|
||||
ENDIF
|
||||
|
||||
|
||||
17
www/hebpdf
Normal file
17
www/hebpdf
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# Hebrew PostScript calendar shell script
|
||||
#
|
||||
# This file is part of REMIND.
|
||||
# Copyright (C) 1992-2018 by Dianne Skoll
|
||||
|
||||
# Figure out the month: If day <= 20, use this month; otherwise, use
|
||||
# next month.
|
||||
echo "Content-type: application/pdf"
|
||||
echo ""
|
||||
|
||||
$REMIND - <<EOR
|
||||
BANNER %
|
||||
REM 20 ++40 RUN $REMIND -iHTML=0 -p $DIR/hebdate.rem %m %y | $REM2PDF -e -c3 -l
|
||||
EOR
|
||||
|
||||
exit 0
|
||||
@@ -9,6 +9,7 @@ banner %
|
||||
|
||||
MSG <HEAD>%
|
||||
MSG <TITLE>Moon over [$Location]</TITLE>%
|
||||
MSG <LINK rel="stylesheet" href="%IMAGEBASE%/calendar.css">%
|
||||
MSG </HEAD>%
|
||||
|
||||
MSG <BODY>
|
||||
|
||||
@@ -8,6 +8,7 @@ set now now()
|
||||
banner %
|
||||
MSG <HEAD>%
|
||||
MSG <TITLE>Sunrise in [$Location]</TITLE>%
|
||||
MSG <LINK rel="stylesheet" href="%IMAGEBASE%/calendar.css">%
|
||||
MSG </HEAD>%
|
||||
|
||||
MSG <BODY>
|
||||
|
||||
@@ -10,6 +10,7 @@ banner %
|
||||
|
||||
MSG <HEAD>%
|
||||
MSG <TITLE>Sunset in [$Location]</TITLE>%
|
||||
MSG <LINK rel="stylesheet" href="%IMAGEBASE%/calendar.css">%
|
||||
MSG </HEAD>%
|
||||
|
||||
MSG <BODY>
|
||||
|
||||
Reference in New Issue
Block a user