about summary refs log tree commit diff
path: root/Src/Zle/compcore.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2011-05-14 00:07:41 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2011-05-14 00:07:41 +0000
commit506615ff94c7784e974f13034f04db87427b367e (patch)
treea7c196125a3ecab16fff2debffdfe98b295ef2b9 /Src/Zle/compcore.c
parent9c0a19669b32bcbf153e2bfdf1a44b0fe0d4876c (diff)
downloadzsh-506615ff94c7784e974f13034f04db87427b367e.tar.gz
zsh-506615ff94c7784e974f13034f04db87427b367e.tar.xz
zsh-506615ff94c7784e974f13034f04db87427b367e.zip
29267: add -enable-zsh-debug and use for debugging completion matcher groups
Diffstat (limited to 'Src/Zle/compcore.c')
-rw-r--r--Src/Zle/compcore.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index fa8b8c11f..9c6f0673a 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -405,6 +405,11 @@ do_completion(UNUSED(Hookdef dummy), Compldat dat)
 	} else if (nmatches == 1 || (nmatches > 1 && !diffmatches)) {
 	    /* Only one match. */
 	    Cmgroup m = amatches;
+#ifdef ZSH_HEAP_DEBUG
+	    if (memory_validate(m->heap_id)) {
+		HEAP_ERROR(m->heap_id);
+	    }
+#endif
 
 	    while (!m->mcount)
 		m = m->next;
@@ -509,6 +514,11 @@ after_complete(UNUSED(Hookdef dummy), int *dat)
 	int ret;
 
 	cdat.matches = amatches;
+#ifdef ZSH_HEAP_DEBUG
+	if (memory_validate(cdat.matches->heap_id)) {
+	    HEAP_ERROR(cdat.matches->heap_id);
+	}
+#endif
 	cdat.num = nmatches;
 	cdat.nmesg = nmessages;
 	cdat.cur = NULL;
@@ -987,6 +997,11 @@ makecomplist(char *s, int incmd, int lst)
 	    diffmatches = odm;
 	    validlist = 1;
 	    amatches = lastmatches;
+#ifdef ZSH_HEAP_DEBUG
+	    if (memory_validate(amatches->heap_id)) {
+		HEAP_ERROR(amatches->heap_id);
+	    }
+#endif
 	    lmatches = lastlmatches;
 	    if (pmatches) {
 		freematches(pmatches, 1);
@@ -2959,6 +2974,11 @@ begcmgroup(char *n, int flags)
 	Cmgroup p = amatches;
 
 	while (p) {
+#ifdef ZSH_HEAP_DEBUG
+	    if (memory_validate(p->heap_id)) {
+		HEAP_ERROR(p->heap_id);
+	    }
+#endif
 	    if (p->name &&
 		flags == (p->flags & (CGF_NOSORT|CGF_UNIQALL|CGF_UNIQCON)) &&
 		!strcmp(n, p->name)) {
@@ -2975,6 +2995,9 @@ begcmgroup(char *n, int flags)
 	}
     }
     mgroup = (Cmgroup) zhalloc(sizeof(struct cmgroup));
+#ifdef ZSH_HEAP_DEBUG
+    mgroup->heap_id = last_heap_id;
+#endif
     mgroup->name = dupstring(n);
     mgroup->lcount = mgroup->llcount = mgroup->mcount = mgroup->ecount = 
 	mgroup->ccount = 0;
@@ -3295,6 +3318,11 @@ permmatches(int last)
 	fi = 1;
     }
     while (g) {
+#ifdef ZSH_HEAP_DEBUG
+	if (memory_validate(g->heap_id)) {
+	    HEAP_ERROR(g->heap_id);
+	}
+#endif
 	if (fi != ofi || !g->perm || g->new) {
 	    if (fi)
 		/* We have no matches, try ignoring fignore. */
@@ -3323,6 +3351,9 @@ permmatches(int last)
 		diffmatches = 1;
 
 	    n = (Cmgroup) zshcalloc(sizeof(struct cmgroup));
+#ifdef ZSH_HEAP_DEBUG
+	    n->heap_id = HEAPID_PERMANENT;
+#endif
 
 	    if (g->perm) {
 		g->perm->next = NULL;