1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
1
|
26 #endif |
|
27 |
1343
|
28 #include <cstdlib> |
|
29 #include <cstring> |
|
30 |
5769
|
31 #include <algorithm> |
3503
|
32 #include <iostream> |
|
33 #include <fstream> |
5765
|
34 #include <sstream> |
1755
|
35 #include <string> |
|
36 |
1350
|
37 #ifdef HAVE_UNISTD_H |
2442
|
38 #ifdef HAVE_SYS_TYPES_H |
1295
|
39 #include <sys/types.h> |
2442
|
40 #endif |
1295
|
41 #include <unistd.h> |
|
42 #endif |
1343
|
43 |
3295
|
44 #include "cmd-edit.h" |
|
45 #include "file-ops.h" |
2926
|
46 #include "oct-env.h" |
1755
|
47 #include "str-vec.h" |
|
48 |
2492
|
49 #include <defaults.h> |
1352
|
50 #include "defun.h" |
|
51 #include "dirfns.h" |
|
52 #include "error.h" |
2233
|
53 #include "fn-cache.h" |
2202
|
54 #include "gripes.h" |
1352
|
55 #include "help.h" |
2177
|
56 #include "input.h" |
1755
|
57 #include "oct-obj.h" |
2976
|
58 #include "ov-usr-fcn.h" |
1352
|
59 #include "pager.h" |
3018
|
60 #include "parse.h" |
1466
|
61 #include "pathsearch.h" |
3295
|
62 #include "procstream.h" |
529
|
63 #include "sighandlers.h" |
|
64 #include "symtab.h" |
2694
|
65 #include "syswait.h" |
1755
|
66 #include "toplev.h" |
242
|
67 #include "utils.h" |
1352
|
68 #include "variables.h" |
3301
|
69 #include "version.h" |
5447
|
70 #include "quit.h" |
529
|
71 |
2202
|
72 // Name of the info file specified on command line. |
|
73 // (--info-file file) |
3523
|
74 std::string Vinfo_file; |
2202
|
75 |
|
76 // Name of the info reader we'd like to use. |
|
77 // (--info-program program) |
3523
|
78 std::string Vinfo_prog; |
2202
|
79 |
3686
|
80 // Name of the makeinfo program to run. |
|
81 static std::string Vmakeinfo_prog = "makeinfo"; |
|
82 |
2189
|
83 // If TRUE, don't print additional help message in help and usage |
|
84 // functions. |
|
85 static bool Vsuppress_verbose_help_message; |
|
86 |
3016
|
87 // XXX FIXME XXX -- maybe this should use string instead of char*. |
|
88 |
|
89 struct help_list |
|
90 { |
|
91 const char *name; |
|
92 const char *help; |
|
93 }; |
|
94 |
1
|
95 static help_list operators[] = |
|
96 { |
|
97 { "!", |
|
98 "Logical not operator. See also `~'.\n", }, |
|
99 |
|
100 { "!=", |
|
101 "Logical not equals operator. See also `~' and `<>'.\n", }, |
|
102 |
|
103 { "\"", |
|
104 "String delimiter.\n", }, |
|
105 |
|
106 { "#", |
928
|
107 "Begin comment character. See also `%'.", }, |
1
|
108 |
|
109 { "%", |
928
|
110 "Begin comment charcter. See also `#'.", }, |
1
|
111 |
|
112 { "&", |
928
|
113 "Logical and operator. See also `&&'.", }, |
1
|
114 |
|
115 { "&&", |
928
|
116 "Logical and operator. See also `&'.", }, |
1
|
117 |
|
118 { "'", |
|
119 "Matrix transpose operator. For complex matrices, computes the\n\ |
|
120 complex conjugate (Hermitian) transpose. See also `.''\n\ |
|
121 \n\ |
|
122 The single quote character may also be used to delimit strings, but\n\ |
|
123 it is better to use the double quote character, since that is never\n\ |
928
|
124 ambiguous", }, |
1
|
125 |
|
126 { "(", |
928
|
127 "Array index or function argument delimiter.", }, |
1
|
128 |
|
129 { ")", |
928
|
130 "Array index or function argument delimiter.", }, |
1
|
131 |
|
132 { "*", |
928
|
133 "Multiplication operator. See also `.*'", }, |
1
|
134 |
|
135 { "**", |
928
|
136 "Power operator. See also `^', `.**', and `.^'", }, |
1
|
137 |
|
138 { "+", |
928
|
139 "Addition operator.", }, |
1
|
140 |
|
141 { "++", |
5339
|
142 "Increment operator. As in C, may be applied as a prefix or postfix\n\ |
|
143 operator.", }, |
1
|
144 |
|
145 { ",", |
928
|
146 "Array index, function argument, or command separator.", }, |
1
|
147 |
|
148 { "-", |
928
|
149 "Subtraction or unary negation operator.", }, |
1
|
150 |
|
151 { "--", |
5339
|
152 "Decrement operator. As in C, may be applied as a prefix or postfix\n\ |
|
153 operator.", }, |
1
|
154 |
|
155 { ".'", |
|
156 "Matrix transpose operator. For complex matrices, computes the\n\ |
928
|
157 transpose, *not* the complex conjugate transpose. See also `''.", }, |
1
|
158 |
|
159 { ".*", |
928
|
160 "Element by element multiplication operator. See also `*'.", }, |
1
|
161 |
|
162 { ".**", |
928
|
163 "Element by element power operator. See also `**', `^', and `.^'.", }, |
1
|
164 |
|
165 { "./", |
928
|
166 "Element by element division operator. See also `/' and `\\'.", }, |
1
|
167 |
|
168 { ".^", |
928
|
169 "Element by element power operator. See also `**', `^', and `.^'.", }, |
1
|
170 |
|
171 { "/", |
928
|
172 "Right division. See also `\\' and `./'.", }, |
1
|
173 |
|
174 { ":", |
928
|
175 "Select entire rows or columns of matrices.", }, |
1
|
176 |
|
177 { ";", |
928
|
178 "Array row or command separator. See also `,'.", }, |
1
|
179 |
|
180 { "<", |
928
|
181 "Less than operator.", }, |
1
|
182 |
|
183 { "<=", |
928
|
184 "Less than or equals operator.", }, |
1
|
185 |
|
186 { "<>", |
928
|
187 "Logical not equals operator. See also `!=' and `~='.", }, |
1
|
188 |
|
189 { "=", |
928
|
190 "Assignment operator.", }, |
1
|
191 |
|
192 { "==", |
928
|
193 "Equality test operator.", }, |
1
|
194 |
|
195 { ">", |
928
|
196 "Greater than operator.", }, |
1
|
197 |
|
198 { ">=", |
928
|
199 "Greater than or equals operator.", }, |
1
|
200 |
|
201 { "[", |
928
|
202 "Return list delimiter. See also `]'.", }, |
1
|
203 |
|
204 { "\\", |
928
|
205 "Left division operator. See also `/' and `./'.", }, |
1
|
206 |
|
207 { "]", |
928
|
208 "Return list delimiter. See also `['.", }, |
1
|
209 |
|
210 { "^", |
928
|
211 "Power operator. See also `**', `.^', and `.**.'", }, |
1
|
212 |
|
213 { "|", |
928
|
214 "Logical or operator. See also `||'.", }, |
1
|
215 |
|
216 { "||", |
928
|
217 "Logical or operator. See also `|'.", }, |
1
|
218 |
|
219 { "~", |
928
|
220 "Logical not operator. See also `!' and `~'.", }, |
1
|
221 |
|
222 { "~=", |
928
|
223 "Logical not equals operator. See also `<>' and `!='.", }, |
1
|
224 |
529
|
225 { 0, 0, }, |
1
|
226 }; |
|
227 |
|
228 static help_list keywords[] = |
|
229 { |
928
|
230 { "all_va_args", |
|
231 "Pass all unnamed arguments to another function call.", }, |
|
232 |
1
|
233 { "break", |
5040
|
234 "Exit the innermost enclosing do, while or for loop.", }, |
|
235 |
|
236 { "case", |
|
237 "A case statement in an switch. Octave cases are exclusive and do not\n\ |
|
238 fall-through as do C-language cases. A switch statement must have at least\n\ |
|
239 one case.",}, |
1
|
240 |
1489
|
241 { "catch", |
|
242 "begin the cleanup part of a try-catch block", }, |
|
243 |
1
|
244 { "continue", |
5040
|
245 "Jump to the end of the innermost enclosing do, while or for loop.", }, |
|
246 |
|
247 { "do", |
|
248 "Begin a do-until loop. This differs from a do-while loop in that the\n\ |
|
249 body of the loop is executed at least once.",}, |
1
|
250 |
|
251 { "else", |
928
|
252 "Alternate action for an if block.", }, |
1
|
253 |
|
254 { "elseif", |
928
|
255 "Alternate conditional test for an if block.", }, |
1
|
256 |
|
257 { "end", |
5040
|
258 "Mark the end of any for, if, do, while, or function block.", }, |
928
|
259 |
1489
|
260 { "end_try_catch", |
|
261 "Mark the end of an try-catch block.", }, |
|
262 |
928
|
263 { "end_unwind_protect", |
|
264 "Mark the end of an unwind_protect block.", }, |
1
|
265 |
|
266 { "endfor", |
928
|
267 "Mark the end of a for loop.", }, |
1
|
268 |
|
269 { "endfunction", |
928
|
270 "Mark the end of a function.", }, |
1
|
271 |
|
272 { "endif", |
928
|
273 "Mark the end of an if block.", }, |
1
|
274 |
5122
|
275 { "endswitch", |
|
276 "Mark the end of a switch block.", }, |
|
277 |
1
|
278 { "endwhile", |
928
|
279 "Mark the end of a while loop.", }, |
1
|
280 |
|
281 { "for", |
928
|
282 "Begin a for loop.", }, |
1
|
283 |
|
284 { "function", |
928
|
285 "Begin a function body.", }, |
1
|
286 |
|
287 { "global", |
928
|
288 "Declare variables to have global scope.", }, |
1
|
289 |
|
290 { "if", |
5393
|
291 "-*- texinfo -*-\n\ |
|
292 @deffn Keyword if (@var{cond}) @dots{} endif\n\ |
|
293 @deffnx Keyword if (@var{cond}) @dots{} else @dots{} endif\n\ |
|
294 @deffnx Keyword if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} endif\n\ |
|
295 @deffnx Keyword if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} else @dots{} endif\n\ |
|
296 Begin an if block.\n\ |
5646
|
297 @seealso{switch}\n\ |
|
298 @end deffn", }, |
1
|
299 |
5040
|
300 { "otherwise", |
|
301 "The default statement in a switch block.", }, |
|
302 |
4686
|
303 { "persistent", |
5623
|
304 "Declare variables as persistent. A variable that has been declared\n\ |
|
305 persistent within a function will retain its contents in memory between\n\ |
|
306 subsequent calls to the same function. The difference between persistent\n\ |
|
307 variables and global variables is that persistent variables are local in scope\n\ |
|
308 to a particular function and are not visible elsewhere.", }, |
4686
|
309 |
5040
|
310 { "replot", |
|
311 "Replot a graphic.", }, |
|
312 |
1
|
313 { "return", |
928
|
314 "Return from a function.", }, |
|
315 |
5040
|
316 { "static", |
|
317 "Declare variables as persistent.", }, |
|
318 |
|
319 { "switch", |
|
320 "Begin a switch statement.",}, |
|
321 |
1489
|
322 { "try", |
|
323 "Begin a try-catch block.", }, |
|
324 |
5040
|
325 { "until", |
|
326 "End a do-until loop.",}, |
|
327 |
928
|
328 { "unwind_protect", |
|
329 "Begin an unwind_protect block.", }, |
|
330 |
|
331 { "unwind_protect_cleanup", |
|
332 "Begin the cleanup section of an unwind_protect block.", }, |
1
|
333 |
5040
|
334 { "varargin", |
5339
|
335 "Pass an arbitrary number of arguments into a function. See also\n\ |
|
336 varargout, nargin, and nargout.",}, |
5040
|
337 |
|
338 { "varargout", |
5339
|
339 "Pass an arbitrary number of arguments out of a function. See also\n\ |
|
340 varargin, nargin, and nargout.",}, |
5040
|
341 |
1
|
342 { "while", |
928
|
343 "Begin a while loop.", }, |
1
|
344 |
529
|
345 { 0, 0, }, |
1
|
346 }; |
|
347 |
581
|
348 // Return a copy of the operator or keyword names. |
|
349 |
3016
|
350 static string_vector |
3355
|
351 names (help_list *lst) |
1
|
352 { |
1755
|
353 string_vector retval; |
|
354 |
3355
|
355 int count = 0; |
1
|
356 help_list *ptr = lst; |
529
|
357 while (ptr->name) |
1
|
358 { |
|
359 count++; |
|
360 ptr++; |
|
361 } |
|
362 |
1755
|
363 if (count > 0) |
|
364 { |
|
365 retval.resize (count); |
1
|
366 |
1755
|
367 ptr = lst; |
|
368 for (int i = 0; i < count; i++) |
|
369 { |
|
370 retval[i] = ptr->name; |
|
371 ptr++; |
|
372 } |
1
|
373 } |
|
374 |
1755
|
375 return retval; |
1
|
376 } |
|
377 |
3014
|
378 static help_list * |
1
|
379 operator_help (void) |
|
380 { |
|
381 return operators; |
|
382 } |
|
383 |
3016
|
384 static help_list * |
1
|
385 keyword_help (void) |
|
386 { |
|
387 return keywords; |
|
388 } |
|
389 |
3016
|
390 // It's not likely that this does the right thing now. XXX FIXME XXX |
|
391 |
|
392 string_vector |
|
393 make_name_list (void) |
|
394 { |
3355
|
395 string_vector key = names (keyword_help ()); |
|
396 int key_len = key.length (); |
3016
|
397 |
4009
|
398 string_vector fbi = fbi_sym_tab->name_list (); |
|
399 int fbi_len = fbi.length (); |
|
400 |
3355
|
401 string_vector glb = global_sym_tab->name_list (); |
|
402 int glb_len = glb.length (); |
3016
|
403 |
3355
|
404 string_vector top = top_level_sym_tab->name_list (); |
|
405 int top_len = top.length (); |
3016
|
406 |
3355
|
407 string_vector lcl; |
3016
|
408 if (top_level_sym_tab != curr_sym_tab) |
3355
|
409 lcl = curr_sym_tab->name_list (); |
|
410 int lcl_len = lcl.length (); |
3016
|
411 |
3355
|
412 string_vector ffl = octave_fcn_file_name_cache::list_no_suffix (); |
3016
|
413 int ffl_len = ffl.length (); |
|
414 |
5592
|
415 string_vector afl = autoloaded_functions (); |
|
416 int afl_len = afl.length (); |
|
417 |
|
418 int total_len = key_len + fbi_len + glb_len + top_len + lcl_len + ffl_len + afl_len; |
3016
|
419 |
|
420 string_vector list (total_len); |
|
421 |
|
422 // Put all the symbols in one big list. |
|
423 |
|
424 int j = 0; |
|
425 int i = 0; |
|
426 for (i = 0; i < key_len; i++) |
|
427 list[j++] = key[i]; |
|
428 |
4009
|
429 for (i = 0; i < fbi_len; i++) |
|
430 list[j++] = fbi[i]; |
|
431 |
3016
|
432 for (i = 0; i < glb_len; i++) |
|
433 list[j++] = glb[i]; |
|
434 |
|
435 for (i = 0; i < top_len; i++) |
|
436 list[j++] = top[i]; |
|
437 |
|
438 for (i = 0; i < lcl_len; i++) |
|
439 list[j++] = lcl[i]; |
|
440 |
|
441 for (i = 0; i < ffl_len; i++) |
|
442 list[j++] = ffl[i]; |
|
443 |
5592
|
444 for (i = 0; i < afl_len; i++) |
|
445 list[j++] = afl[i]; |
|
446 |
3016
|
447 return list; |
|
448 } |
|
449 |
3014
|
450 void |
3523
|
451 additional_help_message (std::ostream& os) |
2470
|
452 { |
|
453 if (! Vsuppress_verbose_help_message) |
5641
|
454 os << "\ |
3259
|
455 Additional help for built-in functions, operators, and variables\n\ |
3160
|
456 is available in the on-line version of the manual. Use the command\n\ |
5672
|
457 `doc <topic>' to search the manual index.\n\ |
3295
|
458 \n\ |
3160
|
459 Help and information about Octave is also available on the WWW\n\ |
5041
|
460 at http://www.octave.org and via the help@octave.org\n\ |
3917
|
461 mailing list.\n"; |
3160
|
462 } |
|
463 |
2976
|
464 // XXX FIXME XXX -- this needs a major overhaul to cope with new |
|
465 // symbol table stuff. |
|
466 |
529
|
467 static void |
3523
|
468 display_names_from_help_list (std::ostream& os, help_list *list, |
542
|
469 const char *desc) |
529
|
470 { |
3355
|
471 string_vector symbols = names (list); |
3259
|
472 |
1808
|
473 if (! symbols.empty ()) |
|
474 { |
2095
|
475 os << "\n*** " << desc << ":\n\n"; |
3259
|
476 |
|
477 symbols.qsort (); |
|
478 |
2095
|
479 symbols.list_in_columns (os); |
1808
|
480 } |
529
|
481 } |
|
482 |
|
483 static void |
3523
|
484 display_symtab_names (std::ostream& os, const string_vector& names, |
|
485 const std::string& desc) |
542
|
486 { |
1808
|
487 if (! names.empty ()) |
|
488 { |
2095
|
489 os << "\n*** " << desc << ":\n\n"; |
|
490 names.list_in_columns (os); |
1808
|
491 } |
542
|
492 } |
|
493 |
|
494 #ifdef LIST_SYMBOLS |
|
495 #undef LIST_SYMBOLS |
|
496 #endif |
|
497 #define LIST_SYMBOLS(type, msg) \ |
|
498 do \ |
|
499 { \ |
3259
|
500 string_vector names \ |
4009
|
501 = fbi_sym_tab->name_list (string_vector (), true, type); \ |
3355
|
502 display_symtab_names (octave_stdout, names, msg); \ |
542
|
503 } \ |
|
504 while (0) |
529
|
505 |
3014
|
506 static void |
|
507 simple_help (void) |
|
508 { |
3160
|
509 octave_stdout << "Help is available for the topics listed below.\n"; |
|
510 |
|
511 additional_help_message (octave_stdout); |
|
512 |
3014
|
513 display_names_from_help_list (octave_stdout, operator_help (), |
|
514 "operators"); |
|
515 |
|
516 display_names_from_help_list (octave_stdout, keyword_help (), |
|
517 "reserved words"); |
|
518 |
1358
|
519 // XXX FIXME XXX -- is this distinction needed? |
|
520 |
3259
|
521 LIST_SYMBOLS (symbol_record::BUILTIN_CONSTANT, "built-in constants"); |
|
522 |
|
523 LIST_SYMBOLS (symbol_record::BUILTIN_VARIABLE, "built-in variables"); |
|
524 |
4208
|
525 LIST_SYMBOLS (symbol_record::COMMAND, "commands"); |
529
|
526 |
3010
|
527 LIST_SYMBOLS (symbol_record::MAPPER_FUNCTION, "mapper functions"); |
542
|
528 |
3010
|
529 LIST_SYMBOLS (symbol_record::BUILTIN_FUNCTION, "general functions"); |
542
|
530 |
1358
|
531 // Also need to list variables and currently compiled functions from |
|
532 // the symbol table, if there are any. |
529
|
533 |
1358
|
534 // Also need to search octave_path for script files. |
529
|
535 |
3195
|
536 string_vector dirs = Vload_path_dir_path.all_directories (); |
679
|
537 |
1787
|
538 int len = dirs.length (); |
679
|
539 |
1787
|
540 for (int i = 0; i < len; i++) |
|
541 { |
2233
|
542 string_vector names = octave_fcn_file_name_cache::list (dirs[i]); |
679
|
543 |
1787
|
544 if (! names.empty ()) |
|
545 { |
3523
|
546 std::string dir |
2926
|
547 = octave_env::make_absolute (dirs[i], octave_env::getcwd ()); |
|
548 |
|
549 octave_stdout << "\n*** function files in " << dir << ":\n\n"; |
679
|
550 |
3259
|
551 names.qsort (); |
|
552 |
2095
|
553 names.list_in_columns (octave_stdout); |
529
|
554 } |
|
555 } |
5592
|
556 |
|
557 string_vector autoloaded = autoloaded_functions (); |
|
558 |
|
559 if (! autoloaded.empty ()) |
|
560 { |
|
561 octave_stdout << "\n*** autoloaded functions:\n\n"; |
|
562 |
|
563 autoloaded.qsort (); |
|
564 |
|
565 autoloaded.list_in_columns (octave_stdout); |
|
566 } |
529
|
567 } |
|
568 |
|
569 static int |
3523
|
570 try_info (const std::string& nm) |
529
|
571 { |
5672
|
572 int retval = -1; |
1295
|
573 |
5672
|
574 warning ("please use `doc' instead of `help -i'"); |
529
|
575 |
5672
|
576 octave_value_list args; |
|
577 args(0) = nm; |
|
578 octave_value_list result = feval ("doc", args, 1); |
4051
|
579 |
5672
|
580 if (result.length () > 0) |
|
581 retval = result(0).int_value (); |
529
|
582 |
5672
|
583 return retval; |
529
|
584 } |
1140
|
585 |
|
586 static void |
1755
|
587 help_from_info (const string_vector& argv, int idx, int argc) |
1140
|
588 { |
1755
|
589 if (idx == argc) |
3523
|
590 try_info (std::string ()); |
1140
|
591 else |
|
592 { |
1755
|
593 for (int i = idx; i < argc; i++) |
1140
|
594 { |
1755
|
595 int status = try_info (argv[i]); |
1140
|
596 |
5672
|
597 if (status == 127) |
|
598 break; |
|
599 else if (status != 0) |
|
600 message ("help", "`%s' is not indexed in the manual", |
|
601 argv[i].c_str ()); |
1140
|
602 } |
|
603 } |
2470
|
604 } |
3014
|
605 |
|
606 static bool |
3523
|
607 looks_like_texinfo (const std::string& msg, size_t& p1) |
3295
|
608 { |
|
609 p1 = msg.find ('\n'); |
|
610 |
3523
|
611 std::string t = msg.substr (0, p1); |
3295
|
612 |
|
613 if (p1 == NPOS) |
|
614 p1 = 0; |
|
615 |
|
616 size_t p2 = t.find ("-*- texinfo -*-"); |
|
617 |
|
618 return (p2 != NPOS); |
|
619 } |
|
620 |
3330
|
621 void |
3523
|
622 display_help_text (std::ostream& os, const std::string& msg) |
3295
|
623 { |
|
624 // Look for "-*- texinfo -*-" in first line of help message. If it |
|
625 // is present, use makeinfo to format the rest of the message before |
|
626 // sending it to the output stream. Otherwise, just print the |
|
627 // message. |
|
628 |
|
629 size_t pos; |
|
630 |
|
631 if (looks_like_texinfo (msg, pos)) |
|
632 { |
5594
|
633 os.flush (); |
|
634 |
3523
|
635 std::string tmp_file_name = file_ops::tempnam ("", ""); |
3295
|
636 |
|
637 int cols = command_editor::terminal_cols (); |
|
638 |
|
639 if (cols > 16) |
|
640 cols--; |
|
641 |
|
642 if (cols > 64) |
|
643 cols -= 7; |
|
644 |
|
645 if (cols > 80) |
|
646 cols = 72; |
|
647 |
5765
|
648 std::ostringstream buf; |
4051
|
649 |
4115
|
650 buf << "sed -e 's/^[#%][#%]* *//' -e 's/^ *@/@/' | " |
4469
|
651 << "\"" << Vmakeinfo_prog << "\"" |
3303
|
652 << " -D \"VERSION " << OCTAVE_VERSION << "\"" |
|
653 << " -D \"OCTAVEHOME " << OCTAVE_PREFIX << "\"" |
3584
|
654 << " -D \"TARGETHOSTTYPE " << OCTAVE_CANONICAL_HOST_TYPE << "\"" |
3301
|
655 << " --fill-column " << cols |
|
656 << " --no-warn" |
|
657 << " --no-validate" |
|
658 << " --no-headers" |
|
659 << " --force" |
5765
|
660 << " --output \"" << tmp_file_name << "\""; |
3295
|
661 |
5765
|
662 oprocstream filter (buf.str ()); |
3295
|
663 |
3686
|
664 if (filter && filter.is_open ()) |
3295
|
665 { |
3405
|
666 filter << "@macro seealso {args}\n" |
5644
|
667 << "@sp 1\n" |
3408
|
668 << "@noindent\n" |
3405
|
669 << "See also: \\args\\.\n" |
|
670 << "@end macro\n"; |
|
671 |
3769
|
672 filter << msg.substr (pos+1) << std::endl; |
3295
|
673 |
3686
|
674 int status = filter.close (); |
3295
|
675 |
3523
|
676 std::ifstream tmp_file (tmp_file_name.c_str ()); |
3295
|
677 |
3686
|
678 if (WIFEXITED (status) && WEXITSTATUS (status) == 0) |
|
679 { |
|
680 int c; |
|
681 while ((c = tmp_file.get ()) != EOF) |
|
682 os << (char) c; |
3295
|
683 |
3686
|
684 tmp_file.close (); |
|
685 } |
|
686 else |
|
687 { |
|
688 warning ("help: Texinfo formatting filter exited abnormally"); |
|
689 warning ("help: raw Texinfo source of help text follows..."); |
5594
|
690 warning ("help:\n\n%s\n\n", msg.c_str ()); |
3686
|
691 } |
3295
|
692 |
|
693 file_ops::unlink (tmp_file_name); |
|
694 } |
|
695 else |
|
696 os << msg; |
|
697 } |
|
698 else |
|
699 os << msg; |
|
700 } |
|
701 |
|
702 static bool |
3523
|
703 help_from_list (std::ostream& os, const help_list *list, |
5399
|
704 const std::string& nm, int usage, bool& symbol_found) |
542
|
705 { |
5399
|
706 bool retval = false; |
|
707 |
2804
|
708 const char *name; |
3014
|
709 |
542
|
710 while ((name = list->name) != 0) |
|
711 { |
1755
|
712 if (strcmp (name, nm.c_str ()) == 0) |
542
|
713 { |
5399
|
714 symbol_found = true; |
|
715 |
|
716 std::string h = list->help; |
|
717 |
|
718 if (h.length () > 0) |
542
|
719 { |
5399
|
720 if (usage) |
|
721 os << "\nusage: "; |
|
722 else |
|
723 os << "\n*** " << nm << ":\n\n"; |
|
724 |
|
725 display_help_text (os, h); |
|
726 |
|
727 os << "\n"; |
|
728 |
|
729 retval = true; |
542
|
730 } |
5399
|
731 break; |
542
|
732 } |
|
733 list++; |
|
734 } |
3014
|
735 |
5399
|
736 return retval;; |
|
737 } |
|
738 |
|
739 std::string |
|
740 extract_help_from_dispatch (const std::string& nm) |
|
741 { |
|
742 std::string retval; |
|
743 |
|
744 symbol_record *builtin = fbi_sym_tab->lookup ("builtin:" + nm, 0); |
|
745 |
|
746 if (builtin) |
|
747 { |
|
748 // Check that builtin is up to date. |
|
749 |
|
750 // Don't try to fight octave's function name handling |
|
751 // mechanism. Instead, move dispatch record out of the way, |
|
752 // and restore the builtin to its original name. |
|
753 symbol_record *dispatch = fbi_sym_tab->lookup (nm, 0); |
|
754 |
|
755 if (dispatch) |
|
756 { |
|
757 dispatch->unprotect (); |
|
758 |
|
759 fbi_sym_tab->rename (nm, "dispatch:" + nm); |
|
760 fbi_sym_tab->rename ("builtin:" + nm, nm); |
|
761 |
|
762 // Check for updates to builtin function; ignore errors |
|
763 // that appear (they interfere with renaming), and remove |
|
764 // the updated name from the current symbol table. XXX |
|
765 // FIXME XXX check that updating a function updates it in |
|
766 // all contexts --- it may be that it is updated only in the |
|
767 // current symbol table, and not the caller. I believe this |
|
768 // won't be a problem because the caller will go through the |
|
769 // same logic and end up with the newer version. |
|
770 |
|
771 octave_function *f = is_valid_function (nm); |
|
772 |
|
773 if (f) |
|
774 retval = builtin->help (); |
|
775 |
|
776 curr_sym_tab->clear_function (nm); |
|
777 |
|
778 // Move the builtin function out of the way and restore the |
|
779 // dispatch fuction. XXX FIXME XXX what if builtin wants to |
|
780 // protect itself? |
|
781 |
|
782 fbi_sym_tab->rename (nm, "builtin:" + nm); |
|
783 fbi_sym_tab->rename ("dispatch:" + nm, nm); |
|
784 |
|
785 dispatch->protect (); |
|
786 } |
|
787 else |
|
788 error ("failed to find dispatch record for `builtin:%s'", nm.c_str ()); |
|
789 } |
|
790 |
|
791 return retval; |
542
|
792 } |
|
793 |
3355
|
794 static bool |
5399
|
795 help_from_symbol_table (std::ostream& os, const std::string& nm, |
|
796 bool& symbol_found) |
3355
|
797 { |
|
798 bool retval = false; |
|
799 |
|
800 symbol_record *sym_rec = lookup_by_name (nm, 0); |
|
801 |
|
802 if (sym_rec && sym_rec->is_defined ()) |
|
803 { |
5399
|
804 symbol_found = true; |
|
805 |
3523
|
806 std::string h = sym_rec->help (); |
3355
|
807 |
|
808 if (h.length () > 0) |
|
809 { |
5399
|
810 h = extract_help_from_dispatch (nm) + h; |
3355
|
811 display_help_text (os, h); |
5641
|
812 if (! Vsuppress_verbose_help_message) |
|
813 { |
|
814 sym_rec->which (os); |
|
815 os << "\n"; |
|
816 } |
3355
|
817 os << "\n"; |
|
818 retval = true; |
|
819 } |
|
820 } |
|
821 |
|
822 return retval; |
|
823 } |
|
824 |
|
825 static bool |
5399
|
826 help_from_file (std::ostream& os, const std::string& nm, bool& symbol_found) |
3355
|
827 { |
|
828 bool retval = false; |
|
829 |
5484
|
830 std::string h = get_help_from_file (nm, symbol_found, true); |
3355
|
831 |
5484
|
832 if (h.length () > 0) |
|
833 { |
|
834 display_help_text (os, h); |
|
835 os << "\n"; |
|
836 retval = true; |
3355
|
837 } |
|
838 |
|
839 return retval; |
|
840 } |
|
841 |
1140
|
842 static void |
1755
|
843 builtin_help (int argc, const string_vector& argv) |
1140
|
844 { |
|
845 help_list *op_help_list = operator_help (); |
|
846 help_list *kw_help_list = keyword_help (); |
|
847 |
1755
|
848 for (int i = 1; i < argc; i++) |
1140
|
849 { |
5399
|
850 bool symbol_found = false; |
|
851 |
|
852 if (help_from_list (octave_stdout, op_help_list, argv[i], 0, |
|
853 symbol_found)) |
1140
|
854 continue; |
|
855 |
5399
|
856 if (help_from_list (octave_stdout, kw_help_list, argv[i], 0, |
|
857 symbol_found)) |
1140
|
858 continue; |
|
859 |
5399
|
860 if (help_from_symbol_table (octave_stdout, argv[i], symbol_found)) |
|
861 continue; |
|
862 |
|
863 if (help_from_file (octave_stdout, argv[i], symbol_found)) |
3355
|
864 continue; |
1755
|
865 |
5399
|
866 if (symbol_found) |
|
867 octave_stdout << "\nhelp: `" << argv[i] |
|
868 << "' is not documented\n"; |
|
869 else |
|
870 octave_stdout << "\nhelp: `" << argv[i] |
|
871 << "' not found\n"; |
1140
|
872 } |
|
873 |
2095
|
874 additional_help_message (octave_stdout); |
1140
|
875 } |
|
876 |
4208
|
877 DEFCMD (help, args, , |
3332
|
878 "-*- texinfo -*-\n\ |
|
879 @deffn {Command} help\n\ |
|
880 Octave's @code{help} command can be used to print brief usage-style\n\ |
|
881 messages, or to display information directly from an on-line version of\n\ |
|
882 the printed manual, using the GNU Info browser. If invoked without any\n\ |
|
883 arguments, @code{help} prints a list of all the available operators,\n\ |
|
884 functions, and built-in variables. If the first argument is @code{-i},\n\ |
|
885 the @code{help} command searches the index of the on-line version of\n\ |
|
886 this manual for the given topics.\n\ |
3168
|
887 \n\ |
3332
|
888 For example, the command @kbd{help help} prints a short message\n\ |
|
889 describing the @code{help} command, and @kbd{help -i help} starts the\n\ |
|
890 GNU Info browser at this node in the on-line version of the manual.\n\ |
|
891 \n\ |
|
892 Once the GNU Info browser is running, help for using it is available\n\ |
|
893 using the command @kbd{C-h}.\n\ |
5672
|
894 @seealso{doc, which, lookfor}\n\ |
3333
|
895 @end deffn") |
529
|
896 { |
2086
|
897 octave_value_list retval; |
529
|
898 |
1755
|
899 int argc = args.length () + 1; |
|
900 |
1968
|
901 string_vector argv = args.make_argv ("help"); |
1755
|
902 |
|
903 if (error_state) |
|
904 return retval; |
529
|
905 |
|
906 if (argc == 1) |
3014
|
907 simple_help (); |
529
|
908 else |
|
909 { |
1755
|
910 if (argv[1] == "-i") |
3014
|
911 help_from_info (argv, 2, argc); |
529
|
912 else |
3014
|
913 builtin_help (argc, argv); |
529
|
914 } |
|
915 |
|
916 return retval; |
|
917 } |
|
918 |
3355
|
919 static void |
3523
|
920 do_type (std::ostream& os, const std::string& name, bool pr_type_info, |
3355
|
921 bool quiet, bool pr_orig_txt) |
|
922 { |
|
923 symbol_record *sym_rec = lookup_by_name (name, 0); |
|
924 |
|
925 if (sym_rec && sym_rec->is_defined ()) |
3356
|
926 sym_rec->type (os, pr_type_info, quiet, pr_orig_txt); |
3355
|
927 else |
|
928 { |
3523
|
929 std::string ff = fcn_file_in_path (name); |
3355
|
930 |
|
931 if (! ff.empty ()) |
|
932 { |
3538
|
933 std::ifstream fs (ff.c_str (), std::ios::in); |
3355
|
934 |
|
935 if (fs) |
|
936 { |
|
937 if (pr_type_info && ! quiet) |
|
938 os << name << " is the script file: " << ff << "\n\n"; |
|
939 |
|
940 char ch; |
|
941 |
|
942 while (fs.get (ch)) |
|
943 os << ch; |
|
944 } |
|
945 else |
|
946 os << "unable to open `" << ff << "' for reading!\n"; |
|
947 } |
|
948 else |
|
949 error ("type: `%s' undefined", name.c_str ()); |
|
950 } |
|
951 } |
|
952 |
4208
|
953 DEFCMD (type, args, nargout, |
3361
|
954 "-*- texinfo -*-\n\ |
|
955 \n\ |
|
956 @deffn {Command} type options name @dots{}\n\ |
|
957 Display the definition of each @var{name} that refers to a function.\n\ |
|
958 \n\ |
|
959 Normally also displays if each @var{name} is user-defined or builtin;\n\ |
|
960 the @code{-q} option suppresses this behaviour.\n\ |
581
|
961 \n\ |
3361
|
962 Currently, Octave can only display functions that can be compiled\n\ |
|
963 cleanly, because it uses its internal representation of the function to\n\ |
|
964 recreate the program text.\n\ |
|
965 \n\ |
|
966 Comments are not displayed because Octave's parser currently discards\n\ |
|
967 them as it converts the text of a function file to its internal\n\ |
|
968 representation. This problem may be fixed in a future release.\n\ |
|
969 @end deffn") |
581
|
970 { |
3584
|
971 octave_value retval; |
1588
|
972 |
1755
|
973 int argc = args.length () + 1; |
|
974 |
1968
|
975 string_vector argv = args.make_argv ("type"); |
1755
|
976 |
3355
|
977 if (! error_state) |
581
|
978 { |
3355
|
979 if (argc > 1) |
|
980 { |
|
981 // XXX FIXME XXX -- we should really use getopt () |
2532
|
982 |
3355
|
983 bool quiet = false; |
|
984 bool pr_orig_txt = true; |
2532
|
985 |
3355
|
986 int idx; |
581
|
987 |
3355
|
988 for (idx = 1; idx < argc; idx++) |
1281
|
989 { |
3355
|
990 if (argv[idx] == "-q" || argv[idx] == "-quiet") |
|
991 quiet = true; |
|
992 else if (argv[idx] == "-t" || argv[idx] == "-transformed") |
|
993 pr_orig_txt = false; |
|
994 else |
|
995 break; |
1281
|
996 } |
|
997 |
3355
|
998 if (idx < argc) |
|
999 { |
5765
|
1000 std::ostringstream output_buf; |
581
|
1001 |
3355
|
1002 for (int i = idx; i < argc; i++) |
581
|
1003 { |
3523
|
1004 std::string id = argv[i]; |
2534
|
1005 |
3355
|
1006 if (nargout == 0) |
|
1007 do_type (octave_stdout, id, true, quiet, pr_orig_txt); |
|
1008 else |
|
1009 do_type (output_buf, id, false, quiet, pr_orig_txt); |
581
|
1010 |
3355
|
1011 if (error_state) |
|
1012 goto abort; |
581
|
1013 } |
|
1014 |
3584
|
1015 if (nargout != 0) |
5765
|
1016 retval = output_buf.str (); |
581
|
1017 } |
|
1018 else |
3355
|
1019 print_usage ("type"); |
|
1020 } |
|
1021 else |
|
1022 print_usage ("type"); |
|
1023 } |
3141
|
1024 |
3355
|
1025 abort: |
581
|
1026 |
|
1027 return retval; |
|
1028 } |
|
1029 |
3536
|
1030 static std::string |
3523
|
1031 do_which (const std::string& name) |
3355
|
1032 { |
3523
|
1033 std::string retval; |
3355
|
1034 |
|
1035 symbol_record *sym_rec = lookup_by_name (name, 0); |
|
1036 |
|
1037 if (sym_rec && sym_rec->is_defined ()) |
|
1038 retval = sym_rec->which (); |
|
1039 else |
|
1040 { |
3523
|
1041 std::string path = fcn_file_in_path (name); |
3355
|
1042 |
|
1043 if (! path.empty ()) |
|
1044 retval = path; |
|
1045 else |
|
1046 retval = "undefined"; |
|
1047 } |
|
1048 |
|
1049 return retval; |
|
1050 } |
|
1051 |
|
1052 static void |
3523
|
1053 do_which (std::ostream& os, const std::string& name) |
3355
|
1054 { |
|
1055 symbol_record *sym_rec = lookup_by_name (name, 0); |
|
1056 |
|
1057 if (sym_rec && sym_rec->is_defined ()) |
|
1058 sym_rec->which (os); |
|
1059 else |
|
1060 { |
3523
|
1061 std::string path = fcn_file_in_path (name); |
3355
|
1062 |
|
1063 if (! path.empty ()) |
|
1064 os << "which: `" << name << "' is the script file\n" |
|
1065 << path << "\n"; |
|
1066 else |
|
1067 os << "which: `" << name << "' is undefined\n"; |
|
1068 } |
|
1069 } |
|
1070 |
4208
|
1071 DEFCMD (which, args, nargout, |
3361
|
1072 "-*- texinfo -*-\n\ |
|
1073 @deffn {Command} which name @dots{}\n\ |
|
1074 Display the type of each @var{name}. If @var{name} is defined from a\n\ |
|
1075 function file, the full name of the file is also displayed.\n\ |
5667
|
1076 @seealso{help, lookfor}\n\ |
3361
|
1077 @end deffn") |
581
|
1078 { |
2086
|
1079 octave_value_list retval; |
581
|
1080 |
1968
|
1081 string_vector argv = args.make_argv ("which"); |
1755
|
1082 |
3355
|
1083 if (! error_state) |
|
1084 { |
|
1085 int argc = argv.length (); |
581
|
1086 |
|
1087 if (nargout > 0) |
|
1088 retval.resize (argc-1, Matrix ()); |
|
1089 |
3355
|
1090 if (argc > 1) |
581
|
1091 { |
3355
|
1092 for (int i = 1; i < argc; i++) |
581
|
1093 { |
3523
|
1094 std::string id = argv[i]; |
3141
|
1095 |
3355
|
1096 if (nargout == 0) |
|
1097 do_which (octave_stdout, id); |
581
|
1098 else |
3355
|
1099 retval(i-1) = do_which (id); |
581
|
1100 } |
|
1101 } |
3355
|
1102 else |
|
1103 print_usage (argv[0]); |
581
|
1104 } |
|
1105 |
|
1106 return retval; |
|
1107 } |
|
1108 |
5447
|
1109 // XXX FIXME XXX |
|
1110 // This function attempts to find the first sentence of a help string, though |
|
1111 // given that the user can create the help in an arbitrary format, your |
|
1112 // success might vary.. it works much better with help string formated in |
|
1113 // texinfo. Using regex might make this function much simpler. |
|
1114 |
|
1115 std::string |
|
1116 first_help_sentence (const std::string& h, bool short_sentence = true) |
|
1117 { |
5738
|
1118 std::string retval; |
|
1119 |
5447
|
1120 size_t pos = 0; |
|
1121 |
|
1122 if (looks_like_texinfo (h, pos)) |
5592
|
1123 { |
|
1124 // Get the parsed help string. |
5447
|
1125 pos = 0; |
5765
|
1126 std::ostringstream os; |
5447
|
1127 display_help_text (os, h); |
|
1128 std::string h2 = os.str (); |
|
1129 |
|
1130 while (1) |
|
1131 { |
|
1132 // Skip leading whitespace and get new line |
|
1133 pos = h2.find_first_not_of ("\n\t ", pos); |
|
1134 |
|
1135 if (pos == NPOS) |
|
1136 break; |
|
1137 |
|
1138 size_t new_pos = h2.find_first_of ('\n', pos); |
|
1139 std::string line = h2.substr (pos, new_pos-pos); |
|
1140 |
|
1141 // Skip lines starting in "-" |
|
1142 if (line.find_first_of ('-') == 0) |
|
1143 { |
|
1144 pos = new_pos + 1; |
|
1145 continue; |
|
1146 } |
|
1147 |
|
1148 break; |
|
1149 } |
|
1150 |
|
1151 if (pos == NPOS) |
5738
|
1152 return retval; |
5447
|
1153 |
|
1154 // At start of real text. Get first line with the sentence |
|
1155 size_t new_pos = h2.find_first_of ('\n', pos); |
|
1156 std::string line = h2.substr (pos, new_pos-pos); |
|
1157 size_t dot_pos; |
|
1158 |
|
1159 while ((dot_pos = line.find_first_of ('.')) == NPOS) |
|
1160 { |
|
1161 // Trim trailing blanks on line |
|
1162 line.substr (0, line.find_last_not_of ("\n\t ") + 1); |
|
1163 |
|
1164 // Append next line |
|
1165 size_t tmp_pos = h2.find_first_not_of ("\n\t ", new_pos + 1); |
|
1166 if (tmp_pos == NPOS || h2.substr (tmp_pos, 1) == "\n") |
|
1167 break; |
|
1168 |
|
1169 new_pos = h2.find_first_of ('\n', tmp_pos); |
|
1170 std::string next = h2.substr (tmp_pos, new_pos-tmp_pos); |
|
1171 |
|
1172 if (short_sentence) |
|
1173 { |
|
1174 if ((tmp_pos = next.find_first_of ('.')) != NPOS) |
|
1175 { |
|
1176 line = line + " " + next; |
|
1177 dot_pos = line.find_first_of ('.'); |
|
1178 } |
|
1179 break; |
|
1180 } |
|
1181 else |
|
1182 line = line + " " + next; |
|
1183 } |
|
1184 |
|
1185 if (dot_pos == NPOS) |
5738
|
1186 retval = line; |
5447
|
1187 else |
5738
|
1188 retval = line.substr (0, dot_pos + 1); |
5447
|
1189 } |
|
1190 else |
|
1191 { |
|
1192 std::string _upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
|
1193 std::string _lower = "abcdefghijklmnopqrstuvwxyz"; |
|
1194 std::string _alpha = _upper + _lower + "_"; |
|
1195 std::string _alphanum = _alpha + "1234567890"; |
|
1196 pos = 0; |
|
1197 |
|
1198 while (1) |
|
1199 { |
|
1200 // Skip leading whitespace and get new line |
|
1201 pos = h.find_first_not_of ("\n\t ", pos); |
|
1202 |
|
1203 if (pos == NPOS) |
|
1204 break; |
|
1205 |
|
1206 size_t new_pos = h.find_first_of ('\n', pos); |
|
1207 std::string line = h.substr (pos, new_pos-pos); |
|
1208 |
|
1209 // Make a lower case copy to simplify some tests |
|
1210 std::string lower = line; |
5768
|
1211 std::transform (lower.begin (), lower.end (), lower.begin (), tolower); |
5447
|
1212 |
|
1213 // Skip lines starting in "-" or "Usage" |
|
1214 if (lower.find_first_of ('-') == 0 |
|
1215 || lower.substr (0, 5) == "usage") |
|
1216 { |
5592
|
1217 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1218 continue; |
|
1219 } |
|
1220 |
|
1221 size_t line_pos = 0; |
|
1222 size_t tmp_pos = 0; |
|
1223 |
|
1224 // chop " blah : " |
|
1225 tmp_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1226 (_alphanum, line_pos)); |
|
1227 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == ":") |
|
1228 line_pos = line.find_first_not_of ("\t ", tmp_pos + 1); |
|
1229 |
|
1230 if (line_pos == NPOS) |
|
1231 { |
5592
|
1232 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1233 continue; |
|
1234 } |
|
1235 |
|
1236 // chop " function " |
|
1237 if (lower.substr (line_pos, 8) == "function") |
|
1238 line_pos = line.find_first_not_of ("\t ", line_pos + 8); |
|
1239 |
|
1240 if (line_pos == NPOS) |
|
1241 { |
5592
|
1242 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1243 continue; |
|
1244 } |
|
1245 |
|
1246 // chop " [a,b] = " |
|
1247 if (line.substr (line_pos, 1) == "[") |
|
1248 { |
|
1249 tmp_pos = line.find_first_not_of |
|
1250 ("\t ", line.find_first_of ("]", line_pos) + 1); |
|
1251 |
|
1252 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "=") |
|
1253 line_pos = line.find_first_not_of ("\t ",tmp_pos + 1); |
|
1254 } |
|
1255 |
|
1256 if (line_pos == NPOS) |
|
1257 { |
5592
|
1258 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1259 continue; |
|
1260 } |
|
1261 |
|
1262 // chop " a = " |
|
1263 if (line.find_first_not_of (_alpha, line_pos) != line_pos) |
|
1264 { |
|
1265 tmp_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1266 (_alphanum, line_pos)); |
|
1267 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "=") |
|
1268 line_pos = line.find_first_not_of ("\t ", tmp_pos + 1); |
|
1269 } |
|
1270 |
|
1271 if (line_pos == NPOS) |
|
1272 { |
|
1273 pos = new_pos + 1; |
|
1274 continue; |
|
1275 } |
|
1276 |
|
1277 // chop " f(x) " |
|
1278 if (line.find_first_not_of (_alpha, line_pos) != line_pos) |
|
1279 { |
|
1280 tmp_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1281 (_alphanum, line_pos)); |
|
1282 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "(") |
|
1283 line_pos = line.find_first_not_of ("\t ", line.find_first_of |
|
1284 (")", tmp_pos) + 1); |
|
1285 } |
|
1286 |
|
1287 if (line_pos == NPOS) |
|
1288 { |
5592
|
1289 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1290 continue; |
|
1291 } |
|
1292 |
|
1293 // chop " ; " |
|
1294 if (line.substr (line_pos, 1) == ":" |
|
1295 || line.substr (line_pos, 1) == ";") |
|
1296 line_pos = line.find_first_not_of ("\t ", line_pos + 1); |
|
1297 |
|
1298 if (line_pos == NPOS) |
|
1299 { |
5592
|
1300 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1301 continue; |
|
1302 } |
|
1303 |
|
1304 // chop " BLAH " |
|
1305 if (line.length () > line_pos + 2 |
|
1306 && line.find_first_of (_upper, line_pos) == line_pos |
|
1307 && line.find_first_of (_upper, line_pos+1) == line_pos + 1) |
|
1308 line_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1309 (_upper + "0123456789_", line_pos)); |
|
1310 |
|
1311 if (line_pos == NPOS) |
|
1312 { |
5592
|
1313 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1314 continue; |
|
1315 } |
|
1316 |
|
1317 // chop " blah --- " |
|
1318 tmp_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1319 (_alphanum, line_pos)); |
|
1320 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "-") |
|
1321 { |
|
1322 tmp_pos = line.find_first_not_of ("-", tmp_pos); |
|
1323 if (line.substr (tmp_pos, 1) == " " |
|
1324 || line.substr (tmp_pos, 1) == "\t") |
|
1325 line_pos = line.find_first_not_of ("\t ", tmp_pos); |
|
1326 } |
|
1327 |
|
1328 if (line_pos == NPOS) |
|
1329 { |
5592
|
1330 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1331 continue; |
|
1332 } |
|
1333 |
|
1334 // chop " blah <TAB> " |
|
1335 if (line.find_first_not_of (_alpha, line_pos) != line_pos) |
|
1336 { |
|
1337 tmp_pos = line.find_first_not_of (" ", line.find_first_not_of |
|
1338 (_alphanum, line_pos)); |
|
1339 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "\t") |
|
1340 line_pos = line.find_first_not_of ("\t ", line.find_first_of |
|
1341 (")", tmp_pos) + 1); |
|
1342 } |
|
1343 |
|
1344 if (line_pos == NPOS) |
|
1345 { |
5592
|
1346 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1347 continue; |
|
1348 } |
|
1349 |
|
1350 // chop " blah " |
|
1351 if (line.find_first_not_of (_alpha, line_pos) != line_pos) |
|
1352 { |
|
1353 tmp_pos = line.find_first_not_of (_alphanum, line_pos); |
|
1354 |
|
1355 if (tmp_pos != NPOS |
|
1356 && (line.substr (tmp_pos, 2) == "\t\t" |
|
1357 || line.substr (tmp_pos, 2) == "\t " |
|
1358 || line.substr (tmp_pos, 2) == " \t" |
|
1359 || line.substr (tmp_pos, 2) == " ")) |
|
1360 line_pos = line.find_first_not_of ("\t ", tmp_pos); |
|
1361 } |
|
1362 |
|
1363 if (line_pos == NPOS) |
|
1364 { |
5592
|
1365 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1366 continue; |
|
1367 } |
|
1368 |
|
1369 // skip blah \n or \n blah |
|
1370 // skip blank line |
|
1371 // skip "# !/usr/bin/octave" |
|
1372 if ((line.substr (line_pos , 2) == "or" |
|
1373 && line.find_first_not_of ("\n\t ", line_pos + 2) == NPOS) |
|
1374 || line.find_first_not_of ("\n\t ", line_pos) == NPOS |
|
1375 || line.substr (line_pos, 2) == "!/") |
|
1376 { |
5592
|
1377 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1378 continue; |
|
1379 } |
|
1380 |
|
1381 // Got the start of first sentence, break. |
|
1382 pos = pos + line_pos; |
|
1383 break; |
|
1384 } |
|
1385 |
|
1386 if (pos == NPOS) |
5738
|
1387 return retval; |
5447
|
1388 |
|
1389 // At start of real text. Get first line with the sentence |
|
1390 size_t new_pos = h.find_first_of ('\n', pos); |
|
1391 std::string line = h.substr (pos, new_pos-pos); |
|
1392 size_t dot_pos; |
|
1393 |
|
1394 while ((dot_pos = line.find_first_of ('.')) == NPOS) |
|
1395 { |
|
1396 // Trim trailing blanks on line |
|
1397 line = line.substr (0, line.find_last_not_of ("\n\t ") + 1); |
|
1398 |
|
1399 // Append next line |
|
1400 size_t tmp_pos = h.find_first_not_of ("\t ", new_pos + 1); |
|
1401 if (tmp_pos == NPOS || h.substr (tmp_pos, 1) == "\n") |
|
1402 break; |
|
1403 |
|
1404 new_pos = h.find_first_of ('\n', tmp_pos); |
|
1405 std::string next = h.substr (tmp_pos, new_pos-tmp_pos); |
|
1406 |
|
1407 if (short_sentence) |
|
1408 { |
|
1409 // Only add the next line if it terminates the sentence, then break |
|
1410 if ((tmp_pos = next.find_first_of ('.')) != NPOS) |
|
1411 { |
|
1412 line = line + " " + next; |
|
1413 dot_pos = line.find_first_of ('.'); |
|
1414 } |
|
1415 break; |
|
1416 } |
|
1417 else |
|
1418 line = line + " " + next; |
|
1419 } |
|
1420 |
|
1421 if (dot_pos == NPOS) |
5738
|
1422 retval = line; |
5447
|
1423 else |
5738
|
1424 retval = line.substr (0, dot_pos + 1); |
5447
|
1425 } |
5738
|
1426 |
|
1427 return retval; |
5447
|
1428 } |
|
1429 |
|
1430 static void |
|
1431 print_lookfor (const std::string& name, const std::string& line) |
|
1432 { |
|
1433 const size_t deflen = 20; |
|
1434 |
|
1435 size_t max_width = command_editor::terminal_cols () - deflen; |
|
1436 if (max_width < deflen) |
|
1437 max_width = deflen; |
|
1438 |
|
1439 size_t name_len = name.length (); |
|
1440 |
|
1441 size_t width = max_width; |
|
1442 if (name_len > deflen) |
|
1443 { |
|
1444 width = command_editor::terminal_cols () - name_len; |
|
1445 if (width < deflen) |
|
1446 width = deflen; |
|
1447 } |
|
1448 |
|
1449 size_t pad_len = deflen > name_len ? deflen - name_len + 1 : 1; |
|
1450 octave_stdout << name << std::string (pad_len, ' '); |
|
1451 |
|
1452 size_t pos = 0; |
|
1453 |
|
1454 while (1) |
|
1455 { |
|
1456 size_t new_pos = line.find_first_of ("\n\t ", pos); |
|
1457 size_t end_pos = new_pos; |
|
1458 |
|
1459 if (line.length () - pos < width) |
|
1460 new_pos = end_pos = NPOS; |
|
1461 else |
|
1462 while (new_pos != NPOS && new_pos - pos < width) |
|
1463 { |
|
1464 end_pos = new_pos; |
|
1465 new_pos = line.find_first_of ("\n\t ", new_pos + 1); |
|
1466 } |
|
1467 |
|
1468 octave_stdout << line.substr (pos, end_pos-pos) << std::endl; |
|
1469 |
|
1470 if (end_pos == NPOS) |
|
1471 break; |
|
1472 |
|
1473 pos = end_pos + 1; |
|
1474 width = max_width; |
|
1475 octave_stdout << std::string (deflen + 1, ' '); |
|
1476 } |
|
1477 } |
|
1478 |
|
1479 DEFCMD (lookfor, args, nargout, |
|
1480 "-*- texinfo -*-\n\ |
|
1481 @deffn {Command} lookfor @var{str}\n\ |
|
1482 @deffnx {Command} lookfor -all @var{str}\n\ |
|
1483 @deffnx {Function} {[@var{fun}, @var{helpstring}] = } lookfor (@var{str})\n\ |
|
1484 @deffnx {Function} {[@var{fun}, @var{helpstring}] = } lookfor ('-all', @var{str})\n\ |
|
1485 Search for the string @var{str} in all of the functions found in\n\ |
|
1486 @var{LOADPATH}. By default @code{lookfor} searchs for @var{str} in the\n\ |
|
1487 first sentence of the help string of each function found. The entire\n\ |
|
1488 help string of each function found of @var{LOADPATH} can be search if\n\ |
|
1489 the '-all' argument is supplied. All searches are case insensitive.\n\ |
|
1490 \n\ |
|
1491 Called with no output arguments, @code{lookfor} prints the list of matching\n\ |
|
1492 functions to the terminal. Otherwise the output arguments @var{fun} and\n\ |
|
1493 @var{helpstring} define the matching functions and the first sentence of\n\ |
|
1494 each of their help strings.\n\ |
|
1495 \n\ |
|
1496 Note that the ability of @code{lookfor} to correctly identify the first\n\ |
|
1497 sentence of the help of the functions is dependent on the format of the\n\ |
|
1498 functions help. All of the functions in octave itself will correctly\n\ |
|
1499 find the first sentence, but the same can not be guaranteed for other\n\ |
|
1500 functions. Therefore the use of the '-all' argument might be necessary\n\ |
|
1501 to find related functions that are not part of octave.\n\ |
5667
|
1502 @seealso{help, which}\n\ |
5642
|
1503 @end deffn") |
5447
|
1504 { |
|
1505 octave_value_list retval; |
|
1506 int nargin = args.length (); |
|
1507 bool first_sentence_only = true; |
|
1508 |
|
1509 if (nargin != 1 && nargin != 2) |
|
1510 { |
|
1511 usage ("lookfor"); |
|
1512 return retval; |
|
1513 } |
|
1514 |
|
1515 string_vector ret[2]; |
|
1516 |
|
1517 std::string txt; |
|
1518 |
|
1519 if (args(0).is_string ()) |
|
1520 { |
|
1521 txt = args(0).string_value (); |
|
1522 |
|
1523 if (nargin == 2) |
|
1524 { |
|
1525 if (args(1).is_string ()) |
|
1526 { |
|
1527 std::string tmp = args(1).string_value (); |
|
1528 |
|
1529 if (txt.substr(0,1) == "-") |
|
1530 { |
|
1531 txt = tmp; |
|
1532 tmp = args(0).string_value (); |
|
1533 } |
|
1534 |
|
1535 if (tmp == "-all") |
|
1536 first_sentence_only = false; |
|
1537 else |
|
1538 error ("lookfor: unrecognized option argument"); |
|
1539 } |
|
1540 else |
|
1541 error ("lookfor: arguments must be a string"); |
|
1542 } |
|
1543 } |
|
1544 else |
|
1545 error ("lookfor: argument must be a string"); |
|
1546 |
|
1547 if (!error_state) |
|
1548 { |
|
1549 // All tests in lower case |
5768
|
1550 std::transform (txt.begin (), txt.end (), txt.begin (), tolower); |
5447
|
1551 |
|
1552 help_list *ptr = keyword_help (); |
|
1553 while (ptr->name) |
|
1554 { |
|
1555 std::string name = ptr->name; |
|
1556 std::string h = ptr->help; |
|
1557 |
5592
|
1558 if (name.find (txt) != NPOS) |
5447
|
1559 { |
|
1560 if (nargout) |
|
1561 { |
|
1562 ret[0].append (name); |
|
1563 ret[1].append (first_help_sentence (h)); |
|
1564 } |
|
1565 else |
|
1566 print_lookfor (name, first_help_sentence (h)); |
|
1567 } |
5592
|
1568 else |
|
1569 { |
|
1570 std::string s; |
|
1571 |
|
1572 if (first_sentence_only) |
|
1573 s = first_help_sentence (h); |
|
1574 else |
|
1575 s = h; |
|
1576 |
5768
|
1577 std::transform (s.begin (), s.end (), s.begin (), tolower); |
5592
|
1578 |
|
1579 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1580 { |
|
1581 if (nargout) |
|
1582 { |
|
1583 ret[0].append (name); |
|
1584 ret[1].append (first_help_sentence (h)); |
|
1585 } |
|
1586 else |
|
1587 print_lookfor (name, first_help_sentence (h)); |
|
1588 } |
|
1589 } |
5447
|
1590 |
|
1591 OCTAVE_QUIT; |
|
1592 |
|
1593 ptr++; |
|
1594 } |
|
1595 |
|
1596 ptr = operator_help (); |
|
1597 while (ptr->name) |
|
1598 { |
|
1599 std::string name = ptr->name; |
|
1600 std::string h = ptr->help; |
|
1601 |
5592
|
1602 if (name.find (txt) != NPOS) |
5447
|
1603 { |
|
1604 if (nargout) |
|
1605 { |
|
1606 ret[0].append (name); |
|
1607 ret[1].append (first_help_sentence (h)); |
|
1608 } |
|
1609 else |
|
1610 print_lookfor (name, first_help_sentence (h)); |
|
1611 } |
5592
|
1612 else |
|
1613 { |
|
1614 std::string s; |
|
1615 if (first_sentence_only) |
|
1616 s = first_help_sentence (h); |
|
1617 else |
|
1618 s = h; |
|
1619 |
5768
|
1620 std::transform (s.begin (), s.end (), s.begin (), tolower); |
5592
|
1621 |
|
1622 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1623 { |
|
1624 if (nargout) |
|
1625 { |
|
1626 ret[0].append (name); |
|
1627 ret[1].append (first_help_sentence (h)); |
|
1628 } |
|
1629 else |
|
1630 print_lookfor (name, first_help_sentence (h)); |
|
1631 } |
|
1632 } |
5447
|
1633 |
|
1634 OCTAVE_QUIT; |
|
1635 |
|
1636 ptr++; |
|
1637 } |
|
1638 |
|
1639 // Check the symbol record table |
|
1640 string_vector names |
|
1641 = fbi_sym_tab->name_list (string_vector (), true); |
|
1642 |
|
1643 for (octave_idx_type i = 0; i < names.length (); i++) |
|
1644 { |
|
1645 std::string name = names (i); |
|
1646 |
|
1647 OCTAVE_QUIT; |
|
1648 |
|
1649 symbol_record *sr = lookup_by_name (name, 0); |
5738
|
1650 if (sr && sr->is_defined () |
|
1651 && sr->type_name () != "overloaded function") |
5447
|
1652 { |
|
1653 std::string h = sr->help (); |
|
1654 |
5592
|
1655 if (name.find (txt) != NPOS) |
5447
|
1656 { |
|
1657 if (nargout) |
|
1658 { |
|
1659 ret[0].append (name); |
|
1660 ret[1].append (first_help_sentence (h)); |
|
1661 } |
|
1662 else |
|
1663 print_lookfor (name, first_help_sentence (h)); |
|
1664 } |
5592
|
1665 else |
|
1666 { |
|
1667 std::string s; |
|
1668 |
|
1669 if (first_sentence_only) |
|
1670 s = first_help_sentence (h); |
|
1671 else |
|
1672 s = h; |
|
1673 |
5768
|
1674 std::transform (s.begin (), s.end (), s.begin (), tolower); |
5592
|
1675 |
|
1676 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1677 { |
|
1678 if (nargout) |
|
1679 { |
|
1680 ret[0].append (name); |
|
1681 ret[1].append (first_help_sentence (h)); |
|
1682 } |
|
1683 else |
|
1684 print_lookfor (name, first_help_sentence (h)); |
|
1685 } |
|
1686 } |
5447
|
1687 } |
|
1688 } |
|
1689 |
|
1690 string_vector dirs = Vload_path_dir_path.all_directories (); |
|
1691 |
|
1692 int len = dirs.length (); |
|
1693 |
|
1694 for (int i = 0; i < len; i++) |
|
1695 { |
|
1696 names = octave_fcn_file_name_cache::list (dirs[i]); |
|
1697 |
|
1698 if (! names.empty ()) |
|
1699 { |
|
1700 for (int j = 0; j < names.length (); j++) |
|
1701 { |
|
1702 std::string name = names (j); |
|
1703 |
|
1704 OCTAVE_QUIT; |
|
1705 |
|
1706 // Strip extension |
|
1707 size_t l = name.length (); |
|
1708 if (l > 4 && name.substr (l-4) == ".oct") |
|
1709 name = name.substr (0, l - 4); |
|
1710 else if (l > 2 && name.substr (l-2) == ".m") |
|
1711 name = name.substr (0, l - 2); |
|
1712 else |
|
1713 continue; |
|
1714 |
|
1715 // Check if already in symbol table |
|
1716 symbol_record *sr = fbi_sym_tab->lookup (name); |
|
1717 |
|
1718 if (!sr) |
|
1719 { |
|
1720 // Check if this version is first in the path |
|
1721 string_vector tmp (2); |
|
1722 tmp(0) = name + ".oct"; |
|
1723 tmp(1) = name + ".m"; |
|
1724 std::string file_name = |
|
1725 Vload_path_dir_path.find_first_of (tmp); |
|
1726 |
|
1727 if (file_name == dirs[i] + tmp(0) |
|
1728 || file_name == dirs[i] + tmp(1)) |
|
1729 { |
5484
|
1730 bool symbol_found; |
|
1731 |
5592
|
1732 std::string h; |
|
1733 if (file_name == dirs[i] + tmp(0)) |
|
1734 { |
|
1735 // oct-file. Must load to get help |
|
1736 sr = lookup_by_name (name, false); |
5447
|
1737 |
5592
|
1738 if (sr && sr->is_defined ()) |
|
1739 h = sr->help (); |
|
1740 } |
5447
|
1741 else |
5592
|
1742 h = get_help_from_file (file_name, symbol_found); |
5447
|
1743 |
5592
|
1744 if (name.find (txt) != NPOS) |
5447
|
1745 { |
|
1746 if (nargout) |
|
1747 { |
|
1748 ret[0].append (name); |
|
1749 ret[1].append (first_help_sentence (h)); |
|
1750 } |
|
1751 else |
|
1752 print_lookfor (name, first_help_sentence (h)); |
|
1753 } |
5592
|
1754 else |
|
1755 { |
|
1756 std::string s; |
|
1757 if (first_sentence_only) |
|
1758 s = first_help_sentence (h); |
|
1759 else |
|
1760 s = h; |
|
1761 |
5768
|
1762 std::transform (s.begin (), s.end (), s.begin (), tolower); |
5592
|
1763 |
|
1764 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1765 { |
|
1766 if (nargout) |
|
1767 { |
|
1768 ret[0].append (name); |
|
1769 ret[1].append (first_help_sentence (h)); |
|
1770 } |
|
1771 else |
|
1772 print_lookfor (name, first_help_sentence (h)); |
|
1773 } |
|
1774 } |
|
1775 } |
|
1776 } |
|
1777 |
|
1778 // Check if this function has autoloaded functions attached to it |
|
1779 std::string file_name = Vload_path_dir_path.find_first_of (names(j)); |
|
1780 string_vector autoload_fcns = reverse_lookup_autoload (file_name); |
|
1781 |
|
1782 if (! autoload_fcns.empty ()) |
|
1783 { |
|
1784 for (int k = 0; k < autoload_fcns.length (); k++) |
|
1785 { |
|
1786 std::string aname = autoload_fcns (k); |
|
1787 |
|
1788 // Check if already in symbol table |
|
1789 sr = fbi_sym_tab->lookup (aname); |
|
1790 |
|
1791 if (!sr) |
|
1792 { |
|
1793 // Must load to get help |
5738
|
1794 sr = lookup_by_name (aname, false); |
5592
|
1795 |
|
1796 std::string h; |
|
1797 if (sr && sr->is_defined ()) |
|
1798 h = sr->help (); |
|
1799 |
|
1800 if (aname.find (txt) != NPOS) |
|
1801 { |
|
1802 if (nargout) |
|
1803 { |
|
1804 ret[0].append (aname); |
|
1805 ret[1].append (first_help_sentence (h)); |
|
1806 } |
|
1807 else |
|
1808 print_lookfor (aname, first_help_sentence (h)); |
|
1809 } |
|
1810 else |
|
1811 { |
|
1812 std::string s; |
|
1813 if (first_sentence_only) |
|
1814 s = first_help_sentence (h); |
|
1815 else |
|
1816 s = h; |
|
1817 |
5768
|
1818 std::transform (s.begin (), s.end (), s.begin (), |
5592
|
1819 tolower); |
|
1820 |
|
1821 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1822 { |
|
1823 if (nargout) |
|
1824 { |
|
1825 ret[0].append (aname); |
|
1826 ret[1].append (first_help_sentence (h)); |
|
1827 } |
|
1828 else |
|
1829 print_lookfor (aname, first_help_sentence (h)); |
|
1830 } |
|
1831 } |
|
1832 } |
5447
|
1833 } |
|
1834 } |
|
1835 } |
|
1836 } |
|
1837 } |
|
1838 |
|
1839 if (nargout != 0) |
|
1840 { |
|
1841 retval (1) = ret[1]; |
|
1842 retval (0) = ret[0]; |
|
1843 } |
|
1844 } |
|
1845 else |
|
1846 { |
|
1847 error ("lookfor: argument must be a string"); |
|
1848 } |
|
1849 |
|
1850 return retval; |
|
1851 } |
|
1852 |
2189
|
1853 static int |
2202
|
1854 info_file (void) |
|
1855 { |
|
1856 int status = 0; |
|
1857 |
3523
|
1858 std::string s = builtin_string_variable ("INFO_FILE"); |
2202
|
1859 |
|
1860 if (s.empty ()) |
|
1861 { |
|
1862 gripe_invalid_value_specified ("INFO_FILE"); |
|
1863 status = -1; |
|
1864 } |
|
1865 else |
|
1866 Vinfo_file = s; |
|
1867 |
|
1868 return status; |
|
1869 } |
|
1870 |
|
1871 static int |
|
1872 info_prog (void) |
|
1873 { |
|
1874 int status = 0; |
|
1875 |
3523
|
1876 std::string s = builtin_string_variable ("INFO_PROGRAM"); |
2202
|
1877 |
|
1878 if (s.empty ()) |
|
1879 { |
|
1880 gripe_invalid_value_specified ("INFO_PROGRAM"); |
|
1881 status = -1; |
|
1882 } |
|
1883 else |
|
1884 Vinfo_prog = s; |
|
1885 |
|
1886 return status; |
|
1887 } |
|
1888 |
3014
|
1889 static int |
3686
|
1890 makeinfo_prog (void) |
|
1891 { |
|
1892 int status = 0; |
|
1893 |
|
1894 std::string s = builtin_string_variable ("MAKEINFO_PROGRAM"); |
|
1895 |
|
1896 if (s.empty ()) |
|
1897 { |
|
1898 gripe_invalid_value_specified ("MAKEINFO_PROGRAM"); |
|
1899 status = -1; |
|
1900 } |
|
1901 else |
|
1902 Vmakeinfo_prog = s; |
|
1903 |
|
1904 return status; |
|
1905 } |
|
1906 |
|
1907 static int |
3014
|
1908 suppress_verbose_help_message (void) |
|
1909 { |
|
1910 Vsuppress_verbose_help_message |
|
1911 = check_preference ("suppress_verbose_help_message"); |
|
1912 |
|
1913 return 0; |
|
1914 } |
|
1915 |
2189
|
1916 void |
|
1917 symbols_of_help (void) |
|
1918 { |
3258
|
1919 DEFVAR (INFO_FILE, Vinfo_file, info_file, |
3332
|
1920 "-*- texinfo -*-\n\ |
|
1921 @defvr {Built-in Variable} INFO_FILE\n\ |
|
1922 The variable @code{INFO_FILE} names the location of the Octave info file.\n\ |
3686
|
1923 The default value is @code{\"@var{octave-home}/info/octave.info\"}, in\n\ |
|
1924 which @var{octave-home} is the directory where all of Octave is installed.\n\ |
3333
|
1925 @end defvr"); |
2202
|
1926 |
3258
|
1927 DEFVAR (INFO_PROGRAM, Vinfo_prog, info_prog, |
3332
|
1928 "-*- texinfo -*-\n\ |
3686
|
1929 @defvr {Built-in Variable} INFO_PROGRAM\n\ |
|
1930 The variable @code{INFO_PROGRAM} names the info program to run. Its\n\ |
|
1931 default initial value is\n\ |
|
1932 @code{\"@var{octave-home}/libexec/octave/@var{version}/exec/@var{arch}/info\"}\n\ |
|
1933 in which @var{octave-home} is the directory where all of Octave is\n\ |
|
1934 installed, @var{version} is the Octave version number, and @var{arch}\n\ |
|
1935 is the system type (for example, @code{i686-pc-linux-gnu}). The\n\ |
|
1936 default initial value may be overridden by the environment variable\n\ |
|
1937 @code{OCTAVE_INFO_PROGRAM}, or the command line argument\n\ |
|
1938 @code{--info-program NAME}, or by setting the value of\n\ |
|
1939 @code{INFO_PROGRAM} in a startup script\n\ |
|
1940 @end defvr"); |
|
1941 |
|
1942 DEFVAR (MAKEINFO_PROGRAM, Vmakeinfo_prog, makeinfo_prog, |
|
1943 "-*- texinfo -*-\n\ |
|
1944 @defvr {Built-in Variable} MAKEINFO_PROGRAM\n\ |
|
1945 The variable @code{MAKEINFO_PROGRAM} names the makeinfo program that\n\ |
|
1946 Octave runs to format help text that contains Texinfo markup commands.\n\ |
|
1947 Its default initial value is @code{\"makeinfo\"}.\n\ |
3333
|
1948 @end defvr"); |
2202
|
1949 |
4233
|
1950 DEFVAR (suppress_verbose_help_message, false, suppress_verbose_help_message, |
3332
|
1951 "-*- texinfo -*-\n\ |
|
1952 @defvr {Built-in Variable} suppress_verbose_help_message\n\ |
|
1953 If the value of @code{suppress_verbose_help_message} is nonzero, Octave\n\ |
|
1954 will not add additional help information to the end of the output from\n\ |
|
1955 the @code{help} command and usage messages for built-in commands.\n\ |
3333
|
1956 @end defvr"); |
2189
|
1957 } |
|
1958 |
1
|
1959 /* |
|
1960 ;;; Local Variables: *** |
|
1961 ;;; mode: C++ *** |
|
1962 ;;; End: *** |
|
1963 */ |