Compare commits

...

16 Commits

Author SHA1 Message Date
Dianne Skoll
e6a4f939a3 Add brackets. 2021-12-29 20:51:01 -05:00
Dianne Skoll
c7ae214853 Remove comment. 2021-12-29 20:44:46 -05:00
Dianne Skoll
68a9cc047e Add tests for deprecation messages. 2021-12-29 10:42:30 -05:00
Dianne Skoll
1f2b25f852 Write options to a temporary file and then rename 2021-12-28 21:14:33 -05:00
Dianne Skoll
20040c8857 Update WHATSNEW 2021-12-28 21:05:13 -05:00
Dianne Skoll
ac64b0c11f Fix option descriptor. 2021-12-28 21:03:30 -05:00
Dianne Skoll
ba47ce7ca8 Make TkRemind remember printer settings. 2021-12-28 21:02:33 -05:00
Dianne Skoll
be1ab4ea36 Properly support '-i$Latitude="x.yyy"' 2021-12-28 17:56:31 -05:00
Dianne Skoll
13cd9f3d04 Fix memory leak. 2021-12-28 17:53:41 -05:00
Dianne Skoll
8e1f82de5f Get rid of _back function definition (not needed) 2021-12-28 16:59:19 -05:00
Dianne Skoll
8631ad3122 Sort function names alphabetically. 2021-12-28 15:31:03 -05:00
Dianne Skoll
90e6aef9d7 Set default location in custom.h 2021-12-28 15:26:59 -05:00
Dianne Skoll
698190fb72 Set default location right on Parliament Hill. 2021-12-28 15:25:32 -05:00
Dianne Skoll
27cfaa9404 Refactor common code in setting latitude/longitude vars 2021-12-28 14:02:07 -05:00
Dianne Skoll
9f296fe76d Update docs 2021-12-28 10:47:21 -05:00
Dianne Skoll
d0112adb08 Sleep with higher precision in -z0 mode. 2021-12-28 10:32:06 -05:00
12 changed files with 201 additions and 226 deletions

View File

@@ -2,15 +2,10 @@ CHANGES TO REMIND
* VERSION 3.3 Patch 11 - 2021-12-30
- IMPROVEMENT: TkRemind: Save the print dialog settings so they persist.
- IMPROVEMENT: TkRemind: Show queue in sorted order.
- NEW FUNCTION: Remind: Add the isany() built-in function.
- IMPROVEMENT: rem2html: Add class names indicating number of rows in calendar
- IMPROVEMENT: rem2html: Coalesce table.rem-cal CSS into one block. Thanks
to Ian! D. Allen for pointing this out.
- IMPROVEMENT: TkRemind: Pass "-r" flag to inotifywait
- IMPROVEMENT: TkRemind: Draw moon phases with Tk canvas items rather than
@@ -21,6 +16,16 @@ CHANGES TO REMIND
them; fire up the editor with either Button-1 or Button-3 for
non-TkRemind-generated reminders.
- NEW FUNCTION: Remind: Add the isany() built-in function.
- IMPROVEMENT: rem2html: Add class names indicating number of rows in calendar
- IMPROVEMENT: remind: In -z0 mode, sleep with higher precision to ensure we
wake as close to possible to each 1-minute boundary.
- IMPROVEMENT: rem2html: Coalesce table.rem-cal CSS into one block. Thanks
to Ian! D. Allen for pointing this out.
- IMPROVEMENT: examples/defs.rem: Modernize the examples and get rid of some
cruft.

View File

