ncurses 5.6 - patch 20080112

+ remove recursive-mutex definitions, finish threading demo for worm.c
+ remove a redundant adjustment of lines in resizeterm.c's
  adjust_window() which caused occasional misadjustment of stdscr when
  softkeys were used.
This commit is contained in:
Thomas E. Dickey 2008-01-13 02:05:47 +00:00
parent 8144a95f57
commit c4d90db4f4
12 changed files with 102 additions and 60 deletions

8
NEWS
View File

@ -25,7 +25,7 @@
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
-------------------------------------------------------------------------------
-- $Id: NEWS,v 1.1195 2008/01/06 00:01:08 tom Exp $
-- $Id: NEWS,v 1.1197 2008/01/13 01:05:34 tom Exp $
-------------------------------------------------------------------------------
This is a log of changes that ncurses has gone through since Zeyd started
@ -45,6 +45,12 @@ See the AUTHORS file for the corresponding full names.
Changes through 1.9.9e did not credit all contributions;
it is not possible to add this information.
20080112
+ remove recursive-mutex definitions, finish threading demo for worm.c
+ remove a redundant adjustment of lines in resizeterm.c's
adjust_window() which caused occasional misadjustment of stdscr when
softkeys were used.
20080105
+ several improvements to terminfo entries based on xterm #230 -TD
+ modify MKlib_gen.sh to handle keyname/key_name prototypes, so the

View File

