public int search(byte text[], int start, int length)
   {
      int textLen = length + start;
      partial = -1;   // assume no partial match

      if (d == null)
         return -1;   // no pattern compiled, nothing matches.

      int m = patLen;
      if (m == 0)
         return 0;

      int k, j = 0;
      int max = 0;   // used in calculation of partial match. Max distand we jumped.

      for (k = start + m - 1; k < textLen;)
      {
         for (j = m - 1; j >= 0 && text[k] == pat[j]; j--)
            k--;

         if (j == -1)
            return k + 1;

         int z = skip[text[k]];
         max = (z > d[j]) ? z : d[j];
         k += max;
      }

      if (k >= textLen && j > 0)   // if we're near end of buffer --
      {
         partial = k - max - 1;

         return -1;   // not a real match
      }

      return -1;   // No match
   }