68 main (
int argc, 
char *argv[])
 
   77    char *infile=
"", *outfile=
"";  
 
   86                         int cstart, 
int cend, 
char *coverstring);
 
   88    if ((coveragefp = fopen (
"coverage.dat", 
"r")) == NULL) {
 
   89       fprintf (stderr, 
"\nError: data file \"coverage.dat\" not found.\n\n");
 
   94       for (i = 1; i < argc; i++) {
 
   95          if (argv[i][0] == 
'-') {  
 
  103                   outfile = &argv[i][2];
 
  106                   fprintf (stderr, 
"\nSyntax:\n\n");
 
  107                   fprintf (stderr, 
"   %s -p<Unicode_Page> ", argv[0]);
 
  108                   fprintf (stderr, 
"-i<Input_File> -o<Output_File> -w\n\n");
 
  118    if (strlen (infile) > 0) {
 
  119       if ((infp = fopen (infile, 
"r")) == NULL) {
 
  120          fprintf (stderr, 
"Error: can't open %s for input.\n", infile);
 
  127    if (strlen (outfile) > 0) {
 
  128       if ((outfp = fopen (outfile, 
"w")) == NULL) {
 
  129          fprintf (stderr, 
"Error: can't open %s for output.\n", outfile);
 
  141       fprintf (outfp, 
"# Glyphs      Range        Script\n");
 
  142       fprintf (outfp, 
"--------      -----        ------\n");
 
  145       fprintf (outfp, 
"Covered      Range        Script\n");
 
  146       fprintf (outfp, 
"-------      -----        ------\n\n");
 
  149    slen = 
nextrange (coveragefp, &cstart, &cend, coverstring);
 
  155    while (slen != 0 && fgets (inbuf, 
MAXBUF-1, infp) != NULL) {
 
  156       sscanf (inbuf, 
"%x", &thischar);
 
  159       while (cend < thischar && slen != 0) {
 
  160          print_subtotal (outfp, print_n, nglyphs, cstart, cend, coverstring);
 
  163          slen = 
nextrange (coveragefp, &cstart, &cend, coverstring);
 
  169    print_subtotal (outfp, print_n, nglyphs, cstart, cend, coverstring);
 
  188               int *cstart, 
int *cend,
 
  192    static char inbuf[
MAXBUF];
 
  198       if (fgets (inbuf, 
MAXBUF-1, coveragefp) != NULL) {
 
  199          retval = strlen (inbuf);
 
  200          if ((inbuf[0] >= 
'0' && inbuf[0] <= 
'9') ||
 
  201              (inbuf[0] >= 
'A' && inbuf[0] <= 
'F') ||
 
  202              (inbuf[0] >= 
'a' && inbuf[0] <= 
'f')) {
 
  203             sscanf (inbuf, 
"%x-%x", cstart, cend);
 
  205             while (inbuf[i] != 
' ') i++;  
 
  206             while (inbuf[i] == 
' ') i++;  
 
  207             strncpy (coverstring, &inbuf[i], 
MAXBUF);
 
  212    } 
while (retval == 0 && !feof (coveragefp));
 
  229                      int cstart, 
int cend, 
char *coverstring) {
 
  233       fprintf (outfp, 
" %6d ", nglyphs);
 
  236       fprintf (outfp, 
" %5.1f%%", 100.0*nglyphs/(1+cend-cstart));
 
  240       fprintf (outfp, 
"  U+%04X..U+%04X   %s",
 
  241                cstart, cend, coverstring);
 
  243       fprintf (outfp, 
" U+%05X..U+%05X  %s",
 
  244                cstart, cend, coverstring);
 
int main(int argc, char *argv[])
The main function.
void print_subtotal(FILE *outfp, int print_n, int nglyphs, int cstart, int cend, char *coverstring)
Print the subtotal for one Unicode script range.
#define MAXBUF
Maximum input line length - 1.
int nextrange(FILE *coveragefp, int *cstart, int *cend, char *coverstring)
Get next Unicode range.