aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fns.c5
-rw-r--r--src/w32proc.c38
2 files changed, 39 insertions, 4 deletions
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