get_default_paper_size: Use access instead of fn_exists
[pspp] / src / output / measure.c
index 35e5fb3f451814cad4197bda4529b55a34055dc0..c352de66d22be708bc0febefe202b7dc5431eec3 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "output/measure.h"
 
+#include <unistd.h>
 #include <gl/c-strtod.h>
 #include <ctype.h>
 #include <errno.h>
@@ -27,7 +28,6 @@
 #include <stdint.h>
 #include <stdlib.h>
 
-#include "data/file-name.h"
 #include "libpspp/str.h"
 
 #include "gl/c-strcase.h"
@@ -297,15 +297,18 @@ 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
 
   /* libpaper defaults to /etc/papersize. */
-  if (fn_exists ("/etc/papersize"))
+  if (0 == access ("/etc/papersize", R_OK))
     return read_paper_conf ("/etc/papersize", h, v);
 
   /* Can't find a default. */