comparison src/lread.c @ 90260:0ca0d9181b5e

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-95 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 598-615) - Update from CVS - Remove lisp/toolbar directory - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 142-146) - Update from CVS
author Miles Bader <miles@gnu.org>
date Mon, 16 Jan 2006 06:59:21 +0000
parents 2d92f5c9d6ae 236b02d0dac9
children 7beb78bc1f8e
comparison
equal deleted inserted replaced
90259:a3ba65547f84 90260:0ca0d9181b5e
846 If optional fourth arg NOSUFFIX is non-nil, don't try adding 846 If optional fourth arg NOSUFFIX is non-nil, don't try adding
847 suffixes `.elc' or `.el' to the specified name FILE. 847 suffixes `.elc' or `.el' to the specified name FILE.
848 If optional fifth arg MUST-SUFFIX is non-nil, insist on 848 If optional fifth arg MUST-SUFFIX is non-nil, insist on
849 the suffix `.elc' or `.el'; don't accept just FILE unless 849 the suffix `.elc' or `.el'; don't accept just FILE unless
850 it ends in one of those suffixes or includes a directory name. 850 it ends in one of those suffixes or includes a directory name.
851
852 Loading a file records its definitions, and its `provide' and
853 `require' calls, in an element of `load-history' whose
854 car is the file name loaded. See `load-history'.
855
851 Return t if file exists. */) 856 Return t if file exists. */)
852 (file, noerror, nomessage, nosuffix, must_suffix) 857 (file, noerror, nomessage, nosuffix, must_suffix)
853 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix; 858 Lisp_Object file, noerror, nomessage, nosuffix, must_suffix;
854 { 859 {
855 register FILE *stream; 860 register FILE *stream;
856 register int fd = -1; 861 register int fd = -1;
857 int count = SPECPDL_INDEX (); 862 int count = SPECPDL_INDEX ();
858 Lisp_Object temp; 863 Lisp_Object temp;
859 struct gcpro gcpro1; 864 struct gcpro gcpro1, gcpro2;
860 Lisp_Object found, efound; 865 Lisp_Object found, efound;
861 /* 1 means we printed the ".el is newer" message. */ 866 /* 1 means we printed the ".el is newer" message. */
862 int newer = 0; 867 int newer = 0;
863 /* 1 means we are loading a compiled file. */ 868 /* 1 means we are loading a compiled file. */
864 int compiled = 0; 869 int compiled = 0;
903 if (SCHARS (file) > 0) 908 if (SCHARS (file) > 0)
904 { 909 {
905 int size = SBYTES (file); 910 int size = SBYTES (file);
906 Lisp_Object tmp[2]; 911 Lisp_Object tmp[2];
907 912
908 GCPRO1 (file); 913 found = Qnil;
914 GCPRO2 (file, found);
909 915
910 if (! NILP (must_suffix)) 916 if (! NILP (must_suffix))
911 { 917 {
912 /* Don't insist on adding a suffix if FILE already ends with one. */ 918 /* Don't insist on adding a suffix if FILE already ends with one. */
913 if (size > 3 919 if (size > 3
992 if (fd != -2) 998 if (fd != -2)
993 { 999 {
994 struct stat s1, s2; 1000 struct stat s1, s2;
995 int result; 1001 int result;
996 1002
1003 GCPRO2 (file, found);
1004
997 if (version < 0 1005 if (version < 0
998 && ! (version = safe_to_load_p (fd))) 1006 && ! (version = safe_to_load_p (fd)))
999 { 1007 {
1000 safe_p = 0; 1008 safe_p = 0;
1001 if (!load_dangerous_libraries) 1009 if (!load_dangerous_libraries)
1009 message_with_string ("File `%s' not compiled in Emacs", found, 1); 1017 message_with_string ("File `%s' not compiled in Emacs", found, 1);
1010 } 1018 }
1011 1019
1012 compiled = 1; 1020 compiled = 1;
1013 1021
1014 GCPRO1 (efound);
1015 efound = ENCODE_FILE (found); 1022 efound = ENCODE_FILE (found);
1016 1023
1017 #ifdef DOS_NT 1024 #ifdef DOS_NT
1018 fmode = "rb"; 1025 fmode = "rb";
1019 #endif /* DOS_NT */ 1026 #endif /* DOS_NT */
1020 stat ((char *)SDATA (efound), &s1); 1027 stat ((char *)SDATA (efound), &s1);
1021 SSET (efound, SBYTES (efound) - 1, 0); 1028 SSET (efound, SBYTES (efound) - 1, 0);
1022 result = stat ((char *)SDATA (efound), &s2); 1029 result = stat ((char *)SDATA (efound), &s2);
1023 SSET (efound, SBYTES (efound) - 1, 'c'); 1030 SSET (efound, SBYTES (efound) - 1, 'c');
1024 UNGCPRO;
1025 1031
1026 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) 1032 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime)
1027 { 1033 {
1028 /* Make the progress messages mention that source is newer. */ 1034 /* Make the progress messages mention that source is newer. */
1029 newer = 1; 1035 newer = 1;
1030 1036
1031 /* If we won't print another message, mention this anyway. */ 1037 /* If we won't print another message, mention this anyway. */
1032 if (!NILP (nomessage)) 1038 if (!NILP (nomessage))
1033 { 1039 {
1034 Lisp_Object file; 1040 Lisp_Object msg_file;
1035 file = Fsubstring (found, make_number (0), make_number (-1)); 1041 msg_file = Fsubstring (found, make_number (0), make_number (-1));
1036 message_with_string ("Source file `%s' newer than byte-compiled file", 1042 message_with_string ("Source file `%s' newer than byte-compiled file",
1037 file, 1); 1043 msg_file, 1);
1038 } 1044 }
1039 } 1045 }
1046 UNGCPRO;
1040 } 1047 }
1041 } 1048 }
1042 else 1049 else
1043 { 1050 {
1044 /* We are loading a source file (*.el). */ 1051 /* We are loading a source file (*.el). */
1053 NILP (nomessage) ? Qnil : Qt); 1060 NILP (nomessage) ? Qnil : Qt);
1054 return unbind_to (count, val); 1061 return unbind_to (count, val);
1055 } 1062 }
1056 } 1063 }
1057 1064
1065 GCPRO2 (file, found);
1066
1058 #ifdef WINDOWSNT 1067 #ifdef WINDOWSNT
1059 emacs_close (fd); 1068 emacs_close (fd);
1060 GCPRO1 (efound);
1061 efound = ENCODE_FILE (found); 1069 efound = ENCODE_FILE (found);
1062 stream = fopen ((char *) SDATA (efound), fmode); 1070 stream = fopen ((char *) SDATA (efound), fmode);
1063 UNGCPRO;
1064 #else /* not WINDOWSNT */ 1071 #else /* not WINDOWSNT */
1065 stream = fdopen (fd, fmode); 1072 stream = fdopen (fd, fmode);
1066 #endif /* not WINDOWSNT */ 1073 #endif /* not WINDOWSNT */
1067 if (stream == 0) 1074 if (stream == 0)
1068 { 1075 {
1085 file, 1); 1092 file, 1);
1086 else /* The typical case; compiled file newer than source file. */ 1093 else /* The typical case; compiled file newer than source file. */
1087 message_with_string ("Loading %s...", file, 1); 1094 message_with_string ("Loading %s...", file, 1);
1088 } 1095 }
1089 1096
1090 GCPRO1 (file);
1091 record_unwind_protect (load_unwind, make_save_value (stream, 0)); 1097 record_unwind_protect (load_unwind, make_save_value (stream, 0));
1092 record_unwind_protect (load_descriptor_unwind, load_descriptor_list); 1098 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
1093 specbind (Qload_file_name, found); 1099 specbind (Qload_file_name, found);
1094 specbind (Qinhibit_file_name_operation, Qnil); 1100 specbind (Qinhibit_file_name_operation, Qnil);
1095 load_descriptor_list 1101 load_descriptor_list
1096 = Fcons (make_number (fileno (stream)), load_descriptor_list); 1102 = Fcons (make_number (fileno (stream)), load_descriptor_list);
1097 load_in_progress++; 1103 load_in_progress++;
1098 if (! version || version >= 22) 1104 if (! version || version >= 22)
1099 readevalloop (Qget_file_char, stream, file, Feval, 1105 readevalloop (Qget_file_char, stream,
1100 0, Qnil, Qnil, Qnil, Qnil); 1106 (! NILP (Vpurify_flag) ? file : found),
1107 Feval, 0, Qnil, Qnil, Qnil, Qnil);
1101 else 1108 else
1102 { 1109 {
1103 /* We can't handle a file which was compiled with 1110 /* We can't handle a file which was compiled with
1104 byte-compile-dynamic by older version of Emacs. */ 1111 byte-compile-dynamic by older version of Emacs. */
1105 specbind (Qload_force_doc_strings, Qt); 1112 specbind (Qload_force_doc_strings, Qt);
4015 FILENAME can also be a symbol (a feature) and FORMS are then executed 4022 FILENAME can also be a symbol (a feature) and FORMS are then executed
4016 when the corresponding call to `provide' is made. */); 4023 when the corresponding call to `provide' is made. */);
4017 Vafter_load_alist = Qnil; 4024 Vafter_load_alist = Qnil;
4018 4025
4019 DEFVAR_LISP ("load-history", &Vload_history, 4026 DEFVAR_LISP ("load-history", &Vload_history,
4020 doc: /* Alist mapping source file names to symbols and features. 4027 doc: /* Alist mapping file names to symbols and features.
4021 Each alist element is a list that starts with a file name, 4028 Each alist element is a list that starts with a file name,
4022 except for one element (optional) that starts with nil and describes 4029 except for one element (optional) that starts with nil and describes
4023 definitions evaluated from buffers not visiting files. 4030 definitions evaluated from buffers not visiting files.
4024 The remaining elements of each list are symbols defined as variables 4031 The remaining elements of each list are symbols defined as variables
4025 and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)', 4032 and cons cells of the form `(provide . FEATURE)', `(require . FEATURE)',
4026 `(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'. 4033 `(defun . FUNCTION)', `(autoload . SYMBOL)', and `(t . SYMBOL)'.
4027 An element `(t . SYMBOL)' precedes an entry `(defun . FUNCTION)', 4034 An element `(t . SYMBOL)' precedes an entry `(defun . FUNCTION)',
4028 and means that SYMBOL was an autoload before this file redefined it 4035 and means that SYMBOL was an autoload before this file redefined it
4029 as a function. */); 4036 as a function.
4037
4038 For a preloaded file, the file name recorded is relative to the main Lisp
4039 directory. These names are converted to absolute by `file-loadhist-lookup'. */);
4030 Vload_history = Qnil; 4040 Vload_history = Qnil;
4031 4041
4032 DEFVAR_LISP ("load-file-name", &Vload_file_name, 4042 DEFVAR_LISP ("load-file-name", &Vload_file_name,
4033 doc: /* Full name of file being loaded by `load'. */); 4043 doc: /* Full name of file being loaded by `load'. */);
4034 Vload_file_name = Qnil; 4044 Vload_file_name = Qnil;