aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrea Corallo2020-12-23 19:49:58 +0100
committerAndrea Corallo2020-12-23 19:49:58 +0100
commitb99a4744822a11e4af098b63db18f54a4e323d58 (patch)
treea3836dfbd6bf4ebfc5b61c566d146cfd65984f62 /src
parentffcd490cb49ba86d625288ea425d98e8cac22a05 (diff)
parent40bc77d9a6b8d824690fb6ee3003d74951bb3ae5 (diff)
downloademacs-b99a4744822a11e4af098b63db18f54a4e323d58.tar.gz
emacs-b99a4744822a11e4af098b63db18f54a4e323d58.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c2
-rw-r--r--src/callproc.c246
-rw-r--r--src/coding.c18
-rw-r--r--src/fileio.c2
-rw-r--r--src/image.c2
-rw-r--r--src/lisp.h4
-rw-r--r--src/nsfns.m8
-rw-r--r--src/nsfont.m7
-rw-r--r--src/nsimage.m4
-rw-r--r--src/nsmenu.m2
-rw-r--r--src/nsselect.m10
-rw-r--r--src/nsterm.m10
-rw-r--r--src/nsxwidget.m19
-rw-r--r--src/pdumper.c2
-rw-r--r--src/process.c14
-rw-r--r--src/xterm.c9
16 files changed, 189 insertions, 170 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 22f37b0cedd..25153621298 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -664,7 +664,7 @@ display_malloc_warning (void)
664 call3 (intern ("display-warning"), 664 call3 (intern ("display-warning"),
665 intern ("alloc"), 665 intern ("alloc"),
666 build_string (pending_malloc_warning), 666 build_string (pending_malloc_warning),
667 intern ("emergency")); 667 intern (":emergency"));
668 pending_malloc_warning = 0; 668 pending_malloc_warning = 0;
669} 669}
670 670
diff --git a/src/callproc.c b/src/callproc.c
index 4bca1e5ebd3..c7f560ac3da 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -541,8 +541,11 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
541 callproc_fd[CALLPROC_STDERR] = fd_error; 541 callproc_fd[CALLPROC_STDERR] = fd_error;
542 } 542 }
543 543
544 char *const *env = make_environment_block (current_dir);
545
544#ifdef MSDOS /* MW, July 1993 */ 546#ifdef MSDOS /* MW, July 1993 */
545 status = child_setup (filefd, fd_output, fd_error, new_argv, 0, current_dir); 547 status = child_setup (filefd, fd_output, fd_error, new_argv, env,
548 SSDATA (current_dir));
546 549
547 if (status < 0) 550 if (status < 0)
548 { 551 {
@@ -589,7 +592,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
589 block_child_signal (&oldset); 592 block_child_signal (&oldset);
590 593
591#ifdef WINDOWSNT 594#ifdef WINDOWSNT
592 pid = child_setup (filefd, fd_output, fd_error, new_argv, 0, current_dir); 595 pid = child_setup (filefd, fd_output, fd_error, new_argv, env,
596 SSDATA (current_dir));
593#else /* not WINDOWSNT */ 597#else /* not WINDOWSNT */
594 598
595 /* vfork, and prevent local vars from being clobbered by the vfork. */ 599 /* vfork, and prevent local vars from being clobbered by the vfork. */
@@ -604,6 +608,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
604 ptrdiff_t volatile sa_avail_volatile = sa_avail; 608 ptrdiff_t volatile sa_avail_volatile = sa_avail;
605 ptrdiff_t volatile sa_count_volatile = sa_count; 609 ptrdiff_t volatile sa_count_volatile = sa_count;
606 char **volatile new_argv_volatile = new_argv; 610 char **volatile new_argv_volatile = new_argv;
611 char *const *volatile env_volatile = env;
607 int volatile callproc_fd_volatile[CALLPROC_FDS]; 612 int volatile callproc_fd_volatile[CALLPROC_FDS];
608 for (i = 0; i < CALLPROC_FDS; i++) 613 for (i = 0; i < CALLPROC_FDS; i++)
609 callproc_fd_volatile[i] = callproc_fd[i]; 614 callproc_fd_volatile[i] = callproc_fd[i];
@@ -620,6 +625,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
620 sa_avail = sa_avail_volatile; 625 sa_avail = sa_avail_volatile;
621 sa_count = sa_count_volatile; 626 sa_count = sa_count_volatile;
622 new_argv = new_argv_volatile; 627 new_argv = new_argv_volatile;
628 env = env_volatile;
623 629
624 for (i = 0; i < CALLPROC_FDS; i++) 630 for (i = 0; i < CALLPROC_FDS; i++)
625 callproc_fd[i] = callproc_fd_volatile[i]; 631 callproc_fd[i] = callproc_fd_volatile[i];
@@ -646,7 +652,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
646 signal (SIGPROF, SIG_DFL); 652 signal (SIGPROF, SIG_DFL);
647#endif 653#endif
648 654
649 child_setup (filefd, fd_output, fd_error, new_argv, 0, current_dir); 655 child_setup (filefd, fd_output, fd_error, new_argv, env,
656 SSDATA (current_dir));
650 } 657 }
651 658
652#endif /* not WINDOWSNT */ 659#endif /* not WINDOWSNT */
@@ -1205,8 +1212,6 @@ exec_failed (char const *name, int err)
1205 Initialize inferior's priority, pgrp, connected dir and environment. 1212 Initialize inferior's priority, pgrp, connected dir and environment.
1206 then exec another program based on new_argv. 1213 then exec another program based on new_argv.
1207 1214
1208 If SET_PGRP, put the subprocess into a separate process group.
1209
1210 CURRENT_DIR is an elisp string giving the path of the current 1215 CURRENT_DIR is an elisp string giving the path of the current
1211 directory the subprocess should have. Since we can't really signal 1216 directory the subprocess should have. Since we can't really signal
1212 a decent error from within the child, this should be verified as an 1217 a decent error from within the child, this should be verified as an
@@ -1217,11 +1222,9 @@ exec_failed (char const *name, int err)
1217 On MS-DOS, either return an exit status or signal an error. */ 1222 On MS-DOS, either return an exit status or signal an error. */
1218 1223
1219CHILD_SETUP_TYPE 1224CHILD_SETUP_TYPE
1220child_setup (int in, int out, int err, char **new_argv, bool set_pgrp, 1225child_setup (int in, int out, int err, char *const *new_argv,
1221 Lisp_Object current_dir) 1226 char *const *env, const char *current_dir)
1222{ 1227{
1223 char **env;
1224 char *pwd_var;
1225#ifdef WINDOWSNT 1228#ifdef WINDOWSNT
1226 int cpid; 1229 int cpid;
1227 HANDLE handles[3]; 1230 HANDLE handles[3];
@@ -1235,24 +1238,6 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1235 src/alloca.c) it is safe because that changes the superior's 1238 src/alloca.c) it is safe because that changes the superior's
1236 static variables as if the superior had done alloca and will be 1239 static variables as if the superior had done alloca and will be
1237 cleaned up in the usual way. */ 1240 cleaned up in the usual way. */
1238 {
1239 char *temp;
1240 ptrdiff_t i;
1241
1242 i = SBYTES (current_dir);
1243#ifdef MSDOS
1244 /* MSDOS must have all environment variables malloc'ed, because
1245 low-level libc functions that launch subsidiary processes rely
1246 on that. */
1247 pwd_var = xmalloc (i + 5);
1248#else
1249 if (MAX_ALLOCA - 5 < i)
1250 exec_failed (new_argv[0], ENOMEM);
1251 pwd_var = alloca (i + 5);
1252#endif
1253 temp = pwd_var + 4;
1254 memcpy (pwd_var, "PWD=", 4);
1255 lispstpcpy (temp, current_dir);
1256 1241
1257#ifndef DOS_NT 1242#ifndef DOS_NT
1258 /* We can't signal an Elisp error here; we're in a vfork. Since 1243 /* We can't signal an Elisp error here; we're in a vfork. Since
@@ -1260,101 +1245,13 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1260 should only return an error if the directory's permissions 1245 should only return an error if the directory's permissions
1261 are changed between the check and this chdir, but we should 1246 are changed between the check and this chdir, but we should
1262 at least check. */ 1247 at least check. */
1263 if (chdir (temp) < 0) 1248 if (chdir (current_dir) < 0)
1264 _exit (EXIT_CANCELED); 1249 _exit (EXIT_CANCELED);
1265#else /* DOS_NT */ 1250#endif
1266 /* Get past the drive letter, so that d:/ is left alone. */
1267 if (i > 2 && IS_DEVICE_SEP (temp[1]) && IS_DIRECTORY_SEP (temp[2]))
1268 {
1269 temp += 2;
1270 i -= 2;
1271 }
1272#endif /* DOS_NT */
1273
1274 /* Strip trailing slashes for PWD, but leave "/" and "//" alone. */
1275 while (i > 2 && IS_DIRECTORY_SEP (temp[i - 1]))
1276 temp[--i] = 0;
1277 }
1278
1279 /* Set `env' to a vector of the strings in the environment. */
1280 {
1281 register Lisp_Object tem;
1282 register char **new_env;
1283 char **p, **q;
1284 register int new_length;
1285 Lisp_Object display = Qnil;
1286
1287 new_length = 0;
1288
1289 for (tem = Vprocess_environment;
1290 CONSP (tem) && STRINGP (XCAR (tem));
1291 tem = XCDR (tem))
1292 {
1293 if (strncmp (SSDATA (XCAR (tem)), "DISPLAY", 7) == 0
1294 && (SDATA (XCAR (tem)) [7] == '\0'
1295 || SDATA (XCAR (tem)) [7] == '='))
1296 /* DISPLAY is specified in process-environment. */
1297 display = Qt;
1298 new_length++;
1299 }
1300
1301 /* If not provided yet, use the frame's DISPLAY. */
1302 if (NILP (display))
1303 {
1304 Lisp_Object tmp = Fframe_parameter (selected_frame, Qdisplay);
1305 if (!STRINGP (tmp) && CONSP (Vinitial_environment))
1306 /* If still not found, Look for DISPLAY in Vinitial_environment. */
1307 tmp = Fgetenv_internal (build_string ("DISPLAY"),
1308 Vinitial_environment);
1309 if (STRINGP (tmp))
1310 {
1311 display = tmp;
1312 new_length++;
1313 }
1314 }
1315
1316 /* new_length + 2 to include PWD and terminating 0. */
1317 if (MAX_ALLOCA / sizeof *env - 2 < new_length)
1318 exec_failed (new_argv[0], ENOMEM);
1319 env = new_env = alloca ((new_length + 2) * sizeof *env);
1320 /* If we have a PWD envvar, pass one down,
1321 but with corrected value. */
1322 if (egetenv ("PWD"))
1323 *new_env++ = pwd_var;
1324
1325 if (STRINGP (display))
1326 {
1327 if (MAX_ALLOCA - sizeof "DISPLAY=" < SBYTES (display))
1328 exec_failed (new_argv[0], ENOMEM);
1329 char *vdata = alloca (sizeof "DISPLAY=" + SBYTES (display));
1330 lispstpcpy (stpcpy (vdata, "DISPLAY="), display);
1331 new_env = add_env (env, new_env, vdata);
1332 }
1333
1334 /* Overrides. */
1335 for (tem = Vprocess_environment;
1336 CONSP (tem) && STRINGP (XCAR (tem));
1337 tem = XCDR (tem))
1338 new_env = add_env (env, new_env, SSDATA (XCAR (tem)));
1339
1340 *new_env = 0;
1341
1342 /* Remove variable names without values. */
1343 p = q = env;
1344 while (*p != 0)
1345 {
1346 while (*q != 0 && strchr (*q, '=') == NULL)
1347 q++;
1348 *p = *q++;
1349 if (*p != 0)
1350 p++;
1351 }
1352 }
1353
1354 1251
1355#ifdef WINDOWSNT 1252#ifdef WINDOWSNT
1356 prepare_standard_handles (in, out, err, handles); 1253 prepare_standard_handles (in, out, err, handles);
1357 set_process_dir (SSDATA (current_dir)); 1254 set_process_dir (current_dir);
1358 /* Spawn the child. (See w32proc.c:sys_spawnve). */ 1255 /* Spawn the child. (See w32proc.c:sys_spawnve). */
1359 cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env); 1256 cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env);
1360 reset_standard_handles (in, out, err, handles); 1257 reset_standard_handles (in, out, err, handles);
@@ -1513,6 +1410,119 @@ egetenv_internal (const char *var, ptrdiff_t len)
1513 return 0; 1410 return 0;
1514} 1411}
1515 1412
1413/* Create a new environment block. You can pass the returned pointer
1414 to `execve'. Add unwind protections for all newly-allocated
1415 objects. Don't call any Lisp code or the garbage collector while
1416 the block is active. */
1417
1418char *const *
1419make_environment_block (Lisp_Object current_dir)
1420{
1421 char **env;
1422 char *pwd_var;
1423
1424 {
1425 char *temp;
1426 ptrdiff_t i;
1427
1428 i = SBYTES (current_dir);
1429 pwd_var = xmalloc (i + 5);
1430 record_unwind_protect_ptr (xfree, pwd_var);
1431 temp = pwd_var + 4;
1432 memcpy (pwd_var, "PWD=", 4);
1433 lispstpcpy (temp, current_dir);
1434
1435#ifdef DOS_NT
1436 /* Get past the drive letter, so that d:/ is left alone. */
1437 if (i > 2 && IS_DEVICE_SEP (temp[1]) && IS_DIRECTORY_SEP (temp[2]))
1438 {
1439 temp += 2;
1440 i -= 2;
1441 }
1442#endif /* DOS_NT */
1443
1444 /* Strip trailing slashes for PWD, but leave "/" and "//" alone. */
1445 while (i > 2 && IS_DIRECTORY_SEP (temp[i - 1]))
1446 temp[--i] = 0;
1447 }
1448
1449 /* Set `env' to a vector of the strings in the environment. */
1450
1451 {
1452 register Lisp_Object tem;
1453 register char **new_env;
1454 char **p, **q;
1455 register int new_length;
1456 Lisp_Object display = Qnil;
1457
1458 new_length = 0;
1459
1460 for (tem = Vprocess_environment;
1461 CONSP (tem) && STRINGP (XCAR (tem));
1462 tem = XCDR (tem))
1463 {
1464 if (strncmp (SSDATA (XCAR (tem)), "DISPLAY", 7) == 0
1465 && (SDATA (XCAR (tem)) [7] == '\0'
1466 || SDATA (XCAR (tem)) [7] == '='))
1467 /* DISPLAY is specified in process-environment. */
1468 display = Qt;
1469 new_length++;
1470 }
1471
1472 /* If not provided yet, use the frame's DISPLAY. */
1473 if (NILP (display))
1474 {
1475 Lisp_Object tmp = Fframe_parameter (selected_frame, Qdisplay);
1476 if (!STRINGP (tmp) && CONSP (Vinitial_environment))
1477 /* If still not found, Look for DISPLAY in Vinitial_environment. */
1478 tmp = Fgetenv_internal (build_string ("DISPLAY"),
1479 Vinitial_environment);
1480 if (STRINGP (tmp))
1481 {
1482 display = tmp;
1483 new_length++;
1484 }
1485 }
1486
1487 /* new_length + 2 to include PWD and terminating 0. */
1488 env = new_env = xnmalloc (new_length + 2, sizeof *env);
1489 record_unwind_protect_ptr (xfree, env);
1490 /* If we have a PWD envvar, pass one down,
1491 but with corrected value. */
1492 if (egetenv ("PWD"))
1493 *new_env++ = pwd_var;
1494
1495 if (STRINGP (display))
1496 {
1497 char *vdata = xmalloc (sizeof "DISPLAY=" + SBYTES (display));
1498 record_unwind_protect_ptr (xfree, vdata);
1499 lispstpcpy (stpcpy (vdata, "DISPLAY="), display);
1500 new_env = add_env (env, new_env, vdata);
1501 }
1502
1503 /* Overrides. */
1504 for (tem = Vprocess_environment;
1505 CONSP (tem) && STRINGP (XCAR (tem));
1506 tem = XCDR (tem))
1507 new_env = add_env (env, new_env, SSDATA (XCAR (tem)));
1508
1509 *new_env = 0;
1510
1511 /* Remove variable names without values. */
1512 p = q = env;
1513 while (*p != 0)
1514 {
1515 while (*q != 0 && strchr (*q, '=') == NULL)
1516 q++;
1517 *p = *q++;
1518 if (*p != 0)
1519 p++;
1520 }
1521 }
1522
1523 return env;
1524}
1525
1516 1526
1517/* This is run before init_cmdargs. */ 1527/* This is run before init_cmdargs. */
1518 1528
diff --git a/src/coding.c b/src/coding.c
index 1afa4aa4749..8c2443889d4 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -10354,8 +10354,8 @@ decode_file_name (Lisp_Object fname)
10354#endif 10354#endif
10355} 10355}
10356 10356
10357Lisp_Object 10357static Lisp_Object
10358encode_file_name (Lisp_Object fname) 10358encode_file_name_1 (Lisp_Object fname)
10359{ 10359{
10360 /* This is especially important during bootstrap and dumping, when 10360 /* This is especially important during bootstrap and dumping, when
10361 file-name encoding is not yet known, and therefore any non-ASCII 10361 file-name encoding is not yet known, and therefore any non-ASCII
@@ -10380,6 +10380,19 @@ encode_file_name (Lisp_Object fname)
10380#endif 10380#endif
10381} 10381}
10382 10382
10383Lisp_Object
10384encode_file_name (Lisp_Object fname)
10385{
10386 Lisp_Object encoded = encode_file_name_1 (fname);
10387 /* No system accepts NUL bytes in filenames. Allowing them can
10388 cause subtle bugs because the system would silently use a
10389 different filename than expected. Perform this check after
10390 encoding to not miss NUL bytes introduced through encoding. */
10391 CHECK_TYPE (memchr (SSDATA (encoded), '\0', SBYTES (encoded)) == NULL,
10392 Qfilenamep, fname);
10393 return encoded;
10394}
10395
10383DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, 10396DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string,
10384 2, 4, 0, 10397 2, 4, 0,
10385 doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. 10398 doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result.
@@ -11780,6 +11793,7 @@ syms_of_coding (void)
11780 DEFSYM (Qignored, "ignored"); 11793 DEFSYM (Qignored, "ignored");
11781 11794
11782 DEFSYM (Qutf_8_string_p, "utf-8-string-p"); 11795 DEFSYM (Qutf_8_string_p, "utf-8-string-p");
11796 DEFSYM (Qfilenamep, "filenamep");
11783 11797
11784 defsubr (&Scoding_system_p); 11798 defsubr (&Scoding_system_p);
11785 defsubr (&Sread_coding_system); 11799 defsubr (&Sread_coding_system);
diff --git a/src/fileio.c b/src/fileio.c
index 51f12e104ef..651e765fca4 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5752,7 +5752,7 @@ auto_save_error (Lisp_Object error_val)
5752 Lisp_Object msg = CALLN (Fformat, format, BVAR (current_buffer, name), 5752 Lisp_Object msg = CALLN (Fformat, format, BVAR (current_buffer, name),
5753 Ferror_message_string (error_val)); 5753 Ferror_message_string (error_val));
5754 call3 (intern ("display-warning"), 5754 call3 (intern ("display-warning"),
5755 intern ("auto-save"), msg, intern ("error")); 5755 intern ("auto-save"), msg, intern (":error"));
5756 5756
5757 return Qnil; 5757 return Qnil;
5758} 5758}
diff --git a/src/image.c b/src/image.c
index d0ae44e7df7..29cd189f177 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2414,7 +2414,7 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id)
2414 2414
2415 /* Look up SPEC in the hash table of the image cache. */ 2415 /* Look up SPEC in the hash table of the image cache. */
2416 hash = sxhash (spec); 2416 hash = sxhash (spec);
2417 img = search_image_cache (f, spec, hash, foreground, background, true); 2417 img = search_image_cache (f, spec, hash, foreground, background, false);
2418 if (img && img->load_failed_p) 2418 if (img && img->load_failed_p)
2419 { 2419 {
2420 free_image (f, img); 2420 free_image (f, img);
diff --git a/src/lisp.h b/src/lisp.h
index 7dc517be727..103ed079559 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4522,7 +4522,9 @@ extern void setup_process_coding_systems (Lisp_Object);
4522# define CHILD_SETUP_ERROR_DESC "Doing vfork" 4522# define CHILD_SETUP_ERROR_DESC "Doing vfork"
4523#endif 4523#endif
4524 4524
4525extern CHILD_SETUP_TYPE child_setup (int, int, int, char **, bool, Lisp_Object); 4525extern CHILD_SETUP_TYPE child_setup (int, int, int, char *const *,
4526 char *const *, const char *);
4527extern char *const *make_environment_block (Lisp_Object);
4526extern void init_callproc_1 (void); 4528extern void init_callproc_1 (void);
4527extern void init_callproc (void); 4529extern void init_callproc (void);
4528extern void set_initial_environment (void); 4530extern void set_initial_environment (void);
diff --git a/src/nsfns.m b/src/nsfns.m
index c7956497c4c..f3c5a9ef679 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -456,7 +456,7 @@ ns_set_name (struct frame *f, Lisp_Object name, int explicit)
456static void 456static void
457ns_set_represented_filename (struct frame *f) 457ns_set_represented_filename (struct frame *f)
458{ 458{
459 Lisp_Object filename, encoded_filename; 459 Lisp_Object filename;
460 Lisp_Object buf = XWINDOW (f->selected_window)->contents; 460 Lisp_Object buf = XWINDOW (f->selected_window)->contents;
461 NSAutoreleasePool *pool; 461 NSAutoreleasePool *pool;
462 NSString *fstr; 462 NSString *fstr;
@@ -473,9 +473,7 @@ ns_set_represented_filename (struct frame *f)
473 473
474 if (! NILP (filename)) 474 if (! NILP (filename))
475 { 475 {
476 encoded_filename = ENCODE_UTF_8 (filename); 476 fstr = [NSString stringWithLispString:filename];
477
478 fstr = [NSString stringWithLispString:encoded_filename];
479 if (fstr == nil) fstr = @""; 477 if (fstr == nil) fstr = @"";
480 } 478 }
481 else 479 else
@@ -3012,7 +3010,7 @@ DEFUN ("ns-show-character-palette",
3012#endif 3010#endif
3013 3011
3014 3012
3015/* Whether N bytes at STR are in the [0,127] range. */ 3013/* Whether N bytes at STR are in the [1,127] range. */
3016static bool 3014static bool
3017all_nonzero_ascii (unsigned char *str, ptrdiff_t n) 3015all_nonzero_ascii (unsigned char *str, ptrdiff_t n)
3018{ 3016{
diff --git a/src/nsfont.m b/src/nsfont.m
index 378a6408401..9e4caca9102 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -329,7 +329,7 @@ static NSString
329{ 329{
330 Lisp_Object script = assq_no_quit (XCAR (otf), Votf_script_alist); 330 Lisp_Object script = assq_no_quit (XCAR (otf), Votf_script_alist);
331 return CONSP (script) 331 return CONSP (script)
332 ? [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (XCDR ((script))))] 332 ? [NSString stringWithLispString: SYMBOL_NAME (XCDR ((script)))]
333 : @""; 333 : @"";
334} 334}
335 335
@@ -345,7 +345,7 @@ static NSString
345 if (!strncmp (SSDATA (r), reg, SBYTES (r))) 345 if (!strncmp (SSDATA (r), reg, SBYTES (r)))
346 { 346 {
347 script = XCDR (XCAR (rts)); 347 script = XCDR (XCAR (rts));
348 return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (script))]; 348 return [NSString stringWithLispString: SYMBOL_NAME (script)];
349 } 349 }
350 rts = XCDR (rts); 350 rts = XCDR (rts);
351 } 351 }
@@ -370,8 +370,7 @@ static NSString
370 { 370 {
371 Lisp_Object key = XCAR (tmp), val = XCDR (tmp); 371 Lisp_Object key = XCAR (tmp), val = XCDR (tmp);
372 if (EQ (key, QCscript) && SYMBOLP (val)) 372 if (EQ (key, QCscript) && SYMBOLP (val))
373 return [NSString stringWithUTF8String: 373 return [NSString stringWithLispString: SYMBOL_NAME (val)];
374 SSDATA (SYMBOL_NAME (val))];
375 if (EQ (key, QClang) && SYMBOLP (val)) 374 if (EQ (key, QClang) && SYMBOLP (val))
376 return ns_lang_to_script (val); 375 return ns_lang_to_script (val);
377 if (EQ (key, QCotf) && CONSP (val) && SYMBOLP (XCAR (val))) 376 if (EQ (key, QCotf) && CONSP (val) && SYMBOLP (XCAR (val)))
diff --git a/src/nsimage.m b/src/nsimage.m
index f9fb368ba80..c47a2b2d64a 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -262,7 +262,7 @@ ns_image_size_in_bytes (void *img)
262 found = ENCODE_FILE (found); 262 found = ENCODE_FILE (found);
263 263
264 image = [[EmacsImage alloc] initByReferencingFile: 264 image = [[EmacsImage alloc] initByReferencingFile:
265 [NSString stringWithUTF8String: SSDATA (found)]]; 265 [NSString stringWithLispString: found]];
266 266
267 image->bmRep = nil; 267 image->bmRep = nil;
268#ifdef NS_IMPL_COCOA 268#ifdef NS_IMPL_COCOA
@@ -278,7 +278,7 @@ ns_image_size_in_bytes (void *img)
278 278
279 [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])]; 279 [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])];
280 280
281 [image setName: [NSString stringWithUTF8String: SSDATA (file)]]; 281 [image setName: [NSString stringWithLispString: file]];
282 282
283 return image; 283 return image;
284} 284}
diff --git a/src/nsmenu.m b/src/nsmenu.m
index a286a80da17..efad978316e 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -970,7 +970,7 @@ ns_menu_show (struct frame *f, int x, int y, int menuflags,
970 } 970 }
971 971
972 pmenu = [[EmacsMenu alloc] initWithTitle: 972 pmenu = [[EmacsMenu alloc] initWithTitle:
973 [NSString stringWithUTF8String: SSDATA (title)]]; 973 [NSString stringWithLispString: title]];
974 [pmenu fillWithWidgetValue: first_wv->contents]; 974 [pmenu fillWithWidgetValue: first_wv->contents];
975 free_menubar_widget_value_tree (first_wv); 975 free_menubar_widget_value_tree (first_wv);
976 unbind_to (specpdl_count, Qnil); 976 unbind_to (specpdl_count, Qnil);
diff --git a/src/nsselect.m b/src/nsselect.m
index 7b1937f5d99..95fce4d0f78 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -58,7 +58,7 @@ symbol_to_nsstring (Lisp_Object sym)
58 if (EQ (sym, QPRIMARY)) return NXPrimaryPboard; 58 if (EQ (sym, QPRIMARY)) return NXPrimaryPboard;
59 if (EQ (sym, QSECONDARY)) return NXSecondaryPboard; 59 if (EQ (sym, QSECONDARY)) return NXSecondaryPboard;
60 if (EQ (sym, QTEXT)) return NSPasteboardTypeString; 60 if (EQ (sym, QTEXT)) return NSPasteboardTypeString;
61 return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))]; 61 return [NSString stringWithLispString: SYMBOL_NAME (sym)];
62} 62}
63 63
64static NSPasteboard * 64static NSPasteboard *
@@ -170,17 +170,12 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype)
170 } 170 }
171 else 171 else
172 { 172 {
173 char *utfStr;
174 NSString *type, *nsStr; 173 NSString *type, *nsStr;
175 NSEnumerator *tenum; 174 NSEnumerator *tenum;
176 175
177 CHECK_STRING (str); 176 CHECK_STRING (str);
178 177
179 utfStr = SSDATA (str); 178 nsStr = [NSString stringWithLispString: str];
180 nsStr = [[NSString alloc] initWithBytesNoCopy: utfStr
181 length: SBYTES (str)
182 encoding: NSUTF8StringEncoding
183 freeWhenDone: NO];
184 // FIXME: Why those 2 different code paths? 179 // FIXME: Why those 2 different code paths?
185 if (gtype == nil) 180 if (gtype == nil)
186 { 181 {
@@ -196,7 +191,6 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype)
196 eassert (gtype == NSPasteboardTypeString); 191 eassert (gtype == NSPasteboardTypeString);
197 [pb setString: nsStr forType: gtype]; 192 [pb setString: nsStr forType: gtype];
198 } 193 }
199 [nsStr release];
200 ns_store_pb_change_count (pb); 194 ns_store_pb_change_count (pb);
201 } 195 }
202} 196}
diff --git a/src/nsterm.m b/src/nsterm.m
index 7972fa4dabb..2a117a07801 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -5541,9 +5541,8 @@ ns_term_init (Lisp_Object display_name)
5541 /* There are 752 colors defined in rgb.txt. */ 5541 /* There are 752 colors defined in rgb.txt. */
5542 if ( cl == nil || [[cl allKeys] count] < 752) 5542 if ( cl == nil || [[cl allKeys] count] < 752)
5543 { 5543 {
5544 Lisp_Object color_file, color_map, color; 5544 Lisp_Object color_file, color_map, color, name;
5545 unsigned long c; 5545 unsigned long c;
5546 char *name;
5547 5546
5548 color_file = Fexpand_file_name (build_string ("rgb.txt"), 5547 color_file = Fexpand_file_name (build_string ("rgb.txt"),
5549 Fsymbol_value (intern ("data-directory"))); 5548 Fsymbol_value (intern ("data-directory")));
@@ -5556,14 +5555,14 @@ ns_term_init (Lisp_Object display_name)
5556 for ( ; CONSP (color_map); color_map = XCDR (color_map)) 5555 for ( ; CONSP (color_map); color_map = XCDR (color_map))
5557 { 5556 {
5558 color = XCAR (color_map); 5557 color = XCAR (color_map);
5559 name = SSDATA (XCAR (color)); 5558 name = XCAR (color);
5560 c = XFIXNUM (XCDR (color)); 5559 c = XFIXNUM (XCDR (color));
5561 [cl setColor: 5560 [cl setColor:
5562 [NSColor colorForEmacsRed: RED_FROM_ULONG (c) / 255.0 5561 [NSColor colorForEmacsRed: RED_FROM_ULONG (c) / 255.0
5563 green: GREEN_FROM_ULONG (c) / 255.0 5562 green: GREEN_FROM_ULONG (c) / 255.0
5564 blue: BLUE_FROM_ULONG (c) / 255.0 5563 blue: BLUE_FROM_ULONG (c) / 255.0
5565 alpha: 1.0] 5564 alpha: 1.0]
5566 forKey: [NSString stringWithUTF8String: name]]; 5565 forKey: [NSString stringWithLispString: name]];
5567 } 5566 }
5568 5567
5569 /* FIXME: Report any errors writing the color file below. */ 5568 /* FIXME: Report any errors writing the color file below. */
@@ -7619,8 +7618,7 @@ not_in_argv (NSString *arg)
7619 [self registerForDraggedTypes: ns_drag_types]; 7618 [self registerForDraggedTypes: ns_drag_types];
7620 7619
7621 tem = f->name; 7620 tem = f->name;
7622 name = [NSString stringWithUTF8String: 7621 name = NILP (tem) ? @"Emacs" : [NSString stringWithLispString:tem];
7623 NILP (tem) ? "Emacs" : SSDATA (tem)];
7624 [win setTitle: name]; 7622 [win setTitle: name];
7625 7623
7626 /* toolbar support */ 7624 /* toolbar support */
diff --git a/src/nsxwidget.m b/src/nsxwidget.m
index dbd4cb29a62..915fd8b59ce 100644
--- a/src/nsxwidget.m
+++ b/src/nsxwidget.m
@@ -296,8 +296,6 @@ static NSString *xwScript;
296 296
297/* Xwidget webkit commands. */ 297/* Xwidget webkit commands. */
298 298
299static Lisp_Object build_string_with_nsstr (NSString *nsstr);
300
301bool 299bool
302nsxwidget_is_web_view (struct xwidget *xw) 300nsxwidget_is_web_view (struct xwidget *xw)
303{ 301{
@@ -309,14 +307,14 @@ Lisp_Object
309nsxwidget_webkit_uri (struct xwidget *xw) 307nsxwidget_webkit_uri (struct xwidget *xw)
310{ 308{
311 XwWebView *xwWebView = (XwWebView *) xw->xwWidget; 309 XwWebView *xwWebView = (XwWebView *) xw->xwWidget;
312 return build_string_with_nsstr (xwWebView.URL.absoluteString); 310 return [xwWebView.URL.absoluteString lispString];
313} 311}
314 312
315Lisp_Object 313Lisp_Object
316nsxwidget_webkit_title (struct xwidget *xw) 314nsxwidget_webkit_title (struct xwidget *xw)
317{ 315{
318 XwWebView *xwWebView = (XwWebView *) xw->xwWidget; 316 XwWebView *xwWebView = (XwWebView *) xw->xwWidget;
319 return build_string_with_nsstr (xwWebView.title); 317 return [xwWebView.title lispString];
320} 318}
321 319
322/* @Note ATS - Need application transport security in 'Info.plist' or 320/* @Note ATS - Need application transport security in 'Info.plist' or
@@ -350,15 +348,6 @@ nsxwidget_webkit_zoom (struct xwidget *xw, double zoom_change)
350 /* TODO: setMagnification:centeredAtPoint. */ 348 /* TODO: setMagnification:centeredAtPoint. */
351} 349}
352 350
353/* Build lisp string */
354static Lisp_Object
355build_string_with_nsstr (NSString *nsstr)
356{
357 const char *utfstr = [nsstr UTF8String];
358 NSUInteger bytes = [nsstr lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
359 return make_string (utfstr, bytes);
360}
361
362/* Recursively convert an objc native type JavaScript value to a Lisp 351/* Recursively convert an objc native type JavaScript value to a Lisp
363 value. Mostly copied from GTK xwidget 'webkit_js_to_lisp'. */ 352 value. Mostly copied from GTK xwidget 'webkit_js_to_lisp'. */
364static Lisp_Object 353static Lisp_Object
@@ -367,7 +356,7 @@ js_to_lisp (id value)
367 if (value == nil || [value isKindOfClass:NSNull.class]) 356 if (value == nil || [value isKindOfClass:NSNull.class])
368 return Qnil; 357 return Qnil;
369 else if ([value isKindOfClass:NSString.class]) 358 else if ([value isKindOfClass:NSString.class])
370 return build_string_with_nsstr ((NSString *) value); 359 return [(NSString *) value lispString];
371 else if ([value isKindOfClass:NSNumber.class]) 360 else if ([value isKindOfClass:NSNumber.class])
372 { 361 {
373 NSNumber *nsnum = (NSNumber *) value; 362 NSNumber *nsnum = (NSNumber *) value;
@@ -407,7 +396,7 @@ js_to_lisp (id value)
407 { 396 {
408 NSString *prop_key = (NSString *) [keys objectAtIndex:i]; 397 NSString *prop_key = (NSString *) [keys objectAtIndex:i];
409 id prop_value = [nsdict valueForKey:prop_key]; 398 id prop_value = [nsdict valueForKey:prop_key];
410 p->contents[i] = Fcons (build_string_with_nsstr (prop_key), 399 p->contents[i] = Fcons ([prop_key lispString],
411 js_to_lisp (prop_value)); 400 js_to_lisp (prop_value));
412 } 401 }
413 XSETVECTOR (obj, p); 402 XSETVECTOR (obj, p);
diff --git a/src/pdumper.c b/src/pdumper.c
index b3abbd66f0c..ae5bbef9b77 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2709,7 +2709,7 @@ dump_hash_table (struct dump_context *ctx,
2709static dump_off 2709static dump_off
2710dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) 2710dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer)
2711{ 2711{
2712#if CHECK_STRUCTS && !defined HASH_buffer_EE36B4292E 2712#if CHECK_STRUCTS && !defined HASH_buffer_99D642C1CB
2713# error "buffer changed. See CHECK_STRUCTS comment in config.h." 2713# error "buffer changed. See CHECK_STRUCTS comment in config.h."
2714#endif 2714#endif
2715 struct buffer munged_buffer = *in_buffer; 2715 struct buffer munged_buffer = *in_buffer;
diff --git a/src/process.c b/src/process.c
index 9efefb1de73..15b4a23784e 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2124,8 +2124,11 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2124 if (!EQ (p->command, Qt)) 2124 if (!EQ (p->command, Qt))
2125 add_process_read_fd (inchannel); 2125 add_process_read_fd (inchannel);
2126 2126
2127 ptrdiff_t count = SPECPDL_INDEX ();
2128
2127 /* This may signal an error. */ 2129 /* This may signal an error. */
2128 setup_process_coding_systems (process); 2130 setup_process_coding_systems (process);
2131 char *const *env = make_environment_block (current_dir);
2129 2132
2130 block_input (); 2133 block_input ();
2131 block_child_signal (&oldset); 2134 block_child_signal (&oldset);
@@ -2139,6 +2142,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2139 int volatile forkout_volatile = forkout; 2142 int volatile forkout_volatile = forkout;
2140 int volatile forkerr_volatile = forkerr; 2143 int volatile forkerr_volatile = forkerr;
2141 struct Lisp_Process *p_volatile = p; 2144 struct Lisp_Process *p_volatile = p;
2145 char *const *volatile env_volatile = env;
2142 2146
2143#ifdef DARWIN_OS 2147#ifdef DARWIN_OS
2144 /* Darwin doesn't let us run setsid after a vfork, so use fork when 2148 /* Darwin doesn't let us run setsid after a vfork, so use fork when
@@ -2163,6 +2167,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2163 forkout = forkout_volatile; 2167 forkout = forkout_volatile;
2164 forkerr = forkerr_volatile; 2168 forkerr = forkerr_volatile;
2165 p = p_volatile; 2169 p = p_volatile;
2170 env = env_volatile;
2166 2171
2167 pty_flag = p->pty_flag; 2172 pty_flag = p->pty_flag;
2168 2173
@@ -2254,9 +2259,11 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2254 if (forkerr < 0) 2259 if (forkerr < 0)
2255 forkerr = forkout; 2260 forkerr = forkout;
2256#ifdef WINDOWSNT 2261#ifdef WINDOWSNT
2257 pid = child_setup (forkin, forkout, forkerr, new_argv, 1, current_dir); 2262 pid = child_setup (forkin, forkout, forkerr, new_argv, env,
2263 SSDATA (current_dir));
2258#else /* not WINDOWSNT */ 2264#else /* not WINDOWSNT */
2259 child_setup (forkin, forkout, forkerr, new_argv, 1, current_dir); 2265 child_setup (forkin, forkout, forkerr, new_argv, env,
2266 SSDATA (current_dir));
2260#endif /* not WINDOWSNT */ 2267#endif /* not WINDOWSNT */
2261 } 2268 }
2262 2269
@@ -2271,6 +2278,9 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
2271 unblock_child_signal (&oldset); 2278 unblock_child_signal (&oldset);
2272 unblock_input (); 2279 unblock_input ();
2273 2280
2281 /* Environment block no longer needed. */
2282 unbind_to (count, Qnil);
2283
2274 if (pid < 0) 2284 if (pid < 0)
2275 report_file_errno (CHILD_SETUP_ERROR_DESC, Qnil, vfork_errno); 2285 report_file_errno (CHILD_SETUP_ERROR_DESC, Qnil, vfork_errno);
2276 else 2286 else
diff --git a/src/xterm.c b/src/xterm.c
index 3de0d2e73c0..7f8728e47c4 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8947,7 +8947,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
8947 if (!f 8947 if (!f
8948 && (f = any) 8948 && (f = any)
8949 && configureEvent.xconfigure.window == FRAME_X_WINDOW (f) 8949 && configureEvent.xconfigure.window == FRAME_X_WINDOW (f)
8950 && FRAME_VISIBLE_P(f)) 8950 && (FRAME_VISIBLE_P(f)
8951 || !(configureEvent.xconfigure.width <= 1
8952 && configureEvent.xconfigure.height <= 1)))
8951 { 8953 {
8952 block_input (); 8954 block_input ();
8953 if (FRAME_X_DOUBLE_BUFFERED_P (f)) 8955 if (FRAME_X_DOUBLE_BUFFERED_P (f))
@@ -8962,7 +8964,10 @@ handle_one_xevent (struct x_display_info *dpyinfo,
8962 f = 0; 8964 f = 0;
8963 } 8965 }
8964#endif 8966#endif
8965 if (f && FRAME_VISIBLE_P(f)) 8967 if (f
8968 && (FRAME_VISIBLE_P(f)
8969 || !(configureEvent.xconfigure.width <= 1
8970 && configureEvent.xconfigure.height <= 1)))
8966 { 8971 {
8967#ifdef USE_GTK 8972#ifdef USE_GTK
8968 /* For GTK+ don't call x_net_wm_state for the scroll bar 8973 /* For GTK+ don't call x_net_wm_state for the scroll bar