Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses * Added new function idcok - this closes PR 10802
details: https://anonhg.NetBSD.org/src/rev/b1a7864a1c5c
branches: trunk
changeset: 534170:b1a7864a1c5c
user: blymn <blymn%NetBSD.org@localhost>
date: Fri Jul 19 13:22:41 2002 +0000
description:
* Added new function idcok - this closes PR 10802
* Added sentinels to the line structures when in debug mode to try
to pick up data overwrite problems, if they occur.
diffstat:
lib/libcurses/Makefile | 12 ++++----
lib/libcurses/addbytes.c | 22 ++++++++++++++-
lib/libcurses/addch.c | 5 ++-
lib/libcurses/curses.h | 3 +-
lib/libcurses/curses_private.h | 8 +++++-
lib/libcurses/idcok.c | 58 ++++++++++++++++++++++++++++++++++++++++++
lib/libcurses/newwin.c | 12 ++++++--
lib/libcurses/resize.c | 7 +++-
lib/libcurses/shlib_version | 4 +-
9 files changed, 112 insertions(+), 19 deletions(-)
diffs (truncated from 301 to 300 lines):
diff -r 737ddf6b72ae -r b1a7864a1c5c lib/libcurses/Makefile
--- a/lib/libcurses/Makefile Fri Jul 19 12:53:31 2002 +0000
+++ b/lib/libcurses/Makefile Fri Jul 19 13:22:41 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.35 2001/12/11 11:18:17 blymn Exp $
+# $NetBSD: Makefile,v 1.36 2002/07/19 13:22:41 blymn Exp $
# @(#)Makefile 8.2 (Berkeley) 1/2/94
CPPFLAGS+=#-DTFILE=\"/dev/ttyp0\"
@@ -14,11 +14,11 @@
border.c box.c clear.c clearok.c clrtobot.c clrtoeol.c color.c \
copywin.c cr_put.c ctrace.c cur_hash.c curs_set.c curses.c delch.c \
deleteln.c delwin.c erase.c flushok.c fullname.c getch.c getstr.c \
- getyx.c id_subwins.c idlok.c inch.c inchstr.c initscr.c insch.c \
- insdelln.c insertln.c instr.c keypad.c leaveok.c line.c longname.c \
- meta.c move.c mvwin.c newwin.c nodelay.c notimeout.c overlay.c \
- overwrite.c pause.c printw.c putchar.c refresh.c resize.c scanw.c \
- screen.c scroll.c scrollok.c setterm.c standout.c timeout.c \
+ getyx.c id_subwins.c idlok.c idcok.c inch.c inchstr.c initscr.c \
+ insch.c insdelln.c insertln.c instr.c keypad.c leaveok.c line.c \
+ longname.c meta.c move.c mvwin.c newwin.c nodelay.c notimeout.c \
+ overlay.c overwrite.c pause.c printw.c putchar.c refresh.c resize.c \
+ scanw.c screen.c scroll.c scrollok.c setterm.c standout.c timeout.c \
toucholap.c touchwin.c tscroll.c tstp.c tty.c unctrl.c underscore.c
MAN= curses.3
diff -r 737ddf6b72ae -r b1a7864a1c5c lib/libcurses/addbytes.c
--- a/lib/libcurses/addbytes.c Fri Jul 19 12:53:31 2002 +0000
+++ b/lib/libcurses/addbytes.c Fri Jul 19 13:22:41 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: addbytes.c,v 1.22 2001/04/20 12:56:08 jdc Exp $ */
+/* $NetBSD: addbytes.c,v 1.23 2002/07/19 13:22:41 blymn Exp $ */
/*
* Copyright (c) 1987, 1993, 1994
@@ -38,12 +38,15 @@
#if 0
static char sccsid[] = "@(#)addbytes.c 8.4 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: addbytes.c,v 1.22 2001/04/20 12:56:08 jdc Exp $");
+__RCSID("$NetBSD: addbytes.c,v 1.23 2002/07/19 13:22:41 blymn Exp $");
#endif
#endif /* not lint */
#include "curses.h"
#include "curses_private.h"
+#ifdef DEBUG
+#include <assert.h>
+#endif
#define SYNCH_IN {y = win->cury; x = win->curx;}
#define SYNCH_OUT {win->cury = y; win->curx = x;}
@@ -106,8 +109,16 @@
int c, newx, x, y;
attr_t attributes;
__LINE *lp;
+#ifdef DEBUG
+ int i;
+ for (i = 0; i < win->maxy; i++) {
+ assert(win->lines[i]->sentinel == SENTINEL_VALUE);
+ }
+#endif
+
SYNCH_IN;
+ lp = win->lines[y];
while (count--) {
c = *bytes++;
@@ -214,5 +225,12 @@
}
}
SYNCH_OUT;
+
+#ifdef DEBUG
+ for (i = 0; i < win->maxy; i++) {
+ assert(win->lines[i]->sentinel == SENTINEL_VALUE);
+ }
+#endif
+
return (OK);
}
diff -r 737ddf6b72ae -r b1a7864a1c5c lib/libcurses/addch.c
--- a/lib/libcurses/addch.c Fri Jul 19 12:53:31 2002 +0000
+++ b/lib/libcurses/addch.c Fri Jul 19 13:22:41 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: addch.c,v 1.11 2000/04/15 13:17:02 blymn Exp $ */
+/* $NetBSD: addch.c,v 1.12 2002/07/19 13:22:41 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)addch.c 8.2 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: addch.c,v 1.11 2000/04/15 13:17:02 blymn Exp $");
+__RCSID("$NetBSD: addch.c,v 1.12 2002/07/19 13:22:41 blymn Exp $");
#endif
#endif /* not lint */
@@ -107,5 +107,6 @@
char buf[2];
buf[0] = dp->ch;
+ buf[1] = '\0';
return (__waddbytes(win, buf, 1, dp->attr));
}
diff -r 737ddf6b72ae -r b1a7864a1c5c lib/libcurses/curses.h
--- a/lib/libcurses/curses.h Fri Jul 19 12:53:31 2002 +0000
+++ b/lib/libcurses/curses.h Fri Jul 19 13:22:41 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: curses.h,v 1.64 2001/12/11 11:18:17 blymn Exp $ */
+/* $NetBSD: curses.h,v 1.65 2002/07/19 13:22:41 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -528,6 +528,7 @@
bool has_ic(void);
bool has_il(void);
int hline(chtype, int);
+int idcok(WINDOW *, bool);
int idlok(WINDOW *, bool);
int init_color(short, short, short, short);
int init_pair(short, short, short);
diff -r 737ddf6b72ae -r b1a7864a1c5c lib/libcurses/curses_private.h
--- a/lib/libcurses/curses_private.h Fri Jul 19 12:53:31 2002 +0000
+++ b/lib/libcurses/curses_private.h Fri Jul 19 13:22:41 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: curses_private.h,v 1.23 2002/06/26 18:37:28 itojun Exp $ */
+/* $NetBSD: curses_private.h,v 1.24 2002/07/19 13:22:41 blymn Exp $ */
/*-
* Copyright (c) 1998-2000 Brett Lymn
@@ -80,6 +80,11 @@
#define __LDATASIZE (sizeof(__LDATA))
struct __line {
+#ifdef DEBUG
+#define SENTINEL_VALUE 0xaac0ffee
+
+ unsigned int sentinel; /* try to catch line overflows */
+#endif
#define __ISDIRTY 0x01 /* Line is dirty. */
#define __ISPASTEOL 0x02 /* Cursor is past end of line */
unsigned int flags;
@@ -109,6 +114,7 @@
#define __LEAVEOK 0x00000100 /* If cursor left */
#define __KEYPAD 0x00010000 /* If interpreting keypad codes */
#define __NOTIMEOUT 0x00020000 /* Wait indefinitely for func keys */
+#define __IDCHAR 0x00040000 /* insert/delete char sequences */
unsigned int flags;
int delay; /* delay for getch() */
attr_t wattr; /* Character attributes */
diff -r 737ddf6b72ae -r b1a7864a1c5c lib/libcurses/idcok.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libcurses/idcok.c Fri Jul 19 13:22:41 2002 +0000
@@ -0,0 +1,58 @@
+/* $NetBSD: idcok.c,v 1.1 2002/07/19 13:22:41 blymn Exp $ */
+
+/*-
+ * Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com@localhost)
+ * All rights reserved.
+ *
+ * This software has been donated to the NetBSD Foundation by the
+ * Author.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)idcok.c blymn 2002/06/06";
+#else
+__RCSID("$NetBSD: idcok.c,v 1.1 2002/07/19 13:22:41 blymn Exp $");
+#endif
+#endif /* not lint */
+
+#include "curses.h"
+#include "curses_private.h"
+
+/*
+ * idcok --
+ * Turn on and off using insert/delete char sequences for the
+ * given window. Note, currently, the ic/dc capabilities are not
+ * used, this function is only provided for compatibility.
+ */
+int
+idcok(WINDOW *win, bool bf)
+{
+ if (bf)
+ win->flags |= __IDCHAR;
+ else
+ win->flags &= ~__IDCHAR;
+ return (OK);
+}
diff -r 737ddf6b72ae -r b1a7864a1c5c lib/libcurses/newwin.c
--- a/lib/libcurses/newwin.c Fri Jul 19 12:53:31 2002 +0000
+++ b/lib/libcurses/newwin.c Fri Jul 19 13:22:41 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: newwin.c,v 1.28 2002/01/02 10:38:28 blymn Exp $ */
+/* $NetBSD: newwin.c,v 1.29 2002/07/19 13:22:41 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)newwin.c 8.3 (Berkeley) 7/27/94";
#else
-__RCSID("$NetBSD: newwin.c,v 1.28 2002/01/02 10:38:28 blymn Exp $");
+__RCSID("$NetBSD: newwin.c,v 1.29 2002/07/19 13:22:41 blymn Exp $");
#endif
#endif /* not lint */
@@ -179,6 +179,9 @@
for (lp = win->lspace, i = 0; i < win->maxy; i++, lp++) {
win->lines[i] = lp;
olp = orig->lines[i + win->begy - orig->begy];
+#ifdef DEBUG
+ lp->sentinel = SENTINEL_VALUE;
+#endif
lp->line = &olp->line[win->ch_off];
lp->firstchp = &olp->firstch;
lp->lastchp = &olp->lastch;
@@ -261,6 +264,9 @@
for (lp = win->lspace, i = 0; i < nlines; i++, lp++) {
win->lines[i] = lp;
lp->line = &win->wspace[i * ncols];
+#ifdef DEBUG
+ lp->sentinel = SENTINEL_VALUE;
+#endif
lp->firstchp = &lp->firstch;
lp->lastchp = &lp->lastch;
lp->firstch = 0;
@@ -276,7 +282,7 @@
win->begy = by;
win->begx = bx;
- win->flags = 0;
+ win->flags = (__IDLINE | __IDCHAR);
win->delay = -1;
win->wattr = 0;
win->bch = ' ';
diff -r 737ddf6b72ae -r b1a7864a1c5c lib/libcurses/resize.c
--- a/lib/libcurses/resize.c Fri Jul 19 12:53:31 2002 +0000
+++ b/lib/libcurses/resize.c Fri Jul 19 13:22:41 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: resize.c,v 1.2 2002/01/02 10:38:29 blymn Exp $ */
+/* $NetBSD: resize.c,v 1.3 2002/07/19 13:22:41 blymn Exp $ */
/*
* Copyright (c) 2001
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)resize.c blymn 2001/08/26";
#else
-__RCSID("$NetBSD: resize.c,v 1.2 2002/01/02 10:38:29 blymn Exp $");
+__RCSID("$NetBSD: resize.c,v 1.3 2002/07/19 13:22:41 blymn Exp $");
#endif
#endif /* not lint */
@@ -236,6 +236,9 @@
for (lp = win->lspace, i = 0; i < nlines; i++, lp++) {
win->lines[i] = lp;
lp->line = &win->wspace[i * ncols];
+#ifdef DEBUG
+ lp->sentinel = SENTINEL_VALUE;
+#endif
lp->firstchp = &lp->firstch;
lp->lastchp = &lp->lastch;
lp->firstch = 0;
diff -r 737ddf6b72ae -r b1a7864a1c5c lib/libcurses/shlib_version
--- a/lib/libcurses/shlib_version Fri Jul 19 12:53:31 2002 +0000
+++ b/lib/libcurses/shlib_version Fri Jul 19 13:22:41 2002 +0000
@@ -1,5 +1,5 @@
-# $NetBSD: shlib_version,v 1.23 2001/12/02 22:43:44 christos Exp $
+# $NetBSD: shlib_version,v 1.24 2002/07/19 13:22:41 blymn Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=5
-minor=0
Home |
Main Index |
Thread Index |
Old Index