[BACK]Return to day.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / calendar

Diff for /src/usr.bin/calendar/day.c between version 1.20 and 1.28

version 1.20, 2005/11/16 16:45:11 version 1.28, 2015/03/15 00:41:28
Line 29 
Line 29 
  * SUCH DAMAGE.   * SUCH DAMAGE.
  */   */
   
 #ifndef lint  
 static const char copyright[] =  
 "@(#) Copyright (c) 1989, 1993\n\  
         The Regents of the University of California.  All rights reserved.\n";  
 #endif /* not lint */  
   
 #ifndef lint  
 #if 0  
 static const char sccsid[] = "@(#)calendar.c  8.3 (Berkeley) 3/25/94";  
 #else  
 static const char rcsid[] = "$OpenBSD$";  
 #endif  
 #endif /* not lint */  
   
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/uio.h>  #include <sys/uio.h>
   
Line 53 
Line 39 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <time.h>  #include <time.h>
 #include <tzfile.h>  
   
 #include "pathnames.h"  #include "pathnames.h"
 #include "calendar.h"  #include "calendar.h"
   
   extern struct iovec header[];
   
 #define WEEKLY 1  #define WEEKLY 1
 #define MONTHLY 2  #define MONTHLY 2
 #define YEARLY 3  #define YEARLY 3
Line 90 
Line 77 
 static struct fixs fnmonths[13];      /* full national months names */  static struct fixs fnmonths[13];      /* full national months names */
 static struct fixs nmonths[13];       /* short national month names */  static struct fixs nmonths[13];       /* short national month names */
   
   
 void  void
 setnnames(void)  setnnames(void)
 {  {
Line 101 
Line 87 
         for (i = 0; i < 7; i++) {          for (i = 0; i < 7; i++) {
                 tm.tm_wday = i;                  tm.tm_wday = i;
                 l = strftime(buf, sizeof(buf), "%a", &tm);                  l = strftime(buf, sizeof(buf), "%a", &tm);
                 for (; l > 0 && isspace((int)buf[l - 1]); l--)                  for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--)
                         ;                          ;
                 buf[l] = '\0';                  buf[l] = '\0';
                 if (ndays[i].name != NULL)                  if (ndays[i].name != NULL)
Line 111 
Line 97 
                 ndays[i].len = strlen(buf);                  ndays[i].len = strlen(buf);
   
                 l = strftime(buf, sizeof(buf), "%A", &tm);                  l = strftime(buf, sizeof(buf), "%A", &tm);
                 for (; l > 0 && isspace((int)buf[l - 1]); l--)                  for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--)
                         ;                          ;
                 buf[l] = '\0';                  buf[l] = '\0';
                 if (fndays[i].name != NULL)                  if (fndays[i].name != NULL)
Line 124 
Line 110 
         for (i = 0; i < 12; i++) {          for (i = 0; i < 12; i++) {
                 tm.tm_mon = i;                  tm.tm_mon = i;
                 l = strftime(buf, sizeof(buf), "%b", &tm);                  l = strftime(buf, sizeof(buf), "%b", &tm);
                 for (; l > 0 && isspace((int)buf[l - 1]); l--)                  for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--)
                         ;                          ;
                 buf[l] = '\0';                  buf[l] = '\0';
                 if (nmonths[i].name != NULL)                  if (nmonths[i].name != NULL)
Line 134 
Line 120 
                 nmonths[i].len = strlen(buf);                  nmonths[i].len = strlen(buf);
   
                 l = strftime(buf, sizeof(buf), "%B", &tm);                  l = strftime(buf, sizeof(buf), "%B", &tm);
                 for (; l > 0 && isspace((int)buf[l - 1]); l--)                  for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--)
                         ;                          ;
                 buf[l] = '\0';                  buf[l] = '\0';
                 if (fnmonths[i].name != NULL)                  if (fnmonths[i].name != NULL)
Line 203 
Line 189 
         len = strlen(date);          len = strlen(date);
         if (len < 2)          if (len < 2)
                 return((time_t)-1);                  return((time_t)-1);
           bzero(&tm, sizeof tm);
         tm.tm_sec = 0;          tm.tm_sec = 0;
         tm.tm_min = 0;          tm.tm_min = 0;
         /* Avoid getting caught by a timezone shift; set time to noon */          /* Avoid getting caught by a timezone shift; set time to noon */
Line 237 
Line 224 
         }          }
   
 #if DEBUG  #if DEBUG
         printf("Mktime: %d %d %d %s\n", (int)mktime(&tm), (int)t, len,          printf("Mktime: %d %lld %d %s\n", (int)mktime(&tm), (long long)t, len,
             asctime(&tm));              asctime(&tm));
 #endif  #endif
         return(mktime(&tm));          return(mktime(&tm));
 }  }
   
 void  static void
 adjust_calendar(int *day, int *month)  adjust_calendar(int *day, int *month)
 {  {
         switch (calendar) {          switch (calendar) {
Line 301 
Line 288 
   
         /* adjust bodun rate */          /* adjust bodun rate */
         if (bodun && !bodun_always)          if (bodun && !bodun_always)
                 bodun = !(arc4random() % 3);                  bodun = !arc4random_uniform(3);
   
         /* Easter or Easter depending days */          /* Easter or Easter depending days */
         if (flags & F_SPECIAL)          if (flags & F_SPECIAL)

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.28