X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=util.c;h=8f6845a7c41f79a463668d5e6335878f42a64dae;hb=2304df62caa7d9be70e8b8bcdb454e139c9c103d;hp=2e31e1862113db3c45b50ee439ea38ff32eb2ed1;hpb=8990e3071044a96302560bbdb5706f3e74cf1bef;p=p5sagit%2Fp5-mst-13.2.git diff --git a/util.c b/util.c index 2e31e18..8f6845a 100644 --- a/util.c +++ b/util.c @@ -59,14 +59,6 @@ # include #endif -#ifdef STANDARD_C -# include -#else -# ifdef I_VARARGS -# include -# endif -#endif - #ifdef I_FCNTL # include #endif @@ -93,7 +85,7 @@ unsigned long size; MEM_SIZE size; #endif /* MSDOS */ { - char *ptr; + char *ptr; #ifndef STANDARD_C char *malloc(); #endif /* ! STANDARD_C */ @@ -741,21 +733,25 @@ long a1, a2, a3, a4; } if (s[-1] != '\n') { - if (curcop->cop_line) { - (void)sprintf(s," at %s line %ld", - SvPVX(GvSV(curcop->cop_filegv)), (long)curcop->cop_line); - s += strlen(s); - } - if (last_in_gv && - GvIO(last_in_gv) && - IoLINES(GvIO(last_in_gv)) ) { - (void)sprintf(s,", <%s> %s %ld", - last_in_gv == argvgv ? "" : GvENAME(last_in_gv), - strEQ(rs,"\n") ? "line" : "chunk", - (long)IoLINES(GvIO(last_in_gv))); - s += strlen(s); + if (dirty) + strcpy(s, " during global destruction.\n"); + else { + if (curcop->cop_line) { + (void)sprintf(s," at %s line %ld", + SvPVX(GvSV(curcop->cop_filegv)), (long)curcop->cop_line); + s += strlen(s); + } + if (last_in_gv && + GvIO(last_in_gv) && + IoLINES(GvIO(last_in_gv)) ) { + (void)sprintf(s,", <%s> %s %ld", + last_in_gv == argvgv ? "" : GvENAME(last_in_gv), + strEQ(rs,"\n") ? "line" : "chunk", + (long)IoLINES(GvIO(last_in_gv))); + s += strlen(s); + } + (void)strcpy(s,".\n"); } - (void)strcpy(s,".\n"); if (usermess) sv_catpv(tmpstr,buf+1); } @@ -801,13 +797,13 @@ long a1, a2, a3, a4; #ifdef STANDARD_C char * -mess(char *pat, va_list args) +mess(char *pat, va_list *args) #else /*VARARGS0*/ char * mess(pat, args) char *pat; - va_list args; + va_list *args; #endif { char *s; @@ -825,31 +821,35 @@ mess(pat, args) usermess = strEQ(pat, "%s"); if (usermess) { tmpstr = sv_newmortal(); - sv_setpv(tmpstr, va_arg(args, char *)); + sv_setpv(tmpstr, va_arg(*args, char *)); *s++ = SvPVX(tmpstr)[SvCUR(tmpstr)-1]; } else { - (void) vsprintf(s,pat,args); + (void) vsprintf(s,pat,*args); s += strlen(s); } - va_end(args); + va_end(*args); if (s[-1] != '\n') { - if (curcop->cop_line) { - (void)sprintf(s," at %s line %ld", - SvPVX(GvSV(curcop->cop_filegv)), (long)curcop->cop_line); - s += strlen(s); - } - if (last_in_gv && - GvIO(last_in_gv) && - IoLINES(GvIO(last_in_gv)) ) { - (void)sprintf(s,", <%s> %s %ld", - last_in_gv == argvgv ? "" : GvNAME(last_in_gv), - strEQ(rs,"\n") ? "line" : "chunk", - (long)IoLINES(GvIO(last_in_gv))); - s += strlen(s); + if (dirty) + strcpy(s, " during global destruction.\n"); + else { + if (curcop->cop_line) { + (void)sprintf(s," at %s line %ld", + SvPVX(GvSV(curcop->cop_filegv)), (long)curcop->cop_line); + s += strlen(s); + } + if (last_in_gv && + GvIO(last_in_gv) && + IoLINES(GvIO(last_in_gv)) ) { + (void)sprintf(s,", <%s> %s %ld", + last_in_gv == argvgv ? "" : GvNAME(last_in_gv), + strEQ(rs,"\n") ? "line" : "chunk", + (long)IoLINES(GvIO(last_in_gv))); + s += strlen(s); + } + (void)strcpy(s,".\n"); } - (void)strcpy(s,".\n"); if (usermess) sv_catpv(tmpstr,buf+1); } @@ -880,7 +880,7 @@ croak(pat, va_alist) #else va_start(args); #endif - message = mess(pat, args); + message = mess(pat, &args); va_end(args); if (restartop = die_where(message)) longjmp(top_env, 3); @@ -910,7 +910,7 @@ warn(pat,va_alist) #else va_start(args); #endif - message = mess(pat, args); + message = mess(pat, &args); va_end(args); fputs(message,stderr); @@ -1283,7 +1283,7 @@ char *mode; close(fd); #endif do_exec(cmd); /* may or may not use the shell */ - warn("Can't exec \"%s\": %s", cmd, strerror(errno)); + warn("Can't exec \"%s\": %s", cmd, Strerror(errno)); _exit(1); } /*SUPPRESS 560*/