#ifdef PERL_MICRO
# include "uconfig.h"
#else
-# include "config.h"
+# ifndef USE_CROSS_COMPILE
+# include "config.h"
+# else
+# include "xconfig.h"
+# endif
#endif
#define PERLIO_NOT_STDIO 0
const char * const s = CopFILE(PL_curcop);
/* 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));
- const STRLEN len2 = vsprintf(buffer+len, fmt, ap);
- PerlLIO_write(PL_perlio_debug_fd, buffer, len + len2);
+ const STRLEN len1 = my_snprintf(buffer, sizeof(buffer), "%.40s:%" IVdf " ", s ? s : "(none)", (IV) CopLINE(PL_curcop));
+ const STRLEN len2 = my_vsnprintf(buffer + len1, sizeof(buffer) - len1, fmt, ap);
+ PerlLIO_write(PL_perlio_debug_fd, buffer, len1 + len2);
#else
const char *s = CopFILE(PL_curcop);
STRLEN len;
PL_known_layers = PerlIO_clone_list(aTHX_ proto->Iknown_layers, param);
PL_def_layerlist = PerlIO_clone_list(aTHX_ proto->Idef_layerlist, param);
PerlIO_allocate(aTHX); /* root slot is never used */
- PerlIO_debug("Clone %p from %p\n",aTHX,proto);
+ PerlIO_debug("Clone %p from %p\n",(void*)aTHX,(void*)proto);
while ((f = *table)) {
int i;
table = (PerlIO **) (f++);
}
}
#else
+ PERL_UNUSED_CONTEXT;
PERL_UNUSED_ARG(proto);
PERL_UNUSED_ARG(param);
#endif
PerlIO **table = &PL_perlio;
PerlIO *f;
#ifdef USE_ITHREADS
- PerlIO_debug("Destruct %p\n",aTHX);
+ PerlIO_debug("Destruct %p\n",(void*)aTHX);
#endif
while ((f = *table)) {
int i;
type = SvPV_const(layers, len);
if (type && mode[0] != 'r') {
/*
- * Skip to write part
+ * Skip to write part, which is separated by a '\0'
*/
- const char * const s = strchr(type, 0);
- if (s && (STRLEN)(s - type) < len) {
- type = s + 1;
+ STRLEN read_len = strlen(type);
+ if (read_len < len) {
+ type += read_len + 1;
}
}
}
SSize_t avail = PerlIO_get_cnt(f);
SSize_t take = 0;
if (avail > 0)
- take = ((SSize_t)count < avail) ? count : avail;
+ take = ((SSize_t)count < avail) ? (SSize_t)count : avail;
if (take > 0) {
STDCHAR *ptr = PerlIO_get_ptr(f);
Copy(ptr, buf, take, STDCHAR);
/* Must be called with PerlIO_mutex locked. */
static void
S_more_refcounted_fds(pTHX_ const int new_fd) {
+ dVAR;
const int old_max = PL_perlio_fd_refcnt_size;
const int new_max = 16 + (new_fd & ~15);
int *new_array;
PL_perlio_fd_refcnt_size = new_max;
PL_perlio_fd_refcnt = new_array;
- PerlIO_debug("Zeroing %p, %d\n", new_array + old_max, new_max - old_max);
+ PerlIO_debug("Zeroing %p, %d\n",
+ (void*)(new_array + old_max),
+ new_max - old_max);
Zero(new_array + old_max, new_max - old_max, int);
}
dVAR;
int i;
#ifdef USE_ITHREADS
- PerlIO_debug("Cleanup layers for %p\n",aTHX);
+ PerlIO_debug("Cleanup layers for %p\n",(void*)aTHX);
#else
PerlIO_debug("Cleanup layers\n");
#endif
}
else {
if (f) {
- /*EMPTY*/;
+ NOOP;
/*
* FIXME: pop layers ???
*/
goto set_this;
}
else {
- /*EMPTY*/;
+ NOOP;
/* FIXME: To avoid messy error recovery if dup fails
re-use the existing stdio as though flag was not set
*/
return PerlSIO_fflush(stdio);
}
else {
- /*EMPTY*/;
+ NOOP;
#if 0
/*
* FIXME: This discards ungetc() and pre-read stuff which is not
ptr -= cnt;
}
else {
- /*EMPTY*/;
+ NOOP;
#if 0
/*
* Test code - delete when it works ...
int
PerlIO_vsprintf(char *s, int n, const char *fmt, va_list ap)
{
- dVAR;
- const int val = vsprintf(s, fmt, ap);
- if (n >= 0) {
- if (strlen(s) >= (STRLEN) n) {
- dTHX;
- (void) PerlIO_puts(Perl_error_log,
- "panic: sprintf overflow - memory corrupted!\n");
- my_exit(1);
- }
+ const int val = my_vsnprintf(s, n > 0 ? n : 0, fmt, ap);
+#ifndef PERL_MY_VSNPRINTF_GUARDED
+ if (val < 0 || (n > 0 ? val >= n : 0)) {
+ dTHX;
+ Perl_croak(aTHX_ "panic: my_vsnprintf overflow in PerlIO_vsprintf\n");
}
+#endif
return val;
}
#endif