(file) Return to Match.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Executor

Diff for /pegasus/src/Executor/Match.h between version 1.2 and 1.3

version 1.2, 2007/05/25 18:35:07 version 1.3, 2007/11/30 01:16:32
Line 36 
Line 36 
  
 #include "Defines.h" #include "Defines.h"
  
 EXECUTOR_LINKAGE  static int Match(const char* pattern, const char* str)
 int Match(const char* pattern, const char* str);  {
       const char* p;
       const char* q;
   
       /* Now match expression to str. */
   
       for (p = pattern, q = str; *p && *q; )
       {
           if (*p == '*')
           {
               const char* r;
   
               p++;
   
               /* Recursively call to find the shortest match. */
   
               for (r = q; *r; r++)
               {
                   if (Match(p, r) == 0)
                       break;
               }
   
               q = r;
   
           }
           else if (*p == *q)
           {
               p++;
               q++;
           }
           else
               return -1;
       }
   
       /* If src was exhausted but pattern has a single '*' remaining charcters,
        * then match the result.
        */
   
       if (p[0] == '*' && p[1] == '\0')
           return 0;
   
       /* If anything left over, then they do not match. */
   
       if (*p || *q)
           return -1;
   
       return 0;
   }
  
 #endif /* _Executor_Match_h */ #endif /* _Executor_Match_h */


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2