Compare commits

...

55 Commits

Author SHA1 Message Date
David F. Skoll
fdb4b302ac Update WHATSNEW with release date. 2010-06-20 16:38:44 -04:00
David F. Skoll
760d5d4a09 Fix trap to reset signal disposition to default. 2010-06-02 09:05:11 -04:00
David F. Skoll
d561f98c42 Fix syntax error. 2010-05-18 20:45:36 -04:00
David F. Skoll
ea74f276dc Don't rkrphgvba more than once. 2010-05-18 12:46:34 -04:00
David F. Skoll
42cf82a5d5 More Apple / Cygwin detection. 2010-05-17 09:32:50 -04:00
David F. Skoll
825a6700da Make "trap" command follow POSIX standard. 2010-05-17 06:59:41 -04:00
David F. Skoll
2f27645dac Handle SPECIAL COLOR correctly with -n commandline option. 2010-05-01 20:52:25 -04:00
David F. Skoll
1e5b44d063 Make handling of continued lines same as in 3.1.8. 2010-04-25 10:07:12 -04:00
David F. Skoll
099ad9945d Fix huge bug in handling of continued lines. 2010-04-25 10:03:13 -04:00
David F. Skoll
540ce3d946 Allow "timepart" to take a TIME or DATETIME. Allow "datepart" to take a
DATE or DATETIME.  Update docs.
2010-04-25 09:50:39 -04:00
David F. Skoll
ac2efcc993 Document timepart() and datepart(). 2010-04-25 09:40:01 -04:00
David F. Skoll
b4bb1d9e37 Update copyright date. 2010-04-25 09:34:49 -04:00
David F. Skoll
9ec8b30934 Update copyright date. 2010-04-22 11:45:19 -04:00
David F. Skoll
fb38e5b35b Update WHATSNEW. 2010-04-21 16:01:04 -04:00
David F. Skoll
5fa10e9d84 Document Purge Mode. 2010-04-21 14:55:28 -04:00
David F. Skoll
3bc1b5bd46 Clean up tests; add test for non-parseable line in purge mode. 2010-04-21 13:30:10 -04:00
David F. Skoll
b266b399ba Test for fix of parse error.
Try REALLY hard to detect constant expressions...
2010-04-21 13:23:26 -04:00
David F. Skoll
0e827a457d Fix YomHashoah date and bug in DoSatReminder. 2010-04-21 09:49:33 -04:00
David F. Skoll
d05d85b243 More tests. 2010-04-21 09:04:48 -04:00
David F. Skoll
a1faa8d804 Finish up Purge Mode:
o Make it recognize constant expressions (yay!)
o Make it not add a blank line to end of *.purged files.
o Make it nuke #!P comments in the source files.
2010-04-21 09:02:25 -04:00
David F. Skoll
70adbf90c2 Add tests for purge mode. 2010-04-20 15:20:49 -04:00
David F. Skoll
501c04f4b6 More work on purge mode. 2010-04-20 14:01:54 -04:00
David F. Skoll
d294e62be1 More work on purge mode. 2010-04-20 11:34:07 -04:00
David F. Skoll
31f90b6c53 Add purge mode. 2010-04-20 10:59:57 -04:00
David F. Skoll
184d29c592 More work on -j ("Purge Mode") option. 2010-04-19 15:57:35 -04:00
David F. Skoll
2d798bc4ec Add support for DURATION in TkRemind. Patch from Marek Marczykowski. 2010-04-19 14:13:48 -04:00
David F. Skoll
bd9a3761a6 Sort PSFILE and PS reminders with same priority (Ticket #17581) 2010-04-19 13:17:00 -04:00
David F. Skoll
b1063b0a9e More purge-mode work. 2010-04-09 11:01:45 -04:00
David F. Skoll
cb2fffab92 Don't expire lines containing expressions. 2010-04-07 15:32:20 -04:00
David F. Skoll
55cca49428 Start implementing a "-j" mode to purge old reminders. 2010-04-07 15:30:29 -04:00
David F. Skoll
5a0ab9ed8a Fix shade.rem to be independent of location and time zone of test machine. 2010-03-10 11:14:36 -05:00
David F. Skoll
1f2cfdfd84 Bump version to 03.01.09. 2010-03-09 10:05:56 -05:00
David F. Skoll
dfd688caa6 Update WHATSNEW date. 2010-03-09 09:55:00 -05:00
David F. Skoll
830e3e339c Make it only mildly annoying to compile on Windows and Mac OS X. 2010-03-06 17:39:39 -05:00
David F. Skoll
bc9f560950 Update WHATSNEW file. 2010-03-03 11:18:35 -05:00
David F. Skoll
f91b748f50 I don't like Microsoft or Apple. So the ./configure script will bail out on those platforms. 2010-03-02 19:15:40 -05:00
David F. Skoll
3adbd7468c Update "WINDOWS" file; rename it to MICROSOFT-AND-APPLE. 2010-03-02 19:06:06 -05:00
David F. Skoll
b66039ee24 Ignore msgprefix()/msgsuffix() on RUN-type reminders. 2010-02-26 09:48:18 -05:00
David F. Skoll
27371f6475 Document new $T, $U system variables. 2009-12-29 21:26:11 -05:00
David F. Skoll
19e7c34b47 Bump version to 03.01.08. 2009-12-29 10:52:06 -05:00
David F. Skoll
3375aff3a7 Add $U, $Um, $Ud, $Uy and $Uw special variables. Just like the $T.. versions,
but using today() instead of trigdate().
2009-12-29 08:47:07 -05:00
David F. Skoll
41e9cb5ca3 Clean up handling of SPECIAL_TYPE variales. Make
$T return 1990-01-01 if last trigger date was not valid.
2009-12-26 13:06:50 -05:00
David F. Skoll
6348860adf Update test for new debugging output. 2009-12-26 00:28:16 -05:00
David F. Skoll
4e9d401002 Add $T, $Td, $Tm, $Tw and $Ty system variables as shorthands for
trigdate(), day(tridate()), month(trigdate()), wkdayno(trigdate()) and
year(trigdate())
2009-12-26 00:26:14 -05:00
David F. Skoll
3db2fc7d0f Make "$t" a synonym for "trigdate()" 2009-12-22 18:25:01 -05:00
David F. Skoll
0101d76113 Better -df output. 2009-11-16 00:09:40 -05:00
David F. Skoll
6fabab6d4b Add remind-conf-mode 2009-11-03 13:32:10 -05:00
David F. Skoll
905f1b0aaf Add some scripts in contrib/ 2009-11-03 13:25:17 -05:00
David F. Skoll
6a5ab8e70c Update man page. 2009-11-01 09:54:28 -05:00
David F. Skoll
943b037589 Better iconphoto. 2009-10-30 22:08:26 -04:00
David F. Skoll
5624cd44de Set a nice iconphoto. 2009-10-30 13:52:19 -04:00
David F. Skoll
8529f8b843 Fix bugs in Makefile.in 2009-10-15 15:19:56 -04:00
David F. Skoll
08be7c43cf Don't make SHADE specials obliterate MOON specials. Fixes ticket 15068. 2009-10-05 14:33:51 -04:00
David F. Skoll
aae76207ec Fix bug in SCHED function calculation (RT #15644) 2009-09-06 18:36:34 -04:00
David F. Skoll
5434f8330e Sort specials. 2009-09-06 18:36:27 -04:00
45 changed files with 4276 additions and 473 deletions

View File

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

View File

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

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

32
configure vendored
View File

@@ -1691,6 +1691,36 @@ EOF
ac_config_headers="$ac_config_headers 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
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -5284,7 +5314,7 @@ _ACEOF
fi
done
VERSION=03.01.07
VERSION=03.01.09
ac_config_files="$ac_config_files src/Makefile www/Makefile src/version.h"

View File

@@ -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
@@ -45,6 +75,6 @@ if test "$GCC" = yes; then
fi
AC_CHECK_FUNCS(setenv unsetenv glob)
VERSION=03.01.07
VERSION=03.01.09
AC_SUBST(VERSION)
AC_OUTPUT(src/Makefile www/Makefile src/version.h)

10
contrib/README Normal file
View 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
View 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 :

View 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
View 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:" . &quotify(${$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} . "]=|" . &quotify($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

View 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

View 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 ")))"
;; )

