Debian Codegraph @

texk/seetexk/gripes0.c

raw
1 /* Copyright (c) 1987, 1989, 2012 University of Maryland Department of
2 Computer Science.
3
4 Permission is hereby granted, free of charge, to any person obtaining
5 a copy of this software and associated documentation files (the
6 "Software"), to deal in the Software without restriction, including
7 without limitation, the rights to use, copy, modify, merge, publish,
8 distribute, sublicense, and/or sell copies of the Software, and to
9 permit persons to whom the Software is furnished to do so, subject to
10 the following conditions: The above copyright notice, this permission
11 notice and the disclaimer statement shall be included in all copies
12 or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23 /*
24 * Common errors (`gripes').
25 */
26
27 #include "types.h"
28 #include "error.h"
29 #include "gripes.h"
30 #include <stdio.h>
31
32 #ifndef WIN32
33 extern int errno;
34 #endif
35
36 /*
37 * Cannot allocate memory.
38 */
39 void
40 GripeOutOfMemory(int n, const char *why)
41 {
42
43 error(1, -1, "ran out of memory allocating %d bytes for %s", n, why);
44 /* NOTREACHED */
45 }
46
47 /*
48 * Cannot get a font.
49 * RETURNS TO CALLER
50 */
51 void
52 GripeCannotGetFont(const char *name, i32 mag, i32 dsz, const char *dev, const char *fullname)
53 {
54 int e = errno;
55 char scale[40];
56
57 if (mag == dsz) /* no scaling */
58 scale[0] = 0;
59 else
60 (void) sprintf(scale, " scaled %d",
61 (int) ((double) mag / (double) dsz * 1000.0 + .5));
62
63 error(0, e, "no font for %s%s", name, scale);
64 if (fullname)
65 error(0, 0, "(wanted, e.g., \"%s\")", fullname);
66 else {
67 if (dev)
68 error(1, 0, "(there are no fonts for the %s engine!)",
69 dev);
70 else
71 error(1, 0, "(I cannot find any fonts!)");
72 /* NOTREACHED */
73 }
74 }
75
76 /*
77 * Font checksums do not match.
78 * RETURNS TO CALLER
79 */
80 void
81 GripeDifferentChecksums(const char *font, i32 tfmsum, i32 fontsum)
82 {
83
84 error(0, 0, "\
85 WARNING: TeX and I have different checksums for font\n\
86 \t\"%s\"\n\
87 \tPlease notify your TeX maintainer\n\
88 \t(TFM checksum = 0%lo, my checksum = 0%lo)",
89 font, (long)tfmsum, (long)fontsum);
90 }
91
92 /*
93 * A font, or several fonts, are missing, so no output.
94 */
95 void
96 GripeMissingFontsPreventOutput(int n)
97 {
98 static char s[2] = {'s', 0};
99
100 error(1, 0, "%d missing font%s prevent%s output (sorry)", n,
101 n > 1 ? s : &s[1], n == 1 ? s : &s[1]);
102 /* NOTREACHED */
103 }