@ -1,5 +1,5 @@
##############################################################################
# Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. #
# Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the "Software"), #
@ -25,7 +25,7 @@
# use or other dealings in this Software without prior written #
# authorization. #
##############################################################################
# $Id: dist.mk,v 1.622 2008/01/05 19:49:50 tom Exp $
# $Id: dist.mk,v 1.624 2008/01/12 16:01:48 tom Exp $
# Makefile for creating ncurses distributions.
#
# This only needs to be used directly as a makefile by developers, but
@ -37,7 +37,7 @@ SHELL = /bin/sh
# These define the major/minor/patch versions of ncurses.
NCURSES_MAJOR = 5
NCURSES_MINOR = 6
NCURSES_PATCH = 20080105
NCURSES_PATCH = 20080112
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -48,7 +48,7 @@
#include <term.h> /* clear_screen, cup & friends, cur_term */
#include <tic.h>
MODULE_ID("$Id: lib_newterm.c,v 1.67 2007/04/21 20:47:32 tom Exp $")
MODULE_ID("$Id: lib_newterm.c,v 1.68 2008/01/12 20:24:40 tom Exp $")
#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
#define ONLCR 0
@ -123,7 +123,7 @@ newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
{
int value;
int errret;
int slk_format = _nc_slk_format;
int slk_format = _nc_globals.slk_format;
SCREEN *current;
SCREEN *result = 0;

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -41,7 +41,7 @@
#include <curses.priv.h>
MODULE_ID("$Id: lib_newwin.c,v 1.42 2007/12/22 23:20:18 tom Exp $")
MODULE_ID("$Id: lib_newwin.c,v 1.44 2008/01/13 00:28:13 tom Exp $")
static WINDOW *
remove_window_from_screen(WINDOW *win)
@ -234,7 +234,7 @@ _nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
{
pthread_mutexattr_t recattr;
memset(&recattr, 0, sizeof(recattr));
pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutexattr_settype(&recattr, PTHREAD_MUTEX_NORMAL);
pthread_mutex_init(&(wp->mutex_use_window), &recattr);
}
#endif

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -45,7 +45,7 @@
#include <ctype.h>
#include <term.h> /* num_labels, label_*, plab_norm */
MODULE_ID("$Id: lib_slk.c,v 1.30 2005/01/08 21:56:36 tom Exp $")
MODULE_ID("$Id: lib_slk.c,v 1.31 2008/01/12 20:21:00 tom Exp $")
/*
* We'd like to move these into the screen context structure, but cannot,
@ -56,7 +56,6 @@ _nc_slk_format = 0; /* one more than format specified in slk_init() */
/*
* Paint the info line for the PC style SLK emulation.
*
*/
static void
slk_paint_info(WINDOW *win)
@ -119,12 +118,12 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
SP->_slk->maxlab = ((num_labels > 0)
? num_labels
: MAX_SKEY(_nc_slk_format));
: MAX_SKEY(_nc_globals.slk_format));
SP->_slk->maxlen = ((num_labels > 0)
? label_width * label_height
: MAX_SKEY_LEN(_nc_slk_format));
SP->_slk->labcnt = ((SP->_slk->maxlab < MAX_SKEY(_nc_slk_format))
? MAX_SKEY(_nc_slk_format)
: MAX_SKEY_LEN(_nc_globals.slk_format));
SP->_slk->labcnt = ((SP->_slk->maxlab < MAX_SKEY(_nc_globals.slk_format))
? MAX_SKEY(_nc_globals.slk_format)
: SP->_slk->maxlab);
if (SP->_slk->maxlen <= 0
@ -148,7 +147,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
memset(SP->_slk->ent[i].form_text, ' ', max_length);
SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
}
if (_nc_slk_format >= 3) { /* PC style */
if (_nc_globals.slk_format >= 3) { /* PC style */
int gap = (cols - 3 * (3 + 4 * max_length)) / 2;
if (gap < 1)
@ -161,7 +160,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
}
slk_paint_info(stwin);
} else {
if (_nc_slk_format == 2) { /* 4-4 */
if (_nc_globals.slk_format == 2) { /* 4-4 */
int gap = cols - (SP->_slk->maxlab * max_length) - 6;
if (gap < 1)
@ -172,7 +171,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
x += (i == 3) ? gap : 1;
}
} else {
if (_nc_slk_format == 1) { /* 1 -> 3-2-3 */
if (_nc_globals.slk_format == 1) { /* 1 -> 3-2-3 */
int gap = (cols - (SP->_slk->maxlab * max_length) - 5)
/ 2;
@ -196,8 +195,8 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
* per default no SLK keys and may call slk_init again to
* define a new layout. (juergen 03-Mar-1999)
*/
SP->slk_format = _nc_slk_format;
_nc_slk_format = 0;
SP->slk_format = _nc_globals.slk_format;
_nc_globals.slk_format = 0;
returnCode(res);
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2000,2007 Free Software Foundation, Inc. *
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -29,6 +29,7 @@
/****************************************************************************
* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
* and: Thomas E. Dickey 1996-on *
****************************************************************************/
/*
@ -38,7 +39,7 @@
*/
#include <curses.priv.h>
MODULE_ID("$Id: lib_slkinit.c,v 1.6 2007/05/12 18:14:21 tom Exp $")
MODULE_ID("$Id: lib_slkinit.c,v 1.7 2008/01/12 20:23:39 tom Exp $")
NCURSES_EXPORT(int)
slk_init(int format)
@ -46,9 +47,9 @@ slk_init(int format)
int code = ERR;
T((T_CALLED("slk_init(%d)"), format));
if (format >= 0 && format <= 3 && !_nc_slk_format) {
_nc_slk_format = 1 + format;
code = _nc_ripoffline(-SLK_LINES(_nc_slk_format), _nc_slk_initialize);
if (format >= 0 && format <= 3 && !_nc_globals.slk_format) {
_nc_globals.slk_format = 1 + format;
code = _nc_ripoffline(-SLK_LINES(_nc_globals.slk_format), _nc_slk_initialize);
}
returnCode(code);
}

View File

@ -41,7 +41,7 @@
#include <curses.priv.h>
#include <term.h>
MODULE_ID("$Id: resizeterm.c,v 1.28 2008/01/06 01:23:36 tom Exp $")
MODULE_ID("$Id: resizeterm.c,v 1.30 2008/01/12 22:26:56 tom Exp $")
#define stolen_lines (screen_lines - SP->_lines_avail)
@ -210,24 +210,22 @@ adjust_window(WINDOW *win, int ToLines, int ToCols, int stolen EXTRA_DCLS)
*/
win->_begy += (ToLines - CurLines);
} else {
if (myLines == CurLines - stolen
&& ToLines != CurLines)
if (myLines == (CurLines - stolen)
&& ToLines != CurLines) {
myLines = ToLines - stolen;
else if (myLines == CurLines
&& ToLines != CurLines)
} else if (myLines == CurLines
&& ToLines != CurLines) {
myLines = ToLines;
}
}
if (myLines > ToLines) {
myLines = ToLines;
}
if (myLines > ToLines)
myLines = ToLines;
if (myCols > ToCols)
myCols = ToCols;
if (myLines == CurLines
&& ToLines != CurLines)
myLines = ToLines;
if (myCols == CurCols
&& ToCols != CurCols)
myCols = ToCols;
@ -425,6 +423,10 @@ resizeterm(int ToLines, int ToCols)
/* ripped-off lines are a special case: if we did not lengthen
* them, we haven't moved them either. repaint them, too.
*
* for the rest - stdscr and other windows - the client has to
* decide which to repaint, since without panels, ncurses does
* not know which are really on top.
*/
for (rop = ripoff_stack; (rop - ripoff_stack) < N_RIPS; rop++) {
if (rop->win != stdscr

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 2007 Free Software Foundation, Inc. *
* Copyright (c) 2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -32,7 +32,7 @@
#include <curses.priv.h>
MODULE_ID("$Id: use_window.c,v 1.2 2007/10/20 19:57:55 tom Exp $")
MODULE_ID("$Id: use_window.c,v 1.3 2008/01/13 00:36:22 tom Exp $")
#ifdef USE_PTHREADS
NCURSES_EXPORT(void)
@ -43,7 +43,7 @@ _nc_lock_window(WINDOW *win)
_nc_lock_global(windowlist);
for (p = _nc_windows; p != 0; p = p->next) {
if (&(p->win) == win) {
pthread_mutex_lock(&(p->mutex_use_window));
_nc_mutex_lock(&(p->mutex_use_window));
break;
}
}
@ -58,7 +58,7 @@ _nc_unlock_window(WINDOW *win)
_nc_lock_global(windowlist);
for (p = _nc_windows; p != 0; p = p->next) {
if (&(p->win) == win) {
pthread_mutex_unlock(&(p->mutex_use_window));
_nc_mutex_unlock(&(p->mutex_use_window));
break;
}
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -34,7 +34,7 @@
/*
* $Id: curses.priv.h,v 1.355 2007/12/29 20:32:54 tom Exp $
* $Id: curses.priv.h,v 1.357 2008/01/13 00:33:10 tom Exp $
*
* curses.priv.h
*
@ -314,9 +314,12 @@ color_t;
#ifdef USE_PTHREADS
#if USE_REENTRANT
#include <pthread.h>
#define _nc_lock_global(name) pthread_mutex_lock(&_nc_globals.mutex_##name)
#define _nc_try_global(name) pthread_mutex_trylock(&_nc_globals.mutex_##name)
#define _nc_unlock_global(name) pthread_mutex_unlock(&_nc_globals.mutex_##name)
extern NCURSES_EXPORT(int) _nc_mutex_lock(pthread_mutex_t *);
extern NCURSES_EXPORT(int) _nc_mutex_trylock(pthread_mutex_t *);
extern NCURSES_EXPORT(int) _nc_mutex_unlock(pthread_mutex_t *);
#define _nc_lock_global(name) _nc_mutex_lock(&_nc_globals.mutex_##name)
#define _nc_try_global(name) _nc_mutex_trylock(&_nc_globals.mutex_##name)
#define _nc_unlock_global(name) _nc_mutex_unlock(&_nc_globals.mutex_##name)
extern NCURSES_EXPORT(void) _nc_lock_window(WINDOW *);
extern NCURSES_EXPORT(void) _nc_unlock_window(WINDOW *);
@ -540,6 +543,8 @@ typedef struct {
char *first_name;
char **keyname_table;
int slk_format;
char *safeprint_buf;
size_t safeprint_used;
@ -1607,7 +1612,6 @@ extern NCURSES_EXPORT_VAR(SCREEN *) SP;
#define screen_lines SP->_lines
#define screen_columns SP->_columns
extern NCURSES_EXPORT_VAR(int) _nc_slk_format; /* != 0 if slk_init() called */
extern NCURSES_EXPORT(int) _nc_slk_initialize (WINDOW *, int);
/*

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -41,7 +41,7 @@
#include <curses.priv.h>
MODULE_ID("$Id: lib_data.c,v 1.35 2007/12/29 20:29:27 tom Exp $")
MODULE_ID("$Id: lib_data.c,v 1.39 2008/01/13 01:21:59 tom Exp $")
/*
* OS/2's native linker complains if we don't initialize public data when
@ -131,6 +131,8 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
NULL, /* first_name */
NULL, /* keyname_table */
0, /* slk_format */
NULL, /* safeprint_buf */
0, /* safeprint_used */
@ -177,10 +179,10 @@ NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
#endif /* TRACE */
#ifdef USE_PTHREADS
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_set_SP */
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_use_screen */
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_use_window */
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, /* mutex_windowlist */
PTHREAD_MUTEX_INITIALIZER, /* mutex_set_SP */
PTHREAD_MUTEX_INITIALIZER, /* mutex_use_screen */
PTHREAD_MUTEX_INITIALIZER, /* mutex_use_window */
PTHREAD_MUTEX_INITIALIZER, /* mutex_windowlist */
PTHREAD_MUTEX_INITIALIZER, /* mutex_tst_tracef */
PTHREAD_MUTEX_INITIALIZER, /* mutex_tracef */
0, /* nested_tracef */
@ -231,3 +233,24 @@ NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
#endif
};
/* *INDENT-ON* */
/******************************************************************************/
#ifdef USE_PTHREADS
NCURSES_EXPORT(int)
_nc_mutex_lock(pthread_mutex_t *obj)
{
return pthread_mutex_lock(obj);
}
NCURSES_EXPORT(int)
_nc_mutex_trylock(pthread_mutex_t *obj)
{
return pthread_mutex_trylock(obj);
}
NCURSES_EXPORT(int)
_nc_mutex_unlock(pthread_mutex_t *obj)
{
return pthread_mutex_unlock(obj);
}
#endif /* USE_PTHREADS */

View File

@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
* Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@ -40,7 +40,7 @@ AUTHOR
Author: Eric S. Raymond <esr@snark.thyrsus.com> 1993
Thomas E. Dickey (beginning revision 1.27 in 1996).
$Id: ncurses.c,v 1.296 2007/12/29 21:05:43 tom Exp $
$Id: ncurses.c,v 1.298 2008/01/12 23:06:58 tom Exp $
***************************************************************************/
@ -76,7 +76,7 @@ $Id: ncurses.c,v 1.296 2007/12/29 21:05:43 tom Exp $
#define NCURSES_CONST_PARAM const void
#ifdef TRACE
static unsigned save_trace = TRACE_ORDINARY | TRACE_CALLS;
static unsigned save_trace = TRACE_ORDINARY | TRACE_ICALLS | TRACE_CALLS;
extern unsigned _nc_tracing;
#endif
@ -2525,6 +2525,7 @@ slk_test(void)
#endif
#if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE
case KEY_RESIZE:
wnoutrefresh(stdscr);
break;
#endif
@ -2655,6 +2656,7 @@ wide_slk_test(void)
break;
#if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE
case KEY_RESIZE:
wnoutrefresh(stdscr);
break;
#endif
default:

View File

@ -61,7 +61,7 @@ Options:
traces will be dumped. The program stops and waits for one character of
input at the beginning and end of the interval.
$Id: worm.c,v 1.50 2007/12/22 23:55:13 tom Exp $
$Id: worm.c,v 1.51 2008/01/13 01:03:23 tom Exp $
*/
#include <test.priv.h>
@ -93,6 +93,7 @@ typedef struct worm {
#endif
} WORM;
static unsigned long sequence = 0;
static bool quitting = FALSE;
static WORM worm[40];
@ -318,16 +319,20 @@ use_window(WINDOW *win, int (*func) (WINDOW *, void *), void *data)
static bool
quit_worm(void)
{
napms(20); /* let the other thread(s) have a chance */
napms(10); /* let the other thread(s) have a chance */
return quitting;
}
static void *
start_worm(void *arg)
{
unsigned long compare = 0;
while (!quit_worm()) {
while (compare < sequence) {
++compare;
use_window(stdscr, draw_worm, arg);
}
}
return NULL;
}
#endif
@ -492,13 +497,13 @@ main(int argc, char *argv[])
}
}
}
napms(10);
refresh();
nodelay(stdscr, TRUE);
while (!done) {
int ch;
++sequence;
if ((ch = getch()) > 0) {
#ifdef TRACE
if (trace_start || trace_end) {