comparison src/evalfunc.c @ 14509:80f715651c4c v8.1.0268

patch 8.1.0268: file type checking has too many #ifdef commit https://github.com/vim/vim/commit/d569bb029983cff947dce704e6f830276204c13f Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 11 13:57:20 2018 +0200 patch 8.1.0268: file type checking has too many #ifdef Problem: File type checking has too many #ifdef. Solution: Always define the S_IF macros. (Ken Takata, closes https://github.com/vim/vim/issues/3306)
author Christian Brabandt <cb@256bit.org>
date Sat, 11 Aug 2018 14:00:05 +0200
parents a7b2dc5f1306
children d33220d3bc27
comparison
equal deleted inserted replaced
14508:7336a81d18c4 14509:80f715651c4c
5086 fname = get_tv_string(&argvars[0]); 5086 fname = get_tv_string(&argvars[0]);
5087 5087
5088 rettv->v_type = VAR_STRING; 5088 rettv->v_type = VAR_STRING;
5089 if (mch_lstat((char *)fname, &st) >= 0) 5089 if (mch_lstat((char *)fname, &st) >= 0)
5090 { 5090 {
5091 #ifdef S_ISREG
5092 if (S_ISREG(st.st_mode)) 5091 if (S_ISREG(st.st_mode))
5093 t = "file"; 5092 t = "file";
5094 else if (S_ISDIR(st.st_mode)) 5093 else if (S_ISDIR(st.st_mode))
5095 t = "dir"; 5094 t = "dir";
5096 # ifdef S_ISLNK
5097 else if (S_ISLNK(st.st_mode)) 5095 else if (S_ISLNK(st.st_mode))
5098 t = "link"; 5096 t = "link";
5099 # endif
5100 # ifdef S_ISBLK
5101 else if (S_ISBLK(st.st_mode)) 5097 else if (S_ISBLK(st.st_mode))
5102 t = "bdev"; 5098 t = "bdev";
5103 # endif
5104 # ifdef S_ISCHR
5105 else if (S_ISCHR(st.st_mode)) 5099 else if (S_ISCHR(st.st_mode))
5106 t = "cdev"; 5100 t = "cdev";
5107 # endif
5108 # ifdef S_ISFIFO
5109 else if (S_ISFIFO(st.st_mode)) 5101 else if (S_ISFIFO(st.st_mode))
5110 t = "fifo"; 5102 t = "fifo";
5111 # endif
5112 # ifdef S_ISSOCK
5113 else if (S_ISSOCK(st.st_mode)) 5103 else if (S_ISSOCK(st.st_mode))
5114 t = "socket"; 5104 t = "socket";
5115 # endif
5116 else 5105 else
5117 t = "other"; 5106 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
5148 type = vim_strsave((char_u *)t); 5107 type = vim_strsave((char_u *)t);
5149 } 5108 }
5150 rettv->vval.v_string = type; 5109 rettv->vval.v_string = type;
5151 } 5110 }
5152 5111