Mercurial > octave
comparison liboctave/cmd-hist.cc @ 2658:dd71eb0bb414
[project @ 1997-02-03 04:49:57 by jwe]
author | jwe |
---|---|
date | Mon, 03 Feb 1997 04:50:10 +0000 |
parents | fda09c1e787e |
children | 5ea93b07a88b |
comparison
equal
deleted
inserted
replaced
2657:7457014d8985 | 2658:dd71eb0bb414 |
---|---|
177 { | 177 { |
178 return ::history_is_stifled (); | 178 return ::history_is_stifled (); |
179 } | 179 } |
180 | 180 |
181 void | 181 void |
182 command_history::read (const string& f_arg) | 182 command_history::read (bool must_exist) |
183 { | |
184 read (xfile, must_exist); | |
185 } | |
186 | |
187 void | |
188 command_history::read (const string& f_arg, bool must_exist) | |
183 { | 189 { |
184 string f = f_arg; | 190 string f = f_arg; |
185 | 191 |
186 if (f.empty ()) | 192 if (f.empty ()) |
187 f = xfile; | 193 f = xfile; |
188 | 194 |
189 if (! f.empty ()) | 195 if (! f.empty ()) |
190 { | 196 { |
191 int status = ::read_history (f.c_str ()); | 197 int status = ::read_history (f.c_str ()); |
192 | 198 |
193 if (status != 0) | 199 if (status != 0 && must_exist) |
194 error (status); | |
195 else | |
196 ::using_history (); | |
197 } | |
198 else | |
199 error ("command_history::read: missing file name"); | |
200 } | |
201 | |
202 void | |
203 command_history::read_range (const string& f_arg, int from, int to) | |
204 { | |
205 if (from < 0) | |
206 from = lines_in_file; | |
207 | |
208 string f = f_arg; | |
209 | |
210 if (f.empty ()) | |
211 f = xfile; | |
212 | |
213 if (! f.empty ()) | |
214 { | |
215 int status = ::read_history_range (f.c_str (), from, to); | |
216 | |
217 if (status != 0) | |
218 error (status); | 200 error (status); |
219 else | 201 else |
220 { | 202 { |
203 lines_in_file = where (); | |
204 | |
221 ::using_history (); | 205 ::using_history (); |
206 } | |
207 } | |
208 else | |
209 error ("command_history::read: missing file name"); | |
210 } | |
211 | |
212 command_history::read_range (int from, int to, bool must_exist) | |
213 { | |
214 read_range (xfile, from, to, must_exist); | |
215 } | |
216 | |
217 void | |
218 command_history::read_range (const string& f_arg, int from, int to, | |
219 bool must_exist) | |
220 { | |
221 if (from < 0) | |
222 from = lines_in_file; | |
223 | |
224 string f = f_arg; | |
225 | |
226 if (f.empty ()) | |
227 f = xfile; | |
228 | |
229 if (! f.empty ()) | |
230 { | |
231 int status = ::read_history_range (f.c_str (), from, to); | |
232 | |
233 if (status != 0 && must_exist) | |
234 error (status); | |
235 else | |
236 { | |
222 lines_in_file = where (); | 237 lines_in_file = where (); |
238 | |
239 ::using_history (); | |
223 } | 240 } |
224 } | 241 } |
225 else | 242 else |
226 error ("command_history::read_range: missing file name"); | 243 error ("command_history::read_range: missing file name"); |
227 } | 244 } |