1797
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1797
|
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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include <cstring> |
|
28 |
3504
|
29 #include <iostream> |
|
30 #include <strstream> |
2926
|
31 #include <string> |
|
32 |
|
33 #include "cmd-edit.h" |
|
34 #include "cmd-hist.h" |
|
35 #include "lo-error.h" |
|
36 #include "str-vec.h" |
|
37 |
|
38 command_history *command_history::instance = 0; |
|
39 |
|
40 #if defined (USE_READLINE) |
|
41 |
|
42 #include <cstdlib> |
|
43 |
3503
|
44 #include <strstream> |
1797
|
45 |
2444
|
46 #ifdef HAVE_FCNTL_H |
1797
|
47 #include <fcntl.h> |
2444
|
48 #endif |
1797
|
49 |
|
50 #ifdef HAVE_UNISTD_H |
2443
|
51 #ifdef HAVE_SYS_TYPES_H |
1797
|
52 #include <sys/types.h> |
2443
|
53 #endif |
1797
|
54 #include <unistd.h> |
|
55 #endif |
|
56 |
|
57 #include <readline/history.h> |
|
58 |
2926
|
59 #include "file-stat.h" |
1797
|
60 |
2926
|
61 class |
|
62 gnu_history : public command_history |
1797
|
63 { |
2926
|
64 public: |
|
65 |
|
66 gnu_history (void) |
|
67 : command_history (), mark (0) { } |
|
68 |
|
69 ~gnu_history (void) { } |
|
70 |
3504
|
71 void do_add (const std::string&); |
2926
|
72 |
|
73 void do_remove (int); |
1797
|
74 |
2926
|
75 int do_where (void); |
|
76 |
|
77 int do_length (void); |
|
78 |
|
79 int do_max_input_history (void); |
|
80 |
|
81 int do_base (void); |
|
82 |
|
83 int do_current_number (void); |
|
84 |
|
85 void do_stifle (int); |
1797
|
86 |
2926
|
87 int do_unstifle (void); |
|
88 |
|
89 int do_is_stifled (void); |
|
90 |
|
91 void do_set_mark (int); |
1797
|
92 |
2926
|
93 void do_goto_mark (void); |
|
94 |
3504
|
95 void do_read (const std::string&, bool); |
1797
|
96 |
3504
|
97 void do_read_range (const std::string&, int, int, bool); |
1797
|
98 |
3504
|
99 void do_write (const std::string&); |
1797
|
100 |
3504
|
101 void do_append (const std::string&); |
2926
|
102 |
3504
|
103 void do_truncate_file (const std::string&, int); |
2926
|
104 |
|
105 string_vector do_list (int, bool); |
|
106 |
3504
|
107 std::string do_get_entry (int); |
1797
|
108 |
3504
|
109 void do_replace_entry (int, const std::string&); |
2926
|
110 |
3504
|
111 void do_clean_up_and_save (const std::string&, int); |
1797
|
112 |
2926
|
113 private: |
|
114 |
|
115 int mark; |
|
116 }; |
1797
|
117 |
|
118 void |
3504
|
119 gnu_history::do_add (const std::string& s) |
1797
|
120 { |
2926
|
121 if (! do_ignoring_entries ()) |
1797
|
122 { |
2512
|
123 if (s.empty () |
|
124 || (s.length () == 1 && (s[0] == '\r' || s[0] == '\n'))) |
|
125 return; |
|
126 |
2470
|
127 ::add_history (s.c_str ()); |
2926
|
128 |
1797
|
129 lines_this_session++; |
|
130 } |
|
131 } |
|
132 |
|
133 void |
2926
|
134 gnu_history::do_remove (int n) |
1797
|
135 { |
2470
|
136 HIST_ENTRY *discard = ::remove_history (n); |
1797
|
137 |
|
138 if (discard) |
|
139 { |
|
140 if (discard->line) |
2470
|
141 ::free (discard->line); |
1797
|
142 |
2470
|
143 ::free (discard); |
1797
|
144 } |
|
145 } |
|
146 |
|
147 int |
2926
|
148 gnu_history::do_where (void) |
1797
|
149 { |
2470
|
150 return ::where_history (); |
1797
|
151 } |
|
152 |
|
153 int |
2926
|
154 gnu_history::do_length (void) |
|
155 { |
|
156 return ::history_length; |
|
157 } |
|
158 |
|
159 int |
|
160 gnu_history::do_max_input_history (void) |
|
161 { |
|
162 return ::max_input_history; |
|
163 } |
|
164 |
|
165 int |
|
166 gnu_history::do_base (void) |
1797
|
167 { |
2470
|
168 return ::history_base; |
1797
|
169 } |
|
170 |
|
171 int |
2926
|
172 gnu_history::do_current_number (void) |
1797
|
173 { |
2926
|
174 return (xsize > 0) ? do_base () + do_where () : -1; |
1797
|
175 } |
|
176 |
|
177 void |
2926
|
178 gnu_history::do_stifle (int n) |
1797
|
179 { |
2470
|
180 ::stifle_history (n); |
1797
|
181 } |
|
182 |
|
183 int |
2926
|
184 gnu_history::do_unstifle (void) |
1797
|
185 { |
2470
|
186 return ::unstifle_history (); |
1797
|
187 } |
|
188 |
|
189 int |
2926
|
190 gnu_history::do_is_stifled (void) |
1797
|
191 { |
2470
|
192 return ::history_is_stifled (); |
1797
|
193 } |
|
194 |
|
195 void |
2926
|
196 gnu_history::do_set_mark (int n) |
2658
|
197 { |
2926
|
198 mark = n; |
2658
|
199 } |
|
200 |
|
201 void |
2926
|
202 gnu_history::do_goto_mark (void) |
|
203 { |
|
204 HIST_ENTRY *h; |
|
205 |
|
206 if (mark) |
|
207 { |
|
208 if (history_set_pos (mark)) |
|
209 { |
|
210 h = ::current_history (); |
|
211 |
|
212 if (h) |
|
213 { |
|
214 command_editor::insert_text (h->line); |
|
215 |
|
216 command_editor::clear_undo_list (); |
|
217 } |
|
218 } |
|
219 } |
|
220 |
|
221 mark = 0; |
|
222 |
|
223 // XXX FIXME XXX -- for operate_and_get_next. |
|
224 command_editor::restore_startup_hook (); |
|
225 } |
|
226 |
|
227 void |
3504
|
228 gnu_history::do_read (const std::string& f, bool must_exist) |
1797
|
229 { |
|
230 if (! f.empty ()) |
|
231 { |
2470
|
232 int status = ::read_history (f.c_str ()); |
1797
|
233 |
2658
|
234 if (status != 0 && must_exist) |
1797
|
235 error (status); |
|
236 else |
2658
|
237 { |
2926
|
238 lines_in_file = do_where (); |
2658
|
239 |
|
240 ::using_history (); |
|
241 } |
1797
|
242 } |
|
243 else |
2926
|
244 error ("gnu_history::read: missing file name"); |
1797
|
245 } |
|
246 |
2659
|
247 void |
3504
|
248 gnu_history::do_read_range (const std::string& f, int from, int to, |
2926
|
249 bool must_exist) |
1797
|
250 { |
|
251 if (from < 0) |
|
252 from = lines_in_file; |
|
253 |
|
254 if (! f.empty ()) |
|
255 { |
2470
|
256 int status = ::read_history_range (f.c_str (), from, to); |
1797
|
257 |
2658
|
258 if (status != 0 && must_exist) |
1797
|
259 error (status); |
|
260 else |
|
261 { |
2926
|
262 lines_in_file = do_where (); |
2658
|
263 |
2470
|
264 ::using_history (); |
1797
|
265 } |
|
266 } |
|
267 else |
2926
|
268 error ("gnu_history::read_range: missing file name"); |
1797
|
269 } |
|
270 |
|
271 void |
3504
|
272 gnu_history::do_write (const std::string& f_arg) |
1797
|
273 { |
3504
|
274 std::string f = f_arg; |
1797
|
275 |
|
276 if (f.empty ()) |
|
277 f = xfile; |
|
278 |
|
279 if (! f.empty ()) |
|
280 { |
2470
|
281 int status = ::write_history (f.c_str ()); |
1797
|
282 |
|
283 if (status != 0) |
|
284 error (status); |
|
285 } |
|
286 else |
2926
|
287 error ("gnu_history::write: missing file name"); |
1797
|
288 } |
|
289 |
|
290 void |
3504
|
291 gnu_history::do_append (const std::string& f_arg) |
1797
|
292 { |
|
293 if (lines_this_session) |
|
294 { |
2926
|
295 if (lines_this_session < do_where ()) |
1797
|
296 { |
|
297 // Create file if it doesn't already exist. |
|
298 |
3504
|
299 std::string f = f_arg; |
1797
|
300 |
|
301 if (f.empty ()) |
|
302 f = xfile; |
|
303 |
|
304 if (! f.empty ()) |
|
305 { |
|
306 file_stat fs (f); |
|
307 |
|
308 if (! fs) |
|
309 { |
|
310 int tem; |
|
311 |
|
312 tem = open (f.c_str (), O_CREAT, 0666); |
|
313 close (tem); |
|
314 } |
|
315 |
2470
|
316 int status = ::append_history (lines_this_session, f.c_str ()); |
1797
|
317 |
|
318 if (status != 0) |
|
319 error (status); |
|
320 else |
|
321 lines_in_file += lines_this_session; |
|
322 |
|
323 lines_this_session = 0; |
|
324 } |
|
325 else |
2926
|
326 error ("gnu_history::append: missing file name"); |
1797
|
327 } |
|
328 } |
|
329 } |
|
330 |
|
331 void |
3504
|
332 gnu_history::do_truncate_file (const std::string& f_arg, int n) |
1797
|
333 { |
3504
|
334 std::string f = f_arg; |
1797
|
335 |
|
336 if (f.empty ()) |
|
337 f = xfile; |
|
338 |
|
339 if (! f.empty ()) |
2470
|
340 ::history_truncate_file (f.c_str (), n); |
1797
|
341 else |
2926
|
342 error ("gnu_history::truncate_file: missing file name"); |
1797
|
343 } |
|
344 |
|
345 string_vector |
2926
|
346 gnu_history::do_list (int limit, bool number_lines) |
1797
|
347 { |
|
348 string_vector retval; |
|
349 |
|
350 if (limit) |
|
351 { |
2470
|
352 HIST_ENTRY **hlist = ::history_list (); |
1797
|
353 |
|
354 if (hlist) |
|
355 { |
|
356 int end = 0; |
|
357 while (hlist[end]) |
|
358 end++; |
|
359 |
|
360 int beg = (limit < 0 || end < limit) ? 0 : (end - limit); |
|
361 |
|
362 retval.resize (end - beg); |
|
363 |
|
364 int k = 0; |
|
365 for (int i = beg; i < end; i++) |
|
366 { |
3504
|
367 std::ostrstream output_buf; |
1797
|
368 |
|
369 if (number_lines) |
2926
|
370 output_buf.form ("%5d%c", i + do_base (), |
1797
|
371 hlist[i]->data ? '*' : ' '); |
|
372 |
3504
|
373 output_buf << hlist[i]->line << std::ends; |
1797
|
374 |
|
375 const char *tmp = output_buf.str (); |
|
376 |
|
377 retval[k++] = tmp; |
|
378 |
|
379 delete [] tmp; |
|
380 } |
|
381 } |
|
382 } |
|
383 |
|
384 return retval; |
|
385 } |
|
386 |
3504
|
387 std::string |
2926
|
388 gnu_history::do_get_entry (int n) |
1797
|
389 { |
3504
|
390 std::string retval; |
1797
|
391 |
2926
|
392 HIST_ENTRY *entry = ::history_get (do_base () + n); |
1797
|
393 |
|
394 if (entry && entry->line) |
|
395 retval = entry->line; |
|
396 |
|
397 return retval; |
|
398 } |
|
399 |
|
400 void |
3504
|
401 gnu_history::do_replace_entry (int which, const std::string& line) |
1797
|
402 { |
2470
|
403 HIST_ENTRY *discard = ::replace_history_entry (which, line.c_str (), 0); |
1797
|
404 |
|
405 if (discard) |
|
406 { |
|
407 if (discard->line) |
2470
|
408 ::free (discard->line); |
1797
|
409 |
2470
|
410 ::free (discard); |
1797
|
411 } |
|
412 } |
|
413 |
|
414 void |
3504
|
415 gnu_history::do_clean_up_and_save (const std::string& f_arg, int n) |
1797
|
416 { |
3504
|
417 std::string f = f_arg; |
1797
|
418 |
|
419 if (f.empty ()) |
|
420 f = xfile; |
|
421 |
|
422 if (! f.empty ()) |
|
423 { |
|
424 if (n < 0) |
|
425 n = xsize; |
|
426 |
|
427 stifle (n); |
|
428 |
2926
|
429 do_write (f.c_str ()); |
1797
|
430 } |
|
431 else |
2926
|
432 error ("gnu_history::clean_up_and_save: missing file name"); |
|
433 } |
|
434 |
|
435 #endif |
|
436 |
|
437 bool |
|
438 command_history::instance_ok (void) |
|
439 { |
|
440 bool retval = true; |
|
441 |
|
442 if (! instance) |
|
443 make_command_history (); |
|
444 |
|
445 if (! instance) |
|
446 { |
|
447 (*current_liboctave_error_handler) |
|
448 ("unable to create command history object!"); |
|
449 |
|
450 retval = false; |
|
451 } |
|
452 |
|
453 return retval; |
|
454 } |
|
455 |
|
456 void |
|
457 command_history::make_command_history (void) |
|
458 { |
|
459 #if defined (USE_READLINE) |
|
460 instance = new gnu_history (); |
|
461 #else |
|
462 instance = new command_history (); |
|
463 #endif |
|
464 } |
|
465 |
|
466 void |
3504
|
467 command_history::set_file (const std::string& f) |
2926
|
468 { |
|
469 if (instance_ok ()) |
|
470 instance->do_set_file (f); |
|
471 } |
|
472 |
3504
|
473 std::string |
2926
|
474 command_history::file (void) |
|
475 { |
|
476 return (instance_ok ()) |
3504
|
477 ? instance->do_file () : std::string (); |
2926
|
478 } |
|
479 |
|
480 void |
|
481 command_history::set_size (int n) |
|
482 { |
|
483 if (instance_ok ()) |
|
484 instance->do_set_size (n); |
|
485 } |
|
486 |
|
487 int |
|
488 command_history::size (void) |
|
489 { |
|
490 return (instance_ok ()) |
|
491 ? instance->do_size () : 0; |
|
492 } |
|
493 |
|
494 void |
|
495 command_history::ignore_entries (bool flag) |
|
496 { |
|
497 if (instance_ok ()) |
|
498 instance->do_ignore_entries (flag); |
|
499 } |
|
500 |
|
501 bool |
|
502 command_history::ignoring_entries (void) |
|
503 { |
|
504 return (instance_ok ()) |
|
505 ? instance->do_ignoring_entries () : false; |
|
506 } |
|
507 |
|
508 void |
3504
|
509 command_history::add (const std::string& s) |
2926
|
510 { |
|
511 if (instance_ok ()) |
|
512 instance->do_add (s); |
|
513 } |
|
514 |
|
515 void |
|
516 command_history::remove (int n) |
|
517 { |
|
518 if (instance_ok ()) |
|
519 instance->do_remove (n); |
|
520 } |
|
521 |
|
522 int |
|
523 command_history::where (void) |
|
524 { |
|
525 return (instance_ok ()) |
|
526 ? instance->do_where () : 0; |
|
527 } |
|
528 |
|
529 int |
|
530 command_history::length (void) |
|
531 { |
|
532 return (instance_ok ()) |
|
533 ? instance->do_length () : 0; |
|
534 } |
|
535 |
|
536 int |
|
537 command_history::max_input_history (void) |
|
538 { |
|
539 return (instance_ok ()) |
|
540 ? instance->do_max_input_history () : 0; |
|
541 } |
|
542 |
|
543 int |
|
544 command_history::base (void) |
|
545 { |
|
546 return (instance_ok ()) |
|
547 ? instance->do_base () : 0; |
|
548 } |
|
549 |
|
550 int |
|
551 command_history::current_number (void) |
|
552 { |
|
553 return (instance_ok ()) |
|
554 ? instance->do_current_number () : 0; |
|
555 } |
|
556 |
|
557 void |
|
558 command_history::stifle (int n) |
|
559 { |
|
560 if (instance_ok ()) |
|
561 instance->do_stifle (n); |
|
562 } |
|
563 |
|
564 int |
|
565 command_history::unstifle (void) |
|
566 { |
|
567 return (instance_ok ()) |
|
568 ? instance->do_unstifle () : 0; |
|
569 } |
|
570 |
|
571 int |
|
572 command_history::is_stifled (void) |
|
573 { |
|
574 return (instance_ok ()) |
|
575 ? instance->do_is_stifled () : 0; |
|
576 } |
|
577 |
|
578 void |
|
579 command_history::set_mark (int n) |
|
580 { |
|
581 if (instance_ok ()) |
|
582 instance->do_set_mark (n); |
|
583 } |
|
584 |
|
585 int |
|
586 command_history::goto_mark (...) |
|
587 { |
|
588 if (instance_ok ()) |
|
589 instance->do_goto_mark (); |
|
590 |
|
591 return 0; |
|
592 } |
|
593 |
|
594 void |
|
595 command_history::read (bool must_exist) |
|
596 { |
|
597 if (instance_ok ()) |
|
598 instance->do_read (must_exist); |
|
599 } |
|
600 |
|
601 void |
3504
|
602 command_history::read (const std::string& f, bool must_exist) |
2926
|
603 { |
|
604 if (instance_ok ()) |
|
605 instance->do_read (f, must_exist); |
|
606 } |
|
607 |
|
608 void |
|
609 command_history::read_range (int from, int to, bool must_exist) |
|
610 { |
|
611 if (instance_ok ()) |
|
612 instance->do_read_range (from, to, must_exist); |
|
613 } |
|
614 |
|
615 void |
3504
|
616 command_history::read_range (const std::string& f, int from, int to, |
2926
|
617 bool must_exist) |
|
618 { |
|
619 if (instance_ok ()) |
|
620 instance->do_read_range (f, from, to, must_exist); |
|
621 } |
|
622 |
|
623 void |
3504
|
624 command_history::write (const std::string& f) |
2926
|
625 { |
|
626 if (instance_ok ()) |
|
627 instance->do_write (f); |
|
628 } |
|
629 |
|
630 void |
3504
|
631 command_history::append (const std::string& f) |
2926
|
632 { |
|
633 if (instance_ok ()) |
|
634 instance->do_append (f); |
|
635 } |
|
636 |
|
637 void |
3504
|
638 command_history::truncate_file (const std::string& f, int n) |
2926
|
639 { |
|
640 if (instance_ok ()) |
|
641 instance->do_truncate_file (f, n); |
|
642 } |
|
643 |
|
644 string_vector |
|
645 command_history::list (int limit, bool number_lines) |
|
646 { |
|
647 return (instance_ok ()) |
|
648 ? instance->do_list (limit, number_lines) : string_vector (); |
|
649 } |
|
650 |
3504
|
651 std::string |
2926
|
652 command_history::get_entry (int n) |
|
653 { |
|
654 return (instance_ok ()) |
3504
|
655 ? instance->do_get_entry (n) : std::string (); |
2926
|
656 } |
|
657 |
|
658 void |
3504
|
659 command_history::replace_entry (int which, const std::string& line) |
2926
|
660 { |
|
661 if (instance_ok ()) |
|
662 instance->do_replace_entry (which, line); |
|
663 } |
|
664 |
|
665 void |
3504
|
666 command_history::clean_up_and_save (const std::string& f, int n) |
2926
|
667 { |
|
668 if (instance_ok ()) |
|
669 instance->do_clean_up_and_save (f, n); |
|
670 } |
|
671 |
|
672 void |
3504
|
673 command_history::do_set_file (const std::string& f) |
2926
|
674 { |
|
675 xfile = f; |
|
676 } |
|
677 |
3504
|
678 std::string |
2926
|
679 command_history::do_file (void) |
|
680 { |
|
681 return xfile; |
|
682 } |
|
683 |
|
684 void |
|
685 command_history::do_set_size (int n) |
|
686 { |
|
687 xsize = n; |
|
688 } |
|
689 |
|
690 int |
|
691 command_history::do_size (void) |
|
692 { |
|
693 return xsize; |
|
694 } |
|
695 |
|
696 void |
|
697 command_history::do_ignore_entries (bool flag) |
|
698 { |
|
699 ignoring_additions = flag; |
|
700 } |
|
701 |
|
702 bool |
|
703 command_history::do_ignoring_entries (void) |
|
704 { |
|
705 return ignoring_additions; |
|
706 } |
|
707 |
|
708 void |
3504
|
709 command_history::do_add (const std::string&) |
2926
|
710 { |
|
711 } |
|
712 |
|
713 void |
|
714 command_history::do_remove (int) |
|
715 { |
|
716 } |
|
717 |
|
718 int |
|
719 command_history::do_where (void) |
|
720 { |
|
721 return 0; |
|
722 } |
|
723 |
|
724 int |
|
725 command_history::do_length (void) |
|
726 { |
|
727 return 0; |
|
728 } |
|
729 |
|
730 int |
|
731 command_history::do_max_input_history (void) |
|
732 { |
|
733 return 0; |
|
734 } |
|
735 |
|
736 int |
|
737 command_history::do_base (void) |
|
738 { |
|
739 return 0; |
|
740 } |
|
741 |
|
742 int |
|
743 command_history::do_current_number (void) |
|
744 { |
|
745 return (xsize > 0) ? do_base () + do_where () : -1; |
|
746 } |
|
747 |
|
748 void |
|
749 command_history::do_stifle (int) |
|
750 { |
|
751 } |
|
752 |
|
753 int |
|
754 command_history::do_unstifle (void) |
|
755 { |
|
756 return -1; |
|
757 } |
|
758 |
|
759 int |
|
760 command_history::do_is_stifled (void) |
|
761 { |
|
762 return 0; |
|
763 } |
|
764 |
|
765 void |
|
766 command_history::do_set_mark (int) |
|
767 { |
|
768 } |
|
769 |
|
770 void |
|
771 command_history::do_goto_mark (void) |
|
772 { |
|
773 } |
|
774 |
|
775 void |
|
776 command_history::do_read (bool must_exist) |
|
777 { |
|
778 do_read (xfile, must_exist); |
|
779 } |
|
780 |
|
781 void |
3504
|
782 command_history::do_read (const std::string& f, bool) |
2926
|
783 { |
|
784 if (f.empty ()) |
|
785 error ("command_history::read: missing file name"); |
|
786 } |
|
787 |
|
788 void |
|
789 command_history::do_read_range (int from, int to, bool must_exist) |
|
790 { |
|
791 do_read_range (xfile, from, to, must_exist); |
|
792 } |
|
793 |
|
794 void |
3504
|
795 command_history::do_read_range (const std::string& f, int, int, bool) |
2926
|
796 { |
|
797 if (f.empty ()) |
|
798 error ("command_history::read_range: missing file name"); |
|
799 } |
|
800 |
|
801 void |
3504
|
802 command_history::do_write (const std::string& f_arg) |
2926
|
803 { |
3504
|
804 std::string f = f_arg; |
2926
|
805 |
|
806 if (f.empty ()) |
|
807 f = xfile; |
|
808 |
|
809 if (f.empty ()) |
|
810 error ("command_history::write: missing file name"); |
|
811 } |
|
812 |
|
813 void |
3504
|
814 command_history::do_append (const std::string& f_arg) |
2926
|
815 { |
|
816 if (lines_this_session) |
|
817 { |
|
818 if (lines_this_session < do_where ()) |
|
819 { |
|
820 // Create file if it doesn't already exist. |
|
821 |
3504
|
822 std::string f = f_arg; |
2926
|
823 |
|
824 if (f.empty ()) |
|
825 f = xfile; |
|
826 |
|
827 if (f.empty ()) |
|
828 error ("command_history::append: missing file name"); |
|
829 } |
|
830 } |
|
831 } |
|
832 |
|
833 void |
3504
|
834 command_history::do_truncate_file (const std::string& f_arg, int) |
2926
|
835 { |
3504
|
836 std::string f = f_arg; |
2926
|
837 |
|
838 if (f.empty ()) |
|
839 f = xfile; |
|
840 |
|
841 if (f.empty ()) |
|
842 error ("command_history::truncate_file: missing file name"); |
|
843 } |
|
844 |
|
845 string_vector |
|
846 command_history::do_list (int, bool) |
|
847 { |
|
848 return string_vector (); |
|
849 } |
|
850 |
3504
|
851 std::string |
2926
|
852 command_history::do_get_entry (int) |
|
853 { |
3504
|
854 return std::string (); |
2926
|
855 } |
|
856 |
|
857 void |
3504
|
858 command_history::do_replace_entry (int, const std::string&) |
2926
|
859 { |
|
860 } |
|
861 |
|
862 void |
3504
|
863 command_history::do_clean_up_and_save (const std::string& f_arg, int) |
2926
|
864 { |
3504
|
865 std::string f = f_arg; |
2926
|
866 |
|
867 if (f.empty ()) |
|
868 f = xfile; |
|
869 |
|
870 if (f.empty ()) |
1797
|
871 error ("command_history::clean_up_and_save: missing file name"); |
|
872 } |
|
873 |
|
874 void |
2470
|
875 command_history::error (int err_num) |
1797
|
876 { |
2470
|
877 (*current_liboctave_error_handler) ("%s", strerror (err_num)); |
1797
|
878 } |
|
879 |
|
880 void |
3504
|
881 command_history::error (const std::string& s) |
1797
|
882 { |
|
883 (*current_liboctave_error_handler) ("%s", s.c_str ()); |
|
884 } |
|
885 |
|
886 /* |
|
887 ;;; Local Variables: *** |
|
888 ;;; mode: C++ *** |
|
889 ;;; End: *** |
|
890 */ |