Mercurial > octave
diff src/symtab.cc @ 867:b6b78f85743a
[project @ 1994-11-02 14:20:02 by jwe]
author | jwe |
---|---|
date | Wed, 02 Nov 1994 14:20:02 +0000 |
parents | dedc491ec606 |
children | ba6acc6309ec |
line wrap: on
line diff
--- a/src/symtab.cc Wed Nov 02 05:19:02 1994 +0000 +++ b/src/symtab.cc Wed Nov 02 14:20:02 1994 +0000 @@ -973,12 +973,26 @@ return strcmp (a->name (), b->name ()); } +static int +matches_patterns (const char *name, char **pats, int npats) +{ + while (npats-- > 0) + { + if (fnmatch (*pats, name, __FNM_FLAGS) == 0) + return 1; + + pats++; + } + + return 0; +} + // This function should probably share code with symbol_table::list. // XXX FIXME XXX symbol_record_info * -symbol_table::long_list (int& count, int sort, unsigned type, - unsigned scope) const +symbol_table::long_list (int& count, char **pats, int npats, int sort, + unsigned type, unsigned scope) const { count = 0; int n = size (); @@ -992,12 +1006,17 @@ while (ptr) { assert (count < n); + unsigned my_scope = ptr->is_linked_to_global () + 1; // Tricky... + unsigned my_type = ptr->type (); - if ((type & my_type) && (scope & my_scope)) - { - symbols[count++] = symbol_record_info (*ptr); - } + + char *my_name = ptr->name (); + + if ((type & my_type) && (scope & my_scope) + && (npats == 0 || matches_patterns (my_name, pats, npats))) + symbols[count++] = symbol_record_info (*ptr); + ptr = ptr->next (); } } @@ -1011,8 +1030,8 @@ } char ** -symbol_table::list (int& count, int sort, unsigned type, - unsigned scope) const +symbol_table::list (int& count, char **pats, int npats, int sort, + unsigned type, unsigned scope) const { count = 0; int n = size (); @@ -1031,7 +1050,10 @@ unsigned my_type = ptr->type (); - if ((type & my_type) && (scope & my_scope)) + char *my_name = ptr->name (); + + if ((type & my_type) && (scope & my_scope) + && (npats == 0 || matches_patterns (my_name, pats, npats))) symbols[count++] = strsave (ptr->name ()); ptr = ptr->next ();