X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/91107bd98003435fbeead3325ce694248863da39..9aa0092cdd378dd8f7a55896c31bb68d2be18b1c:/src/dired.c diff --git a/src/dired.c b/src/dired.c index db07bc61e7..771230717e 100644 --- a/src/dired.c +++ b/src/dired.c @@ -1,5 +1,5 @@ /* Lisp functions for making directory listings. - Copyright (C) 1985-1986, 1993-1994, 1999-2011 Free Software Foundation, Inc. + Copyright (C) 1985-1986, 1993-1994, 1999-2012 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -62,6 +62,7 @@ extern struct direct *readdir (DIR *); #endif /* HAVE_DIRENT_H */ #include +#include #ifdef MSDOS #define DIRENTRY_NONEMPTY(p) ((p)->d_name[0] != 0) @@ -71,9 +72,9 @@ extern struct direct *readdir (DIR *); #include "lisp.h" #include "systime.h" +#include "character.h" #include "buffer.h" #include "commands.h" -#include "character.h" #include "charset.h" #include "coding.h" #include "regex.h" @@ -87,7 +88,6 @@ static Lisp_Object Qfile_attributes; static Lisp_Object Qfile_attributes_lessp; static ptrdiff_t scmp (const char *, const char *, ptrdiff_t); -static Lisp_Object Ffile_attributes (Lisp_Object, Lisp_Object); #ifdef WINDOWSNT Lisp_Object @@ -229,11 +229,11 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object m ptrdiff_t len; int wanted = 0; Lisp_Object name, finalname; - struct gcpro inner_gcpro1, inner_gcpro2; + struct gcpro gcpro1, gcpro2; len = NAMLEN (dp); name = finalname = make_unibyte_string (dp->d_name, len); - GCPRO2_VAR (finalname, name, inner_gcpro); + GCPRO2 (finalname, name); /* Note: DECODE_FILE can GC; it should protect its argument, though. */ @@ -289,23 +289,23 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, Lisp_Object m /* Construct an expanded filename for the directory entry. Use the decoded names for input to Ffile_attributes. */ Lisp_Object decoded_fullname, fileattrs; - struct gcpro innermost_gcpro1, innermost_gcpro2; + struct gcpro gcpro1, gcpro2; decoded_fullname = fileattrs = Qnil; - GCPRO2_VAR (decoded_fullname, fileattrs, innermost_gcpro); + GCPRO2 (decoded_fullname, fileattrs); /* Both Fexpand_file_name and Ffile_attributes can GC. */ decoded_fullname = Fexpand_file_name (name, directory); fileattrs = Ffile_attributes (decoded_fullname, id_format); list = Fcons (Fcons (finalname, fileattrs), list); - UNGCPRO_VAR (innermost_gcpro); + UNGCPRO; } else list = Fcons (finalname, list); } - UNGCPRO_VAR (inner_gcpro); + UNGCPRO; } } @@ -470,9 +470,6 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v CHECK_STRING (file); -#ifdef FILE_SYSTEM_CASE - file = FILE_SYSTEM_CASE (file); -#endif bestmatch = Qnil; encoded_file = encoded_dir = Qnil; GCPRO5 (file, dirname, bestmatch, encoded_file, encoded_dir); @@ -628,7 +625,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v if (includeall && !canexclude) { /* If we have one non-excludable file, we want to exclude the - excudable files. */ + excludable files. */ includeall = 0; /* Throw away any previous excludable match found. */ bestmatch = Qnil; @@ -673,11 +670,11 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v if (!NILP (predicate)) { Lisp_Object val; - struct gcpro inner_gcpro1; + struct gcpro gcpro1; - GCPRO1_VAR (name, inner_gcpro); + GCPRO1 (name); val = call1 (predicate, name); - UNGCPRO_VAR (inner_gcpro); + UNGCPRO; if (NILP (val)) continue; @@ -813,9 +810,8 @@ file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_ad ptrdiff_t len = NAMLEN (dp); ptrdiff_t pos = SCHARS (dirname); int value; - char *fullname; USE_SAFE_ALLOCA; - SAFE_ALLOCA (fullname, char *, len + pos + 2); + char *fullname = SAFE_ALLOCA (len + pos + 2); #ifdef MSDOS /* Some fields of struct stat are *very* expensive to compute on MS-DOS, @@ -893,8 +889,8 @@ Elements of the attribute list are: 2. File uid as a string or a number. If a string value cannot be looked up, a numeric value, either an integer or a float, is returned. 3. File gid, likewise. - 4. Last access time, as a list of two integers. - First integer has high-order 16 bits of time, second has low 16 bits. + 4. Last access time, as a list of integers (HIGH LOW USEC PSEC) in the + same style as (current-time). (See a note below about access time on FAT-based filesystems.) 5. Last modification time, likewise. This is the time of the last change to the file's contents. @@ -979,9 +975,9 @@ so last access time will always be midnight of that day. */) else 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[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 @@ -1018,6 +1014,45 @@ Comparison is in lexicographic order and case is significant. */) return Fstring_lessp (Fcar (f1), Fcar (f2)); } + +DEFUN ("system-users", Fsystem_users, Ssystem_users, 0, 0, 0, + doc: /* Return a list of user names currently registered in the system. +If we don't know how to determine that on this platform, just +return a list with one element, taken from `user-real-login-name'. */) + (void) +{ + Lisp_Object users = Qnil; +#if defined HAVE_GETPWENT && defined HAVE_ENDPWENT + struct passwd *pw; + + while ((pw = getpwent ())) + users = Fcons (DECODE_SYSTEM (build_string (pw->pw_name)), users); + + endpwent (); +#endif + if (EQ (users, Qnil)) + /* At least current user is always known. */ + users = Fcons (Vuser_real_login_name, Qnil); + return users; +} + +DEFUN ("system-groups", Fsystem_groups, Ssystem_groups, 0, 0, 0, + doc: /* Return a list of user group names currently registered in the system. +The value may be nil if not supported on this platform. */) + (void) +{ + Lisp_Object groups = Qnil; +#if defined HAVE_GETGRENT && defined HAVE_ENDGRENT + struct group *gr; + + while ((gr = getgrent ())) + groups = Fcons (DECODE_SYSTEM (build_string (gr->gr_name)), groups); + + endgrent (); +#endif + return groups; +} + void syms_of_dired (void) { @@ -1035,6 +1070,8 @@ syms_of_dired (void) defsubr (&Sfile_name_all_completions); defsubr (&Sfile_attributes); defsubr (&Sfile_attributes_lessp); + defsubr (&Ssystem_users); + defsubr (&Ssystem_groups); DEFVAR_LISP ("completion-ignored-extensions", Vcompletion_ignored_extensions, doc: /* Completion ignores file names ending in any string in this list.