[gs-cvs] rev 7692 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Mon Feb 12 00:28:33 PST 2007
Author: leonardo
Date: 2007-02-12 00:28:32 -0800 (Mon, 12 Feb 2007)
New Revision: 7692
Modified:
trunk/gs/src/gstext.c
trunk/gs/src/gxtext.h
trunk/gs/src/zchar.c
Log:
Fix (interpreter) : Provide a right execution stack on *show errors.
DETAILS :
This improvement is done for CET 13-12-4.
The old code left --%op_show_continue-- on estack when error occors in kshow.
The new code defines a nes field gs_tect_enum_s::enum_client_data,
which stores the initial operator. If an error happens,
op_show_restore puts the initial operator on estack
instead the continuation operator.
Left hand type casts :
*(op_proc_t *)&penum->enum_client_data = zshow
used to quiet MSVC compiler warnings about function<-->data casts.
EXPECTED DIFFERENCES :
comparefiles: None.
CET tests : 13-12-4 (a partial fix).
Modified: trunk/gs/src/gstext.c
===================================================================
--- trunk/gs/src/gstext.c 2007-02-11 09:45:31 UTC (rev 7691)
+++ trunk/gs/src/gstext.c 2007-02-12 08:28:32 UTC (rev 7692)
@@ -181,6 +181,7 @@
#else
pte->text_enum_id = 0;
#endif
+ pte->enum_client_data = NULL;
/* text_begin procedure sets rc */
/* init_dynamic sets current_font */
Modified: trunk/gs/src/gxtext.h
===================================================================
--- trunk/gs/src/gxtext.h 2007-02-11 09:45:31 UTC (rev 7691)
+++ trunk/gs/src/gxtext.h 2007-02-12 08:28:32 UTC (rev 7692)
@@ -91,6 +91,7 @@
/* The following change dynamically. NOTE: gs_text_enum_copy_dynamic */\
/* knows the entire list of dynamically changing elements. */\
rc_header rc;\
+ void *enum_client_data;\
gs_font *current_font; /* changes for composite fonts */\
gs_glyph outer_CID; /* When a Type 3 is a FMapType 9 descendent. */\
bool is_pure_color; /* The text is painted with a pure color. */\
Modified: trunk/gs/src/zchar.c
===================================================================
--- trunk/gs/src/zchar.c 2007-02-11 09:45:31 UTC (rev 7691)
+++ trunk/gs/src/zchar.c 2007-02-12 08:28:32 UTC (rev 7692)
@@ -57,6 +57,7 @@
if (code != 0 ||
(code = gs_show_begin(igs, op->value.bytes, r_size(op), imemory, &penum)) < 0)
return code;
+ *(op_proc_t *)&penum->enum_client_data = zshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup");
return code;
@@ -77,6 +78,7 @@
(code = op_show_setup(i_ctx_p, op)) != 0 ||
(code = gs_ashow_begin(igs, axy[0], axy[1], op->value.bytes, r_size(op), imemory, &penum)) < 0)
return code;
+ *(op_proc_t *)&penum->enum_client_data = zashow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 3, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup");
return code;
@@ -110,6 +112,7 @@
op->value.bytes, r_size(op),
imemory, &penum)) < 0)
return code;
+ *(op_proc_t *)&penum->enum_client_data = zwidthshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 4, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup");
return code;
@@ -146,6 +149,7 @@
op->value.bytes, r_size(op),
imemory, &penum)) < 0)
return code;
+ *(op_proc_t *)&penum->enum_client_data = zawidthshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 6, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup");
return code;
@@ -174,6 +178,7 @@
(code = gs_kshow_begin(igs, op->value.bytes, r_size(op),
imemory, &penum)) < 0)
return code;
+ *(op_proc_t *)&penum->enum_client_data = zkshow;
if ((code = op_show_finish_setup(i_ctx_p, penum, 2, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup");
return code;
@@ -202,6 +207,7 @@
(code = gs_stringwidth_begin(igs, op->value.bytes, r_size(op),
imemory, &penum)) < 0)
return code;
+ *(op_proc_t *)&penum->enum_client_data = zstringwidth;
if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_stringwidth)) < 0) {
ifree_object(penum, "op_show_enum_setup");
return code;
@@ -226,7 +232,7 @@
/* Common code for charpath and .charboxpath. */
private int
-zchar_path(i_ctx_t *i_ctx_p,
+zchar_path(i_ctx_t *i_ctx_p, op_proc_t proc,
int (*begin)(gs_state *, const byte *, uint,
bool, gs_memory_t *, gs_text_enum_t **))
{
@@ -240,6 +246,7 @@
(code = begin(igs, op[-1].value.bytes, r_size(op - 1),
op->value.boolval, imemory, &penum)) < 0)
return code;
+ *(op_proc_t *)&penum->enum_client_data = proc;
if ((code = op_show_finish_setup(i_ctx_p, penum, 2, finish_show)) < 0) {
ifree_object(penum, "op_show_enum_setup");
return code;
@@ -250,13 +257,13 @@
private int
zcharpath(i_ctx_t *i_ctx_p)
{
- return zchar_path(i_ctx_p, gs_charpath_begin);
+ return zchar_path(i_ctx_p, zcharpath, gs_charpath_begin);
}
/* <string> <box_bool> .charboxpath - */
private int
zcharboxpath(i_ctx_t *i_ctx_p)
{
- return zchar_path(i_ctx_p, gs_charboxpath_begin);
+ return zchar_path(i_ctx_p, zcharboxpath, gs_charboxpath_begin);
}
/* <wx> <wy> <llx> <lly> <urx> <ury> setcachedevice - */
@@ -782,6 +789,13 @@
if (count > saved_count) /* if <, we're in trouble */
ref_stack_pop(&o_stack, count - saved_count);
+ if (ep[1].value.opproc == op_show_continue && penum->enum_client_data != NULL) {
+ /* Replace the continuation operaton on estack with the right operator : */
+ op_proc_t proc;
+
+ *(void **)&proc = penum->enum_client_data;
+ make_op_estack(ep + 1, proc);
+ }
}
if (SHOW_IS_STRINGWIDTH(penum) && igs->text_rendering_mode != 3) {
/* stringwidth does an extra gsave */
More information about the gs-cvs
mailing list