comparison libinterp/corefcn/help.cc @ 22199:af0dca907fae

get help text for operators and keywords from docstrings file * help.cc (map_type, pair_type, map_iter): Delete typedefs. (size, names, raw_help_from_map): Delete functions. (operators, keywords): Now simple list of strings. Store only name, not help text. (operators_map, keywords_map): Delete. (operator_names): New variable. (keyword_names): Simplify definition. (raw_help): Don't call raw_help_from_map to search for help text for operators or keywords. (F__operators__, F__keywords__): Simplify using operator_names and keyword_names.
author John W. Eaton <jwe@octave.org>
date Tue, 02 Aug 2016 03:40:02 -0400
parents f6181638f6c5
children 12f1d273d22a
comparison
equal deleted inserted replaced
22198:f6181638f6c5 22199:af0dca907fae
90 90
91 // If TRUE, don't print additional help message in help and usage 91 // If TRUE, don't print additional help message in help and usage
92 // functions. 92 // functions.
93 static bool Vsuppress_verbose_help_message = false; 93 static bool Vsuppress_verbose_help_message = false;
94 94
95 #include <map> 95 const static char * const operators[] =
96 96 {
97 typedef std::map<std::string, std::string> map_type; 97 "!",
98 typedef map_type::value_type pair_type; 98 "~",
99 typedef map_type::const_iterator map_iter; 99 "!=",
100 100 "~=",
101 template <typename T, size_t z> 101 "\"",
102 size_t 102 "#",
103 size (T const (&)[z]) 103 "%",
104 { 104 "#{",
105 return z; 105 "%{",
106 } 106 "#}",
107 107 "%}",
108 // FIXME: the doc strings for operators and keywords is currently 108 "...",
109 // duplicated in op-kw-docs. We should arrange for Octave to read the 109 "&",
110 // info from that file (or the generated DOCSTRINGS file) at startup 110 "&&",
111 // instead and remove the data from this file. 111 "'",
112 112 "(",
113 const static pair_type operators[] = 113 ")",
114 { 114 "*",
115 pair_type ("!", 115 "**",
116 "-*- texinfo -*-\n\ 116 "^",
117 @deftypefn {} {} !\n\ 117 "+",
118 Logical 'not' operator.\n\ 118 "++",
119 @seealso{~, not}\n\ 119 ",",
120 @end deftypefn"), 120 "-",
121 121 "--",
122 pair_type ("~", 122 ".'",
123 "-*- texinfo -*-\n\ 123 ".*",
124 @deftypefn {} {} ~\n\ 124 ".**",
125 Logical 'not' operator.\n\ 125 ".^",
126 @seealso{!, not}\n\ 126 "./",
127 @end deftypefn"), 127 "/",
128 128 ".\\",
129 pair_type ("!=", 129 "\\",
130 "-*- texinfo -*-\n\ 130 ":",
131 @deftypefn {} {} !=\n\ 131 ";",
132 Logical 'not equals' operator.\n\ 132 "<",
133 @seealso{~=, ne}\n\ 133 "<=",
134 @end deftypefn"), 134 "=",
135 135 "==",
136 pair_type ("~=", 136 ">",
137 "-*- texinfo -*-\n\ 137 ">=",
138 @deftypefn {} {} ~=\n\ 138 "[",
139 Logical 'not equals' operator.\n\ 139 "]",
140 @seealso{!=, ne}\n\ 140 "|",
141 @end deftypefn"), 141 "||",
142 142 0
143 pair_type ("\"",
144 "-*- texinfo -*-\n\
145 @deftypefn {} {} \"\n\
146 String delimiter.\n\
147 @end deftypefn"),
148
149 pair_type ("#",
150 "-*- texinfo -*-\n\
151 @deftypefn {} {} #\n\
152 Begin comment character.\n\
153 @seealso{%, #@\\{}\n\
154 @end deftypefn"),
155
156 pair_type ("%",
157 "-*- texinfo -*-\n\
158 @deftypefn {} {} %\n\
159 Begin comment character.\n\
160 @seealso{#, %@\\{}\n\
161 @end deftypefn"),
162
163 pair_type ("#{",
164 "-*- texinfo -*-\n\
165 @deftypefn {} {} #@{\n\
166 Begin block comment. There must be nothing else, other than\n\
167 whitespace, in the line both before and after @code{#@{}.\n\
168 It is possible to nest block comments.\n\
169 @seealso{%@\\{, #@\\}, #}\n\
170 @end deftypefn"),
171
172 pair_type ("%{",
173 "-*- texinfo -*-\n\
174 @deftypefn {} {} %@{\n\
175 Begin block comment. There must be nothing else, other than\n\
176 whitespace, in the line both before and after @code{%@{}.\n\
177 It is possible to nest block comments.\n\
178 @seealso{#@\\{, %@\\}, %}\n\
179 @end deftypefn"),
180
181 pair_type ("#}",
182 "-*- texinfo -*-\n\
183 @deftypefn {} {} #@}\n\
184 Close block comment. There must be nothing else, other than\n\
185 whitespace, in the line both before and after @code{#@}}.\n\
186 It is possible to nest block comments.\n\
187 @seealso{%@\\}, #@\\{, #}\n\
188 @end deftypefn"),
189
190 pair_type ("%}",
191 "-*- texinfo -*-\n\
192 @deftypefn {} {} %@}\n\
193 Close block comment. There must be nothing else, other than\n\
194 whitespace, in the line both before and after @code{%@}}.\n\
195 It is possible to nest block comments.\n\
196 @seealso{#@\\}, %@\\{, %}\n\
197 @end deftypefn"),
198
199 pair_type ("...",
200 "-*- texinfo -*-\n\
201 @deftypefn {} {} ...\n\
202 Continuation marker. Joins current line with following line.\n\
203 @end deftypefn"),
204
205 pair_type ("&",
206 "-*- texinfo -*-\n\
207 @deftypefn {} {} &\n\
208 Element by element logical 'and' operator.\n\
209 @seealso{&&, and}\n\
210 @end deftypefn"),
211
212 pair_type ("&&",
213 "-*- texinfo -*-\n\
214 @deftypefn {} {} &&\n\
215 Logical 'and' operator (with short-circuit evaluation).\n\
216 @seealso{&, and}\n\
217 @end deftypefn"),
218
219 pair_type ("'",
220 "-*- texinfo -*-\n\
221 @deftypefn {} {} '\n\
222 Matrix transpose operator. For complex matrices, computes the\n\
223 complex conjugate (Hermitian) transpose.\n\
224 \n\
225 The single quote character may also be used to delimit strings, but\n\
226 it is better to use the double quote character, since that is never\n\
227 ambiguous.\n\
228 @seealso{.', transpose}\n\
229 @end deftypefn"),
230
231 pair_type ("(",
232 "-*- texinfo -*-\n\
233 @deftypefn {} {} (\n\
234 Array index or function argument delimiter.\n\
235 @end deftypefn"),
236
237 pair_type (")",
238 "-*- texinfo -*-\n\
239 @deftypefn {} {})\n\
240 Array index or function argument delimiter.\n\
241 @end deftypefn"),
242
243 pair_type ("*",
244 "-*- texinfo -*-\n\
245 @deftypefn {} {} *\n\
246 Multiplication operator.\n\
247 @seealso{.*, times}\n\
248 @end deftypefn"),
249
250 pair_type ("**",
251 "-*- texinfo -*-\n\
252 @deftypefn {} {} **\n\
253 Power operator. This may return complex results for real inputs. Use\n\
254 @code{realsqrt}, @code{cbrt}, @code{nthroot}, or @code{realroot} to obtain\n\
255 real results when possible.\n\
256 @seealso{power, ^, .**, .^, realpow, realsqrt, cbrt, nthroot}\n\
257 @end deftypefn"),
258
259 pair_type ("^",
260 "-*- texinfo -*-\n\
261 @deftypefn {} {} ^\n\
262 Power operator. This may return complex results for real inputs. Use\n\
263 @code{realsqrt}, @code{cbrt}, @code{nthroot}, or @code{realroot} to obtain\n\
264 real results when possible.\n\
265 @seealso{power, **, .^, .**, realpow, realsqrt, cbrt, nthroot}\n\
266 @end deftypefn"),
267
268 pair_type ("+",
269 "-*- texinfo -*-\n\
270 @deftypefn {} {} +\n\
271 Addition operator.\n\
272 @seealso{plus}\n\
273 @end deftypefn"),
274
275 pair_type ("++",
276 "-*- texinfo -*-\n\
277 @deftypefn {} {} ++\n\
278 Increment operator. As in C, may be applied as a prefix or postfix\n\
279 operator.\n\
280 @seealso{--}\n\
281 @end deftypefn"),
282
283 pair_type (",",
284 "-*- texinfo -*-\n\
285 @deftypefn {} {} ,\n\
286 Array index, function argument, or command separator.\n\
287 @end deftypefn"),
288
289 pair_type ("-",
290 "-*- texinfo -*-\n\
291 @deftypefn {} {} -\n\
292 Subtraction or unary negation operator.\n\
293 @seealso{minus}\n\
294 @end deftypefn"),
295
296 pair_type ("--",
297 "-*- texinfo -*-\n\
298 @deftypefn {} {} --\n\
299 Decrement operator. As in C, may be applied as a prefix or postfix\n\
300 operator.\n\
301 @seealso{++}\n\
302 @end deftypefn"),
303
304 pair_type (".'",
305 "-*- texinfo -*-\n\
306 @deftypefn {} {} .'\n\
307 Matrix transpose operator. For complex matrices, computes the\n\
308 transpose, @emph{not} the complex conjugate transpose.\n\
309 @seealso{', transpose}\n\
310 @end deftypefn"),
311
312 pair_type (".*",
313 "-*- texinfo -*-\n\
314 @deftypefn {} {} .*\n\
315 Element by element multiplication operator.\n\
316 @seealso{*, times}\n\
317 @end deftypefn"),
318
319 pair_type (".**",
320 "-*- texinfo -*-\n\
321 @deftypefn {} {} .*\n\
322 Element by element power operator. If several complex results are possible,\n\
323 returns the one with smallest non-negative argument (angle). Use\n\
324 @code{realpow}, @code{realsqrt}, @code{cbrt}, or @code{nthroot} if a\n\
325 real result is preferred.\n\
326 @seealso{**, ^, .^, power, realpow, realsqrt, cbrt, nthroot}\n\
327 @end deftypefn"),
328
329 pair_type (".^",
330 "-*- texinfo -*-\n\
331 @deftypefn {} {} .^\n\
332 Element by element power operator. If several complex results are possible,\n\
333 returns the one with smallest non-negative argument (angle). Use\n\
334 @code{realpow}, @code{realsqrt}, @code{cbrt}, or @code{nthroot} if a\n\
335 real result is preferred.\n\
336 @seealso{.**, ^, **, power, realpow, realsqrt, cbrt, nthroot}\n\
337 @end deftypefn"),
338
339 pair_type ("./",
340 "-*- texinfo -*-\n\
341 @deftypefn {} {} ./\n\
342 Element by element right division operator.\n\
343 @seealso{/, .\\, rdivide, mrdivide}\n\
344 @end deftypefn"),
345
346 pair_type ("/",
347 "-*- texinfo -*-\n\
348 @deftypefn {} {} /\n\
349 Right division operator.\n\
350 @seealso{./, \\, rdivide, mrdivide}\n\
351 @end deftypefn"),
352
353 pair_type (".\\",
354 "-*- texinfo -*-\n\
355 @deftypefn {} {} .\\\n\
356 Element by element left division operator.\n\
357 @seealso{\\, ./, rdivide, mrdivide}\n\
358 @end deftypefn"),
359
360 pair_type ("\\",
361 "-*- texinfo -*-\n\
362 @deftypefn {} {} \\\n\
363 Left division operator.\n\
364 @seealso{.\\, /, ldivide, mldivide}\n\
365 @end deftypefn"),
366
367 pair_type (":",
368 "-*- texinfo -*-\n\
369 @deftypefn {} {} :\n\
370 Select entire rows or columns of matrices.\n\
371 @end deftypefn"),
372
373 pair_type (";",
374 "-*- texinfo -*-\n\
375 @deftypefn {} {} ;\n\
376 Array row or command separator.\n\
377 @seealso{,}\n\
378 @end deftypefn"),
379
380 pair_type ("<",
381 "-*- texinfo -*-\n\
382 @deftypefn {} {} <\n\
383 'Less than' operator.\n\
384 @seealso{lt}\n\
385 @end deftypefn"),
386
387 pair_type ("<=",
388 "-*- texinfo -*-\n\
389 @deftypefn {} {} <=\n\
390 'Less than' or 'equals' operator.\n\
391 @seealso{le}\n\
392 @end deftypefn"),
393
394 pair_type ("=",
395 "-*- texinfo -*-\n\
396 @deftypefn {} {} =\n\
397 Assignment operator.\n\
398 @end deftypefn"),
399
400 pair_type ("==",
401 "-*- texinfo -*-\n\
402 @deftypefn {} {} ==\n\
403 Equality test operator.\n\
404 @seealso{eq}\n\
405 @end deftypefn"),
406
407 pair_type (">",
408 "-*- texinfo -*-\n\
409 @deftypefn {} {} >\n\
410 'Greater than' operator.\n\
411 @seealso{gt}\n\
412 @end deftypefn"),
413
414 pair_type (">=",
415 "-*- texinfo -*-\n\
416 @deftypefn {} {} >=\n\
417 'Greater than' or 'equals' operator.\n\
418 @seealso{ge}\n\
419 @end deftypefn"),
420
421 pair_type ("[",
422 "-*- texinfo -*-\n\
423 @deftypefn {} {} [\n\
424 Return list delimiter.\n\
425 @seealso{]}\n\
426 @end deftypefn"),
427
428 pair_type ("]",
429 "-*- texinfo -*-\n\
430 @deftypefn {} {} ]\n\
431 Return list delimiter.\n\
432 @seealso{[}\n\
433 @end deftypefn"),
434
435 pair_type ("|",
436 "-*- texinfo -*-\n\
437 @deftypefn {} {} |\n\
438 Element by element logical 'or' operator.\n\
439 @seealso{||, or}\n\
440 @end deftypefn"),
441
442 pair_type ("||",
443 "-*- texinfo -*-\n\
444 @deftypefn {} {} ||\n\
445 Logical 'or' (with short-circuit evaluation) operator.\n\
446 @seealso{|, or}\n\
447 @end deftypefn"),
448 }; 143 };
449 144
450 const static pair_type keywords[] = 145 const static string_vector operator_names (operators);
451 { 146
452 pair_type ("break", 147 const static char * const keywords[] =
453 "-*- texinfo -*-\n\ 148 {
454 @deftypefn {} {} break\n\ 149 "break",
455 Exit the innermost enclosing do, while or for loop.\n\ 150 "case",
456 @seealso{do, while, for, parfor, continue}\n\ 151 "catch",
457 @end deftypefn"), 152 "continue",
458 153 "do",
459 pair_type ("case", 154 "else",
460 "-*- texinfo -*-\n\ 155 "elseif",
461 @deftypefn {} {} case @var{value}\n\ 156 "end",
462 @deftypefnx {} {} case @{@var{value}, @dots{}@}\n\ 157 "end_try_catch",
463 A case statement in a switch. Octave cases are exclusive and do not\n\ 158 "end_unwind_protect",
464 fall-through as do C-language cases. A switch statement must have at least\n\ 159 "endfor",
465 one case. See @code{switch} for an example.\n\ 160 "endfunction",
466 @seealso{switch}\n\ 161 "endif",
467 @end deftypefn"), 162 "endparfor",
468 163 "endswitch",
469 pair_type ("catch", 164 "endwhile",
470 "-*- texinfo -*-\n\ 165 "for",
471 @deftypefn {} {} catch\n\ 166 "function",
472 @deftypefnx {} {} catch @var{value}\n\ 167 "global",
473 Begin the cleanup part of a try-catch block.\n\ 168 "if",
474 @seealso{try}\n\ 169 "otherwise",
475 @end deftypefn"), 170 "parfor",
476 171 "persistent",
477 pair_type ("continue", 172 "return",
478 "-*- texinfo -*-\n\ 173 "static",
479 @deftypefn {} {} continue\n\ 174 "switch",
480 Jump to the end of the innermost enclosing do, while or for loop.\n\ 175 "try",
481 @seealso{do, while, for, parfor, break}\n\ 176 "until",
482 @end deftypefn"), 177 "unwind_protect",
483 178 "unwind_protect_cleanup",
484 pair_type ("do", 179 "varargin",
485 "-*- texinfo -*-\n\ 180 "varargout",
486 @deftypefn {} {} do\n\ 181 "while",
487 Begin a do-until loop. This differs from a do-while loop in that the\n\ 182 0
488 body of the loop is executed at least once.\n\
489 \n\
490 @example\n\
491 @group\n\
492 i = 0;\n\
493 do\n\
494 i++\n\
495 until (i == 10)\n\
496 @end group\n\
497 @end example\n\
498 @seealso{for, until, while}\n\
499 @end deftypefn"),
500
501 pair_type ("else",
502 "-*- texinfo -*-\n\
503 @deftypefn {} {} else\n\
504 Alternate action for an if block. See @code{if} for an example.\n\
505 @seealso{if}\n\
506 @end deftypefn"),
507
508 pair_type ("elseif",
509 "-*- texinfo -*-\n\
510 @deftypefn {} {} elseif (@var{condition})\n\
511 Alternate conditional test for an if block. See @code{if} for an example.\n\
512 @seealso{if}\n\
513 @end deftypefn"),
514
515 pair_type ("end",
516 "-*- texinfo -*-\n\
517 @deftypefn {} {} end\n\
518 Mark the end of any @code{for}, @code{parfor}, @code{if}, @code{do},\n\
519 @code{while}, @code{function}, @code{switch}, @code{try}, or\n\
520 @code{unwind_protect} block.\n\
521 @seealso{for, parfor, if, do, while, function, switch, try, unwind_protect}\n\
522 @end deftypefn"),
523
524 pair_type ("end_try_catch",
525 "-*- texinfo -*-\n\
526 @deftypefn {} {} end_try_catch\n\
527 Mark the end of an @code{try-catch} block.\n\
528 @seealso{try, catch}\n\
529 @end deftypefn"),
530
531 pair_type ("end_unwind_protect",
532 "-*- texinfo -*-\n\
533 @deftypefn {} {} end_unwind_protect\n\
534 Mark the end of an unwind_protect block.\n\
535 @seealso{unwind_protect}\n\
536 @end deftypefn"),
537
538 pair_type ("endfor",
539 "-*- texinfo -*-\n\
540 @deftypefn {} {} endfor\n\
541 Mark the end of a for loop. See @code{for} for an example.\n\
542 @seealso{for}\n\
543 @end deftypefn"),
544
545 pair_type ("endfunction",
546 "-*- texinfo -*-\n\
547 @deftypefn {} {} endfunction\n\
548 Mark the end of a function.\n\
549 @seealso{function}\n\
550 @end deftypefn"),
551
552 pair_type ("endif",
553 "-*- texinfo -*-\n\
554 @deftypefn {} {} endif\n\
555 Mark the end of an if block. See @code{if} for an example.\n\
556 @seealso{if}\n\
557 @end deftypefn"),
558
559 pair_type ("endparfor",
560 "-*- texinfo -*-\n\
561 @deftypefn {} {} endparfor\n\
562 Mark the end of a parfor loop. See @code{parfor} for an example.\n\
563 @seealso{parfor}\n\
564 @end deftypefn"),
565
566 pair_type ("endswitch",
567 "-*- texinfo -*-\n\
568 @deftypefn {} {} endswitch\n\
569 Mark the end of a switch block. See @code{switch} for an example.\n\
570 @seealso{switch}\n\
571 @end deftypefn"),
572
573 pair_type ("endwhile",
574 "-*- texinfo -*-\n\
575 @deftypefn {} {} endwhile\n\
576 Mark the end of a while loop. See @code{while} for an example.\n\
577 @seealso{do, while}\n\
578 @end deftypefn"),
579
580 pair_type ("for",
581 "-*- texinfo -*-\n\
582 @deftypefn {} {} for @var{i} = @var{range}\n\
583 Begin a for loop.\n\
584 \n\
585 @example\n\
586 @group\n\
587 for i = 1:10\n\
588 i\n\
589 endfor\n\
590 @end group\n\
591 @end example\n\
592 @seealso{do, parfor, while}\n\
593 @end deftypefn"),
594
595 pair_type ("function",
596 "-*- texinfo -*-\n\
597 @deftypefn {} {} function @var{outputs} = function (@var{input}, @dots{})\n\
598 @deftypefnx {} {} function {} function (@var{input}, @dots{})\n\
599 @deftypefnx {} {} function @var{outputs} = function\n\
600 Begin a function body with @var{outputs} as results and @var{inputs} as\n\
601 parameters.\n\
602 @seealso{return}\n\
603 @end deftypefn"),
604
605 pair_type ("global",
606 "-*- texinfo -*-\n\
607 @deftypefn {} {} global @var{var}\n\
608 Declare variables to have global scope.\n\
609 \n\
610 @example\n\
611 @group\n\
612 global @var{x};\n\
613 if (isempty (@var{x}))\n\
614 x = 1;\n\
615 endif\n\
616 @end group\n\
617 @end example\n\
618 @seealso{persistent}\n\
619 @end deftypefn"),
620
621 pair_type ("if",
622 "-*- texinfo -*-\n\
623 @deftypefn {} {} if (@var{cond}) @dots{} endif\n\
624 @deftypefnx {} {} if (@var{cond}) @dots{} else @dots{} endif\n\
625 @deftypefnx {} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} endif\n\
626 @deftypefnx {} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} else @dots{} endif\n\
627 Begin an if block.\n\
628 \n\
629 @example\n\
630 @group\n\
631 x = 1;\n\
632 if (x == 1)\n\
633 disp (\"one\");\n\
634 elseif (x == 2)\n\
635 disp (\"two\");\n\
636 else\n\
637 disp (\"not one or two\");\n\
638 endif\n\
639 @end group\n\
640 @end example\n\
641 @seealso{switch}\n\
642 @end deftypefn"),
643
644 pair_type ("otherwise",
645 "-*- texinfo -*-\n\
646 @deftypefn {} {} otherwise\n\
647 The default statement in a switch block (similar to else in an if block).\n\
648 @seealso{switch}\n\
649 @end deftypefn"),
650
651 pair_type ("parfor",
652 "-*- texinfo -*-\n\
653 @deftypefn {} {} parfor @var{i} = @var{range}\n\
654 @deftypefnx {} {} parfor (@var{i} = @var{range}, @var{maxproc})\n\
655 Begin a for loop that may execute in parallel.\n\
656 \n\
657 @example\n\
658 @group\n\
659 parfor i = 1:10\n\
660 i\n\
661 endparfor\n\
662 @end group\n\
663 @end example\n\
664 @seealso{for, do, while}\n\
665 @end deftypefn"),
666
667 pair_type ("persistent",
668 "-*- texinfo -*-\n\
669 @deftypefn {} {} persistent @var{var}\n\
670 Declare variables as persistent. A variable that has been declared\n\
671 persistent within a function will retain its contents in memory between\n\
672 subsequent calls to the same function. The difference between persistent\n\
673 variables and global variables is that persistent variables are local in\n\
674 scope to a particular function and are not visible elsewhere.\n\
675 @seealso{global}\n\
676 @end deftypefn"),
677
678 pair_type ("return",
679 "-*- texinfo -*-\n\
680 @deftypefn {} {} return\n\
681 Return from a function.\n\
682 @seealso{function}\n\
683 @end deftypefn"),
684
685 pair_type ("static",
686 "-*- texinfo -*-\n\
687 @deftypefn {} {} static\n\
688 This statement has been deprecated in favor of @code{persistent}.\n\
689 @seealso{persistent}\n\
690 @end deftypefn"),
691
692 pair_type ("switch",
693 "-*- texinfo -*-\n\
694 @deftypefn {} {} switch @var{statement}\n\
695 Begin a switch block.\n\
696 \n\
697 @example\n\
698 @group\n\
699 yesno = \"yes\"\n\
700 \n\
701 switch yesno\n\
702 case @{\"Yes\" \"yes\" \"YES\" \"y\" \"Y\"@}\n\
703 value = 1;\n\
704 case @{\"No\" \"no\" \"NO\" \"n\" \"N\"@}\n\
705 value = 0;\n\
706 otherwise\n\
707 error (\"invalid value\");\n\
708 endswitch\n\
709 @end group\n\
710 @end example\n\
711 @seealso{if, case, otherwise}\n\
712 @end deftypefn"),
713
714 pair_type ("try",
715 "-*- texinfo -*-\n\
716 @deftypefn {} {} try\n\
717 Begin a try-catch block.\n\
718 \n\
719 If an error occurs within a try block, then the catch code will be run and\n\
720 execution will proceed after the catch block (though it is often\n\
721 recommended to use the lasterr function to re-throw the error after cleanup\n\
722 is completed).\n\
723 @seealso{catch, unwind_protect}\n\
724 @end deftypefn"),
725
726 pair_type ("until",
727 "-*- texinfo -*-\n\
728 @deftypefn {} {} until (@var{cond})\n\
729 End a do-until loop. See @code{do} for an example.\n\
730 @seealso{do}\n\
731 @end deftypefn"),
732
733 pair_type ("unwind_protect",
734 "-*- texinfo -*-\n\
735 @deftypefn {} {} unwind_protect\n\
736 Begin an unwind_protect block.\n\
737 \n\
738 If an error occurs within the first part of an unwind_protect block\n\
739 the commands within the unwind_protect_cleanup block are executed before\n\
740 the error is thrown. If an error is not thrown, then the\n\
741 unwind_protect_cleanup block is still executed (in other words, the\n\
742 unwind_protect_cleanup will be run with or without an error in the\n\
743 unwind_protect block).\n\
744 @seealso{unwind_protect_cleanup, try}\n\
745 @end deftypefn"),
746
747 pair_type ("unwind_protect_cleanup",
748 "-*- texinfo -*-\n\
749 @deftypefn {} {} unwind_protect_cleanup\n\
750 Begin the cleanup section of an unwind_protect block.\n\
751 @seealso{unwind_protect}\n\
752 @end deftypefn"),
753
754 pair_type ("varargin",
755 "-*- texinfo -*-\n\
756 @deftypefn {} {} varargin\n\
757 Pass an arbitrary number of arguments into a function.\n\
758 @seealso{varargout, nargin, isargout, nargout, nthargout}\n\
759 @end deftypefn"),
760
761 pair_type ("varargout",
762 "-*- texinfo -*-\n\
763 @deftypefn {} {} varargout\n\
764 Pass an arbitrary number of arguments out of a function.\n\
765 @seealso{varargin, nargin, isargout, nargout, nthargout}\n\
766 @end deftypefn"),
767
768 pair_type ("while",
769 "-*- texinfo -*-\n\
770 @deftypefn {} {} while\n\
771 Begin a while loop.\n\
772 \n\
773 @example\n\
774 @group\n\
775 i = 0;\n\
776 while (i < 10)\n\
777 i++\n\
778 endwhile\n\
779 @end group\n\
780 @end example\n\
781 @seealso{do, endwhile, for, until}\n\
782 @end deftypefn"),
783 }; 183 };
784 184
785 // Return a copy of the operator or keyword names. 185 const static string_vector keyword_names (keywords);
786 static string_vector
787 names (const map_type& lst)
788 {
789 string_vector retval (lst.size ());
790 int j = 0;
791 for (map_iter iter = lst.begin (); iter != lst.end (); iter++)
792 retval[j++] = iter->first;
793 return retval;
794 }
795
796 const static map_type operators_map (operators, operators + size (operators));
797 const static map_type keywords_map (keywords, keywords + size (keywords));
798 const static string_vector keyword_names = names (keywords_map);
799 186
800 // Return a vector of all functions from this file, 187 // Return a vector of all functions from this file,
801 // for use in command line auto-completion. 188 // for use in command line auto-completion.
802 static string_vector 189 static string_vector
803 local_functions (void) 190 local_functions (void)
954 341
955 if (h.length () > 0) 342 if (h.length () > 0)
956 retval = true; 343 retval = true;
957 344
958 return retval; 345 return retval;
959 }
960
961 static bool
962 raw_help_from_map (const std::string& nm, std::string& h,
963 const map_type& map, bool& symbol_found)
964 {
965 map_iter idx = map.find (nm);
966 symbol_found = (idx != map.end ());
967 h = (symbol_found) ? idx->second : "";
968 return symbol_found;
969 } 346 }
970 347
971 static bool 348 static bool
972 raw_help_from_docstrings_file (const std::string& nm, std::string& h, 349 raw_help_from_docstrings_file (const std::string& nm, std::string& h,
973 bool& symbol_found) 350 bool& symbol_found)
1095 bool found; 472 bool found;
1096 473
1097 found = raw_help_from_symbol_table (nm, h, w, symbol_found); 474 found = raw_help_from_symbol_table (nm, h, w, symbol_found);
1098 475
1099 if (! found) 476 if (! found)
1100 { 477 found = raw_help_from_file (nm, h, f, symbol_found);
1101 found = raw_help_from_file (nm, h, f, symbol_found);
1102
1103 if (! found)
1104 {
1105 found = raw_help_from_map (nm, h, operators_map, symbol_found);
1106
1107 if (! found)
1108 found = raw_help_from_map (nm, h, keywords_map, symbol_found);
1109 }
1110 }
1111 478
1112 if (! found || h == "external-doc") 479 if (! found || h == "external-doc")
1113 raw_help_from_docstrings_file (nm, h, symbol_found); 480 raw_help_from_docstrings_file (nm, h, symbol_found);
1114 481
1115 return h; 482 return h;
1256 doc: /* -*- texinfo -*- 623 doc: /* -*- texinfo -*-
1257 @deftypefn {} {} __operators__ () 624 @deftypefn {} {} __operators__ ()
1258 Undocumented internal function. 625 Undocumented internal function.
1259 @end deftypefn */) 626 @end deftypefn */)
1260 { 627 {
1261 return ovl (Cell (names (operators_map))); 628 return ovl (Cell (operator_names));
1262 } 629 }
1263 630
1264 // Return a cell array of strings containing the names of all 631 // Return a cell array of strings containing the names of all
1265 // keywords. 632 // keywords.
1266 633
1268 doc: /* -*- texinfo -*- 635 doc: /* -*- texinfo -*-
1269 @deftypefn {} {} __keywords__ () 636 @deftypefn {} {} __keywords__ ()
1270 Undocumented internal function. 637 Undocumented internal function.
1271 @end deftypefn */) 638 @end deftypefn */)
1272 { 639 {
1273 return ovl (Cell (names (keywords_map))); 640 return ovl (Cell (keyword_names));
1274 } 641 }
1275 642
1276 // Return a cell array of strings containing the names of all builtin 643 // Return a cell array of strings containing the names of all builtin
1277 // functions. 644 // functions.
1278 645