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

Commit795a5d9

Browse files
committed
#17 fixed cwk_path_get_relative with relative base
1 parent82eaf2a commit795a5d9

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

‎CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ if(ENABLE_TESTS)
184184
create_test(DEFAULT relative target_div_skipped_end)
185185
create_test(DEFAULT relative skip_all)
186186
create_test(DEFAULT relative different_roots)
187+
create_test(DEFAULT relative relative_and_absolute)
187188
create_test(DEFAULT relative check)
188189
create_test(DEFAULT relative root_path_unix)
189190
create_test(DEFAULT relative root_path_windows)

‎src/cwalk.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,8 @@ size_t cwk_path_get_relative(const char *base_directory, const char *path,
729729
// different roots.
730730
cwk_path_get_root(base_directory,&base_root_length);
731731
cwk_path_get_root(path,&path_root_length);
732-
if (!cwk_path_is_string_equal(base_directory,path,base_root_length)) {
732+
if (base_root_length!=path_root_length||
733+
!cwk_path_is_string_equal(base_directory,path,base_root_length)) {
733734
cwk_path_terminate_output(buffer,buffer_size,pos);
734735
returnpos;
735736
}

‎test/relative_test.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,28 @@ int relative_check()
7171
returnEXIT_SUCCESS;
7272
}
7373

74+
intrelative_relative_and_absolute()
75+
{
76+
charresult[FILENAME_MAX];
77+
size_tlength;
78+
79+
cwk_path_set_style(CWK_STYLE_UNIX);
80+
81+
*result=1;
82+
83+
length=cwk_path_get_relative("./foo","/bar",result,sizeof(result));
84+
85+
if (length!=0) {
86+
returnEXIT_FAILURE;
87+
}
88+
89+
if (*result!='\0') {
90+
returnEXIT_FAILURE;
91+
}
92+
93+
returnEXIT_SUCCESS;
94+
}
95+
7496
intrelative_different_roots()
7597
{
7698
charresult[FILENAME_MAX];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp