From 05a88d8a95cdecf94dbe6e0a11554a0ba88bb614 Mon Sep 17 00:00:00 2001 From: Sasho Date: Sat, 17 Dec 2011 15:08:27 -0800 Subject: [PATCH] Remove FileHandle puts method and fix test and docs Signed-off-by: Jonathan "Duke" Leto --- docs/book/pir/ch08_io.pod | 11 -------- runtime/parrot/library/Archive/Tar.pir | 8 +++--- runtime/parrot/library/Archive/Zip.pir | 28 +++++++++---------- runtime/parrot/library/Configure/genfile.pir | 2 +- runtime/parrot/library/LWP/Protocol.pir | 4 +-- .../parrot/library/Test/Builder/Output.pir | 4 +-- runtime/parrot/library/osutils.pir | 8 +++--- src/pmc/filehandle.pmc | 19 ++----------- t/compilers/imcc/syn/op.t | 2 +- t/dynpmc/gziphandle.t | 2 +- t/pmc/io.t | 16 +++++------ t/pmc/packfile.t | 2 +- t/pmc/stringhandle.t | 10 +++---- 13 files changed, 45 insertions(+), 71 deletions(-) diff --git a/docs/book/pir/ch08_io.pod b/docs/book/pir/ch08_io.pod index ce88b8d40a..e5eecfe8c8 100644 --- a/docs/book/pir/ch08_io.pod +++ b/docs/book/pir/ch08_io.pod @@ -241,17 +241,6 @@ filehandle. The argument can be an integer, number, string, or PMC. =end PIR_FRAGMENT -=head3 puts - -The CX method is similar to C, but it only -takes a string argument. - -=begin PIR_FRAGMENT - - $P0.'puts'('Hello!') - -=end PIR_FRAGMENT - =head3 read The CX method reads a specified number of bytes from the filehandle diff --git a/runtime/parrot/library/Archive/Tar.pir b/runtime/parrot/library/Archive/Tar.pir index 92e12a0ea1..b5cceeb069 100644 --- a/runtime/parrot/library/Archive/Tar.pir +++ b/runtime/parrot/library/Archive/Tar.pir @@ -472,22 +472,22 @@ Write the in-memory archive to disk. The argument is already opened filehandle. entry = shift $P1 .local string header header = entry.'_format_tar_entry'() - fh.'puts'(header) + fh.'print'(header) $S0 = entry.'data'() - fh.'puts'($S0) + fh.'print'($S0) $I0 = length $S0 $I0 %= BLOCK unless $I0 goto L1 .local string TAR_PAD $I0 = BLOCK - $I0 TAR_PAD = repeat "\0", $I0 - fh.'puts'(TAR_PAD) + fh.'print'(TAR_PAD) goto L1 L2: .local string TAR_END $I0 = 2 * BLOCK TAR_END = repeat "\0", $I0 - fh.'puts'(TAR_END) + fh.'print'(TAR_END) .end .sub '_error' :method diff --git a/runtime/parrot/library/Archive/Zip.pir b/runtime/parrot/library/Archive/Zip.pir index 4fdcb3e286..c2011f8ac9 100644 --- a/runtime/parrot/library/Archive/Zip.pir +++ b/runtime/parrot/library/Archive/Zip.pir @@ -282,7 +282,7 @@ to something different than the given 'fileName'. .sub '_writeLocalFileHeader' :method .param pmc fh .const string LOCAL_FILE_HEADER_SIGNATURE = "PK\x03\x04" - $I0 = fh.'puts'(LOCAL_FILE_HEADER_SIGNATURE) + $I0 = fh.'print'(LOCAL_FILE_HEADER_SIGNATURE) if $I0 goto L1 .tailcall self.'_ioError'('writing local header signature') L1: @@ -317,17 +317,17 @@ to something different than the given 'fileName'. $I0 = length localExtraField $S0 = self.'pack_v'($I0) header .= $S0 - $I0 = fh.'puts'(header) + $I0 = fh.'print'(header) if $I0 goto L2 .tailcall self.'_ioError'('writing local header') L2: if fileName == '' goto L3 - $I0 = fh.'puts'(fileName) + $I0 = fh.'print'(fileName) if $I0 goto L3 .tailcall self.'_ioError'('writing local header filename') L3: if localExtraField == '' goto L4 - $I0 = fh.'puts'(localExtraField) + $I0 = fh.'print'(localExtraField) if $I0 goto L4 .tailcall self.'_ioError'('writing local extra field') L4: @@ -337,7 +337,7 @@ to something different than the given 'fileName'. .sub '_writeCentralDirectoryFileHeader' :method .param pmc fh .const string CENTRAL_DIRECTORY_FILE_HEADER_SIGNATURE = "PK\x01\x02" - $I0 = fh.'puts'(CENTRAL_DIRECTORY_FILE_HEADER_SIGNATURE) + $I0 = fh.'print'(CENTRAL_DIRECTORY_FILE_HEADER_SIGNATURE) if $I0 goto L1 .tailcall self.'_ioError'('writing central directory header signature') L1: @@ -394,22 +394,22 @@ to something different than the given 'fileName'. $P0 = getattribute self, 'writeLocalHeaderRelativeOffset' $S0 = self.'pack_V'($P0) header .= $S0 - $I0 = fh.'puts'(header) + $I0 = fh.'print'(header) if $I0 goto L2 .tailcall self.'_ioError'('writing central directory header') L2: unless fileNameLength goto L3 - $I0 = fh.'puts'(fileName) + $I0 = fh.'print'(fileName) if $I0 goto L3 .tailcall self.'_ioError'('writing central directory filename') L3: unless extraFieldLength goto L4 - $I0 = fh.'puts'(cdExtraField) + $I0 = fh.'print'(cdExtraField) if $I0 goto L4 .tailcall self.'_ioError'('writing central directory extra field') L4: unless fileCommentLength goto L5 - $I0 = fh.'puts'(fileComment) + $I0 = fh.'print'(fileComment) if $I0 goto L5 .tailcall self.'_ioError'('writing central directory file comment') L5: @@ -455,7 +455,7 @@ to something different than the given 'fileName'. $I0 = length localExtraField $S0 = self.'pack_v'($I0) header .= $S0 - $I0 = fh.'puts'(header) + $I0 = fh.'print'(header) if $I0 goto L2 .tailcall self.'_ioError'('re-writing local header') L2: @@ -551,7 +551,7 @@ to something different than the given 'fileName'. if $I0 == AZ_OK goto L4 .return ($I0) L4: - writeFh.'puts'($S0) + writeFh.'print'($S0) $I0 = length $S0 compressedSize += $I0 goto L2 @@ -839,7 +839,7 @@ The second arg tells whether or not to try to seek backwards to re-write headers .param int CDoffset .param int EOCDoffset .const string END_OF_CENTRAL_DIRECTORY_SIGNATURE_STRING = "PK\x05\x06" - $I0 = fh.'puts'(END_OF_CENTRAL_DIRECTORY_SIGNATURE_STRING) + $I0 = fh.'print'(END_OF_CENTRAL_DIRECTORY_SIGNATURE_STRING) if $I0 goto L1 .tailcall self.'_ioError'('writing EOCD Signature') L1: @@ -864,12 +864,12 @@ The second arg tells whether or not to try to seek backwards to re-write headers header .= $S0 $S0 = self.'pack_v'(zipfileCommentLength) header .= $S0 - $I0 = fh.'puts'(header) + $I0 = fh.'print'(header) if $I0 goto L2 .tailcall self.'_ioError'('writing EOCD header') L2: unless zipfileCommentLength goto L3 - $I0 = fh.'puts'(zipfileComment) + $I0 = fh.'print'(zipfileComment) if $I0 goto L3 .tailcall self.'_ioError'('writing zipfile comment') L3: diff --git a/runtime/parrot/library/Configure/genfile.pir b/runtime/parrot/library/Configure/genfile.pir index 6058d77c38..363a79e963 100644 --- a/runtime/parrot/library/Configure/genfile.pir +++ b/runtime/parrot/library/Configure/genfile.pir @@ -97,7 +97,7 @@ Pure PIR, without any dependencies. push_eh _handler $P0.'open'(filename, 'w') pop_eh - $P0.'puts'(content) + $P0.'print'(content) $P0.'close'() .return () _handler: diff --git a/runtime/parrot/library/LWP/Protocol.pir b/runtime/parrot/library/LWP/Protocol.pir index f1415b83b2..4aa4d3d25d 100644 --- a/runtime/parrot/library/LWP/Protocol.pir +++ b/runtime/parrot/library/LWP/Protocol.pir @@ -451,7 +451,7 @@ see http://search.cpan.org/dist/libwww-perl/ self.'_fixup_header'(request_headers, url, proxy) $S0 = _format_request(method, fullpath, request_headers) - sock.'puts'($S0) + sock.'print'($S0) .local pmc response response = new ['HTTP';'Response'] @@ -461,7 +461,7 @@ see http://search.cpan.org/dist/libwww-perl/ if null pcontent goto L11 content = pcontent unless content goto L11 - $I1 = sock.'puts'(content) + $I1 = sock.'print'(content) if $I1 >= 0 goto L11 $P0 = box RC_INTERNAL_SERVER_ERROR setattribute response, 'code', $P0 diff --git a/runtime/parrot/library/Test/Builder/Output.pir b/runtime/parrot/library/Test/Builder/Output.pir index 19c2eacafa..97b4dd788e 100644 --- a/runtime/parrot/library/Test/Builder/Output.pir +++ b/runtime/parrot/library/Test/Builder/Output.pir @@ -108,7 +108,7 @@ unescaped newlines. .local pmc output output = self.'output'() - output.'puts'( message ) + output.'print'( message ) .end .sub escape_newlines :method @@ -192,7 +192,7 @@ unescaped newlines. WRITE_MESSAGE: .local pmc diag_output diag_output = self.'diag_output'() - .tailcall diag_output.'puts'( message ) + .tailcall diag_output.'print'( message ) .end =back diff --git a/runtime/parrot/library/osutils.pir b/runtime/parrot/library/osutils.pir index 9677ce387d..27d6521945 100644 --- a/runtime/parrot/library/osutils.pir +++ b/runtime/parrot/library/osutils.pir @@ -377,7 +377,7 @@ called as C. $P0.'open'(dst, 'w') pop_eh - $P0.'puts'($S0) + $P0.'print'($S0) $P0.'close'() .return () @@ -944,7 +944,7 @@ be verbose. If given, the string I> will be displayed. $P0.'open'(filename, 'w') pop_eh - $P0.'puts'(content) + $P0.'print'(content) $P0.'close'() .return () @@ -993,7 +993,7 @@ be verbose. If given, the string I> will be displayed. $P0.'open'(filename, 'a') pop_eh - $P0.'puts'(content) + $P0.'print'(content) $P0.'close'() .return () @@ -1174,7 +1174,7 @@ For more information, see the C man page. $S1 = filename . '.gz' gh.'open'($S1, 'wb') - gh.'puts'($S0) + gh.'print'($S0) gh.'close'() unlink(filename) diff --git a/src/pmc/filehandle.pmc b/src/pmc/filehandle.pmc index dd806c106f..a0692f560c 100644 --- a/src/pmc/filehandle.pmc +++ b/src/pmc/filehandle.pmc @@ -543,26 +543,11 @@ Print the passed in integer, number, string, or PMC to the filehandle. METHOD print(PMC *to_print) { STRING * const string_to_print = VTABLE_get_string(INTERP, to_print); - Parrot_io_putps(INTERP, SELF, string_to_print); - } - - -/* - -=item C - -Print the string to the filehandle. - -=cut - -*/ - - METHOD puts(STRING *to_print) { - const INTVAL status = Parrot_io_putps(INTERP, SELF, to_print); + const INTVAL status = Parrot_io_putps(INTERP, SELF, string_to_print); + RETURN(INTVAL status); } - /* =item C diff --git a/t/compilers/imcc/syn/op.t b/t/compilers/imcc/syn/op.t index aa26482055..6aa6391169 100644 --- a/t/compilers/imcc/syn/op.t +++ b/t/compilers/imcc/syn/op.t @@ -174,7 +174,7 @@ .sub test_x_can $P0 = new 'FileHandle' - $I0 = can $P0, "puts" + $I0 = can $P0, "print" is($I0, 1, 'x = can') .end diff --git a/t/dynpmc/gziphandle.t b/t/dynpmc/gziphandle.t index a3e9db2d13..743afbf57e 100644 --- a/t/dynpmc/gziphandle.t +++ b/t/dynpmc/gziphandle.t @@ -60,7 +60,7 @@ Tests the C PMC, a zlib wrapper. .const string filename = 't/dynpmc/gziphandle.t.gz' $P1 = new 'GzipHandle' $P1.'open'(filename, 'wb') - $P1.'puts'($S0) + $P1.'print'($S0) $P1.'print'($S0) $P1.'close'() $I1 = stat filename, .STAT_FILESIZE diff --git a/t/pmc/io.t b/t/pmc/io.t index fbcf2b13f2..d36f06abaa 100644 --- a/t/pmc/io.t +++ b/t/pmc/io.t @@ -409,34 +409,34 @@ ok 2 ok 3 OUT -pir_output_is( <<'CODE', <<'OUTPUT', 'puts method' ); +pir_output_is( <<'CODE', <<'OUTPUT', 'print method' ); .sub main :main $P0 = getinterp $P2 = $P0.'stdout_handle'() - can $I0, $P2, "puts" + can $I0, $P2, "print" if $I0, ok1 print "not " ok1: print "ok 1\n" set_args "0,0", $P2, "ok 2\n" - callmethodcc $P2, "puts" + callmethodcc $P2, "print" .end CODE ok 1 ok 2 OUTPUT -pir_output_is( <<'CODE', <<'OUTPUT', 'puts method - PIR' ); +pir_output_is( <<'CODE', <<'OUTPUT', 'print method - PIR' ); .sub main :main .local string s s = "ok 2\n" .local pmc io $P0 = getinterp io = $P0.'stdout_handle'() - $I0 = can io, "puts" + $I0 = can io, "print" if $I0 goto ok1 print "not " ok1: print "ok 1\n" - io."puts"(s) + io."print"(s) .end CODE @@ -444,14 +444,14 @@ ok 1 ok 2 OUTPUT -pasm_output_is( <<'CODE', <<'OUTPUT', 'callmethod puts' ); +pasm_output_is( <<'CODE', <<'OUTPUT', 'callmethod print' ); .pcc_sub :main main: getinterp P0 # invocant set_args "0", P0 callmethodcc P0, "stderr_handle" get_results "0", P2 # STDERR - set S0, "puts" # method + set S0, "print" # method set S5, "ok 1\n" # 2nd param set_args "0,0", P2, S5 callmethodcc P2, S0 diff --git a/t/pmc/packfile.t b/t/pmc/packfile.t index 859dcf022a..d540c359d8 100644 --- a/t/pmc/packfile.t +++ b/t/pmc/packfile.t @@ -380,7 +380,7 @@ load_error: # $P1 = new ['FileHandle'] # $P1.'open'("/tmp/1.pbc", "w") - # $P1.'puts'($S0) + # $P1.'print'($S0) # $P1.'close'() pf = new 'Packfile' diff --git a/t/pmc/stringhandle.t b/t/pmc/stringhandle.t index 167ef3f407..d526df3c89 100644 --- a/t/pmc/stringhandle.t +++ b/t/pmc/stringhandle.t @@ -247,7 +247,7 @@ ok 5 - read integer back from file ok 6 - read string back from file OUT -pir_output_is( <<'CODE', <<'OUT', 'puts' ); +pir_output_is( <<'CODE', <<'OUT', 'print' ); .include 'except_types.pasm' .sub 'test' :main .local pmc sh, eh @@ -257,10 +257,10 @@ pir_output_is( <<'CODE', <<'OUT', 'puts' ); eh.'handle_types'(.EXCEPTION_PIO_ERROR) push_eh eh - # puts to SH not opened + # print to SH not opened result = 0 set_label eh, handle1 - sh.'puts'('something') + sh.'print'('something') result = 1 goto done1 handle1: @@ -268,11 +268,11 @@ handle1: done1: say result - # puts to SH opened for reading + # print to SH opened for reading result = 0 set_label eh, handle2 sh.'open'('mockname', 'r') - sh.'puts'('something') + sh.'print'('something') result = 1 goto done2 handle2: