DEBUG mode only change (ie: no effect to any normal shell).
Add tracing of pattern matching (aid in debugging various issues.)
This commit is contained in:
parent
e442a1a054
commit
bcacfd9a45
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: expand.c,v 1.124 2018/07/20 22:47:26 kre Exp $ */
|
||||
/* $NetBSD: expand.c,v 1.125 2018/07/22 20:38:06 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: expand.c,v 1.124 2018/07/20 22:47:26 kre Exp $");
|
||||
__RCSID("$NetBSD: expand.c,v 1.125 2018/07/22 20:38:06 kre Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -1457,6 +1457,7 @@ expmeta(char *enddir, char *name)
|
|||
int atend;
|
||||
int matchdot;
|
||||
|
||||
CTRACE(DBG_EXPAND|DBG_MATCH, ("expmeta(\"%s\")\n", name));
|
||||
metaflag = 0;
|
||||
start = name;
|
||||
for (p = name ; ; p++) {
|
||||
|
@ -1697,6 +1698,8 @@ patmatch(const char *pattern, const char *string, int squoted)
|
|||
char c;
|
||||
wchar_t wc, wc2;
|
||||
|
||||
VTRACE(DBG_MATCH, ("patmatch(P=\"%s\", W=\"%s\"%s): ",
|
||||
pattern, string, squoted ? ", SQ" : ""));
|
||||
p = pattern;
|
||||
q = string;
|
||||
bt_p = NULL;
|
||||
|
@ -1706,6 +1709,7 @@ patmatch(const char *pattern, const char *string, int squoted)
|
|||
case '\0':
|
||||
if (*q != '\0')
|
||||
goto backtrack;
|
||||
VTRACE(DBG_MATCH, ("match\n"));
|
||||
return 1;
|
||||
case CTLESC:
|
||||
if (squoted && *q == CTLESC)
|
||||
|
@ -1719,8 +1723,10 @@ patmatch(const char *pattern, const char *string, int squoted)
|
|||
case '?':
|
||||
if (squoted && *q == CTLESC)
|
||||
q++;
|
||||
if (*q++ == '\0')
|
||||
if (*q++ == '\0') {
|
||||
VTRACE(DBG_MATCH, ("?fail\n"));
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
c = *p;
|
||||
|
@ -1732,8 +1738,10 @@ patmatch(const char *pattern, const char *string, int squoted)
|
|||
if (squoted && *q == CTLESC &&
|
||||
q[1] == c)
|
||||
break;
|
||||
if (*q == '\0')
|
||||
if (*q == '\0') {
|
||||
VTRACE(DBG_MATCH, ("*fail\n"));
|
||||
return 0;
|
||||
}
|
||||
if (squoted && *q == CTLESC)
|
||||
q++;
|
||||
q++;
|
||||
|
@ -1786,8 +1794,10 @@ patmatch(const char *pattern, const char *string, int squoted)
|
|||
p++;
|
||||
}
|
||||
found = 0;
|
||||
if (*q == '\0')
|
||||
if (*q == '\0') {
|
||||
VTRACE(DBG_MATCH, ("[]fail\n"));
|
||||
return 0;
|
||||
}
|
||||
chr = (unsigned char)*q++;
|
||||
c = *p++;
|
||||
do {
|
||||
|
@ -1837,10 +1847,14 @@ backtrack:
|
|||
* of the string), go back to the last '*' seen and
|
||||
* have it match one additional character.
|
||||
*/
|
||||
if (bt_p == NULL)
|
||||
if (bt_p == NULL) {
|
||||
VTRACE(DBG_MATCH, ("BTP fail\n"));
|
||||
return 0;
|
||||
if (*bt_q == '\0')
|
||||
}
|
||||
if (*bt_q == '\0') {
|
||||
VTRACE(DBG_MATCH, ("BTQ fail\n"));
|
||||
return 0;
|
||||
}
|
||||
bt_q++;
|
||||
p = bt_p;
|
||||
q = bt_q;
|
||||
|
@ -1953,6 +1967,8 @@ casematch(union node *pattern, char *val)
|
|||
int result;
|
||||
char *p;
|
||||
|
||||
CTRACE(DBG_MATCH, ("casematch(P=\"%s\", W=\"%s\")\n",
|
||||
pattern->narg.text, val));
|
||||
setstackmark(&smark);
|
||||
argbackq = pattern->narg.backquote;
|
||||
STARTSTACKSTR(expdest);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: shell.h,v 1.25 2017/07/26 03:44:43 kre Exp $ */
|
||||
/* $NetBSD: shell.h,v 1.26 2018/07/22 20:38:06 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -189,10 +189,11 @@ extern int ShNest;
|
|||
#define DBG_ARITH (1LL << 15) /* a */
|
||||
#define DBG_HISTORY (1LL << 16) /* h */
|
||||
#define DBG_SIG (1LL << 17) /* s */
|
||||
#define DBG_MATCH (1LL << 18) /* g (glob) */
|
||||
|
||||
/*
|
||||
* reserved extras: b=builtins l=alias
|
||||
* still free: d g k n q u y
|
||||
* still free: d k n q u y
|
||||
*/
|
||||
|
||||
/* use VTRACE(DBG_ALWAYS, (...)) to test this one */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: show.c,v 1.47 2017/06/30 23:00:40 kre Exp $ */
|
||||
/* $NetBSD: show.c,v 1.48 2018/07/22 20:38:06 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -39,7 +39,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)show.c 8.3 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: show.c,v 1.47 2017/06/30 23:00:40 kre Exp $");
|
||||
__RCSID("$NetBSD: show.c,v 1.48 2018/07/22 20:38:06 kre Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -1070,6 +1070,7 @@ static struct debug_flag {
|
|||
{ 'c', DBG_CMDS }, /* command searching, ... */
|
||||
{ 'e', DBG_EVAL }, /* evaluation of the parse tree */
|
||||
{ 'f', DBG_REDIR }, /* file descriptors & redirections */
|
||||
{ 'g', DBG_MATCH }, /* pattern matching (glob) */
|
||||
{ 'h', DBG_HISTORY }, /* history & cmd line editing */
|
||||
{ 'i', DBG_INPUT }, /* shell input routines */
|
||||
{ 'j', DBG_JOBS }, /* job control, structures */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: trap.c,v 1.41 2017/07/05 19:47:11 kre Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.42 2018/07/22 20:38:06 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: trap.c,v 1.41 2017/07/05 19:47:11 kre Exp $");
|
||||
__RCSID("$NetBSD: trap.c,v 1.42 2018/07/22 20:38:06 kre Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -523,9 +523,11 @@ dotrap(void)
|
|||
savestatus=exitstatus;
|
||||
CTRACE(DBG_TRAP|DBG_SIG, ("dotrap %d: \"%s\"\n", i,
|
||||
trap[i] ? trap[i] : "-NULL-"));
|
||||
tr = savestr(trap[i]); /* trap code may free trap[i] */
|
||||
evalstring(tr, 0);
|
||||
ckfree(tr);
|
||||
if ((tr = trap[i]) != NULL) {
|
||||
tr = savestr(tr); /* trap code may free trap[i] */
|
||||
evalstring(tr, 0);
|
||||
ckfree(tr);
|
||||
}
|
||||
exitstatus=savestatus;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue