mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 14:28:40 +02:00
Compare commits
160 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d90e74b1a3 | ||
|
|
bbd8a4b729 | ||
|
|
cae3e18717 | ||
|
|
0e989a7422 | ||
|
|
7b7ce5bb57 | ||
|
|
df95cdaad0 | ||
|
|
3026b6e5c2 | ||
|
|
b3306c5572 | ||
|
|
9ef3be33e5 | ||
|
|
292262c128 | ||
|
|
e54bfe9197 | ||
|
|
c56cfe9e1d | ||
|
|
f6b6a3285c | ||
|
|
6b031b0fdf | ||
|
|
2dab7025ba | ||
|
|
7403114897 | ||
|
|
82cbeec560 | ||
|
|
df6b4ac566 | ||
|
|
4ba21ab526 | ||
|
|
acac7a7b31 | ||
|
|
2290fd09f5 | ||
|
|
f02b6a1773 | ||
|
|
efffe05d42 | ||
|
|
950d67c522 | ||
|
|
a1aa61f54e | ||
|
|
3c2bd66460 | ||
|
|
245cebee56 | ||
|
|
c45364fdb3 | ||
|
|
e380308604 | ||
|
|
bd019524dd | ||
|
|
895536d7d3 | ||
|
|
3a0e41afd1 | ||
|
|
23dd28471e | ||
|
|
761217d403 | ||
|
|
77ed694111 | ||
|
|
61bcce3104 | ||
|
|
bf41b12ccd | ||
|
|
5eabd7d8d8 | ||
|
|
0c66f5f3af | ||
|
|
3190f784d9 | ||
|
|
394ff55879 | ||
|
|
9b846835bc | ||
|
|
01776af167 | ||
|
|
0db10424ad | ||
|
|
bafd7ea073 | ||
|
|
0ab27fcb4b | ||
|
|
95d016712e | ||
|
|
fcb55001bb | ||
|
|
7bc6961101 | ||
|
|
450e88fad8 | ||
|
|
3222b4c311 | ||
|
|
1e0cc3605d | ||
|
|
129b7bfeb7 | ||
|
|
388811b684 | ||
|
|
f83257407b | ||
|
|
e4ced77340 | ||
|
|
92e0bc316a | ||
|
|
a4a55f35b2 | ||
|
|
ed1150c189 | ||
|
|
08080f4e86 | ||
|
|
de4ebb8be6 | ||
|
|
11e2ce5093 | ||
|
|
2c560e6f2b | ||
|
|
643f394e6a | ||
|
|
6d047c2856 | ||
|
|
be86746685 | ||
|
|
da429b9629 | ||
|
|
b21a206c26 | ||
|
|
85bde8ba3a | ||
|
|
f84e658e6b | ||
|
|
8f0eba8bcd | ||
|
|
2faaaf78a8 | ||
|
|
7f659dace2 | ||
|
|
54cdd566c7 | ||
|
|
e212df87f9 | ||
|
|
4fb4db15e8 | ||
|
|
9a15a25a7b | ||
|
|
c02cfb9b17 | ||
|
|
3e726f21f7 | ||
|
|
21d4faa26f | ||
|
|
1d13d0ee07 | ||
|
|
329d13e480 | ||
|
|
2161c09b1d | ||
|
|
3f2e396c3c | ||
|
|
412e242109 | ||
|
|
e827516b72 | ||
|
|
7f953e98d7 | ||
|
|
821d3fe783 | ||
|
|
fdb4b302ac | ||
|
|
760d5d4a09 | ||
|
|
d561f98c42 | ||
|
|
ea74f276dc | ||
|
|
42cf82a5d5 | ||
|
|
825a6700da | ||
|
|
2f27645dac | ||
|
|
1e5b44d063 | ||
|
|
099ad9945d | ||
|
|
540ce3d946 | ||
|
|
ac2efcc993 | ||
|
|
b4bb1d9e37 | ||
|
|
9ec8b30934 | ||
|
|
fb38e5b35b | ||
|
|
5fa10e9d84 | ||
|
|
3bc1b5bd46 | ||
|
|
b266b399ba | ||
|
|
0e827a457d | ||
|
|
d05d85b243 | ||
|
|
a1faa8d804 | ||
|
|
70adbf90c2 | ||
|
|
501c04f4b6 | ||
|
|
d294e62be1 | ||
|
|
31f90b6c53 | ||
|
|
184d29c592 | ||
|
|
2d798bc4ec | ||
|
|
bd9a3761a6 | ||
|
|
b1063b0a9e | ||
|
|
cb2fffab92 | ||
|
|
55cca49428 | ||
|
|
5a0ab9ed8a | ||
|
|
1f2cfdfd84 | ||
|
|
dfd688caa6 | ||
|
|
830e3e339c | ||
|
|
bc9f560950 | ||
|
|
f91b748f50 | ||
|
|
3adbd7468c | ||
|
|
b66039ee24 | ||
|
|
27371f6475 | ||
|
|
19e7c34b47 | ||
|
|
3375aff3a7 | ||
|
|
41e9cb5ca3 | ||
|
|
6348860adf | ||
|
|
4e9d401002 | ||
|
|
3db2fc7d0f | ||
|
|
0101d76113 | ||
|
|
6fabab6d4b | ||
|
|
905f1b0aaf | ||
|
|
6a5ab8e70c | ||
|
|
943b037589 | ||
|
|
5624cd44de | ||
|
|
8529f8b843 | ||
|
|
08be7c43cf | ||
|
|
aae76207ec | ||
|
|
5434f8330e | ||
|
|
e18b4ed119 | ||
|
|
51f6ffc093 | ||
|
|
72de7c6b14 | ||
|
|
bd4785d631 | ||
|
|
cb08f12470 | ||
|
|
04146db69b | ||
|
|
d3fe045a39 | ||
|
|
2be1e16087 | ||
|
|
051e44ae3e | ||
|
|
6d5ae7a258 | ||
|
|
2e69e140eb | ||
|
|
516c4e2c39 | ||
|
|
b58ed62000 | ||
|
|
c685818783 | ||
|
|
3e20ce56c9 | ||
|
|
dd8d67f659 | ||
|
|
5ef4061819 |
@@ -3,7 +3,7 @@ THE REMIND COPYRIGHT
|
||||
1. REMIND refers to the entire set of files and documentation in the
|
||||
REMIND package.
|
||||
|
||||
2. REMIND is Copyright 1999-2008 Roaring Penguin Software Inc.,
|
||||
2. REMIND is Copyright 1999-2010 Roaring Penguin Software Inc.,
|
||||
except where noted in individual files.
|
||||
|
||||
3. DISTRIBUTION AND USE
|
||||
|
||||
30
MICROSOFT-AND-APPLE
Normal file
30
MICROSOFT-AND-APPLE
Normal file
@@ -0,0 +1,30 @@
|
||||
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.
|
||||
|
||||
--
|
||||
David F. Skoll
|
||||
2
Makefile
2
Makefile
@@ -25,7 +25,7 @@ clean:
|
||||
cd src; $(MAKE) clean
|
||||
|
||||
test:
|
||||
cd src && $(MAKE) test
|
||||
@cd src && $(MAKE) test
|
||||
|
||||
distclean: clean
|
||||
rm -f config.cache config.log config.status src/Makefile src/config.h tests/test.out www/Makefile
|
||||
|
||||
15
WINDOWS
15
WINDOWS
@@ -1,15 +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.
|
||||
|
||||
--
|
||||
David F. Skoll.
|
||||
36
configure.in
36
configure.in
@@ -14,6 +14,36 @@ EOF
|
||||
|
||||
AC_CONFIG_HEADER(src/config.h)
|
||||
|
||||
if test "`uname -s`" = "Darwin" ; then
|
||||
trap 'echo Be patient...' INT TERM
|
||||
cat <<'EOF'
|
||||
|
||||
Please don't use Apple products. This script will continue in 30 seconds
|
||||
if you insist on compiling Remind on Mac OS X.
|
||||
|
||||
EOF
|
||||
for i in 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 ; do
|
||||
sleep 1
|
||||
done
|
||||
trap - INT
|
||||
trap - TERM
|
||||
fi
|
||||
|
||||
if uname -s | grep -i -q 'cygwin' ; then
|
||||
trap 'echo Be patient...' INT TERM
|
||||
cat <<'EOF'
|
||||
|
||||
Please don't use Microsoft products. This script will continue in 30
|
||||
seconds if you insist on compiling Remind on Cygwin.
|
||||
|
||||
EOF
|
||||
for i in 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 ; do
|
||||
sleep 1
|
||||
done
|
||||
trap - INT
|
||||
trap - TERM
|
||||
fi
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
@@ -31,7 +61,7 @@ AC_CHECK_SIZEOF(unsigned int)
|
||||
AC_CHECK_SIZEOF(unsigned long)
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_CHECK_HEADERS(sys/file.h glob.h)
|
||||
AC_CHECK_HEADERS(sys/file.h glob.h wctype.h locale.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_STRUCT_TM
|
||||
@@ -44,7 +74,7 @@ if test "$GCC" = yes; then
|
||||
CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(setenv unsetenv glob)
|
||||
VERSION=03.01.06
|
||||
AC_CHECK_FUNCS(setenv unsetenv glob mbstowcs setlocale)
|
||||
VERSION=03.01.13
|
||||
AC_SUBST(VERSION)
|
||||
AC_OUTPUT(src/Makefile www/Makefile src/version.h)
|
||||
|
||||
10
contrib/README
Normal file
10
contrib/README
Normal file
@@ -0,0 +1,10 @@
|
||||
This directory contains contributed scripts. They are provided
|
||||
"as-is" with no warranty. Please do not contact David Skoll
|
||||
or Roaring Penguin Software Inc. for help with these scripts;
|
||||
instead, contact the script authors.
|
||||
|
||||
You should check the upstream sources; there may be newer versions
|
||||
of these scripts available.
|
||||
|
||||
--
|
||||
David F. Skoll
|
||||
279
contrib/ical2rem.pl
Executable file
279
contrib/ical2rem.pl
Executable file
@@ -0,0 +1,279 @@
|
||||
#!/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
|
||||
# - 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)
|
||||
--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 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 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 :
|
||||
13
contrib/rem2ics-0.93/Makefile
Normal file
13
contrib/rem2ics-0.93/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
DESTDIR?=
|
||||
PREFIX?=/usr
|
||||
BINDIR?=$(PREFIX)/bin
|
||||
MANDIR?=$(PREFIX)/share/man
|
||||
|
||||
default: rem2ics.1
|
||||
|
||||
rem2ics.1:
|
||||
pod2man -c "" rem2ics > rem2ics.1
|
||||
|
||||
install: rem2ics.1
|
||||
install -p -D rem2ics $(DESTDIR)$(BINDIR)/rem2ics
|
||||
install -p -D -m 0644 rem2ics.1 $(DESTDIR)$(MANDIR)/man1/rem2ics.1
|
||||
847
contrib/rem2ics-0.93/rem2ics
Executable file
847
contrib/rem2ics-0.93/rem2ics
Executable file
@@ -0,0 +1,847 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# rem2ics -- convert the output of "remind -s" into RFC2445 iCalendar format.
|
||||
|
||||
# Copyright 2007,2008,2009
|
||||
# Mark Atwood <me@mark.atwood.name>
|
||||
# Paul Hinze <paul dot t dot hinze at gmail dot com>
|
||||
# Michael Schultz <mjschultz at gmail dot com>
|
||||
#
|
||||
# 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
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
rem2ics - convert the output of "remind -s" into RFC2445 iCalendar format.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
TZ=I<timezone> B<rem2ics> [B<-man>] [B<-do>] [B<-norecur>] [B<-usetag>] E<lt>input E<gt>output
|
||||
|
||||
=head1 OPTIONS AND ARGUMENTS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<-man>
|
||||
|
||||
Print the manual page and exit.
|
||||
|
||||
=item B<-do>
|
||||
|
||||
Actually do the conversion. Otherwise just print a brief help message
|
||||
and usage example, and then exit.
|
||||
|
||||
=item B<-norecur>
|
||||
|
||||
Do not attempt to detect and fold together recurring events.
|
||||
|
||||
=item B<-usetag>
|
||||
|
||||
Generate UIDs using remind TAG clauses.
|
||||
|
||||
=back
|
||||
|
||||
Input is from standard input
|
||||
|
||||
Output is to standard output.
|
||||
|
||||
=head1 USAGE
|
||||
|
||||
remind -s360 -irem2ics=1 ~/.reminders 1 Jan 1991 | TZ=PST8PDT rem2ics -do >reminders.ics
|
||||
|
||||
This tells B<remind> to use ~/.reminders, and to process the entire
|
||||
range of dates it can handle (from Jan 1 1991 to Dec 31 2020), and to
|
||||
define a variable named C<rem2ics>, which can be used in
|
||||
C<IF !defined("rem2ics")> / C<ENDIF> pairs.
|
||||
B<rem2ics> will use a timezone of PST8PDT, and will fold events that
|
||||
have the same name and duration into a single iCalendar VEVENT object.
|
||||
|
||||
=head1 NOTES
|
||||
|
||||
=head2 Timezones and the TZ environment variable.
|
||||
|
||||
B<rem2ics> uses the TZ environment variable to determine the value of
|
||||
the RFC2445 TZID property. If you are running on a Linux or other GNU
|
||||
libc based system, you probably don't (and probably shouldn't)
|
||||
normally have TZ set. You can confirm this by running C<printenv TZ>
|
||||
at a shell prompt. If your remind data is in your "local time", and
|
||||
it probably is, you should probably set TZ to a good name for your
|
||||
local timezone just for the run of this script. You probably should
|
||||
NOT set TZ in your login scripts.
|
||||
|
||||
You can use TZ like this:
|
||||
|
||||
remind -s ~/.reminders | TZ=PST8PDT rem2ics -do >reminders.ics
|
||||
|
||||
or
|
||||
|
||||
remind -s ~/.reminders | TZ=US/Pacific rem2ics -do >reminders.ics
|
||||
|
||||
|
||||
If, for some reason, your remind files are all in GMT instead of
|
||||
localtime (you smart person you!), you can do this:
|
||||
|
||||
remind -s ~/.reminders | TZ=GMT rem2ics -do >reminders.ics
|
||||
|
||||
or
|
||||
|
||||
remind -s ~/.reminders | TZ=0 rem2ics -do >reminders.ics
|
||||
|
||||
and B<rem2ics> will use the ISO8601 "Z" notation for GMT time in the ics
|
||||
file. (Other synonyms for GMT are the empty string (not the same as
|
||||
the TZ not set), "I<0>", "I<Z>", "I<Zulu>", "I<Greenwitch>", "I<GMT>",
|
||||
"I<GMT+0>, and "I<GMT-0>".)
|
||||
|
||||
If you leave TZ undefined and unset, B<rem2ics> will use the ISO8601
|
||||
"T" notation date strings with no TZID property, which RFC2445 calls a
|
||||
"floating time". Who knows, it might work for you!
|
||||
|
||||
The TZ string value is literally incorporated into the iCalendar
|
||||
stream, so whatever your iCalendar-using application needs is what you
|
||||
should use. You may have to experiment a bit.
|
||||
|
||||
You can look around in C</usr/share/zoneinfo> to get the names of
|
||||
every timezone anywhere. This is the "Olson database" that RFC2445
|
||||
refers to. Read the man page for L<tzfile(5)> for more than you ever
|
||||
wanted to know about the format of these files, and about GNU libc's
|
||||
handling of timezones. As complex as it is, it's certainly better
|
||||
than what POSIX defines or what most legacy UNIX systems do, and most
|
||||
certainly better than Microsoft, who in their "cutting edge" "state of
|
||||
the art" "server" OS, still hasn't figured out that daylight time
|
||||
rules might be different in different years.
|
||||
|
||||
If you just ran B<rem2ics> without reading all this stuff, or if you
|
||||
don't want to worry about it at all, and somehow your iCalendar
|
||||
application manager is able to guess the proper timezone for you, just
|
||||
leave TZ undefined, and B<rem2ics> will use the ISO8601 "T" notation
|
||||
date strings with no TZID property, which RFC2445 calls a "floating
|
||||
time". Who knows, it might work for you!
|
||||
|
||||
=head2 Detecting recurring events
|
||||
|
||||
B<rem2ics> tries to detect recurring events. If any multiple events
|
||||
appear with exactly the text and exactly the same duration (including
|
||||
"no duration"), instead of multiple VEVENT objects, there will be just
|
||||
one VEVENT object, that will have a RFC2445 C<RDATE> property.
|
||||
|
||||
B<rem2ics> is not yet smart enough to derive an C<RRULE> based
|
||||
recurrance. If you really want that feature, either implement it and
|
||||
send in a patch, or contact the author and convince him to do it.
|
||||
|
||||
=head2 Other iCalendar Properties
|
||||
|
||||
B<rem2ics> does not generate C<DESCRIPTION> or C<LOCATION>. One
|
||||
would have to heuristically parse them out of the text, and everyone
|
||||
uses a idiosyncratic way of putting things in B<remind>.
|
||||
|
||||
If the B<-usetag> option is not used or no C<TAG> is set for a
|
||||
reminder, B<rem2ics> will synthesize C<UID> properties for each
|
||||
VEVENT, but the UIDs will be different (and unique) for each run of
|
||||
B<rem2ics>. If you run rem2ics twice and import the two resulting ICS
|
||||
streams into your new scheduling program, your appointments will
|
||||
appear twice. If, however, you have set C<TAG> clauses in your
|
||||
reminders and activated B<-usetag>, these will be used. The same
|
||||
applies for tags synthesized by B<remind>'s B<-y> option. Hence, it
|
||||
is more useful to use the B<-y> option than to let B<rem2ics>
|
||||
synthesize UIDs, because the UIDs will stay the same across multiple
|
||||
runs.
|
||||
|
||||
=head2 Other iCalendar Perl objects
|
||||
|
||||
Why does't B<rem2ics> use any of the iCalendar Perl stuff in CPAN?
|
||||
Because I don't trust them, and they are too big for this app. One
|
||||
links to a binary library. Another hasn't been maintained since 1991,
|
||||
and is full of notes as to how buggy and incomplete it is. And so
|
||||
forth. I am not at this moment interested in groveling around in
|
||||
L<Net::iCal>, L<DateTime::Format::iCal>, L<Tie::iCal>,
|
||||
L<iCal::Parser>, or C<libical>.
|
||||
|
||||
=head2 Previous implementation
|
||||
|
||||
There is a working quick & dirty rem2ics written in awk
|
||||
by Anthony J. Chivetta E<lt>achivetta@gmail.comE<gt>.
|
||||
|
||||
But it has the following problems: it doesn't escape the text, it
|
||||
doesn't handle events that cross over midnight, it doesn't do
|
||||
timezones, it doesn't enforce the correct EOL sequence, and it doesn't
|
||||
fold long lines. This is a replacement for that script.
|
||||
|
||||
=head1 TODO
|
||||
|
||||
If TZ not set, grab out of system config somewhere
|
||||
Detect recurring events.
|
||||
If I'm REALLY smart, derive RRULE
|
||||
Handle characters not in US-ASCII. Latin1? UTF8?
|
||||
|
||||
=head1 VERSION HISTORY
|
||||
|
||||
=over 8
|
||||
|
||||
=item version 0.1 2007-02-08
|
||||
|
||||
First cut.
|
||||
|
||||
=item version 0.2 2007-02-09
|
||||
|
||||
Reorg into multipass over a data structure.
|
||||
|
||||
=item version 0.3 2007-02-10
|
||||
|
||||
Collapse repeating events. Fold output lines.
|
||||
|
||||
=item version 0.9 2007-02-11
|
||||
|
||||
POD. Command line options. First public release.
|
||||
|
||||
=item version 0.91 2007-02-14
|
||||
|
||||
Bug fix, error message for non-recurring events
|
||||
|
||||
=item version 0.92 2008-01-28
|
||||
|
||||
Bug fix,
|
||||
rem2ics 0.91 chokes on timed reminders with
|
||||
duration using `remind -s` as it functions in remind-03.01.03.
|
||||
Remind 3.01 changed how the -s data is formated for events that have a duration
|
||||
Patch by Paul Hinze E<lt>paul dot t dot hinze at gmail dot comE<gt>
|
||||
and Michael Schultz E<lt>mjschultz at gmail dot comE<gt>
|
||||
|
||||
=item version 0.93 2009-06-25
|
||||
|
||||
Add B<-usetag> option to allow for UIDs to stay the same across multiple runs
|
||||
by using the remind TAG clause.
|
||||
Patch by Tim Weber E<lt>scy at scytale dot nameE<gt>
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<http://mark.atwood.name/code/rem2ics>
|
||||
|
||||
L<http://en.wikipedia.org/wiki/ICalendar>
|
||||
|
||||
L<http://tools.ietf.org/html/rfc2445>
|
||||
|
||||
L<http://www.roaringpenguin.com/en/penguin/openSourceProducts/remind>
|
||||
|
||||
L<remind(1)>
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Copyright 2007,2008,2009 by Mark Atwood E<lt>me+rem2ics@mark.atwood.nameE<gt>. L<http://mark.atwood.name/>.
|
||||
|
||||
Please report bugs (with patches, if possible).
|
||||
|
||||
Inspired by Anthony J. Chivetta E<lt>achivetta@gmail.comE<gt>'s
|
||||
rem2ics in awk.
|
||||
|
||||
Thank you to David Skoll E<lt>dfs@roaringpengiun.com<gt> for Remind,
|
||||
and to the IETF calsch wg for the iCalendar specification.
|
||||
|
||||
=cut
|
||||
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
|
||||
my $app_name = "rem2ics";
|
||||
my $app_version = "0.93";
|
||||
|
||||
# process the command line
|
||||
my %options;
|
||||
GetOptions(\%options, qw(man do norecurr usetag)) || pod2usage(2);
|
||||
pod2usage(-verbose => 2) if ($options{man});
|
||||
|
||||
unless ($options{do}) {
|
||||
print STDERR "Run \"$0 -man\" for information and usage examples.\n"
|
||||
. "Pay special attention to information about timezone.\n";
|
||||
exit(99);
|
||||
}
|
||||
|
||||
# grab the hostname
|
||||
# this is used as part of the UID property of each VEVENT
|
||||
my $ical_uid_hostname = $ENV{'HOSTNAME'};
|
||||
unless ($ical_uid_hostname) {
|
||||
print STDERR "Warning! "
|
||||
. "The environment variable HOSTNAME was not properly set.\n"
|
||||
. "Will use \"localhost\" in the RFC2445 UID property\n";
|
||||
$ical_uid_hostname = "localhost";
|
||||
}
|
||||
|
||||
# look for the TZ
|
||||
my $ical_tzid = undef;
|
||||
if (exists $ENV{'TZ'}) {
|
||||
$ical_tzid = $ENV{'TZ'};
|
||||
my %synonyms_for_gmt = (
|
||||
'' => 1, '0' => 1, 'z' => 1, 'zulu' => 1, 'greenwitch' => 1,
|
||||
'gmt' => 1, 'gmt+0' => 1, 'gmt-0' => 1, );
|
||||
if (exists $synonyms_for_gmt{lc($ical_tzid)}) {
|
||||
$ical_tzid = ''; # empty means GMT, below
|
||||
}
|
||||
} else {
|
||||
# leave it undefined, that has a meaning below
|
||||
}
|
||||
|
||||
# RFC2445 DTSTAMP property will be the time we started running ($^T)
|
||||
my ($ical_dtstamp);
|
||||
{
|
||||
my @gt = gmtime($^T);
|
||||
$ical_dtstamp = sprintf("%04d%02d%02dZ%02d%02d%02dZ",
|
||||
1900+$gt[5], $gt[4]+1, $gt[3],
|
||||
$gt[2], $gt[1], $gt[0]);
|
||||
}
|
||||
|
||||
my ($cnt, $v, @events);
|
||||
|
||||
$cnt = 0;
|
||||
foreach (<STDIN>) {
|
||||
$cnt++;
|
||||
|
||||
s/#.*//; # toss comments
|
||||
next if /^\s*$/; # skip blank lines
|
||||
chomp;
|
||||
|
||||
$v = undef;
|
||||
|
||||
# store the raw line
|
||||
$v->{src} = $_;
|
||||
$v->{cnt} = $cnt;
|
||||
|
||||
# split and parse the line
|
||||
# if we don't like it, skip it and go around again
|
||||
|
||||
# sf[0] = date, in yyyy/mm/dd format
|
||||
# sf[1] = special, usually "*"
|
||||
# sf[2] = tag, usually "*"
|
||||
# sf[3] = duration, in minutes
|
||||
# sf[4] = time, since midnight, in minutes
|
||||
# sf[5] = text
|
||||
|
||||
my @sf = split(' ', $_, 6);
|
||||
next unless ($sf[1] eq '*'); # ignore SPECIAL lines
|
||||
next unless (($sf[3] eq '*') or ($sf[3] =~ m/\d+/));
|
||||
next unless (($sf[4] eq '*') or ($sf[4] =~ m/\d+/));
|
||||
next unless (length($sf[5]) > 0);
|
||||
|
||||
my @dt = split('/', $sf[0], 3);
|
||||
next unless ($dt[0] =~ m/^\d{4}$/); # year
|
||||
next unless ($dt[1] =~ m/^\d{2}$/); # month
|
||||
next unless ($dt[2] =~ m/^\d{2}$/); # day
|
||||
|
||||
if ($sf[4] ne "*") { # a time was given
|
||||
# When an event has a time, remind -s "helpfully" also
|
||||
# puts it as text at the start of the text portion.
|
||||
# This takes the following form:
|
||||
# ##:##[a|p]m <rest of MSG>
|
||||
# or, if the event has a duration:
|
||||
# ##:##[a|p]m-##:##[a|p]m <rest of MSG>
|
||||
# Rather than a nasty regex, just splitting at the
|
||||
# first space does the trick.
|
||||
my($extra_time, $textmsg) = split(' ', $sf[5], 2);
|
||||
$sf[5] = $textmsg;
|
||||
}
|
||||
|
||||
$v->{sf} = \@sf;
|
||||
$v->{dt} = \@dt;
|
||||
|
||||
push @events, $v;
|
||||
}
|
||||
|
||||
# generate the "date time string" for each event
|
||||
foreach $v (@events) {
|
||||
if (${$v->{sf}}[4] eq "*") { # no time was given
|
||||
$v->{dts} = sprintf("%04d%02d%02d", @{$v->{dt}});
|
||||
} else { # a time was given
|
||||
my ($t_hr, $t_mn) = &idiv(${$v->{sf}}[4], 60);
|
||||
$v->{dts} = sprintf("%04d%02d%02dT%02d%02d00",
|
||||
@{$v->{dt}}, $t_hr, $t_mn);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
my(%grovel);
|
||||
|
||||
# if the user doesnt want recurrance detection
|
||||
unless ($options{norecurr}) {
|
||||
|
||||
# then dont put events in the grovel hash
|
||||
|
||||
foreach $v (@events) {
|
||||
# key is duration followed by text
|
||||
# \036 is "ASCII RS Record Separator"
|
||||
my $k = ${$v->{sf}}[3] . "\036" . ${$v->{sf}}[5];
|
||||
push @{$grovel{$k}}, $v;
|
||||
}
|
||||
|
||||
foreach my $k (keys %grovel) {
|
||||
if ((scalar @{$grovel{$k}}) > 1) {
|
||||
$v = ${$grovel{$k}}[0];
|
||||
$v->{recurlist} = \@{$grovel{$k}};
|
||||
foreach my $v0 (@{$grovel{$k}}) {
|
||||
$v0->{is_recurrance} = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# All of the individual events are in the @events array. All of the
|
||||
# unique combinations of duration/event name are the keys in the
|
||||
# %grovel hash, the elements of which are references to an arrays of
|
||||
# references to the events, in the same ordering as they we read by
|
||||
# us, which *ought* to be in datewise order. I don't know if "remind
|
||||
# -s" actually sorts into true chronological order. If it doesn't, we
|
||||
# might have a problem if a recurring event has two instances both on
|
||||
# the first day.
|
||||
|
||||
# Every event that is recurring has a "is_recurrance" property.
|
||||
# Additionally, (hopefully) the first/earliest event in a set of
|
||||
# recurrances has a "recurlist" property. The "recurlist" is a
|
||||
# reference to a list of references to each of the events. The first
|
||||
# one on that list will be the same event that has the "recurlist"
|
||||
# property. The "is_recurrance" property is a reference back to the
|
||||
# event that has the "recurlist" property.
|
||||
|
||||
foreach my $k (keys %grovel) {
|
||||
next if ((scalar @{$grovel{$k}}) <= 1);
|
||||
|
||||
my $recur_str = "";
|
||||
foreach $v (@{$grovel{$k}}) {
|
||||
if (${$v->{sf}}[4] eq "*") { # no time was given
|
||||
$recur_str .= ($v->{dts} . ",");
|
||||
} else {
|
||||
if (defined($ical_tzid)) {
|
||||
if ($ical_tzid eq '') { # tz is defined but empty, so in GMT
|
||||
$recur_str .= $v->{dts} . "Z,";
|
||||
} else { # tz is non-zero, so output the tz as well
|
||||
$recur_str .= $v->{dts} . ",";
|
||||
}
|
||||
} else { # undefined tz, just floating time
|
||||
$recur_str .= $v->{dts} . ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# the recur_str now has an extra comma at the end. chop it off
|
||||
chop($recur_str);
|
||||
${$grovel{$k}}[0]->{recur_str} = $recur_str;
|
||||
}
|
||||
|
||||
foreach my $k (keys %grovel) {
|
||||
next if ((scalar @{$grovel{$k}}) <= 1);
|
||||
my $v = ${$grovel{$k}}[0]; # grab the head of each list
|
||||
if (${$v->{sf}}[4] eq "*") { # no time was given
|
||||
# the default value type for an RDATE is DATE-TIME,
|
||||
# we much change the type to DATE
|
||||
$v->{i_rdate} = sprintf("RDATE;VALUE=DATE:");
|
||||
} else {
|
||||
if (defined($ical_tzid)) {
|
||||
if ($ical_tzid eq '') { # tz is defined but empty, so in GMT
|
||||
$v->{i_rdate} = sprintf("RDATE:");
|
||||
} else { # tz is non-zero, so output the tz as well
|
||||
$v->{i_rdate} = sprintf("RDATE;TZID=%s:", $ical_tzid);
|
||||
}
|
||||
} else { # undefined tz, just floating time
|
||||
$v->{i_rdate} = sprintf("RDATE:");
|
||||
}
|
||||
}
|
||||
# now stick the recur_str onto the end
|
||||
$v->{i_rdate} .= $v->{recur_str};
|
||||
# if we ever get memory tight, we can probably undef($v->{recur_str})
|
||||
}
|
||||
|
||||
foreach $v (@events) {
|
||||
# for recurrant events, skip those that arnt the "head"
|
||||
next if ($v->{is_recurrance} and (not $v->{recurlist}));
|
||||
|
||||
if (${$v->{sf}}[4] eq "*") { # no time was given
|
||||
$v->{i_dtstart} = sprintf("DTSTART:%s", $v->{dts});
|
||||
} else {
|
||||
if (defined($ical_tzid)) {
|
||||
if ($ical_tzid eq '') { # tz is defined but empty, so in GMT
|
||||
$v->{i_dtstart} = sprintf("DTSTART:%sZ", $v->{dts});
|
||||
} else { # tz is non-zero, so output the tz as well
|
||||
$v->{i_dtstart} = sprintf("DTSTART;TZID=%s:%s",
|
||||
$ical_tzid, $v->{dts});
|
||||
}
|
||||
} else { # undefined tz, just floating time
|
||||
$v->{i_dtstart} = sprintf("DTSTART:%s", $v->{dts});
|
||||
}
|
||||
}
|
||||
|
||||
if (${$v->{sf}}[3] ne "*") { # a duration was given
|
||||
# It's convienient that RFC2445 defines DURATION, thus we
|
||||
# don't need to calculate DTEND, with awkward figuring out
|
||||
# crossing hours, days, months, year, etc. Instead we
|
||||
# will let the iCalendar consuming application worry about it.
|
||||
$v->{i_duration} = sprintf("PT%dM", ${$v->{sf}}[3]);
|
||||
}
|
||||
}
|
||||
|
||||
# output header
|
||||
print "BEGIN:VCALENDAR\015\012"
|
||||
. "VERSION:2.0\015\012"
|
||||
. "PRODID:http://mark.atwood.name/code/rem2ics"
|
||||
. " $app_name $app_version\015\012";
|
||||
|
||||
# output each vevent
|
||||
foreach $v (@events) {
|
||||
# for recurrant events, only output the "head", skip the others
|
||||
next if ($v->{is_recurrance} and (not $v->{recurlist}));
|
||||
|
||||
print "BEGIN:VEVENT\015\012";
|
||||
my $tag = ${$v->{sf}}[2];
|
||||
# if $tag is not set, fake up a UID from start time, process id & input line count
|
||||
if ($tag eq "*" || !$options{usetag}) {
|
||||
$tag = sprintf("%x.%x.%x", $^T, $$, $v->{cnt});
|
||||
}
|
||||
# add rem2ics and hostname to UID
|
||||
print &lineify(sprintf("UID:rem2ics.%s@%s",
|
||||
$tag, $ical_uid_hostname));
|
||||
print &lineify("SUMMARY:" . "ify(${$v->{sf}}[5]));
|
||||
print &lineify($v->{i_dtstart});
|
||||
print &lineify("DURATION:" . $v->{i_duration})
|
||||
if ($v->{i_duration});
|
||||
print &lineify($v->{i_rdate})
|
||||
if ($v->{i_rdate});
|
||||
print &lineify("DTSTAMP:" . $ical_dtstamp);
|
||||
print &lineify("COMMENT: generated by $app_name $app_version\\n"
|
||||
. " http://mark.atwood.name/code/rem2ics\\n"
|
||||
. " data[" . $v->{cnt} . "]=|" . "ify($v->{src}) . "|");
|
||||
print "END:VEVENT\015\012";
|
||||
}
|
||||
|
||||
# output trailer
|
||||
print "END:VCALENDAR\015\012";
|
||||
|
||||
|
||||
# integer division, return both quotient and remainder
|
||||
sub idiv {
|
||||
my $n = shift; my $d = shift;
|
||||
my $r = $n; my $q = 0;
|
||||
while ($r >= $d) {
|
||||
$r = $r - $d;
|
||||
$q = $q + 1;
|
||||
}
|
||||
return ($q, $r);
|
||||
}
|
||||
|
||||
# todo, perl5 version that defines ()*, need to specify a requires up top
|
||||
sub lineify {
|
||||
return join("\015\012 ", unpack('(A72)*', shift)) . "\015\012";
|
||||
}
|
||||
|
||||
sub quotify {
|
||||
my $s = shift;
|
||||
return $s if $s =~ m/^(\w| )*$/;
|
||||
|
||||
$s =~ s/\\/\\\\/gso;
|
||||
$s =~ s/\n/\\n/gso;
|
||||
$s =~ s/\s/ /gso;
|
||||
$s =~ s/\"/\\"/gso;
|
||||
$s =~ s/\,/\\,/gso;
|
||||
$s =~ s/\:/\\:/gso;
|
||||
$s =~ s/\;/\\;/gso;
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
__END__
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
EOF
|
||||
50
contrib/rem2ics-0.93/rem2ics.spec
Normal file
50
contrib/rem2ics-0.93/rem2ics.spec
Normal file
@@ -0,0 +1,50 @@
|
||||
Name: rem2ics
|
||||
Version: 0.93
|
||||
Release: 1%{?dist}
|
||||
Summary: Converts the output of "remind -s" into RFC2445 iCalendar format
|
||||
|
||||
Group: Applications/Productivity
|
||||
License: GPLv2+
|
||||
URL: http://mark.atwood.name/code/rem2ics/
|
||||
Source0: http://mark.atwood.name/code/rem2ics/rem2ics-%{version}.tar.gz
|
||||
Source1: rem2ics-Makefile
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
BuildArch: noarch
|
||||
BuildRequires: perl
|
||||
|
||||
|
||||
%description
|
||||
rem2ics converts the output of "remind -s" into RFC2445 iCalendar format.
|
||||
You may want to install remind if you install this package.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -c
|
||||
cp -a %SOURCE1 Makefile
|
||||
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags}
|
||||
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir $RPM_BUILD_ROOT
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc
|
||||
%{_bindir}/rem2ics
|
||||
%{_mandir}/man1/rem2ics.1*
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Mar 25 2008 Till Maas <opensource till name> - 0.92-1
|
||||
- initial spec for Fedora
|
||||
56
contrib/remind-conf-mode.06/ac-remind.el
Normal file
56
contrib/remind-conf-mode.06/ac-remind.el
Normal file
@@ -0,0 +1,56 @@
|
||||
;;; setup for remind autocompletion (totally optional)
|
||||
|
||||
;; put something like
|
||||
;; (add-hook 'remind-conf-mode '(load-library "ac-remind")) in your .emacs file.
|
||||
(require 'auto-complete)
|
||||
|
||||
(define-key ac-complete-mode-map "\r" nil)
|
||||
|
||||
(defvar ac-remind-keywords
|
||||
'((candidates
|
||||
. (lambda ()
|
||||
(all-completions ac-target remind-keywords ))))
|
||||
"Source for remind-conf completion keywords.")
|
||||
|
||||
(defvar ac-remind-time-words
|
||||
'((candidates
|
||||
. (lambda ()
|
||||
(all-completions ac-target remind-time-words))))
|
||||
"Source for remind-conf time words completions.")
|
||||
|
||||
(defvar ac-remind-builtin-variables
|
||||
'((candidates
|
||||
. (lambda ()
|
||||
(all-completions ac-target remind-builtin-variables))))
|
||||
"Source for remind-conf builtin variables.")
|
||||
|
||||
(defvar ac-remind-type-keywords
|
||||
'((candidates
|
||||
. (lambda ()
|
||||
(all-completions ac-target remind-type-keywords))))
|
||||
"Source for remind-conf type keywords.")
|
||||
|
||||
(defvar ac-remind-builtin-functions
|
||||
'((candidates
|
||||
. (lambda ()
|
||||
(all-completions ac-target remind-builtin-functions))))
|
||||
"Source for remind-conf completion builtin functions.")
|
||||
|
||||
(add-hook 'remind-conf-mode-hook
|
||||
(lambda () "Makes auto-completion work in remind-conf-mode"
|
||||
(make-local-variable 'ac-sources)
|
||||
(setq ac-sources '(ac-remind-keywords
|
||||
ac-remind-builtin-variables
|
||||
ac-remind-builtin-functions
|
||||
ac-remind-type-keywords
|
||||
ac-remind-time-words
|
||||
ac-source-abbrev))
|
||||
(auto-complete-mode 1)))
|
||||
|
||||
(provide 'ac-remind)
|
||||
;; (define-skeleton ac-look
|
||||
;; ""
|
||||
;; (skeleton-read "well? ")
|
||||
;; "(when (looking-at (regexp-opt remind-" str " 'words))" \n
|
||||
;; >"(setq ac-sources '(ac-remind-" str ")))"
|
||||
;; )
|
||||
444
contrib/remind-conf-mode.06/remind-conf-mode.el
Normal file
444
contrib/remind-conf-mode.06/remind-conf-mode.el
Normal file
@@ -0,0 +1,444 @@
|
||||
;;; remind-conf-mode.el --- A mode to help configure remind.
|
||||
|
||||
;; Copyright (C) 2008 Shelagh Manton <shelagh.manton@gmail.com>
|
||||
|
||||
;; Author: Shelagh Manton <shelagh.manton@gmail.com> with help from
|
||||
;; David F. Skoll
|
||||
;; Keywords: remind configure mode
|
||||
;; Version: .04
|
||||
|
||||
;; 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., 59 Temple Place - Suite 330, Boston, MA
|
||||
;; 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Use this mode to help with the configuration of remind configuration files.
|
||||
;; Put (require 'remind-conf-mode) in your .emacs file
|
||||
;; or (autoload 'remind-conf-mode "remind-conf-mode" "Mode to help with remind files" t)
|
||||
;; also put (add-to-list 'auto-mode-alist '("\\.rem\\'" . remind-conf-mode)) and
|
||||
;; (setq auto-mode-alist
|
||||
;; (cons '(".reminders$" . remind-conf-mode) auto-mode-alist))
|
||||
;; if you want to have the mode work automatically when you open a remind configuration file.
|
||||
|
||||
;; If you want to use the auto-complete stuff, you will need to download and install the
|
||||
;; auto-complete library from http://www.cx4a.org/pub/auto-complete.el and put
|
||||
;; (require 'auto-complete) in your emacs with
|
||||
;; (add-hook 'remind-conf-mode-hook
|
||||
;; (lambda ()
|
||||
;; (make-local-variable 'ac-sources)
|
||||
;; (setq ac-sources '(ac-remind-conf ac-remind-builtin-variables ac-remind-builtin-functions))
|
||||
;; (auto-complete t)))
|
||||
;; in your .emacs file
|
||||
|
||||
;; PS. you could add ac-source-abbrev ac-source-words-in-buffer to have abbrevs and
|
||||
;; other words in buffer auto-complete too
|
||||
|
||||
;;; History:
|
||||
;; Thu, Feb 14, 2008
|
||||
;; Based mode on wpld-mode tutorial and sample-mode on emacs wiki.
|
||||
;; Ideas from mupad.el for font-lock styles.
|
||||
;; Mon, Jan 26, 2008
|
||||
;; Added rem-setup-colors to make it easy for colourised remind output.
|
||||
;; Added a demo skeleton for people to copy for easy entry of coloured remind entries.
|
||||
;; tried to hook in the auto-complete library so that all known functions and keywords can be easily entered.
|
||||
;; EXPERIMENTAL, but seems to work well here (emacs cvs).
|
||||
;; Seems to work without case folding which is nice. wonder why it didn't yesterday?
|
||||
|
||||
;;; Code:
|
||||
|
||||
|
||||
(require 'font-lock); this goes in the define-derived-mode part.
|
||||
(when (featurep 'xemacs)
|
||||
(require 'overlay)) ;I wonder if this will help with font-lock and xemacs?
|
||||
|
||||
|
||||
(defgroup remind-conf nil
|
||||
"Options for remind-conf-mode."
|
||||
:group 'remind-conf
|
||||
:prefix "remind-conf-")
|
||||
|
||||
|
||||
(defvar remind-conf-mode-hook nil
|
||||
"Hook to run in `remind-conf-mode'.")
|
||||
|
||||
;; keymap
|
||||
|
||||
(defvar remind-conf-mode-map
|
||||
(let ((remind-conf-mode-map (make-sparse-keymap)))
|
||||
remind-conf-mode-map)
|
||||
"Keymap for `remind-conf-mode'.")
|
||||
|
||||
(define-key remind-conf-mode-map "\C-cr" 'rem-skel)
|
||||
(define-key remind-conf-mode-map "\C-ct" 'rem-today)
|
||||
(define-key remind-conf-mode-map "\C-cd" 'rem-today-skel)
|
||||
(define-key remind-conf-mode-map "\C-cw" 'rem-week-away)
|
||||
(define-key remind-conf-mode-map "\C-cx" 'rem-tomorrow)
|
||||
(define-key remind-conf-mode-map "\C-ca" 'rem-days-away)
|
||||
(define-key remind-conf-mode-map "\M-j" 'remind-indent-line)
|
||||
(define-key remind-conf-mode-map (kbd "RET") 'remind-indent-line)
|
||||
(define-key remind-conf-mode-map "\C-c\C-c" 'rem-save-file)
|
||||
|
||||
;; syntax-table
|
||||
|
||||
(defvar remind-conf-syntax-table
|
||||
(let ((remind-conf-syntax-table (make-syntax-table text-mode-syntax-table)))
|
||||
(modify-syntax-entry ?\; ". 1b" remind-conf-syntax-table)
|
||||
(modify-syntax-entry ?\# ". 1b" remind-conf-syntax-table)
|
||||
(modify-syntax-entry ?\n "> b" remind-conf-syntax-table)
|
||||
;Names with _ are still one word.
|
||||
(modify-syntax-entry ?_ "w" remind-conf-syntax-table)
|
||||
(modify-syntax-entry ?. "w" remind-conf-syntax-table)
|
||||
remind-conf-syntax-table)
|
||||
"Syntax table for `remind-conf-mode'.")
|
||||
|
||||
;;; keyword sets
|
||||
|
||||
(defconst remind-keywords
|
||||
(sort
|
||||
(list "RUN" "REM" "ONCE" "SATISFY" "BEFORE" "UNSET" "OMIT"
|
||||
"OMIT" "DATE" "SKIP" "ONCE" "AFTER" "WARN" "PRIORITY" "AT" "SCHED" "IF" "ELSE" "ENDIF"
|
||||
"WARN" "UNTIL" "THROUGH" "SCANFROM" "DURATION" "TAG" "MSG" "MSF" "CAL" "SPECIAL" "IFTRIG"
|
||||
"PS" "PSFILE" "BANNER" "INCLUDE" "PUSH-OMIT-CONTEXT" "DEBUG" "DUMPVARS"
|
||||
"CLEAR-OMIT-CONTEXT" "POP-OMIT-CONTEXT" "SET" "ERRMSG" "FSET"
|
||||
"EXIT" "FLUSH" "PRESERVE" "MOON" "COLOR" "COLOUR")
|
||||
#'(lambda (a b) (> (length a) (length b)))))
|
||||
|
||||
(defconst remind-type-keywords
|
||||
(sort
|
||||
(list "INT" "STRING" "TIME" "DATE" "SHADE")
|
||||
#'(lambda (a b) (> (length a) (length b)))))
|
||||
|
||||
(defconst remind-builtin-variables
|
||||
(sort
|
||||
(list "$CalcUTC" "$CalMode" "$DefaultPrio" "$EndSent" "$EndSentIg" "$NumTrig"
|
||||
"$FirstIndent" "$FoldYear" "$FormWidth" "$MinsFromUTC" "$LatDeg" "$LatMin" "$LatSec"
|
||||
"$Location" "$LongDeg" "$LongMin" "$LongSec" "$MaxSatIter" "$SubsIndent")
|
||||
#'(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" "Fri" "Friday" "Saturday" "Sat" "Sun" "Sunday")
|
||||
#'(lambda (a b) (> (length a) (length b)))))
|
||||
|
||||
(defconst remind-builtin-functions
|
||||
(sort
|
||||
(list "abs" "access" "shell" "args" "asc" "baseyr" "char" "choose" "coerce" "date"
|
||||
"dawn" "today" "day" "daysinmon" "defined" "dosubst" "dusk" "easterdate" "easter"
|
||||
"filedir" "filename" "getenv" "hour" "iif" "trigger" "index" "isdst" "isleap"
|
||||
"isomitted" "hebdate" "hebday" "hebmon" "hebyear" "language" "ord" "thisyear"
|
||||
"sunrise" "sunset" "lower" "max" "min" "minute" "mon" "moondate" "moontime"
|
||||
"moonphase" "now" "ostype" "plural" "realnow" "realtoday" "sgn" "strlen" "psshade"
|
||||
"substr" "trigdate" "trigger" "trigtime" "trigvalid" "typeof" "upper" "psmoon"
|
||||
"value" "version" "wkday" "wkdaynum" "msgprefix" "msgsuffix" "year")
|
||||
#'(lambda (a b) (> (length a) (length b)))))
|
||||
|
||||
;;; faces
|
||||
;;example of setting up special faces for a mode.
|
||||
|
||||
(defvar remind-conf-command-face 'remind-conf-command-face
|
||||
"Remind commands.")
|
||||
(defface remind-conf-command-face
|
||||
'((t :foreground "SeaGreen4" :bold t))
|
||||
"Font Lock mode face used to highlight commands."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-conf-keyword-face 'remind-conf-keyword-face
|
||||
"Remind keywords.")
|
||||
(defface remind-conf-keyword-face
|
||||
'((t :foreground "blue violet"))
|
||||
"Font Lock mode face used to highlight keywords."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-conf-substitutes-face 'remind-conf-substitutes-face
|
||||
"Remind substitutes.")
|
||||
(defface remind-conf-substitutes-face
|
||||
'((t :foreground "blue2"))
|
||||
"Font Lock mode face used to highlight substitutes."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-conf-endline-face 'remind-conf-endline-face
|
||||
"Remind endline.")
|
||||
(defface remind-conf-endline-face
|
||||
'((t :foreground "goldenrod2" :bold t))
|
||||
"Font Lock mode face used to highlight commands."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-conf-variable-face 'remind-conf-variable-face
|
||||
"Remind variable.")
|
||||
(defface remind-conf-variable-face
|
||||
'((t :foreground "DeepPink2" :bold t))
|
||||
"Font Lock mode face used to highlight commands."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-conf-color-face 'remind-conf-color-face
|
||||
"Remind color variables.")
|
||||
(defface remind-conf-color-face
|
||||
'((t :foreground "gold" :bold t))
|
||||
"Font Lock mode face used to highlight color changes."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-conf-delta-face 'remind-conf-delta-face
|
||||
"Remind deltas.")
|
||||
(defface remind-conf-delta-face
|
||||
'((t :foreground "sandy brown" :bold t))
|
||||
"Font Lock mode face used to highlight deltas."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-comment-face 'remind-comment-face
|
||||
"Remind comments.")
|
||||
(defface remind-comment-face
|
||||
'((t :foreground "brown"))
|
||||
"Font-lock face for highlighting comments."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-string-face 'remind-string-face
|
||||
"Remind strings.")
|
||||
(defface remind-string-face
|
||||
'((t :foreground "tomato"))
|
||||
"Font lock mode face used to highlight strings."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-time-face 'remind-time-face
|
||||
"Remind time words.")
|
||||
(defface remind-time-face
|
||||
'((t :foreground "LightSeaGreen" :bold t))
|
||||
"Font lock mode face to highlight time phrases."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defvar remind-conf-type-face 'remind-conf-type-face
|
||||
"Remind type keywords.")
|
||||
(defface remind-conf-type-face
|
||||
'((t :foreground "orange" :bold t))
|
||||
"Font lock mode face to highlight type keywords."
|
||||
:group 'remind-conf)
|
||||
|
||||
(defcustom rem-post-save-function ""
|
||||
"Name of shell function that can be run when you save and close a remind file.
|
||||
|
||||
If you put a & after the name of the function, it will run asyncronously. This might
|
||||
be useful if the process takes a long time."
|
||||
:type 'string
|
||||
:group 'remind-conf
|
||||
)
|
||||
|
||||
;; keywords
|
||||
|
||||
(defconst remind-conf-font-lock-keywords-1
|
||||
(list
|
||||
'("^[\;\#]\\s-+.*$" . remind-comment-face)
|
||||
(cons (regexp-opt remind-keywords 'words) remind-conf-keyword-face)
|
||||
'("%[\"_]" . font-lock-warning-face)
|
||||
'("\\(%[a-mops-w]\\)" . remind-conf-substitutes-face)
|
||||
'("\"[^\"]*\"" . remind-string-face))
|
||||
"Minimal font-locking for `remind-conf-mode'.")
|
||||
|
||||
(defconst remind-conf-font-lock-keywords-2
|
||||
(append remind-conf-font-lock-keywords-1
|
||||
(list
|
||||
(cons (regexp-opt remind-time-words 'words) remind-time-face)
|
||||
(cons (regexp-opt remind-builtin-functions 'words) remind-conf-command-face)
|
||||
'("%$" . remind-conf-endline-face)))
|
||||
"Additional commands to highlight in `remind-conf-mode'.")
|
||||
|
||||
(defconst remind-conf-font-lock-keywords-3
|
||||
(append remind-conf-font-lock-keywords-2
|
||||
(list
|
||||
(cons (regexp-opt remind-type-keywords 'words) remind-conf-type-face)
|
||||
'("\[[a-zA-Z]\\{3,6\\}\]" . remind-conf-color-face)
|
||||
'("\\s-+\\([12][0-9]\\|3[01]\\|0?[0-9]\\)\\s-+" . remind-conf-substitutes-face);better date regexp
|
||||
'("\\s-+\\(\\(?:20\\|19\\)[0-9][0-9]\\)\\s-+" . remind-conf-substitutes-face);years
|
||||
'("\\s-+\\(2[0-4]\\|[01]?[0-9][.:][0-5][0-9]\\)\\s-+" . remind-conf-substitutes-face);24hour clock, more precise
|
||||
'("\\s-+\\([+-][+-]?[1-9][0-9]*\\)\\s-+" 1 remind-conf-delta-face prepend)
|
||||
(cons (regexp-opt remind-builtin-variables 'words) remind-conf-variable-face)))
|
||||
"The ultimate in highlighting experiences for `remind-conf-mode'.")
|
||||
|
||||
(defcustom remind-conf-font-lock-keywords 'remind-conf-font-lock-keywords-3
|
||||
"Font-lock highlighting level for `remind-conf-mode'."
|
||||
:group 'remind-conf
|
||||
:type '(choice (const :tag "Barest minimum of highlighting." remind-conf-font-lock-keywords-1)
|
||||
(const :tag "Medium highlighting." remind-conf-font-lock-keywords-2)
|
||||
(const :tag "Highlighting deluxe." remind-conf-font-lock-keywords-3)))
|
||||
|
||||
;;; Indentation (I'm sure this could be made more simple. But at least it works.)
|
||||
|
||||
(defcustom remind-indent-level 4
|
||||
"User definable indentation."
|
||||
:group 'remind-conf
|
||||
:type '(integer)
|
||||
)
|
||||
|
||||
(defun remind-indent-line ()
|
||||
"Indent current line for remind configuration files."
|
||||
(interactive)
|
||||
(forward-line 0) ;remember this happens on every line as it is done per line basis
|
||||
(if (bobp)
|
||||
(indent-line-to 0)
|
||||
(let ((not-indented t) cur-indent)
|
||||
(if (looking-at "^[ \t]*\\<\\(ENDIF\\|POP\\(?:-OMIT-CONTEXT\\)?\\)\\>")
|
||||
(progn
|
||||
(save-excursion
|
||||
(forward-line -1)
|
||||
(setq cur-indent (- (current-indentation) remind-indent-level))) ;note that not-indented is still t
|
||||
(if (< cur-indent 0) (setq cur-indent 0)))
|
||||
(save-excursion
|
||||
(while not-indented
|
||||
(forward-line -1)
|
||||
(if (looking-at "^[ \t]*\\<\\(ENDIF\\|POP\\(?:-OMIT-CONTEXT\\)?\\)\\>")
|
||||
(progn
|
||||
(setq cur-indent 0)
|
||||
(delete-horizontal-space) ;don't know why I need this when other similar indent functions don't.
|
||||
(setq not-indented nil))
|
||||
(if (looking-at "\\<\\(IF\\(?:TRIG\\)?\\|PUSH\\(?:-OMIT-CONTEXT\\)?\\)\\>")
|
||||
(progn
|
||||
(setq cur-indent remind-indent-level)
|
||||
(setq not-indented nil))
|
||||
(if (bobp)
|
||||
(setq not-indented nil))))))
|
||||
(if cur-indent
|
||||
(indent-line-to cur-indent)
|
||||
(indent-line-to 0))))))
|
||||
|
||||
;;; Convenience functions
|
||||
|
||||
(define-skeleton rem-skel
|
||||
"Skeleton to insert a rem line in a remind configuration file."
|
||||
nil
|
||||
"REM "(skeleton-read "Date? " )
|
||||
("Optional: How many days ahead? " " +" str )
|
||||
resume:
|
||||
("Optional: At what time? Format eg 13:00. " " AT " str)
|
||||
resume:
|
||||
("Optional: How many minutes ahead? " " +" str )
|
||||
resume:
|
||||
("Optional: At what priority? eg 0-9999" " PRIORITY " str )
|
||||
resume:
|
||||
" MSG %\"" (skeleton-read "Your message? " )"%b%\"%" \n
|
||||
)
|
||||
|
||||
(define-skeleton rem-today-skel
|
||||
"Skeleton to insert a line for today's date."
|
||||
nil
|
||||
"REM " (format-time-string "%d %b %Y")
|
||||
("Optional: At what time? Format eg 13:20. " " AT " str)
|
||||
resume:
|
||||
("Optional: How many minutes ahead? " " +" str )
|
||||
resume:
|
||||
("Optional: At what priority? eg 0-9999" " PRIORITY " str )
|
||||
resume:
|
||||
" MSG " (skeleton-read "Your message? " )"%b.%" \n
|
||||
)
|
||||
|
||||
(defun rem-today ()
|
||||
"Insert the date for today in a remind friendly style."
|
||||
(interactive)
|
||||
(insert (format-time-string "%e %b %Y")))
|
||||
|
||||
(defun rem-tomorrow ()
|
||||
"Insert tomorrow's date in a remind friendly style."
|
||||
(interactive)
|
||||
(insert (format-time-string "%e %b %Y" (time-add (current-time) (days-to-time 1)))))
|
||||
|
||||
(defun rem-days-away (arg)
|
||||
"Insert a day N number of days in the future.
|
||||
|
||||
Takes a prefix argument, but defaults to 4."
|
||||
(interactive "nHow many Days?: ")
|
||||
(insert (format-time-string "%e %b %Y" (time-add (current-time) (days-to-time arg)))))
|
||||
|
||||
(defun rem-week-away ()
|
||||
"Insert a day 7 days in the future."
|
||||
(interactive)
|
||||
(insert (format-time-string "%e %b %Y" (time-add (current-time) (days-to-time 7)))))
|
||||
|
||||
(setq skeleton-end-hook nil) ; so the skeletons will not automatically go to a new line.
|
||||
|
||||
;;; private function
|
||||
;; could make it useful for others. Put somethin like the following in your .emacs
|
||||
;(setq rem-post-save-function "~/bin/dailypic &")
|
||||
|
||||
(defun rem-save-file ()
|
||||
"Save the file and start the shell function in one go.
|
||||
|
||||
This function will close the window after running. It needs the
|
||||
variable `rem-post-save-function' to be set. It will be most
|
||||
useful to people who have some sort of function they run to use
|
||||
remind data ie procucing calendars."
|
||||
(interactive)
|
||||
(if (boundp 'rem-post-save-function)
|
||||
(progn (save-buffer)
|
||||
(shell-command rem-post-save-function)
|
||||
(kill-buffer-and-window))
|
||||
(error "`rem-post-save-function' variable is not set")))
|
||||
|
||||
(defun rem-setup-colors ()
|
||||
"Insert set of variables for coloured output in remind messages."
|
||||
(interactive)
|
||||
(find-file (expand-file-name "~/.reminders"))
|
||||
(goto-char 0) ;we do want it somewhere near the top of the file.
|
||||
(save-excursion
|
||||
(re-search-forward "\n\n"); squeeze it in where you have a free line.
|
||||
(insert "\nSET Esc CHAR(27)
|
||||
SET Nrm Esc + \"[0m\"
|
||||
SET Blk Esc + \"[0;30m\"
|
||||
SET Red Esc + \"[0;31m\"
|
||||
SET Grn Esc + \"[0;32m\"
|
||||
SET Ylw Esc + \"[0;33m\"
|
||||
SET Blu Esc + \"[0;34m\"
|
||||
SET Mag Esc + \"[0;35m\"
|
||||
SET Cyn Esc + \"[0;36m\"
|
||||
SET Wht Esc + \"[0;37m\"
|
||||
SET Gry Esc + \"[30;1m\"
|
||||
SET BrRed Esc + \"[31;1m\"
|
||||
SET BrGrn Esc + \"[32;1m\"
|
||||
SET BrYlw Esc + \"[33;1m\"
|
||||
SET BrBlu Esc + \"[34;1m\"
|
||||
SET BrMag Esc + \"[35;1m\"
|
||||
SET BrCyn Esc + \"[36;1m\"
|
||||
SET BrWht Esc + \"[37;1m\" \n \n")))
|
||||
|
||||
;; So now you can do things like:
|
||||
|
||||
(define-skeleton birthcol
|
||||
"Make birthdays magenta.
|
||||
Acts on the region or places point where it needs to be."
|
||||
nil
|
||||
"[Mag]" _ " [Nrm]")
|
||||
|
||||
;; finally the derived mode.
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode remind-conf-mode text-mode "REM"
|
||||
"Major mode for editing remind calendar configuration files.
|
||||
|
||||
\\{remind-conf-mode-map}"
|
||||
:syntax-table remind-conf-syntax-table
|
||||
(set (make-local-variable 'font-lock-keywords-case-fold-search) t) ;this is not working atm 2009-04-13
|
||||
(set (make-local-variable 'font-lock-defaults) '(remind-conf-font-lock-keywords))
|
||||
(set (make-local-variable 'comment-start) ";")
|
||||
(set (make-local-variable 'comment-start) "#")
|
||||
(set (make-local-variable 'comment-end) "\n")
|
||||
(set (make-local-variable 'fill-column) '100);cause I was having problems with autofill.
|
||||
(set (make-local-variable 'indent-line-function) 'remind-indent-line)
|
||||
(use-local-map remind-conf-mode-map)
|
||||
)
|
||||
|
||||
|
||||
(provide 'remind-conf-mode)
|
||||
;;; remind-conf-mode.el ends here
|
||||
|
||||
;;; Indentation code
|
||||
;;; work out how to make the syntax highlighting work only before the (MSG|MSF)
|
||||
;;; keywords and not after.
|
||||
;;; for my own use. keymap to save file and do dailypic C-c C-c in time honoured tradition?
|
||||
114
docs/WHATSNEW
114
docs/WHATSNEW
@@ -1,5 +1,117 @@
|
||||
CHANGES TO REMIND
|
||||
|
||||
* 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
|
||||
places.
|
||||
|
||||
- BUG FIX: Allow specification of margins as low as 0 points in rem2ps,
|
||||
courtesy of Jonathan Kamens.
|
||||
|
||||
- BUG FIX: Permit compilation with gcc 2.95 (which doesn't allow variable
|
||||
declarations after non-declaration statements in a block.)
|
||||
|
||||
- BUG FIX: Several minor documentation errors corrected courtesy of
|
||||
Simon Ruderich.
|
||||
|
||||
- BUG FIX: Spurious test harness failure was fixed.
|
||||
|
||||
* 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
|
||||
example, in English "%i" might yield "on 01-25" while "%*i" yields only
|
||||
"01-25".
|
||||
|
||||
- BUG FIX: The "dusk" and "dawn" calculations were completely wrong. They
|
||||
have been fixed. Also, sunrise/sunset calculations have been tweaked,
|
||||
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
|
||||
|
||||
- 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
|
||||
degrees for Civil Dawn. This has been fixed.
|
||||
|
||||
- BUG FIXES: Clarified the man pages and fixed some typos.
|
||||
|
||||
- BUG FIX: Add THROUGH to the remind.vim syntax highlighting file.
|
||||
|
||||
- ENHANCEMENT (?): Allow SPECIAL COLOR to be spelled SPECIAL COLOUR.
|
||||
|
||||
- BUG FIX: Apply minor Debian cleanups reported by Kurt B. Kaiser.
|
||||
|
||||
* Version 3.1 Patch 10 - 2010-11-01
|
||||
|
||||
- NOTE: This is the 20th anniversary of Remind's first public release.
|
||||
|
||||
- ENHANCEMENT: Add the THROUGH keyword. You can omit blocks of dates with:
|
||||
|
||||
OMIT start THROUGH end
|
||||
|
||||
and the syntax REM start THROUGH end is equivalent to REM start *1 UNTIL end
|
||||
|
||||
- ENHANCEMENT: Add support for multibyte characters (eg, UTF-8) in calendar
|
||||
output. Note that UTF-8 strings are still not supported in PostScript
|
||||
output.
|
||||
|
||||
- ENHANCEMENT: Add support for UTF-8 line-drawing characters in calendar
|
||||
output.
|
||||
|
||||
- ENHANCEMENT: You can have multiple TAG clauses in a REM statement.
|
||||
|
||||
- BUG FIX: Avoid spawning long-running background processes in "make test".
|
||||
|
||||
- BUG FIX: Don't declare variables in the middle of statements (old C
|
||||
compilers choke.)
|
||||
|
||||
* 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.
|
||||
|
||||
- ENHANCEMENT: Support DURATION in TkRemind. Thanks to Marek Marczykowski.
|
||||
|
||||
- BUG FIX: Don't change the order of PS and PSFILE reminders. Bug found
|
||||
by John McGowan.
|
||||
|
||||
- BUG FIX: "REM 1990-01-01 SATISFY 1" would yield a spurious parse error
|
||||
in earlier versions of 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
|
||||
|
||||
- ENHANCEMENT: Include some useful scripts in contrib/
|
||||
|
||||
- ENHANCEMENT: Add the $T, $Td, $Tm, $Tw, $Ty, $U, $Ud, $Um, $Uw, $Uy
|
||||
special variables to make reminder files less wordy. See man page
|
||||
for details.
|
||||
|
||||
- MINOR ENHANCEMENT: Set an icon photo window manager resource on TkRemind.
|
||||
|
||||
- POLICY CHANGE: Discourage use of Remind on MS Windows or Apple Mac OS X.
|
||||
|
||||
- BUG FIX: Ignore msgprefix() and msgsuffix() on RUN-type reminders.
|
||||
|
||||
- BUG FIX: Adjust Remind and Rem2PS so that SHADE specials don't obliterate
|
||||
earlier MOON specials.
|
||||
|
||||
- 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
|
||||
|
||||
- ENHANCEMENT: Wherever you could write "day Mon year", the parser now
|
||||
accepts "YYYY-MM-DD". This applies on the command-line and to the
|
||||
REM and OMIT keywords. You can avoid wrapping date calculations in
|
||||
the trigger() function in many cases.
|
||||
|
||||
- ENHANCEMENT: New slide() built-in function eases some complicated reminders.
|
||||
|
||||
* Version 3.1 Patch 6 - 2008-11-16
|
||||
|
||||
- MAJOR ENHANCEMENT: A new OMITFUNC clause gives you additional
|
||||
@@ -467,7 +579,7 @@ CHANGES TO REMIND
|
||||
+ BUG FIXES
|
||||
|
||||
- Fixed sunset(), sunrise() and minsfromutc() functions which were broken
|
||||
by 3.0.17. (In 3.0.17, they did not account for daylight savings time.)
|
||||
by 3.0.17. (In 3.0.17, they did not account for daylight saving time.)
|
||||
|
||||
- Updated "finnish.h" to include proper URL and translation of all
|
||||
error messages.
|
||||
|
||||
@@ -27,8 +27,8 @@ RUN OFF
|
||||
################################################
|
||||
# Ensure required version of remind is used... #
|
||||
################################################
|
||||
IF version() < "03.01.02"
|
||||
ERRMSG This file requires at least version 03.01.02 of Remind.%
|
||||
IF version() < "03.01.08"
|
||||
ERRMSG This file requires at least version 03.01.08 of Remind.%
|
||||
ERRMSG This version is version [version()].
|
||||
EXIT
|
||||
ENDIF
|
||||
@@ -95,11 +95,8 @@ SET Week_3 15
|
||||
SET Week_4 22
|
||||
FSET _last(mo) "1 " + MON((mo%12)+1) + " --7"
|
||||
|
||||
# Shorthand for commonly used expression...
|
||||
FSET _trig() TRIGGER(TRIGDATE())
|
||||
|
||||
# Handy function to provide SCANFROM dates...
|
||||
FSET _back(days) TRIGGER(TODAY()-days)
|
||||
FSET _back(days) TODAY()-days
|
||||
|
||||
###########################################################
|
||||
# Function which returns a string in "am/pm" format based #
|
||||
@@ -169,14 +166,14 @@ FSET _mail(from, subj) "fastmail -f " + \
|
||||
REM 4 July SCANFROM [_back(7)] SATISFY 1
|
||||
|
||||
IF WKDAYNUM(TRIGDATE()) == Sat
|
||||
REM [TRIGGER(TRIGDATE())] MSG Independence day (actual)
|
||||
OMIT [TRIGGER(TRIGDATE()-1)] MSG Independence day (observed)
|
||||
REM [TRIGDATE()] MSG Independence day (actual)
|
||||
OMIT [TRIGDATE()-1] MSG Independence day (observed)
|
||||
ELSE
|
||||
IF WKDAYNUM(TRIGDATE()) == Sun
|
||||
REM [TRIGGER(TRIGDATE())] MSG Independence day (actual)
|
||||
OMIT [TRIGGER(TRIGDATE()+1)] MSG Independence day (observed)
|
||||
REM [TRIGDATE()] MSG Independence day (actual)
|
||||
OMIT [TRIGDATE()+1] MSG Independence day (observed)
|
||||
ELSE
|
||||
OMIT [TRIGGER(TRIGDATE())] MSG Independence day
|
||||
OMIT [TRIGDATE()] MSG Independence day
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
@@ -197,7 +194,7 @@ REM Mon 8 SATISFY 1
|
||||
# But only actually trigger the delayed meeting if the previous
|
||||
# Monday was a holiday
|
||||
IF ISOMITTED(TRIGDATE()-7)
|
||||
REM [TRIGGER(TRIGDATE())] MSG Delayed meeting
|
||||
REM [TRIGDATE()] MSG Delayed meeting
|
||||
ENDIF
|
||||
|
||||
############################################################################
|
||||
@@ -288,12 +285,12 @@ REM Sat Sun SPECIAL SHADE 220
|
||||
|
||||
SET SaveTrig $NumTrig
|
||||
SET easter EASTERDATE(YEAR(TODAY()))
|
||||
REM [TRIGGER(easter-46)] MSG %"Ash Wednesday%"
|
||||
REM [TRIGGER(easter-7)] MSG %"Palm Sunday%"
|
||||
OMIT [TRIGGER(easter-2)] MSG %"Good Friday%"
|
||||
OMIT [TRIGGER(easter)] MSG %"Easter%" Sunday
|
||||
REM [TRIGGER(easter+39)] MSG %"Ascension Day%"
|
||||
REM [TRIGGER(easter+49)] MSG %"Pentecost%"
|
||||
REM [easter-46] MSG %"Ash Wednesday%"
|
||||
REM [easter-7] MSG %"Palm Sunday%"
|
||||
OMIT [easter-2] MSG %"Good Friday%"
|
||||
OMIT [easter] MSG %"Easter%" Sunday
|
||||
REM [easter+39] MSG %"Ascension Day%"
|
||||
REM [easter+49] MSG %"Pentecost%"
|
||||
|
||||
# Some holidays are omitted, some are not. You may want to change
|
||||
# which ones are omitted - use the general forms shown below.
|
||||
@@ -305,13 +302,13 @@ REM Mon Jan [Week_3] MSG Martin Luther King - %"MLK Day%"
|
||||
REM Feb 2 MSG %"Ground Hog Day%"
|
||||
REM Feb 14 MSG %"Valentine's%" Day
|
||||
REM Mon Feb [Week_3] SCANFROM [_back(7)] SATISFY 1
|
||||
OMIT [_trig()] MSG %"President's Day%"
|
||||
OMIT [trigdate()] MSG %"President's Day%"
|
||||
REM Mar 17 MSG %"St. Patrick's%" Day
|
||||
|
||||
# The DST rules are accurate for most locations in
|
||||
# North America
|
||||
REM Sun Apr 1 ++2 UNTIL 1 Jan 2007 MSG Daylight Savings Time - %"DST starts%" %b
|
||||
REM Sun Mar 8 ++2 FROM 1 Jan 2007 MSG Daylight Savings Time - %"DST starts%" %b
|
||||
REM Sun Apr 1 ++2 UNTIL 1 Jan 2007 MSG Daylight Saving Time - %"DST starts%" %b
|
||||
REM Sun Mar 8 ++2 FROM 1 Jan 2007 MSG Daylight Saving Time - %"DST starts%" %b
|
||||
|
||||
REM Apr 1 MSG %"April Fool's%" Day
|
||||
REM Mon Tue Wed Thu Fri Sat 15 Apr MSG %"Income tax%" due
|
||||
@@ -320,18 +317,18 @@ REM Sat May [Week_1] MSG %"Kentucky Derby%"
|
||||
REM Sun May [Week_2] MSG %"Mother's Day%"
|
||||
REM Sat May [Week_3] MSG %"Armed Forces Day%"
|
||||
REM Mon [_last(May)] SCANFROM [_back(7)] SATISFY 1
|
||||
OMIT [_trig()] MSG %"Memorial Day%"
|
||||
OMIT [trigdate()] MSG %"Memorial Day%"
|
||||
REM Jun 14 MSG %"Flag Day%"
|
||||
REM Sun Jun [Week_3] MSG %"Father's Day%"
|
||||
REM Mon Sep [Week_1] SCANFROM [_back(7)] SATISFY 1
|
||||
OMIT [_trig()] MSG %"Labor Day%"
|
||||
OMIT [trigdate()] MSG %"Labor Day%"
|
||||
REM Mon Oct [Week_2] MSG %"Columbus Day%"
|
||||
REM Nov 11 MSG %"Veterans Day%"
|
||||
|
||||
# The DST rules are accurate for most locations in
|
||||
# North America
|
||||
REM Sun [_last(Oct)] UNTIL 1 Jan 2007 MSG Daylight Savings Time - %"DST over%"
|
||||
REM Sun 1 Nov FROM 1 Jan 2007 MSG Daylight Savings Time - %"DST over%"
|
||||
REM Sun [_last(Oct)] UNTIL 1 Jan 2007 MSG Daylight Saving Time - %"DST over%"
|
||||
REM Sun 1 Nov FROM 1 Jan 2007 MSG Daylight Saving Time - %"DST over%"
|
||||
|
||||
REM Oct 30 MSG %"Mischief Night%"
|
||||
REM Oct 31 MSG %"Halloween%"
|
||||
@@ -339,9 +336,9 @@ REM Tue Nov 2 SCANFROM [_back(7)] \
|
||||
SATISFY [(YEAR(TRIGDATE()) % 4) == 0] \
|
||||
MSG %"Election%" Day
|
||||
REM Thu Nov [Week_4] SCANFROM [_back(7)] SATISFY 1
|
||||
OMIT [_trig()] MSG %"Thanksgiving%" Day
|
||||
OMIT [trigdate()] MSG %"Thanksgiving%" Day
|
||||
REM Fri Nov [Week_4+1] SCANFROM [_back(7)] SATISFY 1
|
||||
OMIT [_trig()] MSG %"Thanksgiving%" (cont.)
|
||||
OMIT [trigdate()] MSG %"Thanksgiving%" (cont.)
|
||||
OMIT Dec 24 MSG %"Christmas Eve%"
|
||||
OMIT Dec 25 MSG %"Christmas%" Day
|
||||
|
||||
@@ -379,10 +376,10 @@ REM PS Border Border moveto \
|
||||
([hebday(today())] [hebmon(today())]) show
|
||||
|
||||
# Fill in the phases of the moon on the PostScript calendar
|
||||
[trigger(moondate(0))] SPECIAL MOON 0
|
||||
[trigger(moondate(1))] SPECIAL MOON 1
|
||||
[trigger(moondate(2))] SPECIAL MOON 2
|
||||
[trigger(moondate(3))] SPECIAL MOON 3
|
||||
[moondate(0)] SPECIAL MOON 0
|
||||
[moondate(1)] SPECIAL MOON 1
|
||||
[moondate(2)] SPECIAL MOON 2
|
||||
[moondate(3)] SPECIAL MOON 3
|
||||
|
||||
# The following example puts sunrise and sunset times in PostScript in the
|
||||
# calendar - the sizes are hard-coded, however, and work best in landscape.
|
||||
@@ -435,11 +432,11 @@ SET InIsrael 0
|
||||
SET Reform 0
|
||||
|
||||
# Convenient function definition to save typing
|
||||
FSET _h(x, y) TRIGGER(HEBDATE(x,y))
|
||||
FSET _h(x, y) HEBDATE(x,y)
|
||||
FSET _h2(x, y) HEBDATE(x, y, TODAY()-7)
|
||||
FSET _PastSat(x, y) TRIGGER(IIF(WKDAYNUM(_h2(x,y))!=6, _h2(x,y), _h2(x,y)+1))
|
||||
FSET _PastSun(x, y) TRIGGER(IIF(WKDAYNUM(_h2(x,y))!=0, _h2(x,y), _h2(x,y)+1))
|
||||
FSET _PastMon(x, y) TRIGGER(IIF(WKDAYNUM(_h2(x,y))!=1, _h2(x,y), _h2(x,y)+1))
|
||||
FSET _PastSat(x, y) IIF(WKDAYNUM(_h2(x,y))!=6, _h2(x,y), _h2(x,y)+1)
|
||||
FSET _PastSun(x, y) IIF(WKDAYNUM(_h2(x,y))!=0, _h2(x,y), _h2(x,y)+1)
|
||||
FSET _PastMon(x, y) IIF(WKDAYNUM(_h2(x,y))!=1, _h2(x,y), _h2(x,y)+1)
|
||||
|
||||
# Default values in case InIsrael and Reform are not set
|
||||
SET InIsrael VALUE("InIsrael", 0)
|
||||
@@ -470,7 +467,7 @@ ELSE
|
||||
ENDIF
|
||||
|
||||
# Because Kislev can change length, we must be more careful about Chanukah
|
||||
FSET _chan(x) TRIGGER(HEBDATE(24, "Kislev", today()-9)+x)
|
||||
FSET _chan(x) HEBDATE(24, "Kislev", today()-9)+x
|
||||
[_chan(1)] ++4 MSG %"Chanukah 1%" is %b.
|
||||
[_chan(2)] MSG %"Chanukah 2%"
|
||||
[_chan(3)] MSG %"Chanukah 3%"
|
||||
@@ -493,9 +490,9 @@ ENDIF
|
||||
|
||||
# If Purim is on Sunday, then Fast of Esther is 11 Adar.
|
||||
IF WKDAYNUM(_h2(13, "Adar")) != 6
|
||||
REM [TRIGGER(_h2(13, "Adar"))] ++4 MSG %"Fast of Esther%" is %b.
|
||||
REM [_h2(13, "Adar")] ++4 MSG %"Fast of Esther%" is %b.
|
||||
ELSE
|
||||
REM [TRIGGER(_h2(11, "Adar"))] ++4 MSG %"Fast of Esther%" is %b.
|
||||
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.
|
||||
@@ -511,7 +508,13 @@ IF !InIsrael && !Reform
|
||||
[_h(22, "Nisan")] MSG %"Pesach 8%"
|
||||
ENDIF
|
||||
|
||||
[_PastSun(27, "Nisan")] ++4 MSG %"Yom HaShoah%" is %b.
|
||||
REM [_PastSun(27, "Nisan")] SATISFY 1
|
||||
|
||||
IF $Tw == 5
|
||||
REM [_PastSun(26, "Nisan")] ++4 MSG %"Yom HaShoah%" is %b.
|
||||
ELSE
|
||||
REM [_PastSun(27, "Nisan")] ++4 MSG %"Yom HaShoah%" is %b.
|
||||
ENDIF
|
||||
|
||||
# If 4 Iyar is a Friday, then Yom Hazikaron is
|
||||
# the Wednesday before and Yom Ha'atzmaut is on
|
||||
@@ -521,7 +524,7 @@ IF WKDAYNUM(_h2(4, "Iyar")) == 5
|
||||
[_h(2, "Iyar")] ++4 MSG %"Yom Hazikaron%" is %b.
|
||||
[_h(3, "Iyar")] ++4 MSG %"Yom Ha'atzmaut%" is %b.
|
||||
ELSE
|
||||
IF WKDAYNUM(_h2, 4, "Iyar") == 0
|
||||
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.
|
||||
ELSE
|
||||
|
||||
@@ -1,53 +1,79 @@
|
||||
" Vim syntax file
|
||||
" Language: Remind
|
||||
" Maintainer: Davide Alberani <alberanid@bigfoot.com>
|
||||
" Last change: 03 Dec 1999
|
||||
" Version: 0.1
|
||||
" URL: http://members.xoom.com/alberanid/vim/syntax/remind.vim
|
||||
" Maintainer: Davide Alberani <alberanid@libero.it>
|
||||
" Last Change: 18 Sep 2009
|
||||
" Version: 0.5
|
||||
" URL: http://erlug.linux.it/~da/vim/syntax/remind.vim
|
||||
"
|
||||
" remind is a sophisticated reminder service
|
||||
" you can download remind from ftp://ftp.doe.carleton.ca/pub/remind-3.0/
|
||||
" you can download remind from:
|
||||
" http://www.roaringpenguin.com/penguin/open_source_remind.php
|
||||
|
||||
" clear any unwanted syntax defs
|
||||
syn clear
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" shut case off
|
||||
" shut case off.
|
||||
syn case ignore
|
||||
|
||||
syn keyword remindCommands REM OMIT SET FSET UNSET
|
||||
syn keyword remindExpiry UNTIL SCANFROM SCAN WARN SCHED
|
||||
syn keyword remindExpiry UNTIL FROM SCANFROM SCAN WARN SCHED THROUGH
|
||||
syn keyword remindTag PRIORITY TAG
|
||||
syn keyword remindTimed AT DURATION
|
||||
syn keyword remindMove ONCE SKIP BEFORE AFTER
|
||||
syn keyword remindSpecial INCLUDE INC BANNER PUSH-OMIT-CONTEXT PUSH CLEAR-OMIT-CONTEXT CLEAR POP-OMIT-CONTEXT POP
|
||||
syn keyword remindSpecial INCLUDE INC BANNER PUSH-OMIT-CONTEXT PUSH CLEAR-OMIT-CONTEXT CLEAR POP-OMIT-CONTEXT POP COLOR COLOUR
|
||||
syn keyword remindRun MSG MSF RUN CAL SATISFY SPECIAL PS PSFILE SHADE MOON
|
||||
syn keyword remindConditional IF ELSE ENDIF IFTRIG
|
||||
syn keyword remindDebug DEBUG DUMPVARS DUMP ERRMSG FLUSH PRESERVE
|
||||
syn match remindComment "#.*$"
|
||||
syn region remindString start=+'+ end=+'+ skip=+\\\\\|\\'+ oneline
|
||||
syn region remindString start=+"+ end=+"+ skip=+\\\\\|\\"+ oneline
|
||||
syn keyword remindDebug DEBUG DUMPVARS DUMP ERRMSG FLUSH PRESERVE
|
||||
syn match remindVar "\$[_a-zA-Z][_a-zA-Z0-9]*"
|
||||
syn match remindSubst "%[^ ]"
|
||||
syn match remindAdvanceNumber "\(\*\|+\|-\|++\|--\)[0-9]\+"
|
||||
" XXX: use different separators for dates and times?
|
||||
syn match remindDateSeparators "[/:@\.-]" contained
|
||||
syn match remindTimes "[0-9]\{1,2}[:\.][0-9]\{1,2}" contains=remindDateSeparators
|
||||
" XXX: why not match only valid dates? Ok, checking for 'Feb the 30' would
|
||||
" be impossible, but at least check for valid months and times.
|
||||
syn match remindDates "'[0-9]\{4}[/-][0-9]\{1,2}[/-][0-9]\{1,2}\(@[0-9]\{1,2}[:\.][0-9]\{1,2}\)\?'" contains=remindDateSeparators
|
||||
" This will match trailing whitespaces that seem to break rem2ps.
|
||||
" Courtesy of Michael Dunn.
|
||||
syn match remindWarning display excludenl "\S\s\+$"ms=s+1
|
||||
|
||||
if !exists("did_remind_syntax_inits")
|
||||
let did_remind_syntax_inits = 1
|
||||
hi link remindCommands Function
|
||||
hi link remindExpiry Repeat
|
||||
hi link remindTag Label
|
||||
hi link remindTimed Statement
|
||||
hi link remindMove Statement
|
||||
hi link remindSpecial Include
|
||||
hi link remindRun Function
|
||||
hi link remindConditional Conditional
|
||||
hi link remindComment Comment
|
||||
hi link remindString String
|
||||
hi link remindDebug Debug
|
||||
hi link remindVar Identifier
|
||||
hi link remindSubst Constant
|
||||
hi link remindAdvanceNumber Number
|
||||
|
||||
if version >= 508 || !exists("did_remind_syn_inits")
|
||||
if version < 508
|
||||
let did_remind_syn_inits = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
HiLink remindCommands Function
|
||||
HiLink remindExpiry Repeat
|
||||
HiLink remindTag Label
|
||||
HiLink remindTimed Statement
|
||||
HiLink remindMove Statement
|
||||
HiLink remindSpecial Include
|
||||
HiLink remindRun Function
|
||||
HiLink remindConditional Conditional
|
||||
HiLink remindComment Comment
|
||||
HiLink remindTimes String
|
||||
HiLink remindString String
|
||||
HiLink remindDebug Debug
|
||||
HiLink remindVar Identifier
|
||||
HiLink remindSubst Constant
|
||||
HiLink remindAdvanceNumber Number
|
||||
HiLink remindDateSeparators Comment
|
||||
HiLink remindDates String
|
||||
HiLink remindWarning Error
|
||||
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
let b:current_syntax = "remind"
|
||||
|
||||
"EOF vim: ts=8 noet tw=100 sw=8 sts=0
|
||||
" vim: ts=8 sw=2
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.TH CM2REM 1 "18 October 1999"
|
||||
.UC4
|
||||
.UC 4
|
||||
.SH NAME
|
||||
cm2rem.tcl \- Convert Sun's "cm" input file to Remind format
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.TH REM 1 "30 August 2007"
|
||||
.UC4
|
||||
.UC 4
|
||||
.SH NAME
|
||||
rem \- Invoke Remind with a default filename
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.TH REM2PS 1 "11 April 2005"
|
||||
.UC4
|
||||
.UC 4
|
||||
.SH NAME
|
||||
rem2ps \- draw a PostScript calendar from Remind output
|
||||
.SH SYNOPSIS
|
||||
@@ -362,7 +362,10 @@ Other back-ends may understand other specials. A back end should
|
||||
\fIsilently ignore\fR a reminder with a special it doesn't understand.
|
||||
.PP
|
||||
\fItag\fR is whatever tag the user provided with the \fBTAG\fR clause,
|
||||
or "*" if no tag was provided.
|
||||
or "*" if no tag was provided. If there is more than one \fBTAG\fR clause,
|
||||
the tags appear in a comma-separated list. For example, the command
|
||||
\fBREM TAG foo TAG bar TAG quux\fR would result in \fBfoo,bar,quux\fR
|
||||
in the \fItag\fR field.
|
||||
.PP
|
||||
\fIdur\fR is the \fBDURATION\fR value in minutes, or "*" if no duration
|
||||
was provided.
|
||||
|
||||
452
man/remind.1
452
man/remind.1
@@ -29,6 +29,10 @@ 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.
|
||||
.TP
|
||||
.B \-j\fR[\fIn\fR]
|
||||
Runs \fBRemind\fR in "purge" mode to get rid of expired reminders.
|
||||
See the section PURGE MODE for details.
|
||||
.TP
|
||||
.B \-r
|
||||
The \fB\-r\fR option disables \fBRUN\fR directives and the \fBshell()\fR
|
||||
function. As of Remind 3.00.17, using \fB\-u\fR implies \fB\-r\fR.
|
||||
@@ -57,6 +61,11 @@ causes \fBRemind\fR to use VT100 line-drawing characters to draw
|
||||
the calendar. The characters are hard-coded and will only work
|
||||
on terminals that emulate the VT00 line-drawing character set.
|
||||
.TP
|
||||
.B 'u'
|
||||
is similar to 'l', but causes \fBRemind\fR to use UNICODE line-drawing
|
||||
characters to draw the calendar. The characters are hard-coded and will
|
||||
only work on terminals that are set to UTF-8 character encoding.
|
||||
.TP
|
||||
.B 'c'
|
||||
causes \fBRemind\fR to use VT100 escape sequences to approximate
|
||||
SPECIAL COLOR reminders. The approximation is (of necessity) very
|
||||
@@ -140,10 +149,16 @@ The \fB\-h\fR option ("hush...") suppresses certain warning and information
|
||||
messages. In particular, if no reminders are triggered, this mode
|
||||
produces no output.
|
||||
.TP
|
||||
\fB\-a\fR
|
||||
The \fB\-a\fR option causes \fBRemind\fR not to immediately trigger timed
|
||||
reminders that would also be queued. It also causes \fBRemind\fR not to
|
||||
place timed reminders in a calendar.
|
||||
.B \-a
|
||||
The \fB\-a\fR option causes \fBRemind\fR not to immediately trigger
|
||||
timed reminders that trigger on the current day. It also causes
|
||||
\fBRemind\fR not to place timed reminders in a calendar. If you
|
||||
supply two or more \fB\-a\fR options, then \fBRemind\fR \fIwill\fR
|
||||
trigger timed reminders that are in the future, but will not trigger
|
||||
timed reminders whose time has passed. (Regardless of how many
|
||||
\fB\-a\fR options you supply, \fBRemind\fR will not include timed
|
||||
reminders in the calendar if at least one \fB\-a\fR option is used.)
|
||||
|
||||
.TP
|
||||
\fB\-q\fR
|
||||
The \fB\-q\fR option causes \fBRemind\fR not to queue timed reminders
|
||||
@@ -216,25 +231,22 @@ As an example, suppose you have an X Window program called \fBxmessage\fR that
|
||||
pops up a window and displays its invocation arguments. You could use:
|
||||
.PP
|
||||
.nf
|
||||
remind '-kxmessage %s &' ...
|
||||
remind '\-kxmessage %s &' ...
|
||||
.fi
|
||||
.PP
|
||||
to have all of your \fBMSG\fR-type reminders processed using xmessage.
|
||||
.PP
|
||||
A word of warning: It is very easy to spawn dozens of xmessage processes
|
||||
with the above technique. So be very careful. Also, the \fIcmd\fR is passed
|
||||
as an argument to \fBsprintf()\fR. If you use formatting directives other
|
||||
than %s, or use more than one %s directive, there's a good chance that
|
||||
you'll crash \fBRemind\fR. Finally, because all shell and whitespace
|
||||
characters are escaped, the program you execute with the \fB\-k\fR
|
||||
option must be prepared to handle the entire message as a single argument.
|
||||
A word of warning: It is very easy to spawn dozens of xmessage
|
||||
processes with the above technique. So be very careful. Because all
|
||||
shell and whitespace characters are escaped, the program you execute
|
||||
with the \fB\-k\fR option must be prepared to handle the entire
|
||||
message as a single argument.
|
||||
.RE
|
||||
.TP
|
||||
\fB\-z\fR[\fIn\fR]
|
||||
Runs \fBRemind\fR in the 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 5, and can range from 5 to 60. Note that the use of the
|
||||
\fB\-z\fR[\fIn\fR] Runs \fBRemind\fR in the 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
|
||||
@@ -286,6 +298,10 @@ set \fBRemind\fR's notion of "now" to a particular time. Supplying
|
||||
a \fItime\fR on the command line also implicitly enables the \fB\-q\fR
|
||||
option and disables the \fB\-z\fR option.
|
||||
.PP
|
||||
If you would rather specify the date more succinctly, you can supply
|
||||
it as YYYY-MM-DD or YYYY/MM/DD. You can even supply a date and
|
||||
time on the command line as one argument: YYYY-MM-DD@HH:MM.
|
||||
.PP
|
||||
In addition, you can supply a \fIrepeat\fR parameter, which has the
|
||||
form *\fInum\fR. This causes \fBRemind\fR to be run \fInum\fR times,
|
||||
with the date incrementing on each iteration. You may have to enclose
|
||||
@@ -306,7 +322,7 @@ very simple and almost immediately understandable:
|
||||
to the baroque and obscure:
|
||||
.PP
|
||||
.nf
|
||||
REM [trigger(date(thisyear, 1, 1) + 180)] ++5 OMIT \\
|
||||
REM [date(thisyear, 1, 1) + 180] ++5 OMIT \\
|
||||
sat sun BEFORE MSG [ord(thisyear-1980)] payment due %b!
|
||||
.fi
|
||||
.PP
|
||||
@@ -322,6 +338,16 @@ wish to pass a \fBRemind\fR script through the C pre-processor, which
|
||||
interprets the '#' character as the start of a pre-processing
|
||||
directive.
|
||||
.PP
|
||||
Note that \fBRemind\fR processes line continuations before anything else.
|
||||
For example:
|
||||
.PP
|
||||
.nf
|
||||
# This is a comment \\
|
||||
This line is part of the comment because of line continuation \\
|
||||
and so on.
|
||||
REM MSG This line is not ignored (no \\ above)
|
||||
.fi
|
||||
.PP
|
||||
\fBRemind\fR is not case sensitive; you can generally use any mixture of upper-
|
||||
or lower-case for commands, parameters, invocation options, etc.
|
||||
.SH THE REM COMMAND
|
||||
@@ -342,7 +368,7 @@ Its syntax is:
|
||||
[\fBAT\fR \fItime\fR [\fItdelta\fR] [\fItrepeat\fR]]
|
||||
[\fBSCHED\fR \fIsched_function\fR]
|
||||
[\fBWARN\fR \fIwarn_function\fR]
|
||||
[\fBUNTIL\fR \fIexpiry_date\fR]
|
||||
[\fBUNTIL\fR \fIexpiry_date\fR | \fBTHROUGH\fR \fIlast_date\fR]
|
||||
[\fBSCANFROM\fR \fIscan_date\fR | \fBFROM\fR \fIstart_date\fR]
|
||||
[\fBDURATION\fR \fIduration\fR]
|
||||
[\fBTAG\fR \fItag\fR]
|
||||
@@ -633,6 +659,48 @@ the
|
||||
.I weekday
|
||||
constraints.
|
||||
.PP
|
||||
.B SHORT-HAND DATE SPECIFICATIONS
|
||||
.PP
|
||||
In addition to spelling out the day, month and year separately, you
|
||||
can specify YYYY-MM-DD or YYYY/MM/DD. For example, the following statements
|
||||
are equivalent:
|
||||
.PP
|
||||
.nf
|
||||
REM 5 June 2010 MSG Cool!
|
||||
REM 2010-06-05 MSG Cool!
|
||||
.fi
|
||||
.PP
|
||||
You can also specify a date and time as YYYY-MM-DD@HH:MM. These
|
||||
statements are equivalent:
|
||||
.PP
|
||||
.nf
|
||||
REM 19 Dec 2010 AT 16:45 MSG Hi
|
||||
REM 2010-12-19@16:45 MSG Hi
|
||||
.fi
|
||||
.PP
|
||||
There's one subtlety with short-hand date specifications: The following
|
||||
statements are \fInot\fR equivalent:
|
||||
.PP
|
||||
.nf
|
||||
REM 19 Dec 2010 AT 16:45 +60 MSG Hi
|
||||
REM 2010-12-19@16:45 +60 MSG Hi
|
||||
.fi
|
||||
.PP
|
||||
In the second statement, the "+60" is a \fIdelta\fR that applies to the
|
||||
date rather than a \fItdelta\fR that applies to the time. We recommend
|
||||
explicitly using the AT keyword with timed reminders.
|
||||
.PP
|
||||
.B THE REMIND ALGORITHM
|
||||
.PP
|
||||
\fBRemind\fR uses the following algorithm to compute a trigger date:
|
||||
Starting from the current date, it examines each day, one at a time, until
|
||||
it finds a date that satisfies the date specification, or proves to
|
||||
itself that no such date exists. (Actually, \fBRemind\fR merely
|
||||
\fIbehaves\fR as if it used this algorithm; it would be much too slow
|
||||
in practice. Internally, \fBRemind\fR uses much faster techniques to
|
||||
calculate a trigger date.) See DETAILS ABOUT TRIGGER COMPUTATION for
|
||||
more information.
|
||||
.PP
|
||||
.B BACKWARD SCANNING
|
||||
.PP
|
||||
Sometimes, it is necessary to specify a date as being a set amount of
|
||||
@@ -641,7 +709,7 @@ month is computed as the first Monday in the next month, minus 7 days.
|
||||
The \fIback\fR specification in the reminder is used in this case:
|
||||
.PP
|
||||
.nf
|
||||
REM Mon 1 -7 MSG Last Monday of every month.
|
||||
REM Mon 1 \-7 MSG Last Monday of every month.
|
||||
.fi
|
||||
.PP
|
||||
A \fIback\fR is specified with one or two dashes followed by an integer.
|
||||
@@ -730,12 +798,21 @@ Another example: Suppose you have jury duty from 30 November 1992 until
|
||||
of your jury duty, as well as 2 days ahead of time:
|
||||
.PP
|
||||
.nf
|
||||
REM 30 Nov 1992 *1 +2 UNTIL 4 Dec 1992 MSG Jury duty
|
||||
REM 1992-11-30 *1 +2 UNTIL 1992-12-04 MSG Jury duty
|
||||
.fi
|
||||
.PP
|
||||
Note that the \fIrepeat\fR of *1 is necessary; without it, the reminder
|
||||
would be issued only on 30 November (and the two days preceding.)
|
||||
.PP
|
||||
As a special case, you can use the \fBTHROUGH\fR keyword instead of
|
||||
*1 and \fBUNTIL\fR. The following two \fBREM\fR commands are equivalent:
|
||||
.PP
|
||||
.nf
|
||||
REM 1992-11-30 *1 +2 UNTIL 1992-12-04 MSG Jury duty
|
||||
|
||||
REM 1992-11-30 +2 THROUGH 1992-12-04 MSG Jury duty
|
||||
.fi
|
||||
.PP
|
||||
.B THE ONCE KEYWORD
|
||||
.PP
|
||||
Sometimes, it is necessary to ensure that reminders are run only once
|
||||
@@ -783,7 +860,7 @@ the reminder is triggered on the first of each month, as well as the day
|
||||
preceding it. The omitted days are counted.
|
||||
.PP
|
||||
.nf
|
||||
REM 1 -1 OMIT Sat Sun MSG Last working day of month
|
||||
REM 1 \-1 OMIT Sat Sun MSG Last working day of month
|
||||
.fi
|
||||
.PP
|
||||
Again, in the above example, the \fIback\fR of \-1 normally causes the
|
||||
@@ -911,7 +988,7 @@ command-line option. This is useful, for example, in .xinitrc
|
||||
scripts, where you can use the command:
|
||||
.PP
|
||||
.nf
|
||||
remind -fa myreminders &
|
||||
remind \-fa myreminders &
|
||||
.fi
|
||||
.PP
|
||||
This ensures that when you exit X-Windows, the \fBRemind\fR process is killed.
|
||||
@@ -939,11 +1016,11 @@ expressions and user-defined functions are explained. See the subsection
|
||||
The \fBTAG\fR keyword lets you "tag" certain reminders. This facility
|
||||
is used by certain back-ends or systems built around \fBRemind\fR,
|
||||
such as \fBTkRemind\fR. These back-ends have specific rules about
|
||||
tags; you should \fInot\fR use the \fBTAG\fR keyword yourself, or
|
||||
your script will interact badly with back-ends.
|
||||
tags; see their documentation for details.
|
||||
.PP
|
||||
The \fBTAG\fR keyword is followed by a tag consisting of up to
|
||||
48 characters.
|
||||
48 characters. You can have as many TAG clauses as you like in
|
||||
a given REM statement.
|
||||
.PP
|
||||
If you supply the \fB\-y\fR option to \fBRemind\fR, then any
|
||||
reminder that lacks a \fBTAG\fR will have one synthesized. The
|
||||
@@ -1239,6 +1316,10 @@ In addition to being a keyword in the \fBREM\fR command,
|
||||
.PP
|
||||
.RS
|
||||
\fBOMIT\fR \fIday\fR \fImonth\fR [\fIyear\fR]
|
||||
.PP
|
||||
or:
|
||||
.PP
|
||||
\fBOMIT\fR \fIday1\fR \fImonth1\fR \fIyear1\fR \fBTHROUGH\fR \fIday2\fR \fImonth2\fR \fIyear2\fR
|
||||
.RE
|
||||
.PP
|
||||
The \fBOMIT\fR command is used to "globally" omit certain days
|
||||
@@ -1257,8 +1338,16 @@ must create an \fBOMIT\fR command for each year. (Later, in the
|
||||
description of expressions and some of the more advanced features of
|
||||
\fBRemind\fR, you will see how to automate this for some cases.)
|
||||
.PP
|
||||
As with the REM command, you can use shorthand specifiers for dates;
|
||||
the following are equivalent:
|
||||
.PP
|
||||
.nf
|
||||
OMIT 7 Sep 1992
|
||||
OMIT 1992-09-07
|
||||
.fi
|
||||
.PP
|
||||
For convenience, you can use a \fIdelta\fR and \fBMSG\fR or \fBRUN\fR
|
||||
keyword in the \fBOMIT\fR command. The following sequences are exactly
|
||||
keyword in the \fBOMIT\fR command. The following sequences are
|
||||
equivalent:
|
||||
.PP
|
||||
.nf
|
||||
@@ -1270,6 +1359,36 @@ equivalent:
|
||||
OMIT 1 Jan +4 MSG New year's day is %b!
|
||||
.fi
|
||||
.PP
|
||||
The \fBTHROUGH\fR keyword lets you conveniently OMIT a range of days.
|
||||
The starting and ending points must be fully-specified (ie, they must
|
||||
include day, month and year.). For example, the following sequences
|
||||
are equivalent:
|
||||
.PP
|
||||
.nf
|
||||
OMIT 3 Jan 2011
|
||||
OMIT 4 Jan 2011
|
||||
OMIT 5 Jan 2011
|
||||
|
||||
and
|
||||
|
||||
OMIT 3 Jan 2011 THROUGH 5 Jan 2011
|
||||
.fi
|
||||
.PP
|
||||
You can make a THROUGH \fBOMIT\fR do double-duty as a \fBREM\fR command:
|
||||
.PP
|
||||
.nf
|
||||
OMIT 6 Sep 2010 THROUGH 10 Sep 2010 MSG Vacation
|
||||
.fi
|
||||
|
||||
.PP
|
||||
You can debug your global OMITs with the following command:
|
||||
.PP
|
||||
.nf
|
||||
OMIT DUMP
|
||||
.fi
|
||||
.PP
|
||||
The OMIT DUMP command prints the current global omits to standard output.
|
||||
.PP
|
||||
.B THE BEFORE, AFTER AND SKIP KEYWORDS
|
||||
.PP
|
||||
Normally, days that are omitted, whether by a global \fBOMIT\fR
|
||||
@@ -1339,7 +1458,7 @@ administrator.)
|
||||
If you specify a filename of "-" in the \fBINCLUDE\fR command, \fBRemind\fR
|
||||
will begin reading from standard input.
|
||||
.PP
|
||||
If you specify a \fIdirectory\fR as the argument to \fBINCLDUE\fR, then
|
||||
If you specify a \fIdirectory\fR as the argument to \fBINCLUDE\fR, then
|
||||
\fBRemind\fR will process all files in that directory that match the shell
|
||||
patterm "*.rem". The files are processed in sorted order; the sort order
|
||||
matches that used by the shell when it expands "*.rem".
|
||||
@@ -1753,7 +1872,7 @@ If non-zero, then the \fB\-c\fR option was supplied on the command line.
|
||||
.B $Daemon (read-only)
|
||||
If the daemon mode \fB\-z\fR was invoked, contains the number of
|
||||
minutes between wakeups. If not running in daemon mode, contains
|
||||
0. For the MS-DOS version, always contains 0.
|
||||
0.
|
||||
.TP
|
||||
.B $DateSep
|
||||
This variable can be set only to "/" or "-". It holds the character
|
||||
@@ -1769,15 +1888,13 @@ from 0 to 9999.
|
||||
.TP
|
||||
.B $DontFork (read-only)
|
||||
If non-zero, then the \fB\-c\fR option was supplied on the command line.
|
||||
For the MS-DOS version, always contains 1.
|
||||
.TP
|
||||
.B $DontTrigAts (read-only)
|
||||
If non-zero, then the \fB\-a\fR option was supplied on the command line.
|
||||
For the MS-DOS version, always contains 0.
|
||||
The number of times that the \fB\-a\fR option was supplied on the
|
||||
command line.
|
||||
.TP
|
||||
.B $DontQueue (read-only)
|
||||
If non-zero, then the \fB\-q\fR option was supplied on the command line.
|
||||
For the MS-DOS version, always contains 1.
|
||||
.TP
|
||||
.B $EndSent (STRING type)
|
||||
Contains a list of characters that end a sentence. The \fBMSF\fR
|
||||
@@ -1810,10 +1927,10 @@ reminder. The default is 0.
|
||||
The standard Unix library functions may have difficulty dealing with dates
|
||||
later than 2037. If this variable is set to 1, then the UTC calculations
|
||||
"fold back" years later than 2037 before using the Unix library functions.
|
||||
For example, to find out whether or not daylight savings time is in
|
||||
For example, to find out whether or not daylight saving time is in
|
||||
effect in June, 2077, the year is "folded back" to 2010, because both
|
||||
years begin on a Monday, and both are non-leapyears. The rules for
|
||||
daylight savings time are thus presumed to be identical for both
|
||||
daylight saving time are thus presumed to be identical for both
|
||||
years, and the Unix library functions can handle 2010. By default,
|
||||
this variable is 0. Set it to 1 if the sun or UTC functions misbehave
|
||||
for years greater than 2037.
|
||||
@@ -1837,7 +1954,7 @@ If non-zero, then the \fB\-t\fR option was supplied on the command line.
|
||||
.TP
|
||||
.B $LatDeg, $LatMin, $LatSec
|
||||
These specify the latitude of your location. \fB$LatDeg\fR can
|
||||
range from -90 to 90, and the others from -59 to 59. Northern latitudes
|
||||
range from \-90 to 90, and the others from \-59 to 59. Northern latitudes
|
||||
are positive; southern ones are negative. For southern latitudes, all
|
||||
three components should be negative.
|
||||
.TP
|
||||
@@ -1849,8 +1966,10 @@ the latitude and longitude system variables.
|
||||
.TP
|
||||
.B $LongDeg, $LongMin, $LongSec
|
||||
These specify the longitude of your location. \fB$LongDeg\fR can
|
||||
range from -180 to 180. Western longitudes are positive; eastern
|
||||
ones are negative.
|
||||
range from \-180 to 180. Western longitudes are positive; eastern
|
||||
ones are negative. Note that all three components should have the
|
||||
same sign: All positive for Western longitudes and all negative
|
||||
for Eastern longitudes.
|
||||
.RS
|
||||
.PP
|
||||
The latitude and longitude information is required for the functions
|
||||
@@ -1868,7 +1987,7 @@ The number of minutes between Universal Time Coordinated and local time. If
|
||||
\fB$CalcUTC\fR is non-zero, this is calculated upon startup of \fBRemind\fR.
|
||||
Otherwise, you must set it explicitly. If \fB$CalcUTC\fR is zero,
|
||||
then \fB$MinsFromUTC\fR is used in the astronomical calculations. You
|
||||
must adjust it for daylight savings time yourself. Also, if you
|
||||
must adjust it for daylight saving time yourself. Also, if you
|
||||
want to initialize \fB$MinsFromUTC\fR
|
||||
using the \fB\-i\fR command-line option, you
|
||||
must also set \fB$CalcUTC\fR to 0 with the \fB\-i\fR option.
|
||||
@@ -1878,7 +1997,7 @@ If non-zero, then the \fB\-n\fR option was supplied on the command line.
|
||||
.TP
|
||||
.B $NumQueued (read-only)
|
||||
Contains the number of reminders queued so far for background
|
||||
timed triggering. For MS-DOS, always returns 0.
|
||||
timed triggering.
|
||||
.TP
|
||||
.B $NumTrig (read-only)
|
||||
Contains the number of reminders triggered for the current date. One
|
||||
@@ -1925,10 +2044,21 @@ order, or 2 if sorting by time in descending order.
|
||||
.B $SubsIndent
|
||||
The number of spaces by which all lines (except the first) of an
|
||||
\fBMSF\fR-type reminder should be indented. The default is 0.
|
||||
.PP
|
||||
Note: If any of the calendar modes are in effect, then the
|
||||
values of $Daemon, $DontFork, $DontTrigAts, $DontQueue, $HushMode,
|
||||
$IgnoreOnce, $InfDelta, and $NextMode are not meaningful.
|
||||
.TP
|
||||
.B $T (read-only, DATE type)
|
||||
Exactly equivalent to \fBtrigdate()\fR. (See BUILT-IN FUNCTIONS.)
|
||||
.TP
|
||||
.B $Td (read-only)
|
||||
Equivalent to \fBday(trigdate())\fR.
|
||||
.TP
|
||||
.B $Tm (read-only)
|
||||
Equivalent to \fBmonnum(trigdate())\fR.
|
||||
.TP
|
||||
.B $Tw (read-only)
|
||||
Equivalent to \fBwkdaynum(trigdate())\fR.
|
||||
.TP
|
||||
.B $Ty (read-only)
|
||||
Equivalent to \fByear(trigdate())\fR.
|
||||
.TP
|
||||
.B $TimeSep
|
||||
This variable can be set only to ":" or ".". It holds the character
|
||||
@@ -1938,6 +2068,25 @@ DATETIME value.
|
||||
.B $UntimedFirst (read-only)
|
||||
Set to 1 if the \fB\-g\fR option is used with a fourth sort character
|
||||
of "d"; set to 0 otherwise.
|
||||
.TP
|
||||
.B $U (read-only, DATE type)
|
||||
Exactly equivalent to \fBtoday()\fR. (See BUILT-IN FUNCTIONS.)
|
||||
.TP
|
||||
.B $Ud (read-only)
|
||||
Equivalent to \fBday(today())\fR.
|
||||
.TP
|
||||
.B $Um (read-only)
|
||||
Equivalent to \fBmonnum(today())\fR.
|
||||
.TP
|
||||
.B $Uw (read-only)
|
||||
Equivalent to \fBwkdaynum(today())\fR.
|
||||
.TP
|
||||
.B $Uy (read-only)
|
||||
Equivalent to \fByear(today())\fR.
|
||||
.PP
|
||||
Note: If any of the calendar modes are in effect, then the
|
||||
values of $Daemon, $DontFork, $DontTrigAts, $DontQueue, $HushMode,
|
||||
$IgnoreOnce, $InfDelta, and $NextMode are not meaningful.
|
||||
.PP
|
||||
.B BUILT-IN FUNCTIONS
|
||||
.PP
|
||||
@@ -1968,11 +2117,11 @@ be a string, containing a mix of the characters "rwx" for read,
|
||||
write and execute permission testing. Alternatively, \fImode\fR can
|
||||
be a number as described in the UNIX \fBaccess\fR(2) system call. The
|
||||
function returns 0 if the file can be accessed with the specified \fImode\fR,
|
||||
and -1 otherwise.
|
||||
and \-1 otherwise.
|
||||
.TP
|
||||
.B args(s_fname)
|
||||
Returns the number of arguments expected by the user-defined function
|
||||
\fIfname\fR, or -1 if no such user-defined function exists. Note that
|
||||
\fIfname\fR, or \-1 if no such user-defined function exists. Note that
|
||||
this function examines only user-defined functions, not built-in functions.
|
||||
Its main use is to determine whether or not a particular user-defined
|
||||
function has been defined previously. The \fBargs()\fR function is
|
||||
@@ -2064,6 +2213,10 @@ actual date and time, or may be the date and time supplied on the command line.
|
||||
The \fBdate()\fR function returns a \fBDATE\fR object with the year,
|
||||
month and day components specified by \fIy\fR, \fIm\fR and \fId\fR.
|
||||
.TP
|
||||
.B datepart(dq_datetime)
|
||||
Returns a \fBDATE\fR object representing the date portion of
|
||||
\fIdatetime\fR.
|
||||
.TP
|
||||
.B datetime(args)
|
||||
The \fBdatetime()\fR function can take anywhere from two to five arguments.
|
||||
It always returns a DATETIME generated from its arguments.
|
||||
@@ -2211,6 +2364,18 @@ environment variable is not defined. Note that the names of environment
|
||||
variables are generally case-sensitive; thus, getenv("HOME") is not
|
||||
the same as getenv("home").
|
||||
.TP
|
||||
.B hebdate(i_day, s_hebmon [,idq_yrstart [,i_jahr [,i_aflag]]])
|
||||
Support for Hebrew dates - see the section "The Hebrew Calendar"
|
||||
.TP
|
||||
.B hebday(dq_date)
|
||||
Support for Hebrew dates - see the section "The Hebrew Calendar"
|
||||
.TP
|
||||
.B hebmon(dq_date)
|
||||
Support for Hebrew dates - see the section "The Hebrew Calendar"
|
||||
.TP
|
||||
.B hebyear(dq_date)
|
||||
Support for Hebrew dates - see the section "The Hebrew Calendar"
|
||||
.TP
|
||||
.B hour(tq_time)
|
||||
Returns the hour component of \fItime\fR.
|
||||
.TP
|
||||
@@ -2234,7 +2399,7 @@ The optional parameter \fIstart\fR specifies the position in
|
||||
.RE
|
||||
.TP
|
||||
.B isdst([d_date [,t_time]]) \fRor\fB isdst(q_datetime)
|
||||
Returns a positive number if daylight savings time is in
|
||||
Returns a positive number if daylight saving time is in
|
||||
effect on the specified date and time. \fIDate\fR
|
||||
defaults to \fBtoday()\fR and \fItime\fR defaults to midnight.
|
||||
.RS
|
||||
@@ -2254,18 +2419,6 @@ context. Returns 0 otherwise. (If a datetime is supplied, only the
|
||||
date part is used.) Note that any local \fBOMIT\fR or \fBOMITFUNC\fR
|
||||
clauses are \fInot\fR taken into account by this function.
|
||||
.TP
|
||||
.B hebdate(i_day, s_hebmon [,idq_yrstart [,i_jahr [,i_aflag]]])
|
||||
Support for Hebrew dates - see the section "The Hebrew Calendar"
|
||||
.TP
|
||||
.B hebday(dq_date)
|
||||
Support for Hebrew dates - see the section "The Hebrew Calendar"
|
||||
.TP
|
||||
.B hebmon(dq_date)
|
||||
Support for Hebrew dates - see the section "The Hebrew Calendar"
|
||||
.TP
|
||||
.B hebyear(dq_date)
|
||||
Support for Hebrew dates - see the section "The Hebrew Calendar"
|
||||
.TP
|
||||
.B language()
|
||||
Returns a \fBSTRING\fR naming the language supported by \fBRemind\fR.
|
||||
(See "Foreign Language Support.") By default, \fBRemind\fR is compiled
|
||||
@@ -2458,10 +2611,10 @@ For example, the following four lines place moon symbols on the PostScript
|
||||
calendar:
|
||||
.PP
|
||||
.nf
|
||||
REM [trigger(moondate(0))] PS [psmoon(0)]
|
||||
REM [trigger(moondate(1))] PS [psmoon(1)]
|
||||
REM [trigger(moondate(2))] PS [psmoon(2)]
|
||||
REM [trigger(moondate(3))] PS [psmoon(3)]
|
||||
REM [moondate(0)] PS [psmoon(0)]
|
||||
REM [moondate(1)] PS [psmoon(1)]
|
||||
REM [moondate(2)] PS [psmoon(2)]
|
||||
REM [moondate(3)] PS [psmoon(3)]
|
||||
.fi
|
||||
.PP
|
||||
If \fInote\fR is specified, the text is used to annotate the moon
|
||||
@@ -2474,7 +2627,7 @@ does not check for this.) For example, if you want the time of each new
|
||||
moon displayed, you could use this in your reminder script:
|
||||
.PP
|
||||
.nf
|
||||
REM [trigger(moondate(0))] PS [psmoon(0, -1, moontime(0)+"")]
|
||||
REM [moondate(0)] PS [psmoon(0, \-1, moontime(0)+"")]
|
||||
.fi
|
||||
.PP
|
||||
Note how the time is coerced to a string by concatenating the null string.
|
||||
@@ -2516,7 +2669,7 @@ Returns the date as provided by the operating system. This is in contrast to
|
||||
in calendar mode, or if a date has been supplied on the command line.
|
||||
.TP
|
||||
.B sgn(i_num)
|
||||
Returns -1 if \fInum\fR is negative, 1 if \fInum\fR is positive,
|
||||
Returns \-1 if \fInum\fR is negative, 1 if \fInum\fR is positive,
|
||||
and 0 if \fInum\fR is zero.
|
||||
.TP
|
||||
.B shell(s_cmd [,i_maxlen])
|
||||
@@ -2534,6 +2687,31 @@ If \fImaxlen\fR is specified, then \fBshell()\fR returns the first
|
||||
output from \fIcmd\fR is returned.
|
||||
.RE
|
||||
.TP
|
||||
.B slide(d_start, i_amt [,s_wkday...])
|
||||
This function is the inverse of \fBnonomitted\fR. It adds \fIamt\fR
|
||||
days (which can be negative) to \fIstart\fR, \fInot counting omitted days\fR.
|
||||
The optional \fIwkday\fR arguments are additional weekday names to omit.
|
||||
.RS
|
||||
.PP
|
||||
Consider this example:
|
||||
.PP
|
||||
.nf
|
||||
OMIT 14 May 2009
|
||||
SET a slide('2009-05-13', 5, "Sat", "Sun")
|
||||
.fi
|
||||
.PP
|
||||
In this case, \fIa\fR is set to 2009-05-21. That's because we slide forward
|
||||
by 5 days, not including Thursday, May 14 or Saturday and Sunday,
|
||||
May 16 and 17. You can go backwards, too, so:
|
||||
.PP
|
||||
.nf
|
||||
OMIT 14 May 2009
|
||||
SET a slide('2009-05-21', \-5, "Sat", "Sun")
|
||||
.fi
|
||||
.PP
|
||||
takes \fIa\fR back to 2009-05-13.
|
||||
.RE
|
||||
.TP
|
||||
.B strlen(s_str)
|
||||
Returns the length of \fIstr\fR.
|
||||
.TP
|
||||
@@ -2562,7 +2740,7 @@ an algorithm in "Almanac for Computers for the year 1978" by
|
||||
L. E. Doggett, Nautical Almanac Office, USNO. They require
|
||||
the latitude and longitude to be specified by setting the appropriate
|
||||
system variables. (See "System Variables".) The sun functions
|
||||
should be accurate to within about 2 minutes for latitudes lower
|
||||
should be accurate to within about 4 minutes for latitudes lower
|
||||
than 60 degrees. The functions are available starting from version
|
||||
03.00.07 of \fBRemind\fR.
|
||||
.RE
|
||||
@@ -2571,6 +2749,10 @@ than 60 degrees. The functions are available starting from version
|
||||
Creates a \fBTIME\fR with the hour and minute components specified by
|
||||
\fIhr\fR and \fImin\fR.
|
||||
.TP
|
||||
.B timepart(tq_datetime)
|
||||
Returns a \fBTIME\fR object representing the time portion of
|
||||
\fIdatetime\fR.
|
||||
.TP
|
||||
.B today()
|
||||
Returns \fBRemind\fR's notion of "today." This may be the actual system
|
||||
date, or a date supplied on the command line, or the date of the
|
||||
@@ -2590,15 +2772,18 @@ triggerable \fBREM\fR command had an \fBAT\fR clause. If there was no
|
||||
returns the integer 0.
|
||||
.TP
|
||||
.B trigger(d_date [,t_time [,i_utcflag]]) \fRor\fB trigger(q_datetime [,i_utcflag])
|
||||
Returns a string suitable for use in a \fBREM\fR command, allowing you
|
||||
to calculate trigger dates in advance. (See the section "Expression
|
||||
pasting" for more information.) Note that \fBtrigger()\fR
|
||||
\fIalways\fR returns its result in English, even for foreign-language
|
||||
versions of \fBRemind\fR. This is to avoid problems with certain C
|
||||
libraries that do not handle accented characters properly. Normally,
|
||||
the \fIdate\fR and \fItime\fR are the local date and time; however, if
|
||||
\fIutcflag\fR is non-zero, the \fIdate\fR and \fItime\fR are
|
||||
interpreted as UTC times, and are converted to local time. Examples:
|
||||
Returns a string suitable for use in a \fBREM\fR command or a SCANFROM
|
||||
or UNTIL clause, allowing you to calculate trigger dates in advance.
|
||||
Note that in earlier versions of \fBRemind\fR, \fBtrigger\fR was
|
||||
required to convert a date into something the \fBREM\fR command could
|
||||
consume. However, in this version of \fBRemind\fR, you can omit it.
|
||||
Note that \fBtrigger()\fR \fIalways\fR returns its result in English,
|
||||
even for foreign-language versions of \fBRemind\fR. This is to avoid
|
||||
problems with certain C libraries that do not handle accented
|
||||
characters properly. Normally, the \fIdate\fR and \fItime\fR are the
|
||||
local date and time; however, if \fIutcflag\fR is non-zero, the
|
||||
\fIdate\fR and \fItime\fR are interpreted as UTC times, and are
|
||||
converted to local time. Examples:
|
||||
.RS
|
||||
.PP
|
||||
trigger('1993/04/01')
|
||||
@@ -2712,10 +2897,10 @@ you can "paste" an expression in. To do this, surround the expression
|
||||
with square brackets. For example:
|
||||
.PP
|
||||
.nf
|
||||
REM [trigger(mydate)] MSG foo
|
||||
REM [mydate] MSG foo
|
||||
.fi
|
||||
.PP
|
||||
This evaluates the expression "trigger(mydate)", where "mydate" is
|
||||
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
|
||||
@@ -2739,7 +2924,7 @@ exceptions:
|
||||
o
|
||||
If \fBRemind\fR is expecting an expression, as in the \fBSET\fR command,
|
||||
or the \fBIF\fR command, you should \fBnot\fR include square brackets.
|
||||
FOr example, use:
|
||||
For example, use:
|
||||
.PP
|
||||
.nf
|
||||
SET a 4+5
|
||||
@@ -2863,7 +3048,7 @@ to true if a corresponding \fBREM\fR command would trigger. Examples:
|
||||
; Executed except on 1 Nov
|
||||
ENDIF
|
||||
|
||||
IFTRIG 1 -1 OMIT Sat Sun +4
|
||||
IFTRIG 1 \-1 OMIT Sat Sun +4
|
||||
; Executed on last working day of month,
|
||||
; and the 4 working days preceding it
|
||||
ELSE
|
||||
@@ -2891,7 +3076,7 @@ you define a function taking no parameters. Here are some examples:
|
||||
.nf
|
||||
FSET double(x) 2*x
|
||||
FSET yeardiff(date1, date2) year(date1) - year(date2)
|
||||
FSET since(x) ord(year(trigdate())-x)
|
||||
FSET since(x) ord(year(trigdate())\-x)
|
||||
.fi
|
||||
.PP
|
||||
The last function is useful in birthday reminders. For example:
|
||||
@@ -3015,7 +3200,7 @@ clause to do anything.
|
||||
Here's an example:
|
||||
.PP
|
||||
.nf
|
||||
FSET _sfun(x) choose(x, -60, 30, 15, 10, 3, 1, 1, 1, 1, 0)
|
||||
FSET _sfun(x) choose(x, \-60, 30, 15, 10, 3, 1, 1, 1, 1, 0)
|
||||
REM AT 13:00 SCHED _sfun MSG foo
|
||||
.fi
|
||||
.PP
|
||||
@@ -3095,7 +3280,7 @@ more complicated sequence:
|
||||
.nf
|
||||
REM 13 SATISFY wkdaynum(trigdate()) == 5
|
||||
IF trigvalid()
|
||||
REM [trigger(trigdate())] +2 MSG \\
|
||||
REM [trigdate()] +2 MSG \\
|
||||
Friday the 13th is %b.
|
||||
ENDIF
|
||||
.fi
|
||||
@@ -3103,8 +3288,7 @@ more complicated sequence:
|
||||
Let's see how this works. The \fBSATISFY\fR clause iterates through
|
||||
all the 13ths of successive months, until a trigger date is found whose
|
||||
day-of-week is Friday (== 5). If a valid date was found, we use the
|
||||
calculated trigger date (converted into a trigger format with the
|
||||
\fBtrigger()\fR function) to set up the next reminder.
|
||||
calculated trigger date to set up the next reminder.
|
||||
.PP
|
||||
We could also have written:
|
||||
.PP
|
||||
@@ -3123,7 +3307,7 @@ could use:
|
||||
.nf
|
||||
# Note: SATISFY 1 is an idiom for "do nothing"
|
||||
REM Mon 1 Sept SATISFY 1
|
||||
OMIT [trigger(trigdate())]
|
||||
OMIT [trigdate()]
|
||||
.fi
|
||||
.PP
|
||||
\fBCAVEAT:\fR This \fIonly\fR omits the \fInext\fR Labour Day, not
|
||||
@@ -3268,7 +3452,7 @@ program to produce a calendar in PostScript format. For example, the
|
||||
following command will send PostScript code to standard output:
|
||||
.PP
|
||||
.nf
|
||||
remind -p .reminders | rem2ps
|
||||
remind \-p .reminders | rem2ps
|
||||
.fi
|
||||
.PP
|
||||
You can print a PostScript calendar by piping this to the \fBlpr\fR command.
|
||||
@@ -3277,7 +3461,7 @@ If you have a reminder script called ".reminders", and you
|
||||
execute this command:
|
||||
.PP
|
||||
.nf
|
||||
remind -c .reminders jan 1993
|
||||
remind \-c .reminders jan 1993
|
||||
.fi
|
||||
.PP
|
||||
then \fBRemind\fR executes the script 31 times, once for each day in
|
||||
@@ -3510,12 +3694,73 @@ 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:
|
||||
.PP
|
||||
.nf
|
||||
remind -z .reminders &
|
||||
remind \-z .reminders &
|
||||
.fi
|
||||
.PP
|
||||
If you use \fBsh\fR or \fBbash\fR, you may have to use the "nohup" command
|
||||
to ensure that the daemon is not killed when you log out.
|
||||
|
||||
.PP
|
||||
.SH PURGE MODE
|
||||
.PP
|
||||
|
||||
If you supply the \fB\-j\fR command-line option, \fBRemind\fR runs
|
||||
in \fIpurge mode\fR. In this mode, it tries to purge expired reminders
|
||||
from your reminder files.
|
||||
.PP
|
||||
In purge mode, \fBRemind\fR reads your reminder file and creates a new
|
||||
file by appending ".purged" to the original file name. Note that
|
||||
\fBRemind\fR \fInever\fR edits your original file; it always creates
|
||||
a new .purged file.
|
||||
.PP
|
||||
If you invoke \fBRemind\fR against a directory instead of a file, then
|
||||
a .purged file is created for each *.rem file in the directory.
|
||||
.PP
|
||||
Normally, \fBRemind\fR does not create .purged files for INCLUDed files.
|
||||
However, if you supply a numeric argument after \fB\-j\fR, then \fBRemind\fR
|
||||
will create .purged files for the specified level of INCLUDE. For example,
|
||||
if you invoke \fBRemind\fR with the argument \fB\-j2\fR, then .purged
|
||||
files will be created for the file (or directory) specified on the command
|
||||
line, any files included by them, and any files included by those files.
|
||||
However, .purged files will not be created for third-or-higher level
|
||||
INCLUDE files.
|
||||
.PP
|
||||
Determining which reminders have expired is extremely tricky. \fBRemind\fR
|
||||
does its best, but you should always compare the .purged file to the
|
||||
original file and hand-merge the changes back in.
|
||||
.PP
|
||||
Remind annotates the .purged file as follows:
|
||||
.PP
|
||||
An expired reminder is prefixed with: #!P: Expired:
|
||||
.PP
|
||||
In situations where \fBRemind\fR cannot reliably determine that
|
||||
something was expired, you may see the following comments inserted
|
||||
before the problematic line:
|
||||
.PP
|
||||
.nf
|
||||
#!P: Cannot purge SATISFY-type reminders
|
||||
|
||||
#!P: The next IF evaluated false...
|
||||
#!P: REM statements in IF block not checked for purging.
|
||||
|
||||
#!P: The previous IF evaluated true.
|
||||
#!P: REM statements in ELSE block not checked for purging
|
||||
|
||||
#!P: The next IFTRIG did not trigger.
|
||||
#!P: REM statements in IFTRIG block not checked for purging.
|
||||
|
||||
#!P: Next line has expired, but contains expression... please verify
|
||||
|
||||
#!P: Next line may have expired, but contains non-constant expression
|
||||
|
||||
#!P! Could not parse next line: Some-Error-Message-Here
|
||||
.fi
|
||||
.PP
|
||||
\fBRemind\fR always annotates .purged files with lines beginning with
|
||||
"#!P". If such lines are encountered in the \fIoriginal\fR file,
|
||||
they are not copied to the .purged file.
|
||||
.PP
|
||||
|
||||
.SH SORTING REMINDERS
|
||||
.PP
|
||||
|
||||
@@ -3864,7 +4109,7 @@ Calculations" by E. M. Reingold and Nachum Dershowitz.
|
||||
.PP
|
||||
The \fBSPECIAL\fR keyword is used to transmit "out-of-band" information
|
||||
to \fBRemind\fR backends, such as \fBtkremind\fR or \fBRem2PS\fR.
|
||||
They are used only when piping data from a \fBremind -p\fR line.
|
||||
They are used only when piping data from a \fBremind \-p\fR line.
|
||||
(Note that the COLOR special is an exception; it downgrades to the
|
||||
equivalent of MSG in \fBremind's\fR normal mode of operation.)
|
||||
.PP
|
||||
@@ -3890,10 +4135,10 @@ in calendars produced by \fBRem2PS\fR, \fBtkremind\fR and \fBrem2html\fR.)
|
||||
The \fBMOON\fR special replaces the \fBpsmoon()\fR function. Use it
|
||||
like this:
|
||||
.nf
|
||||
REM [trigger(moondate(0))] SPECIAL MOON 0
|
||||
REM [trigger(moondate(1))] SPECIAL MOON 1
|
||||
REM [trigger(moondate(2))] SPECIAL MOON 2
|
||||
REM [trigger(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
|
||||
.fi
|
||||
These draw little moons on the various calendars. The complete syntax
|
||||
of the \fBMOON\fR special is as follows:
|
||||
@@ -3905,7 +4150,7 @@ of the \fBMOON\fR special is as follows:
|
||||
1 the first quarter, 2 a full moon and 3 the last quarter.
|
||||
.PP
|
||||
\fImoonsize\fR is the diameter in PostScript units of the moon to
|
||||
draw. If omitted or supplied as -1, the backend chooses an appropriate
|
||||
draw. If omitted or supplied as \-1, the backend chooses an appropriate
|
||||
size.
|
||||
.PP
|
||||
\fIfontsize\fR is the font size in PostScript units of the \fImsg\fR
|
||||
@@ -3923,6 +4168,9 @@ calendar. Use it like this:
|
||||
REM ... SPECIAL COLOR 0 128 0 This is a dark green reminder
|
||||
.fi
|
||||
|
||||
You can spell COLOR either the American way ("COLOR") or the British
|
||||
way ("COLOUR"). This manual will use the American way.
|
||||
|
||||
Immediately following COLOR should be three decimal numbers ranging
|
||||
from 0 to 255 specifying red, green and blue intensities, respectively.
|
||||
The rest of the line is the text to put in the calendar.
|
||||
@@ -3979,7 +4227,7 @@ This section is a sampling of what you can do with \fBRemind\fR.
|
||||
.PP
|
||||
.nf
|
||||
REM 5 Feb 1991 AT 14:00 +45 *30 \\
|
||||
RUN mail -s "Meeting at %2" $LOGNAME </dev/null &
|
||||
RUN mail \-s "Meeting at %2" $LOGNAME </dev/null &
|
||||
.fi
|
||||
.PP
|
||||
On 5 February, 1991, this reminder will mail
|
||||
@@ -3988,14 +4236,14 @@ you reminders of a 2:00pm meeting at 1:15,
|
||||
and the body of the message will be blank.
|
||||
.PP
|
||||
.nf
|
||||
REM AT 17:00 RUN echo "5:00pm - GO HOME!" | xless -g +0+0 &
|
||||
REM AT 17:00 RUN echo "5:00pm - GO HOME!" | xless \-g +0+0 &
|
||||
.fi
|
||||
.PP
|
||||
This reminder will pop up an xless window at 5:00pm every day. The xless
|
||||
window will contain the line "5:00pm - GO HOME!"
|
||||
.PP
|
||||
.nf
|
||||
REM AT 23:59 RUN (sleep 120; remind -a [filename()]) &
|
||||
REM AT 23:59 RUN (sleep 120; remind \-a [filename()]) &
|
||||
.fi
|
||||
.PP
|
||||
This reminder will run at one minute to midnight. It will cause a new
|
||||
@@ -4013,7 +4261,7 @@ This invocation of \fBRemind\fR will cause it to print a calendar for
|
||||
1993, with all entries left blank.
|
||||
.PP
|
||||
.nf
|
||||
REM CAL [trigdate()-date(year(trigdate()), 1, 1)+1]
|
||||
REM CAL [trigdate()\-date(year(trigdate()), 1, 1)+1]
|
||||
.fi
|
||||
.PP
|
||||
This example puts an entry in each box of a calendar showing the number
|
||||
@@ -4022,7 +4270,7 @@ This example puts an entry in each box of a calendar showing the number
|
||||
.nf
|
||||
REM Tue 2 Nov SATISFY (year(trigdate())%4) == 0
|
||||
IF trigvalid()
|
||||
REM [trigger(trigdate())] ++5 MSG \\
|
||||
REM [trigdate()] ++5 MSG \\
|
||||
U.S. Presidential Election!!
|
||||
ENDIF
|
||||
.fi
|
||||
@@ -4073,8 +4321,8 @@ in September. It can move over a range of 7 days. Consider the
|
||||
following sequence:
|
||||
.PP
|
||||
.nf
|
||||
REM Mon 1 Sept SCANFROM [trigger(today()-7)] SATISFY 1
|
||||
OMIT [trigger(trigdate())]
|
||||
REM Mon 1 Sept SCANFROM [today()\-7] SATISFY 1
|
||||
OMIT [trigdate()]
|
||||
|
||||
REM Mon AFTER MSG Hello
|
||||
.fi
|
||||
@@ -4104,7 +4352,7 @@ will trigger on Mondays and Thursdays between 23 July 2007 and
|
||||
the reminder above as follows:
|
||||
.PP
|
||||
.nf
|
||||
REM Mon Thu SCANFROM [trigger(max(today(), '2007-07-23'))] \\
|
||||
REM Mon Thu SCANFROM [max(today(), '2007-07-23')] \\
|
||||
UNTIL 2 Aug 2007 MSG Test
|
||||
.fi
|
||||
.PP
|
||||
|
||||
@@ -74,7 +74,7 @@ The next control specifies an expiry date for the reminder. Select
|
||||
the check button to enable an expiry date, and fill in the values
|
||||
using pull-down menus.
|
||||
|
||||
The third control specifes how much advance notice you want (if any),
|
||||
The third control specifies how much advance notice you want (if any),
|
||||
and whether or not weekends and holidays are counted when computing advance
|
||||
notice.
|
||||
|
||||
@@ -179,7 +179,7 @@ it starts up in a normal window.
|
||||
.TP
|
||||
.B Show Today's Reminders on Startup
|
||||
If this is selected, \fBTkRemind\fR shows a text window containing reminders
|
||||
which would be issued by "remind -q -a -r" on startup, and when the date
|
||||
which would be issued by "remind \-q \-a \-r" on startup, and when the date
|
||||
changes at midnight.
|
||||
|
||||
.TP
|
||||
@@ -268,7 +268,7 @@ the body. Furthermore, if you use expression-pasting in the body,
|
||||
When \fBTkRemind\fR invokes \fBRemind\fR, it supplies the option:
|
||||
.PP
|
||||
.nf
|
||||
-itkremind=1
|
||||
\-itkremind=1
|
||||
.fi
|
||||
.PP
|
||||
on the command line. So, in your \fBRemind\fR file, you can include:
|
||||
@@ -289,7 +289,9 @@ file to store additional state. You can certainly mix
|
||||
if you are aware of the following rules and limitations:
|
||||
.TP
|
||||
o
|
||||
Do not use the \fBTAG\fR keyword in hand-crafted reminders.
|
||||
\fBTkRemind\fR uses \fBTAG\fRs of the form \fBTKTAG\fR\fInnn\fR
|
||||
where \fInnn\fR is a number. You should not use such \fBTAG\fRs
|
||||
in hand-crafted reminders.
|
||||
.TP
|
||||
o
|
||||
Do not edit lines starting with "# TKTAGnnn", "# TKEND", or any
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#
|
||||
# This file is part of REMIND.
|
||||
# Copyright (C) 1992-1998 David F. Skoll
|
||||
# Copyright (C) 1999-2008 Roaring Penguin Software Inc.
|
||||
# Copyright (C) 1999-2010 Roaring Penguin Software Inc.
|
||||
#
|
||||
#--------------------------------------------------------------
|
||||
|
||||
@@ -17,6 +17,38 @@ exec wish "$0" "$@"
|
||||
|
||||
wm withdraw .
|
||||
|
||||
# Our icon photo
|
||||
catch {
|
||||
image create photo rpicon -data {
|
||||
R0lGODlhFwAgAOecABUTERYTERYUERcVEhgWExkXFBkXFRoXFRsZFhwZFxwa
|
||||
GB0bGR4cGR4cGh8dGiAeHCEfHCEfHSIgHSIgHiQiHyYkISknJCooJispJywq
|
||||
Jy4sKTIwLjUzMDUzMTo4Njs5Nzs5ODw7ODw7OT07OT48OkE/PUJAPkNBP0RC
|
||||
QEVDQUVEQkdFQ0lIRkpJR01LSU5MSlBPTVFQTlNSUFRSUFRSUVVTUlVUUllY
|
||||
VltZV1xaWF1cWmBfXmJgX2RiYGZlY2dmZGppZ2tqaG1ram9tbHFwb3Jwb3Rz
|
||||
cXV0c3Z0c3Z1c3Z1dHd1dHh2dXh3dnt5eHx7eXx7en18en59e4B/foGAf4KB
|
||||
f4SDgYWEgoWEg4eGhIiHhouKiI2Mio6Ni46NjJCQj5KRkJSTkZeWlpiXlpmY
|
||||
l5qZmJybmp6dnKCfnqGgoKKhoKOioaSjoqinp6qpqKurqq+urbCvrrCwr7Gw
|
||||
r7OysbW1tLi3tri3t7u6ur28vMTDw8TEw8XFxMbFxcfGxsfHxsrJycrKyczM
|
||||
y83My83MzM3NzdDQz9LR0dPS0tPT09fX19jY19ra2dvb29zc29zc3Ojn5+jo
|
||||
6Orq6uzs7O/v7/T09PX19fb29vf39/r6+vv7+/7+/v//////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
/////////////////////yH5BAEKAP8ALAAAAAAXACAAAAj+AP8JHEiwoMGD
|
||||
CAcusRAAQEKDBQIcEBAAwUODAQJAsBGAwsWCBzJuUBLgI0ENGVM2dACg5UWV
|
||||
KU+Y/JfRQBknPoq8ATQz4wxOQIFa6vMx5ZSgQetczJDSClKgcF6mFDEnE9I2
|
||||
D0fADOChUdA1D7dmTBEUTditDQRQAnomIQaxICpoAmomoUoAGS2YIBIUDEIu
|
||||
YndI8FAJaBaEMlIuSEkloxugUBBOSLkh44AvGfkAPYJQpYqMLIQEILB205DO
|
||||
KW9kJHMhQAmgkaKgzsgjggM5GbEAxaNmdoAPOoz8CCAgEVAtg3wPEPMnQQAU
|
||||
QWsg5AAzDZSMbIBeaoHwAUwSDAI2XMAENA8ThAPEBvAStEkc3yonrOW0aUMk
|
||||
+BkBVAlaKATC8Fsp8Igid5ABgxMHtaTgggy6ZFBAADs= }
|
||||
|
||||
wm iconphoto . -default rpicon
|
||||
}
|
||||
|
||||
proc missing_tcllib { pkg } {
|
||||
catch { puts stderr "Could not find the '$pkg' package -- you must install tcllib.\nPlease see http://tcllib.sourceforge.net/" }
|
||||
tk_dialog .err "Error: tcllib not installed" "Could not find the '$pkg' package -- you must install tcllib. Please see http://tcllib.sourceforge.net/" error 0 OK
|
||||
@@ -360,11 +392,7 @@ proc ConfigureCalFrame { w firstDay numDays } {
|
||||
set first [expr $offset+1]
|
||||
set last [expr $offset+$numDays]
|
||||
|
||||
if {$tk_version >= 8.5} {
|
||||
set bg "#d9d9d9"
|
||||
} else {
|
||||
set bg [lindex [$w.t0 configure -background] 3]
|
||||
}
|
||||
set bg [lindex [. configure -background] 3]
|
||||
|
||||
for {set i 0} {$i < $first} {incr i} {
|
||||
grid $w.l$i $w.t$i
|
||||
@@ -768,6 +796,7 @@ proc FillCalWindow {} {
|
||||
DoMoonSpecial $n $stuff
|
||||
continue
|
||||
}
|
||||
"COLOUR" -
|
||||
"COLOR" {
|
||||
if {[regexp {^ *([0-9]+) +([0-9]+) +([0-9]+) +(.*)$} $stuff all r g b rest]} {
|
||||
if {$r > 255} {
|
||||
@@ -794,7 +823,7 @@ proc FillCalWindow {} {
|
||||
}
|
||||
}
|
||||
}
|
||||
if { $type != "*" && $type != "COLOR"} {
|
||||
if { $type != "*" && $type != "COLOR" && $type != "COLOUR"} {
|
||||
continue
|
||||
}
|
||||
.cal.t$n configure -state normal
|
||||
@@ -1123,12 +1152,13 @@ proc CreateModifyDialog {w day firstDay args} {
|
||||
frame $w.exp -border 4
|
||||
frame $w.adv -border 4
|
||||
frame $w.weekend -border 4
|
||||
frame $w.durationbox -border 4
|
||||
frame $w.time -border 4
|
||||
frame $w.hol -border 4
|
||||
frame $w.msg
|
||||
frame $w.buttons
|
||||
pack $w.o1 $w.o2 $w.o3 -side top -anchor w -in $w.o
|
||||
pack $w.o $w.exp $w.adv $w.weekend $w.time $w.hol $w.msg -side top -anchor w -pady 4 -expand 1 -fill both
|
||||
pack $w.o $w.exp $w.adv $w.weekend $w.time $w.durationbox $w.hol $w.msg -side top -anchor w -pady 4 -expand 1 -fill both
|
||||
pack $w.buttons -side top -anchor w -pady 4 -expand 1 -fill x
|
||||
|
||||
# TYPE 1 REMINDER
|
||||
@@ -1269,6 +1299,22 @@ proc CreateModifyDialog {w day firstDay args} {
|
||||
pack $w.timebut $w.timehour $w.timemin $w.ampm $w.timeadvbut $w.timeadv $w.timelab1 $w.timerepbut $w.timerep $w.timelab2 -side left -anchor w -in $w.time
|
||||
}
|
||||
|
||||
# DURATION
|
||||
checkbutton $w.durationbut -text "Duration"
|
||||
$w.durationbut deselect
|
||||
menubutton $w.durationh -text "1" -menu $w.durationh.menu -relief raised
|
||||
menu $w.durationh.menu -tearoff 0
|
||||
foreach i {0 1 2 3 4 5 6 7 8 9 10 11 12} {
|
||||
$w.durationh.menu add command -label $i -command "$w.durationh configure -text $i"
|
||||
}
|
||||
label $w.durationcolon -text ":"
|
||||
menubutton $w.durationm -text "00" -menu $w.durationm.menu -relief raised
|
||||
menu $w.durationm.menu -tearoff 0
|
||||
foreach i {00 15 30 45} {
|
||||
$w.durationm.menu add command -label $i -command "$w.durationm configure -text $i"
|
||||
}
|
||||
pack $w.durationbut $w.durationh $w.durationcolon $w.durationm -side left -anchor w -in $w.durationbox
|
||||
|
||||
# SKIP TYPE
|
||||
label $w.labhol -text "On holidays or weekends:"
|
||||
radiobutton $w.issue -variable SkipType -value 1 -text "Issue reminder as usual"
|
||||
@@ -1311,7 +1357,7 @@ proc CreateModifyDialog {w day firstDay args} {
|
||||
#***********************************************************************
|
||||
proc RemindDialogToOptions { w } {
|
||||
global OptionType SkipType repbut expbut advbut advcount
|
||||
global timebut timeadvbut timerepbut
|
||||
global timebut timeadvbut timerepbut durationbut
|
||||
global dSaturday dSunday dMonday dTuesday dWednesday dThursday dFriday
|
||||
set ans {}
|
||||
lappend ans "-global-OptionType" $OptionType
|
||||
@@ -1345,7 +1391,7 @@ proc RemindDialogToOptions { w } {
|
||||
#***********************************************************************
|
||||
proc OptionsToRemindDialog { w opts } {
|
||||
global OptionType SkipType repbut expbut advbut advcount
|
||||
global timebut timeadvbut timerepbut TwentyFourHourMode
|
||||
global timebut timeadvbut timerepbut TwentyFourHourMode durationbut
|
||||
global dSaturday dSunday dMonday dTuesday dWednesday dThursday dFriday
|
||||
set hour ""
|
||||
set ampm ""
|
||||
@@ -1557,7 +1603,7 @@ proc CreateReminder {w} {
|
||||
# Delegate the first part to CreateReminder1, CreateReminder2, or
|
||||
# CreateReminder3
|
||||
global OptionType SkipType repbut expbut advbut advcount
|
||||
global timebut timeadvbut timerepbut
|
||||
global timebut timeadvbut timerepbut durationbut
|
||||
|
||||
set rem [CreateReminder$OptionType $w]
|
||||
|
||||
@@ -1599,6 +1645,9 @@ proc CreateReminder {w} {
|
||||
if {$timerepbut} {
|
||||
append rem " *[$w.timerep cget -text]"
|
||||
}
|
||||
if {$durationbut} {
|
||||
append rem " DURATION [$w.durationh cget -text]:[$w.durationm cget -text]"
|
||||
}
|
||||
}
|
||||
|
||||
global SkipType
|
||||
@@ -2271,7 +2320,7 @@ proc main {} {
|
||||
global AppendFile HighestTagSoFar DayNames
|
||||
catch {
|
||||
puts "\nTkRemind Copyright (C) 1996-1998 David F. Skoll"
|
||||
puts "Copyright (C) 1999-2008 Roaring Penguin Software Inc."
|
||||
puts "Copyright (C) 1999-2010 Roaring Penguin Software Inc."
|
||||
}
|
||||
catch { SetFonts }
|
||||
LoadOptions
|
||||
|
||||
@@ -38,10 +38,10 @@ REMINDOBJS= $(REMINDSRCS:.c=.o)
|
||||
all: remind rem2ps
|
||||
|
||||
test: remind
|
||||
sh ../tests/test-rem
|
||||
@sh ../tests/test-rem
|
||||
|
||||
.c.o:
|
||||
@CC@ -c @CFLAGS@ @DEFS@ $(CEXTRA) $(LANGDEF) -I. -I$(srcdir) $<
|
||||
@CC@ -c @CPPFLAGS@ @CFLAGS@ @DEFS@ $(CEXTRA) $(LANGDEF) -I. -I$(srcdir) $<
|
||||
|
||||
rem2ps: rem2ps.o dynbuf.o
|
||||
@CC@ @LDFLAGS@ $(LDEXTRA) -o rem2ps rem2ps.o dynbuf.o
|
||||
@@ -80,13 +80,13 @@ depend:
|
||||
# Build a tar file based on all files checked into git.
|
||||
distro:
|
||||
ln -s . ../remind-$(VERSION)
|
||||
(cd ..; git-ls-files -x .gitignore) | sed -e 's/^/remind-$(VERSION)\//' | xargs tar -C .. -cvf remind-$(VERSION).tar
|
||||
(cd ..; git ls-files | fgrep -v .gitignore | fgrep -v remind.php) | sed -e 's/^/remind-$(VERSION)\//' | xargs tar -C .. -cvf remind-$(VERSION).tar
|
||||
gzip -f -v -9 remind-$(VERSION).tar
|
||||
rm -f ../remind-$(VERSION)
|
||||
|
||||
beta-tgz:
|
||||
ln -s . ../remind-$(VERSION)-BETA-$(BETA)
|
||||
(cd ..; git-ls-files -x .gitignore) | sed -e 's/^/remind-$(VERSION)-BETA-$(BETA)\//' | xargs tar -C .. -cvf remind-$(VERSION)-BETA-$(BETA).tar
|
||||
(cd ..; git ls-files | fgrep -v .gitignore | fgrep -v remind.php) | sed -e 's/^/remind-$(VERSION)-BETA-$(BETA)\//' | xargs tar -C .. -cvf remind-$(VERSION)-BETA-$(BETA).tar
|
||||
gzip -f -v -9 remind-$(VERSION)-BETA-$(BETA).tar
|
||||
rm -f ../remind-$(VERSION)-BETA-$(BETA)
|
||||
|
||||
|
||||
513
src/calendar.c
513
src/calendar.c
@@ -18,6 +18,10 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef REM_USE_WCHAR
|
||||
#include <wctype.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "protos.h"
|
||||
#include "expr.h"
|
||||
@@ -30,11 +34,15 @@ typedef struct cal_entry {
|
||||
struct cal_entry *next;
|
||||
char const *text;
|
||||
char const *pos;
|
||||
#ifdef REM_USE_WCHAR
|
||||
wchar_t const *wc_text;
|
||||
wchar_t const *wc_pos;
|
||||
#endif
|
||||
int is_color;
|
||||
int r, g, b;
|
||||
int time;
|
||||
int priority;
|
||||
char tag[TAG_LEN+1];
|
||||
DynamicBuffer tags;
|
||||
char passthru[PASSTHRU_LEN+1];
|
||||
int duration;
|
||||
char const *filename;
|
||||
@@ -45,17 +53,32 @@ typedef struct cal_entry {
|
||||
struct line_drawing {
|
||||
char const *graphics_on;
|
||||
char const *graphics_off;
|
||||
char tlr, bl, tbl, blr, tblr, tr, tb, br, tbr, tl, lr;
|
||||
char *tlr, *bl, *tbl, *blr, *tblr, *tr, *tb, *br, *tbr, *tl, *lr;
|
||||
};
|
||||
|
||||
static struct line_drawing NormalDrawing = {
|
||||
"", "", '+', '+', '+', '+', '+', '+', '|', '+', '+', '+', '-'
|
||||
"", "", "+", "+", "+", "+", "+", "+", "|", "+", "+", "+", "-"
|
||||
};
|
||||
|
||||
static struct line_drawing VT100Drawing = {
|
||||
"\x1B(0", "\x1B(B",
|
||||
'\x76', '\x6b', '\x75', '\x77', '\x6e', '\x6d', '\x78',
|
||||
'\x6c', '\x74', '\x6a', '\x71'
|
||||
"\x76", "\x6b", "\x75", "\x77", "\x6e", "\x6d", "\x78",
|
||||
"\x6c", "\x74", "\x6a", "\x71"
|
||||
};
|
||||
|
||||
static struct line_drawing UTF8Drawing = {
|
||||
"", "",
|
||||
"\xe2\x94\xb4",
|
||||
"\xe2\x94\x90",
|
||||
"\xe2\x94\xa4",
|
||||
"\xe2\x94\xac",
|
||||
"\xe2\x94\xbc",
|
||||
"\xe2\x94\x94",
|
||||
"\xe2\x94\x82",
|
||||
"\xe2\x94\x8c",
|
||||
"\xe2\x94\x9c",
|
||||
"\xe2\x94\x98",
|
||||
"\xe2\x94\x80"
|
||||
};
|
||||
|
||||
static char *VT100Colors[2][2][2][2] /* [Br][R][G][B] */ = {
|
||||
@@ -108,7 +131,7 @@ static char *VT100Colors[2][2][2][2] /* [Br][R][G][B] */ = {
|
||||
};
|
||||
|
||||
static struct line_drawing *linestruct;
|
||||
#define DRAW(x) putchar(linestruct->x)
|
||||
#define DRAW(x) fputs(linestruct->x, stdout)
|
||||
|
||||
/* Global variables */
|
||||
static CalEntry *CalColumn[7];
|
||||
@@ -124,7 +147,7 @@ static int WriteCalendarRow (void);
|
||||
static void WriteWeekHeaderLine (void);
|
||||
static void WritePostHeaderLine (void);
|
||||
static void PrintLeft (char const *s, int width, char pad);
|
||||
static void PrintCentered (char const *s, int width, char pad);
|
||||
static void PrintCentered (char const *s, int width, char *pad);
|
||||
static int WriteOneCalLine (void);
|
||||
static int WriteOneColLine (int col);
|
||||
static void GenerateCalEntries (int col);
|
||||
@@ -137,6 +160,40 @@ static void WriteBottomCalLine (void);
|
||||
static void WriteIntermediateCalLine (void);
|
||||
static void WriteCalDays (void);
|
||||
|
||||
#ifdef REM_USE_WCHAR
|
||||
static void PutWideChar(wchar_t const wc)
|
||||
{
|
||||
char buf[MB_CUR_MAX+1];
|
||||
int len;
|
||||
|
||||
len = wctomb(buf, wc);
|
||||
if (len > 0) {
|
||||
buf[len] = 0;
|
||||
fputs(buf, stdout);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int make_wchar_versions(CalEntry *e)
|
||||
{
|
||||
#ifdef REM_USE_WCHAR
|
||||
size_t len;
|
||||
wchar_t *buf;
|
||||
len = mbstowcs(NULL, e->text, 0);
|
||||
if (len == (size_t) -1) return 0;
|
||||
|
||||
buf = calloc(len+1, sizeof(wchar_t));
|
||||
if (!buf) return 0;
|
||||
|
||||
(void) mbstowcs(buf, e->text, len+1);
|
||||
e->wc_text = buf;
|
||||
e->wc_pos = buf;
|
||||
return 1;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gon(void)
|
||||
{
|
||||
printf("%s", linestruct->graphics_on);
|
||||
@@ -179,7 +236,9 @@ void ProduceCalendar(void)
|
||||
{
|
||||
int y, m, d;
|
||||
|
||||
if (UseVTChars) {
|
||||
if (UseUTF8Chars) {
|
||||
linestruct = &UTF8Drawing;
|
||||
} else if (UseVTChars) {
|
||||
linestruct = &VT100Drawing;
|
||||
} else {
|
||||
linestruct = &NormalDrawing;
|
||||
@@ -460,20 +519,55 @@ static void PrintLeft(char const *s, int width, char pad)
|
||||
/* */
|
||||
/* PrintCentered */
|
||||
/* */
|
||||
/* Center a piec of text */
|
||||
/* Center a piece of text */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
static void PrintCentered(char const *s, int width, char pad)
|
||||
static void PrintCentered(char const *s, int width, char *pad)
|
||||
{
|
||||
#ifndef REM_USE_WCHAR
|
||||
int len = strlen(s);
|
||||
int d = (width - len) / 2;
|
||||
int i;
|
||||
|
||||
for (i=0; i<d; i++) PutChar(pad);
|
||||
for (i=0; i<d; i++) fputs(pad, stdout);
|
||||
for (i=0; i<width; i++) {
|
||||
if (*s) PutChar(*s++); else break;
|
||||
}
|
||||
for (i=d+len; i<width; i++) PutChar(pad);
|
||||
for (i=d+len; i<width; i++) fputs(pad, stdout);
|
||||
#else
|
||||
size_t len = mbstowcs(NULL, s, 0);
|
||||
int i;
|
||||
wchar_t static_buf[128];
|
||||
wchar_t *buf;
|
||||
wchar_t *ws;
|
||||
int d;
|
||||
|
||||
if (!len) {
|
||||
for (i=0; i<width; i++) {
|
||||
fputs(pad, stdout);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (len + 1 <= 128) {
|
||||
buf = static_buf;
|
||||
} else {
|
||||
buf = calloc(len+1, sizeof(wchar_t));
|
||||
if (!buf) {
|
||||
/* Uh-oh... cannot recover */
|
||||
fprintf(stderr, "%s\n", ErrMsg[E_NO_MEM]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
(void) mbstowcs(buf, s, len+1);
|
||||
d = (width - len) / 2;
|
||||
ws = buf;
|
||||
for (i=0; i<d; i++) fputs(pad, stdout);
|
||||
for (i=0; i<width; i++) {
|
||||
if (*ws) PutWideChar(*ws++); else break;
|
||||
}
|
||||
for (i=d+len; i<width; i++) fputs(pad, stdout);
|
||||
if (buf != static_buf) free(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
@@ -494,7 +588,7 @@ static int WriteOneCalLine(void)
|
||||
if (CalColumn[i]) {
|
||||
if (WriteOneColLine(i)) done = 0;
|
||||
} else {
|
||||
PrintCentered("", ColSpaces, ' ');
|
||||
PrintCentered("", ColSpaces, " ");
|
||||
}
|
||||
gon();
|
||||
DRAW(tb);
|
||||
@@ -519,74 +613,158 @@ static int WriteOneColLine(int col)
|
||||
CalEntry *e = CalColumn[col];
|
||||
char const *s;
|
||||
char const *space;
|
||||
|
||||
#ifdef REM_USE_WCHAR
|
||||
wchar_t const *ws;
|
||||
wchar_t const *wspace;
|
||||
#endif
|
||||
|
||||
int numwritten = 0;
|
||||
|
||||
/* Print as many characters as possible within the column */
|
||||
space = NULL;
|
||||
s = e->pos;
|
||||
/* Print as many characters as possible within the column */
|
||||
#ifdef REM_USE_WCHAR
|
||||
if (e->wc_text) {
|
||||
wspace = NULL;
|
||||
ws = e->wc_pos;
|
||||
|
||||
/* If we're at the end, and there's another entry, do a blank line and move
|
||||
to next entry. */
|
||||
if (!*s && e->next) {
|
||||
PrintLeft("", ColSpaces, ' ');
|
||||
CalColumn[col] = e->next;
|
||||
free((char *) e->text);
|
||||
free((char *) e->filename);
|
||||
free(e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Find the last space char within the column. */
|
||||
while (s - e->pos <= ColSpaces) {
|
||||
if (!*s) {space = s; break;}
|
||||
if (*s == ' ') space = s;
|
||||
s++;
|
||||
}
|
||||
|
||||
/* Colorize reminder if necessary */
|
||||
if (UseVTColors && e->is_color) {
|
||||
Colorize(e);
|
||||
}
|
||||
|
||||
/* If we couldn't find a space char, print what we have. */
|
||||
if (!space) {
|
||||
for (s = e->pos; s - e->pos < ColSpaces; s++) {
|
||||
if (!*s) break;
|
||||
numwritten++;
|
||||
PutChar(*s);
|
||||
/* If we're at the end, and there's another entry, do a blank
|
||||
line and move to next entry. */
|
||||
if (!*ws && e->next) {
|
||||
PrintLeft("", ColSpaces, ' ');
|
||||
CalColumn[col] = e->next;
|
||||
free((void *)e->text);
|
||||
free((void *)e->filename);
|
||||
if (e->wc_text) free((void *)e->wc_text);
|
||||
free(e);
|
||||
return 1;
|
||||
}
|
||||
e->pos = s;
|
||||
} else {
|
||||
|
||||
/* We found a space - print everything before it. */
|
||||
for (s = e->pos; s<space; s++) {
|
||||
if (!*s) break;
|
||||
numwritten++;
|
||||
PutChar(*s);
|
||||
/* Find the last space char within the column. */
|
||||
while (ws - e->wc_pos <= ColSpaces) {
|
||||
if (!*ws) {wspace = ws; break;}
|
||||
if (iswspace(*ws)) wspace = ws;
|
||||
ws++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Decolorize reminder if necessary */
|
||||
if (UseVTColors && e->is_color) {
|
||||
Decolorize();
|
||||
}
|
||||
/* Colorize reminder if necessary */
|
||||
if (UseVTColors && e->is_color) {
|
||||
Colorize(e);
|
||||
}
|
||||
|
||||
/* Flesh out the rest of the column */
|
||||
while(numwritten++ < ColSpaces) PutChar(' ');
|
||||
/* If we couldn't find a space char, print what we have. */
|
||||
if (!wspace) {
|
||||
for (ws = e->wc_pos; ws - e->wc_pos < ColSpaces; ws++) {
|
||||
if (!*ws) break;
|
||||
numwritten++;
|
||||
PutWideChar(*ws);
|
||||
}
|
||||
e->wc_pos = ws;
|
||||
} else {
|
||||
/* We found a space - print everything before it. */
|
||||
for (ws = e->wc_pos; ws<wspace; ws++) {
|
||||
if (!*ws) break;
|
||||
numwritten++;
|
||||
PutWideChar(*ws);
|
||||
}
|
||||
}
|
||||
|
||||
/* Skip any spaces before next word */
|
||||
while (*s == ' ') s++;
|
||||
/* Decolorize reminder if necessary */
|
||||
if (UseVTColors && e->is_color) {
|
||||
Decolorize();
|
||||
}
|
||||
|
||||
/* If done, free memory if no next entry. */
|
||||
if (!*s && !e->next) {
|
||||
CalColumn[col] = e->next;
|
||||
free((char *) e->text);
|
||||
free((char *) e->filename);
|
||||
free(e);
|
||||
/* Flesh out the rest of the column */
|
||||
while(numwritten++ < ColSpaces) PutChar(' ');
|
||||
|
||||
/* Skip any spaces before next word */
|
||||
while (iswspace(*ws)) ws++;
|
||||
|
||||
/* If done, free memory if no next entry. */
|
||||
if (!*ws && !e->next) {
|
||||
CalColumn[col] = e->next;
|
||||
free((void *)e->text);
|
||||
free((void *)e->filename);
|
||||
if (e->wc_text) free((void *)e->wc_text);
|
||||
free(e);
|
||||
} else {
|
||||
e->wc_pos = ws;
|
||||
}
|
||||
if (CalColumn[col]) return 1; else return 0;
|
||||
} else {
|
||||
e->pos = s;
|
||||
#endif
|
||||
space = NULL;
|
||||
s = e->pos;
|
||||
|
||||
/* If we're at the end, and there's another entry, do a blank
|
||||
line and move to next entry. */
|
||||
if (!*s && e->next) {
|
||||
PrintLeft("", ColSpaces, ' ');
|
||||
CalColumn[col] = e->next;
|
||||
free((void *)e->text);
|
||||
free((void *)e->filename);
|
||||
#ifdef REM_USE_WCHAR
|
||||
if (e->wc_text) free((void *)e->wc_text);
|
||||
#endif
|
||||
free(e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Find the last space char within the column. */
|
||||
while (s - e->pos <= ColSpaces) {
|
||||
if (!*s) {space = s; break;}
|
||||
if (*s == ' ') space = s;
|
||||
s++;
|
||||
}
|
||||
|
||||
/* Colorize reminder if necessary */
|
||||
if (UseVTColors && e->is_color) {
|
||||
Colorize(e);
|
||||
}
|
||||
|
||||
/* If we couldn't find a space char, print what we have. */
|
||||
if (!space) {
|
||||
for (s = e->pos; s - e->pos < ColSpaces; s++) {
|
||||
if (!*s) break;
|
||||
numwritten++;
|
||||
PutChar(*s);
|
||||
}
|
||||
e->pos = s;
|
||||
} else {
|
||||
/* We found a space - print everything before it. */
|
||||
for (s = e->pos; s<space; s++) {
|
||||
if (!*s) break;
|
||||
numwritten++;
|
||||
PutChar(*s);
|
||||
}
|
||||
}
|
||||
|
||||
/* Decolorize reminder if necessary */
|
||||
if (UseVTColors && e->is_color) {
|
||||
Decolorize();
|
||||
}
|
||||
|
||||
/* Flesh out the rest of the column */
|
||||
while(numwritten++ < ColSpaces) PutChar(' ');
|
||||
|
||||
/* Skip any spaces before next word */
|
||||
while (*s == ' ') s++;
|
||||
|
||||
/* If done, free memory if no next entry. */
|
||||
if (!*s && !e->next) {
|
||||
CalColumn[col] = e->next;
|
||||
free((void *)e->text);
|
||||
free((void *)e->filename);
|
||||
#ifdef REM_USE_WCHAR
|
||||
if (e->wc_text) free((void *)e->wc_text);
|
||||
#endif
|
||||
free(e);
|
||||
} else {
|
||||
e->pos = s;
|
||||
}
|
||||
if (CalColumn[col]) return 1; else return 0;
|
||||
#ifdef REM_USE_WCHAR
|
||||
}
|
||||
if (CalColumn[col]) return 1; else return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
@@ -714,7 +892,7 @@ static void WriteCalHeader(void)
|
||||
gon();
|
||||
DRAW(tb);
|
||||
goff();
|
||||
PrintCentered(buf, CalWidth-2, ' ');
|
||||
PrintCentered(buf, CalWidth-2, " ");
|
||||
gon();
|
||||
DRAW(tb);
|
||||
goff();
|
||||
@@ -763,26 +941,52 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
DBufInit(&pre_buf);
|
||||
|
||||
/* Parse the trigger date and time */
|
||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) return r;
|
||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Don't include timed reminders in calendar if -a option supplied. */
|
||||
if (DontIssueAts && tim.ttime != NO_TIME) return OK;
|
||||
if (trig.typ == NO_TYPE) return E_EOLN;
|
||||
if (DontIssueAts && tim.ttime != NO_TIME) {
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
if (trig.typ == NO_TYPE) {
|
||||
FreeTrig(&trig);
|
||||
return E_EOLN;
|
||||
}
|
||||
if (trig.typ == SAT_TYPE) {
|
||||
r=DoSatRemind(&trig, &tim, p);
|
||||
if (r) return r;
|
||||
if (!LastTrigValid) return OK;
|
||||
if (r) {
|
||||
FreeTrig(&trig);
|
||||
if (r == E_EXPIRED) return OK;
|
||||
return r;
|
||||
}
|
||||
if (!LastTrigValid) {
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
r=ParseToken(p, &buf);
|
||||
if (r) return r;
|
||||
if (r) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
FindToken(DBufValue(&buf), &tok);
|
||||
DBufFree(&buf);
|
||||
if (tok.type == T_Empty || tok.type == T_Comment) return OK;
|
||||
if (tok.type != T_RemType || tok.val == SAT_TYPE) return E_PARSE_ERR;
|
||||
if (tok.type == T_Empty || tok.type == T_Comment) {
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
if (tok.type != T_RemType || tok.val == SAT_TYPE) {
|
||||
FreeTrig(&trig);
|
||||
return E_PARSE_ERR;
|
||||
}
|
||||
if (tok.val == PASSTHRU_TYPE) {
|
||||
r=ParseToken(p, &buf);
|
||||
if (r) return r;
|
||||
if (!DBufLen(&buf)) {
|
||||
DBufFree(&buf);
|
||||
FreeTrig(&trig);
|
||||
return E_EOLN;
|
||||
}
|
||||
StrnCpy(trig.passthru, DBufValue(&buf), PASSTHRU_LEN);
|
||||
@@ -790,11 +994,17 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
}
|
||||
trig.typ = tok.val;
|
||||
jul = LastTriggerDate;
|
||||
if (!LastTrigValid) return OK;
|
||||
if (!LastTrigValid) {
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
} else {
|
||||
/* Calculate the trigger date */
|
||||
jul = ComputeTrigger(trig.scanfrom, &trig, &r, 1);
|
||||
if (r) return r;
|
||||
if (r) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert PS and PSF to PASSTHRU */
|
||||
@@ -806,39 +1016,51 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
trig.typ = PASSTHRU_TYPE;
|
||||
}
|
||||
if (trig.typ == PASSTHRU_TYPE) {
|
||||
if (!PsCal && strcmp(trig.passthru, "COLOR")) return OK;
|
||||
if (!strcmp(trig.passthru, "COLOR")) {
|
||||
is_color = 1;
|
||||
/* Strip off the three color numbers */
|
||||
DBufFree(&buf);
|
||||
r=ParseToken(p, &buf);
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
DBufFree(&buf);
|
||||
if (r) return r;
|
||||
r=ParseToken(p, &buf);
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
DBufFree(&buf);
|
||||
if (r) return r;
|
||||
r=ParseToken(p, &buf);
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
DBufFree(&buf);
|
||||
if (r) return r;
|
||||
(void) sscanf(DBufValue(&pre_buf), "%d %d %d",
|
||||
&col_r, &col_g, &col_b);
|
||||
if (col_r < 0) col_r = 0;
|
||||
else if (col_r > 255) col_r = 255;
|
||||
if (col_g < 0) col_g = 0;
|
||||
else if (col_g > 255) col_g = 255;
|
||||
if (col_b < 0) col_b = 0;
|
||||
else if (col_b > 255) col_b = 255;
|
||||
|
||||
if (!PsCal && !DoSimpleCalendar) {
|
||||
DBufFree(&pre_buf);
|
||||
}
|
||||
}
|
||||
if (!PsCal && strcmp(trig.passthru, "COLOR") && strcmp(trig.passthru, "COLOUR")) {
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
if (!strcmp(trig.passthru, "COLOR") ||
|
||||
!strcmp(trig.passthru, "COLOUR")) {
|
||||
is_color = 1;
|
||||
/* Strip off the three color numbers */
|
||||
DBufFree(&buf);
|
||||
r=ParseToken(p, &buf);
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
DBufFree(&buf);
|
||||
if (r) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
r=ParseToken(p, &buf);
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
DBufFree(&buf);
|
||||
if (r) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
r=ParseToken(p, &buf);
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
DBufFree(&buf);
|
||||
if (r) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
(void) sscanf(DBufValue(&pre_buf), "%d %d %d",
|
||||
&col_r, &col_g, &col_b);
|
||||
if (col_r < 0) col_r = 0;
|
||||
else if (col_r > 255) col_r = 255;
|
||||
if (col_g < 0) col_g = 0;
|
||||
else if (col_g > 255) col_g = 255;
|
||||
if (col_b < 0) col_b = 0;
|
||||
else if (col_b > 255) col_b = 255;
|
||||
if (!PsCal && !DoSimpleCalendar) {
|
||||
DBufFree(&pre_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If trigger date == today, add it to the current entry */
|
||||
@@ -852,16 +1074,19 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
/* Suppress time if it's not today or if it's a non-COLOR special */
|
||||
if (jul != JulianToday ||
|
||||
(trig.typ == PASSTHRU_TYPE &&
|
||||
strcmp(trig.passthru, "COLOUR") &&
|
||||
strcmp(trig.passthru, "COLOR"))) {
|
||||
if (DBufPuts(&obuf, SimpleTime(NO_TIME)) != OK) {
|
||||
DBufFree(&obuf);
|
||||
DBufFree(&pre_buf);
|
||||
FreeTrig(&trig);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
} else {
|
||||
if (DBufPuts(&obuf, CalendarTime(tim.ttime, tim.duration)) != OK) {
|
||||
DBufFree(&obuf);
|
||||
DBufFree(&pre_buf);
|
||||
FreeTrig(&trig);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
@@ -871,13 +1096,14 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
char evalBuf[64];
|
||||
sprintf(evalBuf, "calprefix(%d)", trig.priority);
|
||||
s2 = evalBuf;
|
||||
r = EvalExpr(&s2, &v);
|
||||
r = EvalExpr(&s2, &v, NULL);
|
||||
if (!r) {
|
||||
if (!DoCoerce(STR_TYPE, &v)) {
|
||||
if (DBufPuts(&obuf, v.v.str) != OK) {
|
||||
DestroyValue(v);
|
||||
DBufFree(&obuf);
|
||||
DBufFree(&pre_buf);
|
||||
FreeTrig(&trig);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
@@ -896,11 +1122,13 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
if (r) {
|
||||
DBufFree(&pre_buf);
|
||||
DBufFree(&obuf);
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
if (DBufLen(&obuf) <= oldLen) {
|
||||
DBufFree(&obuf);
|
||||
DBufFree(&pre_buf);
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
if (trig.typ != PASSTHRU_TYPE &&
|
||||
@@ -908,13 +1136,14 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
char evalBuf[64];
|
||||
sprintf(evalBuf, "calsuffix(%d)", trig.priority);
|
||||
s2 = evalBuf;
|
||||
r = EvalExpr(&s2, &v);
|
||||
r = EvalExpr(&s2, &v, NULL);
|
||||
if (!r) {
|
||||
if (!DoCoerce(STR_TYPE, &v)) {
|
||||
if (DBufPuts(&obuf, v.v.str) != OK) {
|
||||
DestroyValue(v);
|
||||
DBufFree(&obuf);
|
||||
DBufFree(&pre_buf);
|
||||
FreeTrig(&trig);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
@@ -922,34 +1151,41 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
}
|
||||
}
|
||||
s = DBufValue(&obuf);
|
||||
if (!DoSimpleCalendar) while (isspace(*s)) s++;
|
||||
if (!DoSimpleCalendar) while (isempty(*s)) s++;
|
||||
DBufPuts(&pre_buf, s);
|
||||
s = DBufValue(&pre_buf);
|
||||
e = NEW(CalEntry);
|
||||
if (!e) {
|
||||
DBufFree(&obuf);
|
||||
DBufFree(&pre_buf);
|
||||
FreeTrig(&trig);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
#ifdef REM_USE_WCHAR
|
||||
e->wc_pos = NULL;
|
||||
e->wc_text = NULL;
|
||||
#endif
|
||||
e->is_color = is_color;
|
||||
e->r = col_r;
|
||||
e->g = col_g;
|
||||
e->b = col_b;
|
||||
if (!e) {
|
||||
DBufFree(&obuf);
|
||||
DBufFree(&pre_buf);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
e->text = StrDup(s);
|
||||
DBufFree(&obuf);
|
||||
DBufFree(&pre_buf);
|
||||
if (!e->text) {
|
||||
free(e);
|
||||
FreeTrig(&trig);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
StrnCpy(e->tag, trig.tag, TAG_LEN);
|
||||
if (!e->tag[0]) {
|
||||
if (SynthesizeTags) {
|
||||
SynthesizeTag(e->tag);
|
||||
} else {
|
||||
strcpy(e->tag, "*");
|
||||
}
|
||||
make_wchar_versions(e);
|
||||
DBufInit(&(e->tags));
|
||||
DBufPuts(&(e->tags), DBufValue(&(trig.tags)));
|
||||
if (SynthesizeTags) {
|
||||
AppendTag(&(e->tags), SynthesizeTag());
|
||||
}
|
||||
|
||||
/* Don't need tags any more */
|
||||
FreeTrig(&trig);
|
||||
e->duration = tim.duration;
|
||||
e->priority = trig.priority;
|
||||
e->filename = StrDup(FileName);
|
||||
@@ -999,7 +1235,11 @@ static void WriteSimpleEntries(int col, int jul)
|
||||
} else {
|
||||
printf(" *");
|
||||
}
|
||||
printf(" %s ", e->tag);
|
||||
if (*DBufValue(&(e->tags))) {
|
||||
printf(" %s ", DBufValue(&(e->tags)));
|
||||
} else {
|
||||
printf(" * ");
|
||||
}
|
||||
if (e->duration != NO_TIME) {
|
||||
printf("%d ", e->duration);
|
||||
} else {
|
||||
@@ -1011,8 +1251,11 @@ static void WriteSimpleEntries(int col, int jul)
|
||||
printf("* ");
|
||||
}
|
||||
printf("%s\n", e->text);
|
||||
free((char *) e->text);
|
||||
free((char *) e->filename);
|
||||
free((void *)e->text);
|
||||
free((void *)e->filename);
|
||||
#ifdef REM_USE_WCHAR
|
||||
if (e->wc_text) free((void *)e->wc_text);
|
||||
#endif
|
||||
n = e->next;
|
||||
free(e);
|
||||
e = n;
|
||||
@@ -1112,9 +1355,9 @@ static void WriteCalDays(void)
|
||||
goff();
|
||||
for (i=0; i<7; i++) {
|
||||
if (!MondayFirst)
|
||||
PrintCentered(DayName[(i+6)%7], ColSpaces, ' ');
|
||||
PrintCentered(DayName[(i+6)%7], ColSpaces, " ");
|
||||
else
|
||||
PrintCentered(DayName[i%7], ColSpaces, ' ');
|
||||
PrintCentered(DayName[i%7], ColSpaces, " ");
|
||||
gon();
|
||||
DRAW(tb);
|
||||
goff();
|
||||
@@ -1282,10 +1525,11 @@ static void SortCol(CalEntry **col)
|
||||
}
|
||||
}
|
||||
|
||||
void SynthesizeTag(char *out)
|
||||
char const *SynthesizeTag(void)
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
unsigned char buf[16];
|
||||
static char out[128];
|
||||
MD5Init(&ctx);
|
||||
MD5Update(&ctx, (unsigned char *) CurLine, strlen(CurLine));
|
||||
MD5Final(buf, &ctx);
|
||||
@@ -1298,5 +1542,6 @@ void SynthesizeTag(char *out)
|
||||
(unsigned int) buf[10], (unsigned int) buf[11],
|
||||
(unsigned int) buf[12], (unsigned int) buf[13],
|
||||
(unsigned int) buf[14], (unsigned int) buf[15]);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,20 @@
|
||||
/* Define if you have the <glob.h> header file */
|
||||
#undef HAVE_GLOB_H
|
||||
|
||||
#undef HAVE_WCTYPE_H
|
||||
|
||||
#undef HAVE_LOCALE_H
|
||||
|
||||
#undef HAVE_GLOB
|
||||
|
||||
#undef HAVE_SETENV
|
||||
|
||||
#undef HAVE_UNSETENV
|
||||
|
||||
#undef HAVE_MBSTOWCS
|
||||
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* The number of bytes in a unsigned int. */
|
||||
#undef SIZEOF_UNSIGNED_INT
|
||||
|
||||
|
||||
10
src/custom.h
10
src/custom.h
@@ -183,12 +183,12 @@
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* How many global omits of the form YYYY MM DD do we handle? */
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define MAX_FULL_OMITS 250
|
||||
#define MAX_FULL_OMITS 500
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* How many global omits of the form MM DD do we handle? */
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define MAX_PARTIAL_OMITS 250
|
||||
#define MAX_PARTIAL_OMITS 366
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* A newline - some systems need "\n\r" */
|
||||
@@ -221,3 +221,9 @@
|
||||
#define Putc putc
|
||||
#define PutChar putchar
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MBSTOWCS) && defined(HAVE_WCTYPE_H)
|
||||
#define REM_USE_WCHAR 1
|
||||
#else
|
||||
#undef REM_USE_WCHAR
|
||||
#endif
|
||||
|
||||
@@ -178,17 +178,17 @@
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* How many attempts to resolve a weird date spec? */
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define TRIG_ATTEMPTS 50
|
||||
#define TRIG_ATTEMPTS 500
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* How many global omits of the form YYYY MM DD do we handle? */
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define MAX_FULL_OMITS 250
|
||||
#define MAX_FULL_OMITS 500
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* How many global omits of the form MM DD do we handle? */
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define MAX_PARTIAL_OMITS 250
|
||||
#define MAX_PARTIAL_OMITS 366
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* A newline - some systems need "\n\r" */
|
||||
@@ -221,3 +221,9 @@
|
||||
#define Putc putc
|
||||
#define PutChar putchar
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MBSTOWCS) && defined(HAVE_WCTYPE_H)
|
||||
#define REM_USE_WCHAR 1
|
||||
#else
|
||||
#undef REM_USE_WCHAR
|
||||
#endif
|
||||
|
||||
273
src/dorem.c
273
src/dorem.c
@@ -56,29 +56,54 @@ int DoRem(ParsePtr p)
|
||||
DBufInit(&buf);
|
||||
|
||||
/* Parse the trigger date and time */
|
||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) return r;
|
||||
if ( (r=ParseRem(p, &trig, &tim, 1)) ) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (trig.typ == NO_TYPE) return E_EOLN;
|
||||
if (trig.typ == NO_TYPE) {
|
||||
PurgeEchoLine("%s\n%s\n", "#!P! Cannot parse next line", CurLine);
|
||||
FreeTrig(&trig);
|
||||
return E_EOLN;
|
||||
}
|
||||
if (trig.typ == SAT_TYPE) {
|
||||
PurgeEchoLine("%s\n", "#!P: Cannot purge SATISFY-type reminders");
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
r=DoSatRemind(&trig, &tim, p);
|
||||
if (r) return r;
|
||||
if (!LastTrigValid) return OK;
|
||||
if (r) {
|
||||
FreeTrig(&trig);
|
||||
if (r == E_EXPIRED) return OK;
|
||||
return r;
|
||||
}
|
||||
if (!LastTrigValid) {
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
r=ParseToken(p, &buf);
|
||||
if (r) return r;
|
||||
if (r) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
FindToken(DBufValue(&buf), &tok);
|
||||
DBufFree(&buf);
|
||||
if (tok.type == T_Empty || tok.type == T_Comment) {
|
||||
DBufFree(&buf);
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
if (tok.type != T_RemType || tok.val == SAT_TYPE) {
|
||||
DBufFree(&buf);
|
||||
FreeTrig(&trig);
|
||||
return E_PARSE_ERR;
|
||||
}
|
||||
if (tok.val == PASSTHRU_TYPE) {
|
||||
r=ParseToken(p, &buf);
|
||||
if (r) return r;
|
||||
if (r) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
if (!DBufLen(&buf)) {
|
||||
FreeTrig(&trig);
|
||||
DBufFree(&buf);
|
||||
return E_EOLN;
|
||||
}
|
||||
@@ -87,13 +112,42 @@ int DoRem(ParsePtr p)
|
||||
}
|
||||
trig.typ = tok.val;
|
||||
jul = LastTriggerDate;
|
||||
if (!LastTrigValid) return OK;
|
||||
if (!LastTrigValid || PurgeMode) {
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
} else {
|
||||
/* Calculate the trigger date */
|
||||
jul = ComputeTrigger(trig.scanfrom, &trig, &r, 1);
|
||||
if (r) return r;
|
||||
if (r) {
|
||||
if (PurgeMode) {
|
||||
PurgeEchoLine("%s: %s\n", "#!P! Problem calculating trigger date", ErrMsg[r]);
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
}
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
if (PurgeMode) {
|
||||
if (trig.expired || jul < JulianToday) {
|
||||
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", CurLine);
|
||||
} else {
|
||||
PurgeEchoLine("%s\n", "#!P: Next line has expired, but contains expression... please verify");
|
||||
PurgeEchoLine("#!P: Expired: %s\n", CurLine);
|
||||
}
|
||||
} else {
|
||||
PurgeEchoLine("#!P: Expired: %s\n", CurLine);
|
||||
}
|
||||
} else {
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
}
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
/* Queue the reminder, if necessary */
|
||||
if (jul == JulianToday &&
|
||||
!(!IgnoreOnce &&
|
||||
@@ -101,17 +155,21 @@ int DoRem(ParsePtr p)
|
||||
FileAccessDate == JulianToday))
|
||||
QueueReminder(p, &trig, &tim, trig.sched);
|
||||
/* If we're in daemon mode, do nothing over here */
|
||||
if (Daemon) return OK;
|
||||
|
||||
if (ShouldTriggerReminder(&trig, &tim, jul, &err)) {
|
||||
if ( (r=TriggerReminder(p, &trig, &tim, jul)) )
|
||||
{
|
||||
return r;
|
||||
}
|
||||
if (Daemon) {
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
|
||||
if (ShouldTriggerReminder(&trig, &tim, jul, &err)) {
|
||||
if ( (r=TriggerReminder(p, &trig, &tim, jul)) ) {
|
||||
FreeTrig(&trig);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
FreeTrig(&trig);
|
||||
return OK;
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
@@ -126,6 +184,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
register int r;
|
||||
DynamicBuffer buf;
|
||||
Token tok;
|
||||
int y, m, d;
|
||||
|
||||
DBufInit(&buf);
|
||||
|
||||
@@ -146,7 +205,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
trig->sched[0] = 0;
|
||||
trig->warn[0] = 0;
|
||||
trig->omitfunc[0] = 0;
|
||||
trig->tag[0] = 0;
|
||||
DBufInit(&(trig->tags));
|
||||
trig->passthru[0] = 0;
|
||||
tim->ttime = NO_TIME;
|
||||
tim->delta = NO_DELTA;
|
||||
@@ -164,6 +223,32 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
/* Figure out what we've got */
|
||||
FindToken(DBufValue(&buf), &tok);
|
||||
switch(tok.type) {
|
||||
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;
|
||||
FromJulian(tok.val, &y, &m, &d);
|
||||
trig->y = y;
|
||||
trig->m = m;
|
||||
trig->d = d;
|
||||
break;
|
||||
|
||||
case T_DateTime:
|
||||
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;
|
||||
FromJulian(tok.val / MINUTES_PER_DAY, &y, &m, &d);
|
||||
trig->y = y;
|
||||
trig->m = m;
|
||||
trig->d = d;
|
||||
tim->ttime = (tok.val % MINUTES_PER_DAY);
|
||||
if (save_in_globals) {
|
||||
LastTriggerTime = tim->ttime;
|
||||
}
|
||||
break;
|
||||
|
||||
case T_WkDay:
|
||||
DBufFree(&buf);
|
||||
if (trig->wd & (1 << tok.val)) return E_WD_TWICE;
|
||||
@@ -216,6 +301,14 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
}
|
||||
return OK;
|
||||
|
||||
case T_Through:
|
||||
DBufFree(&buf);
|
||||
if (trig->rep != NO_REP) return E_REP_TWICE;
|
||||
trig->rep = 1;
|
||||
r = ParseUntil(s, trig);
|
||||
if (r) return r;
|
||||
break;
|
||||
|
||||
case T_Until:
|
||||
DBufFree(&buf);
|
||||
r=ParseUntil(s, trig);
|
||||
@@ -293,7 +386,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals)
|
||||
case T_Tag:
|
||||
r = ParseToken(s, &buf);
|
||||
if (r) return r;
|
||||
StrnCpy(trig->tag, DBufValue(&buf), TAG_LEN);
|
||||
AppendTag(&(trig->tags), DBufValue(&buf));
|
||||
break;
|
||||
|
||||
case T_Duration:
|
||||
@@ -462,6 +555,23 @@ static int ParseUntil(ParsePtr s, Trigger *t)
|
||||
d = tok.val;
|
||||
break;
|
||||
|
||||
case T_Date:
|
||||
DBufFree(&buf);
|
||||
if (y != NO_YR) {
|
||||
Eprint("UNTIL: %s", ErrMsg[E_YR_TWICE]);
|
||||
return E_YR_TWICE;
|
||||
}
|
||||
if (m != NO_MON) {
|
||||
Eprint("UNTIL: %s", ErrMsg[E_MON_TWICE]);
|
||||
return E_MON_TWICE;
|
||||
}
|
||||
if (d != NO_DAY) {
|
||||
Eprint("UNTIL: %s", ErrMsg[E_DAY_TWICE]);
|
||||
return E_DAY_TWICE;
|
||||
}
|
||||
FromJulian(tok.val, &y, &m, &d);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (y == NO_YR || m == NO_MON || d == NO_DAY) {
|
||||
Eprint("UNTIL: %s", ErrMsg[E_INCOMPLETE]);
|
||||
@@ -537,6 +647,23 @@ static int ParseScanFrom(ParsePtr s, Trigger *t, int type)
|
||||
d = tok.val;
|
||||
break;
|
||||
|
||||
case T_Date:
|
||||
DBufFree(&buf);
|
||||
if (y != NO_YR) {
|
||||
Eprint("%s: %s", word, ErrMsg[E_YR_TWICE]);
|
||||
return E_YR_TWICE;
|
||||
}
|
||||
if (m != NO_MON) {
|
||||
Eprint("%s: %s", word, ErrMsg[E_MON_TWICE]);
|
||||
return E_MON_TWICE;
|
||||
}
|
||||
if (d != NO_DAY) {
|
||||
Eprint("%s: %s", word, ErrMsg[E_DAY_TWICE]);
|
||||
return E_DAY_TWICE;
|
||||
}
|
||||
FromJulian(tok.val, &y, &m, &d);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (y == NO_YR || m == NO_MON || d == NO_DAY) {
|
||||
Eprint("%s: %s", word, ErrMsg[E_INCOMPLETE]);
|
||||
@@ -581,28 +708,34 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul)
|
||||
DBufInit(&calRow);
|
||||
DBufInit(&pre_buf);
|
||||
if (t->typ == RUN_TYPE && RunDisabled) return E_RUN_DISABLED;
|
||||
if ((t->typ == PASSTHRU_TYPE && strcmp(t->passthru, "COLOR")) ||
|
||||
if ((t->typ == PASSTHRU_TYPE && strcmp(t->passthru, "COLOR") && strcmp(t->passthru, "COLOUR")) ||
|
||||
t->typ == CAL_TYPE ||
|
||||
t->typ == PS_TYPE ||
|
||||
t->typ == PSF_TYPE)
|
||||
return OK;
|
||||
|
||||
/* Handle COLOR types */
|
||||
if (t->typ == PASSTHRU_TYPE && !strcmp(t->passthru, "COLOR")) {
|
||||
if (t->typ == PASSTHRU_TYPE && (!strcmp(t->passthru, "COLOR") || !strcmp(t->passthru, "COLOUR"))) {
|
||||
/* Strip off three tokens */
|
||||
r = ParseToken(p, &buf);
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
if (!NextMode) {
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
}
|
||||
DBufFree(&buf);
|
||||
if (r) return r;
|
||||
r = ParseToken(p, &buf);
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
if (!NextMode) {
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
}
|
||||
DBufFree(&buf);
|
||||
if (r) return r;
|
||||
r = ParseToken(p, &buf);
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
if (!NextMode) {
|
||||
DBufPuts(&pre_buf, DBufValue(&buf));
|
||||
DBufPutc(&pre_buf, ' ');
|
||||
}
|
||||
DBufFree(&buf);
|
||||
if (r) return r;
|
||||
t->typ = MSG_TYPE;
|
||||
@@ -642,16 +775,12 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul)
|
||||
DBufFree(&pre_buf);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
if (t->tag[0]) {
|
||||
sprintf(tmpBuf, "%s ", t->tag);
|
||||
} else {
|
||||
sprintf(tmpBuf, "* ");
|
||||
}
|
||||
if (DBufPuts(&calRow, tmpBuf) != OK) {
|
||||
DBufFree(&calRow);
|
||||
DBufFree(&pre_buf);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
if (*DBufValue(&(t->tags))) {
|
||||
DBufPuts(&calRow, DBufValue(&(t->tags)));
|
||||
DBufPutc(&calRow, ' ');
|
||||
} else {
|
||||
DBufPuts(&calRow, "* ");
|
||||
}
|
||||
if (tim->duration != NO_TIME) {
|
||||
sprintf(tmpBuf, "%d ", tim->duration);
|
||||
} else {
|
||||
@@ -686,38 +815,46 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* Put the substituted string into the substitution buffer */
|
||||
if (UserFuncExists("msgprefix") == 1) {
|
||||
sprintf(PrioExpr, "msgprefix(%d)", t->priority);
|
||||
s = PrioExpr;
|
||||
r = EvalExpr(&s, &v);
|
||||
if (!r) {
|
||||
if (!DoCoerce(STR_TYPE, &v)) {
|
||||
if (DBufPuts(&buf, v.v.str) != OK) {
|
||||
DBufFree(&buf);
|
||||
DestroyValue(v);
|
||||
return E_NO_MEM;
|
||||
/* Put the substituted string into the substitution buffer */
|
||||
|
||||
/* Don't use msgprefix() on RUN-type reminders */
|
||||
if (t->typ != RUN_TYPE) {
|
||||
if (UserFuncExists("msgprefix") == 1) {
|
||||
sprintf(PrioExpr, "msgprefix(%d)", t->priority);
|
||||
s = PrioExpr;
|
||||
r = EvalExpr(&s, &v, NULL);
|
||||
if (!r) {
|
||||
if (!DoCoerce(STR_TYPE, &v)) {
|
||||
if (DBufPuts(&buf, v.v.str) != OK) {
|
||||
DBufFree(&buf);
|
||||
DestroyValue(v);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
DestroyValue(v);
|
||||
}
|
||||
DestroyValue(v);
|
||||
}
|
||||
}
|
||||
|
||||
if ( (r=DoSubst(p, &buf, t, tim, jul, NORMAL_MODE)) ) return r;
|
||||
if (UserFuncExists("msgsuffix") == 1) {
|
||||
sprintf(PrioExpr, "msgsuffix(%d)", t->priority);
|
||||
s = PrioExpr;
|
||||
r = EvalExpr(&s, &v);
|
||||
if (!r) {
|
||||
if (!DoCoerce(STR_TYPE, &v)) {
|
||||
if (DBufPuts(&buf, v.v.str) != OK) {
|
||||
DBufFree(&buf);
|
||||
DestroyValue(v);
|
||||
return E_NO_MEM;
|
||||
if (t->typ != RUN_TYPE) {
|
||||
if (UserFuncExists("msgsuffix") == 1) {
|
||||
sprintf(PrioExpr, "msgsuffix(%d)", t->priority);
|
||||
s = PrioExpr;
|
||||
r = EvalExpr(&s, &v, NULL);
|
||||
if (!r) {
|
||||
if (!DoCoerce(STR_TYPE, &v)) {
|
||||
if (DBufPuts(&buf, v.v.str) != OK) {
|
||||
DBufFree(&buf);
|
||||
DestroyValue(v);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
DestroyValue(v);
|
||||
}
|
||||
DestroyValue(v);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!MsgCommand && t->typ == MSG_TYPE) || t->typ == MSF_TYPE) {
|
||||
if (DBufPutc(&buf, '\n') != OK) {
|
||||
DBufFree(&buf);
|
||||
@@ -787,7 +924,17 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int jul, int *err)
|
||||
|
||||
/* Don't trigger timed reminders if DontIssueAts is true, and if the
|
||||
reminder is for today */
|
||||
if (jul == JulianToday && DontIssueAts && tim->ttime != NO_TIME) return 0;
|
||||
if (jul == JulianToday && DontIssueAts && tim->ttime != NO_TIME) {
|
||||
if (DontIssueAts > 1) {
|
||||
/* If two or more -a options, then *DO* issue ats that are in the
|
||||
future */
|
||||
if (tim->ttime < SystemTime(0) / 60) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't trigger "old" timed reminders */
|
||||
/*** REMOVED...
|
||||
@@ -814,9 +961,9 @@ int ShouldTriggerReminder(Trigger *t, TimeTrig *tim, int jul, int *err)
|
||||
if (t->delta < 0)
|
||||
jul = jul + t->delta;
|
||||
else {
|
||||
r = t->delta;
|
||||
int iter = 0;
|
||||
int max = MaxSatIter;
|
||||
r = t->delta;
|
||||
if (max < r*2) max = r*2;
|
||||
while(iter++ < max) {
|
||||
if (!r || (jul <= JulianToday)) {
|
||||
@@ -862,7 +1009,7 @@ int DoSatRemind(Trigger *trig, TimeTrig *tim, ParsePtr p)
|
||||
if (r == E_CANT_TRIG) return OK; else return r;
|
||||
}
|
||||
if (jul == -1) {
|
||||
return OK;
|
||||
return E_EXPIRED;
|
||||
}
|
||||
s = p->pos;
|
||||
r = EvaluateExpr(p, &v);
|
||||
@@ -1003,7 +1150,7 @@ static int ShouldTriggerBasedOnWarn(Trigger *t, int jul, int *err)
|
||||
for (i=1; ; i++) {
|
||||
sprintf(buffer, "%s(%d)", t->warn, i);
|
||||
s = buffer;
|
||||
r = EvalExpr(&s, &v);
|
||||
r = EvalExpr(&s, &v, NULL);
|
||||
if (r) {
|
||||
Eprint("%s: `%s': %s", ErrMsg[M_BAD_WARN_FUNC],
|
||||
t->warn, ErrMsg[r]);
|
||||
|
||||
122
src/dosubst.c
122
src/dosubst.c
@@ -62,6 +62,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
char *os;
|
||||
char s[256];
|
||||
int origLen = DBufLen(dbuf);
|
||||
int altmode;
|
||||
|
||||
FromJulian(jul, &y, &m, &d);
|
||||
|
||||
@@ -141,6 +142,7 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
if (DBufPutc(dbuf, c) != OK) return E_NO_MEM;
|
||||
continue;
|
||||
}
|
||||
altmode = 0;
|
||||
s[0] = 0;
|
||||
c = ParseChar(p, &err, 0);
|
||||
if (err) {
|
||||
@@ -150,6 +152,17 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
if (!c) {
|
||||
break;
|
||||
}
|
||||
if (c == '*') {
|
||||
altmode = c;
|
||||
c = ParseChar(p, &err, 0);
|
||||
if (err) {
|
||||
DBufFree(dbuf);
|
||||
return err;
|
||||
}
|
||||
if (!c) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
done = 0;
|
||||
if (diff <= 1) {
|
||||
switch(UPPER(c)) {
|
||||
@@ -206,8 +219,13 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_A_OVER
|
||||
L_A_OVER
|
||||
#else
|
||||
sprintf(s, "%s %s, %d %s, %d", L_ON, DayName[jul%7], d,
|
||||
MonthName[m], y);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%s, %d %s, %d", DayName[jul%7], d,
|
||||
MonthName[m], y);
|
||||
} else {
|
||||
sprintf(s, "%s %s, %d %s, %d", L_ON, DayName[jul%7], d,
|
||||
MonthName[m], y);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -225,7 +243,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_C_OVER
|
||||
L_C_OVER
|
||||
#else
|
||||
sprintf(s, "%s %s", L_ON, DayName[jul%7]);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%s", DayName[jul%7]);
|
||||
} else {
|
||||
sprintf(s, "%s %s", L_ON, DayName[jul%7]);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -243,8 +265,13 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_E_OVER
|
||||
L_E_OVER
|
||||
#else
|
||||
sprintf(s, "%s %02d%c%02d%c%04d", L_ON, d, DateSep,
|
||||
m+1, DateSep, y);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%02d%c%02d%c%04d", d, DateSep,
|
||||
m+1, DateSep, y);
|
||||
} else {
|
||||
sprintf(s, "%s %02d%c%02d%c%04d", L_ON, d, DateSep,
|
||||
m+1, DateSep, y);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -253,7 +280,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_F_OVER
|
||||
L_F_OVER
|
||||
#else
|
||||
sprintf(s, "%s %02d%c%02d%c%04d", L_ON, m+1, DateSep, d, DateSep, y);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%02d%c%02d%c%04d", m+1, DateSep, d, DateSep, y);
|
||||
} else {
|
||||
sprintf(s, "%s %02d%c%02d%c%04d", L_ON, m+1, DateSep, d, DateSep, y);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -262,7 +293,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_G_OVER
|
||||
L_G_OVER
|
||||
#else
|
||||
sprintf(s, "%s %s, %d %s", L_ON, DayName[jul%7], d, MonthName[m]);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%s, %d %s", DayName[jul%7], d, MonthName[m]);
|
||||
} else {
|
||||
sprintf(s, "%s %s, %d %s", L_ON, DayName[jul%7], d, MonthName[m]);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -271,7 +306,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_H_OVER
|
||||
L_H_OVER
|
||||
#else
|
||||
sprintf(s, "%s %02d%c%02d", L_ON, d, DateSep, m+1);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%02d%c%02d", d, DateSep, m+1);
|
||||
} else {
|
||||
sprintf(s, "%s %02d%c%02d", L_ON, d, DateSep, m+1);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -280,7 +319,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_I_OVER
|
||||
L_I_OVER
|
||||
#else
|
||||
sprintf(s, "%s %02d%c%02d", L_ON, m+1, DateSep, d);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%02d%c%02d", m+1, DateSep, d);
|
||||
} else {
|
||||
sprintf(s, "%s %02d%c%02d", L_ON, m+1, DateSep, d);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -289,8 +332,13 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_J_OVER
|
||||
L_J_OVER
|
||||
#else
|
||||
sprintf(s, "%s %s, %s %d%s, %d", L_ON, DayName[jul%7],
|
||||
MonthName[m], d, plu, y);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%s, %s %d%s, %d", DayName[jul%7],
|
||||
MonthName[m], d, plu, y);
|
||||
} else {
|
||||
sprintf(s, "%s %s, %s %d%s, %d", L_ON, DayName[jul%7],
|
||||
MonthName[m], d, plu, y);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -299,8 +347,13 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_K_OVER
|
||||
L_K_OVER
|
||||
#else
|
||||
sprintf(s, "%s %s, %s %d%s", L_ON, DayName[jul%7],
|
||||
MonthName[m], d, plu);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%s, %s %d%s", DayName[jul%7],
|
||||
MonthName[m], d, plu);
|
||||
} else {
|
||||
sprintf(s, "%s %s, %s %d%s", L_ON, DayName[jul%7],
|
||||
MonthName[m], d, plu);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -309,7 +362,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_L_OVER
|
||||
L_L_OVER
|
||||
#else
|
||||
sprintf(s, "%s %04d%c%02d%c%02d", L_ON, y, DateSep, m+1, DateSep, d);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%04d%c%02d%c%02d", y, DateSep, m+1, DateSep, d);
|
||||
} else {
|
||||
sprintf(s, "%s %04d%c%02d%c%02d", L_ON, y, DateSep, m+1, DateSep, d);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -391,8 +448,13 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_U_OVER
|
||||
L_U_OVER
|
||||
#else
|
||||
sprintf(s, "%s %s, %d%s %s, %d", L_ON, DayName[jul%7], d,
|
||||
plu, MonthName[m], y);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%s, %d%s %s, %d", DayName[jul%7], d,
|
||||
plu, MonthName[m], y);
|
||||
} else {
|
||||
sprintf(s, "%s %s, %d%s %s, %d", L_ON, DayName[jul%7], d,
|
||||
plu, MonthName[m], y);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -401,8 +463,13 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_V_OVER
|
||||
L_V_OVER
|
||||
#else
|
||||
sprintf(s, "%s %s, %d%s %s", L_ON, DayName[jul%7], d, plu,
|
||||
MonthName[m]);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%s, %d%s %s", DayName[jul%7], d, plu,
|
||||
MonthName[m]);
|
||||
} else {
|
||||
sprintf(s, "%s %s, %d%s %s", L_ON, DayName[jul%7], d, plu,
|
||||
MonthName[m]);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -464,7 +531,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
#ifdef L_2_OVER
|
||||
L_2_OVER
|
||||
#else
|
||||
sprintf(s, "%s %d%c%02d%s", L_AT, hh, TimeSep, min, pm);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%d%c%02d%s", hh, TimeSep, min, pm);
|
||||
} else {
|
||||
sprintf(s, "%s %d%c%02d%s", L_AT, hh, TimeSep, min, pm);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -474,7 +545,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
L_3_OVER
|
||||
#else
|
||||
|
||||
sprintf(s, "%s %02d%c%02d", L_AT, h, TimeSep, min);
|
||||
if (altmode == '*') {
|
||||
sprintf(s, "%02d%c%02d", h, TimeSep, min);
|
||||
} else {
|
||||
sprintf(s, "%s %02d%c%02d", L_AT, h, TimeSep, min);
|
||||
}
|
||||
#endif
|
||||
SHIP_OUT(s);
|
||||
break;
|
||||
@@ -590,8 +665,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
|
||||
if (DBufPutc(dbuf, c) != OK) return E_NO_MEM;
|
||||
}
|
||||
if (isupper(c)) {
|
||||
os = DBufValue(dbuf) - strlen(s);
|
||||
*os = UPPER(*os);
|
||||
os = DBufValue(dbuf);
|
||||
os += strlen(os) - strlen(s);
|
||||
if (os >= DBufValue(dbuf)) {
|
||||
*os = UPPER(*os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ EXTERN char *ErrMsg[]
|
||||
"Back value specified twice",
|
||||
"ONCE keyword used twice. (Hah.)",
|
||||
"Expecting time after AT",
|
||||
"UNTIL keyword used twice",
|
||||
"THROUGH/UNTIL keyword used twice",
|
||||
"Incomplete date specification",
|
||||
"FROM/SCANFROM keyword used twice",
|
||||
"Variable",
|
||||
|
||||
91
src/expr.c
91
src/expr.c
@@ -41,8 +41,7 @@ static int Multiply(void), Divide(void), Mod(void), Add(void),
|
||||
UnMinus(void), LogNot(void),
|
||||
Compare(int);
|
||||
|
||||
static int MakeValue (char const *s, Value *v, Var *locals);
|
||||
static int ParseLiteralDate (char const **s, int *jul, int *tim);
|
||||
static int MakeValue (char const *s, Value *v, Var *locals, ParsePtr p);
|
||||
|
||||
/* Binary operators - all left-associative */
|
||||
|
||||
@@ -73,9 +72,7 @@ Operator UnOp[] = {
|
||||
};
|
||||
#define NUM_UN_OPS (sizeof(UnOp) / sizeof(Operator))
|
||||
|
||||
/* Functions have the same definitions as operators, except the prec field
|
||||
is used to indicate how many arguments are needed. */
|
||||
extern Operator Func[];
|
||||
extern BuiltinFunc Func[];
|
||||
|
||||
Operator OpStack[OP_STACK_SIZE];
|
||||
Value ValStack[VAL_STACK_SIZE];
|
||||
@@ -135,7 +132,7 @@ static void CleanStack(void)
|
||||
static char PeekChar(char const **s)
|
||||
{
|
||||
char const *t = *s;
|
||||
while (*t && isspace(*t)) t++;
|
||||
while (*t && isempty(*t)) t++;
|
||||
return *t;
|
||||
}
|
||||
|
||||
@@ -153,7 +150,7 @@ static int ParseExprToken(DynamicBuffer *buf, char const **in)
|
||||
|
||||
DBufFree(buf);
|
||||
/* Skip white space */
|
||||
while (**in && isspace(**in)) (*in)++;
|
||||
while (**in && isempty(**in)) (*in)++;
|
||||
|
||||
if (!**in) return OK;
|
||||
|
||||
@@ -286,7 +283,7 @@ static int ParseExprToken(DynamicBuffer *buf, char const **in)
|
||||
(*in)++;
|
||||
}
|
||||
/* Chew up any remaining white space */
|
||||
while (**in && isspace(**in)) (*in)++;
|
||||
while (**in && isempty(**in)) (*in)++;
|
||||
|
||||
/* Peek ahead - is it '('? Then we have a function call */
|
||||
if (**in == '(') {
|
||||
@@ -306,14 +303,14 @@ static int ParseExprToken(DynamicBuffer *buf, char const **in)
|
||||
/* Put the result into value pointed to by v. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int EvalExpr(char const **e, Value *v)
|
||||
int EvalExpr(char const **e, Value *v, ParsePtr p)
|
||||
{
|
||||
int r;
|
||||
|
||||
OpStackPtr = 0;
|
||||
ValStackPtr = 0;
|
||||
|
||||
r = Evaluate(e, NULL);
|
||||
r = Evaluate(e, NULL, p);
|
||||
|
||||
/* Put last character parsed back onto input stream */
|
||||
if (DBufLen(&ExprBuf)) (*e)--;
|
||||
@@ -329,11 +326,12 @@ int EvalExpr(char const **e, Value *v)
|
||||
}
|
||||
|
||||
/* Evaluate - do the actual work of evaluation. */
|
||||
int Evaluate(char const **s, Var *locals)
|
||||
int Evaluate(char const **s, Var *locals, ParsePtr p)
|
||||
{
|
||||
int OpBase, ValBase;
|
||||
int r;
|
||||
Operator *f;
|
||||
Operator *o;
|
||||
BuiltinFunc *f;
|
||||
int args; /* Number of function arguments */
|
||||
Operator op, op2;
|
||||
Value va;
|
||||
@@ -353,7 +351,7 @@ int Evaluate(char const **s, Var *locals)
|
||||
|
||||
if (*DBufValue(&ExprBuf) == '(') { /* Parenthesized expression */
|
||||
DBufFree(&ExprBuf);
|
||||
r = Evaluate(s, locals); /* Leaves the last parsed token in ExprBuf */
|
||||
r = Evaluate(s, locals, p); /* Leaves the last parsed token in ExprBuf */
|
||||
if (r) return r;
|
||||
r = OK;
|
||||
if (*DBufValue(&ExprBuf) != ')') {
|
||||
@@ -376,9 +374,11 @@ int Evaluate(char const **s, Var *locals)
|
||||
}
|
||||
args = 0;
|
||||
if (PeekChar(s) == ')') { /* Function has no arguments */
|
||||
if (f) r = CallFunc(f, 0);
|
||||
else {
|
||||
r = CallUserFunc(ufname, 0);
|
||||
if (f) {
|
||||
if (!f->is_constant && (p != NULL)) p->nonconst_expr = 1;
|
||||
r = CallFunc(f, 0);
|
||||
} else {
|
||||
r = CallUserFunc(ufname, 0, p);
|
||||
free((char *) ufname);
|
||||
}
|
||||
if (r) return r;
|
||||
@@ -387,7 +387,7 @@ int Evaluate(char const **s, Var *locals)
|
||||
} else { /* Function has some arguments */
|
||||
while(1) {
|
||||
args++;
|
||||
r = Evaluate(s, locals);
|
||||
r = Evaluate(s, locals, p);
|
||||
if (r) {
|
||||
if (!f) free((char *) ufname);
|
||||
return r;
|
||||
@@ -401,19 +401,21 @@ int Evaluate(char const **s, Var *locals)
|
||||
return E_EXPECT_COMMA;
|
||||
}
|
||||
}
|
||||
if (f) r = CallFunc(f, args);
|
||||
else {
|
||||
r = CallUserFunc(ufname, args);
|
||||
if (f) {
|
||||
if (!f->is_constant && (p != NULL)) p->nonconst_expr = 1;
|
||||
r = CallFunc(f, args);
|
||||
} else {
|
||||
r = CallUserFunc(ufname, args, p);
|
||||
free((char *) ufname);
|
||||
}
|
||||
DBufFree(&ExprBuf);
|
||||
if (r) return r;
|
||||
}
|
||||
} else { /* Unary operator */
|
||||
f = FindFunc(DBufValue(&ExprBuf), UnOp, NUM_UN_OPS);
|
||||
if (f) {
|
||||
o = FindOperator(DBufValue(&ExprBuf), UnOp, NUM_UN_OPS);
|
||||
if (o) {
|
||||
DBufFree(&ExprBuf);
|
||||
PushOpStack(*f);
|
||||
PushOpStack(*o);
|
||||
continue; /* Still looking for an atomic vlue */
|
||||
} else if (!ISID(*DBufValue(&ExprBuf)) &&
|
||||
*DBufValue(&ExprBuf) != '$' &&
|
||||
@@ -424,7 +426,7 @@ int Evaluate(char const **s, Var *locals)
|
||||
DBufFree(&ExprBuf);
|
||||
return E_ILLEGAL_CHAR;
|
||||
} else { /* Must be a literal value */
|
||||
r = MakeValue(DBufValue(&ExprBuf), &va, locals);
|
||||
r = MakeValue(DBufValue(&ExprBuf), &va, locals, p);
|
||||
DBufFree(&ExprBuf);
|
||||
if (r) return r;
|
||||
PushValStack(va);
|
||||
@@ -459,13 +461,13 @@ int Evaluate(char const **s, Var *locals)
|
||||
return OK;
|
||||
}
|
||||
/* Must be a binary operator */
|
||||
f = FindFunc(DBufValue(&ExprBuf), BinOp, NUM_BIN_OPS);
|
||||
o = FindOperator(DBufValue(&ExprBuf), BinOp, NUM_BIN_OPS);
|
||||
DBufFree(&ExprBuf);
|
||||
if (!f) return E_EXPECTING_BINOP;
|
||||
if (!o) return E_EXPECTING_BINOP;
|
||||
|
||||
/* While operators of higher or equal precedence are on the stack,
|
||||
pop them off and evaluate */
|
||||
while (OpStackPtr > OpBase && OpStack[OpStackPtr-1].prec >= f->prec) {
|
||||
while (OpStackPtr > OpBase && OpStack[OpStackPtr-1].prec >= o->prec) {
|
||||
PopOpStack(op2);
|
||||
if (r) return r;
|
||||
if (DebugFlag & DB_PRTEXPR)
|
||||
@@ -477,7 +479,7 @@ int Evaluate(char const **s, Var *locals)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
PushOpStack(*f);
|
||||
PushOpStack(*o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +490,7 @@ int Evaluate(char const **s, Var *locals)
|
||||
/* a date or the value of a symbol. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
static int MakeValue(char const *s, Value *v, Var *locals)
|
||||
static int MakeValue(char const *s, Value *v, Var *locals, ParsePtr p)
|
||||
{
|
||||
int len;
|
||||
int h, m, r;
|
||||
@@ -543,6 +545,7 @@ static int MakeValue(char const *s, Value *v, Var *locals)
|
||||
v->v.val = len;
|
||||
return OK;
|
||||
} else if (*s == '$') { /* A system variable */
|
||||
if (p) p->nonconst_expr = 1;
|
||||
if (DebugFlag & DB_PRTEXPR)
|
||||
fprintf(ErrFp, "%s => ", s);
|
||||
r = GetSysVar(s+1, v);
|
||||
@@ -553,10 +556,11 @@ static int MakeValue(char const *s, Value *v, Var *locals)
|
||||
Putc('\n', ErrFp);
|
||||
}
|
||||
return r;
|
||||
} else /* Must be a symbol */
|
||||
} else { /* Must be a symbol */
|
||||
if (DebugFlag & DB_PRTEXPR)
|
||||
fprintf(ErrFp, "%s => ", s);
|
||||
r = GetVarValue(s, v, locals);
|
||||
}
|
||||
r = GetVarValue(s, v, locals, p);
|
||||
if (! (DebugFlag & DB_PRTEXPR)) return r;
|
||||
if (r == OK) {
|
||||
PrintValue(v, ErrFp);
|
||||
@@ -1126,7 +1130,28 @@ static int LogNot(void)
|
||||
/* Find a function. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
Operator *FindFunc(char const *name, Operator where[], int num)
|
||||
Operator *FindOperator(char const *name, Operator where[], int num)
|
||||
{
|
||||
int top=num-1, bot=0;
|
||||
int mid, r;
|
||||
while (top >= bot) {
|
||||
mid = (top + bot) / 2;
|
||||
r = StrCmpi(name, where[mid].name);
|
||||
if (!r) return &where[mid];
|
||||
else if (r > 0) bot = mid+1;
|
||||
else top = mid-1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* FindFunc */
|
||||
/* */
|
||||
/* Find a function. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
BuiltinFunc *FindFunc(char const *name, BuiltinFunc where[], int num)
|
||||
{
|
||||
int top=num-1, bot=0;
|
||||
int mid, r;
|
||||
@@ -1202,7 +1227,7 @@ int CopyValue(Value *dest, const Value *src)
|
||||
/* and tim; update s. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
static int ParseLiteralDate(char const **s, int *jul, int *tim)
|
||||
int ParseLiteralDate(char const **s, int *jul, int *tim)
|
||||
{
|
||||
int y, m, d;
|
||||
int hour, min;
|
||||
|
||||
95
src/files.c
95
src/files.c
@@ -17,6 +17,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -97,6 +98,32 @@ static void DestroyCache (CachedFile *cf);
|
||||
static int CheckSafety (void);
|
||||
static int PopFile (void);
|
||||
|
||||
static void OpenPurgeFile(char const *fname, char const *mode)
|
||||
{
|
||||
DynamicBuffer fname_buf;
|
||||
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
|
||||
/* Do not open a purge file if we're below purge
|
||||
include depth */
|
||||
if (IStackPtr-2 >= PurgeIncludeDepth) {
|
||||
PurgeFP = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
DBufInit(&fname_buf);
|
||||
if (DBufPuts(&fname_buf, fname) != OK) return;
|
||||
if (DBufPuts(&fname_buf, ".purged") != OK) return;
|
||||
PurgeFP = fopen(DBufValue(&fname_buf), mode);
|
||||
if (!PurgeFP) {
|
||||
fprintf(ErrFp, "Cannot open `%s' for writing: %s\n", DBufValue(&fname_buf), strerror(errno));
|
||||
}
|
||||
DBufFree(&fname_buf);
|
||||
}
|
||||
|
||||
static void FreeChainItem(FilenameChain *chain)
|
||||
{
|
||||
if (chain->filename) free((void *) chain->filename);
|
||||
@@ -173,14 +200,32 @@ static int ReadLineFromFile(void)
|
||||
}
|
||||
if (feof(fp)) {
|
||||
FCLOSE(fp);
|
||||
if ((DBufLen(&buf) == 0) &&
|
||||
(DBufLen(&LineBuffer) == 0) && PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) fclose(PurgeFP);
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
}
|
||||
l = DBufLen(&buf);
|
||||
if (l && (DBufValue(&buf)[l-1] == '\\')) {
|
||||
DBufValue(&buf)[l-1] = '\n';
|
||||
if (DBufPuts(&LineBuffer, DBufValue(&buf)) != OK) {
|
||||
DBufFree(&buf);
|
||||
DBufFree(&LineBuffer);
|
||||
return E_NO_MEM;
|
||||
if (PurgeMode) {
|
||||
if (DBufPuts(&LineBuffer, DBufValue(&buf)) != OK) {
|
||||
DBufFree(&buf);
|
||||
DBufFree(&LineBuffer);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
if (DBufPutc(&LineBuffer, '\n') != OK) {
|
||||
DBufFree(&buf);
|
||||
DBufFree(&LineBuffer);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
} else {
|
||||
DBufValue(&buf)[l-1] = '\n';
|
||||
if (DBufPuts(&LineBuffer, DBufValue(&buf)) != OK) {
|
||||
DBufFree(&buf);
|
||||
DBufFree(&LineBuffer);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -212,6 +257,13 @@ int OpenFile(char const *fname)
|
||||
CachedFile *h = CachedFiles;
|
||||
int r;
|
||||
|
||||
if (PurgeMode) {
|
||||
if (PurgeFP != NULL && PurgeFP != stdout) {
|
||||
fclose(PurgeFP);
|
||||
}
|
||||
PurgeFP = NULL;
|
||||
}
|
||||
|
||||
/* Assume we own the file for now */
|
||||
RunDisabled &= ~RUN_NOTOWNER;
|
||||
|
||||
@@ -236,6 +288,9 @@ int OpenFile(char const *fname)
|
||||
/* If it's a dash, then it's stdin */
|
||||
if (!strcmp(fname, "-")) {
|
||||
fp = stdin;
|
||||
if (PurgeMode) {
|
||||
PurgeFP = stdout;
|
||||
}
|
||||
if (DebugFlag & DB_TRACE_FILES) {
|
||||
fprintf(ErrFp, "Reading `-': Reading stdin\n");
|
||||
}
|
||||
@@ -244,6 +299,9 @@ int OpenFile(char const *fname)
|
||||
if (DebugFlag & DB_TRACE_FILES) {
|
||||
fprintf(ErrFp, "Reading `%s': Opening file on disk\n", fname);
|
||||
}
|
||||
if (PurgeMode) {
|
||||
OpenPurgeFile(fname, "w");
|
||||
}
|
||||
}
|
||||
if (!fp || !CheckSafety()) return E_CANT_OPEN;
|
||||
CLine = NULL;
|
||||
@@ -257,8 +315,10 @@ int OpenFile(char const *fname)
|
||||
if (strcmp(fname, "-")) {
|
||||
fp = fopen(fname, "r");
|
||||
if (!fp || !CheckSafety()) return E_CANT_OPEN;
|
||||
if (PurgeMode) OpenPurgeFile(fname, "w");
|
||||
} else {
|
||||
fp = stdin;
|
||||
if (PurgeMode) PurgeFP = stdout;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,7 +349,11 @@ static int CacheFile(char const *fname)
|
||||
/* Create a file header */
|
||||
cf = NEW(CachedFile);
|
||||
cf->cache = NULL;
|
||||
if (!cf) { ShouldCache = 0; FCLOSE(fp); return E_NO_MEM; }
|
||||
if (!cf) {
|
||||
ShouldCache = 0;
|
||||
FCLOSE(fp);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
cf->filename = StrDup(fname);
|
||||
if (!cf->filename) {
|
||||
ShouldCache = 0;
|
||||
@@ -315,7 +379,7 @@ static int CacheFile(char const *fname)
|
||||
}
|
||||
/* Skip blank chars */
|
||||
s = DBufValue(&LineBuffer);
|
||||
while (isspace(*s)) s++;
|
||||
while (isempty(*s)) s++;
|
||||
if (*s && *s!=';' && *s!='#') {
|
||||
/* Add the line to the cache */
|
||||
if (!cl) {
|
||||
@@ -424,8 +488,10 @@ static int PopFile(void)
|
||||
if (strcmp(i->filename, "-")) {
|
||||
fp = fopen(i->filename, "r");
|
||||
if (!fp || !CheckSafety()) return E_CANT_OPEN;
|
||||
if (PurgeMode) OpenPurgeFile(i->filename, "a");
|
||||
} else {
|
||||
fp = stdin;
|
||||
if (PurgeMode) PurgeFP = stdout;
|
||||
}
|
||||
if (fp != stdin)
|
||||
(void) fseek(fp, i->offset, 0); /* Trust that it works... */
|
||||
@@ -495,6 +561,10 @@ static int SetupGlobChain(char const *dirname, IncludeStruct *i)
|
||||
/* Check the cache */
|
||||
while(dc) {
|
||||
if (!strcmp(dc->dirname, dir)) {
|
||||
if (DebugFlag & DB_TRACE_FILES) {
|
||||
fprintf(ErrFp, "Found cached directory listing for `%s'\n",
|
||||
dir);
|
||||
}
|
||||
free(dir);
|
||||
i->chain = dc->chain;
|
||||
return OK;
|
||||
@@ -502,6 +572,10 @@ static int SetupGlobChain(char const *dirname, IncludeStruct *i)
|
||||
dc = dc->next;
|
||||
}
|
||||
|
||||
if (DebugFlag & DB_TRACE_FILES) {
|
||||
fprintf(ErrFp, "Scanning directory `%s' for *.rem files\n", dir);
|
||||
}
|
||||
|
||||
if (ShouldCache) {
|
||||
dc = malloc(sizeof(DirectoryFilenameChain));
|
||||
if (dc) {
|
||||
@@ -512,6 +586,10 @@ static int SetupGlobChain(char const *dirname, IncludeStruct *i)
|
||||
}
|
||||
}
|
||||
if (dc) {
|
||||
if (DebugFlag & DB_TRACE_FILES) {
|
||||
fprintf(ErrFp, "Caching directory `%s' listing\n", dir);
|
||||
}
|
||||
|
||||
dc->chain = NULL;
|
||||
dc->next = CachedDirectoryChains;
|
||||
CachedDirectoryChains = dc;
|
||||
@@ -615,9 +693,6 @@ int IncludeFile(char const *fname)
|
||||
if (stat(fname, &statbuf) == 0) {
|
||||
FilenameChain *fc;
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
if (DebugFlag & DB_TRACE_FILES) {
|
||||
fprintf(ErrFp, "Scanning directory `%s' for *.rem files\n", fname);
|
||||
}
|
||||
if (SetupGlobChain(fname, i) == OK) { /* Glob succeeded */
|
||||
if (!i->chain) { /* Oops... no matching files */
|
||||
if (!Hush) {
|
||||
|
||||
895
src/funcs.c
895
src/funcs.c
File diff suppressed because it is too large
Load Diff
@@ -79,7 +79,10 @@ EXTERN INIT( int MaxSatIter, 150);
|
||||
EXTERN INIT( int MaxStringLen, MAX_STR_LEN);
|
||||
EXTERN INIT( char *FileName, NULL);
|
||||
EXTERN INIT( int UseStdin, 0);
|
||||
EXTERN INIT( int PurgeMode, 0);
|
||||
EXTERN INIT( int PurgeIncludeDepth, 0);
|
||||
EXTERN FILE *ErrFp;
|
||||
EXTERN INIT( FILE *PurgeFP, NULL);
|
||||
EXTERN INIT( int NumIfs, 0);
|
||||
EXTERN INIT( unsigned int IfFlags, 0);
|
||||
EXTERN INIT( int LastTriggerDate, 0);
|
||||
@@ -93,6 +96,7 @@ EXTERN char const **ArgV;
|
||||
EXTERN INIT( int CalLines, CAL_LINES);
|
||||
EXTERN INIT( int CalPad, 1);
|
||||
EXTERN INIT( int UseVTChars, 0);
|
||||
EXTERN INIT( int UseUTF8Chars, 0);
|
||||
EXTERN INIT( int UseVTColors, 0);
|
||||
|
||||
/* Latitude and longitude */
|
||||
|
||||
122
src/init.c
122
src/init.c
@@ -8,7 +8,7 @@
|
||||
/* */
|
||||
/* This file is part of REMIND. */
|
||||
/* Copyright (C) 1992-1998 by David F. Skoll */
|
||||
/* Copyright (C) 1999-2007 by Roaring Penguin Software Inc. */
|
||||
/* Copyright (C) 1999-2011 by Roaring Penguin Software Inc. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
* v = Dump variables at end
|
||||
* l = Display entire line in error messages
|
||||
* -e = Send messages normally sent to stderr to stdout instead
|
||||
* -z[n] = Daemon mode waking up every n (def 5) minutes.
|
||||
* -z[n] = Daemon mode waking up every n (def 1) minutes.
|
||||
* -bn = Time format for cal (0, 1, or 2)
|
||||
* -xn = Max. number of iterations for SATISFY
|
||||
* -uname = Run as user 'name' - only valid when run by root. If run
|
||||
@@ -67,9 +67,13 @@
|
||||
* -kcmd = Run 'cmd' for MSG-type reminders instead of printing to stdout
|
||||
* -iVAR=EXPR = Initialize and preserve VAR.
|
||||
* -m = Start calendar with Monday instead of Sunday.
|
||||
* -j[n] = Purge all junk from reminder files (n = INCLUDE depth)
|
||||
* A minus sign alone indicates to take input from stdin
|
||||
*
|
||||
**************************************************************/
|
||||
#if defined(__APPLE__) || defined(__CYGWIN__)
|
||||
static void rkrphgvba(int x);
|
||||
#endif
|
||||
|
||||
/* For parsing an integer */
|
||||
#define PARSENUM(var, s) \
|
||||
@@ -133,6 +137,16 @@ void InitRemind(int argc, char const *argv[])
|
||||
char const *s;
|
||||
int weeks;
|
||||
|
||||
int jul;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
rkrphgvba(0);
|
||||
#elif defined(__CYGWIN__)
|
||||
rkrphgvba(1);
|
||||
#endif
|
||||
|
||||
jul = NO_DATE;
|
||||
|
||||
/* Initialize global dynamic buffers */
|
||||
DBufInit(&Banner);
|
||||
DBufInit(&LineBuffer);
|
||||
@@ -140,6 +154,8 @@ void InitRemind(int argc, char const *argv[])
|
||||
|
||||
DBufPuts(&Banner, L_BANNER);
|
||||
|
||||
PurgeFP = NULL;
|
||||
|
||||
/* Make sure remind is not installed set-uid or set-gid */
|
||||
if (getgid() != getegid() ||
|
||||
getuid() != geteuid()) {
|
||||
@@ -189,6 +205,13 @@ void InitRemind(int argc, char const *argv[])
|
||||
while (*arg) {
|
||||
switch(*arg++) {
|
||||
|
||||
case 'j':
|
||||
case 'J':
|
||||
PurgeMode = 1;
|
||||
if (*arg) {
|
||||
PARSENUM(PurgeIncludeDepth, arg);
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
case 'I':
|
||||
InitializeVar(arg);
|
||||
@@ -294,7 +317,7 @@ void InitRemind(int argc, char const *argv[])
|
||||
|
||||
case 'a':
|
||||
case 'A':
|
||||
DontIssueAts = 1;
|
||||
DontIssueAts++;
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
@@ -328,6 +351,11 @@ void InitRemind(int argc, char const *argv[])
|
||||
arg++;
|
||||
continue;
|
||||
}
|
||||
if (*arg == 'u' || *arg == 'U') {
|
||||
UseUTF8Chars = 1;
|
||||
arg++;
|
||||
continue;
|
||||
}
|
||||
if (*arg == 'c' || *arg == 'C') {
|
||||
UseVTColors = 1;
|
||||
arg++;
|
||||
@@ -480,18 +508,32 @@ void InitRemind(int argc, char const *argv[])
|
||||
}
|
||||
break;
|
||||
|
||||
case T_DateTime:
|
||||
if (SysTime != -1L) Usage();
|
||||
if (m != NO_MON || d != NO_DAY || y != NO_YR || jul != NO_DATE) Usage();
|
||||
SysTime = (tok.val % MINUTES_PER_DAY) * 60;
|
||||
DontQueue = 1;
|
||||
Daemon = 0;
|
||||
jul = tok.val / MINUTES_PER_DAY;
|
||||
break;
|
||||
|
||||
case T_Date:
|
||||
if (m != NO_MON || d != NO_DAY || y != NO_YR || jul != NO_DATE) Usage();
|
||||
jul = tok.val;
|
||||
break;
|
||||
|
||||
case T_Month:
|
||||
if (m != NO_MON) Usage();
|
||||
if (m != NO_MON || jul != NO_DATE) Usage();
|
||||
else m = tok.val;
|
||||
break;
|
||||
|
||||
case T_Day:
|
||||
if (d != NO_DAY) Usage();
|
||||
if (d != NO_DAY || jul != NO_DATE) Usage();
|
||||
else d = tok.val;
|
||||
break;
|
||||
|
||||
case T_Year:
|
||||
if (y != NO_YR) Usage();
|
||||
if (y != NO_YR || jul != NO_DATE) Usage();
|
||||
else y = tok.val;
|
||||
break;
|
||||
|
||||
@@ -500,7 +542,8 @@ void InitRemind(int argc, char const *argv[])
|
||||
else rep = tok.val;
|
||||
break;
|
||||
|
||||
default: Usage();
|
||||
default:
|
||||
Usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,6 +553,9 @@ void InitRemind(int argc, char const *argv[])
|
||||
Daemon = 0;
|
||||
}
|
||||
|
||||
if (jul != NO_DATE) {
|
||||
FromJulian(jul, &y, &m, &d);
|
||||
}
|
||||
/* Must supply date in the form: day, mon, yr OR mon, yr */
|
||||
if (m != NO_MON || y != NO_YR || d != NO_DAY) {
|
||||
if (m == NO_MON || y == NO_YR) {
|
||||
@@ -523,12 +569,12 @@ void InitRemind(int argc, char const *argv[])
|
||||
}
|
||||
if (d == NO_DAY) d=1;
|
||||
if (d > DaysInMonth(m, y)) {
|
||||
fprintf(ErrFp, BadDate);
|
||||
fprintf(ErrFp, "%s", BadDate);
|
||||
Usage();
|
||||
}
|
||||
JulianToday = Julian(y, m, d);
|
||||
if (JulianToday == -1) {
|
||||
fprintf(ErrFp, BadDate);
|
||||
fprintf(ErrFp, "%s", BadDate);
|
||||
Usage();
|
||||
}
|
||||
CurYear = y;
|
||||
@@ -555,7 +601,7 @@ void InitRemind(int argc, char const *argv[])
|
||||
void Usage(void)
|
||||
{
|
||||
fprintf(ErrFp, "\nREMIND %s (%s version) Copyright 1992-1998 David F. Skoll\n", VERSION, L_LANGNAME);
|
||||
fprintf(ErrFp, "Copyright 1999-2008 Roaring Penguin Software Inc.\n");
|
||||
fprintf(ErrFp, "Copyright 1999-2011 Roaring Penguin Software Inc.\n");
|
||||
#ifdef BETA
|
||||
fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
|
||||
#endif
|
||||
@@ -576,7 +622,7 @@ void Usage(void)
|
||||
fprintf(ErrFp, " -a Don't trigger timed reminders immediately - just queue them\n");
|
||||
fprintf(ErrFp, " -q Don't queue timed reminders\n");
|
||||
fprintf(ErrFp, " -f Trigger timed reminders by staying in foreground\n");
|
||||
fprintf(ErrFp, " -z[n] Enter daemon mode, waking every n (5) minutes.\n");
|
||||
fprintf(ErrFp, " -z[n] Enter daemon mode, waking every n (1) minutes.\n");
|
||||
fprintf(ErrFp, " -d... Debug: e=echo x=expr-eval t=trig v=dumpvars l=showline f=tracefiles\n");
|
||||
fprintf(ErrFp, " -e Divert messages normally sent to stderr to stdout\n");
|
||||
fprintf(ErrFp, " -b[n] Time format for cal: 0=am/pm, 1=24hr, 2=none\n");
|
||||
@@ -586,6 +632,7 @@ void Usage(void)
|
||||
fprintf(ErrFp, " -ivar=val Initialize var to val and preserve var\n");
|
||||
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");
|
||||
exit(1);
|
||||
}
|
||||
#endif /* L_USAGE_OVERRIDE */
|
||||
@@ -630,7 +677,7 @@ static void ChgUser(char const *user)
|
||||
|
||||
home = malloc(strlen(pwent->pw_dir) + 6);
|
||||
if (!home) {
|
||||
fprintf(ErrFp, ErrMsg[M_NOMEM_ENV]);
|
||||
fprintf(ErrFp, "%s", ErrMsg[M_NOMEM_ENV]);
|
||||
exit(1);
|
||||
}
|
||||
sprintf(home, "HOME=%s", pwent->pw_dir);
|
||||
@@ -638,7 +685,7 @@ static void ChgUser(char const *user)
|
||||
|
||||
shell = malloc(strlen(pwent->pw_shell) + 7);
|
||||
if (!shell) {
|
||||
fprintf(ErrFp, ErrMsg[M_NOMEM_ENV]);
|
||||
fprintf(ErrFp, "%s", ErrMsg[M_NOMEM_ENV]);
|
||||
exit(1);
|
||||
}
|
||||
sprintf(shell, "SHELL=%s", pwent->pw_shell);
|
||||
@@ -647,14 +694,14 @@ static void ChgUser(char const *user)
|
||||
if (pwent->pw_uid) {
|
||||
username = malloc(strlen(pwent->pw_name) + 6);
|
||||
if (!username) {
|
||||
fprintf(ErrFp, ErrMsg[M_NOMEM_ENV]);
|
||||
fprintf(ErrFp, "%s", ErrMsg[M_NOMEM_ENV]);
|
||||
exit(1);
|
||||
}
|
||||
sprintf(username, "USER=%s", pwent->pw_name);
|
||||
putenv(username);
|
||||
logname= malloc(strlen(pwent->pw_name) + 9);
|
||||
if (!logname) {
|
||||
fprintf(ErrFp, ErrMsg[M_NOMEM_ENV]);
|
||||
fprintf(ErrFp, "%s", ErrMsg[M_NOMEM_ENV]);
|
||||
exit(1);
|
||||
}
|
||||
sprintf(logname, "LOGNAME=%s", pwent->pw_name);
|
||||
@@ -720,7 +767,7 @@ static void InitializeVar(char const *str)
|
||||
return;
|
||||
}
|
||||
|
||||
r=EvalExpr(&expr, &val);
|
||||
r=EvalExpr(&expr, &val, NULL);
|
||||
if (r) {
|
||||
fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[r]);
|
||||
return;
|
||||
@@ -742,3 +789,46 @@ static void InitializeVar(char const *str)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(__APPLE__) || defined(__CYGWIN__)
|
||||
static char const pmsg1[] = {
|
||||
0x4c, 0x62, 0x68, 0x20, 0x6e, 0x63, 0x63, 0x72, 0x6e, 0x65, 0x20,
|
||||
0x67, 0x62, 0x20, 0x6f, 0x72, 0x20, 0x65, 0x68, 0x61, 0x61, 0x76,
|
||||
0x61, 0x74, 0x20, 0x45, 0x72, 0x7a, 0x76, 0x61, 0x71, 0x20, 0x62,
|
||||
0x61, 0x20, 0x6e, 0x61, 0x20, 0x4e, 0x63, 0x63, 0x79, 0x72, 0x20,
|
||||
0x63, 0x65, 0x62, 0x71, 0x68, 0x70, 0x67, 0x2e, 0x20, 0x20, 0x56,
|
||||
0x27, 0x71, 0x20, 0x65, 0x6e, 0x67, 0x75, 0x72, 0x65, 0x20, 0x67,
|
||||
0x75, 0x6e, 0x67, 0x0a, 0x6c, 0x62, 0x68, 0x20, 0x71, 0x76, 0x71,
|
||||
0x61, 0x27, 0x67, 0x2e, 0x20, 0x20, 0x45, 0x72, 0x7a, 0x76, 0x61,
|
||||
0x71, 0x20, 0x72, 0x6b, 0x72, 0x70, 0x68, 0x67, 0x76, 0x62, 0x61,
|
||||
0x20, 0x6a, 0x76, 0x79, 0x79, 0x20, 0x70, 0x62, 0x61, 0x67, 0x76,
|
||||
0x61, 0x68, 0x72, 0x20, 0x7a, 0x62, 0x7a, 0x72, 0x61, 0x67, 0x6e,
|
||||
0x65, 0x76, 0x79, 0x6c, 0x2e, 0x0a, 0x00
|
||||
};
|
||||
|
||||
static char const pmsg2[] = {
|
||||
0x4c, 0x62, 0x68, 0x20, 0x6e, 0x63, 0x63, 0x72, 0x6e, 0x65, 0x20,
|
||||
0x67, 0x62, 0x20, 0x6f, 0x72, 0x20, 0x65, 0x68, 0x61, 0x61, 0x76,
|
||||
0x61, 0x74, 0x20, 0x45, 0x72, 0x7a, 0x76, 0x61, 0x71, 0x20, 0x62,
|
||||
0x61, 0x20, 0x6e, 0x20, 0x5a, 0x76, 0x70, 0x65, 0x62, 0x66, 0x62,
|
||||
0x73, 0x67, 0x20, 0x66, 0x6c, 0x66, 0x67, 0x72, 0x7a, 0x2e, 0x20,
|
||||
0x20, 0x56, 0x27, 0x71, 0x20, 0x65, 0x6e, 0x67, 0x75, 0x72, 0x65,
|
||||
0x20, 0x67, 0x75, 0x6e, 0x67, 0x0a, 0x6c, 0x62, 0x68, 0x20, 0x71,
|
||||
0x76, 0x71, 0x61, 0x27, 0x67, 0x2e, 0x20, 0x20, 0x45, 0x72, 0x7a,
|
||||
0x76, 0x61, 0x71, 0x20, 0x72, 0x6b, 0x72, 0x70, 0x68, 0x67, 0x76,
|
||||
0x62, 0x61, 0x20, 0x6a, 0x76, 0x79, 0x79, 0x20, 0x70, 0x62, 0x61,
|
||||
0x67, 0x76, 0x61, 0x68, 0x72, 0x20, 0x7a, 0x62, 0x7a, 0x72, 0x61,
|
||||
0x67, 0x6e, 0x65, 0x76, 0x79, 0x6c, 0x2e, 0x0a, 0x00
|
||||
};
|
||||
|
||||
static void
|
||||
rkrphgvba(int x)
|
||||
{
|
||||
char const *s = (x ? pmsg2 : pmsg1);
|
||||
while(*s) {
|
||||
int c = (int) *s++;
|
||||
c=isalpha(c)?tolower(c)<0x6e?c+13:c-13:c;
|
||||
putchar(c);
|
||||
}
|
||||
sleep(5);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -100,10 +100,10 @@
|
||||
|
||||
#define L_AMPM_OVERRIDE(ampm, hour) ampm = (hour < 12) ? (hour<5) ? " om natten" : " om formiddagen" : (hour > 17) ? " om aftenen" : " om eftermiddagen";
|
||||
#define L_ORDINAL_OVERRIDE plu = ".";
|
||||
#define L_A_OVER sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y);
|
||||
#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y); }
|
||||
#define L_E_OVER sprintf(s, "den %02d%c%02d%c%04d", d, DateSep, m+1, DateSep, y);
|
||||
#define L_F_OVER sprintf(s, "den %02d%c%02d%c%04d", m+1, DateSep, d, DateSep, y);
|
||||
#define L_G_OVER sprintf(s, "%s %s, den %d. %s", L_ON, DayName[jul%7], d, MonthName[m]);
|
||||
#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s %s, den %d. %s", L_ON, DayName[jul%7], d, MonthName[m]); }
|
||||
#define L_H_OVER sprintf(s, "den %02d%c%02d", d, DateSep, m+1);
|
||||
#define L_I_OVER sprintf(s, "den %02d%c%02d", m+1, DateSep, d);
|
||||
#define L_U_OVER L_A_OVER
|
||||
|
||||
@@ -161,26 +161,19 @@
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
#define L_A_OVER sprintf(s, "%s%s %d. %s%s %d", DayName[jul%7], L_ON, d, \
|
||||
MonthName[m], L_PARTIT, y);
|
||||
#define L_C_OVER sprintf(s, "%s%s", DayName[jul%7], L_ON);
|
||||
#define L_E_OVER sprintf(s, "%02d%c%02d%c%04d", d, DateSep, m+1, DateSep, \
|
||||
y);
|
||||
#define L_A_OVER if (altmode == '*') { sprintf(s, "%s %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s%s %d. %s%s %d", DayName[jul%7], L_ON, d, MonthName[m], L_PARTIT, y); }
|
||||
#define L_C_OVER if (altmode == '*') { sprintf(s, "%s", DayName[jul%7]); } else { sprintf(s, "%s%s", DayName[jul%7], L_ON); }
|
||||
#define L_E_OVER sprintf(s, "%02d%c%02d%c%04d", d, DateSep, m+1, DateSep, y);
|
||||
#define L_F_OVER sprintf(s, "%02d%c%02d%c%04d", m+1, DateSep, d, DateSep, y);
|
||||
#define L_G_OVER sprintf(s, "%s%s %d. %s%s", DayName[jul%7], L_ON, d, \
|
||||
MonthName[m], L_PARTIT);
|
||||
#define L_G_OVER if (altmode == '*') { sprintf(s, "%s %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s%s %d. %s%s", DayName[jul%7], L_ON, d, MonthName[m], L_PARTIT); }
|
||||
#define L_H_OVER sprintf(s, "%02d%c%02d", d, DateSep, m+1);
|
||||
#define L_I_OVER sprintf(s, "%02d%c%02d", m+1, DateSep, d);
|
||||
#define L_J_OVER sprintf(s, "%s%s %sn %d%s %d", DayName[jul%7], L_ON, \
|
||||
MonthName[m], d, plu, y);
|
||||
#define L_K_OVER sprintf(s, "%s%s %sn %d%s", DayName[jul%7], L_ON, \
|
||||
MonthName[m], d, plu);
|
||||
#define L_J_OVER if (altmode == '*') { sprintf(s, "%s %sn %d%s %d", DayName[jul%7], MonthName[m], d, plu, y); } else { sprintf(s, "%s%s %sn %d%s %d", DayName[jul%7], L_ON, MonthName[m], d, plu, y); }
|
||||
#define L_K_OVER if (altmode == '*') { sprintf(s, "%s %sn %d%s", DayName[jul%7], MonthName[m], d, plu); } else { sprintf(s, "%s%s %sn %d%s", DayName[jul%7], L_ON, MonthName[m], d, plu); }
|
||||
#define L_L_OVER sprintf(s, "%04d%c%02d%c%02d", y, DateSep, m+1, DateSep, d);
|
||||
#define L_Q_OVER sprintf(s, "n");
|
||||
#define L_U_OVER sprintf(s, "%s%s %d%s %s%s %d", DayName[jul%7], L_ON, \
|
||||
d, plu, MonthName[m], L_PARTIT, y);
|
||||
#define L_V_OVER sprintf(s, "%s%s %d%s %s%s", DayName[jul%7], L_ON, d, \
|
||||
plu, MonthName[m], L_PARTIT);
|
||||
#define L_U_OVER if (altmode == '*') { sprintf(s, "%s %d%s %s %d", DayName[jul%7], d, plu, MonthName[m], y); } else { sprintf(s, "%s%s %d%s %s%s %d", DayName[jul%7], L_ON, d, plu, MonthName[m], L_PARTIT, y); }
|
||||
#define L_V_OVER if (altmode == '*') { sprintf(s, "%s %d%s %s", DayName[jul%7], d, plu, MonthName[m]); } else { sprintf(s, "%s%s %d%s %s%s", DayName[jul%7], L_ON, d, plu, MonthName[m], L_PARTIT); }
|
||||
#define L_1_OVER \
|
||||
if (tdiff == 0) \
|
||||
sprintf(s, "%s", L_NOW); \
|
||||
@@ -280,7 +273,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Peruutusarvo annettu kahdesti",
|
||||
"ONCE-avainsanaa k\xE4ytetty kahdesti. (Hah.)",
|
||||
"AT-sanan per\xE4st\xE4 puuttuu aika",
|
||||
"UNTIL-sanaa k\xE4ytetty kahdesti",
|
||||
"THROUGH/UNTIL-sanaa k\xE4ytetty kahdesti",
|
||||
"Ep\xE4t\xE4ydellinen p\xE4iv\xE4ys",
|
||||
"FROM/SCANFROM-sanaa k\xE4ytetty kahdesti",
|
||||
"Muuttuja",
|
||||
@@ -384,7 +377,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Peruutusarvo annettu kahdesti",
|
||||
"ONCE-avainsanaa k\x84ytetty kahdesti. (Hah.)",
|
||||
"AT-sanan per\x84st\x84 puuttuu aika",
|
||||
"UNTIL-sanaa k\x84ytetty kahdesti",
|
||||
"THROUGH/UNTIL-sanaa k\x84ytetty kahdesti",
|
||||
"Ep\x84t\x84ydellinen p\x84iv\x84ys",
|
||||
"FROM/SCANFROM-sanaa k\x84ytetty kahdesti",
|
||||
"Muuttuja",
|
||||
@@ -488,7 +481,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Peruutusarvo annettu kahdesti",
|
||||
"ONCE-avainsanaa k{ytetty kahdesti. (Hah.)",
|
||||
"AT-sanan per{st{ puuttuu aika",
|
||||
"UNTIL-sanaa k{ytetty kahdesti",
|
||||
"THROUGH/UNTIL-sanaa k{ytetty kahdesti",
|
||||
"Ep{t{ydellinen p{iv{ys",
|
||||
"FROM/SCANFROM-sanaa k{ytetty kahdesti",
|
||||
"Muuttuja",
|
||||
|
||||
@@ -129,13 +129,9 @@ else if (tdiff < 0) { \
|
||||
sprintf(s, "dans %d heure%s et %d minute%s", hdiff, hplu, mdiff, mplu); \
|
||||
}
|
||||
|
||||
#define L_J_OVER \
|
||||
sprintf(s, "%s %s, %d%s %s, %d", L_ON, DayName[jul%7], \
|
||||
d, plu, MonthName[m], y);
|
||||
#define L_J_OVER if (altmode == '*') { sprintf(s, "%s, %d%s %s, %d", DayName[jul%7], d, plu, MonthName[m], y); } else { sprintf(s, "%s %s, %d%s %s, %d", L_ON, DayName[jul%7], d, plu, MonthName[m], y); }
|
||||
|
||||
#define L_K_OVER \
|
||||
sprintf(s, "%s %s, %d%s %s", L_ON, DayName[jul%7], \
|
||||
d, plu, MonthName[m]);
|
||||
#define L_K_OVER if (altmode == '*') { sprintf(s, "%s, %d%s %s", DayName[jul%7], d, plu, MonthName[m]); } else { sprintf(s, "%s %s, %d%s %s", L_ON, DayName[jul%7], d, plu, MonthName[m]); }
|
||||
|
||||
#endif /* L_IN_DOSUBST */
|
||||
|
||||
@@ -217,7 +213,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Valeur de retour sp\351cifi\351e deux fois",
|
||||
"Mot-cl\351 ONCE utilis\351 deux fois. (Hah.)",
|
||||
"Heure attendue apr\350s AT",
|
||||
"Mot-cl\351 UNTIL utilis\351 deux fois",
|
||||
"Mot-cl\351 THROUGH/UNTIL utilis\351 deux fois",
|
||||
"Sp\351cification de date incompl\350te",
|
||||
"Mot-cl\351 FROM/SCANFROM utilis\351 deux fois",
|
||||
"Variable",
|
||||
@@ -321,7 +317,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Valeur de retour specifiee deux fois",
|
||||
"Mot-cle ONCE utilise deux fois. (Hah.)",
|
||||
"Heure attendue apres AT",
|
||||
"Mot-cle UNTIL utilise deux fois",
|
||||
"Mot-cle THROUGH/UNTIL utilise deux fois",
|
||||
"Specification de date incomplete",
|
||||
"Mot-cle FROM/SCANFROM utilise deux fois",
|
||||
"Variable",
|
||||
|
||||
@@ -93,8 +93,8 @@
|
||||
See the file dosubst.c for more info. */
|
||||
#define L_AMPM_OVERRIDE(ampm, hour) ampm = (hour < 12) ? (hour<5) ? " nachts" : " vormittags" : (hour > 17) ? " abends" : " nachmittags";
|
||||
#define L_ORDINAL_OVERRIDE plu = ".";
|
||||
#define L_A_OVER sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y);
|
||||
#define L_G_OVER sprintf(s, "%s %s, den %d. %s", L_ON, DayName[jul%7], d, MonthName[m]);
|
||||
#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y); }
|
||||
#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s %s, den %d. %s", L_ON, DayName[jul%7], d, MonthName[m]); }
|
||||
#define L_U_OVER L_A_OVER
|
||||
#define L_V_OVER L_G_OVER
|
||||
|
||||
|
||||
@@ -101,8 +101,8 @@
|
||||
/* Define any overrides here, such as L_ORDINAL_OVERRIDE, L_A_OVER, etc.
|
||||
See the file dosubst.c for more info. */
|
||||
#define L_ORDINAL_OVERRIDE plu = ".";
|
||||
#define L_A_OVER sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y);
|
||||
#define L_G_OVER sprintf(s, "%s %s, den %d. %s", L_ON, DayName[jul%7], d, MonthName[m]);
|
||||
#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, den %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y); }
|
||||
#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, den %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s %s, den %d. %s", L_ON, DayName[jul%7], d, MonthName[m]); }
|
||||
#define L_U_OVER L_A_OVER
|
||||
#define L_V_OVER L_G_OVER
|
||||
|
||||
|
||||
@@ -141,8 +141,8 @@ ampm = (hour<12) ? \
|
||||
: " w nocy";
|
||||
#endif
|
||||
#define L_ORDINAL_OVERRIDE plu = "";
|
||||
#define L_A_OVER sprintf(s, "%s %s, %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y);
|
||||
#define L_G_OVER sprintf(s, "%s %s, %d. %s", L_ON, DayName[jul%7], d, MonthName[m]);
|
||||
#define L_A_OVER if (altmode == '*') { sprintf(s, "%s, %d. %s %d", DayName[jul%7], d, MonthName[m], y); } else { sprintf(s, "%s %s, %d. %s %d", L_ON, DayName[jul%7], d, MonthName[m], y); }
|
||||
#define L_G_OVER if (altmode == '*') { sprintf(s, "%s, %d. %s", DayName[jul%7], d, MonthName[m]); } else { sprintf(s, "%s %s, %d. %s", L_ON, DayName[jul%7], d, MonthName[m]); }
|
||||
#define L_U_OVER L_A_OVER
|
||||
#define L_V_OVER L_G_OVER
|
||||
|
||||
@@ -252,7 +252,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Warto\266\346 cofni\352cia podana dw\363krotnie",
|
||||
"S\263owo ONCE u\277yte dw\363krotnie.",
|
||||
"Po AT oczekiwany jest czas",
|
||||
"S\263owo UNTIL u\277yte dw\363krotnie",
|
||||
"S\263owo THROUGH/UNTIL u\277yte dw\363krotnie",
|
||||
"Niekompletna specyfikacja daty",
|
||||
"S\263owo FROM/SCANFROM u\277yte dw\363krotnie",
|
||||
"Zmienna",
|
||||
@@ -355,7 +355,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Wartosc cofniecia podana dwokrotnie",
|
||||
"Slowo ONCE uzyte dwokrotnie.",
|
||||
"Po AT oczekiwany jest czas",
|
||||
"Slowo UNTIL uzyte dwokrotnie",
|
||||
"Slowo THROUGH/UNTIL uzyte dwokrotnie",
|
||||
"Niekompletna specyfikacja daty",
|
||||
"Slowo FROM/SCANFROM uzyte dwokrotnie",
|
||||
"Zmienna",
|
||||
|
||||
@@ -218,7 +218,7 @@ EXTERN char *ErrMsg[] =
|
||||
"Valor de Back especificado duas vezes",
|
||||
"ONCE usado duas vezes (Eheheh)",
|
||||
"Esperando hora apos AT",
|
||||
"Keyword UNTIL usada duas vezes",
|
||||
"Keyword THROUGH/UNTIL usada duas vezes",
|
||||
"Especificacao de data incompleta",
|
||||
"Keyword FROM/SCANFROM usada duas vezes",
|
||||
"Variavel",
|
||||
|
||||
137
src/main.c
137
src/main.c
@@ -7,7 +7,7 @@
|
||||
/* */
|
||||
/* This file is part of REMIND. */
|
||||
/* Copyright (C) 1992-1998 by David F. Skoll */
|
||||
/* Copyright (C) 1999-2000 by Roaring Penguin Software Inc. */
|
||||
/* Copyright (C) 1999-2011 by Roaring Penguin Software Inc. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
@@ -57,6 +60,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int pid;
|
||||
|
||||
#ifdef HAVE_SETLOCALE
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
|
||||
/* The very first thing to do is to set up ErrFp to be stderr */
|
||||
ErrFp = stderr;
|
||||
|
||||
@@ -70,6 +77,12 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Are we purging old reminders? Then just run through the loop once! */
|
||||
if (PurgeMode) {
|
||||
DoReminders();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Not doing a calendar. Do the regular remind loop */
|
||||
ShouldCache = (Iterations > 1);
|
||||
|
||||
@@ -123,6 +136,17 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PurgeEchoLine(char const *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
va_start(argptr, fmt);
|
||||
if (PurgeFP != NULL) {
|
||||
(void) vfprintf(PurgeFP, fmt, argptr);
|
||||
}
|
||||
va_end(argptr);
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* DoReminders */
|
||||
@@ -136,6 +160,7 @@ static void DoReminders(void)
|
||||
Token tok;
|
||||
char const *s;
|
||||
Parser p;
|
||||
int purge_handled;
|
||||
|
||||
if (!UseStdin) {
|
||||
FileAccessDate = GetAccessDate(InitialFile);
|
||||
@@ -173,23 +198,40 @@ static void DoReminders(void)
|
||||
ShouldIgnoreLine())
|
||||
{
|
||||
/*** IGNORE THE LINE ***/
|
||||
if (PurgeMode) {
|
||||
if (strncmp(CurLine, "#!P", 3)) {
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
purge_handled = 0;
|
||||
/* Create a parser to parse the line */
|
||||
CreateParser(s, &p);
|
||||
switch(tok.type) {
|
||||
|
||||
case T_Empty:
|
||||
case T_Comment:
|
||||
if (!strncmp(CurLine, "#!P", 3)) {
|
||||
purge_handled = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case T_Rem: r=DoRem(&p); break;
|
||||
case T_Rem: r=DoRem(&p); purge_handled = 1; break;
|
||||
case T_ErrMsg: r=DoErrMsg(&p); break;
|
||||
case T_If: r=DoIf(&p); break;
|
||||
case T_IfTrig: r=DoIfTrig(&p); break;
|
||||
case T_Else: r=DoElse(&p); break;
|
||||
case T_EndIf: r=DoEndif(&p); break;
|
||||
case T_Include: r=DoInclude(&p); break;
|
||||
case T_Include:
|
||||
/* In purge mode, include closes file, so we
|
||||
need to echo it here! */
|
||||
if (PurgeMode) {
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
}
|
||||
r=DoInclude(&p);
|
||||
purge_handled = 1;
|
||||
break;
|
||||
case T_Exit: DoExit(&p); break;
|
||||
case T_Flush: r=DoFlush(&p); break;
|
||||
case T_Set: r=DoSet(&p); break;
|
||||
@@ -204,32 +246,42 @@ static void DoReminders(void)
|
||||
DestroyParser(&p);
|
||||
CreateParser(s, &p);
|
||||
r=DoRem(&p);
|
||||
purge_handled = 1;
|
||||
}
|
||||
break;
|
||||
case T_Pop: r=PopOmitContext(&p); break;
|
||||
case T_Preserve: r=DoPreserve(&p); break;
|
||||
case T_Push: r=PushOmitContext(&p); break;
|
||||
case T_RemType: if (tok.val == RUN_TYPE) {
|
||||
r=DoRun(&p);
|
||||
r=DoRun(&p);
|
||||
} else {
|
||||
CreateParser(CurLine, &p);
|
||||
r=DoRem(&p);
|
||||
purge_handled = 1;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
CreateParser(CurLine, &p);
|
||||
r=DoRem(&p);
|
||||
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. */
|
||||
|
||||
default: CreateParser(CurLine, &p); r=DoRem(&p); break;
|
||||
default: CreateParser(CurLine, &p); purge_handled = 1; r=DoRem(&p); break;
|
||||
|
||||
}
|
||||
if (r && (!Hush || r != E_RUN_DISABLED)) {
|
||||
Eprint("%s", ErrMsg[r]);
|
||||
}
|
||||
|
||||
if (PurgeMode) {
|
||||
if (!purge_handled) {
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
} else {
|
||||
if (r) {
|
||||
PurgeEchoLine("#!P! Could not parse next line: %s\n", ErrMsg[r]);
|
||||
PurgeEchoLine("%s\n", CurLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Destroy the parser - free up resources it may be tying up */
|
||||
DestroyParser(&p);
|
||||
}
|
||||
@@ -347,7 +399,7 @@ int ParseChar(ParsePtr p, int *err, int peek)
|
||||
}
|
||||
p->expr_happened = 1;
|
||||
p->pos++;
|
||||
r = EvalExpr(&(p->pos), &val);
|
||||
r = EvalExpr(&(p->pos), &val, p);
|
||||
if (r) {
|
||||
*err = r;
|
||||
DestroyParser(p);
|
||||
@@ -383,7 +435,7 @@ int ParseNonSpaceChar(ParsePtr p, int *err, int peek)
|
||||
ch = ParseChar(p, err, 1);
|
||||
if (*err) return 0;
|
||||
|
||||
while (isspace(ch)) {
|
||||
while (isempty(ch)) {
|
||||
ParseChar(p, err, 0); /* Guaranteed to work */
|
||||
ch = ParseChar(p, err, 1);
|
||||
if (*err) return 0;
|
||||
@@ -407,12 +459,12 @@ int ParseToken(ParsePtr p, DynamicBuffer *dbuf)
|
||||
|
||||
c = ParseChar(p, &err, 0);
|
||||
if (err) return err;
|
||||
while (c && isspace(c)) {
|
||||
while (c && isempty(c)) {
|
||||
c = ParseChar(p, &err, 0);
|
||||
if (err) return err;
|
||||
}
|
||||
if (!c) return OK;
|
||||
while (c && !isspace(c)) {
|
||||
while (c && !isempty(c)) {
|
||||
if (DBufPutc(dbuf, c) != OK) {
|
||||
DBufFree(dbuf);
|
||||
return E_NO_MEM;
|
||||
@@ -443,7 +495,7 @@ int ParseIdentifier(ParsePtr p, DynamicBuffer *dbuf)
|
||||
|
||||
c = ParseChar(p, &err, 0);
|
||||
if (err) return err;
|
||||
while (c && isspace(c)) {
|
||||
while (c && isempty(c)) {
|
||||
c = ParseChar(p, &err, 0);
|
||||
if (err) return err;
|
||||
}
|
||||
@@ -484,13 +536,13 @@ int EvaluateExpr(ParsePtr p, Value *v)
|
||||
int r;
|
||||
|
||||
if (p->isnested) return E_PARSE_ERR; /* Can't nest expressions */
|
||||
while (isspace(*p->pos)) (p->pos)++;
|
||||
while (isempty(*p->pos)) (p->pos)++;
|
||||
if (!p->pos) return E_PARSE_ERR; /* Missing expression */
|
||||
if (*p->pos == BEG_OF_EXPR) {
|
||||
(p->pos)++;
|
||||
bracketed = 1;
|
||||
}
|
||||
r = EvalExpr(&(p->pos), v);
|
||||
r = EvalExpr(&(p->pos), v, p);
|
||||
if (r) return r;
|
||||
if (bracketed) {
|
||||
if (*p->pos != END_OF_EXPR) return E_MISS_END;
|
||||
@@ -567,6 +619,7 @@ void CreateParser(char const *s, ParsePtr p)
|
||||
p->allownested = 1;
|
||||
p->tokenPushed = NULL;
|
||||
p->expr_happened = 0;
|
||||
p->nonconst_expr = 0;
|
||||
DBufInit(&p->pushedToken);
|
||||
}
|
||||
|
||||
@@ -670,10 +723,15 @@ int DoIf(ParsePtr p)
|
||||
Eprint("%s", ErrMsg[r]);
|
||||
} else
|
||||
if ( (v.type != STR_TYPE && v.v.val) ||
|
||||
(v.type == STR_TYPE && strcmp(v.v.str, "")) )
|
||||
(v.type == STR_TYPE && strcmp(v.v.str, "")) ) {
|
||||
syndrome = IF_TRUE | BEFORE_ELSE;
|
||||
else
|
||||
} else {
|
||||
syndrome = IF_FALSE | BEFORE_ELSE;
|
||||
if (PurgeMode) {
|
||||
PurgeEchoLine("%s\n", "#!P: The next IF evaluated false...");
|
||||
PurgeEchoLine("%s\n", "#!P: REM statements in IF block not checked for purging.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NumIfs++;
|
||||
@@ -693,6 +751,8 @@ int DoElse(ParsePtr p)
|
||||
{
|
||||
unsigned syndrome;
|
||||
|
||||
int was_ignoring = ShouldIgnoreLine();
|
||||
|
||||
if (!NumIfs) return E_ELSE_NO_IF;
|
||||
|
||||
syndrome = IfFlags >> (2 * NumIfs - 2);
|
||||
@@ -700,6 +760,10 @@ int DoElse(ParsePtr p)
|
||||
if ((syndrome & IF_ELSE_MASK) == AFTER_ELSE) return E_ELSE_NO_IF;
|
||||
|
||||
IfFlags |= AFTER_ELSE << (2 * NumIfs - 2);
|
||||
if (PurgeMode && ShouldIgnoreLine() && !was_ignoring) {
|
||||
PurgeEchoLine("%s\n", "#!P: The previous IF evaluated true.");
|
||||
PurgeEchoLine("%s\n", "#!P: REM statements in ELSE block not checked for purging");
|
||||
}
|
||||
return VerifyEoln(p);
|
||||
}
|
||||
|
||||
@@ -739,11 +803,17 @@ int DoIfTrig(ParsePtr p)
|
||||
jul = ComputeTrigger(trig.scanfrom, &trig, &r, 1);
|
||||
if (r) syndrome = IF_TRUE | BEFORE_ELSE;
|
||||
else {
|
||||
if (ShouldTriggerReminder(&trig, &tim, jul, &err))
|
||||
if (ShouldTriggerReminder(&trig, &tim, jul, &err)) {
|
||||
syndrome = IF_TRUE | BEFORE_ELSE;
|
||||
else
|
||||
} else {
|
||||
syndrome = IF_FALSE | BEFORE_ELSE;
|
||||
if (PurgeMode) {
|
||||
PurgeEchoLine("%s\n", "#!P: The next IFTRIG did not trigger.");
|
||||
PurgeEchoLine("%s\n", "#!P: REM statements in IFTRIG block not checked for purging.");
|
||||
}
|
||||
}
|
||||
}
|
||||
FreeTrig(&trig);
|
||||
}
|
||||
NumIfs++;
|
||||
IfFlags &= ~(IF_MASK << (2*NumIfs - 2));
|
||||
@@ -889,7 +959,7 @@ int DoBanner(ParsePtr p)
|
||||
DBufInit(&buf);
|
||||
c = ParseChar(p, &err, 0);
|
||||
if (err) return err;
|
||||
while (isspace(c)) {
|
||||
while (isempty(c)) {
|
||||
c = ParseChar(p, &err, 0);
|
||||
if (err) return err;
|
||||
}
|
||||
@@ -969,6 +1039,8 @@ void DoExit(ParsePtr p)
|
||||
int r;
|
||||
Value v;
|
||||
|
||||
if (PurgeMode) return;
|
||||
|
||||
r = EvaluateExpr(p, &v);
|
||||
if (r || v.type != INT_TYPE) exit(99);
|
||||
exit(v.v.val);
|
||||
@@ -990,6 +1062,8 @@ int DoErrMsg(ParsePtr p)
|
||||
|
||||
DynamicBuffer buf;
|
||||
|
||||
if (PurgeMode) return OK;
|
||||
|
||||
DBufInit(&buf);
|
||||
t.typ = MSG_TYPE;
|
||||
tt.ttime = SystemTime(0) / 60;
|
||||
@@ -997,7 +1071,7 @@ int DoErrMsg(ParsePtr p)
|
||||
return r;
|
||||
}
|
||||
s = DBufValue(&buf);
|
||||
while (isspace(*s)) s++;
|
||||
while (isempty(*s)) s++;
|
||||
fprintf(ErrFp, "%s\n", s);
|
||||
DBufFree(&buf);
|
||||
return OK;
|
||||
@@ -1233,3 +1307,18 @@ void SigIntHandler(int d)
|
||||
GotSigInt();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
AppendTag(DynamicBuffer *buf, char const *s)
|
||||
{
|
||||
if (*(DBufValue(buf))) {
|
||||
DBufPutc(buf, ',');
|
||||
}
|
||||
DBufPuts(buf, s);
|
||||
}
|
||||
|
||||
void
|
||||
FreeTrig(Trigger *t)
|
||||
{
|
||||
DBufFree(&(t->tags));
|
||||
}
|
||||
|
||||
150
src/omit.c
150
src/omit.c
@@ -125,7 +125,7 @@ int PushOmitContext(ParsePtr p)
|
||||
free(context);
|
||||
return E_NO_MEM;
|
||||
}
|
||||
|
||||
|
||||
/* Copy the context over */
|
||||
for (i=0; i<NumFullOmits; i++)
|
||||
*(context->fullsave + i) = FullOmitArray[i];
|
||||
@@ -198,7 +198,7 @@ int IsOmitted(int jul, int localomit, char const *omitfunc, int *omit)
|
||||
sprintf(expr, "%s('%04d-%02d-%02d')",
|
||||
omitfunc, y, m+1, d);
|
||||
s = expr;
|
||||
r = EvalExpr(&s, &v);
|
||||
r = EvalExpr(&s, &v, NULL);
|
||||
if (r) return r;
|
||||
if (v.type == INT_TYPE && v.v.val != 0) {
|
||||
*omit = 1;
|
||||
@@ -272,6 +272,9 @@ static void InsertIntoSortedArray(int *array, int num, int key)
|
||||
*cur = key;
|
||||
}
|
||||
|
||||
static int DoThroughOmit(ParsePtr p, int y, int m, int d);
|
||||
static void DumpOmits(void);
|
||||
|
||||
/***************************************************************/
|
||||
/* */
|
||||
/* DoOmit */
|
||||
@@ -285,15 +288,33 @@ int DoOmit(ParsePtr p)
|
||||
Token tok;
|
||||
int parsing=1;
|
||||
int syndrome;
|
||||
int not_first_token = -1;
|
||||
|
||||
DynamicBuffer buf;
|
||||
DBufInit(&buf);
|
||||
|
||||
/* Parse the OMIT. We need a month and day; year is optional. */
|
||||
while(parsing) {
|
||||
not_first_token++;
|
||||
if ( (r=ParseToken(p, &buf)) ) return r;
|
||||
FindToken(DBufValue(&buf), &tok);
|
||||
switch (tok.type) {
|
||||
case T_Dumpvars:
|
||||
if (not_first_token) return E_PARSE_ERR;
|
||||
DBufFree(&buf);
|
||||
r = VerifyEoln(p);
|
||||
if (r != OK) return r;
|
||||
DumpOmits();
|
||||
return OK;
|
||||
|
||||
case T_Date:
|
||||
DBufFree(&buf);
|
||||
if (y != NO_YR) return E_YR_TWICE;
|
||||
if (m != NO_MON) return E_MON_TWICE;
|
||||
if (d != NO_DAY) return E_DAY_TWICE;
|
||||
FromJulian(tok.val, &y, &m, &d);
|
||||
break;
|
||||
|
||||
case T_Year:
|
||||
DBufFree(&buf);
|
||||
if (y != NO_YR) return E_YR_TWICE;
|
||||
@@ -311,11 +332,16 @@ int DoOmit(ParsePtr p)
|
||||
if (d != NO_DAY) return E_DAY_TWICE;
|
||||
d = tok.val;
|
||||
break;
|
||||
|
||||
|
||||
case T_Delta:
|
||||
DBufFree(&buf);
|
||||
break;
|
||||
|
||||
case T_Through:
|
||||
DBufFree(&buf);
|
||||
if (y == NO_YR || m == NO_MON || d == NO_DAY) return E_INCOMPLETE;
|
||||
return DoThroughOmit(p, y, m, d);
|
||||
|
||||
case T_Empty:
|
||||
case T_Comment:
|
||||
case T_RemType:
|
||||
@@ -354,7 +380,123 @@ int DoOmit(ParsePtr p)
|
||||
NumFullOmits++;
|
||||
}
|
||||
}
|
||||
if (tok.type == T_RemType || tok.type == T_Priority) return E_PARSE_AS_REM;
|
||||
if (tok.type == T_Tag || tok.type == T_Duration || tok.type == T_RemType || tok.type == T_Priority) return E_PARSE_AS_REM;
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
DoThroughOmit(ParsePtr p, int ystart, int mstart, int dstart)
|
||||
{
|
||||
int yend = NO_YR, mend = NO_MON, dend = NO_DAY, r;
|
||||
int start, end, tmp;
|
||||
int parsing = 1;
|
||||
|
||||
Token tok;
|
||||
|
||||
DynamicBuffer buf;
|
||||
DBufInit(&buf);
|
||||
|
||||
while(parsing) {
|
||||
if ( (r=ParseToken(p, &buf)) ) return r;
|
||||
FindToken(DBufValue(&buf), &tok);
|
||||
|
||||
switch(tok.type) {
|
||||
case T_Date:
|
||||
DBufFree(&buf);
|
||||
if (yend != NO_YR) return E_YR_TWICE;
|
||||
if (mend != NO_MON) return E_MON_TWICE;
|
||||
if (dend != NO_DAY) return E_DAY_TWICE;
|
||||
FromJulian(tok.val, ¥d, &mend, &dend);
|
||||
break;
|
||||
|
||||
case T_Year:
|
||||
DBufFree(&buf);
|
||||
if (yend != NO_YR) return E_YR_TWICE;
|
||||
yend = tok.val;
|
||||
break;
|
||||
|
||||
case T_Month:
|
||||
DBufFree(&buf);
|
||||
if (mend != NO_MON) return E_MON_TWICE;
|
||||
mend = tok.val;
|
||||
break;
|
||||
|
||||
case T_Day:
|
||||
DBufFree(&buf);
|
||||
if (dend != NO_DAY) return E_DAY_TWICE;
|
||||
dend = tok.val;
|
||||
break;
|
||||
|
||||
case T_Empty:
|
||||
case T_Comment:
|
||||
case T_RemType:
|
||||
case T_Priority:
|
||||
case T_Tag:
|
||||
case T_Duration:
|
||||
DBufFree(&buf);
|
||||
parsing = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
Eprint("%s: `%s' (OMIT)", ErrMsg[E_UNKNOWN_TOKEN],
|
||||
DBufValue(&buf));
|
||||
DBufFree(&buf);
|
||||
return E_UNKNOWN_TOKEN;
|
||||
|
||||
}
|
||||
}
|
||||
if (yend == NO_YR || mend == NO_MON || dend == NO_DAY) return E_INCOMPLETE;
|
||||
if (dend > DaysInMonth(mend, yend)) return E_BAD_DATE;
|
||||
if (dstart > DaysInMonth(mstart, ystart)) return E_BAD_DATE;
|
||||
|
||||
start = Julian(ystart, mstart, dstart);
|
||||
end = Julian(yend, mend, dend);
|
||||
|
||||
if (end < start) {
|
||||
tmp = start;
|
||||
start = end;
|
||||
end = tmp;
|
||||
}
|
||||
|
||||
tmp = end - start + 1;
|
||||
|
||||
/* Don't create any OMITs if there would be too many. */
|
||||
if (NumFullOmits + tmp >= MAX_FULL_OMITS) return E_2MANY_FULL;
|
||||
for (tmp = start; tmp <= end; tmp++) {
|
||||
if (!BexistsIntArray(FullOmitArray, NumFullOmits, tmp)) {
|
||||
InsertIntoSortedArray(FullOmitArray, NumFullOmits, tmp);
|
||||
NumFullOmits++;
|
||||
}
|
||||
}
|
||||
if (tok.type == T_Tag || tok.type == T_Duration || tok.type == T_RemType || tok.type == T_Priority) return E_PARSE_AS_REM;
|
||||
return OK;
|
||||
}
|
||||
|
||||
void
|
||||
DumpOmits(void)
|
||||
{
|
||||
int i;
|
||||
int y, m, d;
|
||||
printf("Global Full OMITs (%d of maximum allowed %d):\n", NumFullOmits, MAX_FULL_OMITS);
|
||||
if (!NumFullOmits) {
|
||||
printf("\tNone.\n");
|
||||
} else {
|
||||
for (i=0; i<NumFullOmits; i++) {
|
||||
FromJulian(FullOmitArray[i], &y, &m, &d);
|
||||
printf("\t%04d%c%02d%c%02d\n",
|
||||
y, DateSep, m+1, DateSep, d);
|
||||
}
|
||||
}
|
||||
printf("Global Partial OMITs (%d of maximum allowed %d):\n", NumPartialOmits, MAX_PARTIAL_OMITS);
|
||||
if (!NumPartialOmits) {
|
||||
printf("\tNone.\n");
|
||||
} else {
|
||||
for (i=0; i<NumPartialOmits; i++) {
|
||||
m = PartialOmitArray[i] >> 5 & 0xf;
|
||||
d = PartialOmitArray[i] & 0x1f;
|
||||
printf("\t%02d%c%02d\n", m+1, DateSep, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
22
src/protos.h
22
src/protos.h
@@ -16,9 +16,12 @@
|
||||
/* Define a general malloc routine for creating pointers to objects */
|
||||
#define NEW(type) (malloc(sizeof(type)))
|
||||
|
||||
/* Characters to ignore */
|
||||
#define isempty(c) (isspace(c) || ((c) == '\\'))
|
||||
|
||||
#include "dynbuf.h"
|
||||
|
||||
int CallUserFunc (char const *name, int nargs);
|
||||
int CallUserFunc (char const *name, int nargs, ParsePtr p);
|
||||
int DoFset (ParsePtr p);
|
||||
void ProduceCalendar (void);
|
||||
char const *SimpleTime (int tim);
|
||||
@@ -31,7 +34,8 @@ int TriggerReminder (ParsePtr p, Trigger *t, TimeTrig *tim, int jul);
|
||||
int ShouldTriggerReminder (Trigger *t, TimeTrig *tim, int jul, int *err);
|
||||
int DoSubst (ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul, int mode);
|
||||
int DoSubstFromString (char const *source, DynamicBuffer *dbuf, int jul, int tim);
|
||||
int EvalExpr (char const **e, Value *v);
|
||||
int ParseLiteralDate (char const **s, int *jul, int *tim);
|
||||
int EvalExpr (char const **e, Value *v, ParsePtr p);
|
||||
int DoCoerce (char type, Value *v);
|
||||
void PrintValue (Value *v, FILE *fp);
|
||||
int CopyValue (Value *dest, const Value *src);
|
||||
@@ -42,7 +46,7 @@ int IncludeFile (char const *fname);
|
||||
int GetAccessDate (char const *file);
|
||||
int SetAccessDate (char const *fname, int jul);
|
||||
int TopLevel (void);
|
||||
int CallFunc (Operator *f, int nargs);
|
||||
int CallFunc (BuiltinFunc *f, int nargs);
|
||||
void InitRemind (int argc, char const *argv[]);
|
||||
void Usage (void);
|
||||
int Julian (int year, int month, int day);
|
||||
@@ -51,7 +55,7 @@ int ParseChar (ParsePtr p, int *err, int peek);
|
||||
int ParseToken (ParsePtr p, DynamicBuffer *dbuf);
|
||||
int ParseIdentifier (ParsePtr p, DynamicBuffer *dbuf);
|
||||
int EvaluateExpr (ParsePtr p, Value *v);
|
||||
int Evaluate (char const **s, Var *locals);
|
||||
int Evaluate (char const **s, Var *locals, ParsePtr p);
|
||||
int FnPopValStack (Value *val);
|
||||
void Eprint (char const *fmt, ...);
|
||||
void OutputLine (FILE *fp);
|
||||
@@ -91,7 +95,7 @@ int StrCmpi (char const *s1, char const *s2);
|
||||
Var *FindVar (char const *str, int create);
|
||||
int DeleteVar (char const *str);
|
||||
int SetVar (char const *str, Value *val);
|
||||
int GetVarValue (char const *str, Value *val, Var *locals);
|
||||
int GetVarValue (char const *str, Value *val, Var *locals, ParsePtr p);
|
||||
int DoSet (Parser *p);
|
||||
int DoUnset (Parser *p);
|
||||
int DoDump (ParsePtr p);
|
||||
@@ -104,7 +108,8 @@ int DoMsgCommand (char const *cmd, char const *msg);
|
||||
int ParseNonSpaceChar (ParsePtr p, int *err, int peek);
|
||||
unsigned int HashVal (char const *str);
|
||||
int DateOK (int y, int m, int d);
|
||||
Operator *FindFunc (char const *name, Operator where[], int num);
|
||||
Operator *FindOperator (char const *name, Operator where[], int num);
|
||||
BuiltinFunc *FindFunc (char const *name, BuiltinFunc where[], int num);
|
||||
int InsertIntoSortBuffer (int jul, int tim, char const *body, int typ, int prio);
|
||||
void IssueSortedReminders (void);
|
||||
int UserFuncExists (char const *fn);
|
||||
@@ -131,4 +136,7 @@ void HuntPhase (int startdate, int starttim, int phas, int *date, int *time);
|
||||
int CompareRems (int dat1, int tim1, int prio1, int dat2, int tim2, int prio2, int bydate, int bytime, int byprio, int untimed_first);
|
||||
void SigIntHandler (int d);
|
||||
void GotSigInt (void);
|
||||
void SynthesizeTag(char *);
|
||||
void PurgeEchoLine(char const *fmt, ...);
|
||||
void FreeTrig(Trigger *t);
|
||||
void AppendTag(DynamicBuffer *buf, char const *s);
|
||||
char const *SynthesizeTag(void);
|
||||
|
||||
28
src/queue.c
28
src/queue.c
@@ -43,7 +43,7 @@ typedef struct queuedrem {
|
||||
char const *text;
|
||||
char passthru[PASSTHRU_LEN+1];
|
||||
char sched[VAR_NAME_LEN+1];
|
||||
char tag[TAG_LEN+1];
|
||||
DynamicBuffer tags;
|
||||
TimeTrig tt;
|
||||
} QueuedRem;
|
||||
|
||||
@@ -96,9 +96,10 @@ int QueueReminder(ParsePtr p, Trigger *trig,
|
||||
qelem->RunDisabled = RunDisabled;
|
||||
qelem->ntrig = 0;
|
||||
strcpy(qelem->sched, sched);
|
||||
strcpy(qelem->tag, trig->tag);
|
||||
if (! *qelem->tag && SynthesizeTags) {
|
||||
SynthesizeTag(qelem->tag);
|
||||
DBufInit(&(qelem->tags));
|
||||
DBufPuts(&(qelem->tags), DBufValue(&(trig->tags)));
|
||||
if (SynthesizeTags) {
|
||||
AppendTag(&(qelem->tags), SynthesizeTag());
|
||||
}
|
||||
QueueHead = qelem;
|
||||
return OK;
|
||||
@@ -235,12 +236,11 @@ void HandleQueuedReminders(void)
|
||||
printf("NOTE reminder %s",
|
||||
SimpleTime(q->tt.ttime));
|
||||
printf("%s", SimpleTime(SystemTime(0)/60));
|
||||
if (!*q->tag) {
|
||||
printf("*");
|
||||
if (!*DBufValue(&q->tags)) {
|
||||
printf("*\n");
|
||||
} else {
|
||||
printf("%s", q->tag);
|
||||
printf("%s\n", DBufValue(&(q->tags)));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* Set up global variables so some functions like trigdate()
|
||||
@@ -411,7 +411,7 @@ static int CalculateNextTimeUsingSched(QueuedRem *q)
|
||||
char exprBuf[VAR_NAME_LEN+32];
|
||||
sprintf(exprBuf, "%s(%d)", q->sched, q->ntrig);
|
||||
s = exprBuf;
|
||||
r = EvalExpr(&s, &v);
|
||||
r = EvalExpr(&s, &v, NULL);
|
||||
if (r) {
|
||||
q->sched[0] = 0;
|
||||
return NO_TIME;
|
||||
@@ -420,7 +420,11 @@ static int CalculateNextTimeUsingSched(QueuedRem *q)
|
||||
ThisTime = v.v.val;
|
||||
} else if (v.type == INT_TYPE) {
|
||||
if (v.v.val > 0)
|
||||
ThisTime = q->tt.nexttime + v.v.val;
|
||||
if (LastTime >= 0) {
|
||||
ThisTime = LastTime + v.v.val;
|
||||
} else {
|
||||
ThisTime = q->tt.nexttime + v.v.val;
|
||||
}
|
||||
else
|
||||
ThisTime = q->tt.ttime + v.v.val;
|
||||
|
||||
@@ -431,6 +435,10 @@ static int CalculateNextTimeUsingSched(QueuedRem *q)
|
||||
}
|
||||
if (ThisTime < 0) ThisTime = 0; /* Can't be less than 00:00 */
|
||||
if (ThisTime > (MINUTES_PER_DAY-1)) ThisTime = (MINUTES_PER_DAY-1); /* or greater than 11:59 */
|
||||
if (DebugFlag & DB_PRTEXPR) {
|
||||
fprintf(ErrFp, "SCHED: Considering %02d%c%02d\n",
|
||||
ThisTime / 60, TimeSep, ThisTime % 60);
|
||||
}
|
||||
if (ThisTime > q->tt.nexttime) return ThisTime;
|
||||
if (ThisTime <= LastTime) {
|
||||
q->sched[0] = 0;
|
||||
|
||||
44
src/rem2ps.c
44
src/rem2ps.c
@@ -28,9 +28,20 @@
|
||||
#define SPECIAL_POSTSCRIPT 1
|
||||
#define SPECIAL_PSFILE 2
|
||||
#define SPECIAL_MOON 3
|
||||
#define SPECIAL_SHADE 4
|
||||
#define SPECIAL_COLOR 5
|
||||
#define SPECIAL_WEEK 6
|
||||
#define SPECIAL_COLOR 4
|
||||
#define SPECIAL_WEEK 5
|
||||
#define SPECIAL_SHADE 6
|
||||
|
||||
/* Array holding how specials sort */
|
||||
static int SpecialSortOrder[] = {
|
||||
0, /* NORMAL */
|
||||
1, /* POSTSCRIPT */
|
||||
1, /* PSFILE */
|
||||
2, /* MOON */
|
||||
0, /* COLOR */
|
||||
4, /* WEEK */
|
||||
5 /* SHADE */
|
||||
};
|
||||
|
||||
typedef struct calentry {
|
||||
struct calentry *next;
|
||||
@@ -186,7 +197,7 @@ void DoPsCal(void)
|
||||
char const *startOfBody;
|
||||
char passthru[PASSTHRU_LEN+1];
|
||||
DynamicBuffer buf;
|
||||
CalEntry *c, *d;
|
||||
CalEntry *c, *d, *p;
|
||||
|
||||
/* Read the month and year name, followed by # days in month and 1st day of
|
||||
month */
|
||||
@@ -336,10 +347,26 @@ void DoPsCal(void)
|
||||
PsEntries[DayNum] = c;
|
||||
} else {
|
||||
d = PsEntries[DayNum];
|
||||
while(d->next) d = d->next;
|
||||
d->next = c;
|
||||
p = NULL;
|
||||
/* Slot it into the right place */
|
||||
while (d->next && (SpecialSortOrder[c->special] <= SpecialSortOrder[d->special])) {
|
||||
p = d;
|
||||
d = d->next;
|
||||
}
|
||||
if (SpecialSortOrder[c->special] <= SpecialSortOrder[d->special]) {
|
||||
c->next = d->next;
|
||||
d->next = c;
|
||||
} else {
|
||||
if (p) {
|
||||
p->next = c;
|
||||
} else {
|
||||
PsEntries[DayNum] = c;
|
||||
}
|
||||
c->next = d;
|
||||
}
|
||||
}
|
||||
} else if (!strcmp(passthru, "*") ||
|
||||
!strcmp(passthru, "COLOUR") ||
|
||||
!strcmp(passthru, "COLOR")) {
|
||||
/* Put on linked list */
|
||||
if (!CurEntries) {
|
||||
@@ -349,7 +376,8 @@ void DoPsCal(void)
|
||||
while(d->next) d = d->next;
|
||||
d->next = c;
|
||||
}
|
||||
if (!strcmp(passthru, "COLOR")) {
|
||||
if (!strcmp(passthru, "COLOR") ||
|
||||
!strcmp(passthru, "COLOUR")) {
|
||||
c->special = SPECIAL_COLOR;
|
||||
}
|
||||
}
|
||||
@@ -744,7 +772,7 @@ void Init(int argc, char *argv[])
|
||||
case 'o':
|
||||
if (i == argc) Usage("Offset must be supplied");
|
||||
offset = atoi(argv[i++]);
|
||||
if (offset < 36) offset = 36;
|
||||
if (offset < 0) offset = 0;
|
||||
if (!*s) Usage("Offset must specify l, r, t or b");
|
||||
while(*s) {
|
||||
switch(*s++) {
|
||||
|
||||
@@ -181,7 +181,7 @@ static void IssueSortBanner(int jul)
|
||||
|
||||
FromJulian(jul, &y, &m, &d);
|
||||
sprintf(BanExpr, "sortbanner('%04d/%02d/%02d')", y, m+1, d);
|
||||
y = EvalExpr(&s, &v);
|
||||
y = EvalExpr(&s, &v, NULL);
|
||||
if (y) return;
|
||||
if (DoCoerce(STR_TYPE, &v)) return;
|
||||
DBufInit(&buf);
|
||||
|
||||
11
src/test-all-languages.sh
Executable file
11
src/test-all-languages.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# Make sure Remind compiles with all supported languages; show
|
||||
# tstlang.rem output for each language.
|
||||
|
||||
ALL=`grep ^#define lang.h | grep -v '#define LANG' | awk '{print $2}'`
|
||||
|
||||
for i in $ALL ; do
|
||||
make clean all LANGDEF=-DLANG=$i || exit 1
|
||||
./remind -q -r ../tests/tstlang.rem
|
||||
done
|
||||
exit 0
|
||||
27
src/token.c
27
src/token.c
@@ -94,6 +94,7 @@ Token TokArray[] = {
|
||||
{ "special", 7, T_RemType, PASSTHRU_TYPE },
|
||||
{ "sunday", 3, T_WkDay, 6 },
|
||||
{ "tag", 3, T_Tag, 0 },
|
||||
{ "through", 7, T_Through, 0 },
|
||||
{ "thursday", 3, T_WkDay, 3 },
|
||||
{ "tuesday", 3, T_WkDay, 1 },
|
||||
{ "unset", 5, T_UnSet, 0 },
|
||||
@@ -146,9 +147,9 @@ char const *FindInitialToken(Token *tok, char const *s)
|
||||
|
||||
tok->type = T_Illegal;
|
||||
|
||||
while (isspace(*s)) s++;
|
||||
while (isempty(*s)) s++;
|
||||
|
||||
while (*s && !isspace(*s)) {
|
||||
while (*s && !isempty(*s)) {
|
||||
if (DBufPutc(&buf, *s++) != OK) return s;
|
||||
}
|
||||
|
||||
@@ -256,12 +257,30 @@ void FindToken(char const *s, Token *tok)
|
||||
void FindNumericToken(char const *s, Token *t)
|
||||
{
|
||||
int mult = 1, hour, min;
|
||||
char const *s_orig = s;
|
||||
|
||||
t->type = T_Illegal;
|
||||
t->val = 0;
|
||||
if (isdigit(*s)) {
|
||||
PARSENUM(t->val, s);
|
||||
|
||||
/* If we hit a '-' or a '/', we may have a date or a datetime */
|
||||
if (*s == '-' || *s == '/') {
|
||||
char const *p = s_orig;
|
||||
int jul, tim;
|
||||
if (ParseLiteralDate(&p, &jul, &tim) == OK) {
|
||||
if (*p) return;
|
||||
if (tim == NO_TIME) {
|
||||
t->type = T_Date;
|
||||
t->val = jul;
|
||||
return;
|
||||
}
|
||||
t->type = T_DateTime;
|
||||
t->val = MINUTES_PER_DAY * jul + tim;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we hit a comma, swallow it. This allows stuff
|
||||
like Jan 6, 1998 */
|
||||
if (*s == ',') {
|
||||
@@ -341,7 +360,7 @@ static int TokStrCmp(Token const *t, char const *s)
|
||||
register int r;
|
||||
char const *tk = t->name;
|
||||
while(*tk && *s && !(*s == ',' && *(s+1) == 0)) {
|
||||
r = *tk - tolower(*s);
|
||||
r = tolower(*tk) - tolower(*s);
|
||||
tk++;
|
||||
s++;
|
||||
if (r) return r;
|
||||
@@ -349,5 +368,5 @@ static int TokStrCmp(Token const *t, char const *s)
|
||||
/* Ignore trailing commas on s */
|
||||
|
||||
if (!*s || (*s == ',' && !*(s+1))) return 0;
|
||||
return (*tk - *s);
|
||||
return (tolower(*tk) - tolower(*s));
|
||||
}
|
||||
|
||||
@@ -301,7 +301,10 @@ static int GetNextTriggerDate(Trigger *trig, int start, int *err, int *nextstart
|
||||
|
||||
/* First: Have we passed the UNTIL date? */
|
||||
if (trig->until != NO_UNTIL &&
|
||||
trig->until < start) return -1; /* expired */
|
||||
trig->until < start) {
|
||||
trig->expired = 1;
|
||||
return -1; /* expired */
|
||||
}
|
||||
|
||||
/* Next: If it's an "AFTER"-type skip, back up
|
||||
until we're at the start of a block of holidays */
|
||||
@@ -422,7 +425,10 @@ int ComputeTrigger(int today, Trigger *trig, int *err, int save_in_globals)
|
||||
y, m, d, omit,
|
||||
result;
|
||||
|
||||
if (save_in_globals) LastTrigValid = 0;
|
||||
trig->expired = 0;
|
||||
if (save_in_globals) {
|
||||
LastTrigValid = 0;
|
||||
}
|
||||
|
||||
/* Assume everything works */
|
||||
*err = OK;
|
||||
@@ -449,6 +455,7 @@ int ComputeTrigger(int today, Trigger *trig, int *err, int save_in_globals)
|
||||
/* If there's an error, die immediately */
|
||||
if (*err) return -1;
|
||||
if (result == -1) {
|
||||
trig->expired = 1;
|
||||
if (DebugFlag & DB_PRTTRIG) {
|
||||
fprintf(ErrFp, "%s(%d): %s\n",
|
||||
FileName, LineNo, ErrMsg[E_EXPIRED]);
|
||||
@@ -485,6 +492,7 @@ int ComputeTrigger(int today, Trigger *trig, int *err, int save_in_globals)
|
||||
if (trig->back == NO_BACK &&
|
||||
trig->skip == NO_SKIP &&
|
||||
trig->rep == NO_REP) {
|
||||
trig->expired = 1;
|
||||
if (DebugFlag & DB_PRTTRIG) {
|
||||
fprintf(ErrFp, "%s(%d): %s\n",
|
||||
FileName, LineNo, ErrMsg[E_EXPIRED]);
|
||||
@@ -513,6 +521,7 @@ int ComputeTrigger(int today, Trigger *trig, int *err, int save_in_globals)
|
||||
LastTrigValid = 1;
|
||||
}
|
||||
}
|
||||
trig->expired = 1;
|
||||
if (DebugFlag & DB_PRTTRIG) {
|
||||
fprintf(ErrFp, "%s(%d): %s\n",
|
||||
FileName, LineNo, ErrMsg[E_EXPIRED]);
|
||||
|
||||
24
src/types.h
24
src/types.h
@@ -30,6 +30,21 @@ typedef struct {
|
||||
int (*func)(void);
|
||||
} Operator;
|
||||
|
||||
/* Structure for passing in Nargs and out RetVal from functions */
|
||||
typedef struct {
|
||||
int nargs;
|
||||
Value retval;
|
||||
} func_info;
|
||||
|
||||
/* Define the type of user-functions */
|
||||
typedef struct {
|
||||
char const *name;
|
||||
char minargs;
|
||||
char maxargs;
|
||||
char is_constant;
|
||||
int (*func)(func_info *);
|
||||
} BuiltinFunc;
|
||||
|
||||
/* Define the structure of a variable */
|
||||
typedef struct var {
|
||||
struct var *next;
|
||||
@@ -40,6 +55,7 @@ typedef struct var {
|
||||
|
||||
/* A trigger */
|
||||
typedef struct {
|
||||
int expired;
|
||||
int wd;
|
||||
int d;
|
||||
int m;
|
||||
@@ -57,7 +73,7 @@ typedef struct {
|
||||
char sched[VAR_NAME_LEN+1]; /* Scheduling function */
|
||||
char warn[VAR_NAME_LEN+1]; /* Warning function */
|
||||
char omitfunc[VAR_NAME_LEN+1]; /* OMITFUNC function */
|
||||
char tag[TAG_LEN+1];
|
||||
DynamicBuffer tags;
|
||||
char passthru[PASSTHRU_LEN+1];
|
||||
} Trigger;
|
||||
|
||||
@@ -81,6 +97,7 @@ typedef struct {
|
||||
DynamicBuffer pushedToken; /* Pushed-back token */
|
||||
char const *tokenPushed; /* NULL if no pushed-back token */
|
||||
char expr_happened; /* Did we encounter an [expression] ? */
|
||||
char nonconst_expr; /* Did we encounter a non-constant [expression] ? */
|
||||
} Parser;
|
||||
|
||||
typedef Parser *ParsePtr; /* Pointer to parser structure */
|
||||
@@ -133,7 +150,7 @@ enum TokTypes
|
||||
T_IfTrig, T_ErrMsg,
|
||||
T_Set, T_UnSet, T_Fset, T_Omit, T_Banner, T_Exit,
|
||||
T_WkDay,
|
||||
T_Month, T_Time,
|
||||
T_Month, T_Time, T_Date, T_DateTime,
|
||||
T_Skip, T_At, T_RemType, T_Until, T_Year, T_Day, T_Rep, T_Delta, T_Back,
|
||||
T_Once,
|
||||
T_Empty,
|
||||
@@ -150,7 +167,8 @@ enum TokTypes
|
||||
T_Tag,
|
||||
T_Duration,
|
||||
T_LongTime,
|
||||
T_OmitFunc
|
||||
T_OmitFunc,
|
||||
T_Through
|
||||
};
|
||||
|
||||
/* The structure of a token */
|
||||
|
||||
@@ -40,7 +40,7 @@ static UserFunc *FuncHash[FUNC_HASH_SIZE];
|
||||
|
||||
/* Access to built-in functions */
|
||||
extern int NumFuncs;
|
||||
extern Operator Func[];
|
||||
extern BuiltinFunc Func[];
|
||||
|
||||
/* We need access to the expression evaluation stack */
|
||||
extern Value ValStack[];
|
||||
@@ -243,7 +243,7 @@ static void FSet(UserFunc *f)
|
||||
/* Call a user-defined function. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int CallUserFunc(char const *name, int nargs)
|
||||
int CallUserFunc(char const *name, int nargs, ParsePtr p)
|
||||
{
|
||||
UserFunc *f;
|
||||
int h = HashVal(name) % FUNC_HASH_SIZE;
|
||||
@@ -299,9 +299,9 @@ int CallUserFunc(char const *name, int nargs)
|
||||
s = f->text;
|
||||
|
||||
/* Skip the opening bracket, if there's one */
|
||||
while (isspace(*s)) s++;
|
||||
while (isempty(*s)) s++;
|
||||
if (*s == BEG_OF_EXPR) s++;
|
||||
h = Evaluate(&s, f->locals);
|
||||
h = Evaluate(&s, f->locals, p);
|
||||
f->IsActive = 0;
|
||||
DestroyLocalVals(f);
|
||||
if (DebugFlag &DB_PRTEXPR) {
|
||||
|
||||
213
src/var.c
213
src/var.c
@@ -36,6 +36,110 @@ static Var *VHashTbl[VAR_HASH_SIZE];
|
||||
|
||||
typedef int (*SysVarFunc)(int, Value *);
|
||||
|
||||
static int trig_date_func(int do_set, Value *val)
|
||||
{
|
||||
val->type = DATE_TYPE;
|
||||
if (!LastTrigValid) {
|
||||
val->v.val = 0;
|
||||
} else {
|
||||
val->v.val = LastTriggerDate;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
static int trig_day_func(int do_set, Value *val)
|
||||
{
|
||||
int y, m, d;
|
||||
val->type = INT_TYPE;
|
||||
if (!LastTrigValid) {
|
||||
val->v.val = -1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
FromJulian(LastTriggerDate, &y, &m, &d);
|
||||
val->v.val = d;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int trig_mon_func(int do_set, Value *val)
|
||||
{
|
||||
int y, m, d;
|
||||
val->type = INT_TYPE;
|
||||
if (!LastTrigValid) {
|
||||
val->v.val = -1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
FromJulian(LastTriggerDate, &y, &m, &d);
|
||||
val->v.val = m+1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int trig_year_func(int do_set, Value *val)
|
||||
{
|
||||
int y, m, d;
|
||||
val->type = INT_TYPE;
|
||||
if (!LastTrigValid) {
|
||||
val->v.val = -1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
FromJulian(LastTriggerDate, &y, &m, &d);
|
||||
val->v.val = y;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int trig_wday_func(int do_set, Value *val)
|
||||
{
|
||||
val->type = INT_TYPE;
|
||||
if (!LastTrigValid) {
|
||||
val->v.val = -1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
val->v.val = (LastTriggerDate + 1) % 7;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int today_date_func(int do_set, Value *val)
|
||||
{
|
||||
val->type = DATE_TYPE;
|
||||
val->v.val = JulianToday;
|
||||
return OK;
|
||||
}
|
||||
static int today_day_func(int do_set, Value *val)
|
||||
{
|
||||
int y, m, d;
|
||||
val->type = INT_TYPE;
|
||||
FromJulian(JulianToday, &y, &m, &d);
|
||||
val->v.val = d;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int today_mon_func(int do_set, Value *val)
|
||||
{
|
||||
int y, m, d;
|
||||
val->type = INT_TYPE;
|
||||
FromJulian(JulianToday, &y, &m, &d);
|
||||
val->v.val = m+1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int today_year_func(int do_set, Value *val)
|
||||
{
|
||||
int y, m, d;
|
||||
val->type = INT_TYPE;
|
||||
FromJulian(JulianToday, &y, &m, &d);
|
||||
val->v.val = y;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int today_wday_func(int do_set, Value *val)
|
||||
{
|
||||
val->type = INT_TYPE;
|
||||
val->v.val = (JulianToday + 1) % 7;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int date_sep_func(int do_set, Value *val)
|
||||
{
|
||||
if (!do_set) {
|
||||
@@ -186,7 +290,7 @@ int SetVar(char const *str, Value *val)
|
||||
/* Get a copy of the value of the variable. */
|
||||
/* */
|
||||
/***************************************************************/
|
||||
int GetVarValue(char const *str, Value *val, Var *locals)
|
||||
int GetVarValue(char const *str, Value *val, Var *locals, ParsePtr p)
|
||||
{
|
||||
Var *v;
|
||||
|
||||
@@ -198,6 +302,8 @@ int GetVarValue(char const *str, Value *val, Var *locals)
|
||||
v = v->next;
|
||||
}
|
||||
|
||||
/* Global variable... mark expression as non-constant */
|
||||
if (p) p->nonconst_expr = 1;
|
||||
v=FindVar(str, 0);
|
||||
|
||||
if (!v) {
|
||||
@@ -286,6 +392,8 @@ int DoDump(ParsePtr p)
|
||||
Var *v;
|
||||
DynamicBuffer buf;
|
||||
|
||||
if (PurgeMode) return OK;
|
||||
|
||||
DBufInit(&buf);
|
||||
r = ParseToken(p, &buf);
|
||||
if (r) return r;
|
||||
@@ -462,47 +570,57 @@ typedef struct {
|
||||
|
||||
/* All of the system variables sorted alphabetically */
|
||||
static SysVar SysVarArr[] = {
|
||||
/* name mod type value min/mal max */
|
||||
{ "CalcUTC", 1, INT_TYPE, &CalculateUTC, 0, 1 },
|
||||
{ "CalMode", 0, INT_TYPE, &DoCalendar, 0, 0 },
|
||||
{ "Daemon", 0, INT_TYPE, &Daemon, 0, 0 },
|
||||
{ "DateSep", 1, SPECIAL_TYPE, date_sep_func, 0, 0 },
|
||||
{ "DefaultPrio", 1, INT_TYPE, &DefaultPrio, 0, 9999 },
|
||||
{ "DeltaOffset", 0, INT_TYPE, &DeltaOffset, 0, 0 },
|
||||
{ "DontFork", 0, INT_TYPE, &DontFork, 0, 0 },
|
||||
{ "DontQueue", 0, INT_TYPE, &DontQueue, 0, 0 },
|
||||
{ "DontTrigAts", 0, INT_TYPE, &DontIssueAts, 0, 0 },
|
||||
{ "EndSent", 1, STR_TYPE, &EndSent, 0, 0 },
|
||||
{ "EndSentIg", 1, STR_TYPE, &EndSentIg, 0, 0 },
|
||||
{ "FirstIndent", 1, INT_TYPE, &FirstIndent, 0, 132 },
|
||||
{ "FoldYear", 1, INT_TYPE, &FoldYear, 0, 1 },
|
||||
{ "FormWidth", 1, INT_TYPE, &FormWidth, 20, 132 },
|
||||
{ "HushMode", 0, INT_TYPE, &Hush, 0, 0 },
|
||||
{ "IgnoreOnce", 0, INT_TYPE, &IgnoreOnce, 0, 0 },
|
||||
{ "InfDelta", 0, INT_TYPE, &InfiniteDelta, 0, 0 },
|
||||
{ "LatDeg", 1, INT_TYPE, &LatDeg, -90, 90 },
|
||||
{ "LatMin", 1, INT_TYPE, &LatMin, -59, 59 },
|
||||
{ "LatSec", 1, INT_TYPE, &LatSec, -59, 59 },
|
||||
{ "Location", 1, STR_TYPE, &Location, 0, 0 },
|
||||
{ "LongDeg", 1, INT_TYPE, &LongDeg, -180, 180 },
|
||||
{ "LongMin", 1, INT_TYPE, &LongMin, -59, 59 },
|
||||
{ "LongSec", 1, INT_TYPE, &LongSec, -59, 59 },
|
||||
{ "MaxSatIter", 1, INT_TYPE, &MaxSatIter, 10, ANY },
|
||||
{ "MaxStringLen", 1, INT_TYPE, &MaxStringLen, -1, ANY },
|
||||
{ "MinsFromUTC", 1, INT_TYPE, &MinsFromUTC, -13*60, 13*60 },
|
||||
{ "NextMode", 0, INT_TYPE, &NextMode, 0, 0 },
|
||||
{ "NumQueued", 0, INT_TYPE, &NumQueued, 0, 0 },
|
||||
{ "NumTrig", 0, INT_TYPE, &NumTriggered, 0, 0 },
|
||||
{ "PrefixLineNo", 0, INT_TYPE, &DoPrefixLineNo,0, 0 },
|
||||
{ "PSCal", 0, INT_TYPE, &PsCal, 0, 0 },
|
||||
{ "RunOff", 0, INT_TYPE, &RunDisabled, 0, 0 },
|
||||
{ "SimpleCal", 0, INT_TYPE, &DoSimpleCalendar, 0, 0 },
|
||||
{ "SortByDate", 0, INT_TYPE, &SortByDate, 0, 0},
|
||||
{ "SortByPrio", 0, INT_TYPE, &SortByPrio, 0, 0},
|
||||
{ "SortByTime", 0, INT_TYPE, &SortByTime, 0, 0},
|
||||
{ "SubsIndent", 1, INT_TYPE, &SubsIndent, 0, 132},
|
||||
{ "TimeSep", 1, SPECIAL_TYPE, time_sep_func, 0, 0 },
|
||||
{ "UntimedFirst", 0, INT_TYPE, &UntimedBeforeTimed, 0, 0 }
|
||||
/* name mod type value min/mal max */
|
||||
{"CalcUTC", 1, INT_TYPE, &CalculateUTC, 0, 1 },
|
||||
{"CalMode", 0, INT_TYPE, &DoCalendar, 0, 0 },
|
||||
{"Daemon", 0, INT_TYPE, &Daemon, 0, 0 },
|
||||
{"DateSep", 1, SPECIAL_TYPE, date_sep_func, 0, 0 },
|
||||
{"DefaultPrio", 1, INT_TYPE, &DefaultPrio, 0, 9999},
|
||||
{"DeltaOffset", 0, INT_TYPE, &DeltaOffset, 0, 0 },
|
||||
{"DontFork", 0, INT_TYPE, &DontFork, 0, 0 },
|
||||
{"DontQueue", 0, INT_TYPE, &DontQueue, 0, 0 },
|
||||
{"DontTrigAts", 0, INT_TYPE, &DontIssueAts, 0, 0 },
|
||||
{"EndSent", 1, STR_TYPE, &EndSent, 0, 0 },
|
||||
{"EndSentIg", 1, STR_TYPE, &EndSentIg, 0, 0 },
|
||||
{"FirstIndent", 1, INT_TYPE, &FirstIndent, 0, 132 },
|
||||
{"FoldYear", 1, INT_TYPE, &FoldYear, 0, 1 },
|
||||
{"FormWidth", 1, INT_TYPE, &FormWidth, 20, 132 },
|
||||
{"HushMode", 0, INT_TYPE, &Hush, 0, 0 },
|
||||
{"IgnoreOnce", 0, INT_TYPE, &IgnoreOnce, 0, 0 },
|
||||
{"InfDelta", 0, INT_TYPE, &InfiniteDelta, 0, 0 },
|
||||
{"LatDeg", 1, INT_TYPE, &LatDeg, -90, 90 },
|
||||
{"LatMin", 1, INT_TYPE, &LatMin, -59, 59 },
|
||||
{"LatSec", 1, INT_TYPE, &LatSec, -59, 59 },
|
||||
{"Location", 1, STR_TYPE, &Location, 0, 0 },
|
||||
{"LongDeg", 1, INT_TYPE, &LongDeg, -180, 180 },
|
||||
{"LongMin", 1, INT_TYPE, &LongMin, -59, 59 },
|
||||
{"LongSec", 1, INT_TYPE, &LongSec, -59, 59 },
|
||||
{"MaxSatIter", 1, INT_TYPE, &MaxSatIter, 10, ANY },
|
||||
{"MaxStringLen", 1, INT_TYPE, &MaxStringLen, -1, ANY },
|
||||
{"MinsFromUTC", 1, INT_TYPE, &MinsFromUTC, -780, 780 },
|
||||
{"NextMode", 0, INT_TYPE, &NextMode, 0, 0 },
|
||||
{"NumQueued", 0, INT_TYPE, &NumQueued, 0, 0 },
|
||||
{"NumTrig", 0, INT_TYPE, &NumTriggered, 0, 0 },
|
||||
{"PrefixLineNo", 0, INT_TYPE, &DoPrefixLineNo, 0, 0 },
|
||||
{"PSCal", 0, INT_TYPE, &PsCal, 0, 0 },
|
||||
{"RunOff", 0, INT_TYPE, &RunDisabled, 0, 0 },
|
||||
{"SimpleCal", 0, INT_TYPE, &DoSimpleCalendar, 0, 0 },
|
||||
{"SortByDate", 0, INT_TYPE, &SortByDate, 0, 0 },
|
||||
{"SortByPrio", 0, INT_TYPE, &SortByPrio, 0, 0 },
|
||||
{"SortByTime", 0, INT_TYPE, &SortByTime, 0, 0 },
|
||||
{"SubsIndent", 1, INT_TYPE, &SubsIndent, 0, 132 },
|
||||
{"T", 0, SPECIAL_TYPE, trig_date_func, 0, 0 },
|
||||
{"Td", 0, SPECIAL_TYPE, trig_day_func, 0, 0 },
|
||||
{"TimeSep", 1, SPECIAL_TYPE, time_sep_func, 0, 0 },
|
||||
{"Tm", 0, SPECIAL_TYPE, trig_mon_func, 0, 0 },
|
||||
{"Tw", 0, SPECIAL_TYPE, trig_wday_func, 0, 0 },
|
||||
{"Ty", 0, SPECIAL_TYPE, trig_year_func, 0, 0 },
|
||||
{"U", 0, SPECIAL_TYPE, today_date_func, 0, 0 },
|
||||
{"Ud", 0, SPECIAL_TYPE, today_day_func, 0, 0 },
|
||||
{"Um", 0, SPECIAL_TYPE, today_mon_func, 0, 0 },
|
||||
{"UntimedFirst", 0, INT_TYPE, &UntimedBeforeTimed, 0, 0 },
|
||||
{"Uw", 0, SPECIAL_TYPE, today_wday_func, 0, 0 },
|
||||
{"Uy", 0, SPECIAL_TYPE, today_year_func, 0, 0 }
|
||||
};
|
||||
|
||||
#define NUMSYSVARS ( sizeof(SysVarArr) / sizeof(SysVar) )
|
||||
@@ -646,9 +764,8 @@ static void DumpSysVar(char const *name, const SysVar *v)
|
||||
Value val;
|
||||
SysVarFunc f = (SysVarFunc) v->value;
|
||||
f(0, &val);
|
||||
if (DoCoerce(STR_TYPE, &val) == OK) {
|
||||
fprintf(ErrFp, "\"%s\"\n", val.v.str);
|
||||
}
|
||||
PrintValue(&val, ErrFp);
|
||||
Putc('\n', ErrFp);
|
||||
DestroyValue(val);
|
||||
} else if (v->type == STR_TYPE) {
|
||||
char const *s = *((char **)v->value);
|
||||
@@ -665,6 +782,12 @@ static void DumpSysVar(char const *name, const SysVar *v)
|
||||
Putc('"', ErrFp);
|
||||
if (*s) fprintf(ErrFp, "...");
|
||||
Putc('\n', ErrFp);
|
||||
} else if (v->type == DATE_TYPE) {
|
||||
Value val;
|
||||
val.type = DATE_TYPE;
|
||||
val.v.val = * (int *) v->value;
|
||||
PrintValue(&val, ErrFp);
|
||||
Putc('\n', ErrFp);
|
||||
} else {
|
||||
if (!v->modifiable) fprintf(ErrFp, "%d\n", *((int *)v->value));
|
||||
else {
|
||||
|
||||
@@ -7,11 +7,11 @@ REM 28 SPECIAL COLOR 65 0 65 Dim Magenta
|
||||
REM 28 SPECIAL COLOR 65 65 0 Dim Yellow
|
||||
REM 28 SPECIAL COLOR 65 65 65 Dim White
|
||||
|
||||
REM 28 SPECIAL COLOR 129 0 0 Bright Red
|
||||
REM 28 SPECIAL COLOR 0 129 0 Bright Green
|
||||
REM 28 SPECIAL COLOR 0 0 129 Bright Blue
|
||||
REM 28 SPECIAL COLOR 0 129 129 Bright Cyan
|
||||
REM 28 SPECIAL COLOR 129 0 129 Bright Magenta
|
||||
REM 28 SPECIAL COLOR 129 129 0 Bright Yellow
|
||||
REM 28 SPECIAL COLOR 129 129 129 Bright White
|
||||
REM 28 SPECIAL COLOUR 129 0 0 Bright Red
|
||||
REM 28 SPECIAL COLOUR 0 129 0 Bright Green
|
||||
REM 28 SPECIAL COLOUR 0 0 129 Bright Blue
|
||||
REM 28 SPECIAL COLOUR 0 129 129 Bright Cyan
|
||||
REM 28 SPECIAL COLOUR 129 0 129 Bright Magenta
|
||||
REM 28 SPECIAL COLOUR 129 129 0 Bright Yellow
|
||||
REM 28 SPECIAL COLOUR 129 129 129 Bright White
|
||||
|
||||
|
||||
1
tests/file.ps
Normal file
1
tests/file.ps
Normal file
@@ -0,0 +1 @@
|
||||
(Second-Bit-Of-PS)
|
||||
1
tests/file2.ps
Normal file
1
tests/file2.ps
Normal file
@@ -0,0 +1 @@
|
||||
(Fourth-Bit-Of-PS)
|
||||
7
tests/purge_dir/f1.rem
Normal file
7
tests/purge_dir/f1.rem
Normal file
@@ -0,0 +1,7 @@
|
||||
# This is f1.rem
|
||||
INCLUDE [filedir()]/f2.rem
|
||||
INCLUDE [filedir()]/f2.rem
|
||||
|
||||
REM 1 Oct 1991 MSG old1.
|
||||
|
||||
REM Monday UNTIL 1 Oct 1991 MSG old2.
|
||||
6
tests/purge_dir/f2.rem
Normal file
6
tests/purge_dir/f2.rem
Normal file
@@ -0,0 +1,6 @@
|
||||
# This is f2.rem
|
||||
|
||||
REM 3 feb 2012 MSG new
|
||||
REM 3 1998 MSG old
|
||||
|
||||
INCLUDE [filedir()]/f3.rem
|
||||
92
tests/purge_dir/f3.rem
Normal file
92
tests/purge_dir/f3.rem
Normal file
@@ -0,0 +1,92 @@
|
||||
# This is f3.rem
|
||||
|
||||
REM Mon MSG repeat
|
||||
|
||||
REM Mon SATISFY [1] MSG repeat
|
||||
|
||||
IF 0
|
||||
REM 1991 MSG wookie
|
||||
ENDIF
|
||||
|
||||
IF 1
|
||||
REM 1991 MSG wookie
|
||||
ENDIF
|
||||
|
||||
IFTRIG 1991
|
||||
REM MSG wookie
|
||||
ENDIF
|
||||
|
||||
# More complex conditional statements
|
||||
IF 1
|
||||
IF 0
|
||||
REM 1991 MSG wookie
|
||||
ELSE
|
||||
REM 1991 MSG wookie
|
||||
ENDIF
|
||||
ELSE
|
||||
IF 1
|
||||
REM 1991 MSG wookie
|
||||
ELSE
|
||||
REM 1991 MSG wookie
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
REM [1990+1] MSG old-with-constant-expression
|
||||
|
||||
REM [1990+1] \
|
||||
MSG Continued line-old-with-constant-expression
|
||||
|
||||
REM 1990 \
|
||||
MSG expired-continued-line
|
||||
|
||||
set y 1990
|
||||
|
||||
REM [y+1] MSG old-with-nonconstant-expression
|
||||
|
||||
# A comment that should be preserved
|
||||
|
||||
#!P A comment that should be nuked because it \
|
||||
starts with #!P
|
||||
|
||||
REM [y+1] \
|
||||
MSG Continued-line-old-with-nonconstant-expression
|
||||
|
||||
OMIT 25 Dec MSG woaaahh!
|
||||
OMIT 24 Dec
|
||||
|
||||
OMIT 1 Jan 1992 MSG woaaahah... expired
|
||||
OMIT 2 Jan 1992
|
||||
|
||||
# Complicated expressions
|
||||
SET a 3
|
||||
FSET const(x) x+3
|
||||
FSET nonconst(x) x+a
|
||||
|
||||
REM [const(5)] Jan 1992 MSG expired... should be commented out
|
||||
REM [const(a)] Jan 1992 MSG nonconstant expression
|
||||
REM [nonconst(5)] Jan 1992 MSG nonconstant expression
|
||||
REM [value("a")] Jan 1992 MSG nonconstant expression
|
||||
|
||||
IF 0
|
||||
# A comment in a false IF block
|
||||
#!P This should be nuked
|
||||
ENDIF
|
||||
|
||||
# Busted line
|
||||
REM [0/0] Jan 1992 MSG ouch
|
||||
|
||||
ERRMSG blorky
|
||||
FLUSH
|
||||
SET a 1
|
||||
FSET a(x) x*x
|
||||
UNSET a
|
||||
CLEAR-OMIT-CONTEXT
|
||||
PUSH-OMIT-CONTEXT
|
||||
POP-OMIT-CONTEXT
|
||||
BANNER wow
|
||||
DEBUG +x
|
||||
DEBUG -x
|
||||
DUMP $
|
||||
EXIT 0
|
||||
PRESERVE i
|
||||
|
||||
30
tests/shade.rem
Normal file
30
tests/shade.rem
Normal file
@@ -0,0 +1,30 @@
|
||||
set $MinsFromUTC -240
|
||||
set $CalcUTC 0
|
||||
set $Location "Ottawa"
|
||||
set $LongDeg 75
|
||||
set $LongMin 39
|
||||
set $LongSec 0
|
||||
set $LatDeg 45
|
||||
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)]
|
||||
ENDIF
|
||||
|
||||
REM 4 PS (First-Bit-Of-PS)
|
||||
REM 4 PSFILE file.ps
|
||||
REM 4 PS (Third-Bit-Of-PS)
|
||||
REM 4 PSFILE file2.ps
|
||||
|
||||
REM Mon SPECIAL SHADE 255 255 255
|
||||
REM Tue SPECIAL SHADE 255 255 204
|
||||
REM Wed SPECIAL SHADE 255 204 255
|
||||
REM Thu SPECIAL SHADE 204 255 255
|
||||
REM Fri SPECIAL SHADE 255 204 204
|
||||
REM Sat SPECIAL SHADE 204 255 204
|
||||
REM Sun SPECIAL SHADE 204 204 255
|
||||
|
||||
13
tests/sun.rem
Normal file
13
tests/sun.rem
Normal file
@@ -0,0 +1,13 @@
|
||||
SET $LatDeg 45
|
||||
SET $LatMin 24
|
||||
SET $LatSec 0
|
||||
SET $LongDeg 75
|
||||
SET $LongMin 39
|
||||
SET $LongSec 0
|
||||
SET $MinsFromUTC -300
|
||||
SET $CalcUTC 0
|
||||
|
||||
MSG Dawn: [dawn()]
|
||||
MSG Sunrise: [sunrise()]
|
||||
MSG Sunset: [sunset()]
|
||||
MSG Dusk: [dusk()]
|
||||
@@ -22,28 +22,28 @@ chmod 000 include_dir/04cantread.rem
|
||||
TEST_GETENV="foo bar baz" ; export TEST_GETENV
|
||||
echo "Test 1" > ../tests/test.out
|
||||
echo "" >> ../tests/test.out
|
||||
../src/remind -e -dxte ../tests/test.rem 16 feb 1991 >> ../tests/test.out
|
||||
../src/remind -e -dxte ../tests/test.rem 16 feb 1991 >> ../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
|
||||
../src/remind -p -l ../tests/test2.rem 1 aug 2007 >> ../tests/test.out 2>&1
|
||||
echo "" >> ../tests/test.out
|
||||
echo "Test 3" >> ../tests/test.out
|
||||
echo "" >> ../tests/test.out
|
||||
../src/remind -s ../tests/test2.rem 1 aug 2007 >> ../tests/test.out
|
||||
../src/remind -s ../tests/test2.rem 1 aug 2007 >> ../tests/test.out 2>&1
|
||||
echo "" >> ../tests/test.out
|
||||
echo "Test 4" >> ../tests/test.out
|
||||
echo "" >> ../tests/test.out
|
||||
../src/remind -sa ../tests/test2.rem 1 aug 2007 >> ../tests/test.out
|
||||
../src/remind -sa ../tests/test2.rem 1 aug 2007 >> ../tests/test.out 2>&1
|
||||
echo "Test 5" >> ../tests/test.out
|
||||
echo "" >> ../tests/test.out
|
||||
../src/remind -p -l -b0 ../tests/test3.rem 1 aug 2007 >> ../tests/test.out
|
||||
../src/remind -p -l -b0 ../tests/test3.rem 1 aug 2007 >> ../tests/test.out 2>&1
|
||||
echo "Test 6" >> ../tests/test.out
|
||||
echo "" >> ../tests/test.out
|
||||
../src/remind -p -l -b1 ../tests/test3.rem 1 aug 2007 >> ../tests/test.out
|
||||
../src/remind -p -l -b1 ../tests/test3.rem 1 aug 2007 >> ../tests/test.out 2>&1
|
||||
echo "Test 7" >> ../tests/test.out
|
||||
echo "" >> ../tests/test.out
|
||||
../src/remind -p -l -b2 ../tests/test3.rem 1 aug 2007 >> ../tests/test.out
|
||||
../src/remind -p -l -b2 ../tests/test3.rem 1 aug 2007 >> ../tests/test.out 2>&1
|
||||
|
||||
echo "Test 8" >> ../tests/test.out
|
||||
echo "" >> ../tests/test.out
|
||||
@@ -58,17 +58,49 @@ echo "" >> ../tests/test.out
|
||||
chmod 644 include_dir/04cantread.rem
|
||||
|
||||
echo "Color Test" >> ../tests/test.out
|
||||
../src/remind -ccl ../tests/colors.rem 1 aug 2007 >> ../tests/test.out
|
||||
../src/remind -ccl ../tests/colors.rem 1 aug 2007 >> ../tests/test.out 2>&1
|
||||
|
||||
echo "MON WKDAY DAY across year test" >> ../tests/test.out
|
||||
echo 'REM Mon 29 Dec MSG x' | ../src/remind -dt - 1 Jan 2000 >> ../tests/test.out 2>&1
|
||||
|
||||
echo "Sort Test" >> ../tests/test.out
|
||||
(echo "REM AT 12:00 MSG Untimed"; echo "REM MSG Timed") | ../src/remind -gaaa - 1 Jan 2000 >> ../tests/test.out 2>&1
|
||||
(echo "REM AT 12:00 MSG Untimed"; echo "REM MSG Timed") | ../src/remind -gaaad - 1 Jan 2000 >> ../tests/test.out 2>&1
|
||||
(echo "REM AT 12:00 MSG Untimed"; echo "REM MSG Timed") | ../src/remind -q -gaaa - 1 Jan 2000 >> ../tests/test.out 2>&1
|
||||
(echo "REM AT 12:00 MSG Untimed"; echo "REM MSG Timed") | ../src/remind -q -gaaad - 1 Jan 2000 >> ../tests/test.out 2>&1
|
||||
|
||||
echo "Purge Test" >> ../tests/test.out
|
||||
../src/remind -j999 ../tests/purge_dir/f1.rem 3 Feb 2012 >> ../tests/test.out 2>&1
|
||||
echo "F1" >> ../tests/test.out
|
||||
cat ../tests/purge_dir/f1.rem.purged >> ../tests/test.out
|
||||
echo "F2" >> ../tests/test.out
|
||||
cat ../tests/purge_dir/f2.rem.purged >> ../tests/test.out
|
||||
echo "F3" >> ../tests/test.out
|
||||
cat ../tests/purge_dir/f3.rem.purged >> ../tests/test.out
|
||||
|
||||
rm -f ../tests/purge_dir/*.rem.purged >> ../tests/test.out 2>&1
|
||||
../src/remind ../tests/runtest.rem >> ../tests/test.out 2>&1
|
||||
|
||||
../src/remind -p ../tests/shade.rem 1 August 2009 | ../src/rem2ps -e -l -c3 >> ../tests/test.out 2>&1
|
||||
|
||||
# The sun tests can fail due to math roundoff error changing the times
|
||||
# by a minute...
|
||||
# ../src/remind -p12 ../tests/sun.rem 1 Jan 2011 >> ../tests/test.out 2>&1
|
||||
|
||||
# Test -a vs -aa
|
||||
../src/remind -q -a - 1 Jan 2012 9:00 <<'EOF' >> ../tests/test.out 2>&1
|
||||
REM 1 Jan 2012 AT 8:00 MSG 8am: Should not show up
|
||||
REM 1 Jan 2012 AT 9:00 MSG 9am: Should not show up
|
||||
REM 1 Jan 2012 AT 10:00 MSG 10am: Should not show up
|
||||
MSG [$DontTrigAts]
|
||||
EOF
|
||||
|
||||
../src/remind -q -a -a - 1 Jan 2012 9:00 <<'EOF' >> ../tests/test.out 2>&1
|
||||
REM 1 Jan 2012 AT 8:00 MSG 8am: Should not show up
|
||||
REM 1 Jan 2012 AT 9:00 MSG 9am: Should show up
|
||||
REM 1 Jan 2012 AT 10:00 MSG 10am: Should show up
|
||||
MSG [$DontTrigAts]
|
||||
EOF
|
||||
|
||||
|
||||
cmp -s ../tests/test.out ../tests/test.cmp
|
||||
if [ "$?" = "0" ]; then
|
||||
echo "Remind: Acceptance test PASSED"
|
||||
|
||||
1733
tests/test.cmp
1733
tests/test.cmp
File diff suppressed because it is too large
Load Diff
@@ -45,6 +45,9 @@ fset _i(x,y,z,a) trigger(hebdate(x,y,z,a))
|
||||
[_i(29, "Adar A", today(), 5755)] MSG Leap
|
||||
[_i(29, "Adar A", today(), 5756)] MSG Illegal
|
||||
|
||||
# This causes a parse error on version 03.01.01
|
||||
REM 1990-01-01 SATISFY 1
|
||||
|
||||
# Test each possible case of the basic reminders.
|
||||
|
||||
REM MSG Every Day
|
||||
@@ -176,6 +179,12 @@ OMIT 2 March 1991
|
||||
REM 1 March OMIT Sun OMITFUNC _ofunc AFTER MSG Should trigger 1 March
|
||||
REM 1 March OMIT Sun AFTER MSG Should trigger 4 March
|
||||
|
||||
# Test shorthand reminders
|
||||
REM 1991-02-28 MSG Feb 28
|
||||
REM 1991/02/28@14:45 MSG Feb 28
|
||||
REM Wed UNTIL 1991-01-01 MSG Expired
|
||||
REM Wed SCANFROM 1991-02-26 MSG SCANFROM
|
||||
|
||||
set a000 abs(1)
|
||||
set a001 abs(-1)
|
||||
set a002 asc("foo")
|
||||
@@ -261,10 +270,42 @@ set a075 dosubst("%i %j %k %l %m %n %o %p", '1992/5/5')
|
||||
msg [a075]%
|
||||
set a076 dosubst("%q %r %s %t %u %v %w %x", '1992/5/5')
|
||||
msg [a076]%
|
||||
set a077 dosubst("%y %z", '1992/5/5')
|
||||
set a074 dosubst("%*a %*b %*c %*d %*e %*f %*g %*h", '1992/5/5')
|
||||
msg [a074]%
|
||||
set a075 dosubst("%*i %*j %*k %*l %*m %*n %*o %*p", '1992/5/5')
|
||||
msg [a075]%
|
||||
set a076 dosubst("%*q %*r %*s %*t %*u %*v %*w %*x", '1992/5/5')
|
||||
msg [a076]%
|
||||
set a077 dosubst("%*y %*z", '1992/5/5')
|
||||
msg [a077]%
|
||||
set a074 dosubst("%A %B %C %D %E %F %G %H", '1992/5/5')
|
||||
msg [a074]%
|
||||
set a075 dosubst("%I %J %K %L %M %N %O %P", '1992/5/5')
|
||||
msg [a075]%
|
||||
set a076 dosubst("%Q %R %S %T %U %V %W %X", '1992/5/5')
|
||||
msg [a076]%
|
||||
set a077 dosubst("%Y %Z", '1992/5/5')
|
||||
msg [a077]%
|
||||
set a074 dosubst("%*A %*B %*C %*D %*E %*F %*G %*H", '1992/5/5')
|
||||
msg [a074]%
|
||||
set a075 dosubst("%*I %*J %*K %*L %*M %*N %*O %*P", '1992/5/5')
|
||||
msg [a075]%
|
||||
set a076 dosubst("%*Q %*R %*S %*T %*U %*V %*W %*X", '1992/5/5')
|
||||
msg [a076]%
|
||||
set a077 dosubst("%*Y %*Z", '1992/5/5')
|
||||
msg [a077]%
|
||||
set a078 easterdate(today())
|
||||
set a079 easterdate(1992)
|
||||
set a080 easterdate(1995)
|
||||
set a081 ""
|
||||
OMIT 1991-03-11
|
||||
set a082 slide('1991-03-01', 7, "Sat", "Sun")
|
||||
set a083 slide('1991-04-01', -7, "Sat")
|
||||
set a084 nonomitted('1991-03-01', '1991-03-13', "Sat", "Sun")
|
||||
set a085 nonomitted('1991-03-24', '1991-04-01', "Sat")
|
||||
dump
|
||||
OMIT 2010-09-03 THROUGH 2010-09-15
|
||||
OMIT December 25 MSG X
|
||||
# Next should give a parse error
|
||||
OMIT 26 Dec 2010 THROUGH 27 Dec 2010 MSG This is not legal
|
||||
OMIT DUMP
|
||||
|
||||
@@ -30,7 +30,7 @@ if !$RunOff || !$DontQueue || $DontTrigAts
|
||||
endif
|
||||
|
||||
# Set up a few useful definitions
|
||||
fset show(x) "%%" + x + " yields: " + char(34) + "%" + x + char(34) + "%"
|
||||
fset show(x) "%%" + x + " yields: " + char(34) + "%" + x + char(34) + "% and %%*" + x + " yields: " + char(34) + "%*" + x + char(34) + "%"
|
||||
set a trigger(today()+2) + " ++2"
|
||||
set l language()
|
||||
set tt now()+134
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Unconfiguring Remind..."
|
||||
echo rm -f config.cache config.log config.status src/Makefile src/config.h src/version.h
|
||||
rm -f config.cache config.log config.status src/Makefile src/config.h src/version.h
|
||||
echo rm -f config.cache config.log config.status src/Makefile src/config.h src/version.h www/Makefile
|
||||
rm -f config.cache config.log config.status src/Makefile src/config.h src/version.h www/Makefile
|
||||
exit 0
|
||||
|
||||
341
www/php/remind.php
Normal file
341
www/php/remind.php
Normal file
@@ -0,0 +1,341 @@
|
||||
<?php
|
||||
|
||||
class Remind
|
||||
{
|
||||
# For validating commands we send to popen
|
||||
function is_valid_day($d) {
|
||||
return (preg_match('/^\d+$/', $d)) &&
|
||||
$d >= 1 && $d <= 31;
|
||||
}
|
||||
|
||||
function is_valid_month($m) {
|
||||
return
|
||||
($m == 'January') ||
|
||||
($m == 'February') ||
|
||||
($m == 'March') ||
|
||||
($m == 'April') ||
|
||||
($m == 'May') ||
|
||||
($m == 'June') ||
|
||||
($m == 'July') ||
|
||||
($m == 'August') ||
|
||||
($m == 'September') ||
|
||||
($m == 'October') ||
|
||||
($m == 'November') ||
|
||||
($m == 'December');
|
||||
}
|
||||
|
||||
function is_valid_year($y) {
|
||||
return preg_match('/^\d\d\d\d$/', $y) &&
|
||||
$y >= 1900;
|
||||
}
|
||||
|
||||
|
||||
function get_el(&$array, $i)
|
||||
{
|
||||
if (!array_key_exists($i, $array)) return null;
|
||||
return $array[$i];
|
||||
}
|
||||
|
||||
function get_elem($array, $indexes)
|
||||
{
|
||||
foreach ($indexes as $i) {
|
||||
if (!is_array($array)) return null;
|
||||
if (!array_key_exists($i, $array)) return null;
|
||||
$array = $array[$i];
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
function munge_entry($day, &$results, &$specials, &$options, $str, &$e) {
|
||||
return htmlspecialchars($str);
|
||||
}
|
||||
|
||||
function format_entry($day, &$results, &$specials, &$options, &$e) {
|
||||
$special = $this->get_el($e, 'special');
|
||||
$body = $this->get_el($e, 'body');
|
||||
|
||||
if ($body === null) $body = '';
|
||||
if ($special === null || $special == '*') {
|
||||
return $this->munge_entry($day, $results, $specials, $options, $body, $e);
|
||||
}
|
||||
if ($special == 'COLOR' || $special == 'COLOUR') {
|
||||
if (preg_match('/^(\d+)\s+(\d+)\s+(\d+)\s+(.*)/', $body, $matches)) {
|
||||
return sprintf('<span style="color: #%02x%02x%02x">%s</span>',
|
||||
$matches[1] % 255,
|
||||
$matches[2] % 255,
|
||||
$matches[3] % 255,
|
||||
$this->munge_entry($day, $results, $specials, $options, $matches[4], $e));
|
||||
}
|
||||
return 'Bad COLOR spec: ' . htmlspecialchars($body);
|
||||
}
|
||||
|
||||
# HTML is passed through un-munged.
|
||||
if ($special == 'HTML') return $body;
|
||||
|
||||
# Ignore unknown specials
|
||||
return '';
|
||||
}
|
||||
|
||||
function format_entries($day, &$results, &$specials, &$options, &$entries) {
|
||||
$html = '';
|
||||
foreach ($entries as $e) {
|
||||
$html .= '<div class="rem-entry">' . $this->format_entry($day, $results, $specials, $options, $e) . '</div>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
function do_one_day($day, &$results, &$specials, &$options) {
|
||||
$class = $this->get_elem($specials, array('HTMLCLASS', $day, 0, 'body'));
|
||||
$shade = $this->get_elem($specials, array('SHADE', $day, 0, 'body'));
|
||||
$moon = $this->get_elem($specials, array('MOON', $day, 0, 'body'));
|
||||
|
||||
if ($class === null) $class = 'rem-cell';
|
||||
$bg = '';
|
||||
if ($shade !== null) {
|
||||
if (preg_match('/(\d+)\s+(\d+)\s+(\d+)/', $shade, $matches)) {
|
||||
if ($matches[1] <= 255 && $matches[2] <= 255 && $matches[3] <= 255) {
|
||||
$bg = sprintf(' style="background: #%02x%02x%02x"',
|
||||
$matches[1], $matches[2], $matches[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$html = "<td class=\"$class\"$bg>";
|
||||
|
||||
$week = $this->get_elem($specials, array('WEEK', $day, 0, 'body'));
|
||||
if ($week === null) {
|
||||
$week = '';
|
||||
} else {
|
||||
$week = ' ' . $week;
|
||||
}
|
||||
|
||||
$moon_html = '';
|
||||
if ($moon !== null) {
|
||||
$phase = -1;
|
||||
if (preg_match('/(\d+)\s+(\S+)\s+(\S+)\s+(.*)$/', $moon, $matches)) {
|
||||
$phase = $matches[1];
|
||||
$moonsize = $matches[2];
|
||||
$fontsize = $matches[3];
|
||||
$msg = $matches[4];
|
||||
} elseif (preg_match('/(\d+)/', $moon, $matches)) {
|
||||
$phase = $matches[1];
|
||||
$msg = '';
|
||||
}
|
||||
if ($phase >= 0) {
|
||||
if ($phase == 0) {
|
||||
$img = 'newmoon.png';
|
||||
$title = 'New Moon';
|
||||
$alt = 'new';
|
||||
} elseif ($phase == 1) {
|
||||
$img = 'firstquarter.png';
|
||||
$title = 'First Quarter';
|
||||
$alt = '1st';
|
||||
} elseif ($phase == 2) {
|
||||
$img = 'fullmoon.png';
|
||||
$alt = 'full';
|
||||
$title = 'Full Moon';
|
||||
} else {
|
||||
$img = 'lastquarter.png';
|
||||
$alt = 'last';
|
||||
$title = 'Last Quarter';
|
||||
}
|
||||
$base = rtrim($this->get_el($options, 'imgbase'), '/');
|
||||
if ($base !== null) {
|
||||
$img = $base . '/' . $img;
|
||||
}
|
||||
$moon_html = '<div class="rem-moon">' . "<img width=\"16\" height=\"16\" alt=\"$alt\" title=\"$title\" src=\"$img\">" . htmlspecialchars($msg) . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
# Day number
|
||||
$html .= $moon_html . '<div class="rem-daynumber">' . $day . $week . '</div>';
|
||||
|
||||
# And the entries
|
||||
$entries = $this->get_elem($results, array('entries', $day));
|
||||
if (is_array($entries) && count($entries) > 0) {
|
||||
$html .= '<div class="rem-entries">';
|
||||
$html .= $this->format_entries($day, $results, $specials, $options, $entries);
|
||||
$html .= '</div>';
|
||||
}
|
||||
$html .= "</td>\n";
|
||||
return $html;
|
||||
}
|
||||
|
||||
function small_calendar($results, $month, $monlen, $first_col, $which, &$options)
|
||||
{
|
||||
$monday_first = $results['monday_flag'];
|
||||
if ($monday_first) {
|
||||
$first_col--;
|
||||
if ($first_col < 0) {
|
||||
$first_col = 6;
|
||||
}
|
||||
}
|
||||
|
||||
$html = "<td class=\"rem-small-calendar\">\n<table class=\"rem-sc-table\">\n<caption class=\"rem-sc-caption\">";
|
||||
# TODO: URL for small calendar
|
||||
$html .= $month;
|
||||
$html .= "</caption>\n";
|
||||
}
|
||||
|
||||
function generate_html(&$results, &$specials, &$options)
|
||||
{
|
||||
$monday_first = $results['monday_flag'];
|
||||
$first_col = $results['first_day'];
|
||||
if ($monday_first) {
|
||||
$first_col--;
|
||||
if ($first_col < 0) $first_col = 6;
|
||||
}
|
||||
|
||||
$last_col = ($first_col + $results['days_in_mon'] -1) % 7;
|
||||
|
||||
$html = '<table class="rem-cal"><caption class="rem-cal-caption">' .
|
||||
htmlspecialchars($results['month']) . ' ' . htmlspecialchars($results['year']) .
|
||||
"</caption>\n";
|
||||
|
||||
$html .= '<tr class="rem-cal-hdr-row">';
|
||||
if (!$monday_first) $html .= '<th class="rem-cal-hdr">' . htmlspecialchars($results['day_names'][0]) . '</th>';
|
||||
for ($i=1; $i<7; $i++) $html .= '<th class="rem-cal-hdr">' . htmlspecialchars($results['day_names'][$i]) . '</th>';
|
||||
if ($monday_first) $html .= '<th class="rem-cal-hdr">' . htmlspecialchars($results['day_names'][0]) . '</th>';
|
||||
$html .= "</tr>\n";
|
||||
|
||||
# Do the leading empty columns
|
||||
for ($col=0; $col < $first_col; $col++) {
|
||||
if ($col == 0) $html .= '<tr class="rem-cal-body-row">';
|
||||
$html .= '<td class="rem-empty"> </td>';
|
||||
}
|
||||
|
||||
for ($day=1; $day <= $results['days_in_mon']; $day++) {
|
||||
if ($col == 0) $html .= '<tr class="rem-cal-body-row">';
|
||||
$col++;
|
||||
$html .= $this->do_one_day($day, $results, $specials, $options);
|
||||
if ($col == 7) {
|
||||
$html .= "</tr>\n";
|
||||
$col = 0;
|
||||
}
|
||||
}
|
||||
if ($col) {
|
||||
while ($col++ < 7) {
|
||||
$html .= '<td class="rem-empty"> </td>';
|
||||
}
|
||||
}
|
||||
$html .= "</tr>\n";
|
||||
|
||||
$html .= "</table>\n";
|
||||
return $html;
|
||||
}
|
||||
function parse_remind_output ($fp)
|
||||
{
|
||||
while(1) {
|
||||
$line = fgets($fp);
|
||||
if ($line === false) break;
|
||||
$line = trim($line);
|
||||
if ($line == '# rem2ps begin') break;
|
||||
}
|
||||
if ($line === false) {
|
||||
return array('success' => 0,
|
||||
'error' => 'Could not find any Rem2PS data');
|
||||
}
|
||||
|
||||
$line = fgets($fp);
|
||||
if ($line === false) {
|
||||
return array('success' => 0,
|
||||
'error' => 'Unexpected end-of-file');
|
||||
}
|
||||
|
||||
$line = trim($line);
|
||||
list($month, $year, $days_in_mon, $first_day, $monday_flag) = explode(' ', $line);
|
||||
$retval = array('month' => $month,
|
||||
'year' => $year,
|
||||
'days_in_mon' => $days_in_mon,
|
||||
'first_day' => $first_day,
|
||||
'monday_flag' => $monday_flag);
|
||||
|
||||
$line = fgets($fp);
|
||||
if ($line === false) {
|
||||
return array('success' => 0,
|
||||
'error' => 'Unexpected end-of-file');
|
||||
}
|
||||
|
||||
$line = trim($line);
|
||||
$retval['day_names'] = explode(' ', $line);
|
||||
|
||||
$line = fgets($fp);
|
||||
if ($line === false) {
|
||||
return array('success' => 0,
|
||||
'error' => 'Unexpected end-of-file');
|
||||
}
|
||||
$line = trim($line);
|
||||
|
||||
list($m, $n) = explode(' ', $line);
|
||||
$retval['prev'] = array('month' => $m, 'days' => $n);
|
||||
|
||||
$line = fgets($fp);
|
||||
if ($line === false) {
|
||||
return array('success' => 0,
|
||||
'error' => 'Unexpected end-of-file');
|
||||
}
|
||||
$line = trim($line);
|
||||
|
||||
list($m, $n) = explode(' ', $line);
|
||||
$retval['next'] = array('month' => $m, 'days' => $n);
|
||||
|
||||
$line_info = 0;
|
||||
|
||||
$entries = array();
|
||||
$specials = array();
|
||||
while (1) {
|
||||
$line = fgets($fp);
|
||||
if ($line === false) break;
|
||||
$line = trim($line);
|
||||
if ($line == '# rem2ps end') break;
|
||||
if (strpos($line, '# fileinfo ') === 0) {
|
||||
list($lno, $fname) = explode(' ', substr($line, 11), 2);
|
||||
$lineinfo = array('file' => $fname, 'line' => $lno);
|
||||
continue;
|
||||
}
|
||||
list($date, $special, $tags, $duration, $time, $body) = explode(' ', $line, 6);
|
||||
list($y, $m, $d) = explode('/', $date);
|
||||
$d = preg_replace('/^0(.)/', '$1', $d);
|
||||
$m = preg_replace('/^0(.)/', '$1', $m);
|
||||
$entry = array('day' => $d,
|
||||
'month' => $m,
|
||||
'year' => $y,
|
||||
'special' => $special,
|
||||
'tags' => $tags,
|
||||
'duration' => $duration,
|
||||
'time' => $time,
|
||||
'body' => $body);
|
||||
if (is_array($lineinfo)) {
|
||||
$entry['line'] = $lineinfo['line'];
|
||||
$entry['file'] = $lineinfo['file'];
|
||||
$lineinfo = 0;
|
||||
}
|
||||
if ($special != '*' && $special != 'COLOR' && $special != 'COLOUR' && $special != 'HTML') {
|
||||
if (!array_key_exists($special, $specials)) {
|
||||
$specials[$special] = array();
|
||||
}
|
||||
if (!array_key_exists($d, $specials[$special])) {
|
||||
$specials[$special][$d] = array();
|
||||
}
|
||||
$specials[$special][$d][] = $entry;
|
||||
} else {
|
||||
if (!array_key_exists($d, $entries)) {
|
||||
$entries[$d] = array();
|
||||
}
|
||||
$entries[$d][] = $entry;
|
||||
}
|
||||
|
||||
}
|
||||
$retval['entries'] = $entries;
|
||||
return array('success' => 1, 'results' => $retval, 'specials' => $specials);
|
||||
}
|
||||
}
|
||||
|
||||
$fp = popen('rem -p -l', 'r');
|
||||
$r = new Remind;
|
||||
$ans = $r->parse_remind_output($fp);
|
||||
pclose($fp);
|
||||
print_r($ans);
|
||||
$options = array();
|
||||
#print $r->generate_html($ans['results'], $ans['specials'], $options);
|
||||
|
||||
?>
|
||||
@@ -257,7 +257,7 @@ sub parse_input
|
||||
$shades->[$d] = sprintf("#%02X%02X%02X",
|
||||
($1 % 256), ($2 % 256), ($3 % 256));
|
||||
}
|
||||
} elsif ($special eq 'COLOR') {
|
||||
} elsif ($special eq 'COLOR' || $special eq 'COLOUR') {
|
||||
if ($body =~ /(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/) {
|
||||
my($r, $g, $b, $text) = ($1, $2, $3, $4);
|
||||
my $color = sprintf("style=\"color: #%02X%02X%02X;\"",
|
||||
|
||||
Reference in New Issue
Block a user