Skip to content

Commit

Permalink
Merge pull request #177 from catch22/fix130again
Browse files Browse the repository at this point in the history
workaround arm-specific regexprep bug
  • Loading branch information
cbm755 authored Jan 4, 2018
2 parents 67b196b + 3fa5777 commit cfffe75
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: doctest
Version: 0.6.0
Date: 2017-12-25
Version: 0.6.1
Date: 2018-01-04
Author: various authors
Maintainer: Colin B. Macdonald <[email protected]>, Michael Walter <[email protected]>
Title: Documentation tests
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
doctest 0.6.1 (2018-01-04)
==========================

* Workaround regex bug on ARM (again!).



doctest 0.6.0 (2017-12-25)
==========================

Expand Down
2 changes: 1 addition & 1 deletion inst/doctest.m
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
[color_ok, color_err, color_warn, reset] = doctest_colors(fid);

% print banner
fprintf(fid, 'Doctest v0.6.0: this is Free Software without warranty, see source.\n\n');
fprintf(fid, 'Doctest v0.6.1: this is Free Software without warranty, see source.\n\n');


summary = struct();
Expand Down
45 changes: 34 additions & 11 deletions inst/private/doctest_collect.m
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,40 @@
% Mark the occurrence of “@example” and “@end example” to be able to find
% example blocks after conversion from texi to plain text. Also consider
% indentation, so we can later correctly unindent the example's content.
% Note: uses “@example” instead of “$2” to avoid ARM-specific bug #130.
str = regexprep (str, ...
'^([ \t]*)(\@example)(.*)$', ...
[ '$1\@example$3\n', ... % retain original line
'$1###### EXAMPLE START ######'], ...
'lineanchors', 'dotexceptnewline', 'emptymatch');
str = regexprep (str, ...
'^([ \t]*)(\@end example)(.*)$', ...
[ '$1###### EXAMPLE STOP ######\n', ...
'$1\@end example$3'], ... % retain original line
'lineanchors', 'dotexceptnewline', 'emptymatch');

% These should work, but I keep hitting ARM-specific when $1 is empty:
% https://savannah.gnu.org/bugs/index.php?52810
%str = regexprep (str, ...
% '^([ \t]*)(\@example)(.*)$', ...
% [ '$1$2$3\n', ... % retain original line
% '$1###### EXAMPLE START ######'], ...
% 'lineanchors', 'dotexceptnewline', 'emptymatch');
%str = regexprep (str, ...
% '^([ \t]*)(\@end example)(.*)$', ...
% [ '$1###### EXAMPLE STOP ######\n', ...
% '$1$2$3'], ... % retain original line
% 'lineanchors', 'dotexceptnewline', 'emptymatch');

% Instead we do it manually
[S, E, TE, M, T, NM, SP] = regexp (str, '^([ \t]*)(\@example)(.*)$', ...
'lineanchors', 'dotexceptnewline', 'emptymatch');
str = SP{1};
for i=1:length (T)
str = [str ...
T{i}{:} sprintf('\n') ... % retain original line
T{i}{1} '###### EXAMPLE START ######' ...
SP{i+1}];
end

[S, E, TE, M, T, NM, SP] = regexp (str, '^([ \t]*)(\@end example)(.*)$', ...
'lineanchors', 'dotexceptnewline', 'emptymatch');
str = SP{1};
for i=1:length (T)
str = [str ...
T{i}{1} '###### EXAMPLE STOP ######' sprintf('\n') ...
T{i}{:} ... % retain original line
SP{i+1}];
end

% special comments "@c doctest: cmd" are translated
% FIXME the expression would also match @@c doctest: ...
Expand Down

0 comments on commit cfffe75

Please sign in to comment.