comparison src/dired.c @ 5492:ededb7b52564

(DIRENTRY_NONEMPTY): New macro; two definitions. (Fdirectory_files, file_name_completion): Use it. [MSDOS]: #include <dirent.h> instead of <sys/dir.h>. Avoid some external definitions. (Ffile_attributes) [MSDOS]: Set execute bits from file name. (Ffile_name_all_completions) [FILE_SYSTEM_CASE]: Convert case of file name as as indicated by conditional.
author Richard M. Stallman <rms@gnu.org>
date Sat, 08 Jan 1994 08:47:19 +0000
parents c3677267e74d
children 3d314bef071a
comparison
equal deleted inserted replaced
5491:3965bf498738 5492:ededb7b52564
45 #ifdef SYSV_SYSTEM_DIR 45 #ifdef SYSV_SYSTEM_DIR
46 46
47 #include <dirent.h> 47 #include <dirent.h>
48 #define DIRENTRY struct dirent 48 #define DIRENTRY struct dirent
49 49
50 #else 50 #else /* not SYSV_SYSTEM_DIR */
51 51
52 #ifdef NONSYSTEM_DIR_LIBRARY 52 #ifdef NONSYSTEM_DIR_LIBRARY
53 #include "ndir.h" 53 #include "ndir.h"
54 #else /* not NONSYSTEM_DIR_LIBRARY */ 54 #else /* not NONSYSTEM_DIR_LIBRARY */
55 #ifdef MSDOS
56 #include <dirent.h>
57 #else
55 #include <sys/dir.h> 58 #include <sys/dir.h>
59 #endif
56 #endif /* not NONSYSTEM_DIR_LIBRARY */ 60 #endif /* not NONSYSTEM_DIR_LIBRARY */
57 61
62 #ifndef MSDOS
58 #define DIRENTRY struct direct 63 #define DIRENTRY struct direct
59 64
60 extern DIR *opendir (); 65 extern DIR *opendir ();
61 extern struct direct *readdir (); 66 extern struct direct *readdir ();
62 67
68 #endif /* not MSDOS */
69 #endif /* not SYSV_SYSTEM_DIR */
70
71 #ifdef MSDOS
72 #define DIRENTRY_NONEMPTY(p) ((p)->d_name[0] != 0)
73 #else
74 #define DIRENTRY_NONEMPTY(p) ((p)->d_ino)
63 #endif 75 #endif
64 76
65 #include "lisp.h" 77 #include "lisp.h"
66 #include "buffer.h" 78 #include "buffer.h"
67 #include "commands.h" 79 #include "commands.h"
171 DIRENTRY *dp = readdir (d); 183 DIRENTRY *dp = readdir (d);
172 int len; 184 int len;
173 185
174 if (!dp) break; 186 if (!dp) break;
175 len = NAMLEN (dp); 187 len = NAMLEN (dp);
176 if (dp->d_ino) 188 if (DIRENTRY_NONEMPTY (dp))
177 { 189 {
178 if (NILP (match) 190 if (NILP (match)
179 || (0 <= re_search (&searchbuf, dp->d_name, len, 0, len, 0))) 191 || (0 <= re_search (&searchbuf, dp->d_name, len, 0, len, 0)))
180 { 192 {
181 if (!NILP (full)) 193 if (!NILP (full))
288 file = Fupcase (file); 300 file = Fupcase (file);
289 #else /* not VMS */ 301 #else /* not VMS */
290 CHECK_STRING (file, 0); 302 CHECK_STRING (file, 0);
291 #endif /* not VMS */ 303 #endif /* not VMS */
292 304
305 #ifdef FILE_SYSTEM_CASE
306 file = FILE_SYSTEM_CASE (file);
307 #endif
293 dirname = Fexpand_file_name (dirname, Qnil); 308 dirname = Fexpand_file_name (dirname, Qnil);
294 bestmatch = Qnil; 309 bestmatch = Qnil;
295 310
296 /* With passcount = 0, ignore files that end in an ignored extension. 311 /* With passcount = 0, ignore files that end in an ignored extension.
297 If nothing found then try again with passcount = 1, don't ignore them. 312 If nothing found then try again with passcount = 1, don't ignore them.
322 337
323 len = NAMLEN (dp); 338 len = NAMLEN (dp);
324 339
325 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) 340 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
326 goto quit; 341 goto quit;
327 if (!dp->d_ino 342 if (! DIRENTRY_NONEMPTY (dp)
328 || len < XSTRING (file)->size 343 || len < XSTRING (file)->size
329 || 0 <= scmp (dp->d_name, XSTRING (file)->data, 344 || 0 <= scmp (dp->d_name, XSTRING (file)->data,
330 XSTRING (file)->size)) 345 XSTRING (file)->size))
331 continue; 346 continue;
332 347
561 return call2 (handler, Qfile_attributes, filename); 576 return call2 (handler, Qfile_attributes, filename);
562 577
563 if (lstat (XSTRING (filename)->data, &s) < 0) 578 if (lstat (XSTRING (filename)->data, &s) < 0)
564 return Qnil; 579 return Qnil;
565 580
581 #ifdef MSDOS
582 {
583 char *tmpnam = XSTRING (Ffile_name_nondirectory (filename))->data;
584 int l = strlen (tmpnam);
585
586 if (l >= 5
587 && S_ISREG (s.st_mode)
588 && (stricmp (&tmpnam[l - 4], ".com") == 0
589 || stricmp (&tmpnam[l - 4], ".exe") == 0
590 || stricmp (&tmpnam[l - 4], ".bat") == 0))
591 {
592 s.st_mode |= S_IEXEC;
593 }
594 }
595 #endif /* MSDOS */
596
566 switch (s.st_mode & S_IFMT) 597 switch (s.st_mode & S_IFMT)
567 { 598 {
568 default: 599 default:
569 values[0] = Qnil; break; 600 values[0] = Qnil; break;
570 case S_IFDIR: 601 case S_IFDIR: