| @@ -1,1009 +1,1006 @@ | | | @@ -1,1009 +1,1006 @@ |
1 | $NetBSD: patch-at,v 1.2.2.2 2008/05/08 14:21:48 rtr Exp $ | | 1 | $NetBSD: patch-at,v 1.2.2.3 2008/05/30 17:53:02 spz Exp $ |
2 | | | 2 | |
3 | --- texk/dviljk/dvi2xx.c | | 3 | --- texk/dviljk/dvi2xx.c |
4 | +++ texk/dviljk/dvi2xx.c | | 4 | +++ texk/dviljk/dvi2xx.c |
5 | @@ -2,4 +2,4 @@ | | 5 | @@ -2,1 +2,1 @@ |
6 | -#define VERSION "2.6p2 (dviljk)" | | 6 | -#define VERSION "2.6p2 (dviljk)" |
7 | +#define VERSION "dviljk (version 2.6p3)" | | 7 | +#define VERSION "dviljk (version 2.6p3)" |
8 | /* | | | |
9 | #define DEBUGGS 1 | | | |
10 | */ | | | |
11 | @@ -165,7 +165,7 @@ char *argv[]; | | 8 | @@ -165,7 +165,7 @@ char *argv[]; |
12 | # endif | | 9 | # endif |
13 | #endif | | 10 | #endif |
14 | | | 11 | |
15 | - /* Initialize pixel_files */ | | 12 | - /* Initialize pixel_files */ |
16 | + /* Initialize pixel_files */ | | 13 | + /* Initialize pixel_files */ |
17 | for (i = 0; i <= MAXOPEN; i++) | | 14 | for (i = 0; i <= MAXOPEN; i++) |
18 | pixel_files[i].pixel_file_id = FPNULL; | | 15 | pixel_files[i].pixel_file_id = FPNULL; |
19 | | | 16 | |
20 | @@ -173,7 +173,7 @@ char *argv[]; | | 17 | @@ -173,7 +173,7 @@ char *argv[]; |
21 | y_origin = YDEFAULTOFF; /* y-origin in dots */ | | 18 | y_origin = YDEFAULTOFF; /* y-origin in dots */ |
22 | | | 19 | |
23 | setbuf(ERR_STREAM, NULL); | | 20 | setbuf(ERR_STREAM, NULL); |
24 | - (void) strcpy(G_progname, argv[0]); | | 21 | - (void) strcpy(G_progname, argv[0]); |
25 | + G_progname = argv[0]; | | 22 | + G_progname = argv[0]; |
26 | #ifdef KPATHSEA | | 23 | #ifdef KPATHSEA |
27 | kpse_set_progname(argv[0]); | | 24 | kpse_set_progname(argv[0]); |
28 | kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile); | | 25 | kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile); |
29 | @@ -275,7 +275,7 @@ char *argv[]; | | 26 | @@ -275,7 +275,7 @@ char *argv[]; |
30 | EMIT1("@PJL SET PAGEPROTECT=OFF\012"); | | 27 | EMIT1("@PJL SET PAGEPROTECT=OFF\012"); |
31 | EMIT1("@PJL ENTER LANGUAGE=PCL\012"); | | 28 | EMIT1("@PJL ENTER LANGUAGE=PCL\012"); |
32 | if (econoMode && LJ6) | | 29 | if (econoMode && LJ6) |
33 | - EMIT1("@PJL SET ECONOMODE=ON\012"); | | 30 | - EMIT1("@PJL SET ECONOMODE=ON\012"); |
34 | + EMIT1("@PJL SET ECONOMODE=ON\012"); | | 31 | + EMIT1("@PJL SET ECONOMODE=ON\012"); |
35 | EMIT3("\033&u%dD\033*t%dR",RESOLUTION,RESOLUTION); | | 32 | EMIT3("\033&u%dD\033*t%dR",RESOLUTION,RESOLUTION); |
36 | if (econoMode && !LJ6) | | 33 | if (econoMode && !LJ6) |
37 | EMIT1("\033*v1T"); | | 34 | EMIT1("\033*v1T"); |
38 | @@ -431,8 +431,8 @@ char *argv[]; | | 35 | @@ -431,8 +431,8 @@ char *argv[]; |
39 | /* | | 36 | /* |
40 | fprintf(ERR_STREAM,"FirstPart\n count %d, mod %d, pp %d\n",(int)count[0],(int)count[0]%2,PageParity); | | 37 | fprintf(ERR_STREAM,"FirstPart\n count %d, mod %d, pp %d\n",(int)count[0],(int)count[0]%2,PageParity); |
41 | */ | | 38 | */ |
42 | - SkipMode = | | 39 | - SkipMode = |
43 | - (bool)(PageParity != (short)((count[0]<0 ? | | 40 | - (bool)(PageParity != (short)((count[0]<0 ? |
44 | + SkipMode = | | 41 | + SkipMode = |
45 | + (bool)(PageParity != (short)((count[0]<0 ? | | 42 | + (bool)(PageParity != (short)((count[0]<0 ? |
46 | labs(count[0])+1 : count[0])%2)); | | 43 | labs(count[0])+1 : count[0])%2)); |
47 | if (count[0] == 0) SkipMode = (bool)!SkipMode; | | 44 | if (count[0] == 0) SkipMode = (bool)!SkipMode; |
48 | } | | 45 | } |
49 | @@ -641,7 +641,7 @@ char *argv[]; | | 46 | @@ -641,7 +641,7 @@ char *argv[]; |
50 | is not buffered. */ | | 47 | is not buffered. */ |
51 | | | 48 | |
52 | /* read a buffered byte */ | | 49 | /* read a buffered byte */ |
53 | -char | | 50 | -char |
54 | +char | | 51 | +char |
55 | #if NeedFunctionPrototypes | | 52 | #if NeedFunctionPrototypes |
56 | b_read(FILEPTR spfp) | | 53 | b_read(FILEPTR spfp) |
57 | #else | | 54 | #else |
58 | @@ -661,7 +661,7 @@ FILEPTR spfp; | | 55 | @@ -661,7 +661,7 @@ FILEPTR spfp; |
59 | } | | 56 | } |
60 | | | 57 | |
61 | #ifdef RISC_BUFFER | | 58 | #ifdef RISC_BUFFER |
62 | -void | | 59 | -void |
63 | +void | | 60 | +void |
64 | #if NeedFunctionPrototypes | | 61 | #if NeedFunctionPrototypes |
65 | b_write(FILEPTR spfp, char c) /* write a buffered byte */ | | 62 | b_write(FILEPTR spfp, char c) /* write a buffered byte */ |
66 | #else | | 63 | #else |
67 | @@ -677,7 +677,7 @@ char c; | | 64 | @@ -677,7 +677,7 @@ char c; |
68 | buffout[boact++] = c; | | 65 | buffout[boact++] = c; |
69 | } | | 66 | } |
70 | | | 67 | |
71 | -void | | 68 | -void |
72 | +void | | 69 | +void |
73 | #if NeedFunctionPrototypes | | 70 | #if NeedFunctionPrototypes |
74 | b_wrtmult(FILEPTR spfp, char *buf, int len) /* write a sequence of bytes to the output buffer */ | | 71 | b_wrtmult(FILEPTR spfp, char *buf, int len) /* write a sequence of bytes to the output buffer */ |
75 | #else | | 72 | #else |
76 | @@ -693,22 +693,22 @@ int len; | | 73 | @@ -693,22 +693,22 @@ int len; |
77 | write_multi(buffout,1,boact,spfp); | | 74 | write_multi(buffout,1,boact,spfp); |
78 | /* Copy only small blocks; large ones are written directly */ | | 75 | /* Copy only small blocks; large ones are written directly */ |
79 | if (len < (BUFFSIZE/4)) { | | 76 | if (len < (BUFFSIZE/4)) { |
80 | - for (i = 0; i<len; i++) | | 77 | - for (i = 0; i<len; i++) |
81 | + for (i = 0; i<len; i++) | | 78 | + for (i = 0; i<len; i++) |
82 | buffout[i] = buf[i]; | | 79 | buffout[i] = buf[i]; |
83 | boact = len; | | 80 | boact = len; |
84 | } else { | | 81 | } else { |
85 | - write_multi(buf,1,len,spfp); | | 82 | - write_multi(buf,1,len,spfp); |
86 | + write_multi(buf,1,len,spfp); | | 83 | + write_multi(buf,1,len,spfp); |
87 | boact = 0; | | 84 | boact = 0; |
88 | } | | 85 | } |
89 | } | | 86 | } |
90 | else { | | 87 | else { |
91 | - for (i = 0; i<len; i++) | | 88 | - for (i = 0; i<len; i++) |
92 | + for (i = 0; i<len; i++) | | 89 | + for (i = 0; i<len; i++) |
93 | buffout[boact++] = buf[i]; | | 90 | buffout[boact++] = buf[i]; |
94 | } | | 91 | } |
95 | } | | 92 | } |
96 | | | 93 | |
97 | /* flush the output buffer */ | | 94 | /* flush the output buffer */ |
98 | -void | | 95 | -void |
99 | +void | | 96 | +void |
100 | #if NeedFunctionPrototypes | | 97 | #if NeedFunctionPrototypes |
101 | b_oflush(FILEPTR spfp) | | 98 | b_oflush(FILEPTR spfp) |
102 | #else | | 99 | #else |
103 | @@ -762,9 +762,9 @@ char *str; | | 100 | @@ -762,9 +762,9 @@ char *str; |
104 | /***************************** CopyHPFile ******************************/ | | 101 | /***************************** CopyHPFile ******************************/ |
105 | /*********************************************************************/ | | 102 | /*********************************************************************/ |
106 | #if NeedFunctionPrototypes | | 103 | #if NeedFunctionPrototypes |
107 | -int getnum(FILEPTR spfp, char *t, char *numstr) | | 104 | -int getnum(FILEPTR spfp, char *t, char *numstr) |
108 | +int getnum(FILEPTR spfp, char *t, char *numstr) | | 105 | +int getnum(FILEPTR spfp, char *t, char *numstr) |
109 | #else | | 106 | #else |
110 | -int getnum(spfp, t, numstr) | | 107 | -int getnum(spfp, t, numstr) |
111 | +int getnum(spfp, t, numstr) | | 108 | +int getnum(spfp, t, numstr) |
112 | FILEPTR spfp; | | 109 | FILEPTR spfp; |
113 | char *t, *numstr; | | 110 | char *t, *numstr; |
114 | #endif | | 111 | #endif |
115 | @@ -777,30 +777,30 @@ char *t, *numstr; | | 112 | @@ -777,30 +777,30 @@ char *t, *numstr; |
116 | } | | 113 | } |
117 | | | 114 | |
118 | #if NeedFunctionPrototypes | | 115 | #if NeedFunctionPrototypes |
119 | -void setOffset(char dir, char sign, int pos) | | 116 | -void setOffset(char dir, char sign, int pos) |
120 | +void setOffset(char dir, char sign, int pos) | | 117 | +void setOffset(char dir, char sign, int pos) |
121 | #else | | 118 | #else |
122 | -void setOffset(dir, sign, pos, first) | | 119 | -void setOffset(dir, sign, pos, first) |
123 | +void setOffset(dir, sign, pos, first) | | 120 | +void setOffset(dir, sign, pos, first) |
124 | char dir, sign; | | 121 | char dir, sign; |
125 | int pos; | | 122 | int pos; |
126 | #endif | | 123 | #endif |
127 | { | | 124 | { |
128 | if ((sign == '+' || sign == '-') && pos > 0 ) { | | 125 | if ((sign == '+' || sign == '-') && pos > 0 ) { |
129 | EMIT4("\033*p%c%d%c",sign,pos,dir); | | 126 | EMIT4("\033*p%c%d%c",sign,pos,dir); |
130 | -#ifdef DEBUGGS | | 127 | -#ifdef DEBUGGS |
131 | +#ifdef DEBUGGS | | 128 | +#ifdef DEBUGGS |
132 | fprintf(stderr, "relative: *p%c%d%c\n", sign, pos, dir); | | 129 | fprintf(stderr, "relative: *p%c%d%c\n", sign, pos, dir); |
133 | #endif | | 130 | #endif |
134 | } else if (pos>0) { | | 131 | } else if (pos>0) { |
135 | EMIT3("\033*p%d%c",pos,dir); | | 132 | EMIT3("\033*p%d%c",pos,dir); |
136 | -#ifdef DEBUGGS | | 133 | -#ifdef DEBUGGS |
137 | +#ifdef DEBUGGS | | 134 | +#ifdef DEBUGGS |
138 | fprintf(stderr, "absolute: *p%d%c\n", pos, dir); | | 135 | fprintf(stderr, "absolute: *p%d%c\n", pos, dir); |
139 | #endif | | 136 | #endif |
140 | - if (dir == 'X') | | 137 | - if (dir == 'X') |
141 | + if (dir == 'X') | | 138 | + if (dir == 'X') |
142 | last_rx = pos; | | 139 | last_rx = pos; |
143 | - else | | 140 | - else |
144 | + else | | 141 | + else |
145 | last_ry = pos; | | 142 | last_ry = pos; |
146 | } else { | | 143 | } else { |
147 | /*EMIT3("\033*p%d%c",pos,dir);*/ | | 144 | /*EMIT3("\033*p%d%c",pos,dir);*/ |
148 | -#ifdef DEBUGGS | | 145 | -#ifdef DEBUGGS |
149 | +#ifdef DEBUGGS | | 146 | +#ifdef DEBUGGS |
150 | fprintf(stderr, "Relative: *p%d%c\n", pos, dir); | | 147 | fprintf(stderr, "Relative: *p%d%c\n", pos, dir); |
151 | #endif | | 148 | #endif |
152 | } | | 149 | } |
153 | @@ -832,7 +832,7 @@ char *str; | | 150 | @@ -832,7 +832,7 @@ char *str; |
154 | unwanted commands from the input file and outputs the rest */ | | 151 | unwanted commands from the input file and outputs the rest */ |
155 | | | 152 | |
156 | /* reset the input buffer */ | | 153 | /* reset the input buffer */ |
157 | - binumber = 0; | | 154 | - binumber = 0; |
158 | + binumber = 0; | | 155 | + binumber = 0; |
159 | biact = 0; | | 156 | biact = 0; |
160 | | | 157 | |
161 | qfprintf(ERR_STREAM," [%s", str); | | 158 | qfprintf(ERR_STREAM," [%s", str); |
162 | @@ -853,16 +853,16 @@ char *str; | | 159 | @@ -853,16 +853,16 @@ char *str; |
163 | /* of the commands (x first, y first) */ | | 160 | /* of the commands (x first, y first) */ |
164 | | | 161 | |
165 | if (t=='Y' || t=='y') { | | 162 | if (t=='Y' || t=='y') { |
166 | - if (numstr[0]!='+' && numstr[0]!='-' && num<miny) | | 163 | - if (numstr[0]!='+' && numstr[0]!='-' && num<miny) |
167 | + if (numstr[0]!='+' && numstr[0]!='-' && num<miny) | | 164 | + if (numstr[0]!='+' && numstr[0]!='-' && num<miny) |
168 | miny = num; | | 165 | miny = num; |
169 | if (t=='y') { | | 166 | if (t=='y') { |
170 | num = getnum(spfp, &t, numstr); | | 167 | num = getnum(spfp, &t, numstr); |
171 | - if (numstr[0]!='+' && numstr[0]!='-' && num<minx) | | 168 | - if (numstr[0]!='+' && numstr[0]!='-' && num<minx) |
172 | + if (numstr[0]!='+' && numstr[0]!='-' && num<minx) | | 169 | + if (numstr[0]!='+' && numstr[0]!='-' && num<minx) |
173 | minx = num; | | 170 | minx = num; |
174 | } | | 171 | } |
175 | } | | 172 | } |
176 | if (t=='X' || t=='x') { | | 173 | if (t=='X' || t=='x') { |
177 | - if (numstr[0]!='+' && numstr[0]!='-' && num<minx) | | 174 | - if (numstr[0]!='+' && numstr[0]!='-' && num<minx) |
178 | + if (numstr[0]!='+' && numstr[0]!='-' && num<minx) | | 175 | + if (numstr[0]!='+' && numstr[0]!='-' && num<minx) |
179 | minx = num; | | 176 | minx = num; |
180 | | | 177 | |
181 | if (t=='x') { | | 178 | if (t=='x') { |
182 | @@ -920,16 +920,16 @@ char *str; | | 179 | @@ -920,16 +920,16 @@ char *str; |
183 | } | | 180 | } |
184 | qfprintf(ERR_STREAM," [%s", str); | | 181 | qfprintf(ERR_STREAM," [%s", str); |
185 | /* reset input buffer again */ | | 182 | /* reset input buffer again */ |
186 | - binumber = 0; | | 183 | - binumber = 0; |
187 | + binumber = 0; | | 184 | + binumber = 0; |
188 | biact = 0; | | 185 | biact = 0; |
189 | | | 186 | |
190 | | | 187 | |
191 | /* Pass through the input file again but this time output the */ | | 188 | /* Pass through the input file again but this time output the */ |
192 | /* retained PCL commands */ | | 189 | /* retained PCL commands */ |
193 | -#ifdef DEBUGGS | | 190 | -#ifdef DEBUGGS |
194 | - fprintf(stderr,"\nminx=%d, miny=%d, xg=%d, yg=%d\n", | | 191 | - fprintf(stderr,"\nminx=%d, miny=%d, xg=%d, yg=%d\n", |
195 | +#ifdef DEBUGGS | | 192 | +#ifdef DEBUGGS |
196 | + fprintf(stderr,"\nminx=%d, miny=%d, xg=%d, yg=%d\n", | | 193 | + fprintf(stderr,"\nminx=%d, miny=%d, xg=%d, yg=%d\n", |
197 | minx, miny, x_goffset, y_goffset); | | 194 | minx, miny, x_goffset, y_goffset); |
198 | -#endif | | 195 | -#endif |
199 | +#endif | | 196 | +#endif |
200 | do { | | 197 | do { |
201 | t = (char)b_read(spfp); | | 198 | t = (char)b_read(spfp); |
202 | if (t==0x1B) { | | 199 | if (t==0x1B) { |
203 | @@ -948,7 +948,7 @@ char *str; | | 200 | @@ -948,7 +948,7 @@ char *str; |
204 | } else { | | 201 | } else { |
205 | setOffset('Y',numstr[0], num); | | 202 | setOffset('Y',numstr[0], num); |
206 | } | | 203 | } |
207 | - | | 204 | - |
208 | + | | 205 | + |
209 | if (t == 'y') { | | 206 | if (t == 'y') { |
210 | num = getnum(spfp, &t,numstr); | | 207 | num = getnum(spfp, &t,numstr); |
211 | if (numstr[0]!='+' && numstr[0]!='-') { | | 208 | if (numstr[0]!='+' && numstr[0]!='-') { |
212 | @@ -960,16 +960,16 @@ char *str; | | 209 | @@ -960,16 +960,16 @@ char *str; |
213 | } | | 210 | } |
214 | } | | 211 | } |
215 | } | | 212 | } |
216 | - | | 213 | - |
217 | + | | 214 | + |
218 | if (t=='X' || t=='x') { | | 215 | if (t=='X' || t=='x') { |
219 | if (numstr[0]!='+' && numstr[0]!='-') { | | 216 | if (numstr[0]!='+' && numstr[0]!='-') { |
220 | /*Add in the correct horizontal offset*/ | | 217 | /*Add in the correct horizontal offset*/ |
221 | setOffset('X',numstr[0], | | 218 | setOffset('X',numstr[0], |
222 | num - minx + (int)PIXROUND(h,hconv) + x_goffset); | | 219 | num - minx + (int)PIXROUND(h,hconv) + x_goffset); |
223 | - } else { | | 220 | - } else { |
224 | + } else { | | 221 | + } else { |
225 | setOffset('X',numstr[0], num); | | 222 | setOffset('X',numstr[0], num); |
226 | } | | 223 | } |
227 | - | | 224 | - |
228 | + | | 225 | + |
229 | if (t=='x') { | | 226 | if (t=='x') { |
230 | num = getnum(spfp, &t,numstr); | | 227 | num = getnum(spfp, &t,numstr); |
231 | if (numstr[0]!='+' && numstr[0]!='-') { | | 228 | if (numstr[0]!='+' && numstr[0]!='-') { |
232 | @@ -1027,7 +1027,7 @@ char *str; | | 229 | @@ -1027,7 +1027,7 @@ char *str; |
233 | case(0x63): | | 230 | case(0x63): |
234 | /* Rectangular draw commands */ | | 231 | /* Rectangular draw commands */ |
235 | EMIT1("\033*c"); | | 232 | EMIT1("\033*c"); |
236 | - for (t = (char)b_read(spfp); t<0x40 || t>0x60; | | 233 | - for (t = (char)b_read(spfp); t<0x40 || t>0x60; |
237 | + for (t = (char)b_read(spfp); t<0x40 || t>0x60; | | 234 | + for (t = (char)b_read(spfp); t<0x40 || t>0x60; |
238 | t = (char)b_read(spfp)) | | 235 | t = (char)b_read(spfp)) |
239 | EMITC(t); | | 236 | EMITC(t); |
240 | EMITC(t); | | 237 | EMITC(t); |
241 | @@ -1110,7 +1110,7 @@ register int n; /* number of byt | | 238 | @@ -1110,7 +1110,7 @@ register int n; /* number of byt |
242 | long4 x = 0; /* number being constructed */ | | 239 | long4 x = 0; /* number being constructed */ |
243 | unsigned char h; | | 240 | unsigned char h; |
244 | while (n--) { | | 241 | while (n--) { |
245 | - x <<= 8; | | 242 | - x <<= 8; |
246 | + x <<= 8; | | 243 | + x <<= 8; |
247 | read_byte(fp,h); | | 244 | read_byte(fp,h); |
248 | x |= h; | | 245 | x |= h; |
249 | } | | 246 | } |
250 | @@ -1143,7 +1143,7 @@ register int n; /* number of bytes | | 247 | @@ -1143,7 +1143,7 @@ register int n; /* number of bytes |
251 | #ifdef SIGN_DEBUG | | 248 | #ifdef SIGN_DEBUG |
252 | long4 x0; /* copy of x */ | | 249 | long4 x0; /* copy of x */ |
253 | #endif | | 250 | #endif |
254 | - read_byte(fp,h); | | 251 | - read_byte(fp,h); |
255 | + read_byte(fp,h); | | 252 | + read_byte(fp,h); |
256 | x = h; /* get first (high-order) byte */ | | 253 | x = h; /* get first (high-order) byte */ |
257 | n1 = n--; | | 254 | n1 = n--; |
258 | while (n--) { | | 255 | while (n--) { |
259 | @@ -1296,7 +1296,7 @@ FILEPTR f; | | 256 | @@ -1296,7 +1296,7 @@ FILEPTR f; |
260 | /* ---> result in DX */ | | 257 | /* ---> result in DX */ |
261 | | | 258 | |
262 | if ( (regs.h.dl & 0x80) /* file handle points to a device */ | | 259 | if ( (regs.h.dl & 0x80) /* file handle points to a device */ |
263 | - && !(regs.h.dl & 0x07) ) { /* neither console i/o or null */ | | 260 | - && !(regs.h.dl & 0x07) ) { /* neither console i/o or null */ |
264 | + && !(regs.h.dl & 0x07) ) { /* neither console i/o or null */ | | 261 | + && !(regs.h.dl & 0x07) ) { /* neither console i/o or null */ |
265 | | | 262 | |
266 | regs.h.dl |= 0x20; /* set BINARY bit in device info */ | | 263 | regs.h.dl |= 0x20; /* set BINARY bit in device info */ |
267 | regs.h.ah = (unsigned char) 0x44; /* IOCTL */ | | 264 | regs.h.ah = (unsigned char) 0x44; /* IOCTL */ |
268 | @@ -1501,20 +1501,20 @@ printf("Emit character %c(%d) id=%d, yof | | 265 | @@ -1501,20 +1501,20 @@ printf("Emit character %c(%d) id=%d, yof |
269 | /* For COMPRESSED CHARS */ | | 266 | /* For COMPRESSED CHARS */ |
270 | if (PrevSize < nbpl) { | | 267 | if (PrevSize < nbpl) { |
271 | PrevSize = nbpl; | | 268 | PrevSize = nbpl; |
272 | - if (PrevLine != NULL) | | 269 | - if (PrevLine != NULL) |
273 | + if (PrevLine != NULL) | | 270 | + if (PrevLine != NULL) |
274 | free(PrevLine); | | 271 | free(PrevLine); |
275 | - if ((PrevLine = (unsigned char*)malloc(PrevSize*sizeof(char))) | | 272 | - if ((PrevLine = (unsigned char*)malloc(PrevSize*sizeof(char))) |
276 | + if ((PrevLine = (unsigned char*)malloc(PrevSize*sizeof(char))) | | 273 | + if ((PrevLine = (unsigned char*)malloc(PrevSize*sizeof(char))) |
277 | == NULL) { | | 274 | == NULL) { |
278 | - PrevSize = 0; | | 275 | - PrevSize = 0; |
279 | + PrevSize = 0; | | 276 | + PrevSize = 0; |
280 | Fatal("EmitChar: Out of memory error!\n"); | | 277 | Fatal("EmitChar: Out of memory error!\n"); |
281 | } | | 278 | } |
282 | } | | 279 | } |
283 | /* Clear seed line */ | | 280 | /* Clear seed line */ |
284 | - for (i = 0; i<nbpl; i++) | | 281 | - for (i = 0; i<nbpl; i++) |
285 | + for (i = 0; i<nbpl; i++) | | 282 | + for (i = 0; i<nbpl; i++) |
286 | PrevLine[i] = 0; | | 283 | PrevLine[i] = 0; |
287 | - CChar_Off = 0; | | 284 | - CChar_Off = 0; |
288 | + CChar_Off = 0; | | 285 | + CChar_Off = 0; |
289 | CChar_Last = -1; | | 286 | CChar_Last = -1; |
290 | - | | 287 | - |
291 | + | | 288 | + |
292 | /* This bit copied from below... */ | | 289 | /* This bit copied from below... */ |
293 | # ifdef USEPXL | | 290 | # ifdef USEPXL |
294 | if (fontptr->id == pk89) | | 291 | if (fontptr->id == pk89) |
295 | @@ -1530,11 +1530,11 @@ printf("Emit character %c(%d) id=%d, yof | | 292 | @@ -1530,11 +1530,11 @@ printf("Emit character %c(%d) id=%d, yof |
296 | CompressedCharLine(ce,nbpl,sl); | | 293 | CompressedCharLine(ce,nbpl,sl); |
297 | } | | 294 | } |
298 | # else | | 295 | # else |
299 | - for (i = num_rows; i > 0; i--) | | 296 | - for (i = num_rows; i > 0; i--) |
300 | + for (i = num_rows; i > 0; i--) | | 297 | + for (i = num_rows; i > 0; i--) |
301 | CompressedCharLine(ce,nbpl,(bits + (i-1)*nbpl)); | | 298 | CompressedCharLine(ce,nbpl,(bits + (i-1)*nbpl)); |
302 | # endif /* USEPXL */ | | 299 | # endif /* USEPXL */ |
303 | } | | 300 | } |
304 | - else | | 301 | - else |
305 | + else | | 302 | + else |
306 | CChar_Off = -1; | | 303 | CChar_Off = -1; |
307 | # endif /* LJ4 */ | | 304 | # endif /* LJ4 */ |
308 | | | 305 | |
309 | @@ -1544,10 +1544,10 @@ printf("Emit character %c(%d) id=%d, yof | | 306 | @@ -1544,10 +1544,10 @@ printf("Emit character %c(%d) id=%d, yof |
310 | # ifdef LJ4 | | 307 | # ifdef LJ4 |
311 | /* printf("raw: %d (%d * %d), comp: %d\n", | | 308 | /* printf("raw: %d (%d * %d), comp: %d\n", |
312 | total,ce->width,ce->height,CChar_Off); */ | | 309 | total,ce->width,ce->height,CChar_Off); */ |
313 | - /* Characters that don't compress well are usually rather small so | | 310 | - /* Characters that don't compress well are usually rather small so |
314 | - reading them again and writing them uncompressed won't take | | 311 | - reading them again and writing them uncompressed won't take |
315 | + /* Characters that don't compress well are usually rather small so | | 312 | + /* Characters that don't compress well are usually rather small so |
316 | + reading them again and writing them uncompressed won't take | | 313 | + reading them again and writing them uncompressed won't take |
317 | much time anyway. */ | | 314 | much time anyway. */ |
318 | - if (CChar_Off > total) | | 315 | - if (CChar_Off > total) |
319 | + if (CChar_Off > total) | | 316 | + if (CChar_Off > total) |
320 | CChar_Off = -1; | | 317 | CChar_Off = -1; |
321 | if (CChar_Off >= 0) { | | 318 | if (CChar_Off >= 0) { |
322 | EMIT4("\033*c%sd%dE\033(s%ldW", cnv_buffer, | | 319 | EMIT4("\033*c%sd%dE\033(s%ldW", cnv_buffer, |
323 | @@ -1606,7 +1606,7 @@ printf("Emit character %c(%d) id=%d, yof | | 320 | @@ -1606,7 +1606,7 @@ printf("Emit character %c(%d) id=%d, yof |
324 | } | | 321 | } |
325 | #endif | | 322 | #endif |
326 | } | | 323 | } |
327 | - | | 324 | - |
328 | + | | 325 | + |
329 | #ifdef IBM3812 | | 326 | #ifdef IBM3812 |
330 | #ifdef USEPXL | | 327 | #ifdef USEPXL |
331 | used_fontstorage += (long4)ce->height * ((ce->width + 15) >> 4) * 2 + 14; | | 328 | used_fontstorage += (long4)ce->height * ((ce->width + 15) >> 4) * 2 + 14; |
332 | @@ -1652,7 +1652,7 @@ unsigned char *pkloc; | | 329 | @@ -1652,7 +1652,7 @@ unsigned char *pkloc; |
333 | int repeatcount; | | 330 | int repeatcount; |
334 | | | 331 | |
335 | void /* <Read and translate raster description@>*/ | | 332 | void /* <Read and translate raster description@>*/ |
336 | -#if NeedFunctionPrototypes | | 333 | -#if NeedFunctionPrototypes |
337 | +#if NeedFunctionPrototypes | | 334 | +#if NeedFunctionPrototypes |
338 | PkRaster(struct char_entry *ce, int raster) | | 335 | PkRaster(struct char_entry *ce, int raster) |
339 | #else | | 336 | #else |
340 | PkRaster(ce, raster) | | 337 | PkRaster(ce, raster) |
341 | @@ -1735,7 +1735,7 @@ int raster; | | 338 | @@ -1735,7 +1735,7 @@ int raster; |
342 | if (wordweight < 31) { | | 339 | if (wordweight < 31) { |
343 | #ifdef COMMENT | | 340 | #ifdef COMMENT |
344 | # ifdef DRAWGLYPH | | 341 | # ifdef DRAWGLYPH |
345 | - { | | 342 | - { |
346 | + { | | 343 | + { |
347 | int k; | | 344 | int k; |
348 | for (k = 15; k>=0; k--) { | | 345 | for (k = 15; k>=0; k--) { |
349 | if ((power[k] & word)!=0) printf("Z"); | | 346 | if ((power[k] & word)!=0) printf("Z"); |
350 | @@ -1749,7 +1749,7 @@ int raster; | | 347 | @@ -1749,7 +1749,7 @@ int raster; |
351 | for (j = 3; j >= (wordwidth * 4 - (long4)nbpl); j--) { | | 348 | for (j = 3; j >= (wordwidth * 4 - (long4)nbpl); j--) { |
352 | OUTCHAR(((word >> (j << 3)) & 0xff)); | | 349 | OUTCHAR(((word >> (j << 3)) & 0xff)); |
353 | #ifdef DRAWGLYPH | | 350 | #ifdef DRAWGLYPH |
354 | - { | | 351 | - { |
355 | + { | | 352 | + { |
356 | int k; | | 353 | int k; |
357 | for (k = 7; k>=0; k--) { | | 354 | for (k = 7; k>=0; k--) { |
358 | if ((power[k] & ((word >> (j << 3)) & 0xff))!=0) printf("M"); | | 355 | if ((power[k] & ((word >> (j << 3)) & 0xff))!=0) printf("M"); |
359 | @@ -1760,9 +1760,9 @@ int raster; | | 356 | @@ -1760,9 +1760,9 @@ int raster; |
360 | } | | 357 | } |
361 | | | 358 | |
362 | } | | 359 | } |
363 | - | | 360 | - |
364 | + | | 361 | + |
365 | switch (raster) { | | 362 | switch (raster) { |
366 | - case 1: | | 363 | - case 1: |
367 | + case 1: | | 364 | + case 1: |
368 | RasterLine(ce, nbpl, current_line, raster_line_buf); | | 365 | RasterLine(ce, nbpl, current_line, raster_line_buf); |
369 | current_line++; | | 366 | current_line++; |
370 | break; | | 367 | break; |
371 | @@ -1826,7 +1826,7 @@ int raster; | | 368 | @@ -1826,7 +1826,7 @@ int raster; |
372 | OUTCHAR((tl & 0xFF)); | | 369 | OUTCHAR((tl & 0xFF)); |
373 | | | 370 | |
374 | #ifdef DRAWGLYPH | | 371 | #ifdef DRAWGLYPH |
375 | - { | | 372 | - { |
376 | + { | | 373 | + { |
377 | int k; | | 374 | int k; |
378 | for (k = 31; k>=0; k--) { | | 375 | for (k = 31; k>=0; k--) { |
379 | if ((power[k] & row[ii])!=0) printf("M"); | | 376 | if ((power[k] & row[ii])!=0) printf("M"); |
380 | @@ -1839,7 +1839,7 @@ int raster; | | 377 | @@ -1839,7 +1839,7 @@ int raster; |
381 | for (j = 3; j >= (wordwidth *4 - (long4)nbpl); j--) { | | 378 | for (j = 3; j >= (wordwidth *4 - (long4)nbpl); j--) { |
382 | OUTCHAR(((tl >> (j << 3)) & 0xff)); | | 379 | OUTCHAR(((tl >> (j << 3)) & 0xff)); |
383 | #ifdef DRAWGLYPH | | 380 | #ifdef DRAWGLYPH |
384 | - { | | 381 | - { |
385 | + { | | 382 | + { |
386 | int k; | | 383 | int k; |
387 | for (k = 7; k>=0; k--) { | | 384 | for (k = 7; k>=0; k--) { |
388 | if ((power[k] & ((tl >> (j << 3)) & 0xff))!=0) printf("M"); | | 385 | if ((power[k] & ((tl >> (j << 3)) & 0xff))!=0) printf("M"); |
389 | @@ -1850,7 +1850,7 @@ int raster; | | 386 | @@ -1850,7 +1850,7 @@ int raster; |
390 | } | | 387 | } |
391 | | | 388 | |
392 | switch (raster) { | | 389 | switch (raster) { |
393 | - case 1: | | 390 | - case 1: |
394 | + case 1: | | 391 | + case 1: |
395 | RasterLine(ce, (unsigned int)nbpl, current_line, raster_line_buf); | | 392 | RasterLine(ce, (unsigned int)nbpl, current_line, raster_line_buf); |
396 | current_line++; | | 393 | current_line++; |
397 | break; | | 394 | break; |
398 | @@ -1969,7 +1969,7 @@ int n; | | 395 | @@ -1969,7 +1969,7 @@ int n; |
399 | | | 396 | |
400 | #ifdef LJ4 | | 397 | #ifdef LJ4 |
401 | /* Compress a raster line in compression mode 2 */ | | 398 | /* Compress a raster line in compression mode 2 */ |
402 | -int | | 399 | -int |
403 | +int | | 400 | +int |
404 | #if NeedFunctionPrototypes | | 401 | #if NeedFunctionPrototypes |
405 | CompressLine2(unsigned char *buffer, unsigned char *buffout, int emitbytes) | | 402 | CompressLine2(unsigned char *buffer, unsigned char *buffout, int emitbytes) |
406 | #else | | 403 | #else |
407 | @@ -1984,13 +1984,13 @@ int emitbytes; | | 404 | @@ -1984,13 +1984,13 @@ int emitbytes; |
408 | char last,c; | | 405 | char last,c; |
409 | | | 406 | |
410 | /* trap empty lines (otherwise problems with Packbits) */ | | 407 | /* trap empty lines (otherwise problems with Packbits) */ |
411 | - if (emitbytes == 0) | | 408 | - if (emitbytes == 0) |
412 | + if (emitbytes == 0) | | 409 | + if (emitbytes == 0) |
413 | return(0); | | 410 | return(0); |
414 | /* Use Packbits compression (mode 2) on raster line */ | | 411 | /* Use Packbits compression (mode 2) on raster line */ |
415 | - pos = buffer; | | 412 | - pos = buffer; |
416 | - litpos = buffer; | | 413 | - litpos = buffer; |
417 | - pack = 1; | | 414 | - pack = 1; |
418 | - ppos = buffout; | | 415 | - ppos = buffout; |
419 | + pos = buffer; | | 416 | + pos = buffer; |
420 | + litpos = buffer; | | 417 | + litpos = buffer; |
421 | + pack = 1; | | 418 | + pack = 1; |
422 | + ppos = buffout; | | 419 | + ppos = buffout; |
423 | last = *pos++; | | 420 | last = *pos++; |
424 | upper = buffer + emitbytes; | | 421 | upper = buffer + emitbytes; |
425 | while (pos < upper) { | | 422 | while (pos < upper) { |
426 | @@ -2000,14 +2000,14 @@ int emitbytes; | | 423 | @@ -2000,14 +2000,14 @@ int emitbytes; |
427 | /* At least three equal bytes ==> write out preceding literal sequence */ | | 424 | /* At least three equal bytes ==> write out preceding literal sequence */ |
428 | if ((pack == 3) && ((lit = (int)(pos - litpos - 3)) != 0)) { | | 425 | if ((pack == 3) && ((lit = (int)(pos - litpos - 3)) != 0)) { |
429 | while (lit >= 128) { | | 426 | while (lit >= 128) { |
430 | - *ppos++ = 127; | | 427 | - *ppos++ = 127; |
431 | - for (i = 1; i<=128; i++) | | 428 | - for (i = 1; i<=128; i++) |
432 | + *ppos++ = 127; | | 429 | + *ppos++ = 127; |
433 | + for (i = 1; i<=128; i++) | | 430 | + for (i = 1; i<=128; i++) |
434 | *ppos++ = *litpos++; | | 431 | *ppos++ = *litpos++; |
435 | lit -= 128; | | 432 | lit -= 128; |
436 | } | | 433 | } |
437 | if (lit != 0) { | | 434 | if (lit != 0) { |
438 | - *ppos++ = lit-1; | | 435 | - *ppos++ = lit-1; |
439 | - while ((lit--) > 0) | | 436 | - while ((lit--) > 0) |
440 | + *ppos++ = lit-1; | | 437 | + *ppos++ = lit-1; |
441 | + while ((lit--) > 0) | | 438 | + while ((lit--) > 0) |
442 | *ppos++ = *litpos++; | | 439 | *ppos++ = *litpos++; |
443 | /* litpos is now pos-3 (i.e. first of the sequence) */ | | 440 | /* litpos is now pos-3 (i.e. first of the sequence) */ |
444 | } | | 441 | } |
445 | @@ -2015,19 +2015,19 @@ int emitbytes; | | 442 | @@ -2015,19 +2015,19 @@ int emitbytes; |
446 | } | | 443 | } |
447 | else { | | 444 | else { |
448 | while (pack >= 128) { | | 445 | while (pack >= 128) { |
449 | - *ppos++ = 129; | | 446 | - *ppos++ = 129; |
450 | - *ppos++ = last; | | 447 | - *ppos++ = last; |
451 | - litpos += 128; | | 448 | - litpos += 128; |
452 | + *ppos++ = 129; | | 449 | + *ppos++ = 129; |
453 | + *ppos++ = last; | | 450 | + *ppos++ = last; |
454 | + litpos += 128; | | 451 | + litpos += 128; |
455 | pack -= 128; | | 452 | pack -= 128; |
456 | } | | 453 | } |
457 | /* At least 3 equal bytes or 2 that don't break a literal sequence | | 454 | /* At least 3 equal bytes or 2 that don't break a literal sequence |
458 | ==> write out packed sequence */ | | 455 | ==> write out packed sequence */ |
459 | if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) { | | 456 | if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) { |
460 | - *ppos++ = 257 - pack; | | 457 | - *ppos++ = 257 - pack; |
461 | - *ppos++ = last; | | 458 | - *ppos++ = last; |
462 | + *ppos++ = 257 - pack; | | 459 | + *ppos++ = 257 - pack; |
463 | + *ppos++ = last; | | 460 | + *ppos++ = last; |
464 | litpos += pack; | | 461 | litpos += pack; |
465 | } | | 462 | } |
466 | - pack = 1; | | 463 | - pack = 1; |
467 | + pack = 1; | | 464 | + pack = 1; |
468 | last = c; | | 465 | last = c; |
469 | } | | 466 | } |
470 | if (ppos > (buffout + BUFFSIZE/2 - 129)) { | | 467 | if (ppos > (buffout + BUFFSIZE/2 - 129)) { |
471 | @@ -2036,28 +2036,28 @@ int emitbytes; | | 468 | @@ -2036,28 +2036,28 @@ int emitbytes; |
472 | return(0); | | 469 | return(0); |
473 | } | | 470 | } |
474 | } | | 471 | } |
475 | - | | 472 | - |
476 | + | | 473 | + |
477 | while (pack >= 128) { | | 474 | while (pack >= 128) { |
478 | - *ppos++ = 129; | | 475 | - *ppos++ = 129; |
479 | - *ppos++ = last; | | 476 | - *ppos++ = last; |
480 | - litpos += 128; | | 477 | - litpos += 128; |
481 | + *ppos++ = 129; | | 478 | + *ppos++ = 129; |
482 | + *ppos++ = last; | | 479 | + *ppos++ = last; |
483 | + litpos += 128; | | 480 | + litpos += 128; |
484 | pack -= 128; | | 481 | pack -= 128; |
485 | } | | 482 | } |
486 | if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) { | | 483 | if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) { |
487 | - *ppos++ = 257 - pack; | | 484 | - *ppos++ = 257 - pack; |
488 | - *ppos++ = last; | | 485 | - *ppos++ = last; |
489 | + *ppos++ = 257 - pack; | | 486 | + *ppos++ = 257 - pack; |
490 | + *ppos++ = last; | | 487 | + *ppos++ = last; |
491 | litpos += pack; | | 488 | litpos += pack; |
492 | } | | 489 | } |
493 | else if ((lit = (int)(pos - litpos)) != 0) { | | 490 | else if ((lit = (int)(pos - litpos)) != 0) { |
494 | while (lit >= 128) { | | 491 | while (lit >= 128) { |
495 | - *ppos++ = 127; | | 492 | - *ppos++ = 127; |
496 | - for (i = 1; i<=128; i++) | | 493 | - for (i = 1; i<=128; i++) |
497 | + *ppos++ = 127; | | 494 | + *ppos++ = 127; |
498 | + for (i = 1; i<=128; i++) | | 495 | + for (i = 1; i<=128; i++) |
499 | *ppos++ = *litpos++; | | 496 | *ppos++ = *litpos++; |
500 | lit -= 128; | | 497 | lit -= 128; |
501 | } | | 498 | } |
502 | if (lit != 0) { | | 499 | if (lit != 0) { |
503 | - *ppos++ = lit-1; | | 500 | - *ppos++ = lit-1; |
504 | - while ((lit--) > 0) | | 501 | - while ((lit--) > 0) |
505 | + *ppos++ = lit-1; | | 502 | + *ppos++ = lit-1; |
506 | + while ((lit--) > 0) | | 503 | + while ((lit--) > 0) |
507 | *ppos++ = *litpos++; | | 504 | *ppos++ = *litpos++; |
508 | } | | 505 | } |
509 | } | | 506 | } |
510 | @@ -2079,24 +2079,24 @@ int emitbytes; | | 507 | @@ -2079,24 +2079,24 @@ int emitbytes; |
511 | int lit,i,pack; | | 508 | int lit,i,pack; |
512 | | | 509 | |
513 | /* Use compression mode 3 */ | | 510 | /* Use compression mode 3 */ |
514 | - pos = buffer; | | 511 | - pos = buffer; |
515 | - ppos = buffout; | | 512 | - ppos = buffout; |
516 | - upper = buffer + emitbytes; | | 513 | - upper = buffer + emitbytes; |
517 | + pos = buffer; | | 514 | + pos = buffer; |
518 | + ppos = buffout; | | 515 | + ppos = buffout; |
519 | + upper = buffer + emitbytes; | | 516 | + upper = buffer + emitbytes; |
520 | prev = PrevLine; | | 517 | prev = PrevLine; |
521 | while(pos < upper) { | | 518 | while(pos < upper) { |
522 | litpos = pos; | | 519 | litpos = pos; |
523 | while ((*prev == *pos) && (pos < upper)) { | | 520 | while ((*prev == *pos) && (pos < upper)) { |
524 | - prev++; | | 521 | - prev++; |
525 | + prev++; | | 522 | + prev++; |
526 | pos++; | | 523 | pos++; |
527 | } | | 524 | } |
528 | if (pos < upper) { | | 525 | if (pos < upper) { |
529 | - pack = (int)(pos - litpos); | | 526 | - pack = (int)(pos - litpos); |
530 | + pack = (int)(pos - litpos); | | 527 | + pack = (int)(pos - litpos); |
531 | litpos = pos; | | 528 | litpos = pos; |
532 | - i = upper - pos; | | 529 | - i = upper - pos; |
533 | - if (i > 8) | | 530 | - if (i > 8) |
534 | + i = upper - pos; | | 531 | + i = upper - pos; |
535 | + if (i > 8) | | 532 | + if (i > 8) |
536 | i = 8; | | 533 | i = 8; |
537 | while ((*pos != *prev) && (i > 0)) { | | 534 | while ((*pos != *prev) && (i > 0)) { |
538 | - *prev++ = *pos++; | | 535 | - *prev++ = *pos++; |
539 | + *prev++ = *pos++; | | 536 | + *prev++ = *pos++; |
540 | i--; | | 537 | i--; |
541 | } | | 538 | } |
542 | i = (int)(pos - litpos - 1); | | 539 | i = (int)(pos - litpos - 1); |
543 | @@ -2105,16 +2105,16 @@ int emitbytes; | | 540 | @@ -2105,16 +2105,16 @@ int emitbytes; |
544 | *ppos++ = lit + pack; | | 541 | *ppos++ = lit + pack; |
545 | } | | 542 | } |
546 | else { | | 543 | else { |
547 | - *ppos++ = lit + 31; | | 544 | - *ppos++ = lit + 31; |
548 | + *ppos++ = lit + 31; | | 545 | + *ppos++ = lit + 31; |
549 | pack -= 31; | | 546 | pack -= 31; |
550 | while (pack >= 255) { | | 547 | while (pack >= 255) { |
551 | - *ppos++ = 255; | | 548 | - *ppos++ = 255; |
552 | + *ppos++ = 255; | | 549 | + *ppos++ = 255; |
553 | pack -= 255; | | 550 | pack -= 255; |
554 | } | | 551 | } |
555 | *ppos++ = pack; | | 552 | *ppos++ = pack; |
556 | } | | 553 | } |
557 | while (i >= 0) { | | 554 | while (i >= 0) { |
558 | - *ppos++ = *litpos++; | | 555 | - *ppos++ = *litpos++; |
559 | + *ppos++ = *litpos++; | | 556 | + *ppos++ = *litpos++; |
560 | i--; | | 557 | i--; |
561 | } | | 558 | } |
562 | } | | 559 | } |
563 | @@ -2134,7 +2134,7 @@ int emitbytes; | | 560 | @@ -2134,7 +2134,7 @@ int emitbytes; |
564 | /**********************************************************************/ | | 561 | /**********************************************************************/ |
565 | void | | 562 | void |
566 | #if NeedFunctionPrototypes | | 563 | #if NeedFunctionPrototypes |
567 | -RasterLine(struct char_entry *ce, unsigned int nbpl, | | 564 | -RasterLine(struct char_entry *ce, unsigned int nbpl, |
568 | +RasterLine(struct char_entry *ce, unsigned int nbpl, | | 565 | +RasterLine(struct char_entry *ce, unsigned int nbpl, |
569 | unsigned int current_line, unsigned char *buffer) | | 566 | unsigned int current_line, unsigned char *buffer) |
570 | #else | | 567 | #else |
571 | RasterLine(ce, nbpl, current_line, buffer) | | 568 | RasterLine(ce, nbpl, current_line, buffer) |
572 | @@ -2208,21 +2208,21 @@ char *buffer; | | 569 | @@ -2208,21 +2208,21 @@ char *buffer; |
573 | EMIT2("\033*b%dW", emitbytes); | | 570 | EMIT2("\033*b%dW", emitbytes); |
574 | EMITL(emitbytes, buffer); | | 571 | EMITL(emitbytes, buffer); |
575 | break; | | 572 | break; |
576 | - | | 573 | - |
577 | + | | 574 | + |
578 | case 2: | | 575 | case 2: |
579 | i = CompressLine2(buffer,buffin,emitbytes); | | 576 | i = CompressLine2(buffer,buffin,emitbytes); |
580 | EMIT2("\033*b%dW", i); | | 577 | EMIT2("\033*b%dW", i); |
581 | EMITL(i,buffin); | | 578 | EMITL(i,buffin); |
582 | break; | | 579 | break; |
583 | - | | 580 | - |
584 | + | | 581 | + |
585 | case 3: | | 582 | case 3: |
586 | i = CompressLine3(buffer,buffin + BUFFSIZE/2,(int)nbpl); | | 583 | i = CompressLine3(buffer,buffin + BUFFSIZE/2,(int)nbpl); |
587 | EMIT2("\033*b%dW", i); | | 584 | EMIT2("\033*b%dW", i); |
588 | EMITL(i,buffin + BUFFSIZE/2); | | 585 | EMITL(i,buffin + BUFFSIZE/2); |
589 | break; | | 586 | break; |
590 | - | | 587 | - |
591 | - default: | | 588 | - default: |
592 | - fprintf(ERR_STREAM,"Unsupported compression mode!\n"); | | 589 | - fprintf(ERR_STREAM,"Unsupported compression mode!\n"); |
593 | + | | 590 | + |
594 | + default: | | 591 | + default: |
595 | + fprintf(ERR_STREAM,"Unsupported compression mode!\n"); | | 592 | + fprintf(ERR_STREAM,"Unsupported compression mode!\n"); |
596 | } | | 593 | } |
597 | # else | | 594 | # else |
598 | EMIT2("\033*b%dW", emitbytes); | | 595 | EMIT2("\033*b%dW", emitbytes); |
599 | @@ -2280,10 +2280,10 @@ struct char_entry *ce; | | 596 | @@ -2280,10 +2280,10 @@ struct char_entry *ce; |
600 | if (CompressCharMode == 3) { | | 597 | if (CompressCharMode == 3) { |
601 | /* Check if PrevLine big enough; claim more space if not */ | | 598 | /* Check if PrevLine big enough; claim more space if not */ |
602 | if (((int)nbpl) > PrevSize) { | | 599 | if (((int)nbpl) > PrevSize) { |
603 | - if (PrevLine != NULL) | | 600 | - if (PrevLine != NULL) |
604 | + if (PrevLine != NULL) | | 601 | + if (PrevLine != NULL) |
605 | free(PrevLine); | | 602 | free(PrevLine); |
606 | if ((PrevLine = (unsigned char *)malloc(nbpl*sizeof(char))) == NULL) { | | 603 | if ((PrevLine = (unsigned char *)malloc(nbpl*sizeof(char))) == NULL) { |
607 | - PrevSize = 0; | | 604 | - PrevSize = 0; |
608 | + PrevSize = 0; | | 605 | + PrevSize = 0; |
609 | Fatal("RasterChar: out of memory!\n"); | | 606 | Fatal("RasterChar: out of memory!\n"); |
610 | } | | 607 | } |
611 | PrevSize = (int)nbpl; | | 608 | PrevSize = (int)nbpl; |
612 | @@ -2419,7 +2419,7 @@ register struct char_entry *ptr; | | 609 | @@ -2419,7 +2419,7 @@ register struct char_entry *ptr; |
613 | if (bytes > 0) { | | 610 | if (bytes > 0) { |
614 | /* do NOT load Huge characters */ | | 611 | /* do NOT load Huge characters */ |
615 | if ((bytes > HUGE_CHAR_PATTERN) && (fontptr->id != pk89)) { | | 612 | if ((bytes > HUGE_CHAR_PATTERN) && (fontptr->id != pk89)) { |
616 | - qfprintf(ERR_STREAM,"Huge Character <%c> (%ld Bytes)\n", | | 613 | - qfprintf(ERR_STREAM,"Huge Character <%c> (%ld Bytes)\n", |
617 | + qfprintf(ERR_STREAM,"Huge Character <%c> (%ld Bytes)\n", | | 614 | + qfprintf(ERR_STREAM,"Huge Character <%c> (%ld Bytes)\n", |
618 | (char)c, bytes); | | 615 | (char)c, bytes); |
619 | ptr->charsize = HUGE_SIZE; | | 616 | ptr->charsize = HUGE_SIZE; |
620 | ptr->where.isloaded = _FALSE; | | 617 | ptr->where.isloaded = _FALSE; |
621 | @@ -2505,7 +2505,7 @@ bool do_posn,in_string; | | 618 | @@ -2505,7 +2505,7 @@ bool do_posn,in_string; |
622 | SetPosn(h, v); | | 619 | SetPosn(h, v); |
623 | } | | 620 | } |
624 | | | 621 | |
625 | - /* | | 622 | - /* |
626 | + /* | | 623 | + /* |
627 | fprintf(ERR_STREAM, | | 624 | fprintf(ERR_STREAM, |
628 | "(%d) hh=%ld (+%ld/+%ld), h=%ld, xh=%ld,xhh=%ld, [%ld|%ld] ->%d\n", | | 625 | "(%d) hh=%ld (+%ld/+%ld), h=%ld, xh=%ld,xhh=%ld, [%ld|%ld] ->%d\n", |
629 | (int)do_posn,hh,(long4)ptr->cw,(long4)ptr->cw*(long4)hconv,h, | | 626 | (int)do_posn,hh,(long4)ptr->cw,(long4)ptr->cw*(long4)hconv,h, |
630 | @@ -2553,7 +2553,7 @@ bool do_posn,in_string; | | 627 | @@ -2553,7 +2553,7 @@ bool do_posn,in_string; |
631 | int tmp; | | 628 | int tmp; |
632 | char sign; | | 629 | char sign; |
633 | | | 630 | |
634 | - if (!do_posn) | | 631 | - if (!do_posn) |
635 | + if (!do_posn) | | 632 | + if (!do_posn) |
636 | SetPosn(h, v); | | 633 | SetPosn(h, v); |
637 | | | 634 | |
638 | #ifdef USEPXL | | 635 | #ifdef USEPXL |
639 | @@ -2563,7 +2563,7 @@ bool do_posn,in_string; | | 636 | @@ -2563,7 +2563,7 @@ bool do_posn,in_string; |
640 | #endif | | 637 | #endif |
641 | if (tmp != 0) { | | 638 | if (tmp != 0) { |
642 | if (tmp < 0) { | | 639 | if (tmp < 0) { |
643 | - sign = '-'; | | 640 | - sign = '-'; |
644 | + sign = '-'; | | 641 | + sign = '-'; |
645 | tmp = -tmp; | | 642 | tmp = -tmp; |
646 | } else | | 643 | } else |
647 | sign = '+'; | | 644 | sign = '+'; |
648 | @@ -2576,7 +2576,7 @@ bool do_posn,in_string; | | 645 | @@ -2576,7 +2576,7 @@ bool do_posn,in_string; |
649 | #endif | | 646 | #endif |
650 | if (tmp != 0) { | | 647 | if (tmp != 0) { |
651 | if (tmp < 0) { | | 648 | if (tmp < 0) { |
652 | - sign = '-'; | | 649 | - sign = '-'; |
653 | + sign = '-'; | | 650 | + sign = '-'; |
654 | tmp = -tmp; | | 651 | tmp = -tmp; |
655 | } else | | 652 | } else |
656 | sign = '+'; | | 653 | sign = '+'; |
657 | @@ -2644,7 +2644,7 @@ bool do_posn,in_string; | | 654 | @@ -2644,7 +2644,7 @@ bool do_posn,in_string; |
658 | fprintf(stderr,"--> hh(%ld) += cw(%ld) * hconv(%ld)", | | 655 | fprintf(stderr,"--> hh(%ld) += cw(%ld) * hconv(%ld)", |
659 | (long)hh, (long)ptr->cw, (long) hconv); | | 656 | (long)hh, (long)ptr->cw, (long) hconv); |
660 | */ | | 657 | */ |
661 | -#ifdef LJ | | 658 | -#ifdef LJ |
662 | +#ifdef LJ | | 659 | +#ifdef LJ |
663 | /* the guessed position must be a multiple of pixels */ | | 660 | /* the guessed position must be a multiple of pixels */ |
664 | if (RESOLUTION == 300) | | 661 | if (RESOLUTION == 300) |
665 | hh += (long4) ((ptr->cw)/4)*4*hconv; | | 662 | hh += (long4) ((ptr->cw)/4)*4*hconv; |
666 | @@ -2661,7 +2661,7 @@ bool do_posn,in_string; | | 663 | @@ -2661,7 +2661,7 @@ bool do_posn,in_string; |
667 | if (command <= SET4) | | 664 | if (command <= SET4) |
668 | h += ptr->tfmw; | | 665 | h += ptr->tfmw; |
669 | | | 666 | |
670 | - if (pos_after) | | 667 | - if (pos_after) |
671 | + if (pos_after) | | 668 | + if (pos_after) |
672 | SetPosn(h, v); | | 669 | SetPosn(h, v); |
673 | else | | 670 | else |
674 | last_rx = (int)PIXROUND(h, hconv) + x_goffset; | | 671 | last_rx = (int)PIXROUND(h, hconv) + x_goffset; |
675 | @@ -2682,7 +2682,7 @@ void DoBop() | | 672 | @@ -2682,7 +2682,7 @@ void DoBop() |
676 | } | | 673 | } |
677 | fonts_used_on_this_page = 0; | | 674 | fonts_used_on_this_page = 0; |
678 | #endif | | 675 | #endif |
679 | - for (p = hfontptr; p; p = p->next) | | 676 | - for (p = hfontptr; p; p = p->next) |
680 | + for (p = hfontptr; p; p = p->next) | | 677 | + for (p = hfontptr; p; p = p->next) |
681 | p->used_on_this_page = _FALSE; | | 678 | p->used_on_this_page = _FALSE; |
682 | } | | 679 | } |
683 | | | 680 | |
684 | @@ -2740,7 +2740,7 @@ long4 x, y; | | 681 | @@ -2740,7 +2740,7 @@ long4 x, y; |
685 | rx = (int)PIXROUND(x, hconv) + x_goffset; | | 682 | rx = (int)PIXROUND(x, hconv) + x_goffset; |
686 | ry = (int)PIXROUND(y, vconv) + y_goffset; | | 683 | ry = (int)PIXROUND(y, vconv) + y_goffset; |
687 | | | 684 | |
688 | - /* | | 685 | - /* |
689 | + /* | | 686 | + /* |
690 | fprintf(ERR_STREAM, | | 687 | fprintf(ERR_STREAM, |
691 | "setposn to %ld/%ld, %d/%d, last: %d/%d\n", | | 688 | "setposn to %ld/%ld, %d/%d, last: %d/%d\n", |
692 | (long)x,(long)y, | | 689 | (long)x,(long)y, |
693 | @@ -2804,13 +2804,13 @@ long4 x, y; | | 690 | @@ -2804,13 +2804,13 @@ long4 x, y; |
694 | offset in the buffer, CChar_Last is the first byte of the last | | 691 | offset in the buffer, CChar_Last is the first byte of the last |
695 | compacted row (line repeat count). Updates the previous line | | 692 | compacted row (line repeat count). Updates the previous line |
696 | (PrevLine) if necessary. */ | | 693 | (PrevLine) if necessary. */ |
697 | -void | | 694 | -void |
698 | +void | | 695 | +void |
699 | #if NeedFunctionPrototypes | | 696 | #if NeedFunctionPrototypes |
700 | CompressedCharLine(struct char_entry *ce, int nbpl, unsigned char *buffer) | | 697 | CompressedCharLine(struct char_entry *ce, int nbpl, unsigned char *buffer) |
701 | #else | | 698 | #else |
702 | CompressedCharLine(ce, nbpl, buffer) | | 699 | CompressedCharLine(ce, nbpl, buffer) |
703 | struct char_entry *ce; | | 700 | struct char_entry *ce; |
704 | -int nbpl; | | 701 | -int nbpl; |
705 | +int nbpl; | | 702 | +int nbpl; |
706 | unsigned char *buffer; | | 703 | unsigned char *buffer; |
707 | #endif | | 704 | #endif |
708 | { | | 705 | { |
709 | @@ -2821,31 +2821,31 @@ unsigned char *buffer; | | 706 | @@ -2821,31 +2821,31 @@ unsigned char *buffer; |
710 | int t,mode,max; | | 707 | int t,mode,max; |
711 | register int x,y,i; | | 708 | register int x,y,i; |
712 | | | 709 | |
713 | - prev = PrevLine; | | 710 | - prev = PrevLine; |
714 | - obuf = buffer; | | 711 | - obuf = buffer; |
715 | - end = buffer + nbpl; | | 712 | - end = buffer + nbpl; |
716 | + prev = PrevLine; | | 713 | + prev = PrevLine; |
717 | + obuf = buffer; | | 714 | + obuf = buffer; |
718 | + end = buffer + nbpl; | | 715 | + end = buffer + nbpl; |
719 | x = 0; | | 716 | x = 0; |
720 | while (obuf < end) { | | 717 | while (obuf < end) { |
721 | if (*obuf != *prev) { | | 718 | if (*obuf != *prev) { |
722 | - *prev = *obuf; | | 719 | - *prev = *obuf; |
723 | + *prev = *obuf; | | 720 | + *prev = *obuf; |
724 | x = 1; | | 721 | x = 1; |
725 | } | | 722 | } |
726 | - obuf++; | | 723 | - obuf++; |
727 | + obuf++; | | 724 | + obuf++; |
728 | prev++; | | 725 | prev++; |
729 | } | | 726 | } |
730 | if (x == 0 && CChar_Last >= 0) { | | 727 | if (x == 0 && CChar_Last >= 0) { |
731 | - (buffin[CChar_Last])++; | | 728 | - (buffin[CChar_Last])++; |
732 | + (buffin[CChar_Last])++; | | 729 | + (buffin[CChar_Last])++; |
733 | return; /* line repeat count +1 */ | | 730 | return; /* line repeat count +1 */ |
734 | } | | 731 | } |
735 | | | 732 | |
736 | - end = buffin + BUFFSIZE - 16; | | 733 | - end = buffin + BUFFSIZE - 16; |
737 | - obuf = buffin + CChar_Off; | | 734 | - obuf = buffin + CChar_Off; |
738 | + end = buffin + BUFFSIZE - 16; | | 735 | + end = buffin + BUFFSIZE - 16; |
739 | + obuf = buffin + CChar_Off; | | 736 | + obuf = buffin + CChar_Off; |
740 | buff = buffer; | | 737 | buff = buffer; |
741 | *obuf++ = 0; /* Line repeat count = 0 */ | | 738 | *obuf++ = 0; /* Line repeat count = 0 */ |
742 | t = 0; | | 739 | t = 0; |
743 | CChar_Last = CChar_Off; /* Next line */ | | 740 | CChar_Last = CChar_Off; /* Next line */ |
744 | - mode = 0; | | 741 | - mode = 0; |
745 | - y = *buff++; | | 742 | - y = *buff++; |
746 | + mode = 0; | | 743 | + mode = 0; |
747 | + y = *buff++; | | 744 | + y = *buff++; |
748 | i = 7; /* i = current bit */ | | 745 | i = 7; /* i = current bit */ |
749 | while ((t < ce->width) && (obuf < end)) { | | 746 | while ((t < ce->width) && (obuf < end)) { |
750 | max = ce->width - t; /* maximum pixels left to do */ | | 747 | max = ce->width - t; /* maximum pixels left to do */ |
751 | @@ -2853,13 +2853,13 @@ unsigned char *buffer; | | 748 | @@ -2853,13 +2853,13 @@ unsigned char *buffer; |
752 | if (mode == 0) { | | 749 | if (mode == 0) { |
753 | /* white run */ | | 750 | /* white run */ |
754 | while ((y & (1<<i)) == 0 && x < max) { | | 751 | while ((y & (1<<i)) == 0 && x < max) { |
755 | - x++; | | 752 | - x++; |
756 | - i--; | | 753 | - i--; |
757 | + x++; | | 754 | + x++; |
758 | + i--; | | 755 | + i--; |
759 | if (i < 0) { | | 756 | if (i < 0) { |
760 | - i = 7; | | 757 | - i = 7; |
761 | - y = *buff++; | | 758 | - y = *buff++; |
762 | + i = 7; | | 759 | + i = 7; |
763 | + y = *buff++; | | 760 | + y = *buff++; |
764 | while (y == 0 && x < max) { | | 761 | while (y == 0 && x < max) { |
765 | - x += 8; | | 762 | - x += 8; |
766 | + x += 8; | | 763 | + x += 8; |
767 | y = *buff++; | | 764 | y = *buff++; |
768 | } | | 765 | } |
769 | } | | 766 | } |
770 | @@ -2869,26 +2869,26 @@ unsigned char *buffer; | | 767 | @@ -2869,26 +2869,26 @@ unsigned char *buffer; |
771 | else { | | 768 | else { |
772 | /* black run */ | | 769 | /* black run */ |
773 | while ((y & (1<<i)) != 0 && x < max) { | | 770 | while ((y & (1<<i)) != 0 && x < max) { |
774 | - x++; | | 771 | - x++; |
775 | - i--; | | 772 | - i--; |
776 | + x++; | | 773 | + x++; |
777 | + i--; | | 774 | + i--; |
778 | if (i < 0) { | | 775 | if (i < 0) { |
779 | - i = 7; | | 776 | - i = 7; |
780 | - y = *buff++; | | 777 | - y = *buff++; |
781 | + i = 7; | | 778 | + i = 7; |
782 | + y = *buff++; | | 779 | + y = *buff++; |
783 | while (y == 0xff && x < max) { | | 780 | while (y == 0xff && x < max) { |
784 | - x += 8; | | 781 | - x += 8; |
785 | + x += 8; | | 782 | + x += 8; |
786 | y = *buff++; | | 783 | y = *buff++; |
787 | } | | 784 | } |
788 | } | | 785 | } |
789 | } | | 786 | } |
790 | mode = 0; | | 787 | mode = 0; |
791 | } | | 788 | } |
792 | - if (x > max) | | 789 | - if (x > max) |
793 | + if (x > max) | | 790 | + if (x > max) |
794 | x = max; | | 791 | x = max; |
795 | t += x; | | 792 | t += x; |
796 | /* make precautions for very long runs */ | | 793 | /* make precautions for very long runs */ |
797 | while (x > 0xff) { | | 794 | while (x > 0xff) { |
798 | - *obuf++ = 0xff; | | 795 | - *obuf++ = 0xff; |
799 | - *obuf++ = 0; | | 796 | - *obuf++ = 0; |
800 | + *obuf++ = 0xff; | | 797 | + *obuf++ = 0xff; |
801 | + *obuf++ = 0; | | 798 | + *obuf++ = 0; |
802 | x -= 0xff; | | 799 | x -= 0xff; |
803 | } | | 800 | } |
804 | *obuf++ = x; | | 801 | *obuf++ = x; |
805 | @@ -2968,8 +2968,8 @@ char *argv[]; | | 802 | @@ -2968,8 +2968,8 @@ char *argv[]; |
806 | #endif | | 803 | #endif |
807 | { | | 804 | { |
808 | int argind; /* argument index for flags */ | | 805 | int argind; /* argument index for flags */ |
809 | - char curarea[STRSIZE]; /* current file area */ | | 806 | - char curarea[STRSIZE]; /* current file area */ |
810 | - char curname[STRSIZE]; /* current file name */ | | 807 | - char curname[STRSIZE]; /* current file name */ |
811 | + char *curarea; /* current file area */ | | 808 | + char *curarea; /* current file area */ |
812 | + char *curname; /* current file name */ | | 809 | + char *curname; /* current file name */ |
813 | char *tcp, *tcp1; /* temporary character pointers */ | | 810 | char *tcp, *tcp1; /* temporary character pointers */ |
814 | char *this_arg; | | 811 | char *this_arg; |
815 | double x_offset = 0.0, y_offset = 0.0; | | 812 | double x_offset = 0.0, y_offset = 0.0; |
816 | @@ -2988,9 +2988,9 @@ char *argv[]; | | 813 | @@ -2988,9 +2988,9 @@ char *argv[]; |
817 | #endif | | 814 | #endif |
818 | #endif | | 815 | #endif |
819 | | | 816 | |
820 | - if (argc == 2 && (strcmp (argv[1], "--version") == 0)) { | | 817 | - if (argc == 2 && (strcmp (argv[1], "--version") == 0)) { |
821 | + if (argc == 2 && EQ(argv[1], "--version")) { | | 818 | + if (argc == 2 && EQ(argv[1], "--version")) { |
822 | extern KPSEDLL char *kpathsea_version_string; | | 819 | extern KPSEDLL char *kpathsea_version_string; |
823 | - puts ("dvilj(k) 2.6"); | | 820 | - puts ("dvilj(k) 2.6"); |
824 | + puts (VERSION); | | 821 | + puts (VERSION); |
825 | puts (kpathsea_version_string); | | 822 | puts (kpathsea_version_string); |
826 | puts ("Copyright (C) 1997 Gustaf Neumann.\n\ | | 823 | puts ("Copyright (C) 1997 Gustaf Neumann.\n\ |
827 | There is NO warranty. You may redistribute this software\n\ | | 824 | There is NO warranty. You may redistribute this software\n\ |
828 | @@ -2998,7 +2998,7 @@ under the terms of the GNU General Publi | | 825 | @@ -2998,7 +2998,7 @@ under the terms of the GNU General Publi |
829 | For more information about these matters, see the files\n\ | | 826 | For more information about these matters, see the files\n\ |
830 | named COPYING and dvi2xx.c.\n\ | | 827 | named COPYING and dvi2xx.c.\n\ |
831 | Primary author of Dvi2xx: Gustaf Neumann; -k maintainer: K. Berry."); | | 828 | Primary author of Dvi2xx: Gustaf Neumann; -k maintainer: K. Berry."); |
832 | - exit (0); | | 829 | - exit (0); |
833 | + exit (0); | | 830 | + exit (0); |
834 | } | | 831 | } |
835 | | | 832 | |
836 | #ifdef LJ4 | | 833 | #ifdef LJ4 |
837 | @@ -3048,9 +3048,9 @@ Primary author of Dvi2xx: Gustaf Neumann | | 834 | @@ -3048,9 +3048,9 @@ Primary author of Dvi2xx: Gustaf Neumann |
838 | #ifdef LJ2P | | 835 | #ifdef LJ2P |
839 | case 'd': /* d selects DUPLEX mode */ | | 836 | case 'd': /* d selects DUPLEX mode */ |
840 | tcp++; | | 837 | tcp++; |
841 | - if (*tcp == '1' ) | | 838 | - if (*tcp == '1' ) |
842 | + if (*tcp == '1' ) | | 839 | + if (*tcp == '1' ) |
843 | DuplexMode = 1; | | 840 | DuplexMode = 1; |
844 | - else if (*tcp == '2') | | 841 | - else if (*tcp == '2') |
845 | + else if (*tcp == '2') | | 842 | + else if (*tcp == '2') |
846 | DuplexMode = 2; | | 843 | DuplexMode = 2; |
847 | else { | | 844 | else { |
848 | Warning("Invalid DUPLEX mode, assuming DUPLEX=1, Long-Edge Binding"); | | 845 | Warning("Invalid DUPLEX mode, assuming DUPLEX=1, Long-Edge Binding"); |
849 | @@ -3062,13 +3062,13 @@ Primary author of Dvi2xx: Gustaf Neumann | | 846 | @@ -3062,13 +3062,13 @@ Primary author of Dvi2xx: Gustaf Neumann |
850 | DoublePage = _TRUE; | | 847 | DoublePage = _TRUE; |
851 | tcp++; | | 848 | tcp++; |
852 | if (*tcp == '1' || *tcp == '2') { | | 849 | if (*tcp == '1' || *tcp == '2') { |
853 | - if (*tcp == '2') | | 850 | - if (*tcp == '2') |
854 | + if (*tcp == '2') | | 851 | + if (*tcp == '2') |
855 | PrintFirstPart = _FALSE; | | 852 | PrintFirstPart = _FALSE; |
856 | - else | | 853 | - else |
857 | + else | | 854 | + else |
858 | PrintSecondPart = _FALSE; | | 855 | PrintSecondPart = _FALSE; |
859 | tcp++; | | 856 | tcp++; |
860 | } | | 857 | } |
861 | - if (*tcp == '-') | | 858 | - if (*tcp == '-') |
862 | + if (*tcp == '-') | | 859 | + if (*tcp == '-') |
863 | PrintEmptyPages = _FALSE; | | 860 | PrintEmptyPages = _FALSE; |
864 | break; | | 861 | break; |
865 | #ifdef LJ4 | | 862 | #ifdef LJ4 |
866 | @@ -3256,14 +3256,14 @@ Primary author of Dvi2xx: Gustaf Neumann | | 863 | @@ -3256,14 +3256,14 @@ Primary author of Dvi2xx: Gustaf Neumann |
867 | #ifdef LJ | | 864 | #ifdef LJ |
868 | case 'V': /* bugfixes for various vendor's PCL emulations */ | | 865 | case 'V': /* bugfixes for various vendor's PCL emulations */ |
869 | tcp++; | | 866 | tcp++; |
870 | - if (*tcp == 'K' || *tcp == 'k') | | 867 | - if (*tcp == 'K' || *tcp == 'k') |
871 | + if (*tcp == 'K' || *tcp == 'k') | | 868 | + if (*tcp == 'K' || *tcp == 'k') |
872 | kyocera_mode = _TRUE; | | 869 | kyocera_mode = _TRUE; |
873 | else | | 870 | else |
874 | - if (*tcp == 'B' || *tcp == 'b') | | 871 | - if (*tcp == 'B' || *tcp == 'b') |
875 | + if (*tcp == 'B' || *tcp == 'b') | | 872 | + if (*tcp == 'B' || *tcp == 'b') |
876 | brother_mode = _TRUE; | | 873 | brother_mode = _TRUE; |
877 | # ifdef LJ4 | | 874 | # ifdef LJ4 |
878 | else | | 875 | else |
879 | - if (*tcp == '6' || *tcp == '6') | | 876 | - if (*tcp == '6' || *tcp == '6') |
880 | + if (*tcp == '6' || *tcp == '6') | | 877 | + if (*tcp == '6' || *tcp == '6') |
881 | LJ6 = _TRUE; | | 878 | LJ6 = _TRUE; |
882 | # endif | | 879 | # endif |
883 | break; | | 880 | break; |
884 | @@ -3306,7 +3306,7 @@ Primary author of Dvi2xx: Gustaf Neumann | | 881 | @@ -3306,7 +3306,7 @@ Primary author of Dvi2xx: Gustaf Neumann |
885 | #endif | | 882 | #endif |
886 | #ifdef __riscos | | 883 | #ifdef __riscos |
887 | case 'i': /* name of directory to store diagrams in */ | | 884 | case 'i': /* name of directory to store diagrams in */ |
888 | - tcp++; | | 885 | - tcp++; |
889 | + tcp++; | | 886 | + tcp++; |
890 | ddi = 0; | | 887 | ddi = 0; |
891 | while (*tcp != ' ' && *tcp != '\0' && ddi < DIAGDIRSIZE-1) { | | 888 | while (*tcp != ' ' && *tcp != '\0' && ddi < DIAGDIRSIZE-1) { |
892 | diagdir[ddi++] = *tcp++; | | 889 | diagdir[ddi++] = *tcp++; |
893 | @@ -3328,8 +3328,8 @@ Primary author of Dvi2xx: Gustaf Neumann | | 890 | @@ -3328,8 +3328,8 @@ Primary author of Dvi2xx: Gustaf Neumann |
894 | } | | 891 | } |
895 | } else { | | 892 | } else { |
896 | | | 893 | |
897 | - (void) strcpy(filename, tcp); | | 894 | - (void) strcpy(filename, tcp); |
898 | - if (!strcmp(filename, "-")) { | | 895 | - if (!strcmp(filename, "-")) { |
899 | + filename = tcp; | | 896 | + filename = tcp; |
900 | + if (EQ(filename, "-")) { | | 897 | + if (EQ(filename, "-")) { |
901 | EmitFileName = "-"; | | 898 | EmitFileName = "-"; |
902 | #ifdef RISC_USE_OSL | | 899 | #ifdef RISC_USE_OSL |
903 | dvifp = BINOPEN("Kbd:"); | | 900 | dvifp = BINOPEN("Kbd:"); |
904 | @@ -3339,57 +3339,68 @@ Primary author of Dvi2xx: Gustaf Neumann | | 901 | @@ -3339,57 +3339,68 @@ Primary author of Dvi2xx: Gustaf Neumann |
905 | AssureBinary(fileno(dvifp)); | | 902 | AssureBinary(fileno(dvifp)); |
906 | #endif | | 903 | #endif |
907 | } else { | | 904 | } else { |
908 | + /* Since this code is used only once during startup, we don't care | | 905 | + /* Since this code is used only once during startup, we don't care |
909 | + about free()ing the allocated strings that represent filenames. | | 906 | + about free()ing the allocated strings that represent filenames. |
910 | + It will be more work to realize proper deallocation handling than | | 907 | + It will be more work to realize proper deallocation handling than |
911 | + it's worth in terms of saving a few bytes. We consider these | | 908 | + it's worth in terms of saving a few bytes. We consider these |
912 | + bytes actually static memory where we don't know the size in | | 909 | + bytes actually static memory where we don't know the size in |
913 | + advance and don't add them to the allocated_storage count. | | 910 | + advance and don't add them to the allocated_storage count. |
914 | + [27 Jun 07 -js] */ | | 911 | + [27 Jun 07 -js] */ |
915 | #ifdef KPATHSEA | | 912 | #ifdef KPATHSEA |
916 | /* split into directory + file name */ | | 913 | /* split into directory + file name */ |
917 | int tcplen, argvlen; | | 914 | int tcplen, argvlen; |
918 | tcp = (char *)xbasename(argv[argind]);/* this knows about any kind of slashes */ | | 915 | tcp = (char *)xbasename(argv[argind]);/* this knows about any kind of slashes */ |
919 | tcplen = strlen(tcp); | | 916 | tcplen = strlen(tcp); |
920 | + if ( tcplen == 0 ) { | | 917 | + if ( tcplen == 0 ) { |
921 | + /* This happens when the DVI file name has a trailing slash; this | | 918 | + /* This happens when the DVI file name has a trailing slash; this |
922 | + is not a valid name. Then we terminate the argument parsing | | 919 | + is not a valid name. Then we terminate the argument parsing |
923 | + loop, a usage message will be output below. */ | | 920 | + loop, a usage message will be output below. */ |
924 | + break; | | 921 | + break; |
925 | + } | | 922 | + } |
926 | argvlen = strlen(argv[argind]); | | 923 | argvlen = strlen(argv[argind]); |
927 | if (tcplen == argvlen) | | 924 | if (tcplen == argvlen) |
928 | - curarea[0] = '\0'; | | 925 | - curarea[0] = '\0'; |
929 | + curarea = ""; | | 926 | + curarea = ""; |
930 | else { | | 927 | else { |
931 | - (void) strcpy(curarea, argv[argind]); | | 928 | - (void) strcpy(curarea, argv[argind]); |
932 | + curarea = xstrdup(argv[argind]); | | 929 | + curarea = xstrdup(argv[argind]); |
933 | curarea[argvlen-tcplen] = '\0'; | | 930 | curarea[argvlen-tcplen] = '\0'; |
934 | } | | 931 | } |
935 | #else | | 932 | #else |
936 | tcp = strrchr(argv[argind], '/'); | | 933 | tcp = strrchr(argv[argind], '/'); |
937 | /* split into directory + file name */ | | 934 | /* split into directory + file name */ |
938 | if (tcp == NULL) { | | 935 | if (tcp == NULL) { |
939 | - curarea[0] = '\0'; | | 936 | - curarea[0] = '\0'; |
940 | + curarea[0] = ""; | | 937 | + curarea[0] = ""; |
941 | tcp = argv[argind]; | | 938 | tcp = argv[argind]; |
942 | } else { | | 939 | } else { |
943 | - (void) strcpy(curarea, argv[argind]); | | 940 | - (void) strcpy(curarea, argv[argind]); |
944 | + curarea = xstrdup(argv[argind]); | | 941 | + curarea = xstrdup(argv[argind]); |
945 | curarea[tcp-argv[argind]+1] = '\0'; | | 942 | curarea[tcp-argv[argind]+1] = '\0'; |
946 | tcp += 1; | | 943 | tcp += 1; |
947 | } | | 944 | } |
948 | #endif | | 945 | #endif |
949 | | | 946 | |
950 | - (void) strcpy(curname, tcp); | | 947 | - (void) strcpy(curname, tcp); |
951 | + curname = (char *) xmalloc(strlen(tcp)+5); /* + space for ".dvi" */ | | 948 | + curname = (char *) xmalloc(strlen(tcp)+5); /* + space for ".dvi" */ |
952 | + (void) strcpy(curname, tcp); | | 949 | + (void) strcpy(curname, tcp); |
953 | /* split into file name + extension */ | | 950 | /* split into file name + extension */ |
954 | - tcp1 = strrchr(tcp, '.'); | | 951 | - tcp1 = strrchr(tcp, '.'); |
955 | + tcp1 = strrchr(curname, '.'); | | 952 | + tcp1 = strrchr(curname, '.'); |
956 | if (tcp1 == NULL) { | | 953 | if (tcp1 == NULL) { |
957 | - (void) strcpy(rootname, curname); | | 954 | - (void) strcpy(rootname, curname); |
958 | + rootname = xstrdup(curname); | | 955 | + rootname = xstrdup(curname); |
959 | strcat(curname, ".dvi"); | | 956 | strcat(curname, ".dvi"); |
960 | } else { | | 957 | } else { |
961 | *tcp1 = '\0'; | | 958 | *tcp1 = '\0'; |
962 | - (void) strcpy(rootname, curname); | | 959 | - (void) strcpy(rootname, curname); |
963 | + rootname = xstrdup(curname); | | 960 | + rootname = xstrdup(curname); |
964 | *tcp1 = '.'; | | 961 | *tcp1 = '.'; |
965 | } | | 962 | } |
966 | | | 963 | |
967 | + filename = (char *) xmalloc(strlen(curarea)+strlen(curname)+1); | | 964 | + filename = (char *) xmalloc(strlen(curarea)+strlen(curname)+1); |
968 | (void) strcpy(filename, curarea); | | 965 | (void) strcpy(filename, curarea); |
969 | (void) strcat(filename, curname); | | 966 | (void) strcat(filename, curname); |
970 | | | 967 | |
971 | if ((dvifp = BINOPEN(filename)) == FPNULL) { | | 968 | if ((dvifp = BINOPEN(filename)) == FPNULL) { |
972 | /* do not insist on .dvi */ | | 969 | /* do not insist on .dvi */ |
973 | if (tcp1 == NULL) { | | 970 | if (tcp1 == NULL) { |
974 | - int l = strlen(curname); | | 971 | - int l = strlen(curname); |
975 | - if (l > 4) | | 972 | - if (l > 4) |
976 | - curname[l - 4] = '\0'; | | 973 | - curname[l - 4] = '\0'; |
977 | - l = strlen(filename); | | 974 | - l = strlen(filename); |
978 | - if (l > 4) | | 975 | - if (l > 4) |
979 | - filename[l - 4] = '\0'; | | 976 | - filename[l - 4] = '\0'; |
980 | + filename[strlen(filename) - 4] = '\0'; | | 977 | + filename[strlen(filename) - 4] = '\0'; |
981 | + dvifp = BINOPEN(filename); | | 978 | + dvifp = BINOPEN(filename); |
982 | } | | 979 | } |
983 | - if (tcp1 != NULL || (dvifp = BINOPEN(filename)) == FPNULL) { | | 980 | - if (tcp1 != NULL || (dvifp = BINOPEN(filename)) == FPNULL) { |
984 | + if (dvifp == FPNULL) { | | 981 | + if (dvifp == FPNULL) { |
985 | #ifdef MSC5 | | 982 | #ifdef MSC5 |
986 | Fatal("%s: can't find DVI file \"%s\"\n\n", | | 983 | Fatal("%s: can't find DVI file \"%s\"\n\n", |
987 | G_progname, filename); | | 984 | G_progname, filename); |
988 | @@ -3411,7 +3422,7 @@ Primary author of Dvi2xx: Gustaf Neumann | | 985 | @@ -3411,7 +3422,7 @@ Primary author of Dvi2xx: Gustaf Neumann |
989 | y_goffset = (short) MM_TO_PXL(y_offset) + y_origin; | | 986 | y_goffset = (short) MM_TO_PXL(y_offset) + y_origin; |
990 | | | 987 | |
991 | if (dvifp == FPNULL) { | | 988 | if (dvifp == FPNULL) { |
992 | - fprintf(ERR_STREAM,"\nThis is the DVI to %s converter version %s", | | 989 | - fprintf(ERR_STREAM,"\nThis is the DVI to %s converter version %s", |
993 | + fprintf(ERR_STREAM,"\nThis is the DVI to %s converter %s", | | 990 | + fprintf(ERR_STREAM,"\nThis is the DVI to %s converter %s", |
994 | PRINTER, VERSION); | | 991 | PRINTER, VERSION); |
995 | #ifdef SEVENBIT | | 992 | #ifdef SEVENBIT |
996 | fprintf(ERR_STREAM,", 7bit"); | | 993 | fprintf(ERR_STREAM,", 7bit"); |
997 | @@ -3507,13 +3518,8 @@ Primary author of Dvi2xx: Gustaf Neumann | | 994 | @@ -3507,13 +3518,8 @@ Primary author of Dvi2xx: Gustaf Neumann |
998 | exit(1); | | 995 | exit(1); |
999 | } | | 996 | } |
1000 | if (EQ(EmitFileName, "")) { | | 997 | if (EQ(EmitFileName, "")) { |
1001 | - if ((EmitFileName = (char *)malloc( STRSIZE )) != NULL) | | 998 | - if ((EmitFileName = (char *)malloc( STRSIZE )) != NULL) |
1002 | - allocated_storage += STRSIZE; | | 999 | - allocated_storage += STRSIZE; |
1003 | - else | | 1000 | - else |
1004 | - Fatal("Can't allocate storage of %d bytes\n",STRSIZE); | | 1001 | - Fatal("Can't allocate storage of %d bytes\n",STRSIZE); |
1005 | - (void) strcpy(EmitFileName, curname); | | 1002 | - (void) strcpy(EmitFileName, curname); |
1006 | - if ((tcp1 = strrchr(EmitFileName, '.'))) | | 1003 | - if ((tcp1 = strrchr(EmitFileName, '.'))) |
1007 | - *tcp1 = '\0'; | | 1004 | - *tcp1 = '\0'; |
1008 | + EmitFileName = (char *) xmalloc(strlen(rootname)+sizeof(EMITFILE_EXTENSION)); | | 1005 | + EmitFileName = (char *) xmalloc(strlen(rootname)+sizeof(EMITFILE_EXTENSION)); |
1009 | + (void) strcpy(EmitFileName, rootname); | | 1006 | + (void) strcpy(EmitFileName, rootname); |