changeset 31257:2deb14b9ad27

Replace all occurrences of @seealso in docstring with @xseealso (bug #63141). * scripts/help/__makeinfo__.m: Avoid greedy regular expression to match too many characters. Loop over and replace all matches of "@seealso".
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 01 Oct 2022 13:36:56 +0200
parents fa4bb329a51a
children 473ac0a602b9
files scripts/help/__makeinfo__.m
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/help/__makeinfo__.m	Tue Oct 04 17:05:21 2022 -0700
+++ b/scripts/help/__makeinfo__.m	Sat Oct 01 13:36:56 2022 +0200
@@ -102,11 +102,14 @@
   ## Texinfo crashes if @end tex does not appear first on the line.
   text = regexprep (text, '^ +@end tex', '@end tex', 'lineanchors');
   ## Replace @seealso with Octave specific @xseealso macro, and escape '@'
-  [s, e] = regexp (text, '@seealso{.*}');
-  if (! isempty (s))
-    esc_text = strrep (text(s+8:e), '@', '@@');
-    text = [text(1:s), 'xseealso', esc_text, text(e+1:end)];
-  endif
+  [s, e] = regexp (text, '@seealso{[^}]*}');
+  cum_rep = 0;
+  for (i_match = 1:numel (s))
+    esc_text = strrep (text(((s(i_match)+8:e(i_match))+i_match-1)+cum_rep), '@', '@@');
+    text = [text(1:s(i_match)+i_match+cum_rep-1), 'xseealso', esc_text, ...
+            text(e(i_match)+1+i_match+cum_rep-1:end)];
+    cum_rep += numel (esc_text) - (e(i_match)-(s(i_match)+8)+1);
+  endfor
 
   ## We don't want *ref macros to clutter plain text output with "Note ..."
   if (strcmp (output_type, "plain text"))