From e10fd700c325a0474f970ca293ad9d6508259922 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Michel=20Vourg=C3=A8re?= Date: Fri, 14 Aug 2015 00:16:25 +0200 Subject: [PATCH] Support 390x format of nl_langinfo(FIRST_WEEKDAY) nl_langinfo returns non-portable format for FIRST_WEEKDAY. See https://www.gnu.org/software/libc/manual/html_node/The-Elegant-and-Fast-Way.html#The-Elegant-and-Fast-Way That patch add support for the format used on 390x architecture. This permits the unit tests to work there. --- configure.ac | 2 ++ src/rrd_graph.c | 14 ++++++++++++-- src/rrd_rpncalc.c | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 5270b229..641dedbc 100644 --- a/configure.ac +++ b/configure.ac @@ -526,6 +526,8 @@ AC_LANG_POP(C) dnl is time_t 32 of 64 bit ? AC_CHECK_SIZEOF([time_t]) +AC_CHECK_SIZEOF([long int]) + CONFIGURE_PART(Find 3rd-Party Libraries) have_libdbi=no diff --git a/src/rrd_graph.c b/src/rrd_graph.c index ff21f321..d6ff8063 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -1500,8 +1500,18 @@ static int find_first_weekday(void){ first_weekday = nl_langinfo (_NL_TIME_FIRST_WEEKDAY)[0]; int week_1stday; long week_1stday_l = (long) nl_langinfo (_NL_TIME_WEEK_1STDAY); - if (week_1stday_l == 19971130) week_1stday = 0; /* Sun */ - else if (week_1stday_l == 19971201) week_1stday = 1; /* Mon */ + if (week_1stday_l == 19971130 +#if SIZEOF_LONG_INT > 4 + || week_1stday_l >> 32 == 19971130 +#endif + ) + week_1stday = 0; /* Sun */ + else if (week_1stday_l == 19971201 +#if SIZEOF_LONG_INT > 4 + || week_1stday_l >> 32 == 19971201 +#endif + ) + week_1stday = 1; /* Mon */ else { first_weekday = 1; diff --git a/src/rrd_rpncalc.c b/src/rrd_rpncalc.c index e57618ec..ad951bfb 100644 --- a/src/rrd_rpncalc.c +++ b/src/rrd_rpncalc.c @@ -512,8 +512,18 @@ static int find_first_weekday(void){ first_weekday = nl_langinfo (_NL_TIME_FIRST_WEEKDAY)[0]; int week_1stday; long week_1stday_l = (long) nl_langinfo (_NL_TIME_WEEK_1STDAY); - if (week_1stday_l == 19971130) week_1stday = 0; /* Sun */ - else if (week_1stday_l == 19971201) week_1stday = 1; /* Mon */ + if (week_1stday_l == 19971130 +#if SIZEOF_LONG_INT > 4 + || week_1stday_l >> 32 == 19971130 +#endif + ) + week_1stday = 0; /* Sun */ + else if (week_1stday_l == 19971201 +#if SIZEOF_LONG_INT > 4 + || week_1stday_l >> 32 == 19971201 +#endif + ) + week_1stday = 1; /* Mon */ else { first_weekday = 1; -- 2.47.2