View 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" "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")
#'(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?

View File

@@ -1,5 +1,41 @@
CHANGES TO REMIND
* 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

View File

@@ -27,8 +27,8 @@ RUN OFF
################################################
# Ensure required version of remind is used... #
################################################
IF version() < "03.01.07"
ERRMSG This file requires at least version 03.01.07 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
@@ -508,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

View File

@@ -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.
@@ -668,6 +672,17 @@ 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
@@ -1968,10 +1983,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
@@ -1981,6 +2007,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
@@ -2107,6 +2152,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.
@@ -2254,6 +2303,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
@@ -2297,18 +2358,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
@@ -2639,6 +2688,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
@@ -3585,7 +3638,68 @@ so to run in the daemon mode in the background, use:
.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

View File

@@ -8,7 +8,7 @@
#
# This file is part of REMIND.
# Copyright (C) 1992-1998 David F. Skoll
# Copyright (C) 1999-2009 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
@@ -1123,12 +1155,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 +1302,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 +1360,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 +1394,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 +1606,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 +1648,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 +2323,7 @@ proc main {} {
global AppendFile HighestTagSoFar DayNames
catch {
puts "\nTkRemind Copyright (C) 1996-1998 David F. Skoll"
puts "Copyright (C) 1999-2009 Roaring Penguin Software Inc."
puts "Copyright (C) 1999-2010 Roaring Penguin Software Inc."
}
catch { SetFonts }
LoadOptions

View File

@@ -38,7 +38,7 @@ 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) $<
@@ -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 -x .gitignore) | 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 -x .gitignore) | 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)

