Skip to content

Commit

Permalink
[test] inline skip_whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Mar 24, 2024
1 parent 5d8be93 commit 9ab2b4d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions loadjson.m
Original file line number Diff line number Diff line change
Expand Up @@ -430,21 +430,33 @@
function [pos, w1, w2] = parse_char(inputstr, pos, c, varargin)
w1 = pos;
w2 = 0;
pos = skip_whitespace(pos, inputstr, varargin{:});

while pos <= length(inputstr) && varargin{1}.isspace(pos)
pos = pos + 1;
end

w1 = pos - w1;
if pos > length(inputstr) || inputstr(pos) ~= c
pos = error_pos(sprintf('Expected %c at position %%d', c), inputstr, pos);
else
pos = pos + 1;
w2 = pos;
pos = skip_whitespace(pos, inputstr, varargin{:});

while pos <= length(inputstr) && varargin{1}.isspace(pos)
pos = pos + 1;
end

w2 = pos - w2;
end
%% -------------------------------------------------------------------------

function [c, pos, w1] = next_char(inputstr, pos, varargin)
w1 = pos;
pos = skip_whitespace(pos, inputstr, varargin{:});

while pos <= length(inputstr) && varargin{1}.isspace(pos)
pos = pos + 1;
end

w1 = pos - w1;
if pos > length(inputstr)
c = [];
Expand Down

0 comments on commit 9ab2b4d

Please sign in to comment.