comparison src/lread.c @ 13036:cd0e7903d0a9

(Fload): Rename arg STR to FILE.
author Richard M. Stallman <rms@gnu.org>
date Fri, 15 Sep 1995 16:45:41 +0000
parents 2c1f71512d5d
children 6182d95acd14
comparison
equal deleted inserted replaced
13035:b8453eab5114 13036:cd0e7903d0a9
366 Print messages at start and end of loading unless\n\ 366 Print messages at start and end of loading unless\n\
367 optional third arg NOMESSAGE is non-nil.\n\ 367 optional third arg NOMESSAGE is non-nil.\n\
368 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\ 368 If optional fourth arg NOSUFFIX is non-nil, don't try adding\n\
369 suffixes `.elc' or `.el' to the specified name FILE.\n\ 369 suffixes `.elc' or `.el' to the specified name FILE.\n\
370 Return t if file exists.") 370 Return t if file exists.")
371 (str, noerror, nomessage, nosuffix) 371 (file, noerror, nomessage, nosuffix)
372 Lisp_Object str, noerror, nomessage, nosuffix; 372 Lisp_Object file, noerror, nomessage, nosuffix;
373 { 373 {
374 register FILE *stream; 374 register FILE *stream;
375 register int fd = -1; 375 register int fd = -1;
376 register Lisp_Object lispstream; 376 register Lisp_Object lispstream;
377 int count = specpdl_ptr - specpdl; 377 int count = specpdl_ptr - specpdl;
383 Lisp_Object handler; 383 Lisp_Object handler;
384 #ifdef DOS_NT 384 #ifdef DOS_NT
385 char *dosmode = "rt"; 385 char *dosmode = "rt";
386 #endif /* DOS_NT */ 386 #endif /* DOS_NT */
387 387
388 CHECK_STRING (str, 0); 388 CHECK_STRING (file, 0);
389 389
390 /* If file name is magic, call the handler. */ 390 /* If file name is magic, call the handler. */
391 handler = Ffind_file_name_handler (str, Qload); 391 handler = Ffind_file_name_handler (file, Qload);
392 if (!NILP (handler)) 392 if (!NILP (handler))
393 return call5 (handler, Qload, str, noerror, nomessage, nosuffix); 393 return call5 (handler, Qload, file, noerror, nomessage, nosuffix);
394 394
395 /* Do this after the handler to avoid 395 /* Do this after the handler to avoid
396 the need to gcpro noerror, nomessage and nosuffix. 396 the need to gcpro noerror, nomessage and nosuffix.
397 (Below here, we care only whether they are nil or not.) */ 397 (Below here, we care only whether they are nil or not.) */
398 str = Fsubstitute_in_file_name (str); 398 file = Fsubstitute_in_file_name (file);
399 399
400 /* Avoid weird lossage with null string as arg, 400 /* Avoid weird lossage with null string as arg,
401 since it would try to load a directory as a Lisp file */ 401 since it would try to load a directory as a Lisp file */
402 if (XSTRING (str)->size > 0) 402 if (XSTRING (file)->size > 0)
403 { 403 {
404 GCPRO1 (str); 404 GCPRO1 (file);
405 fd = openp (Vload_path, str, !NILP (nosuffix) ? "" : ".elc:.el:", 405 fd = openp (Vload_path, file, !NILP (nosuffix) ? "" : ".elc:.el:",
406 &found, 0); 406 &found, 0);
407 UNGCPRO; 407 UNGCPRO;
408 } 408 }
409 409
410 if (fd < 0) 410 if (fd < 0)
411 { 411 {
412 if (NILP (noerror)) 412 if (NILP (noerror))
413 while (1) 413 while (1)
414 Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"), 414 Fsignal (Qfile_error, Fcons (build_string ("Cannot open load file"),
415 Fcons (str, Qnil))); 415 Fcons (file, Qnil)));
416 else 416 else
417 return Qnil; 417 return Qnil;
418 } 418 }
419 419
420 if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]), 420 if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]),
447 stream = fdopen (fd, "r"); 447 stream = fdopen (fd, "r");
448 #endif /* not DOS_NT */ 448 #endif /* not DOS_NT */
449 if (stream == 0) 449 if (stream == 0)
450 { 450 {
451 close (fd); 451 close (fd);
452 error ("Failure to create stdio stream for %s", XSTRING (str)->data); 452 error ("Failure to create stdio stream for %s", XSTRING (file)->data);
453 } 453 }
454 454
455 if (NILP (nomessage) && !nomessage1) 455 if (NILP (nomessage) && !nomessage1)
456 message ("Loading %s...", XSTRING (str)->data); 456 message ("Loading %s...", XSTRING (file)->data);
457 457
458 GCPRO1 (str); 458 GCPRO1 (file);
459 lispstream = Fcons (Qnil, Qnil); 459 lispstream = Fcons (Qnil, Qnil);
460 XSETFASTINT (XCONS (lispstream)->car, (EMACS_UINT)stream >> 16); 460 XSETFASTINT (XCONS (lispstream)->car, (EMACS_UINT)stream >> 16);
461 XSETFASTINT (XCONS (lispstream)->cdr, (EMACS_UINT)stream & 0xffff); 461 XSETFASTINT (XCONS (lispstream)->cdr, (EMACS_UINT)stream & 0xffff);
462 record_unwind_protect (load_unwind, lispstream); 462 record_unwind_protect (load_unwind, lispstream);
463 record_unwind_protect (load_descriptor_unwind, load_descriptor_list); 463 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
464 specbind (Qload_file_name, found); 464 specbind (Qload_file_name, found);
465 load_descriptor_list 465 load_descriptor_list
466 = Fcons (make_number (fileno (stream)), load_descriptor_list); 466 = Fcons (make_number (fileno (stream)), load_descriptor_list);
467 load_in_progress++; 467 load_in_progress++;
468 readevalloop (Qget_file_char, stream, str, Feval, 0); 468 readevalloop (Qget_file_char, stream, file, Feval, 0);
469 unbind_to (count, Qnil); 469 unbind_to (count, Qnil);
470 470
471 /* Run any load-hooks for this file. */ 471 /* Run any load-hooks for this file. */
472 temp = Fassoc (str, Vafter_load_alist); 472 temp = Fassoc (file, Vafter_load_alist);
473 if (!NILP (temp)) 473 if (!NILP (temp))
474 Fprogn (Fcdr (temp)); 474 Fprogn (Fcdr (temp));
475 UNGCPRO; 475 UNGCPRO;
476 476
477 if (saved_doc_string) 477 if (saved_doc_string)
478 free (saved_doc_string); 478 free (saved_doc_string);
479 saved_doc_string = 0; 479 saved_doc_string = 0;
480 saved_doc_string_size = 0; 480 saved_doc_string_size = 0;
481 481
482 if (!noninteractive && NILP (nomessage)) 482 if (!noninteractive && NILP (nomessage))
483 message ("Loading %s...done", XSTRING (str)->data); 483 message ("Loading %s...done", XSTRING (file)->data);
484 return Qt; 484 return Qt;
485 } 485 }
486 486
487 static Lisp_Object 487 static Lisp_Object
488 load_unwind (stream) /* used as unwind-protect function in load */ 488 load_unwind (stream) /* used as unwind-protect function in load */