View File

@@ -770,7 +770,10 @@ static int DoCalRem(ParsePtr p, int col)
if (trig.typ == NO_TYPE) return E_EOLN;
if (trig.typ == SAT_TYPE) {
r=DoSatRemind(&trig, &tim, p);
if (r) return r;
if (r) {
if (r == E_EXPIRED) return OK;
return r;
}
if (!LastTrigValid) return OK;
r=ParseToken(p, &buf);
if (r) return r;
@@ -871,7 +874,7 @@ 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) {
@@ -908,7 +911,7 @@ 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) {
@@ -922,7 +925,7 @@ 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);

View File

@@ -58,10 +58,18 @@ int DoRem(ParsePtr p)
/* Parse the trigger date and time */
if ( (r=ParseRem(p, &trig, &tim, 1)) ) 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);
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 (r) {
if (r == E_EXPIRED) return OK;
return r;
}
if (!LastTrigValid) return OK;
r=ParseToken(p, &buf);
if (r) return r;
@@ -88,12 +96,37 @@ int DoRem(ParsePtr p)
trig.typ = tok.val;
jul = LastTriggerDate;
if (!LastTrigValid) return OK;
if (PurgeMode) 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);
}
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);
}
return OK;
}
/* Queue the reminder, if necessary */
if (jul == JulianToday &&
!(!IgnoreOnce &&
@@ -653,18 +686,24 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul)
if (t->typ == PASSTHRU_TYPE && !strcmp(t->passthru, "COLOR")) {
/* 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;
@@ -748,38 +787,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);
@@ -924,7 +971,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);
@@ -1065,7 +1112,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]);

View File

@@ -41,7 +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 MakeValue (char const *s, Value *v, Var *locals, ParsePtr p);
/* Binary operators - all left-associative */
@@ -132,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;
}
@@ -150,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;
@@ -283,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 == '(') {
@@ -303,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)--;
@@ -326,7 +326,7 @@ 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;
@@ -351,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) != ')') {
@@ -374,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;
@@ -385,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;
@@ -399,9 +401,11 @@ 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);
@@ -422,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);
@@ -486,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;
@@ -541,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);
@@ -551,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);

View File

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

View File

