comparison src/fileio.c @ 6470:9657929ee562 v7.4.564

updated for version 7.4.564 Problem: FEAT_OSFILETYPE is used even though it's never defined. Solution: Remove the code. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Wed, 07 Jan 2015 14:43:39 +0100
parents 27a36d1013a6
children a5ba0921efcb
comparison
equal deleted inserted replaced
6469:9cb37f9ff290 6470:9657929ee562
10047 char_u *tail; /* tail of path */ 10047 char_u *tail; /* tail of path */
10048 int allow_dirs; /* allow matching with dir */ 10048 int allow_dirs; /* allow matching with dir */
10049 { 10049 {
10050 regmatch_T regmatch; 10050 regmatch_T regmatch;
10051 int result = FALSE; 10051 int result = FALSE;
10052 #ifdef FEAT_OSFILETYPE
10053 int no_pattern = FALSE; /* TRUE if check is filetype only */
10054 char_u *type_start;
10055 char_u c;
10056 int match = FALSE;
10057 #endif
10058 10052
10059 regmatch.rm_ic = p_fic; /* ignore case if 'fileignorecase' is set */ 10053 regmatch.rm_ic = p_fic; /* ignore case if 'fileignorecase' is set */
10060 #ifdef FEAT_OSFILETYPE 10054 if (prog != NULL)
10061 if (*pattern == '<') 10055 regmatch.regprog = *prog;
10062 {
10063 /* There is a filetype condition specified with this pattern.
10064 * Check the filetype matches first. If not, don't bother with the
10065 * pattern (set regprog to NULL).
10066 * Always use magic for the regexp.
10067 */
10068
10069 for (type_start = pattern + 1; (c = *pattern); pattern++)
10070 {
10071 if ((c == ';' || c == '>') && match == FALSE)
10072 {
10073 *pattern = NUL; /* Terminate the string */
10074 /* TODO: match with 'filetype' of buffer that "fname" comes
10075 * from. */
10076 match = mch_check_filetype(fname, type_start);
10077 *pattern = c; /* Restore the terminator */
10078 type_start = pattern + 1;
10079 }
10080 if (c == '>')
10081 break;
10082 }
10083
10084 /* (c should never be NUL, but check anyway) */
10085 if (match == FALSE || c == NUL)
10086 regmatch.regprog = NULL; /* Doesn't match - don't check pat. */
10087 else if (*pattern == NUL)
10088 {
10089 regmatch.regprog = NULL; /* Vim will try to free regprog later */
10090 no_pattern = TRUE; /* Always matches - don't check pat. */
10091 }
10092 else
10093 regmatch.regprog = vim_regcomp(pattern + 1, RE_MAGIC);
10094 }
10095 else 10056 else
10096 #endif 10057 regmatch.regprog = vim_regcomp(pattern, RE_MAGIC);
10097 {
10098 if (prog != NULL)
10099 regmatch.regprog = *prog;
10100 else
10101 regmatch.regprog = vim_regcomp(pattern, RE_MAGIC);
10102 }
10103 10058
10104 /* 10059 /*
10105 * Try for a match with the pattern with: 10060 * Try for a match with the pattern with:
10106 * 1. the full file name, when the pattern has a '/'. 10061 * 1. the full file name, when the pattern has a '/'.
10107 * 2. the short file name, when the pattern has a '/'. 10062 * 2. the short file name, when the pattern has a '/'.
10108 * 3. the tail of the file name, when the pattern has no '/'. 10063 * 3. the tail of the file name, when the pattern has no '/'.
10109 */ 10064 */
10110 if ( 10065 if (regmatch.regprog != NULL
10111 #ifdef FEAT_OSFILETYPE
10112 /* If the check is for a filetype only and we don't care
10113 * about the path then skip all the regexp stuff.
10114 */
10115 no_pattern ||
10116 #endif
10117 (regmatch.regprog != NULL
10118 && ((allow_dirs 10066 && ((allow_dirs
10119 && (vim_regexec(&regmatch, fname, (colnr_T)0) 10067 && (vim_regexec(&regmatch, fname, (colnr_T)0)
10120 || (sfname != NULL 10068 || (sfname != NULL
10121 && vim_regexec(&regmatch, sfname, (colnr_T)0)))) 10069 && vim_regexec(&regmatch, sfname, (colnr_T)0))))
10122 || (!allow_dirs && vim_regexec(&regmatch, tail, (colnr_T)0))))) 10070 || (!allow_dirs && vim_regexec(&regmatch, tail, (colnr_T)0))))
10123 result = TRUE; 10071 result = TRUE;
10124 10072
10125 if (prog != NULL) 10073 if (prog != NULL)
10126 *prog = regmatch.regprog; 10074 *prog = regmatch.regprog;
10127 else 10075 else
10174 * a regular expression, and return the result in allocated memory. If there 10122 * a regular expression, and return the result in allocated memory. If there
10175 * is a directory path separator to be matched, then TRUE is put in 10123 * is a directory path separator to be matched, then TRUE is put in
10176 * allow_dirs, otherwise FALSE is put there -- webb. 10124 * allow_dirs, otherwise FALSE is put there -- webb.
10177 * Handle backslashes before special characters, like "\*" and "\ ". 10125 * Handle backslashes before special characters, like "\*" and "\ ".
10178 * 10126 *
10179 * If FEAT_OSFILETYPE defined then pass initial <type> through unchanged. Eg:
10180 * '<html>myfile' becomes '<html>^myfile$' -- leonard.
10181 *
10182 * Returns NULL when out of memory. 10127 * Returns NULL when out of memory.
10183 */ 10128 */
10184 char_u * 10129 char_u *
10185 file_pat_to_reg_pat(pat, pat_end, allow_dirs, no_bslash) 10130 file_pat_to_reg_pat(pat, pat_end, allow_dirs, no_bslash)
10186 char_u *pat; 10131 char_u *pat;
10187 char_u *pat_end; /* first char after pattern or NULL */ 10132 char_u *pat_end; /* first char after pattern or NULL */
10188 char *allow_dirs; /* Result passed back out in here */ 10133 char *allow_dirs; /* Result passed back out in here */
10189 int no_bslash UNUSED; /* Don't use a backward slash as pathsep */ 10134 int no_bslash UNUSED; /* Don't use a backward slash as pathsep */
10190 { 10135 {
10191 int size; 10136 int size = 2; /* '^' at start, '$' at end */
10192 char_u *endp; 10137 char_u *endp;
10193 char_u *reg_pat; 10138 char_u *reg_pat;
10194 char_u *p; 10139 char_u *p;
10195 int i; 10140 int i;
10196 int nested = 0; 10141 int nested = 0;
10197 int add_dollar = TRUE; 10142 int add_dollar = TRUE;
10198 #ifdef FEAT_OSFILETYPE
10199 int check_length = 0;
10200 #endif
10201 10143
10202 if (allow_dirs != NULL) 10144 if (allow_dirs != NULL)
10203 *allow_dirs = FALSE; 10145 *allow_dirs = FALSE;
10204 if (pat_end == NULL) 10146 if (pat_end == NULL)
10205 pat_end = pat + STRLEN(pat); 10147 pat_end = pat + STRLEN(pat);
10206
10207 #ifdef FEAT_OSFILETYPE
10208 /* Find out how much of the string is the filetype check */
10209 if (*pat == '<')
10210 {
10211 /* Count chars until the next '>' */
10212 for (p = pat + 1; p < pat_end && *p != '>'; p++)
10213 ;
10214 if (p < pat_end)
10215 {
10216 /* Pattern is of the form <.*>.* */
10217 check_length = p - pat + 1;
10218 if (p + 1 >= pat_end)
10219 {
10220 /* The 'pattern' is a filetype check ONLY */
10221 reg_pat = (char_u *)alloc(check_length + 1);
10222 if (reg_pat != NULL)
10223 {
10224 mch_memmove(reg_pat, pat, (size_t)check_length);
10225 reg_pat[check_length] = NUL;
10226 }
10227 return reg_pat;
10228 }
10229 }
10230 /* else: there was no closing '>' - assume it was a normal pattern */
10231
10232 }
10233 pat += check_length;
10234 size = 2 + check_length;
10235 #else
10236 size = 2; /* '^' at start, '$' at end */
10237 #endif
10238 10148
10239 for (p = pat; p < pat_end; p++) 10149 for (p = pat; p < pat_end; p++)
10240 { 10150 {
10241 switch (*p) 10151 switch (*p)
10242 { 10152 {
10268 } 10178 }
10269 reg_pat = alloc(size + 1); 10179 reg_pat = alloc(size + 1);
10270 if (reg_pat == NULL) 10180 if (reg_pat == NULL)
10271 return NULL; 10181 return NULL;
10272 10182
10273 #ifdef FEAT_OSFILETYPE
10274 /* Copy the type check in to the start. */
10275 if (check_length)
10276 mch_memmove(reg_pat, pat - check_length, (size_t)check_length);
10277 i = check_length;
10278 #else
10279 i = 0; 10183 i = 0;
10280 #endif
10281 10184
10282 if (pat[0] == '*') 10185 if (pat[0] == '*')
10283 while (pat[0] == '*' && pat < pat_end - 1) 10186 while (pat[0] == '*' && pat < pat_end - 1)
10284 pat++; 10187 pat++;
10285 else 10188 else