aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2023-10-07 03:48:00 -0400
committerEli Zaretskii2023-10-07 03:48:00 -0400
commit5384619921783bc6d411ea88976ea55b1198ed91 (patch)
tree00771c6c29945109eb722063e8dfb6823bff542c /src
parent2132d8d8dd61424af33f5b7d7543d8d30120aec3 (diff)
parenta74e51cfd1518507220de2ba317bb862409541cf (diff)
downloademacs-5384619921783bc6d411ea88976ea55b1198ed91.tar.gz
emacs-5384619921783bc6d411ea88976ea55b1198ed91.zip
Merge from origin/emacs-29
a74e51cfd15 Fix a defcustom :type c27b90d04bf Fix 'ido--ffap-find-file' 1594d5f17ad Fix setting the pipe capacity for subprocesses aad8b5d78f3 Handle LANG on macOS differently (bug#65908) # Conflicts: # src/process.c
Diffstat (limited to 'src')
-rw-r--r--src/nsterm.m39
-rw-r--r--src/process.c13
2 files changed, 30 insertions, 22 deletions
diff --git a/src/nsterm.m b/src/nsterm.m
index efa6ab39a0c..11535f071eb 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -554,29 +554,32 @@ ns_init_locale (void)
554/* macOS doesn't set any environment variables for the locale when run 554/* macOS doesn't set any environment variables for the locale when run
555 from the GUI. Get the locale from the OS and set LANG. */ 555 from the GUI. Get the locale from the OS and set LANG. */
556{ 556{
557 NSLocale *locale = [NSLocale currentLocale];
558
559 NSTRACE ("ns_init_locale"); 557 NSTRACE ("ns_init_locale");
560 558
561 /* If we were run from a terminal then assume an unset LANG variable 559 /* Either use LANG, if set, or try to construct LANG from
562 is intentional and don't try to "fix" it. */ 560 NSLocale. */
563 if (!isatty (STDIN_FILENO)) 561 const char *lang = getenv ("LANG");
562 if (lang == NULL || *lang == 0)
564 { 563 {
565 char *oldLocale = setlocale (LC_ALL, NULL); 564 const NSLocale *locale = [NSLocale currentLocale];
566 /* It seems macOS should probably use UTF-8 everywhere. 565 const NSString *localeID = [NSString stringWithFormat:@"%@.UTF-8",
567 'localeIdentifier' does not specify the encoding, and I can't 566 [locale localeIdentifier]];
568 find any way to get the OS to tell us which encoding to use, 567 lang = [localeID UTF8String];
569 so hard-code '.UTF-8'. */ 568 }
570 NSString *localeID = [NSString stringWithFormat:@"%@.UTF-8",
571 [locale localeIdentifier]];
572
573 /* Check the locale ID is valid and if so set LANG, but not if
574 it is already set. */
575 if (setlocale (LC_ALL, [localeID UTF8String]))
576 setenv("LANG", [localeID UTF8String], 0);
577 569
578 setlocale (LC_ALL, oldLocale); 570 /* Check if LANG can be used for initializing the locale. If not,
571 use a default setting. Note that Emacs' main will undo the
572 setlocale below, initializing the locale from the
573 environment. */
574 if (setlocale (LC_ALL, lang) == NULL)
575 {
576 const char *const default_lang = "en_US.UTF-8";
577 fprintf (stderr, "LANG=%s cannot be used, using %s instead.\n",
578 lang, default_lang);
579 lang = default_lang;
579 } 580 }
581
582 setenv ("LANG", lang, 1);
580} 583}
581 584
582 585
diff --git a/src/process.c b/src/process.c
index 2376d0f288d..e885f771139 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2206,10 +2206,15 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2206 inchannel = p->open_fd[READ_FROM_SUBPROCESS]; 2206 inchannel = p->open_fd[READ_FROM_SUBPROCESS];
2207 forkout = p->open_fd[SUBPROCESS_STDOUT]; 2207 forkout = p->open_fd[SUBPROCESS_STDOUT];
2208 2208
2209#if (defined (GNU_LINUX) || defined __ANDROID__) \ 2209#if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ)
2210 && defined (F_SETPIPE_SZ) 2210 /* If they requested larger reads than the default system pipe
2211 fcntl (inchannel, F_SETPIPE_SZ, read_process_output_max); 2211 capacity, try enlarging the capacity to match the request. */
2212#endif /* (GNU_LINUX || __ANDROID__) && F_SETPIPE_SZ */ 2212 if (read_process_output_max > fcntl (inchannel, F_GETPIPE_SZ))
2213 {
2214 int readmax = clip_to_bounds (1, read_process_output_max, INT_MAX);
2215 fcntl (inchannel, F_SETPIPE_SZ, readmax);
2216 }
2217#endif
2213 } 2218 }
2214 2219
2215 if (!NILP (p->stderrproc)) 2220 if (!NILP (p->stderrproc))