This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PERL_BADLANG wrongly documented.
[perl5.git] / perlio.c
index 0a0625c..a1af870 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -16,7 +16,7 @@
 #endif
 /*
  * This file provides those parts of PerlIO abstraction 
- * which are not #defined in perlio.h.
+ * which are not #defined in iperlsys.h.
  * Which these are depends on various Configure #ifdef's 
  */
 
@@ -26,7 +26,7 @@
 #ifdef PERLIO_IS_STDIO 
 
 void
-PerlIO_init()
+PerlIO_init(void)
 {
  /* Does nothing (yet) except force this file to be included 
     in perl binary. That allows this file to force inclusion
@@ -37,7 +37,7 @@ PerlIO_init()
 
 #undef PerlIO_tmpfile
 PerlIO *
-PerlIO_tmpfile()
+PerlIO_tmpfile(void)
 {
  return tmpfile();
 }
@@ -76,7 +76,7 @@ PerlIO_init()
  sfset(sfstdout,SF_SHARE,0);
 }
 
-#else
+#else /* USE_SFIO */
 
 /* Implement all the PerlIO interface using stdio. 
    - this should be only file to include <stdio.h>
@@ -308,6 +308,7 @@ char *buf;
  return fgetname(f,buf);
 #else
  croak("Don't know how to get file name");
+ return NULL;
 #endif
 }
 
@@ -359,7 +360,11 @@ PerlIO *f;
 #ifdef HAS_SETLINEBUF
     setlinebuf(f);
 #else
+#  ifdef __BORLANDC__ /* Borland doesn't like NULL size for _IOLBF */
+    setvbuf(f, Nullch, _IOLBF, BUFSIZ);
+#  else
     setvbuf(f, Nullch, _IOLBF, 0);
+#  endif
 #endif
 }
 
@@ -369,7 +374,7 @@ PerlIO_putc(f,ch)
 PerlIO *f;
 int ch;
 {
- putc(ch,f);
return putc(ch,f);
 }
 
 #undef PerlIO_ungetc
@@ -378,7 +383,7 @@ PerlIO_ungetc(f,ch)
 PerlIO *f;
 int ch;
 {
- ungetc(ch,f);
return ungetc(ch,f);
 }
 
 #undef PerlIO_read
@@ -411,23 +416,30 @@ va_list ap;
  return vfprintf(f,fmt,ap);
 }
 
-
 #undef PerlIO_tell
-long
+Off_t
 PerlIO_tell(f)
 PerlIO *f;
 {
+#ifdef HAS_FTELLO
+ return ftello(f);
+#else
  return ftell(f);
+#endif
 }
 
 #undef PerlIO_seek
 int
 PerlIO_seek(f,offset,whence)
 PerlIO *f;
-off_t offset;
+Off_t offset;
 int whence;
 {
+#ifdef HAS_FSEEKO
+ return fseeko(f,offset,whence);
+#else
  return fseek(f,offset,whence);
+#endif
 }
 
 #undef PerlIO_rewind
@@ -440,22 +452,11 @@ PerlIO *f;
 
 #undef PerlIO_printf
 int      
-#ifdef I_STDARG
 PerlIO_printf(PerlIO *f,const char *fmt,...)
-#else
-PerlIO_printf(f,fmt,va_alist)
-PerlIO *f;
-const char *fmt;
-va_dcl
-#endif
 {
  va_list ap;
  int result;
-#ifdef I_STDARG
  va_start(ap,fmt);
-#else
- va_start(ap);
-#endif
  result = vfprintf(f,fmt,ap);
  va_end(ap);
  return result;
@@ -463,21 +464,11 @@ va_dcl
 
 #undef PerlIO_stdoutf
 int      
-#ifdef I_STDARG
 PerlIO_stdoutf(const char *fmt,...)
-#else
-PerlIO_stdoutf(fmt, va_alist)
-const char *fmt;
-va_dcl
-#endif
 {
  va_list ap;
  int result;
-#ifdef I_STDARG
  va_start(ap,fmt);
-#else
- va_start(ap);
-#endif
  result = PerlIO_vprintf(PerlIO_stdout(),fmt,ap);
  va_end(ap);
  return result;
@@ -605,11 +596,7 @@ char *pat, *args;
 
 #ifndef PerlIO_vsprintf
 int 
-PerlIO_vsprintf(s,n,fmt,ap)
-char *s;
-const char *fmt;
-int n;
-va_list ap;
+PerlIO_vsprintf(char *s, int n, const char *fmt, va_list ap)
 {
  int val = vsprintf(s, fmt, ap);
  if (n >= 0)
@@ -626,23 +613,11 @@ va_list ap;
 
 #ifndef PerlIO_sprintf
 int      
-#ifdef I_STDARG
 PerlIO_sprintf(char *s, int n, const char *fmt,...)
-#else
-PerlIO_sprintf(s, n, fmt, va_alist)
-char *s;
-int n;
-const char *fmt;
-va_dcl
-#endif
 {
  va_list ap;
  int result;
-#ifdef I_STDARG
  va_start(ap,fmt);
-#else
- va_start(ap);
-#endif
  result = PerlIO_vsprintf(s, n, fmt, ap);
  va_end(ap);
  return result;