home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / sun / volume2 / calentool / patch5d / patches05d
Encoding:
Text File  |  1990-02-04  |  50.3 KB  |  2,026 lines

  1. *** /tmp/,RCSt1a02457    Tue Dec 19 11:34:42 1989
  2. --- utils.c    Tue Dec 19 11:34:15 1989
  3. ***************
  4. *** 1,5
  5.   /*
  6. !  * $Header: utils.c,v 2.3 89/07/19 20:31:40 billr Exp $
  7.    */
  8.   /*
  9.    * utils.c
  10.  
  11. --- 1,5 -----
  12.   /*
  13. !  * $Header: utils.c,v 2.5 89/12/19 11:33:44 billr Exp $
  14.    */
  15.   /*
  16.    * utils.c
  17. ***************
  18. *** 22,27
  19.    * Permission is hereby granted to use and modify the modifications in source
  20.    * or binary form as long as they are not sold for profit and this copyright
  21.    * notice remains intact.
  22.    */
  23.   /********************************************
  24.    *                        *
  25.  
  26. --- 22,29 -----
  27.    * Permission is hereby granted to use and modify the modifications in source
  28.    * or binary form as long as they are not sold for profit and this copyright
  29.    * notice remains intact.
  30. +  * Modified parse_date to allow +nnn and -nnn syntax for dates relative to the
  31. +  * current date.  Peter Marshall <peter.marshall@uwo.ca>. 1989-09-19.
  32.    */
  33.   /********************************************
  34.    *                        *
  35. ***************
  36. *** 33,38
  37.   
  38.   #include "ct.h"
  39.   #include <stdio.h>
  40.   #include <suntool/sunview.h>
  41.   #include <suntool/canvas.h>
  42.   #include <ctype.h>
  43.  
  44. --- 35,41 -----
  45.   
  46.   #include "ct.h"
  47.   #include <stdio.h>
  48. + #ifndef NOTOOL
  49.   #include <suntool/sunview.h>
  50.   #include <suntool/canvas.h>
  51.   #endif  /* NOTOOL */
  52. ***************
  53. *** 35,40
  54.   #include <stdio.h>
  55.   #include <suntool/sunview.h>
  56.   #include <suntool/canvas.h>
  57.   #include <ctype.h>
  58.   #include <sys/types.h>
  59.   #include <sys/file.h>
  60.  
  61. --- 38,44 -----
  62.   #ifndef NOTOOL
  63.   #include <suntool/sunview.h>
  64.   #include <suntool/canvas.h>
  65. + #endif  /* NOTOOL */
  66.   #include <ctype.h>
  67.   #include <sys/types.h>
  68.   #include <sys/time.h>
  69. ***************
  70. *** 37,42
  71.   #include <suntool/canvas.h>
  72.   #include <ctype.h>
  73.   #include <sys/types.h>
  74.   #include <sys/file.h>
  75.   #include <sys/stat.h>
  76.   #include <sys/errno.h>
  77.  
  78. --- 41,47 -----
  79.   #endif  /* NOTOOL */
  80.   #include <ctype.h>
  81.   #include <sys/types.h>
  82. + #include <sys/time.h>
  83.   #include <sys/file.h>
  84.   #include <sys/stat.h>
  85.   #include <sys/errno.h>
  86. ***************
  87. *** 54,60
  88.   extern int one_based, version2, new_entry;
  89.   extern int findex;
  90.   extern struct appt_entry future[];
  91. - extern char todays_date[];
  92.   extern char apts_dir[], lib_dir[];
  93.   extern char printer[];
  94.   extern int include_old, save_old;
  95.  
  96. --- 59,64 -----
  97.   extern int one_based, version2, new_entry;
  98.   extern int findex;
  99.   extern struct appt_entry future[];
  100.   extern char apts_dir[], lib_dir[];
  101.   extern int include_old, save_old, expire_days;
  102.   #ifndef NOTOOL
  103. ***************
  104. *** 56,61
  105.   extern struct appt_entry future[];
  106.   extern char todays_date[];
  107.   extern char apts_dir[], lib_dir[];
  108.   extern char printer[];
  109.   extern int include_old, save_old;
  110.   extern Frame frame;
  111.  
  112. --- 60,67 -----
  113.   extern int findex;
  114.   extern struct appt_entry future[];
  115.   extern char apts_dir[], lib_dir[];
  116. + extern int include_old, save_old, expire_days;
  117. + #ifndef NOTOOL
  118.   extern char printer[];
  119.   extern Frame frame;
  120.   extern Canvas canvas;
  121. ***************
  122. *** 57,63
  123.   extern char todays_date[];
  124.   extern char apts_dir[], lib_dir[];
  125.   extern char printer[];
  126. - extern int include_old, save_old;
  127.   extern Frame frame;
  128.   extern Canvas canvas;
  129.   extern Pixwin *main_pixwin;
  130.  
  131. --- 63,68 -----
  132.   extern int include_old, save_old, expire_days;
  133.   #ifndef NOTOOL
  134.   extern char printer[];
  135.   extern Frame frame;
  136.   extern Canvas canvas;
  137.   extern Pixwin *main_pixwin;
  138. ***************
  139. *** 65,70
  140.   extern Pixfont *font, *sfont;
  141.   extern Frame prompt_frame;
  142.   extern int update_interval;
  143.   extern int errno;
  144.   
  145.   char inbuf[512], strbuf[256], errbuf[64];
  146.  
  147. --- 70,77 -----
  148.   extern Pixfont *font, *sfont;
  149.   extern Frame prompt_frame;
  150.   extern int update_interval;
  151. + extern int monday_first, hour24, day_first;
  152. + #endif  /* NOTOOL */
  153.   extern int errno;
  154.   
  155.   char inbuf[512], strbuf[256], errbuf[128];
  156. ***************
  157. *** 67,75
  158.   extern int update_interval;
  159.   extern int errno;
  160.   
  161. ! char inbuf[512], strbuf[256], errbuf[64];
  162. ! char todays_date[32];
  163. ! static int including;
  164.   static int log_to_console;
  165.   char *daynames[] = {"Sunday","Monday","Tuesday","Wednesday",
  166.                  "Thursday","Friday","Saturday"};
  167.  
  168. --- 74,82 -----
  169.   #endif  /* NOTOOL */
  170.   extern int errno;
  171.   
  172. ! char inbuf[512], strbuf[256], errbuf[128];
  173. ! char clockstr[32];
  174. ! static int include_level = 0;
  175.   static int log_to_console;
  176.   char *daynames[] = {"Sunday","Monday","Tuesday","Wednesday",
  177.                  "Thursday","Friday","Saturday"};
  178. ***************
  179. *** 76,81
  180.   char *monthnames[] = {"January","February","March","April",
  181.                    "May","June","July","August",
  182.                    "September","October","November","December"};
  183.   char *dayname[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
  184.   char rasfile[] = "/usr/tmp/calentool.ras";
  185.   char psfile[] = "/usr/tmp/calentool.ps";
  186.  
  187. --- 83,91 -----
  188.   char *monthnames[] = {"January","February","March","April",
  189.                    "May","June","July","August",
  190.                    "September","October","November","December"};
  191. + char *smonthnames[] = {"Jan","Feb","Mar","Apr",
  192. +                  "May","Jun","Jul","Aug",
  193. +                  "Sep","Oct","Nov","Dec"};
  194.   char *dayname[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
  195.   char rasfile[] = "/usr/tmp/calentool.ras";
  196.   char psfile[] = "/usr/tmp/calentool.ps";
  197. ***************
  198. *** 91,96
  199.   {
  200.       struct tm *tm;
  201.       struct timeval tv;
  202.   
  203.       gettimeofday(&tv, 0);
  204.       tm = localtime(&tv.tv_sec);
  205.  
  206. --- 101,107 -----
  207.   {
  208.       struct tm *tm;
  209.       struct timeval tv;
  210. +     char timstr[16];
  211.   
  212.       gettimeofday(&tv, 0);
  213.       tm = localtime(&tv.tv_sec);
  214. ***************
  215. *** 97,103
  216.   
  217.       today = *tm;
  218.   
  219. !     strcpy(todays_date, asctime(tm));
  220.       if (update_interval >= 60)
  221.           /* overwrite seconds field with year */
  222.           sprintf(&todays_date[16], " %d", today.tm_year+1900);
  223.  
  224. --- 108,120 -----
  225.   
  226.       today = *tm;
  227.   
  228. ! #ifndef CALENCHECK
  229. !     if (day_first)
  230. !         sprintf(clockstr, "%3.3s %d %s %d, ", daynames[today.tm_wday],
  231. !             today.tm_mday, smonthnames[today.tm_mon], today.tm_year+1900);
  232. !     else
  233. !         sprintf(clockstr, "%3.3s %s %d %d, ", daynames[today.tm_wday],
  234. !             smonthnames[today.tm_mon], today.tm_mday, today.tm_year+1900);
  235.       if (update_interval >= 60)
  236.           sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
  237.       else
  238. ***************
  239. *** 99,106
  240.   
  241.       strcpy(todays_date, asctime(tm));
  242.       if (update_interval >= 60)
  243. !         /* overwrite seconds field with year */
  244. !         sprintf(&todays_date[16], " %d", today.tm_year+1900);
  245.       else
  246.           /* just delete trailing \n */
  247.           todays_date[strlen(todays_date)-1] = '\0';
  248.  
  249. --- 116,122 -----
  250.           sprintf(clockstr, "%3.3s %s %d %d, ", daynames[today.tm_wday],
  251.               smonthnames[today.tm_mon], today.tm_mday, today.tm_year+1900);
  252.       if (update_interval >= 60)
  253. !         sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
  254.       else
  255.           sprintf(timstr, "%02d:%02d:%02d", today.tm_hour, today.tm_min, today.tm_sec);
  256.       if (!hour24) {
  257. ***************
  258. *** 102,109
  259.           /* overwrite seconds field with year */
  260.           sprintf(&todays_date[16], " %d", today.tm_year+1900);
  261.       else
  262. !         /* just delete trailing \n */
  263. !         todays_date[strlen(todays_date)-1] = '\0';
  264.   }
  265.   
  266.   /*
  267.  
  268. --- 118,140 -----
  269.       if (update_interval >= 60)
  270.           sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
  271.       else
  272. !         sprintf(timstr, "%02d:%02d:%02d", today.tm_hour, today.tm_min, today.tm_sec);
  273. !     if (!hour24) {
  274. !         /* display am/pm for 12-hour time */
  275. !         if (today.tm_hour > 12) {
  276. !             strcat(timstr, "pm");
  277. !             timstr[0] = ((today.tm_hour - 12) / 10) + '0';
  278. !             timstr[1] = ((today.tm_hour - 12) % 10) + '0';
  279. !         } else if (today.tm_hour == 12) {
  280. !             strcat(timstr, "pm");
  281. !         } else {
  282. !             strcat(timstr, "am");
  283. !         }
  284. !         if (timstr[0] == '0')
  285. !             timstr[0] = ' ';
  286. !     }
  287. !     strcat(clockstr, timstr);
  288. ! #endif  /* CALENCHECK */
  289.   }
  290.   
  291.   /*
  292. ***************
  293. *** 140,169
  294.               current.tm_year++;
  295.           }
  296.       }
  297. !     current.tm_yday = current.tm_mday - 1;
  298. !     for (month = 0; month < current.tm_mon; month++) {
  299. !         current.tm_yday += monthlength(month);
  300. !     }
  301. !     if ((current.tm_year < today.tm_year)
  302. !         || ((current.tm_year == today.tm_year)
  303. !         && (current.tm_yday < today.tm_yday))) {
  304. !         from = current;
  305. !         to = today;
  306. !     } else {
  307. !         from = today;
  308. !         to = current;
  309. !     }
  310. !     if (from.tm_year != to.tm_year) {
  311. !         for (totdays = 0; from.tm_year < to.tm_year; from.tm_year++)
  312. !             totdays += dysize(from.tm_year + 1900);
  313. !     }
  314. !     totdays += to.tm_yday - from.tm_yday;
  315. !     if ((current.tm_year < today.tm_year)
  316. !         || ((current.tm_year == today.tm_year)
  317. !         && (current.tm_yday < today.tm_yday)))
  318. !         totdays = -totdays;
  319. !     current.tm_wday =
  320. !         ((totdays % 7) + 7 + today.tm_wday) % 7;
  321.   }
  322.   
  323.   /*
  324.  
  325. --- 171,178 -----
  326.               current.tm_year++;
  327.           }
  328.       }
  329. !     current.tm_yday = day_of_year((double)current.tm_mday, current.tm_mon+1, current.tm_year+1900);
  330. !     current.tm_wday = get_day_of_week((double)current.tm_mday, current.tm_mon+1, current.tm_year+1900);
  331.   }
  332.   
  333.   /*
  334. ***************
  335. *** 188,194
  336.   {
  337.       static int    monthlengths[] = {31,28,31,30,31,30,31,31,30,31,30,31};
  338.   
  339. !     if (month == FEB && (dysize(current.tm_year + 1900) == 366))
  340.           return(29);
  341.       else
  342.           return(monthlengths[month]);
  343.  
  344. --- 197,203 -----
  345.   {
  346.       static int    monthlengths[] = {31,28,31,30,31,30,31,31,30,31,30,31};
  347.   
  348. !     if (month == FEB && (length_of_year(current.tm_year + 1900) == 366))
  349.           return(29);
  350.       else
  351.           return(monthlengths[month]);
  352. ***************
  353. *** 194,199
  354.           return(monthlengths[month]);
  355.   }
  356.   
  357.   /*
  358.    *
  359.    * Append data from active timeslots to end of "tmp.appointments"
  360.  
  361. --- 203,209 -----
  362.           return(monthlengths[month]);
  363.   }
  364.   
  365. + #ifndef CALENCHECK
  366.   /*
  367.    *
  368.    * Append data from active timeslots to end of "tmp.appointments"
  369. ***************
  370. *** 256,261
  371.           return(1);
  372.       xrename(tmpapts_pathname, apts_pathname);
  373.   }
  374.   
  375.   /*
  376.    * get entry from appointments file
  377.  
  378. --- 266,272 -----
  379.           return(1);
  380.       xrename(tmpapts_pathname, apts_pathname);
  381.   }
  382. + #endif  /* CALENCHECK */
  383.   
  384.   /*
  385.    * get entry from appointments file
  386. ***************
  387. *** 260,266
  388.   /*
  389.    * get entry from appointments file
  390.    */
  391. ! get_aentry(apts_file, appt)
  392.   FILE *apts_file;
  393.   struct appt_entry *appt;
  394.   {
  395.  
  396. --- 271,277 -----
  397.   /*
  398.    * get entry from appointments file
  399.    */
  400. ! get_aentry(apts_file, appt, noInclude)
  401.   FILE *apts_file;
  402.   struct appt_entry *appt;
  403.   int noInclude;
  404. ***************
  405. *** 263,268
  406.   get_aentry(apts_file, appt)
  407.   FILE *apts_file;
  408.   struct appt_entry *appt;
  409.   {
  410.       char *ptr, *str;
  411.       char *fgets(), *index();
  412.  
  413. --- 274,280 -----
  414.   get_aentry(apts_file, appt, noInclude)
  415.   FILE *apts_file;
  416.   struct appt_entry *appt;
  417. + int noInclude;
  418.   {
  419.       char *ptr, *str;
  420.       char *fgets(), *index();
  421. ***************
  422. *** 267,273
  423.       char *ptr, *str;
  424.       char *fgets(), *index();
  425.       char *incl_ptr, incl_buf[128], wday[3];
  426. !     int i, lib;
  427.       struct stat sbuf;
  428.       static FILE *include;
  429.   
  430.  
  431. --- 279,285 -----
  432.       char *ptr, *str;
  433.       char *fgets(), *index();
  434.       char *incl_ptr, incl_buf[128], wday[3];
  435. !     int i, lib, parse_options, nodata = 1;
  436.       struct stat sbuf;
  437.       static FILE *include[MAX_INCLUDE_NESTING];
  438.   
  439. ***************
  440. *** 269,275
  441.       char *incl_ptr, incl_buf[128], wday[3];
  442.       int i, lib;
  443.       struct stat sbuf;
  444. !     static FILE *include;
  445.   
  446.       appt->flags = appt->repeat = appt->lookahead = 0;
  447.       appt->sindex = 0;
  448.  
  449. --- 281,287 -----
  450.       char *incl_ptr, incl_buf[128], wday[3];
  451.       int i, lib, parse_options, nodata = 1;
  452.       struct stat sbuf;
  453. !     static FILE *include[MAX_INCLUDE_NESTING];
  454.   
  455.       appt->flags = appt->repeat = appt->lookahead = 0;
  456.       appt->sindex = 0;
  457. ***************
  458. *** 273,278
  459.   
  460.       appt->flags = appt->repeat = appt->lookahead = 0;
  461.       appt->sindex = 0;
  462.       appt->next = NULL;
  463.       if (including) {
  464.           if (fgets(inbuf, 512, include) == NULL) {
  465.  
  466. --- 285,291 -----
  467.   
  468.       appt->flags = appt->repeat = appt->lookahead = 0;
  469.       appt->sindex = 0;
  470. +     appt->runlength = 0;
  471.       appt->next = NULL;
  472.       /* If noInclude is set then don't follow include files, i.e.
  473.        * treat #include directives as comments. This is useful for
  474. ***************
  475. *** 274,286
  476.       appt->flags = appt->repeat = appt->lookahead = 0;
  477.       appt->sindex = 0;
  478.       appt->next = NULL;
  479. !     if (including) {
  480. !         if (fgets(inbuf, 512, include) == NULL) {
  481. !             /* end of include file - get next entry
  482. !              * from main file
  483. !              */
  484. !             including = 0;
  485. !             fclose(include);
  486.               if (fgets(inbuf, 512, apts_file) == NULL)
  487.                   return(EOF);
  488.           } else {
  489.  
  490. --- 287,310 -----
  491.       appt->sindex = 0;
  492.       appt->runlength = 0;
  493.       appt->next = NULL;
  494. !     /* If noInclude is set then don't follow include files, i.e.
  495. !      * treat #include directives as comments. This is useful for
  496. !      * copying the appts file.
  497. !      */
  498. !     while (nodata) {
  499. !         if (include_level) {
  500. !             if (fgets(inbuf, 512, include[include_level-1]) == NULL) {
  501. !                 /* end of include file - get next entry
  502. !                  * from previous level of nesting
  503. !                  */
  504. !                 fclose(include[include_level-1]);
  505. !                 include_level--;
  506. !             } else {
  507. !                 /* don't modify stuff from include files */
  508. !                 appt->flags |= READONLY;
  509. !                 nodata = 0;    /* still data in file */
  510. !             }
  511. !         } else {
  512.               if (fgets(inbuf, 512, apts_file) == NULL)
  513.                   return(EOF);
  514.               else
  515. ***************
  516. *** 283,292
  517.               fclose(include);
  518.               if (fgets(inbuf, 512, apts_file) == NULL)
  519.                   return(EOF);
  520. !         } else {
  521. !             including = 2;
  522. !             /* don't modify stuff from include files */
  523. !             appt->flags |= READONLY;
  524.           }
  525.       } else
  526.           if (fgets(inbuf, 512, apts_file) == NULL)
  527.  
  528. --- 307,314 -----
  529.           } else {
  530.               if (fgets(inbuf, 512, apts_file) == NULL)
  531.                   return(EOF);
  532. !             else
  533. !                 nodata = 0;    /* still data in file */
  534.           }
  535.       }
  536.       ptr = inbuf;
  537. ***************
  538. *** 288,296
  539.               /* don't modify stuff from include files */
  540.               appt->flags |= READONLY;
  541.           }
  542. !     } else
  543. !         if (fgets(inbuf, 512, apts_file) == NULL)
  544. !             return(EOF);
  545.       ptr = inbuf;
  546.       if (*ptr == '#') {
  547.           if (!strcmp(inbuf, HEADER) && !including) {
  548.  
  549. --- 310,316 -----
  550.               else
  551.                   nodata = 0;    /* still data in file */
  552.           }
  553. !     }
  554.       ptr = inbuf;
  555.       if (noInclude && *ptr == '#') {
  556.           appt->flags |= A_COMMENT;
  557. ***************
  558. *** 292,297
  559.           if (fgets(inbuf, 512, apts_file) == NULL)
  560.               return(EOF);
  561.       ptr = inbuf;
  562.       if (*ptr == '#') {
  563.           if (!strcmp(inbuf, HEADER) && !including) {
  564.               /* first line in file read */
  565.  
  566. --- 312,321 -----
  567.           }
  568.       }
  569.       ptr = inbuf;
  570. +     if (noInclude && *ptr == '#') {
  571. +         appt->flags |= A_COMMENT;
  572. +         return(0);
  573. +     }
  574.       if (*ptr == '#') {
  575.           if (!strcmp(inbuf, HEADER) && !include_level) {
  576.               /* first line in base file read */
  577. ***************
  578. *** 293,300
  579.               return(EOF);
  580.       ptr = inbuf;
  581.       if (*ptr == '#') {
  582. !         if (!strcmp(inbuf, HEADER) && !including) {
  583. !             /* first line in file read */
  584.               if (include_old && (First.tm_year < today.tm_year)) {
  585.                   /* read in old include file (if it exists) */
  586.                   /* prepend directory info */
  587.  
  588. --- 317,324 -----
  589.           return(0);
  590.       }
  591.       if (*ptr == '#') {
  592. !         if (!strcmp(inbuf, HEADER) && !include_level) {
  593. !             /* first line in base file read */
  594.               if (include_old && (First.tm_year < today.tm_year)) {
  595.                   /* read in old include file (if it exists) */
  596.                   /* prepend directory info */
  597. ***************
  598. *** 301,310
  599.                   sprintf(incl_buf, "%s/.appointments.%02d",
  600.                       apts_dir, First.tm_year);
  601.                   if (!stat(incl_buf, &sbuf)) {
  602. !                     if ((include = fopen(incl_buf, "r")) == NULL)
  603. !                         err_rpt("can't open include file (ignored)", NON_FATAL);
  604. !                     else
  605. !                         including = 1;
  606.                   }
  607.               }
  608.           } else if (!strncmp(inbuf, "#include", 8)) {
  609.  
  610. --- 325,337 -----
  611.                   sprintf(incl_buf, "%s/.appointments.%02d",
  612.                       apts_dir, First.tm_year);
  613.                   if (!stat(incl_buf, &sbuf)) {
  614. !                     if ((include[include_level] = fopen(incl_buf, "r")) == NULL) {
  615. !                         strcpy(errbuf, "can't open include file <");
  616. !                         strcat(errbuf, incl_buf);
  617. !                         strcat(errbuf, "> (ignored)");
  618. !                         err_rpt(errbuf, NON_FATAL);
  619. !                     } else
  620. !                         include_level++;
  621.                   }
  622.               }
  623.           } else if (!strncmp(inbuf, "#include", 8)) {
  624. ***************
  625. *** 309,316
  626.               }
  627.           } else if (!strncmp(inbuf, "#include", 8)) {
  628.               /* include file */
  629. !             if (including)
  630. !                 err_rpt("include files may not be nested", FATAL);
  631.               incl_ptr = strbuf;
  632.               if ((ptr = index(inbuf, '"')) == NULL)
  633.   
  634.  
  635. --- 336,346 -----
  636.               }
  637.           } else if (!strncmp(inbuf, "#include", 8)) {
  638.               /* include file */
  639. !             if (include_level > MAX_INCLUDE_NESTING) {
  640. !                 err_rpt("include files nested too deep (ignored)", NON_FATAL);
  641. !                 appt->flags |= A_COMMENT;
  642. !                 return(0);
  643. !             }
  644.               incl_ptr = strbuf;
  645.               if ((ptr = index(inbuf, '"')) == NULL)
  646.   
  647. ***************
  648. *** 316,321
  649.   
  650.                   if ((ptr = index(inbuf, '<')) == NULL) {
  651.                       err_rpt("missing '\"' or '<' in include file spec", NON_FATAL);
  652.                       return(0);
  653.                   } else {
  654.                       lib = 1;
  655.  
  656. --- 346,352 -----
  657.   
  658.                   if ((ptr = index(inbuf, '<')) == NULL) {
  659.                       err_rpt("missing '\"' or '<' in include file spec", NON_FATAL);
  660. +                     appt->flags |= A_COMMENT;
  661.                       return(0);
  662.                   } else {
  663.                       lib = 1;
  664. ***************
  665. *** 327,332
  666.                   *incl_ptr++ = *ptr++;
  667.               if (! *ptr) {
  668.                   err_rpt("missing '\"' or '>' in include file spec", NON_FATAL);
  669.                   return(0);
  670.               }
  671.               *incl_ptr = '\0';
  672.  
  673. --- 358,364 -----
  674.                   *incl_ptr++ = *ptr++;
  675.               if (! *ptr) {
  676.                   err_rpt("missing '\"' or '>' in include file spec", NON_FATAL);
  677. +                 appt->flags |= A_COMMENT;
  678.                   return(0);
  679.               }
  680.               *incl_ptr = '\0';
  681. ***************
  682. *** 339,348
  683.                       sprintf(incl_buf, "%s/%s", lib_dir, strbuf);
  684.                   else
  685.                       sprintf(incl_buf, "%s/%s", apts_dir, strbuf);
  686. !             if ((include = fopen(incl_buf, "r")) == NULL)
  687. !                 err_rpt("can't open include file (ignored)", NON_FATAL);
  688. !             else 
  689. !                 including = 1;
  690.           }
  691.           appt->flags |= A_COMMENT;
  692.           return(0);
  693.  
  694. --- 371,383 -----
  695.                       sprintf(incl_buf, "%s/%s", lib_dir, strbuf);
  696.                   else
  697.                       sprintf(incl_buf, "%s/%s", apts_dir, strbuf);
  698. !             if ((include[include_level] = fopen(incl_buf, "r")) == NULL) {
  699. !                 strcpy(errbuf, "can't open include file <");
  700. !                 strcat(errbuf, incl_buf);
  701. !                 strcat(errbuf, "> (ignored)");
  702. !                 err_rpt(errbuf, NON_FATAL);
  703. !             } else 
  704. !                 include_level++;
  705.           }
  706.           appt->flags |= A_COMMENT;
  707.           return(0);
  708. ***************
  709. *** 367,373
  710.           }
  711.           /* sanity check */
  712.           if (appt->year < 0) {
  713. !             err_rpt("illegal year value (ignored)", NON_FATAL);
  714.               return(1);
  715.           }
  716.       }
  717.  
  718. --- 402,409 -----
  719.           }
  720.           /* sanity check */
  721.           if (appt->year < 0) {
  722. !             sprintf(errbuf, "illegal year value [%d] (ignored)", appt->year);
  723. !             err_rpt(errbuf, NON_FATAL);
  724.               return(1);
  725.           }
  726.       }
  727. ***************
  728. *** 383,389
  729.           if (one_based) (appt->month)--;
  730.           /* sanity check */
  731.           if (appt->month < JAN || appt->month > DEC) {
  732. -             /*
  733.               sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
  734.               err_rpt(errbuf, NON_FATAL);
  735.               */
  736.  
  737. --- 419,424 -----
  738.           if (one_based) (appt->month)--;
  739.           /* sanity check */
  740.           if (appt->month < JAN || appt->month > DEC) {
  741.               sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
  742.               err_rpt(errbuf, NON_FATAL);
  743.               return(1);
  744. ***************
  745. *** 386,393
  746.               /*
  747.               sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
  748.               err_rpt(errbuf, NON_FATAL);
  749. -             */
  750. -             err_rpt("illegal month value (ignored)", NON_FATAL);
  751.               return(1);
  752.           }
  753.       }
  754.  
  755. --- 421,426 -----
  756.           if (appt->month < JAN || appt->month > DEC) {
  757.               sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
  758.               err_rpt(errbuf, NON_FATAL);
  759.               return(1);
  760.           }
  761.       }
  762. ***************
  763. *** 405,411
  764.           if (!one_based) (appt->day)++;
  765.           /* sanity check */
  766.           if (appt->day < 1 || appt->day > 31) {
  767. !             err_rpt("illegal day value (ignored)", NON_FATAL);
  768.               return(1);
  769.           }
  770.       } else {
  771.  
  772. --- 438,445 -----
  773.           if (!one_based) (appt->day)++;
  774.           /* sanity check */
  775.           if (appt->day < 1 || appt->day > 31) {
  776. !             sprintf(errbuf, "illegal day value [%d] (ignored)", appt->day);
  777. !             err_rpt(errbuf, NON_FATAL);
  778.               return(1);
  779.           }
  780.       } else {
  781. ***************
  782. *** 431,437
  783.               appt->flags |= EVERY_SAT;
  784.           else {
  785.               /* sanity check */
  786. !             err_rpt("illegal day name (ignored)", NON_FATAL);
  787.               return(1);
  788.           }
  789.           appt->day = 0;
  790.  
  791. --- 465,472 -----
  792.               appt->flags |= EVERY_SAT;
  793.           else {
  794.               /* sanity check */
  795. !             sprintf(errbuf, "illegal day name [%s] (ignored)", wday);
  796. !             err_rpt(errbuf, NON_FATAL);
  797.               return(1);
  798.           }
  799.           appt->day = 0;
  800. ***************
  801. *** 445,451
  802.       appt->hour += *++ptr - '0';
  803.       /* sanity check */
  804.       if (appt->hour < 0 || (appt->hour > 23 && appt->hour != 99)) {
  805. !         err_rpt("illegal hour value (ignored)", NON_FATAL);
  806.           return(1);
  807.       }
  808.       if ((version2 && appt->hour == 99) || (!version2 && appt->hour == 0))
  809.  
  810. --- 480,487 -----
  811.       appt->hour += *++ptr - '0';
  812.       /* sanity check */
  813.       if (appt->hour < 0 || (appt->hour > 23 && appt->hour != 99)) {
  814. !         sprintf(errbuf, "illegal hour value [%d] (ignored)", appt->hour);
  815. !         err_rpt(errbuf, NON_FATAL);
  816.           return(1);
  817.       }
  818.       if ((version2 && appt->hour == 99) || (!version2 && appt->hour == 0))
  819. ***************
  820. *** 460,466
  821.           /* minutes currently can only be 00 or 30
  822.            * unless it's a note.
  823.            */
  824. !         err_rpt("illegal minute value (ignored)", NON_FATAL);
  825.           return(1);
  826.       }
  827.       if ((appt->flags & A_NOTE) && version2 && appt->minute == 99)
  828.  
  829. --- 496,503 -----
  830.           /* minutes currently can only be 00 or 30
  831.            * unless it's a note.
  832.            */
  833. !         sprintf(errbuf, "illegal minute value [%d] (ignored)", appt->minute);
  834. !         err_rpt(errbuf, NON_FATAL);
  835.           return(1);
  836.       }
  837.       if ((appt->flags & A_NOTE) && version2 && appt->minute == 99)
  838. ***************
  839. *** 472,478
  840.       appt->arrows += *++ptr - '0';
  841.       /* sanity check */
  842.       if (appt->arrows < 0 || appt->arrows > N_TSLOTS) {
  843. !         err_rpt("illegal arrow value (ignored)", NON_FATAL);
  844.           return(1);
  845.       }
  846.       ++ptr;
  847.  
  848. --- 509,516 -----
  849.       appt->arrows += *++ptr - '0';
  850.       /* sanity check */
  851.       if (appt->arrows < 0 || appt->arrows > N_TSLOTS) {
  852. !         sprintf(errbuf, "illegal arrow value [%d] (ignored)", appt->arrows);
  853. !         err_rpt(errbuf, NON_FATAL);
  854.           return(1);
  855.       }
  856.       ++ptr;
  857. ***************
  858. *** 480,513
  859.           ++ptr;
  860.       /* lookahead and repeat entries are free format, i.e. they */
  861.       /* can occur in either order */
  862. !     if (*ptr == '[') {
  863. !         appt->flags |= REPEAT;
  864. !         if (appt->flags & EVERY_SOMEDAY) {
  865. !             if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
  866. !                 return(1);
  867. !         } else {
  868. !             if ((appt->repeat = do_repeat(&ptr)) < 0)
  869. !                 return(1);
  870. !         }
  871. !         if (*ptr == '<') {
  872. !             appt->flags |= LOOKAHEAD;
  873. !             if ((appt->lookahead = do_lookahead(&ptr)) < 0)
  874. !                 return(1);
  875. !         }
  876. !         if (*ptr == '#') {
  877. !             appt->flags |= DELETED;
  878. !             ++ptr;
  879. !             while (isspace(*ptr))
  880. !                 ++ptr;
  881. !         }
  882. !     } else if (*ptr == '<') {
  883. !         appt->flags |= LOOKAHEAD;
  884. !         if ((appt->lookahead = do_lookahead(&ptr)) < 0)
  885. !             return(1);
  886. !         if (*ptr == '[') {
  887. !             appt->flags |= REPEAT;
  888. !             if (appt->flags & EVERY_SOMEDAY) {
  889. !                 if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
  890.                       return(1);
  891.               } else {
  892.                   if ((appt->repeat = do_repeat(&ptr)) < 0)
  893.  
  894. --- 518,542 -----
  895.           ++ptr;
  896.       /* lookahead and repeat entries are free format, i.e. they */
  897.       /* can occur in either order */
  898. !     parse_options = TRUE;
  899. !     while (parse_options) {
  900. !         switch (*ptr) {
  901. !             case '[':
  902. !                 /* repeating appointment */
  903. !                 appt->flags |= REPEAT;
  904. !                 if (appt->flags & EVERY_SOMEDAY) {
  905. !                     if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
  906. !                         return(1);
  907. !                 } else {
  908. !                     if ((appt->repeat = do_repeat(&ptr)) < 0)
  909. !                         return(1);
  910. !                 }
  911. !                 break;
  912. !             
  913. !             case '<':
  914. !                 /* remind us ahead of time */
  915. !                 appt->flags |= LOOKAHEAD;
  916. !                 if ((appt->lookahead = do_lookahead(&ptr)) < 0)
  917.                       return(1);
  918.                   break;
  919.               
  920. ***************
  921. *** 509,516
  922.               if (appt->flags & EVERY_SOMEDAY) {
  923.                   if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
  924.                       return(1);
  925. !             } else {
  926. !                 if ((appt->repeat = do_repeat(&ptr)) < 0)
  927.                       return(1);
  928.               }
  929.           }
  930.  
  931. --- 538,551 -----
  932.                   appt->flags |= LOOKAHEAD;
  933.                   if ((appt->lookahead = do_lookahead(&ptr)) < 0)
  934.                       return(1);
  935. !                 break;
  936. !             
  937. !             case '+':
  938. !                 /* this appointment lasts for n days */
  939. !                 appt->flags |= RUN;
  940. !                 while (isdigit(*++ptr))
  941. !                     appt->runlength = appt->runlength * 10 + (int)(*ptr - '0');
  942. !                 if (appt->runlength < 0)
  943.                       return(1);
  944.                   if (!(appt->flags & REPEAT)) {
  945.                       /* default to run of days */
  946. ***************
  947. *** 512,523
  948.               } else {
  949.                   if ((appt->repeat = do_repeat(&ptr)) < 0)
  950.                       return(1);
  951. !             }
  952. !         }
  953. !         if (*ptr == '#') {
  954. !             appt->flags |= DELETED;
  955. !             ++ptr;
  956. !             while (isspace(*ptr))
  957.                   ++ptr;
  958.           }
  959.       } else if (*ptr == '#') {
  960.  
  961. --- 547,562 -----
  962.                       appt->runlength = appt->runlength * 10 + (int)(*ptr - '0');
  963.                   if (appt->runlength < 0)
  964.                       return(1);
  965. !                 if (!(appt->flags & REPEAT)) {
  966. !                     /* default to run of days */
  967. !                     appt->flags |= REPEAT;
  968. !                     appt->repeat = 1;
  969. !                 }
  970. !                 break;
  971. !             case '#':
  972. !                 /* deleted appointment */
  973. !                 appt->flags |= DELETED;
  974.                   ++ptr;
  975.                   break;
  976.               
  977. ***************
  978. *** 519,524
  979.               ++ptr;
  980.               while (isspace(*ptr))
  981.                   ++ptr;
  982.           }
  983.       } else if (*ptr == '#') {
  984.           appt->flags |= DELETED;
  985.  
  986. --- 558,568 -----
  987.                   /* deleted appointment */
  988.                   appt->flags |= DELETED;
  989.                   ++ptr;
  990. +                 break;
  991. +             
  992. +             default:
  993. +                 parse_options = FALSE;
  994. +                 break;
  995.           }
  996.           while (isspace(*ptr))
  997.               ++ptr;
  998. ***************
  999. *** 520,528
  1000.               while (isspace(*ptr))
  1001.                   ++ptr;
  1002.           }
  1003. -     } else if (*ptr == '#') {
  1004. -         appt->flags |= DELETED;
  1005. -         ++ptr;
  1006.           while (isspace(*ptr))
  1007.               ++ptr;
  1008.       }
  1009.  
  1010. --- 564,569 -----
  1011.                   parse_options = FALSE;
  1012.                   break;
  1013.           }
  1014.           while (isspace(*ptr))
  1015.               ++ptr;
  1016.       }
  1017. ***************
  1018. *** 553,560
  1019.           return(-1);
  1020.       }
  1021.       ++*ptr;
  1022. -     while (isspace(**ptr))
  1023. -         ++*ptr;
  1024.       return(repeat);
  1025.   }
  1026.   
  1027.  
  1028. --- 594,599 -----
  1029.           return(-1);
  1030.       }
  1031.       ++*ptr;
  1032.       return(repeat);
  1033.   }
  1034.   
  1035. ***************
  1036. *** 584,592
  1037.           return(-1);
  1038.       }
  1039.       ++*ptr;
  1040. -     while (isspace(**ptr))
  1041. -         ++*ptr;
  1042.       return(repeat);
  1043.   }
  1044.   
  1045.  
  1046. --- 623,628 -----
  1047.           return(-1);
  1048.       }
  1049.       ++*ptr;
  1050.       return(repeat);
  1051.   }
  1052.   
  1053. ***************
  1054. *** 608,615
  1055.           return(-1);
  1056.       }
  1057.       ++*ptr;
  1058. -     while (isspace(**ptr))
  1059. -         ++*ptr;
  1060.       return(lookahead);
  1061.   }
  1062.   
  1063.  
  1064. --- 644,649 -----
  1065.           return(-1);
  1066.       }
  1067.       ++*ptr;
  1068.       return(lookahead);
  1069.   }
  1070.   
  1071. ***************
  1072. *** 687,692
  1073.   
  1074.       if (appt->flags & LOOKAHEAD)
  1075.           fprintf(apts_file, "<%d> ", appt->lookahead);
  1076.       if (appt->flags & DELETED)
  1077.           fprintf(apts_file, "# %s\n", appt->str);
  1078.       else
  1079.  
  1080. --- 721,728 -----
  1081.   
  1082.       if (appt->flags & LOOKAHEAD)
  1083.           fprintf(apts_file, "<%d> ", appt->lookahead);
  1084. +     if (appt->flags & RUN)
  1085. +         fprintf(apts_file, "+%d ", appt->runlength);
  1086.       if (appt->flags & DELETED)
  1087.           fprintf(apts_file, "# %s\n", appt->str);
  1088.       else
  1089. ***************
  1090. *** 726,731
  1091.       return (rptstr);
  1092.   }
  1093.   
  1094.   /*
  1095.    * Print today's appointments to stdout or mail (useful if we only have an ASCII
  1096.    * terminal connected to our Sun). Invoked by the "-p", "-P" or "-m" options.
  1097.  
  1098. --- 762,768 -----
  1099.       return (rptstr);
  1100.   }
  1101.   
  1102. + #ifndef CALENCHECK
  1103.   /*
  1104.    * Print today's appointments to stdout or mail (useful if we only have an ASCII
  1105.    * terminal connected to our Sun). Invoked by the "-p", "-P", "-m" or
  1106. ***************
  1107. *** 728,734
  1108.   
  1109.   /*
  1110.    * Print today's appointments to stdout or mail (useful if we only have an ASCII
  1111. !  * terminal connected to our Sun). Invoked by the "-p", "-P" or "-m" options.
  1112.    * Month information is only printed as PostScript output.
  1113.    */
  1114.   print_apts(which, dest)
  1115.  
  1116. --- 765,772 -----
  1117.   #ifndef CALENCHECK
  1118.   /*
  1119.    * Print today's appointments to stdout or mail (useful if we only have an ASCII
  1120. !  * terminal connected to our Sun). Invoked by the "-p", "-P", "-m" or
  1121. !  * "-M" options.
  1122.    * Month information is only printed as PostScript output.
  1123.    */
  1124.   print_apts(which, dest)
  1125. ***************
  1126. *** 734,740
  1127.   print_apts(which, dest)
  1128.   int which, dest;
  1129.   {
  1130. !     int i;
  1131.       FILE *output, *pfp, *popen();
  1132.       char cmd[80], *name, *cuserid();
  1133.   
  1134.  
  1135. --- 772,778 -----
  1136.   print_apts(which, dest)
  1137.   int which, dest;
  1138.   {
  1139. !     int i, gd_rtn;
  1140.       FILE *output, *pfp, *popen();
  1141.       char cmd[80], *name, *cuserid();
  1142.   
  1143. ***************
  1144. *** 738,746
  1145.       FILE *output, *pfp, *popen();
  1146.       char cmd[80], *name, *cuserid();
  1147.   
  1148. -     if (dest == DST_MAIL)
  1149. -         /* only mail one day's appts */
  1150. -         which = PRI_DAY;
  1151.       fix_current_day();
  1152.       if ((which == PRI_DAY) && !get_day_appts())
  1153.           return;    /* nothing to show */
  1154.  
  1155. --- 776,781 -----
  1156.       FILE *output, *pfp, *popen();
  1157.       char cmd[80], *name, *cuserid();
  1158.   
  1159.       fix_current_day();
  1160.       gd_rtn = get_day_appts();
  1161.       if (which == PRI_DAY && !gd_rtn)
  1162. ***************
  1163. *** 742,748
  1164.           /* only mail one day's appts */
  1165.           which = PRI_DAY;
  1166.       fix_current_day();
  1167. !     if ((which == PRI_DAY) && !get_day_appts())
  1168.           return;    /* nothing to show */
  1169.       if (dest == DST_MAIL) {
  1170.           if (mailto != NULL) {
  1171.  
  1172. --- 777,784 -----
  1173.       char cmd[80], *name, *cuserid();
  1174.   
  1175.       fix_current_day();
  1176. !     gd_rtn = get_day_appts();
  1177. !     if (which == PRI_DAY && !gd_rtn)
  1178.           return;    /* nothing to show */
  1179.       if (which == PRI_DAY_XNOTES && gd_rtn == SOME_MKNOTES)
  1180.           /* all we have is marked notes */
  1181. ***************
  1182. *** 744,749
  1183.       fix_current_day();
  1184.       if ((which == PRI_DAY) && !get_day_appts())
  1185.           return;    /* nothing to show */
  1186.       if (dest == DST_MAIL) {
  1187.           if (mailto != NULL) {
  1188.               name = mailto;
  1189.  
  1190. --- 780,788 -----
  1191.       gd_rtn = get_day_appts();
  1192.       if (which == PRI_DAY && !gd_rtn)
  1193.           return;    /* nothing to show */
  1194. +     if (which == PRI_DAY_XNOTES && gd_rtn == SOME_MKNOTES)
  1195. +         /* all we have is marked notes */
  1196. +         return;    /* nothing to show */
  1197.       if (dest == DST_MAIL) {
  1198.           if (mailto != NULL) {
  1199.               name = mailto;
  1200. ***************
  1201. *** 750,756
  1202.           } else if ((name = cuserid(NULL)) == NULL) {
  1203.               err_rpt("nobody to mail to", FATAL);
  1204.           }
  1205. !         sprintf(cmd, "mail -s \"Appointments for today\" %s", name);
  1206.           if ((output = popen(cmd, "w")) == NULL)
  1207.               err_rpt("Couldn't pipe to 'mail'", FATAL);
  1208.       } else {
  1209.  
  1210. --- 789,795 -----
  1211.           } else if ((name = cuserid(NULL)) == NULL) {
  1212.               err_rpt("nobody to mail to", FATAL);
  1213.           }
  1214. !         sprintf(cmd, "%s -s \"Appointments for today\" %s", MAILPROG, name);
  1215.           if ((output = popen(cmd, "w")) == NULL)
  1216.               err_rpt("Couldn't pipe to 'mail'", FATAL);
  1217.       } else {
  1218. ***************
  1219. *** 758,764
  1220.       }
  1221.       
  1222.       if (which == PRI_DAY || which == PRI_DAY_XNOTES) {
  1223. !         print_one_day(which, output);
  1224.       } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
  1225.           current.tm_mday -= current.tm_wday; /* Sunday of this week */
  1226.           fix_current_day();
  1227.  
  1228. --- 797,803 -----
  1229.       }
  1230.       
  1231.       if (which == PRI_DAY || which == PRI_DAY_XNOTES) {
  1232. !         print_one_day(which, output, gd_rtn);
  1233.       } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
  1234.           current.tm_mday -= current.tm_wday; /* Sunday of this week */
  1235.           fix_current_day();
  1236. ***************
  1237. *** 762,768
  1238.       } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
  1239.           current.tm_mday -= current.tm_wday; /* Sunday of this week */
  1240.           fix_current_day();
  1241. !         if (nr_weekdays < 7) {
  1242.               current.tm_mday++;
  1243.               fix_current_day();
  1244.           }
  1245.  
  1246. --- 801,807 -----
  1247.       } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
  1248.           current.tm_mday -= current.tm_wday; /* Sunday of this week */
  1249.           fix_current_day();
  1250. !         if (nr_weekdays < 7 || monday_first) {
  1251.               current.tm_mday++;
  1252.               fix_current_day();
  1253.           }
  1254. ***************
  1255. *** 767,774
  1256.               fix_current_day();
  1257.           }
  1258.           for (i=0;i<nr_weekdays;i++) {
  1259. !             if (get_day_appts())
  1260. !                 print_one_day(which, output);
  1261.               current.tm_mday++;
  1262.               fix_current_day();
  1263.           }
  1264.  
  1265. --- 806,814 -----
  1266.               fix_current_day();
  1267.           }
  1268.           for (i=0;i<nr_weekdays;i++) {
  1269. !             gd_rtn = get_day_appts();
  1270. !             if ((gd_rtn && which == PRI_WEEK) || (gd_rtn & ~SOME_MKNOTES && which == PRI_WEEK_XNOTES))
  1271. !                 print_one_day(which, output, gd_rtn);
  1272.               current.tm_mday++;
  1273.               fix_current_day();
  1274.           }
  1275. ***************
  1276. *** 780,786
  1277.           pclose(output);
  1278.   }
  1279.   
  1280. ! print_one_day(which, output)
  1281.   int which;
  1282.   FILE *output;
  1283.   {
  1284.  
  1285. --- 820,826 -----
  1286.           pclose(output);
  1287.   }
  1288.   
  1289. ! print_one_day(which, output, gdrtn)
  1290.   int which;
  1291.   FILE *output;
  1292.   int gdrtn;
  1293. ***************
  1294. *** 783,788
  1295.   print_one_day(which, output)
  1296.   int which;
  1297.   FILE *output;
  1298.   {
  1299.       int i;
  1300.       struct appt_entry tmp_apt;
  1301.  
  1302. --- 823,829 -----
  1303.   print_one_day(which, output, gdrtn)
  1304.   int which;
  1305.   FILE *output;
  1306. + int gdrtn;
  1307.   {
  1308.       int i;
  1309.       struct appt_entry tmp_apt;
  1310. ***************
  1311. *** 788,796
  1312.       struct appt_entry tmp_apt;
  1313.       char *format_appt();
  1314.   
  1315. !     fprintf(output,"\n\t*** Appointments for %s %s %d, %d ***\n\n", 
  1316. !         daynames[current.tm_wday], monthnames[current.tm_mon],
  1317. !         current.tm_mday, current.tm_year+1900);
  1318.   
  1319.       for (i=0; i<N_SLOTS; i++) {
  1320.           if (i == n_tslots)
  1321.  
  1322. --- 829,842 -----
  1323.       struct appt_entry tmp_apt;
  1324.       char *format_appt();
  1325.   
  1326. !     if (day_first)
  1327. !         fprintf(output,"\n\t*** Appointments for %s %d %s %d ***\n\n", 
  1328. !             daynames[current.tm_wday], current.tm_mday,
  1329. !             monthnames[current.tm_mon], current.tm_year+1900);
  1330. !     else
  1331. !         fprintf(output,"\n\t*** Appointments for %s %s %d, %d ***\n\n", 
  1332. !             daynames[current.tm_wday], monthnames[current.tm_mon],
  1333. !             current.tm_mday, current.tm_year+1900);
  1334.   
  1335.       for (i=0; i<N_SLOTS; i++) {
  1336.           if (i == n_tslots)
  1337. ***************
  1338. *** 795,801
  1339.       for (i=0; i<N_SLOTS; i++) {
  1340.           if (i == n_tslots)
  1341.               /* start of notes section */
  1342. !             fprintf(output,"\n\t\t     ===== Notes =====\n");
  1343.           if (slots[i].first != NULL && slots[i].count > 0) {
  1344.               /* at least one appt here */
  1345.               slots[i].cur_appt = slots[i].first;
  1346.  
  1347. --- 841,849 -----
  1348.       for (i=0; i<N_SLOTS; i++) {
  1349.           if (i == n_tslots)
  1350.               /* start of notes section */
  1351. !             if ((gdrtn & SOME_NOTES) ||
  1352. !                (!(which & PRI_XNOTES) && (gdrtn & SOME_MKNOTES)))
  1353. !                 fprintf(output,"\n\t\t     ===== Notes =====\n");
  1354.           if (slots[i].first != NULL && slots[i].count > 0) {
  1355.               /* at least one appt here */
  1356.               slots[i].cur_appt = slots[i].first;
  1357. ***************
  1358. *** 841,847
  1359.        * also support a "lookahead" reminder service to remind one
  1360.        * in advance of a future appointment.
  1361.        * If "save_old" is set, then any appointments for years prior
  1362. !      * to this one are save in a special file of the form
  1363.        * ".appointments.YY", where YY is the year.
  1364.        */
  1365.   
  1366.  
  1367. --- 889,895 -----
  1368.        * also support a "lookahead" reminder service to remind one
  1369.        * in advance of a future appointment.
  1370.        * If "save_old" is set, then any appointments for years prior
  1371. !      * to this one are saved in a special file of the form
  1372.        * ".appointments.YY", where YY is the year.
  1373.        */
  1374.   
  1375. ***************
  1376. *** 864,870
  1377.   
  1378.        /* copy existing entries to the new file */
  1379.        save_base = one_based;
  1380. !      while ((err_flag = get_aentry(oappts, &appt)) != EOF) {
  1381.           if (err_flag)
  1382.               continue;    /* ignore badly formatted input */
  1383.           if (appt.hour == 0)
  1384.  
  1385. --- 912,918 -----
  1386.   
  1387.        /* copy existing entries to the new file */
  1388.        save_base = one_based;
  1389. !      while ((err_flag = get_aentry(oappts, &appt, TRUE)) != EOF) {
  1390.           if (err_flag)
  1391.               continue;    /* ignore badly formatted input */
  1392.           if (appt.hour == 0)
  1393. ***************
  1394. *** 891,898
  1395.                   fclose(fp);
  1396.               }
  1397.           } else {
  1398. !             if (put_aentry(nappts, &appt))
  1399. !                 err_rpt("write to new appt file failed, bailing out", FATAL);
  1400.           }
  1401.           one_based = save_base;    /* (maybe) force old format input */
  1402.       }
  1403.  
  1404. --- 939,949 -----
  1405.                   fclose(fp);
  1406.               }
  1407.           } else {
  1408. !             if (appt.flags & A_COMMENT)
  1409. !                 fputs(inbuf, nappts);
  1410. !             else
  1411. !                 if (put_aentry(nappts, &appt))
  1412. !                     err_rpt("write to new appt file failed, bailing out", FATAL);
  1413.           }
  1414.           one_based = save_base;    /* (maybe) force old format input */
  1415.       }
  1416. ***************
  1417. *** 904,971
  1418.   }
  1419.   
  1420.   /*
  1421. -  * Scan appointments file for outdated appointments and save them to a
  1422. -  * special file of the form ".appointments.YY", where YY is the year
  1423. -  * of that appointment.
  1424. -  */
  1425. - create_old_files()
  1426. - {
  1427. -     FILE *oappts, *nappts, *fp;
  1428. -     struct appt_entry appt;
  1429. -     int err_flag;
  1430. -     char save_file[128];
  1431. -     struct stat stbuf;
  1432. -     if (read_only != 0) {
  1433. -         err_rpt("appts file is read-only, no conversion done", NON_FATAL);
  1434. -         return;
  1435. -     }
  1436. -      /* open files, etc */
  1437. -     if ((oappts = fopen(apts_pathname, "r")) == NULL) {
  1438. -         err_rpt("can't open appts file for reading", FATAL);
  1439. -         /* NOT REACHED */
  1440. -      }
  1441. -     if ((nappts = fopen(tmpapts_pathname, "w")) == NULL) {
  1442. -         err_rpt("can't open temp file for writing", NON_FATAL);
  1443. -         return;
  1444. -      }
  1445. -      /* copy existing entries to the tmp file, checking dates */
  1446. -      while ((err_flag = get_aentry(oappts, &appt)) != EOF) {
  1447. -         if (err_flag)
  1448. -             continue;    /* ignore badly formatted input */
  1449. -         if (!(appt.flags & A_COMMENT)
  1450. -            && !(appt.flags & ALL_YEARS) && (appt.year < today.tm_year)
  1451. -            && !((appt.flags & REPEAT) && !(appt.flags & EVERY_SOMEDAY))) {
  1452. -             /* prepend directory info */
  1453. -             sprintf(save_file, "%s/.appointments.%02d",
  1454. -                 apts_dir, appt.year);
  1455. -             if (stat(save_file, &stbuf) && errno == ENOENT) {
  1456. -                 /* new file*/
  1457. -                 if ((fp = fopen(save_file, "w")) == NULL)
  1458. -                     err_rpt("can't open save file, bailing out", FATAL);
  1459. -                 fputs(HEADER, fp);
  1460. -                 fclose(fp);
  1461. -             }
  1462. -             if ((fp = fopen(save_file, "a+")) == NULL)
  1463. -                 err_rpt("can't open save file, bailing out", FATAL);
  1464. -             else {
  1465. -                 if (put_aentry(fp, &appt))
  1466. -                     err_rpt("write to save appt file failed, bailing out", FATAL);
  1467. -                 fclose(fp);
  1468. -             }
  1469. -         } else {
  1470. -             if (put_aentry(nappts, &appt))
  1471. -                 err_rpt("write to new appt file failed, bailing out", FATAL);
  1472. -         }
  1473. -     }
  1474. -     fclose(oappts);
  1475. -     fclose(nappts);
  1476. -     xrename(tmpapts_pathname, apts_pathname);
  1477. - }
  1478. - /*
  1479.    * convert appt entry to ASCII string for display with date, time and msg
  1480.    */
  1481.   char *
  1482.  
  1483. --- 955,960 -----
  1484.   }
  1485.   
  1486.   /*
  1487.    * convert appt entry to ASCII string for display with date, time and msg
  1488.    */
  1489.   char *
  1490. ***************
  1491. *** 997,1005
  1492.       if (appt->flags & A_NOTE) {
  1493.           /* note */
  1494.           if (appt->flags & ALL_YEARS)
  1495. !             sprintf(strbuf,"%3.3s %2d/%02d    --  %s",
  1496. !                 daynames[current.tm_wday], appt->month+1,
  1497. !                 appt->day, appt->str);
  1498.           else if (appt->year > 99)
  1499.               sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1500.                   daynames[current.tm_wday], appt->month+1,
  1501.  
  1502. --- 986,999 -----
  1503.       if (appt->flags & A_NOTE) {
  1504.           /* note */
  1505.           if (appt->flags & ALL_YEARS)
  1506. !             if (day_first)
  1507. !                 sprintf(strbuf,"%3.3s %2d/%02d    --  %s",
  1508. !                     daynames[current.tm_wday], appt->day,
  1509. !                     appt->month+1, appt->str);
  1510. !             else
  1511. !                 sprintf(strbuf,"%3.3s %2d/%02d    --  %s",
  1512. !                     daynames[current.tm_wday], appt->month+1,
  1513. !                     appt->day, appt->str);
  1514.           else if (appt->year > 99)
  1515.               if (day_first)
  1516.                   sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1517. ***************
  1518. *** 1001,1009
  1519.                   daynames[current.tm_wday], appt->month+1,
  1520.                   appt->day, appt->str);
  1521.           else if (appt->year > 99)
  1522. !             sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1523. !                 daynames[current.tm_wday], appt->month+1,
  1524. !                 appt->day, appt->year-100, appt->str);
  1525.           else
  1526.               sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1527.                   daynames[current.tm_wday], appt->month+1,
  1528.  
  1529. --- 995,1008 -----
  1530.                       daynames[current.tm_wday], appt->month+1,
  1531.                       appt->day, appt->str);
  1532.           else if (appt->year > 99)
  1533. !             if (day_first)
  1534. !                 sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1535. !                     daynames[current.tm_wday], appt->day,
  1536. !                     appt->month+1, appt->year-100, appt->str);
  1537. !             else
  1538. !                 sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1539. !                     daynames[current.tm_wday], appt->month+1,
  1540. !                     appt->day, appt->year-100, appt->str);
  1541.           else
  1542.               if (day_first)
  1543.                   sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1544. ***************
  1545. *** 1005,1014
  1546.                   daynames[current.tm_wday], appt->month+1,
  1547.                   appt->day, appt->year-100, appt->str);
  1548.           else
  1549. !             sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1550. !                 daynames[current.tm_wday], appt->month+1,
  1551. !                 appt->day, appt->year, appt->str);
  1552. !     } else
  1553.           /* standard appointment */
  1554.           sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d   %s",
  1555.               daynames[current.tm_wday], appt->month+1,
  1556.  
  1557. --- 1004,1018 -----
  1558.                       daynames[current.tm_wday], appt->month+1,
  1559.                       appt->day, appt->year-100, appt->str);
  1560.           else
  1561. !             if (day_first)
  1562. !                 sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1563. !                     daynames[current.tm_wday], appt->day,
  1564. !                     appt->month+1, appt->year, appt->str);
  1565. !             else
  1566. !                 sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1567. !                     daynames[current.tm_wday], appt->month+1,
  1568. !                     appt->day, appt->year, appt->str);
  1569. !     } else {
  1570.           /* standard appointment */
  1571.           if (hour24)
  1572.               if (day_first)
  1573. ***************
  1574. *** 1010,1020
  1575.                   appt->day, appt->year, appt->str);
  1576.       } else
  1577.           /* standard appointment */
  1578. !         sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d   %s",
  1579. !             daynames[current.tm_wday], appt->month+1,
  1580. !             appt->day, appt->year, appt->hour, appt->minute,
  1581. !             e_hour, e_minutes, appt->str);
  1582.       current = Save;
  1583.       return(strbuf);
  1584.   }
  1585.  
  1586. --- 1014,1048 -----
  1587.                       appt->day, appt->year, appt->str);
  1588.       } else {
  1589.           /* standard appointment */
  1590. !         if (hour24)
  1591. !             if (day_first)
  1592. !                 sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d   %s",
  1593. !                     daynames[current.tm_wday], appt->day,
  1594. !                     appt->month+1, appt->year, appt->hour, appt->minute,
  1595. !                     e_hour, e_minutes, appt->str);
  1596. !             else
  1597. !                 sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d   %s",
  1598. !                     daynames[current.tm_wday], appt->month+1,
  1599. !                     appt->day, appt->year, appt->hour, appt->minute,
  1600. !                     e_hour, e_minutes, appt->str);
  1601. !         else
  1602. !             if (day_first)
  1603. !                 sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d%s to %2d:%02d%s   %s",
  1604. !                     daynames[current.tm_wday], appt->day,
  1605. !                     appt->month+1, appt->year, (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
  1606. !                     (appt->hour < 12 ? "am" : "pm"),
  1607. !                     (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
  1608. !                     (e_hour < 12 ? "am" : "pm"),
  1609. !                     appt->str);
  1610. !             else
  1611. !                 sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d%s to %2d:%02d%s   %s",
  1612. !                     daynames[current.tm_wday], appt->month+1,
  1613. !                     appt->day, appt->year, (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
  1614. !                     (appt->hour < 12 ? "am" : "pm"),
  1615. !                     (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
  1616. !                     (e_hour < 12 ? "am" : "pm"),
  1617. !                     appt->str);
  1618. !     }
  1619.       current = Save;
  1620.       return(strbuf);
  1621.   }
  1622. ***************
  1623. *** 1046,1052
  1624.       }
  1625.   
  1626.       strbuf[0] = '\0';
  1627. !     if (!(appt->flags & A_NOTE))
  1628.           /* standard appointment */
  1629.           sprintf(strbuf,"%2d:%02d to %2d:%02d  ",
  1630.               appt->hour, appt->minute, e_hour, e_minutes);
  1631.  
  1632. --- 1074,1080 -----
  1633.       }
  1634.   
  1635.       strbuf[0] = '\0';
  1636. !     if (!(appt->flags & A_NOTE)) {
  1637.           /* standard appointment */
  1638.           if (hour24)
  1639.               sprintf(strbuf,"%2d:%02d to %2d:%02d  ",
  1640. ***************
  1641. *** 1048,1055
  1642.       strbuf[0] = '\0';
  1643.       if (!(appt->flags & A_NOTE))
  1644.           /* standard appointment */
  1645. !         sprintf(strbuf,"%2d:%02d to %2d:%02d  ",
  1646. !             appt->hour, appt->minute, e_hour, e_minutes);
  1647.       p = appt->str;
  1648.       q = strbuf + strlen(strbuf);
  1649.       while (*p) {
  1650.  
  1651. --- 1076,1091 -----
  1652.       strbuf[0] = '\0';
  1653.       if (!(appt->flags & A_NOTE)) {
  1654.           /* standard appointment */
  1655. !         if (hour24)
  1656. !             sprintf(strbuf,"%2d:%02d to %2d:%02d  ",
  1657. !                 appt->hour, appt->minute, e_hour, e_minutes);
  1658. !         else
  1659. !             sprintf(strbuf,"%2d:%02d%s to %2d:%02d%s  ",
  1660. !                 (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
  1661. !                 (appt->hour < 12 ? "am" : "pm"),
  1662. !                 (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
  1663. !                 (e_hour < 12 ? "am" : "pm"));
  1664. !     }
  1665.       p = appt->str;
  1666.       q = strbuf + strlen(strbuf);
  1667.       while (*p) {
  1668. ***************
  1669. *** 1077,1083
  1670.   }
  1671.   
  1672.   /*
  1673. !  * parse the date on the given tring and reset the "current"
  1674.    * date to reflect that date. The date may take the form of a
  1675.    * day name (e.g. Tu, Tue, Tuesday) or a date in m/d/y format
  1676.    * where the month and/or year may be missing (e.g. 27 = 27th
  1677.  
  1678. --- 1113,1119 -----
  1679.   }
  1680.   
  1681.   /*
  1682. !  * parse the date on the given string and reset the "current"
  1683.    * date to reflect that date. The date may take the form of a
  1684.    * day name (e.g. Tu, Tue, Tuesday) or a date in m/d/y format
  1685.    * where the month and/or year may be missing (e.g. 27 = 27th
  1686. ***************
  1687. *** 1084,1089
  1688.    * of this month, 8/27 = August 27 of this year, 8/27/89 =
  1689.    * August 27 of 1989. If 'cmdline' is true, then the string
  1690.    * came from the command line '-d' option.
  1691.    */
  1692.   int
  1693.   parse_date(str, cmdline)
  1694.  
  1695. --- 1120,1128 -----
  1696.    * of this month, 8/27 = August 27 of this year, 8/27/89 =
  1697.    * August 27 of 1989. If 'cmdline' is true, then the string
  1698.    * came from the command line '-d' option.
  1699. +  * If the first character of the date is + or - scan the number and
  1700. +  * use it as an offset in days from the current date.  Thus -1 becomes
  1701. +  * yesterday and +1 becomes tomorrow. pbm.
  1702.    */
  1703.   int
  1704.   parse_date(str, cmdline)
  1705. ***************
  1706. *** 1125,1134
  1707.           }
  1708.           if (y > 0)
  1709.               current.tm_year = y;
  1710. !         if (m > 0)
  1711. !             current.tm_mon = m - 1;
  1712. !         if (d > 0)
  1713. !             current.tm_mday = d;
  1714.           fix_current_day();
  1715.       } else {
  1716.           /* day of week */
  1717.  
  1718. --- 1164,1182 -----
  1719.           }
  1720.           if (y > 0)
  1721.               current.tm_year = y;
  1722. !         if (day_first) {
  1723. !             if (m > 0) {
  1724. !                 current.tm_mon = d - 1;
  1725. !                 current.tm_mday = m;
  1726. !             } else if (d > 0)
  1727. !                 current.tm_mday = d;
  1728. !         } else {
  1729. !             if (m > 0) {
  1730. !                 current.tm_mon = m - 1;
  1731. !                 current.tm_mday = d;
  1732. !             } else if (d > 0)
  1733. !                 current.tm_mday = d;
  1734. !         }
  1735.           fix_current_day();
  1736.       } else if (*str == '-' || *str == '+') {
  1737.           /*
  1738. ***************
  1739. *** 1130,1135
  1740.           if (d > 0)
  1741.               current.tm_mday = d;
  1742.           fix_current_day();
  1743.       } else {
  1744.           /* day of week */
  1745.           /* check for day names */
  1746.  
  1747. --- 1178,1193 -----
  1748.                   current.tm_mday = d;
  1749.           }
  1750.           fix_current_day();
  1751. +     } else if (*str == '-' || *str == '+') {
  1752. +         /*
  1753. +          * If the argument begins with a + or - assume that it is an
  1754. +          * offset in days from the current date. Use current date if the
  1755. +          * number doesn't scan after the - or +. pbm
  1756. +          */
  1757. +         if (sscanf(str, "%d", &i) == 1) {
  1758. +             current.tm_mday += i;
  1759. +             fix_current_day();
  1760. +         }
  1761.       } else {
  1762.           /* day of week */
  1763.           /* check for day names */
  1764. ***************
  1765. *** 1180,1186
  1766.   
  1767.       lock_cursors();
  1768.       working(TRUE);
  1769. !     sprintf(buf, "Appointments file \"%s\" printed for %s on %s", apts_pathname, cuserid(NULL), todays_date);
  1770.       if (mainsw_state != DISPLAYING_MONTH) {
  1771.           if ((fp = fopen(rasfile, "w")) != NULL) {
  1772.               rect = (Rect *) window_get(canvas, WIN_RECT);
  1773.  
  1774. --- 1238,1244 -----
  1775.   
  1776.       lock_cursors();
  1777.       working(TRUE);
  1778. !     sprintf(buf, "Appointments file \"%s\" printed for %s on %s", apts_pathname, cuserid(NULL), clockstr);
  1779.       if (mainsw_state != DISPLAYING_MONTH) {
  1780.           if ((fp = fopen(rasfile, "w")) != NULL) {
  1781.               rect = (Rect *) window_get(canvas, WIN_RECT);
  1782. ***************
  1783. *** 1217,1223
  1784.               err_rpt("only PostScript output available for month printout", NON_FATAL);
  1785.           } else {
  1786.               if ((pfp = fopen(psfile, "w")) != NULL) {
  1787. !                 print_month(pfp, FALSE);
  1788.                   fclose(pfp);
  1789.                   sprintf(prntcmd, "%s %s", printer, psfile);
  1790.                   system(prntcmd);
  1791.  
  1792. --- 1275,1281 -----
  1793.               err_rpt("only PostScript output available for month printout", NON_FATAL);
  1794.           } else {
  1795.               if ((pfp = fopen(psfile, "w")) != NULL) {
  1796. !                 print_month(pfp, TRUE);
  1797.                   fclose(pfp);
  1798.                   sprintf(prntcmd, "%s %s", printer, psfile);
  1799.                   system(prntcmd);
  1800. ***************
  1801. *** 1230,1235
  1802.       unlock_cursors();
  1803.   }
  1804.   #endif    /* NO_PRINTER */
  1805.   
  1806.   /* set error logging flag */
  1807.   err2console(state)
  1808.  
  1809. --- 1288,1294 -----
  1810.       unlock_cursors();
  1811.   }
  1812.   #endif    /* NO_PRINTER */
  1813. + #endif  /* CALENCHECK */
  1814.   
  1815.   /* set error logging flag */
  1816.   err2console(state)
  1817. ***************
  1818. *** 1252,1257
  1819.   {
  1820.       FILE    *f;
  1821.       int    closed;
  1822.   
  1823.       closed = (int) window_get(frame, FRAME_CLOSED);
  1824.       if (frame && !log_to_console && !closed) {
  1825.  
  1826. --- 1311,1317 -----
  1827.   {
  1828.       FILE    *f;
  1829.       int    closed;
  1830. +     char *getenv();
  1831.   
  1832.   #ifndef NOTOOL
  1833.       closed = (int) window_get(frame, FRAME_CLOSED);
  1834. ***************
  1835. *** 1253,1258
  1836.       FILE    *f;
  1837.       int    closed;
  1838.   
  1839.       closed = (int) window_get(frame, FRAME_CLOSED);
  1840.       if (frame && !log_to_console && !closed) {
  1841.           /* base frame exists */
  1842.  
  1843. --- 1313,1319 -----
  1844.       int    closed;
  1845.       char *getenv();
  1846.   
  1847. + #ifndef NOTOOL
  1848.       closed = (int) window_get(frame, FRAME_CLOSED);
  1849.       if (frame && !log_to_console && !closed) {
  1850.           /* base frame exists */
  1851. ***************
  1852. *** 1260,1265
  1853.           (void) window_loop(prompt_frame);
  1854.           window_set(prompt_frame, WIN_SHOW, FALSE, 0);
  1855.       } else if ((f=fopen("/dev/console", "w")) != NULL) {
  1856.           fprintf(f, "%s: %s\n", progname, errstr);
  1857.           fclose(f);
  1858.       } else
  1859.  
  1860. --- 1321,1329 -----
  1861.           (void) window_loop(prompt_frame);
  1862.           window_set(prompt_frame, WIN_SHOW, FALSE, 0);
  1863.       } else if ((f=fopen("/dev/console", "w")) != NULL) {
  1864. + #else
  1865. +     if (getenv("WINDOW_PARENT") != NULL && (f=fopen("/dev/console", "w")) != NULL) {
  1866. + #endif
  1867.           fprintf(f, "%s: %s\n", progname, errstr);
  1868.           fclose(f);
  1869.       } else
  1870. ***************
  1871. *** 1268,1273
  1872.           exit(1);
  1873.   }
  1874.   
  1875.   /* Clean-up */
  1876.   cleanup()
  1877.   {
  1878.  
  1879. --- 1332,1338 -----
  1880.           exit(1);
  1881.   }
  1882.   
  1883. + #ifndef CALENCHECK
  1884.   /* Clean-up */
  1885.   cleanup()
  1886.   {
  1887. ***************
  1888. *** 1275,1282
  1889.           close_day();
  1890.   
  1891.       /* create outdated include files (if necessary) */
  1892. !     if (save_old)
  1893. !         create_old_files();
  1894.               
  1895.       /* delete tmp file */
  1896.       if (access(tmpapts_pathname, R_OK) == 0 && unlink(tmpapts_pathname) < 0)
  1897.  
  1898. --- 1340,1347 -----
  1899.           close_day();
  1900.   
  1901.       /* create outdated include files (if necessary) */
  1902. !     if (save_old || expire_days)
  1903. !         expire(expire_days);
  1904.               
  1905.       /* delete tmp file */
  1906.       if (access(tmpapts_pathname, R_OK) == 0 && unlink(tmpapts_pathname) < 0)
  1907. ***************
  1908. *** 1296,1298
  1909.               err_rpt("couldn't rename/copy tmp file", NON_FATAL);
  1910.       }
  1911.   }
  1912.  
  1913. --- 1361,1364 -----
  1914.               err_rpt("couldn't rename/copy tmp file", NON_FATAL);
  1915.       }
  1916.   }
  1917. + #endif  /* CALENCHECK */
  1918. *** /tmp/,RCSt1a16998    Fri Dec 15 17:24:01 1989
  1919. --- version.c    Fri Dec 15 17:18:34 1989
  1920. ***************
  1921. *** 1,5
  1922.   /*
  1923. !  * $Header: version.c,v 2.5 89/09/19 06:09:07 billr Exp $
  1924.    */
  1925.   /*
  1926.    * version.c - current version of calentool program
  1927.  
  1928. --- 1,5 -----
  1929.   /*
  1930. !  * $Header: version.c,v 2.6 89/12/15 17:18:32 billr Exp $
  1931.    */
  1932.   /*
  1933.    * version.c - current version of calentool program
  1934. ***************
  1935. *** 24,27
  1936.    * notice remains intact.
  1937.    */
  1938.   
  1939. ! char version[] = "Calendar Tool V2.1p4";
  1940.  
  1941. --- 24,27 -----
  1942.    * notice remains intact.
  1943.    */
  1944.   
  1945. ! char version[] = "Calendar Tool V2.1p5";
  1946. *** /tmp/,RCSt1a17003    Fri Dec 15 17:24:04 1989
  1947. --- wevent.c    Fri Dec 15 17:18:37 1989
  1948. ***************
  1949. *** 1,5
  1950.   /*
  1951. !  * $Header: wevent.c,v 2.1 89/05/09 14:19:57 billr Exp $
  1952.    */
  1953.   /*
  1954.    * wevent.c
  1955.  
  1956. --- 1,5 -----
  1957.   /*
  1958. !  * $Header: wevent.c,v 2.2 89/12/15 17:18:35 billr Exp $
  1959.    */
  1960.   /*
  1961.    * wevent.c
  1962. ***************
  1963. *** 36,41
  1964.   #include "event.h"
  1965.   
  1966.   extern Frame prompt_frame;
  1967.   
  1968.   week_inputevent(canvas, event) 
  1969.   Canvas canvas;
  1970.  
  1971. --- 36,42 -----
  1972.   #include "event.h"
  1973.   
  1974.   extern Frame prompt_frame;
  1975. + extern int monday_first;
  1976.   
  1977.   week_inputevent(canvas, event) 
  1978.   Canvas canvas;
  1979. ***************
  1980. *** 84,89
  1981.               return;
  1982.           }
  1983.           current.tm_mday -= current.tm_wday;
  1984.           current.tm_mday += day_chosen_from_week;
  1985.           fix_current_day();
  1986.           if (nr_weekdays == 5) {
  1987.  
  1988. --- 85,96 -----
  1989.               return;
  1990.           }
  1991.           current.tm_mday -= current.tm_wday;
  1992. +         if (monday_first) {
  1993. +             if (current.tm_wday == SUN)
  1994. +                 current.tm_mday -= 7;
  1995. +             if (nr_weekdays == 7)
  1996. +                 current.tm_mday++;
  1997. +         }
  1998.           current.tm_mday += day_chosen_from_week;
  1999.           fix_current_day();
  2000.           if (nr_weekdays < 7) {
  2001. ***************
  2002. *** 86,92
  2003.           current.tm_mday -= current.tm_wday;
  2004.           current.tm_mday += day_chosen_from_week;
  2005.           fix_current_day();
  2006. !         if (nr_weekdays == 5) {
  2007.               current.tm_mday++;
  2008.               fix_current_day();
  2009.           }
  2010.  
  2011. --- 93,99 -----
  2012.           }
  2013.           current.tm_mday += day_chosen_from_week;
  2014.           fix_current_day();
  2015. !         if (nr_weekdays < 7) {
  2016.               current.tm_mday++;
  2017.               fix_current_day();
  2018.           }
  2019.