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