diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog.multi-tty | 13 | ||||
| -rw-r--r-- | src/callproc.c | 113 | ||||
| -rw-r--r-- | src/frame.c | 9 | ||||
| -rw-r--r-- | src/frame.h | 2 |
4 files changed, 128 insertions, 9 deletions
diff --git a/src/ChangeLog.multi-tty b/src/ChangeLog.multi-tty index eb455157034..05a7ec48d06 100644 --- a/src/ChangeLog.multi-tty +++ b/src/ChangeLog.multi-tty | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2007-07-02 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * frame.c (Qterm_environment_variable, | ||
| 4 | Qdisplay_environment_variable): New variables. | ||
| 5 | (syms_of_frame): Intern and staticpro them. | ||
| 6 | |||
| 7 | * frame.h: Declare them here. | ||
| 8 | |||
| 9 | * callproc.c (child_setup): Use the display-environment-variable | ||
| 10 | and term-environment-variable frame params. | ||
| 11 | (getenv_internal): Likewise. | ||
| 12 | (set_initial_environment): Initialise Vprocess_environment. | ||
| 13 | |||
| 1 | 2007-06-03 Dan Nicolaescu <dann@ics.uci.edu> | 14 | 2007-06-03 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 15 | ||
| 3 | * xselect.c (x_handle_selection_clear): Only access | 16 | * xselect.c (x_handle_selection_clear): Only access |
diff --git a/src/callproc.c b/src/callproc.c index ce9eb73dd54..a2d517b1bea 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -1245,6 +1245,8 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1245 | { | 1245 | { |
| 1246 | char **env; | 1246 | char **env; |
| 1247 | char *pwd_var; | 1247 | char *pwd_var; |
| 1248 | char *term_var; | ||
| 1249 | char *display_var; | ||
| 1248 | #ifdef WINDOWSNT | 1250 | #ifdef WINDOWSNT |
| 1249 | int cpid; | 1251 | int cpid; |
| 1250 | HANDLE handles[3]; | 1252 | HANDLE handles[3]; |
| @@ -1325,9 +1327,12 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1325 | register char **new_env; | 1327 | register char **new_env; |
| 1326 | char **p, **q; | 1328 | char **p, **q; |
| 1327 | register int new_length; | 1329 | register int new_length; |
| 1328 | Lisp_Object local = get_frame_param (XFRAME (Fframe_with_environment (selected_frame)), | 1330 | Lisp_Object local = selected_frame; /* get_frame_param (XFRAME (Fframe_with_environment (selected_frame)), */ |
| 1329 | Qenvironment); | 1331 | /* Qenvironment); */ |
| 1330 | 1332 | ||
| 1333 | Lisp_Object term; | ||
| 1334 | Lisp_Object display; | ||
| 1335 | |||
| 1331 | new_length = 0; | 1336 | new_length = 0; |
| 1332 | 1337 | ||
| 1333 | for (tem = Vprocess_environment; | 1338 | for (tem = Vprocess_environment; |
| @@ -1335,10 +1340,21 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1335 | tem = XCDR (tem)) | 1340 | tem = XCDR (tem)) |
| 1336 | new_length++; | 1341 | new_length++; |
| 1337 | 1342 | ||
| 1343 | #if 0 | ||
| 1338 | for (tem = local; | 1344 | for (tem = local; |
| 1339 | CONSP (tem) && STRINGP (XCAR (tem)); | 1345 | CONSP (tem) && STRINGP (XCAR (tem)); |
| 1340 | tem = XCDR (tem)) | 1346 | tem = XCDR (tem)) |
| 1341 | new_length++; | 1347 | new_length++; |
| 1348 | #endif | ||
| 1349 | |||
| 1350 | /* Add TERM and DISPLAY from the frame local values. */ | ||
| 1351 | term = get_frame_param (XFRAME (local), Qterm_environment_variable); | ||
| 1352 | if (! NILP (term)) | ||
| 1353 | new_length++; | ||
| 1354 | |||
| 1355 | display = get_frame_param (XFRAME (local), Qdisplay_environment_variable); | ||
| 1356 | if (! NILP (display)) | ||
| 1357 | new_length++; | ||
| 1342 | 1358 | ||
| 1343 | /* new_length + 2 to include PWD and terminating 0. */ | 1359 | /* new_length + 2 to include PWD and terminating 0. */ |
| 1344 | env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *)); | 1360 | env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *)); |
| @@ -1348,18 +1364,43 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1348 | if (egetenv ("PWD")) | 1364 | if (egetenv ("PWD")) |
| 1349 | *new_env++ = pwd_var; | 1365 | *new_env++ = pwd_var; |
| 1350 | 1366 | ||
| 1367 | if (! NILP (term)) | ||
| 1368 | { | ||
| 1369 | int vlen = strlen ("TERM=") + strlen (SDATA (term)) + 1; | ||
| 1370 | char *vdata = (char *) alloca (vlen); | ||
| 1371 | strcpy (vdata, "TERM="); | ||
| 1372 | strcat (vdata, SDATA (term)); | ||
| 1373 | new_env = add_env (env, new_env, vdata); | ||
| 1374 | } | ||
| 1375 | |||
| 1376 | if (! NILP (display)) | ||
| 1377 | { | ||
| 1378 | int vlen = strlen ("DISPLAY=") + strlen (SDATA (display)) + 1; | ||
| 1379 | char *vdata = (char *) alloca (vlen); | ||
| 1380 | strcpy (vdata, "DISPLAY="); | ||
| 1381 | strcat (vdata, SDATA (display)); | ||
| 1382 | new_env = add_env (env, new_env, vdata); | ||
| 1383 | } | ||
| 1384 | |||
| 1351 | /* Overrides. */ | 1385 | /* Overrides. */ |
| 1352 | for (tem = Vprocess_environment; | 1386 | for (tem = Vprocess_environment; |
| 1353 | CONSP (tem) && STRINGP (XCAR (tem)); | 1387 | CONSP (tem) && STRINGP (XCAR (tem)); |
| 1354 | tem = XCDR (tem)) | 1388 | tem = XCDR (tem)) |
| 1355 | new_env = add_env (env, new_env, SDATA (XCAR (tem))); | 1389 | { |
| 1390 | if ((strcmp (SDATA (XCAR (tem)), "TERM") != 0) | ||
| 1391 | && (strcmp (SDATA (XCAR (tem)), "DISPLAY") != 0)) | ||
| 1392 | new_env = add_env (env, new_env, SDATA (XCAR (tem))); | ||
| 1393 | } | ||
| 1356 | 1394 | ||
| 1395 | |||
| 1396 | #if 0 | ||
| 1357 | /* Local part of environment. */ | 1397 | /* Local part of environment. */ |
| 1358 | for (tem = local; | 1398 | for (tem = local; |
| 1359 | CONSP (tem) && STRINGP (XCAR (tem)); | 1399 | CONSP (tem) && STRINGP (XCAR (tem)); |
| 1360 | tem = XCDR (tem)) | 1400 | tem = XCDR (tem)) |
| 1361 | new_env = add_env (env, new_env, SDATA (XCAR (tem))); | 1401 | new_env = add_env (env, new_env, SDATA (XCAR (tem))); |
| 1362 | 1402 | #endif | |
| 1403 | |||
| 1363 | *new_env = 0; | 1404 | *new_env = 0; |
| 1364 | 1405 | ||
| 1365 | /* Remove variable names without values. */ | 1406 | /* Remove variable names without values. */ |
| @@ -1373,6 +1414,8 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir) | |||
| 1373 | p++; | 1414 | p++; |
| 1374 | } | 1415 | } |
| 1375 | } | 1416 | } |
| 1417 | |||
| 1418 | |||
| 1376 | #ifdef WINDOWSNT | 1419 | #ifdef WINDOWSNT |
| 1377 | prepare_standard_handles (in, out, err, handles); | 1420 | prepare_standard_handles (in, out, err, handles); |
| 1378 | set_process_dir (SDATA (current_dir)); | 1421 | set_process_dir (SDATA (current_dir)); |
| @@ -1494,6 +1537,9 @@ getenv_internal (var, varlen, value, valuelen, frame) | |||
| 1494 | Lisp_Object frame; | 1537 | Lisp_Object frame; |
| 1495 | { | 1538 | { |
| 1496 | Lisp_Object scan; | 1539 | Lisp_Object scan; |
| 1540 | Lisp_Object term; | ||
| 1541 | Lisp_Object display; | ||
| 1542 | |||
| 1497 | 1543 | ||
| 1498 | if (NILP (frame)) | 1544 | if (NILP (frame)) |
| 1499 | { | 1545 | { |
| @@ -1528,6 +1574,56 @@ getenv_internal (var, varlen, value, valuelen, frame) | |||
| 1528 | frame = selected_frame; | 1574 | frame = selected_frame; |
| 1529 | } | 1575 | } |
| 1530 | 1576 | ||
| 1577 | /* For TERM and DISPLAY first try to get the values from the frame. */ | ||
| 1578 | term = get_frame_param (XFRAME (frame), Qterm_environment_variable); | ||
| 1579 | if (strcmp (var, "TERM") == 0) | ||
| 1580 | if (! NILP (term)) | ||
| 1581 | { | ||
| 1582 | *value = (char *) SDATA (term); | ||
| 1583 | *valuelen = SBYTES (term); | ||
| 1584 | return 1; | ||
| 1585 | } | ||
| 1586 | display = get_frame_param (XFRAME (frame), Qdisplay_environment_variable); | ||
| 1587 | if (strcmp (var, "DISPLAY") == 0) | ||
| 1588 | if (! NILP (display)) | ||
| 1589 | { | ||
| 1590 | *value = (char *) SDATA (display); | ||
| 1591 | *valuelen = SBYTES (display); | ||
| 1592 | return 1; | ||
| 1593 | } | ||
| 1594 | |||
| 1595 | { | ||
| 1596 | /* Try to find VAR in Vprocess_environment. */ | ||
| 1597 | for (scan = Vprocess_environment; CONSP (scan); scan = XCDR (scan)) | ||
| 1598 | { | ||
| 1599 | Lisp_Object entry = XCAR (scan); | ||
| 1600 | if (STRINGP (entry) | ||
| 1601 | && SBYTES (entry) >= varlen | ||
| 1602 | #ifdef WINDOWSNT | ||
| 1603 | /* NT environment variables are case insensitive. */ | ||
| 1604 | && ! strnicmp (SDATA (entry), var, varlen) | ||
| 1605 | #else /* not WINDOWSNT */ | ||
| 1606 | && ! bcmp (SDATA (entry), var, varlen) | ||
| 1607 | #endif /* not WINDOWSNT */ | ||
| 1608 | ) | ||
| 1609 | { | ||
| 1610 | if (SBYTES (entry) > varlen && SREF (entry, varlen) == '=') | ||
| 1611 | { | ||
| 1612 | *value = (char *) SDATA (entry) + (varlen + 1); | ||
| 1613 | *valuelen = SBYTES (entry) - (varlen + 1); | ||
| 1614 | return 1; | ||
| 1615 | } | ||
| 1616 | else if (SBYTES (entry) == varlen) | ||
| 1617 | { | ||
| 1618 | /* Lone variable names in Vprocess_environment mean that | ||
| 1619 | variable should be removed from the environment. */ | ||
| 1620 | return 0; | ||
| 1621 | } | ||
| 1622 | } | ||
| 1623 | } | ||
| 1624 | } | ||
| 1625 | |||
| 1626 | #if 0 | ||
| 1531 | /* Find the environment in which to search the variable. */ | 1627 | /* Find the environment in which to search the variable. */ |
| 1532 | CHECK_FRAME (frame); | 1628 | CHECK_FRAME (frame); |
| 1533 | frame = Fframe_with_environment (frame); | 1629 | frame = Fframe_with_environment (frame); |
| @@ -1555,7 +1651,7 @@ getenv_internal (var, varlen, value, valuelen, frame) | |||
| 1555 | return 1; | 1651 | return 1; |
| 1556 | } | 1652 | } |
| 1557 | } | 1653 | } |
| 1558 | 1654 | #endif | |
| 1559 | return 0; | 1655 | return 0; |
| 1560 | } | 1656 | } |
| 1561 | 1657 | ||
| @@ -1737,14 +1833,15 @@ void | |||
| 1737 | set_initial_environment () | 1833 | set_initial_environment () |
| 1738 | { | 1834 | { |
| 1739 | register char **envp; | 1835 | register char **envp; |
| 1740 | Lisp_Object env = Qnil; | 1836 | Lisp_Object env = Vprocess_environment; |
| 1741 | #ifndef CANNOT_DUMP | 1837 | #ifndef CANNOT_DUMP |
| 1742 | if (initialized) | 1838 | if (initialized) |
| 1743 | #endif | 1839 | #endif |
| 1744 | { | 1840 | { |
| 1745 | for (envp = environ; *envp; envp++) | 1841 | for (envp = environ; *envp; envp++) |
| 1746 | env = Fcons (build_string (*envp), env); | 1842 | Vprocess_environment = Fcons (build_string (*envp), |
| 1747 | store_frame_param (SELECTED_FRAME(), Qenvironment, env); | 1843 | Vprocess_environment); |
| 1844 | store_frame_param (SELECTED_FRAME(), Qenvironment, Vprocess_environment); | ||
| 1748 | } | 1845 | } |
| 1749 | } | 1846 | } |
| 1750 | 1847 | ||
diff --git a/src/frame.c b/src/frame.c index a1b4e6bd85f..d081fbf55a2 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -111,6 +111,8 @@ Lisp_Object Qtty_color_mode; | |||
| 111 | Lisp_Object Qtty, Qtty_type; | 111 | Lisp_Object Qtty, Qtty_type; |
| 112 | Lisp_Object Qwindow_system; | 112 | Lisp_Object Qwindow_system; |
| 113 | Lisp_Object Qenvironment; | 113 | Lisp_Object Qenvironment; |
| 114 | Lisp_Object Qterm_environment_variable; | ||
| 115 | Lisp_Object Qdisplay_environment_variable; | ||
| 114 | 116 | ||
| 115 | Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth; | 117 | Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth; |
| 116 | 118 | ||
| @@ -4353,7 +4355,12 @@ syms_of_frame () | |||
| 4353 | staticpro (&Qwindow_system); | 4355 | staticpro (&Qwindow_system); |
| 4354 | Qenvironment = intern ("environment"); | 4356 | Qenvironment = intern ("environment"); |
| 4355 | staticpro (&Qenvironment); | 4357 | staticpro (&Qenvironment); |
| 4356 | 4358 | ||
| 4359 | Qterm_environment_variable = intern ("term-environment-variable"); | ||
| 4360 | staticpro (&Qterm_environment_variable); | ||
| 4361 | Qdisplay_environment_variable = intern ("display-environment-variable"); | ||
| 4362 | staticpro (&Qdisplay_environment_variable); | ||
| 4363 | |||
| 4357 | Qface_set_after_frame_default = intern ("face-set-after-frame-default"); | 4364 | Qface_set_after_frame_default = intern ("face-set-after-frame-default"); |
| 4358 | staticpro (&Qface_set_after_frame_default); | 4365 | staticpro (&Qface_set_after_frame_default); |
| 4359 | 4366 | ||
diff --git a/src/frame.h b/src/frame.h index 5686662bb96..161404fdd75 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -780,6 +780,8 @@ extern Lisp_Object Qframep, Qframe_live_p; | |||
| 780 | extern Lisp_Object Qtty, Qtty_type; | 780 | extern Lisp_Object Qtty, Qtty_type; |
| 781 | extern Lisp_Object Qterminal, Qterminal_live_p; | 781 | extern Lisp_Object Qterminal, Qterminal_live_p; |
| 782 | extern Lisp_Object Qenvironment; | 782 | extern Lisp_Object Qenvironment; |
| 783 | extern Lisp_Object Qterm_environment_variable; | ||
| 784 | extern Lisp_Object Qdisplay_environment_variable; | ||
| 783 | 785 | ||
| 784 | extern struct frame *last_nonminibuf_frame; | 786 | extern struct frame *last_nonminibuf_frame; |
| 785 | 787 | ||