mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 14:59:20 +02:00
Compare commits
416 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 | ||
|
|
8eb40ae748 | ||
|
|
89184f1d0f | ||
|
|
e899c790b9 | ||
|
|
bd6d695020 | ||
|
|
20d4626a71 | ||
|
|
8ff94c5031 | ||
|
|
ee185a0eeb | ||
|
|
06f8932efd | ||
|
|
1dc627148c | ||
|
|
3cdde5351f | ||
|
|
6e93b8a73d | ||
|
|
267e8533cf | ||
|
|
d3bfb0a28f | ||
|
|
5a31bc7058 | ||
|
|
746bde71bd | ||
|
|
b274ac635c | ||
|
|
9e0a74e583 | ||
|
|
0f782f7697 | ||
|
|
8efde3e9af | ||
|
|
3bf3137dc4 | ||
|
|
63ec32d28d | ||
|
|
d2f4177cdb | ||
|
|
1d958fb7a8 | ||
|
|
fcd580d42e | ||
|
|
34dab68805 | ||
|
|
216dd03922 | ||
|
|
5eef9ac621 | ||
|
|
6b798d5f7c | ||
|
|
22ccce0934 | ||
|
|
fe2af14952 | ||
|
|
8e99ed27e7 | ||
|
|
bb12362cc8 | ||
|
|
1bfc630a64 | ||
|
|
987983f8ae | ||
|
|
657a6118aa | ||
|
|
43e7e6ec7f | ||
|
|
b8b3c19fbf | ||
|
|
69298c96a5 | ||
|
|
7356138872 | ||
|
|
616966f5df | ||
|
|
a59e277c21 | ||
|
|
740ae2c3e9 | ||
|
|
25b7a40f2b | ||
|
|
2beaab1a2f | ||
|
|
60793d53c6 | ||
|
|
4f869c8c81 | ||
|
|
8955180a35 | ||
|
|
a30cbf5797 | ||
|
|
b2bd6109dc | ||
|
|
9455ec48d7 | ||
|
|
f751f5defa | ||
|
|
994edbebbe | ||
|
|
70959b791c | ||
|
|
524ece5119 | ||
|
|
6334bd61b6 | ||
|
|
2e56edd557 | ||
|
|
8cae1d21cd | ||
|
|
1de6ed16eb | ||
|
|
860cb94f41 | ||
|
|
6b505704e9 | ||
|
|
167631451d | ||
|
|
fa5180b94d | ||
|
|
ae01d7be43 | ||
|
|
d5ce39ade1 | ||
|
|
a043dfe8b9 | ||
|
|
7cfb75e3b3 | ||
|
|
a18f0d982f | ||
|
|
0e2dc805c2 | ||
|
|
4c1e11df2c | ||
|
|
76776d054a | ||
|
|
45ebd05cb6 | ||
|
|
0203ce3979 | ||
|
|
72d10178bf | ||
|
|
96f4e26d53 | ||
|
|
4fd86f1b6a | ||
|
|
2f3ee0aec3 | ||
|
|
a5dde31160 | ||
|
|
b45428df05 | ||
|
|
d938763643 | ||
|
|
e4e2157622 | ||
|
|
04b349c6c7 | ||
|
|
7fe3eb7391 | ||
|
|
c1992b577a | ||
|
|
632283d47f | ||
|
|
1d9e46997c | ||
|
|
861ce34022 | ||
|
|
32e8db322d | ||
|
|
3df2b72175 | ||
|
|
e7ac4f95be | ||
|
|
e7ed69287b | ||
|
|
2e80417f53 | ||
|
|
ee435d2bb9 | ||
|
|
bb516946be | ||
|
|
81157e1cb5 | ||
|
|
51dfd707a2 | ||
|
|
7c3bf8601b | ||
|
|
714195efe5 | ||
|
|
eaeca2d09b | ||
|
|
ffa3b13437 | ||
|
|
2551e98d11 | ||
|
|
1bfd7761bc | ||
|
|
de9cb1d0a3 | ||
|
|
b2d32b514a | ||
|
|
6e53fd6924 | ||
|
|
8296d2b962 | ||
|
|
d6e66ee1e6 | ||
|
|
a49532b9c5 | ||
|
|
57d87f4caf | ||
|
|
ec9b30c616 | ||
|
|
27d8a62ab6 | ||
|
|
5077814c4a | ||
|
|
ca795a352a | ||
|
|
e59fc36458 | ||
|
|
39e3657539 | ||
|
|
6031f70701 | ||
|
|
3567c9e55f | ||
|
|
26de4e3fd3 | ||
|
|
cd65c6144d | ||
|
|
d32edbbb1f | ||
|
|
eae48a5538 | ||
|
|
63eba104d9 | ||
|
|
ae64961735 | ||
|
|
f7bb91320c | ||
|
|
c11071a859 | ||
|
|
53cbcc22db | ||
|
|
af9dcec3e9 | ||
|
|
d5a4b0d235 | ||
|
|
3b870403d9 | ||
|
|
284d822884 | ||
|
|
d881a26ad0 | ||
|
|
8519edde29 | ||
|
|
a30c467c48 | ||
|
|
887cd83ebe | ||
|
|
242d787ca2 | ||
|
|
5dd2cf7356 | ||
|
|
5efb70909d | ||
|
|
a60d466774 | ||
|
|
1c01f36271 | ||
|
|
3718632551 | ||
|
|
e8f3d5ff9f | ||
|
|
d77e27942d | ||
|
|
734cc61489 | ||
|
|
44d489d3d2 | ||
|
|
3e36ffa9ff | ||
|
|
12104a96b1 | ||
|
|
8ab8d65a15 | ||
|
|
f7a8122cef | ||
|
|
77d9bbb7d6 | ||
|
|
623def52fd | ||
|
|
d088e35142 | ||
|
|
5821e55eb8 | ||
|
|
1ee989c65d | ||
|
|
62388fb21f | ||
|
|
13571f84af | ||
|
|
03fdc06b65 | ||
|
|
4bce675ae6 | ||
|
|
7b64623115 | ||
|
|
e268bbf31d | ||
|
|
5863404de6 | ||
|
|
2de5996f4e | ||
|
|
695e79602a | ||
|
|
cf0d958da5 | ||
|
|
85b0348fa7 | ||
|
|
15a5d9a876 | ||
|
|
1baa6dab0c | ||
|
|
34bb250ba3 | ||
|
|
598b1b7464 | ||
|
|
e63d4be4e8 | ||
|
|
65561e7f34 | ||
|
|
da31dadb71 | ||
|
|
705adbb82a | ||
|
|
269f9788b6 | ||
|
|
5e1c5ae384 | ||
|
|
562eb83bde | ||
|
|
a53db00243 | ||
|
|
11375729db | ||
|
|
9fee354e6c | ||
|
|
ec76554d41 | ||
|
|
ddb0817c99 | ||
|
|
3d6ecd1f72 | ||
|
|
e3ec6565e9 | ||
|
|
8ed49ead7f | ||
|
|
49fbca416f | ||
|
|
82cd438fff | ||
|
|
946e1bca38 | ||
|
|
e40c81b5bf | ||
|
|
f23418480d | ||
|
|
bb4df39c50 | ||
|
|
5fec775863 | ||
|
|
a85980fec2 | ||
|
|
f3ea2962e6 | ||
|
|
3a5af23ab6 | ||
|
|
f9656edc51 | ||
|
|
5134b47d47 | ||
|
|
d4a183f3bf | ||
|
|
87e392de6c | ||
|
|
afc1667e64 | ||
|
|
8d25270c43 | ||
|
|
929866a770 | ||
|
|
395bad96a7 | ||
|
|
cd7be006c9 | ||
|
|
f658ba7ee7 | ||
|
|
7416f4c035 | ||
|
|
2860159ff7 | ||
|
|
64fa71ab09 | ||
|
|
ffbba7d4d1 | ||
|
|
fdcc2d8acf | ||
|
|
f1aa4d16af | ||
|
|
a55c5580f3 | ||
|
|
569e315306 | ||
|
|
acd641845d | ||
|
|
6b7e6f6788 | ||
|
|
4248b9c624 | ||
|
|
6de98d1357 | ||
|
|
18f21693af | ||
|
|
6fa500a860 | ||
|
|
941c02582e | ||
|
|
e56e3924d9 | ||
|
|
d1384a8f69 | ||
|
|
0488d689aa | ||
|
|
988a94e669 | ||
|
|
ac7e93ac1c | ||
|
|
bb7e9ee676 | ||
|
|
ac949ce7bd | ||
|
|
0fa8eed11f | ||
|
|
df8694a128 | ||
|
|
13df3d96e5 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,6 +16,7 @@ man/remind.1
|
|||||||
man/tkremind.1
|
man/tkremind.1
|
||||||
pm_to_blib
|
pm_to_blib
|
||||||
rem2html/Makefile
|
rem2html/Makefile
|
||||||
|
rem2html/rem2html
|
||||||
rem2html/rem2html.1
|
rem2html/rem2html.1
|
||||||
rem2pdf/Makefile.PL
|
rem2pdf/Makefile.PL
|
||||||
rem2pdf/Makefile.old
|
rem2pdf/Makefile.old
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
workflow:
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH =~ /wip/
|
||||||
|
when: never
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
image: 'debian:stable-slim'
|
image: 'debian:stable-slim'
|
||||||
before_script:
|
before_script:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ THE REMIND COPYRIGHT
|
|||||||
1. REMIND refers to the entire set of files and documentation in the
|
1. REMIND refers to the entire set of files and documentation in the
|
||||||
REMIND package.
|
REMIND package.
|
||||||
|
|
||||||
2. REMIND is Copyright 1992-2023 Dianne Skoll, except where noted in
|
2. REMIND is Copyright 1992-2024 Dianne Skoll, except where noted in
|
||||||
individual files.
|
individual files.
|
||||||
|
|
||||||
3. DISTRIBUTION AND USE
|
3. DISTRIBUTION AND USE
|
||||||
@@ -16,7 +16,7 @@ individual files.
|
|||||||
Version 2, June 1991
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||||
675 Mass Ave, Cambridge, MA 02139, USA
|
51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
2
Makefile
2
Makefile
@@ -44,7 +44,7 @@ test:
|
|||||||
@$(MAKE) -C src -s test
|
@$(MAKE) -C src -s test
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f config.cache config.log config.status src/Makefile src/config.h tests/test.out www/Makefile rem2pdf/Makefile.top rem2pdf/Makefile.old rem2pdf/Makefile rem2pdf/Makefile.PL rem2pdf/bin/rem2pdf
|
rm -f config.cache config.log config.status src/Makefile src/config.h tests/test.out www/Makefile rem2pdf/Makefile.top rem2pdf/Makefile.old rem2pdf/Makefile rem2pdf/Makefile.PL rem2pdf/bin/rem2pdf rem2html/rem2html
|
||||||
|
|
||||||
src/Makefile: src/Makefile.in
|
src/Makefile: src/Makefile.in
|
||||||
./configure
|
./configure
|
||||||
|
|||||||
54
build.tk
Normal file → Executable file
54
build.tk
Normal file → Executable file
@@ -15,6 +15,8 @@
|
|||||||
# the next line restarts using wish \
|
# the next line restarts using wish \
|
||||||
exec wish "$0" "$@"
|
exec wish "$0" "$@"
|
||||||
|
|
||||||
|
global RemindExecutable
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# %PROCEDURE: SetConfigDefaults
|
# %PROCEDURE: SetConfigDefaults
|
||||||
# %ARGUMENTS:
|
# %ARGUMENTS:
|
||||||
@@ -27,10 +29,10 @@ exec wish "$0" "$@"
|
|||||||
proc SetConfigDefaults {} {
|
proc SetConfigDefaults {} {
|
||||||
global Config
|
global Config
|
||||||
set Config(LAT_DEG) 45
|
set Config(LAT_DEG) 45
|
||||||
set Config(LAT_MIN) 24
|
set Config(LAT_MIN) 25
|
||||||
set Config(LAT_SEC) 14
|
set Config(LAT_SEC) 14
|
||||||
set Config(LON_DEG) 75
|
set Config(LON_DEG) 75
|
||||||
set Config(LON_MIN) 39
|
set Config(LON_MIN) 41
|
||||||
set Config(LON_SEC) 23
|
set Config(LON_SEC) 23
|
||||||
set Config(LOCATION) "Ottawa"
|
set Config(LOCATION) "Ottawa"
|
||||||
set Config(DEFAULT_PAGE) "Letter"
|
set Config(DEFAULT_PAGE) "Letter"
|
||||||
@@ -40,7 +42,7 @@ proc SetConfigDefaults {} {
|
|||||||
set Config(WESTERN_HEMISPHERE) 1
|
set Config(WESTERN_HEMISPHERE) 1
|
||||||
set Config(LANGUAGE) "English"
|
set Config(LANGUAGE) "English"
|
||||||
set Config(INST_DIR) "/usr/local/bin"
|
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.
|
# Pops up an error dialog; then calls exit.
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
proc Bail { msg } {
|
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
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +126,7 @@ proc CreateMainDialog {} {
|
|||||||
# Creates the "installation directories" dialog.
|
# Creates the "installation directories" dialog.
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
proc CreateInstallDirDialog { w } {
|
proc CreateInstallDirDialog { w } {
|
||||||
global Config
|
global Config RemindExecutable
|
||||||
label $w.binlabel -text "Location for programs: "
|
label $w.binlabel -text "Location for programs: "
|
||||||
entry $w.bin -width 30
|
entry $w.bin -width 30
|
||||||
$w.bin insert end $Config(INST_DIR)
|
$w.bin insert end $Config(INST_DIR)
|
||||||
@@ -133,16 +135,19 @@ proc CreateInstallDirDialog { w } {
|
|||||||
entry $w.man -width 30
|
entry $w.man -width 30
|
||||||
$w.man insert end $Config(MAN_DIR)
|
$w.man insert end $Config(MAN_DIR)
|
||||||
|
|
||||||
text $w.blurb -width 1 -height 5 -wrap word -relief flat -takefocus 0
|
text $w.blurb -width 1 -height 20 -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.)"
|
if { "$RemindExecutable" != "" } {
|
||||||
$w.blurb configure -state disabled
|
$w.blurb insert end "Note: Default settings were obtained by querying the existing installed version of Remind found at: $RemindExecutable\n"
|
||||||
# Disable all text-window behaviour
|
}
|
||||||
bindtags $w.blurb {NoSuchTag}
|
$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.binlabel -row 0 -column 0 -sticky e
|
||||||
grid $w.bin -row 0 -column 1 -sticky nsew
|
grid $w.bin -row 0 -column 1 -sticky nsew
|
||||||
grid $w.manlabel -row 1 -column 0 -sticky e
|
grid $w.manlabel -row 1 -column 0 -sticky e
|
||||||
grid $w.man -row 1 -column 1 -sticky nsew
|
grid $w.man -row 1 -column 1 -sticky nsew
|
||||||
grid $w.blurb - -sticky nsew
|
grid $w.blurb - -sticky nsew
|
||||||
|
# Disable all text-window behaviour
|
||||||
|
bindtags $w.blurb {NoSuchTag}
|
||||||
|
$w.blurb configure -state disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
@@ -190,8 +195,8 @@ proc CreateLocationDialog { w } {
|
|||||||
|
|
||||||
grid $w.north $w.west
|
grid $w.north $w.west
|
||||||
grid $w.south $w.east
|
grid $w.south $w.east
|
||||||
grid $w.loclab -sticky e
|
grid $w.loclab -sticky e
|
||||||
grid $w.location -sticky nsew -row 6 -column 1
|
grid $w.location -sticky nsew -row 8 -column 1
|
||||||
}
|
}
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
@@ -293,9 +298,9 @@ proc BuildRemind {} {
|
|||||||
|
|
||||||
.msgs insert end "\n>>> Creating src/custom.h...\n\n" green
|
.msgs insert end "\n>>> Creating src/custom.h...\n\n" green
|
||||||
CreateCustomH
|
CreateCustomH
|
||||||
.msgs insert end ">>> Calling `./configure'...\n\n" green
|
.msgs insert end "\n>>> Calling `./configure'...\n\n" green
|
||||||
CallConfigure
|
CallConfigure
|
||||||
.msgs insert end ">>> Calling `make'...\n\n" green
|
.msgs insert end "\n>>> Calling `make'...\n\n" green
|
||||||
CallMake
|
CallMake
|
||||||
.msgs insert end "\n----------------------------------------------\n\n"
|
.msgs insert end "\n----------------------------------------------\n\n"
|
||||||
.msgs insert end "Remind" red
|
.msgs insert end "Remind" red
|
||||||
@@ -447,12 +452,12 @@ proc CreateCustomH {} {
|
|||||||
"#define DEFAULT_LATITUDE *" {
|
"#define DEFAULT_LATITUDE *" {
|
||||||
set lat [expr $LAT_DEG + ($LAT_MIN/60.0) + ($LAT_SEC/3600.0)];
|
set lat [expr $LAT_DEG + ($LAT_MIN/60.0) + ($LAT_SEC/3600.0)];
|
||||||
puts $out "#define DEFAULT_LATITUDE $lat"
|
puts $out "#define DEFAULT_LATITUDE $lat"
|
||||||
.msgs insert end "#define DEFAULT_LATITUDE $lat"
|
.msgs insert end "#define DEFAULT_LATITUDE $lat\n"
|
||||||
}
|
}
|
||||||
"#define DEFAULT_LONGITUDE *" {
|
"#define DEFAULT_LONGITUDE *" {
|
||||||
set lon [expr -1.0 * ($LON_DEG + ($LON_MIN/60.0) + ($LON_SEC/3600.0))]
|
set lon [expr -1.0 * ($LON_DEG + ($LON_MIN/60.0) + ($LON_SEC/3600.0))]
|
||||||
puts $out "#define DEFAULT_LONGITUDE $lon"
|
puts $out "#define DEFAULT_LONGITUDE $lon"
|
||||||
.msgs insert end "#define DEFAULT_LONGITUDE $lon"
|
.msgs insert end "#define DEFAULT_LONGITUDE $lon\n"
|
||||||
}
|
}
|
||||||
"#define LOCATION *" {
|
"#define LOCATION *" {
|
||||||
puts $out "#define LOCATION \"$Config(LOCATION)\""
|
puts $out "#define LOCATION \"$Config(LOCATION)\""
|
||||||
@@ -506,7 +511,13 @@ proc CallMake {} {
|
|||||||
"Icelandic" { set lang ICELANDIC }
|
"Icelandic" { set lang ICELANDIC }
|
||||||
default { set lang ENGLISH }
|
default { set lang ENGLISH }
|
||||||
}
|
}
|
||||||
RunCommand "make \"LANGDEF=-DLANG=$lang\""
|
set nproc 0
|
||||||
|
catch { set nproc [exec nproc] }
|
||||||
|
if { $nproc != 0 } {
|
||||||
|
RunCommand "make -j $nproc \"LANGDEF=-DLANG=$lang\""
|
||||||
|
} else {
|
||||||
|
RunCommand "make \"LANGDEF=-DLANG=$lang\""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -721,7 +732,7 @@ proc notebook_fix_size {win} {
|
|||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
proc FindRemind {} {
|
proc FindRemind {} {
|
||||||
global env
|
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 {
|
foreach thing $path {
|
||||||
if [file executable [file join $thing "remind"]] {
|
if [file executable [file join $thing "remind"]] {
|
||||||
return [file join $thing "remind"]
|
return [file join $thing "remind"]
|
||||||
@@ -739,16 +750,17 @@ proc FindRemind {} {
|
|||||||
# sensible defaults.
|
# sensible defaults.
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
proc SetConfigFromRemind {} {
|
proc SetConfigFromRemind {} {
|
||||||
global Config
|
global Config RemindExecutable
|
||||||
SetConfigDefaults
|
SetConfigDefaults
|
||||||
set rem [FindRemind]
|
set rem [FindRemind]
|
||||||
|
set RemindExecutable $rem
|
||||||
if {"$rem" == ""} {
|
if {"$rem" == ""} {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
set dir [file dirname $rem]
|
set dir [file dirname $rem]
|
||||||
set Config(INST_DIR) $dir
|
set Config(INST_DIR) $dir
|
||||||
if {"$dir" == "/usr/local/bin"} {
|
if {"$dir" == "/usr/local/bin"} {
|
||||||
set Config(MAN_DIR) "/usr/local/man"
|
set Config(MAN_DIR) "/usr/local/share/man"
|
||||||
} elseif {$dir == "/usr/bin"} {
|
} elseif {$dir == "/usr/bin"} {
|
||||||
set Config(MAN_DIR) "/usr/share/man"
|
set Config(MAN_DIR) "/usr/share/man"
|
||||||
}
|
}
|
||||||
@@ -758,6 +770,8 @@ proc SetConfigFromRemind {} {
|
|||||||
set Config(MAN_DIR) "/usr/share/man"
|
set Config(MAN_DIR) "/usr/share/man"
|
||||||
} elseif {[file readable "/usr/man/man1/remind.1"]} {
|
} elseif {[file readable "/usr/man/man1/remind.1"]} {
|
||||||
set Config(MAN_DIR) "/usr/man"
|
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"]} {
|
} elseif {[file readable "/usr/local/man/man1/remind.1"]} {
|
||||||
set Config(MAN_DIR) "/usr/local/man"
|
set Config(MAN_DIR) "/usr/local/man"
|
||||||
}
|
}
|
||||||
|
|||||||
31
configure.in
31
configure.in
@@ -1,6 +1,7 @@
|
|||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_INIT(src/queue.c)
|
AC_INIT(remind, 05.00.01, , , https://dianne.skoll.ca/projects/remind/)
|
||||||
|
AC_CONFIG_SRCDIR([src/queue.c])
|
||||||
|
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ cat <<'EOF'
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
AC_CONFIG_HEADER(src/config.h)
|
AC_CONFIG_HEADERS([src/config.h])
|
||||||
|
|
||||||
AC_ARG_ENABLE(perl-build-artifacts,
|
AC_ARG_ENABLE(perl-build-artifacts,
|
||||||
[ --disable-perl-build-artifacts
|
[ --disable-perl-build-artifacts
|
||||||
@@ -29,32 +30,30 @@ AC_PATH_PROG([PERL], [perl])
|
|||||||
|
|
||||||
dnl Checks for libraries.
|
dnl Checks for libraries.
|
||||||
AC_CHECK_LIB(m, sqrt)
|
AC_CHECK_LIB(m, sqrt)
|
||||||
|
AC_CHECK_HEADERS_ONCE([sys/time.h stdint.h])
|
||||||
|
|
||||||
dnl Integer sizes
|
dnl Integer sizes
|
||||||
AC_CHECK_SIZEOF(unsigned int)
|
AC_CHECK_SIZEOF(unsigned int)
|
||||||
AC_CHECK_SIZEOF(unsigned long)
|
AC_CHECK_SIZEOF(unsigned long)
|
||||||
|
AC_CHECK_SIZEOF(time_t)
|
||||||
|
|
||||||
dnl Checks for header files.
|
dnl Checks for header files.
|
||||||
AC_CHECK_HEADERS(sys/types.h sys/file.h glob.h wctype.h locale.h langinfo.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.
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_STRUCT_TM
|
AC_STRUCT_TM
|
||||||
|
|
||||||
dnl Checks for library functions.
|
|
||||||
AC_FUNC_UTIME_NULL
|
|
||||||
AC_HEADER_TIME
|
|
||||||
|
|
||||||
if test "$GCC" = yes; then
|
if test "$GCC" = yes; then
|
||||||
CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes"
|
CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes"
|
||||||
# Check for link-time optimization support
|
# Check for link-time optimization support
|
||||||
f=-flto=auto
|
f=-flto=auto
|
||||||
AC_MSG_CHECKING([whether $CC supports $f])
|
AC_MSG_CHECKING([whether $CC supports $f])
|
||||||
if $CC -E $f /dev/null > /dev/null 2>&1 ; then
|
if $CC -Werror -E $f - < /dev/null > /dev/null 2>&1 ; then
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
CFLAGS="$CFLAGS $f"
|
CFLAGS="$CFLAGS $f"
|
||||||
f=-ffat-lto-objects
|
f=-ffat-lto-objects
|
||||||
AC_MSG_CHECKING([whether $CC supports $f])
|
AC_MSG_CHECKING([whether $CC supports $f])
|
||||||
if $CC -E $f /dev/null > /dev/null 2>&1 ; then
|
if $CC -Werror -E $f - < /dev/null > /dev/null 2>&1 ; then
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
CFLAGS="$CFLAGS $f"
|
CFLAGS="$CFLAGS $f"
|
||||||
else
|
else
|
||||||
@@ -65,6 +64,12 @@ if test "$GCC" = yes; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl If sizeof(time_t) is 4, try to get 64-bit time_t
|
||||||
|
if test "$ac_cv_sizeof_time_t" = "4" ; then
|
||||||
|
AC_MSG_NOTICE([time_t is 32-bits on this system; attempting to use 64-bit time_t])
|
||||||
|
CFLAGS="$CFLAGS -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64"
|
||||||
|
fi
|
||||||
|
|
||||||
if test "$ac_cv_perlartifacts" = "yes" ; then
|
if test "$ac_cv_perlartifacts" = "yes" ; then
|
||||||
PERLARTIFACTS=
|
PERLARTIFACTS=
|
||||||
else
|
else
|
||||||
@@ -79,11 +84,13 @@ if test "$?" != 0 ; then
|
|||||||
echo "*** COULD NOT DETERMINE RELEASE DATE: docs/WHATSNEW is incorrect!"
|
echo "*** COULD NOT DETERMINE RELEASE DATE: docs/WHATSNEW is incorrect!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
AC_CHECK_FUNCS(setenv unsetenv glob mbstowcs setlocale initgroups)
|
AC_CHECK_FUNCS(strdup strcasecmp strncasecmp setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1)
|
||||||
VERSION=04.02.02
|
|
||||||
|
VERSION=$PACKAGE_VERSION
|
||||||
AC_SUBST(VERSION)
|
AC_SUBST(VERSION)
|
||||||
AC_SUBST(PERL)
|
AC_SUBST(PERL)
|
||||||
AC_SUBST(PERLARTIFACTS)
|
AC_SUBST(PERLARTIFACTS)
|
||||||
AC_SUBST(RELEASE_DATE)
|
AC_SUBST(RELEASE_DATE)
|
||||||
AC_OUTPUT(src/Makefile www/Makefile src/version.h rem2html/Makefile rem2pdf/Makefile.PL rem2pdf/Makefile.top rem2pdf/bin/rem2pdf man/rem.1 man/rem2ps.1 man/remind.1 man/tkremind.1)
|
AC_CONFIG_FILES([src/Makefile www/Makefile src/version.h rem2html/Makefile rem2html/rem2html rem2pdf/Makefile.PL rem2pdf/Makefile.top rem2pdf/bin/rem2pdf man/rem.1 man/rem2ps.1 man/remind.1 man/tkremind.1])
|
||||||
|
AC_OUTPUT
|
||||||
chmod a+x rem2pdf/bin/rem2pdf
|
chmod a+x rem2pdf/bin/rem2pdf
|
||||||
|
|||||||
@@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
;; You should have received a copy of the GNU General Public License
|
;; You should have received a copy of the GNU General Public License
|
||||||
;; along with this program; if not, write to the Free Software
|
;; along with this program; if not, write to the Free Software
|
||||||
;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
|
||||||
;; 02111-1307, USA.
|
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
@@ -514,6 +513,7 @@ Acts on the region or places point where it needs to be."
|
|||||||
(set (make-local-variable 'comment-start) ";")
|
(set (make-local-variable 'comment-start) ";")
|
||||||
(set (make-local-variable 'comment-start) "#")
|
(set (make-local-variable 'comment-start) "#")
|
||||||
(set (make-local-variable 'comment-end) "\n")
|
(set (make-local-variable 'comment-end) "\n")
|
||||||
|
(set (make-local-variable 'comment-end-skip) "[ \t]*\\(\\s>\\||#\\)")
|
||||||
(set (make-local-variable 'skeleton-end-hook) nil) ; so the skeletons will not automatically go to a new line.
|
(set (make-local-variable 'skeleton-end-hook) nil) ; so the skeletons will not automatically go to a new line.
|
||||||
(set (make-local-variable 'fill-column) '100);cause I was having problems with autofill.
|
(set (make-local-variable 'fill-column) '100);cause I was having problems with autofill.
|
||||||
(set (make-local-variable 'indent-line-function) 'remind-indent-line)
|
(set (make-local-variable 'indent-line-function) 'remind-indent-line)
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ Norman Walsh.
|
|||||||
#!/usr/local/bin/wish
|
#!/usr/local/bin/wish
|
||||||
wm withdraw .
|
wm withdraw .
|
||||||
after 15000 { destroy . ; exit }
|
after 15000 { destroy . ; exit }
|
||||||
tk_dialog .d { Message } $argv warning 0 { OK }
|
tk_messageBox -message Message -detail $argv -icon info -type ok
|
||||||
destroy .
|
destroy .
|
||||||
exit
|
exit
|
||||||
-------------- Cut Here ---------- Cut Here ---------- Cut Here -------------
|
-------------- Cut Here ---------- Cut Here ---------- Cut Here -------------
|
||||||
|
|||||||
471
docs/WHATSNEW
471
docs/WHATSNEW
@@ -1,5 +1,476 @@
|
|||||||
CHANGES TO REMIND
|
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
|
||||||
|
inotify, then in server mode (-z0 or -zj) it monitors the reminders file
|
||||||
|
and restarts itself if it detects a change, and also notifies the client.
|
||||||
|
Moving inotify support directly into Remind means that tkremind no longer
|
||||||
|
has to invoke a separate inotifywait process.
|
||||||
|
|
||||||
|
- IMPROVEMENT: remind: Set the CLOEXEC flag on files we open so we
|
||||||
|
don't leak file descriptors to programs that we run. While I don't
|
||||||
|
think there's a security issue here (any program you run can do
|
||||||
|
anything as your userid anyway) it's best to be clean and tidy.
|
||||||
|
|
||||||
|
- IMPROVEMENT: remind: Add localization for the Catalan language, courtesy
|
||||||
|
of Eloi Torrents.
|
||||||
|
|
||||||
|
- IMPROVEMENT: tkremind: Add a .desktop file and icon so TkRemind can be
|
||||||
|
integrated into the desktop menu system, courtesy of Eloi Torrents.
|
||||||
|
|
||||||
|
- CHANGE: Add a new server mode with the "-zj" flag. This is just
|
||||||
|
like "-z0" except it uses JSON messages to communicate with the
|
||||||
|
client rather than an ad-hoc protocol. The "-z0" mode is still
|
||||||
|
supported, but is deprecated.
|
||||||
|
|
||||||
|
- CHANGE: In server mode (-z0 or -zj) any RUN-type reminders, or message
|
||||||
|
commands of the "-kcommand" type are run with standard input and standard
|
||||||
|
output connected to /dev/null. NOTE INCOMPATIBILITY: If you previously
|
||||||
|
relied on RUN-type reminders to pop up reminders in TkRemind, they no
|
||||||
|
longer do. If you want this, you'll have to get the command that you
|
||||||
|
run to pop up its own window with "xmessage" or something similar.
|
||||||
|
|
||||||
|
- IMPROVEMENT: tkremind: Make the "Go to date..." dialog non-modal.
|
||||||
|
|
||||||
|
- CHANGE: remind: Allow the argument to easterdate() and
|
||||||
|
orthodoxeaster() to be omitted, in which case it defaults to
|
||||||
|
today().
|
||||||
|
|
||||||
|
- BUG FIX: Miscellaneous man page fixes.
|
||||||
|
|
||||||
|
- BUG FIX: Fix a leap-year edge-case. The reminder: REM 29 MSG whatever
|
||||||
|
was not triggered on Feb 29 of leap years.
|
||||||
|
|
||||||
|
- BUG FIX: rem2html: Make the version of rem2html track the version of
|
||||||
|
Remind. Noted by Ian! D. Allen.
|
||||||
|
|
||||||
|
* VERSION 4.2 Patch 9 - 2024-02-04
|
||||||
|
|
||||||
|
- CHANGE: remind: Do not attempt to guess terminal background color on
|
||||||
|
startup. Only obtain it as needed. This can prevent mojibake from
|
||||||
|
appearing on terminals that don't support the color query escape
|
||||||
|
sequence.
|
||||||
|
|
||||||
|
- IMPROVEMENT: remind: Add new system variables $NumFullOmits,
|
||||||
|
$MaxFullOmits, $NumPartialOmits and $MaxPartialOmits.
|
||||||
|
|
||||||
|
- IMPROVEMENT: remind: Issue a warning if someone OMITs every possible date.
|
||||||
|
|
||||||
|
- IMPROVEMENT: remind: In several error messages complaining about limits
|
||||||
|
being exceeded, include the actual limit in the error message. Clarify
|
||||||
|
the man page regarding limits on the number of OMITs.
|
||||||
|
|
||||||
|
- MINOR NEW FEATURE: remind: The expression STRING * INT or INT * STRING
|
||||||
|
is now accepted and yields a string that is INT concatenations of the
|
||||||
|
original STRING. In this case, INT must be non-negative and the total
|
||||||
|
string length can't exceed $MaxStringLen.
|
||||||
|
|
||||||
|
- DOCUMENTATION: Add "Astronomical Algorithms" by Jean Meeus to bibliography.
|
||||||
|
|
||||||
|
- DOCUMENTATION FIX: Update address of the Free Software Foundation in the
|
||||||
|
license file.
|
||||||
|
|
||||||
|
- DOCUMENTATION: Note that rem2ps is deprecated and will not received any
|
||||||
|
new features. Further development will happen on rem2pdf.
|
||||||
|
|
||||||
|
- BUG FIX: Preserve the filename() and priority context for queued reminders.
|
||||||
|
Previously, the filename information was lost and the priority was
|
||||||
|
coming from uninitialized memory (yikes!). bug found by Alexander
|
||||||
|
Möller.
|
||||||
|
|
||||||
|
- BUG FIX: build.tk: Various minor improvements.
|
||||||
|
|
||||||
|
- BUG FIX: remind: In server mode, if we de-queue a reminder without
|
||||||
|
triggering it, issue a "NOTE queued %d" message to update the
|
||||||
|
client's notion of the queue size.
|
||||||
|
|
||||||
|
- BUG FIX: tkremind: Fix typo found by Lorenzo Bazzanini.
|
||||||
|
|
||||||
|
* VERSION 4.2 Patch 8 - 2023-12-14
|
||||||
|
|
||||||
|
- NEW FEATURE: Add the $MaxLateMinutes system variable. This suppresses
|
||||||
|
a queued time reminder if the current time is more than $MaxLateMinutes
|
||||||
|
past the trigger time. (This typically only occurs if the computer
|
||||||
|
has been suspended/hibernated and then resumed.)
|
||||||
|
|
||||||
|
- IMPROVEMENT: tkremind: If an error occurs during printing, catch it
|
||||||
|
and change the Queue... button to Errors... (the same way errors in
|
||||||
|
reminder files are handled.)
|
||||||
|
|
||||||
|
- IMPROVEMENT: rem2html: add the --utf8 flag to set the HTML charset to
|
||||||
|
UTF-8.
|
||||||
|
|
||||||
|
- MINOR IMPROVEMENTS: Refactor some of the C code; use symbolic exit
|
||||||
|
statuses and file descriptors for stdin/stdout/stderr where possible.
|
||||||
|
|
||||||
|
- BUG FIX: configure.in: Use better option detection so we don't use the
|
||||||
|
unsupported option -ffat-lto-objects if compiling with clang instead of gcc.
|
||||||
|
|
||||||
|
- BUG FIXES: Many fixes to man pages, some by Jochen Sprickerhof
|
||||||
|
|
||||||
|
- MINOR BUG FIX: If Remind puts itself in the background, only close
|
||||||
|
stdout/stderr if they are not associated with a terminal. If
|
||||||
|
we close a descriptor, dup /dev/null onto it.
|
||||||
|
|
||||||
|
- MINOR BUG FIX: Catch SIGCONT when running in daemon/background mode.
|
||||||
|
This forces the select() call to be interrupted so we can update the
|
||||||
|
sleep time. This really only matters if the computer or the background
|
||||||
|
Remind process is suspended and then resumed.
|
||||||
|
|
||||||
|
* VERSION 4.2 Patch 7 - 2023-10-09
|
||||||
|
|
||||||
|
- IMPROVEMENT: remind: On 32-bit systems, attempt to use a 64-bit time_t
|
||||||
|
if the C library supports that. This lets Remind work properly with
|
||||||
|
dates after 2038 in the few cases it has to call mktime() internally.
|
||||||
|
|
||||||
|
- MINOR NEW FEATURE: remind: Attempt to obtain the terminal background
|
||||||
|
color using an OSC sequence. This normally only happens if standard
|
||||||
|
output is a terminal, but can be forced with the '-@..,t' option.
|
||||||
|
|
||||||
|
- MINOR NEW FEATURE: remind: Add "--version" long option to print out
|
||||||
|
Remind's version and exit.
|
||||||
|
|
||||||
|
- MINOR IMPROVEMENT: tkremind: Use a higher-resolution PNG image for
|
||||||
|
the icon.
|
||||||
|
|
||||||
|
- MINOR IMPROVEMENT: remind-conf-mode.el: Update highlighting rules
|
||||||
|
courtesy of Bill Benedetto
|
||||||
|
|
||||||
|
- MINOR CHANGE: Make AT optional. If we encounter a TIME in a REM
|
||||||
|
command, implicitly begin an AT clause.
|
||||||
|
|
||||||
|
- DOCUMENTATION: Many minor fixes and improvements courtesy of Dan Jacobson.
|
||||||
|
|
||||||
|
- BUG FIX: Make "-w0" set the calendar width based on standard output
|
||||||
|
rather than setting it to zero and causing an infinite loop.
|
||||||
|
|
||||||
|
* VERSION 4.2 Patch 6 - 2023-09-12
|
||||||
|
|
||||||
|
- NEW FEATURE: remind: The "nonomitted()" function takes an optional
|
||||||
|
extra INT argument called "step". See man page for details. Also
|
||||||
|
allows the "start" argument to be greater than the "end" argument,
|
||||||
|
in which case they are effectively swapped.
|
||||||
|
|
||||||
|
- NEW FEATURE: remind: The "slide()" function takes an optional extra
|
||||||
|
INT argument called "step", similar to "nonomitted()". See man page
|
||||||
|
for details.
|
||||||
|
|
||||||
|
- NEW FEATURE: remind: Added the $ParseUntriggered system variable;
|
||||||
|
see the man page for details. You almost certainly will never need
|
||||||
|
to use this.
|
||||||
|
|
||||||
|
- NEW FILE: holidays/ie.rem: Added Irish holidays, courtesy of
|
||||||
|
Amy de Buitléir.
|
||||||
|
|
||||||
|
- CHANGE: remind: The "-tn" option sets all REM statement deltas to
|
||||||
|
++n rather than adding n to any existing REM statement's delta.
|
||||||
|
Additionally, the corresponding system variable $DeltaOffset has
|
||||||
|
been renamed to $DeltaOverride.
|
||||||
|
|
||||||
|
- NEW OPTION: remind: Add the "-tz" option to explicitly set all
|
||||||
|
REM statement deltas to zero.
|
||||||
|
|
||||||
|
- DOCUMENTATION FIX: remind: various documentation improvements.
|
||||||
|
|
||||||
|
- BUG FIX: Correct some errors in Italian localization, courtesy of
|
||||||
|
Emanuele Torre
|
||||||
|
|
||||||
|
* VERSION 4.2 Patch 5 - 2023-04-11
|
||||||
|
|
||||||
|
- MINOR IMPROVEMENT: remind: If someone uses OMIT yyyy-mm-dd UNTIL yyyy-mm-dd
|
||||||
|
give a better error message suggesting THROUGH instead of UNTIL.
|
||||||
|
|
||||||
|
- BUG FIX: remind: The fix for the combination of ADDOMIT and SATISFY that
|
||||||
|
appeared in version 04.02.00 was not complete; the bug has finally been
|
||||||
|
properly fixed.
|
||||||
|
|
||||||
|
- BUG FIX: remind: Remove an unnecessary #include <sys/file.h>.
|
||||||
|
Nothing needed that and it broke compilation on FreeBSD.
|
||||||
|
|
||||||
|
* VERSION 4.2 Patch 4 - 2023-03-15
|
||||||
|
|
||||||
|
- NEW FEATURE: Remind: Add "htmlescape" and "htmlstriptags" built-in
|
||||||
|
functions.
|
||||||
|
|
||||||
|
- NEW FEATURE: Rem2PDF: Add the "--wrap, -y" option to ensure that no
|
||||||
|
printed calendar takes up more than 5 rows. If a calendar would normally
|
||||||
|
require 6 rows, wrap it so the last day or two appear on the first
|
||||||
|
row instead of on a sixth row.
|
||||||
|
|
||||||
|
- NEW FEATURE: Remind: Improve the -k option to allow specification of
|
||||||
|
separate commands for immediately-issued vs. queued reminders. For
|
||||||
|
example:
|
||||||
|
|
||||||
|
remind '-kcmd1 %s' '-k:cmd2 %s' ...
|
||||||
|
|
||||||
|
will use "cmd1" for immediately-issued reminders and "cmd2" for queued
|
||||||
|
ones. If you only use '-k:cmd2 %s' then immediately-issued reminders
|
||||||
|
are simply printed as usual rather than being passed to a command.
|
||||||
|
|
||||||
|
- IMPROVEMENT: Remind: Make "SPECIAL MSG" the same as just "MSG" and
|
||||||
|
the same for MSF, RUN, PS and PSFILE. This effectively lets you use
|
||||||
|
expression-pasting to determine the type of a REM command; see the
|
||||||
|
remind(1) man page for details.
|
||||||
|
|
||||||
|
- MINOR IMPROVEMENT: If "make test" fails, output up to 200 lines of diff
|
||||||
|
so we can see immediately what failed.
|
||||||
|
|
||||||
|
- DOCUMENTATION FIX: Fix some typos; fix TkRemind syntax description.
|
||||||
|
|
||||||
|
- TEST FIX: Make tests run reliably regardless of local machine's time zone.
|
||||||
|
|
||||||
|
- BUG FIX: TkRemind: Don't crash if local installation of Tk lacks the
|
||||||
|
-underlinefg configuration option.
|
||||||
|
|
||||||
|
- BUG FIX: examples/defs.rem: Fix up US Thanksgiving example.
|
||||||
|
|
||||||
|
- BUG FIX: include/holidays/us.rem: Add logic for US holidays that are
|
||||||
|
observed on a Friday if the holiday is a Saturday, or on a Monday if the
|
||||||
|
holiday is a Sunday.
|
||||||
|
|
||||||
|
- BUG FIX: TkRemind: Don't cut off MOON text at the first white-space
|
||||||
|
character.
|
||||||
|
|
||||||
|
- BUG FIX: Remind: prevent functions defined on the command-line (as in
|
||||||
|
remind '-if(x)=whatever') from segfaulting.
|
||||||
|
|
||||||
|
* VERSION 4.2 Patch 3 - 2023-02-10
|
||||||
|
|
||||||
|
- NEW FEATURE: Remind: add the orthodoxeaster() function to return the
|
||||||
|
date of Orthodox Easter.
|
||||||
|
|
||||||
|
- IMPROVEMENT: Add Greek language support courtesy of JeiEl.
|
||||||
|
|
||||||
|
- IMPROVEMENT: Add Greek holiday file courtesy of JeiEl.
|
||||||
|
|
||||||
|
- IMPROVEMENT: Fix the Perl code (rem2pdf, rem2html) to silence Perl::Critic
|
||||||
|
warnings
|
||||||
|
|
||||||
|
- IMPROVEMENT: Many internal code tweaks to eliminate many cppcheck
|
||||||
|
static analysis warnings.
|
||||||
|
|
||||||
|
- DOCUMENTATION IMPROVEMENT: Clarify the distinction between a "time"
|
||||||
|
and a "duration" as suggested by Ian! D. Allen.
|
||||||
|
|
||||||
|
- BUG FIX: Remind: Fix incorrect interaction between sortbanner() and
|
||||||
|
MSF-type reminders. Bug found by Tim Chase.
|
||||||
|
|
||||||
|
- BUG FIX: examples/defs.rem: Fix the calculation of US Tax Day as per
|
||||||
|
Tavis Ormandy and Tim Chase. Also fixed in include/holidays/us.rem
|
||||||
|
|
||||||
|
- BUG FIX: Remind: Add missing #include <fcntl.h> to funcs.c
|
||||||
|
|
||||||
|
- BUG FIX: Remind: Fix undefined integer-overflow behavior in built-in abs()
|
||||||
|
function. Pointed out on IRC by "ubitux".
|
||||||
|
|
||||||
* VERSION 4.2 Patch 2 - 2023-01-01
|
* VERSION 4.2 Patch 2 - 2023-01-01
|
||||||
|
|
||||||
- NEW FEATURE: Remind: Add the NOQUEUE modifier to the REM statement for
|
- NEW FEATURE: Remind: Add the NOQUEUE modifier to the REM statement for
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ FSET center(x) pad("", " ", (columns() - columns(x))/2) + x
|
|||||||
FSET right(x) pad("", " ", columns() - columns(x)) + x
|
FSET right(x) pad("", " ", columns() - columns(x)) + x
|
||||||
|
|
||||||
MSG This is left-aligned.
|
MSG This is left-aligned.
|
||||||
MSG [ansicolor(0,255,0)]This is also left-aligned.[ansicolor("")]
|
MSG [ansicolor(0,255,0)]🌕 🌕 🌕 🌕 This is also left-aligned.[ansicolor("")]
|
||||||
|
|
||||||
MSG [center("This is centered.")]
|
MSG [center("This is centered.")]
|
||||||
MSG [ansicolor(255,255,0) + center("🌕 🌕 🌕 🌕 This is also centered. ") + ansicolor("")]
|
MSG [ansicolor(255,255,0) + center("🌕 🌕 🌕 🌕 This is also centered. ") + ansicolor("")]
|
||||||
|
|||||||
@@ -8,15 +8,13 @@
|
|||||||
# Set this variable to 1 if your terminal has a dark background or 0 if
|
# Set this variable to 1 if your terminal has a dark background or 0 if
|
||||||
# it: light.
|
# it: light.
|
||||||
|
|
||||||
bg_dark=1
|
|
||||||
|
|
||||||
# Set your latitude and longitude correctly for Sunrise/Sunset/Equinox/Solstice
|
# Set your latitude and longitude correctly for Sunrise/Sunset/Equinox/Solstice
|
||||||
#
|
#
|
||||||
# The values below are for Ottawa, Ontario, Canada
|
# The values below are for Ottawa, Ontario, Canada
|
||||||
latitude="45.420556"
|
latitude="45.420556"
|
||||||
longitude="-75.689722"
|
longitude="-75.689722"
|
||||||
|
|
||||||
remind -g -ibg_dark="$bg_dark" "-i\$Latitude=\"$latitude\"" "-i\$Longitude=\"$longitude\"" -q -@2 - "$@" <<'EOF'
|
remind -g "-i\$Latitude=\"$latitude\"" "-i\$Longitude=\"$longitude\"" -q -@2 - "$@" <<'EOF'
|
||||||
SET $AddBlankLines 0
|
SET $AddBlankLines 0
|
||||||
BANNER %
|
BANNER %
|
||||||
|
|
||||||
@@ -24,24 +22,25 @@ INCLUDE [$SysInclude]/ansitext.rem
|
|||||||
|
|
||||||
MSG Today is [ansi_bold][$T][ansi_normal], being the [ord($T-date(year($T),1,1)+1)] day of [year($T)].%_
|
MSG Today is [ansi_bold][$T][ansi_normal], being the [ord($T-date(year($T),1,1)+1)] day of [year($T)].%_
|
||||||
|
|
||||||
IF bg_dark
|
IF $TerminalBackground == 0
|
||||||
SPECIAL COLOR 255 255 0 Sunrise: 🌅 [sunrise()] today and [sunrise($T+1)] tomorrow
|
SPECIAL COLOR 255 255 0 Sunrise: 🌅 [sunrise()] today and [sunrise($T+1)] tomorrow
|
||||||
SPECIAL COLOR 255 128 0 Sunset: 🌇 [sunset()] today and [sunset($T+1)] tomorrow%_
|
SPECIAL COLOR 255 128 0 Sunset: 🌇 [sunset()] today and [sunset($T+1)] tomorrow%_
|
||||||
|
ELSE
|
||||||
|
SPECIAL COLOR 128 128 0 Sunrise: 🌅 [sunrise()] today and [sunrise($T+1)] tomorrow
|
||||||
|
SPECIAL COLOR 128 32 0 Sunset: 🌇 [sunset()] today and [sunset($T+1)] tomorrow%_
|
||||||
|
|
||||||
ENDIF
|
ENDIF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
remind -g -ibg_dark="$bg_dark" "-i\$Latitude=\"$latitude\"" "-i\$Longitude=\"$longitude\"" -q -@2 - "$@" <<'EOF'
|
remind -g "-i\$Latitude=\"$latitude\"" "-i\$Longitude=\"$longitude\"" -q -@2 - "$@" <<'EOF'
|
||||||
SET $AddBlankLines 0
|
SET $AddBlankLines 0
|
||||||
BANNER %
|
BANNER %
|
||||||
IF bg_dark
|
IF $TerminalBackground == 0
|
||||||
REM [moondatetime(0)] +60 SPECIAL COLOR 255 255 0 New moon: 🌑 [$T] %3 (%b)
|
REM [moondatetime(0)] +60 SPECIAL COLOR 255 255 0 New moon: 🌑 [$T] %3 (%b)
|
||||||
REM [moondatetime(1)] +60 SPECIAL COLOR 255 255 128 First Quarter: 🌓 [$T] %3 (%b)
|
REM [moondatetime(1)] +60 SPECIAL COLOR 255 255 128 First Quarter: 🌓 [$T] %3 (%b)
|
||||||
REM [moondatetime(2)] +60 SPECIAL COLOR 255 255 255 Full moon: 🌕 [$T] %3 (%b)
|
REM [moondatetime(2)] +60 SPECIAL COLOR 255 255 255 Full moon: 🌕 [$T] %3 (%b)
|
||||||
REM [moondatetime(3)] +60 SPECIAL COLOR 255 255 128 Last Quarter: 🌗 [$T] %3 (%b)
|
REM [moondatetime(3)] +60 SPECIAL COLOR 255 255 128 Last Quarter: 🌗 [$T] %3 (%b)
|
||||||
ELSE
|
ELSE
|
||||||
SPECIAL COLOR 128 128 0 Sunrise: 🌅 [sunrise()] today and [sunrise($T+1)] tomorrow
|
|
||||||
SPECIAL COLOR 128 32 0 Sunset: 🌇 [sunset()] today and [sunset($T+1)] tomorrow%_
|
|
||||||
|
|
||||||
REM [moondatetime(0)] +60 SPECIAL COLOR 128 128 0 New moon: 🌑 [$T] %3 (%b)
|
REM [moondatetime(0)] +60 SPECIAL COLOR 128 128 0 New moon: 🌑 [$T] %3 (%b)
|
||||||
REM [moondatetime(1)] +60 SPECIAL COLOR 128 128 64 First Quarter: 🌓 [$T] %3 (%b)
|
REM [moondatetime(1)] +60 SPECIAL COLOR 128 128 64 First Quarter: 🌓 [$T] %3 (%b)
|
||||||
REM [moondatetime(2)] +60 SPECIAL COLOR 0 0 0 Full moon: 🌕 [$T] %3 (%b)
|
REM [moondatetime(2)] +60 SPECIAL COLOR 0 0 0 Full moon: 🌕 [$T] %3 (%b)
|
||||||
@@ -51,7 +50,7 @@ EOF
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
remind -g -ibg_dark="$bg_dark" "-i\$Latitude=\"$latitude\"" "-i\$Longitude=\"$longitude\"" -q -@2 - "$@" <<'EOF'
|
remind -g "-i\$Latitude=\"$latitude\"" "-i\$Longitude=\"$longitude\"" -q -@2 - "$@" <<'EOF'
|
||||||
SET $AddBlankLines 0
|
SET $AddBlankLines 0
|
||||||
BANNER %
|
BANNER %
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
# "#PSSTUFF" for nifty PostScript examples #
|
# "#PSSTUFF" for nifty PostScript examples #
|
||||||
# #
|
# #
|
||||||
# This file is part of REMIND. #
|
# This file is part of REMIND. #
|
||||||
# Copyright (C) 1992-2023 Dianne Skoll #
|
# Copyright (C) 1992-2024 Dianne Skoll #
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
# #
|
# #
|
||||||
#############################################################################
|
#############################################################################
|
||||||
@@ -42,7 +42,6 @@ SET Week_1 1
|
|||||||
SET Week_2 8
|
SET Week_2 8
|
||||||
SET Week_3 15
|
SET Week_3 15
|
||||||
SET Week_4 22
|
SET Week_4 22
|
||||||
FSET _last(mo) "1 " + MON((mo%12)+1) + " --7"
|
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
# Function that removes a single leading zero from a string... #
|
# Function that removes a single leading zero from a string... #
|
||||||
@@ -126,6 +125,8 @@ REM Sat Sun SPECIAL SHADE 220
|
|||||||
# The following holidays were provided by Dave Rickel #
|
# The following holidays were provided by Dave Rickel #
|
||||||
# Modified by D. Skoll to give safe OMITs for moveable holidays #
|
# Modified by D. Skoll to give safe OMITs for moveable holidays #
|
||||||
# #
|
# #
|
||||||
|
# NOTE: See include/holidays/us.rem for more up-to-date definitions #
|
||||||
|
# #
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
SET SaveTrig $NumTrig
|
SET SaveTrig $NumTrig
|
||||||
@@ -157,7 +158,24 @@ REM Last Sunday in October ++2 UNTIL 1 Jan 2007 MSG Daylight Saving Time - %"DST
|
|||||||
REM First Sunday in November ++2 FROM 1 Jan 2007 MSG Daylight Saving Time - %"DST ends%" %b
|
REM First Sunday in November ++2 FROM 1 Jan 2007 MSG Daylight Saving Time - %"DST ends%" %b
|
||||||
|
|
||||||
REM Apr 1 MSG %"April Fool's%" Day
|
REM Apr 1 MSG %"April Fool's%" Day
|
||||||
REM Mon Tue Wed Thu Fri Sat 15 Apr MSG %"Income tax%" due
|
|
||||||
|
# US Tax Day
|
||||||
|
PUSH-OMIT-CONTEXT
|
||||||
|
# Normal case: 16 April falls Mon-Fri
|
||||||
|
REM 16 Apr SCANFROM -7 ADDOMIT SATISFY [$Tw >= 1 && $Tw <= 5] MSG Emancipation Day
|
||||||
|
|
||||||
|
# 16 April falls on Saturday: Observe on the 15th
|
||||||
|
REM 15 Apr SCANFROM -7 ADDOMIT SATISFY [$Tw == 5] MSG Emancipation Day (observed)
|
||||||
|
|
||||||
|
# 16 April falls on Sunday: Observe on the 17th
|
||||||
|
REM 17 Apr SCANFROM -7 ADDOMIT SATISFY [$Tw == 1] MSG Emancipation Day (observed)
|
||||||
|
|
||||||
|
# If you live in Maine or Massachussetts, uncomment the next line
|
||||||
|
# REM Third Monday in April SCANFROM -7 ADDOMIT MSG Patriots Day
|
||||||
|
|
||||||
|
REM Apr 15 OMIT Sat Sun AFTER MSG Tax Day
|
||||||
|
POP-OMIT-CONTEXT
|
||||||
|
|
||||||
REM May 5 MSG %"Cinco de Mayo%"
|
REM May 5 MSG %"Cinco de Mayo%"
|
||||||
REM First Sat in May MSG %"Kentucky Derby%"
|
REM First Sat in May MSG %"Kentucky Derby%"
|
||||||
REM Second Sun in May MSG %"Mother's Day%"
|
REM Second Sun in May MSG %"Mother's Day%"
|
||||||
@@ -172,7 +190,7 @@ REM Nov 11 MSG %"Veterans Day%"
|
|||||||
REM Oct 30 MSG %"Mischief Night%"
|
REM Oct 30 MSG %"Mischief Night%"
|
||||||
REM Oct 31 MSG %"Halloween%"
|
REM Oct 31 MSG %"Halloween%"
|
||||||
REM Tue Nov 2 SCANFROM -7 SATISFY [($Ty % 4) == 0] MSG %"Election Day%"
|
REM Tue Nov 2 SCANFROM -7 SATISFY [($Ty % 4) == 0] MSG %"Election Day%"
|
||||||
REM Last Thu in Nov SCANFROM -7 ADDOMIT MSG %"Thanksgiving Day%"
|
REM Thu Nov [Week_4] SCANFROM -7 ADDOMIT MSG %"Thanksgiving Day%"
|
||||||
REM Fri Nov [Week_4+1] SCANFROM -7 ADDOMIT MSG %"Thanksgiving (cont.)%"
|
REM Fri Nov [Week_4+1] SCANFROM -7 ADDOMIT MSG %"Thanksgiving (cont.)%"
|
||||||
OMIT Dec 24 MSG %"Christmas Eve%"
|
OMIT Dec 24 MSG %"Christmas Eve%"
|
||||||
OMIT Dec 25 MSG %"Christmas%" Day
|
OMIT Dec 25 MSG %"Christmas%" Day
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Not all sequences are supported by all terminals.
|
# Not all sequences are supported by all terminals.
|
||||||
|
|
||||||
# This file is part of REMIND
|
# This file is part of REMIND
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
if !defined("ansi_bold")
|
if !defined("ansi_bold")
|
||||||
|
|||||||
39
include/holidays/gr.rem
Normal file
39
include/holidays/gr.rem
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Greek national holidays
|
||||||
|
# ΑΡΓΙΕΣ (για όλους)
|
||||||
|
|
||||||
|
# fixed
|
||||||
|
REM 1 Jan MSG ΠΡΩΤΟΧΡΟΝΙΑ
|
||||||
|
REM 6 Jan MSG ΤΑ ΦΩΤΑ/ ΘΕΟΦΑΝΕΙΑ
|
||||||
|
REM 25 Mar MSG η 25η Μαρτίου
|
||||||
|
REM 15 Aug MSG 15Αύγουστος
|
||||||
|
REM 28 Oct MSG ΟΧΙ
|
||||||
|
REM 25 Dec MSG ΧΡΙΣΤΟΥΓΕΝΝΑ
|
||||||
|
REM 26 Dec MSG ΧΡΙΣΤΟΥΓΕΝΝΑ2
|
||||||
|
|
||||||
|
REM [orthodoxeaster($Uy)+1] ΔΕΥΤΕΡΑ ΤΟΥ ΠΑΣΧΑ
|
||||||
|
|
||||||
|
|
||||||
|
# May first is a national holiday except if Sunday, day of great week (week before easter) or Monday after easter, then
|
||||||
|
# minister decides moving that holiday. Here is a likely assumption of how this day might be moved.
|
||||||
|
# Uncomment following lines to enable.
|
||||||
|
|
||||||
|
set PM date($Uy,5,1)
|
||||||
|
# IF PM>=orthodoxeaster($Uy)-7 && PM<=orthodoxeaster($Uy)+1
|
||||||
|
# IF PM<orthodoxeaster($Uy)-3
|
||||||
|
# REM orthodoxeaster($Uy) -8 MSG πιθανόν ΕΡΓΑΤΙΚΗ Πρωτομαγιά
|
||||||
|
# ELSE
|
||||||
|
# REM [plusfunc(2)] MSG πιθανόν ΕΡΓΑΤΙΚΗ Πρωτομαγιά
|
||||||
|
# ENDIF
|
||||||
|
# ENDIF
|
||||||
|
# REM [PM] OMIT Sun AFTER MSG Πρωτομαγιά
|
||||||
|
|
||||||
|
REM 1 May MSG Πρωτομαγιά
|
||||||
|
# end of May 1 speculations
|
||||||
|
|
||||||
|
# The following are main national holidays per custom (observed by most but not all)
|
||||||
|
REM [orthodoxeaster($Uy)] -48 MSG Καθαρά Δευτέρα
|
||||||
|
REM [orthodoxeaster($Uy)] -2 MSG Μεγάλη Παρασκευή
|
||||||
|
REM [orthodoxeaster($Uy)] -1 MSG Μεγάλο Σάββατο
|
||||||
|
REM [orthodoxeaster($Uy)+50] MSG Αγίου Πνεύματος
|
||||||
|
|
||||||
|
|
||||||
42
include/holidays/ie.rem
Normal file
42
include/holidays/ie.rem
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
;
|
||||||
|
; Irish Holidays
|
||||||
|
;
|
||||||
|
; The dates for the Public ("bank") holidays are taken from the following site:
|
||||||
|
; https://www.citizensinformation.ie/en/employment/employment-rights-and-conditions/leave-and-holidays/public-holidays/
|
||||||
|
;
|
||||||
|
; This file was derived from:
|
||||||
|
; https://github.com/mhwombat/dotWombat/blob/master/.config/remind/IrishHolidays.rem
|
||||||
|
; by Amy de Buitléir.
|
||||||
|
|
||||||
|
; fixed dates
|
||||||
|
OMIT 31 December MSG New Year's Eve (Oíche Chinn Bliana) Public Holiday
|
||||||
|
OMIT 1 January MSG New Year's Day (Lá Caille, Lá Bliana Nua) Public Holiday
|
||||||
|
OMIT 17 March MSG Saint Patrick's Day (Lá Fhéile Pádraig) Public Holiday
|
||||||
|
OMIT 24 December MSG Christmas Eve (Oíche Nollag) Public Holiday
|
||||||
|
OMIT 25 December MSG Christmas Day (Lá Nollag) Public Holiday
|
||||||
|
OMIT 26 December MSG Saint Stephen's Day, Wren Day (Lá Fhéile Stiofáin, Lá an Dreoilín) Public Holiday
|
||||||
|
|
||||||
|
; moving dates
|
||||||
|
|
||||||
|
; First Monday in May
|
||||||
|
REM Monday 1 May SCANFROM -7 ADDOMIT MSG May Day (Lá Bealtaine) Public Holiday
|
||||||
|
|
||||||
|
; First Monday in June
|
||||||
|
REM Monday 1 June SCANFROM -7 ADDOMIT MSG June Public Holiday
|
||||||
|
|
||||||
|
; First Monday in August
|
||||||
|
REM Monday 1 August SCANFROM -7 ADDOMIT MSG August Public Holiday
|
||||||
|
|
||||||
|
; Last Monday in October
|
||||||
|
REM Monday 1 -7 November SCANFROM -7 ADDOMIT MSG October Public Holiday
|
||||||
|
|
||||||
|
; Easter
|
||||||
|
SET easter easterdate(today())
|
||||||
|
REM [TRIGGER(easter-2)] MSG Good Friday (Aoine an Chéasta)
|
||||||
|
REM [TRIGGER(easter)] MSG Easter Sunday (Domhnach Cásca)
|
||||||
|
OMIT [TRIGGER(easter+1)] MSG Easter Monday (Luan Cásca) Public Holiday
|
||||||
|
|
||||||
|
; St. Brigid's Day
|
||||||
|
REM 1 February MSG Saint Brigid's Day (Lá Fhéile Bríde or Imbolc)
|
||||||
|
; The public holiday is the first Monday in February, or 1 February if the date falls on a Friday
|
||||||
|
REM February SCANFROM -7 ADDOMIT SATISFY [($Td==1 && $Tw==5) || ($Td<8 && $Tw==1 && $Td!=4)] MSG Public Holiday
|
||||||
@@ -106,7 +106,3 @@ IF !Reform
|
|||||||
[_PastSat(17, "Tamuz")] ++4 MSG %"Tzom Tammuz%" is %b.
|
[_PastSat(17, "Tamuz")] ++4 MSG %"Tzom Tammuz%" is %b.
|
||||||
[_PastSat(9, "Av")] ++4 MSG %"Tish'a B'Av%" is %b.
|
[_PastSat(9, "Av")] ++4 MSG %"Tish'a B'Av%" is %b.
|
||||||
ENDIF
|
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,6 +1,6 @@
|
|||||||
# US holidays
|
# US holidays
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# Copyright (C) 1992-2023 Dianne Skoll
|
# Copyright (C) 1992-2024 Dianne Skoll
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
REM [easterdate($Uy)-46] MSG Ash Wednesday
|
REM [easterdate($Uy)-46] MSG Ash Wednesday
|
||||||
@@ -14,6 +14,9 @@ REM [easterdate($Uy)+49] MSG Pentecost
|
|||||||
# which ones are omitted.
|
# which ones are omitted.
|
||||||
|
|
||||||
OMIT Jan 1 MSG New Year's Day
|
OMIT Jan 1 MSG New Year's Day
|
||||||
|
REM 31 Dec SCANFROM -7 ADDOMIT SATISFY [$Tw==5] MSG New Year's Day (observed)
|
||||||
|
REM 2 Jan SCANFROM -7 ADDOMIT SATISFY [$Tw==1] MSG New Year's Day (observed)
|
||||||
|
|
||||||
REM Third Monday in Jan MSG Martin Luther King - %"MLK Day%"
|
REM Third Monday in Jan MSG Martin Luther King - %"MLK Day%"
|
||||||
REM Feb 2 MSG Ground Hog Day
|
REM Feb 2 MSG Ground Hog Day
|
||||||
REM Feb 14 MSG Valentine's Day
|
REM Feb 14 MSG Valentine's Day
|
||||||
@@ -21,11 +24,27 @@ REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG President's Day
|
|||||||
REM Mar 17 MSG St. Patrick's Day
|
REM Mar 17 MSG St. Patrick's Day
|
||||||
|
|
||||||
# These are accurate for most places in North America
|
# These are accurate for most places in North America
|
||||||
REM MAYBE-UNCOMPUTABLE Sun November SATISFY [isdst($T) != isdst($T+1)] MSG Daylight Saving Time Ends
|
REM MAYBE-UNCOMPUTABLE Sun November SATISFY [isdst($T) && !isdst($T+1)] MSG Daylight Saving Time Ends
|
||||||
REM MAYBE-UNCOMPUTABLE Sun March SATISFY [isdst($T) != isdst($T+1)] MSG Daylight Saving Time Starts
|
REM MAYBE-UNCOMPUTABLE Sun March SATISFY [!isdst($T) && isdst($T+1)] MSG Daylight Saving Time Starts
|
||||||
|
|
||||||
REM Apr 1 MSG %"April Fool's%" Day
|
REM Apr 1 MSG %"April Fool's%" Day
|
||||||
REM Mon Tue Wed Thu Fri Sat 15 Apr MSG %"Income tax%" due
|
|
||||||
|
PUSH-OMIT-CONTEXT
|
||||||
|
# Normal case: 16 April falls Mon-Fri
|
||||||
|
REM 16 Apr SCANFROM -7 ADDOMIT SATISFY [$Tw >= 1 && $Tw <= 5] MSG Emancipation Day
|
||||||
|
|
||||||
|
# 16 April falls on Saturday: Observe on the 15th
|
||||||
|
REM 15 Apr SCANFROM -7 ADDOMIT SATISFY [$Tw == 5] MSG Emancipation Day (observed)
|
||||||
|
|
||||||
|
# 16 April falls on Sunday: Observe on the 17th
|
||||||
|
REM 17 Apr SCANFROM -7 ADDOMIT SATISFY [$Tw == 1] MSG Emancipation Day (observed)
|
||||||
|
|
||||||
|
# If you live in Maine or Massachussetts, uncomment the next line
|
||||||
|
# REM Third Monday in April SCANFROM -7 ADDOMIT MSG Patriots Day
|
||||||
|
|
||||||
|
REM Apr 15 OMIT Sat Sun AFTER MSG %"Income tax%" due
|
||||||
|
POP-OMIT-CONTEXT
|
||||||
|
|
||||||
REM May 5 MSG Cinco de Mayo
|
REM May 5 MSG Cinco de Mayo
|
||||||
REM First Sat in May MSG Kentucky Derby
|
REM First Sat in May MSG Kentucky Derby
|
||||||
REM Second Sun in May MSG Mother's Day
|
REM Second Sun in May MSG Mother's Day
|
||||||
@@ -33,14 +52,21 @@ REM Third Sat in May MSG Armed Forces Day
|
|||||||
REM Last Monday in May SCANFROM -7 ADDOMIT MSG Memorial Day
|
REM Last Monday in May SCANFROM -7 ADDOMIT MSG Memorial Day
|
||||||
REM Jun 14 MSG Flag Day
|
REM Jun 14 MSG Flag Day
|
||||||
|
|
||||||
|
OMIT 19 June MSG Juneteenth
|
||||||
|
REM 18 June SCANFROM -7 ADDOMIT SATISFY [$Tw==5] MSG Juneteenth (observed)
|
||||||
|
REM 20 June SCANFROM -7 ADDOMIT SATISFY [$Tw==1] MSG Juneteenth (observed)
|
||||||
|
|
||||||
REM July 4 SCANFROM -7 ADDOMIT MSG Independence Day
|
REM July 4 SCANFROM -7 ADDOMIT MSG Independence Day
|
||||||
REM July 3 SCANFROM -7 ADDOMIT SATISFY [$Tw == 5] MSG Independence Day (observed)
|
REM July 3 SCANFROM -7 ADDOMIT SATISFY [$Tw==5] MSG Independence Day (observed)
|
||||||
REM July 5 SCANFROM -7 ADDOMIT SATISFY [$Tw == 1] MSG Independence Day (observed)
|
REM July 5 SCANFROM -7 ADDOMIT SATISFY [$Tw==1] MSG Independence Day (observed)
|
||||||
|
|
||||||
REM Third Sun in June MSG Father's Day
|
REM Third Sun in June MSG Father's Day
|
||||||
REM First Mon in Sep SCANFROM -7 ADDOMIT MSG Labor Day
|
REM First Mon in Sep SCANFROM -7 ADDOMIT MSG Labor Day
|
||||||
REM Second Mon in Oct MSG Columbus Day / Indigenous Peoples' Day
|
REM Second Mon in Oct MSG Columbus Day / Indigenous Peoples' Day
|
||||||
REM Nov 11 MSG Veterans Day
|
|
||||||
|
OMIT 11 Nov MSG Veterans Day
|
||||||
|
REM 10 Nov SCANFROM -7 ADDOMIT SATISFY [$Tw==5] MSG Veterans Day (observed)
|
||||||
|
REM 12 Nov SCANFROM -7 ADDOMIT SATISFY [$Tw==1] MSG Veterans Day (observed)
|
||||||
|
|
||||||
REM Oct 30 MSG Mischief Night
|
REM Oct 30 MSG Mischief Night
|
||||||
REM Oct 31 MSG Halloween
|
REM Oct 31 MSG Halloween
|
||||||
@@ -48,8 +74,9 @@ REM Oct 31 MSG Halloween
|
|||||||
REM Tue Nov 2 SCANFROM -7 SATISFY [($Ty % 4) == 0] MSG Election Day
|
REM Tue Nov 2 SCANFROM -7 SATISFY [($Ty % 4) == 0] MSG Election Day
|
||||||
|
|
||||||
REM Thu 22 Nov SCANFROM -7 ADDOMIT MSG Thanksgiving Day
|
REM Thu 22 Nov SCANFROM -7 ADDOMIT MSG Thanksgiving Day
|
||||||
|
|
||||||
REM Fri 23 Nov SCANFROM -7 ADDOMIT MSG Thanksgiving (cont.)
|
REM Fri 23 Nov SCANFROM -7 ADDOMIT MSG Thanksgiving (cont.)
|
||||||
|
|
||||||
REM Dec 24 MSG Christmas Eve
|
REM Dec 24 MSG Christmas Eve
|
||||||
OMIT Dec 25 MSG %"Christmas%" Day
|
OMIT Dec 25 MSG %"Christmas%" Day
|
||||||
|
REM 24 Dec SCANFROM -7 ADDOMIT SATISFY [$Tw==5] MSG Christmas (observed)
|
||||||
|
REM 26 Dec SCANFROM -7 ADDOMIT SATISFY [$Tw==1] MSG Christmas (observed)
|
||||||
|
|||||||
@@ -1,20 +1,28 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
SET autolang getenv("LC_ALL")
|
if !defined("__autolang__")
|
||||||
IF autolang == ""
|
SET __autolang__ 1
|
||||||
SET autolang getenv("LANGUAGE")
|
PRESERVE __autolang__
|
||||||
ENDIF
|
SET autolang getenv("REMIND_LANG")
|
||||||
IF autolang == ""
|
|
||||||
SET autolang getenv("LANG")
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
IF autolang != ""
|
IF autolang == ""
|
||||||
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 5)) + ".rem", "r") == 0
|
SET autolang getenv("LC_ALL")
|
||||||
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 5))].rem
|
ENDIF
|
||||||
ELSE
|
IF autolang == ""
|
||||||
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 2)) + ".rem", "r") == 0
|
SET autolang getenv("LANGUAGE")
|
||||||
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 2))].rem
|
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
|
||||||
|
ENDIF
|
||||||
ENDIF
|
ENDIF
|
||||||
ENDIF
|
ENDIF
|
||||||
|
UNSET autolang
|
||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
UNSET autolang
|
|
||||||
|
|||||||
53
include/lang/ca.rem
Normal file
53
include/lang/ca.rem
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Support for the Catalan language.
|
||||||
|
# This file is part of REMIND.
|
||||||
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
|
# This file was created by Eloi Torrents <eloitor@disroot.org>
|
||||||
|
|
||||||
|
SET $Monday "dilluns"
|
||||||
|
SET $Tuesday "dimarts"
|
||||||
|
SET $Wednesday "dimecres"
|
||||||
|
SET $Thursday "dijous"
|
||||||
|
SET $Friday "divendres"
|
||||||
|
SET $Saturday "dissabte"
|
||||||
|
SET $Sunday "diumenge"
|
||||||
|
|
||||||
|
SET $January "gener"
|
||||||
|
SET $February "febrer"
|
||||||
|
SET $March "març"
|
||||||
|
SET $April "abril"
|
||||||
|
SET $May "maig"
|
||||||
|
SET $June "juny"
|
||||||
|
SET $July "juliol"
|
||||||
|
SET $August "agost"
|
||||||
|
SET $September "setembre"
|
||||||
|
SET $October "octubre"
|
||||||
|
SET $November "novembre"
|
||||||
|
SET $December "desembre"
|
||||||
|
|
||||||
|
SET $Today "avui"
|
||||||
|
SET $Tomorrow "demà"
|
||||||
|
FSET subst_bx(a,d,t) iif(d==today()+2, "demà passat", "d'aquí " + (d-today()) + " dies")
|
||||||
|
|
||||||
|
# 1 d'abril vs 1 de maig.
|
||||||
|
FSET subst_sx(a,d,t) iif(isany(substr(mon(d), 1, 1), "a", "o") , "d'", "de")
|
||||||
|
FSET subst_ordinal(d) ""
|
||||||
|
|
||||||
|
BANNER Agenda pel %w, %d %s %m de %y%o:
|
||||||
|
|
||||||
|
SET $Am "am"
|
||||||
|
SET $Pm "pm"
|
||||||
|
|
||||||
|
SET $Ago "fa"
|
||||||
|
SET $Fromnow "des d'avui"
|
||||||
|
SET $On "el dia"
|
||||||
|
SET $Now "ara"
|
||||||
|
SET $At "a les"
|
||||||
|
|
||||||
|
SET $Minute "minut"
|
||||||
|
SET $Mplu "s"
|
||||||
|
SET $Hour "hora"
|
||||||
|
FSET subst_hours(h) iif(h==1, "1 hora", h + " hores")
|
||||||
|
|
||||||
|
SET $Is "és"
|
||||||
|
SET $Was "va ser"
|
||||||
|
SET $And "i"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the Danish language.
|
# Support for the Danish language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Mogens Lynnerup.
|
# This file is derived from a translation by Mogens Lynnerup.
|
||||||
|
|
||||||
SET $Sunday "Søndag"
|
SET $Sunday "Søndag"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the German language.
|
# Support for the German language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Wolfgang Thronicke
|
# This file is derived from a translation by Wolfgang Thronicke
|
||||||
|
|
||||||
# Day names
|
# Day names
|
||||||
@@ -87,3 +87,5 @@ SET daylightST_starts_str "Beginn Sommerzeit"
|
|||||||
|
|
||||||
# Daylight saving time ends
|
# Daylight saving time ends
|
||||||
SET daylightST_ends_str "Ende Sommerzeit"
|
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
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Support for the English language.
|
# Support for the English language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# Nothing to do for English since it is the default.
|
# Nothing to do for English since it is the default.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the Spanish language.
|
# Support for the Spanish language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Rafa Couto <rafacouto@biogate.com>
|
# This file is derived from a translation by Rafa Couto <rafacouto@biogate.com>
|
||||||
|
|
||||||
SET $Sunday "Domingo"
|
SET $Sunday "Domingo"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the Finnish language.
|
# Support for the Finnish language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Mikko Silvonen
|
# This file is derived from a translation by Mikko Silvonen
|
||||||
|
|
||||||
SET $Sunday "sunnuntai"
|
SET $Sunday "sunnuntai"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the French language.
|
# Support for the French language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Laurent Duperval
|
# This file is derived from a translation by Laurent Duperval
|
||||||
|
|
||||||
SET $Sunday "dimanche"
|
SET $Sunday "dimanche"
|
||||||
|
|||||||
85
include/lang/gr.rem
Normal file
85
include/lang/gr.rem
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
# Support for the Hellenic (Greek) language.
|
||||||
|
# This file is part of REMIND.
|
||||||
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
|
# This file is derived from a translation by jarlaxl lamat (jarlaxl@freemail.gr)
|
||||||
|
|
||||||
|
SET $Sunday "Κυριακή"
|
||||||
|
SET $Monday "Δευτέρα"
|
||||||
|
SET $Tuesday "Τρίτη"
|
||||||
|
SET $Wednesday "Τετάρτη"
|
||||||
|
SET $Thursday "Πέμπτη"
|
||||||
|
SET $Friday "Παρασκευή"
|
||||||
|
SET $Saturday "Σάββατο"
|
||||||
|
|
||||||
|
SET $January "Ιανουάρ."
|
||||||
|
SET $February "Φεβρουάρ."
|
||||||
|
SET $March "Μάρτ."
|
||||||
|
SET $April "Απρίλ."
|
||||||
|
SET $May "Μαι."
|
||||||
|
SET $June "Ιούν."
|
||||||
|
SET $July "Ιούλ."
|
||||||
|
SET $August "Αυγουστ."
|
||||||
|
SET $September "Σεπτέμβρ."
|
||||||
|
SET $October "Οκτώβρ."
|
||||||
|
SET $November "Νοέμβρ."
|
||||||
|
SET $December "Δεκέμβρ."
|
||||||
|
|
||||||
|
SET $Today "σήμερα"
|
||||||
|
SET $Tomorrow "αύριο"
|
||||||
|
|
||||||
|
BANNER Υπενθυμίσεις: %w, %d %m, %y%o:
|
||||||
|
|
||||||
|
SET $Am "πμ"
|
||||||
|
SET $Pm "μμ"
|
||||||
|
|
||||||
|
SET $Ago "πριν"
|
||||||
|
SET $Fromnow "από τώρα"
|
||||||
|
|
||||||
|
SET $On "την"
|
||||||
|
|
||||||
|
SET $Now "τώρα"
|
||||||
|
SET $At "στις"
|
||||||
|
SET $Minute "λεπτά"
|
||||||
|
SET $Hour "ώρες"
|
||||||
|
SET $Is "είναι"
|
||||||
|
SET $Was "ήταν"
|
||||||
|
SET $And "και"
|
||||||
|
SET $Hplu ""
|
||||||
|
SET $Mplu ""
|
||||||
|
|
||||||
|
FSET subst_bx(a, d, t) "σε " + (d - today()) + " ημέρες"
|
||||||
|
FSET subst_ordinal(d) "."
|
||||||
|
FSET subst_a_alt(d) wkday(d) + ", " + day(d) + ". " + mon(d) + " " + year(d)
|
||||||
|
FSET subst_ax(alt, d, t) iif(alt, subst_a_alt(d), $On + " " + subst_a_alt(d))
|
||||||
|
FSET subst_g_alt(d) wkday(d) + ", " + day(d) + ". " + mon(d)
|
||||||
|
FSET subst_gx(alt, d, t) iif(alt, subst_g_alt(d), $On + " " + subst_g_alt(d))
|
||||||
|
FSET subst_ux(alt, d, t) subst_ax(alt, d, t)
|
||||||
|
FSET subst_vx(alt, d, t) subst_gx(alt, d, t)
|
||||||
|
|
||||||
|
# Localization of various astronomical events
|
||||||
|
|
||||||
|
# Perihelion
|
||||||
|
SET earthseasons_Perihelion_str "Περιήλιον"
|
||||||
|
|
||||||
|
# Vernal equinox
|
||||||
|
SET earthseasons_EquinoxMar_str "Εαρινή ισημερία"
|
||||||
|
|
||||||
|
# Summer solstice
|
||||||
|
SET earthseasons_SolsticeJun_str "Θερινό ηλιοστάσιο"
|
||||||
|
|
||||||
|
# Aphelion
|
||||||
|
SET earthseasons_Aphelion_str "Αφήλιον"
|
||||||
|
|
||||||
|
# Autumnal Equinox
|
||||||
|
SET earthseasons_EquinoxSep_str "Φθινοπωρινή ισημερία"
|
||||||
|
|
||||||
|
# Winter Solstice
|
||||||
|
SET earthseasons_SolsticeDec_str "Χειμερινό ηλιοστάσιο"
|
||||||
|
|
||||||
|
# Daylight saving time starts
|
||||||
|
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
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the Icelanding language.
|
# Support for the Icelanding language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Björn Davíðsson (bjossi@snerpa.is)
|
# This file is derived from a translation by Björn Davíðsson (bjossi@snerpa.is)
|
||||||
|
|
||||||
SET $Sunday "sunnudagur"
|
SET $Sunday "sunnudagur"
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
# Support for the Italian language.
|
# Support for the Italian language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Valerio Aimale
|
# This file is derived from a translation by Valerio Aimale
|
||||||
|
|
||||||
SET $Sunday "Domenica"
|
SET $Sunday "Domenica"
|
||||||
SET $Monday "Lunedí"
|
SET $Monday "Lunedì"
|
||||||
SET $Tuesday "Martedí"
|
SET $Tuesday "Martedì"
|
||||||
SET $Wednesday "Mercoledí"
|
SET $Wednesday "Mercoledì"
|
||||||
SET $Thursday "Giovedí"
|
SET $Thursday "Giovedì"
|
||||||
SET $Friday "Venerdí"
|
SET $Friday "Venerdì"
|
||||||
SET $Saturday "Sabato"
|
SET $Saturday "Sabato"
|
||||||
|
|
||||||
SET $January "Gennaio"
|
SET $January "Gennaio"
|
||||||
@@ -40,7 +40,7 @@ SET $Now "ora"
|
|||||||
SET $At "alle"
|
SET $At "alle"
|
||||||
SET $Minute "minuto"
|
SET $Minute "minuto"
|
||||||
SET $Hour "ora"
|
SET $Hour "ora"
|
||||||
SET $Is "é"
|
SET $Is "è"
|
||||||
SET $Was "era"
|
SET $Was "era"
|
||||||
SET $And "e"
|
SET $And "e"
|
||||||
SET $Hplu "a"
|
SET $Hplu "a"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the Dutch language.
|
# Support for the Dutch language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Willem Kasdorp and Erik-Jan Vens
|
# This file is derived from a translation by Willem Kasdorp and Erik-Jan Vens
|
||||||
|
|
||||||
SET $Sunday "zondag"
|
SET $Sunday "zondag"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the Norwegian language.
|
# Support for the Norwegian language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Trygve Randen
|
# This file is derived from a translation by Trygve Randen
|
||||||
|
|
||||||
SET $Sunday "Søndag"
|
SET $Sunday "Søndag"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the Polish language.
|
# Support for the Polish language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Jerzy Sobczyk
|
# This file is derived from a translation by Jerzy Sobczyk
|
||||||
|
|
||||||
SET $Sunday "Niedziela"
|
SET $Sunday "Niedziela"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the (Brazilian) Portuguese language.
|
# Support for the (Brazilian) Portuguese language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Marco Paganini
|
# This file is derived from a translation by Marco Paganini
|
||||||
|
|
||||||
SET $Sunday "domingo"
|
SET $Sunday "domingo"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Support for the Romanian language.
|
# Support for the Romanian language.
|
||||||
# This file is part of REMIND.
|
# This file is part of REMIND.
|
||||||
# REMIND is Copyright (C) 1992-2023 by Dianne Skoll
|
# REMIND is Copyright (C) 1992-2024 by Dianne Skoll
|
||||||
# This file is derived from a translation by Liviu Daia
|
# This file is derived from a translation by Liviu Daia
|
||||||
|
|
||||||
SET $Sunday "Duminică"
|
SET $Sunday "Duminică"
|
||||||
|
|||||||
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
|
||||||
@@ -19,4 +19,4 @@ Remind was written by Dianne Skoll <dianne@skoll.ca>
|
|||||||
.SH HOME PAGE
|
.SH HOME PAGE
|
||||||
https://dianne.skoll.ca/projects/remind/
|
https://dianne.skoll.ca/projects/remind/
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
\fBremind\fR
|
\fBremind\fR(1)
|
||||||
|
|||||||
@@ -5,22 +5,25 @@ rem2ps \- draw a PostScript calendar from Remind output
|
|||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B rem2ps [\fIoptions\fR]
|
.B rem2ps [\fIoptions\fR]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBRem2ps\fR reads the standard input, which should be the results of
|
\fBrem2ps\fR reads the standard input, which should be the results of
|
||||||
running \fBRemind\fR with the \fB\-p\fR or \fB\-pp\fR option. It
|
running \fBRemind\fR with the \fB\-p\fR or \fB\-pp\fR option. It
|
||||||
emits PostScript code (which draws a calendar) to the standard output.
|
emits PostScript code (which draws a calendar) to the standard output.
|
||||||
.PP
|
.PP
|
||||||
See the section "Rem2PS Input Format" for details about the \fB\-p\fR
|
Although \fBrem2ps\fR will be maintained, no new features will be added
|
||||||
|
to it. Instead, all new development will continue on \fBrem2pdf\fR.
|
||||||
|
.PP
|
||||||
|
See the section "REM2PS INPUT FORMAT" for details about the \fB\-p\fR
|
||||||
data. This may be useful if you wish to create other \fBRemind\fR
|
data. This may be useful if you wish to create other \fBRemind\fR
|
||||||
back-ends.
|
back-ends.
|
||||||
.PP
|
.PP
|
||||||
Note that \fBRem2PS\fR does not handle UTF-8 input. If you need to
|
Note that \fBrem2ps\fR does not handle UTF-8 input. If you need to
|
||||||
render characters outside the ASCII character set, see
|
render characters outside the ASCII character set, see
|
||||||
\fBrem2pdf\fR instead.
|
\fBrem2pdf\fR instead.
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
Be more verbose. This causes \fBRem2ps\fR to print progress messages
|
Be more verbose. This causes \fBrem2ps\fR to print progress messages
|
||||||
to the standard error stream. Normally, it is silent.
|
to the standard error stream. Normally, it is silent.
|
||||||
.TP
|
.TP
|
||||||
.B \-p file
|
.B \-p file
|
||||||
@@ -133,7 +136,7 @@ numbers.
|
|||||||
|
|
||||||
.PP
|
.PP
|
||||||
Type "rem2ps \-m help" for a list of available media. Note that the media
|
Type "rem2ps \-m help" for a list of available media. Note that the media
|
||||||
type (and all \fBRem2ps\fR options) are case-sensitive. If you don't use
|
type (and all \fBrem2ps\fR options) are case-sensitive. If you don't use
|
||||||
the \fB\-m\fR option, the media defaults to a compiled-in default - this
|
the \fB\-m\fR option, the media defaults to a compiled-in default - this
|
||||||
is usually Letter for North America and A4 for Europe. The "\-m help"
|
is usually Letter for North America and A4 for Europe. The "\-m help"
|
||||||
option will display the compiled-in default.
|
option will display the compiled-in default.
|
||||||
@@ -193,8 +196,8 @@ for good output:
|
|||||||
rem2ps \-ol 72 \-sh 12
|
rem2ps \-ol 72 \-sh 12
|
||||||
.fi
|
.fi
|
||||||
.SH USAGE
|
.SH USAGE
|
||||||
To use \fBRem2ps\fR, you should pipe the output of \fBRemind\fR with the \fB\-p\fR
|
To use \fBrem2ps\fR, you should pipe the output of \fBRemind\fR with the \fB\-p\fR
|
||||||
option to \fBRem2ps\fR, and then send the result to a printer. This is most easily
|
option to \fBrem2ps\fR, and then send the result to a printer. This is most easily
|
||||||
illustrated with examples:
|
illustrated with examples:
|
||||||
.PP
|
.PP
|
||||||
.nf
|
.nf
|
||||||
@@ -228,10 +231,10 @@ calendar entries. This border is normally blank space.
|
|||||||
.TP
|
.TP
|
||||||
BoxWidth and BoxHeight
|
BoxWidth and BoxHeight
|
||||||
The width and height of the calendar box, from center-to-center of the
|
The width and height of the calendar box, from center-to-center of the
|
||||||
black gridlines.
|
black grid lines.
|
||||||
.TP
|
.TP
|
||||||
InBoxHeight
|
InBoxHeight
|
||||||
The height from the center of the bottom black gridline to the top
|
The height from the center of the bottom black grid line to the top
|
||||||
of the regular calendar entry area. The space from here to the top
|
of the regular calendar entry area. The space from here to the top
|
||||||
of the box is used only to draw the day number.
|
of the box is used only to draw the day number.
|
||||||
.TP
|
.TP
|
||||||
@@ -260,7 +263,7 @@ PostScript files. Always test your PostScript thoroughly with a PostScript
|
|||||||
viewer before sending it to the printer. You should not use any document
|
viewer before sending it to the printer. You should not use any document
|
||||||
structuring comments in your PostScript code.
|
structuring comments in your PostScript code.
|
||||||
.PP
|
.PP
|
||||||
In addition, prior to drawing a calendar page, \fBRem2ps\fR emits
|
In addition, prior to drawing a calendar page, \fBrem2ps\fR emits
|
||||||
the following PostScript code:
|
the following PostScript code:
|
||||||
.PP
|
.PP
|
||||||
.nf
|
.nf
|
||||||
@@ -320,14 +323,14 @@ For an example, create a file called "myprolog" whose contents are:
|
|||||||
} bind def
|
} bind def
|
||||||
.fi
|
.fi
|
||||||
.PP
|
.PP
|
||||||
Use that file with the \fBRem2ps\fR \fB\-p\fR option to create calendars
|
Use that file with the \fBrem2ps\fR \fB\-p\fR option to create calendars
|
||||||
with the year and month in large grey letters in the background of the
|
with the year and month in large gray letters in the background of the
|
||||||
calendar.
|
calendar.
|
||||||
.PP
|
.PP
|
||||||
.SH REM2PS INPUT FORMAT (-P OPTION)
|
.SH REM2PS INPUT FORMAT (-P OPTION)
|
||||||
The \fB\-p\fR option is an older, simpler interchange format used by
|
The \fB\-p\fR option is an older, simpler interchange format used by
|
||||||
\fBRemind\fR to communicate with back-ends. New back-ends are
|
\fBRemind\fR to communicate with back-ends. New back-ends are
|
||||||
encoraged to support the new \fB\-pp\fR format preferably, though they
|
encouraged to support the new \fB\-pp\fR format preferably, though they
|
||||||
are encouraged to support the older \fB\-p\fR format as well if the
|
are encouraged to support the older \fB\-p\fR format as well if the
|
||||||
older format contains enough information for them to work properly.
|
older format contains enough information for them to work properly.
|
||||||
.PP
|
.PP
|
||||||
@@ -380,7 +383,7 @@ been set to "-". The consistent use of "/" is designed to ease parsing.
|
|||||||
.PP
|
.PP
|
||||||
\fIspecial\fR is a string used
|
\fIspecial\fR is a string used
|
||||||
for "out-of-band" communication with back-ends. If the reminder
|
for "out-of-band" communication with back-ends. If the reminder
|
||||||
is a normal reminder, \fIspecial\fR is "*". The \fBRem2PS\fR
|
is a normal reminder, \fIspecial\fR is "*". The \fBrem2ps\fR
|
||||||
back-end understands the specials \fBPostScript\fR and \fBPSFile\fR.
|
back-end understands the specials \fBPostScript\fR and \fBPSFile\fR.
|
||||||
Other back-ends may understand other specials. A back end should
|
Other back-ends may understand other specials. A back end should
|
||||||
\fIsilently ignore\fR a reminder with a special it doesn't understand.
|
\fIsilently ignore\fR a reminder with a special it doesn't understand.
|
||||||
@@ -458,7 +461,7 @@ JSON object. The keys that may be present in the JSON object are as
|
|||||||
follows:
|
follows:
|
||||||
.TP
|
.TP
|
||||||
.B date \fIYYYY-MM-DD\fR
|
.B date \fIYYYY-MM-DD\fR
|
||||||
The \fbdate\fR key will \fIalways\fR be present; it is the trigger date
|
The \fBdate\fR key will \fIalways\fR be present; it is the trigger date
|
||||||
of the reminder expressed as a string in the format \fIYYYY-MM-DD\fR
|
of the reminder expressed as a string in the format \fIYYYY-MM-DD\fR
|
||||||
.TP
|
.TP
|
||||||
.B filename \fIf\fR
|
.B filename \fIf\fR
|
||||||
@@ -674,17 +677,17 @@ is desired.
|
|||||||
|
|
||||||
|
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
Rem2PS was written by Dianne Skoll <dianne@skoll.ca>
|
rem2ps was written by Dianne Skoll <dianne@skoll.ca>
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
All \fBRem2ps\fR options are case-sensitive, unlike \fBRemind\fR.
|
All \fBrem2ps\fR options are case-sensitive, unlike \fBRemind\fR.
|
||||||
Any time you supply
|
Any time you supply
|
||||||
a font name or size, line thickness, or border width, it is treated as a
|
a font name or size, line thickness, or border width, it is treated as a
|
||||||
string and sent straight to the PostScript interpreter. Thus, if you
|
string and sent straight to the PostScript interpreter. Thus, if you
|
||||||
supply invalid fonts or sizes, \fBRem2ps\fR will not complain, but the
|
supply invalid fonts or sizes, \fBrem2ps\fR will not complain, but the
|
||||||
resulting PostScript output will probably not work.
|
resulting PostScript output will probably not work.
|
||||||
.PP
|
.PP
|
||||||
You should ensure that the values you supply for margin widths are sensible.
|
You should ensure that the values you supply for margin widths are sensible.
|
||||||
If they are too big for the media size, \fBRem2ps\fR will not complain,
|
If they are too big for the media size, \fBrem2ps\fR will not complain,
|
||||||
but again, the PostScript output will probably not work.
|
but again, the PostScript output will probably not work.
|
||||||
.SH HOME PAGE
|
.SH HOME PAGE
|
||||||
https://dianne.skoll.ca/projects/remind/
|
https://dianne.skoll.ca/projects/remind/
|
||||||
|
|||||||
649
man/remind.1.in
649
man/remind.1.in
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
|||||||
.SH NAME
|
.SH NAME
|
||||||
tkremind \- graphical front-end to Remind calendar program
|
tkremind \- graphical front-end to Remind calendar program
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B tkremind \fR[\fIoptions\fR] [\fIread_file\fR] [\fIwrite_file\fR] [\fIconfig_file\fR]
|
.B tkremind \fR[\fIoptions\fR] [\fIread_file\fR [\fIwrite_file\fR [\fIconfig_file\fR]]]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBTkRemind\fR is a graphical front-end to the \fBRemind\fR program.
|
\fBTkRemind\fR is a graphical front-end to the \fBRemind\fR program.
|
||||||
It provides a friendly graphical interface which allows you to view
|
It provides a friendly graphical interface which allows you to view
|
||||||
@@ -184,7 +184,9 @@ on the reminder.
|
|||||||
If there are any errors in your reminder file, the "Queue..." button
|
If there are any errors in your reminder file, the "Queue..." button
|
||||||
changes to "Errors...". Click on "Errors..." to see the Remind error
|
changes to "Errors...". Click on "Errors..." to see the Remind error
|
||||||
output. Click "OK" to close the error window; this makes the button
|
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
|
.SH BACKGROUND REMINDERS
|
||||||
|
|
||||||
@@ -192,7 +194,7 @@ If you create "timed" reminders, \fBTkRemind\fR will queue them in
|
|||||||
the background and pop up boxes as they are triggered. Additionally,
|
the background and pop up boxes as they are triggered. Additionally,
|
||||||
if you created the reminder using \fBTkRemind\fR, you will be given the
|
if you created the reminder using \fBTkRemind\fR, you will be given the
|
||||||
option of "turning off" the reminder for the rest of the day.
|
option of "turning off" the reminder for the rest of the day.
|
||||||
\fBTkRemind\fR achieves queueing of background reminders by running
|
\fBTkRemind\fR achieves queuing of background reminders by running
|
||||||
\fBRemind\fR in \fIserver mode\fR, described later.
|
\fBRemind\fR in \fIserver mode\fR, described later.
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
@@ -301,11 +303,11 @@ Today
|
|||||||
|
|
||||||
.SH IMMEDIATE UPDATES
|
.SH IMMEDIATE UPDATES
|
||||||
|
|
||||||
If you are running \fBTkRemind\fR on Linux and have the
|
If you are running \fBTkRemind\fR on Linux and \fBRemind\fR has been
|
||||||
\fBinotifywait\fR program installed (part of the \fBinotify-tools\fR
|
compiled with \fBinotify\fR(7) support, then \fBTkRemind\fR redraws
|
||||||
or similar package), then \fBTkRemind\fR redraws the calendar window
|
the calendar window \fIimmediately\fR if \fB$HOME/.reminders\fR
|
||||||
\fIimmediately\fR if \fB$HOME/.reminders\fR changes (or, if it is a
|
changes (or, if it is a directory, any files in that directory
|
||||||
directory, any files in that directory change.)
|
change.)
|
||||||
.PP
|
.PP
|
||||||
This lets \fBTkRemind\fR react immediately to hand-edited reminders or
|
This lets \fBTkRemind\fR react immediately to hand-edited reminders or
|
||||||
to reminder files that are imported from another calendar system (for example,
|
to reminder files that are imported from another calendar system (for example,
|
||||||
@@ -366,60 +368,110 @@ your hand-edited files in a separate \fB*.rem\fR file than \fBTkRemind\fR's
|
|||||||
|
|
||||||
\fBRemind\fR has a special mode for interacting with programs like
|
\fBRemind\fR has a special mode for interacting with programs like
|
||||||
\fBTkRemind\fR. This mode is called \fIserver mode\fR and is
|
\fBTkRemind\fR. This mode is called \fIserver mode\fR and is
|
||||||
selected by supplying the \fB\-z0\fR option to \fBRemind\fR.
|
selected by supplying the \fB\-zj\fR option to \fBRemind\fR.
|
||||||
|
|
||||||
In server mode, \fBRemind\fR operates similar to daemon mode, except
|
In server mode, \fBRemind\fR operates similar to daemon mode, except
|
||||||
it reads commands (one per line)
|
it reads commands (one per line) from standard input and writes status
|
||||||
from standard input and writes status lines to standard output.
|
lines to standard output. Each status line is a JSON object.
|
||||||
|
|
||||||
The commands accepted in server mode are:
|
The commands accepted in server mode are:
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
EXIT
|
EXIT
|
||||||
Terminate the \fBRemind\fR process. EOF on standard input does the
|
Terminate the \fBRemind\fR process. EOF on standard input does the
|
||||||
same thing.
|
same thing. \fBRemind\fR exits immediately without printing
|
||||||
|
a JSON status line.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
STATUS
|
STATUS
|
||||||
Return the number of queued reminders.
|
Return the number of queued reminders. The JSON object looks
|
||||||
|
something like this:
|
||||||
|
.nf
|
||||||
|
|
||||||
|
{"response":"queued","nqueued":n,"command":"STATUS"}
|
||||||
|
|
||||||
|
.fi
|
||||||
|
where \fIn\fR is the number of reminders queued.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
QUEUE or JSONQUEUE
|
||||||
|
Returns the contents of the queue. The JSON object looks something
|
||||||
|
like this:
|
||||||
|
.nf
|
||||||
|
|
||||||
|
{"response":"queue","queue":[ ... ],"command":"QUEUE"}
|
||||||
|
|
||||||
|
.fi
|
||||||
|
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
|
.TP
|
||||||
REREAD
|
REREAD
|
||||||
Re-read the reminder file
|
Re-read the reminder file. Returns the following status line:
|
||||||
|
|
||||||
|
.nf
|
||||||
|
|
||||||
|
{"response":"reread","command":"REREAD"}
|
||||||
|
|
||||||
|
.fi
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
The status lines written are as follows:
|
Additional status lines written are as follows:
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
NOTE reminder \fItime\fR \fItag\fR
|
.nf
|
||||||
Signifies the beginning of a timed reminder whose trigger time is
|
|
||||||
\fItime\fR with tag \fItag\fR. If the reminder has no tag, an
|
|
||||||
asterisk is supplied for \fItag\fR. All lines following this line
|
|
||||||
are the body of the reminder, until the line \fBNOTE endreminder\fR
|
|
||||||
is transmitted.
|
|
||||||
|
|
||||||
|
{"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. \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
|
.TP
|
||||||
NOTE newdate
|
.nf
|
||||||
|
|
||||||
|
{"response":"newdate"}
|
||||||
|
|
||||||
|
.fi
|
||||||
|
|
||||||
This line is emitted whenever \fBRemind\fR has detected a rollover of
|
This line is emitted whenever \fBRemind\fR has detected a rollover of
|
||||||
the system date. The front-end program should redraw its calendar
|
the system date. The front-end program should redraw its calendar
|
||||||
or take whatever other action is needed.
|
or take whatever other action is needed.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
NOTE reread
|
.nf
|
||||||
This line is emitted whenever the number of reminders in \fBRemind\fR's
|
|
||||||
queue changes because of a date rollover or a \fBREREAD\fR command.
|
|
||||||
The front-end should issue a \fBSTATUS\fR command in response to this
|
|
||||||
message.
|
|
||||||
|
|
||||||
.TP
|
{"response":"reread","command":"inotify"}
|
||||||
NOTE queued \fIn\fR
|
|
||||||
This line is emitted in response to a \fBSTATUS\fR command. The number
|
.fi
|
||||||
\fIn\fR is the number of reminders in the queue.
|
|
||||||
|
If \fBRemind\fR was compiled with support for \fBinotify\fR(7), then
|
||||||
|
if it detects a change to the top-level reminder file or directory,
|
||||||
|
it issues the above response. The front-end should redraw its
|
||||||
|
calendar since this response indicates that a change has been made
|
||||||
|
to the reminder file or directory.
|
||||||
|
|
||||||
|
.PP
|
||||||
|
Please note that \fBRemind\fR can write a status message \fIat any time\fR
|
||||||
|
and not just in response to a command sent to its standard input. Therefore,
|
||||||
|
a program that runs \fBRemind\fR in server mode must be prepared to handle
|
||||||
|
asynchronous status messages.
|
||||||
|
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
TkRemind was written by Dianne Skoll <dianne@skoll.ca>
|
TkRemind was written by Dianne Skoll <dianne@skoll.ca>
|
||||||
|
|
||||||
\fBTkRemind\fR is Copyright 1996-2023 by Dianne Skoll.
|
\fBTkRemind\fR is Copyright 1996-2024 by Dianne Skoll.
|
||||||
|
|
||||||
.SH FILES
|
.SH FILES
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ install:
|
|||||||
@if test "$(PERL)" = "" ; then \
|
@if test "$(PERL)" = "" ; then \
|
||||||
echo "Not installing rem2html; Perl is required"; exit 0; fi; \
|
echo "Not installing rem2html; Perl is required"; exit 0; fi; \
|
||||||
for m in $(PERLMODS_NEEDED) ; \
|
for m in $(PERLMODS_NEEDED) ; \
|
||||||
do \
|
do \
|
||||||
$(PERL) -M$$m -e 1 > /dev/null 2>&1; \
|
$(PERL) -M$$m -e 1 > /dev/null 2>&1; \
|
||||||
if test $$? != 0 ; then echo "Not installing rem2html; missing $$m"; exit 0; fi; \
|
if test $$? != 0 ; then echo "Not installing rem2html; missing $$m"; exit 0; fi; \
|
||||||
done; \
|
done; \
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ use warnings;
|
|||||||
|
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use JSON::MaybeXS;
|
use JSON::MaybeXS;
|
||||||
|
use Encode;
|
||||||
|
|
||||||
my %Options;
|
my %Options;
|
||||||
|
|
||||||
my $rem2html_version = '2.1';
|
my $rem2html_version = '@VERSION@';
|
||||||
|
|
||||||
my($days, $shades, $moons, $classes, $Month, $Year, $Numdays, $Firstwkday, $Mondayfirst, $weeks,
|
my($days, $shades, $moons, $classes, $Month, $Year, $Numdays, $Firstwkday, $Mondayfirst, $weeks,
|
||||||
@Daynames, $Nextmon, $Nextlen, $Prevmon, $Prevlen);
|
@Daynames, $Nextmon, $Nextlen, $Prevmon, $Prevlen);
|
||||||
@@ -44,6 +45,11 @@ Print usage information
|
|||||||
|
|
||||||
Print version
|
Print version
|
||||||
|
|
||||||
|
=item --utf8
|
||||||
|
|
||||||
|
Assume standard input is encoded in UTF-8; write UTF-8 data to standard
|
||||||
|
output.
|
||||||
|
|
||||||
=item --backurl I<url>
|
=item --backurl I<url>
|
||||||
|
|
||||||
When producing the small calendar for the previous month, make the
|
When producing the small calendar for the previous month, make the
|
||||||
@@ -154,6 +160,7 @@ Usage: remind -pp ... | rem2html [options]
|
|||||||
Options:
|
Options:
|
||||||
|
|
||||||
--help, -h Print usage information
|
--help, -h Print usage information
|
||||||
|
--utf8 Assume UTF-8 input and write UTF-8 output
|
||||||
--man Show man page (requires "perldoc")
|
--man Show man page (requires "perldoc")
|
||||||
--version Print version
|
--version Print version
|
||||||
--backurl url Make the title on the previous month's small calendar
|
--backurl url Make the title on the previous month's small calendar
|
||||||
@@ -197,6 +204,7 @@ sub parse_options
|
|||||||
local $SIG{__WARN__} = sub { print STDERR "$TIDY_PROGNAME: $_[0]\n"; };
|
local $SIG{__WARN__} = sub { print STDERR "$TIDY_PROGNAME: $_[0]\n"; };
|
||||||
if (!GetOptions(\%Options, "help|h",
|
if (!GetOptions(\%Options, "help|h",
|
||||||
"man",
|
"man",
|
||||||
|
"utf8",
|
||||||
"pngs",
|
"pngs",
|
||||||
"version",
|
"version",
|
||||||
"stylesheet=s",
|
"stylesheet=s",
|
||||||
@@ -216,13 +224,22 @@ sub parse_options
|
|||||||
if ($stylesheet) {
|
if ($stylesheet) {
|
||||||
$Options{stylesheet} = smoosh($Options{imgbase}, $stylesheet);
|
$Options{stylesheet} = smoosh($Options{imgbase}, $stylesheet);
|
||||||
}
|
}
|
||||||
|
if ($Options{utf8}) {
|
||||||
|
binmode(STDIN, ':encoding(UTF-8)');
|
||||||
|
binmode(STDOUT, ':encoding(UTF-8)');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub start_output
|
sub start_output
|
||||||
{
|
{
|
||||||
return if ($Options{tableonly});
|
return if ($Options{tableonly});
|
||||||
|
|
||||||
print("<html>\n<head>\n<title>" . $Options{title} . "</title>\n");
|
print("<html>\n<head>\n");
|
||||||
|
if ($Options{utf8}) {
|
||||||
|
print '<meta charset="UTF-8">' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print("<title>" . $Options{title} . "</title>\n");
|
||||||
if (!$Options{nostyle}) {
|
if (!$Options{nostyle}) {
|
||||||
if ($Options{stylesheet}) {
|
if ($Options{stylesheet}) {
|
||||||
print('<link rel="stylesheet" type="text/css" href="' .
|
print('<link rel="stylesheet" type="text/css" href="' .
|
||||||
@@ -310,7 +327,12 @@ sub parse_input
|
|||||||
($y, $m, $d, $special, $tag, $duration, $time, $body) =
|
($y, $m, $d, $special, $tag, $duration, $time, $body) =
|
||||||
($1, $2, $3, $4, $5, $6, $7, $8);
|
($1, $2, $3, $4, $5, $6, $7, $8);
|
||||||
} elsif (/\{/) {
|
} elsif (/\{/) {
|
||||||
my $obj = decode_json($_);
|
my $obj;
|
||||||
|
if ($Options{utf8}) {
|
||||||
|
$obj = decode_json(encode('UTF-8', $_, Encode::FB_DEFAULT));
|
||||||
|
} else {
|
||||||
|
$obj = decode_json($_);
|
||||||
|
}
|
||||||
next unless ($obj->{date} =~ /^(\d+)-(\d+)-(\d+)$/);
|
next unless ($obj->{date} =~ /^(\d+)-(\d+)-(\d+)$/);
|
||||||
$y = $1;
|
$y = $1;
|
||||||
$m = $2;
|
$m = $2;
|
||||||
@@ -687,7 +709,7 @@ if ($Options{help}) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-t STDIN) {
|
if (-t STDIN) { ## no critic
|
||||||
print STDERR "$TIDY_PROGNAME: Input should not come from a terminal.\n\n";
|
print STDERR "$TIDY_PROGNAME: Input should not come from a terminal.\n\n";
|
||||||
usage(1);
|
usage(1);
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ my $settings = {
|
|||||||
numbers_on_left => 0,
|
numbers_on_left => 0,
|
||||||
small_calendars => 0,
|
small_calendars => 0,
|
||||||
fill_entire_page => 0,
|
fill_entire_page => 0,
|
||||||
|
wrap_calendar => 0,
|
||||||
media => 'Letter',
|
media => 'Letter',
|
||||||
width => 0,
|
width => 0,
|
||||||
height => 0,
|
height => 0,
|
||||||
@@ -86,6 +86,7 @@ Options:
|
|||||||
--media=MEDIA, -mMEDIA Size for specified media
|
--media=MEDIA, -mMEDIA Size for specified media
|
||||||
--width=W, -wW Specify media width in 1/72nds of an inch
|
--width=W, -wW Specify media width in 1/72nds of an inch
|
||||||
--height=H, -hH Specify media height in 1/72nds of an inch
|
--height=H, -hH Specify media height in 1/72nds of an inch
|
||||||
|
--wrap, -y Make calendar fit in at most 5 rows
|
||||||
--title-font=FONT Specify font for calendar title
|
--title-font=FONT Specify font for calendar title
|
||||||
--header-font=FONT Specify font for weekday names
|
--header-font=FONT Specify font for weekday names
|
||||||
--daynum-font=FONT Specify font for day numbers
|
--daynum-font=FONT Specify font for day numbers
|
||||||
@@ -114,6 +115,7 @@ my $ret = GetOptions('landscape|l' => \$settings->{landscape},
|
|||||||
'fill-page|e' => \$settings->{fill_entire_page},
|
'fill-page|e' => \$settings->{fill_entire_page},
|
||||||
'media|m=s' => \$settings->{media},
|
'media|m=s' => \$settings->{media},
|
||||||
'width|w=i' => \$settings->{width},
|
'width|w=i' => \$settings->{width},
|
||||||
|
'wrap|y' => \$settings->{wrap_calendar},
|
||||||
'height|h=i' => \$settings->{height},
|
'height|h=i' => \$settings->{height},
|
||||||
'title-font=s' => \$settings->{title_font},
|
'title-font=s' => \$settings->{title_font},
|
||||||
'header-font=s' => \$settings->{header_font},
|
'header-font=s' => \$settings->{header_font},
|
||||||
@@ -175,7 +177,7 @@ if ($settings->{landscape}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Don't read from a terminal
|
# Don't read from a terminal
|
||||||
if (-t STDIN) {
|
if (-t STDIN) { ## no critic
|
||||||
print STDERR "I can't read data from a terminal. Please run like this:\n";
|
print STDERR "I can't read data from a terminal. Please run like this:\n";
|
||||||
print STDERR " remind -pp [options] filename | $me [options] > out.pdf\n";
|
print STDERR " remind -pp [options] filename | $me [options] > out.pdf\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -249,20 +251,21 @@ sub set_media
|
|||||||
sub set_media_from_file
|
sub set_media_from_file
|
||||||
{
|
{
|
||||||
my ($fn) = @_;
|
my ($fn) = @_;
|
||||||
if (!open(IN, '<', $fn)) {
|
my $IN;
|
||||||
|
if (!open($IN, '<', $fn)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
while(<IN>) {
|
while(<$IN>) {
|
||||||
chomp;
|
chomp;
|
||||||
s/^\s+//;
|
s/^\s+//;
|
||||||
s/\s+$//;
|
s/\s+$//;
|
||||||
next if ($_ eq '');
|
next if ($_ eq '');
|
||||||
next if ($_ =~ /^#/);
|
next if ($_ =~ /^#/);
|
||||||
my $m = $_;
|
my $m = $_;
|
||||||
close(IN);
|
close($IN);
|
||||||
return set_media($m);
|
return set_media($m);
|
||||||
}
|
}
|
||||||
close(IN);
|
close($IN);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,6 +433,14 @@ The default is 36.
|
|||||||
The size of the margin at the right of the page in 1/72ths of an inch.
|
The size of the margin at the right of the page in 1/72ths of an inch.
|
||||||
The default is 36.
|
The default is 36.
|
||||||
|
|
||||||
|
=item --wrap, -y
|
||||||
|
|
||||||
|
Modify the calendar so that if it would normally require 6 rows to print,
|
||||||
|
then the last day (or last two days, as needed) are moved to the
|
||||||
|
first row of the calendar, and adjust the small calendar positions
|
||||||
|
as needed. This results in a calendar that only requires 5 rows, but
|
||||||
|
with the last day or two appearing in the I<first> row.
|
||||||
|
|
||||||
=item --verbose, -v
|
=item --verbose, -v
|
||||||
|
|
||||||
Print (on STDERR) the name of the month and year for each month that
|
Print (on STDERR) the name of the month and year for each month that
|
||||||
@@ -475,7 +486,7 @@ output for the invalid reminder.
|
|||||||
=head1 ABSOLUTELY-POSITIONED TEXT
|
=head1 ABSOLUTELY-POSITIONED TEXT
|
||||||
|
|
||||||
If your B<PANGO> special reminder starts with C<@I<x>,I<y>> where I<x>
|
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
|
positioned absolutely with respect to the day's box (and is not
|
||||||
counted when calculating the box's height.)
|
counted when calculating the box's height.)
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ sub read_one_month
|
|||||||
$self->{daysinnextmonth} = 0;
|
$self->{daysinnextmonth} = 0;
|
||||||
$self->{prevmonthyear} = 0;
|
$self->{prevmonthyear} = 0;
|
||||||
$self->{nextmonthyear} = 0;
|
$self->{nextmonthyear} = 0;
|
||||||
|
|
||||||
for (my $i=0; $i<=31; $i++) {
|
for (my $i=0; $i<=31; $i++) {
|
||||||
$self->{entries}->[$i] = [];
|
$self->{entries}->[$i] = [];
|
||||||
}
|
}
|
||||||
@@ -134,7 +133,7 @@ sub read_one_month
|
|||||||
$line = $in->getline();
|
$line = $in->getline();
|
||||||
chomp($line);
|
chomp($line);
|
||||||
if ($line =~ /^\S+ \S+ \S+ \S+ \S+ \S+ \S+$/) {
|
if ($line =~ /^\S+ \S+ \S+ \S+ \S+ \S+ \S+$/) {
|
||||||
@{$self->{daynames}} = map { s/_/ /g; $_; } (split(/ /, $line));
|
@{$self->{daynames}} = map { s/_/ /g; $_; } (split(/ /, $line)); ## no critic
|
||||||
} else {
|
} else {
|
||||||
return (undef, "Cannot interpret line: $line");
|
return (undef, "Cannot interpret line: $line");
|
||||||
}
|
}
|
||||||
@@ -213,7 +212,7 @@ hash keys found in the newer "remind -pp" JSON output.
|
|||||||
sub parse_oldstyle_line
|
sub parse_oldstyle_line
|
||||||
{
|
{
|
||||||
my ($self, $line) = @_;
|
my ($self, $line) = @_;
|
||||||
return undef unless $line =~ m|^(\d+)/(\d+)/(\d+) (\S+) (\S+) (\S+) (\S+) (.*)$|;
|
return unless $line =~ m|^(\d+)/(\d+)/(\d+) (\S+) (\S+) (\S+) (\S+) (.*)$|;
|
||||||
|
|
||||||
my $hash = {
|
my $hash = {
|
||||||
date => "$1-$2-$3",
|
date => "$1-$2-$3",
|
||||||
@@ -244,6 +243,143 @@ sub parse_oldstyle_line
|
|||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=head2 setup_daymap
|
||||||
|
|
||||||
|
Set up the array that maps ($row, $col) to day number (or -1
|
||||||
|
for rows/cols out of range.)
|
||||||
|
|
||||||
|
=cut
|
||||||
|
sub setup_daymap
|
||||||
|
{
|
||||||
|
my ($self, $settings) = @_;
|
||||||
|
# First column
|
||||||
|
my $first_col = $self->{firstwkday};
|
||||||
|
if ($self->{mondayfirst}) {
|
||||||
|
$first_col--;
|
||||||
|
if ($first_col < 0) {
|
||||||
|
$first_col = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Last column
|
||||||
|
my $last_col = ($first_col + $self->{daysinmonth} - 1) % 7;
|
||||||
|
|
||||||
|
# Number of rows
|
||||||
|
my $rows = 1;
|
||||||
|
my $last_day_on_row = 7 - $first_col;
|
||||||
|
while ($last_day_on_row < $self->{daysinmonth}) {
|
||||||
|
$last_day_on_row += 7;
|
||||||
|
$rows++;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add a row for small calendars if necessary
|
||||||
|
if (($settings->{small_calendars} != 0) && ($first_col == 0) && ($last_col == 6)) {
|
||||||
|
$rows++;
|
||||||
|
$self->{extra_row} = 1;
|
||||||
|
} else {
|
||||||
|
$self->{extra_row} = 0;
|
||||||
|
}
|
||||||
|
$self->{rows} = $rows;
|
||||||
|
$self->{daymap} = [];
|
||||||
|
$self->{first_col} = $first_col;
|
||||||
|
$self->{last_col} = $last_col;
|
||||||
|
for (my $row=0; $row<$rows; $row++) {
|
||||||
|
for (my $col=0; $col < 7; $col++) {
|
||||||
|
$self->{daymap}->[$row]->[$col] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$self->{nextcal_row} = -1;
|
||||||
|
$self->{prevcal_row} = -1;
|
||||||
|
$self->{nextcal_col} = 6;
|
||||||
|
$self->{prevcal_col} = 0;
|
||||||
|
# Figure out where to draw the small calendars
|
||||||
|
my $extra_row = $self->{extra_row};
|
||||||
|
if ($settings->{small_calendars} == 1) {
|
||||||
|
if ($last_col <= 4 || ($last_col == 6 && $extra_row)) {
|
||||||
|
$self->{prevcal_row} = $rows-1;
|
||||||
|
$self->{prevcal_col} = 5;
|
||||||
|
$self->{nextcal_row} = $rows-1;
|
||||||
|
$self->{nextcal_col} = 6;
|
||||||
|
} else {
|
||||||
|
$self->{prevcal_row} = 0;
|
||||||
|
$self->{prevcal_col} = 0;
|
||||||
|
$self->{nextcal_row} = 0;
|
||||||
|
$self->{nextcal_col} = 1;
|
||||||
|
}
|
||||||
|
} elsif ($settings->{small_calendars} == 2) {
|
||||||
|
if ($first_col >= 2) {
|
||||||
|
$self->{prevcal_row} = 0;
|
||||||
|
$self->{prevcal_col} = 0;
|
||||||
|
$self->{nextcal_row} = 0;
|
||||||
|
$self->{nextcal_col} = 1;
|
||||||
|
} else {
|
||||||
|
$self->{prevcal_row} = $rows-1;
|
||||||
|
$self->{prevcal_col} = 5;
|
||||||
|
$self->{nextcal_row} = $rows-1;
|
||||||
|
$self->{nextcal_col} = 6;
|
||||||
|
}
|
||||||
|
} elsif ($settings->{small_calendars} == 3) {
|
||||||
|
if ($first_col >= 1 && $last_col <= 5) {
|
||||||
|
$self->{prevcal_row} = 0;
|
||||||
|
$self->{prevcal_col} = 0;
|
||||||
|
$self->{nextcal_row} = $rows-1;
|
||||||
|
$self->{nextcal_col} = 6;
|
||||||
|
} else {
|
||||||
|
if ($last_col <= 4 || ($last_col == 6 && $extra_row)) {
|
||||||
|
$self->{prevcal_row} = $rows-1;
|
||||||
|
$self->{prevcal_col} = 5;
|
||||||
|
$self->{nextcal_row} = $rows-1;
|
||||||
|
$self->{nextcal_col} = 6;
|
||||||
|
} else {
|
||||||
|
$self->{prevcal_row} = 0;
|
||||||
|
$self->{prevcal_col} = 0;
|
||||||
|
$self->{nextcal_row} = 0;
|
||||||
|
$self->{nextcal_col} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $col = $first_col;
|
||||||
|
my $row = 0;
|
||||||
|
my $day = 1;
|
||||||
|
while ($day <= $self->{daysinmonth}) {
|
||||||
|
$self->{daymap}->[$row]->[$col] = $day;
|
||||||
|
$day++;
|
||||||
|
$col++;
|
||||||
|
if ($col > 6) {
|
||||||
|
$row++;
|
||||||
|
$col = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if we should wrap the calendar
|
||||||
|
if ($self->{rows} == 6 && $settings->{wrap_calendar}) {
|
||||||
|
# Move everything in the last row to the first row
|
||||||
|
my $occupied_col = 0;
|
||||||
|
for (my $col=0; $col<7; $col++) {
|
||||||
|
if ($self->{daymap}->[5]->[$col] > 0) {
|
||||||
|
$self->{daymap}->[0]->[$col] = $self->{daymap}->[5]->[$col];
|
||||||
|
$occupied_col = $col;
|
||||||
|
} else {
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($settings->{small_calendars}) {
|
||||||
|
$self->{prevcal_row} = 0;
|
||||||
|
$self->{prevcal_col} = $occupied_col+1;
|
||||||
|
$self->{nextcal_row} = 0;
|
||||||
|
$self->{nextcal_col} = $occupied_col+2;
|
||||||
|
for (my $col = 6; $col > 0; $col--) {
|
||||||
|
if ($self->{daymap}->[0]->[$col] < 0) {
|
||||||
|
$self->{nextcal_col} = $col;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$self->{rows} = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
=head2 read_one_month_pp($in, $specials_accepted)
|
=head2 read_one_month_pp($in, $specials_accepted)
|
||||||
|
|
||||||
This function reads one month's worth of data from the file handle
|
This function reads one month's worth of data from the file handle
|
||||||
@@ -329,6 +465,7 @@ sub render
|
|||||||
{
|
{
|
||||||
my ($self, $cr, $settings) = @_;
|
my ($self, $cr, $settings) = @_;
|
||||||
|
|
||||||
|
$self->setup_daymap($settings);
|
||||||
$self->{horiz_lines} = [];
|
$self->{horiz_lines} = [];
|
||||||
$cr->set_line_cap('square');
|
$cr->set_line_cap('square');
|
||||||
my $so_far = $self->draw_title($cr, $settings);
|
my $so_far = $self->draw_title($cr, $settings);
|
||||||
@@ -347,111 +484,25 @@ sub render
|
|||||||
$self->{remaining_space} = $settings->{height} - $settings->{margin_bottom} - $so_far;
|
$self->{remaining_space} = $settings->{height} - $settings->{margin_bottom} - $so_far;
|
||||||
|
|
||||||
$self->{minimum_row_height} = $self->{remaining_space} / 9;
|
$self->{minimum_row_height} = $self->{remaining_space} / 9;
|
||||||
# First column
|
|
||||||
my $first_col = $self->{firstwkday};
|
|
||||||
if ($self->{mondayfirst}) {
|
|
||||||
$first_col--;
|
|
||||||
if ($first_col < 0) {
|
|
||||||
$first_col = 6;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Last column
|
|
||||||
my $last_col = ($first_col + $self->{daysinmonth} - 1) % 7;
|
|
||||||
|
|
||||||
# Number of rows
|
|
||||||
my $rows = 1;
|
|
||||||
my $last_day_on_row = 7 - $first_col;
|
|
||||||
while ($last_day_on_row < $self->{daysinmonth}) {
|
|
||||||
$last_day_on_row += 7;
|
|
||||||
$rows++;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $extra_row = 0;
|
|
||||||
# Add a row for small calendars if necessary
|
|
||||||
if (($settings->{small_calendars} != 0) && ($first_col == 0) && ($last_col == 6)) {
|
|
||||||
$rows++;
|
|
||||||
$extra_row++;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Figure out where to draw the small calendars
|
|
||||||
my $prevcal_top = 0;
|
|
||||||
my $nextcal_top = 0;
|
|
||||||
my $prevcal_bottom = 0;
|
|
||||||
my $nextcal_bottom = 0;
|
|
||||||
|
|
||||||
if ($settings->{small_calendars} == 1) {
|
|
||||||
if ($last_col <= 4 || ($last_col == 6 && $extra_row)) {
|
|
||||||
$prevcal_bottom = 1;
|
|
||||||
$nextcal_bottom = 1;
|
|
||||||
} else {
|
|
||||||
$prevcal_top = 1;
|
|
||||||
$nextcal_top = 1;
|
|
||||||
}
|
|
||||||
} elsif ($settings->{small_calendars} == 2) {
|
|
||||||
if ($first_col >= 2) {
|
|
||||||
$prevcal_top = 1;
|
|
||||||
$nextcal_top = 1;
|
|
||||||
} else {
|
|
||||||
$prevcal_bottom = 1;
|
|
||||||
$nextcal_bottom = 1;
|
|
||||||
}
|
|
||||||
} elsif ($settings->{small_calendars} == 3) {
|
|
||||||
if ($first_col >= 1 && $last_col <= 5) {
|
|
||||||
$prevcal_top = 1;
|
|
||||||
$nextcal_bottom = 1;
|
|
||||||
} else {
|
|
||||||
if ($last_col <= 4 || ($last_col == 6 && $extra_row)) {
|
|
||||||
$prevcal_bottom = 1;
|
|
||||||
$nextcal_bottom = 1;
|
|
||||||
} else {
|
|
||||||
$prevcal_top = 1;
|
|
||||||
$nextcal_top = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Row height if we are filling the page
|
# Row height if we are filling the page
|
||||||
$self->{row_height} = $self->{remaining_space} / $rows;
|
$self->{row_height} = $self->{remaining_space} / $self->{rows};
|
||||||
|
|
||||||
my ($start_col, $start_day);
|
for (my $row = 0; $row < $self->{rows}; $row++) {
|
||||||
for (my $row = 0; $row < $rows; $row++) {
|
|
||||||
if ($row == 0) {
|
|
||||||
$start_day = 1;
|
|
||||||
$start_col = $first_col;
|
|
||||||
} else {
|
|
||||||
$start_col = 0;
|
|
||||||
}
|
|
||||||
my $old_so_far = $so_far;
|
my $old_so_far = $so_far;
|
||||||
$so_far = $self->draw_row($cr, $settings, $so_far, $row, $start_day, $start_col);
|
$so_far = $self->draw_row($cr, $settings, $so_far, $row);
|
||||||
$start_day += 7 - $start_col;
|
|
||||||
push(@{$self->{horiz_lines}}, $so_far);
|
push(@{$self->{horiz_lines}}, $so_far);
|
||||||
if ($row == 0) {
|
if ($row == $self->{prevcal_row}) {
|
||||||
if ($prevcal_top) {
|
my ($x1, $y1, $x2, $y2) = $self->col_box_coordinates($old_so_far, $self->{prevcal_col}, $so_far - $old_so_far, $settings);
|
||||||
my ($x1, $y1, $x2, $y2) = $self->col_box_coordinates($old_so_far, 0, $so_far - $old_so_far, $settings);
|
$self->draw_small_calendar($cr, $x1 + $settings->{border_size}, $y1 + $settings->{border_size},
|
||||||
$self->draw_small_calendar($cr, $x1 + $settings->{border_size}, $y1 + $settings->{border_size},
|
$x2 - $x1 - 2*$settings->{border_size}, $y2 - $y1 - 2*$settings->{border_size},
|
||||||
$x2 - $x1 - 2*$settings->{border_size}, $y2 - $y1 - 2*$settings->{border_size},
|
$settings, $self->{prevmonthname}, $self->{daysinprevmonth}, ($self->{first_col} + 35 - $self->{daysinprevmonth}) % 7);
|
||||||
$settings, $self->{prevmonthname}, $self->{daysinprevmonth}, ($first_col + 35 - $self->{daysinprevmonth}) % 7);
|
}
|
||||||
}
|
if ($row == $self->{nextcal_row}) {
|
||||||
if ($nextcal_top) {
|
my ($x1, $y1, $x2, $y2) = $self->col_box_coordinates($old_so_far, $self->{nextcal_col}, $so_far - $old_so_far, $settings);
|
||||||
my ($x1, $y1, $x2, $y2) = $self->col_box_coordinates($old_so_far, 1, $so_far - $old_so_far, $settings);
|
$self->draw_small_calendar($cr, $x1 + $settings->{border_size}, $y1 + $settings->{border_size},
|
||||||
$self->draw_small_calendar($cr, $x1 + $settings->{border_size}, $y1 + $settings->{border_size},
|
$x2 - $x1 - 2*$settings->{border_size}, $y2 - $y1 - 2*$settings->{border_size},
|
||||||
$x2 - $x1 - 2*$settings->{border_size}, $y2 - $y1 - 2*$settings->{border_size},
|
$settings, $self->{nextmonthname}, $self->{daysinnextmonth}, ($self->{last_col} + 1) % 7);
|
||||||
$settings, $self->{nextmonthname}, $self->{daysinnextmonth}, ($last_col + 1) % 7);
|
|
||||||
}
|
|
||||||
} elsif ($row == $rows-1) {
|
|
||||||
if ($prevcal_bottom) {
|
|
||||||
my ($x1, $y1, $x2, $y2) = $self->col_box_coordinates($old_so_far, 5, $so_far - $old_so_far, $settings);
|
|
||||||
$self->draw_small_calendar($cr, $x1 + $settings->{border_size}, $y1 + $settings->{border_size},
|
|
||||||
$x2 - $x1 - 2*$settings->{border_size}, $y2 - $y1 - 2*$settings->{border_size},
|
|
||||||
$settings, $self->{prevmonthname}, $self->{daysinprevmonth}, ($first_col + 35 - $self->{daysinprevmonth}) % 7);
|
|
||||||
}
|
|
||||||
if ($nextcal_bottom) {
|
|
||||||
my ($x1, $y1, $x2, $y2) = $self->col_box_coordinates($old_so_far, 6, $so_far - $old_so_far, $settings);
|
|
||||||
$self->draw_small_calendar($cr, $x1 + $settings->{border_size}, $y1 + $settings->{border_size},
|
|
||||||
$x2 - $x1 - 2*$settings->{border_size}, $y2 - $y1 - 2*$settings->{border_size},
|
|
||||||
$settings, $self->{nextmonthname}, $self->{daysinnextmonth}, ($last_col + 1) % 7);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,23 +546,18 @@ calendar row.
|
|||||||
=cut
|
=cut
|
||||||
sub draw_row
|
sub draw_row
|
||||||
{
|
{
|
||||||
my ($self, $cr, $settings, $so_far, $row, $start_day, $start_col) = @_;
|
my ($self, $cr, $settings, $so_far, $row) = @_;
|
||||||
|
|
||||||
my $col = $start_col;
|
|
||||||
my $day = $start_day;
|
|
||||||
my $height = 0;
|
my $height = 0;
|
||||||
|
|
||||||
# Preview them to figure out the row height...
|
# Preview them to figure out the row height...
|
||||||
if (!$settings->{fill_entire_page}) {
|
if (!$settings->{fill_entire_page}) {
|
||||||
while ($col < 7) {
|
for (my $col=0; $col<7; $col++) {
|
||||||
|
my $day = $self->{daymap}->[$row]->[$col];
|
||||||
|
next if ($day < 1);
|
||||||
my $h = $self->draw_day($cr, $settings, $so_far, $day, $col, 0);
|
my $h = $self->draw_day($cr, $settings, $so_far, $day, $col, 0);
|
||||||
$height = $h if ($h > $height);
|
$height = $h if ($h > $height);
|
||||||
$day++;
|
|
||||||
$col++;
|
|
||||||
last if ($day > $self->{daysinmonth});
|
|
||||||
}
|
}
|
||||||
$col = $start_col;
|
|
||||||
$day = $start_day;
|
|
||||||
} else {
|
} else {
|
||||||
$height = $self->{row_height} - $settings->{border_size} * 2;
|
$height = $self->{row_height} - $settings->{border_size} * 2;
|
||||||
}
|
}
|
||||||
@@ -520,10 +566,10 @@ sub draw_row
|
|||||||
$height = $self->{minimum_row_height};
|
$height = $self->{minimum_row_height};
|
||||||
}
|
}
|
||||||
# Now draw for real
|
# Now draw for real
|
||||||
while ($col < 7 && $day <= $self->{daysinmonth}) {
|
for (my $col=0; $col<7; $col++) {
|
||||||
|
my $day = $self->{daymap}->[$row]->[$col];
|
||||||
|
next if ($day < 1);
|
||||||
$self->draw_day($cr, $settings, $so_far, $day, $col, $height);
|
$self->draw_day($cr, $settings, $so_far, $day, $col, $height);
|
||||||
$day++;
|
|
||||||
$col++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $so_far + $height + $settings->{border_size};
|
return $so_far + $height + $settings->{border_size};
|
||||||
@@ -908,7 +954,7 @@ sub create_from_stream
|
|||||||
return(undef, 'Unable to parse JSON stream');
|
return(undef, 'Unable to parse JSON stream');
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 Remind::PDF::Multi->create_from_stream($json, $specials_accepted)
|
=head2 Remind::PDF::Multi->create_from_json($json, $specials_accepted)
|
||||||
|
|
||||||
This method takes data from a JSON string <$json>. C<$specials_accepted>
|
This method takes data from a JSON string <$json>. C<$specials_accepted>
|
||||||
is a hashref of SPECIAL reminder types to accept; the key is the name of the
|
is a hashref of SPECIAL reminder types to accept; the key is the name of the
|
||||||
|
|||||||
15
resources/tkremind.desktop
Executable file
15
resources/tkremind.desktop
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Exec=tkremind
|
||||||
|
StartupNotify=true
|
||||||
|
Icon=tkremind
|
||||||
|
Terminal=false
|
||||||
|
Name=tkremind
|
||||||
|
Comment=TkRemind Calendar Program
|
||||||
|
Categories=Office;Calendar;
|
||||||
|
Keywords=Calendar;remind;
|
||||||
|
Keywords[ca]=Calendari;remind;
|
||||||
|
Keywords[de]=Kalender;remind;
|
||||||
|
Keywords[en_GB]=Calendar;remind;
|
||||||
|
Keywords[es]=Calendario;remind;
|
||||||
|
|
||||||
BIN
resources/tkremind.png
Normal file
BIN
resources/tkremind.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
656
scripts/tkremind
656
scripts/tkremind
File diff suppressed because it is too large
Load Diff
@@ -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 \
|
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
|
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
|
md5.h protos.h rem2ps.h types.h version.h
|
||||||
REMINDOBJS= $(REMINDSRCS:.c=.o)
|
REMINDOBJS= $(REMINDSRCS:.c=.o)
|
||||||
|
|
||||||
@@ -63,6 +63,16 @@ install: all
|
|||||||
done
|
done
|
||||||
-mkdir -p $(DESTDIR)$(datarootdir)/remind || true
|
-mkdir -p $(DESTDIR)$(datarootdir)/remind || true
|
||||||
cp -R ../include/* $(DESTDIR)$(datarootdir)/remind
|
cp -R ../include/* $(DESTDIR)$(datarootdir)/remind
|
||||||
|
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)/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
|
install-stripped: install
|
||||||
strip $(DESTDIR)$(bindir)/remind || true
|
strip $(DESTDIR)$(bindir)/remind || true
|
||||||
@@ -80,6 +90,9 @@ depend:
|
|||||||
# The next targets are not very useful to you. I use them to build
|
# The next targets are not very useful to you. I use them to build
|
||||||
# distributions, etc.
|
# 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.
|
# Build a tar file based on all files checked into git.
|
||||||
distro:
|
distro:
|
||||||
cd .. && git archive --worktree-attributes --format=tar --prefix=remind-$(VERSION)/ HEAD > src/remind-$(VERSION).tar
|
cd .. && git archive --worktree-attributes --format=tar --prefix=remind-$(VERSION)/ HEAD > src/remind-$(VERSION).tar
|
||||||
|
|||||||
242
src/calendar.c
242
src/calendar.c
@@ -5,7 +5,7 @@
|
|||||||
/* The code for generating a calendar. */
|
/* The code for generating a calendar. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -35,7 +35,6 @@
|
|||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "expr.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
@@ -475,7 +474,7 @@ void PrintJSONKeyPairTime(char const *name, int t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef REM_USE_WCHAR
|
#ifdef REM_USE_WCHAR
|
||||||
void PutWideChar(wchar_t const wc)
|
void PutWideChar(wchar_t const wc, DynamicBuffer *output)
|
||||||
{
|
{
|
||||||
char buf[MB_CUR_MAX+1];
|
char buf[MB_CUR_MAX+1];
|
||||||
int len;
|
int len;
|
||||||
@@ -483,7 +482,11 @@ void PutWideChar(wchar_t const wc)
|
|||||||
len = wctomb(buf, wc);
|
len = wctomb(buf, wc);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
fputs(buf, stdout);
|
if (output) {
|
||||||
|
DBufPuts(output, buf);
|
||||||
|
} else {
|
||||||
|
fputs(buf, stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -497,7 +500,7 @@ get_month_abbrev(char const *mon)
|
|||||||
return buf;
|
return buf;
|
||||||
#else
|
#else
|
||||||
char *s;
|
char *s;
|
||||||
wchar_t tmp_buf[128];
|
wchar_t tmp_buf[128] = {0};
|
||||||
wchar_t *ws;
|
wchar_t *ws;
|
||||||
int i;
|
int i;
|
||||||
int len;
|
int len;
|
||||||
@@ -556,11 +559,11 @@ static void goff(void)
|
|||||||
static void
|
static void
|
||||||
ClampColor(int *r, int *g, int *b)
|
ClampColor(int *r, int *g, int *b)
|
||||||
{
|
{
|
||||||
if (TerminalBackground == TERMINAL_BACKGROUND_UNKNOWN) {
|
if (GetTerminalBackground() == TERMINAL_BACKGROUND_UNKNOWN) {
|
||||||
/* No special clamping if terminal background is unknown */
|
/* No special clamping if terminal background is unknown */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (TerminalBackground == TERMINAL_BACKGROUND_DARK) {
|
if (GetTerminalBackground() == TERMINAL_BACKGROUND_DARK) {
|
||||||
if (*r <= 64 && *g <= 64 && *b <= 64) {
|
if (*r <= 64 && *g <= 64 && *b <= 64) {
|
||||||
int max = *r;
|
int max = *r;
|
||||||
double factor;
|
double factor;
|
||||||
@@ -579,7 +582,7 @@ ClampColor(int *r, int *g, int *b)
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (TerminalBackground == TERMINAL_BACKGROUND_LIGHT) {
|
if (GetTerminalBackground() == TERMINAL_BACKGROUND_LIGHT) {
|
||||||
if (*r > 191 && *g > 191 && *b > 191) {
|
if (*r > 191 && *g > 191 && *b > 191) {
|
||||||
int min = *r;
|
int min = *r;
|
||||||
if (*g < min) min = *g;
|
if (*g < min) min = *g;
|
||||||
@@ -621,7 +624,6 @@ Colorize256(int r, int g, int b, int bg, int clamp)
|
|||||||
best = (int) i;
|
best = (int) i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur = &XTerm256Colors[best];
|
|
||||||
if (bg) {
|
if (bg) {
|
||||||
sprintf(buf, "\x1B[48;5;%dm", best);
|
sprintf(buf, "\x1B[48;5;%dm", best);
|
||||||
} else {
|
} else {
|
||||||
@@ -668,11 +670,11 @@ Colorize(int r, int g, int b, int bg, int clamp)
|
|||||||
if (b > 64) b = 1;
|
if (b > 64) b = 1;
|
||||||
else b = 0;
|
else b = 0;
|
||||||
|
|
||||||
if (clamp && TerminalBackground == TERMINAL_BACKGROUND_DARK && !bg) {
|
if (clamp && GetTerminalBackground() == TERMINAL_BACKGROUND_DARK && !bg) {
|
||||||
/* Convert black-on-black to grey */
|
/* Convert black-on-black to grey */
|
||||||
if (!r && !g && !b) return VT100Colors[1][0][0][0];
|
if (!r && !g && !b) return VT100Colors[1][0][0][0];
|
||||||
}
|
}
|
||||||
if (clamp && TerminalBackground == TERMINAL_BACKGROUND_LIGHT && !bg) {
|
if (clamp && GetTerminalBackground() == TERMINAL_BACKGROUND_LIGHT && !bg) {
|
||||||
/* Convert white-on-white to grey */
|
/* Convert white-on-white to grey */
|
||||||
if (r && g && b) return VT100Colors[1][0][0][0];
|
if (r && g && b) return VT100Colors[1][0][0][0];
|
||||||
}
|
}
|
||||||
@@ -1038,7 +1040,7 @@ static void DoCalendarOneMonth(void)
|
|||||||
printf("\"entries\":[\n");
|
printf("\"entries\":[\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (WriteCalendarRow()) continue;
|
while (WriteCalendarRow()) /* continue */;
|
||||||
|
|
||||||
if (PsCal == PSCAL_LEVEL1) {
|
if (PsCal == PSCAL_LEVEL1) {
|
||||||
printf("%s\n", PSEND);
|
printf("%s\n", PSEND);
|
||||||
@@ -1219,7 +1221,7 @@ static void PrintLeft(char const *s, int width, char pad)
|
|||||||
if (!buf) {
|
if (!buf) {
|
||||||
/* Uh-oh... cannot recover */
|
/* Uh-oh... cannot recover */
|
||||||
fprintf(stderr, "%s\n", ErrMsg[E_NO_MEM]);
|
fprintf(stderr, "%s\n", ErrMsg[E_NO_MEM]);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void) mbstowcs(buf, s, len+1);
|
(void) mbstowcs(buf, s, len+1);
|
||||||
@@ -1228,7 +1230,7 @@ static void PrintLeft(char const *s, int width, char pad)
|
|||||||
ws = buf;
|
ws = buf;
|
||||||
for (i=0; i<width;) {
|
for (i=0; i<width;) {
|
||||||
if (*ws) {
|
if (*ws) {
|
||||||
PutWideChar(*ws++);
|
PutWideChar(*ws++, NULL);
|
||||||
i+= wcwidth(*ws);
|
i+= wcwidth(*ws);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@@ -1236,7 +1238,7 @@ static void PrintLeft(char const *s, int width, char pad)
|
|||||||
}
|
}
|
||||||
/* Mop up any potential combining characters */
|
/* Mop up any potential combining characters */
|
||||||
while (*ws && wcwidth(*ws) == 0) {
|
while (*ws && wcwidth(*ws) == 0) {
|
||||||
PutWideChar(*ws++);
|
PutWideChar(*ws++, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Possibly send lrm control sequence */
|
/* Possibly send lrm control sequence */
|
||||||
@@ -1298,7 +1300,7 @@ static void PrintCentered(char const *s, int width, char *pad)
|
|||||||
if (!buf) {
|
if (!buf) {
|
||||||
/* Uh-oh... cannot recover */
|
/* Uh-oh... cannot recover */
|
||||||
fprintf(stderr, "%s\n", ErrMsg[E_NO_MEM]);
|
fprintf(stderr, "%s\n", ErrMsg[E_NO_MEM]);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void) mbstowcs(buf, s, len+1);
|
(void) mbstowcs(buf, s, len+1);
|
||||||
@@ -1309,7 +1311,7 @@ static void PrintCentered(char const *s, int width, char *pad)
|
|||||||
for (i=0; i<d; i++) fputs(pad, stdout);
|
for (i=0; i<d; i++) fputs(pad, stdout);
|
||||||
for (i=0; i<width; i++) {
|
for (i=0; i<width; i++) {
|
||||||
if (*ws) {
|
if (*ws) {
|
||||||
PutWideChar(*ws++);
|
PutWideChar(*ws++, NULL);
|
||||||
if (wcwidth(*ws) == 0) {
|
if (wcwidth(*ws) == 0) {
|
||||||
/* Don't count this character... it's zero-width */
|
/* Don't count this character... it's zero-width */
|
||||||
i--;
|
i--;
|
||||||
@@ -1320,7 +1322,7 @@ static void PrintCentered(char const *s, int width, char *pad)
|
|||||||
}
|
}
|
||||||
/* Mop up any potential combining characters */
|
/* Mop up any potential combining characters */
|
||||||
while (*ws && wcwidth(*ws) == 0) {
|
while (*ws && wcwidth(*ws) == 0) {
|
||||||
PutWideChar(*ws++);
|
PutWideChar(*ws++, NULL);
|
||||||
}
|
}
|
||||||
/* Possibly send lrm control sequence */
|
/* Possibly send lrm control sequence */
|
||||||
send_lrm();
|
send_lrm();
|
||||||
@@ -1449,7 +1451,7 @@ static int WriteOneColLine(int col)
|
|||||||
}
|
}
|
||||||
numwritten += wcwidth(*ws);
|
numwritten += wcwidth(*ws);
|
||||||
}
|
}
|
||||||
PutWideChar(*ws);
|
PutWideChar(*ws, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e->wc_pos = ws;
|
e->wc_pos = ws;
|
||||||
@@ -1464,7 +1466,7 @@ static int WriteOneColLine(int col)
|
|||||||
if (wcwidth(*ws) > 0) {
|
if (wcwidth(*ws) > 0) {
|
||||||
numwritten += wcwidth(*ws);
|
numwritten += wcwidth(*ws);
|
||||||
}
|
}
|
||||||
PutWideChar(*ws);
|
PutWideChar(*ws, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1604,7 +1606,7 @@ static void GenerateCalEntries(int col)
|
|||||||
r=IncludeFile(InitialFile);
|
r=IncludeFile(InitialFile);
|
||||||
if (r) {
|
if (r) {
|
||||||
fprintf(ErrFp, "%s %s: %s\n", ErrMsg[E_ERR_READING], InitialFile, ErrMsg[r]);
|
fprintf(ErrFp, "%s %s: %s\n", ErrMsg[E_ERR_READING], InitialFile, ErrMsg[r]);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
@@ -1612,7 +1614,7 @@ static void GenerateCalEntries(int col)
|
|||||||
if (r == E_EOF) return;
|
if (r == E_EOF) return;
|
||||||
if (r) {
|
if (r) {
|
||||||
Eprint("%s: %s", ErrMsg[E_ERR_READING], ErrMsg[r]);
|
Eprint("%s: %s", ErrMsg[E_ERR_READING], ErrMsg[r]);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
s = FindInitialToken(&tok, CurLine);
|
s = FindInitialToken(&tok, CurLine);
|
||||||
|
|
||||||
@@ -1667,6 +1669,7 @@ static void GenerateCalEntries(int col)
|
|||||||
case T_Pop: r=PopOmitContext(&p); break;
|
case T_Pop: r=PopOmitContext(&p); break;
|
||||||
case T_Push: r=PushOmitContext(&p); break;
|
case T_Push: r=PushOmitContext(&p); break;
|
||||||
case T_Preserve: r=DoPreserve(&p); break;
|
case T_Preserve: r=DoPreserve(&p); break;
|
||||||
|
case T_Expr: r = DoExpr(&p); break;
|
||||||
case T_RemType: if (tok.val == RUN_TYPE) {
|
case T_RemType: if (tok.val == RUN_TYPE) {
|
||||||
r=DoRun(&p);
|
r=DoRun(&p);
|
||||||
break;
|
break;
|
||||||
@@ -1767,7 +1770,7 @@ static int DoCalRem(ParsePtr p, int col)
|
|||||||
DBufInit(&raw_buf);
|
DBufInit(&raw_buf);
|
||||||
|
|
||||||
/* Parse the trigger date and time */
|
/* Parse the trigger date and time */
|
||||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) {
|
if ( (r=ParseRem(p, &trig, &tim)) ) {
|
||||||
FreeTrig(&trig);
|
FreeTrig(&trig);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -1812,8 +1815,12 @@ static int DoCalRem(ParsePtr p, int col)
|
|||||||
FindToken(DBufValue(&buf), &tok);
|
FindToken(DBufValue(&buf), &tok);
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
if (tok.type == T_Empty || tok.type == T_Comment) {
|
if (tok.type == T_Empty || tok.type == T_Comment) {
|
||||||
|
r = OK;
|
||||||
|
if (trig.addomit) {
|
||||||
|
r = AddGlobalOmit(LastTriggerDate);
|
||||||
|
}
|
||||||
FreeTrig(&trig);
|
FreeTrig(&trig);
|
||||||
return OK;
|
return r;
|
||||||
}
|
}
|
||||||
if (tok.type != T_RemType || tok.val == SAT_TYPE) {
|
if (tok.type != T_RemType || tok.val == SAT_TYPE) {
|
||||||
FreeTrig(&trig);
|
FreeTrig(&trig);
|
||||||
@@ -1831,6 +1838,10 @@ static int DoCalRem(ParsePtr p, int col)
|
|||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
}
|
}
|
||||||
trig.typ = tok.val;
|
trig.typ = tok.val;
|
||||||
|
|
||||||
|
/* Convert some SPECIALs back to plain types */
|
||||||
|
FixSpecialType(&trig);
|
||||||
|
|
||||||
if (trig.typ == MSG_TYPE ||
|
if (trig.typ == MSG_TYPE ||
|
||||||
trig.typ == CAL_TYPE ||
|
trig.typ == CAL_TYPE ||
|
||||||
trig.typ == MSF_TYPE) {
|
trig.typ == MSF_TYPE) {
|
||||||
@@ -2204,10 +2215,114 @@ static void WriteSimpleEntryProtocol1(CalEntry *e)
|
|||||||
printf("%s\n", e->text);
|
printf("%s\n", e->text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WriteJSONTimeTrigger(TimeTrig const *tt)
|
||||||
|
{
|
||||||
|
PrintJSONKeyPairTime("time", tt->ttime);
|
||||||
|
PrintJSONKeyPairTime("nexttime", tt->nexttime);
|
||||||
|
PrintJSONKeyPairInt("tdelta", tt->delta);
|
||||||
|
PrintJSONKeyPairInt("trep", tt->rep);
|
||||||
|
if (tt->duration != NO_TIME) {
|
||||||
|
PrintJSONKeyPairInt("duration", tt->duration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteJSONTrigger(Trigger const *t, int include_tags, int today)
|
||||||
|
{
|
||||||
|
/* wd is an array of days from 0=monday to 6=sunday.
|
||||||
|
We convert to array of strings */
|
||||||
|
if (t->wd != NO_WD) {
|
||||||
|
printf("\"wd\":[");
|
||||||
|
int done = 0;
|
||||||
|
int i;
|
||||||
|
for (i=0; i<7; i++) {
|
||||||
|
if (t->wd & (1 << i)) {
|
||||||
|
if (done) {
|
||||||
|
printf(",");
|
||||||
|
}
|
||||||
|
done = 1;
|
||||||
|
printf("\"%s\"", EnglishDayName[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("],");
|
||||||
|
}
|
||||||
|
if (t->d != NO_DAY) {
|
||||||
|
PrintJSONKeyPairInt("d", t->d);
|
||||||
|
}
|
||||||
|
if (t->m != NO_MON) {
|
||||||
|
PrintJSONKeyPairInt("m", t->m+1);
|
||||||
|
}
|
||||||
|
if (t->y != NO_YR) {
|
||||||
|
PrintJSONKeyPairInt("y", t->y);
|
||||||
|
}
|
||||||
|
if (t->back) {
|
||||||
|
PrintJSONKeyPairInt("back", t->back);
|
||||||
|
}
|
||||||
|
if (t->delta) {
|
||||||
|
PrintJSONKeyPairInt("delta", t->delta);
|
||||||
|
}
|
||||||
|
if (t->rep) {
|
||||||
|
PrintJSONKeyPairInt("rep", t->rep);
|
||||||
|
}
|
||||||
|
/* Local omit is an array of days from 0=monday to 6=sunday.
|
||||||
|
We convert to array of strings */
|
||||||
|
if (t->localomit != NO_WD) {
|
||||||
|
printf("\"localomit\":[");
|
||||||
|
int done = 0;
|
||||||
|
int i;
|
||||||
|
for (i=0; i<7; i++) {
|
||||||
|
if (t->localomit & (1 << i)) {
|
||||||
|
if (done) {
|
||||||
|
printf(",");
|
||||||
|
}
|
||||||
|
done = 1;
|
||||||
|
printf("\"%s\"", EnglishDayName[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("],");
|
||||||
|
}
|
||||||
|
switch(t->skip) {
|
||||||
|
case SKIP_SKIP:
|
||||||
|
PrintJSONKeyPairString("skip", "SKIP");
|
||||||
|
break;
|
||||||
|
case BEFORE_SKIP:
|
||||||
|
PrintJSONKeyPairString("skip", "BEFORE");
|
||||||
|
break;
|
||||||
|
case AFTER_SKIP:
|
||||||
|
PrintJSONKeyPairString("skip", "AFTER");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
PrintJSONKeyPairDate("until", t->until);
|
||||||
|
if (t->once != NO_ONCE) {
|
||||||
|
PrintJSONKeyPairInt("once", t->once);
|
||||||
|
}
|
||||||
|
if (t->scanfrom != today) {
|
||||||
|
PrintJSONKeyPairDate("scanfrom", t->scanfrom);
|
||||||
|
}
|
||||||
|
PrintJSONKeyPairDate("from", t->from);
|
||||||
|
PrintJSONKeyPairInt("priority", t->priority);
|
||||||
|
PrintJSONKeyPairDateTime("eventstart", t->eventstart);
|
||||||
|
if (t->eventduration != NO_TIME) {
|
||||||
|
PrintJSONKeyPairInt("eventduration", t->eventduration);
|
||||||
|
}
|
||||||
|
if (t->maybe_uncomputable) {
|
||||||
|
PrintJSONKeyPairInt("maybe_uncomputable", 1);
|
||||||
|
}
|
||||||
|
if (t->noqueue) {
|
||||||
|
PrintJSONKeyPairInt("noqueue", 1);
|
||||||
|
}
|
||||||
|
PrintJSONKeyPairString("sched", t->sched);
|
||||||
|
PrintJSONKeyPairString("warn", t->warn);
|
||||||
|
PrintJSONKeyPairString("omitfunc", t->omitfunc);
|
||||||
|
if (t->addomit) {
|
||||||
|
PrintJSONKeyPairInt("addomit", 1);
|
||||||
|
}
|
||||||
|
if (include_tags) {
|
||||||
|
PrintJSONKeyPairString("tags", DBufValue(&(t->tags)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void WriteSimpleEntryProtocol2(CalEntry *e, int today)
|
static void WriteSimpleEntryProtocol2(CalEntry *e, int today)
|
||||||
{
|
{
|
||||||
int done = 0;
|
|
||||||
char const *s;
|
char const *s;
|
||||||
if (DoPrefixLineNo) {
|
if (DoPrefixLineNo) {
|
||||||
PrintJSONKeyPairString("filename", e->filename);
|
PrintJSONKeyPairString("filename", e->filename);
|
||||||
@@ -2227,88 +2342,13 @@ static void WriteSimpleEntryProtocol2(CalEntry *e, int today)
|
|||||||
PrintJSONKeyPairInt("trep", e->tt.rep);
|
PrintJSONKeyPairInt("trep", e->tt.rep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e->trig.eventduration != NO_TIME) {
|
WriteJSONTrigger(&e->trig, 0, today);
|
||||||
PrintJSONKeyPairInt("eventduration", e->trig.eventduration);
|
|
||||||
}
|
|
||||||
/* wd is an array of days from 0=monday to 6=sunday.
|
|
||||||
We convert to array of strings */
|
|
||||||
if (e->trig.wd != NO_WD) {
|
|
||||||
printf("\"wd\":[");
|
|
||||||
done = 0;
|
|
||||||
int i;
|
|
||||||
for (i=0; i<7; i++) {
|
|
||||||
if (e->trig.wd & (1 << i)) {
|
|
||||||
if (done) {
|
|
||||||
printf(",");
|
|
||||||
}
|
|
||||||
done = 1;
|
|
||||||
printf("\"%s\"", EnglishDayName[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("],");
|
|
||||||
}
|
|
||||||
if (e->trig.d != NO_DAY) {
|
|
||||||
PrintJSONKeyPairInt("d", e->trig.d);
|
|
||||||
}
|
|
||||||
if (e->trig.m != NO_MON) {
|
|
||||||
PrintJSONKeyPairInt("m", e->trig.m+1);
|
|
||||||
}
|
|
||||||
if (e->trig.y != NO_YR) {
|
|
||||||
PrintJSONKeyPairInt("y", e->trig.y);
|
|
||||||
}
|
|
||||||
PrintJSONKeyPairDateTime("eventstart", e->trig.eventstart);
|
|
||||||
if (e->trig.back) {
|
|
||||||
PrintJSONKeyPairInt("back", e->trig.back);
|
|
||||||
}
|
|
||||||
if (e->trig.delta) {
|
|
||||||
PrintJSONKeyPairInt("delta", e->trig.delta);
|
|
||||||
}
|
|
||||||
if (e->trig.rep) {
|
|
||||||
PrintJSONKeyPairInt("rep", e->trig.rep);
|
|
||||||
}
|
|
||||||
if (e->nonconst_expr) {
|
if (e->nonconst_expr) {
|
||||||
PrintJSONKeyPairInt("nonconst_expr", e->nonconst_expr);
|
PrintJSONKeyPairInt("nonconst_expr", e->nonconst_expr);
|
||||||
}
|
}
|
||||||
if (e->if_depth) {
|
if (e->if_depth) {
|
||||||
PrintJSONKeyPairInt("if_depth", e->if_depth);
|
PrintJSONKeyPairInt("if_depth", e->if_depth);
|
||||||
}
|
}
|
||||||
switch(e->trig.skip) {
|
|
||||||
case SKIP_SKIP:
|
|
||||||
PrintJSONKeyPairString("skip", "SKIP");
|
|
||||||
break;
|
|
||||||
case BEFORE_SKIP:
|
|
||||||
PrintJSONKeyPairString("skip", "BEFORE");
|
|
||||||
break;
|
|
||||||
case AFTER_SKIP:
|
|
||||||
PrintJSONKeyPairString("skip", "AFTER");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Local omit is an array of days from 0=monday to 6=sunday.
|
|
||||||
We convert to array of strings */
|
|
||||||
if (e->trig.localomit != NO_WD) {
|
|
||||||
printf("\"localomit\":[");
|
|
||||||
done = 0;
|
|
||||||
int i;
|
|
||||||
for (i=0; i<7; i++) {
|
|
||||||
if (e->trig.localomit & (1 << i)) {
|
|
||||||
if (done) {
|
|
||||||
printf(",");
|
|
||||||
}
|
|
||||||
done = 1;
|
|
||||||
printf("\"%s\"", EnglishDayName[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("],");
|
|
||||||
}
|
|
||||||
PrintJSONKeyPairDate("until", e->trig.until);
|
|
||||||
if (e->trig.once != NO_ONCE) {
|
|
||||||
PrintJSONKeyPairInt("once", e->trig.once);
|
|
||||||
}
|
|
||||||
if (e->trig.scanfrom != today) {
|
|
||||||
PrintJSONKeyPairDate("scanfrom", e->trig.scanfrom);
|
|
||||||
}
|
|
||||||
PrintJSONKeyPairDate("from", e->trig.from);
|
|
||||||
PrintJSONKeyPairInt("priority", e->trig.priority);
|
|
||||||
|
|
||||||
if (e->is_color) {
|
if (e->is_color) {
|
||||||
PrintJSONKeyPairInt("r", e->r);
|
PrintJSONKeyPairInt("r", e->r);
|
||||||
|
|||||||
@@ -24,27 +24,46 @@ if (!$ARGV[0]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $lang = $ARGV[0];
|
my $lang = $ARGV[0];
|
||||||
if (!exists($language_map->{$lang})) {
|
my $rc = 0;
|
||||||
print STDERR "$lang is not a valid language.\n";
|
if ($lang eq 'all') {
|
||||||
exit(1);
|
foreach my $l (sort(keys(%$language_map))) {
|
||||||
}
|
if (check($l)) {
|
||||||
|
$rc = 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";
|
|
||||||
} else {
|
} 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);
|
exit(0);
|
||||||
|
|
||||||
sub my_sys
|
sub my_sys
|
||||||
|
|||||||
@@ -1,25 +1,30 @@
|
|||||||
/* 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. */
|
/* Define if your <sys/time.h> declares struct tm. */
|
||||||
#undef TM_IN_SYS_TIME
|
#undef TM_IN_SYS_TIME
|
||||||
|
|
||||||
/* Define if you have the <sys/file.h> header file. */
|
|
||||||
#undef HAVE_SYS_FILE_H
|
|
||||||
|
|
||||||
/* Define if you have the <sys/types.h> header file. */
|
/* Define if you have the <sys/types.h> header file. */
|
||||||
#undef HAVE_SYS_TYPES_H
|
#undef HAVE_SYS_TYPES_H
|
||||||
|
|
||||||
|
/* Define if you have the <sys/inotify.h> header file. */
|
||||||
|
#undef HAVE_SYS_INOTIFY_H
|
||||||
|
|
||||||
/* Define if you have the <glob.h> header file */
|
/* Define if you have the <glob.h> header file */
|
||||||
#undef HAVE_GLOB_H
|
#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_WCTYPE_H
|
||||||
|
|
||||||
#undef HAVE_LOCALE_H
|
#undef HAVE_LOCALE_H
|
||||||
|
|
||||||
|
#undef HAVE_INOTIFY_INIT1
|
||||||
|
|
||||||
#undef HAVE_LANGINFO_H
|
#undef HAVE_LANGINFO_H
|
||||||
|
|
||||||
#undef HAVE_GLOB
|
#undef HAVE_GLOB
|
||||||
@@ -40,4 +45,8 @@
|
|||||||
/* The number of bytes in a unsigned long. */
|
/* The number of bytes in a unsigned long. */
|
||||||
#undef SIZEOF_UNSIGNED_LONG
|
#undef SIZEOF_UNSIGNED_LONG
|
||||||
|
|
||||||
|
#define PACKAGE_NAME "@PACKAGE_NAME@"
|
||||||
|
#define PACKAGE_URL "@PACKAGE_URL@"
|
||||||
|
|
||||||
#include "custom.h"
|
#include "custom.h"
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* which you can customize. */
|
/* which you can customize. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
/* VAL_STACK_SIZE: The size of the operand stack for expr. parsing */
|
/* 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? */
|
/* INCLUDE_NEST: How many nested INCLUDES do we handle? */
|
||||||
@@ -166,6 +166,10 @@
|
|||||||
|
|
||||||
#define PASSTHRU_LEN 32
|
#define PASSTHRU_LEN 32
|
||||||
|
|
||||||
|
#define MAX_RECURSION_LEVEL 1000
|
||||||
|
|
||||||
|
#define MAX_FUNC_ARGS 64
|
||||||
|
|
||||||
#define PSBEGIN "# rem2ps begin"
|
#define PSBEGIN "# rem2ps begin"
|
||||||
#define PSEND "# rem2ps end"
|
#define PSEND "# rem2ps end"
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* which you can customize. */
|
/* which you can customize. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
/*---------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------*/
|
||||||
/* VAL_STACK_SIZE: The size of the operand stack for expr. parsing */
|
/* 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? */
|
/* INCLUDE_NEST: How many nested INCLUDES do we handle? */
|
||||||
@@ -166,6 +166,10 @@
|
|||||||
|
|
||||||
#define PASSTHRU_LEN 32
|
#define PASSTHRU_LEN 32
|
||||||
|
|
||||||
|
#define MAX_RECURSION_LEVEL 1000
|
||||||
|
|
||||||
|
#define MAX_FUNC_ARGS 64
|
||||||
|
|
||||||
#define PSBEGIN "# rem2ps begin"
|
#define PSBEGIN "# rem2ps begin"
|
||||||
#define PSEND "# rem2ps end"
|
#define PSEND "# rem2ps end"
|
||||||
|
|
||||||
|
|||||||
211
src/dorem.c
211
src/dorem.c
@@ -7,7 +7,7 @@
|
|||||||
/* commands. */
|
/* commands. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -23,9 +23,8 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
#include "protos.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 ParseLocalOmit (ParsePtr s, Trigger *t);
|
||||||
static int ParseScanFrom (ParsePtr s, Trigger *t, int type);
|
static int ParseScanFrom (ParsePtr s, Trigger *t, int type);
|
||||||
static int ParsePriority (ParsePtr s, Trigger *t);
|
static int ParsePriority (ParsePtr s, Trigger *t);
|
||||||
@@ -63,7 +62,7 @@ int DoRem(ParsePtr p)
|
|||||||
DBufInit(&buf);
|
DBufInit(&buf);
|
||||||
|
|
||||||
/* Parse the trigger date and time */
|
/* Parse the trigger date and time */
|
||||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) {
|
if ( (r=ParseRem(p, &trig, &tim)) ) {
|
||||||
FreeTrig(&trig);
|
FreeTrig(&trig);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -123,8 +122,12 @@ int DoRem(ParsePtr p)
|
|||||||
}
|
}
|
||||||
StrnCpy(trig.passthru, DBufValue(&buf), PASSTHRU_LEN);
|
StrnCpy(trig.passthru, DBufValue(&buf), PASSTHRU_LEN);
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
}
|
}
|
||||||
trig.typ = tok.val;
|
trig.typ = tok.val;
|
||||||
|
|
||||||
|
/* Convert some SPECIALs back to plain types */
|
||||||
|
FixSpecialType(&trig);
|
||||||
|
|
||||||
dse = LastTriggerDate;
|
dse = LastTriggerDate;
|
||||||
if (!LastTrigValid || PurgeMode) {
|
if (!LastTrigValid || PurgeMode) {
|
||||||
FreeTrig(&trig);
|
FreeTrig(&trig);
|
||||||
@@ -159,6 +162,7 @@ int DoRem(ParsePtr p)
|
|||||||
if (p->expr_happened) {
|
if (p->expr_happened) {
|
||||||
if (p->nonconst_expr) {
|
if (p->nonconst_expr) {
|
||||||
PurgeEchoLine("%s\n", "#!P: Next line may have expired, but contains non-constant expression");
|
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);
|
PurgeEchoLine("%s\n", CurLine);
|
||||||
} else {
|
} else {
|
||||||
PurgeEchoLine("%s\n", "#!P: Next line has expired, but contains expression... please verify");
|
PurgeEchoLine("%s\n", "#!P: Next line has expired, but contains expression... please verify");
|
||||||
@@ -188,16 +192,18 @@ int DoRem(ParsePtr p)
|
|||||||
|
|
||||||
r = OK;
|
r = OK;
|
||||||
if (ShouldTriggerReminder(&trig, &tim, dse, &err)) {
|
if (ShouldTriggerReminder(&trig, &tim, dse, &err)) {
|
||||||
if ( (r=TriggerReminder(p, &trig, &tim, dse)) ) {
|
if ( (r=TriggerReminder(p, &trig, &tim, dse, 0, NULL)) ) {
|
||||||
FreeTrig(&trig);
|
FreeTrig(&trig);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Parse the rest of the line to catch any potential
|
/* Parse the rest of the line to catch any potential
|
||||||
expression-pasting errors */
|
expression-pasting errors */
|
||||||
while (ParseChar(p, &r, 0)) {
|
if (ParseUntriggered) {
|
||||||
if (r != 0) {
|
while (ParseChar(p, &r, 0)) {
|
||||||
break;
|
if (r != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,7 +220,7 @@ int DoRem(ParsePtr p)
|
|||||||
/* trigger structure. */
|
/* 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;
|
register int r;
|
||||||
DynamicBuffer buf;
|
DynamicBuffer buf;
|
||||||
@@ -256,10 +262,6 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
|||||||
trig->need_wkday = 0;
|
trig->need_wkday = 0;
|
||||||
trig->adj_for_last = 0;
|
trig->adj_for_last = 0;
|
||||||
|
|
||||||
if (save_in_globals) {
|
|
||||||
LastTriggerTime = NO_TIME;
|
|
||||||
}
|
|
||||||
|
|
||||||
int parsing = 1;
|
int parsing = 1;
|
||||||
while(parsing) {
|
while(parsing) {
|
||||||
/* Read space-delimited string */
|
/* Read space-delimited string */
|
||||||
@@ -309,10 +311,6 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
|||||||
trig->m = m;
|
trig->m = m;
|
||||||
trig->d = d;
|
trig->d = d;
|
||||||
tim->ttime = (tok.val % MINUTES_PER_DAY);
|
tim->ttime = (tok.val % MINUTES_PER_DAY);
|
||||||
if (save_in_globals) {
|
|
||||||
LastTriggerTime = tim->ttime;
|
|
||||||
SaveLastTimeTrig(tim);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_WkDay:
|
case T_WkDay:
|
||||||
@@ -344,9 +342,19 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
|||||||
if (r) return r;
|
if (r) return r;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* A time implicitly introduces an AT if AT is not explicit */
|
||||||
|
case T_Time:
|
||||||
|
DBufFree(&buf);
|
||||||
|
if (tim->ttime != NO_TIME) return E_TIME_TWICE;
|
||||||
|
tim->ttime = tok.val;
|
||||||
|
r = ParseTimeTrig(s, tim);
|
||||||
|
if (r) return r;
|
||||||
|
trig->duration_days = ComputeTrigDuration(tim);
|
||||||
|
break;
|
||||||
|
|
||||||
case T_At:
|
case T_At:
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
r=ParseTimeTrig(s, tim, save_in_globals);
|
r=ParseTimeTrig(s, tim);
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
trig->duration_days = ComputeTrigDuration(tim);
|
trig->duration_days = ComputeTrigDuration(tim);
|
||||||
break;
|
break;
|
||||||
@@ -370,6 +378,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
|||||||
}
|
}
|
||||||
StrnCpy(trig->passthru, DBufValue(&buf), PASSTHRU_LEN);
|
StrnCpy(trig->passthru, DBufValue(&buf), PASSTHRU_LEN);
|
||||||
}
|
}
|
||||||
|
FixSpecialType(trig);
|
||||||
parsing = 0;
|
parsing = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -464,10 +473,10 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
|||||||
r=ParseToken(s, &buf);
|
r=ParseToken(s, &buf);
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
StrnCpy(trig->omitfunc, DBufValue(&buf), VAR_NAME_LEN);
|
StrnCpy(trig->omitfunc, DBufValue(&buf), VAR_NAME_LEN);
|
||||||
|
strtolower(trig->omitfunc);
|
||||||
/* An OMITFUNC counts as a nonconst_expr! */
|
/* An OMITFUNC counts as a nonconst_expr! */
|
||||||
s->expr_happened = 1;
|
s->expr_happened = 1;
|
||||||
s->nonconst_expr = 1;
|
s->nonconst_expr = 1;
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -475,6 +484,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
|||||||
r=ParseToken(s, &buf);
|
r=ParseToken(s, &buf);
|
||||||
if(r) return r;
|
if(r) return r;
|
||||||
StrnCpy(trig->warn, DBufValue(&buf), VAR_NAME_LEN);
|
StrnCpy(trig->warn, DBufValue(&buf), VAR_NAME_LEN);
|
||||||
|
strtolower(trig->warn);
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -505,9 +515,6 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
|||||||
} else {
|
} else {
|
||||||
tim->duration = NO_TIME;
|
tim->duration = NO_TIME;
|
||||||
}
|
}
|
||||||
if (save_in_globals) {
|
|
||||||
SaveLastTimeTrig(tim);
|
|
||||||
}
|
|
||||||
trig->duration_days = ComputeTrigDuration(tim);
|
trig->duration_days = ComputeTrigDuration(tim);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -519,6 +526,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
|||||||
r=ParseToken(s, &buf);
|
r=ParseToken(s, &buf);
|
||||||
if(r) return r;
|
if(r) return r;
|
||||||
StrnCpy(trig->sched, DBufValue(&buf), VAR_NAME_LEN);
|
StrnCpy(trig->sched, DBufValue(&buf), VAR_NAME_LEN);
|
||||||
|
strtolower(trig->sched);
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -591,7 +599,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
|||||||
/* ParseTimeTrig - parse the AT part of a timed reminder */
|
/* 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;
|
Token tok;
|
||||||
int r;
|
int r;
|
||||||
@@ -626,11 +634,6 @@ static int ParseTimeTrig(ParsePtr s, TimeTrig *tim, int save_in_globals)
|
|||||||
default:
|
default:
|
||||||
if (tim->ttime == NO_TIME) return E_EXPECT_TIME;
|
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);
|
PushToken(DBufValue(&buf), s);
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return OK;
|
return OK;
|
||||||
@@ -662,6 +665,9 @@ static int ParseLocalOmit(ParsePtr s, Trigger *t)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
if (t->localomit == NO_WD) {
|
||||||
|
return E_EXPECTING_WEEKDAY;
|
||||||
|
}
|
||||||
PushToken(DBufValue(&buf), s);
|
PushToken(DBufValue(&buf), s);
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return OK;
|
return OK;
|
||||||
@@ -856,6 +862,9 @@ static int ParseScanFrom(ParsePtr s, Trigger *t, int type)
|
|||||||
tok.val = -tok.val;
|
tok.val = -tok.val;
|
||||||
}
|
}
|
||||||
FromDSE(DSEToday - tok.val, &y, &m, &d);
|
FromDSE(DSEToday - tok.val, &y, &m, &d);
|
||||||
|
/* Don't purge reminders with a relative scanfrom */
|
||||||
|
s->expr_happened = 1;
|
||||||
|
s->nonconst_expr = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -893,7 +902,7 @@ static int ParseScanFrom(ParsePtr s, Trigger *t, int type)
|
|||||||
/* Trigger the reminder if it's a RUN or MSG type. */
|
/* Trigger the reminder if it's a RUN or MSG type. */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse)
|
int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse, int is_queued, DynamicBuffer *output)
|
||||||
{
|
{
|
||||||
int r, y, m, d;
|
int r, y, m, d;
|
||||||
char PrioExpr[VAR_NAME_LEN+25];
|
char PrioExpr[VAR_NAME_LEN+25];
|
||||||
@@ -901,8 +910,21 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse)
|
|||||||
DynamicBuffer buf, calRow;
|
DynamicBuffer buf, calRow;
|
||||||
DynamicBuffer pre_buf;
|
DynamicBuffer pre_buf;
|
||||||
char const *s;
|
char const *s;
|
||||||
|
char const *msg_command = NULL;
|
||||||
Value v;
|
Value v;
|
||||||
|
|
||||||
|
if (MsgCommand) {
|
||||||
|
msg_command = MsgCommand;
|
||||||
|
}
|
||||||
|
if (is_queued && QueuedMsgCommand) {
|
||||||
|
msg_command = QueuedMsgCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A null command is no command */
|
||||||
|
if (msg_command && !*msg_command) {
|
||||||
|
msg_command = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int red = -1, green = -1, blue = -1;
|
int red = -1, green = -1, blue = -1;
|
||||||
int is_color = 0;
|
int is_color = 0;
|
||||||
|
|
||||||
@@ -947,7 +969,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse)
|
|||||||
}
|
}
|
||||||
/* If it's a MSG-type reminder, and no -k option was used, issue the banner. */
|
/* If it's a MSG-type reminder, and no -k option was used, issue the banner. */
|
||||||
if ((t->typ == MSG_TYPE || t->typ == MSF_TYPE)
|
if ((t->typ == MSG_TYPE || t->typ == MSF_TYPE)
|
||||||
&& !DidMsgReminder && !NextMode && !MsgCommand) {
|
&& !DidMsgReminder && !NextMode && !msg_command && !is_queued) {
|
||||||
DidMsgReminder = 1;
|
DidMsgReminder = 1;
|
||||||
if (!DoSubstFromString(DBufValue(&Banner), &buf,
|
if (!DoSubstFromString(DBufValue(&Banner), &buf,
|
||||||
DSEToday, NO_TIME) &&
|
DSEToday, NO_TIME) &&
|
||||||
@@ -1014,11 +1036,18 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse)
|
|||||||
return E_NO_MEM;
|
return E_NO_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s%s%s\n", DBufValue(&calRow), DBufValue(&pre_buf), DBufValue(&buf));
|
r = OK;
|
||||||
|
if (output) {
|
||||||
|
if (DBufPuts(output, DBufValue(&calRow)) != OK) r = E_NO_MEM;
|
||||||
|
if (DBufPuts(output, DBufValue(&pre_buf)) != OK) r = E_NO_MEM;
|
||||||
|
if (DBufPuts(output, DBufValue(&buf)) != OK) r = E_NO_MEM;
|
||||||
|
} else {
|
||||||
|
printf("%s%s%s\n", DBufValue(&calRow), DBufValue(&pre_buf), DBufValue(&buf));
|
||||||
|
}
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
DBufFree(&pre_buf);
|
DBufFree(&pre_buf);
|
||||||
DBufFree(&calRow);
|
DBufFree(&calRow);
|
||||||
return OK;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Correct colors */
|
/* Correct colors */
|
||||||
@@ -1091,7 +1120,7 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse)
|
|||||||
DBufPuts(&buf, Decolorize());
|
DBufPuts(&buf, Decolorize());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!MsgCommand && t->typ == MSG_TYPE) || t->typ == MSF_TYPE) {
|
if ((!msg_command && t->typ == MSG_TYPE) || t->typ == MSF_TYPE) {
|
||||||
if (DBufPutc(&buf, '\n') != OK) {
|
if (DBufPutc(&buf, '\n') != OK) {
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return E_NO_MEM;
|
return E_NO_MEM;
|
||||||
@@ -1113,19 +1142,28 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int dse)
|
|||||||
switch(t->typ) {
|
switch(t->typ) {
|
||||||
case MSG_TYPE:
|
case MSG_TYPE:
|
||||||
case PASSTHRU_TYPE:
|
case PASSTHRU_TYPE:
|
||||||
if (MsgCommand) {
|
if (msg_command) {
|
||||||
DoMsgCommand(MsgCommand, DBufValue(&buf));
|
DoMsgCommand(msg_command, DBufValue(&buf), is_queued);
|
||||||
} else {
|
} else {
|
||||||
printf("%s", DBufValue(&buf));
|
if (output) {
|
||||||
|
DBufPuts(output, DBufValue(&buf));
|
||||||
|
} else {
|
||||||
|
/* Add a space before "NOTE endreminder" */
|
||||||
|
if (IsServerMode() && !strncmp(DBufValue(&buf), "NOTE endreminder", 16)) {
|
||||||
|
printf(" %s", DBufValue(&buf));
|
||||||
|
} else {
|
||||||
|
printf("%s", DBufValue(&buf));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSF_TYPE:
|
case MSF_TYPE:
|
||||||
FillParagraph(DBufValue(&buf));
|
FillParagraph(DBufValue(&buf), output);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RUN_TYPE:
|
case RUN_TYPE:
|
||||||
System(DBufValue(&buf));
|
System(DBufValue(&buf), is_queued);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* Unknown/illegal type? */
|
default: /* Unknown/illegal type? */
|
||||||
@@ -1164,7 +1202,7 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int dse, int *err)
|
|||||||
if (DontIssueAts > 1) {
|
if (DontIssueAts > 1) {
|
||||||
/* If two or more -a options, then *DO* issue ats that are in the
|
/* If two or more -a options, then *DO* issue ats that are in the
|
||||||
future */
|
future */
|
||||||
if (tim->ttime < SystemTime(0) / 60) {
|
if (tim->ttime < MinutesPastMidnight(0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1172,29 +1210,31 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int dse, int *err)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't trigger "old" timed reminders */
|
|
||||||
/*** REMOVED...
|
|
||||||
if (dse == DSEToday &&
|
|
||||||
tim->ttime != NO_TIME &&
|
|
||||||
tim->ttime < SystemTime(0) / 60) return 0;
|
|
||||||
*** ...UNTIL HERE */
|
|
||||||
|
|
||||||
/* If "infinite delta" option is chosen, always trigger future reminders */
|
/* If "infinite delta" option is chosen, always trigger future reminders */
|
||||||
if (InfiniteDelta || NextMode) return 1;
|
if (InfiniteDelta || NextMode) return 1;
|
||||||
|
|
||||||
/* If there's a "warn" function, it overrides any deltas */
|
/* If there's a "warn" function, it overrides any deltas except
|
||||||
|
* DeltaOverride*/
|
||||||
if (t->warn[0] != 0) {
|
if (t->warn[0] != 0) {
|
||||||
if (DeltaOffset) {
|
if (DeltaOverride > 0) {
|
||||||
if (dse <= DSEToday + DeltaOffset) {
|
if (dse <= DSEToday + DeltaOverride) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ShouldTriggerBasedOnWarn(t, dse, err);
|
return ShouldTriggerBasedOnWarn(t, dse, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Zero delta */
|
||||||
|
if (DeltaOverride < 0) {
|
||||||
|
return dse == DSEToday;
|
||||||
|
}
|
||||||
|
|
||||||
/* Move back by delta days, if any */
|
/* Move back by delta days, if any */
|
||||||
if (t->delta != NO_DELTA) {
|
if (DeltaOverride) {
|
||||||
if (t->delta < 0)
|
/* A positive DeltaOverride takes precedence over everything */
|
||||||
|
dse = dse - DeltaOverride;
|
||||||
|
} else if (t->delta != NO_DELTA) {
|
||||||
|
if (t->delta < 0)
|
||||||
dse = dse + t->delta;
|
dse = dse + t->delta;
|
||||||
else {
|
else {
|
||||||
int iter = 0;
|
int iter = 0;
|
||||||
@@ -1219,7 +1259,7 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int dse, int *err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Should we trigger the reminder? */
|
/* Should we trigger the reminder? */
|
||||||
return (dse <= DSEToday + DeltaOffset);
|
return (dse <= DSEToday);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -1233,20 +1273,28 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p)
|
|||||||
{
|
{
|
||||||
int iter, dse, r, start;
|
int iter, dse, r, start;
|
||||||
Value v;
|
Value v;
|
||||||
char const *s;
|
expr_node *sat_node;
|
||||||
char const *t;
|
int nonconst = 0;
|
||||||
|
|
||||||
t = p->pos;
|
sat_node = ParseExpr(p, &r);
|
||||||
|
if (r != OK) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
if (!sat_node) {
|
||||||
|
return E_SWERR;
|
||||||
|
}
|
||||||
iter = 0;
|
iter = 0;
|
||||||
start = trig->scanfrom;
|
start = trig->scanfrom;
|
||||||
while (iter++ < MaxSatIter) {
|
while (iter++ < MaxSatIter) {
|
||||||
dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, 0);
|
dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, 0);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
free_expr_tree(sat_node);
|
||||||
if (r == E_CANT_TRIG) return OK; else return r;
|
if (r == E_CANT_TRIG) return OK; else return r;
|
||||||
}
|
}
|
||||||
if (dse != start && trig->duration_days) {
|
if (dse != start && trig->duration_days) {
|
||||||
dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, trig->duration_days);
|
dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, trig->duration_days);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
free_expr_tree(sat_node);
|
||||||
if (r == E_CANT_TRIG) return OK; else return r;
|
if (r == E_CANT_TRIG) return OK; else return r;
|
||||||
}
|
}
|
||||||
} else if (dse == start) {
|
} else if (dse == start) {
|
||||||
@@ -1259,13 +1307,18 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p)
|
|||||||
SaveAllTriggerInfo(trig, tt, dse, tt->ttime, 1);
|
SaveAllTriggerInfo(trig, tt, dse, tt->ttime, 1);
|
||||||
}
|
}
|
||||||
if (dse == -1) {
|
if (dse == -1) {
|
||||||
|
free_expr_tree(sat_node);
|
||||||
return E_EXPIRED;
|
return E_EXPIRED;
|
||||||
}
|
}
|
||||||
s = p->pos;
|
r = evaluate_expression(sat_node, NULL, &v, &nonconst);
|
||||||
r = EvaluateExpr(p, &v);
|
if (r) {
|
||||||
t = p->pos;
|
free_expr_tree(sat_node);
|
||||||
if (r) return r;
|
return r;
|
||||||
if (v.type != INT_TYPE && v.type != STR_TYPE) return E_BAD_TYPE;
|
}
|
||||||
|
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) ||
|
if ((v.type == INT_TYPE && v.v.val) ||
|
||||||
(v.type == STR_TYPE && *v.v.str)) {
|
(v.type == STR_TYPE && *v.v.str)) {
|
||||||
AdjustTriggerForDuration(trig->scanfrom, dse, trig, tt, 1);
|
AdjustTriggerForDuration(trig->scanfrom, dse, trig, tt, 1);
|
||||||
@@ -1290,17 +1343,17 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p)
|
|||||||
}
|
}
|
||||||
fprintf(ErrFp, "\n");
|
fprintf(ErrFp, "\n");
|
||||||
}
|
}
|
||||||
|
free_expr_tree(sat_node);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
p->pos = s;
|
|
||||||
if (dse+trig->duration_days < start) {
|
if (dse+trig->duration_days < start) {
|
||||||
start++;
|
start++;
|
||||||
} else {
|
} else {
|
||||||
start = dse+trig->duration_days+1;
|
start = dse+trig->duration_days+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p->pos = t;
|
|
||||||
LastTrigValid = 0;
|
LastTrigValid = 0;
|
||||||
|
free_expr_tree(sat_node);
|
||||||
return E_CANT_TRIG;
|
return E_CANT_TRIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1350,7 +1403,7 @@ static int ParsePriority(ParsePtr s, Trigger *t)
|
|||||||
/* Execute the '-k' command, escaping shell chars in message. */
|
/* Execute the '-k' command, escaping shell chars in message. */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
int DoMsgCommand(char const *cmd, char const *msg)
|
int DoMsgCommand(char const *cmd, char const *msg, int is_queued)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
int i, l;
|
int i, l;
|
||||||
@@ -1387,7 +1440,7 @@ int DoMsgCommand(char const *cmd, char const *msg)
|
|||||||
}
|
}
|
||||||
r = OK;
|
r = OK;
|
||||||
|
|
||||||
System(DBufValue(&execBuffer));
|
System(DBufValue(&execBuffer), is_queued);
|
||||||
|
|
||||||
finished:
|
finished:
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
@@ -1466,3 +1519,25 @@ static int ShouldTriggerBasedOnWarn(Trigger *t, int dse, int *err)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FixSpecialType(Trigger *t)
|
||||||
|
{
|
||||||
|
if (t->typ != PASSTHRU_TYPE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert SPECIAL MSG / MSF / RUN / CAL to just plain MSG / MSF / etc */
|
||||||
|
if (!StrCmpi(t->passthru, "MSG")) {
|
||||||
|
t->typ = MSG_TYPE;
|
||||||
|
} else if (!StrCmpi(t->passthru, "MSF")) {
|
||||||
|
t->typ = MSF_TYPE;
|
||||||
|
} else if (!StrCmpi(t->passthru, "RUN")) {
|
||||||
|
t->typ = RUN_TYPE;
|
||||||
|
} else if (!StrCmpi(t->passthru, "CAL")) {
|
||||||
|
t->typ = CAL_TYPE;
|
||||||
|
} else if (!StrCmpi(t->passthru, "PS")) {
|
||||||
|
t->typ = PS_TYPE;
|
||||||
|
} else if (!StrCmpi(t->passthru, "PSFILE")) {
|
||||||
|
t->typ = PSF_TYPE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
940
src/dosubst.c
940
src/dosubst.c
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
|||||||
/* buffers. */
|
/* buffers. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -124,7 +124,9 @@ int DBufPuts(DynamicBuffer *dbuf, char const *str)
|
|||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
void DBufFree(DynamicBuffer *dbuf)
|
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);
|
DBufInit(dbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/* Declaration of functions for manipulating dynamic buffers */
|
/* Declaration of functions for manipulating dynamic buffers */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
223
src/err.h
223
src/err.h
@@ -5,7 +5,7 @@
|
|||||||
/* Error definitions. */
|
/* Error definitions. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -121,6 +121,11 @@
|
|||||||
#define E_STRING_TOO_LONG 101
|
#define E_STRING_TOO_LONG 101
|
||||||
#define E_TIME_TWICE 102
|
#define E_TIME_TWICE 102
|
||||||
#define E_DURATION_NO_AT 103
|
#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
|
#ifdef MK_GLOBALS
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#define EXTERN
|
#define EXTERN
|
||||||
@@ -129,115 +134,123 @@
|
|||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define STR(X) STR2(X)
|
||||||
|
#define STR2(X) #X
|
||||||
|
|
||||||
|
|
||||||
#ifndef L_ERR_OVERRIDE
|
#ifndef L_ERR_OVERRIDE
|
||||||
EXTERN char *ErrMsg[]
|
EXTERN char *ErrMsg[]
|
||||||
|
|
||||||
#ifdef MK_GLOBALS
|
#ifdef MK_GLOBALS
|
||||||
= {
|
= {
|
||||||
"Ok",
|
/* OK */ "Ok",
|
||||||
"Missing ']'",
|
/* E_MISS_END */ "Missing ']'",
|
||||||
"Missing quote",
|
/* E_MISS_QUOTE */ "Missing quote",
|
||||||
"Expression too complex - too many operators",
|
/* E_OP_STK_OVER */ "Expression too complex",
|
||||||
"Expression too complex - too many operands",
|
/* E_VA_STK_OVER */ "Expression too complex - too many operands",
|
||||||
"Missing ')'",
|
/* E_MISS_RIGHT_PAREN */ "Missing ')'",
|
||||||
"Undefined function",
|
/* E_UNDEF_FUNC */ "Undefined function",
|
||||||
"Illegal character",
|
/* E_ILLEGAL_CHAR */ "Illegal character",
|
||||||
"Expecting binary operator",
|
/* E_EXPECTING_BINOP */ "Expecting binary operator",
|
||||||
"Out of memory",
|
/* E_NO_MEM */ "Out of memory",
|
||||||
"Ill-formed number",
|
/* E_BAD_NUMBER */ "Ill-formed number",
|
||||||
"Op stack underflow - internal error",
|
/* E_OP_STK_UNDER */ "Op stack underflow - internal error",
|
||||||
"Va stack underflow - internal error",
|
/* E_VA_STK_UNDER */ "Va stack underflow - internal error",
|
||||||
"Can't coerce",
|
/* E_CANT_COERCE */ "Can't coerce",
|
||||||
"Type mismatch",
|
/* E_BAD_TYPE */ "Type mismatch",
|
||||||
"Date overflow",
|
/* E_DATE_OVER */ "Date overflow",
|
||||||
"Stack error - internal error",
|
/* E_STACK_ERR */ "Stack error - internal error",
|
||||||
"Division by zero",
|
/* E_DIV_ZERO */ "Division by zero",
|
||||||
"Undefined variable",
|
/* E_NOSUCH_VAR */ "Undefined variable",
|
||||||
"Unexpected end of line",
|
/* E_EOLN */ "Unexpected end of line",
|
||||||
"Unexpected end of file",
|
/* E_EOF */ "Unexpected end of file",
|
||||||
"I/O error",
|
/* E_IO_ERR */ "I/O error",
|
||||||
"Line too long",
|
/* E_LINE_2_LONG */ "Line too long",
|
||||||
"Internal error",
|
/* E_SWERR */ "Internal error",
|
||||||
"Bad date specification",
|
/* E_BAD_DATE */ "Bad date specification",
|
||||||
"Not enough arguments",
|
/* E_2FEW_ARGS */ "Not enough arguments",
|
||||||
"Too many arguments",
|
/* E_2MANY_ARGS */ "Too many arguments",
|
||||||
"Ill-formed time",
|
/* E_BAD_TIME */ "Ill-formed time",
|
||||||
"Number too high",
|
/* E_2HIGH */ "Number too high",
|
||||||
"Number too low",
|
/* E_2LOW */ "Number too low",
|
||||||
"Can't open file",
|
/* E_CANT_OPEN */ "Can't open file",
|
||||||
"INCLUDE nested too deeply",
|
/* E_NESTED_INCLUDE */ "INCLUDE nested too deeply (max. " STR(INCLUDE_NEST) ")",
|
||||||
"Parse error",
|
/* E_PARSE_ERR */ "Parse error",
|
||||||
"Can't compute trigger",
|
/* E_CANT_TRIG */ "Can't compute trigger",
|
||||||
"Too many nested IFs",
|
/* E_NESTED_IF */ "Too many nested IFs",
|
||||||
"ELSE with no matching IF",
|
/* E_ELSE_NO_IF */ "ELSE with no matching IF",
|
||||||
"ENDIF with no matching IF",
|
/* E_ENDIF_NO_IF */ "ENDIF with no matching IF",
|
||||||
"Can't OMIT every weekday",
|
/* E_2MANY_LOCALOMIT */ "Can't OMIT every weekday",
|
||||||
"Extraneous token(s) on line",
|
/* E_EXTRANEOUS_TOKEN */ "Extraneous token(s) on line",
|
||||||
"POP-OMIT-CONTEXT without matching PUSH-OMIT-CONTEXT",
|
/* E_POP_NO_PUSH */ "POP-OMIT-CONTEXT without matching PUSH-OMIT-CONTEXT",
|
||||||
"RUN disabled",
|
/* E_RUN_DISABLED */ "RUN disabled",
|
||||||
"Domain error",
|
/* E_DOMAIN_ERR */ "Domain error",
|
||||||
"Invalid identifier",
|
/* E_BAD_ID */ "Invalid identifier",
|
||||||
"Recursive function call detected",
|
/* E_RECURSIVE */ "Too many recursive function calls",
|
||||||
"",
|
/* E_PARSE_AS_REM */ "",
|
||||||
"Cannot modify system variable",
|
/* E_CANT_MODIFY */ "Cannot modify system variable",
|
||||||
"C library function can't represent date/time",
|
/* E_MKTIME_PROBLEM */ "C library function can't represent date/time",
|
||||||
"Attempt to redefine built-in function",
|
/* E_REDEF_FUNC */ "Attempt to redefine built-in function",
|
||||||
"Can't nest function definition in expression",
|
/* E_CANTNEST_FDEF */ "Can't nest function definition in expression",
|
||||||
"Must fully specify date to use repeat factor",
|
/* E_REP_FULSPEC */ "Must fully specify date to use repeat factor",
|
||||||
"Year specified twice",
|
/* E_YR_TWICE */ "Year specified twice",
|
||||||
"Month specified twice",
|
/* E_MON_TWICE */ "Month specified twice",
|
||||||
"Day specified twice",
|
/* E_DAY_TWICE */ "Day specified twice",
|
||||||
"Unknown token",
|
/* E_UNKNOWN_TOKEN */ "Unknown token",
|
||||||
"Must specify month in OMIT command",
|
/* E_SPEC_MON */ "Must specify month in OMIT command",
|
||||||
"Too many partial OMITs",
|
/* E_2MANY_PART */ "Too many partial OMITs (max. " STR(MAX_PARTIAL_OMITS) ")",
|
||||||
"Too many full OMITs",
|
/* E_2MANY_FULL */ "Too many full OMITs (max. " STR(MAX_FULL_OMITS) ")",
|
||||||
"Warning: PUSH-OMIT-CONTEXT without matching POP-OMIT-CONTEXT",
|
/* E_PUSH_NOPOP */ "Warning: PUSH-OMIT-CONTEXT without matching POP-OMIT-CONTEXT",
|
||||||
"Error reading",
|
/* E_ERR_READING */ "Error reading",
|
||||||
"Expecting end-of-line",
|
/* E_EXPECTING_EOL */ "Expecting end-of-line",
|
||||||
"Invalid Hebrew date",
|
/* E_BAD_HEBDATE */ "Invalid Hebrew date",
|
||||||
"IIF needs odd number of arguments",
|
/* E_IIF_ODD */ "IIF needs odd number of arguments",
|
||||||
"Warning: Missing ENDIF",
|
/* E_MISS_ENDIF */ "Warning: Missing ENDIF",
|
||||||
"Expecting comma",
|
/* E_EXPECT_COMMA */ "Expecting comma",
|
||||||
"Weekday specified twice",
|
/* E_WD_TWICE */ "Weekday specified twice",
|
||||||
"Only use one of BEFORE, AFTER or SKIP",
|
/* E_SKIP_ERR */ "Only use one of BEFORE, AFTER or SKIP",
|
||||||
"Can't nest MSG, MSF, RUN, etc. in expression",
|
/* E_CANT_NEST_RTYPE */ "Can't nest MSG, MSF, RUN, etc. in expression",
|
||||||
"Repeat value specified twice",
|
/* E_REP_TWICE */ "Repeat value specified twice",
|
||||||
"Delta value specified twice",
|
/* E_DELTA_TWICE */ "Delta value specified twice",
|
||||||
"Back value specified twice",
|
/* E_BACK_TWICE */ "Back value specified twice",
|
||||||
"ONCE keyword used twice. (Hah.)",
|
/* E_ONCE_TWICE */ "ONCE keyword used twice. (Hah.)",
|
||||||
"Expecting time after AT",
|
/* E_EXPECT_TIME */ "Expecting time after AT",
|
||||||
"THROUGH/UNTIL keyword used twice",
|
/* E_UNTIL_TWICE */ "THROUGH/UNTIL keyword used twice",
|
||||||
"Incomplete date specification",
|
/* E_INCOMPLETE */ "Incomplete date specification",
|
||||||
"FROM/SCANFROM keyword used twice",
|
/* E_SCAN_TWICE */ "FROM/SCANFROM keyword used twice",
|
||||||
"Variable",
|
/* E_VAR */ "Variable",
|
||||||
"Value",
|
/* E_VAL */ "Value",
|
||||||
"*UNDEFINED*",
|
/* E_UNDEF */ "*UNDEFINED*",
|
||||||
"Entering UserFN",
|
/* E_ENTER_FUN */ "Entering UserFN",
|
||||||
"Leaving UserFN",
|
/* E_LEAVE_FUN */ "Leaving UserFN",
|
||||||
"Expired",
|
/* E_EXPIRED */ "Expired",
|
||||||
"fork() failed - can't do queued reminders",
|
/* E_CANTFORK */ "fork() failed - can't do queued reminders",
|
||||||
"Can't access file",
|
/* E_CANTACCESS */ "Can't access file",
|
||||||
"Illegal system date: Year is less than %d\n",
|
/* M_BAD_SYS_DATE */ "Illegal system date: Year is less than %d\n",
|
||||||
"Unknown debug flag '%c'\n",
|
/* M_BAD_DB_FLAG */ "Unknown debug flag '%c'\n",
|
||||||
"Unknown option '%c'\n",
|
/* M_BAD_OPTION */ "Unknown option '%c'\n",
|
||||||
"Unknown user '%s'\n",
|
/* M_BAD_USER */ "Unknown user '%s'\n",
|
||||||
"Could not change gid to %d\n",
|
/* M_NO_CHG_GID */ "Could not change gid to %d\n",
|
||||||
"Could not change uid to %d\n",
|
/* M_NO_CHG_UID */ "Could not change uid to %d\n",
|
||||||
"Out of memory for environment\n",
|
/* M_NOMEM_ENV */ "Out of memory for environment\n",
|
||||||
"Missing '=' sign",
|
/* E_MISS_EQ */ "Missing '=' sign",
|
||||||
"Missing variable name",
|
/* E_MISS_VAR */ "Missing variable name",
|
||||||
"Missing expression",
|
/* E_MISS_EXPR */ "Missing expression",
|
||||||
"Can't reset access date of %s\n",
|
/* M_CANTSET_ACCESS */ "Can't reset access date of %s\n",
|
||||||
"Remind: '-i' option: %s\n",
|
/* M_I_OPTION */ "Remind: '-i' option: %s\n",
|
||||||
"No reminders.",
|
/* E_NOREMINDERS */ "No reminders.",
|
||||||
"%d reminder(s) queued for later today.\n",
|
/* M_QUEUED */ "%d reminder(s) queued for later today.\n",
|
||||||
"Expecting number",
|
/* E_EXPECTING_NUMBER */ "Expecting number",
|
||||||
"Bad function in WARN clause",
|
/* M_BAD_WARN_FUNC */ "Bad function in WARN clause",
|
||||||
"Can't convert between time zones",
|
/* E_CANT_CONVERT_TZ */ "Can't convert between time zones",
|
||||||
"No files matching *.rem",
|
/* E_NO_MATCHING_REMS */ "No files matching *.rem",
|
||||||
"String too long",
|
/* E_STRING_TOO_LONG */ "String too long",
|
||||||
"Time specified twice",
|
/* E_TIME_TWICE */ "Time specified twice",
|
||||||
"Cannot specify DURATION without specifying AT"
|
/* 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 */
|
#endif /* MK_GLOBALS */
|
||||||
;
|
;
|
||||||
|
|||||||
3621
src/expr.c
3621
src/expr.c
File diff suppressed because it is too large
Load Diff
65
src/expr.h
65
src/expr.h
@@ -1,65 +0,0 @@
|
|||||||
/***************************************************************/
|
|
||||||
/* */
|
|
||||||
/* EXPR.H */
|
|
||||||
/* */
|
|
||||||
/* Contains a few definitions used by expression evaluator. */
|
|
||||||
/* */
|
|
||||||
/* This file is part of REMIND. */
|
|
||||||
/* Copyright (C) 1992-2023 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 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);
|
|
||||||
|
|
||||||
40
src/files.c
40
src/files.c
@@ -7,7 +7,7 @@
|
|||||||
/* files. */
|
/* files. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -42,8 +42,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Convenient macros for closing files */
|
/* Convenient macros for closing files */
|
||||||
#define FCLOSE(fp) (((fp)&&((fp)!=stdin)) ? (fclose(fp),(fp)=NULL) : ((fp)=NULL))
|
#define FCLOSE(fp) ((((fp)!=stdin)) ? (fclose(fp),(fp)=NULL) : ((fp)=NULL))
|
||||||
#define PCLOSE(fp) (((fp)&&((fp)!=stdin)) ? (pclose(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 */
|
/* Define the structures needed by the file caching system */
|
||||||
typedef struct cache {
|
typedef struct cache {
|
||||||
@@ -79,6 +79,7 @@ typedef struct {
|
|||||||
int LineNo;
|
int LineNo;
|
||||||
unsigned int IfFlags;
|
unsigned int IfFlags;
|
||||||
int NumIfs;
|
int NumIfs;
|
||||||
|
int IfLinenos[IF_NEST];
|
||||||
long offset;
|
long offset;
|
||||||
CachedLine *CLine;
|
CachedLine *CLine;
|
||||||
int ownedByMe;
|
int ownedByMe;
|
||||||
@@ -100,6 +101,22 @@ static int CheckSafety (void);
|
|||||||
static int CheckSafetyAux (struct stat *statbuf);
|
static int CheckSafetyAux (struct stat *statbuf);
|
||||||
static int PopFile (void);
|
static int PopFile (void);
|
||||||
static int IncludeCmd(char const *);
|
static int IncludeCmd(char const *);
|
||||||
|
|
||||||
|
void set_cloexec(FILE *fp)
|
||||||
|
{
|
||||||
|
int flags;
|
||||||
|
int fd;
|
||||||
|
if (fp) {
|
||||||
|
fd = fileno(fp);
|
||||||
|
flags = fcntl(fd, F_GETFD);
|
||||||
|
if (flags >= 0) {
|
||||||
|
flags |= FD_CLOEXEC;
|
||||||
|
fcntl(fd, F_SETFD, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void OpenPurgeFile(char const *fname, char const *mode)
|
static void OpenPurgeFile(char const *fname, char const *mode)
|
||||||
{
|
{
|
||||||
DynamicBuffer fname_buf;
|
DynamicBuffer fname_buf;
|
||||||
@@ -123,6 +140,7 @@ static void OpenPurgeFile(char const *fname, char const *mode)
|
|||||||
if (!PurgeFP) {
|
if (!PurgeFP) {
|
||||||
fprintf(ErrFp, "Cannot open `%s' for writing: %s\n", DBufValue(&fname_buf), strerror(errno));
|
fprintf(ErrFp, "Cannot open `%s' for writing: %s\n", DBufValue(&fname_buf), strerror(errno));
|
||||||
}
|
}
|
||||||
|
set_cloexec(PurgeFP);
|
||||||
DBufFree(&fname_buf);
|
DBufFree(&fname_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,6 +345,7 @@ int OpenFile(char const *fname)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fp = fopen(fname, "r");
|
fp = fopen(fname, "r");
|
||||||
|
set_cloexec(fp);
|
||||||
if (DebugFlag & DB_TRACE_FILES) {
|
if (DebugFlag & DB_TRACE_FILES) {
|
||||||
fprintf(ErrFp, "Reading `%s': Opening file on disk\n", fname);
|
fprintf(ErrFp, "Reading `%s': Opening file on disk\n", fname);
|
||||||
}
|
}
|
||||||
@@ -346,6 +365,7 @@ int OpenFile(char const *fname)
|
|||||||
if (strcmp(fname, "-")) {
|
if (strcmp(fname, "-")) {
|
||||||
fp = fopen(fname, "r");
|
fp = fopen(fname, "r");
|
||||||
if (!fp || !CheckSafety()) return E_CANT_OPEN;
|
if (!fp || !CheckSafety()) return E_CANT_OPEN;
|
||||||
|
set_cloexec(fp);
|
||||||
if (PurgeMode) OpenPurgeFile(fname, "w");
|
if (PurgeMode) OpenPurgeFile(fname, "w");
|
||||||
} else {
|
} else {
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
@@ -507,8 +527,14 @@ static int NextChainedFile(IncludeStruct *i)
|
|||||||
static int PopFile(void)
|
static int PopFile(void)
|
||||||
{
|
{
|
||||||
IncludeStruct *i;
|
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;
|
if (!IStackPtr) return E_EOF;
|
||||||
i = &IStack[IStackPtr-1];
|
i = &IStack[IStackPtr-1];
|
||||||
|
|
||||||
@@ -528,6 +554,7 @@ static int PopFile(void)
|
|||||||
|
|
||||||
LineNo = i->LineNo;
|
LineNo = i->LineNo;
|
||||||
IfFlags = i->IfFlags;
|
IfFlags = i->IfFlags;
|
||||||
|
memcpy(IfLinenos, i->IfLinenos, IF_NEST);
|
||||||
NumIfs = i->NumIfs;
|
NumIfs = i->NumIfs;
|
||||||
CLine = i->CLine;
|
CLine = i->CLine;
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
@@ -542,6 +569,7 @@ static int PopFile(void)
|
|||||||
if (strcmp(i->filename, "-")) {
|
if (strcmp(i->filename, "-")) {
|
||||||
fp = fopen(i->filename, "r");
|
fp = fopen(i->filename, "r");
|
||||||
if (!fp || !CheckSafety()) return E_CANT_OPEN;
|
if (!fp || !CheckSafety()) return E_CANT_OPEN;
|
||||||
|
set_cloexec(fp);
|
||||||
if (PurgeMode) OpenPurgeFile(i->filename, "a");
|
if (PurgeMode) OpenPurgeFile(i->filename, "a");
|
||||||
} else {
|
} else {
|
||||||
fp = stdin;
|
fp = stdin;
|
||||||
@@ -851,6 +879,7 @@ static int IncludeCmd(char const *cmd)
|
|||||||
i->LineNo = LineNo;
|
i->LineNo = LineNo;
|
||||||
i->NumIfs = NumIfs;
|
i->NumIfs = NumIfs;
|
||||||
i->IfFlags = IfFlags;
|
i->IfFlags = IfFlags;
|
||||||
|
memcpy(i->IfLinenos, IfLinenos, IF_NEST);
|
||||||
i->CLine = CLine;
|
i->CLine = CLine;
|
||||||
i->offset = -1L;
|
i->offset = -1L;
|
||||||
i->chain = NULL;
|
i->chain = NULL;
|
||||||
@@ -953,6 +982,7 @@ int IncludeFile(char const *fname)
|
|||||||
i->LineNo = LineNo;
|
i->LineNo = LineNo;
|
||||||
i->NumIfs = NumIfs;
|
i->NumIfs = NumIfs;
|
||||||
i->IfFlags = IfFlags;
|
i->IfFlags = IfFlags;
|
||||||
|
memcpy(i->IfLinenos, IfLinenos, IF_NEST);
|
||||||
i->CLine = CLine;
|
i->CLine = CLine;
|
||||||
i->offset = -1L;
|
i->offset = -1L;
|
||||||
i->chain = NULL;
|
i->chain = NULL;
|
||||||
|
|||||||
981
src/funcs.c
981
src/funcs.c
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
|||||||
/* globals.h and err.h */
|
/* globals.h and err.h */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#define INIT(var, val) var
|
#define INIT(var, val) var
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -39,7 +40,7 @@ EXTERN FILE *ErrFp;
|
|||||||
#define IsLeapYear(y) (((y) % 4) ? 0 : ((!((y) % 100) && ((y) % 400)) ? 0 : 1 ))
|
#define IsLeapYear(y) (((y) % 4) ? 0 : ((!((y) % 100) && ((y) % 400)) ? 0 : 1 ))
|
||||||
#define DaysInMonth(m, y) ((m) != 1 ? MonthDays[m] : 28 + IsLeapYear(y))
|
#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).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 DSEToday;
|
||||||
EXTERN int RealToday;
|
EXTERN int RealToday;
|
||||||
@@ -50,8 +51,10 @@ EXTERN int LineNo;
|
|||||||
EXTERN int FreshLine;
|
EXTERN int FreshLine;
|
||||||
EXTERN uid_t TrustedUsers[MAX_TRUSTED_USERS];
|
EXTERN uid_t TrustedUsers[MAX_TRUSTED_USERS];
|
||||||
|
|
||||||
|
EXTERN INIT( int MaxLateMinutes, 0);
|
||||||
EXTERN INIT( int NumTrustedUsers, 0);
|
EXTERN INIT( int NumTrustedUsers, 0);
|
||||||
EXTERN INIT( char const *MsgCommand, NULL);
|
EXTERN INIT( char const *MsgCommand, NULL);
|
||||||
|
EXTERN INIT( char const *QueuedMsgCommand, NULL);
|
||||||
EXTERN INIT( int ShowAllErrors, 0);
|
EXTERN INIT( int ShowAllErrors, 0);
|
||||||
EXTERN INIT( int DebugFlag, 0);
|
EXTERN INIT( int DebugFlag, 0);
|
||||||
EXTERN INIT( int DoCalendar, 0);
|
EXTERN INIT( int DoCalendar, 0);
|
||||||
@@ -69,15 +72,19 @@ EXTERN INIT( int Hush, 0);
|
|||||||
EXTERN INIT( int NextMode, 0);
|
EXTERN INIT( int NextMode, 0);
|
||||||
EXTERN INIT( int InfiniteDelta, 0);
|
EXTERN INIT( int InfiniteDelta, 0);
|
||||||
EXTERN INIT( int DefaultTDelta, 0);
|
EXTERN INIT( int DefaultTDelta, 0);
|
||||||
EXTERN INIT( int DeltaOffset, 0);
|
EXTERN INIT( int DeltaOverride, 0);
|
||||||
EXTERN INIT( int RunDisabled, 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 IgnoreOnce, 0);
|
||||||
EXTERN INIT( int SortByTime, 0);
|
EXTERN INIT( int SortByTime, 0);
|
||||||
EXTERN INIT( int SortByDate, 0);
|
EXTERN INIT( int SortByDate, 0);
|
||||||
EXTERN INIT( int SortByPrio, 0);
|
EXTERN INIT( int SortByPrio, 0);
|
||||||
EXTERN INIT( int UntimedBeforeTimed, 0);
|
EXTERN INIT( int UntimedBeforeTimed, 0);
|
||||||
EXTERN INIT( int DefaultPrio, NO_PRIORITY);
|
EXTERN INIT( int DefaultPrio, NO_PRIORITY);
|
||||||
EXTERN INIT( long SysTime, -1L);
|
EXTERN INIT( int SysTime, -1);
|
||||||
|
EXTERN INIT( int ParseUntriggered, 1);
|
||||||
|
|
||||||
EXTERN char const *InitialFile;
|
EXTERN char const *InitialFile;
|
||||||
EXTERN int FileAccessDate;
|
EXTERN int FileAccessDate;
|
||||||
@@ -89,6 +96,7 @@ EXTERN INIT( int DontQueue, 0);
|
|||||||
EXTERN INIT( int NumQueued, 0);
|
EXTERN INIT( int NumQueued, 0);
|
||||||
EXTERN INIT( int DontIssueAts, 0);
|
EXTERN INIT( int DontIssueAts, 0);
|
||||||
EXTERN INIT( int Daemon, 0);
|
EXTERN INIT( int Daemon, 0);
|
||||||
|
EXTERN INIT( int DaemonJSON, 0);
|
||||||
EXTERN INIT( char DateSep, DATESEP);
|
EXTERN INIT( char DateSep, DATESEP);
|
||||||
EXTERN INIT( char TimeSep, TIMESEP);
|
EXTERN INIT( char TimeSep, TIMESEP);
|
||||||
EXTERN INIT( char DateTimeSep, DATETIMESEP);
|
EXTERN INIT( char DateTimeSep, DATETIMESEP);
|
||||||
@@ -99,18 +107,19 @@ EXTERN INIT( int SynthesizeTags, 0);
|
|||||||
EXTERN INIT( int ScFormat, SC_AMPM);
|
EXTERN INIT( int ScFormat, SC_AMPM);
|
||||||
EXTERN INIT( int MaxSatIter, 1000);
|
EXTERN INIT( int MaxSatIter, 1000);
|
||||||
EXTERN INIT( int MaxStringLen, MAX_STR_LEN);
|
EXTERN INIT( int MaxStringLen, MAX_STR_LEN);
|
||||||
EXTERN INIT( char *FileName, NULL);
|
EXTERN INIT( char *FileName, NULL);
|
||||||
EXTERN INIT( int UseStdin, 0);
|
EXTERN INIT( int UseStdin, 0);
|
||||||
EXTERN INIT( int PurgeMode, 0);
|
EXTERN INIT( int PurgeMode, 0);
|
||||||
EXTERN INIT( int PurgeIncludeDepth, 0);
|
EXTERN INIT( int PurgeIncludeDepth, 0);
|
||||||
EXTERN INIT( FILE *PurgeFP, NULL);
|
EXTERN INIT( FILE *PurgeFP, NULL);
|
||||||
EXTERN INIT( int NumIfs, 0);
|
EXTERN INIT( int NumIfs, 0);
|
||||||
EXTERN INIT( unsigned int IfFlags, 0);
|
EXTERN INIT( unsigned int IfFlags, 0);
|
||||||
|
EXTERN INIT( int IfLinenos[IF_NEST], {0});
|
||||||
EXTERN INIT( int LastTrigValid, 0);
|
EXTERN INIT( int LastTrigValid, 0);
|
||||||
EXTERN Trigger LastTrigger;
|
EXTERN Trigger LastTrigger;
|
||||||
EXTERN TimeTrig LastTimeTrig;
|
EXTERN TimeTrig LastTimeTrig;
|
||||||
EXTERN INIT( int LastTriggerDate, 0);
|
EXTERN INIT( int LastTriggerDate, 0);
|
||||||
EXTERN INIT( int LastTriggerTime, 0);
|
EXTERN INIT( int LastTriggerTime, NO_TIME);
|
||||||
EXTERN INIT( int ShouldCache, 0);
|
EXTERN INIT( int ShouldCache, 0);
|
||||||
EXTERN char const *CurLine;
|
EXTERN char const *CurLine;
|
||||||
EXTERN INIT( int NumTriggered, 0);
|
EXTERN INIT( int NumTriggered, 0);
|
||||||
@@ -154,6 +163,12 @@ EXTERN INIT( char *EndSentIg, "\"')]}>");
|
|||||||
EXTERN DynamicBuffer Banner;
|
EXTERN DynamicBuffer Banner;
|
||||||
EXTERN DynamicBuffer LineBuffer;
|
EXTERN DynamicBuffer LineBuffer;
|
||||||
EXTERN DynamicBuffer ExprBuf;
|
EXTERN DynamicBuffer ExprBuf;
|
||||||
|
|
||||||
|
/* User-func recursion level */
|
||||||
|
EXTERN INIT( unsigned int FuncRecursionLevel, 0);
|
||||||
|
|
||||||
|
extern int NumFullOmits, NumPartialOmits;
|
||||||
|
|
||||||
/* List of months */
|
/* List of months */
|
||||||
EXTERN char *EnglishMonthName[]
|
EXTERN char *EnglishMonthName[]
|
||||||
#ifdef MK_GLOBALS
|
#ifdef MK_GLOBALS
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/* Support for the Hebrew calendar */
|
/* Support for the Hebrew calendar */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/* Derived from code written by Amos Shapir in 1978; revised */
|
/* Derived from code written by Amos Shapir in 1978; revised */
|
||||||
@@ -20,6 +20,12 @@
|
|||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define HOUR 1080L
|
#define HOUR 1080L
|
||||||
#define DAY (24L*HOUR)
|
#define DAY (24L*HOUR)
|
||||||
#define WEEK (7L*DAY)
|
#define WEEK (7L*DAY)
|
||||||
|
|||||||
308
src/init.c
308
src/init.c
@@ -7,7 +7,7 @@
|
|||||||
/* in normal mode. */
|
/* in normal mode. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -19,16 +19,17 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <poll.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
#ifdef HAVE_INITGROUPS
|
#ifdef HAVE_INITGROUPS
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
@@ -37,9 +38,16 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "expr.h"
|
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
|
|
||||||
|
static int should_guess_terminal_background = 1;
|
||||||
|
|
||||||
|
static void guess_terminal_background(int *r, int *g, int *b);
|
||||||
|
static int tty_init(int fd);
|
||||||
|
static void tty_raw(int fd);
|
||||||
|
static void tty_reset(int fd);
|
||||||
|
|
||||||
|
static void ProcessLongOption(char const *arg);
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
*
|
*
|
||||||
* Command line options recognized:
|
* Command line options recognized:
|
||||||
@@ -69,6 +77,7 @@
|
|||||||
* t = Display trigger dates
|
* t = Display trigger dates
|
||||||
* v = Dump variables at end
|
* v = Dump variables at end
|
||||||
* l = Display entire line in error messages
|
* 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
|
* -e = Send messages normally sent to stderr to stdout instead
|
||||||
* -z[n] = Daemon mode waking up every n (def 1) minutes.
|
* -z[n] = Daemon mode waking up every n (def 1) minutes.
|
||||||
* -bn = Time format for cal (0, 1, or 2)
|
* -bn = Time format for cal (0, 1, or 2)
|
||||||
@@ -219,7 +228,7 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Invoked with a NULL argv[0]; bailing because that's just plain bizarre.\n");
|
fprintf(stderr, "Invoked with a NULL argv[0]; bailing because that's just plain bizarre.\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the command-line options */
|
/* Parse the command-line options */
|
||||||
@@ -243,6 +252,11 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
while(*arg) arg++;
|
while(*arg) arg++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case '-':
|
||||||
|
ProcessLongOption(arg);
|
||||||
|
while(*arg) arg++;
|
||||||
|
break;
|
||||||
|
|
||||||
case '@':
|
case '@':
|
||||||
UseVTColors = 1;
|
UseVTColors = 1;
|
||||||
if (*arg) {
|
if (*arg) {
|
||||||
@@ -259,16 +273,24 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
if (*arg == ',') {
|
if (*arg == ',') {
|
||||||
arg++;
|
arg++;
|
||||||
if (*arg != ',') {
|
if (*arg != ',') {
|
||||||
PARSENUM(x, arg);
|
if (*arg == 't') {
|
||||||
if (x == 0) {
|
arg++;
|
||||||
TerminalBackground = TERMINAL_BACKGROUND_DARK;
|
should_guess_terminal_background = 2;
|
||||||
} else if (x == 1) {
|
|
||||||
TerminalBackground = TERMINAL_BACKGROUND_LIGHT;
|
|
||||||
} else if (x == 2) {
|
|
||||||
TerminalBackground = TERMINAL_BACKGROUND_UNKNOWN;
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(ErrFp, "%s: -@n,m,b: m must be 0, 1 or 2 (assuming 2)\n",
|
PARSENUM(x, arg);
|
||||||
argv[0]);
|
if (x == 0) {
|
||||||
|
should_guess_terminal_background = 0;
|
||||||
|
TerminalBackground = TERMINAL_BACKGROUND_DARK;
|
||||||
|
} else if (x == 1) {
|
||||||
|
should_guess_terminal_background = 0;
|
||||||
|
TerminalBackground = TERMINAL_BACKGROUND_LIGHT;
|
||||||
|
} else if (x == 2) {
|
||||||
|
should_guess_terminal_background = 0;
|
||||||
|
TerminalBackground = TERMINAL_BACKGROUND_UNKNOWN;
|
||||||
|
} else {
|
||||||
|
fprintf(ErrFp, "%s: -@n,m,b: m must be t, 0, 1 or 2 (assuming 2)\n",
|
||||||
|
argv[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,10 +363,15 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
} else if (!*arg) {
|
} else if (!*arg) {
|
||||||
InfiniteDelta = 1;
|
InfiniteDelta = 1;
|
||||||
} else {
|
} else {
|
||||||
PARSENUM(DeltaOffset, arg);
|
if (*arg == 'z') {
|
||||||
if (DeltaOffset < 0) {
|
DeltaOverride = -1;
|
||||||
DeltaOffset = 0;
|
arg++;
|
||||||
}
|
} else {
|
||||||
|
PARSENUM(DeltaOverride, arg);
|
||||||
|
if (DeltaOverride < 0) {
|
||||||
|
DeltaOverride = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
@@ -398,7 +425,11 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
case 'z':
|
case 'z':
|
||||||
case 'Z':
|
case 'Z':
|
||||||
DontFork = 1;
|
DontFork = 1;
|
||||||
if (*arg == '0') {
|
if (*arg == 'j' || *arg == 'J') {
|
||||||
|
while (*arg) arg++;
|
||||||
|
Daemon = -1;
|
||||||
|
DaemonJSON = 1;
|
||||||
|
} else if (*arg == '0') {
|
||||||
PARSENUM(Daemon, arg);
|
PARSENUM(Daemon, arg);
|
||||||
if (Daemon == 0) Daemon = -1;
|
if (Daemon == 0) Daemon = -1;
|
||||||
else if (Daemon < 1) Daemon = 1;
|
else if (Daemon < 1) Daemon = 1;
|
||||||
@@ -532,7 +563,7 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
arg++;
|
arg++;
|
||||||
/* -wt means get width from /dev/tty */
|
/* -wt means get width from /dev/tty */
|
||||||
ttyfd = open("/dev/tty", O_RDONLY);
|
ttyfd = open("/dev/tty", O_RDONLY);
|
||||||
if (!ttyfd) {
|
if (ttyfd < 0) {
|
||||||
fprintf(stderr, "%s: `-wt': Cannot open /dev/tty: %s\n",
|
fprintf(stderr, "%s: `-wt': Cannot open /dev/tty: %s\n",
|
||||||
argv[0], strerror(errno));
|
argv[0], strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
@@ -543,7 +574,12 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
PARSENUM(CalWidth, arg);
|
PARSENUM(CalWidth, arg);
|
||||||
if (CalWidth != 0 && CalWidth < 71) CalWidth = 71;
|
if (CalWidth != 0 && CalWidth < 71) CalWidth = 71;
|
||||||
if (CalWidth == 0) {
|
if (CalWidth == 0) {
|
||||||
CalWidth = -1;
|
/* Cal width of 0 means obtain from stdout */
|
||||||
|
if (isatty(STDOUT_FILENO)) {
|
||||||
|
InitCalWidthAndFormWidth(STDOUT_FILENO);
|
||||||
|
} else {
|
||||||
|
CalWidth = 80;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FormWidth = CalWidth - 8;
|
FormWidth = CalWidth - 8;
|
||||||
if (FormWidth < 20) FormWidth = 20;
|
if (FormWidth < 20) FormWidth = 20;
|
||||||
@@ -568,6 +604,7 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
case 'D':
|
case 'D':
|
||||||
while (*arg) {
|
while (*arg) {
|
||||||
switch(*arg++) {
|
switch(*arg++) {
|
||||||
|
case 's': case 'S': DebugFlag |= DB_PARSE_EXPR; break;
|
||||||
case 'e': case 'E': DebugFlag |= DB_ECHO_LINE; break;
|
case 'e': case 'E': DebugFlag |= DB_ECHO_LINE; break;
|
||||||
case 'x': case 'X': DebugFlag |= DB_PRTEXPR; break;
|
case 'x': case 'X': DebugFlag |= DB_PRTEXPR; break;
|
||||||
case 't': case 'T': DebugFlag |= DB_PRTTRIG; break;
|
case 't': case 'T': DebugFlag |= DB_PRTTRIG; break;
|
||||||
@@ -600,7 +637,12 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
case 'K':
|
case 'K':
|
||||||
MsgCommand = arg;
|
if (*arg == ':') {
|
||||||
|
arg++;
|
||||||
|
QueuedMsgCommand = arg;
|
||||||
|
} else {
|
||||||
|
MsgCommand = arg;
|
||||||
|
}
|
||||||
while (*arg) arg++; /* Chew up remaining chars in this arg */
|
while (*arg) arg++; /* Chew up remaining chars in this arg */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -716,7 +758,7 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
|
|
||||||
/* Figure out the offset from UTC */
|
/* Figure out the offset from UTC */
|
||||||
if (CalculateUTC)
|
if (CalculateUTC)
|
||||||
(void) CalcMinsFromUTC(DSEToday, SystemTime(0)/60,
|
(void) CalcMinsFromUTC(DSEToday, MinutesPastMidnight(0),
|
||||||
&MinsFromUTC, NULL);
|
&MinsFromUTC, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,7 +772,7 @@ void InitRemind(int argc, char const *argv[])
|
|||||||
#ifndef L_USAGE_OVERRIDE
|
#ifndef L_USAGE_OVERRIDE
|
||||||
void Usage(void)
|
void Usage(void)
|
||||||
{
|
{
|
||||||
fprintf(ErrFp, "\nREMIND %s (%s version) Copyright 1992-2023 Dianne Skoll\n", VERSION, L_LANGNAME);
|
fprintf(ErrFp, "\nREMIND %s (%s version) Copyright 1992-2024 Dianne Skoll\n", VERSION, L_LANGNAME);
|
||||||
#ifdef BETA
|
#ifdef BETA
|
||||||
fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
|
fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -763,6 +805,7 @@ void Usage(void)
|
|||||||
fprintf(ErrFp, " -m Start calendar with Monday rather than Sunday\n");
|
fprintf(ErrFp, " -m Start calendar with Monday rather than Sunday\n");
|
||||||
fprintf(ErrFp, " -y Synthesize tags for tagless reminders\n");
|
fprintf(ErrFp, " -y Synthesize tags for tagless reminders\n");
|
||||||
fprintf(ErrFp, " -j[n] Run in 'purge' mode. [n = INCLUDE depth]\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);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#endif /* L_USAGE_OVERRIDE */
|
#endif /* L_USAGE_OVERRIDE */
|
||||||
@@ -882,7 +925,12 @@ static void InitializeVar(char const *str)
|
|||||||
r = 0;
|
r = 0;
|
||||||
while (*str && *str != '=') {
|
while (*str && *str != '=') {
|
||||||
if (r < VAR_NAME_LEN) {
|
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 == '(') {
|
if (*str == '(') {
|
||||||
/* Do a function definition if we see a paren */
|
/* Do a function definition if we see a paren */
|
||||||
@@ -892,10 +940,28 @@ static void InitializeVar(char const *str)
|
|||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
varname[r] = 0;
|
varname[r] = 0;
|
||||||
if (!*str) {
|
if (!*varname) {
|
||||||
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_EQ]);
|
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_VAR]);
|
||||||
return;
|
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) {
|
if (!*varname) {
|
||||||
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_VAR]);
|
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_VAR]);
|
||||||
return;
|
return;
|
||||||
@@ -948,3 +1014,191 @@ AddTrustedUser(char const *username)
|
|||||||
NumTrustedUsers++;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
guess_terminal_background(int *r, int *g, int *b)
|
||||||
|
{
|
||||||
|
int ttyfd;
|
||||||
|
struct pollfd p;
|
||||||
|
unsigned int rr, gg, bb;
|
||||||
|
char buf[128];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
*r = -1;
|
||||||
|
*g = -1;
|
||||||
|
*b = -1;
|
||||||
|
|
||||||
|
/* Don't guess if stdout not a terminal unless asked to by @,t */
|
||||||
|
if (should_guess_terminal_background != 2) {
|
||||||
|
if (!isatty(STDOUT_FILENO)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ttyfd = open("/dev/tty", O_RDWR);
|
||||||
|
if (ttyfd < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isatty(ttyfd)) {
|
||||||
|
/* Not a TTY: Can't guess the color */
|
||||||
|
close(ttyfd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tty_init(ttyfd)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tty_raw(ttyfd);
|
||||||
|
n = write(ttyfd, "\033]11;?\033\\", 8);
|
||||||
|
|
||||||
|
if (n != 8) {
|
||||||
|
/* write failed... WTF? Not much we can do */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait up to 0.1s for terminal to respond */
|
||||||
|
p.fd = ttyfd;
|
||||||
|
p.events = POLLIN;
|
||||||
|
if (poll(&p, 1, 100) < 0) {
|
||||||
|
tty_reset(ttyfd);
|
||||||
|
close(ttyfd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!(p.revents & POLLIN)) {
|
||||||
|
tty_reset(ttyfd);
|
||||||
|
close(ttyfd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
n = read(ttyfd, buf, 127);
|
||||||
|
if (n <= 0) {
|
||||||
|
tty_reset(ttyfd);
|
||||||
|
close(ttyfd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tty_reset(ttyfd);
|
||||||
|
buf[n+1] = 0;
|
||||||
|
if (n < 25) {
|
||||||
|
/* Too short */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sscanf(buf+5, "rgb:%x/%x/%x", &rr, &gg, &bb) != 3) {
|
||||||
|
/* Couldn't scan color codes */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*r = (int) ((rr >> 8) & 255);
|
||||||
|
*g = (int) ((gg >> 8) & 255);
|
||||||
|
*b = (int) ((bb >> 8) & 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct termios orig_termios;
|
||||||
|
|
||||||
|
static int
|
||||||
|
tty_init(int fd)
|
||||||
|
{
|
||||||
|
if (tcgetattr(fd, &orig_termios) < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tty_raw(int fd)
|
||||||
|
{
|
||||||
|
struct termios raw;
|
||||||
|
|
||||||
|
raw = orig_termios;
|
||||||
|
|
||||||
|
raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
|
||||||
|
raw.c_oflag &= ~(OPOST);
|
||||||
|
raw.c_cflag |= (CS8);
|
||||||
|
raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
|
||||||
|
|
||||||
|
/* put terminal in raw mode after flushing */
|
||||||
|
tcsetattr(fd,TCSAFLUSH,&raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tty_reset(int fd)
|
||||||
|
{
|
||||||
|
tcsetattr(fd, TCSAFLUSH, &orig_termios);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
GetTerminalBackground(void)
|
||||||
|
{
|
||||||
|
int r, g, b;
|
||||||
|
if (should_guess_terminal_background) {
|
||||||
|
guess_terminal_background(&r, &g, &b);
|
||||||
|
if (r >= 0 && g >= 0 && b >= 0) {
|
||||||
|
if (r+g+b <= 85*3 && r <= 128 && g <= 128 && b <= 128) {
|
||||||
|
TerminalBackground = TERMINAL_BACKGROUND_DARK;
|
||||||
|
} else {
|
||||||
|
TerminalBackground = TERMINAL_BACKGROUND_LIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
should_guess_terminal_background = 0;
|
||||||
|
}
|
||||||
|
return TerminalBackground;
|
||||||
|
}
|
||||||
|
|||||||
44
src/json.c
44
src/json.c
@@ -249,7 +249,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
const json_char * end;
|
const json_char * end;
|
||||||
json_value * top, * root, * alloc = 0;
|
json_value * top, * root, * alloc = 0;
|
||||||
json_state state = { 0 };
|
json_state state = { 0 };
|
||||||
long flags = 0;
|
long flags;
|
||||||
double num_digits = 0, num_e = 0;
|
double num_digits = 0, num_e = 0;
|
||||||
double num_fraction = 0;
|
double num_fraction = 0;
|
||||||
|
|
||||||
@@ -299,7 +299,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
if (flags & flag_string)
|
if (flags & flag_string)
|
||||||
{
|
{
|
||||||
if (!b)
|
if (!b)
|
||||||
{ sprintf (error, "Unexpected EOF in string (at %d:%d)", line_and_col);
|
{ sprintf (error, "Unexpected EOF in string (at %u:%u)", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
(uc_b3 = hex_value (*++ state.ptr)) == 0xFF ||
|
(uc_b3 = hex_value (*++ state.ptr)) == 0xFF ||
|
||||||
(uc_b4 = hex_value (*++ state.ptr)) == 0xFF)
|
(uc_b4 = hex_value (*++ state.ptr)) == 0xFF)
|
||||||
{
|
{
|
||||||
sprintf (error, "Invalid character value `%c` (at %d:%d)", b, line_and_col);
|
sprintf (error, "Invalid character value `%c` (at %u:%u)", b, line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
(uc_b3 = hex_value (*++ state.ptr)) == 0xFF ||
|
(uc_b3 = hex_value (*++ state.ptr)) == 0xFF ||
|
||||||
(uc_b4 = hex_value (*++ state.ptr)) == 0xFF)
|
(uc_b4 = hex_value (*++ state.ptr)) == 0xFF)
|
||||||
{
|
{
|
||||||
sprintf (error, "Invalid character value `%c` (at %d:%d)", b, line_and_col);
|
sprintf (error, "Invalid character value `%c` (at %u:%u)", b, line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,7 +472,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
if (flags & flag_block_comment)
|
if (flags & flag_block_comment)
|
||||||
{
|
{
|
||||||
if (!b)
|
if (!b)
|
||||||
{ sprintf (error, "%d:%d: Unexpected EOF in block comment", line_and_col);
|
{ sprintf (error, "%u:%u: Unexpected EOF in block comment", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -488,12 +488,12 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
else if (b == '/')
|
else if (b == '/')
|
||||||
{
|
{
|
||||||
if (! (flags & (flag_seek_value | flag_done)) && top->type != json_object)
|
if (! (flags & (flag_seek_value | flag_done)) && top->type != json_object)
|
||||||
{ sprintf (error, "%d:%d: Comment not allowed here", line_and_col);
|
{ sprintf (error, "%u:%u: Comment not allowed here", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++ state.ptr == end)
|
if (++ state.ptr == end)
|
||||||
{ sprintf (error, "%d:%d: EOF unexpected", line_and_col);
|
{ sprintf (error, "%u:%u: EOF unexpected", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +508,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sprintf (error, "%d:%d: Unexpected `%c` in comment opening sequence", line_and_col, b);
|
sprintf (error, "%u:%u: Unexpected `%c` in comment opening sequence", line_and_col, b);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -526,7 +526,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
sprintf (error, "%d:%d: Trailing garbage: `%c`",
|
sprintf (error, "%u:%u: Trailing garbage: `%c`",
|
||||||
state.cur_line, state.cur_col, b);
|
state.cur_line, state.cur_col, b);
|
||||||
|
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
@@ -545,7 +545,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
if (top && top->type == json_array)
|
if (top && top->type == json_array)
|
||||||
flags = (flags & ~ (flag_need_comma | flag_seek_value)) | flag_next;
|
flags = (flags & ~ (flag_need_comma | flag_seek_value)) | flag_next;
|
||||||
else
|
else
|
||||||
{ sprintf (error, "%d:%d: Unexpected ]", line_and_col);
|
{ sprintf (error, "%u:%u: Unexpected ]", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +561,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf (error, "%d:%d: Expected , before %c",
|
sprintf (error, "%u:%u: Expected , before %c",
|
||||||
state.cur_line, state.cur_col, b);
|
state.cur_line, state.cur_col, b);
|
||||||
|
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
@@ -576,7 +576,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf (error, "%d:%d: Expected : before %c",
|
sprintf (error, "%u:%u: Expected : before %c",
|
||||||
state.cur_line, state.cur_col, b);
|
state.cur_line, state.cur_col, b);
|
||||||
|
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
@@ -702,7 +702,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ sprintf (error, "%d:%d: Unexpected %c when seeking value", line_and_col, b);
|
{ sprintf (error, "%u:%u: Unexpected %c when seeking value", line_and_col, b);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -722,7 +722,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
case '"':
|
case '"':
|
||||||
|
|
||||||
if (flags & flag_need_comma)
|
if (flags & flag_need_comma)
|
||||||
{ sprintf (error, "%d:%d: Expected , before \"", line_and_col);
|
{ sprintf (error, "%u:%u: Expected , before \"", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -747,7 +747,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
default:
|
default:
|
||||||
sprintf (error, "%d:%d: Unexpected `%c` in object", line_and_col, b);
|
sprintf (error, "%u:%u: Unexpected `%c` in object", line_and_col, b);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -765,7 +765,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
if (! (flags & flag_num_e))
|
if (! (flags & flag_num_e))
|
||||||
{
|
{
|
||||||
if (flags & flag_num_zero)
|
if (flags & flag_num_zero)
|
||||||
{ sprintf (error, "%d:%d: Unexpected `0` before `%c`", line_and_col, b);
|
{ sprintf (error, "%u:%u: Unexpected `0` before `%c`", line_and_col, b);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -814,7 +814,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
else if (b == '.' && top->type == json_integer)
|
else if (b == '.' && top->type == json_integer)
|
||||||
{
|
{
|
||||||
if (!num_digits)
|
if (!num_digits)
|
||||||
{ sprintf (error, "%d:%d: Expected digit before `.`", line_and_col);
|
{ sprintf (error, "%u:%u: Expected digit before `.`", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -831,7 +831,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
if (top->type == json_double)
|
if (top->type == json_double)
|
||||||
{
|
{
|
||||||
if (!num_digits)
|
if (!num_digits)
|
||||||
{ sprintf (error, "%d:%d: Expected digit after `.`", line_and_col);
|
{ sprintf (error, "%u:%u: Expected digit after `.`", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,11 +857,11 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!num_digits)
|
if (!num_digits)
|
||||||
{ sprintf (error, "%d:%d: Expected digit after `e`", line_and_col);
|
{ sprintf (error, "%u:%u: Expected digit after `e`", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
top->u.dbl *= pow (10.0, (flags & flag_num_e_negative ? - num_e : num_e));
|
top->u.dbl *= pow (10.0, ((flags & flag_num_e_negative) ? - num_e : num_e));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & flag_num_negative)
|
if (flags & flag_num_negative)
|
||||||
@@ -942,7 +942,7 @@ json_value * json_parse_ex (json_settings * settings,
|
|||||||
|
|
||||||
e_unknown_value:
|
e_unknown_value:
|
||||||
|
|
||||||
sprintf (error, "%d:%d: Unknown value", line_and_col);
|
sprintf (error, "%u:%u: Unknown value", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
|
|
||||||
e_alloc_failure:
|
e_alloc_failure:
|
||||||
@@ -952,7 +952,7 @@ e_alloc_failure:
|
|||||||
|
|
||||||
e_overflow:
|
e_overflow:
|
||||||
|
|
||||||
sprintf (error, "%d:%d: Too long (caught overflow)", line_and_col);
|
sprintf (error, "%u:%u: Too long (caught overflow)", line_and_col);
|
||||||
goto e_failed;
|
goto e_failed;
|
||||||
|
|
||||||
e_failed:
|
e_failed:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/* Header file for language support for various languages. */
|
/* Header file for language support for various languages. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* */
|
/* */
|
||||||
/* REMIND is Copyright (C) 1992-2023 by Dianne Skoll */
|
/* REMIND is Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* This file is Copyright (C) 1993 by Mogens Lynnerup. */
|
/* This file is Copyright (C) 1993 by Mogens Lynnerup. */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
/* Further corrections by Erik-Jan Vens */
|
/* Further corrections by Erik-Jan Vens */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/* Support for the English language. */
|
/* Support for the English language. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* This file is Copyright (C) 1993-1998 by Mikko Silvonen. */
|
/* This file is Copyright (C) 1993-1998 by Mikko Silvonen. */
|
||||||
/* REMIND is Copyright (C) 1992-2023 by Dianne Skoll */
|
/* REMIND is Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -145,7 +145,7 @@ EXTERN char *ErrMsg[] =
|
|||||||
"Ok",
|
"Ok",
|
||||||
"Puuttuva ']'",
|
"Puuttuva ']'",
|
||||||
"Puuttuva lainausmerkki",
|
"Puuttuva lainausmerkki",
|
||||||
"Liian monimutkainen lauseke - liikaa operaattoreita",
|
"Liian monimutkainen lauseke",
|
||||||
"Liian monimutkainen lauseke - liikaa operandeja",
|
"Liian monimutkainen lauseke - liikaa operandeja",
|
||||||
"Puuttuva ')'",
|
"Puuttuva ')'",
|
||||||
"Määrittelemätön funktio",
|
"Määrittelemätön funktio",
|
||||||
@@ -245,7 +245,11 @@ EXTERN char *ErrMsg[] =
|
|||||||
"No files matching *.rem",
|
"No files matching *.rem",
|
||||||
"String too long",
|
"String too long",
|
||||||
"Time specified twice",
|
"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 */
|
#endif /* MK_GLOBALS */
|
||||||
|
|
||||||
@@ -254,7 +258,7 @@ EXTERN char *ErrMsg[] =
|
|||||||
#define L_USAGE_OVERRIDE 1
|
#define L_USAGE_OVERRIDE 1
|
||||||
void Usage(void)
|
void Usage(void)
|
||||||
{
|
{
|
||||||
fprintf(ErrFp, "\nREMIND %s (%s version) Copyright 1992-2023 Dianne Skoll\n", VERSION, L_LANGNAME);
|
fprintf(ErrFp, "\nREMIND %s (%s version) Copyright 1992-2024 Dianne Skoll\n", VERSION, L_LANGNAME);
|
||||||
#ifdef BETA
|
#ifdef BETA
|
||||||
fprintf(ErrFp, ">>>> BETAVERSIO <<<<\n");
|
fprintf(ErrFp, ">>>> BETAVERSIO <<<<\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -271,12 +275,10 @@ void Usage(void)
|
|||||||
fprintf(ErrFp, " -o Älä noudata ONCE-lauseita\n");
|
fprintf(ErrFp, " -o Älä noudata ONCE-lauseita\n");
|
||||||
fprintf(ErrFp, " -t Laukaise kaikki viestit deltan arvosta välittämättä\n");
|
fprintf(ErrFp, " -t Laukaise kaikki viestit deltan arvosta välittämättä\n");
|
||||||
fprintf(ErrFp, " -h Suppeat tulostukset\n");
|
fprintf(ErrFp, " -h Suppeat tulostukset\n");
|
||||||
#ifdef HAVE_QUEUED
|
|
||||||
fprintf(ErrFp, " -a Älä laukaise viestejä heti - lisää ne jonoon\n");
|
fprintf(ErrFp, " -a Älä laukaise viestejä heti - lisää ne jonoon\n");
|
||||||
fprintf(ErrFp, " -q Älä lisää viestejä jonoon\n");
|
fprintf(ErrFp, " -q Älä lisää viestejä jonoon\n");
|
||||||
fprintf(ErrFp, " -f Laukaise viestit, pysy etualalla\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");
|
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, " -d... Virheenetsintä: e=echo x=expr-eval t=trig v=dumpvars l=showline\n");
|
||||||
fprintf(ErrFp, " -e Ohjaa virhetulostus stdout-vuohon\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");
|
fprintf(ErrFp, " -b[n] Ajan ilmaisu: 0=ap/ip, 1=24 tuntia, 2=ei aikoja\n");
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* */
|
/* */
|
||||||
/* REMIND is Copyright (C) 1992-2023 by Dianne Skoll */
|
/* REMIND is Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* This file is Copyright (C) 1993 by Laurent Duperval and */
|
/* This file is Copyright (C) 1993 by Laurent Duperval and */
|
||||||
/* Dianne Skoll. */
|
/* Dianne Skoll. */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
@@ -119,7 +119,7 @@ EXTERN char *ErrMsg[] =
|
|||||||
"Ok",
|
"Ok",
|
||||||
"']' manquant",
|
"']' manquant",
|
||||||
"Apostrophe manquant",
|
"Apostrophe manquant",
|
||||||
"Expression trop complexe - trop d'opérateurs",
|
"Expression trop complexe",
|
||||||
"Expression trop complexe - trop d'opérandes",
|
"Expression trop complexe - trop d'opérandes",
|
||||||
"')' manquante",
|
"')' manquante",
|
||||||
"Fonction non-définie",
|
"Fonction non-définie",
|
||||||
@@ -219,7 +219,11 @@ EXTERN char *ErrMsg[] =
|
|||||||
"No files matching *.rem",
|
"No files matching *.rem",
|
||||||
"String too long",
|
"String too long",
|
||||||
"Time specified twice",
|
"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 */
|
#endif /* MK_GLOBALS */
|
||||||
|
|
||||||
@@ -228,7 +232,7 @@ EXTERN char *ErrMsg[] =
|
|||||||
#define L_USAGE_OVERRIDE 1
|
#define L_USAGE_OVERRIDE 1
|
||||||
void Usage(void)
|
void Usage(void)
|
||||||
{
|
{
|
||||||
fprintf(ErrFp, "\nREMIND %s (%s version) Copyright 1992-2023 Dianne Skoll\n", VERSION, L_LANGNAME);
|
fprintf(ErrFp, "\nREMIND %s (%s version) Copyright 1992-2024 Dianne Skoll\n", VERSION, L_LANGNAME);
|
||||||
#ifdef BETA
|
#ifdef BETA
|
||||||
fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
|
fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -245,12 +249,10 @@ void Usage(void)
|
|||||||
fprintf(ErrFp, " -o Ignorer instructions ONCE\n");
|
fprintf(ErrFp, " -o Ignorer instructions ONCE\n");
|
||||||
fprintf(ErrFp, " -t Déclencher tous les rappels peu importe le delta\n");
|
fprintf(ErrFp, " -t Déclencher tous les rappels peu importe le delta\n");
|
||||||
fprintf(ErrFp, " -h Mode silencieux\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, " -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, " -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, " -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");
|
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, " -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, " -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");
|
fprintf(ErrFp, " -b[n] Formats de l'heure pour le calendrier: 0=am/pm, 1=24hr, 2=aucun\n");
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
/* I don't speak German. */
|
/* I don't speak German. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/* Support for the Icelandic language. */
|
/* Support for the Icelandic language. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* Translated by Björn Davíðsson (bjossi@snerpa.is) */
|
/* Translated by Björn Davíðsson (bjossi@snerpa.is) */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* It is Copyright (C) 1996 by Valerio Aimale */
|
/* It is Copyright (C) 1996 by Valerio Aimale */
|
||||||
/* */
|
/* */
|
||||||
/* Remind is copyright (C) 1992-2023 by Dianne Skoll */
|
/* Remind is copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
/* Day names */
|
/* Day names */
|
||||||
#define L_SUNDAY "Domenica"
|
#define L_SUNDAY "Domenica"
|
||||||
#define L_MONDAY "Lunedí"
|
#define L_MONDAY "Lunedì"
|
||||||
#define L_TUESDAY "Martedí"
|
#define L_TUESDAY "Martedì"
|
||||||
#define L_WEDNESDAY "Mercoledí"
|
#define L_WEDNESDAY "Mercoledì"
|
||||||
#define L_THURSDAY "Giovedí"
|
#define L_THURSDAY "Giovedì"
|
||||||
#define L_FRIDAY "Venerdí"
|
#define L_FRIDAY "Venerdì"
|
||||||
#define L_SATURDAY "Sabato"
|
#define L_SATURDAY "Sabato"
|
||||||
|
|
||||||
/* Month names */
|
/* Month names */
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
#define L_AT "alle"
|
#define L_AT "alle"
|
||||||
#define L_MINUTE "minut"
|
#define L_MINUTE "minut"
|
||||||
#define L_HOUR "or"
|
#define L_HOUR "or"
|
||||||
#define L_IS "é"
|
#define L_IS "è"
|
||||||
#define L_WAS "era"
|
#define L_WAS "era"
|
||||||
#define L_AND "e"
|
#define L_AND "e"
|
||||||
/* What to add to make "hour" plural */
|
/* What to add to make "hour" plural */
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* This file is Copyright (C) 1993 by Trygve Randen. */
|
/* This file is Copyright (C) 1993 by Trygve Randen. */
|
||||||
/* Remind is Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Remind is Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
/* Polish. */
|
/* Polish. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -135,7 +135,7 @@ EXTERN char *ErrMsg[] =
|
|||||||
"OK",
|
"OK",
|
||||||
"Brakujący ']'",
|
"Brakujący ']'",
|
||||||
"Brakujący nawias",
|
"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",
|
"Zbyt skomplikowane wyrażenie - za dużo argumentów",
|
||||||
"Brakujący ')'",
|
"Brakujący ')'",
|
||||||
"Nie zdefiniowana funkcja",
|
"Nie zdefiniowana funkcja",
|
||||||
@@ -235,7 +235,10 @@ EXTERN char *ErrMsg[] =
|
|||||||
"No files matching *.rem",
|
"No files matching *.rem",
|
||||||
"String too long",
|
"String too long",
|
||||||
"Time specified twice",
|
"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 */
|
#endif /* MK_GLOBALS */
|
||||||
|
|
||||||
@@ -244,7 +247,7 @@ EXTERN char *ErrMsg[] =
|
|||||||
#define L_USAGE_OVERRIDE 1
|
#define L_USAGE_OVERRIDE 1
|
||||||
void Usage(void)
|
void Usage(void)
|
||||||
{
|
{
|
||||||
fprintf(ErrFp, "\nREMIND %s (%s version) Copyright 1992-2023 Dianne Skoll\n", VERSION, L_LANGNAME);
|
fprintf(ErrFp, "\nREMIND %s (%s version) Copyright 1992-2024 Dianne Skoll\n", VERSION, L_LANGNAME);
|
||||||
#ifdef BETA
|
#ifdef BETA
|
||||||
fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
|
fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -261,12 +264,10 @@ void Usage(void)
|
|||||||
fprintf(ErrFp, " -o Ignoruj instrukcje ONCE\n");
|
fprintf(ErrFp, " -o Ignoruj instrukcje ONCE\n");
|
||||||
fprintf(ErrFp, " -t Odpal wszystkie przyszłe przypomnienia niezależnie od delty\n");
|
fprintf(ErrFp, " -t Odpal wszystkie przyszłe przypomnienia niezależnie od delty\n");
|
||||||
fprintf(ErrFp, " -h Praca bezszmerowa\n");
|
fprintf(ErrFp, " -h Praca bezszmerowa\n");
|
||||||
#ifdef HAVE_QUEUED
|
|
||||||
fprintf(ErrFp, " -a Nie odpalaj przyponień czasowych - kolejkuj je\n");
|
fprintf(ErrFp, " -a Nie odpalaj przyponień czasowych - kolejkuj je\n");
|
||||||
fprintf(ErrFp, " -q Nie kolejkuj przyponień czasowych\n");
|
fprintf(ErrFp, " -q Nie kolejkuj przyponień czasowych\n");
|
||||||
fprintf(ErrFp, " -f Nie przechodź do pracy w tle\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");
|
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, " -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, " -e Komunikaty o błędach skieruj na stdout\n");
|
||||||
fprintf(ErrFp, " -b[n] Format czasu: 0=am/pm, 1=24godz., 2=żaden\n");
|
fprintf(ErrFp, " -b[n] Format czasu: 0=am/pm, 1=24godz., 2=żaden\n");
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* */
|
/* */
|
||||||
/* REMIND is Copyright (C) 1992-2023 by Dianne Skoll */
|
/* REMIND is Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* This file is Copyright (C) 1996 by Marco Paganini and */
|
/* This file is Copyright (C) 1996 by Marco Paganini and */
|
||||||
/* Dianne Skoll. */
|
/* Dianne Skoll. */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
@@ -144,7 +144,7 @@ EXTERN char *ErrMsg[] =
|
|||||||
"Ok",
|
"Ok",
|
||||||
"Falta um ']'",
|
"Falta um ']'",
|
||||||
"Falta uma aspa",
|
"Falta uma aspa",
|
||||||
"Expressao muito complexa - muitos operadores",
|
"Expressao muito complexa",
|
||||||
"Expressao muito complexa - muitos operandos",
|
"Expressao muito complexa - muitos operandos",
|
||||||
"Falta um ')'",
|
"Falta um ')'",
|
||||||
"Funcao nao definida",
|
"Funcao nao definida",
|
||||||
@@ -244,7 +244,10 @@ EXTERN char *ErrMsg[] =
|
|||||||
"No files matching *.rem",
|
"No files matching *.rem",
|
||||||
"String too long",
|
"String too long",
|
||||||
"Time specified twice",
|
"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 */
|
#endif /* MK_GLOBALS */
|
||||||
|
|
||||||
@@ -253,7 +256,7 @@ EXTERN char *ErrMsg[] =
|
|||||||
#define L_USAGE_OVERRIDE 1
|
#define L_USAGE_OVERRIDE 1
|
||||||
void Usage(void)
|
void Usage(void)
|
||||||
{
|
{
|
||||||
fprintf(ErrFp, "\nREMIND %s (versao %s) (C) 1992-2023 Dianne Skoll\n", VERSION, L_LANGNAME);
|
fprintf(ErrFp, "\nREMIND %s (versao %s) (C) 1992-2024 Dianne Skoll\n", VERSION, L_LANGNAME);
|
||||||
#ifdef BETA
|
#ifdef BETA
|
||||||
fprintf(ErrFp, ">>>> VERSAO BETA <<<<\n");
|
fprintf(ErrFp, ">>>> VERSAO BETA <<<<\n");
|
||||||
#endif
|
#endif
|
||||||
@@ -270,12 +273,10 @@ void Usage(void)
|
|||||||
fprintf(ErrFp, " -o Ignora diretivas ONCE\n");
|
fprintf(ErrFp, " -o Ignora diretivas ONCE\n");
|
||||||
fprintf(ErrFp, " -t Aciona todos os compromissos futuros, sem considerar o delta\n");
|
fprintf(ErrFp, " -t Aciona todos os compromissos futuros, sem considerar o delta\n");
|
||||||
fprintf(ErrFp, " -h Modo `Hush' - quieto\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, " -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, " -q Nao coloca compromissos com hora na fila\n");
|
||||||
fprintf(ErrFp, " -f Aciona compromissos com hora em modo foreground\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");
|
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, " -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, " -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");
|
fprintf(ErrFp, " -b[n] Formato da hora para o cal: 0=am/pm, 1=24hr, 2=nenhum\n");
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* */
|
/* */
|
||||||
/* REMIND is Copyright (C) 1992-2023 by Dianne Skoll */
|
/* REMIND is Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* This file is Copyright (C) 1996-1998 by Liviu Daia */
|
/* This file is Copyright (C) 1996-1998 by Liviu Daia */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
/* Author: Rafa Couto <rafacouto@biogate.com> */
|
/* Author: Rafa Couto <rafacouto@biogate.com> */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
424
src/main.c
424
src/main.c
@@ -6,7 +6,7 @@
|
|||||||
/* routines, etc. */
|
/* routines, etc. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -14,28 +14,29 @@
|
|||||||
#define _XOPEN_SOURCE 600
|
#define _XOPEN_SOURCE 600
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#ifdef HAVE_LOCALE_H
|
#ifdef HAVE_LOCALE_H
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#ifdef TIME_WITH_SYS_TIME
|
#if defined(HAVE_SYS_TIME_H)
|
||||||
#include <time.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#else
|
#endif
|
||||||
#if defined(HAVE_SYS_TIME_H) || defined (TIME_WITH_SYS_TIME)
|
|
||||||
#include <sys/time.h>
|
|
||||||
#else
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef REM_USE_WCHAR
|
#ifdef REM_USE_WCHAR
|
||||||
@@ -45,12 +46,46 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "expr.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
|
|
||||||
static void DoReminders(void);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/** **/
|
/** **/
|
||||||
@@ -62,6 +97,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
|
struct sigaction act;
|
||||||
|
|
||||||
#ifdef HAVE_SETLOCALE
|
#ifdef HAVE_SETLOCALE
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
#endif
|
#endif
|
||||||
@@ -74,9 +111,30 @@ int main(int argc, char *argv[])
|
|||||||
ArgV = (char const **) argv;
|
ArgV = (char const **) argv;
|
||||||
|
|
||||||
InitRemind(argc, (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));
|
DBufInit(&(LastTrigger.tags));
|
||||||
ClearLastTriggers();
|
ClearLastTriggers();
|
||||||
|
|
||||||
|
atexit(exitfunc);
|
||||||
|
|
||||||
if (DoCalendar || (DoSimpleCalendar && (!NextMode || PsCal))) {
|
if (DoCalendar || (DoSimpleCalendar && (!NextMode || PsCal))) {
|
||||||
ProduceCalendar();
|
ProduceCalendar();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -100,7 +158,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Hush) {
|
if (!Hush) {
|
||||||
if (DestroyOmitContexts())
|
if (DestroyOmitContexts(1))
|
||||||
Eprint("%s", ErrMsg[E_PUSH_NOPOP]);
|
Eprint("%s", ErrMsg[E_PUSH_NOPOP]);
|
||||||
if (!Daemon && !NextMode && !NumTriggered && !NumQueued) {
|
if (!Daemon && !NextMode && !NumTriggered && !NumQueued) {
|
||||||
printf("%s\n", ErrMsg[E_NOREMINDERS]);
|
printf("%s\n", ErrMsg[E_NOREMINDERS]);
|
||||||
@@ -153,7 +211,7 @@ void
|
|||||||
PerIterationInit(void)
|
PerIterationInit(void)
|
||||||
{
|
{
|
||||||
ClearGlobalOmits();
|
ClearGlobalOmits();
|
||||||
DestroyOmitContexts();
|
DestroyOmitContexts(1);
|
||||||
DestroyVars(0);
|
DestroyVars(0);
|
||||||
DefaultColorR = -1;
|
DefaultColorR = -1;
|
||||||
DefaultColorG = -1;
|
DefaultColorG = -1;
|
||||||
@@ -187,14 +245,14 @@ static void DoReminders(void)
|
|||||||
|
|
||||||
if (FileAccessDate < 0) {
|
if (FileAccessDate < 0) {
|
||||||
fprintf(ErrFp, "%s: `%s': %s.\n", ErrMsg[E_CANTACCESS], InitialFile, strerror(errno));
|
fprintf(ErrFp, "%s: `%s': %s.\n", ErrMsg[E_CANTACCESS], InitialFile, strerror(errno));
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
r=IncludeFile(InitialFile);
|
r=IncludeFile(InitialFile);
|
||||||
if (r) {
|
if (r) {
|
||||||
fprintf(ErrFp, "%s %s: %s\n", ErrMsg[E_ERR_READING],
|
fprintf(ErrFp, "%s %s: %s\n", ErrMsg[E_ERR_READING],
|
||||||
InitialFile, ErrMsg[r]);
|
InitialFile, ErrMsg[r]);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
@@ -202,7 +260,7 @@ static void DoReminders(void)
|
|||||||
if (r == E_EOF) return;
|
if (r == E_EOF) return;
|
||||||
if (r) {
|
if (r) {
|
||||||
Eprint("%s: %s", ErrMsg[E_ERR_READING], ErrMsg[r]);
|
Eprint("%s: %s", ErrMsg[E_ERR_READING], ErrMsg[r]);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
s = FindInitialToken(&tok, CurLine);
|
s = FindInitialToken(&tok, CurLine);
|
||||||
|
|
||||||
@@ -280,9 +338,11 @@ static void DoReminders(void)
|
|||||||
case T_Pop: r=PopOmitContext(&p); break;
|
case T_Pop: r=PopOmitContext(&p); break;
|
||||||
case T_Preserve: r=DoPreserve(&p); break;
|
case T_Preserve: r=DoPreserve(&p); break;
|
||||||
case T_Push: r=PushOmitContext(&p); break;
|
case T_Push: r=PushOmitContext(&p); break;
|
||||||
|
case T_Expr: r = DoExpr(&p); break;
|
||||||
case T_RemType: if (tok.val == RUN_TYPE) {
|
case T_RemType: if (tok.val == RUN_TYPE) {
|
||||||
r=DoRun(&p);
|
r=DoRun(&p);
|
||||||
} else {
|
} else {
|
||||||
|
DestroyParser(&p);
|
||||||
CreateParser(CurLine, &p);
|
CreateParser(CurLine, &p);
|
||||||
r=DoRem(&p);
|
r=DoRem(&p);
|
||||||
purge_handled = 1;
|
purge_handled = 1;
|
||||||
@@ -291,10 +351,8 @@ static void DoReminders(void)
|
|||||||
|
|
||||||
|
|
||||||
/* If we don't recognize the command, do a REM by default */
|
/* 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)) {
|
if (r && (!Hush || r != E_RUN_DISABLED)) {
|
||||||
@@ -385,6 +443,23 @@ void FromDSE(int dse, int *y, int *m, int *d)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int JulianToGregorianOffset(int y, int m)
|
||||||
|
{
|
||||||
|
int offset = 13;
|
||||||
|
int centuries;
|
||||||
|
int four_centuries;
|
||||||
|
if (y >= 2100) {
|
||||||
|
centuries = (y - 2000) / 100;
|
||||||
|
four_centuries = (y - 2000) / 400;
|
||||||
|
offset += centuries - four_centuries;
|
||||||
|
if (!(y%100) && (y % 400)) {
|
||||||
|
if (m < 2) {
|
||||||
|
offset--; /* Offset increments in March */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* ParseChar */
|
/* ParseChar */
|
||||||
@@ -435,6 +510,16 @@ int ParseChar(ParsePtr p, int *err, int peek)
|
|||||||
return *(p->pos++);
|
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->expr_happened = 1;
|
||||||
p->pos++;
|
p->pos++;
|
||||||
r = EvalExpr(&(p->pos), &val, p);
|
r = EvalExpr(&(p->pos), &val, p);
|
||||||
@@ -443,8 +528,15 @@ int ParseChar(ParsePtr p, int *err, int peek)
|
|||||||
DestroyParser(p);
|
DestroyParser(p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
while(*p->pos && (isempty(*p->pos))) {
|
||||||
|
p->pos++;
|
||||||
|
}
|
||||||
if (*p->pos != END_OF_EXPR) {
|
if (*p->pos != END_OF_EXPR) {
|
||||||
*err = E_MISS_END;
|
if (*p->pos) {
|
||||||
|
*err = E_PARSE_ERR;
|
||||||
|
} else {
|
||||||
|
*err = E_MISS_END;
|
||||||
|
}
|
||||||
DestroyParser(p);
|
DestroyParser(p);
|
||||||
DestroyValue(val);
|
DestroyValue(val);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -559,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 */
|
/* EvaluateExpr */
|
||||||
@@ -570,21 +713,22 @@ int ParseIdentifier(ParsePtr p, DynamicBuffer *dbuf)
|
|||||||
int EvaluateExpr(ParsePtr p, Value *v)
|
int EvaluateExpr(ParsePtr p, Value *v)
|
||||||
{
|
{
|
||||||
|
|
||||||
int bracketed = 0;
|
|
||||||
int r;
|
int r;
|
||||||
|
int nonconst = 0;
|
||||||
|
expr_node *node = ParseExpr(p, &r);
|
||||||
|
|
||||||
if (p->isnested) return E_PARSE_ERR; /* Can't nest expressions */
|
if (r != OK) {
|
||||||
while (isempty(*p->pos)) (p->pos)++;
|
return r;
|
||||||
if (!p->pos) return E_PARSE_ERR; /* Missing expression */
|
|
||||||
if (*p->pos == BEG_OF_EXPR) {
|
|
||||||
(p->pos)++;
|
|
||||||
bracketed = 1;
|
|
||||||
}
|
}
|
||||||
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 (r) return r;
|
||||||
if (bracketed) {
|
if (nonconst) {
|
||||||
if (*p->pos != END_OF_EXPR) return E_MISS_END;
|
p->nonconst_expr = 1;
|
||||||
(p->pos)++;
|
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -620,36 +764,36 @@ void Wprint(char const *fmt, ...)
|
|||||||
void Eprint(char const *fmt, ...)
|
void Eprint(char const *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
|
char const *fname;
|
||||||
|
|
||||||
/* Check if more than one error msg. from this line */
|
/* Check if more than one error msg. from this line */
|
||||||
if (!FreshLine && !ShowAllErrors) return;
|
if (!FreshLine && !ShowAllErrors) return;
|
||||||
|
|
||||||
if (FreshLine && FileName) {
|
if (!FileName) {
|
||||||
FreshLine = 0;
|
return;
|
||||||
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 (strcmp(FileName, "-")) {
|
||||||
|
fname = FileName;
|
||||||
|
} else {
|
||||||
|
fname = "-stdin-";
|
||||||
|
}
|
||||||
|
if (FreshLine) {
|
||||||
|
(void) fprintf(ErrFp, "%s(%d): ", fname, LineNo);
|
||||||
|
} else {
|
||||||
|
fprintf(ErrFp, " ");
|
||||||
|
}
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
(void) vfprintf(ErrFp, fmt, argptr);
|
(void) vfprintf(ErrFp, fmt, argptr);
|
||||||
(void) fputc('\n', ErrFp);
|
(void) fputc('\n', ErrFp);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
return;
|
if (print_callstack(ErrFp)) {
|
||||||
|
(void) fprintf(ErrFp, "\n");
|
||||||
|
}
|
||||||
|
if (FreshLine) {
|
||||||
|
if (DebugFlag & DB_PRTLINE) OutputLine(ErrFp);
|
||||||
|
}
|
||||||
|
FreshLine = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -736,19 +880,32 @@ int PushToken(char const *tok, ParsePtr p)
|
|||||||
/* Return the system time in seconds past midnight */
|
/* Return the system time in seconds past midnight */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
long SystemTime(int realtime)
|
int SystemTime(int realtime)
|
||||||
{
|
{
|
||||||
time_t tloc;
|
time_t now;
|
||||||
struct tm *t;
|
struct tm *t;
|
||||||
|
|
||||||
if (!realtime && (SysTime != -1L)) return SysTime;
|
if (!realtime && (SysTime != -1)) return SysTime;
|
||||||
|
|
||||||
(void) time(&tloc);
|
now = time(NULL);
|
||||||
t = localtime(&tloc);
|
t = localtime(&now);
|
||||||
return (long) t->tm_hour * 3600L + (long) t->tm_min * 60L +
|
return t->tm_hour * 3600L + t->tm_min * 60L +
|
||||||
(long) t->tm_sec;
|
t->tm_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***************************************************************/
|
||||||
|
/* */
|
||||||
|
/* MinutesPastMidnight */
|
||||||
|
/* */
|
||||||
|
/* Return the system time in minutes past midnight */
|
||||||
|
/* */
|
||||||
|
/***************************************************************/
|
||||||
|
int MinutesPastMidnight(int realtime)
|
||||||
|
{
|
||||||
|
return (SystemTime(realtime) / 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* SystemDate */
|
/* SystemDate */
|
||||||
@@ -760,11 +917,11 @@ long SystemTime(int realtime)
|
|||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
int SystemDate(int *y, int *m, int *d)
|
int SystemDate(int *y, int *m, int *d)
|
||||||
{
|
{
|
||||||
time_t tloc;
|
time_t now;
|
||||||
struct tm *t;
|
struct tm *t;
|
||||||
|
|
||||||
(void) time(&tloc);
|
now = time(NULL);
|
||||||
t = localtime(&tloc);
|
t = localtime(&now);
|
||||||
|
|
||||||
*d = t->tm_mday;
|
*d = t->tm_mday;
|
||||||
*m = t->tm_mon;
|
*m = t->tm_mon;
|
||||||
@@ -805,6 +962,7 @@ int DoIf(ParsePtr p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IfLinenos[NumIfs] = LineNo;
|
||||||
NumIfs++;
|
NumIfs++;
|
||||||
IfFlags &= ~(IF_MASK << (2*NumIfs - 2));
|
IfFlags &= ~(IF_MASK << (2*NumIfs - 2));
|
||||||
IfFlags |= syndrome << (2 * NumIfs - 2);
|
IfFlags |= syndrome << (2 * NumIfs - 2);
|
||||||
@@ -869,7 +1027,7 @@ int DoIfTrig(ParsePtr p)
|
|||||||
if ((size_t) NumIfs >= IF_NEST) return E_NESTED_IF;
|
if ((size_t) NumIfs >= IF_NEST) return E_NESTED_IF;
|
||||||
if (ShouldIgnoreLine()) syndrome = IF_TRUE | BEFORE_ELSE;
|
if (ShouldIgnoreLine()) syndrome = IF_TRUE | BEFORE_ELSE;
|
||||||
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;
|
if (trig.typ != NO_TYPE) return E_PARSE_ERR;
|
||||||
dse = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1);
|
dse = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1);
|
||||||
if (r) {
|
if (r) {
|
||||||
@@ -987,6 +1145,12 @@ int DoDebug(ParsePtr p)
|
|||||||
else DebugFlag &= ~DB_ECHO_LINE;
|
else DebugFlag &= ~DB_ECHO_LINE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
case 'S':
|
||||||
|
if (val) DebugFlag |= DB_PARSE_EXPR;
|
||||||
|
else DebugFlag &= ~DB_PARSE_EXPR;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'X':
|
case 'X':
|
||||||
if (val) DebugFlag |= DB_PRTEXPR;
|
if (val) DebugFlag |= DB_PRTEXPR;
|
||||||
@@ -1052,7 +1216,7 @@ int DoBanner(ParsePtr p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBufFree(&Banner);
|
DBufFree(&Banner);
|
||||||
|
|
||||||
err = DBufPuts(&Banner, DBufValue(&buf));
|
err = DBufPuts(&Banner, DBufValue(&buf));
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return err;
|
return err;
|
||||||
@@ -1064,7 +1228,6 @@ int DoBanner(ParsePtr p)
|
|||||||
/* */
|
/* */
|
||||||
/* Enable or disable the RUN command under program control */
|
/* Enable or disable the RUN command under program control */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
int DoRun(ParsePtr p)
|
int DoRun(ParsePtr p)
|
||||||
{
|
{
|
||||||
@@ -1091,6 +1254,38 @@ int DoRun(ParsePtr p)
|
|||||||
return VerifyEoln(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 */
|
/* DoFlush */
|
||||||
@@ -1227,19 +1422,19 @@ int CalcMinsFromUTC(int dse, int tim, int *mins, int *isdst)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char const *OutputEscapeSequences(char const *s, int print)
|
static char const *OutputEscapeSequences(char const *s, int print, DynamicBuffer *output)
|
||||||
{
|
{
|
||||||
while (*s == 0x1B && *(s+1) == '[') {
|
while (*s == 0x1B && *(s+1) == '[') {
|
||||||
if (print) putchar(*s);
|
if (print) OUTPUT(*s);
|
||||||
s++;
|
s++;
|
||||||
if (print) putchar(*s);
|
if (print) OUTPUT(*s);
|
||||||
s++;
|
s++;
|
||||||
while (*s && (*s < 0x40 || *s > 0x7E)) {
|
while (*s && (*s < 0x40 || *s > 0x7E)) {
|
||||||
if (print) putchar(*s);
|
if (print) OUTPUT(*s);
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
if (*s) {
|
if (*s) {
|
||||||
if (print) putchar(*s);
|
if (print) OUTPUT(*s);
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1248,19 +1443,19 @@ static char const *OutputEscapeSequences(char const *s, int print)
|
|||||||
|
|
||||||
#ifdef REM_USE_WCHAR
|
#ifdef REM_USE_WCHAR
|
||||||
#define ISWBLANK(c) (iswspace(c) && (c) != '\n')
|
#define ISWBLANK(c) (iswspace(c) && (c) != '\n')
|
||||||
static wchar_t const *OutputEscapeSequencesWS(wchar_t const *s, int print)
|
static wchar_t const *OutputEscapeSequencesWS(wchar_t const *s, int print, DynamicBuffer *output)
|
||||||
{
|
{
|
||||||
while (*s == 0x1B && *(s+1) == '[') {
|
while (*s == 0x1B && *(s+1) == '[') {
|
||||||
if (print) PutWideChar(*s);
|
if (print) PutWideChar(*s, output);
|
||||||
s++;
|
s++;
|
||||||
if (print) PutWideChar(*s);
|
if (print) PutWideChar(*s, output);
|
||||||
s++;
|
s++;
|
||||||
while (*s && (*s < 0x40 || *s > 0x7E)) {
|
while (*s && (*s < 0x40 || *s > 0x7E)) {
|
||||||
if (print) PutWideChar(*s);
|
if (print) PutWideChar(*s, output);
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
if (*s) {
|
if (*s) {
|
||||||
if (print) PutWideChar(*s);
|
if (print) PutWideChar(*s, output);
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1269,7 +1464,7 @@ static wchar_t const *OutputEscapeSequencesWS(wchar_t const *s, int print)
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
FillParagraphWCAux(wchar_t const *s)
|
FillParagraphWCAux(wchar_t const *s, DynamicBuffer *output)
|
||||||
{
|
{
|
||||||
int line = 0;
|
int line = 0;
|
||||||
int i, j;
|
int i, j;
|
||||||
@@ -1284,7 +1479,7 @@ FillParagraphWCAux(wchar_t const *s)
|
|||||||
|
|
||||||
/* If it's a carriage return, output it and start new paragraph */
|
/* If it's a carriage return, output it and start new paragraph */
|
||||||
if (*s == '\n') {
|
if (*s == '\n') {
|
||||||
putchar('\n');
|
OUTPUT('\n');
|
||||||
s++;
|
s++;
|
||||||
line = 0;
|
line = 0;
|
||||||
while(ISWBLANK(*s)) s++;
|
while(ISWBLANK(*s)) s++;
|
||||||
@@ -1297,7 +1492,7 @@ FillParagraphWCAux(wchar_t const *s)
|
|||||||
number of spaces */
|
number of spaces */
|
||||||
j = line ? SubsIndent : FirstIndent;
|
j = line ? SubsIndent : FirstIndent;
|
||||||
for (i=0; i<j; i++) {
|
for (i=0; i<j; i++) {
|
||||||
putchar(' ');
|
OUTPUT(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the amount of room left on this line */
|
/* Calculate the amount of room left on this line */
|
||||||
@@ -1310,7 +1505,7 @@ FillParagraphWCAux(wchar_t const *s)
|
|||||||
if (*s == '\n') break;
|
if (*s == '\n') break;
|
||||||
while(1) {
|
while(1) {
|
||||||
t = s;
|
t = s;
|
||||||
s = OutputEscapeSequencesWS(s, 1);
|
s = OutputEscapeSequencesWS(s, 1, output);
|
||||||
if (s == t) break;
|
if (s == t) break;
|
||||||
while(ISWBLANK(*s)) s++;
|
while(ISWBLANK(*s)) s++;
|
||||||
}
|
}
|
||||||
@@ -1318,7 +1513,7 @@ FillParagraphWCAux(wchar_t const *s)
|
|||||||
len = 0;
|
len = 0;
|
||||||
while(*s && !iswspace(*s)) {
|
while(*s && !iswspace(*s)) {
|
||||||
if (*s == 0x1B && *(s+1) == '[') {
|
if (*s == 0x1B && *(s+1) == '[') {
|
||||||
s = OutputEscapeSequencesWS(s, 0);
|
s = OutputEscapeSequencesWS(s, 0, output);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
len += wcwidth(*s);
|
len += wcwidth(*s);
|
||||||
@@ -1329,17 +1524,17 @@ FillParagraphWCAux(wchar_t const *s)
|
|||||||
}
|
}
|
||||||
if (!pendspace || len+pendspace <= roomleft) {
|
if (!pendspace || len+pendspace <= roomleft) {
|
||||||
for (i=0; i<pendspace; i++) {
|
for (i=0; i<pendspace; i++) {
|
||||||
putchar(' ');
|
OUTPUT(' ');
|
||||||
}
|
}
|
||||||
while(t < s) {
|
while(t < s) {
|
||||||
PutWideChar(*t);
|
PutWideChar(*t, output);
|
||||||
if (strchr(EndSent, *t)) doublespace = 2;
|
if (strchr(EndSent, *t)) doublespace = 2;
|
||||||
else if (!strchr(EndSentIg, *t)) doublespace = 1;
|
else if (!strchr(EndSentIg, *t)) doublespace = 1;
|
||||||
t++;
|
t++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s = t;
|
s = t;
|
||||||
putchar('\n');
|
OUTPUT('\n');
|
||||||
line++;
|
line++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1350,7 +1545,7 @@ FillParagraphWCAux(wchar_t const *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
FillParagraphWC(char const *s)
|
FillParagraphWC(char const *s, DynamicBuffer *output)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
wchar_t *buf;
|
wchar_t *buf;
|
||||||
@@ -1360,7 +1555,7 @@ FillParagraphWC(char const *s)
|
|||||||
buf = calloc(len+1, sizeof(wchar_t));
|
buf = calloc(len+1, sizeof(wchar_t));
|
||||||
if (!buf) return E_NO_MEM;
|
if (!buf) return E_NO_MEM;
|
||||||
(void) mbstowcs(buf, s, len+1);
|
(void) mbstowcs(buf, s, len+1);
|
||||||
FillParagraphWCAux(buf);
|
FillParagraphWCAux(buf, output);
|
||||||
free(buf);
|
free(buf);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -1380,7 +1575,7 @@ FillParagraphWC(char const *s)
|
|||||||
/* A macro safe ONLY if used with arg with no side effects! */
|
/* A macro safe ONLY if used with arg with no side effects! */
|
||||||
#define ISBLANK(c) (isspace(c) && (c) != '\n')
|
#define ISBLANK(c) (isspace(c) && (c) != '\n')
|
||||||
|
|
||||||
void FillParagraph(char const *s)
|
void FillParagraph(char const *s, DynamicBuffer *output)
|
||||||
{
|
{
|
||||||
|
|
||||||
int line = 0;
|
int line = 0;
|
||||||
@@ -1398,7 +1593,7 @@ void FillParagraph(char const *s)
|
|||||||
if (!*s) return;
|
if (!*s) return;
|
||||||
|
|
||||||
#ifdef REM_USE_WCHAR
|
#ifdef REM_USE_WCHAR
|
||||||
if (FillParagraphWC(s) == OK) {
|
if (FillParagraphWC(s, output) == OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1408,7 +1603,7 @@ void FillParagraph(char const *s)
|
|||||||
|
|
||||||
/* If it's a carriage return, output it and start new paragraph */
|
/* If it's a carriage return, output it and start new paragraph */
|
||||||
if (*s == '\n') {
|
if (*s == '\n') {
|
||||||
putchar('\n');
|
OUTPUT('\n');
|
||||||
s++;
|
s++;
|
||||||
line = 0;
|
line = 0;
|
||||||
while(ISBLANK(*s)) s++;
|
while(ISBLANK(*s)) s++;
|
||||||
@@ -1421,7 +1616,7 @@ void FillParagraph(char const *s)
|
|||||||
number of spaces */
|
number of spaces */
|
||||||
j = line ? SubsIndent : FirstIndent;
|
j = line ? SubsIndent : FirstIndent;
|
||||||
for (i=0; i<j; i++) {
|
for (i=0; i<j; i++) {
|
||||||
putchar(' ');
|
OUTPUT(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the amount of room left on this line */
|
/* Calculate the amount of room left on this line */
|
||||||
@@ -1434,7 +1629,7 @@ void FillParagraph(char const *s)
|
|||||||
if (*s == '\n') break;
|
if (*s == '\n') break;
|
||||||
while(1) {
|
while(1) {
|
||||||
t = s;
|
t = s;
|
||||||
s = OutputEscapeSequences(s, 1);
|
s = OutputEscapeSequences(s, 1, output);
|
||||||
if (s == t) break;
|
if (s == t) break;
|
||||||
while(ISBLANK(*s)) s++;
|
while(ISBLANK(*s)) s++;
|
||||||
}
|
}
|
||||||
@@ -1442,7 +1637,7 @@ void FillParagraph(char const *s)
|
|||||||
len = 0;
|
len = 0;
|
||||||
while(*s && !isspace(*s)) {
|
while(*s && !isspace(*s)) {
|
||||||
if (*s == 0x1B && *(s+1) == '[') {
|
if (*s == 0x1B && *(s+1) == '[') {
|
||||||
s = OutputEscapeSequences(s, 0);
|
s = OutputEscapeSequences(s, 0, output);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
@@ -1453,17 +1648,17 @@ void FillParagraph(char const *s)
|
|||||||
}
|
}
|
||||||
if (!pendspace || len+pendspace <= roomleft) {
|
if (!pendspace || len+pendspace <= roomleft) {
|
||||||
for (i=0; i<pendspace; i++) {
|
for (i=0; i<pendspace; i++) {
|
||||||
putchar(' ');
|
OUTPUT(' ');
|
||||||
}
|
}
|
||||||
while(t < s) {
|
while(t < s) {
|
||||||
putchar(*t);
|
OUTPUT(*t);
|
||||||
if (strchr(EndSent, *t)) doublespace = 2;
|
if (strchr(EndSent, *t)) doublespace = 2;
|
||||||
else if (!strchr(EndSentIg, *t)) doublespace = 1;
|
else if (!strchr(EndSentIg, *t)) doublespace = 1;
|
||||||
t++;
|
t++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s = t;
|
s = t;
|
||||||
putchar('\n');
|
OUTPUT('\n');
|
||||||
line++;
|
line++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1627,14 +1822,53 @@ SaveLastTimeTrig(TimeTrig const *t)
|
|||||||
memcpy(&LastTimeTrig, t, sizeof(LastTimeTrig));
|
memcpy(&LastTimeTrig, t, sizeof(LastTimeTrig));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wrapper to ignore warnings about ignoring return value of system() */
|
/* Wrapper to ignore warnings about ignoring return value of system()
|
||||||
|
Also redirects stdin and stdout to /dev/null for queued reminders */
|
||||||
|
|
||||||
void
|
void
|
||||||
System(char const *cmd)
|
System(char const *cmd, int is_queued)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
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) {
|
||||||
|
/* Fork failed... nothing we can do */
|
||||||
|
return;
|
||||||
|
} else if (kid == 0) {
|
||||||
|
/* In the child */
|
||||||
|
(void) close(STDIN_FILENO);
|
||||||
|
(void) close(STDOUT_FILENO);
|
||||||
|
fd = open("/dev/null", O_RDONLY);
|
||||||
|
if (fd >= 0 && fd != STDIN_FILENO) {
|
||||||
|
dup2(fd, STDIN_FILENO);
|
||||||
|
close(STDIN_FILENO);
|
||||||
|
}
|
||||||
|
fd = open("/dev/null", O_WRONLY);
|
||||||
|
if (fd >= 0 && fd != STDOUT_FILENO) {
|
||||||
|
dup2(fd, STDOUT_FILENO);
|
||||||
|
close(STDOUT_FILENO);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* In the parent */
|
||||||
|
while (waitpid(kid, &status, 0) != kid) /* continue */ ;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* This is the child process or original if we never forked */
|
||||||
r = system(cmd);
|
r = system(cmd);
|
||||||
|
if (do_exit) {
|
||||||
|
/* In the child process, so exit! */
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
r = 1;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
src/md5.h
10
src/md5.h
@@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
typedef uint32_t uint32;
|
||||||
|
#else
|
||||||
#if SIZEOF_UNSIGNED_INT == 4
|
#if SIZEOF_UNSIGNED_INT == 4
|
||||||
typedef unsigned int uint32;
|
typedef unsigned int uint32;
|
||||||
#elif SIZEOF_UNSIGNED_LONG == 4
|
#elif SIZEOF_UNSIGNED_LONG == 4
|
||||||
@@ -13,6 +17,7 @@ typedef unsigned long uint32;
|
|||||||
#else
|
#else
|
||||||
# error Could not find a 32-bit integer type
|
# error Could not find a 32-bit integer type
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
struct MD5Context {
|
struct MD5Context {
|
||||||
uint32 buf[4];
|
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 MD5Final(unsigned char digest[16], struct MD5Context *context);
|
||||||
void MD5Transform(uint32 buf[4], uint32 const in[16]);
|
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 */
|
#endif /* !MD5_H */
|
||||||
|
|||||||
11
src/moon.c
11
src/moon.c
@@ -5,7 +5,7 @@
|
|||||||
/* Calculations for figuring out moon phases. */
|
/* Calculations for figuring out moon phases. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -66,7 +66,6 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "expr.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
|
|
||||||
@@ -403,7 +402,7 @@ static double phase(double pdate,
|
|||||||
|
|
||||||
double Day, N, M, Ec, Lambdasun, ml, MM, Ev, Ae, A3, MmP,
|
double Day, N, M, Ec, Lambdasun, ml, MM, Ev, Ae, A3, MmP,
|
||||||
mEc, A4, lP, V, lPP,
|
mEc, A4, lP, V, lPP,
|
||||||
MoonAge, MoonPhase,
|
MoonAge, Phase,
|
||||||
MoonDist, MoonDFrac, MoonAng,
|
MoonDist, MoonDFrac, MoonAng,
|
||||||
F, SunDist, SunAng;
|
F, SunDist, SunAng;
|
||||||
|
|
||||||
@@ -412,7 +411,7 @@ static double phase(double pdate,
|
|||||||
Day = pdate - epoch; /* Date within epoch */
|
Day = pdate - epoch; /* Date within epoch */
|
||||||
N = fixangle((360 / 365.2422) * Day); /* Mean anomaly of the Sun */
|
N = fixangle((360 / 365.2422) * Day); /* Mean anomaly of the Sun */
|
||||||
M = fixangle(N + elonge - elongp); /* Convert from perigee
|
M = fixangle(N + elonge - elongp); /* Convert from perigee
|
||||||
co-ordinates to epoch 1980.0 */
|
coordinates to epoch 1980.0 */
|
||||||
Ec = kepler(M, eccent); /* Solve equation of Kepler */
|
Ec = kepler(M, eccent); /* Solve equation of Kepler */
|
||||||
Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
|
Ec = sqrt((1 + eccent) / (1 - eccent)) * tan(Ec / 2);
|
||||||
Ec = 2 * todeg(atan(Ec)); /* 1 anomaly */
|
Ec = 2 * todeg(atan(Ec)); /* 1 anomaly */
|
||||||
@@ -465,7 +464,7 @@ static double phase(double pdate,
|
|||||||
MoonAge = lPP - Lambdasun;
|
MoonAge = lPP - Lambdasun;
|
||||||
|
|
||||||
/* Phase of the Moon */
|
/* Phase of the Moon */
|
||||||
MoonPhase = (1 - cos(torad(MoonAge))) / 2;
|
Phase = (1 - cos(torad(MoonAge))) / 2;
|
||||||
|
|
||||||
/* Calculate distance of moon from the centre of the Earth */
|
/* Calculate distance of moon from the centre of the Earth */
|
||||||
|
|
||||||
@@ -477,7 +476,7 @@ static double phase(double pdate,
|
|||||||
MoonDFrac = MoonDist / msmax;
|
MoonDFrac = MoonDist / msmax;
|
||||||
MoonAng = mangsiz / MoonDFrac;
|
MoonAng = mangsiz / MoonDFrac;
|
||||||
|
|
||||||
if(pphase) *pphase = MoonPhase;
|
if(pphase) *pphase = Phase;
|
||||||
if(mage) *mage = synmonth * (fixangle(MoonAge) / 360.0);
|
if(mage) *mage = synmonth * (fixangle(MoonAge) / 360.0);
|
||||||
if(dist) *dist = MoonDist;
|
if(dist) *dist = MoonDist;
|
||||||
if(angdia) *angdia = MoonAng;
|
if(angdia) *angdia = MoonAng;
|
||||||
|
|||||||
47
src/omit.c
47
src/omit.c
@@ -6,7 +6,7 @@
|
|||||||
/* the data structures for OMITted dates. */
|
/* the data structures for OMITted dates. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -14,15 +14,14 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "err.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);
|
static void InsertIntoSortedArray (int *array, int num, int key);
|
||||||
|
|
||||||
/* Arrays for the global omits */
|
/* Arrays for the global omits */
|
||||||
@@ -32,11 +31,13 @@ static int PartialOmitArray[MAX_PARTIAL_OMITS];
|
|||||||
/* WeekdayOmits is declared in global.h */
|
/* WeekdayOmits is declared in global.h */
|
||||||
|
|
||||||
/* How many of each omit types do we have? */
|
/* How many of each omit types do we have? */
|
||||||
static int NumFullOmits, NumPartialOmits;
|
int NumFullOmits, NumPartialOmits;
|
||||||
|
|
||||||
/* The structure for saving and restoring OMIT contexts */
|
/* The structure for saving and restoring OMIT contexts */
|
||||||
typedef struct omitcontext {
|
typedef struct omitcontext {
|
||||||
struct omitcontext *next;
|
struct omitcontext *next;
|
||||||
|
char *filename;
|
||||||
|
int lineno;
|
||||||
int numfull, numpart;
|
int numfull, numpart;
|
||||||
int *fullsave;
|
int *fullsave;
|
||||||
int *partsave;
|
int *partsave;
|
||||||
@@ -79,19 +80,25 @@ int DoClear(ParsePtr p)
|
|||||||
/* */
|
/* */
|
||||||
/* Free all the memory used by saved OMIT contexts. */
|
/* Free all the memory used by saved OMIT contexts. */
|
||||||
/* As a side effect, return the number of 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 *c = SavedOmitContexts;
|
||||||
OmitContext *d;
|
OmitContext *d;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
while (c) {
|
while (c) {
|
||||||
|
if (print_unmatched) {
|
||||||
|
Wprint("Unmatched PUSH-OMIT-CONTEXT at %s(%d)",
|
||||||
|
c->filename, c->lineno);
|
||||||
|
}
|
||||||
num++;
|
num++;
|
||||||
if (c->fullsave) free(c->fullsave);
|
if (c->fullsave) free(c->fullsave);
|
||||||
if (c->partsave) free(c->partsave);
|
if (c->partsave) free(c->partsave);
|
||||||
|
if (c->filename) free(c->filename);
|
||||||
d = c->next;
|
d = c->next;
|
||||||
free(c);
|
free(c);
|
||||||
c = d;
|
c = d;
|
||||||
@@ -116,16 +123,28 @@ int PushOmitContext(ParsePtr p)
|
|||||||
context = NEW(OmitContext);
|
context = NEW(OmitContext);
|
||||||
if (!context) return E_NO_MEM;
|
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->numfull = NumFullOmits;
|
||||||
context->numpart = NumPartialOmits;
|
context->numpart = NumPartialOmits;
|
||||||
context->weekdaysave = WeekdayOmits;
|
context->weekdaysave = WeekdayOmits;
|
||||||
context->fullsave = malloc(NumFullOmits * sizeof(int));
|
context->fullsave = malloc(NumFullOmits * sizeof(int));
|
||||||
if (NumFullOmits && !context->fullsave) {
|
if (NumFullOmits && !context->fullsave) {
|
||||||
|
free(context->filename);
|
||||||
free(context);
|
free(context);
|
||||||
return E_NO_MEM;
|
return E_NO_MEM;
|
||||||
}
|
}
|
||||||
context->partsave = malloc(NumPartialOmits * sizeof(int));
|
context->partsave = malloc(NumPartialOmits * sizeof(int));
|
||||||
if (NumPartialOmits && !context->partsave) {
|
if (NumPartialOmits && !context->partsave) {
|
||||||
|
free(context->filename);
|
||||||
free(context->fullsave);
|
free(context->fullsave);
|
||||||
free(context);
|
free(context);
|
||||||
return E_NO_MEM;
|
return E_NO_MEM;
|
||||||
@@ -175,6 +194,7 @@ int PopOmitContext(ParsePtr p)
|
|||||||
/* Free memory used by the saved context */
|
/* Free memory used by the saved context */
|
||||||
if (c->partsave) free(c->partsave);
|
if (c->partsave) free(c->partsave);
|
||||||
if (c->fullsave) free(c->fullsave);
|
if (c->fullsave) free(c->fullsave);
|
||||||
|
if (c->filename) free(c->filename);
|
||||||
free(c);
|
free(c);
|
||||||
|
|
||||||
return VerifyEoln(p);
|
return VerifyEoln(p);
|
||||||
@@ -251,7 +271,7 @@ int IsOmitted(int dse, int localomit, char const *omitfunc, int *omit)
|
|||||||
/* element is found, 0 otherwise. */
|
/* 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;
|
int top=num-1, bot=0, mid;
|
||||||
|
|
||||||
@@ -377,8 +397,12 @@ int DoOmit(ParsePtr p)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Eprint("%s: `%s' (OMIT)", ErrMsg[E_UNKNOWN_TOKEN],
|
if (tok.type == T_Until) {
|
||||||
DBufValue(&buf));
|
Eprint("OMIT: UNTIL not allowed; did you mean THROUGH?");
|
||||||
|
} else {
|
||||||
|
Eprint("%s: `%s' (OMIT)", ErrMsg[E_UNKNOWN_TOKEN],
|
||||||
|
DBufValue(&buf));
|
||||||
|
}
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return E_UNKNOWN_TOKEN;
|
return E_UNKNOWN_TOKEN;
|
||||||
}
|
}
|
||||||
@@ -441,6 +465,9 @@ int DoOmit(ParsePtr p)
|
|||||||
if (!BexistsIntArray(PartialOmitArray, NumPartialOmits, syndrome)) {
|
if (!BexistsIntArray(PartialOmitArray, NumPartialOmits, syndrome)) {
|
||||||
InsertIntoSortedArray(PartialOmitArray, NumPartialOmits, syndrome);
|
InsertIntoSortedArray(PartialOmitArray, NumPartialOmits, syndrome);
|
||||||
NumPartialOmits++;
|
NumPartialOmits++;
|
||||||
|
if (NumPartialOmits == 366) {
|
||||||
|
Wprint("You have OMITted everything! The space-time continuum is at risk.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mc == m[1] && dc == d[1]) {
|
if (mc == m[1] && dc == d[1]) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
90
src/protos.h
90
src/protos.h
@@ -5,7 +5,7 @@
|
|||||||
/* Function Prototypes. */
|
/* Function Prototypes. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -13,6 +13,18 @@
|
|||||||
/* Suppress unused variable warnings */
|
/* Suppress unused variable warnings */
|
||||||
#define UNUSED(x) (void) x
|
#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 a string assignment macro - be careful!!! */
|
||||||
#define STRSET(x, str) { if (x) free(x); (x) = StrDup(str); }
|
#define STRSET(x, str) { if (x) free(x); (x) = StrDup(str); }
|
||||||
|
|
||||||
@@ -22,28 +34,39 @@
|
|||||||
/* Characters to ignore */
|
/* Characters to ignore */
|
||||||
#define isempty(c) (isspace(c) || ((c) == '\\'))
|
#define isempty(c) (isspace(c) || ((c) == '\\'))
|
||||||
|
|
||||||
|
#define IsServerMode() (Daemon < 0)
|
||||||
|
#define ShouldFork (!DontFork)
|
||||||
|
|
||||||
#include "dynbuf.h"
|
#include "dynbuf.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
int CallUserFunc (char const *name, int nargs, ParsePtr p);
|
int CallUserFunc (char const *name, int nargs, ParsePtr p);
|
||||||
int DoFset (ParsePtr p);
|
int DoFset (ParsePtr p);
|
||||||
int DoFunset (ParsePtr p);
|
int DoFunset (ParsePtr p);
|
||||||
|
void UnsetAllUserFuncs(void);
|
||||||
void ProduceCalendar (void);
|
void ProduceCalendar (void);
|
||||||
char const *SimpleTime (int tim);
|
char const *SimpleTime (int tim);
|
||||||
char const *CalendarTime (int tim, int duration);
|
char const *CalendarTime (int tim, int duration);
|
||||||
int DoRem (ParsePtr p);
|
int DoRem (ParsePtr p);
|
||||||
int DoFlush (ParsePtr p);
|
int DoFlush (ParsePtr p);
|
||||||
void DoExit (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 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 ShouldTriggerReminder (Trigger *t, TimeTrig *tim, int dse, int *err);
|
||||||
int DoSubst (ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, int mode);
|
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 DoSubstFromString (char const *source, DynamicBuffer *dbuf, int dse, int tim);
|
||||||
int ParseLiteralDate (char const **s, int *dse, int *tim);
|
int ParseLiteralDate (char const **s, int *dse, int *tim);
|
||||||
int ParseLiteralTime (char const **s, 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 EvalExpr (char const **e, Value *v, ParsePtr p);
|
||||||
int DoCoerce (char type, Value *v);
|
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 CopyValue (Value *dest, const Value *src);
|
||||||
int ReadLine (void);
|
int ReadLine (void);
|
||||||
int OpenFile (char const *fname);
|
int OpenFile (char const *fname);
|
||||||
@@ -58,11 +81,13 @@ void InitRemind (int argc, char const *argv[]);
|
|||||||
void Usage (void);
|
void Usage (void);
|
||||||
int DSE (int year, int month, int day);
|
int DSE (int year, int month, int day);
|
||||||
void FromDSE (int dse, int *y, int *m, int *d);
|
void FromDSE (int dse, int *y, int *m, int *d);
|
||||||
|
int JulianToGregorianOffset(int y, int m);
|
||||||
int ParseChar (ParsePtr p, int *err, int peek);
|
int ParseChar (ParsePtr p, int *err, int peek);
|
||||||
int ParseToken (ParsePtr p, DynamicBuffer *dbuf);
|
int ParseToken (ParsePtr p, DynamicBuffer *dbuf);
|
||||||
int ParseIdentifier (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 EvaluateExpr (ParsePtr p, Value *v);
|
||||||
int Evaluate (char const **s, Var *locals, ParsePtr p);
|
|
||||||
int FnPopValStack (Value *val);
|
int FnPopValStack (Value *val);
|
||||||
void Eprint (char const *fmt, ...);
|
void Eprint (char const *fmt, ...);
|
||||||
void Wprint (char const *fmt, ...);
|
void Wprint (char const *fmt, ...);
|
||||||
@@ -70,7 +95,8 @@ void OutputLine (FILE *fp);
|
|||||||
void CreateParser (char const *s, ParsePtr p);
|
void CreateParser (char const *s, ParsePtr p);
|
||||||
void DestroyParser (ParsePtr p);
|
void DestroyParser (ParsePtr p);
|
||||||
int PushToken (char const *tok, ParsePtr p);
|
int PushToken (char const *tok, ParsePtr p);
|
||||||
long SystemTime (int realtime);
|
int SystemTime (int realtime);
|
||||||
|
int MinutesPastMidnight (int realtime);
|
||||||
int SystemDate (int *y, int *m, int *d);
|
int SystemDate (int *y, int *m, int *d);
|
||||||
int DoIf (ParsePtr p);
|
int DoIf (ParsePtr p);
|
||||||
int DoElse (ParsePtr p);
|
int DoElse (ParsePtr p);
|
||||||
@@ -81,10 +107,11 @@ int VerifyEoln (ParsePtr p);
|
|||||||
int DoDebug (ParsePtr p);
|
int DoDebug (ParsePtr p);
|
||||||
int DoBanner (ParsePtr p);
|
int DoBanner (ParsePtr p);
|
||||||
int DoRun (ParsePtr p);
|
int DoRun (ParsePtr p);
|
||||||
|
int DoExpr (ParsePtr p);
|
||||||
int DoErrMsg (ParsePtr p);
|
int DoErrMsg (ParsePtr p);
|
||||||
int ClearGlobalOmits (void);
|
int ClearGlobalOmits (void);
|
||||||
int DoClear (ParsePtr p);
|
int DoClear (ParsePtr p);
|
||||||
int DestroyOmitContexts (void);
|
int DestroyOmitContexts (int print_unmatched);
|
||||||
int PushOmitContext (ParsePtr p);
|
int PushOmitContext (ParsePtr p);
|
||||||
int PopOmitContext (ParsePtr p);
|
int PopOmitContext (ParsePtr p);
|
||||||
int IsOmitted (int dse, int localomit, char const *omitfunc, int *omit);
|
int IsOmitted (int dse, int localomit, char const *omitfunc, int *omit);
|
||||||
@@ -97,16 +124,27 @@ void FindNumericToken (char const *s, Token *t);
|
|||||||
int ComputeTrigger (int today, Trigger *trig, TimeTrig *tim, int *err, int save_in_globals);
|
int ComputeTrigger (int today, Trigger *trig, TimeTrig *tim, int *err, int save_in_globals);
|
||||||
int ComputeTriggerNoAdjustDuration (int today, Trigger *trig, TimeTrig *tim, int *err, int save_in_globals, int duration_days);
|
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);
|
int AdjustTriggerForDuration(int today, int r, Trigger *trig, TimeTrig *tim, int save_in_globals);
|
||||||
int ComputeScanStart(int today, Trigger *trig, TimeTrig *tt);
|
|
||||||
char *StrnCpy (char *dest, char const *source, int n);
|
char *StrnCpy (char *dest, char const *source, int n);
|
||||||
int StrMatch (char const *s1, char const *s2, int n);
|
|
||||||
|
#ifndef HAVE_STRNCASECMP
|
||||||
int StrinCmp (char const *s1, char const *s2, int n);
|
int StrinCmp (char const *s1, char const *s2, int n);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRDUP
|
||||||
char *StrDup (char const *s);
|
char *StrDup (char const *s);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRCASECMP
|
||||||
int StrCmpi (char const *s1, char const *s2);
|
int StrCmpi (char const *s1, char const *s2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void strtolower(char *s);
|
||||||
|
|
||||||
Var *FindVar (char const *str, int create);
|
Var *FindVar (char const *str, int create);
|
||||||
|
SysVar *FindSysVar (char const *name);
|
||||||
int DeleteVar (char const *str);
|
int DeleteVar (char const *str);
|
||||||
int SetVar (char const *str, Value *val);
|
int SetVar (char const *str, Value const *val);
|
||||||
int GetVarValue (char const *str, Value *val, Var *locals, ParsePtr p);
|
int GetVarValue (char const *str, Value *val);
|
||||||
int DoSet (Parser *p);
|
int DoSet (Parser *p);
|
||||||
int DoUnset (Parser *p);
|
int DoUnset (Parser *p);
|
||||||
int DoDump (ParsePtr p);
|
int DoDump (ParsePtr p);
|
||||||
@@ -115,14 +153,14 @@ void DestroyVars (int all);
|
|||||||
int PreserveVar (char const *name);
|
int PreserveVar (char const *name);
|
||||||
int DoPreserve (Parser *p);
|
int DoPreserve (Parser *p);
|
||||||
int DoSatRemind (Trigger *trig, TimeTrig *tt, ParsePtr p);
|
int DoSatRemind (Trigger *trig, TimeTrig *tt, ParsePtr p);
|
||||||
int DoMsgCommand (char const *cmd, char const *msg);
|
int DoMsgCommand (char const *cmd, char const *msg, int is_queued);
|
||||||
int ParseNonSpaceChar (ParsePtr p, int *err, int peek);
|
int ParseNonSpaceChar (ParsePtr p, int *err, int peek);
|
||||||
unsigned int HashVal (char const *str);
|
unsigned int HashVal (char const *str);
|
||||||
int DateOK (int y, int m, int d);
|
int DateOK (int y, int m, int d);
|
||||||
Operator *FindOperator (char const *name, Operator where[], int num);
|
BuiltinFunc *FindBuiltinFunc (char const *name);
|
||||||
BuiltinFunc *FindFunc (char const *name, BuiltinFunc where[], int num);
|
|
||||||
int InsertIntoSortBuffer (int dse, int tim, char const *body, int typ, int prio);
|
int InsertIntoSortBuffer (int dse, int tim, char const *body, int typ, int prio);
|
||||||
void IssueSortedReminders (void);
|
void IssueSortedReminders (void);
|
||||||
|
UserFunc *FindUserFunc(char const *name);
|
||||||
int UserFuncExists (char const *fn);
|
int UserFuncExists (char const *fn);
|
||||||
void DSEToHeb (int dse, int *hy, int *hm, int *hd);
|
void DSEToHeb (int dse, int *hy, int *hm, int *hd);
|
||||||
int HebNameToNum (char const *mname);
|
int HebNameToNum (char const *mname);
|
||||||
@@ -139,7 +177,7 @@ int GetSysVar (char const *name, Value *val);
|
|||||||
int SetSysVar (char const *name, Value *val);
|
int SetSysVar (char const *name, Value *val);
|
||||||
void DumpSysVarByName (char const *name);
|
void DumpSysVarByName (char const *name);
|
||||||
int CalcMinsFromUTC (int dse, int tim, int *mins, int *isdst);
|
int CalcMinsFromUTC (int dse, int tim, int *mins, int *isdst);
|
||||||
void FillParagraph (char const *s);
|
void FillParagraph (char const *s, DynamicBuffer *output);
|
||||||
void LocalToUTC (int locdate, int loctime, int *utcdate, int *utctime);
|
void LocalToUTC (int locdate, int loctime, int *utcdate, int *utctime);
|
||||||
void UTCToLocal (int utcdate, int utctime, int *locdate, int *loctime);
|
void UTCToLocal (int utcdate, int utctime, int *locdate, int *loctime);
|
||||||
int MoonPhase (int date, int time);
|
int MoonPhase (int date, int time);
|
||||||
@@ -165,23 +203,39 @@ void PrintJSONKeyPairString(char const *name, char const *val);
|
|||||||
void PrintJSONKeyPairDate(char const *name, int dse);
|
void PrintJSONKeyPairDate(char const *name, int dse);
|
||||||
void PrintJSONKeyPairDateTime(char const *name, int dt);
|
void PrintJSONKeyPairDateTime(char const *name, int dt);
|
||||||
void PrintJSONKeyPairTime(char const *name, int t);
|
void PrintJSONKeyPairTime(char const *name, int t);
|
||||||
void System(char const *cmd);
|
void System(char const *cmd, int queued);
|
||||||
int ShellEscape(char const *in, DynamicBuffer *out);
|
int ShellEscape(char const *in, DynamicBuffer *out);
|
||||||
int AddGlobalOmit(int dse);
|
int AddGlobalOmit(int dse);
|
||||||
void set_lat_and_long_from_components(void);
|
void set_lat_and_long_from_components(void);
|
||||||
void set_components_from_lat_and_long(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_day_name(int wkday);
|
||||||
char const *get_month_name(int mon);
|
char const *get_month_name(int mon);
|
||||||
|
|
||||||
|
void set_cloexec(FILE *fp);
|
||||||
int push_call(char const *filename, char const *func, int lineno);
|
int push_call(char const *filename, char const *func, int lineno);
|
||||||
void clear_callstack(void);
|
void clear_callstack(void);
|
||||||
int have_callstack(void);
|
|
||||||
int print_callstack(FILE *fp);
|
int print_callstack(FILE *fp);
|
||||||
|
int have_callstack(void);
|
||||||
void pop_call(void);
|
void pop_call(void);
|
||||||
|
void FixSpecialType(Trigger *trig);
|
||||||
|
void WriteJSONTrigger(Trigger const *t, int include_tags, int today);
|
||||||
|
void WriteJSONTimeTrigger(TimeTrig const *tt);
|
||||||
#ifdef REM_USE_WCHAR
|
#ifdef REM_USE_WCHAR
|
||||||
#define _XOPEN_SOURCE 600
|
#define _XOPEN_SOURCE 600
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
void PutWideChar(wchar_t const wc);
|
void PutWideChar(wchar_t const wc, DynamicBuffer *output);
|
||||||
#endif
|
#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);
|
||||||
|
|||||||
595
src/queue.c
595
src/queue.c
@@ -5,7 +5,7 @@
|
|||||||
/* Queue up reminders for subsequent execution. */
|
/* Queue up reminders for subsequent execution. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -24,15 +24,33 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "expr.h"
|
|
||||||
|
#undef USE_INOTIFY
|
||||||
|
#if defined(HAVE_SYS_INOTIFY_H) && defined(HAVE_INOTIFY_INIT1)
|
||||||
|
#define USE_INOTIFY 1
|
||||||
|
#include <sys/inotify.h>
|
||||||
|
|
||||||
|
int watch_fd = -1;
|
||||||
|
static void consume_inotify_events(int fd);
|
||||||
|
static int setup_inotify_watch(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* A list of filenames associated with queued reminders */
|
||||||
|
typedef struct queuedfname {
|
||||||
|
struct queuedfname *next;
|
||||||
|
char const *fname;
|
||||||
|
} QueuedFilename;
|
||||||
|
|
||||||
|
|
||||||
/* List structure for holding queued reminders */
|
/* List structure for holding queued reminders */
|
||||||
typedef struct queuedrem {
|
typedef struct queuedrem {
|
||||||
@@ -41,16 +59,19 @@ typedef struct queuedrem {
|
|||||||
int RunDisabled;
|
int RunDisabled;
|
||||||
int ntrig;
|
int ntrig;
|
||||||
char const *text;
|
char const *text;
|
||||||
|
char const *fname;
|
||||||
|
int lineno;
|
||||||
char passthru[PASSTHRU_LEN+1];
|
char passthru[PASSTHRU_LEN+1];
|
||||||
char sched[VAR_NAME_LEN+1];
|
char sched[VAR_NAME_LEN+1];
|
||||||
DynamicBuffer tags;
|
|
||||||
Trigger t;
|
Trigger t;
|
||||||
TimeTrig tt;
|
TimeTrig tt;
|
||||||
|
int red, green, blue;
|
||||||
} QueuedRem;
|
} QueuedRem;
|
||||||
|
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
|
|
||||||
static QueuedRem *QueueHead;
|
static QueuedRem *QueueHead = NULL;
|
||||||
|
static QueuedFilename *Files = NULL;
|
||||||
static time_t FileModTime;
|
static time_t FileModTime;
|
||||||
static struct stat StatBuf;
|
static struct stat StatBuf;
|
||||||
|
|
||||||
@@ -58,9 +79,108 @@ static void CheckInitialFile (void);
|
|||||||
static int CalculateNextTime (QueuedRem *q);
|
static int CalculateNextTime (QueuedRem *q);
|
||||||
static QueuedRem *FindNextReminder (void);
|
static QueuedRem *FindNextReminder (void);
|
||||||
static int CalculateNextTimeUsingSched (QueuedRem *q);
|
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 reread (void);
|
||||||
static void PrintQueue(void);
|
static void PrintQueue(void);
|
||||||
|
static char const *QueueFilename(char const *fname);
|
||||||
|
|
||||||
|
static void chomp(DynamicBuffer *buf)
|
||||||
|
{
|
||||||
|
char *s = DBufValue(buf);
|
||||||
|
int l = DBufLen(buf);
|
||||||
|
while (l) {
|
||||||
|
if (s[l-1] == '\n') {
|
||||||
|
s[l-1] = 0;
|
||||||
|
DBufLen(buf)--;
|
||||||
|
l--;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char const *SimpleTimeNoSpace(int tim)
|
||||||
|
{
|
||||||
|
char *s = (char *) SimpleTime(tim);
|
||||||
|
if (s && *s) {
|
||||||
|
size_t l = strlen(s);
|
||||||
|
if (l > 0 && s[l-1] == ' ') {
|
||||||
|
s[l-1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************/
|
||||||
|
/* */
|
||||||
|
/* QueueFilename */
|
||||||
|
/* */
|
||||||
|
/* Add fname to the list of queued filenames if it's not */
|
||||||
|
/* already present. Either way, return a pointer to the */
|
||||||
|
/* filename. Returns NULL if out of memory */
|
||||||
|
/* */
|
||||||
|
/***************************************************************/
|
||||||
|
static QueuedFilename *last_file_found = NULL;
|
||||||
|
static char const *QueueFilename(char const *fname)
|
||||||
|
{
|
||||||
|
QueuedFilename *elem = Files;
|
||||||
|
|
||||||
|
/* Optimization: We are very likely in the same file as
|
||||||
|
before... */
|
||||||
|
if (last_file_found && !strcmp(fname, last_file_found->fname)) {
|
||||||
|
return last_file_found->fname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No such luck; search the list */
|
||||||
|
while(elem) {
|
||||||
|
if (!strcmp(elem->fname, fname)) {
|
||||||
|
last_file_found = elem;
|
||||||
|
return elem->fname;
|
||||||
|
}
|
||||||
|
elem = elem->next;
|
||||||
|
}
|
||||||
|
/* Not found... queue it */
|
||||||
|
elem = NEW(QueuedFilename);
|
||||||
|
if (!elem) return NULL;
|
||||||
|
elem->fname = StrDup(fname);
|
||||||
|
if (!elem->fname) {
|
||||||
|
free(elem);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
elem->next = Files;
|
||||||
|
Files = elem;
|
||||||
|
last_file_found = elem;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
@@ -71,7 +191,7 @@ static void PrintQueue(void);
|
|||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
int QueueReminder(ParsePtr p, Trigger *trig,
|
int QueueReminder(ParsePtr p, Trigger *trig,
|
||||||
TimeTrig *tim, char const *sched)
|
TimeTrig *tim, char const *sched)
|
||||||
{
|
{
|
||||||
QueuedRem *qelem;
|
QueuedRem *qelem;
|
||||||
|
|
||||||
@@ -79,37 +199,99 @@ int QueueReminder(ParsePtr p, Trigger *trig,
|
|||||||
trig->noqueue ||
|
trig->noqueue ||
|
||||||
tim->ttime == NO_TIME ||
|
tim->ttime == NO_TIME ||
|
||||||
trig->typ == CAL_TYPE ||
|
trig->typ == CAL_TYPE ||
|
||||||
tim->ttime < SystemTime(0) / 60 ||
|
tim->ttime < MinutesPastMidnight(0) ||
|
||||||
((trig->typ == RUN_TYPE) && RunDisabled)) return OK;
|
((trig->typ == RUN_TYPE) && RunDisabled)) return OK;
|
||||||
|
|
||||||
qelem = NEW(QueuedRem);
|
qelem = NEW(QueuedRem);
|
||||||
if (!qelem) {
|
if (!qelem) {
|
||||||
return E_NO_MEM;
|
return E_NO_MEM;
|
||||||
}
|
}
|
||||||
|
qelem->red = DefaultColorR;
|
||||||
|
qelem->green = DefaultColorG;
|
||||||
|
qelem->blue = DefaultColorB;
|
||||||
qelem->text = StrDup(p->pos); /* Guaranteed that parser is not nested. */
|
qelem->text = StrDup(p->pos); /* Guaranteed that parser is not nested. */
|
||||||
if (!qelem->text) {
|
if (!qelem->text) {
|
||||||
free(qelem);
|
free(qelem);
|
||||||
return E_NO_MEM;
|
return E_NO_MEM;
|
||||||
}
|
}
|
||||||
|
qelem->fname = QueueFilename(FileName);
|
||||||
|
if (!qelem->fname) {
|
||||||
|
free((void *) qelem->text);
|
||||||
|
free(qelem);
|
||||||
|
return E_NO_MEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
qelem->lineno = LineNo;
|
||||||
NumQueued++;
|
NumQueued++;
|
||||||
qelem->typ = trig->typ;
|
qelem->typ = trig->typ;
|
||||||
strcpy(qelem->passthru, trig->passthru);
|
strcpy(qelem->passthru, trig->passthru);
|
||||||
qelem->tt = *tim;
|
qelem->tt = *tim;
|
||||||
qelem->t = *trig;
|
qelem->t = *trig;
|
||||||
DBufInit(&(qelem->t.tags));
|
DBufInit(&(qelem->t.tags));
|
||||||
|
DBufPuts(&(qelem->t.tags), DBufValue(&(trig->tags)));
|
||||||
|
if (SynthesizeTags) {
|
||||||
|
AppendTag(&(qelem->t.tags), SynthesizeTag());
|
||||||
|
}
|
||||||
qelem->next = QueueHead;
|
qelem->next = QueueHead;
|
||||||
qelem->RunDisabled = RunDisabled;
|
qelem->RunDisabled = RunDisabled;
|
||||||
qelem->ntrig = 0;
|
qelem->ntrig = 0;
|
||||||
strcpy(qelem->sched, sched);
|
strcpy(qelem->sched, sched);
|
||||||
DBufInit(&(qelem->tags));
|
|
||||||
DBufPuts(&(qelem->tags), DBufValue(&(trig->tags)));
|
|
||||||
if (SynthesizeTags) {
|
|
||||||
AppendTag(&(qelem->tags), SynthesizeTag());
|
|
||||||
}
|
|
||||||
QueueHead = qelem;
|
QueueHead = qelem;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
maybe_close(int fd)
|
||||||
|
{
|
||||||
|
int new_fd;
|
||||||
|
/* Don't close descriptors connected to a TTY, except for stdin */
|
||||||
|
if (fd && isatty(fd)) return;
|
||||||
|
|
||||||
|
(void) close(fd);
|
||||||
|
if (fd != STDIN_FILENO) {
|
||||||
|
new_fd = open("/dev/null", O_WRONLY);
|
||||||
|
} else {
|
||||||
|
new_fd = open("/dev/null", O_RDONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the open failed... well... not much we can do */
|
||||||
|
if (new_fd < 0) return;
|
||||||
|
|
||||||
|
/* If we got back the same fd as what we just closed, aces! */
|
||||||
|
if (fd == new_fd) return;
|
||||||
|
|
||||||
|
(void) dup2(new_fd, fd);
|
||||||
|
(void) close(new_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SigContHandler(int d)
|
||||||
|
{
|
||||||
|
UNUSED(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_num_queued(void)
|
||||||
|
{
|
||||||
|
int nqueued = 0;
|
||||||
|
QueuedRem *q = QueueHead;
|
||||||
|
while(q) {
|
||||||
|
if (q->tt.nexttime != NO_TIME) {
|
||||||
|
nqueued++;
|
||||||
|
}
|
||||||
|
q = q->next;
|
||||||
|
}
|
||||||
|
if (DaemonJSON) {
|
||||||
|
printf("{");
|
||||||
|
PrintJSONKeyPairString("response", "queued");
|
||||||
|
PrintJSONKeyPairInt("nqueued", nqueued);
|
||||||
|
printf("\"command\":\"STATUS\"}\n");
|
||||||
|
} else {
|
||||||
|
printf("NOTE queued %d\n", nqueued);
|
||||||
|
}
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* HandleQueuedReminders */
|
/* HandleQueuedReminders */
|
||||||
@@ -123,17 +305,26 @@ void HandleQueuedReminders(void)
|
|||||||
int TimeToSleep;
|
int TimeToSleep;
|
||||||
unsigned SleepTime;
|
unsigned SleepTime;
|
||||||
Parser p;
|
Parser p;
|
||||||
Trigger trig;
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct timeval sleep_tv;
|
struct timeval sleep_tv;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
char qid[64];
|
||||||
|
|
||||||
/* Suppress the BANNER from being issued */
|
/* Disable any potential pending SIGALRMs */
|
||||||
DidMsgReminder = 1;
|
alarm(0);
|
||||||
|
|
||||||
|
/* Un-limit execution time */
|
||||||
|
unlimit_execution_time();
|
||||||
|
|
||||||
/* Turn off sorting -- otherwise, TriggerReminder has no effect! */
|
/* Turn off sorting -- otherwise, TriggerReminder has no effect! */
|
||||||
SortByDate = 0;
|
SortByDate = 0;
|
||||||
|
|
||||||
|
/* Free FileName if necessary */
|
||||||
|
if (FileName) {
|
||||||
|
free(FileName);
|
||||||
|
FileName = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we are not connected to a tty, then we must close the
|
/* If we are not connected to a tty, then we must close the
|
||||||
* standard file descriptors. This is to prevent someone
|
* standard file descriptors. This is to prevent someone
|
||||||
* doing:
|
* doing:
|
||||||
@@ -143,9 +334,10 @@ void HandleQueuedReminders(void)
|
|||||||
* processed correctly are RUN commands, provided they mail
|
* processed correctly are RUN commands, provided they mail
|
||||||
* the result back or use their own resource (as a window).
|
* the result back or use their own resource (as a window).
|
||||||
*/
|
*/
|
||||||
if (!DontFork && (!isatty(1) || !isatty(2))) {
|
if (ShouldFork) {
|
||||||
close(1);
|
maybe_close(STDIN_FILENO);
|
||||||
close(2);
|
maybe_close(STDOUT_FILENO);
|
||||||
|
maybe_close(STDERR_FILENO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're a daemon, get the mod time of initial file */
|
/* If we're a daemon, get the mod time of initial file */
|
||||||
@@ -160,17 +352,23 @@ void HandleQueuedReminders(void)
|
|||||||
/* Initialize the queue - initialize all the entries time of issue */
|
/* Initialize the queue - initialize all the entries time of issue */
|
||||||
|
|
||||||
while (q) {
|
while (q) {
|
||||||
q->tt.nexttime = (int) (SystemTime(1)/60 - 1);
|
q->tt.nexttime = MinutesPastMidnight(1) - 1;
|
||||||
q->tt.nexttime = CalculateNextTime(q);
|
q->tt.nexttime = CalculateNextTime(q);
|
||||||
q = q->next;
|
q = q->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DontFork || Daemon) {
|
if (ShouldFork || Daemon) {
|
||||||
sa.sa_handler = SigIntHandler;
|
sa.sa_handler = SigIntHandler;
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = SA_RESTART;
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
(void) sigaction(SIGINT, &sa, NULL);
|
(void) sigaction(SIGINT, &sa, NULL);
|
||||||
|
sa.sa_handler = SigContHandler;
|
||||||
|
(void) sigaction(SIGCONT, &sa, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_INOTIFY
|
||||||
|
watch_fd = setup_inotify_watch();
|
||||||
|
#endif
|
||||||
/* Sit in a loop, issuing reminders when necessary */
|
/* Sit in a loop, issuing reminders when necessary */
|
||||||
while(1) {
|
while(1) {
|
||||||
q = FindNextReminder();
|
q = FindNextReminder();
|
||||||
@@ -179,7 +377,7 @@ void HandleQueuedReminders(void)
|
|||||||
if (!q && !Daemon) break;
|
if (!q && !Daemon) break;
|
||||||
|
|
||||||
if (Daemon && !q) {
|
if (Daemon && !q) {
|
||||||
if (Daemon < 0) {
|
if (IsServerMode()) {
|
||||||
/* Sleep until midnight */
|
/* Sleep until midnight */
|
||||||
TimeToSleep = MINUTES_PER_DAY*60 - SystemTime(1);
|
TimeToSleep = MINUTES_PER_DAY*60 - SystemTime(1);
|
||||||
} else {
|
} else {
|
||||||
@@ -196,9 +394,7 @@ void HandleQueuedReminders(void)
|
|||||||
SleepTime = 60*Daemon;
|
SleepTime = 60*Daemon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wake up once a minute to recalibrate sleep time in
|
if (IsServerMode()) {
|
||||||
case of laptop hibernation */
|
|
||||||
if (Daemon < 0) {
|
|
||||||
/* Wake up on the next exact minute */
|
/* Wake up on the next exact minute */
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
sleep_tv.tv_sec = 60 - (tv.tv_sec % 60);
|
sleep_tv.tv_sec = 60 - (tv.tv_sec % 60);
|
||||||
@@ -208,7 +404,9 @@ void HandleQueuedReminders(void)
|
|||||||
} else {
|
} else {
|
||||||
sleep_tv.tv_usec = 0;
|
sleep_tv.tv_usec = 0;
|
||||||
}
|
}
|
||||||
DaemonWait(&sleep_tv);
|
ServerWait(&sleep_tv);
|
||||||
|
/* A DEL command might have deleted our queued reminder! */
|
||||||
|
q = FindNextReminder();
|
||||||
} else {
|
} else {
|
||||||
sleep(SleepTime);
|
sleep(SleepTime);
|
||||||
}
|
}
|
||||||
@@ -222,14 +420,16 @@ void HandleQueuedReminders(void)
|
|||||||
if (!Daemon) {
|
if (!Daemon) {
|
||||||
int y, m, d;
|
int y, m, d;
|
||||||
if (RealToday != SystemDate(&y, &m, &d)) {
|
if (RealToday != SystemDate(&y, &m, &d)) {
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Daemon > 0 && SleepTime) CheckInitialFile();
|
if (Daemon > 0 && SleepTime) {
|
||||||
|
CheckInitialFile();
|
||||||
|
}
|
||||||
|
|
||||||
if (Daemon && !q) {
|
if (Daemon && !q) {
|
||||||
if (Daemon < 0) {
|
if (IsServerMode()) {
|
||||||
/* Sleep until midnight */
|
/* Sleep until midnight */
|
||||||
TimeToSleep = MINUTES_PER_DAY*60 - SystemTime(1);
|
TimeToSleep = MINUTES_PER_DAY*60 - SystemTime(1);
|
||||||
} else {
|
} else {
|
||||||
@@ -244,31 +444,60 @@ void HandleQueuedReminders(void)
|
|||||||
/* Do NOT trigger the reminder if tt.nexttime is more than a
|
/* Do NOT trigger the reminder if tt.nexttime is more than a
|
||||||
minute in the past. This can happen if the clock is
|
minute in the past. This can happen if the clock is
|
||||||
changed or a laptop awakes from hibernation.
|
changed or a laptop awakes from hibernation.
|
||||||
However, DO trigger if tt.nexttime == tt.ttime so all
|
However, DO trigger if tt.nexttime == tt.ttime and we're
|
||||||
|
within MaxLateTrigger minutes so all
|
||||||
queued reminders are triggered at least once. */
|
queued reminders are triggered at least once. */
|
||||||
if ((SystemTime(1) - (q->tt.nexttime * 60) <= 60) ||
|
if ((SystemTime(1) - (q->tt.nexttime * 60) <= 60) ||
|
||||||
(q->tt.nexttime == q->tt.ttime)) {
|
(q->tt.nexttime == q->tt.ttime &&
|
||||||
|
(MaxLateMinutes == 0 || SystemTime(1) - (q->tt.nexttime * 60) <= 60 * MaxLateMinutes))) {
|
||||||
/* Trigger the reminder */
|
/* Trigger the reminder */
|
||||||
CreateParser(q->text, &p);
|
CreateParser(q->text, &p);
|
||||||
trig.typ = q->typ;
|
|
||||||
strcpy(trig.passthru, q->passthru);
|
|
||||||
RunDisabled = q->RunDisabled;
|
RunDisabled = q->RunDisabled;
|
||||||
if (Daemon < 0) {
|
if (IsServerMode() && q->typ != RUN_TYPE) {
|
||||||
printf("NOTE reminder %s",
|
if (DaemonJSON) {
|
||||||
SimpleTime(q->tt.ttime));
|
printf("{\"response\":\"reminder\",");
|
||||||
printf("%s", SimpleTime(SystemTime(1)/60));
|
snprintf(qid, sizeof(qid), "%lx", (unsigned long) q);
|
||||||
if (!*DBufValue(&q->tags)) {
|
PrintJSONKeyPairString("qid", qid);
|
||||||
printf("*\n");
|
PrintJSONKeyPairString("ttime", SimpleTimeNoSpace(q->tt.ttime));
|
||||||
} else {
|
PrintJSONKeyPairString("now", SimpleTimeNoSpace(MinutesPastMidnight(1)));
|
||||||
printf("%s\n", DBufValue(&(q->tags)));
|
PrintJSONKeyPairString("tags", DBufValue(&q->t.tags));
|
||||||
}
|
} else {
|
||||||
|
printf("NOTE reminder %s",
|
||||||
|
SimpleTime(q->tt.ttime));
|
||||||
|
printf("%s", SimpleTime(MinutesPastMidnight(1)));
|
||||||
|
if (!*DBufValue(&q->t.tags)) {
|
||||||
|
printf("*\n");
|
||||||
|
} else {
|
||||||
|
printf("%s\n", DBufValue(&(q->t.tags)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up global variables so some functions like trigdate()
|
/* Set up global variables so some functions like trigdate()
|
||||||
and trigtime() work correctly */
|
and trigtime() work correctly */
|
||||||
SaveAllTriggerInfo(&(q->t), &(q->tt), DSEToday, q->tt.ttime, 1);
|
SaveAllTriggerInfo(&(q->t), &(q->tt), DSEToday, q->tt.ttime, 1);
|
||||||
(void) TriggerReminder(&p, &trig, &q->tt, DSEToday);
|
FileName = (char *) q->fname;
|
||||||
if (Daemon < 0) {
|
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, &tcopy, &q->tt, DSEToday, 1, &out);
|
||||||
|
if (q->typ != RUN_TYPE) {
|
||||||
|
printf("\"body\":\"");
|
||||||
|
chomp(&out);
|
||||||
|
PrintJSONString(DBufValue(&out));
|
||||||
|
printf("\"}\n");
|
||||||
|
}
|
||||||
|
DBufFree(&out);
|
||||||
|
} else {
|
||||||
|
(void) TriggerReminder(&p, &tcopy, &q->tt, DSEToday, 1, NULL);
|
||||||
|
}
|
||||||
|
FileName = NULL;
|
||||||
|
if (IsServerMode() && !DaemonJSON && q->typ != RUN_TYPE) {
|
||||||
printf("NOTE endreminder\n");
|
printf("NOTE endreminder\n");
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@@ -277,8 +506,26 @@ void HandleQueuedReminders(void)
|
|||||||
|
|
||||||
/* Calculate the next trigger time */
|
/* Calculate the next trigger time */
|
||||||
q->tt.nexttime = CalculateNextTime(q);
|
q->tt.nexttime = CalculateNextTime(q);
|
||||||
|
|
||||||
|
if (q->tt.nexttime != NO_TIME) {
|
||||||
|
/* If trigger time is way in the past because computer has been
|
||||||
|
suspended or hibernated, remove from queue */
|
||||||
|
if (q->tt.ttime < MinutesPastMidnight(1) - MaxLateMinutes &&
|
||||||
|
q->tt.nexttime < MinutesPastMidnight(1) - MaxLateMinutes) {
|
||||||
|
q->tt.nexttime = NO_TIME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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(0);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -396,7 +643,25 @@ static void CheckInitialFile(void)
|
|||||||
/* If date has rolled around, or file has changed, spawn a new version. */
|
/* If date has rolled around, or file has changed, spawn a new version. */
|
||||||
time_t tim = FileModTime;
|
time_t tim = FileModTime;
|
||||||
int y, m, d;
|
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 (stat(InitialFile, &StatBuf) == 0) tim = StatBuf.st_mtime;
|
||||||
if (tim != FileModTime ||
|
if (tim != FileModTime ||
|
||||||
RealToday != SystemDate(&y, &m, &d)) {
|
RealToday != SystemDate(&y, &m, &d)) {
|
||||||
@@ -474,7 +739,11 @@ static void
|
|||||||
json_queue(QueuedRem const *q)
|
json_queue(QueuedRem const *q)
|
||||||
{
|
{
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
if (DaemonJSON) {
|
||||||
|
printf("{\"response\":\"queue\",\"queue\":");
|
||||||
|
}
|
||||||
printf("[");
|
printf("[");
|
||||||
|
char idbuf[64];
|
||||||
while(q) {
|
while(q) {
|
||||||
if (q->tt.nexttime == NO_TIME) {
|
if (q->tt.nexttime == NO_TIME) {
|
||||||
q = q->next;
|
q = q->next;
|
||||||
@@ -485,6 +754,14 @@ json_queue(QueuedRem const *q)
|
|||||||
}
|
}
|
||||||
done = 1;
|
done = 1;
|
||||||
printf("{");
|
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);
|
||||||
|
PrintJSONKeyPairInt("lineno", q->lineno);
|
||||||
switch(q->typ) {
|
switch(q->typ) {
|
||||||
case NO_TYPE: PrintJSONKeyPairString("type", "NO_TYPE"); break;
|
case NO_TYPE: PrintJSONKeyPairString("type", "NO_TYPE"); break;
|
||||||
case MSG_TYPE: PrintJSONKeyPairString("type", "MSG_TYPE"); break;
|
case MSG_TYPE: PrintJSONKeyPairString("type", "MSG_TYPE"); break;
|
||||||
@@ -494,29 +771,12 @@ json_queue(QueuedRem const *q)
|
|||||||
case PS_TYPE: PrintJSONKeyPairString("type", "PS_TYPE"); break;
|
case PS_TYPE: PrintJSONKeyPairString("type", "PS_TYPE"); break;
|
||||||
case PSF_TYPE: PrintJSONKeyPairString("type", "PSF_TYPE"); break;
|
case PSF_TYPE: PrintJSONKeyPairString("type", "PSF_TYPE"); break;
|
||||||
case MSF_TYPE: PrintJSONKeyPairString("type", "MSF_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;
|
default: PrintJSONKeyPairString("type", "?"); break;
|
||||||
}
|
}
|
||||||
PrintJSONKeyPairInt("rundisabled", q->RunDisabled);
|
|
||||||
PrintJSONKeyPairInt("ntrig", q->ntrig);
|
|
||||||
PrintJSONKeyPairTime("ttime", q->tt.ttime);
|
|
||||||
PrintJSONKeyPairTime("nextttime", q->tt.nexttime);
|
|
||||||
PrintJSONKeyPairInt("delta", q->tt.delta);
|
|
||||||
if (q->tt.rep != NO_TIME) {
|
|
||||||
PrintJSONKeyPairInt("rep", q->tt.rep);
|
|
||||||
}
|
|
||||||
if (q->tt.duration != NO_TIME) {
|
|
||||||
PrintJSONKeyPairInt("duration", q->tt.duration);
|
|
||||||
}
|
|
||||||
if (q->passthru[0]) {
|
|
||||||
PrintJSONKeyPairString("passthru", q->passthru);
|
|
||||||
}
|
|
||||||
if (q->sched[0]) {
|
|
||||||
PrintJSONKeyPairString("sched", q->sched);
|
|
||||||
}
|
|
||||||
if (DBufLen(&(q->tags))) {
|
|
||||||
PrintJSONKeyPairString("tags", DBufValue(&(q->tags)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Last one is a special case - no trailing comma */
|
/* Last one is a special case - no trailing comma */
|
||||||
printf("\"");
|
printf("\"");
|
||||||
@@ -530,30 +790,48 @@ json_queue(QueuedRem const *q)
|
|||||||
printf("\"}");
|
printf("\"}");
|
||||||
q = q->next;
|
q = q->next;
|
||||||
}
|
}
|
||||||
printf("]\n");
|
printf("]");
|
||||||
|
if (DaemonJSON) {
|
||||||
|
printf(",\"command\":\"QUEUE\"}\n");
|
||||||
|
} else {
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* 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;
|
fd_set readSet;
|
||||||
int retval;
|
int retval;
|
||||||
int y, m, d;
|
int y, m, d;
|
||||||
|
int max = 1;
|
||||||
char cmdLine[256];
|
char cmdLine[256];
|
||||||
|
|
||||||
FD_ZERO(&readSet);
|
FD_ZERO(&readSet);
|
||||||
FD_SET(0, &readSet);
|
FD_SET(0, &readSet);
|
||||||
retval = select(1, &readSet, NULL, NULL, sleep_tv);
|
|
||||||
|
#ifdef USE_INOTIFY
|
||||||
|
if (watch_fd >= 0) {
|
||||||
|
FD_SET(watch_fd, &readSet);
|
||||||
|
if (watch_fd > max-1)
|
||||||
|
max = watch_fd+1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
retval = select(max, &readSet, NULL, NULL, sleep_tv);
|
||||||
|
|
||||||
/* If date has rolled around, restart */
|
/* If date has rolled around, restart */
|
||||||
if (RealToday != SystemDate(&y, &m, &d)) {
|
if (RealToday != SystemDate(&y, &m, &d)) {
|
||||||
printf("NOTE newdate\nNOTE reread\n");
|
if (DaemonJSON) {
|
||||||
|
printf("{\"response\":\"newdate\"}\n{\"response\":\"reread\",\"command\":\"newdate\"}\n");
|
||||||
|
} else {
|
||||||
|
printf("NOTE newdate\nNOTE reread\n");
|
||||||
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
reread();
|
reread();
|
||||||
}
|
}
|
||||||
@@ -561,70 +839,108 @@ static void DaemonWait(struct timeval *sleep_tv)
|
|||||||
/* If nothing readable or interrupted system call, return */
|
/* If nothing readable or interrupted system call, return */
|
||||||
if (retval <= 0) return;
|
if (retval <= 0) return;
|
||||||
|
|
||||||
|
/* If inotify watch descriptor is readable, handle it */
|
||||||
|
#ifdef USE_INOTIFY
|
||||||
|
if (watch_fd >= 0) {
|
||||||
|
if (FD_ISSET(watch_fd, &readSet)) {
|
||||||
|
consume_inotify_events(watch_fd);
|
||||||
|
if (DaemonJSON) {
|
||||||
|
printf("{\"response\":\"reread\",\"command\":\"inotify\"}\n");
|
||||||
|
} else {
|
||||||
|
/* In deprecated server mode, we need to spit out
|
||||||
|
a NOTE newdate to force the front-end to redraw
|
||||||
|
the calendar */
|
||||||
|
printf("NOTE newdate\nNOTE reread\n");
|
||||||
|
}
|
||||||
|
fflush(stdout);
|
||||||
|
reread();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* If stdin not readable, return */
|
/* If stdin not readable, return */
|
||||||
if (!FD_ISSET(0, &readSet)) return;
|
if (!FD_ISSET(0, &readSet)) return;
|
||||||
|
|
||||||
/* If EOF on stdin, exit */
|
/* If EOF on stdin, exit */
|
||||||
if (feof(stdin)) {
|
if (feof(stdin)) {
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read a line from stdin and interpret it */
|
/* Read a line from stdin and interpret it */
|
||||||
if (!fgets(cmdLine, sizeof(cmdLine), stdin)) {
|
if (!fgets(cmdLine, sizeof(cmdLine), stdin)) {
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(cmdLine, "EXIT\n")) {
|
if (!strcmp(cmdLine, "EXIT\n")) {
|
||||||
exit(0);
|
exit(EXIT_SUCCESS);
|
||||||
} else if (!strcmp(cmdLine, "STATUS\n")) {
|
} else if (!strcmp(cmdLine, "STATUS\n")) {
|
||||||
int nqueued = 0;
|
print_num_queued();
|
||||||
QueuedRem *q = QueueHead;
|
|
||||||
while(q) {
|
|
||||||
if (q->tt.nexttime != NO_TIME) {
|
|
||||||
nqueued++;
|
|
||||||
}
|
|
||||||
q = q->next;
|
|
||||||
}
|
|
||||||
printf("NOTE queued %d\n", nqueued);
|
|
||||||
fflush(stdout);
|
|
||||||
} else if (!strcmp(cmdLine, "QUEUE\n")) {
|
} else if (!strcmp(cmdLine, "QUEUE\n")) {
|
||||||
printf("NOTE queue\n");
|
if (DaemonJSON) {
|
||||||
QueuedRem *q = QueueHead;
|
json_queue(QueueHead);
|
||||||
while (q) {
|
} else {
|
||||||
if (q->tt.nexttime != NO_TIME) {
|
printf("NOTE queue\n");
|
||||||
switch (q->typ) {
|
QueuedRem *q = QueueHead;
|
||||||
case NO_TYPE: printf("NO_TYPE "); break;
|
while (q) {
|
||||||
case MSG_TYPE: printf("MSG_TYPE "); break;
|
if (q->tt.nexttime != NO_TIME) {
|
||||||
case RUN_TYPE: printf("RUN_TYPE "); break;
|
switch (q->typ) {
|
||||||
case CAL_TYPE: printf("CAL_TYPE "); break;
|
case NO_TYPE: printf("NO_TYPE"); break;
|
||||||
case SAT_TYPE: printf("SAT_TYPE "); break;
|
case MSG_TYPE: printf("MSG_TYPE"); break;
|
||||||
case PS_TYPE: printf("PS_TYPE "); break;
|
case RUN_TYPE: printf("RUN_TYPE"); break;
|
||||||
case PSF_TYPE: printf("PSF_TYPE "); break;
|
case CAL_TYPE: printf("CAL_TYPE"); break;
|
||||||
case MSF_TYPE: printf("MSF_TYPE "); break;
|
case SAT_TYPE: printf("SAT_TYPE"); break;
|
||||||
case PASSTHRU_TYPE: printf("PASSTHRU_TYPE "); break;
|
case PS_TYPE: printf("PS_TYPE"); break;
|
||||||
default: printf("? "); break;
|
case PSF_TYPE: printf("PSF_TYPE"); break;
|
||||||
}
|
case MSF_TYPE: printf("MSF_TYPE"); break;
|
||||||
printf("RunDisabled=%d ntrig=%d ttime=%02d:%02d nexttime=%02d:%02d delta=%d rep=%d duration=%d ", q->RunDisabled, q->ntrig, q->tt.ttime/60, q->tt.ttime % 60, q->tt.nexttime / 60, q->tt.nexttime % 60, q->tt.delta, (q->tt.rep != NO_TIME ? q->tt.rep : -1), (q->tt.duration != NO_TIME ? q->tt.duration : -1));
|
case PASSTHRU_TYPE: printf("PASSTHRU_TYPE"); break;
|
||||||
printf("%s %s %s\n",
|
default: printf("?"); break;
|
||||||
(q->passthru[0] ? q->passthru : "*"),
|
}
|
||||||
(q->sched[0] ? q->sched : "*"),
|
printf(" RunDisabled=%d ntrig=%d ttime=%02d:%02d nexttime=%02d:%02d delta=%d rep=%d duration=%d ", q->RunDisabled, q->ntrig, q->tt.ttime/60, q->tt.ttime % 60, q->tt.nexttime / 60, q->tt.nexttime % 60, q->tt.delta, (q->tt.rep != NO_TIME ? q->tt.rep : -1), (q->tt.duration != NO_TIME ? q->tt.duration : -1));
|
||||||
q->text ? q->text : "NULL");
|
printf("%s %s %s\n",
|
||||||
|
(q->passthru[0] ? q->passthru : "*"),
|
||||||
|
(q->sched[0] ? q->sched : "*"),
|
||||||
|
q->text ? q->text : "NULL");
|
||||||
|
}
|
||||||
|
q = q->next;
|
||||||
}
|
}
|
||||||
q = q->next;
|
printf("NOTE endqueue\n");
|
||||||
}
|
}
|
||||||
printf("NOTE endqueue\n");
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
} else if (!strcmp(cmdLine, "JSONQUEUE\n")) {
|
} else if (!strcmp(cmdLine, "JSONQUEUE\n")) {
|
||||||
printf("NOTE JSONQUEUE\n");
|
if (!DaemonJSON) {
|
||||||
|
printf("NOTE JSONQUEUE\n");
|
||||||
|
}
|
||||||
json_queue(QueueHead);
|
json_queue(QueueHead);
|
||||||
printf("NOTE ENDJSONQUEUE\n");
|
if (!DaemonJSON) {
|
||||||
|
printf("NOTE ENDJSONQUEUE\n");
|
||||||
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
} else if (!strcmp(cmdLine, "REREAD\n")) {
|
} else if (!strcmp(cmdLine, "REREAD\n")) {
|
||||||
printf("NOTE reread\n");
|
if (DaemonJSON) {
|
||||||
|
printf("{\"response\":\"reread\",\"command\":\"REREAD\"}\n");
|
||||||
|
} else {
|
||||||
|
printf("NOTE reread\n");
|
||||||
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
reread();
|
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 {
|
} else {
|
||||||
printf("ERR Invalid daemon command: %s", cmdLine);
|
if (DaemonJSON) {
|
||||||
|
size_t l = strlen(cmdLine);
|
||||||
|
if (l && cmdLine[l-1] == '\n') {
|
||||||
|
cmdLine[l-1] = 0;
|
||||||
|
}
|
||||||
|
printf("{\"response\":\"error\",\"error\":\"Unknown command\",\"command\":\"");
|
||||||
|
PrintJSONString(cmdLine);
|
||||||
|
printf("\"}\n");
|
||||||
|
} else {
|
||||||
|
printf("ERR Invalid daemon command: %s", cmdLine);
|
||||||
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -641,3 +957,56 @@ static void reread(void)
|
|||||||
execvp(ArgV[0], (char **) ArgV);
|
execvp(ArgV[0], (char **) ArgV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_INOTIFY
|
||||||
|
static void consume_inotify_events(int fd)
|
||||||
|
{
|
||||||
|
char buf[sizeof(struct inotify_event) + NAME_MAX + 1];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
struct timespec sleeptime;
|
||||||
|
|
||||||
|
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;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int setup_inotify_watch(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
/* Don't inotify_watch stdin */
|
||||||
|
if (!strcmp(InitialFile, "-")) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
|
||||||
|
if (fd < 0) {
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
if (inotify_add_watch(fd, InitialFile, IN_CLOSE_WRITE | IN_CREATE | IN_DELETE | IN_MODIFY | IN_MOVED_FROM | IN_MOVED_TO) < 0) {
|
||||||
|
close(fd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
34
src/rem2ps.c
34
src/rem2ps.c
@@ -5,7 +5,7 @@
|
|||||||
/* Print a PostScript calendar. */
|
/* Print a PostScript calendar. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -186,19 +186,19 @@ JSONToCalEntry(DynamicBuffer *buf)
|
|||||||
val = json_parse(DBufValue(buf), DBufLen(buf));
|
val = json_parse(DBufValue(buf), DBufLen(buf));
|
||||||
if (!val) {
|
if (!val) {
|
||||||
fprintf(stderr, "Unable to parse JSON line `%s'\n", DBufValue(buf));
|
fprintf(stderr, "Unable to parse JSON line `%s'\n", DBufValue(buf));
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val->type != json_object) {
|
if (val->type != json_object) {
|
||||||
fprintf(stderr, "Expecting JSON object; found `%s'\n",
|
fprintf(stderr, "Expecting JSON object; found `%s'\n",
|
||||||
DBufValue(buf));
|
DBufValue(buf));
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = NEW(CalEntry);
|
c = NEW(CalEntry);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
fprintf(stderr, "malloc failed - aborting.\n");
|
fprintf(stderr, "malloc failed - aborting.\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
c->next = NULL;
|
c->next = NULL;
|
||||||
c->special = SPECIAL_NORMAL;
|
c->special = SPECIAL_NORMAL;
|
||||||
@@ -221,7 +221,7 @@ JSONToCalEntry(DynamicBuffer *buf)
|
|||||||
c->entry = malloc(strlen(s)+1);
|
c->entry = malloc(strlen(s)+1);
|
||||||
if (!c->entry) {
|
if (!c->entry) {
|
||||||
fprintf(stderr, "malloc failed - aborting.\n");
|
fprintf(stderr, "malloc failed - aborting.\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
strcpy(c->entry, s);
|
strcpy(c->entry, s);
|
||||||
got_body = 1;
|
got_body = 1;
|
||||||
@@ -253,7 +253,7 @@ JSONToCalEntry(DynamicBuffer *buf)
|
|||||||
|
|
||||||
if (!got_body || !got_date) {
|
if (!got_body || !got_date) {
|
||||||
fprintf(stderr, "Could not parse line `%s'\n", DBufValue(buf));
|
fprintf(stderr, "Could not parse line `%s'\n", DBufValue(buf));
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ TextToCalEntry(DynamicBuffer *buf)
|
|||||||
CalEntry *c = NEW(CalEntry);
|
CalEntry *c = NEW(CalEntry);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
fprintf(stderr, "malloc failed - aborting.\n");
|
fprintf(stderr, "malloc failed - aborting.\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
c->next = NULL;
|
c->next = NULL;
|
||||||
c->special = SPECIAL_NORMAL;
|
c->special = SPECIAL_NORMAL;
|
||||||
@@ -296,7 +296,7 @@ TextToCalEntry(DynamicBuffer *buf)
|
|||||||
c->entry = malloc(strlen(startOfBody) + 1);
|
c->entry = malloc(strlen(startOfBody) + 1);
|
||||||
if (!c->entry) {
|
if (!c->entry) {
|
||||||
fprintf(stderr, "malloc failed - aborting.\n");
|
fprintf(stderr, "malloc failed - aborting.\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
strcpy(c->entry, startOfBody);
|
strcpy(c->entry, startOfBody);
|
||||||
|
|
||||||
@@ -343,14 +343,14 @@ int main(int argc, char *argv[])
|
|||||||
DBufGets(&buf, stdin);
|
DBufGets(&buf, stdin);
|
||||||
if (first_line && (!strcmp(DBufValue(&buf), "["))) {
|
if (first_line && (!strcmp(DBufValue(&buf), "["))) {
|
||||||
fprintf(stderr, "Rem2PS: It appears that you have invoked Remind with the -ppp option.\n Please use either -p or -pp, but not -ppp.\n");
|
fprintf(stderr, "Rem2PS: It appears that you have invoked Remind with the -ppp option.\n Please use either -p or -pp, but not -ppp.\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
first_line = 0;
|
first_line = 0;
|
||||||
if (!strcmp(DBufValue(&buf), PSBEGIN) ||
|
if (!strcmp(DBufValue(&buf), PSBEGIN) ||
|
||||||
!strcmp(DBufValue(&buf), PSBEGIN2)) {
|
!strcmp(DBufValue(&buf), PSBEGIN2)) {
|
||||||
if (!validfile) {
|
if (!validfile) {
|
||||||
if (Verbose) {
|
if (Verbose) {
|
||||||
fprintf(stderr, "Rem2PS: Version %s Copyright 1992-2023 by Dianne Skoll\n\n", VERSION);
|
fprintf(stderr, "Rem2PS: Version %s Copyright 1992-2024 by Dianne Skoll\n\n", VERSION);
|
||||||
fprintf(stderr, "Generating PostScript calendar\n");
|
fprintf(stderr, "Generating PostScript calendar\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,7 +361,7 @@ int main(int argc, char *argv[])
|
|||||||
if (!validfile) {
|
if (!validfile) {
|
||||||
fprintf(stderr, "Rem2PS: Couldn't find any calendar data - are you\n");
|
fprintf(stderr, "Rem2PS: Couldn't find any calendar data - are you\n");
|
||||||
fprintf(stderr, " sure you fed me input produced by remind -p ...?\n");
|
fprintf(stderr, " sure you fed me input produced by remind -p ...?\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
printf("%%%%Trailer\n");
|
printf("%%%%Trailer\n");
|
||||||
printf("%%%%Pages: %d\n", validfile);
|
printf("%%%%Pages: %d\n", validfile);
|
||||||
@@ -390,7 +390,7 @@ void DoPsCal(void)
|
|||||||
month */
|
month */
|
||||||
DBufInit(&buf);
|
DBufInit(&buf);
|
||||||
DBufGets(&buf, stdin);
|
DBufGets(&buf, stdin);
|
||||||
sscanf(DBufValue(&buf), "%s %s %d %d %d", month, year, &days, &wkday,
|
sscanf(DBufValue(&buf), "%39s %39s %d %d %d", month, year, &days, &wkday,
|
||||||
&MondayFirst);
|
&MondayFirst);
|
||||||
|
|
||||||
/* Replace underscores in month name with spaces */
|
/* Replace underscores in month name with spaces */
|
||||||
@@ -422,9 +422,9 @@ void DoPsCal(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DBufGets(&buf, stdin);
|
DBufGets(&buf, stdin);
|
||||||
sscanf(DBufValue(&buf), "%s %d", prevm, &prevdays);
|
sscanf(DBufValue(&buf), "%39s %d", prevm, &prevdays);
|
||||||
DBufGets(&buf, stdin);
|
DBufGets(&buf, stdin);
|
||||||
sscanf(DBufValue(&buf), "%s %d", nextm, &nextdays);
|
sscanf(DBufValue(&buf), "%39s %d", nextm, &nextdays);
|
||||||
|
|
||||||
/* Replace underscores with spaces in names of next/prev month */
|
/* Replace underscores with spaces in names of next/prev month */
|
||||||
s = prevm;
|
s = prevm;
|
||||||
@@ -486,7 +486,7 @@ void DoPsCal(void)
|
|||||||
while(1) {
|
while(1) {
|
||||||
if (feof(stdin)) {
|
if (feof(stdin)) {
|
||||||
fprintf(stderr, "Input from REMIND is corrupt!\n");
|
fprintf(stderr, "Input from REMIND is corrupt!\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBufGets(&buf, stdin);
|
DBufGets(&buf, stdin);
|
||||||
@@ -952,7 +952,7 @@ void Init(int argc, char *argv[])
|
|||||||
fprintf(stderr, " WxHin Specify size in inches (W and H are decimal numbers)\n");
|
fprintf(stderr, " WxHin Specify size in inches (W and H are decimal numbers)\n");
|
||||||
fprintf(stderr, " WxHcm Specify size in centimetres (W and H are decimal numbers)\n");
|
fprintf(stderr, " WxHcm Specify size in centimetres (W and H are decimal numbers)\n");
|
||||||
fprintf(stderr, "Default media type is %s\n", DefaultPage[0].name);
|
fprintf(stderr, "Default media type is %s\n", DefaultPage[0].name);
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1033,7 +1033,7 @@ void Usage(char const *s)
|
|||||||
fprintf(stderr, "-e Make calendar fill entire page\n");
|
fprintf(stderr, "-e Make calendar fill entire page\n");
|
||||||
fprintf(stderr, "-x Put day numbers on left instead of right\n");
|
fprintf(stderr, "-x Put day numbers on left instead of right\n");
|
||||||
fprintf(stderr, "-o[lrtb] marg Specify left, right, top and bottom margins\n");
|
fprintf(stderr, "-o[lrtb] marg Specify left, right, top and bottom margins\n");
|
||||||
exit(1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/* Define the PostScript prologue */
|
/* Define the PostScript prologue */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -14,7 +14,7 @@ char *PSProlog1[] =
|
|||||||
{
|
{
|
||||||
"% This file was produced by Remind and Rem2PS, written by",
|
"% This file was produced by Remind and Rem2PS, written by",
|
||||||
"% Dianne Skoll.",
|
"% Dianne Skoll.",
|
||||||
"% Remind and Rem2PS are Copyright 1992-2023 Dianne Skoll.",
|
"% Remind and Rem2PS are Copyright 1992-2024 Dianne Skoll.",
|
||||||
"/ISOLatin1Encoding where { pop save true }{ false } ifelse",
|
"/ISOLatin1Encoding where { pop save true }{ false } ifelse",
|
||||||
" /ISOLatin1Encoding [ StandardEncoding 0 45 getinterval aload pop /minus",
|
" /ISOLatin1Encoding [ StandardEncoding 0 45 getinterval aload pop /minus",
|
||||||
" StandardEncoding 46 98 getinterval aload pop /dotlessi /grave /acute",
|
" StandardEncoding 46 98 getinterval aload pop /dotlessi /grave /acute",
|
||||||
|
|||||||
15
src/sort.c
15
src/sort.c
@@ -5,7 +5,7 @@
|
|||||||
/* Routines for sorting reminders by trigger date */
|
/* Routines for sorting reminders by trigger date */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "expr.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
|
|
||||||
@@ -135,8 +134,8 @@ void IssueSortedReminders(void)
|
|||||||
next = cur->next;
|
next = cur->next;
|
||||||
switch(cur->typ) {
|
switch(cur->typ) {
|
||||||
case MSG_TYPE:
|
case MSG_TYPE:
|
||||||
if (MsgCommand) {
|
if (MsgCommand && *MsgCommand) {
|
||||||
DoMsgCommand(MsgCommand, cur->text);
|
DoMsgCommand(MsgCommand, cur->text, 0);
|
||||||
} else {
|
} else {
|
||||||
if (cur->trigdate != olddate) {
|
if (cur->trigdate != olddate) {
|
||||||
IssueSortBanner(cur->trigdate);
|
IssueSortBanner(cur->trigdate);
|
||||||
@@ -147,11 +146,15 @@ void IssueSortedReminders(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSF_TYPE:
|
case MSF_TYPE:
|
||||||
FillParagraph(cur->text);
|
if (cur->trigdate != olddate) {
|
||||||
|
IssueSortBanner(cur->trigdate);
|
||||||
|
olddate = cur->trigdate;
|
||||||
|
}
|
||||||
|
FillParagraph(cur->text, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RUN_TYPE:
|
case RUN_TYPE:
|
||||||
System(cur->text);
|
System(cur->text, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* classifying the tokens parsed. */
|
/* classifying the tokens parsed. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -56,6 +56,7 @@ Token TokArray[] = {
|
|||||||
{ "endif", 5, T_EndIf, 0 },
|
{ "endif", 5, T_EndIf, 0 },
|
||||||
{ "errmsg", 6, T_ErrMsg, 0 },
|
{ "errmsg", 6, T_ErrMsg, 0 },
|
||||||
{ "exit", 4, T_Exit, 0 },
|
{ "exit", 4, T_Exit, 0 },
|
||||||
|
{ "expr", 4, T_Expr, 0 },
|
||||||
{ "february", 3, T_Month, 1 },
|
{ "february", 3, T_Month, 1 },
|
||||||
{ "first", 5, T_Ordinal, 0 },
|
{ "first", 5, T_Ordinal, 0 },
|
||||||
{ "flush", 5, T_Flush, 0 },
|
{ "flush", 5, T_Flush, 0 },
|
||||||
@@ -258,7 +259,6 @@ void FindNumericToken(char const *s, Token *t)
|
|||||||
/* If we hit a comma, swallow it. This allows stuff
|
/* If we hit a comma, swallow it. This allows stuff
|
||||||
like Jan 6, 1998 */
|
like Jan 6, 1998 */
|
||||||
if (*s == ',') {
|
if (*s == ',') {
|
||||||
s++;
|
|
||||||
/* Classify the number we've got */
|
/* Classify the number we've got */
|
||||||
if (t->val >= BASE && t->val <= BASE+YR_RANGE) t->type = T_Year;
|
if (t->val >= BASE && t->val <= BASE+YR_RANGE) t->type = T_Year;
|
||||||
else if (t->val >= 1 && t->val <= 31) t->type = T_Day;
|
else if (t->val >= 1 && t->val <= 31) t->type = T_Day;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
/* Routines for figuring out the trigger date of a reminder */
|
/* Routines for figuring out the trigger date of a reminder */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "expr.h"
|
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
@@ -72,7 +71,10 @@ static int NextSimpleTrig(int startdate, Trigger *trig, int *err)
|
|||||||
m++;
|
m++;
|
||||||
if (m == 12) { m = 0; y++; }
|
if (m == 12) { m = 0; y++; }
|
||||||
}
|
}
|
||||||
while (trig->d > DaysInMonth(m, trig->y)) m++;
|
while (trig->d > DaysInMonth(m, y)) {
|
||||||
|
m++;
|
||||||
|
if (m == 12) { m = 0; y++; }
|
||||||
|
}
|
||||||
j = DSE(y, m, trig->d);
|
j = DSE(y, m, trig->d);
|
||||||
return j;
|
return j;
|
||||||
|
|
||||||
@@ -241,6 +243,7 @@ static int NextSimpleTrig(int startdate, Trigger *trig, int *err)
|
|||||||
|
|
||||||
case GOT_WD+GOT_MON+GOT_YR:
|
case GOT_WD+GOT_MON+GOT_YR:
|
||||||
if (y > trig->y || (y == trig->y && m > trig->m)) return -1;
|
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)) {
|
if (trig->y > y || (trig->y == y && trig->m > m)) {
|
||||||
j = DSE(trig->y, trig->m, 1);
|
j = DSE(trig->y, trig->m, 1);
|
||||||
ADVANCE_TO_WD(j, trig->wd);
|
ADVANCE_TO_WD(j, trig->wd);
|
||||||
@@ -324,8 +327,11 @@ static int GetNextTriggerDate(Trigger *trig, int start, int *err, int *nextstart
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
start--;
|
start--;
|
||||||
|
if (start < 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (iter > MaxSatIter) {
|
if (start < 0 || iter > MaxSatIter) {
|
||||||
/* omitfunc must have returned "true" too often */
|
/* omitfunc must have returned "true" too often */
|
||||||
*err = E_CANT_TRIG;
|
*err = E_CANT_TRIG;
|
||||||
return -2;
|
return -2;
|
||||||
@@ -388,6 +394,10 @@ static int GetNextTriggerDate(Trigger *trig, int start, int *err, int *nextstart
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
simple--;
|
simple--;
|
||||||
|
if (simple < 0) {
|
||||||
|
*err = E_CANT_TRIG;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (iter > MaxSatIter) {
|
if (iter > MaxSatIter) {
|
||||||
*err = E_CANT_TRIG;
|
*err = E_CANT_TRIG;
|
||||||
@@ -622,12 +632,10 @@ int ComputeTriggerNoAdjustDuration(int today, Trigger *trig, TimeTrig *tim,
|
|||||||
fprintf(ErrFp, "%s(%d): %s\n",
|
fprintf(ErrFp, "%s(%d): %s\n",
|
||||||
FileName, LineNo, ErrMsg[E_EXPIRED]);
|
FileName, LineNo, ErrMsg[E_EXPIRED]);
|
||||||
}
|
}
|
||||||
if (result != -1) {
|
if (save_in_globals) {
|
||||||
if (save_in_globals) {
|
LastTriggerDate = result;
|
||||||
LastTriggerDate = result;
|
LastTrigValid = 1;
|
||||||
LastTrigValid = 1;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,12 +648,10 @@ int ComputeTriggerNoAdjustDuration(int today, Trigger *trig, TimeTrig *tim,
|
|||||||
|
|
||||||
/* Keep scanning... unless there's no point in doing it.*/
|
/* Keep scanning... unless there's no point in doing it.*/
|
||||||
if (nextstart <= start) {
|
if (nextstart <= start) {
|
||||||
if (result != -1) {
|
if (save_in_globals) {
|
||||||
if (save_in_globals) {
|
LastTriggerDate = result;
|
||||||
LastTriggerDate = result;
|
LastTrigValid = 1;
|
||||||
LastTrigValid = 1;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
trig->expired = 1;
|
trig->expired = 1;
|
||||||
if (DebugFlag & DB_PRTTRIG) {
|
if (DebugFlag & DB_PRTTRIG) {
|
||||||
fprintf(ErrFp, "%s(%d): %s\n",
|
fprintf(ErrFp, "%s(%d): %s\n",
|
||||||
@@ -662,40 +668,3 @@ int ComputeTriggerNoAdjustDuration(int today, Trigger *trig, TimeTrig *tim,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
|
||||||
/* */
|
|
||||||
/* ComputeScanStart */
|
|
||||||
/* */
|
|
||||||
/* Figure out where to start scan from by examining SCANFROM */
|
|
||||||
/* and DURATION */
|
|
||||||
/* */
|
|
||||||
/***************************************************************/
|
|
||||||
int
|
|
||||||
ComputeScanStart(int today, Trigger *trig, TimeTrig *tt)
|
|
||||||
{
|
|
||||||
int minutes, days;
|
|
||||||
|
|
||||||
/* If we don't have a time/duration, just use scanfrom */
|
|
||||||
if (tt->ttime == NO_TIME ||
|
|
||||||
tt->duration == NO_TIME) {
|
|
||||||
if (trig->scanfrom == NO_DATE) {
|
|
||||||
return today;
|
|
||||||
}
|
|
||||||
return trig->scanfrom;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calculate time-based SCANFROM */
|
|
||||||
minutes = tt->ttime + tt->duration - 1;
|
|
||||||
|
|
||||||
/* Figure out how many days to scan backwards from */
|
|
||||||
days = minutes / MINUTES_PER_DAY;
|
|
||||||
|
|
||||||
if (trig->scanfrom != NO_DATE) {
|
|
||||||
if (trig->scanfrom <= today - days) {
|
|
||||||
return trig->scanfrom;
|
|
||||||
} else {
|
|
||||||
return today - days;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return today - days;
|
|
||||||
}
|
|
||||||
|
|||||||
93
src/types.h
93
src/types.h
@@ -5,7 +5,7 @@
|
|||||||
/* Type definitions all dumped here. */
|
/* Type definitions all dumped here. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -13,6 +13,22 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include "dynbuf.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 */
|
/* Values */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char type;
|
char type;
|
||||||
@@ -22,29 +38,61 @@ typedef struct {
|
|||||||
} v;
|
} v;
|
||||||
} Value;
|
} Value;
|
||||||
|
|
||||||
/* Define the type of operators */
|
/* New-style expr_node structure and constants */
|
||||||
typedef struct {
|
enum expr_node_type
|
||||||
char const *name;
|
{
|
||||||
char prec;
|
N_FREE,
|
||||||
char type;
|
N_ERROR,
|
||||||
int (*func)(void);
|
N_CONSTANT,
|
||||||
} Operator;
|
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 */
|
/* Structure for passing in Nargs and out RetVal from functions */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int nargs;
|
int nargs;
|
||||||
|
Value *args;
|
||||||
Value retval;
|
Value retval;
|
||||||
} func_info;
|
} func_info;
|
||||||
|
|
||||||
|
/* Forward reference */
|
||||||
|
typedef struct expr_node_struct expr_node;
|
||||||
|
|
||||||
/* Define the type of user-functions */
|
/* Define the type of user-functions */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char const *name;
|
char const *name;
|
||||||
char minargs;
|
char minargs;
|
||||||
char maxargs;
|
char maxargs;
|
||||||
char is_constant;
|
char is_constant;
|
||||||
|
/* Old-style function calling convention */
|
||||||
int (*func)(func_info *);
|
int (*func)(func_info *);
|
||||||
|
|
||||||
|
/* New-style function calling convention */
|
||||||
|
int (*newfunc)(expr_node *node, Value *locals, Value *ans, int *nonconst);
|
||||||
} BuiltinFunc;
|
} 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 */
|
/* Define the structure of a variable */
|
||||||
typedef struct var {
|
typedef struct var {
|
||||||
struct var *next;
|
struct var *next;
|
||||||
@@ -142,6 +190,8 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */
|
|||||||
#define MSF_TYPE 7
|
#define MSF_TYPE 7
|
||||||
#define PASSTHRU_TYPE 8
|
#define PASSTHRU_TYPE 8
|
||||||
|
|
||||||
|
/* For function arguments */
|
||||||
|
#define NO_MAX 127
|
||||||
|
|
||||||
/* DEFINES for debugging flags */
|
/* DEFINES for debugging flags */
|
||||||
#define DB_PRTLINE 1
|
#define DB_PRTLINE 1
|
||||||
@@ -150,6 +200,7 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */
|
|||||||
#define DB_DUMP_VARS 8
|
#define DB_DUMP_VARS 8
|
||||||
#define DB_ECHO_LINE 16
|
#define DB_ECHO_LINE 16
|
||||||
#define DB_TRACE_FILES 32
|
#define DB_TRACE_FILES 32
|
||||||
|
#define DB_PARSE_EXPR 64
|
||||||
|
|
||||||
/* Enumeration of the tokens */
|
/* Enumeration of the tokens */
|
||||||
enum TokTypes
|
enum TokTypes
|
||||||
@@ -183,7 +234,8 @@ enum TokTypes
|
|||||||
T_MaybeUncomputable,
|
T_MaybeUncomputable,
|
||||||
T_Ordinal,
|
T_Ordinal,
|
||||||
T_In,
|
T_In,
|
||||||
T_LastBack
|
T_LastBack,
|
||||||
|
T_Expr
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The structure of a token */
|
/* The structure of a token */
|
||||||
@@ -243,3 +295,26 @@ typedef struct {
|
|||||||
#define TERMINAL_BACKGROUND_UNKNOWN -1
|
#define TERMINAL_BACKGROUND_UNKNOWN -1
|
||||||
#define TERMINAL_BACKGROUND_DARK 0
|
#define TERMINAL_BACKGROUND_DARK 0
|
||||||
#define TERMINAL_BACKGROUND_LIGHT 1
|
#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;
|
||||||
|
|
||||||
|
|||||||
340
src/userfns.c
340
src/userfns.c
@@ -6,7 +6,7 @@
|
|||||||
/* functions. */
|
/* functions. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -16,43 +16,46 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
#include "expr.h"
|
|
||||||
|
|
||||||
#define FUNC_HASH_SIZE 32 /* Size of User-defined function hash table */
|
#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 */
|
/* The hash table */
|
||||||
static UserFunc *FuncHash[FUNC_HASH_SIZE];
|
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 DestroyUserFunc (UserFunc *f);
|
||||||
static void FUnset (char const *name);
|
static void FUnset (char const *name);
|
||||||
static void FSet (UserFunc *f);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
seen_one = 1;
|
seen_one = 1;
|
||||||
|
strtolower(DBufValue(&buf));
|
||||||
FUnset(DBufValue(&buf));
|
FUnset(DBufValue(&buf));
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
}
|
}
|
||||||
@@ -93,8 +97,11 @@ int DoFset(ParsePtr p)
|
|||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
int c;
|
int c;
|
||||||
|
int i;
|
||||||
UserFunc *func;
|
UserFunc *func;
|
||||||
Var *v;
|
UserFunc *existing;
|
||||||
|
Var *locals = NULL;
|
||||||
|
Var local_array[MAX_FUNC_ARGS];
|
||||||
int orig_namelen;
|
int orig_namelen;
|
||||||
|
|
||||||
DynamicBuffer buf;
|
DynamicBuffer buf;
|
||||||
@@ -119,38 +126,55 @@ int DoFset(ParsePtr p)
|
|||||||
return E_PARSE_ERR;
|
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);
|
func = NEW(UserFunc);
|
||||||
if (!func) {
|
if (!func) {
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return E_NO_MEM;
|
return E_NO_MEM;
|
||||||
}
|
}
|
||||||
func->filename = StrDup(FileName);
|
if (FileName) {
|
||||||
|
func->filename = StrDup(FileName);
|
||||||
|
} else {
|
||||||
|
func->filename = StrDup("[cmdline]");
|
||||||
|
}
|
||||||
if (!func->filename) {
|
if (!func->filename) {
|
||||||
|
free(func);
|
||||||
return E_NO_MEM;
|
return E_NO_MEM;
|
||||||
}
|
}
|
||||||
func->lineno = LineNo;
|
func->lineno = LineNo;
|
||||||
StrnCpy(func->name, DBufValue(&buf), VAR_NAME_LEN);
|
StrnCpy(func->name, DBufValue(&buf), VAR_NAME_LEN);
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
if (!Hush) {
|
if (!Hush) {
|
||||||
if (FindFunc(func->name, Func, NumFuncs)) {
|
if (FindBuiltinFunc(func->name)) {
|
||||||
Eprint("%s: `%s'", ErrMsg[E_REDEF_FUNC], func->name);
|
Eprint("%s: `%s'", ErrMsg[E_REDEF_FUNC], func->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func->locals = NULL;
|
func->node = NULL;
|
||||||
func->text = NULL;
|
|
||||||
func->IsActive = 0;
|
|
||||||
func->nargs = 0;
|
func->nargs = 0;
|
||||||
|
func->args = NULL;
|
||||||
|
|
||||||
/* Get the local variables - we insert the local variables in REVERSE
|
/* Get the local variables */
|
||||||
order, but that's OK, because we pop them off the stack in reverse
|
|
||||||
order, too, so everything works out just fine. */
|
|
||||||
|
|
||||||
c=ParseNonSpaceChar(p, &r, 1);
|
c=ParseNonSpaceChar(p, &r, 1);
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
if (c == ')') {
|
if (c == ')') {
|
||||||
(void) ParseNonSpaceChar(p, &r, 0);
|
(void) ParseNonSpaceChar(p, &r, 0);
|
||||||
}
|
} else {
|
||||||
else {
|
locals = local_array;
|
||||||
while(1) {
|
while(1) {
|
||||||
if ( (r=ParseIdentifier(p, &buf)) ) return r;
|
if ( (r=ParseIdentifier(p, &buf)) ) return r;
|
||||||
if (*DBufValue(&buf) == '$') {
|
if (*DBufValue(&buf) == '$') {
|
||||||
@@ -158,18 +182,25 @@ int DoFset(ParsePtr p)
|
|||||||
DestroyUserFunc(func);
|
DestroyUserFunc(func);
|
||||||
return E_BAD_ID;
|
return E_BAD_ID;
|
||||||
}
|
}
|
||||||
v = NEW(Var);
|
/* If we've already seen this local variable, error */
|
||||||
if (!v) {
|
for (i=0; i<func->nargs; i++) {
|
||||||
DBufFree(&buf);
|
if (!StrinCmp(DBufValue(&buf), local_array[i].name, VAR_NAME_LEN)) {
|
||||||
DestroyUserFunc(func);
|
DBufFree(&buf);
|
||||||
return E_NO_MEM;
|
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++;
|
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);
|
c = ParseNonSpaceChar(p, &r, 0);
|
||||||
if (c == ')') break;
|
if (c == ')') break;
|
||||||
else if (c != ',') {
|
else if (c != ',') {
|
||||||
@@ -182,19 +213,44 @@ int DoFset(ParsePtr p)
|
|||||||
/* Allow an optional = sign: FSET f(x) = x*x */
|
/* Allow an optional = sign: FSET f(x) = x*x */
|
||||||
c = ParseNonSpaceChar(p, &r, 1);
|
c = ParseNonSpaceChar(p, &r, 1);
|
||||||
if (c == '=') {
|
if (c == '=') {
|
||||||
c = ParseNonSpaceChar(p, &r, 0);
|
(void) ParseNonSpaceChar(p, &r, 0);
|
||||||
}
|
}
|
||||||
/* Copy the text over */
|
|
||||||
if (p->isnested) {
|
if (p->isnested) {
|
||||||
Eprint("%s", ErrMsg[E_CANTNEST_FDEF]);
|
Eprint("%s", ErrMsg[E_CANTNEST_FDEF]);
|
||||||
DestroyUserFunc(func);
|
DestroyUserFunc(func);
|
||||||
return E_PARSE_ERR;
|
return E_PARSE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
func->text = StrDup(p->pos);
|
while(*(p->pos) && isspace(*(p->pos))) {
|
||||||
if (!func->text) {
|
p->pos++;
|
||||||
DestroyUserFunc(func);
|
}
|
||||||
return E_NO_MEM;
|
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 */
|
/* If an old definition of this function exists, destroy it */
|
||||||
@@ -218,23 +274,22 @@ int DoFset(ParsePtr p)
|
|||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
static void DestroyUserFunc(UserFunc *f)
|
static void DestroyUserFunc(UserFunc *f)
|
||||||
{
|
{
|
||||||
Var *v, *prev;
|
int i;
|
||||||
|
|
||||||
/* Free the local variables first */
|
|
||||||
v = f->locals;
|
|
||||||
while(v) {
|
|
||||||
DestroyValue(v->v);
|
|
||||||
prev = v;
|
|
||||||
v = v->next;
|
|
||||||
free(prev);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Free the function definition */
|
/* Free the function definition */
|
||||||
if (f->text) free( (char *) f->text);
|
if (f->node) free_expr_tree(f->node);
|
||||||
|
|
||||||
/* Free the filename */
|
/* Free the filename */
|
||||||
if (f->filename) free( (char *) f->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 the data structure itself */
|
||||||
free(f);
|
free(f);
|
||||||
}
|
}
|
||||||
@@ -252,12 +307,12 @@ static void FUnset(char const *name)
|
|||||||
UserFunc *cur, *prev;
|
UserFunc *cur, *prev;
|
||||||
int h;
|
int h;
|
||||||
|
|
||||||
h = HashVal(name) % FUNC_HASH_SIZE;
|
h = HashVal_nocase(name) % FUNC_HASH_SIZE;
|
||||||
|
|
||||||
cur = FuncHash[h];
|
cur = FuncHash[h];
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
while(cur) {
|
while(cur) {
|
||||||
if (! StrinCmp(name, cur->name, VAR_NAME_LEN)) break;
|
if (! strncmp(name, cur->name, VAR_NAME_LEN)) break;
|
||||||
prev = cur;
|
prev = cur;
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
@@ -275,132 +330,22 @@ static void FUnset(char const *name)
|
|||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
static void FSet(UserFunc *f)
|
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];
|
f->next = FuncHash[h];
|
||||||
FuncHash[h] = f;
|
FuncHash[h] = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
UserFunc *FindUserFunc(char const *name)
|
||||||
/* */
|
|
||||||
/* CallUserFunc */
|
|
||||||
/* */
|
|
||||||
/* Call a user-defined function. */
|
|
||||||
/* */
|
|
||||||
/***************************************************************/
|
|
||||||
int CallUserFunc(char const *name, int nargs, ParsePtr p)
|
|
||||||
{
|
{
|
||||||
UserFunc *f;
|
UserFunc *f;
|
||||||
int h = HashVal(name) % FUNC_HASH_SIZE;
|
int h = HashVal_nocase(name) % FUNC_HASH_SIZE;
|
||||||
int i;
|
|
||||||
char const *s;
|
|
||||||
|
|
||||||
/* Search for the function */
|
/* Search for the function */
|
||||||
f = FuncHash[h];
|
f = FuncHash[h];
|
||||||
while (f && StrinCmp(name, f->name, VAR_NAME_LEN)) f = f->next;
|
while (f && strncmp(name, f->name, VAR_NAME_LEN)) f = f->next;
|
||||||
if (!f) {
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
|
||||||
/* */
|
|
||||||
/* 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 */
|
/* UserFuncExists */
|
||||||
@@ -411,12 +356,33 @@ static void DestroyLocalVals(UserFunc *f)
|
|||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
int UserFuncExists(char const *fn)
|
int UserFuncExists(char const *fn)
|
||||||
{
|
{
|
||||||
UserFunc *f;
|
UserFunc *f = FindUserFunc(fn);
|
||||||
int h = HashVal(fn) % FUNC_HASH_SIZE;
|
|
||||||
|
|
||||||
f = FuncHash[h];
|
|
||||||
while (f && StrinCmp(fn, f->name, VAR_NAME_LEN)) f = f->next;
|
|
||||||
if (!f) return -1;
|
if (!f) return -1;
|
||||||
else return f->nargs;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
124
src/utils.c
124
src/utils.c
@@ -5,7 +5,7 @@
|
|||||||
/* Useful utility functions. */
|
/* Useful utility functions. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -17,6 +17,11 @@ static char const DontEscapeMe[] =
|
|||||||
#include "err.h"
|
#include "err.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_STRINGS_H
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
@@ -36,27 +41,17 @@ char *StrnCpy(char *dest, char const *source, int n)
|
|||||||
{
|
{
|
||||||
char *odest = dest;
|
char *odest = dest;
|
||||||
|
|
||||||
|
if (n <= 0) {
|
||||||
|
*dest = 0;
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
while (n-- && (*dest++ = *source++)) ;
|
while (n-- && (*dest++ = *source++)) ;
|
||||||
if (*(dest-1)) *dest = 0;
|
if (*(dest-1)) *dest = 0;
|
||||||
return odest;
|
return odest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
#ifndef HAVE_STRNCASECMP
|
||||||
/* */
|
|
||||||
/* StrMatch */
|
|
||||||
/* */
|
|
||||||
/* Checks that two strings match (case-insensitive) to at */
|
|
||||||
/* least the specified number of characters, or the length */
|
|
||||||
/* of the first string, whichever is greater. */
|
|
||||||
/* */
|
|
||||||
/***************************************************************/
|
|
||||||
int StrMatch(char const *s1, char const *s2, int n)
|
|
||||||
{
|
|
||||||
int l;
|
|
||||||
if ((l = strlen(s1)) < n) return 0;
|
|
||||||
return !StrinCmp(s1, s2, l);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* StrinCmp - compare strings, case-insensitive */
|
/* StrinCmp - compare strings, case-insensitive */
|
||||||
@@ -75,6 +70,9 @@ int StrinCmp(char const *s1, char const *s2, int n)
|
|||||||
if (n) return (toupper(*s1) - toupper(*s2)); else return 0;
|
if (n) return (toupper(*s1) - toupper(*s2)); else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRDUP
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* StrDup */
|
/* StrDup */
|
||||||
@@ -90,6 +88,9 @@ char *StrDup(char const *s)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRCASECMP
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* StrCmpi */
|
/* StrCmpi */
|
||||||
@@ -109,6 +110,8 @@ int StrCmpi(char const *s1, char const *s2)
|
|||||||
return toupper(*s1) - toupper(*s2);
|
return toupper(*s1) - toupper(*s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* DateOK */
|
/* DateOK */
|
||||||
@@ -124,7 +127,15 @@ int DateOK(int y, int m, int d)
|
|||||||
m > 11 ||
|
m > 11 ||
|
||||||
y > BASE + YR_RANGE ||
|
y > BASE + YR_RANGE ||
|
||||||
d > DaysInMonth(m, y) ) return 0;
|
d > DaysInMonth(m, y) ) return 0;
|
||||||
else return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void strtolower(char *s)
|
||||||
|
{
|
||||||
|
while (*s) {
|
||||||
|
*s = tolower(*s);
|
||||||
|
s++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Functions designed to defeat gcc optimizer */
|
/* Functions designed to defeat gcc optimizer */
|
||||||
@@ -162,11 +173,15 @@ int _private_sub_overflow(int a, int b)
|
|||||||
int
|
int
|
||||||
ShellEscape(char const *in, DynamicBuffer *out)
|
ShellEscape(char const *in, DynamicBuffer *out)
|
||||||
{
|
{
|
||||||
while(*in) {
|
unsigned char const *i = (unsigned char const *) in;
|
||||||
if (!strchr(DontEscapeMe, *in)) {
|
while(*i) {
|
||||||
if (DBufPutc(out, '\\') != OK) return E_NO_MEM;
|
/* 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;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -180,31 +195,33 @@ typedef struct cs_s {
|
|||||||
} cs;
|
} cs;
|
||||||
|
|
||||||
static cs *callstack = NULL;
|
static cs *callstack = NULL;
|
||||||
|
static cs *freecs = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
destroy_cs(cs *entry)
|
destroy_cs(cs *entry)
|
||||||
{
|
{
|
||||||
if (entry->filename) free( (void *) entry->filename);
|
entry->next = freecs;
|
||||||
if (entry->func) free( (void *) entry->func);
|
freecs = entry;
|
||||||
free( (void *) entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
push_call(char const *filename, char const *func, int lineno)
|
push_call(char const *filename, char const *func, int lineno)
|
||||||
{
|
{
|
||||||
cs *entry = NEW(cs);
|
cs *entry;
|
||||||
if (!entry) {
|
if (freecs) {
|
||||||
return E_NO_MEM;
|
entry = freecs;
|
||||||
|
freecs = freecs->next;
|
||||||
|
} else {
|
||||||
|
entry = NEW(cs);
|
||||||
|
if (!entry) {
|
||||||
|
return E_NO_MEM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
entry->next = NULL;
|
entry->next = NULL;
|
||||||
entry->filename = StrDup(filename);
|
entry->filename = filename;
|
||||||
entry->func = StrDup(func);
|
entry->func = func;
|
||||||
entry->lineno = lineno;
|
entry->lineno = lineno;
|
||||||
if (!entry->filename || !entry->func) {
|
|
||||||
destroy_cs(entry);
|
|
||||||
return E_NO_MEM;
|
|
||||||
}
|
|
||||||
entry->next = callstack;
|
entry->next = callstack;
|
||||||
callstack = entry;
|
callstack = entry;
|
||||||
return OK;
|
return OK;
|
||||||
@@ -223,21 +240,38 @@ clear_callstack(void)
|
|||||||
callstack = NULL;
|
callstack = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
have_callstack(void)
|
|
||||||
{
|
|
||||||
if (callstack) return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_callstack_aux(FILE *fp, cs *entry)
|
print_callstack_aux(FILE *fp, cs *entry)
|
||||||
{
|
{
|
||||||
if (entry) {
|
int i = 0;
|
||||||
print_callstack_aux(fp, entry->next);
|
char const *in = "In";
|
||||||
fprintf(fp, "\n");
|
cs *prev = NULL;
|
||||||
(void) fprintf(fp, "%s(%d): In function `%s'", entry->filename, entry->lineno, entry->func);
|
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
|
int
|
||||||
|
|||||||
118
src/var.c
118
src/var.c
@@ -6,7 +6,7 @@
|
|||||||
/* user- and system-defined variables. */
|
/* user- and system-defined variables. */
|
||||||
/* */
|
/* */
|
||||||
/* This file is part of REMIND. */
|
/* This file is part of REMIND. */
|
||||||
/* Copyright (C) 1992-2023 by Dianne Skoll */
|
/* Copyright (C) 1992-2024 by Dianne Skoll */
|
||||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
@@ -22,7 +22,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "expr.h"
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "protos.h"
|
#include "protos.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
@@ -39,8 +38,6 @@ static int IntMax = INT_MAX;
|
|||||||
|
|
||||||
static Var *VHashTbl[VAR_HASH_SIZE];
|
static Var *VHashTbl[VAR_HASH_SIZE];
|
||||||
|
|
||||||
typedef int (*SysVarFunc)(int, Value *);
|
|
||||||
|
|
||||||
static double
|
static double
|
||||||
strtod_in_c_locale(char const *str, char **endptr)
|
strtod_in_c_locale(char const *str, char **endptr)
|
||||||
{
|
{
|
||||||
@@ -167,6 +164,26 @@ static int latitude_func(int do_set, Value *val)
|
|||||||
return latitude_longitude_func(do_set, val, &Latitude, -90.0, 90.0);
|
return latitude_longitude_func(do_set, val, &Latitude, -90.0, 90.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int terminal_bg_func(int do_set, Value *val)
|
||||||
|
{
|
||||||
|
UNUSED(do_set);
|
||||||
|
val->type = INT_TYPE;
|
||||||
|
val->v.val = GetTerminalBackground();
|
||||||
|
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)
|
static int trig_date_func(int do_set, Value *val)
|
||||||
{
|
{
|
||||||
@@ -302,6 +319,29 @@ static int datetime_sep_func(int do_set, Value *val)
|
|||||||
return OK;
|
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)
|
static int default_color_func(int do_set, Value *val)
|
||||||
{
|
{
|
||||||
int col_r, col_g, col_b;
|
int col_r, col_g, col_b;
|
||||||
@@ -470,10 +510,10 @@ int DeleteVar(char const *str)
|
|||||||
/* */
|
/* */
|
||||||
/* SetVar */
|
/* 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);
|
Var *v = FindVar(str, 1);
|
||||||
|
|
||||||
@@ -491,20 +531,10 @@ int SetVar(char const *str, Value *val)
|
|||||||
/* Get a copy of the value of the variable. */
|
/* 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;
|
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);
|
v=FindVar(str, 0);
|
||||||
|
|
||||||
if (!v) {
|
if (!v) {
|
||||||
@@ -525,7 +555,9 @@ int DoSet (Parser *p)
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
DynamicBuffer buf;
|
DynamicBuffer buf;
|
||||||
|
DynamicBuffer buf2;
|
||||||
DBufInit(&buf);
|
DBufInit(&buf);
|
||||||
|
DBufInit(&buf2);
|
||||||
|
|
||||||
r = ParseIdentifier(p, &buf);
|
r = ParseIdentifier(p, &buf);
|
||||||
if (r) return r;
|
if (r) return r;
|
||||||
@@ -535,12 +567,24 @@ int DoSet (Parser *p)
|
|||||||
ParseNonSpaceChar(p, &r, 0);
|
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);
|
r = EvaluateExpr(p, &v);
|
||||||
if (r) {
|
if (r) {
|
||||||
DBufFree(&buf);
|
DBufFree(&buf);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = ParseToken(p, &buf2);
|
||||||
|
if (r) return r;
|
||||||
|
if (DBufLen(&buf2)) {
|
||||||
|
DBufFree(&buf2);
|
||||||
|
return E_EXPECTING_EOL;
|
||||||
|
}
|
||||||
|
DBufFree(&buf2);
|
||||||
if (*DBufValue(&buf) == '$') r = SetSysVar(DBufValue(&buf)+1, &v);
|
if (*DBufValue(&buf) == '$') r = SetSysVar(DBufValue(&buf)+1, &v);
|
||||||
else r = SetVar(DBufValue(&buf), &v);
|
else r = SetVar(DBufValue(&buf), &v);
|
||||||
if (buf.len > VAR_NAME_LEN) {
|
if (buf.len > VAR_NAME_LEN) {
|
||||||
@@ -756,15 +800,9 @@ int DoPreserve (Parser *p)
|
|||||||
/* */
|
/* */
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
|
||||||
/* The structure of a system variable */
|
/* Macro to access "min" but as a constval. Just to make source more
|
||||||
typedef struct {
|
readable */
|
||||||
char const *name;
|
#define constval min
|
||||||
char modifiable;
|
|
||||||
int type;
|
|
||||||
void *value;
|
|
||||||
int min;
|
|
||||||
int max;
|
|
||||||
} SysVar;
|
|
||||||
|
|
||||||
/* If the type of a sys variable is STR_TYPE, then min is redefined
|
/* If the type of a sys variable is STR_TYPE, then min is redefined
|
||||||
to be a flag indicating whether or not the value has been malloc'd. */
|
to be a flag indicating whether or not the value has been malloc'd. */
|
||||||
@@ -792,12 +830,13 @@ static SysVar SysVarArr[] = {
|
|||||||
{"DefaultColor", 1, SPECIAL_TYPE, default_color_func, 0, 0 },
|
{"DefaultColor", 1, SPECIAL_TYPE, default_color_func, 0, 0 },
|
||||||
{"DefaultPrio", 1, INT_TYPE, &DefaultPrio, 0, 9999 },
|
{"DefaultPrio", 1, INT_TYPE, &DefaultPrio, 0, 9999 },
|
||||||
{"DefaultTDelta", 1, INT_TYPE, &DefaultTDelta, 0, 1440 },
|
{"DefaultTDelta", 1, INT_TYPE, &DefaultTDelta, 0, 1440 },
|
||||||
{"DeltaOffset", 0, INT_TYPE, &DeltaOffset, 0, 0 },
|
{"DeltaOverride", 0, INT_TYPE, &DeltaOverride, 0, 0 },
|
||||||
{"DontFork", 0, INT_TYPE, &DontFork, 0, 0 },
|
{"DontFork", 0, INT_TYPE, &DontFork, 0, 0 },
|
||||||
{"DontQueue", 0, INT_TYPE, &DontQueue, 0, 0 },
|
{"DontQueue", 0, INT_TYPE, &DontQueue, 0, 0 },
|
||||||
{"DontTrigAts", 0, INT_TYPE, &DontIssueAts, 0, 0 },
|
{"DontTrigAts", 0, INT_TYPE, &DontIssueAts, 0, 0 },
|
||||||
{"EndSent", 1, STR_TYPE, &EndSent, 0, 0 },
|
{"EndSent", 1, STR_TYPE, &EndSent, 0, 0 },
|
||||||
{"EndSentIg", 1, STR_TYPE, &EndSentIg, 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 },
|
{"February", 1, STR_TYPE, &DynamicMonthName[1], 0, 0 },
|
||||||
{"FirstIndent", 1, INT_TYPE, &FirstIndent, 0, 132 },
|
{"FirstIndent", 1, INT_TYPE, &FirstIndent, 0, 132 },
|
||||||
{"FoldYear", 1, INT_TYPE, &FoldYear, 0, 1 },
|
{"FoldYear", 1, INT_TYPE, &FoldYear, 0, 1 },
|
||||||
@@ -825,6 +864,9 @@ static SysVar SysVarArr[] = {
|
|||||||
{"LongMin", 1, SPECIAL_TYPE, longmin_func, 0, 0 },
|
{"LongMin", 1, SPECIAL_TYPE, longmin_func, 0, 0 },
|
||||||
{"LongSec", 1, SPECIAL_TYPE, longsec_func, 0, 0 },
|
{"LongSec", 1, SPECIAL_TYPE, longsec_func, 0, 0 },
|
||||||
{"March", 1, STR_TYPE, &DynamicMonthName[2], 0, 0 },
|
{"March", 1, STR_TYPE, &DynamicMonthName[2], 0, 0 },
|
||||||
|
{"MaxFullOmits", 0, CONST_INT_TYPE, NULL, MAX_FULL_OMITS, 0},
|
||||||
|
{"MaxLateMinutes", 1, INT_TYPE, &MaxLateMinutes, 0, 1440 },
|
||||||
|
{"MaxPartialOmits",0, CONST_INT_TYPE, NULL, MAX_PARTIAL_OMITS, 0},
|
||||||
{"MaxSatIter", 1, INT_TYPE, &MaxSatIter, 10, ANY },
|
{"MaxSatIter", 1, INT_TYPE, &MaxSatIter, 10, ANY },
|
||||||
{"MaxStringLen", 1, INT_TYPE, &MaxStringLen, -1, ANY },
|
{"MaxStringLen", 1, INT_TYPE, &MaxStringLen, -1, ANY },
|
||||||
{"May", 1, STR_TYPE, &DynamicMonthName[4], 0, 0 },
|
{"May", 1, STR_TYPE, &DynamicMonthName[4], 0, 0 },
|
||||||
@@ -835,10 +877,13 @@ static SysVar SysVarArr[] = {
|
|||||||
{"NextMode", 0, INT_TYPE, &NextMode, 0, 0 },
|
{"NextMode", 0, INT_TYPE, &NextMode, 0, 0 },
|
||||||
{"November", 1, STR_TYPE, &DynamicMonthName[10],0, 0 },
|
{"November", 1, STR_TYPE, &DynamicMonthName[10],0, 0 },
|
||||||
{"Now", 1, STR_TYPE, &DynamicNow, 0, 0 },
|
{"Now", 1, STR_TYPE, &DynamicNow, 0, 0 },
|
||||||
|
{"NumFullOmits", 0, INT_TYPE, &NumFullOmits, 0, 0 },
|
||||||
|
{"NumPartialOmits",0, INT_TYPE, &NumPartialOmits, 0, 0 },
|
||||||
{"NumQueued", 0, INT_TYPE, &NumQueued, 0, 0 },
|
{"NumQueued", 0, INT_TYPE, &NumQueued, 0, 0 },
|
||||||
{"NumTrig", 0, INT_TYPE, &NumTriggered, 0, 0 },
|
{"NumTrig", 0, INT_TYPE, &NumTriggered, 0, 0 },
|
||||||
{"October", 1, STR_TYPE, &DynamicMonthName[9], 0, 0 },
|
{"October", 1, STR_TYPE, &DynamicMonthName[9], 0, 0 },
|
||||||
{"On", 1, STR_TYPE, &DynamicOn, 0, 0 },
|
{"On", 1, STR_TYPE, &DynamicOn, 0, 0 },
|
||||||
|
{"ParseUntriggered", 1, INT_TYPE, &ParseUntriggered, 0, 1 },
|
||||||
{"Pm", 1, STR_TYPE, &DynamicPm, 0, 0 },
|
{"Pm", 1, STR_TYPE, &DynamicPm, 0, 0 },
|
||||||
{"PrefixLineNo", 0, INT_TYPE, &DoPrefixLineNo, 0, 0 },
|
{"PrefixLineNo", 0, INT_TYPE, &DoPrefixLineNo, 0, 0 },
|
||||||
{"PSCal", 0, INT_TYPE, &PsCal, 0, 0 },
|
{"PSCal", 0, INT_TYPE, &PsCal, 0, 0 },
|
||||||
@@ -855,12 +900,13 @@ static SysVar SysVarArr[] = {
|
|||||||
{"SysInclude", 0, STR_TYPE, &SysDir, 0, 0 },
|
{"SysInclude", 0, STR_TYPE, &SysDir, 0, 0 },
|
||||||
{"T", 0, SPECIAL_TYPE, trig_date_func, 0, 0 },
|
{"T", 0, SPECIAL_TYPE, trig_date_func, 0, 0 },
|
||||||
{"Td", 0, SPECIAL_TYPE, trig_day_func, 0, 0 },
|
{"Td", 0, SPECIAL_TYPE, trig_day_func, 0, 0 },
|
||||||
{"TerminalBackground", 0, INT_TYPE, &TerminalBackground, 0, 0 },
|
{"TerminalBackground", 0, SPECIAL_TYPE, terminal_bg_func, 0, 0 },
|
||||||
{"Thursday", 1, STR_TYPE, &DynamicDayName[3], 0, 0 },
|
{"Thursday", 1, STR_TYPE, &DynamicDayName[3], 0, 0 },
|
||||||
{"TimeSep", 1, SPECIAL_TYPE, time_sep_func, 0, 0 },
|
{"TimeSep", 1, SPECIAL_TYPE, time_sep_func, 0, 0 },
|
||||||
{"Tm", 0, SPECIAL_TYPE, trig_mon_func, 0, 0 },
|
{"Tm", 0, SPECIAL_TYPE, trig_mon_func, 0, 0 },
|
||||||
{"Today", 1, STR_TYPE, &DynamicToday, 0, 0 },
|
{"Today", 1, STR_TYPE, &DynamicToday, 0, 0 },
|
||||||
{"Tomorrow", 1, STR_TYPE, &DynamicTomorrow, 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 },
|
{"Tuesday", 1, STR_TYPE, &DynamicDayName[1], 0, 0 },
|
||||||
{"Tw", 0, SPECIAL_TYPE, trig_wday_func, 0, 0 },
|
{"Tw", 0, SPECIAL_TYPE, trig_wday_func, 0, 0 },
|
||||||
{"Ty", 0, SPECIAL_TYPE, trig_year_func, 0, 0 },
|
{"Ty", 0, SPECIAL_TYPE, trig_year_func, 0, 0 },
|
||||||
@@ -879,7 +925,6 @@ static SysVar SysVarArr[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define NUMSYSVARS ( sizeof(SysVarArr) / sizeof(SysVar) )
|
#define NUMSYSVARS ( sizeof(SysVarArr) / sizeof(SysVar) )
|
||||||
static SysVar *FindSysVar (char const *name);
|
|
||||||
static void DumpSysVar (char const *name, const SysVar *v);
|
static void DumpSysVar (char const *name, const SysVar *v);
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/* */
|
/* */
|
||||||
@@ -893,13 +938,13 @@ int SetSysVar(char const *name, Value *value)
|
|||||||
int r;
|
int r;
|
||||||
SysVar *v = FindSysVar(name);
|
SysVar *v = FindSysVar(name);
|
||||||
if (!v) return E_NOSUCH_VAR;
|
if (!v) return E_NOSUCH_VAR;
|
||||||
if (v->type != SPECIAL_TYPE &&
|
|
||||||
v->type != value->type) return E_BAD_TYPE;
|
|
||||||
if (!v->modifiable) {
|
if (!v->modifiable) {
|
||||||
Eprint("%s: `$%s'", ErrMsg[E_CANT_MODIFY], name);
|
Eprint("%s: `$%s'", ErrMsg[E_CANT_MODIFY], name);
|
||||||
return E_CANT_MODIFY;
|
return E_CANT_MODIFY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (v->type != SPECIAL_TYPE &&
|
||||||
|
v->type != value->type) return E_BAD_TYPE;
|
||||||
if (v->type == SPECIAL_TYPE) {
|
if (v->type == SPECIAL_TYPE) {
|
||||||
SysVarFunc f = (SysVarFunc) v->value;
|
SysVarFunc f = (SysVarFunc) v->value;
|
||||||
r = f(1, value);
|
r = f(1, value);
|
||||||
@@ -940,6 +985,11 @@ int GetSysVar(char const *name, Value *val)
|
|||||||
|
|
||||||
val->type = ERR_TYPE;
|
val->type = ERR_TYPE;
|
||||||
if (!v) return E_NOSUCH_VAR;
|
if (!v) return E_NOSUCH_VAR;
|
||||||
|
if (v->type == CONST_INT_TYPE) {
|
||||||
|
val->v.val = v->constval;
|
||||||
|
val->type = INT_TYPE;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
if (v->type == SPECIAL_TYPE) {
|
if (v->type == SPECIAL_TYPE) {
|
||||||
SysVarFunc f = (SysVarFunc) v->value;
|
SysVarFunc f = (SysVarFunc) v->value;
|
||||||
return f(0, val);
|
return f(0, val);
|
||||||
@@ -971,7 +1021,7 @@ int GetSysVar(char const *name, Value *val)
|
|||||||
/* Find a system var with specified name. */
|
/* 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 top=NUMSYSVARS-1, bottom=0;
|
||||||
int mid=(top + bottom) / 2;
|
int mid=(top + bottom) / 2;
|
||||||
@@ -1033,7 +1083,9 @@ static void DumpSysVar(char const *name, const SysVar *v)
|
|||||||
if (name) strcat(buffer, name); else strcat(buffer, v->name);
|
if (name) strcat(buffer, name); else strcat(buffer, v->name);
|
||||||
fprintf(ErrFp, "%16s ", buffer);
|
fprintf(ErrFp, "%16s ", buffer);
|
||||||
if (v) {
|
if (v) {
|
||||||
if (v->type == SPECIAL_TYPE) {
|
if (v->type == CONST_INT_TYPE) {
|
||||||
|
fprintf(ErrFp, "%d\n", v->constval);
|
||||||
|
} else if (v->type == SPECIAL_TYPE) {
|
||||||
SysVarFunc f = (SysVarFunc) v->value;
|
SysVarFunc f = (SysVarFunc) v->value;
|
||||||
f(0, &vtmp);
|
f(0, &vtmp);
|
||||||
PrintValue(&vtmp, ErrFp);
|
PrintValue(&vtmp, ErrFp);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ MSG UseVTColors is: [$UseVTColors]%
|
|||||||
MSG Use256Colors is: [$Use256Colors]%
|
MSG Use256Colors is: [$Use256Colors]%
|
||||||
MSG UseTrueColors is: [$UseTrueColors]%
|
MSG UseTrueColors is: [$UseTrueColors]%
|
||||||
MSG UseBGVTColors is: [$UseBGVTColors]%
|
MSG UseBGVTColors is: [$UseBGVTColors]%
|
||||||
set n ansicolor("")]
|
set n ansicolor("")
|
||||||
MSG This is [ansicolor(0,255,0)]green[n], [ansicolor("255 0 0")]red[n] and [ansicolor("0 0 255")]blue[n] text.%
|
MSG This is [ansicolor(0,255,0)]green[n], [ansicolor("255 0 0")]red[n] and [ansicolor("0 0 255")]blue[n] text.%
|
||||||
MSG This is [ansicolor(0,0,0)][ansicolor(0,255,0,1)]black text on a green background[n]%
|
MSG This is [ansicolor(0,0,0)][ansicolor(0,255,0,1)]black text on a green background[n]%
|
||||||
MSG This is [ansicolor(0,0,0,0,1)]clamped black text[n]%
|
MSG This is [ansicolor(0,0,0,0,1)]clamped black text[n]%
|
||||||
@@ -35,8 +35,8 @@ set a ansicolor(-1, 0, 0)
|
|||||||
set a ansicolor(42, 42, 256)
|
set a ansicolor(42, 42, 256)
|
||||||
set a ansicolor("foo")
|
set a ansicolor("foo")
|
||||||
set a ansicolor("1 1")
|
set a ansicolor("1 1")
|
||||||
set a ansicolor("-1 -1 0");
|
set a ansicolor("-1 -1 0")
|
||||||
set a ansicolor("256 1 1");
|
set a ansicolor("256 1 1")
|
||||||
set a ansicolor(128, 128, 128, 2)
|
set a ansicolor(128, 128, 128, 2)
|
||||||
set a ansicolor(128, 128, 128, -1)
|
set a ansicolor(128, 128, 128, -1)
|
||||||
set a ansicolor(128, 128, 128, 0, 2)
|
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
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user