Mercurial > octave
comparison scripts/help/print_usage.m @ 30244:4fe897f5db8e
print_usage.m: Fix error on invalid texinfo (bug #61363).
* scripts/help/print_usage.m (get_usage_texinfo): Do not call __makeinfo__ if
help string doesn't contain a @def* macro.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Thu, 21 Oct 2021 16:42:38 +0200 |
parents | 7854d5752dd2 |
children | 63147d7d53a0 |
comparison
equal
deleted
inserted
replaced
30243:a4061ae5ff79 | 30244:4fe897f5db8e |
---|---|
115 | 115 |
116 ## Find, and keep, lines that start with @def or @end def. This should | 116 ## Find, and keep, lines that start with @def or @end def. This should |
117 ## include things such as @deftypefn, @deftypefnx, @defvar, etc. and their | 117 ## include things such as @deftypefn, @deftypefnx, @defvar, etc. and their |
118 ## corresponding @end's. | 118 ## corresponding @end's. |
119 def_idx = strfind (help_text, "@def"); | 119 def_idx = strfind (help_text, "@def"); |
120 if (! isempty (def_idx)) | 120 if (isempty (def_idx)) |
121 endf_idx = strfind (help_text, "@end def"); | |
122 def_idx = sort ([def_idx, endf_idx]); | |
123 endl_idx = find (help_text == "\n"); | |
124 buffer = ""; | |
125 for k = 1:length (def_idx) | |
126 endl = endl_idx(find (endl_idx > def_idx(k), 1)); | |
127 if (isempty (endl)) | |
128 buffer = [buffer, help_text(def_idx(k):end), "\n"]; | |
129 else | |
130 buffer = [buffer, help_text(def_idx(k):endl)]; | |
131 endif | |
132 endfor | |
133 else | |
134 [retval, status] = get_usage_plain_text (help_text, max_len); | 121 [retval, status] = get_usage_plain_text (help_text, max_len); |
122 return; | |
135 endif | 123 endif |
124 | |
125 endf_idx = strfind (help_text, "@end def"); | |
126 def_idx = sort ([def_idx, endf_idx]); | |
127 endl_idx = find (help_text == "\n"); | |
128 buffer = ""; | |
129 for k = 1:length (def_idx) | |
130 endl = endl_idx(find (endl_idx > def_idx(k), 1)); | |
131 if (isempty (endl)) | |
132 buffer = [buffer, help_text(def_idx(k):end), "\n"]; | |
133 else | |
134 buffer = [buffer, help_text(def_idx(k):endl)]; | |
135 endif | |
136 endfor | |
136 | 137 |
137 ## Run makeinfo to generate plain text | 138 ## Run makeinfo to generate plain text |
138 [retval, status] = __makeinfo__ (buffer, "plain text"); | 139 [retval, status] = __makeinfo__ (buffer, "plain text"); |
139 | 140 |
140 endfunction | 141 endfunction |