Skip to content

Commit

Permalink
Recognize [:graph:] & [:print:] classifications (#12)
Browse files Browse the repository at this point in the history
Passes 3 more of the original integration tests in tests.txt that had been previously commented out in 146667d.
  • Loading branch information
atifaziz authored and markashleybell committed Oct 26, 2018
1 parent 5130eee commit ecd0c29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions MAB.DotIgnore.Test/test_content/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
1 1 5 [[:xdigit:]]
1 1 f [[:xdigit:]]
1 1 D [[:xdigit:]]
#1 1 _ [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]
1 1 _ [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]
#1 1 … [^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]
#1 1  [^[:alnum:][:alpha:][:blank:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]
#1 1 . [^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]
1 1  [^[:alnum:][:alpha:][:blank:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]
1 1 . [^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]
1 1 5 [a-c[:digit:]x-z]
1 1 b [a-c[:digit:]x-z]
1 1 y [a-c[:digit:]x-z]
Expand Down
23 changes: 13 additions & 10 deletions MAB.DotIgnore/WildMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,21 @@ private static int Match(char[] pattern, char[] text, int p, int t, MatchFlags f
if (Char.IsDigit(t_ch))
match = 1;
}
// else if (CC_EQ(pattern, s, i, "graph"))
// {
// if (ISGRAPH(t_ch))
// match = 1;
// }
else if (CC_EQ(pattern, s, i, "graph"))
{
if (ISGRAPH(t_ch))
match = 1;
}
else if (CC_EQ(pattern, s, i, "lower"))
{
if (Char.IsLower(t_ch))
match = 1;
}
// else if (CC_EQ(pattern, s, i, "print"))
// {
// if (ISPRINT(t_ch))
// match = 1;
// }
else if (CC_EQ(pattern, s, i, "print"))
{
if (ISPRINT(t_ch))
match = 1;
}
else if (CC_EQ(pattern, s, i, "punct"))
{
if (Char.IsPunctuation(t_ch))
Expand Down Expand Up @@ -335,5 +335,8 @@ static bool CC_EQ(char[] pattern, int s, int len, string @class)
{
return string.Compare(new String(pattern, s, len), @class, StringComparison.Ordinal) == 0;
}

static bool ISPRINT(char ch) => ch >= 0x20 && ch <= 0x7e;
static bool ISGRAPH(char ch) => ISPRINT(ch) && ch != 0x20;
}
}

0 comments on commit ecd0c29

Please sign in to comment.