[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.29 and 1.36

version 1.29, 2015/03/17 19:31:30 version 1.36, 2019/02/01 16:22:53
Line 78 
Line 78 
 static struct fixs nmonths[13];       /* short national month names */  static struct fixs nmonths[13];       /* short national month names */
   
 void  void
   fill_print_date(struct match *m, struct tm *tm)
   {
           if (strftime(m->print_date, sizeof(m->print_date),
               daynames ? "%a %b %d" : "%b %d", tm) == 0)
                   m->print_date[sizeof(m->print_date) - 1] = '\0';
   }
   
   void
 setnnames(void)  setnnames(void)
 {  {
         char buf[80];          char buf[80];
Line 90 
Line 98 
                 for (; l > 0 && isspace((unsigned char)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)                  free(ndays[i].name);
                         free(ndays[i].name);  
                 if ((ndays[i].name = strdup(buf)) == NULL)                  if ((ndays[i].name = strdup(buf)) == NULL)
                         err(1, NULL);                          err(1, NULL);
                 ndays[i].len = strlen(buf);                  ndays[i].len = strlen(buf);
Line 100 
Line 107 
                 for (; l > 0 && isspace((unsigned char)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)                  free(fndays[i].name);
                         free(fndays[i].name);  
                 if ((fndays[i].name = strdup(buf)) == NULL)                  if ((fndays[i].name = strdup(buf)) == NULL)
                         err(1, NULL);                          err(1, NULL);
                 fndays[i].len = strlen(buf);                  fndays[i].len = strlen(buf);
Line 113 
Line 119 
                 for (; l > 0 && isspace((unsigned char)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)                  free(nmonths[i].name);
                         free(nmonths[i].name);  
                 if ((nmonths[i].name = strdup(buf)) == NULL)                  if ((nmonths[i].name = strdup(buf)) == NULL)
                         err(1, NULL);                          err(1, NULL);
                 nmonths[i].len = strlen(buf);                  nmonths[i].len = strlen(buf);
Line 123 
Line 128 
                 for (; l > 0 && isspace((unsigned char)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)                  free(fnmonths[i].name);
                         free(fnmonths[i].name);  
                 if ((fnmonths[i].name = strdup(buf)) == NULL)                  if ((fnmonths[i].name = strdup(buf)) == NULL)
                         err(1, NULL);                          err(1, NULL);
                 fnmonths[i].len = strlen(buf);                  fnmonths[i].len = strlen(buf);
Line 162 
Line 166 
                 cumdays = daytab[0];                  cumdays = daytab[0];
         /* Friday displays Monday's events */          /* Friday displays Monday's events */
         offset = tp->tm_wday == 5 ? 3 : 1;          offset = tp->tm_wday == 5 ? 3 : 1;
         if (f_SetdayAfter)          if (f_Setday)
                 offset = 0;     /* Except not when range is set explicitly */                  offset = 0;     /* Except not when range is set explicitly */
         header[5].iov_base = dayname;          header[5].iov_base = dayname;
   
Line 286 
Line 290 
         /* adjust bodun rate */          /* adjust bodun rate */
         if (bodun && !bodun_always)          if (bodun && !bodun_always)
                 bodun = !arc4random_uniform(3);                  bodun = !arc4random_uniform(3);
   
         /* Easter or Easter depending days */          /* Easter or Easter depending days */
         if (flags & F_SPECIAL)          if (flags & F_SPECIAL)
                 vwd = v1;                  vwd = v1;
Line 455 
Line 459 
                         }                          }
   
                         (void)mktime(&tmtmp);                          (void)mktime(&tmtmp);
                         if (strftime(tmp->print_date,                          fill_print_date(tmp, &tmtmp);
                             sizeof(tmp->print_date),  
                         /*    "%a %b %d", &tm);  Skip weekdays */  
                             "%b %d", &tmtmp) == 0)  
                                 tmp->print_date[sizeof(tmp->print_date) - 1] = '\0';  
   
                         tmp->var   = varp;                          tmp->var   = varp;
                         tmp->next  = NULL;                          tmp->next  = NULL;
                         return(tmp);                          return(tmp);
Line 544 
Line 543 
                                 tdiff = difftime(ttmp, f_time)/ SECSPERDAY;                                  tdiff = difftime(ttmp, f_time)/ SECSPERDAY;
                                 if (tdiff <= offset + f_dayAfter ||                                  if (tdiff <= offset + f_dayAfter ||
                                     (bodun && tdiff == -1)) {                                      (bodun && tdiff == -1)) {
                                         if (tdiff >=  0 ||                                          if (((tmtmp.tm_mon == month) ||
                                             (bodun && tdiff == -1)) {                                               (flags & F_SPECIAL) ||
                                                (interval == WEEKLY)) &&
                                               (tdiff >=  0 ||
                                               (bodun && tdiff == -1))) {
                                         if ((tmp = malloc(sizeof(struct match))) == NULL)                                          if ((tmp = malloc(sizeof(struct match))) == NULL)
                                                 err(1, NULL);                                                  err(1, NULL);
                                         tmp->when = ttmp;                                          tmp->when = ttmp;
                                         if (strftime(tmp->print_date,                                          fill_print_date(tmp, &tmtmp);
                                             sizeof(tmp->print_date),  
                                         /*    "%a %b %d", &tm);  Skip weekdays */  
                                             "%b %d", &tmtmp) == 0)  
                                                 tmp->print_date[sizeof(tmp->print_date) - 1] = '\0';  
                                         tmp->bodun = bodun && tdiff == -1;                                          tmp->bodun = bodun && tdiff == -1;
                                         tmp->var   = varp;                                          tmp->var   = varp;
                                         tmp->next  = NULL;                                          tmp->next  = NULL;

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.36