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

Diff for /src/usr.bin/calendar/io.c between version 1.40 and 1.47

version 1.40, 2015/10/23 11:01:30 version 1.47, 2017/09/25 19:13:56
Line 89 
Line 89 
                 if (strncmp(buf, "LANG=", 5) == 0) {                  if (strncmp(buf, "LANG=", 5) == 0) {
                         (void) setlocale(LC_ALL, buf + 5);                          (void) setlocale(LC_ALL, buf + 5);
                         setnnames();                          setnnames();
                         /* XXX remove KOI8 lines after 5.9 is out */  
                         if (!strcmp(buf + 5, "ru_RU.UTF-8") ||                          if (!strcmp(buf + 5, "ru_RU.UTF-8") ||
                             !strcmp(buf + 5, "uk_UA.UTF-8") ||                              !strcmp(buf + 5, "uk_UA.UTF-8") ||
                             !strcmp(buf + 5, "by_BY.UTF-8")) ||                              !strcmp(buf + 5, "by_BY.UTF-8")) {
                             !strcmp(buf + 5, "ru_RU.KOI8-R") ||  
                             !strcmp(buf + 5, "uk_UA.KOI8-U") ||  
                             !strcmp(buf + 5, "by_BY.KOI8-B")) {  
                                 bodun_maybe++;                                  bodun_maybe++;
                                 bodun = 0;                                  bodun = 0;
                                 if (prefix)                                  free(prefix);
                                         free(prefix);  
                                 prefix = NULL;                                  prefix = NULL;
                         } else                          } else
                                 bodun_maybe = 0;                                  bodun_maybe = 0;
Line 124 
Line 119 
                                 calendar = LUNAR;                                  calendar = LUNAR;
                 } else if (bodun_maybe && strncmp(buf, "BODUN=", 6) == 0) {                  } else if (bodun_maybe && strncmp(buf, "BODUN=", 6) == 0) {
                         bodun++;                          bodun++;
                         if (prefix)                          free(prefix);
                                 free(prefix);  
                         if ((prefix = strdup(buf + 6)) == NULL)                          if ((prefix = strdup(buf + 6)) == NULL)
                                 err(1, NULL);                                  err(1, NULL);
                         continue;                          continue;
Line 138 
Line 132 
                                     (p - buf == spev[i].nlen) &&                                      (p - buf == spev[i].nlen) &&
                                     buf[spev[i].nlen + 1]) {                                      buf[spev[i].nlen + 1]) {
                                         p++;                                          p++;
                                         if (spev[i].uname != NULL)                                          free(spev[i].uname);
                                                 free(spev[i].uname);  
                                         if ((spev[i].uname = strdup(p)) == NULL)                                          if ((spev[i].uname = strdup(p)) == NULL)
                                                 err(1, NULL);                                                  err(1, NULL);
                                         spev[i].ulen = strlen(p);                                          spev[i].ulen = strlen(p);
Line 163 
Line 156 
                                 var = 0;                                  var = 0;
                         if (printing) {                          if (printing) {
                                 struct match *foo;                                  struct match *foo;
   
                                 ev1 = NULL;                                  ev1 = NULL;
                                 while (m) {                                  while (m) {
                                         cur_evt = malloc(sizeof(struct event));                                          cur_evt = malloc(sizeof(struct event));
                                         if (cur_evt == NULL)                                          if (cur_evt == NULL)
                                                 err(1, NULL);                                                  err(1, NULL);
   
                                         cur_evt->when = m->when;                                          cur_evt->when = m->when;
                                         snprintf(cur_evt->print_date,                                          snprintf(cur_evt->print_date,
                                             sizeof(cur_evt->print_date), "%s%c",                                              sizeof(cur_evt->print_date), "%s%c",
Line 211 
Line 204 
         tmp = events;          tmp = events;
         while (tmp) {          while (tmp) {
                 events = tmp;                  events = tmp;
                 if (tmp->ldesc)                  free(tmp->ldesc);
                         free(tmp->ldesc);  
                 tmp = tmp->next;                  tmp = tmp->next;
                 free(events);                  free(events);
         }          }
Line 302 
Line 294 
                                  * number of special events. */                                   * number of special events. */
                                 break;                                  break;
                         }                          }
                         *flags |= F_SPECIAL;                          *flags |= F_SPECIAL;
                 }                  }
                 if (!(*flags & F_SPECIAL)) {                  if (!(*flags & F_SPECIAL)) {
                         /* undefined rest */                          /* undefined rest */
Line 339 
Line 331 
                 }                  }
         }          }
   
         if (pipe(pdes) < 0)          if (pipe(pdes) < 0) {
                   close(fdin);
                 return (NULL);                  return (NULL);
           }
         switch (vfork()) {          switch (vfork()) {
         case -1:                        /* error */          case -1:                        /* error */
                 (void)close(pdes[0]);                  (void)close(pdes[0]);
                 (void)close(pdes[1]);                  (void)close(pdes[1]);
                   close(fdin);
                 return (NULL);                  return (NULL);
         case 0:          case 0:
                 dup2(fdin, STDIN_FILENO);                  dup2(fdin, STDIN_FILENO);
Line 354 
Line 349 
                         (void)close(pdes[1]);                          (void)close(pdes[1]);
                 }                  }
                 (void)close(pdes[0]);                  (void)close(pdes[0]);
                 /*                  /*
                  * Set stderr to /dev/null.  Necessary so that cron does not                   * Set stderr to /dev/null.  Necessary so that cron does not
                  * wait for cpp to finish if it's running calendar -a.                   * wait for cpp to finish if it's running calendar -a.
                  */                   */
Line 390 
Line 385 
         struct stat sbuf;          struct stat sbuf;
         int nread, pdes[2], status;          int nread, pdes[2], status;
         char buf[1024];          char buf[1024];
           pid_t pid = -1;
   
         if (!doall)          if (!doall)
                 return;                  return;
Line 399 
Line 395 
                 goto done;                  goto done;
         if (pipe(pdes) < 0)          if (pipe(pdes) < 0)
                 goto done;                  goto done;
         switch (vfork()) {          switch ((pid = vfork())) {
         case -1:                        /* error */          case -1:                        /* error */
                 (void)close(pdes[0]);                  (void)close(pdes[0]);
                 (void)close(pdes[1]);                  (void)close(pdes[1]);
Line 426 
Line 422 
                 (void)write(pdes[1], buf, nread);                  (void)write(pdes[1], buf, nread);
         (void)close(pdes[1]);          (void)close(pdes[1]);
 done:   (void)fclose(fp);  done:   (void)fclose(fp);
         while (wait(&status) >= 0)          if (pid != -1) {
                 ;                  while (waitpid(pid, &status, 0) == -1) {
                           if (errno != EINTR)
                                   break;
                   }
           }
 }  }
   
   

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.47