Author: allison
Date: Tue Nov 11 14:03:33 2008
New Revision: 32564
Modified:
branches/pdd22io/src/io/api.c
Log:
[pdd22io] Use buffering in core I/O API.
Modified: branches/pdd22io/src/io/api.c
==============================================================================
--- branches/pdd22io/src/io/api.c (original)
+++ branches/pdd22io/src/io/api.c Tue Nov 11 14:03:33 2008
@@ -101,6 +101,7 @@
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
"Unable to open filehandle");
+ Parrot_io_setbuf(interp, new_filehandle, PIO_UNBOUND);
return new_filehandle;
}
@@ -138,6 +139,11 @@
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
"Unable to open filehandle");
+ if (Parrot_io_get_flags(interp, new_filehandle) & PIO_F_CONSOLE)
+ Parrot_io_setlinebuf(interp, new_filehandle);
+ else
+ Parrot_io_setbuf(interp, new_filehandle, PIO_UNBOUND);
+
return new_filehandle;
}
@@ -202,6 +208,7 @@
if (Parrot_io_is_closed(interp, pmc))
return;
+ Parrot_io_flush_buffer(interp, pmc);
ignored = PIO_FLUSH(interp, pmc);
UNUSED(ignored);
}
@@ -345,7 +352,8 @@
if (Parrot_io_is_closed(interp, pmc))
return -1;
- return PIO_TELL(interp, pmc);
+ return Parrot_io_get_file_position(interp, pmc);
+ /* return PIO_TELL(interp, pmc); */
}
/*
@@ -436,14 +444,16 @@
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
"Cannot put to a closed I/O handle");
- if (!s)
+ if (STRING_IS_NULL(s))
return 0;
+
#if ! DISABLE_GC_DEBUG
/* trigger GC for debug - but not during tests */
if (0 && GC_DEBUG(interp))
Parrot_do_dod_run(interp, GC_trace_stack_FLAG);
#endif
- return PIO_WRITE(interp, pmc, s);
+
+ return Parrot_io_write_buffer(interp, pmc, s);
}
/*