@@ -184,89 +184,89 @@ extern int ValStackPtr;
/* The array holding the built-in functions. */
BuiltinFunc Func[] = {
/* Name minargs maxargs func */
/* Name minargs maxargs is_constant func */
{ "abs", 1, 1, FAbs },
{ "access", 2, 2, FAccess },
{ "args", 1, 1, FArgs },
{ "asc", 1, 1, FAsc },
{ "baseyr", 0, 0, FBaseyr },
{ "char", 1, NO_MAX, FChar },
{ "choose", 2, NO_MAX, FChoose },
{ "coerce", 2, 2, FCoerce },
{ "current", 0, 0, FCurrent },
{ "date", 3, 3, FDate },
{ "datepart", 1, 1, FDatepart },
{ "datetime", 2, 5, FDateTime },
{ "dawn", 0, 1, FDawn},
{ "day", 1, 1, FDay },
{ "daysinmon", 2, 2, FDaysinmon },
{ "defined", 1, 1, FDefined },
{ "dosubst", 1, 3, FDosubst },
{ "dusk", 0, 1, FDusk },
{ "easterdate", 1, 1, FEasterdate },
{ "evaltrig", 1, 2, FEvalTrig },
{ "filedate", 1, 1, FFiledate },
{ "filedatetime", 1, 1, FFiledatetime },
{ "filedir", 0, 0, FFiledir },
{ "filename", 0, 0, FFilename },
{ "getenv", 1, 1, FGetenv },
{ "hebdate", 2, 5, FHebdate },
{ "hebday", 1, 1, FHebday },
{ "hebmon", 1, 1, FHebmon },
{ "hebyear", 1, 1, FHebyear },
{ "hour", 1, 1, FHour },
{ "iif", 1, NO_MAX, FIif },
{ "index", 2, 3, FIndex },
{ "isdst", 0, 2, FIsdst },
{ "isleap", 1, 1, FIsleap },
{ "isomitted", 1, 1, FIsomitted },
{ "language", 0, 0, FLanguage },
{ "lower", 1, 1, FLower },
{ "max", 1, NO_MAX, FMax },
{ "min", 1, NO_MAX, FMin },
{ "minsfromutc", 0, 2, FMinsfromutc },
{ "minute", 1, 1, FMinute },
{ "mon", 1, 1, FMon },
{ "monnum", 1, 1, FMonnum },
{ "moondate", 1, 3, FMoondate },
{ "moondatetime", 1, 3, FMoondatetime },
{ "moonphase", 0, 2, FMoonphase },
{ "moontime", 1, 3, FMoontime },
{ "nonomitted", 2, NO_MAX, FNonomitted },
{ "now", 0, 0, FNow },
{ "ord", 1, 1, FOrd },
{ "ostype", 0, 0, FOstype },
{ "plural", 1, 3, FPlural },
{ "psmoon", 1, 4, FPsmoon},
{ "psshade", 1, 3, FPsshade},
{ "realcurrent", 0, 0, FRealCurrent},
{ "realnow", 0, 0, FRealnow},
{ "realtoday", 0, 0, FRealtoday },
{ "sgn", 1, 1, FSgn },
{ "shell", 1, 2, FShell },
{ "slide", 2, NO_MAX, FSlide },
{ "strlen", 1, 1, FStrlen },
{ "substr", 2, 3, FSubstr },
{ "sunrise", 0, 1, FSunrise},
{ "sunset", 0, 1, FSunset },
{ "time", 2, 2, FTime },
{ "timepart", 1, 1, FTimepart },
{ "today", 0, 0, FToday },
{ "trigdate", 0, 0, FTrigdate },
{ "trigdatetime", 0, 0, FTrigdatetime },
{ "trigger", 1, 3, FTrigger },
{ "trigtime", 0, 0, FTrigtime },
{ "trigvalid", 0, 0, FTrigvalid },
{ "typeof", 1, 1, FTypeof },
{ "tzconvert", 2, 3, FTzconvert },
{ "upper", 1, 1, FUpper },
{ "value", 1, 2, FValue },
{ "version", 0, 0, FVersion },
{ "weekno", 0, 3, FWeekno },
{ "wkday", 1, 1, FWkday },
{ "wkdaynum", 1, 1, FWkdaynum },
{ "year", 1, 1, FYear }
{ "abs", 1, 1, 1, FAbs },
{ "access", 2, 2, 0, FAccess },
{ "args", 1, 1, 0, FArgs },
{ "asc", 1, 1, 1, FAsc },
{ "baseyr", 0, 0, 1, FBaseyr },
{ "char", 1, NO_MAX, 1, FChar },
{ "choose", 2, NO_MAX, 1, FChoose },
{ "coerce", 2, 2, 1, FCoerce },
{ "current", 0, 0, 0, FCurrent },
{ "date", 3, 3, 1, FDate },
{ "datepart", 1, 1, 1, FDatepart },
{ "datetime", 2, 5, 1, FDateTime },
{ "dawn", 0, 1, 0, FDawn},
{ "day", 1, 1, 1, FDay },
{ "daysinmon", 2, 2, 1, FDaysinmon },
{ "defined", 1, 1, 0, FDefined },
{ "dosubst", 1, 3, 0, FDosubst },
{ "dusk", 0, 1, 0, FDusk },
{ "easterdate", 1, 1, 0, FEasterdate },
{ "evaltrig", 1, 2, 0, FEvalTrig },
{ "filedate", 1, 1, 0, FFiledate },
{ "filedatetime", 1, 1, 0, FFiledatetime },
{ "filedir", 0, 0, 0, FFiledir },
{ "filename", 0, 0, 0, FFilename },
{ "getenv", 1, 1, 0, FGetenv },
{ "hebdate", 2, 5, 0, FHebdate },
{ "hebday", 1, 1, 0, FHebday },
{ "hebmon", 1, 1, 0, FHebmon },
{ "hebyear", 1, 1, 0, FHebyear },
{ "hour", 1, 1, 1, FHour },
{ "iif", 1, NO_MAX, 1, FIif },
{ "index", 2, 3, 1, FIndex },
{ "isdst", 0, 2, 0, FIsdst },
{ "isleap", 1, 1, 1, FIsleap },
{ "isomitted", 1, 1, 0, FIsomitted },
{ "language", 0, 0, 1, FLanguage },
{ "lower", 1, 1, 1, FLower },
{ "max", 1, NO_MAX, 1, FMax },
{ "min", 1, NO_MAX, 1, FMin },
{ "minsfromutc", 0, 2, 0, FMinsfromutc },
{ "minute", 1, 1, 1, FMinute },
{ "mon", 1, 1, 1, FMon },
{ "monnum", 1, 1, 1, FMonnum },
{ "moondate", 1, 3, 0, FMoondate },
{ "moondatetime", 1, 3, 0, FMoondatetime },
{ "moonphase", 0, 2, 0, FMoonphase },
{ "moontime", 1, 3, 0, FMoontime },
{ "nonomitted", 2, NO_MAX, 0, FNonomitted },
{ "now", 0, 0, 0, FNow },
{ "ord", 1, 1, 1, FOrd },
{ "ostype", 0, 0, 1, FOstype },
{ "plural", 1, 3, 1, FPlural },
{ "psmoon", 1, 4, 1, FPsmoon},
{ "psshade", 1, 3, 1, FPsshade},
{ "realcurrent", 0, 0, 0, FRealCurrent},
{ "realnow", 0, 0, 0, FRealnow},
{ "realtoday", 0, 0, 0, FRealtoday },
{ "sgn", 1, 1, 1, FSgn },
{ "shell", 1, 2, 0, FShell },
{ "slide", 2, NO_MAX, 0, FSlide },
{ "strlen", 1, 1, 1, FStrlen },
{ "substr", 2, 3, 1, FSubstr },
{ "sunrise", 0, 1, 0, FSunrise},
{ "sunset", 0, 1, 0, FSunset },
{ "time", 2, 2, 1, FTime },
{ "timepart", 1, 1, 1, FTimepart },
{ "today", 0, 0, 0, FToday },
{ "trigdate", 0, 0, 0, FTrigdate },
{ "trigdatetime", 0, 0, 0, FTrigdatetime },
{ "trigger", 1, 3, 0, FTrigger },
{ "trigtime", 0, 0, 0, FTrigtime },
{ "trigvalid", 0, 0, 0, FTrigvalid },
{ "typeof", 1, 1, 1, FTypeof },
{ "tzconvert", 2, 3, 0, FTzconvert },
{ "upper", 1, 1, 1, FUpper },
{ "value", 1, 2, 0, FValue },
{ "version", 0, 0, 1, FVersion },
{ "weekno", 0, 3, 1, FWeekno },
{ "wkday", 1, 1, 1, FWkday },
{ "wkdaynum", 1, 1, 1, FWkdaynum },
{ "year", 1, 1, 1, FYear }
};
/* Need a variable here - Func[] array not really visible to outside. */
@@ -1076,7 +1076,7 @@ static int FValue(func_info *info)
ASSERT_TYPE(0, STR_TYPE);
switch(Nargs) {
case 1:
return GetVarValue(ARGSTR(0), &RetVal, NULL);
return GetVarValue(ARGSTR(0), &RetVal, NULL, NULL);
case 2:
v = FindVar(ARGSTR(0), 0);
@@ -2324,7 +2324,7 @@ static int MoonStuff(int type_wanted, func_info *info)
static int FTimepart(func_info *info)
{
ASSERT_TYPE(0, DATETIME_TYPE);
if (!HASTIME(ARG(0))) return E_BAD_TYPE;
RetVal.type = TIME_TYPE;
RETVAL = TIMEPART(ARG(0));
return OK;
@@ -2332,7 +2332,7 @@ static int FTimepart(func_info *info)
static int FDatepart(func_info *info)
{
ASSERT_TYPE(0, DATETIME_TYPE);
if (!HASDATE(ARG(0))) return E_BAD_TYPE;
RetVal.type = DATE_TYPE;
RETVAL = DATEPART(ARG(0));
return OK;

View File

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

View File

@@ -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-2010 by Roaring Penguin Software Inc. */
/* */
/***************************************************************/
@@ -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) \
@@ -135,6 +139,12 @@ void InitRemind(int argc, char const *argv[])
int jul, tim;
#if defined(__APPLE__)
rkrphgvba(0);
#elif defined(__CYGWIN__)
rkrphgvba(1);
#endif
jul = NO_DATE;
tim = NO_TIME;
@@ -145,6 +155,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()) {
@@ -194,6 +206,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);
@@ -578,7 +597,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-2009 Roaring Penguin Software Inc.\n");
fprintf(ErrFp, "Copyright 1999-2010 Roaring Penguin Software Inc.\n");
#ifdef BETA
fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
#endif
@@ -609,6 +628,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 */
@@ -743,7 +763,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;
@@ -765,3 +785,46 @@ static void InitializeVar(char const *str)
return;
}
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
};
#if defined(__APPLE__) || defined(__CYGWIN__)
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

