]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/local/lbl/diffs
%G isn't actually part of POSIX, so change to %Y.
[nmh] / docs / historical / mh-6.8.5 / local / lbl / diffs
1 diff -r -w lbl/sbr/formatsbr.c ./sbr/formatsbr.c
2 1a2,4
3 > #ifndef lint
4 > static char ident[] = "@(#)$Id: formatsbr.c,v 1.16 1992/02/09 07:11:55 jromine Exp $";
5 > #endif lint
6 12a16,18
7 > /* \f */
8 >
9 >
10 17a24
11 > #ifdef LBL
12 18a26
13 > #endif
14 20c28,30
15 < int fmt_norm = AD_NAME;
16 ---
17 > static normalize();
18 >
19 > extern int fmt_norm; /* defined in sbr/formatdef.c = AD_NAME */
20 24,28c34
21 < static
22 < normalize(cp)
23 < register char *cp;
24 < {
25 < register char *dp;
26 ---
27 > long time ();
28 30,34c36
29 < for (dp = cp; *cp; cp++)
30 < if (*cp != QUOTE)
31 < *dp++ = *cp;
32 < else
33 < switch (*++cp) {
34 ---
35 > /* \f */
36 36,50c38
37 < case 'b':
38 < *dp++ = '\b';
39 < break;
40 < case 'f':
41 < *dp++ = '\f';
42 < break;
43 < case 'n':
44 < *dp++ = '\n';
45 < break;
46 < case 'r':
47 < *dp++ = '\r';
48 < break;
49 < case 't':
50 < *dp++ = '\t';
51 < break;
52 ---
53 > /* MAJOR HACK: See MHCHANGES for discussion */
54 52,68c40,43
55 < case '\n':
56 < break;
57 <
58 < case NULL:
59 < cp--;
60 < /* fall through */
61 < default:
62 < *dp++ = *cp;
63 < break;
64 < }
65 <
66 < *dp = NULL;
67 < }
68 <
69 < char *
70 < new_fs(form, format, def)
71 < register char *form, *format, *def;
72 ---
73 > char *new_fs (form, format, def)
74 > register char *form,
75 > *format,
76 > *def;
77 89a65
78 >
79 91c67,68
80 < } else {
81 ---
82 > }
83 > else {
84 99a77,109
85 > /* \f */
86 >
87 > static normalize (cp)
88 > register char *cp;
89 > {
90 > register char *dp;
91 >
92 > for (dp = cp; *cp; cp++)
93 > if (*cp != QUOTE)
94 > *dp++ = *cp;
95 > else
96 > switch (*++cp) {
97 > #define grot(y,z) case y: *dp++ = z; break;
98 > grot ('b', '\b');
99 > grot ('f', '\f');
100 > grot ('n', '\n');
101 > grot ('r', '\r');
102 > grot ('t', '\t');
103 >
104 > case '\n':
105 > break;
106 >
107 > case 0:
108 > cp--; /* fall */
109 > default:
110 > *dp++ = *cp;
111 > break;
112 > }
113 >
114 > *dp = 0;
115 > }
116 >
117 > /* \f */
118 104,106c114,117
119 < static int
120 < match(str, sub)
121 < register char *str, *sub;
122 ---
123 >
124 > static int match (str, sub)
125 > register char *str,
126 > *sub;
127 118,119c129
128 < s1 = sub + 1;
129 < s2 = str;
130 ---
131 > s1 = sub + 1; s2 = str;
132 126a137
133 > /* \f */
134 130,135c141,143
135 < #define PUTDF(cp, num, wid, fill) {\
136 < if (cp + wid < ep) {\
137 < if ((i = (num)) < 0)\
138 < i = -(num);\
139 < if ((c = (wid)) < 0)\
140 < c = -c;\
141 ---
142 > #define PUTDF(cp, num, wid, fill) if (cp + wid < ep){\
143 > if((i = (num))<0) i = -(num);\
144 > if((c = (wid))<0) c = -c;\
145 148,152c156,158
146 < }}
147 < #define PUTD(cp, num) {\
148 < if (cp < ep) {\
149 < if ((i = (num)) == 0)\
150 < *cp++ = '0';\
151 ---
152 > }
153 > #define PUTD(cp, num) if (cp < ep){\
154 > if((i = (num))==0) *cp++ = '0';\
155 165c171
156 < }}
157 ---
158 > }
159 167,168c173
160 < char *cp2 = cp;\
161 < rjust = 0;\
162 ---
163 > ljust = 0;\
164 171c176
165 < rjust++;\
166 ---
167 > ljust++;\
168 174c179
169 < if (rjust) {\
170 ---
171 > if (ljust) {\
172 190,193c195
173 < else if (c == '\010') {\
174 < if (cp > cp2)\
175 < --cp;\
176 < } else {\
177 ---
178 > else {\
179 199c201
180 < if (!rjust)\
181 ---
182 > if (!ljust)\
183 203d204
184 <
185 205d205
186 < char *cp2 = cp;\
187 212,215c212
188 < else if (c == '\010') {\
189 < if (cp > cp2)\
190 < --cp;\
191 < } else {\
192 ---
193 > else {\
194 220c217,218
195 < }}
196 ---
197 > }\
198 > }
199 222,225d219
200 < static char *lmonth[] = {
201 < "January", "February", "March", "April", "May", "June",
202 < "July", "August", "September", "October", "November", "December"
203 < };
204 226a221,223
205 > static char *lmonth[] = { "January", "February","March", "April",
206 > "May", "June", "July", "August",
207 > "September","October", "November","December" };
208 227a225,226
209 >
210 > struct format *
211 245,246c244
212 < register int j;
213 < int rjust;
214 ---
215 > int ljust;
216 251c249
217 < for (;;) {
218 ---
219 > while (cp < ep) {
220 258,259c256
221 < PUTSF(cp, fmt->f_comp->c_text, fmt->f_width,
222 < fmt->f_fill);
223 ---
224 > PUTSF (cp, fmt->f_comp->c_text, fmt->f_width, fmt->f_fill);
225 262,269d258
226 < case FT_LIT_FORCE:
227 < sp = fmt->f_text;
228 < i = strlen(sp);
229 < ep += i; /* forced lits are `invisible' */
230 <
231 < while (c = *sp++)
232 < *cp++ = c;
233 < break;
234 277,280c266,268
235 <
236 < /* By default we left justify */
237 < rjust = 0;
238 < if ((i = fmt->f_width) < 0) {
239 ---
240 > ljust = 0;
241 > i = fmt->f_width;
242 > if (i < 0) {
243 282c270
244 < rjust++;
245 ---
246 > ljust++; /* XXX should do something with this */
247 284,294d271
248 <
249 < if (rjust) {
250 < j = strlen(sp);
251 < if (j > i)
252 < sp += j - i;
253 < else while (j < i && cp < ep) {
254 < *cp++ = fmt->f_fill;
255 < ++j;
256 < }
257 < }
258 <
259 297d273
260 <
261 320a297
262 >
263 325c302
264 < if (str == NULLCP || *str == NULL) {
265 ---
266 > if (!(value = (str && *str))) {
267 332c309
268 < if (str != NULLCP && *str != NULL) {
269 ---
270 > if (!(value = (str == NULLCP || *str == 0))) {
271 360c337
272 < if (!str || !match(str, fmt->f_text)) {
273 ---
274 > if (!(value = (str && match (str, fmt->f_text)))) {
275 374c351
276 < if (!str || !uprf(str, fmt->f_text)) {
277 ---
278 > if (!(value = (str && uprf (str, fmt->f_text)))) {
279 381d357
280 < if (str)
281 383,384d358
282 < else
283 < value = 0;
284 388c362
285 < value = (str != NULLCP && *str != NULL);
286 ---
287 > value = (str != NULLCP && *str != 0);
288 392c366
289 < value = (str == NULLCP || *str == NULL);
290 ---
291 > value = (str == NULLCP || *str == 0);
292 419a394,397
293 > case FT_LS_GETENV:
294 > if (!(str = getenv (fmt->f_text)))
295 > str = "";
296 > break;
297 424,425c402
298 < /* Be careful since str can point into buffer */
299 < bcopy(str, buffer, strlen(str) + 1);
300 ---
301 > (void) strcpy(buffer, str);
302 427,428d403
303 <
304 < /* Eat leading whitespace */
305 431,438c406
306 <
307 < /* Trim trailing whitespace */
308 < xp = str + strlen(str) - 1;
309 < while (xp > str && isspace(*xp))
310 < *xp-- = '\0';
311 <
312 < /* By default we left justify */
313 < rjust = 0;
314 ---
315 > ljust = 0;
316 441c409
317 < rjust++;
318 ---
319 > ljust++;
320 444,446c412
321 < /* If necessary, limit width and/or justify */
322 < if (i > 0 && (j = strlen(str)) > i) {
323 < if (!rjust)
324 ---
325 > if (!ljust && i > 0 && strlen(str) > i)
326 448,449c414,419
327 < else
328 < str += j - i;
329 ---
330 > xp = str;
331 > xp += strlen(str) - 1;
332 > while (xp > str && isspace(*xp))
333 > *xp-- = '\0';
334 > if (ljust && i > 0 && strlen(str) > i)
335 > str += strlen(str) - i;
336 451d420
337 < }
338 458,459c427
339 < value = (comp = fmt->f_comp)->c_text ?
340 < atoi(comp->c_text) : 0;
341 ---
342 > value = (comp = fmt->f_comp)->c_text ? atoi(comp->c_text) : 0;
343 484a453,458
344 > case FT_LV_MODULO_L:
345 > if (fmt->f_value)
346 > value = value % fmt->f_value;
347 > else
348 > value = 0;
349 > break;
350 517,518c491
351 < if (!(((tws = fmt->f_comp->c_tws)->tw_flags) &
352 < (TW_SEXP | TW_SIMP)))
353 ---
354 > if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
355 523,524c496
356 < if (!(((tws = fmt->f_comp->c_tws)->tw_flags) &
357 < (TW_SEXP | TW_SIMP)))
358 ---
359 > if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
360 529,530c501
361 < if (!(((tws = fmt->f_comp->c_tws)->tw_flags) &
362 < (TW_SEXP | TW_SIMP)))
363 ---
364 > if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
365 550,551c521
366 < if (!(((tws = fmt->f_comp->c_tws)->tw_flags) &
367 < (TW_SEXP | TW_SIMP)))
368 ---
369 > if (!(((tws = fmt->f_comp->c_tws)->tw_flags) & (TW_SEXP|TW_SIMP)))
370 555,556c525
371 < value = 1;
372 < break;
373 ---
374 > value = 1; break;
375 558,559c527
376 < value = 0;
377 < break;
378 ---
379 > value = 0; break;
380 561,562c529
381 < value = -1;
382 < break;
383 ---
384 > value = -1; break;
385 565,566c532
386 < if ((fmt->f_comp->c_tws->tw_flags & TW_SZONE) ==
387 < TW_SZEXP)
388 ---
389 > if ((fmt->f_comp->c_tws->tw_flags & TW_SZONE) == TW_SZEXP)
390 610a577
391 > case FT_LS_ADDR:
392 614,615c581,587
393 < #else
394 < mn = fmt->f_comp->c_mn;
395 ---
396 > #else not BERK
397 > if ((mn = fmt -> f_comp -> c_mn) == &fmt_mnull) {
398 > str = fmt -> f_comp -> c_text;
399 > break;
400 > }
401 > if (fmt -> f_type == FT_LS_ADDR)
402 > goto unfriendly;
403 616a589,604
404 > if ((str = mn -> m_note)) {
405 > (void) strcpy (buffer, str);
406 > str = buffer;
407 > if (*str == '(')
408 > str++;
409 > sp = str + strlen(str) - 1;
410 > if (*sp == ')') {
411 > *sp-- = '\0';
412 > while (sp >= str)
413 > if (*sp == ' ')
414 > *sp-- = '\0';
415 > else
416 > break;
417 > }
418 > } else {
419 > unfriendly: ;
420 618d605
421 <
422 632c619,620
423 < } else
424 ---
425 > }
426 > else
427 635a624
428 > }
429 661,662c650
430 < bzero((char *)comp->c_tws,
431 < sizeof(*comp->c_tws));
432 ---
433 > bzero ((char *) comp -> c_tws, sizeof *comp -> c_tws);
434 668c656
435 < /* custom address list formatting hook */
436 ---
437 > /* hook for custom address list formatting (see replsbr.c) */
438 673,678c661,665
439 < /*
440 < * Output the str register as an address component,
441 < * splitting it into multiple lines if necessary.
442 < * The value reg. contains the max line length. The
443 < * lit. field may contain a string to prepend to the
444 < * result (e.g., "To: ")
445 ---
446 > /* output the str register as an address component,
447 > * splitting it into multiple lines if necessary. The
448 > * value reg. contains the max line length. The lit.
449 > * field may contain a string to prepend to the result
450 > * (e.g., "To: ")
451 693,696c680,681
452 < /*
453 < * Try to break at a comma; failing
454 < * that, break at a space, failing
455 < * that, just split the line.
456 ---
457 > /* try to break at a comma; failing that, break at a
458 > * space, failing that, just split the line.
459 698,699c683
460 < lastb = 0;
461 < sp = lp + wid;
462 ---
463 > lastb = 0; sp = lp + wid;
464 729c713,715
465 < } else
466 ---
467 > } else {
468 > while (getname("")) /* XXX */
469 > ;
470 730a717
471 > }
472 735,737c722,724
473 < * If there's no component, we say true. Otherwise
474 < * we say "true" only if we can parse the address and
475 < * it matches one of our addresses.
476 ---
477 > * if there's no component, we say true. Otherwise we
478 > * say "true" only if we can parse the address and it
479 > * matches one of our addresses.
480 748,749c735
481 < (mn = getm(sp, NULLCP, 0,
482 < AD_NAME, NULLCP)))
483 ---
484 > (mn = getm (sp, NULLCP, 0, AD_NAME, NULLCP)))
485 751a738,739
486 > while (getname("")) /* XXX */
487 > ;
488 758,762c746,749
489 < /*
490 < * If we're working on a folder (as opposed to a
491 < * file), add the current msg to sequence given in
492 < * literal field. Don't disturb string or value
493 < * registers.
494 ---
495 > #ifdef LBL
496 > /* If we're working on a folder (as opposed to a file), add the
497 > * current msg to sequence given in literal field. Don't
498 > * disturb string or value registers.
499 765,766c752,753
500 < (void) m_seqadd(fmt_current_folder,
501 < fmt->f_text, dat[0], -1);
502 ---
503 > (void)m_seqadd(fmt_current_folder, fmt->f_text, dat[0], -1);
504 > #endif
505 771c758,759
506 < finished:
507 ---
508 > #ifndef JLR
509 > finished:;
510 774,775c762,774
511 < *cp = NULL;
512 < return (value);
513 ---
514 > *cp = 0;
515 > return ((struct format *)0);
516 > #else /* JLR */
517 > if (cp[-1] != '\n')
518 > *cp++ = '\n';
519 > while (fmt->f_type != FT_DONE)
520 > fmt++;
521 >
522 > finished:;
523 > *cp = '\0';
524 > return (fmt -> f_value ? ++fmt : (struct format *)0);
525 >
526 > #endif /* JLR */
527 diff -r -w lbl/sbr/m_gmsg.c ./sbr/m_gmsg.c
528 1a2,4
529 > #ifndef lint
530 > static char ident[] = "@(#)$Id: m_gmsg.c,v 2.8 1992/02/11 21:32:04 jromine Exp $";
531 > #endif lint
532 3a7
533 > #include "../h/local.h"
534 5,16d8
535 < #include <sys/types.h>
536 < #include <sys/stat.h>
537 < #include <ctype.h>
538 < #ifndef BSD42
539 < #ifndef SYS5
540 < #include <ndir.h>
541 < #else SYS5
542 < #include <dir.h>
543 < #endif SYS5
544 < #else BSD42
545 < #include <sys/dir.h>
546 < #endif BSD42
547 25,27c17
548 < static int m_getatr(), m_setatr();
549 <
550 < static int len;
551 ---
552 > static int len=0;
553 29a20,21
554 > static m_getatr();
555 > static int m_setatr();
556 32,33c24
557 < struct msgs *
558 < m_gmsg(name)
559 ---
560 > struct msgs *m_gmsg (name)
561 48a40,43
562 > #ifdef SYS5DIR
563 > register struct dirent *dp;
564 > DIR * dd;
565 > #else SYS5DIR
566 50a46
567 > #endif SYS5DIR
568 59c55
569 < mp = (struct msgs *) malloc (MSIZE (mp, 0, 0));
570 ---
571 > mp = (struct msgs *) malloc (MHSIZE (mp, 0, 0));
572 183c179
573 < realloc ((char *) mp, MSIZE (mp, mp->lowoff, mp->hghoff));
574 ---
575 > realloc ((char *) mp, MHSIZE (mp, mp -> lowoff, mp -> hghoff));
576 191c187
577 < calloc ((unsigned) 1, MSIZEX (mp, mp->lowmsg, mp->hghmsg));
578 ---
579 > calloc ((unsigned) 1, MHSIZEX (mp, mp -> lowmsg, mp -> hghmsg));
580 195c191
581 < if (mp->msgstats < 0)
582 ---
583 > if (mp -> msgstats < (int *)0) /* non portable */
584 207,208c203
585 < static int
586 < m_getatr(mp)
587 ---
588 > static m_getatr (mp)
589 219c214
590 < field[BUFSIZ];
591 ---
592 > field[BUFSIZ * 2];
593 225,226c220,221
594 < mp->msgattrs[0] = getcpy (current);
595 < mp->msgattrs[1] = NULL;
596 ---
597 > mp -> msgattrs[i = 0] = getcpy (current);
598 > mp -> msgattrs[++i] = NULL;
599 237,248d231
600 < case FLDPLUS:
601 < /*
602 < * sequence was too big for buffer: back up
603 < * to a word break.
604 < */
605 < for (cp = &field[sizeof(field)-2]; !isspace(*cp); --cp)
606 < ;
607 < if (i = cp - &field[sizeof(field)-2]) {
608 < *cp = 0;
609 < fseek(fp, i, 1);
610 < }
611 < /*FALL THROUGH*/
612 250,252d232
613 < (void) m_setatr (mp, name, field);
614 < continue;
615 <
616 254c234,235
617 < (void) m_setatr (mp, name, field);
618 ---
619 > (void) m_setatr (mp, getcpy (name), trimcpy (field));
620 > if (state == FLDEOF)
621 255a237
622 > continue;
623 286c268
624 < if ((i = m_setatr (mp, cp, np->n_field)) != NOTOK)
625 ---
626 > if ((i = m_setatr (mp, cp, getcpy (np -> n_field))) != NOTOK)
627 288d269
628 < free(cp);
629 294,295c275
630 < static int
631 < m_setatr(mp, name, field)
632 ---
633 > static int m_setatr (mp, name, field)
634 297c277,278
635 < register char *name, *field;
636 ---
637 > register char *name,
638 > *field;
639 299,300c280,286
640 < register int bits, slot, first, last;
641 < register char *cp;
642 ---
643 > int bits,
644 > hack;
645 > register int i,
646 > j,
647 > k;
648 > register char *cp,
649 > **ap;
650 302,305c288,290
651 < if (strcmp (current, name) == 0) {
652 < mp->curmsg = atoi(field);
653 < return (0);
654 < }
655 ---
656 > bits = FFATTRSLOT;
657 > hack = strcmp (current, name) == 0;/* hack... */
658 > /* if we're going to use UNSEEN, it should be set here! */
659 307,308c292,295
660 < for (slot = 0; mp->msgattrs[slot]; slot++)
661 < if (strcmp(mp->msgattrs[slot], name) == 0)
662 ---
663 > for (i = 0; mp -> msgattrs[i]; i++)
664 > if (strcmp (mp -> msgattrs[i], name) == 0) {
665 > for (j = mp -> lowmsg; j <= mp -> hghmsg; j++)
666 > mp -> msgstats[j] &= ~(1 << (bits + i));
667 310,311c297,300
668 <
669 < if (slot >= NATTRS)
670 ---
671 > }
672 > if (i >= NATTRS) {
673 > free (name);
674 > free (field);
675 312a302
676 > }
677 314,316c304,306
678 < if (mp->msgattrs[slot] == NULL) {
679 < mp->msgattrs[slot] = getcpy(name);
680 < mp->msgattrs[slot + 1] = NULL;
681 ---
682 > if (mp -> msgattrs[i] == NULL) {
683 > mp -> msgattrs[i] = name;
684 > mp -> msgattrs[i + 1] = NULL;
685 317a308,309
686 > else
687 > free (name);
688 319,338c311,328
689 < bits = 1 << (FFATTRSLOT + slot);
690 <
691 < for (cp = field; *cp; ) {
692 < while (isspace(*cp))
693 < ++cp;
694 < if (! isdigit(*cp))
695 < return (NOTOK);
696 < for (first = 0; isdigit(*cp); ++cp)
697 < first = (first * 10) + (*cp - '0');
698 < if (first == 0)
699 < return (NOTOK);
700 < if (*cp++ == '-') {
701 < /* have a range of msgs */
702 < for (last = 0; isdigit(*cp); ++cp)
703 < last = (last * 10) + (*cp - '0');
704 < if (last < first) {
705 < advise(NULLCP,
706 < "seq %s msg range bad: first (%d) > last (%d)",
707 < name, first, last);
708 < continue;
709 ---
710 > for (ap = brkstring (field, " ", "\n");
711 > *ap;
712 > ap++) {
713 > if (cp = index (*ap, '-'))
714 > *cp++ = NULL;
715 > if ((j = m_atoi (*ap)) > 0) {
716 > #ifdef notdef
717 > if (hack && j >= mp -> lowmsg && j <= mp -> hghmsg
718 > && (mp -> msgstats[j] & EXISTS))
719 > mp -> curmsg = j;
720 > #else not notdef
721 > if (hack)
722 > mp -> curmsg = j;
723 > #endif not notdef
724 > for (k = cp ? m_atoi (cp) : j; j <= k; j++)
725 > if (j >= mp -> lowmsg && j <= mp -> hghmsg
726 > && (mp -> msgstats[j] & EXISTS))
727 > mp -> msgstats[j] |= 1 << (bits + i);
728 340,349d329
729 < if (last < mp->lowmsg)
730 < continue;
731 < if (last > mp->hghmsg)
732 < last = mp->hghmsg;
733 < if (first < mp->lowmsg)
734 < first = mp->lowmsg;
735 < } else {
736 < if (first < mp->lowmsg)
737 < continue;
738 < last = first;
739 351,355c331,333
740 < for ( ; first <= last; ++first)
741 < if (mp->msgstats[first] & EXISTS)
742 < mp->msgstats[first] |= bits;
743 < }
744 < return slot;
745 ---
746 > free (field);
747 >
748 > return i;
749 diff -r -w lbl/sbr/m_seq.c ./sbr/m_seq.c
750 1a2,4
751 > #ifndef lint
752 > static char ident[] = "@(#)$Id: m_seq.c,v 1.7 1991/02/14 14:44:38 mh Exp $";
753 > #endif lint
754 6,7c9
755 < static char *buffer;
756 < static int bufsize = BUFSIZ;
757 ---
758 > /* new version from VJ 2/90 - faster? */
759 15,16c17,19
760 < register int i, j, linlen;
761 < register char *bp, *ep;
762 ---
763 > register int i, j;
764 > register char *bp;
765 > static char buffer[BUFSIZ*2]; /* for big sequences */
766 18,21d20
767 < if (buffer == 0) {
768 < if ((buffer = malloc(bufsize)) == NULL)
769 < adios (NULLCP, "unable to allocate seq str storage");
770 < }
771 22a22,23
772 > /* assume this is in sync with msgstats["cur"] */
773 > /* see m_seqadd() for details */
774 38,39d38
775 < ep = bp + bufsize - 16;
776 < linlen = strlen(cp) + 2;
777 41,42d39
778 < register char *oldbp;
779 <
780 46,58c43
781 < oldbp = bp;
782 < if (bp > buffer) {
783 < if (bp >= ep) {
784 < int oldoff = bp - buffer;
785 < bufsize <<= 1;
786 < if ((buffer = realloc(buffer, bufsize)) == NULL)
787 < adios (NULLCP, "unable to allocate seq str storage");
788 < oldbp = bp = buffer + oldoff;
789 < ep = bp + bufsize - 16;
790 < }
791 < if (linlen >= 72) {
792 < linlen = 0;
793 < *bp++ = '\n';
794 ---
795 > if (bp > buffer)
796 60,62c45
797 < }
798 < *bp++ = ' ';
799 < }
800 ---
801 >
802 73d55
803 < linlen += bp - oldbp;
804 diff -r -w lbl/zotnet/tws/dtimep.lex ./zotnet/tws/dtimep.lex
805 1,11d0
806 < %{
807 < #ifndef lint
808 < static char rcsid[] =
809 < #ifdef FLEX_SCANNER
810 < "@(#) $Header: dtimep.lex,v 1.15 90/10/16 14:57:20 leres Exp $ (LBL) (flex generated scanner)";
811 < #else
812 < "@(#) $Header: dtimep.lex,v 1.15 90/10/16 14:57:20 leres Exp $ (LBL) (lex generated scanner)";
813 < #endif
814 < #endif
815 < %}
816 < /*
817 16,17d4
818 < */
819 <
820 48a36,38
821 > #ifndef lint
822 > static char ident[] = "@(#)$Id: dtimep.lex,v 2.11 1992/02/10 20:32:29 jromine Exp jromine $";
823 > #endif
824 49a40
825 > #include "../h/strings.h"
826 50a42,45
827 > #include <sys/types.h>
828 > #ifndef SYS5
829 > #include <sys/timeb.h>
830 > #endif not SYS5
831 51a47,52
832 > #ifdef SYS5
833 > extern int daylight;
834 > extern long timezone;
835 > extern char *tzname[];
836 > #endif SYS5
837 >
838 55c56,57
839 < * American style: MM/DD/YY.
840 ---
841 > * American style: MM/DD/YY. Of course, these are all non-RFC822
842 > * compliant.
843 121c123,126
844 < #define CVT2 (i=(*cp++ - '0'),isdigit(*cp)? i*10 + (*cp++ - '0') : i)
845 ---
846 > #define CVT1OR2 (i=(*cp++ - '0'), isdigit(*cp)? i*10 + (*cp++ - '0') : i)
847 > #define CVT2 ((cp[0] - '0')*10 + (cp[1] - '0'))
848 > #define CVT4 ((((cp[0] - '0')*10 + (cp[1] - '0'))*10 + \
849 > (cp[2] - '0'))*10 + (cp[3] - '0'))
850 128,131c133,138
851 < #ifdef FLEX_SCANNER
852 < /* We get passed a string and return a pointer to a static tws struct */
853 < #undef YY_DECL
854 < #define YY_DECL struct tws *dparsetime(str) char *str;
855 ---
856 > #ifdef DSTXXX
857 > #ifndef BSD42
858 > #include <time.h>
859 > #else BSD42
860 > #include <sys/time.h>
861 > #endif BSD42
862 133,148c140,143
863 < /* We assume that we're never passed more than max_size characters */
864 < #undef YY_INPUT
865 < #define YY_INPUT(buf,result,max_size) \
866 < if (gstr) { \
867 < register char *xp; \
868 < xp = gstr; \
869 < while (isspace(*xp)) \
870 < xp++; \
871 < gstr = xp; \
872 < while (*xp != '\0') \
873 < ++xp; \
874 < result = xp - gstr; \
875 < bcopy(gstr, buf, result); \
876 < gstr = 0; \
877 < } else \
878 < result = YY_NULL;
879 ---
880 > static zonehack (tw)
881 > register struct tws *tw;
882 > {
883 > register struct tm *tm;
884 150,152c145,146
885 < /* Date strings aren't usually very long */
886 < #undef YY_READ_BUF_SIZE
887 < #define YY_READ_BUF_SIZE 128
888 ---
889 > if (twclock (tw) == -1L)
890 > return;
891 154,156c148,168
892 < /* Use mh error reporting routine */
893 < #undef YY_FATAL_ERROR
894 < #define YY_FATAL_ERROR(s) adios("dparsetime()", s);
895 ---
896 > tm = localtime (&tw -> tw_clock);
897 > if (tm -> tm_isdst) {
898 > tw -> tw_flags |= TW_DST;
899 > tw -> tw_zone -= 60;
900 > }
901 > }
902 > #endif DSTXXX
903 > %}
904 > %%
905 > %{
906 > struct tws *dparsetime (str)
907 > char *str;
908 > {
909 > register int i;
910 > static struct tws tw;
911 > register char *cp;
912 > register int gotdate = 0;
913 > #ifndef SYS5
914 > struct timeb tb;
915 > #endif not SYS5
916 > long tclock;
917 158,160c170
918 < /* We need a pointer to the matched text we can modify */
919 < #undef YY_USER_ACTION
920 < #define YY_USER_ACTION cp = yytext
921 ---
922 > start_cond = 0;
923 162,163c172,173
924 < /* Used to initialize */
925 < static struct tws ztw = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
926 ---
927 > /* Zero out the struct. */
928 > bzero( (char *) &tw, sizeof tw);
929 165,167c175,182
930 < /* Global for use by YY_INPUT() macro */
931 < static char *gstr;
932 < #endif
933 ---
934 > /* Set default time zone. */
935 > #ifndef SYS5
936 > ftime( &tb );
937 > tw.tw_zone = -tb.timezone;
938 > #else SYS5
939 > tzset( );
940 > tw.tw_zone = -(timezone / 60);
941 > #endif SYS5
942 169c184,187
943 < %}
944 ---
945 > while (isspace(*str))
946 > str++;
947 > while ( 1 )
948 > switch (cp = str, *cp ? lex_string( &str, start_cond) : 0) {
949 171,175c189,203
950 < %%
951 < register int i, gotdate;
952 < register char *cp;
953 < static struct tws tw;
954 < static void zonehack();
955 ---
956 > case -1:
957 > if (!gotdate || tw.tw_year == 0)
958 > return (struct tws *)0;
959 > /* fall through */
960 > case 0:
961 > if ( tw.tw_year == 0 ) {
962 > /* Set default year. */
963 > time (&tclock);
964 > tw.tw_year = localtime(&tclock)->tm_year + 1900;
965 > }
966 > else if (tw.tw_year < 100) {
967 > /* assume no 2-digit years > 1999 */
968 > tw.tw_year += 1900;
969 > }
970 > return &tw;
971 177,182c205
972 < BEGIN(INITIAL);
973 < yy_init = 1;
974 < tw = ztw;
975 < gstr = str;
976 < gotdate = 0;
977 <
978 ---
979 > %}
980 188,189c211
981 <
982 < {D}"/"{D}"/"(19)?[0-9][0-9]{w} {
983 ---
984 > {D}(("-"{D}"-")|("/"{D}"/")){D}?{d}{d}{w} {
985 192c214
986 < tw.tw_mday = CVT2;
987 ---
988 > tw.tw_mday = CVT1OR2;
989 194c216
990 < tw.tw_mon = CVT2 - 1;
991 ---
992 > tw.tw_mon = CVT1OR2 - 1;
993 197c219
994 < tw.tw_mon = CVT2 - 1;
995 ---
996 > tw.tw_mon = CVT1OR2 - 1;
997 199c221
998 < tw.tw_mday = CVT2;
999 ---
1000 > tw.tw_mday = CVT1OR2;
1001 204c226,236
1002 < tw.tw_year = i % 100;
1003 ---
1004 > tw.tw_year = i;
1005 > gotdate++; /* XXX */
1006 > }
1007 > {D}("/"|"-"){D}{w} {
1008 > if (europeandate) {
1009 > tw.tw_mday = CVT1OR2; cp++;
1010 > tw.tw_mon = CVT1OR2 - 1;
1011 > } else {
1012 > tw.tw_mon = CVT1OR2 - 1; cp++;
1013 > tw.tw_mday = CVT1OR2;
1014 > }
1015 207,208c239,240
1016 < {D}{w}(-)?{w}{MONTH}{w}(-)?{w}(19)?{D}{w}(\,{w}|at{W})? {
1017 < tw.tw_mday = CVT2;
1018 ---
1019 > {D}{w}(-)?{w}{MONTH}{w}(-)?{w}{D}?{d}{d}({W}at)?{w} {
1020 > tw.tw_mday = CVT1OR2;
1021 214c246
1022 < tw.tw_year = i % 100;
1023 ---
1024 > tw.tw_year = i;
1025 216c248,254
1026 < {MONTH}{W}{D}","{W}(19)?{D}{w} {
1027 ---
1028 > {D}"-"?{MONTH}({W}at)?{w} {
1029 > tw.tw_mday = CVT1OR2;
1030 > while ( ! isalpha( *cp++ ) )
1031 > ;
1032 > SETMONTH;
1033 > }
1034 > {MONTH}{W}{D}","{W}{D}?{d}{d}{w} {
1035 219c257
1036 < tw.tw_mday = CVT2;
1037 ---
1038 > tw.tw_mday = CVT1OR2;
1039 223c261
1040 < tw.tw_year = i % 100;
1041 ---
1042 > tw.tw_year = i;
1043 225d262
1044 <
1045 229c266
1046 < tw.tw_mday = CVT2;
1047 ---
1048 > tw.tw_mday = CVT1OR2;
1049 231a269,275
1050 > {D}:{D}:{D}{W}19[6-9]{d} { /* hack: ctime w/o TZ */
1051 > tw.tw_hour = CVT1OR2; cp++;
1052 > tw.tw_min = CVT1OR2; cp++;
1053 > tw.tw_sec = CVT1OR2;
1054 > SKIPD;
1055 > tw.tw_year = CVT4; cp+=4;
1056 > }
1057 233,235c277,279
1058 < tw.tw_hour = CVT2; cp++;
1059 < tw.tw_min = CVT2; cp++;
1060 < tw.tw_sec = CVT2;
1061 ---
1062 > tw.tw_hour = CVT1OR2; cp++;
1063 > tw.tw_min = CVT1OR2; cp++;
1064 > tw.tw_sec = CVT1OR2;
1065 239,240c283,284
1066 < tw.tw_hour = CVT2; cp++;
1067 < tw.tw_min = CVT2;
1068 ---
1069 > tw.tw_hour = CVT1OR2; cp++;
1070 > tw.tw_min = CVT1OR2;
1071 244c288
1072 < tw.tw_hour = CVT2; cp++;
1073 ---
1074 > tw.tw_hour = CVT1OR2; cp++;
1075 247c291
1076 < tw.tw_min = CVT2;
1077 ---
1078 > tw.tw_min = CVT1OR2;
1079 249a294,301
1080 > {D}:{D}:{D}{w}am{w} {
1081 > tw.tw_hour = CVT1OR2; cp++;
1082 > if (tw.tw_hour == 12)
1083 > tw.tw_hour = 0;
1084 > tw.tw_min = CVT1OR2; cp++;
1085 > tw.tw_sec = CVT1OR2;
1086 > BEGIN Z;
1087 > }
1088 251c303
1089 < tw.tw_hour = CVT2; cp++;
1090 ---
1091 > tw.tw_hour = CVT1OR2; cp++;
1092 254c306
1093 < tw.tw_min = CVT2;
1094 ---
1095 > tw.tw_min = CVT1OR2;
1096 256a309,316
1097 > {D}:{D}:{D}{w}pm{w} {
1098 > tw.tw_hour = CVT1OR2; cp++;
1099 > if (tw.tw_hour != 12)
1100 > tw.tw_hour += 12;
1101 > tw.tw_min = CVT1OR2; cp++;
1102 > tw.tw_sec = CVT1OR2;
1103 > BEGIN Z;
1104 > }
1105 258,260c318,320
1106 < tw.tw_hour = CVT2;
1107 < tw.tw_min = CVT2;
1108 < tw.tw_sec = CVT2;
1109 ---
1110 > tw.tw_hour = CVT2; cp+=2;
1111 > tw.tw_min = CVT2; cp+=2;
1112 > tw.tw_sec = CVT2; cp+=2;
1113 267,268c327
1114 < * and minutes. This rule must come
1115 < * the 4 digit hour and minute rule.
1116 ---
1117 > * and minutes.
1118 270,271c329
1119 < cp += 2;
1120 < tw.tw_year = CVT2;
1121 ---
1122 > tw.tw_year = CVT4; cp+=4;
1123 274,275c332,338
1124 < tw.tw_hour = CVT2;
1125 < tw.tw_min = CVT2;
1126 ---
1127 > if (tw.tw_hour || tw.tw_min
1128 > || tw.tw_sec) {
1129 > tw.tw_year = CVT4; cp+=4;
1130 > tw.tw_zone = 0;
1131 > } else {
1132 > tw.tw_hour = CVT2; cp+=2;
1133 > tw.tw_min = CVT2; cp+=2;
1134 277a341
1135 > }
1136 315a380
1137 > EXPZONE;
1138 320d384
1139 < EXPZONE;
1140 327a392
1141 > EXPZONE;
1142 332d396
1143 < EXPZONE;
1144 334c398,401
1145 <
1146 ---
1147 > <Z>{W}{d}{d}{d}{d} {
1148 > SKIPD;
1149 > tw.tw_year = CVT4; cp+=4;
1150 > }
1151 337,349d403
1152 <
1153 < <INITIAL,Z><<EOF>> return(&tw);
1154 <
1155 < . {
1156 < /*
1157 < * We jammed; it's an error if we
1158 < * didn't parse anything.
1159 < */
1160 < if (!gotdate || tw.tw_year == 0)
1161 < return(0);
1162 < return(&tw);
1163 < }
1164 <
1165 351,375d404
1166 <
1167 < #ifdef DSTXXX
1168 < #include <sys/types.h>
1169 < #ifndef BSD42
1170 < #include <time.h>
1171 < #else BSD42
1172 < #include <sys/time.h>
1173 < #endif BSD42
1174 <
1175 < static void
1176 < zonehack(tw)
1177 < register struct tws *tw;
1178 < {
1179 < register struct tm *tm;
1180 <
1181 < if (twclock (tw) == -1L)
1182 < return;
1183 <
1184 < tm = localtime (&tw -> tw_clock);
1185 < if (tm -> tm_isdst) {
1186 < tw -> tw_flags |= TW_DST;
1187 < tw -> tw_zone -= 60;
1188 < }
1189 < }
1190 < #endif DSTXXX