]> ncurses.scripts.mit.edu Git - ncurses.git/commitdiff
ncurses 5.6 - patch 20080112
authorThomas E. Dickey <dickey@invisible-island.net>
Sun, 13 Jan 2008 02:05:47 +0000 (02:05 +0000)
committerThomas E. Dickey <dickey@invisible-island.net>
Sun, 13 Jan 2008 02:05:47 +0000 (02:05 +0000)
+ 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.

12 files changed:
NEWS
dist.mk
ncurses/base/lib_newterm.c
ncurses/base/lib_newwin.c
ncurses/base/lib_slk.c
ncurses/base/lib_slkinit.c
ncurses/base/resizeterm.c
ncurses/base/use_window.c
ncurses/curses.priv.h
ncurses/tinfo/lib_data.c
test/ncurses.c
test/worm.c

diff --git a/NEWS b/NEWS
index 4778fc2f24ec86ad866e984f52f236bdcf1b7959..72b0b8df78daabb583b03f08b8398b4982db3bcb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/dist.mk b/dist.mk
index 58497df54c69d6a81e4ee177c3f8a7bc4305e913..bde9e4facb5fe23d652669db53c9e4a5a1054ca6 100644 (file)
--- a/dist.mk
+++ b/dist.mk
@@ -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)
index 05cd9b8a5b00aaa5cb424ae432b834251279f374..f52562cec1069c615831baec74a0180b089d2b9e 100644 (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;
 
index b0f4603ae7aba1a6b72a40013a83518601d08cd8..21ba95f34ed6e1a0d7bec77b13ef643916d2115d 100644 (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
index 5609e3b59024c819f4c58573fc3e613fc04ee576..27b21b08d718c5498a09aa740ffc235aae1c3bde 100644 (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);
 }
 
index 20c0baa596465563871a102567f7dca42177d241..c440109b34e65d94cb914db11e3744d2bdeea610 100644 (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);
 }
index b2cff21677bb838bb97a0bb795a045c9c28988b3..eb2dd737f94c883b1995e4705eaff3e176c8eeb2 100644 (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)
+    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
index 8792cb47c37ef196b6ff2b8e612c7ba141ecb459..4c9b1375f288b839b7a65186948c92c01f5ab828 100644 (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;
        }
     }
index 484fd19340aa4612f147c1d1677dd8e5159ed7bb..1e748eeca7a610da4a965fc82ac4d81a4f96d728 100644 (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);
 
 /*
index d7f3b59a36e32c9535a797b371f48bbcd4b526b4..21b854b92b6f840cc56df61c9d7df4cacca7ad68 100644 (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 */
index 91acade3c8daea53b3edaf1c2f0adfd82aa73f3c..50f24947f45af39f37847e363d91e89bc6755764 100644 (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:
index 61d97a9a404e866a774ee2671b23803d33de9b3a..172b1dd846f7c681123140d469e1c5534a22adb1 100644 (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,15 +319,19 @@ 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()) {
-       use_window(stdscr, draw_worm, arg);
+       while (compare < sequence) {
+           ++compare;
+           use_window(stdscr, draw_worm, arg);
+       }
     }
     return NULL;
 }
@@ -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) {