Mercurial > octave-nkf
comparison src/variables.cc @ 4207:fa3482b34599
[project @ 2002-12-03 18:22:05 by jwe]
author | jwe |
---|---|
date | Tue, 03 Dec 2002 18:22:51 +0000 |
parents | 8734ba917fea |
children | e96f52432059 |
comparison
equal
deleted
inserted
replaced
4206:fc514e47666e | 4207:fa3482b34599 |
---|---|
25 #endif | 25 #endif |
26 | 26 |
27 #include <cstdio> | 27 #include <cstdio> |
28 #include <cstring> | 28 #include <cstring> |
29 | 29 |
30 #include <set> | |
30 #include <string> | 31 #include <string> |
31 | 32 |
32 #include "file-stat.h" | 33 #include "file-stat.h" |
33 #include "oct-env.h" | 34 #include "oct-env.h" |
34 #include "glob-match.h" | 35 #include "glob-match.h" |
101 return (sr && sr->is_builtin_variable ()); | 102 return (sr && sr->is_builtin_variable ()); |
102 } | 103 } |
103 | 104 |
104 // Is this a text-style function? | 105 // Is this a text-style function? |
105 | 106 |
107 static std::set <std::string> text_function_set; | |
108 | |
109 static inline bool | |
110 is_marked_as_text_function (const std::string& s) | |
111 { | |
112 return text_function_set.find (s) != text_function_set.end (); | |
113 } | |
114 | |
115 static inline void | |
116 mark_as_text_function (const std::string& s) | |
117 { | |
118 text_function_set.insert (s); | |
119 } | |
120 | |
121 static inline void | |
122 unmark_text_function (const std::string& s) | |
123 { | |
124 text_function_set.erase (s); | |
125 | |
126 symbol_record *sr = fbi_sym_tab->lookup (s); | |
127 | |
128 if (sr) | |
129 sr->unmark_text_function (); | |
130 } | |
131 | |
132 DEFUN_TEXT (mark_as_text_function, args, , | |
133 "-*- texinfo -*-\n\ | |
134 @deftypefn {Built-in Function} {} mark_as_text_function (@var{name})\n\ | |
135 Enter @var{name} into the list of text functions\n\ | |
136 @end deftypefn") | |
137 { | |
138 octave_value_list retval; | |
139 | |
140 int nargin = args.length (); | |
141 | |
142 if (nargin > 0) | |
143 { | |
144 int argc = nargin + 1; | |
145 | |
146 string_vector argv = args.make_argv ("mark_as_text_function"); | |
147 | |
148 if (! error_state) | |
149 { | |
150 for (int i = 1; i < argc; i++) | |
151 mark_as_text_function (argv[i]); | |
152 } | |
153 } | |
154 else | |
155 print_usage ("mark_as_text_function"); | |
156 | |
157 return retval; | |
158 } | |
159 | |
160 DEFUN_TEXT (unmark_text_function, args, , | |
161 "-*- texinfo -*-\n\ | |
162 @deftypefn {Built-in Function} {} mark_as_text_function (@var{name})\n\ | |
163 Enter @var{name} into the list of text functions\n\ | |
164 @end deftypefn") | |
165 { | |
166 octave_value_list retval; | |
167 | |
168 int nargin = args.length (); | |
169 | |
170 if (nargin > 0) | |
171 { | |
172 int argc = nargin + 1; | |
173 | |
174 string_vector argv = args.make_argv ("unmark_text_function"); | |
175 | |
176 if (! error_state) | |
177 { | |
178 for (int i = 1; i < argc; i++) | |
179 unmark_text_function (argv[i]); | |
180 } | |
181 } | |
182 else | |
183 print_usage ("unmark_text_function"); | |
184 | |
185 return retval; | |
186 } | |
187 | |
106 bool | 188 bool |
107 is_text_function_name (const std::string& s) | 189 is_text_function_name (const std::string& s) |
108 { | 190 { |
191 bool retval = false; | |
192 | |
109 symbol_record *sr = fbi_sym_tab->lookup (s); | 193 symbol_record *sr = fbi_sym_tab->lookup (s); |
110 return (sr && sr->is_text_function ()); | 194 |
195 if (sr) | |
196 { | |
197 if (sr->is_text_function ()) | |
198 retval = true; | |
199 else if (is_marked_as_text_function (s)) | |
200 { | |
201 sr->mark_as_text_function (); | |
202 retval = true; | |
203 } | |
204 } | |
205 else | |
206 retval = is_marked_as_text_function (s); | |
207 | |
208 return retval; | |
111 } | 209 } |
112 | 210 |
113 // Is this a built-in function? | 211 // Is this a built-in function? |
114 | 212 |
115 bool | 213 bool |