In tagq_free(), fix the test checking whether a TAGQ should be removed from
its tailq. This required introducing a new flag in the TAGQ structure to avoid reverting to poking under the hood of the queue.h API. The concrete bug it solves is that using tags would make vi crash reliably on exit.
This commit is contained in:
parent
4e8f1b53e9
commit
94f28557e3
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ex_cscope.c,v 1.5 2014/01/26 21:43:45 christos Exp $ */
|
||||
/* $NetBSD: ex_cscope.c,v 1.6 2014/08/22 21:28:20 aymeric Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1994, 1996
|
||||
* Rob Mayoff. All rights reserved.
|
||||
|
@ -16,7 +16,7 @@
|
|||
static const char sccsid[] = "Id: ex_cscope.c,v 10.21 2003/11/05 17:11:54 skimo Exp (Berkeley) Date: 2003/11/05 17:11:54 ";
|
||||
#endif /* not lint */
|
||||
#else
|
||||
__RCSID("$NetBSD: ex_cscope.c,v 1.5 2014/01/26 21:43:45 christos Exp $");
|
||||
__RCSID("$NetBSD: ex_cscope.c,v 1.6 2014/08/22 21:28:20 aymeric Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -549,6 +549,7 @@ cscope_find(SCR *sp, EXCMD *cmdp, const CHAR_T *pattern)
|
|||
|
||||
/* Link the current TAGQ structure into place. */
|
||||
TAILQ_INSERT_HEAD(&exp->tq, tqp, q);
|
||||
F_SET(tqp, TAG_IS_LINKED);
|
||||
|
||||
(void)cscope_search(sp, tqp, tqp->current);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ex_tag.c,v 1.11 2014/01/26 21:43:45 christos Exp $ */
|
||||
/* $NetBSD: ex_tag.c,v 1.12 2014/08/22 21:28:20 aymeric Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -19,7 +19,7 @@
|
|||
static const char sccsid[] = "Id: ex_tag.c,v 10.50 2004/03/16 14:09:11 skimo Exp (Berkeley) Date: 2004/03/16 14:09:11 ";
|
||||
#endif /* not lint */
|
||||
#else
|
||||
__RCSID("$NetBSD: ex_tag.c,v 1.11 2014/01/26 21:43:45 christos Exp $");
|
||||
__RCSID("$NetBSD: ex_tag.c,v 1.12 2014/08/22 21:28:20 aymeric Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -606,6 +606,7 @@ ex_tag_copy(SCR *orig, SCR *sp)
|
|||
TAILQ_INSERT_TAIL(&tqp->tagq, tp, q);
|
||||
}
|
||||
TAILQ_INSERT_TAIL(&nexp->tq, tqp, q);
|
||||
F_SET(tqp, TAG_IS_LINKED);
|
||||
}
|
||||
|
||||
/* Copy list of tag files. */
|
||||
|
@ -740,7 +741,7 @@ tagq_free(SCR *sp, TAGQ *tqp)
|
|||
* If allocated and then the user failed to switch files, the TAGQ
|
||||
* structure was never attached to any list.
|
||||
*/
|
||||
if (TAILQ_NEXT(tqp, q) != NULL)
|
||||
if (F_ISSET(tqp, TAG_IS_LINKED))
|
||||
TAILQ_REMOVE(&exp->tq, tqp, q);
|
||||
free(tqp);
|
||||
return (0);
|
||||
|
@ -810,6 +811,7 @@ tagq_push(SCR *sp, TAGQ *tqp, int new_screen, int force)
|
|||
*/
|
||||
if (TAILQ_EMPTY(&exp->tq)) {
|
||||
TAILQ_INSERT_HEAD(&exp->tq, rtqp, q);
|
||||
F_SET(rtqp, TAG_IS_LINKED);
|
||||
} else {
|
||||
free(rtqp);
|
||||
rtqp = TAILQ_FIRST(&exp->tq);
|
||||
|
@ -817,6 +819,7 @@ tagq_push(SCR *sp, TAGQ *tqp, int new_screen, int force)
|
|||
|
||||
/* Link the new TAGQ structure into place. */
|
||||
TAILQ_INSERT_HEAD(&exp->tq, tqp, q);
|
||||
F_SET(tqp, TAG_IS_LINKED);
|
||||
|
||||
(void)ctag_search(sp,
|
||||
tqp->current->search, tqp->current->slen, tqp->tag);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tag.h,v 1.3 2013/11/25 22:43:46 christos Exp $ */
|
||||
/* $NetBSD: tag.h,v 1.4 2014/08/22 21:28:20 aymeric Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
|
@ -104,6 +104,7 @@ struct _tagq { /* Tag queue. */
|
|||
size_t tlen; /* Tag string length. */
|
||||
|
||||
#define TAG_CSCOPE 0x01 /* Cscope tag. */
|
||||
#define TAG_IS_LINKED 0x02 /* Tag was inserted into linked list */
|
||||
u_int8_t flags;
|
||||
|
||||
char buf[1]; /* Variable length buffer. */
|
||||
|
|
Loading…
Reference in New Issue