static int stringCompare(final char[] c1,int p1,final char[] c2,int p2){
  if (p1 == c1.length) {
    return 0;
  }
  final int l1=c1.length;
  final int l2=c2.length;
  while (p1 < l1 && p2 < l2) {
    boolean escaped=false;
    if (c1[p1] == c2[p2]) {
      p1++;
      p2++;
      continue;
    }
    if (c1[p1] == '\\') {
      p1++;
      escaped=true;
    }
    if (c1[p1] == '*' && !escaped) {
      p1++;
      do {
        if (stringCompare(c1,p1,c2,p2) == 0) {
          return 0;
        }
        p2++;
      }
 while (l2 - p2 > -1);
      return 1;
    }
 else {
      if (c1[p1] < c2[p2]) {
        return -1;
      }
 else       if (c1[p1] > c2[p2]) {
        return 1;
      }
    }
  }
  if (p2 == l2 && c1[p1 - 1] == c2[p2 - 1] && (p1 == l1 || p1 == l1 - 1 && c1[p1] == '*')) {
    return 0;
  }
  if (p1 > 0 && c1[p1 - 1] == '*' && p1 == l1 && p2 == l2) {
    return 0;
  }
  final int min=l1 < l2 ? l1 : l2;
  return l1 == min ? -1 : 1;
}

static int stringCompare ( final char [ ] c1 , int p1 , final char [ ] c2 , int p2 ) { if ( p1 == c1 . length ) { return 0 ; } final int l1 = c1 . length ; final int l2 = c2 . length ; while ( p1 < l1 && p2 < l2 ) { boolean escaped = false ; if ( c1 [ p1 ] == c2 [ p2 ] ) { p1 ++ ; p2 ++ ; continue ; } if ( c1 [ p1 ] == '\\' ) { p1 ++ ; escaped = true ; } if ( c1 [ p1 ] == '*' && ! escaped ) { p1 ++ ; do { if ( stringCompare ( c1 , p1 , c2 , p2 ) == 0 ) { return 0 ; } p2 ++ ; } while ( l2 - p2 > - 1 ) ; return 1 ; } else { if ( c1 [ p1 ] < c2 [ p2 ] ) { return - 1 ; } else if ( c1 [ p1 ] > c2 [ p2 ] ) { return 1 ; } } } if ( p2 == l2 && c1 [ p1 - 1 ] == c2 [ p2 - 1 ] && ( p1 == l1 || p1 == l1 - 1 && c1 [ p1 ] == '*' ) ) { return 0 ; } if ( p1 > 0 && c1 [ p1 - 1 ] == '*' && p1 == l1 && p2 == l2 ) { return 0 ; } final int min = l1 < l2 ? l1 : l2 ; return l1 == min ? - 1 : 1 ; }
check , if a value matches a wildcard expression .
