Skip to content

Commit 33263de

Browse files
committed
completely reformat m-files using miss_hit
1 parent 3ff781f commit 33263de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4312
-4329
lines changed

.miss_hit

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
project_root
22

33
suppress_rule: "redundant_brackets"
4+
suppress_rule: "line_length"
5+
suppress_rule: "file_length"
6+
suppress_rule: "copyright_notice"
7+
suppress_rule: "naming_functions"
8+
suppress_rule: "naming_parameters"
9+
suppress_rule: "naming_scripts"
10+
suppress_rule: "unicode"
411
indent_function_file_body: false

base64decode.m

+10-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
% output = base64decode(input)
44
%
55
% Decoding a Base64-encoded byte-stream to recover the original data
6-
% This function depends on JVM in MATLAB or, can optionally use the ZMat
6+
% This function depends on JVM in MATLAB or, can optionally use the ZMat
77
% toolbox (http://github.com/NeuroJSON/zmat)
88
%
99
% Copyright (c) 2012, Kota Yamaguchi
@@ -22,28 +22,27 @@
2222
% orig=char(base64decode(bytes))
2323
%
2424
% license:
25-
% BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
25+
% BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
2626
%
2727
% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
2828
%
2929

30-
if(nargin==0)
30+
if (nargin == 0)
3131
error('you must provide at least 1 input');
3232
end
33-
if(exist('zmat','file')==2 || exist('zmat','file')==3)
34-
output=zmat(varargin{1},0,'base64');
35-
return;
36-
elseif(isoctavemesh)
33+
if (exist('zmat', 'file') == 2 || exist('zmat', 'file') == 3)
34+
output = zmat(varargin{1}, 0, 'base64');
35+
return
36+
elseif (isoctavemesh)
3737
error('You must install the ZMat toolbox (http://github.com/NeuroJSON/zmat) to use this function in Octave');
3838
end
3939

4040
error(javachk('jvm'));
4141

42-
if(ischar(varargin{1}))
43-
varargin{1}=uint8(varargin{1});
42+
if (ischar(varargin{1}))
43+
varargin{1} = uint8(varargin{1});
4444
end
4545

46-
input=typecast(varargin{1}(:)','uint8');
46+
input = typecast(varargin{1}(:)', 'uint8');
4747

4848
output = typecast(org.apache.commons.codec.binary.Base64.decodeBase64(input), 'uint8')';
49-

base64encode.m

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
%
55
% Encoding a binary vector or array using Base64
66
%
7-
% This function depends on JVM in MATLAB or, can optionally use the ZMat
7+
% This function depends on JVM in MATLAB or, can optionally use the ZMat
88
% toolbox (http://github.com/NeuroJSON/zmat)
99
%
1010
% Copyright (c) 2012, Kota Yamaguchi
@@ -23,29 +23,29 @@
2323
% orig=char(base64decode(bytes))
2424
%
2525
% license:
26-
% BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
26+
% BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
2727
%
2828
% -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
2929
%
3030

31-
if(nargin==0)
31+
if (nargin == 0)
3232
error('you must provide at least 1 input');
3333
end
3434

35-
if(exist('zmat','file')==2 || exist('zmat','file')==3)
36-
[varargout{1:nargout}]=zmat(varargin{1}, 1,'base64',varargin{2:end});
37-
return;
35+
if (exist('zmat', 'file') == 2 || exist('zmat', 'file') == 3)
36+
[varargout{1:nargout}] = zmat(varargin{1}, 1, 'base64', varargin{2:end});
37+
return
3838
end
3939

40-
if(ischar(varargin{1}))
41-
varargin{1}=uint8(varargin{1});
40+
if (ischar(varargin{1}))
41+
varargin{1} = uint8(varargin{1});
4242
end
4343

44-
input=typecast(varargin{1}(:)','uint8');
44+
input = typecast(varargin{1}(:)', 'uint8');
4545

46-
if(isoctavemesh)
46+
if (isoctavemesh)
4747
varargout{1} = base64_encode(uint8(input));
48-
return;
48+
return
4949
end
5050

5151
error(javachk('jvm'));
@@ -54,4 +54,4 @@
5454
end
5555

5656
varargout{1} = char(org.apache.commons.codec.binary.Base64.encodeBase64Chunked(input))';
57-
varargout{1} = regexprep(varargout{1} ,'\r','');
57+
varargout{1} = regexprep(varargout{1}, '[\r\n]', '');

decodevarname.m

+35-35
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function newname = decodevarname(name,varargin)
1+
function newname = decodevarname(name, varargin)
22
%
33
% newname = decodevarname(name)
44
%
@@ -16,61 +16,61 @@
1616
% letter into "x0xHH_" and non-ascii letters into "_0xHH_"
1717
% format, where hex key HH stores the ascii (or Unicode) value
1818
% of the character.
19-
%
19+
%
2020
% output:
2121
% newname: the restored original string
2222
%
2323
% example:
2424
% decodevarname('x0x5F_a') % returns _a
2525
% decodevarname('a_') % returns a_ as it is a valid variable name
26-
% decodevarname('x0xE58F98__0xE9878F_') % returns '变量'
26+
% decodevarname('x0xE58F98__0xE9878F_') % returns '变量'
2727
%
2828
% this file is part of EasyH5 Toolbox: https://github.com/NeuroJSON/easyh5
2929
%
3030
% License: GPLv3 or 3-clause BSD license, see https://github.com/NeuroJSON/easyh5 for details
3131
%
3232

33-
newname=name;
34-
isunpack=1;
35-
if(nargin==2 && ~isstruct(varargin{1}))
36-
isunpack=varargin{1};
37-
elseif(nargin>1)
38-
isunpack=jsonopt('UnpackHex',1,varargin{:});
33+
newname = name;
34+
isunpack = 1;
35+
if (nargin == 2 && ~isstruct(varargin{1}))
36+
isunpack = varargin{1};
37+
elseif (nargin > 1)
38+
isunpack = jsonopt('UnpackHex', 1, varargin{:});
3939
end
4040

41-
if(isunpack)
42-
if(isempty(strfind(name, '0x')) || isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
41+
if (isunpack)
42+
if (isempty(strfind(name, '0x')) || isempty(regexp(name, '0x([0-9a-fA-F]+)_', 'once')))
4343
return
4444
end
45-
if(exist('native2unicode','builtin'))
46-
h2u=@hex2unicode;
47-
newname=regexprep(name,'(^x|_){1}0x([0-9a-fA-F]+)_','${h2u($2)}');
45+
if (exist('native2unicode', 'builtin'))
46+
h2u = @hex2unicode;
47+
newname = regexprep(name, '(^x|_){1}0x([0-9a-fA-F]+)_', '${h2u($2)}');
4848
else
49-
if(isunpack && strcmp(name,'x0x0_'))
50-
newname='';
51-
return;
49+
if (isunpack && strcmp(name, 'x0x0_'))
50+
newname = '';
51+
return
5252
end
53-
pos=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','start');
54-
pend=regexp(name,'(^x|_){1}0x([0-9a-fA-F]+)_','end');
55-
if(isempty(pos))
56-
return;
53+
pos = regexp(name, '(^x|_){1}0x([0-9a-fA-F]+)_', 'start');
54+
pend = regexp(name, '(^x|_){1}0x([0-9a-fA-F]+)_', 'end');
55+
if (isempty(pos))
56+
return
5757
end
58-
str0=name;
59-
pos0=[0 pend(:)' length(name)];
60-
newname='';
61-
for i=1:length(pos)
62-
newname=[newname str0(pos0(i)+1:pos(i)-1) char(hex2dec(str0(pos(i)+3:pend(i)-1)))];
58+
str0 = name;
59+
pos0 = [0 pend(:)' length(name)];
60+
newname = '';
61+
for i = 1:length(pos)
62+
newname = [newname str0(pos0(i) + 1:pos(i) - 1) char(hex2dec(str0(pos(i) + 3:pend(i) - 1)))];
6363
end
64-
if(pos(end)~=length(name))
65-
newname=[newname str0(pos0(end-1)+1:pos0(end))];
64+
if (pos(end) ~= length(name))
65+
newname = [newname str0(pos0(end - 1) + 1:pos0(end))];
6666
end
6767
end
6868
end
6969

70-
%--------------------------------------------------------------------------
71-
function str=hex2unicode(hexstr)
72-
val=hex2dec(hexstr);
73-
id=histc(val,[0 2^8 2^16 2^32 2^64]);
74-
type={'uint8','uint16','uint32','uint64'};
75-
bytes=typecast(cast(val,type{id~=0}),'uint8');
76-
str=native2unicode(fliplr(bytes(:,1:find(bytes,1,'last'))));
70+
% --------------------------------------------------------------------------
71+
function str = hex2unicode(hexstr)
72+
val = hex2dec(hexstr);
73+
id = histc(val, [0 2^8 2^16 2^32 2^64]);
74+
type = {'uint8', 'uint16', 'uint32', 'uint64'};
75+
bytes = typecast(cast(val, type{id ~= 0}), 'uint8');
76+
str = native2unicode(fliplr(bytes(:, 1:find(bytes, 1, 'last'))));

encodevarname.m

+28-29
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
function str = encodevarname(str,varargin)
1+
function str = encodevarname(str, varargin)
22
%
33
% newname = encodevarname(name)
44
%
55
% Encode an invalid variable name using a hex-format for bi-directional
6-
% conversions.
6+
% conversions.
77

88
% This function is sensitive to the default charset
99
% settings in MATLAB, please call feature('DefaultCharacterSet','utf8')
@@ -20,7 +20,7 @@
2020
% format, where HH is the ascii (or Unicode) value of the
2121
% character.
2222
%
23-
% if the encoded variable name CAN NOT be longer than 63, i.e.
23+
% if the encoded variable name CAN NOT be longer than 63, i.e.
2424
% the maximum variable name specified by namelengthmax, and
2525
% one uses the output of this function as a struct or variable
2626
% name, the name will be truncated at 63. Please consider using
@@ -30,39 +30,38 @@
3030
% example:
3131
% encodevarname('_a') % returns x0x5F_a
3232
% encodevarname('a_') % returns a_ as it is a valid variable name
33-
% encodevarname('变量') % returns 'x0xE58F98__0xE9878F_'
33+
% encodevarname('变量') % returns 'x0xE58F98__0xE9878F_'
3434
%
3535
% this file is part of EasyH5 Toolbox: https://github.com/NeuroJSON/easyh5
3636
%
3737
% License: GPLv3 or 3-clause BSD license, see https://github.com/NeuroJSON/easyh5 for details
3838
%
3939

40-
if(~isvarname(str(1)))
41-
if(exist('unicode2native','builtin'))
42-
str=sprintf('x0x%s_%s',sprintf('%X',unicode2native(str(1))),str(2:end));
43-
else
44-
str=sprintf('x0x%X_%s',char(str(1))+0,str(2:end));
45-
end
40+
if (~isvarname(str(1)))
41+
if (exist('unicode2native', 'builtin'))
42+
str = sprintf('x0x%s_%s', sprintf('%X', unicode2native(str(1))), str(2:end));
43+
else
44+
str = sprintf('x0x%X_%s', char(str(1)) + 0, str(2:end));
4645
end
47-
if(isvarname(str))
48-
return;
46+
end
47+
if (isvarname(str))
48+
return
49+
end
50+
if (exist('unicode2native', 'builtin'))
51+
str = regexprep(str, '([^0-9A-Za-z_])', '_0x${sprintf(''%X'',unicode2native($1))}_');
52+
else
53+
cpos = find(~ismember(str, ['0':'9', 'A':'Z', 'a':'z', '_']));
54+
% cpos=regexp(str,'[^0-9A-Za-z_]');
55+
if (isempty(cpos))
56+
return
4957
end
50-
if(exist('unicode2native','builtin'))
51-
str=regexprep(str,'([^0-9A-Za-z_])','_0x${sprintf(''%X'',unicode2native($1))}_');
52-
else
53-
cpos=find(~ismember(str, ['0':'9','A':'Z','a':'z','_']));
54-
%cpos=regexp(str,'[^0-9A-Za-z_]');
55-
if(isempty(cpos))
56-
return;
57-
end
58-
str0=str;
59-
pos0=[0 cpos(:)' length(str)];
60-
str='';
61-
for i=1:length(cpos)
62-
str=[str str0(pos0(i)+1:cpos(i)-1) sprintf('_0x%X_',str0(cpos(i))+0)];
63-
end
64-
if(cpos(end)~=length(str))
65-
str=[str str0(pos0(end-1)+1:pos0(end))];
66-
end
58+
str0 = str;
59+
pos0 = [0 cpos(:)' length(str)];
60+
str = '';
61+
for i = 1:length(cpos)
62+
str = [str str0(pos0(i) + 1:cpos(i) - 1) sprintf('_0x%X_', str0(cpos(i)) + 0)];
63+
end
64+
if (cpos(end) ~= length(str))
65+
str = [str str0(pos0(end - 1) + 1:pos0(end))];
6766
end
6867
end

0 commit comments

Comments
 (0)