71main (
int argc, 
char *argv[])
 
   80   char *infile=
"", *outfile=
"";  
 
   88   int nextrange (FILE *coveragefp, 
int *cstart, 
int *cend, 
char *coverstring);
 
   91                        int cstart, 
int cend, 
char *coverstring);
 
   93   if ((coveragefp = fopen (
"coverage.dat", 
"r")) == NULL) {
 
   94      fprintf (stderr, 
"\nError: data file \"coverage.dat\" not found.\n\n");
 
   99      for (i = 1; i < argc; i++) {
 
  100         if (argv[i][0] == 
'-') {  
 
  101            switch (argv[i][1]) {
 
  103                  infile = &argv[i][2];
 
  108                  outfile = &argv[i][2];
 
  111                  fprintf (stderr, 
"\nSyntax:\n\n");
 
  112                  fprintf (stderr, 
"   %s -p<Unicode_Page> ", argv[0]);
 
  113                  fprintf (stderr, 
"-i<Input_File> -o<Output_File> -w\n\n");
 
  123   if (strlen (infile) > 0) {
 
  124      if ((infp = fopen (infile, 
"r")) == NULL) {
 
  125         fprintf (stderr, 
"Error: can't open %s for input.\n", infile);
 
  132   if (strlen (outfile) > 0) {
 
  133      if ((outfp = fopen (outfile, 
"w")) == NULL) {
 
  134         fprintf (stderr, 
"Error: can't open %s for output.\n", outfile);
 
  146      fprintf (outfp, 
"# Glyphs      Range        Script\n");
 
  147      fprintf (outfp, 
"--------      -----        ------\n");
 
  150      fprintf (outfp, 
"Covered      Range        Script\n");
 
  151      fprintf (outfp, 
"-------      -----        ------\n\n");
 
  154   slen = 
nextrange (coveragefp, &cstart, &cend, coverstring);
 
  160   while (slen != 0 && fgets (inbuf, 
MAXBUF-1, infp) != NULL) {
 
  161      sscanf (inbuf, 
"%x", &thischar);
 
  164      while (cend < thischar && slen != 0) {
 
  165         print_subtotal (outfp, print_n, nglyphs, cstart, cend, coverstring);
 
  168         slen = 
nextrange (coveragefp, &cstart, &cend, coverstring);
 
  174   print_subtotal (outfp, print_n, nglyphs, cstart, cend, coverstring);
 
  193              int *cstart, 
int *cend,
 
  197   static char inbuf[
MAXBUF];
 
  203      if (fgets (inbuf, 
MAXBUF-1, coveragefp) != NULL) {
 
  204         retval = strlen (inbuf);
 
  205         if ((inbuf[0] >= 
'0' && inbuf[0] <= 
'9') ||
 
  206             (inbuf[0] >= 
'A' && inbuf[0] <= 
'F') ||
 
  207             (inbuf[0] >= 
'a' && inbuf[0] <= 
'f')) {
 
  208            sscanf (inbuf, 
"%x-%x", cstart, cend);
 
  210            while (inbuf[i] != 
' ') i++;  
 
  211            while (inbuf[i] == 
' ') i++;  
 
  212            strncpy (coverstring, &inbuf[i], 
MAXBUF);
 
  217   } 
while (retval == 0 && !feof (coveragefp));
 
  234                     int cstart, 
int cend, 
char *coverstring) {
 
  238      fprintf (outfp, 
" %6d ", nglyphs);
 
  241      fprintf (outfp, 
" %5.1f%%", 100.0*nglyphs/(1+cend-cstart));
 
  245      fprintf (outfp, 
"  U+%04X..U+%04X   %s",
 
  246               cstart, cend, coverstring);
 
  248      fprintf (outfp, 
" U+%05X..U+%05X  %s",
 
  249               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.