Remove support for DJGPP v1.x (bug#5813).
[bpt/emacs.git] / src / dired.c
index 10d8782..2240f6e 100644 (file)
@@ -1,6 +1,6 @@
 /* Lisp functions for making directory listings.
    Copyright (C) 1985, 1986, 1993, 1994, 1999, 2000, 2001, 2002, 2003,
-                 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+                 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -23,6 +23,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <setjmp.h>
 
 #ifdef HAVE_PWD_H
 #include <pwd.h>
@@ -858,7 +859,6 @@ file_name_completion_stat (dirname, dp, st_addr)
   char *fullname = (char *) alloca (len + pos + 2);
 
 #ifdef MSDOS
-#if __DJGPP__ > 1
   /* Some fields of struct stat are *very* expensive to compute on MS-DOS,
      but aren't required here.  Avoid computing the following fields:
      st_inode, st_size and st_nlink for directories, and the execute bits
@@ -867,7 +867,6 @@ file_name_completion_stat (dirname, dp, st_addr)
   unsigned short save_djstat_flags = _djstat_flags;
 
   _djstat_flags = _STAT_INODE | _STAT_EXEC_MAGIC | _STAT_DIRSIZE;
-#endif /* __DJGPP__ > 1 */
 #endif /* MSDOS */
 
   bcopy (SDATA (dirname), fullname, pos);
@@ -887,9 +886,7 @@ file_name_completion_stat (dirname, dp, st_addr)
 #else
   value = stat (fullname, st_addr);
 #ifdef MSDOS
-#if __DJGPP__ > 1
   _djstat_flags = save_djstat_flags;
-#endif /* __DJGPP__ > 1 */
 #endif /* MSDOS */
   return value;
 #endif /* S_IFLNK */
@@ -933,29 +930,6 @@ stat_gname (struct stat *st)
 #endif
 }
 
-/* Make an integer or float number for UID and GID, while being
-   careful not to produce negative numbers due to signed integer
-   overflow.  */
-static Lisp_Object
-make_uid (struct stat *st)
-{
-  EMACS_INT uid = st->st_uid;
-
-  if (sizeof (st->st_uid) > sizeof (uid) || uid < 0 || FIXNUM_OVERFLOW_P (uid))
-    return make_float ((double)st->st_uid);
-  return make_number (uid);
-}
-
-static Lisp_Object
-make_gid (struct stat *st)
-{
-  EMACS_INT gid = st->st_gid;
-
-  if (sizeof (st->st_gid) > sizeof (gid) || gid < 0 || FIXNUM_OVERFLOW_P (gid))
-    return make_float ((double)st->st_gid);
-  return make_number (gid);
-}
-
 DEFUN ("file-attributes", Ffile_attributes, Sfile_attributes, 1, 2, 0,
        doc: /* Return a list of attributes of file FILENAME.
 Value is nil if specified file cannot be opened.
@@ -1012,7 +986,6 @@ so last access time will always be midnight of that day.  */)
   char modes[10];
   Lisp_Object handler;
   struct gcpro gcpro1;
-  EMACS_INT ino, uid, gid;
   char *uname = NULL, *gname = NULL;
 
   filename = Fexpand_file_name (filename, Qnil);
@@ -1059,19 +1032,16 @@ so last access time will always be midnight of that day.  */)
   if (uname)
     values[2] = DECODE_SYSTEM (build_string (uname));
   else
-    values[2] = make_uid (&s);
+    values[2] = make_fixnum_or_float (s.st_uid);
   if (gname)
     values[3] = DECODE_SYSTEM (build_string (gname));
   else
-    values[3] = make_gid (&s);
+    values[3] = make_fixnum_or_float (s.st_gid);
 
   values[4] = make_time (s.st_atime);
   values[5] = make_time (s.st_mtime);
   values[6] = make_time (s.st_ctime);
-  values[7] = make_number (s.st_size);
-  /* If the size is out of range for an integer, return a float.  */
-  if (XINT (values[7]) != s.st_size)
-    values[7] = make_float ((double)s.st_size);
+  values[7] = make_fixnum_or_float (s.st_size);
   /* If the size is negative, and its type is long, convert it back to
      positive.  */
   if (s.st_size < 0 && sizeof (s.st_size) == sizeof (long))
@@ -1090,17 +1060,10 @@ so last access time will always be midnight of that day.  */)
 #else                                  /* file gid will be egid */
   values[9] = (s.st_gid != getegid ()) ? Qt : Qnil;
 #endif /* BSD4_2 (or BSD4_3) */
-  /* Shut up GCC warnings in FIXNUM_OVERFLOW_P below.  */
-  if (sizeof (s.st_ino) > sizeof (ino))
-    ino = (EMACS_INT)(s.st_ino & 0xffffffff);
-  else
-    ino = s.st_ino;
-  if (!FIXNUM_OVERFLOW_P (ino)
-      && (sizeof (s.st_ino) <= sizeof (ino) || (s.st_ino & ~INTMASK) == 0))
+  if (!FIXNUM_OVERFLOW_P (s.st_ino))
     /* Keep the most common cases as integers.  */
-    values[10] = make_number (ino);
-  else if (sizeof (s.st_ino) <= sizeof (ino)
-          || ((s.st_ino >> 16) & ~INTMASK) == 0)
+    values[10] = make_number (s.st_ino);
+  else if (!FIXNUM_OVERFLOW_P (s.st_ino >> 16))
     /* To allow inode numbers larger than VALBITS, separate the bottom
        16 bits.  */
     values[10] = Fcons (make_number ((EMACS_INT)(s.st_ino >> 16)),
@@ -1120,11 +1083,8 @@ so last access time will always be midnight of that day.  */)
                                 make_number (low_ino & 0xffff)));
     }
 
-  /* Likewise for device, but don't let it become negative.  We used
-     to use FIXNUM_OVERFLOW_P here, but that won't catch large
-     positive numbers such as 0xFFEEDDCC.  */
-  if ((EMACS_INT)s.st_dev < 0
-      || (EMACS_INT)s.st_dev > MOST_POSITIVE_FIXNUM)
+  /* Likewise for device.  */
+  if (FIXNUM_OVERFLOW_P (s.st_dev))
     values[11] = Fcons (make_number (s.st_dev >> 16),
                        make_number (s.st_dev & 0xffff));
   else
@@ -1145,13 +1105,13 @@ Comparison is in lexicographic order and case is significant.  */)
 void
 syms_of_dired ()
 {
-  Qdirectory_files = intern ("directory-files");
-  Qdirectory_files_and_attributes = intern ("directory-files-and-attributes");
-  Qfile_name_completion = intern ("file-name-completion");
-  Qfile_name_all_completions = intern ("file-name-all-completions");
-  Qfile_attributes = intern ("file-attributes");
-  Qfile_attributes_lessp = intern ("file-attributes-lessp");
-  Qdefault_directory = intern ("default-directory");
+  Qdirectory_files = intern_c_string ("directory-files");
+  Qdirectory_files_and_attributes = intern_c_string ("directory-files-and-attributes");
+  Qfile_name_completion = intern_c_string ("file-name-completion");
+  Qfile_name_all_completions = intern_c_string ("file-name-all-completions");
+  Qfile_attributes = intern_c_string ("file-attributes");
+  Qfile_attributes_lessp = intern_c_string ("file-attributes-lessp");
+  Qdefault_directory = intern_c_string ("default-directory");
 
   staticpro (&Qdirectory_files);
   staticpro (&Qdirectory_files_and_attributes);