comparison src/fileio.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents d883f39b8495
children 4af0ddfb7c5b
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
436 beg = XSTRING_DATA (file); 436 beg = XSTRING_DATA (file);
437 p = beg + XSTRING_LENGTH (file); 437 p = beg + XSTRING_LENGTH (file);
438 438
439 while (p != beg && !IS_ANY_SEP (p[-1]) 439 while (p != beg && !IS_ANY_SEP (p[-1])
440 #ifdef WINDOWSNT 440 #ifdef WINDOWSNT
441 /* only recognise drive specifier at beginning */ 441 /* only recognize drive specifier at beginning */
442 && !(p[-1] == ':' && p == beg + 2) 442 && !(p[-1] == ':' && p == beg + 2)
443 #endif 443 #endif
444 ) p--; 444 ) p--;
445 445
446 if (p == beg) 446 if (p == beg)
491 beg = XSTRING_DATA (file); 491 beg = XSTRING_DATA (file);
492 end = p = beg + XSTRING_LENGTH (file); 492 end = p = beg + XSTRING_LENGTH (file);
493 493
494 while (p != beg && !IS_ANY_SEP (p[-1]) 494 while (p != beg && !IS_ANY_SEP (p[-1])
495 #ifdef WINDOWSNT 495 #ifdef WINDOWSNT
496 /* only recognise drive specifier at beginning */ 496 /* only recognize drive specifier at beginning */
497 && !(p[-1] == ':' && p == beg + 2) 497 && !(p[-1] == ':' && p == beg + 2)
498 #endif 498 #endif
499 ) p--; 499 ) p--;
500 500
501 return make_string (p, end - p); 501 return make_string (p, end - p);
740 if (stat ((CONST char *) data, &ignored) < 0) 740 if (stat ((CONST char *) data, &ignored) < 0)
741 { 741 {
742 /* We want to return only if errno is ENOENT. */ 742 /* We want to return only if errno is ENOENT. */
743 if (errno == ENOENT) 743 if (errno == ENOENT)
744 return val; 744 return val;
745 else 745
746 /* The error here is dubious, but there is little else we 746 /* The error here is dubious, but there is little else we
747 can do. The alternatives are to return nil, which is 747 can do. The alternatives are to return nil, which is
748 as bad as (and in many cases worse than) throwing the 748 as bad as (and in many cases worse than) throwing the
749 error, or to ignore the error, which will likely result 749 error, or to ignore the error, which will likely result
750 in inflooping. */ 750 in inflooping. */
751 report_file_error ("Cannot create temporary name for prefix", 751 report_file_error ("Cannot create temporary name for prefix",
752 list1 (prefix)); 752 list1 (prefix));
753 /* not reached */ 753 return Qnil; /* not reached */
754 } 754 }
755 } 755 }
756 RETURN_NOT_REACHED (Qnil);
757 } 756 }
758 757
759 758
760 DEFUN ("expand-file-name", Fexpand_file_name, 1, 2, 0, /* 759 DEFUN ("expand-file-name", Fexpand_file_name, 1, 2, 0, /*
761 Convert filename NAME to absolute, and canonicalize it. 760 Convert filename NAME to absolute, and canonicalize it.
867 { 866 {
868 Bufbyte *colon = strrchr (nm, ':'); 867 Bufbyte *colon = strrchr (nm, ':');
869 868
870 if (colon) 869 if (colon)
871 /* Only recognize colon as part of drive specifier if there is a 870 /* Only recognize colon as part of drive specifier if there is a
872 single alphabetic character preceeding the colon (and if the 871 single alphabetic character preceding the colon (and if the
873 character before the drive letter, if present, is a directory 872 character before the drive letter, if present, is a directory
874 separator); this is to support the remote system syntax used by 873 separator); this is to support the remote system syntax used by
875 ange-ftp, and the "po:username" syntax for POP mailboxes. */ 874 ange-ftp, and the "po:username" syntax for POP mailboxes. */
876 look_again: 875 look_again:
877 if (nm == colon) 876 if (nm == colon)
989 collapse_newdir = 0; 988 collapse_newdir = 0;
990 #endif 989 #endif
991 } 990 }
992 else /* ~user/filename */ 991 else /* ~user/filename */
993 { 992 {
994 for (p = nm; *p && (!IS_DIRECTORY_SEP (*p)); p++); 993 for (p = nm; *p && (!IS_DIRECTORY_SEP (*p)); p++)
994 DO_NOTHING;
995 o = (Bufbyte *) alloca (p - nm + 1); 995 o = (Bufbyte *) alloca (p - nm + 1);
996 memcpy (o, (char *) nm, p - nm); 996 memcpy (o, (char *) nm, p - nm);
997 o [p - nm] = 0; 997 o [p - nm] = 0;
998 998
999 /* #### marcpa's syncing note: FSF uses getpwnam even on NT, 999 /* #### marcpa's syncing note: FSF uses getpwnam even on NT,
1016 #ifdef __CYGWIN32__ 1016 #ifdef __CYGWIN32__
1017 if ((user = user_login_name (NULL)) != NULL) 1017 if ((user = user_login_name (NULL)) != NULL)
1018 { 1018 {
1019 /* Does the user login name match the ~name? */ 1019 /* Does the user login name match the ~name? */
1020 if (strcmp(user,((char *) o + 1)) == 0) 1020 if (strcmp(user,((char *) o + 1)) == 0)
1021 { 1021 {
1022 newdir = (Bufbyte *) get_home_directory(); 1022 newdir = (Bufbyte *) get_home_directory();
1023 nm = p; 1023 nm = p;
1024 } 1024 }
1025 } 1025 }
1026 if (! newdir) 1026 if (! newdir)
1027 { 1027 {
1028 #endif /* __CYGWIN32__ */ 1028 #endif /* __CYGWIN32__ */
1029 /* Jamie reports that getpwnam() can get wedged by SIGIO/SIGALARM 1029 /* Jamie reports that getpwnam() can get wedged by SIGIO/SIGALARM
1030 occurring in it. (It can call select()). */ 1030 occurring in it. (It can call select()). */
1031 slow_down_interrupts (); 1031 slow_down_interrupts ();
1032 pw = (struct passwd *) getpwnam ((char *) o + 1); 1032 pw = (struct passwd *) getpwnam ((char *) o + 1);
1768 report_file_error ("Non-regular file", list1 (filename)); 1768 report_file_error ("Non-regular file", list1 (filename));
1769 } 1769 }
1770 } 1770 }
1771 #endif /* S_ISREG && S_ISLNK */ 1771 #endif /* S_ISREG && S_ISLNK */
1772 1772
1773 ofd = open( (char *) XSTRING_DATA (newname), 1773 ofd = open( (char *) XSTRING_DATA (newname),
1774 O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY, CREAT_MODE); 1774 O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY, CREAT_MODE);
1775 if (ofd < 0) 1775 if (ofd < 0)
1776 report_file_error ("Opening output file", list1 (newname)); 1776 report_file_error ("Opening output file", list1 (newname));
1777 1777
1778 { 1778 {
2047 INTP (ok_if_already_exists), 0); 2047 INTP (ok_if_already_exists), 0);
2048 /* Syncing with FSF 19.34.6 note: FSF does not report a file error 2048 /* Syncing with FSF 19.34.6 note: FSF does not report a file error
2049 on NT here. --marcpa */ 2049 on NT here. --marcpa */
2050 /* But FSF #defines link as sys_link which is supplied in nt.c. We can't do 2050 /* But FSF #defines link as sys_link which is supplied in nt.c. We can't do
2051 that because sysfile.h defines sys_link depending on ENCAPSULATE_LINK. 2051 that because sysfile.h defines sys_link depending on ENCAPSULATE_LINK.
2052 Reverted to previous behaviour pending a working fix. (jhar) */ 2052 Reverted to previous behavior pending a working fix. (jhar) */
2053 #if defined(WINDOWSNT) 2053 #if defined(WINDOWSNT)
2054 /* Windows does not support this operation. */ 2054 /* Windows does not support this operation. */
2055 report_file_error ("Adding new name", Flist (2, &filename)); 2055 report_file_error ("Adding new name", Flist (2, &filename));
2056 #else /* not defined(WINDOWSNT) */ 2056 #else /* not defined(WINDOWSNT) */
2057 2057
2523 if (stat ((char *) XSTRING_DATA (abspath), &st) < 0) 2523 if (stat ((char *) XSTRING_DATA (abspath), &st) < 0)
2524 return Qnil; 2524 return Qnil;
2525 /* Syncing with FSF 19.34.6 note: not in FSF, #if 0'ed out here. */ 2525 /* Syncing with FSF 19.34.6 note: not in FSF, #if 0'ed out here. */
2526 #if 0 2526 #if 0
2527 #ifdef DOS_NT 2527 #ifdef DOS_NT
2528 if (check_executable (XSTRING (abspath)->_data)) 2528 if (check_executable (XSTRING_DATA (abspath)))
2529 st.st_mode |= S_IEXEC; 2529 st.st_mode |= S_IEXEC;
2530 #endif /* DOS_NT */ 2530 #endif /* DOS_NT */
2531 #endif /* 0 */ 2531 #endif /* 0 */
2532 2532
2533 return make_int (st.st_mode & 07777); 2533 return make_int (st.st_mode & 07777);
3344 (This has supposedly been fixed in Sunos 4, 3344 (This has supposedly been fixed in Sunos 4,
3345 but who knows about all the other machines with NFS?) */ 3345 but who knows about all the other machines with NFS?) */
3346 /* On VMS and APOLLO, must do the stat after the close 3346 /* On VMS and APOLLO, must do the stat after the close
3347 since closing changes the modtime. */ 3347 since closing changes the modtime. */
3348 /* As it does on Windows too - kkm */ 3348 /* As it does on Windows too - kkm */
3349 /* The spurious warnings appear on Linux too. Rather than handling 3349 /* The spurious warnings appear on Linux too. Rather than handling
3350 this on a per-system basis, unconditionally do the stat after the close - cgw */ 3350 this on a per-system basis, unconditionally do the stat after the close - cgw */
3351 3351
3352 #if 0 /* !defined (WINDOWSNT) /* !defined (VMS) && !defined (APOLLO) */ 3352 #if 0 /* !defined (WINDOWSNT) */ /* !defined (VMS) && !defined (APOLLO) */
3353 fstat (desc, &st); 3353 fstat (desc, &st);
3354 #endif 3354 #endif
3355 3355
3356 /* NFS can report a write failure now. */ 3356 /* NFS can report a write failure now. */
3357 if (close (desc) < 0) 3357 if (close (desc) < 0)
3365 as necessary). */ 3365 as necessary). */
3366 XCAR (desc_locative) = Qnil; 3366 XCAR (desc_locative) = Qnil;
3367 unbind_to (speccount, Qnil); 3367 unbind_to (speccount, Qnil);
3368 } 3368 }
3369 3369
3370 /* # if defined (WINDOWSNT) /* defined (VMS) || defined (APOLLO) */ 3370 /* # if defined (WINDOWSNT) */ /* defined (VMS) || defined (APOLLO) */
3371 stat ((char *) XSTRING_DATA (fn), &st); 3371 stat ((char *) XSTRING_DATA (fn), &st);
3372 /* #endif */ 3372 /* #endif */
3373 3373
3374 #ifdef CLASH_DETECTION 3374 #ifdef CLASH_DETECTION
3375 if (!auto_saving) 3375 if (!auto_saving)
3427 DEFUN ("car-less-than-car", Fcar_less_than_car, 2, 2, 0, /* 3427 DEFUN ("car-less-than-car", Fcar_less_than_car, 2, 2, 0, /*
3428 Return t if (car A) is numerically less than (car B). 3428 Return t if (car A) is numerically less than (car B).
3429 */ 3429 */
3430 (a, b)) 3430 (a, b))
3431 { 3431 {
3432 return arithcompare (Fcar (a), Fcar (b), arith_less); 3432 Lisp_Object objs[2];
3433 objs[0] = Fcar (a);
3434 objs[1] = Fcar (b);
3435 return Flss (2, objs);
3433 } 3436 }
3434 3437
3435 /* Heh heh heh, let's define this too, just to aggravate the person who 3438 /* Heh heh heh, let's define this too, just to aggravate the person who
3436 wrote the above comment. */ 3439 wrote the above comment. */
3437 DEFUN ("cdr-less-than-cdr", Fcdr_less_than_cdr, 2, 2, 0, /* 3440 DEFUN ("cdr-less-than-cdr", Fcdr_less_than_cdr, 2, 2, 0, /*
3438 Return t if (cdr A) is numerically less than (cdr B). 3441 Return t if (cdr A) is numerically less than (cdr B).
3439 */ 3442 */
3440 (a, b)) 3443 (a, b))
3441 { 3444 {
3442 return arithcompare (Fcdr (a), Fcdr (b), arith_less); 3445 Lisp_Object objs[2];
3446 objs[0] = Fcdr (a);
3447 objs[1] = Fcdr (b);
3448 return Flss (2, objs);
3443 } 3449 }
3444 3450
3445 /* Build the complete list of annotations appropriate for writing out 3451 /* Build the complete list of annotations appropriate for writing out
3446 the text between START and END, by calling all the functions in 3452 the text between START and END, by calling all the functions in
3447 write-region-annotate-functions and merging the lists they return. 3453 write-region-annotate-functions and merging the lists they return.
3826 auto_save_expand_name (Lisp_Object name) 3832 auto_save_expand_name (Lisp_Object name)
3827 { 3833 {
3828 struct gcpro gcpro1; 3834 struct gcpro gcpro1;
3829 3835
3830 /* note that caller did NOT gc protect name, so we do it. */ 3836 /* note that caller did NOT gc protect name, so we do it. */
3831 /* #### dmoore - this might not be neccessary, if condition_case_1 3837 /* #### dmoore - this might not be necessary, if condition_case_1
3832 protects it. but I don't think it does. */ 3838 protects it. but I don't think it does. */
3833 GCPRO1 (name); 3839 GCPRO1 (name);
3834 RETURN_UNGCPRO (Fexpand_file_name (name, Qnil)); 3840 RETURN_UNGCPRO (Fexpand_file_name (name, Qnil));
3835 } 3841 }
3836 3842