summaryrefslogtreecommitdiffstats
path: root/src/os_mac.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os_mac.c')
-rw-r--r--src/os_mac.c175
1 files changed, 8 insertions, 167 deletions
diff --git a/src/os_mac.c b/src/os_mac.c
index 4a3014ba5c..64f0e0919d 100644
--- a/src/os_mac.c
+++ b/src/os_mac.c
@@ -55,7 +55,7 @@ mch_chdir(char *p_name)
* in `path'. Called by mch_expandpath().
* "path" has backslashes before chars that are not to be expanded.
*/
- int
+ static int
mac_expandpath(
garray_T *gap,
char_u *path,
@@ -109,8 +109,7 @@ mac_expandpath(
{
if (e)
break;
- else
- s = p + 1;
+ s = p + 1;
}
/* should use WILCARDLIST but what about ` */
/* if (vim_strchr((char_u *)"*?[{~$", *path) != NULL)*/
@@ -134,12 +133,10 @@ mac_expandpath(
/* now we have one wildcard component between s and e */
*e = NUL;
-#if 1
dany = *s;
*s = NUL;
backslash_halve(buf);
*s = dany;
-#endif
/* convert the file pattern to a regexp pattern */
pat = file_pat_to_reg_pat(s, e, NULL, FALSE);
@@ -207,7 +204,7 @@ mac_expandpath(
gMyCPB.hFileInfo.ioFDirIndex = index;
gMyCPB.hFileInfo.ioDirID = dirID;
- gErr = PBGetCatInfo(&gMyCPB,false);
+ gErr = PBGetCatInfo(&gMyCPB, false);
if (gErr == noErr)
{
@@ -237,12 +234,14 @@ mac_expandpath(
addfile(gap, buf, flags);
}
}
- if ((gMyCPB.hFileInfo.ioFlAttrib & ioDirMask) !=0 )
+#if 0 /* What is this supposed to do? */
+ if ((gMyCPB.hFileInfo.ioFlAttrib & ioDirMask) != 0)
{
}
else
{
}
+#endif
}
index++;
}
@@ -254,7 +253,7 @@ mac_expandpath(
do
{
gMyHPBlock.volumeParam.ioNamePtr = (char_u *) dirname;
- gMyHPBlock.volumeParam.ioVRefNum =0;
+ gMyHPBlock.volumeParam.ioVRefNum = 0;
gMyHPBlock.volumeParam.ioVolIndex = index;
gErr = PBHGetVInfo (&gMyHPBlock,false);
@@ -291,164 +290,6 @@ mac_expandpath(
return gap->ga_len - start_len;
}
-
-#ifdef USE_UNIXFILENAME
- static int
-pstrcmp(a, b)
- const void *a, *b;
-{
- return (pathcmp(*(char **)a, *(char **)b, -1));
-}
-
- static int
-unix_expandpath(gap, path, wildoff, flags)
- garray_T *gap;
- char_u *path;
- int wildoff;
- int flags; /* EW_* flags */
-{
- char_u *buf;
- char_u *path_end;
- char_u *p, *s, *e;
- int start_len, c;
- char_u *pat;
- DIR *dirp;
- regmatch_T regmatch;
- struct dirent *dp;
- int starts_with_dot;
- int matches;
- int len;
-
- start_len = gap->ga_len;
- buf = alloc(STRLEN(path) + BASENAMELEN + 5);/* make room for file name */
- if (buf == NULL)
- return 0;
-
-/*
- * Find the first part in the path name that contains a wildcard.
- * Copy it into buf, including the preceding characters.
- */
- p = buf;
- s = buf;
- e = NULL;
- path_end = path;
- while (*path_end)
- {
- /* May ignore a wildcard that has a backslash before it */
- if (path_end >= path + wildoff && rem_backslash(path_end))
- *p++ = *path_end++;
- else if (*path_end == '/')
- {
- if (e != NULL)
- break;
- else
- s = p + 1;
- }
- else if (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL)
- e = p;
-#ifdef FEAT_MBYTE
- if (has_mbyte)
- {
- len = (*mb_ptr2len_check)(path_end);
- STRNCPY(p, path_end, len);
- p += len;
- path_end += len;
- }
- else
-#endif
- *p++ = *path_end++;
- }
- e = p;
- *e = NUL;
-
- /* now we have one wildcard component between s and e */
- /* Remove backslashes between "wildoff" and the start of the wildcard
- * component. */
- for (p = buf + wildoff; p < s; ++p)
- if (rem_backslash(p))
- {
- STRCPY(p, p + 1);
- --e;
- --s;
- }
-
- /* convert the file pattern to a regexp pattern */
- starts_with_dot = (*s == '.');
- pat = file_pat_to_reg_pat(s, e, NULL, FALSE);
- if (pat == NULL)
- {
- vim_free(buf);
- return 0;
- }
-
- /* compile the regexp into a program */
-#ifdef MACOS_X
- /* We want to behave like Terminal.app */
- regmatch.rm_ic = TRUE;
-#else
- regmatch.rm_ic = FALSE; /* Don't ever ignore case */
-#endif
- regmatch.regprog = vim_regcomp(pat, RE_MAGIC);
- vim_free(pat);
-
- if (regmatch.regprog == NULL)
- {
- vim_free(buf);
- return 0;
- }
-
- /* open the directory for scanning */
- c = *s;
- *s = NUL;
- dirp = opendir(*buf == NUL ? "." : (char *)buf);
- *s = c;
-
- /* Find all matching entries */
- if (dirp != NULL)
- {
- for (;;)
- {
- dp = readdir(dirp);
- if (dp == NULL)
- break;
- if ((dp->d_name[0] != '.' || starts_with_dot)
- && vim_regexec(&regmatch, (char_u *)dp->d_name, (colnr_T)0))
- {
- STRCPY(s, dp->d_name);
- len = STRLEN(buf);
- STRCPY(buf + len, path_end);
- if (mch_has_exp_wildcard(path_end)) /* handle more wildcards */
- {
- /* need to expand another component of the path */
- /* remove backslashes for the remaining components only */
- (void)unix_expandpath(gap, buf, len + 1, flags);
- }
- else
- {
- /* no more wildcards, check if there is a match */
- /* remove backslashes for the remaining components only */
- if (*path_end)
- backslash_halve(buf + len + 1);
- if (mch_getperm(buf) >= 0) /* add existing file */
- addfile(gap, buf, flags);
- }
- }
- }
-
- closedir(dirp);
- }
-
- vim_free(buf);
- vim_free(regmatch.regprog);
-
- matches = gap->ga_len - start_len;
- if (matches)
- qsort(((char_u **)gap->ga_data) + start_len, matches,
- sizeof(char_u *), pstrcmp);
- return matches;
-}
-#endif
-
/*
* Recursively build up a list of files in "gap" matching the first wildcard
* in `path'. Called by expand_wildcards().
@@ -461,7 +302,7 @@ mch_expandpath(
int flags) /* EW_* flags */
{
#ifdef USE_UNIXFILENAME
- return unix_expandpath(gap, path, 0, flags);
+ return unix_expandpath(gap, path, 0, flags, FALSE);
#else
char_u first = *path;
short scan_volume;