|
|
/* $Id: dvi2xx.c,v 2.5 1997/12/08 20:52:20 neumann Exp $ */ | /* $Id: dvi2xx.c,v 2.5 1997/12/08 20:52:20 neumann Exp $ */ |
#define VERSION "2.6p2 (dviljk)" |
#define VERSION "dviljk (version 2.6p3)" |
/* | /* |
#define DEBUGGS 1 | #define DEBUGGS 1 |
*/ | */ |
|
|
y_origin = YDEFAULTOFF; /* y-origin in dots */ | y_origin = YDEFAULTOFF; /* y-origin in dots */ |
| |
setbuf(ERR_STREAM, NULL); | setbuf(ERR_STREAM, NULL); |
(void) strcpy(G_progname, argv[0]); |
G_progname = argv[0]; |
#ifdef KPATHSEA | #ifdef KPATHSEA |
kpse_set_progname(argv[0]); | kpse_set_progname(argv[0]); |
kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile); | kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile); |
|
|
#endif | #endif |
{ | { |
int argind; /* argument index for flags */ | int argind; /* argument index for flags */ |
char curarea[STRSIZE]; /* current file area */ |
char *curarea; /* current file area */ |
char curname[STRSIZE]; /* current file name */ |
char *curname; /* current file name */ |
char *tcp, *tcp1; /* temporary character pointers */ | char *tcp, *tcp1; /* temporary character pointers */ |
char *this_arg; | char *this_arg; |
double x_offset = 0.0, y_offset = 0.0; | double x_offset = 0.0, y_offset = 0.0; |
|
|
#endif | #endif |
#endif | #endif |
| |
if (argc == 2 && (strcmp (argv[1], "--version") == 0)) { |
if (argc == 2 && EQ(argv[1], "--version")) { |
extern KPSEDLL char *kpathsea_version_string; | extern KPSEDLL char *kpathsea_version_string; |
puts ("dvilj(k) 2.6"); |
puts (VERSION); |
puts (kpathsea_version_string); | puts (kpathsea_version_string); |
puts ("Copyright (C) 1997 Gustaf Neumann.\n\ | puts ("Copyright (C) 1997 Gustaf Neumann.\n\ |
There is NO warranty. You may redistribute this software\n\ | There is NO warranty. You may redistribute this software\n\ |
|
Lines 3328-3335
Primary author of Dvi2xx: Gustaf Neumann
|
Link Here
|
|---|
|
} | } |
} else { | } else { |
| |
(void) strcpy(filename, tcp); |
filename = tcp; |
if (!strcmp(filename, "-")) { |
if (EQ(filename, "-")) { |
EmitFileName = "-"; | EmitFileName = "-"; |
#ifdef RISC_USE_OSL | #ifdef RISC_USE_OSL |
dvifp = BINOPEN("Kbd:"); | dvifp = BINOPEN("Kbd:"); |
|
Lines 3339-3395
Primary author of Dvi2xx: Gustaf Neumann
|
Link Here
|
|---|
|
AssureBinary(fileno(dvifp)); | AssureBinary(fileno(dvifp)); |
#endif | #endif |
} else { | } else { |
|
/* Since this code is used only once during startup, we don't care |
|
about free()ing the allocated strings that represent filenames. |
|
It will be more work to realize proper deallocation handling than |
|
it's worth in terms of saving a few bytes. We consider these |
|
bytes actually static memory where we don't know the size in |
|
advance and don't add them to the allocated_storage count. |
|
[27 Jun 07 -js] */ |
#ifdef KPATHSEA | #ifdef KPATHSEA |
/* split into directory + file name */ | /* split into directory + file name */ |
int tcplen, argvlen; | int tcplen, argvlen; |
tcp = (char *)xbasename(argv[argind]);/* this knows about any kind of slashes */ | tcp = (char *)xbasename(argv[argind]);/* this knows about any kind of slashes */ |
tcplen = strlen(tcp); | tcplen = strlen(tcp); |
|
if ( tcplen == 0 ) { |
|
/* This happens when the DVI file name has a trailing slash; this |
|
is not a valid name. Then we terminate the argument parsing |
|
loop, a usage message will be output below. */ |
|
break; |
|
} |
argvlen = strlen(argv[argind]); | argvlen = strlen(argv[argind]); |
if (tcplen == argvlen) | if (tcplen == argvlen) |
curarea[0] = '\0'; |
curarea = ""; |
else { | else { |
(void) strcpy(curarea, argv[argind]); |
curarea = xstrdup(argv[argind]); |
curarea[argvlen-tcplen] = '\0'; | curarea[argvlen-tcplen] = '\0'; |
} | } |
#else | #else |
tcp = strrchr(argv[argind], '/'); | tcp = strrchr(argv[argind], '/'); |
/* split into directory + file name */ | /* split into directory + file name */ |
if (tcp == NULL) { | if (tcp == NULL) { |
curarea[0] = '\0'; |
curarea[0] = ""; |
tcp = argv[argind]; | tcp = argv[argind]; |
} else { | } else { |
(void) strcpy(curarea, argv[argind]); |
curarea = xstrdup(argv[argind]); |
curarea[tcp-argv[argind]+1] = '\0'; | curarea[tcp-argv[argind]+1] = '\0'; |
tcp += 1; | tcp += 1; |
} | } |
#endif | #endif |
| |
|
curname = (char *) xmalloc(strlen(tcp)+5); /* + space for ".dvi" */ |
(void) strcpy(curname, tcp); | (void) strcpy(curname, tcp); |
/* split into file name + extension */ | /* split into file name + extension */ |
tcp1 = strrchr(tcp, '.'); |
tcp1 = strrchr(curname, '.'); |
if (tcp1 == NULL) { | if (tcp1 == NULL) { |
(void) strcpy(rootname, curname); |
rootname = xstrdup(curname); |
strcat(curname, ".dvi"); | strcat(curname, ".dvi"); |
} else { | } else { |
*tcp1 = '\0'; | *tcp1 = '\0'; |
(void) strcpy(rootname, curname); |
rootname = xstrdup(curname); |
*tcp1 = '.'; | *tcp1 = '.'; |
} | } |
| |
|
filename = (char *) xmalloc(strlen(curarea)+strlen(curname)+1); |
(void) strcpy(filename, curarea); | (void) strcpy(filename, curarea); |
(void) strcat(filename, curname); | (void) strcat(filename, curname); |
| |
if ((dvifp = BINOPEN(filename)) == FPNULL) { | if ((dvifp = BINOPEN(filename)) == FPNULL) { |
/* do not insist on .dvi */ | /* do not insist on .dvi */ |
if (tcp1 == NULL) { | if (tcp1 == NULL) { |
int l = strlen(curname); |
filename[strlen(filename) - 4] = '\0'; |
if (l > 4) |
dvifp = BINOPEN(filename); |
curname[l - 4] = '\0'; |
|
l = strlen(filename); |
|
if (l > 4) |
|
filename[l - 4] = '\0'; |
|
} | } |
if (tcp1 != NULL || (dvifp = BINOPEN(filename)) == FPNULL) { |
if (dvifp == FPNULL) { |
#ifdef MSC5 | #ifdef MSC5 |
Fatal("%s: can't find DVI file \"%s\"\n\n", | Fatal("%s: can't find DVI file \"%s\"\n\n", |
G_progname, filename); | G_progname, filename); |
|
Lines 3411-3417
Primary author of Dvi2xx: Gustaf Neumann
|
Link Here
|
|---|
|
y_goffset = (short) MM_TO_PXL(y_offset) + y_origin; | y_goffset = (short) MM_TO_PXL(y_offset) + y_origin; |
| |
if (dvifp == FPNULL) { | if (dvifp == FPNULL) { |
fprintf(ERR_STREAM,"\nThis is the DVI to %s converter version %s", |
fprintf(ERR_STREAM,"\nThis is the DVI to %s converter %s", |
PRINTER, VERSION); | PRINTER, VERSION); |
#ifdef SEVENBIT | #ifdef SEVENBIT |
fprintf(ERR_STREAM,", 7bit"); | fprintf(ERR_STREAM,", 7bit"); |
|
Lines 3507-3519
Primary author of Dvi2xx: Gustaf Neumann
|
Link Here
|
|---|
|
exit(1); | exit(1); |
} | } |
if (EQ(EmitFileName, "")) { | if (EQ(EmitFileName, "")) { |
if ((EmitFileName = (char *)malloc( STRSIZE )) != NULL) |
EmitFileName = (char *) xmalloc(strlen(rootname)+sizeof(EMITFILE_EXTENSION)); |
allocated_storage += STRSIZE; |
(void) strcpy(EmitFileName, rootname); |
else |
|
Fatal("Can't allocate storage of %d bytes\n",STRSIZE); |
|
(void) strcpy(EmitFileName, curname); |
|
if ((tcp1 = strrchr(EmitFileName, '.'))) |
|
*tcp1 = '\0'; |
|
strcat(EmitFileName, EMITFILE_EXTENSION); | strcat(EmitFileName, EMITFILE_EXTENSION); |
} | } |
if (G_quiet) | if (G_quiet) |
|
|
#endif | #endif |
} | } |
CloseFiles(); | CloseFiles(); |
|
if ( tmp_dir[0] != '\0' ) |
|
rmdir (tmp_dir); /* ignore errors */ |
exit(G_errenc); | exit(G_errenc); |
} | } |
| |
|
|
int n; | int n; |
#endif | #endif |
{ | { |
char spbuf[STRSIZE], xs[STRSIZE], ys[STRSIZE]; |
char xs[STRSIZE], ys[STRSIZE]; |
char *sf = NULL, *psfile = NULL; |
char *include_file = NULL; |
|
enum { VerbFile, HPFile, PSFile } file_type; |
float x,y; | float x,y; |
long4 x_pos, y_pos; | long4 x_pos, y_pos; |
KeyWord k; | KeyWord k; |
int i, j, j1; | int i, j, j1; |
static int GrayScale = 10, Pattern = 1; | static int GrayScale = 10, Pattern = 1; |
static bool GrayFill = _TRUE; | static bool GrayFill = _TRUE; |
static long4 p_x[80], p_y[80]; |
static long4 p_x[MAX_SPECIAL_DEFPOINTS], p_y[MAX_SPECIAL_DEFPOINTS]; |
int llx=0, lly=0, urx=0, ury=0, rwi=0, rhi=0; |
int llx=0, lly=0, urx=0, ury=0, rwi=0; |
#ifdef WIN32 |
|
char *gs_path; |
|
#endif |
|
| |
str[n] = '\0'; | str[n] = '\0'; |
spbuf[0] = '\0'; |
for ( i=0 ; i<MAX_SPECIAL_DEFPOINTS ; i++ ) |
|
p_x[i] = p_y[i] = -1; |
| |
SetPosn(h, v); | SetPosn(h, v); |
#ifdef __riscos | #ifdef __riscos |
|
|
/* get all keyword-value pairs */ | /* get all keyword-value pairs */ |
/* for compatibility, single words are taken as file names */ | /* for compatibility, single words are taken as file names */ |
if ( k.vt == None && access(k.Key, 0) == 0) { | if ( k.vt == None && access(k.Key, 0) == 0) { |
if ( sf |
if ( include_file && !kpse_tex_hush ("special") ) { |
#ifdef KPATHSEA |
Warning("More than one \\special file name given. %s ignored", include_file); |
&& !kpse_tex_hush ("special") |
free (include_file); |
#endif |
} |
) |
include_file = xstrdup(k.Key); |
Warning("More than one \\special file name given. %s ignored", sf); |
file_type = VerbFile; |
(void) strcpy(spbuf, k.Key); |
} else if ( GetKeyVal( &k, KeyTab, NKEYS, &i ) && i != -1 ) { |
sf = spbuf; |
|
/* |
|
for (j = 1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++); |
|
*/ |
|
} else if ( GetKeyVal( &k, KeyTab, NKEYS, &i ) && i != -1 ) |
|
switch (i) { | switch (i) { |
case PSFILE: | case PSFILE: |
if (sf |
if ( include_file ) { |
#ifdef KPATHSEA |
Warning("More than one \\special file name given. %s ignored", include_file); |
&& !kpse_tex_hush ("special") |
free(include_file); |
#endif |
} |
) |
include_file = xstrdup(k.Val); |
Warning("More than one \\special file name given. %s ignored", sf); |
file_type = PSFile; |
(void) strcpy(spbuf, k.Val); |
|
psfile = spbuf; |
|
/* |
|
for (j=1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++); |
|
*/ |
|
break; | break; |
| |
case HPFILE: | case HPFILE: |
if (sf) |
if ( include_file && !kpse_tex_hush ("special") ) { |
Warning("More than one \\special file name given. %s ignored", sf); |
Warning("More than one \\special file name given. %s ignored", include_file); |
(void) strcpy(spbuf, k.Val); |
free(include_file); |
sf = spbuf; |
} |
/* |
include_file = xstrdup(k.Val); |
for (j=1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++); |
file_type = HPFile; |
*/ |
|
break; | break; |
| |
case ORIENTATION: | case ORIENTATION: |
|
|
} | } |
#endif | #endif |
else | else |
#ifdef KPATHSEA |
|
if (!kpse_tex_hush ("special")) |
|
#endif |
|
Warning( "Invalid orientation (%d)given; ignored.", k.v.i); | Warning( "Invalid orientation (%d)given; ignored.", k.v.i); |
break; | break; |
| |
case RESETPOINTS: | case RESETPOINTS: |
(void) strcpy(spbuf, k.Val); |
for ( i=0 ; i<MAX_SPECIAL_DEFPOINTS ; i++ ) |
|
p_x[i] = p_y[i] = -1; |
sf = NULL; |
|
break; | break; |
| |
case DEFPOINT: | case DEFPOINT: |
(void) strcpy(spbuf, k.Val); |
/* 254 is STRSIZE-1. cpp should be used to construct that number. */ |
i = sscanf(spbuf,"%d(%[^,],%s)",&j,xs,ys); |
i = sscanf(k.Val,"%d(%254[^,],%254s)",&j,xs,ys); |
if (i>0) { | if (i>0) { |
x_pos = h; |
if ( j < 0 || j >= MAX_SPECIAL_DEFPOINTS ) { |
|
Warning ("defpoint %d ignored, must be between 0 and %d", |
|
j, MAX_SPECIAL_DEFPOINTS); |
|
break; |
|
} |
|
x_pos = h; |
y_pos = v; | y_pos = v; |
if (i>1) { | if (i>1) { |
if (sscanf(xs,"%fpt",&x)>0) { | if (sscanf(xs,"%fpt",&x)>0) { |
|
|
p_x[j]=x_pos; | p_x[j]=x_pos; |
p_y[j]=y_pos; | p_y[j]=y_pos; |
} else | } else |
#ifdef KPATHSEA |
|
if (!kpse_tex_hush ("special")) |
|
#endif |
|
Warning("invalid point definition\n"); | Warning("invalid point definition\n"); |
|
|
sf = NULL; |
|
break; | break; |
| |
case FILL: | case FILL: |
(void) strcpy(spbuf, k.Val); |
/* 254 is STRSIZE-1. cpp should be used to construct that number. */ |
i = sscanf(spbuf,"%d/%d %s",&j,&j1,xs); |
i = sscanf(k.Val,"%d/%d %254s",&j,&j1,xs); |
if (i>1) { | if (i>1) { |
#ifdef LJ | #ifdef LJ |
|
if ( j < 0 || j >= MAX_SPECIAL_DEFPOINTS ) { |
|
Warning ("fill ignored, point %d must be between 0 and %d", |
|
j, MAX_SPECIAL_DEFPOINTS); |
|
break; |
|
} |
|
if ( p_x[j] == -1 ) { |
|
Warning ("fill ignored, point %d is undefined\n", j); |
|
break; |
|
} |
|
if ( j1 < 0 || j1 >= MAX_SPECIAL_DEFPOINTS ) { |
|
Warning ("fill ignored, point %d must be between 0 and %d", |
|
j1, MAX_SPECIAL_DEFPOINTS); |
|
break; |
|
} |
|
if ( p_x[j1] == -1 ) { |
|
Warning ("fill ignored, point %d is undefined\n", j1); |
|
break; |
|
} |
SetPosn(p_x[j], p_y[j]); | SetPosn(p_x[j], p_y[j]); |
x_pos = (long4)PIXROUND(p_x[j1]-p_x[j], hconv); | x_pos = (long4)PIXROUND(p_x[j1]-p_x[j], hconv); |
y_pos = (long4)PIXROUND(p_y[j1]-p_y[j], vconv); | y_pos = (long4)PIXROUND(p_y[j1]-p_y[j], vconv); |
|
|
GrayScale = k.v.i; | GrayScale = k.v.i; |
GrayFill = _TRUE; | GrayFill = _TRUE; |
} else | } else |
#ifdef KPATHSEA |
|
if (!kpse_tex_hush ("special")) |
|
#endif |
|
Warning( "Invalid gray scale (%d) given; ignored.", k.v.i); | Warning( "Invalid gray scale (%d) given; ignored.", k.v.i); |
break; | break; |
| |
|
|
Pattern = k.v.i; | Pattern = k.v.i; |
GrayFill = _FALSE; | GrayFill = _FALSE; |
} else | } else |
#ifdef KPATHSEA |
|
if (!kpse_tex_hush ("special")) |
|
#endif |
|
Warning( "Invalid pattern (%d) given; ignored.", k.v.i); | Warning( "Invalid pattern (%d) given; ignored.", k.v.i); |
break; | break; |
| |
|
|
case URX: urx = k.v.i; break; | case URX: urx = k.v.i; break; |
case URY: ury = k.v.i; break; | case URY: ury = k.v.i; break; |
case RWI: rwi = k.v.i; break; | case RWI: rwi = k.v.i; break; |
case RHI: rhi = k.v.i; break; |
case RHI: |
|
if (!kpse_tex_hush ("special")) |
|
Warning("Whatever rhi was good for once, it is ignored now."); |
|
break; |
| |
default: | default: |
#ifdef KPATHSEA |
if ( !kpse_tex_hush ("special") ) |
if (!kpse_tex_hush ("special")) |
|
#endif |
|
Warning("Can't handle %s=%s command; ignored.", k.Key, k.Val); | Warning("Can't handle %s=%s command; ignored.", k.Key, k.Val); |
break; | break; |
} | } |
|
|
else |
} else if (!kpse_tex_hush ("special")) { |
#ifdef KPATHSEA |
|
if (!kpse_tex_hush ("special")) |
|
#endif |
|
Warning("Invalid keyword or value in \\special - <%s> ignored", k.Key); | Warning("Invalid keyword or value in \\special - <%s> ignored", k.Key); |
|
} |
|
|
|
free (k.Key); |
|
if ( k.Val != NULL ) free(k.Val); |
} | } |
| |
if ( sf || psfile ) { |
if ( include_file ) { |
last_rx = last_ry = UNKNOWN; | last_rx = last_ry = UNKNOWN; |
#ifdef IBM3812 | #ifdef IBM3812 |
PMPflush; | PMPflush; |
#endif | #endif |
if (sf) { |
|
if (i == HPFILE) |
|
CopyHPFile( sf ); |
|
else |
|
CopyFile( sf ); |
|
} |
|
else |
|
#ifdef LJ | #ifdef LJ |
if (psfile) { |
if ( file_type == PSFile) { |
/* int height = rwi * (urx - llx) / (ury - lly);*/ | /* int height = rwi * (urx - llx) / (ury - lly);*/ |
int width = urx - llx; | int width = urx - llx; |
int height = ury - lly; | int height = ury - lly; |
char cmd[255]; | char cmd[255]; |
int scale_factor = 3000 * width / rwi; |
char *cmd_format = "%s -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit"; |
int adjusted_height = height * 300/scale_factor; |
char *gs_cmd; |
int adjusted_llx = llx * 300/scale_factor; |
int scale_factor, adjusted_height, adjusted_llx; |
char *printer = "ljetplus"; /* use the most stupid one */ | char *printer = "ljetplus"; /* use the most stupid one */ |
| |
|
char pcl_file[STRSIZE]; |
char scale_file_name[255]; |
char scale_file[STRSIZE]; |
char *scale_file = tmpnam(scale_file_name); |
|
char *pcl_file = tmpnam(NULL); |
|
FILEPTR scalef; | FILEPTR scalef; |
| |
if ( (scalef = BOUTOPEN(scale_file)) == FPNULL ) { |
if ( urx == 0 || ury == 0 || rwi == 0 ) { |
Warning("Unable to open file %s for writing", scale_file ); |
/* Since dvips' psfile special has a different syntax, this might |
return; |
well be one of those specials, i.e., a non-dviljk special. Then |
} |
the Warning should be suppressable. */ |
fprintf(scalef, "%.2f %.2f scale\n%d %d translate\n", |
if ( !kpse_tex_hush ("special") ) |
300.0/scale_factor, 300.0/scale_factor, |
Warning ("Ignoring psfile special without urx, ury and rwi attributes"); |
0, adjusted_height == height ? 0 : ury); |
free (include_file); |
BCLOSE( scalef ); |
return; |
|
} |
|
scale_factor = 3000 * width / rwi; |
|
adjusted_height = height * 300/scale_factor; |
|
adjusted_llx = llx * 300/scale_factor; |
|
|
|
/* We cannot use mkstemp, as we cannot pass two open file descriptors |
|
portably to Ghostscript. We don't want to use tmpnam() or tempnam() |
|
either, as they have tempfile creation race conditions. Instead we |
|
create a temporary directory with mkdtemp() -- if that's available. |
|
If not, we are thrown back to tempnam(), to get our functionality |
|
at all. We need to create the temporary directory only once per |
|
run; it will be deleted in AllDone(). */ |
|
if ( tmp_dir[0] == '\0' ) { |
|
char * base_dir; |
|
if ( (base_dir = getenv("TMPDIR")) == NULL ) { |
|
base_dir = "/tmp"; |
|
} else if ( strlen(base_dir) > STRSIZE - sizeof("/dviljkXXXXXX/include.pcl") ) { |
|
Warning ("TMPDIR %s is too long, using /tmp instead", base_dir); |
|
base_dir = "/tmp"; |
|
} |
|
if ( base_dir[0] == '/' && base_dir[1] == '\0' ) { |
|
Warning ("Feeling naughty, do we? / is no temporary directory, dude"); |
|
base_dir = "/tmp"; |
|
} |
|
strcpy (tmp_dir, base_dir); |
|
strcat (tmp_dir, "/dviljkXXXXXX"); |
|
if ( mkdtemp(tmp_dir) == NULL ) { |
|
Warning ("Could not create temporary directory %s, errno = %d; ignoring include file special", |
|
tmp_dir, errno); |
|
return; |
|
} |
|
} |
|
strcpy(pcl_file, tmp_dir); |
|
strcat(pcl_file, "/include.pcl"); |
|
strcpy(scale_file, tmp_dir); |
|
strcat(scale_file, "/scale.ps"); |
|
|
|
if ( (scalef = BOUTOPEN(scale_file)) == FPNULL ) { |
|
Warning("Unable to open file %s for writing", scale_file ); |
|
free (include_file); |
|
unlink(scale_file); /* ignore error */ |
|
return; |
|
} |
|
fprintf(scalef, "%.2f %.2f scale\n%d %d translate\n", |
|
300.0/scale_factor, 300.0/scale_factor, |
|
0, adjusted_height == height ? 0 : ury); |
|
BCLOSE( scalef ); |
| |
#ifdef WIN32 | #ifdef WIN32 |
gs_path = getenv("GS_PATH"); |
if ( (gs_cmd = getenv("GS_PATH")) == NULL ) |
if (!gs_path) |
gs_cmd = "gswin32c.exe"; |
gs_path = "gswin32c.exe"; |
|
sprintf(cmd,"%s -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit", |
|
gs_path, printer, pcl_file, scale_file, psfile); |
|
#else | #else |
sprintf(cmd,"gs -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit", |
gs_cmd = "gs"; |
printer, pcl_file, scale_file, psfile); |
|
#endif | #endif |
|
if ( strlen(cmd_format)-10 + strlen(gs_cmd) + strlen(printer) + |
|
strlen(pcl_file) + strlen(scale_file) + strlen(include_file) +1 > |
|
sizeof(cmd) ) { |
|
Warning ("Ghostscript command for %s would be too long, skipping special", include_file); |
|
free (include_file); |
|
unlink(scale_file); /* ignore errors */ |
|
unlink(pcl_file); |
|
return; |
|
} |
|
sprintf(cmd, cmd_format, |
|
gs_cmd, printer, pcl_file, scale_file, include_file); |
#ifdef DEBUGGS | #ifdef DEBUGGS |
fprintf(stderr, | fprintf(stderr, |
"PS-file '%s' w=%d, h=%d, urx=%d, ury=%d, llx=%d, lly=%d, rwi=%d\n", | "PS-file '%s' w=%d, h=%d, urx=%d, ury=%d, llx=%d, lly=%d, rwi=%d\n", |
psfile, urx - llx, height, urx,ury,llx,lly, rwi); |
include_file, urx - llx, height, urx,ury,llx,lly, rwi); |
fprintf(stderr,"%s\n",cmd); | fprintf(stderr,"%s\n",cmd); |
#endif | #endif |
if (system(cmd)) { | if (system(cmd)) { |
|
|
#endif | #endif |
| |
CopyHPFile( pcl_file ); | CopyHPFile( pcl_file ); |
/* unlink(pcl_file); */ |
|
/* unlink(scale_file); */ |
|
} |
|
} | } |
|
unlink(scale_file); /* ignore errors */ |
|
unlink(pcl_file); |
|
} |
|
else |
#endif /* LJ */ | #endif /* LJ */ |
|
|
|
if ( file_type == HPFile ) |
|
CopyHPFile( include_file ); |
|
else if ( file_type == VerbFile ) |
|
CopyFile( include_file ); |
|
else |
|
Warning ("This can't happen: unknown file_type value %d", file_type); |
|
|
|
if ( include_file != NULL ) free(include_file); |
} | } |
} | } |
| |
|
|
/**********************************************************************/ | /**********************************************************************/ |
/***************************** GetKeyStr ****************************/ | /***************************** GetKeyStr ****************************/ |
/**********************************************************************/ | /**********************************************************************/ |
/* extract first keyword-value pair from string (value part may be null) |
/* Extract first keyword-value pair from string (value part may be null), |
* return pointer to remainder of string |
* keyword and value are allocated and must be free by caller. |
* return NULL if none found |
* Return pointer to remainder of string, |
|
* return NULL if none found. |
*/ | */ |
char KeyStr[STRSIZE]; |
|
char ValStr[STRSIZE]; |
|
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
char *GetKeyStr(char *str, KeyWord *kw ) | char *GetKeyStr(char *str, KeyWord *kw ) |
#else | #else |
|
|
KeyWord *kw; | KeyWord *kw; |
#endif | #endif |
{ | { |
char *s, *k, *v, t; |
char *s, *start; |
|
char save_char, quote_char; |
if ( !str ) | if ( !str ) |
return( NULL ); | return( NULL ); |
for (s = str; *s == ' '; s++) | for (s = str; *s == ' '; s++) |
; /* skip over blanks */ | ; /* skip over blanks */ |
if (*s == '\0') | if (*s == '\0') |
return( NULL ); | return( NULL ); |
for (k = KeyStr; /* extract keyword portion */ |
start = s++; /* start of keyword */ |
*s != ' ' && *s != '\0' && *s != '='; |
while ( *s != ' ' && *s != '\0' && *s != '=' ) /* locate end */ |
*k++ = *s++) |
s++; |
; |
save_char = *s; |
*k = '\0'; |
*s = '\0'; |
kw->Key = KeyStr; |
kw->Key = xstrdup(start); |
kw->Val = v = NULL; |
kw->Val = NULL; |
kw->vt = None; | kw->vt = None; |
for ( ; *s == ' '; s++) |
if ( save_char == '\0' ) /* shortcut when we're at the end */ |
; /* skip over blanks */ |
return (s); |
if ( *s != '=' ) /* look for "=" */ |
*s = save_char; /* restore keyword end char */ |
|
while ( *s == ' ' ) s++ ; /* skip over blanks */ |
|
if ( *s != '=' ) /* no "=" means no value */ |
return( s ); | return( s ); |
for (s++; *s == ' '; s++); /* skip over blanks */ |
for (s++; *s == ' '; s++) |
if ( *s == '\'' || *s == '\"' ) /* get string delimiter */ |
; /* skip over blanks */ |
t = *s++; |
if ( *s == '\'' || *s == '\"' ) /* get string delimiter */ |
|
quote_char = *s++; |
else | else |
t = ' '; |
quote_char = ' '; |
for (v = ValStr; /* copy value portion up to delim */ |
start = s; /* no increment, might be "" as value */ |
*s != t && *s != '\0'; |
while ( *s != quote_char && *s != '\0' ) |
*v++ = *s++) |
s++; /* locate end of value portion */ |
; |
save_char = *s; |
if ( t != ' ' && *s == t ) |
*s = '\0'; |
s++; |
kw->Val = xstrdup(start); |
*v = '\0'; |
|
kw->Val = ValStr; |
|
kw->vt = String; | kw->vt = String; |
|
if ( save_char != '\0' ) { /* save_char is now quote_char */ |
|
*s = save_char; |
|
if ( quote_char != ' ' ) /* we had real quote chars */ |
|
s++; |
|
} |
return( s ); | return( s ); |
} | } |
| |
|
Lines 4819-4831
struct font_entry *fontptr;
|
Link Here
|
|---|
|
the resident fonts. */ | the resident fonts. */ |
if (tfm_read_info(fontptr->n, &tfm_info) | if (tfm_read_info(fontptr->n, &tfm_info) |
&& tfm_info.family[0] | && tfm_info.family[0] |
&& strcmp((char *)tfm_info.family, "HPAUTOTFM") == 0) { |
&& EQ((char *)tfm_info.family, "HPAUTOTFM")) { |
unsigned i; | unsigned i; |
double factor = fontptr->s / (double)0x100000; | double factor = fontptr->s / (double)0x100000; |
| |
resident_count++; | resident_count++; |
fontptr->resident_p = _TRUE; | fontptr->resident_p = _TRUE; |
strcpy(fontptr->symbol_set, (char *)tfm_info.coding_scheme); |
strncpy(fontptr->symbol_set, (char *)tfm_info.coding_scheme, 39); |
|
fontptr->symbol_set[39] = '\0'; |
fontptr->resid = tfm_info.typeface_id; | fontptr->resid = tfm_info.typeface_id; |
fontptr->spacing = tfm_info.spacing; | fontptr->spacing = tfm_info.spacing; |
fontptr->style = tfm_info.style; | fontptr->style = tfm_info.style; |
|
Lines 4878-4884
struct font_entry *fontptr;
|
Link Here
|
|---|
|
fontptr->resident_p = _FALSE; | fontptr->resident_p = _FALSE; |
| |
if (tfm_info.family[0] | if (tfm_info.family[0] |
&& strcmp((char *)tfm_info.family, "UNSPECIFIED") == 0) { |
&& EQ((char *)tfm_info.family, "UNSPECIFIED")) { |
Warning("font family for %s is UNSPECIFIED; need to run dvicopy?", | Warning("font family for %s is UNSPECIFIED; need to run dvicopy?", |
fontptr->n); | fontptr->n); |
fontptr->font_file_id = NO_FILE; | fontptr->font_file_id = NO_FILE; |
|
Lines 5031-5040
printf("[%ld]=%lf * %lf * %lf + 0.5 = %l
|
Link Here
|
|---|
|
if (tfontptr->resident_p) | if (tfontptr->resident_p) |
return; | return; |
| |
if (!(resident_font_located)) { |
if (!(resident_font_located)) |
#endif | #endif |
| |
#ifdef KPATHSEA |
|
{ | { |
kpse_glyph_file_type font_ret; | kpse_glyph_file_type font_ret; |
char *name; | char *name; |
|
Lines 5047-5055
printf("[%ld]=%lf * %lf * %lf + 0.5 = %l
|
Link Here
|
|---|
|
if (name) | if (name) |
{ | { |
font_found = _TRUE; | font_found = _TRUE; |
strcpy (tfontptr->name, name); |
tfontptr->name = name; |
free (name); |
allocated_storage += strlen(name)+1; |
|
|
if (!FILESTRCASEEQ (tfontptr->n, font_ret.name)) { | if (!FILESTRCASEEQ (tfontptr->n, font_ret.name)) { |
fprintf (stderr, | fprintf (stderr, |
"dvilj: Font %s not found, using %s at %d instead.\n", | "dvilj: Font %s not found, using %s at %d instead.\n", |
|
Lines 5071-5099
printf("[%ld]=%lf * %lf * %lf + 0.5 = %l
|
Link Here
|
|---|
|
tfontptr->n, dpi); | tfontptr->n, dpi); |
} | } |
} | } |
#else /* not KPATHSEA */ |
|
if (!(findfile(PXLpath, |
|
tfontptr->n, |
|
tfontptr->font_mag, |
|
tfontptr->name, |
|
_FALSE, |
|
0))) { |
|
Warning(tfontptr->name); /* contains error messsage */ |
|
tfontptr->font_file_id = NO_FILE; |
|
#ifdef __riscos |
|
MakeMetafontFile(PXLpath, tfontptr->n, tfontptr->font_mag); |
|
#endif |
|
} |
|
else { |
|
font_found = _TRUE; |
|
if (G_verbose) |
|
fprintf(ERR_STREAM,"%d: using font <%s>\n", plusid, tfontptr->name); |
|
} |
|
#endif /* not KPATHSEA */ |
|
|
|
#ifdef LJ_RESIDENT_FONTS |
|
} |
|
#endif |
|
| |
tfontptr->plusid = plusid; | tfontptr->plusid = plusid; |
plusid++; | plusid++; |