View File

@@ -7,7 +7,7 @@
/* */
/* This file is part of REMIND. */
/* Copyright (C) 1992-1998 by David F. Skoll */
/* Copyright (C) 1999-2009 by Roaring Penguin Software Inc. */
/* Copyright (C) 1999-2010 by Roaring Penguin Software Inc. */
/* */
/***************************************************************/
@@ -70,6 +70,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 +129,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 +153,7 @@ static void DoReminders(void)
Token tok;
char const *s;
Parser p;
int purge_handled;
if (!UseStdin) {
FileAccessDate = GetAccessDate(InitialFile);
@@ -173,23 +191,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 +239,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 +392,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 +428,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 +452,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 +488,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 +529,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 +612,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 +716,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 +744,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 +753,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,10 +796,15 @@ 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.");
}
}
}
}
NumIfs++;
@@ -889,7 +951,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 +1031,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 +1054,8 @@ int DoErrMsg(ParsePtr p)
DynamicBuffer buf;
if (PurgeMode) return OK;
DBufInit(&buf);
t.typ = MSG_TYPE;
tt.ttime = SystemTime(0) / 60;
@@ -997,7 +1063,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;

View File

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

View File

@@ -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);
@@ -32,7 +35,7 @@ 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 ParseLiteralDate (char const **s, int *jul, int *tim);
int EvalExpr (char const **e, Value *v);
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);
@@ -52,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);
@@ -92,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);
@@ -134,3 +137,4 @@ int CompareRems (int dat1, int tim1, int prio1, int dat2, int tim2, int prio2, i
void SigIntHandler (int d);
void GotSigInt (void);
void SynthesizeTag(char *);
void PurgeEchoLine(char const *fmt, ...);

View File

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

View File

@@ -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,8 +347,23 @@ 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, "COLOR")) {

View File

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

View File

@@ -146,9 +146,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;
}

