develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34466 - branches/pdd22io_part3/src/io

From:
allison
Date:
December 27, 2008 22:28
Subject:
[svn:parrot] r34466 - branches/pdd22io_part3/src/io
Message ID:
20081228062828.066E6CB9B0@x12.develooper.com
Author: allison
Date: Sat Dec 27 22:28:27 2008
New Revision: 34466

Modified:
   branches/pdd22io_part3/src/io/api.c

Log:
[pdd22io] Change 'write' function to call existing function that already makes
a method call on the filehandle object.


Modified: branches/pdd22io_part3/src/io/api.c
==============================================================================
--- branches/pdd22io_part3/src/io/api.c	(original)
+++ branches/pdd22io_part3/src/io/api.c	Sat Dec 27 22:28:27 2008
@@ -239,28 +239,22 @@
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
 INTVAL
-Parrot_io_write(PARROT_INTERP, ARGMOD(PMC *pmc), ARGIN(const void *buffer), size_t len)
+Parrot_io_write(PARROT_INTERP, ARGMOD(PMC *pmc), ARGIN(const void *buffer), size_t length)
 {
     DECL_CONST_CAST;
+    INTVAL result;
+    STRING fake;
 
-    if (Parrot_io_is_closed(interp, pmc))
+    if (PMC_IS_NULL(pmc))
         return -1;
 
-    if (Parrot_io_get_flags(interp, pmc) & PIO_F_WRITE) {
-        STRING fake;
-        /* TODO skip utf8 translation layers if any */
-        fake.strstart = (char *) PARROT_const_cast(void *, buffer);
-        fake.strlen = fake.bufused = len;
-        fake.charset = Parrot_default_charset_ptr;
-        fake.encoding = Parrot_default_encoding_ptr;
-
-        if (Parrot_io_is_encoding(interp, pmc, CONST_STRING(interp, "utf8")))
-            return Parrot_io_write_utf8(interp, pmc, &fake);
+    fake.strstart = (char *) PARROT_const_cast(void *, buffer);
+    fake.strlen = fake.bufused = length;
+    fake.charset = Parrot_default_charset_ptr;
+    fake.encoding = Parrot_default_encoding_ptr;
 
-        return Parrot_io_write_buffer(interp, pmc, &fake);
-    }
-    else
-        return 0;
+    result = Parrot_io_putps(interp, pmc, &fake);
+    return result;
 }
 
 /*



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About