bfile_heuristics.c

changeset 23
778388400f7b
parent 22
4508da679ffb
     1.1 --- a/bfile_heuristics.c	Thu Oct 20 17:29:23 2011 +0200
     1.2 +++ b/bfile_heuristics.c	Fri Oct 21 15:09:26 2011 +0200
     1.3 @@ -32,20 +32,23 @@
     1.4        def->bcount++;
     1.5      }
     1.6  
     1.7 -    switch (def->level) {
     1.8 -    case BFILE_LOW_ACCURACY:
     1.9 -      if (def->tcount > 15 || next_char == EOF) {
    1.10 -        ret = (1.0*def->bcount)/def->tcount > 0.32;
    1.11 -      }
    1.12 -      break;
    1.13 -    case BFILE_HIGH_ACCURACY:
    1.14 -      if (def->tcount > 500 || next_char == EOF) {
    1.15 -        ret = (1.0*def->bcount)/def->tcount > 0.1;
    1.16 -      }
    1.17 -      break;
    1.18 -    default: /* BFILE_MEDIUM_ACCURACY */
    1.19 -      if (def->tcount > 100 || next_char == EOF) {
    1.20 -        ret = (1.0*def->bcount)/def->tcount > 0.1;
    1.21 +    if (def->tcount > 1) { /* empty files are text files */
    1.22 +      switch (def->level) {
    1.23 +      case BFILE_LOW_ACCURACY:
    1.24 +        if (def->tcount > 15 || next_char == EOF) {
    1.25 +          ret = (1.0*def->bcount)/def->tcount > 0.32;
    1.26 +        }
    1.27 +        break;
    1.28 +      case BFILE_HIGH_ACCURACY:
    1.29 +        if (def->tcount > 500 || next_char == EOF) {
    1.30 +          ret = (1.0*def->bcount)/def->tcount > 0.1;
    1.31 +        }
    1.32 +        break;
    1.33 +      default: /* BFILE_MEDIUM_ACCURACY */
    1.34 +        if (def->tcount > 100 || next_char == EOF) {
    1.35 +          ret = (1.0*def->bcount)/def->tcount > 0.1;
    1.36 +        }
    1.37 +        break;
    1.38        }
    1.39      }
    1.40    }

mercurial