Example #1
0
/*----------------------------------------------------------------------
 *	Check the validity of a word break in the backward direction
 *----------------------------------------------------------------------*/
static int check_rbreak(Word *word, int pos)
{
  int ok = FALSE;
  char rtext[MAXLEN+1];
  int i;
  revncpy(rtext, word->chars, pos);
  if (pos == 1 || use_head(rtext, pos)) {
    ok = TRUE;
  }
  for (i=pos-1; i >= 0; i--) {
    if (ISBREAK(word,i)) {
      revncpy(rtext, word->chars+i, pos-i);
      if (use_word(rtext)) {
	ok = TRUE;
      }
    }
  }
  return ok;
}
Example #2
0
/*----------------------------------------------------------------------
 *	Check the validity of a word break in the forward direction
 *----------------------------------------------------------------------*/
static int check_break(Word *word, int pos)
{
  int ok = FALSE;
  char rtext[MAXLEN+1];
  int tlen = word->len - pos;
  int i;
  revncpy(rtext, word->chars+pos, tlen);
  if (tlen == 1 || use_tail(rtext+tlen, tlen)) {
    ok = TRUE;
  }
  for (i=pos+1; i <= word->len; i++) {
    if (ISBREAK(word,i)) {
      revncpy(rtext, word->chars+pos, i-pos);
      if (use_word(rtext)) {
	ok = TRUE;
      }
    }
  }
  return ok;
}
Example #3
0
int main()
{
    FILE *f = fopen("times.log", "rt");
    if (!f)
        return 1;

    char lines[0xffff][64] = {0};

    int n = 0;
    float mintime=0.0f, maxtime=0.0f;
    char rev[10] = {0};
    char line[128] = {0};

    while (fgets(line,sizeof(line),f) && n < (sizeof(lines)/sizeof(*lines))) {
        if (strncmp(line,"HEAD is now at ", 15) == 0) {
            if (rev[0])
                sprintf(lines[n++],"%s\t%.1f\t%.1f", rev, mintime, maxtime);
            revncpy(rev, line+15, sizeof(rev)-1);
            mintime = 0.0f;
            maxtime = 0.0f;
        }
        if (strncmp(line,"Overall time:",13)==0) {
            float time = atof(line+14);
            if (mintime < 0.1f || time < mintime)
                mintime = time;
            if (time > maxtime)
                maxtime = time;
        }
    }

    while (n > 0)
        printf("%s\n", lines[--n]);

    fclose(f);
    return 0;
}