[inseperable differences to perl 5.004_03]
[p5sagit/p5-mst-13.2.git] / ext / IO / IO.xs
index 8611b2d..e558d5c 100644 (file)
@@ -106,11 +106,12 @@ fsetpos(handle, pos)
        InputStream     handle
        SV *            pos
     CODE:
-       if (handle)
+       char *p;
+       if (handle && (p = SvPVx(pos, na)) && na == sizeof(Fpos_t))
 #ifdef PerlIO
-           RETVAL = PerlIO_setpos(handle, (Fpos_t*)SvPVX(pos));
+           RETVAL = PerlIO_setpos(handle, (Fpos_t*)p);
 #else
-           RETVAL = fsetpos(handle, (Fpos_t*)SvPVX(pos));
+           RETVAL = fsetpos(handle, (Fpos_t*)p);
 #endif
        else {
            RETVAL = -1;
@@ -268,8 +269,10 @@ setvbuf(handle, buf, type, size)
        int             type
        int             size
     CODE:
-#ifdef PERLIO_IS_STDIO
-#ifdef _IOFBF   /* Should be HAS_SETVBUF once Configure tests for that */
+/* Should check HAS_SETVBUF once Configure tests for that */
+#if defined(PERLIO_IS_STDIO) && defined(_IOFBF)
+       if (!handle)                    /* Try input stream. */
+           handle = IoIFP(sv_2io(ST(0)));
        if (handle)
            RETVAL = setvbuf(handle, buf, type, size);
        else {
@@ -277,10 +280,7 @@ setvbuf(handle, buf, type, size)
            errno = EINVAL;
        }
 #else
-           RETVAL = (SysRet) not_here("IO::Handle::setvbuf");
-#endif /* _IOFBF */
-#else
-           not_here("IO::Handle::setvbuf");
+       RETVAL = (SysRet) not_here("IO::Handle::setvbuf");
 #endif
     OUTPUT:
        RETVAL