From 2ec3651f85d85de00aced2f4f0b4e5fd5d606d1a Mon Sep 17 00:00:00 2001
From: ellson <devnull@localhost>
Date: Wed, 20 Aug 2008 03:20:09 +0000
Subject: [PATCH] initial fix for rendering to string in tcldot

---
 lib/gvc/gvcint.h          |  2 +-
 lib/gvc/gvdevice.c        |  2 +-
 tclpkg/gv/gv_php_init.cpp | 12 ++++++------
 tclpkg/tcldot/tcldot.c    |  5 +++--
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/lib/gvc/gvcint.h b/lib/gvc/gvcint.h
index 03e6d93a9..271112142 100644
--- a/lib/gvc/gvcint.h
+++ b/lib/gvc/gvcint.h
@@ -92,7 +92,7 @@ extern "C" {
 	void *keycodes;
 
         /* externally provided write() displine */
-	size_t (*write_fn) (const char *s, int len);
+	size_t (*write_fn) (GVJ_t *job, const char *s, int len);
 
 /* FIXME - everything below should probably move to GVG_t */
 
diff --git a/lib/gvc/gvdevice.c b/lib/gvc/gvdevice.c
index c1995262f..19ba6b847 100644
--- a/lib/gvc/gvdevice.c
+++ b/lib/gvc/gvdevice.c
@@ -54,7 +54,7 @@ static const int PAGE_ALIGN = 4095;		/* align to a 4K boundary (less one), typic
 size_t gvdevice_write (GVJ_t * job, const unsigned char *s, unsigned int len)
 {
     if (job->gvc->write_fn && job->output_file == stdout)   /* externally provided write dicipline */
-	return (job->gvc->write_fn)((char*)s, len);
+	return (job->gvc->write_fn)(job, (char*)s, len);
     if (job->flags & GVDEVICE_COMPRESSED_FORMAT) {
 #ifdef HAVE_LIBZ
 	return gzwrite((gzFile *) (job->output_file), s, len);
diff --git a/tclpkg/gv/gv_php_init.cpp b/tclpkg/gv/gv_php_init.cpp
index f4de4a2ff..0559e4b49 100644
--- a/tclpkg/gv/gv_php_init.cpp
+++ b/tclpkg/gv/gv_php_init.cpp
@@ -1,15 +1,15 @@
 #include <php.h>
-#include <gvc.h>
-#include <gvplugin.h>
-#include <gvcjob.h>
-#include <gvcint.h>
+#include "gvc.h"
+#include "gvplugin.h"
+#include "gvcjob.h"
+#include "gvcint.h"
 
-static size_t gv_php_writer (const char *s, int len)
+static size_t gv_php_writer (GVJ_t *job, const char *s, int len)
 {
 	return PHPWRITE(s, len);
 }
 
-void gv_binding_init ( GVC_t *gvc)
+void gv_binding_init (GVC_t *gvc)
 {
 	gvc->write_fn = gv_php_writer;
 }
diff --git a/tclpkg/tcldot/tcldot.c b/tclpkg/tcldot/tcldot.c
index 226314f67..06efae73b 100644
--- a/tclpkg/tcldot/tcldot.c
+++ b/tclpkg/tcldot/tcldot.c
@@ -1632,9 +1632,10 @@ static int dotstring(ClientData clientData, Tcl_Interp * interp,
     return (tcldot_fixup(interp, gvc, g));
 }
 
-static size_t Tcldot_writer(const char *s, int len)
+static size_t Tcldot_writer(GVJ_t *job, const char *s, int len)
 {
-    return fwrite(s, sizeof(char), len, stdout);
+    Tcl_AppendResult((Tcl_Interp*)(job->context), s, (char *) NULL);
+    return len;
 }
 
 #if defined(_BLD_tcldot) && defined(_DLL)
-- 
2.40.0