コード例 #1
0
ファイル: kwset.c プロジェクト: ctSkennerton/fagrep
/* Search TEXT for a match of any member of the keyword set, KWS.
   Return the offset (into TEXT) of the first byte of the matching substring,
   or (size_t) -1 if no match is found.  Upon a match, store details in
   *KWSMATCH: index of matched keyword, start offset (same as the return
   value), and length.  */
size_t
kwsexec (kwset_t kws, char const *text, size_t size, struct kwsmatch *kwsmatch)
{
  struct kwset const *kwset = (struct kwset *) kws;
  if (kwset->words == 1 && kwset->trans == NULL)
    {
      size_t ret = bmexec (kws, text, size);
      if (ret != (size_t) -1)
        {
          kwsmatch->index = 0;
          kwsmatch->offset[0] = ret;
          kwsmatch->size[0] = kwset->mind;
        }
      return ret;
    }
  else
    return cwexec(kws, text, size, kwsmatch);
}
コード例 #2
0
ファイル: cw.c プロジェクト: pecorade/OS-Zero
/* virtual machine main loop */
void
cwloop(void)
{
    long pid = cwmars.curpid;

    while (cwmars.nturn[pid]--) {
        cwexec(pid);
        pid++;
        pid &= 0x01;
        cwmars.curpid = pid;
    }
    fprintf(stderr, "TIE\n");
#if defined(ZEUS)
    sleep(5);
#endif
    
    exit(0);
}