diff options
| author | Alexey Zelkin <phantom@FreeBSD.org> | 2001-02-08 17:08:13 +0000 | 
|---|---|---|
| committer | Alexey Zelkin <phantom@FreeBSD.org> | 2001-02-08 17:08:13 +0000 | 
| commit | 930cd7110730e3d4c4ae66b0f609dc1504f4fbb6 (patch) | |
| tree | 0edb90bd51fc1ebd2872ecc820b2521770e0550b | |
| parent | 18f3e1e4004b7454ec7fe0fa0f2800de4f4d4423 (diff) | |
Notes
| -rw-r--r-- | lib/libc/stdtime/strftime.c | 25 | ||||
| -rw-r--r-- | lib/libc/stdtime/strptime.c | 45 | 
2 files changed, 36 insertions, 34 deletions
diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c index 83bddc9a48c2..27b0170a0ad4 100644 --- a/lib/libc/stdtime/strftime.c +++ b/lib/libc/stdtime/strftime.c @@ -78,6 +78,7 @@ _fmt(format, t, pt, ptlim)  	const char *const ptlim;  {  	int Ealternative, Oalternative; +	struct lc_time_T *tptr = __get_current_time_locale();  	for ( ; *format; ++format) {  		if (*format == '%') { @@ -90,24 +91,24 @@ label:  				break;  			case 'A':  				pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? -					"?" : Locale->weekday[t->tm_wday], +					"?" : tptr->weekday[t->tm_wday],  					pt, ptlim);  				continue;  			case 'a':  				pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? -					"?" : Locale->wday[t->tm_wday], +					"?" : tptr->wday[t->tm_wday],  					pt, ptlim);  				continue;  			case 'B':  				pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ?  -					"?" : (Oalternative ? Locale->alt_month : -					Locale->month)[t->tm_mon], +					"?" : (Oalternative ? tptr->alt_month : +					tptr->month)[t->tm_mon],  					pt, ptlim);  				continue;  			case 'b':  			case 'h':  				pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? -					"?" : Locale->mon[t->tm_mon], +					"?" : tptr->mon[t->tm_mon],  					pt, ptlim);  				continue;  			case 'C': @@ -161,12 +162,12 @@ label:  			case 'f':  				if (!Ealternative)  					break; -				pt = _fmt(Locale->Ef_fmt, t, pt, ptlim); +				pt = _fmt(tptr->Ef_fmt, t, pt, ptlim);  				continue;  			case 'F':  				if (!Ealternative)  					break; -				pt = _fmt(Locale->EF_fmt, t, pt, ptlim); +				pt = _fmt(tptr->EF_fmt, t, pt, ptlim);  				continue;  			case 'H':  				pt = _conv(t->tm_hour, "%02d", pt, ptlim); @@ -225,8 +226,8 @@ label:  				continue;  			case 'p':  				pt = _add((t->tm_hour >= 12) ? -					Locale->pm : -					Locale->am, +					tptr->pm : +					tptr->am,  					pt, ptlim);  				continue;  			case 'R': @@ -378,10 +379,10 @@ label:  				pt = _conv(t->tm_wday, "%d", pt, ptlim);  				continue;  			case 'X': -				pt = _fmt(Locale->X_fmt, t, pt, ptlim); +				pt = _fmt(tptr->X_fmt, t, pt, ptlim);  				continue;  			case 'x': -				pt = _fmt(Locale->x_fmt, t, pt, ptlim); +				pt = _fmt(tptr->x_fmt, t, pt, ptlim);  				continue;  			case 'y':  				pt = _conv((t->tm_year + TM_YEAR_BASE) % 100, @@ -417,7 +418,7 @@ label:  				};  				continue;  			case '+': -				pt = _fmt(Locale->date_fmt, t, pt, ptlim); +				pt = _fmt(tptr->date_fmt, t, pt, ptlim);  				continue;  			case '%':  			/* diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c index 88d04ce8a5fd..7da0b9c8c018 100644 --- a/lib/libc/stdtime/strptime.c +++ b/lib/libc/stdtime/strptime.c @@ -88,6 +88,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm)  	int	i,  		len;  	int Ealternative, Oalternative; +	struct lc_time_T *tptr = __get_current_time_locale();  	ptr = fmt;  	while (*ptr != 0) { @@ -117,7 +118,7 @@ label:  			break;  		case '+': -			buf = _strptime(buf, Locale->date_fmt, tm); +			buf = _strptime(buf, tptr->date_fmt, tm);  			if (buf == 0)  				return 0;  			break; @@ -168,7 +169,7 @@ label:  		case 'f':  			if (!Ealternative)  				break; -			buf = _strptime(buf, (c == 'f') ? Locale->Ef_fmt : Locale->EF_fmt, tm); +			buf = _strptime(buf, (c == 'f') ? tptr->Ef_fmt : tptr->EF_fmt, tm);  			if (buf == 0)  				return 0;  			break; @@ -192,13 +193,13 @@ label:  			break;  		case 'X': -			buf = _strptime(buf, Locale->X_fmt, tm); +			buf = _strptime(buf, tptr->X_fmt, tm);  			if (buf == 0)  				return 0;  			break;  		case 'x': -			buf = _strptime(buf, Locale->x_fmt, tm); +			buf = _strptime(buf, tptr->x_fmt, tm);  			if (buf == 0)  				return 0;  			break; @@ -288,8 +289,8 @@ label:  			 * XXX This is bogus if parsed before hour-related  			 * specifiers.  			 */ -			len = strlen(Locale->am); -			if (strncasecmp(buf, Locale->am, len) == 0) { +			len = strlen(tptr->am); +			if (strncasecmp(buf, tptr->am, len) == 0) {  				if (tm->tm_hour > 12)  					return 0;  				if (tm->tm_hour == 12) @@ -298,8 +299,8 @@ label:  				break;  			} -			len = strlen(Locale->pm); -			if (strncasecmp(buf, Locale->pm, len) == 0) { +			len = strlen(tptr->pm); +			if (strncasecmp(buf, tptr->pm, len) == 0) {  				if (tm->tm_hour > 12)  					return 0;  				if (tm->tm_hour != 12) @@ -312,22 +313,22 @@ label:  		case 'A':  		case 'a': -			for (i = 0; i < asizeof(Locale->weekday); i++) { +			for (i = 0; i < asizeof(tptr->weekday); i++) {  				if (c == 'A') { -					len = strlen(Locale->weekday[i]); +					len = strlen(tptr->weekday[i]);  					if (strncasecmp(buf, -							Locale->weekday[i], +							tptr->weekday[i],  							len) == 0)  						break;  				} else { -					len = strlen(Locale->wday[i]); +					len = strlen(tptr->wday[i]);  					if (strncasecmp(buf, -							Locale->wday[i], +							tptr->wday[i],  							len) == 0)  						break;  				}  			} -			if (i == asizeof(Locale->weekday)) +			if (i == asizeof(tptr->weekday))  				return 0;  			tm->tm_wday = i; @@ -406,32 +407,32 @@ label:  		case 'B':  		case 'b':  		case 'h': -			for (i = 0; i < asizeof(Locale->month); i++) { +			for (i = 0; i < asizeof(tptr->month); i++) {  				if (Oalternative) {  					if (c == 'B') { -						len = strlen(Locale->alt_month[i]); +						len = strlen(tptr->alt_month[i]);  						if (strncasecmp(buf, -								Locale->alt_month[i], +								tptr->alt_month[i],  								len) == 0)  							break;  					}  				} else {  					if (c == 'B') { -						len = strlen(Locale->month[i]); +						len = strlen(tptr->month[i]);  						if (strncasecmp(buf, -								Locale->month[i], +								tptr->month[i],  								len) == 0)  							break;  					} else { -						len = strlen(Locale->mon[i]); +						len = strlen(tptr->mon[i]);  						if (strncasecmp(buf, -								Locale->mon[i], +								tptr->mon[i],  								len) == 0)  							break;  					}  				}  			} -			if (i == asizeof(Locale->month)) +			if (i == asizeof(tptr->month))  				return 0;  			tm->tm_mon = i;  | 
