1: #include "bm.h"
   2: #include "Extern.h"
   3: int Search(Pattern,PatLen,Buffer, EndBuff, Skip1, Skip2, Desc)
   4: char Pattern[];
   5: int PatLen;
   6: char Buffer[];
   7: char *EndBuff;
   8: int Skip1[], Skip2[];
   9: struct PattDesc *Desc;
  10: {
  11:     register char *k, /* indexes text */
  12:         *j, /* indexes Pattern */
  13:         *PatBegin; /* register pointing to char
  14: 		* before beginning of Pattern */
  15:     register int Skip; /* skip distance */
  16:     char *PatEnd,
  17:     *BuffEnd; /* pointers to last char in Pattern and Buffer */
  18:     BuffEnd = EndBuff;
  19:     PatBegin = Pattern - 1;
  20:     PatEnd = Pattern + PatLen - 1;
  21: 
  22:     k = Desc->Start;
  23:     Skip = PatLen-1;
  24:     while ( Skip <= (BuffEnd - k) ) {
  25:         j = PatEnd;
  26:         k = k + Skip;
  27:         while (j > PatBegin && *j == *k) {
  28:             --j; --k;
  29:         } /* while */
  30:         if (j< Pattern) {
  31:             /* found it. Start next search
  32: 			* just after the pattern */
  33:             Desc -> Start = k + 1 + Desc->PatLen;
  34:             return(1);
  35:         } /* if */
  36:         Skip = max(Skip1[*(unsigned char *)k],Skip2[j-Pattern]);
  37:     } /* while */
  38:     Desc->Start = k;
  39:     return(0);
  40: } /* Search */

Defined functions

Search defined in line 3; used 2 times
Last modified: 1985-09-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2189
Valid CSS Valid XHTML 1.0 Strict