/* Lisp functions for making directory listings.
Copyright (C) 1985, 1986, 1993, 1994, 1999, 2000, 2001, 2002, 2003,
- 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
#endif
extern int completion_ignore_case;
+extern Lisp_Object Qcompletion_ignore_case;
extern Lisp_Object Vcompletion_regexp_list;
Lisp_Object Vcompletion_ignored_extensions;
-Lisp_Object Qcompletion_ignore_case;
Lisp_Object Qdirectory_files;
Lisp_Object Qdirectory_files_and_attributes;
Lisp_Object Qfile_name_completion;
If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
NOSORT is useful if you plan to sort the result yourself.
ID-FORMAT specifies the preferred format of attributes uid and gid, see
-`file-attributes' for further documentation. */)
+`file-attributes' for further documentation.
+On MS-Windows, performance depends on `w32-get-true-file-attributes',
+which see. */)
(directory, full, match, nosort, id_format)
Lisp_Object directory, full, match, nosort, id_format;
{
if (!NILP (predicate))
{
Lisp_Object decoded;
+ Lisp_Object val;
+ struct gcpro gcpro1;
+
+ GCPRO1 (name);
decoded = Fexpand_file_name (DECODE_FILE (name), dirname);
- if (NILP (call1 (predicate, decoded)))
+ val = call1 (predicate, decoded);
+ UNGCPRO;
+
+ if (NILP (val))
continue;
}
compare = min (bestmatchsize, len);
p1 = SDATA (bestmatch);
p2 = (unsigned char *) dp->d_name;
- matchsize = scmp(p1, p2, compare);
+ matchsize = scmp (p1, p2, compare);
if (matchsize < 0)
matchsize = compare;
if (completion_ignore_case)
7. Size in bytes.
This is a floating point number if the size is too large for an integer.
8. File modes, as a string of ten letters or dashes as in ls -l.
- 9. t iff file's gid would change if file were deleted and recreated.
+ 9. t if file's gid would change if file were deleted and recreated.
10. inode number. If inode number is larger than the Emacs integer,
this is a cons cell containing two integers: first the high part,
then the low 16 bits.
11. Device number. If it is larger than the Emacs integer, this is
- a cons cell, similar to the inode number. */)
+ a cons cell, similar to the inode number.
+
+On MS-Windows, performance depends on `w32-get-true-file-attributes',
+which see. */)
(filename, id_format)
Lisp_Object filename, id_format;
{
shorter than an int (e.g., `short'), GCC whines about comparison
being always false due to limited range of data type. Fix by
copying s.st_uid and s.st_gid into int variables. */
+#ifdef WINDOWSNT
+ /* Windows uses signed short for the uid and gid in the stat structure,
+ but we use an int for getuid (limited to the range 0-60000).
+ So users with uid > 32767 need their uid patched back here. */
+ uid = (unsigned short) s.st_uid;
+ gid = (unsigned short) s.st_gid;
+#else
uid = s.st_uid;
gid = s.st_gid;
+#endif
if (NILP (id_format) || EQ (id_format, Qinteger))
{
values[2] = make_fixnum_or_float (uid);
values[9] = (gid != getegid ()) ? Qt : Qnil;
#endif /* BSD4_2 (or BSD4_3) */
/* Shut up GCC warnings in FIXNUM_OVERFLOW_P below. */
+#ifdef WINDOWSNT
+ {
+ /* The bit-shuffling we do in w32.c:stat can turn on the MSB, which
+ will produce negative inode numbers. People don't like that, so
+ force a positive inode instead. */
+ unsigned short tem = s.st_ino;
+ ino = tem;
+ }
+#else
ino = s.st_ino;
+#endif
if (FIXNUM_OVERFLOW_P (ino))
/* To allow inode numbers larger than VALBITS, separate the bottom
16 bits. */
/* But keep the most common cases as integers. */
values[10] = make_number (ino);
- /* Likewise for device. */
- if (FIXNUM_OVERFLOW_P (s.st_dev))
+ /* 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)
values[11] = Fcons (make_number (s.st_dev >> 16),
make_number (s.st_dev & 0xffff));
else
defsubr (&Sfile_attributes);
defsubr (&Sfile_attributes_lessp);
-#ifdef VMS
- Qcompletion_ignore_case = intern ("completion-ignore-case");
- staticpro (&Qcompletion_ignore_case);
-#endif /* VMS */
-
DEFVAR_LISP ("completion-ignored-extensions", &Vcompletion_ignored_extensions,
doc: /* Completion ignores file names ending in any string in this list.
It does not ignore them if all possible completions end in one of