version 1.40, 2015/10/23 11:01:30 |
version 1.47, 2017/09/25 19:13:56 |
|
|
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; |
|
|
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; |
|
|
(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); |
|
|
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", |
|
|
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); |
} |
} |
|
|
* 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 */ |
|
|
} |
} |
} |
} |
|
|
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); |
|
|
(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. |
*/ |
*/ |
|
|
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; |
|
|
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]); |
|
|
(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; |
|
} |
|
} |
} |
} |
|
|
|
|