From: Mark Lord <kernel@teksavvy.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: IDE/ATA development list <linux-ide@vger.kernel.org>,
Tejun Heo <htejun@gmail.com>
Subject: Re: [PATCH 4/4] libata: allow hyphenated pattern ranges
Date: Mon, 05 Jul 2010 10:25:45 -0400 [thread overview]
Message-ID: <4C31EB69.5070903@teksavvy.com> (raw)
In-Reply-To: <4C2D1424.4050407@teksavvy.com>
[-- Attachment #1: Type: text/plain, Size: 1930 bytes --]
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>
---
Patch also attached, to get around ongoing mailer issues here.
Eventually, glob_match() will move out of libata into lib/string.c or similar.
--- old/drivers/ata/libata-core.c 2010-07-01 18:12:52.471339000 -0400
+++ linux/drivers/ata/libata-core.c 2010-07-05 10:23:51.198204782 -0400
@@ -4283,11 +4283,13 @@
* ? matches any single character.
* * matches any run of characters.
* [xyz] matches a single character from the set: x, y, or z.
+ * [a-d] matches a single character from the range: a, b, c, or d.
+ * [a-d0-9] matches a single character from either range.
*
- * Note: hyphenated ranges [0-9] are _not_ supported here.
- * The special characters ?, [, or *, can be matched using a set, eg. [*]
+ * The special characters ?, [, -, or *, can be matched using a set, eg. [*]
+ * Behaviour with malformed patterns is undefined, though generally reasonable.
*
- * Example patterns: "SD1?", "SD1[012345]", "*R0", SD*1?[012]*xx"
+ * Example patterns: "SD1?", "SD1[0-5]", "*R0", SD*1?[012]*xx"
*
* This function uses one level of recursion per '*' in pattern.
* Since it calls _nothing_ else, and has _no_ explicit local variables,
@@ -4307,7 +4309,13 @@
/* Match single char against a '[' bracketed ']' pattern set */
if (!*text || *pattern != '[')
break; /* Not a pattern set */
- while (*++pattern && *pattern != ']' && *text != *pattern);
+ while (*++pattern && *pattern != ']' && *text != *pattern) {
+ if (*pattern == '-' && *(pattern - 1) != '[')
+ if (*text > *(pattern - 1) && *text < *(pattern + 1)) {
+ ++pattern;
+ break;
+ }
+ }
if (!*pattern || *pattern == ']')
return 1; /* No match */
while (*pattern && *pattern++ != ']');
[-- Attachment #2: 54_libata_hyphenated_globs.patch --]
[-- Type: text/x-diff, Size: 1916 bytes --]
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>
---
Patch also attached, to get around ongoing mailer issues here.
Eventually, glob_match() will move out of libata into lib/string.c or similar.
--- old/drivers/ata/libata-core.c 2010-07-01 18:12:52.471339000 -0400
+++ linux/drivers/ata/libata-core.c 2010-07-05 10:23:51.198204782 -0400
@@ -4283,11 +4283,13 @@
* ? matches any single character.
* * matches any run of characters.
* [xyz] matches a single character from the set: x, y, or z.
+ * [a-d] matches a single character from the range: a, b, c, or d.
+ * [a-d0-9] matches a single character from either range.
*
- * Note: hyphenated ranges [0-9] are _not_ supported here.
- * The special characters ?, [, or *, can be matched using a set, eg. [*]
+ * The special characters ?, [, -, or *, can be matched using a set, eg. [*]
+ * Behaviour with malformed patterns is undefined, though generally reasonable.
*
- * Example patterns: "SD1?", "SD1[012345]", "*R0", SD*1?[012]*xx"
+ * Example patterns: "SD1?", "SD1[0-5]", "*R0", SD*1?[012]*xx"
*
* This function uses one level of recursion per '*' in pattern.
* Since it calls _nothing_ else, and has _no_ explicit local variables,
@@ -4307,7 +4309,13 @@
/* Match single char against a '[' bracketed ']' pattern set */
if (!*text || *pattern != '[')
break; /* Not a pattern set */
- while (*++pattern && *pattern != ']' && *text != *pattern);
+ while (*++pattern && *pattern != ']' && *text != *pattern) {
+ if (*pattern == '-' && *(pattern - 1) != '[')
+ if (*text > *(pattern - 1) && *text < *(pattern + 1)) {
+ ++pattern;
+ break;
+ }
+ }
if (!*pattern || *pattern == ']')
return 1; /* No match */
while (*pattern && *pattern++ != ']');
next prev parent reply other threads:[~2010-07-05 14:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-01 15:30 [PATCH 1/3] libata: glob_match for ata_device_blacklist Mark Lord
2010-07-01 15:31 ` [PATCH 2/3] libata: reduce blacklist size Mark Lord
2010-07-01 15:31 ` [PATCH 3/3] libata: reduce blacklist size even more Mark Lord
2010-07-01 15:36 ` [PATCH 3/3] libata: reduce blacklist size (resend) Mark Lord
2010-07-01 15:34 ` [PATCH 1/3] libata: glob_match for ata_device_blacklist Mark Lord
2010-07-01 15:36 ` James Bottomley
2010-07-01 15:44 ` Mark Lord
2010-07-01 19:24 ` Jeff Garzik
2010-07-01 21:56 ` Mark Lord
2010-07-01 22:09 ` Mark Lord
2010-07-01 22:16 ` [PATCH 1/3] libata: glob_match for ata_device_blacklist (v2) Mark Lord
2010-07-01 22:17 ` [PATCH 2/3] libata: reduce blacklist size (v2) Mark Lord
2010-07-01 22:18 ` [PATCH 3/3] libata: reduce blacklist size even more (v2) Mark Lord
2010-07-02 7:19 ` Jeff Garzik
2010-07-05 14:25 ` Mark Lord [this message]
2010-07-05 18:33 ` [PATCH 4/4] libata: allow hyphenated pattern ranges Jeff Garzik
2010-07-05 21:47 ` Mark Lord
2010-07-05 22:20 ` Jeff Garzik
2010-07-05 22:39 ` Mark Lord
2010-07-05 22:50 ` [PATCH 5/5] " Mark Lord
2010-07-05 22:51 ` Mark Lord
2010-07-05 22:53 ` [PATCH 5/5] libata: allow hyphenated pattern ranges (v2) Mark Lord
2010-07-14 7:54 ` Jeff Garzik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C31EB69.5070903@teksavvy.com \
--to=kernel@teksavvy.com \
--cc=htejun@gmail.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.