Mercurial > emacs
comparison src/lread.c @ 485:8c615e453683
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Mon, 13 Jan 1992 21:48:08 +0000 |
parents | ffdbf3445088 |
children | 63a8e7b3c547 |
comparison
equal
deleted
inserted
replaced
484:3165b2697c78 | 485:8c615e453683 |
---|---|
120 return c; | 120 return c; |
121 } | 121 } |
122 | 122 |
123 tem = call0 (readcharfun); | 123 tem = call0 (readcharfun); |
124 | 124 |
125 if (NULL (tem)) | 125 if (NILP (tem)) |
126 return -1; | 126 return -1; |
127 return XINT (tem); | 127 return XINT (tem); |
128 } | 128 } |
129 | 129 |
130 /* Unread the character C in the way appropriate for the stream READCHARFUN. | 130 /* Unread the character C in the way appropriate for the stream READCHARFUN. |
248 | 248 |
249 /* Avoid weird lossage with null string as arg, | 249 /* Avoid weird lossage with null string as arg, |
250 since it would try to load a directory as a Lisp file */ | 250 since it would try to load a directory as a Lisp file */ |
251 if (XSTRING (str)->size > 0) | 251 if (XSTRING (str)->size > 0) |
252 { | 252 { |
253 fd = openp (Vload_path, str, !NULL (nosuffix) ? "" : ".elc:.el:", | 253 fd = openp (Vload_path, str, !NILP (nosuffix) ? "" : ".elc:.el:", |
254 &found, 0); | 254 &found, 0); |
255 } | 255 } |
256 | 256 |
257 if (fd < 0) | 257 if (fd < 0) |
258 { | 258 { |
259 if (NULL (noerror)) | 259 if (NILP (noerror)) |
260 while (1) | 260 while (1) |
261 Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"), | 261 Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"), |
262 Fcons (str, Qnil))); | 262 Fcons (str, Qnil))); |
263 else | 263 else |
264 return Qnil; | 264 return Qnil; |
284 { | 284 { |
285 close (fd); | 285 close (fd); |
286 error ("Failure to create stdio stream for %s", XSTRING (str)->data); | 286 error ("Failure to create stdio stream for %s", XSTRING (str)->data); |
287 } | 287 } |
288 | 288 |
289 if (NULL (nomessage)) | 289 if (NILP (nomessage)) |
290 message ("Loading %s...", XSTRING (str)->data); | 290 message ("Loading %s...", XSTRING (str)->data); |
291 | 291 |
292 GCPRO1 (str); | 292 GCPRO1 (str); |
293 /* We may not be able to store STREAM itself as a Lisp_Object pointer | 293 /* We may not be able to store STREAM itself as a Lisp_Object pointer |
294 since that is guaranteed to work only for data that has been malloc'd. | 294 since that is guaranteed to work only for data that has been malloc'd. |
301 readevalloop (Qget_file_char, stream, Feval, 0); | 301 readevalloop (Qget_file_char, stream, Feval, 0); |
302 unbind_to (count, Qnil); | 302 unbind_to (count, Qnil); |
303 | 303 |
304 /* Run any load-hooks for this file. */ | 304 /* Run any load-hooks for this file. */ |
305 temp = Fassoc (str, Vafter_load_alist); | 305 temp = Fassoc (str, Vafter_load_alist); |
306 if (!NULL (temp)) | 306 if (!NILP (temp)) |
307 Fprogn (Fcdr (temp)); | 307 Fprogn (Fcdr (temp)); |
308 UNGCPRO; | 308 UNGCPRO; |
309 | 309 |
310 if (!noninteractive && NULL (nomessage)) | 310 if (!noninteractive && NILP (nomessage)) |
311 message ("Loading %s...done", XSTRING (str)->data); | 311 message ("Loading %s...done", XSTRING (str)->data); |
312 return Qt; | 312 return Qt; |
313 } | 313 } |
314 | 314 |
315 static Lisp_Object | 315 static Lisp_Object |
371 *storeptr = Qnil; | 371 *storeptr = Qnil; |
372 | 372 |
373 if (complete_filename_p (str)) | 373 if (complete_filename_p (str)) |
374 absolute = 1; | 374 absolute = 1; |
375 | 375 |
376 for (; !NULL (path); path = Fcdr (path)) | 376 for (; !NILP (path); path = Fcdr (path)) |
377 { | 377 { |
378 char *nsuffix; | 378 char *nsuffix; |
379 | 379 |
380 filename = Fexpand_file_name (str, Fcar (path)); | 380 filename = Fexpand_file_name (str, Fcar (path)); |
381 if (!complete_filename_p (filename)) | 381 if (!complete_filename_p (filename)) |
470 continue; | 470 continue; |
471 } | 471 } |
472 if (c < 0) break; | 472 if (c < 0) break; |
473 if (c == ' ' || c == '\t' || c == '\n' || c == '\f') continue; | 473 if (c == ' ' || c == '\t' || c == '\n' || c == '\f') continue; |
474 | 474 |
475 if (!NULL (Vpurify_flag) && c == '(') | 475 if (!NILP (Vpurify_flag) && c == '(') |
476 { | 476 { |
477 record_unwind_protect (unreadpure, Qnil); | 477 record_unwind_protect (unreadpure, Qnil); |
478 val = read_list (-1, readcharfun); | 478 val = read_list (-1, readcharfun); |
479 unbind_to (count + 1, Qnil); | 479 unbind_to (count + 1, Qnil); |
480 } | 480 } |
511 Lisp_Object printflag; | 511 Lisp_Object printflag; |
512 { | 512 { |
513 int count = specpdl_ptr - specpdl; | 513 int count = specpdl_ptr - specpdl; |
514 Lisp_Object tem; | 514 Lisp_Object tem; |
515 | 515 |
516 if (NULL (printflag)) | 516 if (NILP (printflag)) |
517 tem = Qsymbolp; | 517 tem = Qsymbolp; |
518 else | 518 else |
519 tem = printflag; | 519 tem = printflag; |
520 specbind (Qstandard_output, tem); | 520 specbind (Qstandard_output, tem); |
521 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 521 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
522 SET_PT (BEGV); | 522 SET_PT (BEGV); |
523 readevalloop (Fcurrent_buffer (), 0, Feval, !NULL (printflag)); | 523 readevalloop (Fcurrent_buffer (), 0, Feval, !NILP (printflag)); |
524 return unbind_to (count, Qnil); | 524 return unbind_to (count, Qnil); |
525 } | 525 } |
526 | 526 |
527 DEFUN ("eval-region", Feval_region, Seval_region, 2, 3, "r", | 527 DEFUN ("eval-region", Feval_region, Seval_region, 2, 3, "r", |
528 "Execute the region as Lisp code.\n\ | 528 "Execute the region as Lisp code.\n\ |
538 Lisp_Object b, e, printflag; | 538 Lisp_Object b, e, printflag; |
539 { | 539 { |
540 int count = specpdl_ptr - specpdl; | 540 int count = specpdl_ptr - specpdl; |
541 Lisp_Object tem; | 541 Lisp_Object tem; |
542 | 542 |
543 if (NULL (printflag)) | 543 if (NILP (printflag)) |
544 tem = Qsymbolp; | 544 tem = Qsymbolp; |
545 else | 545 else |
546 tem = printflag; | 546 tem = printflag; |
547 specbind (Qstandard_output, tem); | 547 specbind (Qstandard_output, tem); |
548 | 548 |
549 if (NULL (printflag)) | 549 if (NILP (printflag)) |
550 record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 550 record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
551 record_unwind_protect (save_restriction_restore, save_restriction_save ()); | 551 record_unwind_protect (save_restriction_restore, save_restriction_save ()); |
552 | 552 |
553 /* This both uses b and checks its type. */ | 553 /* This both uses b and checks its type. */ |
554 Fgoto_char (b); | 554 Fgoto_char (b); |
555 Fnarrow_to_region (make_number (BEGV), e); | 555 Fnarrow_to_region (make_number (BEGV), e); |
556 readevalloop (Fcurrent_buffer (), 0, Feval, !NULL (printflag)); | 556 readevalloop (Fcurrent_buffer (), 0, Feval, !NILP (printflag)); |
557 | 557 |
558 return unbind_to (count, Qnil); | 558 return unbind_to (count, Qnil); |
559 } | 559 } |
560 | 560 |
561 #endif /* standalone */ | 561 #endif /* standalone */ |
573 (readcharfun) | 573 (readcharfun) |
574 Lisp_Object readcharfun; | 574 Lisp_Object readcharfun; |
575 { | 575 { |
576 extern Lisp_Object Fread_minibuffer (); | 576 extern Lisp_Object Fread_minibuffer (); |
577 | 577 |
578 if (NULL (readcharfun)) | 578 if (NILP (readcharfun)) |
579 readcharfun = Vstandard_input; | 579 readcharfun = Vstandard_input; |
580 if (EQ (readcharfun, Qt)) | 580 if (EQ (readcharfun, Qt)) |
581 readcharfun = Qread_char; | 581 readcharfun = Qread_char; |
582 | 582 |
583 #ifndef standalone | 583 #ifndef standalone |
602 int startval, endval; | 602 int startval, endval; |
603 Lisp_Object tem; | 603 Lisp_Object tem; |
604 | 604 |
605 CHECK_STRING (string,0); | 605 CHECK_STRING (string,0); |
606 | 606 |
607 if (NULL (end)) | 607 if (NILP (end)) |
608 endval = XSTRING (string)->size; | 608 endval = XSTRING (string)->size; |
609 else | 609 else |
610 { CHECK_NUMBER (end,2); | 610 { CHECK_NUMBER (end,2); |
611 endval = XINT (end); | 611 endval = XINT (end); |
612 if (endval < 0 || endval > XSTRING (string)->size) | 612 if (endval < 0 || endval > XSTRING (string)->size) |
613 args_out_of_range (string, end); | 613 args_out_of_range (string, end); |
614 } | 614 } |
615 | 615 |
616 if (NULL (start)) | 616 if (NILP (start)) |
617 startval = 0; | 617 startval = 0; |
618 else | 618 else |
619 { CHECK_NUMBER (start,1); | 619 { CHECK_NUMBER (start,1); |
620 startval = XINT (start); | 620 startval = XINT (start); |
621 if (startval < 0 || startval > endval) | 621 if (startval < 0 || startval > endval) |
657 { | 657 { |
658 register int c = READCHAR; | 658 register int c = READCHAR; |
659 switch (c) | 659 switch (c) |
660 { | 660 { |
661 case 'a': | 661 case 'a': |
662 return '\a'; | 662 return '\007'; |
663 case 'b': | 663 case 'b': |
664 return '\b'; | 664 return '\b'; |
665 case 'e': | 665 case 'e': |
666 return 033; | 666 return 033; |
667 case 'f': | 667 case 'f': |
857 if (c < 0) return Fsignal (Qend_of_file, Qnil); | 857 if (c < 0) return Fsignal (Qend_of_file, Qnil); |
858 | 858 |
859 /* If purifying, and string starts with \ newline, | 859 /* If purifying, and string starts with \ newline, |
860 return zero instead. This is for doc strings | 860 return zero instead. This is for doc strings |
861 that we are really going to find in share-lib/DOC.nn.nn */ | 861 that we are really going to find in share-lib/DOC.nn.nn */ |
862 if (!NULL (Vpurify_flag) && NULL (Vdoc_file_name) && cancel) | 862 if (!NILP (Vpurify_flag) && NILP (Vdoc_file_name) && cancel) |
863 return make_number (0); | 863 return make_number (0); |
864 | 864 |
865 if (read_pure) | 865 if (read_pure) |
866 return make_pure_string (read_buffer, p - read_buffer); | 866 return make_pure_string (read_buffer, p - read_buffer); |
867 else | 867 else |
1058 if (XINT (elt) == ')') | 1058 if (XINT (elt) == ')') |
1059 return val; | 1059 return val; |
1060 if (XINT (elt) == '.') | 1060 if (XINT (elt) == '.') |
1061 { | 1061 { |
1062 GCPRO2 (val, tail); | 1062 GCPRO2 (val, tail); |
1063 if (!NULL (tail)) | 1063 if (!NILP (tail)) |
1064 XCONS (tail)->cdr = read0 (readcharfun); | 1064 XCONS (tail)->cdr = read0 (readcharfun); |
1065 else | 1065 else |
1066 val = read0 (readcharfun); | 1066 val = read0 (readcharfun); |
1067 elt = read1 (readcharfun); | 1067 elt = read1 (readcharfun); |
1068 UNGCPRO; | 1068 UNGCPRO; |
1073 return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil)); | 1073 return Fsignal (Qinvalid_read_syntax, Fcons (make_string ("] in a list", 11), Qnil)); |
1074 } | 1074 } |
1075 tem = (read_pure && flag <= 0 | 1075 tem = (read_pure && flag <= 0 |
1076 ? pure_cons (elt, Qnil) | 1076 ? pure_cons (elt, Qnil) |
1077 : Fcons (elt, Qnil)); | 1077 : Fcons (elt, Qnil)); |
1078 if (!NULL (tail)) | 1078 if (!NILP (tail)) |
1079 XCONS (tail)->cdr = tem; | 1079 XCONS (tail)->cdr = tem; |
1080 else | 1080 else |
1081 val = tem; | 1081 val = tem; |
1082 tail = tem; | 1082 tail = tem; |
1083 if (defunflag < 0) | 1083 if (defunflag < 0) |
1118 if (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0) | 1118 if (XTYPE (obarray) != Lisp_Vector || XVECTOR (obarray)->size == 0) |
1119 obarray = check_obarray (obarray); | 1119 obarray = check_obarray (obarray); |
1120 tem = oblookup (obarray, str, len); | 1120 tem = oblookup (obarray, str, len); |
1121 if (XTYPE (tem) == Lisp_Symbol) | 1121 if (XTYPE (tem) == Lisp_Symbol) |
1122 return tem; | 1122 return tem; |
1123 return Fintern ((!NULL (Vpurify_flag) | 1123 return Fintern ((!NILP (Vpurify_flag) |
1124 ? make_pure_string (str, len) | 1124 ? make_pure_string (str, len) |
1125 : make_string (str, len)), | 1125 : make_string (str, len)), |
1126 obarray); | 1126 obarray); |
1127 } | 1127 } |
1128 | 1128 |
1134 (str, obarray) | 1134 (str, obarray) |
1135 Lisp_Object str, obarray; | 1135 Lisp_Object str, obarray; |
1136 { | 1136 { |
1137 register Lisp_Object tem, sym, *ptr; | 1137 register Lisp_Object tem, sym, *ptr; |
1138 | 1138 |
1139 if (NULL (obarray)) obarray = Vobarray; | 1139 if (NILP (obarray)) obarray = Vobarray; |
1140 obarray = check_obarray (obarray); | 1140 obarray = check_obarray (obarray); |
1141 | 1141 |
1142 CHECK_STRING (str, 0); | 1142 CHECK_STRING (str, 0); |
1143 | 1143 |
1144 tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size); | 1144 tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size); |
1145 if (XTYPE (tem) != Lisp_Int) | 1145 if (XTYPE (tem) != Lisp_Int) |
1146 return tem; | 1146 return tem; |
1147 | 1147 |
1148 if (!NULL (Vpurify_flag)) | 1148 if (!NILP (Vpurify_flag)) |
1149 str = Fpurecopy (str); | 1149 str = Fpurecopy (str); |
1150 sym = Fmake_symbol (str); | 1150 sym = Fmake_symbol (str); |
1151 | 1151 |
1152 ptr = &XVECTOR (obarray)->contents[XINT (tem)]; | 1152 ptr = &XVECTOR (obarray)->contents[XINT (tem)]; |
1153 if (XTYPE (*ptr) == Lisp_Symbol) | 1153 if (XTYPE (*ptr) == Lisp_Symbol) |
1165 (str, obarray) | 1165 (str, obarray) |
1166 Lisp_Object str, obarray; | 1166 Lisp_Object str, obarray; |
1167 { | 1167 { |
1168 register Lisp_Object tem; | 1168 register Lisp_Object tem; |
1169 | 1169 |
1170 if (NULL (obarray)) obarray = Vobarray; | 1170 if (NILP (obarray)) obarray = Vobarray; |
1171 obarray = check_obarray (obarray); | 1171 obarray = check_obarray (obarray); |
1172 | 1172 |
1173 CHECK_STRING (str, 0); | 1173 CHECK_STRING (str, 0); |
1174 | 1174 |
1175 tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size); | 1175 tem = oblookup (obarray, XSTRING (str)->data, XSTRING (str)->size); |
1268 (function, obarray) | 1268 (function, obarray) |
1269 Lisp_Object function, obarray; | 1269 Lisp_Object function, obarray; |
1270 { | 1270 { |
1271 Lisp_Object tem; | 1271 Lisp_Object tem; |
1272 | 1272 |
1273 if (NULL (obarray)) obarray = Vobarray; | 1273 if (NILP (obarray)) obarray = Vobarray; |
1274 obarray = check_obarray (obarray); | 1274 obarray = check_obarray (obarray); |
1275 | 1275 |
1276 map_obarray (obarray, mapatoms_1, function); | 1276 map_obarray (obarray, mapatoms_1, function); |
1277 return Qnil; | 1277 return Qnil; |
1278 } | 1278 } |
1450 | 1450 |
1451 Vload_path = normal_path; | 1451 Vload_path = normal_path; |
1452 } | 1452 } |
1453 | 1453 |
1454 /* Warn if dirs in the *standard* path don't exist. */ | 1454 /* Warn if dirs in the *standard* path don't exist. */ |
1455 for (; !NULL (normal_path); normal_path = XCONS (normal_path)->cdr) | 1455 for (; !NILP (normal_path); normal_path = XCONS (normal_path)->cdr) |
1456 { | 1456 { |
1457 Lisp_Object dirfile; | 1457 Lisp_Object dirfile; |
1458 dirfile = Fcar (normal_path); | 1458 dirfile = Fcar (normal_path); |
1459 if (!NULL (dirfile)) | 1459 if (!NILP (dirfile)) |
1460 { | 1460 { |
1461 dirfile = Fdirectory_file_name (dirfile); | 1461 dirfile = Fdirectory_file_name (dirfile); |
1462 if (access (XSTRING (dirfile)->data, 0) < 0) | 1462 if (access (XSTRING (dirfile)->data, 0) < 0) |
1463 printf ("Warning: lisp library (%s) does not exist.\n", | 1463 printf ("Warning: lisp library (%s) does not exist.\n", |
1464 XSTRING (Fcar (normal_path))->data); | 1464 XSTRING (Fcar (normal_path))->data); |
1466 } | 1466 } |
1467 | 1467 |
1468 if (egetenv ("EMACSLOADPATH")) | 1468 if (egetenv ("EMACSLOADPATH")) |
1469 Vload_path = decode_env_path ("EMACSLOADPATH", normal); | 1469 Vload_path = decode_env_path ("EMACSLOADPATH", normal); |
1470 #ifndef CANNOT_DUMP | 1470 #ifndef CANNOT_DUMP |
1471 if (!NULL (Vpurify_flag)) | 1471 if (!NILP (Vpurify_flag)) |
1472 Vload_path = Fcons (build_string ("../lisp"), Vload_path); | 1472 Vload_path = Fcons (build_string ("../lisp"), Vload_path); |
1473 #endif | 1473 #endif |
1474 | 1474 |
1475 Vvalues = Qnil; | 1475 Vvalues = Qnil; |
1476 | 1476 |