GNU Unifont 17.0.01
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/*
35 6 September 2025 [Paul Hardy]:
36 - Changed iy from "int" to "unsigned" for compatibility with
37 sscanf definition.
38*/
39
40#include <stdio.h>
41#include <stdlib.h>
42
43#define MAXBUF 256 ///< Maximum input line length - 1
44
45
46/**
47 @brief The main function.
48
49 @param[in] argc The count of command line arguments.
50 @param[in] argv Pointer to array of command line arguments.
51 @return This program exits with status 0.
52*/
53int
54main (int argc, char **argv)
55{
56
57 int ix, iy; /* two code points to compare for equality */
58 char inbuf[MAXBUF];
59 char *infile; /* the input file name */
60 FILE *infilefp; /* file pointer to input file */
61
62 if (argc > 1) {
63 infile = argv[1];
64 if ((infilefp = fopen (infile, "r")) == NULL) {
65 fprintf (stderr, "\nERROR: Can't open file %s\n\n", infile);
66 exit (EXIT_FAILURE);
67 }
68 }
69 else {
70 infilefp = stdin;
71 }
72
73 ix = -1;
74
75 while (fgets (inbuf, MAXBUF-1, infilefp) != NULL) {
76 sscanf (inbuf, "%X", (unsigned *)&iy);
77 if (ix == iy) fprintf (stderr, "Duplicate code point: %04X\n", ix);
78 else ix = iy;
79 }
80 exit (0);
81}
int main(void)
The main function.
Definition: unibdf2hex.c:46
#define MAXBUF
Maximum input line length - 1.
Definition: unidup.c:43