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