Compare commits

...

315 Commits

Author SHA1 Message Date
Dianne Skoll
5e738020a7 Make a note about include ca.rem directly
All checks were successful
Remind unit tests / tests (push) Successful in 32s
2024-11-02 18:03:18 -04:00
Dianne Skoll
7949341037 Split Canadian holidays by province. 2024-11-02 16:59:20 -04:00
Dianne Skoll
f4d8331456 Clarify invocation commandlines.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-11-02 10:45:05 -04:00
Dianne Skoll
17beef5ce6 Use a much shorter static size for dynamic buffers.
All checks were successful
Remind unit tests / tests (push) Successful in 32s
Most strings are pretty short.
2024-11-01 16:40:44 -04:00
Dianne Skoll
aaae80d02b Update manual to reflect that iif() and choose() only evaluate arguments needed for the final result.
All checks were successful
Remind unit tests / tests (push) Successful in 25s
2024-10-21 23:35:41 -04:00
Dianne Skoll
e97de16203 Clarify that arg of OMITFUNC must be a user-defined function.
All checks were successful
Remind unit tests / tests (push) Successful in 27s
2024-10-21 08:58:36 -04:00
Dianne Skoll
d5e38ee3b4 Fix typo in test.rem.
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-10-18 11:26:41 -04:00
Dianne Skoll
11594aee2d Rename configure.in to configure.ac to avoid autoreconf warning. 2024-10-18 11:21:41 -04:00
Dianne Skoll
711f0b6c69 Rename contrib/ical2rem-0.7.1 to contrib/ical2rem-0.8
All checks were successful
Remind unit tests / tests (push) Successful in 29s
2024-10-17 15:29:15 -04:00
Dianne Skoll
87a8b9811d Update to upstream 0.8. 2024-10-17 15:28:42 -04:00
Dianne Skoll
689b1d0e13 Rebuild src/config.h.in with autoreconf
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-10-17 13:19:53 -04:00
Dianne Skoll
a8650e888f Add comment to AC_DEFINE_UNQUOTED 2024-10-17 13:17:44 -04:00
Dianne Skoll
dea2aed628 Update release notes.
All checks were successful
Remind unit tests / tests (push) Successful in 32s
2024-10-16 13:23:04 -04:00
Dianne Skoll
5618b928e0 Add National Day for Truth and Reconciliation 2024-10-16 13:13:01 -04:00
Dianne Skoll
91187c4c60 Include Remind version in Options dialog. 2024-10-16 10:00:04 -04:00
Dianne Skoll
636ae8f21a Include TkRemind version in title bar.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-10-15 14:59:09 -04:00
Dianne Skoll
405398b226 Use % instead of @ for substitution to avoid possible autoconf conflicts. 2024-10-15 14:56:25 -04:00
Dianne Skoll
0df3a903b1 Remove useless comment. 2024-10-15 14:54:25 -04:00
Dianne Skoll
eac07d212c Bump version to 05.00.07
All checks were successful
Remind unit tests / tests (push) Successful in 29s
2024-10-15 11:55:40 -04:00
Dianne Skoll
96da3a6596 Add note about safety of eval remind --print-config-cmd 2024-10-15 11:22:42 -04:00
Dianne Skoll
94ef20d702 Make sure string is well-formed C 2024-10-15 11:18:16 -04:00
Dianne Skoll
c9c309e436 Document how to use --print-config-cmd 2024-10-15 10:36:55 -04:00
Dianne Skoll
52c973509b Add --print-config-cmd long option. 2024-10-15 10:32:01 -04:00
Dianne Skoll
c192c580da Fix permissions.
All checks were successful
Remind unit tests / tests (push) Successful in 27s
2024-10-14 08:41:00 -04:00
Dianne Skoll
235e5ec1c7 Make ./configure generate tkremind from tkremind.in. 2024-10-14 08:40:05 -04:00
Dianne Skoll
3d30173f9a Print version info in options window. 2024-10-14 08:36:44 -04:00
Dianne Skoll
8b0bbc9fb7 Remove obsolete comment.
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-10-13 10:35:33 -04:00
Dianne Skoll
c57d2fd52a Tweak "astro" example. 2024-10-13 10:33:38 -04:00
Dianne Skoll
2970591187 Add a couple more examples.
All checks were successful
Remind unit tests / tests (push) Successful in 31s
2024-10-12 12:47:17 -04:00
Dianne Skoll
23ec559ddf Fix typo 2024-10-12 12:47:04 -04:00
Dianne Skoll
302bc5a5de Make hash table sizes prime numbers instead of powers of two. 2024-10-12 10:24:22 -04:00
Dianne Skoll
950c0b3747 Use HashPJW for hasing user-defined function names and variable names.
All checks were successful
Remind unit tests / tests (push) Successful in 26s
2024-10-12 10:17:50 -04:00
Dianne Skoll
ad382fea25 Print hash-table statistics with "-ds" debugging.
Some checks failed
Remind unit tests / tests (push) Failing after 29s
2024-10-11 16:34:11 -04:00
Dianne Skoll
a66e855ca7 Remove dead code; remove unnecessary catch { ... } 2024-10-11 16:00:47 -04:00
Dianne Skoll
a1b814d6b1 Allow "hostname" to fail.
All checks were successful
Remind unit tests / tests (push) Successful in 27s
2024-10-10 11:43:26 -04:00
Dianne Skoll
62030719bb Set app name to tkremind.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-10-02 11:08:17 -04:00
Dianne Skoll
985816dc32 Document that system notifications work if notify-send is installed. 2024-10-02 11:05:38 -04:00
Dianne Skoll
a131a53132 Fix typos. 2024-10-02 11:05:27 -04:00
Dianne Skoll
c5e723b6ac Use "notify-send" if Tk < 9.0 2024-10-02 11:00:28 -04:00
Dianne Skoll
3fe2b88e65 Document "Use system notifications when issuing a reminder" 2024-10-02 09:26:11 -04:00
Dianne Skoll
54603090ee Use "tk sysnotify" if we have it.
All checks were successful
Remind unit tests / tests (push) Successful in 39s
2024-10-01 11:02:32 -04:00
Dianne Skoll
2514b3681f Make tkremind work with Tcl/Tk 9.0.
All checks were successful
Remind unit tests / tests (push) Successful in 35s
2024-09-30 11:40:03 -04:00
Dianne Skoll
0b7b101814 Accept Tk >= 8.5 including 9.0 2024-09-30 11:26:30 -04:00
Dianne Skoll
3ac1c622fd Update ical2rem to upstream 0.7.1.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-09-19 16:14:23 -04:00
Dianne Skoll
7878f6623c Fix typo
All checks were successful
Remind unit tests / tests (push) Successful in 35s
2024-09-16 14:48:57 -04:00
Dianne Skoll
00ad38e5fe Put N_ERROR at the end. 2024-09-16 14:47:09 -04:00
Dianne Skoll
10ae0b0077 Add DEBUG +s test. 2024-09-16 14:43:37 -04:00
Dianne Skoll
e032f3315d Mark a freshly-allocated node of type N_ERROR rather than N_FREE. 2024-09-16 14:41:30 -04:00
Dianne Skoll
a38fd95a90 Add guard against double-free of expr_node. 2024-09-16 14:39:26 -04:00
Dianne Skoll
9f7609b2c6 Fix typo. Sigh. 2024-09-16 09:48:50 -04:00
Dianne Skoll
a6c166ae0c Update release notes.
All checks were successful
Remind unit tests / tests (push) Successful in 36s
2024-09-16 09:41:12 -04:00
Dianne Skoll
e9c89b770f Bump version to 05.00.06 2024-09-16 08:29:58 -04:00
Dianne Skoll
df6298bd63 Add test for $SuppressImplicitWarnings
All checks were successful
Remind unit tests / tests (push) Successful in 1m15s
2024-09-15 16:59:46 -04:00
Dianne Skoll
739d285e36 Indent system variable dump better.
All checks were successful
Remind unit tests / tests (push) Successful in 48s
2024-09-15 10:21:22 -04:00
Dianne Skoll
ee1c931932 Add $SuppressImplicitWarnings system variable.
This suppresses warnings about missing REM or MSG tokens.
2024-09-15 09:39:15 -04:00
Dianne Skoll
0806b6738f Add test for time constants of the form '12:34'
All checks were successful
Remind unit tests / tests (push) Successful in 41s
2024-09-13 13:07:49 -04:00
Dianne Skoll
020e82d575 Document that TIME constants may be surrounded by single quotes. 2024-09-13 13:06:57 -04:00
Dianne Skoll
a20f2b588e Accept either 12:34 or '12:34' as a time constant. 2024-09-13 13:02:46 -04:00
Dianne Skoll
631e721a96 More helpful error if someone uses '...' around a TIME constant. 2024-09-13 12:46:38 -04:00
Dianne Skoll
8453e17c6c Add a guard to avoid calling free(NULL)
All checks were successful
Remind unit tests / tests (push) Successful in 29s
2024-09-12 11:50:11 -04:00
Dianne Skoll
76c1e2abb3 Avoid unnecessary double-initialization. 2024-09-12 11:38:59 -04:00
Dianne Skoll
3389f1c91b Refactor init_token and token_error. 2024-09-12 10:58:35 -04:00
Dianne Skoll
b2d47ae979 Initialize token.val in a few places. 2024-09-12 10:51:00 -04:00
Dianne Skoll
e2c615f310 Fix comment. 2024-09-12 10:16:01 -04:00
Dianne Skoll
e8492a4303 Add Chinese New Year file. 2024-09-11 12:09:57 -04:00
Dianne Skoll
4695efaabd Use DBG macro
Some checks failed
Remind unit tests / tests (push) Failing after 28s
2024-09-11 11:53:07 -04:00
Dianne Skoll
c433f42587 Get rid of useless function. 2024-09-11 11:49:04 -04:00
Dianne Skoll
4708e59a43 No need to munch following whitespace. 2024-09-11 11:46:40 -04:00
Dianne Skoll
d56ac6332a Use switch rather than if...else chains
All checks were successful
Remind unit tests / tests (push) Successful in 33s
2024-09-11 11:37:30 -04:00
Dianne Skoll
b054baf590 Stricter tokenization of datetime 2024-09-11 09:01:52 -04:00
Dianne Skoll
42f5e3467d Better error messages for ill-formed time. 2024-09-11 08:52:06 -04:00
Dianne Skoll
97013ae89b Return T_Illegal with a negative tok.val if we can't parse a numeric token. 2024-09-11 08:45:31 -04:00
Dianne Skoll
2acead9118 Shorten error message.
All checks were successful
Remind unit tests / tests (push) Successful in 29s
2024-09-10 16:25:00 -04:00
Dianne Skoll
a53a80acb4 Make error message more explicit. 2024-09-10 16:23:52 -04:00
Dianne Skoll
56e62b1b4d More error checking of bad date specs. 2024-09-10 14:27:46 -04:00
Dianne Skoll
c645db5ede Diagnose bad YYYY-MM-DD constants in REM command. 2024-09-10 14:09:52 -04:00
Dianne Skoll
ef6b9c3783 Better error message when a number that isn't recognized as a day number or year is encountered. 2024-09-10 13:57:34 -04:00
Dianne Skoll
019bee26cb Start refactoring calendar code.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-09-10 10:47:32 -04:00
Dianne Skoll
152cd4090b Better error message.
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-09-09 17:01:56 -04:00
Dianne Skoll
b7fc2b5776 Tweak remind-conf-mode.el with new Remind keywords and better handling of comment lines. 2024-09-09 16:50:27 -04:00
Dianne Skoll
723aba9b7c Document and test --print-tokens
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-09-08 10:33:24 -04:00
Dianne Skoll
8a5b88338b Add --print-tokens long option to dump Remind tokens to stdout. 2024-09-08 10:29:49 -04:00
Dianne Skoll
7236441e02 Remove note saying REM can be omitted. 2024-09-08 10:26:07 -04:00
Dianne Skoll
e4bab0dda4 Be more explicit. 2024-09-08 09:57:52 -04:00
Dianne Skoll
5b7d4a07ec More explicit error messages.
All checks were successful
Remind unit tests / tests (push) Successful in 47s
2024-09-07 13:25:31 -04:00
Dianne Skoll
8c3d2c4003 More specific error message. 2024-09-07 13:14:31 -04:00
Dianne Skoll
f485d607ff Fix error message. 2024-09-07 10:16:57 -04:00
Dianne Skoll
a0effa5f0b Update keyword/variable/function list in remind-conf-mode.el. 2024-09-07 10:15:02 -04:00
Dianne Skoll
7d501cda6f Update to ical2rem version 0.7.
All checks were successful
Remind unit tests / tests (push) Successful in 31s
2024-09-05 12:44:17 -04:00
Dianne Skoll
5d7f55c8d5 Make error messages more consistent.
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-09-03 10:53:45 -04:00
Dianne Skoll
097bf92bea Better error message. 2024-09-03 10:51:50 -04:00
Dianne Skoll
b9dea59206 Update changelog.
All checks were successful
Remind unit tests / tests (push) Successful in 39s
2024-09-02 14:46:58 -04:00
Dianne Skoll
46aa144b65 Bump version to 05.00.05 2024-09-02 10:15:56 -04:00
Dianne Skoll
914971308d Better error message.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-09-01 23:42:29 -04:00
Dianne Skoll
a22e81040f Check error return in a couple of spots. 2024-09-01 23:22:00 -04:00
Dianne Skoll
72f74f03cf Check for errors. 2024-09-01 23:18:09 -04:00
Dianne Skoll
d0e45e727e Don't print closing ] in error indicator.
All checks were successful
Remind unit tests / tests (push) Successful in 31s
2024-09-01 22:39:49 -04:00
Dianne Skoll
ce2b2e80da Remove unnecessary _h() function definition.
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-09-01 11:31:28 -04:00
Dianne Skoll
11771b7d3d Better formatting of ^-- here message for expressions with embedded newlines 2024-09-01 11:27:34 -04:00
Dianne Skoll
01cb028532 Fix up tests to pass in September 2024. 2024-09-01 11:09:32 -04:00
Dianne Skoll
58b6f43b9c Better diagnosis of wrong #args for builtin functions. 2024-09-01 09:03:26 -04:00
Dianne Skoll
1dedb667e8 Prevent a couple of file descriptor leaks.
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-08-31 09:06:05 -04:00
Dianne Skoll
8a96236788 Avoid warnings if REM_USE_WCHAR is undefined.
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-08-30 20:44:08 -04:00
Dianne Skoll
2a13163659 Fix some weird edge cases in text-mode calendar formatting.
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-08-29 13:25:36 -04:00
Dianne Skoll
336a9684d4 In calendar mode, SHADE the entire calendar box including day number.
All checks were successful
Remind unit tests / tests (push) Successful in 29s
2024-08-29 08:50:57 -04:00
Dianne Skoll
86945c6e18 Remove incorrect test obsoleted by changes in 05.00.04. 2024-08-29 08:39:55 -04:00
Dianne Skoll
684280db5e Remove "SCHED _sfun" and hard-code "+15" instead. 2024-08-29 08:15:10 -04:00
Dianne Skoll
d801408933 Update WHATSNEW. 2024-08-29 08:01:50 -04:00
Dianne Skoll
79b3da3820 Update man page.
All checks were successful
Remind unit tests / tests (push) Successful in 27s
2024-08-28 20:43:27 -04:00
Dianne Skoll
ed021d3f46 Let IIF's boolean arg be any type... we use truthy(). 2024-08-28 20:41:21 -04:00
Dianne Skoll
27d0fda280 Factor out truthy code from Fiif 2024-08-28 20:38:04 -04:00
Dianne Skoll
ef12da4ec6 Refactor out "truthy". 2024-08-28 20:36:30 -04:00
Dianne Skoll
7b098e95ad Make error messages more consistent. 2024-08-28 18:21:35 -04:00
Dianne Skoll
7d13f4b09e Better diagnostics when printing "Too many/few arguments" errors 2024-08-28 18:14:43 -04:00
Dianne Skoll
cecdfe6ade Bump version to 05.00.04. 2024-08-28 18:00:50 -04:00
Dianne Skoll
216bbd6378 Fix the logic that recurses into user-defined functions. 2024-08-28 17:56:47 -04:00
Dianne Skoll
30e2e9c633 When looking at SATISFY expressions to make sure they use the trigger date, look recursively into user-defined functions in the expression also. 2024-08-28 17:49:12 -04:00
Dianne Skoll
bf2aabd610 Update release notes. 2024-08-28 15:42:23 -04:00
Dianne Skoll
c019221d15 Add diagnostics for missing/bad subst_XXX functions. 2024-08-28 15:15:34 -04:00
Dianne Skoll
b7bd6faf07 Warn if SCHED/WARN/OMITFUNC functions take wrong number of args. 2024-08-28 15:02:22 -04:00
Dianne Skoll
80d58220fe In warnings, give file/lineno where function is defined. 2024-08-28 14:59:13 -04:00
Dianne Skoll
cd8624e176 Tweak diagnostic messages. 2024-08-28 14:35:49 -04:00
Dianne Skoll
8515fb7ddd Update / clarify manual. 2024-08-28 14:28:34 -04:00
Dianne Skoll
84f9f4ae0a Update tests. 2024-08-28 14:23:14 -04:00
Dianne Skoll
e201ebcfa4 Document that logical operators can take any type; add tests. 2024-08-28 14:22:07 -04:00
Dianne Skoll
4e15c3ec35 Remove an optimization that was interfering with expression debugging. 2024-08-28 14:21:44 -04:00
Dianne Skoll
1adccf9b1f Add tests for SCHED/WARN/OMITFUNC functions that don't use their argument. 2024-08-28 13:54:47 -04:00
Dianne Skoll
a1aa5c2ad9 Change wording of warning slightly. 2024-08-28 13:54:40 -04:00
Dianne Skoll
1e0d650737 Fix tests. 2024-08-28 13:49:34 -04:00
Dianne Skoll
553d092ca8 Diagnost if WARN/SCHED/OMITFUNC functions don't reference their argument. 2024-08-28 13:49:17 -04:00
Dianne Skoll
dc62841517 Fix accidental broken commit. :( 2024-08-28 13:45:42 -04:00
Dianne Skoll
326e7bfc53 Document calendar back-end handling of %_ 2024-08-28 13:23:54 -04:00
Dianne Skoll
b9dc7c16ad Use /s modifier on regex. 2024-08-28 13:09:18 -04:00
Dianne Skoll
abd54b016b Add tests for newlines in calendars. 2024-08-28 12:56:53 -04:00
Dianne Skoll
db02b54067 Collapse multiple whitespace; convert newlines to "<br />" in HTML output. 2024-08-28 12:52:39 -04:00
Dianne Skoll
40a78dfbbb Collapse multiple newlines after all other processing. 2024-08-28 12:52:29 -04:00
Dianne Skoll
c860b46baa Collapse multiple runs of whitespace 2024-08-28 12:52:07 -04:00
Dianne Skoll
1458ba8856 Clean up whitespace runs in rem2pdf.
All checks were successful
Remind unit tests / tests (push) Successful in 45s
2024-08-28 10:44:41 -04:00
Dianne Skoll
7b9b6ebc96 Preserve %_ newlines in "-C" mode. 2024-08-28 10:14:06 -04:00
Dianne Skoll
7ee4073c7a Document warning on function redefinitiion.
All checks were successful
Remind unit tests / tests (push) Successful in 26s
2024-08-27 21:43:46 -04:00
Dianne Skoll
8c072cd9b6 Add a warning if a function is redefined. 2024-08-27 21:41:45 -04:00
Dianne Skoll
b794a45c3f Add more SATISFY diagnostics.
All checks were successful
Remind unit tests / tests (push) Successful in 34s
2024-08-27 15:02:11 -04:00
Dianne Skoll
98e491ed1d Remove some left-over debugging code. 2024-08-27 15:01:59 -04:00
Dianne Skoll
c397cc06da Rewrite code to avoid need to pass address of "mentioned" variable.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-08-27 11:33:41 -04:00
Dianne Skoll
8616236b3c Document that SATISFY clauses that don't mention trigdate are diagnosed. 2024-08-27 11:26:13 -04:00
Dianne Skoll
702704af1a Make sure SATISFY expressions are either constant or mention trigdate. 2024-08-27 11:22:42 -04:00
Dianne Skoll
a0d1b19050 Fix typo in comment.
All checks were successful
Remind unit tests / tests (push) Successful in 39s
2024-08-23 15:08:35 -04:00
Dianne Skoll
a5c8ae491c Add test for diagnosing function definitions with too many arguments. 2024-08-23 15:05:24 -04:00
Dianne Skoll
b3cf741d15 Suppress warning in GCC 14.2.1. Patch courtesy of Emanuele Torre
All checks were successful
Remind unit tests / tests (push) Successful in 38s
2024-08-23 07:44:36 -04:00
Dianne Skoll
0b28dde9c7 Add optional argument to ampm() to specify that hour should be zero-padded to two digits.
All checks were successful
Remind unit tests / tests (push) Successful in 46s
2024-08-22 17:38:54 -04:00
Dianne Skoll
5a3980b5b8 Make note about intended use of defs.rem 2024-08-22 12:51:58 -04:00
Dianne Skoll
a8e33118d6 Suppress warnings. 2024-08-22 10:32:27 -04:00
Dianne Skoll
2223277f64 Fix many warnings. 2024-08-22 10:26:48 -04:00
Dianne Skoll
c72413e3c1 Fix up tests for previous commit.
All checks were successful
Remind unit tests / tests (push) Successful in 29s
2024-08-21 15:10:28 -04:00
Dianne Skoll
fa1033db6f Don't warn about assuming REM type if we've already warned about assuming "REM" 2024-08-21 15:09:41 -04:00
Dianne Skoll
61e3edd2ac Add tests for new diagnostics. 2024-08-21 12:57:04 -04:00
Dianne Skoll
093c97ff91 Add tests for missing REM or missing MSG being diagnosed. 2024-08-21 12:50:51 -04:00
Dianne Skoll
6e64b175aa Diagnose lines that are implicitly treated as REM lines.
Diagnose REM commands that are implicitly treated as having MSG type.

Properly start all lines that should start with REM, with REM.
2024-08-21 12:45:30 -04:00
Dianne Skoll
09dba4bc94 Clarify caching of INCLUDECMD output.
All checks were successful
Remind unit tests / tests (push) Successful in 27s
2024-08-07 13:26:00 -04:00
Dianne Skoll
2e443ac5b7 Properly handle landscape mode in PostScript output.
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-08-04 08:04:56 -04:00
Dianne Skoll
59a8c88178 Use %%PageOrientation, not %%Orientation in DSC comments. 2024-08-04 07:55:55 -04:00
Dianne Skoll
40eab03d84 Add two ways to produce PostScript code: Using rem2ps or rem2pdf
All checks were successful
Remind unit tests / tests (push) Successful in 28s
2024-08-01 12:27:33 -04:00
Dianne Skoll
e993bf59cf Add support for Encapsulated PostScript to rem2pdf. 2024-08-01 09:57:16 -04:00
Dianne Skoll
c6de5a2c8f Add support for producing PostScript to rem2pdf. 2024-08-01 09:40:29 -04:00
Dianne Skoll
51cc939d0c Suppress a couple of cppcheck warnings.
All checks were successful
Remind unit tests / tests (push) Successful in 30s
2024-07-30 15:17:13 -04:00
Dianne Skoll
c857192e6d Change the man page to remove statements that are no longer true (since the new expression-evaluation code in 05.00.00.)
All checks were successful
Remind unit tests / tests (push) Successful in 27s
2024-07-27 08:51:00 -04:00
Dianne Skoll
4591c2b181 Bump version number; fix a bunch of man page warnings; make "make test" fail if there are any man page warnings iff the "man" command accepts --warning
All checks were successful
Remind unit tests / tests (push) Successful in 6m7s
2024-07-26 09:59:46 -04:00
Dianne Skoll
7843a1b2ba Fix typo: .RP should be .PP 2024-07-26 08:18:33 -04:00
Dianne Skoll
649481cf01 Bump version to 05.00.02 2024-07-26 07:56:50 -04:00
Dianne Skoll
c253bdfcbe Update release date. 2024-07-26 07:54:21 -04:00
Dianne Skoll
1910808fd7 Update WHATSNEW 2024-07-10 14:04:06 -04:00
Dianne Skoll
1d8cb9749e Add a test to ensure ONCE works even when taking input from STDIN if $OnceFile is set. 2024-07-10 13:55:41 -04:00
Dianne Skoll
e3f9380fcd Allow ONCE to be used if input is stdin, as long as $OnceFile is set.
Clarify documentation.
2024-07-10 09:32:05 -04:00
Dianne Skoll
326c3f59b0 Make tests pass on any day, not just 2024-07-09. :) 2024-07-10 09:23:21 -04:00
Dianne Skoll
03f1c5a047 Fix typo 2024-07-09 09:36:52 -04:00
Dianne Skoll
02122491c3 Add test to ensure we warn if we try to set $OnceFile to something else after a ONCE has been seen. 2024-07-09 09:33:58 -04:00
Dianne Skoll
735f6f5686 Ignore attempts to set $OnceFile to the value it already has. 2024-07-09 09:33:02 -04:00
Dianne Skoll
ac033d75c0 Add the $OnceFile special variable.
This lets us specify a timestamp file that Remind
uses to track the last run for the purpose of handling
the ONCE keyword, rather than using the last access date
of the reminder file.

Keeping a timestamp file is a more reliable way to track
when Remind was last run.
2024-07-09 09:23:15 -04:00
Dianne Skoll
e2185e773a Add warning if someone attempts to create a multi-page SVG calendar. 2024-07-05 16:57:18 -04:00
Dianne Skoll
d9ae417e01 Fix typo 2024-07-05 14:22:55 -04:00
Dianne Skoll
e1d0948538 Update doc. 2024-07-05 14:22:16 -04:00
Dianne Skoll
357ddf285a Add --svg option to rem2pdf to produce SVG instead of PDF output. 2024-07-05 14:18:29 -04:00
Dianne Skoll
41859fc484 Remove some unused definitions; use symbolic value for sort initializer. 2024-07-04 16:58:41 -04:00
Dianne Skoll
07275e71b0 Remove obsolete definitions. 2024-07-04 13:13:27 -04:00
Dianne Skoll
f68521cb95 Fix spacing. 2024-07-04 13:09:21 -04:00
Dianne Skoll
526610bdd2 Stop parsing user func early if possible. 2024-07-02 09:16:47 -04:00
Dianne Skoll
973e3448ae Fix typo in comment. 2024-07-02 07:58:24 -04:00
Dianne Skoll
9a3f28f6fc Optimize storage of short string constants in expr_node objects. 2024-06-12 10:19:27 -04:00
Dianne Skoll
a3e32d2dc4 Update changelog. 2024-06-08 10:57:38 -04:00
Dianne Skoll
a8b78eff00 Add a few more tests. 2024-06-08 09:20:48 -04:00
Dianne Skoll
460db83298 Bump version to 05.00.01 2024-06-08 09:18:42 -04:00
Dianne Skoll
4560712778 Fix a couple of potential memory leaks. 2024-06-07 21:27:24 -04:00
Dianne Skoll
ce8803dde9 The zero-argument form of weekno() is not constant. 2024-06-07 21:22:32 -04:00
Dianne Skoll
60ca5d45e3 Convert "isany" to short-circuit evaluation. 2024-06-07 15:55:12 -04:00
Dianne Skoll
4454613d00 Fix typo 2024-06-06 12:51:02 -04:00
Dianne Skoll
0704808500 Don't rely on newer C feature that allows anonymous parameters 2024-06-06 12:48:44 -04:00
Dianne Skoll
166b1ac499 Only reset alarm if expression time limit was set 2024-06-06 11:47:39 -04:00
Dianne Skoll
e33bf4e80a Explicitly set sa_flags in sigaction. 2024-06-06 10:42:04 -04:00
Dianne Skoll
b3af44d212 Update docs/WHATSNEW for 05.00.00 release. 2024-06-06 10:28:38 -04:00
Dianne Skoll
1e753d5209 Preserve variables needed across iterations. 2024-06-05 15:08:12 -04:00
Dianne Skoll
4bf31005ea Better error location in a couple more cases. 2024-06-05 09:15:10 -04:00
Dianne Skoll
7c86bc910a Better diagnostics of unmatched IFs 2024-06-05 09:08:04 -04:00
Dianne Skoll
4f146a99a9 Simplify Eprint logic. 2024-06-04 21:10:17 -04:00
Dianne Skoll
a6a638e0e6 Add test for UNMATCHED PUSH 2024-06-04 16:27:23 -04:00
Dianne Skoll
325814f5e1 Print the location of unmatched PUSH 2024-06-04 16:25:14 -04:00
Dianne Skoll
5c4ea7d09e Allow "configure" to work, haha. 2024-06-04 12:02:54 -04:00
Dianne Skoll
2bf73987ac Don't need to flush unless we're about to print. 2024-06-04 11:56:05 -04:00
Dianne Skoll
3e9eeea8dc Update docs; kill time-limiter when we queue. 2024-06-04 11:51:27 -04:00
Dianne Skoll
d164d72c1c Update test file 2024-06-04 09:02:50 -04:00
Dianne Skoll
632cee62d9 Don't permit unary-minus overflow. 2024-06-04 09:02:26 -04:00
Dianne Skoll
7a40260f0d Add some expression evaluation tests. 2024-06-04 08:37:19 -04:00
Dianne Skoll
09f043b3de Don't print bytes allocated --- makes test output differ on different architectures. 2024-06-04 07:32:53 -04:00
Dianne Skoll
c0341c8ba3 Fix typo. 2024-06-03 21:54:12 -04:00
Dianne Skoll
850c717803 Handle unary '+' properly. 2024-06-03 20:20:54 -04:00
Dianne Skoll
f13f9e18bd Somewhat better error reporting. 2024-06-03 20:14:11 -04:00
Dianne Skoll
8bdca0d684 More code refactoring. 2024-06-03 19:49:36 -04:00
Dianne Skoll
129bf5612e Refactor some code. 2024-06-03 19:43:28 -04:00
Dianne Skoll
829962fae1 We don't need to check for excessive parse depth if we're not at the high water mark. 2024-06-03 19:35:42 -04:00
Dianne Skoll
c5f9ed8541 Fix logic error 2024-06-03 18:04:10 -04:00
Dianne Skoll
4a7cef4644 Better error diagnostics. 2024-06-03 18:02:19 -04:00
Dianne Skoll
0e010b56ec Fix some error messages. 2024-06-03 17:59:11 -04:00
Dianne Skoll
ee179ee2f5 Suppress duplicate call frames. 2024-06-03 17:47:38 -04:00
Dianne Skoll
e28712cef3 Add "s" to list of debug flags. 2024-06-03 16:16:44 -04:00
Dianne Skoll
8f0a2a7e79 Limit parse high-water to 2000 2024-06-03 15:15:58 -04:00
Dianne Skoll
ef23bba77f Track parse level high-water mark. 2024-06-03 15:13:32 -04:00
Dianne Skoll
602086ae2d Make "-ds" show built-in functions with ucfirst and user-defined ones all lower-case. 2024-06-03 14:56:32 -04:00
Dianne Skoll
f5a170acbd Update man page. 2024-06-03 11:58:37 -04:00
Dianne Skoll
8125b96f0b Add --max-excution-time cmdline option. 2024-06-03 10:40:58 -04:00
Dianne Skoll
0bb7d89bb9 Update man page. 2024-06-03 10:14:36 -04:00
Dianne Skoll
eb109bbbc0 Finish commenting expr.c 2024-06-03 10:01:38 -04:00
Dianne Skoll
1a0809fd31 Start updating man page. 2024-06-02 23:23:06 -04:00
Dianne Skoll
09625b9d68 More docs 2024-06-02 23:07:49 -04:00
Dianne Skoll
4e164c4268 More comments. 2024-06-02 21:08:04 -04:00
Dianne Skoll
691185f22c Update test file so tests pass. 2024-06-02 20:50:34 -04:00
Dianne Skoll
a8bfb41a9e Add $ExpressionTimeLimit system variable. 2024-06-02 14:01:17 -04:00
Dianne Skoll
fafb30db05 Add --max-execution-time option 2024-06-02 12:56:46 -04:00
Dianne Skoll
243e816523 Add translated error messages 2024-06-02 12:43:32 -04:00
Dianne Skoll
b49c0f52bd Implement EXPR ON and EXPR OFF 2024-06-02 12:39:00 -04:00
Dianne Skoll
07fca94a7f Properly handle purging of SCANFROM reminders. 2024-06-02 12:07:12 -04:00
Dianne Skoll
73917ee537 Only set nonconst_expr in purge mode in a couple of cases. 2024-06-02 12:02:29 -04:00
Dianne Skoll
76f9edecf6 Don't purge reminders with a SCANFROM clause. 2024-06-02 10:36:21 -04:00
Dianne Skoll
d77d9854d2 Remove src/expr.h - everything in it is now in types.h or protos.h 2024-06-02 10:26:41 -04:00
Dianne Skoll
c2b53f95a4 Remove dead code 2024-06-02 10:23:24 -04:00
Dianne Skoll
caef8b80d6 Make it easier to match error messages to error constants. 2024-06-02 10:00:04 -04:00
Dianne Skoll
5e016768af More comments. 2024-06-02 09:46:53 -04:00
Dianne Skoll
ee08ce98d7 More comments. 2024-06-01 23:33:33 -04:00
Dianne Skoll
581bd95838 Allow placing a literal [ in a reminder by using [[ 2024-06-01 18:46:17 -04:00
Dianne Skoll
bb92dab1ab More docs. 2024-06-01 16:44:37 -04:00
Dianne Skoll
83b5c52c76 Make parse_expr_token much any following whitespace to replicate prior behavior.
There may be other parts of the code that rely on this.
2024-06-01 16:35:20 -04:00
Dianne Skoll
93eca25141 Fix spurious "Missing ']'" error reported by Jochen Sprickerhof 2024-06-01 16:30:48 -04:00
Dianne Skoll
34421cb10e Don't funset the Jewish holiday functions. 2024-06-01 14:08:48 -04:00
Dianne Skoll
29b87898aa Add some ASCII art 2024-06-01 14:00:39 -04:00
Dianne Skoll
e9e4db94bd More comments 2024-06-01 13:44:21 -04:00
Dianne Skoll
c95ad0261a Start adding comments; do not distinguish between N_BINARY_OPERATOR and N_UNARY_OPERATOR 2024-06-01 13:37:58 -04:00
Dianne Skoll
7fef456483 Don't allocate - nodes if we don't need to 2024-06-01 13:23:52 -04:00
Dianne Skoll
386131e74d Show bytes used for expression notes. 2024-06-01 09:45:37 -04:00
Dianne Skoll
824d3c88f1 Store at most 5 function args on stack. Any more and we malloc. 2024-06-01 09:41:26 -04:00
Dianne Skoll
18a206abd2 Store args on stack if possible. 2024-06-01 09:30:42 -04:00
Dianne Skoll
8dbae776c9 Fix SEGV. 2024-06-01 09:27:27 -04:00
Dianne Skoll
b78702cc53 Assume all function names are lower-case. 2024-06-01 08:46:27 -04:00
Dianne Skoll
d2b43605ad Completely revamp expression engine. 2024-06-01 08:19:12 -04:00
Dianne Skoll
7728e09337 Don't allow duplicate arg names in function definitions. 2024-06-01 08:19:09 -04:00
Dianne Skoll
2666353ce6 Put an include guard around auto.rem 2024-06-01 08:19:08 -04:00
Dianne Skoll
0b8a306483 Disable CI for "wip" branches. 2024-06-01 08:19:08 -04:00
Dianne Skoll
b51a0b2d08 Document that -ivar is the same as -ivar=0 2024-05-25 10:26:00 -04:00
Dianne Skoll
959355b19c Stricter parsing of '-i' option. 2024-05-25 09:36:33 -04:00
Dianne Skoll
9c3f0f1994 Allow "-ifoo" on the command-line, which is the same as "-ifoo=0" 2024-05-25 09:22:41 -04:00
Dianne Skoll
dac337a65b Convert all leading spaces to tabs. Per Tim Chase. 2024-05-01 09:48:59 -04:00
Dianne Skoll
98739dfdbc Replace spaces with tab (per Emanuele Torre)
Because different invisible things are different.
2024-05-01 09:11:19 -04:00
Dianne Skoll
17b7a1ea84 Fix typo 2024-04-29 17:13:52 -04:00
Dianne Skoll
4d45925758 Fix typo 2024-04-29 16:18:49 -04:00
Dianne Skoll
8cadb23f48 Update release notes. 2024-04-29 16:16:42 -04:00
Dianne Skoll
63211b65c2 Bump version to 04.03.07 2024-04-22 14:55:47 -04:00
Dianne Skoll
1be84525b1 Don't rely on behavior of "%" with negative args. 2024-04-22 09:57:32 -04:00
Dianne Skoll
67ae95a464 Make sure shellescape() does not mangle UTF-8 characters. 2024-04-22 09:50:17 -04:00
Dianne Skoll
c03a95ad94 Use built-in versions of strdup, strcasecmp and strncasecmp instead of writing our own. 2024-04-21 14:44:24 -04:00
Dianne Skoll
51aa7aecb9 Make $Tt a synonym for trigtime() 2024-04-20 11:50:39 -04:00
Dianne Skoll
592cfe5a20 Use "uint32_t" if we have <stdint.h> for MD5 code. 2024-04-20 10:50:44 -04:00
Dianne Skoll
b4cf15e73e Remove some unused autoconf cruft. 2024-04-20 10:45:22 -04:00
Dianne Skoll
862e143372 Ugh, forgot to regen ./configure. 2024-04-20 10:40:06 -04:00
Dianne Skoll
1f10ca49ad Pass proper args to AC_INIT; include Remind home page in usage output. 2024-04-20 10:39:12 -04:00
Dianne Skoll
4a0c4ffdca Add a test to ensure we don't save trigger time while parsing. 2024-04-18 23:48:30 -04:00
Dianne Skoll
27c8737f3a Only save trigger date when computing it, not while parsing. 2024-04-18 23:41:47 -04:00
Dianne Skoll
ecf45fc453 Add tests for commit 0a1178cfd7: Don't clear out last trigger time unnecessarily. 2024-04-18 18:32:38 -04:00
Dianne Skoll
0a1178cfd7 Don't clear out last trigger time unnecessarily. 2024-04-18 17:56:49 -04:00
Dianne Skoll
20a35dc627 Put the tabbed notebook blurb after the blurb about obtaining default settings. 2024-04-10 09:44:40 -04:00
Dianne Skoll
79887c06f0 Tweak wording. 2024-04-10 09:43:13 -04:00
Dianne Skoll
f7ff424904 Remove debugging line. 2024-04-04 13:43:44 -04:00
Dianne Skoll
6678721fe3 Make build.tk add a little note if it obtained default settings from an existing Remind installation. 2024-04-04 13:42:31 -04:00
Dianne Skoll
496302097b Add a missing release note... sigh. 2024-04-02 09:13:59 -04:00
Dianne Skoll
fe3e2b9a20 Install include files with proper permissions. 2024-04-02 09:05:25 -04:00
Dianne Skoll
400a6b066f Add Portuguese holidays, courtesy of Joop Kiefte. 2024-04-02 09:01:45 -04:00
Dianne Skoll
76d181e7fc Update docs 2024-04-02 08:56:27 -04:00
Dianne Skoll
77373eed2d Fix tests on FreeBSD. We need to copy the results of getenv or when we change it, it will be overwritten. 2024-04-02 08:54:40 -04:00
Dianne Skoll
6b52be388f Update docs. 2024-04-02 08:23:21 -04:00
Dianne Skoll
0518a12a91 Don't fail make install if we can't jigger desktop icons. 2024-04-01 14:42:17 -04:00
Dianne Skoll
362a02c4b8 Don't include inotify-related code if we don't have inotify.
Fixes bug that broke compilation on FreeBSD.
2024-04-01 14:24:00 -04:00
Dianne Skoll
3e3a0cde47 Add "all" option to compare-language-mods.pl 2024-04-01 12:03:34 -04:00
Dianne Skoll
c16f93effd Update WHATSNEW. 2024-04-01 09:14:25 -04:00
Dianne Skoll
61b27c02b5 Be a little more aggressive. 2024-04-01 09:07:13 -04:00
Dianne Skoll
ba28eaad53 Fix typo. 2024-04-01 08:42:48 -04:00
Dianne Skoll
92c2d0cc9f Remove obsolete #ifdef tests 2024-04-01 08:41:29 -04:00
Dianne Skoll
21d5e8a095 Tweak daemon mode documentation. 2024-04-01 08:39:24 -04:00
Dianne Skoll
60417d68a7 Bump version to 04.03.05 2024-04-01 08:31:59 -04:00
Dianne Skoll
7d25387403 Remove the MICROSOFT-AND-APPLE file. I think I've made my point. 2024-03-31 12:07:11 -04:00
Dianne Skoll
b454cf5b20 Refactor set_cloexec to make it more convenient to call. 2024-03-31 09:49:32 -04:00
Dianne Skoll
9ea6385b72 Tweak whitespace. 2024-03-31 09:42:13 -04:00
Dianne Skoll
55b7908444 Add International Transgender Day of Visibility to man page
Done to annoy the anti-LGBT crowd.
2024-03-31 09:40:58 -04:00
Dianne Skoll
e9ff66478b Document that we use inotify, where possible, to detect changes to reminder scripts / directories. 2024-03-30 13:25:57 -04:00
Dianne Skoll
d3240d711d Rename DaemonWait to ServerWait. 2024-03-29 19:57:47 -04:00
Dianne Skoll
a8d63a4199 Use inotfy even in normal daemon mode (-zn where n>0) to detect file changes. 2024-03-29 08:28:41 -04:00
Dianne Skoll
a4807a21c3 Save the value of $DefaultColor that was in effect at the time a reminder was queued. Restore this value when triggering the reminder. 2024-03-26 11:44:42 -04:00
Dianne Skoll
a394ef53a0 Print the "passthru" field for PASSTHRU_TYPE reminders when listing the queue. 2024-03-26 11:29:37 -04:00
Dianne Skoll
eb8243743a Prevent mishandling of SPECIAL COLOR reminders when pulling them from the queue.
Bug reported by Damien Tardy-Panis.
2024-03-26 11:21:17 -04:00
Dianne Skoll
8444bb15c5 Fix typo. 2024-03-26 09:54:31 -04:00
99 changed files with 10209 additions and 4156 deletions

2
.gitignore vendored
View File

@@ -22,6 +22,7 @@ rem2pdf/Makefile.PL
rem2pdf/Makefile.old
rem2pdf/Makefile.top
rem2pdf/bin/rem2pdf
scripts/tkremind
set-irc-topic
src/*.tar.gz*
src/Makefile
@@ -33,3 +34,4 @@ src/version.h
tests/test.out
www/Makefile
gmon.out
tests/once.timestamp

View File

@@ -1,3 +1,8 @@
workflow:
rules:
- if: $CI_COMMIT_BRANCH =~ /wip/
when: never
tests:
image: 'debian:stable-slim'
before_script:

View File

@@ -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

View File

@@ -24,7 +24,7 @@ install:
@$(MAKE) -C rem2pdf -f Makefile.top install INSTALL_BASE=$(INSTALL_BASE)
clean:
find . -name '*~' -exec rm {} \;
-rm man/rem.1 man/rem2ps.1 man/remind.1 man/tkremind.1
-rm man/rem.1 man/rem2ps.1 man/remind.1 man/tkremind.1 scripts/tkremind
-$(MAKE) -C src clean
-$(MAKE) -C rem2pdf clean

View File

@@ -15,6 +15,8 @@
# the next line restarts using wish \
exec wish "$0" "$@"
global RemindExecutable
#***********************************************************************
# %PROCEDURE: SetConfigDefaults
# %ARGUMENTS:
@@ -40,7 +42,7 @@ proc SetConfigDefaults {} {
set Config(WESTERN_HEMISPHERE) 1
set Config(LANGUAGE) "English"
set Config(INST_DIR) "/usr/local/bin"
set Config(MAN_DIR) "/usr/local/man"
set Config(MAN_DIR) "/usr/local/share/man"
}
#***********************************************************************
@@ -124,7 +126,7 @@ proc CreateMainDialog {} {
# Creates the "installation directories" dialog.
#***********************************************************************
proc CreateInstallDirDialog { w } {
global Config
global Config RemindExecutable
label $w.binlabel -text "Location for programs: "
entry $w.bin -width 30
$w.bin insert end $Config(INST_DIR)
@@ -133,16 +135,19 @@ proc CreateInstallDirDialog { w } {
entry $w.man -width 30
$w.man insert end $Config(MAN_DIR)
text $w.blurb -width 1 -height 5 -wrap word -relief flat -takefocus 0
$w.blurb insert end "\n(Tabbed-notebook Tcl code taken from \"Effective Tcl/Tk Programming\" by Mark Harrison and Michael McLennan, Addison-Wesley Professional Computing Series.)"
$w.blurb configure -state disabled
# Disable all text-window behaviour
bindtags $w.blurb {NoSuchTag}
text $w.blurb -width 1 -height 20 -wrap word -relief flat -takefocus 0
if { "$RemindExecutable" != "" } {
$w.blurb insert end "Note: Default settings were obtained by querying the existing installed version of Remind found at: $RemindExecutable\n"
}
$w.blurb insert end "\n(Tabbed-notebook Tcl code taken from \"Effective Tcl/Tk Programming\" by Mark Harrison and Michael McLennan, Addison-Wesley Professional Computing Series.)\n"
grid $w.binlabel -row 0 -column 0 -sticky e
grid $w.bin -row 0 -column 1 -sticky nsew
grid $w.manlabel -row 1 -column 0 -sticky e
grid $w.man -row 1 -column 1 -sticky nsew
grid $w.blurb - -sticky nsew
# Disable all text-window behaviour
bindtags $w.blurb {NoSuchTag}
$w.blurb configure -state disabled
}
#***********************************************************************
@@ -727,7 +732,7 @@ proc notebook_fix_size {win} {
#***********************************************************************
proc FindRemind {} {
global env
set path [concat [split $env(PATH) ":"] "/bin" "/usr/bin" "/usr/local/bin"]
set path [concat [split $env(PATH) ":"] "/usr/local/bin" "/bin" "/usr/bin" ]
foreach thing $path {
if [file executable [file join $thing "remind"]] {
return [file join $thing "remind"]
@@ -745,16 +750,17 @@ proc FindRemind {} {
# sensible defaults.
#***********************************************************************
proc SetConfigFromRemind {} {
global Config
global Config RemindExecutable
SetConfigDefaults
set rem [FindRemind]
set RemindExecutable $rem
if {"$rem" == ""} {
return
}
set dir [file dirname $rem]
set Config(INST_DIR) $dir
if {"$dir" == "/usr/local/bin"} {
set Config(MAN_DIR) "/usr/local/man"
set Config(MAN_DIR) "/usr/local/share/man"
} elseif {$dir == "/usr/bin"} {
set Config(MAN_DIR) "/usr/share/man"
}
@@ -764,6 +770,8 @@ proc SetConfigFromRemind {} {
set Config(MAN_DIR) "/usr/share/man"
} elseif {[file readable "/usr/man/man1/remind.1"]} {
set Config(MAN_DIR) "/usr/man"
} elseif {[file readable "/usr/local/share/man/man1/remind.1"]} {
set Config(MAN_DIR) "/usr/local/share/man"
} elseif {[file readable "/usr/local/man/man1/remind.1"]} {
set Config(MAN_DIR) "/usr/local/man"
}

126
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.71.
# Generated by GNU Autoconf 2.71 for remind 05.00.07.
#
#
# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
@@ -606,12 +606,12 @@ MFLAGS=
MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME=''
PACKAGE_TARNAME=''
PACKAGE_VERSION=''
PACKAGE_STRING=''
PACKAGE_NAME='remind'
PACKAGE_TARNAME='remind'
PACKAGE_VERSION='05.00.07'
PACKAGE_STRING='remind 05.00.07'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
PACKAGE_URL='https://dianne.skoll.ca/projects/remind/'
ac_unique_file="src/queue.c"
# Factoring default headers for most tests.
@@ -651,6 +651,7 @@ LIBOBJS
RELEASE_DATE
PERLARTIFACTS
VERSION
CONFIG_CMD
PERL
SET_MAKE
LN_S
@@ -757,7 +758,7 @@ localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
@@ -1264,7 +1265,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures this package to adapt to many kinds of systems.
\`configure' configures remind 05.00.07 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1313,7 +1314,7 @@ Fine tuning of the installation directories:
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
--docdir=DIR documentation root [DATAROOTDIR/doc/remind]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
@@ -1325,7 +1326,9 @@ _ACEOF
fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of remind 05.00.07:";;
esac
cat <<\_ACEOF
Optional Features:
@@ -1348,6 +1351,7 @@ Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider.
remind home page: <https://dianne.skoll.ca/projects/remind/>.
_ACEOF
ac_status=$?
fi
@@ -1411,7 +1415,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
configure
remind configure 05.00.07
generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
@@ -1861,7 +1865,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was
It was created by remind $as_me 05.00.07, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw
@@ -2450,7 +2454,6 @@ as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"
as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"
as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"
as_fn_append ac_header_c_list " sys/time.h sys_time_h HAVE_SYS_TIME_H"
as_fn_append ac_header_c_list " utime.h utime_h HAVE_UTIME_H"
# Auxiliary files required by this configure script.
ac_aux_files="install-sh"
@@ -4004,6 +4007,12 @@ printf "%s\n" "#define SIZEOF_TIME_T $ac_cv_sizeof_time_t" >>confdefs.h
ac_fn_c_check_header_compile "$LINENO" "strings.h" "ac_cv_header_strings_h" "$ac_includes_default"
if test "x$ac_cv_header_strings_h" = xyes
then :
printf "%s\n" "#define HAVE_STRINGS_H 1" >>confdefs.h
fi
ac_fn_c_check_header_compile "$LINENO" "sys/types.h" "ac_cv_header_sys_types_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_types_h" = xyes
then :
@@ -4080,60 +4089,6 @@ printf "%s\n" "#define TM_IN_SYS_TIME 1" >>confdefs.h
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether utime accepts a null argument" >&5
printf %s "checking whether utime accepts a null argument... " >&6; }
if test ${ac_cv_func_utime_null+y}
then :
printf %s "(cached) " >&6
else $as_nop
rm -f conftest.data; >conftest.data
# Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
if test "$cross_compiling" = yes
then :
ac_cv_func_utime_null='guessing yes'
else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$ac_includes_default
#ifdef HAVE_UTIME_H
# include <utime.h>
#endif
int
main (void)
{
struct stat s, t;
return ! (stat ("conftest.data", &s) == 0
&& utime ("conftest.data", 0) == 0
&& stat ("conftest.data", &t) == 0
&& t.st_mtime >= s.st_mtime
&& t.st_mtime - s.st_mtime < 120);
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"
then :
ac_cv_func_utime_null=yes
else $as_nop
ac_cv_func_utime_null=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_utime_null" >&5
printf "%s\n" "$ac_cv_func_utime_null" >&6; }
if test "x$ac_cv_func_utime_null" != xno; then
ac_cv_func_utime_null=yes
printf "%s\n" "#define HAVE_UTIME_NULL 1" >>confdefs.h
fi
rm -f conftest.data
if test "$GCC" = yes; then
CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes"
# Check for link-time optimization support
@@ -4181,6 +4136,24 @@ if test "$?" != 0 ; then
echo "*** COULD NOT DETERMINE RELEASE DATE: docs/WHATSNEW is incorrect!"
exit 1
fi
ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup"
if test "x$ac_cv_func_strdup" = xyes
then :
printf "%s\n" "#define HAVE_STRDUP 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp"
if test "x$ac_cv_func_strcasecmp" = xyes
then :
printf "%s\n" "#define HAVE_STRCASECMP 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "strncasecmp" "ac_cv_func_strncasecmp"
if test "x$ac_cv_func_strncasecmp" = xyes
then :
printf "%s\n" "#define HAVE_STRNCASECMP 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "setenv" "ac_cv_func_setenv"
if test "x$ac_cv_func_setenv" = xyes
then :
@@ -4225,12 +4198,18 @@ then :
fi
VERSION=04.03.04
VERSION=$PACKAGE_VERSION
CONFIG_CMD="$0$ac_configure_args_raw"
CONFIG_CMD=`echo "$CONFIG_CMD" | sed -e 's/"/\\\\"/g'`
printf "%s\n" "#define CONFIG_CMD \"$CONFIG_CMD\"" >>confdefs.h
ac_config_files="$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_config_files="$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 scripts/tkremind"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -4731,7 +4710,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by $as_me, which was
This file was extended by remind $as_me 05.00.07, which was
generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -4787,7 +4766,8 @@ $config_files
Configuration headers:
$config_headers
Report bugs to the package provider."
Report bugs to the package provider.
remind home page: <https://dianne.skoll.ca/projects/remind/>."
_ACEOF
ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"`
@@ -4795,7 +4775,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
config.status
remind config.status 05.00.07
configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\"
@@ -4930,6 +4910,7 @@ do
"man/rem2ps.1") CONFIG_FILES="$CONFIG_FILES man/rem2ps.1" ;;
"man/remind.1") CONFIG_FILES="$CONFIG_FILES man/remind.1" ;;
"man/tkremind.1") CONFIG_FILES="$CONFIG_FILES man/tkremind.1" ;;
"scripts/tkremind") CONFIG_FILES="$CONFIG_FILES scripts/tkremind" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
@@ -5517,4 +5498,5 @@ printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2
fi
chmod a+x rem2pdf/bin/rem2pdf
chmod a+x scripts/tkremind

View File

@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT
AC_INIT(remind, 05.00.07, , , https://dianne.skoll.ca/projects/remind/)
AC_CONFIG_SRCDIR([src/queue.c])
cat <<'EOF'
@@ -30,7 +30,7 @@ AC_PATH_PROG([PERL], [perl])
dnl Checks for libraries.
AC_CHECK_LIB(m, sqrt)
AC_CHECK_HEADERS_ONCE([sys/time.h])
AC_CHECK_HEADERS_ONCE([sys/time.h stdint.h])
dnl Integer sizes
AC_CHECK_SIZEOF(unsigned int)
@@ -38,13 +38,11 @@ AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(time_t)
dnl Checks for header files.
AC_CHECK_HEADERS(sys/types.h glob.h wctype.h locale.h langinfo.h sys/inotify.h)
AC_CHECK_HEADERS(strings.h sys/types.h glob.h wctype.h locale.h langinfo.h sys/inotify.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_STRUCT_TM
dnl Checks for library functions.
AC_FUNC_UTIME_NULL
if test "$GCC" = yes; then
CFLAGS="$CFLAGS -Wall -Wextra -Wstrict-prototypes"
# Check for link-time optimization support
@@ -86,13 +84,18 @@ if test "$?" != 0 ; then
echo "*** COULD NOT DETERMINE RELEASE DATE: docs/WHATSNEW is incorrect!"
exit 1
fi
AC_CHECK_FUNCS(setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1)
AC_CHECK_FUNCS(strdup strcasecmp strncasecmp setenv unsetenv glob mbstowcs setlocale initgroups inotify_init1)
VERSION=04.03.04
VERSION=$PACKAGE_VERSION
CONFIG_CMD="$0$ac_configure_args_raw"
CONFIG_CMD=`echo "$CONFIG_CMD" | sed -e 's/"/\\\\"/g'`
AC_DEFINE_UNQUOTED([CONFIG_CMD], ["$CONFIG_CMD"], [Configuration command used to build Remind])
AC_SUBST(CONFIG_CMD)
AC_SUBST(VERSION)
AC_SUBST(PERL)
AC_SUBST(PERLARTIFACTS)
AC_SUBST(RELEASE_DATE)
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_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 scripts/tkremind])
AC_OUTPUT
chmod a+x rem2pdf/bin/rem2pdf
chmod a+x scripts/tkremind

View File

@@ -0,0 +1,3 @@
The upstream GitHub project for ical2rem is:
https://github.com/jbalcorn/ical2rem

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2005, 2007, 2019 Justin B. Alcorn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,103 @@
# ical2rem
The original iCal to Remind script, first released in 2005.
Reads iCal files and outputs remind-compatible files. Tested ONLY with
calendar files created by Mozilla Calendar/Sunbird. Use at your own risk.
## License
In 2005, this was released with the Gnu Public License V2. However, I am changing it to the MIT License, since that provides greater freedom to do with this code what you want.
Copyright (c) 2005, 2007, 2019 Justin B. Alcorn
## How I use Remind and Google Calendar together
- My family has a Google Email domain, and our email addresses all end in the same domain. We all use Google Calendars and I want to mail reminders to each of the family members containing both Google Calendar and .reminder information.
- Under my ~/.rem/ directory each family member has a directory. Each directory contains a standard remind file called 'reminders' that at the very least has the line "INCLUDE /home/jalcorn/.rem/<username>/ical2rem" and flag files indicating whether they want Daily or Weekly reminders. My reminders files references my standard .reminders file, and I also have a flag so if I run a Test run I'll get it. There's actually a lot more files (I have a big family).
````
./rem
./son1:
drwxrwxr-x 2 jalcorn jalcorn 4096 Dec 12 14:02 .
drwxr-xr-x 12 jalcorn jalcorn 4096 Dec 12 14:13 ..
-rw-rw-r-- 1 jalcorn jalcorn 51 Mar 3 06:10 ical2rem
lrwxrwxrwx 1 jalcorn jalcorn 33 Oct 27 2016 son1.ics -> /home/jalcorn/calendars/son1.ics
-rw-rw-r-- 1 jalcorn jalcorn 976 Dec 12 14:02 reminders
-rw-rw-r-- 1 jalcorn jalcorn 0 Oct 27 2016 Weekly
./justin:
drwxrwxr-x 2 jalcorn jalcorn 4096 Feb 27 08:29 .
drwxr-xr-x 12 jalcorn jalcorn 4096 Dec 12 14:13 ..
lrwxrwxrwx 1 jalcorn jalcorn 32 Oct 27 2016 son1.ics -> /home/jalcorn/calendars/son1.ics
-rw-rw-r-- 1 jalcorn jalcorn 0 Nov 7 2016 Daily
lrwxrwxrwx 1 jalcorn jalcorn 34 Oct 27 2016 family.ics -> /home/jalcorn/calendars/family.ics
-rw-rw-r-- 1 jalcorn jalcorn 37320 Mar 3 06:10 ical2rem
lrwxrwxrwx 1 jalcorn jalcorn 34 Oct 27 2016 justin.ics -> /home/jalcorn/calendars/justin.ics
lrwxrwxrwx 1 jalcorn jalcorn 24 Nov 7 2016 reminders -> /home/jalcorn/.reminders
lrwxrwxrwx 1 jalcorn jalcorn 34 Oct 27 2016 vmd.ics -> /home/jalcorn/calendars/vmd.ics
-rw-rw-r-- 1 jalcorn jalcorn 0 Oct 27 2016 Test
-rw-rw-r-- 1 jalcorn jalcorn 0 Nov 7 2016 Weekly
````
- bin/getgooglecals.sh runs out of crontab and downloads whatever calendars I want. Note that we can also download organization calendars, I've included a public one here (Cleveland Heights Vocal Music Department calendar).
- dailyreminders.sh is linked to weeklyreminders.sh and testreminders.sh so I can run it in different modes. The concatenate the various calendar outputs as a single remind file then send the reminders via email.
### Example: .rem/son1/reminders file:
````
INCLUDE /home/jalcorn/.rem/defs.rem
INCLUDE /home/jalcorn/.rem/float
INCLUDE /home/jalcorn/.rem/son1/ical2rem
fset _weeks() coerce("STRING", (trigdate()-today())/7) + plural((trigdate()-today())/7, " week")
FSET _sfun(x) choose(x, -60, 30, 5, 0)
FSET oldfloat(y,m,d) trigger(MAX(realtoday(), date(y,m,d)))
FSET due(y,m,d) "(" + (date(y,m,d)-trigdate()) + ")"
SET fullmoon moondate(2)
REM [trigger(realtoday())] SPECIAL SHADE 145 70 100 %
REM [float(2019,4,15,105)] MSG File tax return [due(2017,4,15)]%
REM PRIORITY 9999 MSG %"%"%
INCLUDE /home/jalcorn/.rem/bdays
SET $LongDeg 81
SET $LongMin 11
SET $LongSec 11
SET $LatDeg 41
SET $LatMin 11
SET $LatSec 11
REM [trigger(moondate(2))] +1 MSG %"Full Moon%" %b%
fset _srtd() coerce("STRING", _no_lz(_am_pm(sunrise(today()))))
fset _sstd() coerce("STRING", _no_lz(_am_pm(sunset(today()))))
MSG Sun is up today from [_srtd()] to [_sstd()].%"%"%
````
## Revision History
### Version 0.7 2024-09-04
- ISSUE 8: New version of remind complains if _sfun isn't defined. Output a header
to define a function that does nothing if the function doesn't exist.
### Version 0.6 2019-03-01
- Publish on GitHub and change license to MIT License
- Add supporting files and explanation of how I use it
### version 0.5.2 2007-03-23
- BUG: leadtime for recurring events had a max of 4 instead of DEFAULT_LEAD_TIME
- remove project-lead-time, since Category was a non-standard attribute
- NOTE: There is a bug in iCal::Parser v1.14 that causes multiple calendars to
fail if a calendar with recurring events is followed by a calendar with no
recurring events. This has been reported to the iCal::Parser author.
### version 0.5.1 2007-03-21
- BUG: Handle multiple calendars on STDIN
- add --heading option for priority on section headers
### version 0.5 2007-03-21
- Add more help options
- --project-lead-time option
- Supress printing of heading if there are no todos to print
### version 0.4
- Version 0.4 changes all written or inspired by, and thanks to Mark Stosberg
- Change to GetOptions
- Change to pipe
- Add --label, --help options
- Add Help Text
- Change to subroutines
- Efficiency and Cleanup
### version 0.3
- Convert to GPL (Thanks to Mark Stosberg)
- Add usage
### version 0.2
- add command line switches
- add debug code
- add SCHED _sfun keyword
- fix typos
### version 0.1 - ALPHA CODE.

View File

@@ -0,0 +1,82 @@
#!/usr/bin/perl -w
#
# cal_futureonly.pl -
# Reads iCal files and outputs events between 1 month ago and 1 year from now.
# Copyright (c) 2005, 2007, 2019 Justin B. Alcorn
=head1 SYNOPSIS
cal_futureonly.pl --file=filname.ics > output.ics
--help Usage
--man Complete man page
--infile (REQUIRED) name of input calendar file
--file (REQUIRED) name of output calendar file
Expects an ICAL stream on STDIN. Converts it to the format
used by the C<remind> script and prints it to STDOUT.
=head2 --infile
Input file
=head2 --file
Output File
=cut
use strict;
use Data::ICal;
use Data::ICal::Entry;
use DateTime::Span;
use Data::ICal::DateTime;
use DateTime;
use Getopt::Long 2.24 qw':config auto_help';
use Pod::Usage;
use Data::Dumper;
use vars '$VERSION';
$VERSION = "0.1";
my $help;
my $man;
my $infile;
my $file;
my $debug = 0;
GetOptions (
"help|?" => \$help,
"man" => \$man,
"debug" => \$debug,
"infile=s" => \$infile,
"file=s" => \$file
);
pod2usage(1) if $help;
pod2usage(1) if (! $file);
pod2usage(-verbose => 2) if $man;
my $limit = DateTime->now();
$limit->subtract( months => 1);
my $endlimit = DateTime->now()->add(years =>1);
print STDERR "including events from: ",$limit->ymd," to: ".$endlimit->ymd,"\n" if $debug;
my $span = DateTime::Span->from_datetimes( start => $limit, end => $endlimit );
print STDERR "Parsing $infile\n" if $debug;
my $cal = Data::ICal->new(filename => $infile);
if (! $cal) {
die "Died Trying to read $infile :".$cal->error_message;
}
#my $archive = Data::ICal->new(filename => 'archive.ics');
print "Output = $file\n" if $debug;
my $new = Data::ICal->new();
if (! $new) {
die $new->error_message;
}
my @events = $cal->events($span);
$new->add_entries(@events);
open(NEW, ">$file");
print NEW $new->as_string;
close NEW;
exit 0;
#:vim set ft=perl ts=4 sts=4 expandtab :

View File

@@ -0,0 +1,45 @@
#!/bin/bash
r=`basename $0`
if [ $r == 'weeklyreminders.sh' ];
then
t=14;
w=Weekly;
elif [ $r == 'dailyreminders.sh' ];
then
t=3;
w=Daily;
else
t=5
w=Test;
fi
cd .rem
for d in * ;
do
if [ "$( ls -A $d/$w 2>/dev/null )" ];
then
echo "Sending a $w reminder to $d"
ft=/tmp/$d-t-$$.txt
f=/tmp/$d-$$.txt
echo "Reminders for next $t days:" >> $f
cat /dev/null > $d/ical2rem
for c in $d/*.ics
do
calname=`basename $c .ics | tr a-z A-Z`
cat $c 2>/dev/null | sed -e "s/^SUMMARY:/SUMMARY: {${calname}} /" \
| sed -e 's/DT\([A-Z]*\);TZID=UTC:\([0-9T]*\)/DT\1:\2Z/' >> $ft
done
cat $ft | ~/bin/ical2rem.pl --label "Online Calendar" --heading "PRIORITY 9999" --lead-time $t >> $d/ical2rem
if [ -e $d/reminders ];then r="${d}/reminders"; else r="${d}/ical2rem";fi
/usr/bin/remind -q -iplain=1 $r >> $f
echo "
All calendars can be accessed by logging into https://calendar.google.com/ as $d@jalcorn.net
" >> $f
cat $f | mail -s "$w Reminders for $d" $d@jalcorn.net;
cat $f
rm $f
rm $ft
fi;
done

View File

@@ -0,0 +1,21 @@
#!/bin/sh
#
# Get google calendars, fix issues caused by changes in Google calendars, and remove all past events.
#
# Obviously, I've removed the private hashes from private calendars.
#
cd ~/calendars
wget -q -O full/justin.ics --no-check-certificate https://www.google.com/calendar/ical/jbalcorn\%40gmail.com/private-aaaaaaaaaaaaaaaaaaaaaaaaaa/basic.ics
wget -q -O full/family.ics --no-check-certificate https://www.google.com/calendar/ical/jalcorn.net_aaaaaaaaaaaaaaaaaaaaaaaaaa\%40group.calendar.google.com/private-6c42a79dec0b3b3bb7b9b0ebf9776bc1/basic.ics
wget -q -O full/son1.ics --no-check-certificate https://www.google.com/calendar/ical/son1\%40jalcorn.net/private-aaaaaaaaaaaaaaaaaaaaaaaaaa/basic.ics
wget -q -O full/vmd.ics --no-check-certificate https://calendar.google.com/calendar/ical/chuh.org_0pmkefjkiqc4snoel7occlslh8%40group.calendar.google.com/public/basic.ics
for i in full/*.ics;do
cat $i 2>/dev/null | sed -e 's/DT\([A-Z]*\);TZID=UTC:\([0-9T]*\)/DT\1:\2Z/' > /tmp/temp.ics
cp /tmp/temp.ics $i
done
~/bin/cal_futureonly.pl --infile=full/justin.ics --file=justin.ics
~/bin/cal_futureonly.pl --infile=full/family.ics --file=family.ics
~/bin/cal_futureonly.pl --infile=full/son1.ics --file=son1.ics
~/bin/cal_futureonly.pl --infile=full/vmd.ics --file=vmd.ics

396
contrib/ical2rem-0.8/ical2rem.pl Executable file
View File

@@ -0,0 +1,396 @@
#!/usr/bin/perl -w
#
# ical2rem.pl -
# Reads iCal files and outputs remind-compatible files. Tested ONLY with
# calendar files created by Mozilla Calendar/Sunbird. Use at your own risk.
# MIT License
#
# Copyright (c) 2005, 2007, 2019 Justin B. Alcorn
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# version 0.8 2024-10-16
# - Issue 9. Remove extra day notation on all day events.
# version 0.7.1 2024-09-19
# - Made sure license statements were consistent
# version 0.7 2024-09-04
# - Added dummy _sfun to resolve Issue #8
# version 0.6 2019-03-01
# - Updates to put on GitHub
# version 0.5.2 2007-03-23
# - BUG: leadtime for recurring events had a max of 4 instead of DEFAULT_LEAD_TIME
# - remove project-lead-time, since Category was a non-standard attribute
# - NOTE: There is a bug in iCal::Parser v1.14 that causes multiple calendars to
# fail if a calendar with recurring events is followed by a calendar with no
# recurring events. This has been reported to the iCal::Parser author.
# version 0.5.1 2007-03-21
# - BUG: Handle multiple calendars on STDIN
# - add --heading option for priority on section headers
# version 0.5 2007-03-21
# - Add more help options
# - --project-lead-time option
# - Supress printing of heading if there are no todos to print
# version 0.4
# - Version 0.4 changes all written or inspired by, and thanks to Mark Stosberg
# - Change to GetOptions
# - Change to pipe
# - Add --label, --help options
# - Add Help Text
# - Change to subroutines
# - Efficiency and Cleanup
# version 0.3
# - Convert to GPL (Thanks to Mark Stosberg)
# - Add usage
# version 0.2
# - add command line switches
# - add debug code
# - add SCHED _sfun keyword
# - fix typos
# version 0.1 - ALPHA CODE.
=head1 SYNOPSIS
cat /path/to/file*.ics | ical2rem.pl > ~/.ical2rem
All options have reasonable defaults:
--label Calendar name (Default: Calendar)
--start Start of time period to parse (parsed by str2time)
--end End of time period to parse
--lead-time Advance days to start reminders (Default: 3)
--todos, --no-todos Process Todos? (Default: Yes)
--iso8601 Use YYYY-MM-DD date format
--locations, --no-locations Include location? (Default: Yes)
--end-times, --no-end-times Include event end times in reminder text
(Default: No)
--heading Define a priority for static entries
--help Usage
--debug Enable debug output
--man Complete man page
Expects an ICAL stream on STDIN. Converts it to the format
used by the C<remind> script and prints it to STDOUT.
=head2 --label
ical2rem.pl --label "Bob's Calendar"
The syntax generated includes a label for the calendar parsed.
By default this is "Calendar". You can customize this with
the "--label" option.
=head2 --iso8601
Use YYYY-MM-DD date format in output instead of Mmm DD YYYY
=head2 --locations, --no-locations
Whether or not to include locations in events
=head2 --lead-time
ical2rem.pl --lead-time 3
How may days in advance to start getting reminders about the events. Defaults to 3.
=head2 --no-todos
ical2rem.pl --no-todos
If you don't care about the ToDos the calendar, this will surpress
printing of the ToDo heading, as well as skipping ToDo processing.
=head2 --heading
ical2rem.pl --heading "PRIORITY 9999"
Set an option on static messages output. Using priorities can made the static messages look different from
the calendar entries. See the file defs.rem from the remind distribution for more information.
=cut
use strict;
use iCal::Parser;
use Date::Parse;
use DateTime;
use Getopt::Long 2.24 qw':config auto_help';
use Pod::Usage;
use Data::Dumper;
use vars '$VERSION';
$VERSION = "0.5.2";
# Declare how many days in advance to remind
my $DEFAULT_LEAD_TIME = 3;
my $PROCESS_TODOS = 1;
my $HEADING = "";
my $help;
my $debug;
my $man;
my $iso8601;
my $do_location = 1;
my $do_end_times;
my $start;
my $end;
my $label = 'Calendar';
GetOptions (
"label=s" => \$label,
"start=s" => \$start,
"end=s" => \$end,
"lead-time=i" => \$DEFAULT_LEAD_TIME,
"todos!" => \$PROCESS_TODOS,
"iso8601!" => \$iso8601,
"locations!" => \$do_location,
"end-times!" => \$do_end_times,
"heading=s" => \$HEADING,
"help|?" => \$help,
"debug" => \$debug,
"man" => \$man
) or pod2usage(1);
pod2usage(1) if $help;
pod2usage(-verbose => 2) if $man;
my $month = ['None','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
my @calendars;
my $in;
while (<>) {
$in .= $_;
if (/END:VCALENDAR/) {
push(@calendars,$in);
$in = "";
}
}
print STDERR "Read all calendars\n" if $debug;
my(%parser_opts) = ("debug" => $debug);
if ($start) {
my $t = str2time($start);
die "Invalid time $start\n" if (! $t);
$parser_opts{'start'} = DateTime->from_epoch(epoch => $t);
}
if ($end) {
my $t = str2time($end);
die "Invalid time $end\n" if (! $t);
$parser_opts{'end'} = DateTime->from_epoch(epoch => $t);
}
print STDERR "About to parse calendars\n" if $debug;
my $parser = iCal::Parser->new(%parser_opts);
my $hash = $parser->parse_strings(@calendars);
print STDERR "Calendars parsed\n" if $debug;
##############################################################
#
# Subroutines
#
#############################################################
#
# _process_todos()
# expects 'todos' hashref from iCal::Parser is input
# returns String to output
sub _process_todos {
my $todos = shift;
my ($todo, @newtodos, $leadtime);
my $output = "";
$output .= 'REM '.$HEADING.' MSG '.$label.' ToDos:%"%"%'."\n";
# For sorting, make sure everything's got something
# To sort on.
my $now = DateTime->now;
for $todo (@{$todos}) {
# remove completed items
if ($todo->{'STATUS'} && $todo->{'STATUS'} eq 'COMPLETED') {
next;
} elsif ($todo->{'DUE'}) {
# All we need is a due date, everything else is sugar
$todo->{'SORT'} = $todo->{'DUE'}->clone;
} elsif ($todo->{'DTSTART'}) {
# for sorting, sort on start date if there's no due date
$todo->{'SORT'} = $todo->{'DTSTART'}->clone;
} else {
# if there's no due or start date, just make it now.
$todo->{'SORT'} = $now;
}
push(@newtodos,$todo);
}
if (! (scalar @newtodos)) {
return "";
}
# Now sort on the new Due dates and print them out.
for $todo (sort { DateTime->compare($a->{'SORT'}, $b->{'SORT'}) } @newtodos) {
my $due = $todo->{'SORT'}->clone();
my $priority = "";
if (defined($todo->{'PRIORITY'})) {
if ($todo->{'PRIORITY'} == 1) {
$priority = "PRIORITY 1000";
} elsif ($todo->{'PRIORITY'} == 3) {
$priority = "PRIORITY 7500";
}
}
if (defined($todo->{'DTSTART'}) && defined($todo->{'DUE'})) {
# Lead time is duration of task + lead time
my $diff = ($todo->{'DUE'}->delta_days($todo->{'DTSTART'})->days())+$DEFAULT_LEAD_TIME;
$leadtime = "+".$diff;
} else {
$leadtime = "+".$DEFAULT_LEAD_TIME;
}
$output .= "REM ".$due->month_abbr." ".$due->day." ".$due->year." $leadtime $priority MSG \%a $todo->{'SUMMARY'}\%\"\%\"\%\n";
}
$output .= 'REM '.$HEADING.' MSG %"%"%'."\n";
return $output;
}
#######################################################################
#
# Main Program
#
######################################################################
# Issue 8 https://github.com/jbalcorn/ical2rem/issues/8
# Make sure there is a _sfun function declared in the reminder file. We'll just make it do nothing here.
print 'IF args("_sfun") < 1
FSET _sfun(x) choose(x,0)
ENDIF
';
print _process_todos($hash->{'todos'}) if $PROCESS_TODOS;
my ($leadtime, $yearkey, $monkey, $daykey,$uid,%eventsbyuid);
print 'REM '.$HEADING.' MSG '.$label.' Events:%"%"%'."\n";
my $events = $hash->{'events'};
foreach $yearkey (sort keys %{$events} ) {
my $yearevents = $events->{$yearkey};
foreach $monkey (sort {$a <=> $b} keys %{$yearevents}){
my $monevents = $yearevents->{$monkey};
foreach $daykey (sort {$a <=> $b} keys %{$monevents} ) {
my $dayevents = $monevents->{$daykey};
foreach $uid (sort {
DateTime->compare($dayevents->{$a}->{'DTSTART'}, $dayevents->{$b}->{'DTSTART'})
} keys %{$dayevents}) {
my $event = $dayevents->{$uid};
if ($eventsbyuid{$uid}) {
my $curreventday = $event->{'DTSTART'}->clone;
$curreventday->truncate( to => 'day' );
$eventsbyuid{$uid}{$curreventday->epoch()} =1;
for (my $i = 0;$i < $DEFAULT_LEAD_TIME && !defined($event->{'LEADTIME'});$i++) {
if ($eventsbyuid{$uid}{$curreventday->subtract( days => $i+1 )->epoch() }) {
$event->{'LEADTIME'} = $i;
}
}
# Issue 9. Multi-day events have extra day with zero time. Mark this as the date not needed in reminders file so we can skip later
# Repeating multi-day events have the same uid so we need to mark each one.
if ($event->{'DTSTART'} eq $event->{'DTEND'} and $event->{'DTEND'}->hour eq 0 and $event->{'DTEND'}->minute eq 0 and $event->{'DTEND'}->second eq 0) {
$eventsbyuid{$uid}{$event->{'DTSTART'}->ymd} = 'rm';
}
} else {
$eventsbyuid{$uid} = $event;
my $curreventday = $event->{'DTSTART'}->clone;
$curreventday->truncate( to => 'day' );
$eventsbyuid{$uid}{$curreventday->epoch()} =1;
}
}
}
}
}
foreach $yearkey (sort keys %{$events} ) {
my $yearevents = $events->{$yearkey};
foreach $monkey (sort {$a <=> $b} keys %{$yearevents}){
my $monevents = $yearevents->{$monkey};
foreach $daykey (sort {$a <=> $b} keys %{$monevents} ) {
my $dayevents = $monevents->{$daykey};
foreach $uid (sort {
DateTime->compare($dayevents->{$a}->{'DTSTART'}, $dayevents->{$b}->{'DTSTART'})
} keys %{$dayevents}) {
my $event = $dayevents->{$uid};
if (exists($event->{'LEADTIME'})) {
$leadtime = "+".$event->{'LEADTIME'};
} else {
$leadtime = "+".$DEFAULT_LEAD_TIME;
}
my $start = $event->{'DTSTART'};
my $end = $event->{'DTEND'};
my $duration = "";
# Issue 9. All Day events create an event that has zero length and DTSTART and DTEND at 00:00 on last day. Marked while handling multi-day events. Ignore these
if ($start eq $end and $eventsbyuid{$uid}{$start->ymd} and $eventsbyuid{$uid}{$start->ymd} eq 'rm') {
next;
}
if ($end and ($start->hour or $start->minute or $end->hour or $end->minute)) {
# We need both an HH:MM version of the delta, to put in the
# DURATION specifier, and a human-readable version of the
# delta, to put in the message if the user requested it.
my $seconds = $end->epoch - $start->epoch;
my $minutes = int($seconds / 60);
my $hours = int($minutes / 60);
$minutes -= $hours * 60;
$duration = sprintf("DURATION %d:%02d ", $hours, $minutes);
}
print "REM ";
if ($iso8601) {
print $start->strftime("%F ");
} else {
print $start->month_abbr." ".$start->day." ".$start->year." ";
}
print "$leadtime ";
if ($duration or $start->hour > 0 or $start->minute > 0) {
print "AT ";
print $start->strftime("%H:%M");
print " SCHED _sfun ${duration}MSG %a %2 ";
} else {
print "MSG %a ";
}
print "%\"", &quote($event->{'SUMMARY'});
print(" at ", &quote($event->{'LOCATION'}))
if ($do_location and $event->{'LOCATION'});
print "\%\"";
if ($do_end_times and ($start->hour or $start->minute or
$end->hour or $end->minute)) {
my $start_date = $start->strftime("%F");
my $start_time = $start->strftime("%k:%M");
my $end_date = $end->strftime("%F");
my $end_time = $end->strftime("%k:%M");
# We don't want leading whitespace; some strftime's support
# disabling the pdding in the format string, but not all,
# so for maximum portability we do it ourselves.
$start_time =~ s/^\s+//;
$end_time =~ s/^\s+//;
my(@pieces);
if ($start_date ne $end_date) {
push(@pieces, $end_date);
}
if ($start_time ne $end_time) {
push(@pieces, $end_time);
}
print " (-", join(" ", @pieces), ")";
}
print "%\n";
}
}
}
}
sub quote {
local($_) = @_;
s/\[/["["]/g;
return $_;
}
exit 0;
#:vim set ft=perl ts=4 sts=4 tabstop=4 expandtab :

View File

@@ -1,279 +0,0 @@
#!/usr/bin/perl -w
#
# ical2rem.pl -
# Reads iCal files and outputs remind-compatible files. Tested ONLY with
# calendar files created by Mozilla Calendar/Sunbird. Use at your own risk.
# Copyright (c) 2005, 2007, Justin B. Alcorn
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# version 0.5.2 2007-03-23
# - BUG: leadtime for recurring events had a max of 4 instead of DEFAULT_LEAD_TIME
# - remove project-lead-time, since Category was a non-standard attribute
# - NOTE: There is a bug in iCal::Parser v1.14 that causes multiple calendars to
# fail if a calendar with recurring events is followed by a calendar with no
# recurring events. This has been reported to the iCal::Parser author.
# version 0.5.1 2007-03-21
# - BUG: Handle multiple calendars on STDIN
# - add --heading option for priority on section headers
# version 0.5 2007-03-21
# - Add more help options
# - --project-lead-time option
# - Suppress printing of heading if there are no todos to print
# version 0.4
# - Version 0.4 changes all written or inspired by, and thanks to Mark Stosberg
# - Change to GetOptions
# - Change to pipe
# - Add --label, --help options
# - Add Help Text
# - Change to subroutines
# - Efficiency and Cleanup
# version 0.3
# - Convert to GPL (Thanks to Mark Stosberg)
# - Add usage
# version 0.2
# - add command line switches
# - add debug code
# - add SCHED _sfun keyword
# - fix typos
# version 0.1 - ALPHA CODE.
=head1 SYNOPSIS
cat /path/to/file*.ics | ical2rem.pl > ~/.ical2rem
All options have reasonable defaults:
--label Calendar name (Default: Calendar)
--lead-time Advance days to start reminders (Default: 3)
--todos, --no-todos Process Todos? (Default: Yes)
--heading Define a priority for static entries
--help Usage
--man Complete man page
Expects an ICAL stream on STDIN. Converts it to the format
used by the C<remind> script and prints it to STDOUT.
=head2 --label
ical2rem.pl --label "Bob's Calendar"
The syntax generated includes a label for the calendar parsed.
By default this is "Calendar". You can customize this with
the "--label" option.
=head2 --lead-time
ical2rem.pl --lead-time 3
How may days in advance to start getting reminders about the events. Defaults to 3.
=head2 --no-todos
ical2rem.pl --no-todos
If you don't care about the ToDos the calendar, this will suppress
printing of the ToDo heading, as well as skipping ToDo processing.
=head2 --heading
ical2rem.pl --heading "PRIORITY 9999"
Set an option on static messages output. Using priorities can made the static messages look different from
the calendar entries. See the file defs.rem from the remind distribution for more information.
=cut
use strict;
use iCal::Parser;
use DateTime;
use Getopt::Long 2.24 qw':config auto_help';
use Pod::Usage;
use Data::Dumper;
use vars '$VERSION';
$VERSION = "0.5.2";
# Declare how many days in advance to remind
my $DEFAULT_LEAD_TIME = 3;
my $PROCESS_TODOS = 1;
my $HEADING = "";
my $help;
my $man;
my $label = 'Calendar';
GetOptions (
"label=s" => \$label,
"lead-time=i" => \$DEFAULT_LEAD_TIME,
"todos!" => \$PROCESS_TODOS,
"heading=s" => \$HEADING,
"help|?" => \$help,
"man" => \$man
);
pod2usage(1) if $help;
pod2usage(-verbose => 2) if $man;
my $month = ['None','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
my @calendars;
my $in;
while (<>) {
$in .= $_;
if (/END:VCALENDAR/) {
push(@calendars,$in);
$in = "";
}
}
my $parser = iCal::Parser->new();
my $hash = $parser->parse_strings(@calendars);
##############################################################
#
# Subroutines
#
#############################################################
#
# _process_todos()
# expects 'todos' hashref from iCal::Parser is input
# returns String to output
sub _process_todos {
my $todos = shift;
my ($todo, @newtodos, $leadtime);
my $output = "";
$output .= 'REM '.$HEADING.' MSG '.$label.' ToDos:%"%"%'."\n";
# For sorting, make sure everything's got something
# To sort on.
my $now = DateTime->now;
for $todo (@{$todos}) {
# remove completed items
if ($todo->{'STATUS'} && $todo->{'STATUS'} eq 'COMPLETED') {
next;
} elsif ($todo->{'DUE'}) {
# All we need is a due date, everything else is sugar
$todo->{'SORT'} = $todo->{'DUE'}->clone;
} elsif ($todo->{'DTSTART'}) {
# for sorting, sort on start date if there's no due date
$todo->{'SORT'} = $todo->{'DTSTART'}->clone;
} else {
# if there's no due or start date, just make it now.
$todo->{'SORT'} = $now;
}
push(@newtodos,$todo);
}
if (! (scalar @newtodos)) {
return "";
}
# Now sort on the new Due dates and print them out.
for $todo (sort { DateTime->compare($a->{'SORT'}, $b->{'SORT'}) } @newtodos) {
my $due = $todo->{'SORT'}->clone();
my $priority = "";
if (defined($todo->{'PRIORITY'})) {
if ($todo->{'PRIORITY'} == 1) {
$priority = "PRIORITY 1000";
} elsif ($todo->{'PRIORITY'} == 3) {
$priority = "PRIORITY 7500";
}
}
if (defined($todo->{'DTSTART'}) && defined($todo->{'DUE'})) {
# Lead time is duration of task + lead time
my $diff = ($todo->{'DUE'}->delta_days($todo->{'DTSTART'})->days())+$DEFAULT_LEAD_TIME;
$leadtime = "+".$diff;
} else {
$leadtime = "+".$DEFAULT_LEAD_TIME;
}
$output .= "REM ".$due->month_abbr." ".$due->day." ".$due->year." $leadtime $priority MSG \%a $todo->{'SUMMARY'}\%\"\%\"\%\n";
}
$output .= 'REM '.$HEADING.' MSG %"%"%'."\n";
return $output;
}
#######################################################################
#
# Main Program
#
######################################################################
print _process_todos($hash->{'todos'}) if $PROCESS_TODOS;
my ($leadtime, $yearkey, $monkey, $daykey,$uid,%eventsbyuid);
print 'REM '.$HEADING.' MSG '.$label.' Events:%"%"%'."\n";
my $events = $hash->{'events'};
foreach $yearkey (sort keys %{$events} ) {
my $yearevents = $events->{$yearkey};
foreach $monkey (sort {$a <=> $b} keys %{$yearevents}){
my $monevents = $yearevents->{$monkey};
foreach $daykey (sort {$a <=> $b} keys %{$monevents} ) {
my $dayevents = $monevents->{$daykey};
foreach $uid (sort {
DateTime->compare($dayevents->{$a}->{'DTSTART'}, $dayevents->{$b}->{'DTSTART'})
} keys %{$dayevents}) {
my $event = $dayevents->{$uid};
if ($eventsbyuid{$uid}) {
my $curreventday = $event->{'DTSTART'}->clone;
$curreventday->truncate( to => 'day' );
$eventsbyuid{$uid}{$curreventday->epoch()} =1;
for (my $i = 0;$i < $DEFAULT_LEAD_TIME && !defined($event->{'LEADTIME'});$i++) {
if ($eventsbyuid{$uid}{$curreventday->subtract( days => $i+1 )->epoch() }) {
$event->{'LEADTIME'} = $i;
}
}
} else {
$eventsbyuid{$uid} = $event;
my $curreventday = $event->{'DTSTART'}->clone;
$curreventday->truncate( to => 'day' );
$eventsbyuid{$uid}{$curreventday->epoch()} =1;
}
}
}
}
}
foreach $yearkey (sort keys %{$events} ) {
my $yearevents = $events->{$yearkey};
foreach $monkey (sort {$a <=> $b} keys %{$yearevents}){
my $monevents = $yearevents->{$monkey};
foreach $daykey (sort {$a <=> $b} keys %{$monevents} ) {
my $dayevents = $monevents->{$daykey};
foreach $uid (sort {
DateTime->compare($dayevents->{$a}->{'DTSTART'}, $dayevents->{$b}->{'DTSTART'})
} keys %{$dayevents}) {
my $event = $dayevents->{$uid};
if (exists($event->{'LEADTIME'})) {
$leadtime = "+".$event->{'LEADTIME'};
} else {
$leadtime = "+".$DEFAULT_LEAD_TIME;
}
my $start = $event->{'DTSTART'};
print "REM ".$start->month_abbr." ".$start->day." ".$start->year." $leadtime ";
if ($start->hour > 0) {
print " AT ";
print $start->strftime("%H:%M");
print " SCHED _sfun MSG %a %2 ";
} else {
print " MSG %a ";
}
print "%\"$event->{'SUMMARY'}";
print " at $event->{'LOCATION'}" if $event->{'LOCATION'};
print "\%\"%\n";
}
}
}
}
exit 0;
#:vim set ft=perl ts=4 sts=4 expandtab :

View File

@@ -109,18 +109,15 @@
(defconst remind-keywords
(sort
(list "ADDOMIT" "AFTER" "AT" "BANNER" "BEFORE"
"CAL" "CLEAR-OMIT-CONTEXT" "DEBUG" "DO" "DUMPVARS"
"DURATION" "ELSE" "ENDIF" "ERRMSG" "EXIT" "FIRST"
"FLUSH" "FOURTH" "FROM" "FSET" "IF" "IFTRIG" "IN"
"INCLUDE" "INCLUDECMD" "LAST" "LASTDAY"
"LASTWORKDAY" "MAYBE-UNCOMPUTABLE" "MSF"
"MSG" "OMIT" "OMITFUNC" "ONCE"
"POP-OMIT-CONTEXT" "PRESERVE" "PRIORITY" "PS" "PSFILE"
"PUSH-OMIT-CONTEXT" "REM" "RUN" "SATISFY" "SCANFROM"
"SCHED" "SECOND" "SET" "SKIP" "SPECIAL"
"TAG" "THIRD" "THROUGH" "UNSET" "UNTIL"
"WARN")
(list "ADDOMIT" "AFTER" "AT" "BAN" "BANNER" "BEFORE" "CAL" "CLEAR"
"CLEAR-OMIT-CONTEXT" "DEBUG" "DO" "DUMP" "DUMPVARS" "DURATION" "ELSE"
"ENDIF" "ERRMSG" "EXIT" "EXPR" "FIRST" "FLUSH" "FOURTH" "FROM" "FSET"
"FUNSET" "IF" "IFTRIG" "IN" "INC" "INCLUDE" "INCLUDECMD" "LAST"
"LASTDAY" "LASTWORKDAY" "MAYBE" "MAYBE-UNCOMPUTABLE" "MSF" "MSG"
"NOQUEUE" "OMIT" "OMITFUNC" "ONCE" "POP" "POP-OMIT-CONTEXT" "PRESERVE"
"PRIORITY" "PS" "PSFILE" "PUSH" "PUSH-OMIT-CONTEXT" "REM" "RUN"
"SATISFY" "SCAN" "SCANFROM" "SCHED" "SECOND" "SET" "SKIP" "SPECIAL"
"TAG" "THIRD" "THROUGH" "UNSET" "UNTIL" "WARN")
#'(lambda (a b) (> (length a) (length b)))))
@@ -131,50 +128,57 @@
(defconst remind-builtin-variables
(sort
(list "$Ago" "$Am" "$And" "$April" "$At" "$August" "$CalcUTC" "$CalMode" "$Daemon" "$DateSep"
"$DateTimeSep" "$December" "$DefaultColor" "$DefaultPrio"
"$DefaultTDelta" "$DeltaOffset" "$DontFork" "$DontQueue"
"$DontTrigAts" "$EndSent" "$EndSentIg" "$February" "$FirstIndent"
"$FoldYear" "$FormWidth" "$Friday" "$Fromnow" "$Hour" "$Hplu" "$HushMode" "$IgnoreOnce"
"$InfDelta" "$IntMax" "$IntMin" "$Is" "$January" "$July" "$June" "$LatDeg"
"$Latitude" "$LatMin" "$LatSec" "$Location" "$LongDeg" "$Longitude"
"$LongMin" "$LongSec" "$March" "$MaxSatIter" "$MaxStringLen" "$May"
"$MinsFromUTC" "$Minute" "$Monday" "$Mplu" "$NextMode" "$November" "$Now" "$NumQueued"
"$NumTrig" "$October" "$On" "$Pm" "$PrefixLineNo" "$PSCal" "$RunOff" "$Saturday"
"$September" "$SimpleCal" "$SortByDate" "$SortByPrio" "$SortByTime"
"$SubsIndent" "$Sunday" "$SysInclude" "$T" "$Td" "$Thursday" "$TimeSep" "$Tm"
"$Today" "$Tomorrow" "$Tuesday" "$Tw" "$Ty" "$U" "$Ud" "$Um" "$UntimedFirst" "$Uw" "$Uy"
"$Was" "$Wednesday")
(list "$AddBlankLines" "$Ago" "$Am" "$And" "$April" "$At" "$August"
"$CalcUTC" "$CalMode" "$Daemon" "$DateSep" "$DateTimeSep" "$December"
"$DefaultColor" "$DefaultPrio" "$DefaultTDelta" "$DeltaOverride"
"$DontFork" "$DontQueue" "$DontTrigAts" "$EndSent" "$EndSentIg"
"$ExpressionTimeLimit" "$February" "$FirstIndent" "$FoldYear"
"$FormWidth" "$Friday" "$Fromnow" "$Hour" "$Hplu" "$HushMode"
"$IgnoreOnce" "$InfDelta" "$IntMax" "$IntMin" "$Is" "$January" "$July"
"$June" "$LatDeg" "$Latitude" "$LatMin" "$LatSec" "$Location"
"$LongDeg" "$Longitude" "$LongMin" "$LongSec" "$March" "$MaxFullOmits"
"$MaxLateMinutes" "$MaxPartialOmits" "$MaxSatIter" "$MaxStringLen"
"$May" "$MinsFromUTC" "$Minute" "$Monday" "$Mplu" "$NextMode"
"$November" "$Now" "$NumFullOmits" "$NumPartialOmits" "$NumQueued"
"$NumTrig" "$October" "$On" "$OnceFile" "$ParseUntriggered" "$Pm"
"$PrefixLineNo" "$PSCal" "$RunOff" "$Saturday" "$September"
"$SimpleCal" "$SortByDate" "$SortByPrio" "$SortByTime" "$SubsIndent"
"$Sunday" "$SuppressImplicitWarnings" "$SuppressLRM" "$SysInclude" "$T" "$Td"
"$TerminalBackground" "$Thursday" "$TimeSep" "$Tm" "$Today"
"$Tomorrow" "$Tt" "$Tuesday" "$Tw" "$Ty" "$U" "$Ud" "$Um"
"$UntimedFirst" "$Use256Colors" "$UseBGVTColors" "$UseTrueColors"
"$UseVTColors" "$Uw" "$Uy" "$Was" "$Wednesday")
#'(lambda (a b) (> (length a) (length b)))))
(defconst remind-time-words
(sort
(list "Jan" "January" "Feb" "Mar" "Apr" "Jun" "Jul" "Aug" "Sept" "Sep" "Oct" "Nov" "Dec"
"February" "March" "April" "May" "June" "July" "August" "September" "October"
"November" "December" "Mon" "Monday" "Tue" "Tues" "Tuesday" "Wed" "Wednesday"
"Thu" "Thursday" "Thurs" "Fri" "Friday" "Saturday" "Sat" "Sun" "Sunday")
(list "Apr" "April" "Aug" "August" "Dec" "December" "Feb" "February"
"Jan" "January" "Jul" "July" "Jun" "June" "Mar" "March" "May"
"Nov" "November" "Oct" "October" "Sep" "September" "Fri"
"Friday" "Mon" "Monday" "Sat" "Saturday" "Sun" "Sunday" "Thu"
"Thursday" "Tue" "Tuesday" "Wed" "Wednesday")
#'(lambda (a b) (> (length a) (length b)))))
(defconst remind-builtin-functions
(sort
(list "abs" "access" "adawn" "adusk" "ampm" "args" "asc" "baseyr" "char"
"choose" "coerce" "current" "date" "datepart" "datetime" "dawn" "day"
"daysinmon" "defined" "dosubst" "dusk" "easterdate" "evaltrig"
"filedate" "filedatetime" "filedir" "filename" "getenv" "hebdate"
"hebday" "hebmon" "hebyear" "hour" "iif" "index" "isany" "isdst"
"isleap" "isomitted" "language" "lower" "max" "min" "minsfromutc"
(list "abs" "access" "adawn" "adusk" "ampm" "ansicolor" "args" "asc"
"baseyr" "char" "choose" "coerce" "columns" "current" "date"
"datepart" "datetime" "dawn" "day" "daysinmon" "defined" "dosubst"
"dusk" "easterdate" "evaltrig" "filedate" "filedatetime" "filedir"
"filename" "getenv" "hebdate" "hebday" "hebmon" "hebyear" "hour"
"htmlescape" "htmlstriptags" "iif" "index" "isany" "isdst" "isleap"
"isomitted" "language" "localtoutc" "lower" "max" "min" "minsfromutc"
"minute" "mon" "monnum" "moondate" "moondatetime" "moonphase"
"moontime" "ndawn" "ndusk" "nonomitted" "now" "ord" "ostype" "pad" "plural"
"psmoon" "psshade" "realcurrent" "realnow" "realtoday" "sgn" "shell"
"shellescape" "slide" "strlen" "substr" "sunrise" "sunset" "time"
"timepart" "today" "trig" "trigback" "trigdate" "trigdatetime"
"trigdelta" "trigduration" "trigeventduration" "trigeventstart"
"trigfrom" "trigger" "trigpriority" "trigrep" "trigscanfrom"
"trigtime" "trigtimedelta" "trigtimerep" "triguntil" "trigvalid"
"typeof" "tzconvert" "upper" "value" "version" "weekno" "wkday"
"wkdaynum" "year")
"moontime" "multitrig" "ndawn" "ndusk" "nonomitted" "now" "ord"
"orthodoxeaster" "ostype" "pad" "plural" "psmoon" "psshade"
"realcurrent" "realnow" "realtoday" "rows" "sgn" "shell" "shellescape"
"slide" "soleq" "stdout" "strlen" "substr" "sunrise" "sunset" "time"
"timepart" "timezone" "today" "trig" "trigback" "trigdate"
"trigdatetime" "trigdelta" "trigduration" "trigeventduration"
"trigeventstart" "trigfrom" "trigger" "trigpriority" "trigrep"
"trigscanfrom" "trigtags" "trigtime" "trigtimedelta" "trigtimerep"
"triguntil" "trigvalid" "typeof" "tzconvert" "upper" "utctolocal"
"value" "version" "weekno" "wkday" "wkdaynum" "year")
#'(lambda (a b) (> (length a) (length b)))))
;;; faces
@@ -290,7 +294,7 @@
(defconst remind-conf-font-lock-keywords-1
(list
'("^[\;\#]\\s-+.*$" . remind-comment-face)
'("^\s*[\;\#].*$" . remind-comment-face)
'(remind-keywords-matcher . remind-conf-keyword-face)
'("%[\"_]" . font-lock-warning-face)
'("\\(%[a-mops-w]\\)" . remind-conf-substitutes-face)

View File

@@ -1,61 +1,359 @@
CHANGES TO REMIND
* VERSION 5.0 Patch 7 - 2024-10-16
- NEW FEATURE: tkremind: Add option to create a desktop notification when
a queued reminder is triggered. For Tcl/Tk 9.0 or later, uses the native
"tk sysnotify" facility. For earlier versions of Tcl/Tk, executes the
"notify-send" program if possible.
- NEW FEATURE: remind: Add --print-config-cmd option which prints the
exact ./configure command used to build Remind. This will let you
configure future Remind releases exactly the same way an installed
version was configured.
- UPDATE: include/holidays/ca.rem: Add National Day for Truth and
Reconciliation to Canadian holiday list.
- MINOR IMPROVEMENTS: Update examples/ansitext and examples/astro
- MINOR IMPROVEMENT: remind: Use HashPJW to hash variable and function
names; make the hash table size a prime rather than a power of two.
This seems to improve hash performance ever so slightly in most cases.
- UPDATE: Update contrib/ical2rem to upstream version 0.7.1
- FIX: tkremind: Make tkremind work with Tcl/Tk 8.5 or higher, including
Tcl/Tk 9.0
- MINOR CHANGE: remind: Add hash table statistics to "-ds" debugging
output. This is probably of no use to anyone except the author of
Remind.
* VERSION 5.0 Patch 6 - 2024-09-16
- NEW FEATURE: remind: Include a file containing the dates of Chinese
New Year through 2050.
- NEW FEATURE: remind: Add $SuppressImplicitWarnings system variable.
Setting this to 1 suppresses the warnings "Unrecognized command;
interpreting as REM" and "Missing REM type; assuming MSG"
- NEW FEATURE: remind: Add --print-tokens command-line argument. This
simply prints all of Remind's built-in tokens, functions, and system
variables. It's designed to help people who are writing editor
add-ons for syntax highlighting.
- CHANGE: remind: allow '12:34' to be parsed as a TIME constant. This
matches DATEs and DATETIMEs which are enclosed in single-quotes.
(The quotes are optional for TIME constants, however.)
- IMPROVEMENT: Improve many error messages and warnings.
- UPDATE: contrib/ical2rem: Update to upstream version 0.7
- IMPROVEMENT: contrib/remind-conf-mode: Improve the Emacs
remind-conf-mode package. Add new keywords and make comment
highlighting correct.
- FIX: remind man page: Remove note saying REM can be omitted.
* VERSION 5.0 Patch 5 - 2024-09-02
- CHANGE: remind: When using the "-c" option and with the SHADE special
enabled, shade the entire calendar box including the line containing the
day number.
- IMPROVEMENT: remind: Better error messages when diagnosing certain
errors in expressions.
- IMPROVEMENT: include/holidays/jewish.rem: Remove unnecessary _h()
function definition.
- BUG FIX: remind: In a couple of spots when we parsed a character, we did
not check for an error return. This has been fixed.
- BUG FIX: remind: Fix edge-case bugs in "remind -c" output formatting.
- BUG FIX: make test: Fix a test that was broken for all of September 2024.
- BUG FIX: remind: Fix a couple of potential file-descriptor leaks.
- BUG FIX: contrib/ical2rem.pl: Replace "SCHED _sfun" with "+15" to
hard-code 15-minutes advance warning rather than using an undefined
scheduling function. If this is not what you want, you should edit
ical2rem.pl to suit your taste; it's not officially part of Remind and
is meant more as a starting point for you to customize than a finished
product.
- DOCUMENTATION FIX: Remove obsolete info from Remind man page.
* VERSION 5.0 Patch 4 - 2024-08-29
- IMPROVEMENT: remind: When checking if a SATISFY expression refers to the
trigger date, look recursively at any user-defined functions it calls.
This reduces spurious warnings.
- CHANGE: remind: Allow any type to be used as the test argument for IIF.
- IMPROVEMENT: remind man page: Clarify how various types are treated
in boolean context.
* VERSION 5.0 Patch 3 - 2024-08-28
- IMPROVEMENT: remind: Preserve newlines ("%_" sequences) in calendar
mode in most cases. See the remind man page for details.
- IMPROVEMENT: rem2pdf: rem2pdf can now produce PostScript and
Encapsulated PostScript output in addition to PDF and SVG.
- IMPROVEMENT: remind: Emit warnings if a subst_XXX function takes the
wrong number of arguments, or for custom sequences, if the function
is not defined.
- IMPROVEMENT: remind: Emit warnings if WARN/SCHED/OMITFUNC functions
do not reference their argument.
- IMPROVEMENT: remind: Allow strings to be used with logical
operators. The empty string "" is considered false and all other
strings are considered true.
- IMPROVEMENT: remind: Emit warnings for lines that are implicitly
treated as REM commands; add warnings for REM commands that are
implicitly treated as MSG-type reminders.
- IMPROVEMENT: remind: Add an optional fourth argument to the built-in
ampm() function that specifies not to suppress a leading zero in the
hour component.
- IMPROVEMENT: remind: If a SATISFY expression is not constant and
doesn't reference the trigger date somehow, issue a warning.
- IMPROVEMENT: remind: Add a warning if a user-defined function is
redefined. If you do have a use-case that requires you to redefine
a function, simply FUNSET it first before FSETting it for the second
time.
- DOCUMENTATION FIX: Clarify man pages and remove some information that
has become incorrect as Remind has evolved.
- BUG FIX: Fix typos in man pages
* VERSION 5.0 Patch 2 - 2024-07-26
- IMPROVEMENT: Remind: Revamp how ONCE works. You can now set a
special variable $OnceFile to be the path to a timestamp file. The
ONCE directive uses this timestamp file to track when it was last
run rather than the access date of the main reminder script. This
is more reliable because it doesn't rely on the atime of a file
(which might not be maintained accurately) and is not affected if
you edit your reminder script.
- CHANGE: Taking input from stdin no longer implies the "-o" option; ONCE can
work if you set $OnceFile
- CHANGE: Any of the -c, -n, -p and -s options implicitly enable the
-o option. As before, specifying a repeat factor *N or a date that
is not today on the command-line also implies -o.
- MINOR NEW FEATURE: Rem2PDF: Add the "--svg" command-line option to produce
SVG output rather than PDF.
- MINOR IMPROVEMENT: Remind: Improve the storage efficiency of short
string constants in compiled expression trees.
- MINOR IMPROVEMENT: Remind: Remove some obsolete macro definitions
* 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"
- 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
- IMPROVEMENT: tkremind: Make errors in your reminders file stand out more
prominently.
* IMPROVEMENT: tkremind: If you click on an error in the "Errors..." popup,
- 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
- 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
- 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.
- IMPROVEMENT: Clean up the demo code in www/ and add PDF output.
* BUG FIX: tkremind: Correctly handle filenames containing spaces and other
- 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
- BUG FIX: tkremind: Raise dialog boxes after errors so that they
remain visible.
* CLEANUP: tkremind: Remove some dead code.
- 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
- 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: C code: Fix a number of cppcheck static-analysis warnings.
* IMPROVEMENT: remind: Update the "-zj" protocol to include a queue-id for
- 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
- 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
- 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
- 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
- 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
- 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
@@ -1028,7 +1326,7 @@ CHANGES TO REMIND
- MINOR IMPROVEMENT: Add the "ampm()" built-in function.
* Version 3.3 Patch 0 - 2020-01-31
* VERSION 3.3 Patch 0 - 2020-01-31
- FIX: rem2ps: Add a %%PageBoundingBox: document structuring convention
comment.
@@ -1063,7 +1361,7 @@ CHANGES TO REMIND
- CHANGE: SPECIALs are now case-insensitive. Before, only SPECIAL COLOR
would work. Now you can use Special Color, special color, etc.
* Version 3.2 Patch 0 - 2020-01-03
* VERSION 3.2 Patch 0 - 2020-01-03
- IMPROVEMENT: Add support for events spanning multiple days (with AT
and DURATION). Add trigeventstart() and trigeventduration()
@@ -1105,7 +1403,7 @@ CHANGES TO REMIND
- BUG FIX: TkRemind: Fix startup failure of TkRemind if options are at
default. :(
* Version 3.1 Patch 17 - 2019-11-15
* VERSION 3.1 Patch 17 - 2019-11-15
- IMPROVEMENT: Add "Extra Remind Options" setting to TkRemind.
@@ -1122,7 +1420,7 @@ CHANGES TO REMIND
- BUG FIX: Fix various documentation errors and update man page.
* Version 3.1 Patch 16 - 2018-11-09
* VERSION 3.1 Patch 16 - 2018-11-09
- IMPROVEMENT: Add patch from Stephen Morgan to calculate astronomical and
nautical twilight in addition to civil twilight.
@@ -1152,7 +1450,7 @@ CHANGES TO REMIND
- BUG FIX: In "remind -z0" mode, remind wakes up exactly on the minute instead
of sleeping for 60 seconds each time, which could cause it to fall behind.
* Version 3.1 Patch 15 - 2015-07-27
* VERSION 3.1 Patch 15 - 2015-07-27
- BUG FIX: Fix a buffer overflow found by Alexander Keller
@@ -1162,7 +1460,7 @@ CHANGES TO REMIND
- BUG FIX: Make parser reject repeated delta or *repeat values.
* Version 3.1 Patch 14 - 2015-04-24
* VERSION 3.1 Patch 14 - 2015-04-24
- NEW FEATURE: Putting the line __EOF__ in a .rem file causes Remind
to treat it as end-of-file.
@@ -1179,7 +1477,7 @@ CHANGES TO REMIND
- BUG FIX: Typo in Spanish translation was fixed.
* Version 3.1 Patch 13 - 2013-03-22
* VERSION 3.1 Patch 13 - 2013-03-22
- BUG FIX: Sunrise/Sunset calculations greatly improved thanks to John
McGowan. Accuracy should now be within a couple of minutes in most
@@ -1196,7 +1494,7 @@ CHANGES TO REMIND
- BUG FIX: Spurious test harness failure was fixed.
* Version 3.1 Patch 12 - 2012-01-23
* VERSION 3.1 Patch 12 - 2012-01-23
- NEW FEATURE: Many substitution sequences "%x" have an alternate mode
denoted by "%*x". This alternate mode leaves out prepositions. For
@@ -1208,7 +1506,7 @@ CHANGES TO REMIND
so the results may be off by a minute or two compared to previous versions
of Remind.
* Version 3.1 Patch 11 - 2011-12-16
* VERSION 3.1 Patch 11 - 2011-12-16
- BUG FIX: For some inexplicable reason, dawn was considered to happen when
the sun was 14 degrees below the horizon instead of the standard 6
@@ -1222,7 +1520,7 @@ CHANGES TO REMIND
- BUG FIX: Apply minor Debian cleanups reported by Kurt B. Kaiser.
* Version 3.1 Patch 10 - 2010-11-01
* VERSION 3.1 Patch 10 - 2010-11-01
- NOTE: This is the 20th anniversary of Remind's first public release.
@@ -1246,7 +1544,7 @@ CHANGES TO REMIND
- BUG FIX: Don't declare variables in the middle of statements (old C
compilers choke.)
* Version 3.1 Patch 9 - 2010-06-20
* VERSION 3.1 Patch 9 - 2010-06-20
- MAJOR ENHANCEMENT: New "purge mode" to delete expired reminders. See
the PURGE MODE section of the remind man page.
@@ -1262,7 +1560,7 @@ CHANGES TO REMIND
- BUG FIX: Yom HaShoah is moved to Thursday if it would normally fall on
a Friday. Thanks to Jonathan Kamens for pointing this out.
* Version 3.1 Patch 8 - 2010-03-09
* VERSION 3.1 Patch 8 - 2010-03-09
- ENHANCEMENT: Include some useful scripts in contrib/
@@ -1282,7 +1580,7 @@ CHANGES TO REMIND
- BUG FIX: Fix bug in SCHED calculations if Remind is started in the middle
of a SCHED interval.
* Version 3.1 Patch 7 - 2009-05-31
* VERSION 3.1 Patch 7 - 2009-05-31
- ENHANCEMENT: Wherever you could write "day Mon year", the parser now
accepts "YYYY-MM-DD". This applies on the command-line and to the
@@ -1291,7 +1589,7 @@ CHANGES TO REMIND
- ENHANCEMENT: New slide() built-in function eases some complicated reminders.
* Version 3.1 Patch 6 - 2008-11-16
* VERSION 3.1 Patch 6 - 2008-11-16
- MAJOR ENHANCEMENT: A new OMITFUNC clause gives you additional
control and flexibility over "omitted days" calculations. This is
@@ -1319,7 +1617,7 @@ CHANGES TO REMIND
weekday would fail if it needed to cross a year boundary. This has
been fixed.
* Version 3.1 Patch 5 - 2008-04-15
* VERSION 3.1 Patch 5 - 2008-04-15
- MAJOR ENHANCEMENT: If you supply a directory name on the command line
or for an INCLUDE command, then Remind reads all *.rem file in that
@@ -1349,7 +1647,7 @@ CHANGES TO REMIND
- BUG FIX: Parse error in calendar mode was fixed.
* Version 3.1 Patch 4 - 2008-02-03
* VERSION 3.1 Patch 4 - 2008-02-03
- ENHANCEMENT: tkremind respects the "-b1" option and operates in 24-hour
clock mode if the option is supplied.
@@ -1371,7 +1669,7 @@ CHANGES TO REMIND
- BUG FIX: The "-ivar=value" command-line option failed if Remind re-execed
itself because we overwrote argv[]. This has been fixed.
* Version 3.1 Patch 3 - 2007-10-15
* VERSION 3.1 Patch 3 - 2007-10-15
+ MINOR ENHANCEMENTS
@@ -1390,7 +1688,7 @@ CHANGES TO REMIND
is not evaluated. This helps avoid spurious error messages in some
reminders.
* Version 3.1 Patch 2 - 2007-09-12
* VERSION 3.1 Patch 2 - 2007-09-12
+ MINOR ENHANCEMENTS
@@ -1444,7 +1742,7 @@ CHANGES TO REMIND
- Using the psshade() or psmoon() functions emits a warning on stderr. You
should use SPECIAL SHADE or SPECIAL MOON instead.
* Version 3.1 Patch 1 - 2007-08-23
* VERSION 3.1 Patch 1 - 2007-08-23
+ MAJOR ENHANCEMENTS
@@ -1474,7 +1772,7 @@ CHANGES TO REMIND
- Various man-page fixes.
* Version 3.1 Patch 0 - 2007-07-14
* VERSION 3.1 Patch 0 - 2007-07-14
+ MAJOR ENHANCEMENTS
@@ -1537,7 +1835,7 @@ CHANGES TO REMIND
- rem2ps would produce invalid PostScript in some rare cases
(eg, for February 2007). This has been fixed.
* Version 3.0 Patch 24 - 2005-11-19
* VERSION 3.0 Patch 24 - 2005-11-19
+ MINOR ENHANCEMENTS
@@ -1560,7 +1858,7 @@ CHANGES TO REMIND
- Fixed a bug in the tokenizer that could make Remind segfault. Fix courtesy
of Stan Tobias.
* Version 3.0 Patch 23 - 2005-04-14
* VERSION 3.0 Patch 23 - 2005-04-14
+ MINOR ENHANCEMENTS
@@ -1584,7 +1882,7 @@ CHANGES TO REMIND
- Fixed parser error for unterminated date constant: '2005/01/01
* Version 3.0 Patch 22 - 2000-06-16
* VERSION 3.0 Patch 22 - 2000-06-16
+ MINOR ENHANCEMENTS
@@ -1606,7 +1904,7 @@ CHANGES TO REMIND
- Fixed serious bug in which background queued reminders were ignored and
Remind simply exited. Doh! Sorry about that.
* Version 3.0 Patch 21 - 2000-03-15
* VERSION 3.0 Patch 21 - 2000-03-15
+ MINOR ENHANCEMENTS
@@ -1637,7 +1935,7 @@ CHANGES TO REMIND
- Fixed compilation problem on FreeBSD, IRIX, Tru64 and other UNIXes.
* Version 3.0 Patch 20 - 1999-04-12
* VERSION 3.0 Patch 20 - 1999-04-12
+ LICENSE CHANGE
@@ -1659,7 +1957,7 @@ CHANGES TO REMIND
- Fixed a typo in danish.h, courtesy of Niels Kristian Bech Jensen.
* Version 3.0 Patch 19 - 1998-05-09
* VERSION 3.0 Patch 19 - 1998-05-09
+ MAJOR ENHANCEMENTS
@@ -1701,7 +1999,7 @@ CHANGES TO REMIND
- Lots more silly little bugs squashed -- too many to go into in
detail.
* Version 3.0 Patch 18 - 1998-02-15
* VERSION 3.0 Patch 18 - 1998-02-15
+ MAJOR ENHANCEMENTS
@@ -1765,7 +2063,7 @@ CHANGES TO REMIND
- Getting rid of fixed-sized buffers meant lots of changes to code.
No doubt, I missed a few regression tests.
* Version 3.0 Patch 17 - 1997-09-07
* VERSION 3.0 Patch 17 - 1997-09-07
+ MINOR ENHANCEMENTS
@@ -1806,7 +2104,7 @@ CHANGES TO REMIND
library. All three of these fixes are courtesy of Christopher
J. Madsen <madsen@iglobal.net>. Thanks, Christopher.
* Version 3.0 Patch 16 - 1997-02-11
* VERSION 3.0 Patch 16 - 1997-02-11
+ MINOR ENHANCEMENTS
@@ -1834,7 +2132,7 @@ CHANGES TO REMIND
- Fixed a problem under Solaris 2.5 whereby rem2ps was skipping some
latin1 characters which it interpreted as white space.
* Version 3.0 Patch 15 - 1996-10-27
* VERSION 3.0 Patch 15 - 1996-10-27
+ IMPORTANT NOTES
@@ -1864,7 +2162,7 @@ CHANGES TO REMIND
- Fixed bug in TkRemind which caused a crash if the "-m" option was used
for a month beginning on Sunday. Doh!!!
* Version 3.0 Patch 14 - 1996-05-25
* VERSION 3.0 Patch 14 - 1996-05-25
+ CHANGE IN COPYING POLICY
@@ -1923,7 +2221,7 @@ CHANGES TO REMIND
_not_ support MS Windows, and in fact do not allow Remind to run
under Windows (see COPYRIGHT).
* Version 3.0 Patch 13 - 1994-05-06
* VERSION 3.0 Patch 13 - 1994-05-06
+ MINOR ENHANCEMENTS
@@ -1958,7 +2256,7 @@ CHANGES TO REMIND
- Updated the copyright notices everywhere.
* Version 3.0 Patch 12 - 1994-02-01
* VERSION 3.0 Patch 12 - 1994-02-01
+ MINOR ENHANCEMENTS
@@ -1977,7 +2275,7 @@ CHANGES TO REMIND
- Fixed a problem with the '-k' option which resulted in a newline being
placed after the message text. This was giving sh(1) heartburn...
* Version 3.0 Patch 11 - 1993-11-26
* VERSION 3.0 Patch 11 - 1993-11-26
+ MINOR ENHANCEMENTS
@@ -2009,7 +2307,7 @@ CHANGES TO REMIND
- Fixed typos in french.h
* Version 3.0 Patch 10
* VERSION 3.0 Patch 10
+ MAJOR ENHANCEMENT
@@ -2057,7 +2355,7 @@ CHANGES TO REMIND
- Fixed the Finnish language support which was missing a few newlines.
* Version 3.0 Patch 9 - 1993-10-04
* VERSION 3.0 Patch 9 - 1993-10-04
+ NOTES
@@ -2114,7 +2412,7 @@ CHANGES TO REMIND
so that newlines in the body start new paragraphs, rather than being
swallowed as white-space.
* Version 3.0 Patch 8 - 1993-09-08
* VERSION 3.0 Patch 8 - 1993-09-08
+ MAJOR ENHANCEMENTS
@@ -2166,7 +2464,7 @@ CHANGES TO REMIND
range [-128, 255] (but not 0) so that char(asc(s)) works even
on machines with signed char types.
* Version 3.0 Patch 7 - 1993-07-22
* VERSION 3.0 Patch 7 - 1993-07-22
+ MAJOR ENHANCEMENTS
@@ -2209,7 +2507,7 @@ CHANGES TO REMIND
- Changed kall so that "kall sh" doesn't commit suicide - patch courtesy
of Michael Salmon.
* Version 3.0 Patch 6 - 1993-05-05
* VERSION 3.0 Patch 6 - 1993-05-05
+ MINOR ENHANCEMENTS
@@ -2232,7 +2530,7 @@ CHANGES TO REMIND
- Fixed a bug in the -u option which sometimes caused a core dump
(embarrassed grin!) The fix is due to Tina Hoeltig. Thanks, Tina!
* Version 3.0 Patch 5 - 1993-04-27
* VERSION 3.0 Patch 5 - 1993-04-27
+ MAJOR ENHANCEMENTS:
@@ -2267,7 +2565,7 @@ CHANGES TO REMIND
- Fixed a bug in the man page - thanks to Ed Oskiewicz.
* Version 3.0 Patch 4 - 1993-03-08
* VERSION 3.0 Patch 4 - 1993-03-08
- Added the -g option - this sorts reminders by date/time before
issuing them. (You can see I'm running out of letters to
@@ -2326,13 +2624,13 @@ CHANGES TO REMIND
- Put my new mailing address in the README files.
* Version 3.0 Patch 3 - 1993-02-21
* VERSION 3.0 Patch 3 - 1993-02-21
- Corrected bugs in Remind and Rem2PS. No new features added. You
should NOT use patch level 2 - either stick to 3.0.1 or upgrade to
3.0.3.
* Version 3.0 Patch 2 - 1993-02-04
* VERSION 3.0 Patch 2 - 1993-02-04
- Added the -u option to Remind so that root can run it as any user.
This simplifies the remind-all scripts, and makes them more efficient.
@@ -2372,7 +2670,7 @@ CHANGES TO REMIND
- Changed Remind so that supplying the -a option causes timed reminders
not to be placed into the calendar in calendar mode.
* Version 3.0 Patch 1 - 1992-12-18
* VERSION 3.0 Patch 1 - 1992-12-18
- Wrote the Rem2ps program to produce PostScript calendars
@@ -2412,7 +2710,7 @@ CHANGES TO REMIND
- Re-formatted the WHATSNEW.30 file.
* Version 3.0 - 1992-11-09
* VERSION 3.0 - 1992-11-09
- Total rewrite from previous versions
@@ -2433,23 +2731,23 @@ CHANGES TO REMIND
- Fixed a lurking bug in trigger date calculation which, amazingly, had not
been caught in the couple of years that Remind has been out!
* Version 2.3 Patch 5 - 1992-04-11
* VERSION 2.3 Patch 5 - 1992-04-11
- Added the "c+n" option for printing a calendar by
weeks instead of months, courtesy Dennis Cottel (dennis@peanuts.nosc.mil).
* Version 2.3 Patch 4 - 1991-11-06
* VERSION 2.3 Patch 4 - 1991-11-06
- Made the init.c file nicer. Made the Makefile
prettier. Added "make test", "make tar" and "make shar" Makefile targets.
* Version 2.3 Patch 3 - 1991-09-11
* VERSION 2.3 Patch 3 - 1991-09-11
- Added a command-line option for Remind to process
queued reminders in the foreground. This makes automatic termination
of Remind processes from within X-Windows and Sunview easier.
* Version 2.3 Patch 2 - 1991-07-19
* VERSION 2.3 Patch 2 - 1991-07-19
- Fixed up a problem with timed reminders which resulted
in cursor not starting from left side of screen on some systems.
@@ -2466,7 +2764,7 @@ CHANGES TO REMIND
- Made the Makefile more portable
* Version 2.3 Patch 1 - 1991-03-08
* VERSION 2.3 Patch 1 - 1991-03-08
- Added the "-t" command-line option to get Remind
to trigger all non-expired reminders.
@@ -2480,7 +2778,7 @@ CHANGES TO REMIND
- Added manual pages for "kall" and "rem".
* Version 2.3 - 1991-02-20
* VERSION 2.3 - 1991-02-20
- Added the UNTIL keyword for forcing reminders to expire.
@@ -2502,32 +2800,32 @@ CHANGES TO REMIND
- Modified the calendar and SimpleCalendar formats so that the % escape
substitutions ARE performed.
* Version 2.2 - Patch 5 - 1990-12-03
* VERSION 2.2 - Patch 5 - 1990-12-03
- Added the BEFORE, AFTER and SKIP tokens to make the
handling of holidays more sensible. Also corrected a few more bugs.
* Version 2.2 - Patch 3 - 1990-11-28
* VERSION 2.2 - Patch 3 - 1990-11-28
- Added the MSG or RUN tokens in an OMIT command; also
allowed RUN-type reminders to be explicitly included in the calendar by
using the %" escape sequence.
* Version 2.2 - 1990-11-16
* VERSION 2.2 - 1990-11-16
- Added the AT keyword, the timed reminders daemon, and the
calendar facility.
* Version 2.1 - 1990-11-06
* VERSION 2.1 - 1990-11-06
- Added the "repeat" token for repeating reminders with a period
other than 7 days. Also fixed some bugs from version 2.0
* Version 2.0 - 1990-11-01
* VERSION 2.0 - 1990-11-01
- first public release. Included advanced date specifications,
character substitution, and the RUN keyword.
* Version 1.0
* VERSION 1.0
- never publicly released.

View File

@@ -26,7 +26,10 @@ MSG This is [ansicolor(0,255,0)]green.[ansicolor("")]
MSG This is [ansicolor(0,0,255)]blue.[ansicolor("")]
MSG This is [ansicolor(255,255,0)]yellow.[ansicolor("")]
MSG This is [ansicolor(255,0,255)]magenta.[ansicolor("")]
MSG This is [ansicolor(0,255,255)]cyan.[ansicolor("")]%_
MSG This is [ansicolor(0,255,255)]cyan.[ansicolor("")]
MSG This is [ansi_bold][ansicolor(255,255,255)][ansicolor(0,0,0,1)]white on black[ansicolor("")][ansi_normal]
MSG This is [ansi_bold][ansicolor(0,0,0)][ansicolor(255,255,255,1)]black on white[ansicolor("")][ansi_normal]
MSG %_
# You can combine attributes
MSG This is [ansicolor(0,255,0)][ansicolor(0,0,96,1)][ansi_italic][ansi_bold]Green-Bold-Italic-on-Blue[ansi_normal][ansicolor("")]

View File

@@ -5,9 +5,6 @@
# Best used in a UTF-8 environment.
# SPDX-License-Identifier: GPL-2.0-only
# Set this variable to 1 if your terminal has a dark background or 0 if
# it: light.
# Set your latitude and longitude correctly for Sunrise/Sunset/Equinox/Solstice
#
# The values below are for Ottawa, Ontario, Canada
@@ -20,7 +17,8 @@ BANNER %
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)].
MSG Not including today, the year [year($T)] has [date(year($T)+1, 1, 1)-$T-1] more [plural(date(year($T)+1, 1, 1)-$T-1, "day")] left.%_
IF $TerminalBackground == 0
SPECIAL COLOR 255 255 0 Sunrise: 🌅 [sunrise()] today and [sunrise($T+1)] tomorrow

View File

@@ -6,6 +6,11 @@
# Cut and paste as desired! Also, near the end, there are a bunch of #
# holiday definitions for the U.S. #
# #
# *** NOTE *** #
# #
# This file is simply a grab-bag of examples. It is NOT meant to be #
# included as-is in a live reminder file. #
# #
# Some examples provided by George M. Sipe <gsipe@pyratl.ga.pyramid.com> #
# #
# U.S. holidays provided by Dave Rickel <drickel@sjc.mentorg.com> #
@@ -27,7 +32,7 @@ RUN OFF
# Ensure required version of remind is used... #
################################################
IF version() < "03.04.02"
ERRMSG This file requires at least version 03.01.10 of Remind.%
ERRMSG This file requires at least version 03.04.02 of Remind.%
ERRMSG This version is version [version()].
EXIT
ENDIF
@@ -305,51 +310,51 @@ FSET _PastMon(x, y) IIF(WKDAYNUM(_h2(x,y))!=1, _h2(x,y), _h2(x,y)+1)
SET InIsrael VALUE("InIsrael", 0)
SET Reform VALUE("Reform", 0)
[_h(1, "Tishrey")] ++4 MSG %"Rosh Hashana 1%" is %b.
REM [_h(1, "Tishrey")] ++4 MSG %"Rosh Hashana 1%" is %b.
# No RH-2 or Tzom Gedalia in Reform
IF !Reform
[_h(2, "Tishrey")] ++4 MSG %"Rosh Hashana 2%" is %b.
[_PastSat(3, "Tishrey")] ++4 MSG %"Tzom Gedalia%" is %b.
REM [_h(2, "Tishrey")] ++4 MSG %"Rosh Hashana 2%" is %b.
REM [_PastSat(3, "Tishrey")] ++4 MSG %"Tzom Gedalia%" is %b.
ENDIF
[_h(10, "Tishrey")] ++4 MSG %"Yom Kippur%" is %b.
[_h(15, "Tishrey")] ++4 MSG %"Sukkot 1%" is %b.
REM [_h(10, "Tishrey")] ++4 MSG %"Yom Kippur%" is %b.
REM [_h(15, "Tishrey")] ++4 MSG %"Sukkot 1%" is %b.
IF !InIsrael
[_h(16, "Tishrey")] MSG %"Sukkot 2%"
REM [_h(16, "Tishrey")] MSG %"Sukkot 2%"
ENDIF
[_h(21, "Tishrey")] ++4 MSG %"Hoshana Rabba%" is %b.
[_h(22, "Tishrey")] ++4 MSG %"Shemini Atzeret%" is %b.
REM [_h(21, "Tishrey")] ++4 MSG %"Hoshana Rabba%" is %b.
REM [_h(22, "Tishrey")] ++4 MSG %"Shemini Atzeret%" is %b.
IF InIsrael
[_h(22, "Tishrey")] ++4 MSG %"Simchat Torah%" is %b.
REM [_h(22, "Tishrey")] ++4 MSG %"Simchat Torah%" is %b.
ELSE
[_h(23, "Tishrey")] ++4 MSG %"Simchat Torah%" is %b.
REM [_h(23, "Tishrey")] ++4 MSG %"Simchat Torah%" is %b.
ENDIF
# Because Kislev can change length, we must be more careful about Chanukah
FSET _chan(x) HEBDATE(24, "Kislev", $U-9)+x
[_chan(1)] ++4 MSG %"Chanukah 1%" is %b.
[_chan(2)] MSG %"Chanukah 2%"
[_chan(3)] MSG %"Chanukah 3%"
[_chan(4)] MSG %"Chanukah 4%"
[_chan(5)] MSG %"Chanukah 5%"
[_chan(6)] MSG %"Chanukah 6%"
[_chan(7)] MSG %"Chanukah 7%"
[_chan(8)] MSG %"Chanukah 8%"
REM [_chan(1)] ++4 MSG %"Chanukah 1%" is %b.
REM [_chan(2)] MSG %"Chanukah 2%"
REM [_chan(3)] MSG %"Chanukah 3%"
REM [_chan(4)] MSG %"Chanukah 4%"
REM [_chan(5)] MSG %"Chanukah 5%"
REM [_chan(6)] MSG %"Chanukah 6%"
REM [_chan(7)] MSG %"Chanukah 7%"
REM [_chan(8)] MSG %"Chanukah 8%"
# Not sure about Reform's position on the next one.
IF !Reform
# 10 Tevet will never be a Saturday, so whether or not to
# move it is moot. (Thanks to Art Werschulz.)
[_h(10, "Tevet")] MSG %"Tzom Tevet%" is %b.
REM [_h(10, "Tevet")] MSG %"Tzom Tevet%" is %b.
ENDIF
[_h(15, "Shvat")] ++4 MSG %"Tu B'Shvat%" is %b.
[_h(14, "Adar A")] ++4 MSG %"Purim Katan%" is %b.
[_h(15, "Adar A")] ++4 MSG %"Shushan Purim Katan%" is %b.
REM [_h(15, "Shvat")] ++4 MSG %"Tu B'Shvat%" is %b.
REM [_h(14, "Adar A")] ++4 MSG %"Purim Katan%" is %b.
REM [_h(15, "Adar A")] ++4 MSG %"Shushan Purim Katan%" is %b.
# If Purim is on Sunday, then Fast of Esther is 11 Adar.
IF WKDAYNUM(_h2(13, "Adar")) != 6
@@ -357,18 +362,18 @@ IF WKDAYNUM(_h2(13, "Adar")) != 6
ELSE
REM [_h2(11, "Adar")] ++4 MSG %"Fast of Esther%" is %b.
ENDIF
[_h(14, "Adar")] ++4 MSG %"Purim%" is %b.
[_h(15, "Adar")] ++4 MSG %"Shushan Purim%" is %b.
[_h(15, "Nisan")] ++4 MSG %"Pesach%" is %b.
REM [_h(14, "Adar")] ++4 MSG %"Purim%" is %b.
REM [_h(15, "Adar")] ++4 MSG %"Shushan Purim%" is %b.
REM [_h(15, "Nisan")] ++4 MSG %"Pesach%" is %b.
IF !InIsrael
[_h(16, "Nisan")] MSG %"Pesach 2%"
REM [_h(16, "Nisan")] MSG %"Pesach 2%"
ENDIF
[_h(21, "Nisan")] MSG %"Pesach 7%"
REM [_h(21, "Nisan")] MSG %"Pesach 7%"
IF !InIsrael && !Reform
[_h(22, "Nisan")] MSG %"Pesach 8%"
REM [_h(22, "Nisan")] MSG %"Pesach 8%"
ENDIF
REM [_PastSun(27, "Nisan")] SATISFY 1
@@ -384,36 +389,36 @@ ENDIF
# Thursday. If 4 Iyar is a Sunday, then Yom Hazikaron
# moves to 5 Iyar and Yom Ha'atzmaut to 6 Iyar.
IF WKDAYNUM(_h2(4, "Iyar")) == 4 || WKDAYNUM(_h2(4, "Iyar")) == 5
[_h(2, "Iyar")] ++4 MSG %"Yom Hazikaron%" is %b.
[_h(3, "Iyar")] ++4 MSG %"Yom Ha'atzmaut%" is %b.
REM [_h(2, "Iyar")] ++4 MSG %"Yom Hazikaron%" is %b.
REM [_h(3, "Iyar")] ++4 MSG %"Yom Ha'atzmaut%" is %b.
ELSE
IF WKDAYNUM(_h2(4, "Iyar")) == 0
[_h(5, "Iyar")] ++4 MSG %"Yom Hazikaron%" is %b.
[_h(6, "Iyar")] ++4 MSG %"Yom Ha'atzmaut%" is %b.
REM [_h(5, "Iyar")] ++4 MSG %"Yom Hazikaron%" is %b.
REM [_h(6, "Iyar")] ++4 MSG %"Yom Ha'atzmaut%" is %b.
ELSE
[_h(4, "Iyar")] ++4 MSG %"Yom Hazikaron%" is %b.
[_h(5, "Iyar")] ++4 MSG %"Yom Ha'atzmaut%" is %b.
REM [_h(4, "Iyar")] ++4 MSG %"Yom Hazikaron%" is %b.
REM [_h(5, "Iyar")] ++4 MSG %"Yom Ha'atzmaut%" is %b.
ENDIF
ENDIF
# Not sure about Reform's position on Lag B'Omer
IF !Reform
[_h(18, "Iyar")] ++4 MSG %"Lag B'Omer%" is %b.
REM [_h(18, "Iyar")] ++4 MSG %"Lag B'Omer%" is %b.
ENDIF
[_h(28, "Iyar")] ++4 MSG %"Yom Yerushalayim%" is %b.
[_h(6, "Sivan")] ++4 MSG %"Shavuot%" is %b.
REM [_h(28, "Iyar")] ++4 MSG %"Yom Yerushalayim%" is %b.
REM [_h(6, "Sivan")] ++4 MSG %"Shavuot%" is %b.
IF !InIsrael && !Reform
[_h(7, "Sivan")] MSG %"Shavuot 2%"
REM [_h(7, "Sivan")] MSG %"Shavuot 2%"
ENDIF
# Fairly sure Reform Jews don't observe the next two
IF !Reform
# Tzom Tamuz and Tish'a B'Av are moved to Sunday if they normally
# fall on a Saturday
[_PastSat(17, "Tamuz")] ++4 MSG %"Tzom Tammuz%" is %b.
[_PastSat(9, "Av")] ++4 MSG %"Tish'a B'Av%" is %b.
REM [_PastSat(17, "Tamuz")] ++4 MSG %"Tzom Tammuz%" is %b.
REM [_PastSat(9, "Av")] ++4 MSG %"Tish'a B'Av%" is %b.
ENDIF
# Counting the omer - do the whole spiel, i.e:

View File

@@ -1,30 +1,14 @@
# Canadian holidays
# Canadian Federal Holidays
# SPDX-License-Identifier: GPL-2.0-only
# You should probably NOT include this file directly! Instead, for
# all of the statutory holidays of the province you live in, use:
# INCLUDE [$SysInclude]/ca/XY.rem where XY is the two-letter
# abbreviation for yoru province. For example, if you live in
# Ontario, use: INCLUDE [$SysInclude]/ca/on.rem
OMIT 1 Jan MSG New Year's Day
# This varies by province
REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG Family Day
# This varies by province
OMIT [easterdate($Uy) - 2] MSG Good Friday
# This varies by province
OMIT [easterdate($Uy) + 1] MSG Easter Monday
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
OMIT 1 July MSG Canada Day
# This varies by province
REM First Monday in Aug SCANFROM -7 ADDOMIT MSG Civic Holiday
REM First Monday in Sep SCANFROM -7 ADDOMIT MSG Labour Day
REM Second Monday in Oct SCANFROM -7 ADDOMIT MSG Thanksgiving Day
REM 11 November MSG Remembrance Day
REM 30 Sep MSG National Day for Truth and Reconciliation
OMIT 25 Dec MSG Christmas
OMIT 26 Dec MSG Boxing Day

View File

@@ -0,0 +1,10 @@
# Alberta Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG Family Day
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
REM First Monday in Aug SCANFROM -7 ADDOMIT MSG Civic Holiday
REM Second Monday in Oct SCANFROM -7 ADDOMIT MSG Thanksgiving Day
OMIT 11 November MSG Remembrance Day

View File

@@ -0,0 +1,10 @@
# British Columbia Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG Family Day
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
REM First Monday in Aug SCANFROM -7 ADDOMIT MSG Civic Holiday
REM Second Monday in Oct SCANFROM -7 ADDOMIT MSG Thanksgiving Day
OMIT 11 November MSG Remembrance Day

View File

@@ -0,0 +1,9 @@
# Manitoba Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG Louis Riel Day
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
REM Second Monday in Oct SCANFROM -7 ADDOMIT MSG Thanksgiving Day
OMIT 11 November MSG Remembrance Day

View File

@@ -0,0 +1,8 @@
# New Brunswick Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG Family Day
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM First Monday in Aug SCANFROM -7 ADDOMIT MSG Civic Holiday
OMIT 11 November MSG Remembrance Day

View File

@@ -0,0 +1,9 @@
# Newfoundland and Labrador Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
OMIT 17 March MSG St. Patrick's Day
OMIT [easterdate($Uy) - 2] MSG Good Friday
OMIT 23 April MSG St. George's Day
OMIT 24 June MSG Discovery Day
REM 11 November MSG Remembrance Day

View File

@@ -0,0 +1,8 @@
# Nova Scotia Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG Heritage Day
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM 11 November MSG Remembrance Day

View File

@@ -0,0 +1,9 @@
# Northwest Territories Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
OMIT 21 June MSG National Aboriginal Day
REM Second Monday in Oct SCANFROM -7 ADDOMIT MSG Thanksgiving Day
OMIT 11 November MSG Remembrance Day

View File

@@ -0,0 +1,9 @@
# Nunavut Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
OMIT 9 July MSG Nunavut Day
REM First Monday in Aug SCANFROM -7 ADDOMIT MSG Civic Holiday
OMIT 11 November MSG Remembrance Day

View File

@@ -0,0 +1,10 @@
# Ontario Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG Family Day
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
REM First Monday in Aug SCANFROM -7 ADDOMIT MSG Civic Holiday
REM 11 November MSG Remembrance Day
OMIT 26 Dec MSG Boxing Day

View File

@@ -0,0 +1,8 @@
# Prince Edward Island Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM First Monday in Aug SCANFROM -7 ADDOMIT MSG Islander Day
OMIT 11 November MSG Remembrance Day

View File

@@ -0,0 +1,9 @@
# Quebec Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
OMIT [easterdate($Uy) + 1] MSG Easter Monday
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
OMIT 24 June MSG Fête Nationale
REM Second Monday in Oct SCANFROM -7 ADDOMIT MSG Thanksgiving Day
REM 11 November MSG Remembrance Day

View File

@@ -0,0 +1,10 @@
# Saskatchewan Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG Family Day
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
REM First Monday in Aug SCANFROM -7 ADDOMIT MSG Civic Holiday
REM Second Monday in Oct SCANFROM -7 ADDOMIT MSG Thanksgiving Day
OMIT 11 November MSG Remembrance Day

View File

@@ -0,0 +1,10 @@
# Yukon Territory Holidays
# SPDX-License-Identifier: GPL-2.0-only
DO ../ca.rem
REM Third Monday in Feb SCANFROM -7 ADDOMIT MSG Discovery Day
OMIT [easterdate($Uy) - 2] MSG Good Friday
REM Mon 18 May SCANFROM -7 ADDOMIT MSG Victoria Day
OMIT June 21 MSG National Indigenous Peoples Day
REM Second Monday in Oct SCANFROM -7 ADDOMIT MSG Thanksgiving Day
OMIT 11 November MSG Remembrance Day

View File

@@ -0,0 +1,29 @@
REM 1 Feb 2022 MSG Chinese New Year (Tiger)
REM 22 Jan 2023 MSG Chinese New Year (Rabbit)
REM 10 Feb 2024 MSG Chinese New Year (Dragon)
REM 29 Jan 2025 MSG Chinese New Year (Snake)
REM 17 Feb 2026 MSG Chinese New Year (Horse)
REM 6 Feb 2027 MSG Chinese New Year (Goat)
REM 26 Jan 2028 MSG Chinese New Year (Monkey)
REM 13 Feb 2029 MSG Chinese New Year (Rooster)
REM 3 Feb 2030 MSG Chinese New Year (Dog)
REM 23 Jan 2031 MSG Chinese New Year (Pig)
REM 11 Feb 2032 MSG Chinese New Year (Rat)
REM 31 Jan 2033 MSG Chinese New Year (Ox)
REM 19 Feb 2034 MSG Chinese New Year (Tiger)
REM 8 Feb 2035 MSG Chinese New Year (Rabbit)
REM 28 Jan 2036 MSG Chinese New Year (Dragon)
REM 15 Feb 2037 MSG Chinese New Year (Snake)
REM 4 Feb 2038 MSG Chinese New Year (Horse)
REM 24 Jan 2039 MSG Chinese New Year (Goat)
REM 12 Feb 2040 MSG Chinese New Year (Monkey)
REM 1 Feb 2041 MSG Chinese New Year (Rooster)
REM 22 Jan 2042 MSG Chinese New Year (Dog)
REM 10 Feb 2043 MSG Chinese New Year (Pig)
REM 30 Jan 2044 MSG Chinese New Year (Rat)
REM 17 Feb 2045 MSG Chinese New Year (Ox)
REM 6 Feb 2046 MSG Chinese New Year (Tiger)
REM 26 Jan 2047 MSG Chinese New Year (Rabbit)
REM 14 Feb 2048 MSG Chinese New Year (Dragon)
REM 2 Feb 2049 MSG Chinese New Year (Snake)
REM 23 Jan 2050 MSG Chinese New Year (Horse)

View File

@@ -10,7 +10,7 @@ REM 28 Oct MSG ΟΧΙ
REM 25 Dec MSG ΧΡΙΣΤΟΥΓΕΝΝΑ
REM 26 Dec MSG ΧΡΙΣΤΟΥΓΕΝΝΑ2
REM [orthodoxeaster($Uy)+1] ΔΕΥΤΕΡΑ ΤΟΥ ΠΑΣΧΑ
REM [orthodoxeaster($Uy)+1] MSG ΔΕΥΤΕΡΑ ΤΟΥ ΠΑΣΧΑ
# May first is a national holiday except if Sunday, day of great week (week before easter) or Monday after easter, then

View File

@@ -10,7 +10,6 @@ SET InIsrael value("InIsrael", 0)
SET Reform value("Reform", 0)
# Convenient function definition to save typing
FSET _h(x, y) HEBDATE(x,y)
FSET _h2(x, y) HEBDATE(x, y, $U-7)
FSET _PastSat(x, y) IIF(WKDAYNUM(_h2(x,y))!=6, _h2(x,y), _h2(x,y)+1)
FSET _BackTwoFri(x, y) IIF(WKDAYNUM(_h2(x,y))!=5, _h2(x,y), _h2(x,y)-2)
@@ -19,50 +18,50 @@ FSET _BackTwoSat(x, y) IIF(WKDAYNUM(_h2(x,y))!=6, _h2(x,y), _h2(x,y)-2)
SET InIsrael VALUE("InIsrael", 0)
SET Reform VALUE("Reform", 0)
[_h(1, "Tishrey")] ++4 MSG %"Rosh Hashana 1%" is %b.
REM [hebdate(1, "Tishrey")] ++4 MSG %"Rosh Hashana 1%" is %b.
# No RH-2 or Tzom Gedalia in Reform
IF !Reform
[_h(2, "Tishrey")] ++4 MSG %"Rosh Hashana 2%" is %b.
[_PastSat(3, "Tishrey")] ++4 MSG %"Tzom Gedalia%" is %b.
REM [hebdate(2, "Tishrey")] ++4 MSG %"Rosh Hashana 2%" is %b.
REM [_PastSat(3, "Tishrey")] ++4 MSG %"Tzom Gedalia%" is %b.
ENDIF
[_h(10, "Tishrey")] ++4 MSG %"Yom Kippur%" is %b.
[_h(15, "Tishrey")] ++4 MSG %"Sukkot 1%" is %b.
REM [hebdate(10, "Tishrey")] ++4 MSG %"Yom Kippur%" is %b.
REM [hebdate(15, "Tishrey")] ++4 MSG %"Sukkot 1%" is %b.
IF !InIsrael
[_h(16, "Tishrey")] MSG %"Sukkot 2%"
REM [hebdate(16, "Tishrey")] MSG %"Sukkot 2%"
ENDIF
[_h(21, "Tishrey")] ++4 MSG %"Hoshana Rabba%" is %b.
[_h(22, "Tishrey")] ++4 MSG %"Shemini Atzeret%" is %b.
REM [hebdate(21, "Tishrey")] ++4 MSG %"Hoshana Rabba%" is %b.
REM [hebdate(22, "Tishrey")] ++4 MSG %"Shemini Atzeret%" is %b.
IF InIsrael
[_h(22, "Tishrey")] ++4 MSG %"Simchat Torah%" is %b.
REM [hebdate(22, "Tishrey")] ++4 MSG %"Simchat Torah%" is %b.
ELSE
[_h(23, "Tishrey")] ++4 MSG %"Simchat Torah%" is %b.
REM [hebdate(23, "Tishrey")] ++4 MSG %"Simchat Torah%" is %b.
ENDIF
# Because Kislev can change length, we must be more careful about Chanukah
FSET _chan(x) HEBDATE(24, "Kislev", $U-9)+x
[_chan(1)] ++4 MSG %"Chanukah 1%" is %b.
[_chan(2)] MSG %"Chanukah 2%"
[_chan(3)] MSG %"Chanukah 3%"
[_chan(4)] MSG %"Chanukah 4%"
[_chan(5)] MSG %"Chanukah 5%"
[_chan(6)] MSG %"Chanukah 6%"
[_chan(7)] MSG %"Chanukah 7%"
[_chan(8)] MSG %"Chanukah 8%"
REM [_chan(1)] ++4 MSG %"Chanukah 1%" is %b.
REM [_chan(2)] MSG %"Chanukah 2%"
REM [_chan(3)] MSG %"Chanukah 3%"
REM [_chan(4)] MSG %"Chanukah 4%"
REM [_chan(5)] MSG %"Chanukah 5%"
REM [_chan(6)] MSG %"Chanukah 6%"
REM [_chan(7)] MSG %"Chanukah 7%"
REM [_chan(8)] MSG %"Chanukah 8%"
# Not sure about Reform's position on the next one.
IF !Reform
# 10 Tevet will never be a Saturday, so whether or not to
# move it is moot. (Thanks to Art Werschulz.)
[_h(10, "Tevet")] MSG %"Tzom Tevet%" is %b.
REM [hebdate(10, "Tevet")] MSG %"Tzom Tevet%" is %b.
ENDIF
[_h(15, "Shvat")] ++4 MSG %"Tu B'Shvat%" is %b.
[_h(14, "Adar A")] ++4 MSG %"Purim Katan%" is %b.
REM [hebdate(15, "Shvat")] ++4 MSG %"Tu B'Shvat%" is %b.
REM [hebdate(14, "Adar A")] ++4 MSG %"Purim Katan%" is %b.
# If Purim is on Sunday, then Fast of Esther is 11 Adar.
IF WKDAYNUM(_h2(13, "Adar")) != 6
@@ -70,43 +69,39 @@ IF WKDAYNUM(_h2(13, "Adar")) != 6
ELSE
REM [_h2(11, "Adar")] ++4 MSG %"Fast of Esther%" is %b.
ENDIF
[_h(14, "Adar")] ++4 MSG %"Purim%" is %b.
[_h(15, "Nisan")] ++4 MSG %"Pesach%" is %b.
REM [hebdate(14, "Adar")] ++4 MSG %"Purim%" is %b.
REM [hebdate(15, "Nisan")] ++4 MSG %"Pesach%" is %b.
IF !InIsrael
[_h(16, "Nisan")] MSG %"Pesach 2%"
REM [hebdate(16, "Nisan")] MSG %"Pesach 2%"
ENDIF
[_h(21, "Nisan")] MSG %"Pesach 7%"
REM [hebdate(21, "Nisan")] MSG %"Pesach 7%"
IF !InIsrael && !Reform
[_h(22, "Nisan")] MSG %"Pesach 8%"
REM [hebdate(22, "Nisan")] MSG %"Pesach 8%"
ENDIF
[_h(27, "Nisan")] ++4 MSG %"Yom HaShoah%" is %b.
[_BackTwoFri(4, "Iyar")] ++4 MSG %"Yom HaZikaron%" is %b.
[_BackTwoSat(5, "Iyar")] ++4 MSG %"Yom Ha'atzmaut%" is %b.
REM [hebdate(27, "Nisan")] ++4 MSG %"Yom HaShoah%" is %b.
REM [_BackTwoFri(4, "Iyar")] ++4 MSG %"Yom HaZikaron%" is %b.
REM [_BackTwoSat(5, "Iyar")] ++4 MSG %"Yom Ha'atzmaut%" is %b.
# Not sure about Reform's position on Lag B'Omer
IF !Reform
[_h(18, "Iyar")] ++4 MSG %"Lag B'Omer%" is %b.
REM [hebdate(18, "Iyar")] ++4 MSG %"Lag B'Omer%" is %b.
ENDIF
[_h(28, "Iyar")] ++4 MSG %"Yom Yerushalayim%" is %b.
[_h(6, "Sivan")] ++4 MSG %"Shavuot%" is %b.
REM [hebdate(28, "Iyar")] ++4 MSG %"Yom Yerushalayim%" is %b.
REM [hebdate(6, "Sivan")] ++4 MSG %"Shavuot%" is %b.
IF !InIsrael && !Reform
[_h(7, "Sivan")] MSG %"Shavuot 2%"
REM [hebdate(7, "Sivan")] MSG %"Shavuot 2%"
ENDIF
# Fairly sure Reform Jews don't observe the next two
IF !Reform
# Tzom Tamuz and Tish'a B'Av are moved to Sunday if they normally
# fall on a Saturday
[_PastSat(17, "Tamuz")] ++4 MSG %"Tzom Tammuz%" is %b.
[_PastSat(9, "Av")] ++4 MSG %"Tish'a B'Av%" is %b.
REM [_PastSat(17, "Tamuz")] ++4 MSG %"Tzom Tammuz%" is %b.
REM [_PastSat(9, "Av")] ++4 MSG %"Tish'a B'Av%" is %b.
ENDIF
# Clean up
FUNSET _h _h2 _PastSat _BackTwoFri _BackTwoSat _chan

17
include/holidays/pt.rem Normal file
View 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

View File

@@ -1,24 +1,28 @@
# SPDX-License-Identifier: GPL-2.0-only
SET autolang getenv("REMIND_LANG")
if !defined("__autolang__")
SET __autolang__ 1
PRESERVE __autolang__
SET autolang getenv("REMIND_LANG")
IF autolang == ""
SET autolang getenv("LC_ALL")
ENDIF
IF autolang == ""
SET autolang getenv("LANGUAGE")
ENDIF
IF autolang == ""
SET autolang getenv("LANG")
ENDIF
IF autolang == ""
SET autolang getenv("LC_ALL")
ENDIF
IF autolang == ""
SET autolang getenv("LANGUAGE")
ENDIF
IF autolang == ""
SET autolang getenv("LANG")
ENDIF
IF autolang != ""
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 5)) + ".rem", "r") == 0
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 5))].rem
ELSE
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 2)) + ".rem", "r") == 0
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 2))].rem
IF autolang != ""
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 5)) + ".rem", "r") == 0
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 5))].rem
ELSE
IF access($SysInclude + "/lang/" + lower(substr(autolang, 1, 2)) + ".rem", "r") == 0
INCLUDE [$SysInclude]/lang/[lower(substr(autolang, 1, 2))].rem
ENDIF
ENDIF
ENDIF
UNSET autolang
ENDIF
UNSET autolang

View File

@@ -87,3 +87,5 @@ SET daylightST_starts_str "Beginn Sommerzeit"
# Daylight saving time ends
SET daylightST_ends_str "Ende Sommerzeit"
PRESERVE earthseasons_Perihelion_str earthseasons_EquinoxMar_str earthseasons_SolsticeJun_str earthseasons_Aphelion_str earthseasons_EquinoxSep_str earthseasons_SolsticeDec_str daylightST_starts_str daylightST_ends_str

View File

@@ -81,3 +81,5 @@ SET daylightST_starts_str "Έναρξη θέρους"
# Daylight saving time ends
SET daylightST_ends_str "Τέλος θέρους"
PRESERVE earthseasons_Perihelion_str earthseasons_EquinoxMar_str earthseasons_SolsticeJun_str earthseasons_Aphelion_str earthseasons_EquinoxSep_str earthseasons_SolsticeDec_str daylightST_starts_str daylightST_ends_str

View File

@@ -525,9 +525,9 @@ contains the back value. If the "back" value was \-n, the value will
be positive; if it was \-\-n, the value will be negative.
.TP
.B delta \fIn\fR
If the reminder contained a "delta" clause (\+n or \+\+n), this key
contains the delta value. If the "delta" value was \+n, the value will
be positive; if it was \+\+n, the value will be negative.
If the reminder contained a "delta" clause (+n or ++n), this key
contains the delta value. If the "delta" value was +n, the value will
be positive; if it was ++n, the value will be negative.
.TP
.B rep \fIn\fR
If the reminder contained a "repeat" clause (*n), this key contains

View File

@@ -11,8 +11,8 @@ reminder or alarm can consist of a message sent to standard output, or
a program to be executed.
.PP
If \fIfilename\fR is specified as a single dash '-', then \fBRemind\fR
takes its input from standard input. This also implicitly enables
the \fB\-o\fR option, described below.
takes its input from standard input.
.PP
If \fIfilename\fR happens to
be a directory rather than a plain file, then \fBRemind\fR reads all of
@@ -28,15 +28,12 @@ Anything after the __EOF__ marker is completely ignored.
\fBRemind\fR has a slew of options. If you're new to the program,
ignore them for now and skip to the section "REMINDER FILES".
.TP
.B \-\-version
The \fB\-\-version\fR option causes \fBRemind\fR to print its version number
to standard output and then exit.
.TP
.B \-n
The \fB\-n\fR option causes \fBRemind\fR to print the \fBnext\fR occurrence
of each reminder in a simple calendar format. You can sort this by
date by piping the output through \fBsort(1)\fR. Note that the \fB\-n\fR
option causes any \fB\-g\fR option to be \fIignored\fR.
option causes any \fB\-g\fR option to be \fIignored\fR and also implicitly
enables the \fB\-o\fR option.
.TP
.B \-j\fR[\fIn\fR]
Runs \fBRemind\fR in "purge" mode to get rid of expired reminders.
@@ -51,7 +48,7 @@ The \fB\-c\fR option causes \fBRemind\fR to produce a calendar that is
sent to standard output. If you supply a number \fIn\fR, then a
calendar will be generated for \fIn\fR months, starting with the
current month. By default, a calendar for only the current month is
produced.
produced. This option implicitly enables the \fB\-o\fR option.
.RS
.PP
You can precede \fIn\fR (if any) with a set of flags. The flags
@@ -177,7 +174,7 @@ The \fB\-s\fR option is very similar to the \fB\-c\fR option, except
that the output calendar is not formatted. It is listed in a "simple
format" that can be used as input for more sophisticated calendar-drawing
programs. If \fIn\fR starts with "+", then it is interpreted as a number
of weeks.
of weeks. This option also implicitly enables the \fB\-o\fR option.
If you immediately follow the \fBs\fR with the letter
\fBa\fR, then \fBRemind\fR displays reminders on the calendar on the
@@ -204,6 +201,9 @@ letter with this option, then the normal calendar-mode substitution filter
is disabled and the %"...%" sequences are preserved in the output.
.RS
.PP
The \fB\-p\fR, \fB\-pp\fR and \fB\-ppp\fR options implicitly enable
the \fB\-o\fR option.
.PP
Note that the \fB\-pp\fR or \fB\-ppp\fR options also enable the \fB\-l\fR
option.
.RE
@@ -227,7 +227,11 @@ error, and to print a security message if a script tests the
$RunOff system variable.
.TP
.B \-o
The \fB\-o\fR option causes \fBRemind\fR to ignore all \fBONCE\fR directives.
The \fB\-o\fR option causes \fBRemind\fR to ignore all \fBONCE\fR
directives. Note that \fBONCE\fR is also ignored if any of the
\fB\-c\fR, \fB\-n\fR, \fB\-p\fR, or \fB\-s\fR options is used, if a
repetition factor \fB*n\fR is used, or if a date other than today's
date is specified on the command-line.
.TP
.B \-t
The \fB\-t\fR option causes \fBRemind\fR to trigger all non-expired reminders,
@@ -236,13 +240,13 @@ regardless of the \fIdelta\fR supplied for each reminder.
.B \-t\fR\fIn\fR
If you supply a number \fIn\fR after the \fB\-t\fR option, then
\fBRemind\fR pretends that echo \fBREM\fR command has a delta
of \+\+\fIn\fR, regardless of any existing delta.
of ++\fIn\fR, regardless of any existing delta.
.TP
.B \-tz\fR
If you supply the letter \fBz\fR after the \fB\-t\fR option, then
\fBRemind\fR sets all REM statements' deltas to zero, regardless of the
value supplied in the REM statement itself. In effect, this disables
all deltas of the form \fB\+\fIn\fR and \fB\+\+\fIn\fR.
all deltas of the form \fB+\fIn\fR and \fB++\fIn\fR.
.TP
.B \-tt\fR[\fIn\fR]
The \fB-tt\fR option causes \fBRemind\fR to assume a default delta of
@@ -302,9 +306,9 @@ Echo lines when displaying error messages
Trace the reading of reminder files
.TP
.B s
Upon exit, print the high-water mark of the operator and value stacks
used for expression-parsing. This is unlikely to be useful unless
you're intimately familiar with Remind's source code.
Trace expression parsing and display the internal expression node
tree. This is unlikely to be useful unless you are working on
\fBRemind\fR's expression evaluation engine.
.RE
.TP
\fB\-g\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR[\fBa|d\fR]]]]
@@ -366,13 +370,18 @@ You use both \fB\-k\fR\fIcmd1\fR and \fB\-k:\fR\fIcmd2\fR to use different
commands for queued versus non-queued reminders.
.RE
.TP
\fB\-z\fR[\fIn\fR] Runs \fBRemind\fR in the daemon mode. If \fIn\fR
\fB\-z\fR[\fIn\fR] Runs \fBRemind\fR in "daemon mode". If \fIn\fR
is supplied, it specifies how often (in minutes) \fBRemind\fR should
wake up to check if the reminder script has been changed. \fIN\fR
defaults to 1, and can range from 1 to 60. Note that the use of the
\fB\-z\fR option also enables the \fB\-f\fR option.
.PP
.RS
If \fBRemind\fR is compiled on a system that supports
\fBinotify\fR(7), then if the reminder script supplied on the
command-line is actually a directory, \fBRemind\fR additionally checks
if all files within that directory have been modified since startup.
.PP
If you supply the option \fB\-zj\fR, \fBRemind\fR runs in a
special mode called \fBserver mode\fR. This is documented
in the tkremind man page; see tkremind(1). The older server mode
@@ -415,7 +424,9 @@ TAG clause.
\fB\-i\fR\fIvar\fR\fB=\fR\fIexpr\fR
Sets the value of the specified \fIvar\fR to \fIexpr\fR, and \fBpreserves\fR
\fIvar\fR. \fIExpr\fR can be any valid \fBRemind\fR expression. See the
section "INITIALIZING VARIABLES ON THE COMMAND LINE" for more details.
section "INITIALIZING VARIABLES ON THE COMMAND LINE" for more details. If
you omit the \fB=\fR\fIexpr\fR part, then \fIvar\fR is initialized to 0.
In other words, \fB\-i\fIvar\fR is exactly the same as \fB\-i\fIvar\fR\fB=\fR0.
.TP
\fB\-i\fR\fIfunc\fR(\fIargs\fR)=\fIdefinition\fR
Allows you to define a function on the command line.
@@ -446,6 +457,55 @@ with the date incrementing on each iteration. You may have to enclose
the parameter in quotes to avoid shell expansion. See the subsection
"Repeated Execution" in the section "CALENDAR MODE" for more
information.
.SH LONG OPTIONS
\fBRemind\fR supports the following long options, which \fIare\fR
case-sensitive:
.PP
.B \-\-version
The \fB\-\-version\fR option causes \fBRemind\fR to print its version number
to standard output and then exit.
.TP
.B \-\-print-config-cmd
This option causes \fBRemind\fR to print the exact \fB./configure\fR
command that was used when \fBRemind\fR was built. You can use this
to build a new version of \fBRemind\fR using the same configuration
as an existing one by running:
.RS
.PP
.nf
eval `remind --print-config-cmd`
.fi
.PP
from the top-level \fBRemind\fR source directory. (However, it's safer
to simply run \fBremind --print-config-cmd\fR and then type in the
command once you've verified that it looks OK.)
.RE
.TP
.B \-\-print-tokens
The \fB\-\-print-tokens\fR option causes \fBRemind\fR to print the tokens
used by the parser, built-in function names, and system variable names
to standard output and then exit. This output is designed to make it easy
to create a syntax-highlighting file for various text editors. The output
can be modified by hand or by a script into a syntax-highlighting file
with relative ease.
.TP
.B \-\-max-execution-time\fR=\fIn\fR
Limit the total execution time (as measured by the wall clock) to
\fIn\fR seconds. This is useful if \fBRemind\fR is invoked on
potentially-untrustworthy files that could attempt to use a lot of
resources. Note that the limit \fIn\fR is approximate and
\fBRemind\fR might execute for one or two more seconds before it is
killed. If \fIn\fR is specified as zero, then no limit is applied, just
as if the option had not been used at all.
.PP
If a limit is applied, it applies only to the foreground run of \fBRemind\fR.
If \fBRemind\fR finishes processing the script and then starts handling
queued reminders, the time limit is reset to no limit.
.PP
.SH REMINDER FILES
.PP
\fBRemind\fR uses scripts to control its operation. You can use any
@@ -454,14 +514,14 @@ text editor capable of creating plain-text files to create a
very simple and almost immediately understandable:
.PP
.nf
REM 6 Jan MSG Dianne's birthday
REM Mar 31 MSG International Transgender Day of Visibility
.fi
.PP
to the baroque and obscure:
.PP
.nf
REM [date(thisyear, 1, 1) + 180] ++5 OMIT \\
sat sun BEFORE MSG [ord(thisyear-1980)] payment due %b!
REM [date(thisyear, 1, 1) + 180] ++5 OMIT \\
sat sun BEFORE MSG [ord(thisyear-1980)] payment due %b!
.fi
.PP
A reminder file consists of commands, with one command per line. Several
@@ -520,12 +580,15 @@ Its syntax is:
The parts of the \fBREM\fR command can be specified in any order, except
that the \fIbody\fR must come immediately after the \fBMSG\fR,
\fBRUN\fR, \fBCAL\fR, \fBPS\fR, \fBPSFILE\fR or \fBSATISFY\fR keyword.
The portion of the \fBREM\fR command before the \fBMSG\fR, \fBMSF\fR
\fBRUN\fR, \fBCAL\fR or \fBSATISFY\fR clause is called a
\fItrigger\fR.
.PP
The \fBREM\fR token is optional, providing that the remainder
of the command cannot be mistaken for another \fBRemind\fR command
such as \fBOMIT\fR or \fBRUN\fR. The portion of the \fBREM\fR command
before the \fBMSG\fR, \fBMSF\fR \fBRUN\fR, \fBCAL\fR or \fBSATISFY\fR clause
is called a \fItrigger\fR.
In earlier versions of \fBRemind\fR, the \fBREM\fR token was optional
providing that the remainder of the command cannot be mistaken for
another \fBRemind\fR command. However, this use is deprecated and will
now cause a warning to be issued. All of your reminder lines should
be written to start with the REM command.
.PP
.B "MSG, MSF, RUN, CAL, SPECIAL, PS and PSFILE"
.PP
@@ -538,14 +601,16 @@ used the \fB\-k\fR command-line option, then \fBMSG\fR-type reminders are
passed to the appropriate program. Note that the options \fB\-c\fR,
\fB\-s\fR, \fB\-p\fR and \fB\-n\fR disable the \fB\-k\fR option.
.PP
Note that you can omit the reminder type, in which case it
defaults to \fBMSG\fR. So you can write:
Earlier versions of \fBRemind\fR let you omit the reminder type,
in which case it defaulted to \fBMSG\fR. However, this usage is
deprecated and will cause a warning. Something like:
.PP
.nf
6 January Dianne's Birthday
REM 6 January Dianne's Birthday
.fi
.PP
although this is not recommended.
will issue the warning "Missing REM type; assuming MSG"
.PP
The \fBMSF\fR keyword is almost the same as the \fBMSG\fR keyword,
except that the reminder is formatted to fit into a paragraph-like
@@ -992,26 +1057,35 @@ overrides that.
.B THE ONCE KEYWORD
.PP
Sometimes, it is necessary to ensure that reminders are run only once
on a given day. For example, if you have a reminder that makes a backup
of your files every Friday:
on a given day. For example, compare the following two reminders:
.PP
.nf
REM Fri RUN do_backup
REM Fri RUN do_backup
REM Fri ONCE RUN do_backup
.fi
.PP
(Here, \fIdo_backup\fR is assumed to be a program or shell script that
does the work.) If you run \fBRemind\fR from your .login script, for
example, and log in several times per day, the \fIdo_backup\fR program
will be run each time you log in. If, however, you use the \fBONCE\fR
keyword in the reminder, the \fBRemind\fR checks the last access date of
the reminder script. If it is the same as the current date, \fBRemind\fR
assumes that it has already been run, and will not issue reminders containing
the \fBONCE\fR keyword.
The first will be run every time you invoke \fBRemind\fR on a Friday,
whereas the second will be run only the first time you invoke
\fBRemind\fR on a given Friday.
.PP
If you run \fBRemind\fR from your .login script, for example, and log
in several times per day, the \fIdo_backup\fR program in the first
reminder will be run each time you log in. If, however, you use the
\fBONCE\fR keyword in the reminder, the \fBRemind\fR checks the last
access date of the reminder script. If it is the same as the current
date, \fBRemind\fR assumes that it has already been run, and will not
issue reminders containing the \fBONCE\fR keyword.
.PP
Note that if you view or edit your reminder script, the last access date
will be updated, and the \fBONCE\fR keyword will not operate properly.
You can fix this by setting a timestamp file for \fBRemind\fR to track
the last-run date; see the documentation of \fB$OnceFile\fR in the
\fBSYSTEM VARIABLES\fR section. If you use standard input as your
\fBRemind\fR input file, then you \fImust\fR use \fB$OnceFile\fR for the
\fBONCE\fR keyword to work properly.
.PP
If you start \fBRemind\fR with the \fB\-o\fR option, then the \fBONCE\fR
keyword will be ignored.
keyword will be ignored and any \fB$OnceFile\fR will be ignored.
.PP
.B LOCALLY OMITTING WEEKDAYS
.PP
@@ -1065,6 +1139,10 @@ be Friday, Saturday and Sunday.
.PP
The \fBOMITFUNC\fR phrase of the \fBREM\fR command allows you to
supply a function that determines whether or not a date is omitted.
Note that \fBOMITFUNC\fR must be given just the name of a user-defined
function; it can't take an arbitrary expression or the name of a built-in
function.
.PP
The function is passed a single parameter of type \fBDATE\fR, and must
return a non-zero integer if the date is considered "omitted" and 0
otherwise. Here's an example:
@@ -1521,7 +1599,35 @@ is replaced with "\fIyy\fR", the last two digits of the year.
.TP
.B %_
(percent-underscore) is replaced with a newline. You can use this to
achieve multi-line reminders.
achieve multi-line reminders. Note that calendar back-ends vary in
how they handle multi-line reminders:
.RS
.TP
.B o
Running \fBremind -c\fR preserves newlines in the terminal calendar output.
.TP
.B o
\fBrem2pdf\fR preserves newlines if \fBremind\fR is invoked with the \fB\-pp\fR
or \fB\-ppp\fR option.
.TP
.B o
\fBrem2html\fR preserves newlines if \fBremind\fR is invoked with the
\fB\-pp\fR option.
.TP
.B o
\fBtkremind\fR preserves newlines.\fR
.TP
.B o
\fBrem2ps\fR converts newlines to spaces. But \fBrem2ps\fR is deprecated;
use \fBrem2pdf\fR instead.
.TP
.B o
The "simple calendar" formats (ie, \fBremind\fR's \fB\-s\fR, \fB\-n\fR and
\fB\-p\fR options) convert newlines to spaces.
.PP
All calendar back-ends collapse multiple spaces to a single space and
multiple newlines to a single newline.
.RE
.TP
.B %1
is replaced with "now", "\fIm\fR minutes from now", "\fIm\fR minutes ago",
@@ -1655,7 +1761,7 @@ or:
The \fBOMIT\fR command is used to "globally" omit certain days
(usually holidays). These globally-omitted days are skipped by the
"\-" and "+" forms of \fIback\fR and \fIdelta\fR, but not by the
"\-\-" and "\+\+" forms. Some examples:
"\-\-" and "++" forms. Some examples:
.PP
.nf
OMIT Saturday Sunday
@@ -1875,24 +1981,6 @@ If you run \fBRemind\fR with the \fB\-r\fR command-line option,
regardless of any \fBRUN\fR commands in the reminder script. However,
any command supplied with the \fB\-k\fR option will still be executed.
.PP
One use of the \fBRUN\fR command is to provide a secure interface
between \fBRemind\fR and the \fBElm\fR mail system. The \fBElm\fR
system can automatically scan incoming mail for reminder or calendar
entries, and place them in your calendar file. To use this feature,
you should set the calendar filename option under \fBElm\fR to be something
like "~/.reminders.in", \fInot\fR your main reminder file! This is
so that any \fBRUN ON\fR commands mailed to you can never be activated.
.PP
Then, you can use the \fBElm\fR \fIscan message for calendar entries\fR
command to place reminders prefaced by "->" into .reminders.in. In
your main .reminders file, include the following lines:
.PP
.nf
RUN OFF # Disable RUN
INCLUDE .reminders.in
RUN ON # Re-enable RUN
.fi
.PP
In addition, \fBRemind\fR contains a few other security
features. It will not read a file that is group- or world-writable.
It will not run set-uid. If it reads a file you don't own, it will
@@ -1904,6 +1992,30 @@ attempt to check the ownership of standard input, even if it is
coming from a file, and hence does \fInot\fR disable RUN and shell()
in this situation.
.PP
.SH THE EXPR COMMAND
.PP
\fBRemind\fR lets you completely disable expression evaluation. This
could be useful if you are running Remind on a somewhat-untrustworthy
file that is not expected to contain expressions. To disable
expression evaluation, use:
.PP
.nf
EXPR OFF
.fi
.PP
If \fBRemind\fR encounters an expression while EXPR OFF is in effect, it
returns an error
.PP
To re-enable expression evaluation, use:
.PP
.nf
EXPR ON
.fi
.PP
As with \fBRUN ON\fB, \fBEXPR ON\fR can be used only in the top-level
script, not in an included file.
.PP
.SH THE INCLUDECMD COMMAND
.PP
\fBRemind\fR allows you to execute a shell command and evaluate the
@@ -1945,6 +2057,10 @@ your INCLUDECMD uses expression-pasting that results in differences depending
on the value of \fBtoday()\fR, then each \fIunique\fR version of the
command will be executed once.
.PP
If a given reminder file contains more than one identical
\fBINCLUDECMD\fR, only the first one will actually be executed. All
subsequent identical ones will use the cached output from the first one.
.PP
.SH THE BANNER COMMAND
.PP
@@ -2094,6 +2210,11 @@ If the \fBTIME\fR is used where \fBRemind\fR expects a time-of-day
\fIpm\fR suffix and the hour can be as large as you want, so long
as the total number of minutes in the duration fits in a signed integer
variable.
.PP
For convenience, a \fBTIME\fR constant may be surrounded by single
quotes to match \fBDATE\fR and \fBDATETIME\fR constants, but these
quotes are optional. That is, 12:56 and '12:56' represent the same
\fBTIME\fR constant.
.RE
.TP
.B DATE constants
@@ -2128,11 +2249,11 @@ and time separator characters for \fBDATE\fR and \fBTIME\fR constants apply
also to \fBDATETIME\fR constants.
.RE
.PP
.B ZERO VALUES
.B ZERO VALUES AND TRUE/FALSE
.PP
The non-string types all have an associated \fIzero\fR value, which is
treated as "false" by the IF command and the logical operators. The
zero values are:
All types have an associated \fIzero value\fR, which is treated as
\fIfalse\fR by the IF command, the IIF function, and the logical
operators. The zero values are:
.PP
.RS
.PP
@@ -2143,10 +2264,11 @@ zero values are:
\fBTIME\fR - 00:00
.PP
\fBDATETIME\fR - '1990-01-01@00:00'
.PP
\fBSTRING\fR - "" (the empty string)
.RE
.PP
Additionally, for the purpose of the IF command (but \fInot\fR the
logical operators) the empty string "" is considered a false value.
Any value other than the \fIzero value\fR is treated as \fItrue\fR.
.PP
.B OPERATORS
.PP
@@ -2156,21 +2278,21 @@ than those on higher lines. The operators approximately correspond to
C operators.
.PP
.nf
! - (unary logical negation and arithmetic negation)
* / %
+ -
< <= > >=
== !=
&&
||
! - (unary logical negation and arithmetic negation)
* / % (multiplication, division, modulus)
+ - (addition/concatenation, subtraction)
< <= > >= (comparisons)
== != (equality and inequality tests)
&& (logical AND)
|| (logical OR)
.fi
.PP
.B DESCRIPTION OF OPERATORS
.PP
.TP
.B !
Logical negation. Can be applied to an \fBINT\fR type. If the operand
is non-zero, returns zero. Otherwise, returns 1.
Logical negation. Can be applied to any type. If the operand
is non-zero, returns 0. Otherwise, returns 1.
.TP
.B \-
Unary minus. Can be applied to an \fBINT\fR. Returns the negative
@@ -2274,16 +2396,16 @@ If the operands are not of the same type, == returns 0 and != returns
.RE
.TP
.B &&
This is the logical AND operator. Both of its operands must be of the
same type and must not be \fBSTRING\fR type. Returns the second
operand if both operands are non-zero. Otherwise, returns a zero
of the same type as the operands.
This is the logical AND operator. Returns the second operand if both
operands are non-zero. Otherwise, returns whichever operand is zero.
Operands can be any type and "zero" is interpreted as appropriate for
each operand's type.
.TP
.B ||
This is the logical OR operator. Both of its operands must be of
the same type and must not be of \fBSTRING\fR type. It returns
the first operand that is non-zero; if both operands are zero, then
returns a zero of the same type as the operands.
This is the logical OR operator. It returns the first operand that is
non-zero; if both operands are zero, then returns the second operand.
Operands can be any type and "zero" is interpreted as appropriate for
each operand's type.
.PP
.B NOTES
.PP
@@ -2304,15 +2426,10 @@ For example:
12:59 + (1 + "test") yields "12:591test"
.fi
.PP
The logical operators are \fInot\fR so-called short-circuit operators, as
they are in C. Both operands are always evaluated. Thus, an expression
such as:
.PP
.nf
(f!=0) && (100/f <= 3)
.fi
.PP
will cause an error if f is zero.
The logical operators are so-called short-circuit operators, as
they are in C. This means that if the first operand of || is true,
then the second operand is \fInot\fR evaluated. Similarly, if the first
operand of && is false, then the second operand is \fInot\fR evaluated.
.PP
.B VARIABLES
.PP
@@ -2394,9 +2511,9 @@ Universal Time Coordinated in the \fB$MinsFromUTC\fR system variable.
If non-zero, then the \fB\-c\fR option was supplied on the command line.
.TP
.B $Daemon (read-only)
If the daemon mode \fB\-z\fR was invoked, contains the number of
If "daemon mode" \fB\-z\fR was invoked, contains the number of
minutes between wakeups. If not running in daemon mode, contains
0.
0. In server mode (either \fB-z0\fR or \fB-zj\fR), contains -1.
.TP
.B $DateSep
This variable can be set only to "/" or "-". It holds the character
@@ -2469,6 +2586,14 @@ because the final parenthesis and quote are ignored (for the purposes
of spacing) when they follow a period.
.RE
.TP
.B $ExpressionTimeLimit
If set to a non-zero value \fIn\fR, than any expression that takes longer than
\fIn\fR seconds to evaluate will be aborted and an error returned. This is
to prevent maliciously-crafted expressions for creating a denial-of-service.
In an included file, $ExpressionTimeLimit can only be lowered from its
current value. In the top-level file, it can be set to any value, including
zero to disable the time limit.
.TP
.B $FirstIndent
The number of spaces by which to indent the first line of a \fBMSF\fR-type
reminder. The default is 0.
@@ -2497,9 +2622,9 @@ truncated - the width limit will be ignored.
If non-zero, then the \fB\-h\fR option was supplied on the command line.
.TP
.B $IgnoreOnce (read-only)
If non-zero, then the \fB\-o\fR option was supplied on the command line,
or a date different from today's true date was supplied. If non-zero,
then \fBONCE\fR directives will be ignored.
If non-zero, then the \fB\-o\fR option was supplied on the command
line, or implicitly enabled for some other reason. In this case,
\fBONCE\fR directives will be ignored.
.TP
.B $InfDelta (read-only)
If non-zero, then the \fB\-t\fR option was supplied on the command line,
@@ -2656,6 +2781,20 @@ by \fBREM\fR commands; triggers in \fBIFTRIG\fR commands do
not affect it.
.RE
.TP
.B $OnceFile (STRING type)
If you set this variable to a non-empty string, then rather than using
the file access date to determine whether or not to run a ONCE-type
reminder, \fBRemind\fR will maintain a timestamp in the file \fB$OnceFile\fR.
This is more reliable than using the access date of the reminder file.
.RS
.PP
If \fB$OnceFile\fR does not exist, then it will be created the first time
a \fBONCE\fR keyword is processed. The file must be writable by the
current user. If you try to set \fB$OnceFile\fR \fIafter\fR a \fBONCE\fR
reminder has already been processed, \fBRemind\fR will issue a warning
and ignore the attempt to set \fB$OnceFile\fR.
.RE
.TP
.B $ParseUntriggered
A flag indicating whether or not \fBRemind\fR should fully parse \fBREM\fR
statements that are not triggered. 0 means to skip parsing them and 1
@@ -2707,8 +2846,15 @@ order, or 2 if sorting by time in descending order.
The number of spaces by which all lines (except the first) of an
\fBMSF\fR-type reminder should be indented. The default is 0.
.TP
.B $SuppressImplicitWarnings
Normally, \fBRemind\fR issues a warning if a line begins with an unknown
token and is treated as a \fBREM\fR command, or if a \fBREM\fR command
is missing a type and is treated as a \fBMSG\fR-type reminder. Setting
\fB$SuppressImplicitWarnings\fR to 1 suppresses these warnings. The default
is 0 and we do not recommend disabling the warnings.
.TP
.B $SuppressLRM
Normally, when Remind is run with the \fB\-c\fR option in a UTF-8 locale,
Normally, when \fBRemind\fR is run with the \fB\-c\fR option in a UTF-8 locale,
it emits a left-to-right mark sequence after printing day names or
reminders. Some terminals render this incorrectly, so you can use:
.RS
@@ -2742,6 +2888,9 @@ Equivalent to \fBwkdaynum(trigdate())\fR.
.B $Ty (read-only)
Equivalent to \fByear(trigdate())\fR.
.TP
.B $Tt (read-only, TIME type)
Equivalent to \fBtrigtime()\fR.
.TP
.B $TimeSep
This variable can be set only to ":" or ".". It holds the character
used to separate portions of a time when \fBRemind\fR prints a TIME or
@@ -2831,18 +2980,25 @@ is supplied, only the date component is used.
Returns the time of "astronomical twilight" on the specified \fIdate\fR. If
\fIdate\fR is omitted, defaults to \fBtoday()\fR.
.TP
.B ampm(tq_time [,s_am [,s_pm]])
.B ampm(tq_time [,s_am [,s_pm [,i_lz]]])
Returns a \fBSTRING\fR that is the result of converting \fItime\fR
(which is either a \fBTIME\fR or a \fBDATETIME\fR object) to "AM/PM"
format. The optional arguments \fIam\fR and \fIpm\fR are the strings
to append in the AM and PM case, respectively; they default to "AM"
and "PM". The function obeys the system variables $DateSep,
$TimeSep and $DateTimeSep when formatting its output. For example:
and "PM". The optional argument \fIlz\fR specifies whether or not
the hour should be padded to two digits with a leading zero. If \fIlz\fR is
zero, then a leading 0 is not added; otherwise, the hour is padded out to
two digits with a leading zero. If not supplied, \fIlz\fR defaults to zero.
.RS
.PP
The function obeys the system variables $DateSep, $TimeSep and
$DateTimeSep when formatting its output. Here are some examples of
its output:
.PP
.nf
ampm(0:22) returns "12:22AM"
ampm(17:45, "am", "pm") returns "5:45pm"
ampm(17:45, "am", "pm", 1) returns "05:45pm"
ampm('2020-03-14@21:34') returns "2020-03-14@9:34PM"
.fi
.PP
@@ -2945,8 +3101,9 @@ arguments, then the last argument is returned. Examples:
\fBchoose(4, "foo", 1:13, 1000)\fR returns 1000
.fi
.RS
Note that all arguments to \fBchoose()\fR are \fIalways\fR
evaluated.
.PP
Note that only the first argument and the chosen result are
evaluated. Any non-chosen arguments will not be evaluated.
.RE
.TP
.B coerce(s_type, x_arg)
@@ -3202,14 +3359,15 @@ out. The stripping algorithm is fairly naive; the function starts
stripping characters when it encounters a "<" and it stops stripping
when it encounters a ">".
.TP
.B iif(si_test1, x_arg1, [si_test2, x_arg2,...], x_default)
If \fItest1\fR is not zero or the null string, returns \fIarg1\fR.
Otherwise, if \fItest2\fR is not zero or the null string, returns
\fIarg2\fR, and so on. If all of the \fItest\fR arguments are false,
returns \fIdefault\fR. Note that all arguments are \fIalways\fR evaluated.
This function accepts an odd number of arguments - note that prior to version
03.00.05 of \fBRemind\fR, it accepted 3 arguments only. The 3-argument
version of \fBiif()\fR is compatible with previous versions of \fBRemind\fR.
.B iif(x_test1, x_arg1, [x_test2, x_arg2,...], x_default)
If \fItest1\fR is true, returns \fIarg1\fR. Otherwise, if \fItest2\fR
is true, returns \fIarg2\fR, and so on. If all of the \fItest\fR
arguments are false, returns \fIdefault\fR. Note that only
those arguments needed to determine the final result are
evaluated. This function accepts an odd number of
arguments - note that prior to version 03.00.05 of \fBRemind\fR, it
accepted 3 arguments only. The 3-argument version of \fBiif()\fR is
compatible with previous versions of \fBRemind\fR.
.TP
.B index(s_search, s_target [,i_start)
Returns an \fBINT\fR that is the location of \fItarget\fR in the
@@ -3830,7 +3988,7 @@ function for advance warning to work properly. This is because
\fBtrig\fR returns a date constant (the trigger date) and the
REM command does not know the details of \fBtrig\fR's arguments.
.PP
Note that because \fBRemind\fR does not have short-circuit logical
Note that because \fBRemind\fR has short-circuit logical
operators, something like:
.PP
.nf
@@ -3838,58 +3996,9 @@ operators, something like:
.fi
would set the value of trig() to the date of the following
Thursday. Even though trig("Mon +7") always returns true,
the logical-OR operator still evaluates trig("Fri +7") which
\fIalso\fR returns true and sets \fBtrig()\fR.
.PP
You can work around the lack of a short-circuit logical-OR as follows:
If \fBtrig\fR returns a true value, the specific value it returns
can be coerced to a DATE which is the trigger date. So the following code:
.PP
.nf
SET a trig("Mon +4") || trig("Fri +4")
IF a
REM [a] +4 MSG [wkday($T)] %b.
ENDIF
.fi
.PP
would operate as follows:
.PP
.nf
On Monday: Monday today.
On Tuesday: Friday in 3 days' time.
On Wednesday: Friday in 2 days' time.
On Thursday: Monday in 4 days' time.
On Friday: Monday in 3 days' time.
On Saturday: Monday in 2 days' time.
On Sunday: Monday tomorrow.
.fi
.PP
Compare with the following:
.PP
.nf
SET a trig("Mon +4") || trig("Fri +4")
IF a
REM [trig()] +4 MSG [wkday($T)] %b.
ENDIF
.fi
.PP
which yields:
.PP
.nf
On Monday: Friday in 4 days' time.
On Tuesday: Friday in 3 days' time.
On Wednesday: Friday in 2 days' time.
On Thursday: Friday tomorrow.
On Friday: Friday today.
On Saturday: Monday in 2 days' time.
On Sunday: Monday tomorrow.
.fi
.PP
That is because \fBtrig()\fR returns the trigger date of
the \fIlast\fR trig function that returns true,
whereas the value of \fBa\fR is the trigger date of the \fIfirst\fR
trig function that returns true.
Monday. Because trig("Mon +7") always returns true,
the logical-OR operator does not bother evaluating trig("Fri +7") which
therefore does not set \fBtrig()\fR.
.PP
\fBImportant Note\fR: Because \fBtrig()\fR always returns an absolute
date, it will \fBnot\fR work properly with a \fBSATISFY\fR clause.
@@ -4229,6 +4338,14 @@ with square brackets. For example:
This evaluates the expression "mydate", where "mydate" is
presumably some pre-computed variable, and then "pastes" the result
into the command-line for the parser to process.
.PP
If you want a literal "[" character for some reason, simply use "[[". For
example:
.PP
.nf
REM MSG Here are [[square] brackets!
.fi
.PP
A formal description of this is: When \fBRemind\fR encounters a
"pasted-in" expression, it evaluates the expression, and coerces the
@@ -4465,11 +4582,10 @@ The above sequence sets y to 1, which is the global value of x.
.TP
o
User-defined functions may call other functions, including other user-defined
functions. However, recursive calls are not allowed.
.TP
o
User-defined functions are not syntax-checked when they are defined; parsing
occurs only when they are called.
functions. Recursive calls are allowed, but they must terminate (for
example, by using a short-circuit operator or function that breaks the
recursion) or an error will result after a certain maximum number of
recursive calls (by default, 1000.)
.TP
o
If a user-defined function has the same name as a built-in function,
@@ -4491,6 +4607,11 @@ or thirdfunc will exist. \fBRemind\fR does not issue an error if you
try to \fBFUNSET\fR a nonexistent user-defined function; it simply
does nothing in that case.
.PP
If you define a user-defined function and then later on redefine it,
\fBRemind\fR will issue a warning. If you do not want this warning,
then use \fBFUNSET\fR to remove the existing definition before you
redefine the function.
.PP
.SH PRECISE SCHEDULING
.PP
The \fBWARN\fR keyword allows precise control over advance warning in
@@ -4624,8 +4745,11 @@ the error message "Can't compute trigger" is issued. Otherwise,
\fBtrigvalid()\fR is set to 1.
.PP
This is really useful only if \fIexpr\fR involves a call to the
\fBtrigdate()\fR or related functions; otherwise, \fIexpr\fR will not change as
\fBRemind\fR iterates.
\fBtrigdate()\fR or related functions or system variables; otherwise,
\fIexpr\fR will not change as \fBRemind\fR iterates. In fact, if
\fIexpr\fR is not a constant and does not call \fBtrigdate()\fR or
related functions or system variables, then \fBRemind\fR will issue a
warning.
.PP
An example of the usefulness of \fBSATISFY\fR: Suppose you wish to
be warned of every Friday the 13th. Your first attempt may be:
@@ -4776,7 +4900,7 @@ under program control. The format is:
.PP
\fBDEBUG\fR [+\fIflagson\fR] [\-\fIflagsoff\fR]
.PP
\fIFlagson\fR and \fIflagsoff\fR consist of strings of the characters "extvlf"
\fIFlagson\fR and \fIflagsoff\fR consist of strings of the characters "extvlfs"
that correspond to the debugging options discussed in the command-line
options section. If preceded with a "+", the corresponding group of
debugging options is switched on. Otherwise, they are switched off.
@@ -5080,21 +5204,25 @@ structuring comments in your PostScript code.
.PP
.SH DAEMON MODE
.PP
If you use the \fB\-z\fR command-line option, \fBRemind\fR runs in the
"daemon" mode. In this mode, no "normal" reminders are issued.
If you use the \fB\-z\fR command-line option, \fBRemind\fR runs in
"daemon mode". In this mode, no "normal" reminders are issued.
Instead, only timed reminders are collected and queued, and are then
issued whenever they reach their trigger time.
.PP
In addition, \fBRemind\fR wakes up every few minutes to check the modification
date on the reminder script (the filename supplied on the command line.)
If \fBRemind\fR detects that the script has changed, it re-executes itself
in daemon mode, and interprets the changed script.
In addition, \fBRemind\fR wakes up every few minutes to check the
modification date on the reminder script (the filename supplied on the
command line.) If \fBRemind\fR detects that the script has changed,
it re-executes itself in daemon mode, and interprets the changed
script. If \fBRemind\fR was compiled with support for
\fBinotify\fR(7), then if the command-line reminder script is really a
directory, \fBRemind\fR also re-executes itself if any of the files in
the directory is changed.
.PP
In daemon mode, \fBRemind\fR also re-reads the remind script when it
detects that the system date has changed.
.PP
In daemon mode, \fBRemind\fR acts as if the \fB\-f\fR option had been used,
so to run in the daemon mode in the background, use:
so to run in daemon mode in the background, use:
.PP
.nf
remind \-z .reminders &
@@ -5752,10 +5880,6 @@ after the WEEK keyword.
The following tokens can be abbreviated:
.TP
o
\fBREM\fR can be omitted - it is implied if no other valid command
is present.
.TP
o
\fBCLEAR-OMIT-CONTEXT\fR --> \fBCLEAR\fR
.TP
o

View File

@@ -224,6 +224,14 @@ If this is selected, pop-up reminder boxes will be closed after one minute
has elapsed. Otherwise, they remain on your screen forever until you
explicitly dismiss them.
.TP
.B Use system notifications when issuing a reminder
This option is available only for Tcl/Tk version 9.0 or later, or if
you have the \fBnotify-send\fR program installed; it will be greyed
out if neither condition is true. If selected, then when a reminder
is popped up, it will also be sent to the desktop notification system,
causing a notification to appear.
.TP
.B Beep terminal when popping up a reminder
If selected, \fBTkRemind\fR beeps the terminal bell when a queued reminder
@@ -266,7 +274,7 @@ Useful strings might be "emacs +%d %s" or "gvim +%d %s"
.TP
.B Extra Argument for Remind
This specifies any extra arguments that should be passed to Remind
when \BTkRemind\fR invokes \fBremind\fR. Unless you know what
when \fBTkRemind\fR invokes \fBremind\fR. Unless you know what
you are doing, leave this blank.
.TP

View File

@@ -15,7 +15,7 @@ install:
@if test "$(PERL)" = "" ; then \
echo "Not installing rem2html; Perl is required"; exit 0; fi; \
for m in $(PERLMODS_NEEDED) ; \
do \
do \
$(PERL) -M$$m -e 1 > /dev/null 2>&1; \
if test $$? != 0 ; then echo "Not installing rem2html; missing $$m"; exit 0; fi; \
done; \

View File

@@ -26,12 +26,12 @@ rem2html - Convert the output of "remind -pp" to HTML
=head1 SYNOPSIS
remind -pp ... | rem2html [options]
remind -pp [remind_options] file | rem2html [options]
You can also use the old interchange format as below, but the -pp
version is preferred.
remind -p ... | rem2html [options]
remind -p [remind_options] file | rem2html [options]
=head1 OPTIONS
@@ -155,7 +155,7 @@ sub usage
print STDERR <<"EOM";
$TIDY_PROGNAME: Produce an HTML calendar from the output of "remind -pp"
Usage: remind -pp ... | rem2html [options]
Usage: remind -pp [remind_options] file | rem2html [options]
Options:
@@ -374,19 +374,37 @@ sub parse_input
($1 % 256), ($1 % 256), ($1 % 256));
}
} elsif ($special eq 'COLOR' || $special eq 'COLOUR') {
if ($body =~ /(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/) {
if ($body =~ /(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/s) {
my($r, $g, $b, $text) = ($1, $2, $3, $4);
my $color = sprintf("style=\"color: #%02X%02X%02X;\"",
$r % 256, $g % 256, $b % 256);
push(@{$days->[$d]}, "<p$class $color>" . escape_html($text) . '</p>');
push(@{$days->[$d]}, "<p$class $color>" . fix_whitespace(escape_html($text)) . '</p>');
}
} elsif ($special eq '*') {
push(@{$days->[$d]}, "<p$class>" . escape_html($body) . '</p>');
push(@{$days->[$d]}, "<p$class>" . fix_whitespace(escape_html($body)) . '</p>');
}
}
return $found_data;
}
sub fix_whitespace
{
my ($text) = @_;
# Collapse multiple spaces/tabs to a single space
$text =~ s/[ \t]+/ /gs;
# Remove whitespace before/after newlines
$text =~ s/\s+\n/\n/gs;
$text =~ s/\n\s+/\n/gs;
# Collapse multiple newlines to a single newline
$text =~ s/\n+/\n/gs;
# Convert newlines to <br />
$text =~ s|\n|<br />|g;
return $text;
}
sub small_calendar
{
my($month, $monlen, $url, $first_col) = @_;

View File

@@ -60,7 +60,9 @@ my $settings = {
margin_bottom => 36,
margin_left => 36,
margin_right => 36,
svg => 0,
ps => 0,
eps => 0,
verbose => 0,
};
@@ -80,6 +82,9 @@ Options:
--landscape, -l Print in landscape orientation
--small-calendars=N Choose location for small calendars
--svg Output SVG instead of PDF
--ps Output PostScript instead of PDF
--eps Output encapsulated PostScript instead of PDF
-cN Synonym for --small-calendars=N
--left-numbers, -x Print day numbers on the left
--fill-page, -e Fill the entire page
@@ -112,6 +117,9 @@ Getopt::Long::Configure('bundling_values');
my $ret = GetOptions('landscape|l' => \$settings->{landscape},
'small-calendars|c=i' => \$settings->{small_calendars},
'left-numbers|x' => \$settings->{numbers_on_left},
'svg' => \$settings->{svg},
'ps' => \$settings->{ps},
'eps' => \$settings->{eps},
'fill-page|e' => \$settings->{fill_entire_page},
'media|m=s' => \$settings->{media},
'width|w=i' => \$settings->{width},
@@ -176,6 +184,17 @@ if ($settings->{landscape}) {
$settings->{height} = $tmp;
}
if ($settings->{svg} && $settings->{ps} ||
$settings->{svg} && $settings->{eps} ||
$settings->{eps} && $settings->{ps}) {
print STDERR "Only one of --eps, --ps or --svg may be used.\n";
exit(1);
}
if ($settings->{eps}) {
$settings->{ps} = 1;
}
# Don't read from a terminal
if (-t STDIN) { ## no critic
print STDERR "I can't read data from a terminal. Please run like this:\n";
@@ -187,8 +206,25 @@ my $done_one = 0;
my $errored_out = 0;
my $surface = Cairo::PdfSurface->create_for_stream(sub { print $_[1] unless $errored_out; }, undef,
$settings->{width}, $settings->{height});
my $surface;
if ($settings->{svg}) {
$surface = Cairo::SvgSurface->create_for_stream(sub { print $_[1] unless $errored_out; }, undef,
$settings->{width}, $settings->{height});
} elsif ($settings->{ps}) {
if ($settings->{landscape}) {
$surface = Cairo::PsSurface->create_for_stream(sub { print $_[1] unless $errored_out; }, undef,
$settings->{height}, $settings->{width});
} else {
$surface = Cairo::PsSurface->create_for_stream(sub { print $_[1] unless $errored_out; }, undef,
$settings->{width}, $settings->{height});
}
if ($settings->{eps}) {
$surface->set_eps(1);
}
} else {
$surface = Cairo::PdfSurface->create_for_stream(sub { print $_[1] unless $errored_out; }, undef,
$settings->{width}, $settings->{height});
}
# set_metadata not available in older versions of Cairo
eval { $surface->set_metadata('title', 'Calendar'); };
@@ -196,10 +232,26 @@ eval { $surface->set_metadata('author', 'Remind (https://dianne.skoll.ca/project
eval { $surface->set_metadata('creator', 'rem2pdf (https://dianne.skoll.ca/projects/remind/)'); };
eval { $surface->set_metadata('subject', 'Calendar'); };
if ($settings->{ps}) {
$surface->dsc_comment('%%Title: Calendar');
$surface->dsc_comment('%%Producer: rem2pdf (https://dianne.skoll.ca/projects/remind/)');
$surface->dsc_comment('%%PageOrientation: ' . (($settings->{landscape}) ? 'Landscape' : 'Portrait'));
$surface->dsc_begin_setup();
}
my $cr = Cairo::Context->create($surface);
$cr->set_line_width($settings->{line_thickness});
if ($settings->{ps} && $settings->{landscape}) {
$cr->translate(0, $settings->{width});
$cr->rotate(-1.5707963267949); # Rotate -90 degrees
}
my $warned = 0;
while(1) {
if ($settings->{ps}) {
$surface->dsc_begin_page_setup();
$surface->dsc_comment('%%PageOrientation: ' . (($settings->{landscape}) ? 'Landscape' : 'Portrait'));
}
my ($obj, $err) = Remind::PDF->create_from_stream(*STDIN,
{color => 1,
shade => 1,
@@ -215,8 +267,15 @@ while(1) {
}
last;
}
$done_one = 1;
if (($settings->{eps} || $settings->{svg}) && $done_one) {
if (!$warned) {
print STDERR "WARNING: --eps and --svg can only output one page; ignoring subsequent\nmonths in a multi-month calendar.\n";
$warned = 1;
}
next;
}
$obj->render($cr, $settings);
$done_one = 1;
}
$surface->finish();
@@ -273,17 +332,22 @@ __END__
=head1 NAME
rem2pdf - draw a PDF calendar from Remind output
rem2pdf - draw a PDF, SVG or PostScript calendar from Remind output
=head1 SYNOPSIS
remind -pp [options] file | rem2pdf [options] > output.pdf
remind -pp [remind_options] file | rem2pdf [options] > output.pdf
remind -pp [remind_options] file | rem2pdf --svg [options] > output.svg
remind -pp [remind_options] file | rem2pdf --ps [options] > output.ps
remind -pp [remind_options] file | rem2pdf --eps [options] > output.eps
=head1 DESCRIPTION
B<rem2pdf> reads the standard input, which should be the results of
running B<remind> with the B<-p>, B<-pp> or B<-ppp> options. It emits
PDF code that draws a calendar to standard output.
PDF, SVG or PostScript code that draws a calendar to standard output. (The
addition of support for SVG and PostScript means that rem2pdf is increasingly
misnamed...)
B<rem2pdf> uses the Pango text formatting library (L<https://pango.gnome.org/>)
and the Cairo graphics library (L<https://www.cairographics.org/>) to produce
@@ -298,6 +362,22 @@ output at all.
=over
=item --ps
Output PostScript instead of PDF.
=item --eps
Output Encapsulated PostScript instead of PDF. In this case, you
should feed C<rem2pdf> only one month's worth of calendar data,
because it cannot create a multi-page encapsulated PostScript file.
=item --svg
Output SVG instead of PDF. In this case, you should feed C<rem2pdf>
only one month's worth of calendar data, because it cannot create
a multi-page SVG file.
=item --landscape, -l
Print the calendar in landscape orientation. Essentially, this swaps
@@ -486,7 +566,7 @@ output for the invalid reminder.
=head1 ABSOLUTELY-POSITIONED TEXT
If your B<PANGO> special reminder starts with C<@I<x>,I<y>> where I<x>
and I<y> are floating-point numbers, then the Pango marked-up test is
and I<y> are floating-point numbers, then the Pango marked-up text is
positioned absolutely with respect to the day's box (and is not
counted when calculating the box's height.)

View File

@@ -1008,7 +1008,17 @@ as were read from the C<remind -ppp> stream
sub render
{
my ($self, $cr, $settings) = @_;
my $done = 0;
my $warned = 0;
foreach my $e (@{$self->{entries}}) {
if ($settings->{svg} && $done) {
if (!$warned) {
print STDERR "WARNING: --svg can only output one page; ignoring subsequent\nmonths in a multi-month calendar.\n";
$warned = 1;
}
next;
}
$done = 1;
$e->render($cr, $settings);
}
}

View File

@@ -85,6 +85,18 @@ sub render
} else {
$body = $self->{body};
}
# Clean up the body:
# Collapse multiple spaces/tabs to a single space
$body =~ s/[ \t]+/ /gs;
# Remove whitespace before/after newlines
$body =~ s/\s+\n/\n/gs;
$body =~ s/\n\s+/\n/gs;
# Collapse multiple newlines to a single newline
$body =~ s/\n+/\n/gs;
$layout->set_text(Encode::decode('UTF-8', $body));
my $desc = Pango::FontDescription->from_string($settings->{entry_font} . ' ' . $settings->{entry_size} . 'px');
$layout->set_font_description($desc);

124
scripts/tkremind → scripts/tkremind.in Executable file → Normal file
View File

@@ -15,8 +15,10 @@
# the next line restarts using wish \
exec wish "$0" "$@"
tk appname tkremind
# We need at least version 8.5 because of {*} list expansion operator
if {[catch {package require Tcl 8.5}]} {
if {[catch {package require Tcl 8.5-}]} {
puts stderr "This program requires Tcl 8.5 or higher."
puts stderr "You have version [info tclversion]"
exit 1
@@ -24,7 +26,33 @@ if {[catch {package require Tcl 8.5}]} {
wm withdraw .
set Hostname [exec hostname]
catch {
set Hostname [exec hostname]
}
global env
set HOME $env(HOME)
# Check if we have "tk sysnotify"
set HAVE_SYSNOTIFY 0
set NOTIFY_SEND_PATH ""
catch { tk sysnotify } err opt
if { [dict get $opt -errorcode] == "TCL WRONGARGS" } {
set HAVE_SYSNOTIFY 1
} else {
set path [split $env(PATH) :]
foreach d $path {
if { [file executable [file join $d "notify-send"]] } {
set NOTIFY_SEND_PATH [file join $d "notify-send"]
break
}
}
}
proc home { f } {
global HOME
return [string cat $HOME $f]
}
# Our icon photo
catch {
@@ -166,6 +194,9 @@ set OptDescr(Deiconify) "(0/1) If 1, TkRemind deiconifies the calendar window wh
set Option(ShowTodaysReminders) 1
set OptDescr(ShowTodaysReminders) "(0/1) If 1, TkRemind shows all of today's non-timed reminders in a window at startup and when the date changes"
set Option(SysNotify) 0
set OptDescr(SysNotify) "(0/1) If 1, TkRemind uses the system notification mechanism when a reminder pops up (Tcl 9.0 or newer)"
set Option(RunCmd) ""
set OptDescr(RunCmd) "(String) If non-blank, run specified command when a pop-up reminder appears"
set Option(FeedReminder) 0
@@ -231,8 +262,7 @@ if {[string match "rem2pdf:*" "$a"]} {
}
# Reminder file to source -- default
set ReminderFile {NOSUCHFILE}
set ReminderFile [file nativename "~/.reminders"]
set ReminderFile [file nativename [home "/.reminders"]]
# Default options file
set ConfigFile ""
@@ -243,8 +273,7 @@ set EditorPid -1
set RemindErrors ""
# Reminder file to append to -- default
set AppendFile {NOSUCHFILE}
catch {set AppendFile $ReminderFile}
set AppendFile $ReminderFile
# Array of tags -> JSON dicts
array unset TagToObj
@@ -319,7 +348,7 @@ set Option(PrintMargins) 36pt
set OptDescr(PrintSmallCalendars) "(0/1) If 1, print small calendars in PostScript output"
set Option(PrintSmallCalendars) 1
set OptDescr(PrintFormat) "Print format: pdf or ps"
set OptDescr(PrintFormat) "Print format: pdf, ps or ps1 - ps1 means PostScript using rem2pdf"
set Option(PrintFormat) ps
set WarningHeaders [list "# Lines starting with REM TAG TKTAGnnn ... were created by tkremind" "# Do not edit them by hand or results may be unpredictable."]
@@ -400,8 +429,8 @@ proc Initialize {} {
set TodayYear [clock format $now -format %Y]
set TodayDay [string trim [clock format $now -format %e]]
set CommandLine "$Remind -itkremind=1 -pp -y -l @EXTRA@"
set PSCmd "$Remind -itkremind=1 -itkprint=1 -pp -l @EXTRA@"
set CommandLine "$Remind -itkremind=1 -pp -y -l %EXTRA%"
set PSCmd "$Remind -itkremind=1 -itkprint=1 -pp -l %EXTRA%"
set i 0
while {$i < $argc} {
if {[regexp -- {-[bgxim].*} [lindex $argv $i]]} {
@@ -478,7 +507,7 @@ proc Initialize {} {
append PSCmd " "
append PSCmd [posix_escape $ReminderFile]
set CommandLine "|/bin/sh -c \"$CommandLine @MONTH@ @YEAR@\""
set CommandLine "|/bin/sh -c \"$CommandLine %MONTH% %YEAR%\""
}
#***********************************************************************
@@ -734,7 +763,7 @@ proc CreateCalWindow { dayNames } {
# Lets user edit options
#***********************************************************************
proc EditOptions {} {
global Option tmpOpt
global Option tmpOpt HAVE_SYSNOTIFY NOTIFY_SEND_PATH ver
# Make a working copy of current option set
foreach name [array names Option] {
@@ -751,6 +780,8 @@ proc EditOptions {} {
pack $w.f -side top -expand 1 -fill both
pack $w.b -side top -expand 0 -fill x
label $w.ver -text "TkRemind version @VERSION@ on Tcl/Tk version [info tclversion] with Remind version $ver"
pack $w.ver -in $w.f -side top -expand 0 -fill x
# Start iconified
checkbutton $w.startIconified -text "Start up Iconified" \
-anchor w -justify left \
@@ -770,6 +801,16 @@ proc EditOptions {} {
-text "Automatically close pop-up reminders after a minute" \
-anchor w -justify left -variable tmpOpt(AutoClose)
checkbutton $w.sysNotify \
-text "Use system notifications when issuing a reminder" \
-anchor w -justify left -variable tmpOpt(SysNotify)
if { ! $HAVE_SYSNOTIFY } {
if { "$NOTIFY_SEND_PATH" == "" } {
$w.sysNotify configure -state disabled -takefocus 0
}
}
# Ring bell when popping up reminder
checkbutton $w.ring -text "Beep terminal when popping up a reminder" \
-anchor w -justify left -variable tmpOpt(RingBell)
@@ -873,6 +914,7 @@ proc EditOptions {} {
pack $w.showTodays -in $w.f -side top -expand 0 -fill x
pack $w.confirmQuit -in $w.f -side top -expand 0 -fill x
pack $w.bringDown -in $w.f -side top -expand 0 -fill x
pack $w.sysNotify -in $w.f -side top -expand 0 -fill x
pack $w.ring -in $w.f -side top -expand 0 -fill x
pack $w.deic -in $w.f -side top -expand 0 -fill x
pack $w.ancFrame -in $w.f -side top -expand 0 -fill x
@@ -1063,7 +1105,11 @@ proc LoadOptions {} {
proc ConfigureCalWindow { month year firstDay numDays } {
global Hostname
.h.title configure -text "$month $year"
wm title . "$month $year - TkRemind on $Hostname"
if {[info exists Hostname]} {
wm title . "$month $year - TkRemind @VERSION@ on $Hostname"
} else {
wm title . "$month $year - TkRemind @VERSION@"
}
wm iconname . "$month $year"
ConfigureCalFrame .cal $firstDay $numDays
}
@@ -1082,9 +1128,9 @@ proc FillCalWindow {} {
set_button_to_queue
set month [lindex $MonthNames $CurMonth]
set cmd [regsub @EXTRA@ $CommandLine $Option(ExtraRemindArgs)]
set cmd [regsub @MONTH@ $cmd $month]
set cmd [regsub @YEAR@ $cmd $CurYear]
set cmd [regsub %EXTRA% $CommandLine $Option(ExtraRemindArgs)]
set cmd [regsub %MONTH% $cmd $month]
set cmd [regsub %YEAR% $cmd $CurYear]
set file [open $cmd r]
# Look for # rem2ps2 begin line
@@ -1217,6 +1263,13 @@ proc FillCalWindow {} {
continue
}
.cal.t$n configure -state normal
# Canonicalize spaces and newlines
set stuff [regsub -all {[ \t]+} $stuff " "]
set stuff [regsub -all {[ \t]+\n} $stuff "\n"]
set stuff [regsub -all {\n[ \t]} $stuff "\n"]
set stuff [regsub -all {\n+} $stuff "\n"]
if {[regexp {TKTAG([0-9]+)} $tag all tagno] && "$fntag" != "x"} {
.cal.t$n insert end [string trim $stuff] [list REM TAGGED "TKTAG$tagno" "date_$date" $extratags $fntag]
.cal.t$n tag bind "TKTAG$tagno" <Enter> "TaggedEnter .cal.t$n"
@@ -1333,7 +1386,8 @@ proc DoPrint {} {
frame .p.ff -relief sunken -bd 2
label .p.format -text "Output Format:"
radiobutton .p.pdf -text "PDF" -variable Option(PrintFormat) -value pdf
radiobutton .p.ps -text "PostScript" -variable Option(PrintFormat) -value ps
radiobutton .p.ps -text "PostScript (using rem2ps)" -variable Option(PrintFormat) -value ps
radiobutton .p.ps1 -text "PostScript (using rem2pdf)" -variable Option(PrintFormat) -value ps1
}
label .p.size -text "Paper Size:"
@@ -1350,7 +1404,7 @@ proc DoPrint {} {
radiobutton .p.portrait -text "Portrait" -variable Option(PrintOrient) -value portrait
checkbutton .p.fill -text "Fill page" -variable Option(PrintFill)
checkbutton .p.wrap -text "Use at most 5 rows (PDF only)" -variable Option(WrapCal)
checkbutton .p.wrap -text "Use at most 5 rows (rem2pdf only)" -variable Option(WrapCal)
checkbutton .p.right -text "Day numbers at top-right" -variable Option(PrintDaysRight)
checkbutton .p.encoding -text "ISO 8859-1 PostScript encoding" -variable Option(PrintEncoding)
checkbutton .p.calendars -text "Print small calendars" -variable Option(PrintSmallCalendars)
@@ -1374,7 +1428,7 @@ proc DoPrint {} {
pack .p.tofile .p.filename .p.browse -in .p.f11 -side left -fill none -expand 0 -anchor w
pack .p.tocmd .p.command -in .p.f12 -side left -fill none -expand 0 -anchor w
if { $HaveRem2PDF } {
pack .p.format .p.pdf .p.ps -in .p.ff -side top -fill none -expand 0 -anchor w
pack .p.format .p.pdf .p.ps .p.ps1 -in .p.ff -side top -fill none -expand 0 -anchor w
}
pack .p.size .p.letter .p.a4 -in .p.f2 -side top -fill none -expand 0 -anchor w
pack .p.margin .p.24pt .p.36pt .p.48pt -in .p.f2a -side top -anchor w -fill none -expand 0
@@ -1420,10 +1474,13 @@ proc DoPrint {} {
}
if {$HaveRem2PDF && $Option(PrintFormat) == "pdf"} {
set p [regsub @EXTRA@ $PSCmd "-itkpdf=1 $Option(ExtraRemindArgs)"]
set p [regsub %EXTRA% $PSCmd "-itkpdf=1 $Option(ExtraRemindArgs)"]
set cmd "$p 1 [lindex $MonthNames $CurMonth] $CurYear | $Rem2PDF"
} elseif {$HaveRem2PDF && $Option(PrintFormat) == "ps1"} {
set p [regsub %EXTRA% $PSCmd "-itkpdf=1 $Option(ExtraRemindArgs)"]
set cmd "$p 1 [lindex $MonthNames $CurMonth] $CurYear | $Rem2PDF --ps"
} else {
set p [regsub @EXTRA@ $PSCmd $Option(ExtraRemindArgs)]
set p [regsub %EXTRA% $PSCmd $Option(ExtraRemindArgs)]
set cmd "$p 1 [lindex $MonthNames $CurMonth] $CurYear | $Rem2PS"
set Option(PrintFormat) ps
}
@@ -1463,7 +1520,7 @@ proc DoPrint {} {
}
if {$Option(WrapCal)} {
if {$Option(PrintFormat) == "pdf"} {
if {$Option(PrintFormat) == "pdf" || $Option(PrintFormat) == "ps1"} {
append cmd " --wrap"
}
}
@@ -2857,7 +2914,7 @@ proc DaemonReadable { file } {
# Reads a background reminder from daemon and pops up window.
#---------------------------------------------------------------------------
proc IssueBackgroundReminder { body time now tag qid } {
global BgCounter Option Ignore DaemonFile
global BgCounter Option Ignore DaemonFile HAVE_SYSNOTIFY NOTIFY_SEND_PATH
if {$Option(Deiconify)} {
wm deiconify .
}
@@ -2917,6 +2974,15 @@ proc IssueBackgroundReminder { body time now tag qid } {
if {$Option(RingBell)} {
bell
}
if {$Option(SysNotify)} {
if {$HAVE_SYSNOTIFY} {
tk sysnotify "Reminder for $time" $body
} elseif {"$NOTIFY_SEND_PATH" != "" } {
catch {
exec $NOTIFY_SEND_PATH -a tkremind -i dialog-information "Reminder for $time" "$body"
}
}
}
if {$Option(RunCmd) != ""} {
if {$Option(FeedReminder)} {
FeedReminderToCommand $Option(RunCmd) "$time: $body"
@@ -4214,7 +4280,7 @@ proc FindConfigFile {} {
set confighome $env(XDG_CONFIG_HOME)
}
if {"$confighome" == ""} {
set confighome "~/.config"
set confighome [home "/.config"]
}
# If $confighome does not exist, attempt to
@@ -4225,15 +4291,15 @@ proc FindConfigFile {} {
if {[file isdirectory $confighome]} {
# Migrate .tkremindrc to $confighome/tkremindrc
if {[file exists "~/.tkremindrc"]} {
if {[file exists [home "/.tkremindrc"]]} {
if {![file exists "$confighome/tkreminderc"]} {
puts "Migrating ~/.tkremindrc to $confighome/tkremindrc"
if {[catch { file copy "~/.tkremindrc" "$confighome/tkremindrc"}]} {
if {[catch { file copy [home "/.tkremindrc"] "$confighome/tkremindrc"}]} {
puts "FAILED!\n"
set ConfigFile "~/.tkremindrc"
set ConfigFile [home "/.tkremindrc"]
return
}
catch { file delete "~/.tkremindrc" }
catch { file delete [home "/.tkremindrc"] }
}
set ConfigFile "$confighome/tkremindrc"
return
@@ -4241,7 +4307,7 @@ proc FindConfigFile {} {
set ConfigFile "$confighome/tkremindrc"
return
}
set ConfigFile "~/.tkremindrc"
set ConfigFile [home "/.tkremindrc"]
}
proc set_default_colors { w } {
@@ -4331,6 +4397,4 @@ proc DoneShowingErrors {} {
destroy .errors
}
# Rem2PS program to execute -- supply full path if you want
main

View File

@@ -30,7 +30,7 @@ REMINDSRCS= calendar.c dynbuf.c dorem.c dosubst.c expr.c files.c funcs.c \
globals.c hbcal.c init.c main.c md5.c moon.c omit.c queue.c \
sort.c token.c trigger.c userfns.c utils.c var.c
REMINDHDRS=config.h custom.h dynbuf.h err.h expr.h globals.h lang.h \
REMINDHDRS=config.h custom.h dynbuf.h err.h globals.h lang.h \
md5.h protos.h rem2ps.h types.h version.h
REMINDOBJS= $(REMINDSRCS:.c=.o)
@@ -63,15 +63,16 @@ install: all
done
-mkdir -p $(DESTDIR)$(datarootdir)/remind || true
cp -R ../include/* $(DESTDIR)$(datarootdir)/remind
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; \
xdg-desktop-menu install --novendor $(DESTDIR)$(prefix)/share/applications/tkremind.desktop < /dev/null > /dev/null 2>&1 ; \
fi
xdg-icon-resource install --novendor --size 64 $(DESTDIR)$(prefix)/share/pixmaps/tkremind.png < /dev/null > /dev/null 2>&1 || true; \
xdg-desktop-menu install --novendor $(DESTDIR)$(prefix)/share/applications/tkremind.desktop < /dev/null > /dev/null 2>&1 || true; \
fi
install-stripped: install
strip $(DESTDIR)$(bindir)/remind || true

View File

@@ -35,7 +35,6 @@
#include "lang.h"
#include "types.h"
#include "protos.h"
#include "expr.h"
#include "globals.h"
#include "err.h"
#include "md5.h"
@@ -282,6 +281,7 @@ static void ColorizeEntry(CalEntry const *e, int clamp);
static void SortCol (CalEntry **col);
static void DoCalendarOneWeek (int nleft);
static void DoCalendarOneMonth (void);
static void DoSimpleCalendarOneMonth (void);
static int WriteCalendarRow (void);
static void WriteWeekHeaderLine (void);
static void WritePostHeaderLine (void);
@@ -339,6 +339,7 @@ UnBackgroundize(int d)
printf("%s", Decolorize());
}
#ifdef REM_USE_WCHAR
static void
send_lrm(void)
{
@@ -353,6 +354,7 @@ send_lrm(void)
printf("\xE2\x80\x8E");
}
}
#endif
static char const *
despace(char const *s)
@@ -527,9 +529,9 @@ get_month_abbrev(char const *mon)
#endif
}
#ifdef REM_USE_WCHAR
static int make_wchar_versions(CalEntry *e)
{
#ifdef REM_USE_WCHAR
size_t len;
wchar_t *buf;
len = mbstowcs(NULL, e->text, 0);
@@ -543,10 +545,8 @@ static int make_wchar_versions(CalEntry *e)
e->wc_text = buf;
e->wc_pos = buf;
return 1;
#else
return 1;
#endif
}
#endif
static void gon(void)
{
@@ -759,13 +759,11 @@ SetMoonEntry(int dse, char const *moon)
if (sscanf(moon, "%d %*d %*d %27[^\x01]", &phase, msg) < 4) {
if (sscanf(moon, "%d", &phase) != 1) {
/* Malformed MOON special; ignore */
fprintf(stderr, "Oops 1\n");
return;
}
}
if (phase < 0 || phase > 3) {
/* Bad phase */
fprintf(stderr, "Oops 2\n");
return;
}
FromDSE(dse, &y, &m, &d);
@@ -903,13 +901,17 @@ static void DoCalendarOneWeek(int nleft)
if (UseVTColors) {
printf("\x1B[1m"); /* Bold */
}
Backgroundize(d);
PrintLeft(buf, ColSpaces-1, '*');
putchar(' ');
UnBackgroundize(d);
if (UseVTColors) {
printf("\x1B[0m"); /* Normal */
}
putchar(' ');
} else {
Backgroundize(d);
PrintLeft(buf, ColSpaces, ' ');
UnBackgroundize(d);
}
gon();
DRAW(tb);
@@ -966,21 +968,20 @@ static void DoCalendarOneWeek(int nleft)
/***************************************************************/
/* */
/* DoCalendarOneMonth */
/* DoSimpleCalendarOneMonth */
/* */
/* Produce a calendar for the current month. */
/* Produce a "simple" calendar for the current month. */
/* */
/* A simple calendar is produced if the -s or -p option */
/* was used. */
/* */
/***************************************************************/
static void DoCalendarOneMonth(void)
static void DoSimpleCalendarOneMonth(void)
{
int y, m, d, mm, yy, i, j;
InitMoonsAndShades();
if (!DoSimpleCalendar) WriteCalHeader();
DidADay = 0;
if (PsCal) {
FromDSE(DSEToday, &y, &m, &d);
if (PsCal == PSCAL_LEVEL1) {
@@ -1053,7 +1054,29 @@ static void DoCalendarOneMonth(void)
}
printf("]\n}");
}
if (!DoSimpleCalendar) WriteCalTrailer();
}
/***************************************************************/
/* */
/* DoCalendarOneMonth */
/* */
/* Produce a calendar for the current month. */
/* */
/***************************************************************/
static void DoCalendarOneMonth(void)
{
InitMoonsAndShades();
if (DoSimpleCalendar) {
DoSimpleCalendarOneMonth();
return;
}
WriteCalHeader();
while (WriteCalendarRow()) /* continue */;
WriteCalTrailer();
}
/***************************************************************/
@@ -1125,13 +1148,17 @@ static int WriteCalendarRow(void)
if (UseVTColors) {
printf("\x1B[1m"); /* Bold */
}
Backgroundize(d+i-wd);
PrintLeft(buf, ColSpaces-1, '*');
putchar(' ');
if (UseVTColors) {
printf("\x1B[0m"); /* Normal */
}
putchar(' ');
UnBackgroundize(d+i-wd);
} else {
Backgroundize(d+i-wd);
PrintLeft(buf, ColSpaces, ' ');
UnBackgroundize(d+i-wd);
}
}
gon();
@@ -1199,15 +1226,17 @@ static void PrintLeft(char const *s, int width, char pad)
{
#ifndef REM_USE_WCHAR
int len = strlen(s);
printf("%s", s);
while (len++ < width) putchar(pad);
int i;
for (i=0; i<len && i<width; i++) {
fputc(*(s+i), stdout);
}
while (i++ < width) putchar(pad);
#else
size_t len = mbstowcs(NULL, s, 0);
int i;
wchar_t static_buf[128];
wchar_t *buf;
wchar_t *ws;
int display_len;
if (!len) {
for (i=0; i<width; i++) {
@@ -1226,13 +1255,16 @@ static void PrintLeft(char const *s, int width, char pad)
}
}
(void) mbstowcs(buf, s, len+1);
display_len = wcswidth(buf, len+1);
ws = buf;
for (i=0; i<width;) {
i=0;
while (i<width) {
if (*ws) {
if (i + wcwidth(*ws) > width) {
break;
}
i += wcwidth(*ws);
PutWideChar(*ws++, NULL);
i+= wcwidth(*ws);
} else {
break;
}
@@ -1245,7 +1277,10 @@ static void PrintLeft(char const *s, int width, char pad)
/* Possibly send lrm control sequence */
send_lrm();
for (i=display_len; i<width; i++) fputc(pad, stdout);
while (i<width) {
fputc(pad, stdout);
i++;
}
if (buf != static_buf) free(buf);
#endif
@@ -1266,7 +1301,7 @@ static void PrintCentered(char const *s, int width, char *pad)
int i;
for (i=0; i<d; i++) fputs(pad, stdout);
for (i=0; i<width; i++) {
for (i=0; i<width-d; i++) {
if (*s) {
if (isspace(*s)) {
putchar(' ');
@@ -1310,13 +1345,14 @@ static void PrintCentered(char const *s, int width, char *pad)
if (d < 0) d = 0;
ws = buf;
for (i=0; i<d; i++) fputs(pad, stdout);
for (i=0; i<width; i++) {
i=0;
while (i+d < width) {
if (*ws) {
PutWideChar(*ws++, NULL);
if (wcwidth(*ws) == 0) {
/* Don't count this character... it's zero-width */
i--;
if (i+d + wcwidth(*ws) > width) {
break;
}
i += wcwidth(*ws);
PutWideChar(*ws++, NULL);
} else {
break;
}
@@ -1328,7 +1364,10 @@ static void PrintCentered(char const *s, int width, char *pad)
/* Possibly send lrm control sequence */
send_lrm();
for (i=d+display_len; i<width; i++) fputs(pad, stdout);
while (i+d<width) {
fputs(pad, stdout);
i++;
}
if (buf != static_buf) free(buf);
#endif
}
@@ -1415,7 +1454,7 @@ static int WriteOneColLine(int col)
/* Find the last space char within the column. */
width = 0;
while (width <= ColSpaces) {
if (!*ws) {
if (!*ws || *ws == '\n') {
wspace = ws;
break;
}
@@ -1521,7 +1560,7 @@ static int WriteOneColLine(int col)
/* Find the last space char within the column. */
while (s - e->pos <= ColSpaces) {
if (!*s) {space = s; break;}
if (!*s || *s == '\n') {space = s; break;}
if (isspace(*s)) space = s;
s++;
}
@@ -1670,6 +1709,7 @@ static void GenerateCalEntries(int col)
case T_Pop: r=PopOmitContext(&p); break;
case T_Push: r=PushOmitContext(&p); break;
case T_Preserve: r=DoPreserve(&p); break;
case T_Expr: r = DoExpr(&p); break;
case T_RemType: if (tok.val == RUN_TYPE) {
r=DoRun(&p);
break;
@@ -1683,7 +1723,12 @@ static void GenerateCalEntries(int col)
/* Note: Since the parser hasn't been used yet, we don't */
/* need to destroy it here. */
default: CreateParser(CurLine, &p);
default:
if (!SuppressImplicitRemWarnings) {
Wprint("Unrecognized command; interpreting as REM");
WarnedAboutImplicit = 1;
}
CreateParser(CurLine, &p);
r=DoCalRem(&p, col);
break;
}
@@ -1770,7 +1815,7 @@ static int DoCalRem(ParsePtr p, int col)
DBufInit(&raw_buf);
/* Parse the trigger date and time */
if ( (r=ParseRem(p, &trig, &tim, 1)) ) {
if ( (r=ParseRem(p, &trig, &tim)) ) {
FreeTrig(&trig);
return r;
}
@@ -2142,7 +2187,9 @@ static int DoCalRem(ParsePtr p, int col)
FreeTrig(&trig);
return E_NO_MEM;
}
#ifdef REM_USE_WCHAR
make_wchar_versions(e);
#endif
DBufInit(&(e->tags));
DBufPuts(&(e->tags), DBufValue(&(trig.tags)));
if (SynthesizeTags) {

View File

@@ -24,27 +24,46 @@ if (!$ARGV[0]) {
}
my $lang = $ARGV[0];
if (!exists($language_map->{$lang})) {
print STDERR "$lang is not a valid language.\n";
exit(1);
}
my $flag = $language_map->{$lang};
print STDERR "Testing for: $lang - $flag.\n";
my_sys("make clean > /dev/null 2>&1") && die("make clean failed");
my_sys("make -j6 all LANGDEF=-DLANG=$flag > /dev/null 2>&1") && die("make all failed");
my_sys("./remind -q -r ../tests/tstlang.rem 2022-03-23 11:44 > test-$lang-compiled.out 2>&1");
my_sys("make clean > /dev/null 2>&1") && die("make clean failed");
my_sys("make -j6 all > /dev/null 2>&1") && die("make all failed");
my_sys("./remind -q -r -ii=\\\"../include/lang/$lang.rem\\\" ../tests/tstlang.rem 2022-03-23 11:44 > test-$lang-runtime.out 2>&1");
my $rc = my_sys("cmp test-$lang-compiled.out test-$lang-runtime.out > /dev/null 2>&1");
if ($rc == 0) {
print STDERR "Congrats! Compiled and runtime language output matches for $lang.\n";
my $rc = 0;
if ($lang eq 'all') {
foreach my $l (sort(keys(%$language_map))) {
if (check($l)) {
$rc = 1;
}
}
} else {
print STDERR "Whoops. Compiled and runtime language output differs for $lang.\n"
$rc = check($lang);
}
exit($rc);
sub check
{
my ($lang) = @_;
if (!exists($language_map->{$lang})) {
print STDERR "$lang is not a valid language.\n";
return 1;
}
my $flag = $language_map->{$lang};
print STDERR "Testing for: $lang - $flag.\n";
my_sys("make clean > /dev/null 2>&1") && die("make clean failed");
my_sys("make -j18 all LANGDEF=-DLANG=$flag > /dev/null 2>&1") && die("make all failed");
my_sys("./remind -q -r ../tests/tstlang.rem 2022-03-23 11:44 > test-$lang-compiled.out 2>&1");
my_sys("make clean > /dev/null 2>&1") && die("make clean failed");
my_sys("make -j18 all > /dev/null 2>&1") && die("make all failed");
my_sys("./remind -q -r -ii=\\\"../include/lang/$lang.rem\\\" ../tests/tstlang.rem 2022-03-23 11:44 > test-$lang-runtime.out 2>&1");
my $rc = my_sys("cmp test-$lang-compiled.out test-$lang-runtime.out > /dev/null 2>&1");
if ($rc == 0) {
print STDERR "Congrats! Compiled and runtime language output matches for $lang.\n";
} else {
print STDERR "Whoops. Compiled and runtime language output differs for $lang.\n"
}
return $rc;
}
exit(0);
sub my_sys

View File

@@ -1,45 +1,119 @@
/* Define if utime(file, NULL) sets file's timestamp to the present. */
#undef HAVE_UTIME_NULL
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define if your <sys/time.h> declares struct tm. */
#undef TM_IN_SYS_TIME
/* Define if you have the <sys/types.h> header file. */
#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 */
#undef HAVE_GLOB_H
#undef HAVE_WCTYPE_H
#undef HAVE_LOCALE_H
#undef HAVE_INOTIFY_INIT1
#undef HAVE_LANGINFO_H
/* Configuration command used to build Remind */
#undef CONFIG_CMD
/* Define to 1 if you have the `glob' function. */
#undef HAVE_GLOB
#undef HAVE_SETENV
/* Define to 1 if you have the <glob.h> header file. */
#undef HAVE_GLOB_H
/* Define to 1 if you have the `initgroups' function. */
#undef HAVE_INITGROUPS
#undef HAVE_UNSETENV
/* Define to 1 if you have the `inotify_init1' function. */
#undef HAVE_INOTIFY_INIT1
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if you have the `mbstowcs' function. */
#undef HAVE_MBSTOWCS
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
/* Define to 1 if you have the `setlocale' function. */
#undef HAVE_SETLOCALE
/* The number of bytes in a unsigned int. */
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strncasecmp' function. */
#undef HAVE_STRNCASECMP
/* Define to 1 if you have the <sys/inotify.h> header file. */
#undef HAVE_SYS_INOTIFY_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `unsetenv' function. */
#undef HAVE_UNSETENV
/* Define to 1 if you have the <wctype.h> header file. */
#undef HAVE_WCTYPE_H
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `time_t', as computed by sizeof. */
#undef SIZEOF_TIME_T
/* The size of `unsigned int', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_INT
/* The number of bytes in a unsigned long. */
/* The size of `unsigned long', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG
#include "custom.h"
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
#include <custom.h>

View File

@@ -20,7 +20,7 @@
/* western hemisphere. */
/* */
/* The default values are initially set to the city hall in Ottawa, */
/* Ontario, Canada. */
/* Ontario, Canada. */
/*---------------------------------------------------------------------*/
#define DEFAULT_LATITUDE 45.420556
#define DEFAULT_LONGITUDE -75.689722
@@ -68,12 +68,6 @@
/**********************************************************************/
/**********************************************************************/
/*---------------------------------------------------------------------*/
/* WANT_SHELL_ESCAPING: Define this if you want special shell */
/* characters to be escaped with a backslash for the -k option. */
/*---------------------------------------------------------------------*/
#define WANT_SHELL_ESCAPING 1
/*---------------------------------------------------------------------*/
/* BASE: The base year for date calculation. NOTE! January 1 of the */
/* base year MUST be a Monday, else Remind will not work! */
@@ -109,16 +103,6 @@
/*---------------------------------------------------------------------*/
#define MAX_STR_LEN 65535
/*---------------------------------------------------------------------*/
/* OP_STACK_SIZE: The size of the operator stack for expr. parsing */
/*---------------------------------------------------------------------*/
#define OP_STACK_SIZE 100
/*---------------------------------------------------------------------*/
/* VAL_STACK_SIZE: The size of the operand stack for expr. parsing */
/*---------------------------------------------------------------------*/
#define VAL_STACK_SIZE 100
/*---------------------------------------------------------------------*/
/* INCLUDE_NEST: How many nested INCLUDES do we handle? */
/*---------------------------------------------------------------------*/
@@ -166,6 +150,10 @@
#define PASSTHRU_LEN 32
#define MAX_RECURSION_LEVEL 1000
#define MAX_FUNC_ARGS 64
#define PSBEGIN "# rem2ps begin"
#define PSEND "# rem2ps end"

View File

@@ -20,7 +20,7 @@
/* western hemisphere. */
/* */
/* The default values are initially set to the city hall in Ottawa, */
/* Ontario, Canada. */
/* Ontario, Canada. */
/*---------------------------------------------------------------------*/
#define DEFAULT_LATITUDE 45.420556
#define DEFAULT_LONGITUDE -75.689722
@@ -68,12 +68,6 @@
/**********************************************************************/
/**********************************************************************/
/*---------------------------------------------------------------------*/
/* WANT_SHELL_ESCAPING: Define this if you want special shell */
/* characters to be escaped with a backslash for the -k option. */
/*---------------------------------------------------------------------*/
#define WANT_SHELL_ESCAPING 1
/*---------------------------------------------------------------------*/
/* BASE: The base year for date calculation. NOTE! January 1 of the */
/* base year MUST be a Monday, else Remind will not work! */
@@ -109,16 +103,6 @@
/*---------------------------------------------------------------------*/
#define MAX_STR_LEN 65535
/*---------------------------------------------------------------------*/
/* OP_STACK_SIZE: The size of the operator stack for expr. parsing */
/*---------------------------------------------------------------------*/
#define OP_STACK_SIZE 100
/*---------------------------------------------------------------------*/
/* VAL_STACK_SIZE: The size of the operand stack for expr. parsing */
/*---------------------------------------------------------------------*/
#define VAL_STACK_SIZE 100
/*---------------------------------------------------------------------*/
/* INCLUDE_NEST: How many nested INCLUDES do we handle? */
/*---------------------------------------------------------------------*/
@@ -166,6 +150,10 @@
#define PASSTHRU_LEN 32
#define MAX_RECURSION_LEVEL 1000
#define MAX_FUNC_ARGS 64
#define PSBEGIN "# rem2ps begin"
#define PSEND "# rem2ps end"

View File

@@ -23,9 +23,8 @@
#include "globals.h"
#include "err.h"
#include "protos.h"
#include "expr.h"
static int ParseTimeTrig (ParsePtr s, TimeTrig *tim, int save_in_globals);
static int ParseTimeTrig (ParsePtr s, TimeTrig *tim);
static int ParseLocalOmit (ParsePtr s, Trigger *t);
static int ParseScanFrom (ParsePtr s, Trigger *t, int type);
static int ParsePriority (ParsePtr s, Trigger *t);
@@ -33,6 +32,152 @@ static int ParseUntil (ParsePtr s, Trigger *t, int type);
static int ShouldTriggerBasedOnWarn (Trigger *t, int dse, int *err);
static int ComputeTrigDuration(TimeTrig *t);
static int
ensure_expr_references_first_local_arg(expr_node *node)
{
expr_node *other;
if (!node) {
return 0;
}
if (node->type == N_LOCAL_VAR && node->u.arg == 0) {
return 1;
}
if (ensure_expr_references_first_local_arg(node->child)) {
return 1;
}
other = node->sibling;
while (other) {
if (ensure_expr_references_first_local_arg(other)) {
return 1;
}
other = other->sibling;
}
return 0;
}
static void
check_trigger_function(char const *fname, char const *type)
{
UserFunc *f;
if (!*fname) {
return;
}
f = FindUserFunc(fname);
if (!f) {
if (strcmp(type, "WARN")) {
/* Undefined WARN functions are diagnosed elsewhere... */
Wprint("Undefined %s function: `%s'", type, fname);
}
return;
}
if (f->nargs != 1) {
Wprint("%s function `%s' defined at %s:%d should take 1 argument but actually takes %d", type, fname, f->filename, f->lineno, f->nargs);
return;
}
if (ensure_expr_references_first_local_arg(f->node)) {
return;
}
Wprint("%s function `%s' defined at %s:%d does not use its argument", type, fname, f->filename, f->lineno);
}
static void
ensure_satnode_mentions_trigdate_aux(expr_node *node, int *mentioned)
{
char const *name;
expr_node *other;
UserFunc *f;
if (!node) {
return;
}
if (*mentioned) {
return;
}
if (node->type == N_BUILTIN_FUNC) {
name = node->u.builtin_func->name;
if (!strcmp(name, "trigdate") ||
!strcmp(name, "trigdatetime")) {
*mentioned = 1;
return;
}
} else if (node->type == N_SHORT_SYSVAR || node->type == N_SYSVAR) {
if (node->type == N_SHORT_SYSVAR) {
name = node->u.name;
} else {
name = node->u.value.v.str;
}
if (!StrCmpi(name, "T") ||
!StrCmpi(name, "Td") ||
!StrCmpi(name, "Tm") ||
!StrCmpi(name, "Tw") ||
!StrCmpi(name, "Ty")) {
*mentioned = 1;
return;
}
} else if (node->type == N_SHORT_USER_FUNC || node->type == N_USER_FUNC) {
if (node->type == N_SHORT_USER_FUNC) {
name = node->u.name;
} else {
name = node->u.value.v.str;
}
f = FindUserFunc(name);
if (f && !f->recurse_flag) {
f->recurse_flag = 1;
ensure_satnode_mentions_trigdate_aux(f->node, mentioned);
f->recurse_flag = 0;
if (*mentioned) {
return;
}
}
}
ensure_satnode_mentions_trigdate_aux(node->child, mentioned);
if (*mentioned) {
return;
}
other = node->sibling;
while (other) {
ensure_satnode_mentions_trigdate_aux(other, mentioned);
if (*mentioned) {
return;
}
other = other->sibling;
}
}
static void ensure_satnode_mentions_trigdate(expr_node *node)
{
int mentioned = 0;
char const *str;
if (node->type == N_CONSTANT || node->type == N_SHORT_STR) {
if (node->type == N_CONSTANT) {
if (node->u.value.type == INT_TYPE) {
if (node->u.value.v.val == 0) {
Wprint("SATISFY: constant 0 will never be true");
}
return;
}
if (node->u.value.type != STR_TYPE) {
return;
}
str = node->u.value.v.str;
} else {
str = node->u.name;
}
if (!*str) {
Wprint("SATISFY: constant \"\" will never be true");
}
return;
}
ensure_satnode_mentions_trigdate_aux(node, &mentioned);
if (!mentioned) {
Wprint("SATISFY: expression has no reference to trigdate() or $T...");
}
}
static int
ComputeTrigDuration(TimeTrig *t)
{
@@ -63,7 +208,7 @@ int DoRem(ParsePtr p)
DBufInit(&buf);
/* Parse the trigger date and time */
if ( (r=ParseRem(p, &trig, &tim, 1)) ) {
if ( (r=ParseRem(p, &trig, &tim)) != OK ) {
FreeTrig(&trig);
return r;
}
@@ -163,6 +308,7 @@ int DoRem(ParsePtr p)
if (p->expr_happened) {
if (p->nonconst_expr) {
PurgeEchoLine("%s\n", "#!P: Next line may have expired, but contains non-constant expression");
PurgeEchoLine("%s\n", "#!P: or a relative SCANFROM clause");
PurgeEchoLine("%s\n", CurLine);
} else {
PurgeEchoLine("%s\n", "#!P: Next line has expired, but contains expression... please verify");
@@ -182,7 +328,7 @@ int DoRem(ParsePtr p)
if (dse == DSEToday &&
!(!IgnoreOnce &&
trig.once != NO_ONCE &&
FileAccessDate == DSEToday))
GetOnceDate() == DSEToday))
QueueReminder(p, &trig, &tim, trig.sched);
/* If we're in daemon mode, do nothing over here */
if (Daemon) {
@@ -220,7 +366,7 @@ int DoRem(ParsePtr p)
/* trigger structure. */
/* */
/***************************************************************/
int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim)
{
register int r;
DynamicBuffer buf;
@@ -262,10 +408,6 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
trig->need_wkday = 0;
trig->adj_for_last = 0;
if (save_in_globals) {
LastTriggerTime = NO_TIME;
}
int parsing = 1;
while(parsing) {
/* Read space-delimited string */
@@ -295,10 +437,17 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
break;
case T_Date:
DBufFree(&buf);
if (trig->d != NO_DAY) return E_DAY_TWICE;
if (trig->m != NO_MON) return E_MON_TWICE;
if (trig->y != NO_YR) return E_YR_TWICE;
DBufFree(&buf);
if (trig->d != NO_DAY) {
return E_DAY_TWICE;
}
if (trig->m != NO_MON) {
return E_MON_TWICE;
}
if (trig->y != NO_YR) {
return E_YR_TWICE;
}
FromDSE(tok.val, &y, &m, &d);
trig->y = y;
trig->m = m;
@@ -315,10 +464,6 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
trig->m = m;
trig->d = d;
tim->ttime = (tok.val % MINUTES_PER_DAY);
if (save_in_globals) {
LastTriggerTime = tim->ttime;
SaveLastTimeTrig(tim);
}
break;
case T_WkDay:
@@ -355,14 +500,14 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
DBufFree(&buf);
if (tim->ttime != NO_TIME) return E_TIME_TWICE;
tim->ttime = tok.val;
r = ParseTimeTrig(s, tim, save_in_globals);
r = ParseTimeTrig(s, tim);
if (r) return r;
trig->duration_days = ComputeTrigDuration(tim);
break;
case T_At:
DBufFree(&buf);
r=ParseTimeTrig(s, tim, save_in_globals);
r=ParseTimeTrig(s, tim);
if (r) return r;
trig->duration_days = ComputeTrigDuration(tim);
break;
@@ -404,6 +549,12 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
if (r) return r;
break;
case T_Number:
DBufFree(&buf);
Eprint("`%d' is not recognized as a year (%d-%d) or a day number (1-31)",
tok.val, BASE, BASE+YR_RANGE);
return E_PARSE_ERR;
case T_Year:
DBufFree(&buf);
if (trig->y != NO_YR) return E_YR_TWICE;
@@ -481,10 +632,10 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
r=ParseToken(s, &buf);
if (r) return r;
StrnCpy(trig->omitfunc, DBufValue(&buf), VAR_NAME_LEN);
strtolower(trig->omitfunc);
/* An OMITFUNC counts as a nonconst_expr! */
s->expr_happened = 1;
s->nonconst_expr = 1;
s->expr_happened = 1;
s->nonconst_expr = 1;
DBufFree(&buf);
break;
@@ -492,6 +643,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
r=ParseToken(s, &buf);
if(r) return r;
StrnCpy(trig->warn, DBufValue(&buf), VAR_NAME_LEN);
strtolower(trig->warn);
DBufFree(&buf);
break;
@@ -522,9 +674,6 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
} else {
tim->duration = NO_TIME;
}
if (save_in_globals) {
SaveLastTimeTrig(tim);
}
trig->duration_days = ComputeTrigDuration(tim);
break;
default:
@@ -536,6 +685,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
r=ParseToken(s, &buf);
if(r) return r;
StrnCpy(trig->sched, DBufValue(&buf), VAR_NAME_LEN);
strtolower(trig->sched);
DBufFree(&buf);
break;
@@ -545,10 +695,19 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
break;
default:
if (tok.type == T_Illegal && tok.val < 0) {
Eprint("%s: `%s'", ErrMsg[-tok.val], DBufValue(&buf));
DBufFree(&buf);
return -tok.val;
}
PushToken(DBufValue(&buf), s);
DBufFree(&buf);
trig->typ = MSG_TYPE;
if (s->isnested) return E_CANT_NEST_RTYPE;
if (!WarnedAboutImplicit && !SuppressImplicitRemWarnings) {
Wprint("Missing REM type; assuming MSG");
WarnedAboutImplicit = 1;
}
parsing = 0;
break;
}
@@ -600,6 +759,11 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
trig->scanfrom = DSEToday;
}
/* Check that any SCHED / WARN / OMITFUNC functions refer to
their arguments */
check_trigger_function(trig->sched, "SCHED");
check_trigger_function(trig->warn, "WARN");
check_trigger_function(trig->omitfunc, "OMITFUNC");
return OK;
}
@@ -608,7 +772,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
/* ParseTimeTrig - parse the AT part of a timed reminder */
/* */
/***************************************************************/
static int ParseTimeTrig(ParsePtr s, TimeTrig *tim, int save_in_globals)
static int ParseTimeTrig(ParsePtr s, TimeTrig *tim)
{
Token tok;
int r;
@@ -641,13 +805,13 @@ static int ParseTimeTrig(ParsePtr s, TimeTrig *tim, int save_in_globals)
break;
default:
if (tok.type == T_Illegal && tok.val < 0) {
Eprint("%s: `%s'", ErrMsg[-tok.val], DBufValue(&buf));
DBufFree(&buf);
return -tok.val;
}
if (tim->ttime == NO_TIME) return E_EXPECT_TIME;
/* Save trigger time in global variable */
if (save_in_globals) {
LastTriggerTime = tim->ttime;
SaveLastTimeTrig(tim);
}
PushToken(DBufValue(&buf), s);
DBufFree(&buf);
return OK;
@@ -763,6 +927,11 @@ static int ParseUntil(ParsePtr s, Trigger *t, int type)
break;
default:
if (tok.type == T_Illegal && tok.val < 0) {
Eprint("%s: `%s'", ErrMsg[-tok.val], DBufValue(&buf));
DBufFree(&buf);
return -tok.val;
}
if (y == NO_YR || m == NO_MON || d == NO_DAY) {
Eprint("%s: %s", which, ErrMsg[E_INCOMPLETE]);
DBufFree(&buf);
@@ -876,9 +1045,17 @@ static int ParseScanFrom(ParsePtr s, Trigger *t, int type)
tok.val = -tok.val;
}
FromDSE(DSEToday - tok.val, &y, &m, &d);
/* Don't purge reminders with a relative scanfrom */
s->expr_happened = 1;
s->nonconst_expr = 1;
break;
default:
if (tok.type == T_Illegal && tok.val < 0) {
Eprint("%s: `%s'", ErrMsg[-tok.val], DBufValue(&buf));
DBufFree(&buf);
return -tok.val;
}
if (y == NO_YR || m == NO_MON || d == NO_DAY) {
Eprint("%s: %s", word, ErrMsg[E_INCOMPLETE]);
DBufFree(&buf);
@@ -1202,7 +1379,7 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int dse, int *err)
*err = 0;
/* Handle the ONCE modifier in the reminder. */
if (!IgnoreOnce && t->once !=NO_ONCE && FileAccessDate == DSEToday)
if (!IgnoreOnce && t->once !=NO_ONCE && GetOnceDate() == DSEToday)
return 0;
if (dse < DSEToday) return 0;
@@ -1284,20 +1461,32 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p)
{
int iter, dse, r, start;
Value v;
char const *s;
char const *t;
expr_node *sat_node;
int nonconst = 0;
sat_node = ParseExpr(p, &r);
if (r != OK) {
return r;
}
if (!sat_node) {
return E_SWERR;
}
/* Diagnose if SAT_NODE does not reference trigdate */
ensure_satnode_mentions_trigdate(sat_node);
t = p->pos;
iter = 0;
start = trig->scanfrom;
while (iter++ < MaxSatIter) {
dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, 0);
if (r) {
free_expr_tree(sat_node);
if (r == E_CANT_TRIG) return OK; else return r;
}
if (dse != start && trig->duration_days) {
dse = ComputeTriggerNoAdjustDuration(start, trig, tt, &r, 1, trig->duration_days);
if (r) {
free_expr_tree(sat_node);
if (r == E_CANT_TRIG) return OK; else return r;
}
} else if (dse == start) {
@@ -1310,13 +1499,18 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p)
SaveAllTriggerInfo(trig, tt, dse, tt->ttime, 1);
}
if (dse == -1) {
free_expr_tree(sat_node);
return E_EXPIRED;
}
s = p->pos;
r = EvaluateExpr(p, &v);
t = p->pos;
if (r) return r;
if (v.type != INT_TYPE && v.type != STR_TYPE) return E_BAD_TYPE;
r = evaluate_expression(sat_node, NULL, &v, &nonconst);
if (r) {
free_expr_tree(sat_node);
return r;
}
if (v.type != INT_TYPE && v.type != STR_TYPE) {
free_expr_tree(sat_node);
return E_BAD_TYPE;
}
if ((v.type == INT_TYPE && v.v.val) ||
(v.type == STR_TYPE && *v.v.str)) {
AdjustTriggerForDuration(trig->scanfrom, dse, trig, tt, 1);
@@ -1341,17 +1535,17 @@ int DoSatRemind(Trigger *trig, TimeTrig *tt, ParsePtr p)
}
fprintf(ErrFp, "\n");
}
free_expr_tree(sat_node);
return OK;
}
p->pos = s;
if (dse+trig->duration_days < start) {
start++;
} else {
start = dse+trig->duration_days+1;
}
}
p->pos = t;
LastTrigValid = 0;
free_expr_tree(sat_node);
return E_CANT_TRIG;
}

View File

@@ -12,15 +12,13 @@
/***************************************************************/
#include "config.h"
#include "expr.h"
#define L_IN_DOSUBST
#include "types.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "types.h"
#include "globals.h"
#include "err.h"
#include "protos.h"
@@ -33,6 +31,19 @@
#define SHIP_OUT(s) if(DBufPuts(dbuf, s) != OK) return E_NO_MEM
static int
check_subst_args(UserFunc *f, int n)
{
if (!f) {
return 0;
}
if (f->nargs == n) {
return 1;
}
Wprint("Function `%s' defined at %s:%d should take %d argument%s, but actually takes %d",
f->name, f->filename, f->lineno, n, (n == 1 ? "" : "s"), f->nargs);
return 0;
}
/***************************************************************/
/* */
/* DoSubst */
@@ -69,6 +80,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
int altmode;
int r;
Value v;
UserFunc *func;
FromDSE(dse, &y, &m, &d);
@@ -102,7 +114,8 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
L_AMPM_OVERRIDE (pm, h)
#else
r = -1;
if (UserFuncExists("subst_ampm") == 1) {
func = FindUserFunc("subst_ampm");
if (func && check_subst_args(func, 1)) {
snprintf(s, sizeof(s), "subst_ampm(%d)", h);
expr = (char const *) s;
r = EvalExpr(&expr, &v, NULL);
@@ -131,7 +144,8 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
L_AMPM_OVERRIDE (cpm, ch)
#else
r = -1;
if (UserFuncExists("subst_ampm") == 1) {
func = FindUserFunc("subst_ampm");
if (func && check_subst_args(func, 1)) {
snprintf(s, sizeof(s), "subst_ampm(%d)", ch);
expr = (char const *) s;
r = EvalExpr(&expr, &v, NULL);
@@ -142,6 +156,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
} else {
r = -1;
}
DestroyValue(v);
} else {
Eprint("%s", ErrMsg[r]);
}
@@ -155,7 +170,8 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
#ifdef L_ORDINAL_OVERRIDE
L_ORDINAL_OVERRIDE;
#else
if (UserFuncExists("subst_ordinal") == 1) {
func = FindUserFunc("subst_ordinal");
if (func && check_subst_args(func, 1)) {
snprintf(s, sizeof(s), "subst_ordinal(%d)", d);
expr = (char const *) s;
r = EvalExpr(&expr, &v, NULL);
@@ -166,6 +182,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
} else {
r = -1;
}
DestroyValue(v);
} else {
Eprint("%s", ErrMsg[r]);
}
@@ -242,7 +259,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
break;
}
if (i < 64) {
*ss++ = c;
*ss++ = tolower(c);
*ss = 0;
i++;
}
@@ -250,7 +267,13 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
if (!c) {
Wprint("Warning: Unterminated %%{...} substitution sequence");
}
if (UserFuncExists(s) != 3) {
func = FindUserFunc(s);
if (!func) {
Wprint("No substition function `%s' defined", s);
continue;
}
if (!check_subst_args(func, 3)) {
continue;
}
snprintf(ss, sizeof(s) - (ss-s), "(%d,'%04d-%02d-%02d',%02d:%02d)",
@@ -269,10 +292,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
continue;
}
done = 0;
snprintf(uf, sizeof(uf), "subst_%c", c);
if (UserFuncExists(uf) == 3) {
snprintf(uf, sizeof(uf), "subst_%c", tolower(c));
func = FindUserFunc(uf);
if (func && check_subst_args(func, 3)) {
snprintf(s, sizeof(s), "subst_%c(%d,'%04d-%02d-%02d',%02d:%02d)",
c, altmode ? 1 : 0, y, m+1, d, h, min);
tolower(c), altmode ? 1 : 0, y, m+1, d, h, min);
expr = (char const *) s;
r = EvalExpr(&expr, &v, NULL);
if (r == OK) {
@@ -344,10 +368,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
if (!done) {
snprintf(uf, sizeof(uf), "subst_%cx", c);
if (UserFuncExists(uf) == 3) {
snprintf(uf, sizeof(uf), "subst_%cx", tolower(c));
func = FindUserFunc(uf);
if (func && check_subst_args(func, 3)) {
snprintf(s, sizeof(s), "subst_%cx(%d,'%04d-%02d-%02d',%02d:%02d)",
c, altmode ? 1 : 0, y, m+1, d, h, min);
tolower(c), altmode ? 1 : 0, y, m+1, d, h, min);
expr = (char const *) s;
r = EvalExpr(&expr, &v, NULL);
if (r == OK) {
@@ -797,7 +822,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse,
break;
case '_':
if (PsCal == PSCAL_LEVEL2 || PsCal == PSCAL_LEVEL3 || (mode != CAL_MODE && mode != ADVANCE_MODE && !(MsgCommand && *MsgCommand))) {
if (PsCal == PSCAL_LEVEL2 || PsCal == PSCAL_LEVEL3 || DoCalendar || (mode != CAL_MODE && mode != ADVANCE_MODE && !(MsgCommand && *MsgCommand))) {
snprintf(s, sizeof(s), "%s", NL);
} else {
snprintf(s, sizeof(s), " ");

View File

@@ -124,7 +124,9 @@ int DBufPuts(DynamicBuffer *dbuf, char const *str)
**********************************************************************/
void DBufFree(DynamicBuffer *dbuf)
{
if (dbuf->buffer != dbuf->staticBuf) free(dbuf->buffer);
if (dbuf->buffer != NULL && dbuf->buffer != dbuf->staticBuf) {
free(dbuf->buffer);
}
DBufInit(dbuf);
}
@@ -150,7 +152,6 @@ int DBufGets(DynamicBuffer *dbuf, FILE *fp)
/* Try reading the first few bytes right into the buffer --
we can usually save some unnecessary copying */
*(dbuf->buffer) = 0;
if (fgets(dbuf->buffer, dbuf->allocatedLen, fp) == NULL) {
return OK;
}

View File

@@ -15,7 +15,7 @@
#include <stdio.h> /* For FILE */
#define DBUF_STATIC_SIZE 128
#define DBUF_STATIC_SIZE 32
typedef struct {
char *buffer;
size_t len;

216
src/err.h
View File

@@ -122,6 +122,9 @@
#define E_TIME_TWICE 102
#define E_DURATION_NO_AT 103
#define E_EXPECTING_WEEKDAY 104
#define E_REPEATED_ARG 105
#define E_EXPR_DISABLED 106
#define E_TIME_EXCEEDED 107
#ifdef MK_GLOBALS
#undef EXTERN
@@ -140,111 +143,114 @@ EXTERN char *ErrMsg[]
#ifdef MK_GLOBALS
= {
"Ok",
"Missing ']'",
"Missing quote",
"Expression too complex - too many operators",
"Expression too complex - too many operands",
"Missing ')'",
"Undefined function",
"Illegal character",
"Expecting binary operator",
"Out of memory",
"Ill-formed number",
"Op stack underflow - internal error",
"Va stack underflow - internal error",
"Can't coerce",
"Type mismatch",
"Date overflow",
"Stack error - internal error",
"Division by zero",
"Undefined variable",
"Unexpected end of line",
"Unexpected end of file",
"I/O error",
"Line too long",
"Internal error",
"Bad date specification",
"Not enough arguments",
"Too many arguments",
"Ill-formed time",
"Number too high",
"Number too low",
"Can't open file",
"INCLUDE nested too deeply (max. " STR(INCLUDE_NEST) ")",
"Parse error",
"Can't compute trigger",
"Too many nested IFs",
"ELSE with no matching IF",
"ENDIF with no matching IF",
"Can't OMIT every weekday",
"Extraneous token(s) on line",
"POP-OMIT-CONTEXT without matching PUSH-OMIT-CONTEXT",
"RUN disabled",
"Domain error",
"Invalid identifier",
"Recursive function call detected",
"",
"Cannot modify system variable",
"C library function can't represent date/time",
"Attempt to redefine built-in function",
"Can't nest function definition in expression",
"Must fully specify date to use repeat factor",
"Year specified twice",
"Month specified twice",
"Day specified twice",
"Unknown token",
"Must specify month in OMIT command",
"Too many partial OMITs (max. " STR(MAX_PARTIAL_OMITS) ")",
"Too many full OMITs (max. " STR(MAX_FULL_OMITS) ")",
"Warning: PUSH-OMIT-CONTEXT without matching POP-OMIT-CONTEXT",
"Error reading",
"Expecting end-of-line",
"Invalid Hebrew date",
"IIF needs odd number of arguments",
"Warning: Missing ENDIF",
"Expecting comma",
"Weekday specified twice",
"Only use one of BEFORE, AFTER or SKIP",
"Can't nest MSG, MSF, RUN, etc. in expression",
"Repeat value specified twice",
"Delta value specified twice",
"Back value specified twice",
"ONCE keyword used twice. (Hah.)",
"Expecting time after AT",
"THROUGH/UNTIL keyword used twice",
"Incomplete date specification",
"FROM/SCANFROM keyword used twice",
"Variable",
"Value",
"*UNDEFINED*",
"Entering UserFN",
"Leaving UserFN",
"Expired",
"fork() failed - can't do queued reminders",
"Can't access file",
"Illegal system date: Year is less than %d\n",
"Unknown debug flag '%c'\n",
"Unknown option '%c'\n",
"Unknown user '%s'\n",
"Could not change gid to %d\n",
"Could not change uid to %d\n",
"Out of memory for environment\n",
"Missing '=' sign",
"Missing variable name",
"Missing expression",
"Can't reset access date of %s\n",
"Remind: '-i' option: %s\n",
"No reminders.",
"%d reminder(s) queued for later today.\n",
"Expecting number",
"Bad function in WARN clause",
"Can't convert between time zones",
"No files matching *.rem",
"String too long",
"Time specified twice",
"Cannot specify DURATION without specifying AT",
"Expecting weekday name"
/* OK */ "Ok",
/* E_MISS_END */ "Missing ']'",
/* E_MISS_QUOTE */ "Missing quote",
/* E_OP_STK_OVER */ "Expression too complex",
/* E_VA_STK_OVER */ "Expression too complex - too many operands",
/* E_MISS_RIGHT_PAREN */ "Missing ')'",
/* E_UNDEF_FUNC */ "Undefined function",
/* E_ILLEGAL_CHAR */ "Illegal character",
/* E_EXPECTING_BINOP */ "Expecting binary operator",
/* E_NO_MEM */ "Out of memory",
/* E_BAD_NUMBER */ "Ill-formed number",
/* E_OP_STK_UNDER */ "Op stack underflow - internal error",
/* E_VA_STK_UNDER */ "Va stack underflow - internal error",
/* E_CANT_COERCE */ "Can't coerce",
/* E_BAD_TYPE */ "Type mismatch",
/* E_DATE_OVER */ "Date overflow",
/* E_STACK_ERR */ "Stack error - internal error",
/* E_DIV_ZERO */ "Division by zero",
/* E_NOSUCH_VAR */ "Undefined variable",
/* E_EOLN */ "Unexpected end of line",
/* E_EOF */ "Unexpected end of file",
/* E_IO_ERR */ "I/O error",
/* E_LINE_2_LONG */ "Line too long",
/* E_SWERR */ "Internal error",
/* E_BAD_DATE */ "Bad date specification",
/* E_2FEW_ARGS */ "Not enough arguments",
/* E_2MANY_ARGS */ "Too many arguments",
/* E_BAD_TIME */ "Ill-formed time",
/* E_2HIGH */ "Number too high",
/* E_2LOW */ "Number too low",
/* E_CANT_OPEN */ "Can't open file",
/* E_NESTED_INCLUDE */ "INCLUDE nested too deeply (max. " STR(INCLUDE_NEST) ")",
/* E_PARSE_ERR */ "Parse error",
/* E_CANT_TRIG */ "Can't compute trigger",
/* E_NESTED_IF */ "Too many nested IFs",
/* E_ELSE_NO_IF */ "ELSE with no matching IF",
/* E_ENDIF_NO_IF */ "ENDIF with no matching IF",
/* E_2MANY_LOCALOMIT */ "Can't OMIT every weekday",
/* E_EXTRANEOUS_TOKEN */ "Extraneous token(s) on line",
/* E_POP_NO_PUSH */ "POP-OMIT-CONTEXT without matching PUSH-OMIT-CONTEXT",
/* E_RUN_DISABLED */ "RUN disabled",
/* E_DOMAIN_ERR */ "Domain error",
/* E_BAD_ID */ "Invalid identifier",
/* E_RECURSIVE */ "Too many recursive function calls",
/* E_PARSE_AS_REM */ "",
/* E_CANT_MODIFY */ "Cannot modify system variable",
/* E_MKTIME_PROBLEM */ "C library function can't represent date/time",
/* E_REDEF_FUNC */ "Attempt to redefine built-in function",
/* E_CANTNEST_FDEF */ "Can't nest function definition in expression",
/* E_REP_FULSPEC */ "Must fully specify date to use repeat factor",
/* E_YR_TWICE */ "Year specified twice",
/* E_MON_TWICE */ "Month specified twice",
/* E_DAY_TWICE */ "Day specified twice",
/* E_UNKNOWN_TOKEN */ "Unknown token",
/* E_SPEC_MON */ "Must specify month in OMIT command",
/* E_2MANY_PART */ "Too many partial OMITs (max. " STR(MAX_PARTIAL_OMITS) ")",
/* E_2MANY_FULL */ "Too many full OMITs (max. " STR(MAX_FULL_OMITS) ")",
/* E_PUSH_NOPOP */ "Warning: PUSH-OMIT-CONTEXT without matching POP-OMIT-CONTEXT",
/* E_ERR_READING */ "Error reading",
/* E_EXPECTING_EOL */ "Expecting end-of-line",
/* E_BAD_HEBDATE */ "Invalid Hebrew date",
/* E_IIF_ODD */ "iif(): odd number of arguments required",
/* E_MISS_ENDIF */ "Warning: Missing ENDIF",
/* E_EXPECT_COMMA */ "Expecting comma",
/* E_WD_TWICE */ "Weekday specified twice",
/* E_SKIP_ERR */ "Only use one of BEFORE, AFTER or SKIP",
/* E_CANT_NEST_RTYPE */ "Can't nest MSG, MSF, RUN, etc. in expression",
/* E_REP_TWICE */ "Repeat value specified twice",
/* E_DELTA_TWICE */ "Delta value specified twice",
/* E_BACK_TWICE */ "Back value specified twice",
/* E_ONCE_TWICE */ "ONCE keyword used twice. (Hah.)",
/* E_EXPECT_TIME */ "Expecting time after AT",
/* E_UNTIL_TWICE */ "THROUGH/UNTIL keyword used twice",
/* E_INCOMPLETE */ "Incomplete date specification",
/* E_SCAN_TWICE */ "FROM/SCANFROM keyword used twice",
/* E_VAR */ "Variable",
/* E_VAL */ "Value",
/* E_UNDEF */ "*UNDEFINED*",
/* E_ENTER_FUN */ "Entering UserFN",
/* E_LEAVE_FUN */ "Leaving UserFN",
/* E_EXPIRED */ "Expired",
/* E_CANTFORK */ "fork() failed - can't do queued reminders",
/* E_CANTACCESS */ "Can't access file",
/* M_BAD_SYS_DATE */ "Illegal system date: Year is less than %d\n",
/* M_BAD_DB_FLAG */ "Unknown debug flag '%c'\n",
/* M_BAD_OPTION */ "Unknown option '%c'\n",
/* M_BAD_USER */ "Unknown user '%s'\n",
/* M_NO_CHG_GID */ "Could not change gid to %d\n",
/* M_NO_CHG_UID */ "Could not change uid to %d\n",
/* M_NOMEM_ENV */ "Out of memory for environment\n",
/* E_MISS_EQ */ "Missing '=' sign",
/* E_MISS_VAR */ "Missing variable name",
/* E_MISS_EXPR */ "Missing expression",
/* M_CANTSET_ACCESS */ "Can't reset access date of %s\n",
/* M_I_OPTION */ "Remind: '-i' option: %s\n",
/* E_NOREMINDERS */ "No reminders.",
/* M_QUEUED */ "%d reminder(s) queued for later today.\n",
/* E_EXPECTING_NUMBER */ "Expecting number",
/* M_BAD_WARN_FUNC */ "Undefined WARN function",
/* E_CANT_CONVERT_TZ */ "Can't convert between time zones",
/* E_NO_MATCHING_REMS */ "No files matching *.rem",
/* E_STRING_TOO_LONG */ "String too long",
/* E_TIME_TWICE */ "Time specified twice",
/* E_DURATION_NO_AT */ "Cannot specify DURATION without specifying AT",
/* E_EXPECTING_WEEKDAY */ "Expecting weekday name",
/* E_REPEATED_ARG */ "Duplicate argument name",
/* E_EXPR_DISABLED */ "Expression evaluation is disabled",
/* E_TIME_EXCEEDED */ "Time limit for expression evaluation exceeded",
}
#endif /* MK_GLOBALS */
;

3747
src/expr.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,67 +0,0 @@
/***************************************************************/
/* */
/* EXPR.H */
/* */
/* Contains a few definitions used by expression evaluator. */
/* */
/* This file is part of REMIND. */
/* Copyright (C) 1992-2024 by Dianne Skoll */
/* SPDX-License-Identifier: GPL-2.0-only */
/* */
/***************************************************************/
/* Define the types of values */
#define ERR_TYPE 0
#define INT_TYPE 1
#define TIME_TYPE 2
#define DATE_TYPE 3
#define STR_TYPE 4
#define DATETIME_TYPE 5
#define SPECIAL_TYPE 6 /* Only for system variables */
#define CONST_INT_TYPE 7 /* Only for system variables */
/* Define stuff for parsing expressions */
#define BEG_OF_EXPR '['
#define END_OF_EXPR ']'
#define COMMA ','
#define UN_OP 0 /* Unary operator */
#define BIN_OP 1 /* Binary Operator */
#define FUNC 2 /* Function */
/* Make the pushing and popping of values and operators in-line code
for speed. BEWARE: These macros invoke return if an error happens ! */
#define PushOpStack(op) \
do { if (OpStackPtr >= OP_STACK_SIZE) return E_OP_STK_OVER; \
else { OpStack[OpStackPtr++] = (op); if (OpStackPtr > OpStackHiWater) OpStackHiWater = OpStackPtr; } } while(0)
#define PopOpStack(op) \
if (OpStackPtr <= 0) \
return E_OP_STK_UNDER; \
else \
(op) = OpStack[--OpStackPtr]
#define PushValStack(val) \
do { if (ValStackPtr >= VAL_STACK_SIZE) { \
DestroyValue(val); \
return E_VA_STK_OVER; \
} else { \
ValStack[ValStackPtr++] = (val); \
if (ValStackPtr > ValStackHiWater) ValStackHiWater = ValStackPtr; \
} } while (0);
#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);

View File

@@ -79,6 +79,7 @@ typedef struct {
int LineNo;
unsigned int IfFlags;
int NumIfs;
int IfLinenos[IF_NEST];
long offset;
CachedLine *CLine;
int ownedByMe;
@@ -101,13 +102,24 @@ static int CheckSafetyAux (struct stat *statbuf);
static int PopFile (void);
static int IncludeCmd(char const *);
void set_cloexec(int fd)
static void
got_a_fresh_line(void)
{
FreshLine = 1;
WarnedAboutImplicit = 0;
}
void set_cloexec(FILE *fp)
{
int flags;
flags = fcntl(fd, F_GETFD);
if (flags >= 0) {
flags |= FD_CLOEXEC;
fcntl(fd, F_SETFD, flags);
int fd;
if (fp) {
fd = fileno(fp);
flags = fcntl(fd, F_GETFD);
if (flags >= 0) {
flags |= FD_CLOEXEC;
fcntl(fd, F_SETFD, flags);
}
}
}
@@ -135,7 +147,7 @@ static void OpenPurgeFile(char const *fname, char const *mode)
if (!PurgeFP) {
fprintf(ErrFp, "Cannot open `%s' for writing: %s\n", DBufValue(&fname_buf), strerror(errno));
}
set_cloexec(fileno(PurgeFP));
set_cloexec(PurgeFP);
DBufFree(&fname_buf);
}
@@ -177,7 +189,7 @@ int ReadLine(void)
CurLine = CLine->text;
LineNo = CLine->LineNo;
CLine = CLine->next;
FreshLine = 1;
got_a_fresh_line();
clear_callstack();
if (DebugFlag & DB_ECHO_LINE) OutputLine(ErrFp);
return OK;
@@ -278,7 +290,7 @@ static int ReadLineFromFile(int use_pclose)
CurLine = DBufValue(&LineBuffer);
}
FreshLine = 1;
got_a_fresh_line();
clear_callstack();
if (DebugFlag & DB_ECHO_LINE) OutputLine(ErrFp);
return OK;
@@ -340,7 +352,7 @@ int OpenFile(char const *fname)
}
} else {
fp = fopen(fname, "r");
if (fp) set_cloexec(fileno(fp));
set_cloexec(fp);
if (DebugFlag & DB_TRACE_FILES) {
fprintf(ErrFp, "Reading `%s': Opening file on disk\n", fname);
}
@@ -360,7 +372,7 @@ int OpenFile(char const *fname)
if (strcmp(fname, "-")) {
fp = fopen(fname, "r");
if (!fp || !CheckSafety()) return E_CANT_OPEN;
set_cloexec(fileno(fp));
set_cloexec(fp);
if (PurgeMode) OpenPurgeFile(fname, "w");
} else {
fp = stdin;
@@ -522,8 +534,14 @@ static int NextChainedFile(IncludeStruct *i)
static int PopFile(void)
{
IncludeStruct *i;
int j;
if (!Hush && NumIfs) Eprint("%s", ErrMsg[E_MISS_ENDIF]);
if (!Hush && NumIfs) {
Eprint("%s", ErrMsg[E_MISS_ENDIF]);
for (j=NumIfs-1; j >=0; j--) {
fprintf(ErrFp, "%s(%d): IF without ENDIF\n", FileName, IfLinenos[j]);
}
}
if (!IStackPtr) return E_EOF;
i = &IStack[IStackPtr-1];
@@ -543,6 +561,7 @@ static int PopFile(void)
LineNo = i->LineNo;
IfFlags = i->IfFlags;
memcpy(IfLinenos, i->IfLinenos, IF_NEST);
NumIfs = i->NumIfs;
CLine = i->CLine;
fp = NULL;
@@ -557,7 +576,7 @@ static int PopFile(void)
if (strcmp(i->filename, "-")) {
fp = fopen(i->filename, "r");
if (!fp || !CheckSafety()) return E_CANT_OPEN;
set_cloexec(fileno(fp));
set_cloexec(fp);
if (PurgeMode) OpenPurgeFile(i->filename, "a");
} else {
fp = stdin;
@@ -837,7 +856,7 @@ static int IncludeCmd(char const *cmd)
char const *fname;
int old_flag;
FreshLine = 1;
got_a_fresh_line();
clear_callstack();
if (IStackPtr+1 >= INCLUDE_NEST) return E_NESTED_INCLUDE;
i = &IStack[IStackPtr];
@@ -867,6 +886,7 @@ static int IncludeCmd(char const *cmd)
i->LineNo = LineNo;
i->NumIfs = NumIfs;
i->IfFlags = IfFlags;
memcpy(i->IfLinenos, IfLinenos, IF_NEST);
i->CLine = CLine;
i->offset = -1L;
i->chain = NULL;
@@ -955,7 +975,7 @@ int IncludeFile(char const *fname)
int oldRunDisabled;
struct stat statbuf;
FreshLine = 1;
got_a_fresh_line();
clear_callstack();
if (IStackPtr+1 >= INCLUDE_NEST) return E_NESTED_INCLUDE;
i = &IStack[IStackPtr];
@@ -969,6 +989,7 @@ int IncludeFile(char const *fname)
i->LineNo = LineNo;
i->NumIfs = NumIfs;
i->IfFlags = IfFlags;
memcpy(i->IfLinenos, IfLinenos, IF_NEST);
i->CLine = CLine;
i->offset = -1L;
i->chain = NULL;

View File

@@ -23,6 +23,11 @@
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <ctype.h>
#include <math.h>
#include <sys/ioctl.h>
@@ -49,12 +54,16 @@
#include "globals.h"
#include "protos.h"
#include "err.h"
#include "expr.h"
/* Defines that used to be static variables */
#define Nargs (info->nargs)
#define RetVal (info->retval)
#define DBG(x) do { if (DebugFlag & DB_PRTEXPR) { x; } } while(0)
/* Debugging helpers for "choose()", "iif(), etc. */
#define PUT(x) DBufPuts(&DebugBuf, x)
#define OUT() do { fprintf(ErrFp, "%s\n", DBufValue(&DebugBuf)); DBufFree(&DebugBuf); } while(0)
static int
solstice_equinox_for_year(int y, int which);
@@ -69,7 +78,7 @@ static int FArgs (func_info *);
static int FAsc (func_info *);
static int FBaseyr (func_info *);
static int FChar (func_info *);
static int FChoose (func_info *);
static int FChoose (expr_node *, Value *, Value *, int *);
static int FCoerce (func_info *);
static int FColumns (func_info *);
static int FCurrent (func_info *);
@@ -96,9 +105,9 @@ static int FHebyear (func_info *);
static int FHour (func_info *);
static int FHtmlEscape (func_info *);
static int FHtmlStriptags (func_info *);
static int FIif (func_info *);
static int FIif (expr_node *, Value *, Value *, int *);
static int FIndex (func_info *);
static int FIsAny (func_info *);
static int FIsAny (expr_node *, Value *, Value *, int *);
static int FIsdst (func_info *);
static int FIsleap (func_info *);
static int FIsomitted (func_info *);
@@ -175,14 +184,9 @@ static int FWkday (func_info *);
static int FWkdaynum (func_info *);
static int FYear (func_info *);
static int CleanUpAfterFunc (func_info *);
static int CheckArgs (BuiltinFunc *f, int nargs);
static int SunStuff (int rise, double cosz, int dse);
static int tz_set_tz (char const *tz);
/* "Overload" the struct Operator definition */
#define NO_MAX 127
/* Caches for extracting months, days, years from dates - may
improve performance slightly. */
static int CacheDse = -1;
@@ -191,14 +195,9 @@ static int CacheYear, CacheMon, CacheDay;
static int CacheHebDse = -1;
static int CacheHebYear, CacheHebMon, CacheHebDay;
/* We need access to the value stack */
extern Value ValStack[];
extern int ValStackPtr;
extern int ValStackHiWater;
/* Macro for accessing arguments from the value stack - args are numbered
from 0 to (Nargs - 1) */
#define ARG(x) (ValStack[ValStackPtr - Nargs + (x)])
#define ARG(x) (info->args[x])
#define ARGV(x) ARG(x).v.val
#define ARGSTR(x) ARG(x).v.str
@@ -226,215 +225,127 @@ extern int ValStackHiWater;
/* The array holding the built-in functions. */
BuiltinFunc Func[] = {
/* Name minargs maxargs is_constant func */
/* Name minargs maxargs is_constant func newfunc*/
{ "abs", 1, 1, 1, FAbs },
{ "access", 2, 2, 0, FAccess },
{ "adawn", 0, 1, 0, FADawn},
{ "adusk", 0, 1, 0, FADusk},
{ "ampm", 1, 3, 1, FAmpm },
{ "ansicolor", 1, 5, 1, FAnsicolor },
{ "args", 1, 1, 0, FArgs },
{ "asc", 1, 1, 1, FAsc },
{ "baseyr", 0, 0, 1, FBaseyr },
{ "char", 1, NO_MAX, 1, FChar },
{ "choose", 2, NO_MAX, 1, FChoose },
{ "coerce", 2, 2, 1, FCoerce },
{ "columns", 0, 1, 0, FColumns },
{ "current", 0, 0, 0, FCurrent },
{ "date", 3, 3, 1, FDate },
{ "datepart", 1, 1, 1, FDatepart },
{ "datetime", 2, 5, 1, FDateTime },
{ "dawn", 0, 1, 0, FDawn},
{ "day", 1, 1, 1, FDay },
{ "daysinmon", 2, 2, 1, FDaysinmon },
{ "defined", 1, 1, 0, FDefined },
{ "dosubst", 1, 3, 0, FDosubst },
{ "dusk", 0, 1, 0, FDusk },
{ "easterdate", 0, 1, 0, FEasterdate },
{ "evaltrig", 1, 2, 0, FEvalTrig },
{ "filedate", 1, 1, 0, FFiledate },
{ "filedatetime", 1, 1, 0, FFiledatetime },
{ "filedir", 0, 0, 0, FFiledir },
{ "filename", 0, 0, 0, FFilename },
{ "getenv", 1, 1, 0, FGetenv },
{ "hebdate", 2, 5, 0, FHebdate },
{ "hebday", 1, 1, 0, FHebday },
{ "hebmon", 1, 1, 0, FHebmon },
{ "hebyear", 1, 1, 0, FHebyear },
{ "hour", 1, 1, 1, FHour },
{ "htmlescape", 1, 1, 1, FHtmlEscape },
{ "htmlstriptags",1, 1, 1, FHtmlStriptags },
{ "iif", 1, NO_MAX, 1, FIif },
{ "index", 2, 3, 1, FIndex },
{ "isany", 1, NO_MAX, 1, FIsAny },
{ "isdst", 0, 2, 0, FIsdst },
{ "isleap", 1, 1, 1, FIsleap },
{ "isomitted", 1, 1, 0, FIsomitted },
{ "language", 0, 0, 1, FLanguage },
{ "localtoutc", 1, 1, 1, FLocalToUTC },
{ "lower", 1, 1, 1, FLower },
{ "max", 1, NO_MAX, 1, FMax },
{ "min", 1, NO_MAX, 1, FMin },
{ "minsfromutc", 0, 2, 0, FMinsfromutc },
{ "minute", 1, 1, 1, FMinute },
{ "mon", 1, 1, 1, FMon },
{ "monnum", 1, 1, 1, FMonnum },
{ "moondate", 1, 3, 0, FMoondate },
{ "moondatetime", 1, 3, 0, FMoondatetime },
{ "moonphase", 0, 2, 0, FMoonphase },
{ "moontime", 1, 3, 0, FMoontime },
{ "multitrig", 1, NO_MAX, 0, FMultiTrig },
{ "ndawn", 0, 1, 0, FNDawn},
{ "ndusk", 0, 1, 0, FNDusk},
{ "nonomitted", 2, NO_MAX, 0, FNonomitted },
{ "now", 0, 0, 0, FNow },
{ "ord", 1, 1, 1, FOrd },
{ "orthodoxeaster",0, 1, 0, FOrthodoxeaster },
{ "ostype", 0, 0, 1, FOstype },
{ "pad", 3, 4, 1, FPad },
{ "plural", 1, 3, 1, FPlural },
{ "psmoon", 1, 4, 1, FPsmoon},
{ "psshade", 1, 3, 1, FPsshade},
{ "realcurrent", 0, 0, 0, FRealCurrent},
{ "realnow", 0, 0, 0, FRealnow},
{ "realtoday", 0, 0, 0, FRealtoday },
{ "rows", 0, 0, 0, FRows },
{ "sgn", 1, 1, 1, FSgn },
{ "shell", 1, 2, 0, FShell },
{ "shellescape", 1, 1, 1, FShellescape },
{ "slide", 2, NO_MAX, 0, FSlide },
{ "soleq", 1, 2, 0, FSoleq },
{ "stdout", 0, 0, 1, FStdout },
{ "strlen", 1, 1, 1, FStrlen },
{ "substr", 2, 3, 1, FSubstr },
{ "sunrise", 0, 1, 0, FSunrise},
{ "sunset", 0, 1, 0, FSunset },
{ "time", 2, 2, 1, FTime },
{ "timepart", 1, 1, 1, FTimepart },
{ "timezone", 0, 1, 1, FTimezone },
{ "today", 0, 0, 0, FToday },
{ "trig", 0, NO_MAX, 0, FTrig },
{ "trigback", 0, 0, 0, FTrigback },
{ "trigdate", 0, 0, 0, FTrigdate },
{ "trigdatetime", 0, 0, 0, FTrigdatetime },
{ "trigdelta", 0, 0, 0, FTrigdelta },
{ "trigduration", 0, 0, 0, FTrigduration },
{ "trigeventduration", 0, 0, 0, FTrigeventduration },
{ "trigeventstart", 0, 0, 0, FTrigeventstart },
{ "trigfrom", 0, 0, 0, FTrigfrom },
{ "trigger", 1, 3, 0, FTrigger },
{ "trigpriority", 0, 0, 0, FTrigpriority },
{ "trigrep", 0, 0, 0, FTrigrep },
{ "trigscanfrom", 0, 0, 0, FTrigscanfrom },
{ "trigtags", 0, 0, 0, FTrigtags },
{ "trigtime", 0, 0, 0, FTrigtime },
{ "trigtimedelta",0, 0, 0, FTrigtimedelta },
{ "trigtimerep", 0, 0, 0, FTrigtimerep },
{ "triguntil", 0, 0, 0, FTriguntil },
{ "trigvalid", 0, 0, 0, FTrigvalid },
{ "typeof", 1, 1, 1, FTypeof },
{ "tzconvert", 2, 3, 0, FTzconvert },
{ "upper", 1, 1, 1, FUpper },
{ "utctolocal", 1, 1, 1, FUTCToLocal },
{ "value", 1, 2, 0, FValue },
{ "version", 0, 0, 1, FVersion },
{ "weekno", 0, 3, 1, FWeekno },
{ "wkday", 1, 1, 1, FWkday },
{ "wkdaynum", 1, 1, 1, FWkdaynum },
{ "year", 1, 1, 1, FYear }
{ "abs", 1, 1, 1, FAbs, NULL },
{ "access", 2, 2, 0, FAccess, NULL },
{ "adawn", 0, 1, 0, FADawn, NULL},
{ "adusk", 0, 1, 0, FADusk, NULL},
{ "ampm", 1, 4, 1, FAmpm, NULL },
{ "ansicolor", 1, 5, 1, FAnsicolor, NULL },
{ "args", 1, 1, 0, FArgs, NULL },
{ "asc", 1, 1, 1, FAsc, NULL },
{ "baseyr", 0, 0, 1, FBaseyr, NULL },
{ "char", 1, NO_MAX, 1, FChar, NULL },
{ "choose", 2, NO_MAX, 1, NULL, FChoose }, /*NEW-STYLE*/
{ "coerce", 2, 2, 1, FCoerce, NULL },
{ "columns", 0, 1, 0, FColumns, NULL },
{ "current", 0, 0, 0, FCurrent, NULL },
{ "date", 3, 3, 1, FDate, NULL },
{ "datepart", 1, 1, 1, FDatepart, NULL },
{ "datetime", 2, 5, 1, FDateTime, NULL },
{ "dawn", 0, 1, 0, FDawn, NULL },
{ "day", 1, 1, 1, FDay, NULL },
{ "daysinmon", 2, 2, 1, FDaysinmon, NULL },
{ "defined", 1, 1, 0, FDefined, NULL },
{ "dosubst", 1, 3, 0, FDosubst, NULL },
{ "dusk", 0, 1, 0, FDusk, NULL },
{ "easterdate", 0, 1, 0, FEasterdate, NULL },
{ "evaltrig", 1, 2, 0, FEvalTrig, NULL },
{ "filedate", 1, 1, 0, FFiledate, NULL },
{ "filedatetime", 1, 1, 0, FFiledatetime, NULL },
{ "filedir", 0, 0, 0, FFiledir, NULL },
{ "filename", 0, 0, 0, FFilename, NULL },
{ "getenv", 1, 1, 0, FGetenv, NULL },
{ "hebdate", 2, 5, 0, FHebdate, NULL },
{ "hebday", 1, 1, 0, FHebday, NULL },
{ "hebmon", 1, 1, 0, FHebmon, NULL },
{ "hebyear", 1, 1, 0, FHebyear, NULL },
{ "hour", 1, 1, 1, FHour, NULL },
{ "htmlescape", 1, 1, 1, FHtmlEscape, NULL },
{ "htmlstriptags",1, 1, 1, FHtmlStriptags, NULL },
{ "iif", 1, NO_MAX, 1, NULL, FIif }, /*NEW-STYLE*/
{ "index", 2, 3, 1, FIndex, NULL },
{ "isany", 1, NO_MAX, 1, NULL, FIsAny }, /*NEW-STYLE*/
{ "isdst", 0, 2, 0, FIsdst, NULL },
{ "isleap", 1, 1, 1, FIsleap, NULL },
{ "isomitted", 1, 1, 0, FIsomitted, NULL },
{ "language", 0, 0, 1, FLanguage, NULL },
{ "localtoutc", 1, 1, 1, FLocalToUTC, NULL },
{ "lower", 1, 1, 1, FLower, NULL },
{ "max", 1, NO_MAX, 1, FMax, NULL },
{ "min", 1, NO_MAX, 1, FMin, NULL },
{ "minsfromutc", 0, 2, 0, FMinsfromutc, NULL },
{ "minute", 1, 1, 1, FMinute, NULL },
{ "mon", 1, 1, 1, FMon, NULL },
{ "monnum", 1, 1, 1, FMonnum, NULL },
{ "moondate", 1, 3, 0, FMoondate, NULL },
{ "moondatetime", 1, 3, 0, FMoondatetime, NULL },
{ "moonphase", 0, 2, 0, FMoonphase, NULL },
{ "moontime", 1, 3, 0, FMoontime, NULL },
{ "multitrig", 1, NO_MAX, 0, FMultiTrig, NULL },
{ "ndawn", 0, 1, 0, FNDawn, NULL },
{ "ndusk", 0, 1, 0, FNDusk, NULL },
{ "nonomitted", 2, NO_MAX, 0, FNonomitted, NULL },
{ "now", 0, 0, 0, FNow, NULL },
{ "ord", 1, 1, 1, FOrd, NULL },
{ "orthodoxeaster",0, 1, 0, FOrthodoxeaster, NULL },
{ "ostype", 0, 0, 1, FOstype, NULL },
{ "pad", 3, 4, 1, FPad, NULL },
{ "plural", 1, 3, 1, FPlural, NULL },
{ "psmoon", 1, 4, 1, FPsmoon, NULL },
{ "psshade", 1, 3, 1, FPsshade, NULL },
{ "realcurrent", 0, 0, 0, FRealCurrent, NULL },
{ "realnow", 0, 0, 0, FRealnow, NULL },
{ "realtoday", 0, 0, 0, FRealtoday, NULL },
{ "rows", 0, 0, 0, FRows, NULL },
{ "sgn", 1, 1, 1, FSgn, NULL },
{ "shell", 1, 2, 0, FShell, NULL },
{ "shellescape", 1, 1, 1, FShellescape, NULL },
{ "slide", 2, NO_MAX, 0, FSlide, NULL },
{ "soleq", 1, 2, 0, FSoleq, NULL },
{ "stdout", 0, 0, 1, FStdout, NULL },
{ "strlen", 1, 1, 1, FStrlen, NULL },
{ "substr", 2, 3, 1, FSubstr, NULL },
{ "sunrise", 0, 1, 0, FSunrise, NULL },
{ "sunset", 0, 1, 0, FSunset, NULL },
{ "time", 2, 2, 1, FTime, NULL },
{ "timepart", 1, 1, 1, FTimepart, NULL },
{ "timezone", 0, 1, 1, FTimezone, NULL },
{ "today", 0, 0, 0, FToday, NULL },
{ "trig", 0, NO_MAX, 0, FTrig, NULL },
{ "trigback", 0, 0, 0, FTrigback, NULL },
{ "trigdate", 0, 0, 0, FTrigdate, NULL },
{ "trigdatetime", 0, 0, 0, FTrigdatetime, NULL },
{ "trigdelta", 0, 0, 0, FTrigdelta, NULL },
{ "trigduration", 0, 0, 0, FTrigduration, NULL },
{ "trigeventduration", 0, 0, 0, FTrigeventduration, NULL },
{ "trigeventstart", 0, 0, 0, FTrigeventstart, NULL },
{ "trigfrom", 0, 0, 0, FTrigfrom, NULL },
{ "trigger", 1, 3, 0, FTrigger, NULL },
{ "trigpriority", 0, 0, 0, FTrigpriority, NULL },
{ "trigrep", 0, 0, 0, FTrigrep, NULL },
{ "trigscanfrom", 0, 0, 0, FTrigscanfrom, NULL },
{ "trigtags", 0, 0, 0, FTrigtags, NULL },
{ "trigtime", 0, 0, 0, FTrigtime, NULL },
{ "trigtimedelta",0, 0, 0, FTrigtimedelta, NULL },
{ "trigtimerep", 0, 0, 0, FTrigtimerep, NULL },
{ "triguntil", 0, 0, 0, FTriguntil, NULL },
{ "trigvalid", 0, 0, 0, FTrigvalid, NULL },
{ "typeof", 1, 1, 1, FTypeof, NULL },
{ "tzconvert", 2, 3, 0, FTzconvert, NULL },
{ "upper", 1, 1, 1, FUpper, NULL },
{ "utctolocal", 1, 1, 1, FUTCToLocal, NULL },
{ "value", 1, 2, 0, FValue, NULL },
{ "version", 0, 0, 1, FVersion, NULL },
{ "weekno", 0, 3, 0, FWeekno, NULL },
{ "wkday", 1, 1, 1, FWkday, NULL },
{ "wkdaynum", 1, 1, 1, FWkdaynum, NULL },
{ "year", 1, 1, 1, FYear, NULL }
};
/* Need a variable here - Func[] array not really visible to outside. */
int NumFuncs = sizeof(Func) / sizeof(Operator) ;
/***************************************************************/
/* */
/* CallFunc */
/* */
/* Call a function given a pointer to it, and the number */
/* of arguments supplied. */
/* */
/***************************************************************/
int CallFunc(BuiltinFunc *f, int nargs)
{
register int r = CheckArgs(f, nargs);
int i;
func_info info_obj;
func_info *info = &info_obj;
Nargs = nargs;
RetVal.type = ERR_TYPE;
if (DebugFlag & DB_PRTEXPR) {
fprintf(ErrFp, "%s(", f->name);
for (i=0; i<nargs; i++) {
PrintValue(&ARG(i), ErrFp);
if (i<nargs-1) fprintf(ErrFp, ", ");
}
fprintf(ErrFp, ") => ");
if (r) {
fprintf(ErrFp, "%s\n", ErrMsg[r]);
return r;
}
}
if (r) {
Eprint("%s(): %s", f->name, ErrMsg[r]);
return r;
}
r = (*(f->func))(info);
if (r) {
DestroyValue(RetVal);
if (DebugFlag & DB_PRTEXPR)
fprintf(ErrFp, "%s\n", ErrMsg[r]);
else
Eprint("%s(): %s", f->name, ErrMsg[r]);
return r;
}
if (DebugFlag & DB_PRTEXPR) {
PrintValue(&RetVal, ErrFp);
fprintf(ErrFp, "\n");
}
r = CleanUpAfterFunc(info);
return r;
}
/***************************************************************/
/* */
/* CheckArgs */
/* */
/* Check that the right number of args have been supplied */
/* for a function. */
/* */
/***************************************************************/
static int CheckArgs(BuiltinFunc *f, int nargs)
{
if (nargs < f->minargs) return E_2FEW_ARGS;
if (nargs > f->maxargs && f->maxargs != NO_MAX) return E_2MANY_ARGS;
return OK;
}
/***************************************************************/
/* */
/* CleanUpAfterFunc */
/* */
/* Clean up the stack after a function call - remove */
/* args and push the new value. */
/* */
/***************************************************************/
static int CleanUpAfterFunc(func_info *info)
{
Value v;
int i;
for (i=0; i<Nargs; i++) {
PopValStack(v);
DestroyValue(v);
}
PushValStack(RetVal);
return OK;
}
int NumFuncs = sizeof(Func) / sizeof(BuiltinFunc) ;
/***************************************************************/
/* */
@@ -468,10 +379,9 @@ static int RetStrVal(char const *s, func_info *info)
/***************************************************************/
static int FStrlen(func_info *info)
{
Value *v = &ARG(0);
if (v->type != STR_TYPE) return E_BAD_TYPE;
ASSERT_TYPE(0, STR_TYPE);
RetVal.type = INT_TYPE;
size_t l = strlen(v->v.str);
size_t l = strlen(ARGSTR(0));
if (l > INT_MAX) return E_2HIGH;
RETVAL = (int) l;
return OK;
@@ -1035,6 +945,8 @@ static int FAmpm(func_info *info)
char const *pm = "PM";
char const *ampm = NULL;
int include_leading_zero = 0;
char outbuf[128];
if (ARG(0).type != DATETIME_TYPE && ARG(0).type != TIME_TYPE) {
@@ -1049,6 +961,10 @@ static int FAmpm(func_info *info)
if (Nargs >= 3) {
ASSERT_TYPE(2, STR_TYPE);
pm = ARGSTR(2);
if (Nargs >= 4) {
ASSERT_TYPE(3, INT_TYPE);
include_leading_zero = ARGV(3);
}
}
}
h = TIMEPART(ARG(0)) / 60;
@@ -1063,9 +979,17 @@ static int FAmpm(func_info *info)
}
} else {
if (ARG(0).type == DATETIME_TYPE) {
snprintf(outbuf, sizeof(outbuf), "%04d%c%02d%c%02d%c%d%c%02d", yr, DateSep, mo+1, DateSep, da, DateTimeSep, h, TimeSep, m);
if (include_leading_zero) {
snprintf(outbuf, sizeof(outbuf), "%04d%c%02d%c%02d%c%02d%c%02d", yr, DateSep, mo+1, DateSep, da, DateTimeSep, h, TimeSep, m);
} else {
snprintf(outbuf, sizeof(outbuf), "%04d%c%02d%c%02d%c%d%c%02d", yr, DateSep, mo+1, DateSep, da, DateTimeSep, h, TimeSep, m);
}
} else {
snprintf(outbuf, sizeof(outbuf), "%d%c%02d", h, TimeSep, m);
if (include_leading_zero) {
snprintf(outbuf, sizeof(outbuf), "%02d%c%02d", h, TimeSep, m);
} else {
snprintf(outbuf, sizeof(outbuf), "%d%c%02d", h, TimeSep, m);
}
}
}
ampm = am;
@@ -1074,9 +998,17 @@ static int FAmpm(func_info *info)
h -= 12;
}
if (ARG(0).type == DATETIME_TYPE) {
snprintf(outbuf, sizeof(outbuf), "%04d%c%02d%c%02d%c%d%c%02d", yr, DateSep, mo+1, DateSep, da, DateTimeSep, h, TimeSep, m);
if (include_leading_zero) {
snprintf(outbuf, sizeof(outbuf), "%04d%c%02d%c%02d%c%02d%c%02d", yr, DateSep, mo+1, DateSep, da, DateTimeSep, h, TimeSep, m);
} else {
snprintf(outbuf, sizeof(outbuf), "%04d%c%02d%c%02d%c%d%c%02d", yr, DateSep, mo+1, DateSep, da, DateTimeSep, h, TimeSep, m);
}
} else {
snprintf(outbuf, sizeof(outbuf), "%d%c%02d", h, TimeSep, m);
if (include_leading_zero) {
snprintf(outbuf, sizeof(outbuf), "%02d%c%02d", h, TimeSep, m);
} else {
snprintf(outbuf, sizeof(outbuf), "%d%c%02d", h, TimeSep, m);
}
}
ampm = pm;
}
@@ -1108,8 +1040,11 @@ static int FOrd(func_info *info)
ASSERT_TYPE(0, INT_TYPE);
v = ARGV(0);
t = v % 100;
if (t < 0) t = -t;
if (v < 0) {
t = (-v) % 100;
} else {
t = v % 100;
}
u = t % 10;
s = "th";
if (u == 1 && t != 11) s = "st";
@@ -1123,8 +1058,8 @@ static int FOrd(func_info *info)
/* */
/* FPad - Pad a string to min length */
/* */
/* pad("1", "0", 4) --> "0004" */
/* pad("1", "0", 4, 1) --> "4000" */
/* pad("1", "0", 4) --> "0001" */
/* pad("1", "0", 4, 1) --> "1000" */
/* pad("foo", "bar", 7) -> "barbfoo" */
/* */
/***************************************************************/
@@ -1248,25 +1183,66 @@ static int FPlural(func_info *info)
/* otherwise. */
/* */
/***************************************************************/
static int FIsAny(func_info *info)
static int FIsAny(expr_node *node, Value *locals, Value *ans, int *nonconst)
{
int i;
RetVal.type = INT_TYPE;
RETVAL = 0;
for (i=1; i<Nargs; i++) {
if (ARG(0).type == ARG(i).type) {
if (ARG(0).type == STR_TYPE) {
if (!strcmp(ARGSTR(0), ARGSTR(i))) {
RETVAL = 1;
return OK;
}
} else {
if (ARGV(0) == ARGV(i)) {
RETVAL = 1;
return OK;
}
DynamicBuffer DebugBuf;
expr_node *cur;
int r;
Value v;
Value candidate;
ans->type = INT_TYPE;
ans->v.val = 0;
DBG(DBufInit(&DebugBuf));
DBG(PUT("isany("));
cur = node->child;
r = evaluate_expr_node(cur, locals, &v, nonconst);
if (r != OK) {
DBG(DBufFree(&DebugBuf));
return r;
}
DBG(PUT(PrintValue(&v, NULL)));
while(cur->sibling) {
cur = cur->sibling;
r = evaluate_expr_node(cur, locals, &candidate, nonconst);
if (r != OK) {
DestroyValue(v);
DBG(DBufFree(&DebugBuf));
return r;
}
DBG(PUT(", "));
DBG(PUT(PrintValue(&candidate, NULL)));
if (candidate.type != v.type) {
DestroyValue(candidate);
continue;
}
if (v.type == STR_TYPE) {
if (strcmp(v.v.str, candidate.v.str)) {
DestroyValue(candidate);
continue;
}
} else {
if (v.v.val != candidate.v.val) {
DestroyValue(candidate);
continue;
}
}
DestroyValue(candidate);
ans->v.val = 1;
break;
}
DestroyValue(v);
if (DebugFlag & DB_PRTEXPR) {
while(cur->sibling) {
cur = cur->sibling;
PUT(", ?");
}
PUT(") => ");
PUT(PrintValue(ans, NULL));
OUT();
}
return OK;
}
@@ -1279,15 +1255,64 @@ static int FIsAny(func_info *info)
/* from 1. */
/* */
/***************************************************************/
static int FChoose(func_info *info)
static int FChoose(expr_node *node, Value *locals, Value *ans, int *nonconst)
{
int v;
DynamicBuffer DebugBuf;
expr_node *cur;
int r;
int n;
int nargs = node->num_kids;
Value v;
DBG(DBufInit(&DebugBuf));
DBG(PUT("choose("));
ASSERT_TYPE(0, INT_TYPE);
v = ARGV(0);
if (v < 1) v = 1;
if (v > Nargs-1) v = Nargs-1;
DCOPYVAL(RetVal, ARG(v));
cur = node->child;
r = evaluate_expr_node(cur, locals, &v, nonconst);
if (r != OK) {
DBG(DBufFree(&DebugBuf));
return r;
}
DBG(PUT(PrintValue(&v, NULL)));
if (v.type != INT_TYPE) {
if (DebugFlag & DB_PRTEXPR) {
cur = cur->sibling;
while(cur) {
PUT(", ?");
cur = cur->sibling;
}
PUT(") => ");
PUT(ErrMsg[E_BAD_TYPE]);
OUT();
}
Eprint("choose(): %s", ErrMsg[E_BAD_TYPE]);
return E_BAD_TYPE;
}
n = v.v.val;
if (n < 1) n = 1;
if (n > nargs-1) n = nargs-1;
while(n--) {
cur = cur->sibling;
DBG(if (n) { PUT(", ?"); });
if (!cur) return E_SWERR; /* Should not happen! */
}
r = evaluate_expr_node(cur, locals, ans, nonconst);
if (r != OK) {
DBG(DBufFree(&DebugBuf));
return r;
}
if (DebugFlag & DB_PRTEXPR) {
PUT(", ");
PUT(PrintValue(ans, NULL));
cur = cur->sibling;
while(cur) {
PUT(", ?");
cur = cur->sibling;
}
PUT(") => ");
PUT(PrintValue(ans, NULL));
OUT();
}
return OK;
}
@@ -1473,7 +1498,7 @@ static int FValue(func_info *info)
ASSERT_TYPE(0, STR_TYPE);
switch(Nargs) {
case 1:
return GetVarValue(ARGSTR(0), &RetVal, NULL, NULL);
return GetVarValue(ARGSTR(0), &RetVal);
case 2:
v = FindVar(ARGSTR(0), 0);
@@ -1945,33 +1970,82 @@ static int FIndex(func_info *info)
/* */
/* FIif */
/* */
/* The IIF function. */
/* The IIF function. Uses new-style evaluation */
/* */
/***************************************************************/
static int FIif(func_info *info)
static int FIif(expr_node *node, Value *locals, Value *ans, int *nonconst)
{
int istrue;
int arg;
int r;
int done;
Value v;
expr_node *cur;
DynamicBuffer DebugBuf;
if (!(Nargs % 2)) return E_IIF_ODD;
DBG(DBufInit(&DebugBuf));
DBG(PUT("iif("));
cur = node->child;
for (arg=0; arg<Nargs-1; arg += 2) {
if (ARG(arg).type != STR_TYPE && ARG(arg).type != INT_TYPE)
return E_BAD_TYPE;
if (ARG(arg).type == INT_TYPE)
istrue = ARG(arg).v.val;
else
istrue = *(ARG(arg).v.str);
if (istrue) {
DCOPYVAL(RetVal, ARG(arg+1));
return OK;
}
if (!(node->num_kids % 2)) {
if (DebugFlag & DB_PRTEXPR) {
r = 0;
while(cur) {
if (r) PUT(", ");
r=1;
PUT("?");
cur = cur->sibling;
}
PUT(") => ");
PUT(ErrMsg[E_IIF_ODD]);
OUT();
}
return E_IIF_ODD;
}
DCOPYVAL(RetVal, ARG(Nargs-1));
return OK;
done = 0;
while(cur->sibling) {
r = evaluate_expr_node(cur, locals, &v, nonconst);
if (r != OK) {
DBG(DBufFree(&DebugBuf));
return r;
}
if (DebugFlag & DB_PRTEXPR) {
if (done) PUT(", ");
done = 1;
PUT(PrintValue(&v, NULL));
}
if (truthy(&v)) {
r = evaluate_expr_node(cur->sibling, locals, ans, nonconst);
if (r == OK && (DebugFlag & DB_PRTEXPR)) {
PUT(", ");
PUT(PrintValue(ans, NULL));
cur = cur->sibling->sibling;
while(cur) {
PUT(", ?");
cur = cur->sibling;
}
PUT(") => ");
PUT(PrintValue(ans, NULL));
OUT();
}
DBG(DBufFree(&DebugBuf));
return r;
}
DBG(PUT(", ?"));
cur = cur->sibling->sibling;
}
/* Return the last arg */
r = evaluate_expr_node(cur, locals, ans, nonconst);
if (DebugFlag & DB_PRTEXPR) {
if (done) PUT(", ");
PUT(PrintValue(ans, NULL));
PUT(") => ");
PUT(PrintValue(ans, NULL));
OUT();
}
return r;
}
/***************************************************************/
@@ -2093,6 +2167,7 @@ static int FArgs(func_info *info)
{
ASSERT_TYPE(0, STR_TYPE);
RetVal.type = INT_TYPE;
strtolower(ARGSTR(0));
RETVAL = UserFuncExists(ARGSTR(0));
return OK;
}
@@ -2365,14 +2440,18 @@ static int FEasterdate(func_info *info)
{
int y, m, d;
int g, c, x, z, e, n;
int base;
if (Nargs == 0) {
base = DSEToday;
FromDSE(DSEToday, &y, &m, &d);
} else {
if (ARG(0).type == INT_TYPE) {
base = -1;
y = ARGV(0);
if (y < BASE) return E_2LOW;
else if (y > BASE+YR_RANGE) return E_2HIGH;
} else if (HASDATE(ARG(0))) {
base = DATEPART(ARG(0));
FromDSE(DATEPART(ARG(0)), &y, &m, &d); /* We just want the year */
} else return E_BAD_TYPE;
}
@@ -2398,7 +2477,7 @@ static int FEasterdate(func_info *info)
RetVal.type = DATE_TYPE;
RETVAL = DSE(y, m, d);
y++; } while (HASDATE(ARG(0)) && RETVAL < DATEPART(ARG(0)));
y++; } while (base > -1 && RETVAL < base);
return OK;
}
@@ -2414,7 +2493,9 @@ static int FOrthodoxeaster(func_info *info)
{
int y, m, d;
int a, b, c, dd, e, f, dse;
int base = -1;
if (Nargs == 0) {
base = DSEToday;
FromDSE(DSEToday, &y, &m, &d);
} else {
if (ARG(0).type == INT_TYPE) {
@@ -2422,6 +2503,7 @@ static int FOrthodoxeaster(func_info *info)
if (y < BASE) return E_2LOW;
else if (y > BASE+YR_RANGE) return E_2HIGH;
} else if (HASDATE(ARG(0))) {
base = DATEPART(ARG(0));
FromDSE(DATEPART(ARG(0)), &y, &m, &d); /* We just want the year */
} else return E_BAD_TYPE;
}
@@ -2441,7 +2523,7 @@ static int FOrthodoxeaster(func_info *info)
RetVal.type = DATE_TYPE;
RETVAL = dse;
y++;
} while (HASDATE(ARG(0)) && RETVAL < DATEPART(ARG(0)));
} while (base > -1 && RETVAL < base);
return OK;
}
@@ -2575,6 +2657,10 @@ static int UTCToLocalHelper(int datetime, int *ret)
min = (datetime % MINUTES_PER_DAY) % 60;
old_tz = getenv("TZ");
if (old_tz) {
old_tz = StrDup(old_tz);
if (!old_tz) return E_NO_MEM;
}
tz_set_tz("UTC");
@@ -2588,6 +2674,9 @@ static int UTCToLocalHelper(int datetime, int *ret)
utc.tm_isdst = 0;
utc_t = mktime(&utc);
tz_set_tz(old_tz);
if (old_tz) {
free( (void *) old_tz);
}
if (utc_t == -1) {
return E_MKTIME_PROBLEM;
@@ -3222,6 +3311,10 @@ static int tz_convert(int year, int month, int day,
/* backup old TZ env var */
old_tz = getenv("TZ");
if (old_tz) {
old_tz = StrDup(old_tz);
if (!old_tz) return E_NO_MEM;
}
if (tgt_tz == NULL) {
tgt_tz = old_tz;
}
@@ -3229,6 +3322,8 @@ static int tz_convert(int year, int month, int day,
/* set source TZ */
r = tz_set_tz(src_tz);
if (r == -1) {
tz_set_tz(old_tz);
if (old_tz) free((void *) old_tz);
return -1;
}
@@ -3236,14 +3331,16 @@ static int tz_convert(int year, int month, int day,
t = mktime(tm);
if (t == (time_t) -1) {
tz_set_tz(old_tz);
tz_set_tz(old_tz);
if (old_tz) free((void *) old_tz);
return -1;
}
/* set target TZ */
r = tz_set_tz(tgt_tz);
if (r == -1) {
tz_set_tz(old_tz);
tz_set_tz(old_tz);
if (old_tz) free((void *) old_tz);
return -1;
}
@@ -3252,6 +3349,7 @@ static int tz_convert(int year, int month, int day,
/* restore old TZ */
tz_set_tz(old_tz);
if (old_tz) free((void *) old_tz);
/* return result */
if (res == NULL) {
@@ -3482,7 +3580,7 @@ FEvalTrig(func_info *info)
CreateParser(ARGSTR(0), &p);
p.allownested = 0;
r = ParseRem(&p, &trig, &tim, 0);
r = ParseRem(&p, &trig, &tim);
if (r) {
DestroyParser(&p);
return r;
@@ -3541,7 +3639,7 @@ FMultiTrig(func_info *info)
for (i=0; i<Nargs; i++) {
CreateParser(ARGSTR(i), &p);
p.allownested = 0;
r = ParseRem(&p, &trig, &tim, 0);
r = ParseRem(&p, &trig, &tim);
if (r) {
DestroyParser(&p);
return r;
@@ -3598,7 +3696,7 @@ FTrig(func_info *info)
for (i=0; i<Nargs; i++) {
CreateParser(ARGSTR(i), &p);
p.allownested = 0;
r = ParseRem(&p, &trig, &tim, 0);
r = ParseRem(&p, &trig, &tim);
if (r) {
DestroyParser(&p);
return r;
@@ -3872,3 +3970,48 @@ FSoleq(func_info *info)
RETVAL = ret;
return OK;
}
/* Compare two strings case-insensitively, where we KNOW
that the second string is definitely lower-case */
static int strcmp_lcfirst(char const *s1, char const *s2)
{
int r;
while (*s1 && *s2) {
r = tolower(*s1) - *s2;
if (r) return r;
s1++;
s2++;
}
return tolower(*s1) - *s2;
}
/***************************************************************/
/* */
/* FindBuiltinFunc */
/* */
/* Find a built-in function. */
/* */
/***************************************************************/
BuiltinFunc *FindBuiltinFunc(char const *name)
{
int top=NumFuncs-1, bot=0;
int mid, r;
while (top >= bot) {
mid = (top + bot) / 2;
r = strcmp_lcfirst(name, Func[mid].name);
if (!r) return &Func[mid];
else if (r > 0) bot = mid+1;
else top = mid-1;
}
return NULL;
}
void
print_builtinfunc_tokens(void)
{
int i;
printf("\n# Built-in Functions\n\n");
for (i=0; i<NumFuncs; i++) {
printf("%s\n", Func[i].name);
}
}

View File

@@ -23,6 +23,7 @@
#define INIT(var, val) var
#endif
#include <signal.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -48,6 +49,7 @@ EXTERN int CurMon;
EXTERN int CurYear;
EXTERN int LineNo;
EXTERN int FreshLine;
EXTERN int WarnedAboutImplicit;
EXTERN uid_t TrustedUsers[MAX_TRUSTED_USERS];
EXTERN INIT( int MaxLateMinutes, 0);
@@ -73,10 +75,16 @@ EXTERN INIT( int InfiniteDelta, 0);
EXTERN INIT( int DefaultTDelta, 0);
EXTERN INIT( int DeltaOverride, 0);
EXTERN INIT( int RunDisabled, 0);
EXTERN INIT( int ExpressionEvaluationDisabled, 0);
EXTERN INIT( int ExpressionEvaluationTimeLimit, 0);
EXTERN INIT( volatile sig_atomic_t ExpressionTimeLimitExceeded, 0);
EXTERN INIT( int IgnoreOnce, 0);
EXTERN INIT( int SortByTime, 0);
EXTERN INIT( int SortByDate, 0);
EXTERN INIT( int SortByPrio, 0);
EXTERN INIT( char const *OnceFile, NULL);
EXTERN INIT( int OnceDate, -1);
EXTERN INIT( int ProcessedOnce, 0);
EXTERN INIT( int SortByTime, SORT_NONE);
EXTERN INIT( int SortByDate, SORT_NONE);
EXTERN INIT( int SortByPrio, SORT_NONE);
EXTERN INIT( int UntimedBeforeTimed, 0);
EXTERN INIT( int DefaultPrio, NO_PRIORITY);
EXTERN INIT( int SysTime, -1);
@@ -110,11 +118,12 @@ EXTERN INIT( int PurgeIncludeDepth, 0);
EXTERN INIT( FILE *PurgeFP, NULL);
EXTERN INIT( int NumIfs, 0);
EXTERN INIT( unsigned int IfFlags, 0);
EXTERN INIT( int IfLinenos[IF_NEST], {0});
EXTERN INIT( int LastTrigValid, 0);
EXTERN Trigger LastTrigger;
EXTERN TimeTrig LastTimeTrig;
EXTERN INIT( int LastTriggerDate, 0);
EXTERN INIT( int LastTriggerTime, 0);
EXTERN INIT( int LastTriggerTime, NO_TIME);
EXTERN INIT( int ShouldCache, 0);
EXTERN char const *CurLine;
EXTERN INIT( int NumTriggered, 0);
@@ -159,6 +168,12 @@ EXTERN DynamicBuffer Banner;
EXTERN DynamicBuffer LineBuffer;
EXTERN DynamicBuffer ExprBuf;
/* User-func recursion level */
EXTERN INIT( unsigned int FuncRecursionLevel, 0);
/* Suppress warnings about implicit REM and MSG */
EXTERN INIT( int SuppressImplicitRemWarnings, 0);
extern int NumFullOmits, NumPartialOmits;
/* List of months */

View File

@@ -20,6 +20,12 @@
#include "protos.h"
#include "globals.h"
#include "err.h"
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#define HOUR 1080L
#define DAY (24L*HOUR)
#define WEEK (7L*DAY)

View File

@@ -19,7 +19,7 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -38,7 +38,6 @@
#include "types.h"
#include "globals.h"
#include "protos.h"
#include "expr.h"
#include "err.h"
static int should_guess_terminal_background = 1;
@@ -242,7 +241,6 @@ void InitRemind(int argc, char const *argv[])
arg++;
if (!*arg) {
UseStdin = 1;
IgnoreOnce = 1;
i--;
break;
}
@@ -325,6 +323,7 @@ void InitRemind(int argc, char const *argv[])
NextMode = 1;
DontQueue = 1;
Daemon = 0;
IgnoreOnce = 1;
break;
case 'r':
@@ -458,6 +457,7 @@ void InitRemind(int argc, char const *argv[])
break;
case 'c':
case 'C':
IgnoreOnce = 1;
DoCalendar = 1;
weeks = 0;
/* Parse the flags */
@@ -502,6 +502,7 @@ void InitRemind(int argc, char const *argv[])
case 's':
case 'S':
DoSimpleCalendar = 1;
IgnoreOnce = 1;
weeks = 0;
while(*arg) {
if (*arg == 'a' || *arg == 'A') {
@@ -528,6 +529,7 @@ void InitRemind(int argc, char const *argv[])
case 'p':
case 'P':
DoSimpleCalendar = 1;
IgnoreOnce = 1;
PsCal = PSCAL_LEVEL1;
while (*arg == 'a' || *arg == 'A' ||
*arg == 'q' || *arg == 'Q' ||
@@ -605,7 +607,7 @@ void InitRemind(int argc, char const *argv[])
case 'D':
while (*arg) {
switch(*arg++) {
case 's': case 'S': DebugFlag |= DB_EXPR_STACKS; break;
case 's': case 'S': DebugFlag |= DB_PARSE_EXPR; break;
case 'e': case 'E': DebugFlag |= DB_ECHO_LINE; break;
case 'x': case 'X': DebugFlag |= DB_PRTEXPR; break;
case 't': case 'T': DebugFlag |= DB_PRTTRIG; break;
@@ -715,12 +717,17 @@ void InitRemind(int argc, char const *argv[])
break;
default:
if (tok.type == T_Illegal && tok.val < 0) {
fprintf(stderr, "%s: `%s'\n", ErrMsg[-tok.val], arg);
Usage();
}
Usage();
}
}
if (rep > 0) {
Iterations = rep;
IgnoreOnce = 1;
DontQueue = 1;
Daemon = 0;
}
@@ -806,6 +813,7 @@ void Usage(void)
fprintf(ErrFp, " -m Start calendar with Monday rather than Sunday\n");
fprintf(ErrFp, " -y Synthesize tags for tagless reminders\n");
fprintf(ErrFp, " -j[n] Run in 'purge' mode. [n = INCLUDE depth]\n");
fprintf(ErrFp, "\nRemind home page: %s\n", PACKAGE_URL);
exit(EXIT_FAILURE);
}
#endif /* L_USAGE_OVERRIDE */
@@ -925,7 +933,12 @@ static void InitializeVar(char const *str)
r = 0;
while (*str && *str != '=') {
if (r < VAR_NAME_LEN) {
varname[r++] = *str;
if (isalpha(*str) || *str == '_' || (r > 0 && *str == '(') || (r == 0 && *str == '$') || (r > 0 && isdigit(*str))) {
varname[r++] = *str;
} else {
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_ILLEGAL_CHAR]);
return;
}
}
if (*str == '(') {
/* Do a function definition if we see a paren */
@@ -935,10 +948,28 @@ static void InitializeVar(char const *str)
str++;
}
varname[r] = 0;
if (!*str) {
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_EQ]);
if (!*varname) {
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_VAR]);
return;
}
if (!*str) {
/* Setting a system var does require =expr on the commandline */
if (*varname == '$') {
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_EQ]);
return;
}
val.type = INT_TYPE;
val.v.val = 0;
r = SetVar(varname, &val);
if (!r) {
r = PreserveVar(varname);
}
if (r) {
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[r]);
}
return;
}
if (!*varname) {
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_MISS_VAR]);
return;
@@ -991,13 +1022,75 @@ AddTrustedUser(char const *username)
NumTrustedUsers++;
}
static pid_t LimiterPid = (pid_t) -1;
void unlimit_execution_time(void)
{
if (LimiterPid != (pid_t) -1) {
kill(LimiterPid, SIGTERM);
LimiterPid = (pid_t) -1;
}
}
static void limit_execution_time(int t)
{
pid_t parent = getpid();
pid_t pid = fork();
if (pid < 0) {
perror("fork");
exit(1);
}
if (pid > 0) {
LimiterPid = pid;
/* In the parent */
return;
}
/* In the child */
time_t start = time(NULL);
while(1) {
sleep(1);
if (kill(parent, 0) < 0) {
/* Parent has probably exited */
exit(0);
}
if (time(NULL) - start > t) {
kill(parent, SIGXCPU);
exit(0);
}
}
}
static void
ProcessLongOption(char const *arg)
{
int t;
if (!strcmp(arg, "version")) {
printf("%s\n", VERSION);
exit(EXIT_SUCCESS);
}
if (!strcmp(arg, "print-config-cmd")) {
printf("%s\n", CONFIG_CMD);
exit(EXIT_SUCCESS);
}
if (!strcmp(arg, "print-tokens")) {
print_remind_tokens();
print_builtinfunc_tokens();
print_sysvar_tokens();
exit(0);
}
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);
}
@@ -1040,6 +1133,8 @@ guess_terminal_background(int *r, int *g, int *b)
if (n != 8) {
/* write failed... WTF? Not much we can do */
tty_reset(ttyfd);
close(ttyfd);
return;
}
@@ -1063,6 +1158,7 @@ guess_terminal_background(int *r, int *g, int *b)
return;
}
tty_reset(ttyfd);
close(ttyfd);
buf[n+1] = 0;
if (n < 25) {
/* Too short */

View File

@@ -145,7 +145,7 @@ EXTERN char *ErrMsg[] =
"Ok",
"Puuttuva ']'",
"Puuttuva lainausmerkki",
"Liian monimutkainen lauseke - liikaa operaattoreita",
"Liian monimutkainen lauseke",
"Liian monimutkainen lauseke - liikaa operandeja",
"Puuttuva ')'",
"Määrittelemätön funktio",
@@ -245,8 +245,11 @@ EXTERN char *ErrMsg[] =
"No files matching *.rem",
"String too long",
"Time specified twice",
"Cannot specify DURATION without specifying AT".
"Odotettu viikonpäivän nimi"
"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 */
@@ -272,12 +275,10 @@ void Usage(void)
fprintf(ErrFp, " -o Älä noudata ONCE-lauseita\n");
fprintf(ErrFp, " -t Laukaise kaikki viestit deltan arvosta välittämättä\n");
fprintf(ErrFp, " -h Suppeat tulostukset\n");
#ifdef HAVE_QUEUED
fprintf(ErrFp, " -a Älä laukaise viestejä heti - lisää ne jonoon\n");
fprintf(ErrFp, " -q Älä lisää viestejä jonoon\n");
fprintf(ErrFp, " -f Laukaise viestit, pysy etualalla\n");
fprintf(ErrFp, " -z[n] Käynnisty demonina, herätys n:n (5:n) minuutin välein\n");
#endif
fprintf(ErrFp, " -d... Virheenetsintä: e=echo x=expr-eval t=trig v=dumpvars l=showline\n");
fprintf(ErrFp, " -e Ohjaa virhetulostus stdout-vuohon\n");
fprintf(ErrFp, " -b[n] Ajan ilmaisu: 0=ap/ip, 1=24 tuntia, 2=ei aikoja\n");

View File

@@ -119,7 +119,7 @@ EXTERN char *ErrMsg[] =
"Ok",
"']' manquant",
"Apostrophe manquant",
"Expression trop complexe - trop d'opérateurs",
"Expression trop complexe",
"Expression trop complexe - trop d'opérandes",
"')' manquante",
"Fonction non-définie",
@@ -221,6 +221,9 @@ EXTERN char *ErrMsg[] =
"Time specified twice",
"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 */
@@ -246,12 +249,10 @@ void Usage(void)
fprintf(ErrFp, " -o Ignorer instructions ONCE\n");
fprintf(ErrFp, " -t Déclencher tous les rappels peu importe le delta\n");
fprintf(ErrFp, " -h Mode silencieux\n");
#ifdef HAVE_QUEUED
fprintf(ErrFp, " -a Ne pas déclencher les rappels minutés immédiatement - les mettre en file\n");
fprintf(ErrFp, " -q Ne pas mettre les rappels minutés en file\n");
fprintf(ErrFp, " -f Déclencher les rappels minutés immédiatement en restant en avant-plan\n");
fprintf(ErrFp, " -z[n] Entrer en mode 'daemon', réveil chaque n (5) minutes\n");
#endif
fprintf(ErrFp, " -d... Debug: e=echo x=expr-eval t=trig v=dumpvars l=showline\n");
fprintf(ErrFp, " -e Envoyer les messages de stderr à stdout\n");
fprintf(ErrFp, " -b[n] Formats de l'heure pour le calendrier: 0=am/pm, 1=24hr, 2=aucun\n");

View File

@@ -135,7 +135,7 @@ EXTERN char *ErrMsg[] =
"OK",
"Brakujący ']'",
"Brakujący nawias",
"Zbyt skomplikowane wyrażenie - za dużo operatorów",
"Zbyt skomplikowane wyrażenie",
"Zbyt skomplikowane wyrażenie - za dużo argumentów",
"Brakujący ')'",
"Nie zdefiniowana funkcja",
@@ -236,7 +236,9 @@ EXTERN char *ErrMsg[] =
"String too long",
"Time specified twice",
"Cannot specify DURATION without specifying AT",
"Oczekiwana nazwa dnia tygodnia"
"Oczekiwana nazwa dnia tygodnia",
"Zduplikowana nazwa argumentu",
"Ocena wyrażeń jest wyłączona",
};
#endif /* MK_GLOBALS */
@@ -262,12 +264,10 @@ void Usage(void)
fprintf(ErrFp, " -o Ignoruj instrukcje ONCE\n");
fprintf(ErrFp, " -t Odpal wszystkie przyszłe przypomnienia niezależnie od delty\n");
fprintf(ErrFp, " -h Praca bezszmerowa\n");
#ifdef HAVE_QUEUED
fprintf(ErrFp, " -a Nie odpalaj przyponień czasowych - kolejkuj je\n");
fprintf(ErrFp, " -q Nie kolejkuj przyponień czasowych\n");
fprintf(ErrFp, " -f Nie przechodź do pracy w tle\n");
fprintf(ErrFp, " -z[n] Pracuj jako demon, budząc się co n (5) minut\n");
#endif
fprintf(ErrFp, " -d... Odpluskwianie: e=echo x=expr-eval t=trig v=dumpvars l=showline\n");
fprintf(ErrFp, " -e Komunikaty o błędach skieruj na stdout\n");
fprintf(ErrFp, " -b[n] Format czasu: 0=am/pm, 1=24godz., 2=żaden\n");

View File

@@ -144,7 +144,7 @@ EXTERN char *ErrMsg[] =
"Ok",
"Falta um ']'",
"Falta uma aspa",
"Expressao muito complexa - muitos operadores",
"Expressao muito complexa",
"Expressao muito complexa - muitos operandos",
"Falta um ')'",
"Funcao nao definida",
@@ -246,6 +246,8 @@ EXTERN char *ErrMsg[] =
"Time specified twice",
"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 */
@@ -271,12 +273,10 @@ void Usage(void)
fprintf(ErrFp, " -o Ignora diretivas ONCE\n");
fprintf(ErrFp, " -t Aciona todos os compromissos futuros, sem considerar o delta\n");
fprintf(ErrFp, " -h Modo `Hush' - quieto\n");
#ifdef HAVE_QUEUED
fprintf(ErrFp, " -a Nao aciona compromissos com hora imediatamente - apenas coloca na fila\n");
fprintf(ErrFp, " -q Nao coloca compromissos com hora na fila\n");
fprintf(ErrFp, " -f Aciona compromissos com hora em modo foreground\n");
fprintf(ErrFp, " -z[n] Modo `daemon', acordando a cada n (5) minutos.\n");
#endif
fprintf(ErrFp, " -d... Debug: e=echo x=expr-eval t=trigger v=dumpvars l=showline\n");
fprintf(ErrFp, " -e Desvia mensagens normalmente enviadas a stderr para stdout\n");
fprintf(ErrFp, " -b[n] Formato da hora para o cal: 0=am/pm, 1=24hr, 2=nenhum\n");

View File

@@ -22,6 +22,11 @@
#include <stdio.h>
#include <signal.h>
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <stdarg.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
@@ -41,7 +46,6 @@
#include "types.h"
#include "protos.h"
#include "expr.h"
#include "globals.h"
#include "err.h"
@@ -50,6 +54,46 @@ 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();
int maxlen, total;
double avglen;
if (DebugFlag & DB_PARSE_EXPR) {
fflush(stdout);
fflush(stderr);
get_var_hash_stats(&total, &maxlen, &avglen);
fprintf(stderr, " Var hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen);
get_userfunc_hash_stats(&total, &maxlen, &avglen);
fprintf(stderr, "Func hash: total = %d; maxlen = %d; avglen = %.3f\n", total, maxlen, avglen);
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 */
/* cppcheck-suppress duplicateExpression */
/* cppcheck-suppress knownArgument */
_exit(1 + (r-r));
}
/***************************************************************/
/***************************************************************/
/** **/
@@ -61,6 +105,8 @@ int main(int argc, char *argv[])
{
int pid;
struct sigaction act;
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
@@ -73,10 +119,29 @@ int main(int argc, char *argv[])
ArgV = (char const **) argv;
InitRemind(argc, (char const **) argv);
act.sa_handler = sigalrm;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_RESTART;
if (sigaction(SIGALRM, &act, NULL) < 0) {
fprintf(stderr, "%s: sigaction() failed: %s\n",
argv[0], strerror(errno));
exit(1);
}
act.sa_handler = sigxcpu;
act.sa_flags = SA_RESTART;
sigemptyset(&act.sa_mask);
if (sigaction(SIGXCPU, &act, NULL) < 0) {
fprintf(stderr, "%s: sigaction() failed: %s\n",
argv[0], strerror(errno));
exit(1);
}
DBufInit(&(LastTrigger.tags));
ClearLastTriggers();
atexit(DebugExitFunc);
atexit(exitfunc);
if (DoCalendar || (DoSimpleCalendar && (!NextMode || PsCal))) {
ProduceCalendar();
@@ -101,7 +166,7 @@ int main(int argc, char *argv[])
}
if (!Hush) {
if (DestroyOmitContexts())
if (DestroyOmitContexts(1))
Eprint("%s", ErrMsg[E_PUSH_NOPOP]);
if (!Daemon && !NextMode && !NumTriggered && !NumQueued) {
printf("%s\n", ErrMsg[E_NOREMINDERS]);
@@ -154,7 +219,7 @@ void
PerIterationInit(void)
{
ClearGlobalOmits();
DestroyOmitContexts();
DestroyOmitContexts(1);
DestroyVars(0);
DefaultColorR = -1;
DefaultColorG = -1;
@@ -183,7 +248,8 @@ static void DoReminders(void)
if (!UseStdin) {
FileAccessDate = GetAccessDate(InitialFile);
} else {
FileAccessDate = DSEToday;
FileAccessDate = DSEToday - 1;
if (FileAccessDate < 0) FileAccessDate = 0;
}
if (FileAccessDate < 0) {
@@ -281,9 +347,11 @@ static void DoReminders(void)
case T_Pop: r=PopOmitContext(&p); break;
case T_Preserve: r=DoPreserve(&p); break;
case T_Push: r=PushOmitContext(&p); break;
case T_Expr: r = DoExpr(&p); break;
case T_RemType: if (tok.val == RUN_TYPE) {
r=DoRun(&p);
} else {
DestroyParser(&p);
CreateParser(CurLine, &p);
r=DoRem(&p);
purge_handled = 1;
@@ -291,11 +359,18 @@ static void DoReminders(void)
break;
/* 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. */
/* If we don't recognize the command, do a REM by default, but warn */
default: CreateParser(CurLine, &p); purge_handled = 1; r=DoRem(&p); break;
default:
if (!SuppressImplicitRemWarnings) {
Wprint("Unrecognized command; interpreting as REM");
WarnedAboutImplicit = 1;
}
DestroyParser(&p);
CreateParser(CurLine, &p);
purge_handled = 1;
r=DoRem(&p);
break;
}
if (r && (!Hush || r != E_RUN_DISABLED)) {
@@ -453,6 +528,16 @@ int ParseChar(ParsePtr p, int *err, int peek)
return *(p->pos++);
}
}
/* Convert [[ to just a literal [ */
if (*p->pos == BEG_OF_EXPR && *(p->pos+1) == BEG_OF_EXPR) {
if (peek) {
return *(p->pos+1);
} else {
p->pos++;
return *(p->pos++);
}
}
p->expr_happened = 1;
p->pos++;
r = EvalExpr(&(p->pos), &val, p);
@@ -461,8 +546,15 @@ int ParseChar(ParsePtr p, int *err, int peek)
DestroyParser(p);
return 0;
}
while(*p->pos && (isempty(*p->pos))) {
p->pos++;
}
if (*p->pos != END_OF_EXPR) {
*err = E_MISS_END;
if (*p->pos) {
*err = E_PARSE_ERR;
} else {
*err = E_MISS_END;
}
DestroyParser(p);
DestroyValue(val);
return 0;
@@ -577,6 +669,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 */
@@ -588,21 +731,22 @@ int ParseIdentifier(ParsePtr p, DynamicBuffer *dbuf)
int EvaluateExpr(ParsePtr p, Value *v)
{
int bracketed = 0;
int r;
int nonconst = 0;
expr_node *node = ParseExpr(p, &r);
if (p->isnested) return E_PARSE_ERR; /* Can't nest expressions */
if (!p->pos) return E_PARSE_ERR; /* Missing expression */
while (isempty(*p->pos)) (p->pos)++;
if (*p->pos == BEG_OF_EXPR) {
(p->pos)++;
bracketed = 1;
if (r != OK) {
return r;
}
r = EvalExpr(&(p->pos), v, p);
if (!node) {
return E_SWERR;
}
r = evaluate_expression(node, NULL, v, &nonconst);
free_expr_tree(node);
if (r) return r;
if (bracketed) {
if (*p->pos != END_OF_EXPR) return E_MISS_END;
(p->pos)++;
if (nonconst) {
p->nonconst_expr = 1;
}
return OK;
}
@@ -638,36 +782,36 @@ void Wprint(char const *fmt, ...)
void Eprint(char const *fmt, ...)
{
va_list argptr;
char const *fname;
/* Check if more than one error msg. from this line */
if (!FreshLine && !ShowAllErrors) return;
if (FreshLine && FileName) {
FreshLine = 0;
if (strcmp(FileName, "-")) {
(void) fprintf(ErrFp, "%s(%d): ", FileName, LineNo);
if (print_callstack(ErrFp)) {
(void) fprintf(ErrFp, ": ");
}
} else {
(void) fprintf(ErrFp, "-stdin-(%d): ", LineNo);
if (print_callstack(ErrFp)) {
(void) fprintf(ErrFp, ": ");
}
}
if (DebugFlag & DB_PRTLINE) OutputLine(ErrFp);
} else if (FileName) {
fprintf(ErrFp, " ");
if (print_callstack(ErrFp)) {
(void) fprintf(ErrFp, ": ");
}
if (!FileName) {
return;
}
if (strcmp(FileName, "-")) {
fname = FileName;
} else {
fname = "-stdin-";
}
if (FreshLine) {
(void) fprintf(ErrFp, "%s(%d): ", fname, LineNo);
} else {
fprintf(ErrFp, " ");
}
va_start(argptr, fmt);
(void) vfprintf(ErrFp, fmt, argptr);
(void) fputc('\n', ErrFp);
va_end(argptr);
return;
if (print_callstack(ErrFp)) {
(void) fprintf(ErrFp, "\n");
}
if (FreshLine) {
if (DebugFlag & DB_PRTLINE) OutputLine(ErrFp);
}
FreshLine = 0;
}
/***************************************************************/
@@ -836,6 +980,7 @@ int DoIf(ParsePtr p)
}
}
IfLinenos[NumIfs] = LineNo;
NumIfs++;
IfFlags &= ~(IF_MASK << (2*NumIfs - 2));
IfFlags |= syndrome << (2 * NumIfs - 2);
@@ -900,7 +1045,7 @@ int DoIfTrig(ParsePtr p)
if ((size_t) NumIfs >= IF_NEST) return E_NESTED_IF;
if (ShouldIgnoreLine()) syndrome = IF_TRUE | BEFORE_ELSE;
else {
if ( (r=ParseRem(p, &trig, &tim, 1)) ) return r;
if ( (r=ParseRem(p, &trig, &tim)) ) return r;
if (trig.typ != NO_TYPE) return E_PARSE_ERR;
dse = ComputeTrigger(trig.scanfrom, &trig, &tim, &r, 1);
if (r) {
@@ -1020,8 +1165,8 @@ int DoDebug(ParsePtr p)
case 's':
case 'S':
if (val) DebugFlag |= DB_EXPR_STACKS;
else DebugFlag &= ~DB_EXPR_STACKS;
if (val) DebugFlag |= DB_PARSE_EXPR;
else DebugFlag &= ~DB_PARSE_EXPR;
break;
case 'x':
@@ -1089,7 +1234,7 @@ int DoBanner(ParsePtr p)
}
}
DBufFree(&Banner);
err = DBufPuts(&Banner, DBufValue(&buf));
DBufFree(&buf);
return err;
@@ -1101,7 +1246,6 @@ int DoBanner(ParsePtr p)
/* */
/* Enable or disable the RUN command under program control */
/* */
/* */
/***************************************************************/
int DoRun(ParsePtr p)
{
@@ -1128,6 +1272,38 @@ int DoRun(ParsePtr p)
return VerifyEoln(p);
}
/***************************************************************/
/* */
/* DoExpr */
/* */
/* Enable or disable expression evaluation */
/* */
/***************************************************************/
int DoExpr(ParsePtr p)
{
int r;
DynamicBuffer buf;
DBufInit(&buf);
if ( (r=ParseToken(p, &buf)) ) return r;
/* Only allow EXPR ON in top-level script */
if (! StrCmpi(DBufValue(&buf), "ON")) {
if (TopLevel()) ExpressionEvaluationDisabled = 0;
}
/* But allow EXPR OFF anywhere */
else if (! StrCmpi(DBufValue(&buf), "OFF"))
ExpressionEvaluationDisabled = 1;
else {
DBufFree(&buf);
return E_PARSE_ERR;
}
DBufFree(&buf);
return VerifyEoln(p);
}
/***************************************************************/
/* */
/* DoFlush */
@@ -1733,3 +1909,40 @@ get_month_name(int mon)
if (DynamicMonthName[mon]) return DynamicMonthName[mon];
return MonthName[mon];
}
static int GetOnceDateFromFile(void)
{
FILE *fp;
int once_date = 0;
fp = fopen(OnceFile, "r");
if (fp) {
if (fscanf(fp, "%d", &once_date) != 1) {
once_date = 0;
}
fclose(fp);
}
/* Save today to file */
fp = fopen(OnceFile, "w");
if (!fp) {
Wprint("Warning: Unable to save ONCE timestamp to %s: %s",
OnceFile, strerror(errno));
return once_date;
}
fprintf(fp, "%d\n# This is a timestamp file used by Remind to track ONCE reminders.\n# Do not edit or delete it.\n", DSEToday);
fclose(fp);
return once_date;
}
int GetOnceDate(void)
{
ProcessedOnce = 1;
if (IgnoreOnce || !OnceFile || !*OnceFile) {
return FileAccessDate;
}
if (OnceDate < 0) {
OnceDate = GetOnceDateFromFile();
}
return OnceDate;
}

View File

@@ -6,6 +6,10 @@
#include "config.h"
#ifdef HAVE_STDINT_H
#include <stdint.h>
typedef uint32_t uint32;
#else
#if SIZEOF_UNSIGNED_INT == 4
typedef unsigned int uint32;
#elif SIZEOF_UNSIGNED_LONG == 4
@@ -13,6 +17,7 @@ typedef unsigned long uint32;
#else
# error Could not find a 32-bit integer type
#endif
#endif
struct MD5Context {
uint32 buf[4];
@@ -26,9 +31,4 @@ void MD5Update(struct MD5Context *context, unsigned char const *buf,
void MD5Final(unsigned char digest[16], struct MD5Context *context);
void MD5Transform(uint32 buf[4], uint32 const in[16]);
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
*/
typedef struct MD5Context MD5_CTX;
#endif /* !MD5_H */

View File

@@ -66,7 +66,6 @@
#include <time.h>
#include "types.h"
#include "protos.h"
#include "expr.h"
#include "globals.h"
#include "err.h"
@@ -101,21 +100,12 @@ static double phase (double, double *, double *, double *, double *, double *, d
#define mmlong 64.975464 /* Moon's mean lonigitude at the epoch */
#define mmlongp 349.383063 /* Mean longitude of the perigee at the
epoch */
#define mlnode 151.950429 /* Mean longitude of the node at the
epoch */
#define minc 5.145396 /* Inclination of the Moon's orbit */
#define mecc 0.054900 /* Eccentricity of the Moon's orbit */
#define mangsiz 0.5181 /* Moon's angular size at distance a
from Earth */
#define msmax 384401.0 /* Semi-major axis of Moon's orbit in km */
#define mparallax 0.9507 /* Parallax at distance a from Earth */
#define synmonth 29.53058868 /* Synodic month (new Moon to new Moon) */
#define lunatbase 2423436.0 /* Base date for E. W. Brown's numbered
series of lunations (1923 January 16) */
/* Properties of the Earth */
#define earthrad 6378.16 /* Radius of Earth in kilometres */
#ifdef PI
#undef PI
#endif
@@ -124,11 +114,6 @@ static double phase (double, double *, double *, double *, double *, double *, d
/* Handy mathematical functions */
#ifdef sgn
#undef sgn
#endif
#define sgn(x) (((x) < 0) ? -1 : ((x) > 0 ? 1 : 0)) /* Extract sign */
#ifdef abs
#undef abs
#endif
@@ -144,7 +129,7 @@ static double phase (double, double *, double *, double *, double *, double *, d
/* */
/* jdate */
/* */
/* Convert a date and time to DSE day and fraction. */
/* Convert a date and time to Julian day and fraction. */
/* */
/***************************************************************/
static long jdate(int y, int mon, int day)

View File

@@ -14,13 +14,12 @@
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "types.h"
#include "protos.h"
#include "globals.h"
#include "err.h"
#include "expr.h"
static int BexistsIntArray (int const array[], int num, int key);
static void InsertIntoSortedArray (int *array, int num, int key);
@@ -37,6 +36,8 @@ int NumFullOmits, NumPartialOmits;
/* The structure for saving and restoring OMIT contexts */
typedef struct omitcontext {
struct omitcontext *next;
char *filename;
int lineno;
int numfull, numpart;
int *fullsave;
int *partsave;
@@ -79,19 +80,25 @@ int DoClear(ParsePtr p)
/* */
/* Free all the memory used by saved OMIT contexts. */
/* As a side effect, return the number of OMIT contexts */
/* destroyed. */
/* destroyed. If print_unmatched is true, print an error for */
/* each undestroyed OMIT contect */
/* */
/***************************************************************/
int DestroyOmitContexts(void)
int DestroyOmitContexts(int print_unmatched)
{
OmitContext *c = SavedOmitContexts;
OmitContext *d;
int num = 0;
while (c) {
if (print_unmatched) {
Wprint("Unmatched PUSH-OMIT-CONTEXT at %s(%d)",
c->filename, c->lineno);
}
num++;
if (c->fullsave) free(c->fullsave);
if (c->partsave) free(c->partsave);
if (c->filename) free(c->filename);
d = c->next;
free(c);
c = d;
@@ -116,17 +123,31 @@ int PushOmitContext(ParsePtr p)
context = NEW(OmitContext);
if (!context) return E_NO_MEM;
if (FileName) {
context->filename = StrDup(FileName);
} else {
context->filename = StrDup("");
}
if (!context->filename) {
free(context);
return E_NO_MEM;
}
context->lineno = LineNo;
context->numfull = NumFullOmits;
context->numpart = NumPartialOmits;
context->weekdaysave = WeekdayOmits;
context->fullsave = malloc(NumFullOmits * sizeof(int));
if (NumFullOmits && !context->fullsave) {
free(context->filename);
free(context);
return E_NO_MEM;
}
context->partsave = malloc(NumPartialOmits * sizeof(int));
if (NumPartialOmits && !context->partsave) {
free(context->fullsave);
free(context->filename);
if (context->fullsave) {
free(context->fullsave);
}
free(context);
return E_NO_MEM;
}
@@ -175,6 +196,7 @@ int PopOmitContext(ParsePtr p)
/* Free memory used by the saved context */
if (c->partsave) free(c->partsave);
if (c->fullsave) free(c->fullsave);
if (c->filename) free(c->filename);
free(c);
return VerifyEoln(p);
@@ -379,6 +401,8 @@ int DoOmit(ParsePtr p)
default:
if (tok.type == T_Until) {
Eprint("OMIT: UNTIL not allowed; did you mean THROUGH?");
} else if (tok.type == T_Illegal && tok.val < 0) {
Eprint("%s: `%s'", ErrMsg[-tok.val], DBufValue(&buf));
} else {
Eprint("%s: `%s' (OMIT)", ErrMsg[E_UNKNOWN_TOKEN],
DBufValue(&buf));

View File

@@ -13,6 +13,18 @@
/* Suppress unused variable warnings */
#define UNUSED(x) (void) x
#ifdef HAVE_STRDUP
#define StrDup strdup
#endif
#ifdef HAVE_STRNCASECMP
#define StrinCmp strncasecmp
#endif
#ifdef HAVE_STRCASECMP
#define StrCmpi strcasecmp
#endif
/* Define a string assignment macro - be careful!!! */
#define STRSET(x, str) { if (x) free(x); (x) = StrDup(str); }
@@ -31,22 +43,32 @@
int CallUserFunc (char const *name, int nargs, ParsePtr p);
int DoFset (ParsePtr p);
int DoFunset (ParsePtr p);
void UnsetAllUserFuncs(void);
void ProduceCalendar (void);
char const *SimpleTime (int tim);
char const *CalendarTime (int tim, int duration);
int DoRem (ParsePtr p);
int DoFlush (ParsePtr p);
void DoExit (ParsePtr p);
int ParseRem (ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals);
int ParseRem (ParsePtr s, Trigger *trig, TimeTrig *tim);
int TriggerReminder (ParsePtr p, Trigger *t, TimeTrig *tim, int dse, int is_queued, DynamicBuffer *output);
int ShouldTriggerReminder (Trigger *t, TimeTrig *tim, int dse, int *err);
int DoSubst (ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int dse, int mode);
int DoSubstFromString (char const *source, DynamicBuffer *dbuf, int dse, int tim);
int ParseLiteralDate (char const **s, int *dse, int *tim);
int ParseLiteralDateOrTime (char const **s, int *dse, int *tim);
int ParseLiteralTime (char const **s, int *tim);
expr_node *parse_expression(char const **e, int *r, Var *locals);
int evaluate_expression(expr_node *node, Value *locals, Value *ans, int *nonconst);
int evaluate_expr_node(expr_node *node, Value *locals, Value *ans, int *nonconst);
int truthy(Value const *v);
void print_expr_tree(expr_node *node, FILE *fp);
void unlimit_execution_time(void);
expr_node *free_expr_tree(expr_node *node);
int EvalExpr (char const **e, Value *v, ParsePtr p);
int DoCoerce (char type, Value *v);
void PrintValue (Value *v, FILE *fp);
char const *PrintValue (Value *v, FILE *fp);
int CopyValue (Value *dest, const Value *src);
int ReadLine (void);
int OpenFile (char const *fname);
@@ -65,8 +87,9 @@ int JulianToGregorianOffset(int y, int m);
int ParseChar (ParsePtr p, int *err, int peek);
int ParseToken (ParsePtr p, DynamicBuffer *dbuf);
int ParseIdentifier (ParsePtr p, DynamicBuffer *dbuf);
expr_node * ParseExpr(ParsePtr p, int *r);
void print_expr_nodes_stats(void);
int EvaluateExpr (ParsePtr p, Value *v);
int Evaluate (char const **s, Var *locals, ParsePtr p);
int FnPopValStack (Value *val);
void Eprint (char const *fmt, ...);
void Wprint (char const *fmt, ...);
@@ -86,10 +109,11 @@ int VerifyEoln (ParsePtr p);
int DoDebug (ParsePtr p);
int DoBanner (ParsePtr p);
int DoRun (ParsePtr p);
int DoExpr (ParsePtr p);
int DoErrMsg (ParsePtr p);
int ClearGlobalOmits (void);
int DoClear (ParsePtr p);
int DestroyOmitContexts (void);
int DestroyOmitContexts (int print_unmatched);
int PushOmitContext (ParsePtr p);
int PopOmitContext (ParsePtr p);
int IsOmitted (int dse, int localomit, char const *omitfunc, int *omit);
@@ -103,13 +127,26 @@ int ComputeTrigger (int today, Trigger *trig, TimeTrig *tim, int *err, int save_
int ComputeTriggerNoAdjustDuration (int today, Trigger *trig, TimeTrig *tim, int *err, int save_in_globals, int duration_days);
int AdjustTriggerForDuration(int today, int r, Trigger *trig, TimeTrig *tim, int save_in_globals);
char *StrnCpy (char *dest, char const *source, int n);
#ifndef HAVE_STRNCASECMP
int StrinCmp (char const *s1, char const *s2, int n);
#endif
#ifndef HAVE_STRDUP
char *StrDup (char const *s);
#endif
#ifndef HAVE_STRCASECMP
int StrCmpi (char const *s1, char const *s2);
#endif
void strtolower(char *s);
Var *FindVar (char const *str, int create);
SysVar *FindSysVar (char const *name);
int DeleteVar (char const *str);
int SetVar (char const *str, Value 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 DoUnset (Parser *p);
int DoDump (ParsePtr p);
@@ -122,10 +159,10 @@ int DoMsgCommand (char const *cmd, char const *msg, int is_queued);
int ParseNonSpaceChar (ParsePtr p, int *err, int peek);
unsigned int HashVal (char const *str);
int DateOK (int y, int m, int d);
Operator *FindOperator (char const *name, Operator where[], int num);
BuiltinFunc *FindFunc (char const *name, BuiltinFunc where[], int num);
BuiltinFunc *FindBuiltinFunc (char const *name);
int InsertIntoSortBuffer (int dse, int tim, char const *body, int typ, int prio);
void IssueSortedReminders (void);
UserFunc *FindUserFunc(char const *name);
int UserFuncExists (char const *fn);
void DSEToHeb (int dse, int *hy, int *hm, int *hd);
int HebNameToNum (char const *mname);
@@ -181,17 +218,35 @@ int GetTerminalBackground(void);
char const *get_day_name(int wkday);
char const *get_month_name(int mon);
void set_cloexec(int fd);
void set_cloexec(FILE *fp);
int push_call(char const *filename, char const *func, int lineno);
void clear_callstack(void);
int print_callstack(FILE *fp);
int have_callstack(void);
void pop_call(void);
void FixSpecialType(Trigger *trig);
void WriteJSONTrigger(Trigger const *t, int include_tags, int today);
void WriteJSONTimeTrigger(TimeTrig const *tt);
int GetOnceDate(void);
#ifdef REM_USE_WCHAR
#define _XOPEN_SOURCE 600
#include <wctype.h>
#include <wchar.h>
void PutWideChar(wchar_t const wc, DynamicBuffer *output);
#endif
/* These functions are in utils.c and are used to detect overflow
in various arithmetic operators. They have to be in separate
functions with extern linkage to defeat compiler optimizations
that would otherwise break the overflow checks. */
extern int _private_mul_overflow(int a, int b);
extern int _private_add_overflow(int a, int b);
extern int _private_sub_overflow(int a, int b);
/* Utility functions for dumping tokens */
void print_sysvar_tokens(void);
void print_builtinfunc_tokens(void);
void print_remind_tokens(void);
void get_var_hash_stats(int *total, int *maxlen, double *avglen);
void get_userfunc_hash_stats(int *total, int *maxlen, double *avglen);

View File

@@ -34,7 +34,6 @@
#include "globals.h"
#include "err.h"
#include "protos.h"
#include "expr.h"
#undef USE_INOTIFY
#if defined(HAVE_SYS_INOTIFY_H) && defined(HAVE_INOTIFY_INIT1)
@@ -66,6 +65,7 @@ typedef struct queuedrem {
char sched[VAR_NAME_LEN+1];
Trigger t;
TimeTrig tt;
int red, green, blue;
} QueuedRem;
/* Global variables */
@@ -79,7 +79,7 @@ static void CheckInitialFile (void);
static int CalculateNextTime (QueuedRem *q);
static QueuedRem *FindNextReminder (void);
static int CalculateNextTimeUsingSched (QueuedRem *q);
static void DaemonWait (struct timeval *sleep_tv);
static void ServerWait (struct timeval *sleep_tv);
static void reread (void);
static void PrintQueue(void);
static char const *QueueFilename(char const *fname);
@@ -206,6 +206,9 @@ int QueueReminder(ParsePtr p, Trigger *trig,
if (!qelem) {
return E_NO_MEM;
}
qelem->red = DefaultColorR;
qelem->green = DefaultColorG;
qelem->blue = DefaultColorB;
qelem->text = StrDup(p->pos); /* Guaranteed that parser is not nested. */
if (!qelem->text) {
free(qelem);
@@ -307,6 +310,12 @@ void HandleQueuedReminders(void)
struct sigaction sa;
char qid[64];
/* Disable any potential pending SIGALRMs */
alarm(0);
/* Un-limit execution time */
unlimit_execution_time();
/* Turn off sorting -- otherwise, TriggerReminder has no effect! */
SortByDate = 0;
@@ -350,16 +359,15 @@ void HandleQueuedReminders(void)
if (ShouldFork || Daemon) {
sa.sa_handler = SigIntHandler;
sa.sa_flags = 0;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
(void) sigaction(SIGINT, &sa, NULL);
sa.sa_handler = SigContHandler;
(void) sigaction(SIGCONT, &sa, NULL);
}
#ifdef USE_INOTIFY
if (IsServerMode()) {
watch_fd = setup_inotify_watch();
}
watch_fd = setup_inotify_watch();
#endif
/* Sit in a loop, issuing reminders when necessary */
while(1) {
@@ -386,8 +394,6 @@ void HandleQueuedReminders(void)
SleepTime = 60*Daemon;
}
/* Wake up once a minute to recalibrate sleep time in
case of laptop hibernation */
if (IsServerMode()) {
/* Wake up on the next exact minute */
gettimeofday(&tv, NULL);
@@ -398,7 +404,7 @@ void HandleQueuedReminders(void)
} else {
sleep_tv.tv_usec = 0;
}
DaemonWait(&sleep_tv);
ServerWait(&sleep_tv);
/* A DEL command might have deleted our queued reminder! */
q = FindNextReminder();
} else {
@@ -418,7 +424,9 @@ void HandleQueuedReminders(void)
}
}
if (Daemon > 0 && SleepTime) CheckInitialFile();
if (Daemon > 0 && SleepTime) {
CheckInitialFile();
}
if (Daemon && !q) {
if (IsServerMode()) {
@@ -469,10 +477,15 @@ void HandleQueuedReminders(void)
and trigtime() work correctly */
SaveAllTriggerInfo(&(q->t), &(q->tt), DSEToday, q->tt.ttime, 1);
FileName = (char *) q->fname;
DefaultColorR = q->red;
DefaultColorG = q->green;
DefaultColorB = q->blue;
/* Make a COPY of q->t because TriggerReminder can change q->t.typ */
Trigger tcopy = q->t;
if (DaemonJSON) {
DynamicBuffer out;
DBufInit(&out);
(void) TriggerReminder(&p, &q->t, &q->tt, DSEToday, 1, &out);
(void) TriggerReminder(&p, &tcopy, &q->tt, DSEToday, 1, &out);
if (q->typ != RUN_TYPE) {
printf("\"body\":\"");
chomp(&out);
@@ -481,7 +494,7 @@ void HandleQueuedReminders(void)
}
DBufFree(&out);
} else {
(void) TriggerReminder(&p, &q->t, &q->tt, DSEToday, 1, NULL);
(void) TriggerReminder(&p, &tcopy, &q->tt, DSEToday, 1, NULL);
}
FileName = NULL;
if (IsServerMode() && !DaemonJSON && q->typ != RUN_TYPE) {
@@ -630,7 +643,25 @@ static void CheckInitialFile(void)
/* If date has rolled around, or file has changed, spawn a new version. */
time_t tim = FileModTime;
int y, m, d;
#ifdef USE_INOTIFY
char buf[sizeof(struct inotify_event) + NAME_MAX + 1];
int n;
#endif
#ifdef USE_INOTIFY
/* If there are any inotify events, reread */
if (watch_fd >= 0) {
while(1) {
n = read(watch_fd, buf, sizeof(buf));
if (n < 0 && errno == EINTR) continue;
if (n > 0) {
close(watch_fd);
reread();
}
break;
}
}
#endif
if (stat(InitialFile, &StatBuf) == 0) tim = StatBuf.st_mtime;
if (tim != FileModTime ||
RealToday != SystemDate(&y, &m, &d)) {
@@ -740,7 +771,10 @@ json_queue(QueuedRem const *q)
case PS_TYPE: PrintJSONKeyPairString("type", "PS_TYPE"); break;
case PSF_TYPE: PrintJSONKeyPairString("type", "PSF_TYPE"); break;
case MSF_TYPE: PrintJSONKeyPairString("type", "MSF_TYPE"); break;
case PASSTHRU_TYPE: PrintJSONKeyPairString("type", "PASSTHRU_TYPE"); break;
case PASSTHRU_TYPE:
PrintJSONKeyPairString("type", "PASSTHRU_TYPE");
PrintJSONKeyPairString("passthru", q->passthru);
break;
default: PrintJSONKeyPairString("type", "?"); break;
}
@@ -766,12 +800,12 @@ json_queue(QueuedRem const *q)
/***************************************************************/
/* */
/* DaemonWait */
/* ServerWait */
/* */
/* Sleep or read command from stdin in "daemon -1" mode */
/* Sleep or read command from stdin in server mode */
/* */
/***************************************************************/
static void DaemonWait(struct timeval *sleep_tv)
static void ServerWait(struct timeval *sleep_tv)
{
fd_set readSet;
int retval;

View File

@@ -18,7 +18,6 @@
#include <stdlib.h>
#include "types.h"
#include "protos.h"
#include "expr.h"
#include "globals.h"
#include "err.h"

View File

@@ -39,23 +39,24 @@ while (isdigit(*(string))) { \
Token TokArray[] = {
/* NAME MINLEN TYPE VALUE */
{ "addomit", 7, T_AddOmit, 0 },
{ "after", 3, T_Skip, AFTER_SKIP },
{ "after", 5, T_Skip, AFTER_SKIP },
{ "april", 3, T_Month, 3 },
{ "at", 2, T_At, 0 },
{ "august", 3, T_Month, 7 },
{ "banner", 3, T_Banner, 0 },
{ "before", 3, T_Skip, BEFORE_SKIP },
{ "before", 6, T_Skip, BEFORE_SKIP },
{ "cal", 3, T_RemType, CAL_TYPE },
{ "clear-omit-context", 5, T_Clr, 0 },
{ "debug", 5, T_Debug, 0 },
{ "december", 3, T_Month, 11 },
{ "do", 2, T_IncludeR, 0 },
{ "dumpvars", 4, T_Dumpvars, 0 },
{ "duration", 3, T_Duration, 0 },
{ "duration", 8, T_Duration, 0 },
{ "else", 4, T_Else, 0 },
{ "endif", 5, T_EndIf, 0 },
{ "errmsg", 6, T_ErrMsg, 0 },
{ "exit", 4, T_Exit, 0 },
{ "expr", 4, T_Expr, 0 },
{ "february", 3, T_Month, 1 },
{ "first", 5, T_Ordinal, 0 },
{ "flush", 5, T_Flush, 0 },
@@ -84,9 +85,9 @@ Token TokArray[] = {
{ "noqueue", 7, T_NoQueue, 0 },
{ "november", 3, T_Month, 10 },
{ "october", 3, T_Month, 9 },
{ "omit", 3, T_Omit, 0 },
{ "omit", 4, T_Omit, 0 },
{ "omitfunc", 8, T_OmitFunc, 0 },
{ "once", 3, T_Once, 0 },
{ "once", 4, T_Once, 0 },
{ "pop-omit-context", 3, T_Pop, 0 },
{ "preserve", 8, T_Preserve, 0 },
{ "priority", 8, T_Priority, 0 },
@@ -102,7 +103,7 @@ Token TokArray[] = {
{ "second", 6, T_Ordinal, 1 },
{ "september", 3, T_Month, 8 },
{ "set", 3, T_Set, 0 },
{ "skip", 3, T_Skip, SKIP_SKIP },
{ "skip", 4, T_Skip, SKIP_SKIP },
{ "special", 7, T_RemType, PASSTHRU_TYPE },
{ "sunday", 3, T_WkDay, 6 },
{ "tag", 3, T_Tag, 0 },
@@ -111,13 +112,28 @@ Token TokArray[] = {
{ "thursday", 3, T_WkDay, 3 },
{ "tuesday", 3, T_WkDay, 1 },
{ "unset", 5, T_UnSet, 0 },
{ "until", 3, T_Until, 0 },
{ "until", 5, T_Until, 0 },
{ "warn", 4, T_Warn, 0 },
{ "wednesday", 3, T_WkDay, 2 }
};
static int TokStrCmp (Token const *t, char const *s);
static void
init_token(Token *t)
{
t->name = NULL;
t->type = T_Illegal;
t->val = 0;
}
static void
token_error(Token *t, int errcode)
{
t->type = T_Illegal;
t->val = -errcode;
}
/***************************************************************/
/* */
/* FindInitialToken */
@@ -131,7 +147,7 @@ char const *FindInitialToken(Token *tok, char const *s)
DynamicBuffer buf;
DBufInit(&buf);
tok->type = T_Illegal;
init_token(tok);
while (isempty(*s)) s++;
@@ -158,7 +174,7 @@ void FindToken(char const *s, Token *tok)
int top, bot, mid, r, max;
int l;
tok->type = T_Illegal;
init_token(tok);
if (! *s) {
tok->type = T_Empty;
return;
@@ -232,9 +248,9 @@ void FindNumericToken(char const *s, Token *t)
int mult = 1, hour, min;
char const *s_orig = s;
int ampm = 0;
int r;
t->type = T_Illegal;
t->val = 0;
init_token(t);
if (isdigit(*s)) {
PARSENUM(t->val, s);
@@ -242,22 +258,37 @@ void FindNumericToken(char const *s, Token *t)
if (*s == '-' || *s == '/') {
char const *p = s_orig;
int dse, tim;
if (ParseLiteralDate(&p, &dse, &tim) == OK) {
if (*p) return;
r = ParseLiteralDateOrTime(&p, &dse, &tim);
if (r == OK) {
if (*p) {
if (tim == NO_TIME) {
t->val = -E_BAD_DATE;
} else {
t->val = -E_BAD_TIME;
}
return;
}
if (tim == NO_TIME) {
t->type = T_Date;
t->val = dse;
return;
}
if (dse == NO_DATE) {
t->type = T_Time;
t->val = tim;
return;
}
t->type = T_DateTime;
t->val = MINUTES_PER_DAY * dse + tim;
}
} else {
token_error(t, r);
}
return;
}
/* If we hit a comma, swallow it. This allows stuff
like Jan 6, 1998 */
if (*s == ',') {
if (*s == ',' && *(s+1) == 0) {
/* Classify the number we've got */
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;
@@ -268,8 +299,16 @@ void FindNumericToken(char const *s, Token *t)
if (*s == ':' || *s == '.' || *s == TimeSep) {
s++;
hour = t->val;
if (!isdigit(*s)) {
token_error(t, E_BAD_TIME);
return;
}
PARSENUM(min, s);
if (min > 59) return; /* Illegal time */
if (min > 59) {
/* Illegal time */
token_error(t, E_BAD_TIME);
return;
}
/* Check for p[m] or a[m] */
if (*s == 'A' || *s == 'a' || *s == 'P' || *s == 'p') {
ampm = tolower(*s);
@@ -278,9 +317,15 @@ void FindNumericToken(char const *s, Token *t)
s++;
}
}
if (*s) return; /* Illegal time */
if (*s) {
token_error(t, E_BAD_TIME);
return;
}
if (ampm) {
if (hour < 1 || hour > 12) return;
if (hour < 1 || hour > 12) {
token_error(t, E_BAD_TIME);
return;
}
if (ampm == 'a') {
if (hour == 12) {
hour = 0;
@@ -302,45 +347,70 @@ void FindNumericToken(char const *s, Token *t)
}
/* If we hit a non-digit, error! */
if (*s) return;
if (*s) {
token_error(t, E_BAD_NUMBER);
return;
}
/* Classify the number we've got */
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 t->type = T_Number;
return;
} else if (*s == '*') {
}
switch (*s) {
case '*':
s++;
PARSENUM(t->val, s);
if (*s) return; /* Illegal token if followed by non-numeric char */
if (*s) {
/* Illegal token if followed by non-numeric char */
token_error(t, E_BAD_NUMBER);
return;
}
t->type = T_Rep;
return;
} else if (*s == '+') {
case '+':
s++;
if (*s == '+') { mult = -1; s++; }
PARSENUM(t->val, s);
if (*s) return; /* Illegal token if followed by non-numeric char */
if (*s) {
/* Illegal token if followed by non-numeric char */
token_error(t, E_BAD_NUMBER);
return;
}
t->type = T_Delta;
t->val *= mult;
return;
} else if (*s == '-') {
case '-':
s++;
if (*s == '-') { mult = -1; s++; }
PARSENUM(t->val, s);
if (*s) return; /* Illegal token if followed by non-numeric char */
if (*s) {
/* Illegal token if followed by non-numeric char */
token_error(t, E_BAD_NUMBER);
return;
}
t->type = T_Back;
t->val *= mult;
return;
} else if (*s == '~') {
case '~':
s++;
if (*s == '~') { mult = -1; s++; }
PARSENUM(t->val, s);
if (*s) return; /* Illegal token if followed by non-numeric char */
if (*s) {
/* Illegal token if followed by non-numeric char */
token_error(t, E_BAD_NUMBER);
return;
}
t->type = T_BackAdj;
t->val *= mult;
return;
default: return;
}
return; /* Unknown token type */
}
@@ -367,3 +437,43 @@ static int TokStrCmp(Token const *t, char const *s)
if (!*s || (*s == ',' && !*(s+1))) return 0;
return (*tk - tolower(*s));
}
static void
print_token(Token *tok)
{
if (tok->MinLen < (int) strlen(tok->name)) {
printf("%.*s\n", tok->MinLen, tok->name);
}
printf("%s\n", tok->name);
}
void
print_remind_tokens(void)
{
int i;
Token *tok;
int num = (int) (sizeof(TokArray) / sizeof(TokArray[0]));
printf("# Remind Tokens\n\n");
for (i=0; i<num; i++) {
tok = &TokArray[i];
if (tok->type != T_Month && tok->type != T_WkDay) {
print_token(tok);
}
}
printf("\n# Month Names\n\n");
for (i=0; i<num; i++) {
tok = &TokArray[i];
if (tok->type == T_Month) {
print_token(tok);
}
}
printf("\n# Weekdays\n\n");
for (i=0; i<num; i++) {
tok = &TokArray[i];
if (tok->type == T_WkDay) {
print_token(tok);
}
}
}

View File

@@ -15,7 +15,6 @@
#include <stdlib.h>
#include "types.h"
#include "expr.h"
#include "protos.h"
#include "globals.h"
#include "err.h"

View File

@@ -13,6 +13,22 @@
#include <limits.h>
#include "dynbuf.h"
typedef struct udf_struct UserFunc;
/* Define the types of values */
#define ERR_TYPE 0
#define INT_TYPE 1
#define TIME_TYPE 2
#define DATE_TYPE 3
#define STR_TYPE 4
#define DATETIME_TYPE 5
#define SPECIAL_TYPE 6 /* Only for system variables */
#define CONST_INT_TYPE 7 /* Only for system variables */
#define BEG_OF_EXPR '['
#define END_OF_EXPR ']'
#define COMMA ','
/* Values */
typedef struct {
char type;
@@ -22,29 +38,62 @@ typedef struct {
} v;
} Value;
/* Define the type of operators */
typedef struct {
char const *name;
char prec;
char type;
int (*func)(void);
} Operator;
/* New-style expr_node structure and constants */
enum expr_node_type
{
N_FREE = 0,
N_CONSTANT,
N_SHORT_STR,
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,
N_ERROR = 32767,
};
/* Structure for passing in Nargs and out RetVal from functions */
typedef struct {
int nargs;
Value *args;
Value retval;
} func_info;
/* Forward reference */
typedef struct expr_node_struct expr_node;
/* Define the type of user-functions */
typedef struct {
char const *name;
char minargs;
char maxargs;
char is_constant;
/* Old-style function calling convention */
int (*func)(func_info *);
/* New-style function calling convention */
int (*newfunc)(expr_node *node, Value *locals, Value *ans, int *nonconst);
} BuiltinFunc;
#define SHORT_NAME_BUF 16
typedef struct expr_node_struct {
struct expr_node_struct *child;
struct expr_node_struct *sibling;
enum expr_node_type type;
int num_kids;
union {
Value value;
int arg;
BuiltinFunc *builtin_func;
char name[SHORT_NAME_BUF];
int (*operator_func) (struct expr_node_struct *node, Value *locals, Value *ans, int *nonconst);
} u;
} expr_node;
/* Define the structure of a variable */
typedef struct var {
struct var *next;
@@ -142,6 +191,8 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */
#define MSF_TYPE 7
#define PASSTHRU_TYPE 8
/* For function arguments */
#define NO_MAX 127
/* DEFINES for debugging flags */
#define DB_PRTLINE 1
@@ -150,7 +201,7 @@ typedef Parser *ParsePtr; /* Pointer to parser structure */
#define DB_DUMP_VARS 8
#define DB_ECHO_LINE 16
#define DB_TRACE_FILES 32
#define DB_EXPR_STACKS 64
#define DB_PARSE_EXPR 64
/* Enumeration of the tokens */
enum TokTypes
@@ -184,7 +235,8 @@ enum TokTypes
T_MaybeUncomputable,
T_Ordinal,
T_In,
T_LastBack
T_LastBack,
T_Expr
};
/* The structure of a token */
@@ -244,3 +296,27 @@ typedef struct {
#define TERMINAL_BACKGROUND_UNKNOWN -1
#define TERMINAL_BACKGROUND_DARK 0
#define TERMINAL_BACKGROUND_LIGHT 1
typedef int (*SysVarFunc)(int, Value *);
/* The structure of a system variable */
typedef struct {
char const *name;
char modifiable;
int type;
void *value;
int min; /* Or const-value */
int max;
} SysVar;
/* Define the data structure used to hold a user-defined function */
typedef struct udf_struct {
struct udf_struct *next;
char name[VAR_NAME_LEN+1];
expr_node *node;
char **args;
int nargs;
char const *filename;
int lineno;
int recurse_flag;
} UserFunc;

View File

@@ -16,43 +16,46 @@
#include <stdio.h>
#include <ctype.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <string.h>
#include <stdlib.h>
#include "types.h"
#include "globals.h"
#include "protos.h"
#include "err.h"
#include "expr.h"
#define FUNC_HASH_SIZE 32 /* Size of User-defined function hash table */
/* Define the data structure used to hold a user-defined function */
typedef struct udf_struct {
struct udf_struct *next;
char name[VAR_NAME_LEN+1];
char const *text;
Var *locals;
char IsActive;
int nargs;
char const *filename;
int lineno;
} UserFunc;
#define FUNC_HASH_SIZE 31 /* Size of User-defined function hash table */
/* The hash table */
static UserFunc *FuncHash[FUNC_HASH_SIZE];
/* Access to built-in functions */
extern int NumFuncs;
extern BuiltinFunc Func[];
/* We need access to the expression evaluation stack */
extern Value ValStack[];
extern int ValStackPtr;
static void DestroyUserFunc (UserFunc *f);
static void FUnset (char const *name);
static void FSet (UserFunc *f);
static int SetUpLocalVars (UserFunc *f);
static void DestroyLocalVals (UserFunc *f);
/***************************************************************/
/* */
/* HashVal */
/* Given a string, compute the hash value. */
/* */
/***************************************************************/
unsigned int HashVal_nocase(char const *str)
{
unsigned int h = 0, high;
while(*str) {
h = (h << 4) + (unsigned int) *str;
str++;
high = h & 0xF0000000;
if (high) {
h ^= (high >> 24);
}
h &= ~high;
}
return h;
}
/***************************************************************/
/* */
@@ -75,6 +78,7 @@ int DoFunset(ParsePtr p)
break;
}
seen_one = 1;
strtolower(DBufValue(&buf));
FUnset(DBufValue(&buf));
DBufFree(&buf);
}
@@ -93,8 +97,11 @@ int DoFset(ParsePtr p)
{
int r;
int c;
int i;
UserFunc *func;
Var *v;
UserFunc *existing;
Var *locals = NULL;
Var local_array[MAX_FUNC_ARGS];
int orig_namelen;
DynamicBuffer buf;
@@ -108,6 +115,25 @@ int DoFset(ParsePtr p)
}
orig_namelen = buf.len;
/* 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;
}
/* Warn about redefinition */
Wprint("Function %s redefined (previously defined at %s:%d)",
existing->name, existing->filename, existing->lineno);
}
/* Should be followed by '(' */
c = ParseNonSpaceChar(p, &r, 0);
if (r) {
@@ -134,28 +160,26 @@ int DoFset(ParsePtr p)
return E_NO_MEM;
}
func->lineno = LineNo;
func->recurse_flag = 0;
StrnCpy(func->name, DBufValue(&buf), VAR_NAME_LEN);
DBufFree(&buf);
if (!Hush) {
if (FindFunc(func->name, Func, NumFuncs)) {
if (FindBuiltinFunc(func->name)) {
Eprint("%s: `%s'", ErrMsg[E_REDEF_FUNC], func->name);
}
}
func->locals = NULL;
func->text = NULL;
func->IsActive = 0;
func->node = NULL;
func->nargs = 0;
func->args = NULL;
/* Get the local variables - we insert the local variables in REVERSE
order, but that's OK, because we pop them off the stack in reverse
order, too, so everything works out just fine. */
/* Get the local variables */
c=ParseNonSpaceChar(p, &r, 1);
if (r) return r;
if (c == ')') {
(void) ParseNonSpaceChar(p, &r, 0);
}
else {
} else {
locals = local_array;
while(1) {
if ( (r=ParseIdentifier(p, &buf)) ) return r;
if (*DBufValue(&buf) == '$') {
@@ -163,19 +187,31 @@ int DoFset(ParsePtr p)
DestroyUserFunc(func);
return E_BAD_ID;
}
v = NEW(Var);
if (!v) {
DBufFree(&buf);
DestroyUserFunc(func);
return E_NO_MEM;
}
/* If we've already seen this local variable, error */
for (i=0; i<func->nargs; i++) {
if (!StrinCmp(DBufValue(&buf), local_array[i].name, VAR_NAME_LEN)) {
DBufFree(&buf);
DestroyUserFunc(func);
return E_REPEATED_ARG;
}
}
i = func->nargs;
if (i >= MAX_FUNC_ARGS-1) {
DBufFree(&buf);
DestroyUserFunc(func);
return E_2MANY_ARGS;
}
local_array[i].v.type = ERR_TYPE;
StrnCpy(local_array[i].name, DBufValue(&buf), VAR_NAME_LEN);
local_array[i].next = &(local_array[i+1]);
local_array[i+1].next = NULL;
func->nargs++;
v->v.type = ERR_TYPE;
StrnCpy(v->name, DBufValue(&buf), VAR_NAME_LEN);
DBufFree(&buf);
v->next = func->locals;
func->locals = v;
c = ParseNonSpaceChar(p, &r, 0);
if (r) {
DBufFree(&buf);
DestroyUserFunc(func);
return r;
}
if (c == ')') break;
else if (c != ',') {
DestroyUserFunc(func);
@@ -186,20 +222,50 @@ int DoFset(ParsePtr p)
/* Allow an optional = sign: FSET f(x) = x*x */
c = ParseNonSpaceChar(p, &r, 1);
if (r) {
DestroyUserFunc(func);
return r;
}
if (c == '=') {
(void) ParseNonSpaceChar(p, &r, 0);
}
/* Copy the text over */
if (p->isnested) {
Eprint("%s", ErrMsg[E_CANTNEST_FDEF]);
DestroyUserFunc(func);
return E_PARSE_ERR;
}
func->text = StrDup(p->pos);
if (!func->text) {
DestroyUserFunc(func);
return E_NO_MEM;
while(*(p->pos) && isspace(*(p->pos))) {
p->pos++;
}
if (!*(p->pos)) {
DestroyUserFunc(func);
return E_EOLN;
}
/* Parse the expression */
func->node = parse_expression(&(p->pos), &r, locals);
if (!func->node) {
DestroyUserFunc(func);
return r;
}
c = ParseNonSpaceChar(p, &r, 1);
if (c != 0 || r != 0) {
DestroyUserFunc(func);
if (r != 0) return r;
return E_EXPECTING_EOL;
}
/* Save the argument names */
if (func->nargs) {
func->args = calloc(func->nargs, sizeof(char *));
for (i=0; i<func->nargs; i++) {
func->args[i] = StrDup(local_array[i].name);
if (!func->args[i]) {
DestroyUserFunc(func);
return E_NO_MEM;
}
}
}
/* If an old definition of this function exists, destroy it */
@@ -223,23 +289,22 @@ int DoFset(ParsePtr p)
/***************************************************************/
static void DestroyUserFunc(UserFunc *f)
{
Var *v, *prev;
/* Free the local variables first */
v = f->locals;
while(v) {
DestroyValue(v->v);
prev = v;
v = v->next;
free(prev);
}
int i;
/* Free the function definition */
if (f->text) free( (char *) f->text);
if (f->node) free_expr_tree(f->node);
/* Free the filename */
if (f->filename) free( (char *) f->filename);
/* Free arg names */
if (f->args) {
for (i=0; i<f->nargs; i++) {
if (f->args[i]) free(f->args[i]);
}
free(f->args);
}
/* Free the data structure itself */
free(f);
}
@@ -257,12 +322,12 @@ static void FUnset(char const *name)
UserFunc *cur, *prev;
int h;
h = HashVal(name) % FUNC_HASH_SIZE;
h = HashVal_nocase(name) % FUNC_HASH_SIZE;
cur = FuncHash[h];
prev = NULL;
while(cur) {
if (! StrinCmp(name, cur->name, VAR_NAME_LEN)) break;
if (! strncmp(name, cur->name, VAR_NAME_LEN)) break;
prev = cur;
cur = cur->next;
}
@@ -280,134 +345,22 @@ static void FUnset(char const *name)
/***************************************************************/
static void FSet(UserFunc *f)
{
int h = HashVal(f->name) % FUNC_HASH_SIZE;
int h = HashVal_nocase(f->name) % FUNC_HASH_SIZE;
f->next = FuncHash[h];
FuncHash[h] = f;
}
/***************************************************************/
/* */
/* CallUserFunc */
/* */
/* Call a user-defined function. */
/* */
/***************************************************************/
int CallUserFunc(char const *name, int nargs, ParsePtr p)
UserFunc *FindUserFunc(char const *name)
{
UserFunc *f;
int h = HashVal(name) % FUNC_HASH_SIZE;
int i;
char const *s;
UserFunc *f;
int h = HashVal_nocase(name) % FUNC_HASH_SIZE;
/* Search for the function */
f = FuncHash[h];
while (f && StrinCmp(name, f->name, VAR_NAME_LEN)) f = f->next;
if (!f) {
Eprint("%s: `%s'", ErrMsg[E_UNDEF_FUNC], name);
return E_UNDEF_FUNC;
}
/* Debugging stuff */
if (DebugFlag & DB_PRTEXPR) {
fprintf(ErrFp, "%s %s(", ErrMsg[E_ENTER_FUN], f->name);
for (i=0; i<nargs; i++) {
PrintValue(&ValStack[ValStackPtr - nargs + i], ErrFp);
if (i<nargs-1) fprintf(ErrFp, ", ");
}
fprintf(ErrFp, ")\n");
}
/* Detect illegal recursive call */
if (f->IsActive) {
if (DebugFlag &DB_PRTEXPR) {
fprintf(ErrFp, "%s %s() => ", ErrMsg[E_LEAVE_FUN], name);
fprintf(ErrFp, "%s\n", ErrMsg[E_RECURSIVE]);
}
return E_RECURSIVE;
}
/* Check number of args */
if (nargs != f->nargs) {
if (DebugFlag &DB_PRTEXPR) {
fprintf(ErrFp, "%s %s() => ", ErrMsg[E_LEAVE_FUN], name);
fprintf(ErrFp, "%s\n",
ErrMsg[(nargs < f->nargs) ? E_2FEW_ARGS : E_2MANY_ARGS]);
}
return (nargs < f->nargs) ? E_2FEW_ARGS : E_2MANY_ARGS;
}
/* Found the function - set up a local variable frame */
h = SetUpLocalVars(f);
if (h) {
if (DebugFlag &DB_PRTEXPR) {
fprintf(ErrFp, "%s %s() => ", ErrMsg[E_LEAVE_FUN], name);
fprintf(ErrFp, "%s\n", ErrMsg[h]);
}
return h;
}
/* Evaluate the expression */
f->IsActive = 1;
s = f->text;
/* Skip the opening bracket, if there's one */
while (isempty(*s)) s++;
if (*s == BEG_OF_EXPR) {
s++;
}
push_call(f->filename, f->name, f->lineno);
h = Evaluate(&s, f->locals, p);
if (h == OK) {
pop_call();
}
f->IsActive = 0;
DestroyLocalVals(f);
if (DebugFlag &DB_PRTEXPR) {
fprintf(ErrFp, "%s %s() => ", ErrMsg[E_LEAVE_FUN], name);
if (h) fprintf(ErrFp, "%s\n", ErrMsg[h]);
else {
PrintValue(&ValStack[ValStackPtr-1], ErrFp);
fprintf(ErrFp, "\n");
}
}
return h;
/* Search for the function */
f = FuncHash[h];
while (f && strncmp(name, f->name, VAR_NAME_LEN)) f = f->next;
return f;
}
/***************************************************************/
/* */
/* SetUpLocalVars */
/* */
/* Set up the local variables from the stack frame. */
/* */
/***************************************************************/
static int SetUpLocalVars(UserFunc *f)
{
int i, r;
Var *var;
for (i=0, var=f->locals; var && i<f->nargs; var=var->next, i++) {
if ( (r=FnPopValStack(&(var->v))) ) {
DestroyLocalVals(f);
return r;
}
}
return OK;
}
/***************************************************************/
/* */
/* DestroyLocalVals */
/* */
/* Destroy the values of all local variables after evaluating */
/* the function. */
/* */
/***************************************************************/
static void DestroyLocalVals(UserFunc *f)
{
Var *v = f->locals;
while(v) {
DestroyValue(v->v);
v = v->next;
}
}
/***************************************************************/
/* */
/* UserFuncExists */
@@ -418,12 +371,58 @@ static void DestroyLocalVals(UserFunc *f)
/***************************************************************/
int UserFuncExists(char const *fn)
{
UserFunc *f;
int h = HashVal(fn) % FUNC_HASH_SIZE;
UserFunc *f = FindUserFunc(fn);
f = FuncHash[h];
while (f && StrinCmp(fn, f->name, VAR_NAME_LEN)) f = f->next;
if (!f) return -1;
else return f->nargs;
}
/***************************************************************/
/* */
/* UnsetAllUserFuncs */
/* */
/* Call FUNSET on all user funcs. Used with -ds flag to */
/* ensure no expr_node memory leaks. */
/* */
/***************************************************************/
void
UnsetAllUserFuncs(void)
{
UserFunc *f;
UserFunc *next;
int i;
for (i=0; i<FUNC_HASH_SIZE; i++) {
f = FuncHash[i];
while(f) {
next = f->next;
DestroyUserFunc(f);
f = next;
}
FuncHash[i] = NULL;
}
}
void
get_userfunc_hash_stats(int *total, int *maxlen, double *avglen)
{
int len;
int i;
UserFunc *f;
*maxlen = 0;
*total = 0;
for (i=0; i<FUNC_HASH_SIZE; i++) {
len = 0;
f = FuncHash[i];
while(f) {
len++;
(*total)++;
f = f->next;
}
if (len > *maxlen) {
*maxlen = len;
}
}
*avglen = (double) *total / (double) FUNC_HASH_SIZE;
}

View File

@@ -17,6 +17,11 @@ static char const DontEscapeMe[] =
#include "err.h"
#include <string.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include <stdio.h>
#include <ctype.h>
@@ -46,6 +51,7 @@ char *StrnCpy(char *dest, char const *source, int n)
return odest;
}
#ifndef HAVE_STRNCASECMP
/***************************************************************/
/* */
/* StrinCmp - compare strings, case-insensitive */
@@ -64,6 +70,9 @@ int StrinCmp(char const *s1, char const *s2, int n)
if (n) return (toupper(*s1) - toupper(*s2)); else return 0;
}
#endif
#ifndef HAVE_STRDUP
/***************************************************************/
/* */
/* StrDup */
@@ -79,6 +88,9 @@ char *StrDup(char const *s)
return ret;
}
#endif
#ifndef HAVE_STRCASECMP
/***************************************************************/
/* */
/* StrCmpi */
@@ -98,6 +110,8 @@ int StrCmpi(char const *s1, char const *s2)
return toupper(*s1) - toupper(*s2);
}
#endif
/***************************************************************/
/* */
/* DateOK */
@@ -116,6 +130,14 @@ int DateOK(int y, int m, int d)
return 1;
}
void strtolower(char *s)
{
while (*s) {
*s = tolower(*s);
s++;
}
}
/* Functions designed to defeat gcc optimizer */
int _private_mul_overflow(int a, int b)
@@ -151,11 +173,15 @@ int _private_sub_overflow(int a, int b)
int
ShellEscape(char const *in, DynamicBuffer *out)
{
while(*in) {
if (!strchr(DontEscapeMe, *in)) {
if (DBufPutc(out, '\\') != OK) return E_NO_MEM;
unsigned char const *i = (unsigned char const *) in;
while(*i) {
/* Don't escape chars with high bit set. That will mangle UTF-8 */
if (! (*i & 0x80) ) {
if (!strchr(DontEscapeMe, *i)) {
if (DBufPutc(out, '\\') != OK) return E_NO_MEM;
}
}
if (DBufPutc(out, *in++) != OK) return E_NO_MEM;
if (DBufPutc(out, *i++) != OK) return E_NO_MEM;
}
return OK;
}
@@ -169,31 +195,33 @@ typedef struct cs_s {
} cs;
static cs *callstack = NULL;
static cs *freecs = NULL;
static void
destroy_cs(cs *entry)
{
if (entry->filename) free( (void *) entry->filename);
if (entry->func) free( (void *) entry->func);
free( (void *) entry);
entry->next = freecs;
freecs = entry;
}
int
push_call(char const *filename, char const *func, int lineno)
{
cs *entry = NEW(cs);
if (!entry) {
return E_NO_MEM;
cs *entry;
if (freecs) {
entry = freecs;
freecs = freecs->next;
} else {
entry = NEW(cs);
if (!entry) {
return E_NO_MEM;
}
}
entry->next = NULL;
entry->filename = StrDup(filename);
entry->func = StrDup(func);
entry->filename = filename;
entry->func = func;
entry->lineno = lineno;
if (!entry->filename || !entry->func) {
destroy_cs(entry);
return E_NO_MEM;
}
entry->next = callstack;
callstack = entry;
return OK;
@@ -215,11 +243,35 @@ clear_callstack(void)
static void
print_callstack_aux(FILE *fp, cs *entry)
{
if (entry) {
print_callstack_aux(fp, entry->next);
fprintf(fp, "\n");
(void) fprintf(fp, "%s(%d): In function `%s'", entry->filename, entry->lineno, entry->func);
int i = 0;
char const *in = "In";
cs *prev = NULL;
while(entry) {
if (prev) {
in = "Called from";
}
if (!prev || strcmp(prev->func, entry->func) || strcmp(prev->filename, entry->filename) || prev->lineno != entry->lineno) {
if (prev) {
fprintf(fp, "\n");
}
(void) fprintf(fp, " %s(%d): [#%d] %s function `%s'", entry->filename, entry->lineno, i, in, entry->func);
}
prev = entry;
entry = entry->next;
i++;
if (i > 10) {
break;
}
}
if (entry) {
(void) fprintf(fp, "\n [remaining call frames omitted]");
}
}
int
have_callstack(void)
{
return (callstack != NULL);
}
int

176
src/var.c
View File

@@ -22,14 +22,13 @@
#include <errno.h>
#include <locale.h>
#include "types.h"
#include "expr.h"
#include "globals.h"
#include "protos.h"
#include "err.h"
#define UPPER(c) (islower(c) ? toupper(c) : c)
/* The variable hash table */
#define VAR_HASH_SIZE 64
#define VAR_HASH_SIZE 67
#define VARIABLE ErrMsg[E_VAR]
#define VALUE ErrMsg[E_VAL]
#define UNDEF ErrMsg[E_UNDEF]
@@ -39,8 +38,6 @@ static int IntMax = INT_MAX;
static Var *VHashTbl[VAR_HASH_SIZE];
typedef int (*SysVarFunc)(int, Value *);
static double
strtod_in_c_locale(char const *str, char **endptr)
{
@@ -167,6 +164,40 @@ static int latitude_func(int do_set, Value *val)
return latitude_longitude_func(do_set, val, &Latitude, -90.0, 90.0);
}
static int oncefile_func(int do_set, Value *val)
{
if (do_set) {
if (val->type != STR_TYPE) return E_BAD_TYPE;
if (! (*val->v.str) && (!OnceFile || !*OnceFile)) {
/* Trying to set already-empty string to empty string */
return OK;
}
if (OnceFile && !strcmp(OnceFile, val->v.str)) {
/* Trying to set to the exact same value */
return OK;
}
if (ProcessedOnce) {
Wprint("Not setting $OnceFile: Already processed a reminder with a ONCE clause");
return OK;
}
if (OnceFile) {
free( (void *) OnceFile);
}
OnceFile = StrDup(val->v.str);
if (!OnceFile) return E_NO_MEM;
return OK;
}
if (!OnceFile) {
val->v.str = StrDup("");
} else {
val->v.str = StrDup(OnceFile);
}
if (!val->v.str) return E_NO_MEM;
val->type = STR_TYPE;
return OK;
}
static int terminal_bg_func(int do_set, Value *val)
{
UNUSED(do_set);
@@ -175,6 +206,19 @@ static int terminal_bg_func(int do_set, Value *val)
return OK;
}
static int trig_time_func(int do_set, Value *val)
{
UNUSED(do_set);
if (LastTriggerTime != NO_TIME) {
val->type = TIME_TYPE;
val->v.val = LastTriggerTime;
} else {
val->type = INT_TYPE;
val->v.val = 0;
}
return OK;
}
static int trig_date_func(int do_set, Value *val)
{
UNUSED(do_set);
@@ -309,6 +353,29 @@ static int datetime_sep_func(int do_set, Value *val)
return OK;
}
static int expr_time_limit_func(int do_set, Value *val)
{
if (!do_set) {
val->type = INT_TYPE;
val->v.val = ExpressionEvaluationTimeLimit;
return OK;
}
if (val->type != INT_TYPE) return E_BAD_TYPE;
if (val->v.val < 0) return E_2LOW;
if (!TopLevel()) {
/* Ignore attempts to set from non-toplevel unless it's
lower than current value */
if (val->v.val == 0 ||
val->v.val >= ExpressionEvaluationTimeLimit) {
return OK;
}
}
ExpressionEvaluationTimeLimit = val->v.val;
return OK;
}
static int default_color_func(int do_set, Value *val)
{
int col_r, col_g, col_b;
@@ -394,17 +461,17 @@ static int time_sep_func(int do_set, Value *val)
/***************************************************************/
unsigned int HashVal(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 * (unsigned int) UPPER(*str);
str++;
len++;
j = 3-j;
unsigned int h = 0, high;
while(*str) {
h = (h << 4) + (unsigned int) UPPER(*str);
str++;
high = h & 0xF0000000;
if (high) {
h ^= (high >> 24);
}
h &= ~high;
}
return i;
return h;
}
/***************************************************************/
@@ -477,7 +544,7 @@ int DeleteVar(char const *str)
/* */
/* SetVar */
/* */
/* Set the indicate variable to the specified value. */
/* Set the indicated variable to the specified value. */
/* */
/***************************************************************/
int SetVar(char const *str, Value const *val)
@@ -498,24 +565,14 @@ int SetVar(char const *str, Value const *val)
/* Get a copy of the value of the variable. */
/* */
/***************************************************************/
int GetVarValue(char const *str, Value *val, Var *locals, ParsePtr p)
int GetVarValue(char const *str, Value *val)
{
Var *v;
/* Try searching local variables first */
v = locals;
while (v) {
if (! StrinCmp(str, v->name, VAR_NAME_LEN))
return CopyValue(val, &v->v);
v = v->next;
}
/* Global variable... mark expression as non-constant */
if (p) p->nonconst_expr = 1;
v=FindVar(str, 0);
if (!v) {
Eprint("%s: %s", ErrMsg[E_NOSUCH_VAR], str);
Eprint("%s: `%s'", ErrMsg[E_NOSUCH_VAR], str);
return E_NOSUCH_VAR;
}
return CopyValue(val, &v->v);
@@ -530,7 +587,7 @@ int DoSet (Parser *p)
{
Value v;
int r;
int ch;
DynamicBuffer buf;
DynamicBuffer buf2;
DBufInit(&buf);
@@ -540,8 +597,16 @@ int DoSet (Parser *p)
if (r) return r;
/* Allow optional equals-sign: SET var = value */
if (ParseNonSpaceChar(p, &r, 1) == '=') {
ch = ParseNonSpaceChar(p, &r, 1);
if (r) return r;
if (ch == '=') {
ParseNonSpaceChar(p, &r, 0);
if (r) return r;
}
if (p->isnested) {
Eprint("%s", "Do not use [] around expression in SET command");
return E_CANTNEST_FDEF;
}
r = EvaluateExpr(p, &v);
@@ -772,16 +837,6 @@ int DoPreserve (Parser *p)
/* */
/***************************************************************/
/* The structure of a system variable */
typedef struct {
char const *name;
char modifiable;
int type;
void *value;
int min; /* Or const-value */
int max;
} SysVar;
/* Macro to access "min" but as a constval. Just to make source more
readable */
#define constval min
@@ -818,6 +873,7 @@ static SysVar SysVarArr[] = {
{"DontTrigAts", 0, INT_TYPE, &DontIssueAts, 0, 0 },
{"EndSent", 1, STR_TYPE, &EndSent, 0, 0 },
{"EndSentIg", 1, STR_TYPE, &EndSentIg, 0, 0 },
{"ExpressionTimeLimit", 1, SPECIAL_TYPE, expr_time_limit_func, 0, 0 },
{"February", 1, STR_TYPE, &DynamicMonthName[1], 0, 0 },
{"FirstIndent", 1, INT_TYPE, &FirstIndent, 0, 132 },
{"FoldYear", 1, INT_TYPE, &FoldYear, 0, 1 },
@@ -864,6 +920,7 @@ static SysVar SysVarArr[] = {
{"NumTrig", 0, INT_TYPE, &NumTriggered, 0, 0 },
{"October", 1, STR_TYPE, &DynamicMonthName[9], 0, 0 },
{"On", 1, STR_TYPE, &DynamicOn, 0, 0 },
{"OnceFile", 1, SPECIAL_TYPE, oncefile_func, 0, 0 },
{"ParseUntriggered", 1, INT_TYPE, &ParseUntriggered, 0, 1 },
{"Pm", 1, STR_TYPE, &DynamicPm, 0, 0 },
{"PrefixLineNo", 0, INT_TYPE, &DoPrefixLineNo, 0, 0 },
@@ -877,6 +934,7 @@ static SysVar SysVarArr[] = {
{"SortByTime", 0, INT_TYPE, &SortByTime, 0, 0 },
{"SubsIndent", 1, INT_TYPE, &SubsIndent, 0, 132 },
{"Sunday", 1, STR_TYPE, &DynamicDayName[6], 0, 0 },
{"SuppressImplicitWarnings", 1, INT_TYPE, &SuppressImplicitRemWarnings, 0, 1},
{"SuppressLRM", 1, INT_TYPE, &SuppressLRM, 0, 1 },
{"SysInclude", 0, STR_TYPE, &SysDir, 0, 0 },
{"T", 0, SPECIAL_TYPE, trig_date_func, 0, 0 },
@@ -887,6 +945,7 @@ static SysVar SysVarArr[] = {
{"Tm", 0, SPECIAL_TYPE, trig_mon_func, 0, 0 },
{"Today", 1, STR_TYPE, &DynamicToday, 0, 0 },
{"Tomorrow", 1, STR_TYPE, &DynamicTomorrow, 0, 0 },
{"Tt", 0, SPECIAL_TYPE, trig_time_func, 0, 0 },
{"Tuesday", 1, STR_TYPE, &DynamicDayName[1], 0, 0 },
{"Tw", 0, SPECIAL_TYPE, trig_wday_func, 0, 0 },
{"Ty", 0, SPECIAL_TYPE, trig_year_func, 0, 0 },
@@ -905,7 +964,6 @@ static SysVar SysVarArr[] = {
};
#define NUMSYSVARS ( sizeof(SysVarArr) / sizeof(SysVar) )
static SysVar *FindSysVar (char const *name);
static void DumpSysVar (char const *name, const SysVar *v);
/***************************************************************/
/* */
@@ -1002,7 +1060,7 @@ int GetSysVar(char const *name, Value *val)
/* Find a system var with specified name. */
/* */
/***************************************************************/
static SysVar *FindSysVar(char const *name)
SysVar *FindSysVar(char const *name)
{
int top=NUMSYSVARS-1, bottom=0;
int mid=(top + bottom) / 2;
@@ -1062,7 +1120,7 @@ static void DumpSysVar(char const *name, const SysVar *v)
return;
}
if (name) strcat(buffer, name); else strcat(buffer, v->name);
fprintf(ErrFp, "%16s ", buffer);
fprintf(ErrFp, "%25s ", buffer);
if (v) {
if (v->type == CONST_INT_TYPE) {
fprintf(ErrFp, "%d\n", v->constval);
@@ -1141,3 +1199,37 @@ set_components_from_lat_and_long(void)
}
}
void
print_sysvar_tokens(void)
{
int i;
printf("\n# System Variables\n\n");
for (i=0; i< (int) NUMSYSVARS; i++) {
printf("$%s\n", SysVarArr[i].name);
}
}
void
get_var_hash_stats(int *total, int *maxlen, double *avglen)
{
int len;
int i;
Var *v;
*maxlen = 0;
*total = 0;
for (i=0; i<VAR_HASH_SIZE; i++) {
len = 0;
v = VHashTbl[i];
while(v) {
len++;
(*total)++;
v = v->next;
}
if (len > *maxlen) {
*maxlen = len;
}
}
*avglen = (double) *total / (double) VAR_HASH_SIZE;
}

View File

@@ -35,8 +35,8 @@ set a ansicolor(-1, 0, 0)
set a ansicolor(42, 42, 256)
set a ansicolor("foo")
set a ansicolor("1 1")
set a ansicolor("-1 -1 0");
set a ansicolor("256 1 1");
set a ansicolor("-1 -1 0")
set a ansicolor("256 1 1")
set a ansicolor(128, 128, 128, 2)
set a ansicolor(128, 128, 128, -1)
set a ansicolor(128, 128, 128, 0, 2)

55
tests/expr.rem Normal file
View 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
View File

@@ -0,0 +1,4 @@
BANNER %
set $AddBlankLines 0
IF 1
INCLUDE [filedir()]/if2.rem

5
tests/if2.rem Normal file
View File

@@ -0,0 +1,5 @@
# Another unmatched IF
IF 0
ELSE
IF 1

View File

@@ -2,5 +2,5 @@ FSET msgprefix(x) "Priority: " + x + "; Filename: " + filename() + ": "
REM at 23:56 MSG foo
REM PRIORITY 42 at 23:57 MSG bar
REM PRIORITY 999 at 23:58 MSQ quux
REM PRIORITY 999 at 23:58 MSG quux
DO queue2.rem

View File

@@ -9,10 +9,10 @@ set $LatMin 24
set $LatSec 0
IF $PSCAL
[trigger(moondate(0))] SPECIAL MOON 0 -1 -1 [moontime(0)]
[trigger(moondate(1))] SPECIAL MOON 1 -1 -1 [moontime(1)]
[trigger(moondate(2))] SPECIAL MOON 2 -1 -1 [moontime(2)]
[trigger(moondate(3))] SPECIAL MOON 3 -1 -1 [moontime(3)]
REM [trigger(moondate(0))] SPECIAL MOON 0 -1 -1 [moontime(0)]
REM [trigger(moondate(1))] SPECIAL MOON 1 -1 -1 [moontime(1)]
REM [trigger(moondate(2))] SPECIAL MOON 2 -1 -1 [moontime(2)]
REM [trigger(moondate(3))] SPECIAL MOON 3 -1 -1 [moontime(3)]
ENDIF
REM 4 PS (First-Bit-Of-PS)

7
tests/test-once.rem Normal file
View File

@@ -0,0 +1,7 @@
BANNER %
SET $OnceFile "../tests/once.timestamp"
REM ONCE MSG This should only be issued once per day.
SET $OnceFile "../tests/once.timestamp"
SET $OnceFile "../tests/once-again.timestamp"

View File

@@ -65,8 +65,6 @@ echo "Test 1" > ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -e -dxte ../tests/test.rem 16 feb 1991 12:13 >> ../tests/test.out 2>&1
echo "" >> ../tests/test.out
echo '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+2*3))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))' | ../src/remind -ds - 16 feb 1991 12:13 >> ../tests/test.out 2>&1
echo "" >> ../tests/test.out
echo "Test 2" >> ../tests/test.out
echo "" >> ../tests/test.out
../src/remind -p -l ../tests/test2.rem 1 aug 2007 >> ../tests/test.out 2>&1
@@ -178,7 +176,7 @@ REM 1 Jan 2012 AT 10:00 MSG 10am: Should show up
MSG [$DontTrigAts]
EOF
# An OMITFUNC should indicate nonconst_expr
# OMITFUNC should indicate nonconst_expr
../src/remind -pp - 1 jan 2012 9:00 <<'EOF' >> ../tests/test.out 2>&1
REM Mon OMITFUNC foo MSG bar
EOF
@@ -541,8 +539,67 @@ EOF
(echo 'BANNER %'; echo 'REM 29 MSG No bug') | ../src/remind -dt - 29 Feb 2024 >> ../tests/test.out 2>&1
../src/remind -ifoo - <<'EOF' >> ../tests/test.out 2>&1
BANNER %
DUMP
EOF
../src/remind '-i$AddBlankLines' - <<'EOF' >> ../tests/test.out 2>&1
BANNER %
DUMP
EOF
../src/remind ../tests/expr.rem >> ../tests/test.out 2>&1
../src/remind - <<'EOF' >> ../tests/test.out 2>&1
PUSH
POP
PUSH
PUSH
POP
POP
PUSH
PUSH
POP
PUSH
POP
PUSH
POP
EOF
../src/remind ../tests/if1.rem 2020-03-03 >> ../tests/test.out 2>&1
# Test ONCE with a timestamp file
rm -f ../tests/once.timestamp
../src/remind ../tests/test-once.rem >> ../tests/test.out 2>&1
../src/remind ../tests/test-once.rem >> ../tests/test.out 2>&1
../src/remind ../tests/test-once.rem >> ../tests/test.out 2>&1
tail +2 ../tests/once.timestamp >> ../tests/test.out 2>&1
rm -f ../tests/once.timestamp
../src/remind - < ../tests/test-once.rem >> ../tests/test.out 2>&1
../src/remind - < ../tests/test-once.rem >> ../tests/test.out 2>&1
../src/remind - < ../tests/test-once.rem >> ../tests/test.out 2>&1
tail +2 ../tests/once.timestamp >> ../tests/test.out 2>&1
rm -f ../tests/once.timestamp
# Newlines in calendar output
(echo 'REM 16 MSG foo%_bar%_baz wookie quux apple %_ %_ %_ blech'; echo "REM 16 MSG ANOTHER") | ../src/remind -c -w80 - 1 sep 1990 >> ../tests/test.out 2>&1
# Remove references to SysInclude, which is build-specific
grep -F -v '$SysInclude' < ../tests/test.out > ../tests/test.out.1 && mv -f ../tests/test.out.1 ../tests/test.out
# If "man" accepts the --warnings flag, test all the man pages.
man man | grep -e --warnings > /dev/null 2>&1
if test $? = 0 ; then
for i in ../man/*.1 ; do
man --warnings=w $i 2>>../tests/test.out 1>/dev/null
done
fi
# Test --print-tokens long option
../src/remind --print-tokens < /dev/null >> ../tests/test.out 2>&1
cmp -s ../tests/test.out ../tests/test.cmp
if [ "$?" = "0" ]; then
echo "Remind: Acceptance test PASSED"

File diff suppressed because one or more lines are too long

View File

@@ -33,7 +33,7 @@ fset _h(x, y) trigger(hebdate(x,y))
# Test case from Remind mailing list
set mltest "a b"
INCLUDECMD printf 'REM %s\n' [mltest]
INCLUDECMD printf 'REM MSG %s\n' [mltest]
# Disabling RUN in an !includecmd
INCLUDECMD !echo MSG foo
@@ -49,38 +49,38 @@ INCLUDECMD echo MSG foo
RUN ON
INCLUDECMD echo MSG foo
[_h(1, "Tishrey")] MSG Rosh Hashana 1
[_h(2, "Tishrey")] MSG Rosh Hashana 2
[_h(3, "Tishrey")] MSG Tzom Gedalia
[_h(10, "Tishrey")] MSG Yom Kippur
[_h(15, "Tishrey")] MSG Sukkot 1
[_h(25, "Kislev")] MSG Channuka
[_h(10, "Tevet")] MSG Asara B'Tevet
[_h(15, "Shvat")] MSG Tu B'Shvat
[_h(15, "Adar A")] MSG Purim Katan
[_h(14, "Adar")] MSG Purim
[_h(15, "Nisan")] MSG Pesach
[_h(27, "Nisan")] MSG Yom HaShoah
[_h(4, "Iyar")] MSG Yom HaZikaron
[_h(5, "Iyar")] MSG Yom Ha'atzmaut
[_h(28, "Iyar")] MSG Yom Yerushalayim
[_h(6, "Sivan")] MSG Shavuot
[_h(9, "Av")] MSG Tish'a B'Av
REM [_h(1, "Tishrey")] MSG Rosh Hashana 1
REM [_h(2, "Tishrey")] MSG Rosh Hashana 2
REM [_h(3, "Tishrey")] MSG Tzom Gedalia
REM [_h(10, "Tishrey")] MSG Yom Kippur
REM [_h(15, "Tishrey")] MSG Sukkot 1
REM [_h(25, "Kislev")] MSG Channuka
REM [_h(10, "Tevet")] MSG Asara B'Tevet
REM [_h(15, "Shvat")] MSG Tu B'Shvat
REM [_h(15, "Adar A")] MSG Purim Katan
REM [_h(14, "Adar")] MSG Purim
REM [_h(15, "Nisan")] MSG Pesach
REM [_h(27, "Nisan")] MSG Yom HaShoah
REM [_h(4, "Iyar")] MSG Yom HaZikaron
REM [_h(5, "Iyar")] MSG Yom Ha'atzmaut
REM [_h(28, "Iyar")] MSG Yom Yerushalayim
REM [_h(6, "Sivan")] MSG Shavuot
REM [_h(9, "Av")] MSG Tish'a B'Av
# Test some jahrzeit cases
fset _i(x,y,z,a) trigger(hebdate(x,y,z,a))
[_i(30, "Heshvan", today(), 5759)] MSG Complete-Complete
[_i(30, "Heshvan", today(), 5760)] MSG Complete-Defective
[_i(30, "Heshvan", today(), 5761)] MSG Illegal
REM [_i(30, "Heshvan", today(), 5759)] MSG Complete-Complete
REM [_i(30, "Heshvan", today(), 5760)] MSG Complete-Defective
REM [_i(30, "Heshvan", today(), 5761)] MSG Illegal
[_i(30, "Kislev", today(), 5759)] MSG Complete-Complete
[_i(30, "Kislev", today(), 5760)] MSG Complete-Defective
[_i(30, "Kislev", today(), 5761)] MSG Illegal
REM [_i(30, "Kislev", today(), 5759)] MSG Complete-Complete
REM [_i(30, "Kislev", today(), 5760)] MSG Complete-Defective
REM [_i(30, "Kislev", today(), 5761)] MSG Illegal
[_i(30, "Adar A", today(), 5755)] MSG Leap
[_i(30, "Adar A", today(), 5756)] MSG Illegal
[_i(29, "Adar A", today(), 5755)] MSG Leap
[_i(29, "Adar A", today(), 5756)] MSG Illegal
REM [_i(30, "Adar A", today(), 5755)] MSG Leap
REM [_i(30, "Adar A", today(), 5756)] MSG Illegal
REM [_i(29, "Adar A", today(), 5755)] MSG Leap
REM [_i(29, "Adar A", today(), 5756)] MSG Illegal
# This causes a parse error on version 03.01.01
REM 1990-01-01 SATISFY 1
@@ -238,8 +238,8 @@ CLEAR-OMIT-CONTEXT
REM tag ill,egal MSG bad tag
REM MSG The tags are: [trigtags()]
REM TAG foo The tags are: [trigtags()]
REM TAG foo TAG bar TAG quux TAG znort TAG cabbage The tags are: [trigtags()]
REM TAG foo MSG The tags are: [trigtags()]
REM TAG foo TAG bar TAG quux TAG znort TAG cabbage MSG The tags are: [trigtags()]
REM MSG The tags are: [trigtags()]
# Test ADDOMIT
@@ -329,6 +329,7 @@ set a052 time(1+2, 3+4)
rem 10 jan 1992 AT 11:22 CAL
set a053 trigdate()
set a054 trigtime()
set a054b $Tt
set a055 trigvalid()
set a056 upper("sdfjhsdf ksjdfh kjsdfh ksjdfh")
set a057 value("a05"+"6")
@@ -449,7 +450,7 @@ set a125 trigduration()
# Test adding TIME+TIME and DATETIME+TIME
set a126 11:00 + 3:00
set a127 23:00 + 5:30
set a127 '23:00' + 5:30
set a128 '2018-02-03@10:00' + 6:45
set a129 23:30 + '2019-02-02@16:44'
@@ -457,6 +458,7 @@ set a129 23:30 + '2019-02-02@16:44'
REM 13 AT 16:00 DURATION 72:00 MSG 72-hour event
set a130 trigdate()
set a131 trigtime()
set a131b $Tt
set a132 trigdatetime()
set a133 trigduration()
set a134 trigeventstart()
@@ -557,11 +559,11 @@ REM 1992-01-01 *1 UNTIL 1991-12-31 MSG Diagnosed
set x '1992-01-01'
REM [x] *1 UNTIL 1991-12-31 MSG Not diagnosed - nonconst expression
REM MON FROM 1992-01-01 UNTIL 1991-12-31 Diagnosed
REM MON SCANFROM 1992-01-01 UNTIL 1991-12-31 Diagnosed
REM MON FROM 1992-01-01 UNTIL 1991-12-31 MSG Diagnosed
REM MON SCANFROM 1992-01-01 UNTIL 1991-12-31 MSG Diagnosed
REM MON FROM [x] UNTIL 1991-12-31 Not diagnosed
REM MON SCANFROM [x] UNTIL 1991-12-31 Not diagnosed
REM MON FROM [x] UNTIL 1991-12-31 MSG Not diagnosed
REM MON SCANFROM [x] UNTIL 1991-12-31 MSG Not diagnosed
REM 1992-01-01 UNTIL 1992-02-02 MSG Diagnosed
REM [x] UNTIL 1992-02-02 MSG Diagnosed
@@ -573,7 +575,7 @@ OMIT December 25 MSG X
OMIT 26 Dec 2010 THROUGH 27 Dec 2010 MSG This is not legal
OMIT DUMP
# Regression test for bugfix in Hebrew calendar Adar jahrzeit
[_i(14, "Adar", today(), 5761)] MSG Purim
REM [_i(14, "Adar", today(), 5761)] MSG Purim
# Regression test for bug found by Larry Hynes
REM SATISFY [day(trigdate()-25) == 14] MSG Foo
@@ -706,6 +708,56 @@ set x ampm(21:12) + ""
set x ampm(22:12) + ""
set x ampm(23:12) + ""
set x ampm(0:12,"AM", "PM", 1) + ""
set x ampm(1:12,"AM", "PM", 1) + ""
set x ampm(2:12,"AM", "PM", 1) + ""
set x ampm(3:12,"AM", "PM", 1) + ""
set x ampm(4:12,"AM", "PM", 1) + ""
set x ampm(5:12,"AM", "PM", 1) + ""
set x ampm(6:12,"AM", "PM", 1) + ""
set x ampm(7:12,"AM", "PM", 1) + ""
set x ampm(8:12,"AM", "PM", 1) + ""
set x ampm(9:12,"AM", "PM", 1) + ""
set x ampm(10:12,"AM", "PM", 1) + ""
set x ampm(11:12,"AM", "PM", 1) + ""
set x ampm(12:12,"AM", "PM", 1) + ""
set x ampm(13:12,"AM", "PM", 1) + ""
set x ampm(14:12,"AM", "PM", 1) + ""
set x ampm(15:12,"AM", "PM", 1) + ""
set x ampm(16:12,"AM", "PM", 1) + ""
set x ampm(17:12,"AM", "PM", 1) + ""
set x ampm(18:12,"AM", "PM", 1) + ""
set x ampm(19:12,"AM", "PM", 1) + ""
set x ampm(20:12,"AM", "PM", 1) + ""
set x ampm(21:12,"AM", "PM", 1) + ""
set x ampm(22:12,"AM", "PM", 1) + ""
set x ampm(23:12,"AM", "PM", 1) + ""
set x ampm(0:02,"AM", "PM", 0) + ""
set x ampm(0:02,"AM", "PM", 0) + ""
set x ampm(2:02,"AM", "PM", 0) + ""
set x ampm(3:02,"AM", "PM", 0) + ""
set x ampm(4:02,"AM", "PM", 0) + ""
set x ampm(5:02,"AM", "PM", 0) + ""
set x ampm(6:02,"AM", "PM", 0) + ""
set x ampm(7:02,"AM", "PM", 0) + ""
set x ampm(8:02,"AM", "PM", 0) + ""
set x ampm(9:02,"AM", "PM", 0) + ""
set x ampm(00:02,"AM", "PM", 0) + ""
set x ampm(00:02,"AM", "PM", 0) + ""
set x ampm(02:02,"AM", "PM", 0) + ""
set x ampm(03:02,"AM", "PM", 0) + ""
set x ampm(04:02,"AM", "PM", 0) + ""
set x ampm(05:02,"AM", "PM", 0) + ""
set x ampm(06:02,"AM", "PM", 0) + ""
set x ampm(07:02,"AM", "PM", 0) + ""
set x ampm(08:02,"AM", "PM", 0) + ""
set x ampm(09:02,"AM", "PM", 0) + ""
set x ampm(20:02,"AM", "PM", 0) + ""
set x ampm(20:02,"AM", "PM", 0) + ""
set x ampm(22:02,"AM", "PM", 0) + ""
set x ampm(23:02,"AM", "PM", 0) + ""
# Coerce with am/pm
set x coerce("TIME", "12:45am")
set x coerce("TIME", "12:45")
@@ -775,12 +827,15 @@ ENDIF
# Trig with a good warnfunc
FSET w(x) choose(x, 5, 3, 1, 0)
# Ugh. This is where short-circuit logical operators
# would really come in handy.
# Short-circuit operators
IF trig("sun warn w") || trig("thu warn w")
REM [trig()] +5 MSG Foo %b
ENDIF
IF trig("thu warn w") || trig("sun warn w")
REM [trig()] +5 MSG Foo %b
ENDIF
REM [trig("Mon", "Tue", "Wed", "Sat")] MSG foo
REM [trig("Mon", "Tue", "Wed")] MSG bar
@@ -867,6 +922,17 @@ REM MSG Here: %{custom}
REM MSG There: %*{custom}
REM MSG Bad: %{custom
REM MSG Undefined: %{nopity_nope_nope}
# Bad substitution functions
FSET subst_bad() "foo"
REM MSG %{bad}
FSET subst_ampm(a, b, c, d, e, f, g) "wookie"
REM AT 11:00 MSG %2
FUNSET subst_ampm
# Test FUNSET
FSET square(x) x*x
SET a square(5)
@@ -925,6 +991,148 @@ REM Tue OMIT 2024-01-01 MSG Wookie
# No error
REM Tue OMIT Wed 2024-01-01 MSG Blort
# Make sure trigtime() is not reset between invocations
REM Tue AT 16:00 DURATION 30 MSG Thing One
REM [$T] AT [trigtime()+trigduration()] DURATION 15 MSG Thing Two
REM [$T] AT [$Tt+trigduration()] DURATION 30 MSG Thing Three
REM [$T] AT [trigtime()+trigduration()] DURATION 10 MSG Last Thing
# Make sure trigtime is not reset during parsing
REM Tue AT 16:00 MSG blort
REM Tue AT 10:00 DURATION [$Tt] MSG blort
REM Tue AT 16:00 MSG blort
REM Tue AT 10:00 DURATION [trigtime()] MSG blort
# Make sure shellescape does not mangle UTF-8 characters
msg [shellescape("😆")]
This should be diagnosed as implicitly being REM
REM This should be diganosed as implicitly being MSG-type
# Check that user-defined functions with too many arguments are
# correctly diagnosed.
# This should be OK
FSET f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63) 3
# This should give an error
FSET f(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60, a61, a62, a63, a64) 3
# Check that SATISFY expressions that don't reference trigdate are diagnosed
# These should all NOT be diagnosed
set x 3
REM SATISFY 1
REM SATISFY trigdate() > '1990-01-01'
REM AT 23:59 SATISFY trigdatetime() > '1990-01-01@12:00'
REM SATISFY $T > '1990-01-01'
REM SATISFY $Ty > 1990
REM SATISFY $Tm > 0
REM SATISFY $Td > 0
REM SATISFY $Tw > -1
REM SATISFY [max(x, max(x, 1, 2, 3), 4, 5, 6) * max(5, $Td)]
FSET references_t(x) $T != x
REM SATISFY references_t($U)
FSET recursive_t(x) iif(x==0, recursive_t(1), references_t($U))
REM SATISFY recursive_t(0)
REM SATISFY recursive_t(2)
# These should be diagnosed
REM SATISFY 0
REM SATISFY ""
REM SATISFY [version() > "01.00.00"]
REM SATISFY [max(x, max(x, 1, 2, 3), 4, 5, 6) * 5]
FSET gg(x) 0
REM WARN gg MSG Wookie
REM AT 11:00 SCHED gg MSG blork
REM OMITFUNC gg MSG hehe
FSET gg(x,y,z) 0
REM WARN gg MSG Wookie
REM AT 11:00 SCHED gg MSG blork
REM OMITFUNC gg MSG hehe
FSET gg() 0
REM WARN gg MSG Wookie
REM AT 11:00 SCHED gg MSG blork
REM OMITFUNC gg MSG hehe
FSET gg(x) x-x
REM WARN gg MSG Wookie
REM AT 11:00 SCHED gg MSG blork
REM OMITFUNC gg MSG hehe
REM WARN not_defined MSG Wookie
REM AT 11:00 SCHED not_defined MSG blork
REM OMITFUNC not_defined MSG hehe
### Strings in logical operators
SET logstr "" && 7
SET logstr "foo" && 7
SET logstr "" && ""
SET logstr "foo" && ""
SET logstr "" && "bar"
SET logstr "foo" && "bar"
SET logstr "" && '2023-02-01'
SET logstr "foo" && '2023-02-01'
SET logstr "" || 7
SET logstr "foo" || 7
SET logstr "" || ""
SET logstr "foo" || ""
SET logstr "" || "bar"
SET logstr "foo" || "bar"
SET logstr "" || '2023-02-01'
SET logstr "foo" || '2023-02-01'
set xyz ! 0
set xyz ! 1
set xyz ! 2
set xyz ! date(baseyr(), 1, 1)
set xyz ! date(baseyr(), 1, 2)
set xyz ! '2024-01-01'
set xyz ! datetime(baseyr(), 1, 1, 00:00)
set xyz ! datetime(baseyr(), 1, 1, 00:01)
set xyz ! datetime(baseyr(), 1, 2, 12:30)
set xyz ! '2024-01-01@11:47'
set xyz ! 00:00
set xyz ! 00:01
set xyz ! 23:59
set xyz ! ""
set xyz ! "foo"
set xyz ! "0"
# Test error messages for function calls with too many / too few args
set zxk version(1)
set zxk max()
fset dooby(x) 1
set zxk dooby()
set zxk dooby(1, 2)
set zxk dooby(1)
REM 1 Jan 1873 MSG This should fail
REM 1873-12-11 MSG Also bad.
# Test $SuppressImplicitWarnings
REM wookie
Barf
set $SuppressImplicitWarnings 1
REM wookie
Barf
# Output expression-node stats
DEBUG +s
# Don't want Remind to queue reminders
EXIT

View File

@@ -1,7 +1,7 @@
MSG ру́сский ру́сский ру́сский ру́сский ру́сский ру́сский ру́сский ру́сский
MSG עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית
REM MSG ру́сский ру́сский ру́сский ру́сский ру́сский ру́сский ру́сский ру́сский
REM MSG עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית עִבְרִית
Wed MSG With tabs and spaces
REM Wed MSG With tabs and spaces
REM [moondate(0)] MSG 🌑
REM [moondate(1)] MSG 🌓 woo

View File

@@ -79,7 +79,7 @@ install:
chmod 755 $(DESTDIR)$(SCRIPTDIR)/calpdf $(DESTDIR)$(SCRIPTDIR)/calps $(DESTDIR)$(SCRIPTDIR)/hebdate \
$(DESTDIR)$(SCRIPTDIR)/hebps $(DESTDIR)$(SCRIPTDIR)/hebpdf $(DESTDIR)$(SCRIPTDIR)/moon \
$(DESTDIR)$(SCRIPTDIR)/sunrise $(DESTDIR)$(SCRIPTDIR)/sunset \
$(DESTDIR)$(SCRIPTDIR)/hebhtml \
$(DESTDIR)$(SCRIPTDIR)/hebhtml \
-mkdir -p $(DESTDIR)$(IMAGEDIR)
cp calendar.css rem-default.css *.png $(DESTDIR)$(IMAGEDIR)

View File

@@ -1,5 +1,5 @@
[moondate(0)] SPECIAL MOON 0
[moondate(1)] SPECIAL MOON 1
[moondate(2)] SPECIAL MOON 2
[moondate(3)] SPECIAL MOON 3
REM [moondate(0)] SPECIAL MOON 0
REM [moondate(1)] SPECIAL MOON 1
REM [moondate(2)] SPECIAL MOON 2
REM [moondate(3)] SPECIAL MOON 3
REM Monday SPECIAL WEEK (W[weekno()])

View File

@@ -9,8 +9,8 @@ IF !$PSCAL
FSET msgsuffix(x) "<P>"
MSG The Hebrew date for today, %d %m, %y, is [_hstr(today())]. %
MSG And the Hebrew date for tomorrow is [_hstr(today()+1)]. %
REM MSG The Hebrew date for today, %d %m, %y, is [_hstr(today())]. %
REM MSG And the Hebrew date for tomorrow is [_hstr(today()+1)]. %
fset msgprefix(x) iif($NumTrig==OldTrig, "<H2>Upcoming Holidays</H2>"+char(13,10),"")
set oldtrig $numtrig
@@ -51,40 +51,40 @@ FSET _PastSat(x, y) IIF(WKDAYNUM(_h2(x,y))!=6, \
SET InIsrael VALUE("InIsrael", 0)
SET Reform VALUE("Reform", 0)
[_h(1, "Tishrey")] ++12 MSG %"Rosh Hashana 1%" is %b.
REM [_h(1, "Tishrey")] ++12 MSG %"Rosh Hashana 1%" is %b.
# No RH-2 or Tzom Gedalia in Reform
IF !Reform
[_h(2, "Tishrey")] ++12 MSG %"Rosh Hashana 2%" is %b.
[_PastSat(3, "Tishrey")] ++12 MSG %"Tzom Gedalia%" is %b.
REM [_h(2, "Tishrey")] ++12 MSG %"Rosh Hashana 2%" is %b.
REM [_PastSat(3, "Tishrey")] ++12 MSG %"Tzom Gedalia%" is %b.
ENDIF
[_h(10, "Tishrey")] ++12 MSG %"Yom Kippur%" is %b.
[_h(15, "Tishrey")] ++12 MSG %"Sukkot 1%" is %b.
REM [_h(10, "Tishrey")] ++12 MSG %"Yom Kippur%" is %b.
REM [_h(15, "Tishrey")] ++12 MSG %"Sukkot 1%" is %b.
IF !InIsrael
[_h(16, "Tishrey")] MSG %"Sukkot 2%"
REM [_h(16, "Tishrey")] MSG %"Sukkot 2%"
ENDIF
[_h(21, "Tishrey")] ++12 MSG %"Hoshana Rabba%" is %b.
[_h(22, "Tishrey")] ++12 MSG %"Shemini Atzeret%" is %b.
REM [_h(21, "Tishrey")] ++12 MSG %"Hoshana Rabba%" is %b.
REM [_h(22, "Tishrey")] ++12 MSG %"Shemini Atzeret%" is %b.
IF InIsrael
[_h(22, "Tishrey")] ++12 MSG %"Simchat Torah%" is %b.
REM [_h(22, "Tishrey")] ++12 MSG %"Simchat Torah%" is %b.
ELSE
[_h(23, "Tishrey")] ++12 MSG %"Simchat Torah%" is %b.
REM [_h(23, "Tishrey")] ++12 MSG %"Simchat Torah%" is %b.
ENDIF
# Because Kislev can change length, we must be more careful about Chanukah
FSET _chan(x) TRIGGER(HEBDATE(24, "Kislev", today()-9)+x)
[_chan(1)] ++12 MSG %"Chanukah 1%" is %b.
[_chan(2)] MSG %"Chanukah 2%"
[_chan(3)] MSG %"Chanukah 3%"
[_chan(4)] MSG %"Chanukah 4%"
[_chan(5)] MSG %"Chanukah 5%"
[_chan(6)] MSG %"Chanukah 6%"
[_chan(7)] MSG %"Chanukah 7%"
[_chan(8)] MSG %"Chanukah 8%"
REM [_chan(1)] ++12 MSG %"Chanukah 1%" is %b.
REM [_chan(2)] MSG %"Chanukah 2%"
REM [_chan(3)] MSG %"Chanukah 3%"
REM [_chan(4)] MSG %"Chanukah 4%"
REM [_chan(5)] MSG %"Chanukah 5%"
REM [_chan(6)] MSG %"Chanukah 6%"
REM [_chan(7)] MSG %"Chanukah 7%"
REM [_chan(8)] MSG %"Chanukah 8%"
# Not sure about Reform's position on the next one.
IF !Reform
@@ -92,8 +92,8 @@ IF !Reform
REM [_PastSat(10, "Tevet")] MSG %"Tzom Tevet%" is %b.
ENDIF
[_h(15, "Shvat")] ++12 MSG %"Tu B'Shvat%" is %b.
[_h(15, "Adar A")] ++12 MSG %"Purim Katan%" is %b.
REM [_h(15, "Shvat")] ++12 MSG %"Tu B'Shvat%" is %b.
REM [_h(15, "Adar A")] ++12 MSG %"Purim Katan%" is %b.
# If Purim is on Sunday, then Fast of Esther is 11 Adar.
IF WKDAYNUM(_h2(13, "Adar")) != 6
@@ -101,41 +101,41 @@ IF WKDAYNUM(_h2(13, "Adar")) != 6
ELSE
REM [TRIGGER(_h2(11, "Adar"))] ++12 MSG %"Fast of Esther%" is %b.
ENDIF
[_h(14, "Adar")] ++12 MSG %"Purim%" is %b.
[_h(15, "Nisan")] ++12 MSG %"Pesach%" is %b.
REM [_h(14, "Adar")] ++12 MSG %"Purim%" is %b.
REM [_h(15, "Nisan")] ++12 MSG %"Pesach%" is %b.
IF !InIsrael
[_h(16, "Nisan")] MSG %"Pesach 2%" is %b.
REM [_h(16, "Nisan")] MSG %"Pesach 2%" is %b.
ENDIF
[_h(21, "Nisan")] MSG %"Pesach 7%" is %b.
REM [_h(21, "Nisan")] MSG %"Pesach 7%" is %b.
IF !InIsrael && !Reform
[_h(22, "Nisan")] MSG %"Pesach 8%" is %b.
REM [_h(22, "Nisan")] MSG %"Pesach 8%" is %b.
ENDIF
[_h(27, "Nisan")] ++12 MSG %"Yom HaShoah%" is %b.
[_h(4, "Iyar")] ++12 MSG %"Yom HaZikaron%" is %b.
[_h(5, "Iyar")] ++12 MSG %"Yom Ha'atzmaut%" is %b.
REM [_h(27, "Nisan")] ++12 MSG %"Yom HaShoah%" is %b.
REM [_h(4, "Iyar")] ++12 MSG %"Yom HaZikaron%" is %b.
REM [_h(5, "Iyar")] ++12 MSG %"Yom Ha'atzmaut%" is %b.
# Not sure about Reform's position on Lag B'Omer
IF !Reform
[_h(18, "Iyar")] ++12 MSG %"Lag B'Omer%" is %b.
REM [_h(18, "Iyar")] ++12 MSG %"Lag B'Omer%" is %b.
ENDIF
[_h(28, "Iyar")] ++12 MSG %"Yom Yerushalayim%" is %b.
[_h(6, "Sivan")] ++12 MSG %"Shavuot%" is %b.
REM [_h(28, "Iyar")] ++12 MSG %"Yom Yerushalayim%" is %b.
REM [_h(6, "Sivan")] ++12 MSG %"Shavuot%" is %b.
IF !InIsrael && !Reform
[_h(7, "Sivan")] MSG %"Shavuot 2%" is %b.
REM [_h(7, "Sivan")] MSG %"Shavuot 2%" is %b.
ENDIF
# Fairly sure Reform Jews don't observe the next two
IF !Reform
# Tzom Tamuz and Tish'a B'Av are moved to Sunday if they normally
# fall on a Saturday
[_PastSat(17, "Tamuz")] ++12 MSG %"Tzom Tammuz%" is %b.
[_PastSat(9, "Av")] ++12 MSG %"Tish'a B'Av%" is %b.
REM [_PastSat(17, "Tamuz")] ++12 MSG %"Tzom Tammuz%" is %b.
REM [_PastSat(9, "Av")] ++12 MSG %"Tish'a B'Av%" is %b.
ENDIF
fset msgprefix(x) ""