Mercurial > hg > octave-lyh
annotate src/comment-list.cc @ 14522:f739e30494c8
condest.m: Fix failing %!test.
* condest.m: Use is_function_handle rather than isscalar to determine
if input is a function handle.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 03 Apr 2012 21:16:29 -0700 |
parents | 72c96de7a403 |
children | f7afecdd87ef |
rev | line source |
---|---|
3665 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13983
diff
changeset
|
3 Copyright (C) 2000-2012 John W. Eaton |
3665 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3665 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
3665 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "lo-utils.h" | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
28 #include "singleton-cleanup.h" |
3665 | 29 |
30 #include "comment-list.h" | |
31 #include "error.h" | |
32 | |
33 octave_comment_buffer *octave_comment_buffer::instance = 0; | |
34 | |
5861 | 35 octave_comment_list * |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
36 octave_comment_list::dup (void) const |
5861 | 37 { |
38 octave_comment_list *new_cl = new octave_comment_list (); | |
39 | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
40 for (const_iterator p = begin (); p != end (); p++) |
5861 | 41 { |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
42 const octave_comment_elt elt = *p; |
5861 | 43 |
44 new_cl->append (elt); | |
45 } | |
46 | |
47 return new_cl; | |
48 } | |
49 | |
3665 | 50 bool |
51 octave_comment_buffer::instance_ok (void) | |
52 { | |
53 bool retval = true; | |
54 | |
55 if (! instance) | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
56 { |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
57 instance = new octave_comment_buffer (); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
58 |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
59 if (instance) |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
60 singleton_cleanup_list::add (cleanup_instance); |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
61 } |
3665 | 62 |
63 if (! instance) | |
64 { | |
65 ::error ("unable to create comment buffer object"); | |
66 | |
67 retval = false; | |
68 } | |
69 | |
70 return retval; | |
71 } | |
72 | |
73 void | |
74 octave_comment_buffer::append (const std::string& s, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
75 octave_comment_elt::comment_type t) |
3665 | 76 { |
77 if (instance_ok ()) | |
78 instance->do_append (s, t); | |
79 } | |
80 | |
81 octave_comment_list * | |
82 octave_comment_buffer::get_comment (void) | |
83 { | |
84 return (instance_ok ()) ? instance->do_get_comment () : 0; | |
85 } | |
86 | |
87 void | |
88 octave_comment_buffer::do_append (const std::string& s, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
89 octave_comment_elt::comment_type t) |
3665 | 90 { |
91 comment_list->append(s, t); | |
92 } | |
93 | |
94 octave_comment_list * | |
95 octave_comment_buffer::do_get_comment (void) | |
96 { | |
97 octave_comment_list *retval = 0; | |
98 | |
99 if (comment_list && comment_list->length () > 0) | |
100 { | |
101 retval = comment_list; | |
102 comment_list = new octave_comment_list (); | |
103 } | |
104 | |
105 return retval; | |
106 } |