New function to detect wild pathname components.

This commit is contained in:
Juan Jose Garcia Ripoll 2012-03-18 16:53:44 +01:00
parent a85ee4d210
commit f37055af48
2 changed files with 21 additions and 3 deletions

View file

@ -824,14 +824,14 @@ cl_logical_pathname(cl_object x)
if (component == Cnil || component == @':name') {
cl_object name = pathname->pathname.name;
if (name != Cnil &&
(name == @':wild' || (!SYMBOLP(name) && ecl_member_char('*', name))))
(name == @':wild' || ecl_wild_string_p(name)))
@(return Ct);
checked = 1;
}
if (component == Cnil || component == @':type') {
cl_object name = pathname->pathname.type;
if (name != Cnil &&
(name == @':wild' || (!SYMBOLP(name) && ecl_member_char('*', name))))
(name == @':wild' || ecl_wild_string_p(name)))
@(return Ct);
checked = 1;
}
@ -842,7 +842,7 @@ cl_logical_pathname(cl_object x)
cl_object name = ECL_CONS_CAR(list);
if (name != Cnil &&
(name == @':wild' || name == @':wild-inferiors' ||
(!SYMBOLP(name) && ecl_member_char('*', name))))
ecl_wild_string_p(name)))
{
@(return Ct)
}
@ -1379,6 +1379,20 @@ cl_host_namestring(cl_object pname)
/* --------------- PATHNAME MATCHING ------------------ */
bool
ecl_wild_string_p(cl_object item)
{
if (ECL_STRINGP(item)) {
cl_index i, l = ecl_length(item);
for (i = 0; i < l; i++) {
ecl_character c = ecl_char(item, i);
if (c == '\\' || c == '*' || c == '?')
return 1;
}
}
return 0;
}
/*
* Take two C strings and check if the first (s) one matches against
* the pattern given by the second one (p). The pattern is that of a

View file

@ -418,6 +418,10 @@ extern void cl_write_object(cl_object x, cl_object stream);
extern cl_object _ecl_package_to_be_created(const cl_env_ptr env, cl_object name);
/* pathname.d */
extern ecl_wild_string_p(cl_object item);
/* sequence.d */
typedef struct { cl_index start, end, length; } cl_index_pair;
extern ECL_API cl_index_pair ecl_sequence_start_end(cl_object fun, cl_object s, cl_object start, cl_object end);