#include #include #include long count[1<<16]; Biobuf bout; void freq(int, char*); long flag; enum { Fdec = 1<<0, Fhex = 1<<1, Foct = 1<<2, Fchar = 1<<3, Frune = 1<<4, }; void main(int argc, char *argv[]) { int f, i; flag = 0; Binit(&bout, 1, OWRITE); ARGBEGIN{ default: fprint(2, "freq: unknown option %c\n", ARGC()); exits("usage"); case 'd': flag |= Fdec; break; case 'x': flag |= Fhex; break; case 'o': flag |= Foct; break; case 'c': flag |= Fchar; break; case 'r': flag |= Frune; break; }ARGEND if((flag&(Fdec|Fhex|Foct|Fchar)) == 0) flag |= Fdec | Fhex | Foct | Fchar; if(argc < 1) { freq(0, "-"); exits(0); } for(i=0; i= 0x7f && i < 0xa0 || i > 0xff && !(flag & Frune)) Bprint(&bout, "- "); else Bprint(&bout, "%C ", i); } Bprint(&bout, "%8ld\n", count[i]); } Bflush(&bout); }