#define sv_pvn_force_flags Perl_sv_pvn_force_flags
#define sv_2pv_flags Perl_sv_2pv_flags
#define my_atof2 Perl_my_atof2
+#if defined(USE_PERLIO) && !defined(USE_SFIO)
+#define PerlIO_close Perl_PerlIO_close
+#define PerlIO_fill Perl_PerlIO_fill
+#define PerlIO_fileno Perl_PerlIO_fileno
+#define PerlIO_eof Perl_PerlIO_eof
+#define PerlIO_error Perl_PerlIO_error
+#define PerlIO_flush Perl_PerlIO_flush
+#define PerlIO_clearerr Perl_PerlIO_clearerr
+#define PerlIO_set_cnt Perl_PerlIO_set_cnt
+#define PerlIO_set_ptrcnt Perl_PerlIO_set_ptrcnt
+#define PerlIO_setlinebuf Perl_PerlIO_setlinebuf
+#define PerlIO_read Perl_PerlIO_read
+#define PerlIO_write Perl_PerlIO_write
+#define PerlIO_unread Perl_PerlIO_unread
+#define PerlIO_tell Perl_PerlIO_tell
+#define PerlIO_seek Perl_PerlIO_seek
+#define PerlIO_get_base Perl_PerlIO_get_base
+#define PerlIO_get_ptr Perl_PerlIO_get_ptr
+#define PerlIO_get_bufsiz Perl_PerlIO_get_bufsiz
+#define PerlIO_get_cnt Perl_PerlIO_get_cnt
+#define PerlIO_stdin Perl_PerlIO_stdin
+#define PerlIO_stdout Perl_PerlIO_stdout
+#define PerlIO_stderr Perl_PerlIO_stderr
+#endif /* PERLIO_LAYERS */
#define ck_anoncode Perl_ck_anoncode
#define ck_bitop Perl_ck_bitop
#define ck_concat Perl_ck_concat
#define sv_pvn_force_flags(a,b,c) Perl_sv_pvn_force_flags(aTHX_ a,b,c)
#define sv_2pv_flags(a,b,c) Perl_sv_2pv_flags(aTHX_ a,b,c)
#define my_atof2(a,b) Perl_my_atof2(aTHX_ a,b)
+#if defined(USE_PERLIO) && !defined(USE_SFIO)
+#define PerlIO_close(a) Perl_PerlIO_close(aTHX_ a)
+#define PerlIO_fill(a) Perl_PerlIO_fill(aTHX_ a)
+#define PerlIO_fileno(a) Perl_PerlIO_fileno(aTHX_ a)
+#define PerlIO_eof(a) Perl_PerlIO_eof(aTHX_ a)
+#define PerlIO_error(a) Perl_PerlIO_error(aTHX_ a)
+#define PerlIO_flush(a) Perl_PerlIO_flush(aTHX_ a)
+#define PerlIO_clearerr(a) Perl_PerlIO_clearerr(aTHX_ a)
+#define PerlIO_set_cnt(a,b) Perl_PerlIO_set_cnt(aTHX_ a,b)
+#define PerlIO_set_ptrcnt(a,b,c) Perl_PerlIO_set_ptrcnt(aTHX_ a,b,c)
+#define PerlIO_setlinebuf(a) Perl_PerlIO_setlinebuf(aTHX_ a)
+#define PerlIO_read(a,b,c) Perl_PerlIO_read(aTHX_ a,b,c)
+#define PerlIO_write(a,b,c) Perl_PerlIO_write(aTHX_ a,b,c)
+#define PerlIO_unread(a,b,c) Perl_PerlIO_unread(aTHX_ a,b,c)
+#define PerlIO_tell(a) Perl_PerlIO_tell(aTHX_ a)
+#define PerlIO_seek(a,b,c) Perl_PerlIO_seek(aTHX_ a,b,c)
+#define PerlIO_get_base(a) Perl_PerlIO_get_base(aTHX_ a)
+#define PerlIO_get_ptr(a) Perl_PerlIO_get_ptr(aTHX_ a)
+#define PerlIO_get_bufsiz(a) Perl_PerlIO_get_bufsiz(aTHX_ a)
+#define PerlIO_get_cnt(a) Perl_PerlIO_get_cnt(aTHX_ a)
+#define PerlIO_stdin() Perl_PerlIO_stdin(aTHX)
+#define PerlIO_stdout() Perl_PerlIO_stdout(aTHX)
+#define PerlIO_stderr() Perl_PerlIO_stderr(aTHX)
+#endif /* PERLIO_LAYERS */
#define ck_anoncode(a) Perl_ck_anoncode(aTHX_ a)
#define ck_bitop(a) Perl_ck_bitop(aTHX_ a)
#define ck_concat(a) Perl_ck_concat(aTHX_ a)
return PerlIO_apply_layers(aTHX_ f, NULL, names) == 0 ? TRUE : FALSE;
}
-#undef PerlIO__close
int
-PerlIO__close(PerlIO *f)
+PerlIO__close(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Close) (aTHX_ f);
else {
}
}
-#undef PerlIO_close
int
-PerlIO_close(PerlIO *f)
+Perl_PerlIO_close(pTHX_ PerlIO *f)
{
- dTHX;
int code = -1;
if (f && *f) {
code = (*PerlIOBase(f)->tab->Close) (aTHX_ f);
return code;
}
-#undef PerlIO_fileno
int
-PerlIO_fileno(PerlIO *f)
+Perl_PerlIO_fileno(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Fileno) (aTHX_ f);
else {
}
-#undef PerlIO_fdopen
-PerlIO *
-PerlIO_fdopen(int fd, const char *mode)
-{
- dTHX;
- return PerlIO_openn(aTHX_ Nullch, mode, fd, 0, 0, NULL, 0, NULL);
-}
-
-#undef PerlIO_open
-PerlIO *
-PerlIO_open(const char *path, const char *mode)
-{
- dTHX;
- SV *name = sv_2mortal(newSVpvn(path, strlen(path)));
- return PerlIO_openn(aTHX_ Nullch, mode, -1, 0, 0, NULL, 1, &name);
-}
-
-#undef PerlIO_reopen
-PerlIO *
-PerlIO_reopen(const char *path, const char *mode, PerlIO *f)
-{
- dTHX;
- SV *name = sv_2mortal(newSVpvn(path, strlen(path)));
- return PerlIO_openn(aTHX_ Nullch, mode, -1, 0, 0, f, 1, &name);
-}
-
-#undef PerlIO_read
SSize_t
-PerlIO_read(PerlIO *f, void *vbuf, Size_t count)
+Perl_PerlIO_read(pTHX_ PerlIO *f, void *vbuf, Size_t count)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Read) (aTHX_ f, vbuf, count);
else {
}
}
-#undef PerlIO_unread
SSize_t
-PerlIO_unread(PerlIO *f, const void *vbuf, Size_t count)
+Perl_PerlIO_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Unread) (aTHX_ f, vbuf, count);
else {
}
}
-#undef PerlIO_write
SSize_t
-PerlIO_write(PerlIO *f, const void *vbuf, Size_t count)
+Perl_PerlIO_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Write) (aTHX_ f, vbuf, count);
else {
}
}
-#undef PerlIO_seek
int
-PerlIO_seek(PerlIO *f, Off_t offset, int whence)
+Perl_PerlIO_seek(pTHX_ PerlIO *f, Off_t offset, int whence)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Seek) (aTHX_ f, offset, whence);
else {
}
}
-#undef PerlIO_tell
Off_t
-PerlIO_tell(PerlIO *f)
+Perl_PerlIO_tell(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Tell) (aTHX_ f);
else {
}
}
-#undef PerlIO_flush
int
-PerlIO_flush(PerlIO *f)
+Perl_PerlIO_flush(pTHX_ PerlIO *f)
{
- dTHX;
if (f) {
if (*f) {
PerlIO_funcs *tab = PerlIOBase(f)->tab;
}
}
-#undef PerlIO_fill
int
-PerlIO_fill(PerlIO *f)
+Perl_PerlIO_fill(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Fill) (aTHX_ f);
else {
}
}
-#undef PerlIO_isutf8
int
PerlIO_isutf8(PerlIO *f)
{
}
}
-#undef PerlIO_eof
int
-PerlIO_eof(PerlIO *f)
+Perl_PerlIO_eof(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Eof) (aTHX_ f);
else {
}
}
-#undef PerlIO_error
int
-PerlIO_error(PerlIO *f)
+Perl_PerlIO_error(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Error) (aTHX_ f);
else {
}
}
-#undef PerlIO_clearerr
void
-PerlIO_clearerr(PerlIO *f)
+Perl_PerlIO_clearerr(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
(*PerlIOBase(f)->tab->Clearerr) (aTHX_ f);
else
SETERRNO(EBADF, SS$_IVCHAN);
}
-#undef PerlIO_setlinebuf
void
-PerlIO_setlinebuf(PerlIO *f)
+Perl_PerlIO_setlinebuf(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
(*PerlIOBase(f)->tab->Setlinebuf) (aTHX_ f);
else
SETERRNO(EBADF, SS$_IVCHAN);
}
-#undef PerlIO_has_base
int
PerlIO_has_base(PerlIO *f)
{
return 0;
}
-#undef PerlIO_fast_gets
int
PerlIO_fast_gets(PerlIO *f)
{
return 0;
}
-#undef PerlIO_has_cntptr
int
PerlIO_has_cntptr(PerlIO *f)
{
return 0;
}
-#undef PerlIO_canset_cnt
int
PerlIO_canset_cnt(PerlIO *f)
{
return 0;
}
-#undef PerlIO_get_base
STDCHAR *
-PerlIO_get_base(PerlIO *f)
+Perl_PerlIO_get_base(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Get_base) (aTHX_ f);
return NULL;
}
-#undef PerlIO_get_bufsiz
int
-PerlIO_get_bufsiz(PerlIO *f)
+Perl_PerlIO_get_bufsiz(pTHX_ PerlIO *f)
{
- dTHX;
if (f && *f)
return (*PerlIOBase(f)->tab->Get_bufsiz) (aTHX_ f);
return 0;
}
-#undef PerlIO_get_ptr
STDCHAR *
-PerlIO_get_ptr(PerlIO *f)
+Perl_PerlIO_get_ptr(pTHX_ PerlIO *f)
{
- dTHX;
PerlIO_funcs *tab = PerlIOBase(f)->tab;
if (tab->Get_ptr == NULL)
return NULL;
return (*tab->Get_ptr) (aTHX_ f);
}
-#undef PerlIO_get_cnt
int
-PerlIO_get_cnt(PerlIO *f)
+Perl_PerlIO_get_cnt(pTHX_ PerlIO *f)
{
- dTHX;
PerlIO_funcs *tab = PerlIOBase(f)->tab;
if (tab->Get_cnt == NULL)
return 0;
return (*tab->Get_cnt) (aTHX_ f);
}
-#undef PerlIO_set_cnt
void
-PerlIO_set_cnt(PerlIO *f, int cnt)
+Perl_PerlIO_set_cnt(pTHX_ PerlIO *f, int cnt)
{
- dTHX;
(*PerlIOBase(f)->tab->Set_ptrcnt) (aTHX_ f, NULL, cnt);
}
-#undef PerlIO_set_ptrcnt
void
-PerlIO_set_ptrcnt(PerlIO *f, STDCHAR * ptr, int cnt)
+Perl_PerlIO_set_ptrcnt(pTHX_ PerlIO *f, STDCHAR * ptr, int cnt)
{
- dTHX;
PerlIO_funcs *tab = PerlIOBase(f)->tab;
if (tab->Set_ptrcnt == NULL) {
Perl_croak(aTHX_ "PerlIO buffer snooping abuse");
return PerlIOBase_pushed(aTHX_ f, mode, arg);
}
-#undef PerlIO_importFILE
PerlIO *
PerlIO_importFILE(FILE *stdio, int fl)
{
PerlSIO_set_ptr(stdio, (void*)ptr); /* LHS STDCHAR* cast non-portable */
#ifdef STDIO_PTR_LVAL_SETS_CNT
if (PerlSIO_get_cnt(stdio) != (cnt)) {
- dTHX;
assert(PerlSIO_get_cnt(stdio) == (cnt));
}
#endif
#endif /* USE_STDIO_PTR */
};
-#undef PerlIO_exportFILE
FILE *
PerlIO_exportFILE(PerlIO *f, int fl)
{
+ dTHX;
FILE *stdio;
PerlIO_flush(f);
stdio = fdopen(PerlIO_fileno(f), "r+");
if (stdio) {
- dTHX;
PerlIOStdio *s =
PerlIOSelf(PerlIO_push(aTHX_ f, &PerlIO_stdio, "r+", Nullsv),
PerlIOStdio);
return stdio;
}
-#undef PerlIO_findFILE
FILE *
PerlIO_findFILE(PerlIO *f)
{
return PerlIO_exportFILE(f, 0);
}
-#undef PerlIO_releaseFILE
void
PerlIO_releaseFILE(PerlIO *p, FILE *f)
{
PerlIO_get_base(f);
b->ptr = ptr;
if (PerlIO_get_cnt(f) != cnt || b->ptr < b->buf) {
- dTHX;
assert(PerlIO_get_cnt(f) == cnt);
assert(b->ptr >= b->buf);
}
/*
* Blast - found CR as last char in buffer
*/
-
+
if (b->ptr < nl) {
/*
* They may not care, defer work as long as
if (ptr+cnt == c->nl && c->nl+1 == b->end && *c->nl == 0xd) {
/* Defered CR at end of buffer case - we lied about count */
chk--;
- }
+ }
chk -= cnt;
if (ptr != chk ) {
}
IV
-PerlIOMmap_unmap(PerlIO *f)
+PerlIOMmap_unmap(pTHX_ PerlIO *f)
{
PerlIOMmap *m = PerlIOSelf(f, PerlIOMmap);
PerlIOBuf *b = &m->base;
* No, or wrong sort of, buffer
*/
if (m->len) {
- if (PerlIOMmap_unmap(f) != 0)
+ if (PerlIOMmap_unmap(aTHX_ f) != 0)
return 0;
}
/*
/*
* Unmap the buffer
*/
- if (PerlIOMmap_unmap(f) != 0)
+ if (PerlIOMmap_unmap(aTHX_ f) != 0)
code = -1;
}
else {
#endif /* HAS_MMAP */
-#undef PerlIO_stdin
PerlIO *
-PerlIO_stdin(void)
+Perl_PerlIO_stdin(pTHX)
{
- dTHX;
if (!PL_perlio) {
PerlIO_stdstreams(aTHX);
}
return &PL_perlio[1];
}
-#undef PerlIO_stdout
PerlIO *
-PerlIO_stdout(void)
+Perl_PerlIO_stdout(pTHX)
{
- dTHX;
if (!PL_perlio) {
PerlIO_stdstreams(aTHX);
}
return &PL_perlio[2];
}
-#undef PerlIO_stderr
PerlIO *
-PerlIO_stderr(void)
+Perl_PerlIO_stderr(pTHX)
{
- dTHX;
if (!PL_perlio) {
PerlIO_stdstreams(aTHX);
}
/*--------------------------------------------------------------------------------------*/
-#undef PerlIO_getname
char *
PerlIO_getname(PerlIO *f, char *buf)
{
* terms of above
*/
+#undef PerlIO_fdopen
+PerlIO *
+PerlIO_fdopen(int fd, const char *mode)
+{
+ dTHX;
+ return PerlIO_openn(aTHX_ Nullch, mode, fd, 0, 0, NULL, 0, NULL);
+}
+
+#undef PerlIO_open
+PerlIO *
+PerlIO_open(const char *path, const char *mode)
+{
+ dTHX;
+ SV *name = sv_2mortal(newSVpvn(path, strlen(path)));
+ return PerlIO_openn(aTHX_ Nullch, mode, -1, 0, 0, NULL, 1, &name);
+}
+
+#undef Perlio_reopen
+PerlIO *
+PerlIO_reopen(const char *path, const char *mode, PerlIO *f)
+{
+ dTHX;
+ SV *name = sv_2mortal(newSVpvn(path, strlen(path)));
+ return PerlIO_openn(aTHX_ Nullch, mode, -1, 0, 0, f, 1, &name);
+}
+
#undef PerlIO_getc
int
PerlIO_getc(PerlIO *f)
{
+ dTHX;
STDCHAR buf[1];
SSize_t count = PerlIO_read(f, buf, 1);
if (count == 1) {
int
PerlIO_ungetc(PerlIO *f, int ch)
{
+ dTHX;
if (ch != EOF) {
STDCHAR buf = ch;
if (PerlIO_unread(f, &buf, 1) == 1)
int
PerlIO_putc(PerlIO *f, int ch)
{
+ dTHX;
STDCHAR buf = ch;
return PerlIO_write(f, &buf, 1);
}
int
PerlIO_puts(PerlIO *f, const char *s)
{
+ dTHX;
STRLEN len = strlen(s);
return PerlIO_write(f, s, len);
}
void
PerlIO_rewind(PerlIO *f)
{
+ dTHX;
PerlIO_seek(f, (Off_t) 0, SEEK_SET);
PerlIO_clearerr(f);
}
int
PerlIO_stdoutf(const char *fmt, ...)
{
+ dTHX;
va_list ap;
int result;
va_start(ap, fmt);