From 5520a0b23027ab60ed0b52a7d3841101b1ae68f3 Mon Sep 17 00:00:00 2001 From: Friedrich Beckmann Date: Wed, 24 Jun 2015 23:50:52 +0200 Subject: [PATCH] fix s390x build failure on debian due to wrong type casting The problem showed up on s390x for the 0.8.5 debian version where four graph tests using pdf export failed with the same assertion. The problem is due to wrong casting. intptr_t is long int (64 Bit) on s390x but nl_langinfo returns 0xd200000000 on s390x where 0 is the integer result. This results in wrong but positive height and width values for the paper size. --- src/output/measure.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/output/measure.c b/src/output/measure.c index 35e5fb3f45..3589585501 100644 --- a/src/output/measure.c +++ b/src/output/measure.c @@ -297,9 +297,12 @@ get_default_paper_size (int *h, int *v) return read_paper_conf (getenv ("PAPERCONF"), h, v); #if HAVE_LC_PAPER - /* LC_PAPER is a non-standard glibc extension. */ - *h = (intptr_t) nl_langinfo(_NL_PAPER_WIDTH) * (72000 / 25.4); - *v = (intptr_t) nl_langinfo(_NL_PAPER_HEIGHT) * (72000 / 25.4); + /* LC_PAPER is a non-standard glibc extension. + The (int)(intptr_t) cast is for 64 Bit Systems where intptr_t + translates to 64 Bit long int but the upper 32 Bits have wrong + values. The result from nl_langinfo is integer (32 Bit) */ + *h = (int)(intptr_t) nl_langinfo(_NL_PAPER_WIDTH) * (72000 / 25.4); + *v = (int)(intptr_t) nl_langinfo(_NL_PAPER_HEIGHT) * (72000 / 25.4); if (*h > 0 && *v > 0) return true; #endif -- 2.30.2