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) |
5794
|
78 std::string Vinfo_program; |
2202
|
79 |
3686
|
80 // Name of the makeinfo program to run. |
5794
|
81 static std::string Vmakeinfo_program = "makeinfo"; |
3686
|
82 |
2189
|
83 // If TRUE, don't print additional help message in help and usage |
|
84 // functions. |
5794
|
85 static bool Vsuppress_verbose_help_message = false; |
2189
|
86 |
5775
|
87 // FIXME -- maybe this should use string instead of char*. |
3016
|
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 |
5775
|
390 // It's not likely that this does the right thing now. FIXME |
3016
|
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 << "\ |
5794
|
455 Additional help for built-in functions and operators is\n\ |
|
456 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 |
5775
|
464 // FIXME -- this needs a major overhaul to cope with new |
2976
|
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 |
5775
|
519 // FIXME -- is this distinction needed? |
1358
|
520 |
4208
|
521 LIST_SYMBOLS (symbol_record::COMMAND, "commands"); |
529
|
522 |
3010
|
523 LIST_SYMBOLS (symbol_record::MAPPER_FUNCTION, "mapper functions"); |
542
|
524 |
3010
|
525 LIST_SYMBOLS (symbol_record::BUILTIN_FUNCTION, "general functions"); |
542
|
526 |
1358
|
527 // Also need to list variables and currently compiled functions from |
|
528 // the symbol table, if there are any. |
529
|
529 |
1358
|
530 // Also need to search octave_path for script files. |
529
|
531 |
3195
|
532 string_vector dirs = Vload_path_dir_path.all_directories (); |
679
|
533 |
1787
|
534 int len = dirs.length (); |
679
|
535 |
1787
|
536 for (int i = 0; i < len; i++) |
|
537 { |
2233
|
538 string_vector names = octave_fcn_file_name_cache::list (dirs[i]); |
679
|
539 |
1787
|
540 if (! names.empty ()) |
|
541 { |
3523
|
542 std::string dir |
2926
|
543 = octave_env::make_absolute (dirs[i], octave_env::getcwd ()); |
|
544 |
|
545 octave_stdout << "\n*** function files in " << dir << ":\n\n"; |
679
|
546 |
3259
|
547 names.qsort (); |
|
548 |
2095
|
549 names.list_in_columns (octave_stdout); |
529
|
550 } |
|
551 } |
5592
|
552 |
|
553 string_vector autoloaded = autoloaded_functions (); |
|
554 |
|
555 if (! autoloaded.empty ()) |
|
556 { |
|
557 octave_stdout << "\n*** autoloaded functions:\n\n"; |
|
558 |
|
559 autoloaded.qsort (); |
|
560 |
|
561 autoloaded.list_in_columns (octave_stdout); |
|
562 } |
529
|
563 } |
|
564 |
|
565 static int |
3523
|
566 try_info (const std::string& nm) |
529
|
567 { |
5672
|
568 int retval = -1; |
1295
|
569 |
5672
|
570 warning ("please use `doc' instead of `help -i'"); |
529
|
571 |
5672
|
572 octave_value_list args; |
|
573 args(0) = nm; |
|
574 octave_value_list result = feval ("doc", args, 1); |
4051
|
575 |
5672
|
576 if (result.length () > 0) |
|
577 retval = result(0).int_value (); |
529
|
578 |
5672
|
579 return retval; |
529
|
580 } |
1140
|
581 |
|
582 static void |
1755
|
583 help_from_info (const string_vector& argv, int idx, int argc) |
1140
|
584 { |
1755
|
585 if (idx == argc) |
3523
|
586 try_info (std::string ()); |
1140
|
587 else |
|
588 { |
1755
|
589 for (int i = idx; i < argc; i++) |
1140
|
590 { |
1755
|
591 int status = try_info (argv[i]); |
1140
|
592 |
5672
|
593 if (status == 127) |
|
594 break; |
|
595 else if (status != 0) |
|
596 message ("help", "`%s' is not indexed in the manual", |
|
597 argv[i].c_str ()); |
1140
|
598 } |
|
599 } |
2470
|
600 } |
3014
|
601 |
|
602 static bool |
3523
|
603 looks_like_texinfo (const std::string& msg, size_t& p1) |
3295
|
604 { |
|
605 p1 = msg.find ('\n'); |
|
606 |
3523
|
607 std::string t = msg.substr (0, p1); |
3295
|
608 |
|
609 if (p1 == NPOS) |
|
610 p1 = 0; |
|
611 |
|
612 size_t p2 = t.find ("-*- texinfo -*-"); |
|
613 |
|
614 return (p2 != NPOS); |
|
615 } |
|
616 |
3330
|
617 void |
3523
|
618 display_help_text (std::ostream& os, const std::string& msg) |
3295
|
619 { |
|
620 // Look for "-*- texinfo -*-" in first line of help message. If it |
|
621 // is present, use makeinfo to format the rest of the message before |
|
622 // sending it to the output stream. Otherwise, just print the |
|
623 // message. |
|
624 |
|
625 size_t pos; |
|
626 |
|
627 if (looks_like_texinfo (msg, pos)) |
|
628 { |
5594
|
629 os.flush (); |
|
630 |
3523
|
631 std::string tmp_file_name = file_ops::tempnam ("", ""); |
3295
|
632 |
|
633 int cols = command_editor::terminal_cols (); |
|
634 |
|
635 if (cols > 16) |
|
636 cols--; |
|
637 |
|
638 if (cols > 64) |
|
639 cols -= 7; |
|
640 |
|
641 if (cols > 80) |
|
642 cols = 72; |
|
643 |
5765
|
644 std::ostringstream buf; |
4051
|
645 |
4115
|
646 buf << "sed -e 's/^[#%][#%]* *//' -e 's/^ *@/@/' | " |
5794
|
647 << "\"" << Vmakeinfo_program << "\"" |
3303
|
648 << " -D \"VERSION " << OCTAVE_VERSION << "\"" |
|
649 << " -D \"OCTAVEHOME " << OCTAVE_PREFIX << "\"" |
3584
|
650 << " -D \"TARGETHOSTTYPE " << OCTAVE_CANONICAL_HOST_TYPE << "\"" |
3301
|
651 << " --fill-column " << cols |
|
652 << " --no-warn" |
|
653 << " --no-validate" |
|
654 << " --no-headers" |
|
655 << " --force" |
5765
|
656 << " --output \"" << tmp_file_name << "\""; |
3295
|
657 |
5765
|
658 oprocstream filter (buf.str ()); |
3295
|
659 |
3686
|
660 if (filter && filter.is_open ()) |
3295
|
661 { |
3405
|
662 filter << "@macro seealso {args}\n" |
5644
|
663 << "@sp 1\n" |
3408
|
664 << "@noindent\n" |
3405
|
665 << "See also: \\args\\.\n" |
|
666 << "@end macro\n"; |
|
667 |
3769
|
668 filter << msg.substr (pos+1) << std::endl; |
3295
|
669 |
3686
|
670 int status = filter.close (); |
3295
|
671 |
3523
|
672 std::ifstream tmp_file (tmp_file_name.c_str ()); |
3295
|
673 |
3686
|
674 if (WIFEXITED (status) && WEXITSTATUS (status) == 0) |
|
675 { |
|
676 int c; |
|
677 while ((c = tmp_file.get ()) != EOF) |
|
678 os << (char) c; |
3295
|
679 |
3686
|
680 tmp_file.close (); |
|
681 } |
|
682 else |
|
683 { |
|
684 warning ("help: Texinfo formatting filter exited abnormally"); |
|
685 warning ("help: raw Texinfo source of help text follows..."); |
5594
|
686 warning ("help:\n\n%s\n\n", msg.c_str ()); |
3686
|
687 } |
3295
|
688 |
|
689 file_ops::unlink (tmp_file_name); |
|
690 } |
|
691 else |
|
692 os << msg; |
|
693 } |
|
694 else |
|
695 os << msg; |
|
696 } |
|
697 |
5800
|
698 void |
|
699 display_usage_text (std::ostream& os, const std::string& msg) |
|
700 { |
|
701 std::string filtered_msg = msg; |
|
702 |
|
703 size_t pos; |
|
704 |
|
705 if (looks_like_texinfo (msg, pos)) |
|
706 { |
|
707 std::ostringstream buf; |
|
708 |
|
709 buf << "-*- texinfo -*-\n"; |
|
710 |
|
711 bool found_def = false; |
|
712 |
|
713 size_t msg_len = msg.length (); |
|
714 |
|
715 while (pos < msg_len) |
|
716 { |
|
717 size_t new_pos = msg.find_first_of ('\n', pos); |
|
718 |
|
719 if (new_pos == NPOS) |
|
720 new_pos = msg_len-1; |
|
721 |
|
722 std::string line = msg.substr (pos, new_pos-pos+1); |
|
723 |
|
724 if (line.substr (0, 4) == "@def" |
|
725 || line.substr (0, 8) == "@end def") |
|
726 { |
|
727 found_def = true; |
|
728 buf << line; |
|
729 } |
|
730 |
|
731 pos = new_pos + 1; |
|
732 } |
|
733 |
|
734 if (found_def) |
|
735 filtered_msg = buf.str (); |
|
736 } |
|
737 |
|
738 display_help_text (os, filtered_msg); |
|
739 } |
|
740 |
3295
|
741 static bool |
3523
|
742 help_from_list (std::ostream& os, const help_list *list, |
5399
|
743 const std::string& nm, int usage, bool& symbol_found) |
542
|
744 { |
5399
|
745 bool retval = false; |
|
746 |
2804
|
747 const char *name; |
3014
|
748 |
542
|
749 while ((name = list->name) != 0) |
|
750 { |
1755
|
751 if (strcmp (name, nm.c_str ()) == 0) |
542
|
752 { |
5399
|
753 symbol_found = true; |
|
754 |
|
755 std::string h = list->help; |
|
756 |
|
757 if (h.length () > 0) |
542
|
758 { |
5399
|
759 if (usage) |
|
760 os << "\nusage: "; |
|
761 else |
|
762 os << "\n*** " << nm << ":\n\n"; |
|
763 |
|
764 display_help_text (os, h); |
|
765 |
|
766 os << "\n"; |
|
767 |
|
768 retval = true; |
542
|
769 } |
5399
|
770 break; |
542
|
771 } |
|
772 list++; |
|
773 } |
3014
|
774 |
5399
|
775 return retval;; |
|
776 } |
|
777 |
|
778 std::string |
|
779 extract_help_from_dispatch (const std::string& nm) |
|
780 { |
|
781 std::string retval; |
|
782 |
|
783 symbol_record *builtin = fbi_sym_tab->lookup ("builtin:" + nm, 0); |
|
784 |
|
785 if (builtin) |
|
786 { |
|
787 // Check that builtin is up to date. |
|
788 |
|
789 // Don't try to fight octave's function name handling |
|
790 // mechanism. Instead, move dispatch record out of the way, |
|
791 // and restore the builtin to its original name. |
|
792 symbol_record *dispatch = fbi_sym_tab->lookup (nm, 0); |
|
793 |
|
794 if (dispatch) |
|
795 { |
|
796 dispatch->unprotect (); |
|
797 |
|
798 fbi_sym_tab->rename (nm, "dispatch:" + nm); |
|
799 fbi_sym_tab->rename ("builtin:" + nm, nm); |
|
800 |
|
801 // Check for updates to builtin function; ignore errors |
|
802 // that appear (they interfere with renaming), and remove |
5775
|
803 // the updated name from the current symbol table. FIXME -- |
|
804 // check that updating a function updates it in all |
|
805 // contexts. It may be that it is updated only in the |
5399
|
806 // current symbol table, and not the caller. I believe this |
|
807 // won't be a problem because the caller will go through the |
|
808 // same logic and end up with the newer version. |
|
809 |
|
810 octave_function *f = is_valid_function (nm); |
|
811 |
|
812 if (f) |
|
813 retval = builtin->help (); |
|
814 |
|
815 curr_sym_tab->clear_function (nm); |
|
816 |
|
817 // Move the builtin function out of the way and restore the |
5775
|
818 // dispatch fuction. FIXME what if builtin wants to |
5399
|
819 // protect itself? |
|
820 |
|
821 fbi_sym_tab->rename (nm, "builtin:" + nm); |
|
822 fbi_sym_tab->rename ("dispatch:" + nm, nm); |
|
823 |
|
824 dispatch->protect (); |
|
825 } |
|
826 else |
|
827 error ("failed to find dispatch record for `builtin:%s'", nm.c_str ()); |
|
828 } |
|
829 |
|
830 return retval; |
542
|
831 } |
|
832 |
3355
|
833 static bool |
5399
|
834 help_from_symbol_table (std::ostream& os, const std::string& nm, |
|
835 bool& symbol_found) |
3355
|
836 { |
|
837 bool retval = false; |
|
838 |
|
839 symbol_record *sym_rec = lookup_by_name (nm, 0); |
|
840 |
|
841 if (sym_rec && sym_rec->is_defined ()) |
|
842 { |
5399
|
843 symbol_found = true; |
|
844 |
3523
|
845 std::string h = sym_rec->help (); |
3355
|
846 |
|
847 if (h.length () > 0) |
|
848 { |
5399
|
849 h = extract_help_from_dispatch (nm) + h; |
3355
|
850 display_help_text (os, h); |
5641
|
851 if (! Vsuppress_verbose_help_message) |
|
852 { |
|
853 sym_rec->which (os); |
|
854 os << "\n"; |
|
855 } |
3355
|
856 os << "\n"; |
|
857 retval = true; |
|
858 } |
|
859 } |
|
860 |
|
861 return retval; |
|
862 } |
|
863 |
|
864 static bool |
5399
|
865 help_from_file (std::ostream& os, const std::string& nm, bool& symbol_found) |
3355
|
866 { |
|
867 bool retval = false; |
|
868 |
5484
|
869 std::string h = get_help_from_file (nm, symbol_found, true); |
3355
|
870 |
5484
|
871 if (h.length () > 0) |
|
872 { |
|
873 display_help_text (os, h); |
|
874 os << "\n"; |
|
875 retval = true; |
3355
|
876 } |
|
877 |
|
878 return retval; |
|
879 } |
|
880 |
1140
|
881 static void |
1755
|
882 builtin_help (int argc, const string_vector& argv) |
1140
|
883 { |
|
884 help_list *op_help_list = operator_help (); |
|
885 help_list *kw_help_list = keyword_help (); |
|
886 |
1755
|
887 for (int i = 1; i < argc; i++) |
1140
|
888 { |
5399
|
889 bool symbol_found = false; |
|
890 |
|
891 if (help_from_list (octave_stdout, op_help_list, argv[i], 0, |
|
892 symbol_found)) |
1140
|
893 continue; |
|
894 |
5399
|
895 if (help_from_list (octave_stdout, kw_help_list, argv[i], 0, |
|
896 symbol_found)) |
1140
|
897 continue; |
|
898 |
5399
|
899 if (help_from_symbol_table (octave_stdout, argv[i], symbol_found)) |
|
900 continue; |
|
901 |
|
902 if (help_from_file (octave_stdout, argv[i], symbol_found)) |
3355
|
903 continue; |
1755
|
904 |
5399
|
905 if (symbol_found) |
|
906 octave_stdout << "\nhelp: `" << argv[i] |
|
907 << "' is not documented\n"; |
|
908 else |
|
909 octave_stdout << "\nhelp: `" << argv[i] |
|
910 << "' not found\n"; |
1140
|
911 } |
|
912 |
2095
|
913 additional_help_message (octave_stdout); |
1140
|
914 } |
|
915 |
4208
|
916 DEFCMD (help, args, , |
3332
|
917 "-*- texinfo -*-\n\ |
|
918 @deffn {Command} help\n\ |
|
919 Octave's @code{help} command can be used to print brief usage-style\n\ |
|
920 messages, or to display information directly from an on-line version of\n\ |
|
921 the printed manual, using the GNU Info browser. If invoked without any\n\ |
5794
|
922 arguments, @code{help} prints a list of all the available operators\n\ |
|
923 and functions. If the first argument is @code{-i}, the @code{help}\n\ |
|
924 command searches the index of the on-line version of this manual for\n\ |
|
925 the given topics.\n\ |
3168
|
926 \n\ |
3332
|
927 For example, the command @kbd{help help} prints a short message\n\ |
|
928 describing the @code{help} command, and @kbd{help -i help} starts the\n\ |
|
929 GNU Info browser at this node in the on-line version of the manual.\n\ |
|
930 \n\ |
|
931 Once the GNU Info browser is running, help for using it is available\n\ |
|
932 using the command @kbd{C-h}.\n\ |
5672
|
933 @seealso{doc, which, lookfor}\n\ |
3333
|
934 @end deffn") |
529
|
935 { |
2086
|
936 octave_value_list retval; |
529
|
937 |
1755
|
938 int argc = args.length () + 1; |
|
939 |
1968
|
940 string_vector argv = args.make_argv ("help"); |
1755
|
941 |
|
942 if (error_state) |
|
943 return retval; |
529
|
944 |
|
945 if (argc == 1) |
3014
|
946 simple_help (); |
529
|
947 else |
|
948 { |
1755
|
949 if (argv[1] == "-i") |
3014
|
950 help_from_info (argv, 2, argc); |
529
|
951 else |
3014
|
952 builtin_help (argc, argv); |
529
|
953 } |
|
954 |
|
955 return retval; |
|
956 } |
|
957 |
3355
|
958 static void |
3523
|
959 do_type (std::ostream& os, const std::string& name, bool pr_type_info, |
3355
|
960 bool quiet, bool pr_orig_txt) |
|
961 { |
|
962 symbol_record *sym_rec = lookup_by_name (name, 0); |
|
963 |
|
964 if (sym_rec && sym_rec->is_defined ()) |
3356
|
965 sym_rec->type (os, pr_type_info, quiet, pr_orig_txt); |
3355
|
966 else |
|
967 { |
3523
|
968 std::string ff = fcn_file_in_path (name); |
3355
|
969 |
|
970 if (! ff.empty ()) |
|
971 { |
3538
|
972 std::ifstream fs (ff.c_str (), std::ios::in); |
3355
|
973 |
|
974 if (fs) |
|
975 { |
|
976 if (pr_type_info && ! quiet) |
|
977 os << name << " is the script file: " << ff << "\n\n"; |
|
978 |
|
979 char ch; |
|
980 |
|
981 while (fs.get (ch)) |
|
982 os << ch; |
|
983 } |
|
984 else |
|
985 os << "unable to open `" << ff << "' for reading!\n"; |
|
986 } |
|
987 else |
|
988 error ("type: `%s' undefined", name.c_str ()); |
|
989 } |
|
990 } |
|
991 |
4208
|
992 DEFCMD (type, args, nargout, |
3361
|
993 "-*- texinfo -*-\n\ |
|
994 \n\ |
|
995 @deffn {Command} type options name @dots{}\n\ |
|
996 Display the definition of each @var{name} that refers to a function.\n\ |
|
997 \n\ |
|
998 Normally also displays if each @var{name} is user-defined or builtin;\n\ |
|
999 the @code{-q} option suppresses this behaviour.\n\ |
581
|
1000 \n\ |
3361
|
1001 Currently, Octave can only display functions that can be compiled\n\ |
|
1002 cleanly, because it uses its internal representation of the function to\n\ |
|
1003 recreate the program text.\n\ |
|
1004 \n\ |
|
1005 Comments are not displayed because Octave's parser currently discards\n\ |
|
1006 them as it converts the text of a function file to its internal\n\ |
|
1007 representation. This problem may be fixed in a future release.\n\ |
|
1008 @end deffn") |
581
|
1009 { |
3584
|
1010 octave_value retval; |
1588
|
1011 |
1755
|
1012 int argc = args.length () + 1; |
|
1013 |
1968
|
1014 string_vector argv = args.make_argv ("type"); |
1755
|
1015 |
3355
|
1016 if (! error_state) |
581
|
1017 { |
3355
|
1018 if (argc > 1) |
|
1019 { |
5775
|
1020 // FIXME -- we should really use getopt () |
2532
|
1021 |
3355
|
1022 bool quiet = false; |
|
1023 bool pr_orig_txt = true; |
2532
|
1024 |
3355
|
1025 int idx; |
581
|
1026 |
3355
|
1027 for (idx = 1; idx < argc; idx++) |
1281
|
1028 { |
3355
|
1029 if (argv[idx] == "-q" || argv[idx] == "-quiet") |
|
1030 quiet = true; |
|
1031 else if (argv[idx] == "-t" || argv[idx] == "-transformed") |
|
1032 pr_orig_txt = false; |
|
1033 else |
|
1034 break; |
1281
|
1035 } |
|
1036 |
3355
|
1037 if (idx < argc) |
|
1038 { |
5765
|
1039 std::ostringstream output_buf; |
581
|
1040 |
3355
|
1041 for (int i = idx; i < argc; i++) |
581
|
1042 { |
3523
|
1043 std::string id = argv[i]; |
2534
|
1044 |
3355
|
1045 if (nargout == 0) |
|
1046 do_type (octave_stdout, id, true, quiet, pr_orig_txt); |
|
1047 else |
|
1048 do_type (output_buf, id, false, quiet, pr_orig_txt); |
581
|
1049 |
3355
|
1050 if (error_state) |
|
1051 goto abort; |
581
|
1052 } |
|
1053 |
3584
|
1054 if (nargout != 0) |
5765
|
1055 retval = output_buf.str (); |
581
|
1056 } |
|
1057 else |
3355
|
1058 print_usage ("type"); |
|
1059 } |
|
1060 else |
|
1061 print_usage ("type"); |
|
1062 } |
3141
|
1063 |
3355
|
1064 abort: |
581
|
1065 |
|
1066 return retval; |
|
1067 } |
|
1068 |
3536
|
1069 static std::string |
3523
|
1070 do_which (const std::string& name) |
3355
|
1071 { |
3523
|
1072 std::string retval; |
3355
|
1073 |
|
1074 symbol_record *sym_rec = lookup_by_name (name, 0); |
|
1075 |
|
1076 if (sym_rec && sym_rec->is_defined ()) |
|
1077 retval = sym_rec->which (); |
|
1078 else |
|
1079 { |
3523
|
1080 std::string path = fcn_file_in_path (name); |
3355
|
1081 |
|
1082 if (! path.empty ()) |
|
1083 retval = path; |
|
1084 else |
|
1085 retval = "undefined"; |
|
1086 } |
|
1087 |
|
1088 return retval; |
|
1089 } |
|
1090 |
|
1091 static void |
3523
|
1092 do_which (std::ostream& os, const std::string& name) |
3355
|
1093 { |
|
1094 symbol_record *sym_rec = lookup_by_name (name, 0); |
|
1095 |
|
1096 if (sym_rec && sym_rec->is_defined ()) |
|
1097 sym_rec->which (os); |
|
1098 else |
|
1099 { |
3523
|
1100 std::string path = fcn_file_in_path (name); |
3355
|
1101 |
|
1102 if (! path.empty ()) |
|
1103 os << "which: `" << name << "' is the script file\n" |
|
1104 << path << "\n"; |
|
1105 else |
|
1106 os << "which: `" << name << "' is undefined\n"; |
|
1107 } |
|
1108 } |
|
1109 |
4208
|
1110 DEFCMD (which, args, nargout, |
3361
|
1111 "-*- texinfo -*-\n\ |
|
1112 @deffn {Command} which name @dots{}\n\ |
|
1113 Display the type of each @var{name}. If @var{name} is defined from a\n\ |
|
1114 function file, the full name of the file is also displayed.\n\ |
5667
|
1115 @seealso{help, lookfor}\n\ |
3361
|
1116 @end deffn") |
581
|
1117 { |
2086
|
1118 octave_value_list retval; |
581
|
1119 |
1968
|
1120 string_vector argv = args.make_argv ("which"); |
1755
|
1121 |
3355
|
1122 if (! error_state) |
|
1123 { |
|
1124 int argc = argv.length (); |
581
|
1125 |
|
1126 if (nargout > 0) |
|
1127 retval.resize (argc-1, Matrix ()); |
|
1128 |
3355
|
1129 if (argc > 1) |
581
|
1130 { |
3355
|
1131 for (int i = 1; i < argc; i++) |
581
|
1132 { |
3523
|
1133 std::string id = argv[i]; |
3141
|
1134 |
3355
|
1135 if (nargout == 0) |
|
1136 do_which (octave_stdout, id); |
581
|
1137 else |
3355
|
1138 retval(i-1) = do_which (id); |
581
|
1139 } |
|
1140 } |
3355
|
1141 else |
|
1142 print_usage (argv[0]); |
581
|
1143 } |
|
1144 |
|
1145 return retval; |
|
1146 } |
|
1147 |
5775
|
1148 // FIXME |
5447
|
1149 // This function attempts to find the first sentence of a help string, though |
|
1150 // given that the user can create the help in an arbitrary format, your |
|
1151 // success might vary.. it works much better with help string formated in |
|
1152 // texinfo. Using regex might make this function much simpler. |
|
1153 |
|
1154 std::string |
|
1155 first_help_sentence (const std::string& h, bool short_sentence = true) |
|
1156 { |
5738
|
1157 std::string retval; |
|
1158 |
5447
|
1159 size_t pos = 0; |
|
1160 |
|
1161 if (looks_like_texinfo (h, pos)) |
5592
|
1162 { |
|
1163 // Get the parsed help string. |
5447
|
1164 pos = 0; |
5765
|
1165 std::ostringstream os; |
5447
|
1166 display_help_text (os, h); |
|
1167 std::string h2 = os.str (); |
|
1168 |
|
1169 while (1) |
|
1170 { |
|
1171 // Skip leading whitespace and get new line |
|
1172 pos = h2.find_first_not_of ("\n\t ", pos); |
|
1173 |
|
1174 if (pos == NPOS) |
|
1175 break; |
|
1176 |
|
1177 size_t new_pos = h2.find_first_of ('\n', pos); |
|
1178 std::string line = h2.substr (pos, new_pos-pos); |
|
1179 |
|
1180 // Skip lines starting in "-" |
|
1181 if (line.find_first_of ('-') == 0) |
|
1182 { |
|
1183 pos = new_pos + 1; |
|
1184 continue; |
|
1185 } |
|
1186 |
|
1187 break; |
|
1188 } |
|
1189 |
|
1190 if (pos == NPOS) |
5738
|
1191 return retval; |
5447
|
1192 |
|
1193 // At start of real text. Get first line with the sentence |
|
1194 size_t new_pos = h2.find_first_of ('\n', pos); |
|
1195 std::string line = h2.substr (pos, new_pos-pos); |
|
1196 size_t dot_pos; |
|
1197 |
|
1198 while ((dot_pos = line.find_first_of ('.')) == NPOS) |
|
1199 { |
|
1200 // Trim trailing blanks on line |
|
1201 line.substr (0, line.find_last_not_of ("\n\t ") + 1); |
|
1202 |
|
1203 // Append next line |
|
1204 size_t tmp_pos = h2.find_first_not_of ("\n\t ", new_pos + 1); |
|
1205 if (tmp_pos == NPOS || h2.substr (tmp_pos, 1) == "\n") |
|
1206 break; |
|
1207 |
|
1208 new_pos = h2.find_first_of ('\n', tmp_pos); |
|
1209 std::string next = h2.substr (tmp_pos, new_pos-tmp_pos); |
|
1210 |
|
1211 if (short_sentence) |
|
1212 { |
|
1213 if ((tmp_pos = next.find_first_of ('.')) != NPOS) |
|
1214 { |
|
1215 line = line + " " + next; |
|
1216 dot_pos = line.find_first_of ('.'); |
|
1217 } |
|
1218 break; |
|
1219 } |
|
1220 else |
|
1221 line = line + " " + next; |
|
1222 } |
|
1223 |
|
1224 if (dot_pos == NPOS) |
5738
|
1225 retval = line; |
5447
|
1226 else |
5738
|
1227 retval = line.substr (0, dot_pos + 1); |
5447
|
1228 } |
|
1229 else |
|
1230 { |
|
1231 std::string _upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
|
1232 std::string _lower = "abcdefghijklmnopqrstuvwxyz"; |
|
1233 std::string _alpha = _upper + _lower + "_"; |
|
1234 std::string _alphanum = _alpha + "1234567890"; |
|
1235 pos = 0; |
|
1236 |
|
1237 while (1) |
|
1238 { |
|
1239 // Skip leading whitespace and get new line |
|
1240 pos = h.find_first_not_of ("\n\t ", pos); |
|
1241 |
|
1242 if (pos == NPOS) |
|
1243 break; |
|
1244 |
|
1245 size_t new_pos = h.find_first_of ('\n', pos); |
|
1246 std::string line = h.substr (pos, new_pos-pos); |
|
1247 |
|
1248 // Make a lower case copy to simplify some tests |
|
1249 std::string lower = line; |
5768
|
1250 std::transform (lower.begin (), lower.end (), lower.begin (), tolower); |
5447
|
1251 |
|
1252 // Skip lines starting in "-" or "Usage" |
|
1253 if (lower.find_first_of ('-') == 0 |
|
1254 || lower.substr (0, 5) == "usage") |
|
1255 { |
5592
|
1256 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1257 continue; |
|
1258 } |
|
1259 |
|
1260 size_t line_pos = 0; |
|
1261 size_t tmp_pos = 0; |
|
1262 |
|
1263 // chop " blah : " |
|
1264 tmp_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1265 (_alphanum, line_pos)); |
|
1266 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == ":") |
|
1267 line_pos = line.find_first_not_of ("\t ", tmp_pos + 1); |
|
1268 |
|
1269 if (line_pos == NPOS) |
|
1270 { |
5592
|
1271 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1272 continue; |
|
1273 } |
|
1274 |
|
1275 // chop " function " |
|
1276 if (lower.substr (line_pos, 8) == "function") |
|
1277 line_pos = line.find_first_not_of ("\t ", line_pos + 8); |
|
1278 |
|
1279 if (line_pos == NPOS) |
|
1280 { |
5592
|
1281 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1282 continue; |
|
1283 } |
|
1284 |
|
1285 // chop " [a,b] = " |
|
1286 if (line.substr (line_pos, 1) == "[") |
|
1287 { |
|
1288 tmp_pos = line.find_first_not_of |
|
1289 ("\t ", line.find_first_of ("]", line_pos) + 1); |
|
1290 |
|
1291 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "=") |
|
1292 line_pos = line.find_first_not_of ("\t ",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 " a = " |
|
1302 if (line.find_first_not_of (_alpha, line_pos) != line_pos) |
|
1303 { |
|
1304 tmp_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1305 (_alphanum, line_pos)); |
|
1306 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "=") |
|
1307 line_pos = line.find_first_not_of ("\t ", tmp_pos + 1); |
|
1308 } |
|
1309 |
|
1310 if (line_pos == NPOS) |
|
1311 { |
|
1312 pos = new_pos + 1; |
|
1313 continue; |
|
1314 } |
|
1315 |
|
1316 // chop " f(x) " |
|
1317 if (line.find_first_not_of (_alpha, line_pos) != line_pos) |
|
1318 { |
|
1319 tmp_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1320 (_alphanum, line_pos)); |
|
1321 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "(") |
|
1322 line_pos = line.find_first_not_of ("\t ", line.find_first_of |
|
1323 (")", tmp_pos) + 1); |
|
1324 } |
|
1325 |
|
1326 if (line_pos == NPOS) |
|
1327 { |
5592
|
1328 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1329 continue; |
|
1330 } |
|
1331 |
|
1332 // chop " ; " |
|
1333 if (line.substr (line_pos, 1) == ":" |
|
1334 || line.substr (line_pos, 1) == ";") |
|
1335 line_pos = line.find_first_not_of ("\t ", line_pos + 1); |
|
1336 |
|
1337 if (line_pos == NPOS) |
|
1338 { |
5592
|
1339 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1340 continue; |
|
1341 } |
|
1342 |
|
1343 // chop " BLAH " |
|
1344 if (line.length () > line_pos + 2 |
|
1345 && line.find_first_of (_upper, line_pos) == line_pos |
|
1346 && line.find_first_of (_upper, line_pos+1) == line_pos + 1) |
|
1347 line_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1348 (_upper + "0123456789_", line_pos)); |
|
1349 |
|
1350 if (line_pos == NPOS) |
|
1351 { |
5592
|
1352 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1353 continue; |
|
1354 } |
|
1355 |
|
1356 // chop " blah --- " |
|
1357 tmp_pos = line.find_first_not_of ("\t ", line.find_first_not_of |
|
1358 (_alphanum, line_pos)); |
|
1359 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "-") |
|
1360 { |
|
1361 tmp_pos = line.find_first_not_of ("-", tmp_pos); |
|
1362 if (line.substr (tmp_pos, 1) == " " |
|
1363 || line.substr (tmp_pos, 1) == "\t") |
|
1364 line_pos = line.find_first_not_of ("\t ", tmp_pos); |
|
1365 } |
|
1366 |
|
1367 if (line_pos == NPOS) |
|
1368 { |
5592
|
1369 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1370 continue; |
|
1371 } |
|
1372 |
|
1373 // chop " blah <TAB> " |
|
1374 if (line.find_first_not_of (_alpha, line_pos) != line_pos) |
|
1375 { |
|
1376 tmp_pos = line.find_first_not_of (" ", line.find_first_not_of |
|
1377 (_alphanum, line_pos)); |
|
1378 if (tmp_pos != NPOS && line.substr (tmp_pos, 1) == "\t") |
|
1379 line_pos = line.find_first_not_of ("\t ", line.find_first_of |
|
1380 (")", tmp_pos) + 1); |
|
1381 } |
|
1382 |
|
1383 if (line_pos == NPOS) |
|
1384 { |
5592
|
1385 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1386 continue; |
|
1387 } |
|
1388 |
|
1389 // chop " blah " |
|
1390 if (line.find_first_not_of (_alpha, line_pos) != line_pos) |
|
1391 { |
|
1392 tmp_pos = line.find_first_not_of (_alphanum, line_pos); |
|
1393 |
|
1394 if (tmp_pos != NPOS |
|
1395 && (line.substr (tmp_pos, 2) == "\t\t" |
|
1396 || line.substr (tmp_pos, 2) == "\t " |
|
1397 || line.substr (tmp_pos, 2) == " \t" |
|
1398 || line.substr (tmp_pos, 2) == " ")) |
|
1399 line_pos = line.find_first_not_of ("\t ", tmp_pos); |
|
1400 } |
|
1401 |
|
1402 if (line_pos == NPOS) |
|
1403 { |
5592
|
1404 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1405 continue; |
|
1406 } |
|
1407 |
|
1408 // skip blah \n or \n blah |
|
1409 // skip blank line |
|
1410 // skip "# !/usr/bin/octave" |
|
1411 if ((line.substr (line_pos , 2) == "or" |
|
1412 && line.find_first_not_of ("\n\t ", line_pos + 2) == NPOS) |
|
1413 || line.find_first_not_of ("\n\t ", line_pos) == NPOS |
|
1414 || line.substr (line_pos, 2) == "!/") |
|
1415 { |
5592
|
1416 pos = (new_pos == NPOS ? NPOS : new_pos + 1); |
5447
|
1417 continue; |
|
1418 } |
|
1419 |
|
1420 // Got the start of first sentence, break. |
|
1421 pos = pos + line_pos; |
|
1422 break; |
|
1423 } |
|
1424 |
|
1425 if (pos == NPOS) |
5738
|
1426 return retval; |
5447
|
1427 |
|
1428 // At start of real text. Get first line with the sentence |
|
1429 size_t new_pos = h.find_first_of ('\n', pos); |
|
1430 std::string line = h.substr (pos, new_pos-pos); |
|
1431 size_t dot_pos; |
|
1432 |
|
1433 while ((dot_pos = line.find_first_of ('.')) == NPOS) |
|
1434 { |
|
1435 // Trim trailing blanks on line |
|
1436 line = line.substr (0, line.find_last_not_of ("\n\t ") + 1); |
|
1437 |
|
1438 // Append next line |
|
1439 size_t tmp_pos = h.find_first_not_of ("\t ", new_pos + 1); |
|
1440 if (tmp_pos == NPOS || h.substr (tmp_pos, 1) == "\n") |
|
1441 break; |
|
1442 |
|
1443 new_pos = h.find_first_of ('\n', tmp_pos); |
|
1444 std::string next = h.substr (tmp_pos, new_pos-tmp_pos); |
|
1445 |
|
1446 if (short_sentence) |
|
1447 { |
|
1448 // Only add the next line if it terminates the sentence, then break |
|
1449 if ((tmp_pos = next.find_first_of ('.')) != NPOS) |
|
1450 { |
|
1451 line = line + " " + next; |
|
1452 dot_pos = line.find_first_of ('.'); |
|
1453 } |
|
1454 break; |
|
1455 } |
|
1456 else |
|
1457 line = line + " " + next; |
|
1458 } |
|
1459 |
|
1460 if (dot_pos == NPOS) |
5738
|
1461 retval = line; |
5447
|
1462 else |
5738
|
1463 retval = line.substr (0, dot_pos + 1); |
5447
|
1464 } |
5738
|
1465 |
|
1466 return retval; |
5447
|
1467 } |
|
1468 |
|
1469 static void |
|
1470 print_lookfor (const std::string& name, const std::string& line) |
|
1471 { |
|
1472 const size_t deflen = 20; |
|
1473 |
|
1474 size_t max_width = command_editor::terminal_cols () - deflen; |
|
1475 if (max_width < deflen) |
|
1476 max_width = deflen; |
|
1477 |
|
1478 size_t name_len = name.length (); |
|
1479 |
|
1480 size_t width = max_width; |
|
1481 if (name_len > deflen) |
|
1482 { |
|
1483 width = command_editor::terminal_cols () - name_len; |
|
1484 if (width < deflen) |
|
1485 width = deflen; |
|
1486 } |
|
1487 |
|
1488 size_t pad_len = deflen > name_len ? deflen - name_len + 1 : 1; |
|
1489 octave_stdout << name << std::string (pad_len, ' '); |
|
1490 |
|
1491 size_t pos = 0; |
|
1492 |
|
1493 while (1) |
|
1494 { |
|
1495 size_t new_pos = line.find_first_of ("\n\t ", pos); |
|
1496 size_t end_pos = new_pos; |
|
1497 |
|
1498 if (line.length () - pos < width) |
|
1499 new_pos = end_pos = NPOS; |
|
1500 else |
|
1501 while (new_pos != NPOS && new_pos - pos < width) |
|
1502 { |
|
1503 end_pos = new_pos; |
|
1504 new_pos = line.find_first_of ("\n\t ", new_pos + 1); |
|
1505 } |
|
1506 |
|
1507 octave_stdout << line.substr (pos, end_pos-pos) << std::endl; |
|
1508 |
|
1509 if (end_pos == NPOS) |
|
1510 break; |
|
1511 |
|
1512 pos = end_pos + 1; |
|
1513 width = max_width; |
|
1514 octave_stdout << std::string (deflen + 1, ' '); |
|
1515 } |
|
1516 } |
|
1517 |
|
1518 DEFCMD (lookfor, args, nargout, |
|
1519 "-*- texinfo -*-\n\ |
|
1520 @deffn {Command} lookfor @var{str}\n\ |
|
1521 @deffnx {Command} lookfor -all @var{str}\n\ |
|
1522 @deffnx {Function} {[@var{fun}, @var{helpstring}] = } lookfor (@var{str})\n\ |
|
1523 @deffnx {Function} {[@var{fun}, @var{helpstring}] = } lookfor ('-all', @var{str})\n\ |
|
1524 Search for the string @var{str} in all of the functions found in\n\ |
|
1525 @var{LOADPATH}. By default @code{lookfor} searchs for @var{str} in the\n\ |
|
1526 first sentence of the help string of each function found. The entire\n\ |
|
1527 help string of each function found of @var{LOADPATH} can be search if\n\ |
|
1528 the '-all' argument is supplied. All searches are case insensitive.\n\ |
|
1529 \n\ |
|
1530 Called with no output arguments, @code{lookfor} prints the list of matching\n\ |
|
1531 functions to the terminal. Otherwise the output arguments @var{fun} and\n\ |
|
1532 @var{helpstring} define the matching functions and the first sentence of\n\ |
|
1533 each of their help strings.\n\ |
|
1534 \n\ |
|
1535 Note that the ability of @code{lookfor} to correctly identify the first\n\ |
|
1536 sentence of the help of the functions is dependent on the format of the\n\ |
|
1537 functions help. All of the functions in octave itself will correctly\n\ |
|
1538 find the first sentence, but the same can not be guaranteed for other\n\ |
|
1539 functions. Therefore the use of the '-all' argument might be necessary\n\ |
|
1540 to find related functions that are not part of octave.\n\ |
5667
|
1541 @seealso{help, which}\n\ |
5642
|
1542 @end deffn") |
5447
|
1543 { |
|
1544 octave_value_list retval; |
|
1545 int nargin = args.length (); |
|
1546 bool first_sentence_only = true; |
|
1547 |
|
1548 if (nargin != 1 && nargin != 2) |
|
1549 { |
|
1550 usage ("lookfor"); |
|
1551 return retval; |
|
1552 } |
|
1553 |
|
1554 string_vector ret[2]; |
|
1555 |
|
1556 std::string txt; |
|
1557 |
|
1558 if (args(0).is_string ()) |
|
1559 { |
|
1560 txt = args(0).string_value (); |
|
1561 |
|
1562 if (nargin == 2) |
|
1563 { |
|
1564 if (args(1).is_string ()) |
|
1565 { |
|
1566 std::string tmp = args(1).string_value (); |
|
1567 |
|
1568 if (txt.substr(0,1) == "-") |
|
1569 { |
|
1570 txt = tmp; |
|
1571 tmp = args(0).string_value (); |
|
1572 } |
|
1573 |
|
1574 if (tmp == "-all") |
|
1575 first_sentence_only = false; |
|
1576 else |
|
1577 error ("lookfor: unrecognized option argument"); |
|
1578 } |
|
1579 else |
|
1580 error ("lookfor: arguments must be a string"); |
|
1581 } |
|
1582 } |
|
1583 else |
|
1584 error ("lookfor: argument must be a string"); |
|
1585 |
|
1586 if (!error_state) |
|
1587 { |
|
1588 // All tests in lower case |
5768
|
1589 std::transform (txt.begin (), txt.end (), txt.begin (), tolower); |
5447
|
1590 |
|
1591 help_list *ptr = keyword_help (); |
|
1592 while (ptr->name) |
|
1593 { |
|
1594 std::string name = ptr->name; |
|
1595 std::string h = ptr->help; |
|
1596 |
5592
|
1597 if (name.find (txt) != NPOS) |
5447
|
1598 { |
|
1599 if (nargout) |
|
1600 { |
|
1601 ret[0].append (name); |
|
1602 ret[1].append (first_help_sentence (h)); |
|
1603 } |
|
1604 else |
|
1605 print_lookfor (name, first_help_sentence (h)); |
|
1606 } |
5592
|
1607 else |
|
1608 { |
|
1609 std::string s; |
|
1610 |
|
1611 if (first_sentence_only) |
|
1612 s = first_help_sentence (h); |
|
1613 else |
|
1614 s = h; |
|
1615 |
5768
|
1616 std::transform (s.begin (), s.end (), s.begin (), tolower); |
5592
|
1617 |
|
1618 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1619 { |
|
1620 if (nargout) |
|
1621 { |
|
1622 ret[0].append (name); |
|
1623 ret[1].append (first_help_sentence (h)); |
|
1624 } |
|
1625 else |
|
1626 print_lookfor (name, first_help_sentence (h)); |
|
1627 } |
|
1628 } |
5447
|
1629 |
|
1630 OCTAVE_QUIT; |
|
1631 |
|
1632 ptr++; |
|
1633 } |
|
1634 |
|
1635 ptr = operator_help (); |
|
1636 while (ptr->name) |
|
1637 { |
|
1638 std::string name = ptr->name; |
|
1639 std::string h = ptr->help; |
|
1640 |
5592
|
1641 if (name.find (txt) != NPOS) |
5447
|
1642 { |
|
1643 if (nargout) |
|
1644 { |
|
1645 ret[0].append (name); |
|
1646 ret[1].append (first_help_sentence (h)); |
|
1647 } |
|
1648 else |
|
1649 print_lookfor (name, first_help_sentence (h)); |
|
1650 } |
5592
|
1651 else |
|
1652 { |
|
1653 std::string s; |
|
1654 if (first_sentence_only) |
|
1655 s = first_help_sentence (h); |
|
1656 else |
|
1657 s = h; |
|
1658 |
5768
|
1659 std::transform (s.begin (), s.end (), s.begin (), tolower); |
5592
|
1660 |
|
1661 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1662 { |
|
1663 if (nargout) |
|
1664 { |
|
1665 ret[0].append (name); |
|
1666 ret[1].append (first_help_sentence (h)); |
|
1667 } |
|
1668 else |
|
1669 print_lookfor (name, first_help_sentence (h)); |
|
1670 } |
|
1671 } |
5447
|
1672 |
|
1673 OCTAVE_QUIT; |
|
1674 |
|
1675 ptr++; |
|
1676 } |
|
1677 |
|
1678 // Check the symbol record table |
|
1679 string_vector names |
|
1680 = fbi_sym_tab->name_list (string_vector (), true); |
|
1681 |
|
1682 for (octave_idx_type i = 0; i < names.length (); i++) |
|
1683 { |
|
1684 std::string name = names (i); |
|
1685 |
|
1686 OCTAVE_QUIT; |
|
1687 |
|
1688 symbol_record *sr = lookup_by_name (name, 0); |
5738
|
1689 if (sr && sr->is_defined () |
|
1690 && sr->type_name () != "overloaded function") |
5447
|
1691 { |
|
1692 std::string h = sr->help (); |
|
1693 |
5592
|
1694 if (name.find (txt) != NPOS) |
5447
|
1695 { |
|
1696 if (nargout) |
|
1697 { |
|
1698 ret[0].append (name); |
|
1699 ret[1].append (first_help_sentence (h)); |
|
1700 } |
|
1701 else |
|
1702 print_lookfor (name, first_help_sentence (h)); |
|
1703 } |
5592
|
1704 else |
|
1705 { |
|
1706 std::string s; |
|
1707 |
|
1708 if (first_sentence_only) |
|
1709 s = first_help_sentence (h); |
|
1710 else |
|
1711 s = h; |
|
1712 |
5768
|
1713 std::transform (s.begin (), s.end (), s.begin (), tolower); |
5592
|
1714 |
|
1715 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1716 { |
|
1717 if (nargout) |
|
1718 { |
|
1719 ret[0].append (name); |
|
1720 ret[1].append (first_help_sentence (h)); |
|
1721 } |
|
1722 else |
|
1723 print_lookfor (name, first_help_sentence (h)); |
|
1724 } |
|
1725 } |
5447
|
1726 } |
|
1727 } |
|
1728 |
|
1729 string_vector dirs = Vload_path_dir_path.all_directories (); |
|
1730 |
|
1731 int len = dirs.length (); |
|
1732 |
|
1733 for (int i = 0; i < len; i++) |
|
1734 { |
|
1735 names = octave_fcn_file_name_cache::list (dirs[i]); |
|
1736 |
|
1737 if (! names.empty ()) |
|
1738 { |
|
1739 for (int j = 0; j < names.length (); j++) |
|
1740 { |
|
1741 std::string name = names (j); |
|
1742 |
|
1743 OCTAVE_QUIT; |
|
1744 |
|
1745 // Strip extension |
|
1746 size_t l = name.length (); |
|
1747 if (l > 4 && name.substr (l-4) == ".oct") |
|
1748 name = name.substr (0, l - 4); |
|
1749 else if (l > 2 && name.substr (l-2) == ".m") |
|
1750 name = name.substr (0, l - 2); |
|
1751 else |
|
1752 continue; |
|
1753 |
|
1754 // Check if already in symbol table |
|
1755 symbol_record *sr = fbi_sym_tab->lookup (name); |
|
1756 |
|
1757 if (!sr) |
|
1758 { |
|
1759 // Check if this version is first in the path |
|
1760 string_vector tmp (2); |
|
1761 tmp(0) = name + ".oct"; |
|
1762 tmp(1) = name + ".m"; |
|
1763 std::string file_name = |
|
1764 Vload_path_dir_path.find_first_of (tmp); |
|
1765 |
|
1766 if (file_name == dirs[i] + tmp(0) |
|
1767 || file_name == dirs[i] + tmp(1)) |
|
1768 { |
5484
|
1769 bool symbol_found; |
|
1770 |
5592
|
1771 std::string h; |
|
1772 if (file_name == dirs[i] + tmp(0)) |
|
1773 { |
|
1774 // oct-file. Must load to get help |
|
1775 sr = lookup_by_name (name, false); |
5447
|
1776 |
5592
|
1777 if (sr && sr->is_defined ()) |
|
1778 h = sr->help (); |
|
1779 } |
5447
|
1780 else |
5592
|
1781 h = get_help_from_file (file_name, symbol_found); |
5447
|
1782 |
5592
|
1783 if (name.find (txt) != NPOS) |
5447
|
1784 { |
|
1785 if (nargout) |
|
1786 { |
|
1787 ret[0].append (name); |
|
1788 ret[1].append (first_help_sentence (h)); |
|
1789 } |
|
1790 else |
|
1791 print_lookfor (name, first_help_sentence (h)); |
|
1792 } |
5592
|
1793 else |
|
1794 { |
|
1795 std::string s; |
|
1796 if (first_sentence_only) |
|
1797 s = first_help_sentence (h); |
|
1798 else |
|
1799 s = h; |
|
1800 |
5768
|
1801 std::transform (s.begin (), s.end (), s.begin (), tolower); |
5592
|
1802 |
|
1803 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1804 { |
|
1805 if (nargout) |
|
1806 { |
|
1807 ret[0].append (name); |
|
1808 ret[1].append (first_help_sentence (h)); |
|
1809 } |
|
1810 else |
|
1811 print_lookfor (name, first_help_sentence (h)); |
|
1812 } |
|
1813 } |
|
1814 } |
|
1815 } |
|
1816 |
|
1817 // Check if this function has autoloaded functions attached to it |
|
1818 std::string file_name = Vload_path_dir_path.find_first_of (names(j)); |
|
1819 string_vector autoload_fcns = reverse_lookup_autoload (file_name); |
|
1820 |
|
1821 if (! autoload_fcns.empty ()) |
|
1822 { |
|
1823 for (int k = 0; k < autoload_fcns.length (); k++) |
|
1824 { |
|
1825 std::string aname = autoload_fcns (k); |
|
1826 |
|
1827 // Check if already in symbol table |
|
1828 sr = fbi_sym_tab->lookup (aname); |
|
1829 |
|
1830 if (!sr) |
|
1831 { |
|
1832 // Must load to get help |
5738
|
1833 sr = lookup_by_name (aname, false); |
5592
|
1834 |
|
1835 std::string h; |
|
1836 if (sr && sr->is_defined ()) |
|
1837 h = sr->help (); |
|
1838 |
|
1839 if (aname.find (txt) != NPOS) |
|
1840 { |
|
1841 if (nargout) |
|
1842 { |
|
1843 ret[0].append (aname); |
|
1844 ret[1].append (first_help_sentence (h)); |
|
1845 } |
|
1846 else |
|
1847 print_lookfor (aname, first_help_sentence (h)); |
|
1848 } |
|
1849 else |
|
1850 { |
|
1851 std::string s; |
|
1852 if (first_sentence_only) |
|
1853 s = first_help_sentence (h); |
|
1854 else |
|
1855 s = h; |
|
1856 |
5768
|
1857 std::transform (s.begin (), s.end (), s.begin (), |
5592
|
1858 tolower); |
|
1859 |
|
1860 if (s.length () > 0 && s.find (txt) != NPOS) |
|
1861 { |
|
1862 if (nargout) |
|
1863 { |
|
1864 ret[0].append (aname); |
|
1865 ret[1].append (first_help_sentence (h)); |
|
1866 } |
|
1867 else |
|
1868 print_lookfor (aname, first_help_sentence (h)); |
|
1869 } |
|
1870 } |
|
1871 } |
5447
|
1872 } |
|
1873 } |
|
1874 } |
|
1875 } |
|
1876 } |
|
1877 |
|
1878 if (nargout != 0) |
|
1879 { |
|
1880 retval (1) = ret[1]; |
|
1881 retval (0) = ret[0]; |
|
1882 } |
|
1883 } |
|
1884 else |
|
1885 { |
|
1886 error ("lookfor: argument must be a string"); |
|
1887 } |
|
1888 |
|
1889 return retval; |
|
1890 } |
|
1891 |
5794
|
1892 DEFUN (info_file, args, nargout, |
|
1893 "-*- texinfo -*-\n\ |
|
1894 @deftypefn {Built-in Function} {@var{val} =} info_file ()\n\ |
|
1895 @deftypefnx {Built-in Function} {@var{old_val} =} info_file (@var{new_val})\n\ |
|
1896 Query or set the internal variable that specifies the name of the\n\ |
|
1897 Octave info file. The default value is\n\ |
|
1898 @code{\"@var{octave-home}/info/octave.info\"}, in\n\ |
|
1899 which @var{octave-home} is the directory where all of Octave is installed.\n\ |
|
1900 @seealso{info_program, doc, help, makeinfo_program}\n\ |
|
1901 @end deftypefn") |
2202
|
1902 { |
5794
|
1903 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_file); |
2202
|
1904 } |
|
1905 |
5794
|
1906 DEFUN (info_program, args, nargout, |
|
1907 "-*- texinfo -*-\n\ |
|
1908 @deftypefn {Built-in Function} {@var{val} =} info_program ()\n\ |
|
1909 @deftypefnx {Built-in Function} {@var{old_val} =} info_program (@var{new_val})\n\ |
|
1910 Query or set the internal variable that specifies the name of the\n\ |
|
1911 info program to run. The default initial value is\n\ |
3686
|
1912 @code{\"@var{octave-home}/libexec/octave/@var{version}/exec/@var{arch}/info\"}\n\ |
|
1913 in which @var{octave-home} is the directory where all of Octave is\n\ |
|
1914 installed, @var{version} is the Octave version number, and @var{arch}\n\ |
|
1915 is the system type (for example, @code{i686-pc-linux-gnu}). The\n\ |
|
1916 default initial value may be overridden by the environment variable\n\ |
|
1917 @code{OCTAVE_INFO_PROGRAM}, or the command line argument\n\ |
5794
|
1918 @code{--info-program NAME}.\n\ |
|
1919 @seealso{info_file, doc, help, makeinfo_program}\n\ |
|
1920 @end deftypefn") |
|
1921 { |
|
1922 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_program); |
|
1923 } |
3686
|
1924 |
5794
|
1925 DEFUN (makeinfo_program, args, nargout, |
|
1926 "-*- texinfo -*-\n\ |
|
1927 @deftypefn {Built-in Function} {@var{val} =} makeinfo_program ()\n\ |
|
1928 @deftypefnx {Built-in Function} {@var{old_val} =} makeinfo_program (@var{new_val})\n\ |
|
1929 Query or set the internal variable that specifies the name of the\n\ |
|
1930 makeinfo program that Octave runs to format help text containing\n\ |
|
1931 Texinfo markup commands. The default initial value is @code{\"makeinfo\"}.\n\ |
|
1932 @seealso{info_file, info_program, doc, help}\n\ |
|
1933 @end deftypefn") |
|
1934 { |
|
1935 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (makeinfo_program); |
|
1936 } |
2202
|
1937 |
5794
|
1938 DEFUN (suppress_verbose_help_message, args, nargout, |
|
1939 "-*- texinfo -*-\n\ |
|
1940 @deftypefn {Built-in Function} {@var{val} =} suppress_verbose_help_message ()\n\ |
|
1941 @deftypefnx {Built-in Function} {@var{old_val} =} suppress_verbose_help_message (@var{new_val})\n\ |
|
1942 Query or set the internal vaiable that controls whether Octave\n\ |
|
1943 will add additional help information to the end of the output from\n\ |
3332
|
1944 the @code{help} command and usage messages for built-in commands.\n\ |
5794
|
1945 @end deftypefn") |
|
1946 { |
|
1947 return SET_INTERNAL_VARIABLE (suppress_verbose_help_message); |
2189
|
1948 } |
|
1949 |
1
|
1950 /* |
|
1951 ;;; Local Variables: *** |
|
1952 ;;; mode: C++ *** |
|
1953 ;;; End: *** |
|
1954 */ |