comparison src/utils.cc @ 2233:0da2c91573d9

[project @ 1996-05-17 17:27:17 by jwe]
author jwe
date Fri, 17 May 1996 17:31:30 +0000
parents a24158362f9f
children a174011c96f2
comparison
equal deleted inserted replaced
2232:834eab508368 2233:0da2c91573d9
53 extern "C" int strncasecmp (const char*, const char*, size_t); 53 extern "C" int strncasecmp (const char*, const char*, size_t);
54 #endif 54 #endif
55 55
56 #include "SLStack.h" 56 #include "SLStack.h"
57 57
58 #include "file-ops.h"
58 #include "oct-cmplx.h" 59 #include "oct-cmplx.h"
59 #include "str-vec.h" 60 #include "str-vec.h"
60 61
61 #include "defaults.h" 62 #include "defaults.h"
62 #include "defun.h" 63 #include "defun.h"
205 delete [] to_match; 206 delete [] to_match;
206 207
207 return status; 208 return status;
208 } 209 }
209 210
210 string_vector
211 get_fcn_file_names (const string& name, int no_suffix)
212 {
213 string_vector retval;
214
215 dir_entry dir (name);
216
217 if (dir)
218 {
219 string_vector tmp = dir.read ();
220
221 int max_len = tmp.length ();
222
223 retval.resize (max_len);
224
225 int k = 0;
226 int i;
227 for (i = 0; i < max_len; i++)
228 {
229 string entry = tmp[i];
230
231 int len = entry.length ();
232
233 #if defined (WITH_DYNAMIC_LINKING)
234 if ((len > 2
235 && entry[len-2] == '.' && entry[len-1] == 'm')
236 || (len > 4
237 && entry[len-4] == '.' && entry[len-3] == 'o'
238 && entry[len-2] == 'c' && entry[len-1] == 't'))
239 #else
240 if (len > 2
241 && entry[len-2] == '.' && entry[len-1] == 'm')
242 #endif
243 {
244 if (no_suffix)
245 {
246 if (entry[len-1] == 'm')
247 entry.resize (len-2);
248 else
249 entry.resize (len-4);
250 }
251
252 retval[k++] = entry;
253 }
254 }
255
256 retval.resize (k);
257 }
258
259 return retval;
260 }
261
262 string_vector
263 get_fcn_file_names (int no_suffix)
264 {
265 static int num_max = 1024;
266
267 string_vector retval (num_max);
268
269 dir_path p (Vload_path);
270
271 string_vector dirs = p.all_directories ();
272
273 int len = dirs.length ();
274
275 int k = 0;
276
277 for (int i = 0; i < len; i++)
278 {
279 string_vector names = get_fcn_file_names (dirs[i], no_suffix);
280
281 int tmp_num = names.length ();
282
283 if (k + tmp_num > num_max)
284 {
285 num_max += tmp_num;
286 retval.resize (num_max);
287 }
288
289 for (int j = 0; j < tmp_num; j++)
290 retval[k++] = names[j];
291 }
292
293 retval.resize (k);
294
295 return retval;
296 }
297
298 // Return non-zero if either NR or NC is zero. Return -1 if this
299 // should be considered fatal; return 1 if this is ok.
300
301 int
302 empty_arg (const char *name, int nr, int nc)
303 {
304 int is_empty = 0;
305
306 if (nr == 0 || nc == 0)
307 {
308 int flag = Vpropagate_empty_matrices;
309
310 if (flag < 0)
311 {
312 gripe_empty_arg (name, 0);
313 is_empty = 1;
314 }
315 else if (flag == 0)
316 {
317 gripe_empty_arg (name, 1);
318 is_empty = -1;
319 }
320 else
321 is_empty = 1;
322 }
323
324 return is_empty;
325 }
326
327 // See if the given file is in the path. 211 // See if the given file is in the path.
328 212
329 string 213 string
330 search_path_for_file (const string& path, const string& name) 214 search_path_for_file (const string& path, const string& name)
331 { 215 {