@@ -92,9 +92,6 @@ SET Week_3 15
SET Week_4 22
FSET _last(mo) "1 " + MON((mo%12)+1) + " --7"
# Handy function to provide SCANFROM dates...
FSET _back(days) $U-days
#################################################################
# Function that removes a single leading zero from a string... #
#################################################################
@@ -134,7 +131,7 @@ REM 1 MSG John's [_mo_num(11, 1984)] 'monthly' anniversary
############################################################################
# Calculate the weekday of the holiday.
REM 4 July SCANFROM [_back(7)] SATISFY 1
REM 4 July SCANFROM -7 SATISFY 1
SET iday $T
IF WKDAYNUM(iday) == Sat
@@ -216,15 +213,14 @@ REM [easter+39] MSG %"Ascension Day%"
REM [easter+49] MSG %"Pentecost%"
# Some holidays are omitted, some are not. You may want to change
# which ones are omitted - use the general forms shown below.
# You'll need the _back() function and the Week_n variables defined
# way up in the file.
# which ones are omitted - use the general forms shown below. You'll
# need the Week_n variables defined way up in the file.
OMIT Jan 1 MSG %"New Year's%" Day
REM Mon Jan [Week_3] MSG Martin Luther King - %"MLK Day%"
REM Feb 2 MSG %"Ground Hog Day%"
REM Feb 14 MSG %"Valentine's%" Day
REM Mon Feb [Week_3] SCANFROM [_back(7)] ADDOMIT MSG %"President's Day%"
REM Mon Feb [Week_3] SCANFROM -7 ADDOMIT MSG %"President's Day%"
REM Mar 17 MSG %"St. Patrick's%" Day
# The DST rules are accurate for most locations in
@@ -241,18 +237,18 @@ REM May 5 MSG %"Cinco de Mayo%"
REM Sat May [Week_1] MSG %"Kentucky Derby%"
REM Sun May [Week_2] MSG %"Mother's Day%"
REM Sat May [Week_3] MSG %"Armed Forces Day%"
REM Mon [_last(May)] SCANFROM [_back(7)] ADDOMIT MSG %"Memorial Day%"
REM Mon [_last(May)] SCANFROM -7 ADDOMIT MSG %"Memorial Day%"
REM Jun 14 MSG %"Flag Day%"
REM Sun Jun [Week_3] MSG %"Father's Day%"
REM Mon Sep [Week_1] SCANFROM [_back(7)] ADDOMIT MSG %"Labor Day%"
REM Mon Sep [Week_1] SCANFROM -7 ADDOMIT MSG %"Labor Day%"
REM Mon Oct [Week_2] MSG %"Columbus Day%"
REM Nov 11 MSG %"Veterans Day%"
REM Oct 30 MSG %"Mischief Night%"
REM Oct 31 MSG %"Halloween%"
REM Tue Nov 2 SCANFROM [_back(7)] SATISFY [($Ty % 4) == 0] MSG %"Election Day%"
REM Thu Nov [Week_4] SCANFROM [_back(7)] ADDOMIT MSG %"Thanksgiving Day%"
REM Fri Nov [Week_4+1] SCANFROM [_back(7)] ADDOMIT MSG %"Thanksgiving (cont.)%"
REM Tue Nov 2 SCANFROM -7 SATISFY [($Ty % 4) == 0] MSG %"Election Day%"
REM Thu Nov [Week_4] SCANFROM -7 ADDOMIT MSG %"Thanksgiving Day%"
REM Fri Nov [Week_4+1] SCANFROM -7 ADDOMIT MSG %"Thanksgiving (cont.)%"
OMIT Dec 24 MSG %"Christmas Eve%"
OMIT Dec 25 MSG %"Christmas%" Day

View File

