]> code.delx.au - gnu-emacs/blobdiff - src/dired.c
(reseat_1): Set it->area to TEXT_AREA.
[gnu-emacs] / src / dired.c
index 692d193c5aedd6a38539fdae86092dd3afdb1121..bf2a0e4e02076c9e5f105daccbc8f5f28dca4baf 100644 (file)
@@ -130,7 +130,7 @@ directory_files_internal_unwind (dh)
   return Qnil;
 }
 
-/* Function shared by Fdirectory_files and Fdirectory_files_and_attributes.  
+/* Function shared by Fdirectory_files and Fdirectory_files_and_attributes.
    When ATTRS is zero, return a list of directory filenames; when
    non-zero, return a list of directory filenames and their attributes.  */
 
@@ -153,7 +153,6 @@ directory_files_internal (directory, full, match, nosort, attrs)
      Ffuncall, and cause a GC.  */
   list = encoded_directory = dirfilename = Qnil;
   GCPRO5 (match, directory, list, dirfilename, encoded_directory);
-  directory = Fexpand_file_name (directory, Qnil);
   dirfilename = Fdirectory_file_name (directory);
 
   if (!NILP (match))
@@ -187,7 +186,7 @@ directory_files_internal (directory, full, match, nosort, attrs)
      have to make sure it gets closed, and setting up an
      unwind_protect to do so would be a pain.  */
  retry:
-  
+
   d = opendir (SDATA (dirfilename));
   if (d == NULL)
     report_file_error ("Opening directory", Fcons (directory, Qnil));
@@ -219,7 +218,7 @@ directory_files_internal (directory, full, match, nosort, attrs)
       if (dp == NULL && errno == EAGAIN)
        continue;
 #endif
-      
+
       if (dp == NULL)
        break;
 
@@ -233,7 +232,7 @@ directory_files_internal (directory, full, match, nosort, attrs)
          len = NAMLEN (dp);
          name = finalname = make_unibyte_string (dp->d_name, len);
          GCPRO2 (finalname, name);
-         
+
          /* Note: ENCODE_FILE can GC; it should protect its argument,
             though.  */
          name = DECODE_FILE (name);
@@ -261,24 +260,24 @@ directory_files_internal (directory, full, match, nosort, attrs)
                  fullname = make_uninit_multibyte_string (nbytes, nbytes);
                  bcopy (SDATA (directory), SDATA (fullname),
                         directory_nbytes);
-                 
+
                  if (needsep)
                    SSET (fullname, directory_nbytes, DIRECTORY_SEP);
-                 
+
                  bcopy (SDATA (name),
                         SDATA (fullname) + directory_nbytes + needsep,
                         len);
-                 
+
                  nchars = chars_in_text (SDATA (fullname), nbytes);
 
                  /* Some bug somewhere.  */
                  if (nchars > nbytes)
                    abort ();
-                     
+
                  STRING_SET_CHARS (fullname, nchars);
                  if (nchars == nbytes)
                    STRING_SET_UNIBYTE (fullname);
-                 
+
                  finalname = fullname;
                }
              else
@@ -328,7 +327,7 @@ directory_files_internal (directory, full, match, nosort, attrs)
   if (NILP (nosort))
     list = Fsort (Fnreverse (list),
                  attrs ? Qfile_attributes_lessp : Qstring_lessp);
-  
+
   RETURN_UNGCPRO (list);
 }
 
@@ -345,6 +344,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
      Lisp_Object directory, full, match, nosort;
 {
   Lisp_Object handler;
+  directory = Fexpand_file_name (directory, Qnil);
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
@@ -378,6 +378,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
      Lisp_Object directory, full, match, nosort;
 {
   Lisp_Object handler;
+  directory = Fexpand_file_name (directory, Qnil);
 
   /* If the file name has special constructs in it,
      call the corresponding file handler.  */
@@ -519,10 +520,16 @@ file_name_completion (file, dirname, all_flag, ver_flag)
 
   for (passcount = !!all_flag; NILP (bestmatch) && passcount < 2; passcount++)
     {
+      int inner_count = SPECPDL_INDEX ();
+
       d = opendir (SDATA (Fdirectory_file_name (encoded_dir)));
       if (!d)
        report_file_error ("Opening directory", Fcons (dirname, Qnil));
 
+      record_unwind_protect (directory_files_internal_unwind,
+                             Fcons (make_number (((unsigned long) d) >> 16),
+                                    make_number (((unsigned long) d) & 0xffff)));
+
       /* Loop reading blocks */
       /* (att3b compiler bug requires do a null comparison this way) */
       while (1)
@@ -539,8 +546,7 @@ file_name_completion (file, dirname, all_flag, ver_flag)
 
          len = NAMLEN (dp);
 
-         if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
-           goto quit;
+         QUIT;
          if (! DIRENTRY_NONEMPTY (dp)
              || len < SCHARS (encoded_file)
              || 0 <= scmp (dp->d_name, SDATA (encoded_file),
@@ -681,7 +687,7 @@ file_name_completion (file, dirname, all_flag, ver_flag)
                  /* This tests that the current file is an exact match
                     but BESTMATCH is not (it is too long).  */
                  if ((matchsize == len
-                      && matchsize + !!directoryp 
+                      && matchsize + !!directoryp
                          < SCHARS (bestmatch))
                      ||
                      /* If there is no exact match ignoring case,
@@ -694,7 +700,7 @@ file_name_completion (file, dirname, all_flag, ver_flag)
                         either both or neither are exact.  */
                      (((matchsize == len)
                        ==
-                       (matchsize + !!directoryp 
+                       (matchsize + !!directoryp
                         == SCHARS (bestmatch)))
                       && !bcmp (p2, SDATA (encoded_file), SCHARS (encoded_file))
                       && bcmp (p1, SDATA (encoded_file), SCHARS (encoded_file))))
@@ -715,7 +721,8 @@ file_name_completion (file, dirname, all_flag, ver_flag)
              bestmatchsize = matchsize;
            }
        }
-      closedir (d);
+      /* This closes the directory.  */
+      bestmatch = unbind_to (inner_count, bestmatch);
     }
 
   UNGCPRO;
@@ -735,11 +742,6 @@ file_name_completion (file, dirname, all_flag, ver_flag)
      decode it from the coding system in use.  */
   bestmatch = DECODE_FILE (bestmatch);
   return bestmatch;
-
- quit:
-  if (d) closedir (d);
-  Vquit_flag = Qnil;
-  return Fsignal (Qquit, Qnil);
 }
 
 /* Compare exactly LEN chars of strings at S1 and S2,
@@ -940,6 +942,11 @@ If file does not exist, returns nil.  */)
   /* 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);
+  /* 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))
+    values[7] = make_float ((double) ((unsigned long) s.st_size));
+
   filemodestring (&s, modes);
   values[8] = make_string (modes, 10);
 #if defined (BSD4_2) || defined (BSD4_3) /* file gid will be dir gid */