diff options
| author | Joseph Arceneaux | 1992-08-06 03:24:07 +0000 |
|---|---|---|
| committer | Joseph Arceneaux | 1992-08-06 03:24:07 +0000 |
| commit | 012c6fcb48ff1d47324e74592bd6b75cc3d19aeb (patch) | |
| tree | a66c9d9703d461f68ebe3aff1eb1977f61efe305 | |
| parent | a61f59b428b43a9b0457ba51de1d5acef0a0edc0 (diff) | |
| download | emacs-012c6fcb48ff1d47324e74592bd6b75cc3d19aeb.tar.gz emacs-012c6fcb48ff1d47324e74592bd6b75cc3d19aeb.zip | |
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
disappeared.
| -rw-r--r-- | src/callproc.c | 71 |
1 files changed, 66 insertions, 5 deletions
diff --git a/src/callproc.c b/src/callproc.c index 7d8185c5a4b..85e86c50da9 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -128,7 +128,7 @@ If you quit, the process is killed with SIGKILL.") | |||
| 128 | 128 | ||
| 129 | CHECK_STRING (args[0], 0); | 129 | CHECK_STRING (args[0], 0); |
| 130 | 130 | ||
| 131 | if (nargs <= 1 || NULL (args[1])) | 131 | if (nargs <= 1 || NILP (args[1])) |
| 132 | args[1] = build_string ("/dev/null"); | 132 | args[1] = build_string ("/dev/null"); |
| 133 | else | 133 | else |
| 134 | args[1] = Fexpand_file_name (args[1], current_buffer->directory); | 134 | args[1] = Fexpand_file_name (args[1], current_buffer->directory); |
| @@ -169,7 +169,7 @@ If you quit, the process is killed with SIGKILL.") | |||
| 169 | } | 169 | } |
| 170 | /* Search for program; barf if not found. */ | 170 | /* Search for program; barf if not found. */ |
| 171 | openp (Vexec_path, args[0], "", &path, 1); | 171 | openp (Vexec_path, args[0], "", &path, 1); |
| 172 | if (NULL (path)) | 172 | if (NILP (path)) |
| 173 | { | 173 | { |
| 174 | close (filefd); | 174 | close (filefd); |
| 175 | report_file_error ("Searching for program", Fcons (args[0], Qnil)); | 175 | report_file_error ("Searching for program", Fcons (args[0], Qnil)); |
| @@ -267,9 +267,9 @@ If you quit, the process is killed with SIGKILL.") | |||
| 267 | while ((nread = read (fd[0], buf, sizeof buf)) > 0) | 267 | while ((nread = read (fd[0], buf, sizeof buf)) > 0) |
| 268 | { | 268 | { |
| 269 | immediate_quit = 0; | 269 | immediate_quit = 0; |
| 270 | if (!NULL (buffer)) | 270 | if (!NILP (buffer)) |
| 271 | insert (buf, nread); | 271 | insert (buf, nread); |
| 272 | if (!NULL (display) && INTERACTIVE) | 272 | if (!NILP (display) && INTERACTIVE) |
| 273 | redisplay_preserve_echo_area (); | 273 | redisplay_preserve_echo_area (); |
| 274 | immediate_quit = 1; | 274 | immediate_quit = 1; |
| 275 | QUIT; | 275 | QUIT; |
| @@ -337,7 +337,7 @@ If you quit, the process is killed with SIGKILL.") | |||
| 337 | Fwrite_region (start, end, filename_string, Qnil, Qlambda); | 337 | Fwrite_region (start, end, filename_string, Qnil, Qlambda); |
| 338 | record_unwind_protect (delete_temp_file, filename_string); | 338 | record_unwind_protect (delete_temp_file, filename_string); |
| 339 | 339 | ||
| 340 | if (!NULL (args[3])) | 340 | if (!NILP (args[3])) |
| 341 | Fdelete_region (start, end); | 341 | Fdelete_region (start, end); |
| 342 | 342 | ||
| 343 | args[3] = filename_string; | 343 | args[3] = filename_string; |
| @@ -456,6 +456,66 @@ child_setup (in, out, err, new_argv, env, set_pgrp) | |||
| 456 | _exit (1); | 456 | _exit (1); |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | static int | ||
| 460 | getenv_internal (var, varlen, value, valuelen) | ||
| 461 | char *var; | ||
| 462 | int varlen; | ||
| 463 | char **value; | ||
| 464 | int *valuelen; | ||
| 465 | { | ||
| 466 | Lisp_Object scan; | ||
| 467 | |||
| 468 | for (scan = Vprocess_environment; CONSP (scan); scan = XCONS (scan)->cdr) | ||
| 469 | { | ||
| 470 | Lisp_Object entry = XCONS (scan)->car; | ||
| 471 | |||
| 472 | if (XTYPE (entry) == Lisp_String | ||
| 473 | && XSTRING (entry)->size > varlen | ||
| 474 | && XSTRING (entry)->data[varlen] == '=' | ||
| 475 | && ! bcmp (XSTRING (entry)->data, var, varlen)) | ||
| 476 | { | ||
| 477 | *value = (char *) XSTRING (entry)->data + (varlen + 1); | ||
| 478 | *valuelen = XSTRING (entry)->size - (varlen + 1); | ||
| 479 | return 1; | ||
| 480 | } | ||
| 481 | } | ||
| 482 | |||
| 483 | return 0; | ||
| 484 | } | ||
| 485 | |||
| 486 | DEFUN ("getenv", Fgetenv, Sgetenv, 1, 2, 0, | ||
| 487 | "Return the value of environment variable VAR, as a string.\n\ | ||
| 488 | VAR should be a string. Value is nil if VAR is undefined in the environment.\n\ | ||
| 489 | This function consults the variable ``process-environment'' for its value.") | ||
| 490 | (var) | ||
| 491 | Lisp_Object var; | ||
| 492 | { | ||
| 493 | char *value; | ||
| 494 | int valuelen; | ||
| 495 | |||
| 496 | CHECK_STRING (var, 0); | ||
| 497 | if (getenv_internal (XSTRING (var)->data, XSTRING (var)->size, | ||
| 498 | &value, &valuelen)) | ||
| 499 | return make_string (value, valuelen); | ||
| 500 | else | ||
| 501 | return Qnil; | ||
| 502 | } | ||
| 503 | |||
| 504 | /* A version of getenv that consults process_environment, easily | ||
| 505 | callable from C. */ | ||
| 506 | char * | ||
| 507 | egetenv (var) | ||
| 508 | char *var; | ||
| 509 | { | ||
| 510 | char *value; | ||
| 511 | int valuelen; | ||
| 512 | |||
| 513 | if (getenv_internal (var, strlen (var), &value, &valuelen)) | ||
| 514 | return value; | ||
| 515 | else | ||
| 516 | return 0; | ||
| 517 | } | ||
| 518 | |||
| 459 | #endif /* not VMS */ | 519 | #endif /* not VMS */ |
| 460 | 520 | ||
| 461 | init_callproc () | 521 | init_callproc () |
| @@ -522,4 +582,5 @@ Each string should have the format ENVVARNAME=VALUE."); | |||
| 522 | defsubr (&Scall_process); | 582 | defsubr (&Scall_process); |
| 523 | #endif | 583 | #endif |
| 524 | defsubr (&Scall_process_region); | 584 | defsubr (&Scall_process_region); |
| 585 | defsubr (&Sgetenv); | ||
| 525 | } | 586 | } |