@@ -2389,21 +2389,6 @@ $TimeSep and $DateTimeSep when formatting its output. For example:
.PP
.RE
.TP
.B isany(arg1 [,arg2, ..., argN]);
Returns 1 if the first argument \fIarg1\fR is equal to any of the
subsequent arguments \fIarg2\fR through \fIargN\fR; returns 0 otherwise.
Also returns 0 if called with only one argument.
.RS
.PP
As an example, the following two expressions are equivalent:
.PP
.nf
(a == b) || (a == c) || (a == d) || (a == e)
isany(a, b, c, d, e)
.fi
.RE
.TP
.B args(s_fname)
Returns the number of arguments expected by the user-defined function
\fIfname\fR, or \-1 if no such user-defined function exists. Note that
@@ -2683,6 +2668,21 @@ The optional parameter \fIstart\fR specifies the position in
\fIsearch\fR at which to start looking for \fItarget\fR.
.RE
.TP
.B isany(arg1 [,arg2, ..., argN]);
Returns 1 if the first argument \fIarg1\fR is equal to any of the
subsequent arguments \fIarg2\fR through \fIargN\fR; returns 0 otherwise.
Also returns 0 if called with only one argument.
.RS
.PP
As an example, the following two expressions are equivalent:
.PP
.nf
(a == b) || (a == c) || (a == d) || (a == e)
isany(a, b, c, d, e)
.fi
.RE
.TP
.B isdst([d_date [,t_time]]) \fRor\fB isdst(q_datetime)
Returns a positive number if daylight saving time is in
effect on the specified date and time. \fIDate\fR

View File

