X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/04783dc7025287c5d75ab531602c7ec786a1e787..7ff1117359e03ce00638e9ee1daad537321e75d6:/util.c diff --git a/util.c b/util.c index fd053cd..e305943 100644 --- a/util.c +++ b/util.c @@ -26,7 +26,7 @@ #include "perl.h" #include "reentr.h" -#ifdef USE_PERLIO +#if defined(USE_PERLIO) #include "perliol.h" /* For PerlIOUnix_refcnt */ #endif @@ -896,6 +896,10 @@ string which is a duplicate of C. The size of the string is determined by C. The memory allocated for the new string can be freed with the C function. +On some platforms, Windows for example, all allocated memory owned by a thread +is deallocated when that thread ends. So if you need that not to happen, you +need to use the shared memory functions, such as C>. + =cut */ @@ -923,6 +927,10 @@ pointer to a newly allocated string which is a duplicate of the first C bytes from C, plus a trailing NUL byte. The memory allocated for the new string can be freed with the C function. +On some platforms, Windows for example, all allocated memory owned by a thread +is deallocated when that thread ends. So if you need that not to happen, you +need to use the shared memory functions, such as C>. + =cut */ @@ -999,6 +1007,10 @@ Perl_savesharedpvn(pTHX_ const char *const pv, const STRLEN len) A version of C/C which gets the string to duplicate from the passed in SV using C +On some platforms, Windows for example, all allocated memory owned by a thread +is deallocated when that thread ends. So if you need that not to happen, you +need to use the shared memory functions, such as C>. + =cut */ @@ -1331,17 +1343,10 @@ Perl_write_to_stderr(pTHX_ SV* msv) Perl_magic_methcall(aTHX_ MUTABLE_SV(io), mg, SV_CONST(PRINT), G_SCALAR | G_DISCARD | G_WRITING_TO_STDERR, 1, msv); else { -#ifdef USE_SFIO - /* SFIO can really mess with your errno */ - dSAVED_ERRNO; -#endif PerlIO * const serr = Perl_error_log; do_print(msv, serr); (void)PerlIO_flush(serr); -#ifdef USE_SFIO - RESTORE_ERRNO; -#endif } } @@ -2716,7 +2721,7 @@ Perl_my_pclose(pTHX_ PerlIO *ptr) SvREFCNT_dec(*svp); *svp = NULL; -#ifdef USE_PERLIO +#if defined(USE_PERLIO) /* Find out whether the refcount is low enough for us to wait for the child proc without blocking. */ should_wait = PerlIOUnix_refcnt(fd) == 1 && pid > 0; @@ -3305,7 +3310,7 @@ Perl_get_vtbl(pTHX_ int vtbl_id) I32 Perl_my_fflush_all(pTHX) { -#if defined(USE_PERLIO) || defined(FFLUSH_NULL) || defined(USE_SFIO) +#if defined(USE_PERLIO) || defined(FFLUSH_NULL) return PerlIO_flush(NULL); #else # if defined(HAS__FWALK) @@ -3686,7 +3691,11 @@ Perl_my_strftime(pTHX_ const char *fmt, int sec, int min, int hour, int mday, in #endif buflen = 64; Newx(buf, buflen, char); + + GCC_DIAG_IGNORE(-Wformat-nonliteral); /* fmt checked by caller */ len = strftime(buf, buflen, fmt, &mytm); + GCC_DIAG_RESTORE; + /* ** The following is needed to handle to the situation where ** tmpbuf overflows. Basically we want to allocate a buffer @@ -3710,7 +3719,11 @@ Perl_my_strftime(pTHX_ const char *fmt, int sec, int min, int hour, int mday, in Renew(buf, bufsize, char); while (buf) { + + GCC_DIAG_IGNORE(-Wformat-nonliteral); /* fmt checked by caller */ buflen = strftime(buf, bufsize, fmt, &mytm); + GCC_DIAG_RESTORE; + if (buflen > 0 && buflen < bufsize) break; /* heuristic to prevent out-of-memory errors */