| 1 |
diff -up texlive-2007/texk/dviljk/c-auto.in.dviljktemp texlive-2007/texk/dviljk/c-auto.in
|
| 2 |
--- texlive-2007/texk/dviljk/c-auto.in.dviljktemp 2006-01-17 22:41:51.000000000 +0100
|
| 3 |
+++ texlive-2007/texk/dviljk/c-auto.in 2008-08-27 13:32:10.000000000 +0200
|
| 4 |
@@ -1,9 +1,23 @@
|
| 5 |
-/* c-auto.in. Generated automatically from configure.in by autoheader. */
|
| 6 |
+/* c-auto.in. Generated from configure.in by autoheader. */
|
| 7 |
+/* acconfig.h -- used by autoheader when generating c-auto.in.
|
| 8 |
|
| 9 |
-/* Define if type char is unsigned and you are not using gcc. */
|
| 10 |
-#ifndef __CHAR_UNSIGNED__
|
| 11 |
-#undef __CHAR_UNSIGNED__
|
| 12 |
-#endif
|
| 13 |
+ If you're thinking of editing acconfig.h to fix a configuration
|
| 14 |
+ problem, don't. Edit the c-auto.h file created by configure,
|
| 15 |
+ instead. Even better, fix configure to give the right answer. */
|
| 16 |
+
|
| 17 |
+/* Define to 1 if you have the `mkdtemp' function. */
|
| 18 |
+#undef HAVE_MKDTEMP
|
| 19 |
+
|
| 20 |
+/* Define to 1 if you have the `rmdir' function. */
|
| 21 |
+#undef HAVE_RMDIR
|
| 22 |
|
| 23 |
-/* The number of bytes in a long. */
|
| 24 |
+/* Define to 1 if you have the `unlink' function. */
|
| 25 |
+#undef HAVE_UNLINK
|
| 26 |
+
|
| 27 |
+/* The size of a `long', as computed by sizeof. */
|
| 28 |
#undef SIZEOF_LONG
|
| 29 |
+
|
| 30 |
+/* Define to 1 if type `char' is unsigned and you are not using gcc. */
|
| 31 |
+#ifndef __CHAR_UNSIGNED__
|
| 32 |
+# undef __CHAR_UNSIGNED__
|
| 33 |
+#endif
|
| 34 |
diff -U0 texlive-2007/texk/dviljk/ChangeLog.dviljktemp texlive-2007/texk/dviljk/ChangeLog
|
| 35 |
--- texlive-2007/texk/dviljk/ChangeLog.dviljktemp 2006-05-29 22:09:20.000000000 +0200
|
| 36 |
+++ texlive-2007/texk/dviljk/ChangeLog 2008-08-27 13:32:10.000000000 +0200
|
| 37 |
@@ -0,0 +1,39 @@
|
| 38 |
+2007-07-02 Joachim Schrod <jschrod@acm.org>
|
| 39 |
+
|
| 40 |
+ * dvi2xx.c (DoSpecial): Security issue: usage of tmpnam() caused
|
| 41 |
+ tempfile race condition. I use mkdtemp() if it's available and
|
| 42 |
+ fall back to tmpnam.
|
| 43 |
+
|
| 44 |
+ Special parsing of include files was inconsistent, unify it. The
|
| 45 |
+ current parsing code still allows lots of non-sensical special
|
| 46 |
+ commands, but at least it doesn't access unrelated variables any
|
| 47 |
+ more.
|
| 48 |
+
|
| 49 |
+2007-06-28 Joachim Schrod <jschrod@acm.org>
|
| 50 |
+
|
| 51 |
+ * dvi2xx.c: Fixed a whole bunch of buffer overflows: The program
|
| 52 |
+ did not check memory bounds for any string operation. All places
|
| 53 |
+ where strings are copied with strcpy are replaced by dynamically
|
| 54 |
+ allocated strings (with xstrdup from kpathsea) or bounded string
|
| 55 |
+ operations. Fixed also manual string copy operations on special
|
| 56 |
+ strings. Fixed array buffer overflow in defpoint and fill special
|
| 57 |
+ operations.
|
| 58 |
+ (DoSpecial): Call of ghostscript for psfile special had also a
|
| 59 |
+ potential buffer overflow caused by unchecked usage of sprintf.
|
| 60 |
+ Fix core dump: Check if all required parameters of psfile special
|
| 61 |
+ are passed.
|
| 62 |
+
|
| 63 |
+ Bumped version number up to 2.6p3.
|
| 64 |
+
|
| 65 |
+ * dvi2xx.h: Some fixed sized string arrays are pointers now, they
|
| 66 |
+ get dynamically allocated.
|
| 67 |
+ (GetBytes): Another buffer overflow: Check that the buffer size is
|
| 68 |
+ sufficient to store the read bytes. That relies on the invariant
|
| 69 |
+ that the GetBytes macro is always called with an array as argument
|
| 70 |
+ and not with a pointer.
|
| 71 |
+
|
| 72 |
+ * config.h: Throw an error if kpathsea is not used. dvi2xx.c
|
| 73 |
+ had previously already kpathsea dependencies without protecting
|
| 74 |
+ them with #if KPATHSEA. We go that road further since upstream
|
| 75 |
+ does not exist any more.
|
| 76 |
+
|
| 77 |
diff -up texlive-2007/texk/dviljk/config.h.dviljktemp texlive-2007/texk/dviljk/config.h
|
| 78 |
--- texlive-2007/texk/dviljk/config.h.dviljktemp 2006-01-17 22:41:51.000000000 +0100
|
| 79 |
+++ texlive-2007/texk/dviljk/config.h 2008-08-27 13:32:10.000000000 +0200
|
| 80 |
@@ -216,12 +216,7 @@ typedef SCHAR_TYPE signed_char;
|
| 81 |
#endif
|
| 82 |
|
| 83 |
#ifndef KPATHSEA
|
| 84 |
-extern bool findfile(
|
| 85 |
-#if NeedFunctionPrototypes
|
| 86 |
-char path[], char n[], long4 fontmag, char name[],
|
| 87 |
- bool tfm, int level
|
| 88 |
-#endif
|
| 89 |
- );
|
| 90 |
+#error "Would need changed findfile, dviljk has changed allocation semantic of name member in tfontptr"
|
| 91 |
#endif
|
| 92 |
|
| 93 |
|
| 94 |
@@ -444,3 +439,24 @@ typedef FILE *FILEPTR;
|
| 95 |
/* If we have neither, should fall back to fprintf with fixed args. */
|
| 96 |
#endif
|
| 97 |
#endif
|
| 98 |
+
|
| 99 |
+/* If unlink and rmdir are not there, we don't delete the temporary files. */
|
| 100 |
+#ifndef HAVE_RMDIR
|
| 101 |
+#define rmdir(dir)
|
| 102 |
+#endif
|
| 103 |
+#ifndef HAVE_UNLINK
|
| 104 |
+#define unlink(file)
|
| 105 |
+#endif
|
| 106 |
+
|
| 107 |
+/* If mkdtemp() does not exist, we have to use tmpnam(). */
|
| 108 |
+#ifndef HAVE_MKDTEMP
|
| 109 |
+#define mkdtemp(dir) (tmpnam(dir) ? \
|
| 110 |
+ ( mkdir(dir, 0700) == -1 ? NULL : dir ) : \
|
| 111 |
+ ( errno = EINVAL, NULL ) )
|
| 112 |
+#endif
|
| 113 |
+
|
| 114 |
+#ifndef KPATHSEA
|
| 115 |
+/* FIXME: Should provide a strdup function. But currently this tree is
|
| 116 |
+ only used in connection with kpathsea anyhow. */
|
| 117 |
+#error "Need xstrdup and xmalloc function, e.g. from kpathsea"
|
| 118 |
+#endif
|
| 119 |
diff -up texlive-2007/texk/dviljk/configure.in.dviljktemp texlive-2007/texk/dviljk/configure.in
|
| 120 |
--- texlive-2007/texk/dviljk/configure.in.dviljktemp 2006-01-17 22:41:51.000000000 +0100
|
| 121 |
+++ texlive-2007/texk/dviljk/configure.in 2008-08-27 13:32:10.000000000 +0200
|
| 122 |
@@ -13,6 +13,7 @@ sinclude(../kpathsea/withenable.ac)
|
| 123 |
dnl These tests prevent reliable cross-compilation. Sigh.
|
| 124 |
AC_C_CHAR_UNSIGNED
|
| 125 |
AC_CHECK_SIZEOF(long)
|
| 126 |
+AC_CHECK_FUNCS(rmdir unlink mkdtemp)
|
| 127 |
|
| 128 |
KPSE_CONFIG_FILES([Makefile])
|
| 129 |
AC_OUTPUT
|
| 130 |
diff -up texlive-2007/texk/dviljk/dvi2xx.c.dviljktemp texlive-2007/texk/dviljk/dvi2xx.c
|
| 131 |
--- texlive-2007/texk/dviljk/dvi2xx.c.dviljktemp 2006-01-17 22:41:51.000000000 +0100
|
| 132 |
+++ texlive-2007/texk/dviljk/dvi2xx.c 2008-08-27 13:32:10.000000000 +0200
|
| 133 |
@@ -1,5 +1,5 @@
|
| 134 |
/* $Id: dvi2xx.c,v 2.5 1997/12/08 20:52:20 neumann Exp $ */
|
| 135 |
-#define VERSION "2.6p2 (dviljk)"
|
| 136 |
+#define VERSION "dviljk (version 2.6p3)"
|
| 137 |
/*
|
| 138 |
#define DEBUGGS 1
|
| 139 |
*/
|
| 140 |
@@ -173,7 +173,7 @@ char *argv[];
|
| 141 |
y_origin = YDEFAULTOFF; /* y-origin in dots */
|
| 142 |
|
| 143 |
setbuf(ERR_STREAM, NULL);
|
| 144 |
- (void) strcpy(G_progname, argv[0]);
|
| 145 |
+ G_progname = argv[0];
|
| 146 |
#ifdef KPATHSEA
|
| 147 |
kpse_set_progname(argv[0]);
|
| 148 |
kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile);
|
| 149 |
@@ -2968,8 +2968,8 @@ char *argv[];
|
| 150 |
#endif
|
| 151 |
{
|
| 152 |
int argind; /* argument index for flags */
|
| 153 |
- char curarea[STRSIZE]; /* current file area */
|
| 154 |
- char curname[STRSIZE]; /* current file name */
|
| 155 |
+ char *curarea; /* current file area */
|
| 156 |
+ char *curname; /* current file name */
|
| 157 |
char *tcp, *tcp1; /* temporary character pointers */
|
| 158 |
char *this_arg;
|
| 159 |
double x_offset = 0.0, y_offset = 0.0;
|
| 160 |
@@ -2988,9 +2988,9 @@ char *argv[];
|
| 161 |
#endif
|
| 162 |
#endif
|
| 163 |
|
| 164 |
- if (argc == 2 && (strcmp (argv[1], "--version") == 0)) {
|
| 165 |
+ if (argc == 2 && EQ(argv[1], "--version")) {
|
| 166 |
extern KPSEDLL char *kpathsea_version_string;
|
| 167 |
- puts ("dvilj(k) 2.6");
|
| 168 |
+ puts (VERSION);
|
| 169 |
puts (kpathsea_version_string);
|
| 170 |
puts ("Copyright (C) 1997 Gustaf Neumann.\n\
|
| 171 |
There is NO warranty. You may redistribute this software\n\
|
| 172 |
@@ -3328,8 +3328,8 @@ Primary author of Dvi2xx: Gustaf Neumann
|
| 173 |
}
|
| 174 |
} else {
|
| 175 |
|
| 176 |
- (void) strcpy(filename, tcp);
|
| 177 |
- if (!strcmp(filename, "-")) {
|
| 178 |
+ filename = tcp;
|
| 179 |
+ if (EQ(filename, "-")) {
|
| 180 |
EmitFileName = "-";
|
| 181 |
#ifdef RISC_USE_OSL
|
| 182 |
dvifp = BINOPEN("Kbd:");
|
| 183 |
@@ -3339,57 +3339,68 @@ Primary author of Dvi2xx: Gustaf Neumann
|
| 184 |
AssureBinary(fileno(dvifp));
|
| 185 |
#endif
|
| 186 |
} else {
|
| 187 |
+ /* Since this code is used only once during startup, we don't care
|
| 188 |
+ about free()ing the allocated strings that represent filenames.
|
| 189 |
+ It will be more work to realize proper deallocation handling than
|
| 190 |
+ it's worth in terms of saving a few bytes. We consider these
|
| 191 |
+ bytes actually static memory where we don't know the size in
|
| 192 |
+ advance and don't add them to the allocated_storage count.
|
| 193 |
+ [27 Jun 07 -js] */
|
| 194 |
#ifdef KPATHSEA
|
| 195 |
/* split into directory + file name */
|
| 196 |
int tcplen, argvlen;
|
| 197 |
tcp = (char *)xbasename(argv[argind]);/* this knows about any kind of slashes */
|
| 198 |
tcplen = strlen(tcp);
|
| 199 |
+ if ( tcplen == 0 ) {
|
| 200 |
+ /* This happens when the DVI file name has a trailing slash; this
|
| 201 |
+ is not a valid name. Then we terminate the argument parsing
|
| 202 |
+ loop, a usage message will be output below. */
|
| 203 |
+ break;
|
| 204 |
+ }
|
| 205 |
argvlen = strlen(argv[argind]);
|
| 206 |
if (tcplen == argvlen)
|
| 207 |
- curarea[0] = '\0';
|
| 208 |
+ curarea = "";
|
| 209 |
else {
|
| 210 |
- (void) strcpy(curarea, argv[argind]);
|
| 211 |
+ curarea = xstrdup(argv[argind]);
|
| 212 |
curarea[argvlen-tcplen] = '\0';
|
| 213 |
}
|
| 214 |
#else
|
| 215 |
tcp = strrchr(argv[argind], '/');
|
| 216 |
/* split into directory + file name */
|
| 217 |
if (tcp == NULL) {
|
| 218 |
- curarea[0] = '\0';
|
| 219 |
+ curarea[0] = "";
|
| 220 |
tcp = argv[argind];
|
| 221 |
} else {
|
| 222 |
- (void) strcpy(curarea, argv[argind]);
|
| 223 |
+ curarea = xstrdup(argv[argind]);
|
| 224 |
curarea[tcp-argv[argind]+1] = '\0';
|
| 225 |
tcp += 1;
|
| 226 |
}
|
| 227 |
#endif
|
| 228 |
|
| 229 |
+ curname = (char *) xmalloc(strlen(tcp)+5); /* + space for ".dvi" */
|
| 230 |
(void) strcpy(curname, tcp);
|
| 231 |
/* split into file name + extension */
|
| 232 |
- tcp1 = strrchr(tcp, '.');
|
| 233 |
+ tcp1 = strrchr(curname, '.');
|
| 234 |
if (tcp1 == NULL) {
|
| 235 |
- (void) strcpy(rootname, curname);
|
| 236 |
+ rootname = xstrdup(curname);
|
| 237 |
strcat(curname, ".dvi");
|
| 238 |
} else {
|
| 239 |
*tcp1 = '\0';
|
| 240 |
- (void) strcpy(rootname, curname);
|
| 241 |
+ rootname = xstrdup(curname);
|
| 242 |
*tcp1 = '.';
|
| 243 |
}
|
| 244 |
|
| 245 |
+ filename = (char *) xmalloc(strlen(curarea)+strlen(curname)+1);
|
| 246 |
(void) strcpy(filename, curarea);
|
| 247 |
(void) strcat(filename, curname);
|
| 248 |
|
| 249 |
if ((dvifp = BINOPEN(filename)) == FPNULL) {
|
| 250 |
/* do not insist on .dvi */
|
| 251 |
if (tcp1 == NULL) {
|
| 252 |
- int l = strlen(curname);
|
| 253 |
- if (l > 4)
|
| 254 |
- curname[l - 4] = '\0';
|
| 255 |
- l = strlen(filename);
|
| 256 |
- if (l > 4)
|
| 257 |
- filename[l - 4] = '\0';
|
| 258 |
+ filename[strlen(filename) - 4] = '\0';
|
| 259 |
+ dvifp = BINOPEN(filename);
|
| 260 |
}
|
| 261 |
- if (tcp1 != NULL || (dvifp = BINOPEN(filename)) == FPNULL) {
|
| 262 |
+ if (dvifp == FPNULL) {
|
| 263 |
#ifdef MSC5
|
| 264 |
Fatal("%s: can't find DVI file \"%s\"\n\n",
|
| 265 |
G_progname, filename);
|
| 266 |
@@ -3411,7 +3422,7 @@ Primary author of Dvi2xx: Gustaf Neumann
|
| 267 |
y_goffset = (short) MM_TO_PXL(y_offset) + y_origin;
|
| 268 |
|
| 269 |
if (dvifp == FPNULL) {
|
| 270 |
- fprintf(ERR_STREAM,"\nThis is the DVI to %s converter version %s",
|
| 271 |
+ fprintf(ERR_STREAM,"\nThis is the DVI to %s converter %s",
|
| 272 |
PRINTER, VERSION);
|
| 273 |
#ifdef SEVENBIT
|
| 274 |
fprintf(ERR_STREAM,", 7bit");
|
| 275 |
@@ -3507,13 +3518,8 @@ Primary author of Dvi2xx: Gustaf Neumann
|
| 276 |
exit(1);
|
| 277 |
}
|
| 278 |
if (EQ(EmitFileName, "")) {
|
| 279 |
- if ((EmitFileName = (char *)malloc( STRSIZE )) != NULL)
|
| 280 |
- allocated_storage += STRSIZE;
|
| 281 |
- else
|
| 282 |
- Fatal("Can't allocate storage of %d bytes\n",STRSIZE);
|
| 283 |
- (void) strcpy(EmitFileName, curname);
|
| 284 |
- if ((tcp1 = strrchr(EmitFileName, '.')))
|
| 285 |
- *tcp1 = '\0';
|
| 286 |
+ EmitFileName = (char *) xmalloc(strlen(rootname)+sizeof(EMITFILE_EXTENSION));
|
| 287 |
+ (void) strcpy(EmitFileName, rootname);
|
| 288 |
strcat(EmitFileName, EMITFILE_EXTENSION);
|
| 289 |
}
|
| 290 |
if (G_quiet)
|
| 291 |
@@ -3698,6 +3704,8 @@ bool PFlag;
|
| 292 |
#endif
|
| 293 |
}
|
| 294 |
CloseFiles();
|
| 295 |
+ if ( tmp_dir[0] != '\0' )
|
| 296 |
+ rmdir (tmp_dir); /* ignore errors */
|
| 297 |
exit(G_errenc);
|
| 298 |
}
|
| 299 |
|
| 300 |
@@ -3895,22 +3903,21 @@ char *str;
|
| 301 |
int n;
|
| 302 |
#endif
|
| 303 |
{
|
| 304 |
- char spbuf[STRSIZE], xs[STRSIZE], ys[STRSIZE];
|
| 305 |
- char *sf = NULL, *psfile = NULL;
|
| 306 |
+ char xs[STRSIZE], ys[STRSIZE];
|
| 307 |
+ char *include_file = NULL;
|
| 308 |
+ enum { VerbFile, HPFile, PSFile } file_type;
|
| 309 |
float x,y;
|
| 310 |
long4 x_pos, y_pos;
|
| 311 |
KeyWord k;
|
| 312 |
int i, j, j1;
|
| 313 |
static int GrayScale = 10, Pattern = 1;
|
| 314 |
static bool GrayFill = _TRUE;
|
| 315 |
- static long4 p_x[80], p_y[80];
|
| 316 |
- int llx=0, lly=0, urx=0, ury=0, rwi=0, rhi=0;
|
| 317 |
-#ifdef WIN32
|
| 318 |
- char *gs_path;
|
| 319 |
-#endif
|
| 320 |
+ static long4 p_x[MAX_SPECIAL_DEFPOINTS], p_y[MAX_SPECIAL_DEFPOINTS];
|
| 321 |
+ int llx=0, lly=0, urx=0, ury=0, rwi=0;
|
| 322 |
|
| 323 |
str[n] = '\0';
|
| 324 |
- spbuf[0] = '\0';
|
| 325 |
+ for ( i=0 ; i<MAX_SPECIAL_DEFPOINTS ; i++ )
|
| 326 |
+ p_x[i] = p_y[i] = -1;
|
| 327 |
|
| 328 |
SetPosn(h, v);
|
| 329 |
#ifdef __riscos
|
| 330 |
@@ -3924,41 +3931,30 @@ int n;
|
| 331 |
/* get all keyword-value pairs */
|
| 332 |
/* for compatibility, single words are taken as file names */
|
| 333 |
if ( k.vt == None && access(k.Key, 0) == 0) {
|
| 334 |
- if ( sf
|
| 335 |
-#ifdef KPATHSEA
|
| 336 |
- && !kpse_tex_hush ("special")
|
| 337 |
-#endif
|
| 338 |
- )
|
| 339 |
- Warning("More than one \\special file name given. %s ignored", sf);
|
| 340 |
- (void) strcpy(spbuf, k.Key);
|
| 341 |
- sf = spbuf;
|
| 342 |
- /*
|
| 343 |
- for (j = 1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++);
|
| 344 |
- */
|
| 345 |
- } else if ( GetKeyVal( &k, KeyTab, NKEYS, &i ) && i != -1 )
|
| 346 |
+ if ( include_file && !kpse_tex_hush ("special") ) {
|
| 347 |
+ Warning("More than one \\special file name given. %s ignored", include_file);
|
| 348 |
+ free (include_file);
|
| 349 |
+ }
|
| 350 |
+ include_file = xstrdup(k.Key);
|
| 351 |
+ file_type = VerbFile;
|
| 352 |
+ } else if ( GetKeyVal( &k, KeyTab, NKEYS, &i ) && i != -1 ) {
|
| 353 |
switch (i) {
|
| 354 |
case PSFILE:
|
| 355 |
- if (sf
|
| 356 |
-#ifdef KPATHSEA
|
| 357 |
- && !kpse_tex_hush ("special")
|
| 358 |
-#endif
|
| 359 |
- )
|
| 360 |
- Warning("More than one \\special file name given. %s ignored", sf);
|
| 361 |
- (void) strcpy(spbuf, k.Val);
|
| 362 |
- psfile = spbuf;
|
| 363 |
- /*
|
| 364 |
- for (j=1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++);
|
| 365 |
- */
|
| 366 |
+ if ( include_file ) {
|
| 367 |
+ Warning("More than one \\special file name given. %s ignored", include_file);
|
| 368 |
+ free(include_file);
|
| 369 |
+ }
|
| 370 |
+ include_file = xstrdup(k.Val);
|
| 371 |
+ file_type = PSFile;
|
| 372 |
break;
|
| 373 |
|
| 374 |
case HPFILE:
|
| 375 |
- if (sf)
|
| 376 |
- Warning("More than one \\special file name given. %s ignored", sf);
|
| 377 |
- (void) strcpy(spbuf, k.Val);
|
| 378 |
- sf = spbuf;
|
| 379 |
- /*
|
| 380 |
- for (j=1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++);
|
| 381 |
- */
|
| 382 |
+ if ( include_file && !kpse_tex_hush ("special") ) {
|
| 383 |
+ Warning("More than one \\special file name given. %s ignored", include_file);
|
| 384 |
+ free(include_file);
|
| 385 |
+ }
|
| 386 |
+ include_file = xstrdup(k.Val);
|
| 387 |
+ file_type = HPFile;
|
| 388 |
break;
|
| 389 |
|
| 390 |
case ORIENTATION:
|
| 391 |
@@ -3978,23 +3974,24 @@ int n;
|
| 392 |
}
|
| 393 |
#endif
|
| 394 |
else
|
| 395 |
-#ifdef KPATHSEA
|
| 396 |
- if (!kpse_tex_hush ("special"))
|
| 397 |
-#endif
|
| 398 |
Warning( "Invalid orientation (%d)given; ignored.", k.v.i);
|
| 399 |
break;
|
| 400 |
|
| 401 |
case RESETPOINTS:
|
| 402 |
- (void) strcpy(spbuf, k.Val);
|
| 403 |
-
|
| 404 |
- sf = NULL;
|
| 405 |
+ for ( i=0 ; i<MAX_SPECIAL_DEFPOINTS ; i++ )
|
| 406 |
+ p_x[i] = p_y[i] = -1;
|
| 407 |
break;
|
| 408 |
|
| 409 |
case DEFPOINT:
|
| 410 |
- (void) strcpy(spbuf, k.Val);
|
| 411 |
- i = sscanf(spbuf,"%d(%[^,],%s)",&j,xs,ys);
|
| 412 |
+ /* 254 is STRSIZE-1. cpp should be used to construct that number. */
|
| 413 |
+ i = sscanf(k.Val,"%d(%254[^,],%254s)",&j,xs,ys);
|
| 414 |
if (i>0) {
|
| 415 |
- x_pos = h;
|
| 416 |
+ if ( j < 0 || j >= MAX_SPECIAL_DEFPOINTS ) {
|
| 417 |
+ Warning ("defpoint %d ignored, must be between 0 and %d",
|
| 418 |
+ j, MAX_SPECIAL_DEFPOINTS);
|
| 419 |
+ break;
|
| 420 |
+ }
|
| 421 |
+ x_pos = h;
|
| 422 |
y_pos = v;
|
| 423 |
if (i>1) {
|
| 424 |
if (sscanf(xs,"%fpt",&x)>0) {
|
| 425 |
@@ -4011,19 +4008,32 @@ int n;
|
| 426 |
p_x[j]=x_pos;
|
| 427 |
p_y[j]=y_pos;
|
| 428 |
} else
|
| 429 |
-#ifdef KPATHSEA
|
| 430 |
- if (!kpse_tex_hush ("special"))
|
| 431 |
-#endif
|
| 432 |
Warning("invalid point definition\n");
|
| 433 |
-
|
| 434 |
- sf = NULL;
|
| 435 |
break;
|
| 436 |
|
| 437 |
case FILL:
|
| 438 |
- (void) strcpy(spbuf, k.Val);
|
| 439 |
- i = sscanf(spbuf,"%d/%d %s",&j,&j1,xs);
|
| 440 |
+ /* 254 is STRSIZE-1. cpp should be used to construct that number. */
|
| 441 |
+ i = sscanf(k.Val,"%d/%d %254s",&j,&j1,xs);
|
| 442 |
if (i>1) {
|
| 443 |
#ifdef LJ
|
| 444 |
+ if ( j < 0 || j >= MAX_SPECIAL_DEFPOINTS ) {
|
| 445 |
+ Warning ("fill ignored, point %d must be between 0 and %d",
|
| 446 |
+ j, MAX_SPECIAL_DEFPOINTS);
|
| 447 |
+ break;
|
| 448 |
+ }
|
| 449 |
+ if ( p_x[j] == -1 ) {
|
| 450 |
+ Warning ("fill ignored, point %d is undefined\n", j);
|
| 451 |
+ break;
|
| 452 |
+ }
|
| 453 |
+ if ( j1 < 0 || j1 >= MAX_SPECIAL_DEFPOINTS ) {
|
| 454 |
+ Warning ("fill ignored, point %d must be between 0 and %d",
|
| 455 |
+ j1, MAX_SPECIAL_DEFPOINTS);
|
| 456 |
+ break;
|
| 457 |
+ }
|
| 458 |
+ if ( p_x[j1] == -1 ) {
|
| 459 |
+ Warning ("fill ignored, point %d is undefined\n", j1);
|
| 460 |
+ break;
|
| 461 |
+ }
|
| 462 |
SetPosn(p_x[j], p_y[j]);
|
| 463 |
x_pos = (long4)PIXROUND(p_x[j1]-p_x[j], hconv);
|
| 464 |
y_pos = (long4)PIXROUND(p_y[j1]-p_y[j], vconv);
|
| 465 |
@@ -4044,9 +4054,6 @@ int n;
|
| 466 |
GrayScale = k.v.i;
|
| 467 |
GrayFill = _TRUE;
|
| 468 |
} else
|
| 469 |
-#ifdef KPATHSEA
|
| 470 |
- if (!kpse_tex_hush ("special"))
|
| 471 |
-#endif
|
| 472 |
Warning( "Invalid gray scale (%d) given; ignored.", k.v.i);
|
| 473 |
break;
|
| 474 |
|
| 475 |
@@ -4055,9 +4062,6 @@ int n;
|
| 476 |
Pattern = k.v.i;
|
| 477 |
GrayFill = _FALSE;
|
| 478 |
} else
|
| 479 |
-#ifdef KPATHSEA
|
| 480 |
- if (!kpse_tex_hush ("special"))
|
| 481 |
-#endif
|
| 482 |
Warning( "Invalid pattern (%d) given; ignored.", k.v.i);
|
| 483 |
break;
|
| 484 |
|
| 485 |
@@ -4066,75 +4070,123 @@ int n;
|
| 486 |
case URX: urx = k.v.i; break;
|
| 487 |
case URY: ury = k.v.i; break;
|
| 488 |
case RWI: rwi = k.v.i; break;
|
| 489 |
- case RHI: rhi = k.v.i; break;
|
| 490 |
+ case RHI:
|
| 491 |
+ if (!kpse_tex_hush ("special"))
|
| 492 |
+ Warning("Whatever rhi was good for once, it is ignored now.");
|
| 493 |
+ break;
|
| 494 |
|
| 495 |
default:
|
| 496 |
-#ifdef KPATHSEA
|
| 497 |
- if (!kpse_tex_hush ("special"))
|
| 498 |
-#endif
|
| 499 |
+ if ( !kpse_tex_hush ("special") )
|
| 500 |
Warning("Can't handle %s=%s command; ignored.", k.Key, k.Val);
|
| 501 |
break;
|
| 502 |
}
|
| 503 |
-
|
| 504 |
- else
|
| 505 |
-#ifdef KPATHSEA
|
| 506 |
- if (!kpse_tex_hush ("special"))
|
| 507 |
-#endif
|
| 508 |
+
|
| 509 |
+ } else if (!kpse_tex_hush ("special")) {
|
| 510 |
Warning("Invalid keyword or value in \\special - <%s> ignored", k.Key);
|
| 511 |
+ }
|
| 512 |
+
|
| 513 |
+ free (k.Key);
|
| 514 |
+ if ( k.Val != NULL ) free(k.Val);
|
| 515 |
}
|
| 516 |
|
| 517 |
- if ( sf || psfile ) {
|
| 518 |
+ if ( include_file ) {
|
| 519 |
last_rx = last_ry = UNKNOWN;
|
| 520 |
#ifdef IBM3812
|
| 521 |
PMPflush;
|
| 522 |
#endif
|
| 523 |
- if (sf) {
|
| 524 |
- if (i == HPFILE)
|
| 525 |
- CopyHPFile( sf );
|
| 526 |
- else
|
| 527 |
- CopyFile( sf );
|
| 528 |
- }
|
| 529 |
- else
|
| 530 |
+
|
| 531 |
#ifdef LJ
|
| 532 |
- if (psfile) {
|
| 533 |
+ if ( file_type == PSFile) {
|
| 534 |
/* int height = rwi * (urx - llx) / (ury - lly);*/
|
| 535 |
int width = urx - llx;
|
| 536 |
int height = ury - lly;
|
| 537 |
char cmd[255];
|
| 538 |
- int scale_factor = 3000 * width / rwi;
|
| 539 |
- int adjusted_height = height * 300/scale_factor;
|
| 540 |
- int adjusted_llx = llx * 300/scale_factor;
|
| 541 |
+ char *cmd_format = "%s -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit";
|
| 542 |
+ char *gs_cmd;
|
| 543 |
+ int scale_factor, adjusted_height, adjusted_llx;
|
| 544 |
char *printer = "ljetplus"; /* use the most stupid one */
|
| 545 |
|
| 546 |
-
|
| 547 |
- char scale_file_name[255];
|
| 548 |
- char *scale_file = tmpnam(scale_file_name);
|
| 549 |
- char *pcl_file = tmpnam(NULL);
|
| 550 |
+ char pcl_file[STRSIZE];
|
| 551 |
+ char scale_file[STRSIZE];
|
| 552 |
FILEPTR scalef;
|
| 553 |
|
| 554 |
- if ( (scalef = BOUTOPEN(scale_file)) == FPNULL ) {
|
| 555 |
- Warning("Unable to open file %s for writing", scale_file );
|
| 556 |
- return;
|
| 557 |
- }
|
| 558 |
- fprintf(scalef, "%.2f %.2f scale\n%d %d translate\n",
|
| 559 |
- 300.0/scale_factor, 300.0/scale_factor,
|
| 560 |
- 0, adjusted_height == height ? 0 : ury);
|
| 561 |
- BCLOSE( scalef );
|
| 562 |
+ if ( urx == 0 || ury == 0 || rwi == 0 ) {
|
| 563 |
+ /* Since dvips' psfile special has a different syntax, this might
|
| 564 |
+ well be one of those specials, i.e., a non-dviljk special. Then
|
| 565 |
+ the Warning should be suppressable. */
|
| 566 |
+ if ( !kpse_tex_hush ("special") )
|
| 567 |
+ Warning ("Ignoring psfile special without urx, ury and rwi attributes");
|
| 568 |
+ free (include_file);
|
| 569 |
+ return;
|
| 570 |
+ }
|
| 571 |
+ scale_factor = 3000 * width / rwi;
|
| 572 |
+ adjusted_height = height * 300/scale_factor;
|
| 573 |
+ adjusted_llx = llx * 300/scale_factor;
|
| 574 |
+
|
| 575 |
+ /* We cannot use mkstemp, as we cannot pass two open file descriptors
|
| 576 |
+ portably to Ghostscript. We don't want to use tmpnam() or tempnam()
|
| 577 |
+ either, as they have tempfile creation race conditions. Instead we
|
| 578 |
+ create a temporary directory with mkdtemp() -- if that's available.
|
| 579 |
+ If not, we are thrown back to tempnam(), to get our functionality
|
| 580 |
+ at all. We need to create the temporary directory only once per
|
| 581 |
+ run; it will be deleted in AllDone(). */
|
| 582 |
+ if ( tmp_dir[0] == '\0' ) {
|
| 583 |
+ char * base_dir;
|
| 584 |
+ if ( (base_dir = getenv("TMPDIR")) == NULL ) {
|
| 585 |
+ base_dir = "/tmp";
|
| 586 |
+ } else if ( strlen(base_dir) > STRSIZE - sizeof("/dviljkXXXXXX/include.pcl") ) {
|
| 587 |
+ Warning ("TMPDIR %s is too long, using /tmp instead", base_dir);
|
| 588 |
+ base_dir = "/tmp";
|
| 589 |
+ }
|
| 590 |
+ if ( base_dir[0] == '/' && base_dir[1] == '\0' ) {
|
| 591 |
+ Warning ("Feeling naughty, do we? / is no temporary directory, dude");
|
| 592 |
+ base_dir = "/tmp";
|
| 593 |
+ }
|
| 594 |
+ strcpy (tmp_dir, base_dir);
|
| 595 |
+ strcat (tmp_dir, "/dviljkXXXXXX");
|
| 596 |
+ if ( mkdtemp(tmp_dir) == NULL ) {
|
| 597 |
+ Warning ("Could not create temporary directory %s, errno = %d; ignoring include file special",
|
| 598 |
+ tmp_dir, errno);
|
| 599 |
+ return;
|
| 600 |
+ }
|
| 601 |
+ }
|
| 602 |
+ strcpy(pcl_file, tmp_dir);
|
| 603 |
+ strcat(pcl_file, "/include.pcl");
|
| 604 |
+ strcpy(scale_file, tmp_dir);
|
| 605 |
+ strcat(scale_file, "/scale.ps");
|
| 606 |
+
|
| 607 |
+ if ( (scalef = BOUTOPEN(scale_file)) == FPNULL ) {
|
| 608 |
+ Warning("Unable to open file %s for writing", scale_file );
|
| 609 |
+ free (include_file);
|
| 610 |
+ unlink(scale_file); /* ignore error */
|
| 611 |
+ return;
|
| 612 |
+ }
|
| 613 |
+ fprintf(scalef, "%.2f %.2f scale\n%d %d translate\n",
|
| 614 |
+ 300.0/scale_factor, 300.0/scale_factor,
|
| 615 |
+ 0, adjusted_height == height ? 0 : ury);
|
| 616 |
+ BCLOSE( scalef );
|
| 617 |
|
| 618 |
#ifdef WIN32
|
| 619 |
- gs_path = getenv("GS_PATH");
|
| 620 |
- if (!gs_path)
|
| 621 |
- gs_path = "gswin32c.exe";
|
| 622 |
- sprintf(cmd,"%s -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit",
|
| 623 |
- gs_path, printer, pcl_file, scale_file, psfile);
|
| 624 |
+ if ( (gs_cmd = getenv("GS_PATH")) == NULL )
|
| 625 |
+ gs_cmd = "gswin32c.exe";
|
| 626 |
#else
|
| 627 |
- sprintf(cmd,"gs -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit",
|
| 628 |
- printer, pcl_file, scale_file, psfile);
|
| 629 |
+ gs_cmd = "gs";
|
| 630 |
#endif
|
| 631 |
+ if ( strlen(cmd_format)-10 + strlen(gs_cmd) + strlen(printer) +
|
| 632 |
+ strlen(pcl_file) + strlen(scale_file) + strlen(include_file) +1 >
|
| 633 |
+ sizeof(cmd) ) {
|
| 634 |
+ Warning ("Ghostscript command for %s would be too long, skipping special", include_file);
|
| 635 |
+ free (include_file);
|
| 636 |
+ unlink(scale_file); /* ignore errors */
|
| 637 |
+ unlink(pcl_file);
|
| 638 |
+ return;
|
| 639 |
+ }
|
| 640 |
+ sprintf(cmd, cmd_format,
|
| 641 |
+ gs_cmd, printer, pcl_file, scale_file, include_file);
|
| 642 |
#ifdef DEBUGGS
|
| 643 |
fprintf(stderr,
|
| 644 |
"PS-file '%s' w=%d, h=%d, urx=%d, ury=%d, llx=%d, lly=%d, rwi=%d\n",
|
| 645 |
- psfile, urx - llx, height, urx,ury,llx,lly, rwi);
|
| 646 |
+ include_file, urx - llx, height, urx,ury,llx,lly, rwi);
|
| 647 |
fprintf(stderr,"%s\n",cmd);
|
| 648 |
#endif
|
| 649 |
if (system(cmd)) {
|
| 650 |
@@ -4158,11 +4210,21 @@ int n;
|
| 651 |
#endif
|
| 652 |
|
| 653 |
CopyHPFile( pcl_file );
|
| 654 |
- /* unlink(pcl_file); */
|
| 655 |
- /* unlink(scale_file); */
|
| 656 |
- }
|
| 657 |
}
|
| 658 |
+ unlink(scale_file); /* ignore errors */
|
| 659 |
+ unlink(pcl_file);
|
| 660 |
+ }
|
| 661 |
+ else
|
| 662 |
#endif /* LJ */
|
| 663 |
+
|
| 664 |
+ if ( file_type == HPFile )
|
| 665 |
+ CopyHPFile( include_file );
|
| 666 |
+ else if ( file_type == VerbFile )
|
| 667 |
+ CopyFile( include_file );
|
| 668 |
+ else
|
| 669 |
+ Warning ("This can't happen: unknown file_type value %d", file_type);
|
| 670 |
+
|
| 671 |
+ if ( include_file != NULL ) free(include_file);
|
| 672 |
}
|
| 673 |
}
|
| 674 |
|
| 675 |
@@ -4173,12 +4235,11 @@ int n;
|
| 676 |
/**********************************************************************/
|
| 677 |
/***************************** GetKeyStr ****************************/
|
| 678 |
/**********************************************************************/
|
| 679 |
-/* extract first keyword-value pair from string (value part may be null)
|
| 680 |
- * return pointer to remainder of string
|
| 681 |
- * return NULL if none found
|
| 682 |
+/* Extract first keyword-value pair from string (value part may be null),
|
| 683 |
+ * keyword and value are allocated and must be free by caller.
|
| 684 |
+ * Return pointer to remainder of string,
|
| 685 |
+ * return NULL if none found.
|
| 686 |
*/
|
| 687 |
-char KeyStr[STRSIZE];
|
| 688 |
-char ValStr[STRSIZE];
|
| 689 |
#if NeedFunctionPrototypes
|
| 690 |
char *GetKeyStr(char *str, KeyWord *kw )
|
| 691 |
#else
|
| 692 |
@@ -4187,39 +4248,46 @@ char *str;
|
| 693 |
KeyWord *kw;
|
| 694 |
#endif
|
| 695 |
{
|
| 696 |
- char *s, *k, *v, t;
|
| 697 |
+ char *s, *start;
|
| 698 |
+ char save_char, quote_char;
|
| 699 |
if ( !str )
|
| 700 |
return( NULL );
|
| 701 |
for (s = str; *s == ' '; s++)
|
| 702 |
; /* skip over blanks */
|
| 703 |
if (*s == '\0')
|
| 704 |
return( NULL );
|
| 705 |
- for (k = KeyStr; /* extract keyword portion */
|
| 706 |
- *s != ' ' && *s != '\0' && *s != '=';
|
| 707 |
- *k++ = *s++)
|
| 708 |
- ;
|
| 709 |
- *k = '\0';
|
| 710 |
- kw->Key = KeyStr;
|
| 711 |
- kw->Val = v = NULL;
|
| 712 |
+ start = s++; /* start of keyword */
|
| 713 |
+ while ( *s != ' ' && *s != '\0' && *s != '=' ) /* locate end */
|
| 714 |
+ s++;
|
| 715 |
+ save_char = *s;
|
| 716 |
+ *s = '\0';
|
| 717 |
+ kw->Key = xstrdup(start);
|
| 718 |
+ kw->Val = NULL;
|
| 719 |
kw->vt = None;
|
| 720 |
- for ( ; *s == ' '; s++)
|
| 721 |
- ; /* skip over blanks */
|
| 722 |
- if ( *s != '=' ) /* look for "=" */
|
| 723 |
+ if ( save_char == '\0' ) /* shortcut when we're at the end */
|
| 724 |
+ return (s);
|
| 725 |
+ *s = save_char; /* restore keyword end char */
|
| 726 |
+ while ( *s == ' ' ) s++ ; /* skip over blanks */
|
| 727 |
+ if ( *s != '=' ) /* no "=" means no value */
|
| 728 |
return( s );
|
| 729 |
- for (s++; *s == ' '; s++); /* skip over blanks */
|
| 730 |
- if ( *s == '\'' || *s == '\"' ) /* get string delimiter */
|
| 731 |
- t = *s++;
|
| 732 |
+ for (s++; *s == ' '; s++)
|
| 733 |
+ ; /* skip over blanks */
|
| 734 |
+ if ( *s == '\'' || *s == '\"' ) /* get string delimiter */
|
| 735 |
+ quote_char = *s++;
|
| 736 |
else
|
| 737 |
- t = ' ';
|
| 738 |
- for (v = ValStr; /* copy value portion up to delim */
|
| 739 |
- *s != t && *s != '\0';
|
| 740 |
- *v++ = *s++)
|
| 741 |
- ;
|
| 742 |
- if ( t != ' ' && *s == t )
|
| 743 |
- s++;
|
| 744 |
- *v = '\0';
|
| 745 |
- kw->Val = ValStr;
|
| 746 |
+ quote_char = ' ';
|
| 747 |
+ start = s; /* no increment, might be "" as value */
|
| 748 |
+ while ( *s != quote_char && *s != '\0' )
|
| 749 |
+ s++; /* locate end of value portion */
|
| 750 |
+ save_char = *s;
|
| 751 |
+ *s = '\0';
|
| 752 |
+ kw->Val = xstrdup(start);
|
| 753 |
kw->vt = String;
|
| 754 |
+ if ( save_char != '\0' ) { /* save_char is now quote_char */
|
| 755 |
+ *s = save_char;
|
| 756 |
+ if ( quote_char != ' ' ) /* we had real quote chars */
|
| 757 |
+ s++;
|
| 758 |
+ }
|
| 759 |
return( s );
|
| 760 |
}
|
| 761 |
|
| 762 |
@@ -4819,13 +4887,14 @@ struct font_entry *fontptr;
|
| 763 |
the resident fonts. */
|
| 764 |
if (tfm_read_info(fontptr->n, &tfm_info)
|
| 765 |
&& tfm_info.family[0]
|
| 766 |
- && strcmp((char *)tfm_info.family, "HPAUTOTFM") == 0) {
|
| 767 |
+ && EQ((char *)tfm_info.family, "HPAUTOTFM")) {
|
| 768 |
unsigned i;
|
| 769 |
double factor = fontptr->s / (double)0x100000;
|
| 770 |
|
| 771 |
resident_count++;
|
| 772 |
fontptr->resident_p = _TRUE;
|
| 773 |
- strcpy(fontptr->symbol_set, (char *)tfm_info.coding_scheme);
|
| 774 |
+ strncpy(fontptr->symbol_set, (char *)tfm_info.coding_scheme, 39);
|
| 775 |
+ fontptr->symbol_set[39] = '\0';
|
| 776 |
fontptr->resid = tfm_info.typeface_id;
|
| 777 |
fontptr->spacing = tfm_info.spacing;
|
| 778 |
fontptr->style = tfm_info.style;
|
| 779 |
@@ -4878,7 +4947,7 @@ struct font_entry *fontptr;
|
| 780 |
fontptr->resident_p = _FALSE;
|
| 781 |
|
| 782 |
if (tfm_info.family[0]
|
| 783 |
- && strcmp((char *)tfm_info.family, "UNSPECIFIED") == 0) {
|
| 784 |
+ && EQ((char *)tfm_info.family, "UNSPECIFIED")) {
|
| 785 |
Warning("font family for %s is UNSPECIFIED; need to run dvicopy?",
|
| 786 |
fontptr->n);
|
| 787 |
fontptr->font_file_id = NO_FILE;
|
| 788 |
@@ -5031,10 +5100,9 @@ printf("[%ld]=%lf * %lf * %lf + 0.5 = %l
|
| 789 |
if (tfontptr->resident_p)
|
| 790 |
return;
|
| 791 |
|
| 792 |
- if (!(resident_font_located)) {
|
| 793 |
+ if (!(resident_font_located))
|
| 794 |
#endif
|
| 795 |
|
| 796 |
-#ifdef KPATHSEA
|
| 797 |
{
|
| 798 |
kpse_glyph_file_type font_ret;
|
| 799 |
char *name;
|
| 800 |
@@ -5047,9 +5115,9 @@ printf("[%ld]=%lf * %lf * %lf + 0.5 = %l
|
| 801 |
if (name)
|
| 802 |
{
|
| 803 |
font_found = _TRUE;
|
| 804 |
- strcpy (tfontptr->name, name);
|
| 805 |
- free (name);
|
| 806 |
-
|
| 807 |
+ tfontptr->name = name;
|
| 808 |
+ allocated_storage += strlen(name)+1;
|
| 809 |
+
|
| 810 |
if (!FILESTRCASEEQ (tfontptr->n, font_ret.name)) {
|
| 811 |
fprintf (stderr,
|
| 812 |
"dvilj: Font %s not found, using %s at %d instead.\n",
|
| 813 |
@@ -5071,29 +5139,6 @@ printf("[%ld]=%lf * %lf * %lf + 0.5 = %l
|
| 814 |
tfontptr->n, dpi);
|
| 815 |
}
|
| 816 |
}
|
| 817 |
-#else /* not KPATHSEA */
|
| 818 |
- if (!(findfile(PXLpath,
|
| 819 |
- tfontptr->n,
|
| 820 |
- tfontptr->font_mag,
|
| 821 |
- tfontptr->name,
|
| 822 |
- _FALSE,
|
| 823 |
- 0))) {
|
| 824 |
- Warning(tfontptr->name); /* contains error messsage */
|
| 825 |
- tfontptr->font_file_id = NO_FILE;
|
| 826 |
-#ifdef __riscos
|
| 827 |
- MakeMetafontFile(PXLpath, tfontptr->n, tfontptr->font_mag);
|
| 828 |
-#endif
|
| 829 |
- }
|
| 830 |
- else {
|
| 831 |
- font_found = _TRUE;
|
| 832 |
- if (G_verbose)
|
| 833 |
- fprintf(ERR_STREAM,"%d: using font <%s>\n", plusid, tfontptr->name);
|
| 834 |
- }
|
| 835 |
-#endif /* not KPATHSEA */
|
| 836 |
-
|
| 837 |
-#ifdef LJ_RESIDENT_FONTS
|
| 838 |
- }
|
| 839 |
-#endif
|
| 840 |
|
| 841 |
tfontptr->plusid = plusid;
|
| 842 |
plusid++;
|
| 843 |
diff -up texlive-2007/texk/dviljk/dvi2xx.h.dviljktemp texlive-2007/texk/dviljk/dvi2xx.h
|
| 844 |
--- texlive-2007/texk/dviljk/dvi2xx.h.dviljktemp 2006-01-17 22:41:51.000000000 +0100
|
| 845 |
+++ texlive-2007/texk/dviljk/dvi2xx.h 2008-08-27 13:32:10.000000000 +0200
|
| 846 |
@@ -10,8 +10,8 @@
|
| 847 |
|
| 848 |
#ifdef KPATHSEA
|
| 849 |
#include <kpathsea/config.h>
|
| 850 |
+#include <kpathsea/c-std.h>
|
| 851 |
#include <kpathsea/c-limits.h>
|
| 852 |
-#include <kpathsea/c-memstr.h>
|
| 853 |
#include <kpathsea/magstep.h>
|
| 854 |
#include <kpathsea/proginit.h>
|
| 855 |
#include <kpathsea/progname.h>
|
| 856 |
@@ -24,6 +24,7 @@
|
| 857 |
#include <string.h>
|
| 858 |
#include <stdio.h>
|
| 859 |
#include <stdlib.h>
|
| 860 |
+#include <unistd.h>
|
| 861 |
#ifdef unix
|
| 862 |
#include <limits.h>
|
| 863 |
#endif
|
| 864 |
@@ -41,9 +42,6 @@
|
| 865 |
#ifdef MSC5
|
| 866 |
#include <dos.h> /* only for binaryopen on device */
|
| 867 |
#endif
|
| 868 |
-#if defined (unix) && !defined (KPATHSEA)
|
| 869 |
-#include <limits.h>
|
| 870 |
-#endif
|
| 871 |
|
| 872 |
|
| 873 |
#include "config.h"
|
| 874 |
@@ -116,6 +114,7 @@
|
| 875 |
#define HUGE_SIZE (unsigned char) 2
|
| 876 |
#define HUGE_CHAR_PATTERN 32767l
|
| 877 |
#define BYTES_PER_PIXEL_LINE 500 /* max number of bytes per pixel line */
|
| 878 |
+#define MAX_SPECIAL_DEFPOINTS 80 /* max number of defpoint specials */
|
| 879 |
|
| 880 |
|
| 881 |
#define PK_POST 245
|
| 882 |
@@ -281,7 +280,14 @@ char *MFMODE = MFMODE600;
|
| 883 |
#define VisChar(c) (unsigned char)(c)
|
| 884 |
#endif
|
| 885 |
|
| 886 |
-#define GetBytes(fp,buf,n) read_multi(buf,1,n,fp) /* used to be a function */
|
| 887 |
+/* Used to be a function. buf is always an array, never a pointer.
|
| 888 |
+ Without that invariant, we would have to introduce full dynamic
|
| 889 |
+ memory management in this driver -- probably it would be easier to
|
| 890 |
+ write a new one. [27 Jun 07 -js] */
|
| 891 |
+#define GetBytes(fp,buf,n) \
|
| 892 |
+ ( sizeof(buf) != sizeof(void *) && sizeof(buf) > n ? \
|
| 893 |
+ read_multi(buf, 1, n, fp) \
|
| 894 |
+ : Fatal("Try to read %d bytes in an array of size %d", n, sizeof(buf)) )
|
| 895 |
|
| 896 |
|
| 897 |
/**********************************************************************/
|
| 898 |
@@ -307,6 +313,7 @@ int printf();
|
| 899 |
int sscanf();
|
| 900 |
int strcmp();
|
| 901 |
char *strcpy();
|
| 902 |
+char *strncpy();
|
| 903 |
# ifdef MSC5
|
| 904 |
unsigned int strlen();
|
| 905 |
# endif
|
| 906 |
@@ -393,7 +400,7 @@ struct font_entry { /* font entry */
|
| 907 |
char n[STRSIZE]; /* FNT_DEF command parameters */
|
| 908 |
long4 font_mag; /* computed from FNT_DEF s and d parameters */
|
| 909 |
/*char psname[STRSIZE];*/ /* PostScript name of the font */
|
| 910 |
- char name[STRSIZE]; /* full name of PXL file */
|
| 911 |
+ char *name; /* full name of PXL file */
|
| 912 |
FILEPTR font_file_id; /* file identifier (NO_FILE if none) */
|
| 913 |
#ifdef USEPXL
|
| 914 |
long4 magnification; /* magnification read from PXL file */
|
| 915 |
@@ -487,8 +494,8 @@ void LoadAChar DVIPROTO((long4, regis
|
| 916 |
long4 NoSignExtend DVIPROTO((FILEPTR, int));
|
| 917 |
void OpenFontFile DVIPROTO((void));
|
| 918 |
long4 PixRound DVIPROTO((long4, long4));
|
| 919 |
-void PkRaster DVIPROTO((struct char_entry *, int));
|
| 920 |
-void RasterLine DVIPROTO((struct char_entry *, unsigned int,
|
| 921 |
+void PkRaster DVIPROTO((struct char_entry *, int));
|
| 922 |
+void RasterLine DVIPROTO((struct char_entry *, unsigned int,
|
| 923 |
unsigned int, unsigned char *));
|
| 924 |
void RasterChar DVIPROTO((struct char_entry *));
|
| 925 |
void ReadFontDef DVIPROTO((long4));
|
| 926 |
@@ -534,11 +541,12 @@ bool LastPageSpecified = _FALSE;
|
| 927 |
#ifndef KPATHSEA
|
| 928 |
char *PXLpath = FONTAREA;
|
| 929 |
#endif
|
| 930 |
-char G_progname[STRSIZE]; /* program name */
|
| 931 |
-char filename[STRSIZE]; /* DVI file name */
|
| 932 |
-char rootname[STRSIZE]; /* DVI filename without extension */
|
| 933 |
+char *G_progname; /* program name */
|
| 934 |
+char *filename; /* DVI file name */
|
| 935 |
+char *rootname; /* DVI filename without extension */
|
| 936 |
char *HeaderFileName = ""; /* file name & path of Headerfile */
|
| 937 |
char *EmitFileName = ""; /* file name & path for output */
|
| 938 |
+char tmp_dir[STRSIZE] = ""; /* temporary directory for auxilliary files */
|
| 939 |
#ifdef IBM3812
|
| 940 |
bool FirstAlternate = _FALSE; /* first page from alternate casette ? */
|
| 941 |
#endif
|