Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit27e19eb

Browse files
committed
#2 fixed guess style call with empty string
1 parent96617f8 commit27e19eb

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

‎CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ create_test(DEFAULT extension change_overlap)
9191
create_test(DEFAULT extension change_overlap_long)
9292
create_test(DEFAULT extension change_hidden_file)
9393
create_test(DEFAULT extension change_with_trailing_slash)
94+
create_test(DEFAULT guess empty_string)
9495
create_test(DEFAULT guess windows_root)
9596
create_test(DEFAULT guess unix_root)
9697
create_test(DEFAULT guess windows_separator)

‎docs/_layouts/default.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ <h1>{{ page.title }}</h1>
3939
<footer>
4040
find this repository on<ahref="https://github.com/likle/cwalk/tree/master">github</a>
4141
</footer>
42-
</html>
42+
</html>

‎docs/reference/cwk_path_guess_style.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ WINDOWS.
7474

7575
| Version| Description|
7676
|------------|--------------------------------------------------------|
77-
|**v1.2.0**| The function is introduced.|
77+
|**v1.2.1**| Fixed crash on call with empty string.|
78+
|**v1.2.0**| The function is introduced.|

‎src/cwalk.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,12 @@ enum cwk_path_style cwk_path_guess_style(const char *path)
13831383
// actually must be the first one), and determine whether the segment starts
13841384
// with a dot. A dot is a hidden folder or file in the UNIX world, in that
13851385
// case we assume the path to have UNIX style.
1386-
cwk_path_get_last_segment(path,&segment);
1386+
if (!cwk_path_get_last_segment(path,&segment)) {
1387+
// We couldn't find any segments, so we default to a UNIX path style since
1388+
// there is no way to make any assumptions.
1389+
returnCWK_STYLE_UNIX;
1390+
}
1391+
13871392
if (*segment.begin=='.') {
13881393
returnCWK_STYLE_UNIX;
13891394
}

‎test/guess_test.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#include<cwalk.h>
22
#include<stdlib.h>
33

4+
intguess_empty_string()
5+
{
6+
if (cwk_path_guess_style("")!=CWK_STYLE_UNIX) {
7+
returnEXIT_FAILURE;
8+
}
9+
10+
returnEXIT_SUCCESS;
11+
}
12+
413
intguess_unguessable()
514
{
615
if (cwk_path_guess_style("myfile")!=CWK_STYLE_UNIX) {
@@ -93,4 +102,4 @@ int guess_windows_root()
93102
}
94103

95104
returnEXIT_SUCCESS;
96-
}
105+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp