[NTOSKRNL]

Rewritten FsRtlIsDbcsInExpression() using FsRtlIsNameInExpression() pattern.
This fixes all failing tests from kmtest.sys and make this function definitely tastier to MS fastfat.sys

svn path=/trunk/; revision=50021
This commit is contained in:
Pierre Schweitzer 2010-12-13 11:24:52 +00:00
parent 2fed6b5925
commit 435cdd8c49

View file

@ -160,55 +160,66 @@ NTAPI
FsRtlIsDbcsInExpression(IN PANSI_STRING Expression, FsRtlIsDbcsInExpression(IN PANSI_STRING Expression,
IN PANSI_STRING Name) IN PANSI_STRING Name)
{ {
ULONG ExpressionPosition, NamePosition, MatchingChars = 0; USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars;
PAGED_CODE(); PAGED_CODE();
ASSERT(Name->Length); ASSERT(Name->Length);
ASSERT(Expression->Length); ASSERT(Expression->Length);
ASSERT(!FsRtlDoesDbcsContainWildCards(Name)); ASSERT(!FsRtlDoesDbcsContainWildCards(Name));
/* One can't be null, both can be */ while (NamePosition < Name->Length && ExpressionPosition < Expression->Length)
if (!Expression->Length || !Name->Length)
{ {
return !(Expression->Length ^ Name->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] == '.'))
for (ExpressionPosition = 0; ExpressionPosition < Expression->Length; ExpressionPosition++)
{ {
if ((Expression->Buffer[ExpressionPosition] == Name->Buffer[MatchingChars]) || NamePosition++;
(Expression->Buffer[ExpressionPosition] == '?') || ExpressionPosition++;
(Expression->Buffer[ExpressionPosition] == ANSI_DOS_QM) ||
(Expression->Buffer[ExpressionPosition] == ANSI_DOS_DOT &&
(Name->Buffer[MatchingChars] == '.' || Name->Buffer[MatchingChars] == '0')))
{
MatchingChars++;
} }
else if (Expression->Buffer[ExpressionPosition] == '*') else if (Expression->Buffer[ExpressionPosition] == '*')
{ {
MatchingChars = Name->Length; if (ExpressionPosition < (Expression->Length - 1))
}
else if (Expression->Buffer[ExpressionPosition] == ANSI_DOS_STAR)
{ {
for (NamePosition = MatchingChars; NamePosition < Name->Length; NamePosition++) 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)
{ {
if (Name->Buffer[NamePosition] == '.') while (Name->Buffer[NamePosition] != Expression->Buffer[ExpressionPosition+1] &&
{ NamePosition < Name->Length) NamePosition++;
MatchingChars = NamePosition;
break;
}
} }
} }
else else
{ {
MatchingChars = 0; NamePosition = Name->Length;
} }
if (MatchingChars == Name->Length) ExpressionPosition++;
}
else if (Expression->Buffer[ExpressionPosition] == ANSI_DOS_STAR)
{ {
return TRUE; MatchingChars = NamePosition;
while (MatchingChars < Name->Length)
{
if (Name->Buffer[MatchingChars] == '.')
{
NamePosition = MatchingChars;
} }
MatchingChars++;
}
ExpressionPosition++;
}
else
{
NamePosition = Name->Length;
}
}
if (ExpressionPosition + 1 == Expression->Length && NamePosition == Name->Length &&
Expression->Buffer[ExpressionPosition] == ANSI_DOS_DOT)
{
ExpressionPosition++;
} }
return FALSE; return (ExpressionPosition == Expression->Length && NamePosition == Name->Length);
} }
/*++ /*++