Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/nvi/dist/ex In tagq_free(), fix the test checki...



details:   https://anonhg.NetBSD.org/src/rev/a35c3cf4c3d3
branches:  trunk
changeset: 801892:a35c3cf4c3d3
user:      aymeric <aymeric%NetBSD.org@localhost>
date:      Fri Aug 22 21:28:20 2014 +0000

description:
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.

diffstat:

 external/bsd/nvi/dist/ex/ex_cscope.c |  5 +++--
 external/bsd/nvi/dist/ex/ex_tag.c    |  9 ++++++---
 external/bsd/nvi/dist/ex/tag.h       |  3 ++-
 3 files changed, 11 insertions(+), 6 deletions(-)

diffs (94 lines):

diff -r d53c66bf07db -r a35c3cf4c3d3 external/bsd/nvi/dist/ex/ex_cscope.c
--- a/external/bsd/nvi/dist/ex/ex_cscope.c      Fri Aug 22 20:54:29 2014 +0000
+++ b/external/bsd/nvi/dist/ex/ex_cscope.c      Fri Aug 22 21:28:20 2014 +0000
@@ -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 @@
 
        /* 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);
 
diff -r d53c66bf07db -r a35c3cf4c3d3 external/bsd/nvi/dist/ex/ex_tag.c
--- a/external/bsd/nvi/dist/ex/ex_tag.c Fri Aug 22 20:54:29 2014 +0000
+++ b/external/bsd/nvi/dist/ex/ex_tag.c Fri Aug 22 21:28:20 2014 +0000
@@ -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 @@
                        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 @@
         * 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 @@
         */
        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 @@
 
        /* 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);
diff -r d53c66bf07db -r a35c3cf4c3d3 external/bsd/nvi/dist/ex/tag.h
--- a/external/bsd/nvi/dist/ex/tag.h    Fri Aug 22 20:54:29 2014 +0000
+++ b/external/bsd/nvi/dist/ex/tag.h    Fri Aug 22 21:28:20 2014 +0000
@@ -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 @@
        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. */



Home | Main Index | Thread Index | Old Index