Mercurial > emacs
comparison src/dired.c @ 75205:248d2b5b7577
(Ffile_attributes): Copy some members of `struct stat' into int's to avoid
GCC warnings about limited range of short in arguments to FIXNUM_OVERFLOW_P.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 12 Jan 2007 15:54:58 +0000 |
parents | cf3da57bf8a5 |
children | 4ffeb7d1d7ba |
comparison
equal
deleted
inserted
replaced
75204:f6378042b0fa | 75205:248d2b5b7577 |
---|---|
928 struct stat sdir; | 928 struct stat sdir; |
929 #endif | 929 #endif |
930 char modes[10]; | 930 char modes[10]; |
931 Lisp_Object handler; | 931 Lisp_Object handler; |
932 struct gcpro gcpro1; | 932 struct gcpro gcpro1; |
933 int uid, gid, ino; | |
933 | 934 |
934 filename = Fexpand_file_name (filename, Qnil); | 935 filename = Fexpand_file_name (filename, Qnil); |
935 | 936 |
936 /* If the file name has special constructs in it, | 937 /* If the file name has special constructs in it, |
937 call the corresponding file handler. */ | 938 call the corresponding file handler. */ |
962 case S_IFLNK: | 963 case S_IFLNK: |
963 values[0] = Ffile_symlink_p (filename); break; | 964 values[0] = Ffile_symlink_p (filename); break; |
964 #endif | 965 #endif |
965 } | 966 } |
966 values[1] = make_number (s.st_nlink); | 967 values[1] = make_number (s.st_nlink); |
968 /* When make_fixnum_or_float is called below with types that are | |
969 shorter than an int (e.g., `short'), GCC whines about comparison | |
970 being always false due to limited range of data type. Fix by | |
971 copying s.st_uid and s.st_gid into int variables. */ | |
972 uid = s.st_uid; | |
973 gid = s.st_gid; | |
967 if (NILP (id_format) || EQ (id_format, Qinteger)) | 974 if (NILP (id_format) || EQ (id_format, Qinteger)) |
968 { | 975 { |
969 values[2] = make_fixnum_or_float (s.st_uid); | 976 values[2] = make_fixnum_or_float (uid); |
970 values[3] = make_fixnum_or_float (s.st_gid); | 977 values[3] = make_fixnum_or_float (gid); |
971 } | 978 } |
972 else | 979 else |
973 { | 980 { |
974 BLOCK_INPUT; | 981 BLOCK_INPUT; |
975 pw = (struct passwd *) getpwuid (s.st_uid); | 982 pw = (struct passwd *) getpwuid (uid); |
976 values[2] = (pw ? build_string (pw->pw_name) | 983 values[2] = (pw ? build_string (pw->pw_name) |
977 : make_fixnum_or_float (s.st_uid)); | 984 : make_fixnum_or_float (uid)); |
978 gr = (struct group *) getgrgid (s.st_gid); | 985 gr = (struct group *) getgrgid (gid); |
979 values[3] = (gr ? build_string (gr->gr_name) | 986 values[3] = (gr ? build_string (gr->gr_name) |
980 : make_fixnum_or_float (s.st_gid)); | 987 : make_fixnum_or_float (gid)); |
981 UNBLOCK_INPUT; | 988 UNBLOCK_INPUT; |
982 } | 989 } |
983 values[4] = make_time (s.st_atime); | 990 values[4] = make_time (s.st_atime); |
984 values[5] = make_time (s.st_mtime); | 991 values[5] = make_time (s.st_mtime); |
985 values[6] = make_time (s.st_ctime); | 992 values[6] = make_time (s.st_ctime); |
997 #if defined (BSD4_2) || defined (BSD4_3) /* file gid will be dir gid */ | 1004 #if defined (BSD4_2) || defined (BSD4_3) /* file gid will be dir gid */ |
998 dirname = Ffile_name_directory (filename); | 1005 dirname = Ffile_name_directory (filename); |
999 if (! NILP (dirname)) | 1006 if (! NILP (dirname)) |
1000 encoded = ENCODE_FILE (dirname); | 1007 encoded = ENCODE_FILE (dirname); |
1001 if (! NILP (dirname) && stat (SDATA (encoded), &sdir) == 0) | 1008 if (! NILP (dirname) && stat (SDATA (encoded), &sdir) == 0) |
1002 values[9] = (sdir.st_gid != s.st_gid) ? Qt : Qnil; | 1009 values[9] = (sdir.st_gid != gid) ? Qt : Qnil; |
1003 else /* if we can't tell, assume worst */ | 1010 else /* if we can't tell, assume worst */ |
1004 values[9] = Qt; | 1011 values[9] = Qt; |
1005 #else /* file gid will be egid */ | 1012 #else /* file gid will be egid */ |
1006 values[9] = (s.st_gid != getegid ()) ? Qt : Qnil; | 1013 values[9] = (gid != getegid ()) ? Qt : Qnil; |
1007 #endif /* BSD4_2 (or BSD4_3) */ | 1014 #endif /* BSD4_2 (or BSD4_3) */ |
1008 if (FIXNUM_OVERFLOW_P (s.st_ino)) | 1015 /* Shut up GCC warnings in FIXNUM_OVERFLOW_P below. */ |
1016 ino = s.st_ino; | |
1017 if (FIXNUM_OVERFLOW_P (ino)) | |
1009 /* To allow inode numbers larger than VALBITS, separate the bottom | 1018 /* To allow inode numbers larger than VALBITS, separate the bottom |
1010 16 bits. */ | 1019 16 bits. */ |
1011 values[10] = Fcons (make_number (s.st_ino >> 16), | 1020 values[10] = Fcons (make_number (ino >> 16), |
1012 make_number (s.st_ino & 0xffff)); | 1021 make_number (ino & 0xffff)); |
1013 else | 1022 else |
1014 /* But keep the most common cases as integers. */ | 1023 /* But keep the most common cases as integers. */ |
1015 values[10] = make_number (s.st_ino); | 1024 values[10] = make_number (ino); |
1016 | 1025 |
1017 /* Likewise for device. */ | 1026 /* Likewise for device. */ |
1018 if (FIXNUM_OVERFLOW_P (s.st_dev)) | 1027 if (FIXNUM_OVERFLOW_P (s.st_dev)) |
1019 values[11] = Fcons (make_number (s.st_dev >> 16), | 1028 values[11] = Fcons (make_number (s.st_dev >> 16), |
1020 make_number (s.st_dev & 0xffff)); | 1029 make_number (s.st_dev & 0xffff)); |