[NTOSKRNL]
authorPierre Schweitzer <pierre@reactos.org>
Mon, 13 Dec 2010 11:33:29 +0000 (11:33 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Mon, 13 Dec 2010 11:33:29 +0000 (11:33 +0000)
Merge some changes from r50021 to FsRtlIsNameInExpression() to make code easier to read and understand...

svn path=/trunk/; revision=50022

reactos/ntoskrnl/fsrtl/name.c

index a930117..fc4d740 100644 (file)
@@ -22,63 +22,63 @@ FsRtlIsNameInExpressionPrivate(IN PUNICODE_STRING Expression,
                                IN BOOLEAN IgnoreCase,
                                IN PWCHAR UpcaseTable OPTIONAL)
 {
-    ULONG i = 0, j, k = 0;
+    USHORT ExpressionPosition = 0, NamePosition = 0, MatchingChars;
     PAGED_CODE();
 
     ASSERT(!IgnoreCase || UpcaseTable);
 
-    while (i < Name->Length / sizeof(WCHAR) && k < Expression->Length / sizeof(WCHAR))
+    while (NamePosition < Name->Length / sizeof(WCHAR) && ExpressionPosition < Expression->Length / sizeof(WCHAR))
     {
-        if ((Expression->Buffer[k] == (IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i])) ||
-            (Expression->Buffer[k] == L'?') || (Expression->Buffer[k] == DOS_QM) ||
-            (Expression->Buffer[k] == DOS_DOT && Name->Buffer[i] == L'.'))
+        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'.'))
         {
-            i++;
-            k++;
+            NamePosition++;
+            ExpressionPosition++;
         }
-        else if (Expression->Buffer[k] == L'*')
+        else if (Expression->Buffer[ExpressionPosition] == L'*')
         {
-            if (k < (Expression->Length / sizeof(WCHAR) - 1))
+            if (ExpressionPosition < (Expression->Length / sizeof(WCHAR) - 1))
             {
-                if (Expression->Buffer[k+1] != L'*' && Expression->Buffer[k+1] != L'?' &&
-                    Expression->Buffer[k+1] != DOS_DOT && Expression->Buffer[k+1] != DOS_QM &&
-                    Expression->Buffer[k+1] != DOS_STAR)
+                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)
                 {
-                    while ((IgnoreCase ? UpcaseTable[Name->Buffer[i]] : Name->Buffer[i]) != Expression->Buffer[k+1] &&
-                           i < Name->Length / sizeof(WCHAR)) i++;
+                    while ((IgnoreCase ? UpcaseTable[Name->Buffer[NamePosition]] : Name->Buffer[NamePosition]) != Expression->Buffer[ExpressionPosition+1] &&
+                           NamePosition < Name->Length / sizeof(WCHAR)) NamePosition++;
                 }
             }
             else
             {
-                i = Name->Length / sizeof(WCHAR);
+                NamePosition = Name->Length / sizeof(WCHAR);
             }
-            k++;
+            ExpressionPosition++;
         }
-        else if (Expression->Buffer[k] == DOS_STAR)
+        else if (Expression->Buffer[ExpressionPosition] == DOS_STAR)
         {
-            j = i;
-            while (j < Name->Length / sizeof(WCHAR))
+            MatchingChars = NamePosition;
+            while (MatchingChars < Name->Length / sizeof(WCHAR))
             {
-                if (Name->Buffer[j] == L'.')
+                if (Name->Buffer[MatchingChars] == L'.')
                 {
-                    i = j;
+                    NamePosition = MatchingChars;
                 }
-                j++;
+                MatchingChars++;
             }
-            k++;
+            ExpressionPosition++;
         }
         else
         {
-            i = Name->Length / sizeof(WCHAR);
+            NamePosition = Name->Length / sizeof(WCHAR);
         }
     }
-    if (k + 1 == Expression->Length / sizeof(WCHAR) && i == Name->Length / sizeof(WCHAR) &&
-        Expression->Buffer[k] == DOS_DOT)
+    if (ExpressionPosition + 1 == Expression->Length / sizeof(WCHAR) && NamePosition == Name->Length / sizeof(WCHAR) &&
+        Expression->Buffer[ExpressionPosition] == DOS_DOT)
     {
-        k++;
+        ExpressionPosition++;
     }
 
-    return (k == Expression->Length / sizeof(WCHAR) && i == Name->Length / sizeof(WCHAR));
+    return (ExpressionPosition == Expression->Length / sizeof(WCHAR) && NamePosition == Name->Length / sizeof(WCHAR));
 }
 
 /* PUBLIC FUNCTIONS **********************************************************/