This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Further ANSI changes now builds and passes (most) tests
[perl5.git] / ext / IO / IO.xs
index 5efbf24..f226a79 100644 (file)
@@ -22,17 +22,14 @@ typedef FILE * OutputStream;
 #endif
 
 static int
-not_here(s)
-char *s;
+not_here(char *s)
 {
     croak("%s not implemented on this architecture", s);
     return -1;
 }
 
 static bool
-constant(name, pval)
-char *name;
-IV *pval;
+constant(char *name, IV *pval)
 {
     switch (*name) {
     case '_':
@@ -106,11 +103,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;
@@ -270,6 +268,8 @@ setvbuf(handle, buf, type, size)
     CODE:
 /* 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 {