Mercurial > emacs
comparison src/lread.c @ 26072:1e8b099fba75
(Fload): Calculate bytes of filename correctly.
(openp): Likewise.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 18 Oct 1999 02:11:42 +0000 |
parents | 3d1138357287 |
children | b7aa6ac26872 |
comparison
equal
deleted
inserted
replaced
26071:7a69d4312d7f | 26072:1e8b099fba75 |
---|---|
623 | 623 |
624 /* Avoid weird lossage with null string as arg, | 624 /* Avoid weird lossage with null string as arg, |
625 since it would try to load a directory as a Lisp file */ | 625 since it would try to load a directory as a Lisp file */ |
626 if (XSTRING (file)->size > 0) | 626 if (XSTRING (file)->size > 0) |
627 { | 627 { |
628 int size = XSTRING (file)->size; | 628 int size = STRING_BYTES (XSTRING (file)); |
629 | 629 |
630 GCPRO1 (file); | 630 GCPRO1 (file); |
631 | 631 |
632 if (! NILP (must_suffix)) | 632 if (! NILP (must_suffix)) |
633 { | 633 { |
679 return call5 (handler, Qload, found, noerror, nomessage, Qt); | 679 return call5 (handler, Qload, found, noerror, nomessage, Qt); |
680 } | 680 } |
681 | 681 |
682 /* Load .elc files directly, but not when they are | 682 /* Load .elc files directly, but not when they are |
683 remote and have no handler! */ | 683 remote and have no handler! */ |
684 if (!bcmp (&(XSTRING (found)->data[XSTRING (found)->size - 4]), | 684 if (!bcmp (&(XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 4]), |
685 ".elc", 4) | 685 ".elc", 4) |
686 && fd != 0) | 686 && fd != 0) |
687 { | 687 { |
688 struct stat s1, s2; | 688 struct stat s1, s2; |
689 int result; | 689 int result; |
692 | 692 |
693 #ifdef DOS_NT | 693 #ifdef DOS_NT |
694 fmode = "rb"; | 694 fmode = "rb"; |
695 #endif /* DOS_NT */ | 695 #endif /* DOS_NT */ |
696 stat ((char *)XSTRING (found)->data, &s1); | 696 stat ((char *)XSTRING (found)->data, &s1); |
697 XSTRING (found)->data[XSTRING (found)->size - 1] = 0; | 697 XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 1] = 0; |
698 result = stat ((char *)XSTRING (found)->data, &s2); | 698 result = stat ((char *)XSTRING (found)->data, &s2); |
699 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) | 699 if (result >= 0 && (unsigned) s1.st_mtime < (unsigned) s2.st_mtime) |
700 { | 700 { |
701 /* Make the progress messages mention that source is newer. */ | 701 /* Make the progress messages mention that source is newer. */ |
702 newer = 1; | 702 newer = 1; |
704 /* If we won't print another message, mention this anyway. */ | 704 /* If we won't print another message, mention this anyway. */ |
705 if (! NILP (nomessage)) | 705 if (! NILP (nomessage)) |
706 message_with_string ("Source file `%s' newer than byte-compiled file", | 706 message_with_string ("Source file `%s' newer than byte-compiled file", |
707 found, 1); | 707 found, 1); |
708 } | 708 } |
709 XSTRING (found)->data[XSTRING (found)->size - 1] = 'c'; | 709 XSTRING (found)->data[STRING_BYTES (XSTRING (found)) - 1] = 'c'; |
710 } | 710 } |
711 else | 711 else |
712 { | 712 { |
713 /* We are loading a source file (*.el). */ | 713 /* We are loading a source file (*.el). */ |
714 if (!NILP (Vload_source_file_function)) | 714 if (!NILP (Vload_source_file_function)) |
895 continue; | 895 continue; |
896 } | 896 } |
897 | 897 |
898 /* Calculate maximum size of any filename made from | 898 /* Calculate maximum size of any filename made from |
899 this path element/specified file name and any possible suffix. */ | 899 this path element/specified file name and any possible suffix. */ |
900 want_size = strlen (suffix) + XSTRING (filename)->size + 1; | 900 want_size = strlen (suffix) + STRING_BYTES (XSTRING (filename)) + 1; |
901 if (fn_size < want_size) | 901 if (fn_size < want_size) |
902 fn = (char *) alloca (fn_size = 100 + want_size); | 902 fn = (char *) alloca (fn_size = 100 + want_size); |
903 | 903 |
904 nsuffix = suffix; | 904 nsuffix = suffix; |
905 | 905 |
915 if (XSTRING (filename)->size > 2 | 915 if (XSTRING (filename)->size > 2 |
916 && XSTRING (filename)->data[0] == '/' | 916 && XSTRING (filename)->data[0] == '/' |
917 && XSTRING (filename)->data[1] == ':') | 917 && XSTRING (filename)->data[1] == ':') |
918 { | 918 { |
919 strncpy (fn, XSTRING (filename)->data + 2, | 919 strncpy (fn, XSTRING (filename)->data + 2, |
920 XSTRING (filename)->size - 2); | 920 STRING_BYTES (XSTRING (filename)) - 2); |
921 fn[XSTRING (filename)->size - 2] = 0; | 921 fn[STRING_BYTES (XSTRING (filename)) - 2] = 0; |
922 } | 922 } |
923 else | 923 else |
924 { | 924 { |
925 strncpy (fn, XSTRING (filename)->data, XSTRING (filename)->size); | 925 strncpy (fn, XSTRING (filename)->data, |
926 fn[XSTRING (filename)->size] = 0; | 926 STRING_BYTES (XSTRING (filename))); |
927 fn[STRING_BYTES (XSTRING (filename))] = 0; | |
927 } | 928 } |
928 | 929 |
929 if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */ | 930 if (lsuffix != 0) /* Bug happens on CCI if lsuffix is 0. */ |
930 strncat (fn, nsuffix, lsuffix); | 931 strncat (fn, nsuffix, lsuffix); |
931 | 932 |