All of syswrite/send/sendto need to return character counts,
Jarkko Hietaniemi [Sun, 18 Nov 2001 16:46:11 +0000 (16:46 +0000)]
and character counts from the offset, not the beginning of
the scalar.

p4raw-id: //depot/perl@13076

pp_sys.c

index a333b10..bf2b352 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1842,9 +1842,6 @@ PP(pp_send)
            /* See the note at doio.c:do_print about filesize limits. --jhi */
            retval = PerlLIO_write(PerlIO_fileno(IoIFP(io)),
                                   buffer, length);
-           if (DO_UTF8(bufsv))
-               retval = utf8_length((U8*)SvPVX(bufsv),
-                                    (U8*)SvPVX(bufsv) + retval);
        }
     }
 #ifdef HAS_SOCKET
@@ -1866,6 +1863,8 @@ PP(pp_send)
     if (retval < 0)
        goto say_undef;
     SP = ORIGMARK;
+    if (DO_UTF8(bufsv))
+        retval = utf8_length((U8*)buffer, (U8*)buffer + retval);
 #if Size_t_size > IVSIZE
     PUSHn(retval);
 #else