home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3862
< prev
next >
Wrap
Internet Message Format
|
1991-08-22
|
49KB
Path: wupost!cs.utexas.edu!uwm.edu!linac!att!cbnews!jbr0
From: jbr0@cbnews.cb.att.com (joseph.a.brownlee)
Newsgroups: alt.sources
Subject: Pcal v4.1, part 2 of 6
Keywords: pcal calendar postscript
Message-ID: <1991Aug19.121327.445@cbnews.cb.att.com>
Date: 19 Aug 91 12:13:27 GMT
Followup-To: alt.sources.d
Organization: AT&T Bell Laboratories
Lines: 1387
#!/bin/sh
# This is part 02 of a multipart archive
# ============= Pcal.hlp ==============
if test -f 'Pcal.hlp' -a X"$1" != X"-c"; then
echo 'x - skipping Pcal.hlp (File already exists)'
else
echo 'x - extracting Pcal.hlp (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'Pcal.hlp' &&
1 PCAL
X Pcal generates PostScript to produce landscape or portrait
X calendars for any month and year. The arguments month,year, and
X nmonths, if provided, should be numeric. The month value should
X be in the range 1 - 12, and the year value should be specified as
X 1 or 2 digits or as the full 4 digit year. If no numeric
X arguments are provided, the calendar for the current month and
X year will be generated.
X
X If one numeric argument is provided, it is interpreted as the
X year value, and calendars for the entire year will be generated.
X Otherwise, nmonth months, starting with month and year, will be
X generated.
X
X For whole-year calendars (i.e. the -w option is given), the
X command line arguments are interpreted somewhat differently. By
X default, all months in the current year are printed, starting with
X January. If the month argument alone is given, it is expected to
X be the desired year to print, and prints all of the months in the
X given year. If both month and year are given, then 12 consecutive
X months are printed starting at the given month and year. If the
X month, year, and nmonths arguments are all present, printing
X begins with the given month and year and nmonths months are
X printed, rounded up to the nearest multiple of 12.
X
X VMS Version
X Execution format:
X
X pcal [options] [mm yy] [n]
X
2 Parameters
X mm yy n
X "mm" and "yy" are numeric values of the month (1-12) and year
X (0-99) (i.e., July 1990 would be 7 90). If you just include the
X "yy" option, an entire 12 months of calendars will be generated.
X A specific month can be produced by including the "mm" parameter.
X The "n" parameter will produce the "n" consecutive months of
X calendars starting with the requested month.
X
X The following flags may be specified (in increasing order of
X precedence) in global symbol PCAL_OPTS, in "opt" lines in the date
X file (all but -e, -f, -h, -v, -"D", -"U"), or on the command line.
X Any flag which normally takes an argument may be specified without
X the argument; this resets its value to the program default.
X (-"D" alone thus clears all defined symbols; -"U" alone has no
X effect.)
X
X The "-" flag has been added to disambiguate cases where an
X argument-less flag has been specified immediately before a numeric
X parameter:
X
X pcal -t - 9 90
X
2 Options
X Pcal accepts several command line options (or from the
X CALENDAR.DAT file). The uppercase options should be enclosed in
X quotes as pcal is case-sensitive and the VMS command line parser
X will convert the string to upper case otherwise. The quoted
X strings are not needed if the options are included within the
X CALENDAR.DAT file.
X
3 -e
X Print an empty calendar (i.e., do not print entries from a
X CALENDAR.DAT file.)
X
3 -f <FILE>
X Directs pcal to use the file name <FILE> as the input file in
X place of the default CALENDAR.DAT file in the callers home
X directory or in the directory specified by logical name PCAL_DIR.
X
3 -o <FILE>
X Directs pcal to write the PostScript calendar into FILE
X (default: CALENDAR.PS in the current directory.)
X
3 -j
X Directs pcal to print the Julian (Day Of Year, DOY) in each
X calendar box.
X
3 -"J"
X Directs pcal to print the Julian (Day Of Year, DOY) and the
X number of days remaining in the year in each calendar box.
X
3 -l
X This will cause the output to come out in landscape mode
X (This is the default).
X
3 -p
X This will cause the output to come out in portrait mode
X instead of landscape mode.
X
3 -m
X This option causes a moon to be printed on days corresponding
X to a full, half, or new moon (default: no moons).
X
3 -"M"
X This option causes a fractional moon to be printed on all days
X (default: no moons).
X
3 -b <DAY> | all
X This will cause all dates on weekday DAY to be printed in
X black; "-b all" causes all dates to be printed in black unless
X explicitly flagged as a holiday.
X
3 -g <DAY> | all
X This will cause all dates on weekday DAY to be printed in
X gray; "-g all" causes all dates to be printed in gray. Default is
X to print Saturdays and Sundays in gray and other dates in black.
X
3 -"O"
X Causes pcal to print "gray" dates as outlined characters.
X
3 -"G"
X Causes pcal to print "gray" dates as outlined characters
X filled with gray.
X
3 -"F" <DAY>
X This will cause the weekday DAY to be the first day of each
X week; weekday DAY will appear in the left-most column of each
X calendar.
X
3 -"A" | -"E"
X Directs pcal to use either American or European date
X conventions. Use one of these options to select the date format
X for the calendar file. The -"A" option (the default) selects
X American-style dates like "10/19/90" or "Sep 19 1990", while the
X -"E" option selects European-style dates like "17/10/90" or "19
X Sep 1990".
X
3 -t <FONT>
X This option can be used to change the font the title is
X printed in (ie. pcal -t Times-Roman). The default is Times-Bold.
X
3 -d <FONT>
X This option is the same as -t except that the font used to
X print the day numbers is changed. The default is Times-Bold.
X
3 -n <FONT>
X This option is the same as -n except that the font used to
X print the notes in the calendar boxes is changed. The default is
X Helvetica-Narrow.
X
3 -"L" <STRING>
X This will cause STRING to be printed as a left footer.
X
3 -"C" <STRING>
X This will cause STRING to be printed as a center footer.
X
3 -"R" <STRING>
X This will cause STRING to be printed as a right footer.
X
3 -"D" <SYM>
X This will define symbol SYM prior to reading the date file;
X -"D" alone clears all defined symbols.
X
3 -"U" <SYM>
X This will undefine symbol SYM prior to reading the date file.
X
3 -x xscale
X Specifies the x-axis scaling factor for the calendar size.
X
3 -y yscale
X Specifies the y-axis scaling factor for the calendar size.
X
3 -"X" xtrans
X Specifies the x-axis translation value for positioning the
X output on the page.
X
3 -"Y" ytrans
X Specifies the y-axis translation value for positioning the
X output on the page.
X
3 -"I"
X Resets all parameters to the program defaults.
X
3 -"B"
X Causes pcal to leave unused calendar boxes blank (default is
X gray).
X
3 -w
X Causes pcal to print a calendar for 12 consecutive months: 3
X rows / 4 columns in landscape mode, 4 rows / 3 columns in portrait
X mode. This option effectively disables the -"M"|m (moons) and
X -"J"|j (Julian dates) flags, and also suppresses the text in the
X calendar boxes. The numeric parameters work slightly differently:
X
X yy print Jan/yy .. Dec/yy
X mm yy print 12 months starting with mm/yy
X mm yy n print n months (rounded up to multiple of 12)
X starting with mm/yy
X (default) print Jan .. Dec of current year
X
X Note that "-w" in conjunction with "-p" overrides any Y-scale
X factor (default or set with "-y") in order to use the full
X portrait page.
X
3 -h
X This prints version AND usage information only. (LONG)
X
3 -v
X This prints version information only.
X
2 Calendar_File
X By default, pcal simply prints an empty calendar. Its real
X power is in its ability to place "events" in appropriate days on
X the calendar, thus allowing the user to create personalized
X calendars. This is achieved through the use of the "date file".
X
X The date file is named CALENDAR.DAT Pcal will look in several
X places for such a file. First, if a file called CALENDAR.DAT
X exists in the caller's home directory, it is used. Next, if such
X a file exists in the directory indicated by the logical name
X PCAL_DIR (or the current directory if no such variable is
X defined), it is used. Finally, the directory where the pcal
X executable resides will be checked. If no date file is found, an
X empty calendar is printed.
X
X If a date file is found, it will be searched for lines with
X leading dates matching the requested month and year. Any text
X following the dates found will be printed on the calendar under
X the appropriate day of the month. Dates in the CALENDAR.DAT file
X may be expressed in any of several formats:
X
X <ordinal> <day_spec> in <month_spec>{*} {<text>}
X <day_spec> <prep> <date_spec>{*} {<text>}
X <date_spec>{*} {<text>}
X
X Where:
X
X <month_spec> := first 3+ characters of name of month or "all"
X <day_spec> := first 3+ characters of name of weekday, "day",
X "weekday", "workday", "holiday",
X "nonweekday", "nonworkday", or "nonholiday"
X <ordinal> := "first", "1st", ... "fifth", "5th",
X "last", "odd", "even", or "all"
X <prep> := "before", "preceding", "after", "following",
X "on_or_before" ("oob"), or
X "on_or_after" ("ooa")
X <sep> := 1 or more non-numeric, non-space, non-"*" characters
X <month> := day of month (1-31)
X <day> := a numeric month (1-12)
X <year> := a numeric year
X
X If the -"A" option (American date formats, the default) is given:
X
X <date_spec> := [<month_spec><day> | <month><sep><day>{<sep><year>}]
X
X If the -"E" option (European date formats) is given:
X
X <date_spec> := [<day><month_spec> | <day><sep><month>{<sep><year>}]
X
3 Text_Format_Description
X Pcal also allows format specifiers in both the text and foot
X strings (see the -L, -C, and -R options below); each will be
X replaced by a corresponding string as outlined in the table below.
X Most of these are derived from the strftime() function; the %l
X and %[o0+--] format specifiers are specific to pcal:
X
X %a abbreviated weekday
X %A full weekday
X %b abbreviated month name
X %B full month name
X %d day of month (1-31)
X %j day of year (1-366)
X %l days left in year (0-365)
X %m month (1-12)
X %U week number (0-53)
X %W week number (0-53)
X %y year w/o century (00-99)
X %Y year w/century
X %% % character
X
X %o print number as ordinal
X %0 print number with leading zeroes
X %+ use following month or year
X %- use previous month or year
X
X The %U format specifier considers the first logical Sunday
X (the first day of the week as printed; see the -F option below)
X of the year as the first day of week number 1; the %W specifier
X uses the first logical Monday instead. This is an extension of
X the behavior of the strftime() function.
X
X The %o format specifier prints a number as an ordinal, with
X the appropriate suffix ("st", "nd", "rd", or "th" in English)
X appended; for example, %od prints the day of the month as "1st",
X "2nd", "3rd", etc.
X
X Unlike strftime(), pcal's default is to print numbers (except
X %y) without leading zeroes. If leading zeroes are desired, the
X "0" prefix may be used; for example, %0j prints the day of year
X as 001-365.
X
X The %+ and %- format specifiers direct pcal to substitute the
X following or previous month or year for the following [bBmyY]
X specifier; for example, %+B prints the name of the following
X month.
X
3 Date_Syntax_Description
X Any non-numeric character may separate numeric dates.
X Holidays may be flagged by following the date immediately with "*"
X as in the examples above; this will cause the date to be printed
X in gray. "Each" and "every" are accepted as synonyms for "all",
X and any word may be used in place of "in". The abbreviations
X "oob" and "ooa" may be used in place of the keywords
X "on_or_before" and "on_or_after", respectively.
X
X Wildcard day names are also provided. The keyword "weekday"
X applies to any days which are normally printed in black on the
X calendar. The keyword "workday" is the same, but does not include
X any holidays. The keyword "holiday" includes only those days
X flagged as holidays. The keywords "nonweekday", "nonworkday", and
X "nonholiday" are also recognized as negations of the above. See
X the Caveats below for important notes on using these keywords.
X
X Ordinal day numbers may be used to specify dates, either
X relative to the month or to the year. Either words or numeric
X abbreviations may be used for "first" through "fifth"; higher
X numbers must be given using the numeric equivalent (e.g. 100th).
X Negative ordinal numbers may even be used. For example, "-2nd"
X means "next to last".
X
X "Odd" and "even" do not refer to the actual date; instead,
X "odd" means "alternate, starting with the first", and "even" means
X "alternate, starting with the second". Thus, "odd Fridays in
X March" refers to the first, third, and (if present) fifth Fridays
X in March - not to those Fridays falling on odd dates.
X
X "All" refers to each individual month; "year" refers to the
X year as an entity. Thus "odd Fridays in all" refers to the first,
X third, and fifth Friday of each month, while "odd Fridays in year"
X refers to the first Friday of January and every other Friday
X thereafter.
X
X Text in the date file may use C-like escape sequences (i.e. a
X "\" followed by a character, 1--3 octal digits, or "x" followed by
X 1--2 hexadecimal digits). Escaped whitespace (including newline)
X and the standard ANSI character escapes ("\a", "\b", "\f", "\n",
X "\r", "\t", "\v") are all replaced by a single blank.
X
X Lines in the CALENDAR.DAT file consisting of year #### (where
X #### is a numeric year) can be used to set the year for following
X entries. This assumes that the following entries do not contain a
X year; any date entries containing year information will set the
X remembered year to that year.
X
X Lines in the CALENDAR.DAT file consisting of opt <options> can
X be used to override the defaults for any command-line options
X except -e, -f, -h, -"D", and -"U". Any options specified in this
X manner are, in turn, overridden by those specified explicitly on
X the command line. Note that the upper case letter options do NOT
X need to be enclosed in quotes if they are put in the CALENDAR.DAT
X file. Enclose the upper case letters in quotes only when they are
X used on the DCL.
X
X Lines in the CALENDAR.DAT file consisting of note <month> can
X be used to place notes regarding the entire month is one of the
X unused blocks of the calendar. The <month> indicator may be
X either a number 1 through 12 or an alphabetic month name as
X described above; "note all" will place the associated text in the
X notes block for each month in the current year.
X
X Comments are supported in the CALENDAR.DAT file. Any
X characters following a "#" character through the end of the line
X are ignored.
X
X Pcal supports rudimentary cpp-like functionality in the date
X file, allowing the following constructs: define | undef, if{n}def
X ... {else ...} endif, and include. Note that these are not
X preceded by "#" as they are in C. Symbol names defined using
X these keywords (or via the -"D" option) are case-insensitive. It
X is not an error to undef an undefined symbol, nor to define a
X previously-defined one. An ifdef alone is always false; an
X ifndef alone is always true.
X
X The name of the file in the include directive may optionally
X be surrounded by either "" or <>, both of which are ignored. If
X the name is not an absolute path, it is taken to be relative to
X the directory where the file containing the directive is located.
X
X In addition to pre-processing keywords, pcal also accepts
X boolean expressions in if{n}def directives. These expressions
X consist of symbol names joined by the boolean operators !, &, ^,
X and |, in order of precedence, high to low. Parentheses may be
X used to alter the precedence. The synonyms && and || are accepted
X for & and |. A symbol name evaluates to true if currently
X defined, false if not; thus:
X
X ifdef A | B | C
X
X ...is true if any of the symbols A, B, and C is defined, and:
X
X ifdef A & B & C
X
X ...is true if they all are. Note that ifndef <expr> is equivalent
X to ifdef !( <expr> ).
X
3 Example
X Date File Example:
X
X # A sample "opt" line to change the fonts and output file names,
X # to print only Sundays in gray, and to print moons on all days:
X #
X opt -d Helvetica-Bold -t Helvetica-Bold -o myfile.ps -b all -g sun -M
X
X year 1990 # set year explicitly
X 1/1* New Year's Day
X ifndef Arizona
X 3rd Mon in Jan* Martin Luther King's Birthday
X endif
X 2/2 Groundhog Day
X Feb 14 Valentine's Day
X 3rd Monday in Feb* Presidents' Day
X 3/17 St. Patrick's Day
X last Monday in May* Memorial Day
X 7/4* Independence Day
X 1st Monday in Sep* Labor Day
X second Monday in Oct* Columbus Day (observed)
X first workday in all %-B progress report due
X all Fridays in Oct Status Meeting, 11 AM
X all Fri in all Time card due, 3 PM
X all Monday in all Fiscal week %0W
X -2nd workday in all Schedule for %+B due
X Fri on_or_before all 15 Pay Day
X even Fridays in year Pay Day
X 183rd day of year mid-year (%l days left)
X 10/12 Columbus Day (traditional)
X 10/31 Halloween
X Tue after first Mon in Nov Election Day
X second Monday in Nov* Veterans' Day (observed)
X 11/11* Veterans' Day (traditional)
X fourth Thu in Nov* Thanksgiving
X Fri after 4th Thu in Nov* Day after Thanksgiving
X day after fourth Thu in Nov*
X 12/24* Christmas Eve
X 12/25* Christmas
X last day in Dec* New Year's Eve
X last workday in all Status reports due
X note Dec Office closed throughout week of Christmas
X 1/1/91* New Year's Day # set new year implicitly
X
2 Moon_File
X If a file of the name MOON##.DAT (where ## is the last two
X digits of the calendar year) exists in the same directory as the
X date file, pcal uses the information contained within to calculate
X the phase of the moon. If no such file exists, pcal uses an
X extreamly reliable algorithm. This is the prefered method of use.
X
X Entries in the moon file must conform to the following syntax:
X
X If the -"A" option (American date formats, the default) is
X given:
X
X <quarter> <month><sep><day> {<hour><sep><min>}
X
X If the -"E" option (European date formats) is given:
X
X <quarter> <day><sep><month> {<hour><sep><min>}
X
X Where:
X
X <quarter> := "nm", "fq" or "1q", "fm", "3q" or "lq"
X (new moon,first quarter,full moon,last quarter)
X <hour> := number 0-23 (24-hour clock)
X <min> := number 0-59
X
X This file must contain entries for all quarter moons in the
X year, in chronological order; if any errors are encountered, pcal
X will revert to using its default algorithm.
X
X As in the date file, comments start with "#" and run through
X end-of-line.
X
3 Example
X The following is a short example of an European style (-"E)
X moon data file. It is taken from the MOON91.DAT file supplied
X with pcal.
X
X 3q 01/07 13:37 # third quarter
X nm 01/15 18:51 # new moon
X 1q 01/23 09:23 # first quarter
X fm 01/30 01:10 # full moon
X
2 Logical_Names
X Pcal optionally uses two (2) logical names during execution.
X A user may define them or let the administrator set them up.
X
3 Pcal_Dir
X Pcal logical name for the location of the directory for input
X and output files. In this way, a user can over-ride the current
X default location for the source of the CALENDAR.DAT input file
X and the CALENDAR.PS output file.
X
3 Pcal_Opts
X Pcal also looks for a logical name "Pcal_Opts; if defined,
X its contents are parsed as command-line flags. These over-ride
X the program defaults, but are over-ridden by any specified via
X "opt" lines in the date file or on the command line. Example:
X
X Define Pcal_Opts "-n Helvetica -D meetings" ! login.com
X pcal -"U" meetings 9 90 ! un-define symbol at runtime
X
2 Caveats
X The "workday" and "holiday" keywords are aware of only those
X holidays which have already been flagged at the point where they
X appear. For example, consider January 1990:
X
X January 1990
X S M Tu W Th F S
X 1 2 3 4 5 6
X 7 8 9 10 11 12 13
X 14 15 16 17 18 19 20
X 21 22 23 24 25 26 27
X 28 29 30 31
X
X If the CALENDAR.DAT file looked like this:
X
X workday on_or_before all 15 payday
X 3rd Mon in Jan* MLK day
X
X then Pcal would mark the 15th as "payday" since at that point in
X the CALENDAR.DAT file it has no way of knowing that January 15th
X will later be flagged as a holiday. If the two lines were
X reversed, such that the holiday preceded the "workday" wildcard,
X then Pcal would work as intended, marking instead the 12th as
X "payday". Also, beware of year boundaries which affect the
X handling of all of the day wildcard keywords. In general, it is
X best to place monthly wildcards such as the example above at the
X end of each year to acheive the desired effect.
X
X When the -w and -p options are used together, pcal revises the
X y-scale factor in order to use the entire portrait page;
X therefore, the user should avoid using use the -y using both the
X -w and -p options. Use of the -w option in any case effectively
X disables the -m, -"M", -j, and -"J" options.
X
2 Authors
X The original PostScript code to generate the calendars was
X written by Patrick Wood (Copyright (c) 1987 by Patrick Wood of
X Pipeline Associates, Inc.), and authorized for modification and
X redistribution. The CALENDAR.DAT file inclusion code was
X originally written in "bs(1)" by Bill Vogel of AT&T. Patrick's
X original PostScript was modified and enhanced several times by
X others whose names have regrettably been lost. Ken Keirnan of
X Pacific Bell assembled the original "C" version upon which this is
X based; additional modifications and enhancements were the work of
X Joseph P. Larson, Ed Hand, Andrew W. Rogers, Mark Kantrowitz,
X Joe Brownlee, Jamie Zawinski and Floyd Miller. The moon routines
X were originally written by Mark Hanson, were improved and
X incorporated into this version by Jamie Zawinski, and were
X translated from PostScript to C by Andrew Rogers. VMS and TeX
X support was provided by Richard Dyson and updated by Andrew W.
X Rogers and Joe Brownlee. The Amiga support was supplied by Bill
X Hogsett.
X
2 Version
X This help file currently reflects pcal v4.1 dated 15-AUG-1991
X and was updated by Richard Dyson on 15-AUG-1991.
SHAR_EOF
chmod 0644 Pcal.hlp ||
echo 'restore of Pcal.hlp failed'
Wc_c="`wc -c < 'Pcal.hlp'`"
test 24613 -eq "$Wc_c" ||
echo 'Pcal.hlp: original size 24613, current size' "$Wc_c"
fi
# ============= SetUp.com ==============
if test -f 'SetUp.com' -a X"$1" != X"-c"; then
echo 'x - skipping SetUp.com (File already exists)'
else
echo 'x - extracting SetUp.com (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'SetUp.com' &&
$ Write Sys$Output "SETting UP Pcal (v4.1)..."
$ THIS_PATH = F$Element (0, "]", F$Environment ("PROCEDURE")) + "]"
$ PCAL :== $ 'THIS_PATH'PCAL.EXE
$ Define Pcal_Dir 'THIS_PATH'
$!
$! Put the help library into the next available help library slot
$!
$ LIB = "Hlp$Library"
$ X = F$Trnlnm (LIB, "Lnm$Process")
$ If X .eqs. "" Then GoTo INSERT
$ If X .eqs. "''THIS_PATH'PCAL.HLB" Then GoTo EXIT
$ BASE = LIB + "_"
$ N = 1
$NEXTLIB:
$ LIB := 'BASE''N'
$ X = F$Trnlnm (LIB, "Lnm$Process")
$ If X .eqs. "" Then GoTo INSERT
$ If X .eqs. "''THIS_PATH'PCAL.HLB" Then GoTo EXIT
$ N = N + 1
$ GoTo NEXTLIB
$INSERT:
$ Define 'LIB' 'THIS_PATH'PCAL.HLB
$EXIT:
$ Exit
SHAR_EOF
chmod 0644 SetUp.com ||
echo 'restore of SetUp.com failed'
Wc_c="`wc -c < 'SetUp.com'`"
test 670 -eq "$Wc_c" ||
echo 'SetUp.com: original size 670, current size' "$Wc_c"
fi
# ============= VaxCrtl.opt ==============
if test -f 'VaxCrtl.opt' -a X"$1" != X"-c"; then
echo 'x - skipping VaxCrtl.opt (File already exists)'
else
echo 'x - extracting VaxCrtl.opt (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'VaxCrtl.opt' &&
Sys$Library:VAXCRTL.EXE /Share
SHAR_EOF
chmod 0644 VaxCrtl.opt ||
echo 'restore of VaxCrtl.opt failed'
Wc_c="`wc -c < 'VaxCrtl.opt'`"
test 31 -eq "$Wc_c" ||
echo 'VaxCrtl.opt: original size 31, current size' "$Wc_c"
fi
# ============= calendar ==============
if test -f 'calendar' -a X"$1" != X"-c"; then
echo 'x - skipping calendar (File already exists)'
else
echo 'x - extracting calendar (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'calendar' &&
# Sample date file for Pcal: this should be called .calendar for Un*x,
# CALENDAR.DAT for VMS, and should live in the user's home directory.
#
# Date file syntax:
#
# The following rules describe the syntax of date file entries:
#
# year <year>
#
# opt <options>
#
# note <month_spec> <text>
# note <month> <text>
#
# if -A flag (American date formats) specified:
# <month_name> <day>{*} {<text>}
# <month><sep><day>{<sep><year>}{*} {<text>}
#
# if -E flag (European date formats) specified:
# <day> <month_name>{*} {<text>}
# <day><sep><month>{<sep><year>}{*} {<text>}
#
# <ordinal> <day_name> in <month_spec>{*} {<text>}
# <day_name> <prep> <date_spec>
#
# where
#
# {x} means x is optional
#
# <date_spec> := any of the above date specs (not year, note, or opt)
# <month_name> := first 3+ characters of name of month, or "all"
# <month_spec> := <month_name>, or "year"
# <day_name> := first 3+ characters of name of weekday, "day",
# "weekday", "workday", "holiday", "nonweekday",
# "nonworkday", or "nonholiday"
# <ordinal> := ordinal number ("1st", "2nd", etc.), "first" .. "fifth",
# "last", "even", "odd", or "all"
# <prep> := "before", "preceding", "after", "following", "on_or_before",
# or "on_or_after"
# <sep> := one or more non-numeric, non-space, non-'*' characters
# <month>, <day>, <year> are the numeric forms
#
# <options> := any command-line option except -e, -f, -h, -D, -U
#
# Comments start with '#' and run through end-of-line.
#
# Holidays may be flagged by specifying '*' as the last character of
# the date field(s), e.g. "10/12* Columbus Day", "July 4* Independence
# Day", etc. Any dates flagged as holidays will be printed in gray, and
# any associated text will appear adjacent to the date.
#
# Note that the numeric date formats (mm/dd{/yy}, dd.mm{.yy}) support
# an optional year, which will become the subsequent default year. The
# alphabetic date formats (month dd, dd month) do not support a year
# field; the "year yy" command is provided to reset the default year.
#
# "Floating" days may be specified in the date file as "first Mon in
# Sep", "last Mon in May", "4th Thu in Nov", etc.; any word may be
# used in place of "in". "Relative floating" days (e.g. "Fri after 4th
# Thu in Nov") are also accepted; they may span month/year bounds.
# Pcal also accepts date specs such as "all Friday{s} in October", "last
# Thursday in all", etc., and produces the expected results; "each" and
# "every" are accepted as synonyms for "all". Negative ordinals are
# allowed; "-2nd" means "next to last".
#
# The words "day", "weekday", "workday", and "holiday" may be used as
# wildcards: "day" matches any day, "weekday" matches any day normally
# printed in black, "workday" matches any day normally printed in black
# and not explicitly flagged as a holiday, and "holiday" matches any
# day explicitly flagged as a holiday. "Nonweekday", "nonworkday",
# and "nonholiday" are also supported and have the obvious meanings.
#
# "Odd" and "even" do not refer to the actual date; instead, "odd"
# means "alternate, starting with the first"; "even" means "alternate,
# starting with the second". Thus, "odd Fridays in March" refers to
# the first, third, and (if present) fifth Fridays in March - not to
# those Fridays falling on odd dates.
#
# "All" refers to each individual month; "year" refers to the year
# as an entity. Thus "odd Fridays in all" refers to the first/third/
# fifth Friday of each month, while "odd Fridays in year" refers to
# the first Friday of January and every other Friday thereafter.
#
# Additional notes may be propagated to an empty calendar box by the
# inclusion of one or more lines of the form "note <month> <text>",
# where <month> may be numeric or alphabetic; "note all <text>"
# propagates <text> to each month in the current year.
#
# Pcal also allows format specifiers in the text (and foot strings -
# cf. the -L, -C, and -R options); each will be replaced by its
# equivalent string as outlined in the table below. (Most of these are
# derived from the strftime() function; %[lo0+-] are Pcal-specific.)
#
# %a : abbreviated weekday
# %A : full weekday
# %b : abbreviated month name
# %B : full month name
# %d : day of month (1-31)
# %j : day of year (1-366)
# %l : days left in year (0-365)
# %m : month (1-12)
# %U : week number (0-53)
# %W : week number (0-53)
# %y : year w/o century (00-99)
# %Y : year w/century
# %% : '%' character
#
# %o : print number as ordinal
# %0 : print number with leading zeroes
# %+ : use following month or year
# %- : use previous month or year
#
# %U considers the first logical Sunday (the first day of the week as
# printed; cf. the -F flag) of the year as the first day of week 1;
# %W uses the first logical Monday instead. This is an extension of
# strftime()'s behavior.
#
# %o prints a number as an ordinal, with the appropriate suffix ("st",
# "nd", "rd", or "th" in English) appended; for example, "%od" prints
# the day of the month as "1st", "2nd", "3rd", etc.
#
# Unlike strftime(), Pcal's default is to print numbers (except %y)
# without leading zeroes. If leading zeroes are desired, the '0'
# prefix may be used; for example, "%0j" prints the day of year as
# 001-365.
#
# %+ and %- direct Pcal to substitute the following/previous month/year
# in the following [bBmyY] specifier; for example, %+B prints the name
# of the next month.
#
# Simple cpp-like functionality is provided. The date file may include
# the following commands, which work like their cpp counterparts:
#
# define <sym>
# undef <sym>
#
# if{n}def <expr>
# ...
# { else
# ... }
# endif
#
# include <file>
#
# Note that these do not start with '#', which is reserved as a comment
# character.
#
# <sym> is a symbol name consisting of a letter followed by zero or
# more letters, digits, or underscores ('_'). Symbol names are always
# treated in a case-insensitive manner.
#
# <expr> is an expression consisting of symbol names joined by the logical
# operators (in order of precedence, high to low) '!' (unary negate), '&'
# (and), '^' (exclusive or), and '|' (inclusive or). '&&' and '||' are
# accepted as synonyms for '&' and '|' respectively; the order of
# evaluation may be altered by the use of parentheses. A symbol whose
# name is currently defined evaluates to TRUE; one whose name is not
# currently defined evaluates to FALSE. Thus "ifdef A | B | C" is TRUE
# if any of the symbols A, B, and C is currently defined, and
# "ifdef A & B & C" is TRUE if all of them are.
#
# "ifndef A | B | C" is equivalent to "ifdef !(A | B | C)" (or, using
# DeMorgan's Law, "ifdef !A & !B & !C") - in other words, TRUE if none of
# the symbols A, B, and C is currently defined.
#
# "define" alone deletes all the current definitions; "ifdef" alone is
# always false; "ifndef" alone is always true.
#
# The file name in the "include" directive may optionally be surrounded
# by "" or <>. In any case, path names are taken to be relative to
# the location of the file containing the "include" directive.
X
X
# "opt" lines to override program defaults
X
opt -d Helvetica-Bold -t Helvetica-Bold -n Helvetica # override default fonts
opt -M # moon icons on all days
opt -O # print outlined characters
X
year 1991 # set year explicitly
X
# note to be propagated to "Notes" box for all months
X
note all Engineering staff meeting every Tuesday, 1:30 PM
X
# examples of format specifiers
X
all Monday in all Fiscal week %W.%y # e.g. 26.91
last workday in all %B status meeting # substitute month name
2nd workday in all %-B status report due # use previous month
X
# some sample holidays (flagged by '*') and other days of note
X
1/1* New Year's Day
X
# if "AZ" or "MT" defined, holiday definition will be skipped
ifndef AZ || NH || MT
3rd Monday in Jan* Martin Luther King Day (except AZ, NH, MT)
endif
X
3rd Monday in Feb Presidents' Day
Feb 14 Valentine's Day
X
# any Pcal users in Alaska?
ifdef AK
first Sat in March Iditarod starts
endif
X
3/17 St. Patrick's Day
X
# another local holiday - included only if "MA" or "ME" defined
ifdef MA || ME
3rd Monday in Apr Patriots' Day (MA, ME)
endif
X
last Monday in May* Memorial Day
X
6/14 Flag Day
X
7/4* Independence Day
X
1st Monday in Sep* Labor Day
X
second Monday in Oct Columbus Day (observed)
10/31 Halloween
X
Tue after first Mon in Nov Election Day
second Mon in Nov Veterans' Day # (observed)
fourth Thu in Nov* Thanksgiving
day after fourth Thu in Nov*
X
12/24* Christmas Eve
12/25* Christmas
last day in Dec* New Year's Eve
X
# if the symbol "paydays" has been defined, print text on alternate
# Fridays (starting with the first Friday of the year)
ifdef paydays
odd Fridays in year Pay Day
endif
X
# if the symbol "meetings" has been defined, print text on the next-to-last
# Monday of each month
ifdef meetings
-2nd Monday in all Monthly staff meeting
endif
X
1/1/92* New Year's Day # reset year implicitly
SHAR_EOF
chmod 0666 calendar ||
echo 'restore of calendar failed'
Wc_c="`wc -c < 'calendar'`"
test 9144 -eq "$Wc_c" ||
echo 'calendar: original size 9144, current size' "$Wc_c"
fi
# ============= exprpars.c ==============
if test -f 'exprpars.c' -a X"$1" != X"-c"; then
echo 'x - skipping exprpars.c (File already exists)'
else
echo 'x - extracting exprpars.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'exprpars.c' &&
/*
X * exprpars.c - Pcal routines concerned with parsing if{n}def expressions
X *
X * Contents:
X *
X * do_xxx
X * lookup_token
X * next_token
X * parse_expr
X *
X * Revision history:
X *
X * 4.0 AWR 02/06/91 Author
X *
X */
X
/*
X * Standard headers:
X */
X
#include <ctype.h>
#include <string.h>
#include <stdio.h>
X
/*
X * Pcal-specific definitions:
X */
X
#include "pcaldefs.h"
#include "pcalglob.h"
X
/*
X * Macros:
X */
X
/*
X * token type code definitions:
X */
X
#define TK_UNKNOWN 0 /* codes returned by next_token() */
#define TK_IDENT 1
#define TK_LPAREN 2
#define TK_RPAREN 3
#define TK_UNARYOP 4
#define TK_BINARYOP 5
#define TK_ENDINPUT 6
#define TK_STARTINPUT 7 /* special code for start symbol */
X
/* bit position for token type codes (cf. where_ok[] below) */
#define ID_OK (1 << TK_IDENT)
#define LP_OK (1 << TK_LPAREN)
#define RP_OK (1 << TK_RPAREN)
#define UO_OK (1 << TK_UNARYOP)
#define BO_OK (1 << TK_BINARYOP)
#define ST_OK (1 << TK_STARTINPUT)
#define NEVER_OK 0
X
/* is token "curr" legal after "prev"? (cf. where_ok[] below) */
#define IS_LEGAL(curr, prev) (where_ok[curr] & (1 << (prev)))
X
/*
X * operator-related definitions:
X */
X
#define OP_AND 0 /* operator subcodes */
#define OP_OR 1
#define OP_XOR 2
#define OP_NEGATE 3
X
#define ENDINPUT_PREC -1 /* arbitrary number < lowest op. prec */
#define OR_PREC 1 /* operator precedence levels */
#define XOR_PREC 2
#define AND_PREC 3
#define NEGATE_PREC 4
#define PAREN_PREC 8 /* arbitrary number > highest op. prec */
X
/* lower bits of operator stack entry are code; higher are precedence */
#define OPR_BITS 4
#define OPR_MASK ((1 << OPR_BITS) - 1)
#define PREC(op) ((op) >> OPR_BITS)
#define OPCODE(op) ((op) & OPR_MASK)
#define MAKE_OPR(p, o) (((p) << OPR_BITS) | (o))
X
#define MAX_OP 20 /* size of operand and operator stacks */
X
/*
X * Globals:
X */
X
typedef short OPERAND; /* types for operand and operator stacks */
typedef short OPERATOR;
X
X
typedef struct {
X char *name; /* token spelling */
X short type; /* token type code */
X short value; /* associated value */
X } TOKEN;
X
/* token table - note that substrings must follow longer strings */
X
TOKEN token_tbl[] = {
X "&&", TK_BINARYOP, OP_AND, /* synonym for "&" */
X "&", TK_BINARYOP, OP_AND,
X "||", TK_BINARYOP, OP_OR, /* synonym for "|" */
X "|", TK_BINARYOP, OP_OR,
X "!", TK_UNARYOP, OP_NEGATE,
X "^", TK_BINARYOP, OP_XOR,
X "(", TK_LPAREN, 0,
X ")", TK_RPAREN, 0,
X NULL, TK_UNKNOWN, 0 /* must be last entry */
X };
X
X
typedef struct {
X short prec; /* precedence */
X short type; /* token type (TK_UNARYOP or TK_BINARYOP) */
#ifdef PROTOS
X OPERAND (*pfcn)(OPERAND *); /* dispatch function */
#else
X OPERAND (*pfcn)(); /* dispatch function */
#endif
X } OPR;
X
/* operator table - entries must be in same order as OP_XXX */
X
#ifdef PROTOS
static OPERAND do_and(OPERAND *);
static OPERAND do_or(OPERAND *);
static OPERAND do_xor(OPERAND *);
static OPERAND do_negate(OPERAND *);
#else
static OPERAND do_and(), do_or(), do_xor(), do_negate(); /* dispatch fcns */
#endif
X
OPR opr_tbl[] = {
X AND_PREC, TK_BINARYOP, do_and, /* OP_AND */
X OR_PREC, TK_BINARYOP, do_or, /* OP_OR */
X XOR_PREC, TK_BINARYOP, do_xor, /* OP_XOR */
X NEGATE_PREC, TK_UNARYOP, do_negate /* OP_NEGATE */
X };
X
X
/* set of tokens which each token may legally follow (in TK_XXX order) */
X
int where_ok[] = {
X NEVER_OK , /* TK_UNKNOWN */
X ST_OK | LP_OK | UO_OK | BO_OK , /* TK_IDENT */
X ST_OK | LP_OK | UO_OK | BO_OK , /* TK_LPAREN */
X ID_OK | LP_OK | RP_OK , /* TK_RPAREN */
X ST_OK | LP_OK | BO_OK , /* TK_UNARYOP */
X ID_OK | RP_OK , /* TK_BINARYOP */
X ST_OK | ID_OK | RP_OK /* TK_ENDINPUT */
X };
X
X
/*
X * do_xxx - dispatch functions for operators
X */
X
#ifdef PROTOS
static OPERAND do_and(OPERAND *ptop)
#else
static OPERAND do_and(ptop)
X OPERAND *ptop;
#endif
{
X return ptop[0] & ptop[-1];
}
X
X
#ifdef PROTOS
static OPERAND do_or(OPERAND *ptop)
#else
static OPERAND do_or(ptop)
X OPERAND *ptop;
#endif
{
X return ptop[0] | ptop[-1];
}
X
X
#ifdef PROTOS
static OPERAND do_xor(OPERAND *ptop)
#else
static OPERAND do_xor(ptop)
X OPERAND *ptop;
#endif
{
X return ptop[0] ^ ptop[-1];
}
X
X
#ifdef PROTOS
static OPERAND do_negate(OPERAND *ptop)
#else
static OPERAND do_negate(ptop)
X OPERAND *ptop;
#endif
{
X return ! ptop[0];
}
X
X
/*
X * lookup_token - look up token in table; return pointer to table entry
X */
#ifdef PROTOS
static TOKEN *lookup_token(char *p)
#else
static TOKEN *lookup_token(p)
X char *p;
#endif
{
X TOKEN *ptok;
X
X for (ptok = token_tbl;
X ptok->name && strncmp(p, ptok->name, strlen(ptok->name));
X ptok++)
X ;
X
X return ptok;
}
X
X
/*
X * next_token - fetch next token from input string; fill in its type and value
X * and return pointer to following character
X */
#ifdef PROTOS
static char *next_token(char *p,
X int *ptype,
X int *pvalue)
#else
static char *next_token(p, ptype, pvalue)
X char *p;
X int *ptype;
X int *pvalue;
#endif
{
X TOKEN *ptok;
X char tokbuf[STRSIZ], *pb;
X
#define NT_RETURN(p, t, v) \
X if (1) { *ptype = t; *pvalue = v; return p; } else
X
X while (*p && isspace(*p)) /* skip whitespace */
X p++;
X
X if (*p == '\0') /* end of input? */
X NT_RETURN(p, TK_ENDINPUT, 0);
X
X if (isalpha(*p)) { /* identifier? */
X
X pb = tokbuf; /* make local copy and look up */
X while (*p && (isalpha(*p) || isdigit(*p) || *p == '_'))
X *pb++ = *p++;
X *pb = '\0';
X
X NT_RETURN(p, TK_IDENT, find_sym(tokbuf));
X }
X
X ptok = lookup_token(p); /* other token */
X NT_RETURN(p + (ptok->name ? strlen(ptok->name) : 1), ptok->type,
X ptok->value);
}
X
X
/*
X * parse_expr - parses expression consisting of identifiers and logical
X * operators; return TRUE if expression is true (identifier defined => true);
X * FALSE if false; EXPR_ERR if syntax error in expression
X */
#ifdef PROTOS
int parse_expr(char *pbuf)
#else
int parse_expr(pbuf)
X char *pbuf;
#endif
{
X OPERAND opd_stack[MAX_OP]; /* operand stack - TRUE/FALSE values */
X OPERATOR opr_stack[MAX_OP]; /* operator stack - precedence | op */
X int value, token, plevel, prec, result, npop, opr, opd, prev_token, op;
X
X plevel = 0; /* paren nesting level */
X opd = opr = -1; /* indices of stack tops */
X prev_token = TK_STARTINPUT; /* to detect null expressions */
X
X do {
X pbuf = next_token(pbuf, &token, &value);
X
X /* check that the current token may follow the previous one */
X if (! IS_LEGAL(token, prev_token))
X return EXPR_ERR;
X
X switch(token) {
X
X case TK_IDENT: /* identifier => 1 if def, 0 if not */
X opd_stack[++opd] = value != PP_SYM_UNDEF;
X break;
X
X case TK_LPAREN: /* left paren - bump nesting level */
X ++plevel;
X break;
X
X case TK_RPAREN: /* right paren - decrement nesting */
X if (--plevel < 0)
X return EXPR_ERR;
X break;
X
X case TK_ENDINPUT: /* end-of-input - treat as operator */
X if (prev_token == TK_STARTINPUT)
X return FALSE; /* null expr => FALSE */
X /* fall through */
X
X case TK_UNARYOP:
X case TK_BINARYOP:
X
X /* get precedence of operator, adjusting for paren
X * nesting (TK_ENDINPUT has the lowest precedence
X * of all, to unwind operand/operator stacks at end)
X */
X
X prec = token == TK_ENDINPUT ? ENDINPUT_PREC :
X (plevel * PAREN_PREC) + opr_tbl[value].prec;
X
X /* pop (and perform) any equal- or higher-precedence
X * operators on operator stack: extract operator,
X * check for operand stack underflow, execute
X * operator, adjust operand stack height and place
X * result of operator on top
X */
X
X for ( ;
X opr >= 0 && PREC(opr_stack[opr]) >= prec;
X opr--) {
X op = OPCODE(opr_stack[opr]);
X npop = opr_tbl[op].type == TK_UNARYOP ? 0 : 1;
X if (opd < npop)
X return EXPR_ERR;
X result = (*opr_tbl[op].pfcn)(opd_stack + opd);
X opd_stack[opd -= npop] = result;
X }
X
X /* push operator (if any) onto stack */
X
X if (token != TK_ENDINPUT)
X opr_stack[++opr] = MAKE_OPR(prec, value);
X
X break;
X
X default: /* should never get here */
X return EXPR_ERR;
X break;
X
X }
X
X prev_token = token;
X
X } while (token != TK_ENDINPUT);
X
X /* done - check for dangling parens, and leftover operand/operators */
X
X return plevel != 0 || opd != 0 || opr != -1 ?
X EXPR_ERR : /* leftover junk - return error */
X opd_stack[0]; /* all OK - return final value */
}
X
SHAR_EOF
chmod 0666 exprpars.c ||
echo 'restore of exprpars.c failed'
Wc_c="`wc -c < 'exprpars.c'`"
test 8311 -eq "$Wc_c" ||
echo 'exprpars.c: original size 8311, current size' "$Wc_c"
fi
# ============= moon91 ==============
if test -f 'moon91' -a X"$1" != X"-c"; then
echo 'x - skipping moon91 (File already exists)'
else
echo 'x - extracting moon91 (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'moon91' &&
# 1991 moon phase information for Pcal (from Old Farmer's Almanac)
#
# This file is to be called .moon91 (or moon91) for Un*x, moon91.dat for VMS;
# it is to live in the same directory as the .calendar file.
#
# Pcal originally used an extremely simplistic moon phase algorithm; this file
# (and the code to read it - cf. moonphas.c) was added to v4.0 to enable Pcal
# to interpolate the phase of the moon from the (presumably more accurate)
# information within. More recently, the original moon phase algorithm was
# superseded by an astronomer-quality version (courtesy of Richard Dyson),
# largely obviating the need for this file; however, it will continue to be
# supported for the foreseeable future.
#
# Moon file syntax:
#
# Entries in the moon file must conform to the following syntax:
#
# if -A flag (American date formats) specified:
# <quarter> <month><sep><day> {<hour><sep><min>}
#
# if -E flag (European date formats) specified:
# <quarter> <day><sep><month> {<hour><sep><min>}
#
# where
#
# <quarter> := "nm", "fq" or "1q", "fm", "lq" or "3q" (new
# moon, first quarter, full moon, last quarter)
# <hour> := number 0-23 (24-hour clock)
# <min> := number 0-59
#
# As in the date file, comments start with '#' and run through
# end-of-line.
#
# This file must contain entries for all quarter moons in the year,
# in chronological order; if any errors (e.g., invalid date, date
# or phase out of sequence, unrecognizable line) are encountered,
# Pcal will revert to using its default algorithm.
#
# Dates and times below are for Boston (EST), in -A format; you may wish to
# adjust these dates and times to conform to your location.
X
3q 01/07 13:37 # third quarter
nm 01/15 18:51 # new moon
1q 01/23 09:23 # first quarter
fm 01/30 01:10 # full moon
X
3q 02/06 08:53
nm 02/14 12:33
1q 02/21 17:59
fm 02/28 13:26
X
3q 03/08 05:33
nm 03/16 03:11
1q 03/23 01:03
fm 03/30 02:18
X
3q 04/07 01:47
nm 04/14 14:38
1q 04/21 07:40
fm 04/28 16:00
X
3q 05/06 19:48
nm 05/13 23:37
1q 05/20 14:47
fm 05/28 06:38
X
3q 06/05 10:31
nm 06/12 07:07
1q 06/18 23:20
fm 06/26 22:00
X
3q 07/04 21:51
nm 07/11 14:07
1q 07/18 10:12
fm 07/26 13:25
X
3q 08/03 06:27
nm 08/09 21:28
1q 08/17 00:02
fm 08/25 04:08
X
3q 09/01 13:17
nm 09/08 06:02
1q 09/15 17:02
fm 09/23 17:41
3q 09/30 19:31
X
nm 10/07 16:39
1q 10/15 12:34
fm 10/23 06:09
3q 10/30 02:12
X
nm 11/06 06:12
1q 11/14 09:02
fm 11/21 17:58
3q 11/28 10:22
X
nm 12/05 22:57
1q 12/14 04:33
fm 12/21 05:24
3q 12/27 20:56
SHAR_EOF
chmod 0666 moon91 ||
echo 'restore of moon91 failed'
Wc_c="`wc -c < 'moon91'`"
test 2504 -eq "$Wc_c" ||
echo 'moon91: original size 2504, current size' "$Wc_c"
fi
true || echo 'restore of moonphas.c failed'
echo End of part 2, continue with part 3
exit 0
--
^ _ Joe Brownlee, Analysts International Corporation @ AT&T Bell Labs
/_\ @ / ` 471 E Broad St, Suite 2001, Columbus, Ohio 43215 (614) 860-7461
/ \ | \_, E-mail: jbr@cblph.att.com Who pays attention to what _I_ say?
"Scotty, we need warp speed in 3 minutes or we're all dead!" --- James T. Kirk