Deleted Added
full compact
strftime.c (51186) strftime.c (53940)
1/*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 */
17
18#ifdef LIBC_RCS
19static const char rcsid[] =
1/*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 */
17
18#ifdef LIBC_RCS
19static const char rcsid[] =
20 "$FreeBSD: head/lib/libc/stdtime/strftime.c 51186 1999-09-11 21:35:21Z dt $";
20 "$FreeBSD: head/lib/libc/stdtime/strftime.c 53940 1999-11-30 07:33:37Z ache $";
21#endif
22
23#ifndef lint
24#ifndef NOID
25static const char elsieid[] = "@(#)strftime.c 7.38";
26/*
27** Based on the UCB version with the ID appearing below.
28** This is ANSIish only when "multibyte character == plain character".

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

70
71static char *
72_fmt(format, t, pt, ptlim)
73 const char *format;
74 const struct tm *const t;
75 char *pt;
76 const char *const ptlim;
77{
21#endif
22
23#ifndef lint
24#ifndef NOID
25static const char elsieid[] = "@(#)strftime.c 7.38";
26/*
27** Based on the UCB version with the ID appearing below.
28** This is ANSIish only when "multibyte character == plain character".

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

70
71static char *
72_fmt(format, t, pt, ptlim)
73 const char *format;
74 const struct tm *const t;
75 char *pt;
76 const char *const ptlim;
77{
78 int alternative;
78 int Ealternative, Oalternative;
79
79 for ( ; *format; ++format) {
80 if (*format == '%') {
80 for ( ; *format; ++format) {
81 if (*format == '%') {
81 alternative = 0;
82 Ealternative = 0;
83 Oalternative = 0;
82label:
83 switch (*++format) {
84 case '\0':
85 --format;
86 break;
87 case 'A':
88 pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ?
89 "?" : Locale->weekday[t->tm_wday],
90 pt, ptlim);
91 continue;
92 case 'a':
93 pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ?
94 "?" : Locale->wday[t->tm_wday],
95 pt, ptlim);
96 continue;
97 case 'B':
98 pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ?
84label:
85 switch (*++format) {
86 case '\0':
87 --format;
88 break;
89 case 'A':
90 pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ?
91 "?" : Locale->weekday[t->tm_wday],
92 pt, ptlim);
93 continue;
94 case 'a':
95 pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ?
96 "?" : Locale->wday[t->tm_wday],
97 pt, ptlim);
98 continue;
99 case 'B':
100 pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ?
99 "?" : (alternative ? Locale->alt_month :
101 "?" : (Oalternative ? Locale->alt_month :
100 Locale->month)[t->tm_mon],
101 pt, ptlim);
102 continue;
103 case 'b':
104 case 'h':
105 pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ?
106 "?" : Locale->mon[t->tm_mon],
107 pt, ptlim);

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

122 continue;
123 case 'D':
124 pt = _fmt("%m/%d/%y", t, pt, ptlim);
125 continue;
126 case 'd':
127 pt = _conv(t->tm_mday, "%02d", pt, ptlim);
128 continue;
129 case 'E':
102 Locale->month)[t->tm_mon],
103 pt, ptlim);
104 continue;
105 case 'b':
106 case 'h':
107 pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ?
108 "?" : Locale->mon[t->tm_mon],
109 pt, ptlim);

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

124 continue;
125 case 'D':
126 pt = _fmt("%m/%d/%y", t, pt, ptlim);
127 continue;
128 case 'd':
129 pt = _conv(t->tm_mday, "%02d", pt, ptlim);
130 continue;
131 case 'E':
132 Ealternative++;
133 goto label;
130 case 'O':
131 /*
132 ** POSIX locale extensions, a la
133 ** Arnold Robbins' strftime version 3.0.
134 ** The sequences
135 ** %Ec %EC %Ex %Ey %EY
136 ** %Od %oe %OH %OI %Om %OM
137 ** %OS %Ou %OU %OV %Ow %OW %Oy
138 ** are supposed to provide alternate
139 ** representations.
140 ** (ado, 5/24/93)
141 */
134 case 'O':
135 /*
136 ** POSIX locale extensions, a la
137 ** Arnold Robbins' strftime version 3.0.
138 ** The sequences
139 ** %Ec %EC %Ex %Ey %EY
140 ** %Od %oe %OH %OI %Om %OM
141 ** %OS %Ou %OU %OV %Ow %OW %Oy
142 ** are supposed to provide alternate
143 ** representations.
144 ** (ado, 5/24/93)
145 */
142 alternative = 1;
146 Oalternative++;
143 goto label;
144 case 'e':
145 pt = _conv(t->tm_mday, "%2d", pt, ptlim);
146 continue;
147 case 'H':
148 pt = _conv(t->tm_hour, "%02d", pt, ptlim);
149 continue;
150 case 'I':

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

352 continue;
353 case 'w':
354 pt = _conv(t->tm_wday, "%d", pt, ptlim);
355 continue;
356 case 'X':
357 pt = _fmt(Locale->X_fmt, t, pt, ptlim);
358 continue;
359 case 'x':
147 goto label;
148 case 'e':
149 pt = _conv(t->tm_mday, "%2d", pt, ptlim);
150 continue;
151 case 'H':
152 pt = _conv(t->tm_hour, "%02d", pt, ptlim);
153 continue;
154 case 'I':

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

356 continue;
357 case 'w':
358 pt = _conv(t->tm_wday, "%d", pt, ptlim);
359 continue;
360 case 'X':
361 pt = _fmt(Locale->X_fmt, t, pt, ptlim);
362 continue;
363 case 'x':
360 pt = _fmt(Locale->x_fmt, t, pt, ptlim);
364 pt = _fmt(Ealternative ? Locale->Ex_fmt : Locale->x_fmt, t, pt, ptlim);
361 continue;
362 case 'y':
363 pt = _conv((t->tm_year + TM_YEAR_BASE) % 100,
364 "%02d", pt, ptlim);
365 continue;
366 case 'Y':
367 pt = _conv(t->tm_year + TM_YEAR_BASE, "%04d",
368 pt, ptlim);

--- 53 unchanged lines hidden ---
365 continue;
366 case 'y':
367 pt = _conv((t->tm_year + TM_YEAR_BASE) % 100,
368 "%02d", pt, ptlim);
369 continue;
370 case 'Y':
371 pt = _conv(t->tm_year + TM_YEAR_BASE, "%04d",
372 pt, ptlim);

--- 53 unchanged lines hidden ---