diff options
| author | Richard M. Stallman | 1997-01-27 00:48:16 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-01-27 00:48:16 +0000 |
| commit | 74549846a63692215ebe93c1cfbbfc261eedd8b3 (patch) | |
| tree | de3e1308a360ee891a990b00bdbf19a7ba422827 /src/lread.c | |
| parent | b3da9d80a7aa0cb8db8f52f55ff2048e47e1caf6 (diff) | |
| download | emacs-74549846a63692215ebe93c1cfbbfc261eedd8b3.tar.gz emacs-74549846a63692215ebe93c1cfbbfc261eedd8b3.zip | |
(openp): Handle remote file names in path.
Don't use the path for an absolute name.
(Fload): Handle openp finding a remote file name.
(Qinhibit_file_name_operation): New variable.
(syms_of_lread): Initialize and staticpro.
(Fload): Bind inhibit-file-name-operation to nil.
Diffstat (limited to 'src/lread.c')
| -rw-r--r-- | src/lread.c | 71 |
1 files changed, 59 insertions, 12 deletions
diff --git a/src/lread.c b/src/lread.c index 55904b96b4f..4441b022dcc 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -73,8 +73,10 @@ Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list; | |||
| 73 | Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; | 73 | Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; |
| 74 | Lisp_Object Qascii_character, Qload, Qload_file_name; | 74 | Lisp_Object Qascii_character, Qload, Qload_file_name; |
| 75 | Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; | 75 | Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; |
| 76 | Lisp_Object Qinhibit_file_name_operation; | ||
| 76 | 77 | ||
| 77 | extern Lisp_Object Qevent_symbol_element_mask; | 78 | extern Lisp_Object Qevent_symbol_element_mask; |
| 79 | extern Lisp_Object Qfile_exists_p; | ||
| 78 | 80 | ||
| 79 | /* non-zero if inside `load' */ | 81 | /* non-zero if inside `load' */ |
| 80 | int load_in_progress; | 82 | int load_in_progress; |
| @@ -433,6 +435,13 @@ Return t if file exists.") | |||
| 433 | return Qnil; | 435 | return Qnil; |
| 434 | } | 436 | } |
| 435 | 437 | ||
| 438 | /* If FD is 0, that means openp found a remote file. */ | ||
| 439 | if (fd == 0) | ||
| 440 | { | ||
| 441 | handler = Ffind_file_name_handler (found, Qload); | ||
| 442 | return call5 (handler, Qload, found, noerror, nomessage, Qt); | ||
| 443 | } | ||
| 444 | |||
| 436 | if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]), | 445 | if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]), |
| 437 | ".elc", 4)) | 446 | ".elc", 4)) |
| 438 | { | 447 | { |
| @@ -490,6 +499,7 @@ Return t if file exists.") | |||
| 490 | record_unwind_protect (load_unwind, lispstream); | 499 | record_unwind_protect (load_unwind, lispstream); |
| 491 | record_unwind_protect (load_descriptor_unwind, load_descriptor_list); | 500 | record_unwind_protect (load_descriptor_unwind, load_descriptor_list); |
| 492 | specbind (Qload_file_name, found); | 501 | specbind (Qload_file_name, found); |
| 502 | specbind (Qinhibit_file_name_operation, Qnil); | ||
| 493 | load_descriptor_list | 503 | load_descriptor_list |
| 494 | = Fcons (make_number (fileno (stream)), load_descriptor_list); | 504 | = Fcons (make_number (fileno (stream)), load_descriptor_list); |
| 495 | load_in_progress++; | 505 | load_in_progress++; |
| @@ -579,7 +589,11 @@ complete_filename_p (pathname) | |||
| 579 | 589 | ||
| 580 | If STOREPTR is nonzero, it points to a slot where the name of | 590 | If STOREPTR is nonzero, it points to a slot where the name of |
| 581 | the file actually found should be stored as a Lisp string. | 591 | the file actually found should be stored as a Lisp string. |
| 582 | Nil is stored there on failure. */ | 592 | nil is stored there on failure. |
| 593 | |||
| 594 | If the file we find is remote, return 0 | ||
| 595 | but store the found remote file name in *STOREPTR. | ||
| 596 | We do not check for remote files if EXEC_ONLY is nonzero. */ | ||
| 583 | 597 | ||
| 584 | int | 598 | int |
| 585 | openp (path, str, suffix, storeptr, exec_only) | 599 | openp (path, str, suffix, storeptr, exec_only) |
| @@ -594,7 +608,7 @@ openp (path, str, suffix, storeptr, exec_only) | |||
| 594 | register char *fn = buf; | 608 | register char *fn = buf; |
| 595 | int absolute = 0; | 609 | int absolute = 0; |
| 596 | int want_size; | 610 | int want_size; |
| 597 | register Lisp_Object filename; | 611 | Lisp_Object filename; |
| 598 | struct stat st; | 612 | struct stat st; |
| 599 | struct gcpro gcpro1; | 613 | struct gcpro gcpro1; |
| 600 | 614 | ||
| @@ -634,6 +648,7 @@ openp (path, str, suffix, storeptr, exec_only) | |||
| 634 | { | 648 | { |
| 635 | char *esuffix = (char *) index (nsuffix, ':'); | 649 | char *esuffix = (char *) index (nsuffix, ':'); |
| 636 | int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix); | 650 | int lsuffix = esuffix ? esuffix - nsuffix : strlen (nsuffix); |
| 651 | Lisp_Object handler; | ||
| 637 | 652 | ||
| 638 | /* Concatenate path element/specified name with the suffix. | 653 | /* Concatenate path element/specified name with the suffix. |
| 639 | If the directory starts with /:, remove that. */ | 654 | If the directory starts with /:, remove that. */ |
| @@ -654,23 +669,52 @@ openp (path, str, suffix, storeptr, exec_only) | |||
| 654 | if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */ | 669 | if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */ |
| 655 | strncat (fn, nsuffix, lsuffix); | 670 | strncat (fn, nsuffix, lsuffix); |
| 656 | 671 | ||
| 657 | /* Ignore file if it's a directory. */ | 672 | /* Check that the file exists and is not a directory. */ |
| 658 | if (stat (fn, &st) >= 0 | 673 | if (absolute) |
| 659 | && (st.st_mode & S_IFMT) != S_IFDIR) | 674 | handler = Qnil; |
| 675 | else | ||
| 676 | handler = Ffind_file_name_handler (filename, Qfile_exists_p); | ||
| 677 | if (! NILP (handler) && ! exec_only) | ||
| 660 | { | 678 | { |
| 661 | /* Check that we can access or open it. */ | 679 | Lisp_Object string; |
| 662 | if (exec_only) | 680 | int exists; |
| 663 | fd = (access (fn, X_OK) == 0) ? 1 : -1; | ||
| 664 | else | ||
| 665 | fd = open (fn, O_RDONLY, 0); | ||
| 666 | 681 | ||
| 667 | if (fd >= 0) | 682 | string = build_string (fn); |
| 683 | exists = ! NILP (exec_only ? Ffile_executable_p (string) | ||
| 684 | : Ffile_readable_p (string)); | ||
| 685 | if (exists | ||
| 686 | && ! NILP (Ffile_directory_p (build_string (fn)))) | ||
| 687 | exists = 0; | ||
| 688 | |||
| 689 | if (exists) | ||
| 668 | { | 690 | { |
| 669 | /* We succeeded; return this descriptor and filename. */ | 691 | /* We succeeded; return this descriptor and filename. */ |
| 670 | if (storeptr) | 692 | if (storeptr) |
| 671 | *storeptr = build_string (fn); | 693 | *storeptr = build_string (fn); |
| 672 | UNGCPRO; | 694 | UNGCPRO; |
| 673 | return fd; | 695 | return 0; |
| 696 | } | ||
| 697 | } | ||
| 698 | else | ||
| 699 | { | ||
| 700 | int exists = (stat (fn, &st) >= 0 | ||
| 701 | && (st.st_mode & S_IFMT) != S_IFDIR); | ||
| 702 | if (exists) | ||
| 703 | { | ||
| 704 | /* Check that we can access or open it. */ | ||
| 705 | if (exec_only) | ||
| 706 | fd = (access (fn, X_OK) == 0) ? 1 : -1; | ||
| 707 | else | ||
| 708 | fd = open (fn, O_RDONLY, 0); | ||
| 709 | |||
| 710 | if (fd >= 0) | ||
| 711 | { | ||
| 712 | /* We succeeded; return this descriptor and filename. */ | ||
| 713 | if (storeptr) | ||
| 714 | *storeptr = build_string (fn); | ||
| 715 | UNGCPRO; | ||
| 716 | return fd; | ||
| 717 | } | ||
| 674 | } | 718 | } |
| 675 | } | 719 | } |
| 676 | 720 | ||
| @@ -2591,6 +2635,9 @@ You cannot count on them to still be there!"); | |||
| 2591 | Qcomma_dot = intern (",."); | 2635 | Qcomma_dot = intern (",."); |
| 2592 | staticpro (&Qcomma_dot); | 2636 | staticpro (&Qcomma_dot); |
| 2593 | 2637 | ||
| 2638 | Qinhibit_file_name_operation = intern ("inhibit-file-name-operation"); | ||
| 2639 | staticpro (&Qinhibit_file_name_operation); | ||
| 2640 | |||
| 2594 | Qascii_character = intern ("ascii-character"); | 2641 | Qascii_character = intern ("ascii-character"); |
| 2595 | staticpro (&Qascii_character); | 2642 | staticpro (&Qascii_character); |
| 2596 | 2643 | ||