-/* $RCSfile: toke.c,v $$Revision: 4.0.1.3 $$Date: 91/06/10 01:32:26 $
+/* $RCSfile: toke.c,v $$Revision: 4.0.1.4 $$Date: 91/11/05 19:02:48 $
*
* Copyright (c) 1991, Larry Wall
*
* License or the Artistic License, as specified in the README file.
*
* $Log: toke.c,v $
+ * Revision 4.0.1.4 91/11/05 19:02:48 lwall
+ * patch11: \x and \c were subject to double interpretation in regexps
+ * patch11: prepared for ctype implementations that don't define isascii()
+ * patch11: nested list operators could miscount parens
+ * patch11: once-thru blocks didn't display right in the debugger
+ * patch11: sort eval "whatever" didn't work
+ * patch11: underscore is now allowed within literal octal and hex numbers
+ *
* Revision 4.0.1.3 91/06/10 01:32:26 lwall
* patch10: m'$foo' now treats string as single quoted
* patch10: certain pattern optimizations were botched
/* which backslash sequences to keep in m// or s// */
-static char *patleave = "\\.^$@dDwWsSbB+*?|()-nrtf0123456789[{]}";
+static char *patleave = "\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}";
char *reparse; /* if non-null, scanident found ${foo[$bar]} */
* paren came before the listop rather than after.
*/
#define LOP(f) return(CLINE, *s == '(' || (s = skipspace(s), *s == '(') ? \
- (*s = META('('), bufptr = oldbufptr, '(') : \
+ (*s = (char) META('('), bufptr = oldbufptr, '(') : \
(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)LISTOP))
/* grandfather return to old style */
#define OLDLOP(f) return(yylval.ival=f,expectterm = TRUE,bufptr = s,(int)LISTOP)
skipspace(s)
register char *s;
{
- while (s < bufend && isascii(*s) && isspace(*s))
+ while (s < bufend && isSPACE(*s))
s++;
return s;
}
#endif
#ifdef BADSWITCH
if (*s & 128) {
- if ((*s & 127) == '(')
+ if ((*s & 127) == '(') {
*s++ = '(';
+ oldbufptr = s;
+ }
else
warn("Unrecognized character \\%03o ignored", *s++ & 255);
goto retry;
#endif
switch (*s) {
default:
- if ((*s & 127) == '(')
+ if ((*s & 127) == '(') {
*s++ = '(';
+ oldbufptr = s;
+ }
else
warn("Unrecognized character \\%03o ignored", *s++ & 255);
goto retry;
if (rsfp) {
if (preprocess)
(void)mypclose(rsfp);
- else if (rsfp == stdin)
+ else if ((FILE*)rsfp == stdin)
clearerr(stdin);
else
(void)fclose(rsfp);
if (*s == ' ')
s++;
cmd = s;
- while (s < bufend && !isspace(*s))
+ while (s < bufend && !isSPACE(*s))
s++;
*s++ = '\0';
- while (s < bufend && isspace(*s))
+ while (s < bufend && isSPACE(*s))
s++;
if (s < bufend) {
Newz(899,newargv,origargc+3,char*);
newargv[1] = s;
- while (s < bufend && !isspace(*s))
+ while (s < bufend && !isSPACE(*s))
s++;
*s = '\0';
Copy(origargv+1, newargv+2, origargc+1, char*);
}
}
else {
- while (s < bufend && isspace(*s))
+ while (s < bufend && isSPACE(*s))
s++;
if (*s == ':') /* for csh's that have to exec sh scripts */
s++;
goto retry;
case '#':
if (preprocess && s == str_get(linestr) &&
- s[1] == ' ' && isdigit(s[2])) {
- curcmd->c_line = atoi(s+2)-1;
- for (s += 2; isdigit(*s); s++) ;
+ s[1] == ' ' && (isDIGIT(s[2]) || strnEQ(s+2,"line ",5)) ) {
+ while (*s && !isDIGIT(*s))
+ s++;
+ curcmd->c_line = atoi(s)-1;
+ while (isDIGIT(*s))
+ s++;
d = bufend;
- while (s < d && isspace(*s)) s++;
+ while (s < d && isSPACE(*s)) s++;
s[strlen(s)-1] = '\0'; /* wipe out newline */
if (*s == '"') {
s++;
}
goto retry;
case '-':
- if (s[1] && isalpha(s[1]) && !isalpha(s[2])) {
+ if (s[1] && isALPHA(s[1]) && !isALPHA(s[2])) {
s++;
switch (*s++) {
case 'r': FTST(O_FTEREAD);
OPERATOR(tmp);
case '{':
tmp = *s++;
- if (isspace(*s) || *s == '#')
+ yylval.ival = curcmd->c_line;
+ if (isSPACE(*s) || *s == '#')
cmdline = NOLINE; /* invalidate current command line number */
OPERATOR(tmp);
case ';':
s--;
if (expectterm) {
d = bufend;
- while (s < d && isspace(*s))
+ while (s < d && isSPACE(*s))
s++;
- if (isalpha(*s) || *s == '_' || *s == '\'')
+ if (isALPHA(*s) || *s == '_' || *s == '\'')
*(--s) = '\\'; /* force next ident to WORD */
OPERATOR(AMPER);
}
#define SNARFWORD \
d = tokenbuf; \
- while (isascii(*s) && \
- (isalpha(*s) || isdigit(*s) || *s == '_' || *s == '\'')) \
+ while (isALNUM(*s) || *s == '\'') \
*d++ = *s++; \
while (d[-1] == '\'') \
d--,s--; \
d = tokenbuf;
case '$':
- if (s[1] == '#' && (isalpha(s[2]) || s[2] == '_')) {
+ if (s[1] == '#' && (isALPHA(s[2]) || s[2] == '_')) {
s++;
s = scanident(s,bufend,tokenbuf);
yylval.stabval = aadd(stabent(tokenbuf,TRUE));
OPERATOR(tmp);
case '.':
- if (!expectterm || !isdigit(s[1])) {
+ if (!expectterm || !isDIGIT(s[1])) {
tmp = *s++;
if (*s == tmp) {
s++;
STAB *stab;
int fd;
+ /*SUPPRESS 560*/
if (stab = stabent("DATA",FALSE)) {
stab->str_pok |= SP_MULTI;
stab_io(stab) = stio_new();
#endif
if (preprocess)
stab_io(stab)->type = '|';
- else if (rsfp == stdin)
+ else if ((FILE*)rsfp == stdin)
stab_io(stab)->type = '-';
else
stab_io(stab)->type = '<';
UNI(O_CALLER);
if (strEQ(d,"crypt")) {
#ifdef FCRYPT
- init_des();
+ static int cryptseen = 0;
+
+ if (!cryptseen++)
+ init_des();
#endif
FUN2(O_CRYPT);
}
SNARFWORD;
if (strEQ(d,"do")) {
d = bufend;
- while (s < d && isspace(*s))
+ while (s < d && isSPACE(*s))
s++;
- if (isalpha(*s) || *s == '_')
+ if (isALPHA(*s) || *s == '_')
*(--s) = '\\'; /* force next ident to WORD */
OPERATOR(DO);
}
}
if (strEQ(d,"format")) {
d = bufend;
- while (s < d && isspace(*s))
+ while (s < d && isSPACE(*s))
s++;
- if (isalpha(*s) || *s == '_')
+ if (isALPHA(*s) || *s == '_')
*(--s) = '\\'; /* force next ident to WORD */
in_format = TRUE;
allstabs = TRUE; /* must initialize everything since */
if (strEQ(d,"sort")) {
checkcomma(s,"subroutine name");
d = bufend;
- while (s < d && isascii(*s) && isspace(*s)) s++;
+ while (s < d && isSPACE(*s)) s++;
if (*s == ';' || *s == ')') /* probably a close */
fatal("sort is now a reserved word");
- if (isascii(*s) && (isalpha(*s) || *s == '_')) {
- for (d = s; isalpha(*d) || isdigit(*d) || *d == '_'; d++) ;
+ if (isALPHA(*s) || *s == '_') {
+ /*SUPPRESS 530*/
+ for (d = s; isALNUM(*d); d++) ;
strncpy(tokenbuf,s,d-s);
if (strNE(tokenbuf,"keys") &&
strNE(tokenbuf,"values") &&
strNE(tokenbuf,"readdir") &&
strNE(tokenbuf,"unpack") &&
strNE(tokenbuf,"do") &&
- (d >= bufend || isspace(*d)) )
+ strNE(tokenbuf,"eval") &&
+ (d >= bufend || isSPACE(*d)) )
*(--s) = '\\'; /* force next ident to WORD */
}
LOP(O_SORT);
if (strEQ(d,"substr"))
FUN2x(O_SUBSTR);
if (strEQ(d,"sub")) {
+ yylval.ival = savestack->ary_fill; /* restore stuff on reduce */
+ if (perldb) {
+ savelong(&subline);
+ saveitem(subname);
+ }
+
subline = curcmd->c_line;
d = bufend;
- while (s < d && isspace(*s))
+ while (s < d && isSPACE(*s))
s++;
- if (isalpha(*s) || *s == '_' || *s == '\'') {
+ if (isALPHA(*s) || *s == '_' || *s == '\'') {
if (perldb) {
str_sset(subname,curstname);
str_ncat(subname,"'",1);
- for (d = s+1;
- isalpha(*d) || isdigit(*d) || *d == '_' || *d == '\'';
- d++);
+ for (d = s+1; isALNUM(*d) || *d == '\''; d++)
+ /*SUPPRESS 530*/
+ ;
if (d[-1] == '\'')
d--;
str_ncat(subname,s,d-s);
yylval.cval = savestr(d);
expectterm = FALSE;
if (oldoldbufptr && oldoldbufptr < bufptr) {
- while (isspace(*oldoldbufptr))
+ while (isSPACE(*oldoldbufptr))
oldoldbufptr++;
if (*oldoldbufptr == 'p' && strnEQ(oldoldbufptr,"print",5))
expectterm = TRUE;
if (*s == '(')
s++;
- while (s < bufend && isascii(*s) && isspace(*s))
+ while (s < bufend && isSPACE(*s))
s++;
- if (isascii(*s) && (isalpha(*s) || *s == '_')) {
+ if (isALPHA(*s) || *s == '_') {
someword = s++;
- while (isalpha(*s) || isdigit(*s) || *s == '_')
+ while (isALNUM(*s))
s++;
- while (s < bufend && isspace(*s))
+ while (s < bufend && isSPACE(*s))
s++;
if (*s == ',') {
*s = '\0';
reparse = Nullch;
s++;
d = dest;
- if (isdigit(*s)) {
- while (isdigit(*s))
+ if (isDIGIT(*s)) {
+ while (isDIGIT(*s))
*d++ = *s++;
}
else {
- while (isalpha(*s) || isdigit(*s) || *s == '_' || *s == '\'')
+ while (isALNUM(*s) || *s == '\'')
*d++ = *s++;
}
while (d > dest+1 && d[-1] == '\'')
d = dest;
brackets++;
while (s < send && brackets) {
- if (!reparse && (d == dest || (*s && isascii(*s) &&
- (isalpha(*s) || isdigit(*s) || *s == '_') ))) {
+ if (!reparse && (d == dest || (*s && isALNUM(*s) ))) {
*d++ = *s++;
continue;
}
else
d[1] = '\0';
}
- if (*d == '^' && (isupper(*s) || index("[\\]^_?",*s)))
+ if (*d == '^' && (isUPPER(*s) || index("[\\]^_?", *s))) {
+#ifdef DEBUGGING
+ if (*s == 'D')
+ debug |= 32768;
+#endif
*d = *s++ ^ 64;
+ }
return s;
}
-STR *
+void
scanconst(spat,string,len)
SPAT *spat;
char *string;
int len;
{
- register STR *retstr;
+ register STR *tmpstr;
register char *t;
register char *d;
register char *e;
static char *vert = "|";
if (ninstr(string, string+len, vert, vert+1))
- return Nullstr;
+ return;
if (*string == '^')
string++, len--;
- retstr = Str_new(86,len);
- str_nset(retstr,string,len);
- t = str_get(retstr);
+ tmpstr = Str_new(86,len);
+ str_nset(tmpstr,string,len);
+ t = str_get(tmpstr);
e = t + len;
- retstr->str_u.str_useful = 100;
+ tmpstr->str_u.str_useful = 100;
for (d=t; d < e; ) {
switch (*d) {
case '{':
- if (isdigit(d[1]))
+ if (isDIGIT(d[1]))
e = d;
else
goto defchar;
break;
case '.': case '[': case '$': case '(': case ')': case '|': case '+':
+ case '^':
e = d;
break;
case '\\':
- if (d[1] && index("wWbB0123456789sSdDlLuUE",d[1])) {
+ if (d[1] && index("wWbB0123456789sSdDlLuUExc",d[1])) {
e = d;
break;
}
}
}
if (d == t) {
- str_free(retstr);
- return Nullstr;
+ str_free(tmpstr);
+ return;
}
*d = '\0';
- retstr->str_cur = d - t;
+ tmpstr->str_cur = d - t;
if (d == t+len)
spat->spat_flags |= SPAT_ALL;
if (*origstring != '^')
spat->spat_flags |= SPAT_SCANFIRST;
- spat->spat_short = retstr;
+ spat->spat_short = tmpstr;
spat->spat_slen = d - t;
- return retstr;
}
char *
arg->arg_type = O_ITEM;
arg[1].arg_type = A_DOUBLE;
arg[1].arg_ptr.arg_str = str_smake(str);
- d = scanident(d,bufend,buf);
+ d = scanident(d,e,buf);
(void)stabent(buf,TRUE); /* make sure it's created */
for (; *d; d++) {
if (*d == '$' && d[1] && d[-1] != '\\' && d[1] != '|') {
- d = scanident(d,bufend,buf);
+ d = scanident(d,e,buf);
(void)stabent(buf,TRUE);
}
else if (*d == '@' && d[-1] != '\\') {
- d = scanident(d,bufend,buf);
+ d = scanident(d,e,buf);
if (strEQ(buf,"ARGV") || strEQ(buf,"ENV") ||
strEQ(buf,"SIG") || strEQ(buf,"INC"))
(void)stabent(buf,TRUE);
e = tmpstr->str_ptr + tmpstr->str_cur;
for (t = tmpstr->str_ptr; t < e; t++) {
if (*t == '$' && t[1] && (index("`'&+0123456789",t[1]) ||
- (t[1] == '{' /*}*/ && isdigit(t[2])) ))
+ (t[1] == '{' /*}*/ && isDIGIT(t[2])) ))
spat->spat_flags &= ~SPAT_CONST;
}
}
s++;
if ((spat->spat_repl[1].arg_type & A_MASK) == A_DOUBLE)
spat->spat_repl[1].arg_type = A_SINGLE;
- spat->spat_repl = make_op(O_EVAL,2,
+ spat->spat_repl = make_op(
+ (spat->spat_repl[1].arg_type == A_SINGLE ? O_EVALONCE : O_EVAL),
+ 2,
spat->spat_repl,
Nullarg,
Nullarg);
switch (*s) {
default:
goto out;
+ case '_':
+ s++;
+ break;
case '8': case '9':
if (shift != 4)
yyerror("Illegal octal digit");
decimal:
arg[1].arg_type = A_SINGLE;
d = tokenbuf;
- while (isdigit(*s) || *s == '_') {
+ while (isDIGIT(*s) || *s == '_') {
if (*s == '_')
s++;
else
}
if (*s == '.' && s[1] && index("0123456789eE ;",s[1])) {
*d++ = *s++;
- while (isdigit(*s) || *s == '_') {
+ while (isDIGIT(*s) || *s == '_') {
if (*s == '_')
s++;
else
*d++ = *s++;
if (*s == '+' || *s == '-')
*d++ = *s++;
- while (isdigit(*s))
+ while (isDIGIT(*s))
*d++ = *s++;
}
*d = '\0';
s++, term = '\'';
else
term = '"';
- while (isascii(*s) && (isalpha(*s) || isdigit(*s) || *s == '_'))
+ while (isALNUM(*s))
*d++ = *s++;
} /* assuming tokenbuf won't clobber */
*d++ = '\n';
if (s < bufend)
s++;
if (*d == '$') d++;
- while (*d &&
- (isalpha(*d) || isdigit(*d) || *d == '_' || *d == '\''))
+ while (*d && (isALNUM(*d) || *d == '\''))
d++;
if (d - tokenbuf != len) {
d = tokenbuf;
s = tmpstr->str_ptr;
send = s + tmpstr->str_cur;
while (s < send) { /* see if we can make SINGLE */
- if (*s == '\\' && s[1] && isdigit(s[1]) && !isdigit(s[2]) &&
+ if (*s == '\\' && s[1] && isDIGIT(s[1]) && !isDIGIT(s[2]) &&
!alwaysdollar && s[1] != '0')
*s = '$'; /* grandfather \digit in subst */
if ((*s == '$' || *s == '@') && s+1 < send &&
if ((*s == '$' && s+1 < send &&
(alwaysdollar || /*(*/ (s[1] != ')' && s[1] != '|')) ) ||
(*s == '@' && s+1 < send) ) {
+ if (s[1] == '#' && (isALPHA(s[2]) || s[2] == '_'))
+ *d++ = *s++;
len = scanident(s,send,tokenbuf) - s;
if (*s == '$' || strEQ(tokenbuf,"ARGV")
|| strEQ(tokenbuf,"ENV")
case 'c':
s++;
*d = *s++;
- if (islower(*d))
+ if (isLOWER(*d))
*d = toupper(*d);
*d++ ^= 64;
continue;
astore(stab_xarray(curcmd->c_filestab), (int)curcmd->c_line,tmpstr);
}
if (*s == '.') {
+ /*SUPPRESS 530*/
for (t = s+1; *t == ' ' || *t == '\t'; t++) ;
if (*t == '\n') {
bufptr = s;
}
else {
eol[-1] = '\n';
- while (s < eol && isspace(*s))
+ while (s < eol && isSPACE(*s))
s++;
t = s;
while (s < eol) {
case ' ': case '\t': case '\n': case ';':
str_ncat(str, t, s - t);
str_ncat(str, "," ,1);
- while (s < eol && (isspace(*s) || *s == ';'))
+ while (s < eol && (isSPACE(*s) || *s == ';'))
s++;
t = s;
break;
-/* $RCSfile: util.c,v $$Revision: 4.0.1.2 $$Date: 91/06/07 12:10:42 $
+/* $RCSfile: util.c,v $$Revision: 4.0.1.3 $$Date: 91/11/05 19:18:26 $
*
* Copyright (c) 1991, Larry Wall
*
* License or the Artistic License, as specified in the README file.
*
* $Log: util.c,v $
+ * Revision 4.0.1.3 91/11/05 19:18:26 lwall
+ * patch11: safe malloc code now integrated into Perl's malloc when possible
+ * patch11: index("little", "longer string") could visit faraway places
+ * patch11: warn '-' x 10000 dumped core
+ * patch11: forked exec on non-existent program now issues a warning
+ *
* Revision 4.0.1.2 91/06/07 12:10:42 lwall
* patch4: new copyright notice
* patch4: made some allowances for "semi-standard" C
* 4.0 baseline.
*
*/
+/*SUPPRESS 112*/
#include "EXTERN.h"
#include "perl.h"
#define FLUSH
+#ifndef safemalloc
+
static char nomem[] = "Out of memory!\n";
/* paranoid version of malloc */
# endif
#endif
if (where) {
+ /*SUPPRESS 701*/
free(where);
}
}
+#endif /* !safemalloc */
+
#ifdef LEAKTEST
#define ALIGN sizeof(long)
register int i;
for (i = 0; i < MAXXCOUNT; i++) {
- if (xcount[i] != lastxcount[i]) {
+ if (xcount[i] > lastxcount[i]) {
fprintf(stderr,"%2d %2d\t%ld\n", i / 100, i % 100, xcount[i]);
lastxcount[i] = xcount[i];
}
if (!first && little > littleend)
return big;
+ if (bigend - big < littleend - little)
+ return Nullch;
bigend -= littleend - little++;
while (big <= bigend) {
if (*big++ != first)
{
register unsigned char *s;
register unsigned char *table;
- register int i;
- register int len = str->str_cur;
+ register unsigned int i;
+ register unsigned int len = str->str_cur;
int rarest = 0;
unsigned int frequency = 256;
if (littlestr->str_pok & SP_CASEFOLD) { /* case insensitive? */
if (s < bigend) {
top1:
+ /*SUPPRESS 560*/
if (tmp = table[*s]) {
#ifdef POINTERRIGOR
if (bigend - s > tmp) {
else {
if (s < bigend) {
top2:
+ /*SUPPRESS 560*/
if (tmp = table[*s]) {
#ifdef POINTERRIGOR
if (bigend - s > tmp) {
big = Null(unsigned char*);
#endif
bigend = big + bigstr->str_cur;
- big -= previous;
while (pos < previous) {
#ifndef lint
if (!(pos += screamnext[pos]))
#endif
return Nullch;
}
+#ifdef POINTERRIGOR
if (littlestr->str_pok & SP_CASEFOLD) { /* case insignificant? */
do {
- if (big[pos] != first && big[pos] != fold[first])
- continue;
+#ifndef lint
+ while (big[pos-previous] != first && big[pos-previous] != fold[first]
+ && (pos += screamnext[pos]) )
+ /*SUPPRESS 530*/
+ ;
+#endif
+ for (x=big+pos+1-previous,s=little; s < littleend; /**/ ) {
+ if (x >= bigend)
+ return Nullch;
+ if (*s++ != *x++ && fold[*(s-1)] != *(x-1)) {
+ s--;
+ break;
+ }
+ }
+ if (s == littleend)
+#ifndef lint
+ return (char *)(big+pos-previous);
+#else
+ return Nullch;
+#endif
+ } while (
+#ifndef lint
+ pos += screamnext[pos] /* does this goof up anywhere? */
+#else
+ pos += screamnext[0]
+#endif
+ );
+ }
+ else {
+ do {
+#ifndef lint
+ while (big[pos-previous] != first && (pos += screamnext[pos]))
+ /*SUPPRESS 530*/
+ ;
+#endif
+ for (x=big+pos+1-previous,s=little; s < littleend; /**/ ) {
+ if (x >= bigend)
+ return Nullch;
+ if (*s++ != *x++) {
+ s--;
+ break;
+ }
+ }
+ if (s == littleend)
+#ifndef lint
+ return (char *)(big+pos-previous);
+#else
+ return Nullch;
+#endif
+ } while (
+#ifndef lint
+ pos += screamnext[pos]
+#else
+ pos += screamnext[0]
+#endif
+ );
+ }
+#else /* !POINTERRIGOR */
+ big -= previous;
+ if (littlestr->str_pok & SP_CASEFOLD) { /* case insignificant? */
+ do {
+#ifndef lint
+ while (big[pos] != first && big[pos] != fold[first]
+ && (pos += screamnext[pos]) )
+ /*SUPPRESS 530*/
+ ;
+#endif
for (x=big+pos+1,s=little; s < littleend; /**/ ) {
if (x >= bigend)
return Nullch;
}
else {
do {
- if (big[pos] != first)
- continue;
+#ifndef lint
+ while (big[pos] != first && (pos += screamnext[pos]))
+ /*SUPPRESS 530*/
+ ;
+#endif
for (x=big+pos+1,s=little; s < littleend; /**/ ) {
if (x >= bigend)
return Nullch;
#endif
);
}
+#endif /* POINTERRIGOR */
return Nullch;
}
long a1, a2, a3, a4;
{
char *s;
+ int usermess = strEQ(pat,"%s");
+ STR *tmpstr;
s = buf;
- (void)sprintf(s,pat,a1,a2,a3,a4);
- s += strlen(s);
+ if (usermess) {
+ tmpstr = str_mortal(&str_undef);
+ str_set(tmpstr, (char*)a1);
+ *s++ = tmpstr->str_ptr[tmpstr->str_cur-1];
+ }
+ else {
+ (void)sprintf(s,pat,a1,a2,a3,a4);
+ s += strlen(s);
+ }
+
if (s[-1] != '\n') {
if (curcmd->c_line) {
(void)sprintf(s," at %s line %ld",
s += strlen(s);
}
(void)strcpy(s,".\n");
+ if (usermess)
+ str_cat(tmpstr,buf+1);
}
+ if (usermess)
+ return tmpstr->str_ptr;
+ else
+ return buf;
}
/*VARARGS1*/
extern FILE *e_fp;
extern char *e_tmpname;
char *tmps;
+ char *message;
- mess(pat,a1,a2,a3,a4);
+ message = mess(pat,a1,a2,a3,a4);
if (in_eval) {
- str_set(stab_val(stabent("@",TRUE)),buf);
+ str_set(stab_val(stabent("@",TRUE)),message);
tmps = "_EVAL_";
while (loop_ptr >= 0 && (!loop_stack[loop_ptr].loop_label ||
strNE(tmps,loop_stack[loop_ptr].loop_label) )) {
}
longjmp(loop_stack[loop_ptr].loop_env, 1);
}
- fputs(buf,stderr);
+ fputs(message,stderr);
(void)fflush(stderr);
if (e_fp)
(void)UNLINK(e_tmpname);
char *pat;
long a1, a2, a3, a4;
{
- mess(pat,a1,a2,a3,a4);
- fputs(buf,stderr);
+ char *message;
+
+ message = mess(pat,a1,a2,a3,a4);
+ fputs(message,stderr);
#ifdef LEAKTEST
#ifdef DEBUGGING
if (debug & 4096)
}
#else
/*VARARGS0*/
+char *
mess(args)
va_list args;
{
char *pat;
char *s;
+ STR *tmpstr;
+ int usermess;
#ifndef HAS_VPRINTF
#ifdef CHARVSPRINTF
char *vsprintf();
#endif
#endif
- s = buf;
#ifdef lint
pat = Nullch;
#else
pat = va_arg(args, char *);
#endif
- (void) vsprintf(s,pat,args);
+ s = buf;
+ usermess = strEQ(pat, "%s");
+ if (usermess) {
+ tmpstr = str_mortal(&str_undef);
+ str_set(tmpstr, va_arg(args, char *));
+ *s++ = tmpstr->str_ptr[tmpstr->str_cur-1];
+ }
+ else {
+ (void) vsprintf(s,pat,args);
+ s += strlen(s);
+ }
- s += strlen(s);
if (s[-1] != '\n') {
if (curcmd->c_line) {
(void)sprintf(s," at %s line %ld",
s += strlen(s);
}
(void)strcpy(s,".\n");
+ if (usermess)
+ str_cat(tmpstr,buf+1);
}
+
+ if (usermess)
+ return tmpstr->str_ptr;
+ else
+ return buf;
}
/*VARARGS0*/
extern FILE *e_fp;
extern char *e_tmpname;
char *tmps;
+ char *message;
#ifndef lint
va_start(args);
#else
args = 0;
#endif
- mess(args);
+ message = mess(args);
va_end(args);
if (in_eval) {
- str_set(stab_val(stabent("@",TRUE)),buf);
+ str_set(stab_val(stabent("@",TRUE)),message);
tmps = "_EVAL_";
while (loop_ptr >= 0 && (!loop_stack[loop_ptr].loop_label ||
strNE(tmps,loop_stack[loop_ptr].loop_label) )) {
}
longjmp(loop_stack[loop_ptr].loop_env, 1);
}
- fputs(buf,stderr);
+ fputs(message,stderr);
(void)fflush(stderr);
if (e_fp)
(void)UNLINK(e_tmpname);
va_dcl
{
va_list args;
+ char *message;
#ifndef lint
va_start(args);
#else
args = 0;
#endif
- mess(args);
+ message = mess(args);
va_end(args);
- fputs(buf,stderr);
+ fputs(message,stderr);
#ifdef LEAKTEST
#ifdef DEBUGGING
if (debug & 4096)
int max;
char **tmpenv;
+ /*SUPPRESS 530*/
for (max = i; environ[max]; max++) ;
New(901,tmpenv, max+2, char*);
for (j=0; j<max; j++) /* copy environment */
close(fd);
#endif
do_exec(cmd); /* may or may not use the shell */
+ warn("Can't exec \"%s\": %s", cmd, strerror(errno));
_exit(1);
}
+ /*SUPPRESS 560*/
if (tmpstab = stabent("$",allstabs))
str_numset(STAB_STR(tmpstab),(double)getpid());
forkprocess = 0;
int pid;
str = afetch(fdpid,fileno(ptr),TRUE);
+ pid = (int)str->str_u.str_useful;
astore(fdpid,fileno(ptr),Nullstr);
fclose(ptr);
- pid = (int)str->str_u.str_useful;
hstat = signal(SIGHUP, SIG_IGN);
istat = signal(SIGINT, SIG_IGN);
qstat = signal(SIGQUIT, SIG_IGN);
int *statusp;
int flags;
{
+#if !defined(HAS_WAIT4) && !defined(HAS_WAITPID)
int result;
STR *str;
char spid[16];
+#endif
if (!pid)
return -1;
#endif
}
+/*SUPPRESS 590*/
pidgone(pid,status)
int pid;
int status;