Finish constifying the new parsebackquote() function. Save a
variable or two... Should change nothing. (from kre@)
This commit is contained in:
parent
ca12a0b88a
commit
f9acd92dd8
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: parser.c,v 1.108 2016/03/27 14:34:46 christos Exp $ */
|
/* $NetBSD: parser.c,v 1.109 2016/03/27 14:35:30 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1991, 1993
|
* Copyright (c) 1991, 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
|
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: parser.c,v 1.108 2016/03/27 14:34:46 christos Exp $");
|
__RCSID("$NetBSD: parser.c,v 1.109 2016/03/27 14:35:30 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -1091,18 +1091,16 @@ parsebackq(VSS *const stack, char * const in,
|
||||||
struct nodelist **const pbqlist, const int oldstyle)
|
struct nodelist **const pbqlist, const int oldstyle)
|
||||||
{
|
{
|
||||||
struct nodelist **nlpp;
|
struct nodelist **nlpp;
|
||||||
int savepbq;
|
const int savepbq = parsebackquote;
|
||||||
union node *n;
|
union node *n;
|
||||||
char *out;
|
char *out;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
char *pout;
|
|
||||||
char *volatile sstr = str;
|
char *volatile sstr = str;
|
||||||
struct jmploc jmploc;
|
struct jmploc jmploc;
|
||||||
struct jmploc *const savehandler = handler;
|
struct jmploc *const savehandler = handler;
|
||||||
int savelen;
|
const int savelen = in - stackblock();
|
||||||
int saveprompt;
|
int saveprompt;
|
||||||
|
|
||||||
savepbq = parsebackquote;
|
|
||||||
if (setjmp(jmploc.loc)) {
|
if (setjmp(jmploc.loc)) {
|
||||||
if (sstr)
|
if (sstr)
|
||||||
ckfree(__UNVOLATILE(sstr));
|
ckfree(__UNVOLATILE(sstr));
|
||||||
|
@ -1112,9 +1110,7 @@ parsebackq(VSS *const stack, char * const in,
|
||||||
longjmp(handler->loc, 1);
|
longjmp(handler->loc, 1);
|
||||||
}
|
}
|
||||||
INTOFF;
|
INTOFF;
|
||||||
out = in;
|
|
||||||
sstr = str = NULL;
|
sstr = str = NULL;
|
||||||
savelen = out - stackblock();
|
|
||||||
if (savelen > 0) {
|
if (savelen > 0) {
|
||||||
sstr = str = ckmalloc(savelen);
|
sstr = str = ckmalloc(savelen);
|
||||||
memcpy(str, stackblock(), savelen);
|
memcpy(str, stackblock(), savelen);
|
||||||
|
@ -1134,7 +1130,7 @@ parsebackq(VSS *const stack, char * const in,
|
||||||
* need to bother the state stack. That will be used
|
* need to bother the state stack. That will be used
|
||||||
* (as appropriate) when the processed string is re-read.
|
* (as appropriate) when the processed string is re-read.
|
||||||
*/
|
*/
|
||||||
STARTSTACKSTR(pout);
|
STARTSTACKSTR(out);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (needprompt) {
|
if (needprompt) {
|
||||||
setprompt(2);
|
setprompt(2);
|
||||||
|
@ -1161,7 +1157,7 @@ parsebackq(VSS *const stack, char * const in,
|
||||||
}
|
}
|
||||||
if (pc != '\\' && pc != '`' && pc != '$'
|
if (pc != '\\' && pc != '`' && pc != '$'
|
||||||
&& (!ISDBLQUOTE() || pc != '"'))
|
&& (!ISDBLQUOTE() || pc != '"'))
|
||||||
STPUTC('\\', pout);
|
STPUTC('\\', out);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
|
@ -1177,13 +1173,13 @@ parsebackq(VSS *const stack, char * const in,
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
STPUTC(pc, pout);
|
STPUTC(pc, out);
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
STPUTC('\0', pout);
|
STPUTC('\0', out);
|
||||||
psavelen = pout - stackblock();
|
psavelen = out - stackblock();
|
||||||
if (psavelen > 0) {
|
if (psavelen > 0) {
|
||||||
pstr = grabstackstr(pout);
|
pstr = grabstackstr(out);
|
||||||
setinputstring(pstr, 1);
|
setinputstring(pstr, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1220,12 +1216,13 @@ done:
|
||||||
popfile();
|
popfile();
|
||||||
tokpushback = 0;
|
tokpushback = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (stackblocksize() <= savelen)
|
while (stackblocksize() <= savelen)
|
||||||
growstackblock();
|
growstackblock();
|
||||||
STARTSTACKSTR(pout);
|
STARTSTACKSTR(out);
|
||||||
if (str) {
|
if (str) {
|
||||||
memcpy(pout, str, savelen);
|
memcpy(out, str, savelen);
|
||||||
STADJUST(savelen, pout);
|
STADJUST(savelen, out);
|
||||||
INTOFF;
|
INTOFF;
|
||||||
ckfree(str);
|
ckfree(str);
|
||||||
sstr = str = NULL;
|
sstr = str = NULL;
|
||||||
|
@ -1234,11 +1231,11 @@ done:
|
||||||
parsebackquote = savepbq;
|
parsebackquote = savepbq;
|
||||||
handler = savehandler;
|
handler = savehandler;
|
||||||
if (arinest || ISDBLQUOTE())
|
if (arinest || ISDBLQUOTE())
|
||||||
USTPUTC(CTLBACKQ | CTLQUOTE, pout);
|
USTPUTC(CTLBACKQ | CTLQUOTE, out);
|
||||||
else
|
else
|
||||||
USTPUTC(CTLBACKQ, pout);
|
USTPUTC(CTLBACKQ, out);
|
||||||
|
|
||||||
return pout;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC int
|
STATIC int
|
||||||
|
|
Loading…
Reference in New Issue