summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-10-06 02:36:53 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-10-06 02:36:53 +0000
commitbf49b057b09bec860588a9b554c3a77683394722 (patch)
treefc9654fc3743f5dfbde82f6eb5729519d41f568d /util.c
parent65cec58980c279c041788ef30ee8617e63ab5229 (diff)
downloadperl-bf49b057b09bec860588a9b554c3a77683394722.tar.gz
make die/warn and other diagnostics go to wherever STDERR happens
to point at; change places that meant Perl_debug_log rather than PerlIO_stderr() p4raw-id: //depot/perl@4302
Diffstat (limited to 'util.c')
-rw-r--r--util.c122
1 files changed, 67 insertions, 55 deletions
diff --git a/util.c b/util.c
index 97401ab9df..24af6622f8 100644
--- a/util.c
+++ b/util.c
@@ -85,7 +85,7 @@ Perl_safesysmalloc(MEM_SIZE size)
Malloc_t ptr;
#ifdef HAS_64K_LIMIT
if (size > 0xffff) {
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"Allocation too large: %lx\n", size) FLUSH;
my_exit(1);
}
@@ -101,7 +101,7 @@ Perl_safesysmalloc(MEM_SIZE size)
else if (PL_nomemok)
return Nullch;
else {
- PerlIO_puts(PerlIO_stderr(),PL_no_mem) FLUSH;
+ PerlIO_puts(Perl_error_log,PL_no_mem) FLUSH;
my_exit(1);
return Nullch;
}
@@ -121,7 +121,7 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size)
#ifdef HAS_64K_LIMIT
if (size > 0xffff) {
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"Reallocation too large: %lx\n", size) FLUSH;
my_exit(1);
}
@@ -147,7 +147,7 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size)
else if (PL_nomemok)
return Nullch;
else {
- PerlIO_puts(PerlIO_stderr(),PL_no_mem) FLUSH;
+ PerlIO_puts(Perl_error_log,PL_no_mem) FLUSH;
my_exit(1);
return Nullch;
}
@@ -177,7 +177,7 @@ Perl_safesyscalloc(MEM_SIZE count, MEM_SIZE size)
#ifdef HAS_64K_LIMIT
if (size * count > 0xffff) {
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"Allocation too large: %lx\n", size * count) FLUSH;
my_exit(1);
}
@@ -196,7 +196,7 @@ Perl_safesyscalloc(MEM_SIZE count, MEM_SIZE size)
else if (PL_nomemok)
return Nullch;
else {
- PerlIO_puts(PerlIO_stderr(),PL_no_mem) FLUSH;
+ PerlIO_puts(Perl_error_log,PL_no_mem) FLUSH;
my_exit(1);
return Nullch;
}
@@ -298,7 +298,7 @@ S_xstat(pTHX_ int flag)
subtot[j] = 0;
}
- PerlIO_printf(PerlIO_stderr(), " Id subtot 4 8 12 16 20 24 28 32 36 40 48 56 64 72 80 80+\n", total);
+ PerlIO_printf(Perl_debug_log, " Id subtot 4 8 12 16 20 24 28 32 36 40 48 56 64 72 80 80+\n", total);
for (i = 0; i < MAXXCOUNT; i++) {
total += xcount[i];
for (j = 0; j < MAXYCOUNT; j++) {
@@ -309,7 +309,7 @@ S_xstat(pTHX_ int flag)
: (flag == 2
? xcount[i] != lastxcount[i] /* Changed */
: xcount[i] > lastxcount[i])) { /* Growed */
- PerlIO_printf(PerlIO_stderr(),"%2d %02d %7ld ", i / 100, i % 100,
+ PerlIO_printf(Perl_debug_log,"%2d %02d %7ld ", i / 100, i % 100,
flag == 2 ? xcount[i] - lastxcount[i] : xcount[i]);
lastxcount[i] = xcount[i];
for (j = 0; j < MAXYCOUNT; j++) {
@@ -318,28 +318,28 @@ S_xstat(pTHX_ int flag)
: (flag == 2
? xycount[i][j] != lastxycount[i][j] /* Changed */
: xycount[i][j] > lastxycount[i][j])) { /* Growed */
- PerlIO_printf(PerlIO_stderr(),"%3ld ",
+ PerlIO_printf(Perl_debug_log,"%3ld ",
flag == 2
? xycount[i][j] - lastxycount[i][j]
: xycount[i][j]);
lastxycount[i][j] = xycount[i][j];
} else {
- PerlIO_printf(PerlIO_stderr(), " . ", xycount[i][j]);
+ PerlIO_printf(Perl_debug_log, " . ", xycount[i][j]);
}
}
- PerlIO_printf(PerlIO_stderr(), "\n");
+ PerlIO_printf(Perl_debug_log, "\n");
}
}
if (flag != 2) {
- PerlIO_printf(PerlIO_stderr(), "Total %7ld ", total);
+ PerlIO_printf(Perl_debug_log, "Total %7ld ", total);
for (j = 0; j < MAXYCOUNT; j++) {
if (subtot[j]) {
- PerlIO_printf(PerlIO_stderr(), "%3ld ", subtot[j]);
+ PerlIO_printf(Perl_debug_log, "%3ld ", subtot[j]);
} else {
- PerlIO_printf(PerlIO_stderr(), " . ");
+ PerlIO_printf(Perl_debug_log, " . ");
}
}
- PerlIO_printf(PerlIO_stderr(), "\n");
+ PerlIO_printf(Perl_debug_log, "\n");
}
}
@@ -711,41 +711,41 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
if (locwarn) {
#ifdef LC_ALL
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"perl: warning: Setting locale failed.\n");
#else /* !LC_ALL */
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"perl: warning: Setting locale failed for the categories:\n\t");
#ifdef USE_LOCALE_CTYPE
if (! curctype)
- PerlIO_printf(PerlIO_stderr(), "LC_CTYPE ");
+ PerlIO_printf(Perl_error_log, "LC_CTYPE ");
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
if (! curcoll)
- PerlIO_printf(PerlIO_stderr(), "LC_COLLATE ");
+ PerlIO_printf(Perl_error_log, "LC_COLLATE ");
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
if (! curnum)
- PerlIO_printf(PerlIO_stderr(), "LC_NUMERIC ");
+ PerlIO_printf(Perl_error_log, "LC_NUMERIC ");
#endif /* USE_LOCALE_NUMERIC */
- PerlIO_printf(PerlIO_stderr(), "\n");
+ PerlIO_printf(Perl_error_log, "\n");
#endif /* LC_ALL */
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"perl: warning: Please check that your locale settings:\n");
#ifdef __GLIBC__
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"\tLANGUAGE = %c%s%c,\n",
language ? '"' : '(',
language ? language : "unset",
language ? '"' : ')');
#endif
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"\tLC_ALL = %c%s%c,\n",
lc_all ? '"' : '(',
lc_all ? lc_all : "unset",
@@ -757,18 +757,18 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
if (strnEQ(*e, "LC_", 3)
&& strnNE(*e, "LC_ALL=", 7)
&& (p = strchr(*e, '=')))
- PerlIO_printf(PerlIO_stderr(), "\t%.*s = \"%s\",\n",
+ PerlIO_printf(Perl_error_log, "\t%.*s = \"%s\",\n",
(int)(p - *e), *e, p + 1);
}
}
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"\tLANG = %c%s%c\n",
lang ? '"' : '(',
lang ? lang : "unset",
lang ? '"' : ')');
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
" are supported and installed on your system.\n");
}
@@ -776,13 +776,13 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
if (setlocale(LC_ALL, "C")) {
if (locwarn)
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"perl: warning: Falling back to the standard locale (\"C\").\n");
ok = 0;
}
else {
if (locwarn)
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"perl: warning: Failed to fall back to the standard locale (\"C\").\n");
ok = -1;
}
@@ -802,7 +802,7 @@ Perl_init_i18nl10n(pTHX_ int printwarn)
)
{
if (locwarn)
- PerlIO_printf(PerlIO_stderr(),
+ PerlIO_printf(Perl_error_log,
"perl: warning: Cannot fall back to the standard locale (\"C\").\n");
ok = -1;
}
@@ -1463,7 +1463,7 @@ Perl_vdie(pTHX_ const char* pat, va_list *args)
SV *msv;
STRLEN msglen;
- DEBUG_S(PerlIO_printf(PerlIO_stderr(),
+ DEBUG_S(PerlIO_printf(Perl_debug_log,
"%p: die: curstack = %p, mainstack = %p\n",
thr, PL_curstack, PL_mainstack));
@@ -1481,7 +1481,7 @@ Perl_vdie(pTHX_ const char* pat, va_list *args)
message = Nullch;
}
- DEBUG_S(PerlIO_printf(PerlIO_stderr(),
+ DEBUG_S(PerlIO_printf(Perl_debug_log,
"%p: die: message = %s\ndiehook = %p\n",
thr, message, PL_diehook));
if (PL_diehook) {
@@ -1521,7 +1521,7 @@ Perl_vdie(pTHX_ const char* pat, va_list *args)
}
PL_restartop = die_where(message, msglen);
- DEBUG_S(PerlIO_printf(PerlIO_stderr(),
+ DEBUG_S(PerlIO_printf(Perl_debug_log,
"%p: die: restartop = %p, was_in_eval = %d, top_env = %p\n",
thr, PL_restartop, was_in_eval, PL_top_env));
if ((!PL_restartop && was_in_eval) || PL_top_env->je_prev)
@@ -1574,7 +1574,7 @@ Perl_vcroak(pTHX_ const char* pat, va_list *args)
else
message = SvPV(msv,msglen);
- DEBUG_S(PerlIO_printf(PerlIO_stderr(), "croak: 0x%lx %s",
+ DEBUG_S(PerlIO_printf(Perl_debug_log, "croak: 0x%lx %s",
(unsigned long) thr, message));
if (PL_diehook) {
@@ -1612,8 +1612,10 @@ Perl_vcroak(pTHX_ const char* pat, va_list *args)
/* SFIO can really mess with your errno */
int e = errno;
#endif
- PerlIO_write(PerlIO_stderr(), message, msglen);
- (void)PerlIO_flush(PerlIO_stderr());
+ PerlIO *serr = Perl_error_log;
+
+ PerlIO_write(serr, message, msglen);
+ (void)PerlIO_flush(serr);
#ifdef USE_SFIO
errno = e;
#endif
@@ -1685,16 +1687,20 @@ Perl_vwarn(pTHX_ const char* pat, va_list *args)
return;
}
}
- PerlIO_write(PerlIO_stderr(), message, msglen);
+ {
+ PerlIO *serr = Perl_error_log;
+
+ PerlIO_write(serr, message, msglen);
#ifdef LEAKTEST
- DEBUG_L(*message == '!'
- ? (xstat(message[1]=='!'
- ? (message[2]=='!' ? 2 : 1)
- : 0)
- , 0)
- : 0);
+ DEBUG_L(*message == '!'
+ ? (xstat(message[1]=='!'
+ ? (message[2]=='!' ? 2 : 1)
+ : 0)
+ , 0)
+ : 0);
#endif
- (void)PerlIO_flush(PerlIO_stderr());
+ (void)PerlIO_flush(serr);
+ }
}
#if defined(PERL_IMPLICIT_CONTEXT)
@@ -1755,7 +1761,7 @@ Perl_vwarner(pTHX_ U32 err, const char* pat, va_list* args)
if (ckDEAD(err)) {
#ifdef USE_THREADS
- DEBUG_S(PerlIO_printf(PerlIO_stderr(), "croak: 0x%lx %s", (unsigned long) thr, message));
+ DEBUG_S(PerlIO_printf(Perl_debug_log, "croak: 0x%lx %s", (unsigned long) thr, message));
#endif /* USE_THREADS */
if (PL_diehook) {
/* sv_2cv might call Perl_croak() */
@@ -1786,8 +1792,11 @@ Perl_vwarner(pTHX_ U32 err, const char* pat, va_list* args)
PL_restartop = die_where(message, msglen);
JMPENV_JUMP(3);
}
- PerlIO_write(PerlIO_stderr(), message, msglen);
- (void)PerlIO_flush(PerlIO_stderr());
+ {
+ PerlIO *serr = Perl_error_log;
+ PerlIO_write(serr, message, msglen);
+ (void)PerlIO_flush(serr);
+ }
my_failure_exit();
}
@@ -1819,11 +1828,14 @@ Perl_vwarner(pTHX_ U32 err, const char* pat, va_list* args)
return;
}
}
- PerlIO_write(PerlIO_stderr(), message, msglen);
+ {
+ PerlIO *serr = Perl_error_log;
+ PerlIO_write(serr, message, msglen);
#ifdef LEAKTEST
- DEBUG_L(xstat());
+ DEBUG_L(xstat());
#endif
- (void)PerlIO_flush(PerlIO_stderr());
+ (void)PerlIO_flush(serr);
+ }
}
}
@@ -2373,12 +2385,12 @@ Perl_dump_fds(pTHX_ char *s)
int fd;
struct stat tmpstatbuf;
- PerlIO_printf(PerlIO_stderr(),"%s", s);
+ PerlIO_printf(Perl_debug_log,"%s", s);
for (fd = 0; fd < 32; fd++) {
if (PerlLIO_fstat(fd,&tmpstatbuf) >= 0)
- PerlIO_printf(PerlIO_stderr()," %d",fd);
+ PerlIO_printf(Perl_debug_log," %d",fd);
}
- PerlIO_printf(PerlIO_stderr(),"\n");
+ PerlIO_printf(Perl_debug_log,"\n");
}
#endif /* DUMP_FDS */
@@ -3342,7 +3354,7 @@ Perl_condpair_magic(pTHX_ SV *sv)
mg->mg_ptr = (char *)cp;
mg->mg_len = sizeof(cp);
MUTEX_UNLOCK(&PL_cred_mutex); /* XXX need separate mutex? */
- DEBUG_S(WITH_THR(PerlIO_printf(PerlIO_stderr(),
+ DEBUG_S(WITH_THR(PerlIO_printf(Perl_debug_log,
"%p: condpair_magic %p\n", thr, sv));)
}
}
@@ -3460,7 +3472,7 @@ Perl_new_struct_thread(pTHX_ struct perl_thread *t)
SV *sv = newSVsv(*svp);
av_store(thr->threadsv, i, sv);
sv_magic(sv, 0, 0, &PL_threadsv_names[i], 1);
- DEBUG_S(PerlIO_printf(PerlIO_stderr(),
+ DEBUG_S(PerlIO_printf(Perl_debug_log,
"new_struct_thread: copied threadsv %d %p->%p\n",i, t, thr));
}
}