comparison src/lread.c @ 10200:899f5bd94bbb

(Qload_file_name, Vload_file_name): New variables. (syms_of_lread): Initialize and staticpro it. (Fload): Bind it. (read_list): Before dumping, ignore (#$ . WHATEVER)--return 0.
author Richard M. Stallman <rms@gnu.org>
date Wed, 21 Dec 1994 18:14:20 +0000
parents 70b04b218216
children 97b210b19217
comparison
equal deleted inserted replaced
10199:3e2571e22b61 10200:899f5bd94bbb
65 65
66 extern int errno; 66 extern int errno;
67 67
68 Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list; 68 Lisp_Object Qread_char, Qget_file_char, Qstandard_input, Qcurrent_load_list;
69 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; 69 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist;
70 Lisp_Object Qascii_character, Qload; 70 Lisp_Object Qascii_character, Qload, Qload_file_name;
71 71
72 extern Lisp_Object Qevent_symbol_element_mask; 72 extern Lisp_Object Qevent_symbol_element_mask;
73 73
74 /* non-zero if inside `load' */ 74 /* non-zero if inside `load' */
75 int load_in_progress; 75 int load_in_progress;
79 79
80 /* This is the user-visible association list that maps features to 80 /* This is the user-visible association list that maps features to
81 lists of defs in their load files. */ 81 lists of defs in their load files. */
82 Lisp_Object Vload_history; 82 Lisp_Object Vload_history;
83 83
84 /* This is useud to build the load history. */ 84 /* This is used to build the load history. */
85 Lisp_Object Vcurrent_load_list; 85 Lisp_Object Vcurrent_load_list;
86
87 /* Name of file actually being read by `load'. */
88 Lisp_Object Vload_file_name;
86 89
87 /* List of descriptors now open for Fload. */ 90 /* List of descriptors now open for Fload. */
88 static Lisp_Object load_descriptor_list; 91 static Lisp_Object load_descriptor_list;
89 92
90 /* File for get_file_char to read from. Use by load */ 93 /* File for get_file_char to read from. Use by load */
434 lispstream = Fcons (Qnil, Qnil); 437 lispstream = Fcons (Qnil, Qnil);
435 XSETFASTINT (XCONS (lispstream)->car, (EMACS_UINT)stream >> 16); 438 XSETFASTINT (XCONS (lispstream)->car, (EMACS_UINT)stream >> 16);
436 XSETFASTINT (XCONS (lispstream)->cdr, (EMACS_UINT)stream & 0xffff); 439 XSETFASTINT (XCONS (lispstream)->cdr, (EMACS_UINT)stream & 0xffff);
437 record_unwind_protect (load_unwind, lispstream); 440 record_unwind_protect (load_unwind, lispstream);
438 record_unwind_protect (load_descriptor_unwind, load_descriptor_list); 441 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
442 specbind (Qload_file_name, found);
439 load_descriptor_list 443 load_descriptor_list
440 = Fcons (make_number (fileno (stream)), load_descriptor_list); 444 = Fcons (make_number (fileno (stream)), load_descriptor_list);
441 load_in_progress++; 445 load_in_progress++;
442 readevalloop (Qget_file_char, stream, str, Feval, 0); 446 readevalloop (Qget_file_char, stream, str, Feval, 0);
443 unbind_to (count, Qnil); 447 unbind_to (count, Qnil);
1181 } 1185 }
1182 UNGCPRO; 1186 UNGCPRO;
1183 return tmp; 1187 return tmp;
1184 } 1188 }
1185 #endif 1189 #endif
1190 /* #@NUMBER is used to skip NUMBER following characters.
1191 That's used in .elc files to skip over doc strings
1192 and function definitions. */
1193 if (c == '@')
1194 {
1195 int i, nskip = 0;
1196
1197 /* Read a decimal integer. */
1198 while ((c = READCHAR) >= 0
1199 && c >= '0' && c <= '9')
1200 {
1201 nskip *= 10;
1202 nskip += c - '0';
1203 }
1204 if (c >= 0)
1205 UNREAD (c);
1206
1207 /* Skip that many characters. */
1208 for (i = 0; i < nskip && c >= 0; i++)
1209 c = READCHAR;
1210 goto retry;
1211 }
1212 if (c == '$')
1213 return Vload_file_name;
1214
1186 UNREAD (c); 1215 UNREAD (c);
1187 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil)); 1216 Fsignal (Qinvalid_read_syntax, Fcons (make_string ("#", 1), Qnil));
1188 1217
1189 case ';': 1218 case ';':
1190 while ((c = READCHAR) >= 0 && c != '\n'); 1219 while ((c = READCHAR) >= 0 && c != '\n');
1469 1 means already checked and found defun. */ 1498 1 means already checked and found defun. */
1470 int defunflag = flag < 0 ? -1 : 0; 1499 int defunflag = flag < 0 ? -1 : 0;
1471 Lisp_Object val, tail; 1500 Lisp_Object val, tail;
1472 register Lisp_Object elt, tem; 1501 register Lisp_Object elt, tem;
1473 struct gcpro gcpro1, gcpro2; 1502 struct gcpro gcpro1, gcpro2;
1503 int cancel = 0;
1474 1504
1475 val = Qnil; 1505 val = Qnil;
1476 tail = Qnil; 1506 tail = Qnil;
1477 1507
1478 while (1) 1508 while (1)
1479 { 1509 {
1480 char ch; 1510 char ch;
1481 GCPRO2 (val, tail); 1511 GCPRO2 (val, tail);
1482 elt = read1 (readcharfun, &ch); 1512 elt = read1 (readcharfun, &ch);
1483 UNGCPRO; 1513 UNGCPRO;
1514
1515 /* If purifying, and the list starts with #$,
1516 return 0 instead. This is a doc string reference
1517 and it will be replaced anyway by Snarf-documentation,
1518 so don't waste pure space with it. */
1519 if (EQ (elt, Vload_file_name)
1520 && !NILP (Vpurify_flag) && NILP (Vdoc_file_name))
1521 cancel = 1;
1522
1484 if (ch) 1523 if (ch)
1485 { 1524 {
1486 if (flag > 0) 1525 if (flag > 0)
1487 { 1526 {
1488 if (ch == ']') 1527 if (ch == ']')
1499 else 1538 else
1500 val = read0 (readcharfun); 1539 val = read0 (readcharfun);
1501 read1 (readcharfun, &ch); 1540 read1 (readcharfun, &ch);
1502 UNGCPRO; 1541 UNGCPRO;
1503 if (ch == ')') 1542 if (ch == ')')
1504 return val; 1543 return (cancel ? make_number (0) : val);
1505 return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil)); 1544 return Fsignal (Qinvalid_read_syntax, Fcons (make_string (". in wrong context", 18), Qnil));
1506 } 1545 }
1507 return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil)); 1546 return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil));
1508 } 1547 }
1509 tem = (read_pure && flag <= 0 1548 tem = (read_pure && flag <= 0
2018 definitions evaluated from buffers not visiting files.\n\ 2057 definitions evaluated from buffers not visiting files.\n\
2019 The remaining elements of each list are symbols defined as functions\n\ 2058 The remaining elements of each list are symbols defined as functions\n\
2020 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'."); 2059 or variables, and cons cells `(provide . FEATURE)' and `(require . FEATURE)'.");
2021 Vload_history = Qnil; 2060 Vload_history = Qnil;
2022 2061
2062 DEFVAR_LISP ("load-file-name", &Vload_file_name,
2063 "Full name of file being loaded by `load'.");
2064 Vload_file_name = Qnil;
2065
2023 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list, 2066 DEFVAR_LISP ("current-load-list", &Vcurrent_load_list,
2024 "Used for internal purposes by `load'."); 2067 "Used for internal purposes by `load'.");
2025 Vcurrent_load_list = Qnil; 2068 Vcurrent_load_list = Qnil;
2026 2069
2027 load_descriptor_list = Qnil; 2070 load_descriptor_list = Qnil;
2042 Qascii_character = intern ("ascii-character"); 2085 Qascii_character = intern ("ascii-character");
2043 staticpro (&Qascii_character); 2086 staticpro (&Qascii_character);
2044 2087
2045 Qload = intern ("load"); 2088 Qload = intern ("load");
2046 staticpro (&Qload); 2089 staticpro (&Qload);
2047 } 2090
2091 Qload_file_name = intern ("load-file-name");
2092 staticpro (&Qload_file_name);
2093 }