comparison src/dired.c @ 2117:cb164a9e44ba

* dired.c (NAMLEN): Never use d_nameln to get the length of the directory entry's name; it is used inconsistently. Always call strlen instead.
author Jim Blandy <jimb@redhat.com>
date Thu, 11 Mar 1993 07:11:34 +0000
parents a03b87a92614
children 4ffe88f2e493
comparison
equal deleted inserted replaced
2116:76df2de3dd55 2117:cb164a9e44ba
28 #include <string.h> 28 #include <string.h>
29 #include <rms.h> 29 #include <rms.h>
30 #include <rmsdef.h> 30 #include <rmsdef.h>
31 #endif 31 #endif
32 32
33 /* The d_nameln member of a struct dirent includes the '\0' character
34 on some systems, but not on others. What's worse, you can't tell
35 at compile-time which one it will be, since it really depends on
36 the sort of system providing the filesystem you're reading from,
37 not the system you are running on. Paul Eggert
38 <eggert@bi.twinsun.com> says this occurs when Emacs is running on a
39 SunOS 4.1.2 host, reading a directory that is remote-mounted from a
40 Solaris 2.1 host and is in a native Solaris 2.1 filesystem.
41
42 Since applying strlen to the name always works, we'll just do that. */
43 #define NAMLEN(p) strlen (p->d_name)
44
33 #ifdef SYSV_SYSTEM_DIR 45 #ifdef SYSV_SYSTEM_DIR
34 46
35 #include <dirent.h> 47 #include <dirent.h>
36 #define DIRENTRY struct dirent 48 #define DIRENTRY struct dirent
37 #define NAMLEN(p) strlen (p->d_name)
38 49
39 #else 50 #else
40 51
41 #ifdef NONSYSTEM_DIR_LIBRARY 52 #ifdef NONSYSTEM_DIR_LIBRARY
42 #include "ndir.h" 53 #include "ndir.h"
43 #else /* not NONSYSTEM_DIR_LIBRARY */ 54 #else /* not NONSYSTEM_DIR_LIBRARY */
44 #include <sys/dir.h> 55 #include <sys/dir.h>
45 #endif /* not NONSYSTEM_DIR_LIBRARY */ 56 #endif /* not NONSYSTEM_DIR_LIBRARY */
46 57
47 #define DIRENTRY struct direct 58 #define DIRENTRY struct direct
48 #define NAMLEN(p) p->d_namlen
49 59
50 extern DIR *opendir (); 60 extern DIR *opendir ();
51 extern struct direct *readdir (); 61 extern struct direct *readdir ();
52 62
53 #endif 63 #endif