Remove the profiling and debugging ifdefs. Most of this is for
instrumenting the expression evaluator and has been in place for
35 years. I think we're done debugging.
ok?
diff -uNrp -xCVS csh,3/Makefile csh/Makefile
--- csh,3/Makefile Mon Oct 26 17:40:17 2015
+++ csh/Makefile Mon Oct 26 21:50:37 2015
@@ -2,12 +2,8 @@
#
# C Shell with process control; VM/UNIX VAX Makefile
# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
-#
-# To profile, put -DPROF in DEFS and -pg in CFLAGS, and recompile.
PROG= csh
-#CFLAGS+=-g
-#CFLAGS+=-Wall
CFLAGS+=-I${.CURDIR} -I.
SRCS= alloc.c char.c const.c csh.c dir.c dol.c error.c exec.c exp.c file.c \
func.c glob.c hist.c init.c lex.c misc.c parse.c proc.c \
diff -uNrp -xCVS csh,3/csh.c csh/csh.c
--- csh,3/csh.c Mon Oct 26 17:40:17 2015
+++ csh/csh.c Mon Oct 26 19:07:34 2015
@@ -819,9 +819,6 @@ void
exitstat(void)
{
Char *s;
-#ifdef PROF
- monitor(0);
-#endif
/*
* Note that if STATUS is corrupted (i.e. getn bombs) then error will exit
* directly because we poke child here. Otherwise we might continue
@@ -1257,11 +1254,7 @@ initdesc(void)
void
-#ifdef PROF
-done(int i)
-#else
xexit(int i)
-#endif
{
untty();
_exit(i);
diff -uNrp -xCVS csh,3/csh.h csh/csh.h
--- csh,3/csh.h Mon Oct 26 17:40:17 2015
+++ csh/csh.h Mon Oct 26 19:07:09 2015
@@ -53,10 +53,6 @@
#define FSHERR 18 /* ... shell diagnostics */
#define FOLDSTD 19 /* ... old std input */
-#ifdef PROF
-#define xexit(n) done(n)
-#endif
-
typedef short Char;
#define SAVE(a) (Strsave(str2short(a)))
diff -uNrp -xCVS csh,3/exp.c csh/exp.c
--- csh,3/exp.c Mon Oct 26 17:40:17 2015
+++ csh/exp.c Mon Oct 26 18:50:04 2015
@@ -71,11 +71,6 @@ static void evalav(Char **);
static int isa(Char *, int);
static int egetn(Char *);
-#ifdef EDEBUG
-static void etracc(char *, Char *, Char ***);
-static void etraci(char *, int, Char ***);
-#endif
-
int
expr(Char ***vp)
{
@@ -87,17 +82,11 @@ exp0(Char ***vp, bool ignore)
{
int p1 = exp1(vp, ignore);
-#ifdef EDEBUG
- etraci("exp0 p1", p1, vp);
-#endif
if (**vp && eq(**vp, STRor2)) {
int p2;
(*vp)++;
p2 = exp0(vp, (ignore & IGNORE) || p1);
-#ifdef EDEBUG
- etraci("exp0 p2", p2, vp);
-#endif
return (p1 || p2);
}
return (p1);
@@ -108,17 +97,11 @@ exp1(Char ***vp, bool ignore)
{
int p1 = exp2_(vp, ignore);
-#ifdef EDEBUG
- etraci("exp1 p1", p1, vp);
-#endif
if (**vp && eq(**vp, STRand2)) {
int p2;
(*vp)++;
p2 = exp1(vp, (ignore & IGNORE) || !p1);
-#ifdef EDEBUG
- etraci("exp1 p2", p2, vp);
-#endif
return (p1 && p2);
}
return (p1);
@@ -129,17 +112,11 @@ exp2_(Char ***vp, bool ignore)
{
int p1 = exp2a(vp, ignore);
-#ifdef EDEBUG
- etraci("exp3 p1", p1, vp);
-#endif
if (**vp && eq(**vp, STRor)) {
int p2;
(*vp)++;
p2 = exp2_(vp, ignore);
-#ifdef EDEBUG
- etraci("exp3 p2", p2, vp);
-#endif
return (p1 | p2);
}
return (p1);
@@ -150,17 +127,11 @@ exp2a(Char ***vp, bool ignore)
{
int p1 = exp2b(vp, ignore);
-#ifdef EDEBUG
- etraci("exp2a p1", p1, vp);
-#endif
if (**vp && eq(**vp, STRcaret)) {
int p2;
(*vp)++;
p2 = exp2a(vp, ignore);
-#ifdef EDEBUG
- etraci("exp2a p2", p2, vp);
-#endif
return (p1 ^ p2);
}
return (p1);
@@ -171,17 +142,11 @@ exp2b(Char ***vp, bool ignore)
{
int p1 = exp2c(vp, ignore);
-#ifdef EDEBUG
- etraci("exp2b p1", p1, vp);
-#endif
if (**vp && eq(**vp, STRand)) {
int p2;
(*vp)++;
p2 = exp2b(vp, ignore);
-#ifdef EDEBUG
- etraci("exp2b p2", p2, vp);
-#endif
return (p1 & p2);
}
return (p1);
@@ -194,17 +159,11 @@ exp2c(Char ***vp, bool ignore)
Char *p2;
int i;
-#ifdef EDEBUG
- etracc("exp2c p1", p1, vp);
-#endif
if ((i = isa(**vp, EQOP)) != 0) {
(*vp)++;
if (i == EQMATCH || i == NOTEQMATCH)
ignore |= NOGLOB;
p2 = exp3(vp, ignore);
-#ifdef EDEBUG
- etracc("exp2c p2", p2, vp);
-#endif
if (!(ignore & IGNORE))
switch (i) {
@@ -240,17 +199,11 @@ exp3(Char ***vp, bool ignore)
int i;
p1 = exp3a(vp, ignore);
-#ifdef EDEBUG
- etracc("exp3 p1", p1, vp);
-#endif
if ((i = isa(**vp, RELOP)) != 0) {
(*vp)++;
if (**vp && eq(**vp, STRequal))
i |= 1, (*vp)++;
p2 = exp3(vp, ignore);
-#ifdef EDEBUG
- etracc("exp3 p2", p2, vp);
-#endif
if (!(ignore & IGNORE))
switch (i) {
@@ -284,16 +237,10 @@ exp3a(Char ***vp, bool ignore)
int i;
p1 = exp4(vp, ignore);
-#ifdef EDEBUG
- etracc("exp3a p1", p1, vp);
-#endif
op = **vp;
if (op && any("<>", op[0]) && op[0] == op[1]) {
(*vp)++;
p2 = exp3a(vp, ignore);
-#ifdef EDEBUG
- etracc("exp3a p2", p2, vp);
-#endif
if (op[0] == '<')
i = egetn(p1) << egetn(p2);
else
@@ -312,16 +259,10 @@ exp4(Char ***vp, bool ignore)
int i = 0;
p1 = exp5(vp, ignore);
-#ifdef EDEBUG
- etracc("exp4 p1", p1, vp);
-#endif
if (isa(**vp, ADDOP)) {
Char *op = *(*vp)++;
p2 = exp4(vp, ignore);
-#ifdef EDEBUG
- etracc("exp4 p2", p2, vp);
-#endif
if (!(ignore & IGNORE))
switch (op[0]) {
@@ -347,16 +288,10 @@ exp5(Char ***vp, bool ignore)
int i = 0, l;
p1 = exp6(vp, ignore);
-#ifdef EDEBUG
- etracc("exp5 p1", p1, vp);
-#endif
if (isa(**vp, MULOP)) {
Char *op = *(*vp)++;
p2 = exp5(vp, ignore);
-#ifdef EDEBUG
- etracc("exp5 p2", p2, vp);
-#endif
if (!(ignore & IGNORE))
switch (op[0]) {
@@ -404,9 +339,6 @@ exp6(Char ***vp, bool ignore)
if (eq(**vp, STRbang)) {
(*vp)++;
cp = exp6(vp, ignore);
-#ifdef EDEBUG
- etracc("exp6 ! cp", cp, vp);
-#endif
i = egetn(cp);
xfree(cp);
return (putn(!i));
@@ -414,9 +346,6 @@ exp6(Char ***vp, bool ignore)
if (eq(**vp, STRtilde)) {
(*vp)++;
cp = exp6(vp, ignore);
-#ifdef EDEBUG
- etracc("exp6 ~ cp", cp, vp);
-#endif
i = egetn(cp);
xfree(cp);
return (putn(~i));
@@ -424,9 +353,6 @@ exp6(Char ***vp, bool ignore)
if (eq(**vp, STRLparen)) {
(*vp)++;
ccode = exp0(vp, ignore);
-#ifdef EDEBUG
- etraci("exp6 () ccode", ccode, vp);
-#endif
if (*vp == 0 || **vp == 0 || ***vp != ')')
stderror(ERR_NAME | ERR_EXPRESSION);
(*vp)++;
@@ -461,9 +387,6 @@ exp6(Char ***vp, bool ignore)
}
pwait();
prestjob();
-#ifdef EDEBUG
- etraci("exp6 {} status", egetn(value(STRstatus)), vp);
-#endif
return (putn(egetn(value(STRstatus)) == 0));
}
if (isa(**vp, ANYOP))
@@ -543,15 +466,9 @@ exp6(Char ***vp, bool ignore)
break;
}
}
-#ifdef EDEBUG
- etraci("exp6 -? i", i, vp);
-#endif
xfree(ep);
return (putn(i));
}
-#ifdef EDEBUG
- etracc("exp6 default", cp, vp);
-#endif
return (ignore & NOGLOB ? Strsave(cp) : globone(cp, G_ERROR));
}
@@ -640,20 +557,3 @@ egetn(Char *cp)
}
/* Phew! */
-
-#ifdef EDEBUG
-static void
-etraci(char *str, int i, Char ***vp)
-{
- (void) fprintf(csherr, "%s=%d\t", str, i);
- blkpr(csherr, *vp);
- (void) fprintf(csherr, "\n");
-}
-static void
-etracc(char *str, Char *cp, Char ***vp)
-{
- (void) fprintf(csherr, "%s=%s\t", str, vis_str(cp));
- blkpr(csherr, *vp);
- (void) fprintf(csherr, "\n");
-}
-#endif
diff -uNrp -xCVS csh,3/extern.h csh/extern.h
--- csh,3/extern.h Mon Oct 26 17:40:17 2015
+++ csh/extern.h Mon Oct 26 19:06:49 2015
@@ -48,12 +48,7 @@ void process(bool);
void rechist(void);
void untty(void);
int vis_fputc(int, FILE *);
-
-#ifdef PROF
-void done(int);
-#else
-void xexit(int);
-#endif
+void xexit(int);
/*
* dir.c
diff -uNrp -xCVS csh,3/proc.c csh/proc.c
--- csh,3/proc.c Mon Oct 26 17:40:17 2015
+++ csh/proc.c Mon Oct 26 18:42:27 2015
@@ -276,10 +276,6 @@ pjwait(struct process *pp)
while ((fp = (fp->p_friends)) != pp);
if ((jobflags & PRUNNING) == 0)
break;
-#ifdef JOBDEBUG
- (void) fprintf(csherr, "starting to sigsuspend for SIGCHLD on %d\n",
- fp->p_pid);
-#endif /* JOBDEBUG */
sigset = osigset;
sigdelset(&sigset, SIGCHLD);
sigsuspend(&sigset);
--
Christian "naddy" Weisgerber [email protected]