emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 713eece: Support (locale-info 'paper) on GNU platfo


From: Paul Eggert
Subject: [Emacs-diffs] master 713eece: Support (locale-info 'paper) on GNU platforms
Date: Sat, 2 Feb 2019 16:25:04 -0500 (EST)

branch: master
commit 713eece307bf48717b868f21789eed8160ada5ba
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Support (locale-info 'paper) on GNU platforms
    
    * configure.ac (HAVE_LANGINFO__NL_PAPER_WIDTH): New macro.
    * src/fns.c (Flocale_info) [HAVE_LANGINFO__NL_PAPER_WIDTH]:
    Get paper width and height from locale.
---
 configure.ac                    | 26 +++++++++++++++++++-------
 etc/NEWS                        |  3 +++
 lisp/international/mule-cmds.el |  1 -
 src/fns.c                       | 23 +++++++++++------------
 4 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0259c82..5857900 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4492,15 +4492,27 @@ fi
 AC_SUBST(XGSELOBJ)
 
 dnl Adapted from Haible's version.
-AC_CACHE_CHECK([for nl_langinfo and CODESET], emacs_cv_langinfo_codeset,
+AC_CACHE_CHECK([for nl_langinfo and CODESET], [emacs_cv_langinfo_codeset],
   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
-    [[char* cs = nl_langinfo(CODESET);]])],
-    emacs_cv_langinfo_codeset=yes,
-    emacs_cv_langinfo_codeset=no)
+    [[char *cs = nl_langinfo(CODESET);]])],
+    [emacs_cv_langinfo_codeset=yes],
+    [emacs_cv_langinfo_codeset=no])
   ])
-if test $emacs_cv_langinfo_codeset = yes; then
-  AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
-    [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+if test "$emacs_cv_langinfo_codeset" = yes; then
+  AC_DEFINE([HAVE_LANGINFO_CODESET], 1,
+    [Define if you have <langinfo.h> and nl_langinfo (CODESET).])
+
+  AC_CACHE_CHECK([for nl_langinfo and _NL_PAPER_WIDTH],
+    [emacs_cv_langinfo__nl_paper_width],
+    [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
+      [[char *cs = nl_langinfo (_NL_PAPER_WIDTH);]])],
+      [emacs_cv_langinfo__nl_paper_width=yes],
+      [emacs_cv_langinfo__nl_paper_width=no])
+    ])
+  if test "$emacs_cv_langinfo__nl_paper_width" = yes; then
+    AC_DEFINE([HAVE_LANGINFO__NL_PAPER_WIDTH], 1,
+      [Define if you have <langinfo.h> and nl_langinfo (_NL_PAPER_WIDTH).])
+  fi
 fi
 
 AC_TYPE_MBSTATE_T
diff --git a/etc/NEWS b/etc/NEWS
index 2bbc387..cac379f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1527,6 +1527,9 @@ systems, the XRender extension to X11 is required for 
this to be
 available; the configure script will test for it and, if found, enable
 scaling.)
 
++++
+** (locale-info 'paper) now returns the paper size on GNUish hosts.
+
 The new function 'image-scaling-p' can be used to test whether any
 given frame supports resizing.
 
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index f91b3ea..fdcd606 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -2727,7 +2727,6 @@ See also `locale-charset-language-names', 
`locale-language-names',
       (let ((paper (locale-info 'paper))
             locale)
        (if paper
-           ;; This will always be null at the time of writing.
            (cond
             ((equal paper '(216 279))
              (setq ps-paper-type 'letter))
diff --git a/src/fns.c b/src/fns.c
index 3452114..a7279b1 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3118,8 +3118,8 @@ The data read from the system are decoded using 
`locale-coding-system'.  */)
       str = nl_langinfo (CODESET);
       return build_string (str);
     }
-#ifdef DAY_1
-  else if (EQ (item, Qdays))   /* e.g. for calendar-day-name-array */
+# ifdef DAY_1
+  if (EQ (item, Qdays))  /* E.g., for calendar-day-name-array.  */
     {
       Lisp_Object v = make_nil_vector (7);
       const int days[7] = {DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7};
@@ -3136,9 +3136,9 @@ The data read from the system are decoded using 
`locale-coding-system'.  */)
        }
       return v;
     }
-#endif /* DAY_1 */
-#ifdef MON_1
-  else if (EQ (item, Qmonths)) /* e.g. for calendar-month-name-array */
+# endif
+# ifdef MON_1
+  if (EQ (item, Qmonths))  /* E.g., for calendar-month-name-array.  */
     {
       Lisp_Object v = make_nil_vector (12);
       const int months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7,
@@ -3153,13 +3153,12 @@ The data read from the system are decoded using 
`locale-coding-system'.  */)
        }
       return v;
     }
-#endif /* MON_1 */
-/* LC_PAPER stuff isn't defined as accessible in glibc as of 2.3.1,
-   but is in the locale files.  This could be used by ps-print.  */
-#ifdef PAPER_WIDTH
-  else if (EQ (item, Qpaper))
-    return list2i (nl_langinfo (PAPER_WIDTH), nl_langinfo (PAPER_HEIGHT));
-#endif /* PAPER_WIDTH */
+# endif
+# ifdef HAVE_LANGINFO__NL_PAPER_WIDTH
+  if (EQ (item, Qpaper))
+    return list2i ((intptr_t) nl_langinfo (_NL_PAPER_WIDTH),
+                  (intptr_t) nl_langinfo (_NL_PAPER_HEIGHT));
+# endif
 #endif /* HAVE_LANGINFO_CODESET*/
   return Qnil;
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]