X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=perlio.c;h=49b1b2d1f9d7df7d05aaa18a1887b1cfe1b11788;hb=17fda5459df9207789e2c93a13c6057a90cf1f93;hp=8a2346184e4407d2453b88518c441dfa0f5223ca;hpb=dcda55fce16d4bfd5fd692594c1b771b8c7e87d8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/perlio.c b/perlio.c index 8a23461..49b1b2d 100644 --- a/perlio.c +++ b/perlio.c @@ -475,8 +475,8 @@ PerlIO_debug(const char *fmt, ...) /* Use fixed buffer as sv_catpvf etc. needs SVs */ char buffer[1024]; const STRLEN len = my_sprintf(buffer, "%.40s:%" IVdf " ", s ? s : "(none)", (IV) CopLINE(PL_curcop)); - vsprintf(buffer+len, fmt, ap); - PerlLIO_write(PL_perlio_debug_fd, buffer, strlen(buffer)); + const STRLEN len2 = vsprintf(buffer+len, fmt, ap); + PerlLIO_write(PL_perlio_debug_fd, buffer, len + len2); #else const char *s = CopFILE(PL_curcop); STRLEN len; @@ -1296,9 +1296,10 @@ PerlIO_apply_layers(pTHX_ PerlIO *f, const char *mode, const char *names) int PerlIO_binmode(pTHX_ PerlIO *f, int iotype, int mode, const char *names) { - PerlIO_debug("PerlIO_binmode f=%p %s %c %x %s\n", - (void*)f, PerlIOBase(f)->tab->name, iotype, mode, - (names) ? names : "(Null)"); + PerlIO_debug("PerlIO_binmode f=%p %s %c %x %s\n", (void*)f, + (PerlIOBase(f)) ? PerlIOBase(f)->tab->name : "(Null)", + iotype, mode, (names) ? names : "(Null)"); + if (names) { /* Do not flush etc. if (e.g.) switching encodings. if a pushed layer knows it needs to flush lower layers @@ -1546,8 +1547,8 @@ PerlIO_openn(pTHX_ const char *layers, const char *mode, int fd, Perl_croak(aTHX_ "More than one argument to open(,':%s')",tab->name); } PerlIO_debug("openn(%s,'%s','%s',%d,%x,%o,%p,%d,%p)\n", - tab->name, layers, mode, fd, imode, perm, - (void*)f, narg, (void*)args); + tab->name, layers ? layers : "(Null)", mode, fd, + imode, perm, (void*)f, narg, (void*)args); if (tab->Open) f = (*tab->Open) (aTHX_ tab, layera, n, mode, fd, imode, perm, f, narg, args); @@ -3169,7 +3170,7 @@ PerlIOStdio_flush(pTHX_ PerlIO *f) /* * Not writeable - sync by attempting a seek */ - int err = errno; + const int err = errno; if (PerlSIO_fseek(stdio, (Off_t) 0, SEEK_CUR) != 0) errno = err; #endif @@ -4785,7 +4786,7 @@ PerlIO * PerlIO_open(const char *path, const char *mode) { dTHX; - SV *name = sv_2mortal(newSVpvn(path, strlen(path))); + SV *name = sv_2mortal(newSVpv(path, 0)); return PerlIO_openn(aTHX_ Nullch, mode, -1, 0, 0, NULL, 1, &name); } @@ -4794,7 +4795,7 @@ PerlIO * PerlIO_reopen(const char *path, const char *mode, PerlIO *f) { dTHX; - SV *name = sv_2mortal(newSVpvn(path, strlen(path))); + SV *name = sv_2mortal(newSVpv(path,0)); return PerlIO_openn(aTHX_ Nullch, mode, -1, 0, 0, f, 1, &name); }