Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
neovim
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Efraim Flashner
neovim
Commits
70349035
Commit
70349035
authored
Mar 31, 2014
by
John Schmidt
Committed by
Thiago de Arruda
Apr 01, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move pathcmp from misc2.c
parent
2a6df95f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
68 deletions
+68
-68
src/misc2.c
src/misc2.c
+0
-67
src/misc2.h
src/misc2.h
+0
-1
src/path.c
src/path.c
+67
-0
src/path.h
src/path.h
+1
-0
No files found.
src/misc2.c
View file @
70349035
...
...
@@ -1685,73 +1685,6 @@ void sort_strings(char_u **files, int count)
qsort
((
void
*
)
files
,
(
size_t
)
count
,
sizeof
(
char_u
*
),
sort_compare
);
}
#if !defined(NO_EXPANDPATH) || defined(PROTO)
/*
* Compare path "p[]" to "q[]".
* If "maxlen" >= 0 compare "p[maxlen]" to "q[maxlen]"
* Return value like strcmp(p, q), but consider path separators.
*/
int
pathcmp
(
const
char
*
p
,
const
char
*
q
,
int
maxlen
)
{
int
i
;
int
c1
,
c2
;
const
char
*
s
=
NULL
;
for
(
i
=
0
;
maxlen
<
0
||
i
<
maxlen
;
i
+=
MB_PTR2LEN
((
char_u
*
)
p
+
i
))
{
c1
=
PTR2CHAR
((
char_u
*
)
p
+
i
);
c2
=
PTR2CHAR
((
char_u
*
)
q
+
i
);
/* End of "p": check if "q" also ends or just has a slash. */
if
(
c1
==
NUL
)
{
if
(
c2
==
NUL
)
/* full match */
return
0
;
s
=
q
;
break
;
}
/* End of "q": check if "p" just has a slash. */
if
(
c2
==
NUL
)
{
s
=
p
;
break
;
}
if
((
p_fic
?
MB_TOUPPER
(
c1
)
!=
MB_TOUPPER
(
c2
)
:
c1
!=
c2
)
#ifdef BACKSLASH_IN_FILENAME
/* consider '/' and '\\' to be equal */
&&
!
((
c1
==
'/'
&&
c2
==
'\\'
)
||
(
c1
==
'\\'
&&
c2
==
'/'
))
#endif
)
{
if
(
vim_ispathsep
(
c1
))
return
-
1
;
if
(
vim_ispathsep
(
c2
))
return
1
;
return
p_fic
?
MB_TOUPPER
(
c1
)
-
MB_TOUPPER
(
c2
)
:
c1
-
c2
;
/* no match */
}
}
if
(
s
==
NULL
)
/* "i" ran into "maxlen" */
return
0
;
c1
=
PTR2CHAR
((
char_u
*
)
s
+
i
);
c2
=
PTR2CHAR
((
char_u
*
)
s
+
i
+
MB_PTR2LEN
((
char_u
*
)
s
+
i
));
/* ignore a trailing slash, but not "//" or ":/" */
if
(
c2
==
NUL
&&
i
>
0
&&
!
after_pathsep
((
char_u
*
)
s
,
(
char_u
*
)
s
+
i
)
#ifdef BACKSLASH_IN_FILENAME
&&
(
c1
==
'/'
||
c1
==
'\\'
)
#else
&&
c1
==
'/'
#endif
)
return
0
;
/* match with trailing slash */
if
(
s
==
q
)
return
-
1
;
/* no match */
return
1
;
}
#endif
/*
* Return 0 for not writable, 1 for writable file, 2 for a dir which we have
* rights to write into.
...
...
src/misc2.h
View file @
70349035
...
...
@@ -72,7 +72,6 @@ int vim_chdirfile(char_u *fname);
int
illegal_slash
(
char
*
name
);
int
vim_chdir
(
char_u
*
new_dir
);
void
sort_strings
(
char_u
**
files
,
int
count
);
int
pathcmp
(
const
char
*
p
,
const
char
*
q
,
int
maxlen
);
int
filewritable
(
char_u
*
fname
);
int
emsg3
(
char_u
*
s
,
char_u
*
a1
,
char_u
*
a2
);
int
emsgn
(
char_u
*
s
,
long
n
);
...
...
src/path.c
View file @
70349035
...
...
@@ -1694,3 +1694,70 @@ int same_directory(char_u *f1, char_u *f2)
&&
pathcmp
((
char
*
)
ffname
,
(
char
*
)
f2
,
(
int
)(
t1
-
ffname
))
==
0
;
}
#if !defined(NO_EXPANDPATH) || defined(PROTO)
/*
* Compare path "p[]" to "q[]".
* If "maxlen" >= 0 compare "p[maxlen]" to "q[maxlen]"
* Return value like strcmp(p, q), but consider path separators.
*/
int
pathcmp
(
const
char
*
p
,
const
char
*
q
,
int
maxlen
)
{
int
i
;
int
c1
,
c2
;
const
char
*
s
=
NULL
;
for
(
i
=
0
;
maxlen
<
0
||
i
<
maxlen
;
i
+=
MB_PTR2LEN
((
char_u
*
)
p
+
i
))
{
c1
=
PTR2CHAR
((
char_u
*
)
p
+
i
);
c2
=
PTR2CHAR
((
char_u
*
)
q
+
i
);
/* End of "p": check if "q" also ends or just has a slash. */
if
(
c1
==
NUL
)
{
if
(
c2
==
NUL
)
/* full match */
return
0
;
s
=
q
;
break
;
}
/* End of "q": check if "p" just has a slash. */
if
(
c2
==
NUL
)
{
s
=
p
;
break
;
}
if
((
p_fic
?
MB_TOUPPER
(
c1
)
!=
MB_TOUPPER
(
c2
)
:
c1
!=
c2
)
#ifdef BACKSLASH_IN_FILENAME
/* consider '/' and '\\' to be equal */
&&
!
((
c1
==
'/'
&&
c2
==
'\\'
)
||
(
c1
==
'\\'
&&
c2
==
'/'
))
#endif
)
{
if
(
vim_ispathsep
(
c1
))
return
-
1
;
if
(
vim_ispathsep
(
c2
))
return
1
;
return
p_fic
?
MB_TOUPPER
(
c1
)
-
MB_TOUPPER
(
c2
)
:
c1
-
c2
;
/* no match */
}
}
if
(
s
==
NULL
)
/* "i" ran into "maxlen" */
return
0
;
c1
=
PTR2CHAR
((
char_u
*
)
s
+
i
);
c2
=
PTR2CHAR
((
char_u
*
)
s
+
i
+
MB_PTR2LEN
((
char_u
*
)
s
+
i
));
/* ignore a trailing slash, but not "//" or ":/" */
if
(
c2
==
NUL
&&
i
>
0
&&
!
after_pathsep
((
char_u
*
)
s
,
(
char_u
*
)
s
+
i
)
#ifdef BACKSLASH_IN_FILENAME
&&
(
c1
==
'/'
||
c1
==
'\\'
)
#else
&&
c1
==
'/'
#endif
)
return
0
;
/* match with trailing slash */
if
(
s
==
q
)
return
-
1
;
/* no match */
return
1
;
}
#endif
src/path.h
View file @
70349035
...
...
@@ -33,4 +33,5 @@ int vim_FullName(char_u *fname, char_u *buf, int len, int force);
char_u
*
fix_fname
(
char_u
*
fname
);
int
after_pathsep
(
char_u
*
b
,
char_u
*
p
);
int
same_directory
(
char_u
*
f1
,
char_u
*
f2
);
int
pathcmp
(
const
char
*
p
,
const
char
*
q
,
int
maxlen
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment