]> err.no Git - util-linux/commitdiff
cal: remove gcc-ism from nl_langinfo() call
authorKarel Zak <kzak@redhat.com>
Tue, 10 Mar 2009 12:36:56 +0000 (13:36 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 10 Mar 2009 12:36:56 +0000 (13:36 +0100)
> 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 <kzak@redhat.com>
misc-utils/cal.c

index 753cc24c4495310279a2cb29135d66ab72d36491..2417f1b5a999f0546d16a46dc1e85d937bafb671 100644 (file)
@@ -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;
        }