home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume39 / remind / patch09b / patch.09.C
Encoding:
Text File  |  1993-10-04  |  51.0 KB  |  1,734 lines

  1. *** ../prev/french.h    Thu Aug 26 10:49:49 1993
  2. --- ./french.h    Tue Sep 28 12:35:38 1993
  3. ***************
  4. *** 361,367 ****
  5.      fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
  6.   #endif
  7.   #ifdef ISOLATIN1
  8. !    fprintf(ErrFp, "\nUtilisation: remind [options] fichier [date]\n");
  9.      fprintf(ErrFp, "Options:\n");
  10.      fprintf(ErrFp, " -n     Afficher la prochaine occurence des rappels en format simple\n");
  11.      fprintf(ErrFp, " -r     D\351sactiver les instructions RUN\n");
  12. --- 361,367 ----
  13.      fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
  14.   #endif
  15.   #ifdef ISOLATIN1
  16. !    fprintf(ErrFp, "\nUtilisation: remind [options] fichier [date] [*r\351p\351tition]\n");
  17.      fprintf(ErrFp, "Options:\n");
  18.      fprintf(ErrFp, " -n     Afficher la prochaine occurence des rappels en format simple\n");
  19.      fprintf(ErrFp, " -r     D\351sactiver les instructions RUN\n");
  20. ***************
  21. *** 387,394 ****
  22.      fprintf(ErrFp, " -kcmd  Ex\351cuter 'cmd' pour les rappels de type MSG\n");
  23.      fprintf(ErrFp, " -g[d[d]] Trier les rappels par date et heure avant lancement\n");
  24.      fprintf(ErrFp, " -ivar=val Initialiser var \340 val et conserver var\n\n");
  25.   #else /* ISOLATIN1 */
  26. !    fprintf(ErrFp, "\nUtilisation: remind [options] fichier [date]\n");
  27.      fprintf(ErrFp, "Options:\n");
  28.      fprintf(ErrFp, " -n     Afficher la prochaine occurence des rappels en format simple\n");
  29.      fprintf(ErrFp, " -r     Desactiver les instructions RUN\n");
  30. --- 387,395 ----
  31.      fprintf(ErrFp, " -kcmd  Ex\351cuter 'cmd' pour les rappels de type MSG\n");
  32.      fprintf(ErrFp, " -g[d[d]] Trier les rappels par date et heure avant lancement\n");
  33.      fprintf(ErrFp, " -ivar=val Initialiser var \340 val et conserver var\n\n");
  34. +    fprintf(ErrFp, " -m     Commencer le calendrier avec lundi plutot que dimanche");
  35.   #else /* ISOLATIN1 */
  36. !    fprintf(ErrFp, "\nUtilisation: remind [options] fichier [date] [*repetition]\n");
  37.      fprintf(ErrFp, "Options:\n");
  38.      fprintf(ErrFp, " -n     Afficher la prochaine occurence des rappels en format simple\n");
  39.      fprintf(ErrFp, " -r     Desactiver les instructions RUN\n");
  40. ***************
  41. *** 414,419 ****
  42. --- 415,421 ----
  43.      fprintf(ErrFp, " -kcmd  Executer 'cmd' pour les rappels de type MSG\n");
  44.      fprintf(ErrFp, " -g[d[d]] Trier les rappels par date et heure avant lancement\n");
  45.      fprintf(ErrFp, " -ivar=val Initialiser var a val et conserver var\n\n");
  46. +    fprintf(ErrFp, " -m     Commencer le calendrier avec lundi plutot que dimanche");
  47.   #endif /* ISOLATIN1 */
  48.      exit(1);
  49.   }
  50. *** ../prev/funcs.c    Thu Aug 19 16:58:12 1993
  51. --- ./funcs.c    Tue Sep 28 16:45:33 1993
  52. ***************
  53. *** 81,86 ****
  54. --- 81,89 ----
  55.   PRIVATE    int    FMin        ARGS ((void));
  56.   PRIVATE    int    FMinute        ARGS ((void));
  57.   PRIVATE    int    FMinsfromutc    ARGS ((void));
  58. + PRIVATE    int    FMoondate    ARGS ((void));
  59. + PRIVATE    int    FMoonphase    ARGS ((void));
  60. + PRIVATE    int    FMoontime    ARGS ((void));
  61.   PRIVATE    int    FMon        ARGS ((void));
  62.   PRIVATE    int    FMonnum        ARGS ((void));
  63.   PRIVATE    int    FOrd        ARGS ((void));
  64. ***************
  65. *** 87,92 ****
  66. --- 90,97 ----
  67.   PRIVATE    int    FOstype     ARGS ((void));
  68.   PRIVATE    int    FPlural        ARGS ((void));
  69.   PRIVATE    int    FSgn        ARGS ((void));
  70. + PRIVATE int    FPsmoon        ARGS ((void));
  71. + PRIVATE int    FPsshade    ARGS ((void));
  72.   PRIVATE    int    FShell        ARGS ((void));
  73.   PRIVATE    int    FStrlen        ARGS ((void));
  74.   PRIVATE    int    FSubstr        ARGS ((void));
  75. ***************
  76. *** 196,205 ****
  77. --- 201,215 ----
  78.       {   "minute",    1,    1,    FMinute },
  79.       {   "mon",        1,    1,    FMon    },
  80.       {   "monnum",    1,    1,    FMonnum },
  81. +     {    "moondate",    1,    3,    FMoondate },
  82. +     {    "moonphase",    0,    2,    FMoonphase },
  83. +     {    "moontime",    1,    3,    FMoontime },
  84.       {   "now",        0,    0,    FNow    },
  85.       {   "ord",        1,    1,    FOrd    },
  86.       {   "ostype",       0,      0,      FOstype },
  87.       {   "plural",    1,    3,    FPlural },
  88. +     {    "psmoon",    1,    2,    FPsmoon},
  89. +     {    "psshade",    1,    1,    FPsshade},
  90.       {   "realtoday",    0,      0,      FRealtoday },
  91.       {   "sgn",        1,    1,    FSgn    },
  92.       {   "shell",    1,    1,    FShell    },
  93. ***************
  94. *** 2044,2046 ****
  95. --- 2054,2250 ----
  96.   
  97.      return OK;
  98.   }
  99. + /***************************************************************/
  100. + /*                                                             */
  101. + /*  FPsshade                                                   */
  102. + /*                                                             */
  103. + /*  Canned PostScript code for shading a calendar square       */
  104. + /*                                                             */
  105. + /***************************************************************/
  106. + #ifdef HAVE_PROTOS
  107. + PRIVATE int FPsshade(void)
  108. + #else
  109. + static int FPsshade()
  110. + #endif
  111. + {
  112. +    char psbuff[256];
  113. +    char *s = psbuff;
  114. +    if (ARG(0).type != INT_TYPE) return E_BAD_TYPE;
  115. +    if (ARG(0).v.val < 0) return E_2LOW;
  116. +    if (ARG(0).v.val > 100) return E_2HIGH;
  117. +    sprintf(s, "/_A LineWidth 2 div def ");
  118. +    s += strlen(s);
  119. +    sprintf(s, "_A _A moveto ");
  120. +    s += strlen(s);
  121. +    sprintf(s, "BoxWidth _A sub _A lineto BoxWidth _A sub BoxHeight _A sub lineto ");
  122. +    s += strlen(s);
  123. +    sprintf(s, "_A BoxHeight _A sub lineto closepath %d 100 div setgray fill 0.0 setgray", ARG(0).v.val);
  124. +    return RetStrVal(psbuff);
  125. + }
  126. + /***************************************************************/
  127. + /*                                                             */
  128. + /*  FPsmoon                                                    */
  129. + /*                                                             */
  130. + /*  Canned PostScript code for generating moon phases          */
  131. + /*                                                             */
  132. + /***************************************************************/
  133. + #ifdef HAVE_PROTOS
  134. + PRIVATE int FPsmoon(void)
  135. + #else
  136. + static int FPsmoon()
  137. + #endif
  138. + {
  139. +    char psbuff[256];
  140. +    char sizebuf[30];
  141. +    char *s = psbuff;
  142. +    if (ARG(0).type != INT_TYPE) return E_BAD_TYPE;
  143. +    if (ARG(0).v.val < 0) return E_2LOW;
  144. +    if (ARG(0).v.val > 3) return E_2HIGH;
  145. +    if (Nargs > 1) {
  146. +       if (ARG(1).type != INT_TYPE) return E_BAD_TYPE;
  147. +       if (ARG(1).v.val <= 0) return E_2LOW;
  148. +       sprintf(sizebuf, "%d", ARG(1).v.val);
  149. +    } else {
  150. +       strcpy(sizebuf, "DaySize 2 div");
  151. +    }
  152. +    sprintf(s, "gsave 0 setgray newpath Border %s add BoxHeight Border sub %s sub",
  153. +            sizebuf, sizebuf);
  154. +    s += strlen(s);
  155. +    sprintf(s, " %s 0 360 arc closepath", sizebuf);
  156. +    s += strlen(s);
  157. +    switch(ARG(0).v.val) {
  158. +       case 0:
  159. +      sprintf(s, " fill grestore");
  160. +      break;
  161. +       case 2:
  162. +      sprintf(s, " stroke grestore");
  163. +      break;
  164. +       case 1:
  165. +          sprintf(s, " stroke");
  166. +      s += strlen(s);
  167. +          sprintf(s, " newpath Border %s add BoxHeight Border sub %s sub",
  168. +                  sizebuf, sizebuf);
  169. +      s += strlen(s);
  170. +      sprintf(s, " %s 90 270 arc closepath fill grestore", sizebuf);
  171. +      break;
  172. +       default:
  173. +          sprintf(s, " stroke");
  174. +      s += strlen(s);
  175. +          sprintf(s, " newpath Border %s add BoxHeight Border sub %s sub",
  176. +                  sizebuf, sizebuf);
  177. +      s += strlen(s);
  178. +      sprintf(s, " %s 270 90 arc closepath fill grestore", sizebuf);
  179. +      break;
  180. +    }
  181. +    return RetStrVal(psbuff);
  182. + }
  183. + /***************************************************************/
  184. + /*                                                             */
  185. + /*  FMoonphase                                                 */
  186. + /*                                                             */
  187. + /*  Phase of moon for specified date/time.                     */
  188. + /*                                                             */
  189. + /***************************************************************/
  190. + #ifdef HAVE_PROTOS
  191. + PRIVATE int FMoonphase(void)
  192. + #else
  193. + static int FMoonphase()
  194. + #endif
  195. + {
  196. +    int date, time;
  197. +    switch(Nargs) {
  198. +       case 0:
  199. +          date = JulianToday;
  200. +      time = 0;
  201. +      break;
  202. +       case 1:
  203. +          if (ARG(0).type != DATE_TYPE) return E_BAD_TYPE;
  204. +      date = ARG(0).v.val;
  205. +      time = 0;
  206. +      break;
  207. +       case 2:
  208. +          if (ARG(0).type != DATE_TYPE && ARG(1).type != TIM_TYPE) return E_BAD_TYPE;
  209. +      date = ARG(0).v.val;
  210. +      time = ARG(1).v.val;
  211. +      break;
  212. +       default: return E_SWERR;
  213. +    }
  214. +    RetVal.type = INT_TYPE;
  215. +    RetVal.v.val = MoonPhase(date, time);
  216. +    return OK;
  217. + }
  218. + /***************************************************************/
  219. + /*                                                             */
  220. + /*  FMoondate                                                  */
  221. + /*                                                             */
  222. + /*  Hunt for next occurrence of specified moon phase           */
  223. + /*                                                             */
  224. + /***************************************************************/
  225. + PRIVATE int MoonStuff ARGS ((int want_time));
  226. + #ifdef HAVE_PROTOS
  227. + PRIVATE int FMoondate(void)
  228. + #else
  229. + static int FMoondate()
  230. + #endif
  231. + {
  232. +    return MoonStuff(0);
  233. + }
  234. + #ifdef HAVE_PROTOS
  235. + PRIVATE int FMoontime(void)
  236. + #else
  237. + static int FMoontime()
  238. + #endif
  239. + {
  240. +    return MoonStuff(1);
  241. + }
  242. + #ifdef HAVE_PROTOS
  243. + PRIVATE int MoonStuff(int want_time)
  244. + #else
  245. + static int MoonStuff(want_time)
  246. + int want_time;
  247. + #endif
  248. + {
  249. +    int startdate, starttim;
  250. +    int d, t;
  251. +    startdate = JulianToday;
  252. +    starttim = 0;
  253. +    if (ARG(0).type != INT_TYPE) return E_BAD_TYPE;
  254. +    if (ARG(0).v.val < 0) return E_2LOW;
  255. +    if (ARG(0).v.val > 3) return E_2HIGH;
  256. +    if (Nargs >= 2) {
  257. +       if (ARG(1).type != DATE_TYPE) return E_BAD_TYPE;
  258. +       startdate = ARG(1).v.val;
  259. +       if (Nargs >= 3) {
  260. +          if (ARG(2).type != TIM_TYPE) return E_BAD_TYPE;
  261. +      starttim = ARG(2).v.val;
  262. +       }
  263. +    }
  264. +    HuntPhase(startdate, starttim, ARG(0).v.val, &d, &t);
  265. +    if (want_time) {
  266. +       RetVal.type = TIM_TYPE;
  267. +       RetVal.v.val = t;
  268. +    } else {
  269. +       RetVal.type = DATE_TYPE;
  270. +       RetVal.v.val = d;
  271. +    }
  272. +    return OK;
  273. + }
  274. *** ../prev/globals.h    Thu Aug 19 15:46:05 1993
  275. --- ./globals.h    Tue Sep 28 10:56:14 1993
  276. ***************
  277. *** 39,44 ****
  278. --- 39,46 ----
  279.   EXTERN  INIT(    int     DebugFlag, 0);
  280.   EXTERN  INIT(   int    DoCalendar, 0);
  281.   EXTERN  INIT(   int     DoSimpleCalendar, 0);
  282. + EXTERN    INIT(    int    MondayFirst, 0);
  283. + EXTERN    INIT(    int    Iterations, 1);
  284.   EXTERN  INIT(   int     PsCal, 0);
  285.   EXTERN  INIT(   int     CalWidth, 80);
  286.   EXTERN  INIT(   int     CalWeeks, 0);
  287. ***************
  288. *** 86,91 ****
  289. --- 88,94 ----
  290.   EXTERN  INIT(    int      LongDeg, LON_DEG);
  291.   EXTERN  INIT(    int      LongMin, LON_MIN);
  292.   EXTERN  INIT(    int      LongSec, LON_SEC);
  293. + EXTERN    INIT(    char      *Location, LOCATION);
  294.   
  295.   /* UTC calculation stuff */
  296.   EXTERN  INIT(    int      MinsFromUTC, 0);
  297. ***************
  298. *** 96,101 ****
  299. --- 99,106 ----
  300.   EXTERN  INIT(   int      FormWidth, 72);
  301.   EXTERN    INIT(    int      FirstIndent, 0);
  302.   EXTERN    INIT(    int      SubsIndent, 0);
  303. + EXTERN    INIT(    char      *EndSent, ".?!");
  304. + EXTERN    INIT(    char      *EndSentIg, "\"')]}>");
  305.   
  306.   /* We need the language stuff here... */
  307.   
  308. *** ../prev/init.c    Fri Aug 20 11:46:29 1993
  309. --- ./init.c    Tue Sep 28 11:03:50 1993
  310. ***************
  311. *** 66,71 ****
  312. --- 66,72 ----
  313.    *             by non-root, changes environment but not effective uid.
  314.    *  -kcmd    = Run 'cmd' for MSG-type reminders instead of printing to stdout
  315.    *  -iVAR=EXPR = Initialize and preserve VAR.
  316. +  *  -m       = Start calendar with Monday instead of Sunday.
  317.    *  A minus sign alone indicates to take input from stdin
  318.    *
  319.    **************************************************************/
  320. ***************
  321. *** 104,115 ****
  322.   {
  323.      char *arg;
  324.      int i;
  325. !    int y, m, d;
  326.      Token tok;
  327.   
  328.      y = NO_YR;
  329.      m = NO_MON;
  330.      d = NO_DAY;
  331.   
  332.      RealToday = SystemDate(&CurYear, &CurMon, &CurDay);
  333.      if (RealToday < 0) {
  334. --- 105,117 ----
  335.   {
  336.      char *arg;
  337.      int i;
  338. !    int y, m, d, rep;
  339.      Token tok;
  340.   
  341.      y = NO_YR;
  342.      m = NO_MON;
  343.      d = NO_DAY;
  344. +    rep = NO_REP;
  345.   
  346.      RealToday = SystemDate(&CurYear, &CurMon, &CurDay);
  347.      if (RealToday < 0) {
  348. ***************
  349. *** 162,167 ****
  350. --- 164,174 ----
  351.              RunDisabled = 1;
  352.              break;
  353.   
  354. +         case 'm':
  355. +         case 'M':
  356. +            MondayFirst = 1;
  357. +            break;
  358.           case 'o':
  359.           case 'O':
  360.              IgnoreOnce = 1;
  361. ***************
  362. *** 358,369 ****
  363.              else y = tok.val;
  364.              break;
  365.   
  366.           default: Usage();
  367.            }
  368.         }
  369.   
  370.   /* Must supply date in the form:  day, mon, yr OR mon, yr */
  371. !       if (m == NO_MON || y == NO_YR) Usage();
  372.         if (d == NO_DAY) d=1;
  373.         if (d > DaysInMonth(m, y)) {
  374.            fprintf(ErrFp, BadDate);
  375. --- 365,394 ----
  376.              else y = tok.val;
  377.              break;
  378.   
  379. +         case T_Rep:
  380. +            rep = tok.val;
  381. +            break;
  382.           default: Usage();
  383.            }
  384.         }
  385.   
  386. +       if (rep > 0) {
  387. +          Iterations = rep;
  388. +      DontQueue = 1;
  389. +      Daemon = 0;
  390. +       }
  391.   /* Must supply date in the form:  day, mon, yr OR mon, yr */
  392. !       if (m == NO_MON || y == NO_YR) {
  393. !          if (rep == NO_REP) Usage();
  394. !      else if (m != NO_MON || y != NO_YR) Usage();
  395. !      else {
  396. !         m = CurMon;
  397. !         y = CurYear;
  398. !         if (d == NO_DAY) d = CurDay;
  399. !          }
  400. !       }
  401.         if (d == NO_DAY) d=1;
  402.         if (d > DaysInMonth(m, y)) {
  403.            fprintf(ErrFp, BadDate);
  404. ***************
  405. *** 404,410 ****
  406.   #ifdef BETA
  407.      fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
  408.   #endif
  409. !    fprintf(ErrFp, "Usage: remind [options] filename [date]\n");
  410.      fprintf(ErrFp, "Options:\n");
  411.      fprintf(ErrFp, " -n     Output next occurrence of reminders in simple format\n");
  412.      fprintf(ErrFp, " -r     Disable RUN directives\n");
  413. --- 429,435 ----
  414.   #ifdef BETA
  415.      fprintf(ErrFp, ">>>> BETA VERSION <<<<\n");
  416.   #endif
  417. !    fprintf(ErrFp, "Usage: remind [options] filename [date] [*rep]\n");
  418.      fprintf(ErrFp, "Options:\n");
  419.      fprintf(ErrFp, " -n     Output next occurrence of reminders in simple format\n");
  420.      fprintf(ErrFp, " -r     Disable RUN directives\n");
  421. ***************
  422. *** 430,435 ****
  423. --- 455,461 ----
  424.      fprintf(ErrFp, " -kcmd  Run 'cmd' for MSG-type reminders\n");
  425.      fprintf(ErrFp, " -g[d[d]] Sort reminders by date and time before issuing\n");
  426.      fprintf(ErrFp, " -ivar=val Initialize var to val and preserve var\n");
  427. +    fprintf(ErrFp, " -m     Start calendar with Monday rather than Sunday\n");
  428.      exit(1);
  429.   }
  430.   #endif /* L_USAGE_OVERRIDE */
  431. ***************
  432. *** 560,570 ****
  433.      }
  434.   
  435.      if (*varname == '$') {
  436. !       if (val.type != INT_TYPE) {
  437. !          fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[E_BAD_TYPE]);
  438. !      return;
  439. !       }
  440. !       r=SetSysVar(varname+1, val.v.val);
  441.         if (r) fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[r]);
  442.         return;
  443.      }
  444. --- 586,592 ----
  445.      }
  446.   
  447.      if (*varname == '$') {
  448. !       r=SetSysVar(varname+1, &val);
  449.         if (r) fprintf(ErrFp, ErrMsg[M_I_OPTION], ErrMsg[r]);
  450.         return;
  451.      }
  452. *** ../prev/lnk.msc    Mon Jun 28 12:30:12 1993
  453. --- ./lnk.msc    Mon Sep 20 14:59:42 1993
  454. ***************
  455. *** 8,13 ****
  456. --- 8,14 ----
  457.   hbcal.obj +
  458.   init.obj +
  459.   main.obj +
  460. + moon.obj +
  461.   omit.obj +
  462.   sort.obj +
  463.   token.obj +
  464. *** ../prev/lnk.tc    Mon Jun 28 12:30:13 1993
  465. --- ./lnk.tc    Mon Sep 20 14:59:34 1993
  466. ***************
  467. *** 9,14 ****
  468. --- 9,15 ----
  469.   hbcal.obj
  470.   init.obj
  471.   main.obj
  472. + moon.obj
  473.   omit.obj
  474.   sort.obj
  475.   token.obj
  476. *** ../prev/main.c    Wed Aug 25 13:06:26 1993
  477. --- ./main.c    Tue Sep 28 16:50:30 1993
  478. ***************
  479. *** 80,86 ****
  480.   
  481.   /* The very first thing to do is to set up ErrFp to be stderr */
  482.      ErrFp = stderr;
  483. !    
  484.   /* Set up global vars */
  485.      ArgC = argc;
  486.      ArgV = argv;
  487. --- 80,86 ----
  488.   
  489.   /* The very first thing to do is to set up ErrFp to be stderr */
  490.      ErrFp = stderr;
  491.   /* Set up global vars */
  492.      ArgC = argc;
  493.      ArgV = argv;
  494. ***************
  495. *** 92,147 ****
  496.      }
  497.   
  498.      /* Not doing a calendar.  Do the regular remind loop */
  499. !    DoReminders();
  500.   
  501. !    if (DebugFlag & DB_DUMP_VARS) {
  502. !       DumpVarTable();
  503. !       DumpSysVarByName(NULL);
  504. !    }
  505.   
  506. !    if (!Hush) {
  507. !       if (DestroyOmitContexts())
  508. !     Eprint("%s", E_PUSH_NOPOP);
  509.   #ifdef HAVE_QUEUED
  510. !       if (!Daemon && !NextMode && !NumTriggered && !NumQueued) printf("%s\n", ErrMsg[E_NOREMINDERS]);
  511. !    else
  512. !       if (!Daemon && !NextMode && !NumTriggered) printf(ErrMsg[M_QUEUED],
  513. !          NumQueued);
  514.   #else
  515. !       if (!NextMode && !NumTriggered) printf("%s\n", ErrMsg[E_NOREMINDERS]);
  516.   #endif
  517. !    }
  518.   
  519.      /* If it's MS-DOS or OS2, reset the file access date */
  520.   #if defined(__MSDOS__) || defined(OS2)
  521. !    if (!UseStdin && (RealToday == JulianToday))
  522. !       SetAccessDate(InitialFile, RealToday);
  523.   #endif
  524.   
  525.      /* If there are sorted reminders, handle them */
  526. !    if (SortByDate) IssueSortedReminders();
  527.   
  528.      /* If there are any background reminders queued up, handle them */
  529.   #ifdef HAVE_QUEUED
  530. !    if (NumQueued || Daemon) {
  531.   
  532. !       if (DontFork) {
  533. !      HandleQueuedReminders();
  534. !      return 0;
  535. !       } else {
  536. !      pid = fork();
  537. !      if (pid == 0) {
  538. !         HandleQueuedReminders();
  539. !         return 0;
  540. !      }
  541. !      if (pid == -1) {
  542. !         fprintf(ErrFp, "%s", ErrMsg[E_CANTFORK]);
  543. !         return 1;
  544. !      }
  545.         }
  546. -    }
  547.   #endif
  548.      return 0;
  549.   }
  550.   
  551. --- 92,157 ----
  552.      }
  553.   
  554.      /* Not doing a calendar.  Do the regular remind loop */
  555. !    ShouldCache = (Iterations > 1);
  556.   
  557. !    while (Iterations--) {
  558. !       DoReminders();
  559.   
  560. !       if (DebugFlag & DB_DUMP_VARS) {
  561. !          DumpVarTable();
  562. !          DumpSysVarByName(NULL);
  563. !       }
  564. !       if (!Hush) {
  565. !          if (DestroyOmitContexts())
  566. !          Eprint("%s", E_PUSH_NOPOP);
  567.   #ifdef HAVE_QUEUED
  568. !          if (!Daemon && !NextMode && !NumTriggered && !NumQueued) printf("%s\n", ErrMsg[E_NOREMINDERS]);
  569. !       else
  570. !          if (!Daemon && !NextMode && !NumTriggered) printf(ErrMsg[M_QUEUED],
  571. !             NumQueued);
  572.   #else
  573. !          if (!NextMode && !NumTriggered) printf("%s\n", ErrMsg[E_NOREMINDERS]);
  574.   #endif
  575. !       }
  576.   
  577.      /* If it's MS-DOS or OS2, reset the file access date */
  578.   #if defined(__MSDOS__) || defined(OS2)
  579. !       if (!UseStdin && (RealToday == JulianToday))
  580. !          SetAccessDate(InitialFile, RealToday);
  581.   #endif
  582.   
  583.      /* If there are sorted reminders, handle them */
  584. !       if (SortByDate) IssueSortedReminders();
  585.   
  586.      /* If there are any background reminders queued up, handle them */
  587.   #ifdef HAVE_QUEUED
  588. !       if (NumQueued || Daemon) {
  589.   
  590. !          if (DontFork) {
  591. !            HandleQueuedReminders();
  592. !           return 0;
  593. !          } else {
  594. !         pid = fork();
  595. !         if (pid == 0) {
  596. !            HandleQueuedReminders();
  597. !            return 0;
  598. !         }
  599. !         if (pid == -1) {
  600. !            fprintf(ErrFp, "%s", ErrMsg[E_CANTFORK]);
  601. !            return 1;
  602. !         }
  603. !          }
  604.         }
  605.   #endif
  606. !       if (Iterations) {
  607. !          ClearGlobalOmits();
  608. !          DestroyOmitContexts();
  609. !          DestroyVars(0);
  610. !          NumTriggered = 0;
  611. !      JulianToday++;
  612. !       }
  613. !    }
  614.      return 0;
  615.   }
  616.   
  617. ***************
  618. *** 213,219 ****
  619.           case T_Else:    r=DoElse(&p);    break;
  620.           case T_EndIf:   r=DoEndif(&p);   break;
  621.           case T_Include: r=DoInclude(&p); break;
  622. !         case T_Exit:    exit(99);        break;
  623.           case T_Set:     r=DoSet(&p);     break;
  624.           case T_Fset:    r=DoFset(&p);    break;
  625.           case T_UnSet:   r=DoUnset(&p);   break;
  626. --- 223,230 ----
  627.           case T_Else:    r=DoElse(&p);    break;
  628.           case T_EndIf:   r=DoEndif(&p);   break;
  629.           case T_Include: r=DoInclude(&p); break;
  630. !         case T_Exit:    DoExit(&p);      break;
  631. !         case T_Flush:   r=DoFlush(&p);   break;
  632.           case T_Set:     r=DoSet(&p);     break;
  633.           case T_Fset:    r=DoFset(&p);    break;
  634.           case T_UnSet:   r=DoUnset(&p);   break;
  635. ***************
  636. *** 239,246 ****
  637.                   r=DoRem(&p);
  638.                   break;
  639.                    }
  640. -                  
  641.   
  642.        /* If we don't recognize the command, do a REM by default */
  643.        /* Note:  Since the parser hasn't been used yet, we don't */
  644.        /* need to destroy it here. */
  645. --- 250,257 ----
  646.                   r=DoRem(&p);
  647.                   break;
  648.                    }
  649.   
  650.        /* If we don't recognize the command, do a REM by default */
  651.        /* Note:  Since the parser hasn't been used yet, we don't */
  652.        /* need to destroy it here. */
  653. ***************
  654. *** 306,318 ****
  655.      int y400 = (y2 / 400) - (y1 / 400); /* ... but do count multiples of 400 */
  656.   
  657.      int try_jul= 365 * (try_yr-BASE) + y4 - y100 + y400;
  658. !    
  659.      while (try_jul > jul) {
  660.         try_yr--;
  661.         try_jul -= DaysInYear(try_yr);
  662.      }
  663.      jul -= try_jul;
  664. !    
  665.      t = DaysInMonth(try_mon, try_yr);
  666.      while (jul >= t) {
  667.         jul -= t;
  668. --- 317,329 ----
  669.      int y400 = (y2 / 400) - (y1 / 400); /* ... but do count multiples of 400 */
  670.   
  671.      int try_jul= 365 * (try_yr-BASE) + y4 - y100 + y400;
  672.      while (try_jul > jul) {
  673.         try_yr--;
  674.         try_jul -= DaysInYear(try_yr);
  675.      }
  676.      jul -= try_jul;
  677.      t = DaysInMonth(try_mon, try_yr);
  678.      while (jul >= t) {
  679.         jul -= t;
  680. ***************
  681. *** 436,442 ****
  682.   {
  683.      int c, err;
  684.      int len = 0;
  685. !    
  686.      *out = 0;
  687.   
  688.      c = ParseChar(p, &err, 0);
  689. --- 447,453 ----
  690.   {
  691.      int c, err;
  692.      int len = 0;
  693.      *out = 0;
  694.   
  695.      c = ParseChar(p, &err, 0);
  696. ***************
  697. *** 480,486 ****
  698.   {
  699.      int c, err;
  700.      int len = 0;
  701. !    
  702.      *out = 0;
  703.   
  704.      c = ParseChar(p, &err, 0);
  705. --- 491,497 ----
  706.   {
  707.      int c, err;
  708.      int len = 0;
  709.      *out = 0;
  710.   
  711.      c = ParseChar(p, &err, 0);
  712. ***************
  713. *** 566,572 ****
  714.   #ifndef HAVE_STDARG
  715.      char *fmt;
  716.   #endif
  717. !    
  718.      /* Check if more than one error msg. from this line */
  719.      if (!FreshLine && !ShowAllErrors) return;
  720.   
  721. --- 577,583 ----
  722.   #ifndef HAVE_STDARG
  723.      char *fmt;
  724.   #endif
  725.      /* Check if more than one error msg. from this line */
  726.      if (!FreshLine && !ShowAllErrors) return;
  727.   
  728. ***************
  729. *** 679,685 ****
  730.      strcpy(TPushBuffer, tok);
  731.      strcat(TPushBuffer, " ");  /* Separate the pushed token from the next
  732.                            token */
  733. !    
  734.   }
  735.   
  736.   /***************************************************************/
  737. --- 690,696 ----
  738.      strcpy(TPushBuffer, tok);
  739.      strcat(TPushBuffer, " ");  /* Separate the pushed token from the next
  740.                            token */
  741.   }
  742.   
  743.   /***************************************************************/
  744. ***************
  745. *** 779,785 ****
  746.         if ( (r = EvaluateExpr(p, &v)) ) {
  747.            syndrome = IF_TRUE | BEFORE_ELSE;
  748.        Eprint("%s", ErrMsg[r]);
  749. !       } else 
  750.            if ( (v.type != STR_TYPE && v.v.val) ||
  751.                 (v.type == STR_TYPE && strcmp(v.v.str, "")) )
  752.               syndrome = IF_TRUE | BEFORE_ELSE;
  753. --- 790,796 ----
  754.         if ( (r = EvaluateExpr(p, &v)) ) {
  755.            syndrome = IF_TRUE | BEFORE_ELSE;
  756.        Eprint("%s", ErrMsg[r]);
  757. !       } else
  758.            if ( (v.type != STR_TYPE && v.v.val) ||
  759.                 (v.type == STR_TYPE && strcmp(v.v.str, "")) )
  760.               syndrome = IF_TRUE | BEFORE_ELSE;
  761. ***************
  762. *** 877,883 ****
  763.      return OK;
  764.   }
  765.   
  766. !        
  767.   /***************************************************************/
  768.   /*                                                             */
  769.   /*  ShouldIgnoreLine - given the current state of the IF       */
  770. --- 888,894 ----
  771.      return OK;
  772.   }
  773.   
  774.   /***************************************************************/
  775.   /*                                                             */
  776.   /*  ShouldIgnoreLine - given the current state of the IF       */
  777. ***************
  778. *** 943,949 ****
  779.   {
  780.      int err;
  781.      int ch;
  782. !    int val=1;     
  783.   
  784.      while(1) {
  785.         ch = ParseChar(p, &err, 0);
  786. --- 954,960 ----
  787.   {
  788.      int err;
  789.      int ch;
  790. !    int val=1;
  791.   
  792.      while(1) {
  793.         ch = ParseChar(p, &err, 0);
  794. ***************
  795. *** 965,971 ****
  796.        case '-':
  797.           val = 0;
  798.           break;
  799. !  
  800.         case 'e':
  801.         case 'E':
  802.           if (val) DebugFlag |=  DB_ECHO_LINE;
  803. --- 976,982 ----
  804.        case '-':
  805.           val = 0;
  806.           break;
  807.         case 'e':
  808.         case 'E':
  809.           if (val) DebugFlag |=  DB_ECHO_LINE;
  810. ***************
  811. *** 1072,1077 ****
  812. --- 1083,1129 ----
  813.   
  814.   /***************************************************************/
  815.   /*                                                             */
  816. + /*  DoFlush                                                    */
  817. + /*                                                             */
  818. + /*  Flush stdout and stderr                                    */
  819. + /*                                                             */
  820. + /***************************************************************/
  821. + #ifdef HAVE_PROTOS
  822. + PUBLIC int DoFlush(ParsePtr p)
  823. + #else
  824. + int DoFlush(p)
  825. + ParsePtr p;
  826. + #endif
  827. + {
  828. +    fflush(stdout);
  829. +    fflush(stderr);
  830. +    return VerifyEoln(p);
  831. + }
  832. + /***************************************************************/
  833. + /*                                                             */
  834. + /*  DoExit                                                     */
  835. + /*                                                             */
  836. + /*  Handle the EXIT command.                                   */
  837. + /*                                                             */
  838. + /***************************************************************/
  839. + #ifdef HAVE_PROTOS
  840. + PUBLIC void DoExit(ParsePtr p)
  841. + #else
  842. + void DoExit(p)
  843. + ParsePtr p;
  844. + #endif
  845. + {
  846. +    int r;
  847. +    Value v;
  848. +    r = EvaluateExpr(p, &v);
  849. +    if (r || v.type != INT_TYPE) exit(99);
  850. +    exit(v.v.val);
  851. + }
  852. + /***************************************************************/
  853. + /*                                                             */
  854.   /*  DoErrMsg                                                   */
  855.   /*                                                             */
  856.   /*  Issue an error message under program control.              */
  857. ***************
  858. *** 1091,1097 ****
  859.   
  860.      t.typ = MSG_TYPE;
  861.      tt.ttime = SystemTime() / 60;
  862. !    if ( (r=DoSubst(p, SubstBuffer, &t, &tt, JulianToday, NORMAL_MODE)) ) 
  863.         return r;
  864.      s = SubstBuffer;
  865.      while (isspace(*s)) s++;
  866. --- 1143,1149 ----
  867.   
  868.      t.typ = MSG_TYPE;
  869.      tt.ttime = SystemTime() / 60;
  870. !    if ( (r=DoSubst(p, SubstBuffer, &t, &tt, JulianToday, NORMAL_MODE)) )
  871.         return r;
  872.      s = SubstBuffer;
  873.      while (isspace(*s)) s++;
  874. ***************
  875. *** 1112,1118 ****
  876.      on the specified weekday.  For example, FoldArray[0][2] is a
  877.      non-leapyear beginning on Wednesday, and FoldArray[1][5] is a
  878.      leapyear beginning on Saturday.  Used to fold back dates which
  879. !    are too high for the standard Unix representation. 
  880.      NOTE:  This implies that you cannot set BASE > 2001!!!!! */
  881.   static int FoldArray[2][7] = {
  882.      {2001, 2002, 2003, 2009, 2010, 2005, 2006},
  883. --- 1164,1170 ----
  884.      on the specified weekday.  For example, FoldArray[0][2] is a
  885.      non-leapyear beginning on Wednesday, and FoldArray[1][5] is a
  886.      leapyear beginning on Saturday.  Used to fold back dates which
  887. !    are too high for the standard Unix representation.
  888.      NOTE:  This implies that you cannot set BASE > 2001!!!!! */
  889.   static int FoldArray[2][7] = {
  890.      {2001, 2002, 2003, 2009, 2010, 2005, 2006},
  891. ***************
  892. *** 1168,1174 ****
  893.                                (loc_t - utc_t) / 60 );  /* Should use difftime */
  894.   #else
  895.      if (mins) *mins = (int) ((utc_t - loc_t) / 60);
  896. ! #endif   
  897.      if (isdst) *isdst = temp->tm_isdst;
  898.      return 0;
  899.   }
  900. --- 1220,1226 ----
  901.                                (loc_t - utc_t) / 60 );  /* Should use difftime */
  902.   #else
  903.      if (mins) *mins = (int) ((utc_t - loc_t) / 60);
  904. ! #endif
  905.      if (isdst) *isdst = temp->tm_isdst;
  906.      return 0;
  907.   }
  908. ***************
  909. *** 1180,1189 ****
  910.   /*  Write a string to standard output, formatting it as a      */
  911.   /*  paragraph according to the FirstIndent, FormWidth and      */
  912.   /*  SubsIndent variables.  Spaces are gobbled.  Double-spaces  */
  913. ! /*  are inserted after periods.  As a special case, if the     */
  914. ! /*  last char in s is '\n', an extra newline is emitted.       */
  915.   /*                                                             */
  916.   /***************************************************************/
  917.   #ifdef HAVE_PROTOS
  918.   PUBLIC void FillParagraph(char *s)
  919.   #else
  920. --- 1232,1245 ----
  921.   /*  Write a string to standard output, formatting it as a      */
  922.   /*  paragraph according to the FirstIndent, FormWidth and      */
  923.   /*  SubsIndent variables.  Spaces are gobbled.  Double-spaces  */
  924. ! /*  are inserted after '.', '?' and '!'.  Newlines in the      */
  925. ! /*  source are treated as paragraph breaks.                    */
  926.   /*                                                             */
  927.   /***************************************************************/
  928. + /* A macro safe ONLY if used with arg with no side effects! */
  929. + #define ISBLANK(c) (isspace(c) && (c) != '\n')
  930.   #ifdef HAVE_PROTOS
  931.   PUBLIC void FillParagraph(char *s)
  932.   #else
  933. ***************
  934. *** 1194,1199 ****
  935. --- 1250,1256 ----
  936.   
  937.      int line = 0;
  938.      int i, j;
  939. +    int doublespace = 1;
  940.      int pendspace;
  941.      int len;
  942.      char *t;
  943. ***************
  944. *** 1203,1214 ****
  945.      if (!s || !*s) return;
  946.   
  947.      /* Skip leading spaces */
  948. !    while(isspace(*s)) s++;
  949.   
  950.      /* Start formatting */
  951.      while(1) {
  952.         if (!*s) {
  953. !          if (*(s-1) == '\n') putchar('\n');
  954.            return;
  955.         }
  956.         /* Over here, we're at the beginning of a line.  Emit the correct
  957. --- 1260,1280 ----
  958.      if (!s || !*s) return;
  959.   
  960.      /* Skip leading spaces */
  961. !    while(ISBLANK(*s)) s++;
  962.   
  963.      /* Start formatting */
  964.      while(1) {
  965. +       /* If it's a carriage return, output it and start new paragraph */
  966. +       if (*s == '\n') {
  967. +          putchar('\n');
  968. +      s++;
  969. +      line = 0;
  970. +      while(ISBLANK(*s)) s++;
  971. +      continue;
  972. +       }
  973.         if (!*s) {
  974. !          putchar('\n');
  975.            return;
  976.         }
  977.         /* Over here, we're at the beginning of a line.  Emit the correct
  978. ***************
  979. *** 1222,1234 ****
  980.   
  981.         /* Emit words until the next one won't fit */
  982.         while(1) {
  983. !          while(isspace(*s)) s++;
  984.            t = s;
  985.            while(*s && !isspace(*s)) s++;
  986.        len = s - t;
  987.        if (!len) {
  988.           putchar('\n');
  989. -             if (*(s-1) == '\n') putchar('\n');
  990.           return;
  991.            }
  992.        if (!pendspace || len+pendspace <= roomleft) {
  993. --- 1288,1300 ----
  994.   
  995.         /* Emit words until the next one won't fit */
  996.         while(1) {
  997. !          while(ISBLANK(*s)) s++;
  998. !      if (*s == '\n') break;
  999.            t = s;
  1000.            while(*s && !isspace(*s)) s++;
  1001.        len = s - t;
  1002.        if (!len) {
  1003.           putchar('\n');
  1004.           return;
  1005.            }
  1006.        if (!pendspace || len+pendspace <= roomleft) {
  1007. ***************
  1008. *** 1235,1240 ****
  1009. --- 1301,1308 ----
  1010.               for (i=0; i<pendspace; i++) putchar(' ');
  1011.              while(t < s) {
  1012.              putchar(*t);
  1013. +            if (strchr(EndSent, *t)) doublespace = 2;
  1014. +            else if (!strchr(EndSentIg, *t)) doublespace = 1;
  1015.              t++;
  1016.               }
  1017.            } else {
  1018. ***************
  1019. *** 1243,1250 ****
  1020.           line++;
  1021.           break;
  1022.            }
  1023. !      pendspace = (*(t-1) == '.') ? 2 : 1;
  1024. !      roomleft -= len+pendspace;
  1025.         }
  1026.      }
  1027.   }
  1028. --- 1311,1318 ----
  1029.           line++;
  1030.           break;
  1031.            }
  1032. !      roomleft -= len+doublespace;
  1033. !      pendspace = doublespace;
  1034.         }
  1035.      }
  1036.   }
  1037. ***************
  1038. *** 1266,1272 ****
  1039.       long guess = time((long *) NULL);
  1040.       struct tm g;
  1041.       int diff;
  1042. !     
  1043.       g = *gmtime (&guess);
  1044.       while ((diff = year - g.tm_year) > 0)
  1045.       {
  1046. --- 1334,1340 ----
  1047.       long guess = time((long *) NULL);
  1048.       struct tm g;
  1049.       int diff;
  1050.       g = *gmtime (&guess);
  1051.       while ((diff = year - g.tm_year) > 0)
  1052.       {
  1053. ***************
  1054. *** 1323,1325 ****
  1055. --- 1391,1458 ----
  1056.       return (clock);
  1057.   }
  1058.   #endif /* NEED_TIMEGM */
  1059. + /***************************************************************/
  1060. + /*                                                             */
  1061. + /*  LocalToUTC                                                 */
  1062. + /*                                                             */
  1063. + /*  Convert a local date/time to a UTC date/time.              */
  1064. + /*                                                             */
  1065. + /***************************************************************/
  1066. + #ifdef HAVE_PROTOS
  1067. + PUBLIC void LocalToUTC(int locdate, int loctime, int *utcdate, int *utctime)
  1068. + #else
  1069. + void LocalToUTC(locdate, loctime, utcdate, utctime)
  1070. + int locdate, loctime, *utcdate, *utctime;
  1071. + #endif
  1072. + {
  1073. +    int diff;
  1074. +    int dummy;
  1075. +    if (!CalculateUTC || !CalcMinsFromUTC(locdate, loctime, &diff, &dummy)) 
  1076. +    diff=MinsFromUTC;
  1077. +    loctime -= MinsFromUTC;
  1078. +    if (loctime < 0) {
  1079. +       loctime += 1440;
  1080. +       locdate--;
  1081. +    } else if (loctime >= 1440) {
  1082. +       loctime -= 1440;
  1083. +       locdate++;
  1084. +    }
  1085. +    *utcdate = locdate;
  1086. +    *utctime = loctime;
  1087. + }
  1088. + /***************************************************************/
  1089. + /*                                                             */
  1090. + /*  UTCToLocal                                                 */
  1091. + /*                                                             */
  1092. + /*  Convert a UTC date/time to a local date/time.              */
  1093. + /*                                                             */
  1094. + /***************************************************************/
  1095. + #ifdef HAVE_PROTOS
  1096. + PUBLIC void UTCToLocal(int utcdate, int utctime, int *locdate, int *loctime)
  1097. + #else
  1098. + void UTCToLocal(utcdate, utctime, locdate, loctime)
  1099. + int utcdate, utctime, *locdate, *loctime;
  1100. + #endif
  1101. + {
  1102. +    int diff;
  1103. +    int dummy;
  1104. +    /* Hack -- not quite right when DST changes.  */
  1105. +    if (!CalculateUTC || !CalcMinsFromUTC(utcdate, utctime, &diff, &dummy)) 
  1106. +    diff=MinsFromUTC;
  1107. +    utctime += MinsFromUTC;
  1108. +    if (utctime < 0) {
  1109. +       utctime += 1440;
  1110. +       utcdate--;
  1111. +    } else if (utctime >= 1440) {
  1112. +       utctime -= 1440;
  1113. +       utcdate++;
  1114. +    }
  1115. +    *locdate = utcdate;
  1116. +    *loctime = utctime;
  1117. + }
  1118. *** ../prev/makefile.msc    Mon Jun 28 12:30:11 1993
  1119. --- ./makefile.msc    Thu Sep 30 15:50:35 1993
  1120. ***************
  1121. *** 2,12 ****
  1122.   
  1123.   OBJS= calendar.obj dorem.obj dosubst.obj expr.obj files.obj funcs.obj \
  1124.   globals.obj init.obj main.obj omit.obj token.obj trigger.obj userfns.obj \
  1125. ! utils.obj var.obj sort.obj hbcal.obj
  1126.   
  1127.   DEFINES= /D__MSDOS__ /D__MSC__
  1128.   
  1129. ! MODEL= /AS
  1130.   
  1131.   calendar.obj: calendar.c
  1132.       cl /c $(DEFINES) $(MODEL) /Focalendar.obj calendar.c
  1133. --- 2,12 ----
  1134.   
  1135.   OBJS= calendar.obj dorem.obj dosubst.obj expr.obj files.obj funcs.obj \
  1136.   globals.obj init.obj main.obj omit.obj token.obj trigger.obj userfns.obj \
  1137. ! utils.obj var.obj sort.obj hbcal.obj moon.obj
  1138.   
  1139.   DEFINES= /D__MSDOS__ /D__MSC__
  1140.   
  1141. ! MODEL= /AM
  1142.   
  1143.   calendar.obj: calendar.c
  1144.       cl /c $(DEFINES) $(MODEL) /Focalendar.obj calendar.c
  1145. ***************
  1146. *** 40,45 ****
  1147. --- 40,48 ----
  1148.   
  1149.   main.obj: main.c
  1150.       cl /c $(DEFINES) $(MODEL) /Fomain.obj main.c
  1151. + moon.obj: moon.c
  1152. +     cl /c $(DEFINES) $(MODEL) /Fomoon.obj moon.c
  1153.   
  1154.   omit.obj: omit.c
  1155.       cl /c $(DEFINES) $(MODEL) /Foomit.obj omit.c
  1156. *** ../prev/makefile.os2    Wed Aug 18 11:13:19 1993
  1157. --- ./makefile.os2    Mon Sep 20 15:00:08 1993
  1158. ***************
  1159. *** 25,31 ****
  1160.   # YOU SHOULDN'T EDIT ANYTHING BELOW HERE.  You may want to change some things
  1161.   # in config.h; then, you should be able to type 'make'.
  1162.   #-----------------------------------------------------------------------------
  1163. ! VERSION= 03.00.08
  1164.   
  1165.   HDRS= config.h err.h expr.h globals.h protos.h types.h version.h \
  1166.   lang.h english.h german.h dutch.h finish.h french.h norwgian.h
  1167. --- 25,31 ----
  1168.   # YOU SHOULDN'T EDIT ANYTHING BELOW HERE.  You may want to change some things
  1169.   # in config.h; then, you should be able to type 'make'.
  1170.   #-----------------------------------------------------------------------------
  1171. ! VERSION= 03.00.09
  1172.   
  1173.   HDRS= config.h err.h expr.h globals.h protos.h types.h version.h \
  1174.   lang.h english.h german.h dutch.h finish.h french.h norwgian.h
  1175. ***************
  1176. *** 35,41 ****
  1177.   LANGHDRS= english.h german.h dutch.h finnish.h french.h norwgian.h
  1178.   
  1179.   SRCS= calendar.c dorem.c dosubst.c expr.c files.c funcs.c globals.c init.c \
  1180. ! main.c omit.c sort.c token.c trigger.c userfns.c utils.c var.c hbcal.c
  1181.   
  1182.   MANIFEST= README.UNIX README.DOS COPYRIGHT $(HDRS) $(SRCS) Makefile rem rem.1 \
  1183.   remind.1 remind-all.csh remind-all.sh test.rem test-rem test.cmp makefile.tc \
  1184. --- 35,41 ----
  1185.   LANGHDRS= english.h german.h dutch.h finnish.h french.h norwgian.h
  1186.   
  1187.   SRCS= calendar.c dorem.c dosubst.c expr.c files.c funcs.c globals.c init.c \
  1188. ! main.c moon.c omit.c sort.c token.c trigger.c userfns.c utils.c var.c hbcal.c
  1189.   
  1190.   MANIFEST= README.UNIX README.DOS COPYRIGHT $(HDRS) $(SRCS) Makefile rem rem.1 \
  1191.   remind.1 remind-all.csh remind-all.sh test.rem test-rem test.cmp makefile.tc \
  1192. ***************
  1193. *** 77,82 ****
  1194. --- 77,83 ----
  1195.   globals$O: globals.c config.h types.h globals.h err.h lang.h
  1196.   init$O: init.c $(STDHDRS) expr.h version.h
  1197.   main$O: main.c $(STDHDRS) expr.h
  1198. + moon$O: moon.c $(STDHDRS)
  1199.   omit$O: omit.c $(STDHDRS)
  1200.   sort$O: sort.c $(STDHDRS)
  1201.   token$O: token.c $(STDHDRS)
  1202. *** ../prev/makefile.tc    Wed Aug 18 11:13:06 1993
  1203. --- ./makefile.tc    Thu Sep 30 15:50:25 1993
  1204. ***************
  1205. *** 1,6 ****
  1206.   # Makefile for REMIND for Turbo C for MSDOS
  1207.   
  1208. ! VERSION= 03.00.08
  1209.   
  1210.   HDRS= config.h err.h expr.h globals.h protos.h types.h version.h \
  1211.   lang.h english.h german.h dutch.h finnish.h french.h norwgian.h
  1212. --- 1,6 ----
  1213.   # Makefile for REMIND for Turbo C for MSDOS
  1214.   
  1215. ! VERSION= 03.00.09
  1216.   
  1217.   HDRS= config.h err.h expr.h globals.h protos.h types.h version.h \
  1218.   lang.h english.h german.h dutch.h finnish.h french.h norwgian.h
  1219. ***************
  1220. *** 10,16 ****
  1221.   LANGHDRS= english.h german.h dutch.h finnish.h french.h norwgian.h
  1222.   
  1223.   SRCS= calendar.c dorem.c dosubst.c expr.c files.c funcs.c globals.c init.c \
  1224. ! main.c omit.c sort.c token.c trigger.c userfns.c utils.c var.c hbcal.c
  1225.   
  1226.   OBJS=calendar.obj dorem.obj dosubst.obj expr.obj files.obj funcs.obj \
  1227.   globals.obj init.obj main.obj omit.obj sort.obj token.obj trigger.obj \
  1228. --- 10,16 ----
  1229.   LANGHDRS= english.h german.h dutch.h finnish.h french.h norwgian.h
  1230.   
  1231.   SRCS= calendar.c dorem.c dosubst.c expr.c files.c funcs.c globals.c init.c \
  1232. ! moon.c main.c omit.c sort.c token.c trigger.c userfns.c utils.c var.c hbcal.c
  1233.   
  1234.   OBJS=calendar.obj dorem.obj dosubst.obj expr.obj files.obj funcs.obj \
  1235.   globals.obj init.obj main.obj omit.obj sort.obj token.obj trigger.obj \
  1236. ***************
  1237. *** 31,37 ****
  1238.       tcc -erem2ps.exe rem2ps.obj
  1239.   
  1240.   .c.obj:
  1241. !     tcc -A -w-pia -c -O -ms {$< }
  1242.   
  1243.   rem2ps.obj: rem2ps.c rem2ps.h config.h lang.h
  1244.   
  1245. --- 31,37 ----
  1246.       tcc -erem2ps.exe rem2ps.obj
  1247.   
  1248.   .c.obj:
  1249. !     tcc -A -w-pia -c -O -mm {$< }
  1250.   
  1251.   rem2ps.obj: rem2ps.c rem2ps.h config.h lang.h
  1252.   
  1253. ***************
  1254. *** 52,57 ****
  1255. --- 52,59 ----
  1256.   init.obj: init.c $(STDHDRS) expr.h version.h
  1257.   
  1258.   main.obj: main.c $(STDHDRS) expr.h
  1259. + moon.obj: moon.c $(STDHDRS) expr.h
  1260.   
  1261.   omit.obj: omit.c $(STDHDRS)
  1262.   
  1263. *** ../prev/protos.h    Wed Aug 18 12:52:08 1993
  1264. --- ./protos.h    Mon Sep 20 16:53:13 1993
  1265. ***************
  1266. *** 29,34 ****
  1267. --- 29,36 ----
  1268.   void ProduceCalendar ARGS ((void));
  1269.   char *SimpleTime ARGS ((int tim, char *out));
  1270.   int DoRem ARGS ((ParsePtr p));
  1271. + int DoFlush ARGS ((ParsePtr p));
  1272. + void DoExit ARGS ((ParsePtr p));
  1273.   int ParseRem ARGS ((ParsePtr s, Trigger *trig, TimeTrig *tim));
  1274.   int TriggerReminder ARGS ((ParsePtr p, Trigger *t, TimeTrig *tim, int jul));
  1275.   int ShouldTriggerReminder ARGS ((Trigger *t, TimeTrig *tim, int jul));
  1276. ***************
  1277. *** 103,109 ****
  1278.   int DoUnset  ARGS ((Parser *p));
  1279.   int DoDump ARGS ((ParsePtr p));
  1280.   void DumpVarTable ARGS ((void));
  1281. ! void DestroyVars ARGS ((void));
  1282.   int PreserveVar ARGS ((char *name));
  1283.   int DoPreserve  ARGS ((Parser *p));
  1284.   int DoSatRemind ARGS ((Trigger *trig, TimeTrig *tim, ParsePtr p));
  1285. --- 105,111 ----
  1286.   int DoUnset  ARGS ((Parser *p));
  1287.   int DoDump ARGS ((ParsePtr p));
  1288.   void DumpVarTable ARGS ((void));
  1289. ! void DestroyVars ARGS ((int all));
  1290.   int PreserveVar ARGS ((char *name));
  1291.   int DoPreserve  ARGS ((Parser *p));
  1292.   int DoSatRemind ARGS ((Trigger *trig, TimeTrig *tim, ParsePtr p));
  1293. ***************
  1294. *** 126,132 ****
  1295.   int GetNextHebrewDate ARGS((int julstart, int hm, int hd, int yahr, int adarbehave, int *ans));
  1296.   int ComputeJahr ARGS ((int y, int m, int d, int *ans));
  1297.   int GetSysVar ARGS ((const char *name, Value *val));
  1298. ! int SetSysVar ARGS ((const char *name, int value));
  1299.   void DumpSysVarByName ARGS ((const char *name));
  1300.   int CalcMinsFromUTC ARGS ((int jul, int tim, int *mins, int *isdst));
  1301.   void FillParagraph ARGS ((char *s));
  1302. --- 128,138 ----
  1303.   int GetNextHebrewDate ARGS((int julstart, int hm, int hd, int yahr, int adarbehave, int *ans));
  1304.   int ComputeJahr ARGS ((int y, int m, int d, int *ans));
  1305.   int GetSysVar ARGS ((const char *name, Value *val));
  1306. ! int SetSysVar ARGS ((const char *name, Value *val));
  1307.   void DumpSysVarByName ARGS ((const char *name));
  1308.   int CalcMinsFromUTC ARGS ((int jul, int tim, int *mins, int *isdst));
  1309.   void FillParagraph ARGS ((char *s));
  1310. + void LocalToUTC ARGS ((int locdate, int loctime, int *utcdate, int *utctime));
  1311. + void UTCToLocal ARGS ((int utcdate, int utctime, int *locdate, int *loctime));
  1312. + int MoonPhase ARGS ((int date, int time));
  1313. + void HuntPhase ARGS ((int startdate, int starttim, int phas, int *date, int *time));
  1314. *** ../prev/rem2ps.1    Wed Jul 28 10:22:25 1993
  1315. --- ./rem2ps.1    Thu Sep 30 15:23:25 1993
  1316. ***************
  1317. *** 1,4 ****
  1318. ! .TH REM2PS 1 "8 January 1993"
  1319.   .UC4
  1320.   .SH NAME
  1321.   rem2ps \- draw a PostScript calendar from Remind output
  1322. --- 1,4 ----
  1323. ! .TH REM2PS 1 "30 September 1993"
  1324.   .UC4
  1325.   .SH NAME
  1326.   rem2ps \- draw a PostScript calendar from Remind output
  1327. ***************
  1328. *** 10,15 ****
  1329. --- 10,18 ----
  1330.   draws a calendar) to the standard output.
  1331.   .SH OPTIONS
  1332.   .TP
  1333. + .B \-n
  1334. + Produce a calendar whose first column is Monday (rather than Sunday.)
  1335. + .TP
  1336.   .B \-p file
  1337.   Include the contents of \fIfile\fR in the PostScript prologue.  This
  1338.   allows you to define procedures, variables etc. which can be used
  1339. ***************
  1340. *** 20,30 ****
  1341.   Produce the calendar in landscape mode rather than the default
  1342.   portrait mode.
  1343.   .TP
  1344. ! .B \-c
  1345. ! Do not generate small calendars for the next and previous months.  By
  1346. ! default, these small calendars are generated and placed on the main
  1347. ! calendar.
  1348.   .TP
  1349.   .B \-i
  1350.   Use ISO 8859-1 standard encoding for the PostScript fonts.  If you do
  1351.   not use this option, the default encoding is used.
  1352. --- 23,53 ----
  1353.   Produce the calendar in landscape mode rather than the default
  1354.   portrait mode.
  1355.   .TP
  1356. ! \fB\-c\fR[\fIn\fR]
  1357. ! If \fIn\fR is omitted, disables the small calendars for next and previous
  1358. ! months which are normally generated.  If \fIn\fR is supplied, it can range
  1359. ! from 0 to 3, with the following meanings:
  1360. ! .RS
  1361.   .TP
  1362. + .B 0
  1363. + Disable small calendars
  1364. + .TP
  1365. + .B 1
  1366. + Place the small calendars at the bottom-right if there is room; otherwise,
  1367. + place them at the top-left.
  1368. + .TP
  1369. + .B 2
  1370. + Place the small calendars at the top-left if there is room; otherwise,
  1371. + place them at the bottom-right.
  1372. + .TP
  1373. + .B 3
  1374. + Place the previous month's small calendar at the top-left and the next
  1375. + month's at the bottom-right if there is room; otherwise, follow \fIn\fR=1.
  1376. + A moment's thought reveals that an option which splits the calendars if
  1377. + there is room and otherwise follows \fIn\fR=2 yields the same results as
  1378. + \fIn\fR=3.
  1379. + .RE
  1380. + .TP
  1381.   .B \-i
  1382.   Use ISO 8859-1 standard encoding for the PostScript fonts.  If you do
  1383.   not use this option, the default encoding is used.
  1384. ***************
  1385. *** 90,97 ****
  1386.   option will display the compiled-in default.
  1387.   .RE
  1388.   .TP
  1389. ! \fB\-f\fR[\fBshed\fR] \fIfont\fR
  1390. ! Set the font for the small calendar, the calendar headings, the calendar
  1391.   entries, and the day numbers, respectively.  \fIFont\fR must be the
  1392.   name of a valid PostScript font.  The default fonts are equivalent to
  1393.   specifying:
  1394. --- 113,121 ----
  1395.   option will display the compiled-in default.
  1396.   .RE
  1397.   .TP
  1398. ! \fB\-f\fR[\fBtshed\fR] \fIfont\fR
  1399. ! Set the font for the calendar title,
  1400. ! the small calendars, the day-of-week headings, the calendar
  1401.   entries, and the day numbers, respectively.  \fIFont\fR must be the
  1402.   name of a valid PostScript font.  The default fonts are equivalent to
  1403.   specifying:
  1404. ***************
  1405. *** 98,104 ****
  1406.   .RS
  1407.   .PP
  1408.   .nf
  1409. !     -fhes Helvetica -fd Helvetica-BoldOblique
  1410.   .fi
  1411.   .PP
  1412.   In other words, the heading, entry and small-calendar fonts are set
  1413. --- 122,128 ----
  1414.   .RS
  1415.   .PP
  1416.   .nf
  1417. !     -ftshe Helvetica -fd Helvetica-BoldOblique
  1418.   .fi
  1419.   .PP
  1420.   In other words, the heading, entry and small-calendar fonts are set
  1421. ***************
  1422. *** 106,120 ****
  1423.   Helvetica-BoldOblique.
  1424.   .RE
  1425.   .TP
  1426. ! \fB\-s\fR[\fBhed\fR] \fIsize\fR
  1427. ! Set the size (in points) of the text for the the calendar headings,
  1428. ! the calendar entries, and the day numbers, respectively.  \fISize\fR
  1429. ! must be a decimal number.  The default sizes are equivalent to
  1430. ! specifying:
  1431.   .RS
  1432.   .PP
  1433.   .nf
  1434. !     -sdh 14 -se 8
  1435.   .fi
  1436.   .PP
  1437.   In other words, the heading and day numbers are 14-point fonts, and the
  1438. --- 130,144 ----
  1439.   Helvetica-BoldOblique.
  1440.   .RE
  1441.   .TP
  1442. ! \fB\-s\fR[\fBthed\fR] \fIsize\fR
  1443. ! Set the size (in points) of the text for the the calendar title,
  1444. ! day-of-week headings, the calendar entries, and the day numbers,
  1445. ! respectively.  \fISize\fR must be a decimal number.  The default sizes
  1446. ! are equivalent to specifying:
  1447.   .RS
  1448.   .PP
  1449.   .nf
  1450. !     -sthd 14 -se 8
  1451.   .fi
  1452.   .PP
  1453.   In other words, the heading and day numbers are 14-point fonts, and the
  1454. ***************
  1455. *** 185,195 ****
  1456.   of the regular calendar entry area.  The space from here to the top
  1457.   of the box is used only to draw the day number.
  1458.   .TP
  1459. ! /DayFont, /EntryFont, /SmallFont and /HeadFont
  1460. ! The fonts used to draw the day numbers, the calendar entries, the small
  1461. ! calendars, and the month and day headings, respectively.
  1462.   .TP
  1463. ! DaySize, EntrySize and HeadSize
  1464.   The sizes of the above fonts.  (The size of the small calendar font
  1465.   is \fInot\fR defined here.)  For example, if you wanted to print
  1466.   the Hebrew date next to the regular day number in the calendar, use:
  1467. --- 209,220 ----
  1468.   of the regular calendar entry area.  The space from here to the top
  1469.   of the box is used only to draw the day number.
  1470.   .TP
  1471. ! /DayFont, /TitleFont, /EntryFont, /SmallFont and /HeadFont
  1472. ! The fonts used to draw the day numbers, the month and year title,
  1473. ! the calendar entries, the small
  1474. ! calendars, and the day-of-week headings, respectively.
  1475.   .TP
  1476. ! DaySize, TitleSize, EntrySize and HeadSize
  1477.   The sizes of the above fonts.  (The size of the small calendar font
  1478.   is \fInot\fR defined here.)  For example, if you wanted to print
  1479.   the Hebrew date next to the regular day number in the calendar, use:
  1480. *** ../prev/rem2ps.c    Wed Jul 28 10:15:11 1993
  1481. --- ./rem2ps.c    Tue Sep 28 12:33:59 1993
  1482. ***************
  1483. *** 43,48 ****
  1484. --- 43,59 ----
  1485.   
  1486.   char Days[]=L_DAYINIT;
  1487.   
  1488. + char *SmallCalLoc[] = {
  1489. +    "",
  1490. +    "bt",
  1491. +    "tb",
  1492. +    "sbt",
  1493. + };
  1494. + #define NUMSMALL (sizeof(SmallCalLoc)/sizeof(SmallCalLoc[0]))
  1495. + char *SmallLocation;
  1496. + int SmallCol1, SmallCol2;
  1497.   PageType Pages[] =
  1498.   {
  1499.      {"Letter", 612, 792},     /* 8.5 x 11 in. */
  1500. ***************
  1501. *** 78,83 ****
  1502. --- 89,95 ----
  1503.   char LineBuffer[LINELEN];
  1504.   
  1505.   char *HeadFont="Helvetica";
  1506. + char *TitleFont="Helvetica";
  1507.   char *DayFont="Helvetica-BoldOblique";
  1508.   char *EntryFont="Helvetica";
  1509.   char *SmallFont="Helvetica";
  1510. ***************
  1511. *** 84,89 ****
  1512. --- 96,102 ----
  1513.   char *LineWidth = "1";
  1514.   
  1515.   char *HeadSize="14";
  1516. + char *TitleSize="14";
  1517.   char *DaySize="14";
  1518.   char *EntrySize="8";
  1519.   char *BorderSize = "6";
  1520. ***************
  1521. *** 96,102 ****
  1522.   int MaxDay;
  1523.   int DayNum;
  1524.   int WkDayNum;
  1525.   int LeftMarg, RightMarg, TopMarg, BotMarg;
  1526.   int FillPage;
  1527.   
  1528. --- 109,116 ----
  1529.   int MaxDay;
  1530.   int DayNum;
  1531.   int WkDayNum;
  1532. ! int FirstWkDay;
  1533. ! int MondayFirst;
  1534.   int LeftMarg, RightMarg, TopMarg, BotMarg;
  1535.   int FillPage;
  1536.   
  1537. ***************
  1538. *** 104,113 ****
  1539.   void Usage ARGS ((char *s));
  1540.   void DoPsCal ARGS ((void));
  1541.   int DoQueuedPs ARGS ((void));
  1542. ! void DoSmallCal ARGS((char *m, int days, int first, int col));
  1543.   void WriteProlog ARGS ((void));
  1544.   void WriteCalEntry ARGS ((void));
  1545.   void WriteOneEntry ARGS ((char *s));
  1546.   
  1547.   /***************************************************************/
  1548.   /*                                                             */
  1549. --- 118,128 ----
  1550.   void Usage ARGS ((char *s));
  1551.   void DoPsCal ARGS ((void));
  1552.   int DoQueuedPs ARGS ((void));
  1553. ! void DoSmallCal ARGS((char *m, int days, int first, int col, int which));
  1554.   void WriteProlog ARGS ((void));
  1555.   void WriteCalEntry ARGS ((void));
  1556.   void WriteOneEntry ARGS ((char *s));
  1557. + void GetSmallLocations ARGS ((void));
  1558.   
  1559.   /***************************************************************/
  1560.   /*                                                             */
  1561. ***************
  1562. *** 165,177 ****
  1563.      int days, wkday, prevdays, nextdays;
  1564.      int sfirst;
  1565.      int i;
  1566. -    int smallcol = 0; /* Stop GCC from complaining about uninit var */
  1567.      int is_ps;
  1568.      CalEntry *c, *d;
  1569.   
  1570.      printf("%%%%Page: %d %d\n", validfile, validfile);
  1571.   /* Read the month and year name, followed by # days in month and 1st day of
  1572. !    month */
  1573.      gets(LineBuffer);
  1574.      sscanf(LineBuffer, "%s %s %d %d", month, year, &days, &wkday);
  1575.      gets(LineBuffer);
  1576. --- 180,191 ----
  1577.      int days, wkday, prevdays, nextdays;
  1578.      int sfirst;
  1579.      int i;
  1580.      int is_ps;
  1581.      CalEntry *c, *d;
  1582.   
  1583.      printf("%%%%Page: %d %d\n", validfile, validfile);
  1584.   /* Read the month and year name, followed by # days in month and 1st day of
  1585. !    month, followed by the MondayFirst flag */
  1586.      gets(LineBuffer);
  1587.      sscanf(LineBuffer, "%s %s %d %d", month, year, &days, &wkday);
  1588.      gets(LineBuffer);
  1589. ***************
  1590. *** 179,184 ****
  1591. --- 193,199 ----
  1592.      gets(LineBuffer);
  1593.      sscanf(LineBuffer, "%s %d", nextm, &nextdays);
  1594.      MaxDay = days;
  1595. +    FirstWkDay = wkday;
  1596.   
  1597.   /* Emit PostScript to do the heading */
  1598.      if (!PortraitMode) printf("XSIZE 0 translate 90 rotate\n");
  1599. ***************
  1600. *** 197,207 ****
  1601.            printf("/MinBoxSize ytop MinY sub 5 div def\n");
  1602.      }
  1603.   
  1604. ! /* If wkday >= 2, then do the small calendars at the top. */
  1605. !    if (wkday >=2 && !NoSmallCal) {
  1606. !       smallcol = 0;
  1607. !       printf("/ysmall ytop def\n");
  1608. !    }
  1609.   
  1610.   /* Do each entry */
  1611.   
  1612. --- 212,218 ----
  1613.            printf("/MinBoxSize ytop MinY sub 5 div def\n");
  1614.      }
  1615.   
  1616. !    printf("/ysmalltop ytop def\n");
  1617.   
  1618.   /* Do each entry */
  1619.   
  1620. ***************
  1621. *** 262,278 ****
  1622.      }
  1623.   
  1624.   /* If wkday < 2, set ysmall.  If necessary (only for feb) increase cal size. */
  1625. !    if (wkday < 2 && !NoSmallCal) {
  1626. !       smallcol = 5;
  1627. !       printf("/ysmall ylast def\n");
  1628. !       if (days == 28 && wkday == 0) {
  1629. !          printf("/ysmall ymin def /ymin ysmall MinBoxSize sub def\n");
  1630. !      printf("MinX ymin MaxX ymin L\n");
  1631. !       }
  1632. !    }
  1633. !        
  1634.   
  1635.   /* Now draw the vertical lines */
  1636.      for (i=0; i<=7; i++) {
  1637.         printf("%d xincr mul MinX add ymin %d xincr mul MinX add topy L\n",
  1638.                 i, i);
  1639. --- 273,282 ----
  1640.      }
  1641.   
  1642.   /* If wkday < 2, set ysmall.  If necessary (only for feb) increase cal size. */
  1643. !    printf("/ysmallbot ylast def\n");
  1644.   
  1645.   /* Now draw the vertical lines */
  1646. +    GetSmallLocations();
  1647.      for (i=0; i<=7; i++) {
  1648.         printf("%d xincr mul MinX add ymin %d xincr mul MinX add topy L\n",
  1649.                 i, i);
  1650. ***************
  1651. *** 282,291 ****
  1652.      if (!NoSmallCal) {
  1653.         sfirst = wkday - (prevdays % 7);
  1654.         if (sfirst < 0) sfirst += 7;
  1655. !       DoSmallCal(prevm, prevdays, sfirst, smallcol);
  1656.         sfirst = wkday + (days % 7);
  1657.         if (sfirst >6) sfirst -= 7;
  1658. !       DoSmallCal(nextm, nextdays, sfirst, smallcol+1);
  1659.      }
  1660.   /* Do it! */
  1661.      printf("showpage\n");
  1662. --- 286,295 ----
  1663.      if (!NoSmallCal) {
  1664.         sfirst = wkday - (prevdays % 7);
  1665.         if (sfirst < 0) sfirst += 7;
  1666. !       DoSmallCal(prevm, prevdays, sfirst, SmallCol1, 1);
  1667.         sfirst = wkday + (days % 7);
  1668.         if (sfirst >6) sfirst -= 7;
  1669. !       DoSmallCal(nextm, nextdays, sfirst, SmallCol2, 2);
  1670.      }
  1671.   /* Do it! */
  1672.      printf("showpage\n");
  1673. ***************
  1674. *** 322,332 ****
  1675.   /* Write the document structuring stuff */
  1676.      printf("%%!PS-Adobe-\n");
  1677.      printf("%%%%DocumentFonts: %s", HeadFont);
  1678. !    if (strcmp(HeadFont, DayFont)) printf(" %s", DayFont);
  1679.      if (strcmp(EntryFont, HeadFont) &&
  1680.          strcmp(EntryFont, DayFont)) printf(" %s", EntryFont);
  1681.      if (!NoSmallCal && strcmp(SmallFont, HeadFont) &&
  1682.