This reverts commit
dcb54fafb128ab41772ae217afc6a7612e2cc446,
"cal: remove gcc-ism from nl_langinfo() call".
The code:
int wfd = (int)(intptr_t) nl_langinfo(_NL_TIME_WEEK_1STDAY);
does not work on big-endian machines. The original solution based on
union is better.
Note that the "type punning" is not gcc-ism any more, it's allowed
by C99 (6.5.2.3).
Reported-by: Joseph Jezak <josejx@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
POSIX: 19971201 + 7 -1 = 0
*/
{
- int wfd = (int)(intptr_t) nl_langinfo(_NL_TIME_WEEK_1STDAY);
+ int wfd;
+ union { unsigned int word; char *string; } val;
+ val.string = nl_langinfo(_NL_TIME_WEEK_1STDAY);
+
+ wfd = val.word;
wfd = day_in_week(wfd % 100, (wfd / 100) % 100, wfd / (100 * 100));
weekstart = (wfd + *nl_langinfo(_NL_TIME_FIRST_WEEKDAY) - 1) % 7;
}