[svn:parrot] r46317 - trunk/src/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Wed May 5 21:15:50 UTC 2010
Author: NotFound
Date: Wed May 5 21:15:50 2010
New Revision: 46317
URL: https://trac.parrot.org/parrot/changeset/46317
Log:
cleanup FileHandle.readall method
Modified:
trunk/src/pmc/filehandle.pmc
Modified: trunk/src/pmc/filehandle.pmc
==============================================================================
--- trunk/src/pmc/filehandle.pmc Wed May 5 16:53:18 2010 (r46316)
+++ trunk/src/pmc/filehandle.pmc Wed May 5 21:15:50 2010 (r46317)
@@ -459,7 +459,6 @@
result = Parrot_io_reads(INTERP, filehandle, size);
Parrot_io_close(INTERP, filehandle);
- RETURN(STRING *result);
}
else {
/* slurp open file */
@@ -467,19 +466,16 @@
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_PIO_ERROR,
"Cannot readall without a file name or open filehandle");
- result = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
-
/* Do line buffering on the filehandle */
if (!(PARROT_FILEHANDLE(SELF)->flags & PIO_F_LINEBUF))
Parrot_io_setlinebuf(INTERP, SELF);
+ result = STRINGNULL;
do {
STRING * const part = Parrot_io_reads(INTERP, SELF, 0);
- result = Parrot_str_concat(INTERP, result, part);
-
- if (Parrot_io_eof(INTERP, SELF))
- break;
- } while (1);
+ result = STRING_IS_NULL(result) ? part :
+ Parrot_str_concat(INTERP, result, part);
+ } while (!Parrot_io_eof(INTERP, SELF));
}
RETURN(STRING *result);
More information about the parrot-commits
mailing list