Deleted Added
full compact
ncal.c (74573) ncal.c (74612)
1/*-
2 * Copyright (c) 1997 Wolfgang Helbig
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifndef lint
28static const char rcsid[] =
1/*-
2 * Copyright (c) 1997 Wolfgang Helbig
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#ifndef lint
28static const char rcsid[] =
29 "$FreeBSD: head/usr.bin/ncal/ncal.c 74573 2001-03-21 14:24:05Z ache $";
29 "$FreeBSD: head/usr.bin/ncal/ncal.c 74612 2001-03-22 00:25:26Z ache $";
30#endif /* not lint */
31
32#include <calendar.h>
30#endif /* not lint */
31
32#include <calendar.h>
33#include <ctype.h>
33#include <err.h>
34#include <langinfo.h>
35#include <locale.h>
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <sysexits.h>
40#include <time.h>

--- 154 unchanged lines hidden (view full) ---

195 char *cp; /* character pointer */
196 char *locale; /* locale to get country code */
197
198 /*
199 * Use locale to determine the country code,
200 * and use the country code to determine the default
201 * switchdate and date format from the switches table.
202 */
34#include <err.h>
35#include <langinfo.h>
36#include <locale.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <sysexits.h>
41#include <time.h>

--- 154 unchanged lines hidden (view full) ---

196 char *cp; /* character pointer */
197 char *locale; /* locale to get country code */
198
199 /*
200 * Use locale to determine the country code,
201 * and use the country code to determine the default
202 * switchdate and date format from the switches table.
203 */
203 if ((locale = setlocale(LC_TIME, "")) == NULL)
204 if (setlocale(LC_ALL, "") == NULL)
204 warn("setlocale");
205 warn("setlocale");
206 locale = setlocale(LC_TIME, NULL);
205 if (locale == NULL || locale == "C")
206 locale = "_US";
207 q = switches + sizeof(switches) / sizeof(struct djswitch);
208 for (p = switches; p != q; p++)
209 if ((cp = strstr(locale, p->cc)) != NULL && *(cp - 1) == '_')
210 break;
211 if (p == q) {
212 nswitch = ndaysj(&dftswitch->dt);

--- 365 unchanged lines hidden (view full) ---

578 int jan1 = 0; /* the first day of this year */
579 char *ds; /* pointer to day strings (daystr or
580 * jdaystr) */
581
582 /* Set name of month. */
583 memset(&tm, 0, sizeof(tm));
584 tm.tm_mon = m;
585 strftime(mlines->name, sizeof(mlines->name), "%OB", &tm);
207 if (locale == NULL || locale == "C")
208 locale = "_US";
209 q = switches + sizeof(switches) / sizeof(struct djswitch);
210 for (p = switches; p != q; p++)
211 if ((cp = strstr(locale, p->cc)) != NULL && *(cp - 1) == '_')
212 break;
213 if (p == q) {
214 nswitch = ndaysj(&dftswitch->dt);

--- 365 unchanged lines hidden (view full) ---

580 int jan1 = 0; /* the first day of this year */
581 char *ds; /* pointer to day strings (daystr or
582 * jdaystr) */
583
584 /* Set name of month. */
585 memset(&tm, 0, sizeof(tm));
586 tm.tm_mon = m;
587 strftime(mlines->name, sizeof(mlines->name), "%OB", &tm);
588 mlines->name[0] = toupper((unsigned char)mlines->name[0]);
586
587 /*
588 * Set first and last to the day number of the first day of this
589 * month and the first day of next month respectively. Set jan1 to
590 * the day number of the first day of this year.
591 */
592 first = firstday(y, m + 1);
593 if (m == 11)

--- 75 unchanged lines hidden (view full) ---

669 ds = daystr;
670 dw = 3;
671 }
672
673 /* Set name of month centered */
674 memset(&tm, 0, sizeof(tm));
675 tm.tm_mon = m;
676 strftime(mlines->name, sizeof(mlines->name), "%OB", &tm);
589
590 /*
591 * Set first and last to the day number of the first day of this
592 * month and the first day of next month respectively. Set jan1 to
593 * the day number of the first day of this year.
594 */
595 first = firstday(y, m + 1);
596 if (m == 11)

--- 75 unchanged lines hidden (view full) ---

672 ds = daystr;
673 dw = 3;
674 }
675
676 /* Set name of month centered */
677 memset(&tm, 0, sizeof(tm));
678 tm.tm_mon = m;
679 strftime(mlines->name, sizeof(mlines->name), "%OB", &tm);
680 mlines->name[0] = toupper((unsigned char)mlines->name[0]);
677
678 /*
679 * Set first and last to the day number of the first day of this
680 * month and the first day of next month respectively. Set jan1 to
681 * the day number of Jan 1st of this year.
682 */
683 dt.y = y;
684 dt.m = m + 1;

--- 55 unchanged lines hidden (view full) ---

740 struct tm tm;
741
742 memset(&tm, 0, sizeof(tm));
743
744 for (i = 0; i != 7; i++) {
745 tm.tm_wday = (i+1) % 7;
746 strftime(wds->names[i], 4, "%a", &tm);
747 wds->names[i][2] = ' ';
681
682 /*
683 * Set first and last to the day number of the first day of this
684 * month and the first day of next month respectively. Set jan1 to
685 * the day number of Jan 1st of this year.
686 */
687 dt.y = y;
688 dt.m = m + 1;

--- 55 unchanged lines hidden (view full) ---

744 struct tm tm;
745
746 memset(&tm, 0, sizeof(tm));
747
748 for (i = 0; i != 7; i++) {
749 tm.tm_wday = (i+1) % 7;
750 strftime(wds->names[i], 4, "%a", &tm);
751 wds->names[i][2] = ' ';
752 wds->names[i][3] = '\0';
748 }
749}
750
751/*
752 * Compute the day number of the first
753 * existing date after the first day in month.
754 * (the first day in month and even the month might not exist!)
755 */

--- 83 unchanged lines hidden ---
753 }
754}
755
756/*
757 * Compute the day number of the first
758 * existing date after the first day in month.
759 * (the first day in month and even the month might not exist!)
760 */

--- 83 unchanged lines hidden ---