GNU Unifont: src/unidup.c Source File

GNU Unifont 15.1.02 Pan-Unicode font with complete Unicode Plane 0 coverage and partial coverage of higher planes

unidup.c
Go to the documentation of this file.
1/**
2 @file unidup.c
3
4 @brief unidup - Check for duplicate code points in sorted unifont.hex file
5
6 @author Paul Hardy, unifoundry <at> unifoundry.com, December 2007
7
8 @copyright Copyright (C) 2007, 2008, 2013 Paul Hardy
9
10 This program reads a sorted list of glyphs in Unifont .hex format
11 and prints duplicate code points on stderr if any were detected.
12
13 Synopsis: unidup < unifont_file.hex
14
15 [Hopefully there won't be any output!]
16*/
17/*
18 LICENSE:
19
20 This program is free software: you can redistribute it and/or modify
21 it under the terms of the GNU General Public License as published by
22 the Free Software Foundation, either version 2 of the License, or
23 (at your option) any later version.
24
25 This program is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 GNU General Public License for more details.
29
30 You should have received a copy of the GNU General Public License
31 along with this program. If not, see <http://www.gnu.org/licenses/>.
32*/
33
34#include <stdio.h>
35#include <stdlib.h>
36
37#define MAXBUF 256 ///< Maximum input line length - 1
38
39
40/**
41 @brief The main function.
42
43 @param[in] argc The count of command line arguments.
44 @param[in] argv Pointer to array of command line arguments.
45 @return This program exits with status 0.
46*/
47int
48main (int argc, char **argv)
49{
50
51 int ix, iy;
52 char inbuf[MAXBUF];
53 char *infile; /* the input file name */
54 FILE *infilefp; /* file pointer to input file */
55
56 if (argc > 1) {
57 infile = argv[1];
58 if ((infilefp = fopen (infile, "r")) == NULL) {
59 fprintf (stderr, "\nERROR: Can't open file %s\n\n", infile);
60 exit (EXIT_FAILURE);
61 }
62 }
63 else {
64 infilefp = stdin;
65 }
66
67 ix = -1;
68
69 while (fgets (inbuf, MAXBUF-1, infilefp) != NULL) {
70 sscanf (inbuf, "%X", &iy);
71 if (ix == iy) fprintf (stderr, "Duplicate code point: %04X\n", ix);
72 else ix = iy;
73 }
74 exit (0);
75}
main
int main(int argc, char **argv)
The main function.
Definition: unidup.c:48
MAXBUF
#define MAXBUF
Maximum input line length - 1.
Definition: unidup.c:37