@@ -137,7 +137,6 @@ set TimerUpdateForChanges ""
# Remind program to execute -- supply full path if you want
set Remind "remind"
#set Remind "/home/dfs/Remind/src/remind"
# Rem2PS program to execute -- supply full path if you want
set Rem2PS "rem2ps"
@@ -200,14 +199,29 @@ set PSCmd {}
# Print options -- destination file; letter-size; landscape; fill page; default
# encoding; 36pt margins; print small calendars
set PrintDest file
set PrintSize letter
set PrintOrient landscape
set PrintFill 1
set PrintDaysRight 1
set PrintEncoding 0
set PrintMargins 36pt
set PrintSmallCalendars 1
set OptDescr(PrintDest) "Print destination: file or command"
set Option(PrintDest) file
set OptDescr(PrintSize) "Page size: a4 or letter"
set Option(PrintSize) letter
set OptDescr(PrintOrient) "Page orientation: portrait or landscape"
set Option(PrintOrient) landscape
set OptDescr(PrintFill) "(0/1) If 1, fill entire page when printing"
set Option(PrintFill) 1
set OptDescr(PrintDaysRight) "(0/1) If 1, put day numbers in the top-right of each calendar box"
set Option(PrintDaysRight) 1
set OptDescr(PrintEncoding) "(0/1) If 1, apply ISO-8859-1 encoding to PostScript output"
set Option(PrintEncoding) 0
set OptDescr(PrintMargins) "Print margins: One of 24pt, 36pt or 48pt"
set Option(PrintMargins) 36pt
set OptDescr(PrintSmallCalendars) "(0/1) If 1, print small calendars in PostScript output"
set Option(PrintSmallCalendars) 1
set WarningHeaders [list "# Lines staring with REM TAG TKTAGnnn ... were created by tkremind" "# Do not edit them by hand or results may be unpredictable."]
@@ -829,27 +843,9 @@ proc ApplyOptions { w } {
# Saves options in specified config file
#***********************************************************************
proc SaveOptions { w } {
global Option OptDescr ConfigFile
global Option OptDescr
ApplyOptions $w
set problem [catch {set f [open $ConfigFile "w"]} err]
if {$problem} {
tk_dialog .error Error "Can't write $ConfigFile: $err" 0 OK
return
}
puts $f "# TkRemind option file -- created automatically"
puts $f "# [clock format [clock seconds]]"
puts $f "# Format of each line is 'key value' where 'key'"
puts $f "# specifies the option name, and 'value' is a"
puts $f "# *legal Tcl list element* specifying the option value."
foreach name [lsort [array names Option]] {
puts $f ""
puts $f "# $OptDescr($name)"
puts $f [list $name $Option($name)]
}
puts $f ""
close $f
WriteOptionsToFile
FillCalWindow
.h.title configure -background $Option(WinBackground) -foreground $Option(LabelColor)
for {set i 0} {$i < 7} {incr i} {
@@ -868,6 +864,30 @@ proc SaveOptions { w } {
.b.options configure -foreground $Option(LabelColor) -background $Option(WinBackground)
}
proc WriteOptionsToFile {} {
global ConfigFile
global Option OptDescr
set problem [catch {set f [open "$ConfigFile.tmp" "w"]} err]
if {$problem} {
tk_dialog .error Error "Can't write $ConfigFile.tmp: $err" 0 OK
return
}
puts $f "# TkRemind option file -- created automatically"
puts $f "# [clock format [clock seconds]]"
puts $f "# Format of each line is 'key value' where 'key'"
puts $f "# specifies the option name, and 'value' is a"
puts $f "# *legal Tcl list element* specifying the option value."
foreach name [lsort [array names Option]] {
puts $f ""
puts $f "# $OptDescr($name)"
puts $f [list $name $Option($name)]
}
puts $f ""
close $f
file rename -force "$ConfigFile.tmp" $ConfigFile
}
#***********************************************************************
# %PROCEDURE: LoadOptions
# %ARGUMENTS:
@@ -1130,7 +1150,7 @@ proc Status { stuff } {
# None
#---------------------------------------------------------------------------
proc DoPrint {} {
global PrintDest PrintSize PrintMargins PrintOrient PrintFill PrintDaysRight PrintEncoding PrintSmallCalendars PrintStatus Rem2PS PSCmd Option
global Rem2PS PSCmd Option PrintStatus
global CurMonth CurYear MonthNames
catch {destroy .p}
toplevel .p
@@ -1145,30 +1165,30 @@ proc DoPrint {} {
frame .p.f3a -relief sunken -border 2
frame .p.f4
radiobutton .p.tofile -text "To file: " -variable PrintDest -value file
radiobutton .p.tofile -text "To file: " -variable Option(PrintDest) -value file
entry .p.filename
button .p.browse -text "Browse..." -command PrintFileBrowse
radiobutton .p.tocmd -text "To command: " -variable PrintDest -value command
radiobutton .p.tocmd -text "To command: " -variable Option(PrintDest) -value command
entry .p.command
.p.command insert end "lpr"
label .p.size -text "Paper Size:"
radiobutton .p.letter -text "Letter" -variable PrintSize -value letter
radiobutton .p.a4 -text "A4" -variable PrintSize -value a4
radiobutton .p.letter -text "Letter" -variable Option(PrintSize) -value letter
radiobutton .p.a4 -text "A4" -variable Option(PrintSize) -value a4
label .p.margin -text "Margins:"
radiobutton .p.24pt -text "24pt margins" -variable PrintMargins -value 24pt
radiobutton .p.36pt -text "36pt margins" -variable PrintMargins -value 36pt
radiobutton .p.48pt -text "48pt margins" -variable PrintMargins -value 48pt
radiobutton .p.24pt -text "24pt margins" -variable Option(PrintMargins) -value 24pt
radiobutton .p.36pt -text "36pt margins" -variable Option(PrintMargins) -value 36pt
radiobutton .p.48pt -text "48pt margins" -variable Option(PrintMargins) -value 48pt
label .p.orient -text "Orientation:"
radiobutton .p.landscape -text "Landscape" -variable PrintOrient -value landscape
radiobutton .p.portrait -text "Portrait" -variable PrintOrient -value portrait
radiobutton .p.landscape -text "Landscape" -variable Option(PrintOrient) -value landscape
radiobutton .p.portrait -text "Portrait" -variable Option(PrintOrient) -value portrait
checkbutton .p.fill -text "Fill page" -variable PrintFill
checkbutton .p.right -text "Day numbers at top-right" -variable PrintDaysRight
checkbutton .p.encoding -text "ISO 8859-1 PostScript encoding" -variable PrintEncoding
checkbutton .p.calendars -text "Print small calendars" -variable PrintSmallCalendars
checkbutton .p.fill -text "Fill page" -variable Option(PrintFill)
checkbutton .p.right -text "Day numbers at top-right" -variable Option(PrintDaysRight)
checkbutton .p.encoding -text "ISO 8859-1 PostScript encoding" -variable Option(PrintEncoding)
checkbutton .p.calendars -text "Print small calendars" -variable Option(PrintSmallCalendars)
button .p.print -text "Print" -command {set PrintStatus print}
button .p.cancel -text "Cancel" -command {set PrintStatus cancel}
@@ -1202,7 +1222,8 @@ proc DoPrint {} {
if {$PrintStatus == "cancel"} {
return
}
if {$PrintDest == "file"} {
WriteOptionsToFile
if {$Option(PrintDest) == "file"} {
if {$fname == ""} {
tk_dialog .error Error "No filename specified" error 0 Ok
return
@@ -1225,36 +1246,36 @@ proc DoPrint {} {
# Build the command line
set p [regsub EXTRA $PSCmd $Option(ExtraRemindArgs)]
set cmd "$p 1 [lindex $MonthNames $CurMonth] $CurYear | $Rem2PS"
if {$PrintSize == "letter"} {
if {$Option(PrintSize) == "letter"} {
append cmd " -m Letter"
} else {
append cmd " -m A4"
}
if {$PrintMargins == "24pt"} {
if {$Option(PrintMargins) == "24pt"} {
append cmd " -or 24 -ol 24 -ot 24 -ob 24"
} elseif {$PrintMargins == "36pt"} {
} elseif {$Option(PrintMargins) == "36pt"} {
append cmd " -or 36 -ol 36 -ot 36 -ob 36"
} else {
append cmd " -or 48 -ol 48 -ot 48 -ob 48"
}
if {$PrintOrient == "landscape"} {
if {$Option(PrintOrient) == "landscape"} {
append cmd " -l"
}
if {$PrintFill} {
if {$Option(PrintFill)} {
append cmd " -e"
}
if {!$PrintDaysRight} {
if {!$Option(PrintDaysRight)} {
append cmd " -x"
}
if {$PrintEncoding} {
if {$Option(PrintEncoding)} {
append cmd " -i"
}
if {$PrintSmallCalendars} {
if {$Option(PrintSmallCalendars)} {
append cmd " -c3"
} else {
append cmd " -c0"

View File

@@ -22,11 +22,11 @@
/* The default values are initially set to Ottawa, Ontario, Canada. */
/*---------------------------------------------------------------------*/
#define LAT_DEG 45
#define LAT_MIN 24
#define LAT_SEC 0
#define LAT_MIN 25
#define LAT_SEC 30
#define LON_DEG 75
#define LON_MIN 39
#define LON_SEC 0
#define LON_MIN 41
#define LON_SEC 59
#define LOCATION "Ottawa"
/*---------------------------------------------------------------------*/

View File

@@ -22,11 +22,11 @@
/* The default values are initially set to Ottawa, Ontario, Canada. */
/*---------------------------------------------------------------------*/
#define LAT_DEG 45
#define LAT_MIN 24
#define LAT_SEC 0
#define LAT_MIN 25
#define LAT_SEC 30
#define LON_DEG 75
#define LON_MIN 39
#define LON_SEC 0
#define LON_MIN 41
#define LON_SEC 59
#define LOCATION "Ottawa"
/*---------------------------------------------------------------------*/

View File

@@ -411,8 +411,9 @@ static int RetStrVal(char const *s, func_info *info)
if (!s) {
RetVal.v.str = malloc(1);
if (RetVal.v.str) *RetVal.v.str = 0;
} else
} else {
RetVal.v.str = StrDup(s);
}
if (!RetVal.v.str) {
RetVal.type = ERR_TYPE;
@@ -2400,6 +2401,7 @@ static int FPsshade(func_info *info)
if (!psshade_warned) {
psshade_warned = 1;
Eprint("psshade() is deprecated; use SPECIAL SHADE instead.");
FreshLine = 1;
}
sprintf(s, "/_A LineWidth 2 div def ");
@@ -2455,6 +2457,7 @@ static int FPsmoon(func_info *info)
if (!psmoon_warned) {
psmoon_warned = 1;
Eprint("psmoon() is deprecated; use SPECIAL MOON instead.");
FreshLine = 1;
}
if (size > 0) {
sprintf(sizebuf, "%d", size);

View File

@@ -193,6 +193,9 @@ void InitRemind(int argc, char const *argv[])
JulianToday = RealToday;
FromJulian(JulianToday, &CurYear, &CurMon, &CurDay);
/* Initialize Latitude and Longitude */
set_lat_and_long_from_components();
/* See if we were invoked as "rem" rather than "remind" */
if (argv[0]) {
s = strrchr(argv[0], '/');
@@ -647,7 +650,6 @@ void InitRemind(int argc, char const *argv[])
}
set_lat_and_long_from_components();
/* Figure out the offset from UTC */
if (CalculateUTC)
(void) CalcMinsFromUTC(JulianToday, SystemTime(0)/60,
@@ -848,6 +850,7 @@ static void InitializeVar(char const *str)
if (*varname == '$') {
r=SetSysVar(varname+1, &val);
DestroyValue(val);
if (r) fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[r]);
return;
}

View File

@@ -57,7 +57,7 @@ static void CheckInitialFile (void);
static int CalculateNextTime (QueuedRem *q);
static QueuedRem *FindNextReminder (void);
static int CalculateNextTimeUsingSched (QueuedRem *q);
static void DaemonWait (unsigned int sleeptime);
static void DaemonWait (struct timeval *sleep_tv);
static void reread (void);
/***************************************************************/
@@ -121,6 +121,8 @@ void HandleQueuedReminders(void)
unsigned SleepTime;
Parser p;
Trigger trig;
struct timeval tv;
struct timeval sleep_tv;
/* Suppress the BANNER from being issued */
NumTriggered = 1;
@@ -186,16 +188,20 @@ void HandleQueuedReminders(void)
/* Wake up once a minute to recalibrate sleep time in
case of laptop hibernation */
if (Daemon <= 0) {
if (Daemon < 0) {
/* Wake up on the next exact minute */
SleepTime = 60 - (SystemTime(1)%60);
}
if (Daemon >= 0) {
sleep(SleepTime);
gettimeofday(&tv, NULL);
sleep_tv.tv_sec = 60 - (tv.tv_sec % 60);
if (tv.tv_usec != 0 && sleep_tv.tv_sec != 0) {
sleep_tv.tv_sec--;
sleep_tv.tv_usec = 1000000 - tv.tv_usec;
} else {
sleep_tv.tv_usec = 0;
}
DaemonWait(&sleep_tv);
} else {
DaemonWait(SleepTime);
}
sleep(SleepTime);
}
/* If not in daemon mode and day has rolled around,
exit -- not much we can do. */
@@ -519,19 +525,16 @@ json_queue(QueuedRem const *q)
/* Sleep or read command from stdin in "daemon -1" mode */
/* */
/***************************************************************/
static void DaemonWait(unsigned int sleeptime)
static void DaemonWait(struct timeval *sleep_tv)
{
fd_set readSet;
struct timeval timeout;
int retval;
int y, m, d;
char cmdLine[256];
FD_ZERO(&readSet);
FD_SET(0, &readSet);
timeout.tv_sec = sleeptime;
timeout.tv_usec = 0;
retval = select(1, &readSet, NULL, NULL, &timeout);
retval = select(1, &readSet, NULL, NULL, sleep_tv);
/* If date has rolled around, restart */
if (RealToday != SystemDate(&y, &m, &d)) {

162
src/var.c
View File

@@ -48,159 +48,88 @@ static void deprecated_var(char const *var, char const *instead)
}
}
static int latdeg_func(int do_set, Value *val)
static int latlong_component_func(int do_set, Value *val, int *var, int min, int max, char const *varname, char const *newvarname)
{
if (!do_set) {
val->type = INT_TYPE;
val->v.val = LatDeg;
val->v.val = *var;
return OK;
}
deprecated_var("$LatDeg", "$Latitude");
deprecated_var(varname, newvarname);
if (val->type != INT_TYPE) return E_BAD_TYPE;
if (val->v.val < -90) return E_2LOW;
if (val->v.val > 90) return E_2HIGH;
LatDeg = val->v.val;
if (val->v.val < min) return E_2LOW;
if (val->v.val > max) return E_2HIGH;
*var = val->v.val;
set_lat_and_long_from_components();
return OK;
}
static int latdeg_func(int do_set, Value *val)
{
return latlong_component_func(do_set, val, &LatDeg, -90, 90, "$LatDeg", "$Latitude");
}
static int latmin_func(int do_set, Value *val)
{
if (!do_set) {
val->type = INT_TYPE;
val->v.val = LatMin;
return OK;
}
deprecated_var("$LatMin", "$Latitude");
if (val->type != INT_TYPE) return E_BAD_TYPE;
if (val->v.val < -59) return E_2LOW;
if (val->v.val > 59) return E_2HIGH;
LatMin = val->v.val;
set_lat_and_long_from_components();
return OK;
return latlong_component_func(do_set, val, &LatMin, -59, 59, "$LatMin", "$Latitude");
}
static int latsec_func(int do_set, Value *val)
{
if (!do_set) {
val->type = INT_TYPE;
val->v.val = LatSec;
return OK;
}
deprecated_var("$LatSec", "$Latitude");
if (val->type != INT_TYPE) return E_BAD_TYPE;
if (val->v.val < -59) return E_2LOW;
if (val->v.val > 59) return E_2HIGH;
LatSec = val->v.val;
set_lat_and_long_from_components();
return OK;
return latlong_component_func(do_set, val, &LatSec, -59, 59, "$LatSec", "$Latitude");
}
static int longdeg_func(int do_set, Value *val)
{
if (!do_set) {
val->type = INT_TYPE;
val->v.val = LongDeg;
return OK;
}
deprecated_var("$LongDeg", "$Longitude");
if (val->type != INT_TYPE) return E_BAD_TYPE;
if (val->v.val < -180) return E_2LOW;
if (val->v.val > 180) return E_2HIGH;
LongDeg = val->v.val;
set_lat_and_long_from_components();
return OK;
return latlong_component_func(do_set, val, &LongDeg, -180, 180, "$LongDeg", "$Longitude");
}
static int longmin_func(int do_set, Value *val)
{
if (!do_set) {
val->type = INT_TYPE;
val->v.val = LongMin;
return OK;
}
deprecated_var("$LongMin", "$Longitude");
if (val->type != INT_TYPE) return E_BAD_TYPE;
if (val->v.val < -59) return E_2LOW;
if (val->v.val > 59) return E_2HIGH;
LongMin = val->v.val;
set_lat_and_long_from_components();
return OK;
return latlong_component_func(do_set, val, &LongMin, -59, 59, "$LongMin", "$Longitude");
}
static int longsec_func(int do_set, Value *val)
{
return latlong_component_func(do_set, val, &LongSec, -59, 59, "$LongSec", "$Longitude");
}
static int latitude_longitude_func(int do_set, Value *val, double *var, double min, double max) {
char buf[64];
double x;
char *endptr;
if (!do_set) {
val->type = INT_TYPE;
val->v.val = LongSec;
snprintf(buf, sizeof(buf), "%f", *var);
val->v.str = malloc(strlen(buf)+1);
if (!val->v.str) return E_NO_MEM;
strcpy(val->v.str, buf);
val->type = STR_TYPE;
return OK;
}
deprecated_var("$LongSec", "$Longitude");
if (val->type != INT_TYPE) return E_BAD_TYPE;
if (val->v.val < -59) return E_2LOW;
if (val->v.val > 59) return E_2HIGH;
LongSec = val->v.val;
set_lat_and_long_from_components();
if (val->type == INT_TYPE) {
x = (double) val->v.val;
} else {
if (val->type != STR_TYPE) return E_BAD_TYPE;
errno = 0;
x = strtod(val->v.str, &endptr);
if (errno) return E_BAD_TYPE;
if (*endptr) return E_BAD_TYPE;
}
if (x < min) return E_2LOW;
if (x > max) return E_2HIGH;
*var = x;
set_components_from_lat_and_long();
return OK;
}
static int longitude_func(int do_set, Value *val)
{
char buf[64];
double x;
char *endptr;
if (!do_set) {
snprintf(buf, sizeof(buf), "%f", Longitude);
val->v.str = malloc(strlen(buf)+1);
if (!val->v.str) return E_NO_MEM;
strcpy(val->v.str, buf);
val->type = STR_TYPE;
return OK;
}
if (val->type == INT_TYPE) {
x = (double) val->v.val;
} else {
if (val->type != STR_TYPE) return E_BAD_TYPE;
errno = 0;
x = strtod(val->v.str, &endptr);
if (errno) return E_BAD_TYPE;
if (*endptr) return E_BAD_TYPE;
}
if (x < -180.0) return E_2LOW;
if (x > 180.0) return E_2HIGH;
Longitude = x;
set_components_from_lat_and_long();
return OK;
return latitude_longitude_func(do_set, val, &Longitude, -180.0, 180.0);
}
static int latitude_func(int do_set, Value *val)
{
char buf[64];
double x;
char *endptr;
if (!do_set) {
snprintf(buf, sizeof(buf), "%f", Latitude);
val->v.str = malloc(strlen(buf)+1);
if (!val->v.str) return E_NO_MEM;
strcpy(val->v.str, buf);
val->type = STR_TYPE;
return OK;
}
if (val->type == INT_TYPE) {
x = (double) val->v.val;
} else {
if (val->type != STR_TYPE) return E_BAD_TYPE;
errno = 0;
x = strtod(val->v.str, &endptr);
if (errno) return E_BAD_TYPE;
if (*endptr) return E_BAD_TYPE;
}
if (x < -90.0) return E_2LOW;
if (x > 90.0) return E_2HIGH;
Latitude = x;
set_components_from_lat_and_long();
return OK;
return latitude_longitude_func(do_set, val, &Latitude, -90.0, 90.0);
}
@@ -881,6 +810,7 @@ static void DumpSysVar (char const *name, const SysVar *v);
/***************************************************************/
int SetSysVar(char const *name, Value *value)
{
int r;
SysVar *v = FindSysVar(name);
if (!v) return E_NOSUCH_VAR;
if (v->type != SPECIAL_TYPE &&
@@ -892,7 +822,9 @@ int SetSysVar(char const *name, Value *value)
if (v->type == SPECIAL_TYPE) {
SysVarFunc f = (SysVarFunc) v->value;
return f(1, value);
r = f(1, value);
DestroyValue(*value);
return r;
} else if (v->type == STR_TYPE) {
/* If it's a string variable, special measures must be taken */
if (v->been_malloced) free(*((char **)(v->value)));

View File

@@ -3385,6 +3385,14 @@ a => "\ \!\"\#\$\%\%\&\'\(\)\*+,-./0123456789\"...
\ \!\"\#\$\\\&\'\(\)\*+,-./0123456789\:\;\<=\>\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\[\\\]\^_\`abcdefghijklmnopqrstuvwxyz\{\|\}\~
# Deprecated functions
set x psshade(50)
psshade(50) => ../tests/test.rem(637): psshade() is deprecated; use SPECIAL SHADE instead.
"/_A LineWidth 2 div def _A _A moveto Box"...
set x psmoon(0)
psmoon(0) => ../tests/test.rem(638): psmoon() is deprecated; use SPECIAL MOON instead.
"gsave 0 setgray newpath Border DaySize 2"...
# Don't want Remind to queue reminders
EXIT

View File

@@ -633,6 +633,10 @@ set a shellescape(" !\"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ
msg [a]
# Deprecated functions
set x psshade(50)
set x psmoon(0)
# Don't want Remind to queue reminders
EXIT