strftime.c (50476) | strftime.c (51186) |
---|---|
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 50476 1999-08-28 00:22:10Z peter $"; | 20 "$FreeBSD: head/lib/libc/stdtime/strftime.c 51186 1999-09-11 21:35:21Z dt $"; |
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 for ( ; *format; ++format) { 79 if (*format == '%') { | 79 for ( ; *format; ++format) { 80 if (*format == '%') { |
81 alternative = 0; |
|
80label: 81 switch (*++format) { 82 case '\0': 83 --format; 84 break; 85 case 'A': 86 pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? 87 "?" : Locale->weekday[t->tm_wday], 88 pt, ptlim); 89 continue; 90 case 'a': 91 pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? 92 "?" : Locale->wday[t->tm_wday], 93 pt, ptlim); 94 continue; 95 case 'B': | 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': |
96 pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? 97 "?" : Locale->month[t->tm_mon], | 98 pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? 99 "?" : (alternative ? Locale->alt_month : 100 Locale->month)[t->tm_mon], |
98 pt, ptlim); 99 continue; 100 case 'b': 101 case 'h': 102 pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? 103 "?" : Locale->mon[t->tm_mon], 104 pt, ptlim); 105 continue; --- 25 unchanged lines hidden (view full) --- 131 ** The sequences 132 ** %Ec %EC %Ex %Ey %EY 133 ** %Od %oe %OH %OI %Om %OM 134 ** %OS %Ou %OU %OV %Ow %OW %Oy 135 ** are supposed to provide alternate 136 ** representations. 137 ** (ado, 5/24/93) 138 */ | 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); 108 continue; --- 25 unchanged lines hidden (view full) --- 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 */ |
142 alternative = 1; |
|
139 goto label; 140 case 'e': 141 pt = _conv(t->tm_mday, "%2d", pt, ptlim); 142 continue; 143 case 'H': 144 pt = _conv(t->tm_hour, "%02d", pt, ptlim); 145 continue; 146 case 'I': --- 271 unchanged lines hidden --- | 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': --- 271 unchanged lines hidden --- |