Skip to content

Commit e85a10f

Browse files
committed
root_name: improve correctness
1 parent 05be111 commit e85a10f

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

+stdlib/root_name.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
p {mustBeTextScalar}
1111
end
1212

13-
r = "";
13+
r = '';
1414

1515
if ~ispc || strlength(p) < 2
16-
return
17-
end
18-
19-
c = char(p);
16+
% noop
17+
else
18+
c = char(p);
2019

21-
if c(2) == ':' && isletter(c(1))
22-
r = c(1:2);
20+
if c(2) == ':' && isletter(c(1))
21+
r = c(1:2);
22+
end
2323
end
2424

2525
if isstring(p)

test/TestFilePure.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function test_root_name(tc, p)
3636

3737
p = {{"", ""}, ...
3838
{"a/b", ""}, ...
39-
{"/etc", ""}, ...
39+
{'/etc', ''}, ...
4040
{"c:/etc", ""}
4141
};
4242

test/TestFilename.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
properties (TestParameter)
44
p = {
5+
{'', ''}, ...
56
{"", ""}, ...
67
{"/a/b/c", "c"}, ...
7-
{"/a/b/c/", ""}, ...
8-
{"a/b/c.txt", "c.txt"}, ...
8+
{'/a/b/c/', ''}, ...
9+
{'a/b/c.txt', 'c.txt'}, ...
910
{"a/b/c.txt.gz", "c.txt.gz"}, ...
1011
};
1112
end

0 commit comments

Comments
 (0)