Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libcurses Just return ERR instead of asserting if someon...
details: https://anonhg.NetBSD.org/src/rev/2313bf1b2fc8
branches: trunk
changeset: 351010:2313bf1b2fc8
user: roy <roy%NetBSD.org@localhost>
date: Mon Jan 30 17:15:52 2017 +0000
description:
Just return ERR instead of asserting if someone calls the slk routines
to affect the ripped off window before the window is actually ripped off.
diffstat:
lib/libcurses/slk.c | 51 +++++++++++++++++++++------------------------------
1 files changed, 21 insertions(+), 30 deletions(-)
diffs (180 lines):
diff -r 16ffb5d215db -r 2313bf1b2fc8 lib/libcurses/slk.c
--- a/lib/libcurses/slk.c Mon Jan 30 16:50:44 2017 +0000
+++ b/lib/libcurses/slk.c Mon Jan 30 17:15:52 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: slk.c,v 1.1 2017/01/24 17:27:30 roy Exp $ */
+/* $NetBSD: slk.c,v 1.2 2017/01/30 17:15:52 roy Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -31,10 +31,9 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: slk.c,v 1.1 2017/01/24 17:27:30 roy Exp $");
+__RCSID("$NetBSD: slk.c,v 1.2 2017/01/30 17:15:52 roy Exp $");
#endif /* not lint */
-#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
@@ -280,8 +279,7 @@
__slk_attron(SCREEN *screen, const chtype attr)
{
- assert(screen != NULL);
- if (screen->slk_window == NULL)
+ if (screen == NULL || screen->slk_window == NULL)
return ERR;
return wattron(screen->slk_window, attr);
}
@@ -294,8 +292,7 @@
__slk_attr_on(SCREEN *screen, const attr_t attr, void *opt)
{
- assert(screen != NULL);
- if (screen->slk_window == NULL)
+ if (screen == NULL || screen->slk_window == NULL)
return ERR;
return wattr_on(screen->slk_window, attr, opt);
}
@@ -308,8 +305,7 @@
__slk_attroff(SCREEN *screen, const chtype attr)
{
- assert(screen != NULL);
- if (screen->slk_window == NULL)
+ if (screen == NULL || screen->slk_window == NULL)
return ERR;
return wattroff(screen->slk_window, attr);
}
@@ -322,8 +318,7 @@
__slk_attr_off(SCREEN *screen, const attr_t attr, void *opt)
{
- assert(screen != NULL);
- if (screen->slk_window == NULL)
+ if (screen == NULL || screen->slk_window == NULL)
return ERR;
return wattr_off(screen->slk_window, attr, opt);
}
@@ -336,8 +331,7 @@
__slk_attrset(SCREEN *screen, const chtype attr)
{
- assert(screen != NULL);
- if (screen->slk_window == NULL)
+ if (screen == NULL || screen->slk_window == NULL)
return ERR;
return wattrset(screen->slk_window, attr);
}
@@ -350,8 +344,7 @@
__slk_attr_set(SCREEN *screen, const attr_t attr, short pair, void *opt)
{
- assert(screen != NULL);
- if (screen->slk_window == NULL)
+ if (screen == NULL || screen->slk_window == NULL)
return ERR;
return wattr_set(screen->slk_window, attr, pair, opt);
}
@@ -364,7 +357,8 @@
__slk_clear(SCREEN *screen)
{
- assert(screen != NULL);
+ if (screen == NULL)
+ return ERR;
screen->slk_hidden = true;
if (screen->is_term_slk) {
if (t_label_off(screen->term) == NULL)
@@ -386,8 +380,7 @@
__slk_color(SCREEN *screen, short pair)
{
- assert(screen != NULL);
- if (screen->slk_window == NULL)
+ if (screen == NULL || screen->slk_window == NULL)
return ERR;
return wcolor_set(screen->slk_window, pair, NULL);
}
@@ -401,8 +394,7 @@
__slk_label(SCREEN *screen, int labnum)
{
- assert(screen != NULL);
- if (labnum < 1 || labnum > screen->slk_nlabels)
+ if (screen == NULL || labnum < 1 || labnum > screen->slk_nlabels)
return NULL;
return screen->slk_labels[--labnum].text;
}
@@ -415,8 +407,7 @@
__slk_noutrefresh(SCREEN *screen)
{
- assert(screen != NULL);
- if (screen->slk_window == NULL)
+ if (screen == NULL || screen->slk_window == NULL)
return ERR;
return wnoutrefresh(screen->slk_window);
}
@@ -429,7 +420,8 @@
__slk_restore(SCREEN *screen)
{
- assert(screen != NULL);
+ if (screen == NULL)
+ return ERR;
screen->slk_hidden = false;
if (screen->is_term_slk) {
if (t_label_on(screen->term) == NULL)
@@ -461,9 +453,8 @@
size_t wc_len;
#endif
- assert(screen != NULL);
/* Check args. */
- if (labnum < 1 || labnum > screen->slk_nlabels)
+ if (screen == NULL || labnum < 1 || labnum > screen->slk_nlabels)
return ERR;
switch(justify) {
case SLK_JUSTIFY_LEFT:
@@ -520,8 +511,7 @@
__slk_touch(SCREEN *screen)
{
- assert(screen != NULL);
- if (screen->slk_window == NULL)
+ if (screen == NULL || screen->slk_window == NULL)
return ERR;
return touchwin(screen->slk_window);
}
@@ -540,7 +530,8 @@
char *str;
int result = ERR;
- assert(screen != NULL);
+ if (screen == NULL)
+ return ERR;
olabel = label;
if ((len = wcsrtombs(NULL, &olabel, 0, &screen->sp)) == -1)
return ERR;
@@ -624,7 +615,6 @@
if (window == NULL)
return ERR;
- assert(window->screen->slk_window == NULL);
window->screen->slk_window = window;
wattron(window,
(t_no_color_video(window->screen->term) & 1) == 0
@@ -643,7 +633,8 @@
int x = 0;
struct __slk_label *l;
- assert(screen != NULL);
+ if (screen == NULL)
+ return ERR;
if (screen->is_term_slk || screen->slk_nlabels == 0)
return OK;
Home |
Main Index |
Thread Index |
Old Index