Author: pschweitzer
Date: Sat Feb 12 18:39:17 2011
New Revision: 50670
URL:
http://svn.reactos.org/svn/reactos?rev=50670&view=rev
Log:
[NTOSKRNL]
For both FsRtlIsNameInExpression & FsRtlIsDbcsInExpression:
- Remove useless checks
- Move redundant sum before loop, so it's done only once
- Fix handling of * wildcard
This fixes failing kmtest tests added in r50614
Modified:
trunk/reactos/ntoskrnl/fsrtl/dbcsname.c
trunk/reactos/ntoskrnl/fsrtl/name.c
Modified: trunk/reactos/ntoskrnl/fsrtl/dbcsname.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/dbcsname.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/fsrtl/dbcsname.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/fsrtl/dbcsname.c [iso-8859-1] Sat Feb 12 18:39:17 2011
@@ -160,7 +160,7 @@
FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
IN PANSI_STRING Name)
{
- USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars;
+ USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars, StarFound =
MAXUSHORT;
PAGED_CODE();
ASSERT(Name->Length);
@@ -169,34 +169,37 @@
while (NamePosition < Name->Length && ExpressionPosition <
Expression->Length)
{
- if ((Expression->Buffer[ExpressionPosition] == Name->Buffer[NamePosition])
||
- (Expression->Buffer[ExpressionPosition] == '?') ||
(Expression->Buffer[ExpressionPosition] == ANSI_DOS_QM) ||
- (Expression->Buffer[ExpressionPosition] == ANSI_DOS_DOT &&
Name->Buffer[NamePosition] == '.'))
+ if ((Expression->Buffer[ExpressionPosition] ==
Name->Buffer[NamePosition]))
{
NamePosition++;
ExpressionPosition++;
}
+ else if ((Expression->Buffer[ExpressionPosition] == '?') ||
(Expression->Buffer[ExpressionPosition] == ANSI_DOS_QM) ||
+ (Expression->Buffer[ExpressionPosition] == ANSI_DOS_DOT &&
Name->Buffer[NamePosition] == '.'))
+ {
+ NamePosition++;
+ ExpressionPosition++;
+ StarFound = MAXUSHORT;
+ }
else if (Expression->Buffer[ExpressionPosition] == '*')
{
- if (ExpressionPosition < (Expression->Length - 1))
- {
- if (Expression->Buffer[ExpressionPosition+1] != '*' &&
Expression->Buffer[ExpressionPosition+1] != '?' &&
- Expression->Buffer[ExpressionPosition+1] != ANSI_DOS_DOT
&&
- Expression->Buffer[ExpressionPosition+1] != ANSI_DOS_QM
&&
- Expression->Buffer[ExpressionPosition+1] != ANSI_DOS_STAR)
+ StarFound = ExpressionPosition++;
+ if (StarFound < (Expression->Length - 1))
+ {
+ while (Name->Buffer[NamePosition] !=
Expression->Buffer[ExpressionPosition] &&
+ NamePosition < Name->Length)
{
- while (Name->Buffer[NamePosition] !=
Expression->Buffer[ExpressionPosition+1] &&
- NamePosition < Name->Length) NamePosition++;
+ NamePosition++;
}
}
else
{
NamePosition = Name->Length;
}
- ExpressionPosition++;
}
else if (Expression->Buffer[ExpressionPosition] == ANSI_DOS_STAR)
{
+ StarFound = MAXUSHORT;
MatchingChars = NamePosition;
while (MatchingChars < Name->Length)
{
@@ -207,6 +210,15 @@
MatchingChars++;
}
ExpressionPosition++;
+ }
+ else if (StarFound != MAXUSHORT)
+ {
+ ExpressionPosition = StarFound + 1;
+ while (Name->Buffer[NamePosition] !=
Expression->Buffer[ExpressionPosition] &&
+ NamePosition < Name->Length)
+ {
+ NamePosition++;
+ }
}
else
{
Modified: trunk/reactos/ntoskrnl/fsrtl/name.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/fsrtl/name.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/fsrtl/name.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/fsrtl/name.c [iso-8859-1] Sat Feb 12 18:39:17 2011
@@ -22,40 +22,44 @@
IN BOOLEAN IgnoreCase,
IN PWCHAR UpcaseTable OPTIONAL)
{
- USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars;
+ USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars, StarFound =
MAXUSHORT;
PAGED_CODE();
ASSERT(!IgnoreCase || UpcaseTable);
while (NamePosition < Name->Length / sizeof(WCHAR) &&
ExpressionPosition < Expression->Length / sizeof(WCHAR))
{
- if ((Expression->Buffer[ExpressionPosition] == (IgnoreCase ?
UpcaseTable[Name->Buffer[NamePosition]] : Name->Buffer[NamePosition])) ||
- (Expression->Buffer[ExpressionPosition] == L'?') ||
(Expression->Buffer[ExpressionPosition] == DOS_QM) ||
- (Expression->Buffer[ExpressionPosition] == DOS_DOT &&
Name->Buffer[NamePosition] == L'.'))
+ if ((Expression->Buffer[ExpressionPosition] == (IgnoreCase ?
UpcaseTable[Name->Buffer[NamePosition]] : Name->Buffer[NamePosition])))
{
NamePosition++;
ExpressionPosition++;
}
+ else if (Expression->Buffer[ExpressionPosition] == L'?' ||
(Expression->Buffer[ExpressionPosition] == DOS_QM) ||
+ (Expression->Buffer[ExpressionPosition] == DOS_DOT &&
Name->Buffer[NamePosition] == L'.'))
+ {
+ NamePosition++;
+ ExpressionPosition++;
+ StarFound = MAXUSHORT;
+ }
else if (Expression->Buffer[ExpressionPosition] == L'*')
{
- if (ExpressionPosition < (Expression->Length / sizeof(WCHAR) - 1))
- {
- if (Expression->Buffer[ExpressionPosition+1] != L'*'
&& Expression->Buffer[ExpressionPosition+1] != L'?' &&
- Expression->Buffer[ExpressionPosition+1] != DOS_DOT &&
Expression->Buffer[ExpressionPosition+1] != DOS_QM &&
- Expression->Buffer[ExpressionPosition+1] != DOS_STAR)
+ StarFound = ExpressionPosition++;
+ if (StarFound < (Expression->Length / sizeof(WCHAR) - 1))
+ {
+ while ((IgnoreCase ? UpcaseTable[Name->Buffer[NamePosition]] :
Name->Buffer[NamePosition]) != Expression->Buffer[ExpressionPosition] &&
+ NamePosition < Name->Length / sizeof(WCHAR))
{
- while ((IgnoreCase ? UpcaseTable[Name->Buffer[NamePosition]] :
Name->Buffer[NamePosition]) != Expression->Buffer[ExpressionPosition+1] &&
- NamePosition < Name->Length / sizeof(WCHAR))
NamePosition++;
+ NamePosition++;
}
}
else
{
NamePosition = Name->Length / sizeof(WCHAR);
}
- ExpressionPosition++;
}
else if (Expression->Buffer[ExpressionPosition] == DOS_STAR)
{
+ StarFound = MAXUSHORT;
MatchingChars = NamePosition;
while (MatchingChars < Name->Length / sizeof(WCHAR))
{
@@ -66,6 +70,15 @@
MatchingChars++;
}
ExpressionPosition++;
+ }
+ else if (StarFound != MAXUSHORT)
+ {
+ ExpressionPosition = StarFound + 1;
+ while ((IgnoreCase ? UpcaseTable[Name->Buffer[NamePosition]] :
Name->Buffer[NamePosition]) != Expression->Buffer[ExpressionPosition] &&
+ NamePosition < Name->Length / sizeof(WCHAR))
+ {
+ NamePosition++;
+ }
}
else
{