[svn:mod_parrot] r490 - in mod_parrot/trunk: src t/response/TestAPI

[email protected] Thu, 13 Nov 2008 08:05:10 -0800 (PST)
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Thu Nov 13 08:05:09 2008
New Revision: 490

Modified:
   mod_parrot/trunk/src/nci.c
   mod_parrot/trunk/t/response/TestAPI/request_rec.pir

Log:
clean up write method


Modified: mod_parrot/trunk/src/nci.c
==============================================================================
--- mod_parrot/trunk/src/nci.c	(original)
+++ mod_parrot/trunk/src/nci.c	Thu Nov 13 08:05:09 2008
@@ -175,21 +175,18 @@
 int mpnci_rwrite(Parrot_Interp interp, Parrot_PMC p, int size, request_rec *r)
 {
     modparrot_context *ctxp;
-    Parrot_Interp interpreter;
-    int bytes;
-    char *tmp;
+    Parrot_Int plen;
+    int len;
+    char *buf;
 
     ctxp = get_interp_ctx(interp);
     if (!ctxp) return 0;
-    interpreter = ctxp->interp;
-
-    /* will this work for binary data??? */
-    tmp = (char *)string_to_cstring(interpreter, PMC_str_val(p));
 
-    bytes = ap_rwrite(tmp, size, r);
-    string_cstring_free(tmp);
+    buf = Parrot_PMC_get_cstringn(ctxp->interp, p, &plen);
+    len = ap_rwrite(buf, (plen < size) ? len : size, r);
+    string_cstring_free(buf);
 
-    return(bytes);
+    return(len);
 }
 
 size_t mpnci_request_read(Parrot_Interp interp, Parrot_PMC pbuf, size_t len,

Modified: mod_parrot/trunk/t/response/TestAPI/request_rec.pir
==============================================================================
--- mod_parrot/trunk/t/response/TestAPI/request_rec.pir	(original)
+++ mod_parrot/trunk/t/response/TestAPI/request_rec.pir	Thu Nov 13 08:05:09 2008
@@ -25,6 +25,7 @@
   OK_2:
     r.'puts'("ok 2 - puts()\n")
 
+  # XXX failure here may cause all subsequent tests to fail
   START_3:
     push_eh NOT_OK_3
     $I0 = r.'write'("# testing 123\n", 14)