Skip to content

Commit 22bd6ad

Browse files
committed
FIX: TO-LOCAL-FILE/FULL adding additional SLASH when used in root directory
Fixes: metaeducation/rebol-issues#2351
1 parent e313b9e commit 22bd6ad

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/core/s-file.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@
175175
dst->tail = abs(clen);
176176
//Append_Bytes(dst, lpath);
177177
#endif
178-
Append_Byte(dst, OS_DIR_SEP);
178+
if (OS_DIR_SEP != UNI_LAST(dst)[0])
179+
Append_Byte(dst, OS_DIR_SEP);
179180
OS_FREE(lpath);
180181
}
181182
out = UNI_HEAD(dst);

src/tests/run-tests.r3

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dt [ ;- delta time
3030
wrap load %units/compress-test.r3
3131
wrap load %units/date-test.r3
3232
wrap load %units/image-test.r3
33+
wrap load %units/file-test.r3
3334

3435
recycle/torture
3536
recycle

src/tests/units/file-test.r3

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Rebol [
2+
Title: "Rebol3 file test script"
3+
Author: "Oldes"
4+
File: %file-test.r3
5+
Tabs: 4
6+
Needs: [%../quick-test-module.r3]
7+
]
8+
9+
~~~start-file~~~ "FILE tests"
10+
11+
===start-group=== "to-local-file"
12+
13+
--test-- "issues/2351"
14+
;@@ https://github.com/rebol/rebol-issues/issues/2351
15+
f: first read what-dir
16+
--assert (to-rebol-file to-local-file/full f) = join what-dir f
17+
18+
d: what-dir
19+
cd %/ f: first read %/
20+
--assert (to-rebol-file to-local-file/full f) = join what-dir f
21+
cd d
22+
23+
===end-group===
24+
25+
~~~end-file~~~

0 commit comments

Comments
 (0)