aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2019-02-04 18:05:59 +0200
committerEli Zaretskii2019-02-04 18:05:59 +0200
commitf37000aeb2b987c0fb14b6770fef69eaf274167a (patch)
treeaf50afbb4fd52389a11ae8259d2f18ccd081ce61
parentd5f629d193ffe88c464379f02dd2adaadc9dfdf0 (diff)
downloademacs-f37000aeb2b987c0fb14b6770fef69eaf274167a.tar.gz
emacs-f37000aeb2b987c0fb14b6770fef69eaf274167a.zip
Support (locale-info 'paper) on MS-Windows
* src/w32proc.c (LOCALE_IPAPERSIZE): Define if undefined. (nl_langinfo): Support _NL_PAPER_WIDTH and _NL_PAPER_HEIGHT like glibc does. * src/fns.c (Flocale_info): Update the doc string. * nt/inc/langinfo.h: Add _NL_PAPER_WIDTH and _NL_PAPER_HEIGHT to the enumeration. (_NL_PAPER_WIDTH, _NL_PAPER_HEIGHT): Define namesake macros. * nt/mingw-cfg.site (emacs_cv_langinfo__nl_paper_width): Set to 'yes'. * doc/lispref/nonascii.texi (Locales): Update the documentation of 'locale-info' for the argument of 'paper'. * etc/NEWS: Update the locale-info entry.
-rw-r--r--doc/lispref/nonascii.texi6
-rw-r--r--etc/NEWS8
-rw-r--r--nt/inc/langinfo.h4
-rw-r--r--nt/mingw-cfg.site1
-rw-r--r--src/fns.c5
-rw-r--r--src/w32proc.c38
6 files changed, 52 insertions, 10 deletions
diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi
index 56d96cff328..ae9a8ab6323 100644
--- a/doc/lispref/nonascii.texi
+++ b/doc/lispref/nonascii.texi
@@ -2115,9 +2115,9 @@ Return a 12-element vector of month names (locale items @code{MON_1}
2115through @code{MON_12}). 2115through @code{MON_12}).
2116 2116
2117@item paper 2117@item paper
2118Return a list @code{(@var{width} @var{height})} for the default paper 2118Return a list @w{@code{(@var{width} @var{height})}} of 2 integers, for
2119size measured in millimeters (locale items @code{PAPER_WIDTH} and 2119the default paper size measured in millimeters (locale items
2120@code{PAPER_HEIGHT}). 2120@code{_NL_PAPER_WIDTH} and @code{_NL_PAPER_HEIGHT}).
2121@end table 2121@end table
2122 2122
2123If the system can't provide the requested information, or if 2123If the system can't provide the requested information, or if
diff --git a/etc/NEWS b/etc/NEWS
index bbfc3285ee6..a9c009e9d21 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1533,12 +1533,14 @@ systems, the XRender extension to X11 is required for this to be
1533available; the configure script will test for it and, if found, enable 1533available; the configure script will test for it and, if found, enable
1534scaling.) 1534scaling.)
1535 1535
1536+++
1537** (locale-info 'paper) now returns the paper size on GNUish hosts.
1538
1539The new function 'image-scaling-p' can be used to test whether any 1536The new function 'image-scaling-p' can be used to test whether any
1540given frame supports resizing. 1537given frame supports resizing.
1541 1538
1539+++
1540** (locale-info 'paper) now returns the paper size on systems that support it.
1541This is currently supported on GNUish hosts and on modern versions of
1542MS-Windows.
1543
1542 1544
1543* Changes in Emacs 27.1 on Non-Free Operating Systems 1545* Changes in Emacs 27.1 on Non-Free Operating Systems
1544 1546
diff --git a/nt/inc/langinfo.h b/nt/inc/langinfo.h
index fc69068969e..6c4959ecb54 100644
--- a/nt/inc/langinfo.h
+++ b/nt/inc/langinfo.h
@@ -27,6 +27,7 @@ enum {
27 DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7, 27 DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7,
28 MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7, MON_8, MON_9, MON_10, 28 MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7, MON_8, MON_9, MON_10,
29 MON_11, MON_12, 29 MON_11, MON_12,
30 _NL_PAPER_WIDTH, _NL_PAPER_HEIGHT,
30 31
31 /* Number of enumerated values. */ 32 /* Number of enumerated values. */
32 _NL_NUM 33 _NL_NUM
@@ -55,6 +56,9 @@ enum {
55#define MON_11 MON_11 56#define MON_11 MON_11
56#define MON_12 MON_12 57#define MON_12 MON_12
57 58
59#define _NL_PAPER_WIDTH _NL_PAPER_WIDTH
60#define _NL_PAPER_HEIGHT _NL_PAPER_HEIGHT
61
58extern char *nl_langinfo (nl_item); 62extern char *nl_langinfo (nl_item);
59 63
60#endif /* _LANGINFO_H */ 64#endif /* _LANGINFO_H */
diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site
index d9a824008cb..4df20494921 100644
--- a/nt/mingw-cfg.site
+++ b/nt/mingw-cfg.site
@@ -109,6 +109,7 @@ gl_cv_func_pthread_sigmask_return_works=yes
109gl_cv_func_pthread_sigmask_unblock_works="not relevant" 109gl_cv_func_pthread_sigmask_unblock_works="not relevant"
110# Implemented in w32proc.c 110# Implemented in w32proc.c
111emacs_cv_langinfo_codeset=yes 111emacs_cv_langinfo_codeset=yes
112emacs_cv_langinfo__nl_paper_width=yes
112# Declared in ms-w32.h 113# Declared in ms-w32.h
113ac_cv_have_decl_alarm=yes 114ac_cv_have_decl_alarm=yes
114# Avoid including the gnulib dup2 module 115# Avoid including the gnulib dup2 module
diff --git a/src/fns.c b/src/fns.c
index a7279b13552..95bafae6c4c 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3100,8 +3100,9 @@ ITEM should be one of the following:
3100 3100
3101`months', returning a 12-element vector of month names (locale items MON_n); 3101`months', returning a 12-element vector of month names (locale items MON_n);
3102 3102
3103`paper', returning a list (WIDTH HEIGHT) for the default paper size, 3103`paper', returning a list of 2 integers (WIDTH HEIGHT) for the default
3104 both measured in millimeters (locale items PAPER_WIDTH, PAPER_HEIGHT). 3104 paper size, both measured in millimeters (locale items _NL_PAPER_WIDTH,
3105 _NL_PAPER_HEIGHT).
3105 3106
3106If the system can't provide such information through a call to 3107If the system can't provide such information through a call to
3107`nl_langinfo', or if ITEM isn't from the list above, return nil. 3108`nl_langinfo', or if ITEM isn't from the list above, return nil.
diff --git a/src/w32proc.c b/src/w32proc.c
index 05e6c46b336..ab0bf0fff08 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -3248,6 +3248,12 @@ such programs cannot be invoked by Emacs anyway. */)
3248} 3248}
3249 3249
3250#ifdef HAVE_LANGINFO_CODESET 3250#ifdef HAVE_LANGINFO_CODESET
3251
3252/* If we are compiling for compatibility with older 32-bit Windows
3253 versions, this might not be defined by the Windows headers. */
3254#ifndef LOCALE_IPAPERSIZE
3255# define LOCALE_IPAPERSIZE 0x100A
3256#endif
3251/* Emulation of nl_langinfo. Used in fns.c:Flocale_info. */ 3257/* Emulation of nl_langinfo. Used in fns.c:Flocale_info. */
3252char * 3258char *
3253nl_langinfo (nl_item item) 3259nl_langinfo (nl_item item)
@@ -3260,7 +3266,8 @@ nl_langinfo (nl_item item)
3260 LOCALE_SMONTHNAME1, LOCALE_SMONTHNAME2, LOCALE_SMONTHNAME3, 3266 LOCALE_SMONTHNAME1, LOCALE_SMONTHNAME2, LOCALE_SMONTHNAME3,
3261 LOCALE_SMONTHNAME4, LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6, 3267 LOCALE_SMONTHNAME4, LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6,
3262 LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8, LOCALE_SMONTHNAME9, 3268 LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8, LOCALE_SMONTHNAME9,
3263 LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12 3269 LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12,
3270 LOCALE_IPAPERSIZE, LOCALE_IPAPERSIZE
3264 }; 3271 };
3265 3272
3266 static char *nl_langinfo_buf = NULL; 3273 static char *nl_langinfo_buf = NULL;
@@ -3269,6 +3276,8 @@ nl_langinfo (nl_item item)
3269 if (nl_langinfo_len <= 0) 3276 if (nl_langinfo_len <= 0)
3270 nl_langinfo_buf = xmalloc (nl_langinfo_len = 1); 3277 nl_langinfo_buf = xmalloc (nl_langinfo_len = 1);
3271 3278
3279 char *retval = nl_langinfo_buf;
3280
3272 if (item < 0 || item >= _NL_NUM) 3281 if (item < 0 || item >= _NL_NUM)
3273 nl_langinfo_buf[0] = 0; 3282 nl_langinfo_buf[0] = 0;
3274 else 3283 else
@@ -3290,6 +3299,8 @@ nl_langinfo (nl_item item)
3290 if (nl_langinfo_len <= need_len) 3299 if (nl_langinfo_len <= need_len)
3291 nl_langinfo_buf = xrealloc (nl_langinfo_buf, 3300 nl_langinfo_buf = xrealloc (nl_langinfo_buf,
3292 nl_langinfo_len = need_len); 3301 nl_langinfo_len = need_len);
3302 retval = nl_langinfo_buf;
3303
3293 if (!GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP, 3304 if (!GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP,
3294 nl_langinfo_buf, nl_langinfo_len)) 3305 nl_langinfo_buf, nl_langinfo_len))
3295 nl_langinfo_buf[0] = 0; 3306 nl_langinfo_buf[0] = 0;
@@ -3306,9 +3317,32 @@ nl_langinfo (nl_item item)
3306 nl_langinfo_buf[1] = 'p'; 3317 nl_langinfo_buf[1] = 'p';
3307 } 3318 }
3308 } 3319 }
3320 else if (item == _NL_PAPER_WIDTH || item == _NL_PAPER_HEIGHT)
3321 {
3322 static const int paper_size[][2] =
3323 {
3324 { -1, -1 },
3325 { 216, 279 },
3326 { -1, -1 },
3327 { -1, -1 },
3328 { -1, -1 },
3329 { 216, 356 },
3330 { -1, -1 },
3331 { -1, -1 },
3332 { 297, 420 },
3333 { 210, 297 }
3334 };
3335 int idx = atoi (nl_langinfo_buf);
3336 if (0 <= idx && idx < ARRAYELTS (paper_size))
3337 retval = (char *)(intptr_t) (item == _NL_PAPER_WIDTH
3338 ? paper_size[idx][0]
3339 : paper_size[idx][1]);
3340 else
3341 retval = (char *)(intptr_t) -1;
3342 }
3309 } 3343 }
3310 } 3344 }
3311 return nl_langinfo_buf; 3345 return retval;
3312} 3346}
3313#endif /* HAVE_LANGINFO_CODESET */ 3347#endif /* HAVE_LANGINFO_CODESET */
3314 3348