Changeset 4058 for trunk/lib-src/b2m.c
- Timestamp:
- 04/16/06 21:46:31 (3 years ago)
- Files:
-
- trunk/lib-src/b2m.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib-src/b2m.c
r3684 r4058 45 45 typedef int logical; 46 46 47 #define TM_YEAR_BASE 1900 48 49 /* Nonzero if TM_YEAR is a struct tm's tm_year value that causes 50 asctime to have well-defined behavior. */ 51 #ifndef TM_YEAR_IN_ASCTIME_RANGE 52 # define TM_YEAR_IN_ASCTIME_RANGE(tm_year) \ 53 (1000 - TM_YEAR_BASE <= (tm_year) && (tm_year) <= 9999 - TM_YEAR_BASE) 54 #endif 55 47 56 /* 48 57 * A `struct linebuffer' is a structure which holds a line of text. … … 88 97 logical labels_saved, printing, header; 89 98 time_t ltoday; 99 struct tm *tm; 90 100 char *labels, *p, *today; 91 101 struct linebuffer data; … … 132 142 labels_saved = printing = header = FALSE; 133 143 ltoday = time (0); 134 today = ctime (<oday); 144 /* Convert to a string, checking for out-of-range time stamps. 145 Don't use 'ctime', as that might dump core if the hardware clock 146 is set to a bizarre value. */ 147 tm = localtime (<oday); 148 if (! (tm && TM_YEAR_IN_ASCTIME_RANGE (tm->tm_year) 149 && (today = asctime (tm)))) 150 fatal ("current time is out of range"); 135 151 data.size = 200; 136 152 data.buffer = xnew (200, char);
