mike@srava.sra.junet (Michael Smolenski) (06/01/89)
Thank you for version 1.2 of Ghostscript. I have been very happy with
the performance. I have made a number of changes that I think you
might be interested in. I have included the context diffs in this
mail - feel free to use any that you think will improve ghostscript.
Most changes have fairly obvious reasons, but some may be obscure. In
particular, in gxfill.c I added a " <= 0.001" to find_cross_y(). This
fixed some character drawing problems that were visible when things were
scaled down (as far as characters, I especially remember 'h' and 90 rotated
'y' as being problems). If you haven`t seen these problems, it might be
better not to apply that patch.
If you have any questions, I can be reached at 'mike@sra.junet'.
-------------- diffs
diff -bc ghostscript-1.2/gschar.c newgs/gschar.c
*** ghostscript-1.2/gschar.c Fri Feb 24 18:03:44 1989
--- newgs/gschar.c Wed May 31 19:17:38 1989
***************
*** 398,406 ****
/* and undo the extra gsave. */
if ( penum->for_stringwidth )
{ gs_point end_pt, start_pt;
gs_currentpoint(pgs, &end_pt);
gs_grestore(pgs);
! gs_currentpoint(pgs, &start_pt);
penum->width.x = end_pt.x - start_pt.x;
penum->width.y = end_pt.y - start_pt.y;
}
--- 398,411 ----
/* and undo the extra gsave. */
if ( penum->for_stringwidth )
{ gs_point end_pt, start_pt;
+ gs_fixed_point pt;
gs_currentpoint(pgs, &end_pt);
gs_grestore(pgs);
! if ( gx_path_current_point(pgs->path, &pt) < 0 )
! start_pt.x = start_pt.y = 0; /* no current point, use (0,0) */
! else
! gs_itransform(pgs, fixed2float(pt.x), fixed2float(pt.y),
! &start_pt);
penum->width.x = end_pt.x - start_pt.x;
penum->width.y = end_pt.y - start_pt.y;
}
diff -bc ghostscript-1.2/gxfill.c newgs/gxfill.c
*** ghostscript-1.2/gxfill.c Fri Feb 24 18:31:07 1989
--- newgs/gxfill.c Wed May 31 19:25:42 1989
***************
*** 303,312 ****
find_cross_y(active_line *endp, active_line *alp,
fixed y, fixed y1, fixed *cross_yp)
{ float cross_slope = al_slope(endp) - al_slope(alp);
! fixed diff_x;
fixed y_limit;
! if ( cross_slope <= 0 ) return 0;
! diff_x = (float)(alp->x_current - endp->x_current);
/* Compute the y limit, the min of endp's end, alp's end, and y1. */
y_limit = endp->y_end;
if ( alp->y_end < y_limit ) y_limit = alp->y_end;
--- 303,312 ----
find_cross_y(active_line *endp, active_line *alp,
fixed y, fixed y1, fixed *cross_yp)
{ float cross_slope = al_slope(endp) - al_slope(alp);
! float diff_x;
fixed y_limit;
! if ( cross_slope <= 0.001 ) return 0;
! diff_x = fixed2float(alp->x_current - endp->x_current);
/* Compute the y limit, the min of endp's end, alp's end, and y1. */
y_limit = endp->y_end;
if ( alp->y_end < y_limit ) y_limit = alp->y_end;
***************
*** 316,326 ****
printf("[f]cross? %lx %lx y_limit=%f -> ",
(ulong)endp, (ulong)alp, fixed2float(y_limit));
#endif
! if ( diff_x < (y_limit - y) * cross_slope )
! { *cross_yp = y + diff_x / cross_slope;
#ifdef gs_DEBUG
if ( gs_debug['f'] )
! printf("%f\n", *cross_yp);
#endif
return 1;
}
--- 316,326 ----
printf("[f]cross? %lx %lx y_limit=%f -> ",
(ulong)endp, (ulong)alp, fixed2float(y_limit));
#endif
! if ( diff_x < fixed2float(y_limit - y) * cross_slope )
! { *cross_yp = float2fixed(fixed2float(y) + (diff_x / cross_slope));
#ifdef gs_DEBUG
if ( gs_debug['f'] )
! printf("%f\n", fixed2float(*cross_yp));
#endif
return 1;
}
diff -bc ghostscript-1.2/gxpath.c newgs/gxpath.c
*** ghostscript-1.2/gxpath.c Fri Feb 24 17:40:48 1989
--- newgs/gxpath.c Fri Mar 10 16:54:40 1989
***************
*** 188,193 ****
--- 188,195 ----
gx_path_add_line(gx_path *ppath, fixed x, fixed y)
{ subpath *psub = ppath->current_subpath;
register line_segment *lp;
+ if ( !ppath->position_valid )
+ return_error(gs_error_nocurrentpoint);
path_open();
path_alloc_segment(lp, line_segment, s_line);
path_alloc_link(lp);
***************
*** 230,235 ****
--- 232,239 ----
fixed x1, fixed y1, fixed x2, fixed y2, fixed x3, fixed y3)
{ subpath *psub = ppath->current_subpath;
register curve_segment *lp;
+ if ( !ppath->position_valid )
+ return_error(gs_error_nocurrentpoint);
path_open();
path_alloc_segment(lp, curve_segment, s_curve);
path_alloc_link(lp);
diff -bc ghostscript-1.2/iname.c newgs/iname.c
*** ghostscript-1.2/iname.c Fri Feb 24 16:53:41 1989
--- newgs/iname.c Tue Mar 14 16:26:08 1989
***************
*** 36,41 ****
--- 36,48 ----
while ( --pname >= name_table ) pname->value.pname = 0;
}
+ /* get a names length */
+ int
+ name_length(ref *ppname)
+ {
+ return ppname->value.pname->string.size;
+ }
+
/* Look up or enter a name in the table. */
/* Return 0 or an error code. */
/* The return may overlap the characters of the string! */
diff -bc ghostscript-1.2/iscan.c newgs/iscan.c
*** ghostscript-1.2/iscan.c Fri Feb 24 16:49:53 1989
--- newgs/iscan.c Wed May 31 18:39:09 1989
***************
*** 389,395 ****
while ( 1 )
{ c = sgetc(s);
if ( isdigit(c) ) c -= '0';
! else if ( isalpha(c) ) c = toupper(c) - ('A' - 10);
else break;
if ( c >= radix ) break;
if ( ival >= imax && (ival > imax || c > irem) )
--- 393,400 ----
while ( 1 )
{ c = sgetc(s);
if ( isdigit(c) ) c -= '0';
! else if ( islower(c) ) c = c - ('a' - 10);
! else if ( isupper(c) ) c = c - ('A' - 10);
else break;
if ( c >= radix ) break;
if ( ival >= imax && (ival > imax || c > irem) )
diff -bc ghostscript-1.2/zfile.c newgs/zfile.c
*** ghostscript-1.2/zfile.c Fri Feb 24 17:02:53 1989
--- newgs/zfile.c Wed May 31 19:05:35 1989
***************
*** 358,363 ****
--- 358,364 ----
sflush(s);
if ( !s->writing )
fseek(s->file, 0L, 2); /* set to end */
+ pop(1);
return 0;
}
***************
*** 451,457 ****
{"1bytesavailable", zbytesavailable},
{"1closefile", zclosefile},
{"0currentfile", zcurrentfile},
! {"0currentfileposition", zcurrentfileposition},
{"1echo", zecho},
{"2file", zfile},
{"0flush", zflush},
--- 452,458 ----
{"1bytesavailable", zbytesavailable},
{"1closefile", zclosefile},
{"0currentfile", zcurrentfile},
! {"1currentfileposition", zcurrentfileposition},
{"1echo", zecho},
{"2file", zfile},
{"0flush", zflush},
diff -bc ghostscript-1.2/zgeneric.c newgs/zgeneric.c
*** ghostscript-1.2/zgeneric.c Fri Feb 24 17:32:10 1989
--- newgs/zgeneric.c Wed May 31 18:43:39 1989
***************
*** 76,81 ****
--- 76,84 ----
zlength(register ref *op)
{ switch ( r_type(op) )
{
+ case t_name: /* names are also allowed in 'length' */
+ make_int(op, name_length(op));
+ return 0;
case t_array:
case t_packedarray:
case t_string:
***************
*** 135,142 ****
if ( code ) return code; /* error */
}
break;
case t_array:
- case t_packedarray:
check_type(*op1, t_integer);
if ( op1->value.intval < 0 || op1->value.intval >= op2->size )
return e_rangecheck;
--- 138,146 ----
if ( code ) return code; /* error */
}
break;
+ case t_packedarray: /* put into a packed array gets error */
+ return e_invalidaccess; /* (doesn't matter now but, ...) */
case t_array:
check_type(*op1, t_integer);
if ( op1->value.intval < 0 || op1->value.intval >= op2->size )
return e_rangecheck;
diff -bc ghostscript-1.2/zmath.c newgs/zmath.c
*** ghostscript-1.2/zmath.c Fri Feb 24 17:11:25 1989
--- newgs/zmath.c Wed May 31 19:28:12 1989
***************
*** 136,141 ****
--- 136,142 ----
if ( args[0] < 0.0 && (modf(args[1], &frac), frac != 0.0) )
return e_undefinedresult;
result = pow(args[0], args[1]);
+ pop(1);
make_real(op, result);
return 0;
}
***************
*** 211,219 ****
{"1log", zlog},
{"0rand", zrand},
{"0rrand", zrrand},
! {"0sin", zsin},
! {"0sqrt", zsqrt},
! {"0srand", zsrand},
op_def_end
};
z_op_init(my_defs);
--- 212,220 ----
{"1log", zlog},
{"0rand", zrand},
{"0rrand", zrrand},
! {"1sin", zsin},
! {"1sqrt", zsqrt},
! {"1srand", zsrand},
op_def_end
};
z_op_init(my_defs);
diff -bc ghostscript-1.2/zmisc.c newgs/zmisc.c
*** ghostscript-1.2/zmisc.c Fri Feb 24 17:16:55 1989
--- newgs/zmisc.c Fri Mar 10 19:01:54 1989
***************
*** 37,44 ****
{ ref *bsp = op; /* bottom of stack */
/****** WHAT ABOUT PACKED ARRAYS? ******/
/****** SHOULD MAKE INNER ARRAYS READ-ONLY ******/
! check_type(*op, t_array);
! if ( !(r_attrs(op) & a_write) ) return e_invalidaccess;
*++bsp = *op;
while ( bsp > op )
{ while ( bsp->size )
--- 37,79 ----
{ ref *bsp = op; /* bottom of stack */
/****** WHAT ABOUT PACKED ARRAYS? ******/
/****** SHOULD MAKE INNER ARRAYS READ-ONLY ******/
! /*
! This postscript fragment show what to do about packed arrays when
! sent to a LaserWriter:
!
! /Times-Roman findfont 20 scalefont setfont
!
! /p { ( bound) systemdict /show get exec } def
!
! /a { moveto show p } def
! /b { moveto show p } bind def
! /c { moveto show p } readonly bind def
! /d { moveto show p } bind readonly def
!
! true setpacking
!
! /e { moveto show p } def
! /f { moveto show p } bind def
! /g { moveto show p } readonly bind def
! /h { moveto show p } bind readonly def
!
! /show { systemdict /show get exec
! ( not) systemdict /show get exec } def
!
! (def - ) 100 100 a
! (bind def - ) 100 200 b
! (readonly bind def - ) 100 300 c
! (bind readonly def - ) 100 400 d
! (def - ) 300 150 e
! (bind def - ) 300 250 f
! (readonly bind def - ) 300 350 g
! (bind readonly def - ) 300 450 h
!
! showpage
! */
! check_array(*op);
! if ( r_type(op) != t_packedarray && /*can bind a readonly packed array*/
! !(r_attrs(op) & a_write) ) return 0;
*++bsp = *op;
while ( bsp > op )
{ while ( bsp->size )
***************
*** 54,60 ****
}
break;
case t_array: /* push into array if procedure */
! if ( !(~r_attrs(tp) & (a_executable+a_write)) && bsp < ostop )
*++bsp = *tp;
}
}
--- 89,97 ----
}
break;
case t_array: /* push into array if procedure */
! if ( (r_attrs(tp) & a_executable) &&
! (r_type(tp) != t_packedarray &&
! !(~r_attrs(tp) & a_write)) && bsp < ostop )
*++bsp = *tp;
}
}
diff -bc ghostscript-1.2/zrelbit.c newgs/zrelbit.c
*** ghostscript-1.2/zrelbit.c Fri Feb 24 17:14:24 1989
--- newgs/zrelbit.c Mon Mar 6 17:54:07 1989
***************
*** 229,234 ****
--- 229,235 ----
break;
default: return e_typecheck;
}
+ break;
case t_real:
real1 = op1->value.realval;
switch ( r_type(op) )
diff -bc ghostscript-1.2/ztype.c newgs/ztype.c
*** ghostscript-1.2/ztype.c Fri Feb 24 17:04:38 1989
--- newgs/ztype.c Mon May 8 08:17:16 1989
***************
*** 191,197 ****
}
val = (ival < 0 ? -ival : ival);
do
! { *--dp = val % radix + '0';
val /= radix;
}
while ( val );
--- 191,198 ----
}
val = (ival < 0 ? -ival : ival);
do
! {
! *--dp = val % radix + ((val % radix) < 10 ? '0' : ('A' - 10));
val /= radix;
}
while ( val );
-------------- end diffs