Skip to content

Commit d514b38

Browse files
committed
strempty: more correct
1 parent d7eb90a commit d514b38

File tree

8 files changed

+17
-8
lines changed

8 files changed

+17
-8
lines changed

+stdlib/+java/filesystem_type.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
end
1313

1414
t = '';
15-
if ~strlength(file), return, end
15+
if stdlib.strempty(file), return, end
1616

1717
try %#ok<TRYNC>
1818
t = char(java.nio.file.Files.getFileStore(javaPathObject(file)).type);

+stdlib/+java/get_owner.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
% https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/LinkOption.html
1616

1717
n = "";
18-
if ~strlength(file), return, end
18+
if stdlib.strempty(file), return, end
1919

2020
file = stdlib.absolute(file);
2121
% Java 1.8 benefits from absolute.

+stdlib/+python/get_owner.m

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

66
n = "";
77

8-
if ~strlength(file), return, end
8+
if stdlib.strempty(file), return, end
99

1010
try %#ok<TRYNC>
1111
n = string(py.pathlib.Path(file).owner());

+stdlib/+sys/is_removable.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
if ispc()
1111
r = stdlib.root_name(filepath);
12-
if ~strlength(r), return, end
12+
if stdlib.strempty(r)
13+
return
14+
end
1315
r = extractBefore(r, 2);
1416

1517
psFile = fullfile(fileparts(mfilename('fullpath')), "isRemovableDrive.ps1");

+stdlib/parent.m

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

1616
p = fileparts(stdlib.drop_slash(file));
1717

18-
i = ~strlength(p);
18+
i = stdlib.strempty(p);
1919
p(i) = ".";
2020

2121
% the ~all(i) is for Windows Matlab < R2025a

+stdlib/private/pvt_python_version.m

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

55
pe = pyenv();
66
vs = pe.Version;
7-
if ~strlength(vs), return, end
7+
if stdlib.strempty(vs), return, end
88

99
% this line may error like
1010
% "Python Error: TypeError: cannot create 'sys.version_info' instances"

+stdlib/strempty.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
%% STREMPTY is the char | string empty
2+
% that means literally string.empty OR strlength == 0
23

34
function y = strempty(s)
45

5-
y = isempty(s) | strlength(s) == 0;
6+
if isempty(s)
7+
y = true;
8+
else
9+
y = strlength(s) == 0;
10+
end
611

712
end

private/get_compiler.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
comp = co.Details.CompilerExecutable;
3232
% disp(lang + " compiler: " + co.ShortName + " " + co.Name + " " + co.Version + " " + comp)
3333
end
34-
if ~strlength(comp), return, end
34+
if stdlib.strempty(comp)
35+
return
36+
end
3537

3638
if ispc()
3739
if isempty(co)

0 commit comments

Comments
 (0)