Skip to content

Commit cfffe75

Browse files
authored
Merge pull request #177 from catch22/fix130again
workaround arm-specific regexprep bug
2 parents 67b196b + 3fa5777 commit cfffe75

File tree

4 files changed

+44
-14
lines changed

4 files changed

+44
-14
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: doctest
2-
Version: 0.6.0
3-
Date: 2017-12-25
2+
Version: 0.6.1
3+
Date: 2018-01-04
44
Author: various authors
55
Maintainer: Colin B. Macdonald <[email protected]>, Michael Walter <[email protected]>
66
Title: Documentation tests

NEWS

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
doctest 0.6.1 (2018-01-04)
2+
==========================
3+
4+
* Workaround regex bug on ARM (again!).
5+
6+
7+
18
doctest 0.6.0 (2017-12-25)
29
==========================
310

inst/doctest.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
[color_ok, color_err, color_warn, reset] = doctest_colors(fid);
274274

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

278278

279279
summary = struct();

inst/private/doctest_collect.m

+34-11
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,40 @@
338338
% Mark the occurrence of “@example” and “@end example” to be able to find
339339
% example blocks after conversion from texi to plain text. Also consider
340340
% indentation, so we can later correctly unindent the example's content.
341-
% Note: uses “@example” instead of “$2” to avoid ARM-specific bug #130.
342-
str = regexprep (str, ...
343-
'^([ \t]*)(\@example)(.*)$', ...
344-
[ '$1\@example$3\n', ... % retain original line
345-
'$1###### EXAMPLE START ######'], ...
346-
'lineanchors', 'dotexceptnewline', 'emptymatch');
347-
str = regexprep (str, ...
348-
'^([ \t]*)(\@end example)(.*)$', ...
349-
[ '$1###### EXAMPLE STOP ######\n', ...
350-
'$1\@end example$3'], ... % retain original line
351-
'lineanchors', 'dotexceptnewline', 'emptymatch');
341+
342+
% These should work, but I keep hitting ARM-specific when $1 is empty:
343+
% https://savannah.gnu.org/bugs/index.php?52810
344+
%str = regexprep (str, ...
345+
% '^([ \t]*)(\@example)(.*)$', ...
346+
% [ '$1$2$3\n', ... % retain original line
347+
% '$1###### EXAMPLE START ######'], ...
348+
% 'lineanchors', 'dotexceptnewline', 'emptymatch');
349+
%str = regexprep (str, ...
350+
% '^([ \t]*)(\@end example)(.*)$', ...
351+
% [ '$1###### EXAMPLE STOP ######\n', ...
352+
% '$1$2$3'], ... % retain original line
353+
% 'lineanchors', 'dotexceptnewline', 'emptymatch');
354+
355+
% Instead we do it manually
356+
[S, E, TE, M, T, NM, SP] = regexp (str, '^([ \t]*)(\@example)(.*)$', ...
357+
'lineanchors', 'dotexceptnewline', 'emptymatch');
358+
str = SP{1};
359+
for i=1:length (T)
360+
str = [str ...
361+
T{i}{:} sprintf('\n') ... % retain original line
362+
T{i}{1} '###### EXAMPLE START ######' ...
363+
SP{i+1}];
364+
end
365+
366+
[S, E, TE, M, T, NM, SP] = regexp (str, '^([ \t]*)(\@end example)(.*)$', ...
367+
'lineanchors', 'dotexceptnewline', 'emptymatch');
368+
str = SP{1};
369+
for i=1:length (T)
370+
str = [str ...
371+
T{i}{1} '###### EXAMPLE STOP ######' sprintf('\n') ...
372+
T{i}{:} ... % retain original line
373+
SP{i+1}];
374+
end
352375

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

0 commit comments

Comments
 (0)