#include "msdos.h" /* for fstatat */
#endif
-static Lisp_Object Qdirectory_files;
-static Lisp_Object Qdirectory_files_and_attributes;
-static Lisp_Object Qfile_name_completion;
-static Lisp_Object Qfile_name_all_completions;
-static Lisp_Object Qfile_attributes;
-static Lisp_Object Qfile_attributes_lessp;
-
static ptrdiff_t scmp (const char *, const char *, ptrdiff_t);
static Lisp_Object file_attributes (int, char const *, Lisp_Object);
\f
/* Note: ENCODE_FILE and DECODE_FILE can GC because they can run
run_pre_post_conversion_on_str which calls Lisp directly and
indirectly. */
- if (STRING_MULTIBYTE (dirfilename))
- dirfilename = ENCODE_FILE (dirfilename);
- encoded_directory = (STRING_MULTIBYTE (directory)
- ? ENCODE_FILE (directory) : directory);
+ dirfilename = ENCODE_FILE (dirfilename);
+ encoded_directory = ENCODE_FILE (directory);
/* Now *bufp is the compiled form of MATCH; don't call anything
which might compile a new regexp until we're done with the loop! */
}
static int file_name_completion_stat (int, struct dirent *, struct stat *);
-static Lisp_Object Qdefault_directory;
static Lisp_Object
file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
/* Actually, this is not quite true any more: we do most of the completion
work with decoded file names, but we still do some filtering based
on the encoded file name. */
- encoded_file = STRING_MULTIBYTE (file) ? ENCODE_FILE (file) : file;
+ encoded_file = ENCODE_FILE (file);
encoded_dir = ENCODE_FILE (Fdirectory_file_name (dirname));
name = DECODE_FILE (name);
{
- Lisp_Object regexps;
+ Lisp_Object regexps, table = (completion_ignore_case
+ ? Vascii_canon_table : Qnil);
/* Ignore this element if it fails to match all the regexps. */
- if (completion_ignore_case)
- {
- for (regexps = Vcompletion_regexp_list; CONSP (regexps);
- regexps = XCDR (regexps))
- if (fast_string_match_ignore_case (XCAR (regexps), name) < 0)
- break;
- }
- else
- {
- for (regexps = Vcompletion_regexp_list; CONSP (regexps);
- regexps = XCDR (regexps))
- if (fast_string_match (XCAR (regexps), name) < 0)
- break;
- }
+ for (regexps = Vcompletion_regexp_list; CONSP (regexps);
+ regexps = XCDR (regexps))
+ if (fast_string_match_internal (XCAR (regexps), name, table) < 0)
+ break;
if (CONSP (regexps))
continue;
static Lisp_Object
file_attributes (int fd, char const *name, Lisp_Object id_format)
{
- Lisp_Object values[12];
struct stat s;
int lstat_result;
if (lstat_result < 0)
return Qnil;
- values[0] = (S_ISLNK (s.st_mode) ? emacs_readlinkat (fd, name)
- : S_ISDIR (s.st_mode) ? Qt : Qnil);
- values[1] = make_number (s.st_nlink);
-
if (!(NILP (id_format) || EQ (id_format, Qinteger)))
{
block_input ();
gname = stat_gname (&s);
unblock_input ();
}
- if (uname)
- values[2] = DECODE_SYSTEM (build_unibyte_string (uname));
- else
- values[2] = make_fixnum_or_float (s.st_uid);
- if (gname)
- values[3] = DECODE_SYSTEM (build_unibyte_string (gname));
- else
- values[3] = make_fixnum_or_float (s.st_gid);
-
- values[4] = make_lisp_time (get_stat_atime (&s));
- values[5] = make_lisp_time (get_stat_mtime (&s));
- values[6] = make_lisp_time (get_stat_ctime (&s));
-
- /* If the file size is a 4-byte type, assume that files of sizes in
- the 2-4 GiB range wrap around to negative values, as this is a
- common bug on older 32-bit platforms. */
- if (sizeof (s.st_size) == 4)
- values[7] = make_fixnum_or_float (s.st_size & 0xffffffffu);
- else
- values[7] = make_fixnum_or_float (s.st_size);
filemodestring (&s, modes);
- values[8] = make_string (modes, 10);
- values[9] = Qt;
- values[10] = INTEGER_TO_CONS (s.st_ino);
- values[11] = INTEGER_TO_CONS (s.st_dev);
- return Flist (sizeof (values) / sizeof (values[0]), values);
+ return CALLN (Flist,
+ (S_ISLNK (s.st_mode) ? emacs_readlinkat (fd, name)
+ : S_ISDIR (s.st_mode) ? Qt : Qnil),
+ make_number (s.st_nlink),
+ (uname
+ ? DECODE_SYSTEM (build_unibyte_string (uname))
+ : make_fixnum_or_float (s.st_uid)),
+ (gname
+ ? DECODE_SYSTEM (build_unibyte_string (gname))
+ : make_fixnum_or_float (s.st_gid)),
+ make_lisp_time (get_stat_atime (&s)),
+ make_lisp_time (get_stat_mtime (&s)),
+ make_lisp_time (get_stat_ctime (&s)),
+
+ /* If the file size is a 4-byte type, assume that
+ files of sizes in the 2-4 GiB range wrap around to
+ negative values, as this is a common bug on older
+ 32-bit platforms. */
+ make_fixnum_or_float (sizeof (s.st_size) == 4
+ ? s.st_size & 0xffffffffu
+ : s.st_size),
+
+ make_string (modes, 10),
+ Qt,
+ INTEGER_TO_CONS (s.st_ino),
+ INTEGER_TO_CONS (s.st_dev));
}
DEFUN ("file-attributes-lessp", Ffile_attributes_lessp, Sfile_attributes_lessp, 2, 2, 0,