diff options
author | Mark Lord <kernel@teksavvy.com> | 2010-07-05 10:25:45 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2010-08-01 19:36:04 -0400 |
commit | 2f9e4d16c5b6f627670f1641b3f288d16d84b202 (patch) | |
tree | d195b3a9cd67879b3d4a501cd09ed712601b9ec8 /drivers/ata/libata-core.c | |
parent | 728e0eaf99631d197e5158e21b4a8c4335a39231 (diff) |
libata: allow hyphenated pattern ranges
Enable use of hyphenated pattern ranges in glob_match(), similar to how
shell globbing works, and how developers might expect things to work.
Signed-off-by: Mark Lord <mlord@pobox.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 2984e45bc16b..eefb948f0632 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -4283,11 +4283,13 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
4283 | * ? matches any single character. | 4283 | * ? matches any single character. |
4284 | * * matches any run of characters. | 4284 | * * matches any run of characters. |
4285 | * [xyz] matches a single character from the set: x, y, or z. | 4285 | * [xyz] matches a single character from the set: x, y, or z. |
4286 | * [a-d] matches a single character from the range: a, b, c, or d. | ||
4287 | * [a-d0-9] matches a single character from either range. | ||
4286 | * | 4288 | * |
4287 | * Note: hyphenated ranges [0-9] are _not_ supported here. | 4289 | * The special characters ?, [, -, or *, can be matched using a set, eg. [*] |
4288 | * The special characters ?, [, or *, can be matched using a set, eg. [*] | 4290 | * Behaviour with malformed patterns is undefined, though generally reasonable. |
4289 | * | 4291 | * |
4290 | * Example patterns: "SD1?", "SD1[012345]", "*R0", SD*1?[012]*xx" | 4292 | * Example patterns: "SD1?", "SD1[0-5]", "*R0", SD*1?[012]*xx" |
4291 | * | 4293 | * |
4292 | * This function uses one level of recursion per '*' in pattern. | 4294 | * This function uses one level of recursion per '*' in pattern. |
4293 | * Since it calls _nothing_ else, and has _no_ explicit local variables, | 4295 | * Since it calls _nothing_ else, and has _no_ explicit local variables, |
@@ -4307,7 +4309,13 @@ static int glob_match (const char *text, const char *pattern) | |||
4307 | /* Match single char against a '[' bracketed ']' pattern set */ | 4309 | /* Match single char against a '[' bracketed ']' pattern set */ |
4308 | if (!*text || *pattern != '[') | 4310 | if (!*text || *pattern != '[') |
4309 | break; /* Not a pattern set */ | 4311 | break; /* Not a pattern set */ |
4310 | while (*++pattern && *pattern != ']' && *text != *pattern); | 4312 | while (*++pattern && *pattern != ']' && *text != *pattern) { |
4313 | if (*pattern == '-' && *(pattern - 1) != '[') | ||
4314 | if (*text > *(pattern - 1) && *text < *(pattern + 1)) { | ||
4315 | ++pattern; | ||
4316 | break; | ||
4317 | } | ||
4318 | } | ||
4311 | if (!*pattern || *pattern == ']') | 4319 | if (!*pattern || *pattern == ']') |
4312 | return 1; /* No match */ | 4320 | return 1; /* No match */ |
4313 | while (*pattern && *pattern++ != ']'); | 4321 | while (*pattern && *pattern++ != ']'); |