We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a69e172 commit 4a355b2Copy full SHA for 4a355b2
+stdlib/root.m
@@ -5,25 +5,23 @@
5
6
function r = root(p)
7
arguments
8
- p (1,1) string
+ p {mustBeTextScalar}
9
end
10
11
r = stdlib.root_name(p);
12
13
if ~strlength(r)
14
- if strncmp(p, "/", 1)
15
- r = "/";
+ if strncmp(p, '/', 1)
+ r = '/';
16
17
-
18
- return
+elseif ~(ispc && strcmp(r, p))
+ r = strcat(r, '/');
19
20
21
-if ispc && strcmp(r, p)
22
+if isstring(p)
+ r = string(r);
23
24
25
-r = strcat(r, "/");
26
27
28
29
%!assert(root(''), '')
test/TestRoot.m
@@ -18,7 +18,7 @@ function test_root(tc, p)
p = {{"", ""}, ...
{"a/b", ""}, ...
{"./a/b", ""}, ...
-{"/etc", "/"}, ...
+{'/etc', '/'}, ...
{"c:", ""}, ...
{"c:/etc", ""}};
0 commit comments