74main (
int argc,
char *argv[])
83 char *infile=
"", *outfile=
"";
86 unsigned cstart, cend;
91 int nextrange (FILE *coveragefp,
unsigned *cstart,
unsigned *cend,
95 unsigned cstart,
unsigned cend,
char *coverstring);
97 if ((coveragefp = fopen (
"coverage.dat",
"r")) == NULL) {
98 fprintf (stderr,
"\nError: data file \"coverage.dat\" not found.\n\n");
103 for (i = 1; i < argc; i++) {
104 if (argv[i][0] ==
'-') {
105 switch (argv[i][1]) {
107 infile = &argv[i][2];
112 outfile = &argv[i][2];
115 fprintf (stderr,
"\nSyntax:\n\n");
116 fprintf (stderr,
" %s -p<Unicode_Page> ", argv[0]);
117 fprintf (stderr,
"-i<Input_File> -o<Output_File> -w\n\n");
127 if (strlen (infile) > 0) {
128 if ((infp = fopen (infile,
"r")) == NULL) {
129 fprintf (stderr,
"Error: can't open %s for input.\n", infile);
136 if (strlen (outfile) > 0) {
137 if ((outfp = fopen (outfile,
"w")) == NULL) {
138 fprintf (stderr,
"Error: can't open %s for output.\n", outfile);
150 fprintf (outfp,
"# Glyphs Range Script\n");
151 fprintf (outfp,
"-------- ----- ------\n");
154 fprintf (outfp,
"Covered Range Script\n");
155 fprintf (outfp,
"------- ----- ------\n\n");
158 slen =
nextrange (coveragefp, &cstart, &cend, coverstring);
164 while (slen != 0 && fgets (inbuf,
MAXBUF-1, infp) != NULL) {
165 sscanf (inbuf,
"%x", &thischar);
168 while (cend < thischar && slen != 0) {
169 print_subtotal (outfp, print_n, nglyphs, cstart, cend, coverstring);
172 slen =
nextrange (coveragefp, &cstart, &cend, coverstring);
178 print_subtotal (outfp, print_n, nglyphs, cstart, cend, coverstring);
197 unsigned *cstart,
unsigned *cend,
201 static char inbuf[
MAXBUF];
207 if (fgets (inbuf,
MAXBUF-1, coveragefp) != NULL) {
208 retval = strlen (inbuf);
209 if ((inbuf[0] >=
'0' && inbuf[0] <=
'9') ||
210 (inbuf[0] >=
'A' && inbuf[0] <=
'F') ||
211 (inbuf[0] >=
'a' && inbuf[0] <=
'f')) {
212 sscanf (inbuf,
"%x-%x", cstart, cend);
214 while (inbuf[i] !=
' ') i++;
215 while (inbuf[i] ==
' ') i++;
216 strncpy (coverstring, &inbuf[i],
MAXBUF);
221 }
while (retval == 0 && !feof (coveragefp));
238 unsigned cstart,
unsigned cend,
char *coverstring) {
242 fprintf (outfp,
" %6d ", nglyphs);
245 fprintf (outfp,
" %5.1f%%", 100.0*nglyphs/(1+cend-cstart));
249 fprintf (outfp,
" U+%04X..U+%04X %s",
250 cstart, cend, coverstring);
252 fprintf (outfp,
" U+%05X..U+%05X %s",
253 cstart, cend, coverstring);
int main(void)
The main function.
void print_subtotal(FILE *outfp, int print_n, int nglyphs, unsigned cstart, unsigned cend, char *coverstring)
Print the subtotal for one Unicode script range.
#define MAXBUF
Maximum input line length - 1.
int nextrange(FILE *coveragefp, unsigned *cstart, unsigned *cend, char *coverstring)
Get next Unicode range.