Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
82a7a24c
Commit
82a7a24c
authored
Jun 08, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3165 from ethomson/downcase
Downcase
parents
c0d79992
bad33a5d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
24 deletions
+75
-24
src/config_file.c
+2
-2
src/fnmatch.c
+5
-5
src/iterator.c
+4
-4
src/netops.c
+3
-3
src/path.c
+1
-1
src/util.c
+9
-9
src/util.h
+9
-0
tests/core/string.c
+42
-0
No files found.
src/config_file.c
View file @
82a7a24c
...
@@ -156,7 +156,7 @@ int git_config_file_normalize_section(char *start, char *end)
...
@@ -156,7 +156,7 @@ int git_config_file_normalize_section(char *start, char *end)
if
(
end
&&
scan
>=
end
)
if
(
end
&&
scan
>=
end
)
break
;
break
;
if
(
isalnum
(
*
scan
))
if
(
isalnum
(
*
scan
))
*
scan
=
(
char
)
tolower
(
*
scan
);
*
scan
=
(
char
)
git__
tolower
(
*
scan
);
else
if
(
*
scan
!=
'-'
||
scan
==
start
)
else
if
(
*
scan
!=
'-'
||
scan
==
start
)
return
GIT_EINVALIDSPEC
;
return
GIT_EINVALIDSPEC
;
}
}
...
@@ -1083,7 +1083,7 @@ static int parse_section_header(struct reader *reader, char **section_out)
...
@@ -1083,7 +1083,7 @@ static int parse_section_header(struct reader *reader, char **section_out)
goto
fail_parse
;
goto
fail_parse
;
}
}
name
[
name_length
++
]
=
(
char
)
tolower
(
c
);
name
[
name_length
++
]
=
(
char
)
git__
tolower
(
c
);
}
while
((
c
=
line
[
pos
++
])
!=
']'
);
}
while
((
c
=
line
[
pos
++
])
!=
']'
);
...
...
src/fnmatch.c
View file @
82a7a24c
...
@@ -164,8 +164,8 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs)
...
@@ -164,8 +164,8 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs)
default:
default:
normal:
normal:
if
(
c
!=
*
string
&&
!
((
flags
&
FNM_CASEFOLD
)
&&
if
(
c
!=
*
string
&&
!
((
flags
&
FNM_CASEFOLD
)
&&
(
tolower
((
unsigned
char
)
c
)
==
(
git__
tolower
((
unsigned
char
)
c
)
==
tolower
((
unsigned
char
)
*
string
))))
git__
tolower
((
unsigned
char
)
*
string
))))
return
(
FNM_NOMATCH
);
return
(
FNM_NOMATCH
);
++
string
;
++
string
;
break
;
break
;
...
@@ -190,7 +190,7 @@ rangematch(const char *pattern, char test, int flags, char **newp)
...
@@ -190,7 +190,7 @@ rangematch(const char *pattern, char test, int flags, char **newp)
++
pattern
;
++
pattern
;
if
(
flags
&
FNM_CASEFOLD
)
if
(
flags
&
FNM_CASEFOLD
)
test
=
(
char
)
tolower
((
unsigned
char
)
test
);
test
=
(
char
)
git__
tolower
((
unsigned
char
)
test
);
/*
/*
* A right bracket shall lose its special meaning and represent
* A right bracket shall lose its special meaning and represent
...
@@ -207,7 +207,7 @@ rangematch(const char *pattern, char test, int flags, char **newp)
...
@@ -207,7 +207,7 @@ rangematch(const char *pattern, char test, int flags, char **newp)
if
(
c
==
'/'
&&
(
flags
&
FNM_PATHNAME
))
if
(
c
==
'/'
&&
(
flags
&
FNM_PATHNAME
))
return
(
RANGE_NOMATCH
);
return
(
RANGE_NOMATCH
);
if
((
flags
&
FNM_CASEFOLD
))
if
((
flags
&
FNM_CASEFOLD
))
c
=
(
char
)
tolower
((
unsigned
char
)
c
);
c
=
(
char
)
git__
tolower
((
unsigned
char
)
c
);
if
(
*
pattern
==
'-'
if
(
*
pattern
==
'-'
&&
(
c2
=
*
(
pattern
+
1
))
!=
EOS
&&
c2
!=
']'
)
{
&&
(
c2
=
*
(
pattern
+
1
))
!=
EOS
&&
c2
!=
']'
)
{
pattern
+=
2
;
pattern
+=
2
;
...
@@ -216,7 +216,7 @@ rangematch(const char *pattern, char test, int flags, char **newp)
...
@@ -216,7 +216,7 @@ rangematch(const char *pattern, char test, int flags, char **newp)
if
(
c2
==
EOS
)
if
(
c2
==
EOS
)
return
(
RANGE_ERROR
);
return
(
RANGE_ERROR
);
if
(
flags
&
FNM_CASEFOLD
)
if
(
flags
&
FNM_CASEFOLD
)
c2
=
(
char
)
tolower
((
unsigned
char
)
c2
);
c2
=
(
char
)
git__
tolower
((
unsigned
char
)
c2
);
if
(
c
<=
test
&&
test
<=
c2
)
if
(
c
<=
test
&&
test
<=
c2
)
ok
=
1
;
ok
=
1
;
}
else
if
(
c
==
test
)
}
else
if
(
c
==
test
)
...
...
src/iterator.c
View file @
82a7a24c
...
@@ -1405,10 +1405,10 @@ GIT_INLINE(bool) workdir_path_is_dotgit(const git_buf *path)
...
@@ -1405,10 +1405,10 @@ GIT_INLINE(bool) workdir_path_is_dotgit(const git_buf *path)
if
(
path
->
ptr
[
len
-
1
]
==
'/'
)
if
(
path
->
ptr
[
len
-
1
]
==
'/'
)
len
--
;
len
--
;
if
(
tolower
(
path
->
ptr
[
len
-
1
])
!=
't'
||
if
(
git__
tolower
(
path
->
ptr
[
len
-
1
])
!=
't'
||
tolower
(
path
->
ptr
[
len
-
2
])
!=
'i'
||
git__
tolower
(
path
->
ptr
[
len
-
2
])
!=
'i'
||
tolower
(
path
->
ptr
[
len
-
3
])
!=
'g'
||
git__
tolower
(
path
->
ptr
[
len
-
3
])
!=
'g'
||
tolower
(
path
->
ptr
[
len
-
4
])
!=
'.'
)
git__
tolower
(
path
->
ptr
[
len
-
4
])
!=
'.'
)
return
false
;
return
false
;
return
(
len
==
4
||
path
->
ptr
[
len
-
5
]
==
'/'
);
return
(
len
==
4
||
path
->
ptr
[
len
-
5
]
==
'/'
);
...
...
src/netops.c
View file @
82a7a24c
...
@@ -84,7 +84,7 @@ void gitno_consume_n(gitno_buffer *buf, size_t cons)
...
@@ -84,7 +84,7 @@ void gitno_consume_n(gitno_buffer *buf, size_t cons)
int
gitno__match_host
(
const
char
*
pattern
,
const
char
*
host
)
int
gitno__match_host
(
const
char
*
pattern
,
const
char
*
host
)
{
{
for
(;;)
{
for
(;;)
{
char
c
=
tolower
(
*
pattern
++
);
char
c
=
git__
tolower
(
*
pattern
++
);
if
(
c
==
'\0'
)
if
(
c
==
'\0'
)
return
*
host
?
-
1
:
0
;
return
*
host
?
-
1
:
0
;
...
@@ -102,7 +102,7 @@ int gitno__match_host(const char *pattern, const char *host)
...
@@ -102,7 +102,7 @@ int gitno__match_host(const char *pattern, const char *host)
*/
*/
while
(
*
host
)
{
while
(
*
host
)
{
char
h
=
tolower
(
*
host
);
char
h
=
git__
tolower
(
*
host
);
if
(
c
==
h
)
if
(
c
==
h
)
return
gitno__match_host
(
pattern
,
host
++
);
return
gitno__match_host
(
pattern
,
host
++
);
if
(
h
==
'.'
)
if
(
h
==
'.'
)
...
@@ -112,7 +112,7 @@ int gitno__match_host(const char *pattern, const char *host)
...
@@ -112,7 +112,7 @@ int gitno__match_host(const char *pattern, const char *host)
return
-
1
;
return
-
1
;
}
}
if
(
c
!=
tolower
(
*
host
++
))
if
(
c
!=
git__
tolower
(
*
host
++
))
return
-
1
;
return
-
1
;
}
}
...
...
src/path.c
View file @
82a7a24c
...
@@ -1473,7 +1473,7 @@ static int32_t next_hfs_char(const char **in, size_t *len)
...
@@ -1473,7 +1473,7 @@ static int32_t next_hfs_char(const char **in, size_t *len)
* the ASCII range, which is perfectly fine, because the
* the ASCII range, which is perfectly fine, because the
* git folder name can only be composed of ascii characters
* git folder name can only be composed of ascii characters
*/
*/
return
tolower
(
codepoint
);
return
git__
tolower
(
codepoint
);
}
}
return
0
;
/* NULL byte -- end of string */
return
0
;
/* NULL byte -- end of string */
}
}
...
...
src/util.c
View file @
82a7a24c
...
@@ -171,9 +171,9 @@ int git__strcmp(const char *a, const char *b)
...
@@ -171,9 +171,9 @@ int git__strcmp(const char *a, const char *b)
int
git__strcasecmp
(
const
char
*
a
,
const
char
*
b
)
int
git__strcasecmp
(
const
char
*
a
,
const
char
*
b
)
{
{
while
(
*
a
&&
*
b
&&
tolower
(
*
a
)
==
tolower
(
*
b
))
while
(
*
a
&&
*
b
&&
git__tolower
(
*
a
)
==
git__
tolower
(
*
b
))
++
a
,
++
b
;
++
a
,
++
b
;
return
(
tolower
(
*
a
)
-
tolower
(
*
b
));
return
(
(
unsigned
char
)
git__tolower
(
*
a
)
-
(
unsigned
char
)
git__
tolower
(
*
b
));
}
}
int
git__strcasesort_cmp
(
const
char
*
a
,
const
char
*
b
)
int
git__strcasesort_cmp
(
const
char
*
a
,
const
char
*
b
)
...
@@ -182,7 +182,7 @@ int git__strcasesort_cmp(const char *a, const char *b)
...
@@ -182,7 +182,7 @@ int git__strcasesort_cmp(const char *a, const char *b)
while
(
*
a
&&
*
b
)
{
while
(
*
a
&&
*
b
)
{
if
(
*
a
!=
*
b
)
{
if
(
*
a
!=
*
b
)
{
if
(
tolower
(
*
a
)
!=
tolower
(
*
b
))
if
(
git__tolower
(
*
a
)
!=
git__
tolower
(
*
b
))
break
;
break
;
/* use case in sort order even if not in equivalence */
/* use case in sort order even if not in equivalence */
if
(
!
cmp
)
if
(
!
cmp
)
...
@@ -193,7 +193,7 @@ int git__strcasesort_cmp(const char *a, const char *b)
...
@@ -193,7 +193,7 @@ int git__strcasesort_cmp(const char *a, const char *b)
}
}
if
(
*
a
||
*
b
)
if
(
*
a
||
*
b
)
return
tolower
(
*
a
)
-
tolower
(
*
b
);
return
(
unsigned
char
)
git__tolower
(
*
a
)
-
(
unsigned
char
)
git__
tolower
(
*
b
);
return
cmp
;
return
cmp
;
}
}
...
@@ -212,8 +212,8 @@ int git__strncasecmp(const char *a, const char *b, size_t sz)
...
@@ -212,8 +212,8 @@ int git__strncasecmp(const char *a, const char *b, size_t sz)
int
al
,
bl
;
int
al
,
bl
;
do
{
do
{
al
=
(
unsigned
char
)
tolower
(
*
a
);
al
=
(
unsigned
char
)
git__
tolower
(
*
a
);
bl
=
(
unsigned
char
)
tolower
(
*
b
);
bl
=
(
unsigned
char
)
git__
tolower
(
*
b
);
++
a
,
++
b
;
++
a
,
++
b
;
}
while
(
--
sz
&&
al
&&
al
==
bl
);
}
while
(
--
sz
&&
al
&&
al
==
bl
);
...
@@ -225,7 +225,7 @@ void git__strntolower(char *str, size_t len)
...
@@ -225,7 +225,7 @@ void git__strntolower(char *str, size_t len)
size_t
i
;
size_t
i
;
for
(
i
=
0
;
i
<
len
;
++
i
)
{
for
(
i
=
0
;
i
<
len
;
++
i
)
{
str
[
i
]
=
(
char
)
tolower
(
str
[
i
]);
str
[
i
]
=
(
char
)
git__
tolower
(
str
[
i
]);
}
}
}
}
...
@@ -255,8 +255,8 @@ int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix)
...
@@ -255,8 +255,8 @@ int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix)
int
s
,
p
;
int
s
,
p
;
while
(
str_n
--
)
{
while
(
str_n
--
)
{
s
=
(
unsigned
char
)
tolower
(
*
str
++
);
s
=
(
unsigned
char
)
git__
tolower
(
*
str
++
);
p
=
(
unsigned
char
)
tolower
(
*
prefix
++
);
p
=
(
unsigned
char
)
git__
tolower
(
*
prefix
++
);
if
(
s
!=
p
)
if
(
s
!=
p
)
return
s
-
p
;
return
s
-
p
;
...
...
src/util.h
View file @
82a7a24c
...
@@ -275,6 +275,15 @@ extern char *git__strsep(char **end, const char *sep);
...
@@ -275,6 +275,15 @@ extern char *git__strsep(char **end, const char *sep);
extern
void
git__strntolower
(
char
*
str
,
size_t
len
);
extern
void
git__strntolower
(
char
*
str
,
size_t
len
);
extern
void
git__strtolower
(
char
*
str
);
extern
void
git__strtolower
(
char
*
str
);
#ifdef GIT_WIN32
GIT_INLINE
(
int
)
git__tolower
(
int
c
)
{
return
(
c
>=
'A'
&&
c
<=
'Z'
)
?
(
c
+
32
)
:
c
;
}
#else
# define git__tolower(a) tolower(a)
#endif
GIT_INLINE
(
const
char
*
)
git__next_line
(
const
char
*
s
)
GIT_INLINE
(
const
char
*
)
git__next_line
(
const
char
*
s
)
{
{
while
(
*
s
&&
*
s
!=
'\n'
)
s
++
;
while
(
*
s
&&
*
s
!=
'\n'
)
s
++
;
...
...
tests/core/string.c
View file @
82a7a24c
...
@@ -39,3 +39,45 @@ void test_core_string__2(void)
...
@@ -39,3 +39,45 @@ void test_core_string__2(void)
cl_assert
(
git__strcasesort_cmp
(
"BAR"
,
"foo"
)
<
0
);
cl_assert
(
git__strcasesort_cmp
(
"BAR"
,
"foo"
)
<
0
);
cl_assert
(
git__strcasesort_cmp
(
"fooBar"
,
"foobar"
)
<
0
);
cl_assert
(
git__strcasesort_cmp
(
"fooBar"
,
"foobar"
)
<
0
);
}
}
void
test_core_string__strcmp
(
void
)
{
cl_assert
(
git__strcmp
(
""
,
""
)
==
0
);
cl_assert
(
git__strcmp
(
"foo"
,
"foo"
)
==
0
);
cl_assert
(
git__strcmp
(
"Foo"
,
"foo"
)
<
0
);
cl_assert
(
git__strcmp
(
"foo"
,
"FOO"
)
>
0
);
cl_assert
(
git__strcmp
(
"foo"
,
"fOO"
)
>
0
);
cl_assert
(
strcmp
(
"rt
\303\202
of"
,
"rt dev
\302\266
h"
)
>
0
);
cl_assert
(
strcmp
(
"e
\342\202\254
ghi="
,
"et"
)
>
0
);
cl_assert
(
strcmp
(
"rt dev
\302\266
h"
,
"rt
\303\202
of"
)
<
0
);
cl_assert
(
strcmp
(
"et"
,
"e
\342\202\254
ghi="
)
<
0
);
cl_assert
(
strcmp
(
"
\303\215
"
,
"
\303\255
"
)
<
0
);
cl_assert
(
git__strcmp
(
"rt
\303\202
of"
,
"rt dev
\302\266
h"
)
>
0
);
cl_assert
(
git__strcmp
(
"e
\342\202\254
ghi="
,
"et"
)
>
0
);
cl_assert
(
git__strcmp
(
"rt dev
\302\266
h"
,
"rt
\303\202
of"
)
<
0
);
cl_assert
(
git__strcmp
(
"et"
,
"e
\342\202\254
ghi="
)
<
0
);
cl_assert
(
git__strcmp
(
"
\303\215
"
,
"
\303\255
"
)
<
0
);
}
void
test_core_string__strcasecmp
(
void
)
{
cl_assert
(
git__strcasecmp
(
""
,
""
)
==
0
);
cl_assert
(
git__strcasecmp
(
"foo"
,
"foo"
)
==
0
);
cl_assert
(
git__strcasecmp
(
"foo"
,
"Foo"
)
==
0
);
cl_assert
(
git__strcasecmp
(
"foo"
,
"FOO"
)
==
0
);
cl_assert
(
git__strcasecmp
(
"foo"
,
"fOO"
)
==
0
);
cl_assert
(
strcasecmp
(
"rt
\303\202
of"
,
"rt dev
\302\266
h"
)
>
0
);
cl_assert
(
strcasecmp
(
"e
\342\202\254
ghi="
,
"et"
)
>
0
);
cl_assert
(
strcasecmp
(
"rt dev
\302\266
h"
,
"rt
\303\202
of"
)
<
0
);
cl_assert
(
strcasecmp
(
"et"
,
"e
\342\202\254
ghi="
)
<
0
);
cl_assert
(
strcasecmp
(
"
\303\215
"
,
"
\303\255
"
)
<
0
);
cl_assert
(
git__strcasecmp
(
"rt
\303\202
of"
,
"rt dev
\302\266
h"
)
>
0
);
cl_assert
(
git__strcasecmp
(
"e
\342\202\254
ghi="
,
"et"
)
>
0
);
cl_assert
(
git__strcasecmp
(
"rt dev
\302\266
h"
,
"rt
\303\202
of"
)
<
0
);
cl_assert
(
git__strcasecmp
(
"et"
,
"e
\342\202\254
ghi="
)
<
0
);
cl_assert
(
git__strcasecmp
(
"
\303\215
"
,
"
\303\255
"
)
<
0
);
}
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