| 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 |
* Gripes having to do with DVI files. |
| 25 |
*/ |
| 26 |
|
| 27 |
#include "types.h" |
| 28 |
#include "error.h" |
| 29 |
#include "font.h" |
| 30 |
#include "gripes.h" |
| 31 |
#include <stdio.h> |
| 32 |
|
| 33 |
static const char * |
| 34 |
dfn(void) |
| 35 |
{ |
| 36 |
|
| 37 |
return (DVIFileName ? DVIFileName : "the input"); |
| 38 |
} |
| 39 |
|
| 40 |
/* |
| 41 |
* Save string space by declaring these here. |
| 42 |
*/ |
| 43 |
#if __STDC__ >= 1 |
| 44 |
static const char dfl[] = "DVI file"; |
| 45 |
static const char areyousure[] = "(are you sure %s is a %s?)"; |
| 46 |
#else |
| 47 |
static char dfl[] = "DVI file"; |
| 48 |
static char areyousure[] = "(are you sure %s is a %s?)"; |
| 49 |
#endif |
| 50 |
|
| 51 |
/* |
| 52 |
* DVI file requests a font it never defined. |
| 53 |
*/ |
| 54 |
void |
| 55 |
GripeNoSuchFont(i32 n) |
| 56 |
{ |
| 57 |
|
| 58 |
error(0, 0, "%s wants font %ld, which it never defined", dfl, (long)n); |
| 59 |
error(1, 0, areyousure, dfn(), dfl); |
| 60 |
/* NOTREACHED */ |
| 61 |
} |
| 62 |
|
| 63 |
/* |
| 64 |
* DVI file redefines a font. |
| 65 |
*/ |
| 66 |
void |
| 67 |
GripeFontAlreadyDefined(i32 n) |
| 68 |
{ |
| 69 |
|
| 70 |
error(0, 0, "%s redefines font %ld", dfl, n); |
| 71 |
error(1, 0, areyousure, dfn(), dfl); |
| 72 |
/* NOTREACHED */ |
| 73 |
} |
| 74 |
|
| 75 |
/* |
| 76 |
* Unexpected end of DVI file. |
| 77 |
*/ |
| 78 |
void |
| 79 |
GripeUnexpectedDVIEOF(void) |
| 80 |
{ |
| 81 |
|
| 82 |
GripeUnexpectedOp("end of file"); |
| 83 |
/* NOTREACHED */ |
| 84 |
} |
| 85 |
|
| 86 |
/* |
| 87 |
* Unexpected DVI opcode. |
| 88 |
*/ |
| 89 |
void |
| 90 |
GripeUnexpectedOp(const char *s) |
| 91 |
{ |
| 92 |
|
| 93 |
error(0, 0, "unexpected %s in %s", s, dfl); |
| 94 |
error(1, 0, areyousure, dfn(), dfl); |
| 95 |
/* NOTREACHED */ |
| 96 |
} |
| 97 |
|
| 98 |
/* |
| 99 |
* Missing DVI opcode. |
| 100 |
*/ |
| 101 |
void |
| 102 |
GripeMissingOp(const char *s) |
| 103 |
{ |
| 104 |
|
| 105 |
error(0, 0, "missing %s in %s", s, dfl); |
| 106 |
error(1, 0, areyousure, dfn(), dfl); |
| 107 |
/* NOTREACHED */ |
| 108 |
} |
| 109 |
|
| 110 |
/* |
| 111 |
* Cannot find DVI postamble. |
| 112 |
*/ |
| 113 |
void |
| 114 |
GripeCannotFindPostamble(void) |
| 115 |
{ |
| 116 |
|
| 117 |
error(0, 0, "cannot find postamble"); |
| 118 |
error(1, 0, areyousure, dfn(), dfl); |
| 119 |
/* NOTREACHED */ |
| 120 |
} |
| 121 |
|
| 122 |
/* |
| 123 |
* Inconsistent DVI value. |
| 124 |
*/ |
| 125 |
void |
| 126 |
GripeMismatchedValue(const char *s) |
| 127 |
{ |
| 128 |
|
| 129 |
error(0, 0, "mismatched %s in %s", s, dfl); |
| 130 |
error(1, 0, areyousure, dfn(), dfl); |
| 131 |
/* NOTREACHED */ |
| 132 |
} |
| 133 |
|
| 134 |
/* |
| 135 |
* Undefined DVI opcode. |
| 136 |
*/ |
| 137 |
void |
| 138 |
GripeUndefinedOp(int n) |
| 139 |
{ |
| 140 |
|
| 141 |
error(0, 0, "undefined DVI opcode %d", n); |
| 142 |
error(1, 0, areyousure, dfn(), dfl); |
| 143 |
/* NOTREACHED */ |
| 144 |
} |
| 145 |
|
| 146 |
/* |
| 147 |
* DVI file requests glyph that is not in some font, or |
| 148 |
* when no font is set for this page. |
| 149 |
* |
| 150 |
* RETURNS TO CALLER |
| 151 |
*/ |
| 152 |
void |
| 153 |
GripeBadGlyph(i32 c, struct font *f) |
| 154 |
{ |
| 155 |
|
| 156 |
if (f->f_path == NULL) { |
| 157 |
error(0, 0, "bad %s: char without setfont", dfl); |
| 158 |
error(1, 0, "(try checking %s with dvitype)", dfn()); |
| 159 |
/* NOTREACHED */ |
| 160 |
} |
| 161 |
error(0, 0, "there is no character %ld in %s!", (long)c, f->f_path); |
| 162 |
} |