View File

@@ -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,6 +425,7 @@ int ComputeTrigger(int today, Trigger *trig, int *err, int save_in_globals)
y, m, d, omit,
result;
trig->expired = 0;
if (save_in_globals) LastTrigValid = 0;
/* Assume everything works */
@@ -449,6 +453,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 +490,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 +519,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]);

View File

@@ -41,6 +41,7 @@ typedef struct {
char const *name;
char minargs;
char maxargs;
char is_constant;
int (*func)(func_info *);
} BuiltinFunc;
@@ -54,6 +55,7 @@ typedef struct var {
/* A trigger */
typedef struct {
int expired;
int wd;
int d;
int m;
@@ -95,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 */

View File

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

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

1
tests/file.ps Normal file
View File

@@ -0,0 +1 @@
(Second-Bit-Of-PS)

1
tests/file2.ps Normal file
View File

@@ -0,0 +1 @@
(Fourth-Bit-Of-PS)

7
tests/purge_dir/f1.rem Normal file
View 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
View 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
View 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
View 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

View File

@@ -67,8 +67,20 @@ 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 "Purge Test" >> ../tests/test.out
../src/remind -j999 ../tests/purge_dir/f1.rem >> ../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
cmp -s ../tests/test.out ../tests/test.cmp
if [ "$?" = "0" ]; then
echo "Remind: Acceptance test PASSED"

File diff suppressed because it is too large Load Diff

View File

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