From: Sven Verdoolaege Date: Tue, 3 Aug 1999 13:14:07 +0000 (+0200) Subject: (Retracted). See #3913. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=92479810ad7bcca524d84878cb8fc5387a2d262c;p=p5sagit%2Fp5-mst-13.2.git (Retracted). See #3913. To: perl5-porters@perl.org Subject: [ID 19990803.003] Not OK: perl 5.00560 on i586-linux-thread 2.1.125 [PATCH] Message-Id: <19990803131407.A30911@pool.kotnet.org> p4raw-id: //depot/cfgperl@3912 --- diff --git a/doio.c b/doio.c index f13d09f..0b7a46c 100644 --- a/doio.c +++ b/doio.c @@ -792,7 +792,7 @@ Perl_do_eof(pTHX_ GV *gv) while (IoIFP(io)) { if (PerlIO_has_cntptr(IoIFP(io))) { /* (the code works without this) */ - if (PerlIO_get_cnt(IoIFP(io)) > 0) /* cheat a little, since */ + if (PerlIO_get_cnt(aTHX_ IoIFP(io)) > 0) /* cheat a little, since */ return FALSE; /* this is the most usual case */ } @@ -802,8 +802,8 @@ Perl_do_eof(pTHX_ GV *gv) return FALSE; } if (PerlIO_has_cntptr(IoIFP(io)) && PerlIO_canset_cnt(IoIFP(io))) { - if (PerlIO_get_cnt(IoIFP(io)) < -1) - PerlIO_set_cnt(IoIFP(io),-1); + if (PerlIO_get_cnt(aTHX_ IoIFP(io)) < -1) + PerlIO_set_cnt(aTHX_ IoIFP(io),-1); } if (PL_op->op_flags & OPf_SPECIAL) { /* not necessarily a real EOF yet? */ if (!nextargv(PL_argvgv)) /* get another fp handy */ diff --git a/iperlsys.h b/iperlsys.h index f6e19ac..0aa4bd8 100644 --- a/iperlsys.h +++ b/iperlsys.h @@ -220,13 +220,13 @@ struct IPerlStdIOInfo (*PL_StdIO->pClearerr)(PL_StdIO, (f)) #define PerlIO_getc(f) \ (*PL_StdIO->pGetc)(PL_StdIO, (f)) -#define PerlIO_get_base(f) \ +#define PerlIO_get_base(mTHX_ f) \ (*PL_StdIO->pGetBase)(PL_StdIO, (f)) -#define PerlIO_get_bufsiz(f) \ +#define PerlIO_get_bufsiz(mTHX_ f) \ (*PL_StdIO->pGetBufsiz)(PL_StdIO, (f)) -#define PerlIO_get_cnt(f) \ +#define PerlIO_get_cnt(mTHX_ f) \ (*PL_StdIO->pGetCnt)(PL_StdIO, (f)) -#define PerlIO_get_ptr(f) \ +#define PerlIO_get_ptr(mTHX_ f) \ (*PL_StdIO->pGetPtr)(PL_StdIO, (f)) #define PerlIO_putc(f,c) \ (*PL_StdIO->pPutc)(PL_StdIO, (f),(c)) @@ -252,9 +252,9 @@ struct IPerlStdIOInfo (*PL_StdIO->pSetBuf)(PL_StdIO, (f), (b)) #define PerlIO_setvbuf(f,b,t,s) \ (*PL_StdIO->pSetVBuf)(PL_StdIO, (f),(b),(t),(s)) -#define PerlIO_set_cnt(f,c) \ +#define PerlIO_set_cnt(mTHX_ f,c) \ (*PL_StdIO->pSetCnt)(PL_StdIO, (f), (c)) -#define PerlIO_set_ptrcnt(f,p,c) \ +#define PerlIO_set_ptrcnt(mTHX_ f,p,c) \ (*PL_StdIO->pSetPtrCnt)(PL_StdIO, (f), (p), (c)) #define PerlIO_setlinebuf(f) \ (*PL_StdIO->pSetlinebuf)(PL_StdIO, (f)) @@ -425,22 +425,22 @@ extern int PerlIO_fast_gets (PerlIO *); extern int PerlIO_canset_cnt (PerlIO *); #endif #ifndef PerlIO_get_ptr -extern STDCHAR * PerlIO_get_ptr (PerlIO *); +extern STDCHAR * PerlIO_get_ptr (pTHX_ PerlIO *); #endif #ifndef PerlIO_get_cnt -extern int PerlIO_get_cnt (PerlIO *); +extern int PerlIO_get_cnt (pTHX_ PerlIO *); #endif #ifndef PerlIO_set_cnt -extern void PerlIO_set_cnt (PerlIO *,int); +extern void PerlIO_set_cnt (pTHX_ PerlIO *,int); #endif #ifndef PerlIO_set_ptrcnt -extern void PerlIO_set_ptrcnt (PerlIO *,STDCHAR *,int); +extern void PerlIO_set_ptrcnt (pTHX_ PerlIO *,STDCHAR *,int); #endif #ifndef PerlIO_get_base -extern STDCHAR * PerlIO_get_base (PerlIO *); +extern STDCHAR * PerlIO_get_base (pTHX_ PerlIO *); #endif #ifndef PerlIO_get_bufsiz -extern int PerlIO_get_bufsiz (PerlIO *); +extern int PerlIO_get_bufsiz (pTHX_ PerlIO *); #endif #ifndef PerlIO_tmpfile extern PerlIO * PerlIO_tmpfile (void); diff --git a/perl.h b/perl.h index f150fb5..3d23e97 100644 --- a/perl.h +++ b/perl.h @@ -184,10 +184,13 @@ struct perl_thread; # define dTHXa(a) pTHX = (PerlInterpreter *)a # define dTHX dTHXa(PERL_GET_INTERP) # endif +# define mTHX macro_argument # define pTHX_ pTHX, # define _pTHX ,pTHX # define aTHX_ aTHX, # define _aTHX ,aTHX +# define mTHX_ mTHX, +# define _mTHX ,mTHX #endif #define STATIC static @@ -220,6 +223,9 @@ struct perl_thread; # define aTHX # define aTHX_ # define _aTHX +# define mTHX +# define mTHX_ +# define _mTHX # define dTHXa(a) dNOOP # define dTHX dNOOP #endif diff --git a/perlio.c b/perlio.c index a2e979a..01cec42 100644 --- a/perlio.c +++ b/perlio.c @@ -141,7 +141,7 @@ PerlIO_canset_cnt(PerlIO *f) #undef PerlIO_set_cnt void -PerlIO_set_cnt(PerlIO *f, int cnt) +PerlIO_set_cnt(pTHX_ PerlIO *f, int cnt) { dTHX; if (cnt < -1 && ckWARN_d(WARN_INTERNAL)) @@ -155,7 +155,7 @@ PerlIO_set_cnt(PerlIO *f, int cnt) #undef PerlIO_set_ptrcnt void -PerlIO_set_ptrcnt(PerlIO *f, STDCHAR *ptr, int cnt) +PerlIO_set_ptrcnt(pTHX_ PerlIO *f, STDCHAR *ptr, int cnt) { #ifdef FILE_bufsiz dTHX; @@ -182,7 +182,7 @@ PerlIO_set_ptrcnt(PerlIO *f, STDCHAR *ptr, int cnt) #undef PerlIO_get_cnt int -PerlIO_get_cnt(PerlIO *f) +PerlIO_get_cnt(pTHX_ PerlIO *f) { #ifdef FILE_cnt return FILE_cnt(f); @@ -195,7 +195,7 @@ PerlIO_get_cnt(PerlIO *f) #undef PerlIO_get_bufsiz int -PerlIO_get_bufsiz(PerlIO *f) +PerlIO_get_bufsiz(pTHX_ PerlIO *f) { #ifdef FILE_bufsiz return FILE_bufsiz(f); @@ -208,7 +208,7 @@ PerlIO_get_bufsiz(PerlIO *f) #undef PerlIO_get_ptr STDCHAR * -PerlIO_get_ptr(PerlIO *f) +PerlIO_get_ptr(pTHX_ PerlIO *f) { #ifdef FILE_ptr return FILE_ptr(f); @@ -221,7 +221,7 @@ PerlIO_get_ptr(PerlIO *f) #undef PerlIO_get_base STDCHAR * -PerlIO_get_base(PerlIO *f) +PerlIO_get_base(pTHX_ PerlIO *f) { #ifdef FILE_base return FILE_base(f); @@ -287,7 +287,7 @@ PerlIO_eof(PerlIO *f) #undef PerlIO_getname char * -PerlIO_getname(PerlIO *f, char *buf) +PerlIO_getname(pTHX_ PerlIO *f, char *buf) { #ifdef VMS return fgetname(f,buf); diff --git a/perlsdio.h b/perlsdio.h index 46a15de..e9dd1f5 100644 --- a/perlsdio.h +++ b/perlsdio.h @@ -49,7 +49,7 @@ # define PerlIO_read(f,buf,count) (SSize_t)fread(buf,1,count,f) #endif #define PerlIO_eof(f) feof(f) -#define PerlIO_getname(f,b) fgetname(f,b) +#define PerlIO_getname(mTHX_ f,b) fgetname(f,b) #define PerlIO_error(f) ferror(f) #define PerlIO_fileno(f) fileno(f) #define PerlIO_clearerr(f) clearerr(f) @@ -90,34 +90,34 @@ #ifdef USE_STDIO_PTR #define PerlIO_has_cntptr(f) 1 -#define PerlIO_get_ptr(f) FILE_ptr(f) -#define PerlIO_get_cnt(f) FILE_cnt(f) +#define PerlIO_get_ptr(mTHX_ f) FILE_ptr(f) +#define PerlIO_get_cnt(mTHX_ f) FILE_cnt(f) #ifdef STDIO_CNT_LVALUE #define PerlIO_canset_cnt(f) 1 #ifdef STDIO_PTR_LVALUE #define PerlIO_fast_gets(f) 1 #endif -#define PerlIO_set_cnt(f,c) (FILE_cnt(f) = (c)) +#define PerlIO_set_cnt(mTHX_ f,c) (FILE_cnt(f) = (c)) #else #define PerlIO_canset_cnt(f) 0 -#define PerlIO_set_cnt(f,c) abort() +#define PerlIO_set_cnt(mTHX_ f,c) abort() #endif #ifdef STDIO_PTR_LVALUE -#define PerlIO_set_ptrcnt(f,p,c) (FILE_ptr(f) = (p), PerlIO_set_cnt(f,c)) +#define PerlIO_set_ptrcnt(mTHX_ f,p,c) (FILE_ptr(f) = (p), pTHX_ PerlIO_set_cnt(mTHX_ f,c)) #else -#define PerlIO_set_ptrcnt(f,p,c) abort() +#define PerlIO_set_ptrcnt(mTHX_ f,p,c) abort() #endif #else /* USE_STDIO_PTR */ #define PerlIO_has_cntptr(f) 0 #define PerlIO_canset_cnt(f) 0 -#define PerlIO_get_cnt(f) (abort(),0) -#define PerlIO_get_ptr(f) (abort(),(void *)0) -#define PerlIO_set_cnt(f,c) abort() -#define PerlIO_set_ptrcnt(f,p,c) abort() +#define PerlIO_get_cnt(mTHX_ f) (abort(),0) +#define PerlIO_get_ptr(mTHX_ f) (abort(),(void *)0) +#define PerlIO_set_cnt(mTHX_ f,c) abort() +#define PerlIO_set_ptrcnt(mTHX_ f,p,c) abort() #endif /* USE_STDIO_PTR */ @@ -128,12 +128,12 @@ #ifdef FILE_base #define PerlIO_has_base(f) 1 -#define PerlIO_get_base(f) FILE_base(f) -#define PerlIO_get_bufsiz(f) FILE_bufsiz(f) +#define PerlIO_get_base(mTHX_ f) FILE_base(f) +#define PerlIO_get_bufsiz(mTHX_ f) FILE_bufsiz(f) #else #define PerlIO_has_base(f) 0 -#define PerlIO_get_base(f) (abort(),(void *)0) -#define PerlIO_get_bufsiz(f) (abort(),0) +#define PerlIO_get_base(mTHX_ f) (abort(),(void *)0) +#define PerlIO_get_bufsiz(mTHX_ f) (abort(),0) #endif #else /* PERLIO_IS_STDIO */ #ifdef PERL_CORE diff --git a/perlsfio.h b/perlsfio.h index c4ed5c7..82814e1 100644 --- a/perlsfio.h +++ b/perlsfio.h @@ -45,15 +45,15 @@ extern int _stdprintf _ARG_((const char*, ...)); /* Now our interface to equivalent of Configure's FILE_xxx macros */ #define PerlIO_has_cntptr(f) 1 -#define PerlIO_get_ptr(f) ((f)->next) -#define PerlIO_get_cnt(f) ((f)->endr - (f)->next) +#define PerlIO_get_ptr(mTHX_ f) ((f)->next) +#define PerlIO_get_cnt(mTHX_ f) ((f)->endr - (f)->next) #define PerlIO_canset_cnt(f) 1 #define PerlIO_fast_gets(f) 1 -#define PerlIO_set_ptrcnt(f,p,c) ((f)->next = (p)) -#define PerlIO_set_cnt(f,c) 1 +#define PerlIO_set_ptrcnt(mTHX_ f,p,c) ((f)->next = (p)) +#define PerlIO_set_cnt(mTHX_ f,c) 1 #define PerlIO_has_base(f) 1 -#define PerlIO_get_base(f) ((f)->data) -#define PerlIO_get_bufsiz(f) ((f)->endr - (f)->data) +#define PerlIO_get_base(mTHX_ f) ((f)->data) +#define PerlIO_get_bufsiz(mTHX_ f) ((f)->endr - (f)->data) diff --git a/pp_sys.c b/pp_sys.c index e081d67..0527fef 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2946,15 +2946,15 @@ PP(pp_fttext) RETPUSHNO; else RETPUSHYES; - if (PerlIO_get_cnt(IoIFP(io)) <= 0) { + if (PerlIO_get_cnt(aTHX_ IoIFP(io)) <= 0) { i = PerlIO_getc(IoIFP(io)); if (i != EOF) (void)PerlIO_ungetc(IoIFP(io),i); } - if (PerlIO_get_cnt(IoIFP(io)) <= 0) /* null file is anything */ + if (PerlIO_get_cnt(aTHX_ IoIFP(io)) <= 0) /* null file is anything */ RETPUSHYES; - len = PerlIO_get_bufsiz(IoIFP(io)); - s = (STDCHAR *) PerlIO_get_base(IoIFP(io)); + len = PerlIO_get_bufsiz(aTHX_ IoIFP(io)); + s = (STDCHAR *) PerlIO_get_base(aTHX_ IoIFP(io)); /* sfio can have large buffers - limit to 512 */ if (len > 512) len = 512; diff --git a/sv.c b/sv.c index 1b15240..3c70855 100644 --- a/sv.c +++ b/sv.c @@ -3517,7 +3517,7 @@ Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append) /* Here is some breathtakingly efficient cheating */ - cnt = PerlIO_get_cnt(fp); /* get count into register */ + cnt = PerlIO_get_cnt(aTHX_ fp); /* get count into register */ (void)SvPOK_only(sv); /* validate pointer */ if (SvLEN(sv) - append <= cnt + 1) { /* make sure we have the room */ if (cnt > 80 && SvLEN(sv) > append) { @@ -3533,13 +3533,13 @@ Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append) else shortbuffered = 0; bp = (STDCHAR*)SvPVX(sv) + append; /* move these two too to registers */ - ptr = (STDCHAR*)PerlIO_get_ptr(fp); + ptr = (STDCHAR*)PerlIO_get_ptr(aTHX_ fp); DEBUG_P(PerlIO_printf(Perl_debug_log, "Screamer: entering, ptr=%ld, cnt=%ld\n",(long)ptr,(long)cnt)); DEBUG_P(PerlIO_printf(Perl_debug_log, "Screamer: entering: FILE * thinks ptr=%ld, cnt=%ld, base=%ld\n", - (long)PerlIO_get_ptr(fp), (long)PerlIO_get_cnt(fp), - (long)(PerlIO_has_base(fp) ? PerlIO_get_base(fp) : 0))); + (long)PerlIO_get_ptr(aTHX_ fp), (long)PerlIO_get_cnt(aTHX_ fp), + (long)(PerlIO_has_base(fp) ? PerlIO_get_base(aTHX_ fp) : 0))); for (;;) { screamer: if (cnt > 0) { @@ -3570,21 +3570,21 @@ Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append) DEBUG_P(PerlIO_printf(Perl_debug_log, "Screamer: going to getc, ptr=%ld, cnt=%ld\n",(long)ptr,(long)cnt)); - PerlIO_set_ptrcnt(fp, ptr, cnt); /* deregisterize cnt and ptr */ + PerlIO_set_ptrcnt(aTHX_ fp, ptr, cnt); /* deregisterize cnt and ptr */ DEBUG_P(PerlIO_printf(Perl_debug_log, "Screamer: pre: FILE * thinks ptr=%ld, cnt=%ld, base=%ld\n", - (long)PerlIO_get_ptr(fp), (long)PerlIO_get_cnt(fp), - (long)(PerlIO_has_base (fp) ? PerlIO_get_base(fp) : 0))); + (long)PerlIO_get_ptr(aTHX_ fp), (long)PerlIO_get_cnt(aTHX_ fp), + (long)(PerlIO_has_base (fp) ? PerlIO_get_base(aTHX_ fp) : 0))); /* This used to call 'filbuf' in stdio form, but as that behaves like getc when cnt <= 0 we use PerlIO_getc here to avoid introducing another abstraction. */ i = PerlIO_getc(fp); /* get more characters */ DEBUG_P(PerlIO_printf(Perl_debug_log, "Screamer: post: FILE * thinks ptr=%ld, cnt=%ld, base=%ld\n", - (long)PerlIO_get_ptr(fp), (long)PerlIO_get_cnt(fp), - (long)(PerlIO_has_base (fp) ? PerlIO_get_base(fp) : 0))); - cnt = PerlIO_get_cnt(fp); - ptr = (STDCHAR*)PerlIO_get_ptr(fp); /* reregisterize cnt and ptr */ + (long)PerlIO_get_ptr(aTHX_ fp), (long)PerlIO_get_cnt(aTHX_ fp), + (long)(PerlIO_has_base (fp) ? PerlIO_get_base(aTHX_ fp) : 0))); + cnt = PerlIO_get_cnt(aTHX_ fp); + ptr = (STDCHAR*)PerlIO_get_ptr(aTHX_ fp); /* reregisterize cnt and ptr */ DEBUG_P(PerlIO_printf(Perl_debug_log, "Screamer: after getc, ptr=%ld, cnt=%ld\n",(long)ptr,(long)cnt)); @@ -3611,11 +3611,11 @@ thats_really_all_folks: cnt += shortbuffered; DEBUG_P(PerlIO_printf(Perl_debug_log, "Screamer: quitting, ptr=%ld, cnt=%ld\n",(long)ptr,(long)cnt)); - PerlIO_set_ptrcnt(fp, ptr, cnt); /* put these back or we're in trouble */ + PerlIO_set_ptrcnt(aTHX_ fp, ptr, cnt); /* put these back or we're in trouble */ DEBUG_P(PerlIO_printf(Perl_debug_log, "Screamer: end: FILE * thinks ptr=%ld, cnt=%ld, base=%ld\n", - (long)PerlIO_get_ptr(fp), (long)PerlIO_get_cnt(fp), - (long)(PerlIO_has_base (fp) ? PerlIO_get_base(fp) : 0))); + (long)PerlIO_get_ptr(aTHX_ fp), (long)PerlIO_get_cnt(aTHX_ fp), + (long)(PerlIO_has_base (fp) ? PerlIO_get_base(aTHX_ fp) : 0))); *bp = '\0'; SvCUR_set(sv, bp - (STDCHAR*)SvPVX(sv)); /* set length */ DEBUG_P(PerlIO_printf(Perl_debug_log,