Skip to content

Commit 248b564

Browse files
committed
use fullfile where appropriate
1 parent 167cf48 commit 248b564

File tree

11 files changed

+23
-29
lines changed

11 files changed

+23
-29
lines changed

+stdlib/absolute.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
end
3434

3535
if ~strempty(c)
36-
c = strcat(b, '/', c);
36+
c = fullfile(b, c);
3737
else
3838
c = b;
3939
end
@@ -46,4 +46,4 @@
4646

4747

4848
%!assert(absolute('', ''), pwd)
49-
%!assert(absolute('a/b', ''), strcat(pwd(), '/a/b'))
49+
%!assert(absolute('a/b', ''), fullfile(pwd(), 'a/b'))

+stdlib/expanduser.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
elseif L < 2
2525
e = home;
2626
else
27-
e = strcat(home, '/', e(3:end));
27+
e = fullfile(home, e(3:end));
2828
end
2929
end
3030

@@ -40,4 +40,4 @@
4040
%!assert(expanduser("~/"), strcat(homedir(), '/'))
4141
%!assert(expanduser("~user"), "~user")
4242
%!assert(expanduser("~user/"), "~user/")
43-
%!assert(expanduser("~/c"), strcat(homedir(), "/c"))
43+
%!assert(expanduser("~/c"), fullfile(homedir(), "c"))

+stdlib/get_shell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
cmd = "(dir 2>&1 *`|echo CMD);&<# rem #>echo ($PSVersionTable).PSEdition";
88
else
99
% https://askubuntu.com/a/1349538
10-
cmd = strcat("lsof -p ", '"$$"', " | grep -m 1 txt | xargs -n 1 | tail -n +9");
10+
cmd = strjoin({'lsof -p', '"$$"', '|','grep -m 1 txt', '|', 'xargs -n 1', '|', 'tail -n +9'});
1111
end
1212

1313
[r, msg] = system(cmd);

+stdlib/homedir.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
h = getenv("HOME");
99
end
1010

11-
h = stdlib.posix(h);
12-
1311
end
1412

1513
%!assert(!isempty(homedir()))

+stdlib/join.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,15 @@
1717
elseif ~strempty(rdo)
1818

1919
if ~strempty(rnb)
20-
p = strcat(rnb, '/', other);
20+
p = fullfile(rnb, other);
2121
else
2222
p = other;
2323
end
2424

2525
elseif ~strempty(base)
2626

2727
if ~strempty(other)
28-
if endsWith(base, {'/', filesep})
29-
p = strcat(base, other);
30-
else
31-
p = strcat(base, '/', other);
32-
end
28+
p = fullfile(base, other);
3329
else
3430
p = base;
3531
end

+stdlib/which.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
if strempty(p), continue, end
5555

56-
e = strcat(p, '/', cmd);
56+
e = fullfile(p, cmd);
5757
if isfile(e) && stdlib.is_exe(e)
5858
if find_all
5959
exe(end+1) = e; %#ok<AGROW>

+stdlib/with_suffix.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
if strcmp(r, '.')
2828
f = s;
2929
else
30-
f = strcat(r, filesep, s);
30+
f = fullfile(r, s);
3131
end
3232

3333
f = strcat(f, suffix);

test/TestAbsolute.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function test_absolute1arg(tc, p1)
2626
r = tc.td;
2727

2828
if strlength(p1)
29-
r = strcat(r, '/', p1);
29+
r = fullfile(r, p1);
3030
end
3131

3232
if isstring(p1)
@@ -42,11 +42,11 @@ function test_absolute2arg(tc, p2)
4242
r = tc.td;
4343

4444
if strlength(p2{2})
45-
r = strcat(r, '/', p2{2});
45+
r = fullfile(r, p2{2});
4646
end
4747

4848
if strlength(p2{1})
49-
r = strcat(r, '/', p2{1});
49+
r = fullfile(r, p2{1});
5050
end
5151

5252
if isstring(p2{1}) || isstring(p2{2})

test/TestExpanduser.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
{"~abc", "~abc"}, ...
77
{'~', stdlib.homedir()},...
88
{"~", string(stdlib.homedir())}, ...
9-
{'~/', strcat(stdlib.homedir(), '/')},...
10-
{"~/", stdlib.homedir() + "/"}, ...
11-
{"~/c", stdlib.homedir() + "/c"}, ...
12-
{"~//c", stdlib.homedir() + "//c"}};
9+
{'~/', stdlib.homedir()},...
10+
{"~/", string(stdlib.homedir())}, ...
11+
{"~/c", fullfile(stdlib.homedir(), "c")}, ...
12+
{"~//c", fullfile(stdlib.homedir(), "c")}};
1313
end
1414

1515
methods(Test, TestTags="impure")

test/TestJoin.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
p = {{"", "", ""}, ...
55
{"a", "", "a"}, ...
66
{"", "a", "a"}, ...
7-
{"a/b/", "c", "a/b/c"}, ...
7+
{"a/b/", "c", fullfile("a", "b", "c")}, ...
88
{"/", "", "/"}, ...
99
{"", "/", "/"}, ...
10-
{"a", "b", "a/b"}, ...
11-
{"a/b/../", "c/d/..", "a/b/../c/d/.."}, ...
12-
{"a/b", "..", "a/b/.."}, ...
13-
{"a/b", "c/d", "a/b/c/d"}, ...
10+
{"a", "b", fullfile("a", "b")}, ...
11+
{"a/b/../", "c/d/..", fullfile("a", "b", "..", "c", "d", "..")}, ...
12+
{"a/b", "..", fullfile("a", "b", "..")}, ...
13+
{"a/b", "c/d", fullfile("a", "b", "c", "d")}, ...
1414
{"ab/cd", "/ef", "/ef"}, ...
1515
{stdlib.homedir(), "", stdlib.homedir()}, ...
16-
{matlabroot, "bin", matlabroot + "/bin"}
16+
{matlabroot, "bin", fullfile(matlabroot, "bin")}
1717
}
1818
end
1919

0 commit comments

Comments
 (0)