bfile_heuristics.c

changeset 23
778388400f7b
parent 22
4508da679ffb
equal deleted inserted replaced
22:4508da679ffb 23:778388400f7b
30 def->tcount++; 30 def->tcount++;
31 if (!isprint(next_char) && !isspace(next_char)) { 31 if (!isprint(next_char) && !isspace(next_char)) {
32 def->bcount++; 32 def->bcount++;
33 } 33 }
34 34
35 switch (def->level) { 35 if (def->tcount > 1) { /* empty files are text files */
36 case BFILE_LOW_ACCURACY: 36 switch (def->level) {
37 if (def->tcount > 15 || next_char == EOF) { 37 case BFILE_LOW_ACCURACY:
38 ret = (1.0*def->bcount)/def->tcount > 0.32; 38 if (def->tcount > 15 || next_char == EOF) {
39 } 39 ret = (1.0*def->bcount)/def->tcount > 0.32;
40 break; 40 }
41 case BFILE_HIGH_ACCURACY: 41 break;
42 if (def->tcount > 500 || next_char == EOF) { 42 case BFILE_HIGH_ACCURACY:
43 ret = (1.0*def->bcount)/def->tcount > 0.1; 43 if (def->tcount > 500 || next_char == EOF) {
44 } 44 ret = (1.0*def->bcount)/def->tcount > 0.1;
45 break; 45 }
46 default: /* BFILE_MEDIUM_ACCURACY */ 46 break;
47 if (def->tcount > 100 || next_char == EOF) { 47 default: /* BFILE_MEDIUM_ACCURACY */
48 ret = (1.0*def->bcount)/def->tcount > 0.1; 48 if (def->tcount > 100 || next_char == EOF) {
49 ret = (1.0*def->bcount)/def->tcount > 0.1;
50 }
51 break;
49 } 52 }
50 } 53 }
51 } 54 }
52 55
53 return ret; 56 return ret;

mercurial