Mercurial > emacs
comparison src/callproc.c @ 942:c519b70eb50b
Replaced fuctions egetenv, Fgetenv, getenv_internal, which had
disappeared.
author | Joseph Arceneaux <jla@gnu.org> |
---|---|
date | Thu, 06 Aug 1992 03:24:07 +0000 |
parents | 1e2e41fd188b |
children | 928ed74adf4f |
comparison
equal
deleted
inserted
replaced
941:eb8a7ea2798e | 942:c519b70eb50b |
---|---|
126 GCPRO1 (*args); | 126 GCPRO1 (*args); |
127 gcpro1.nvars = nargs; | 127 gcpro1.nvars = nargs; |
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); |
135 | 135 |
136 CHECK_STRING (args[1], 1); | 136 CHECK_STRING (args[1], 1); |
167 { | 167 { |
168 report_file_error ("Opening process input file", Fcons (args[1], Qnil)); | 168 report_file_error ("Opening process input file", Fcons (args[1], Qnil)); |
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)); |
176 } | 176 } |
177 new_argv[0] = XSTRING (path)->data; | 177 new_argv[0] = XSTRING (path)->data; |
265 register int nread; | 265 register int nread; |
266 | 266 |
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; |
276 } | 276 } |
277 } | 277 } |
335 start = args[0]; | 335 start = args[0]; |
336 end = args[1]; | 336 end = args[1]; |
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; |
344 Fcall_process (nargs - 2, args + 2); | 344 Fcall_process (nargs - 2, args + 2); |
345 | 345 |
454 write (1, "Couldn't exec the program ", 26); | 454 write (1, "Couldn't exec the program ", 26); |
455 write (1, new_argv[0], strlen (new_argv[0])); | 455 write (1, new_argv[0], strlen (new_argv[0])); |
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 () |
462 { | 522 { |
463 register char * sh; | 523 register char * sh; |
520 | 580 |
521 #ifndef VMS | 581 #ifndef VMS |
522 defsubr (&Scall_process); | 582 defsubr (&Scall_process); |
523 #endif | 583 #endif |
524 defsubr (&Scall_process_region); | 584 defsubr (&Scall_process_region); |
525 } | 585 defsubr (&Sgetenv); |
586 } |