[gs-cvs] gs/src

Igor Melichev igor at ghostscript.com
Thu Jul 15 05:37:52 PDT 2004


Update of /cvs/ghostscript/gs/src
In directory casper:/tmp/cvs-serv27359/gs/src

Modified Files:
	gdevpdtc.c gdevpdte.c 
Log Message:
Fix (pdfwrite) : text.operation was inconsistent after replacing TEXT_FROM_GLYPHS.

DETAILS :

Bug 687563 "segfault during pdfwrite".
text.operation became inconsistent after replacing 
TEXT_FROM_*_GLYPH* with TEXT_FROM_STRING.
Declared a stronger constraint for process_text_modify_width,
and documented the trick with text indices in process_plain_text.

EXPECTED DIFFERENCES :

pdfwtite -r300 tpc2.ps


Index: gdevpdtc.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpdtc.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- gdevpdtc.c	14 Mar 2004 22:01:26 -0000	1.35
+++ gdevpdtc.c	15 Jul 2004 12:37:49 -0000	1.36
@@ -455,7 +455,7 @@
 	    gs_matrix m0, m1, m2, m3;
 	    int xy_index_step = (pte->text.x_widths != NULL && /* see gs_text_replaced_width */
 				 pte->text.x_widths == pte->text.y_widths ? 2 : 1);
-	    gs_const_string save_text;
+	    gs_text_params_t save_text;
 
 	    code = pdf_font_orig_matrix(subfont0, &m0);
 	    if (code < 0)
@@ -491,8 +491,7 @@
 	    /* process_text_modify_width breaks text parameters. 
 	       We would like to improve it someday. 
 	       Now save them locally and restore after the call. */
-	    save_text.data = pte->text.data.bytes;
-	    save_text.size = pte->text.size;
+	    save_text = pte->text;
 	    str.data = scan.text.data.bytes + index;
 	    str.size = break_index - index;
 	    if (pte->text.x_widths != NULL)
@@ -506,8 +505,7 @@
 		pte->text.x_widths -= xy_index * xy_index_step;
 	    if (pte->text.y_widths != NULL)
 		pte->text.y_widths -= xy_index * xy_index_step;
-	    pte->text.data.bytes = save_text.data;
-	    pte->text.size = save_text.size;
+	    pte->text = save_text;
 	    pte->cdevproc_callout = false;
 	    if (code < 0) {
 		pte->index = index;

Index: gdevpdte.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpdte.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- gdevpdte.c	27 May 2004 19:05:37 -0000	1.59
+++ gdevpdte.c	15 Jul 2004 12:37:49 -0000	1.60
@@ -757,6 +757,9 @@
  * Emulate TEXT_ADD_TO_ALL_WIDTHS and/or TEXT_ADD_TO_SPACE_WIDTH,
  * and implement TEXT_REPLACE_WIDTHS if requested.
  * Uses and updates ppts->values.matrix; uses ppts->values.pdfont.
+ * 
+ * Destroys the text parameters in *pte. 
+ * The caller must restore them.
  */
 int
 process_text_modify_width(pdf_text_enum_t *pte, gs_font *font,
@@ -783,6 +786,8 @@
     pte->text.data.bytes = pstr->data;
     pte->text.size = pstr->size;
     pte->index = 0;
+    pte->text.operation &= ~TEXT_FROM_ANY;
+    pte->text.operation |= TEXT_FROM_STRING;
     start.x = ppts->values.matrix.tx;
     start.y = ppts->values.matrix.ty;
     total.x = total.y = 0;	/* user space */
@@ -1038,7 +1043,7 @@
 	    if (code < 0)
 		break;
 	    count += char_code_length;
-	    if (pte->text.operation & TEXT_INTERVENE)
+	    if (operation & TEXT_INTERVENE)
 		break; /* Just do one character. */
 	}
 	if (i < size) {
@@ -1055,10 +1060,15 @@
 	    }
 	    count = size;
 	}
+	/*  So far we will use TEXT_FROM_STRING instead
+	    TEXT_FROM_*_GLYPH*. Since we used a single 
+	    byte encoding, the character index appears invariant
+	    during this substitution.
+	 */
     } else
 	return_error(gs_error_rangecheck);
     str.data = buf;
-    if (count > 1 && (pte->text.operation & TEXT_INTERVENE)) {
+    if (count > 1 && (operation & TEXT_INTERVENE)) {
 	/* Just do one character. */
 	str.size = 1;
 	code = pdf_encode_process_string(penum, &str, gdata, NULL, &text_state);



More information about the gs-cvs mailing list