From: Karel Zak Date: Tue, 10 Mar 2009 12:36:56 +0000 (+0100) Subject: cal: remove gcc-ism from nl_langinfo() call X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcb54fafb128ab41772ae217afc6a7612e2cc446;p=util-linux cal: remove gcc-ism from nl_langinfo() call > On Tue, Mar 10, 2009 at 01:15:14PM +0100, Samuel Thibault wrote: > That will only work with the gcc compiler, which allows to read a > union field what you wrote in another. Shouldn't > (int)(intptr_t)nl_langinfo() be just fine? Signed-off-by: Karel Zak --- diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 753cc24c..2417f1b5 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -310,11 +310,7 @@ main(int argc, char **argv) { POSIX: 19971201 + 7 -1 = 0 */ { - int wfd; - union { unsigned int word; char *string; } val; - val.string = nl_langinfo(_NL_TIME_WEEK_1STDAY); - - wfd = val.word; + int wfd = (int)(intptr_t) nl_langinfo(_NL_TIME_WEEK_1STDAY); wfd = day_in_week(wfd % 100, (wfd / 100) % 100, wfd / (100 * 100)); weekstart = (wfd + *nl_langinfo(_NL_TIME_FIRST_WEEKDAY) - 1) % 7; }