File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -204,13 +204,8 @@ open_buffer(
204204#endif
205205#ifdef UNIX
206206 perm = mch_getperm (curbuf -> b_ffname );
207- if (perm >= 0 && (0
208- # ifdef S_ISFIFO
209- || S_ISFIFO (perm )
210- # endif
211- # ifdef S_ISSOCK
207+ if (perm >= 0 && (S_ISFIFO (perm )
212208 || S_ISSOCK (perm )
213- # endif
214209# ifdef OPEN_CHR_FILES
215210 || (S_ISCHR (perm ) && is_dev_fd_file (curbuf -> b_ffname ))
216211# endif
Original file line number Diff line number Diff line change @@ -5088,63 +5088,22 @@ f_getftype(typval_T *argvars, typval_T *rettv)
50885088 rettv -> v_type = VAR_STRING ;
50895089 if (mch_lstat ((char * )fname , & st ) >= 0 )
50905090 {
5091- #ifdef S_ISREG
50925091 if (S_ISREG (st .st_mode ))
50935092 t = "file" ;
50945093 else if (S_ISDIR (st .st_mode ))
50955094 t = "dir" ;
5096- # ifdef S_ISLNK
50975095 else if (S_ISLNK (st .st_mode ))
50985096 t = "link" ;
5099- # endif
5100- # ifdef S_ISBLK
51015097 else if (S_ISBLK (st .st_mode ))
51025098 t = "bdev" ;
5103- # endif
5104- # ifdef S_ISCHR
51055099 else if (S_ISCHR (st .st_mode ))
51065100 t = "cdev" ;
5107- # endif
5108- # ifdef S_ISFIFO
51095101 else if (S_ISFIFO (st .st_mode ))
51105102 t = "fifo" ;
5111- # endif
5112- # ifdef S_ISSOCK
51135103 else if (S_ISSOCK (st .st_mode ))
51145104 t = "socket" ;
5115- # endif
51165105 else
51175106 t = "other" ;
5118- #else
5119- # ifdef S_IFMT
5120- switch (st .st_mode & S_IFMT )
5121- {
5122- case S_IFREG : t = "file" ; break ;
5123- case S_IFDIR : t = "dir" ; break ;
5124- # ifdef S_IFLNK
5125- case S_IFLNK : t = "link" ; break ;
5126- # endif
5127- # ifdef S_IFBLK
5128- case S_IFBLK : t = "bdev" ; break ;
5129- # endif
5130- # ifdef S_IFCHR
5131- case S_IFCHR : t = "cdev" ; break ;
5132- # endif
5133- # ifdef S_IFIFO
5134- case S_IFIFO : t = "fifo" ; break ;
5135- # endif
5136- # ifdef S_IFSOCK
5137- case S_IFSOCK : t = "socket" ; break ;
5138- # endif
5139- default : t = "other" ;
5140- }
5141- # else
5142- if (mch_isdir (fname ))
5143- t = "dir" ;
5144- else
5145- t = "file" ;
5146- # endif
5147- #endif
51485107 type = vim_strsave ((char_u * )t );
51495108 }
51505109 rettv -> vval .v_string = type ;
Original file line number Diff line number Diff line change @@ -424,12 +424,8 @@ readfile(
424424 */
425425 perm = mch_getperm (fname );
426426 if (perm >= 0 && !S_ISREG (perm ) /* not a regular file ... */
427- # ifdef S_ISFIFO
428427 && !S_ISFIFO (perm ) /* ... or fifo */
429- # endif
430- # ifdef S_ISSOCK
431428 && !S_ISSOCK (perm ) /* ... or socket */
432- # endif
433429# ifdef OPEN_CHR_FILES
434430 && !(S_ISCHR (perm ) && is_dev_fd_file (fname ))
435431 /* ... or a character special file named /dev/fd/<n> */
@@ -2497,28 +2493,16 @@ readfile(
24972493 c = FALSE;
24982494
24992495#ifdef UNIX
2500- # ifdef S_ISFIFO
2501- if (S_ISFIFO (perm )) /* fifo or socket */
2502- {
2503- STRCAT (IObuff , _ ("[fifo/socket]" ));
2504- c = TRUE;
2505- }
2506- # else
2507- # ifdef S_IFIFO
2508- if ((perm & S_IFMT ) == S_IFIFO ) /* fifo */
2496+ if (S_ISFIFO (perm )) /* fifo */
25092497 {
25102498 STRCAT (IObuff , _ ("[fifo]" ));
25112499 c = TRUE;
25122500 }
2513- # endif
2514- # ifdef S_IFSOCK
2515- if ((perm & S_IFMT ) == S_IFSOCK ) /* or socket */
2501+ if (S_ISSOCK (perm )) /* or socket */
25162502 {
25172503 STRCAT (IObuff , _ ("[socket]" ));
25182504 c = TRUE;
25192505 }
2520- # endif
2521- # endif
25222506# ifdef OPEN_CHR_FILES
25232507 if (S_ISCHR (perm )) /* or character special */
25242508 {
Original file line number Diff line number Diff line change @@ -550,7 +550,7 @@ cs_add_common(
550550 }
551551
552552 /* if filename is a directory, append the cscope database name to it */
553- if ((statbuf .st_mode & S_IFMT ) == S_IFDIR )
553+ if (S_ISDIR (statbuf .st_mode ) )
554554 {
555555 fname2 = (char * )alloc ((unsigned )(strlen (CSCOPE_DBFILE ) + strlen (fname ) + 2 ));
556556 if (fname2 == NULL )
@@ -581,12 +581,7 @@ cs_add_common(
581581
582582 i = cs_insert_filelist (fname2 , ppath , flags , & statbuf );
583583 }
584- #if defined(UNIX )
585584 else if (S_ISREG (statbuf .st_mode ) || S_ISLNK (statbuf .st_mode ))
586- #else
587- /* WIN32 - substitute define S_ISREG from os_unix.h */
588- else if ( ((statbuf .st_mode ) & S_IFMT ) == S_IFREG )
589- #endif
590585 {
591586 i = cs_insert_filelist (fname , ppath , flags , & statbuf );
592587 }
Original file line number Diff line number Diff line change @@ -3138,11 +3138,7 @@ mch_isdir(char_u *name)
31383138 return FALSE;
31393139 if (stat ((char * )name , & statb ))
31403140 return FALSE;
3141- #ifdef _POSIX_SOURCE
31423141 return (S_ISDIR (statb .st_mode ) ? TRUE : FALSE);
3143- #else
3144- return ((statb .st_mode & S_IFMT ) == S_IFDIR ? TRUE : FALSE);
3145- #endif
31463142}
31473143
31483144/*
@@ -3159,11 +3155,7 @@ mch_isrealdir(char_u *name)
31593155 return FALSE;
31603156 if (mch_lstat ((char * )name , & statb ))
31613157 return FALSE;
3162- #ifdef _POSIX_SOURCE
31633158 return (S_ISDIR (statb .st_mode ) ? TRUE : FALSE);
3164- #else
3165- return ((statb .st_mode & S_IFMT ) == S_IFDIR ? TRUE : FALSE);
3166- #endif
31673159}
31683160
31693161static int executable_file (char_u * name );
Original file line number Diff line number Diff line change @@ -458,25 +458,6 @@ int mch_rename(const char *src, const char *dest);
458458# endif
459459#endif
460460
461- #if !defined(S_ISDIR ) && defined(S_IFDIR )
462- # define S_ISDIR (m ) (((m) & S_IFMT) == S_IFDIR)
463- #endif
464- #if !defined(S_ISREG ) && defined(S_IFREG )
465- # define S_ISREG (m ) (((m) & S_IFMT) == S_IFREG)
466- #endif
467- #if !defined(S_ISBLK ) && defined(S_IFBLK )
468- # define S_ISBLK (m ) (((m) & S_IFMT) == S_IFBLK)
469- #endif
470- #if !defined(S_ISSOCK ) && defined(S_IFSOCK )
471- # define S_ISSOCK (m ) (((m) & S_IFMT) == S_IFSOCK)
472- #endif
473- #if !defined(S_ISFIFO ) && defined(S_IFIFO )
474- # define S_ISFIFO (m ) (((m) & S_IFMT) == S_IFIFO)
475- #endif
476- #if !defined(S_ISCHR ) && defined(S_IFCHR )
477- # define S_ISCHR (m ) (((m) & S_IFMT) == S_IFCHR)
478- #endif
479-
480461/* Note: Some systems need both string.h and strings.h (Savage). However,
481462 * some systems can't handle both, only use string.h in that case. */
482463#ifdef HAVE_STRING_H
Original file line number Diff line number Diff line change @@ -794,6 +794,8 @@ static char *(features[]) =
794794
795795static int included_patches [] =
796796{ /* Add new patch number below this line */
797+ /**/
798+ 268 ,
797799/**/
798800 267 ,
799801/**/
Original file line number Diff line number Diff line change @@ -2290,15 +2290,6 @@ typedef enum {
22902290
22912291#endif
22922292
2293- /* ISSYMLINK(mode) tests if a file is a symbolic link. */
2294- #if (defined(S_IFMT ) && defined(S_IFLNK )) || defined(S_ISLNK )
2295- # define HAVE_ISSYMLINK
2296- # if defined(S_IFMT ) && defined(S_IFLNK )
2297- # define ISSYMLINK (mode ) (((mode) & S_IFMT) == S_IFLNK)
2298- # else
2299- # define ISSYMLINK (mode ) S_ISLNK(mode)
2300- # endif
2301- #endif
23022293
23032294#define SIGN_BYTE 1 /* byte value used where sign is displayed;
23042295 attribute value is sign type */
@@ -2517,10 +2508,61 @@ typedef enum {
25172508
25182509/* BSD is supposed to cover FreeBSD and similar systems. */
25192510#if (defined(SUN_SYSTEM ) || defined(BSD ) || defined(__FreeBSD_kernel__ )) \
2520- && defined(S_ISCHR )
2511+ && ( defined(S_ISCHR ) || defined( S_IFCHR ) )
25212512# define OPEN_CHR_FILES
25222513#endif
25232514
2515+ /* stat macros */
2516+ #ifndef S_ISDIR
2517+ # ifdef S_IFDIR
2518+ # define S_ISDIR (m ) (((m) & S_IFMT) == S_IFDIR)
2519+ # else
2520+ # define S_ISDIR (m ) 0
2521+ # endif
2522+ #endif
2523+ #ifndef S_ISREG
2524+ # ifdef S_IFREG
2525+ # define S_ISREG (m ) (((m) & S_IFMT) == S_IFREG)
2526+ # else
2527+ # define S_ISREG (m ) 0
2528+ # endif
2529+ #endif
2530+ #ifndef S_ISBLK
2531+ # ifdef S_IFBLK
2532+ # define S_ISBLK (m ) (((m) & S_IFMT) == S_IFBLK)
2533+ # else
2534+ # define S_ISBLK (m ) 0
2535+ # endif
2536+ #endif
2537+ #ifndef S_ISSOCK
2538+ # ifdef S_IFSOCK
2539+ # define S_ISSOCK (m ) (((m) & S_IFMT) == S_IFSOCK)
2540+ # else
2541+ # define S_ISSOCK (m ) 0
2542+ # endif
2543+ #endif
2544+ #ifndef S_ISFIFO
2545+ # ifdef S_IFIFO
2546+ # define S_ISFIFO (m ) (((m) & S_IFMT) == S_IFIFO)
2547+ # else
2548+ # define S_ISFIFO (m ) 0
2549+ # endif
2550+ #endif
2551+ #ifndef S_ISCHR
2552+ # ifdef S_IFCHR
2553+ # define S_ISCHR (m ) (((m) & S_IFMT) == S_IFCHR)
2554+ # else
2555+ # define S_ISCHR (m ) 0
2556+ # endif
2557+ #endif
2558+ #ifndef S_ISLNK
2559+ # ifdef S_IFLNK
2560+ # define S_ISLNK (m ) (((m) & S_IFMT) == S_IFLNK)
2561+ # else
2562+ # define S_ISLNK (m ) 0
2563+ # endif
2564+ #endif
2565+
25242566#if defined(HAVE_GETTIMEOFDAY ) && defined(HAVE_SYS_TIME_H )
25252567# define ELAPSED_TIMEVAL
25262568# define ELAPSED_INIT (v ) gettimeofday(&v, NULL)
You can’t perform that action at this time.
0 commit comments