Submitted By: Jim Gifford (patches at jg555 dot com)
Date: 2005-05-12
Initial Package Version: 5.4
Origin: Ncurses Site - Updates/Fixes
Upstream Status: Already Applied
Description: Various Fixes for ncurses
	This patch contains all updates from it's release to
	5-7-2005
	This patch fixes cross-compile issues

 
diff -Naur ncurses-5.4.orig/Ada95/gen/Makefile.in ncurses-5.4/Ada95/gen/Makefile.in
--- ncurses-5.4.orig/Ada95/gen/Makefile.in	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/gen/Makefile.in	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -28,8 +28,7 @@
 #
 #  Author:  Juergen Pfeifer, 1996
 #
-#  Version Control
-#  $Revision: 1.44 $
+#  $Id: Makefile.in,v 1.48 2005/04/23 17:49:06 tom Exp $
 #
 .SUFFIXES:
 
@@ -68,12 +67,10 @@
 CFLAGS_DEFAULT	= $(CFLAGS_@DFT_UPR_MODEL@)
 
 LINK		= $(HOST_CC)
-LD_FLAGS	= @LD_MODEL@ $(LOCAL_LIBS) @LDFLAGS@ @LIBS@ @LOCAL_LDFLAGS2@ $(LDFLAGS)
+LD_FLAGS	= @LD_MODEL@ $(LOCAL_LIBS) @LDFLAGS@ @LIBS@ @LOCAL_LDFLAGS2@ $(LDFLAGS) @TINFO_ARGS2@
 
 RANLIB		= @RANLIB@
 
-LIB_CURSES      = -L../../lib -lncurses@LIB_SUFFIX@
-
 M4		= m4
 M4FLAGS		=
 
@@ -152,7 +149,7 @@
 
 all \
 libs :	$(GEN_TARGETS)
-	@
+	@echo made $@
 
 sources:
 
@@ -184,7 +181,7 @@
 	-@cd $(ADA_OBJECTS) && rm -f $(ALIB)[-.]*
 
 gen$x:	gen.o
-	@ECHO_LINK@ $(LINK) $(CFLAGS_NORMAL) gen.o $(LD_FLAGS) -o $@ $(LIB_CURSES)
+	@ECHO_LINK@ $(LINK) $(CFLAGS_NORMAL) gen.o $(LD_FLAGS) -o $@
 
 gen.o:	$(srcdir)/gen.c
 	$(HOST_CC) $(CFLAGS_NORMAL) -c -o $@ $(srcdir)/gen.c
@@ -431,7 +428,7 @@
 	@rm -rf html
 
 html : adahtml $(HTML_DIR)/table.html
-	@
+	@echo made $@
 
 ###############################################################################
 # The remainder of this file is automatically generated during configuration
diff -Naur ncurses-5.4.orig/Ada95/gen/gen.c ncurses-5.4/Ada95/gen/gen.c
--- ncurses-5.4.orig/Ada95/gen/gen.c	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/gen/gen.c	2005-05-13 04:09:49.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998,2004,2005 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 @@
 
 /*
     Version Control
-    $Revision: 1.36 $
+    $Id: gen.c,v 1.40 2005/01/22 17:03:48 tom Exp $
   --------------------------------------------------------------------------*/
 /*
   This program generates various record structures and constants from the
@@ -55,27 +55,31 @@
 static const char *model = "";
 static int little_endian = 0;
 
-typedef struct {
-  const char *name;
-  unsigned long attr;
-} name_attribute_pair;
+typedef struct
+  {
+    const char *name;
+    unsigned long attr;
+  }
+name_attribute_pair;
 
-static int find_pos (char *s, unsigned len, int *low, int *high)
+static int
+find_pos(char *s, unsigned len, int *low, int *high)
 {
-  unsigned int i,j;
+  unsigned int i, j;
   int l = 0;
 
   *high = -1;
-  *low  = 8*len;
+  *low = 8 * len;
 
-  for(i=0; i < len; i++,s++)
+  for (i = 0; i < len; i++, s++)
     {
       if (*s)
 	{
-	  for(j=0;j<8*sizeof(char);j++)
+	  for (j = 0; j < 8 * sizeof(char); j++)
+
 	    {
-	      if ((( little_endian && ((*s)&0x01)) ||
-		   (!little_endian && ((*s)&0x80))) )
+	      if (((little_endian && ((*s) & 0x01)) ||
+		   (!little_endian && ((*s) & 0x80))))
 		{
 		  if (l > *high)
 		    *high = l;
@@ -102,212 +106,229 @@
  * bit size, i.e. they fit into an (u)int or a (u)short.
  */
 static void
-gen_reps
-(const name_attribute_pair *nap, /* array of name_attribute_pair records */
- const char *name,               /* name of the represented record type  */
- int len,                        /* size of the record in bytes          */
- int bias)
+  gen_reps
+  (const name_attribute_pair * nap,	/* array of name_attribute_pair records */
+   const char *name,		/* name of the represented record type  */
+   int len,			/* size of the record in bytes          */
+   int bias)
 {
-  int i,n,l,cnt = 0,low,high;
+  int i, n, l, cnt = 0, low, high;
   int width = strlen(RES_NAME) + 3;
   unsigned long a;
   unsigned long mask = 0;
 
-  assert (nap!=NULL);
+  assert(nap != NULL);
 
-  for (i=0; nap[i].name != (char *)0; i++)
+  for (i = 0; nap[i].name != (char *)0; i++)
     {
       cnt++;
       l = strlen(nap[i].name);
-      if (l>width)
+      if (l > width)
 	width = l;
     }
-  assert (width > 0);
+  assert(width > 0);
 
-  printf("   type %s is\n",name);
+  printf("   type %s is\n", name);
   printf("      record\n");
-  for (i=0; nap[i].name != (char *)0; i++)
+  for (i = 0; nap[i].name != (char *)0; i++)
     {
-      printf("         %-*s : Boolean;\n",width,nap[i].name);
+      printf("         %-*s : Boolean;\n", width, nap[i].name);
     }
   printf("      end record;\n");
-  printf("   pragma Pack (%s);\n",name);
-  printf("   pragma Convention (C, %s);\n\n",name);
+  printf("   pragma Convention (C, %s);\n\n", name);
 
-  printf("   for %s use\n",name);
+  printf("   for %s use\n", name);
   printf("      record\n");
 
-  for (i=0; nap[i].name != (char *)0; i++)
+  for (i = 0; nap[i].name != (char *)0; i++)
     {
       a = nap[i].attr;
       mask |= a;
-      l = find_pos( (char *)&a,sizeof(a),&low,&high );
-      if (l>=0)
-	printf("         %-*s at 0 range %2d .. %2d;\n",width,nap[i].name,
-	       low-bias,high-bias);
+      l = find_pos((char *)&a, sizeof(a), &low, &high);
+      if (l >= 0)
+	printf("         %-*s at 0 range %2d .. %2d;\n", width, nap[i].name,
+	       low - bias, high - bias);
     }
-  i = 1; n = cnt;
+  i = 1;
+  n = cnt;
   printf("      end record;\n");
-  printf("   for %s'Size use %d;\n", name, 8*len);
+  printf("   for %s'Size use %d;\n", name, 8 * len);
   printf("   --  Please note: this rep. clause is generated and may be\n");
   printf("   --               different on your system.");
 }
 
-
-static void chtype_rep (const char *name, attr_t mask)
+static void
+chtype_rep(const char *name, attr_t mask)
 {
   attr_t x = -1;
   attr_t t = x & mask;
   int low, high;
-  int l = find_pos ((char *)&t, sizeof(t), &low, &high);
-  if (l>=0)
-    printf("         %-5s at 0 range %2d .. %2d;\n",name,low,high);
+  int l = find_pos((char *)&t, sizeof(t), &low, &high);
+
+  if (l >= 0)
+    printf("         %-5s at 0 range %2d .. %2d;\n", name, low, high);
 }
 
-static void gen_chtype_rep(const char *name)
-{
-  printf("   for %s use\n      record\n",name);
-  chtype_rep("Ch",A_CHARTEXT);
-  chtype_rep("Color",A_COLOR);
-  chtype_rep("Attr",(A_ATTRIBUTES&~A_COLOR));
-  printf("      end record;\n   for %s'Size use %ld;\n", name, (long)(8*sizeof(chtype)));
+static void
+gen_chtype_rep(const char *name)
+{
+  printf("   for %s use\n      record\n", name);
+  chtype_rep("Ch", A_CHARTEXT);
+  chtype_rep("Color", A_COLOR);
+  chtype_rep("Attr", (A_ATTRIBUTES & ~A_COLOR));
+  printf("      end record;\n   for %s'Size use %ld;\n",
+	 name, (long)(8 * sizeof(chtype)));
+
   printf("      --  Please note: this rep. clause is generated and may be\n");
   printf("      --               different on your system.\n");
 }
 
-
-static void mrep_rep (const char *name, void *rec)
+static void
+mrep_rep(const char *name, void *rec)
 {
   int low, high;
   int l = find_pos((char *)rec, sizeof(MEVENT), &low, &high);
-  if (l>=0)
-    printf("         %-7s at 0 range %3d .. %3d;\n",name,low,high);
-}
 
+  if (l >= 0)
+    printf("         %-7s at 0 range %3d .. %3d;\n", name, low, high);
+}
 
-static void gen_mrep_rep(const char *name)
+static void
+gen_mrep_rep(const char *name)
 {
   MEVENT x;
 
-  printf("   for %s use\n      record\n",name);
+  printf("   for %s use\n      record\n", name);
 
-  memset(&x,0,sizeof(x));
+  memset(&x, 0, sizeof(x));
   x.id = -1;
-  mrep_rep("Id",&x);
+  mrep_rep("Id", &x);
 
-  memset(&x,0,sizeof(x));
+  memset(&x, 0, sizeof(x));
   x.x = -1;
-  mrep_rep("X",&x);
+  mrep_rep("X", &x);
 
-  memset(&x,0,sizeof(x));
+  memset(&x, 0, sizeof(x));
   x.y = -1;
-  mrep_rep("Y",&x);
+  mrep_rep("Y", &x);
 
-  memset(&x,0,sizeof(x));
+  memset(&x, 0, sizeof(x));
   x.z = -1;
-  mrep_rep("Z",&x);
+  mrep_rep("Z", &x);
 
-  memset(&x,0,sizeof(x));
+  memset(&x, 0, sizeof(x));
   x.bstate = -1;
-  mrep_rep("Bstate",&x);
+  mrep_rep("Bstate", &x);
 
   printf("      end record;\n");
   printf("      --  Please note: this rep. clause is generated and may be\n");
   printf("      --               different on your system.\n");
 }
 
-static void gen_attr_set( const char *name )
+static void
+gen_attr_set(const char *name)
 {
   /* All of the A_xxx symbols are defined in ncurses, but not all are nonzero
    * if "configure --enable-widec" is specified.
    */
-  static const name_attribute_pair nap[] = {
+  static const name_attribute_pair nap[] =
+  {
 #if A_STANDOUT
-    {"Stand_Out",               A_STANDOUT},
+    {"Stand_Out", A_STANDOUT},
 #endif
 #if A_UNDERLINE
-    {"Under_Line",              A_UNDERLINE},
+    {"Under_Line", A_UNDERLINE},
 #endif
 #if A_REVERSE
-    {"Reverse_Video",           A_REVERSE},
+    {"Reverse_Video", A_REVERSE},
 #endif
 #if A_BLINK
-    {"Blink",                   A_BLINK},
+    {"Blink", A_BLINK},
 #endif
 #if A_DIM
-    {"Dim_Character",           A_DIM},
+    {"Dim_Character", A_DIM},
 #endif
 #if A_BOLD
-    {"Bold_Character",          A_BOLD},
+    {"Bold_Character", A_BOLD},
 #endif
 #if A_ALTCHARSET
     {"Alternate_Character_Set", A_ALTCHARSET},
 #endif
 #if A_INVIS
-    {"Invisible_Character",     A_INVIS},
+    {"Invisible_Character", A_INVIS},
 #endif
 #if A_PROTECT
-    {"Protected_Character",     A_PROTECT},
+    {"Protected_Character", A_PROTECT},
 #endif
 #if A_HORIZONTAL
-    {"Horizontal",              A_HORIZONTAL},
+    {"Horizontal", A_HORIZONTAL},
 #endif
 #if A_LEFT
-    {"Left",                    A_LEFT},
+    {"Left", A_LEFT},
 #endif
 #if A_LOW
-    {"Low",                     A_LOW},
+    {"Low", A_LOW},
 #endif
 #if A_RIGHT
-    {"Right",                   A_RIGHT},
+    {"Right", A_RIGHT},
 #endif
 #if A_TOP
-    {"Top",                     A_TOP},
+    {"Top", A_TOP},
 #endif
 #if A_VERTICAL
-    {"Vertical",                A_VERTICAL},
+    {"Vertical", A_VERTICAL},
 #endif
-    {(char *)0,                 0}
+    {(char *)0, 0}
   };
   chtype attr = A_ATTRIBUTES & ~A_COLOR;
-  int start=-1, len=0, i, set;
-  for(i=0;i<(int)(8*sizeof(chtype));i++) {
-    set = attr&1;
-    if (set) {
-      if (start<0)
-	start = i;
-      if (start>=0) {
-	len++;
-      }
+  int start = -1;
+  int len = 0;
+  int i, set;
+  for (i = 0; i < (int)(8 * sizeof(chtype)); i++)
+
+    {
+      set = attr & 1;
+      if (set)
+	{
+	  if (start < 0)
+	    start = i;
+	  if (start >= 0)
+	    {
+	      len++;
+	    }
+	}
+      attr = attr >> 1;
     }
-    attr = attr >> 1;
-  }
-  gen_reps (nap, name, (len+7)/8, little_endian?start:0);
+  gen_reps(nap, name, (len + 7) / 8, little_endian ? start : 0);
 }
 
-static void gen_trace(const char *name)
-{  
-  static const name_attribute_pair nap[] = {
-    {"Times",               TRACE_TIMES},
-    {"Tputs",               TRACE_TPUTS},
-    {"Update",              TRACE_UPDATE},
-    {"Cursor_Move",         TRACE_MOVE},
-    {"Character_Output",    TRACE_CHARPUT},
-    {"Calls",               TRACE_CALLS},
-    {"Virtual_Puts",        TRACE_VIRTPUT},
-    {"Input_Events",        TRACE_IEVENT},
-    {"TTY_State",           TRACE_BITS},
-    {"Internal_Calls",      TRACE_ICALLS},
-    {"Character_Calls",     TRACE_CCALLS},
-    {"Termcap_TermInfo",    TRACE_DATABASE},
-    {(char *)0,                0}
+static void
+gen_trace(const char *name)
+{
+  static const name_attribute_pair nap[] =
+  {
+    {"Times", TRACE_TIMES},
+    {"Tputs", TRACE_TPUTS},
+    {"Update", TRACE_UPDATE},
+    {"Cursor_Move", TRACE_MOVE},
+    {"Character_Output", TRACE_CHARPUT},
+    {"Calls", TRACE_CALLS},
+    {"Virtual_Puts", TRACE_VIRTPUT},
+    {"Input_Events", TRACE_IEVENT},
+    {"TTY_State", TRACE_BITS},
+    {"Internal_Calls", TRACE_ICALLS},
+    {"Character_Calls", TRACE_CCALLS},
+    {"Termcap_TermInfo", TRACE_DATABASE},
+    {(char *)0, 0}
   };
-  gen_reps(nap,name,sizeof(int),0);
+  gen_reps(nap, name, sizeof(int), 0);
 }
 
-static void gen_menu_opt_rep(const char *name)
+static void
+gen_menu_opt_rep(const char *name)
 {
-  static const name_attribute_pair nap[] = {
+  static const name_attribute_pair nap[] =
+  {
 #ifdef O_ONEVALUE
     {"One_Valued", O_ONEVALUE},
 #endif
@@ -328,90 +349,99 @@
 #endif
     {(char *)0, 0}
   };
-  gen_reps (nap, name, sizeof(int),0);
+  gen_reps(nap, name, sizeof(int), 0);
 }
 
-static void gen_item_opt_rep(const char *name)
+static void
+gen_item_opt_rep(const char *name)
 {
-  static const name_attribute_pair nap[] = {
+  static const name_attribute_pair nap[] =
+  {
 #ifdef O_SELECTABLE
     {"Selectable", O_SELECTABLE},
 #endif
-    {(char *)0   , 0}
+    {(char *)0, 0}
   };
-  gen_reps (nap, name, sizeof(int),0);
+  gen_reps(nap, name, sizeof(int), 0);
 }
 
-static void gen_form_opt_rep(const char *name)
+static void
+gen_form_opt_rep(const char *name)
 {
-  static const name_attribute_pair nap[] = {
+  static const name_attribute_pair nap[] =
+  {
 #ifdef O_NL_OVERLOAD
     {"NL_Overload", O_NL_OVERLOAD},
 #endif
 #ifdef O_BS_OVERLOAD
     {"BS_Overload", O_BS_OVERLOAD},
 #endif
-    {(char *)0    , 0}
+    {(char *)0, 0}
   };
-  gen_reps (nap, name, sizeof(int),0);
+  gen_reps(nap, name, sizeof(int), 0);
 }
 
 /*
  * Generate the representation clause for the Field_Option_Set record
  */
-static void gen_field_opt_rep(const char *name)
+static void
+gen_field_opt_rep(const char *name)
 {
-  static const name_attribute_pair nap[] = {
+  static const name_attribute_pair nap[] =
+  {
 #ifdef O_VISIBLE
-    {"Visible",O_VISIBLE},
+    {"Visible", O_VISIBLE},
 #endif
 #ifdef O_ACTIVE
-    {"Active",O_ACTIVE},
+    {"Active", O_ACTIVE},
 #endif
 #ifdef O_PUBLIC
-    {"Public",O_PUBLIC},
+    {"Public", O_PUBLIC},
 #endif
 #ifdef O_EDIT
-    {"Edit",O_EDIT},
+    {"Edit", O_EDIT},
 #endif
 #ifdef O_WRAP
-    {"Wrap",O_WRAP},
+    {"Wrap", O_WRAP},
 #endif
 #ifdef O_BLANK
-    {"Blank",O_BLANK},
+    {"Blank", O_BLANK},
 #endif
 #ifdef O_AUTOSKIP
-    {"Auto_Skip",O_AUTOSKIP},
+    {"Auto_Skip", O_AUTOSKIP},
 #endif
 #ifdef O_NULLOK
-    {"Null_Ok",O_NULLOK},
+    {"Null_Ok", O_NULLOK},
 #endif
 #ifdef O_PASSOK
-    {"Pass_Ok",O_PASSOK},
+    {"Pass_Ok", O_PASSOK},
 #endif
 #ifdef O_STATIC
-    {"Static",O_STATIC},
+    {"Static", O_STATIC},
 #endif
     {(char *)0, 0}
   };
-  gen_reps (nap, name, sizeof(int),0);
+  gen_reps(nap, name, sizeof(int), 0);
 }
 
 /*
  * Generate a single key code constant definition.
  */
-static void keydef(const char *name, const char *old_name, int value, int mode)
+static void
+keydef(const char *name, const char *old_name, int value, int mode)
 {
-  if (mode==0) /* Generate the new name */
-    printf("   %-30s : constant Special_Key_Code := 8#%3o#;\n",name,value);
+  if (mode == 0)		/* Generate the new name */
+    printf("   %-30s : constant Special_Key_Code := 8#%3o#;\n", name, value);
   else
-    { /* generate the old name, but only if it doesn't conflict with the old
-       * name (Ada95 isn't case sensitive!)
-       */
-      const char *s = old_name; const char *t = name;
-      while ( *s && *t && (toupper(*s++) == toupper(*t++)));
+    {				/* generate the old name, but only if it doesn't conflict with the old
+				 * name (Ada95 isn't case sensitive!)
+				 */
+      const char *s = old_name;
+      const char *t = name;
+
+      while (*s && *t && (toupper(*s++) == toupper(*t++)));
       if (*s || *t)
-	printf("   %-16s : Special_Key_Code renames %s;\n",old_name,name);
+	printf("   %-16s : Special_Key_Code renames %s;\n", old_name, name);
     }
 }
 
@@ -422,298 +452,299 @@
  * generated, given that the name wasn't already defined in the "nice"
  * list.
  */
-static void gen_keydefs (int mode)
+static void
+gen_keydefs(int mode)
 {
   char buf[16];
   char obuf[16];
   int i;
 
 #ifdef KEY_CODE_YES
-  keydef("Key_Code_Yes","KEY_CODE_YES",KEY_CODE_YES,mode);
+  keydef("Key_Code_Yes", "KEY_CODE_YES", KEY_CODE_YES, mode);
 #endif
 #ifdef KEY_MIN
-  keydef("Key_Min","KEY_MIN",KEY_MIN,mode);
+  keydef("Key_Min", "KEY_MIN", KEY_MIN, mode);
 #endif
 #ifdef KEY_BREAK
-  keydef("Key_Break","KEY_BREAK",KEY_BREAK,mode);
+  keydef("Key_Break", "KEY_BREAK", KEY_BREAK, mode);
 #endif
 #ifdef KEY_DOWN
-  keydef("Key_Cursor_Down","KEY_DOWN",KEY_DOWN,mode);
+  keydef("Key_Cursor_Down", "KEY_DOWN", KEY_DOWN, mode);
 #endif
 #ifdef KEY_UP
-  keydef("Key_Cursor_Up","KEY_UP",KEY_UP,mode);
+  keydef("Key_Cursor_Up", "KEY_UP", KEY_UP, mode);
 #endif
 #ifdef KEY_LEFT
-  keydef("Key_Cursor_Left","KEY_LEFT",KEY_LEFT,mode);
+  keydef("Key_Cursor_Left", "KEY_LEFT", KEY_LEFT, mode);
 #endif
 #ifdef KEY_RIGHT
-  keydef("Key_Cursor_Right","KEY_RIGHT",KEY_RIGHT,mode);
+  keydef("Key_Cursor_Right", "KEY_RIGHT", KEY_RIGHT, mode);
 #endif
 #ifdef KEY_HOME
-  keydef("Key_Home","KEY_HOME",KEY_HOME,mode);
+  keydef("Key_Home", "KEY_HOME", KEY_HOME, mode);
 #endif
 #ifdef KEY_BACKSPACE
-  keydef("Key_Backspace","KEY_BACKSPACE",KEY_BACKSPACE,mode);
+  keydef("Key_Backspace", "KEY_BACKSPACE", KEY_BACKSPACE, mode);
 #endif
 #ifdef KEY_F0
-  keydef("Key_F0","KEY_F0",KEY_F0,mode);
+  keydef("Key_F0", "KEY_F0", KEY_F0, mode);
 #endif
 #ifdef KEY_F
-  for(i=1;i<=24;i++)
+  for (i = 1; i <= 24; i++)
     {
-      sprintf(buf ,"Key_F%d",i);
-      sprintf(obuf,"KEY_F%d",i);
-      keydef(buf,obuf,KEY_F(i),mode);
+      sprintf(buf, "Key_F%d", i);
+      sprintf(obuf, "KEY_F%d", i);
+      keydef(buf, obuf, KEY_F(i), mode);
     }
 #endif
 #ifdef KEY_DL
-  keydef("Key_Delete_Line","KEY_DL",KEY_DL,mode);
+  keydef("Key_Delete_Line", "KEY_DL", KEY_DL, mode);
 #endif
 #ifdef KEY_IL
-  keydef("Key_Insert_Line","KEY_IL",KEY_IL,mode);
+  keydef("Key_Insert_Line", "KEY_IL", KEY_IL, mode);
 #endif
 #ifdef KEY_DC
-  keydef("Key_Delete_Char","KEY_DC",KEY_DC,mode);
+  keydef("Key_Delete_Char", "KEY_DC", KEY_DC, mode);
 #endif
 #ifdef KEY_IC
-  keydef("Key_Insert_Char","KEY_IC",KEY_IC,mode);
+  keydef("Key_Insert_Char", "KEY_IC", KEY_IC, mode);
 #endif
 #ifdef KEY_EIC
-  keydef("Key_Exit_Insert_Mode","KEY_EIC",KEY_EIC,mode);
+  keydef("Key_Exit_Insert_Mode", "KEY_EIC", KEY_EIC, mode);
 #endif
 #ifdef KEY_CLEAR
-  keydef("Key_Clear_Screen","KEY_CLEAR",KEY_CLEAR,mode);
+  keydef("Key_Clear_Screen", "KEY_CLEAR", KEY_CLEAR, mode);
 #endif
 #ifdef KEY_EOS
-  keydef("Key_Clear_End_Of_Screen","KEY_EOS",KEY_EOS,mode);
+  keydef("Key_Clear_End_Of_Screen", "KEY_EOS", KEY_EOS, mode);
 #endif
 #ifdef KEY_EOL
-  keydef("Key_Clear_End_Of_Line","KEY_EOL",KEY_EOL,mode);
+  keydef("Key_Clear_End_Of_Line", "KEY_EOL", KEY_EOL, mode);
 #endif
 #ifdef KEY_SF
-  keydef("Key_Scroll_1_Forward","KEY_SF",KEY_SF,mode);
+  keydef("Key_Scroll_1_Forward", "KEY_SF", KEY_SF, mode);
 #endif
 #ifdef KEY_SR
-  keydef("Key_Scroll_1_Backward","KEY_SR",KEY_SR,mode);
+  keydef("Key_Scroll_1_Backward", "KEY_SR", KEY_SR, mode);
 #endif
 #ifdef KEY_NPAGE
-  keydef("Key_Next_Page","KEY_NPAGE",KEY_NPAGE,mode);
+  keydef("Key_Next_Page", "KEY_NPAGE", KEY_NPAGE, mode);
 #endif
 #ifdef KEY_PPAGE
-  keydef("Key_Previous_Page","KEY_PPAGE",KEY_PPAGE,mode);
+  keydef("Key_Previous_Page", "KEY_PPAGE", KEY_PPAGE, mode);
 #endif
 #ifdef KEY_STAB
-  keydef("Key_Set_Tab","KEY_STAB",KEY_STAB,mode);
+  keydef("Key_Set_Tab", "KEY_STAB", KEY_STAB, mode);
 #endif
 #ifdef KEY_CTAB
-  keydef("Key_Clear_Tab","KEY_CTAB",KEY_CTAB,mode);
+  keydef("Key_Clear_Tab", "KEY_CTAB", KEY_CTAB, mode);
 #endif
 #ifdef KEY_CATAB
-  keydef("Key_Clear_All_Tabs","KEY_CATAB",KEY_CATAB,mode);
+  keydef("Key_Clear_All_Tabs", "KEY_CATAB", KEY_CATAB, mode);
 #endif
 #ifdef KEY_ENTER
-  keydef("Key_Enter_Or_Send","KEY_ENTER",KEY_ENTER,mode);
+  keydef("Key_Enter_Or_Send", "KEY_ENTER", KEY_ENTER, mode);
 #endif
 #ifdef KEY_SRESET
-  keydef("Key_Soft_Reset","KEY_SRESET",KEY_SRESET,mode);
+  keydef("Key_Soft_Reset", "KEY_SRESET", KEY_SRESET, mode);
 #endif
 #ifdef KEY_RESET
-  keydef("Key_Reset","KEY_RESET",KEY_RESET,mode);
+  keydef("Key_Reset", "KEY_RESET", KEY_RESET, mode);
 #endif
 #ifdef KEY_PRINT
-  keydef("Key_Print","KEY_PRINT",KEY_PRINT,mode);
+  keydef("Key_Print", "KEY_PRINT", KEY_PRINT, mode);
 #endif
 #ifdef KEY_LL
-  keydef("Key_Bottom","KEY_LL",KEY_LL,mode);
+  keydef("Key_Bottom", "KEY_LL", KEY_LL, mode);
 #endif
 #ifdef KEY_A1
-  keydef("Key_Upper_Left_Of_Keypad","KEY_A1",KEY_A1,mode);
+  keydef("Key_Upper_Left_Of_Keypad", "KEY_A1", KEY_A1, mode);
 #endif
 #ifdef KEY_A3
-  keydef("Key_Upper_Right_Of_Keypad","KEY_A3",KEY_A3,mode);
+  keydef("Key_Upper_Right_Of_Keypad", "KEY_A3", KEY_A3, mode);
 #endif
 #ifdef KEY_B2
-  keydef("Key_Center_Of_Keypad","KEY_B2",KEY_B2,mode);
+  keydef("Key_Center_Of_Keypad", "KEY_B2", KEY_B2, mode);
 #endif
 #ifdef KEY_C1
-  keydef("Key_Lower_Left_Of_Keypad","KEY_C1",KEY_C1,mode);
+  keydef("Key_Lower_Left_Of_Keypad", "KEY_C1", KEY_C1, mode);
 #endif
 #ifdef KEY_C3
-  keydef("Key_Lower_Right_Of_Keypad","KEY_C3",KEY_C3,mode);
+  keydef("Key_Lower_Right_Of_Keypad", "KEY_C3", KEY_C3, mode);
 #endif
 #ifdef KEY_BTAB
-  keydef("Key_Back_Tab","KEY_BTAB",KEY_BTAB,mode);
+  keydef("Key_Back_Tab", "KEY_BTAB", KEY_BTAB, mode);
 #endif
 #ifdef KEY_BEG
-  keydef("Key_Beginning","KEY_BEG",KEY_BEG,mode);
+  keydef("Key_Beginning", "KEY_BEG", KEY_BEG, mode);
 #endif
 #ifdef KEY_CANCEL
-  keydef("Key_Cancel","KEY_CANCEL",KEY_CANCEL,mode);
+  keydef("Key_Cancel", "KEY_CANCEL", KEY_CANCEL, mode);
 #endif
 #ifdef KEY_CLOSE
-  keydef("Key_Close","KEY_CLOSE",KEY_CLOSE,mode);
+  keydef("Key_Close", "KEY_CLOSE", KEY_CLOSE, mode);
 #endif
 #ifdef KEY_COMMAND
-  keydef("Key_Command","KEY_COMMAND",KEY_COMMAND,mode);
+  keydef("Key_Command", "KEY_COMMAND", KEY_COMMAND, mode);
 #endif
 #ifdef KEY_COPY
-  keydef("Key_Copy","KEY_COPY",KEY_COPY,mode);
+  keydef("Key_Copy", "KEY_COPY", KEY_COPY, mode);
 #endif
 #ifdef KEY_CREATE
-  keydef("Key_Create","KEY_CREATE",KEY_CREATE,mode);
+  keydef("Key_Create", "KEY_CREATE", KEY_CREATE, mode);
 #endif
 #ifdef KEY_END
-  keydef("Key_End","KEY_END",KEY_END,mode);
+  keydef("Key_End", "KEY_END", KEY_END, mode);
 #endif
 #ifdef KEY_EXIT
-  keydef("Key_Exit","KEY_EXIT",KEY_EXIT,mode);
+  keydef("Key_Exit", "KEY_EXIT", KEY_EXIT, mode);
 #endif
 #ifdef KEY_FIND
-  keydef("Key_Find","KEY_FIND",KEY_FIND,mode);
+  keydef("Key_Find", "KEY_FIND", KEY_FIND, mode);
 #endif
 #ifdef KEY_HELP
-  keydef("Key_Help","KEY_HELP",KEY_HELP,mode);
+  keydef("Key_Help", "KEY_HELP", KEY_HELP, mode);
 #endif
 #ifdef KEY_MARK
-  keydef("Key_Mark","KEY_MARK",KEY_MARK,mode);
+  keydef("Key_Mark", "KEY_MARK", KEY_MARK, mode);
 #endif
 #ifdef KEY_MESSAGE
-  keydef("Key_Message","KEY_MESSAGE",KEY_MESSAGE,mode);
+  keydef("Key_Message", "KEY_MESSAGE", KEY_MESSAGE, mode);
 #endif
 #ifdef KEY_MOVE
-  keydef("Key_Move","KEY_MOVE",KEY_MOVE,mode);
+  keydef("Key_Move", "KEY_MOVE", KEY_MOVE, mode);
 #endif
 #ifdef KEY_NEXT
-  keydef("Key_Next","KEY_NEXT",KEY_NEXT,mode);
+  keydef("Key_Next", "KEY_NEXT", KEY_NEXT, mode);
 #endif
 #ifdef KEY_OPEN
-  keydef("Key_Open","KEY_OPEN",KEY_OPEN,mode);
+  keydef("Key_Open", "KEY_OPEN", KEY_OPEN, mode);
 #endif
 #ifdef KEY_OPTIONS
-  keydef("Key_Options","KEY_OPTIONS",KEY_OPTIONS,mode);
+  keydef("Key_Options", "KEY_OPTIONS", KEY_OPTIONS, mode);
 #endif
 #ifdef KEY_PREVIOUS
-  keydef("Key_Previous","KEY_PREVIOUS",KEY_PREVIOUS,mode);
+  keydef("Key_Previous", "KEY_PREVIOUS", KEY_PREVIOUS, mode);
 #endif
 #ifdef KEY_REDO
-  keydef("Key_Redo","KEY_REDO",KEY_REDO,mode);
+  keydef("Key_Redo", "KEY_REDO", KEY_REDO, mode);
 #endif
 #ifdef KEY_REFERENCE
-  keydef("Key_Reference","KEY_REFERENCE",KEY_REFERENCE,mode);
+  keydef("Key_Reference", "KEY_REFERENCE", KEY_REFERENCE, mode);
 #endif
 #ifdef KEY_REFRESH
-  keydef("Key_Refresh","KEY_REFRESH",KEY_REFRESH,mode);
+  keydef("Key_Refresh", "KEY_REFRESH", KEY_REFRESH, mode);
 #endif
 #ifdef KEY_REPLACE
-  keydef("Key_Replace","KEY_REPLACE",KEY_REPLACE,mode);
+  keydef("Key_Replace", "KEY_REPLACE", KEY_REPLACE, mode);
 #endif
 #ifdef KEY_RESTART
-  keydef("Key_Restart","KEY_RESTART",KEY_RESTART,mode);
+  keydef("Key_Restart", "KEY_RESTART", KEY_RESTART, mode);
 #endif
 #ifdef KEY_RESUME
-  keydef("Key_Resume","KEY_RESUME",KEY_RESUME,mode);
+  keydef("Key_Resume", "KEY_RESUME", KEY_RESUME, mode);
 #endif
 #ifdef KEY_SAVE
-  keydef("Key_Save","KEY_SAVE",KEY_SAVE,mode);
+  keydef("Key_Save", "KEY_SAVE", KEY_SAVE, mode);
 #endif
 #ifdef KEY_SBEG
-  keydef("Key_Shift_Begin","KEY_SBEG",KEY_SBEG,mode);
+  keydef("Key_Shift_Begin", "KEY_SBEG", KEY_SBEG, mode);
 #endif
 #ifdef KEY_SCANCEL
-  keydef("Key_Shift_Cancel","KEY_SCANCEL",KEY_SCANCEL,mode);
+  keydef("Key_Shift_Cancel", "KEY_SCANCEL", KEY_SCANCEL, mode);
 #endif
 #ifdef KEY_SCOMMAND
-  keydef("Key_Shift_Command","KEY_SCOMMAND",KEY_SCOMMAND,mode);
+  keydef("Key_Shift_Command", "KEY_SCOMMAND", KEY_SCOMMAND, mode);
 #endif
 #ifdef KEY_SCOPY
-  keydef("Key_Shift_Copy","KEY_SCOPY",KEY_SCOPY,mode);
+  keydef("Key_Shift_Copy", "KEY_SCOPY", KEY_SCOPY, mode);
 #endif
 #ifdef KEY_SCREATE
-  keydef("Key_Shift_Create","KEY_SCREATE",KEY_SCREATE,mode);
+  keydef("Key_Shift_Create", "KEY_SCREATE", KEY_SCREATE, mode);
 #endif
 #ifdef KEY_SDC
-  keydef("Key_Shift_Delete_Char","KEY_SDC",KEY_SDC,mode);
+  keydef("Key_Shift_Delete_Char", "KEY_SDC", KEY_SDC, mode);
 #endif
 #ifdef KEY_SDL
-  keydef("Key_Shift_Delete_Line","KEY_SDL",KEY_SDL,mode);
+  keydef("Key_Shift_Delete_Line", "KEY_SDL", KEY_SDL, mode);
 #endif
 #ifdef KEY_SELECT
-  keydef("Key_Select","KEY_SELECT",KEY_SELECT,mode);
+  keydef("Key_Select", "KEY_SELECT", KEY_SELECT, mode);
 #endif
 #ifdef KEY_SEND
-  keydef("Key_Shift_End","KEY_SEND",KEY_SEND,mode);
+  keydef("Key_Shift_End", "KEY_SEND", KEY_SEND, mode);
 #endif
 #ifdef KEY_SEOL
-  keydef("Key_Shift_Clear_End_Of_Line","KEY_SEOL",KEY_SEOL,mode);
+  keydef("Key_Shift_Clear_End_Of_Line", "KEY_SEOL", KEY_SEOL, mode);
 #endif
 #ifdef KEY_SEXIT
-  keydef("Key_Shift_Exit","KEY_SEXIT",KEY_SEXIT,mode);
+  keydef("Key_Shift_Exit", "KEY_SEXIT", KEY_SEXIT, mode);
 #endif
 #ifdef KEY_SFIND
-  keydef("Key_Shift_Find","KEY_SFIND",KEY_SFIND,mode);
+  keydef("Key_Shift_Find", "KEY_SFIND", KEY_SFIND, mode);
 #endif
 #ifdef KEY_SHELP
-  keydef("Key_Shift_Help","KEY_SHELP",KEY_SHELP,mode);
+  keydef("Key_Shift_Help", "KEY_SHELP", KEY_SHELP, mode);
 #endif
 #ifdef KEY_SHOME
-  keydef("Key_Shift_Home","KEY_SHOME",KEY_SHOME,mode);
+  keydef("Key_Shift_Home", "KEY_SHOME", KEY_SHOME, mode);
 #endif
 #ifdef KEY_SIC
-  keydef("Key_Shift_Insert_Char","KEY_SIC",KEY_SIC,mode);
+  keydef("Key_Shift_Insert_Char", "KEY_SIC", KEY_SIC, mode);
 #endif
 #ifdef KEY_SLEFT
-  keydef("Key_Shift_Cursor_Left","KEY_SLEFT",KEY_SLEFT,mode);
+  keydef("Key_Shift_Cursor_Left", "KEY_SLEFT", KEY_SLEFT, mode);
 #endif
 #ifdef KEY_SMESSAGE
-  keydef("Key_Shift_Message","KEY_SMESSAGE",KEY_SMESSAGE,mode);
+  keydef("Key_Shift_Message", "KEY_SMESSAGE", KEY_SMESSAGE, mode);
 #endif
 #ifdef KEY_SMOVE
-  keydef("Key_Shift_Move","KEY_SMOVE",KEY_SMOVE,mode);
+  keydef("Key_Shift_Move", "KEY_SMOVE", KEY_SMOVE, mode);
 #endif
 #ifdef KEY_SNEXT
-  keydef("Key_Shift_Next_Page","KEY_SNEXT",KEY_SNEXT,mode);
+  keydef("Key_Shift_Next_Page", "KEY_SNEXT", KEY_SNEXT, mode);
 #endif
 #ifdef KEY_SOPTIONS
-  keydef("Key_Shift_Options","KEY_SOPTIONS",KEY_SOPTIONS,mode);
+  keydef("Key_Shift_Options", "KEY_SOPTIONS", KEY_SOPTIONS, mode);
 #endif
 #ifdef KEY_SPREVIOUS
-  keydef("Key_Shift_Previous_Page","KEY_SPREVIOUS",KEY_SPREVIOUS,mode);
+  keydef("Key_Shift_Previous_Page", "KEY_SPREVIOUS", KEY_SPREVIOUS, mode);
 #endif
 #ifdef KEY_SPRINT
-  keydef("Key_Shift_Print","KEY_SPRINT",KEY_SPRINT,mode);
+  keydef("Key_Shift_Print", "KEY_SPRINT", KEY_SPRINT, mode);
 #endif
 #ifdef KEY_SREDO
-  keydef("Key_Shift_Redo","KEY_SREDO",KEY_SREDO,mode);
+  keydef("Key_Shift_Redo", "KEY_SREDO", KEY_SREDO, mode);
 #endif
 #ifdef KEY_SREPLACE
-  keydef("Key_Shift_Replace","KEY_SREPLACE",KEY_SREPLACE,mode);
+  keydef("Key_Shift_Replace", "KEY_SREPLACE", KEY_SREPLACE, mode);
 #endif
 #ifdef KEY_SRIGHT
-  keydef("Key_Shift_Cursor_Right","KEY_SRIGHT",KEY_SRIGHT,mode);
+  keydef("Key_Shift_Cursor_Right", "KEY_SRIGHT", KEY_SRIGHT, mode);
 #endif
 #ifdef KEY_SRSUME
-  keydef("Key_Shift_Resume","KEY_SRSUME",KEY_SRSUME,mode);
+  keydef("Key_Shift_Resume", "KEY_SRSUME", KEY_SRSUME, mode);
 #endif
 #ifdef KEY_SSAVE
-  keydef("Key_Shift_Save","KEY_SSAVE",KEY_SSAVE,mode);
+  keydef("Key_Shift_Save", "KEY_SSAVE", KEY_SSAVE, mode);
 #endif
 #ifdef KEY_SSUSPEND
-  keydef("Key_Shift_Suspend","KEY_SSUSPEND",KEY_SSUSPEND,mode);
+  keydef("Key_Shift_Suspend", "KEY_SSUSPEND", KEY_SSUSPEND, mode);
 #endif
 #ifdef KEY_SUNDO
-  keydef("Key_Shift_Undo","KEY_SUNDO",KEY_SUNDO,mode);
+  keydef("Key_Shift_Undo", "KEY_SUNDO", KEY_SUNDO, mode);
 #endif
 #ifdef KEY_SUSPEND
-  keydef("Key_Suspend","KEY_SUSPEND",KEY_SUSPEND,mode);
+  keydef("Key_Suspend", "KEY_SUSPEND", KEY_SUSPEND, mode);
 #endif
 #ifdef KEY_UNDO
-  keydef("Key_Undo","KEY_UNDO",KEY_UNDO,mode);
+  keydef("Key_Undo", "KEY_UNDO", KEY_UNDO, mode);
 #endif
 #ifdef KEY_MOUSE
-  keydef("Key_Mouse","KEY_MOUSE",KEY_MOUSE,mode);
+  keydef("Key_Mouse", "KEY_MOUSE", KEY_MOUSE, mode);
 #endif
 #ifdef KEY_RESIZE
-  keydef("Key_Resize","KEY_RESIZE",KEY_RESIZE,mode);
+  keydef("Key_Resize", "KEY_RESIZE", KEY_RESIZE, mode);
 #endif
 }
 
@@ -722,120 +753,122 @@
  * is a reference to the ACS character in the acs_map[] array and
  * will be translated into an index.
  */
-static void acs_def (const char *name, chtype *a)
+static void
+acs_def(const char *name, chtype *a)
 {
   int c = a - &acs_map[0];
-  printf("   %-24s : constant Character := ",name);
-  if (isprint(c) && (c!='`'))
-    printf("'%c';\n",c);
+
+  printf("   %-24s : constant Character := ", name);
+  if (isprint(c) && (c != '`'))
+    printf("'%c';\n", c);
   else
-    printf("Character'Val (%d);\n",c);
+    printf("Character'Val (%d);\n", c);
 }
 
 /*
  * Generate the constants for the ACS characters
  */
-static void gen_acs (void)
+static void
+gen_acs(void)
 {
 #ifdef ACS_ULCORNER
-  acs_def("ACS_Upper_Left_Corner",&ACS_ULCORNER);
+  acs_def("ACS_Upper_Left_Corner", &ACS_ULCORNER);
 #endif
 #ifdef ACS_LLCORNER
-  acs_def("ACS_Lower_Left_Corner",&ACS_LLCORNER);
+  acs_def("ACS_Lower_Left_Corner", &ACS_LLCORNER);
 #endif
 #ifdef ACS_URCORNER
-  acs_def("ACS_Upper_Right_Corner",&ACS_URCORNER);
+  acs_def("ACS_Upper_Right_Corner", &ACS_URCORNER);
 #endif
 #ifdef ACS_LRCORNER
-  acs_def("ACS_Lower_Right_Corner",&ACS_LRCORNER);
+  acs_def("ACS_Lower_Right_Corner", &ACS_LRCORNER);
 #endif
 #ifdef ACS_LTEE
-  acs_def("ACS_Left_Tee",&ACS_LTEE);
+  acs_def("ACS_Left_Tee", &ACS_LTEE);
 #endif
 #ifdef ACS_RTEE
-  acs_def("ACS_Right_Tee",&ACS_RTEE);
+  acs_def("ACS_Right_Tee", &ACS_RTEE);
 #endif
 #ifdef ACS_BTEE
-  acs_def("ACS_Bottom_Tee",&ACS_BTEE);
+  acs_def("ACS_Bottom_Tee", &ACS_BTEE);
 #endif
 #ifdef ACS_TTEE
-  acs_def("ACS_Top_Tee",&ACS_TTEE);
+  acs_def("ACS_Top_Tee", &ACS_TTEE);
 #endif
 #ifdef ACS_HLINE
-  acs_def("ACS_Horizontal_Line",&ACS_HLINE);
+  acs_def("ACS_Horizontal_Line", &ACS_HLINE);
 #endif
 #ifdef ACS_VLINE
-  acs_def("ACS_Vertical_Line",&ACS_VLINE);
+  acs_def("ACS_Vertical_Line", &ACS_VLINE);
 #endif
 #ifdef ACS_PLUS
-  acs_def("ACS_Plus_Symbol",&ACS_PLUS);
+  acs_def("ACS_Plus_Symbol", &ACS_PLUS);
 #endif
 #ifdef ACS_S1
-  acs_def("ACS_Scan_Line_1",&ACS_S1);
+  acs_def("ACS_Scan_Line_1", &ACS_S1);
 #endif
 #ifdef ACS_S9
-  acs_def("ACS_Scan_Line_9",&ACS_S9);
+  acs_def("ACS_Scan_Line_9", &ACS_S9);
 #endif
 #ifdef ACS_DIAMOND
-  acs_def("ACS_Diamond",&ACS_DIAMOND);
+  acs_def("ACS_Diamond", &ACS_DIAMOND);
 #endif
 #ifdef ACS_CKBOARD
-  acs_def("ACS_Checker_Board",&ACS_CKBOARD);
+  acs_def("ACS_Checker_Board", &ACS_CKBOARD);
 #endif
 #ifdef ACS_DEGREE
-  acs_def("ACS_Degree",&ACS_DEGREE);
+  acs_def("ACS_Degree", &ACS_DEGREE);
 #endif
 #ifdef ACS_PLMINUS
-  acs_def("ACS_Plus_Minus",&ACS_PLMINUS);
+  acs_def("ACS_Plus_Minus", &ACS_PLMINUS);
 #endif
 #ifdef ACS_BULLET
-  acs_def("ACS_Bullet",&ACS_BULLET);
+  acs_def("ACS_Bullet", &ACS_BULLET);
 #endif
 #ifdef ACS_LARROW
-  acs_def("ACS_Left_Arrow",&ACS_LARROW);
+  acs_def("ACS_Left_Arrow", &ACS_LARROW);
 #endif
 #ifdef ACS_RARROW
-  acs_def("ACS_Right_Arrow",&ACS_RARROW);
+  acs_def("ACS_Right_Arrow", &ACS_RARROW);
 #endif
 #ifdef ACS_DARROW
-  acs_def("ACS_Down_Arrow",&ACS_DARROW);
+  acs_def("ACS_Down_Arrow", &ACS_DARROW);
 #endif
 #ifdef ACS_UARROW
-  acs_def("ACS_Up_Arrow",&ACS_UARROW);
+  acs_def("ACS_Up_Arrow", &ACS_UARROW);
 #endif
 #ifdef ACS_BOARD
-  acs_def("ACS_Board_Of_Squares",&ACS_BOARD);
+  acs_def("ACS_Board_Of_Squares", &ACS_BOARD);
 #endif
 #ifdef ACS_LANTERN
-  acs_def("ACS_Lantern",&ACS_LANTERN);
+  acs_def("ACS_Lantern", &ACS_LANTERN);
 #endif
 #ifdef ACS_BLOCK
-  acs_def("ACS_Solid_Block",&ACS_BLOCK);
+  acs_def("ACS_Solid_Block", &ACS_BLOCK);
 #endif
 #ifdef ACS_S3
-  acs_def("ACS_Scan_Line_3",&ACS_S3);
+  acs_def("ACS_Scan_Line_3", &ACS_S3);
 #endif
 #ifdef ACS_S7
-  acs_def("ACS_Scan_Line_7",&ACS_S7);
+  acs_def("ACS_Scan_Line_7", &ACS_S7);
 #endif
 #ifdef ACS_LEQUAL
-  acs_def("ACS_Less_Or_Equal",&ACS_LEQUAL);
+  acs_def("ACS_Less_Or_Equal", &ACS_LEQUAL);
 #endif
 #ifdef ACS_GEQUAL
-  acs_def("ACS_Greater_Or_Equal",&ACS_GEQUAL);
+  acs_def("ACS_Greater_Or_Equal", &ACS_GEQUAL);
 #endif
 #ifdef ACS_PI
-  acs_def("ACS_PI",&ACS_PI);
+  acs_def("ACS_PI", &ACS_PI);
 #endif
 #ifdef ACS_NEQUAL
-  acs_def("ACS_Not_Equal",&ACS_NEQUAL);
+  acs_def("ACS_Not_Equal", &ACS_NEQUAL);
 #endif
 #ifdef ACS_STERLING
-  acs_def("ACS_Sterling",&ACS_STERLING);
+  acs_def("ACS_Sterling", &ACS_STERLING);
 #endif
 }
 
-
 #define GEN_EVENT(name,value) \
    printf("   %-25s : constant Event_Mask := 8#%011lo#;\n", \
           #name, value)
@@ -845,7 +878,8 @@
           #name, name)
 
 static
-void gen_mouse_events(void)
+void
+gen_mouse_events(void)
 {
   mmask_t all1 = 0;
   mmask_t all2 = 0;
@@ -959,15 +993,15 @@
 #endif
 #ifdef REPORT_MOUSE_POSITION
   GEN_MEVENT(REPORT_MOUSE_POSITION);
-#endif   
+#endif
 #ifdef ALL_MOUSE_EVENTS
   GEN_MEVENT(ALL_MOUSE_EVENTS);
 #endif
 
-GEN_EVENT(BUTTON1_EVENTS,all1);
-GEN_EVENT(BUTTON2_EVENTS,all2);
-GEN_EVENT(BUTTON3_EVENTS,all3);
-GEN_EVENT(BUTTON4_EVENTS,all4);
+  GEN_EVENT(BUTTON1_EVENTS, all1);
+  GEN_EVENT(BUTTON2_EVENTS, all2);
+  GEN_EVENT(BUTTON3_EVENTS, all3);
+  GEN_EVENT(BUTTON4_EVENTS, all4);
 }
 
 /*
@@ -975,41 +1009,45 @@
  * The name parameter is the name of the facility to be used in
  * the comment.
  */
-static void prologue(const char *name)
+static void
+prologue(const char *name)
 {
-  printf("--  %s binding.\n",name);
+  printf("--  %s binding.\n", name);
   printf("--  This module is generated. Please don't change it manually!\n");
   printf("--  Run the generator instead.\n--  |");
 
   printf("define(`M4_BIT_ORDER',`%s_Order_First')",
-	 little_endian ? "Low":"High");
+	 little_endian ? "Low" : "High");
 }
 
 /*
  * Write the prologue for the curses facility and make sure that
  * KEY_MIN and KEY_MAX are defined for the rest of this source.
  */
-static void basedefs (void)
+static void
+basedefs(void)
 {
   prologue("curses");
 #ifndef KEY_MAX
 #  define KEY_MAX 0777
 #endif
-  printf("define(`M4_KEY_MAX',`8#%o#')",KEY_MAX);
+  printf("define(`M4_KEY_MAX',`8#%o#')", KEY_MAX);
 #ifndef KEY_MIN
 #  define KEY_MIN 0401
 #endif
-  if (KEY_MIN == 256) {
-    fprintf(stderr,"Unexpected value for KEY_MIN: %d\n",KEY_MIN);
-    exit(1);
-  }
-  printf("define(`M4_SPECIAL_FIRST',`8#%o#')",KEY_MIN - 1);
+  if (KEY_MIN == 256)
+    {
+      fprintf(stderr, "Unexpected value for KEY_MIN: %d\n", KEY_MIN);
+      exit(1);
+    }
+  printf("define(`M4_SPECIAL_FIRST',`8#%o#')", KEY_MIN - 1);
 }
 
 /*
  * Write out the comment lines for the menu facility
  */
-static void menu_basedefs (void)
+static void
+menu_basedefs(void)
 {
   prologue("menu");
 }
@@ -1017,7 +1055,8 @@
 /*
  * Write out the comment lines for the form facility
  */
-static void form_basedefs (void)
+static void
+form_basedefs(void)
 {
   prologue("form");
 }
@@ -1025,7 +1064,8 @@
 /*
  * Write out the comment lines for the mouse facility
  */
-static void mouse_basedefs(void)
+static void
+mouse_basedefs(void)
 {
   prologue("mouse");
 }
@@ -1033,9 +1073,10 @@
 /*
  * Write the definition of a single color
  */
-static void color_def (const char *name, int value)
+static void
+color_def(const char *name, int value)
 {
-  printf("   %-16s : constant Color_Number := %d;\n",name,value);
+  printf("   %-16s : constant Color_Number := %d;\n", name, value);
 }
 
 #define HAVE_USE_DEFAULT_COLORS 1
@@ -1043,87 +1084,93 @@
 /*
  * Generate all color definitions
  */
-static void gen_color (void)
+static void
+gen_color(void)
 {
 #ifdef HAVE_USE_DEFAULT_COLORS
-  color_def ("Default_Color",-1);
+  color_def("Default_Color", -1);
 #endif
 #ifdef COLOR_BLACK
-  color_def ("Black",COLOR_BLACK);
+  color_def("Black", COLOR_BLACK);
 #endif
 #ifdef COLOR_RED
-  color_def ("Red",COLOR_RED);
+  color_def("Red", COLOR_RED);
 #endif
 #ifdef COLOR_GREEN
-  color_def ("Green",COLOR_GREEN);
+  color_def("Green", COLOR_GREEN);
 #endif
 #ifdef COLOR_YELLOW
-  color_def ("Yellow",COLOR_YELLOW);
+  color_def("Yellow", COLOR_YELLOW);
 #endif
 #ifdef COLOR_BLUE
-  color_def ("Blue",COLOR_BLUE);
+  color_def("Blue", COLOR_BLUE);
 #endif
 #ifdef COLOR_MAGENTA
-  color_def ("Magenta",COLOR_MAGENTA);
+  color_def("Magenta", COLOR_MAGENTA);
 #endif
 #ifdef COLOR_CYAN
-  color_def ("Cyan",COLOR_CYAN);
+  color_def("Cyan", COLOR_CYAN);
 #endif
 #ifdef COLOR_WHITE
-  color_def ("White",COLOR_WHITE);
+  color_def("White", COLOR_WHITE);
 #endif
 }
 
 /*
  * Generate the linker options for the base facility
  */
-static void gen_linkopts (void)
+static void
+gen_linkopts(void)
 {
-   printf("   pragma Linker_Options (\"-lncurses%s\");\n", model);
+  printf("   pragma Linker_Options (\"-lncurses%s\");\n", model);
 }
 
 /*
  * Generate the linker options for the menu facility
  */
-static void gen_menu_linkopts (void)
+static void
+gen_menu_linkopts(void)
 {
-   printf("   pragma Linker_Options (\"-lmenu%s\");\n", model);
+  printf("   pragma Linker_Options (\"-lmenu%s\");\n", model);
 }
 
 /*
  * Generate the linker options for the form facility
  */
-static void gen_form_linkopts (void)
+static void
+gen_form_linkopts(void)
 {
-   printf("   pragma Linker_Options (\"-lform%s\");\n", model);
+  printf("   pragma Linker_Options (\"-lform%s\");\n", model);
 }
 
 /*
  * Generate the linker options for the panel facility
  */
-static void gen_panel_linkopts (void)
+static void
+gen_panel_linkopts(void)
 {
-   printf("   pragma Linker_Options (\"-lpanel%s\");\n", model);
+  printf("   pragma Linker_Options (\"-lpanel%s\");\n", model);
 }
 
-static void gen_version_info (void)
+static void
+gen_version_info(void)
 {
-  static const char* v1 =
-    "   NC_Major_Version : constant := %d; --  Major version of the library\n";
-  static const char* v2 =
-    "   NC_Minor_Version : constant := %d; --  Minor version of the library\n";
-  static const char* v3 =
-    "   NC_Version : constant String := %c%d.%d%c;  --  Version of library\n";
+  static const char *v1 =
+  "   NC_Major_Version : constant := %d; --  Major version of the library\n";
+  static const char *v2 =
+  "   NC_Minor_Version : constant := %d; --  Minor version of the library\n";
+  static const char *v3 =
+  "   NC_Version : constant String := %c%d.%d%c;  --  Version of library\n";
 
   printf(v1, NCURSES_VERSION_MAJOR);
   printf(v2, NCURSES_VERSION_MINOR);
-  printf(v3, '"',NCURSES_VERSION_MAJOR,NCURSES_VERSION_MINOR,'"');
+  printf(v3, '"', NCURSES_VERSION_MAJOR, NCURSES_VERSION_MINOR, '"');
 }
 
 static int
-eti_gen(char*buf, int code, const char* name, int* etimin, int* etimax)
+eti_gen(char *buf, int code, const char *name, int *etimin, int *etimax)
 {
-  sprintf(buf,"   E_%-16s : constant Eti_Error := %d;\n",name,code);
+  sprintf(buf, "   E_%-16s : constant Eti_Error := %d;\n", name, code);
   if (code < *etimin)
     *etimin = code;
   if (code > *etimax)
@@ -1136,68 +1183,77 @@
     o = offsetof(WINDOW, member);                                   \
     if ((o%sizeof(itype) == 0)) {                                   \
        printf("   Offset%-*s : constant Natural := %2ld; --  %s\n", \
-              12, #member, o/sizeof(itype),#itype);                 \
+              12, #member, (long)(o/sizeof(itype)),#itype);         \
     }                                                               \
   }
-  
+
 static void
 gen_offsets(void)
 {
   long o;
-  const char* s_bool = "";
+  const char *s_bool = "";
 
-  GEN_OFFSET(_maxy,short);
-  GEN_OFFSET(_maxx,short);
-  GEN_OFFSET(_begy,short);
-  GEN_OFFSET(_begx,short);
-  GEN_OFFSET(_cury,short);
-  GEN_OFFSET(_curx,short);
-  GEN_OFFSET(_yoffset,short);
-  GEN_OFFSET(_pary,int);
-  GEN_OFFSET(_parx,int);
-  if (sizeof(bool) == sizeof(char)) {
-    GEN_OFFSET(_notimeout,char);
-    GEN_OFFSET(_clear,char);
-    GEN_OFFSET(_leaveok,char);
-    GEN_OFFSET(_scroll,char);
-    GEN_OFFSET(_idlok,char);
-    GEN_OFFSET(_idcok,char);
-    GEN_OFFSET(_immed,char);
-    GEN_OFFSET(_sync,char);
-    GEN_OFFSET(_use_keypad,char);
-    s_bool = "char";
-  } else if (sizeof(bool) == sizeof(short)) {
-    GEN_OFFSET(_notimeout,short);
-    GEN_OFFSET(_clear,short);
-    GEN_OFFSET(_leaveok,short);
-    GEN_OFFSET(_scroll,short);
-    GEN_OFFSET(_idlok,short);
-    GEN_OFFSET(_idcok,short);
-    GEN_OFFSET(_immed,short);
-    GEN_OFFSET(_sync,short);
-    GEN_OFFSET(_use_keypad,short);
-    s_bool = "short";
-  } else if (sizeof(bool) == sizeof(int)) {
-    GEN_OFFSET(_notimeout,int);
-    GEN_OFFSET(_clear,int);
-    GEN_OFFSET(_leaveok,int);
-    GEN_OFFSET(_scroll,int);
-    GEN_OFFSET(_idlok,int);
-    GEN_OFFSET(_idcok,int);
-    GEN_OFFSET(_immed,int);
-    GEN_OFFSET(_sync,int);
-    GEN_OFFSET(_use_keypad,int);
-    s_bool = "int";
-  }
+  GEN_OFFSET(_maxy, short);
+  GEN_OFFSET(_maxx, short);
+  GEN_OFFSET(_begy, short);
+  GEN_OFFSET(_begx, short);
+  GEN_OFFSET(_cury, short);
+  GEN_OFFSET(_curx, short);
+  GEN_OFFSET(_yoffset, short);
+  GEN_OFFSET(_pary, int);
+  GEN_OFFSET(_parx, int);
+  if (sizeof(bool) == sizeof(char))
+    {
+      GEN_OFFSET(_notimeout, char);
+      GEN_OFFSET(_clear, char);
+      GEN_OFFSET(_leaveok, char);
+      GEN_OFFSET(_scroll, char);
+      GEN_OFFSET(_idlok, char);
+      GEN_OFFSET(_idcok, char);
+      GEN_OFFSET(_immed, char);
+      GEN_OFFSET(_sync, char);
+      GEN_OFFSET(_use_keypad, char);
+
+      s_bool = "char";
+    }
+  else if (sizeof(bool) == sizeof(short))
+    {
+      GEN_OFFSET(_notimeout, short);
+      GEN_OFFSET(_clear, short);
+      GEN_OFFSET(_leaveok, short);
+      GEN_OFFSET(_scroll, short);
+      GEN_OFFSET(_idlok, short);
+      GEN_OFFSET(_idcok, short);
+      GEN_OFFSET(_immed, short);
+      GEN_OFFSET(_sync, short);
+      GEN_OFFSET(_use_keypad, short);
+
+      s_bool = "short";
+    }
+  else if (sizeof(bool) == sizeof(int))
+    {
+      GEN_OFFSET(_notimeout, int);
+      GEN_OFFSET(_clear, int);
+      GEN_OFFSET(_leaveok, int);
+      GEN_OFFSET(_scroll, int);
+      GEN_OFFSET(_idlok, int);
+      GEN_OFFSET(_idcok, int);
+      GEN_OFFSET(_immed, int);
+      GEN_OFFSET(_sync, int);
+      GEN_OFFSET(_use_keypad, int);
+
+      s_bool = "int";
+    }
   printf("   Sizeof%-*s : constant Natural := %2ld; --  %s\n",
-	 12, "_bool", (long) sizeof(bool),"bool");
+	 12, "_bool", (long)sizeof(bool), "bool");
+
   /* In ncurses _maxy and _maxx needs an offset for the "public"
    * value
    */
   printf("   Offset%-*s : constant Natural := %2d; --  %s\n",
-	 12, "_XY",1,"int");
+	 12, "_XY", 1, "int");
   printf("\n");
-  printf("   type Curses_Bool is mod 2 ** Interfaces.C.%s'Size;\n",s_bool);
+  printf("   type Curses_Bool is mod 2 ** Interfaces.C.%s'Size;\n", s_bool);
 }
 
 /*
@@ -1213,7 +1269,8 @@
  * The second character then denotes the specific output that should be
  * generated for the selected facility.
  */
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
   int x = 0x12345678;
   char *s = (char *)&x;
@@ -1221,216 +1278,226 @@
   if (*s == 0x78)
     little_endian = 1;
 
-  if (argc!=4)
+  if (argc != 4)
     exit(1);
   model = *++argv;
 
-  switch(argv[1][0])
+  switch (argv[1][0])
     {
-      /* ---------------------------------------------------------------*/   
-    case 'B': /* The Base facility */
-      switch(argv[2][0])
+      /* --------------------------------------------------------------- */
+    case 'B':			/* The Base facility */
+      switch (argv[2][0])
 	{
-	case 'A': /* chtype translation into Ada95 record type */
+	case 'A':		/* chtype translation into Ada95 record type */
 	  gen_attr_set("Character_Attribute_Set");
 	  break;
-	case 'K': /* translation of keycodes */
+	case 'K':		/* translation of keycodes */
 	  gen_keydefs(0);
 	  break;
-	case 'B': /* write some initial comment lines */
+	case 'B':		/* write some initial comment lines */
 	  basedefs();
 	  break;
-	case 'C': /* generate color constants */
+	case 'C':		/* generate color constants */
 	  gen_color();
 	  break;
-	case 'D': /* generate displacements of fields in WINDOW struct. */
+	case 'D':		/* generate displacements of fields in WINDOW struct. */
 	  gen_offsets();
 	  break;
-	case 'E': /* generate Mouse Event codes */
+	case 'E':		/* generate Mouse Event codes */
 	  gen_mouse_events();
 	  break;
-	case 'M': /* generate constants for the ACS characters */
+	case 'M':		/* generate constants for the ACS characters */
 	  gen_acs();
 	  break;
-	case 'L': /* generate the Linker_Options pragma */
+	case 'L':		/* generate the Linker_Options pragma */
 	  gen_linkopts();
 	  break;
-	case 'O': /* generate definitions of the old key code names */
+	case 'O':		/* generate definitions of the old key code names */
 	  gen_keydefs(1);
 	  break;
-	case 'R': /* generate representation clause for Attributed character */
+	case 'R':		/* generate representation clause for Attributed character */
 	  gen_chtype_rep("Attributed_Character");
 	  break;
-	case 'V': /* generate version info */
+	case 'V':		/* generate version info */
 	  gen_version_info();
 	  break;
-	case 'T': /* generate the Trace info */
+	case 'T':		/* generate the Trace info */
 	  gen_trace("Trace_Attribute_Set");
 	  break;
 	default:
 	  break;
 	}
       break;
-      /* ---------------------------------------------------------------*/   
-    case 'M': /* The Menu facility */
-      switch(argv[2][0])
+      /* --------------------------------------------------------------- */
+    case 'M':			/* The Menu facility */
+      switch (argv[2][0])
 	{
-	case 'R': /* generate representation clause for Menu_Option_Set */
+	case 'R':		/* generate representation clause for Menu_Option_Set */
 	  gen_menu_opt_rep("Menu_Option_Set");
 	  break;
-	case 'B': /* write some initial comment lines */
+	case 'B':		/* write some initial comment lines */
 	  menu_basedefs();
 	  break;
-	case 'L': /* generate the Linker_Options pragma */
+	case 'L':		/* generate the Linker_Options pragma */
 	  gen_menu_linkopts();
 	  break;
-	case 'I': /* generate representation clause for Item_Option_Set */
+	case 'I':		/* generate representation clause for Item_Option_Set */
 	  gen_item_opt_rep("Item_Option_Set");
 	  break;
 	default:
 	  break;
 	}
       break;
-      /* ---------------------------------------------------------------*/   
-    case 'F': /* The Form facility */
-      switch(argv[2][0])
+      /* --------------------------------------------------------------- */
+    case 'F':			/* The Form facility */
+      switch (argv[2][0])
 	{
-	case 'R': /* generate representation clause for Form_Option_Set */
+	case 'R':		/* generate representation clause for Form_Option_Set */
 	  gen_form_opt_rep("Form_Option_Set");
 	  break;
-	case 'B': /* write some initial comment lines */
+	case 'B':		/* write some initial comment lines */
 	  form_basedefs();
 	  break;
-	case 'L': /* generate the Linker_Options pragma */
+	case 'L':		/* generate the Linker_Options pragma */
 	  gen_form_linkopts();
 	  break;
-	case 'I': /* generate representation clause for Field_Option_Set */
+	case 'I':		/* generate representation clause for Field_Option_Set */
 	  gen_field_opt_rep("Field_Option_Set");
 	  break;
 	default:
 	  break;
 	}
       break;
-      /* ---------------------------------------------------------------*/   
-    case 'P': /* The Pointer(=Mouse) facility */
-      switch(argv[2][0]) {
-	case 'B': /* write some initial comment lines */
+      /* --------------------------------------------------------------- */
+    case 'P':			/* The Pointer(=Mouse) facility */
+      switch (argv[2][0])
+	{
+	case 'B':		/* write some initial comment lines */
 	  mouse_basedefs();
 	  break;
-	case 'M': /* generate representation clause for Mouse_Event */
+	case 'M':		/* generate representation clause for Mouse_Event */
 	  gen_mrep_rep("Mouse_Event");
 	  break;
-	case 'L': /* generate the Linker_Options pragma */
+	case 'L':		/* generate the Linker_Options pragma */
 	  gen_panel_linkopts();
 	  break;
 	default:
 	  break;
 	}
-	break;
-      /* ---------------------------------------------------------------*/   
-    case 'E' : /* chtype size detection */
-      switch(argv[2][0]) {
-      case 'C':
+      break;
+      /* --------------------------------------------------------------- */
+    case 'E':			/* chtype size detection */
+      switch (argv[2][0])
 	{
-	  const char* fmt  = "   type    C_Chtype   is new %s;\n";
-	  const char* afmt = "   type    C_AttrType is new %s;\n";
-
-	  if (sizeof(chtype)==sizeof(int)) {
-	    if (sizeof(int)==sizeof(long))
-	      printf(fmt,"C_ULong");
+	case 'C':
+	  {
+	    const char *fmt = "   type    C_Chtype   is new %s;\n";
+	    const char *afmt = "   type    C_AttrType is new %s;\n";
+
+	    if (sizeof(chtype) == sizeof(int))
+	      {
+		if (sizeof(int) == sizeof(long))
+		    printf(fmt, "C_ULong");
+
+		else
+		  printf(fmt, "C_UInt");
+	      }
+	    else if (sizeof(chtype) == sizeof(long))
+	      {
+		printf(fmt, "C_ULong");
+	      }
 	    else
-	      printf(fmt,"C_UInt");
-	  }
-	  else if (sizeof(chtype)==sizeof(long)) {
-	    printf(fmt,"C_ULong");
-	  }
-	  else
-	    printf("Error\n");
+	      printf("Error\n");
 
-	  if (sizeof(attr_t)==sizeof(int)) {
-	    if (sizeof(int)==sizeof(long))
-	      printf(afmt,"C_ULong");
+	    if (sizeof(attr_t) == sizeof(int))
+	      {
+		if (sizeof(int) == sizeof(long))
+		    printf(afmt, "C_ULong");
+
+		else
+		  printf(afmt, "C_UInt");
+	      }
+	    else if (sizeof(attr_t) == sizeof(long))
+	      {
+		printf(afmt, "C_ULong");
+	      }
 	    else
-	      printf(afmt,"C_UInt");
-	  }
-	  else if (sizeof(attr_t)==sizeof(long)) {
-	    printf(afmt,"C_ULong");
-	  }
-	  else
-	    printf("Error\n");
+	      printf("Error\n");
 
-	  printf("define(`CF_CURSES_OK',`%d')",OK);
-	  printf("define(`CF_CURSES_ERR',`%d')",ERR);
-	  printf("define(`CF_CURSES_TRUE',`%d')",TRUE);
-	  printf("define(`CF_CURSES_FALSE',`%d')",FALSE);
-	}
-	break;
-      case 'E':
-	{
-	  char* buf  = (char*)malloc(2048);
-	  char* p    = buf;
-	  int etimin = E_OK;
-	  int etimax = E_OK;
-	  if (p) {
-	    p += eti_gen(p, E_OK, "Ok", &etimin, &etimax);
-	    p += eti_gen(p, E_SYSTEM_ERROR,"System_Error", &etimin, &etimax);
-	    p += eti_gen(p, E_BAD_ARGUMENT, "Bad_Argument", &etimin, &etimax);
-	    p += eti_gen(p, E_POSTED, "Posted", &etimin, &etimax);
-	    p += eti_gen(p, E_CONNECTED, "Connected", &etimin, &etimax);
-	    p += eti_gen(p, E_BAD_STATE, "Bad_State", &etimin, &etimax);
-	    p += eti_gen(p, E_NO_ROOM, "No_Room", &etimin, &etimax);
-	    p += eti_gen(p, E_NOT_POSTED, "Not_Posted", &etimin, &etimax);
-	    p += eti_gen(p, E_UNKNOWN_COMMAND,
-			 "Unknown_Command", &etimin, &etimax);
-	    p += eti_gen(p, E_NO_MATCH, "No_Match", &etimin, &etimax);
-	    p += eti_gen(p, E_NOT_SELECTABLE,
-			 "Not_Selectable", &etimin, &etimax);
-	    p += eti_gen(p, E_NOT_CONNECTED,
-			 "Not_Connected", &etimin, &etimax);
-	    p += eti_gen(p, E_REQUEST_DENIED,
-			 "Request_Denied", &etimin, &etimax);
-	    p += eti_gen(p, E_INVALID_FIELD,
-			 "Invalid_Field", &etimin, &etimax);
-	    p += eti_gen(p, E_CURRENT,
-			 "Current", &etimin, &etimax);
+	    printf("define(`CF_CURSES_OK',`%d')", OK);
+	    printf("define(`CF_CURSES_ERR',`%d')", ERR);
+	    printf("define(`CF_CURSES_TRUE',`%d')", TRUE);
+	    printf("define(`CF_CURSES_FALSE',`%d')", FALSE);
+	  }
+	  break;
+	case 'E':
+	  {
+	    char *buf = (char *)malloc(2048);
+	    char *p = buf;
+	    int etimin = E_OK;
+	    int etimax = E_OK;
+
+	    if (p)
+	      {
+		p += eti_gen(p, E_OK, "Ok", &etimin, &etimax);
+		p += eti_gen(p, E_SYSTEM_ERROR, "System_Error", &etimin, &etimax);
+		p += eti_gen(p, E_BAD_ARGUMENT, "Bad_Argument", &etimin, &etimax);
+		p += eti_gen(p, E_POSTED, "Posted", &etimin, &etimax);
+		p += eti_gen(p, E_CONNECTED, "Connected", &etimin, &etimax);
+		p += eti_gen(p, E_BAD_STATE, "Bad_State", &etimin, &etimax);
+		p += eti_gen(p, E_NO_ROOM, "No_Room", &etimin, &etimax);
+		p += eti_gen(p, E_NOT_POSTED, "Not_Posted", &etimin, &etimax);
+		p += eti_gen(p, E_UNKNOWN_COMMAND,
+			     "Unknown_Command", &etimin, &etimax);
+		p += eti_gen(p, E_NO_MATCH, "No_Match", &etimin, &etimax);
+		p += eti_gen(p, E_NOT_SELECTABLE,
+			     "Not_Selectable", &etimin, &etimax);
+		p += eti_gen(p, E_NOT_CONNECTED,
+			     "Not_Connected", &etimin, &etimax);
+		p += eti_gen(p, E_REQUEST_DENIED,
+			     "Request_Denied", &etimin, &etimax);
+		p += eti_gen(p, E_INVALID_FIELD,
+			     "Invalid_Field", &etimin, &etimax);
+		p += eti_gen(p, E_CURRENT,
+			     "Current", &etimin, &etimax);
+	      }
+	    printf("   subtype Eti_Error is C_Int range %d .. %d;\n\n",
+		   etimin, etimax);
+	    printf(buf);
 	  }
-	  printf("   subtype Eti_Error is C_Int range %d .. %d;\n\n",
-		 etimin,etimax);
-	  printf(buf);
+	  break;
+	default:
+	  break;
 	}
-	break;
-      default:
-	break;
-      }
       break;
-      /* ---------------------------------------------------------------*/   
-    case 'V' : /* plain version dump */
+      /* --------------------------------------------------------------- */
+    case 'V':			/* plain version dump */
       {
-	switch(argv[2][0]) {
-	case '1': /* major version */
+	switch (argv[2][0])
+	  {
+	  case '1':		/* major version */
 #ifdef NCURSES_VERSION_MAJOR
-	  printf("%d",NCURSES_VERSION_MAJOR);
+	    printf("%d", NCURSES_VERSION_MAJOR);
 #endif
-	  break;
-	case '2': /* minor version */
+	    break;
+	  case '2':		/* minor version */
 #ifdef NCURSES_VERSION_MINOR
-	  printf("%d",NCURSES_VERSION_MINOR);
+	    printf("%d", NCURSES_VERSION_MINOR);
 #endif
-	  break;
-	case '3': /* patch level */
+	    break;
+	  case '3':		/* patch level */
 #ifdef NCURSES_VERSION_PATCH
-	  printf("%d",NCURSES_VERSION_PATCH);
+	    printf("%d", NCURSES_VERSION_PATCH);
 #endif
-	  break;
-	default:
-	  break;
-	}
+	    break;
+	  default:
+	    break;
+	  }
       }
       break;
-      /* ---------------------------------------------------------------*/	
+      /* --------------------------------------------------------------- */
     default:
       break;
     }
   return 0;
 }
-  
diff -Naur ncurses-5.4.orig/Ada95/gen/terminal_interface-curses-mouse.ads.m4 ncurses-5.4/Ada95/gen/terminal_interface-curses-mouse.ads.m4
--- ncurses-5.4.orig/Ada95/gen/terminal_interface-curses-mouse.ads.m4	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/gen/terminal_interface-curses-mouse.ads.m4	2005-05-13 04:09:49.000000000 +0000
@@ -10,7 +10,7 @@
 --                                 S P E C                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -38,7 +38,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.22 $
+--  $Revision: 1.25 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 include(`Mouse_Base_Defs')
@@ -169,7 +170,6 @@
          Bstate  : Event_Mask;
       end record;
    pragma Convention (C, Mouse_Event);
-   pragma Pack (Mouse_Event);
 
 include(`Mouse_Event_Rep')
    Generation_Bit_Order : constant System.Bit_Order := System.M4_BIT_ORDER;
diff -Naur ncurses-5.4.orig/Ada95/gen/terminal_interface-curses.ads.m4 ncurses-5.4/Ada95/gen/terminal_interface-curses.ads.m4
--- ncurses-5.4.orig/Ada95/gen/terminal_interface-curses.ads.m4	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/gen/terminal_interface-curses.ads.m4	2005-05-13 04:09:49.000000000 +0000
@@ -9,7 +9,7 @@
 --                                 S P E C                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -37,7 +37,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.31 $
+--  $Revision: 1.35 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 include(`Base_Defs')
@@ -59,11 +60,12 @@
    subtype Column_Count is Column_Position range 1 .. Column_Position'Last;
    --  Type to count columns. We do not allow null windows, so must be positive
 
-   type Key_Code is new Natural;
+   type Key_Code is new Integer;
    --  That is anything including real characters, special keys and logical
    --  request codes.
 
-   subtype Real_Key_Code is Key_Code range 0 .. M4_KEY_MAX;
+   --  FIXME: The "-1" should be Curses_Err
+   subtype Real_Key_Code is Key_Code range -1 .. M4_KEY_MAX;
    --  This are the codes that potentially represent a real keystroke.
    --  Not all codes may be possible on a specific terminal. To check the
    --  availability of a special key, the Has_Key function is provided.
diff -Naur ncurses-5.4.orig/Ada95/samples/Makefile.in ncurses-5.4/Ada95/samples/Makefile.in
--- ncurses-5.4.orig/Ada95/samples/Makefile.in	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/Makefile.in	2005-05-13 04:09:49.000000000 +0000
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -28,8 +28,7 @@
 #
 #  Author:  Juergen Pfeifer, 1996
 #
-#  Version Control
-#  $Revision: 1.30 $
+#  $Id: Makefile.in,v 1.32 2005/01/22 20:11:48 tom Exp $
 #
 .SUFFIXES:
 
@@ -84,7 +83,7 @@
 ABASE        = $(ALIB)-curses
 
 CARGS        =-cargs $(ADAFLAGS)
-LARGS        =-largs -L../../lib @TEST_ARGS@ $(LD_FLAGS) -lAdaCurses @EXTRA_LIBS@
+LARGS        =-largs -L../../lib @TEST_ARGS@ $(LD_FLAGS) -lAdaCurses
  
 PROGS        = tour rain ncurses 
 
@@ -111,19 +110,19 @@
 
 
 all ::  tour$x rain$x ncurses$x
-	@
+	@echo made $@
 
 sources :
-	@
+	@echo made $@
 
 libs \
 install \
 install.libs ::
-	@
+	@echo made $@
 
 uninstall \
 uninstall.libs ::
-	@
+	@echo made $@
 
 ncurses$x :
 	$(ADAMAKE) $(ADAMAKEFLAGS) ncurses $(CARGS) $(LARGS)
@@ -138,7 +137,7 @@
 	$(ADAMAKE) $(ADAMAKEFLAGS) rain $(CARGS) $(LARGS)
 
 mostlyclean:
-	@
+	@echo made $@
 
 clean :: mostlyclean
 	rm -f *.o *.ali b_t*.* *.s $(PROGS) a.out core b_*_test.c *.xr[bs] \
@@ -148,6 +147,4 @@
 	rm -f Makefile
 
 realclean :: distclean
-	@
-
-
+	@echo made $@
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-acs_and_scroll.adb ncurses-5.4/Ada95/samples/ncurses2-acs_and_scroll.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-acs_and_scroll.adb	2000-12-02 22:31:22.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-acs_and_scroll.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.6 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 --  Windows and scrolling tester.
@@ -224,8 +225,8 @@
          );
 
       buf : Bounded_String;
-      do_keypad : Boolean := HaveKeyPad (curpw);
-      do_scroll : Boolean := HaveScroll (curpw);
+      do_keypad : constant Boolean := HaveKeyPad (curpw);
+      do_scroll : constant Boolean := HaveScroll (curpw);
 
       pos : Natural;
 
@@ -331,8 +332,8 @@
       res : pair;
       i : Line_Position := 0;
       j : Column_Position := 0;
-      si : Line_Position := lri - uli + 1;
-      sj : Column_Position := lrj - ulj + 1;
+      si : constant Line_Position := lri - uli + 1;
+      sj : constant Column_Position := lrj - ulj + 1;
    begin
       res.y := uli;
       res.x := ulj;
@@ -714,7 +715,7 @@
 
    Allow_Scrolling (Mode => True);
 
-   End_Mouse;
+   End_Mouse (Mask2);
    Set_Raw_Mode (SwitchOn => True);
    Erase;
    End_Windows;
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-acs_display.adb ncurses-5.4/Ada95/samples/ncurses2-acs_display.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-acs_display.adb	2000-12-02 22:31:23.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-acs_display.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.4 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with ncurses2.util; use ncurses2.util;
@@ -57,8 +58,8 @@
 
 
    procedure show_upper_chars (first : Integer)  is
-      C1 : Boolean := (first = 128);
-      last : Integer := first + 31;
+      C1 : constant Boolean := (first = 128);
+      last : constant Integer := first + 31;
       package p is new ncurses2.genericPuts (200);
       use p;
       use p.BS;
@@ -91,9 +92,11 @@
 
       for code in first .. last loop
          declare
-            row : Line_Position := Line_Position (4 + ((code - first) mod 16));
-            col : Column_Position := Column_Position (((code - first) / 16) *
-                                                      Integer (Columns) / 2);
+            row : constant Line_Position
+                := Line_Position (4 + ((code - first) mod 16));
+            col : constant Column_Position
+                := Column_Position (((code - first) / 16) *
+                                    Integer (Columns) / 2);
             tmp3 : String (1 .. 3);
             tmpx : String (1 .. Integer (Columns / 4));
             reply : Key_Code;
@@ -129,8 +132,8 @@
                         code :  Attributed_Character)
                        return Integer is
       height : constant Integer := 16;
-      row : Line_Position := Line_Position (4 + (N mod height));
-      col : Column_Position := Column_Position ((N / height) *
+      row : constant Line_Position := Line_Position (4 + (N mod height));
+      col : constant Column_Position := Column_Position ((N / height) *
                                                 Integer (Columns) / 2);
       tmpx : String (1 .. Integer (Columns) / 3);
    begin
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-attr_test.adb ncurses-5.4/Ada95/samples/ncurses2-attr_test.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-attr_test.adb	2001-07-21 21:34:37.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-attr_test.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2001,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.2 $
+--  $Revision: 1.5 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with ncurses2.util; use ncurses2.util;
@@ -222,7 +223,7 @@
             elsif ncv > 0 and has_A_COLOR (Get_Background) then
                declare
                   Color_Supported_Attributes :
-                    Character_Attribute_Set := make_record (ncv);
+                    constant Character_Attribute_Set := make_record (ncv);
                begin
                   if intersect (Color_Supported_Attributes, attr) then
                      Add (Str => " (NCV) ");
@@ -236,7 +237,7 @@
 
    procedure attr_getc (skip : out Integer; fg, bg : in out Color_Number;
                                             result : out Boolean) is
-      ch : Key_Code := Getchar;
+      ch : constant Key_Code := Getchar;
       nc : constant Color_Number := Color_Number (Number_Of_Colors);
       curscr : Window;
       pragma Import (C, curscr, "curscr");
@@ -293,7 +294,7 @@
          --  row := 2; -- weird, row is set to 0 without this.
          --  TODO delete the above line, it was a gdb quirk that confused me
          if Has_Colors then declare
-            pair : Color_Pair :=
+            pair : constant Color_Pair :=
               Color_Pair (fg * Color_Number (Number_Of_Colors) + bg);
          begin
             --  Go though each color pair. Assume that the number of
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-color_edit.adb ncurses-5.4/Ada95/samples/ncurses2-color_edit.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-color_edit.adb	2000-12-02 22:31:24.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-color_edit.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.4 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with ncurses2.util; use ncurses2.util;
@@ -101,7 +102,6 @@
    current : Color_Number := 0;
    field : RGB_Enum := Redx;
    this_c : Key_Code := 0;
-   last_c : Key_Code;
 begin
    Refresh;
 
@@ -185,7 +185,6 @@
 
       Move_Cursor (Line => 2 + Line_Position (current), Column => 0);
 
-      last_c := this_c;
       this_c := Getchar;
       if Is_Digit (this_c) then
          value := 0;
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-demo_forms.adb ncurses-5.4/Ada95/samples/ncurses2-demo_forms.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-demo_forms.adb	2000-12-02 22:31:25.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-demo_forms.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.4 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with ncurses2.util; use ncurses2.util;
@@ -282,7 +283,7 @@
          );
 
       c : Key_Code := Getchar (w);
-      me : Field := Current (f);
+      me : constant Field := Current (f);
 
    begin
       if c = Character'Pos (']') mod 16#20# then
@@ -314,7 +315,7 @@
    end form_virtualize;
 
    function my_form_driver (f : Form; c : Key_Code) return Boolean is
-      flag : Driver_Result := Driver (f, F_Validate_Field);
+      flag : constant Driver_Result := Driver (f, F_Validate_Field);
    begin
       if c = Form_Request_Code'Last + 1
         and flag = Form_Ok then
@@ -328,7 +329,7 @@
    function make_label (frow  : Line_Position;
                         fcol  : Column_Position;
                         label : String) return Field is
-      f : Field := Create (1, label'Length, frow, fcol, 0, 0);
+      f : constant Field := Create (1, label'Length, frow, fcol, 0, 0);
       o : Field_Option_Set := Get_Options (f);
    begin
       if f /= Null_Field then
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-demo_pad.adb ncurses-5.4/Ada95/samples/ncurses2-demo_pad.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-demo_pad.adb	2000-12-02 22:31:26.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-demo_pad.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.5 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with ncurses2.util; use ncurses2.util;
@@ -104,7 +105,7 @@
       package myP is new System.Address_To_Access_Conversions (timeval);
       use myP;
 
-      t : Object_Pointer := new timeval;
+      t : constant Object_Pointer := new timeval;
 
       function gettimeofday
         (TP : System.Storage_Elements.Integer_Address;
@@ -116,8 +117,13 @@
                            (myP.To_Address (t)),
                            System.Storage_Elements.To_Integer
                            (myP.To_Address (null)));
-      retval.seconds := Integer (t.tv_sec);
-      retval.microseconds := Integer (t.tv_usec);
+      if tmp < 0 then
+         retval.seconds := 0;
+         retval.microseconds := 0;
+      else
+         retval.seconds := Integer (t.tv_sec);
+         retval.microseconds := Integer (t.tv_usec);
+      end if;
       return retval;
    end gettime;
 
@@ -202,7 +208,7 @@
          "Use <,> (or h,l) to grow/shrink the panner horizontally.     ");
       legendsize : constant := 4;
 
-      n : Integer := legendsize - Integer (Lines - line);
+      n : constant Integer := legendsize - Integer (Lines - line);
    begin
       if line < Lines and n >= 0 then
          Move_Cursor (Line => line, Column => 0);
@@ -216,9 +222,10 @@
    end panner_legend;
 
    procedure panner_legend (line : Line_Position) is
-      tmp : Boolean;
    begin
-      tmp := panner_legend (line);
+      if not panner_legend (line) then
+         Beep;
+      end if;
    end panner_legend;
 
    procedure panner_h_cleanup (from_y : Line_Position;
@@ -435,8 +442,8 @@
             when Key_Cursor_Right =>
                --  pan rightwards
                --  if (basex + portx - (pymax > porty) < pxmax)
-               if (basex + portx -
-                   Column_Position (greater (pymax, porty)) < pxmax) then
+               if basex + portx -
+                   Column_Position (greater (pymax, porty)) < pxmax then
                   --  if basex + portx  < pxmax or
                   --      (pymax > porty and basex + portx - 1 < pxmax) then
                   basex := basex + 1;
@@ -455,8 +462,8 @@
             when Key_Cursor_Down =>
                --  pan downwards
                --  same as if (basey + porty - (pxmax > portx) < pymax)
-               if (basey + porty -
-                   Line_Position (greater (pxmax, portx)) < pymax) then
+               if basey + porty -
+                   Line_Position (greater (pxmax, portx)) < pymax then
                   --  if (basey + porty  < pymax) or
                   --      (pxmax > portx and basey + porty - 1 < pymax) then
                   basey := basey + 1;
@@ -472,9 +479,10 @@
             when   Character'Pos ('E') |
               Key_End |
               Key_Select =>
-               basey := pymax - porty;
-               if basey < 0 then --  basey := max(basey, 0);
+               if pymax < porty then
                   basey := 0;
+               else
+                  basey := pymax - porty;
                end if;
 
             when others =>
@@ -500,7 +508,7 @@
          --  in C was ... pxmax > portx - 1
          if scrollers and pxmax >= portx then
             declare
-               length : Column_Position := portx - top_x - 1;
+               length : constant Column_Position := portx - top_x - 1;
                lowend, highend : Column_Position;
             begin
                --  Instead of using floats, I'll use integers only.
@@ -527,7 +535,7 @@
 
          if scrollers and pymax >= porty then
             declare
-               length : Line_Position := porty - top_y - 1;
+               length : constant Line_Position := porty - top_y - 1;
                lowend, highend : Line_Position;
             begin
                lowend := top_y + (basey * length) / pymax;
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-demo_panels.adb ncurses-5.4/Ada95/samples/ncurses2-demo_panels.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-demo_panels.adb	2000-12-02 22:31:37.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-demo_panels.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.4 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with ncurses2.util; use ncurses2.util;
@@ -115,10 +116,10 @@
    procedure wait_a_while (msec : Integer) is
    begin
       --  The C version had some #ifdef blocks here
-      if nap_msec = 1 then
+      if msec = 1 then
          Getchar;
       else
-         Nap_Milli_Seconds (nap_msec);
+         Nap_Milli_Seconds (msec);
       end if;
    end wait_a_while;
 
@@ -137,8 +138,8 @@
    use PUD;
 
    procedure fill_panel (pan : Panel) is
-      win : Window := Panel_Window (pan);
-      num : Character := Get_User_Data (pan) (2);
+      win : constant Window := Panel_Window (pan);
+      num : constant Character := Get_User_Data (pan) (2);
       tmp6 : String (1 .. 6) := "-panx-";
       maxy : Line_Count;
       maxx : Column_Count;
@@ -158,7 +159,7 @@
       end loop;
    end fill_panel;
 
-   modstr : array (0 .. 5) of String (1 .. 5) :=
+   modstr : constant array (0 .. 5) of String (1 .. 5) :=
      ("test ",
       "TEST ",
       "(**) ",
@@ -185,11 +186,11 @@
    for y in 0 .. 4 loop
       declare
          p1, p2, p3, p4, p5 : Panel;
-         U1 : User_Data_Access := new User_Data'("p1");
-         U2 : User_Data_Access := new User_Data'("p2");
-         U3 : User_Data_Access := new User_Data'("p3");
-         U4 : User_Data_Access := new User_Data'("p4");
-         U5 : User_Data_Access := new User_Data'("p5");
+         U1 : constant User_Data_Access := new User_Data'("p1");
+         U2 : constant User_Data_Access := new User_Data'("p2");
+         U3 : constant User_Data_Access := new User_Data'("p3");
+         U4 : constant User_Data_Access := new User_Data'("p4");
+         U5 : constant User_Data_Access := new User_Data'("p5");
 
       begin
          p1 := mkpanel (Red, Lines / 2 - 2, Columns / 8 + 1, 0, 0);
@@ -295,8 +296,8 @@
 
          for itmp in  0 ..  5 loop
             declare
-               w4 : Window := Panel_Window (p4);
-               w5 : Window := Panel_Window (p5);
+               w4 : constant Window := Panel_Window (p4);
+               w5 : constant Window := Panel_Window (p5);
             begin
 
                saywhat ("m4; press any key to continue");
@@ -364,7 +365,7 @@
          rmpanel (p5);
          pflush;
          wait_a_while (nap_msec);
-         if (nap_msec = 1) then
+         if nap_msec = 1 then
             exit;
          else
             nap_msec := 100;
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-getch_test.adb ncurses-5.4/Ada95/samples/ncurses2-getch_test.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-getch_test.adb	2000-12-02 22:31:01.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-getch_test.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.5 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 --  Character input test
@@ -96,6 +97,7 @@
    y : Line_Position;
    tmpx : Integer;
    incount : Integer := 0;
+
 begin
    Refresh;
    tmp2 := Start_Mouse (All_Events);
@@ -135,7 +137,7 @@
             Add (Ch => newl);
          elsif c > 16#80# then --  TODO fix, use constant if possible
             declare
-               c2 : Character := Character'Val (c mod 16#80#);
+               c2 : constant Character := Character'Val (c mod 16#80#);
             begin
                if Ada.Characters.Handling.Is_Graphic (c2) then
                   Add (Str => "M-");
@@ -150,7 +152,7 @@
                Add (Ch => newl);
             end;
          else declare
-            c2 : Character := Character'Val (c mod 16#80#);
+            c2 : constant Character := Character'Val (c mod 16#80#);
          begin
             if Ada.Characters.Handling.Is_Graphic (c2) then
                Add (Ch => c2);
@@ -242,7 +244,7 @@
       end loop;
    end loop;
 
-   tmp2 := Start_Mouse (No_Events);
+   End_Mouse (tmp2);
    Set_Timeout_Mode (Mode => Blocking, Amount => 0); --  amount is ignored
    Set_Raw_Mode (SwitchOn => False);
    Set_NL_Mode (SwitchOn => True);
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-getopt.adb ncurses-5.4/Ada95/samples/ncurses2-getopt.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-getopt.adb	2004-01-30 23:56:40.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-getopt.adb	2005-05-13 04:09:49.000000000 +0000
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.3 $
+--  $Revision: 1.6 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 --  A simplified version of the  GNU getopt function
@@ -47,8 +48,6 @@
 
 package body ncurses2.getopt is
 
-   optopt : Character := '?';
-
    nextchar : Natural := 0;
 
    --  Ncurses doesn't use the non option elements so we are spared
@@ -104,13 +103,12 @@
       --  Look at and handle the next short option-character.
       declare
          c : Character := argv (optind) (nextchar);
-         temp : Natural :=
+         temp : constant Natural :=
            Ada.Strings.Fixed.Index (optstring, String'(1 => c));
       begin
          if temp = 0 or c = ':' then
             Put_Line (Standard_Error,
                       argv (optind) & ": invalid option -- " & c);
-            optopt := c;
             c := '?';
             return;
          end if;
@@ -134,7 +132,6 @@
                   Put_Line (Standard_Error,
                             argv (optind) &
                             ": option requires an argument -- " & c);
-                  optopt := c;
                   if optstring (1) = ':'  then
                      c := ':';
                   else
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-m.adb ncurses-5.4/Ada95/samples/ncurses2-m.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-m.adb	2004-01-30 23:56:51.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-m.adb	2005-05-13 04:09:49.000000000 +0000
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.2 $
+--  $Revision: 1.5 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 --  TODO use Default_Character where appropriate
@@ -332,7 +333,7 @@
                default_colors := True;
             when 'e' =>
                myio.Get (optarg.all, tmpi, length);
-               if Integer (tmpi) > 3 then
+               if tmpi > 3 then
                   usage;
                   return 1;
                end if;
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-menu_test.adb ncurses-5.4/Ada95/samples/ncurses2-menu_test.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-menu_test.adb	2000-12-02 22:31:04.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-menu_test.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.5 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with ncurses2.util; use ncurses2.util;
@@ -92,6 +93,7 @@
    items_a : Item_Array_Access := new Item_Array (1 .. animals'Last + 1);
 
    tmp : Event_Mask;
+
    procedure xAdd (l : Line_Position; c : Column_Position; s : String) is
    begin
       Add (Line => l, Column => c, Str => s);
@@ -161,5 +163,5 @@
 
    Delete (m);
 
-   tmp := Start_Mouse (No_Events);
+   End_Mouse (tmp);
 end ncurses2.menu_test;
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-overlap_test.adb ncurses-5.4/Ada95/samples/ncurses2-overlap_test.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-overlap_test.adb	2000-12-02 22:31:05.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-overlap_test.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.4 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with ncurses2.util; use ncurses2.util;
@@ -71,8 +72,8 @@
       Get_Size (win, y1, x1);
       for y in 0 .. y1 - 1 loop
          for x in 0 .. x1 - 1 loop
-            if (((x > (x1 - 1) / 3) and (x <= (2 * (x1 - 1)) / 3))
-                or (((y > (y1 - 1) / 3) and (y <= (2 * (y1 - 1)) / 3)))) then
+            if ((x > (x1 - 1) / 3) and (x <= (2 * (x1 - 1)) / 3))
+                or (((y > (y1 - 1) / 3) and (y <= (2 * (y1 - 1)) / 3))) then
                Move_Cursor (win, y, x);
                Add (win, Ch => ch);
             end if;
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-slk_test.adb ncurses-5.4/Ada95/samples/ncurses2-slk_test.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-slk_test.adb	2000-12-02 22:31:05.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-slk_test.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.6 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with ncurses2.util; use ncurses2.util;
@@ -63,10 +64,13 @@
                          Len : int) return int;
       pragma Import (C, Wgetnstr, "wgetnstr");
 
-      Txt : char_array (0 .. 10);
+      --  FIXME: how to construct "(Len > 0) ? Len : 80"?
+      Ask : constant Interfaces.C.size_t := Interfaces.C.size_t'Val (Len + 80);
+      Txt : char_array (0 .. Ask);
+
    begin
       Txt (0) := Interfaces.C.char'First;
-      if Wgetnstr (Win, Txt, 8) = Curses_Err then
+      if Wgetnstr (Win, Txt, Txt'Length) = Curses_Err then
          raise Curses_Exception;
       end if;
       Str := To_Unbounded_String (To_Ada (Txt, True));
diff -Naur ncurses-5.4.orig/Ada95/samples/ncurses2-util.adb ncurses-5.4/Ada95/samples/ncurses2-util.adb
--- ncurses-5.4.orig/Ada95/samples/ncurses2-util.adb	2000-12-02 22:31:07.000000000 +0000
+++ ncurses-5.4/Ada95/samples/ncurses2-util.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
 --  Version Control
---  $Revision: 1.1 $
+--  $Revision: 1.5 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
@@ -104,9 +105,10 @@
    end Getchar;
 
    procedure Getchar (win : Window := Standard_Window) is
-      x : Key_Code;
    begin
-      x := Getchar (win);
+      if Getchar (win) < 0 then
+         Beep;
+      end if;
    end Getchar;
 
 
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-curses_demo.adb ncurses-5.4/Ada95/samples/sample-curses_demo.adb
--- ncurses-5.4.orig/Ada95/samples/sample-curses_demo.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-curses_demo.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.12 $
+--  $Revision: 1.15 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
@@ -74,7 +75,7 @@
          New_Item ("Mouse Demo"),
          Null_Item);
       M  : Menu := New_Menu (Itm);
-      U1 : User_Data_Access := new User_Data'(4711);
+      U1 : constant User_Data_Access := new User_Data'(4711);
       U2 : User_Data_Access;
 
       function My_Driver (M : Menu;
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-explanation.adb ncurses-5.4/Ada95/samples/sample-explanation.adb
--- ncurses-5.4.orig/Ada95/samples/sample-explanation.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-explanation.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.15 $
+--  $Revision: 1.18 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 --  Poor mans help system. This scans a sequential file for key lines and
@@ -57,7 +58,7 @@
    Help_Keys : constant String := "HELPKEYS";
    In_Help   : constant String := "INHELP";
 
-   File_Name : String := "explain.msg";
+   File_Name : constant String := "explain.msg";
    F : File_Type;
 
    type Help_Line;
@@ -116,7 +117,7 @@
       Current  : Help_Line_Access;
       Top_Line : Help_Line_Access;
 
-      Has_More : Boolean;
+      Has_More : Boolean := True;
 
       procedure Unknown_Key
       is
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-form_demo-aux.adb ncurses-5.4/Ada95/samples/sample-form_demo-aux.adb
--- ncurses-5.4.orig/Ada95/samples/sample-form_demo-aux.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-form_demo-aux.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.13 $
+--  $Revision: 1.16 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
@@ -198,7 +199,7 @@
                   Text        : String) return Field
    is
       Fld : Field;
-      C : Column_Count := Column_Count (Text'Length);
+      C : constant Column_Count := Column_Count (Text'Length);
    begin
       Fld := New_Field (1, C, Top, Left);
       Set_Buffer (Fld, 0, Text);
@@ -215,7 +216,7 @@
                    Left        : Column_Position;
                    Off_Screen  : Natural := 0) return Field
    is
-      Fld : Field := New_Field (Height, Width, Top, Left, Off_Screen);
+      Fld : constant Field := New_Field (Height, Width, Top, Left, Off_Screen);
    begin
       if Has_Colors then
          Set_Foreground (Fld => Fld, Color => Form_Fore_Color);
@@ -231,6 +232,9 @@
                             P : Panel) return Boolean
    is
    begin
+      if P = Null_Panel then
+         raise Panel_Exception;
+      end if;
       if K in User_Key_Code'Range and then K = QUIT then
          if Driver (F, F_Validate_Field) = Form_Ok  then
             return True;
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-form_demo-handler.adb ncurses-5.4/Ada95/samples/sample-form_demo-handler.adb
--- ncurses-5.4.orig/Ada95/samples/sample-form_demo-handler.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-form_demo-handler.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.10 $
+--  $Revision: 1.13 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Sample.Form_Demo.Aux;
@@ -72,7 +73,7 @@
       end if;
       loop
          declare
-            K : Key_Code := Aux.Get_Request (F, Pan, Handle_CRLF);
+            K : constant Key_Code := Aux.Get_Request (F, Pan, Handle_CRLF);
             R : Driver_Result;
          begin
             if (K = 13 or else K = 10) and then not Handle_CRLF then
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-form_demo.adb ncurses-5.4/Ada95/samples/sample-form_demo.adb
--- ncurses-5.4.orig/Ada95/samples/sample-form_demo.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-form_demo.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,13 +35,13 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.10 $
+--  $Revision: 1.13 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
 with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms;
 with Terminal_Interface.Curses.Forms.Field_User_Data;
-with Terminal_Interface.Curses.Forms.Form_User_Data;
 with Sample.My_Field_Type; use Sample.My_Field_Type;
 with Sample.Explanation; use Sample.Explanation;
 with Sample.Form_Demo.Aux; use Sample.Form_Demo.Aux;
@@ -66,10 +66,6 @@
      Terminal_Interface.Curses.Forms.Field_User_Data (User_Data,
                                                       User_Access);
 
-   package Frm_U is new
-     Terminal_Interface.Curses.Forms.Form_User_Data (User_Data,
-                                                     User_Access);
-
    type Weekday is (Sunday, Monday, Tuesday, Wednesday, Thursday,
                     Friday, Saturday);
 
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-function_key_setting.adb ncurses-5.4/Ada95/samples/sample-function_key_setting.adb
--- ncurses-5.4.orig/Ada95/samples/sample-function_key_setting.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-function_key_setting.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.10 $
+--  $Revision: 1.13 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Unchecked_Deallocation;
@@ -97,7 +98,7 @@
       P.Help := Active_Context;
       P.Notepad := Active_Notepad;
       --  The notepad must now vanish and the new notepad is empty.
-      if (P.Notepad /= Null_Panel) then
+      if P.Notepad /= Null_Panel then
          Hide (P.Notepad);
          Update_Panels;
       end if;
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-header_handler.adb ncurses-5.4/Ada95/samples/sample-header_handler.adb
--- ncurses-5.4.orig/Ada95/samples/sample-header_handler.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-header_handler.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.11 $
+--  $Revision: 1.14 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Calendar; use Ada.Calendar;
@@ -111,12 +112,12 @@
          "November ",
          "December ");
 
-      Now : Time := Clock;
-      Sec : Integer := Integer (Seconds (Now));
-      Hour   : Integer := Sec / 3600;
-      Minute : Integer := (Sec - Hour * 3600) / 60;
-      Mon    : Month_Number := Month (Now);
-      D      : Day_Number   := Day (Now);
+      Now    : constant Time         := Clock;
+      Sec    : constant Integer      := Integer (Seconds (Now));
+      Hour   : constant Integer      := Sec / 3600;
+      Minute : constant Integer      := (Sec - Hour * 3600) / 60;
+      Mon    : constant Month_Number := Month (Now);
+      D      : constant Day_Number   := Day (Now);
    begin
       if Header_Window /= Null_Window then
          if Minute /= Display_Min or else Hour /= Display_Hour
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-keyboard_handler.adb ncurses-5.4/Ada95/samples/sample-keyboard_handler.adb
--- ncurses-5.4.orig/Ada95/samples/sample-keyboard_handler.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-keyboard_handler.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.9 $
+--  $Revision: 1.12 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Strings; use Ada.Strings;
@@ -95,6 +96,9 @@
          is
             Ch : Character;
          begin
+            if P = Null_Panel then
+               raise Panel_Exception;
+            end if;
             if C in User_Key_Code'Range and then C = QUIT then
                if Driver (F, F_Validate_Field) = Form_Ok  then
                   K := Key_None;
@@ -102,7 +106,7 @@
                end if;
             elsif C in Normal_Key_Code'Range then
                Ch := Character'Val (C);
-               if (Ch = LF or else Ch = CR) then
+               if Ch = LF or else Ch = CR then
                   if Driver (F, F_Validate_Field) = Form_Ok  then
                      declare
                         Buffer : String (1 .. Positive (Columns - 11));
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-menu_demo-handler.adb ncurses-5.4/Ada95/samples/sample-menu_demo-handler.adb
--- ncurses-5.4.orig/Ada95/samples/sample-menu_demo-handler.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-menu_demo-handler.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.12 $
+--  $Revision: 1.15 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Sample.Menu_Demo.Aux;
@@ -75,7 +76,7 @@
       loop
          declare
             K : Key_Code := Aux.Get_Request (M, Pan);
-            R : Driver_Result := Driver (M, K);
+            R : constant Driver_Result := Driver (M, K);
          begin
             case R is
                when Menu_Ok => null;
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-menu_demo.adb ncurses-5.4/Ada95/samples/sample-menu_demo.adb
--- ncurses-5.4.orig/Ada95/samples/sample-menu_demo.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-menu_demo.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.13 $
+--  $Revision: 1.17 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Terminal_Interface.Curses; use Terminal_Interface.Curses;
@@ -105,6 +106,12 @@
                              P : Panel) return Boolean
          is
          begin
+            if M = Null_Menu then
+               raise Menu_Exception;
+            end if;
+            if P = Null_Panel then
+               raise Panel_Exception;
+            end if;
             To_Change := No_Change;
             if K in User_Key_Code'Range then
                if K = QUIT then
@@ -331,9 +338,9 @@
          Null_Item);
       M : Menu := New_Menu (Itm);
 
-      U1 : User_Data_Access := new User_Data'(4711);
+      U1 : constant User_Data_Access := new User_Data'(4711);
       U2 : User_Data_Access;
-      U3 : User_Data_Access := new User_Data'(4712);
+      U3 : constant User_Data_Access := new User_Data'(4712);
       U4 : User_Data_Access;
 
       function My_Driver (M : Menu;
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-my_field_type.adb ncurses-5.4/Ada95/samples/sample-my_field_type.adb
--- ncurses-5.4.orig/Ada95/samples/sample-my_field_type.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-my_field_type.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.9 $
+--  $Revision: 1.13 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms;
@@ -45,11 +46,14 @@
 --
 package body Sample.My_Field_Type is
 
-   --  That's simple. There are no field validity checks.
+   --  That's simple. There are minimal field validity checks.
    function Field_Check (Fld : Field;
                          Typ : My_Data) return Boolean
    is
    begin
+      if Fld = Null_Field or Typ.Ch = Character'Val (0) then
+         return False;
+      end if;
       return True;
    end Field_Check;
 
diff -Naur ncurses-5.4.orig/Ada95/samples/sample-text_io_demo.adb ncurses-5.4/Ada95/samples/sample-text_io_demo.adb
--- ncurses-5.4.orig/Ada95/samples/sample-text_io_demo.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/samples/sample-text_io_demo.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control
---  $Revision: 1.11 $
+--  $Revision: 1.14 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Numerics.Generic_Elementary_Functions;
@@ -109,9 +110,9 @@
       W : Window;
       P : Panel := Create (Standard_Window);
       K : Real_Key_Code;
-      Im : Complex := (0.0, 1.0);
-      Fx : Fix := 3.14;
-      Dc : Dec := 2.72;
+      Im : constant Complex := (0.0, 1.0);
+      Fx : constant Fix := 3.14;
+      Dc : constant Dec := 2.72;
       L : Md;
 
    begin
diff -Naur ncurses-5.4.orig/Ada95/src/Makefile.in ncurses-5.4/Ada95/src/Makefile.in
--- ncurses-5.4.orig/Ada95/src/Makefile.in	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/Makefile.in	2005-05-13 04:09:49.000000000 +0000
@@ -1,5 +1,5 @@
 ##############################################################################
-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
+# Copyright (c) 1998-2003,2004 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"), #
@@ -28,8 +28,7 @@
 #
 #  Author:  Juergen Pfeifer, 1996
 #
-#  Version Control
-#  $Revision: 1.28 $
+#  $Id: Makefile.in,v 1.30 2004/08/21 21:29:50 tom Exp $
 #
 .SUFFIXES:
 
@@ -175,17 +174,17 @@
 	@sh -c 'for f in $(LIBALIS) $(GENALIS); do test -f $$f || touch $$f; done'
 
 sources :
-	@
+	@echo made $@
 
 libs \
 install \
 install.libs \
 uninstall \
 uninstall.libs ::
-	@
+	@echo made $@
 
 generics: $(GENALIS)
-	@
+	@echo made $@
 
 mostlyclean ::
 	rm -f *.o *.ali b_t*.* *.s $(PROGS) a.out core b_*_test.c *.xr[bs] *.a
@@ -232,7 +231,7 @@
 
 $(ABASE)-trace.adb : $(srcdir)/$(ABASE)-trace.adb_p
 	rm -f $@
-	$(ADAPREP) -DADA_TRACE=@ADA_TRACE@ $(srcdir)/$(ABASE)-trace.adb_p $@
+	$(ADAPREP) -DADA_TRACE=@ADA_TRACE@ -DPRAGMA_UNREF=@PRAGMA_UNREF@ $(srcdir)/$(ABASE)-trace.adb_p $@
 
 $(ABASE)-trace.o: \
 		$(ABASE)-trace.ads \
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb ncurses-5.4/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.7 $
+--  $Revision: 1.10 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Characters.Handling; use Ada.Characters.Handling;
@@ -54,7 +55,7 @@
       I.Match_Must_Be_Unique := Must_Be_Unique;
 
       for E in T'Range loop
-         I.Names (J) := new String'(T'Image (T (E)));
+         I.Names (J) := new String'(T'Image (E));
          --  The Image attribute defaults to upper case, so we have to handle
          --  only the other ones...
          if Set /= Upper_Case then
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb ncurses-5.4/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.10 $
+--  $Revision: 1.13 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Unchecked_Conversion;
@@ -53,7 +54,7 @@
                           Usr : System.Address) return C_Int
    is
       Result : Boolean;
-      Udf    : User_Defined_Field_Type_With_Choice_Access :=
+      Udf    : constant User_Defined_Field_Type_With_Choice_Access :=
         User_Defined_Field_Type_With_Choice_Access
         (To_Argument_Access (Usr).Typ);
    begin
@@ -65,7 +66,7 @@
                           Usr : System.Address) return C_Int
    is
       Result : Boolean;
-      Udf    : User_Defined_Field_Type_With_Choice_Access :=
+      Udf    : constant User_Defined_Field_Type_With_Choice_Access :=
         User_Defined_Field_Type_With_Choice_Access
         (To_Argument_Access (Usr).Typ);
    begin
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms-field_types-user.adb ncurses-5.4/Ada95/src/terminal_interface-curses-forms-field_types-user.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms-field_types-user.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-forms-field_types-user.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.10 $
+--  $Revision: 1.13 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Unchecked_Conversion;
@@ -63,7 +64,8 @@
       function Allocate_Arg (T : User_Defined_Field_Type'Class)
                              return Argument_Access
       is
-         Ptr : Field_Type_Access := new User_Defined_Field_Type'Class'(T);
+         Ptr : constant Field_Type_Access
+             := new User_Defined_Field_Type'Class'(T);
       begin
          return new Argument'(Usr => System.Null_Address,
                               Typ => Ptr,
@@ -84,7 +86,7 @@
                                  Usr : System.Address) return C_Int
    is
       Result : Boolean;
-      Udf    : User_Defined_Field_Type_Access :=
+      Udf    : constant User_Defined_Field_Type_Access :=
         User_Defined_Field_Type_Access (To_Argument_Access (Usr).Typ);
    begin
       Result := Field_Check (Fld, Udf.all);
@@ -95,7 +97,7 @@
                                 Usr : System.Address) return C_Int
    is
       Result : Boolean;
-      Udf    : User_Defined_Field_Type_Access :=
+      Udf    : constant User_Defined_Field_Type_Access :=
         User_Defined_Field_Type_Access (To_Argument_Access (Usr).Typ);
    begin
       Result := Character_Check (Character'Val (Ch), Udf.all);
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms-field_types.adb ncurses-5.4/Ada95/src/terminal_interface-curses-forms-field_types.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms-field_types.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-forms-field_types.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.14 $
+--  $Revision: 1.17 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Interfaces.C;
@@ -144,7 +145,7 @@
                            Typ : Field_Type'Class;
                            Cft : C_Field_Type := C_Builtin_Router)
    is
-      Usr_Arg   : System.Address := Get_Arg (Fld);
+      Usr_Arg   : constant System.Address := Get_Arg (Fld);
       Low_Level : constant C_Field_Type := Get_Fieldtype (Fld);
       Arg : Argument_Access;
       Res : Eti_Error;
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms.adb ncurses-5.4/Ada95/src/terminal_interface-curses-forms.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-forms.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-forms.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.22 $
+--  $Revision: 1.25 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Unchecked_Deallocation;
@@ -330,7 +331,7 @@
                                Opt : C_Int) return C_Int;
       pragma Import (C, Set_Field_Opts, "set_field_opts");
 
-      Opt : C_Int := FOS_2_CInt (Options);
+      Opt : constant C_Int := FOS_2_CInt (Options);
       Res : Eti_Error;
    begin
       Res := Set_Field_Opts (Fld, Opt);
@@ -353,7 +354,7 @@
       pragma Import (C, Field_Opts_Off, "field_opts_off");
 
       Err : Eti_Error;
-      Opt : C_Int := FOS_2_CInt (Options);
+      Opt : constant C_Int := FOS_2_CInt (Options);
    begin
       if On then
          Err := Field_Opts_On (Fld, Opt);
@@ -373,7 +374,7 @@
       function Field_Opts (Fld : Field) return C_Int;
       pragma Import (C, Field_Opts, "field_opts");
 
-      Res : C_Int := Field_Opts (Fld);
+      Res : constant C_Int := Field_Opts (Fld);
    begin
       Options := CInt_2_FOS (Res);
    end Get_Options;
@@ -845,7 +846,7 @@
                               Opt : C_Int) return C_Int;
       pragma Import (C, Set_Form_Opts, "set_form_opts");
 
-      Opt : C_Int := FrmOS_2_CInt (Options);
+      Opt : constant C_Int := FrmOS_2_CInt (Options);
       Res : Eti_Error;
    begin
       Res := Set_Form_Opts (Frm, Opt);
@@ -868,7 +869,7 @@
       pragma Import (C, Form_Opts_Off, "form_opts_off");
 
       Err : Eti_Error;
-      Opt : C_Int := FrmOS_2_CInt (Options);
+      Opt : constant C_Int := FrmOS_2_CInt (Options);
    begin
       if On then
          Err := Form_Opts_On (Frm, Opt);
@@ -888,7 +889,7 @@
       function Form_Opts (Frm : Form) return C_Int;
       pragma Import (C, Form_Opts, "form_opts");
 
-      Res : C_Int := Form_Opts (Frm);
+      Res : constant C_Int := Form_Opts (Frm);
    begin
       Options := CInt_2_FrmOS (Res);
    end Get_Options;
@@ -995,7 +996,7 @@
       function Frm_Driver (Frm : Form; Key : C_Int) return C_Int;
       pragma Import (C, Frm_Driver, "form_driver");
 
-      R : Eti_Error := Frm_Driver (Frm, C_Int (Key));
+      R : constant Eti_Error := Frm_Driver (Frm, C_Int (Key));
    begin
       if R /= E_Ok then
          if R = E_Unknown_Command then
@@ -1135,7 +1136,7 @@
    begin
       if FA /= null and then Free_Fields then
          for I in FA'First .. (FA'Last - 1) loop
-            if (FA (I) /= Null_Field) then
+            if FA (I) /= Null_Field then
                Delete (FA (I));
             end if;
          end loop;
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-menus.adb ncurses-5.4/Ada95/src/terminal_interface-curses-menus.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-menus.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-menus.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.22 $
+--  $Revision: 1.25 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Ada.Unchecked_Deallocation;
@@ -105,8 +106,8 @@
       type Desc_String_Ptr is access Desc_String;
       pragma Controlled (Desc_String_Ptr);
 
-      Name_Str : Name_String_Ptr := new Name_String;
-      Desc_Str : Desc_String_Ptr := new Desc_String;
+      Name_Str : constant Name_String_Ptr := new Name_String;
+      Desc_Str : constant Desc_String_Ptr := new Desc_String;
       Name_Len, Desc_Len : size_t;
       Result : Item;
    begin
@@ -194,7 +195,7 @@
                               Opt : C_Int) return C_Int;
       pragma Import (C, Set_Item_Opts, "set_item_opts");
 
-      Opt : C_Int := IOS_2_CInt (Options);
+      Opt : constant C_Int := IOS_2_CInt (Options);
       Res : Eti_Error;
    begin
       Res := Set_Item_Opts (Itm, Opt);
@@ -214,7 +215,7 @@
                               Opt : C_Int) return C_Int;
       pragma Import (C, Item_Opts_Off, "item_opts_off");
 
-      Opt : C_Int := IOS_2_CInt (Options);
+      Opt : constant C_Int := IOS_2_CInt (Options);
       Err : Eti_Error;
    begin
       if On then
@@ -233,7 +234,7 @@
       function Item_Opts (Itm : Item) return C_Int;
       pragma Import (C, Item_Opts, "item_opts");
 
-      Res : C_Int := Item_Opts (Itm);
+      Res : constant C_Int := Item_Opts (Itm);
    begin
       Options := CInt_2_IOS (Res);
    end Get_Options;
@@ -374,7 +375,7 @@
                               Opt : C_Int) return C_Int;
       pragma Import (C, Set_Menu_Opts, "set_menu_opts");
 
-      Opt : C_Int := MOS_2_CInt (Options);
+      Opt : constant C_Int := MOS_2_CInt (Options);
       Res : Eti_Error;
    begin
       Res := Set_Menu_Opts (Men, Opt);
@@ -394,7 +395,7 @@
                               Opt : C_Int) return C_Int;
       pragma Import (C, Menu_Opts_Off, "menu_opts_off");
 
-      Opt : C_Int := MOS_2_CInt (Options);
+      Opt : constant C_Int := MOS_2_CInt (Options);
       Err : Eti_Error;
    begin
       if On then
@@ -413,7 +414,7 @@
       function Menu_Opts (Men : Menu) return C_Int;
       pragma Import (C, Menu_Opts, "menu_opts");
 
-      Res : C_Int := Menu_Opts (Men);
+      Res : constant C_Int := Menu_Opts (Men);
    begin
       Options := CInt_2_MOS (Res);
    end Get_Options;
@@ -973,7 +974,7 @@
                        Key : C_Int) return C_Int;
       pragma Import (C, Driver, "menu_driver");
 
-      R : Eti_Error := Driver (Men, C_Int (Key));
+      R : constant Eti_Error := Driver (Men, C_Int (Key));
    begin
       if R /= E_Ok then
          case R is
@@ -996,7 +997,7 @@
    begin
       if IA /= null and then Free_Items then
          for I in IA'First .. (IA'Last - 1) loop
-            if (IA (I) /= Null_Item) then
+            if IA (I) /= Null_Item then
                Delete (IA (I));
             end if;
          end loop;
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-mouse.adb ncurses-5.4/Ada95/src/terminal_interface-curses-mouse.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-mouse.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-mouse.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.18 $
+--  $Revision: 1.21 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with System;
@@ -116,13 +117,18 @@
       Old : aliased Event_Mask;
    begin
       R := MMask (Mask, Old'Access);
+      if R = No_Events then
+         Beep;
+      end if;
       return Old;
    end Start_Mouse;
 
    procedure End_Mouse (Mask : in Event_Mask := No_Events)
    is
    begin
-      null;
+      if Mask /= No_Events then
+         Beep;
+      end if;
    end End_Mouse;
 
    procedure Dispatch_Event (Mask   : in  Event_Mask;
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-panels.adb ncurses-5.4/Ada95/src/terminal_interface-curses-panels.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-panels.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-panels.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.10 $
+--  $Revision: 1.13 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
@@ -104,7 +105,7 @@
       function Panel_Win (Pan : Panel) return Window;
       pragma Import (C, Panel_Win, "panel_window");
 
-      Win : Window := Panel_Win (Pan);
+      Win : constant Window := Panel_Win (Pan);
    begin
       if Win = Null_Window then
          raise Panel_Exception;
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-termcap.adb ncurses-5.4/Ada95/src/terminal_interface-curses-termcap.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-termcap.adb	2004-01-30 23:57:01.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-termcap.adb	2005-05-13 04:09:49.000000000 +0000
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.6 $
+--  $Revision: 1.9 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 
@@ -52,7 +53,7 @@
       pragma Import (C, tgetent, "tgetent");
       NameTxt : char_array (0 .. Name'Length);
       Length  : size_t;
-      ignored : char_array (0 .. 0) := (0 => nul);
+      ignored : constant char_array (0 .. 0) := (0 => nul);
       result  : C_Int;
    begin
       To_C (Name, NameTxt, Length);
@@ -111,7 +112,7 @@
       Length : size_t;
       Txt2   : chars_ptr;
       type t is new char_array (0 .. 1024); --  does it need to be 1024?
-      Return_Buffer : t := (others => nul);
+      Return_Buffer : constant t := (others => nul);
    begin
       To_C (Name, Txt, Length);
       Txt2 := tgetstr (Txt, char_array (Return_Buffer));
@@ -132,7 +133,7 @@
       Length : size_t;
       Txt2   : chars_ptr;
       type t is new char_array (0 .. 1024); --  does it need to be 1024?
-      Phony_Txt : t := (others => nul);
+      Phony_Txt : constant t := (others => nul);
    begin
       To_C (Name, Txt, Length);
       Txt2 := tgetstr (Txt, char_array (Phony_Txt));
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-text_io.adb ncurses-5.4/Ada95/src/terminal_interface-curses-text_io.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-text_io.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-text_io.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.14 $
+--  $Revision: 1.17 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 package body Terminal_Interface.Curses.Text_IO is
@@ -86,9 +87,9 @@
       N_Cols  : Column_Count;
    begin
       Get_Size (Win, N_Lines, N_Cols);
-      if Natural (N_Cols) > Natural (Count'Last) then
-         raise Layout_Error;
-      end if;
+      --  if Natural (N_Cols) > Natural (Count'Last) then
+      --     raise Layout_Error;
+      --  end if;
       return Count (N_Cols);
    end Line_Length;
 
@@ -107,9 +108,9 @@
          return 0;
       else
          Get_Size (Win, N_Lines, N_Cols);
-         if Natural (N_Lines) > Natural (Count'Last) then
-            raise Layout_Error;
-         end if;
+         --  if Natural (N_Lines) > Natural (Count'Last) then
+         --     raise Layout_Error;
+         --  end if;
          return Count (N_Lines);
       end if;
    end Page_Length;
@@ -229,9 +230,9 @@
    begin
       Get_Cursor_Position (Win, Y, X);
       N := Natural (X); N := N + 1;
-      if N > Natural (Count'Last) then
-         raise Layout_Error;
-      end if;
+      --  if N > Natural (Count'Last) then
+      --     raise Layout_Error;
+      --  end if;
       return Positive_Count (N);
    end Col;
 
@@ -249,9 +250,9 @@
    begin
       Get_Cursor_Position (Win, Y, X);
       N := Natural (Y); N := N + 1;
-      if N > Natural (Count'Last) then
-         raise Layout_Error;
-      end if;
+      --  if N > Natural (Count'Last) then
+      --     raise Layout_Error;
+      --  end if;
       return Positive_Count (N);
    end Line;
 
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses-trace.adb_p ncurses-5.4/Ada95/src/terminal_interface-curses-trace.adb_p
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses-trace.adb_p	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses-trace.adb_p	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
+-- Copyright (c) 2000,2004 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            --
@@ -35,7 +35,7 @@
 ------------------------------------------------------------------------------
 --  Author:  Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.4 $
+--  $Revision: 1.5 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 #if ADA_TRACE then
@@ -78,11 +78,17 @@
    end Trace_Put;
 #else
    procedure Trace_On (x : Trace_Attribute_Set) is
+#if PRAGMA_UNREF
+   pragma Unreferenced (x);
+#end if;
    begin
       null;
    end Trace_On;
 
    procedure Trace_Put (str : String) is
+#if PRAGMA_UNREF
+   pragma Unreferenced (str);
+#end if;
    begin
       null;
    end Trace_Put;
diff -Naur ncurses-5.4.orig/Ada95/src/terminal_interface-curses.adb ncurses-5.4/Ada95/src/terminal_interface-curses.adb
--- ncurses-5.4.orig/Ada95/src/terminal_interface-curses.adb	2003-10-25 15:39:18.000000000 +0000
+++ ncurses-5.4/Ada95/src/terminal_interface-curses.adb	2005-05-13 04:09:49.000000000 +0000
@@ -7,7 +7,7 @@
 --                                 B O D Y                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
+-- Copyright (c) 1998,2004 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            --
@@ -35,7 +35,8 @@
 ------------------------------------------------------------------------------
 --  Author: Juergen Pfeifer, 1996
 --  Version Control:
---  $Revision: 1.29 $
+--  $Revision: 1.32 $
+--  $Date: 2004/08/21 21:37:00 $
 --  Binding Version 01.00
 ------------------------------------------------------------------------------
 with System;
@@ -373,7 +374,7 @@
       function Dupwin (Win : Window) return Window;
       pragma Import (C, Dupwin, "dupwin");
 
-      W : Window := Dupwin (Win);
+      W : constant Window := Dupwin (Win);
    begin
       if W = Null_Window then
          raise Curses_Exception;
@@ -935,6 +936,9 @@
       procedure No_Qiflush;
       pragma Import (C, No_Qiflush, "noqiflush");
    begin
+      if Win = Null_Window then
+         raise Curses_Exception;
+      end if;
       if Flush then
          Qiflush;
       else
@@ -1398,8 +1402,10 @@
    is
       --  Please note: in ncurses they are one off.
       --  This might be different in other implementations of curses
-      Y : C_Int := C_Int (W_Get_Short (Win, Offset_maxy)) + C_Int (Offset_XY);
-      X : C_Int := C_Int (W_Get_Short (Win, Offset_maxx)) + C_Int (Offset_XY);
+      Y : constant C_Int := C_Int (W_Get_Short (Win, Offset_maxy))
+                          + C_Int (Offset_XY);
+      X : constant C_Int := C_Int (W_Get_Short (Win, Offset_maxx))
+                          + C_Int (Offset_XY);
    begin
       Number_Of_Lines   := Line_Count (Y);
       Number_Of_Columns := Column_Count (X);
@@ -1410,8 +1416,8 @@
       Top_Left_Line   : out Line_Position;
       Top_Left_Column : out Column_Position)
    is
-      Y : C_Short := W_Get_Short (Win, Offset_begy);
-      X : C_Short := W_Get_Short (Win, Offset_begx);
+      Y : constant C_Short := W_Get_Short (Win, Offset_begy);
+      X : constant C_Short := W_Get_Short (Win, Offset_begx);
    begin
       Top_Left_Line   := Line_Position (Y);
       Top_Left_Column := Column_Position (X);
@@ -1422,8 +1428,8 @@
       Line   : out Line_Position;
       Column : out Column_Position)
    is
-      Y : C_Short := W_Get_Short (Win, Offset_cury);
-      X : C_Short := W_Get_Short (Win, Offset_curx);
+      Y : constant C_Short := W_Get_Short (Win, Offset_cury);
+      X : constant C_Short := W_Get_Short (Win, Offset_curx);
    begin
       Line   := Line_Position (Y);
       Column := Column_Position (X);
@@ -1435,8 +1441,8 @@
       Top_Left_Column    : out Column_Position;
       Is_Not_A_Subwindow : out Boolean)
    is
-      Y : C_Int := W_Get_Int (Win, Offset_pary);
-      X : C_Int := W_Get_Int (Win, Offset_parx);
+      Y : constant C_Int := W_Get_Int (Win, Offset_pary);
+      X : constant C_Int := W_Get_Int (Win, Offset_parx);
    begin
       if Y = -1 then
          Top_Left_Line   := Line_Position'Last;
@@ -1762,7 +1768,8 @@
       pragma Import (C, Winchnstr, "winchnstr");
 
       N   : Integer := Len;
-      Txt : chtype_array (0 .. Str'Length) := (0 => Default_Character);
+      Txt : constant chtype_array (0 .. Str'Length)
+          := (0 => Default_Character);
       Cnt : Natural := 0;
    begin
       if N < 0 then
@@ -2457,7 +2464,7 @@
       pragma Import (C, C_Assume_Default_Colors, "assume_default_colors");
 
       Err : constant C_Int := C_Assume_Default_Colors (C_Int (Fore),
-                                                       C_Int (Black));
+                                                       C_Int (Back));
    begin
       if Err = Curses_Err then
          raise Curses_Exception;
diff -Naur ncurses-5.4.orig/INSTALL ncurses-5.4/INSTALL
--- ncurses-5.4.orig/INSTALL	2004-02-07 21:06:05.000000000 +0000
+++ ncurses-5.4/INSTALL	2005-05-13 04:09:57.000000000 +0000
@@ -1,4 +1,4 @@
--- $Id: INSTALL,v 1.71 2004/02/07 21:06:05 tom Exp $
+-- $Id: INSTALL,v 1.83 2005/04/23 18:27:03 tom Exp $
 ---------------------------------------------------------------------
              How to install Ncurses/Terminfo on your system
 ---------------------------------------------------------------------
@@ -19,12 +19,6 @@
 If you are converting from BSD curses and do not have root access, be sure
 to read the BSD CONVERSION NOTES section below.
 
-If you are using a version of XFree86 xterm older than 3.1.2F, see the section
-on RECENT XTERM VERSIONS below.
-
-If you are trying to build GNU Emacs using ncurses for terminal support,
-read the USING NCURSES WITH EMACS section below.
-
 If you are trying to build applications using gpm with ncurses,
 read the USING NCURSES WITH GPM section below.
 
@@ -45,7 +39,7 @@
 REQUIREMENTS:
 ------------
 
-You will need the following in order to build and install ncurses under UNIX:
+You will need the following to build and install ncurses under UNIX:
 
 	* ANSI C compiler  (gcc, for instance)
 	* sh               (bash will do)
@@ -64,9 +58,10 @@
     with it.
 
     The --prefix option to configure changes the root directory for installing
-    ncurses.  The default is in subdirectories of /usr/local.  Use
-    --prefix=/usr to replace your default curses distribution.  This is the
-    default for Linux and BSD/OS users.
+    ncurses.  The default is normally in subdirectories of /usr/local, except
+    for systems where ncurses is normally installed as a system library, e.g.,
+    Linux, the various BSD systems and Cygwin.  Use --prefix=/usr to replace
+    your default curses distribution.
 
     The package gets installed beneath the --prefix directory as follows:
 
@@ -77,9 +72,20 @@
     In $(prefix)/include:      C header files
     Under $(prefix)/man:       the manual pages
 
-    Note however that the configure script attempts to locate previous
-    installation of ncurses, and will set the default prefix according to where
-    it finds the ncurses headers.
+    Note that the configure script attempts to locate previous installation of
+    ncurses, and will set the default prefix according to where it finds the
+    ncurses headers.
+
+    Do not use commands such as
+
+    	make install prefix=XXX
+
+    to change the prefix after configuration, since the prefix value is used
+    for some absolute pathnames such as TERMINFO.  Instead do this
+
+    	make install DESTDIR=XXX
+
+    See also the discussion of --with-install-prefix.
 
 2.  Type `./configure' in the top-level directory of the distribution to
     configure ncurses for your operating system and create the Makefiles.
@@ -298,6 +304,11 @@
 	For testing, compile-in code that frees memory that normally would not
 	be freed, to simplify analysis of memory-leaks.
 
+    --disable-lp64
+	The header files will ignore use of the _LP64 symbol to make chtype
+	and mmask_t types 32 bits (they may be long on 64-bit hosts, for
+	compatibility with older releases).
+
     --disable-macros
 	For testing, use functions rather than macros.  The program will run
 	more slowly, but it is simpler to debug.  This makes a header file
@@ -379,6 +390,22 @@
 	For testing, generate functions for certain macros to make them visible
 	as such to the debugger.  See also the --disable-macros option.
 
+    --enable-ext-colors
+	Extend the cchar_t structure to allow more than 16 colors to be
+	encoded.  This applies only to the wide-character (--enable-widec)
+	configuration.
+
+	NOTE: this option is not yet complete (2005/1/29).
+
+	NOTE:  using this option will make libraries which are not binary-
+	compatible with libncursesw 5.4.  None of the interfaces change, but
+	applications which have an array of cchar_t's must be recompiled.
+
+    --enable-ext-mouse
+	Modify the encoding of mouse state to make room for a 5th mouse button.
+	That allows one to use ncurses with a wheel mouse with xterm or
+	similar X terminal emulators.
+
     --enable-getcap
 	Use the 4.4BSD getcap code if available, or a bundled version of it to
 	fetch termcap entries.  Entries read in this way cannot use (make
@@ -401,6 +428,9 @@
 	may not be accurate, or that your stty settings have disabled the use
 	of tabs.
 
+    --enable-largefile
+	Modify compiler flags as needed to use large-file interfaces.
+
     --enable-no-padding
 	Compile-in support for the $NCURSES_NO_PADDING environment variable,
 	which allows you to suppress the effect of non-mandatory padding in
@@ -444,9 +474,9 @@
 	Turn on GCC compiler warnings.  There should be only a few.
 
     --enable-widec
-	Compile with experimental wide-character code.  This makes a different
-	version of the libraries (e.g., libncursesw.so), which stores
-	characters as wide-characters,
+	Compile with wide-character code.  This makes a different version of
+	the libraries (e.g., libncursesw.so), which stores characters as
+	wide-characters,
 
 	NOTE: applications compiled with this configuration are not compatible
 	with those built for 8-bit characters.  You cannot simply make a
@@ -551,7 +581,11 @@
     --with-install-prefix=XXX
 	Allows you to specify an alternate location for installing ncurses
 	after building it.  The value you specify is prepended to the "real"
-	install location.  This simplifies making binary packages.
+	install location.  This simplifies making binary packages.  The
+	makefile variable DESTDIR is set by this option.  It is also possible
+	to use
+		make install DESTDIR=XXX
+	since the makefiles pass that variable to subordinate makes.
 
 	NOTE:  a few systems build shared libraries with fixed pathnames; this
 	option probably will not work for those configurations.
@@ -657,12 +691,19 @@
 	Specify a search-list of terminfo directories which will be compiled
 	into the ncurses library (default: DATADIR/terminfo)
 
-    --with-termlib
+    --with-termlib[=XXX]
 	When building the ncurses library, organize this as two parts:  the
 	curses library (libncurses) and the low-level terminfo library
 	(libtinfo).  This is done to accommodate applications that use only
 	the latter.  The terminfo library is about half the size of the total.
 
+	If an option value is given, that overrides the name of the terminfo
+	library.  For instance, if the wide-character version is built, the
+	terminfo library would be named libtinfow.  But the libtinfow interface
+	is upward compatible from libtinfo, so it would be possible to overlay
+	libtinfo.so with a "wide" version of libtinfow.so by renaming it with
+	this option.
+
     --with-termpath=XXX
 	Specify a search-list of termcap files which will be compiled into the
 	ncurses library (default:  /etc/termcap:/usr/share/misc/termcap)
@@ -698,6 +739,11 @@
 	programs (e.g., tic).  The test applications will still be built if you
 	type "make", though not if you simply do "make install".
 
+    --without-xterm-new
+	Tell the configure script to use "xterm-old" for the entry used in
+	the terminfo database.  This will work with variations such as
+	X11R5 and X11R6 xterm.
+
 
 COMPATIBILITY WITH OLDER VERSIONS OF NCURSES:
 --------------------------------------------
@@ -1063,17 +1109,10 @@
 ---------------------
 
 	The terminfo database file included with this distribution assumes you
-	are running an XFree86 xterm based on X11R6 (i.e., xterm-r6).  The
-	earlier X11R5 entry (xterm-r5) is provided as well.
-
-	If you are running XFree86 version 3.2 (actually 3.1.2F and up), you
-	should consider using the xterm-xf86-v32 (or later, the most recent
-	version is always named "xterm-xfree86") entry, which adds ANSI color
-	and the VT220 capabilities which have been added in XFree86.  If you
-	are running a mixed network, however, where this terminal description
-	may be used on an older xterm, you may have problems, since
-	applications that assume these capabilities will produce incorrect
-	output on the older xterm (e.g., highlighting is not cleared).
+	are running a modern xterm based on XFree86 (i.e., xterm-new).  The
+	earlier X11R6 entry (xterm-r6) and X11R5 entry (xterm-r5) is provided
+	as well.  See the --without-xterm-new configure script option if you
+	are unable to update your system.
 
 
 CONFIGURING FALLBACK ENTRIES:
@@ -1186,17 +1225,6 @@
 	can't hard-link across them.  The --enable-symlinks option copes
 	with this by making tic use symbolic links.
 
-USING NCURSES WITH EMACS:
-	GNU Emacs has its own termcap support.  By default, it uses a mixture
-	of those functions and code linked from the host system's libraries.
-	You need to foil this and shut out the GNU termcap library entirely.
-
-	In order to do this, hack the Linux config file (s/linux.h) to contain
-	a #define TERMINFO and set the symbol LIBS_TERMCAP to "-lncurses".
-
-	We have submitted such a change for the 19.30 release, so it may
-	already be applied in your sources -- check for the #define TERMINFO.
-
 USING NCURSES WITH GPM:
 	Ncurses 4.1 and up can be configured to use GPM (General Purpose Mouse)
 	which is used on Linux console.  Be aware that GPM is commonly
@@ -1210,13 +1238,9 @@
 		cc -o foo foo.o -lncurses -lgpm -lncurses
 
 	but the linker may not cooperate, producing mysterious errors.
-	A patched version of gpm is available:
-
-		dickey.his.com:/ncurses/gpm-1.10-970125.tar.gz
+	See the FAQ:
 
-	This patch is incorporated in gpm 1.12; however some integrators
-	are slow to update this library.  Current distributions of gpm can
-	be configured properly using the --without-curses option.
+	http://invisible-island.net/ncurses/ncurses.faq.html#using_gpm_lib
 
 BUILDING NCURSES WITH A CROSS-COMPILER
 	Ncurses can be built with a cross-compiler.  Some parts must be built
diff -Naur ncurses-5.4.orig/MANIFEST ncurses-5.4/MANIFEST
--- ncurses-5.4.orig/MANIFEST	2004-01-03 23:04:44.000000000 +0000
+++ ncurses-5.4/MANIFEST	2005-05-13 04:09:58.000000000 +0000
@@ -433,6 +433,7 @@
 ./doc/ncurses-intro.doc
 ./form/Makefile.in
 ./form/READ.ME
+./form/f_trace.c
 ./form/fld_arg.c
 ./form/fld_attr.c
 ./form/fld_current.c
@@ -663,6 +664,7 @@
 ./menu/m_scale.c
 ./menu/m_spacing.c
 ./menu/m_sub.c
+./menu/m_trace.c
 ./menu/m_userptr.c
 ./menu/m_win.c
 ./menu/menu.h
@@ -677,11 +679,13 @@
 ./misc/emx.src
 ./misc/form.def
 ./misc/form.ref
-./misc/indent.pro
+./misc/gen_edit.sh
+./misc/jpf-indent
 ./misc/makedef.cmd
 ./misc/makellib
 ./misc/menu.def
 ./misc/menu.ref
+./misc/ncu-indent
 ./misc/ncurses.def
 ./misc/ncurses.ref
 ./misc/panel.def
@@ -738,6 +742,7 @@
 ./ncurses/base/lib_initscr.c
 ./ncurses/base/lib_insch.c
 ./ncurses/base/lib_insdel.c
+./ncurses/base/lib_insnstr.c
 ./ncurses/base/lib_instr.c
 ./ncurses/base/lib_isendwin.c
 ./ncurses/base/lib_leaveok.c
@@ -958,6 +963,7 @@
 ./test/demo_keyok.c
 ./test/demo_menus.c
 ./test/demo_panels.c
+./test/demo_termcap.c
 ./test/ditto.c
 ./test/dots.c
 ./test/edit_field.c
@@ -973,6 +979,7 @@
 ./test/inserts.c
 ./test/keynames.c
 ./test/knight.c
+./test/linux-color.dat
 ./test/listused.sh
 ./test/lrtest.c
 ./test/modules
@@ -990,3 +997,5 @@
 ./test/view.c
 ./test/worm.c
 ./test/xmas.c
+./test/xterm-16color.dat
+./test/xterm-88color.dat
diff -Naur ncurses-5.4.orig/Makefile.in ncurses-5.4/Makefile.in
--- ncurses-5.4.orig/Makefile.in	2001-10-27 18:17:22.000000000 +0000
+++ ncurses-5.4/Makefile.in	2005-05-13 04:09:49.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.22 2001/10/27 18:17:22 tom Exp $
+# $Id: Makefile.in,v 1.24 2005/01/29 19:30:06 tom Exp $
 ##############################################################################
-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -65,6 +65,9 @@
 	@ echo ''
 	@ echo '** Configuration summary for NCURSES $(NCURSES_MAJOR).$(NCURSES_MINOR) $(NCURSES_PATCH):'
 	@ echo ''
+	@ echo '     extended funcs: '`test @NCURSES_EXT_FUNCS@ != 0 && echo yes || echo no`
+	@ echo '     xterm terminfo: '@WHICH_XTERM@
+	@ echo ''
 	@ echo '      bin directory: '$(bindir)
 	@ echo '      lib directory: '$(libdir)
 	@ echo '  include directory: '$(includedir)
@@ -89,5 +92,6 @@
 realclean \
 depend \
 sources \
+tags \
 uninstall \
 install ::
diff -Naur ncurses-5.4.orig/NEWS ncurses-5.4/NEWS
--- ncurses-5.4.orig/NEWS	2004-02-08 21:15:26.000000000 +0000
+++ ncurses-5.4/NEWS	2005-05-13 04:09:59.000000000 +0000
@@ -1,4 +1,4 @@
--- $Id: NEWS,v 1.797 2004/02/08 21:15:26 tom Exp $
+-- $Id: NEWS,v 1.894 2005/05/07 23:44:35 tom Exp $
 
 This is a log of changes that ncurses has gone through since Zeyd started
 working with Pavel Curtis' original work, pcurses, in 1992.
@@ -6,6 +6,598 @@
 Changes through 1.9.9e are recorded by Zeyd M. Ben-Halim.
 Changes since 1.9.9e are recorded by Thomas Dickey.
 
+20050507
+	+ regenerated html documentation for manpages.
+	+ add $(BUILD_EXEEXT) suffix to invocation of make_keys in
+	  ncurses/Makefile (Gentoo #89772).
+	+ modify c++/demo.cc to build with g++ -fno-implicit-templates option
+	  (patch by Mike Frysinger).
+	+ modify tic to filter out long extended names when translating to
+	  termcap format.  Only two characters are permissible for termcap
+	  capability names.
+
+20050430
+	+ modify terminfo entries xterm-new and rxvt to add strings for
+	  shift-, control-cursor keys.
+	+ workaround to allow c++ binding to compile with g++ 2.95.3, which
+	  has a broken implementation of static_cast<> (patch by Jeff Chua).
+	+ modify initialization of key lookup table so that if an extended
+	  capability (tic -x) string is defined, and its name begins with 'k',
+	  it will automatically be treated as a key.
+	+ modify test/keynames.c to allow for the possibility of extended
+	  key names, e.g., via define_key(), or via "tic -x".
+	+ add test/demo_termcap.c to show the contents of given entry via the
+	  termcap interface.
+
+20050423
+	+ minor fixes for vt100/vt52 entries -TD
+	+ add configure option --enable-largefile
+	+ corrected libraries used to build Ada95/gen/gen, found in testing
+	  gcc 4.0.0.
+
+20050416
+	+ update config.guess, config.sub
+	+ modify configure script check for _XOPEN_SOURCE, disable that on
+	  Darwin whose header files have problems (patch by Chris Zubrzycki).
+	+ modify form library Is_Printable_String() to use iswprint() rather
+	  than wcwidth() for determining if a character is printable.  The
+	  latter caused it to reject menu items containing non-spacing
+	  characters.
+	+ modify ncurses test program's F-test to handle non-spacing characters
+	  by combining them with a reverse-video blank.
+	+ review/fix several gcc -Wconversion warnings.
+
+20050409
+	+ correct an off-by-one error in m_driver() for mouse-clicks used to
+	  position the mouse to a particular item.
+	+ implement test/demo_menus.c
+	+ add some checks in lib_mouse to ensure SP is set.
+	+ modify C++ binding to make 20050403 changes work with the configure
+	  --enable-const option.
+
+20050403
+	+ modify start_color() to return ERR if it cannot allocate memory.
+	+ address g++ compiler warnings in C++ binding by adding explicit
+	  member initialization, assignment operators and copy constructors.
+	  Most of the changes simply preserve the existing semantics of the
+	  binding, which can leak memory, etc., but by making these features
+	  visible, it provides a framework for improving the binding.
+	+ improve C++ binding using static_cast, etc.
+	+ modify configure script --enable-warnings to add options to g++ to
+	  correspond to the gcc --enable-warnings.
+	+ modify C++ binding to use some C internal functions to make it
+	  compile properly on Solaris (and other platforms).
+
+20050327
+	+ amend change from 20050320 to limit it to configurations with a
+	  valid locale.
+	+ fix a bug introduced in 20050320 which broke the translation of
+	  nonprinting characters to uparrow form (report by TAKAHASHI Tamotsu).
+
+20050326
+	+ add ifdef's for _LP64 in curses.h to avoid using wasteful 64-bits for
+	  chtype and mmask_t, but add configure option --disable-lp64 in case
+	  anyone used that configuration.
+	+ update misc/shlib script to account for Mac OS X (report by Michail
+	  Vidiassov).
+	+ correct comparison for wrapping multibyte characters in
+	  waddch_literal() (report by TAKAHASHI Tamotsu).
+
+20050320
+	+ add -c and -w options to tset to allow user to suppress ncurses'
+	  resizing of the terminal emulator window in the special case where it
+	  is not able to detect the true size (report by Win Delvaux, Debian
+	  #300419).
+	+ modify waddch_nosync() to account for locale zn_CH.GBK, which uses
+	  codes 128-159 as part of multibyte characters (report by WANG
+	  WenRui, Debian #300512).
+
+20050319
+	+ modify ncurses.c 'd' test to make it work with 88-color
+	  configuration, i.e., by implementing scrolling.
+	+ improve scrolling in ncurses.c 'c' and 'C' tests, e.g., for 88-color
+	  configuration.
+
+20050312
+	+ change tracemunch to use strict checking.
+	+ modify ncurses.c 'p' test to test line-drawing within a pad.
+	+ implement environment variable NCURSES_NO_UTF8_ACS to support
+	  miscellaneous terminal emulators which ignore alternate character
+	  set escape sequences when in UTF-8 mode.
+
+20050305
+	+ change NCursesWindow::err_handler() to a virtual function (request by
+	  Steve Beal).
+	+ modify ftp_int.c and fty_num.c to handle wide characters (report by
+	  Wolfgang Gutjahr).
+	+ adapt fix for fty_alpha.c to fty_alnum.c, which also handled normal
+	  and wide characters inconsistently (report by Wolfgang Gutjahr).
+	+ update llib-* files to reflect internal interface additions/changes.
+
+20050226
+	+ improve test/configure script, adding tests for _XOPEN_SOURCE, etc.,
+	  from lynx.
+	+ add aixterm-16color terminfo entry -TD
+	+ modified xterm-new terminfo entry to work with tgetent() changes -TD
+	+ extended changes in tgetent() from 20040710 to allow the substring of
+	  sgr0 which matches rmacs to be at the beginning of the sgr0 string
+	  (request by Thomas Wolff, who says the visual effect in combination
+	  with pre-20040710 ncurses is improved).
+	+ fix off-by-one in winnstr() call which caused form field validation
+	  of multibyte characters to ignore the last character in a field.
+	+ correct logic in winsch() for inserting multibyte strings; the code
+	  would clear cells after the insertion rather than push them to the
+	  right (cf: 20040228).
+	+ fix an inconsistency in Check_Alpha_Field() between normal and wide
+	  character logic (report by Wolfgang Gutjahr).
+
+20050219
+	+ fix a bug in editing wide-characters in form library: deleting a
+	  nonwide character modified the previous wide-character.
+	+ update manpage to describe NCURSES_MOUSE_VERSION 2.
+	+ correct manpage description of mouseinterval() (Debian #280687).
+	+ add a note to default_colors.3x explaining why this extension was
+	  added (Debian #295083).
+	+ add traces to panel library.
+
+20050212
+	+ improve editing of wide-characters in form library:  left/right
+	  cursor movement, and single-character deletions work properly.
+	+ disable GPM mouse support when $TERM happens to be prefixed with
+	  "xterm".  Gpm_Open() would otherwise assert that it can deal with
+	  mouse events in this case.
+	+ modify GPM mouse support so it closes the server connection when
+	  the caller disables the mouse (report by Stanislav Ievlev).
+
+20050205
+	+ add traces for callback functions in form library.
+	+ add experimental configure option --enable-ext-mouse, which defines
+	  NCURSES_MOUSE_VERSION 2, and modifies the encoding of mouse events to
+	  support wheel mice, which may transmit buttons 4 and 5.  This works
+	  with xterm and similar X terminal emulators (prompted by question by
+	  Andreas Henningsson, this is also related to Debian #230990).
+	+ improve configure macros CF_XOPEN_SOURCE and CF_POSIX_C_SOURCE to
+	  avoid redefinition warnings on cygwin.
+
+20050129
+	+ merge remaining development changes for extended colors (mostly
+	  complete, does not appear to break other configurations).
+	+ add xterm-88color.dat (part of extended colors testing).
+	+ improve _tracedump() handling of color pairs past 96. 
+	+ modify return-value from start_color() to return OK if colors have
+	  already been started.
+	+ modify curs_color.3x list error conditions for init_pair(),
+	  pair_content() and color_content().
+	+ modify pair_content() to return -1 for consistency with init_pair()
+	  if it corresponds to the default-color.
+	+ change internal representation of default-color to allow application
+	  to use color number 255.  This does not affect the total number of
+	  color pairs which are allowed.
+	+ add a top-level tags rule.
+
+20050122
+	+ add a null-pointer check in wgetch() in case it is called without
+	  first calling initscr().
+	+ add some null-pointer checks for SP, which is not set by libtinfo.
+	+ modify misc/shlib to ensure that absolute pathnames are used.
+	+ modify test/Makefile.in, etc., to link test programs only against the
+	  libraries needed, e.g., omit form/menu/panel library for the ones
+	  that are curses-specific.
+	+ change SP->_current_attr to a pointer, adjust ifdef's to ensure that
+	  libtinfo.so and libtinfow.so have the same ABI.  The reason for this
+	  is that the corresponding data which belongs to the upper-level
+	  ncurses library has a different size in each model (report by
+	  Stanislav Ievlev).
+
+20050115
+	+ minor fixes to allow test-compiles with g++.
+	+ correct column value shown in tic's warnings, which did not account
+	  for leading whitespace.
+	+ add a check in _nc_trans_string() for improperly ended strings, i.e.,
+	  where a following line begins in column 1.
+	+ modify _nc_save_str() to return a null pointer on buffer overflow.
+	+ improve repainting while scrolling wide-character data (Eungkyu Song).
+
+20050108
+	+ merge some development changes to extend color capabilities.
+
+20050101
+	+ merge some development changes to extend color capabilities.
+	+ fix manpage typo (FreeBSD report docs/75544).
+	+ update config.guess, config.sub
+	> patches by Albert Chin-A-Young (for configure script):
+	+ improved fix to make mbstate_t recognized on HPUX 11i (cf: 
+	  20030705), making vsscanf() prototype visible on IRIX64.  Tested for
+	  on HP-UX 11i, Solaris 7, 8, 9, AIX 4.3.3, 5.2, Tru64 UNIX 4.0D, 5.1,
+	  IRIX64 6.5, Redhat Linux 7.1, 9, and RHEL 2.1, 3.0.
+	+ print the result of the --disable-home-terminfo option.
+	+ use -rpath when compiling with SGI C compiler.
+
+20041225
+	+ add trace calls to remaining public functions in form and menu
+	  libraries.
+	+ fix check for numeric digits in test/ncurses.c 'b' and 'B' tests.
+	+ fix typo in test/ncurses.c 'c' test from 20041218.
+
+20041218
+	+ revise test/ncurses.c 'c' color test to improve use for xterm-88color
+	  and xterm-256color, added 'C' test using the wide-character color_set
+	  and attr_set functions.
+
+20041211
+	+ modify configure script to work with Intel compiler.
+	+ fix an limit-check in wadd_wchnstr() which caused labels in the
+	  forms-demo to be one character short.
+	+ fix typo in curs_addchstr.3x (Jared Yanovich).
+	+ add trace calls to most functions in form and menu libraries.
+	+ update working-position for adding wide-characters when window is
+	  scrolled (prompted by related report by Eungkyu Song).
+
+20041204
+	+ replace some references on Linux to wcrtomb() which use it to obtain
+	  the length of a multibyte string with _nc_wcrtomb, since wcrtomb() is
+	  broken in glibc (see Debian #284260).
+	+ corrected length-computation in wide-character support for
+	  field_buffer().
+	+ some fixes to frm_driver.c to allow it to accept multibyte input.
+	+ modify configure script to work with Intel 8.0 compiler.
+
+20041127
+	+ amend change to setupterm() in 20030405 which would reuse the value
+	  of cur_term if the same output was selected.  This now reuses it only
+	  when setupterm() is called from tgetent(), which has no notion of
+	  separate SCREENs.  Note that tgetent() must be called after initscr()
+	  or newterm() to use this feature (Redhat Bugzilla #140326).
+	+ add a check in CF_BUILD_CC macro to ensure that developer has given
+	  the --with-build-cc option when cross-compiling (report by Alexandre
+	  Campo).
+	+ improved configure script checks for _XOPEN_SOURCE and
+	  _POSIX_C_SOURCE (fix for IRIX 5.3 from Georg Schwarz, _POSIX_C_SOURCE
+	  updates from lynx).
+	+ cosmetic fix to test/gdc.c to recolor the bottom edge of the box
+	  for consistency (comment by Dan Nelson).
+
+20041120
+	+ update wsvt25 terminfo entry -TD
+	+ modify test/ins_wide.c to test all flavors of ins_wstr().
+	+ ignore filler-cells in wadd_wchnstr() when adding a cchar_t array
+	  which consists of multi-column characters, since this function
+	  constructs them (cf: 20041023).
+	+ modify winnstr() to return multibyte character strings for the
+	  wide-character configuration.
+
+20041106
+	+ fixes to make slk_set() and slk_wset() accept and store multibyte
+	  or multicolumn characters.
+
+20041030
+	+ improve color optimization a little by making _nc_do_color() check
+	  if the old/new pairs are equivalent to the default pair 0.
+	+ modify assume_default_colors() to not require that
+	  use_default_colors() be called first.
+
+20041023
+	+ modify term_attrs() to use termattrs(), add the extended attributes
+	  such as enter_horizontal_hl_mode for WA_HORIZONTAL to term_attrs().
+	+ add logic in waddch_literal() to clear orphaned cells when one
+	  multi-column character partly overwrites another.
+	+ improved logic for clearing cells when a multi-column character
+	  must be wrapped to a new line.
+	+ revise storage of cells for multi-column characters to correct a
+	  problem with repainting.  In the old scheme, it was possible for
+	  doupdate() to decide that only part of a multi-column character
+	  should be repainted since the filler cells stored only an attribute
+	  to denote them as fillers, rather than the character value and the
+	  attribute.
+
+20041016
+	+ minor fixes for traces.
+	+ add SP->_screen_acs_map[], used to ensure that mapping of missing
+	  line-drawing characters is handled properly.  For example, ACS_DARROW
+	  is absent from xterm-new, and it was coincidentally displayed the
+	  same as ACS_BTEE.
+
+20041009
+	+ amend 20021221 workaround for broken acs to reset the sgr, rmacs
+	  and smacs strings as well.  Also modify the check for screen's
+	  limitations in that area to allow the multi-character shift-in
+	  and shift-out which seem to work.
+	+ change GPM initialization, using dl library to load it dynamically
+	  at runtime (Debian #110586).
+
+20041002
+	+ correct logic for color pair in setcchar() and getcchar() (patch by
+	  Marcin 'Qrczak' Kowalczyk).
+	+ add t/T commands to ncurses b/B tests to allow a different color to
+	  be tested for the attrset part of the test than is used in the
+	  background color.
+
+20040925
+	+ fix to make setcchar() to work when its wchar_t* parameter is
+	  pointing to a string which contains more data than can be converted.
+	+ modify wget_wstr() and example in ncurses.c to work if wchar_t and
+	  wint_t are different sizes (report by Marcin 'Qrczak' Kowalczyk).
+
+20040918
+	+ remove check in wget_wch() added to fix an infinite loop, appears to
+	  have been working around a transitory glibc bug, and interferes
+	  with normal operation (report by Marcin 'Qrczak' Kowalczyk).
+	+ correct wadd_wch() and wecho_wch(), which did not pass the rendition
+	  information (report by Marcin 'Qrczak' Kowalczyk).
+	+ fix aclocal.m4 so that the wide-character version of ncurses gets
+	  compiled as libncursesw.5.dylib, instead of libncurses.5w.dylib
+	  (adapted from patch by James J Ramsey).
+	+ change configure script for --with-caps option to indicate that it
+	  is no longer experimental.
+	+ change configure script to reflect the fact that --enable-widec has
+	  not been "experimental" since 5.3 (report by Bruno Lustosa).
+
+20040911
+	+ add 'B' test to ncurses.c, to exercise some wide-character functions.
+
+20040828
+	+ modify infocmp -i option to match 8-bit controls against its table
+	  entries, e.g., so it can analyze the xterm-8bit entry.
+	+ add morphos terminfo entry, improve amiga-8bit entry (Pavel Fedin).
+	+ correct translation of "%%" in terminfo format to termcap, e.g.,
+	  using "tic -C" (Redhat Bugzilla #130921).
+	+ modified configure script CF_XOPEN_SOURCE macro to ensure that if
+	  it defines _POSIX_C_SOURCE, that it defines it to a specific value
+	  (comp.os.stratus newsgroup comment).
+
+20040821
+	+ fixes to build with Ada95 binding with gnat 3.4 (all warnings are
+	  fatal, and gnat does not follow the guidelines for pragmas).
+	  However that did find a coding error in Assume_Default_Colors().
+	+ modify several terminfo entries to ensure xterm mouse and cursor
+	  visibility are reset in rs2 string:  hurd, putty, gnome,
+	  konsole-base, mlterm, Eterm, screen (Debian #265784, #55637).  The
+	  xterm entries are left alone - old ones for compatibility, and the
+	  new ones do not require this change. -TD
+
+20040814
+	+ fake a SIGWINCH in newterm() to accommodate buggy terminal emulators
+	  and window managers (Debian #265631).
+	> terminfo updates -TD
+	+ remove dch/dch1 from rxvt because they are implemented inconsistently
+	  with the common usage of bce/ech
+	+ remove khome from vt220 (vt220's have no home key)
+	+ add rxvt+pcfkeys
+
+20040807
+	+ modify test/ncurses.c 'b' test, adding v/V toggles to cycle through
+	  combinations of video attributes so that for instance bold and
+	  underline can be tested.  This made the legend too crowded, added
+	  a help window as well.
+	+ modify test/ncurses.c 'b' test to cycle through default colors if
+	  the -d option is set.
+	+ update putty terminfo entry (Robert de Bath).
+
+20040731
+	+ modify test/cardfile.c to allow it to read more data than can be
+	  displayed.
+	+ correct logic in resizeterm.c which kept it from processing all
+	  levels of window hierarchy (reports by Folkert van Heusden,
+	  Chris Share).
+
+20040724
+	+ modify "tic -cv" to ignore delays when comparing strings.  Also
+	  modify it to ignore a canceled sgr string, e.g., for terminals which
+	  cannot properly combine attributes in one control sequence.
+	+ corrections for gnome and konsole entries (Redhat Bugzilla #122815,
+	  patch by Hans de Goede)
+	> terminfo updates -TD
+	+ make ncsa-m rmacs/smacs consistent with sgr
+	+ add sgr, rc/sc and ech to syscons entries
+	+ add function-keys to decansi
+	+ add sgr to mterm-ansi
+	+ add sgr, civis, cnorm to emu
+	+ correct/simplify cup in addrinfo
+
+20040717
+	> terminfo updates -TD
+	+ add xterm-pc-fkeys
+	+ review/update gnome and gnome-rh90 entries (prompted by Redhat
+	  Bugzilla #122815).
+	+ review/update konsole entries
+	+ add sgr, correct sgr0 for kterm and mlterm
+	+ correct tsl string in kterm
+
+20040711
+	+ add configure option --without-xterm-new
+
+20040710
+	+ add check in wget_wch() for printable bytes that are not part of a
+	  multibyte character.
+	+ modify wadd_wchnstr() to render text using window's background
+	  attributes.
+	+ improve tic's check to compare sgr and sgr0.
+	+ fix c++ directory's .cc.i rule.
+	+ modify logic in tgetent() which adjusts the termcap "me" string
+	  to work with ISO-2022 string used in xterm-new (cf: 20010908).
+	+ modify tic's check for conflicting function keys to omit that if
+	  converting termcap to termcap format.
+	+ add -U option to tic and infocmp.
+	+ add rmam/smam to linux terminfo entry (Trevor Van Bremen)
+	> terminfo updates -TD
+	+ minor fixes for emu
+	+ add emu-220
+	+ change wyse acsc strings to use 'i' map rather than 'I'
+	+ fixes for avatar0
+	+ fixes for vp3a+
+
+20040703
+	+ use tic -x to install terminfo database -TD
+	+ add -x to infocmp's usage message.
+	+ correct field used for comparing O_ROWMAJOR in set_menu_format()
+	  (report/patch by Tony Li).
+	+ fix a missing nul check in set_field_buffer() from 20040508 changes.
+	> terminfo updates -TD
+	  + make xterm-xf86-v43 derived from xterm-xf86-v40 rather than
+	    xterm-basic -TD
+	  + align with xterm patch #192's use of xterm-new -TD
+	  + update xterm-new and xterm-8bit for cvvis/cnorm strings -TD
+	  + make xterm-new the default "xterm" entry -TD
+
+20040626
+	+ correct BUILD_CPPFLAGS substitution in ncurses/Makefile.in, to allow
+	  cross-compiling from a separate directory tree (report/patch by
+	  Dan Engel).
+	+ modify is_term_resized() to ensure that window sizes are nonzero,
+	  as documented in the manpage (report by Ian Collier).
+	+ modify CF_XOPEN_SOURCE configure macro to make Hurd port build
+	  (Debian #249214, report/patch by Jeff Bailey).
+	+ configure-script mods from xterm, e.g., updates to CF_ADD_CFLAGS
+	+ update config.guess, config.sub
+	> terminfo updates -TD
+	  + add mlterm
+	  + add xterm-xf86-v44
+	  + modify xterm-new aka xterm-xfree86 to accommodate luit, which
+	    relies on G1 being used via an ISO-2022 escape sequence (report by
+	    Juliusz Chroboczek)
+	  + add 'hurd' entry
+
+20040619
+	+ reconsidered winsnstr(), decided after comparing other
+	  implementations that wrapping is an X/Open documentation error.
+	+ modify test/inserts.c to test all flavors of insstr().
+
+20040605
+	+ add setlocale() calls to a few test programs which may require it:
+	  demo_forms.c, filter.c, ins_wide.c, inserts.c
+	+ correct a few misspelled function names in ncurses-intro.html (report
+	  by Tony Li).
+	+ correct internal name of key_defined() manpage, which conflicted with
+	  define_key().
+
+20040529
+	+ correct size of internal pad used for holding wide-character
+	  field_buffer() results.
+	+ modify data_ahead() to work with wide-characters.
+
+20040522
+	+ improve description of terminfo if-then-else expressions (suggested
+	  by Arne Thomassen).
+	+ improve test/ncurses.c 'd' test, allow it to use external file for
+	  initial palette (added xterm-16color.dat and linux-color.dat), and
+	  reset colors to the initial palette when starting/ending the test.
+	+ change limit-check in init_color() to allow r/g/b component to
+	  reach 1000 (cf: 20020928).
+
+20040516
+	+ modify form library to use cchar_t's rather than char's in the
+	  wide-character configuration for storing data for field buffers.
+	+ correct logic of win_wchnstr(), which did not work for more than
+	  one cell.
+
+20040508
+	+ replace memset/memcpy usage in form library with for-loops to
+	  simplify changing the datatype of FIELD.buf, part of wide-character
+	  changes.
+	+ fix some inconsistent use of #if/#ifdef (report by Alain Guibert).
+
+20040501
+	+ modify menu library to account for actual number of columns used by
+	  multibyte character strings, in the wide-character configuration
+	  (adapted from patch by Philipp Tomsich).
+	+ add "-x" option to infocmp like tic's "-x", for use in "-F"
+	  comparisons.  This modifies infocmp to only report extended
+	  capabilities if the -x option is given, making this more consistent
+	  with tic.  Some scripts may break, since infocmp previous gave this
+	  information without an option.
+	+ modify termcap-parsing to retain 2-character aliases at the beginning
+	  of an entry if the "-x" option is used in tic.
+
+20040424
+	+ minor compiler-warning and test-program fixes.
+
+20040417
+	+ modify tic's missing-sgr warning to apply to terminfo only.
+	+ free some memory leaks in tic.
+	+ remove check in post_menu() that prevented menus from extending
+	  beyond the screen (request by Max J. Werner).
+	+ remove check in newwin() that prevents allocating windows
+	  that extend beyond the screen.  Solaris curses does this.
+	+ add ifdef in test/color_set.c to allow it to compile with older
+	  curses.
+	+ add napms() calls to test/dots.c to make it not be a CPU hog.
+
+20040403
+	+ modify unctrl() to return null if its parameter does not correspond
+	  to an unsigned char.
+	+ add some limit-checks to guard isprint(), etc., from being used on
+	  values that do not fit into an unsigned char (report by Sami Farin).
+
+20040328
+	+ fix a typo in the _nc_get_locale() change.
+
+20040327
+	+ modify _nc_get_locale() to use setlocale() to query the program's
+	  current locale rather than using getenv().  This fixes a case in tin
+	  which relies on legacy treatment of 8-bit characters when the locale
+	  is not initialized (reported by Urs Jansen).
+	+ add sgr string to screen's and rxvt's terminfo entries -TD.
+	+ add a check in tic for terminfo entries having an sgr0 but no sgr
+	  string.  This confuses Tru64 and HPUX curses when combined with
+	  color, e.g., making them leave line-drawing characters in odd places.
+	+ correct casts used in ABSENT_BOOLEAN, CANCELLED_BOOLEAN, matches the
+	  original definitions used in Debian package to fix PowerPC bug before
+	  20030802 (Debian #237629).
+
+20040320
+	+ modify PutAttrChar() and PUTC() macro to improve use of
+	  A_ALTCHARSET attribute to prevent line-drawing characters from
+	  being lost in situations where the locale would otherwise treat the
+	  raw data as nonprintable (Debian #227879).
+
+20040313
+	+ fix a redefinition of CTRL() macro in test/view.c for AIX 5.2 (report
+	  by Jim Idle).
+	+ remove ".PP" after ".SH NAME" in a few manpages; this confuses
+	  some apropos script (Debian #237831).
+
+20040306
+	+ modify ncurses.c 'r' test so editing commands, like inserted text,
+	  set the field background, and the state of insert/overlay editing
+	  mode is shown in that test.
+	+ change syntax of dummy targets in Ada95 makefiles to work with pmake.
+	+ correct logic in test/ncurses.c 'b' for noncolor terminals which
+	  did not recognize a quit-command (cf: 20030419).
+
+20040228
+	+ modify _nc_insert_ch() to allow for its input to be part of a
+	  multibyte string.
+	+ split out lib_insnstr.c, to prepare to rewrite it.  X/Open states
+	  that this function performs wrapping, unlike all of the other
+	  insert-functions.  Currently it does not wrap.
+	+ check for nl_langinfo(CODESET), use it if available (report by
+	  Stanislav Ievlev).
+	+ split-out CF_BUILD_CC macro, actually did this for lynx first.
+	+ fixes for configure script CF_WITH_DBMALLOC and CF_WITH_DMALLOC,
+	  which happened to work with bash, but not with Bourne shell (report
+	  by Marco d'Itri via tin-dev).
+
+20040221
+	+ some changes to adapt the form library to wide characters, incomplete
+	  (request by Mike Aubury).
+	+ add symbol to curses.h which can be used to suppress include of
+	  stdbool.h, e.g.,
+	  	#define NCURSES_ENABLE_STDBOOL_H 0
+		#include <curses.h>
+	  (discussion on XFree86 mailing list).
+
+20040214
+	+ modify configure --with-termlib option to accept a value which sets
+	  the name of the terminfo library.  This would allow a packager to
+	  build libtinfow.so renamed to coincide with libtinfo.so (discussion
+	  with Stanislav Ievlev).
+	+ improve documentation of --with-install-prefix, --prefix and
+	  $(DESTDIR) in INSTALL (prompted by discussion with Paul Lew).
+	+ add configure check if the compiler can use -c -o options to rename
+	  its output file, use that to omit the 'cd' command which was used to
+	  ensure object files are created in a separate staging directory
+	  (prompted by comments by Johnny Wezel, Martin Mokrejs).
+
 20040208 5.4 release for upload to ftp.gnu.org
 	+ update TO-DO.
 
@@ -6014,7 +6606,8 @@
 	+ added has_key()
 	+ added 't' to ncurses.c test.
 	+ moved delay_output() to lib_tputs.c
-	+ removed tparam().
+	+ removed tparam() (was added in 1.9.9, but conflicts with emacs and
+	  is not part of X/Open Curses).
 	+ misc cursor & optimization fixes.
 
 960504	- snapshot
diff -Naur ncurses-5.4.orig/README ncurses-5.4/README
--- ncurses-5.4.orig/README	2003-02-08 19:36:39.000000000 +0000
+++ ncurses-5.4/README	2005-05-13 04:09:49.000000000 +0000
@@ -1,4 +1,4 @@
--- $Id: README,v 1.21 2003/02/08 19:36:39 tom Exp $
+-- $Id: README,v 1.22 2004/08/07 23:42:43 tom Exp $
 -------------------------------------------------------------------------------
 		README file for the ncurses package
 
@@ -64,7 +64,7 @@
 In the `Ada95' directory, you'll find code and documentation for an
 Ada95 binding of the curses API, to be used with the GNAT compiler.
 This binding is built by a normal top-level `make' if configure detects
-an usable version of GNAT (3.10 or above). It is not installed automatically.
+an usable version of GNAT (3.11 or above). It is not installed automatically.
 See the Ada95 directory for more build and installation instructions and
 for documentation of the binding.
 
diff -Naur ncurses-5.4.orig/TO-DO ncurses-5.4/TO-DO
--- ncurses-5.4.orig/TO-DO	2004-02-08 21:09:00.000000000 +0000
+++ ncurses-5.4/TO-DO	2005-05-13 04:09:49.000000000 +0000
@@ -1,4 +1,4 @@
--- $Id: TO-DO,v 1.43 2004/02/08 21:09:00 tom Exp $
+-- $Id: TO-DO,v 1.44 2004/03/07 02:04:20 tom Exp $
 
 SHORT-TERM TO-DO ITEMS:
 
@@ -6,9 +6,6 @@
 
 * The form/menu libraries do not use wide-character features.
 
-* Some users would like to build a single version of libtinfo which can be
-  used from either libncursesw or libncurses.
-
 * libtool does not work with GNAT.
 
 * The screen optimization has been tested only in an ad hoc manner.  We should
diff -Naur ncurses-5.4.orig/aclocal.m4 ncurses-5.4/aclocal.m4
--- ncurses-5.4.orig/aclocal.m4	2004-01-30 20:59:56.000000000 +0000
+++ ncurses-5.4/aclocal.m4	2005-05-13 04:09:56.000000000 +0000
@@ -1,5 +1,5 @@
 dnl***************************************************************************
-dnl Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+dnl Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
 dnl                                                                          *
 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
 dnl copy of this software and associated documentation files (the            *
@@ -26,15 +26,38 @@
 dnl authorization.                                                           *
 dnl***************************************************************************
 dnl
-dnl Author: Thomas E. Dickey 1995-2003
+dnl Author: Thomas E. Dickey 1995-on
 dnl
-dnl $Id: aclocal.m4,v 1.333 2004/01/30 20:59:56 tom Exp $
+dnl $Id: aclocal.m4,v 1.354 2005/04/16 23:08:58 tom Exp $
 dnl Macros used in NCURSES auto-configuration script.
 dnl
 dnl See http://invisible-island.net/autoconf/ for additional information.
 dnl
 dnl ---------------------------------------------------------------------------
 dnl ---------------------------------------------------------------------------
+dnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
+dnl -------------------
+dnl Inserted as requested by gettext 0.10.40
+dnl File from /usr/share/aclocal
+dnl codeset.m4
+dnl ====================
+dnl serial AM1
+dnl
+dnl From Bruno Haible.
+AC_DEFUN([AM_LANGINFO_CODESET],
+[
+  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
+    [AC_TRY_LINK([#include <langinfo.h>],
+      [char* cs = nl_langinfo(CODESET);],
+      am_cv_langinfo_codeset=yes,
+      am_cv_langinfo_codeset=no)
+    ])
+  if test $am_cv_langinfo_codeset = yes; then
+    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
+      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+  fi
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_ADA_INCLUDE_DIRS version: 4 updated: 2002/12/01 00:12:15
 dnl -------------------
 dnl Construct the list of include-options for the C programs in the Ada95
@@ -59,18 +82,44 @@
 AC_SUBST(ACPPFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ADD_CFLAGS version: 5 updated: 2002/12/01 00:12:15
+dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30
 dnl -------------
 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
 dnl The second parameter if given makes this macro verbose.
+dnl
+dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
+dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
+dnl confused by the quotes (which require backslashes to keep them usable).
 AC_DEFUN([CF_ADD_CFLAGS],
 [
+cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
+cf_new_extra_cppflags=
+
 for cf_add_cflags in $1
 do
+case $cf_fix_cppflags in
+no)
 	case $cf_add_cflags in #(vi
 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+		case $cf_add_cflags in
+		-D*)
+			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
+
+			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+			&& test -z "${cf_tst_cflags}" \
+			&& cf_fix_cppflags=yes
+
+			if test $cf_fix_cppflags = yes ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			fi
+			;;
+		esac
 		case "$CPPFLAGS" in
 		*$cf_add_cflags) #(vi
 			;;
@@ -83,6 +132,17 @@
 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
 		;;
 	esac
+	;;
+yes)
+	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
+
+	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+	&& test -z "${cf_tst_cflags}" \
+	&& cf_fix_cppflags=no
+	;;
+esac
 done
 
 if test -n "$cf_new_cflags" ; then
@@ -95,6 +155,13 @@
 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
 fi
 
+if test -n "$cf_new_extra_cppflags" ; then
+	ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
+	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+AC_SUBST(EXTRA_CPPFLAGS)
+
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
@@ -282,6 +349,77 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_BUILD_CC version: 4 updated: 2004/11/27 16:03:59
+dnl -----------
+dnl If we're cross-compiling, allow the user to override the tools and their
+dnl options.  The configure script is oriented toward identifying the host
+dnl compiler, etc., but we need a build compiler to generate parts of the
+dnl source.
+dnl
+dnl $1 = default for $CPPFLAGS
+dnl $2 = default for $LIBS
+AC_DEFUN([CF_BUILD_CC],[
+AC_REQUIRE([CF_PROG_EXT])
+if test "$cross_compiling" = yes ; then
+	# defaults that we might want to override
+	: ${BUILD_CC:='$(CC)'}
+	: ${BUILD_CPP:='$(CC) -E'}
+	: ${BUILD_CFLAGS:=''}
+	: ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
+	: ${BUILD_LDFLAGS:=''}
+	: ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
+	: ${BUILD_EXEEXT:='$x'}
+	: ${BUILD_OBJEXT:='o'}
+	AC_ARG_WITH(build-cc,
+		[  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
+		[BUILD_CC="$withval"],
+		[AC_CHECK_PROGS(BUILD_CC, $CC gcc cc)])
+	AC_ARG_WITH(build-cpp,
+		[  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
+		[BUILD_CPP="$withval"],
+		[BUILD_CPP='$(CC) -E'])
+	AC_ARG_WITH(build-cflags,
+		[  --with-build-cflags=XXX the build C compiler-flags],
+		[BUILD_CFLAGS="$withval"])
+	AC_ARG_WITH(build-cppflags,
+		[  --with-build-cppflags=XXX the build C preprocessor-flags],
+		[BUILD_CPPFLAGS="$withval"])
+	AC_ARG_WITH(build-ldflags,
+		[  --with-build-ldflags=XXX the build linker-flags],
+		[BUILD_LDFLAGS="$withval"])
+	AC_ARG_WITH(build-libs,
+		[  --with-build-libs=XXX   the build libraries],
+		[BUILD_LIBS="$withval"])
+	# this assumes we're on Unix.
+	BUILD_EXEEXT=
+	BUILD_OBJEXT=o
+
+	if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '$(CC)' ) ; then
+		AC_MSG_ERROR([Cross-build requires two compilers.
+Use --with-build-cc to specify the native compiler.])
+	fi
+
+else
+	: ${BUILD_CC:='$(CC)'}
+	: ${BUILD_CPP:='$(CPP)'}
+	: ${BUILD_CFLAGS:='$(CFLAGS)'}
+	: ${BUILD_CPPFLAGS:='$(CPPFLAGS)'}
+	: ${BUILD_LDFLAGS:='$(LDFLAGS)'}
+	: ${BUILD_LIBS:='$(LIBS)'}
+	: ${BUILD_EXEEXT:='$x'}
+	: ${BUILD_OBJEXT:='o'}
+fi
+
+AC_SUBST(BUILD_CC)
+AC_SUBST(BUILD_CPP)
+AC_SUBST(BUILD_CFLAGS)
+AC_SUBST(BUILD_CPPFLAGS)
+AC_SUBST(BUILD_LDFLAGS)
+AC_SUBST(BUILD_LIBS)
+AC_SUBST(BUILD_EXEEXT)
+AC_SUBST(BUILD_OBJEXT)
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_CFG_DEFAULTS version: 6 updated: 2003/07/12 15:15:19
 dnl ---------------
 dnl Determine the default configuration into which we'll install ncurses.  This
@@ -359,7 +497,7 @@
 test "$cf_cv_cgetent" = yes && AC_DEFINE(HAVE_BSD_CGETENT)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_CACHE version: 9 updated: 2004/01/30 15:59:13
+dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
 dnl --------------
 dnl Check if we're accidentally using a cache from a different machine.
 dnl Derive the system name, as a check for reusing the autoconf cache.
@@ -373,7 +511,7 @@
 dnl autoconf 2.5x broke compatibility with autoconf 2.13
 AC_DEFUN([CF_CHECK_CACHE],
 [
-if test -f $srcdir/config.guess ; then
+if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
 	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
 	system_name="$host_os"
 else
@@ -627,6 +765,41 @@
 CXXFLAGS="$cf_save_CXXFLAGS"
 ])
 dnl ---------------------------------------------------------------------------
+dnl CF_FUNC_DLSYM version: 1 updated: 2004/06/16 20:52:45
+dnl -------------
+dnl Test for dlsym() and related functions, as well as libdl.
+dnl
+dnl Sets
+dnl	$cf_have_dlsym
+dnl	$cf_have_libdl
+AC_DEFUN([CF_FUNC_DLSYM],[
+cf_have_dlsym=no
+AC_CHECK_FUNC(dlsym,cf_have_dlsym=yes,[
+
+cf_have_libdl=no
+AC_CHECK_LIB(dl,dlsym,[
+	cf_have_dlsym=yes
+	cf_have_libdl=yes])])
+
+if test "$cf_have_dlsym" = yes ; then
+	test "$cf_have_libdl" = yes && LIBS="-ldl $LIBS"
+
+	AC_MSG_CHECKING(whether able to link to dl*() functions)
+	AC_TRY_LINK([#include <dlfcn.h>],[
+		void *obj;
+		if ((obj = dlopen("filename", 0)) != 0) {
+			if (dlsym(obj, "symbolname") == 0) {
+			dlclose(obj);
+			}
+		}],[
+		AC_DEFINE(HAVE_LIBDL)],[
+		AC_MSG_ERROR(Cannot link test program for libdl)])
+	AC_MSG_RESULT(ok)
+else
+	AC_MSG_ERROR(Cannot find dlsym function)
+fi
+])
+dnl ---------------------------------------------------------------------------
 dnl CF_FUNC_MEMMOVE version: 5 updated: 2000/08/12 23:18:52
 dnl ---------------
 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
@@ -850,7 +1023,7 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GCC_WARNINGS version: 15 updated: 2003/07/05 18:42:30
+dnl CF_GCC_WARNINGS version: 18 updated: 2004/12/03 20:51:07
 dnl ---------------
 dnl Check if the compiler supports useful warning options.  There's a few that
 dnl we don't use, simply because they're too noisy:
@@ -862,10 +1035,36 @@
 dnl		is enabled for ncurses using "--enable-const".
 dnl	-pedantic
 dnl
+dnl Parameter:
+dnl	$1 is an optional list of gcc warning flags that a particular
+dnl		application might want to use, e.g., "no-unused" for
+dnl		-Wno-unused
+dnl Special:
+dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
+dnl
 AC_DEFUN([CF_GCC_WARNINGS],
 [
+AC_REQUIRE([CF_INTEL_COMPILER])
 AC_REQUIRE([CF_GCC_VERSION])
-if test "$GCC" = yes
+if test "$INTEL_COMPILER" = yes
+then
+# The "-wdXXX" options suppress warnings:
+# remark #1419: external declaration in primary source file
+# remark #193: zero used for undefined preprocessing identifier
+# remark #593: variable "curs_sb_left_arrow" was set but never used
+# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
+# remark #869: parameter "tw" was never referenced
+# remark #981: operands are evaluated in unspecified order
+# warning #269: invalid format string conversion
+	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall \
+ -wd1419 \
+ -wd193 \
+ -wd279 \
+ -wd593 \
+ -wd810 \
+ -wd869 \
+ -wd981"
+elif test "$GCC" = yes
 then
 	cat > conftest.$ac_ext <<EOF
 #line __oline__ "configure"
@@ -887,7 +1086,7 @@
 		Wpointer-arith \
 		Wshadow \
 		Wstrict-prototypes \
-		Wundef $cf_warn_CONST
+		Wundef $cf_warn_CONST $1
 	do
 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
 		if AC_TRY_EVAL(ac_compile); then
@@ -913,10 +1112,43 @@
 AC_SUBST(EXTRA_CFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GNAT_TRY_RUN version: 2 updated: 1998/07/19 00:25:18
+dnl CF_GNAT_TRY_LINK version: 1 updated: 2004/08/21 19:02:08
+dnl ----------------
+dnl Verify that a test program compiles/links with GNAT.
+dnl $cf_ada_make is set to the program that compiles/links
+dnl $ADAFLAGS may be set to the GNAT flags.
+dnl
+dnl $1 is the text of the spec
+dnl $2 is the text of the body
+dnl $3 is the shell command to execute if successful
+dnl $4 is the shell command to execute if not successful
+AC_DEFUN([CF_GNAT_TRY_LINK],
+[
+rm -f conftest*
+cat >>conftest.ads <<CF_EOF
+$1
+CF_EOF
+cat >>conftest.adb <<CF_EOF
+$2
+CF_EOF
+if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
+ifelse($3,,      :,[      $3])
+ifelse($4,,,[else
+   $4])
+fi
+rm -f conftest*
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_GNAT_TRY_RUN version: 3 updated: 2004/08/21 19:02:08
 dnl ---------------
 dnl Verify that a test program compiles and runs with GNAT
 dnl $cf_ada_make is set to the program that compiles/links
+dnl $ADAFLAGS may be set to the GNAT flags.
+dnl
+dnl $1 is the text of the spec
+dnl $2 is the text of the body
+dnl $3 is the shell command to execute if successful
+dnl $4 is the shell command to execute if not successful
 AC_DEFUN([CF_GNAT_TRY_RUN],
 [
 rm -f conftest*
@@ -926,7 +1158,7 @@
 cat >>conftest.adb <<CF_EOF
 $2
 CF_EOF
-if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then
+if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
 ifelse($3,,      :,[      $3])
 ifelse($4,,,[   else
@@ -967,7 +1199,7 @@
 esac
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_GNU_SOURCE version: 3 updated: 2000/10/29 23:30:53
+dnl CF_GNU_SOURCE version: 4 updated: 2004/12/03 20:43:00
 dnl -------------
 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
@@ -977,6 +1209,9 @@
 dnl Well, yes we could work around it...
 AC_DEFUN([CF_GNU_SOURCE],
 [
+AC_REQUIRE([CF_INTEL_COMPILER])
+
+if test "$INTEL_COMPILER" = no ; then
 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
 AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifndef _XOPEN_SOURCE
@@ -995,6 +1230,7 @@
 	])
 ])
 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+fi
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl CF_GPP_LIBRARY version: 8 updated: 2003/02/02 01:41:46
@@ -1054,6 +1290,93 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_GXX_WARNINGS version: 2 updated: 2005/04/02 13:49:56
+dnl ---------------
+dnl Check if the compiler supports useful warning options.
+dnl
+dnl Most of gcc's options apply to g++, except:
+dnl	-Wbad-function-cast
+dnl	-Wmissing-declarations
+dnl	-Wnested-externs
+dnl
+dnl Omit a few (for now):
+dnl	-Winline
+dnl
+dnl Parameter:
+dnl	$1 is an optional list of g++ warning flags that a particular
+dnl		application might want to use, e.g., "no-unused" for
+dnl		-Wno-unused
+dnl Special:
+dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
+dnl
+AC_DEFUN([CF_GXX_WARNINGS],
+[
+AC_REQUIRE([CF_INTEL_COMPILER])
+AC_REQUIRE([CF_GXX_VERSION])
+
+AC_LANG_SAVE
+AC_LANG_CPLUSPLUS
+
+if test "$INTEL_COMPILER" = yes
+then
+# The "-wdXXX" options suppress warnings:
+# remark #1419: external declaration in primary source file
+# remark #193: zero used for undefined preprocessing identifier
+# remark #593: variable "curs_sb_left_arrow" was set but never used
+# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
+# remark #869: parameter "tw" was never referenced
+# remark #981: operands are evaluated in unspecified order
+# warning #269: invalid format string conversion
+	EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -Wall \
+ -wd1419 \
+ -wd193 \
+ -wd279 \
+ -wd593 \
+ -wd810 \
+ -wd869 \
+ -wd981"
+elif test "$GXX" = yes
+then
+	cat > conftest.$ac_ext <<EOF
+#line __oline__ "configure"
+int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
+EOF
+	AC_CHECKING([for $CXX warning options])
+	cf_save_CXXFLAGS="$CXXFLAGS"
+	EXTRA_CXXFLAGS="-W -Wall"
+	cf_warn_CONST=""
+	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
+	for cf_opt in \
+		Wabi \
+		fabi-version=0 \
+		Woverloaded-virtual \
+		Wsign-promo \
+		Wsynth \
+		Wold-style-cast \
+		Weffc++ \
+		Wcast-align \
+		Wcast-qual \
+		Wmissing-prototypes \
+		Wpointer-arith \
+		Wshadow \
+		Wstrict-prototypes \
+		Wundef $cf_warn_CONST $1
+	do
+		CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
+		if AC_TRY_EVAL(ac_compile); then
+			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
+			EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
+		else
+			test -n "$verbose" && AC_MSG_RESULT(... no -$cf_opt)
+		fi
+	done
+	rm -f conftest*
+	CXXFLAGS="$cf_save_CXXFLAGS"
+fi
+AC_LANG_RESTORE
+AC_SUBST(EXTRA_CXXFLAGS)
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
 dnl ---------------
 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
@@ -1087,6 +1410,40 @@
 AC_SUBST(CPPFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_INTEL_COMPILER version: 1 updated: 2004/12/03 20:27:48
+dnl -----------------
+dnl Check if the given compiler is really the Intel compiler for Linux.
+dnl It tries to imitate gcc, but does not return an error when it finds a
+dnl mismatch between prototypes, e.g., as exercised by CF_MISSING_CHECK.
+dnl
+dnl This macro should be run "soon" after AC_PROG_CC, to ensure that it is
+dnl not mistaken for gcc.
+AC_DEFUN([CF_INTEL_COMPILER],[
+AC_REQUIRE([AC_PROG_CC])
+
+INTEL_COMPILER=no
+
+if test "$GCC" = yes ; then
+	case $host_os in
+	linux*|gnu*)
+		AC_MSG_CHECKING(if this is really Intel compiler)
+		cf_save_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS -no-gcc"
+		AC_TRY_COMPILE([],[
+#ifdef __INTEL_COMPILER
+#else
+make an error
+#endif
+],[INTEL_COMPILER=yes
+cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
+],[])
+		CFLAGS="$cf_save_CFLAGS"
+		AC_MSG_RESULT($INTEL_COMPILER)
+		;;
+	esac
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_ISASCII version: 3 updated: 2000/08/12 23:18:52
 dnl ----------
 dnl Check if we have either a function or macro for 'isascii()'.
@@ -1138,7 +1495,7 @@
 	AC_SUBST(LIB_PREFIX)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_LIB_RULES version: 30 updated: 2004/01/10 15:50:50
+dnl CF_LIB_RULES version: 35 updated: 2004/09/18 17:54:16
 dnl ------------
 dnl Append definitions and rules for the given models to the subdirectory
 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
@@ -1170,13 +1527,33 @@
 				case "$cf_cv_shlib_version" in #(vi
 				rel) #(vi
 					case "$cf_cv_system_name" in #(vi
-					darwin*) cf_suffix='.$(REL_VERSION)'"$cf_suffix" ;; #(vi
+					darwin*)
+					case .${LIB_SUFFIX} in
+					.w*)
+						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
+						cf_suffix=w'.$(REL_VERSION)'"$cf_suffix"
+						;;
+					*)
+						cf_suffix='.$(REL_VERSION)'"$cf_suffix"
+						;;
+					esac
+					;; #(vi
 					*) cf_suffix="$cf_suffix"'.$(REL_VERSION)' ;;
 					esac
 					;;
 				abi)
 					case "$cf_cv_system_name" in #(vi
-					darwin*) cf_suffix='.$(ABI_VERSION)'"$cf_suffix" ;; #(vi
+					darwin*)
+					case .${LIB_SUFFIX} in
+					.w*)
+						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
+						cf_suffix=w'.$(ABI_VERSION)'"$cf_suffix"
+						;;
+					*)
+						cf_suffix='.$(ABI_VERSION)'"$cf_suffix"
+						;;
+					esac
+					;; #(vi
 					*) cf_suffix="$cf_suffix"'.$(ABI_VERSION)' ;;
 					esac
 					;;
@@ -1199,7 +1576,7 @@
 			cf_subsets="$LIB_SUBSETS"
 			cf_termlib=`echo "$cf_subsets" |sed -e 's/ .*$//'`
 			if test "$cf_termlib" != "$cf_subsets" ; then
-				cf_item=`echo $LIBS_TO_MAKE |sed -e s%$LIB_NAME%$TINFO_NAME%g`
+				cf_item=`echo $LIBS_TO_MAKE |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
 				LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
 			fi
 		else
@@ -1226,6 +1603,22 @@
 			CF_LIB_SUFFIX($cf_item,cf_suffix)
 			CF_OBJ_SUBDIR($cf_item,cf_subdir)
 
+			# Test for case where we build libtinfo with a different name.
+			cf_libname=$cf_dir
+			if test $cf_dir = ncurses ; then
+				case $cf_subset in
+				*base*)
+					;;
+				termlib*)
+					cf_libname=$TINFO_LIB_SUFFIX
+					if test -n "${DFT_ARG_SUFFIX}" ; then
+						# undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
+						cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
+					fi
+				;;
+				esac
+			fi
+
 			# These dependencies really are for development, not
 			# builds, but they are useful in porting, too.
 			cf_depend="../include/ncurses_cfg.h"
@@ -1241,8 +1634,22 @@
 				cf_depend="$cf_depend $cf_reldir/curses.priv.h"
 			fi
 
+ 			cf_dir_suffix=
+ 			old_cf_suffix="$cf_suffix"
+ 			if test "$cf_cv_shlib_version_infix" = yes ; then
+			if test -n "$LIB_SUFFIX" ; then
+				case $LIB_SUFFIX in
+				w*)
+					cf_libname=`echo $cf_libname | sed 's/w$//'`
+					cf_suffix=`echo $cf_suffix | sed 's/^w//'`
+					cf_dir_suffix=w
+					;;
+				esac
+			fi
+ 			fi
+
 			$AWK -f $srcdir/mk-1st.awk \
-				name=$cf_dir \
+				name=${cf_libname}${cf_dir_suffix} \
 				traces=$LIB_TRACING \
 				MODEL=$CF_ITEM \
 				model=$cf_subdir \
@@ -1258,6 +1665,9 @@
 				depend="$cf_depend" \
 				host="$host" \
 				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
+
+			cf_suffix="$old_cf_suffix"
+
 			for cf_subdir2 in $cf_subdirs lib
 			do
 				test $cf_subdir = $cf_subdir2 && break
@@ -1271,6 +1681,8 @@
 				subset=$cf_subset \
 				srcdir=$srcdir \
 				echo=$WITH_ECHO \
+				crenames=$cf_cv_prog_CC_c_o \
+				cxxrenames=$cf_cv_prog_CXX_c_o \
 				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
 			cf_subdirs="$cf_subdirs $cf_subdir"
 			done
@@ -2346,6 +2758,14 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
+dnl ----------
+dnl Write a debug message to config.log, along with the line number in the
+dnl configure script.
+AC_DEFUN([CF_MSG_LOG],[
+echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
 dnl ----------------
 dnl Check if the given variable is a number.  If not, report an error.
@@ -2429,6 +2849,65 @@
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_POSIX_C_SOURCE version: 3 updated: 2005/02/04 06:56:22
+dnl -----------------
+dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
+dnl
+dnl	POSIX.1-1990				_POSIX_SOURCE
+dnl	POSIX.1-1990 and			_POSIX_SOURCE and
+dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
+dnl		Bindings Option
+dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
+dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
+dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
+dnl
+dnl Parameters:
+dnl	$1 is the nominal value for _POSIX_C_SOURCE
+AC_DEFUN([CF_POSIX_C_SOURCE],
+[
+cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
+AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
+	CF_MSG_LOG(if the symbol is already defined go no further)
+	AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif],
+	[cf_cv_posix_c_source=no],
+	[cf_want_posix_source=no
+	 case .$cf_POSIX_C_SOURCE in
+	 .[[12]]??*)
+		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+		;;
+	 .2)
+		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+		cf_want_posix_source=yes
+		;;
+	 .*)
+		cf_want_posix_source=yes
+		;;
+	 esac
+	 if test "$cf_want_posix_source" = yes ; then
+		AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifdef _POSIX_SOURCE
+make an error
+#endif],[],
+		cf_cv_posix_c_source="$cf_cv_posix_c_source -U_POSIX_SOURCE -D_POSIX_SOURCE")
+	 fi
+	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
+	 cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
+	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
+	 AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif],,
+	[cf_cv_posix_c_source=no])
+	CPPFLAGS="$cf_save"
+	])
+])
+test "$cf_cv_posix_c_source" != no && CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_PREDEFINE version: 1 updated: 2003/07/26 17:53:56
 dnl ------------
 dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
@@ -2462,6 +2941,45 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_PROG_CC_C_O version: 1 updated: 2004/02/14 15:00:43
+dnl --------------
+dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
+dnl the output file can be renamed, and allows for a shell variable that can
+dnl be used later.  The parameter is either CC or CXX.  The result is the
+dnl cache variable:
+dnl	$cf_cv_prog_CC_c_o
+dnl	$cf_cv_prog_CXX_c_o
+AC_DEFUN([CF_PROG_CC_C_O],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
+AC_CACHE_VAL(cf_cv_prog_$1_c_o,
+[
+cat > conftest.$ac_ext <<CF_EOF
+#include <stdio.h>
+int main()
+{
+	return 0;
+}
+CF_EOF
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='[$]$1 -c conftest.$ac_ext -o conftest2.$ac_objext >&AC_FD_CC'
+if AC_TRY_EVAL(ac_try) &&
+  test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
+then
+  eval cf_cv_prog_$1_c_o=yes
+else
+  eval cf_cv_prog_$1_c_o=no
+fi
+rm -f conftest*
+])dnl
+if test $cf_cv_prog_$1_c_o = yes; then
+  AC_MSG_RESULT([yes])
+else
+  AC_MSG_RESULT([no])
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
 dnl -----------
 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
@@ -2559,7 +3077,7 @@
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_SHARED_OPTS version: 30 updated: 2003/12/27 20:48:07
+dnl CF_SHARED_OPTS version: 31 updated: 2005/01/01 16:39:44
 dnl --------------
 dnl Attempt to determine the appropriate CC/LD options for creating a shared
 dnl library.
@@ -2661,8 +3179,13 @@
 		;;
 	irix*)
 		if test "$cf_cv_ld_rpath" = yes ; then
-			cf_ld_rpath_opt="-Wl,-rpath,"
-			EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
+			if test "$GCC" = yes; then
+				cf_ld_rpath_opt="-Wl,-rpath,"
+				EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
+			else
+				cf_ld_rpath_opt="-rpath "
+				EXTRA_LDFLAGS="-rpath \$(libdir) $EXTRA_LDFLAGS"
+			fi
 		fi
 		# tested with IRIX 5.2 and 'cc'.
 		if test "$GCC" != yes; then
@@ -2904,7 +3427,7 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_SRC_MODULES version: 15 updated: 2004/01/10 16:05:16
+dnl CF_SRC_MODULES version: 17 updated: 2005/01/22 15:26:37
 dnl --------------
 dnl For each parameter, test if the source-directory exists, and if it contains
 dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
@@ -2924,9 +3447,6 @@
 	TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
 fi
 
-# dependencies and linker-arguments for utility-programs
-test "$with_termlib" != yes && PROG_ARGS="$TEST_ARGS"
-
 cf_cv_src_modules=
 for cf_dir in $1
 do
@@ -2970,9 +3490,6 @@
 AC_SUBST(TEST_DEPS)
 AC_SUBST(TEST_ARGS)
 
-PROG_ARGS="-L${LIB_DIR} $PROG_ARGS"
-AC_SUBST(PROG_ARGS)
-
 SRC_SUBDIRS="man include"
 for cf_dir in $cf_cv_src_modules
 do
@@ -3356,33 +3873,37 @@
 ])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_DBMALLOC version: 2 updated: 2002/12/29 21:11:45
+dnl CF_WITH_DBMALLOC version: 4 updated: 2004/02/28 05:49:27
 dnl ----------------
-dnl Configure-option for dbmalloc
+dnl Configure-option for dbmalloc.  The optional parameter is used to override
+dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
 AC_DEFUN([CF_WITH_DBMALLOC],[
 AC_MSG_CHECKING(if you want to link with dbmalloc for testing)
 AC_ARG_WITH(dbmalloc,
-	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
+	[  --with-dbmalloc         use Conor Cahill's dbmalloc library],
 	[with_dbmalloc=$withval],
 	[with_dbmalloc=no])
 AC_MSG_RESULT($with_dbmalloc)
-if test $with_dbmalloc = yes ; then
-	AC_CHECK_LIB(dbmalloc,debug_malloc)
+if test "$with_dbmalloc" = yes ; then
+	AC_CHECK_HEADER(dbmalloc.h,
+		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))])
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_WITH_DMALLOC version: 2 updated: 2002/12/29 21:11:45
+dnl CF_WITH_DMALLOC version: 4 updated: 2004/02/28 05:49:27
 dnl ---------------
-dnl Configure-option for dmalloc
+dnl Configure-option for dmalloc.  The optional parameter is used to override
+dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
 AC_DEFUN([CF_WITH_DMALLOC],[
 AC_MSG_CHECKING(if you want to link with dmalloc for testing)
 AC_ARG_WITH(dmalloc,
-	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
+	[  --with-dmalloc          use Gray Watson's dmalloc library],
 	[with_dmalloc=$withval],
 	[with_dmalloc=no])
 AC_MSG_RESULT($with_dmalloc)
-if test $with_dmalloc = yes ; then
-	AC_CHECK_LIB(dmalloc,dmalloc_debug)
+if test "$with_dmalloc" = yes ; then
+	AC_CHECK_HEADER(dmalloc.h,
+		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))])
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
@@ -3631,22 +4152,41 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_XOPEN_SOURCE version: 11 updated: 2004/01/26 20:58:41
+dnl CF_XOPEN_SOURCE version: 18 updated: 2005/04/16 19:02:58
 dnl ---------------
 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
 dnl or adapt to the vendor's definitions to get equivalent functionality.
+dnl
+dnl Parameters:
+dnl	$1 is the nominal value for _XOPEN_SOURCE
+dnl	$2 is the nominal value for _POSIX_C_SOURCE
 AC_DEFUN([CF_XOPEN_SOURCE],[
+
+cf_XOPEN_SOURCE=ifelse($1,,500,$1)
+cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
+
 case $host_os in #(vi
+aix[[45]]*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
+	;;
+darwin*) #(vi                                                                  
+	# setting _XOPEN_SOURCE breaks things on Darwin                         
+	;;                                                                      
 freebsd*) #(vi
-	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600"
+	# 5.x headers associate
+	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
+	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
+	cf_POSIX_C_SOURCE=200112L
+	cf_XOPEN_SOURCE=600
+	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
 	;;
 hpux*) #(vi
 	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
 	;;
-irix6.*) #(vi
+irix[[56]].*) #(vi
 	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
 	;;
-linux*) #(vi
+linux*|gnu*) #(vi
 	CF_GNU_SOURCE
 	;;
 mirbsd*) #(vi
@@ -3675,37 +4215,18 @@
 #endif],
 	[cf_cv_xopen_source=no],
 	[cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
+	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
 	 AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifdef _XOPEN_SOURCE
 make an error
 #endif],
 	[cf_cv_xopen_source=no],
-	[cf_cv_xopen_source=yes])
-	CPPFLAGS="$cf_save"
-	])
-])
-test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
-
-	# FreeBSD 5.x headers demand this...
-	AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_xopen_source,[
-	AC_TRY_COMPILE([#include <sys/types.h>],[
-#ifndef _POSIX_C_SOURCE
-make an error
-#endif],
-	[cf_cv_xopen_source=no],
-	[cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
-	 AC_TRY_COMPILE([#include <sys/types.h>],[
-#ifdef _POSIX_C_SOURCE
-make an error
-#endif],
-	[cf_cv_xopen_source=no],
-	[cf_cv_xopen_source=yes])
+	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
 	CPPFLAGS="$cf_save"
 	])
 ])
-test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
+test "$cf_cv_xopen_source" != no && CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE -D_XOPEN_SOURCE=$cf_cv_xopen_source"
+	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
 	;;
 esac
 ])
diff -Naur ncurses-5.4.orig/c++/Makefile.in ncurses-5.4/c++/Makefile.in
--- ncurses-5.4.orig/c++/Makefile.in	2004-01-16 22:44:56.000000000 +0000
+++ ncurses-5.4/c++/Makefile.in	2005-05-13 04:09:54.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.72 2004/01/16 22:44:56 tom Exp $
+# $Id: Makefile.in,v 1.76 2005/04/02 18:47:38 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -67,8 +67,8 @@
 RANLIB		= @LIB_PREP@
 
 CXX		= @CXX@
-CPP		= @CPP@
-CXXFLAGS	= @CXXFLAGS@
+CPP		= @CXXCPP@
+CXXFLAGS	= @CXXFLAGS@ @EXTRA_CXXFLAGS@
 CXXLIBS		= @CXXLIBS@
 
 INCDIR		= ../include
@@ -108,7 +108,7 @@
 LINK_SHARED	= $(LINK_FLAGS)
 
 LDFLAGS		= @TEST_ARGS@ @LDFLAGS@ \
-	@LD_MODEL@ @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ $(CXXLIBS)
+	@LD_MODEL@ @LIBS@ @LOCAL_LDFLAGS@ $(CXXLIBS)
 
 LDFLAGS_LIBTOOL	= $(LDFLAGS) $(CFLAGS_LIBTOOL)
 LDFLAGS_NORMAL	= $(LDFLAGS) $(CFLAGS_NORMAL)
@@ -130,6 +130,9 @@
 
 depend :
 
+tags:
+	ctags *.[h] *.cc
+
 # Build a conventional library for installing, since a shared library would
 # pull in all of the ncurses libraries (panel, menu, form, ncurses) as direct
 # dependencies.
diff -Naur ncurses-5.4.orig/c++/cursesapp.cc ncurses-5.4/c++/cursesapp.cc
--- ncurses-5.4.orig/c++/cursesapp.cc	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursesapp.cc	2005-05-13 04:09:54.000000000 +0000
@@ -1,6 +1,6 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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,14 +34,15 @@
 #include "internal.h"
 #include "cursesapp.h"
 
-MODULE_ID("$Id: cursesapp.cc,v 1.10 2003/10/25 15:04:46 tom Exp $")
+MODULE_ID("$Id: cursesapp.cc,v 1.13 2005/04/03 12:25:23 tom Exp $")
 
 void
-NCursesApplication::init(bool bColors) {
+NCursesApplication::init(bool bColors)
+{
   if (bColors)
     NCursesWindow::useColors();
-  
-  if (Root_Window->colors() > 1) {    
+
+  if (Root_Window->colors() > 1) {
     b_Colors = TRUE;
     Root_Window->setcolor(1);
     Root_Window->setpalette(COLOR_YELLOW,COLOR_BLUE);
@@ -66,7 +67,8 @@
 NCursesWindow* NCursesApplication::titleWindow = 0;
 NCursesApplication::SLK_Link* NCursesApplication::slk_stack = 0;
 
-NCursesApplication::~NCursesApplication() {
+NCursesApplication::~NCursesApplication()
+{
   Soft_Label_Key_Set* S;
 
   delete titleWindow;
@@ -78,12 +80,14 @@
   ::endwin();
 }
 
-int NCursesApplication::rinit(NCursesWindow& w) {
+int NCursesApplication::rinit(NCursesWindow& w)
+{
   titleWindow = &w;
   return OK;
 }
 
-void NCursesApplication::push(Soft_Label_Key_Set& S) {
+void NCursesApplication::push(Soft_Label_Key_Set& S)
+{
   SLK_Link* L = new SLK_Link;
   assert(L != 0);
   L->prev = slk_stack;
@@ -93,7 +97,8 @@
     S.show();
 }
 
-bool NCursesApplication::pop() {
+bool NCursesApplication::pop()
+{
   if (slk_stack) {
     SLK_Link* L = slk_stack;
     slk_stack = slk_stack->prev;
@@ -104,22 +109,24 @@
   return (slk_stack ? FALSE : TRUE);
 }
 
-Soft_Label_Key_Set* NCursesApplication::top() const {
+Soft_Label_Key_Set* NCursesApplication::top() const
+{
   if (slk_stack)
     return slk_stack->SLKs;
   else
-    return (Soft_Label_Key_Set*)0;
+    return static_cast<Soft_Label_Key_Set*>(0);
 }
 
-int NCursesApplication::operator()(void) {
+int NCursesApplication::operator()(void)
+{
   bool bColors = b_Colors;
-  Soft_Label_Key_Set* S;
+  Soft_Label_Key_Set* S = 0;
 
   int ts = titlesize();
   if (ts>0)
     NCursesWindow::ripoffline(ts,rinit);
   Soft_Label_Key_Set::Label_Layout fmt = useSLKs();
-  if (fmt!=Soft_Label_Key_Set::None) {    
+  if (fmt!=Soft_Label_Key_Set::None) {
     S = new Soft_Label_Key_Set(fmt);
     assert(S != 0);
     init_labels(*S);
@@ -137,8 +144,10 @@
   return run();
 }
 
-NCursesApplication::NCursesApplication(bool bColors) {
-  b_Colors = bColors;
+NCursesApplication::NCursesApplication(bool bColors)
+  : b_Colors(bColors),
+    Root_Window(NULL)
+{
   if (theApp)
     THROW(new NCursesException("Application object already created."));
   else
diff -Naur ncurses-5.4.orig/c++/cursesapp.h ncurses-5.4/c++/cursesapp.h
--- ncurses-5.4.orig/c++/cursesapp.h	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursesapp.h	2005-05-13 04:09:54.000000000 +0000
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -31,7 +31,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursesapp.h,v 1.9 2003/10/25 15:04:46 tom Exp $
+// $Id: cursesapp.h,v 1.10 2005/04/03 12:22:50 tom Exp $
 
 #ifndef NCURSES_CURSESAPP_H_incl
 #define NCURSES_CURSESAPP_H_incl
@@ -86,11 +86,24 @@
   // be the exit value of your application.
   virtual int run() = 0;
 
-
   // The constructor is protected, so you may use it in your derived
   // class constructor. The argument tells whether or not you want colors.
   NCursesApplication(bool wantColors = FALSE);
 
+  NCursesApplication& operator=(const NCursesApplication& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+    }
+    return *this;
+  }
+
+  NCursesApplication(const NCursesApplication& rhs)
+    : b_Colors(rhs.b_Colors),
+      Root_Window(rhs.Root_Window)
+  {
+  }
+
 public:
   virtual ~NCursesApplication();
 
diff -Naur ncurses-5.4.orig/c++/cursesf.cc ncurses-5.4/c++/cursesf.cc
--- ncurses-5.4.orig/c++/cursesf.cc	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursesf.cc	2005-05-13 04:09:54.000000000 +0000
@@ -1,6 +1,6 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -35,9 +35,10 @@
 #include "cursesf.h"
 #include "cursesapp.h"
 
-MODULE_ID("$Id: cursesf.cc,v 1.16 2003/10/25 15:04:46 tom Exp $")
+MODULE_ID("$Id: cursesf.cc,v 1.20 2005/04/02 20:33:08 tom Exp $")
 
-NCursesFormField::~NCursesFormField () {
+NCursesFormField::~NCursesFormField ()
+{
   if (field)
     OnError(::free_field (field));
 }
@@ -46,7 +47,8 @@
  * objects.
  */
 FIELD**
-NCursesForm::mapFields(NCursesFormField* nfields[]) {
+NCursesForm::mapFields(NCursesFormField* nfields[])
+{
   int fieldCount = 0,lcv;
   FIELD** old_fields;
 
@@ -65,13 +67,14 @@
   my_fields = nfields;
 
   if (form && (old_fields = ::form_fields(form))) {
-    ::set_form_fields(form,(FIELD**)0);
+    ::set_form_fields(form, static_cast<FIELD**>(0));
     delete[] old_fields;
   }
   return fields;
 }
 
-void NCursesForm::setDefaultAttributes() {
+void NCursesForm::setDefaultAttributes()
+{
   NCursesApplication* S = NCursesApplication::getApplication();
 
   int n = count();
@@ -102,7 +105,8 @@
 void
 NCursesForm::InitForm(NCursesFormField* nfields[],
 		      bool with_frame,
-		      bool autoDelete_Fields) {
+		      bool autoDelete_Fields)
+{
   int mrows, mcols;
 
   keypad(TRUE);
@@ -111,7 +115,7 @@
   b_framed = with_frame;
   b_autoDelete = autoDelete_Fields;
 
-  form = (FORM*)0;
+  form = static_cast<FORM*>(0);
   form = ::new_form(mapFields(nfields));
   if (!form)
     OnError (E_SYSTEM_ERROR);
@@ -120,12 +124,12 @@
   hook->m_user   = NULL;
   hook->m_back   = this;
   hook->m_owner  = form;
-  ::set_form_userptr(form,(void*)hook);
+  ::set_form_userptr(form, reinterpret_cast<void*>(hook));
 
-  ::set_form_init  (form, NCursesForm::frm_init);
-  ::set_form_term  (form, NCursesForm::frm_term);
-  ::set_field_init (form, NCursesForm::fld_init);
-  ::set_field_term (form, NCursesForm::fld_term);
+  ::set_form_init  (form, _nc_xx_frm_init);
+  ::set_form_term  (form, _nc_xx_frm_term);
+  ::set_field_init (form, _nc_xx_fld_init);
+  ::set_field_term (form, _nc_xx_fld_term);
 
   scale(mrows, mcols);
   ::set_form_win(form, w);
@@ -138,25 +142,26 @@
     b_sub_owner = TRUE;
   }
   else {
-    sub = (NCursesWindow*)0;
+    sub = static_cast<NCursesWindow*>(0);
     b_sub_owner = FALSE;
   }
   options_on(O_NL_OVERLOAD);
   setDefaultAttributes();
 }
 
-NCursesForm::~NCursesForm() {
-  UserHook* hook = (UserHook*)::form_userptr(form);
+NCursesForm::~NCursesForm()
+{
+  UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(form));
   delete hook;
   if (b_sub_owner) {
     delete sub;
-    ::set_form_sub(form,(WINDOW *)0);
+    ::set_form_sub(form, static_cast<WINDOW *>(0));
   }
   if (form) {
     FIELD** fields = ::form_fields(form);
     int cnt = count();
 
-    OnError(::set_form_fields(form,(FIELD**)0));
+    OnError(::set_form_fields(form, static_cast<FIELD**>(0)));
 
     if (b_autoDelete) {
       if (cnt>0) {
@@ -173,7 +178,8 @@
 }
 
 void
-NCursesForm::setSubWindow(NCursesWindow& nsub) {
+NCursesForm::setSubWindow(NCursesWindow& nsub)
+{
   if (!isDescendant(nsub))
     OnError(E_SYSTEM_ERROR);
   else {
@@ -190,46 +196,55 @@
  * implementing a virtual method in a derived class
  */
 void
-NCursesForm::frm_init(FORM *f) {
-  getHook(f)->On_Form_Init();
+_nc_xx_frm_init(FORM *f)
+{
+  NCursesForm::getHook(f)->On_Form_Init();
 }
 
 void
-NCursesForm::frm_term(FORM *f) {
-  getHook(f)->On_Form_Termination();
+_nc_xx_frm_term(FORM *f)
+{
+  NCursesForm::getHook(f)->On_Form_Termination();
 }
 
 void
-NCursesForm::fld_init(FORM *f) {
-  NCursesForm* F = getHook(f);
+_nc_xx_fld_init(FORM *f)
+{
+  NCursesForm* F = NCursesForm::getHook(f);
   F->On_Field_Init (*(F->current_field ()));
 }
 
 void
-NCursesForm::fld_term(FORM *f) {
-  NCursesForm* F = getHook(f);
+_nc_xx_fld_term(FORM *f)
+{
+  NCursesForm* F = NCursesForm::getHook(f);
   F->On_Field_Termination (*(F->current_field ()));
 }
 
 void
-NCursesForm::On_Form_Init() {
+NCursesForm::On_Form_Init()
+{
 }
 
 void
-NCursesForm::On_Form_Termination() {
+NCursesForm::On_Form_Termination()
+{
 }
 
 void
-NCursesForm::On_Field_Init(NCursesFormField& field) {
+NCursesForm::On_Field_Init(NCursesFormField& field)
+{
 }
 
 void
-NCursesForm::On_Field_Termination(NCursesFormField& field) {
+NCursesForm::On_Field_Termination(NCursesFormField& field)
+{
 }
 
 // call the form driver and do basic error checking.
 int
-NCursesForm::driver (int c) {
+NCursesForm::driver (int c)
+{
   int res = ::form_driver (form, c);
   switch (res) {
   case E_OK:
@@ -243,22 +258,26 @@
   return (res);
 }
 
-void NCursesForm::On_Request_Denied(int c) const {
+void NCursesForm::On_Request_Denied(int c) const
+{
   ::beep();
 }
 
-void NCursesForm::On_Invalid_Field(int c) const {
+void NCursesForm::On_Invalid_Field(int c) const
+{
   ::beep();
 }
 
-void NCursesForm::On_Unknown_Command(int c) const {
+void NCursesForm::On_Unknown_Command(int c) const
+{
   ::beep();
 }
 
 static const int CMD_QUIT = MAX_COMMAND + 1;
 
 NCursesFormField*
-NCursesForm::operator()(void) {
+NCursesForm::operator()(void)
+{
   int drvCmnd;
   int err;
   int c;
@@ -296,7 +315,8 @@
 // The default implementation provides a hopefully straightforward
 // mapping for the most common keystrokes and form requests.
 int
-NCursesForm::virtualize(int c) {
+NCursesForm::virtualize(int c)
+{
   switch(c) {
 
   case KEY_HOME      : return(REQ_FIRST_FIELD);
@@ -351,76 +371,84 @@
 // User Defined Fieldtypes
 // -------------------------------------------------------------------------
 //
-bool UserDefinedFieldType::fcheck(FIELD *f, const void *u) {
-  NCursesFormField* F = (NCursesFormField*)u;
+bool _nc_xx_fld_fcheck(FIELD *f, const void *u)
+{
+  NCursesFormField* F = reinterpret_cast<NCursesFormField*>(const_cast<void *>(u));
   assert(F != 0);
-  UserDefinedFieldType* udf = (UserDefinedFieldType*)(F->fieldtype());
+  UserDefinedFieldType* udf = reinterpret_cast<UserDefinedFieldType*>(F->fieldtype());
   assert(udf != 0);
   return udf->field_check(*F);
 }
 
-bool UserDefinedFieldType::ccheck(int c, const void *u) {
-  NCursesFormField* F = (NCursesFormField*)u;
+bool _nc_xx_fld_ccheck(int c, const void *u)
+{
+  NCursesFormField* F = reinterpret_cast<NCursesFormField*>(const_cast<void *>(u));
   assert(F != 0);
   UserDefinedFieldType* udf =
-    (UserDefinedFieldType*)(F->fieldtype());
+    reinterpret_cast<UserDefinedFieldType*>(F->fieldtype());
   assert(udf != 0);
   return udf->char_check(c);
 }
 
-void* UserDefinedFieldType::makearg(va_list* va) {
+void* _nc_xx_fld_makearg(va_list* va)
+{
   return va_arg(*va,NCursesFormField*);
 }
 
 FIELDTYPE* UserDefinedFieldType::generic_fieldtype =
-  ::new_fieldtype(UserDefinedFieldType::fcheck,
-		  UserDefinedFieldType::ccheck);
+  ::new_fieldtype(_nc_xx_fld_fcheck,
+		  _nc_xx_fld_ccheck);
 
 FIELDTYPE* UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice =
-  ::new_fieldtype(UserDefinedFieldType::fcheck,
-		  UserDefinedFieldType::ccheck);
+  ::new_fieldtype(_nc_xx_fld_fcheck,
+		  _nc_xx_fld_ccheck);
 
-bool UserDefinedFieldType_With_Choice::next_choice(FIELD *f, const void *u) {
-  NCursesFormField* F = (NCursesFormField*)u;
+bool _nc_xx_next_choice(FIELD *f, const void *u)
+{
+  NCursesFormField* F = reinterpret_cast<NCursesFormField*>(const_cast<void *>(u));
   assert(F != 0);
   UserDefinedFieldType_With_Choice* udf =
-    (UserDefinedFieldType_With_Choice*)(F->fieldtype());
+    reinterpret_cast<UserDefinedFieldType_With_Choice*>(F->fieldtype());
   assert(udf != 0);
   return udf->next(*F);
 }
 
-bool UserDefinedFieldType_With_Choice::prev_choice(FIELD *f, const void *u) {
-  NCursesFormField* F = (NCursesFormField*)u;
+bool _nc_xx_prev_choice(FIELD *f, const void *u)
+{
+  NCursesFormField* F = reinterpret_cast<NCursesFormField*>(const_cast<void *>(u));
   assert(F != 0);
   UserDefinedFieldType_With_Choice* udf =
-    (UserDefinedFieldType_With_Choice*)(F->fieldtype());
+    reinterpret_cast<UserDefinedFieldType_With_Choice*>(F->fieldtype());
   assert(udf != 0);
   return udf->previous(*F);
 }
 
-class UDF_Init {
+class UDF_Init
+{
 private:
   int code;
   static UDF_Init* I;
+
 public:
-  UDF_Init() {
+  UDF_Init()
+    : code()
+  {
     code = ::set_fieldtype_arg(UserDefinedFieldType::generic_fieldtype,
-			       UserDefinedFieldType::makearg,
+			       _nc_xx_fld_makearg,
 			       NULL,
 			       NULL);
     if (code==E_OK)
       code = ::set_fieldtype_arg
 	(UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice,
-	 UserDefinedFieldType::makearg,
+	 _nc_xx_fld_makearg,
 	 NULL,
 	 NULL);
     if (code==E_OK)
       code = ::set_fieldtype_choice
 	(UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice,
-	 UserDefinedFieldType_With_Choice::next_choice,
-	 UserDefinedFieldType_With_Choice::prev_choice);
+	 _nc_xx_next_choice,
+	 _nc_xx_prev_choice);
   }
 };
 
 UDF_Init* UDF_Init::I = new UDF_Init();
-
diff -Naur ncurses-5.4.orig/c++/cursesf.h ncurses-5.4/c++/cursesf.h
--- ncurses-5.4.orig/c++/cursesf.h	2004-01-15 00:43:46.000000000 +0000
+++ ncurses-5.4/c++/cursesf.h	2005-05-13 04:09:58.000000000 +0000
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -31,7 +31,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursesf.h,v 1.19 2004/01/15 00:43:46 tom Exp $
+// $Id: cursesf.h,v 1.25 2005/04/30 20:26:05 Jeff.Chua Exp $
 
 #ifndef NCURSES_CURSESF_H_incl
 #define NCURSES_CURSESF_H_incl 1
@@ -51,7 +51,8 @@
 
 // Class to represent builtin field types as well as C++ written new
 // fieldtypes (see classes UserDefineFieldType...
-class NCURSES_IMPEXP NCursesFieldType {
+class NCURSES_IMPEXP NCursesFieldType
+{
   friend class NCursesFormField;
 
 protected:
@@ -71,8 +72,24 @@
   virtual void set(NCursesFormField& f) = 0;
 
 public:
-  NCursesFieldType() : fieldtype((FIELDTYPE*)0) {
+  NCursesFieldType()
+    : fieldtype(STATIC_CAST(FIELDTYPE*)(0))
+  {
+  }
+
+  NCursesFieldType& operator=(const NCursesFieldType& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+    }
+    return *this;
   }
+
+  NCursesFieldType(const NCursesFieldType& rhs)
+    : fieldtype(rhs.fieldtype)
+  {
+  }
+
 };
 
 //
@@ -80,11 +97,12 @@
 // The class representing a forms field, wrapping the lowlevel FIELD struct
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP NCursesFormField {
+class NCURSES_IMPEXP NCursesFormField
+{
   friend class NCursesForm;
 
 protected:
-  FIELD *field;              // lowlevel structure
+  FIELD *field;		     // lowlevel structure
   NCursesFieldType* ftype;   // Associated field type
 
   // Error handler
@@ -96,27 +114,45 @@
 public:
   // Create a 'Null' field. Can be used to delimit a field list
   NCursesFormField()
-    : field((FIELD*)0), ftype((NCursesFieldType*)0) {
+    : field(STATIC_CAST(FIELD*)(0)),
+      ftype(STATIC_CAST(NCursesFieldType*)(0))
+  {
   }
 
   // Create a new field
   NCursesFormField (int rows,
-		    int cols,
+		    int ncols,
 		    int first_row = 0,
 		    int first_col = 0,
 		    int offscreen_rows = 0,
 		    int additional_buffers = 0)
-    : ftype((NCursesFieldType*)0) {
-      field = ::new_field(rows,cols,first_row,first_col,
+    : field(),
+      ftype(STATIC_CAST(NCursesFieldType*)(0))
+  {
+      field = ::new_field(rows, ncols, first_row, first_col,
 			  offscreen_rows, additional_buffers);
       if (!field)
 	OnError(errno);
   }
 
+  NCursesFormField& operator=(const NCursesFormField& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+    }
+    return *this;
+  }
+
+  NCursesFormField(const NCursesFormField& rhs)
+    : field(rhs.field), ftype(rhs.ftype)
+  {
+  }
+
   virtual ~NCursesFormField ();
 
   // Duplicate the field at a new position
-  inline NCursesFormField* dup(int first_row, int first_col) {
+  inline NCursesFormField* dup(int first_row, int first_col)
+  {
     NCursesFormField* f = new NCursesFormField();
     if (!f)
       OnError(E_SYSTEM_ERROR);
@@ -149,10 +185,10 @@
   }
 
   // Retrieve info about the field
-  inline void info(int& rows, int& cols,
+  inline void info(int& rows, int& ncols,
 		   int& first_row, int& first_col,
 		   int& offscreen_rows, int& additional_buffers) const {
-    OnError(::field_info(field, &rows, &cols,
+    OnError(::field_info(field, &rows, &ncols,
 			 &first_row, &first_col,
 			 &offscreen_rows, &additional_buffers));
   }
@@ -195,8 +231,8 @@
     return ::field_just(field);
   }
   // Set the foreground attribute for the field
-  inline void set_foreground(chtype fore) {
-    OnError(::set_field_fore(field,fore));
+  inline void set_foreground(chtype foreground) {
+    OnError(::set_field_fore(field,foreground));
   }
 
   // Retrieve the fields foreground attribute
@@ -205,8 +241,8 @@
   }
 
   // Set the background attribute for the field
-  inline void set_background(chtype back) {
-    OnError(::set_field_back(field,back));
+  inline void set_background(chtype background) {
+    OnError(::set_field_back(field,background));
   }
 
   // Retrieve the fields background attribute
@@ -215,8 +251,8 @@
   }
 
   // Set the padding character for the field
-  inline void set_pad_character(int pad) {
-    OnError(::set_field_pad(field,pad));
+  inline void set_pad_character(int padding) {
+    OnError(::set_field_pad(field, padding));
   }
 
   // Retrieve the fields padding character
@@ -225,13 +261,13 @@
   }
 
   // Switch on the fields options
-  inline void options_on (Field_Options options) {
-    OnError (::field_opts_on (field, options));
+  inline void options_on (Field_Options opts) {
+    OnError (::field_opts_on (field, opts));
   }
 
   // Switch off the fields options
-  inline void options_off (Field_Options options) {
-    OnError (::field_opts_off (field, options));
+  inline void options_off (Field_Options opts) {
+    OnError (::field_opts_off (field, opts));
   }
 
   // Retrieve the fields options
@@ -240,8 +276,8 @@
   }
 
   // Set the fields options
-  inline void set_options (Field_Options options) {
-    OnError (::set_field_opts (field, options));
+  inline void set_options (Field_Options opts) {
+    OnError (::set_field_opts (field, opts));
   }
 
   // Mark the field as changed
@@ -283,19 +319,30 @@
 
 };
 
+  // This are the built-in hook functions in this C++ binding. In C++ we use
+  // virtual member functions (see below On_..._Init and On_..._Termination)
+  // to provide this functionality in an object oriented manner.
+extern "C" {
+  void _nc_xx_frm_init(FORM *);
+  void _nc_xx_frm_term(FORM *);
+  void _nc_xx_fld_init(FORM *);
+  void _nc_xx_fld_term(FORM *);
+}
+
 //
 // -------------------------------------------------------------------------
 // The class representing a form, wrapping the lowlevel FORM struct
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP NCursesForm : public NCursesPanel {
+class NCURSES_IMPEXP NCursesForm : public NCursesPanel
+{
 protected:
   FORM* form;  // the lowlevel structure
 
 private:
   NCursesWindow* sub;   // the subwindow object
   bool b_sub_owner;     // is this our own subwindow?
-  bool b_framed;        // has the form a border?
+  bool b_framed;	// has the form a border?
   bool b_autoDelete;    // Delete fields when deleting form?
 
   NCursesFormField** my_fields; // The array of fields for this form
@@ -303,25 +350,22 @@
   // This structure is used for the form's user data field to link the
   // FORM* to the C++ object and to provide extra space for a user pointer.
   typedef struct {
-    void*              m_user;      // the pointer for the user's data
+    void*	       m_user;	    // the pointer for the user's data
     const NCursesForm* m_back;      // backward pointer to C++ object
-    const FORM*        m_owner;
+    const FORM*	       m_owner;
   } UserHook;
 
   // Get the backward pointer to the C++ object from a FORM
   static inline NCursesForm* getHook(const FORM *f) {
-    UserHook* hook = (UserHook*)::form_userptr(f);
+    UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(f));
     assert(hook != 0 && hook->m_owner==f);
-    return (NCursesForm*)(hook->m_back);
+    return const_cast<NCursesForm*>(hook->m_back);
   }
 
-  // This are the built-in hook functions in this C++ binding. In C++ we use
-  // virtual member functions (see below On_..._Init and On_..._Termination)
-  // to provide this functionality in an object oriented manner.
-  static void frm_init(FORM *);
-  static void frm_term(FORM *);
-  static void fld_init(FORM *);
-  static void fld_term(FORM *);
+  friend void _nc_xx_frm_init(FORM *);
+  friend void _nc_xx_frm_term(FORM *);
+  friend void _nc_xx_fld_init(FORM *);
+  friend void _nc_xx_fld_term(FORM *);
 
   // Calculate FIELD* array for the menu
   FIELD** mapFields(NCursesFormField* nfields[]);
@@ -329,13 +373,13 @@
 protected:
   // internal routines
   inline void set_user(void *user) {
-    UserHook* uptr = (UserHook*)::form_userptr (form);
+    UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
     assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
     uptr->m_user = user;
   }
 
   inline void *get_user() {
-    UserHook* uptr = (UserHook*)::form_userptr (form);
+    UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
     assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
     return uptr->m_user;
   }
@@ -354,35 +398,75 @@
 
   // 'Internal' constructor, builds an object without association to a
   // field array.
-  NCursesForm( int  lines,
-	       int  cols,
+  NCursesForm( int  nlines,
+	       int  ncols,
 	       int  begin_y = 0,
 	       int  begin_x = 0)
-    : NCursesPanel(lines,cols,begin_y,begin_x),
-      form ((FORM*)0) {
+    : NCursesPanel(nlines, ncols, begin_y, begin_x),
+      form (STATIC_CAST(FORM*)(0)),
+      sub(),
+      b_sub_owner(),
+      b_framed(),
+      b_autoDelete(),
+      my_fields()
+  {
   }
 
 public:
   // Create form for the default panel.
   NCursesForm (NCursesFormField* Fields[],
-	       bool with_frame=FALSE,         // reserve space for a frame?
+	       bool with_frame=FALSE,	      // reserve space for a frame?
 	       bool autoDelete_Fields=FALSE)  // do automatic cleanup?
-    : NCursesPanel() {
+    : NCursesPanel(),
+      form(),
+      sub(),
+      b_sub_owner(),
+      b_framed(),
+      b_autoDelete(),
+      my_fields()
+  {
     InitForm(Fields, with_frame, autoDelete_Fields);
   }
 
   // Create a form in a panel with the given position and size.
   NCursesForm (NCursesFormField* Fields[],
-	       int  lines,
-	       int  cols,
+	       int  nlines,
+	       int  ncols,
 	       int  begin_y,
 	       int  begin_x,
-	       bool with_frame=FALSE,        // reserve space for a frame?
+	       bool with_frame=FALSE,	     // reserve space for a frame?
 	       bool autoDelete_Fields=FALSE) // do automatic cleanup?
-    : NCursesPanel(lines, cols, begin_y, begin_x) {
+    : NCursesPanel(nlines, ncols, begin_y, begin_x),
+      form(),
+      sub(),
+      b_sub_owner(),
+      b_framed(),
+      b_autoDelete(),
+      my_fields()
+  {
       InitForm(Fields, with_frame, autoDelete_Fields);
   }
 
+  NCursesForm& operator=(const NCursesForm& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+      NCursesPanel::operator=(rhs);
+    }
+    return *this;
+  }
+
+  NCursesForm(const NCursesForm& rhs)
+    : NCursesPanel(rhs),
+      form(rhs.form),
+      sub(rhs.sub),
+      b_sub_owner(rhs.b_sub_owner),
+      b_framed(rhs.b_framed),
+      b_autoDelete(rhs.b_autoDelete),
+      my_fields(rhs.my_fields)
+  {
+  }
+
   virtual ~NCursesForm();
 
   // Set the default attributes for the form
@@ -452,8 +536,8 @@
   virtual void On_Field_Termination(NCursesFormField& field);
 
   // Calculate required window size for the form.
-  void scale(int& rows, int& cols) const {
-    OnError(::scale_form(form,&rows,&cols));
+  void scale(int& rows, int& ncols) const {
+    OnError(::scale_form(form,&rows,&ncols));
   }
 
   // Retrieve number of fields in the form.
@@ -462,8 +546,8 @@
   }
 
   // Make the page the current page of the form.
-  void set_page(int page) {
-    OnError(::set_form_page(form,page));
+  void set_page(int pageNum) {
+    OnError(::set_form_page(form, pageNum));
   }
 
   // Retrieve current page number
@@ -472,13 +556,13 @@
   }
 
   // Switch on the forms options
-  inline void options_on (Form_Options options) {
-    OnError (::form_opts_on (form, options));
+  inline void options_on (Form_Options opts) {
+    OnError (::form_opts_on (form, opts));
   }
 
   // Switch off the forms options
-  inline void options_off (Form_Options options) {
-    OnError (::form_opts_off (form, options));
+  inline void options_off (Form_Options opts) {
+    OnError (::form_opts_off (form, opts));
   }
 
   // Retrieve the forms options
@@ -487,8 +571,8 @@
   }
 
   // Set the forms options
-  inline void set_options (Form_Options options) {
-    OnError (::set_form_opts (form, options));
+  inline void set_options (Form_Options opts) {
+    OnError (::set_form_opts (form, opts));
   }
 
   // Are there more data in the current field after the data shown
@@ -545,28 +629,28 @@
 {
 public:
   NCursesUserField (int rows,
-		    int cols,
+		    int ncols,
 		    int first_row = 0,
 		    int first_col = 0,
-		    const T* p_UserData = (T*)0,
+		    const T* p_UserData = STATIC_CAST(T*)(0),
 		    int offscreen_rows = 0,
 		    int additional_buffers = 0)
-    : NCursesFormField (rows, cols,
+    : NCursesFormField (rows, ncols,
 			first_row, first_col,
 			offscreen_rows, additional_buffers) {
       if (field)
-	OnError(::set_field_userptr(field,(void *)p_UserData));
+	OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData)));
   }
 
   virtual ~NCursesUserField() {};
 
   inline const T* UserData (void) const {
-    return (const T*)::field_userptr (field);
+    return reinterpret_cast<const T*>(::field_userptr (field));
   }
 
   inline virtual void setUserData(const T* p_UserData) {
     if (field)
-      OnError (::set_field_userptr (field, (void *)p_UserData));
+      OnError (::set_field_userptr (field, STATIC_CAST(void *)(p_UserData)));
   }
 };
 //
@@ -579,50 +663,50 @@
 protected:
   // 'Internal' constructor, builds an object without association to a
   // field array.
-  NCursesUserForm( int  lines,
-		   int  cols,
+  NCursesUserForm( int  nlines,
+		   int  ncols,
 		   int  begin_y = 0,
 		   int  begin_x = 0,
-		   const T* p_UserData = (T*)0)
-    : NCursesForm(lines,cols,begin_y,begin_x) {
+		   const T* p_UserData = STATIC_CAST(T*)(0))
+    : NCursesForm(nlines,ncols,begin_y,begin_x) {
       if (form)
-	set_user ((void *)p_UserData);
+	set_user (const_cast<void *>(p_UserData));
   }
 
 public:
   NCursesUserForm (NCursesFormField Fields[],
-		   const T* p_UserData = (T*)0,
+		   const T* p_UserData = STATIC_CAST(T*)(0),
 		   bool with_frame=FALSE,
 		   bool autoDelete_Fields=FALSE)
     : NCursesForm (Fields, with_frame, autoDelete_Fields) {
       if (form)
-	set_user ((void *)p_UserData);
+	set_user (const_cast<void *>(p_UserData));
   };
 
   NCursesUserForm (NCursesFormField Fields[],
-		   int lines,
-		   int cols,
+		   int nlines,
+		   int ncols,
 		   int begin_y = 0,
 		   int begin_x = 0,
-		   const T* p_UserData = (T*)0,
+		   const T* p_UserData = STATIC_CAST(T*)(0),
 		   bool with_frame=FALSE,
 		   bool autoDelete_Fields=FALSE)
-    : NCursesForm (Fields, lines, cols, begin_y, begin_x,
+    : NCursesForm (Fields, nlines, ncols, begin_y, begin_x,
 		   with_frame, autoDelete_Fields) {
       if (form)
-	set_user ((void *)p_UserData);
+	set_user (const_cast<void *>(p_UserData));
   };
 
   virtual ~NCursesUserForm() {
   };
 
   inline T* UserData (void) const {
-    return (T*)get_user ();
+    return reinterpret_cast<T*>(get_user ());
   };
 
   inline virtual void setUserData (const T* p_UserData) {
     if (form)
-      set_user ((void *)p_UserData);
+      set_user (const_cast<void *>(p_UserData));
   }
 
 };
@@ -631,7 +715,8 @@
 // Builtin Fieldtypes
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP Alpha_Field : public NCursesFieldType {
+class NCURSES_IMPEXP Alpha_Field : public NCursesFieldType
+{
 private:
   int min_field_width;
 
@@ -646,7 +731,8 @@
   }
 };
 
-class NCURSES_IMPEXP Alphanumeric_Field : public NCursesFieldType {
+class NCURSES_IMPEXP Alphanumeric_Field : public NCursesFieldType
+{
 private:
   int min_field_width;
 
@@ -661,7 +747,8 @@
   }
 };
 
-class NCURSES_IMPEXP Integer_Field : public NCursesFieldType {
+class NCURSES_IMPEXP Integer_Field : public NCursesFieldType
+{
 private:
   int precision;
   long lower_limit, upper_limit;
@@ -678,7 +765,8 @@
   }
 };
 
-class NCURSES_IMPEXP Numeric_Field : public NCursesFieldType {
+class NCURSES_IMPEXP Numeric_Field : public NCursesFieldType
+{
 private:
   int precision;
   double lower_limit, upper_limit;
@@ -695,7 +783,8 @@
   }
 };
 
-class NCURSES_IMPEXP Regular_Expression_Field : public NCursesFieldType {
+class NCURSES_IMPEXP Regular_Expression_Field : public NCursesFieldType
+{
 private:
   char* regex;
 
@@ -703,11 +792,35 @@
     OnError(::set_field_type(f.get_field(),fieldtype,regex));
   }
 
+  void copy_regex(const char *source)
+  {
+    regex = new char[1 + ::strlen(source)];
+    (::strcpy)(regex, source);
+  }
+
 public:
   Regular_Expression_Field(const char *expr)
-    : NCursesFieldType(TYPE_REGEXP) {
-      regex = new char[1 + ::strlen(expr)];
-      (::strcpy)(regex,expr);
+    : NCursesFieldType(TYPE_REGEXP),
+      regex(NULL)
+  {
+    copy_regex(expr);
+  }
+
+  Regular_Expression_Field& operator=(const Regular_Expression_Field& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+      copy_regex(rhs.regex);
+      NCursesFieldType::operator=(rhs);
+    }
+    return *this;
+  }
+
+  Regular_Expression_Field(const Regular_Expression_Field& rhs)
+    : NCursesFieldType(rhs),
+      regex(NULL)
+  {
+    copy_regex(rhs.regex);
   }
 
   ~Regular_Expression_Field() {
@@ -715,7 +828,8 @@
   }
 };
 
-class NCURSES_IMPEXP Enumeration_Field : public NCursesFieldType {
+class NCURSES_IMPEXP Enumeration_Field : public NCursesFieldType
+{
 private:
   const char** list;
   int case_sensitive;
@@ -731,12 +845,30 @@
 		    bool non_unique=FALSE)
     : NCursesFieldType(TYPE_ENUM),
       list(enums),
-      case_sensitive(case_sens?-1:0),
-      non_unique_matches(non_unique?-1:0) {
+      case_sensitive(case_sens ? -1 : 0),
+      non_unique_matches(non_unique ? -1 : 0) {
+  }
+
+  Enumeration_Field& operator=(const Enumeration_Field& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+      NCursesFieldType::operator=(rhs);
+    }
+    return *this;
+  }
+
+  Enumeration_Field(const Enumeration_Field& rhs)
+    : NCursesFieldType(rhs),
+      list(rhs.list),
+      case_sensitive(rhs.case_sensitive),
+      non_unique_matches(rhs.non_unique_matches)
+  {
   }
 };
 
-class NCURSES_IMPEXP IPV4_Address_Field : public NCursesFieldType {
+class NCURSES_IMPEXP IPV4_Address_Field : public NCursesFieldType
+{
 private:
   void set(NCursesFormField& f) {
     OnError(::set_field_type(f.get_field(),fieldtype));
@@ -746,12 +878,20 @@
   IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) {
   }
 };
+
+extern "C" {
+  bool _nc_xx_fld_fcheck(FIELD *, const void*);
+  bool _nc_xx_fld_ccheck(int c, const void *);
+  void* _nc_xx_fld_makearg(va_list*);
+}
+
 //
 // -------------------------------------------------------------------------
 // Abstract base class for User-Defined Fieldtypes
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP UserDefinedFieldType : public NCursesFieldType {
+class NCURSES_IMPEXP UserDefinedFieldType : public NCursesFieldType
+{
   friend class UDF_Init; // Internal helper to set up statics
 private:
   // For all C++ defined fieldtypes we need only one generic lowlevel
@@ -761,9 +901,9 @@
 protected:
   // This are the functions required by the low level libforms functions
   // to construct a fieldtype.
-  static bool fcheck(FIELD *, const void*);
-  static bool ccheck(int c, const void *);
-  static void* makearg(va_list*);
+  friend bool _nc_xx_fld_fcheck(FIELD *, const void*);
+  friend bool _nc_xx_fld_ccheck(int c, const void *);
+  friend void* _nc_xx_fld_makearg(va_list*);
 
   void set(NCursesFormField& f) {
     OnError(::set_field_type(f.get_field(),fieldtype,&f));
@@ -782,12 +922,19 @@
   UserDefinedFieldType() : NCursesFieldType(generic_fieldtype) {
   }
 };
+
+extern "C" {
+  bool _nc_xx_next_choice(FIELD*, const void *);
+  bool _nc_xx_prev_choice(FIELD*, const void *);
+}
+
 //
 // -------------------------------------------------------------------------
 // Abstract base class for User-Defined Fieldtypes with Choice functions
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType {
+class NCURSES_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType
+{
   friend class UDF_Init; // Internal helper to set up statics
 private:
   // For all C++ defined fieldtypes with choice functions we need only one
@@ -796,8 +943,8 @@
 
   // This are the functions required by the low level libforms functions
   // to construct a fieldtype with choice functions.
-  static bool next_choice(FIELD*, const void *);
-  static bool prev_choice(FIELD*, const void *);
+  friend bool _nc_xx_next_choice(FIELD*, const void *);
+  friend bool _nc_xx_prev_choice(FIELD*, const void *);
 
 protected:
   // Redefine this function to do the retrieval of the next choice value.
diff -Naur ncurses-5.4.orig/c++/cursesm.cc ncurses-5.4/c++/cursesm.cc
--- ncurses-5.4.orig/c++/cursesm.cc	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursesm.cc	2005-05-13 04:09:54.000000000 +0000
@@ -1,6 +1,6 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -35,23 +35,27 @@
 #include "cursesm.h"
 #include "cursesapp.h"
 
-MODULE_ID("$Id: cursesm.cc,v 1.18 2003/10/25 15:04:46 tom Exp $")
+MODULE_ID("$Id: cursesm.cc,v 1.22 2005/04/02 20:39:05 tom Exp $")
 
-NCursesMenuItem::~NCursesMenuItem() {
+NCursesMenuItem::~NCursesMenuItem()
+{
   if (item)
     OnError(::free_item(item));
 }
 
 bool
-NCursesMenuItem::action() {
+NCursesMenuItem::action()
+{
   return FALSE;
-};
+}
 
-NCursesMenuCallbackItem::~NCursesMenuCallbackItem() {
+NCursesMenuCallbackItem::~NCursesMenuCallbackItem()
+{
 }
 
 bool
-NCursesMenuCallbackItem::action() {
+NCursesMenuCallbackItem::action()
+{
   if (p_fct)
     return p_fct (*this);
   else
@@ -64,24 +68,28 @@
  * implementing a virtual method in a derived class
  */
 void
-NCursesMenu::mnu_init(MENU *m) {
-  getHook(m)->On_Menu_Init();
+_nc_xx_mnu_init(MENU *m)
+{
+  NCursesMenu::getHook(m)->On_Menu_Init();
 }
 
 void
-NCursesMenu::mnu_term(MENU *m) {
-  getHook(m)->On_Menu_Termination();
+_nc_xx_mnu_term(MENU *m)
+{
+  NCursesMenu::getHook(m)->On_Menu_Termination();
 }
 
 void
-NCursesMenu::itm_init(MENU *m) {
-  NCursesMenu* M = getHook(m);
+_nc_xx_itm_init(MENU *m)
+{
+  NCursesMenu* M = NCursesMenu::getHook(m);
   M->On_Item_Init (*(M->current_item ()));
 }
 
 void
-NCursesMenu::itm_term(MENU *m) {
-  NCursesMenu* M = getHook(m);
+_nc_xx_itm_term(MENU *m)
+{
+  NCursesMenu* M = NCursesMenu::getHook(m);
   M->On_Item_Termination (*(M->current_item ()));
 }
 
@@ -89,30 +97,32 @@
  * objects.
  */
 ITEM**
-NCursesMenu::mapItems(NCursesMenuItem* nitems[]) {
+NCursesMenu::mapItems(NCursesMenuItem* nitems[])
+{
   int itemCount = 0,lcv;
 
   for (lcv=0; nitems[lcv]->item; ++lcv)
     ++itemCount;
 
-  ITEM** items = new ITEM*[itemCount + 1];
+  ITEM** itemArray = new ITEM*[itemCount + 1];
 
   for (lcv=0;nitems[lcv]->item;++lcv) {
-    items[lcv] = nitems[lcv]->item;
+    itemArray[lcv] = nitems[lcv]->item;
   }
-  items[lcv] = NULL;
+  itemArray[lcv] = NULL;
 
   my_items = nitems;
 
   if (menu)
     delete[] ::menu_items(menu);
-  return items;
+  return itemArray;
 }
 
 void
 NCursesMenu::InitMenu(NCursesMenuItem* nitems[],
 		      bool with_frame,
-		      bool autoDelete_Items) {
+		      bool autoDelete_Items)
+{
   int mrows, mcols;
 
   keypad(TRUE);
@@ -121,7 +131,7 @@
   b_framed = with_frame;
   b_autoDelete = autoDelete_Items;
 
-  menu = (MENU*)0;
+  menu = static_cast<MENU*>(0);
   menu = ::new_menu(mapItems(nitems));
   if (!menu)
     OnError (E_SYSTEM_ERROR);
@@ -130,12 +140,12 @@
   hook->m_user   = NULL;
   hook->m_back   = this;
   hook->m_owner  = menu;
-  ::set_menu_userptr(menu,(void*)hook);
+  ::set_menu_userptr(menu, static_cast<void*>(hook));
 
-  ::set_menu_init (menu, NCursesMenu::mnu_init);
-  ::set_menu_term (menu, NCursesMenu::mnu_term);
-  ::set_item_init (menu, NCursesMenu::itm_init);
-  ::set_item_term (menu, NCursesMenu::itm_term);
+  ::set_menu_init (menu, _nc_xx_mnu_init);
+  ::set_menu_term (menu, _nc_xx_mnu_term);
+  ::set_item_init (menu, _nc_xx_itm_init);
+  ::set_item_term (menu, _nc_xx_itm_term);
 
   scale(mrows, mcols);
   ::set_menu_win(menu, w);
@@ -148,14 +158,15 @@
     b_sub_owner = TRUE;
   }
   else {
-    sub = (NCursesWindow*)0;
+    sub = static_cast<NCursesWindow*>(0);
     b_sub_owner = FALSE;
   }
   setDefaultAttributes();
 }
 
 void
-NCursesMenu::setDefaultAttributes() {
+NCursesMenu::setDefaultAttributes()
+{
   NCursesApplication* S = NCursesApplication::getApplication();
   if (S) {
     ::set_menu_fore(menu, S->foregrounds());
@@ -164,18 +175,19 @@
   }
 }
 
-NCursesMenu::~NCursesMenu() {
-  UserHook* hook = (UserHook*)::menu_userptr(menu);
+NCursesMenu::~NCursesMenu()
+{
+  UserHook* hook = reinterpret_cast<UserHook*>(::menu_userptr(menu));
   delete hook;
   if (b_sub_owner) {
     delete sub;
-    ::set_menu_sub(menu,(WINDOW *)0);
+    ::set_menu_sub(menu, static_cast<WINDOW *>(0));
   }
   if (menu) {
     ITEM** itms = ::menu_items(menu);
     int cnt = count();
 
-    OnError(::set_menu_items(menu,(ITEM**)0));
+    OnError(::set_menu_items(menu, static_cast<ITEM**>(0)));
 
     if (b_autoDelete) {
       if (cnt>0) {
@@ -192,7 +204,8 @@
 }
 
 void
-NCursesMenu::setSubWindow(NCursesWindow& nsub) {
+NCursesMenu::setSubWindow(NCursesWindow& nsub)
+{
   if (!isDescendant(nsub))
     OnError(E_SYSTEM_ERROR);
   else {
@@ -204,7 +217,8 @@
 }
 
 bool
-NCursesMenu::set_pattern (const char *pat) {
+NCursesMenu::set_pattern (const char *pat)
+{
   int res = ::set_menu_pattern (menu, pat);
   switch(res) {
   case E_OK:
@@ -219,7 +233,8 @@
 
 // call the menu driver and do basic error checking.
 int
-NCursesMenu::driver (int c) {
+NCursesMenu::driver (int c)
+{
   int res = ::menu_driver (menu, c);
   switch (res) {
   case E_OK:
@@ -244,7 +259,8 @@
 // mapping for the most common keystrokes and menu requests.
 // -------------------------------------------------------------------------
 int
-NCursesMenu::virtualize(int c) {
+NCursesMenu::virtualize(int c)
+{
   switch(c) {
   case CTRL('X')     : return(CMD_QUIT);              // eXit
 
@@ -281,7 +297,8 @@
 }
 
 NCursesMenuItem*
-NCursesMenu::operator()(void) {
+NCursesMenu::operator()(void)
+{
   int drvCmnd;
   int err;
   int c;
@@ -290,9 +307,9 @@
   post();
   show();
   refresh();
-  
+
   while (!b_action && ((drvCmnd = virtualize((c=getKey()))) != CMD_QUIT)) {
-    
+
     switch((err=driver(drvCmnd))) {
     case E_REQUEST_DENIED:
       On_Request_Denied(c);
@@ -346,37 +363,45 @@
 }
 
 void
-NCursesMenu::On_Menu_Init() {
+NCursesMenu::On_Menu_Init()
+{
 }
 
 void
-NCursesMenu::On_Menu_Termination() {
+NCursesMenu::On_Menu_Termination()
+{
 }
 
 void
-NCursesMenu::On_Item_Init(NCursesMenuItem& item) {
+NCursesMenu::On_Item_Init(NCursesMenuItem& item)
+{
 }
 
 void
-NCursesMenu::On_Item_Termination(NCursesMenuItem& item) {
+NCursesMenu::On_Item_Termination(NCursesMenuItem& item)
+{
 }
 
 void
-NCursesMenu::On_Request_Denied(int c) const {
+NCursesMenu::On_Request_Denied(int c) const
+{
   ::beep();
 }
 
 void
-NCursesMenu::On_Not_Selectable(int c) const {
+NCursesMenu::On_Not_Selectable(int c) const
+{
   ::beep();
 }
 
 void
-NCursesMenu::On_No_Match(int c) const {
+NCursesMenu::On_No_Match(int c) const
+{
   ::beep();
 }
 
 void
-NCursesMenu::On_Unknown_Command(int c) const {
+NCursesMenu::On_Unknown_Command(int c) const
+{
   ::beep();
 }
diff -Naur ncurses-5.4.orig/c++/cursesm.h ncurses-5.4/c++/cursesm.h
--- ncurses-5.4.orig/c++/cursesm.h	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursesm.h	2005-05-13 04:09:58.000000000 +0000
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -31,7 +31,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursesm.h,v 1.17 2003/10/25 15:04:46 tom Exp $
+// $Id: cursesm.h,v 1.23 2005/04/30 20:26:05 Jeff.Chua Exp $
 
 #ifndef NCURSES_CURSESM_H_incl
 #define NCURSES_CURSESM_H_incl 1
@@ -46,9 +46,10 @@
 // This wraps the ITEM type of <menu.h>
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP NCursesMenuItem {
+class NCURSES_IMPEXP NCursesMenuItem
+{
   friend class NCursesMenu;
-  
+
 protected:
   ITEM *item;
 
@@ -59,15 +60,30 @@
 
 public:
   NCursesMenuItem (const char* p_name     = NULL,
-		   const char* p_descript = NULL ) { 
-    item = p_name ? ::new_item (p_name, p_descript) : (ITEM*)0; 
+		   const char* p_descript = NULL)
+    : item()
+  {
+    item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0);
     if (p_name && !item)
       OnError (E_SYSTEM_ERROR);
   }
   // Create an item. If you pass both parameters as NULL, a delimiting
   // item is constructed which can be used to terminate a list of
   // NCursesMenu objects.
-  
+
+  NCursesMenuItem& operator=(const NCursesMenuItem& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+    }
+    return *this;
+  }
+
+  NCursesMenuItem(const NCursesMenuItem& rhs)
+    : item()
+  {
+  }
+
   virtual ~NCursesMenuItem ();
   // Release the items memory
 
@@ -80,19 +96,19 @@
     return ::item_description (item);
   }
   // Description of the item
-  
+
   inline int (index) (void) const {
     return ::item_index (item);
   }
   // Index of the item in an item array (or -1)
 
-  inline void options_on (Item_Options options) {
-    OnError (::item_opts_on (item, options));
+  inline void options_on (Item_Options opts) {
+    OnError (::item_opts_on (item, opts));
   }
   // Switch on the items options
 
-  inline void options_off (Item_Options options) {
-    OnError (::item_opts_off (item, options));
+  inline void options_off (Item_Options opts) {
+    OnError (::item_opts_off (item, opts));
   }
   // Switch off the item's option
 
@@ -101,8 +117,8 @@
   }
   // Retrieve the items options
 
-  inline void set_options (Item_Options options) {
-    OnError (::set_item_opts (item, options));
+  inline void set_options (Item_Options opts) {
+    OnError (::set_item_opts (item, opts));
   }
   // Set the items options
 
@@ -115,7 +131,7 @@
     return ::item_value (item);
   }
   // Retrieve the items selection state
-  
+
   inline bool visible () const {
     return ::item_visible (item);
   }
@@ -135,7 +151,8 @@
 // If you don't like to create a child class for individual items to
 // overload action(), you may use this class and provide a callback
 // function pointer for items.
-class NCURSES_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem {
+class NCURSES_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem
+{
 private:
   ITEMCALLBACK* p_fct;
 
@@ -146,17 +163,43 @@
     : NCursesMenuItem (p_name, p_descript),
       p_fct (fct) {
   }
-  
+
+  NCursesMenuCallbackItem& operator=(const NCursesMenuCallbackItem& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+    }
+    return *this;
+  }
+
+  NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs)
+    : NCursesMenuItem(rhs),
+      p_fct()
+  {
+  }
+
   virtual ~NCursesMenuCallbackItem();
 
   bool action();
 };
+
+  // This are the built-in hook functions in this C++ binding. In C++ we use
+  // virtual member functions (see below On_..._Init and On_..._Termination)
+  // to provide this functionality in an object oriented manner.
+extern "C" {
+  void _nc_xx_mnu_init(MENU *);
+  void _nc_xx_mnu_term(MENU *);
+  void _nc_xx_itm_init(MENU *);
+  void _nc_xx_itm_term(MENU *);
+}
+
 //
 // -------------------------------------------------------------------------
 // This wraps the MENU type of <menu.h>
 // -------------------------------------------------------------------------
 //
-class NCURSES_IMPEXP NCursesMenu : public NCursesPanel {
+class NCURSES_IMPEXP NCursesMenu : public NCursesPanel
+{
 protected:
   MENU *menu;
 
@@ -178,36 +221,33 @@
 
   // Get the backward pointer to the C++ object from a MENU
   static inline NCursesMenu* getHook(const MENU *m) {
-    UserHook* hook = (UserHook*)::menu_userptr(m);
+    UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m));
     assert(hook != 0 && hook->m_owner==m);
-    return (NCursesMenu*)(hook->m_back);
+    return const_cast<NCursesMenu*>(hook->m_back);
   }
 
-  // This are the built-in hook functions in this C++ binding. In C++ we use
-  // virtual member functions (see below On_..._Init and On_..._Termination)
-  // to provide this functionality in an object oriented manner.
-  static void mnu_init(MENU *);
-  static void mnu_term(MENU *);
-  static void itm_init(MENU *);
-  static void itm_term(MENU *);
-  
+  friend void _nc_xx_mnu_init(MENU *);
+  friend void _nc_xx_mnu_term(MENU *);
+  friend void _nc_xx_itm_init(MENU *);
+  friend void _nc_xx_itm_term(MENU *);
+
   // Calculate ITEM* array for the menu
   ITEM** mapItems(NCursesMenuItem* nitems[]);
-  
+
 protected:
-  // internal routines 
+  // internal routines
   inline void set_user(void *user) {
-    UserHook* uptr = (UserHook*)::menu_userptr (menu);
+    UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
     assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
     uptr->m_user = user;
   }
 
   inline void *get_user() {
-    UserHook* uptr = (UserHook*)::menu_userptr (menu);
+    UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
     assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
     return uptr->m_user;
-  }  
-  
+  }
+
   void InitMenu (NCursesMenuItem* menu[],
 		 bool with_frame,
 		 bool autoDeleteItems);
@@ -216,18 +256,24 @@
     if (err != E_OK)
       THROW(new NCursesMenuException (this, err));
   }
-  
+
   // this wraps the menu_driver call.
   virtual int driver (int c) ;
-  
+
   // 'Internal' constructor to create a menu without association to
   // an array of items.
-  NCursesMenu( int  lines, 
-	       int  cols, 
-	       int  begin_y = 0, 
-	       int  begin_x = 0) 
-    : NCursesPanel(lines,cols,begin_y,begin_x), 
-      menu ((MENU*)0) {
+  NCursesMenu( int  nlines,
+	       int  ncols,
+	       int  begin_y = 0,
+	       int  begin_x = 0)
+    : NCursesPanel(nlines,ncols,begin_y,begin_x),
+      menu (STATIC_CAST(MENU*)(0)),
+      sub(),
+      b_sub_owner(),
+      b_framed(),
+      b_autoDelete(),
+      my_items()
+  {
   }
 
 public:
@@ -235,22 +281,56 @@
   NCursesMenu (NCursesMenuItem* Items[],
 	       bool with_frame=FALSE,        // Reserve space for a frame?
 	       bool autoDelete_Items=FALSE)  // Autocleanup of Items?
-    : NCursesPanel() {
+    : NCursesPanel(),
+      menu(),
+      sub(),
+      b_sub_owner(),
+      b_framed(),
+      b_autoDelete(),
+      my_items()
+  {
       InitMenu(Items, with_frame, autoDelete_Items);
   }
 
   // Make a menu with a window of this size.
-  NCursesMenu (NCursesMenuItem* Items[], 
-	       int  lines, 
-	       int  cols, 
-	       int  begin_y = 0, 
+  NCursesMenu (NCursesMenuItem* Items[],
+	       int  nlines,
+	       int  ncols,
+	       int  begin_y = 0,
 	       int  begin_x = 0,
 	       bool with_frame=FALSE,        // Reserve space for a frame?
 	       bool autoDelete_Items=FALSE)  // Autocleanup of Items?
-    : NCursesPanel(lines, cols, begin_y, begin_x) {
+    : NCursesPanel(nlines, ncols, begin_y, begin_x),
+      menu(),
+      sub(),
+      b_sub_owner(),
+      b_framed(),
+      b_autoDelete(),
+      my_items()
+  {
       InitMenu(Items, with_frame, autoDelete_Items);
   }
 
+  NCursesMenu& operator=(const NCursesMenu& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+      NCursesPanel::operator=(rhs);
+    }
+    return *this;
+  }
+
+  NCursesMenu(const NCursesMenu& rhs)
+    : NCursesPanel(rhs),
+      menu(rhs.menu),
+      sub(rhs.sub),
+      b_sub_owner(rhs.b_sub_owner),
+      b_framed(rhs.b_framed),
+      b_autoDelete(rhs.b_autoDelete),
+      my_items(rhs.my_items)
+  {
+  }
+
   virtual ~NCursesMenu ();
 
   // Retrieve the menus subwindow
@@ -264,17 +344,17 @@
 
   // Set these items for the menu
   inline void setItems(NCursesMenuItem* Items[]) {
-    OnError(::set_menu_items(menu,mapItems(Items)));    
+    OnError(::set_menu_items(menu,mapItems(Items)));
   }
 
   // Remove the menu from the screen
-  inline void unpost (void) { 
-    OnError (::unpost_menu (menu)); 
+  inline void unpost (void) {
+    OnError (::unpost_menu (menu));
   }
-  
+
   // Post the menu to the screen if flag is true, unpost it otherwise
   inline void post(bool flag = TRUE) {
-    flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu)); 
+    flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu));
   }
 
   // Get the numer of rows and columns for this menu
@@ -286,35 +366,35 @@
   inline void set_format(int mrows, int mcols) {
     OnError (::set_menu_format(menu, mrows, mcols));
   }
-  
+
   // Get the format of this menu
-  inline void menu_format(int& rows,int& cols) { 
-    ::menu_format(menu,&rows,&cols); 
+  inline void menu_format(int& rows,int& ncols) {
+    ::menu_format(menu,&rows,&ncols);
   }
-  
+
   // Items of the menu
   inline NCursesMenuItem* items() const {
-    return *my_items; 
+    return *my_items;
   }
 
   // Get the number of items in this menu
   inline int count() const {
-    return ::item_count(menu); 
+    return ::item_count(menu);
   }
 
   // Get the current item (i.e. the one the cursor is located)
   inline NCursesMenuItem* current_item() const {
     return my_items[::item_index(::current_item(menu))];
   }
-  
+
   // Get the marker string
   inline const char* mark() const {
     return ::menu_mark(menu);
   }
 
   // Set the marker string
-  inline void set_mark(const char *mark) {
-    OnError (::set_menu_mark (menu, mark));
+  inline void set_mark(const char *marker) {
+    OnError (::set_menu_mark (menu, marker));
   }
 
   // Get the name of the request code c
@@ -363,7 +443,7 @@
   inline chtype set_grey(chtype a) {
     return ::set_menu_grey(menu,a);
   }
-  
+
   inline void options_on (Menu_Options opts) {
     OnError (::menu_opts_on (menu,opts));
   }
@@ -375,7 +455,7 @@
   inline Menu_Options options() const {
     return ::menu_opts(menu);
   }
-  
+
   inline void set_options (Menu_Options opts) {
     OnError (::set_menu_opts (menu,opts));
   }
@@ -387,7 +467,7 @@
   inline void set_pad (int padch) {
     OnError (::set_menu_pad (menu, padch));
   }
-  
+
   // Position the cursor to the current item
   inline void position_cursor () const {
     OnError (::pos_menu_cursor (menu));
@@ -418,7 +498,7 @@
 			       spc_rows,
 			       spc_columns));
   }
-  
+
   // Get the spacing info for the menu
   inline void Spacing(int& spc_description,
 		      int& spc_rows,
@@ -443,7 +523,7 @@
     else
       OnError(E_SYSTEM_ERROR);
   }
-  
+
   inline void label(const char *topLabel, const char *bottomLabel) {
     if (b_framed)
       NCursesPanel::label(topLabel,bottomLabel);
@@ -468,7 +548,7 @@
 
   // Called before this item is left as current item.
   virtual void On_Item_Termination(NCursesMenuItem& item);
-  
+
   // Provide a default key virtualization. Translate the keyboard
   // code c into a menu request code.
   // The default implementation provides a hopefully straightforward
@@ -495,7 +575,7 @@
 
   // Called if the request is denied
   virtual void On_Request_Denied(int c) const;
-  
+
   // Called if the item is not selectable
   virtual void On_Not_Selectable(int c) const;
 
@@ -519,21 +599,21 @@
 public:
   NCursesUserItem (const char* p_name,
 		   const char* p_descript = NULL,
-		   const T* p_UserData    = (T*)0)
+		   const T* p_UserData    = STATIC_CAST(T*)(0))
     : NCursesMenuItem (p_name, p_descript) {
       if (item)
-	OnError (::set_item_userptr (item, (void *)p_UserData));
-  };
+	OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData))));
+  }
 
-  virtual ~NCursesUserItem() {};
+  virtual ~NCursesUserItem() {}
 
   inline const T* UserData (void) const {
-    return (const T*)::item_userptr (item);
+    return reinterpret_cast<const T*>(::item_userptr (item));
   };
 
   inline virtual void setUserData(const T* p_UserData) {
     if (item)
-      OnError (::set_item_userptr (item, (void *)p_UserData));
+      OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void *>(p_UserData))));
   }
 };
 //
@@ -544,48 +624,48 @@
 template<class T> class NCURSES_IMPEXP NCursesUserMenu : public NCursesMenu
 {
 protected:
-  NCursesUserMenu( int  lines, 
-		   int  cols, 
-		   int  begin_y = 0, 
+  NCursesUserMenu( int  nlines,
+		   int  ncols,
+		   int  begin_y = 0,
 		   int  begin_x = 0,
-		   const T* p_UserData = (T*)0) 
-    : NCursesMenu(lines,cols,begin_y,begin_x) {
+		   const T* p_UserData = STATIC_CAST(T*)(0))
+    : NCursesMenu(nlines,ncols,begin_y,begin_x) {
       if (menu)
-	set_user ((void *)p_UserData);
+	set_user (const_cast<void *>(p_UserData));
   }
 
 public:
   NCursesUserMenu (NCursesMenuItem Items[],
-		   const T* p_UserData = (T*)0,
+		   const T* p_UserData = STATIC_CAST(T*)(0),
 		   bool with_frame=FALSE,
 		   bool autoDelete_Items=FALSE)
     : NCursesMenu (Items, with_frame, autoDelete_Items) {
       if (menu)
-	set_user ((void *)p_UserData);
+	set_user (const_cast<void *>(p_UserData));
   };
-  
+
   NCursesUserMenu (NCursesMenuItem Items[],
-		   int lines, 
-		   int cols, 
-		   int begin_y = 0, 
+		   int nlines,
+		   int ncols,
+		   int begin_y = 0,
 		   int begin_x = 0,
-		   const T* p_UserData = (T*)0,
+		   const T* p_UserData = STATIC_CAST(T*)(0),
 		   bool with_frame=FALSE)
-    : NCursesMenu (Items, lines, cols, begin_y, begin_x, with_frame) {
+    : NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) {
       if (menu)
-	set_user ((void *)p_UserData);
-  };  
-  
+	set_user (const_cast<void *>(p_UserData));
+  };
+
   virtual ~NCursesUserMenu() {
   };
-  
+
   inline T* UserData (void) const {
-    return (T*)get_user ();
+    return reinterpret_cast<T*>(get_user ());
   };
 
   inline virtual void setUserData (const T* p_UserData) {
     if (menu)
-      set_user ((void *)p_UserData);
+      set_user (const_cast<void *>(p_UserData));
   }
 };
 
diff -Naur ncurses-5.4.orig/c++/cursesp.cc ncurses-5.4/c++/cursesp.cc
--- ncurses-5.4.orig/c++/cursesp.cc	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursesp.cc	2005-05-13 04:09:56.000000000 +0000
@@ -1,6 +1,6 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -35,11 +35,12 @@
 #include "cursesp.h"
 #include <string.h>
 
-MODULE_ID("$Id: cursesp.cc,v 1.21 2003/10/25 15:04:46 tom Exp $")
+MODULE_ID("$Id: cursesp.cc,v 1.24 2005/04/09 14:12:23 tom Exp $")
 
-NCursesPanel* NCursesPanel::dummy = (NCursesPanel*)0;
+NCursesPanel* NCursesPanel::dummy = static_cast<NCursesPanel*>(0);
 
-void NCursesPanel::init() {
+void NCursesPanel::init()
+{
   p = ::new_panel(w);
   if (!p)
     OnError(ERR);
@@ -48,11 +49,12 @@
   hook->m_user  = NULL;
   hook->m_back  = this;
   hook->m_owner = p;
-  ::set_panel_userptr(p, (void *)hook);
+  ::set_panel_userptr(p, reinterpret_cast<void *>(hook));
 }
 
-NCursesPanel::~NCursesPanel() {
-  UserHook* hook = (UserHook*)::panel_userptr(p);
+NCursesPanel::~NCursesPanel()
+{
+  UserHook* hook = UserPointer();
   assert(hook != 0 && hook->m_back==this && hook->m_owner==p);
   delete hook;
   ::del_panel(p);
@@ -60,7 +62,8 @@
 }
 
 void
-NCursesPanel::redraw() {
+NCursesPanel::redraw()
+{
   PANEL *pan;
 
   pan = ::panel_above(NULL);
@@ -73,26 +76,30 @@
 }
 
 int
-NCursesPanel::refresh() {
+NCursesPanel::refresh()
+{
   ::update_panels();
   return ::doupdate();
 }
 
 int
-NCursesPanel::noutrefresh() {
+NCursesPanel::noutrefresh()
+{
   ::update_panels();
   return OK;
 }
 
 void
-NCursesPanel::boldframe(const char *title, const char* btitle) {
+NCursesPanel::boldframe(const char *title, const char* btitle)
+{
   standout();
   frame(title, btitle);
   standend();
 }
 
 void
-NCursesPanel::frame(const char *title,const char *btitle) {
+NCursesPanel::frame(const char *title,const char *btitle)
+{
   int err = OK;
   if (!title && !btitle) {
     err = box();
@@ -106,7 +113,8 @@
 }
 
 void
-NCursesPanel::label(const char *tLabel, const char *bLabel) {
+NCursesPanel::label(const char *tLabel, const char *bLabel)
+{
   if (tLabel)
     centertext(0,tLabel);
   if (bLabel)
@@ -114,16 +122,18 @@
 }
 
 void
-NCursesPanel::centertext(int row,const char *label) {
-  if (label) {
-    int x = (maxx() - ::strlen(label)) / 2;
+NCursesPanel::centertext(int row,const char *labelText)
+{
+  if (labelText) {
+    int x = (maxx() - ::strlen(labelText)) / 2;
     if (x<0)
       x=0;
-    OnError(addstr(row, x, label, width()));
+    OnError(addstr(row, x, labelText, width()));
   }
 }
 
 int
-NCursesPanel::getKey(void) {
+NCursesPanel::getKey(void)
+{
   return getch();
 }
diff -Naur ncurses-5.4.orig/c++/cursesp.h ncurses-5.4/c++/cursesp.h
--- ncurses-5.4.orig/c++/cursesp.h	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursesp.h	2005-05-13 04:09:58.000000000 +0000
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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 @@
 #ifndef NCURSES_CURSESP_H_incl
 #define NCURSES_CURSESP_H_incl 1
 
-// $Id: cursesp.h,v 1.18 2003/10/25 15:04:46 tom Exp $
+// $Id: cursesp.h,v 1.23 2005/04/30 21:01:56 Jeff.Chua Exp $
 
 #include <cursesw.h>
 
@@ -42,7 +42,9 @@
 #  include <panel.h>
 }
 
-class NCURSES_IMPEXP NCursesPanel : public NCursesWindow {
+class NCURSES_IMPEXP NCursesPanel
+  : public NCursesWindow
+{
 protected:
   PANEL *p;
   static NCursesPanel *dummy;
@@ -56,23 +58,33 @@
     const PANEL*        m_owner;     // the panel itself
   } UserHook;
 
+  inline UserHook *UserPointer()
+  {
+    UserHook* uptr = reinterpret_cast<UserHook*>(
+                           const_cast<void *>(::panel_userptr (p)));
+    return 0;
+  }
+
   void init();                       // Initialize the panel object
 
 protected:
-  void set_user(void *user) {
-    UserHook* uptr = (UserHook*)::panel_userptr (p);
+  void set_user(void *user)
+  {
+    UserHook* uptr = UserPointer();
     assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p);
     uptr->m_user = user;
   }
   // Set the user pointer of the panel.
-  
-  void *get_user() {
-    UserHook* uptr = (UserHook*)::panel_userptr (p);
+
+  void *get_user()
+  {
+    UserHook* uptr = UserPointer();
     assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p);
     return uptr->m_user;
   }
-  
-  void OnError (int err) const THROWS((NCursesPanelException)) {
+
+  void OnError (int err) const THROWS((NCursesPanelException))
+  {
     if (err==ERR)
       THROW(new NCursesPanelException (this, err));
   }
@@ -83,50 +95,76 @@
   virtual int getKey(void);
 
 public:
-  NCursesPanel(int lines,
-	       int cols,
+  NCursesPanel(int nlines,
+	       int ncols,
 	       int begin_y = 0,
 	       int begin_x = 0)
-    : NCursesWindow(lines,cols,begin_y,begin_x) {
-      init();
-  } 
+    : NCursesWindow(nlines,ncols,begin_y,begin_x), p()
+  {
+    init();
+  }
   // Create a panel with this size starting at the requested position.
 
-  NCursesPanel() : NCursesWindow(::stdscr) { init(); }
+  NCursesPanel()
+    : NCursesWindow(::stdscr), p()
+  {
+    init();
+  }
   // This constructor creates the default Panel associated with the
   // ::stdscr window
 
+  NCursesPanel& operator=(const NCursesPanel& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+      NCursesWindow::operator=(rhs);
+    }
+    return *this;
+  }
+
+  NCursesPanel(const NCursesPanel& rhs)
+    : NCursesWindow(rhs),
+      p(rhs.p)
+  {
+  }
+
   virtual ~NCursesPanel();
-  
+
   // basic manipulation
-  inline void hide() {
+  inline void hide()
+  {
     OnError (::hide_panel(p));
   }
   // Hide the panel. It stays in the stack but becomes invisible.
 
-  inline void show() {
+  inline void show()
+  {
     OnError (::show_panel(p));
   }
   // Show the panel, i.e. make it visible.
 
-  inline void top() {
+  inline void top()
+  {
     OnError (::top_panel(p));
   }
   // Make this panel the top panel in the stack.
-  
-  inline void bottom() {
+
+  inline void bottom()
+  {
     OnError (::bottom_panel(p));
   }
   // Make this panel the bottom panel in the stack.
   // N.B.: The panel associated with ::stdscr is always on the bottom. So
   // actually bottom() makes the panel the first above ::stdscr.
-  
-  virtual int mvwin(int y, int x) {
+
+  virtual int mvwin(int y, int x)
+  {
     OnError(::move_panel(p, y, x));
     return OK;
   }
-  
-  inline bool hidden() const {
+
+  inline bool hidden() const
+  {
     return (::panel_hidden (p) ? TRUE : FALSE);
   }
   // Return TRUE if the panel is hidden, FALSE otherwise.
@@ -138,12 +176,14 @@
    need a reverse mapping from PANEL to NCursesPanel which needs some
    redesign of the low level stuff. At the moment, we define them in the
    interface but they will always produce an error. */
-  inline NCursesPanel& above() const {
+  inline NCursesPanel& above() const
+  {
     OnError(ERR);
     return *dummy;
   }
 
-  inline NCursesPanel& below() const {
+  inline NCursesPanel& below() const
+  {
     OnError(ERR);
     return *dummy;
   }
@@ -151,7 +191,7 @@
   // Those two are rewrites of the corresponding virtual members of
   // NCursesWindow
   virtual int refresh();
-  // Propagate all panel changes to the virtual screen and update the 
+  // Propagate all panel changes to the virtual screen and update the
   // physical screen.
 
   virtual int noutrefresh();
@@ -159,9 +199,9 @@
 
   static void redraw();
   // Redraw all panels.
- 
+
   // decorations
-  virtual void frame(const char* title=NULL, 
+  virtual void frame(const char* title=NULL,
 		     const char* btitle=NULL);
   // Put a frame around the panel and put the title centered in the top line
   // and btitle in the bottom line.
@@ -179,41 +219,45 @@
 };
 
 /* We use templates to provide a typesafe mechanism to associate
- * user data with a panel. A NCursesUserPanel<T> is a panel 
+ * user data with a panel. A NCursesUserPanel<T> is a panel
  * associated with some user data of type T.
  */
 template<class T> class NCursesUserPanel : public NCursesPanel
 {
 public:
-  NCursesUserPanel (int lines,
-		    int cols,
+  NCursesUserPanel (int nlines,
+		    int ncols,
 		    int begin_y = 0,
 		    int begin_x = 0,
-		    const T* p_UserData = (T*)0)
-    : NCursesPanel (lines, cols, begin_y, begin_x) {
+		    const T* p_UserData = STATIC_CAST(T*)(0))
+    : NCursesPanel (nlines, ncols, begin_y, begin_x)
+  {
       if (p)
-	set_user ((void *)p_UserData);
+	set_user (const_cast<void *>(p_UserData));
   };
   // This creates an user panel of the requested size with associated
   // user data pointed to by p_UserData.
-  
-  NCursesUserPanel(const T* p_UserData = (T*)0) : NCursesPanel() {
+
+  NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel()
+  {
     if (p)
-      set_user((void *)p_UserData);
+      set_user(const_cast<void *>(p_UserData));
   };
   // This creates an user panel associated with the ::stdscr and user data
   // pointed to by p_UserData.
 
   virtual ~NCursesUserPanel() {};
 
-  T* UserData (void) const {
-    return (T*)get_user ();
+  T* UserData (void) const
+  {
+    return reinterpret_cast<T*>(get_user ());
   };
   // Retrieve the user data associated with the panel.
-  
-  virtual void setUserData (const T* p_UserData) {
+
+  virtual void setUserData (const T* p_UserData)
+  {
     if (p)
-      set_user ((void *)p_UserData);
+      set_user (const_cast<void *>(p_UserData));
   }
   // Associate the user panel with the user data pointed to by p_UserData.
 };
diff -Naur ncurses-5.4.orig/c++/cursespad.cc ncurses-5.4/c++/cursespad.cc
--- ncurses-5.4.orig/c++/cursespad.cc	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursespad.cc	2005-05-13 04:09:54.000000000 +0000
@@ -1,6 +1,6 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -35,17 +35,17 @@
 #include "etip.h"
 #include "cursesw.h"
 
-MODULE_ID("$Id: cursespad.cc,v 1.7 2003/10/25 15:04:46 tom Exp $")
+MODULE_ID("$Id: cursespad.cc,v 1.9 2005/04/02 20:25:35 tom Exp $")
 
-NCursesPad::NCursesPad(int lines, int cols)
+NCursesPad::NCursesPad(int nlines, int ncols)
   : NCursesWindow(),
-    viewWin((NCursesWindow*)0),
-    viewSub((NCursesWindow*)0),
+    viewWin(static_cast<NCursesWindow*>(0)),
+    viewSub(static_cast<NCursesWindow*>(0)),
     h_gridsize(0), v_gridsize(0),
     min_row(0), min_col(0)
 {
-  w = ::newpad(lines,cols);
-  if ((WINDOW*)0==w) {
+  w = ::newpad(nlines, ncols);
+  if (static_cast<WINDOW*>(0) == w) {
     count--;
     err_handler("Cannot construct window");
   }
@@ -84,7 +84,7 @@
 {
   NCursesWindow* W = Win();
 
-  if ((NCursesWindow*)0 != W) {
+  if (static_cast<NCursesWindow*>(0) != W) {
     int Width  = W->width();
     int Height = W->height();
 
@@ -169,7 +169,7 @@
 int NCursesPad::refresh()
 {
   int res = noutrefresh();
-  if (res==OK && ((NCursesWindow*)0 != viewWin)) {
+  if (res==OK && (static_cast<NCursesWindow*>(0) != viewWin)) {
     res = (viewWin->refresh());
   }
   return(res);
@@ -179,7 +179,7 @@
 {
   int res = OK;
   NCursesWindow* W = Win();
-  if ((NCursesWindow*)0 != W) {
+  if (static_cast<NCursesWindow*>(0) != W) {
     res = copywin(*W,min_row,min_col,
 		  0,0,W->maxy(),W->maxx(),
 		  FALSE);
@@ -207,7 +207,7 @@
 
 void NCursesPad::setSubWindow(NCursesWindow& sub)
 {
-  if ((NCursesWindow*)0 == viewWin)
+  if (static_cast<NCursesWindow*>(0) == viewWin)
     err_handler("Pad has no viewport");
   if (!viewWin->isDescendant(sub))
     THROW(new NCursesException("NCursesFramePad", E_SYSTEM_ERROR));
@@ -217,9 +217,9 @@
 void NCursesFramedPad::OnOperation(int pad_req)
 {
   NCursesWindow* W = Win();
-  NCursesWindow* Win = getWindow();
+  NCursesWindow* W2 = getWindow();
 
-  if (((NCursesWindow*)0 != W) && ((NCursesWindow*)0 != Win)) {
+  if ((static_cast<NCursesWindow*>(0) != W) && (static_cast<NCursesWindow*>(0) != W2)) {
     int Width  = W->width();
     int Height = W->height();
     int i, row, col, h_len, v_len;
@@ -244,32 +244,32 @@
     if (row + v_len > Height)
       row = Height - v_len;
 
-    Win->vline(1,Width+1,Height);
-    Win->attron(A_REVERSE);
+    W2->vline(1,Width+1,Height);
+    W2->attron(A_REVERSE);
     if (v_len>=2) {
-      Win->addch(row+1,Width+1,ACS_UARROW);
+      W2->addch(row+1,Width+1,ACS_UARROW);
       for(i=2;i<v_len;i++)
-	Win->addch(row+i,Width+1,' ');
-      Win->addch(row+v_len,Width+1,ACS_DARROW);
+	W2->addch(row+i,Width+1,' ');
+      W2->addch(row+v_len,Width+1,ACS_DARROW);
     }
     else {
       for(i=1;i<=v_len;i++)
-	Win->addch(row+i,Width+1,' ');
+	W2->addch(row+i,Width+1,' ');
     }
-    Win->attroff(A_REVERSE);
+    W2->attroff(A_REVERSE);
 
-    Win->hline(Height+1,1,Width);
-    Win->attron(A_REVERSE);
+    W2->hline(Height+1,1,Width);
+    W2->attron(A_REVERSE);
     if (h_len >= 2) {
-      Win->addch(Height+1,col+1,ACS_LARROW);
+      W2->addch(Height+1,col+1,ACS_LARROW);
       for(i=2;i<h_len;i++)
-	Win->addch(Height+1,col+i,' ');
-      Win->addch(Height+1,col+h_len,ACS_RARROW);
+	W2->addch(Height+1,col+i,' ');
+      W2->addch(Height+1,col+h_len,ACS_RARROW);
     }
     else {
       for(i=1;i<=h_len;i++)
-	Win->addch(Height+1,col+i,' ');
+	W2->addch(Height+1,col+i,' ');
     }
-    Win->attroff(A_REVERSE);
+    W2->attroff(A_REVERSE);
   }
 }
diff -Naur ncurses-5.4.orig/c++/cursesw.cc ncurses-5.4/c++/cursesw.cc
--- ncurses-5.4.orig/c++/cursesw.cc	2003-10-25 15:02:46.000000000 +0000
+++ ncurses-5.4/c++/cursesw.cc	2005-05-13 04:09:54.000000000 +0000
@@ -26,7 +26,7 @@
 #include "internal.h"
 #include "cursesw.h"
 
-MODULE_ID("$Id: cursesw.cc,v 1.26 2003/10/25 15:02:46 tom Exp $")
+MODULE_ID("$Id: cursesw.cc,v 1.29 2005/04/02 20:28:50 tom Exp $")
 
 #define COLORS_NEED_INITIALIZATION  -1
 #define COLORS_NOT_INITIALIZED       0
@@ -150,7 +150,8 @@
 }
 
 void
-NCursesWindow::initialize() {
+NCursesWindow::initialize()
+{
   if (!b_initialized) {
     ::initscr();
     b_initialized = TRUE;
@@ -163,21 +164,24 @@
   }
 }
 
-NCursesWindow::NCursesWindow() {
+NCursesWindow::NCursesWindow()
+  : w(), alloced(), par(), subwins(), sib()
+{
   initialize();
 
-  w = (WINDOW *)0;
+  w = static_cast<WINDOW *>(0);
   init();
   alloced = FALSE;
   subwins = par = sib = 0;
   count++;
 }
 
-NCursesWindow::NCursesWindow(int lines, int cols, int begin_y, int begin_x)
+NCursesWindow::NCursesWindow(int nlines, int ncols, int begin_y, int begin_x)
+  : w(), alloced(), par(), subwins(), sib()
 {
     initialize();
 
-    w = ::newwin(lines, cols, begin_y, begin_x);
+    w = ::newwin(nlines, ncols, begin_y, begin_x);
     if (w == 0) {
 	err_handler("Cannot construct window");
     }
@@ -189,6 +193,7 @@
 }
 
 NCursesWindow::NCursesWindow(WINDOW* &window)
+  : w(), alloced(), par(), subwins(), sib()
 {
     initialize();
 
@@ -201,6 +206,7 @@
 
 NCursesWindow::NCursesWindow(NCursesWindow& win, int l, int c,
 			     int begin_y, int begin_x, char absrel)
+  : w(), alloced(), par(), subwins(), sib()
 {
     initialize();
     if (absrel == 'a') { // absolute origin
@@ -227,6 +233,7 @@
 
 NCursesWindow::NCursesWindow(NCursesWindow& win,
 				bool do_box NCURSES_PARAM_INIT(TRUE))
+  : w(), alloced(), par(), subwins(), sib()
 {
   initialize();
   w = :: derwin(win.w,win.height()-2,win.width()-2,1,1);
@@ -247,7 +254,8 @@
   }
 }
 
-NCursesWindow NCursesWindow::Clone() {
+NCursesWindow NCursesWindow::Clone()
+{
   WINDOW *d = ::dupwin(w);
   NCursesWindow W(d);
   W.subwins = subwins;
@@ -264,29 +272,32 @@
 
 extern "C" int _nc_ripoffline(int,int (*init)(WINDOW*,int));
 
-NCursesWindow::NCursesWindow(WINDOW *win, int cols) {
+NCursesWindow::NCursesWindow(WINDOW *win, int ncols)
+  : w(), alloced(), par(), subwins(), sib()
+{
   initialize();
   w = win;
-  assert((w->_maxx+1)==cols);
+  assert((w->_maxx+1)==ncols);
   alloced = FALSE;
   subwins = par = sib = 0;
 }
 
-int NCursesWindow::ripoff_init(WINDOW *w, int cols)
+int _nc_xx_ripoff_init(WINDOW *w, int ncols)
 {
   int res = ERR;
 
   RIPOFFINIT init = *prip++;
   if (init) {
-    NCursesWindow* W = new NCursesWindow(w,cols);
+    NCursesWindow* W = new NCursesWindow(w,ncols);
     res = init(*W);
   }
   return res;
 }
 
 int NCursesWindow::ripoffline(int ripoff_lines,
-			      int (*init)(NCursesWindow& win)) {
-  int code = ::_nc_ripoffline(ripoff_lines,ripoff_init);
+			      int (*init)(NCursesWindow& win))
+{
+  int code = ::_nc_ripoffline(ripoff_lines,_nc_xx_ripoff_init);
   if (code==OK && init && ripoff_lines) {
     R_INIT[r_init_idx++] = init;
   }
@@ -294,7 +305,8 @@
 }
 
 bool
-NCursesWindow::isDescendant(NCursesWindow& win) {
+NCursesWindow::isDescendant(NCursesWindow& win)
+{
   for (NCursesWindow* p = subwins; p != NULL; p = p->sib) {
     if (p==&win)
       return TRUE;
@@ -386,7 +398,7 @@
     short fore, back;
 
     if (colorInitialized==COLORS_ARE_REALLY_THERE) {
-      if (::pair_content((short)PAIR_NUMBER(w->_attrs), &fore, &back))
+      if (::pair_content(static_cast<short>(PAIR_NUMBER(w->_attrs)), &fore, &back))
 	err_handler("Can't get color pair");
     }
     else {
@@ -427,7 +439,7 @@
 NCursesWindow::setpalette(short fore, short back)
 {
   if (colorInitialized==COLORS_ARE_REALLY_THERE)
-    return setpalette(fore, back, (short)PAIR_NUMBER(w->_attrs));
+    return setpalette(fore, back, static_cast<short>(PAIR_NUMBER(w->_attrs)));
   else
     return OK;
 }
@@ -449,7 +461,8 @@
 #if HAVE_HAS_KEY
 extern "C" int _nc_has_mouse(void);
 
-bool NCursesWindow::has_mouse() const {
+bool NCursesWindow::has_mouse() const
+{
   return ((::has_key(KEY_MOUSE) || ::_nc_has_mouse())
 	  ? TRUE : FALSE);
 }
diff -Naur ncurses-5.4.orig/c++/cursesw.h ncurses-5.4/c++/cursesw.h
--- ncurses-5.4.orig/c++/cursesw.h	2004-02-08 00:11:54.000000000 +0000
+++ ncurses-5.4/c++/cursesw.h	2005-05-13 04:09:54.000000000 +0000
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2001,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -30,7 +30,7 @@
 #ifndef NCURSES_CURSESW_H_incl
 #define NCURSES_CURSESW_H_incl 1
 
-// $Id: cursesw.h,v 1.30 2004/02/08 00:11:54 tom Exp $
+// $Id: cursesw.h,v 1.35 2005/04/02 21:57:10 tom Exp $
 
 #include <etip.h>
 #include <stdarg.h>
@@ -690,9 +690,10 @@
  *
  * C++ class for windows.
  *
- *
  */
 
+extern "C" int     _nc_xx_ripoff_init(WINDOW *, int);
+
 class NCURSES_IMPEXP NCursesWindow
 {
   friend class NCursesMenu;
@@ -701,7 +702,7 @@
 private:
   static bool    b_initialized;
   static void    initialize();
-  static int     ripoff_init(WINDOW *, int);
+  friend int     _nc_xx_ripoff_init(WINDOW *, int);
 
   void           init();
 
@@ -712,10 +713,10 @@
 
   // This private constructor is only used during the initialization
   // of windows generated by ripoffline() calls.
-  NCursesWindow(WINDOW* win, int cols);
+  NCursesWindow(WINDOW* win, int ncols);
 
 protected:
-  void           err_handler(const char *) const THROWS(NCursesException);
+  virtual void   err_handler(const char *) const THROWS(NCursesException);
   // Signal an error with the given message text.
 
   static long count;        // count of all active windows:
@@ -741,14 +742,14 @@
 public:
   NCursesWindow(WINDOW* &window);  // useful only for stdscr
 
-  NCursesWindow(int lines,         // number of lines
-		int cols,          // number of columns
+  NCursesWindow(int nlines,        // number of lines
+		int ncols,         // number of columns
 		int begin_y,       // line origin
 		int begin_x);      // col origin
 
   NCursesWindow(NCursesWindow& par,// parent window
-		int lines,         // number of lines
-		int cols,          // number of columns
+		int nlines,        // number of lines
+		int ncols,         // number of columns
 		int begin_y,       // absolute or relative
 		int begin_x,       //   origins:
 		char absrel = 'a');// if `a', begin_y & begin_x are
@@ -760,6 +761,18 @@
   // is two lines and two columns smaller and begins at (1,1).
   // We may automatically request the box around it.
 
+  NCursesWindow& operator=(const NCursesWindow& rhs)
+  {
+    if (this != &rhs)
+      *this = rhs;
+    return *this;
+  }
+
+  NCursesWindow(const NCursesWindow& rhs)
+    : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
+  {
+  }
+
   virtual ~NCursesWindow();
 
   NCursesWindow Clone();
@@ -979,10 +992,10 @@
   int            attron (chtype at) { return ::wattron (w, at); }
   // Switch on the window attributes;
 
-  int            attroff(chtype at) { return ::wattroff(w, (int) at); }
+  int            attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
   // Switch off the window attributes;
 
-  int            attrset(chtype at) { return ::wattrset(w, (int) at); }
+  int            attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
   // Set the window attributes;
 
   int            color_set(short color_pair_number, void* opts=NULL) {
@@ -1112,7 +1125,7 @@
   // Mark the whole window as unmodified.
 
   int            touchln(int s, int cnt, bool changed=TRUE) {
-    return ::wtouchln(w, s, cnt, (int)(changed?1:0)); }
+    return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
   // Mark cnt lines beginning from line s as changed or unchanged, depending
   // on the value of the changed flag.
 
@@ -1196,9 +1209,9 @@
   int            copywin(NCursesWindow& win,
 			 int sminrow, int smincol,
 			 int dminrow, int dmincol,
-			 int dmaxrow, int dmaxcol, bool overlay=TRUE) {
+			 int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
     return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
-		     dmaxrow, dmaxcol, (int)(overlay?1:0)); }
+		     dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
   // Overlay or overwrite the rectangle in win given by dminrow,dmincol,
   // dmaxrow,dmaxcol with the rectangle in this window beginning at
   // sminrow,smincol.
@@ -1228,26 +1241,28 @@
 // -------------------------------------------------------------------------
 // We leave this here for compatibility reasons.
 // -------------------------------------------------------------------------
-class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow {
+class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow
+{
 public:
   NCursesColorWindow(WINDOW* &window)   // useful only for stdscr
     : NCursesWindow(window) {
       useColors(); }
 
-  NCursesColorWindow(int lines,         // number of lines
-		     int cols,          // number of columns
+  NCursesColorWindow(int nlines,        // number of lines
+		     int ncols,         // number of columns
 		     int begin_y,       // line origin
 		     int begin_x)       // col origin
-    : NCursesWindow(lines, cols, begin_y, begin_x) {
+    : NCursesWindow(nlines, ncols, begin_y, begin_x) {
       useColors(); }
 
-  NCursesColorWindow(NCursesWindow& par,// parent window
-		     int lines,         // number of lines
-		     int cols,          // number of columns
+  NCursesColorWindow(NCursesWindow& parentWin,// parent window
+		     int nlines,        // number of lines
+		     int ncols,         // number of columns
 		     int begin_y,       // absolute or relative
 		     int begin_x,       //   origins:
 		     char absrel = 'a') // if `a', by & bx are
-    : NCursesWindow(par, lines, cols,   // absolute screen pos,
+    : NCursesWindow(parentWin,
+		    nlines, ncols,	// absolute screen pos,
 		    begin_y, begin_x,   // else if `r', they are
 		    absrel ) {          // relative to par origin
       useColors(); }
@@ -1272,7 +1287,8 @@
 // Pad Support. We allow an association of a pad with a "real" window
 // through which the pad may be viewed.
 // -------------------------------------------------------------------------
-class NCURSES_IMPEXP NCursesPad : public NCursesWindow {
+class NCURSES_IMPEXP NCursesPad : public NCursesWindow
+{
 private:
   NCursesWindow* viewWin;       // the "viewport" window
   NCursesWindow* viewSub;       // the "viewport" subwindow
@@ -1314,9 +1330,29 @@
   // the refresh() operation is done.
 
 public:
-  NCursesPad(int lines, int cols);
+  NCursesPad(int nlines, int ncols);
   // create a pad with the given size
 
+  NCursesPad& operator=(const NCursesPad& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+      NCursesWindow::operator=(rhs);
+    }
+    return *this;
+  }
+
+  NCursesPad(const NCursesPad& rhs)
+    : NCursesWindow(rhs),
+      viewWin(rhs.viewWin),
+      viewSub(rhs.viewSub),
+      h_gridsize(rhs.h_gridsize),
+      v_gridsize(rhs.v_gridsize),
+      min_row(rhs.min_row),
+      min_col(rhs.min_col)
+  {
+  }
+
   virtual ~NCursesPad() {}
 
   int echochar(const chtype ch) { return ::pechochar(w, ch); }
@@ -1364,14 +1400,15 @@
 // A FramedPad is constructed always with a viewport window. This viewport
 // will be framed (by a box() command) and the interior of the box is the
 // viewport subwindow. On the frame we display scrollbar sliders.
-class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad {
+class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad
+{
 protected:
   virtual void OnOperation(int pad_req);
 
 public:
-  NCursesFramedPad(NCursesWindow& win, int lines, int cols,
+  NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
 		   int v_grid = 1, int h_grid = 1)
-    : NCursesPad(lines, cols) {
+    : NCursesPad(nlines, ncols) {
     NCursesPad::setWindow(win, v_grid, h_grid);
     NCursesPad::setSubWindow(*(new NCursesWindow(win)));
   }
diff -Naur ncurses-5.4.orig/c++/cursslk.cc ncurses-5.4/c++/cursslk.cc
--- ncurses-5.4.orig/c++/cursslk.cc	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursslk.cc	2005-05-13 04:09:54.000000000 +0000
@@ -1,6 +1,6 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -36,21 +36,25 @@
 #include "cursesapp.h"
 #include <string.h>
 
-MODULE_ID("$Id: cursslk.cc,v 1.11 2003/10/25 15:04:46 tom Exp $")
+MODULE_ID("$Id: cursslk.cc,v 1.14 2005/04/03 12:49:46 tom Exp $")
 
-void Soft_Label_Key_Set::Soft_Label_Key::operator=(char *text)  {
+Soft_Label_Key_Set::Soft_Label_Key&
+  Soft_Label_Key_Set::Soft_Label_Key::operator=(char *text)
+{
   delete[] label;
   label = new char[1 + ::strlen(text)];
   (::strcpy)(label,text);
+  return *this;
 }
 
 long Soft_Label_Key_Set::count      = 0L;
 int  Soft_Label_Key_Set::num_labels = 0;
 
-Soft_Label_Key_Set::Label_Layout 
+Soft_Label_Key_Set::Label_Layout
   Soft_Label_Key_Set::format = None;
 
-void Soft_Label_Key_Set::init() {
+void Soft_Label_Key_Set::init()
+{
   slk_array = new Soft_Label_Key[num_labels];
   for(int i=0; i < num_labels; i++) {
     slk_array[i].num = i+1;
@@ -58,18 +62,24 @@
   b_attrInit = FALSE;
 }
 
-Soft_Label_Key_Set::Soft_Label_Key_Set() {
+Soft_Label_Key_Set::Soft_Label_Key_Set()
+  : b_attrInit(FALSE),
+    slk_array(NULL)
+{
   if (format==None)
     Error("No default SLK layout");
   init();
 }
 
-Soft_Label_Key_Set::Soft_Label_Key_Set(Soft_Label_Key_Set::Label_Layout fmt) {
+Soft_Label_Key_Set::Soft_Label_Key_Set(Soft_Label_Key_Set::Label_Layout fmt)
+  : b_attrInit(FALSE),
+    slk_array(NULL)
+{
   if (fmt==None)
     Error("Invalid SLK Layout");
   if (count++==0) {
     format = fmt;
-    if (ERR == ::slk_init((int)fmt))
+    if (ERR == ::slk_init(static_cast<int>(fmt)))
       Error("slk_init");
     num_labels = (fmt>=PC_Style?12:8);
   }
@@ -103,7 +113,8 @@
   noutrefresh();
 }
 
-void Soft_Label_Key_Set::activate_labels(bool bf) {
+void Soft_Label_Key_Set::activate_labels(bool bf)
+{
   if (!b_attrInit) {
     NCursesApplication* A = NCursesApplication::getApplication();
     if (A) attrset(A->labels());
diff -Naur ncurses-5.4.orig/c++/cursslk.h ncurses-5.4/c++/cursslk.h
--- ncurses-5.4.orig/c++/cursslk.h	2003-10-25 15:04:46.000000000 +0000
+++ ncurses-5.4/c++/cursslk.h	2005-05-13 04:09:54.000000000 +0000
@@ -1,6 +1,6 @@
 // * this is for making emacs happy: -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -31,7 +31,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: cursslk.h,v 1.9 2003/10/25 15:04:46 tom Exp $
+// $Id: cursslk.h,v 1.12 2005/04/03 12:50:24 tom Exp $
 
 #ifndef NCURSES_CURSSLK_H_incl
 #define NCURSES_CURSSLK_H_incl
@@ -51,28 +51,45 @@
     Justification format;  // The Justification
     int num;               // The number of the Label
 
-    Soft_Label_Key() : label((char*)0),format(Left),num(-1) {
+    Soft_Label_Key() : label(NULL), format(Left), num(-1) {
     }
-    
+
     virtual ~Soft_Label_Key() {
       delete[] label;
     };
 
   public:
     // Set the text of the Label
-    void operator=(char *text);
-    
+    Soft_Label_Key& operator=(char *text);
+
     // Set the Justification of the Label
-    inline void operator=(Justification just) {
+    Soft_Label_Key& operator=(Justification just) {
       format = just;
+      return *this;
     }
-	 
+
     // Retrieve the text of the label
     inline char* operator()(void) const {
-      return label; 
+      return label;
+    }
+
+    Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
+    {
+      if (this != &rhs) {
+        *this = rhs;
+      }
+      return *this;
+    }
+
+    Soft_Label_Key(const Soft_Label_Key& rhs)
+      : label(NULL),
+        format(rhs.format),
+        num(rhs.num)
+    {
+      *this = rhs.label;
     }
   };
-  
+
 public:
   typedef enum {
     None                = -1,
@@ -87,7 +104,7 @@
   static Label_Layout NCURSES_IMPEXP  format;     // Layout of the Key Sets
   static int  NCURSES_IMPEXP num_labels;          // Number Of Labels in Key Sets
   bool NCURSES_IMPEXP b_attrInit;                 // Are attributes initialized
-  
+
   Soft_Label_Key *slk_array;       // The array of SLK's
 
   // Init the Key Set
@@ -105,13 +122,13 @@
   }
 
   // Remove SLK's from screen
-  void clear() { 
+  void clear() {
     if (ERR==::slk_clear())
       Error("slk_clear");
-  }    
+  }
 
   // Restore them
-  void restore() { 
+  void restore() {
     if (ERR==::slk_restore())
       Error("slk_restore");
   }
@@ -128,29 +145,45 @@
   // with a layout by the constructor above. This layout will be reused.
   NCURSES_IMPEXP Soft_Label_Key_Set();
 
+  Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+      init();		// allocate a new slk_array[]
+    }
+    return *this;
+  }
+
+  Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
+    : b_attrInit(rhs.b_attrInit),
+      slk_array(NULL)
+  {
+    init();		// allocate a new slk_array[]
+  }
+
   virtual ~Soft_Label_Key_Set();
 
   // Get Label# i. Label counting starts with 1!
   NCURSES_IMPEXP Soft_Label_Key& operator[](int i);
 
   // Retrieve number of Labels
-  inline int labels() const { return num_labels; }          
+  inline int labels() const { return num_labels; }
 
   // Refresh the SLK portion of the screen
-  inline void refresh() { 
+  inline void refresh() {
     if (ERR==::slk_refresh())
       Error("slk_refresh");
   }
 
   // Mark the SLK portion of the screen for refresh, defer actual refresh
   // until next update call.
-  inline void noutrefresh() { 
+  inline void noutrefresh() {
     if (ERR==::slk_noutrefresh())
       Error("slk_noutrefresh");
   }
 
   // Mark the whole SLK portion of the screen as modified
-  inline void touch() { 
+  inline void touch() {
     if (ERR==::slk_touch())
       Error("slk_touch");
   }
diff -Naur ncurses-5.4.orig/c++/demo.cc ncurses-5.4/c++/demo.cc
--- ncurses-5.4.orig/c++/demo.cc	2004-01-15 00:21:27.000000000 +0000
+++ ncurses-5.4/c++/demo.cc	2005-05-13 04:09:59.000000000 +0000
@@ -6,9 +6,10 @@
  *   Demo code for NCursesMenu and NCursesForm written by
  *   Juergen Pfeifer
  *
- * $Id: demo.cc,v 1.24 2004/01/15 00:21:27 tom Exp $
+ * $Id: demo.cc,v 1.30 2005/05/07 18:53:14 Mike.Frysinger Exp $
  */
 
+#include "internal.h"
 #include "cursesapp.h"
 #include "cursesm.h"
 #include "cursesf.h"
@@ -141,10 +142,10 @@
 public:
   MyAction (const char* p_name,
             const T* p_UserData)
-    : NCursesUserItem<T>(p_name, (const char*)0, p_UserData)
-  {};
+    : NCursesUserItem<T>(p_name, static_cast<const char*>(0), p_UserData)
+  {}
 
-  ~MyAction() {}
+  virtual ~MyAction() {}
 
   bool action() {
     SillyDemo a;
@@ -153,6 +154,9 @@
   }
 };
 
+template class MyAction<UserData>;
+template class NCURSES_IMPEXP NCursesUserItem<UserData>;
+
 class QuitItem : public NCursesMenuItem
 {
 public:
@@ -171,7 +175,7 @@
 public:
   Label(const char* title,
         int row, int col)
-    : NCursesFormField(1,(int)::strlen(title),row,col) {
+    : NCursesFormField(1, static_cast<int>(::strlen(title)), row, col) {
       set_value(title);
       options_off(O_EDIT|O_ACTIVE);
   }
@@ -179,7 +183,8 @@
 //
 // -------------------------------------------------------------------------
 //
-class MyFieldType : public UserDefinedFieldType {
+class MyFieldType : public UserDefinedFieldType
+{
 private:
   int chk;
 protected:
@@ -207,7 +212,13 @@
   static const char *weekdays[];
 
 public:
-  TestForm() : NCursesForm(13,51,(lines()-15)/2,(cols()-53)/2) {
+  TestForm()
+    : NCursesForm(13, 51, (lines() - 15)/2, (cols() - 53)/2),
+      F(),
+      mft(),
+      ift(),
+      eft()
+  {
 
     F     = new NCursesFormField*[10];
     mft   = new MyFieldType('X');
@@ -239,6 +250,19 @@
     F[8]->options_off(O_STATIC);  // make field dynamic
   }
 
+  TestForm& operator=(const TestForm& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+    }
+    return *this;
+  }
+
+  TestForm(const TestForm& rhs)
+    : NCursesForm(rhs), F(), mft(), ift(), eft()
+  {
+  }
+
   ~TestForm() {
     delete mft;
     delete ift;
@@ -248,7 +272,7 @@
 
 const char* TestForm::weekdays[] = {
     "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
-    "Friday", "Saturday", (const char *)0 };
+    "Friday", "Saturday", NULL };
 //
 // -------------------------------------------------------------------------
 //
@@ -297,7 +321,7 @@
           if (i==0 || j==0)
             FP.addch('+');
           else
-            FP.addch((chtype)('A' + (gridcount++ % 26)));
+            FP.addch(static_cast<chtype>('A' + (gridcount++ % 26)));
         }
         else if (i % GRIDSIZE == 0)
           FP.addch('-');
@@ -318,7 +342,8 @@
 //
 // -------------------------------------------------------------------------
 //
-class PassiveItem : public NCursesMenuItem {
+class PassiveItem : public NCursesMenuItem
+{
 public:
   PassiveItem(const char* text) : NCursesMenuItem(text) {
     options_off(O_SELECTABLE);
@@ -346,13 +371,13 @@
     ::echo();
 
     s->printw("Enter decimal integers.  The running total will be shown\n");
-    int value = -1;
+    int nvalue = -1;
     int result = 0;
-    while (value != 0) {
-      value = 0;
-      s->scanw("%d", &value);
-      if (value != 0) {
-        s->printw("%d: ", result += value);
+    while (nvalue != 0) {
+      nvalue = 0;
+      s->scanw("%d", &nvalue);
+      if (nvalue != 0) {
+        s->printw("%d: ", result += nvalue);
       }
       s->refresh();
     }
@@ -380,7 +405,8 @@
 
 public:
   MyMenu ()
-    : NCursesMenu (n_items+2, 8, (lines()-10)/2, (cols()-10)/2)
+    : NCursesMenu (n_items+2, 8, (lines()-10)/2, (cols()-10)/2),
+      P(), I(), u()
   {
     u = new UserData(1);
     I = new NCursesMenuItem*[1+n_items];
@@ -400,6 +426,19 @@
     P->show();
   }
 
+  MyMenu& operator=(const MyMenu& rhs)
+  {
+    if (this != &rhs) {
+      *this = rhs;
+    }
+    return *this;
+  }
+
+  MyMenu(const MyMenu& rhs)
+    : NCursesMenu(rhs), P(), I(), u()
+  {
+  }
+
   ~MyMenu()
   {
     P->hide();
@@ -445,7 +484,8 @@
 //
 // -------------------------------------------------------------------------
 //
-class TestApplication : public NCursesApplication {
+class TestApplication : public NCursesApplication
+{
 protected:
   int titlesize() const { return 1; }
   void title();
@@ -461,7 +501,8 @@
   int run();
 };
 
-void TestApplication::init_labels(Soft_Label_Key_Set& S) const {
+void TestApplication::init_labels(Soft_Label_Key_Set& S) const
+{
   for(int i=1; i <= S.labels(); i++) {
     char buf[5];
     ::sprintf(buf,"Key%02d",i);
@@ -470,17 +511,19 @@
   }
 }
 
-void TestApplication::title() {
-  const char * const title = "Simple C++ Binding Demo";
-  const int len = ::strlen(title);
+void TestApplication::title()
+{
+  const char * const titleText = "Simple C++ Binding Demo";
+  const int len = ::strlen(titleText);
 
   titleWindow->bkgd(screen_titles());
-  titleWindow->addstr(0,(titleWindow->cols()-len)/2,title);
+  titleWindow->addstr(0,(titleWindow->cols() - len)/2, titleText);
   titleWindow->noutrefresh();
 }
 
 
-int TestApplication::run() {
+int TestApplication::run()
+{
   MyMenu M;
   M();
   return 0;
diff -Naur ncurses-5.4.orig/c++/edit_cfg.sh ncurses-5.4/c++/edit_cfg.sh
--- ncurses-5.4.orig/c++/edit_cfg.sh	2003-12-20 13:14:25.000000000 +0000
+++ ncurses-5.4/c++/edit_cfg.sh	2005-05-13 04:09:58.000000000 +0000
@@ -1,7 +1,7 @@
 #!/bin/sh
-# $Id: edit_cfg.sh,v 1.13 2003/12/20 13:14:25 tom Exp $
+# $Id: edit_cfg.sh,v 1.14 2005/04/30 21:00:22 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2001,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2003,2005 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"), #
@@ -39,6 +39,7 @@
 echo "substituting autoconf'd values from $1 into $2"
 for name in \
 	CPP_HAS_PARAM_INIT \
+	CPP_HAS_STATIC_CAST \
 	ETIP_NEEDS_MATH_EXCEPTION \
 	ETIP_NEEDS_MATH_H \
 	HAVE_BUILTIN_H \
diff -Naur ncurses-5.4.orig/c++/etip.h.in ncurses-5.4/c++/etip.h.in
--- ncurses-5.4.orig/c++/etip.h.in	2003-10-25 15:05:58.000000000 +0000
+++ ncurses-5.4/c++/etip.h.in	2005-05-13 04:09:58.000000000 +0000
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc.         *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -31,7 +31,7 @@
  *   Author: Juergen Pfeifer, 1997                                          *
  ****************************************************************************/
 
-// $Id: etip.h.in,v 1.25 2003/10/25 15:05:58 tom Exp $
+// $Id: etip.h.in,v 1.29 2005/04/30 21:19:11 tom Exp $
 
 #ifndef NCURSES_ETIP_H_incl
 #define NCURSES_ETIP_H_incl 1
@@ -73,6 +73,10 @@
 #define CPP_HAS_PARAM_INIT 0
 #endif
 
+#ifndef CPP_HAS_STATIC_CAST
+#define CPP_HAS_STATIC_CAST 0	// workaround for g++ 2.95.3
+#endif
+
 #ifndef USE_STRSTREAM_VSCAN
 #define USE_STRSTREAM_VSCAN 0
 #endif
@@ -135,6 +139,12 @@
 #define NCURSES_PARAM_INIT(value) /*nothing*/
 #endif
 
+#if CPP_HAS_STATIC_CAST
+#define STATIC_CAST(s) static_cast<s>
+#else
+#define STATIC_CAST(s) (s)
+#endif
+
 // Forward Declarations
 class NCURSES_IMPEXP NCursesPanel;
 class NCURSES_IMPEXP NCursesMenu;
@@ -154,9 +164,24 @@
     : message(msg), errorno (E_SYSTEM_ERROR)
     {};
 
+  NCursesException& operator=(const NCursesException& rhs)
+  {
+    errorno = rhs.errorno;
+    return *this;
+  }
+
+  NCursesException(const NCursesException& rhs)
+    : message(rhs.message), errorno(rhs.errorno)
+  {
+  }
+
   virtual const char *classname() const {
     return "NCursesWindow";
   }
+
+  virtual ~NCursesException()
+  {
+  }
 };
 
 class NCURSES_IMPEXP NCursesPanelException : public NCursesException
@@ -166,7 +191,7 @@
 
   NCursesPanelException (const char *msg, int err) :
     NCursesException (msg, err),
-    p ((NCursesPanel*)0)
+    p (static_cast<NCursesPanel*>(0))
     {};
 
   NCursesPanelException (const NCursesPanel* panel,
@@ -178,7 +203,7 @@
 
   NCursesPanelException (int err) :
     NCursesException ("panel library error", err),
-    p ((NCursesPanel*)0)
+    p (static_cast<NCursesPanel*>(0))
     {};
 
   NCursesPanelException (const NCursesPanel* panel,
@@ -187,10 +212,27 @@
     p (panel)
     {};
 
+  NCursesPanelException& operator=(const NCursesPanelException& rhs)
+  {
+    if (this != &rhs) {
+      NCursesException::operator=(rhs);
+      p = rhs.p;
+    }
+    return *this;
+  }
+
+  NCursesPanelException(const NCursesPanelException& rhs)
+    : NCursesException(rhs), p(rhs.p)
+  {
+  }
+
   virtual const char *classname() const {
     return "NCursesPanel";
   }
 
+  virtual ~NCursesPanelException()
+  {
+  }
 };
 
 class NCURSES_IMPEXP NCursesMenuException : public NCursesException
@@ -200,7 +242,7 @@
 
   NCursesMenuException (const char *msg, int err) :
     NCursesException (msg, err),
-    m ((NCursesMenu *)0)
+    m (static_cast<NCursesMenu *>(0))
     {};
 
   NCursesMenuException (const NCursesMenu* menu,
@@ -212,7 +254,7 @@
 
   NCursesMenuException (int err) :
     NCursesException ("menu library error", err),
-    m ((NCursesMenu *)0)
+    m (static_cast<NCursesMenu *>(0))
     {};
 
   NCursesMenuException (const NCursesMenu* menu,
@@ -221,10 +263,27 @@
     m (menu)
     {};
 
+  NCursesMenuException& operator=(const NCursesMenuException& rhs)
+  {
+    if (this != &rhs) {
+      NCursesException::operator=(rhs);
+      m = rhs.m;
+    }
+    return *this;
+  }
+
+  NCursesMenuException(const NCursesMenuException& rhs)
+    : NCursesException(rhs), m(rhs.m)
+  {
+  }
+
   virtual const char *classname() const {
     return "NCursesMenu";
   }
 
+  virtual ~NCursesMenuException()
+  {
+  }
 };
 
 class NCURSES_IMPEXP NCursesFormException : public NCursesException
@@ -234,7 +293,7 @@
 
   NCursesFormException (const char *msg, int err) :
     NCursesException (msg, err),
-    f ((NCursesForm*)0)
+    f (static_cast<NCursesForm*>(0))
     {};
 
   NCursesFormException (const NCursesForm* form,
@@ -246,7 +305,7 @@
 
   NCursesFormException (int err) :
     NCursesException ("form library error", err),
-    f ((NCursesForm*)0)
+    f (static_cast<NCursesForm*>(0))
     {};
 
   NCursesFormException (const NCursesForm* form,
@@ -255,10 +314,27 @@
     f (form)
     {};
 
+  NCursesFormException& operator=(const NCursesFormException& rhs)
+  {
+    if (this != &rhs) {
+      NCursesException::operator=(rhs);
+      f = rhs.f;
+    }
+    return *this;
+  }
+
+  NCursesFormException(const NCursesFormException& rhs)
+    : NCursesException(rhs), f(rhs.f)
+  {
+  }
+
   virtual const char *classname() const {
     return "NCursesForm";
   }
 
+  virtual ~NCursesFormException()
+  {
+  }
 };
 
 #if !((defined(__GNUG__) && defined(__EXCEPTIONS)) || defined(__SUNPRO_CC))
diff -Naur ncurses-5.4.orig/config.guess ncurses-5.4/config.guess
--- ncurses-5.4.orig/config.guess	2004-01-07 00:58:42.000000000 +0000
+++ ncurses-5.4/config.guess	2005-05-13 04:09:56.000000000 +0000
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
-timestamp='2004-01-05'
+timestamp='2005-03-24'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
@@ -197,15 +197,21 @@
 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
 	echo "${machine}-${os}${release}"
 	exit 0 ;;
+    amd64:OpenBSD:*:*)
+	echo x86_64-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
     amiga:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    arc:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+    cats:OpenBSD:*:*)
+	echo arm-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     hp300:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
+    luna88k:OpenBSD:*:*)
+    	echo m88k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
     mac68k:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
@@ -221,28 +227,33 @@
     mvmeppc:OpenBSD:*:*)
 	echo powerpc-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    pegasos:OpenBSD:*:*)
-	echo powerpc-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
-    pmax:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
     sgi:OpenBSD:*:*)
-	echo mipseb-unknown-openbsd${UNAME_RELEASE}
+	echo mips64-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     sun3:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    wgrisc:OpenBSD:*:*)
-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
-	exit 0 ;;
     *:OpenBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
+    *:ekkoBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+	exit 0 ;;
+    macppc:MirBSD:*:*)
+	echo powerppc-unknown-mirbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:MirBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+	exit 0 ;;
     alpha:OSF1:*:*)
-	if test $UNAME_RELEASE = "V4.0"; then
+	case $UNAME_RELEASE in
+	*4.0)
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
-	fi
+		;;
+	*5.*)
+	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		;;
+	esac
 	# According to Compaq, /usr/sbin/psrinfo has been available on
 	# OSF/1 and Tru64 systems produced since 1995.  I hope that
 	# covers most systems running today.  This code pipes the CPU
@@ -280,14 +291,12 @@
 	    "EV7.9 (21364A)")
 		UNAME_MACHINE="alphaev79" ;;
 	esac
+	# A Pn.n version is a patched version.
 	# A Vn.n version is a released version.
 	# A Tn.n version is a released field test version.
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
-	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	exit 0 ;;
-    Alpha*:OpenVMS:*:*)
-	echo alpha-hp-vms
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
 	exit 0 ;;
     Alpha\ *:Windows_NT*:*)
 	# How do we know it's Interix rather than the generic POSIX subsystem?
@@ -310,8 +319,11 @@
     *:OS/390:*:*)
 	echo i370-ibm-openedition
 	exit 0 ;;
+    *:z/VM:*:*)
+	echo s390-ibm-zvmoe
+	exit 0 ;;
     *:OS400:*:*)
-	echo powerpc-ibm-os400
+        echo powerpc-ibm-os400
 	exit 0 ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
@@ -333,7 +345,7 @@
     DRS?6000:unix:4.0:6*)
 	echo sparc-icl-nx6
 	exit 0 ;;
-    DRS?6000:UNIX_SV:4.2*:7*)
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
 	case `/usr/bin/uname -p` in
 	    sparc) echo sparc-icl-nx7 && exit 0 ;;
 	esac ;;
@@ -405,6 +417,9 @@
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
         echo m68k-unknown-mint${UNAME_RELEASE}
         exit 0 ;;
+    m68k:machten:*:*)
+	echo m68k-apple-machten${UNAME_RELEASE}
+	exit 0 ;;
     powerpc:machten:*:*)
 	echo powerpc-apple-machten${UNAME_RELEASE}
 	exit 0 ;;
@@ -740,18 +755,18 @@
 	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     *:UNICOS/mp:*:*)
-	echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
 	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-	exit 0 ;;
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit 0 ;;
     5000:UNIX_System_V:4.*:*)
-	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
 	exit 0 ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
@@ -763,21 +778,7 @@
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     *:FreeBSD:*:*)
-	# Determine whether the default compiler uses glibc.
-	eval $set_cc_for_build
-	sed 's/^	//' << EOF >$dummy.c
-	#include <features.h>
-	#if __GLIBC__ >= 2
-	LIBC=gnu
-	#else
-	LIBC=
-	#endif
-EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
-	# GNU/KFreeBSD systems have a "k" prefix to indicate we are using
-	# FreeBSD's kernel, but not the complete OS.
-	case ${LIBC} in gnu) kernel_only='k' ;; esac
-	echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
+	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit 0 ;;
     i*:CYGWIN*:*)
 	echo ${UNAME_MACHINE}-pc-cygwin
@@ -803,6 +804,9 @@
     i*:UWIN*:*)
 	echo ${UNAME_MACHINE}-pc-uwin
 	exit 0 ;;
+    amd64:CYGWIN*:*:*)
+	echo x86_64-unknown-cygwin
+	exit 0 ;;
     p*:CYGWIN*:*)
 	echo powerpcle-unknown-cygwin
 	exit 0 ;;
@@ -826,9 +830,18 @@
     cris:Linux:*:*)
 	echo cris-axis-linux-gnu
 	exit 0 ;;
+    crisv32:Linux:*:*)
+	echo crisv32-axis-linux-gnu
+	exit 0 ;;
+    frv:Linux:*:*)
+    	echo frv-unknown-linux-gnu
+	exit 0 ;;
     ia64:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
     m68*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
@@ -905,7 +918,7 @@
 	echo ${UNAME_MACHINE}-ibm-linux
 	exit 0 ;;
     sh64*:Linux:*:*)
-	echo ${UNAME_MACHINE}-unknown-linux-gnu
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit 0 ;;
     sh*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -997,7 +1010,7 @@
     i*86:atheos:*:*)
 	echo ${UNAME_MACHINE}-unknown-atheos
 	exit 0 ;;
-    i*86:syllable:*:*)
+	i*86:syllable:*:*)
 	echo ${UNAME_MACHINE}-pc-syllable
 	exit 0 ;;
     i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
@@ -1069,9 +1082,9 @@
     M680?0:D-NIX:5.3:*)
 	echo m68k-diab-dnix
 	exit 0 ;;
-    M68*:*:R3V[567]*:*)
+    M68*:*:R3V[5678]*:*)
 	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
-    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
 	OS_REL=''
 	test -r /etc/.relid \
 	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -1169,9 +1182,10 @@
 	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
 	exit 0 ;;
     *:Darwin:*:*)
-	case `uname -p` in
+	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+	case $UNAME_PROCESSOR in
 	    *86) UNAME_PROCESSOR=i686 ;;
-	    powerpc) UNAME_PROCESSOR=powerpc ;;
+	    unknown) UNAME_PROCESSOR=powerpc ;;
 	esac
 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 	exit 0 ;;
@@ -1186,6 +1200,9 @@
     *:QNX:*:4*)
 	echo i386-pc-qnx
 	exit 0 ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+	echo nse-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
     NSR-?:NONSTOP_KERNEL:*:*)
 	echo nsr-tandem-nsk${UNAME_RELEASE}
 	exit 0 ;;
@@ -1228,10 +1245,20 @@
 	echo pdp10-unknown-its
 	exit 0 ;;
     SEI:*:*:SEIUX)
-	echo mips-sei-seiux${UNAME_RELEASE}
+        echo mips-sei-seiux${UNAME_RELEASE}
+	exit 0 ;;
+    *:DragonFly:*:*)
+	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit 0 ;;
-    *:DRAGONFLY:*:*)
-	echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE}
+    *:*VMS:*:*)
+    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	case "${UNAME_MACHINE}" in
+	    A*) echo alpha-dec-vms && exit 0 ;;
+	    I*) echo ia64-dec-vms && exit 0 ;;
+	    V*) echo vax-dec-vms && exit 0 ;;
+	esac ;;
+    *:XENIX:*:SysV)
+	echo i386-pc-xenix
 	exit 0 ;;
 esac
 
@@ -1392,7 +1419,9 @@
 the operating system you are using. It is advised that you
 download the most up to date version of the config scripts from
 
-    ftp://ftp.gnu.org/pub/gnu/config/
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
 
 If the version you run ($0) is already up to date, please
 send the following data and any information you think might be
diff -Naur ncurses-5.4.orig/config.sub ncurses-5.4/config.sub
--- ncurses-5.4.orig/config.sub	2004-01-07 01:00:46.000000000 +0000
+++ ncurses-5.4/config.sub	2005-05-13 04:09:56.000000000 +0000
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
-timestamp='2004-01-05'
+timestamp='2005-02-10'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -70,7 +70,7 @@
 version="\
 GNU config.sub ($timestamp)
 
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
@@ -145,7 +145,7 @@
 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-	-apple | -axis)
+	-apple | -axis | -knuth | -cray)
 		os=
 		basic_machine=$1
 		;;
@@ -237,7 +237,7 @@
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| i370 | i860 | i960 | ia64 \
 	| ip2k | iq2000 \
-	| m32r | m68000 | m68k | m88k | mcore \
+	| m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
 	| mips | mipsbe | mipseb | mipsel | mipsle \
 	| mips16 \
 	| mips64 | mips64el \
@@ -262,12 +262,12 @@
 	| pyramid \
 	| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
 	| sh64 | sh64le \
-	| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
+	| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \
 	| strongarm \
 	| tahoe | thumb | tic4x | tic80 | tron \
 	| v850 | v850e \
 	| we32k \
-	| x86 | xscale | xstormy16 | xtensa \
+	| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
 	| z8k)
 		basic_machine=$basic_machine-unknown
 		;;
@@ -283,8 +283,8 @@
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
 	i*86 | x86_64)
-		basic_machine=$basic_machine-pc
-		;;
+	  basic_machine=$basic_machine-pc
+	  ;;
 	# Object if more than one company name word.
 	*-*-*)
 		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
@@ -300,7 +300,7 @@
 	| avr-* \
 	| bs2000-* \
 	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
-	| clipper-* | cydra-* \
+	| clipper-* | craynv-* | cydra-* \
 	| d10v-* | d30v-* | dlx-* \
 	| elxsi-* \
 	| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
@@ -308,9 +308,9 @@
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| i*86-* | i860-* | i960-* | ia64-* \
 	| ip2k-* | iq2000-* \
-	| m32r-* \
+	| m32r-* | m32rle-* \
 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
-	| m88110-* | m88k-* | mcore-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* \
 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
 	| mips16-* \
 	| mips64-* | mips64el-* \
@@ -326,8 +326,9 @@
 	| mipsisa64sb1-* | mipsisa64sb1el-* \
 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
 	| mipstx39-* | mipstx39el-* \
+	| mmix-* \
 	| msp430-* \
-	| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
@@ -336,14 +337,14 @@
 	| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
-	| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
 	| tahoe-* | thumb-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
 	| tron-* \
 	| v850-* | v850e-* | vax-* \
 	| we32k-* \
-	| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
-	| xtensa-* \
+	| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| xstormy16-* | xtensa-* \
 	| ymp-* \
 	| z8k-*)
 		;;
@@ -363,6 +364,9 @@
 		basic_machine=a29k-amd
 		os=-udi
 		;;
+    	abacus)
+		basic_machine=abacus-unknown
+		;;
 	adobe68k)
 		basic_machine=m68010-adobe
 		os=-scout
@@ -442,12 +446,27 @@
 		basic_machine=j90-cray
 		os=-unicos
 		;;
+	craynv)
+		basic_machine=craynv-cray
+		os=-unicosmp
+		;;
+	cr16c)
+		basic_machine=cr16c-unknown
+		os=-elf
+		;;
 	crds | unos)
 		basic_machine=m68k-crds
 		;;
+	crisv32 | crisv32-* | etraxfs*)
+		basic_machine=crisv32-axis
+		;;
 	cris | cris-* | etrax*)
 		basic_machine=cris-axis
 		;;
+	crx)
+		basic_machine=crx-unknown
+		os=-elf
+		;;
 	da30 | da30-*)
 		basic_machine=m68k-da30
 		;;
@@ -470,6 +489,10 @@
 		basic_machine=m88k-motorola
 		os=-sysv3
 		;;
+	djgpp)
+		basic_machine=i586-pc
+		os=-msdosdjgpp
+		;;
 	dpx20 | dpx20-*)
 		basic_machine=rs6000-bull
 		os=-bosx
@@ -648,10 +671,6 @@
 	mips3*)
 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
 		;;
-	mmix*)
-		basic_machine=mmix-knuth
-		os=-mmixware
-		;;
 	monitor)
 		basic_machine=m68k-rom68k
 		os=-coff
@@ -732,10 +751,6 @@
 	np1)
 		basic_machine=np1-gould
 		;;
-	nv1)
-		basic_machine=nv1-cray
-		os=-unicosmp
-		;;
 	nsr-tandem)
 		basic_machine=nsr-tandem
 		;;
@@ -1018,6 +1033,10 @@
 		basic_machine=hppa1.1-winbond
 		os=-proelf
 		;;
+	xbox)
+		basic_machine=i686-pc
+		os=-mingw32
+		;;
 	xps | xps100)
 		basic_machine=xps100-honeywell
 		;;
@@ -1048,6 +1067,9 @@
 	romp)
 		basic_machine=romp-ibm
 		;;
+	mmix)
+		basic_machine=mmix-knuth
+		;;
 	rs6000)
 		basic_machine=rs6000-ibm
 		;;
@@ -1070,7 +1092,7 @@
 	sh64)
 		basic_machine=sh64-unknown
 		;;
-	sparc | sparcv9 | sparcv9b)
+	sparc | sparcv8 | sparcv9 | sparcv9b)
 		basic_machine=sparc-sun
 		;;
 	cydra)
@@ -1114,8 +1136,8 @@
 if [ x"$os" != x"" ]
 then
 case $os in
-	# First match some system type aliases
-	# that might get confused with valid system types.
+        # First match some system type aliases
+        # that might get confused with valid system types.
 	# -solaris* is a basic system type, with this one exception.
 	-solaris1 | -solaris1.*)
 		os=`echo $os | sed -e 's|solaris1|sunos4|'`
@@ -1143,8 +1165,9 @@
 	      | -aos* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-	      | -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
-	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
+	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* \
@@ -1194,7 +1217,7 @@
 	-opened*)
 		os=-openedition
 		;;
-	-os400*)
+        -os400*)
 		os=-os400
 		;;
 	-wince*)
@@ -1243,7 +1266,7 @@
 	-sinix*)
 		os=-sysv4
 		;;
-	-tpf*)
+        -tpf*)
 		os=-tpf
 		;;
 	-triton*)
@@ -1282,6 +1305,9 @@
 	-kaos*)
 		os=-kaos
 		;;
+	-zvmoe)
+		os=-zvmoe
+		;;
 	-none)
 		;;
 	*)
@@ -1313,9 +1339,9 @@
 	arm*-semi)
 		os=-aout
 		;;
-	c4x-* | tic4x-*)
-		os=-coff
-		;;
+    c4x-* | tic4x-*)
+        os=-coff
+        ;;
 	# This must come before the *-dec entry.
 	pdp10-*)
 		os=-tops20
@@ -1362,6 +1388,9 @@
 	*-ibm)
 		os=-aix
 		;;
+    	*-knuth)
+		os=-mmixware
+		;;
 	*-wec)
 		os=-proelf
 		;;
diff -Naur ncurses-5.4.orig/configure ncurses-5.4/configure
--- ncurses-5.4.orig/configure	2004-02-01 01:03:42.000000000 +0000
+++ ncurses-5.4/configure	2005-05-13 04:09:58.000000000 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 1.312 .
+# From configure.in Revision: 1.337 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by Autoconf 2.52.20030208.
 #
@@ -666,6 +666,7 @@
   --with-install-prefix   prefixes actual install-location ($DESTDIR)
 Build-Tools Needed to Compile Temporary Applications for Cross-compiling:
   --with-build-cc=XXX     the build C compiler ($BUILD_CC)
+  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)
   --with-build-cflags=XXX the build C compiler-flags
   --with-build-cppflags=XXX the build C preprocessor-flags
   --with-build-ldflags=XXX the build linker-flags
@@ -677,8 +678,8 @@
   --with-debug            generate debug-libraries (default)
   --with-profile          generate profile-libraries
   --with-termlib          generate separate terminfo library
-  --with-dbmalloc         test: use Conor Cahill's dbmalloc library
-  --with-dmalloc          test: use Gray Watson's dmalloc library
+  --with-dbmalloc         use Conor Cahill's dbmalloc library
+  --with-dmalloc          use Gray Watson's dmalloc library
   --with-gpm              use Alessandro Rubini's GPM library
   --with-sysmouse         use sysmouse (FreeBSD console)
   --enable-rpath          use rpath option when generating shared libraries
@@ -688,6 +689,7 @@
   --disable-database      do not use terminfo, only fallbacks/termcap
   --with-database=XXX     specify terminfo source to install
   --with-fallbacks=XXX    specify list of fallback terminal descriptions
+  --without-xterm-new     specify if xterm terminfo should be old version
   --with-terminfo-dirs=XXX specify list of terminfo directories (default: DATADIR/terminfo)
   --with-default-terminfo-dir=DIR default terminfo directory (default: DATADIR/terminfo)
   --disable-big-core      assume machine has little memory
@@ -696,9 +698,15 @@
   --enable-getcap         fast termcap load, no xrefs to terminfo
   --enable-getcap-cache   cache translated termcaps in ~/.terminfo
   --disable-home-terminfo drop ~/.terminfo from terminfo search-path
+  --disable-root-environ  limit environment when running as root
   --enable-symlinks       make tic use symbolic links not hard links
   --enable-broken_linker  compile with broken-linker support code
+  --enable-widec          compile with wide-char/UTF-8 code
+  --disable-lp64          allow chtype to be long (ignore _LP64)
+  --enable-largefile      compile-in large file support
+  --disable-largefile     omit support for large files
   --with-bool=TYPE        override fallback type of bool variable
+  --with-caps=alt         compile with alternate Caps file
   --with-ospeed=TYPE      override type of ospeed variable
   --enable-bsdpad         recognize BSD-style prefix padding
   --with-rcs-ids          compile-in RCS identifiers
@@ -718,16 +726,15 @@
 Development Code:
   --with-develop          enable all development options
   --enable-hard-tabs      compile with hard-tabs code
-  --disable-root-environ  limit environment when running as root
   --enable-xmc-glitch     compile with limited support for xmc
 Experimental Code:
   --disable-assumed-color do not assume anything about default-colors
   --disable-hashmap       compile without hashmap scrolling-optimization
   --enable-colorfgbg      compile with $COLORFGBG code
+  --enable-ext-colors     compile for experimental 256-color support
+  --enable-ext-mouse      compile for experimental mouse-encoding
   --enable-safe-sprintf   compile with experimental safe-sprintf code
   --disable-scroll-hints  compile without scroll-hints code
-  --enable-widec          compile with experimental wide-char/UTF-8 code
-  --with-caps=alt         compile with experimental alternate Caps file
 Testing/development Options:
   --enable-echo           build: display "compiling" commands (default)
   --enable-warnings       build: turn on GCC compiler warnings
@@ -936,7 +943,7 @@
 fi
 for ac_site_file in $CONFIG_SITE; do
   if test -r "$ac_site_file"; then
-    { echo "$as_me:939: loading site script $ac_site_file" >&5
+    { echo "$as_me:946: loading site script $ac_site_file" >&5
 echo "$as_me: loading site script $ac_site_file" >&6;}
     cat "$ac_site_file" >&5
     . "$ac_site_file"
@@ -947,7 +954,7 @@
   # Some versions of bash will fail to source /dev/null (special
   # files actually), so we avoid doing that.
   if test -f "$cache_file"; then
-    { echo "$as_me:950: loading cache $cache_file" >&5
+    { echo "$as_me:957: loading cache $cache_file" >&5
 echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
       [\\/]* | ?:[\\/]* ) . $cache_file;;
@@ -955,7 +962,7 @@
     esac
   fi
 else
-  { echo "$as_me:958: creating cache $cache_file" >&5
+  { echo "$as_me:965: creating cache $cache_file" >&5
 echo "$as_me: creating cache $cache_file" >&6;}
   >$cache_file
 fi
@@ -971,21 +978,21 @@
   eval ac_new_val="\$ac_env_${ac_var}_value"
   case $ac_old_set,$ac_new_set in
     set,)
-      { echo "$as_me:974: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+      { echo "$as_me:981: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,set)
-      { echo "$as_me:978: error: \`$ac_var' was not set in the previous run" >&5
+      { echo "$as_me:985: error: \`$ac_var' was not set in the previous run" >&5
 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
       ac_cache_corrupted=: ;;
     ,);;
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
-        { echo "$as_me:984: error: \`$ac_var' has changed since the previous run:" >&5
+        { echo "$as_me:991: error: \`$ac_var' has changed since the previous run:" >&5
 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-        { echo "$as_me:986:   former value:  $ac_old_val" >&5
+        { echo "$as_me:993:   former value:  $ac_old_val" >&5
 echo "$as_me:   former value:  $ac_old_val" >&2;}
-        { echo "$as_me:988:   current value: $ac_new_val" >&5
+        { echo "$as_me:995:   current value: $ac_new_val" >&5
 echo "$as_me:   current value: $ac_new_val" >&2;}
         ac_cache_corrupted=:
       fi;;
@@ -1004,9 +1011,9 @@
   fi
 done
 if $ac_cache_corrupted; then
-  { echo "$as_me:1007: error: changes in the environment can compromise the build" >&5
+  { echo "$as_me:1014: error: changes in the environment can compromise the build" >&5
 echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  { { echo "$as_me:1009: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+  { { echo "$as_me:1016: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1026,10 +1033,10 @@
 echo "#! $SHELL" >conftest.sh
 echo  "exit 0"   >>conftest.sh
 chmod +x conftest.sh
-if { (echo "$as_me:1029: PATH=\".;.\"; conftest.sh") >&5
+if { (echo "$as_me:1036: PATH=\".;.\"; conftest.sh") >&5
   (PATH=".;."; conftest.sh) 2>&5
   ac_status=$?
-  echo "$as_me:1032: \$? = $ac_status" >&5
+  echo "$as_me:1039: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   ac_path_separator=';'
 else
@@ -1046,7 +1053,7 @@
 cf_cv_abi_version=${NCURSES_MAJOR}
 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
 cf_cv_timestamp=`date`
-echo "$as_me:1049: result: Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp)" >&5
+echo "$as_me:1056: result: Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp)" >&5
 echo "${ECHO_T}Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp)" >&6
 
 test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
@@ -1054,7 +1061,7 @@
 # Check whether --with-rel-version or --without-rel-version was given.
 if test "${with_rel_version+set}" = set; then
   withval="$with_rel_version"
-  { echo "$as_me:1057: WARNING: overriding release version $cf_cv_rel_version to $withval" >&5
+  { echo "$as_me:1064: WARNING: overriding release version $cf_cv_rel_version to $withval" >&5
 echo "$as_me: WARNING: overriding release version $cf_cv_rel_version to $withval" >&2;}
  cf_cv_rel_version=$withval
 fi;
@@ -1067,13 +1074,13 @@
   [0-9]*) #(vi
  	;;
   *)
-	{ { echo "$as_me:1070: error: Release major-version is not a number: $NCURSES_MAJOR" >&5
+	{ { echo "$as_me:1077: error: Release major-version is not a number: $NCURSES_MAJOR" >&5
 echo "$as_me: error: Release major-version is not a number: $NCURSES_MAJOR" >&2;}
    { (exit 1); exit 1; }; }
  	;;
   esac
 else
-  { { echo "$as_me:1076: error: Release major-version value is empty" >&5
+  { { echo "$as_me:1083: error: Release major-version value is empty" >&5
 echo "$as_me: error: Release major-version value is empty" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1083,13 +1090,13 @@
   [0-9]*) #(vi
  	;;
   *)
-	{ { echo "$as_me:1086: error: Release minor-version is not a number: $NCURSES_MINOR" >&5
+	{ { echo "$as_me:1093: error: Release minor-version is not a number: $NCURSES_MINOR" >&5
 echo "$as_me: error: Release minor-version is not a number: $NCURSES_MINOR" >&2;}
    { (exit 1); exit 1; }; }
  	;;
   esac
 else
-  { { echo "$as_me:1092: error: Release minor-version value is empty" >&5
+  { { echo "$as_me:1099: error: Release minor-version value is empty" >&5
 echo "$as_me: error: Release minor-version value is empty" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1099,7 +1106,7 @@
 # Check whether --with-abi-version or --without-abi-version was given.
 if test "${with_abi_version+set}" = set; then
   withval="$with_abi_version"
-  { echo "$as_me:1102: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&5
+  { echo "$as_me:1109: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&5
 echo "$as_me: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&2;}
  cf_cv_abi_version=$withval
 fi;
@@ -1109,13 +1116,13 @@
   [0-9]*) #(vi
  	;;
   *)
-	{ { echo "$as_me:1112: error: ABI version is not a number: $cf_cv_abi_version" >&5
+	{ { echo "$as_me:1119: error: ABI version is not a number: $cf_cv_abi_version" >&5
 echo "$as_me: error: ABI version is not a number: $cf_cv_abi_version" >&2;}
    { (exit 1); exit 1; }; }
  	;;
   esac
 else
-  { { echo "$as_me:1118: error: ABI version value is empty" >&5
+  { { echo "$as_me:1125: error: ABI version value is empty" >&5
 echo "$as_me: error: ABI version value is empty" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1137,7 +1144,7 @@
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:1140: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+  { { echo "$as_me:1147: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1147,11 +1154,11 @@
 
 # Make sure we can run config.sub.
 $ac_config_sub sun4 >/dev/null 2>&1 ||
-  { { echo "$as_me:1150: error: cannot run $ac_config_sub" >&5
+  { { echo "$as_me:1157: error: cannot run $ac_config_sub" >&5
 echo "$as_me: error: cannot run $ac_config_sub" >&2;}
    { (exit 1); exit 1; }; }
 
-echo "$as_me:1154: checking build system type" >&5
+echo "$as_me:1161: checking build system type" >&5
 echo $ECHO_N "checking build system type... $ECHO_C" >&6
 if test "${ac_cv_build+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1160,23 +1167,23 @@
 test -z "$ac_cv_build_alias" &&
   ac_cv_build_alias=`$ac_config_guess`
 test -z "$ac_cv_build_alias" &&
-  { { echo "$as_me:1163: error: cannot guess build type; you must specify one" >&5
+  { { echo "$as_me:1170: error: cannot guess build type; you must specify one" >&5
 echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
    { (exit 1); exit 1; }; }
 ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
-  { { echo "$as_me:1167: error: $ac_config_sub $ac_cv_build_alias failed." >&5
+  { { echo "$as_me:1174: error: $ac_config_sub $ac_cv_build_alias failed." >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1172: result: $ac_cv_build" >&5
+echo "$as_me:1179: result: $ac_cv_build" >&5
 echo "${ECHO_T}$ac_cv_build" >&6
 build=$ac_cv_build
 build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
-echo "$as_me:1179: checking host system type" >&5
+echo "$as_me:1186: checking host system type" >&5
 echo $ECHO_N "checking host system type... $ECHO_C" >&6
 if test "${ac_cv_host+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1185,20 +1192,20 @@
 test -z "$ac_cv_host_alias" &&
   ac_cv_host_alias=$ac_cv_build_alias
 ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
-  { { echo "$as_me:1188: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+  { { echo "$as_me:1195: error: $ac_config_sub $ac_cv_host_alias failed" >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1193: result: $ac_cv_host" >&5
+echo "$as_me:1200: result: $ac_cv_host" >&5
 echo "${ECHO_T}$ac_cv_host" >&6
 host=$ac_cv_host
 host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
 host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
 
-if test -f $srcdir/config.guess ; then
-	echo "$as_me:1201: checking target system type" >&5
+if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
+	echo "$as_me:1208: checking target system type" >&5
 echo $ECHO_N "checking target system type... $ECHO_C" >&6
 if test "${ac_cv_target+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1207,12 +1214,12 @@
 test "x$ac_cv_target_alias" = "x" &&
   ac_cv_target_alias=$ac_cv_host_alias
 ac_cv_target=`$ac_config_sub $ac_cv_target_alias` ||
-  { { echo "$as_me:1210: error: $ac_config_sub $ac_cv_target_alias failed" >&5
+  { { echo "$as_me:1217: error: $ac_config_sub $ac_cv_target_alias failed" >&5
 echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:1215: result: $ac_cv_target" >&5
+echo "$as_me:1222: result: $ac_cv_target" >&5
 echo "${ECHO_T}$ac_cv_target" >&6
 target=$ac_cv_target
 target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
@@ -1243,13 +1250,13 @@
 fi
 
 test -z "$system_name" && system_name="$cf_cv_system_name"
-test -n "$cf_cv_system_name" && echo "$as_me:1246: result: Configuring for $cf_cv_system_name" >&5
+test -n "$cf_cv_system_name" && echo "$as_me:1253: result: Configuring for $cf_cv_system_name" >&5
 echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6
 
 if test ".$system_name" != ".$cf_cv_system_name" ; then
-	echo "$as_me:1250: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
+	echo "$as_me:1257: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
 echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6
-	{ { echo "$as_me:1252: error: \"Please remove config.cache and try again.\"" >&5
+	{ { echo "$as_me:1259: error: \"Please remove config.cache and try again.\"" >&5
 echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -1257,7 +1264,7 @@
 # Check whether --with-system-type or --without-system-type was given.
 if test "${with_system_type+set}" = set; then
   withval="$with_system_type"
-  { echo "$as_me:1260: WARNING: overriding system type to $withval" >&5
+  { echo "$as_me:1267: WARNING: overriding system type to $withval" >&5
 echo "$as_me: WARNING: overriding system type to $withval" >&2;}
  cf_cv_system_name=$withval
 fi;
@@ -1267,7 +1274,7 @@
 
 ###	Default install-location
 
-echo "$as_me:1270: checking for prefix" >&5
+echo "$as_me:1277: checking for prefix" >&5
 echo $ECHO_N "checking for prefix... $ECHO_C" >&6
 if test "x$prefix" = "xNONE" ; then
 	case "$cf_cv_system_name" in
@@ -1279,11 +1286,11 @@
 		;;
 	esac
 fi
-echo "$as_me:1282: result: $prefix" >&5
+echo "$as_me:1289: result: $prefix" >&5
 echo "${ECHO_T}$prefix" >&6
 
 if test "x$prefix" = "xNONE" ; then
-echo "$as_me:1286: checking for default include-directory" >&5
+echo "$as_me:1293: checking for default include-directory" >&5
 echo $ECHO_N "checking for default include-directory... $ECHO_C" >&6
 test -n "$verbose" && echo 1>&6
 for cf_symbol in \
@@ -1306,7 +1313,7 @@
 	fi
 	test -n "$verbose"  && echo "	tested $cf_dir" 1>&6
 done
-echo "$as_me:1309: result: $includedir" >&5
+echo "$as_me:1316: result: $includedir" >&5
 echo "${ECHO_T}$includedir" >&6
 fi
 
@@ -1319,7 +1326,7 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:1322: checking for $ac_word" >&5
+echo "$as_me:1329: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1334,7 +1341,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="${ac_tool_prefix}gcc"
-echo "$as_me:1337: found $ac_dir/$ac_word" >&5
+echo "$as_me:1344: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1342,10 +1349,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1345: result: $CC" >&5
+  echo "$as_me:1352: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1348: result: no" >&5
+  echo "$as_me:1355: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1354,7 +1361,7 @@
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-echo "$as_me:1357: checking for $ac_word" >&5
+echo "$as_me:1364: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1369,7 +1376,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="gcc"
-echo "$as_me:1372: found $ac_dir/$ac_word" >&5
+echo "$as_me:1379: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1377,10 +1384,10 @@
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1380: result: $ac_ct_CC" >&5
+  echo "$as_me:1387: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1383: result: no" >&5
+  echo "$as_me:1390: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1393,7 +1400,7 @@
   if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:1396: checking for $ac_word" >&5
+echo "$as_me:1403: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1408,7 +1415,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="${ac_tool_prefix}cc"
-echo "$as_me:1411: found $ac_dir/$ac_word" >&5
+echo "$as_me:1418: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1416,10 +1423,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1419: result: $CC" >&5
+  echo "$as_me:1426: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1422: result: no" >&5
+  echo "$as_me:1429: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1428,7 +1435,7 @@
   ac_ct_CC=$CC
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:1431: checking for $ac_word" >&5
+echo "$as_me:1438: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1443,7 +1450,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="cc"
-echo "$as_me:1446: found $ac_dir/$ac_word" >&5
+echo "$as_me:1453: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1451,10 +1458,10 @@
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1454: result: $ac_ct_CC" >&5
+  echo "$as_me:1461: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1457: result: no" >&5
+  echo "$as_me:1464: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1467,7 +1474,7 @@
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:1470: checking for $ac_word" >&5
+echo "$as_me:1477: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1487,7 +1494,7 @@
   continue
 fi
 ac_cv_prog_CC="cc"
-echo "$as_me:1490: found $ac_dir/$ac_word" >&5
+echo "$as_me:1497: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1509,10 +1516,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1512: result: $CC" >&5
+  echo "$as_me:1519: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1515: result: no" >&5
+  echo "$as_me:1522: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1523,7 +1530,7 @@
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:1526: checking for $ac_word" >&5
+echo "$as_me:1533: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1538,7 +1545,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-echo "$as_me:1541: found $ac_dir/$ac_word" >&5
+echo "$as_me:1548: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1546,10 +1553,10 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:1549: result: $CC" >&5
+  echo "$as_me:1556: result: $CC" >&5
 echo "${ECHO_T}$CC" >&6
 else
-  echo "$as_me:1552: result: no" >&5
+  echo "$as_me:1559: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1562,7 +1569,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:1565: checking for $ac_word" >&5
+echo "$as_me:1572: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -1577,7 +1584,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CC="$ac_prog"
-echo "$as_me:1580: found $ac_dir/$ac_word" >&5
+echo "$as_me:1587: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -1585,10 +1592,10 @@
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:1588: result: $ac_ct_CC" >&5
+  echo "$as_me:1595: result: $ac_ct_CC" >&5
 echo "${ECHO_T}$ac_ct_CC" >&6
 else
-  echo "$as_me:1591: result: no" >&5
+  echo "$as_me:1598: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -1600,32 +1607,32 @@
 
 fi
 
-test -z "$CC" && { { echo "$as_me:1603: error: no acceptable cc found in \$PATH" >&5
+test -z "$CC" && { { echo "$as_me:1610: error: no acceptable cc found in \$PATH" >&5
 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
    { (exit 1); exit 1; }; }
 
 # Provide some information about the compiler.
-echo "$as_me:1608:" \
+echo "$as_me:1615:" \
      "checking for C compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:1611: \"$ac_compiler --version </dev/null >&5\"") >&5
+{ (eval echo "$as_me:1618: \"$ac_compiler --version </dev/null >&5\"") >&5
   (eval $ac_compiler --version </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1614: \$? = $ac_status" >&5
+  echo "$as_me:1621: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:1616: \"$ac_compiler -v </dev/null >&5\"") >&5
+{ (eval echo "$as_me:1623: \"$ac_compiler -v </dev/null >&5\"") >&5
   (eval $ac_compiler -v </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1619: \$? = $ac_status" >&5
+  echo "$as_me:1626: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:1621: \"$ac_compiler -V </dev/null >&5\"") >&5
+{ (eval echo "$as_me:1628: \"$ac_compiler -V </dev/null >&5\"") >&5
   (eval $ac_compiler -V </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:1624: \$? = $ac_status" >&5
+  echo "$as_me:1631: \$? = $ac_status" >&5
   (exit $ac_status); }
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 1628 "configure"
+#line 1635 "configure"
 #include "confdefs.h"
 
 int
@@ -1641,13 +1648,13 @@
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-echo "$as_me:1644: checking for C compiler default output" >&5
+echo "$as_me:1651: checking for C compiler default output" >&5
 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:1647: \"$ac_link_default\"") >&5
+if { (eval echo "$as_me:1654: \"$ac_link_default\"") >&5
   (eval $ac_link_default) 2>&5
   ac_status=$?
-  echo "$as_me:1650: \$? = $ac_status" >&5
+  echo "$as_me:1657: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   # Find the output, starting from the most likely.  This scheme is
 # not robust to junk in `.', hence go to wildcards (a.*) only as a last
@@ -1670,34 +1677,34 @@
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-{ { echo "$as_me:1673: error: C compiler cannot create executables" >&5
+{ { echo "$as_me:1680: error: C compiler cannot create executables" >&5
 echo "$as_me: error: C compiler cannot create executables" >&2;}
    { (exit 77); exit 77; }; }
 fi
 
 ac_exeext=$ac_cv_exeext
-echo "$as_me:1679: result: $ac_file" >&5
+echo "$as_me:1686: result: $ac_file" >&5
 echo "${ECHO_T}$ac_file" >&6
 
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1684: checking whether the C compiler works" >&5
+echo "$as_me:1691: checking whether the C compiler works" >&5
 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
 # If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
   if { ac_try='./$ac_file'
-  { (eval echo "$as_me:1690: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1697: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1693: \$? = $ac_status" >&5
+  echo "$as_me:1700: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
     cross_compiling=no
   else
     if test "$cross_compiling" = maybe; then
 	cross_compiling=yes
     else
-	{ { echo "$as_me:1700: error: cannot run C compiled programs.
+	{ { echo "$as_me:1707: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'." >&5
 echo "$as_me: error: cannot run C compiled programs.
 If you meant to cross compile, use \`--host'." >&2;}
@@ -1705,24 +1712,24 @@
     fi
   fi
 fi
-echo "$as_me:1708: result: yes" >&5
+echo "$as_me:1715: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
 rm -f a.out a.exe conftest$ac_cv_exeext
 ac_clean_files=$ac_clean_files_save
 # Check the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:1715: checking whether we are cross compiling" >&5
+echo "$as_me:1722: checking whether we are cross compiling" >&5
 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:1717: result: $cross_compiling" >&5
+echo "$as_me:1724: result: $cross_compiling" >&5
 echo "${ECHO_T}$cross_compiling" >&6
 
-echo "$as_me:1720: checking for executable suffix" >&5
+echo "$as_me:1727: checking for executable suffix" >&5
 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
-if { (eval echo "$as_me:1722: \"$ac_link\"") >&5
+if { (eval echo "$as_me:1729: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:1725: \$? = $ac_status" >&5
+  echo "$as_me:1732: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   # If both `conftest.exe' and `conftest' are `present' (well, observable)
 # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
@@ -1738,25 +1745,25 @@
   esac
 done
 else
-  { { echo "$as_me:1741: error: cannot compute EXEEXT: cannot compile and link" >&5
+  { { echo "$as_me:1748: error: cannot compute EXEEXT: cannot compile and link" >&5
 echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 rm -f conftest$ac_cv_exeext
-echo "$as_me:1747: result: $ac_cv_exeext" >&5
+echo "$as_me:1754: result: $ac_cv_exeext" >&5
 echo "${ECHO_T}$ac_cv_exeext" >&6
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
-echo "$as_me:1753: checking for object suffix" >&5
+echo "$as_me:1760: checking for object suffix" >&5
 echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
 if test "${ac_cv_objext+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 1759 "configure"
+#line 1766 "configure"
 #include "confdefs.h"
 
 int
@@ -1768,10 +1775,10 @@
 }
 _ACEOF
 rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:1771: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1778: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1774: \$? = $ac_status" >&5
+  echo "$as_me:1781: \$? = $ac_status" >&5
   (exit $ac_status); }; then
   for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
   case $ac_file in
@@ -1783,24 +1790,24 @@
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-{ { echo "$as_me:1786: error: cannot compute OBJEXT: cannot compile" >&5
+{ { echo "$as_me:1793: error: cannot compute OBJEXT: cannot compile" >&5
 echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
    { (exit 1); exit 1; }; }
 fi
 
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
-echo "$as_me:1793: result: $ac_cv_objext" >&5
+echo "$as_me:1800: result: $ac_cv_objext" >&5
 echo "${ECHO_T}$ac_cv_objext" >&6
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-echo "$as_me:1797: checking whether we are using the GNU C compiler" >&5
+echo "$as_me:1804: checking whether we are using the GNU C compiler" >&5
 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
 if test "${ac_cv_c_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 1803 "configure"
+#line 1810 "configure"
 #include "confdefs.h"
 
 int
@@ -1815,16 +1822,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1818: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1825: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1821: \$? = $ac_status" >&5
+  echo "$as_me:1828: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1824: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1831: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1827: \$? = $ac_status" >&5
+  echo "$as_me:1834: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_compiler_gnu=yes
 else
@@ -1836,19 +1843,19 @@
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:1839: result: $ac_cv_c_compiler_gnu" >&5
+echo "$as_me:1846: result: $ac_cv_c_compiler_gnu" >&5
 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
 GCC=`test $ac_compiler_gnu = yes && echo yes`
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
 CFLAGS="-g"
-echo "$as_me:1845: checking whether $CC accepts -g" >&5
+echo "$as_me:1852: checking whether $CC accepts -g" >&5
 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_g+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 1851 "configure"
+#line 1858 "configure"
 #include "confdefs.h"
 
 int
@@ -1860,16 +1867,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1863: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1870: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1866: \$? = $ac_status" >&5
+  echo "$as_me:1873: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1869: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1876: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1872: \$? = $ac_status" >&5
+  echo "$as_me:1879: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_prog_cc_g=yes
 else
@@ -1879,7 +1886,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:1882: result: $ac_cv_prog_cc_g" >&5
+echo "$as_me:1889: result: $ac_cv_prog_cc_g" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
 if test "$ac_test_CFLAGS" = set; then
   CFLAGS=$ac_save_CFLAGS
@@ -1906,16 +1913,16 @@
 #endif
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1909: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1916: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1912: \$? = $ac_status" >&5
+  echo "$as_me:1919: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1915: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1922: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1918: \$? = $ac_status" >&5
+  echo "$as_me:1925: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   for ac_declaration in \
    ''\
@@ -1927,7 +1934,7 @@
    'void exit (int);'
 do
   cat >conftest.$ac_ext <<_ACEOF
-#line 1930 "configure"
+#line 1937 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 $ac_declaration
@@ -1940,16 +1947,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1943: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1950: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1946: \$? = $ac_status" >&5
+  echo "$as_me:1953: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1949: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1956: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1952: \$? = $ac_status" >&5
+  echo "$as_me:1959: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -1959,7 +1966,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
   cat >conftest.$ac_ext <<_ACEOF
-#line 1962 "configure"
+#line 1969 "configure"
 #include "confdefs.h"
 $ac_declaration
 int
@@ -1971,16 +1978,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:1974: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:1981: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:1977: \$? = $ac_status" >&5
+  echo "$as_me:1984: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:1980: \"$ac_try\"") >&5
+  { (eval echo "$as_me:1987: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:1983: \$? = $ac_status" >&5
+  echo "$as_me:1990: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   break
 else
@@ -2009,11 +2016,11 @@
 
 GCC_VERSION=none
 if test "$GCC" = yes ; then
-	echo "$as_me:2012: checking version of $CC" >&5
+	echo "$as_me:2019: checking version of $CC" >&5
 echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
 	GCC_VERSION="`${CC} --version|sed -e '2,$d' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
 	test -z "$GCC_VERSION" && GCC_VERSION=unknown
-	echo "$as_me:2016: result: $GCC_VERSION" >&5
+	echo "$as_me:2023: result: $GCC_VERSION" >&5
 echo "${ECHO_T}$GCC_VERSION" >&6
 fi
 
@@ -2022,7 +2029,7 @@
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:2025: checking how to run the C preprocessor" >&5
+echo "$as_me:2032: checking how to run the C preprocessor" >&5
 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
@@ -2043,18 +2050,18 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >conftest.$ac_ext <<_ACEOF
-#line 2046 "configure"
+#line 2053 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:2051: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:2058: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2057: \$? = $ac_status" >&5
+  echo "$as_me:2064: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2077,17 +2084,17 @@
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
-#line 2080 "configure"
+#line 2087 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:2084: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:2091: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2090: \$? = $ac_status" >&5
+  echo "$as_me:2097: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2124,7 +2131,7 @@
 else
   ac_cv_prog_CPP=$CPP
 fi
-echo "$as_me:2127: result: $CPP" >&5
+echo "$as_me:2134: result: $CPP" >&5
 echo "${ECHO_T}$CPP" >&6
 ac_preproc_ok=false
 for ac_c_preproc_warn_flag in '' yes
@@ -2134,18 +2141,18 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >conftest.$ac_ext <<_ACEOF
-#line 2137 "configure"
+#line 2144 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:2142: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:2149: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2148: \$? = $ac_status" >&5
+  echo "$as_me:2155: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2168,17 +2175,17 @@
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
-#line 2171 "configure"
+#line 2178 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:2175: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:2182: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:2181: \$? = $ac_status" >&5
+  echo "$as_me:2188: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -2206,7 +2213,7 @@
 if $ac_preproc_ok; then
   :
 else
-  { { echo "$as_me:2209: error: C preprocessor \"$CPP\" fails sanity check" >&5
+  { { echo "$as_me:2216: error: C preprocessor \"$CPP\" fails sanity check" >&5
 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -2218,14 +2225,14 @@
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 if test $ac_cv_c_compiler_gnu = yes; then
-    echo "$as_me:2221: checking whether $CC needs -traditional" >&5
+    echo "$as_me:2228: checking whether $CC needs -traditional" >&5
 echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6
 if test "${ac_cv_prog_gcc_traditional+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
     ac_pattern="Autoconf.*'x'"
   cat >conftest.$ac_ext <<_ACEOF
-#line 2228 "configure"
+#line 2235 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 int Autoconf = TIOCGETP;
@@ -2240,7 +2247,7 @@
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat >conftest.$ac_ext <<_ACEOF
-#line 2243 "configure"
+#line 2250 "configure"
 #include "confdefs.h"
 #include <termio.h>
 int Autoconf = TCGETA;
@@ -2253,19 +2260,61 @@
 
   fi
 fi
-echo "$as_me:2256: result: $ac_cv_prog_gcc_traditional" >&5
+echo "$as_me:2263: result: $ac_cv_prog_gcc_traditional" >&5
 echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6
   if test $ac_cv_prog_gcc_traditional = yes; then
     CC="$CC -traditional"
   fi
 fi
 
-echo "$as_me:2263: checking for POSIXized ISC" >&5
+echo "$as_me:2270: checking whether $CC understands -c and -o together" >&5
+echo $ECHO_N "checking whether $CC understands -c and -o together... $ECHO_C" >&6
+if test "${cf_cv_prog_CC_c_o+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat > conftest.$ac_ext <<CF_EOF
+#include <stdio.h>
+int main()
+{
+	return 0;
+}
+CF_EOF
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+if { (eval echo "$as_me:2286: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2289: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+  test -f conftest2.$ac_objext && { (eval echo "$as_me:2291: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:2294: \$? = $ac_status" >&5
+  (exit $ac_status); };
+then
+  eval cf_cv_prog_CC_c_o=yes
+else
+  eval cf_cv_prog_CC_c_o=no
+fi
+rm -f conftest*
+
+fi
+if test $cf_cv_prog_CC_c_o = yes; then
+  echo "$as_me:2305: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me:2308: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+echo "$as_me:2312: checking for POSIXized ISC" >&5
 echo $ECHO_N "checking for POSIXized ISC... $ECHO_C" >&6
 if test -d /etc/conf/kconfig.d &&
    grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
 then
-  echo "$as_me:2268: result: yes" >&5
+  echo "$as_me:2317: result: yes" >&5
 echo "${ECHO_T}yes" >&6
   ISC=yes # If later tests want to check for ISC.
 
@@ -2279,12 +2328,12 @@
     CC="$CC -Xp"
   fi
 else
-  echo "$as_me:2282: result: no" >&5
+  echo "$as_me:2331: result: no" >&5
 echo "${ECHO_T}no" >&6
   ISC=
 fi
 
-echo "$as_me:2287: checking for ${CC-cc} option to accept ANSI C" >&5
+echo "$as_me:2336: checking for ${CC-cc} option to accept ANSI C" >&5
 echo $ECHO_N "checking for ${CC-cc} option to accept ANSI C... $ECHO_C" >&6
 if test "${cf_cv_ansi_cc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2309,12 +2358,34 @@
 	-Xc
 do
 
+cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
+cf_new_extra_cppflags=
+
 for cf_add_cflags in $cf_arg
 do
+case $cf_fix_cppflags in
+no)
 	case $cf_add_cflags in #(vi
 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+		case $cf_add_cflags in
+		-D*)
+			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+			&& test -z "${cf_tst_cflags}" \
+			&& cf_fix_cppflags=yes
+
+			if test $cf_fix_cppflags = yes ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			fi
+			;;
+		esac
 		case "$CPPFLAGS" in
 		*$cf_add_cflags) #(vi
 			;;
@@ -2327,6 +2398,17 @@
 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
 		;;
 	esac
+	;;
+yes)
+	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+	&& test -z "${cf_tst_cflags}" \
+	&& cf_fix_cppflags=no
+	;;
+esac
 done
 
 if test -n "$cf_new_cflags" ; then
@@ -2339,8 +2421,13 @@
 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
 fi
 
+if test -n "$cf_new_extra_cppflags" ; then
+
+	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
 	cat >conftest.$ac_ext <<_ACEOF
-#line 2343 "configure"
+#line 2430 "configure"
 #include "confdefs.h"
 
 #ifndef CC_HAS_PROTOS
@@ -2361,16 +2448,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2364: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2451: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2367: \$? = $ac_status" >&5
+  echo "$as_me:2454: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2370: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2457: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2373: \$? = $ac_status" >&5
+  echo "$as_me:2460: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_ansi_cc="$cf_arg"; break
 else
@@ -2383,18 +2470,40 @@
 CPPFLAGS="$cf_save_CPPFLAGS"
 
 fi
-echo "$as_me:2386: result: $cf_cv_ansi_cc" >&5
+echo "$as_me:2473: result: $cf_cv_ansi_cc" >&5
 echo "${ECHO_T}$cf_cv_ansi_cc" >&6
 
 if test "$cf_cv_ansi_cc" != "no"; then
 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
 
+cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
+cf_new_extra_cppflags=
+
 for cf_add_cflags in $cf_cv_ansi_cc
 do
+case $cf_fix_cppflags in
+no)
 	case $cf_add_cflags in #(vi
 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+		case $cf_add_cflags in
+		-D*)
+			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+			&& test -z "${cf_tst_cflags}" \
+			&& cf_fix_cppflags=yes
+
+			if test $cf_fix_cppflags = yes ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			fi
+			;;
+		esac
 		case "$CPPFLAGS" in
 		*$cf_add_cflags) #(vi
 			;;
@@ -2407,6 +2516,17 @@
 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
 		;;
 	esac
+	;;
+yes)
+	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+	&& test -z "${cf_tst_cflags}" \
+	&& cf_fix_cppflags=no
+	;;
+esac
 done
 
 if test -n "$cf_new_cflags" ; then
@@ -2419,6 +2539,11 @@
 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
 fi
 
+if test -n "$cf_new_extra_cppflags" ; then
+
+	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
 else
 	cat >>confdefs.h <<\EOF
 #define CC_HAS_PROTOS 1
@@ -2428,7 +2553,7 @@
 fi
 
 if test "$cf_cv_ansi_cc" = "no"; then
-	{ { echo "$as_me:2431: error: Your compiler does not appear to recognize prototypes.
+	{ { echo "$as_me:2556: error: Your compiler does not appear to recognize prototypes.
 You have the following choices:
 	a. adjust your compiler options
 	b. get an up-to-date compiler
@@ -2468,7 +2593,7 @@
 *) LDPATH=$PATH:/sbin:/usr/sbin
   # Extract the first word of "ldconfig", so it can be a program name with args.
 set dummy ldconfig; ac_word=$2
-echo "$as_me:2471: checking for $ac_word" >&5
+echo "$as_me:2596: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_LDCONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2485,7 +2610,7 @@
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_LDCONFIG="$ac_dir/$ac_word"
-   echo "$as_me:2488: found $ac_dir/$ac_word" >&5
+   echo "$as_me:2613: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -2496,10 +2621,10 @@
 LDCONFIG=$ac_cv_path_LDCONFIG
 
 if test -n "$LDCONFIG"; then
-  echo "$as_me:2499: result: $LDCONFIG" >&5
+  echo "$as_me:2624: result: $LDCONFIG" >&5
 echo "${ECHO_T}$LDCONFIG" >&6
 else
-  echo "$as_me:2502: result: no" >&5
+  echo "$as_me:2627: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2507,7 +2632,7 @@
 esac
 fi
 
-echo "$as_me:2510: checking if you want to ensure bool is consistent with C++" >&5
+echo "$as_me:2635: checking if you want to ensure bool is consistent with C++" >&5
 echo $ECHO_N "checking if you want to ensure bool is consistent with C++... $ECHO_C" >&6
 
 # Check whether --with-cxx or --without-cxx was given.
@@ -2517,7 +2642,7 @@
 else
   cf_with_cxx=yes
 fi;
-echo "$as_me:2520: result: $cf_with_cxx" >&5
+echo "$as_me:2645: result: $cf_with_cxx" >&5
 echo "${ECHO_T}$cf_with_cxx" >&6
 if test "X$cf_with_cxx" = Xno ; then
 	CXX=""
@@ -2534,7 +2659,7 @@
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:2537: checking for $ac_word" >&5
+echo "$as_me:2662: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2549,7 +2674,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
-echo "$as_me:2552: found $ac_dir/$ac_word" >&5
+echo "$as_me:2677: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2557,10 +2682,10 @@
 fi
 CXX=$ac_cv_prog_CXX
 if test -n "$CXX"; then
-  echo "$as_me:2560: result: $CXX" >&5
+  echo "$as_me:2685: result: $CXX" >&5
 echo "${ECHO_T}$CXX" >&6
 else
-  echo "$as_me:2563: result: no" >&5
+  echo "$as_me:2688: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2573,7 +2698,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2576: checking for $ac_word" >&5
+echo "$as_me:2701: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2588,7 +2713,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_CXX="$ac_prog"
-echo "$as_me:2591: found $ac_dir/$ac_word" >&5
+echo "$as_me:2716: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2596,10 +2721,10 @@
 fi
 ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
 if test -n "$ac_ct_CXX"; then
-  echo "$as_me:2599: result: $ac_ct_CXX" >&5
+  echo "$as_me:2724: result: $ac_ct_CXX" >&5
 echo "${ECHO_T}$ac_ct_CXX" >&6
 else
-  echo "$as_me:2602: result: no" >&5
+  echo "$as_me:2727: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -2611,32 +2736,32 @@
 fi
 
 # Provide some information about the compiler.
-echo "$as_me:2614:" \
+echo "$as_me:2739:" \
      "checking for C++ compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:2617: \"$ac_compiler --version </dev/null >&5\"") >&5
+{ (eval echo "$as_me:2742: \"$ac_compiler --version </dev/null >&5\"") >&5
   (eval $ac_compiler --version </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:2620: \$? = $ac_status" >&5
+  echo "$as_me:2745: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:2622: \"$ac_compiler -v </dev/null >&5\"") >&5
+{ (eval echo "$as_me:2747: \"$ac_compiler -v </dev/null >&5\"") >&5
   (eval $ac_compiler -v </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:2625: \$? = $ac_status" >&5
+  echo "$as_me:2750: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:2627: \"$ac_compiler -V </dev/null >&5\"") >&5
+{ (eval echo "$as_me:2752: \"$ac_compiler -V </dev/null >&5\"") >&5
   (eval $ac_compiler -V </dev/null >&5) 2>&5
   ac_status=$?
-  echo "$as_me:2630: \$? = $ac_status" >&5
+  echo "$as_me:2755: \$? = $ac_status" >&5
   (exit $ac_status); }
 
-echo "$as_me:2633: checking whether we are using the GNU C++ compiler" >&5
+echo "$as_me:2758: checking whether we are using the GNU C++ compiler" >&5
 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 2639 "configure"
+#line 2764 "configure"
 #include "confdefs.h"
 
 int
@@ -2651,16 +2776,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2654: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2779: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2657: \$? = $ac_status" >&5
+  echo "$as_me:2782: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2660: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2785: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2663: \$? = $ac_status" >&5
+  echo "$as_me:2788: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_compiler_gnu=yes
 else
@@ -2672,19 +2797,19 @@
 ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:2675: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "$as_me:2800: result: $ac_cv_cxx_compiler_gnu" >&5
 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
 GXX=`test $ac_compiler_gnu = yes && echo yes`
 ac_test_CXXFLAGS=${CXXFLAGS+set}
 ac_save_CXXFLAGS=$CXXFLAGS
 CXXFLAGS="-g"
-echo "$as_me:2681: checking whether $CXX accepts -g" >&5
+echo "$as_me:2806: checking whether $CXX accepts -g" >&5
 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
 if test "${ac_cv_prog_cxx_g+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 2687 "configure"
+#line 2812 "configure"
 #include "confdefs.h"
 
 int
@@ -2696,16 +2821,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2699: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2824: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2702: \$? = $ac_status" >&5
+  echo "$as_me:2827: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2705: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2830: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2708: \$? = $ac_status" >&5
+  echo "$as_me:2833: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_prog_cxx_g=yes
 else
@@ -2715,7 +2840,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:2718: result: $ac_cv_prog_cxx_g" >&5
+echo "$as_me:2843: result: $ac_cv_prog_cxx_g" >&5
 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
 if test "$ac_test_CXXFLAGS" = set; then
   CXXFLAGS=$ac_save_CXXFLAGS
@@ -2742,7 +2867,7 @@
    'void exit (int);'
 do
   cat >conftest.$ac_ext <<_ACEOF
-#line 2745 "configure"
+#line 2870 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 $ac_declaration
@@ -2755,16 +2880,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2758: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2883: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2761: \$? = $ac_status" >&5
+  echo "$as_me:2886: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2764: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2889: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2767: \$? = $ac_status" >&5
+  echo "$as_me:2892: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -2774,7 +2899,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
   cat >conftest.$ac_ext <<_ACEOF
-#line 2777 "configure"
+#line 2902 "configure"
 #include "confdefs.h"
 $ac_declaration
 int
@@ -2786,16 +2911,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:2789: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:2914: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:2792: \$? = $ac_status" >&5
+  echo "$as_me:2917: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:2795: \"$ac_try\"") >&5
+  { (eval echo "$as_me:2920: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:2798: \$? = $ac_status" >&5
+  echo "$as_me:2923: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   break
 else
@@ -2821,7 +2946,7 @@
 	if test "$CXX" = "g++" ; then
 		# Extract the first word of "g++", so it can be a program name with args.
 set dummy g++; ac_word=$2
-echo "$as_me:2824: checking for $ac_word" >&5
+echo "$as_me:2949: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2838,7 +2963,7 @@
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_CXX="$ac_dir/$ac_word"
-   echo "$as_me:2841: found $ac_dir/$ac_word" >&5
+   echo "$as_me:2966: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -2849,16 +2974,16 @@
 CXX=$ac_cv_path_CXX
 
 if test -n "$CXX"; then
-  echo "$as_me:2852: result: $CXX" >&5
+  echo "$as_me:2977: result: $CXX" >&5
 echo "${ECHO_T}$CXX" >&6
 else
-  echo "$as_me:2855: result: no" >&5
+  echo "$as_me:2980: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
 	fi
 	if test "$CXX" = "g++" ; then
-		{ echo "$as_me:2861: WARNING: ignoring hardcoded g++" >&5
+		{ echo "$as_me:2986: WARNING: ignoring hardcoded g++" >&5
 echo "$as_me: WARNING: ignoring hardcoded g++" >&2;}
 		cf_with_cxx=no; CXX=""; GXX="";
 	fi
@@ -2866,10 +2991,10 @@
 
 GXX_VERSION=none
 if test "$GXX" = yes; then
-	echo "$as_me:2869: checking version of g++" >&5
+	echo "$as_me:2994: checking version of g++" >&5
 echo $ECHO_N "checking version of g++... $ECHO_C" >&6
 	GXX_VERSION="`${CXX-g++} --version|sed -e '2,$d'`"
-	echo "$as_me:2872: result: $GXX_VERSION" >&5
+	echo "$as_me:2997: result: $GXX_VERSION" >&5
 echo "${ECHO_T}$GXX_VERSION" >&6
 fi
 
@@ -2877,12 +3002,12 @@
 1*|2.[0-6]*)
 	GXX=""; CXX=""; ac_cv_cxx_compiler_gnu=no
 	cf_cxx_library=no
-	{ echo "$as_me:2880: WARNING: templates do not work" >&5
+	{ echo "$as_me:3005: WARNING: templates do not work" >&5
 echo "$as_me: WARNING: templates do not work" >&2;}
 	;;
 esac
 
-echo "$as_me:2885: checking if you want to build C++ binding and demo" >&5
+echo "$as_me:3010: checking if you want to build C++ binding and demo" >&5
 echo $ECHO_N "checking if you want to build C++ binding and demo... $ECHO_C" >&6
 
 # Check whether --with-cxx-binding or --without-cxx-binding was given.
@@ -2892,10 +3017,10 @@
 else
   cf_with_cxx_binding=$cf_with_cxx
 fi;
-echo "$as_me:2895: result: $cf_with_cxx_binding" >&5
+echo "$as_me:3020: result: $cf_with_cxx_binding" >&5
 echo "${ECHO_T}$cf_with_cxx_binding" >&6
 
-echo "$as_me:2898: checking if you want to build with Ada95" >&5
+echo "$as_me:3023: checking if you want to build with Ada95" >&5
 echo $ECHO_N "checking if you want to build with Ada95... $ECHO_C" >&6
 
 # Check whether --with-ada or --without-ada was given.
@@ -2905,10 +3030,10 @@
 else
   cf_with_ada=yes
 fi;
-echo "$as_me:2908: result: $cf_with_ada" >&5
+echo "$as_me:3033: result: $cf_with_ada" >&5
 echo "${ECHO_T}$cf_with_ada" >&6
 
-echo "$as_me:2911: checking if you want to build programs such as tic" >&5
+echo "$as_me:3036: checking if you want to build programs such as tic" >&5
 echo $ECHO_N "checking if you want to build programs such as tic... $ECHO_C" >&6
 
 # Check whether --with-progs or --without-progs was given.
@@ -2918,10 +3043,10 @@
 else
   cf_with_progs=yes
 fi;
-echo "$as_me:2921: result: $cf_with_progs" >&5
+echo "$as_me:3046: result: $cf_with_progs" >&5
 echo "${ECHO_T}$cf_with_progs" >&6
 
-echo "$as_me:2924: checking if you wish to install curses.h" >&5
+echo "$as_me:3049: checking if you wish to install curses.h" >&5
 echo $ECHO_N "checking if you wish to install curses.h... $ECHO_C" >&6
 
 # Check whether --with-curses-h or --without-curses-h was given.
@@ -2931,7 +3056,7 @@
 else
   with_curses_h=yes
 fi;
-echo "$as_me:2934: result: $with_curses_h" >&5
+echo "$as_me:3059: result: $with_curses_h" >&5
 echo "${ECHO_T}$with_curses_h" >&6
 
 modules_to_build="ncurses"
@@ -2957,7 +3082,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:2960: checking for $ac_word" >&5
+echo "$as_me:3085: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_AWK+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -2972,7 +3097,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_AWK="$ac_prog"
-echo "$as_me:2975: found $ac_dir/$ac_word" >&5
+echo "$as_me:3100: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -2980,17 +3105,17 @@
 fi
 AWK=$ac_cv_prog_AWK
 if test -n "$AWK"; then
-  echo "$as_me:2983: result: $AWK" >&5
+  echo "$as_me:3108: result: $AWK" >&5
 echo "${ECHO_T}$AWK" >&6
 else
-  echo "$as_me:2986: result: no" >&5
+  echo "$as_me:3111: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
   test -n "$AWK" && break
 done
 
-echo "$as_me:2993: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "$as_me:3118: checking whether ${MAKE-make} sets \${MAKE}" >&5
 echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
 if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
@@ -3010,11 +3135,11 @@
 rm -f conftest.make
 fi
 if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$as_me:3013: result: yes" >&5
+  echo "$as_me:3138: result: yes" >&5
 echo "${ECHO_T}yes" >&6
   SET_MAKE=
 else
-  echo "$as_me:3017: result: no" >&5
+  echo "$as_me:3142: result: no" >&5
 echo "${ECHO_T}no" >&6
   SET_MAKE="MAKE=${MAKE-make}"
 fi
@@ -3031,7 +3156,7 @@
 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:3034: checking for a BSD compatible install" >&5
+echo "$as_me:3159: checking for a BSD compatible install" >&5
 echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
 if test -z "$INSTALL"; then
 if test "${ac_cv_path_install+set}" = set; then
@@ -3080,7 +3205,7 @@
     INSTALL=$ac_install_sh
   fi
 fi
-echo "$as_me:3083: result: $INSTALL" >&5
+echo "$as_me:3208: result: $INSTALL" >&5
 echo "${ECHO_T}$INSTALL" >&6
 
 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
@@ -3101,7 +3226,7 @@
   ;;
 esac
 
-echo "$as_me:3104: checking for long file names" >&5
+echo "$as_me:3229: checking for long file names" >&5
 echo $ECHO_N "checking for long file names... $ECHO_C" >&6
 if test "${ac_cv_sys_long_file_names+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3140,7 +3265,7 @@
   rm -rf $ac_xdir 2>/dev/null
 done
 fi
-echo "$as_me:3143: result: $ac_cv_sys_long_file_names" >&5
+echo "$as_me:3268: result: $ac_cv_sys_long_file_names" >&5
 echo "${ECHO_T}$ac_cv_sys_long_file_names" >&6
 if test $ac_cv_sys_long_file_names = yes; then
 
@@ -3150,7 +3275,7 @@
 
 fi
 
-echo "$as_me:3153: checking if filesystem supports mixed-case filenames" >&5
+echo "$as_me:3278: checking if filesystem supports mixed-case filenames" >&5
 echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6
 if test "${cf_cv_mixedcase+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3177,26 +3302,26 @@
 fi
 
 fi
-echo "$as_me:3180: result: $cf_cv_mixedcase" >&5
+echo "$as_me:3305: result: $cf_cv_mixedcase" >&5
 echo "${ECHO_T}$cf_cv_mixedcase" >&6
 test "$cf_cv_mixedcase" = yes && cat >>confdefs.h <<\EOF
 #define MIXEDCASE_FILENAMES 1
 EOF
 
-echo "$as_me:3186: checking whether ln -s works" >&5
+echo "$as_me:3311: checking whether ln -s works" >&5
 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
 LN_S=$as_ln_s
 if test "$LN_S" = "ln -s"; then
-  echo "$as_me:3190: result: yes" >&5
+  echo "$as_me:3315: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 else
-  echo "$as_me:3193: result: no, using $LN_S" >&5
+  echo "$as_me:3318: result: no, using $LN_S" >&5
 echo "${ECHO_T}no, using $LN_S" >&6
 fi
 
 # Extract the first word of "ctags", so it can be a program name with args.
 set dummy ctags; ac_word=$2
-echo "$as_me:3199: checking for $ac_word" >&5
+echo "$as_me:3324: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3211,7 +3336,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_MAKE_LOWER_TAGS="yes"
-echo "$as_me:3214: found $ac_dir/$ac_word" >&5
+echo "$as_me:3339: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3220,17 +3345,17 @@
 fi
 MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS
 if test -n "$MAKE_LOWER_TAGS"; then
-  echo "$as_me:3223: result: $MAKE_LOWER_TAGS" >&5
+  echo "$as_me:3348: result: $MAKE_LOWER_TAGS" >&5
 echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6
 else
-  echo "$as_me:3226: result: no" >&5
+  echo "$as_me:3351: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
 if test "$cf_cv_mixedcase" = yes ; then
 	# Extract the first word of "etags", so it can be a program name with args.
 set dummy etags; ac_word=$2
-echo "$as_me:3233: checking for $ac_word" >&5
+echo "$as_me:3358: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3245,7 +3370,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_MAKE_UPPER_TAGS="yes"
-echo "$as_me:3248: found $ac_dir/$ac_word" >&5
+echo "$as_me:3373: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3254,10 +3379,10 @@
 fi
 MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS
 if test -n "$MAKE_UPPER_TAGS"; then
-  echo "$as_me:3257: result: $MAKE_UPPER_TAGS" >&5
+  echo "$as_me:3382: result: $MAKE_UPPER_TAGS" >&5
 echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6
 else
-  echo "$as_me:3260: result: no" >&5
+  echo "$as_me:3385: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3281,7 +3406,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:3284: checking for $ac_word" >&5
+echo "$as_me:3409: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_LINT+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3296,7 +3421,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_LINT="$ac_prog"
-echo "$as_me:3299: found $ac_dir/$ac_word" >&5
+echo "$as_me:3424: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3304,10 +3429,10 @@
 fi
 LINT=$ac_cv_prog_LINT
 if test -n "$LINT"; then
-  echo "$as_me:3307: result: $LINT" >&5
+  echo "$as_me:3432: result: $LINT" >&5
 echo "${ECHO_T}$LINT" >&6
 else
-  echo "$as_me:3310: result: no" >&5
+  echo "$as_me:3435: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3318,7 +3443,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:3321: checking for $ac_word" >&5
+echo "$as_me:3446: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_MAN+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3333,7 +3458,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_MAN="$ac_prog"
-echo "$as_me:3336: found $ac_dir/$ac_word" >&5
+echo "$as_me:3461: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3341,10 +3466,10 @@
 fi
 MAN=$ac_cv_prog_MAN
 if test -n "$MAN"; then
-  echo "$as_me:3344: result: $MAN" >&5
+  echo "$as_me:3469: result: $MAN" >&5
 echo "${ECHO_T}$MAN" >&6
 else
-  echo "$as_me:3347: result: no" >&5
+  echo "$as_me:3472: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3354,7 +3479,7 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:3357: checking for $ac_word" >&5
+echo "$as_me:3482: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_RANLIB+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3369,7 +3494,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-echo "$as_me:3372: found $ac_dir/$ac_word" >&5
+echo "$as_me:3497: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3377,10 +3502,10 @@
 fi
 RANLIB=$ac_cv_prog_RANLIB
 if test -n "$RANLIB"; then
-  echo "$as_me:3380: result: $RANLIB" >&5
+  echo "$as_me:3505: result: $RANLIB" >&5
 echo "${ECHO_T}$RANLIB" >&6
 else
-  echo "$as_me:3383: result: no" >&5
+  echo "$as_me:3508: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3389,7 +3514,7 @@
   ac_ct_RANLIB=$RANLIB
   # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
-echo "$as_me:3392: checking for $ac_word" >&5
+echo "$as_me:3517: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3404,7 +3529,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_RANLIB="ranlib"
-echo "$as_me:3407: found $ac_dir/$ac_word" >&5
+echo "$as_me:3532: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3413,10 +3538,10 @@
 fi
 ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
 if test -n "$ac_ct_RANLIB"; then
-  echo "$as_me:3416: result: $ac_ct_RANLIB" >&5
+  echo "$as_me:3541: result: $ac_ct_RANLIB" >&5
 echo "${ECHO_T}$ac_ct_RANLIB" >&6
 else
-  echo "$as_me:3419: result: no" >&5
+  echo "$as_me:3544: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3428,7 +3553,7 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ld; ac_word=$2
-echo "$as_me:3431: checking for $ac_word" >&5
+echo "$as_me:3556: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_LD+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3443,7 +3568,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_LD="${ac_tool_prefix}ld"
-echo "$as_me:3446: found $ac_dir/$ac_word" >&5
+echo "$as_me:3571: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3451,10 +3576,10 @@
 fi
 LD=$ac_cv_prog_LD
 if test -n "$LD"; then
-  echo "$as_me:3454: result: $LD" >&5
+  echo "$as_me:3579: result: $LD" >&5
 echo "${ECHO_T}$LD" >&6
 else
-  echo "$as_me:3457: result: no" >&5
+  echo "$as_me:3582: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3463,7 +3588,7 @@
   ac_ct_LD=$LD
   # Extract the first word of "ld", so it can be a program name with args.
 set dummy ld; ac_word=$2
-echo "$as_me:3466: checking for $ac_word" >&5
+echo "$as_me:3591: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_LD+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3478,7 +3603,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_LD="ld"
-echo "$as_me:3481: found $ac_dir/$ac_word" >&5
+echo "$as_me:3606: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3487,10 +3612,10 @@
 fi
 ac_ct_LD=$ac_cv_prog_ac_ct_LD
 if test -n "$ac_ct_LD"; then
-  echo "$as_me:3490: result: $ac_ct_LD" >&5
+  echo "$as_me:3615: result: $ac_ct_LD" >&5
 echo "${ECHO_T}$ac_ct_LD" >&6
 else
-  echo "$as_me:3493: result: no" >&5
+  echo "$as_me:3618: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3502,7 +3627,7 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
-echo "$as_me:3505: checking for $ac_word" >&5
+echo "$as_me:3630: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_AR+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3517,7 +3642,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_AR="${ac_tool_prefix}ar"
-echo "$as_me:3520: found $ac_dir/$ac_word" >&5
+echo "$as_me:3645: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3525,10 +3650,10 @@
 fi
 AR=$ac_cv_prog_AR
 if test -n "$AR"; then
-  echo "$as_me:3528: result: $AR" >&5
+  echo "$as_me:3653: result: $AR" >&5
 echo "${ECHO_T}$AR" >&6
 else
-  echo "$as_me:3531: result: no" >&5
+  echo "$as_me:3656: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3537,7 +3662,7 @@
   ac_ct_AR=$AR
   # Extract the first word of "ar", so it can be a program name with args.
 set dummy ar; ac_word=$2
-echo "$as_me:3540: checking for $ac_word" >&5
+echo "$as_me:3665: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3552,7 +3677,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_ac_ct_AR="ar"
-echo "$as_me:3555: found $ac_dir/$ac_word" >&5
+echo "$as_me:3680: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3561,10 +3686,10 @@
 fi
 ac_ct_AR=$ac_cv_prog_ac_ct_AR
 if test -n "$ac_ct_AR"; then
-  echo "$as_me:3564: result: $ac_ct_AR" >&5
+  echo "$as_me:3689: result: $ac_ct_AR" >&5
 echo "${ECHO_T}$ac_ct_AR" >&6
 else
-  echo "$as_me:3567: result: no" >&5
+  echo "$as_me:3692: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3577,10 +3702,10 @@
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
-echo "$as_me:3580: checking for archiver options (symbol AR_OPTS)" >&5
+echo "$as_me:3705: checking for archiver options (symbol AR_OPTS)" >&5
 echo $ECHO_N "checking for archiver options (symbol AR_OPTS)... $ECHO_C" >&6
 test -z "$AR_OPTS" && AR_OPTS=rv
-echo "$as_me:3583: result: $AR_OPTS" >&5
+echo "$as_me:3708: result: $AR_OPTS" >&5
 echo "${ECHO_T}$AR_OPTS" >&6
 
 cf_cv_subst_AR_OPTS=$AR_OPTS
@@ -3588,7 +3713,7 @@
 
 AR_OPTS=${cf_cv_subst_AR_OPTS}
 
-echo "$as_me:3591: checking for makeflags variable" >&5
+echo "$as_me:3716: checking for makeflags variable" >&5
 echo $ECHO_N "checking for makeflags variable... $ECHO_C" >&6
 if test "${cf_cv_makeflags+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3621,10 +3746,10 @@
 	rm -f cf_makeflags.tmp
 
 fi
-echo "$as_me:3624: result: $cf_cv_makeflags" >&5
+echo "$as_me:3749: result: $cf_cv_makeflags" >&5
 echo "${ECHO_T}$cf_cv_makeflags" >&6
 
-echo "$as_me:3627: checking if you have specified an install-prefix" >&5
+echo "$as_me:3752: checking if you have specified an install-prefix" >&5
 echo $ECHO_N "checking if you have specified an install-prefix... $ECHO_C" >&6
 
 # Check whether --with-install-prefix or --without-install-prefix was given.
@@ -3637,7 +3762,7 @@
 		;;
 	esac
 fi;
-echo "$as_me:3640: result: $DESTDIR" >&5
+echo "$as_me:3765: result: $DESTDIR" >&5
 echo "${ECHO_T}$DESTDIR" >&6
 
 ###############################################################################
@@ -3645,13 +3770,17 @@
 # If we're cross-compiling, allow the user to override the tools and their
 # options.  The configure script is oriented toward identifying the host
 # compiler, etc., but we need a build compiler to generate parts of the source.
-: ${BUILD_CC:='$(CC)'}
-: ${BUILD_CFLAGS:='$(CFLAGS)'}
-: ${BUILD_CPPFLAGS:='$(CPPFLAGS)'}
-: ${BUILD_LDFLAGS:='$(LDFLAGS)'}
-: ${BUILD_LIBS:='$(LIBS)'}
-: ${BUILD_EXEEXT:='$x'}
+
 if test "$cross_compiling" = yes ; then
+	# defaults that we might want to override
+	: ${BUILD_CC:='$(CC)'}
+	: ${BUILD_CPP:='$(CC) -E'}
+	: ${BUILD_CFLAGS:=''}
+	: ${BUILD_CPPFLAGS:=''}
+	: ${BUILD_LDFLAGS:=''}
+	: ${BUILD_LIBS:=''}
+	: ${BUILD_EXEEXT:='$x'}
+	: ${BUILD_OBJEXT:='o'}
 
 # Check whether --with-build-cc or --without-build-cc was given.
 if test "${with_build_cc+set}" = set; then
@@ -3662,7 +3791,7 @@
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:3665: checking for $ac_word" >&5
+echo "$as_me:3794: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_BUILD_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3677,7 +3806,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_BUILD_CC="$ac_prog"
-echo "$as_me:3680: found $ac_dir/$ac_word" >&5
+echo "$as_me:3809: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -3685,10 +3814,10 @@
 fi
 BUILD_CC=$ac_cv_prog_BUILD_CC
 if test -n "$BUILD_CC"; then
-  echo "$as_me:3688: result: $BUILD_CC" >&5
+  echo "$as_me:3817: result: $BUILD_CC" >&5
 echo "${ECHO_T}$BUILD_CC" >&6
 else
-  echo "$as_me:3691: result: no" >&5
+  echo "$as_me:3820: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -3697,6 +3826,14 @@
 
 fi;
 
+# Check whether --with-build-cpp or --without-build-cpp was given.
+if test "${with_build_cpp+set}" = set; then
+  withval="$with_build_cpp"
+  BUILD_CPP="$withval"
+else
+  BUILD_CPP='$(CC) -E'
+fi;
+
 # Check whether --with-build-cflags or --without-build-cflags was given.
 if test "${with_build_cflags+set}" = set; then
   withval="$with_build_cflags"
@@ -3720,7 +3857,27 @@
   withval="$with_build_libs"
   BUILD_LIBS="$withval"
 fi;
+	# this assumes we're on Unix.
 	BUILD_EXEEXT=
+	BUILD_OBJEXT=o
+
+	if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '$(CC)' ) ; then
+		{ { echo "$as_me:3865: error: Cross-build requires two compilers.
+Use --with-build-cc to specify the native compiler." >&5
+echo "$as_me: error: Cross-build requires two compilers.
+Use --with-build-cc to specify the native compiler." >&2;}
+   { (exit 1); exit 1; }; }
+	fi
+
+else
+	: ${BUILD_CC:='$(CC)'}
+	: ${BUILD_CPP:='$(CPP)'}
+	: ${BUILD_CFLAGS:='$(CFLAGS)'}
+	: ${BUILD_CPPFLAGS:='$(CPPFLAGS)'}
+	: ${BUILD_LDFLAGS:='$(LDFLAGS)'}
+	: ${BUILD_LIBS:='$(LIBS)'}
+	: ${BUILD_EXEEXT:='$x'}
+	: ${BUILD_OBJEXT:='o'}
 fi
 
 ###############################################################################
@@ -3746,7 +3903,7 @@
 LIB_INSTALL=
 LIB_UNINSTALL=
 
-echo "$as_me:3749: checking if you want to build libraries with libtool" >&5
+echo "$as_me:3906: checking if you want to build libraries with libtool" >&5
 echo $ECHO_N "checking if you want to build libraries with libtool... $ECHO_C" >&6
 
 # Check whether --with-libtool or --without-libtool was given.
@@ -3756,7 +3913,7 @@
 else
   with_libtool=no
 fi;
-echo "$as_me:3759: result: $with_libtool" >&5
+echo "$as_me:3916: result: $with_libtool" >&5
 echo "${ECHO_T}$with_libtool" >&6
 if test "$with_libtool" != "no"; then
 
@@ -3781,7 +3938,7 @@
   with_libtool=`echo $with_libtool | sed -e s%NONE%$ac_default_prefix%`
   ;;
 *)
-  { { echo "$as_me:3784: error: expected a pathname, not \"$with_libtool\"" >&5
+  { { echo "$as_me:3941: error: expected a pathname, not \"$with_libtool\"" >&5
 echo "$as_me: error: expected a pathname, not \"$with_libtool\"" >&2;}
    { (exit 1); exit 1; }; }
   ;;
@@ -3791,7 +3948,7 @@
 	else
  		# Extract the first word of "libtool", so it can be a program name with args.
 set dummy libtool; ac_word=$2
-echo "$as_me:3794: checking for $ac_word" >&5
+echo "$as_me:3951: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_path_LIBTOOL+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -3808,7 +3965,7 @@
   test -z "$ac_dir" && ac_dir=.
   if $as_executable_p "$ac_dir/$ac_word"; then
    ac_cv_path_LIBTOOL="$ac_dir/$ac_word"
-   echo "$as_me:3811: found $ac_dir/$ac_word" >&5
+   echo "$as_me:3968: found $ac_dir/$ac_word" >&5
    break
 fi
 done
@@ -3819,16 +3976,16 @@
 LIBTOOL=$ac_cv_path_LIBTOOL
 
 if test -n "$LIBTOOL"; then
-  echo "$as_me:3822: result: $LIBTOOL" >&5
+  echo "$as_me:3979: result: $LIBTOOL" >&5
 echo "${ECHO_T}$LIBTOOL" >&6
 else
-  echo "$as_me:3825: result: no" >&5
+  echo "$as_me:3982: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
  	fi
  	if test -z "$LIBTOOL" ; then
- 		{ { echo "$as_me:3831: error: Cannot find libtool" >&5
+ 		{ { echo "$as_me:3988: error: Cannot find libtool" >&5
 echo "$as_me: error: Cannot find libtool" >&2;}
    { (exit 1); exit 1; }; }
  	fi
@@ -3843,17 +4000,17 @@
 	LIB_PREP=:
 
 	# Show the version of libtool
-	echo "$as_me:3846: checking version of libtool" >&5
+	echo "$as_me:4003: checking version of libtool" >&5
 echo $ECHO_N "checking version of libtool... $ECHO_C" >&6
 
 	# Save the version in a cache variable - this is not entirely a good
 	# thing, but the version string from libtool is very ugly, and for
 	# bug reports it might be useful to have the original string.
 	cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '2,$d' -e 's/([^)]*)//g' -e 's/^[^1-9]*//' -e 's/[^0-9.].*//'`
-	echo "$as_me:3853: result: $cf_cv_libtool_version" >&5
+	echo "$as_me:4010: result: $cf_cv_libtool_version" >&5
 echo "${ECHO_T}$cf_cv_libtool_version" >&6
 	if test -z "$cf_cv_libtool_version" ; then
-		{ { echo "$as_me:3856: error: This is not libtool" >&5
+		{ { echo "$as_me:4013: error: This is not libtool" >&5
 echo "$as_me: error: This is not libtool" >&2;}
    { (exit 1); exit 1; }; }
 	fi
@@ -3880,7 +4037,7 @@
 
 else
 
-echo "$as_me:3883: checking if you want to build shared libraries" >&5
+echo "$as_me:4040: checking if you want to build shared libraries" >&5
 echo $ECHO_N "checking if you want to build shared libraries... $ECHO_C" >&6
 
 # Check whether --with-shared or --without-shared was given.
@@ -3890,11 +4047,11 @@
 else
   with_shared=no
 fi;
-echo "$as_me:3893: result: $with_shared" >&5
+echo "$as_me:4050: result: $with_shared" >&5
 echo "${ECHO_T}$with_shared" >&6
 test "$with_shared" = "yes" && cf_list_models="$cf_list_models shared"
 
-echo "$as_me:3897: checking if you want to build static libraries" >&5
+echo "$as_me:4054: checking if you want to build static libraries" >&5
 echo $ECHO_N "checking if you want to build static libraries... $ECHO_C" >&6
 
 # Check whether --with-normal or --without-normal was given.
@@ -3904,11 +4061,11 @@
 else
   with_normal=yes
 fi;
-echo "$as_me:3907: result: $with_normal" >&5
+echo "$as_me:4064: result: $with_normal" >&5
 echo "${ECHO_T}$with_normal" >&6
 test "$with_normal" = "yes" && cf_list_models="$cf_list_models normal"
 
-echo "$as_me:3911: checking if you want to build debug libraries" >&5
+echo "$as_me:4068: checking if you want to build debug libraries" >&5
 echo $ECHO_N "checking if you want to build debug libraries... $ECHO_C" >&6
 
 # Check whether --with-debug or --without-debug was given.
@@ -3918,11 +4075,11 @@
 else
   with_debug=yes
 fi;
-echo "$as_me:3921: result: $with_debug" >&5
+echo "$as_me:4078: result: $with_debug" >&5
 echo "${ECHO_T}$with_debug" >&6
 test "$with_debug" = "yes" && cf_list_models="$cf_list_models debug"
 
-echo "$as_me:3925: checking if you want to build profiling libraries" >&5
+echo "$as_me:4082: checking if you want to build profiling libraries" >&5
 echo $ECHO_N "checking if you want to build profiling libraries... $ECHO_C" >&6
 
 # Check whether --with-profile or --without-profile was given.
@@ -3932,7 +4089,7 @@
 else
   with_profile=no
 fi;
-echo "$as_me:3935: result: $with_profile" >&5
+echo "$as_me:4092: result: $with_profile" >&5
 echo "${ECHO_T}$with_profile" >&6
 test "$with_profile" = "yes" && cf_list_models="$cf_list_models profile"
 
@@ -3940,19 +4097,19 @@
 
 ###############################################################################
 
-echo "$as_me:3943: checking for specified models" >&5
+echo "$as_me:4100: checking for specified models" >&5
 echo $ECHO_N "checking for specified models... $ECHO_C" >&6
 test -z "$cf_list_models" && cf_list_models=normal
 test "$with_libtool" != "no" && cf_list_models=libtool
-echo "$as_me:3947: result: $cf_list_models" >&5
+echo "$as_me:4104: result: $cf_list_models" >&5
 echo "${ECHO_T}$cf_list_models" >&6
 
 ### Use the first model as the default, and save its suffix for use in building
 ### up test-applications.
-echo "$as_me:3952: checking for default model" >&5
+echo "$as_me:4109: checking for default model" >&5
 echo $ECHO_N "checking for default model... $ECHO_C" >&6
 DFT_LWR_MODEL=`echo "$cf_list_models" | $AWK '{print $1}'`
-echo "$as_me:3955: result: $DFT_LWR_MODEL" >&5
+echo "$as_me:4112: result: $DFT_LWR_MODEL" >&5
 echo "${ECHO_T}$DFT_LWR_MODEL" >&6
 
 DFT_UPR_MODEL=`echo "$DFT_LWR_MODEL" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
@@ -3976,7 +4133,7 @@
 
 ###############################################################################
 
-echo "$as_me:3979: checking if you want to build a separate terminfo library" >&5
+echo "$as_me:4136: checking if you want to build a separate terminfo library" >&5
 echo $ECHO_N "checking if you want to build a separate terminfo library... $ECHO_C" >&6
 
 # Check whether --with-termlib or --without-termlib was given.
@@ -3986,12 +4143,12 @@
 else
   with_termlib=no
 fi;
-echo "$as_me:3989: result: $with_termlib" >&5
+echo "$as_me:4146: result: $with_termlib" >&5
 echo "${ECHO_T}$with_termlib" >&6
 
 ### Checks for special libraries, must be done up-front.
 
-echo "$as_me:3994: checking if you want to link with dbmalloc for testing" >&5
+echo "$as_me:4151: checking if you want to link with dbmalloc for testing" >&5
 echo $ECHO_N "checking if you want to link with dbmalloc for testing... $ECHO_C" >&6
 
 # Check whether --with-dbmalloc or --without-dbmalloc was given.
@@ -4001,11 +4158,49 @@
 else
   with_dbmalloc=no
 fi;
-echo "$as_me:4004: result: $with_dbmalloc" >&5
+echo "$as_me:4161: result: $with_dbmalloc" >&5
 echo "${ECHO_T}$with_dbmalloc" >&6
-if test $with_dbmalloc = yes ; then
+if test "$with_dbmalloc" = yes ; then
+	echo "$as_me:4164: checking for dbmalloc.h" >&5
+echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6
+if test "${ac_cv_header_dbmalloc_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4170 "configure"
+#include "confdefs.h"
+#include <dbmalloc.h>
+_ACEOF
+if { (eval echo "$as_me:4174: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:4180: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_cv_header_dbmalloc_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_header_dbmalloc_h=no
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:4199: result: $ac_cv_header_dbmalloc_h" >&5
+echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6
+if test $ac_cv_header_dbmalloc_h = yes; then
 
-echo "$as_me:4008: checking for debug_malloc in -ldbmalloc" >&5
+echo "$as_me:4203: checking for debug_malloc in -ldbmalloc" >&5
 echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6
 if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4013,7 +4208,7 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldbmalloc  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 4016 "configure"
+#line 4211 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -4032,16 +4227,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4035: \"$ac_link\"") >&5
+if { (eval echo "$as_me:4230: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4038: \$? = $ac_status" >&5
+  echo "$as_me:4233: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:4041: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4236: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4044: \$? = $ac_status" >&5
+  echo "$as_me:4239: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_dbmalloc_debug_malloc=yes
 else
@@ -4052,7 +4247,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:4055: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
+echo "$as_me:4250: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
 echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6
 if test $ac_cv_lib_dbmalloc_debug_malloc = yes; then
   cat >>confdefs.h <<EOF
@@ -4065,7 +4260,9 @@
 
 fi
 
-echo "$as_me:4068: checking if you want to link with dmalloc for testing" >&5
+fi
+
+echo "$as_me:4265: checking if you want to link with dmalloc for testing" >&5
 echo $ECHO_N "checking if you want to link with dmalloc for testing... $ECHO_C" >&6
 
 # Check whether --with-dmalloc or --without-dmalloc was given.
@@ -4075,11 +4272,49 @@
 else
   with_dmalloc=no
 fi;
-echo "$as_me:4078: result: $with_dmalloc" >&5
+echo "$as_me:4275: result: $with_dmalloc" >&5
 echo "${ECHO_T}$with_dmalloc" >&6
-if test $with_dmalloc = yes ; then
+if test "$with_dmalloc" = yes ; then
+	echo "$as_me:4278: checking for dmalloc.h" >&5
+echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6
+if test "${ac_cv_header_dmalloc_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4284 "configure"
+#include "confdefs.h"
+#include <dmalloc.h>
+_ACEOF
+if { (eval echo "$as_me:4288: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  egrep -v '^ *\+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:4294: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_cv_header_dmalloc_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_header_dmalloc_h=no
+fi
+rm -f conftest.err conftest.$ac_ext
+fi
+echo "$as_me:4313: result: $ac_cv_header_dmalloc_h" >&5
+echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6
+if test $ac_cv_header_dmalloc_h = yes; then
 
-echo "$as_me:4082: checking for dmalloc_debug in -ldmalloc" >&5
+echo "$as_me:4317: checking for dmalloc_debug in -ldmalloc" >&5
 echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6
 if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4087,7 +4322,7 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldmalloc  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 4090 "configure"
+#line 4325 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -4106,16 +4341,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4109: \"$ac_link\"") >&5
+if { (eval echo "$as_me:4344: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4112: \$? = $ac_status" >&5
+  echo "$as_me:4347: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:4115: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4350: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4118: \$? = $ac_status" >&5
+  echo "$as_me:4353: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_dmalloc_dmalloc_debug=yes
 else
@@ -4126,7 +4361,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:4129: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
+echo "$as_me:4364: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
 echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6
 if test $ac_cv_lib_dmalloc_dmalloc_debug = yes; then
   cat >>confdefs.h <<EOF
@@ -4139,21 +4374,23 @@
 
 fi
 
+fi
+
 SHLIB_LIST=""
-echo "$as_me:4143: checking if you want to link with the gpm mouse library" >&5
-echo $ECHO_N "checking if you want to link with the gpm mouse library... $ECHO_C" >&6
+echo "$as_me:4380: checking if you want to link with the GPM mouse library" >&5
+echo $ECHO_N "checking if you want to link with the GPM mouse library... $ECHO_C" >&6
 
 # Check whether --with-gpm or --without-gpm was given.
 if test "${with_gpm+set}" = set; then
   withval="$with_gpm"
   with_gpm=$withval
 else
-  with_gpm=no
+  with_gpm=maybe
 fi;
-echo "$as_me:4153: result: $with_gpm" >&5
+echo "$as_me:4390: result: $with_gpm" >&5
 echo "${ECHO_T}$with_gpm" >&6
-if test "$with_gpm" = yes ; then
-	echo "$as_me:4156: checking for Gpm_Open in -lgpm" >&5
+if test "$with_gpm" != no ; then
+	echo "$as_me:4393: checking for Gpm_Open in -lgpm" >&5
 echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6
 if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -4161,7 +4398,7 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lgpm  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 4164 "configure"
+#line 4401 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -4180,16 +4417,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4183: \"$ac_link\"") >&5
+if { (eval echo "$as_me:4420: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4186: \$? = $ac_status" >&5
+  echo "$as_me:4423: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:4189: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4426: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4192: \$? = $ac_status" >&5
+  echo "$as_me:4429: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_gpm_Gpm_Open=yes
 else
@@ -4200,36 +4437,27 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:4203: result: $ac_cv_lib_gpm_Gpm_Open" >&5
+echo "$as_me:4440: result: $ac_cv_lib_gpm_Gpm_Open" >&5
 echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6
 if test $ac_cv_lib_gpm_Gpm_Open = yes; then
 
-		EXTRA_LIBS="-lgpm -lncurses $EXTRA_LIBS"
-		SHLIB_LIST="-lgpm $SHLIB_LIST"
-		cat >>confdefs.h <<\EOF
-#define HAVE_LIBGPM 1
-EOF
-
-for ac_header in gpm.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:4216: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
+		echo "$as_me:4444: checking for gpm.h" >&5
+echo $ECHO_N "checking for gpm.h... $ECHO_C" >&6
+if test "${ac_cv_header_gpm_h+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 4222 "configure"
+#line 4450 "configure"
 #include "confdefs.h"
-#include <$ac_header>
+#include <gpm.h>
 _ACEOF
-if { (eval echo "$as_me:4226: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:4454: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:4232: \$? = $ac_status" >&5
+  echo "$as_me:4460: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -4240,118 +4468,376 @@
   ac_cpp_err=yes
 fi
 if test -z "$ac_cpp_err"; then
-  eval "$as_ac_Header=yes"
+  ac_cv_header_gpm_h=yes
 else
   echo "$as_me: failed program was:" >&5
   cat conftest.$ac_ext >&5
-  eval "$as_ac_Header=no"
+  ac_cv_header_gpm_h=no
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:4251: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+echo "$as_me:4479: result: $ac_cv_header_gpm_h" >&5
+echo "${ECHO_T}$ac_cv_header_gpm_h" >&6
+if test $ac_cv_header_gpm_h = yes; then
+
+			cat >>confdefs.h <<\EOF
+#define HAVE_GPM_H 1
 EOF
 
-fi
-done
+			with_gpm=yes
 
 else
-  { echo "$as_me:4262: WARNING: Cannot link with gpm library - read the FAQ" >&5
-echo "$as_me: WARNING: Cannot link with gpm library - read the FAQ" >&2;}
+
+			if test "$with_gpm" = yes ; then
+				{ { echo "$as_me:4492: error: Cannot find GPM header" >&5
+echo "$as_me: error: Cannot find GPM header" >&2;}
+   { (exit 1); exit 1; }; }
+			fi
+
 fi
 
+else
+
+		if test "$with_gpm" = yes ; then
+			{ { echo "$as_me:4502: error: Cannot link with GPM library" >&5
+echo "$as_me: error: Cannot link with GPM library" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+		with_gpm=no
+
 fi
 
-# not everyone has "test -c"
-if test -c /dev/sysmouse 2>/dev/null ; then
-echo "$as_me:4270: checking if you want to use sysmouse" >&5
-echo $ECHO_N "checking if you want to use sysmouse... $ECHO_C" >&6
+	if test "$with_gpm" = yes ; then
 
-# Check whether --with-sysmouse or --without-sysmouse was given.
-if test "${with_sysmouse+set}" = set; then
-  withval="$with_sysmouse"
-  cf_with_sysmouse=$withval
+cf_have_dlsym=no
+echo "$as_me:4513: checking for dlsym" >&5
+echo $ECHO_N "checking for dlsym... $ECHO_C" >&6
+if test "${ac_cv_func_dlsym+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cf_with_sysmouse=maybe
-fi;
-	if test "$cf_with_sysmouse" != no ; then
-	cat >conftest.$ac_ext <<_ACEOF
-#line 4282 "configure"
+  cat >conftest.$ac_ext <<_ACEOF
+#line 4519 "configure"
 #include "confdefs.h"
-
-#include <osreldate.h>
-#if (__FreeBSD_version >= 400017)
-#include <sys/consio.h>
-#include <sys/fbio.h>
-#else
-#include <machine/console.h>
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char dlsym (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
 #endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlsym ();
+char (*f) ();
 
 int
 main ()
 {
-
-	struct mouse_info the_mouse;
-	ioctl(0, CONS_MOUSECTL, &the_mouse);
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_dlsym) || defined (__stub___dlsym)
+choke me
+#else
+f = dlsym;
+#endif
 
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4305: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4550: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4308: \$? = $ac_status" >&5
+  echo "$as_me:4553: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4311: \"$ac_try\"") >&5
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4556: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4314: \$? = $ac_status" >&5
+  echo "$as_me:4559: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_with_sysmouse=yes
+  ac_cv_func_dlsym=yes
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_with_sysmouse=no
+ac_cv_func_dlsym=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	fi
-echo "$as_me:4324: result: $cf_with_sysmouse" >&5
-echo "${ECHO_T}$cf_with_sysmouse" >&6
-test "$cf_with_sysmouse" = yes && cat >>confdefs.h <<\EOF
-#define USE_SYSMOUSE 1
-EOF
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:4569: result: $ac_cv_func_dlsym" >&5
+echo "${ECHO_T}$ac_cv_func_dlsym" >&6
+if test $ac_cv_func_dlsym = yes; then
+  cf_have_dlsym=yes
+else
+
+cf_have_libdl=no
+echo "$as_me:4576: checking for dlsym in -ldl" >&5
+echo $ECHO_N "checking for dlsym in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlsym+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 4584 "configure"
+#include "confdefs.h"
 
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char dlsym ();
+int
+main ()
+{
+dlsym ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4603: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4606: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4609: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4612: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_dl_dlsym=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_dl_dlsym=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
+echo "$as_me:4623: result: $ac_cv_lib_dl_dlsym" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlsym" >&6
+if test $ac_cv_lib_dl_dlsym = yes; then
 
-if test X"$CC_G_OPT" = X"" ; then
-	CC_G_OPT='-g'
-	test -n "$GCC" && test "${ac_cv_prog_cc_g}" != yes && CC_G_OPT=''
+	cf_have_dlsym=yes
+	cf_have_libdl=yes
 fi
 
-if test X"$CXX_G_OPT" = X"" ; then
-	CXX_G_OPT='-g'
-	test -n "$GXX" && test "${ac_cv_prog_cxx_g}" != yes && CXX_G_OPT=''
 fi
 
-echo "$as_me:4342: checking for default loader flags" >&5
-echo $ECHO_N "checking for default loader flags... $ECHO_C" >&6
-case $DFT_LWR_MODEL in
-libtool) LD_MODEL=''   ;;
-normal)  LD_MODEL=''   ;;
-debug)   LD_MODEL=$CC_G_OPT ;;
-profile) LD_MODEL='-pg';;
-shared)  LD_MODEL=''   ;;
-esac
-echo "$as_me:4351: result: $LD_MODEL" >&5
+if test "$cf_have_dlsym" = yes ; then
+	test "$cf_have_libdl" = yes && LIBS="-ldl $LIBS"
+
+	echo "$as_me:4636: checking whether able to link to dl*() functions" >&5
+echo $ECHO_N "checking whether able to link to dl*() functions... $ECHO_C" >&6
+	cat >conftest.$ac_ext <<_ACEOF
+#line 4639 "configure"
+#include "confdefs.h"
+#include <dlfcn.h>
+int
+main ()
+{
+
+		void *obj;
+		if ((obj = dlopen("filename", 0)) != 0) {
+			if (dlsym(obj, "symbolname") == 0) {
+			dlclose(obj);
+			}
+		}
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4657: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4660: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4663: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4666: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+		cat >>confdefs.h <<\EOF
+#define HAVE_LIBDL 1
+EOF
+
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+
+		{ { echo "$as_me:4677: error: Cannot link test program for libdl" >&5
+echo "$as_me: error: Cannot link test program for libdl" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+	echo "$as_me:4682: result: ok" >&5
+echo "${ECHO_T}ok" >&6
+else
+	{ { echo "$as_me:4685: error: Cannot find dlsym function" >&5
+echo "$as_me: error: Cannot find dlsym function" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+		SHLIB_LIST="-ldl $SHLIB_LIST"
+		cat >>confdefs.h <<\EOF
+#define HAVE_LIBGPM 1
+EOF
+
+		echo "$as_me:4695: checking for Gpm_Wgetch in -lgpm" >&5
+echo $ECHO_N "checking for Gpm_Wgetch in -lgpm... $ECHO_C" >&6
+if test "${ac_cv_lib_gpm_Gpm_Wgetch+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgpm  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 4703 "configure"
+#include "confdefs.h"
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char Gpm_Wgetch ();
+int
+main ()
+{
+Gpm_Wgetch ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:4722: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:4725: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:4728: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4731: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_gpm_Gpm_Wgetch=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_lib_gpm_Gpm_Wgetch=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:4742: result: $ac_cv_lib_gpm_Gpm_Wgetch" >&5
+echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Wgetch" >&6
+if test $ac_cv_lib_gpm_Gpm_Wgetch = yes; then
+
+			{ echo "$as_me:4746: WARNING: GPM library is already linked with curses - read the FAQ" >&5
+echo "$as_me: WARNING: GPM library is already linked with curses - read the FAQ" >&2;}
+
+fi
+
+	fi
+fi
+
+# not everyone has "test -c"
+if test -c /dev/sysmouse 2>/dev/null ; then
+echo "$as_me:4756: checking if you want to use sysmouse" >&5
+echo $ECHO_N "checking if you want to use sysmouse... $ECHO_C" >&6
+
+# Check whether --with-sysmouse or --without-sysmouse was given.
+if test "${with_sysmouse+set}" = set; then
+  withval="$with_sysmouse"
+  cf_with_sysmouse=$withval
+else
+  cf_with_sysmouse=maybe
+fi;
+	if test "$cf_with_sysmouse" != no ; then
+	cat >conftest.$ac_ext <<_ACEOF
+#line 4768 "configure"
+#include "confdefs.h"
+
+#include <osreldate.h>
+#if (__FreeBSD_version >= 400017)
+#include <sys/consio.h>
+#include <sys/fbio.h>
+#else
+#include <machine/console.h>
+#endif
+
+int
+main ()
+{
+
+	struct mouse_info the_mouse;
+	ioctl(0, CONS_MOUSECTL, &the_mouse);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:4791: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:4794: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:4797: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:4800: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_with_sysmouse=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_with_sysmouse=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+	fi
+echo "$as_me:4810: result: $cf_with_sysmouse" >&5
+echo "${ECHO_T}$cf_with_sysmouse" >&6
+test "$cf_with_sysmouse" = yes && cat >>confdefs.h <<\EOF
+#define USE_SYSMOUSE 1
+EOF
+
+fi
+
+if test X"$CC_G_OPT" = X"" ; then
+	CC_G_OPT='-g'
+	test -n "$GCC" && test "${ac_cv_prog_cc_g}" != yes && CC_G_OPT=''
+fi
+
+if test X"$CXX_G_OPT" = X"" ; then
+	CXX_G_OPT='-g'
+	test -n "$GXX" && test "${ac_cv_prog_cxx_g}" != yes && CXX_G_OPT=''
+fi
+
+echo "$as_me:4828: checking for default loader flags" >&5
+echo $ECHO_N "checking for default loader flags... $ECHO_C" >&6
+case $DFT_LWR_MODEL in
+libtool) LD_MODEL=''   ;;
+normal)  LD_MODEL=''   ;;
+debug)   LD_MODEL=$CC_G_OPT ;;
+profile) LD_MODEL='-pg';;
+shared)  LD_MODEL=''   ;;
+esac
+echo "$as_me:4837: result: $LD_MODEL" >&5
 echo "${ECHO_T}$LD_MODEL" >&6
 
-echo "$as_me:4354: checking if rpath option should be used" >&5
+echo "$as_me:4840: checking if rpath option should be used" >&5
 echo $ECHO_N "checking if rpath option should be used... $ECHO_C" >&6
 
 # Check whether --enable-rpath or --disable-rpath was given.
@@ -4361,7 +4847,7 @@
 else
   cf_cv_ld_rpath=no
 fi;
-echo "$as_me:4364: result: $cf_cv_ld_rpath" >&5
+echo "$as_me:4850: result: $cf_cv_ld_rpath" >&5
 echo "${ECHO_T}$cf_cv_ld_rpath" >&6
 
 	LOCAL_LDFLAGS=
@@ -4371,7 +4857,7 @@
 
 	cf_cv_do_symlinks=no
 
-	echo "$as_me:4374: checking if release/abi version should be used for shared libs" >&5
+	echo "$as_me:4860: checking if release/abi version should be used for shared libs" >&5
 echo $ECHO_N "checking if release/abi version should be used for shared libs... $ECHO_C" >&6
 
 # Check whether --with-shlib-version or --without-shlib-version was given.
@@ -4386,7 +4872,7 @@
 		cf_cv_shlib_version=$withval
 		;;
 	*)
-		{ { echo "$as_me:4389: error: option value must be one of: rel, abi, auto or no" >&5
+		{ { echo "$as_me:4875: error: option value must be one of: rel, abi, auto or no" >&5
 echo "$as_me: error: option value must be one of: rel, abi, auto or no" >&2;}
    { (exit 1); exit 1; }; }
 		;;
@@ -4395,7 +4881,7 @@
 else
   cf_cv_shlib_version=auto
 fi;
-	echo "$as_me:4398: result: $cf_cv_shlib_version" >&5
+	echo "$as_me:4884: result: $cf_cv_shlib_version" >&5
 echo "${ECHO_T}$cf_cv_shlib_version" >&6
 
 	cf_cv_rm_so_locs=no
@@ -4404,14 +4890,14 @@
 	CC_SHARED_OPTS=
 	if test "$GCC" = yes
 	then
-		echo "$as_me:4407: checking which $CC option to use" >&5
+		echo "$as_me:4893: checking which $CC option to use" >&5
 echo $ECHO_N "checking which $CC option to use... $ECHO_C" >&6
 		cf_save_CFLAGS="$CFLAGS"
 		for CC_SHARED_OPTS in -fPIC -fpic ''
 		do
 			CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
 			cat >conftest.$ac_ext <<_ACEOF
-#line 4414 "configure"
+#line 4900 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int
@@ -4423,16 +4909,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:4426: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:4912: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:4429: \$? = $ac_status" >&5
+  echo "$as_me:4915: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:4432: \"$ac_try\"") >&5
+  { (eval echo "$as_me:4918: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4435: \$? = $ac_status" >&5
+  echo "$as_me:4921: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   break
 else
@@ -4441,7 +4927,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 		done
-		echo "$as_me:4444: result: $CC_SHARED_OPTS" >&5
+		echo "$as_me:4930: result: $CC_SHARED_OPTS" >&5
 echo "${ECHO_T}$CC_SHARED_OPTS" >&6
 		CFLAGS="$cf_save_CFLAGS"
 	fi
@@ -4480,8 +4966,13 @@
 		;;
 	irix*)
 		if test "$cf_cv_ld_rpath" = yes ; then
-			cf_ld_rpath_opt="-Wl,-rpath,"
-			EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
+			if test "$GCC" = yes; then
+				cf_ld_rpath_opt="-Wl,-rpath,"
+				EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
+			else
+				cf_ld_rpath_opt="-rpath "
+				EXTRA_LDFLAGS="-rpath \$(libdir) $EXTRA_LDFLAGS"
+			fi
 		fi
 		# tested with IRIX 5.2 and 'cc'.
 		if test "$GCC" != yes; then
@@ -4625,7 +5116,7 @@
 			test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
 			;;
 		*)
-			{ echo "$as_me:4628: WARNING: ignored --with-shlib-version" >&5
+			{ echo "$as_me:5119: WARNING: ignored --with-shlib-version" >&5
 echo "$as_me: WARNING: ignored --with-shlib-version" >&2;}
 			;;
 		esac
@@ -4633,12 +5124,12 @@
 	esac
 
 	if test -n "$cf_ld_rpath_opt" ; then
-		echo "$as_me:4636: checking if we need a space after rpath option" >&5
+		echo "$as_me:5127: checking if we need a space after rpath option" >&5
 echo $ECHO_N "checking if we need a space after rpath option... $ECHO_C" >&6
 		cf_save_LIBS="$LIBS"
 		LIBS="$LIBS ${cf_ld_rpath_opt}$libdir"
 		cat >conftest.$ac_ext <<_ACEOF
-#line 4641 "configure"
+#line 5132 "configure"
 #include "confdefs.h"
 
 int
@@ -4650,16 +5141,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:4653: \"$ac_link\"") >&5
+if { (eval echo "$as_me:5144: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4656: \$? = $ac_status" >&5
+  echo "$as_me:5147: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:4659: \"$ac_try\"") >&5
+  { (eval echo "$as_me:5150: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4662: \$? = $ac_status" >&5
+  echo "$as_me:5153: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_rpath_space=no
 else
@@ -4669,7 +5160,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 		LIBS="$cf_save_LIBS"
-		echo "$as_me:4672: result: $cf_rpath_space" >&5
+		echo "$as_me:5163: result: $cf_rpath_space" >&5
 echo "${ECHO_T}$cf_rpath_space" >&6
 		test "$cf_rpath_space" = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
 		MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
@@ -4678,7 +5169,7 @@
 if test "$CC_SHARED_OPTS" = "unknown"; then
 	for model in $cf_list_models; do
 		if test "$model" = "shared"; then
-			{ { echo "$as_me:4681: error: Shared libraries are not supported in this version" >&5
+			{ { echo "$as_me:5172: error: Shared libraries are not supported in this version" >&5
 echo "$as_me: error: Shared libraries are not supported in this version" >&2;}
    { (exit 1); exit 1; }; }
 		fi
@@ -4688,7 +5179,7 @@
 ###############################################################################
 
 ###	use option --disable-overwrite to leave out the link to -lcurses
-echo "$as_me:4691: checking if you wish to install ncurses overwriting curses" >&5
+echo "$as_me:5182: checking if you wish to install ncurses overwriting curses" >&5
 echo $ECHO_N "checking if you wish to install ncurses overwriting curses... $ECHO_C" >&6
 
 # Check whether --enable-overwrite or --disable-overwrite was given.
@@ -4698,10 +5189,10 @@
 else
   if test "$prefix" = "/usr" ; then with_overwrite=yes; else with_overwrite=no; fi
 fi;
-echo "$as_me:4701: result: $with_overwrite" >&5
+echo "$as_me:5192: result: $with_overwrite" >&5
 echo "${ECHO_T}$with_overwrite" >&6
 
-echo "$as_me:4704: checking if external terminfo-database is used" >&5
+echo "$as_me:5195: checking if external terminfo-database is used" >&5
 echo $ECHO_N "checking if external terminfo-database is used... $ECHO_C" >&6
 
 # Check whether --enable-database or --disable-database was given.
@@ -4711,7 +5202,7 @@
 else
   use_database=yes
 fi;
-echo "$as_me:4714: result: $use_database" >&5
+echo "$as_me:5205: result: $use_database" >&5
 echo "${ECHO_T}$use_database" >&6
 
 case $host_os in #(vi
@@ -4733,7 +5224,7 @@
 #define USE_DATABASE 1
 EOF
 
-	echo "$as_me:4736: checking which terminfo source-file will be installed" >&5
+	echo "$as_me:5227: checking which terminfo source-file will be installed" >&5
 echo $ECHO_N "checking which terminfo source-file will be installed... $ECHO_C" >&6
 
 # Check whether --enable-database or --disable-database was given.
@@ -4741,11 +5232,11 @@
   enableval="$enable_database"
   TERMINFO_SRC=$withval
 fi;
-	echo "$as_me:4744: result: $TERMINFO_SRC" >&5
+	echo "$as_me:5235: result: $TERMINFO_SRC" >&5
 echo "${ECHO_T}$TERMINFO_SRC" >&6
 fi
 
-echo "$as_me:4748: checking for list of fallback descriptions" >&5
+echo "$as_me:5239: checking for list of fallback descriptions" >&5
 echo $ECHO_N "checking for list of fallback descriptions... $ECHO_C" >&6
 
 # Check whether --with-fallbacks or --without-fallbacks was given.
@@ -4755,17 +5246,35 @@
 else
   with_fallback=
 fi;
-echo "$as_me:4758: result: $with_fallback" >&5
+echo "$as_me:5249: result: $with_fallback" >&5
 echo "${ECHO_T}$with_fallback" >&6
 FALLBACK_LIST=`echo "$with_fallback" | sed -e 's/,/ /g'`
 
+echo "$as_me:5253: checking if you want modern xterm or antique" >&5
+echo $ECHO_N "checking if you want modern xterm or antique... $ECHO_C" >&6
+
+# Check whether --with-xterm-new or --without-xterm-new was given.
+if test "${with_xterm_new+set}" = set; then
+  withval="$with_xterm_new"
+  with_xterm_new=$withval
+else
+  with_xterm_new=yes
+fi;
+case $with_xterm_new in
+no)	with_xterm_new=xterm-old;;
+*)	with_xterm_new=xterm-new;;
+esac
+echo "$as_me:5267: result: $with_xterm_new" >&5
+echo "${ECHO_T}$with_xterm_new" >&6
+WHICH_XTERM=$with_xterm_new
+
 MAKE_TERMINFO=
 if test "$use_database" = no ; then
 	TERMINFO="${datadir}/terminfo"
 	MAKE_TERMINFO="#"
 else
 
-echo "$as_me:4768: checking for list of terminfo directories" >&5
+echo "$as_me:5277: checking for list of terminfo directories" >&5
 echo $ECHO_N "checking for list of terminfo directories... $ECHO_C" >&6
 
 # Check whether --with-terminfo-dirs or --without-terminfo-dirs was given.
@@ -4799,7 +5308,7 @@
   cf_src_path=`echo $cf_src_path | sed -e s%NONE%$ac_default_prefix%`
   ;;
 *)
-  { { echo "$as_me:4802: error: expected a pathname, not \"$cf_src_path\"" >&5
+  { { echo "$as_me:5311: error: expected a pathname, not \"$cf_src_path\"" >&5
 echo "$as_me: error: expected a pathname, not \"$cf_src_path\"" >&2;}
    { (exit 1); exit 1; }; }
   ;;
@@ -4812,13 +5321,13 @@
 
 eval 'TERMINFO_DIRS="$cf_dst_path"'
 
-echo "$as_me:4815: result: $TERMINFO_DIRS" >&5
+echo "$as_me:5324: result: $TERMINFO_DIRS" >&5
 echo "${ECHO_T}$TERMINFO_DIRS" >&6
 test -n "$TERMINFO_DIRS" && cat >>confdefs.h <<EOF
 #define TERMINFO_DIRS "$TERMINFO_DIRS"
 EOF
 
-echo "$as_me:4821: checking for default terminfo directory" >&5
+echo "$as_me:5330: checking for default terminfo directory" >&5
 echo $ECHO_N "checking for default terminfo directory... $ECHO_C" >&6
 
 # Check whether --with-default-terminfo-dir or --without-default-terminfo-dir was given.
@@ -4847,7 +5356,7 @@
   withval=`echo $withval | sed -e s%NONE%$ac_default_prefix%`
   ;;
 *)
-  { { echo "$as_me:4850: error: expected a pathname, not \"$withval\"" >&5
+  { { echo "$as_me:5359: error: expected a pathname, not \"$withval\"" >&5
 echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
    { (exit 1); exit 1; }; }
   ;;
@@ -4855,7 +5364,7 @@
 
 eval TERMINFO="$withval"
 
-echo "$as_me:4858: result: $TERMINFO" >&5
+echo "$as_me:5367: result: $TERMINFO" >&5
 echo "${ECHO_T}$TERMINFO" >&6
 cat >>confdefs.h <<EOF
 #define TERMINFO "$TERMINFO"
@@ -4865,7 +5374,7 @@
 
 ###	use option --disable-big-core to make tic run on small machines
 ###	We need 4Mb, check if we can allocate 50% more than that.
-echo "$as_me:4868: checking if big-core option selected" >&5
+echo "$as_me:5377: checking if big-core option selected" >&5
 echo $ECHO_N "checking if big-core option selected... $ECHO_C" >&6
 
 # Check whether --enable-big-core or --disable-big-core was given.
@@ -4877,7 +5386,7 @@
   with_big_core=no
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 4880 "configure"
+#line 5389 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -4891,15 +5400,15 @@
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:4894: \"$ac_link\"") >&5
+if { (eval echo "$as_me:5403: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:4897: \$? = $ac_status" >&5
+  echo "$as_me:5406: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:4899: \"$ac_try\"") >&5
+  { (eval echo "$as_me:5408: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:4902: \$? = $ac_status" >&5
+  echo "$as_me:5411: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   with_big_core=yes
 else
@@ -4911,14 +5420,14 @@
 rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi;
-echo "$as_me:4914: result: $with_big_core" >&5
+echo "$as_me:5423: result: $with_big_core" >&5
 echo "${ECHO_T}$with_big_core" >&6
 test "$with_big_core" = "yes" && cat >>confdefs.h <<\EOF
 #define HAVE_BIG_CORE 1
 EOF
 
 ###	use option --enable-termcap to compile in the termcap fallback support
-echo "$as_me:4921: checking if you want termcap-fallback support" >&5
+echo "$as_me:5430: checking if you want termcap-fallback support" >&5
 echo $ECHO_N "checking if you want termcap-fallback support... $ECHO_C" >&6
 
 # Check whether --enable-termcap or --disable-termcap was given.
@@ -4928,13 +5437,13 @@
 else
   with_termcap=no
 fi;
-echo "$as_me:4931: result: $with_termcap" >&5
+echo "$as_me:5440: result: $with_termcap" >&5
 echo "${ECHO_T}$with_termcap" >&6
 
 if test "$with_termcap" != "yes" ; then
 	if test "$use_database" = no ; then
 		if test -z "$with_fallback" ; then
-			{ { echo "$as_me:4937: error: You have disabled the database w/o specifying fallbacks" >&5
+			{ { echo "$as_me:5446: error: You have disabled the database w/o specifying fallbacks" >&5
 echo "$as_me: error: You have disabled the database w/o specifying fallbacks" >&2;}
    { (exit 1); exit 1; }; }
 		fi
@@ -4949,7 +5458,7 @@
 #define USE_TERMCAP 1
 EOF
 
-echo "$as_me:4952: checking for list of termcap files" >&5
+echo "$as_me:5461: checking for list of termcap files" >&5
 echo $ECHO_N "checking for list of termcap files... $ECHO_C" >&6
 
 # Check whether --with-termpath or --without-termpath was given.
@@ -4983,7 +5492,7 @@
   cf_src_path=`echo $cf_src_path | sed -e s%NONE%$ac_default_prefix%`
   ;;
 *)
-  { { echo "$as_me:4986: error: expected a pathname, not \"$cf_src_path\"" >&5
+  { { echo "$as_me:5495: error: expected a pathname, not \"$cf_src_path\"" >&5
 echo "$as_me: error: expected a pathname, not \"$cf_src_path\"" >&2;}
    { (exit 1); exit 1; }; }
   ;;
@@ -4996,14 +5505,14 @@
 
 eval 'TERMPATH="$cf_dst_path"'
 
-echo "$as_me:4999: result: $TERMPATH" >&5
+echo "$as_me:5508: result: $TERMPATH" >&5
 echo "${ECHO_T}$TERMPATH" >&6
 test -n "$TERMPATH" && cat >>confdefs.h <<EOF
 #define TERMPATH "$TERMPATH"
 EOF
 
 ###	use option --enable-getcap to use a hacked getcap for reading termcaps
-echo "$as_me:5006: checking if fast termcap-loader is needed" >&5
+echo "$as_me:5515: checking if fast termcap-loader is needed" >&5
 echo $ECHO_N "checking if fast termcap-loader is needed... $ECHO_C" >&6
 
 # Check whether --enable-getcap or --disable-getcap was given.
@@ -5013,13 +5522,13 @@
 else
   with_getcap=no
 fi;
-echo "$as_me:5016: result: $with_getcap" >&5
+echo "$as_me:5525: result: $with_getcap" >&5
 echo "${ECHO_T}$with_getcap" >&6
 test "$with_getcap" = "yes" && cat >>confdefs.h <<\EOF
 #define USE_GETCAP 1
 EOF
 
-echo "$as_me:5022: checking if translated termcaps will be cached in ~/.terminfo" >&5
+echo "$as_me:5531: checking if translated termcaps will be cached in ~/.terminfo" >&5
 echo $ECHO_N "checking if translated termcaps will be cached in ~/.terminfo... $ECHO_C" >&6
 
 # Check whether --enable-getcap-cache or --disable-getcap-cache was given.
@@ -5029,7 +5538,7 @@
 else
   with_getcap_cache=no
 fi;
-echo "$as_me:5032: result: $with_getcap_cache" >&5
+echo "$as_me:5541: result: $with_getcap_cache" >&5
 echo "${ECHO_T}$with_getcap_cache" >&6
 test "$with_getcap_cache" = "yes" && cat >>confdefs.h <<\EOF
 #define USE_GETCAP_CACHE 1
@@ -5038,7 +5547,7 @@
 fi
 
 ###   Use option --disable-home-terminfo to completely remove ~/.terminfo
-echo "$as_me:5041: checking if ~/.terminfo is wanted" >&5
+echo "$as_me:5550: checking if ~/.terminfo is wanted" >&5
 echo $ECHO_N "checking if ~/.terminfo is wanted... $ECHO_C" >&6
 
 # Check whether --enable-home-terminfo or --disable-home-terminfo was given.
@@ -5048,10 +5557,28 @@
 else
   with_home_terminfo=yes
 fi;
+echo "$as_me:5560: result: $with_home_terminfo" >&5
+echo "${ECHO_T}$with_home_terminfo" >&6
 test "$with_home_terminfo" = "yes" && cat >>confdefs.h <<\EOF
 #define USE_HOME_TERMINFO 1
 EOF
 
+echo "$as_me:5566: checking if you want to use restrict environment when running as root" >&5
+echo $ECHO_N "checking if you want to use restrict environment when running as root... $ECHO_C" >&6
+
+# Check whether --enable-root-environ or --disable-root-environ was given.
+if test "${enable_root_environ+set}" = set; then
+  enableval="$enable_root_environ"
+  with_root_environ=$enableval
+else
+  with_root_environ=yes
+fi;
+echo "$as_me:5576: result: $with_root_environ" >&5
+echo "${ECHO_T}$with_root_environ" >&6
+test "$with_root_environ" = yes && cat >>confdefs.h <<\EOF
+#define USE_ROOT_ENVIRON 1
+EOF
+
 ###   Use option --enable-symlinks to make tic use symlinks, not hard links
 ###   to reduce storage requirements for the terminfo database.
 
@@ -5060,13 +5587,13 @@
 	unlink
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:5063: checking for $ac_func" >&5
+echo "$as_me:5590: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 5069 "configure"
+#line 5596 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func (); below.  */
@@ -5097,16 +5624,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5100: \"$ac_link\"") >&5
+if { (eval echo "$as_me:5627: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5103: \$? = $ac_status" >&5
+  echo "$as_me:5630: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5106: \"$ac_try\"") >&5
+  { (eval echo "$as_me:5633: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5109: \$? = $ac_status" >&5
+  echo "$as_me:5636: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -5116,7 +5643,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:5119: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "$as_me:5646: result: `eval echo '${'$as_ac_var'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
 if test `eval echo '${'$as_ac_var'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -5133,13 +5660,13 @@
 		symlink
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:5136: checking for $ac_func" >&5
+echo "$as_me:5663: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 5142 "configure"
+#line 5669 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func (); below.  */
@@ -5170,16 +5697,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:5173: \"$ac_link\"") >&5
+if { (eval echo "$as_me:5700: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5176: \$? = $ac_status" >&5
+  echo "$as_me:5703: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:5179: \"$ac_try\"") >&5
+  { (eval echo "$as_me:5706: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5182: \$? = $ac_status" >&5
+  echo "$as_me:5709: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -5189,7 +5716,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:5192: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "$as_me:5719: result: `eval echo '${'$as_ac_var'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
 if test `eval echo '${'$as_ac_var'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -5200,7 +5727,7 @@
 done
 
 else
-	echo "$as_me:5203: checking if link/symlink functions work" >&5
+	echo "$as_me:5730: checking if link/symlink functions work" >&5
 echo $ECHO_N "checking if link/symlink functions work... $ECHO_C" >&6
 if test "${cf_cv_link_funcs+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -5213,7 +5740,7 @@
 			eval 'ac_cv_func_'$cf_func'=error'
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 5216 "configure"
+#line 5743 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -5243,15 +5770,15 @@
 
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:5246: \"$ac_link\"") >&5
+if { (eval echo "$as_me:5773: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:5249: \$? = $ac_status" >&5
+  echo "$as_me:5776: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:5251: \"$ac_try\"") >&5
+  { (eval echo "$as_me:5778: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:5254: \$? = $ac_status" >&5
+  echo "$as_me:5781: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
 			cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
@@ -5269,7 +5796,7 @@
 		test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
 
 fi
-echo "$as_me:5272: result: $cf_cv_link_funcs" >&5
+echo "$as_me:5799: result: $cf_cv_link_funcs" >&5
 echo "${ECHO_T}$cf_cv_link_funcs" >&6
 	test "$ac_cv_func_link"    = yes && cat >>confdefs.h <<\EOF
 #define HAVE_LINK 1
@@ -5285,27 +5812,27 @@
 with_symlinks=no
 
 if test "$ac_cv_func_link" != yes ; then
-    echo "$as_me:5288: checking if tic should use symbolic links" >&5
+    echo "$as_me:5815: checking if tic should use symbolic links" >&5
 echo $ECHO_N "checking if tic should use symbolic links... $ECHO_C" >&6
     if test "$ac_cv_func_symlink" = yes ; then
     	with_symlinks=yes
     else
     	with_symlinks=no
     fi
-    echo "$as_me:5295: result: $with_symlinks" >&5
+    echo "$as_me:5822: result: $with_symlinks" >&5
 echo "${ECHO_T}$with_symlinks" >&6
 elif test "$ac_cv_func_symlink" != yes ; then
-    echo "$as_me:5298: checking if tic should use hard links" >&5
+    echo "$as_me:5825: checking if tic should use hard links" >&5
 echo $ECHO_N "checking if tic should use hard links... $ECHO_C" >&6
     if test "$ac_cv_func_link" = yes ; then
     	with_links=yes
     else
     	with_links=no
     fi
-    echo "$as_me:5305: result: $with_links" >&5
+    echo "$as_me:5832: result: $with_links" >&5
 echo "${ECHO_T}$with_links" >&6
 else
-    echo "$as_me:5308: checking if tic should use symbolic links" >&5
+    echo "$as_me:5835: checking if tic should use symbolic links" >&5
 echo $ECHO_N "checking if tic should use symbolic links... $ECHO_C" >&6
 
 # Check whether --enable-symlinks or --disable-symlinks was given.
@@ -5315,7 +5842,7 @@
 else
   with_symlinks=no
 fi;
-    echo "$as_me:5318: result: $with_symlinks" >&5
+    echo "$as_me:5845: result: $with_symlinks" >&5
 echo "${ECHO_T}$with_symlinks" >&6
 fi
 
@@ -5328,7 +5855,7 @@
 EOF
 
 ###   use option --enable-broken-linker to force on use of broken-linker support
-echo "$as_me:5331: checking if you want broken-linker support code" >&5
+echo "$as_me:5858: checking if you want broken-linker support code" >&5
 echo $ECHO_N "checking if you want broken-linker support code... $ECHO_C" >&6
 
 # Check whether --enable-broken_linker or --disable-broken_linker was given.
@@ -5338,7 +5865,7 @@
 else
   with_broken_linker=${BROKEN_LINKER-no}
 fi;
-echo "$as_me:5341: result: $with_broken_linker" >&5
+echo "$as_me:5868: result: $with_broken_linker" >&5
 echo "${ECHO_T}$with_broken_linker" >&6
 
 BROKEN_LINKER=0
@@ -5362,1774 +5889,2356 @@
 	esac
 fi
 
-###   use option --with-bool to override bool's type
-echo "$as_me:5366: checking for type of bool" >&5
-echo $ECHO_N "checking for type of bool... $ECHO_C" >&6
+###   use option --enable-widec to turn on use of wide-character support
+NCURSES_CH_T=chtype
+NCURSES_LIBUTF8=0
 
-# Check whether --with-bool or --without-bool was given.
-if test "${with_bool+set}" = set; then
-  withval="$with_bool"
-  NCURSES_BOOL="$withval"
-else
-  NCURSES_BOOL=auto
-fi;
-echo "$as_me:5376: result: $NCURSES_BOOL" >&5
-echo "${ECHO_T}$NCURSES_BOOL" >&6
+NEED_WCHAR_H=0
+NCURSES_MBSTATE_T=0
+NCURSES_WCHAR_T=0
+NCURSES_WINT_T=0
 
-###   use option --with-ospeed to override ospeed's type
-echo "$as_me:5380: checking for type of ospeed" >&5
-echo $ECHO_N "checking for type of ospeed... $ECHO_C" >&6
+# Check to define _XOPEN_SOURCE "automatically"
 
-# Check whether --with-ospeed or --without-ospeed was given.
-if test "${with_ospeed+set}" = set; then
-  withval="$with_ospeed"
-  NCURSES_OSPEED="$withval"
-else
-  NCURSES_OSPEED=short
-fi;
-echo "$as_me:5390: result: $NCURSES_OSPEED" >&5
-echo "${ECHO_T}$NCURSES_OSPEED" >&6
+INTEL_COMPILER=no
 
-###   use option --enable-bsdpad to have tputs process BSD-style prefix padding
-echo "$as_me:5394: checking if tputs should process BSD-style prefix padding" >&5
-echo $ECHO_N "checking if tputs should process BSD-style prefix padding... $ECHO_C" >&6
+if test "$GCC" = yes ; then
+	case $host_os in
+	linux*|gnu*)
+		echo "$as_me:5908: checking if this is really Intel compiler" >&5
+echo $ECHO_N "checking if this is really Intel compiler... $ECHO_C" >&6
+		cf_save_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS -no-gcc"
+		cat >conftest.$ac_ext <<_ACEOF
+#line 5913 "configure"
+#include "confdefs.h"
 
-# Check whether --enable-bsdpad or --disable-bsdpad was given.
-if test "${enable_bsdpad+set}" = set; then
-  enableval="$enable_bsdpad"
-  with_bsdpad=$enableval
-else
-  with_bsdpad=no
-fi;
-echo "$as_me:5404: result: $with_bsdpad" >&5
-echo "${ECHO_T}$with_bsdpad" >&6
-test "$with_bsdpad" = yes && cat >>confdefs.h <<\EOF
-#define BSD_TPUTS 1
-EOF
+int
+main ()
+{
 
-### Enable compiling-in rcs id's
-echo "$as_me:5411: checking if RCS identifiers should be compiled-in" >&5
-echo $ECHO_N "checking if RCS identifiers should be compiled-in... $ECHO_C" >&6
+#ifdef __INTEL_COMPILER
+#else
+make an error
+#endif
 
-# Check whether --with-rcs-ids or --without-rcs-ids was given.
-if test "${with_rcs_ids+set}" = set; then
-  withval="$with_rcs_ids"
-  with_rcs_ids=$withval
-else
-  with_rcs_ids=no
-fi;
-echo "$as_me:5421: result: $with_rcs_ids" >&5
-echo "${ECHO_T}$with_rcs_ids" >&6
-test "$with_rcs_ids" = yes && cat >>confdefs.h <<\EOF
-#define USE_RCS_IDS 1
-EOF
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:5930: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:5933: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:5936: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:5939: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  INTEL_COMPILER=yes
+cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
 
-###############################################################################
-
-echo "$as_me:5429: checking format of man-pages" >&5
-echo $ECHO_N "checking format of man-pages... $ECHO_C" >&6
-
-# Check whether --with-manpage-format or --without-manpage-format was given.
-if test "${with_manpage_format+set}" = set; then
-  withval="$with_manpage_format"
-  MANPAGE_FORMAT=$withval
 else
-  MANPAGE_FORMAT=unknown
-fi;
-
-test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
-MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
-
-cf_unknown=
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+		CFLAGS="$cf_save_CFLAGS"
+		echo "$as_me:5950: result: $INTEL_COMPILER" >&5
+echo "${ECHO_T}$INTEL_COMPILER" >&6
+		;;
+	esac
+fi
 
-case $MANPAGE_FORMAT in
-unknown)
-  if test -z "$MANPATH" ; then
-    MANPATH="/usr/man:/usr/share/man"
-  fi
+cf_XOPEN_SOURCE=500
+cf_POSIX_C_SOURCE=199506L
 
-  # look for the 'date' man-page (it's most likely to be installed!)
-  MANPAGE_FORMAT=
-  cf_preform=no
-  cf_catonly=yes
-  cf_example=date
+case $host_os in #(vi
+aix[45]*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
+	;;
+darwin*) #(vi
+	# setting _XOPEN_SOURCE breaks things on Darwin
+	;;
+freebsd*) #(vi
+	# 5.x headers associate
+	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
+	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
+	cf_POSIX_C_SOURCE=200112L
+	cf_XOPEN_SOURCE=600
+	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+	;;
+hpux*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
+	;;
+irix[56].*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
+	;;
+linux*|gnu*) #(vi
 
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
-  for cf_dir in $MANPATH; do
-    test -z "$cf_dir" && cf_dir=/usr/man
-    for cf_name in $cf_dir/man*/$cf_example.[01]* $cf_dir/cat*/$cf_example.[01]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
-    do
-      cf_test=`echo $cf_name | sed -e 's/*//'`
-      if test "x$cf_test" = "x$cf_name" ; then
+if test "$INTEL_COMPILER" = no ; then
+echo "$as_me:5983: checking if we must define _GNU_SOURCE" >&5
+echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_gnu_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-	case "$cf_name" in
-	*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
-	*.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
-	*.0)	MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
-	*)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
-	esac
+cat >conftest.$ac_ext <<_ACEOF
+#line 5990 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
 
-	case "$cf_name" in
-	$cf_dir/man*)
-	  cf_catonly=no
-	  ;;
-	$cf_dir/cat*)
-	  cf_preform=yes
-	  ;;
-	esac
-	break
-      fi
+#ifndef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6005: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6008: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6011: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6014: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_gnu_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+	 cat >conftest.$ac_ext <<_ACEOF
+#line 6023 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
 
-      # if we found a match in either man* or cat*, stop looking
-      if test -n "$MANPAGE_FORMAT" ; then
-	cf_found=no
-	test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
-	test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
-	case "$cf_name" in
-	$cf_dir/cat*)
-	  cf_found=yes
-	  ;;
-	esac
-	test $cf_found=yes && break
-      fi
-    done
-    # only check the first directory in $MANPATH where we find manpages
-    if test -n "$MANPAGE_FORMAT" ; then
-       break
-    fi
-  done
-  # if we did not find the example, just assume it is normal
-  test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
-  IFS="$ac_save_ifs"
-  ;;
-*)
-  for cf_option in $MANPAGE_FORMAT; do
-     case $cf_option in #(vi
-     gzip|compress|BSDI|normal|formatted|catonly)
-       ;;
-     *)
-       cf_unknown="$cf_unknown $cf_option"
-       ;;
-     esac
-  done
-  ;;
-esac
+#ifdef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6038: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6041: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6044: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6047: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_gnu_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_gnu_source=yes
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+	CPPFLAGS="$cf_save"
 
-echo "$as_me:5518: result: $MANPAGE_FORMAT" >&5
-echo "${ECHO_T}$MANPAGE_FORMAT" >&6
-if test -n "$cf_unknown" ; then
-  { echo "$as_me:5521: WARNING: Unexpected manpage-format $cf_unknown" >&5
-echo "$as_me: WARNING: Unexpected manpage-format $cf_unknown" >&2;}
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-echo "$as_me:5525: checking for manpage renaming" >&5
-echo $ECHO_N "checking for manpage renaming... $ECHO_C" >&6
+fi
+echo "$as_me:6062: result: $cf_cv_gnu_source" >&5
+echo "${ECHO_T}$cf_cv_gnu_source" >&6
+test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+fi
 
-# Check whether --with-manpage-renames or --without-manpage-renames was given.
-if test "${with_manpage_renames+set}" = set; then
-  withval="$with_manpage_renames"
-  MANPAGE_RENAMES=$withval
+	;;
+mirbsd*) #(vi
+	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
+	;;
+netbsd*) #(vi
+	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
+	;;
+openbsd*) #(vi
+	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+	;;
+osf[45]*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
+	;;
+sco*) #(vi
+	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+	;;
+solaris*) #(vi
+	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
+	;;
+*)
+	echo "$as_me:6087: checking if we should define _XOPEN_SOURCE" >&5
+echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_xopen_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  MANPAGE_RENAMES=yes
-fi;
-
-case ".$MANPAGE_RENAMES" in #(vi
-.no) #(vi
-  ;;
-.|.yes)
-  # Debian 'man' program?
-  if test -f /etc/debian_version ; then
-    MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
-  else
-    MANPAGE_RENAMES=no
-  fi
-  ;;
-esac
 
-if test "$MANPAGE_RENAMES" != no ; then
-  if test -f $srcdir/man/$MANPAGE_RENAMES ; then
-    MANPAGE_RENAMES=`cd $srcdir/man && pwd`/$MANPAGE_RENAMES
-  elif test ! -f $MANPAGE_RENAMES ; then
-    { { echo "$as_me:5553: error: not a filename: $MANPAGE_RENAMES" >&5
-echo "$as_me: error: not a filename: $MANPAGE_RENAMES" >&2;}
-   { (exit 1); exit 1; }; }
-  fi
+	cat >conftest.$ac_ext <<_ACEOF
+#line 6094 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
 
-  test ! -d man && mkdir man
+#ifndef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6109: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6112: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6115: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6118: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xopen_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+	 cat >conftest.$ac_ext <<_ACEOF
+#line 6127 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
 
-  # Construct a sed-script to perform renaming within man-pages
-  if test -n "$MANPAGE_RENAMES" ; then
-    test ! -d man && mkdir man
-    sh $srcdir/man/make_sed.sh $MANPAGE_RENAMES >man/edit_man.sed
-  fi
+#ifdef _XOPEN_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6142: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6145: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6148: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6151: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_xopen_source=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_xopen_source=$cf_XOPEN_SOURCE
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+	CPPFLAGS="$cf_save"
 
-echo "$as_me:5567: result: $MANPAGE_RENAMES" >&5
-echo "${ECHO_T}$MANPAGE_RENAMES" >&6
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-echo "$as_me:5570: checking if manpage aliases will be installed" >&5
-echo $ECHO_N "checking if manpage aliases will be installed... $ECHO_C" >&6
+fi
+echo "$as_me:6166: result: $cf_cv_xopen_source" >&5
+echo "${ECHO_T}$cf_cv_xopen_source" >&6
+test "$cf_cv_xopen_source" != no && CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE -D_XOPEN_SOURCE=$cf_cv_xopen_source"
 
-# Check whether --with-manpage-aliases or --without-manpage-aliases was given.
-if test "${with_manpage_aliases+set}" = set; then
-  withval="$with_manpage_aliases"
-  MANPAGE_ALIASES=$withval
+cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
+echo "$as_me:6171: checking if we should define _POSIX_C_SOURCE" >&5
+echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
+if test "${cf_cv_posix_c_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  MANPAGE_ALIASES=yes
-fi;
 
-echo "$as_me:5581: result: $MANPAGE_ALIASES" >&5
-echo "${ECHO_T}$MANPAGE_ALIASES" >&6
+echo "(line 6177) testing if the symbol is already defined go no further ..." 1>&5
 
-if test "$LN_S" = "ln -s"; then
-	cf_use_symlinks=yes
-else
-	cf_use_symlinks=no
-fi
-
-MANPAGE_SYMLINKS=no
-if test "$MANPAGE_ALIASES" = yes ; then
-echo "$as_me:5592: checking if manpage symlinks should be used" >&5
-echo $ECHO_N "checking if manpage symlinks should be used... $ECHO_C" >&6
+	cat >conftest.$ac_ext <<_ACEOF
+#line 6180 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
 
-# Check whether --with-manpage-symlinks or --without-manpage-symlinks was given.
-if test "${with_manpage_symlinks+set}" = set; then
-  withval="$with_manpage_symlinks"
-  MANPAGE_SYMLINKS=$withval
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6195: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6198: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6201: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6204: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_posix_c_source=no
 else
-  MANPAGE_SYMLINKS=$cf_use_symlinks
-fi;
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_want_posix_source=no
+	 case .$cf_POSIX_C_SOURCE in
+	 .[12]??*)
+		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+		;;
+	 .2)
+		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+		cf_want_posix_source=yes
+		;;
+	 .*)
+		cf_want_posix_source=yes
+		;;
+	 esac
+	 if test "$cf_want_posix_source" = yes ; then
+		cat >conftest.$ac_ext <<_ACEOF
+#line 6225 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
 
-if test "$$cf_use_symlinks" = no; then
-if test "$MANPAGE_SYMLINKS" = yes ; then
-	{ echo "$as_me:5605: WARNING: cannot make symlinks" >&5
-echo "$as_me: WARNING: cannot make symlinks" >&2;}
-	MANPAGE_SYMLINKS=no
-fi
+#ifdef _POSIX_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6240: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6243: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6246: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6249: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_posix_c_source="$cf_cv_posix_c_source -U_POSIX_SOURCE -D_POSIX_SOURCE"
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+	 fi
 
-echo "$as_me:5611: result: $MANPAGE_SYMLINKS" >&5
-echo "${ECHO_T}$MANPAGE_SYMLINKS" >&6
-fi
+echo "(line 6260) testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
 
-echo "$as_me:5615: checking for manpage tbl" >&5
-echo $ECHO_N "checking for manpage tbl... $ECHO_C" >&6
+	 cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
 
-# Check whether --with-manpage-tbl or --without-manpage-tbl was given.
-if test "${with_manpage_tbl+set}" = set; then
-  withval="$with_manpage_tbl"
-  MANPAGE_TBL=$withval
+echo "(line 6265) testing if the second compile does not leave our definition intact error ..." 1>&5
+
+	 cat >conftest.$ac_ext <<_ACEOF
+#line 6268 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int
+main ()
+{
+
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6283: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6286: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6289: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6292: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
 else
-  MANPAGE_TBL=no
-fi;
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_posix_c_source=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+	CPPFLAGS="$cf_save"
 
-echo "$as_me:5626: result: $MANPAGE_TBL" >&5
-echo "${ECHO_T}$MANPAGE_TBL" >&6
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
 
-  if test "$prefix" = "NONE" ; then
-     cf_prefix="$ac_default_prefix"
-  else
-     cf_prefix="$prefix"
-  fi
+fi
+echo "$as_me:6307: result: $cf_cv_posix_c_source" >&5
+echo "${ECHO_T}$cf_cv_posix_c_source" >&6
+test "$cf_cv_posix_c_source" != no && CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
 
-  case "$MANPAGE_FORMAT" in # (vi
-  *catonly*) # (vi
-    cf_format=yes
-    cf_inboth=no
-    ;;
-  *formatted*) # (vi
-    cf_format=yes
-    cf_inboth=yes
-    ;;
-  *)
-    cf_format=no
-    cf_inboth=no
-    ;;
-  esac
+	;;
+esac
 
-test ! -d man && mkdir man
+# Checks for CODESET support.
 
-cf_so_strip=
-cf_compress=
-case "$MANPAGE_FORMAT" in #(vi
-*compress*) #(vi
-	cf_so_strip="Z"
-	cf_compress=compress
-  ;;
-*gzip*) #(vi
-	cf_so_strip="gz"
-	cf_compress=gzip
-  ;;
-esac
+  echo "$as_me:6316: checking for nl_langinfo and CODESET" >&5
+echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
+if test "${am_cv_langinfo_codeset+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 6322 "configure"
+#include "confdefs.h"
+#include <langinfo.h>
+int
+main ()
+{
+char* cs = nl_langinfo(CODESET);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6334: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6337: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6340: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6343: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  am_cv_langinfo_codeset=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+am_cv_langinfo_codeset=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
-cf_edit_man=man/edit_man.sh
+fi
+echo "$as_me:6354: result: $am_cv_langinfo_codeset" >&5
+echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
+  if test $am_cv_langinfo_codeset = yes; then
 
-cat >$cf_edit_man <<CF_EOF
-#! /bin/sh
-# this script is generated by the configure-script CF_MAN_PAGES macro.
-prefix="$cf_prefix"
-datadir="$datadir"
-NCURSES_OSPEED="$NCURSES_OSPEED"
-TERMINFO="$TERMINFO"
-MKDIRS="sh `cd $srcdir && pwd`/mkinstalldirs"
-INSTALL="$INSTALL"
-INSTALL_DATA="$INSTALL_DATA"
-transform="$program_transform_name"
+cat >>confdefs.h <<\EOF
+#define HAVE_LANGINFO_CODESET 1
+EOF
 
-TMP=\${TMPDIR-/tmp}/man\$\$
-trap "rm -f \$TMP" 0 1 2 5 15
+  fi
 
-form=\$1
-shift || exit 1
+# use these variables to work around a defect in gcc's fixincludes.
+NCURSES_OK_WCHAR_T=
+NCURSES_OK_WINT_T=
 
-verb=\$1
-shift || exit 1
+echo "$as_me:6368: checking if you want wide-character code" >&5
+echo $ECHO_N "checking if you want wide-character code... $ECHO_C" >&6
 
-mandir=\$1
-shift || exit 1
+# Check whether --enable-widec or --disable-widec was given.
+if test "${enable_widec+set}" = set; then
+  enableval="$enable_widec"
+  with_widec=$enableval
+else
+  with_widec=no
+fi;
+echo "$as_me:6378: result: $with_widec" >&5
+echo "${ECHO_T}$with_widec" >&6
+if test "$with_widec" = yes ; then
+	LIB_SUFFIX="w${LIB_SUFFIX}"
+	cat >>confdefs.h <<\EOF
+#define USE_WIDEC_SUPPORT 1
+EOF
 
-srcdir=\$1
-shift || exit 1
+echo "$as_me:6386: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
+echo $ECHO_N "checking if we must define _XOPEN_SOURCE_EXTENDED... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line 6389 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
 
-if test "\$form" = normal ; then
-	if test "$cf_format" = yes ; then
-	if test "$cf_inboth" = no ; then
-		sh \$0 format \$verb \$mandir \$srcdir \$*
-		exit $?
-	fi
-	fi
-	cf_subdir=\$mandir/man
-	cf_tables=$MANPAGE_TBL
+int
+main ()
+{
+
+#ifndef _XOPEN_SOURCE_EXTENDED
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6405: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6408: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6411: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6414: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_result=no
 else
-	cf_subdir=\$mandir/cat
-	cf_tables=yes
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_result=yes
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:6423: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
 
-# process the list of source-files
-for i in \$* ; do
-case \$i in #(vi
-*.orig|*.rej) ;; #(vi
-*.[0-9]*)
-	section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
-	if test \$verb = installing ; then
-	if test ! -d \$cf_subdir\${section} ; then
-		\$MKDIRS \$cf_subdir\$section
-	fi
-	fi
-	aliases=
-	source=\`basename \$i\`
-	inalias=\$source
-	test ! -f \$inalias && inalias="\$srcdir/\$inalias"
-	if test ! -f \$inalias ; then
-		echo .. skipped \$source
-		continue
-	fi
-CF_EOF
+if test "$cf_result" = yes ; then
+	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
+elif test "x" != "x" ; then
+	echo "$as_me:6429: checking checking for compatible value versus " >&5
+echo $ECHO_N "checking checking for compatible value versus ... $ECHO_C" >&6
+	cat >conftest.$ac_ext <<_ACEOF
+#line 6432 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
 
-if test "$MANPAGE_ALIASES" != no ; then
-cat >>$cf_edit_man <<CF_EOF
-	aliases=\`sed -f \$srcdir/manlinks.sed \$inalias | sort -u\`
-CF_EOF
-fi
+int
+main ()
+{
 
-if test "$MANPAGE_RENAMES" = no ; then
-cat >>$cf_edit_man <<CF_EOF
-	# perform program transformations for section 1 man pages
-	if test \$section = 1 ; then
-		target=\$cf_subdir\${section}/\`echo \$source|sed "\${transform}"\`
-	else
-		target=\$cf_subdir\${section}/\$source
-	fi
-CF_EOF
+#if _XOPEN_SOURCE_EXTENDED- < 0
+make an error
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6448: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6451: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6454: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6457: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_result=yes
 else
-cat >>$cf_edit_man <<CF_EOF
-	target=\`grep "^\$source" $MANPAGE_RENAMES | $AWK '{print \$2}'\`
-	if test -z "\$target" ; then
-		echo '? missing rename for '\$source
-		target="\$source"
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_result=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+	echo "$as_me:6466: result: $cf_result" >&5
+echo "${ECHO_T}$cf_result" >&6
+	if test "$cf_result" = no ; then
+		# perhaps we can override it - try...
+		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED="
 	fi
-	target="\$cf_subdir\${section}/\${target}"
-CF_EOF
 fi
 
-	# replace variables in man page
-
-	for cf_name in  captoinfo clear infocmp infotocap tic toe tput
-	do
-cat >>$cf_edit_man <<CF_EOF
-	prog_$cf_name=\`echo $cf_name|sed "\${transform}"\`
-CF_EOF
-	done
+	# with_overwrite=no
+	NCURSES_CH_T=cchar_t
 
-cat >>$cf_edit_man <<CF_EOF
-	sed	-e "s,@DATADIR@,\$datadir," \\
-		-e "s,@TERMINFO@,\$TERMINFO," \\
-		-e "s,@NCURSES_OSPEED@,\$NCURSES_OSPEED," \\
-CF_EOF
+for ac_func in putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:6480: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+#line 6486 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func (); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char $ac_func ();
+char (*f) ();
 
-	for cf_name in  captoinfo clear infocmp infotocap tic toe tput
-	do
-		cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
-cat >>$cf_edit_man <<CF_EOF
-		-e "s,@$cf_NAME@,\$prog_$cf_name," \\
-CF_EOF
-	done
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
 
-if test -f $MANPAGE_RENAMES ; then
-cat >>$cf_edit_man <<CF_EOF
-		< \$i | sed -f $srcdir/edit_man.sed >\$TMP
-CF_EOF
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6517: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6520: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6523: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6526: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  eval "$as_ac_var=yes"
 else
-cat >>$cf_edit_man <<CF_EOF
-		< \$i >\$TMP
-CF_EOF
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
 fi
-
-cat >>$cf_edit_man <<CF_EOF
-if test \$cf_tables = yes ; then
-	tbl \$TMP >\$TMP.out
-	mv \$TMP.out \$TMP
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-CF_EOF
+echo "$as_me:6536: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+  cat >>confdefs.h <<EOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+EOF
 
-if test $with_curses_h != yes ; then
-cat >>$cf_edit_man <<CF_EOF
-	sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
-	mv \$TMP.out \$TMP
-CF_EOF
 fi
+done
 
-cat >>$cf_edit_man <<CF_EOF
-	if test \$form = format ; then
-		nroff -man \$TMP >\$TMP.out
-		mv \$TMP.out \$TMP
-	fi
-CF_EOF
+	if test "$ac_cv_func_putwc" != yes ; then
 
-if test -n "$cf_compress" ; then
-cat >>$cf_edit_man <<CF_EOF
-	if test \$verb = installing ; then
-	if ( $cf_compress -f \$TMP )
-	then
-		mv \$TMP.$cf_so_strip \$TMP
-	fi
-	fi
-	target="\$target.$cf_so_strip"
-CF_EOF
-fi
+echo "$as_me:6548: checking for putwc in libutf8" >&5
+echo $ECHO_N "checking for putwc in libutf8... $ECHO_C" >&6
+if test "${cf_cv_libutf8+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-case "$MANPAGE_FORMAT" in #(vi
-*BSDI*)
-cat >>$cf_edit_man <<CF_EOF
-	if test \$form = format ; then
-		# BSDI installs only .0 suffixes in the cat directories
-		target="\`echo \$target|sed -e 's/\.[1-9]\+[a-z]*/.0/'\`"
-	fi
-CF_EOF
-  ;;
-esac
+	cf_save_LIBS="$LIBS"
+	LIBS="-lutf8 $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line 6557 "configure"
+#include "confdefs.h"
 
-cat >>$cf_edit_man <<CF_EOF
-	suffix=\`basename \$target | sed -e 's%^[^.]*%%'\`
-	if test \$verb = installing ; then
-		echo \$verb \$target
-		\$INSTALL_DATA \$TMP \$target
-		test -n "\$aliases" && (
-			cd \$cf_subdir\${section} && (
-				source=\`echo \$target |sed -e 's%^.*/\([^/][^/]*/[^/][^/]*$\)%\1%'\`
-				test -n "$cf_so_strip" && source=\`echo \$source |sed -e 's%\.$cf_so_strip\$%%'\`
-				target=\`basename \$target\`
-				for cf_alias in \$aliases
-				do
-					if test \$section = 1 ; then
-						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
-					fi
+#include <libutf8.h>
+int
+main ()
+{
+putwc(0,0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:6570: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:6573: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:6576: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6579: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_libutf8=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_libutf8=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+	LIBS="$cf_save_LIBS"
 
-					if test "$MANPAGE_SYMLINKS" = yes ; then
-						if test -f \$cf_alias\${suffix} ; then
-							if ( cmp -s \$target \$cf_alias\${suffix} )
-							then
-								continue
-							fi
-						fi
-						echo .. \$verb alias \$cf_alias\${suffix}
-						rm -f \$cf_alias\${suffix}
-						$LN_S \$target \$cf_alias\${suffix}
-					elif test "\$target" != "\$cf_alias\${suffix}" ; then
-						echo ".so \$source" >\$TMP
-CF_EOF
-if test -n "$cf_compress" ; then
-cat >>$cf_edit_man <<CF_EOF
-						if test -n "$cf_so_strip" ; then
-							$cf_compress -f \$TMP
-							mv \$TMP.$cf_so_strip \$TMP
-						fi
-CF_EOF
 fi
-cat >>$cf_edit_man <<CF_EOF
-						echo .. \$verb alias \$cf_alias\${suffix}
-						rm -f \$cf_alias\${suffix}
-						\$INSTALL_DATA \$TMP \$cf_alias\${suffix}
-					fi
-				done
-			)
-		)
-	elif test \$verb = removing ; then
-		echo \$verb \$target
-		rm -f \$target
-		test -n "\$aliases" && (
-			cd \$cf_subdir\${section} && (
-				for cf_alias in \$aliases
-				do
-					if test \$section = 1 ; then
-						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
-					fi
+echo "$as_me:6591: result: $cf_cv_libutf8" >&5
+echo "${ECHO_T}$cf_cv_libutf8" >&6
 
-					echo .. \$verb alias \$cf_alias\${suffix}
-					rm -f \$cf_alias\${suffix}
-				done
-			)
-		)
-	else
-#		echo ".hy 0"
-		cat \$TMP
-	fi
-	;;
-esac
-done
+if test "$cf_cv_libutf8" = yes ; then
+	cat >>confdefs.h <<\EOF
+#define HAVE_LIBUTF8_H 1
+EOF
 
-if test $cf_inboth = yes ; then
-if test \$form != format ; then
-	sh \$0 format \$verb \$mandir \$srcdir \$*
-fi
+	LIBS="-lutf8 $LIBS"
 fi
 
-exit 0
-CF_EOF
-chmod 755 $cf_edit_man
+		if test "$cf_cv_libutf8" = yes ; then
+			NCURSES_LIBUTF8=1
+		fi
+	fi
 
-###############################################################################
+# This is needed on Tru64 5.0 to declare mbstate_t
+echo "$as_me:6608: checking if we must include wchar.h to declare mbstate_t" >&5
+echo $ECHO_N "checking if we must include wchar.h to declare mbstate_t... $ECHO_C" >&6
+if test "${cf_cv_mbstate_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-### Note that some functions (such as const) are normally disabled anyway.
-echo "$as_me:5914: checking if you want to build with function extensions" >&5
-echo $ECHO_N "checking if you want to build with function extensions... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line 6615 "configure"
+#include "confdefs.h"
 
-# Check whether --enable-ext-funcs or --disable-ext-funcs was given.
-if test "${enable_ext_funcs+set}" = set; then
-  enableval="$enable_ext_funcs"
-  with_ext_funcs=$enableval
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
+#endif
+int
+main ()
+{
+mbstate_t state
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6633: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6636: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6639: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6642: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_mbstate_t=no
 else
-  with_ext_funcs=yes
-fi;
-echo "$as_me:5924: result: $with_ext_funcs" >&5
-echo "${ECHO_T}$with_ext_funcs" >&6
-if test "$with_ext_funcs" = yes ; then
-	NCURSES_EXT_FUNCS=1
-	cat >>confdefs.h <<\EOF
-#define HAVE_CURSES_VERSION 1
-EOF
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cat >conftest.$ac_ext <<_ACEOF
+#line 6649 "configure"
+#include "confdefs.h"
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <wchar.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
+#endif
+int
+main ()
+{
+mbstate_t value
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6668: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6671: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6674: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6677: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_mbstate_t=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_mbstate_t=unknown
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:6689: result: $cf_cv_mbstate_t" >&5
+echo "${ECHO_T}$cf_cv_mbstate_t" >&6
 
+if test "$cf_cv_mbstate_t" = yes ; then
 	cat >>confdefs.h <<\EOF
-#define HAVE_HAS_KEY 1
+#define NEED_WCHAR_H 1
 EOF
 
-	cat >>confdefs.h <<\EOF
-#define HAVE_RESIZETERM 1
-EOF
+	NEED_WCHAR_H=1
+fi
 
-	cat >>confdefs.h <<\EOF
-#define HAVE_RESIZE_TERM 1
-EOF
+# if we do not find mbstate_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_mbstate_t" = unknown ; then
+	NCURSES_MBSTATE_T=1
+fi
 
-	cat >>confdefs.h <<\EOF
-#define HAVE_USE_DEFAULT_COLORS 1
-EOF
+# This is needed on Tru64 5.0 to declare wchar_t
+echo "$as_me:6706: checking if we must include wchar.h to declare wchar_t" >&5
+echo $ECHO_N "checking if we must include wchar.h to declare wchar_t... $ECHO_C" >&6
+if test "${cf_cv_wchar_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-	cat >>confdefs.h <<\EOF
-#define HAVE_WRESIZE 1
-EOF
+cat >conftest.$ac_ext <<_ACEOF
+#line 6713 "configure"
+#include "confdefs.h"
 
-	cat >>confdefs.h <<\EOF
-#define NCURSES_EXT_FUNCS 1
-EOF
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
+#endif
+int
+main ()
+{
+wchar_t state
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6731: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6734: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6737: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6740: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_wchar_t=no
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cat >conftest.$ac_ext <<_ACEOF
+#line 6747 "configure"
+#include "confdefs.h"
 
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <wchar.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
+#endif
+int
+main ()
+{
+wchar_t value
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6766: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6769: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6772: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6775: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_wchar_t=yes
 else
-	NCURSES_EXT_FUNCS=0
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_wchar_t=unknown
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:6787: result: $cf_cv_wchar_t" >&5
+echo "${ECHO_T}$cf_cv_wchar_t" >&6
 
-###   use option --enable-const to turn on use of const beyond that in XSI.
-echo "$as_me:5961: checking for extended use of const keyword" >&5
-echo $ECHO_N "checking for extended use of const keyword... $ECHO_C" >&6
+if test "$cf_cv_wchar_t" = yes ; then
+	cat >>confdefs.h <<\EOF
+#define NEED_WCHAR_H 1
+EOF
 
-# Check whether --enable-const or --disable-const was given.
-if test "${enable_const+set}" = set; then
-  enableval="$enable_const"
-  with_ext_const=$enableval
-else
-  with_ext_const=no
-fi;
-echo "$as_me:5971: result: $with_ext_const" >&5
-echo "${ECHO_T}$with_ext_const" >&6
-NCURSES_CONST='/*nothing*/'
-if test "$with_ext_const" = yes ; then
-	NCURSES_CONST=const
+	NEED_WCHAR_H=1
 fi
 
-echo "$as_me:5978: checking if you want \$NCURSES_NO_PADDING code" >&5
-echo $ECHO_N "checking if you want \$NCURSES_NO_PADDING code... $ECHO_C" >&6
+# if we do not find wchar_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_wchar_t" = unknown ; then
+	NCURSES_WCHAR_T=1
+fi
 
-# Check whether --enable-no-padding or --disable-no-padding was given.
-if test "${enable_no_padding+set}" = set; then
-  enableval="$enable_no_padding"
-  with_no_padding=$enableval
+# if we find wchar_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_wchar_t" != unknown ; then
+	NCURSES_OK_WCHAR_T=1
+fi
+
+# This is needed on Tru64 5.0 to declare wint_t
+echo "$as_me:6809: checking if we must include wchar.h to declare wint_t" >&5
+echo $ECHO_N "checking if we must include wchar.h to declare wint_t... $ECHO_C" >&6
+if test "${cf_cv_wint_t+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  with_no_padding=$with_ext_funcs
-fi;
-echo "$as_me:5988: result: $with_no_padding" >&5
-echo "${ECHO_T}$with_no_padding" >&6
-test "$with_no_padding" = yes && cat >>confdefs.h <<\EOF
-#define NCURSES_NO_PADDING 1
-EOF
 
-###   use option --enable-sigwinch to turn on use of SIGWINCH logic
-echo "$as_me:5995: checking if you want SIGWINCH handler" >&5
-echo $ECHO_N "checking if you want SIGWINCH handler... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line 6816 "configure"
+#include "confdefs.h"
 
-# Check whether --enable-sigwinch or --disable-sigwinch was given.
-if test "${enable_sigwinch+set}" = set; then
-  enableval="$enable_sigwinch"
-  with_sigwinch=$enableval
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
+#endif
+int
+main ()
+{
+wint_t state
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6834: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6837: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6840: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6843: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_wint_t=no
 else
-  with_sigwinch=$with_ext_funcs
-fi;
-echo "$as_me:6005: result: $with_sigwinch" >&5
-echo "${ECHO_T}$with_sigwinch" >&6
-test "$with_sigwinch" = yes && cat >>confdefs.h <<\EOF
-#define USE_SIGWINCH 1
-EOF
-
-###   use option --enable-tcap-names to allow user to define new capabilities
-echo "$as_me:6012: checking if you want user-definable terminal capabilities like termcap" >&5
-echo $ECHO_N "checking if you want user-definable terminal capabilities like termcap... $ECHO_C" >&6
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cat >conftest.$ac_ext <<_ACEOF
+#line 6850 "configure"
+#include "confdefs.h"
 
-# Check whether --enable-tcap-names or --disable-tcap-names was given.
-if test "${enable_tcap_names+set}" = set; then
-  enableval="$enable_tcap_names"
-  with_tcap_names=$enableval
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <wchar.h>
+#ifdef HAVE_LIBUTF8_H
+#include <libutf8.h>
+#endif
+int
+main ()
+{
+wint_t value
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6869: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6872: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6875: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6878: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cf_cv_wint_t=yes
 else
-  with_tcap_names=$with_ext_funcs
-fi;
-echo "$as_me:6022: result: $with_tcap_names" >&5
-echo "${ECHO_T}$with_tcap_names" >&6
-NCURSES_XNAMES=0
-test "$with_tcap_names" = yes && NCURSES_XNAMES=1
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+cf_cv_wint_t=unknown
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:6890: result: $cf_cv_wint_t" >&5
+echo "${ECHO_T}$cf_cv_wint_t" >&6
 
-###############################################################################
-# These options are relatively safe to experiment with.
+if test "$cf_cv_wint_t" = yes ; then
+	cat >>confdefs.h <<\EOF
+#define NEED_WCHAR_H 1
+EOF
 
-echo "$as_me:6030: checking if you want all development code" >&5
-echo $ECHO_N "checking if you want all development code... $ECHO_C" >&6
+	NEED_WCHAR_H=1
+fi
 
-# Check whether --with-develop or --without-develop was given.
-if test "${with_develop+set}" = set; then
-  withval="$with_develop"
-  with_develop=$withval
-else
-  with_develop=no
-fi;
-echo "$as_me:6040: result: $with_develop" >&5
-echo "${ECHO_T}$with_develop" >&6
+# if we do not find wint_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_wint_t" = unknown ; then
+	NCURSES_WINT_T=1
+fi
 
-###   use option --enable-hard-tabs to turn on use of hard-tabs optimize
-echo "$as_me:6044: checking if you want hard-tabs code" >&5
-echo $ECHO_N "checking if you want hard-tabs code... $ECHO_C" >&6
+# if we find wint_t in either place, use substitution to provide a fallback.
+if test "$cf_cv_wint_t" != unknown ; then
+	NCURSES_OK_WINT_T=1
+fi
 
-# Check whether --enable-hard-tabs or --disable-hard-tabs was given.
-if test "${enable_hard_tabs+set}" = set; then
-  enableval="$enable_hard_tabs"
-  with_hardtabs=$enableval
-else
-  with_hardtabs=$with_develop
-fi;
-echo "$as_me:6054: result: $with_hardtabs" >&5
-echo "${ECHO_T}$with_hardtabs" >&6
-test "$with_hardtabs" = yes && cat >>confdefs.h <<\EOF
-#define USE_HARD_TABS 1
+	if test "$NCURSES_MBSTATE_T" != 0; then
+		cat >>confdefs.h <<\EOF
+#define NEED_MBSTATE_T_DEF 1
 EOF
 
-echo "$as_me:6060: checking if you want to use restrict environment when running as root" >&5
-echo $ECHO_N "checking if you want to use restrict environment when running as root... $ECHO_C" >&6
+	fi
+fi
 
-# Check whether --enable-root-environ or --disable-root-environ was given.
-if test "${enable_root_environ+set}" = set; then
-  enableval="$enable_root_environ"
-  with_root_environ=$enableval
+###   use option --disable-lp64 to allow long chtype
+echo "$as_me:6920: checking if defining _LP64 overrides chtype definition" >&5
+echo $ECHO_N "checking if defining _LP64 overrides chtype definition... $ECHO_C" >&6
+
+# Check whether --enable-lp64 or --disable-lp64 was given.
+if test "${enable_lp64+set}" = set; then
+  enableval="$enable_lp64"
+  with_lp64=$enableval
 else
-  with_root_environ=yes
+  with_lp64=yes
 fi;
-echo "$as_me:6070: result: $with_root_environ" >&5
-echo "${ECHO_T}$with_root_environ" >&6
-test "$with_root_environ" = yes && cat >>confdefs.h <<\EOF
-#define USE_ROOT_ENVIRON 1
-EOF
+echo "$as_me:6930: result: $with_lp64" >&5
+echo "${ECHO_T}$with_lp64" >&6
+if test "$with_lp64" = yes ; then
+	cf_cv_enable_lp64=1
+else
+	cf_cv_enable_lp64=0
+fi
 
-###   use option --enable-xmc-glitch to turn on use of magic-cookie optimize
-echo "$as_me:6077: checking if you want limited support for xmc" >&5
-echo $ECHO_N "checking if you want limited support for xmc... $ECHO_C" >&6
+echo "$as_me:6938: checking if largefile support is wanted" >&5
+echo $ECHO_N "checking if largefile support is wanted... $ECHO_C" >&6
 
-# Check whether --enable-xmc-glitch or --disable-xmc-glitch was given.
-if test "${enable_xmc_glitch+set}" = set; then
-  enableval="$enable_xmc_glitch"
-  with_xmc_glitch=$enableval
+# Check whether --enable-largefile or --disable-largefile was given.
+if test "${enable_largefile+set}" = set; then
+  enableval="$enable_largefile"
+  with_largefile=$enableval
 else
-  with_xmc_glitch=$with_develop
+  with_largefile=yes
 fi;
-echo "$as_me:6087: result: $with_xmc_glitch" >&5
-echo "${ECHO_T}$with_xmc_glitch" >&6
-test "$with_xmc_glitch" = yes && cat >>confdefs.h <<\EOF
-#define USE_XMC_SUPPORT 1
-EOF
+echo "$as_me:6948: result: $with_largefile" >&5
+echo "${ECHO_T}$with_largefile" >&6
+if test "$with_largefile" = yes ; then
+	echo "$as_me:6951: checking for _LARGEFILE_SOURCE value needed for large files" >&5
+echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6
+if test "${ac_cv_sys_largefile_source+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  while :; do
+  ac_cv_sys_largefile_source=no
+  cat >conftest.$ac_ext <<_ACEOF
+#line 6959 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int
+main ()
+{
+return !fseeko;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:6971: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:6974: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:6977: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:6980: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+#line 6989 "configure"
+#include "confdefs.h"
+#define _LARGEFILE_SOURCE 1
+#include <stdio.h>
+int
+main ()
+{
+return !fseeko;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7002: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:7005: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7008: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7011: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sys_largefile_source=1; break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  break
+done
+fi
+echo "$as_me:7022: result: $ac_cv_sys_largefile_source" >&5
+echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6
+if test "$ac_cv_sys_largefile_source" != no; then
 
-###############################################################################
-# These are just experimental, probably should not be in a package:
+cat >>confdefs.h <<EOF
+#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source
+EOF
 
-echo "$as_me:6096: checking if you do not want to assume colors are white-on-black" >&5
-echo $ECHO_N "checking if you do not want to assume colors are white-on-black... $ECHO_C" >&6
+fi
+rm -f conftest*
 
-# Check whether --enable-assumed-color or --disable-assumed-color was given.
-if test "${enable_assumed_color+set}" = set; then
-  enableval="$enable_assumed_color"
-  with_assumed_color=$enableval
+# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
+# in glibc 2.1.3, but that breaks too many other things.
+# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
+echo "$as_me:7036: checking for fseeko" >&5
+echo $ECHO_N "checking for fseeko... $ECHO_C" >&6
+if test "${ac_cv_func_fseeko+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  with_assumed_color=yes
-fi;
-echo "$as_me:6106: result: $with_assumed_color" >&5
-echo "${ECHO_T}$with_assumed_color" >&6
-test "$with_assumed_color" = yes && cat >>confdefs.h <<\EOF
-#define USE_ASSUMED_COLOR 1
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7042 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+int
+main ()
+{
+return fseeko && fseeko (stdin, 0, 0);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:7054: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:7057: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:7060: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7063: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_func_fseeko=yes
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_func_fseeko=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:7073: result: $ac_cv_func_fseeko" >&5
+echo "${ECHO_T}$ac_cv_func_fseeko" >&6
+if test $ac_cv_func_fseeko = yes; then
+
+cat >>confdefs.h <<\EOF
+#define HAVE_FSEEKO 1
 EOF
 
-###   use option --enable-hashmap to turn on use of hashmap scrolling logic
-echo "$as_me:6113: checking if you want hashmap scrolling-optimization code" >&5
-echo $ECHO_N "checking if you want hashmap scrolling-optimization code... $ECHO_C" >&6
+fi
 
-# Check whether --enable-hashmap or --disable-hashmap was given.
-if test "${enable_hashmap+set}" = set; then
-  enableval="$enable_hashmap"
-  with_hashmap=$enableval
-else
-  with_hashmap=yes
-fi;
-echo "$as_me:6123: result: $with_hashmap" >&5
-echo "${ECHO_T}$with_hashmap" >&6
-test "$with_hashmap" = yes && cat >>confdefs.h <<\EOF
-#define USE_HASHMAP 1
-EOF
+# Check whether --enable-largefile or --disable-largefile was given.
+if test "${enable_largefile+set}" = set; then
+  enableval="$enable_largefile"
 
-###   use option --enable-colorfgbg to turn on use of $COLORFGBG environment
-echo "$as_me:6130: checking if you want colorfgbg code" >&5
-echo $ECHO_N "checking if you want colorfgbg code... $ECHO_C" >&6
+fi;
+if test "$enable_largefile" != no; then
 
-# Check whether --enable-colorfgbg or --disable-colorfgbg was given.
-if test "${enable_colorfgbg+set}" = set; then
-  enableval="$enable_colorfgbg"
-  with_colorfgbg=$enableval
+  echo "$as_me:7090: checking for special C compiler options needed for large files" >&5
+echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6
+if test "${ac_cv_sys_largefile_CC+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  with_colorfgbg=no
-fi;
-echo "$as_me:6140: result: $with_colorfgbg" >&5
-echo "${ECHO_T}$with_colorfgbg" >&6
-test "$with_colorfgbg" = yes && cat >>confdefs.h <<\EOF
-#define USE_COLORFGBG 1
-EOF
+  ac_cv_sys_largefile_CC=no
+     if test "$GCC" != yes; then
+       ac_save_CC=$CC
+       while :; do
+     	 # IRIX 6.2 and later do not support large files by default,
+     	 # so use the C compiler's -n32 option if that helps.
+         cat >conftest.$ac_ext <<_ACEOF
+#line 7102 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
 
-echo "$as_me:6146: checking if you want experimental safe-sprintf code" >&5
-echo $ECHO_N "checking if you want experimental safe-sprintf code... $ECHO_C" >&6
+  ;
+  return 0;
+}
+_ACEOF
+     	 rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7122: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:7125: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7128: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7131: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext
+     	 CC="$CC -n32"
+     	 rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7141: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:7144: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7147: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7150: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sys_largefile_CC=' -n32'; break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext
+         break
+       done
+       CC=$ac_save_CC
+       rm -f conftest.$ac_ext
+    fi
+fi
+echo "$as_me:7164: result: $ac_cv_sys_largefile_CC" >&5
+echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6
+  if test "$ac_cv_sys_largefile_CC" != no; then
+    CC=$CC$ac_cv_sys_largefile_CC
+  fi
 
-# Check whether --enable-safe-sprintf or --disable-safe-sprintf was given.
-if test "${enable_safe_sprintf+set}" = set; then
-  enableval="$enable_safe_sprintf"
-  with_safe_sprintf=$enableval
+  echo "$as_me:7170: checking for _FILE_OFFSET_BITS value needed for large files" >&5
+echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6
+if test "${ac_cv_sys_file_offset_bits+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  with_safe_sprintf=no
-fi;
-echo "$as_me:6156: result: $with_safe_sprintf" >&5
-echo "${ECHO_T}$with_safe_sprintf" >&6
-test "$with_safe_sprintf" = yes && cat >>confdefs.h <<\EOF
-#define USE_SAFE_SPRINTF 1
-EOF
+  while :; do
+  ac_cv_sys_file_offset_bits=no
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7178 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
 
-###   use option --disable-scroll-hints to turn off use of scroll-hints scrolling logic
-# when hashmap is used scroll hints are useless
-if test "$with_hashmap" = no ; then
-echo "$as_me:6165: checking if you want to experiment without scrolling-hints code" >&5
-echo $ECHO_N "checking if you want to experiment without scrolling-hints code... $ECHO_C" >&6
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7198: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:7201: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7204: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7207: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  break
+else
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7216 "configure"
+#include "confdefs.h"
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
+int
+main ()
+{
 
-# Check whether --enable-scroll-hints or --disable-scroll-hints was given.
-if test "${enable_scroll_hints+set}" = set; then
-  enableval="$enable_scroll_hints"
-  with_scroll_hints=$enableval
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:7237: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:7240: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:7243: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:7246: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sys_file_offset_bits=64; break
 else
-  with_scroll_hints=yes
-fi;
-echo "$as_me:6175: result: $with_scroll_hints" >&5
-echo "${ECHO_T}$with_scroll_hints" >&6
-test "$with_scroll_hints" = yes && cat >>confdefs.h <<\EOF
-#define USE_SCROLL_HINTS 1
-EOF
-
+  echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
 fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  break
+done
+fi
+echo "$as_me:7257: result: $ac_cv_sys_file_offset_bits" >&5
+echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6
+if test "$ac_cv_sys_file_offset_bits" != no; then
 
-###   use option --enable-widec to turn on use of wide-character support
-NCURSES_CH_T=chtype
-NCURSES_LIBUTF8=0
-
-NEED_WCHAR_H=0
-NCURSES_MBSTATE_T=0
-NCURSES_WCHAR_T=0
-NCURSES_WINT_T=0
-
-# Check to define _XOPEN_SOURCE "automatically"
-
-case $host_os in #(vi
-freebsd*) #(vi
-	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600"
-	;;
-hpux*) #(vi
-	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
-	;;
-irix6.*) #(vi
-	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
-	;;
-linux*) #(vi
+cat >>confdefs.h <<EOF
+#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
+EOF
 
-echo "$as_me:6206: checking if we must define _GNU_SOURCE" >&5
-echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
-if test "${cf_cv_gnu_source+set}" = set; then
+fi
+rm -f conftest*
+  echo "$as_me:7267: checking for _LARGE_FILES value needed for large files" >&5
+echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6
+if test "${ac_cv_sys_large_files+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-
-cat >conftest.$ac_ext <<_ACEOF
-#line 6213 "configure"
+  while :; do
+  ac_cv_sys_large_files=no
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7275 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
 int
 main ()
 {
 
-#ifndef _XOPEN_SOURCE
-make an error
-#endif
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6228: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7295: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6231: \$? = $ac_status" >&5
+  echo "$as_me:7298: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6234: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7301: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6237: \$? = $ac_status" >&5
+  echo "$as_me:7304: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_gnu_source=no
+  break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
-	 cat >conftest.$ac_ext <<_ACEOF
-#line 6246 "configure"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+  cat >conftest.$ac_ext <<_ACEOF
+#line 7313 "configure"
 #include "confdefs.h"
+#define _LARGE_FILES 1
 #include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+    We can't simply define LARGE_OFF_T to be 9223372036854775807,
+    since some C++ compilers masquerading as C compilers
+    incorrectly reject 9223372036854775807.  */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+  int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+		       && LARGE_OFF_T % 2147483647 == 1)
+		      ? 1 : -1];
 int
 main ()
 {
 
-#ifdef _XOPEN_SOURCE
-make an error
-#endif
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6261: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:7334: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:6264: \$? = $ac_status" >&5
+  echo "$as_me:7337: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6267: \"$ac_try\"") >&5
+  { (eval echo "$as_me:7340: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:6270: \$? = $ac_status" >&5
+  echo "$as_me:7343: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cf_cv_gnu_source=no
+  ac_cv_sys_large_files=1; break
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
-cf_cv_gnu_source=yes
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-	CPPFLAGS="$cf_save"
+  break
+done
+fi
+echo "$as_me:7354: result: $ac_cv_sys_large_files" >&5
+echo "${ECHO_T}$ac_cv_sys_large_files" >&6
+if test "$ac_cv_sys_large_files" != no; then
+
+cat >>confdefs.h <<EOF
+#define _LARGE_FILES $ac_cv_sys_large_files
+EOF
 
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
+rm -f conftest*
+fi
 
 fi
-echo "$as_me:6285: result: $cf_cv_gnu_source" >&5
-echo "${ECHO_T}$cf_cv_gnu_source" >&6
-test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
 
-	;;
-mirbsd*) #(vi
-	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
-	;;
-netbsd*) #(vi
-	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
-	;;
-openbsd*) #(vi
-	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
-	;;
-osf[45]*) #(vi
-	CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
-	;;
-sco*) #(vi
-	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
-	;;
-solaris*) #(vi
-	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
-	;;
+###   use option --with-bool to override bool's type
+echo "$as_me:7369: checking for type of bool" >&5
+echo $ECHO_N "checking for type of bool... $ECHO_C" >&6
+
+# Check whether --with-bool or --without-bool was given.
+if test "${with_bool+set}" = set; then
+  withval="$with_bool"
+  NCURSES_BOOL="$withval"
+else
+  NCURSES_BOOL=auto
+fi;
+echo "$as_me:7379: result: $NCURSES_BOOL" >&5
+echo "${ECHO_T}$NCURSES_BOOL" >&6
+
+echo "$as_me:7382: checking for alternate terminal capabilities file" >&5
+echo $ECHO_N "checking for alternate terminal capabilities file... $ECHO_C" >&6
+
+# Check whether --with-caps or --without-caps was given.
+if test "${with_caps+set}" = set; then
+  withval="$with_caps"
+  TERMINFO_CAPS=Caps.$withval
+else
+  TERMINFO_CAPS=Caps
+fi;
+test -f ${srcdir}/include/${TERMINFO_CAPS} || TERMINFO_CAPS=Caps
+echo "$as_me:7393: result: $TERMINFO_CAPS" >&5
+echo "${ECHO_T}$TERMINFO_CAPS" >&6
+
+###   use option --with-ospeed to override ospeed's type
+echo "$as_me:7397: checking for type of ospeed" >&5
+echo $ECHO_N "checking for type of ospeed... $ECHO_C" >&6
+
+# Check whether --with-ospeed or --without-ospeed was given.
+if test "${with_ospeed+set}" = set; then
+  withval="$with_ospeed"
+  NCURSES_OSPEED="$withval"
+else
+  NCURSES_OSPEED=short
+fi;
+echo "$as_me:7407: result: $NCURSES_OSPEED" >&5
+echo "${ECHO_T}$NCURSES_OSPEED" >&6
+
+###   use option --enable-bsdpad to have tputs process BSD-style prefix padding
+echo "$as_me:7411: checking if tputs should process BSD-style prefix padding" >&5
+echo $ECHO_N "checking if tputs should process BSD-style prefix padding... $ECHO_C" >&6
+
+# Check whether --enable-bsdpad or --disable-bsdpad was given.
+if test "${enable_bsdpad+set}" = set; then
+  enableval="$enable_bsdpad"
+  with_bsdpad=$enableval
+else
+  with_bsdpad=no
+fi;
+echo "$as_me:7421: result: $with_bsdpad" >&5
+echo "${ECHO_T}$with_bsdpad" >&6
+test "$with_bsdpad" = yes && cat >>confdefs.h <<\EOF
+#define BSD_TPUTS 1
+EOF
+
+### Enable compiling-in rcs id's
+echo "$as_me:7428: checking if RCS identifiers should be compiled-in" >&5
+echo $ECHO_N "checking if RCS identifiers should be compiled-in... $ECHO_C" >&6
+
+# Check whether --with-rcs-ids or --without-rcs-ids was given.
+if test "${with_rcs_ids+set}" = set; then
+  withval="$with_rcs_ids"
+  with_rcs_ids=$withval
+else
+  with_rcs_ids=no
+fi;
+echo "$as_me:7438: result: $with_rcs_ids" >&5
+echo "${ECHO_T}$with_rcs_ids" >&6
+test "$with_rcs_ids" = yes && cat >>confdefs.h <<\EOF
+#define USE_RCS_IDS 1
+EOF
+
+###############################################################################
+
+echo "$as_me:7446: checking format of man-pages" >&5
+echo $ECHO_N "checking format of man-pages... $ECHO_C" >&6
+
+# Check whether --with-manpage-format or --without-manpage-format was given.
+if test "${with_manpage_format+set}" = set; then
+  withval="$with_manpage_format"
+  MANPAGE_FORMAT=$withval
+else
+  MANPAGE_FORMAT=unknown
+fi;
+
+test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
+MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
+
+cf_unknown=
+
+case $MANPAGE_FORMAT in
+unknown)
+  if test -z "$MANPATH" ; then
+    MANPATH="/usr/man:/usr/share/man"
+  fi
+
+  # look for the 'date' man-page (it's most likely to be installed!)
+  MANPAGE_FORMAT=
+  cf_preform=no
+  cf_catonly=yes
+  cf_example=date
+
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
+  for cf_dir in $MANPATH; do
+    test -z "$cf_dir" && cf_dir=/usr/man
+    for cf_name in $cf_dir/man*/$cf_example.[01]* $cf_dir/cat*/$cf_example.[01]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
+    do
+      cf_test=`echo $cf_name | sed -e 's/*//'`
+      if test "x$cf_test" = "x$cf_name" ; then
+
+	case "$cf_name" in
+	*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
+	*.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
+	*.0)	MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
+	*)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
+	esac
+
+	case "$cf_name" in
+	$cf_dir/man*)
+	  cf_catonly=no
+	  ;;
+	$cf_dir/cat*)
+	  cf_preform=yes
+	  ;;
+	esac
+	break
+      fi
+
+      # if we found a match in either man* or cat*, stop looking
+      if test -n "$MANPAGE_FORMAT" ; then
+	cf_found=no
+	test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
+	test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
+	case "$cf_name" in
+	$cf_dir/cat*)
+	  cf_found=yes
+	  ;;
+	esac
+	test $cf_found=yes && break
+      fi
+    done
+    # only check the first directory in $MANPATH where we find manpages
+    if test -n "$MANPAGE_FORMAT" ; then
+       break
+    fi
+  done
+  # if we did not find the example, just assume it is normal
+  test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
+  IFS="$ac_save_ifs"
+  ;;
 *)
-	echo "$as_me:6309: checking if we should define _XOPEN_SOURCE" >&5
-echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
-if test "${cf_cv_xopen_source+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+  for cf_option in $MANPAGE_FORMAT; do
+     case $cf_option in #(vi
+     gzip|compress|BSDI|normal|formatted|catonly)
+       ;;
+     *)
+       cf_unknown="$cf_unknown $cf_option"
+       ;;
+     esac
+  done
+  ;;
+esac
+
+echo "$as_me:7535: result: $MANPAGE_FORMAT" >&5
+echo "${ECHO_T}$MANPAGE_FORMAT" >&6
+if test -n "$cf_unknown" ; then
+  { echo "$as_me:7538: WARNING: Unexpected manpage-format $cf_unknown" >&5
+echo "$as_me: WARNING: Unexpected manpage-format $cf_unknown" >&2;}
+fi
+
+echo "$as_me:7542: checking for manpage renaming" >&5
+echo $ECHO_N "checking for manpage renaming... $ECHO_C" >&6
+
+# Check whether --with-manpage-renames or --without-manpage-renames was given.
+if test "${with_manpage_renames+set}" = set; then
+  withval="$with_manpage_renames"
+  MANPAGE_RENAMES=$withval
 else
+  MANPAGE_RENAMES=yes
+fi;
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 6316 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int
-main ()
-{
+case ".$MANPAGE_RENAMES" in #(vi
+.no) #(vi
+  ;;
+.|.yes)
+  # Debian 'man' program?
+  if test -f /etc/debian_version ; then
+    MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
+  else
+    MANPAGE_RENAMES=no
+  fi
+  ;;
+esac
 
-#ifndef _XOPEN_SOURCE
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6331: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6334: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6337: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6340: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_xopen_source=no
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
-	 cat >conftest.$ac_ext <<_ACEOF
-#line 6349 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int
-main ()
-{
+if test "$MANPAGE_RENAMES" != no ; then
+  if test -f $srcdir/man/$MANPAGE_RENAMES ; then
+    MANPAGE_RENAMES=`cd $srcdir/man && pwd`/$MANPAGE_RENAMES
+  elif test ! -f $MANPAGE_RENAMES ; then
+    { { echo "$as_me:7570: error: not a filename: $MANPAGE_RENAMES" >&5
+echo "$as_me: error: not a filename: $MANPAGE_RENAMES" >&2;}
+   { (exit 1); exit 1; }; }
+  fi
 
-#ifdef _XOPEN_SOURCE
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6364: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6367: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6370: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6373: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_xopen_source=no
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_xopen_source=yes
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	CPPFLAGS="$cf_save"
+  test ! -d man && mkdir man
 
+  # Construct a sed-script to perform renaming within man-pages
+  if test -n "$MANPAGE_RENAMES" ; then
+    test ! -d man && mkdir man
+    sh $srcdir/man/make_sed.sh $MANPAGE_RENAMES >man/edit_man.sed
+  fi
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
 
-fi
-echo "$as_me:6388: result: $cf_cv_xopen_source" >&5
-echo "${ECHO_T}$cf_cv_xopen_source" >&6
-test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
+echo "$as_me:7584: result: $MANPAGE_RENAMES" >&5
+echo "${ECHO_T}$MANPAGE_RENAMES" >&6
 
-	# FreeBSD 5.x headers demand this...
-	echo "$as_me:6393: checking if we should define _POSIX_C_SOURCE" >&5
-echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
-if test "${cf_cv_xopen_source+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+echo "$as_me:7587: checking if manpage aliases will be installed" >&5
+echo $ECHO_N "checking if manpage aliases will be installed... $ECHO_C" >&6
+
+# Check whether --with-manpage-aliases or --without-manpage-aliases was given.
+if test "${with_manpage_aliases+set}" = set; then
+  withval="$with_manpage_aliases"
+  MANPAGE_ALIASES=$withval
 else
+  MANPAGE_ALIASES=yes
+fi;
 
-	cat >conftest.$ac_ext <<_ACEOF
-#line 6400 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int
-main ()
-{
+echo "$as_me:7598: result: $MANPAGE_ALIASES" >&5
+echo "${ECHO_T}$MANPAGE_ALIASES" >&6
 
-#ifndef _POSIX_C_SOURCE
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6415: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6418: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6421: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6424: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_xopen_source=no
+if test "$LN_S" = "ln -s"; then
+	cf_use_symlinks=yes
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_save="$CPPFLAGS"
-	 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
-	 cat >conftest.$ac_ext <<_ACEOF
-#line 6433 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-int
-main ()
-{
+	cf_use_symlinks=no
+fi
 
-#ifdef _POSIX_C_SOURCE
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6448: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6451: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6454: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6457: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_xopen_source=no
+MANPAGE_SYMLINKS=no
+if test "$MANPAGE_ALIASES" = yes ; then
+echo "$as_me:7609: checking if manpage symlinks should be used" >&5
+echo $ECHO_N "checking if manpage symlinks should be used... $ECHO_C" >&6
+
+# Check whether --with-manpage-symlinks or --without-manpage-symlinks was given.
+if test "${with_manpage_symlinks+set}" = set; then
+  withval="$with_manpage_symlinks"
+  MANPAGE_SYMLINKS=$withval
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_xopen_source=yes
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	CPPFLAGS="$cf_save"
+  MANPAGE_SYMLINKS=$cf_use_symlinks
+fi;
 
+if test "$$cf_use_symlinks" = no; then
+if test "$MANPAGE_SYMLINKS" = yes ; then
+	{ echo "$as_me:7622: WARNING: cannot make symlinks" >&5
+echo "$as_me: WARNING: cannot make symlinks" >&2;}
+	MANPAGE_SYMLINKS=no
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-
 fi
-echo "$as_me:6472: result: $cf_cv_xopen_source" >&5
-echo "${ECHO_T}$cf_cv_xopen_source" >&6
-test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
-	;;
-esac
 
-# use these variables to work around a defect in gcc's fixincludes.
-NCURSES_OK_WCHAR_T=
-NCURSES_OK_WINT_T=
+echo "$as_me:7628: result: $MANPAGE_SYMLINKS" >&5
+echo "${ECHO_T}$MANPAGE_SYMLINKS" >&6
+fi
 
-echo "$as_me:6482: checking if you want experimental wide-character code" >&5
-echo $ECHO_N "checking if you want experimental wide-character code... $ECHO_C" >&6
+echo "$as_me:7632: checking for manpage tbl" >&5
+echo $ECHO_N "checking for manpage tbl... $ECHO_C" >&6
 
-# Check whether --enable-widec or --disable-widec was given.
-if test "${enable_widec+set}" = set; then
-  enableval="$enable_widec"
-  with_widec=$enableval
+# Check whether --with-manpage-tbl or --without-manpage-tbl was given.
+if test "${with_manpage_tbl+set}" = set; then
+  withval="$with_manpage_tbl"
+  MANPAGE_TBL=$withval
 else
-  with_widec=no
+  MANPAGE_TBL=no
 fi;
-echo "$as_me:6492: result: $with_widec" >&5
-echo "${ECHO_T}$with_widec" >&6
-if test "$with_widec" = yes ; then
-	LIB_SUFFIX="w${LIB_SUFFIX}"
-	cat >>confdefs.h <<\EOF
-#define USE_WIDEC_SUPPORT 1
-EOF
 
-echo "$as_me:6500: checking if we must define _XOPEN_SOURCE" >&5
-echo $ECHO_N "checking if we must define _XOPEN_SOURCE... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 6503 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
+echo "$as_me:7643: result: $MANPAGE_TBL" >&5
+echo "${ECHO_T}$MANPAGE_TBL" >&6
 
-int
-main ()
-{
+  if test "$prefix" = "NONE" ; then
+     cf_prefix="$ac_default_prefix"
+  else
+     cf_prefix="$prefix"
+  fi
 
-#ifndef _XOPEN_SOURCE
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6519: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6522: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6525: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6528: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=no
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=yes
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:6537: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
+  case "$MANPAGE_FORMAT" in # (vi
+  *catonly*) # (vi
+    cf_format=yes
+    cf_inboth=no
+    ;;
+  *formatted*) # (vi
+    cf_format=yes
+    cf_inboth=yes
+    ;;
+  *)
+    cf_format=no
+    cf_inboth=no
+    ;;
+  esac
+
+test ! -d man && mkdir man
+
+cf_so_strip=
+cf_compress=
+case "$MANPAGE_FORMAT" in #(vi
+*compress*) #(vi
+	cf_so_strip="Z"
+	cf_compress=compress
+  ;;
+*gzip*) #(vi
+	cf_so_strip="gz"
+	cf_compress=gzip
+  ;;
+esac
 
-if test "$cf_result" = yes ; then
-	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
-elif test "x500" != "x" ; then
-	echo "$as_me:6543: checking checking for compatible value versus 500" >&5
-echo $ECHO_N "checking checking for compatible value versus 500... $ECHO_C" >&6
-	cat >conftest.$ac_ext <<_ACEOF
-#line 6546 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
+cf_edit_man=man/edit_man.sh
 
-int
-main ()
-{
+cat >$cf_edit_man <<CF_EOF
+#! /bin/sh
+# this script is generated by the configure-script CF_MAN_PAGES macro.
+prefix="$cf_prefix"
+datadir="$datadir"
+NCURSES_OSPEED="$NCURSES_OSPEED"
+TERMINFO="$TERMINFO"
+MKDIRS="sh `cd $srcdir && pwd`/mkinstalldirs"
+INSTALL="$INSTALL"
+INSTALL_DATA="$INSTALL_DATA"
+transform="$program_transform_name"
 
-#if _XOPEN_SOURCE-500 < 0
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6562: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6565: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6568: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6571: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	echo "$as_me:6580: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-	if test "$cf_result" = no ; then
-		# perhaps we can override it - try...
-		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
-	fi
-fi
+TMP=\${TMPDIR-/tmp}/man\$\$
+trap "rm -f \$TMP" 0 1 2 5 15
 
-echo "$as_me:6588: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
-echo $ECHO_N "checking if we must define _XOPEN_SOURCE_EXTENDED... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-#line 6591 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
+form=\$1
+shift || exit 1
 
-int
-main ()
-{
+verb=\$1
+shift || exit 1
 
-#ifndef _XOPEN_SOURCE_EXTENDED
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6607: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6610: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6613: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6616: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=no
+mandir=\$1
+shift || exit 1
+
+srcdir=\$1
+shift || exit 1
+
+if test "\$form" = normal ; then
+	if test "$cf_format" = yes ; then
+	if test "$cf_inboth" = no ; then
+		sh \$0 format \$verb \$mandir \$srcdir \$*
+		exit $?
+	fi
+	fi
+	cf_subdir=\$mandir/man
+	cf_tables=$MANPAGE_TBL
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=yes
+	cf_subdir=\$mandir/cat
+	cf_tables=yes
 fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:6625: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
 
-if test "$cf_result" = yes ; then
-	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
-elif test "x" != "x" ; then
-	echo "$as_me:6631: checking checking for compatible value versus " >&5
-echo $ECHO_N "checking checking for compatible value versus ... $ECHO_C" >&6
-	cat >conftest.$ac_ext <<_ACEOF
-#line 6634 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
+# process the list of source-files
+for i in \$* ; do
+case \$i in #(vi
+*.orig|*.rej) ;; #(vi
+*.[0-9]*)
+	section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
+	if test \$verb = installing ; then
+	if test ! -d \$cf_subdir\${section} ; then
+		\$MKDIRS \$cf_subdir\$section
+	fi
+	fi
+	aliases=
+	source=\`basename \$i\`
+	inalias=\$source
+	test ! -f \$inalias && inalias="\$srcdir/\$inalias"
+	if test ! -f \$inalias ; then
+		echo .. skipped \$source
+		continue
+	fi
+CF_EOF
 
-int
-main ()
-{
+if test "$MANPAGE_ALIASES" != no ; then
+cat >>$cf_edit_man <<CF_EOF
+	aliases=\`sed -f \$srcdir/manlinks.sed \$inalias | sort -u\`
+CF_EOF
+fi
 
-#if _XOPEN_SOURCE_EXTENDED- < 0
-make an error
-#endif
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6650: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6653: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6656: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6659: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_result=yes
+if test "$MANPAGE_RENAMES" = no ; then
+cat >>$cf_edit_man <<CF_EOF
+	# perform program transformations for section 1 man pages
+	if test \$section = 1 ; then
+		target=\$cf_subdir\${section}/\`echo \$source|sed "\${transform}"\`
+	else
+		target=\$cf_subdir\${section}/\$source
+	fi
+CF_EOF
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_result=no
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-	echo "$as_me:6668: result: $cf_result" >&5
-echo "${ECHO_T}$cf_result" >&6
-	if test "$cf_result" = no ; then
-		# perhaps we can override it - try...
-		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED="
+cat >>$cf_edit_man <<CF_EOF
+	target=\`grep "^\$source" $MANPAGE_RENAMES | $AWK '{print \$2}'\`
+	if test -z "\$target" ; then
+		echo '? missing rename for '\$source
+		target="\$source"
 	fi
+	target="\$cf_subdir\${section}/\${target}"
+CF_EOF
 fi
 
-	# with_overwrite=no
-	NCURSES_CH_T=cchar_t
+	# replace variables in man page
 
-for ac_func in putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:6682: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-#line 6688 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.  */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-char (*f) ();
+	for cf_name in  captoinfo clear infocmp infotocap tic toe tput
+	do
+cat >>$cf_edit_man <<CF_EOF
+	prog_$cf_name=\`echo $cf_name|sed "\${transform}"\`
+CF_EOF
+	done
 
-int
-main ()
-{
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-f = $ac_func;
-#endif
+cat >>$cf_edit_man <<CF_EOF
+	sed	-e "s,@DATADIR@,\$datadir," \\
+		-e "s,@TERMINFO@,\$TERMINFO," \\
+		-e "s,@NCURSES_OSPEED@,\$NCURSES_OSPEED," \\
+CF_EOF
 
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:6719: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:6722: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:6725: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6728: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
+	for cf_name in  captoinfo clear infocmp infotocap tic toe tput
+	do
+		cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+cat >>$cf_edit_man <<CF_EOF
+		-e "s,@$cf_NAME@,\$prog_$cf_name," \\
+CF_EOF
+	done
+
+if test -f $MANPAGE_RENAMES ; then
+cat >>$cf_edit_man <<CF_EOF
+		< \$i | sed -f $srcdir/edit_man.sed >\$TMP
+CF_EOF
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-eval "$as_ac_var=no"
+cat >>$cf_edit_man <<CF_EOF
+		< \$i >\$TMP
+CF_EOF
 fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+
+cat >>$cf_edit_man <<CF_EOF
+if test \$cf_tables = yes ; then
+	tbl \$TMP >\$TMP.out
+	mv \$TMP.out \$TMP
 fi
-echo "$as_me:6738: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<EOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-EOF
+CF_EOF
 
+if test $with_curses_h != yes ; then
+cat >>$cf_edit_man <<CF_EOF
+	sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
+	mv \$TMP.out \$TMP
+CF_EOF
 fi
-done
 
-	if test "$ac_cv_func_putwc" != yes ; then
+cat >>$cf_edit_man <<CF_EOF
+	if test \$form = format ; then
+		nroff -man \$TMP >\$TMP.out
+		mv \$TMP.out \$TMP
+	fi
+CF_EOF
 
-echo "$as_me:6750: checking for putwc in libutf8" >&5
-echo $ECHO_N "checking for putwc in libutf8... $ECHO_C" >&6
-if test "${cf_cv_libutf8+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+if test -n "$cf_compress" ; then
+cat >>$cf_edit_man <<CF_EOF
+	if test \$verb = installing ; then
+	if ( $cf_compress -f \$TMP )
+	then
+		mv \$TMP.$cf_so_strip \$TMP
+	fi
+	fi
+	target="\$target.$cf_so_strip"
+CF_EOF
+fi
 
-	cf_save_LIBS="$LIBS"
-	LIBS="-lutf8 $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-#line 6759 "configure"
-#include "confdefs.h"
+case "$MANPAGE_FORMAT" in #(vi
+*BSDI*)
+cat >>$cf_edit_man <<CF_EOF
+	if test \$form = format ; then
+		# BSDI installs only .0 suffixes in the cat directories
+		target="\`echo \$target|sed -e 's/\.[1-9]\+[a-z]*/.0/'\`"
+	fi
+CF_EOF
+  ;;
+esac
 
-#include <libutf8.h>
-int
-main ()
-{
-putwc(0,0);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:6772: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  echo "$as_me:6775: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:6778: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6781: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_libutf8=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_libutf8=no
-fi
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
-	LIBS="$cf_save_LIBS"
+cat >>$cf_edit_man <<CF_EOF
+	suffix=\`basename \$target | sed -e 's%^[^.]*%%'\`
+	if test \$verb = installing ; then
+		echo \$verb \$target
+		\$INSTALL_DATA \$TMP \$target
+		test -n "\$aliases" && (
+			cd \$cf_subdir\${section} && (
+				source=\`echo \$target |sed -e 's%^.*/\([^/][^/]*/[^/][^/]*$\)%\1%'\`
+				test -n "$cf_so_strip" && source=\`echo \$source |sed -e 's%\.$cf_so_strip\$%%'\`
+				target=\`basename \$target\`
+				for cf_alias in \$aliases
+				do
+					if test \$section = 1 ; then
+						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
+					fi
 
+					if test "$MANPAGE_SYMLINKS" = yes ; then
+						if test -f \$cf_alias\${suffix} ; then
+							if ( cmp -s \$target \$cf_alias\${suffix} )
+							then
+								continue
+							fi
+						fi
+						echo .. \$verb alias \$cf_alias\${suffix}
+						rm -f \$cf_alias\${suffix}
+						$LN_S \$target \$cf_alias\${suffix}
+					elif test "\$target" != "\$cf_alias\${suffix}" ; then
+						echo ".so \$source" >\$TMP
+CF_EOF
+if test -n "$cf_compress" ; then
+cat >>$cf_edit_man <<CF_EOF
+						if test -n "$cf_so_strip" ; then
+							$cf_compress -f \$TMP
+							mv \$TMP.$cf_so_strip \$TMP
+						fi
+CF_EOF
 fi
-echo "$as_me:6793: result: $cf_cv_libutf8" >&5
-echo "${ECHO_T}$cf_cv_libutf8" >&6
+cat >>$cf_edit_man <<CF_EOF
+						echo .. \$verb alias \$cf_alias\${suffix}
+						rm -f \$cf_alias\${suffix}
+						\$INSTALL_DATA \$TMP \$cf_alias\${suffix}
+					fi
+				done
+			)
+		)
+	elif test \$verb = removing ; then
+		echo \$verb \$target
+		rm -f \$target
+		test -n "\$aliases" && (
+			cd \$cf_subdir\${section} && (
+				for cf_alias in \$aliases
+				do
+					if test \$section = 1 ; then
+						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
+					fi
 
-if test "$cf_cv_libutf8" = yes ; then
-	cat >>confdefs.h <<\EOF
-#define HAVE_LIBUTF8_H 1
-EOF
+					echo .. \$verb alias \$cf_alias\${suffix}
+					rm -f \$cf_alias\${suffix}
+				done
+			)
+		)
+	else
+#		echo ".hy 0"
+		cat \$TMP
+	fi
+	;;
+esac
+done
 
-	LIBS="-lutf8 $LIBS"
+if test $cf_inboth = yes ; then
+if test \$form != format ; then
+	sh \$0 format \$verb \$mandir \$srcdir \$*
+fi
 fi
 
-		if test "$cf_cv_libutf8" = yes ; then
-			NCURSES_LIBUTF8=1
-		fi
-	fi
+exit 0
+CF_EOF
+chmod 755 $cf_edit_man
 
-# This is needed on Tru64 5.0 to declare mbstate_t
-echo "$as_me:6810: checking if we must include wchar.h to declare mbstate_t" >&5
-echo $ECHO_N "checking if we must include wchar.h to declare mbstate_t... $ECHO_C" >&6
-if test "${cf_cv_mbstate_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
+###############################################################################
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 6817 "configure"
-#include "confdefs.h"
+### Note that some functions (such as const) are normally disabled anyway.
+echo "$as_me:7931: checking if you want to build with function extensions" >&5
+echo $ECHO_N "checking if you want to build with function extensions... $ECHO_C" >&6
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
-int
-main ()
-{
-mbstate_t state
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6835: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6838: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6841: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6844: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_mbstate_t=no
+# Check whether --enable-ext-funcs or --disable-ext-funcs was given.
+if test "${enable_ext_funcs+set}" = set; then
+  enableval="$enable_ext_funcs"
+  with_ext_funcs=$enableval
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cat >conftest.$ac_ext <<_ACEOF
-#line 6851 "configure"
-#include "confdefs.h"
+  with_ext_funcs=yes
+fi;
+echo "$as_me:7941: result: $with_ext_funcs" >&5
+echo "${ECHO_T}$with_ext_funcs" >&6
+if test "$with_ext_funcs" = yes ; then
+	NCURSES_EXT_FUNCS=1
+	cat >>confdefs.h <<\EOF
+#define HAVE_CURSES_VERSION 1
+EOF
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
-int
-main ()
-{
-mbstate_t value
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6870: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6873: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6876: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6879: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_mbstate_t=yes
-else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_mbstate_t=unknown
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:6891: result: $cf_cv_mbstate_t" >&5
-echo "${ECHO_T}$cf_cv_mbstate_t" >&6
+	cat >>confdefs.h <<\EOF
+#define HAVE_HAS_KEY 1
+EOF
+
+	cat >>confdefs.h <<\EOF
+#define HAVE_RESIZETERM 1
+EOF
+
+	cat >>confdefs.h <<\EOF
+#define HAVE_RESIZE_TERM 1
+EOF
 
-if test "$cf_cv_mbstate_t" = yes ; then
 	cat >>confdefs.h <<\EOF
-#define NEED_WCHAR_H 1
+#define HAVE_USE_DEFAULT_COLORS 1
 EOF
 
-	NEED_WCHAR_H=1
+	cat >>confdefs.h <<\EOF
+#define HAVE_WRESIZE 1
+EOF
+
+	cat >>confdefs.h <<\EOF
+#define NCURSES_EXT_FUNCS 1
+EOF
+
+else
+	NCURSES_EXT_FUNCS=0
 fi
 
-# if we do not find mbstate_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_mbstate_t" = unknown ; then
-	NCURSES_MBSTATE_T=1
+###   use option --enable-const to turn on use of const beyond that in XSI.
+echo "$as_me:7978: checking for extended use of const keyword" >&5
+echo $ECHO_N "checking for extended use of const keyword... $ECHO_C" >&6
+
+# Check whether --enable-const or --disable-const was given.
+if test "${enable_const+set}" = set; then
+  enableval="$enable_const"
+  with_ext_const=$enableval
+else
+  with_ext_const=no
+fi;
+echo "$as_me:7988: result: $with_ext_const" >&5
+echo "${ECHO_T}$with_ext_const" >&6
+NCURSES_CONST='/*nothing*/'
+if test "$with_ext_const" = yes ; then
+	NCURSES_CONST=const
 fi
 
-# This is needed on Tru64 5.0 to declare wchar_t
-echo "$as_me:6908: checking if we must include wchar.h to declare wchar_t" >&5
-echo $ECHO_N "checking if we must include wchar.h to declare wchar_t... $ECHO_C" >&6
-if test "${cf_cv_wchar_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+echo "$as_me:7995: checking if you want \$NCURSES_NO_PADDING code" >&5
+echo $ECHO_N "checking if you want \$NCURSES_NO_PADDING code... $ECHO_C" >&6
+
+# Check whether --enable-no-padding or --disable-no-padding was given.
+if test "${enable_no_padding+set}" = set; then
+  enableval="$enable_no_padding"
+  with_no_padding=$enableval
 else
+  with_no_padding=$with_ext_funcs
+fi;
+echo "$as_me:8005: result: $with_no_padding" >&5
+echo "${ECHO_T}$with_no_padding" >&6
+test "$with_no_padding" = yes && cat >>confdefs.h <<\EOF
+#define NCURSES_NO_PADDING 1
+EOF
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 6915 "configure"
-#include "confdefs.h"
+###   use option --enable-sigwinch to turn on use of SIGWINCH logic
+echo "$as_me:8012: checking if you want SIGWINCH handler" >&5
+echo $ECHO_N "checking if you want SIGWINCH handler... $ECHO_C" >&6
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
-int
-main ()
-{
-wchar_t state
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6933: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6936: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6939: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6942: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_wchar_t=no
+# Check whether --enable-sigwinch or --disable-sigwinch was given.
+if test "${enable_sigwinch+set}" = set; then
+  enableval="$enable_sigwinch"
+  with_sigwinch=$enableval
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cat >conftest.$ac_ext <<_ACEOF
-#line 6949 "configure"
-#include "confdefs.h"
+  with_sigwinch=$with_ext_funcs
+fi;
+echo "$as_me:8022: result: $with_sigwinch" >&5
+echo "${ECHO_T}$with_sigwinch" >&6
+test "$with_sigwinch" = yes && cat >>confdefs.h <<\EOF
+#define USE_SIGWINCH 1
+EOF
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
-int
-main ()
-{
-wchar_t value
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:6968: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:6971: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:6974: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:6977: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_wchar_t=yes
+###   use option --enable-tcap-names to allow user to define new capabilities
+echo "$as_me:8029: checking if you want user-definable terminal capabilities like termcap" >&5
+echo $ECHO_N "checking if you want user-definable terminal capabilities like termcap... $ECHO_C" >&6
+
+# Check whether --enable-tcap-names or --disable-tcap-names was given.
+if test "${enable_tcap_names+set}" = set; then
+  enableval="$enable_tcap_names"
+  with_tcap_names=$enableval
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_wchar_t=unknown
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:6989: result: $cf_cv_wchar_t" >&5
-echo "${ECHO_T}$cf_cv_wchar_t" >&6
+  with_tcap_names=$with_ext_funcs
+fi;
+echo "$as_me:8039: result: $with_tcap_names" >&5
+echo "${ECHO_T}$with_tcap_names" >&6
+NCURSES_XNAMES=0
+test "$with_tcap_names" = yes && NCURSES_XNAMES=1
 
-if test "$cf_cv_wchar_t" = yes ; then
-	cat >>confdefs.h <<\EOF
-#define NEED_WCHAR_H 1
-EOF
+###############################################################################
+# These options are relatively safe to experiment with.
 
-	NEED_WCHAR_H=1
-fi
+echo "$as_me:8047: checking if you want all development code" >&5
+echo $ECHO_N "checking if you want all development code... $ECHO_C" >&6
 
-# if we do not find wchar_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_wchar_t" = unknown ; then
-	NCURSES_WCHAR_T=1
-fi
+# Check whether --with-develop or --without-develop was given.
+if test "${with_develop+set}" = set; then
+  withval="$with_develop"
+  with_develop=$withval
+else
+  with_develop=no
+fi;
+echo "$as_me:8057: result: $with_develop" >&5
+echo "${ECHO_T}$with_develop" >&6
 
-# if we find wchar_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_wchar_t" != unknown ; then
-	NCURSES_OK_WCHAR_T=1
-fi
+###   use option --enable-hard-tabs to turn on use of hard-tabs optimize
+echo "$as_me:8061: checking if you want hard-tabs code" >&5
+echo $ECHO_N "checking if you want hard-tabs code... $ECHO_C" >&6
 
-# This is needed on Tru64 5.0 to declare wint_t
-echo "$as_me:7011: checking if we must include wchar.h to declare wint_t" >&5
-echo $ECHO_N "checking if we must include wchar.h to declare wint_t... $ECHO_C" >&6
-if test "${cf_cv_wint_t+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
+# Check whether --enable-hard-tabs or --disable-hard-tabs was given.
+if test "${enable_hard_tabs+set}" = set; then
+  enableval="$enable_hard_tabs"
+  with_hardtabs=$enableval
 else
+  with_hardtabs=$with_develop
+fi;
+echo "$as_me:8071: result: $with_hardtabs" >&5
+echo "${ECHO_T}$with_hardtabs" >&6
+test "$with_hardtabs" = yes && cat >>confdefs.h <<\EOF
+#define USE_HARD_TABS 1
+EOF
 
-cat >conftest.$ac_ext <<_ACEOF
-#line 7018 "configure"
-#include "confdefs.h"
+###   use option --enable-xmc-glitch to turn on use of magic-cookie optimize
+echo "$as_me:8078: checking if you want limited support for xmc" >&5
+echo $ECHO_N "checking if you want limited support for xmc... $ECHO_C" >&6
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
-int
-main ()
-{
-wint_t state
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7036: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:7039: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7042: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:7045: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_wint_t=no
+# Check whether --enable-xmc-glitch or --disable-xmc-glitch was given.
+if test "${enable_xmc_glitch+set}" = set; then
+  enableval="$enable_xmc_glitch"
+  with_xmc_glitch=$enableval
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cat >conftest.$ac_ext <<_ACEOF
-#line 7052 "configure"
-#include "confdefs.h"
+  with_xmc_glitch=$with_develop
+fi;
+echo "$as_me:8088: result: $with_xmc_glitch" >&5
+echo "${ECHO_T}$with_xmc_glitch" >&6
+test "$with_xmc_glitch" = yes && cat >>confdefs.h <<\EOF
+#define USE_XMC_SUPPORT 1
+EOF
 
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <wchar.h>
-#ifdef HAVE_LIBUTF8_H
-#include <libutf8.h>
-#endif
-int
-main ()
-{
-wint_t value
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7071: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  echo "$as_me:7074: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-         { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7077: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:7080: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  cf_cv_wint_t=yes
+###############################################################################
+# These are just experimental, probably should not be in a package:
+
+echo "$as_me:8097: checking if you do not want to assume colors are white-on-black" >&5
+echo $ECHO_N "checking if you do not want to assume colors are white-on-black... $ECHO_C" >&6
+
+# Check whether --enable-assumed-color or --disable-assumed-color was given.
+if test "${enable_assumed_color+set}" = set; then
+  enableval="$enable_assumed_color"
+  with_assumed_color=$enableval
+else
+  with_assumed_color=yes
+fi;
+echo "$as_me:8107: result: $with_assumed_color" >&5
+echo "${ECHO_T}$with_assumed_color" >&6
+test "$with_assumed_color" = yes && cat >>confdefs.h <<\EOF
+#define USE_ASSUMED_COLOR 1
+EOF
+
+###   use option --enable-hashmap to turn on use of hashmap scrolling logic
+echo "$as_me:8114: checking if you want hashmap scrolling-optimization code" >&5
+echo $ECHO_N "checking if you want hashmap scrolling-optimization code... $ECHO_C" >&6
+
+# Check whether --enable-hashmap or --disable-hashmap was given.
+if test "${enable_hashmap+set}" = set; then
+  enableval="$enable_hashmap"
+  with_hashmap=$enableval
 else
-  echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-cf_cv_wint_t=unknown
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:7092: result: $cf_cv_wint_t" >&5
-echo "${ECHO_T}$cf_cv_wint_t" >&6
+  with_hashmap=yes
+fi;
+echo "$as_me:8124: result: $with_hashmap" >&5
+echo "${ECHO_T}$with_hashmap" >&6
+test "$with_hashmap" = yes && cat >>confdefs.h <<\EOF
+#define USE_HASHMAP 1
+EOF
 
-if test "$cf_cv_wint_t" = yes ; then
+###   use option --enable-colorfgbg to turn on use of $COLORFGBG environment
+echo "$as_me:8131: checking if you want colorfgbg code" >&5
+echo $ECHO_N "checking if you want colorfgbg code... $ECHO_C" >&6
+
+# Check whether --enable-colorfgbg or --disable-colorfgbg was given.
+if test "${enable_colorfgbg+set}" = set; then
+  enableval="$enable_colorfgbg"
+  with_colorfgbg=$enableval
+else
+  with_colorfgbg=no
+fi;
+echo "$as_me:8141: result: $with_colorfgbg" >&5
+echo "${ECHO_T}$with_colorfgbg" >&6
+test "$with_colorfgbg" = yes && cat >>confdefs.h <<\EOF
+#define USE_COLORFGBG 1
+EOF
+
+###   use option --enable-ext-colors to turn on use of colors beyond 16.
+echo "$as_me:8148: checking if you want to use experimental extended colors" >&5
+echo $ECHO_N "checking if you want to use experimental extended colors... $ECHO_C" >&6
+
+# Check whether --enable-ext-colors or --disable-ext-colors was given.
+if test "${enable_ext_colors+set}" = set; then
+  enableval="$enable_ext_colors"
+  with_ext_colors=$enableval
+else
+  with_ext_colors=no
+fi;
+echo "$as_me:8158: result: $with_ext_colors" >&5
+echo "${ECHO_T}$with_ext_colors" >&6
+NCURSES_EXT_COLORS=0
+if test "$with_ext_colors" = yes ; then
+	if test "$with_widec" != yes ; then
+		{ echo "$as_me:8163: WARNING: This option applies only to wide-character library" >&5
+echo "$as_me: WARNING: This option applies only to wide-character library" >&2;}
+	else
+		# cannot be ABI 5 since it changes sizeof(cchar_t)
+		case $cf_cv_rel_version in
+		5.*)
+			cf_cv_rel_version=6.0
+			cf_cv_abi_version=6
+			{ echo "$as_me:8171: WARNING: Overriding ABI version to $cf_cv_abi_version" >&5
+echo "$as_me: WARNING: Overriding ABI version to $cf_cv_abi_version" >&2;}
+			;;
+		esac
+	fi
+	NCURSES_EXT_COLORS=1
 	cat >>confdefs.h <<\EOF
-#define NEED_WCHAR_H 1
+#define NCURSES_EXT_COLORS 1
 EOF
 
-	NEED_WCHAR_H=1
 fi
 
-# if we do not find wint_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_wint_t" = unknown ; then
-	NCURSES_WINT_T=1
-fi
+###   use option --enable-ext-mouse to modify coding to support 5-button mice
+echo "$as_me:8184: checking if you want to use experimental extended mouse encoding" >&5
+echo $ECHO_N "checking if you want to use experimental extended mouse encoding... $ECHO_C" >&6
 
-# if we find wint_t in either place, use substitution to provide a fallback.
-if test "$cf_cv_wint_t" != unknown ; then
-	NCURSES_OK_WINT_T=1
+# Check whether --enable-ext-mouse or --disable-ext-mouse was given.
+if test "${enable_ext_mouse+set}" = set; then
+  enableval="$enable_ext_mouse"
+  with_ext_mouse=$enableval
+else
+  with_ext_mouse=no
+fi;
+echo "$as_me:8194: result: $with_ext_mouse" >&5
+echo "${ECHO_T}$with_ext_mouse" >&6
+NCURSES_MOUSE_VERSION=1
+if test "$with_ext_mouse" = yes ; then
+	NCURSES_MOUSE_VERSION=2
 fi
 
-fi
+echo "$as_me:8201: checking if you want experimental safe-sprintf code" >&5
+echo $ECHO_N "checking if you want experimental safe-sprintf code... $ECHO_C" >&6
+
+# Check whether --enable-safe-sprintf or --disable-safe-sprintf was given.
+if test "${enable_safe_sprintf+set}" = set; then
+  enableval="$enable_safe_sprintf"
+  with_safe_sprintf=$enableval
+else
+  with_safe_sprintf=no
+fi;
+echo "$as_me:8211: result: $with_safe_sprintf" >&5
+echo "${ECHO_T}$with_safe_sprintf" >&6
+test "$with_safe_sprintf" = yes && cat >>confdefs.h <<\EOF
+#define USE_SAFE_SPRINTF 1
+EOF
 
-echo "$as_me:7115: checking for terminal capabilities file" >&5
-echo $ECHO_N "checking for terminal capabilities file... $ECHO_C" >&6
+###   use option --disable-scroll-hints to turn off use of scroll-hints scrolling logic
+# when hashmap is used scroll hints are useless
+if test "$with_hashmap" = no ; then
+echo "$as_me:8220: checking if you want to experiment without scrolling-hints code" >&5
+echo $ECHO_N "checking if you want to experiment without scrolling-hints code... $ECHO_C" >&6
 
-# Check whether --with-caps or --without-caps was given.
-if test "${with_caps+set}" = set; then
-  withval="$with_caps"
-  TERMINFO_CAPS=Caps.$withval
+# Check whether --enable-scroll-hints or --disable-scroll-hints was given.
+if test "${enable_scroll_hints+set}" = set; then
+  enableval="$enable_scroll_hints"
+  with_scroll_hints=$enableval
 else
-  TERMINFO_CAPS=Caps
+  with_scroll_hints=yes
 fi;
-test -f ${srcdir}/include/${TERMINFO_CAPS} || TERMINFO_CAPS=Caps
-echo "$as_me:7126: result: $TERMINFO_CAPS" >&5
-echo "${ECHO_T}$TERMINFO_CAPS" >&6
+echo "$as_me:8230: result: $with_scroll_hints" >&5
+echo "${ECHO_T}$with_scroll_hints" >&6
+test "$with_scroll_hints" = yes && cat >>confdefs.h <<\EOF
+#define USE_SCROLL_HINTS 1
+EOF
+
+fi
 
 ###############################################################################
 
 ###	use option --disable-echo to suppress full display compiling commands
-echo "$as_me:7132: checking if you want to display full commands during build" >&5
+echo "$as_me:8241: checking if you want to display full commands during build" >&5
 echo $ECHO_N "checking if you want to display full commands during build... $ECHO_C" >&6
 
 # Check whether --enable-echo or --disable-echo was given.
@@ -7145,11 +8254,11 @@
 	ECHO_LINK='@ echo linking $@ ... ;'
 	test -n "$LIBTOOL" && LIBTOOL="$LIBTOOL --silent"
 fi
-echo "$as_me:7148: result: $with_echo" >&5
+echo "$as_me:8257: result: $with_echo" >&5
 echo "${ECHO_T}$with_echo" >&6
 
 ###	use option --enable-warnings to turn on all gcc warnings
-echo "$as_me:7152: checking if you want to see compiler warnings" >&5
+echo "$as_me:8261: checking if you want to see compiler warnings" >&5
 echo $ECHO_N "checking if you want to see compiler warnings... $ECHO_C" >&6
 
 # Check whether --enable-warnings or --disable-warnings was given.
@@ -7157,19 +8266,37 @@
   enableval="$enable_warnings"
   with_warnings=$enableval
 fi;
-echo "$as_me:7160: result: $with_warnings" >&5
+echo "$as_me:8269: result: $with_warnings" >&5
 echo "${ECHO_T}$with_warnings" >&6
 
 if test -n "$with_warnings"; then
  	ADAFLAGS="$ADAFLAGS -gnatg"
 
-if test "$GCC" = yes
+if test "$INTEL_COMPILER" = yes
+then
+# The "-wdXXX" options suppress warnings:
+# remark #1419: external declaration in primary source file
+# remark #193: zero used for undefined preprocessing identifier
+# remark #593: variable "curs_sb_left_arrow" was set but never used
+# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
+# remark #869: parameter "tw" was never referenced
+# remark #981: operands are evaluated in unspecified order
+# warning #269: invalid format string conversion
+	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall \
+ -wd1419 \
+ -wd193 \
+ -wd279 \
+ -wd593 \
+ -wd810 \
+ -wd869 \
+ -wd981"
+elif test "$GCC" = yes
 then
 	cat > conftest.$ac_ext <<EOF
-#line 7169 "configure"
+#line 8296 "configure"
 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
 EOF
-	{ echo "$as_me:7172: checking for $CC warning options..." >&5
+	{ echo "$as_me:8299: checking for $CC warning options..." >&5
 echo "$as_me: checking for $CC warning options..." >&6;}
 	cf_save_CFLAGS="$CFLAGS"
 	EXTRA_CFLAGS="-W -Wall"
@@ -7189,12 +8316,12 @@
 		Wundef $cf_warn_CONST
 	do
 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
-		if { (eval echo "$as_me:7192: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:8319: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7195: \$? = $ac_status" >&5
+  echo "$as_me:8322: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-			test -n "$verbose" && echo "$as_me:7197: result: ... -$cf_opt" >&5
+			test -n "$verbose" && echo "$as_me:8324: result: ... -$cf_opt" >&5
 echo "${ECHO_T}... -$cf_opt" >&6
 			case $cf_opt in #(vi
 			Wcast-qual) #(vi
@@ -7216,6 +8343,84 @@
 	CFLAGS="$cf_save_CFLAGS"
 fi
 
+	if test "$cf_with_cxx" = yes ; then
+
+ac_ext=cc
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+if test "$INTEL_COMPILER" = yes
+then
+# The "-wdXXX" options suppress warnings:
+# remark #1419: external declaration in primary source file
+# remark #193: zero used for undefined preprocessing identifier
+# remark #593: variable "curs_sb_left_arrow" was set but never used
+# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
+# remark #869: parameter "tw" was never referenced
+# remark #981: operands are evaluated in unspecified order
+# warning #269: invalid format string conversion
+	EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -Wall \
+ -wd1419 \
+ -wd193 \
+ -wd279 \
+ -wd593 \
+ -wd810 \
+ -wd869 \
+ -wd981"
+elif test "$GXX" = yes
+then
+	cat > conftest.$ac_ext <<EOF
+#line 8375 "configure"
+int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
+EOF
+	{ echo "$as_me:8378: checking for $CXX warning options..." >&5
+echo "$as_me: checking for $CXX warning options..." >&6;}
+	cf_save_CXXFLAGS="$CXXFLAGS"
+	EXTRA_CXXFLAGS="-W -Wall"
+	cf_warn_CONST=""
+	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
+	for cf_opt in \
+		Wabi \
+		fabi-version=0 \
+		Woverloaded-virtual \
+		Wsign-promo \
+		Wsynth \
+		Wold-style-cast \
+		Weffc++ \
+		Wcast-align \
+		Wcast-qual \
+		Wmissing-prototypes \
+		Wpointer-arith \
+		Wshadow \
+		Wstrict-prototypes \
+		Wundef $cf_warn_CONST Wno-unused
+	do
+		CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
+		if { (eval echo "$as_me:8401: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:8404: \$? = $ac_status" >&5
+  (exit $ac_status); }; then
+			test -n "$verbose" && echo "$as_me:8406: result: ... -$cf_opt" >&5
+echo "${ECHO_T}... -$cf_opt" >&6
+			EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
+		else
+			test -n "$verbose" && echo "$as_me:8410: result: ... no -$cf_opt" >&5
+echo "${ECHO_T}... no -$cf_opt" >&6
+		fi
+	done
+	rm -f conftest*
+	CXXFLAGS="$cf_save_CXXFLAGS"
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+	fi
 fi
 
 if test "$GCC" = yes
@@ -7236,10 +8441,10 @@
 EOF
 if test "$GCC" = yes
 then
-	{ echo "$as_me:7239: checking for $CC __attribute__ directives..." >&5
+	{ echo "$as_me:8444: checking for $CC __attribute__ directives..." >&5
 echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
 cat > conftest.$ac_ext <<EOF
-#line 7242 "configure"
+#line 8447 "configure"
 #include "confdefs.h"
 #include "conftest.h"
 #include "conftest.i"
@@ -7277,12 +8482,12 @@
 EOF
 			;;
 		esac
-		if { (eval echo "$as_me:7280: \"$ac_compile\"") >&5
+		if { (eval echo "$as_me:8485: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7283: \$? = $ac_status" >&5
+  echo "$as_me:8488: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-			test -n "$verbose" && echo "$as_me:7285: result: ... $cf_attribute" >&5
+			test -n "$verbose" && echo "$as_me:8490: result: ... $cf_attribute" >&5
 echo "${ECHO_T}... $cf_attribute" >&6
 			cat conftest.h >>confdefs.h
 		fi
@@ -7294,7 +8499,7 @@
 fi
 
 ###	use option --enable-assertions to turn on generation of assertion code
-echo "$as_me:7297: checking if you want to enable runtime assertions" >&5
+echo "$as_me:8502: checking if you want to enable runtime assertions" >&5
 echo $ECHO_N "checking if you want to enable runtime assertions... $ECHO_C" >&6
 
 # Check whether --enable-assertions or --disable-assertions was given.
@@ -7304,7 +8509,7 @@
 else
   with_assertions=no
 fi;
-echo "$as_me:7307: result: $with_assertions" >&5
+echo "$as_me:8512: result: $with_assertions" >&5
 echo "${ECHO_T}$with_assertions" >&6
 if test -n "$GCC"
 then
@@ -7365,7 +8570,7 @@
 	;;
 esac
 
-echo "$as_me:7368: checking whether to add trace feature to all models" >&5
+echo "$as_me:8573: checking whether to add trace feature to all models" >&5
 echo $ECHO_N "checking whether to add trace feature to all models... $ECHO_C" >&6
 
 # Check whether --with-trace or --without-trace was given.
@@ -7375,19 +8580,41 @@
 else
   cf_with_trace=$cf_all_traces
 fi;
-echo "$as_me:7378: result: $with_trace" >&5
+echo "$as_me:8583: result: $with_trace" >&5
 echo "${ECHO_T}$with_trace" >&6
 
 if test "$cf_with_trace" = yes ; then
 	LIB_TRACING=all
 	ADA_TRACE=TRUE
 
+cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
+cf_new_extra_cppflags=
+
 for cf_add_cflags in -DTRACE
 do
+case $cf_fix_cppflags in
+no)
 	case $cf_add_cflags in #(vi
 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+		case $cf_add_cflags in
+		-D*)
+			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+			&& test -z "${cf_tst_cflags}" \
+			&& cf_fix_cppflags=yes
+
+			if test $cf_fix_cppflags = yes ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			fi
+			;;
+		esac
 		case "$CPPFLAGS" in
 		*$cf_add_cflags) #(vi
 			;;
@@ -7400,6 +8627,17 @@
 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
 		;;
 	esac
+	;;
+yes)
+	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+	&& test -z "${cf_tst_cflags}" \
+	&& cf_fix_cppflags=no
+	;;
+esac
 done
 
 if test -n "$cf_new_cflags" ; then
@@ -7412,19 +8650,24 @@
 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
 fi
 
+if test -n "$cf_new_extra_cppflags" ; then
+
+	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
 else
 	LIB_TRACING=DEBUG
 	ADA_TRACE=FALSE
 fi
 
 ###	Checks for libraries.
-echo "$as_me:7421: checking for gettimeofday" >&5
+echo "$as_me:8664: checking for gettimeofday" >&5
 echo $ECHO_N "checking for gettimeofday... $ECHO_C" >&6
 if test "${ac_cv_func_gettimeofday+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7427 "configure"
+#line 8670 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gettimeofday (); below.  */
@@ -7455,16 +8698,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7458: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8701: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7461: \$? = $ac_status" >&5
+  echo "$as_me:8704: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7464: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8707: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7467: \$? = $ac_status" >&5
+  echo "$as_me:8710: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_func_gettimeofday=yes
 else
@@ -7474,7 +8717,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:7477: result: $ac_cv_func_gettimeofday" >&5
+echo "$as_me:8720: result: $ac_cv_func_gettimeofday" >&5
 echo "${ECHO_T}$ac_cv_func_gettimeofday" >&6
 if test $ac_cv_func_gettimeofday = yes; then
   cat >>confdefs.h <<\EOF
@@ -7483,7 +8726,7 @@
 
 else
 
-echo "$as_me:7486: checking for gettimeofday in -lbsd" >&5
+echo "$as_me:8729: checking for gettimeofday in -lbsd" >&5
 echo $ECHO_N "checking for gettimeofday in -lbsd... $ECHO_C" >&6
 if test "${ac_cv_lib_bsd_gettimeofday+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7491,7 +8734,7 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lbsd  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 7494 "configure"
+#line 8737 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7510,16 +8753,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7513: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8756: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7516: \$? = $ac_status" >&5
+  echo "$as_me:8759: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7519: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8762: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7522: \$? = $ac_status" >&5
+  echo "$as_me:8765: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_bsd_gettimeofday=yes
 else
@@ -7530,7 +8773,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7533: result: $ac_cv_lib_bsd_gettimeofday" >&5
+echo "$as_me:8776: result: $ac_cv_lib_bsd_gettimeofday" >&5
 echo "${ECHO_T}$ac_cv_lib_bsd_gettimeofday" >&6
 if test $ac_cv_lib_bsd_gettimeofday = yes; then
   cat >>confdefs.h <<\EOF
@@ -7542,14 +8785,14 @@
 
 fi
 
-echo "$as_me:7545: checking if -lm needed for math functions" >&5
+echo "$as_me:8788: checking if -lm needed for math functions" >&5
 echo $ECHO_N "checking if -lm needed for math functions... $ECHO_C" >&6
 if test "${cf_cv_need_libm+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 7552 "configure"
+#line 8795 "configure"
 #include "confdefs.h"
 
 	#include <stdio.h>
@@ -7564,16 +8807,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7567: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8810: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7570: \$? = $ac_status" >&5
+  echo "$as_me:8813: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7573: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8816: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7576: \$? = $ac_status" >&5
+  echo "$as_me:8819: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_need_libm=no
 else
@@ -7583,7 +8826,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:7586: result: $cf_cv_need_libm" >&5
+echo "$as_me:8829: result: $cf_cv_need_libm" >&5
 echo "${ECHO_T}$cf_cv_need_libm" >&6
 if test "$cf_cv_need_libm" = yes
 then
@@ -7591,13 +8834,13 @@
 fi
 
 ###	Checks for header files.
-echo "$as_me:7594: checking for ANSI C header files" >&5
+echo "$as_me:8837: checking for ANSI C header files" >&5
 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
 if test "${ac_cv_header_stdc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7600 "configure"
+#line 8843 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -7605,13 +8848,13 @@
 #include <float.h>
 
 _ACEOF
-if { (eval echo "$as_me:7608: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:8851: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:7614: \$? = $ac_status" >&5
+  echo "$as_me:8857: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -7633,7 +8876,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
   cat >conftest.$ac_ext <<_ACEOF
-#line 7636 "configure"
+#line 8879 "configure"
 #include "confdefs.h"
 #include <string.h>
 
@@ -7651,7 +8894,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
   cat >conftest.$ac_ext <<_ACEOF
-#line 7654 "configure"
+#line 8897 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 
@@ -7672,7 +8915,7 @@
   :
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7675 "configure"
+#line 8918 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #if ((' ' & 0x0FF) == 0x020)
@@ -7698,15 +8941,15 @@
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7701: \"$ac_link\"") >&5
+if { (eval echo "$as_me:8944: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7704: \$? = $ac_status" >&5
+  echo "$as_me:8947: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:7706: \"$ac_try\"") >&5
+  { (eval echo "$as_me:8949: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7709: \$? = $ac_status" >&5
+  echo "$as_me:8952: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   :
 else
@@ -7719,7 +8962,7 @@
 fi
 fi
 fi
-echo "$as_me:7722: result: $ac_cv_header_stdc" >&5
+echo "$as_me:8965: result: $ac_cv_header_stdc" >&5
 echo "${ECHO_T}$ac_cv_header_stdc" >&6
 if test $ac_cv_header_stdc = yes; then
 
@@ -7732,13 +8975,13 @@
 ac_header_dirent=no
 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
   as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
-echo "$as_me:7735: checking for $ac_hdr that defines DIR" >&5
+echo "$as_me:8978: checking for $ac_hdr that defines DIR" >&5
 echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7741 "configure"
+#line 8984 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -7753,16 +8996,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7756: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:8999: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7759: \$? = $ac_status" >&5
+  echo "$as_me:9002: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7762: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9005: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7765: \$? = $ac_status" >&5
+  echo "$as_me:9008: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_Header=yes"
 else
@@ -7772,7 +9015,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:7775: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:9018: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -7785,7 +9028,7 @@
 done
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
-  echo "$as_me:7788: checking for opendir in -ldir" >&5
+  echo "$as_me:9031: checking for opendir in -ldir" >&5
 echo $ECHO_N "checking for opendir in -ldir... $ECHO_C" >&6
 if test "${ac_cv_lib_dir_opendir+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7793,7 +9036,7 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-ldir  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 7796 "configure"
+#line 9039 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7812,16 +9055,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7815: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9058: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7818: \$? = $ac_status" >&5
+  echo "$as_me:9061: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7821: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9064: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7824: \$? = $ac_status" >&5
+  echo "$as_me:9067: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_dir_opendir=yes
 else
@@ -7832,14 +9075,14 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7835: result: $ac_cv_lib_dir_opendir" >&5
+echo "$as_me:9078: result: $ac_cv_lib_dir_opendir" >&5
 echo "${ECHO_T}$ac_cv_lib_dir_opendir" >&6
 if test $ac_cv_lib_dir_opendir = yes; then
   LIBS="$LIBS -ldir"
 fi
 
 else
-  echo "$as_me:7842: checking for opendir in -lx" >&5
+  echo "$as_me:9085: checking for opendir in -lx" >&5
 echo $ECHO_N "checking for opendir in -lx... $ECHO_C" >&6
 if test "${ac_cv_lib_x_opendir+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -7847,7 +9090,7 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lx  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 7850 "configure"
+#line 9093 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -7866,16 +9109,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7869: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9112: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7872: \$? = $ac_status" >&5
+  echo "$as_me:9115: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7875: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9118: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7878: \$? = $ac_status" >&5
+  echo "$as_me:9121: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_x_opendir=yes
 else
@@ -7886,7 +9129,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:7889: result: $ac_cv_lib_x_opendir" >&5
+echo "$as_me:9132: result: $ac_cv_lib_x_opendir" >&5
 echo "${ECHO_T}$ac_cv_lib_x_opendir" >&6
 if test $ac_cv_lib_x_opendir = yes; then
   LIBS="$LIBS -lx"
@@ -7894,13 +9137,13 @@
 
 fi
 
-echo "$as_me:7897: checking whether time.h and sys/time.h may both be included" >&5
+echo "$as_me:9140: checking whether time.h and sys/time.h may both be included" >&5
 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
 if test "${ac_cv_header_time+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 7903 "configure"
+#line 9146 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -7916,16 +9159,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:7919: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9162: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:7922: \$? = $ac_status" >&5
+  echo "$as_me:9165: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:7925: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9168: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7928: \$? = $ac_status" >&5
+  echo "$as_me:9171: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_header_time=yes
 else
@@ -7935,7 +9178,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:7938: result: $ac_cv_header_time" >&5
+echo "$as_me:9181: result: $ac_cv_header_time" >&5
 echo "${ECHO_T}$ac_cv_header_time" >&6
 if test $ac_cv_header_time = yes; then
 
@@ -7945,14 +9188,14 @@
 
 fi
 
-echo "$as_me:7948: checking for regular-expression headers" >&5
+echo "$as_me:9191: checking for regular-expression headers" >&5
 echo $ECHO_N "checking for regular-expression headers... $ECHO_C" >&6
 if test "${cf_cv_regex+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 7955 "configure"
+#line 9198 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <regex.h>
@@ -7970,16 +9213,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:7973: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9216: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:7976: \$? = $ac_status" >&5
+  echo "$as_me:9219: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:7979: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9222: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:7982: \$? = $ac_status" >&5
+  echo "$as_me:9225: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_regex="regex.h"
 else
@@ -7987,7 +9230,7 @@
 cat conftest.$ac_ext >&5
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 7990 "configure"
+#line 9233 "configure"
 #include "confdefs.h"
 #include <regexp.h>
 int
@@ -8002,16 +9245,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8005: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9248: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8008: \$? = $ac_status" >&5
+  echo "$as_me:9251: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8011: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9254: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8014: \$? = $ac_status" >&5
+  echo "$as_me:9257: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_regex="regexp.h"
 else
@@ -8021,7 +9264,7 @@
 		cf_save_LIBS="$LIBS"
 		LIBS="-lgen $LIBS"
 		cat >conftest.$ac_ext <<_ACEOF
-#line 8024 "configure"
+#line 9267 "configure"
 #include "confdefs.h"
 #include <regexpr.h>
 int
@@ -8036,16 +9279,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8039: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9282: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8042: \$? = $ac_status" >&5
+  echo "$as_me:9285: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8045: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9288: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8048: \$? = $ac_status" >&5
+  echo "$as_me:9291: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_regex="regexpr.h"
 else
@@ -8061,7 +9304,7 @@
 
 fi
 
-echo "$as_me:8064: result: $cf_cv_regex" >&5
+echo "$as_me:9307: result: $cf_cv_regex" >&5
 echo "${ECHO_T}$cf_cv_regex" >&6
 case $cf_cv_regex in
 	regex.h)   cat >>confdefs.h <<\EOF
@@ -8097,23 +9340,23 @@
 wctype.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:8100: checking for $ac_header" >&5
+echo "$as_me:9343: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8106 "configure"
+#line 9349 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:8110: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:9353: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:8116: \$? = $ac_status" >&5
+  echo "$as_me:9359: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -8132,7 +9375,7 @@
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:8135: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:9378: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -8146,7 +9389,7 @@
 # Note: even non-Posix ISC needs <sys/bsdtypes.h> to declare fd_set
 if test "$ISC" = yes ; then
 
-echo "$as_me:8149: checking for main in -lcposix" >&5
+echo "$as_me:9392: checking for main in -lcposix" >&5
 echo $ECHO_N "checking for main in -lcposix... $ECHO_C" >&6
 if test "${ac_cv_lib_cposix_main+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8154,7 +9397,7 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-lcposix  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 8157 "configure"
+#line 9400 "configure"
 #include "confdefs.h"
 
 int
@@ -8166,16 +9409,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8169: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9412: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8172: \$? = $ac_status" >&5
+  echo "$as_me:9415: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8175: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9418: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8178: \$? = $ac_status" >&5
+  echo "$as_me:9421: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_cposix_main=yes
 else
@@ -8186,7 +9429,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:8189: result: $ac_cv_lib_cposix_main" >&5
+echo "$as_me:9432: result: $ac_cv_lib_cposix_main" >&5
 echo "${ECHO_T}$ac_cv_lib_cposix_main" >&6
 if test $ac_cv_lib_cposix_main = yes; then
   cat >>confdefs.h <<EOF
@@ -8197,7 +9440,7 @@
 
 fi
 
-	echo "$as_me:8200: checking for bzero in -linet" >&5
+	echo "$as_me:9443: checking for bzero in -linet" >&5
 echo $ECHO_N "checking for bzero in -linet... $ECHO_C" >&6
 if test "${ac_cv_lib_inet_bzero+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8205,7 +9448,7 @@
   ac_check_lib_save_LIBS=$LIBS
 LIBS="-linet  $LIBS"
 cat >conftest.$ac_ext <<_ACEOF
-#line 8208 "configure"
+#line 9451 "configure"
 #include "confdefs.h"
 
 /* Override any gcc2 internal prototype to avoid an error.  */
@@ -8224,16 +9467,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8227: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9470: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8230: \$? = $ac_status" >&5
+  echo "$as_me:9473: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8233: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9476: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8236: \$? = $ac_status" >&5
+  echo "$as_me:9479: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_lib_inet_bzero=yes
 else
@@ -8244,21 +9487,21 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:8247: result: $ac_cv_lib_inet_bzero" >&5
+echo "$as_me:9490: result: $ac_cv_lib_inet_bzero" >&5
 echo "${ECHO_T}$ac_cv_lib_inet_bzero" >&6
 if test $ac_cv_lib_inet_bzero = yes; then
   LIBS="$LIBS -linet"
 fi
 fi
 
-echo "$as_me:8254: checking if sys/time.h works with sys/select.h" >&5
+echo "$as_me:9497: checking if sys/time.h works with sys/select.h" >&5
 echo $ECHO_N "checking if sys/time.h works with sys/select.h... $ECHO_C" >&6
 if test "${cf_cv_sys_time_select+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 8261 "configure"
+#line 9504 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -8278,16 +9521,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8281: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9524: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8284: \$? = $ac_status" >&5
+  echo "$as_me:9527: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8287: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9530: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8290: \$? = $ac_status" >&5
+  echo "$as_me:9533: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_sys_time_select=yes
 else
@@ -8299,7 +9542,7 @@
 
 fi
 
-echo "$as_me:8302: result: $cf_cv_sys_time_select" >&5
+echo "$as_me:9545: result: $cf_cv_sys_time_select" >&5
 echo "${ECHO_T}$cf_cv_sys_time_select" >&6
 test "$cf_cv_sys_time_select" = yes && cat >>confdefs.h <<\EOF
 #define HAVE_SYS_TIME_SELECT 1
@@ -8312,7 +9555,7 @@
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-echo "$as_me:8315: checking for $CC option to accept ANSI C" >&5
+echo "$as_me:9558: checking for $CC option to accept ANSI C" >&5
 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
 if test "${ac_cv_prog_cc_stdc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8320,7 +9563,7 @@
   ac_cv_prog_cc_stdc=no
 ac_save_CC=$CC
 cat >conftest.$ac_ext <<_ACEOF
-#line 8323 "configure"
+#line 9566 "configure"
 #include "confdefs.h"
 #include <stdarg.h>
 #include <stdio.h>
@@ -8369,16 +9612,16 @@
 do
   CC="$ac_save_CC $ac_arg"
   rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8372: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9615: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8375: \$? = $ac_status" >&5
+  echo "$as_me:9618: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8378: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9621: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8381: \$? = $ac_status" >&5
+  echo "$as_me:9624: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_prog_cc_stdc=$ac_arg
 break
@@ -8395,21 +9638,21 @@
 
 case "x$ac_cv_prog_cc_stdc" in
   x|xno)
-    echo "$as_me:8398: result: none needed" >&5
+    echo "$as_me:9641: result: none needed" >&5
 echo "${ECHO_T}none needed" >&6 ;;
   *)
-    echo "$as_me:8401: result: $ac_cv_prog_cc_stdc" >&5
+    echo "$as_me:9644: result: $ac_cv_prog_cc_stdc" >&5
 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
     CC="$CC $ac_cv_prog_cc_stdc" ;;
 esac
 
-echo "$as_me:8406: checking for an ANSI C-conforming const" >&5
+echo "$as_me:9649: checking for an ANSI C-conforming const" >&5
 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
 if test "${ac_cv_c_const+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8412 "configure"
+#line 9655 "configure"
 #include "confdefs.h"
 
 int
@@ -8467,16 +9710,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8470: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9713: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8473: \$? = $ac_status" >&5
+  echo "$as_me:9716: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8476: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9719: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8479: \$? = $ac_status" >&5
+  echo "$as_me:9722: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_const=yes
 else
@@ -8486,7 +9729,7 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:8489: result: $ac_cv_c_const" >&5
+echo "$as_me:9732: result: $ac_cv_c_const" >&5
 echo "${ECHO_T}$ac_cv_c_const" >&6
 if test $ac_cv_c_const = no; then
 
@@ -8496,7 +9739,7 @@
 
 fi
 
-echo "$as_me:8499: checking for inline" >&5
+echo "$as_me:9742: checking for inline" >&5
 echo $ECHO_N "checking for inline... $ECHO_C" >&6
 if test "${ac_cv_c_inline+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8504,7 +9747,7 @@
   ac_cv_c_inline=no
 for ac_kw in inline __inline__ __inline; do
   cat >conftest.$ac_ext <<_ACEOF
-#line 8507 "configure"
+#line 9750 "configure"
 #include "confdefs.h"
 #ifndef __cplusplus
 static $ac_kw int static_foo () {return 0; }
@@ -8513,16 +9756,16 @@
 
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8516: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9759: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8519: \$? = $ac_status" >&5
+  echo "$as_me:9762: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8522: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9765: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8525: \$? = $ac_status" >&5
+  echo "$as_me:9768: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_c_inline=$ac_kw; break
 else
@@ -8533,7 +9776,7 @@
 done
 
 fi
-echo "$as_me:8536: result: $ac_cv_c_inline" >&5
+echo "$as_me:9779: result: $ac_cv_c_inline" >&5
 echo "${ECHO_T}$ac_cv_c_inline" >&6
 case $ac_cv_c_inline in
   inline | yes) ;;
@@ -8552,14 +9795,14 @@
 #define CC_HAS_INLINE_FUNCS 1
 EOF
 
-echo "$as_me:8555: checking if unsigned literals are legal" >&5
+echo "$as_me:9798: checking if unsigned literals are legal" >&5
 echo $ECHO_N "checking if unsigned literals are legal... $ECHO_C" >&6
 if test "${cf_cv_unsigned_literals+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 8562 "configure"
+#line 9805 "configure"
 #include "confdefs.h"
 
 int
@@ -8571,16 +9814,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8574: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9817: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8577: \$? = $ac_status" >&5
+  echo "$as_me:9820: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8580: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9823: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8583: \$? = $ac_status" >&5
+  echo "$as_me:9826: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_unsigned_literals=yes
 else
@@ -8592,10 +9835,10 @@
 
 fi
 
-echo "$as_me:8595: result: $cf_cv_unsigned_literals" >&5
+echo "$as_me:9838: result: $cf_cv_unsigned_literals" >&5
 echo "${ECHO_T}$cf_cv_unsigned_literals" >&6
 
-echo "$as_me:8598: checking for type of chtype" >&5
+echo "$as_me:9841: checking for type of chtype" >&5
 echo $ECHO_N "checking for type of chtype... $ECHO_C" >&6
 if test "${cf_cv_typeof_chtype+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8605,7 +9848,7 @@
   cf_cv_typeof_chtype=long
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8608 "configure"
+#line 9851 "configure"
 #include "confdefs.h"
 
 #ifdef USE_WIDEC_SUPPORT
@@ -8652,15 +9895,15 @@
 
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:8655: \"$ac_link\"") >&5
+if { (eval echo "$as_me:9898: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8658: \$? = $ac_status" >&5
+  echo "$as_me:9901: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:8660: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9903: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8663: \$? = $ac_status" >&5
+  echo "$as_me:9906: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_typeof_chtype=`cat cf_test.out`
 else
@@ -8675,7 +9918,7 @@
 
 fi
 
-echo "$as_me:8678: result: $cf_cv_typeof_chtype" >&5
+echo "$as_me:9921: result: $cf_cv_typeof_chtype" >&5
 echo "${ECHO_T}$cf_cv_typeof_chtype" >&6
 
 cat >>confdefs.h <<EOF
@@ -8688,14 +9931,14 @@
 
 ###	Checks for external-data
 
-echo "$as_me:8691: checking if external errno is declared" >&5
+echo "$as_me:9934: checking if external errno is declared" >&5
 echo $ECHO_N "checking if external errno is declared... $ECHO_C" >&6
 if test "${cf_cv_dcl_errno+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
     cat >conftest.$ac_ext <<_ACEOF
-#line 8698 "configure"
+#line 9941 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_STDLIB_H
@@ -8713,16 +9956,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:8716: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:9959: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8719: \$? = $ac_status" >&5
+  echo "$as_me:9962: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:8722: \"$ac_try\"") >&5
+  { (eval echo "$as_me:9965: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8725: \$? = $ac_status" >&5
+  echo "$as_me:9968: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_dcl_errno=yes
 else
@@ -8733,7 +9976,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 
 fi
-echo "$as_me:8736: result: $cf_cv_dcl_errno" >&5
+echo "$as_me:9979: result: $cf_cv_dcl_errno" >&5
 echo "${ECHO_T}$cf_cv_dcl_errno" >&6
 
 if test "$cf_cv_dcl_errno" = no ; then
@@ -8748,14 +9991,14 @@
 
 # It's possible (for near-UNIX clones) that the data doesn't exist
 
-echo "$as_me:8751: checking if external errno exists" >&5
+echo "$as_me:9994: checking if external errno exists" >&5
 echo $ECHO_N "checking if external errno exists... $ECHO_C" >&6
 if test "${cf_cv_have_errno+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
     cat >conftest.$ac_ext <<_ACEOF
-#line 8758 "configure"
+#line 10001 "configure"
 #include "confdefs.h"
 
 #undef errno
@@ -8770,16 +10013,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8773: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10016: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8776: \$? = $ac_status" >&5
+  echo "$as_me:10019: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8779: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10022: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8782: \$? = $ac_status" >&5
+  echo "$as_me:10025: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_have_errno=yes
 else
@@ -8790,7 +10033,7 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
 fi
-echo "$as_me:8793: result: $cf_cv_have_errno" >&5
+echo "$as_me:10036: result: $cf_cv_have_errno" >&5
 echo "${ECHO_T}$cf_cv_have_errno" >&6
 
 if test "$cf_cv_have_errno" = yes ; then
@@ -8803,7 +10046,7 @@
 
 fi
 
-echo "$as_me:8806: checking if data-only library module links" >&5
+echo "$as_me:10049: checking if data-only library module links" >&5
 echo $ECHO_N "checking if data-only library module links... $ECHO_C" >&6
 if test "${cf_cv_link_dataonly+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -8811,20 +10054,20 @@
 
 	rm -f conftest.a
 	cat >conftest.$ac_ext <<EOF
-#line 8814 "configure"
+#line 10057 "configure"
 int	testdata[3] = { 123, 456, 789 };
 EOF
-	if { (eval echo "$as_me:8817: \"$ac_compile\"") >&5
+	if { (eval echo "$as_me:10060: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8820: \$? = $ac_status" >&5
+  echo "$as_me:10063: \$? = $ac_status" >&5
   (exit $ac_status); } ; then
 		mv conftest.o data.o && \
 		( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
 	fi
 	rm -f conftest.$ac_ext data.o
 	cat >conftest.$ac_ext <<EOF
-#line 8827 "configure"
+#line 10070 "configure"
 int	testfunc()
 {
 #if defined(NeXT)
@@ -8837,10 +10080,10 @@
 #endif
 }
 EOF
-	if { (eval echo "$as_me:8840: \"$ac_compile\"") >&5
+	if { (eval echo "$as_me:10083: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:8843: \$? = $ac_status" >&5
+  echo "$as_me:10086: \$? = $ac_status" >&5
   (exit $ac_status); }; then
 		mv conftest.o func.o && \
 		( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
@@ -8853,7 +10096,7 @@
   cf_cv_link_dataonly=unknown
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8856 "configure"
+#line 10099 "configure"
 #include "confdefs.h"
 
 	int main()
@@ -8864,15 +10107,15 @@
 
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:8867: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10110: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8870: \$? = $ac_status" >&5
+  echo "$as_me:10113: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:8872: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10115: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8875: \$? = $ac_status" >&5
+  echo "$as_me:10118: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_link_dataonly=yes
 else
@@ -8887,7 +10130,7 @@
 
 fi
 
-echo "$as_me:8890: result: $cf_cv_link_dataonly" >&5
+echo "$as_me:10133: result: $cf_cv_link_dataonly" >&5
 echo "${ECHO_T}$cf_cv_link_dataonly" >&6
 
 if test "$cf_cv_link_dataonly" = no ; then
@@ -8906,7 +10149,6 @@
 geteuid \
 getttynam \
 issetugid \
-memccpy \
 nanosleep \
 poll \
 remove \
@@ -8924,13 +10166,13 @@
 
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:8927: checking for $ac_func" >&5
+echo "$as_me:10169: checking for $ac_func" >&5
 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
 if eval "test \"\${$as_ac_var+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 8933 "configure"
+#line 10175 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func (); below.  */
@@ -8961,16 +10203,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:8964: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10206: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:8967: \$? = $ac_status" >&5
+  echo "$as_me:10209: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:8970: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10212: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:8973: \$? = $ac_status" >&5
+  echo "$as_me:10215: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   eval "$as_ac_var=yes"
 else
@@ -8980,7 +10222,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:8983: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "$as_me:10225: result: `eval echo '${'$as_ac_var'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
 if test `eval echo '${'$as_ac_var'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -8992,14 +10234,14 @@
 
 if test "$with_getcap" = "yes" ; then
 
-echo "$as_me:8995: checking for terminal-capability database functions" >&5
+echo "$as_me:10237: checking for terminal-capability database functions" >&5
 echo $ECHO_N "checking for terminal-capability database functions... $ECHO_C" >&6
 if test "${cf_cv_cgetent+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 9002 "configure"
+#line 10244 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -9019,16 +10261,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9022: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10264: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9025: \$? = $ac_status" >&5
+  echo "$as_me:10267: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9028: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10270: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9031: \$? = $ac_status" >&5
+  echo "$as_me:10273: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_cgetent=yes
 else
@@ -9040,7 +10282,7 @@
 
 fi
 
-echo "$as_me:9043: result: $cf_cv_cgetent" >&5
+echo "$as_me:10285: result: $cf_cv_cgetent" >&5
 echo "${ECHO_T}$cf_cv_cgetent" >&6
 test "$cf_cv_cgetent" = yes && cat >>confdefs.h <<\EOF
 #define HAVE_BSD_CGETENT 1
@@ -9048,14 +10290,14 @@
 
 fi
 
-echo "$as_me:9051: checking for isascii" >&5
+echo "$as_me:10293: checking for isascii" >&5
 echo $ECHO_N "checking for isascii... $ECHO_C" >&6
 if test "${cf_cv_have_isascii+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 9058 "configure"
+#line 10300 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 int
@@ -9067,16 +10309,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9070: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10312: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9073: \$? = $ac_status" >&5
+  echo "$as_me:10315: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9076: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10318: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9079: \$? = $ac_status" >&5
+  echo "$as_me:10321: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_have_isascii=yes
 else
@@ -9087,17 +10329,17 @@
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 
 fi
-echo "$as_me:9090: result: $cf_cv_have_isascii" >&5
+echo "$as_me:10332: result: $cf_cv_have_isascii" >&5
 echo "${ECHO_T}$cf_cv_have_isascii" >&6
 test "$cf_cv_have_isascii" = yes && cat >>confdefs.h <<\EOF
 #define HAVE_ISASCII 1
 EOF
 
 if test "$ac_cv_func_sigaction" = yes; then
-echo "$as_me:9097: checking whether sigaction needs _POSIX_SOURCE" >&5
+echo "$as_me:10339: checking whether sigaction needs _POSIX_SOURCE" >&5
 echo $ECHO_N "checking whether sigaction needs _POSIX_SOURCE... $ECHO_C" >&6
 cat >conftest.$ac_ext <<_ACEOF
-#line 9100 "configure"
+#line 10342 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -9111,16 +10353,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9114: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10356: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9117: \$? = $ac_status" >&5
+  echo "$as_me:10359: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9120: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10362: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9123: \$? = $ac_status" >&5
+  echo "$as_me:10365: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   sigact_bad=no
 else
@@ -9128,7 +10370,7 @@
 cat conftest.$ac_ext >&5
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 9131 "configure"
+#line 10373 "configure"
 #include "confdefs.h"
 
 #define _POSIX_SOURCE
@@ -9143,16 +10385,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9146: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10388: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9149: \$? = $ac_status" >&5
+  echo "$as_me:10391: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9152: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10394: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9155: \$? = $ac_status" >&5
+  echo "$as_me:10397: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   sigact_bad=yes
 	 cat >>confdefs.h <<\EOF
@@ -9167,7 +10409,7 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:9170: result: $sigact_bad" >&5
+echo "$as_me:10412: result: $sigact_bad" >&5
 echo "${ECHO_T}$sigact_bad" >&6
 fi
 
@@ -9178,23 +10420,23 @@
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:9181: checking for $ac_header" >&5
+echo "$as_me:10423: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9187 "configure"
+#line 10429 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:9191: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:10433: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:9197: \$? = $ac_status" >&5
+  echo "$as_me:10439: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -9213,7 +10455,7 @@
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:9216: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:10458: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -9228,23 +10470,23 @@
 for ac_header in sys/termio.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:9231: checking for $ac_header" >&5
+echo "$as_me:10473: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9237 "configure"
+#line 10479 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:9241: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:10483: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:9247: \$? = $ac_status" >&5
+  echo "$as_me:10489: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_c_preproc_warn_flag
@@ -9263,7 +10505,7 @@
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:9266: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:10508: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -9281,10 +10523,10 @@
 	*)	termios_bad=maybe ;;
 	esac
 	if test "$termios_bad" = maybe ; then
-	echo "$as_me:9284: checking whether termios.h needs _POSIX_SOURCE" >&5
+	echo "$as_me:10526: checking whether termios.h needs _POSIX_SOURCE" >&5
 echo $ECHO_N "checking whether termios.h needs _POSIX_SOURCE... $ECHO_C" >&6
 	cat >conftest.$ac_ext <<_ACEOF
-#line 9287 "configure"
+#line 10529 "configure"
 #include "confdefs.h"
 #include <termios.h>
 int
@@ -9296,16 +10538,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9299: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10541: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9302: \$? = $ac_status" >&5
+  echo "$as_me:10544: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9305: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10547: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9308: \$? = $ac_status" >&5
+  echo "$as_me:10550: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   termios_bad=no
 else
@@ -9313,7 +10555,7 @@
 cat conftest.$ac_ext >&5
 
 		cat >conftest.$ac_ext <<_ACEOF
-#line 9316 "configure"
+#line 10558 "configure"
 #include "confdefs.h"
 
 #define _POSIX_SOURCE
@@ -9327,16 +10569,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9330: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:10572: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9333: \$? = $ac_status" >&5
+  echo "$as_me:10575: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9336: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10578: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9339: \$? = $ac_status" >&5
+  echo "$as_me:10581: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   termios_bad=unknown
 else
@@ -9351,19 +10593,19 @@
 
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
-	echo "$as_me:9354: result: $termios_bad" >&5
+	echo "$as_me:10596: result: $termios_bad" >&5
 echo "${ECHO_T}$termios_bad" >&6
 	fi
 fi
 
-echo "$as_me:9359: checking for tcgetattr" >&5
+echo "$as_me:10601: checking for tcgetattr" >&5
 echo $ECHO_N "checking for tcgetattr... $ECHO_C" >&6
 if test "${cf_cv_have_tcgetattr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 9366 "configure"
+#line 10608 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -9391,16 +10633,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9394: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10636: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9397: \$? = $ac_status" >&5
+  echo "$as_me:10639: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9400: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10642: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9403: \$? = $ac_status" >&5
+  echo "$as_me:10645: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_have_tcgetattr=yes
 else
@@ -9410,20 +10652,20 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:9413: result: $cf_cv_have_tcgetattr" >&5
+echo "$as_me:10655: result: $cf_cv_have_tcgetattr" >&5
 echo "${ECHO_T}$cf_cv_have_tcgetattr" >&6
 test "$cf_cv_have_tcgetattr" = yes && cat >>confdefs.h <<\EOF
 #define HAVE_TCGETATTR 1
 EOF
 
-echo "$as_me:9419: checking for vsscanf function or workaround" >&5
+echo "$as_me:10661: checking for vsscanf function or workaround" >&5
 echo $ECHO_N "checking for vsscanf function or workaround... $ECHO_C" >&6
 if test "${cf_cv_func_vsscanf+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 9426 "configure"
+#line 10668 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -9439,16 +10681,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9442: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10684: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9445: \$? = $ac_status" >&5
+  echo "$as_me:10687: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9448: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10690: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9451: \$? = $ac_status" >&5
+  echo "$as_me:10693: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_func_vsscanf=vsscanf
 else
@@ -9456,7 +10698,7 @@
 cat conftest.$ac_ext >&5
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 9459 "configure"
+#line 10701 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -9478,16 +10720,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9481: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10723: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9484: \$? = $ac_status" >&5
+  echo "$as_me:10726: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9487: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10729: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9490: \$? = $ac_status" >&5
+  echo "$as_me:10732: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_func_vsscanf=vfscanf
 else
@@ -9495,7 +10737,7 @@
 cat conftest.$ac_ext >&5
 
 cat >conftest.$ac_ext <<_ACEOF
-#line 9498 "configure"
+#line 10740 "configure"
 #include "confdefs.h"
 
 #include <stdarg.h>
@@ -9517,16 +10759,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9520: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10762: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9523: \$? = $ac_status" >&5
+  echo "$as_me:10765: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9526: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10768: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9529: \$? = $ac_status" >&5
+  echo "$as_me:10771: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_func_vsscanf=_doscan
 else
@@ -9541,7 +10783,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:9544: result: $cf_cv_func_vsscanf" >&5
+echo "$as_me:10786: result: $cf_cv_func_vsscanf" >&5
 echo "${ECHO_T}$cf_cv_func_vsscanf" >&6
 
 case $cf_cv_func_vsscanf in #(vi
@@ -9559,7 +10801,7 @@
 ;;
 esac
 
-echo "$as_me:9562: checking for working mkstemp" >&5
+echo "$as_me:10804: checking for working mkstemp" >&5
 echo $ECHO_N "checking for working mkstemp... $ECHO_C" >&6
 if test "${cf_cv_func_mkstemp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -9567,13 +10809,13 @@
 
 rm -f conftest*
 if test "$cross_compiling" = yes; then
-  echo "$as_me:9570: checking for mkstemp" >&5
+  echo "$as_me:10812: checking for mkstemp" >&5
 echo $ECHO_N "checking for mkstemp... $ECHO_C" >&6
 if test "${ac_cv_func_mkstemp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9576 "configure"
+#line 10818 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char mkstemp (); below.  */
@@ -9604,16 +10846,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:9607: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10849: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9610: \$? = $ac_status" >&5
+  echo "$as_me:10852: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:9613: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10855: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9616: \$? = $ac_status" >&5
+  echo "$as_me:10858: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_func_mkstemp=yes
 else
@@ -9623,12 +10865,12 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:9626: result: $ac_cv_func_mkstemp" >&5
+echo "$as_me:10868: result: $ac_cv_func_mkstemp" >&5
 echo "${ECHO_T}$ac_cv_func_mkstemp" >&6
 
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9631 "configure"
+#line 10873 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -9666,15 +10908,15 @@
 
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:9669: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10911: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9672: \$? = $ac_status" >&5
+  echo "$as_me:10914: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:9674: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10916: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9677: \$? = $ac_status" >&5
+  echo "$as_me:10919: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_func_mkstemp=yes
 
@@ -9689,7 +10931,7 @@
 fi
 
 fi
-echo "$as_me:9692: result: $cf_cv_func_mkstemp" >&5
+echo "$as_me:10934: result: $cf_cv_func_mkstemp" >&5
 echo "${ECHO_T}$cf_cv_func_mkstemp" >&6
 if test "$cf_cv_func_mkstemp" = yes ; then
 	cat >>confdefs.h <<\EOF
@@ -9706,21 +10948,21 @@
 fi
 
 if test "$cross_compiling" = yes ; then
-	{ echo "$as_me:9709: WARNING: cross compiling: assume setvbuf params not reversed" >&5
+	{ echo "$as_me:10951: WARNING: cross compiling: assume setvbuf params not reversed" >&5
 echo "$as_me: WARNING: cross compiling: assume setvbuf params not reversed" >&2;}
 else
-	echo "$as_me:9712: checking whether setvbuf arguments are reversed" >&5
+	echo "$as_me:10954: checking whether setvbuf arguments are reversed" >&5
 echo $ECHO_N "checking whether setvbuf arguments are reversed... $ECHO_C" >&6
 if test "${ac_cv_func_setvbuf_reversed+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   if test "$cross_compiling" = yes; then
-  { { echo "$as_me:9718: error: cannot run test program while cross compiling" >&5
+  { { echo "$as_me:10960: error: cannot run test program while cross compiling" >&5
 echo "$as_me: error: cannot run test program while cross compiling" >&2;}
    { (exit 1); exit 1; }; }
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9723 "configure"
+#line 10965 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 /* If setvbuf has the reversed format, exit 0. */
@@ -9737,15 +10979,15 @@
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:9740: \"$ac_link\"") >&5
+if { (eval echo "$as_me:10982: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:9743: \$? = $ac_status" >&5
+  echo "$as_me:10985: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:9745: \"$ac_try\"") >&5
+  { (eval echo "$as_me:10987: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9748: \$? = $ac_status" >&5
+  echo "$as_me:10990: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_func_setvbuf_reversed=yes
 else
@@ -9758,7 +11000,7 @@
 fi
 rm -f core core.* *.core
 fi
-echo "$as_me:9761: result: $ac_cv_func_setvbuf_reversed" >&5
+echo "$as_me:11003: result: $ac_cv_func_setvbuf_reversed" >&5
 echo "${ECHO_T}$ac_cv_func_setvbuf_reversed" >&6
 if test $ac_cv_func_setvbuf_reversed = yes; then
 
@@ -9769,13 +11011,13 @@
 fi
 
 fi
-echo "$as_me:9772: checking return type of signal handlers" >&5
+echo "$as_me:11014: checking return type of signal handlers" >&5
 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6
 if test "${ac_cv_type_signal+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9778 "configure"
+#line 11020 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -9797,16 +11039,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9800: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11042: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9803: \$? = $ac_status" >&5
+  echo "$as_me:11045: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9806: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11048: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9809: \$? = $ac_status" >&5
+  echo "$as_me:11051: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_type_signal=void
 else
@@ -9816,21 +11058,21 @@
 fi
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:9819: result: $ac_cv_type_signal" >&5
+echo "$as_me:11061: result: $ac_cv_type_signal" >&5
 echo "${ECHO_T}$ac_cv_type_signal" >&6
 
 cat >>confdefs.h <<EOF
 #define RETSIGTYPE $ac_cv_type_signal
 EOF
 
-echo "$as_me:9826: checking for type sigaction_t" >&5
+echo "$as_me:11068: checking for type sigaction_t" >&5
 echo $ECHO_N "checking for type sigaction_t... $ECHO_C" >&6
 if test "${cf_cv_type_sigaction+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 9833 "configure"
+#line 11075 "configure"
 #include "confdefs.h"
 
 #include <signal.h>
@@ -9843,16 +11085,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9846: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11088: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9849: \$? = $ac_status" >&5
+  echo "$as_me:11091: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9852: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11094: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9855: \$? = $ac_status" >&5
+  echo "$as_me:11097: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_type_sigaction=yes
 else
@@ -9863,13 +11105,13 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 fi
 
-echo "$as_me:9866: result: $cf_cv_type_sigaction" >&5
+echo "$as_me:11108: result: $cf_cv_type_sigaction" >&5
 echo "${ECHO_T}$cf_cv_type_sigaction" >&6
 test "$cf_cv_type_sigaction" = yes && cat >>confdefs.h <<\EOF
 #define HAVE_TYPE_SIGACTION 1
 EOF
 
-echo "$as_me:9872: checking declaration of size-change" >&5
+echo "$as_me:11114: checking declaration of size-change" >&5
 echo $ECHO_N "checking declaration of size-change... $ECHO_C" >&6
 if test "${cf_cv_sizechange+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -9884,7 +11126,7 @@
     CPPFLAGS="$cf_save_CPPFLAGS"
     test -n "$cf_opts" && CPPFLAGS="$CPPFLAGS -D$cf_opts"
     cat >conftest.$ac_ext <<_ACEOF
-#line 9887 "configure"
+#line 11129 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #ifdef HAVE_TERMIOS_H
@@ -9928,16 +11170,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:9931: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11173: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:9934: \$? = $ac_status" >&5
+  echo "$as_me:11176: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:9937: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11179: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:9940: \$? = $ac_status" >&5
+  echo "$as_me:11182: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_sizechange=yes
 else
@@ -9956,7 +11198,7 @@
 done
 
 fi
-echo "$as_me:9959: result: $cf_cv_sizechange" >&5
+echo "$as_me:11201: result: $cf_cv_sizechange" >&5
 echo "${ECHO_T}$cf_cv_sizechange" >&6
 if test "$cf_cv_sizechange" != no ; then
 	cat >>confdefs.h <<\EOF
@@ -9973,13 +11215,13 @@
 	esac
 fi
 
-echo "$as_me:9976: checking for memmove" >&5
+echo "$as_me:11218: checking for memmove" >&5
 echo $ECHO_N "checking for memmove... $ECHO_C" >&6
 if test "${ac_cv_func_memmove+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 9982 "configure"
+#line 11224 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char memmove (); below.  */
@@ -10010,16 +11252,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10013: \"$ac_link\"") >&5
+if { (eval echo "$as_me:11255: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10016: \$? = $ac_status" >&5
+  echo "$as_me:11258: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10019: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11261: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10022: \$? = $ac_status" >&5
+  echo "$as_me:11264: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_func_memmove=yes
 else
@@ -10029,19 +11271,19 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:10032: result: $ac_cv_func_memmove" >&5
+echo "$as_me:11274: result: $ac_cv_func_memmove" >&5
 echo "${ECHO_T}$ac_cv_func_memmove" >&6
 if test $ac_cv_func_memmove = yes; then
   :
 else
 
-echo "$as_me:10038: checking for bcopy" >&5
+echo "$as_me:11280: checking for bcopy" >&5
 echo $ECHO_N "checking for bcopy... $ECHO_C" >&6
 if test "${ac_cv_func_bcopy+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 10044 "configure"
+#line 11286 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char bcopy (); below.  */
@@ -10072,16 +11314,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10075: \"$ac_link\"") >&5
+if { (eval echo "$as_me:11317: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10078: \$? = $ac_status" >&5
+  echo "$as_me:11320: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10081: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11323: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10084: \$? = $ac_status" >&5
+  echo "$as_me:11326: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   ac_cv_func_bcopy=yes
 else
@@ -10091,11 +11333,11 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 fi
-echo "$as_me:10094: result: $ac_cv_func_bcopy" >&5
+echo "$as_me:11336: result: $ac_cv_func_bcopy" >&5
 echo "${ECHO_T}$ac_cv_func_bcopy" >&6
 if test $ac_cv_func_bcopy = yes; then
 
-	echo "$as_me:10098: checking if bcopy does overlapping moves" >&5
+	echo "$as_me:11340: checking if bcopy does overlapping moves" >&5
 echo $ECHO_N "checking if bcopy does overlapping moves... $ECHO_C" >&6
 if test "${cf_cv_good_bcopy+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -10105,7 +11347,7 @@
   cf_cv_good_bcopy=unknown
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 10108 "configure"
+#line 11350 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -10119,15 +11361,15 @@
 
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:10122: \"$ac_link\"") >&5
+if { (eval echo "$as_me:11364: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10125: \$? = $ac_status" >&5
+  echo "$as_me:11367: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:10127: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11369: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10130: \$? = $ac_status" >&5
+  echo "$as_me:11372: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_good_bcopy=yes
 else
@@ -10140,7 +11382,7 @@
 fi
 
 fi
-echo "$as_me:10143: result: $cf_cv_good_bcopy" >&5
+echo "$as_me:11385: result: $cf_cv_good_bcopy" >&5
 echo "${ECHO_T}$cf_cv_good_bcopy" >&6
 
 else
@@ -10161,7 +11403,7 @@
 
 fi
 
-echo "$as_me:10164: checking if poll really works" >&5
+echo "$as_me:11406: checking if poll really works" >&5
 echo $ECHO_N "checking if poll really works... $ECHO_C" >&6
 if test "${cf_cv_working_poll+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -10171,7 +11413,7 @@
   cf_cv_working_poll=unknown
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 10174 "configure"
+#line 11416 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -10192,15 +11434,15 @@
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:10195: \"$ac_link\"") >&5
+if { (eval echo "$as_me:11437: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10198: \$? = $ac_status" >&5
+  echo "$as_me:11440: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:10200: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11442: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10203: \$? = $ac_status" >&5
+  echo "$as_me:11445: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_working_poll=yes
 else
@@ -10212,7 +11454,7 @@
 rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 fi
-echo "$as_me:10215: result: $cf_cv_working_poll" >&5
+echo "$as_me:11457: result: $cf_cv_working_poll" >&5
 echo "${ECHO_T}$cf_cv_working_poll" >&6
 test "$cf_cv_working_poll" = "yes" && cat >>confdefs.h <<\EOF
 #define HAVE_WORKING_POLL 1
@@ -10225,7 +11467,7 @@
 
 # Just in case, check if the C compiler has a bool type.
 
-echo "$as_me:10228: checking if we should include stdbool.h" >&5
+echo "$as_me:11470: checking if we should include stdbool.h" >&5
 echo $ECHO_N "checking if we should include stdbool.h... $ECHO_C" >&6
 
 if test "${cf_cv_header_stdbool_h+set}" = set; then
@@ -10233,7 +11475,7 @@
 else
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 10236 "configure"
+#line 11478 "configure"
 #include "confdefs.h"
 
 int
@@ -10245,23 +11487,23 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:10248: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11490: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10251: \$? = $ac_status" >&5
+  echo "$as_me:11493: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:10254: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11496: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10257: \$? = $ac_status" >&5
+  echo "$as_me:11499: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_header_stdbool_h=0
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 cat >conftest.$ac_ext <<_ACEOF
-#line 10264 "configure"
+#line 11506 "configure"
 #include "confdefs.h"
 
 #ifndef __BEOS__
@@ -10277,16 +11519,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:10280: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11522: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10283: \$? = $ac_status" >&5
+  echo "$as_me:11525: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:10286: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11528: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10289: \$? = $ac_status" >&5
+  echo "$as_me:11531: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_header_stdbool_h=1
 else
@@ -10300,13 +11542,13 @@
 fi
 
 if test "$cf_cv_header_stdbool_h" = 1
-then	echo "$as_me:10303: result: yes" >&5
+then	echo "$as_me:11545: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-else	echo "$as_me:10305: result: no" >&5
+else	echo "$as_me:11547: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:10309: checking for builtin bool type" >&5
+echo "$as_me:11551: checking for builtin bool type" >&5
 echo $ECHO_N "checking for builtin bool type... $ECHO_C" >&6
 
 if test "${cf_cv_cc_bool_type+set}" = set; then
@@ -10314,7 +11556,7 @@
 else
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 10317 "configure"
+#line 11559 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -10329,16 +11571,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:10332: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:11574: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10335: \$? = $ac_status" >&5
+  echo "$as_me:11577: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:10338: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11580: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10341: \$? = $ac_status" >&5
+  echo "$as_me:11583: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_cc_bool_type=1
 else
@@ -10351,9 +11593,9 @@
 fi
 
 if test "$cf_cv_cc_bool_type" = 1
-then	echo "$as_me:10354: result: yes" >&5
+then	echo "$as_me:11596: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-else	echo "$as_me:10356: result: no" >&5
+else	echo "$as_me:11598: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -10374,7 +11616,7 @@
 	cf_stdcpp_libname=stdc++
 	;;
 esac
-echo "$as_me:10377: checking for library $cf_stdcpp_libname" >&5
+echo "$as_me:11619: checking for library $cf_stdcpp_libname" >&5
 echo $ECHO_N "checking for library $cf_stdcpp_libname... $ECHO_C" >&6
 if test "${cf_cv_libstdcpp+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -10383,7 +11625,7 @@
 	cf_save="$LIBS"
 	LIBS="$LIBS -l$cf_stdcpp_libname"
 cat >conftest.$ac_ext <<_ACEOF
-#line 10386 "configure"
+#line 11628 "configure"
 #include "confdefs.h"
 
 #include <strstream.h>
@@ -10399,16 +11641,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10402: \"$ac_link\"") >&5
+if { (eval echo "$as_me:11644: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10405: \$? = $ac_status" >&5
+  echo "$as_me:11647: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10408: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11650: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10411: \$? = $ac_status" >&5
+  echo "$as_me:11653: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_libstdcpp=yes
 else
@@ -10420,11 +11662,53 @@
 	LIBS="$cf_save"
 
 fi
-echo "$as_me:10423: result: $cf_cv_libstdcpp" >&5
+echo "$as_me:11665: result: $cf_cv_libstdcpp" >&5
 echo "${ECHO_T}$cf_cv_libstdcpp" >&6
 test "$cf_cv_libstdcpp" = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
 fi
 
+	echo "$as_me:11670: checking whether $CXX understands -c and -o together" >&5
+echo $ECHO_N "checking whether $CXX understands -c and -o together... $ECHO_C" >&6
+if test "${cf_cv_prog_CXX_c_o+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat > conftest.$ac_ext <<CF_EOF
+#include <stdio.h>
+int main()
+{
+	return 0;
+}
+CF_EOF
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CXX -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+if { (eval echo "$as_me:11686: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11689: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+  test -f conftest2.$ac_objext && { (eval echo "$as_me:11691: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:11694: \$? = $ac_status" >&5
+  (exit $ac_status); };
+then
+  eval cf_cv_prog_CXX_c_o=yes
+else
+  eval cf_cv_prog_CXX_c_o=no
+fi
+rm -f conftest*
+
+fi
+if test $cf_cv_prog_CXX_c_o = yes; then
+  echo "$as_me:11705: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me:11708: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
 	case $GXX_VERSION in
 	1*|2.0-6*)
 		cf_cxx_library=yes
@@ -10441,12 +11725,12 @@
 	;;
 esac
 if test "$GXX" = yes; then
-	echo "$as_me:10444: checking for lib$cf_gpp_libname" >&5
+	echo "$as_me:11728: checking for lib$cf_gpp_libname" >&5
 echo $ECHO_N "checking for lib$cf_gpp_libname... $ECHO_C" >&6
 	cf_save="$LIBS"
 	LIBS="$LIBS -l$cf_gpp_libname"
 	cat >conftest.$ac_ext <<_ACEOF
-#line 10449 "configure"
+#line 11733 "configure"
 #include "confdefs.h"
 
 #include <$cf_gpp_libname/builtin.h>
@@ -10460,16 +11744,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10463: \"$ac_link\"") >&5
+if { (eval echo "$as_me:11747: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10466: \$? = $ac_status" >&5
+  echo "$as_me:11750: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10469: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11753: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10472: \$? = $ac_status" >&5
+  echo "$as_me:11756: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cxx_library=yes
 	 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
@@ -10488,7 +11772,7 @@
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 cat >conftest.$ac_ext <<_ACEOF
-#line 10491 "configure"
+#line 11775 "configure"
 #include "confdefs.h"
 
 #include <builtin.h>
@@ -10502,16 +11786,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:10505: \"$ac_link\"") >&5
+if { (eval echo "$as_me:11789: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10508: \$? = $ac_status" >&5
+  echo "$as_me:11792: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:10511: \"$ac_try\"") >&5
+  { (eval echo "$as_me:11795: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10514: \$? = $ac_status" >&5
+  echo "$as_me:11798: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cxx_library=yes
 	 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
@@ -10528,7 +11812,7 @@
 fi
 rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
 	LIBS="$cf_save"
-	echo "$as_me:10531: result: $cf_cxx_library" >&5
+	echo "$as_me:11815: result: $cf_cxx_library" >&5
 echo "${ECHO_T}$cf_cxx_library" >&6
 fi
 
@@ -10538,12 +11822,20 @@
 		;;
 	esac
 
+	case "$GCC_VERSION" in
+	2.95.*)
+		;;
+	*)
+		CPPFLAGS="$CPPFLAGS -DCPP_HAS_STATIC_CAST"
+		;;
+	esac
+
 	ac_ext=cc
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-echo "$as_me:10546: checking how to run the C++ preprocessor" >&5
+echo "$as_me:11838: checking how to run the C++ preprocessor" >&5
 echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
 if test -z "$CXXCPP"; then
   if test "${ac_cv_prog_CXXCPP+set}" = set; then
@@ -10560,18 +11852,18 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >conftest.$ac_ext <<_ACEOF
-#line 10563 "configure"
+#line 11855 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:10568: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:11860: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:10574: \$? = $ac_status" >&5
+  echo "$as_me:11866: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -10594,17 +11886,17 @@
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
-#line 10597 "configure"
+#line 11889 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:10601: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:11893: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:10607: \$? = $ac_status" >&5
+  echo "$as_me:11899: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -10641,7 +11933,7 @@
 else
   ac_cv_prog_CXXCPP=$CXXCPP
 fi
-echo "$as_me:10644: result: $CXXCPP" >&5
+echo "$as_me:11936: result: $CXXCPP" >&5
 echo "${ECHO_T}$CXXCPP" >&6
 ac_preproc_ok=false
 for ac_cxx_preproc_warn_flag in '' yes
@@ -10651,18 +11943,18 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp. "Syntax error" is here to catch this case.
   cat >conftest.$ac_ext <<_ACEOF
-#line 10654 "configure"
+#line 11946 "configure"
 #include "confdefs.h"
 #include <assert.h>
                      Syntax error
 _ACEOF
-if { (eval echo "$as_me:10659: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:11951: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:10665: \$? = $ac_status" >&5
+  echo "$as_me:11957: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -10685,17 +11977,17 @@
   # OK, works on sane cases.  Now check whether non-existent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
-#line 10688 "configure"
+#line 11980 "configure"
 #include "confdefs.h"
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:10692: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:11984: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:10698: \$? = $ac_status" >&5
+  echo "$as_me:11990: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -10723,7 +12015,7 @@
 if $ac_preproc_ok; then
   :
 else
-  { { echo "$as_me:10726: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&5
+  { { echo "$as_me:12018: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&5
 echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&2;}
    { (exit 1); exit 1; }; }
 fi
@@ -10737,23 +12029,23 @@
 for ac_header in typeinfo
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:10740: checking for $ac_header" >&5
+echo "$as_me:12032: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 10746 "configure"
+#line 12038 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:10750: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:12042: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:10756: \$? = $ac_status" >&5
+  echo "$as_me:12048: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -10772,7 +12064,7 @@
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:10775: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:12067: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -10782,7 +12074,7 @@
 fi
 done
 
-echo "$as_me:10785: checking if we should include stdbool.h" >&5
+echo "$as_me:12077: checking if we should include stdbool.h" >&5
 echo $ECHO_N "checking if we should include stdbool.h... $ECHO_C" >&6
 
 if test "${cf_cv_header_stdbool_h+set}" = set; then
@@ -10790,7 +12082,7 @@
 else
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 10793 "configure"
+#line 12085 "configure"
 #include "confdefs.h"
 
 int
@@ -10802,23 +12094,23 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:10805: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12097: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10808: \$? = $ac_status" >&5
+  echo "$as_me:12100: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:10811: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12103: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10814: \$? = $ac_status" >&5
+  echo "$as_me:12106: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_header_stdbool_h=0
 else
   echo "$as_me: failed program was:" >&5
 cat conftest.$ac_ext >&5
 cat >conftest.$ac_ext <<_ACEOF
-#line 10821 "configure"
+#line 12113 "configure"
 #include "confdefs.h"
 
 #ifndef __BEOS__
@@ -10834,16 +12126,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:10837: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12129: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10840: \$? = $ac_status" >&5
+  echo "$as_me:12132: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:10843: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12135: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10846: \$? = $ac_status" >&5
+  echo "$as_me:12138: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_header_stdbool_h=1
 else
@@ -10857,13 +12149,13 @@
 fi
 
 if test "$cf_cv_header_stdbool_h" = 1
-then	echo "$as_me:10860: result: yes" >&5
+then	echo "$as_me:12152: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-else	echo "$as_me:10862: result: no" >&5
+else	echo "$as_me:12154: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:10866: checking for builtin bool type" >&5
+echo "$as_me:12158: checking for builtin bool type" >&5
 echo $ECHO_N "checking for builtin bool type... $ECHO_C" >&6
 
 if test "${cf_cv_builtin_bool+set}" = set; then
@@ -10871,7 +12163,7 @@
 else
 
 	cat >conftest.$ac_ext <<_ACEOF
-#line 10874 "configure"
+#line 12166 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -10886,16 +12178,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:10889: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12181: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:10892: \$? = $ac_status" >&5
+  echo "$as_me:12184: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:10895: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12187: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10898: \$? = $ac_status" >&5
+  echo "$as_me:12190: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_builtin_bool=1
 else
@@ -10908,13 +12200,13 @@
 fi
 
 if test "$cf_cv_builtin_bool" = 1
-then	echo "$as_me:10911: result: yes" >&5
+then	echo "$as_me:12203: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-else	echo "$as_me:10913: result: no" >&5
+else	echo "$as_me:12205: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
-echo "$as_me:10917: checking for size of bool" >&5
+echo "$as_me:12209: checking for size of bool" >&5
 echo $ECHO_N "checking for size of bool... $ECHO_C" >&6
 if test "${cf_cv_type_of_bool+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -10925,7 +12217,7 @@
   cf_cv_type_of_bool=unknown
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 10928 "configure"
+#line 12220 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -10967,15 +12259,15 @@
 
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:10970: \"$ac_link\"") >&5
+if { (eval echo "$as_me:12262: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:10973: \$? = $ac_status" >&5
+  echo "$as_me:12265: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:10975: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12267: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:10978: \$? = $ac_status" >&5
+  echo "$as_me:12270: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_type_of_bool=`cat cf_test.out`
 		 if test -z "$cf_cv_type_of_bool"; then
@@ -10993,18 +12285,18 @@
 fi
 
 	rm -f cf_test.out
-echo "$as_me:10996: result: $cf_cv_type_of_bool" >&5
+echo "$as_me:12288: result: $cf_cv_type_of_bool" >&5
 echo "${ECHO_T}$cf_cv_type_of_bool" >&6
 if test "$cf_cv_type_of_bool" = unknown ; then
 	case .$NCURSES_BOOL in #(vi
 	.auto|.) NCURSES_BOOL=unsigned;;
 	esac
-	{ echo "$as_me:11002: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
+	{ echo "$as_me:12294: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
 echo "$as_me: WARNING: Assuming $NCURSES_BOOL for type of bool" >&2;}
 	cf_cv_type_of_bool=$NCURSES_BOOL
 fi
 
-echo "$as_me:11007: checking for special defines needed for etip.h" >&5
+echo "$as_me:12299: checking for special defines needed for etip.h" >&5
 echo $ECHO_N "checking for special defines needed for etip.h... $ECHO_C" >&6
 cf_save_CXXFLAGS="$CXXFLAGS"
 cf_result="none"
@@ -11016,7 +12308,7 @@
 	test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
 	test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
 cat >conftest.$ac_ext <<_ACEOF
-#line 11019 "configure"
+#line 12311 "configure"
 #include "confdefs.h"
 
 #include <etip.h.in>
@@ -11030,16 +12322,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:11033: \"$ac_compile\"") >&5
+if { (eval echo "$as_me:12325: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
-  echo "$as_me:11036: \$? = $ac_status" >&5
+  echo "$as_me:12328: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:11039: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12331: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11042: \$? = $ac_status" >&5
+  echo "$as_me:12334: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
 	test -n "$cf_math" && cat >>confdefs.h <<EOF
@@ -11060,12 +12352,12 @@
 rm -f conftest.$ac_objext conftest.$ac_ext
 done
 done
-echo "$as_me:11063: result: $cf_result" >&5
+echo "$as_me:12355: result: $cf_result" >&5
 echo "${ECHO_T}$cf_result" >&6
 CXXFLAGS="$cf_save_CXXFLAGS"
 
 if test -n "$CXX"; then
-echo "$as_me:11068: checking if $CXX accepts parameter initialization" >&5
+echo "$as_me:12360: checking if $CXX accepts parameter initialization" >&5
 echo $ECHO_N "checking if $CXX accepts parameter initialization... $ECHO_C" >&6
 if test "${cf_cv_cpp_param_init+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -11081,7 +12373,7 @@
   cf_cv_cpp_param_init=unknown
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 11084 "configure"
+#line 12376 "configure"
 #include "confdefs.h"
 
 class TEST {
@@ -11100,15 +12392,15 @@
 
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:11103: \"$ac_link\"") >&5
+if { (eval echo "$as_me:12395: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:11106: \$? = $ac_status" >&5
+  echo "$as_me:12398: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:11108: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12400: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11111: \$? = $ac_status" >&5
+  echo "$as_me:12403: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_cpp_param_init=yes
 else
@@ -11126,7 +12418,7 @@
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
 fi
-echo "$as_me:11129: result: $cf_cv_cpp_param_init" >&5
+echo "$as_me:12421: result: $cf_cv_cpp_param_init" >&5
 echo "${ECHO_T}$cf_cv_cpp_param_init" >&6
 fi
 test "$cf_cv_cpp_param_init" = yes && cat >>confdefs.h <<\EOF
@@ -11144,23 +12436,23 @@
 for ac_header in strstream.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:11147: checking for $ac_header" >&5
+echo "$as_me:12439: checking for $ac_header" >&5
 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 11153 "configure"
+#line 12445 "configure"
 #include "confdefs.h"
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:11157: \"$ac_cpp conftest.$ac_ext\"") >&5
+if { (eval echo "$as_me:12449: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
   ac_status=$?
   egrep -v '^ *\+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
-  echo "$as_me:11163: \$? = $ac_status" >&5
+  echo "$as_me:12455: \$? = $ac_status" >&5
   (exit $ac_status); } >/dev/null; then
   if test -s conftest.err; then
     ac_cpp_err=$ac_cxx_preproc_warn_flag
@@ -11179,7 +12471,7 @@
 fi
 rm -f conftest.err conftest.$ac_ext
 fi
-echo "$as_me:11182: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "$as_me:12474: result: `eval echo '${'$as_ac_Header'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<EOF
@@ -11189,7 +12481,7 @@
 fi
 done
 
-echo "$as_me:11192: checking if $CXX supports vscan function" >&5
+echo "$as_me:12484: checking if $CXX supports vscan function" >&5
 echo $ECHO_N "checking if $CXX supports vscan function... $ECHO_C" >&6
 if test "${cf_cv_cpp_vscan_func+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -11203,7 +12495,7 @@
 	strstream_cast)	cf_vscan_defs=USE_STRSTREAM_VSCAN_CAST ;;
 	esac
 	cat >conftest.$ac_ext <<_ACEOF
-#line 11206 "configure"
+#line 12498 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -11248,16 +12540,16 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:11251: \"$ac_link\"") >&5
+if { (eval echo "$as_me:12543: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:11254: \$? = $ac_status" >&5
+  echo "$as_me:12546: \$? = $ac_status" >&5
   (exit $ac_status); } &&
          { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:11257: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12549: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11260: \$? = $ac_status" >&5
+  echo "$as_me:12552: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_cpp_vscan_func=$cf_vscan_func; break
 else
@@ -11270,7 +12562,7 @@
 	done
 
 fi
-echo "$as_me:11273: result: $cf_cv_cpp_vscan_func" >&5
+echo "$as_me:12565: result: $cf_cv_cpp_vscan_func" >&5
 echo "${ECHO_T}$cf_cv_cpp_vscan_func" >&6
 
 ac_ext=cc
@@ -11352,7 +12644,7 @@
 	else
 		if test "$cf_cv_header_stdbool_h" = 1 ; then
 
-echo "$as_me:11355: checking for size of bool" >&5
+echo "$as_me:12647: checking for size of bool" >&5
 echo $ECHO_N "checking for size of bool... $ECHO_C" >&6
 if test "${cf_cv_type_of_bool+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -11363,7 +12655,7 @@
   cf_cv_type_of_bool=unknown
 else
   cat >conftest.$ac_ext <<_ACEOF
-#line 11366 "configure"
+#line 12658 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -11405,15 +12697,15 @@
 
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:11408: \"$ac_link\"") >&5
+if { (eval echo "$as_me:12700: \"$ac_link\"") >&5
   (eval $ac_link) 2>&5
   ac_status=$?
-  echo "$as_me:11411: \$? = $ac_status" >&5
+  echo "$as_me:12703: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:11413: \"$ac_try\"") >&5
+  { (eval echo "$as_me:12705: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
-  echo "$as_me:11416: \$? = $ac_status" >&5
+  echo "$as_me:12708: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
   cf_cv_type_of_bool=`cat cf_test.out`
 		 if test -z "$cf_cv_type_of_bool"; then
@@ -11431,25 +12723,25 @@
 fi
 
 	rm -f cf_test.out
-echo "$as_me:11434: result: $cf_cv_type_of_bool" >&5
+echo "$as_me:12726: result: $cf_cv_type_of_bool" >&5
 echo "${ECHO_T}$cf_cv_type_of_bool" >&6
 if test "$cf_cv_type_of_bool" = unknown ; then
 	case .$NCURSES_BOOL in #(vi
 	.auto|.) NCURSES_BOOL=unsigned;;
 	esac
-	{ echo "$as_me:11440: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
+	{ echo "$as_me:12732: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
 echo "$as_me: WARNING: Assuming $NCURSES_BOOL for type of bool" >&2;}
 	cf_cv_type_of_bool=$NCURSES_BOOL
 fi
 
 		else
-			echo "$as_me:11446: checking for fallback type of bool" >&5
+			echo "$as_me:12738: checking for fallback type of bool" >&5
 echo $ECHO_N "checking for fallback type of bool... $ECHO_C" >&6
 			case "$host_cpu" in #(vi
 			i?86)	cf_cv_type_of_bool=char	;; #(vi
 			*)	cf_cv_type_of_bool=int	;;
 			esac
-			echo "$as_me:11452: result: $cf_cv_type_of_bool" >&5
+			echo "$as_me:12744: result: $cf_cv_type_of_bool" >&5
 echo "${ECHO_T}$cf_cv_type_of_bool" >&6
 		fi
 	fi
@@ -11478,7 +12770,7 @@
 cf_ada_make=gnatmake
 # Extract the first word of "$cf_ada_make", so it can be a program name with args.
 set dummy $cf_ada_make; ac_word=$2
-echo "$as_me:11481: checking for $ac_word" >&5
+echo "$as_me:12773: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_gnat_exists+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -11493,7 +12785,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_gnat_exists="yes"
-echo "$as_me:11496: found $ac_dir/$ac_word" >&5
+echo "$as_me:12788: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -11502,10 +12794,10 @@
 fi
 gnat_exists=$ac_cv_prog_gnat_exists
 if test -n "$gnat_exists"; then
-  echo "$as_me:11505: result: $gnat_exists" >&5
+  echo "$as_me:12797: result: $gnat_exists" >&5
 echo "${ECHO_T}$gnat_exists" >&6
 else
-  echo "$as_me:11508: result: no" >&5
+  echo "$as_me:12800: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -11513,11 +12805,11 @@
    cf_ada_make=
 else
 
-echo "$as_me:11516: checking for gnat version" >&5
+echo "$as_me:12808: checking for gnat version" >&5
 echo $ECHO_N "checking for gnat version... $ECHO_C" >&6
 cf_gnat_version=`${cf_ada_make-gnatmake} -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\
   sed -e '2,$d' -e 's/[^0-9 \.]//g' -e 's/^[ ]*//' -e 's/ .*//'`
-echo "$as_me:11520: result: $cf_gnat_version" >&5
+echo "$as_me:12812: result: $cf_gnat_version" >&5
 echo "${ECHO_T}$cf_gnat_version" >&6
 
 case $cf_gnat_version in
@@ -11540,7 +12832,7 @@
 
    # Extract the first word of "m4", so it can be a program name with args.
 set dummy m4; ac_word=$2
-echo "$as_me:11543: checking for $ac_word" >&5
+echo "$as_me:12835: checking for $ac_word" >&5
 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
 if test "${ac_cv_prog_M4_exists+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
@@ -11555,7 +12847,7 @@
   test -z "$ac_dir" && ac_dir=.
   $as_executable_p "$ac_dir/$ac_word" || continue
 ac_cv_prog_M4_exists="yes"
-echo "$as_me:11558: found $ac_dir/$ac_word" >&5
+echo "$as_me:12850: found $ac_dir/$ac_word" >&5
 break
 done
 
@@ -11564,10 +12856,10 @@
 fi
 M4_exists=$ac_cv_prog_M4_exists
 if test -n "$M4_exists"; then
-  echo "$as_me:11567: result: $M4_exists" >&5
+  echo "$as_me:12859: result: $M4_exists" >&5
 echo "${ECHO_T}$M4_exists" >&6
 else
-  echo "$as_me:11570: result: no" >&5
+  echo "$as_me:12862: result: no" >&5
 echo "${ECHO_T}no" >&6
 fi
 
@@ -11576,7 +12868,7 @@
       echo Ada95 binding required program m4 not found. Ada95 binding disabled.
    fi
    if test "$cf_cv_prog_gnat_correct" = yes; then
-      echo "$as_me:11579: checking if GNAT works" >&5
+      echo "$as_me:12871: checking if GNAT works" >&5
 echo $ECHO_N "checking if GNAT works... $ECHO_C" >&6
 
 rm -f conftest*
@@ -11593,7 +12885,7 @@
    GNAT.OS_Lib.OS_Exit (0);
 end conftest;
 CF_EOF
-if ( $cf_ada_make conftest 1>&5 2>&1 ) ; then
+if ( $cf_ada_make $ADAFLAGS conftest 1>&5 2>&1 ) ; then
    if ( ./conftest 1>&5 2>&1 ) ; then
       cf_cv_prog_gnat_correct=yes
    else
@@ -11604,13 +12896,50 @@
 fi
 rm -f conftest*
 
-      echo "$as_me:11607: result: $cf_cv_prog_gnat_correct" >&5
+      echo "$as_me:12899: result: $cf_cv_prog_gnat_correct" >&5
 echo "${ECHO_T}$cf_cv_prog_gnat_correct" >&6
    fi
 fi
 if test	"$cf_cv_prog_gnat_correct" = yes; then
    ADAFLAGS="-O3 -gnatpn $ADAFLAGS"
 
+   echo "$as_me:12906: checking if GNAT pragma Unreferenced works" >&5
+echo $ECHO_N "checking if GNAT pragma Unreferenced works... $ECHO_C" >&6
+
+rm -f conftest*
+cat >>conftest.ads <<CF_EOF
+procedure conftest;
+CF_EOF
+cat >>conftest.adb <<CF_EOF
+with Text_IO;
+with GNAT.OS_Lib;
+procedure conftest is
+   test : Integer;
+   pragma Unreferenced (test);
+begin
+   test := 1;
+   Text_IO.Put ("Hello World");
+   Text_IO.New_Line;
+   GNAT.OS_Lib.OS_Exit (0);
+end conftest;
+CF_EOF
+if ( $cf_ada_make $ADAFLAGS conftest 1>&5 2>&1 ) ; then
+      cf_cv_pragma_unreferenced=yes
+else
+   cf_cv_pragma_unreferenced=no
+fi
+rm -f conftest*
+
+   echo "$as_me:12933: result: $cf_cv_pragma_unreferenced" >&5
+echo "${ECHO_T}$cf_cv_pragma_unreferenced" >&6
+
+   # if the pragma is supported, use it (needed in the Trace code).
+   if test $cf_cv_pragma_unreferenced = yes ; then
+      PRAGMA_UNREF=TRUE
+   else
+      PRAGMA_UNREF=FALSE
+   fi
+
 # Check whether --with-ada-compiler or --without-ada-compiler was given.
 if test "${with_ada_compiler+set}" = set; then
   withval="$with_ada_compiler"
@@ -11647,7 +12976,7 @@
   withval=`echo $withval | sed -e s%NONE%$ac_default_prefix%`
   ;;
 *)
-  { { echo "$as_me:11650: error: expected a pathname, not \"$withval\"" >&5
+  { { echo "$as_me:12979: error: expected a pathname, not \"$withval\"" >&5
 echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
    { (exit 1); exit 1; }; }
   ;;
@@ -11681,7 +13010,7 @@
   withval=`echo $withval | sed -e s%NONE%$ac_default_prefix%`
   ;;
 *)
-  { { echo "$as_me:11684: error: expected a pathname, not \"$withval\"" >&5
+  { { echo "$as_me:13013: error: expected a pathname, not \"$withval\"" >&5
 echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
    { (exit 1); exit 1; }; }
   ;;
@@ -11694,9 +13023,9 @@
 
 ### Construct the library-subsets, if any, from this set of keywords:
 ### none, base, ext_funcs, ext_tinfo, termlib, widechar (see CF_LIB_RULES).
-echo "$as_me:11697: checking for library subsets" >&5
+echo "$as_me:13026: checking for library subsets" >&5
 echo $ECHO_N "checking for library subsets... $ECHO_C" >&6
-if test "$with_termlib" = yes ; then
+if test "$with_termlib" != no ; then
 	LIB_SUBSETS="termlib"
 	test "$with_ext_funcs" = yes && LIB_SUBSETS="${LIB_SUBSETS}+ext_tinfo"
 	LIB_SUBSETS="${LIB_SUBSETS} "
@@ -11707,7 +13036,7 @@
 LIB_SUBSETS="${LIB_SUBSETS}base"
 test "$with_widec"     = yes && LIB_SUBSETS="${LIB_SUBSETS}+widechar"
 test "$with_ext_funcs" = yes && LIB_SUBSETS="${LIB_SUBSETS}+ext_funcs"
-echo "$as_me:11710: result: $LIB_SUBSETS" >&5
+echo "$as_me:13039: result: $LIB_SUBSETS" >&5
 echo "${ECHO_T}$LIB_SUBSETS" >&6
 
 ### Construct the list of include-directories to be generated
@@ -11745,7 +13074,7 @@
 fi
 
 ### Build up pieces for makefile rules
-echo "$as_me:11748: checking default library suffix" >&5
+echo "$as_me:13077: checking default library suffix" >&5
 echo $ECHO_N "checking default library suffix... $ECHO_C" >&6
 
 	case $DFT_LWR_MODEL in
@@ -11756,10 +13085,10 @@
 	shared)  DFT_ARG_SUFFIX=''   ;;
 	esac
 	test -n "$LIB_SUFFIX" && DFT_ARG_SUFFIX="${LIB_SUFFIX}${DFT_ARG_SUFFIX}"
-echo "$as_me:11759: result: $DFT_ARG_SUFFIX" >&5
+echo "$as_me:13088: result: $DFT_ARG_SUFFIX" >&5
 echo "${ECHO_T}$DFT_ARG_SUFFIX" >&6
 
-echo "$as_me:11762: checking default library-dependency suffix" >&5
+echo "$as_me:13091: checking default library-dependency suffix" >&5
 echo $ECHO_N "checking default library-dependency suffix... $ECHO_C" >&6
 
 	case $DFT_LWR_MODEL in
@@ -11788,10 +13117,10 @@
 		;;
 	esac
 fi
-echo "$as_me:11791: result: $DFT_DEP_SUFFIX" >&5
+echo "$as_me:13120: result: $DFT_DEP_SUFFIX" >&5
 echo "${ECHO_T}$DFT_DEP_SUFFIX" >&6
 
-echo "$as_me:11794: checking default object directory" >&5
+echo "$as_me:13123: checking default object directory" >&5
 echo $ECHO_N "checking default object directory... $ECHO_C" >&6
 
 	case $DFT_LWR_MODEL in
@@ -11807,12 +13136,12 @@
 			DFT_OBJ_SUBDIR='obj_s' ;;
 		esac
 	esac
-echo "$as_me:11810: result: $DFT_OBJ_SUBDIR" >&5
+echo "$as_me:13139: result: $DFT_OBJ_SUBDIR" >&5
 echo "${ECHO_T}$DFT_OBJ_SUBDIR" >&6
 
 # libtool thinks it can make c++ shared libraries (perhaps only g++)
 if test "$cf_with_cxx" = yes ; then
-echo "$as_me:11815: checking c++ library-dependency suffix" >&5
+echo "$as_me:13144: checking c++ library-dependency suffix" >&5
 echo $ECHO_N "checking c++ library-dependency suffix... $ECHO_C" >&6
 if test "$with_libtool" != "no"; then
 	CXX_LIB_SUFFIX=$DFT_DEP_SUFFIX
@@ -11838,22 +13167,47 @@
 	esac
 	test -n "$LIB_SUFFIX" && CXX_LIB_SUFFIX="${LIB_SUFFIX}${CXX_LIB_SUFFIX}"
 fi
-echo "$as_me:11841: result: $CXX_LIB_SUFFIX" >&5
+echo "$as_me:13170: result: $CXX_LIB_SUFFIX" >&5
 echo "${ECHO_T}$CXX_LIB_SUFFIX" >&6
 
 fi
 
+### Set up low-level terminfo dependencies for makefiles.
 TINFO_LIST="$SHLIB_LIST"
-if test "$with_libtool" = no ; then
-	test "$with_termlib" = yes && SHLIB_LIST="$SHLIB_LIST -ltinfo${LIB_SUFFIX}"
+if test "$with_termlib" != no ; then
+
+	if test "$with_termlib" != yes ; then
+		TINFO_NAME=$with_termlib
+		TINFO_ARG_SUFFIX="${with_termlib}`echo ${DFT_ARG_SUFFIX}|sed -e "s/^${LIB_SUFFIX}//"`"
+		TINFO_DEP_SUFFIX="${with_termlib}`echo ${DFT_DEP_SUFFIX}|sed -e "s/^${LIB_SUFFIX}//"`"
+		TINFO_LIB_SUFFIX="${with_termlib}"
+	else
+		TINFO_ARG_SUFFIX="${TINFO_NAME}${DFT_ARG_SUFFIX}"
+		TINFO_DEP_SUFFIX="${TINFO_NAME}${DFT_DEP_SUFFIX}"
+		TINFO_LIB_SUFFIX="${TINFO_NAME}${LIB_SUFFIX}"
+	fi
+
+	TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TINFO_DEP_SUFFIX}"
+	if test "$DFT_LWR_MODEL" = "libtool"; then
+		TEST_ARGS="${TEST_DEPS}"
+	else
+		TEST_ARGS="-l${TINFO_ARG_SUFFIX}"
+		TINFO_ARGS="-L${LIB_DIR} $TEST_ARGS"
+		SHLIB_LIST="$SHLIB_LIST -l${TINFO_LIB_SUFFIX}"
+	fi
+else
+	TINFO_ARGS="-L${LIB_DIR} -l${LIB_NAME}${DFT_ARG_SUFFIX}"
 fi
 
-echo "$as_me:11851: checking where we will install curses.h" >&5
+# needed for Ada95
+TINFO_ARGS2=`echo "$TINFO_ARGS" | sed -e 's,-L\.\./,-L../../,'`
+
+echo "$as_me:13205: checking where we will install curses.h" >&5
 echo $ECHO_N "checking where we will install curses.h... $ECHO_C" >&6
 test "$with_overwrite" = no && \
 test "x$includedir" = 'x${prefix}/include' && \
 	includedir='$(prefix)/include/ncurses'${LIB_SUFFIX}
-echo "$as_me:11856: result: $includedir" >&5
+echo "$as_me:13210: result: $includedir" >&5
 echo "${ECHO_T}$includedir" >&6
 
 ### Resolve a conflict between normal and wide-curses by forcing applications
@@ -11861,24 +13215,11 @@
 if test "$with_overwrite" != no ; then
 if test "$NCURSES_LIBUTF8" = 1 ; then
 	NCURSES_LIBUTF8='defined(HAVE_LIBUTF8_H)'
-	{ echo "$as_me:11864: WARNING: Wide-character applications must define HAVE_LIBUTF8_H to include curses.h" >&5
+	{ echo "$as_me:13218: WARNING: Wide-character applications must define HAVE_LIBUTF8_H to include curses.h" >&5
 echo "$as_me: WARNING: Wide-character applications must define HAVE_LIBUTF8_H to include curses.h" >&2;}
 fi
 fi
 
-### Set up low-level terminfo dependencies for makefiles.  Note that we
-### could override this.
-if test "$with_termlib" = yes ; then
-	TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TINFO_NAME}${DFT_DEP_SUFFIX}"
-	if test "$DFT_LWR_MODEL" = "libtool"; then
-		TEST_ARGS="${TEST_DEPS}"
-	else
-		TEST_ARGS="-l${TINFO_NAME}${DFT_ARG_SUFFIX}"
-	fi
-fi
-PROG_DEPS="$TEST_DEPS"
-PROG_ARGS="$TEST_ARGS"
-
 ### predefined stuff for the test programs
 cat >>confdefs.h <<\EOF
 #define HAVE_SLK_COLOR 1
@@ -11887,7 +13228,7 @@
 ### Construct the list of subdirectories for which we'll customize makefiles
 ### with the appropriate compile-rules.
 
-echo "$as_me:11890: checking for src modules" >&5
+echo "$as_me:13231: checking for src modules" >&5
 echo $ECHO_N "checking for src modules... $ECHO_C" >&6
 
 # dependencies and linker-arguments for test-programs
@@ -11898,9 +13239,6 @@
 	TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
 fi
 
-# dependencies and linker-arguments for utility-programs
-test "$with_termlib" != yes && PROG_ARGS="$TEST_ARGS"
-
 cf_cv_src_modules=
 for cf_dir in $modules_to_build
 do
@@ -11947,12 +13285,10 @@
 		fi
 	fi
 done
-echo "$as_me:11950: result: $cf_cv_src_modules" >&5
+echo "$as_me:13288: result: $cf_cv_src_modules" >&5
 echo "${ECHO_T}$cf_cv_src_modules" >&6
 TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
 
-PROG_ARGS="-L${LIB_DIR} $PROG_ARGS"
-
 SRC_SUBDIRS="man include"
 for cf_dir in $cf_cv_src_modules
 do
@@ -12021,12 +13357,34 @@
 
 ### Now that we're done running tests, add the compiler-warnings, if any
 
+cf_fix_cppflags=no
 cf_new_cflags=
 cf_new_cppflags=
+cf_new_extra_cppflags=
+
 for cf_add_cflags in $EXTRA_CFLAGS
 do
+case $cf_fix_cppflags in
+no)
 	case $cf_add_cflags in #(vi
 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+		case $cf_add_cflags in
+		-D*)
+			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+			&& test -z "${cf_tst_cflags}" \
+			&& cf_fix_cppflags=yes
+
+			if test $cf_fix_cppflags = yes ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			fi
+			;;
+		esac
 		case "$CPPFLAGS" in
 		*$cf_add_cflags) #(vi
 			;;
@@ -12039,6 +13397,17 @@
 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
 		;;
 	esac
+	;;
+yes)
+	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+	&& test -z "${cf_tst_cflags}" \
+	&& cf_fix_cppflags=no
+	;;
+esac
 done
 
 if test -n "$cf_new_cflags" ; then
@@ -12051,6 +13420,11 @@
 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
 fi
 
+if test -n "$cf_new_extra_cppflags" ; then
+
+	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
 ################################################################################
 test "$use_database" = yes && SUB_MAKEFILES="$SUB_MAKEFILES misc/run_tic.sh:misc/run_tic.in"
 ac_config_files="$ac_config_files include/MKterm.h.awk include/curses.head:include/curses.h.in include/termcap.h include/unctrl.h $SUB_MAKEFILES Makefile"
@@ -12134,7 +13508,7 @@
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:12137: creating $CONFIG_STATUS" >&5
+{ echo "$as_me:13511: creating $CONFIG_STATUS" >&5
 echo "$as_me: creating $CONFIG_STATUS" >&6;}
 cat >$CONFIG_STATUS <<_ACEOF
 #! $SHELL
@@ -12310,7 +13684,7 @@
     echo "$ac_cs_version"; exit 0 ;;
   --he | --h)
     # Conflict between --help and --header
-    { { echo "$as_me:12313: error: ambiguous option: $1
+    { { echo "$as_me:13687: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: ambiguous option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -12329,7 +13703,7 @@
     ac_need_defaults=false;;
 
   # This is an error.
-  -*) { { echo "$as_me:12332: error: unrecognized option: $1
+  -*) { { echo "$as_me:13706: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&5
 echo "$as_me: error: unrecognized option: $1
 Try \`$0 --help' for more information." >&2;}
@@ -12369,6 +13743,7 @@
 
 AWK="$AWK"
 CF_LIST_MODELS="$cf_list_models"
+DFT_ARG_SUFFIX="$DFT_ARG_SUFFIX"
 DFT_LWR_MODEL="$DFT_LWR_MODEL"
 LDCONFIG="$LDCONFIG"
 LIB_NAME="$LIB_NAME"
@@ -12379,12 +13754,17 @@
 NCURSES_OSPEED="$NCURSES_OSPEED"
 SRC_SUBDIRS="$SRC_SUBDIRS"
 TERMINFO="$TERMINFO"
+TINFO_ARG_SUFFIX="$TINFO_ARG_SUFFIX"
+TINFO_LIB_SUFFIX="$TINFO_LIB_SUFFIX"
 TINFO_NAME="$TINFO_NAME"
 WITH_CURSES_H="$with_curses_h"
 WITH_ECHO="$with_echo"
 WITH_OVERWRITE="$with_overwrite"
 cf_cv_abi_version="$cf_cv_abi_version"
 cf_cv_do_symlinks="$cf_cv_do_symlinks"
+cf_cv_enable_lp64="$cf_cv_enable_lp64"
+cf_cv_prog_CC_c_o=$cf_cv_prog_CC_c_o
+cf_cv_prog_CXX_c_o=$cf_cv_prog_CXX_c_o
 cf_cv_rel_version="$cf_cv_rel_version"
 cf_cv_rm_so_locs="$cf_cv_rm_so_locs"
 cf_cv_shlib_version="$cf_cv_shlib_version"
@@ -12409,7 +13789,7 @@
   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
   "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
   "include/ncurses_cfg.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/ncurses_cfg.h:include/ncurses_cfg.hin" ;;
-  *) { { echo "$as_me:12412: error: invalid argument: $ac_config_target" >&5
+  *) { { echo "$as_me:13792: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
   esac
@@ -12519,6 +13899,7 @@
 s,@EXEEXT@,$EXEEXT,;t t
 s,@OBJEXT@,$OBJEXT,;t t
 s,@CPP@,$CPP,;t t
+s,@EXTRA_CPPFLAGS@,$EXTRA_CPPFLAGS,;t t
 s,@PROG_EXT@,$PROG_EXT,;t t
 s,@LDCONFIG@,$LDCONFIG,;t t
 s,@CXX@,$CXX,;t t
@@ -12545,11 +13926,13 @@
 s,@cf_cv_makeflags@,$cf_cv_makeflags,;t t
 s,@DESTDIR@,$DESTDIR,;t t
 s,@BUILD_CC@,$BUILD_CC,;t t
+s,@BUILD_CPP@,$BUILD_CPP,;t t
 s,@BUILD_CFLAGS@,$BUILD_CFLAGS,;t t
 s,@BUILD_CPPFLAGS@,$BUILD_CPPFLAGS,;t t
 s,@BUILD_LDFLAGS@,$BUILD_LDFLAGS,;t t
 s,@BUILD_LIBS@,$BUILD_LIBS,;t t
 s,@BUILD_EXEEXT@,$BUILD_EXEEXT,;t t
+s,@BUILD_OBJEXT@,$BUILD_OBJEXT,;t t
 s,@cf_list_models@,$cf_list_models,;t t
 s,@LIBTOOL@,$LIBTOOL,;t t
 s,@LIBTOOL_CXX@,$LIBTOOL_CXX,;t t
@@ -12582,17 +13965,12 @@
 s,@TERMINFO_SRC@,$TERMINFO_SRC,;t t
 s,@PATHSEP@,$PATHSEP,;t t
 s,@FALLBACK_LIST@,$FALLBACK_LIST,;t t
+s,@WHICH_XTERM@,$WHICH_XTERM,;t t
 s,@TERMINFO_DIRS@,$TERMINFO_DIRS,;t t
 s,@TERMINFO@,$TERMINFO,;t t
 s,@MAKE_TERMINFO@,$MAKE_TERMINFO,;t t
 s,@TERMPATH@,$TERMPATH,;t t
 s,@BROKEN_LINKER@,$BROKEN_LINKER,;t t
-s,@NCURSES_BOOL@,$NCURSES_BOOL,;t t
-s,@NCURSES_OSPEED@,$NCURSES_OSPEED,;t t
-s,@MANPAGE_RENAMES@,$MANPAGE_RENAMES,;t t
-s,@NCURSES_EXT_FUNCS@,$NCURSES_EXT_FUNCS,;t t
-s,@NCURSES_CONST@,$NCURSES_CONST,;t t
-s,@NCURSES_XNAMES@,$NCURSES_XNAMES,;t t
 s,@NCURSES_CH_T@,$NCURSES_CH_T,;t t
 s,@NCURSES_LIBUTF8@,$NCURSES_LIBUTF8,;t t
 s,@NEED_WCHAR_H@,$NEED_WCHAR_H,;t t
@@ -12601,9 +13979,19 @@
 s,@NCURSES_WINT_T@,$NCURSES_WINT_T,;t t
 s,@NCURSES_OK_WCHAR_T@,$NCURSES_OK_WCHAR_T,;t t
 s,@NCURSES_OK_WINT_T@,$NCURSES_OK_WINT_T,;t t
+s,@cf_cv_enable_lp64@,$cf_cv_enable_lp64,;t t
+s,@NCURSES_BOOL@,$NCURSES_BOOL,;t t
 s,@TERMINFO_CAPS@,$TERMINFO_CAPS,;t t
+s,@NCURSES_OSPEED@,$NCURSES_OSPEED,;t t
+s,@MANPAGE_RENAMES@,$MANPAGE_RENAMES,;t t
+s,@NCURSES_EXT_FUNCS@,$NCURSES_EXT_FUNCS,;t t
+s,@NCURSES_CONST@,$NCURSES_CONST,;t t
+s,@NCURSES_XNAMES@,$NCURSES_XNAMES,;t t
+s,@NCURSES_EXT_COLORS@,$NCURSES_EXT_COLORS,;t t
+s,@NCURSES_MOUSE_VERSION@,$NCURSES_MOUSE_VERSION,;t t
 s,@ECHO_LINK@,$ECHO_LINK,;t t
 s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t
+s,@EXTRA_CXXFLAGS@,$EXTRA_CXXFLAGS,;t t
 s,@ADA_TRACE@,$ADA_TRACE,;t t
 s,@MATH_LIB@,$MATH_LIB,;t t
 s,@cf_cv_typeof_chtype@,$cf_cv_typeof_chtype,;t t
@@ -12623,6 +14011,7 @@
 s,@ADAFLAGS@,$ADAFLAGS,;t t
 s,@cf_compile_generics@,$cf_compile_generics,;t t
 s,@cf_generic_objects@,$cf_generic_objects,;t t
+s,@PRAGMA_UNREF@,$PRAGMA_UNREF,;t t
 s,@ADA_INCLUDE@,$ADA_INCLUDE,;t t
 s,@ADA_OBJECTS@,$ADA_OBJECTS,;t t
 s,@ACPPFLAGS@,$ACPPFLAGS,;t t
@@ -12630,12 +14019,15 @@
 s,@DFT_DEP_SUFFIX@,$DFT_DEP_SUFFIX,;t t
 s,@DFT_OBJ_SUBDIR@,$DFT_OBJ_SUBDIR,;t t
 s,@CXX_LIB_SUFFIX@,$CXX_LIB_SUFFIX,;t t
-s,@EXTRA_LIBS@,$EXTRA_LIBS,;t t
+s,@TINFO_ARG_SUFFIX@,$TINFO_ARG_SUFFIX,;t t
+s,@TINFO_DEP_SUFFIX@,$TINFO_DEP_SUFFIX,;t t
+s,@TINFO_LIB_SUFFIX@,$TINFO_LIB_SUFFIX,;t t
+s,@TINFO_ARGS@,$TINFO_ARGS,;t t
+s,@TINFO_ARGS2@,$TINFO_ARGS2,;t t
 s,@TINFO_LIST@,$TINFO_LIST,;t t
 s,@SHLIB_LIST@,$SHLIB_LIST,;t t
 s,@TEST_DEPS@,$TEST_DEPS,;t t
 s,@TEST_ARGS@,$TEST_ARGS,;t t
-s,@PROG_ARGS@,$PROG_ARGS,;t t
 s,@ADA_SUBDIRS@,$ADA_SUBDIRS,;t t
 s,@DIRS_TO_MAKE@,$DIRS_TO_MAKE,;t t
 CEOF
@@ -12752,7 +14144,7 @@
   esac
 
   if test x"$ac_file" != x-; then
-    { echo "$as_me:12755: creating $ac_file" >&5
+    { echo "$as_me:14147: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
     rm -f "$ac_file"
   fi
@@ -12770,7 +14162,7 @@
       -) echo $tmp/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:12773: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:14165: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -12783,7 +14175,7 @@
            echo $srcdir/$f
          else
            # /dev/null tree
-           { { echo "$as_me:12786: error: cannot find input file: $f" >&5
+           { { echo "$as_me:14178: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
@@ -12849,7 +14241,7 @@
   * )   ac_file_in=$ac_file.in ;;
   esac
 
-  test x"$ac_file" != x- && { echo "$as_me:12852: creating $ac_file" >&5
+  test x"$ac_file" != x- && { echo "$as_me:14244: creating $ac_file" >&5
 echo "$as_me: creating $ac_file" >&6;}
 
   # First look for the input files in the build tree, otherwise in the
@@ -12860,7 +14252,7 @@
       -) echo $tmp/stdin ;;
       [\\/$]*)
          # Absolute (can't be DOS-style, as IFS=:)
-         test -f "$f" || { { echo "$as_me:12863: error: cannot find input file: $f" >&5
+         test -f "$f" || { { echo "$as_me:14255: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          echo $f;;
@@ -12873,7 +14265,7 @@
            echo $srcdir/$f
          else
            # /dev/null tree
-           { { echo "$as_me:12876: error: cannot find input file: $f" >&5
+           { { echo "$as_me:14268: error: cannot find input file: $f" >&5
 echo "$as_me: error: cannot find input file: $f" >&2;}
    { (exit 1); exit 1; }; }
          fi;;
@@ -12931,7 +14323,7 @@
   rm -f $tmp/in
   if test x"$ac_file" != x-; then
     if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
-      { echo "$as_me:12934: $ac_file is unchanged" >&5
+      { echo "$as_me:14326: $ac_file is unchanged" >&5
 echo "$as_me: $ac_file is unchanged" >&6;}
     else
       ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
@@ -13026,13 +14418,33 @@
 				case "$cf_cv_shlib_version" in #(vi
 				rel) #(vi
 					case "$cf_cv_system_name" in #(vi
-					darwin*) cf_suffix='.$(REL_VERSION)'"$cf_suffix" ;; #(vi
+					darwin*)
+					case .${LIB_SUFFIX} in
+					.w*)
+						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
+						cf_suffix=w'.$(REL_VERSION)'"$cf_suffix"
+						;;
+					*)
+						cf_suffix='.$(REL_VERSION)'"$cf_suffix"
+						;;
+					esac
+					;; #(vi
 					*) cf_suffix="$cf_suffix"'.$(REL_VERSION)' ;;
 					esac
 					;;
 				abi)
 					case "$cf_cv_system_name" in #(vi
-					darwin*) cf_suffix='.$(ABI_VERSION)'"$cf_suffix" ;; #(vi
+					darwin*)
+					case .${LIB_SUFFIX} in
+					.w*)
+						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
+						cf_suffix=w'.$(ABI_VERSION)'"$cf_suffix"
+						;;
+					*)
+						cf_suffix='.$(ABI_VERSION)'"$cf_suffix"
+						;;
+					esac
+					;; #(vi
 					*) cf_suffix="$cf_suffix"'.$(ABI_VERSION)' ;;
 					esac
 					;;
@@ -13055,7 +14467,7 @@
 			cf_subsets="$LIB_SUBSETS"
 			cf_termlib=`echo "$cf_subsets" |sed -e 's/ .*$//'`
 			if test "$cf_termlib" != "$cf_subsets" ; then
-				cf_item=`echo $LIBS_TO_MAKE |sed -e s%$LIB_NAME%$TINFO_NAME%g`
+				cf_item=`echo $LIBS_TO_MAKE |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
 				LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
 			fi
 		else
@@ -13115,6 +14527,22 @@
 		esac
 	esac
 
+			# Test for case where we build libtinfo with a different name.
+			cf_libname=$cf_dir
+			if test $cf_dir = ncurses ; then
+				case $cf_subset in
+				*base*)
+					;;
+				termlib*)
+					cf_libname=$TINFO_LIB_SUFFIX
+					if test -n "${DFT_ARG_SUFFIX}" ; then
+						# undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
+						cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
+					fi
+				;;
+				esac
+			fi
+
 			# These dependencies really are for development, not
 			# builds, but they are useful in porting, too.
 			cf_depend="../include/ncurses_cfg.h"
@@ -13130,8 +14558,22 @@
 				cf_depend="$cf_depend $cf_reldir/curses.priv.h"
 			fi
 
+ 			cf_dir_suffix=
+ 			old_cf_suffix="$cf_suffix"
+ 			if test "$cf_cv_shlib_version_infix" = yes ; then
+			if test -n "$LIB_SUFFIX" ; then
+				case $LIB_SUFFIX in
+				w*)
+					cf_libname=`echo $cf_libname | sed 's/w$//'`
+					cf_suffix=`echo $cf_suffix | sed 's/^w//'`
+					cf_dir_suffix=w
+					;;
+				esac
+			fi
+ 			fi
+
 			$AWK -f $srcdir/mk-1st.awk \
-				name=$cf_dir \
+				name=${cf_libname}${cf_dir_suffix} \
 				traces=$LIB_TRACING \
 				MODEL=$CF_ITEM \
 				model=$cf_subdir \
@@ -13147,6 +14589,9 @@
 				depend="$cf_depend" \
 				host="$host" \
 				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
+
+			cf_suffix="$old_cf_suffix"
+
 			for cf_subdir2 in $cf_subdirs lib
 			do
 				test $cf_subdir = $cf_subdir2 && break
@@ -13160,6 +14605,8 @@
 				subset=$cf_subset \
 				srcdir=$srcdir \
 				echo=$WITH_ECHO \
+				crenames=$cf_cv_prog_CC_c_o \
+				cxxrenames=$cf_cv_prog_CXX_c_o \
 				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
 			cf_subdirs="$cf_subdirs $cf_subdir"
 			done
diff -Naur ncurses-5.4.orig/configure.in ncurses-5.4/configure.in
--- ncurses-5.4.orig/configure.in	2004-01-24 19:29:13.000000000 +0000
+++ ncurses-5.4/configure.in	2005-05-13 04:09:58.000000000 +0000
@@ -1,5 +1,5 @@
 dnl***************************************************************************
-dnl Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+dnl Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
 dnl                                                                          *
 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
 dnl copy of this software and associated documentation files (the            *
@@ -28,14 +28,14 @@
 dnl
 dnl Author: Thomas E. Dickey 1995-on
 dnl
-dnl $Id: configure.in,v 1.312 2004/01/24 19:29:13 tom Exp $
+dnl $Id: configure.in,v 1.337 2005/04/30 21:21:59 tom Exp $
 dnl Process this file with autoconf to produce a configure script.
 dnl
 dnl See http://invisible-island.net/autoconf/ for additional information.
 dnl
 dnl ---------------------------------------------------------------------------
 AC_PREREQ(2.13.20020210)
-AC_REVISION($Revision: 1.312 $)
+AC_REVISION($Revision: 1.337 $)
 AC_INIT(ncurses/base/lib_initscr.c)
 AC_CONFIG_HEADER(include/ncurses_cfg.h:include/ncurses_cfg.hin)
 
@@ -62,6 +62,7 @@
 
 AC_PROG_CPP
 AC_PROG_GCC_TRADITIONAL
+CF_PROG_CC_C_O(CC)
 AC_ISC_POSIX
 CF_ANSI_CC_REQD
 CF_PROG_EXT
@@ -180,37 +181,7 @@
 # If we're cross-compiling, allow the user to override the tools and their
 # options.  The configure script is oriented toward identifying the host
 # compiler, etc., but we need a build compiler to generate parts of the source.
-: ${BUILD_CC:='$(CC)'}
-: ${BUILD_CFLAGS:='$(CFLAGS)'}
-: ${BUILD_CPPFLAGS:='$(CPPFLAGS)'}
-: ${BUILD_LDFLAGS:='$(LDFLAGS)'}
-: ${BUILD_LIBS:='$(LIBS)'}
-: ${BUILD_EXEEXT:='$x'}
-if test "$cross_compiling" = yes ; then
-	AC_ARG_WITH(build-cc,
-		[  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
-		[BUILD_CC="$withval"],
-		[AC_CHECK_PROGS(BUILD_CC, $CC gcc cc)])
-	AC_ARG_WITH(build-cflags,
-		[  --with-build-cflags=XXX the build C compiler-flags],
-		[BUILD_CFLAGS="$withval"])
-	AC_ARG_WITH(build-cppflags,
-		[  --with-build-cppflags=XXX the build C preprocessor-flags],
-		[BUILD_CPPFLAGS="$withval"])
-	AC_ARG_WITH(build-ldflags,
-		[  --with-build-ldflags=XXX the build linker-flags],
-		[BUILD_LDFLAGS="$withval"])
-	AC_ARG_WITH(build-libs,
-		[  --with-build-libs=XXX   the build libraries],
-		[BUILD_LIBS="$withval"])
-	BUILD_EXEEXT=
-fi
-AC_SUBST(BUILD_CC)
-AC_SUBST(BUILD_CFLAGS)
-AC_SUBST(BUILD_CPPFLAGS)
-AC_SUBST(BUILD_LDFLAGS)
-AC_SUBST(BUILD_LIBS)
-AC_SUBST(BUILD_EXEEXT)
+CF_BUILD_CC
 
 ###############################################################################
 CF_HELP_MESSAGE(Options to Specify the Libraries Built/Used:)
@@ -310,19 +281,36 @@
 CF_WITH_DMALLOC
 
 SHLIB_LIST=""
-AC_MSG_CHECKING(if you want to link with the gpm mouse library)
+AC_MSG_CHECKING(if you want to link with the GPM mouse library)
 AC_ARG_WITH(gpm,
 	[  --with-gpm              use Alessandro Rubini's GPM library],
 	[with_gpm=$withval],
-	[with_gpm=no])
+	[with_gpm=maybe])
 AC_MSG_RESULT($with_gpm)
-if test "$with_gpm" = yes ; then
+if test "$with_gpm" != no ; then
 	AC_CHECK_LIB(gpm,Gpm_Open,[
-		EXTRA_LIBS="-lgpm -lncurses $EXTRA_LIBS"
-		SHLIB_LIST="-lgpm $SHLIB_LIST"
+		AC_CHECK_HEADER(gpm.h,[
+			AC_DEFINE(HAVE_GPM_H)
+			with_gpm=yes
+		],[
+			if test "$with_gpm" = yes ; then
+				AC_ERROR(Cannot find GPM header)
+			fi
+		])
+	],[
+		if test "$with_gpm" = yes ; then
+			AC_ERROR(Cannot link with GPM library)
+		fi
+		with_gpm=no
+	])
+	if test "$with_gpm" = yes ; then
+		CF_FUNC_DLSYM
+		SHLIB_LIST="-ldl $SHLIB_LIST"
 		AC_DEFINE(HAVE_LIBGPM)
-		AC_CHECK_HEADERS(gpm.h)
-	],AC_MSG_WARN(Cannot link with gpm library - read the FAQ))
+		AC_CHECK_LIB(gpm,Gpm_Wgetch,[
+			AC_MSG_WARN(GPM library is already linked with curses - read the FAQ)
+		])
+	fi
 fi
 
 CF_WITH_SYSMOUSE
@@ -415,6 +403,19 @@
 FALLBACK_LIST=`echo "$with_fallback" | sed -e 's/,/ /g'`
 AC_SUBST(FALLBACK_LIST)
 
+AC_MSG_CHECKING(if you want modern xterm or antique)
+AC_ARG_WITH(xterm-new,
+	[  --without-xterm-new     specify if xterm terminfo should be old version],
+	[with_xterm_new=$withval],
+	[with_xterm_new=yes])
+case $with_xterm_new in
+no)	with_xterm_new=xterm-old;;
+*)	with_xterm_new=xterm-new;;
+esac
+AC_MSG_RESULT($with_xterm_new)
+WHICH_XTERM=$with_xterm_new
+AC_SUBST(WHICH_XTERM)
+
 MAKE_TERMINFO=
 if test "$use_database" = no ; then
 	TERMINFO="${datadir}/terminfo"
@@ -517,8 +518,17 @@
 	[  --disable-home-terminfo drop ~/.terminfo from terminfo search-path],
 	[with_home_terminfo=$enableval],
 	[with_home_terminfo=yes])
+AC_MSG_RESULT($with_home_terminfo)
 test "$with_home_terminfo" = "yes" && AC_DEFINE(USE_HOME_TERMINFO)
 
+AC_MSG_CHECKING(if you want to use restrict environment when running as root)
+AC_ARG_ENABLE(root-environ,
+	[  --disable-root-environ  limit environment when running as root],
+	[with_root_environ=$enableval],
+	[with_root_environ=yes])
+AC_MSG_RESULT($with_root_environ)
+test "$with_root_environ" = yes && AC_DEFINE(USE_ROOT_ENVIRON)
+
 ###   Use option --enable-symlinks to make tic use symlinks, not hard links
 ###   to reduce storage requirements for the terminfo database.
 CF_LINK_FUNCS
@@ -577,6 +587,90 @@
 fi
 AC_SUBST(BROKEN_LINKER)
 
+###   use option --enable-widec to turn on use of wide-character support
+NCURSES_CH_T=chtype
+NCURSES_LIBUTF8=0
+
+NEED_WCHAR_H=0
+NCURSES_MBSTATE_T=0
+NCURSES_WCHAR_T=0
+NCURSES_WINT_T=0
+
+# Check to define _XOPEN_SOURCE "automatically"
+CF_XOPEN_SOURCE
+
+# Checks for CODESET support.
+AM_LANGINFO_CODESET
+
+# use these variables to work around a defect in gcc's fixincludes.
+NCURSES_OK_WCHAR_T=
+NCURSES_OK_WINT_T=
+
+AC_MSG_CHECKING(if you want wide-character code)
+AC_ARG_ENABLE(widec,
+	[  --enable-widec          compile with wide-char/UTF-8 code],
+	[with_widec=$enableval],
+	[with_widec=no])
+AC_MSG_RESULT($with_widec)
+if test "$with_widec" = yes ; then
+	LIB_SUFFIX="w${LIB_SUFFIX}"
+	AC_DEFINE(USE_WIDEC_SUPPORT)
+	CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
+	# with_overwrite=no
+	NCURSES_CH_T=cchar_t
+	AC_CHECK_FUNCS(putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc)
+	if test "$ac_cv_func_putwc" != yes ; then
+		CF_LIBUTF8
+		if test "$cf_cv_libutf8" = yes ; then
+			NCURSES_LIBUTF8=1
+		fi
+	fi
+	CF_WCHAR_TYPE(mbstate_t, NCURSES_MBSTATE_T)
+	CF_WCHAR_TYPE(wchar_t,   NCURSES_WCHAR_T,   NCURSES_OK_WCHAR_T)
+	CF_WCHAR_TYPE(wint_t,    NCURSES_WINT_T,    NCURSES_OK_WINT_T)
+
+	if test "$NCURSES_MBSTATE_T" != 0; then
+		AC_DEFINE(NEED_MBSTATE_T_DEF)
+	fi
+fi
+AC_SUBST(NCURSES_CH_T)
+AC_SUBST(NCURSES_LIBUTF8)
+
+AC_SUBST(NEED_WCHAR_H)
+AC_SUBST(NCURSES_MBSTATE_T)
+AC_SUBST(NCURSES_WCHAR_T)
+AC_SUBST(NCURSES_WINT_T)
+
+AC_SUBST(NCURSES_OK_WCHAR_T)
+AC_SUBST(NCURSES_OK_WINT_T)
+
+###   use option --disable-lp64 to allow long chtype
+AC_MSG_CHECKING(if defining _LP64 overrides chtype definition)
+AC_ARG_ENABLE(lp64,
+	[  --disable-lp64          allow chtype to be long (ignore _LP64)],
+	[with_lp64=$enableval],
+	[with_lp64=yes])
+AC_MSG_RESULT($with_lp64)
+if test "$with_lp64" = yes ; then
+	cf_cv_enable_lp64=1
+else
+	cf_cv_enable_lp64=0
+fi
+AC_SUBST(cf_cv_enable_lp64)
+
+ifdef([AC_FUNC_FSEEKO],[
+AC_MSG_CHECKING(if largefile support is wanted)
+AC_ARG_ENABLE(largefile,
+	[  --enable-largefile      compile-in large file support],
+	[with_largefile=$enableval],
+	[with_largefile=yes])
+AC_MSG_RESULT($with_largefile)
+if test "$with_largefile" = yes ; then
+	AC_FUNC_FSEEKO
+	AC_SYS_LARGEFILE
+fi
+])
+
 ###   use option --with-bool to override bool's type
 AC_MSG_CHECKING(for type of bool)
 AC_ARG_WITH(bool,
@@ -586,6 +680,15 @@
 AC_MSG_RESULT($NCURSES_BOOL)
 AC_SUBST(NCURSES_BOOL)
 
+AC_MSG_CHECKING(for alternate terminal capabilities file)
+AC_ARG_WITH(caps,
+	[  --with-caps=alt         compile with alternate Caps file],
+	[TERMINFO_CAPS=Caps.$withval],
+	[TERMINFO_CAPS=Caps])
+test -f ${srcdir}/include/${TERMINFO_CAPS} || TERMINFO_CAPS=Caps
+AC_MSG_RESULT($TERMINFO_CAPS)
+AC_SUBST(TERMINFO_CAPS)
+
 ###   use option --with-ospeed to override ospeed's type
 AC_MSG_CHECKING(for type of ospeed)
 AC_ARG_WITH(ospeed,
@@ -700,14 +803,6 @@
 AC_MSG_RESULT($with_hardtabs)
 test "$with_hardtabs" = yes && AC_DEFINE(USE_HARD_TABS)
 
-AC_MSG_CHECKING(if you want to use restrict environment when running as root)
-AC_ARG_ENABLE(root-environ,
-	[  --disable-root-environ  limit environment when running as root],
-	[with_root_environ=$enableval],
-	[with_root_environ=yes])
-AC_MSG_RESULT($with_root_environ)
-test "$with_root_environ" = yes && AC_DEFINE(USE_ROOT_ENVIRON)
-
 ###   use option --enable-xmc-glitch to turn on use of magic-cookie optimize
 AC_MSG_CHECKING(if you want limited support for xmc)
 AC_ARG_ENABLE(xmc-glitch,
@@ -747,6 +842,45 @@
 AC_MSG_RESULT($with_colorfgbg)
 test "$with_colorfgbg" = yes && AC_DEFINE(USE_COLORFGBG)
 
+###   use option --enable-ext-colors to turn on use of colors beyond 16.
+AC_MSG_CHECKING(if you want to use experimental extended colors)
+AC_ARG_ENABLE(ext-colors,
+	[  --enable-ext-colors     compile for experimental 256-color support],
+	[with_ext_colors=$enableval],
+	[with_ext_colors=no])
+AC_MSG_RESULT($with_ext_colors)
+NCURSES_EXT_COLORS=0
+if test "$with_ext_colors" = yes ; then
+	if test "$with_widec" != yes ; then
+		AC_MSG_WARN(This option applies only to wide-character library)
+	else
+		# cannot be ABI 5 since it changes sizeof(cchar_t)
+		case $cf_cv_rel_version in
+		5.*)
+			cf_cv_rel_version=6.0
+			cf_cv_abi_version=6
+			AC_MSG_WARN(Overriding ABI version to $cf_cv_abi_version)
+			;;
+		esac
+	fi
+	NCURSES_EXT_COLORS=1
+	AC_DEFINE(NCURSES_EXT_COLORS)
+fi
+AC_SUBST(NCURSES_EXT_COLORS)
+
+###   use option --enable-ext-mouse to modify coding to support 5-button mice
+AC_MSG_CHECKING(if you want to use experimental extended mouse encoding)
+AC_ARG_ENABLE(ext-mouse,
+	[  --enable-ext-mouse      compile for experimental mouse-encoding],
+	[with_ext_mouse=$enableval],
+	[with_ext_mouse=no])
+AC_MSG_RESULT($with_ext_mouse)
+NCURSES_MOUSE_VERSION=1
+if test "$with_ext_mouse" = yes ; then
+	NCURSES_MOUSE_VERSION=2
+fi
+AC_SUBST(NCURSES_MOUSE_VERSION)
+
 AC_MSG_CHECKING(if you want experimental safe-sprintf code)
 AC_ARG_ENABLE(safe-sprintf,
 	[  --enable-safe-sprintf   compile with experimental safe-sprintf code],
@@ -767,66 +901,6 @@
 test "$with_scroll_hints" = yes && AC_DEFINE(USE_SCROLL_HINTS)
 fi
 
-###   use option --enable-widec to turn on use of wide-character support
-NCURSES_CH_T=chtype
-NCURSES_LIBUTF8=0
-
-NEED_WCHAR_H=0
-NCURSES_MBSTATE_T=0
-NCURSES_WCHAR_T=0
-NCURSES_WINT_T=0
-
-# Check to define _XOPEN_SOURCE "automatically"
-CF_XOPEN_SOURCE
-
-# use these variables to work around a defect in gcc's fixincludes.
-NCURSES_OK_WCHAR_T=
-NCURSES_OK_WINT_T=
-
-AC_MSG_CHECKING(if you want experimental wide-character code)
-AC_ARG_ENABLE(widec,
-	[  --enable-widec          compile with experimental wide-char/UTF-8 code],
-	[with_widec=$enableval],
-	[with_widec=no])
-AC_MSG_RESULT($with_widec)
-if test "$with_widec" = yes ; then
-	LIB_SUFFIX="w${LIB_SUFFIX}"
-	AC_DEFINE(USE_WIDEC_SUPPORT)
-	CF_PREDEFINE(_XOPEN_SOURCE,500)
-	CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
-	# with_overwrite=no
-	NCURSES_CH_T=cchar_t
-	AC_CHECK_FUNCS(putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc)
-	if test "$ac_cv_func_putwc" != yes ; then
-		CF_LIBUTF8
-		if test "$cf_cv_libutf8" = yes ; then
-			NCURSES_LIBUTF8=1
-		fi
-	fi
-	CF_WCHAR_TYPE(mbstate_t, NCURSES_MBSTATE_T)
-	CF_WCHAR_TYPE(wchar_t,   NCURSES_WCHAR_T,   NCURSES_OK_WCHAR_T)
-	CF_WCHAR_TYPE(wint_t,    NCURSES_WINT_T,    NCURSES_OK_WINT_T)
-fi
-AC_SUBST(NCURSES_CH_T)
-AC_SUBST(NCURSES_LIBUTF8)
-
-AC_SUBST(NEED_WCHAR_H)
-AC_SUBST(NCURSES_MBSTATE_T)
-AC_SUBST(NCURSES_WCHAR_T)
-AC_SUBST(NCURSES_WINT_T)
-
-AC_SUBST(NCURSES_OK_WCHAR_T)
-AC_SUBST(NCURSES_OK_WINT_T)
-
-AC_MSG_CHECKING(for terminal capabilities file)
-AC_ARG_WITH(caps,
-	[  --with-caps=alt         compile with experimental alternate Caps file],
-	[TERMINFO_CAPS=Caps.$withval],
-	[TERMINFO_CAPS=Caps])
-test -f ${srcdir}/include/${TERMINFO_CAPS} || TERMINFO_CAPS=Caps
-AC_MSG_RESULT($TERMINFO_CAPS)
-AC_SUBST(TERMINFO_CAPS)
-
 ###############################################################################
 CF_HELP_MESSAGE(Testing/development Options:)
 
@@ -855,6 +929,9 @@
 if test -n "$with_warnings"; then
  	ADAFLAGS="$ADAFLAGS -gnatg"
 	CF_GCC_WARNINGS
+	if test "$cf_with_cxx" = yes ; then
+		CF_GXX_WARNINGS(Wno-unused)
+	fi
 fi
 CF_GCC_ATTRIBUTES
 
@@ -983,7 +1060,6 @@
 geteuid \
 getttynam \
 issetugid \
-memccpy \
 nanosleep \
 poll \
 remove \
@@ -1042,6 +1118,7 @@
 if test -n "$CXX" ; then
 	AC_LANG_CPLUSPLUS
 	CF_STDCPP_LIBRARY
+	CF_PROG_CC_C_O(CXX)
 
 	case $GXX_VERSION in
 	1*|2.[0-6]*)
@@ -1055,6 +1132,14 @@
 		;;
 	esac
 
+	case "$GCC_VERSION" in
+	2.95.*)
+		;;
+	*)
+		CPPFLAGS="$CPPFLAGS -DCPP_HAS_STATIC_CAST"
+		;;
+	esac
+
 	AC_CHECK_HEADERS(typeinfo)
 
 	CF_BOOL_DECL
@@ -1168,6 +1253,28 @@
 if test	"$cf_cv_prog_gnat_correct" = yes; then
    ADAFLAGS="-O3 -gnatpn $ADAFLAGS"
 
+   AC_MSG_CHECKING(if GNAT pragma Unreferenced works)
+   CF_GNAT_TRY_LINK([procedure conftest;],
+[with Text_IO;
+with GNAT.OS_Lib;
+procedure conftest is
+   test : Integer;
+   pragma Unreferenced (test);
+begin
+   test := 1;
+   Text_IO.Put ("Hello World");
+   Text_IO.New_Line;
+   GNAT.OS_Lib.OS_Exit (0);
+end conftest;],[cf_cv_pragma_unreferenced=yes],[cf_cv_pragma_unreferenced=no])
+   AC_MSG_RESULT($cf_cv_pragma_unreferenced)
+
+   # if the pragma is supported, use it (needed in the Trace code).
+   if test $cf_cv_pragma_unreferenced = yes ; then
+      PRAGMA_UNREF=TRUE
+   else
+      PRAGMA_UNREF=FALSE
+   fi
+
    AC_ARG_WITH(ada-compiler,
 	[  --with-ada-compiler=CMD specify Ada95 compiler command (default gnatmake)],
 	[cf_ada_compiler=$withval],
@@ -1181,6 +1288,7 @@
    AC_SUBST(ADAFLAGS)
    AC_SUBST(cf_compile_generics)
    AC_SUBST(cf_generic_objects)
+   AC_SUBST(PRAGMA_UNREF)
 
    CF_WITH_PATH(ada-include,
        [  --with-ada-include=DIR  Ada includes are in DIR],
@@ -1202,7 +1310,7 @@
 ### Construct the library-subsets, if any, from this set of keywords:
 ### none, base, ext_funcs, ext_tinfo, termlib, widechar (see CF_LIB_RULES).
 AC_MSG_CHECKING(for library subsets)
-if test "$with_termlib" = yes ; then
+if test "$with_termlib" != no ; then
 	LIB_SUBSETS="termlib"
 	test "$with_ext_funcs" = yes && LIB_SUBSETS="${LIB_SUBSETS}+ext_tinfo"
 	LIB_SUBSETS="${LIB_SUBSETS} "
@@ -1254,10 +1362,40 @@
 AC_SUBST(CXX_LIB_SUFFIX)
 fi
 
+### Set up low-level terminfo dependencies for makefiles.
 TINFO_LIST="$SHLIB_LIST"
-if test "$with_libtool" = no ; then
-	test "$with_termlib" = yes && SHLIB_LIST="$SHLIB_LIST -ltinfo${LIB_SUFFIX}"
+if test "$with_termlib" != no ; then
+
+	if test "$with_termlib" != yes ; then
+		TINFO_NAME=$with_termlib
+		TINFO_ARG_SUFFIX="${with_termlib}`echo ${DFT_ARG_SUFFIX}|sed -e "s/^${LIB_SUFFIX}//"`"
+		TINFO_DEP_SUFFIX="${with_termlib}`echo ${DFT_DEP_SUFFIX}|sed -e "s/^${LIB_SUFFIX}//"`"
+		TINFO_LIB_SUFFIX="${with_termlib}"
+	else
+		TINFO_ARG_SUFFIX="${TINFO_NAME}${DFT_ARG_SUFFIX}"
+		TINFO_DEP_SUFFIX="${TINFO_NAME}${DFT_DEP_SUFFIX}"
+		TINFO_LIB_SUFFIX="${TINFO_NAME}${LIB_SUFFIX}"
+	fi
+
+	TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TINFO_DEP_SUFFIX}"
+	if test "$DFT_LWR_MODEL" = "libtool"; then
+		TEST_ARGS="${TEST_DEPS}"
+	else
+		TEST_ARGS="-l${TINFO_ARG_SUFFIX}"
+		TINFO_ARGS="-L${LIB_DIR} $TEST_ARGS"
+		SHLIB_LIST="$SHLIB_LIST -l${TINFO_LIB_SUFFIX}"
+	fi
+else
+	TINFO_ARGS="-L${LIB_DIR} -l${LIB_NAME}${DFT_ARG_SUFFIX}"
 fi
+AC_SUBST(TINFO_ARG_SUFFIX)
+AC_SUBST(TINFO_DEP_SUFFIX)
+AC_SUBST(TINFO_LIB_SUFFIX)
+AC_SUBST(TINFO_ARGS)
+
+# needed for Ada95
+TINFO_ARGS2=`echo "$TINFO_ARGS" | sed -e 's,-L\.\./,-L../../,'`
+AC_SUBST(TINFO_ARGS2)
 
 AC_MSG_CHECKING(where we will install curses.h)
 test "$with_overwrite" = no && \
@@ -1274,23 +1412,9 @@
 fi
 fi
 
-AC_SUBST(EXTRA_LIBS)
 AC_SUBST(TINFO_LIST)
 AC_SUBST(SHLIB_LIST)
 
-### Set up low-level terminfo dependencies for makefiles.  Note that we
-### could override this.
-if test "$with_termlib" = yes ; then
-	TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TINFO_NAME}${DFT_DEP_SUFFIX}"
-	if test "$DFT_LWR_MODEL" = "libtool"; then
-		TEST_ARGS="${TEST_DEPS}"
-	else
-		TEST_ARGS="-l${TINFO_NAME}${DFT_ARG_SUFFIX}"
-	fi
-fi
-PROG_DEPS="$TEST_DEPS"
-PROG_ARGS="$TEST_ARGS"
-
 ### predefined stuff for the test programs
 AC_DEFINE(HAVE_SLK_COLOR)
 
@@ -1323,6 +1447,7 @@
 
 AWK="$AWK"
 CF_LIST_MODELS="$cf_list_models"
+DFT_ARG_SUFFIX="$DFT_ARG_SUFFIX"
 DFT_LWR_MODEL="$DFT_LWR_MODEL"
 LDCONFIG="$LDCONFIG"
 LIB_NAME="$LIB_NAME"
@@ -1333,12 +1458,17 @@
 NCURSES_OSPEED="$NCURSES_OSPEED"
 SRC_SUBDIRS="$SRC_SUBDIRS"
 TERMINFO="$TERMINFO"
+TINFO_ARG_SUFFIX="$TINFO_ARG_SUFFIX"
+TINFO_LIB_SUFFIX="$TINFO_LIB_SUFFIX"
 TINFO_NAME="$TINFO_NAME"
 WITH_CURSES_H="$with_curses_h"
 WITH_ECHO="$with_echo"
 WITH_OVERWRITE="$with_overwrite"
 cf_cv_abi_version="$cf_cv_abi_version"
 cf_cv_do_symlinks="$cf_cv_do_symlinks"
+cf_cv_enable_lp64="$cf_cv_enable_lp64"
+cf_cv_prog_CC_c_o=$cf_cv_prog_CC_c_o
+cf_cv_prog_CXX_c_o=$cf_cv_prog_CXX_c_o
 cf_cv_rel_version="$cf_cv_rel_version"
 cf_cv_rm_so_locs="$cf_cv_rm_so_locs"
 cf_cv_shlib_version="$cf_cv_shlib_version"
diff -Naur ncurses-5.4.orig/dist.mk ncurses-5.4/dist.mk
--- ncurses-5.4.orig/dist.mk	2004-02-08 20:56:43.000000000 +0000
+++ ncurses-5.4/dist.mk	2005-05-13 04:09:59.000000000 +0000
@@ -1,4 +1,4 @@
-# $Id: dist.mk,v 1.402 2004/02/08 20:56:43 tom Exp $
+# $Id: dist.mk,v 1.471 2005/05/07 23:27:02 tom Exp $
 # Makefile for creating ncurses distributions.
 #
 # This only needs to be used directly as a makefile by developers, but
@@ -10,7 +10,7 @@
 # These define the major/minor/patch versions of ncurses.
 NCURSES_MAJOR = 5
 NCURSES_MINOR = 4
-NCURSES_PATCH = 20040208
+NCURSES_PATCH = 20050507
 
 # We don't append the patch to the version, since this only applies to releases
 VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
@@ -51,7 +51,15 @@
 doc/hackguide.doc: doc/html/hackguide.html
 	$(DUMP2) doc/html/hackguide.html > $@
 
-MANPROG	= tbl | nroff -man
+# This is the original command:
+#	MANPROG	= tbl | nroff -man
+#
+# This happens to work for groff 1.18.1 on Debian.  At some point groff's
+# maintainer changed the line-length (we do not want/need that here).
+#
+# The distributed html files are formatted using
+#	configure --without-manpage-renames
+MANPROG	= tbl | nroff -mandoc -rLL=65n -rLT=71n -Tascii
 
 manhtml: MANIFEST
 	@rm -f doc/html/man/*.html
diff -Naur ncurses-5.4.orig/doc/html/man/captoinfo.1m.html ncurses-5.4/doc/html/man/captoinfo.1m.html
--- ncurses-5.4.orig/doc/html/man/captoinfo.1m.html	2003-10-25 17:39:44.000000000 +0000
+++ ncurses-5.4/doc/html/man/captoinfo.1m.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2004 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: captoinfo.1m,v 1.17 2003/05/11 00:32:53 tom Exp @
+  * @Id: captoinfo.1m,v 1.18 2004/07/05 13:16:08 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>                                       <STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>
+<STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>                                             <STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>
 
 
 
@@ -100,6 +100,7 @@
        has not mistakenly translated  a  completely  unknown  and
        random capability and/or syntax error.
 
+
        Nonstd   Std    From           Terminfo
         name    name                 capability
        -----------------------------------------------
@@ -115,8 +116,8 @@
        GE       ae     XENIX   exit_alt_charset_mode
        GS       as     XENIX   enter_alt_charset_mode
        HM       kh     XENIX   key_home
-       LD       kL     XENIX   key_dl
 
+       LD       kL     XENIX   key_dl
        PD       kN     XENIX   key_npage
        PN       po     XENIX   prtr_off
        PS       pf     XENIX   prtr_on
@@ -137,6 +138,7 @@
        bilities for forms drawing, designed to take advantage  of
        the IBM PC high-half graphics.  They were as follows:
 
+
        Cap          Graphic
        -----------------------------
        G2    upper left
@@ -172,6 +174,7 @@
        minfo but incompatible with the SVr4 format. The following
        AIX extensions are automatically translated:
 
+
         IBM    XSI
        -------------
        ksel    kslt
@@ -179,6 +182,7 @@
        font0   s0ds
        font1   s1ds
        font2   s2ds
+
        font3   s3ds
 
        Additionally, the AIX <STRONG>box1</STRONG> capability  will  be  automati-
@@ -211,7 +215,7 @@
 
 
 
-                                                    <STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>
+                                                          <STRONG><A HREF="captoinfo.1m.html">captoinfo(1m)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/clear.1.html ncurses-5.4/doc/html/man/clear.1.html
--- ncurses-5.4.orig/doc/html/man/clear.1.html	2003-10-25 17:39:44.000000000 +0000
+++ ncurses-5.4/doc/html/man/clear.1.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>                                                 <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>
+<STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>                                                       <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>
 
 
 
@@ -68,7 +68,7 @@
 
 
 
-                                                         <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>
+                                                               <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_add_wch.3x.html ncurses-5.4/doc/html/man/curs_add_wch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_add_wch.3x.html	2003-10-25 17:39:44.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_add_wch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>                                 <STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>
+<STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>                                       <STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>
 
 
 
@@ -130,7 +130,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_add_wchstr.3x.html ncurses-5.4/doc/html/man/curs_add_wchstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_add_wchstr.3x.html	2004-01-11 01:46:14.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_add_wchstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
+  * Copyright (c) 2002-2004,2005 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_add_wchstr.3x,v 1.2 2003/12/27 18:53:41 tom Exp @
+  * @Id: curs_add_wchstr.3x,v 1.6 2005/01/02 01:28:49 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>                           <STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>                                 <STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>
 
 
 
@@ -83,7 +83,7 @@
        riage  return characters), they do not advance the current
        cursor position, they do not expand other control  charac-
        ters  to  ^-escapes,  and  they  truncate the string if it
-       crosses the right margin, rather then wrapping  it  around
+       crosses the right margin, rather than wrapping  it  around
        to the new line.
 
        These  routines  end  successfully  on encountering a null
@@ -112,11 +112,11 @@
 
 </PRE>
 <H2>SEE ALSO</H2><PRE>
-       <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG> <STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>
+       <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>, <STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>
 
 
 
-                                              <STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>
+                                                    <STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_addch.3x.html ncurses-5.4/doc/html/man/curs_addch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_addch.3x.html	2004-01-11 01:46:15.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_addch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2004 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_addch.3x,v 1.22 2003/12/27 18:38:28 tom Exp @
+  * @Id: curs_addch.3x,v 1.23 2004/01/31 13:16:21 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>                                     <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>
+<STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>                                           <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>
 
 
 
@@ -115,6 +115,7 @@
        replacement for it (but see the EXTENSIONS section below).
        The names are taken from VT100 nomenclature.
 
+
        <EM>Name</EM>           <EM>Default</EM>   <EM>Description</EM>
        --------------------------------------------------
        ACS_BLOCK      #         solid square block
@@ -183,6 +184,10 @@
        The  <STRONG>TABSIZE</STRONG>  variable  is implemented in some versions of
        curses, but is not part of X/Open curses.
 
+       If <EM>ch</EM> is a carriage return, the cursor  is  moved  to  the
+       beginning  of the current row of the window.  This is true
+       of other implementations, but is not documented.
+
 
 </PRE>
 <H2>SEE ALSO</H2><PRE>
@@ -191,7 +196,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_addchstr.3x.html ncurses-5.4/doc/html/man/curs_addchstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_addchstr.3x.html	2004-01-11 01:46:15.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_addchstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>                               <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>                                     <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>
 
 
 
@@ -112,7 +112,7 @@
 
 
 
-                                                <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>
+                                                      <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_addstr.3x.html ncurses-5.4/doc/html/man/curs_addstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_addstr.3x.html	2004-01-11 01:46:15.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_addstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>                                   <STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>                                         <STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>
 
 
 
@@ -105,7 +105,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_addwstr.3x.html ncurses-5.4/doc/html/man/curs_addwstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_addwstr.3x.html	2004-01-11 01:46:15.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_addwstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
+  * Copyright (c) 2002-2003,2004 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_addwstr.3x,v 1.3 2003/12/27 18:51:01 tom Exp @
+  * @Id: curs_addwstr.3x,v 1.4 2004/09/11 20:57:04 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>                                 <STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>                                       <STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>
 
 
 
@@ -69,7 +69,7 @@
 </PRE>
 <H2>DESCRIPTION</H2><PRE>
        These  routines  write  the characters of the (null-termi-
-       nated) <STRONG>wchar_t</STRONG>character string <EM>wstr</EM> on the  given  window.
+       nated) <STRONG>wchar_t</STRONG> character string <EM>wstr</EM> on the given  window.
        It  is  similar to constructing a <STRONG>cchar_t</STRONG> for each wchar_t
        in the string, then calling  <STRONG>wadd_wch</STRONG>  for  the  resulting
        <STRONG>cchar_t</STRONG>.
@@ -109,7 +109,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_attr.3x.html ncurses-5.4/doc/html/man/curs_attr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_attr.3x.html	2004-01-11 01:46:15.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_attr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>                                       <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
+<STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>                                             <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
 
 
 
@@ -152,6 +152,7 @@
        be passed to the routines <STRONG>attron</STRONG>, <STRONG>attroff</STRONG>, and <STRONG>attrset</STRONG>, or
        OR'ed with the characters passed to <STRONG>addch</STRONG>.
 
+
         <STRONG>A_NORMAL</STRONG>        Normal display (no highlight)
         <STRONG>A_STANDOUT</STRONG>      Best highlighting mode of the terminal.
         <STRONG>A_UNDERLINE</STRONG>     Underlining
@@ -203,6 +204,7 @@
        <STRONG>wattr_set</STRONG>.  These are intended to work with a  new  series
        of highlight macros prefixed with <STRONG>WA_</STRONG>.
 
+
         <STRONG>WA_NORMAL</STRONG>       Normal display (no highlight)
         <STRONG>WA_STANDOUT</STRONG>     Best highlighting mode of the terminal.
         <STRONG>WA_UNDERLINE</STRONG>    Underlining
@@ -229,7 +231,7 @@
 
 
 
-                                                    <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
+                                                          <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_beep.3x.html ncurses-5.4/doc/html/man/curs_beep.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_beep.3x.html	2004-01-11 01:46:15.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_beep.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998,2003 Free Software Foundation, Inc.                   *
+  * Copyright (c) 1998-2003,2005 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_beep.3x,v 1.9 2003/12/27 18:44:30 tom Exp @
+  * @Id: curs_beep.3x,v 1.10 2005/01/08 17:55:51 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_beep.3x.html">curs_beep(3x)</A></STRONG>                                       <STRONG><A HREF="curs_beep.3x.html">curs_beep(3x)</A></STRONG>
+<STRONG><A HREF="curs_beep.3x.html">curs_beep(3x)</A></STRONG>                                             <STRONG><A HREF="curs_beep.3x.html">curs_beep(3x)</A></STRONG>
 
 
 
@@ -84,7 +84,7 @@
 
 </PRE>
 <H2>PORTABILITY</H2><PRE>
-       These functions are defined in the  XSI  Curses  standard,
+       These functions are described in the XSI Curses  standard,
        Issue  4.  Like SVr4, it specifies that they always return
        <STRONG>OK</STRONG>.
 
@@ -95,7 +95,7 @@
 
 
 
-                                                    <STRONG><A HREF="curs_beep.3x.html">curs_beep(3x)</A></STRONG>
+                                                          <STRONG><A HREF="curs_beep.3x.html">curs_beep(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_bkgd.3x.html ncurses-5.4/doc/html/man/curs_bkgd.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_bkgd.3x.html	2004-01-11 01:46:15.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_bkgd.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>                                       <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>
+<STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>                                             <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>
 
 
 
@@ -120,7 +120,7 @@
 
 
 
-                                                    <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>
+                                                          <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_bkgrnd.3x.html ncurses-5.4/doc/html/man/curs_bkgrnd.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_bkgrnd.3x.html	2003-10-25 17:39:45.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_bkgrnd.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+  * Copyright (c) 2002,2004 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_bkgrnd.3x,v 1.1 2002/02/23 23:23:42 tom Exp @
+  * @Id: curs_bkgrnd.3x,v 1.2 2004/03/13 19:39:10 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_bkgrnd.3x.html">curs_bkgrnd(3x)</A></STRONG>                                   <STRONG><A HREF="curs_bkgrnd.3x.html">curs_bkgrnd(3x)</A></STRONG>
+<STRONG><A HREF="curs_bkgrnd.3x.html">curs_bkgrnd(3x)</A></STRONG>                                         <STRONG><A HREF="curs_bkgrnd.3x.html">curs_bkgrnd(3x)</A></STRONG>
 
 
 
@@ -118,7 +118,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_bkgrnd.3x.html">curs_bkgrnd(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_bkgrnd.3x.html">curs_bkgrnd(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_border.3x.html ncurses-5.4/doc/html/man/curs_border.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_border.3x.html	2003-10-25 17:39:45.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_border.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_border.3x.html">curs_border(3x)</A></STRONG>                                   <STRONG><A HREF="curs_border.3x.html">curs_border(3x)</A></STRONG>
+<STRONG><A HREF="curs_border.3x.html">curs_border(3x)</A></STRONG>                                         <STRONG><A HREF="curs_border.3x.html">curs_border(3x)</A></STRONG>
 
 
 
@@ -141,7 +141,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_border.3x.html">curs_border(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_border.3x.html">curs_border(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_border_set.3x.html ncurses-5.4/doc/html/man/curs_border_set.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_border_set.3x.html	2003-10-25 17:39:45.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_border_set.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+  * Copyright (c) 2002,2004 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_border_set.3x,v 1.3 2002/04/20 16:49:13 tom Exp @
+  * @Id: curs_border_set.3x,v 1.4 2004/03/13 19:39:10 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_border_set.3x.html">curs_border_set(3x)</A></STRONG>                           <STRONG><A HREF="curs_border_set.3x.html">curs_border_set(3x)</A></STRONG>
+<STRONG><A HREF="curs_border_set.3x.html">curs_border_set(3x)</A></STRONG>                                 <STRONG><A HREF="curs_border_set.3x.html">curs_border_set(3x)</A></STRONG>
 
 
 
@@ -165,7 +165,7 @@
 
 
 
-                                              <STRONG><A HREF="curs_border_set.3x.html">curs_border_set(3x)</A></STRONG>
+                                                    <STRONG><A HREF="curs_border_set.3x.html">curs_border_set(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_clear.3x.html ncurses-5.4/doc/html/man/curs_clear.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_clear.3x.html	2003-10-25 17:39:45.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_clear.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>                                     <STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>
+<STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>                                           <STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>
 
 
 
@@ -119,7 +119,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_color.3x.html ncurses-5.4/doc/html/man/curs_color.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_color.3x.html	2003-10-25 17:39:46.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_color.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2004,2005 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_color.3x,v 1.19 2002/02/16 22:38:32 tom Exp @
+  * @Id: curs_color.3x,v 1.25 2005/04/03 14:06:00 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>                                     <STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>
+<STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>                                           <STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>
 
 
 
@@ -112,8 +112,10 @@
             <STRONG>COLOR_PAIRS-1</STRONG>.
 
        -    The value of the second and third arguments  must  be
-            between  0  and  <STRONG>COLORS</STRONG> (the 0 color pair is wired to
-            white on black and cannot be changed).
+            between  0 and <STRONG>COLORS</STRONG>.  Color pair 0 is assumed to be
+            white on black, but is actually whatever the terminal
+            implements before color is initialized.  It cannot be
+            modified by the application.
 
        If the color-pair was previously initialized,  the  screen
        is  refreshed  and  all occurrences of that color-pair are
@@ -190,6 +192,20 @@
        an <STRONG>OK</STRONG> (SVr4 specifies only "an integer  value  other  than
        <STRONG>ERR</STRONG>") upon successful completion.
 
+       X/Open  defines  no error conditions.  This implementation
+       will return <STRONG>ERR</STRONG> on attempts to use  color  values  outside
+       the  range  0  to  COLORS-1 (except for the default colors
+       extension), or use color pairs  outside  the  range  0  to
+       COLOR_PAIR-1.   Color values used in <STRONG>init_color</STRONG> must be in
+       the range 0 to 1000.
+
+       If the color table cannot be allocated, or if the terminal
+       has not been initialized, <STRONG>start_color</STRONG> returns ERR.  If the
+       screen has not been initialized, that is also an error.
+
+       An error is returned, e.g., from <STRONG>init_pair</STRONG>, if <STRONG>start_color</STRONG>
+       was not first called.
+
 
 </PRE>
 <H2>NOTES</H2><PRE>
@@ -235,8 +251,11 @@
 
        The assumption that <STRONG>COLOR_BLACK</STRONG> is the default  background
        color   for  all  terminals  can  be  modified  using  the
-       <STRONG>assume_default_colors</STRONG> extension,
+       <STRONG>assume_default_colors</STRONG> extension.
 
+       This implementation checks the  pointers,  e.g.,  for  the
+       values  returned  by  <STRONG>color_content</STRONG>  and <STRONG>pair_content</STRONG>, and
+       will treat those as optional parameters when null.
 
 
 </PRE>
@@ -246,7 +265,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_delch.3x.html ncurses-5.4/doc/html/man/curs_delch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_delch.3x.html	2003-10-25 17:39:46.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_delch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_delch.3x.html">curs_delch(3x)</A></STRONG>                                     <STRONG><A HREF="curs_delch.3x.html">curs_delch(3x)</A></STRONG>
+<STRONG><A HREF="curs_delch.3x.html">curs_delch(3x)</A></STRONG>                                           <STRONG><A HREF="curs_delch.3x.html">curs_delch(3x)</A></STRONG>
 
 
 
@@ -97,7 +97,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_delch.3x.html">curs_delch(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_delch.3x.html">curs_delch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_deleteln.3x.html ncurses-5.4/doc/html/man/curs_deleteln.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_deleteln.3x.html	2003-10-25 17:39:46.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_deleteln.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_deleteln.3x.html">curs_deleteln(3x)</A></STRONG>                               <STRONG><A HREF="curs_deleteln.3x.html">curs_deleteln(3x)</A></STRONG>
+<STRONG><A HREF="curs_deleteln.3x.html">curs_deleteln(3x)</A></STRONG>                                     <STRONG><A HREF="curs_deleteln.3x.html">curs_deleteln(3x)</A></STRONG>
 
 
 
@@ -111,7 +111,7 @@
 
 
 
-                                                <STRONG><A HREF="curs_deleteln.3x.html">curs_deleteln(3x)</A></STRONG>
+                                                      <STRONG><A HREF="curs_deleteln.3x.html">curs_deleteln(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_extend.3x.html ncurses-5.4/doc/html/man/curs_extend.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_extend.3x.html	2004-01-11 01:46:16.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_extend.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1999-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1999-2003,2004 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            *
@@ -28,7 +28,7 @@
   * authorization.                                                           *
   ****************************************************************************
   * Author: Thomas E. Dickey 1999
-  * @Id: curs_extend.3x,v 1.12 2003/10/25 20:33:16 tom Exp @
+  * @Id: curs_extend.3x,v 1.13 2004/07/05 13:16:08 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_extend.3x.html">curs_extend(3x)</A></STRONG>                                   <STRONG><A HREF="curs_extend.3x.html">curs_extend(3x)</A></STRONG>
+<STRONG><A HREF="curs_extend.3x.html">curs_extend(3x)</A></STRONG>                                         <STRONG><A HREF="curs_extend.3x.html">curs_extend(3x)</A></STRONG>
 
 
 
@@ -101,7 +101,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_extend.3x.html">curs_extend(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_extend.3x.html">curs_extend(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_get_wch.3x.html ncurses-5.4/doc/html/man/curs_get_wch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_get_wch.3x.html	2003-10-25 17:39:46.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_get_wch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_get_wch.3x.html">curs_get_wch(3x)</A></STRONG>                                 <STRONG><A HREF="curs_get_wch.3x.html">curs_get_wch(3x)</A></STRONG>
+<STRONG><A HREF="curs_get_wch.3x.html">curs_get_wch(3x)</A></STRONG>                                       <STRONG><A HREF="curs_get_wch.3x.html">curs_get_wch(3x)</A></STRONG>
 
 
 
@@ -140,7 +140,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_get_wch.3x.html">curs_get_wch(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_get_wch.3x.html">curs_get_wch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_get_wstr.3x.html ncurses-5.4/doc/html/man/curs_get_wstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_get_wstr.3x.html	2003-10-25 17:39:46.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_get_wstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_get_wstr.3x.html">curs_get_wstr(3x)</A></STRONG>                               <STRONG><A HREF="curs_get_wstr.3x.html">curs_get_wstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_get_wstr.3x.html">curs_get_wstr(3x)</A></STRONG>                                     <STRONG><A HREF="curs_get_wstr.3x.html">curs_get_wstr(3x)</A></STRONG>
 
 
 
@@ -144,7 +144,7 @@
 
 
 
-                                                <STRONG><A HREF="curs_get_wstr.3x.html">curs_get_wstr(3x)</A></STRONG>
+                                                      <STRONG><A HREF="curs_get_wstr.3x.html">curs_get_wstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_getcchar.3x.html ncurses-5.4/doc/html/man/curs_getcchar.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_getcchar.3x.html	2003-10-25 17:39:46.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_getcchar.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>                               <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>
+<STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>                                     <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>
 
 
 
@@ -142,7 +142,7 @@
 
 
 
-                                                <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>
+                                                      <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_getch.3x.html ncurses-5.4/doc/html/man/curs_getch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_getch.3x.html	2004-01-11 01:46:17.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_getch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2005 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_getch.3x,v 1.24 2003/12/27 18:46:06 tom Exp @
+  * @Id: curs_getch.3x,v 1.26 2005/01/02 01:27:47 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>                                     <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>
+<STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>                                           <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>
 
 
 
@@ -118,6 +118,7 @@
        that  not  all  of  these are necessarily supported on any
        particular terminal.
 
+
             <EM>Name</EM>            <EM>Key</EM> <EM>name</EM>
 
                    KEY_BREAK       Break key
@@ -178,10 +179,10 @@
             KEY_REFERENCE   Ref(erence) key
             KEY_REFRESH     Refresh key
             KEY_REPLACE     Replace key
-
             KEY_RESIZE      Screen resized
             KEY_RESTART     Restart key
             KEY_RESUME      Resume key
+
             KEY_SAVE        Save key
             KEY_SBEG        Shifted beginning key
             KEY_SCANCEL     Shifted cancel key
@@ -217,6 +218,7 @@
 
        Keypad is arranged like this:
 
+
                          +-----+------+-------+
                          | <STRONG>A1</STRONG>  |  <STRONG>up</STRONG>  |  <STRONG>A3</STRONG>   |
                          +-----+------+-------+
@@ -309,11 +311,11 @@
 </PRE>
 <H2>SEE ALSO</H2><PRE>
        <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>,        <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>,        <STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG>,
-       <STRONG><A HREF="curs_move.3x.html">curs_move(3x)</A></STRONG>, <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>.  <STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG>.
+       <STRONG><A HREF="curs_move.3x.html">curs_move(3x)</A></STRONG>, <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>, <STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG>.
 
 
 
-                                                   <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_getstr.3x.html ncurses-5.4/doc/html/man/curs_getstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_getstr.3x.html	2003-10-25 17:39:47.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_getstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>                                   <STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>                                         <STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>
 
 
 
@@ -120,8 +120,8 @@
        useful  (being,  in  fact, the low-order eight bits of the
        key's KEY_ value).
 
-       The functions <STRONG>getnstr</STRONG>, <STRONG>mvgetnstr</STRONG>, and <STRONG>mvwgetnstr</STRONG> were pre-
-       sent but not documented in SVr4.
+       The functions  <STRONG>getnstr</STRONG>,  <STRONG>mvgetnstr</STRONG>,  and  <STRONG>mvwgetnstr</STRONG>  were
+       present but not documented in SVr4.
 
 
 </PRE>
@@ -130,7 +130,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_getstr.3x.html">curs_getstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_getyx.3x.html ncurses-5.4/doc/html/man/curs_getyx.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_getyx.3x.html	2003-10-25 17:39:47.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_getyx.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_getyx.3x.html">curs_getyx(3x)</A></STRONG>                                     <STRONG><A HREF="curs_getyx.3x.html">curs_getyx(3x)</A></STRONG>
+<STRONG><A HREF="curs_getyx.3x.html">curs_getyx(3x)</A></STRONG>                                           <STRONG><A HREF="curs_getyx.3x.html">curs_getyx(3x)</A></STRONG>
 
 
 
@@ -105,7 +105,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_getyx.3x.html">curs_getyx(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_getyx.3x.html">curs_getyx(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_in_wch.3x.html ncurses-5.4/doc/html/man/curs_in_wch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_in_wch.3x.html	2003-10-25 17:39:47.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_in_wch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>                                   <STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>
+<STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>                                         <STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>
 
 
 
@@ -94,7 +94,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_in_wchstr.3x.html ncurses-5.4/doc/html/man/curs_in_wchstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_in_wchstr.3x.html	2003-10-25 17:39:47.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_in_wchstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+  * Copyright (c) 2002,2005 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_in_wchstr.3x,v 1.2 2002/05/18 21:48:30 tom Exp @
+  * @Id: curs_in_wchstr.3x,v 1.4 2005/01/02 01:27:19 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_in_wchstr.3x.html">curs_in_wchstr(3x)</A></STRONG>                             <STRONG><A HREF="curs_in_wchstr.3x.html">curs_in_wchstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_in_wchstr.3x.html">curs_in_wchstr(3x)</A></STRONG>                                   <STRONG><A HREF="curs_in_wchstr.3x.html">curs_in_wchstr(3x)</A></STRONG>
 
 
 
@@ -104,12 +104,12 @@
 
 </PRE>
 <H2>SEE ALSO</H2><PRE>
-       Functions:   <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>,  <STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>  <STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>,
+       Functions:  <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>,  <STRONG><A HREF="curs_in_wch.3x.html">curs_in_wch(3x)</A></STRONG>,  <STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>,
        <STRONG><A HREF="curs_inwstr.3x.html">curs_inwstr(3x)</A></STRONG>
 
 
 
-                                               <STRONG><A HREF="curs_in_wchstr.3x.html">curs_in_wchstr(3x)</A></STRONG>
+                                                     <STRONG><A HREF="curs_in_wchstr.3x.html">curs_in_wchstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_inch.3x.html ncurses-5.4/doc/html/man/curs_inch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_inch.3x.html	2003-10-25 17:39:47.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_inch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>                                       <STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>
+<STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>                                             <STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>
 
 
 
@@ -76,6 +76,7 @@
        The  following  bit-masks  may  be  AND-ed with characters
        returned by <STRONG>winch</STRONG>.
 
+
        <STRONG>A_CHARTEXT</STRONG>     Bit-mask to extract character
        <STRONG>A_ATTRIBUTES</STRONG>   Bit-mask to extract attributes
        <STRONG>A_COLOR</STRONG>        Bit-mask to extract color-pair field information
@@ -98,7 +99,7 @@
 
 
 
-                                                    <STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>
+                                                          <STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_inchstr.3x.html ncurses-5.4/doc/html/man/curs_inchstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_inchstr.3x.html	2003-10-25 17:39:47.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_inchstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_inchstr.3x.html">curs_inchstr(3x)</A></STRONG>                                 <STRONG><A HREF="curs_inchstr.3x.html">curs_inchstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_inchstr.3x.html">curs_inchstr(3x)</A></STRONG>                                       <STRONG><A HREF="curs_inchstr.3x.html">curs_inchstr(3x)</A></STRONG>
 
 
 
@@ -111,7 +111,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_inchstr.3x.html">curs_inchstr(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_inchstr.3x.html">curs_inchstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_initscr.3x.html ncurses-5.4/doc/html/man/curs_initscr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_initscr.3x.html	2003-10-25 17:39:47.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_initscr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3x)</A></STRONG>                                 <STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3x)</A></STRONG>
+<STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3x)</A></STRONG>                                       <STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3x)</A></STRONG>
 
 
 
@@ -152,7 +152,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_initscr.3x.html">curs_initscr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_inopts.3x.html ncurses-5.4/doc/html/man/curs_inopts.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_inopts.3x.html	2004-01-11 01:46:18.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_inopts.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>                                   <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>
+<STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>                                         <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>
 
 
 
@@ -241,7 +241,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_ins_wch.3x.html ncurses-5.4/doc/html/man/curs_ins_wch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_ins_wch.3x.html	2003-10-25 17:39:48.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_ins_wch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_ins_wch.3x.html">curs_ins_wch(3x)</A></STRONG>                                 <STRONG><A HREF="curs_ins_wch.3x.html">curs_ins_wch(3x)</A></STRONG>
+<STRONG><A HREF="curs_ins_wch.3x.html">curs_ins_wch(3x)</A></STRONG>                                       <STRONG><A HREF="curs_ins_wch.3x.html">curs_ins_wch(3x)</A></STRONG>
 
 
 
@@ -89,7 +89,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_ins_wch.3x.html">curs_ins_wch(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_ins_wch.3x.html">curs_ins_wch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_ins_wstr.3x.html ncurses-5.4/doc/html/man/curs_ins_wstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_ins_wstr.3x.html	2003-10-25 17:39:48.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_ins_wstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_ins_wstr.3x.html">curs_ins_wstr(3x)</A></STRONG>                               <STRONG><A HREF="curs_ins_wstr.3x.html">curs_ins_wstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_ins_wstr.3x.html">curs_ins_wstr(3x)</A></STRONG>                                     <STRONG><A HREF="curs_ins_wstr.3x.html">curs_ins_wstr(3x)</A></STRONG>
 
 
 
@@ -114,7 +114,7 @@
 
 
 
-                                                <STRONG><A HREF="curs_ins_wstr.3x.html">curs_ins_wstr(3x)</A></STRONG>
+                                                      <STRONG><A HREF="curs_ins_wstr.3x.html">curs_ins_wstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_insch.3x.html ncurses-5.4/doc/html/man/curs_insch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_insch.3x.html	2003-10-25 17:39:48.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_insch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_insch.3x.html">curs_insch(3x)</A></STRONG>                                     <STRONG><A HREF="curs_insch.3x.html">curs_insch(3x)</A></STRONG>
+<STRONG><A HREF="curs_insch.3x.html">curs_insch(3x)</A></STRONG>                                           <STRONG><A HREF="curs_insch.3x.html">curs_insch(3x)</A></STRONG>
 
 
 
@@ -99,7 +99,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_insch.3x.html">curs_insch(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_insch.3x.html">curs_insch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_insstr.3x.html ncurses-5.4/doc/html/man/curs_insstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_insstr.3x.html	2003-10-25 17:39:48.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_insstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2001,2004 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_insstr.3x,v 1.12 2001/11/03 19:59:03 tom Exp @
+  * @Id: curs_insstr.3x,v 1.14 2004/06/19 22:22:51 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_insstr.3x.html">curs_insstr(3x)</A></STRONG>                                   <STRONG><A HREF="curs_insstr.3x.html">curs_insstr(3x)</A></STRONG>
+<STRONG><A HREF="curs_insstr.3x.html">curs_insstr(3x)</A></STRONG>                                         <STRONG><A HREF="curs_insstr.3x.html">curs_insstr(3x)</A></STRONG>
 
 
 
@@ -71,22 +71,14 @@
        These  routines insert a character string (as many charac-
        ters as will fit on the line) before the  character  under
        the cursor.  All characters to the right of the cursor are
-       shifted right, with the possibility of the rightmost char-
+       shifted right with the possibility of the rightmost  char-
        acters  on  the line being lost.  The cursor position does
-       not change (after moving to <EM>y</EM>, <EM>x</EM>, if specified). The  four
-       routines with <EM>n</EM> as the last argument insert a leading sub-
-       string of at most <EM>n</EM> characters.  If <EM>n</EM>&lt;=0, then the  entire
-       string is inserted.
-
-       If  a  character in <EM>str</EM> is a tab, newline, carriage return
-       or backspace, the cursor is moved appropriately within the
-       window.   A  newline  also  does a <STRONG>clrtoeol</STRONG> before moving.
-       Tabs are considered to be at every eighth  column.   If  a
-       character in <EM>str</EM> is another control character, it is drawn
-       in the <STRONG>^</STRONG><EM>X</EM> notation.  Calling <STRONG>winch</STRONG> after adding a  control
-       character (and moving to it, if necessary) does not return
-       the control character, but instead returns a character  in
-       the ^-representation of the control character.
+       not change (after moving to  <EM>y</EM>,  <EM>x</EM>,  if  specified).   The
+       functions  with  <EM>n</EM>  as  the last argument insert a leading
+       substring of at most <EM>n</EM>  characters.   If  <EM>n</EM>&lt;=0,  then  the
+       entire string is inserted.
+
+       Special characters are handled as in <STRONG>addch</STRONG>.
 
 
 </PRE>
@@ -111,14 +103,20 @@
        detected (this implementation does not  yet  support  XPG4
        multibyte characters).
 
+       The  Single  Unix  Specification,  Version  2  states that
+       <STRONG>insnstr</STRONG> and <STRONG>winsnstr</STRONG> perform wrapping.  This  is  probably
+       an error, since it makes this group of functions inconsis-
+       tent.  Also, no implementation of  curses  documents  this
+       inconsistency.
+
 
 </PRE>
 <H2>SEE ALSO</H2><PRE>
-       <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>, <STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>.
+       <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="unctrl.3x.html">unctrl(3x)</A></STRONG>, <STRONG><A HREF="curs_clear.3x.html">curs_clear(3x)</A></STRONG>, <STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>.
 
 
 
-                                                  <STRONG><A HREF="curs_insstr.3x.html">curs_insstr(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_insstr.3x.html">curs_insstr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_instr.3x.html ncurses-5.4/doc/html/man/curs_instr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_instr.3x.html	2003-10-25 17:39:48.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_instr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>                                     <STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>
+<STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>                                           <STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>
 
 
 
@@ -108,7 +108,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_inwstr.3x.html ncurses-5.4/doc/html/man/curs_inwstr.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_inwstr.3x.html	2003-10-25 17:39:48.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_inwstr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+  * Copyright (c) 2002,2004 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_inwstr.3x,v 1.2 2002/04/13 20:25:35 tom Exp @
+  * @Id: curs_inwstr.3x,v 1.3 2004/03/13 19:39:10 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_inwstr.3.html">curs_inwstr(3)</A></STRONG>                                     <STRONG><A HREF="curs_inwstr.3.html">curs_inwstr(3)</A></STRONG>
+<STRONG><A HREF="curs_inwstr.3.html">curs_inwstr(3)</A></STRONG>                                           <STRONG><A HREF="curs_inwstr.3.html">curs_inwstr(3)</A></STRONG>
 
 
 
@@ -100,7 +100,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_inwstr.3.html">curs_inwstr(3)</A></STRONG>
+                                                         <STRONG><A HREF="curs_inwstr.3.html">curs_inwstr(3)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_kernel.3x.html ncurses-5.4/doc/html/man/curs_kernel.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_kernel.3x.html	2003-10-25 17:39:49.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_kernel.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_kernel.3x.html">curs_kernel(3x)</A></STRONG>                                   <STRONG><A HREF="curs_kernel.3x.html">curs_kernel(3x)</A></STRONG>
+<STRONG><A HREF="curs_kernel.3x.html">curs_kernel(3x)</A></STRONG>                                         <STRONG><A HREF="curs_kernel.3x.html">curs_kernel(3x)</A></STRONG>
 
 
 
@@ -179,7 +179,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_kernel.3x.html">curs_kernel(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_kernel.3x.html">curs_kernel(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_mouse.3x.html ncurses-5.4/doc/html/man/curs_mouse.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_mouse.3x.html	2004-01-11 01:46:19.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_mouse.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2005 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_mouse.3x,v 1.24 2003/12/27 18:47:54 tom Exp @
+  * @Id: curs_mouse.3x,v 1.26 2005/02/19 20:59:40 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG>                                     <STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG>
+<STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG>                                           <STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG>
 
 
 
@@ -95,7 +95,8 @@
        the  mouse pointer; setting a nonzero mask may turn it on.
        Whether this happens is device-dependent.
 
-       Here are the mouse event type masks:
+       Here are the mouse event type masks which may be defined:
+
 
        <EM>Name</EM>                     <EM>Description</EM>
        ---------------------------------------------------------------------
@@ -104,27 +105,38 @@
        BUTTON1_CLICKED          mouse button 1 clicked
        BUTTON1_DOUBLE_CLICKED   mouse button 1 double clicked
        BUTTON1_TRIPLE_CLICKED   mouse button 1 triple clicked
+       ---------------------------------------------------------------------
        BUTTON2_PRESSED          mouse button 2 down
        BUTTON2_RELEASED         mouse button 2 up
        BUTTON2_CLICKED          mouse button 2 clicked
        BUTTON2_DOUBLE_CLICKED   mouse button 2 double clicked
        BUTTON2_TRIPLE_CLICKED   mouse button 2 triple clicked
+       ---------------------------------------------------------------------
+
        BUTTON3_PRESSED          mouse button 3 down
        BUTTON3_RELEASED         mouse button 3 up
        BUTTON3_CLICKED          mouse button 3 clicked
-
        BUTTON3_DOUBLE_CLICKED   mouse button 3 double clicked
        BUTTON3_TRIPLE_CLICKED   mouse button 3 triple clicked
+       ---------------------------------------------------------------------
        BUTTON4_PRESSED          mouse button 4 down
        BUTTON4_RELEASED         mouse button 4 up
        BUTTON4_CLICKED          mouse button 4 clicked
        BUTTON4_DOUBLE_CLICKED   mouse button 4 double clicked
        BUTTON4_TRIPLE_CLICKED   mouse button 4 triple clicked
+       ---------------------------------------------------------------------
+       BUTTON5_PRESSED          mouse button 5 down
+       BUTTON5_RELEASED         mouse button 5 up
+       BUTTON5_CLICKED          mouse button 5 clicked
+       BUTTON5_DOUBLE_CLICKED   mouse button 5 double clicked
+       BUTTON5_TRIPLE_CLICKED   mouse button 5 triple clicked
+       ---------------------------------------------------------------------
        BUTTON_SHIFT             shift was down during button state change
        BUTTON_CTRL              control was down during button state change
        BUTTON_ALT               alt was down during button state change
        ALL_MOUSE_EVENTS         report all button state changes
        REPORT_MOUSE_POSITION    report mouse movement
+       ---------------------------------------------------------------------
 
        Once a class of mouse events have been made visible  in  a
        window,  calling  the  <STRONG>wgetch</STRONG>  function on that window may
@@ -139,9 +151,9 @@
        event type.
 
        The <STRONG>ungetmouse</STRONG> function behaves  analogously  to  <STRONG>ungetch</STRONG>.
-       It  pushes  a  <STRONG>KEY_MOUSE</STRONG>  event  onto the input queue, and
-       associates with  that  event  the  given  state  data  and
-       screen-relative character-cell coordinates.
+       It  pushes a <STRONG>KEY_MOUSE</STRONG> event onto the input queue, and as-
+       sociates with that event the given state data and  screen-
+       relative character-cell coordinates.
 
        The  <STRONG>wenclose</STRONG>  function  tests  whether  a  given  pair of
        screen-relative character-cell coordinates is enclosed  by
@@ -175,79 +187,88 @@
        The <STRONG>mouseinterval</STRONG> function sets the maximum time (in thou-
        sands  of  a  second)  that  can  elapse between press and
        release events for them to be recognized as a click.   Use
-       <STRONG>mouseinterval(-1)</STRONG> to disable click resolution.  This func-
-       tion returns the previous interval value.  The default  is
-       one sixth of a second.
+       <STRONG>mouseinterval(0)</STRONG>  to disable click resolution.  This func-
+       tion returns the previous interval value.  Use <STRONG>mouseinter-</STRONG>
+       <STRONG>val(-1)</STRONG>  to  obtain the interval without altering it.  The
+       default is one sixth of a second.
 
-       Note  that  mouse  events will be ignored when input is in
+       Note that mouse events will be ignored when  input  is  in
        cooked mode, and will cause an error beep when cooked mode
-       is  being simulated in a window by a function such as <STRONG>get-</STRONG>
+       is being simulated in a window by a function such as  <STRONG>get-</STRONG>
        <STRONG>str</STRONG> that expects a linefeed for input-loop termination.
 
 
 </PRE>
 <H2>RETURN VALUE</H2><PRE>
-       <STRONG>getmouse</STRONG>, <STRONG>ungetmouse</STRONG> and <STRONG>mouseinterval</STRONG> return the  integer
+       <STRONG>getmouse</STRONG>,  <STRONG>ungetmouse</STRONG> and <STRONG>mouseinterval</STRONG> return the integer
        <STRONG>ERR</STRONG> upon failure or <STRONG>OK</STRONG> upon successful completion.  <STRONG>mouse-</STRONG>
-       <STRONG>mask</STRONG> returns the mask of reportable events.  <STRONG>wenclose</STRONG>  and
+       <STRONG>mask</STRONG>  returns the mask of reportable events.  <STRONG>wenclose</STRONG> and
        <STRONG>wmouse_trafo</STRONG> are boolean functions returning <STRONG>TRUE</STRONG> or <STRONG>FALSE</STRONG>
        depending on their test result.
 
 
 </PRE>
 <H2>PORTABILITY</H2><PRE>
-       These calls were designed for  <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>,  and  are  not
+       These  calls  were  designed  for <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>, and are not
        found in SVr4 curses, 4.4BSD curses, or any other previous
        version of curses.
 
        The feature macro <STRONG>NCURSES_MOUSE_VERSION</STRONG> is provided so the
-       preprocessor  can  be  used to test whether these features
-       are present  (its  value  is  1).   If  the  interface  is
-       changed, the value of <STRONG>NCURSES_MOUSE_VERSION</STRONG> will be incre-
-       mented.
+       preprocessor can be used to test  whether  these  features
+       are  present.   If  the interface is changed, the value of
+       <STRONG>NCURSES_MOUSE_VERSION</STRONG> will be incremented.   These  values
+       for  <STRONG>NCURSES_MOUSE_VERSION</STRONG> may be specified when configur-
+       ing ncurses:
+
+              1  has definitions for reserved events.   The  mask
+                 uses 28 bits.
+
+              2  adds definitions for button 5, removes the defi-
+                 nitions for reserved events.  The mask  uses  29
+                 bits.
 
-       The order of the <STRONG>MEVENT</STRONG> structure members is  not  guaran-
-       teed.   Additional fields may be added to the structure in
+       The  order  of the <STRONG>MEVENT</STRONG> structure members is not guaran-
+       teed.  Additional fields may be added to the structure  in
        the future.
 
        Under  <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>,  these  calls  are  implemented  using
-       either  xterm's  built-in  mouse-tracking API or platform-
+       either xterm's built-in mouse-tracking  API  or  platform-
        specific drivers including
               Alessandro Rubini's gpm server.
               FreeBSD sysmouse
               OS/2 EMX
-       If you  are  using  an  unsupported  configuration,  mouse
+       If  you  are  using  an  unsupported  configuration, mouse
        events will not be visible to <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG> (and the <STRONG>wmouse-</STRONG>
        <STRONG>mask</STRONG> function will always return <STRONG>0</STRONG>).
 
-       If the terminfo entry contains a <STRONG>XM</STRONG> string, this  is  used
-       in  the xterm mouse driver to control the way the terminal
+       If  the  terminfo entry contains a <STRONG>XM</STRONG> string, this is used
+       in the xterm mouse driver to control the way the  terminal
        is initialized for mouse operation.  The default, if <STRONG>XM</STRONG> is
        not found, corresponds to private mode 1000 of xterm:
               \E[?1000%?%p1%{1}%=%th%el%;
        The z member in the event structure is not presently used.
-       It is intended for use with touch screens  (which  may  be
+       It  is  intended  for use with touch screens (which may be
        pressure-sensitive)   or   with   3D-mice/trackballs/power
        gloves.
 
 
 </PRE>
 <H2>BUGS</H2><PRE>
-       Mouse events under xterm will not in fact be ignored  dur-
-       ing  cooked mode, if they have been enabled by <STRONG>wmousemask</STRONG>.
-       Instead, the xterm mouse report sequence  will  appear  in
+       Mouse  events under xterm will not in fact be ignored dur-
+       ing cooked mode, if they have been enabled by  <STRONG>wmousemask</STRONG>.
+       Instead,  the  xterm  mouse report sequence will appear in
        the string read.
 
        Mouse events under xterm will not be detected correctly in
-       a window with its keypad bit off, since  they  are  inter-
-       preted  as  a  variety  of  function  key.   Your terminfo
-       description must have <STRONG>kmous</STRONG> set to "\E[M"  (the  beginning
+       a  window  with  its keypad bit off, since they are inter-
+       preted as  a  variety  of  function  key.   Your  terminfo
+       description  must  have <STRONG>kmous</STRONG> set to "\E[M" (the beginning
        of the response from xterm for mouse clicks).
 
-       Because  there  are  no  standard  terminal responses that
-       would serve to identify terminals which support the  xterm
-       mouse  protocol,  <STRONG>ncurses</STRONG> assumes that if your $TERM envi-
-       ronment variable contains "xterm", or <STRONG>kmous</STRONG> is defined  in
+       Because there are  no  standard  terminal  responses  that
+       would  serve to identify terminals which support the xterm
+       mouse protocol, <STRONG>ncurses</STRONG> assumes that if your  $TERM  envi-
+       ronment  variable contains "xterm", or <STRONG>kmous</STRONG> is defined in
        the terminal description, then the terminal may send mouse
        events.
 
@@ -258,7 +279,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_move.3x.html ncurses-5.4/doc/html/man/curs_move.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_move.3x.html	2003-10-25 17:39:49.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_move.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_move.3x.html">curs_move(3x)</A></STRONG>                                       <STRONG><A HREF="curs_move.3x.html">curs_move(3x)</A></STRONG>
+<STRONG><A HREF="curs_move.3x.html">curs_move(3x)</A></STRONG>                                             <STRONG><A HREF="curs_move.3x.html">curs_move(3x)</A></STRONG>
 
 
 
@@ -95,7 +95,7 @@
 
 
 
-                                                    <STRONG><A HREF="curs_move.3x.html">curs_move(3x)</A></STRONG>
+                                                          <STRONG><A HREF="curs_move.3x.html">curs_move(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_outopts.3x.html ncurses-5.4/doc/html/man/curs_outopts.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_outopts.3x.html	2003-10-25 17:39:49.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_outopts.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_outopts.3x.html">curs_outopts(3x)</A></STRONG>                                 <STRONG><A HREF="curs_outopts.3x.html">curs_outopts(3x)</A></STRONG>
+<STRONG><A HREF="curs_outopts.3x.html">curs_outopts(3x)</A></STRONG>                                       <STRONG><A HREF="curs_outopts.3x.html">curs_outopts(3x)</A></STRONG>
 
 
 
@@ -206,7 +206,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_outopts.3x.html">curs_outopts(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_outopts.3x.html">curs_outopts(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_overlay.3x.html ncurses-5.4/doc/html/man/curs_overlay.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_overlay.3x.html	2003-10-25 17:39:49.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_overlay.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_overlay.3x.html">curs_overlay(3x)</A></STRONG>                                 <STRONG><A HREF="curs_overlay.3x.html">curs_overlay(3x)</A></STRONG>
+<STRONG><A HREF="curs_overlay.3x.html">curs_overlay(3x)</A></STRONG>                                       <STRONG><A HREF="curs_overlay.3x.html">curs_overlay(3x)</A></STRONG>
 
 
 
@@ -106,7 +106,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_overlay.3x.html">curs_overlay(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_overlay.3x.html">curs_overlay(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_pad.3x.html ncurses-5.4/doc/html/man/curs_pad.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_pad.3x.html	2004-01-11 01:46:20.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_pad.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_pad.3x.html">curs_pad(3x)</A></STRONG>                                         <STRONG><A HREF="curs_pad.3x.html">curs_pad(3x)</A></STRONG>
+<STRONG><A HREF="curs_pad.3x.html">curs_pad(3x)</A></STRONG>                                               <STRONG><A HREF="curs_pad.3x.html">curs_pad(3x)</A></STRONG>
 
 
 
@@ -153,7 +153,7 @@
 
 
 
-                                                     <STRONG><A HREF="curs_pad.3x.html">curs_pad(3x)</A></STRONG>
+                                                           <STRONG><A HREF="curs_pad.3x.html">curs_pad(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_print.3x.html ncurses-5.4/doc/html/man/curs_print.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_print.3x.html	2003-10-25 17:39:49.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_print.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_print.3x.html">curs_print(3x)</A></STRONG>                                     <STRONG><A HREF="curs_print.3x.html">curs_print(3x)</A></STRONG>
+<STRONG><A HREF="curs_print.3x.html">curs_print(3x)</A></STRONG>                                           <STRONG><A HREF="curs_print.3x.html">curs_print(3x)</A></STRONG>
 
 
 
@@ -111,7 +111,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_print.3x.html">curs_print(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_print.3x.html">curs_print(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_printw.3x.html ncurses-5.4/doc/html/man/curs_printw.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_printw.3x.html	2003-10-25 17:39:50.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_printw.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_printw.3x.html">curs_printw(3x)</A></STRONG>                                   <STRONG><A HREF="curs_printw.3x.html">curs_printw(3x)</A></STRONG>
+<STRONG><A HREF="curs_printw.3x.html">curs_printw(3x)</A></STRONG>                                         <STRONG><A HREF="curs_printw.3x.html">curs_printw(3x)</A></STRONG>
 
 
 
@@ -106,7 +106,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_printw.3x.html">curs_printw(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_printw.3x.html">curs_printw(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_refresh.3x.html ncurses-5.4/doc/html/man/curs_refresh.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_refresh.3x.html	2003-10-25 17:39:50.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_refresh.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>                                 <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>
+<STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>                                       <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>
 
 
 
@@ -148,7 +148,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_scanw.3x.html ncurses-5.4/doc/html/man/curs_scanw.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_scanw.3x.html	2003-10-25 17:39:50.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_scanw.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG>                                     <STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG>
+<STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG>                                           <STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG>
 
 
 
@@ -118,7 +118,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_scanw.3x.html">curs_scanw(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_scr_dump.3x.html ncurses-5.4/doc/html/man/curs_scr_dump.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_scr_dump.3x.html	2004-01-11 01:46:20.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_scr_dump.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_scr_dump.3x.html">curs_scr_dump(3x)</A></STRONG>                               <STRONG><A HREF="curs_scr_dump.3x.html">curs_scr_dump(3x)</A></STRONG>
+<STRONG><A HREF="curs_scr_dump.3x.html">curs_scr_dump(3x)</A></STRONG>                                     <STRONG><A HREF="curs_scr_dump.3x.html">curs_scr_dump(3x)</A></STRONG>
 
 
 
@@ -122,7 +122,7 @@
 
 
 
-                                                <STRONG><A HREF="curs_scr_dump.3x.html">curs_scr_dump(3x)</A></STRONG>
+                                                      <STRONG><A HREF="curs_scr_dump.3x.html">curs_scr_dump(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_scroll.3x.html ncurses-5.4/doc/html/man/curs_scroll.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_scroll.3x.html	2003-10-25 17:39:50.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_scroll.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_scroll.3x.html">curs_scroll(3x)</A></STRONG>                                   <STRONG><A HREF="curs_scroll.3x.html">curs_scroll(3x)</A></STRONG>
+<STRONG><A HREF="curs_scroll.3x.html">curs_scroll(3x)</A></STRONG>                                         <STRONG><A HREF="curs_scroll.3x.html">curs_scroll(3x)</A></STRONG>
 
 
 
@@ -114,7 +114,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_scroll.3x.html">curs_scroll(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_scroll.3x.html">curs_scroll(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_slk.3x.html ncurses-5.4/doc/html/man/curs_slk.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_slk.3x.html	2003-10-25 17:39:50.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_slk.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>                                         <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
+<STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>                                               <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
 
 
 
@@ -171,7 +171,7 @@
 
 
 
-                                                     <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
+                                                           <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_termattrs.3x.html ncurses-5.4/doc/html/man/curs_termattrs.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_termattrs.3x.html	2004-01-11 01:46:21.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_termattrs.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_termattrs.3x.html">curs_termattrs(3x)</A></STRONG>                             <STRONG><A HREF="curs_termattrs.3x.html">curs_termattrs(3x)</A></STRONG>
+<STRONG><A HREF="curs_termattrs.3x.html">curs_termattrs(3x)</A></STRONG>                                   <STRONG><A HREF="curs_termattrs.3x.html">curs_termattrs(3x)</A></STRONG>
 
 
 
@@ -150,7 +150,7 @@
 
 
 
-                                               <STRONG><A HREF="curs_termattrs.3x.html">curs_termattrs(3x)</A></STRONG>
+                                                     <STRONG><A HREF="curs_termattrs.3x.html">curs_termattrs(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_termcap.3x.html ncurses-5.4/doc/html/man/curs_termcap.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_termcap.3x.html	2003-10-25 17:39:50.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_termcap.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>                                 <STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>
+<STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>                                       <STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>
 
 
 
@@ -115,9 +115,9 @@
 </PRE>
 <H2>RETURN VALUE</H2><PRE>
        Except where explicitly noted,  routines  that  return  an
-       integer  return  <STRONG>ERR</STRONG> upon failure and <STRONG>OK</STRONG> (SVr4 only speci-
-       fies "an integer value other than  <STRONG>ERR</STRONG>")  upon  successful
-       completion.
+       integer   return  <STRONG>ERR</STRONG>  upon  failure  and  <STRONG>OK</STRONG>  (SVr4  only
+       specifies "an integer value other than <STRONG>ERR</STRONG>") upon success-
+       ful completion.
 
        Routines that return pointers return <STRONG>NULL</STRONG> on error.
 
@@ -176,7 +176,7 @@
 
 
 
-                                                 <STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>
+                                                       <STRONG><A HREF="curs_termcap.3x.html">curs_termcap(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_terminfo.3x.html ncurses-5.4/doc/html/man/curs_terminfo.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_terminfo.3x.html	2004-01-11 01:46:21.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_terminfo.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG>                               <STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG>
+<STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG>                                     <STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG>
 
 
 
@@ -297,7 +297,7 @@
 
 
 
-                                                <STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG>
+                                                      <STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_touch.3x.html ncurses-5.4/doc/html/man/curs_touch.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_touch.3x.html	2003-10-25 17:39:51.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_touch.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_touch.3x.html">curs_touch(3x)</A></STRONG>                                     <STRONG><A HREF="curs_touch.3x.html">curs_touch(3x)</A></STRONG>
+<STRONG><A HREF="curs_touch.3x.html">curs_touch(3x)</A></STRONG>                                           <STRONG><A HREF="curs_touch.3x.html">curs_touch(3x)</A></STRONG>
 
 
 
@@ -118,7 +118,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_touch.3x.html">curs_touch(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_touch.3x.html">curs_touch(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_trace.3x.html ncurses-5.4/doc/html/man/curs_trace.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_trace.3x.html	2003-10-25 17:39:51.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_trace.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_trace.3x.html">curs_trace(3x)</A></STRONG>                                     <STRONG><A HREF="curs_trace.3x.html">curs_trace(3x)</A></STRONG>
+<STRONG><A HREF="curs_trace.3x.html">curs_trace(3x)</A></STRONG>                                           <STRONG><A HREF="curs_trace.3x.html">curs_trace(3x)</A></STRONG>
 
 
 
@@ -163,7 +163,7 @@
 
 
 
-                                                   <STRONG><A HREF="curs_trace.3x.html">curs_trace(3x)</A></STRONG>
+                                                         <STRONG><A HREF="curs_trace.3x.html">curs_trace(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_util.3x.html ncurses-5.4/doc/html/man/curs_util.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_util.3x.html	2003-10-25 17:39:51.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_util.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2004,2005 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: curs_util.3x,v 1.11 2003/07/19 19:59:56 tom Exp @
+  * @Id: curs_util.3x,v 1.13 2005/04/30 19:39:53 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_util.3x.html">curs_util(3x)</A></STRONG>                                       <STRONG><A HREF="curs_util.3x.html">curs_util(3x)</A></STRONG>
+<STRONG><A HREF="curs_util.3x.html">curs_util(3x)</A></STRONG>                                             <STRONG><A HREF="curs_util.3x.html">curs_util(3x)</A></STRONG>
 
 
 
@@ -145,6 +145,18 @@
        from the XSI Curses standard (which erroneously  fails  to
        describe the disabling of <STRONG>cuu</STRONG>).
 
+       The  strings returned by <STRONG>unctrl</STRONG> in this implementation are
+       determined at compile time, showing C1 controls  from  the
+       upper-128  codes with a `~' prefix rather than `^'.  Other
+       implementations typically show both sets of control  char-
+       acters  with  `^',  and may strip the parameter to 7 bits.
+       This implementation uses 8 bits but does  not  modify  the
+       string to reflect locale.
+
+       The  <STRONG>keyname</STRONG> function may return the names of user-defined
+       string capabilities which  are  defined  in  the  terminfo
+       entry via the <STRONG>-x</STRONG> option of <STRONG>tic</STRONG>.
+
 
 </PRE>
 <H2>SEE ALSO</H2><PRE>
@@ -153,7 +165,7 @@
 
 
 
-                                                    <STRONG><A HREF="curs_util.3x.html">curs_util(3x)</A></STRONG>
+                                                          <STRONG><A HREF="curs_util.3x.html">curs_util(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/curs_window.3x.html ncurses-5.4/doc/html/man/curs_window.3x.html
--- ncurses-5.4.orig/doc/html/man/curs_window.3x.html	2003-10-25 17:39:51.000000000 +0000
+++ ncurses-5.4/doc/html/man/curs_window.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="curs_window.3x.html">curs_window(3x)</A></STRONG>                                   <STRONG><A HREF="curs_window.3x.html">curs_window(3x)</A></STRONG>
+<STRONG><A HREF="curs_window.3x.html">curs_window(3x)</A></STRONG>                                         <STRONG><A HREF="curs_window.3x.html">curs_window(3x)</A></STRONG>
 
 
 
@@ -179,7 +179,7 @@
 
 
 
-                                                  <STRONG><A HREF="curs_window.3x.html">curs_window(3x)</A></STRONG>
+                                                        <STRONG><A HREF="curs_window.3x.html">curs_window(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/default_colors.3x.html ncurses-5.4/doc/html/man/default_colors.3x.html
--- ncurses-5.4.orig/doc/html/man/default_colors.3x.html	2004-01-11 01:46:22.000000000 +0000
+++ ncurses-5.4/doc/html/man/default_colors.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2005 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            *
@@ -27,8 +27,8 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * Author: Thomas E. Dickey 1997,1999,2000
-  * @Id: default_colors.3x,v 1.17 2003/10/25 20:41:08 tom Exp @
+  * Author: Thomas E. Dickey 1997,1999,2000,2005
+  * @Id: default_colors.3x,v 1.18 2005/02/19 20:25:44 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>                             <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>
+<STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>                                   <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>
 
 
 
@@ -125,12 +125,35 @@
        accepts negative arguments to specify  default  foreground
        or background colors.
 
+       The  <EM>use</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM>  function  was  added to support
+       <EM>ded</EM>.  This is a full-screen application which uses  curses
+       to  manage only part of the screen.  The bottom portion of
+       the screen, which is of adjustable size, is left uncolored
+       to  display the results from shell commands.  The top por-
+       tion of the screen colors filenames using  a  scheme  like
+       the  "color  ls" programs.  Attempting to manage the back-
+       ground color of the screen for this application would give
+       unsatisfactory  results  for  a  variety of reasons.  This
+       extension was devised after noting that color  xterm  (and
+       similar  programs)  provides a background color which does
+       not necessarily correspond to  any  of  the  ANSI  colors.
+       While  a special terminfo entry could be constructed using
+       nine colors, there was no mechanism provided within curses
+       to  account for the related <EM>orig</EM><STRONG>_</STRONG><EM>pair</EM> and <EM>back</EM><STRONG>_</STRONG><EM>color</EM><STRONG>_</STRONG><EM>erase</EM>
+       capabilities.
+
+       The <EM>assume</EM><STRONG>_</STRONG><EM>default</EM><STRONG>_</STRONG><EM>colors()</EM> function was added to solve  a
+       different  problem:  support  for applications which would
+       use  environment  variables  and  other  configuration  to
+       bypass  curses'  notion  of the terminal's default colors,
+       setting specific values.
+
 
 </PRE>
 <H2>PORTABILITY</H2><PRE>
-       These  routines  are  specific  to ncurses.  They were not
-       supported on Version 7, BSD or System  V  implementations.
-       It  is recommended that any code depending on them be con-
+       These routines are specific to  ncurses.   They  were  not
+       supported  on  Version 7, BSD or System V implementations.
+       It is recommended that any code depending on them be  con-
        ditioned using NCURSES_VERSION.
 
 
@@ -141,12 +164,12 @@
 
 </PRE>
 <H2>AUTHOR</H2><PRE>
-       Thomas Dickey (from an analysis of  the  requirements  for
+       Thomas  Dickey  (from  an analysis of the requirements for
        color xterm for XFree86 3.1.2C, February 1996).
 
 
 
-                                               <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>
+                                                     <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/define_key.3x.html ncurses-5.4/doc/html/man/define_key.3x.html
--- ncurses-5.4.orig/doc/html/man/define_key.3x.html	2004-01-11 01:46:22.000000000 +0000
+++ ncurses-5.4/doc/html/man/define_key.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2004 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            *
@@ -28,7 +28,7 @@
   * authorization.                                                           *
   ****************************************************************************
   * Author: Thomas E. Dickey 1997
-  * @Id: define_key.3x,v 1.10 2003/10/25 20:33:16 tom Exp @
+  * @Id: define_key.3x,v 1.11 2004/06/05 19:20:03 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="define_key.3x.html">define_key(3x)</A></STRONG>                                     <STRONG><A HREF="define_key.3x.html">define_key(3x)</A></STRONG>
+<STRONG><A HREF="define_key.3x.html">define_key(3x)</A></STRONG>                                           <STRONG><A HREF="define_key.3x.html">define_key(3x)</A></STRONG>
 
 
 
@@ -88,7 +88,7 @@
 
 </PRE>
 <H2>SEE ALSO</H2><PRE>
-       <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>.
+       <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>, <STRONG><A HREF="key_defined.3x.html">key_defined(3x)</A></STRONG>.
 
 
 </PRE>
@@ -97,7 +97,7 @@
 
 
 
-                                                   <STRONG><A HREF="define_key.3x.html">define_key(3x)</A></STRONG>
+                                                         <STRONG><A HREF="define_key.3x.html">define_key(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form.3x.html ncurses-5.4/doc/html/man/form.3x.html
--- ncurses-5.4.orig/doc/html/man/form.3x.html	2003-10-25 17:39:52.000000000 +0000
+++ ncurses-5.4/doc/html/man/form.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>                                                 <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>
+<STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>                                                       <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>
 
 
 
@@ -84,6 +84,7 @@
        The following table lists each <STRONG>form</STRONG> routine and  the  name
        of the manual page on which it is described.
 
+
        <STRONG>curses</STRONG> Routine Name    Manual Page Name
        -------------------------------------------------
        current_field          <STRONG><A HREF="form_page.3x.html">form_page(3x)</A></STRONG>
@@ -111,8 +112,8 @@
        form_driver            <STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG>
        form_fields            <STRONG><A HREF="form_field.3x.html">form_field(3x)</A></STRONG>
        form_init              <STRONG><A HREF="form_hook.3x.html">form_hook(3x)</A></STRONG>
-       form_opts              <STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>
 
+       form_opts              <STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>
        form_opts_off          <STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>
        form_opts_on           <STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>
        form_page              <STRONG><A HREF="form_page.3x.html">form_page(3x)</A></STRONG>
@@ -234,7 +235,7 @@
 
 
 
-                                                         <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>
+                                                               <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_cursor.3x.html ncurses-5.4/doc/html/man/form_cursor.3x.html
--- ncurses-5.4.orig/doc/html/man/form_cursor.3x.html	2003-10-25 17:39:52.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_cursor.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_cursor.3x.html">form_cursor(3x)</A></STRONG>                                   <STRONG><A HREF="form_cursor.3x.html">form_cursor(3x)</A></STRONG>
+<STRONG><A HREF="form_cursor.3x.html">form_cursor(3x)</A></STRONG>                                         <STRONG><A HREF="form_cursor.3x.html">form_cursor(3x)</A></STRONG>
 
 
 
@@ -107,7 +107,7 @@
 
 
 
-                                                  <STRONG><A HREF="form_cursor.3x.html">form_cursor(3x)</A></STRONG>
+                                                        <STRONG><A HREF="form_cursor.3x.html">form_cursor(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_data.3x.html ncurses-5.4/doc/html/man/form_data.3x.html
--- ncurses-5.4.orig/doc/html/man/form_data.3x.html	2003-10-25 17:39:52.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_data.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_data.3x.html">form_data(3x)</A></STRONG>                                       <STRONG><A HREF="form_data.3x.html">form_data(3x)</A></STRONG>
+<STRONG><A HREF="form_data.3x.html">form_data(3x)</A></STRONG>                                             <STRONG><A HREF="form_data.3x.html">form_data(3x)</A></STRONG>
 
 
 
@@ -93,7 +93,7 @@
 
 
 
-                                                    <STRONG><A HREF="form_data.3x.html">form_data(3x)</A></STRONG>
+                                                          <STRONG><A HREF="form_data.3x.html">form_data(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_driver.3x.html ncurses-5.4/doc/html/man/form_driver.3x.html
--- ncurses-5.4.orig/doc/html/man/form_driver.3x.html	2003-10-25 17:39:52.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_driver.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG>                                   <STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG>
+<STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG>                                         <STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG>
 
 
 
@@ -308,7 +308,7 @@
 
 
 
-                                                  <STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG>
+                                                        <STRONG><A HREF="form_driver.3x.html">form_driver(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_field.3x.html ncurses-5.4/doc/html/man/form_field.3x.html
--- ncurses-5.4.orig/doc/html/man/form_field.3x.html	2003-10-25 17:39:52.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_field.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_field.3x.html">form_field(3x)</A></STRONG>                                     <STRONG><A HREF="form_field.3x.html">form_field(3x)</A></STRONG>
+<STRONG><A HREF="form_field.3x.html">form_field(3x)</A></STRONG>                                           <STRONG><A HREF="form_field.3x.html">form_field(3x)</A></STRONG>
 
 
 
@@ -130,7 +130,7 @@
 
 
 
-                                                   <STRONG><A HREF="form_field.3x.html">form_field(3x)</A></STRONG>
+                                                         <STRONG><A HREF="form_field.3x.html">form_field(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_field_attributes.3x.html ncurses-5.4/doc/html/man/form_field_attributes.3x.html
--- ncurses-5.4.orig/doc/html/man/form_field_attributes.3x.html	2003-10-25 17:39:52.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_field_attributes.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_field_attributes.3x.html">form_field_attributes(3x)</A></STRONG>               <STRONG><A HREF="form_field_attributes.3x.html">form_field_attributes(3x)</A></STRONG>
+<STRONG><A HREF="form_field_attributes.3x.html">form_field_attributes(3x)</A></STRONG>                     <STRONG><A HREF="form_field_attributes.3x.html">form_field_attributes(3x)</A></STRONG>
 
 
 
@@ -119,7 +119,7 @@
 
 
 
-                                        <STRONG><A HREF="form_field_attributes.3x.html">form_field_attributes(3x)</A></STRONG>
+                                              <STRONG><A HREF="form_field_attributes.3x.html">form_field_attributes(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_field_buffer.3x.html ncurses-5.4/doc/html/man/form_field_buffer.3x.html
--- ncurses-5.4.orig/doc/html/man/form_field_buffer.3x.html	2003-10-25 17:39:52.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_field_buffer.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2004 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: form_field_buffer.3x,v 1.10 2003/05/10 20:22:01 tom Exp @
+  * @Id: form_field_buffer.3x,v 1.11 2004/05/16 15:58:51 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_field_buffer.3x.html">form_field_buffer(3x)</A></STRONG>                       <STRONG><A HREF="form_field_buffer.3x.html">form_field_buffer(3x)</A></STRONG>
+<STRONG><A HREF="form_field_buffer.3x.html">form_field_buffer(3x)</A></STRONG>                             <STRONG><A HREF="form_field_buffer.3x.html">form_field_buffer(3x)</A></STRONG>
 
 
 
@@ -118,7 +118,13 @@
 </PRE>
 <H2>NOTES</H2><PRE>
        The header file <STRONG>&lt;form.h&gt;</STRONG> automatically includes the header
-       file <STRONG>&lt;curses.h&gt;</STRONG>.
+       file
+
+       When  configured for wide-characters, <STRONG>field_buffer</STRONG> returns
+       a pointer to temporary storage (allocated and freed by the
+       library).   The  application  should not attempt to modify
+       the  data.   It  will  be  freed  on  the  next  call   to
+       <STRONG>field_buffer</STRONG> to return the same buffer.  <STRONG>&lt;curses.h&gt;</STRONG>.
 
 
 </PRE>
@@ -134,7 +140,7 @@
 
 
 
-                                            <STRONG><A HREF="form_field_buffer.3x.html">form_field_buffer(3x)</A></STRONG>
+                                                  <STRONG><A HREF="form_field_buffer.3x.html">form_field_buffer(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_field_info.3x.html ncurses-5.4/doc/html/man/form_field_info.3x.html
--- ncurses-5.4.orig/doc/html/man/form_field_info.3x.html	2003-10-25 17:39:53.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_field_info.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_field_info.3x.html">form_field_info(3x)</A></STRONG>                           <STRONG><A HREF="form_field_info.3x.html">form_field_info(3x)</A></STRONG>
+<STRONG><A HREF="form_field_info.3x.html">form_field_info(3x)</A></STRONG>                                 <STRONG><A HREF="form_field_info.3x.html">form_field_info(3x)</A></STRONG>
 
 
 
@@ -118,7 +118,7 @@
 
 
 
-                                              <STRONG><A HREF="form_field_info.3x.html">form_field_info(3x)</A></STRONG>
+                                                    <STRONG><A HREF="form_field_info.3x.html">form_field_info(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_field_just.3x.html ncurses-5.4/doc/html/man/form_field_just.3x.html
--- ncurses-5.4.orig/doc/html/man/form_field_just.3x.html	2003-10-25 17:39:53.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_field_just.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_field_just.3x.html">form_field_just(3x)</A></STRONG>                           <STRONG><A HREF="form_field_just.3x.html">form_field_just(3x)</A></STRONG>
+<STRONG><A HREF="form_field_just.3x.html">form_field_just(3x)</A></STRONG>                                 <STRONG><A HREF="form_field_just.3x.html">form_field_just(3x)</A></STRONG>
 
 
 
@@ -109,7 +109,7 @@
 
 
 
-                                              <STRONG><A HREF="form_field_just.3x.html">form_field_just(3x)</A></STRONG>
+                                                    <STRONG><A HREF="form_field_just.3x.html">form_field_just(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_field_new.3x.html ncurses-5.4/doc/html/man/form_field_new.3x.html
--- ncurses-5.4.orig/doc/html/man/form_field_new.3x.html	2003-10-25 17:39:53.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_field_new.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_field_new.3x.html">form_field_new(3x)</A></STRONG>                             <STRONG><A HREF="form_field_new.3x.html">form_field_new(3x)</A></STRONG>
+<STRONG><A HREF="form_field_new.3x.html">form_field_new(3x)</A></STRONG>                                   <STRONG><A HREF="form_field_new.3x.html">form_field_new(3x)</A></STRONG>
 
 
 
@@ -130,7 +130,7 @@
 
 
 
-                                               <STRONG><A HREF="form_field_new.3x.html">form_field_new(3x)</A></STRONG>
+                                                     <STRONG><A HREF="form_field_new.3x.html">form_field_new(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_field_opts.3x.html ncurses-5.4/doc/html/man/form_field_opts.3x.html
--- ncurses-5.4.orig/doc/html/man/form_field_opts.3x.html	2003-10-25 17:39:53.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_field_opts.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_field_opts.3x.html">form_field_opts(3x)</A></STRONG>                           <STRONG><A HREF="form_field_opts.3x.html">form_field_opts(3x)</A></STRONG>
+<STRONG><A HREF="form_field_opts.3x.html">form_field_opts(3x)</A></STRONG>                                 <STRONG><A HREF="form_field_opts.3x.html">form_field_opts(3x)</A></STRONG>
 
 
 
@@ -150,7 +150,7 @@
 
 
 
-                                              <STRONG><A HREF="form_field_opts.3x.html">form_field_opts(3x)</A></STRONG>
+                                                    <STRONG><A HREF="form_field_opts.3x.html">form_field_opts(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_field_userptr.3x.html ncurses-5.4/doc/html/man/form_field_userptr.3x.html
--- ncurses-5.4.orig/doc/html/man/form_field_userptr.3x.html	2003-10-25 17:39:53.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_field_userptr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_field_userptr.3x.html">form_field_userptr(3x)</A></STRONG>                     <STRONG><A HREF="form_field_userptr.3x.html">form_field_userptr(3x)</A></STRONG>
+<STRONG><A HREF="form_field_userptr.3x.html">form_field_userptr(3x)</A></STRONG>                           <STRONG><A HREF="form_field_userptr.3x.html">form_field_userptr(3x)</A></STRONG>
 
 
 
@@ -104,7 +104,7 @@
 
 
 
-                                           <STRONG><A HREF="form_field_userptr.3x.html">form_field_userptr(3x)</A></STRONG>
+                                                 <STRONG><A HREF="form_field_userptr.3x.html">form_field_userptr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_field_validation.3x.html ncurses-5.4/doc/html/man/form_field_validation.3x.html
--- ncurses-5.4.orig/doc/html/man/form_field_validation.3x.html	2003-10-25 17:39:53.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_field_validation.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_field_validation.3x.html">form_field_validation(3x)</A></STRONG>               <STRONG><A HREF="form_field_validation.3x.html">form_field_validation(3x)</A></STRONG>
+<STRONG><A HREF="form_field_validation.3x.html">form_field_validation(3x)</A></STRONG>                     <STRONG><A HREF="form_field_validation.3x.html">form_field_validation(3x)</A></STRONG>
 
 
 
@@ -185,7 +185,7 @@
 
 
 
-                                        <STRONG><A HREF="form_field_validation.3x.html">form_field_validation(3x)</A></STRONG>
+                                              <STRONG><A HREF="form_field_validation.3x.html">form_field_validation(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_fieldtype.3x.html ncurses-5.4/doc/html/man/form_fieldtype.3x.html
--- ncurses-5.4.orig/doc/html/man/form_fieldtype.3x.html	2003-10-25 17:39:53.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_fieldtype.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>                             <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
+<STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>                                   <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
 
 
 
@@ -166,7 +166,7 @@
 
 
 
-                                               <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
+                                                     <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_hook.3x.html ncurses-5.4/doc/html/man/form_hook.3x.html
--- ncurses-5.4.orig/doc/html/man/form_hook.3x.html	2003-10-25 17:39:53.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_hook.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_hook.3x.html">form_hook(3x)</A></STRONG>                                       <STRONG><A HREF="form_hook.3x.html">form_hook(3x)</A></STRONG>
+<STRONG><A HREF="form_hook.3x.html">form_hook(3x)</A></STRONG>                                             <STRONG><A HREF="form_hook.3x.html">form_hook(3x)</A></STRONG>
 
 
 
@@ -127,7 +127,7 @@
 
 
 
-                                                    <STRONG><A HREF="form_hook.3x.html">form_hook(3x)</A></STRONG>
+                                                          <STRONG><A HREF="form_hook.3x.html">form_hook(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_new.3x.html ncurses-5.4/doc/html/man/form_new.3x.html
--- ncurses-5.4.orig/doc/html/man/form_new.3x.html	2003-10-25 17:39:54.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_new.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_new.3x.html">form_new(3x)</A></STRONG>                                         <STRONG><A HREF="form_new.3x.html">form_new(3x)</A></STRONG>
+<STRONG><A HREF="form_new.3x.html">form_new(3x)</A></STRONG>                                               <STRONG><A HREF="form_new.3x.html">form_new(3x)</A></STRONG>
 
 
 
@@ -111,7 +111,7 @@
 
 
 
-                                                     <STRONG><A HREF="form_new.3x.html">form_new(3x)</A></STRONG>
+                                                           <STRONG><A HREF="form_new.3x.html">form_new(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_new_page.3x.html ncurses-5.4/doc/html/man/form_new_page.3x.html
--- ncurses-5.4.orig/doc/html/man/form_new_page.3x.html	2003-10-25 17:39:54.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_new_page.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_new_page.3x.html">form_new_page(3x)</A></STRONG>                               <STRONG><A HREF="form_new_page.3x.html">form_new_page(3x)</A></STRONG>
+<STRONG><A HREF="form_new_page.3x.html">form_new_page(3x)</A></STRONG>                                     <STRONG><A HREF="form_new_page.3x.html">form_new_page(3x)</A></STRONG>
 
 
 
@@ -108,7 +108,7 @@
 
 
 
-                                                <STRONG><A HREF="form_new_page.3x.html">form_new_page(3x)</A></STRONG>
+                                                      <STRONG><A HREF="form_new_page.3x.html">form_new_page(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_opts.3x.html ncurses-5.4/doc/html/man/form_opts.3x.html
--- ncurses-5.4.orig/doc/html/man/form_opts.3x.html	2003-10-25 17:39:54.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_opts.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>                                       <STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>
+<STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>                                             <STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>
 
 
 
@@ -123,7 +123,7 @@
 
 
 
-                                                    <STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>
+                                                          <STRONG><A HREF="form_opts.3x.html">form_opts(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_page.3x.html ncurses-5.4/doc/html/man/form_page.3x.html
--- ncurses-5.4.orig/doc/html/man/form_page.3x.html	2003-10-25 17:39:54.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_page.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_page.3x.html">form_page(3x)</A></STRONG>                                       <STRONG><A HREF="form_page.3x.html">form_page(3x)</A></STRONG>
+<STRONG><A HREF="form_page.3x.html">form_page(3x)</A></STRONG>                                             <STRONG><A HREF="form_page.3x.html">form_page(3x)</A></STRONG>
 
 
 
@@ -128,7 +128,7 @@
 
 
 
-                                                    <STRONG><A HREF="form_page.3x.html">form_page(3x)</A></STRONG>
+                                                          <STRONG><A HREF="form_page.3x.html">form_page(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_post.3x.html ncurses-5.4/doc/html/man/form_post.3x.html
--- ncurses-5.4.orig/doc/html/man/form_post.3x.html	2003-10-25 17:39:54.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_post.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_post.3x.html">form_post(3x)</A></STRONG>                                       <STRONG><A HREF="form_post.3x.html">form_post(3x)</A></STRONG>
+<STRONG><A HREF="form_post.3x.html">form_post(3x)</A></STRONG>                                             <STRONG><A HREF="form_post.3x.html">form_post(3x)</A></STRONG>
 
 
 
@@ -125,7 +125,7 @@
 
 
 
-                                                    <STRONG><A HREF="form_post.3x.html">form_post(3x)</A></STRONG>
+                                                          <STRONG><A HREF="form_post.3x.html">form_post(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_requestname.3x.html ncurses-5.4/doc/html/man/form_requestname.3x.html
--- ncurses-5.4.orig/doc/html/man/form_requestname.3x.html	2003-10-25 17:39:54.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_requestname.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_requestname.3x.html">form_requestname(3x)</A></STRONG>                         <STRONG><A HREF="form_requestname.3x.html">form_requestname(3x)</A></STRONG>
+<STRONG><A HREF="form_requestname.3x.html">form_requestname(3x)</A></STRONG>                               <STRONG><A HREF="form_requestname.3x.html">form_requestname(3x)</A></STRONG>
 
 
 
@@ -62,8 +62,8 @@
 <H2>DESCRIPTION</H2><PRE>
        The  function <STRONG>form_request_name</STRONG> returns the printable name
        of a form request code.
-       The function <STRONG>form_request_by_name</STRONG> searches  in  the  name-
-       table  for  a  request with the given name and returns its
+       The function <STRONG>form_request_by_name</STRONG> searches in the name-ta-
+       ble  for  a  request  with  the given name and returns its
        request code. Otherwise E_NO_MATCH is returned.
 
 
@@ -100,7 +100,7 @@
 
 
 
-                                             <STRONG><A HREF="form_requestname.3x.html">form_requestname(3x)</A></STRONG>
+                                                   <STRONG><A HREF="form_requestname.3x.html">form_requestname(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_userptr.3x.html ncurses-5.4/doc/html/man/form_userptr.3x.html
--- ncurses-5.4.orig/doc/html/man/form_userptr.3x.html	2003-10-25 17:39:54.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_userptr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_userptr.3x.html">form_userptr(3x)</A></STRONG>                                 <STRONG><A HREF="form_userptr.3x.html">form_userptr(3x)</A></STRONG>
+<STRONG><A HREF="form_userptr.3x.html">form_userptr(3x)</A></STRONG>                                       <STRONG><A HREF="form_userptr.3x.html">form_userptr(3x)</A></STRONG>
 
 
 
@@ -104,7 +104,7 @@
 
 
 
-                                                 <STRONG><A HREF="form_userptr.3x.html">form_userptr(3x)</A></STRONG>
+                                                       <STRONG><A HREF="form_userptr.3x.html">form_userptr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/form_win.3x.html ncurses-5.4/doc/html/man/form_win.3x.html
--- ncurses-5.4.orig/doc/html/man/form_win.3x.html	2003-10-25 17:39:55.000000000 +0000
+++ ncurses-5.4/doc/html/man/form_win.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="form_win.3x.html">form_win(3x)</A></STRONG>                                         <STRONG><A HREF="form_win.3x.html">form_win(3x)</A></STRONG>
+<STRONG><A HREF="form_win.3x.html">form_win(3x)</A></STRONG>                                               <STRONG><A HREF="form_win.3x.html">form_win(3x)</A></STRONG>
 
 
 
@@ -128,7 +128,7 @@
 
 
 
-                                                     <STRONG><A HREF="form_win.3x.html">form_win(3x)</A></STRONG>
+                                                           <STRONG><A HREF="form_win.3x.html">form_win(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/infocmp.1m.html ncurses-5.4/doc/html/man/infocmp.1m.html
--- ncurses-5.4.orig/doc/html/man/infocmp.1m.html	2004-01-11 01:46:25.000000000 +0000
+++ ncurses-5.4/doc/html/man/infocmp.1m.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2004 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: infocmp.1m,v 1.34 2003/10/25 16:19:01 tom Exp @
+  * @Id: infocmp.1m,v 1.39 2004/08/28 22:43:49 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>                                           <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>
+<STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>                                                 <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>
 
 
 
@@ -53,7 +53,7 @@
 
 </PRE>
 <H2>SYNOPSIS</H2><PRE>
-       <STRONG>infocmp</STRONG> [<STRONG>-1CEFGILTVcdegilnpqrtu</STRONG>]
+       <STRONG>infocmp</STRONG> [<STRONG>-1CEFGILTVcdegilnpqrtux</STRONG>]
              [<STRONG>-v</STRONG> <EM>n</EM>] [<STRONG>-s</STRONG> <STRONG>d</STRONG>| <STRONG>i</STRONG>| <STRONG>l</STRONG>| <STRONG>c</STRONG>] [<STRONG>-R</STRONG> <STRONG>subset</STRONG>]
              [<STRONG>-w</STRONG> <EM>width</EM>] [<STRONG>-A</STRONG> <EM>directory</EM>] [<STRONG>-B</STRONG> <EM>directory</EM>]
              [<EM>termname</EM>...]
@@ -103,6 +103,7 @@
        The <STRONG>-I</STRONG>, <STRONG>-L</STRONG>, and <STRONG>-C</STRONG> options will produce a  source  listing
        for each terminal named.
 
+
       <STRONG>-I</STRONG>   use the <STRONG>terminfo</STRONG> names
       <STRONG>-L</STRONG>   use the long C variable name listed in &lt;<STRONG>term.h</STRONG>&gt;
       <STRONG>-C</STRONG>   use the <STRONG>termcap</STRONG> names
@@ -144,6 +145,7 @@
        equivalents, and some terminal types which  commonly  have
        such sequences, are:
 
+
      <STRONG>terminfo</STRONG>                    <STRONG>termcap</STRONG>   Representative Terminals
      ---------------------------------------------------------------
      <STRONG>%p1%c</STRONG>                       <STRONG>%.</STRONG>        adm
@@ -280,6 +282,7 @@
             tions.  Here  is  a  list  of  the  DEC/ANSI  special
             sequences recognized:
 
+
                   Action        Meaning
                   -----------------------------------------
                   RIS           full reset
@@ -288,6 +291,9 @@
                   LL            home-down
                   RSR           reset scroll region
 
+                  DECSTR        soft reset (VT320)
+                  S7C1T         7-bit controls (VT220)
+
                   ISO DEC G0    enable DEC graphics for G0
                   ISO UK G0     enable UK chars for G0
                   ISO US G0     enable US chars for G0
@@ -299,8 +305,14 @@
                   DECPNM        normal keypad mode
                   DECANSI       enter ANSI mode
 
+                  ECMA[+-]AM    keyboard action mode
+                  ECMA[+-]IRM   insert replace mode
+                  ECMA[+-]SRM   send receive mode
+                  ECMA[+-]LNM   linefeed mode
+
                   DEC[+-]CKM    application cursor keys
                   DEC[+-]ANM    set VT52 mode
+
                   DEC[+-]COLM   132-column mode
                   DEC[+-]SCLM   smooth scroll
                   DEC[+-]SCNM   reverse video mode
@@ -376,6 +388,10 @@
        <STRONG>-w</STRONG> <EM>width</EM>
             changes the output to <EM>width</EM> characters.
 
+       <STRONG>-x</STRONG>   print   information  for  user-defined  capabilities.
+            These are extensions to the terminfo repertoire which
+            can be loaded using the <STRONG>-x</STRONG> option of <STRONG>tic</STRONG>.
+
 
 </PRE>
 <H2>FILES</H2><PRE>
@@ -412,7 +428,7 @@
 
 
 
-                                                      <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>
+                                                            <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/infotocap.1m.html ncurses-5.4/doc/html/man/infotocap.1m.html
--- ncurses-5.4.orig/doc/html/man/infotocap.1m.html	2003-10-25 17:39:55.000000000 +0000
+++ ncurses-5.4/doc/html/man/infotocap.1m.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1999-2000,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1999-2003,2004 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: infotocap.1m,v 1.4 2003/05/11 00:32:53 tom Exp @
+  * @Id: infotocap.1m,v 1.5 2004/07/05 13:16:08 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>                                       <STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>
+<STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>                                             <STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>
 
 
 
@@ -95,7 +95,7 @@
 
 
 
-                                                    <STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>
+                                                          <STRONG><A HREF="infotocap.1m.html">infotocap(1m)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/key_defined.3x.html ncurses-5.4/doc/html/man/key_defined.3x.html
--- ncurses-5.4.orig/doc/html/man/key_defined.3x.html	2003-10-25 17:39:55.000000000 +0000
+++ ncurses-5.4/doc/html/man/key_defined.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 2003 Free Software Foundation, Inc.                        *
+  * Copyright (c) 2003,2004 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            *
@@ -28,7 +28,7 @@
   * authorization.                                                           *
   ****************************************************************************
   * Author: Thomas E. Dickey 2003
-  * @Id: key_defined.3x,v 1.2 2003/05/17 23:24:45 tom Exp @
+  * @Id: key_defined.3x,v 1.3 2004/06/05 19:19:09 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,14 +41,14 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="key_defined.3x.html">key_defined(3x)</A></STRONG>                                   <STRONG><A HREF="key_defined.3x.html">key_defined(3x)</A></STRONG>
+<STRONG><A HREF="key_defined.3x.html">key_defined(3x)</A></STRONG>                                         <STRONG><A HREF="key_defined.3x.html">key_defined(3x)</A></STRONG>
 
 
 
 
 </PRE>
 <H2>NAME</H2><PRE>
-       <STRONG>define_key</STRONG> - define a keycode
+       <STRONG>key_defined</STRONG> - check if a keycode is defined
 
 
 </PRE>
@@ -92,7 +92,7 @@
 
 
 
-                                                  <STRONG><A HREF="key_defined.3x.html">key_defined(3x)</A></STRONG>
+                                                        <STRONG><A HREF="key_defined.3x.html">key_defined(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/keybound.3x.html ncurses-5.4/doc/html/man/keybound.3x.html
--- ncurses-5.4.orig/doc/html/man/keybound.3x.html	2004-01-11 01:46:25.000000000 +0000
+++ ncurses-5.4/doc/html/man/keybound.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>                                               <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>
+<STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>                                                     <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>
 
 
 
@@ -94,7 +94,7 @@
 
 
 
-                                                        <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>
+                                                              <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/keyok.3x.html ncurses-5.4/doc/html/man/keyok.3x.html
--- ncurses-5.4.orig/doc/html/man/keyok.3x.html	2004-01-11 01:46:26.000000000 +0000
+++ ncurses-5.4/doc/html/man/keyok.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>                                               <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>
+<STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>                                                     <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>
 
 
 
@@ -94,7 +94,7 @@
 
 
 
-                                                        <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>
+                                                              <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu.3x.html ncurses-5.4/doc/html/man/menu.3x.html
--- ncurses-5.4.orig/doc/html/man/menu.3x.html	2003-10-25 17:39:55.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu.3x.html">menu(3x)</A></STRONG>                                                 <STRONG><A HREF="menu.3x.html">menu(3x)</A></STRONG>
+<STRONG><A HREF="menu.3x.html">menu(3x)</A></STRONG>                                                       <STRONG><A HREF="menu.3x.html">menu(3x)</A></STRONG>
 
 
 
@@ -84,6 +84,7 @@
        The following table lists each <STRONG>menu</STRONG> routine and  the  name
        of the manual page on which it is described.
 
+
        <STRONG>curses</STRONG> Routine Name    Manual Page Name
        --------------------------------------------
        current_item           <STRONG><A HREF="mitem_current.3x.html">mitem_current(3x)</A></STRONG>
@@ -111,8 +112,8 @@
        menu_mark              <STRONG><A HREF="menu_mark.3x.html">menu_mark(3x)</A></STRONG>
        menu_opts              <STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>
        menu_opts_off          <STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>
-       menu_opts_on           <STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>
 
+       menu_opts_on           <STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>
        menu_pad               <STRONG><A HREF="menu_attributes.3x.html">menu_attributes(3x)</A></STRONG>
        menu_pattern           <STRONG><A HREF="menu_pattern.3x.html">menu_pattern(3x)</A></STRONG>
        menu_request_by_name   <STRONG><A HREF="menu_requestname.3x.html">menu_requestname(3x)</A></STRONG>
@@ -227,7 +228,7 @@
 
 
 
-                                                         <STRONG><A HREF="menu.3x.html">menu(3x)</A></STRONG>
+                                                               <STRONG><A HREF="menu.3x.html">menu(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_attributes.3x.html ncurses-5.4/doc/html/man/menu_attributes.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_attributes.3x.html	2003-10-25 17:39:55.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_attributes.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_attributes.3x.html">menu_attributes(3x)</A></STRONG>                           <STRONG><A HREF="menu_attributes.3x.html">menu_attributes(3x)</A></STRONG>
+<STRONG><A HREF="menu_attributes.3x.html">menu_attributes(3x)</A></STRONG>                                 <STRONG><A HREF="menu_attributes.3x.html">menu_attributes(3x)</A></STRONG>
 
 
 
@@ -128,7 +128,7 @@
 
 
 
-                                              <STRONG><A HREF="menu_attributes.3x.html">menu_attributes(3x)</A></STRONG>
+                                                    <STRONG><A HREF="menu_attributes.3x.html">menu_attributes(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_cursor.3x.html ncurses-5.4/doc/html/man/menu_cursor.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_cursor.3x.html	2003-10-25 17:39:56.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_cursor.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_cursor.3x.html">menu_cursor(3x)</A></STRONG>                                   <STRONG><A HREF="menu_cursor.3x.html">menu_cursor(3x)</A></STRONG>
+<STRONG><A HREF="menu_cursor.3x.html">menu_cursor(3x)</A></STRONG>                                         <STRONG><A HREF="menu_cursor.3x.html">menu_cursor(3x)</A></STRONG>
 
 
 
@@ -106,7 +106,7 @@
 
 
 
-                                                  <STRONG><A HREF="menu_cursor.3x.html">menu_cursor(3x)</A></STRONG>
+                                                        <STRONG><A HREF="menu_cursor.3x.html">menu_cursor(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_driver.3x.html ncurses-5.4/doc/html/man/menu_driver.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_driver.3x.html	2003-10-25 17:39:56.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_driver.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>                                   <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>
+<STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>                                         <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>
 
 
 
@@ -213,7 +213,7 @@
 
 
 
-                                                  <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>
+                                                        <STRONG><A HREF="menu_driver.3x.html">menu_driver(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_format.3x.html ncurses-5.4/doc/html/man/menu_format.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_format.3x.html	2003-10-25 17:39:56.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_format.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_format.3x.html">menu_format(3x)</A></STRONG>                                   <STRONG><A HREF="menu_format.3x.html">menu_format(3x)</A></STRONG>
+<STRONG><A HREF="menu_format.3x.html">menu_format(3x)</A></STRONG>                                         <STRONG><A HREF="menu_format.3x.html">menu_format(3x)</A></STRONG>
 
 
 
@@ -119,7 +119,7 @@
 
 
 
-                                                  <STRONG><A HREF="menu_format.3x.html">menu_format(3x)</A></STRONG>
+                                                        <STRONG><A HREF="menu_format.3x.html">menu_format(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_hook.3x.html ncurses-5.4/doc/html/man/menu_hook.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_hook.3x.html	2003-10-25 17:39:56.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_hook.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_hook.3x.html">menu_hook(3x)</A></STRONG>                                       <STRONG><A HREF="menu_hook.3x.html">menu_hook(3x)</A></STRONG>
+<STRONG><A HREF="menu_hook.3x.html">menu_hook(3x)</A></STRONG>                                             <STRONG><A HREF="menu_hook.3x.html">menu_hook(3x)</A></STRONG>
 
 
 
@@ -127,7 +127,7 @@
 
 
 
-                                                    <STRONG><A HREF="menu_hook.3x.html">menu_hook(3x)</A></STRONG>
+                                                          <STRONG><A HREF="menu_hook.3x.html">menu_hook(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_items.3x.html ncurses-5.4/doc/html/man/menu_items.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_items.3x.html	2003-10-25 17:39:56.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_items.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_items.3x.html">menu_items(3x)</A></STRONG>                                     <STRONG><A HREF="menu_items.3x.html">menu_items(3x)</A></STRONG>
+<STRONG><A HREF="menu_items.3x.html">menu_items(3x)</A></STRONG>                                           <STRONG><A HREF="menu_items.3x.html">menu_items(3x)</A></STRONG>
 
 
 
@@ -126,6 +126,7 @@
 
 
 
+                                                         <STRONG><A HREF="menu_items.3x.html">menu_items(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_mark.3x.html ncurses-5.4/doc/html/man/menu_mark.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_mark.3x.html	2003-10-25 17:39:56.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_mark.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_mark.3x.html">menu_mark(3x)</A></STRONG>                                       <STRONG><A HREF="menu_mark.3x.html">menu_mark(3x)</A></STRONG>
+<STRONG><A HREF="menu_mark.3x.html">menu_mark(3x)</A></STRONG>                                             <STRONG><A HREF="menu_mark.3x.html">menu_mark(3x)</A></STRONG>
 
 
 
@@ -117,7 +117,7 @@
 
 
 
-                                                    <STRONG><A HREF="menu_mark.3x.html">menu_mark(3x)</A></STRONG>
+                                                          <STRONG><A HREF="menu_mark.3x.html">menu_mark(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_new.3x.html ncurses-5.4/doc/html/man/menu_new.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_new.3x.html	2003-10-25 17:39:56.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_new.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_new.3x.html">menu_new(3x)</A></STRONG>                                         <STRONG><A HREF="menu_new.3x.html">menu_new(3x)</A></STRONG>
+<STRONG><A HREF="menu_new.3x.html">menu_new(3x)</A></STRONG>                                               <STRONG><A HREF="menu_new.3x.html">menu_new(3x)</A></STRONG>
 
 
 
@@ -111,7 +111,7 @@
 
 
 
-                                                     <STRONG><A HREF="menu_new.3x.html">menu_new(3x)</A></STRONG>
+                                                           <STRONG><A HREF="menu_new.3x.html">menu_new(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_opts.3x.html ncurses-5.4/doc/html/man/menu_opts.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_opts.3x.html	2003-10-25 17:39:56.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_opts.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>                                       <STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>
+<STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>                                             <STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>
 
 
 
@@ -137,7 +137,7 @@
 
 
 
-                                                    <STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>
+                                                          <STRONG><A HREF="menu_opts.3x.html">menu_opts(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_pattern.3x.html ncurses-5.4/doc/html/man/menu_pattern.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_pattern.3x.html	2003-10-25 17:39:57.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_pattern.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_pattern.3x.html">menu_pattern(3x)</A></STRONG>                                 <STRONG><A HREF="menu_pattern.3x.html">menu_pattern(3x)</A></STRONG>
+<STRONG><A HREF="menu_pattern.3x.html">menu_pattern(3x)</A></STRONG>                                       <STRONG><A HREF="menu_pattern.3x.html">menu_pattern(3x)</A></STRONG>
 
 
 
@@ -116,7 +116,7 @@
 
 
 
-                                                 <STRONG><A HREF="menu_pattern.3x.html">menu_pattern(3x)</A></STRONG>
+                                                       <STRONG><A HREF="menu_pattern.3x.html">menu_pattern(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_post.3x.html ncurses-5.4/doc/html/man/menu_post.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_post.3x.html	2003-10-25 17:39:57.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_post.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_post.3x.html">menu_post(3x)</A></STRONG>                                       <STRONG><A HREF="menu_post.3x.html">menu_post(3x)</A></STRONG>
+<STRONG><A HREF="menu_post.3x.html">menu_post(3x)</A></STRONG>                                             <STRONG><A HREF="menu_post.3x.html">menu_post(3x)</A></STRONG>
 
 
 
@@ -127,7 +127,7 @@
 
 
 
-                                                    <STRONG><A HREF="menu_post.3x.html">menu_post(3x)</A></STRONG>
+                                                          <STRONG><A HREF="menu_post.3x.html">menu_post(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_requestname.3x.html ncurses-5.4/doc/html/man/menu_requestname.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_requestname.3x.html	2003-10-25 17:39:57.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_requestname.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_requestname.3x.html">menu_requestname(3x)</A></STRONG>                         <STRONG><A HREF="menu_requestname.3x.html">menu_requestname(3x)</A></STRONG>
+<STRONG><A HREF="menu_requestname.3x.html">menu_requestname(3x)</A></STRONG>                               <STRONG><A HREF="menu_requestname.3x.html">menu_requestname(3x)</A></STRONG>
 
 
 
@@ -62,8 +62,8 @@
 <H2>DESCRIPTION</H2><PRE>
        The  function <STRONG>menu_request_name</STRONG> returns the printable name
        of a menu request code.
-       The function <STRONG>menu_request_by_name</STRONG> searches  in  the  name-
-       table  for  a  request with the given name and returns its
+       The function <STRONG>menu_request_by_name</STRONG> searches in the name-ta-
+       ble  for  a  request  with  the given name and returns its
        request code. Otherwise E_NO_MATCH is returned.
 
 
@@ -100,7 +100,7 @@
 
 
 
-                                             <STRONG><A HREF="menu_requestname.3x.html">menu_requestname(3x)</A></STRONG>
+                                                   <STRONG><A HREF="menu_requestname.3x.html">menu_requestname(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_spacing.3x.html ncurses-5.4/doc/html/man/menu_spacing.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_spacing.3x.html	2003-10-25 17:39:57.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_spacing.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1998,2001 Free Software Foundation, Inc.                   *
+  * Copyright (c) 1998-2001,2004 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: menu_spacing.3x,v 1.6 2001/08/04 20:36:16 William.Setzer Exp @
+  * @Id: menu_spacing.3x,v 1.8 2004/12/11 23:39:07 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_spacing.3x.html">menu_spacing(3x)</A></STRONG>                                 <STRONG><A HREF="menu_spacing.3x.html">menu_spacing(3x)</A></STRONG>
+<STRONG><A HREF="menu_spacing.3x.html">menu_spacing(3x)</A></STRONG>                                       <STRONG><A HREF="menu_spacing.3x.html">menu_spacing(3x)</A></STRONG>
 
 
 
@@ -73,7 +73,7 @@
        the  middle  of  this  spacing area the pad character. The
        remaining parts are filled with spaces.  <STRONG>spc_rows</STRONG> controls
        the  number of rows that are used for an item. It must not
-       be larger than 3. The menu system inserts then blank lines
+       be larger than 3. The menu system inserts the blank  lines
        between  item rows, these lines will contain the pad char-
        acter in the appropriate positions.  <STRONG>spc_columns</STRONG>  controls
        the number of blanks between columns of items. It must not
@@ -118,7 +118,7 @@
 
 
 
-                                                 <STRONG><A HREF="menu_spacing.3x.html">menu_spacing(3x)</A></STRONG>
+                                                       <STRONG><A HREF="menu_spacing.3x.html">menu_spacing(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_userptr.3x.html ncurses-5.4/doc/html/man/menu_userptr.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_userptr.3x.html	2003-10-25 17:39:57.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_userptr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_userptr.3x.html">menu_userptr(3x)</A></STRONG>                                 <STRONG><A HREF="menu_userptr.3x.html">menu_userptr(3x)</A></STRONG>
+<STRONG><A HREF="menu_userptr.3x.html">menu_userptr(3x)</A></STRONG>                                       <STRONG><A HREF="menu_userptr.3x.html">menu_userptr(3x)</A></STRONG>
 
 
 
@@ -104,7 +104,7 @@
 
 
 
-                                                 <STRONG><A HREF="menu_userptr.3x.html">menu_userptr(3x)</A></STRONG>
+                                                       <STRONG><A HREF="menu_userptr.3x.html">menu_userptr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/menu_win.3x.html ncurses-5.4/doc/html/man/menu_win.3x.html
--- ncurses-5.4.orig/doc/html/man/menu_win.3x.html	2003-10-25 17:39:57.000000000 +0000
+++ ncurses-5.4/doc/html/man/menu_win.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="menu_win.3x.html">menu_win(3x)</A></STRONG>                                         <STRONG><A HREF="menu_win.3x.html">menu_win(3x)</A></STRONG>
+<STRONG><A HREF="menu_win.3x.html">menu_win(3x)</A></STRONG>                                               <STRONG><A HREF="menu_win.3x.html">menu_win(3x)</A></STRONG>
 
 
 
@@ -128,7 +128,7 @@
 
 
 
-                                                     <STRONG><A HREF="menu_win.3x.html">menu_win(3x)</A></STRONG>
+                                                           <STRONG><A HREF="menu_win.3x.html">menu_win(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/mitem_current.3x.html ncurses-5.4/doc/html/man/mitem_current.3x.html
--- ncurses-5.4.orig/doc/html/man/mitem_current.3x.html	2003-10-25 17:39:57.000000000 +0000
+++ ncurses-5.4/doc/html/man/mitem_current.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="mitem_current.3x.html">mitem_current(3x)</A></STRONG>                               <STRONG><A HREF="mitem_current.3x.html">mitem_current(3x)</A></STRONG>
+<STRONG><A HREF="mitem_current.3x.html">mitem_current(3x)</A></STRONG>                                     <STRONG><A HREF="mitem_current.3x.html">mitem_current(3x)</A></STRONG>
 
 
 
@@ -134,7 +134,7 @@
 
 
 
-                                                <STRONG><A HREF="mitem_current.3x.html">mitem_current(3x)</A></STRONG>
+                                                      <STRONG><A HREF="mitem_current.3x.html">mitem_current(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/mitem_name.3x.html ncurses-5.4/doc/html/man/mitem_name.3x.html
--- ncurses-5.4.orig/doc/html/man/mitem_name.3x.html	2003-10-25 17:39:57.000000000 +0000
+++ ncurses-5.4/doc/html/man/mitem_name.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="mitem_name.3x.html">mitem_name(3x)</A></STRONG>                                     <STRONG><A HREF="mitem_name.3x.html">mitem_name(3x)</A></STRONG>
+<STRONG><A HREF="mitem_name.3x.html">mitem_name(3x)</A></STRONG>                                           <STRONG><A HREF="mitem_name.3x.html">mitem_name(3x)</A></STRONG>
 
 
 
@@ -95,7 +95,7 @@
 
 
 
-                                                   <STRONG><A HREF="mitem_name.3x.html">mitem_name(3x)</A></STRONG>
+                                                         <STRONG><A HREF="mitem_name.3x.html">mitem_name(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/mitem_new.3x.html ncurses-5.4/doc/html/man/mitem_new.3x.html
--- ncurses-5.4.orig/doc/html/man/mitem_new.3x.html	2004-01-11 01:46:28.000000000 +0000
+++ ncurses-5.4/doc/html/man/mitem_new.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="mitem_new.3x.html">mitem_new(3x)</A></STRONG>                                       <STRONG><A HREF="mitem_new.3x.html">mitem_new(3x)</A></STRONG>
+<STRONG><A HREF="mitem_new.3x.html">mitem_new(3x)</A></STRONG>                                             <STRONG><A HREF="mitem_new.3x.html">mitem_new(3x)</A></STRONG>
 
 
 
@@ -115,7 +115,7 @@
 
 
 
-                                                    <STRONG><A HREF="mitem_new.3x.html">mitem_new(3x)</A></STRONG>
+                                                          <STRONG><A HREF="mitem_new.3x.html">mitem_new(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/mitem_opts.3x.html ncurses-5.4/doc/html/man/mitem_opts.3x.html
--- ncurses-5.4.orig/doc/html/man/mitem_opts.3x.html	2003-10-25 17:39:58.000000000 +0000
+++ ncurses-5.4/doc/html/man/mitem_opts.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="mitem_opts.3x.html">mitem_opts(3x)</A></STRONG>                                     <STRONG><A HREF="mitem_opts.3x.html">mitem_opts(3x)</A></STRONG>
+<STRONG><A HREF="mitem_opts.3x.html">mitem_opts(3x)</A></STRONG>                                           <STRONG><A HREF="mitem_opts.3x.html">mitem_opts(3x)</A></STRONG>
 
 
 
@@ -115,7 +115,7 @@
 
 
 
-                                                   <STRONG><A HREF="mitem_opts.3x.html">mitem_opts(3x)</A></STRONG>
+                                                         <STRONG><A HREF="mitem_opts.3x.html">mitem_opts(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/mitem_userptr.3x.html ncurses-5.4/doc/html/man/mitem_userptr.3x.html
--- ncurses-5.4.orig/doc/html/man/mitem_userptr.3x.html	2003-10-25 17:39:58.000000000 +0000
+++ ncurses-5.4/doc/html/man/mitem_userptr.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="mitem_userptr.3x.html">mitem_userptr(3x)</A></STRONG>                               <STRONG><A HREF="mitem_userptr.3x.html">mitem_userptr(3x)</A></STRONG>
+<STRONG><A HREF="mitem_userptr.3x.html">mitem_userptr(3x)</A></STRONG>                                     <STRONG><A HREF="mitem_userptr.3x.html">mitem_userptr(3x)</A></STRONG>
 
 
 
@@ -104,7 +104,7 @@
 
 
 
-                                                <STRONG><A HREF="mitem_userptr.3x.html">mitem_userptr(3x)</A></STRONG>
+                                                      <STRONG><A HREF="mitem_userptr.3x.html">mitem_userptr(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/mitem_value.3x.html ncurses-5.4/doc/html/man/mitem_value.3x.html
--- ncurses-5.4.orig/doc/html/man/mitem_value.3x.html	2003-10-25 17:39:58.000000000 +0000
+++ ncurses-5.4/doc/html/man/mitem_value.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="mitem_value.3x.html">mitem_value(3x)</A></STRONG>                                   <STRONG><A HREF="mitem_value.3x.html">mitem_value(3x)</A></STRONG>
+<STRONG><A HREF="mitem_value.3x.html">mitem_value(3x)</A></STRONG>                                         <STRONG><A HREF="mitem_value.3x.html">mitem_value(3x)</A></STRONG>
 
 
 
@@ -106,7 +106,7 @@
 
 
 
-                                                  <STRONG><A HREF="mitem_value.3x.html">mitem_value(3x)</A></STRONG>
+                                                        <STRONG><A HREF="mitem_value.3x.html">mitem_value(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/mitem_visible.3x.html ncurses-5.4/doc/html/man/mitem_visible.3x.html
--- ncurses-5.4.orig/doc/html/man/mitem_visible.3x.html	2003-10-25 17:39:58.000000000 +0000
+++ ncurses-5.4/doc/html/man/mitem_visible.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="mitem_visible.3x.html">mitem_visible(3x)</A></STRONG>                               <STRONG><A HREF="mitem_visible.3x.html">mitem_visible(3x)</A></STRONG>
+<STRONG><A HREF="mitem_visible.3x.html">mitem_visible(3x)</A></STRONG>                                     <STRONG><A HREF="mitem_visible.3x.html">mitem_visible(3x)</A></STRONG>
 
 
 
@@ -89,7 +89,7 @@
 
 
 
-                                                <STRONG><A HREF="mitem_visible.3x.html">mitem_visible(3x)</A></STRONG>
+                                                      <STRONG><A HREF="mitem_visible.3x.html">mitem_visible(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/ncurses.3x.html ncurses-5.4/doc/html/man/ncurses.3x.html
--- ncurses-5.4.orig/doc/html/man/ncurses.3x.html	2004-01-11 01:46:29.000000000 +0000
+++ ncurses-5.4/doc/html/man/ncurses.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2004,2005 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: ncurses.3x,v 1.70 2004/01/11 01:45:54 tom Exp @
+  * @Id: ncurses.3x,v 1.74 2005/03/12 19:45:57 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>                                           <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>
+<STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>                                                 <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>
 
 
 
@@ -227,6 +227,7 @@
        flagged with `*' are ncurses-specific,  not  described  by
        XPG4 or present in SVr4.
 
+
               <STRONG>curses</STRONG> Routine Name     Manual Page Name
               --------------------------------------------
               COLOR_PAIR              <STRONG><A HREF="curs_color.3x.html">curs_color(3x)</A></STRONG>
@@ -243,8 +244,8 @@
               add_wch                 <STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>
               add_wchnstr             <STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>
               add_wchstr              <STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>
-              addch                   <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>
 
+              addch                   <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>
               addchnstr               <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>
               addchstr                <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>
               addnstr                 <STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>
@@ -309,8 +310,8 @@
               getbkgd                 <STRONG><A HREF="curs_bkgd.3x.html">curs_bkgd(3x)</A></STRONG>
               getbkgrnd               <STRONG><A HREF="curs_bkgrnd.3x.html">curs_bkgrnd(3x)</A></STRONG>
               getcchar                <STRONG><A HREF="curs_getcchar.3x.html">curs_getcchar(3x)</A></STRONG>
-              getch                   <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>
 
+              getch                   <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG>
               getmaxyx                <STRONG><A HREF="curs_getyx.3x.html">curs_getyx(3x)</A></STRONG>
               getmouse                <STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG>*
               getn_wstr               <STRONG><A HREF="curs_get_wstr.3x.html">curs_get_wstr(3x)</A></STRONG>
@@ -375,8 +376,8 @@
               mvadd_wchnstr           <STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>
               mvadd_wchstr            <STRONG><A HREF="curs_add_wchstr.3x.html">curs_add_wchstr(3x)</A></STRONG>
               mvaddch                 <STRONG><A HREF="curs_addch.3x.html">curs_addch(3x)</A></STRONG>
-              mvaddchnstr             <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>
 
+              mvaddchnstr             <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>
               mvaddchstr              <STRONG><A HREF="curs_addchstr.3x.html">curs_addchstr(3x)</A></STRONG>
               mvaddnstr               <STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>
               mvaddnwstr              <STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>
@@ -441,8 +442,8 @@
               mvwinch                 <STRONG><A HREF="curs_inch.3x.html">curs_inch(3x)</A></STRONG>
               mvwinchnstr             <STRONG><A HREF="curs_inchstr.3x.html">curs_inchstr(3x)</A></STRONG>
               mvwinchstr              <STRONG><A HREF="curs_inchstr.3x.html">curs_inchstr(3x)</A></STRONG>
-              mvwinnstr               <STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>
 
+              mvwinnstr               <STRONG><A HREF="curs_instr.3x.html">curs_instr(3x)</A></STRONG>
               mvwinnwstr              <STRONG><A HREF="curs_inwstr.3x.html">curs_inwstr(3x)</A></STRONG>
               mvwins_nwstr            <STRONG><A HREF="curs_ins_wstr.3x.html">curs_ins_wstr(3x)</A></STRONG>
               mvwins_wch              <STRONG><A HREF="curs_ins_wch.3x.html">curs_ins_wch(3x)</A></STRONG>
@@ -507,8 +508,8 @@
               slk_attr_off            <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
               slk_attr_on             <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
               slk_attr_set            <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
-              slk_attroff             <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
 
+              slk_attroff             <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
               slk_attron              <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
               slk_attrset             <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
               slk_clear               <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>
@@ -573,8 +574,8 @@
               waddnwstr               <STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>
               waddstr                 <STRONG><A HREF="curs_addstr.3x.html">curs_addstr(3x)</A></STRONG>
               waddwstr                <STRONG><A HREF="curs_addwstr.3x.html">curs_addwstr(3x)</A></STRONG>
-              wattr_get               <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
 
+              wattr_get               <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
               wattr_off               <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
               wattr_on                <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
               wattr_set               <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
@@ -639,8 +640,8 @@
               wstandend               <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
               wstandout               <STRONG><A HREF="curs_attr.3x.html">curs_attr(3x)</A></STRONG>
               wsyncdown               <STRONG><A HREF="curs_window.3x.html">curs_window(3x)</A></STRONG>
-              wsyncup                 <STRONG><A HREF="curs_window.3x.html">curs_window(3x)</A></STRONG>
 
+              wsyncup                 <STRONG><A HREF="curs_window.3x.html">curs_window(3x)</A></STRONG>
               wtimeout                <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>
               wtouchln                <STRONG><A HREF="curs_touch.3x.html">curs_touch(3x)</A></STRONG>
               wunctrl                 <STRONG><A HREF="curs_util.3x.html">curs_util(3x)</A></STRONG>
@@ -730,6 +731,14 @@
             timeout applies to the composed multi-click event  as
             well as the individual clicks.
 
+            In  addition to the environment variable, this imple-
+            mentation provides a global variable  with  the  same
+            name.  Portable applications should not rely upon the
+            presence of ESCDELAY in either form, but setting  the
+            environment  variable rather than the global variable
+            does not create problems when compiling  an  applica-
+            tion.
+
        HOME Tells  <STRONG>ncurses</STRONG> where your home directory is.  That is
             where  it  may  read  and  write  auxiliary  terminal
             descriptions:
@@ -771,19 +780,19 @@
             Most  of  the  terminal  descriptions in the terminfo
             database are written for real  "hardware"  terminals.
             Many  people  use  terminal  emulators which run in a
-            windowing environment and use  curses-based  applica-
-            tions.   Terminal  emulators can duplicate all of the
-            important aspects of a hardware terminal, but they do
-            not  have the same limitations.  The chief limitation
-            of a hardware terminal from the  standpoint  of  your
-            application  is  the  management  of  dataflow, i.e.,
-            timing.  Unless a  hardware  terminal  is  interfaced
-            into  a  terminal  concentrator (which does flow con-
-            trol), it (or your application) must manage dataflow,
-            preventing overruns.  The cheapest solution (no hard-
-            ware cost) is for your program to do this by  pausing
-            after  operations that the terminal does slowly, such
-            as clearing the display.
+            windowing   environment    and    use    curses-based
+            applications.   Terminal  emulators can duplicate all
+            of the important aspects of a hardware terminal,  but
+            they  do  not  have  the same limitations.  The chief
+            limitation of a hardware terminal from the standpoint
+            of  your  application  is the management of dataflow,
+            i.e., timing.  Unless a hardware terminal  is  inter-
+            faced  into  a terminal concentrator (which does flow
+            control),  it  (or  your  application)  must   manage
+            dataflow, preventing overruns.  The cheapest solution
+            (no hardware cost) is for your program to do this  by
+            pausing  after  operations  that  the  terminal  does
+            slowly, such as clearing the display.
 
             As a result, many  terminal  descriptions  (including
             the  vt100)  have delay times embedded.  You may wish
@@ -804,37 +813,56 @@
             leaving  the  output  in  the  original (usually line
             buffered) mode.
 
+       NCURSES_NO_UTF8_ACS
+            During initialization, the <STRONG>ncurses</STRONG> library checks for
+            special  cases where VT100 line-drawing (and the cor-
+            responding  alternate  character  set   capabilities)
+            described  in  the  terminfo are known to be missing.
+            Specifically, when running in  a  UTF-8  locale,  the
+            Linux  console  emulator  and  the GNU screen program
+            ignore these.  Ncurses checks  the  TERM  environment
+            variable  for  these.   For  other special cases, you
+            should set this  environment  variable.   Doing  this
+            tells  ncurses to use Unicode values which correspond
+            to the VT100 line-drawing glyphs.  That works for the
+            special cases cited, and is likely to work for termi-
+            nal emulators.
+
+            When setting this variable, you should set  it  to  a
+            nonzero  value.   Setting it to zero (or to a nonnum-
+            ber) disables the special check for Linux and screen.
+
        NCURSES_TRACE
-            During initialization, the <STRONG>ncurses</STRONG> debugging  library
-            checks  the  NCURSES_TRACE symbol.  If it is defined,
+            During  initialization, the <STRONG>ncurses</STRONG> debugging library
+            checks the NCURSES_TRACE symbol.  If it  is  defined,
             to a numeric value, <STRONG>ncurses</STRONG> calls the <STRONG>trace</STRONG> function,
             using that value as the argument.
 
-            The  argument  values, which are defined in <STRONG>curses.h</STRONG>,
-            provide several types of information.   When  running
-            with  traces enabled, your application will write the
+            The argument values, which are defined  in  <STRONG>curses.h</STRONG>,
+            provide  several  types of information.  When running
+            with traces enabled, your application will write  the
             file <STRONG>trace</STRONG> to the current directory.
 
-       TERM Denotes your terminal type.  Each  terminal  type  is
+       TERM Denotes  your  terminal  type.  Each terminal type is
             distinct, though many are similar.
 
        TERMCAP
             If the <STRONG>ncurses</STRONG> library has been configured with <EM>term-</EM>
-            <EM>cap</EM> support, <STRONG>ncurses</STRONG>  will  check  for  a  terminal's
+            <EM>cap</EM>  support,  <STRONG>ncurses</STRONG>  will  check  for a terminal's
             description in termcap form if it is not available in
             the terminfo database.
 
-            The  TERMCAP  symbol  contains  either   a   terminal
-            description  (with  newlines stripped out), or a file
-            name telling where the  information  denoted  by  the
-            TERM  symbol  exists.   In  either  case,  setting it
-            directs <STRONG>ncurses</STRONG> to ignore the usual  place  for  this
+            The   TERMCAP   symbol  contains  either  a  terminal
+            description (with newlines stripped out), or  a  file
+            name  telling  where  the  information denoted by the
+            TERM symbol  exists.   In  either  case,  setting  it
+            directs  <STRONG>ncurses</STRONG>  to  ignore the usual place for this
             information, e.g., /etc/termcap.
 
        TERMINFO
             Overrides the directory in which <STRONG>ncurses</STRONG> searches for
             your terminal description.  This is the simplest, but
-            not  the  only way to change the list of directories.
+            not the only way to change the list  of  directories.
             The complete list of directories in order follows:
 
             -  the last directory to which <STRONG>ncurses</STRONG> wrote, if any,
@@ -851,39 +879,39 @@
                /usr/share/terminfo
 
        TERMINFO_DIRS
-            Specifies  a list of directories to search for termi-
-            nal descriptions.  The list is  separated  by  colons
-            (i.e.,  ":") on Unix, semicolons on OS/2 EMX.  All of
+            Specifies a list of directories to search for  termi-
+            nal  descriptions.   The  list is separated by colons
+            (i.e., ":") on Unix, semicolons on OS/2 EMX.  All  of
             the terminal descriptions are in terminfo form, which
-            makes  a  subdirectory  named for the first letter of
+            makes a subdirectory named for the  first  letter  of
             the terminal names therein.
 
        TERMPATH
-            If TERMCAP does not hold a  file  name  then  <STRONG>ncurses</STRONG>
-            checks  the TERMPATH symbol.  This is a list of file-
-            names separated by spaces or colons  (i.e.,  ":")  on
+            If  TERMCAP  does  not  hold a file name then <STRONG>ncurses</STRONG>
+            checks the TERMPATH symbol.  This is a list of  file-
+            names  separated  by  spaces or colons (i.e., ":") on
             Unix, semicolons on OS/2 EMX.  If the TERMPATH symbol
-            is not set, <STRONG>ncurses</STRONG> looks in the files  /etc/termcap,
-            /usr/share/misc/termcap  and  $HOME/.termcap, in that
+            is  not set, <STRONG>ncurses</STRONG> looks in the files /etc/termcap,
+            /usr/share/misc/termcap and $HOME/.termcap,  in  that
             order.
 
-       The library may be configured to disregard  the  following
-       variables  when  the current user is the superuser (root),
-       or if the application uses setuid or  setgid  permissions:
+       The  library  may be configured to disregard the following
+       variables when the current user is the  superuser  (root),
+       or  if  the application uses setuid or setgid permissions:
        $TERMINFO, $TERMINFO_DIRS, $TERMPATH, as well as $HOME.
 
 
 </PRE>
 <H2>FILES</H2><PRE>
        /usr/share/tabset
-            directory  containing  initialization  files  for the
+            directory containing  initialization  files  for  the
             terminal capability database /usr/share/terminfo ter-
             minal capability database
 
 
 </PRE>
 <H2>SEE ALSO</H2><PRE>
-       <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>  and  related  pages whose names begin "curs_"
+       <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG> and related pages whose  names  begin  "curs_"
        for detailed routine descriptions.
 
 
@@ -892,100 +920,100 @@
        The  <STRONG>ncurses</STRONG>  library  can  be  compiled  with  an  option
        (<STRONG>-DUSE_GETCAP</STRONG>) that falls back to the old-style /etc/term-
        cap file if the terminal setup code cannot find a terminfo
-       entry  corresponding  to <STRONG>TERM</STRONG>.  Use of this feature is not
-       recommended, as it essentially includes an entire  termcap
-       compiler  in the <STRONG>ncurses</STRONG> startup code, at significant cost
+       entry corresponding to <STRONG>TERM</STRONG>.  Use of this feature  is  not
+       recommended,  as it essentially includes an entire termcap
+       compiler in the <STRONG>ncurses</STRONG> startup code, at significant  cost
        in core and startup cycles.
 
-       The <STRONG>ncurses</STRONG>  library  includes  facilities  for  capturing
-       mouse  events  on certain terminals (including xterm). See
+       The  <STRONG>ncurses</STRONG>  library  includes  facilities  for capturing
+       mouse events on certain terminals (including  xterm).  See
        the <STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG> manual page for details.
 
-       The <STRONG>ncurses</STRONG> library includes facilities for responding  to
-       window  resizing  events,  e.g., when running in an xterm.
-       See the <STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG> and <STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG>  manual  pages  for
-       details.   In addition, the library may be configured with
+       The  <STRONG>ncurses</STRONG> library includes facilities for responding to
+       window resizing events, e.g., when running  in  an  xterm.
+       See  the  <STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG>  and <STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG> manual pages for
+       details.  In addition, the library may be configured  with
        a SIGWINCH handler.
 
-       The <STRONG>ncurses</STRONG> library extends the fixed set of function  key
-       capabilities  of  terminals  by  allowing  the application
-       designer to define additional key  sequences  at  runtime.
+       The  <STRONG>ncurses</STRONG> library extends the fixed set of function key
+       capabilities of  terminals  by  allowing  the  application
+       designer  to  define  additional key sequences at runtime.
        See the <STRONG><A HREF="define_key.3x.html">define_key(3x)</A></STRONG> <STRONG><A HREF="key_defined.3x.html">key_defined(3x)</A></STRONG>, and <STRONG><A HREF="keyok.3x.html">keyok(3x)</A></STRONG> man-
        ual pages for details.
 
        The <STRONG>ncurses</STRONG> library can exploit the capabilities of termi-
-       nals  which  implement  the  ISO-6429  SGR  39  and SGR 49
-       controls, which allow an application to reset the terminal
-       to  its  original  foreground and background colors.  From
-       the users' perspective, the application is  able  to  draw
-       colored  text  on a background whose color is set indepen-
-       dently, providing better  control  over  color  contrasts.
+       nals which implement the ISO-6429 SGR 39 and SGR  49  con-
+       trols, which allow an application to reset the terminal to
+       its original foreground and background colors.   From  the
+       users'  perspective,  the application is able to draw col-
+       ored text on a background  whose  color  is  set  indepen-
+       dently,  providing  better  control  over color contrasts.
        See the <STRONG><A HREF="default_colors.3x.html">default_colors(3x)</A></STRONG> manual page for details.
 
-       The  <STRONG>ncurses</STRONG>  library  includes  a  function for directing
-       application output to a printer attached to  the  terminal
+       The <STRONG>ncurses</STRONG> library  includes  a  function  for  directing
+       application  output  to a printer attached to the terminal
        device.  See the <STRONG><A HREF="curs_print.3x.html">curs_print(3x)</A></STRONG> manual page for details.
 
 
 </PRE>
 <H2>PORTABILITY</H2><PRE>
-       The  <STRONG>ncurses</STRONG>  library is intended to be BASE-level confor-
-       mant with the  XSI  Curses  standard.   The  EXTENDED  XSI
-       Curses  functionality  (including  color  support) is sup-
+       The <STRONG>ncurses</STRONG> library is intended to be  BASE-level  confor-
+       mant  with  the  XSI  Curses  standard.   The EXTENDED XSI
+       Curses functionality (including  color  support)  is  sup-
        ported.
 
-       A small number of local differences (that  is,  individual
-       differences  between the XSI Curses and <STRONG>ncurses</STRONG> calls) are
-       described in  <STRONG>PORTABILITY</STRONG>  sections  of  the  library  man
+       A  small  number of local differences (that is, individual
+       differences between the XSI Curses and <STRONG>ncurses</STRONG> calls)  are
+       described  in  <STRONG>PORTABILITY</STRONG>  sections  of  the  library man
        pages.
 
        The routine <STRONG>has_key</STRONG> is not part of XPG4, nor is it present
-       in SVr4.  See the <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG> manual page for  details.
+       in  SVr4.  See the <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG> manual page for details.
 
-       The  routine  <STRONG>slk_attr</STRONG> is not part of XPG4, nor is it pre-
-       sent in  SVr4.   See  the  <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG>  manual  page  for
+       The routine <STRONG>slk_attr</STRONG> is  not  part  of  XPG4,  nor  is  it
+       present  in  SVr4.   See  the <STRONG><A HREF="curs_slk.3x.html">curs_slk(3x)</A></STRONG> manual page for
        details.
 
-       The  routines <STRONG>getmouse</STRONG>, <STRONG>mousemask</STRONG>, <STRONG>ungetmouse</STRONG>, <STRONG>mouseinter-</STRONG>
-       <STRONG>val</STRONG>, and <STRONG>wenclose</STRONG> relating to mouse  interfacing  are  not
-       part  of  XPG4,  nor  are  they  present in SVr4.  See the
+       The routines <STRONG>getmouse</STRONG>, <STRONG>mousemask</STRONG>, <STRONG>ungetmouse</STRONG>,  <STRONG>mouseinter-</STRONG>
+       <STRONG>val</STRONG>,  and  <STRONG>wenclose</STRONG>  relating to mouse interfacing are not
+       part of XPG4, nor are  they  present  in  SVr4.   See  the
        <STRONG><A HREF="curs_mouse.3x.html">curs_mouse(3x)</A></STRONG> manual page for details.
 
        The routine <STRONG>mcprint</STRONG> was not present in any previous curses
-       implementation.   See  the  <STRONG><A HREF="curs_print.3x.html">curs_print(3x)</A></STRONG> manual page for
+       implementation.  See the <STRONG><A HREF="curs_print.3x.html">curs_print(3x)</A></STRONG>  manual  page  for
        details.
 
        The routine <STRONG>wresize</STRONG> is not part of XPG4, nor is it present
        in SVr4.  See the <STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG> manual page for details.
 
-       In  historic curses versions, delays embedded in the capa-
+       In historic curses versions, delays embedded in the  capa-
        bilities <STRONG>cr</STRONG>, <STRONG>ind</STRONG>, <STRONG>cub1</STRONG>, <STRONG>ff</STRONG> and <STRONG>tab</STRONG> activated corresponding
-       delay  bits  in  the UNIX tty driver.  In this implementa-
-       tion, all padding is done by NUL sends.   This  method  is
-       slightly  more expensive, but narrows the interface to the
-       UNIX kernel  significantly  and  increases  the  package's
+       delay bits in the UNIX tty driver.   In  this  implementa-
+       tion,  all  padding  is done by NUL sends.  This method is
+       slightly more expensive, but narrows the interface to  the
+       UNIX  kernel  significantly  and  increases  the package's
        portability correspondingly.
 
 
 </PRE>
 <H2>NOTES</H2><PRE>
-       The  header  file  <STRONG>&lt;curses.h&gt;</STRONG>  automatically  includes the
+       The header  file  <STRONG>&lt;curses.h&gt;</STRONG>  automatically  includes  the
        header files <STRONG>&lt;stdio.h&gt;</STRONG> and <STRONG>&lt;unctrl.h&gt;</STRONG>.
 
-       If standard output from a <STRONG>ncurses</STRONG> program  is  re-directed
-       to  something  which  is not a tty, screen updates will be
+       If  standard  output from a <STRONG>ncurses</STRONG> program is re-directed
+       to something which is not a tty, screen  updates  will  be
        directed to standard error.  This was an undocumented fea-
        ture of AT&amp;T System V Release 3 curses.
 
 
 </PRE>
 <H2>AUTHORS</H2><PRE>
-       Zeyd  M.  Ben-Halim,  Eric  S.  Raymond, Thomas E. Dickey.
+       Zeyd M. Ben-Halim, Eric  S.  Raymond,  Thomas  E.  Dickey.
        Based on pcurses by Pavel Curtis.
 
 
 
-                                                      <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>
+                                                            <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/panel.3x.html ncurses-5.4/doc/html/man/panel.3x.html
--- ncurses-5.4.orig/doc/html/man/panel.3x.html	2003-10-25 17:39:59.000000000 +0000
+++ ncurses-5.4/doc/html/man/panel.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="panel.3x.html">panel(3x)</A></STRONG>                                               <STRONG><A HREF="panel.3x.html">panel(3x)</A></STRONG>
+<STRONG><A HREF="panel.3x.html">panel(3x)</A></STRONG>                                                     <STRONG><A HREF="panel.3x.html">panel(3x)</A></STRONG>
 
 
 
@@ -223,7 +223,7 @@
 
 
 
-                                                        <STRONG><A HREF="panel.3x.html">panel(3x)</A></STRONG>
+                                                              <STRONG><A HREF="panel.3x.html">panel(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/resizeterm.3x.html ncurses-5.4/doc/html/man/resizeterm.3x.html
--- ncurses-5.4.orig/doc/html/man/resizeterm.3x.html	2004-01-11 01:46:29.000000000 +0000
+++ ncurses-5.4/doc/html/man/resizeterm.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG>                                     <STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG>
+<STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG>                                           <STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG>
 
 
 
@@ -123,7 +123,7 @@
 
 
 
-                                                   <STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG>
+                                                         <STRONG><A HREF="resizeterm.3x.html">resizeterm(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/term.5.html ncurses-5.4/doc/html/man/term.5.html
--- ncurses-5.4.orig/doc/html/man/term.5.html	2003-10-25 17:39:59.000000000 +0000
+++ ncurses-5.4/doc/html/man/term.5.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2004 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: term.5,v 1.15 2003/05/10 20:33:49 jmc Exp @
+  * @Id: term.5,v 1.16 2004/07/05 13:16:08 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="TERM.5.html">TERM(5)</A></STRONG>                                                   <STRONG><A HREF="TERM.5.html">TERM(5)</A></STRONG>
+<STRONG><A HREF="TERM.5.html">TERM(5)</A></STRONG>                                                         <STRONG><A HREF="TERM.5.html">TERM(5)</A></STRONG>
 
 
 
@@ -208,7 +208,7 @@
 
 
 
-                                                          <STRONG><A HREF="TERM.5.html">TERM(5)</A></STRONG>
+                                                                <STRONG><A HREF="TERM.5.html">TERM(5)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/term.7.html ncurses-5.4/doc/html/man/term.7.html
--- ncurses-5.4.orig/doc/html/man/term.7.html	2003-10-25 17:39:59.000000000 +0000
+++ ncurses-5.4/doc/html/man/term.7.html	2005-05-13 04:09:59.000000000 +0000
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="TERM.7.html">TERM(7)</A></STRONG>                                                   <STRONG><A HREF="TERM.7.html">TERM(7)</A></STRONG>
+<STRONG><A HREF="TERM.7.html">TERM(7)</A></STRONG>                                                         <STRONG><A HREF="TERM.7.html">TERM(7)</A></STRONG>
 
 
 
@@ -240,7 +240,7 @@
 
 
 
-                                                          <STRONG><A HREF="TERM.7.html">TERM(7)</A></STRONG>
+                                                                <STRONG><A HREF="TERM.7.html">TERM(7)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/terminfo.5.html ncurses-5.4/doc/html/man/terminfo.5.html
--- ncurses-5.4.orig/doc/html/man/terminfo.5.html	2003-10-25 17:40:00.000000000 +0000
+++ ncurses-5.4/doc/html/man/terminfo.5.html	2005-05-13 04:09:59.000000000 +0000
@@ -6,7 +6,7 @@
   * Note: this must be run through tbl before nroff.
   * The magic cookie on the first line triggers this under some man programs.
   ****************************************************************************
-  * Copyright (c) 1998-2000,2002 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2002,2004 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,10 +32,15 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: terminfo.head,v 1.10 2002/08/17 23:37:10 tom Exp @
+  * @Id: terminfo.head,v 1.12 2004/09/25 19:07:11 tom Exp @
   * Head of terminfo man page ends here
-  * @Id: terminfo.tail,v 1.38 2003/01/05 22:47:05 tom Exp @
+  * @Id: terminfo.tail,v 1.41 2004/07/05 13:08:56 tom Exp @
   * Beginning of terminfo.tail file
+  * See "terminfo.head" for copyright.
+  *.in -2
+  *.in +2
+  *.in -2
+  *.in +2
   *.TH
 -->
 <HTML>
@@ -49,7 +54,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="TERMINFO.5.html">TERMINFO(5)</A></STRONG>                File Formats               <STRONG><A HREF="TERMINFO.5.html">TERMINFO(5)</A></STRONG>
+<STRONG><A HREF="TERMINFO.5.html">TERMINFO(5)</A></STRONG>                   File Formats                  <STRONG><A HREF="TERMINFO.5.html">TERMINFO(5)</A></STRONG>
 
 
 
@@ -86,6 +91,16 @@
        no blanks; the last name may well contain upper  case  and
        blanks for readability.
 
+       Lines beginning with a `#' in the first column are treated
+       as comments.  While comment lines are legal at any  point,
+       the  output  of  <EM>captoinfo</EM> and <EM>infotocap</EM> (aliases for <EM>tic</EM>)
+       will move comments so they occur only between entries.
+
+       Newlines and leading  tabs  may  be  used  for  formatting
+       entries  for  readability.   These are removed from parsed
+       entries.  The <EM>infocmp</EM> <EM>-f</EM> option relies on this  to  format
+       if-then-else expressions: the result can be read by <EM>tic</EM>.
+
        Terminal names (except for the last, verbose entry) should
        be chosen using the following conventions.  The particular
        piece  of  hardware  making  up the terminal should have a
@@ -96,6 +111,7 @@
        vt100-w.  The following suffixes should be used where pos-
        sible:
 
+
       <STRONG>Suffix</STRONG>                  <STRONG>Meaning</STRONG>                   <STRONG>Example</STRONG>
       -<EM>nn</EM>      Number of lines on the screen            aaa-60
       -<EM>n</EM>p      Number of pages of memory                c100-4p
@@ -109,6 +125,7 @@
       -rv      Reverse video                            c100-rv
       -s       Enable status line                       vt100-s
       -vb      Use visible bell instead of beep         wy370-vb
+
       -w       Wide mode (&gt; 80 columns, usually 132)    vt100-w
 
        For  more  on terminal naming conventions, see the <STRONG>term(7)</STRONG>
@@ -156,6 +173,7 @@
 
        These are the boolean capabilities:
 
+
                <STRONG>Variable</STRONG>          <STRONG>Cap-</STRONG>  <STRONG>TCap</STRONG>      <STRONG>Description</STRONG>
                <STRONG>Booleans</STRONG>          <STRONG>name</STRONG>  <STRONG>Code</STRONG>
        auto_left_margin          bw    bw    cub1 wraps from col-
@@ -171,6 +189,9 @@
                                              by overwriting (hp)
        col_addr_glitch           xhpa  YA    only positive motion
                                              for hpa/mhpa caps
+
+
+
        cpi_changes_res           cpix  YF    changing character
                                              pitch changes reso-
                                              lution
@@ -186,7 +207,6 @@
                                              strikes with a blank
        generic_type              gn    gn    generic line type
        hard_copy                 hc    hc    hardcopy terminal
-
        hard_cursor               chts  HC    cursor is hard to
                                              see
        has_meta_key              km    km    Has a meta key
@@ -236,6 +256,8 @@
                                              on the status line
        tilde_glitch              hz    hz    cannot print ~'s
                                              (hazeltine)
+
+
        transparent_underline     ul    ul    underline character
                                              overstrikes
        xon_xoff                  xon   xo    terminal uses
@@ -243,6 +265,7 @@
 
        These are the numeric capabilities:
 
+
             <STRONG>Variable</STRONG>         <STRONG>Cap-</STRONG>     <STRONG>TCap</STRONG>       <STRONG>Description</STRONG>
              <STRONG>Numeric</STRONG>         <STRONG>name</STRONG>     <STRONG>Code</STRONG>
        columns               cols     co     number of columns in
@@ -252,7 +275,6 @@
        label_height          lh       lh     rows in each label
        label_width           lw       lw     columns in each
                                              label
-
        lines                 lines    li     number of lines on
                                              screen or page
        lines_of_memory       lm       lm     lines of memory if &gt;
@@ -286,6 +308,7 @@
        SVr4.0 term structure, but are not yet documented  in  the
        man page.  They came in with SVr4's printer support.
 
+
              <STRONG>Variable</STRONG>         <STRONG>Cap-</STRONG>    <STRONG>TCap</STRONG>       <STRONG>Description</STRONG>
              <STRONG>Numeric</STRONG>          <STRONG>name</STRONG>    <STRONG>Code</STRONG>
        bit_image_entwining    bitwin  Yo     number of passes for
@@ -300,6 +323,7 @@
        dot_horz_spacing       spinh   Yc     spacing of dots hor-
                                              izontally in dots
                                              per inch
+
        dot_vert_spacing       spinv   Yb     spacing of pins ver-
                                              tically in pins per
                                              inch
@@ -316,9 +340,6 @@
        output_res_char        orc     Yi     horizontal resolu-
                                              tion in units per
                                              line
-
-
-
        output_res_horz_inch   orhi    Yk     horizontal resolu-
                                              tion in units per
                                              inch
@@ -334,6 +355,7 @@
 
        These are the string capabilities:
 
+
                <STRONG>Variable</STRONG>          <STRONG>Cap-</STRONG>   <STRONG>TCap</STRONG>     <STRONG>Description</STRONG>
                 <STRONG>String</STRONG>           <STRONG>name</STRONG>   <STRONG>Code</STRONG>
        acs_chars                 acsc   ac   graphics charset
@@ -366,6 +388,8 @@
                                              home cursor (P*)
        clr_bol                   el1    cb   Clear to beginning
                                              of line
+
+
        clr_eol                   el     ce   clear to end of line
                                              (P)
        clr_eos                   ed     cd   clear to end of
@@ -384,7 +408,6 @@
                                              cup)
        cursor_invisible          civis  vi   make cursor invisi-
                                              ble
-
        cursor_left               cub1   le   move left one space
        cursor_mem_address        mrcup  CM   memory relative cur-
                                              sor addressing, move
@@ -432,6 +455,7 @@
        enter_italics_mode        sitm   ZH   Enter italic mode
        enter_leftward_mode       slm    ZI   Start leftward car-
                                              riage motion
+
        enter_micro_mode          smicm  ZJ   Start micro-motion
                                              mode
        enter_near_letter_quality snlq   ZK   Enter NLQ mode
@@ -450,7 +474,6 @@
        enter_subscript_mode      ssubm  ZN   Enter subscript mode
        enter_superscript_mode    ssupm  ZO   Enter superscript
                                              mode
-
        enter_underline_mode      smul   us   begin underline mode
        enter_upward_mode         sum    ZP   Start upward car-
                                              riage motion
@@ -498,6 +521,7 @@
                                              string
        init_2string              is2    is   initialization
                                              string
+
        init_3string              is3    i3   initialization
                                              string
        init_file                 if     if   name of initializa-
@@ -515,8 +539,6 @@
        insert_padding            ip     ip   insert padding after
                                              inserted character
        key_a1                    ka1    K1   upper left of keypad
-
-
        key_a3                    ka3    K3   upper right of key-
                                              pad
        key_b2                    kb2    K2   center of keypad
@@ -565,6 +587,7 @@
        key_f22                   kf22   FC   F22 function key
        key_f23                   kf23   FD   F23 function key
        key_f24                   kf24   FE   F24 function key
+
        key_f25                   kf25   FF   F25 function key
        key_f26                   kf26   FG   F26 function key
        key_f27                   kf27   FH   F27 function key
@@ -582,7 +605,6 @@
        key_f38                   kf38   FS   F38 function key
        key_f39                   kf39   FT   F39 function key
        key_f4                    kf4    k4   F4 function key
-
        key_f40                   kf40   FU   F40 function key
        key_f41                   kf41   FV   F41 function key
        key_f42                   kf42   FW   F42 function key
@@ -631,6 +653,7 @@
        key_previous              kprv   %8   previous key
        key_print                 kprt   %9   print key
        key_redo                  krdo   %0   redo key
+
        key_reference             kref   &amp;1   reference key
        key_refresh               krfr   &amp;2   refresh key
        key_replace               krpl   &amp;3   replace key
@@ -648,7 +671,6 @@
        key_sdl                   kDL    *5   shifted delete-line
                                              key
        key_select                kslt   *6   select key
-
        key_send                  kEND   *7   shifted end key
        key_seol                  kEOL   *8   shifted clear-to-
                                              end-of-line key
@@ -696,6 +718,8 @@
                                              key f3 if not f3
        lab_f4                    lf4    l4   label on function
                                              key f4 if not f4
+
+
        lab_f5                    lf5    l5   label on function
                                              key f5 if not f5
        lab_f6                    lf6    l6   label on function
@@ -714,7 +738,6 @@
                                              (8th-bit on)
        micro_column_address      mhpa   ZY   Like column_address
                                              in micro mode
-
        micro_down                mcud1  ZZ   Like cursor_down in
                                              micro mode
        micro_left                mcub1  Za   Like cursor_left in
@@ -761,6 +784,8 @@
                                              in micro mode
        pkey_key                  pfkey  pk   program function key
                                              #1 to type string #2
+
+
        pkey_local                pfloc  pl   program function key
                                              #1 to execute string
                                              #2
@@ -779,8 +804,6 @@
        quick_dial                qdial  QD   dial number #1 with-
                                              out checking
        remove_clock              rmclk  RC   remove clock
-
-
        repeat_char               rep    rp   repeat char #1 #2
                                              times (P*)
        req_for_input             rfi    RF   send next input char
@@ -828,6 +851,7 @@
                                              umn
        set_right_margin_parm     smgrp  Zn   Set right margin at
                                              column #1
+
        set_tab                   hts    st   set a tab in every
                                              row, current columns
        set_top_margin            smgt   Zo   Set top margin at
@@ -845,8 +869,6 @@
                                              set
        stop_bit_image            rbim   Zs   Stop printing bit
                                              image graphics
-
-
        stop_char_set_def         rcsd   Zt   End definition of
                                              character set #1
        subscript_characters      subcs  Zu   List of subscript-
@@ -885,6 +907,7 @@
        SVr4.0  term structure, but were originally not documented
        in the man page.
 
+
                <STRONG>Variable</STRONG>          <STRONG>Cap-</STRONG>     <STRONG>TCap</STRONG>    <STRONG>Description</STRONG>
                 <STRONG>String</STRONG>           <STRONG>name</STRONG>     <STRONG>Code</STRONG>
        alt_scancode_esc          scesa    S8   Alternate escape
@@ -894,6 +917,7 @@
                                                of same row
        bit_image_newline         binel    Zz   Move to next row
                                                of the bit image
+
        bit_image_repeat          birep    Xy   Repeat bit image
                                                cell #1 #2 times
        char_set_names            csnm     Zy   Produce #1'th item
@@ -911,8 +935,6 @@
                                                port
        display_pc_char           dispc    S1   Display PC charac-
                                                ter #1
-
-
        end_bit_image_region      endbi    Yy   End a bit-image
                                                region
        enter_pc_charset_mode     smpch    S2   Enter PC character
@@ -961,6 +983,7 @@
                                                cap).
        set_page_length           slines   YZ   Set page length to
                                                #1 lines
+
        set_tb_margin             smgtb    MT   Sets both top and
                                                bottom margins to
                                                #1, #2
@@ -973,12 +996,11 @@
         these, they may not be binary-compatible  with  System  V
         terminfo entries after SVr4.1; beware!
 
+
                 <STRONG>Variable</STRONG>         <STRONG>Cap-</STRONG>   <STRONG>TCap</STRONG>     <STRONG>Description</STRONG>
                  <STRONG>String</STRONG>          <STRONG>name</STRONG>   <STRONG>Code</STRONG>
         enter_horizontal_hl_mode ehhlm  Xh   Enter horizontal
                                              highlight mode
-
-
         enter_left_hl_mode       elhlm  Xl   Enter left highlight
                                              mode
         enter_low_hl_mode        elohlm Xo   Enter low highlight
@@ -1027,11 +1049,11 @@
        space at the beginning of  each  line  except  the  first.
        Comments  may  be  included on lines beginning with ``#''.
        Capabilities in <EM>terminfo</EM> are of three types: Boolean capa-
-       bilities which indicate that the terminal has some partic-
-       ular feature, numeric capabilities giving the size of  the
-       terminal  or  the  size  of  particular delays, and string
-       capabilities, which give a sequence which can be  used  to
-       perform particular terminal operations.
+       bilities   which  indicate  that  the  terminal  has  some
+       particular feature, numeric capabilities giving  the  size
+       of  the  terminal  or  the  size of particular delays, and
+       string capabilities, which give a sequence  which  can  be
+       used to perform particular terminal operations.
 
 
    <STRONG>Types</STRONG> <STRONG>of</STRONG> <STRONG>Capabilities</STRONG>
@@ -1199,14 +1221,14 @@
        "glass-tty" terminals.  Thus  the  model  33  teletype  is
        described as
 
-     33|tty33|tty|model 33 teletype,
-     bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os,
+       33|tty33|tty|model 33 teletype,
+            bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os,
 
        while the Lear Siegler ADM-3 is described as
 
-     adm3|3|lsi adm3,
-     am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
-     ind=^J, lines#24,
+       adm3|3|lsi adm3,
+            am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
+            ind=^J, lines#24,
 
 
    <STRONG>Parameterized</STRONG> <STRONG>Strings</STRONG>
@@ -1287,292 +1309,304 @@
        %i   add 1 to first two parameters (for ANSI terminals)
 
        %? <EM>expr</EM> %t <EM>thenpart</EM> %e <EM>elsepart</EM> %;
-            if-then-else, %e <EM>elsepart</EM> is optional.  else-if's are
-            possible a la Algol 68:
+            This forms  an  if-then-else.   The  %e  <EM>elsepart</EM>  is
+            optional.   Usually  the  %? <EM>expr</EM> part pushes a value
+            onto the stack, and %t pops it from the stack,  test-
+            ing  if it is nonzero (true).  If it is zero (false),
+            control passes to the %e (else) part.
+
+            It is possible to form else-if's a la Algol 68:
             %? c1 %t b1 %e c2 %t b2 %e c3 %t b3 %e c4 %t b4 %e %;
-            ci are conditions, bi are bodies.
+
+            where ci are conditions, bi are bodies.
+
+            Use the <STRONG>-f</STRONG> option of <STRONG>tic</STRONG> or <STRONG>infocmp</STRONG> to see the struc-
+            ture of if-the-else's.  Some strings, e.g.,  <STRONG>sgr</STRONG>  can
+            be very complicated when written on one line.  The <STRONG>-f</STRONG>
+            option splits the string into lines  with  the  parts
+            indented.
 
        Binary operations are in postfix form with the operands in
-       the  usual  order.   That  is,  to  get  x-5 one would use
-       "%gx%{5}%-".  %P and %g variables  are  persistent  across
+       the usual order.  That  is,  to  get  x-5  one  would  use
+       "%gx%{5}%-".   %P  and  %g variables are persistent across
        escape-string evaluations.
 
        Consider the HP2645, which, to get to row 3 and column 12,
-       needs to be sent \E&amp;a12c03Y  padded  for  6  milliseconds.
-       Note  that  the  order of the rows and columns is inverted
-       here, and that the row and column are printed as two  dig-
+       needs  to  be  sent  \E&amp;a12c03Y padded for 6 milliseconds.
+       Note that the order of the rows and  columns  is  inverted
+       here,  and that the row and column are printed as two dig-
        its.  Thus its <STRONG>cup</STRONG> capability is "cup=6\E&amp;%p2%2dc%p1%2dY".
 
        The Microterm ACT-IV needs the current row and column sent
-       preceded  by  a <STRONG>^T</STRONG>, with the row and column simply encoded
-       in binary, "cup=^T%p1%c%p2%c".  Terminals which  use  "%c"
-       need  to  be  able  to backspace the cursor (<STRONG>cub1</STRONG>), and to
+       preceded by a <STRONG>^T</STRONG>, with the row and column  simply  encoded
+       in  binary,  "cup=^T%p1%c%p2%c".  Terminals which use "%c"
+       need to be able to backspace the  cursor  (<STRONG>cub1</STRONG>),  and  to
        move the cursor up one line on the screen (<STRONG>cuu1</STRONG>).  This is
-       necessary  because it is not always safe to transmit <STRONG>\n</STRONG> <STRONG>^D</STRONG>
-       and <STRONG>\r</STRONG>, as the system may change or  discard  them.   (The
-       library  routines  dealing  with terminfo set tty modes so
+       necessary because it is not always safe to transmit <STRONG>\n</STRONG>  <STRONG>^D</STRONG>
+       and  <STRONG>\r</STRONG>,  as  the system may change or discard them.  (The
+       library routines dealing with terminfo set  tty  modes  so
        that tabs are never expanded, so \t is safe to send.  This
        turns out to be essential for the Ann Arbor 4080.)
 
        A final example is the LSI ADM-3a, which uses row and col-
        umn  offset  by  a  blank  character,  thus  "cup=\E=%p1%'
-       '%+%c%p2%'  '%+%c".   After sending `\E=', this pushes the
-       first parameter, pushes the ASCII value for a space  (32),
-       adds  them  (pushing  the sum on the stack in place of the
-       two previous values) and outputs that value as  a  charac-
-       ter.   Then  the  same  is  done for the second parameter.
+       '%+%c%p2%' '%+%c".  After sending `\E=', this  pushes  the
+       first  parameter, pushes the ASCII value for a space (32),
+       adds them (pushing the sum on the stack in  place  of  the
+       two  previous  values) and outputs that value as a charac-
+       ter.  Then the same is  done  for  the  second  parameter.
        More complex arithmetic is possible using the stack.
 
 
    <STRONG>Cursor</STRONG> <STRONG>Motions</STRONG>
        If the terminal has a fast way to home the cursor (to very
-       upper  left  corner  of  screen) then this can be given as
-       <STRONG>home</STRONG>; similarly a fast way of getting to the  lower  left-
-       hand  corner can be given as <STRONG>ll</STRONG>; this may involve going up
-       with <STRONG>cuu1</STRONG> from the home position,  but  a  program  should
-       never  do this itself (unless <STRONG>ll</STRONG> does) because it can make
-       no assumption about the effect of moving up from the  home
-       position.   Note  that  the  home  position is the same as
+       upper left corner of screen) then this  can  be  given  as
+       <STRONG>home</STRONG>;  similarly  a fast way of getting to the lower left-
+       hand corner can be given as <STRONG>ll</STRONG>; this may involve going  up
+       with  <STRONG>cuu1</STRONG>  from  the  home position, but a program should
+       never do this itself (unless <STRONG>ll</STRONG> does) because it can  make
+       no  assumption about the effect of moving up from the home
+       position.  Note that the home  position  is  the  same  as
        addressing to (0,0): to the top left corner of the screen,
-       not  of  memory.   (Thus, the \EH sequence on HP terminals
+       not of memory.  (Thus, the \EH sequence  on  HP  terminals
        cannot be used for <STRONG>home</STRONG>.)
 
        If the terminal has row or column absolute cursor address-
-       ing,  these  can be given as single parameter capabilities
+       ing, these can be given as single  parameter  capabilities
        <STRONG>hpa</STRONG> (horizontal position absolute) and <STRONG>vpa</STRONG> (vertical posi-
        tion absolute).  Sometimes these are shorter than the more
-       general two parameter sequence (as with  the  hp2645)  and
+       general  two  parameter  sequence (as with the hp2645) and
        can be used in preference to <STRONG>cup</STRONG>.  If there are parameter-
-       ized local motions (e.g., move  <EM>n</EM>  spaces  to  the  right)
+       ized  local  motions  (e.g.,  move  <EM>n</EM> spaces to the right)
        these can be given as <STRONG>cud</STRONG>, <STRONG>cub</STRONG>, <STRONG>cuf</STRONG>, and <STRONG>cuu</STRONG> with a single
-       parameter indicating how many spaces to move.   These  are
-       primarily  useful  if the terminal does not have <STRONG>cup</STRONG>, such
+       parameter  indicating  how many spaces to move.  These are
+       primarily useful if the terminal does not have  <STRONG>cup</STRONG>,  such
        as the TEKTRONIX 4025.
 
        If the terminal needs to be in a special mode when running
        a program that uses these capabilities, the codes to enter
-       and exit this mode can be given as <STRONG>smcup</STRONG> and <STRONG>rmcup</STRONG>.   This
-       arises,  for example, from terminals like the Concept with
-       more than one page of memory.  If the  terminal  has  only
-       memory  relative cursor addressing and not screen relative
+       and  exit this mode can be given as <STRONG>smcup</STRONG> and <STRONG>rmcup</STRONG>.  This
+       arises, for example, from terminals like the Concept  with
+       more  than  one  page of memory.  If the terminal has only
+       memory relative cursor addressing and not screen  relative
        cursor addressing, a one screen-sized window must be fixed
-       into  the terminal for cursor addressing to work properly.
+       into the terminal for cursor addressing to work  properly.
        This is also used for the TEKTRONIX 4025, where <STRONG>smcup</STRONG> sets
-       the  command character to be the one used by terminfo.  If
-       the <STRONG>smcup</STRONG> sequence will not restore the  screen  after  an
+       the command character to be the one used by terminfo.   If
+       the  <STRONG>smcup</STRONG>  sequence  will not restore the screen after an
        <STRONG>rmcup</STRONG> sequence is output (to the state prior to outputting
        <STRONG>rmcup</STRONG>), specify <STRONG>nrrmc</STRONG>.
 
 
    <STRONG>Area</STRONG> <STRONG>Clears</STRONG>
        If the terminal can clear from the current position to the
-       end  of  the  line,  leaving  the cursor where it is, this
+       end of the line, leaving the  cursor  where  it  is,  this
        should be given as <STRONG>el</STRONG>.  If the terminal can clear from the
-       beginning  of  the line to the current position inclusive,
-       leaving the cursor where it is, this should  be  given  as
-       <STRONG>el1</STRONG>.   If the terminal can clear from the current position
-       to the end of the display, then this should  be  given  as
-       <STRONG>ed</STRONG>.   <STRONG>Ed</STRONG>  is only defined from the first column of a line.
-       (Thus, it can be simulated by a request to delete a  large
+       beginning of the line to the current  position  inclusive,
+       leaving  the  cursor  where it is, this should be given as
+       <STRONG>el1</STRONG>.  If the terminal can clear from the current  position
+       to  the  end  of the display, then this should be given as
+       <STRONG>ed</STRONG>.  <STRONG>Ed</STRONG> is only defined from the first column of  a  line.
+       (Thus,  it can be simulated by a request to delete a large
        number of lines, if a true <STRONG>ed</STRONG> is not available.)
 
 
    <STRONG>Insert/delete</STRONG> <STRONG>line</STRONG> <STRONG>and</STRONG> <STRONG>vertical</STRONG> <STRONG>motions</STRONG>
-       If  the terminal can open a new blank line before the line
-       where the cursor is, this should be given as <STRONG>il1</STRONG>; this  is
-       done  only  from the first position of a line.  The cursor
+       If the terminal can open a new blank line before the  line
+       where  the cursor is, this should be given as <STRONG>il1</STRONG>; this is
+       done only from the first position of a line.   The  cursor
        must then appear on the newly blank line.  If the terminal
-       can  delete  the  line  which  the cursor is on, then this
-       should be given as <STRONG>dl1</STRONG>; this is done only from  the  first
-       position  on  the line to be deleted.  Versions of <STRONG>il1</STRONG> and
-       <STRONG>dl1</STRONG> which take a single parameter  and  insert  or  delete
+       can delete the line which the  cursor  is  on,  then  this
+       should  be  given as <STRONG>dl1</STRONG>; this is done only from the first
+       position on the line to be deleted.  Versions of  <STRONG>il1</STRONG>  and
+       <STRONG>dl1</STRONG>  which  take  a  single parameter and insert or delete
        that many lines can be given as <STRONG>il</STRONG> and <STRONG>dl</STRONG>.
 
-       If  the terminal has a settable scrolling region (like the
-       vt100) the command to set this can be described  with  the
-       <STRONG>csr</STRONG>  capability,  which  takes two parameters: the top and
+       If the terminal has a settable scrolling region (like  the
+       vt100)  the  command to set this can be described with the
+       <STRONG>csr</STRONG> capability, which takes two parameters:  the  top  and
        bottom lines of the scrolling region.  The cursor position
        is, alas, undefined after using this command.
 
-       It  is possible to get the effect of insert or delete line
+       It is possible to get the effect of insert or delete  line
        using <STRONG>csr</STRONG> on a properly chosen region; the <STRONG>sc</STRONG> and <STRONG>rc</STRONG> (save
-       and  restore  cursor)  commands may be useful for ensuring
-       that your synthesized insert/delete string does  not  move
-       the  cursor.  (Note that the <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG> library does this
-       synthesis  automatically,  so   you   need   not   compose
+       and restore cursor) commands may be  useful  for  ensuring
+       that  your  synthesized insert/delete string does not move
+       the cursor.  (Note that the <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG> library does  this
+       synthesis   automatically,   so   you   need  not  compose
        insert/delete strings for an entry with <STRONG>csr</STRONG>).
 
        Yet another way to construct insert and delete might be to
-       use a combination of index with  the  memory-lock  feature
-       found  on some terminals (like the HP-700/90 series, which
+       use  a  combination  of index with the memory-lock feature
+       found on some terminals (like the HP-700/90 series,  which
        however also has insert/delete).
 
-       Inserting lines at the top or bottom  of  the  screen  can
-       also  be  done using <STRONG>ri</STRONG> or <STRONG>ind</STRONG> on many terminals without a
-       true insert/delete line, and is often faster even on  ter-
+       Inserting  lines  at  the  top or bottom of the screen can
+       also be done using <STRONG>ri</STRONG> or <STRONG>ind</STRONG> on many terminals  without  a
+       true  insert/delete line, and is often faster even on ter-
        minals with those features.
 
-       The  boolean  <STRONG>non_dest_scroll_region</STRONG> should be set if each
-       scrolling window is effectively a view port on  a  screen-
-       sized  canvas.   To  test  for  this  capability, create a
-       scrolling region in the middle of the screen, write  some-
-       thing  to  the  bottom line, move the cursor to the top of
+       The boolean <STRONG>non_dest_scroll_region</STRONG> should be set  if  each
+       scrolling  window  is effectively a view port on a screen-
+       sized canvas.  To  test  for  this  capability,  create  a
+       scrolling  region in the middle of the screen, write some-
+       thing to the bottom line, move the cursor to  the  top  of
        the region, and do <STRONG>ri</STRONG> followed by <STRONG>dl1</STRONG> or <STRONG>ind</STRONG>.  If the data
-       scrolled  off  the  bottom  of  the  region  by the <STRONG>ri</STRONG> re-
-       appears, then scrolling is non-destructive.  System V  and
-       XSI  Curses  expect that <STRONG>ind</STRONG>, <STRONG>ri</STRONG>, <STRONG>indn</STRONG>, and <STRONG>rin</STRONG> will simu-
-       late destructive scrolling; their  documentation  cautions
-       you  not  to  define <STRONG>csr</STRONG> unless this is true.  This <STRONG>curses</STRONG>
+       scrolled off the bottom  of  the  region  by  the  <STRONG>ri</STRONG>  re-
+       appears,  then scrolling is non-destructive.  System V and
+       XSI Curses expect that <STRONG>ind</STRONG>, <STRONG>ri</STRONG>, <STRONG>indn</STRONG>, and <STRONG>rin</STRONG>  will  simu-
+       late  destructive  scrolling; their documentation cautions
+       you not to define <STRONG>csr</STRONG> unless this is  true.   This  <STRONG>curses</STRONG>
        implementation is more liberal and will do explicit erases
        after scrolling if <STRONG>ndstr</STRONG> is defined.
 
        If the terminal has the ability to define a window as part
-       of memory, which all commands affect, it should  be  given
+       of  memory,  which all commands affect, it should be given
        as the parameterized string <STRONG>wind</STRONG>.  The four parameters are
-       the starting and ending lines in memory and  the  starting
+       the  starting  and ending lines in memory and the starting
        and ending columns in memory, in that order.
 
-       If  the terminal can retain display memory above, then the
-       <STRONG>da</STRONG> capability should be given; if display  memory  can  be
-       retained  below,  then <STRONG>db</STRONG> should be given.  These indicate
-       that deleting a line  or  scrolling  may  bring  non-blank
-       lines  up  from  below  or that scrolling back with <STRONG>ri</STRONG> may
+       If the terminal can retain display memory above, then  the
+       <STRONG>da</STRONG>  capability  should  be given; if display memory can be
+       retained below, then <STRONG>db</STRONG> should be given.   These  indicate
+       that  deleting  a  line  or  scrolling may bring non-blank
+       lines up from below or that scrolling  back  with  <STRONG>ri</STRONG>  may
        bring down non-blank lines.
 
 
    <STRONG>Insert/Delete</STRONG> <STRONG>Character</STRONG>
-       There are two basic kinds of  intelligent  terminals  with
-       respect  to insert/delete character which can be described
-       using <EM>terminfo.</EM>  The most common  insert/delete  character
-       operations  affect only the characters on the current line
-       and shift characters off the  end  of  the  line  rigidly.
-       Other  terminals,  such  as the Concept 100 and the Perkin
-       Elmer Owl, make a distinction between  typed  and  untyped
-       blanks  on  the  screen, shifting upon an insert or delete
-       only to an untyped blank on the  screen  which  is  either
-       eliminated,  or  expanded  to two untyped blanks.  You can
-       determine the kind of terminal you have  by  clearing  the
-       screen  and  then typing text separated by cursor motions.
-       Type "abc    def" using local cursor motions (not  spaces)
+       There  are  two  basic kinds of intelligent terminals with
+       respect to insert/delete character which can be  described
+       using  <EM>terminfo.</EM>   The most common insert/delete character
+       operations affect only the characters on the current  line
+       and  shift  characters  off  the  end of the line rigidly.
+       Other terminals, such as the Concept 100  and  the  Perkin
+       Elmer  Owl,  make  a distinction between typed and untyped
+       blanks on the screen, shifting upon an  insert  or  delete
+       only  to  an  untyped  blank on the screen which is either
+       eliminated, or expanded to two untyped  blanks.   You  can
+       determine  the  kind  of terminal you have by clearing the
+       screen and then typing text separated by  cursor  motions.
+       Type  "abc    def" using local cursor motions (not spaces)
        between the "abc" and the "def".  Then position the cursor
-       before the "abc" and put the terminal in insert mode.   If
-       typing  characters  causes  the  rest of the line to shift
+       before  the "abc" and put the terminal in insert mode.  If
+       typing characters causes the rest of  the  line  to  shift
        rigidly and characters to fall off the end, then your ter-
-       minal  does  not  distinguish  between  blanks and untyped
-       positions.  If the "abc" shifts over to  the  "def"  which
-       then  move together around the end of the current line and
-       onto the next as you insert, you have the second  type  of
-       terminal,  and should give the capability <STRONG>in</STRONG>, which stands
+       minal does not  distinguish  between  blanks  and  untyped
+       positions.   If  the  "abc" shifts over to the "def" which
+       then move together around the end of the current line  and
+       onto  the  next as you insert, you have the second type of
+       terminal, and should give the capability <STRONG>in</STRONG>, which  stands
        for "insert null".  While these are two logically separate
-       attributes  (one  line  versus multi-line insert mode, and
-       special treatment of untyped spaces) we have seen no  ter-
+       attributes (one line versus multi-line  insert  mode,  and
+       special  treatment of untyped spaces) we have seen no ter-
        minals whose insert mode cannot be described with the sin-
        gle attribute.
 
-       Terminfo can describe both terminals which have an  insert
+       Terminfo  can describe both terminals which have an insert
        mode, and terminals which send a simple sequence to open a
-       blank position on the current  line.   Give  as  <STRONG>smir</STRONG>  the
-       sequence  to  get  into  insert  mode.   Give  as <STRONG>rmir</STRONG> the
-       sequence to leave insert  mode.   Now  give  as  <STRONG>ich1</STRONG>  any
+       blank  position  on  the  current  line.  Give as <STRONG>smir</STRONG> the
+       sequence to get  into  insert  mode.   Give  as  <STRONG>rmir</STRONG>  the
+       sequence  to  leave  insert  mode.   Now  give as <STRONG>ich1</STRONG> any
        sequence needed to be sent just before sending the charac-
-       ter to be inserted.  Most terminals  with  a  true  insert
-       mode  will  not give <STRONG>ich1</STRONG>; terminals which send a sequence
+       ter  to  be  inserted.   Most terminals with a true insert
+       mode will not give <STRONG>ich1</STRONG>; terminals which send  a  sequence
        to open a screen position should give it here.
 
-       If your terminal has both, insert mode is usually  prefer-
-       able  to  <STRONG>ich1</STRONG>.   Technically,  you  should  not give both
-       unless the terminal actually requires both to be  used  in
-       combination.   Accordingly,  some  non-curses applications
-       get confused if both are present; the symptom  is  doubled
+       If  your terminal has both, insert mode is usually prefer-
+       able to <STRONG>ich1</STRONG>.   Technically,  you  should  not  give  both
+       unless  the  terminal actually requires both to be used in
+       combination.  Accordingly,  some  non-curses  applications
+       get  confused  if both are present; the symptom is doubled
        characters in an update using insert.  This requirement is
        now rare; most <STRONG>ich</STRONG> sequences do not require previous smir,
        and most smir insert modes do not require <STRONG>ich1</STRONG> before each
-       character.  Therefore, the  new  <STRONG>curses</STRONG>  actually  assumes
-       this  is the case and uses either <STRONG>rmir</STRONG>/<STRONG>smir</STRONG> or <STRONG>ich</STRONG>/<STRONG>ich1</STRONG> as
+       character.   Therefore,  the  new  <STRONG>curses</STRONG> actually assumes
+       this is the case and uses either <STRONG>rmir</STRONG>/<STRONG>smir</STRONG> or <STRONG>ich</STRONG>/<STRONG>ich1</STRONG>  as
        appropriate (but not both).  If you have to write an entry
-       to  be  used under new curses for a terminal old enough to
+       to be used under new curses for a terminal old  enough  to
        need both, include the <STRONG>rmir</STRONG>/<STRONG>smir</STRONG> sequences in <STRONG>ich1</STRONG>.
 
        If post insert padding is needed, give this as a number of
-       milliseconds  in <STRONG>ip</STRONG> (a string option).  Any other sequence
-       which may need to be sent after  an  insert  of  a  single
+       milliseconds in <STRONG>ip</STRONG> (a string option).  Any other  sequence
+       which  may  need  to  be  sent after an insert of a single
        character may also be given in <STRONG>ip</STRONG>.  If your terminal needs
        both to be placed into an `insert mode' and a special code
-       to  precede  each  inserted character, then both <STRONG>smir</STRONG>/<STRONG>rmir</STRONG>
-       and <STRONG>ich1</STRONG> can be given, and both will  be  used.   The  <STRONG>ich</STRONG>
+       to precede each inserted character,  then  both  <STRONG>smir</STRONG>/<STRONG>rmir</STRONG>
+       and  <STRONG>ich1</STRONG>  can  be  given, and both will be used.  The <STRONG>ich</STRONG>
        capability, with one parameter, <EM>n</EM>, will repeat the effects
        of <STRONG>ich1</STRONG> <EM>n</EM> times.
 
        If padding is necessary between characters typed while not
-       in  insert  mode,  give  this  as a number of milliseconds
+       in insert mode, give this  as  a  number  of  milliseconds
        padding in <STRONG>rmp</STRONG>.
 
-       It is occasionally  necessary  to  move  around  while  in
-       insert  mode  to delete characters on the same line (e.g.,
-       if there is a tab after the insertion position).  If  your
-       terminal  allows  motion while in insert mode you can give
-       the capability <STRONG>mir</STRONG> to speed up  inserting  in  this  case.
-       Omitting  <STRONG>mir</STRONG>  will  affect  only  speed.   Some terminals
+       It  is  occasionally  necessary  to  move  around while in
+       insert mode to delete characters on the same  line  (e.g.,
+       if  there is a tab after the insertion position).  If your
+       terminal allows motion while in insert mode you  can  give
+       the  capability  <STRONG>mir</STRONG>  to  speed up inserting in this case.
+       Omitting <STRONG>mir</STRONG>  will  affect  only  speed.   Some  terminals
        (notably Datamedia's) must not have <STRONG>mir</STRONG> because of the way
        their insert mode works.
 
-       Finally,  you  can specify <STRONG>dch1</STRONG> to delete a single charac-
-       ter, <STRONG>dch</STRONG> with one parameter, <EM>n</EM>, to  delete  <EM>n</EM>  <EM>characters,</EM>
-       and  delete mode by giving <STRONG>smdc</STRONG> and <STRONG>rmdc</STRONG> to enter and exit
-       delete mode (any mode the terminal needs to be  placed  in
+       Finally, you can specify <STRONG>dch1</STRONG> to delete a  single  charac-
+       ter,  <STRONG>dch</STRONG>  with  one parameter, <EM>n</EM>, to delete <EM>n</EM> <EM>characters,</EM>
+       and delete mode by giving <STRONG>smdc</STRONG> and <STRONG>rmdc</STRONG> to enter and  exit
+       delete  mode  (any mode the terminal needs to be placed in
        for <STRONG>dch1</STRONG> to work).
 
-       A  command to erase <EM>n</EM> characters (equivalent to outputting
-       <EM>n</EM> blanks without moving the cursor) can be  given  as  <STRONG>ech</STRONG>
+       A command to erase <EM>n</EM> characters (equivalent to  outputting
+       <EM>n</EM>  blanks  without  moving the cursor) can be given as <STRONG>ech</STRONG>
        with one parameter.
 
 
    <STRONG>Highlighting,</STRONG> <STRONG>Underlining,</STRONG> <STRONG>and</STRONG> <STRONG>Visible</STRONG> <STRONG>Bells</STRONG>
        If  your  terminal  has  one  or  more  kinds  of  display
-       attributes, these can be represented in a number  of  dif-
+       attributes,  these  can be represented in a number of dif-
        ferent ways.  You should choose one display form as <EM>stand-</EM>
        <EM>out</EM> <EM>mode</EM>, representing a good, high contrast, easy-on-the-
-       eyes,  format  for  highlighting  error messages and other
-       attention getters.  (If you have a choice,  reverse  video
-       plus  half-bright  is  good, or reverse video alone.)  The
-       sequences to enter and exit standout  mode  are  given  as
-       <STRONG>smso</STRONG>  and  <STRONG>rmso</STRONG>, respectively.  If the code to change into
-       or out of standout mode  leaves  one  or  even  two  blank
-       spaces  on the screen, as the TVI 912 and Teleray 1061 do,
+       eyes, format for highlighting  error  messages  and  other
+       attention  getters.   (If you have a choice, reverse video
+       plus half-bright is good, or reverse  video  alone.)   The
+       sequences  to  enter  and  exit standout mode are given as
+       <STRONG>smso</STRONG> and <STRONG>rmso</STRONG>, respectively.  If the code to  change  into
+       or  out  of  standout  mode  leaves  one or even two blank
+       spaces on the screen, as the TVI 912 and Teleray 1061  do,
        then <STRONG>xmc</STRONG> should be given to tell how many spaces are left.
 
-       Codes  to  begin  underlining  and  end underlining can be
-       given as <STRONG>smul</STRONG> and <STRONG>rmul</STRONG> respectively.  If the terminal  has
-       a  code  to  underline  the current character and move the
+       Codes to begin underlining  and  end  underlining  can  be
+       given  as <STRONG>smul</STRONG> and <STRONG>rmul</STRONG> respectively.  If the terminal has
+       a code to underline the current  character  and  move  the
        cursor one space to the right, such as the Microterm Mime,
        this can be given as <STRONG>uc</STRONG>.
 
-       Other  capabilities  to  enter  various highlighting modes
-       include <STRONG>blink</STRONG> (blinking) <STRONG>bold</STRONG> (bold or extra  bright)  <STRONG>dim</STRONG>
-       (dim  or  half-bright)  <STRONG>invis</STRONG> (blanking or invisible text)
-       <STRONG>prot</STRONG> (protected) <STRONG>rev</STRONG> (reverse video) <STRONG>sgr0</STRONG>  (turn  off  <EM>all</EM>
-       attribute  modes)  <STRONG>smacs</STRONG>  (enter  alternate  character set
-       mode) and  <STRONG>rmacs</STRONG>  (exit  alternate  character  set  mode).
-       Turning  on  any of these modes singly may or may not turn
+       Other capabilities to  enter  various  highlighting  modes
+       include  <STRONG>blink</STRONG>  (blinking) <STRONG>bold</STRONG> (bold or extra bright) <STRONG>dim</STRONG>
+       (dim or half-bright) <STRONG>invis</STRONG> (blanking  or  invisible  text)
+       <STRONG>prot</STRONG>  (protected)  <STRONG>rev</STRONG>  (reverse video) <STRONG>sgr0</STRONG> (turn off <EM>all</EM>
+       attribute modes)  <STRONG>smacs</STRONG>  (enter  alternate  character  set
+       mode)  and  <STRONG>rmacs</STRONG>  (exit  alternate  character  set mode).
+       Turning on any of these modes singly may or may  not  turn
        off other modes.
 
-       If there is a sequence to set  arbitrary  combinations  of
-       modes,  this should be given as <STRONG>sgr</STRONG> (set attributes), tak-
-       ing 9 parameters.  Each parameter is either 0 or  nonzero,
+       If  there  is  a sequence to set arbitrary combinations of
+       modes, this should be given as <STRONG>sgr</STRONG> (set attributes),  tak-
+       ing  9 parameters.  Each parameter is either 0 or nonzero,
        as the corresponding attribute is on or off.  The 9 param-
-       eters are, in order: standout, underline, reverse,  blink,
-       dim,  bold,  blank, protect, alternate character set.  Not
-       all modes need be supported by <STRONG>sgr</STRONG>, only those  for  which
+       eters  are, in order: standout, underline, reverse, blink,
+       dim, bold, blank, protect, alternate character  set.   Not
+       all  modes  need be supported by <STRONG>sgr</STRONG>, only those for which
        corresponding separate attribute commands exist.
 
        For example, the DEC vt220 supports most of the modes:
 
+
            <STRONG>tparm</STRONG> <STRONG>parameter</STRONG>   <STRONG>attribute</STRONG>    <STRONG>escape</STRONG> <STRONG>sequence</STRONG>
 
            none              none         \E[0m
            p1                standout     \E[0;1;7m
            p2                underline    \E[0;4m
-
            p3                reverse      \E[0;7m
            p4                blink        \E[0;5m
            p5                dim          not available
@@ -1581,24 +1615,25 @@
            p8                protect      not used
            p9                altcharset   ^O (off) ^N (on)
 
-       We  begin each escape sequence by turning off any existing
-       modes, since there is no quick way  to  determine  whether
+       We begin each escape sequence by turning off any  existing
+       modes,  since  there  is no quick way to determine whether
        they are active.  Standout is set up to be the combination
-       of reverse and bold.  The vt220  terminal  has  a  protect
-       mode,  though  it  is  not commonly used in sgr because it
-       protects characters on the screen  from  the  host's  era-
-       sures.   The  altcharset mode also is different in that it
-       is either ^O or ^N, depending on whether it is off or  on.
-       If  all  modes  are  turned  on, the resulting sequence is
+       of  reverse  and  bold.   The vt220 terminal has a protect
+       mode, though it is not commonly used  in  sgr  because  it
+       protects  characters  on  the  screen from the host's era-
+       sures.  The altcharset mode also is different in  that  it
+       is  either ^O or ^N, depending on whether it is off or on.
+       If all modes are turned  on,  the  resulting  sequence  is
        \E[0;1;4;5;7;8m^N.
 
-       Some sequences are common to different modes.   For  exam-
-       ple,  ;7  is output when either p1 or p3 is true, that is,
+       Some  sequences  are common to different modes.  For exam-
+       ple, ;7 is output when either p1 or p3 is true,  that  is,
        if either standout or reverse modes are turned on.
 
-       Writing out the above sequences, along with  their  depen-
+       Writing  out  the above sequences, along with their depen-
        dencies yields
 
+
          <STRONG>sequence</STRONG>    <STRONG>when</STRONG> <STRONG>to</STRONG> <STRONG>output</STRONG>     <STRONG>terminfo</STRONG> <STRONG>translation</STRONG>
 
          \E[0       always              \E[0
@@ -1608,6 +1643,7 @@
          ;7         if p1 or p3         %?%p1%p3%|%t;7%;
          ;8         if p7               %?%p7%|%t;8%;
          m          always              m
+
          ^N or ^O   if p9 ^N, else ^O   %?%p9%t^N%e^O%;
 
        Putting this all together into the sgr sequence gives:
@@ -1615,216 +1651,223 @@
            sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;
                %?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
 
-       Remember  that  if  you specify sgr, you must also specify
-       sgr0.
-
-       Terminals with the ``magic cookie'' glitch  (<STRONG>xmc</STRONG>)  deposit
-       special   ``cookies''   when   they  receive  mode-setting
-       sequences, which affect the display algorithm rather  than
-       having  extra  bits  for  each character.  Some terminals,
-       such as the HP 2621,  automatically  leave  standout  mode
-       when  they  move to a new line or the cursor is addressed.
-       Programs using standout mode  should  exit  standout  mode
-       before  moving the cursor or sending a newline, unless the
-       <STRONG>msgr</STRONG> capability, asserting that it  is  safe  to  move  in
+       Remember that if you specify sgr, you  must  also  specify
+       sgr0.   Also, some implementations rely on sgr being given
+       if sgr0 is, Not all terminfo entries necessarily  have  an
+       sgr  string,  however.   Many terminfo entries are derived
+       from termcap entries which have no sgr string.   The  only
+       drawback  to  adding  an  sgr  string is that termcap also
+       assumes that sgr0 does not exit  alternate  character  set
+       mode.
+
+       Terminals  with  the ``magic cookie'' glitch (<STRONG>xmc</STRONG>) deposit
+       special  ``cookies''  when   they   receive   mode-setting
+       sequences,  which affect the display algorithm rather than
+       having extra bits for  each  character.   Some  terminals,
+       such  as  the  HP  2621, automatically leave standout mode
+       when they move to a new line or the cursor  is  addressed.
+       Programs  using  standout  mode  should exit standout mode
+       before moving the cursor or sending a newline, unless  the
+       <STRONG>msgr</STRONG>  capability,  asserting  that  it  is safe to move in
        standout mode, is present.
 
-       If  the terminal has a way of flashing the screen to indi-
-       cate an error quietly (a bell replacement) then  this  can
+       If the terminal has a way of flashing the screen to  indi-
+       cate  an  error quietly (a bell replacement) then this can
        be given as <STRONG>flash</STRONG>; it must not move the cursor.
 
-       If  the  cursor  needs to be made more visible than normal
+       If the cursor needs to be made more  visible  than  normal
        when it is not on the bottom line (to make, for example, a
-       non-blinking  underline  into  an  easier to find block or
+       non-blinking underline into an easier  to  find  block  or
        blinking underline) give this sequence as <STRONG>cvvis</STRONG>.  If there
-       is  a  way  to  make the cursor completely invisible, give
+       is a way to make the  cursor  completely  invisible,  give
        that as <STRONG>civis</STRONG>.  The capability <STRONG>cnorm</STRONG> should be given which
        undoes the effects of both of these modes.
 
        If your terminal correctly generates underlined characters
-       (with no special codes needed) even  though  it  does  not
-       overstrike,  then you should give the capability <STRONG>ul</STRONG>.  If a
-       character overstriking another leaves both  characters  on
+       (with  no  special  codes  needed) even though it does not
+       overstrike, then you should give the capability <STRONG>ul</STRONG>.  If  a
+       character  overstriking  another leaves both characters on
        the screen, specify the capability <STRONG>os</STRONG>.  If overstrikes are
-       erasable with a blank, then this should  be  indicated  by
+       erasable  with  a  blank, then this should be indicated by
        giving <STRONG>eo</STRONG>.
 
 
    <STRONG>Keypad</STRONG> <STRONG>and</STRONG> <STRONG>Function</STRONG> <STRONG>Keys</STRONG>
        If the terminal has a keypad that transmits codes when the
-       keys are pressed, this information  can  be  given.   Note
+       keys  are  pressed,  this  information can be given.  Note
        that it is not possible to handle terminals where the key-
        pad only works in local (this applies, for example, to the
-       unshifted  HP  2621  keys).   If  the keypad can be set to
-       transmit or not transmit, give these  codes  as  <STRONG>smkx</STRONG>  and
+       unshifted HP 2621 keys).  If the  keypad  can  be  set  to
+       transmit  or  not  transmit,  give these codes as <STRONG>smkx</STRONG> and
        <STRONG>rmkx</STRONG>.  Otherwise the keypad is assumed to always transmit.
-       The codes sent by the left arrow, right arrow,  up  arrow,
-       down  arrow,  and  home keys can be given as <STRONG>kcub1,</STRONG> <STRONG>kcuf1,</STRONG>
-       <STRONG>kcuu1,</STRONG> <STRONG>kcud1,</STRONG> and <STRONG>khome</STRONG> respectively.  If there are  func-
-       tion  keys  such  as f0, f1, ..., f10, the codes they send
-       can be given as <STRONG>kf0,</STRONG> <STRONG>kf1,</STRONG> <STRONG>...,</STRONG> <STRONG>kf10</STRONG>.  If these  keys  have
-       labels  other  than the default f0 through f10, the labels
-       can be given as <STRONG>lf0,</STRONG> <STRONG>lf1,</STRONG> <STRONG>...,</STRONG> <STRONG>lf10</STRONG>.  The codes  transmit-
-       ted  by certain other special keys can be given: <STRONG>kll</STRONG> (home
-       down), <STRONG>kbs</STRONG>  (backspace),  <STRONG>ktbc</STRONG>  (clear  all  tabs),  <STRONG>kctab</STRONG>
+       The  codes  sent by the left arrow, right arrow, up arrow,
+       down arrow, and home keys can be given  as  <STRONG>kcub1,</STRONG>  <STRONG>kcuf1,</STRONG>
+       <STRONG>kcuu1,</STRONG>  <STRONG>kcud1,</STRONG> and <STRONG>khome</STRONG> respectively.  If there are func-
+       tion keys such as f0, f1, ..., f10, the  codes  they  send
+       can  be  given as <STRONG>kf0,</STRONG> <STRONG>kf1,</STRONG> <STRONG>...,</STRONG> <STRONG>kf10</STRONG>.  If these keys have
+       labels other than the default f0 through f10,  the  labels
+       can  be given as <STRONG>lf0,</STRONG> <STRONG>lf1,</STRONG> <STRONG>...,</STRONG> <STRONG>lf10</STRONG>.  The codes transmit-
+       ted by certain other special keys can be given: <STRONG>kll</STRONG>  (home
+       down),  <STRONG>kbs</STRONG>  (backspace),  <STRONG>ktbc</STRONG>  (clear  all  tabs), <STRONG>kctab</STRONG>
        (clear the tab stop in this column), <STRONG>kclr</STRONG> (clear screen or
-       erase key), <STRONG>kdch1</STRONG> (delete character), <STRONG>kdl1</STRONG> (delete  line),
-       <STRONG>krmir</STRONG>  (exit insert mode), <STRONG>kel</STRONG> (clear to end of line), <STRONG>ked</STRONG>
+       erase  key), <STRONG>kdch1</STRONG> (delete character), <STRONG>kdl1</STRONG> (delete line),
+       <STRONG>krmir</STRONG> (exit insert mode), <STRONG>kel</STRONG> (clear to end of line),  <STRONG>ked</STRONG>
        (clear to end of screen), <STRONG>kich1</STRONG> (insert character or enter
-       insert  mode),  <STRONG>kil1</STRONG>  (insert  line), <STRONG>knp</STRONG> (next page), <STRONG>kpp</STRONG>
-       (previous page), <STRONG>kind</STRONG> (scroll forward/down),  <STRONG>kri</STRONG>  (scroll
-       backward/up),  <STRONG>khts</STRONG>  (set  a tab stop in this column).  In
+       insert mode), <STRONG>kil1</STRONG> (insert line),  <STRONG>knp</STRONG>  (next  page),  <STRONG>kpp</STRONG>
+       (previous  page),  <STRONG>kind</STRONG> (scroll forward/down), <STRONG>kri</STRONG> (scroll
+       backward/up), <STRONG>khts</STRONG> (set a tab stop in  this  column).   In
        addition, if the keypad has a 3 by 3 array of keys includ-
-       ing  the four arrow keys, the other five keys can be given
-       as <STRONG>ka1</STRONG>, <STRONG>ka3</STRONG>, <STRONG>kb2</STRONG>, <STRONG>kc1</STRONG>, and <STRONG>kc3</STRONG>.   These  keys  are  useful
+       ing the four arrow keys, the other five keys can be  given
+       as  <STRONG>ka1</STRONG>,  <STRONG>ka3</STRONG>,  <STRONG>kb2</STRONG>,  <STRONG>kc1</STRONG>, and <STRONG>kc3</STRONG>.  These keys are useful
        when the effects of a 3 by 3 directional pad are needed.
 
-       Strings  to  program  function keys can be given as <STRONG>pfkey</STRONG>,
-       <STRONG>pfloc</STRONG>, and <STRONG>pfx</STRONG>.  A string to program screen labels  should
-       be  specified  as  <STRONG>pln</STRONG>.   Each  of these strings takes two
-       parameters: the function key number to program (from 0  to
-       10)  and the string to program it with.  Function key num-
-       bers out of this range may program  undefined  keys  in  a
-       terminal  dependent  manner.   The  difference between the
-       capabilities is that <STRONG>pfkey</STRONG> causes pressing the  given  key
-       to  be the same as the user typing the given string; <STRONG>pfloc</STRONG>
+       Strings to program function keys can be  given  as  <STRONG>pfkey</STRONG>,
+       <STRONG>pfloc</STRONG>,  and <STRONG>pfx</STRONG>.  A string to program screen labels should
+       be specified as <STRONG>pln</STRONG>.  Each  of  these  strings  takes  two
+       parameters:  the function key number to program (from 0 to
+       10) and the string to program it with.  Function key  num-
+       bers  out  of  this  range may program undefined keys in a
+       terminal dependent manner.   The  difference  between  the
+       capabilities  is  that <STRONG>pfkey</STRONG> causes pressing the given key
+       to be the same as the user typing the given string;  <STRONG>pfloc</STRONG>
        causes the string to be executed by the terminal in local;
-       and  <STRONG>pfx</STRONG>  causes  the string to be transmitted to the com-
+       and <STRONG>pfx</STRONG> causes the string to be transmitted  to  the  com-
        puter.
 
        The capabilities <STRONG>nlab</STRONG>, <STRONG>lw</STRONG> and <STRONG>lh</STRONG> define the number of pro-
-       grammable  screen  labels  and their width and height.  If
-       there are commands to turn the labels  on  and  off,  give
-       them  in <STRONG>smln</STRONG> and <STRONG>rmln</STRONG>.  <STRONG>smln</STRONG> is normally output after one
+       grammable screen labels and their width  and  height.   If
+       there  are  commands  to  turn the labels on and off, give
+       them in <STRONG>smln</STRONG> and <STRONG>rmln</STRONG>.  <STRONG>smln</STRONG> is normally output after  one
        or more pln sequences to make sure that the change becomes
        visible.
 
 
    <STRONG>Tabs</STRONG> <STRONG>and</STRONG> <STRONG>Initialization</STRONG>
-       If  the terminal has hardware tabs, the command to advance
-       to the next tab stop can be given as <STRONG>ht</STRONG>  (usually  control
-       I).   A  ``back-tab''  command which moves leftward to the
+       If the terminal has hardware tabs, the command to  advance
+       to  the  next tab stop can be given as <STRONG>ht</STRONG> (usually control
+       I).  A ``back-tab'' command which moves  leftward  to  the
        preceding tab stop can be given as <STRONG>cbt</STRONG>.  By convention, if
-       the  teletype  modes indicate that tabs are being expanded
-       by the computer rather than being sent  to  the  terminal,
-       programs  should  not  use <STRONG>ht</STRONG> or <STRONG>cbt</STRONG> even if they are pre-
-       sent, since the user may not have the tab  stops  properly
-       set.   If  the  terminal  has hardware tabs which are ini-
-       tially set every <EM>n</EM> spaces when the terminal is powered up,
-       the  numeric  parameter <STRONG>it</STRONG> is given, showing the number of
-       spaces the tabs are set to.  This is normally used by  the
-       <EM>tset</EM>  command  to  determine  whether  to set the mode for
-       hardware tab expansion, and whether to set the tab  stops.
-       If  the  terminal  has tab stops that can be saved in non-
-       volatile memory, the terminfo description can assume  that
+       the teletype modes indicate that tabs are  being  expanded
+       by  the  computer  rather than being sent to the terminal,
+       programs should not  use  <STRONG>ht</STRONG>  or  <STRONG>cbt</STRONG>  even  if  they  are
+       present,  since  the user may not have the tab stops prop-
+       erly set.  If the terminal has  hardware  tabs  which  are
+       initially  set every <EM>n</EM> spaces when the terminal is powered
+       up, the numeric parameter <STRONG>it</STRONG> is given, showing the  number
+       of  spaces  the tabs are set to.  This is normally used by
+       the <EM>tset</EM> command to determine whether to set the mode  for
+       hardware  tab expansion, and whether to set the tab stops.
+       If the terminal has tab stops that can be  saved  in  non-
+       volatile  memory, the terminfo description can assume that
        they are properly set.
 
-       Other  capabilities include <STRONG>is1</STRONG>, <STRONG>is2</STRONG>, and <STRONG>is3</STRONG>, initializa-
-       tion strings for the terminal, <STRONG>iprog</STRONG>, the path name  of  a
-       program  to be run to initialize the terminal, and <STRONG>if</STRONG>, the
-       name of a file  containing  long  initialization  strings.
-       These  strings are expected to set the terminal into modes
-       consistent with the  rest  of  the  terminfo  description.
+       Other capabilities include <STRONG>is1</STRONG>, <STRONG>is2</STRONG>, and <STRONG>is3</STRONG>,  initializa-
+       tion  strings  for the terminal, <STRONG>iprog</STRONG>, the path name of a
+       program to be run to initialize the terminal, and <STRONG>if</STRONG>,  the
+       name  of  a  file  containing long initialization strings.
+       These strings are expected to set the terminal into  modes
+       consistent  with  the  rest  of  the terminfo description.
        They are normally sent to the terminal, by the <EM>init</EM> option
-       of the <EM>tput</EM> program, each time the  user  logs  in.   They
-       will  be  printed  in the following order: run the program
-       <STRONG>iprog</STRONG>; output <STRONG>is1</STRONG>; <STRONG>is2</STRONG>; set the margins  using  <STRONG>mgc</STRONG>,  <STRONG>smgl</STRONG>
-       and  <STRONG>smgr</STRONG>;  set tabs using <STRONG>tbc</STRONG> and <STRONG>hts</STRONG>; print the file <STRONG>if</STRONG>;
+       of  the  <EM>tput</EM>  program,  each time the user logs in.  They
+       will be printed in the following order:  run  the  program
+       <STRONG>iprog</STRONG>;  output  <STRONG>is1</STRONG>;  <STRONG>is2</STRONG>; set the margins using <STRONG>mgc</STRONG>, <STRONG>smgl</STRONG>
+       and <STRONG>smgr</STRONG>; set tabs using <STRONG>tbc</STRONG> and <STRONG>hts</STRONG>; print the  file  <STRONG>if</STRONG>;
        and finally output <STRONG>is3</STRONG>.
 
-       Most initialization is done with  <STRONG>is2</STRONG>.   Special  terminal
+       Most  initialization  is  done with <STRONG>is2</STRONG>.  Special terminal
        modes can be set up without duplicating strings by putting
-       the common sequences in <STRONG>is2</STRONG> and special cases in  <STRONG>is1</STRONG>  and
-       <STRONG>is3</STRONG>.   A pair of sequences that does a harder reset from a
-       totally unknown state can be  analogously  given  as  <STRONG>rs1</STRONG>,
-       <STRONG>rs2</STRONG>,  <STRONG>rf</STRONG>, and <STRONG>rs3</STRONG>, analogous to <STRONG>is2</STRONG> and <STRONG>if</STRONG>.  These strings
-       are output by the <EM>reset</EM> program, which is  used  when  the
-       terminal  gets into a wedged state.  Commands are normally
-       placed in <STRONG>rs1</STRONG>, <STRONG>rs2</STRONG> <STRONG>rs3</STRONG> and <STRONG>rf</STRONG> only if they produce  annoy-
-       ing  effects on the screen and are not necessary when log-
-       ging in.  For example, the command to set the  vt100  into
-       80-column  mode  would  normally  be  part  of <STRONG>is2</STRONG>, but it
-       causes an annoying glitch of the screen and  is  not  nor-
-       mally  needed  since the terminal is usually already in 80
+       the  common  sequences in <STRONG>is2</STRONG> and special cases in <STRONG>is1</STRONG> and
+       <STRONG>is3</STRONG>.  A pair of sequences that does a harder reset from  a
+       totally  unknown  state  can  be analogously given as <STRONG>rs1</STRONG>,
+       <STRONG>rs2</STRONG>, <STRONG>rf</STRONG>, and <STRONG>rs3</STRONG>, analogous to <STRONG>is2</STRONG> and <STRONG>if</STRONG>.  These  strings
+       are  output  by  the <EM>reset</EM> program, which is used when the
+       terminal gets into a wedged state.  Commands are  normally
+       placed  in <STRONG>rs1</STRONG>, <STRONG>rs2</STRONG> <STRONG>rs3</STRONG> and <STRONG>rf</STRONG> only if they produce annoy-
+       ing effects on the screen and are not necessary when  log-
+       ging  in.   For example, the command to set the vt100 into
+       80-column mode would normally  be  part  of  <STRONG>is2</STRONG>,  but  it
+       causes  an  annoying  glitch of the screen and is not nor-
+       mally needed since the terminal is usually already  in  80
        column mode.
 
        If there are commands to set and clear tab stops, they can
-       be  given  as <STRONG>tbc</STRONG> (clear all tab stops) and <STRONG>hts</STRONG> (set a tab
-       stop in the current column of every row).  If a more  com-
-       plex  sequence  is  needed  to  set  the  tabs than can be
-       described by this, the sequence can be placed  in  <STRONG>is2</STRONG>  or
+       be given as <STRONG>tbc</STRONG> (clear all tab stops) and <STRONG>hts</STRONG> (set  a  tab
+       stop  in the current column of every row).  If a more com-
+       plex sequence is needed  to  set  the  tabs  than  can  be
+       described  by  this,  the sequence can be placed in <STRONG>is2</STRONG> or
        <STRONG>if</STRONG>.
 
    <STRONG>Delays</STRONG> <STRONG>and</STRONG> <STRONG>Padding</STRONG>
-       Many  older  and  slower  terminals  don't  support either
+       Many older  and  slower  terminals  don't  support  either
        XON/XOFF or DTR handshaking, including hard copy terminals
-       and  some  very  archaic CRTs (including, for example, DEC
-       VT100s).  These may require padding characters after  cer-
+       and some very archaic CRTs (including,  for  example,  DEC
+       VT100s).   These may require padding characters after cer-
        tain cursor motions and screen changes.
 
        If the terminal uses xon/xoff handshaking for flow control
-       (that is, it automatically emits ^S back to the host  when
+       (that  is, it automatically emits ^S back to the host when
        its input buffers are close to full), set <STRONG>xon</STRONG>.  This capa-
-       bility suppresses the emission of padding.  You  can  also
-       set  it for memory-mapped console devices effectively that
-       don't have a  speed  limit.   Padding  information  should
-       still  be  included so that routines can make better deci-
+       bility  suppresses  the emission of padding.  You can also
+       set it for memory-mapped console devices effectively  that
+       don't  have  a  speed  limit.   Padding information should
+       still be included so that routines can make  better  deci-
        sions about relative costs, but actual pad characters will
        not be transmitted.
 
-       If  <STRONG>pb</STRONG> (padding baud rate) is given, padding is suppressed
-       at baud rates below the value of <STRONG>pb</STRONG>.  If the entry has  no
-       padding  baud rate, then whether padding is emitted or not
+       If <STRONG>pb</STRONG> (padding baud rate) is given, padding is  suppressed
+       at  baud rates below the value of <STRONG>pb</STRONG>.  If the entry has no
+       padding baud rate, then whether padding is emitted or  not
        is completely controlled by <STRONG>xon</STRONG>.
 
-       If the terminal requires other than a null (zero)  charac-
-       ter  as  a  pad,  then this can be given as <STRONG>pad</STRONG>.  Only the
+       If  the terminal requires other than a null (zero) charac-
+       ter as a pad, then this can be given  as  <STRONG>pad</STRONG>.   Only  the
        first character of the <STRONG>pad</STRONG> string is used.
 
 
    <STRONG>Status</STRONG> <STRONG>Lines</STRONG>
-       Some terminals have an extra `status line'  which  is  not
-       normally  used  by  software  (and thus not counted in the
+       Some  terminals  have  an extra `status line' which is not
+       normally used by software (and thus  not  counted  in  the
        terminal's <STRONG>lines</STRONG> capability).
 
-       The simplest case  is  a  status  line  which  is  cursor-
-       addressable  but  not part of the main scrolling region on
-       the screen; the Heathkit H19 has a  status  line  of  this
-       kind,  as  would  a 24-line VT100 with a 23-line scrolling
-       region set up on initialization.  This situation is  indi-
+       The  simplest  case  is  a  status  line  which is cursor-
+       addressable but not part of the main scrolling  region  on
+       the  screen;  the  Heathkit  H19 has a status line of this
+       kind, as would a 24-line VT100 with  a  23-line  scrolling
+       region  set up on initialization.  This situation is indi-
        cated by the <STRONG>hs</STRONG> capability.
 
        Some terminals with status lines need special sequences to
-       access the status line.   These  may  be  expressed  as  a
+       access  the  status  line.   These  may  be expressed as a
        string with single parameter <STRONG>tsl</STRONG> which takes the cursor to
-       a given zero-origin column on the status line.  The  capa-
+       a  given zero-origin column on the status line.  The capa-
        bility <STRONG>fsl</STRONG> must return to the main-screen cursor positions
-       before the last <STRONG>tsl</STRONG>.  You may need  to  embed  the  string
-       values  of <STRONG>sc</STRONG> (save cursor) and <STRONG>rc</STRONG> (restore cursor) in <STRONG>tsl</STRONG>
+       before  the  last  <STRONG>tsl</STRONG>.   You may need to embed the string
+       values of <STRONG>sc</STRONG> (save cursor) and <STRONG>rc</STRONG> (restore cursor) in  <STRONG>tsl</STRONG>
        and <STRONG>fsl</STRONG> to accomplish this.
 
-       The status line is normally assumed to be the  same  width
-       as  the width of the terminal.  If this is untrue, you can
+       The  status  line is normally assumed to be the same width
+       as the width of the terminal.  If this is untrue, you  can
        specify it with the numeric capability <STRONG>wsl</STRONG>.
 
-       A command to erase or blank the status line may be  speci-
+       A  command to erase or blank the status line may be speci-
        fied as <STRONG>dsl</STRONG>.
 
-       The   boolean   capability  <STRONG>eslok</STRONG>  specifies  that  escape
+       The  boolean  capability  <STRONG>eslok</STRONG>  specifies   that   escape
        sequences, tabs, etc., work ordinarily in the status line.
 
-       The  <STRONG>ncurses</STRONG>  implementation does not yet use any of these
-       capabilities.  They are documented here in case they  ever
+       The <STRONG>ncurses</STRONG> implementation does not yet use any  of  these
+       capabilities.   They are documented here in case they ever
        become important.
 
 
    <STRONG>Line</STRONG> <STRONG>Graphics</STRONG>
-       Many  terminals  have  alternate character sets useful for
-       forms-drawing.  Terminfo and <STRONG>curses</STRONG> build in  support  for
-       the  drawing  characters supported by the VT100, with some
-       characters from the AT&amp;T  4410v1  added.   This  alternate
+       Many terminals have alternate character  sets  useful  for
+       forms-drawing.   Terminfo  and <STRONG>curses</STRONG> build in support for
+       the drawing characters supported by the VT100,  with  some
+       characters  from  the  AT&amp;T  4410v1 added.  This alternate
        character set may be specified by the <STRONG>acsc</STRONG> capability.
 
+
                 <STRONG>Glyph</STRONG>             <STRONG>ACS</STRONG>            <STRONG>Ascii</STRONG>      <STRONG>VT100</STRONG>
                  <STRONG>Name</STRONG>             <STRONG>Name</STRONG>           <STRONG>Default</STRONG>    <STRONG>Name</STRONG>
        UK pound sign              ACS_STERLING   f          }
@@ -1836,7 +1879,6 @@
        bullet                     ACS_BULLET     o          ~
        checker board (stipple)    ACS_CKBOARD    :          a
        degree symbol              ACS_DEGREE     \          f
-
        diamond                    ACS_DIAMOND    +          `
        greater-than-or-equal-to   ACS_GEQUAL     &gt;          z
        greek pi                   ACS_PI         *          {
@@ -1861,60 +1903,61 @@
        upper right corner         ACS_URCORNER   +          k
        vertical line              ACS_VLINE      |          x
 
-       The  best  way to define a new device's graphics set is to
-       add a column to a copy of this table  for  your  terminal,
-       giving   the   character   which   (when  emitted  between
-       <STRONG>smacs</STRONG>/<STRONG>rmacs</STRONG> switches) will be rendered as the  correspond-
-       ing  graphic.  Then read off the VT100/your terminal char-
-       acter pairs right to left in sequence;  these  become  the
-       ACSC string.
+       The best way to define a new device's graphics set  is  to
+       add  a  column  to a copy of this table for your terminal,
+       giving  the  character   which   (when   emitted   between
+       <STRONG>smacs</STRONG>/<STRONG>rmacs</STRONG>  switches) will be rendered as the correspond-
+       ing  graphic.   Then  read  off  the  VT100/your  terminal
+       character  pairs  right  to left in sequence; these become
+       the ACSC string.
 
 
    <STRONG>Color</STRONG> <STRONG>Handling</STRONG>
-       Most  color  terminals are either `Tektronix-like' or `HP-
-       like'.  Tektronix-like terminals have a predefined set  of
-       N  colors  (where N usually 8), and can set character-cell
+       Most color terminals are either `Tektronix-like'  or  `HP-
+       like'.   Tektronix-like terminals have a predefined set of
+       N colors (where N usually 8), and can  set  character-cell
        foreground and background characters independently, mixing
-       them  into  N  * N color-pairs.  On HP-like terminals, the
+       them into N * N color-pairs.  On  HP-like  terminals,  the
        use must set each color pair up separately (foreground and
-       background  are  not  independently  settable).   Up  to M
-       color-pairs may be  set  up  from  2*M  different  colors.
+       background are  not  independently  settable).   Up  to  M
+       color-pairs  may  be  set  up  from  2*M different colors.
        ANSI-compatible terminals are Tektronix-like.
 
        Some basic color capabilities are independent of the color
        method.  The numeric capabilities <STRONG>colors</STRONG> and <STRONG>pairs</STRONG> specify
-       the  maximum numbers of colors and color-pairs that can be
-       displayed simultaneously.  The <STRONG>op</STRONG> (original  pair)  string
-       resets  foreground  and background colors to their default
-       values for the terminal.  The <STRONG>oc</STRONG> string resets all  colors
-       or  color-pairs  to their default values for the terminal.
-       Some terminals  (including  many  PC  terminal  emulators)
-       erase  screen  areas  with  the  current  background color
-       rather than the power-up default background; these  should
+       the maximum numbers of colors and color-pairs that can  be
+       displayed  simultaneously.   The <STRONG>op</STRONG> (original pair) string
+       resets foreground and background colors to  their  default
+       values  for the terminal.  The <STRONG>oc</STRONG> string resets all colors
+       or color-pairs to their default values for  the  terminal.
+       Some  terminals  (including  many  PC  terminal emulators)
+       erase screen  areas  with  the  current  background  color
+       rather  than the power-up default background; these should
        have the boolean capability <STRONG>bce</STRONG>.
 
-       To  change the current foreground or background color on a
-       Tektronix-type terminal, use <STRONG>setaf</STRONG> (set  ANSI  foreground)
-       and  <STRONG>setab</STRONG>  (set ANSI background) or <STRONG>setf</STRONG> (set foreground)
-       and <STRONG>setb</STRONG> (set background).  These take one parameter,  the
+       To change the current foreground or background color on  a
+       Tektronix-type  terminal,  use <STRONG>setaf</STRONG> (set ANSI foreground)
+       and <STRONG>setab</STRONG> (set ANSI background) or <STRONG>setf</STRONG>  (set  foreground)
+       and  <STRONG>setb</STRONG> (set background).  These take one parameter, the
        color  number.   The  SVr4  documentation  describes  only
-       <STRONG>setaf</STRONG>/<STRONG>setab</STRONG>; the XPG4 draft says  that  "If  the  terminal
+       <STRONG>setaf</STRONG>/<STRONG>setab</STRONG>;  the  XPG4  draft  says that "If the terminal
        supports ANSI escape sequences to set background and fore-
-       ground, they should be coded as <STRONG>setaf</STRONG> and  <STRONG>setab</STRONG>,  respec-
-       tively.   If  the terminal supports other escape sequences
-       to set background and foreground, they should be coded  as
-       <STRONG>setf</STRONG>  and  <STRONG>setb</STRONG>, respectively.  The <EM>vidputs()</EM> function and
-       the refresh functions use <STRONG>setaf</STRONG>  and  <STRONG>setab</STRONG>  if  they  are
+       ground,  they  should be coded as <STRONG>setaf</STRONG> and <STRONG>setab</STRONG>, respec-
+       tively.  If the terminal supports other  escape  sequences
+       to  set background and foreground, they should be coded as
+       <STRONG>setf</STRONG> and <STRONG>setb</STRONG>, respectively.  The <EM>vidputs()</EM>  function  and
+       the  refresh  functions  use  <STRONG>setaf</STRONG>  and <STRONG>setab</STRONG> if they are
        defined."
 
-       The  <STRONG>setaf</STRONG>/<STRONG>setab</STRONG>  and <STRONG>setf</STRONG>/<STRONG>setb</STRONG> capabilities take a single
+       The <STRONG>setaf</STRONG>/<STRONG>setab</STRONG> and <STRONG>setf</STRONG>/<STRONG>setb</STRONG> capabilities take  a  single
        numeric argument each.  Argument values 0-7 of <STRONG>setaf</STRONG>/<STRONG>setab</STRONG>
-       are  portably defined as follows (the middle column is the
+       are portably defined as follows (the middle column is  the
        symbolic #define available in the header for the <STRONG>curses</STRONG> or
-       <STRONG>ncurses</STRONG>  libraries).  The terminal hardware is free to map
-       these as it likes, but  the  RGB  values  indicate  normal
+       <STRONG>ncurses</STRONG> libraries).  The terminal hardware is free to  map
+       these  as  it  likes,  but  the RGB values indicate normal
        locations in color space.
 
+
              <STRONG>Color</STRONG>       <STRONG>#define</STRONG>       <STRONG>Value</STRONG>       <STRONG>RGB</STRONG>
              black     <STRONG>COLOR_BLACK</STRONG>       0     0, 0, 0
              red       <STRONG>COLOR_RED</STRONG>         1     max,0,0
@@ -1925,10 +1968,12 @@
              cyan      <STRONG>COLOR_CYAN</STRONG>        6     0,max,max
              white     <STRONG>COLOR_WHITE</STRONG>       7     max,max,max
 
-       The  argument  values of <STRONG>setf</STRONG>/<STRONG>setb</STRONG> historically correspond
+       The argument values of <STRONG>setf</STRONG>/<STRONG>setb</STRONG>  historically  correspond
        to a different mapping, i.e.,
+
              <STRONG>Color</STRONG>       <STRONG>#define</STRONG>       <STRONG>Value</STRONG>       <STRONG>RGB</STRONG>
              black     <STRONG>COLOR_BLACK</STRONG>       0     0, 0, 0
+
              blue      <STRONG>COLOR_BLUE</STRONG>        1     0,0,max
              green     <STRONG>COLOR_GREEN</STRONG>       2     0,max,0
              cyan      <STRONG>COLOR_CYAN</STRONG>        3     0,max,max
@@ -1937,38 +1982,38 @@
              yellow    <STRONG>COLOR_YELLOW</STRONG>      6     max,max,0
              white     <STRONG>COLOR_WHITE</STRONG>       7     max,max,max
        It is important to not confuse the two sets of color capa-
-       bilities;  otherwise  red/blue will be interchanged on the
+       bilities; otherwise red/blue will be interchanged  on  the
        display.
 
-       On an HP-like terminal, use <STRONG>scp</STRONG> with a  color-pair  number
+       On  an  HP-like terminal, use <STRONG>scp</STRONG> with a color-pair number
        parameter to set which color pair is current.
 
-       On  a  Tektronix-like  terminal, the capability <STRONG>ccc</STRONG> may be
-       present to indicate that colors can be modified.   If  so,
+       On a Tektronix-like terminal, the capability  <STRONG>ccc</STRONG>  may  be
+       present  to  indicate that colors can be modified.  If so,
        the <STRONG>initc</STRONG> capability will take a color number (0 to <STRONG>colors</STRONG>
-       - 1)and three more parameters which  describe  the  color.
+       -  1)and  three  more parameters which describe the color.
        These three parameters default to being interpreted as RGB
-       (Red, Green, Blue) values.  If the boolean capability  <STRONG>hls</STRONG>
+       (Red,  Green, Blue) values.  If the boolean capability <STRONG>hls</STRONG>
        is present, they are instead as HLS (Hue, Lightness, Satu-
        ration) indices.  The ranges are terminal-dependent.
 
-       On an HP-like terminal, <STRONG>initp</STRONG> may give  a  capability  for
-       changing  a  color-pair value.  It will take seven parame-
-       ters; a color-pair number (0 to <STRONG>max_pairs</STRONG> -  1),  and  two
-       triples  describing  first  background and then foreground
-       colors.  These parameters must be (Red,  Green,  Blue)  or
+       On  an  HP-like  terminal, <STRONG>initp</STRONG> may give a capability for
+       changing a color-pair value.  It will take  seven  parame-
+       ters;  a  color-pair  number (0 to <STRONG>max_pairs</STRONG> - 1), and two
+       triples describing first background  and  then  foreground
+       colors.   These  parameters  must be (Red, Green, Blue) or
        (Hue, Lightness, Saturation) depending on <STRONG>hls</STRONG>.
 
-       On  some  color terminals, colors collide with highlights.
+       On some color terminals, colors collide  with  highlights.
        You can register these collisions with the <STRONG>ncv</STRONG> capability.
-       This  is a bit-mask of attributes not to be used when col-
-       ors are enabled.  The correspondence with  the  attributes
+       This is a bit-mask of attributes not to be used when  col-
+       ors  are  enabled.  The correspondence with the attributes
        understood by <STRONG>curses</STRONG> is as follows:
 
+
                       <STRONG>Attribute</STRONG>      <STRONG>Bit</STRONG>   <STRONG>Decimal</STRONG>
                       A_STANDOUT     0     1
                       A_UNDERLINE    1     2
-
                       A_REVERSE      2     4
                       A_BLINK        3     8
                       A_DIM          4     16
@@ -1977,298 +2022,299 @@
                       A_PROTECT      7     128
                       A_ALTCHARSET   8     256
 
-       For  example,  on  many  IBM  PC  consoles,  the underline
-       attribute collides with the foreground color blue  and  is
-       not  available  in  color  mode.  These should have an <STRONG>ncv</STRONG>
+       For example,  on  many  IBM  PC  consoles,  the  underline
+       attribute  collides  with the foreground color blue and is
+       not available in color mode.  These  should  have  an  <STRONG>ncv</STRONG>
        capability of 2.
 
-       SVr4 curses does nothing with <STRONG>ncv</STRONG>, ncurses  recognizes  it
+       SVr4  curses  does nothing with <STRONG>ncv</STRONG>, ncurses recognizes it
        and optimizes the output in favor of colors.
 
 
    <STRONG>Miscellaneous</STRONG>
-       If  the terminal requires other than a null (zero) charac-
-       ter as a pad, then this can be given  as  pad.   Only  the
-       first  character of the pad string is used.  If the termi-
+       If the terminal requires other than a null (zero)  charac-
+       ter  as  a  pad,  then this can be given as pad.  Only the
+       first character of the pad string is used.  If the  termi-
        nal does not have a pad character, specify npc.  Note that
-       ncurses  implements  the  termcap-compatible  <STRONG>PC</STRONG> variable;
-       though the application may set  this  value  to  something
-       other  than  a  null,  ncurses will test <STRONG>npc</STRONG> first and use
+       ncurses implements  the  termcap-compatible  <STRONG>PC</STRONG>  variable;
+       though  the  application  may  set this value to something
+       other than a null, ncurses will test  <STRONG>npc</STRONG>  first  and  use
        napms if the terminal has no pad character.
 
-       If the terminal can move up or down half a line, this  can
-       be  indicated  with  <STRONG>hu</STRONG>  (half-line  up) and <STRONG>hd</STRONG> (half-line
+       If  the terminal can move up or down half a line, this can
+       be indicated with <STRONG>hu</STRONG>  (half-line  up)  and  <STRONG>hd</STRONG>  (half-line
        down).  This is primarily useful for superscripts and sub-
-       scripts  on  hard-copy terminals.  If a hard-copy terminal
-       can eject to the next page (form feed), give  this  as  <STRONG>ff</STRONG>
+       scripts on hard-copy terminals.  If a  hard-copy  terminal
+       can  eject  to  the next page (form feed), give this as <STRONG>ff</STRONG>
        (usually control L).
 
-       If  there is a command to repeat a given character a given
-       number of times (to save time transmitting a large  number
-       of  identical  characters)  this can be indicated with the
-       parameterized string <STRONG>rep</STRONG>.   The  first  parameter  is  the
-       character  to  be repeated and the second is the number of
-       times to repeat it.  Thus, tparm(repeat_char, 'x', 10)  is
+       If there is a command to repeat a given character a  given
+       number  of times (to save time transmitting a large number
+       of identical characters) this can be  indicated  with  the
+       parameterized  string  <STRONG>rep</STRONG>.   The  first  parameter is the
+       character to be repeated and the second is the  number  of
+       times  to repeat it.  Thus, tparm(repeat_char, 'x', 10) is
        the same as `xxxxxxxxxx'.
 
-       If  the terminal has a settable command character, such as
-       the TEKTRONIX 4025, this can be indicated with  <STRONG>cmdch</STRONG>.   A
+       If the terminal has a settable command character, such  as
+       the  TEKTRONIX  4025, this can be indicated with <STRONG>cmdch</STRONG>.  A
        prototype command character is chosen which is used in all
-       capabilities.  This character is given in the <STRONG>cmdch</STRONG>  capa-
-       bility  to  identify it.  The following convention is sup-
-       ported on some UNIX systems:  The  environment  is  to  be
-       searched  for a <STRONG>CC</STRONG> variable, and if found, all occurrences
+       capabilities.   This character is given in the <STRONG>cmdch</STRONG> capa-
+       bility to identify it.  The following convention  is  sup-
+       ported  on  some  UNIX  systems:  The environment is to be
+       searched for a <STRONG>CC</STRONG> variable, and if found, all  occurrences
        of the prototype character are replaced with the character
        in the environment variable.
 
-       Terminal  descriptions  that  do  not represent a specific
+       Terminal descriptions that do  not  represent  a  specific
        kind of known terminal, such as <EM>switch</EM>, <EM>dialup</EM>, <EM>patch</EM>, and
-       <EM>network</EM>,  should  include  the  <STRONG>gn</STRONG> (generic) capability so
-       that programs can complain that they do not  know  how  to
-       talk  to the terminal.  (This capability does not apply to
-       <EM>virtual</EM>  terminal  descriptions  for  which   the   escape
+       <EM>network</EM>, should include the  <STRONG>gn</STRONG>  (generic)  capability  so
+       that  programs  can  complain that they do not know how to
+       talk to the terminal.  (This capability does not apply  to
+       <EM>virtual</EM>   terminal   descriptions  for  which  the  escape
        sequences are known.)
 
-       If  the  terminal has a ``meta key'' which acts as a shift
-       key, setting the 8th bit  of  any  character  transmitted,
-       this  fact  can be indicated with <STRONG>km</STRONG>.  Otherwise, software
+       If the terminal has a ``meta key'' which acts as  a  shift
+       key,  setting  the  8th  bit of any character transmitted,
+       this fact can be indicated with <STRONG>km</STRONG>.   Otherwise,  software
        will assume that the 8th bit is parity and it will usually
-       be  cleared.   If strings exist to turn this ``meta mode''
+       be cleared.  If strings exist to turn this  ``meta  mode''
        on and off, they can be given as <STRONG>smm</STRONG> and <STRONG>rmm</STRONG>.
 
-       If the terminal has more lines of memory than will fit  on
-       the  screen  at once, the number of lines of memory can be
-       indicated with <STRONG>lm</STRONG>.  A value of  <STRONG>lm</STRONG>#0  indicates  that  the
+       If  the terminal has more lines of memory than will fit on
+       the screen at once, the number of lines of memory  can  be
+       indicated  with  <STRONG>lm</STRONG>.   A  value of <STRONG>lm</STRONG>#0 indicates that the
        number of lines is not fixed, but that there is still more
        memory than fits on the screen.
 
        If the terminal is one of those supported by the UNIX vir-
-       tual  terminal  protocol, the terminal number can be given
+       tual terminal protocol, the terminal number can  be  given
        as <STRONG>vt</STRONG>.
 
        Media copy strings which control an auxiliary printer con-
        nected to the terminal can be given as <STRONG>mc0</STRONG>: print the con-
-       tents of the screen, <STRONG>mc4</STRONG>: turn off the printer,  and  <STRONG>mc5</STRONG>:
-       turn  on  the  printer.   When the printer is on, all text
-       sent to the terminal will be sent to the printer.   It  is
+       tents  of  the screen, <STRONG>mc4</STRONG>: turn off the printer, and <STRONG>mc5</STRONG>:
+       turn on the printer.  When the printer  is  on,  all  text
+       sent  to  the terminal will be sent to the printer.  It is
        undefined whether the text is also displayed on the termi-
        nal screen when the printer is on.  A variation <STRONG>mc5p</STRONG> takes
        one parameter, and leaves the printer on for as many char-
-       acters as the value  of  the  parameter,  then  turns  the
-       printer  off.   The  parameter should not exceed 255.  All
+       acters  as  the  value  of  the  parameter, then turns the
+       printer off.  The parameter should not  exceed  255.   All
        text,  including  <STRONG>mc4</STRONG>,  is  transparently  passed  to  the
        printer while an <STRONG>mc5p</STRONG> is in effect.
 
 
    <STRONG>Glitches</STRONG> <STRONG>and</STRONG> <STRONG>Braindamage</STRONG>
-       Hazeltine  terminals, which do not allow `~' characters to
+       Hazeltine terminals, which do not allow `~' characters  to
        be displayed should indicate <STRONG>hz</STRONG>.
 
        Terminals which ignore a line-feed immediately after an <STRONG>am</STRONG>
        wrap, such as the Concept and vt100, should indicate <STRONG>xenl</STRONG>.
 
-       If <STRONG>el</STRONG> is required to  get  rid  of  standout  (instead  of
-       merely  writing  normal  text on top of it), <STRONG>xhp</STRONG> should be
+       If  <STRONG>el</STRONG>  is  required  to  get  rid of standout (instead of
+       merely writing normal text on top of it),  <STRONG>xhp</STRONG>  should  be
        given.
 
-       Teleray terminals, where tabs turn  all  characters  moved
-       over  to  blanks,  should  indicate <STRONG>xt</STRONG> (destructive tabs).
-       Note:   the    variable    indicating    this    is    now
-       `dest_tabs_magic_smso';  in  older  versions,  it was tel-
+       Teleray  terminals,  where  tabs turn all characters moved
+       over to blanks, should  indicate  <STRONG>xt</STRONG>  (destructive  tabs).
+       Note:    the    variable    indicating    this    is   now
+       `dest_tabs_magic_smso'; in older  versions,  it  was  tel-
        eray_glitch.  This glitch is also taken to mean that it is
-       not  possible  to  position the cursor on top of a ``magic
+       not possible to position the cursor on top  of  a  ``magic
        cookie'', that to erase standout mode it is instead neces-
        sary to use delete and insert line.  The ncurses implemen-
        tation ignores this glitch.
 
-       The Beehive Superbee, which is unable to correctly  trans-
-       mit  the escape or control C characters, has <STRONG>xsb</STRONG>, indicat-
-       ing that the f1 key is used for escape and f2 for  control
-       C.   (Only  certain Superbees have this problem, depending
-       on the ROM.)  Note that in older terminfo  versions,  this
-       capability   was   called   `beehive_glitch';  it  is  now
+       The  Beehive Superbee, which is unable to correctly trans-
+       mit the escape or control C characters, has <STRONG>xsb</STRONG>,  indicat-
+       ing  that the f1 key is used for escape and f2 for control
+       C.  (Only certain Superbees have this  problem,  depending
+       on  the  ROM.)  Note that in older terminfo versions, this
+       capability  was  called  `beehive_glitch';   it   is   now
        `no_esc_ctl_c'.
 
-       Other specific  terminal  problems  may  be  corrected  by
+       Other  specific  terminal  problems  may  be  corrected by
        adding more capabilities of the form <STRONG>x</STRONG><EM>x</EM>.
 
 
    <STRONG>Similar</STRONG> <STRONG>Terminals</STRONG>
        If there are two very similar terminals, one (the variant)
-       can be defined as being just like  the  other  (the  base)
-       with  certain  exceptions.  In the definition of the vari-
-       ant, the string capability <STRONG>use</STRONG> can be given with the  name
-       of  the  base terminal.  The capabilities given before <STRONG>use</STRONG>
-       override those in the base type named by  <STRONG>use</STRONG>.   If  there
-       are  multiple <STRONG>use</STRONG> capabilities, they are merged in reverse
-       order.  That is, the rightmost <STRONG>use</STRONG> reference is  processed
-       first,  then the one to its left, and so forth.  Capabili-
-       ties given explicitly in the entry override those  brought
+       can  be  defined  as  being just like the other (the base)
+       with certain exceptions.  In the definition of  the  vari-
+       ant,  the string capability <STRONG>use</STRONG> can be given with the name
+       of the base terminal.  The capabilities given  before  <STRONG>use</STRONG>
+       override  those  in  the base type named by <STRONG>use</STRONG>.  If there
+       are multiple <STRONG>use</STRONG> capabilities, they are merged in  reverse
+       order.   That is, the rightmost <STRONG>use</STRONG> reference is processed
+       first, then the one to its left, and so forth.   Capabili-
+       ties  given explicitly in the entry override those brought
        in by <STRONG>use</STRONG> references.
 
        A capability can be canceled by placing <STRONG>xx@</STRONG> to the left of
-       the use reference that imports it, where <EM>xx</EM> is  the  capa-
+       the  use  reference that imports it, where <EM>xx</EM> is the capa-
        bility.  For example, the entry
 
                    2621-nl, smkx@, rmkx@, use=2621,
 
-       defines  a  2621-nl  that  does  not have the <STRONG>smkx</STRONG> or <STRONG>rmkx</STRONG>
-       capabilities, and hence does not turn on the function  key
-       labels  when in visual mode.  This is useful for different
+       defines a 2621-nl that does not  have  the  <STRONG>smkx</STRONG>  or  <STRONG>rmkx</STRONG>
+       capabilities,  and hence does not turn on the function key
+       labels when in visual mode.  This is useful for  different
        modes for a terminal, or for different user preferences.
 
 
    <STRONG>Pitfalls</STRONG> <STRONG>of</STRONG> <STRONG>Long</STRONG> <STRONG>Entries</STRONG>
-       Long terminfo entries are unlikely to  be  a  problem;  to
-       date,  no  entry has even approached terminfo's 4K string-
-       table maximum.  Unfortunately,  the  termcap  translations
-       are  much  more  strictly  limited  (to  1K), thus termcap
-       translations of long terminfo entries can cause  problems.
-
-       The  man  pages for 4.3BSD and older versions of tgetent()
-       instruct the user to allocate a 1K buffer for the  termcap
-       entry.   The  entry  gets  null-terminated  by the termcap
-       library, so that makes the maximum safe length for a term-
-       cap entry 1k-1 (1023) bytes.  Depending on what the appli-
-       cation and the termcap library being used does, and  where
-       in  the  termcap  file the terminal type that tgetent() is
-       searching for is, several bad things can happen.
-
-       Some termcap libraries print a warning message or exit  if
-       they  find  an entry that's longer than 1023 bytes; others
-       don't; others truncate the entries to  1023  bytes.   Some
+       Long  terminfo  entries  are  unlikely to be a problem; to
+       date, no entry has even  approached  terminfo's  4096-byte
+       string-table maximum.  Unfortunately, the termcap transla-
+       tions are much more strictly limited (to 1023 bytes), thus
+       termcap  translations  of  long terminfo entries can cause
+       problems.
+
+       The man pages for 4.3BSD and older versions  of  <STRONG>tgetent()</STRONG>
+       instruct  the  user to allocate a 1024-byte buffer for the
+       termcap entry.  The  entry  gets  null-terminated  by  the
+       termcap library, so that makes the maximum safe length for
+       a termcap entry 1k-1 (1023) bytes.  Depending on what  the
+       application  and  the termcap library being used does, and
+       where in the termcap file the terminal type that <STRONG>tgetent()</STRONG>
+       is searching for is, several bad things can happen.
+
+       Some  termcap libraries print a warning message or exit if
+       they find an entry that's longer than 1023  bytes;  others
+       don't;  others  truncate  the entries to 1023 bytes.  Some
        application programs allocate more than the recommended 1K
        for the termcap entry; others don't.
 
        Each termcap entry has two important sizes associated with
        it: before "tc" expansion, and after "tc" expansion.  "tc"
-       is the capability that tacks on another termcap  entry  to
-       the  end  of  the current one, to add on its capabilities.
-       If a termcap entry doesn't use the "tc"  capability,  then
+       is  the  capability that tacks on another termcap entry to
+       the end of the current one, to add  on  its  capabilities.
+       If  a  termcap entry doesn't use the "tc" capability, then
        of course the two lengths are the same.
 
-       The  "before  tc  expansion"  length is the most important
-       one, because it affects more than just users of that  par-
-       ticular  terminal.   This is the length of the entry as it
+       The "before tc expansion" length  is  the  most  important
+       one,  because it affects more than just users of that par-
+       ticular terminal.  This is the length of the entry  as  it
        exists in /etc/termcap, minus the backslash-newline pairs,
-       which tgetent() strips out while reading it.  Some termcap
-       libraries strip off the final newline,  too  (GNU  termcap
+       which <STRONG>tgetent()</STRONG> strips out while reading it.  Some termcap
+       libraries  strip  off  the final newline, too (GNU termcap
        does not).  Now suppose:
 
-       *    a  termcap  entry  before expansion is more than 1023
+       *    a termcap entry before expansion is  more  than  1023
             bytes long,
 
        *    and the application has only allocated a 1k buffer,
 
-       *    and the termcap library (like the one in  BSD/OS  1.1
-            and  GNU)  reads  the whole entry into the buffer, no
-            matter what its length, to see if it's the  entry  it
+       *    and  the  termcap library (like the one in BSD/OS 1.1
+            and GNU) reads the whole entry into  the  buffer,  no
+            matter  what  its length, to see if it's the entry it
             wants,
 
-       *    and  tgetent()  is searching for a terminal type that
+       *    and <STRONG>tgetent()</STRONG> is searching for a terminal  type  that
             either is the long entry, appears in the termcap file
-            after  the  long entry, or doesn't appear in the file
-            at all (so that tgetent() has  to  search  the  whole
+            after the long entry, or doesn't appear in  the  file
+            at  all  (so  that  <STRONG>tgetent()</STRONG> has to search the whole
             termcap file).
 
-       Then  tgetent()  will overwrite memory, perhaps its stack,
-       and probably core dump the program.  Programs like  telnet
-       are  particularly  vulnerable;  modern  telnets pass along
-       values like the terminal type automatically.  The  results
-       are  almost  as  undesirable  with a termcap library, like
-       SunOS 4.1.3 and Ultrix 4.4, that prints  warning  messages
-       when  it reads an overly long termcap entry.  If a termcap
-       library truncates long entries,  like  OSF/1  3.0,  it  is
-       immune  to  dying  here but will return incorrect data for
+       Then <STRONG>tgetent()</STRONG> will overwrite memory, perhaps  its  stack,
+       and  probably core dump the program.  Programs like telnet
+       are particularly vulnerable;  modern  telnets  pass  along
+       values  like the terminal type automatically.  The results
+       are almost as undesirable with  a  termcap  library,  like
+       SunOS  4.1.3  and Ultrix 4.4, that prints warning messages
+       when it reads an overly long termcap entry.  If a  termcap
+       library  truncates  long  entries,  like  OSF/1 3.0, it is
+       immune to dying here but will return  incorrect  data  for
        the terminal.
 
        The "after tc expansion" length will have a similar effect
        to the above, but only for people who actually set TERM to
-       that terminal type, since tgetent() only does "tc"  expan-
+       that  terminal type, since <STRONG>tgetent()</STRONG> only does "tc" expan-
        sion once it's found the terminal type it was looking for,
        not while searching.
 
        In summary, a termcap entry that is longer than 1023 bytes
-       can  cause,  on  various combinations of termcap libraries
-       and applications, a  core  dump,  warnings,  or  incorrect
-       operation.   If  it's too long even before "tc" expansion,
+       can cause, on various combinations  of  termcap  libraries
+       and  applications,  a  core  dump,  warnings, or incorrect
+       operation.  If it's too long even before  "tc"  expansion,
        it will have this effect even for users of some other ter-
-       minal  types and users whose TERM variable does not have a
+       minal types and users whose TERM variable does not have  a
        termcap entry.
 
        When in -C (translate to termcap) mode, the <STRONG>ncurses</STRONG> imple-
-       mentation  of <STRONG><A HREF="tic.1.html">tic(1)</A></STRONG> issues warning messages when the pre-
-       tc length of a termcap translation is too  long.   The  -c
-       (check)  option  also checks resolved (after tc expansion)
+       mentation of <STRONG><A HREF="tic.1.html">tic(1)</A></STRONG> issues warning messages when the  pre-
+       tc  length  of  a termcap translation is too long.  The -c
+       (check) option also checks resolved (after  tc  expansion)
        lengths.
 
    <STRONG>Binary</STRONG> <STRONG>Compatibility</STRONG>
-       It is not wise to count on portability of binary  terminfo
-       entries  between commercial UNIX versions.  The problem is
-       that there are at least two versions  of  terminfo  (under
+       It  is not wise to count on portability of binary terminfo
+       entries between commercial UNIX versions.  The problem  is
+       that  there  are  at least two versions of terminfo (under
        HP-UX and AIX) which diverged from System V terminfo after
-       SVr1, and have added extension capabilities to the  string
-       table  that  (in  the binary format) collide with System V
+       SVr1,  and have added extension capabilities to the string
+       table that (in the binary format) collide  with  System  V
        and XSI Curses extensions.
 
 
 </PRE>
 <H2>EXTENSIONS</H2><PRE>
-       Some SVr4 <STRONG>curses</STRONG>  implementations,  and  all  previous  to
+       Some  SVr4  <STRONG>curses</STRONG>  implementations,  and  all previous to
        SVr4, don't interpret the %A and %O operators in parameter
        strings.
 
-       SVr4/XPG4 do not specify whether  <STRONG>msgr</STRONG>  licenses  movement
-       while  in an alternate-character-set mode (such modes may,
+       SVr4/XPG4  do  not  specify whether <STRONG>msgr</STRONG> licenses movement
+       while in an alternate-character-set mode (such modes  may,
        among other things, map CR and NL to characters that don't
-       trigger   local   motions).   The  <STRONG>ncurses</STRONG>  implementation
-       ignores <STRONG>msgr</STRONG> in <STRONG>ALTCHARSET</STRONG> mode.  This raises  the  possi-
-       bility  that  an  XPG4  implementation making the opposite
-       interpretation may need terminfo entries made for  <STRONG>ncurses</STRONG>
+       trigger  local  motions).   The   <STRONG>ncurses</STRONG>   implementation
+       ignores  <STRONG>msgr</STRONG>  in <STRONG>ALTCHARSET</STRONG> mode.  This raises the possi-
+       bility that an XPG4  implementation  making  the  opposite
+       interpretation  may need terminfo entries made for <STRONG>ncurses</STRONG>
        to have <STRONG>msgr</STRONG> turned off.
 
-       The  <STRONG>ncurses</STRONG>  library handles insert-character and insert-
+       The <STRONG>ncurses</STRONG> library handles insert-character  and  insert-
        character modes in a slightly non-standard way to get bet-
-       ter  update  efficiency.   See the <STRONG>Insert/Delete</STRONG> <STRONG>Character</STRONG>
+       ter update efficiency.  See  the  <STRONG>Insert/Delete</STRONG>  <STRONG>Character</STRONG>
        subsection above.
 
-       The  parameter  substitutions  for  <STRONG>set_clock</STRONG>   and   <STRONG>dis-</STRONG>
-       <STRONG>play_clock</STRONG>  are  not  documented in SVr4 or the XSI Curses
+       The   parameter   substitutions  for  <STRONG>set_clock</STRONG>  and  <STRONG>dis-</STRONG>
+       <STRONG>play_clock</STRONG> are not documented in SVr4 or  the  XSI  Curses
        standard.  They are deduced from the documentation for the
        AT&amp;T 505 terminal.
 
-       Be  careful  assigning  the <STRONG>kmous</STRONG> capability.  The <STRONG>ncurses</STRONG>
-       wants to interpret it as <STRONG>KEY_MOUSE</STRONG>, for use  by  terminals
-       and  emulators  like  xterm that can return mouse-tracking
+       Be careful assigning the <STRONG>kmous</STRONG>  capability.   The  <STRONG>ncurses</STRONG>
+       wants  to  interpret it as <STRONG>KEY_MOUSE</STRONG>, for use by terminals
+       and emulators like xterm that  can  return  mouse-tracking
        information in the keyboard-input stream.
 
-       Different commercial ports of terminfo and curses  support
-       different  subsets of the XSI Curses standard and (in some
+       Different  commercial ports of terminfo and curses support
+       different subsets of the XSI Curses standard and (in  some
        cases) different extension sets.  Here is a summary, accu-
        rate as of October 1995:
 
        <STRONG>SVR4,</STRONG> <STRONG>Solaris,</STRONG> <STRONG>ncurses</STRONG> -- These support all SVr4 capabili-
        ties.
 
-       <STRONG>SGI</STRONG> --  Supports  the  SVr4  set,  adds  one  undocumented
+       <STRONG>SGI</STRONG>  --  Supports  the  SVr4  set,  adds  one undocumented
        extended string capability (<STRONG>set_pglen</STRONG>).
 
-       <STRONG>SVr1,</STRONG>  <STRONG>Ultrix</STRONG> -- These support a restricted subset of ter-
-       minfo capabilities.  The booleans end with  <STRONG>xon_xoff</STRONG>;  the
-       numerics  with  <STRONG>width_status_line</STRONG>;  and  the  strings with
+       <STRONG>SVr1,</STRONG> <STRONG>Ultrix</STRONG> -- These support a restricted subset of  ter-
+       minfo  capabilities.   The booleans end with <STRONG>xon_xoff</STRONG>; the
+       numerics with  <STRONG>width_status_line</STRONG>;  and  the  strings  with
        <STRONG>prtr_non</STRONG>.
 
-       <STRONG>HP/UX</STRONG> -- Supports  the  SVr1  subset,  plus  the  SVr[234]
+       <STRONG>HP/UX</STRONG>  --  Supports  the  SVr1  subset,  plus the SVr[234]
        numerics <STRONG>num_labels</STRONG>, <STRONG>label_height</STRONG>, <STRONG>label_width</STRONG>, plus func-
-       tion keys 11 through 63,  plus  <STRONG>plab_norm</STRONG>,  <STRONG>label_on</STRONG>,  and
+       tion  keys  11  through  63, plus <STRONG>plab_norm</STRONG>, <STRONG>label_on</STRONG>, and
        <STRONG>label_off</STRONG>, plus some incompatible extensions in the string
        table.
 
-       <STRONG>AIX</STRONG> -- Supports the SVr1 subset,  plus  function  keys  11
-       through  63,  plus  a  number of incompatible string table
+       <STRONG>AIX</STRONG>  --  Supports  the  SVr1 subset, plus function keys 11
+       through 63, plus a number  of  incompatible  string  table
        extensions.
 
-       <STRONG>OSF</STRONG> -- Supports both the SVr4 set and the AIX  extensions.
+       <STRONG>OSF</STRONG>  -- Supports both the SVr4 set and the AIX extensions.
 
 
 </PRE>
@@ -2279,17 +2325,17 @@
 
 </PRE>
 <H2>SEE ALSO</H2><PRE>
-       <STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="printf.3S.html">printf(3S)</A></STRONG>, <STRONG><A HREF="term.5.html">term(5)</A></STRONG>.
+       <STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>, <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG>, <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="printf.3S.html">printf(3S)</A></STRONG>, <STRONG><A HREF="term.5.html">term(5)</A></STRONG>.
 
 
 </PRE>
 <H2>AUTHORS</H2><PRE>
-       Zeyd M. Ben-Halim, Eric  S.  Raymond,  Thomas  E.  Dickey.
+       Zeyd  M.  Ben-Halim,  Eric  S.  Raymond, Thomas E. Dickey.
        Based on pcurses by Pavel Curtis.
 
 
 
-                                                      <STRONG><A HREF="TERMINFO.5.html">TERMINFO(5)</A></STRONG>
+                                                            <STRONG><A HREF="TERMINFO.5.html">TERMINFO(5)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/tic.1m.html ncurses-5.4/doc/html/man/tic.1m.html
--- ncurses-5.4.orig/doc/html/man/tic.1m.html	2003-10-25 17:40:00.000000000 +0000
+++ ncurses-5.4/doc/html/man/tic.1m.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2004,2005 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: tic.1m,v 1.35 2003/05/11 00:32:53 tom Exp @
+  * @Id: tic.1m,v 1.38 2005/04/30 19:39:28 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>                                                   <STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>
+<STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>                                                         <STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>
 
 
 
@@ -86,7 +86,9 @@
               rather than discarding them.  Capabilities are com-
               mented by prefixing them with a period.  This  sets
               the  <STRONG>-x</STRONG> option, because it treats the commented-out
-              entries as user-defined names.
+              entries as user-defined names.  If  the  source  is
+              termcap,  accept  the 2-character names required by
+              version 6.  Otherwise these are ignored.
 
        <STRONG>-C</STRONG>     Force source translation to termcap format.   Note:
               this  differs  from the <STRONG>-C</STRONG> option of <STRONG><A HREF="infocmp.1m.html">infocmp(1m)</A></STRONG> in
@@ -111,8 +113,8 @@
               alias of a terminal matches one of the names in the
               list, the entry will be written  or  translated  as
               normal.   Otherwise no output will be generated for
-              it.  The option value  is  interpreted  as  a  file
-              containing  the  list if it contains a '/'.  (Note:
+              it.  The option value is interpreted as a file con-
+              taining  the  list  if  it  contains a '/'.  (Note:
               depending on how tic was compiled, this option  may
               require <STRONG>-I</STRONG> or <STRONG>-C</STRONG>.)
 
@@ -194,7 +196,9 @@
               is,  if you supply a capability name which <STRONG>tic</STRONG> does
               not recognize, it will  infer  its  type  (boolean,
               number  or  string)  from  the  syntax  and make an
-              extended table entry for that.
+              extended table entry for that.  User-defined  capa-
+              bility  strings  whose  name  begins with ``k'' are
+              treated as function keys.
 
        <EM>file</EM>   contains one or more <STRONG>terminfo</STRONG> terminal descriptions
               in  source format [see <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>].  Each descrip-
@@ -215,8 +219,8 @@
 
        8      List of tokens encountered by scanner
 
-       9      All  values  computed  in  construction of the hash
-              table
+       9      All values computed in construction of the hash ta-
+              ble
 
        If the debug level <EM>n</EM> is not given, it is taken to be  one.
 
@@ -301,7 +305,7 @@
 
 
 
-                                                          <STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>
+                                                                <STRONG><A HREF="tic.1m.html">tic(1m)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/toe.1m.html ncurses-5.4/doc/html/man/toe.1m.html
--- ncurses-5.4.orig/doc/html/man/toe.1m.html	2003-10-25 17:40:00.000000000 +0000
+++ ncurses-5.4/doc/html/man/toe.1m.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2003,2004 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: toe.1m,v 1.12 2003/05/11 00:32:53 tom Exp @
+  * @Id: toe.1m,v 1.13 2004/07/05 13:16:08 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="toe.1m.html">toe(1m)</A></STRONG>                                                   <STRONG><A HREF="toe.1m.html">toe(1m)</A></STRONG>
+<STRONG><A HREF="toe.1m.html">toe(1m)</A></STRONG>                                                         <STRONG><A HREF="toe.1m.html">toe(1m)</A></STRONG>
 
 
 
@@ -107,7 +107,7 @@
 
 
 
-                                                          <STRONG><A HREF="toe.1m.html">toe(1m)</A></STRONG>
+                                                                <STRONG><A HREF="toe.1m.html">toe(1m)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/tput.1.html ncurses-5.4/doc/html/man/tput.1.html
--- ncurses-5.4.orig/doc/html/man/tput.1.html	2003-10-25 17:40:00.000000000 +0000
+++ ncurses-5.4/doc/html/man/tput.1.html	2005-05-13 04:09:59.000000000 +0000
@@ -2,7 +2,7 @@
 <!-- 
   * t
   ****************************************************************************
-  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2004,2005 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            *
@@ -28,7 +28,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: tput.1,v 1.20 2003/05/11 00:32:53 tom Exp @
+  * @Id: tput.1,v 1.22 2005/01/08 17:44:26 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>                                                   <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>
+<STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>                                                         <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>
 
 
 
@@ -68,17 +68,28 @@
        values  of terminal-dependent capabilities and information
        available to the shell (see <STRONG><A HREF="sh.1.html">sh(1)</A></STRONG>), to initialize or reset
        the  terminal,  or  return  the long name of the requested
-       terminal type.  <STRONG>tput</STRONG> outputs a  string  if  the  attribute
-       (<EM>cap</EM>ability  <EM>name</EM>) is of type string, or an integer if the
-       attribute is of type integer.  If the attribute is of type
-       boolean, <STRONG>tput</STRONG> simply sets the exit code (<STRONG>0</STRONG> for TRUE if the
-       terminal has the capability, <STRONG>1</STRONG> for FALSE if it does  not),
-       and  produces no output.  Before using a value returned on
-       standard output, the user should test the exit  code  [<STRONG>$?</STRONG>,
-       see  <STRONG><A HREF="sh.1.html">sh(1)</A></STRONG>]  to  be sure it is <STRONG>0</STRONG>.  (See the <STRONG>EXIT</STRONG> <STRONG>CODES</STRONG> and
-       <STRONG>DIAGNOSTICS</STRONG> sections.)  For a complete list  of  capabili-
-       ties  and  the  <EM>capname</EM>  associated  with  each,  see <STRONG>ter-</STRONG>
-       <STRONG><A HREF="terminfo.1.html">minfo(1)</A></STRONG>.
+       terminal type.  The result depends upon  the  capability's
+       type:
+
+              string
+                   <STRONG>tput</STRONG> writes the string to the standard output.
+                   No trailing newline is supplied.
+
+              integer
+                   <STRONG>tput</STRONG> writes the decimal value to the  standard
+                   output, with a trailing newline.
+
+              boolean
+                   <STRONG>tput</STRONG>  simply sets the exit code (<STRONG>0</STRONG> for TRUE if
+                   the terminal has the capability, <STRONG>1</STRONG>  for  FALSE
+                   if  it  does  not),  and writes nothing to the
+                   standard output.
+
+       Before using a value returned on the standard output,  the
+       application  should  test  the  exit  code  (e.g., <STRONG>$?</STRONG>, see
+       <STRONG><A HREF="sh.1.html">sh(1)</A></STRONG>) to be sure it is <STRONG>0</STRONG>.  (See the <STRONG>EXIT</STRONG> <STRONG>CODES</STRONG> and  <STRONG>DIAG-</STRONG>
+       <STRONG>NOSTICS</STRONG>  sections.)   For  a complete list of capabilities
+       and the <EM>capname</EM> associated with each, see <STRONG><A HREF="terminfo.1.html">terminfo(1)</A></STRONG>.
 
        <STRONG>-T</STRONG><EM>type</EM> indicates the  <EM>type</EM>  of  terminal.   Normally  this
               option is unnecessary, because the default is taken
@@ -88,21 +99,21 @@
               be queried for the actual screen size.
 
        <EM>capname</EM>
-              indicates the attribute from the <STRONG>terminfo</STRONG> database.
-              When <STRONG>termcap</STRONG> support is compiled  in,  the  <STRONG>termcap</STRONG>
-              name for the attribute is also accepted.
-
-       <EM>parms</EM>  If the attribute is a string that takes parameters,
-              the arguments <EM>parms</EM> will be instantiated  into  the
-              string.   An all-numeric argument will be passed to
-              the attribute as a number.
-
-              Only a few  terminfo  capabilities  require  string
-              parameters;  <STRONG>tput</STRONG>  uses  a table to decide which to
-              pass as strings.  Normally <STRONG>tput</STRONG> uses <STRONG>tparm</STRONG> (3x)  to
-              perform  the  substitution.   If  no parameters are
-              given for the attribute,  <STRONG>tput</STRONG>  writes  the  string
-              without performing the substitution.
+              indicates   the   capability   from   the  <STRONG>terminfo</STRONG>
+              database.  When <STRONG>termcap</STRONG> support is compiled in, the
+              <STRONG>termcap</STRONG> name for the capability is also accepted.
+
+       <EM>parms</EM>  If  the  capability  is a string that takes parame-
+              ters, the arguments <EM>parms</EM> will be instantiated into
+              the string.
+
+              Most  parameters  are numbers.  Only a few terminfo
+              capabilities require string parameters; <STRONG>tput</STRONG> uses a
+              table to decide which to pass as strings.  Normally
+              <STRONG>tput</STRONG> uses <STRONG>tparm</STRONG> (3x) to perform  the  substitution.
+              If no parameters are given for the capability, <STRONG>tput</STRONG>
+              writes   the   string   without   performing    the
+              substitution.
 
        <STRONG>-S</STRONG>     allows  more  than one capability per invocation of
               <STRONG>tput</STRONG>.  The capabilities must be passed to <STRONG>tput</STRONG> from
@@ -112,9 +123,9 @@
               and <STRONG>1</STRONG> boolean and string exit codes (see  the  EXIT
               CODES section).
 
-              Again,  <STRONG>tput</STRONG>  uses  a  table  and  the  presence of
-              parameters in its input to decide  whether  to  use
-              <STRONG>tparm</STRONG> (3x), and how to interpret the parameters.
+              Again, <STRONG>tput</STRONG> uses a table and the presence of param-
+              eters in its input to decide whether to  use  <STRONG>tparm</STRONG>
+              (3x), and how to interpret the parameters.
 
        <STRONG>-V</STRONG>     reports  the  version  of ncurses which was used in
               this program, and exits.
@@ -222,12 +233,6 @@
        <STRONG>/usr/share/terminfo</STRONG>
               compiled terminal description database
 
-       <STRONG>/usr/include/curses.h</STRONG>
-              <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG> header file
-
-       <STRONG>/usr/include/term.h</STRONG>
-              <STRONG>terminfo</STRONG> header file
-
        <STRONG>/usr/share/tabset/*</STRONG>
               tab settings for some terminals, in a format appro-
               priate   to  be  output  to  the  terminal  (escape
@@ -279,6 +284,7 @@
        <STRONG>tput</STRONG> prints the following error messages and sets the cor-
        responding exit codes.
 
+
        exit code   error message
        ---------------------------------------------------------------------
        <STRONG>0</STRONG>           (<EM>capname</EM>  is a numeric variable that is not specified in
@@ -305,7 +311,7 @@
 
 
 
-                                                          <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>
+                                                                <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/tset.1.html ncurses-5.4/doc/html/man/tset.1.html
--- ncurses-5.4.orig/doc/html/man/tset.1.html	2003-10-25 17:40:00.000000000 +0000
+++ ncurses-5.4/doc/html/man/tset.1.html	2005-05-13 04:09:59.000000000 +0000
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <!-- 
   ****************************************************************************
-  * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
+  * Copyright (c) 1998-2004,2005 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            *
@@ -27,7 +27,7 @@
   * sale, use or other dealings in this Software without prior written       *
   * authorization.                                                           *
   ****************************************************************************
-  * @Id: tset.1,v 1.13 2003/05/11 00:32:53 tom Exp @
+  * @Id: tset.1,v 1.15 2005/03/20 18:27:09 tom Exp @
 -->
 <HTML>
 <HEAD>
@@ -40,7 +40,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>                                                   <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>
+<STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>                                                         <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>
 
 
 
@@ -52,9 +52,9 @@
 
 </PRE>
 <H2>SYNOPSIS</H2><PRE>
-       tset  [-IQVqrs]  [-]  [-e <EM>ch</EM>] [-i <EM>ch</EM>] [-k <EM>ch</EM>] [-m <EM>mapping</EM>]
+       <STRONG>tset</STRONG>  [<STRONG>-IQVcqrsw</STRONG>] [<STRONG>-</STRONG>] [<STRONG>-e</STRONG> <EM>ch</EM>] [<STRONG>-i</STRONG> <EM>ch</EM>] [<STRONG>-k</STRONG> <EM>ch</EM>] [<STRONG>-m</STRONG> <EM>mapping</EM>]
        [<EM>terminal</EM>]
-       reset [-IQVqrs] [-] [-e <EM>ch</EM>] [-i <EM>ch</EM>] [-k <EM>ch</EM>]  [-m  <EM>mapping</EM>]
+       <STRONG>reset</STRONG> [<STRONG>-IQVcqrsw</STRONG>] [<STRONG>-</STRONG>] [<STRONG>-e</STRONG> <EM>ch</EM>] [<STRONG>-i</STRONG> <EM>ch</EM>] [<STRONG>-k</STRONG> <EM>ch</EM>] [<STRONG>-m</STRONG> <EM>mapping</EM>]
        [<EM>terminal</EM>]
 
 
@@ -77,23 +77,27 @@
        4. The default terminal type, ``unknown''.
 
        If  the  terminal  type  was not specified on the command-
-       line, the <STRONG>-m</STRONG> option mappings are then applied  (see  below
-       for  more information).  Then, if the terminal type begins
-       with a question mark (``?''), the  user  is  prompted  for
-       confirmation of the terminal type.  An empty response con-
-       firms the type, or, another type can be entered to specify
-       a  new  type.  Once the terminal type has been determined,
-       the terminfo entry for the terminal is retrieved.   If  no
-       terminfo entry is found for the type, the user is prompted
-       for another terminal type.
+       line, the <STRONG>-m</STRONG> option mappings are  then  applied  (see  the
+       section  <STRONG>TERMINAL</STRONG>  <STRONG>TYPE</STRONG>  <STRONG>MAPPING</STRONG>  for  more  information).
+       Then, if the terminal type begins  with  a  question  mark
+       (``?''), the user is prompted for confirmation of the ter-
+       minal type.  An empty  response  confirms  the  type,  or,
+       another  type  can be entered to specify a new type.  Once
+       the terminal type has been determined, the terminfo  entry
+       for  the  terminal  is retrieved.  If no terminfo entry is
+       found for the type, the user is prompted for another  ter-
+       minal type.
 
-       Once the terminfo entry is  retrieved,  the  window  size,
-       backspace,  interrupt and line kill characters (among many
+       Once  the  terminfo  entry  is retrieved, the window size,
+       backspace, interrupt and line kill characters (among  many
        other things) are set and the terminal and tab initializa-
-       tion  strings  are  sent  to  the  standard  error output.
-       Finally, if the erase, interrupt and line kill  characters
-       have  changed,  or  are  not  set to their default values,
-       their values are displayed to the standard error output.
+       tion strings  are  sent  to  the  standard  error  output.
+       Finally,  if the erase, interrupt and line kill characters
+       have changed, or are not  set  to  their  default  values,
+       their  values  are displayed to the standard error output.
+       Use the <STRONG>-c</STRONG> or <STRONG>-w</STRONG> option to select only the  window  sizing
+       versus  the  other  initialization.   If neither option is
+       given, both are assumed.
 
        When invoked as <STRONG>reset</STRONG>, <STRONG>tset</STRONG> sets cooked  and  echo  modes,
        turns  off cbreak and raw modes, turns on newline transla-
@@ -112,34 +116,41 @@
 
        The options are as follows:
 
-       <STRONG>-q</STRONG>   The  terminal  type is displayed to the standard out-
-            put, and the terminal is not initialized in any  way.
-            The option `-' by itself is equivalent but archaic.
-
-       <STRONG>-e</STRONG>   Set the erase character to <EM>ch</EM>.
+       <STRONG>-c</STRONG>   Set  control  characters and modes.  <STRONG>-e</STRONG> Set the erase
+            character to <EM>ch</EM>.
 
        <STRONG>-I</STRONG>   Do  not  send  the  terminal  or  tab  initialization
             strings to the terminal.
 
-       <STRONG>-Q</STRONG>   Don't display any values for the erase, interrupt and
-            line kill characters.
-
-       <STRONG>-V</STRONG>   reports the version of ncurses which was used in this
-            program, and exits.
-
        <STRONG>-i</STRONG>   Set the interrupt character to <EM>ch</EM>.
 
        <STRONG>-k</STRONG>   Set the line kill character to <EM>ch</EM>.
 
-       <STRONG>-m</STRONG>   Specify a mapping from a port  type  to  a  terminal.
-            See below for more information.
+       <STRONG>-m</STRONG>   Specify  a  mapping  from  a port type to a terminal.
+            See the section <STRONG>TERMINAL</STRONG> <STRONG>TYPE</STRONG> <STRONG>MAPPING</STRONG> for more infor-
+            mation.
+
+       <STRONG>-Q</STRONG>   Do  not  display  any values for the erase, interrupt
+            and line kill characters.  Normally <STRONG>tset</STRONG> displays the
+            values  for  control characters which differ from the
+            system's default values.
+
+       <STRONG>-q</STRONG>   The terminal type is displayed to the  standard  out-
+            put,  and the terminal is not initialized in any way.
+            The option `-' by itself is equivalent but archaic.
 
        <STRONG>-r</STRONG>   Print the terminal type to the standard error output.
 
-       <STRONG>-s</STRONG>   Print the sequence of shell  commands  to  initialize
+       <STRONG>-s</STRONG>   Print  the  sequence  of shell commands to initialize
             the environment variable <STRONG>TERM</STRONG> to the standard output.
-            See the section below on setting the environment  for
-            details.
+            See  the section <STRONG>SETTING</STRONG> <STRONG>THE</STRONG> <STRONG>ENVIRONMENT</STRONG> for details.
+
+       <STRONG>-V</STRONG>   reports the version of ncurses which was used in this
+            program, and exits.
+
+       <STRONG>-w</STRONG>   Resize  the  window  to  match  the  size deduced via
+            <STRONG>setupterm</STRONG>.   Normally  this  has  no  effect,  unless
+            <STRONG>setupterm</STRONG> is not able to detect the window size.
 
        The arguments for the <STRONG>-e</STRONG>, <STRONG>-i</STRONG>, and <STRONG>-k</STRONG> options may either be
        entered as actual characters or by using the  `hat'  nota-
@@ -181,89 +192,88 @@
        that kind of terminal''.
 
        The argument to the <STRONG>-m</STRONG> option consists of an optional port
-       type,   an   optional  operator,  an  optional  baud  rate
-       specification, an optional colon (``:'') character  and  a
-       terminal  type.   The  port type is a string (delimited by
-       either the operator or the colon character).  The operator
-       may  be any combination of ``&gt;'', ``&lt;'', ``@'', and ``!'';
-       ``&gt;'' means greater than, ``&lt;''  means  less  than,  ``@''
-       means  equal  to  and ``!'' inverts the sense of the test.
-       The baud rate is specified as a  number  and  is  compared
-       with  the speed of the standard error output (which should
-       be the control terminal).  The terminal type is a  string.
+       type, an optional operator, an optional baud rate specifi-
+       cation, an optional colon (``:'') character and a terminal
+       type.   The port type is a string (delimited by either the
+       operator or the colon character).  The operator may be any
+       combination of ``&gt;'', ``&lt;'', ``@'', and ``!''; ``&gt;'' means
+       greater than, ``&lt;'' means less than, ``@'' means equal  to
+       and ``!'' inverts the sense of the test.  The baud rate is
+       specified as a number and is compared with  the  speed  of
+       the  standard  error  output  (which should be the control
+       terminal).  The terminal type is a string.
 
        If the terminal type is not specified on the command line,
-       the <STRONG>-m</STRONG> mappings are applied to the terminal type.  If  the
-       port  type  and  baud rate match the mapping, the terminal
-       type specified in the mapping replaces the  current  type.
-       If  more than one mapping is specified, the first applica-
+       the  <STRONG>-m</STRONG> mappings are applied to the terminal type.  If the
+       port type and baud rate match the  mapping,  the  terminal
+       type  specified  in the mapping replaces the current type.
+       If more than one mapping is specified, the first  applica-
        ble mapping is used.
 
-       For   example,    consider    the    following    mapping:
+       For    example,    consider    the    following   mapping:
        <STRONG>dialup&gt;9600:vt100</STRONG>.  The port type is dialup , the operator
-       is &gt;, the baud rate specification is 9600, and the  termi-
+       is  &gt;, the baud rate specification is 9600, and the termi-
        nal type is vt100.  The result of this mapping is to spec-
        ify that if the terminal type is <STRONG>dialup</STRONG>, and the baud rate
-       is  greater  than 9600 baud, a terminal type of <STRONG>vt100</STRONG> will
+       is greater than 9600 baud, a terminal type of  <STRONG>vt100</STRONG>  will
        be used.
 
        If no baud rate is specified, the terminal type will match
        any baud rate.  If no port type is specified, the terminal
-       type  will  match  any  port  type.    For   example,   <STRONG>-m</STRONG>
+       type   will   match   any  port  type.   For  example,  <STRONG>-m</STRONG>
        <STRONG>dialup:vt100</STRONG>  <STRONG>-m</STRONG>  <STRONG>:?xterm</STRONG>  will  cause  any  dialup  port,
        regardless of baud rate, to match the terminal type vt100,
-       and  any  non-dialup  port type to match the terminal type
-       ?xterm.  Note, because of the leading question  mark,  the
-       user  will be queried on a default port as to whether they
+       and any non-dialup port type to match  the  terminal  type
+       ?xterm.   Note,  because of the leading question mark, the
+       user will be queried on a default port as to whether  they
        are actually using an xterm terminal.
 
-       No whitespace characters are permitted in  the  <STRONG>-m</STRONG>  option
-       argument.   Also,  to avoid problems with meta-characters,
-       it is suggested that the  entire  <STRONG>-m</STRONG>  option  argument  be
-       placed  within single quote characters, and that <STRONG>csh</STRONG> users
-       insert a backslash character (``\'') before  any  exclama-
+       No  whitespace  characters  are permitted in the <STRONG>-m</STRONG> option
+       argument.  Also, to avoid problems  with  meta-characters,
+       it  is  suggested  that  the  entire <STRONG>-m</STRONG> option argument be
+       placed within single quote characters, and that <STRONG>csh</STRONG>  users
+       insert  a  backslash character (``\'') before any exclama-
        tion marks (``!'').
 
 
 </PRE>
 <H2>HISTORY</H2><PRE>
-       The  <STRONG>tset</STRONG> command appeared in BSD 3.0.  The <STRONG>ncurses</STRONG> imple-
-       mentation was lightly adapted from the 4.4BSD sources  for
+       The <STRONG>tset</STRONG> command appeared in BSD 3.0.  The <STRONG>ncurses</STRONG>  imple-
+       mentation  was lightly adapted from the 4.4BSD sources for
        a terminfo environment by Eric S. Raymond &lt;esr@snark.thyr-
        sus.com&gt;.
 
 
 </PRE>
 <H2>COMPATIBILITY</H2><PRE>
-       The <STRONG>tset</STRONG> utility has been provided  for  backward-compati-
-       bility  with  BSD  environments (under most modern UNIXes,
-       <STRONG>/etc/inittab</STRONG> and <STRONG><A HREF="getty.1.html">getty(1)</A></STRONG> can set <STRONG>TERM</STRONG>  appropriately  for
-       each  dial-up  line;  this  obviates  what was <STRONG>tset</STRONG>'s most
-       important use).  This implementation behaves  like  4.4BSD
+       The  <STRONG>tset</STRONG>  utility has been provided for backward-compati-
+       bility with BSD environments (under  most  modern  UNIXes,
+       <STRONG>/etc/inittab</STRONG>  and  <STRONG><A HREF="getty.1.html">getty(1)</A></STRONG> can set <STRONG>TERM</STRONG> appropriately for
+       each dial-up line; this  obviates  what  was  <STRONG>tset</STRONG>'s  most
+       important  use).   This implementation behaves like 4.4BSD
        tset, with a few exceptions specified here.
 
-       The  <STRONG>-S</STRONG>  option  of BSD tset no longer works; it prints an
+       The <STRONG>-S</STRONG> option of BSD tset no longer works;  it  prints  an
        error message to stderr and dies.  The <STRONG>-s</STRONG> option only sets
-       <STRONG>TERM</STRONG>,  not  <STRONG>TERMCAP</STRONG>.   Both  these changes are because the
-       <STRONG>TERMCAP</STRONG> variable is no longer  supported  under  terminfo-
+       <STRONG>TERM</STRONG>, not <STRONG>TERMCAP</STRONG>.  Both these  changes  are  because  the
+       <STRONG>TERMCAP</STRONG>  variable  is  no longer supported under terminfo-
        based <STRONG>ncurses</STRONG>, which makes <STRONG>tset</STRONG> <STRONG>-S</STRONG> useless (we made it die
        noisily rather than silently induce lossage).
 
-       There was an undocumented  4.4BSD  feature  that  invoking
+       There  was  an  undocumented  4.4BSD feature that invoking
        tset via a link named `TSET` (or via any other name begin-
-       ning with an upper-case letter) set the  terminal  to  use
+       ning  with  an  upper-case letter) set the terminal to use
        upper-case only.  This feature has been omitted.
 
-       The  <STRONG>-A</STRONG>,  <STRONG>-E</STRONG>,  <STRONG>-h</STRONG>, <STRONG>-u</STRONG> and <STRONG>-v</STRONG> options were deleted from the
-       <STRONG>tset</STRONG> utility in 4.4BSD.  None of them were  documented  in
-       4.3BSD and all are of limited utility at best.  The <STRONG>-a</STRONG>, -,
-       and                                                      -
-       options  are  similarly not documented or useful, but were
-       retained as they appear to be in widespread  use.   It  is
-       strongly recommended that any usage of these three options
-       be changed to use the <STRONG>-m</STRONG> option instead.   The  -n  option
-       remains,  but has no effect.  The <STRONG>-adnp</STRONG> options are there-
-       fore omitted from the usage summary above.
+       The <STRONG>-A</STRONG>, <STRONG>-E</STRONG>, <STRONG>-h</STRONG>, <STRONG>-u</STRONG> and <STRONG>-v</STRONG> options were  deleted  from  the
+       <STRONG>tset</STRONG>  utility  in 4.4BSD.  None of them were documented in
+       4.3BSD and all are of limited utility at  best.   The  <STRONG>-a</STRONG>,
+       <STRONG>-d</STRONG>, and <STRONG>-p</STRONG> options are similarly not documented or useful,
+       but were retained as they appear to be in widespread  use.
+       It  is  strongly recommended that any usage of these three
+       options be changed to use the <STRONG>-m</STRONG> option instead.   The  -n
+       option  remains, but has no effect.  The <STRONG>-adnp</STRONG> options are
+       therefore omitted from the usage summary above.
 
        It is still permissible to specify  the  <STRONG>-e</STRONG>,  <STRONG>-i</STRONG>,  and  <STRONG>-k</STRONG>
        options  without arguments, although it is strongly recom-
@@ -294,13 +304,13 @@
 
 </PRE>
 <H2>SEE ALSO</H2><PRE>
-       <STRONG><A HREF="csh.1.html">csh(1)</A></STRONG>, <STRONG><A HREF="sh.1.html">sh(1)</A></STRONG>, <STRONG><A HREF="stty.1.html">stty(1)</A></STRONG>, <STRONG><A HREF="tty.4.html">tty(4)</A></STRONG>, <STRONG><A HREF="termcap.5.html">termcap(5)</A></STRONG>, <STRONG><A HREF="ttys.5.html">ttys(5)</A></STRONG>, envi-
-       <STRONG><A HREF="ron.7.html">ron(7)</A></STRONG>
+       <STRONG><A HREF="csh.1.html">csh(1)</A></STRONG>, <STRONG><A HREF="sh.1.html">sh(1)</A></STRONG>, <STRONG><A HREF="stty.1.html">stty(1)</A></STRONG>, <STRONG><A HREF="setupterm.3.html">setupterm(3)</A></STRONG>, <STRONG><A HREF="tty.4.html">tty(4)</A></STRONG>,  <STRONG><A HREF="termcap.5.html">termcap(5)</A></STRONG>,
+       <STRONG><A HREF="ttys.5.html">ttys(5)</A></STRONG>, <STRONG><A HREF="environ.7.html">environ(7)</A></STRONG>
 
 
 
 
-                                                          <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>
+                                                                <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/man/wresize.3x.html ncurses-5.4/doc/html/man/wresize.3x.html
--- ncurses-5.4.orig/doc/html/man/wresize.3x.html	2004-01-11 01:46:31.000000000 +0000
+++ ncurses-5.4/doc/html/man/wresize.3x.html	2005-05-13 04:09:59.000000000 +0000
@@ -41,7 +41,7 @@
 <HR>
 <PRE>
 <!-- Manpage converted by man2html 3.0.1 -->
-<STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG>                                           <STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG>
+<STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG>                                                 <STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG>
 
 
 
@@ -97,7 +97,7 @@
 
 
 
-                                                      <STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG>
+                                                            <STRONG><A HREF="wresize.3x.html">wresize(3x)</A></STRONG>
 </PRE>
 <HR>
 <ADDRESS>
diff -Naur ncurses-5.4.orig/doc/html/ncurses-intro.html ncurses-5.4/doc/html/ncurses-intro.html
--- ncurses-5.4.orig/doc/html/ncurses-intro.html	2003-10-25 16:19:24.000000000 +0000
+++ ncurses-5.4/doc/html/ncurses-intro.html	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
 <!--
-  $Id: ncurses-intro.html,v 1.39 2003/10/25 16:19:24 tom Exp $
+  $Id: ncurses-intro.html,v 1.40 2004/06/05 19:10:10 tom Exp $
 -->
 <HTML>
 <HEAD>
@@ -687,7 +687,7 @@
 occurs a message is written to standard error and the program
 exits. Otherwise it returns a pointer to stdscr.  A few functions may be
 called before initscr (<CODE>slk_init()</CODE>, <CODE>filter()</CODE>,
-<CODE>ripofflines()</CODE>, <CODE>use_env()</CODE>, and, if you are using multiple
+<CODE>ripoffline()</CODE>, <CODE>use_env()</CODE>, and, if you are using multiple
 terminals, <CODE>newterm()</CODE>.)
 <DT> <CODE>endwin()</CODE>
 <DD> Your program should always call <CODE>endwin()</CODE> before exiting or
@@ -729,7 +729,7 @@
 structures.  <CODE>wrefresh()</CODE> copies the named window  to the physical
 terminal screen,  taking  into account  what is already
 there in  order to  do optimizations.  <CODE>refresh()</CODE> does a
-refresh of <CODE>stdscr()</CODE>.   Unless <CODE>leaveok()</CODE> has been
+refresh of <CODE>stdscr</CODE>.   Unless <CODE>leaveok()</CODE> has been
 enabled, the physical cursor of the terminal is left at  the
 location of the window's cursor.
 <DT> <CODE>doupdate()</CODE> and <CODE>wnoutrefresh(win)</CODE>
@@ -1017,7 +1017,7 @@
 
 The really clean way to handle this is to use the panels library.  If,
 when you want a screen update, you do <CODE>update_panels()</CODE>, it will
-do all the necessary <CODE>wnoutrfresh()</CODE> calls for whatever panel
+do all the necessary <CODE>wnoutrefresh()</CODE> calls for whatever panel
 stacking order you have defined.  Then you can do one <CODE>doupdate()</CODE>
 and there will be a <EM>single</EM> burst of physical I/O that will do
 all your updates.
@@ -1219,10 +1219,10 @@
 <LI>Initialize <CODE>curses</CODE>.
 <LI>Create the menu items, using <CODE>new_item()</CODE>.
 <LI>Create the menu using <CODE>new_menu()</CODE>.
-<LI>Post the menu using <CODE>menu_post()</CODE>.
+<LI>Post the menu using <CODE>post_menu()</CODE>.
 <LI>Refresh the screen.
 <LI>Process user requests via an input loop.
-<LI>Unpost the menu using <CODE>menu_unpost()</CODE>.
+<LI>Unpost the menu using <CODE>unpost_menu()</CODE>.
 <LI>Free the menu, using <CODE>free_menu()</CODE>.
 <LI>Free the items using <CODE>free_item()</CODE>.
 <LI>Terminate <CODE>curses</CODE>.
@@ -1305,8 +1305,8 @@
 By default, both windows are <CODE>stdscr</CODE>.  You can set them with the
 functions in <CODE>menu_win(3x)</CODE>. <P>
 
-When you call <CODE>menu_post()</CODE>, you write the menu to its
-subwindow.  When you call <CODE>menu_unpost()</CODE>, you erase the
+When you call <CODE>post_menu()</CODE>, you write the menu to its
+subwindow.  When you call <CODE>unpost_menu()</CODE>, you erase the
 subwindow, However, neither of these actually modifies the screen.  To
 do that, call <CODE>wrefresh()</CODE> or some equivalent.
 
@@ -1438,10 +1438,10 @@
 <LI>Initialize <CODE>curses</CODE>.
 <LI>Create the form fields, using <CODE>new_field()</CODE>.
 <LI>Create the form using <CODE>new_form()</CODE>.
-<LI>Post the form using <CODE>form_post()</CODE>.
+<LI>Post the form using <CODE>post_form()</CODE>.
 <LI>Refresh the screen.
 <LI>Process user requests via an input loop.
-<LI>Unpost the form using <CODE>form_unpost()</CODE>.
+<LI>Unpost the form using <CODE>unpost_form()</CODE>.
 <LI>Free the form, using <CODE>free_form()</CODE>.
 <LI>Free the fields using <CODE>free_field()</CODE>.
 <LI>Terminate <CODE>curses</CODE>.
@@ -1477,7 +1477,7 @@
 greater). Note that these coordinates are relative to the form
 subwindow, which will coincide with <CODE>stdscr</CODE> by default but
 need not be <CODE>stdscr</CODE> if you've done an explicit
-<CODE>set_form_window()</CODE> call. <P>
+<CODE>set_form_win()</CODE> call. <P>
 
 The fifth argument allows you to specify a number of off-screen rows.  If
 this is zero, the entire field will always be displayed.  If it is
diff -Naur ncurses-5.4.orig/doc/ncurses-intro.doc ncurses-5.4/doc/ncurses-intro.doc
--- ncurses-5.4.orig/doc/ncurses-intro.doc	2003-10-25 16:15:12.000000000 +0000
+++ ncurses-5.4/doc/ncurses-intro.doc	2005-05-13 04:09:50.000000000 +0000
@@ -609,7 +609,7 @@
           refresh()  will  clear the screen. If an error occurs a message
           is  written  to standard error and the program exits. Otherwise
           it  returns  a pointer to stdscr. A few functions may be called
-          before initscr (slk_init(), filter(), ripofflines(), use_env(),
+          before  initscr (slk_init(), filter(), ripoffline(), use_env(),
           and, if you are using multiple terminals, newterm().)
 
    endwin()
@@ -651,10 +651,9 @@
           the   terminal,   as  other  routines  merely  manipulate  data
           structures.  wrefresh() copies the named window to the physical
           terminal  screen,  taking into account what is already there in
-          order   to  do  optimizations.  refresh()  does  a  refresh  of
-          stdscr().  Unless  leaveok()  has  been  enabled,  the physical
-          cursor  of the terminal is left at the location of the window's
-          cursor.
+          order  to do optimizations. refresh() does a refresh of stdscr.
+          Unless  leaveok()  has been enabled, the physical cursor of the
+          terminal is left at the location of the window's cursor.
 
    doupdate() and wnoutrefresh(win)
           These two functions allow multiple updates with more efficiency
@@ -929,7 +928,7 @@
 
    The  really clean way to handle this is to use the panels library. If,
    when  you want a screen update, you do update_panels(), it will do all
-   the  necessary  wnoutrfresh()  calls for whatever panel stacking order
+   the  necessary  wnoutrefresh() calls for whatever panel stacking order
    you  have  defined. Then you can do one doupdate() and there will be a
    single burst of physical I/O that will do all your updates.
 
@@ -1115,10 +1114,10 @@
     1. Initialize curses.
     2. Create the menu items, using new_item().
     3. Create the menu using new_menu().
-    4. Post the menu using menu_post().
+    4. Post the menu using post_menu().
     5. Refresh the screen.
     6. Process user requests via an input loop.
-    7. Unpost the menu using menu_unpost().
+    7. Unpost the menu using unpost_menu().
     8. Free the menu, using free_menu().
     9. Free the items using free_item().
    10. Terminate curses.
@@ -1198,8 +1197,8 @@
    By  default,  both  windows  are  stdscr.  You  can  set them with the
    functions in menu_win(3x).
 
-   When  you  call menu_post(), you write the menu to its subwindow. When
-   you  call  menu_unpost(), you erase the subwindow, However, neither of
+   When  you  call post_menu(), you write the menu to its subwindow. When
+   you  call  unpost_menu(), you erase the subwindow, However, neither of
    these  actually  modifies  the  screen. To do that, call wrefresh() or
    some equivalent.
 
@@ -1315,10 +1314,10 @@
     1. Initialize curses.
     2. Create the form fields, using new_field().
     3. Create the form using new_form().
-    4. Post the form using form_post().
+    4. Post the form using post_form().
     5. Refresh the screen.
     6. Process user requests via an input loop.
-    7. Unpost the form using form_unpost().
+    7. Unpost the form using unpost_form().
     8. Free the form, using free_form().
     9. Free the fields using free_field().
    10. Terminate curses.
@@ -1350,7 +1349,7 @@
    the  screen  (the  third  and  fourth arguments, which must be zero or
    greater).  Note  that  these  coordinates  are  relative  to  the form
    subwindow,  which will coincide with stdscr by default but need not be
-   stdscr if you've done an explicit set_form_window() call.
+   stdscr if you've done an explicit set_form_win() call.
 
    The  fifth argument allows you to specify a number of off-screen rows.
    If  this  is zero, the entire field will always be displayed. If it is
@@ -2345,9 +2344,9 @@
 
    O_NL_OVERLOAD
           Enable  overloading  of  REQ_NEW_LINE  as  described in Editing
-          Requests.  The  value  of  this  option  is  ignored on dynamic
-          fields  that  have  not reached their size limit; these have no
-          last line, so the circumstances for triggering a REQ_NEXT_FIELD
+          Requests. The value of this option is ignored on dynamic fields
+          that  have  not  reached  their  size limit; these have no last
+          line,  so  the  circumstances  for  triggering a REQ_NEXT_FIELD
           never arise.
 
    O_BS_OVERLOAD
diff -Naur ncurses-5.4.orig/form/Makefile.in ncurses-5.4/form/Makefile.in
--- ncurses-5.4.orig/form/Makefile.in	2003-11-01 22:44:33.000000000 +0000
+++ ncurses-5.4/form/Makefile.in	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.40 2003/11/01 22:44:33 tom Exp $
+# $Id: Makefile.in,v 1.41 2004/05/08 19:14:14 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2003,2004 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"), #
@@ -79,8 +79,7 @@
 CPP		= @CPP@
 CFLAGS		= @CFLAGS@
 
-CPPFLAGS	= @CPPFLAGS@ \
-		  -DHAVE_CONFIG_H 
+CPPFLAGS	= -I@top_srcdir@/ncurses -DHAVE_CONFIG_H @CPPFLAGS@
 
 CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
 
@@ -116,7 +115,7 @@
 LINT_LIBS	= -lform -lncurses @LIBS@
 
 AUTO_SRC	= \
-		../include/form.h  
+		../include/form.h
 
 ################################################################################
 all \
diff -Naur ncurses-5.4.orig/form/f_trace.c ncurses-5.4/form/f_trace.c
--- ncurses-5.4.orig/form/f_trace.c	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/form/f_trace.c	2005-05-13 04:09:50.000000000 +0000
@@ -0,0 +1,70 @@
+/****************************************************************************
+ * Copyright (c) 2004 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"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *   Author:  Thomas E. Dickey                                              *
+ ****************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: f_trace.c,v 1.1 2004/12/25 23:28:49 tom Exp $")
+
+NCURSES_EXPORT(FIELD **)
+_nc_retrace_field_ptr(FIELD **code)
+{
+  T((T_RETURN("%p"), code));
+  return code;
+}
+
+NCURSES_EXPORT(FIELD *)
+_nc_retrace_field(FIELD *code)
+{
+  T((T_RETURN("%p"), code));
+  return code;
+}
+
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_retrace_field_type(FIELDTYPE *code)
+{
+  T((T_RETURN("%p"), code));
+  return code;
+}
+
+NCURSES_EXPORT(FORM *)
+_nc_retrace_form(FORM *code)
+{
+  T((T_RETURN("%p"), code));
+  return code;
+}
+
+NCURSES_EXPORT(Form_Hook)
+_nc_retrace_form_hook(Form_Hook code)
+{
+  T((T_RETURN("%p"), code));
+  return code;
+}
diff -Naur ncurses-5.4.orig/form/fld_arg.c ncurses-5.4/form/fld_arg.c
--- ncurses-5.4.orig/form/fld_arg.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_arg.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,16 +32,16 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_arg.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_arg.c,v 1.11 2004/12/25 22:20:18 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_fieldtype_arg(
 |                            FIELDTYPE *typ,
 |                            void * (* const make_arg)(va_list *),
 |                            void * (* const copy_arg)(const void *),
 |                            void   (* const free_arg)(void *) )
-|   
+|
 |   Description   :  Connects to the type additional arguments necessary
 |                    for a set_field_type call. The various function pointer
 |                    arguments are:
@@ -61,34 +61,38 @@
 |                    E_BAD_ARGUMENT - invalid argument
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_fieldtype_arg
-    (FIELDTYPE * typ,
-     void * (* const make_arg)(va_list *),
-     void * (* const copy_arg)(const void *),
-     void   (* const free_arg)(void *))
+set_fieldtype_arg(FIELDTYPE *typ,
+		  void *(*const make_arg)(va_list *),
+		  void *(*const copy_arg)(const void *),
+		  void (*const free_arg) (void *))
 {
-  if ( !typ || !make_arg )
-    RETURN(E_BAD_ARGUMENT);
+  T((T_CALLED("set_fieldtype_arg(%p,%p,%p,%p)"),
+     typ, make_arg, copy_arg, free_arg));
 
-  typ->status |= _HAS_ARGS;
-  typ->makearg = make_arg;
-  typ->copyarg = copy_arg;
-  typ->freearg = free_arg;
-  RETURN(E_OK);
+  if (typ != 0 && make_arg != (void *)0)
+    {
+      typ->status |= _HAS_ARGS;
+      typ->makearg = make_arg;
+      typ->copyarg = copy_arg;
+      typ->freearg = free_arg;
+      RETURN(E_OK);
+    }
+  RETURN(E_BAD_ARGUMENT);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  void *field_arg(const FIELD *field)
-|   
+|
 |   Description   :  Retrieve pointer to the fields argument structure.
 |
 |   Return Values :  Pointer to structure or NULL if none is defined.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void *)
-field_arg (const FIELD * field)
+field_arg(const FIELD *field)
 {
-  return Normalize_Field(field)->arg;
+  T((T_CALLED("field_arg(%p)"), field));
+  returnVoidPtr(Normalize_Field(field)->arg);
 }
 
 /* fld_arg.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_attr.c ncurses-5.4/form/fld_attr.c
--- ncurses-5.4.orig/form/fld_attr.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_attr.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_attr.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_attr.c,v 1.10 2004/12/11 21:33:15 tom Exp $")
 
 /*----------------------------------------------------------------------------
   Field-Attribute manipulation routines
@@ -42,16 +42,22 @@
 NCURSES_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\
 {\
    int res = E_BAD_ARGUMENT;\
+   T((T_CALLED("set_field_" #name "(%p,%s)"), field, _traceattr(attr)));\
    if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\
      {\
        Normalize_Field( field );\
-       if ((field -> name) != attr)\
-         {\
-           field -> name = attr;\
-           res = _nc_Synchronize_Attributes( field );\
-         }\
-       else\
-	 res = E_OK;\
+       if (field != 0) \
+	 { \
+	 if ((field -> name) != attr)\
+	   {\
+	     field -> name = attr;\
+	     res = _nc_Synchronize_Attributes( field );\
+	   }\
+	 else\
+	   {\
+	     res = E_OK;\
+	   }\
+	 }\
      }\
    RETURN(res);\
 }
@@ -60,13 +66,14 @@
 #define GEN_FIELD_ATTR_GET_FCT( name ) \
 NCURSES_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\
 {\
-   return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
+   T((T_CALLED("field_" #name "(%p)"), field));\
+   returnAttr( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_fore(FIELD *field, chtype attr)
-|   
+|
 |   Description   :  Sets the foreground of the field used to display the
 |                    field contents.
 |
@@ -74,22 +81,22 @@
 |                    E_BAD_ARGUMENT   - invalid attributes
 |                    E_SYSTEM_ERROR   - system error
 +--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_SET_FCT( fore )
+GEN_FIELD_ATTR_SET_FCT(fore)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  chtype field_fore(const FIELD *)
-|   
+|
 |   Description   :  Retrieve fields foreground attribute
 |
 |   Return Values :  The foreground attribute
 +--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_GET_FCT( fore )
+GEN_FIELD_ATTR_GET_FCT(fore)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_back(FIELD *field, chtype attr)
-|   
+|
 |   Description   :  Sets the background of the field used to display the
 |                    fields extend.
 |
@@ -97,16 +104,16 @@
 |                    E_BAD_ARGUMENT   - invalid attributes
 |                    E_SYSTEM_ERROR   - system error
 +--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_SET_FCT( back )
+GEN_FIELD_ATTR_SET_FCT(back)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform
-|   Function      :  chtype field_back(const 
-|   
+|   Function      :  chtype field_back(const
+|
 |   Description   :  Retrieve fields background attribute
 |
 |   Return Values :  The background attribute
 +--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_GET_FCT( back )
+GEN_FIELD_ATTR_GET_FCT(back)
 
 /* fld_attr.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_current.c ncurses-5.4/form/fld_current.c
--- ncurses-5.4.orig/form/fld_current.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_current.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,12 +32,12 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_current.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_current.c,v 1.11 2004/12/25 22:40:13 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_current_field(FORM  * form,FIELD * field)
-|   
+|
 |   Description   :  Set the current field of the form to the specified one.
 |
 |   Return Values :  E_OK              - success
@@ -48,46 +48,53 @@
 |                    E_SYSTEM_ERROR    - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_current_field (FORM  * form, FIELD * field)
+set_current_field(FORM *form, FIELD *field)
 {
   int err = E_OK;
 
-  if ( !form || !field )
-    RETURN(E_BAD_ARGUMENT);
-
-  if ( (form != field->form) || Field_Is_Not_Selectable(field) )
-    RETURN(E_REQUEST_DENIED);
-
-  if (!(form->status & _POSTED))
+  T((T_CALLED("set_current_field(%p,%p)"), form, field));
+  if (form == 0 || field == 0)
+    {
+      RETURN(E_BAD_ARGUMENT);
+    }
+  else if ((form != field->form) || Field_Is_Not_Selectable(field))
+    {
+      RETURN(E_REQUEST_DENIED);
+    }
+  else if ((form->status & _POSTED) == 0)
     {
       form->current = field;
       form->curpage = field->page;
-  }
+    }
   else
     {
-      if (form->status & _IN_DRIVER) 
-	err = E_BAD_STATE;
+      if ((form->status & _IN_DRIVER) != 0)
+	{
+	  err = E_BAD_STATE;
+	}
       else
 	{
 	  if (form->current != field)
 	    {
-	      if (!_nc_Internal_Validation(form)) 
-	       err = E_INVALID_FIELD;
+	      if (!_nc_Internal_Validation(form))
+		{
+		  err = E_INVALID_FIELD;
+		}
 	      else
 		{
-		  Call_Hook(form,fieldterm);
+		  Call_Hook(form, fieldterm);
 		  if (field->page != form->curpage)
 		    {
-		      Call_Hook(form,formterm);
-		      err = _nc_Set_Form_Page(form,field->page,field);
-		      Call_Hook(form,forminit);
-		    } 
-		  else 
+		      Call_Hook(form, formterm);
+		      err = _nc_Set_Form_Page(form, (int)field->page, field);
+		      Call_Hook(form, forminit);
+		    }
+		  else
 		    {
-		      err = _nc_Set_Current_Field(form,field);
+		      err = _nc_Set_Current_Field(form, field);
 		    }
-		  Call_Hook(form,fieldinit);
-		  _nc_Refresh_Current_Field(form);
+		  Call_Hook(form, fieldinit);
+		  (void)_nc_Refresh_Current_Field(form);
 		}
 	    }
 	}
@@ -96,23 +103,24 @@
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FIELD *current_field(const FORM * form)
-|   
+|
 |   Description   :  Return the current field.
 |
 |   Return Values :  Pointer to the current field.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FIELD *)
-current_field (const FORM * form)
+current_field(const FORM *form)
 {
-  return Normalize_Form(form)->current;
+  T((T_CALLED("current_field(%p)"), form));
+  returnField(Normalize_Form(form)->current);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int field_index(const FIELD * field)
-|   
+|
 |   Description   :  Return the index of the field in the field-array of
 |                    the form.
 |
@@ -120,9 +128,10 @@
 |                    -1     : fieldpointer invalid or field not connected
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-field_index (const FIELD * field)
+field_index(const FIELD *field)
 {
-  return ( (field && field->form) ? field->index : -1 );
+  T((T_CALLED("field_index(%p)"), field));
+  returnCode((field != 0 && field->form != 0) ? (int)field->index : -1);
 }
 
 /* fld_current.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_def.c ncurses-5.4/form/fld_def.c
--- ncurses-5.4.orig/form/fld_def.c	2003-11-08 21:15:02.000000000 +0000
+++ ncurses-5.4/form/fld_def.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,291 +32,319 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_def.c,v 1.17 2003/11/08 21:15:02 Jonathon.Gray Exp $")
+MODULE_ID("$Id: fld_def.c,v 1.33 2005/04/16 17:31:17 tom Exp $")
 
 /* this can't be readonly */
-static FIELD default_field = {
-  0,                       /* status */
-  0,                       /* rows   */
-  0,                       /* cols   */
-  0,                       /* frow   */
-  0,                       /* fcol   */
-  0,                       /* drows  */
-  0,                       /* dcols  */
-  0,                       /* maxgrow*/
-  0,                       /* nrow   */
-  0,                       /* nbuf   */
-  NO_JUSTIFICATION,        /* just   */
-  0,                       /* page   */
-  0,                       /* index  */
-  (int)' ',                /* pad    */
-  A_NORMAL,                /* fore   */
-  A_NORMAL,                /* back   */
-  ALL_FIELD_OPTS,          /* opts   */
-  (FIELD *)0,              /* snext  */
-  (FIELD *)0,              /* sprev  */
-  (FIELD *)0,              /* link   */
-  (FORM *)0,               /* form   */
-  (FIELDTYPE *)0,          /* type   */
-  (char *)0,               /* arg    */ 
-  (char *)0,               /* buf    */
-  (char *)0                /* usrptr */
+static FIELD default_field =
+{
+  0,				/* status  */
+  0,				/* rows    */
+  0,				/* cols    */
+  0,				/* frow    */
+  0,				/* fcol    */
+  0,				/* drows   */
+  0,				/* dcols   */
+  0,				/* maxgrow */
+  0,				/* nrow    */
+  0,				/* nbuf    */
+  NO_JUSTIFICATION,		/* just    */
+  0,				/* page    */
+  0,				/* index   */
+  (int)' ',			/* pad     */
+  A_NORMAL,			/* fore    */
+  A_NORMAL,			/* back    */
+  ALL_FIELD_OPTS,		/* opts    */
+  (FIELD *)0,			/* snext   */
+  (FIELD *)0,			/* sprev   */
+  (FIELD *)0,			/* link    */
+  (FORM *)0,			/* form    */
+  (FIELDTYPE *)0,		/* type    */
+  (char *)0,			/* arg     */
+  (FIELD_CELL *)0,		/* buf     */
+  (char *)0			/* usrptr  */
+  NCURSES_FIELD_EXTENSION
 };
 
-NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field = &default_field;
-
+NCURSES_EXPORT_VAR(FIELD *)
+_nc_Default_Field = &default_field;
+
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  TypeArgument *_nc_Make_Argument(
 |                              const FIELDTYPE *typ,
 |                              va_list *ap,
 |                              int *err )
-|   
+|
 |   Description   :  Create an argument structure for the specified type.
 |                    Use the type-dependent argument list to construct
 |                    it.
 |
 |   Return Values :  Pointer to argument structure. Maybe NULL.
-|                    In case of an error in *err an error counter is increased. 
+|                    In case of an error in *err an error counter is increased.
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(TypeArgument*)
-_nc_Make_Argument
-(const FIELDTYPE *typ, va_list *ap, int *err)
+NCURSES_EXPORT(TypeArgument *)
+_nc_Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err)
 {
-  TypeArgument *res = (TypeArgument *)0; 
+  TypeArgument *res = (TypeArgument *)0;
   TypeArgument *p;
 
-  if (typ && (typ->status & _HAS_ARGS))
+  if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
     {
-      assert(err && ap);
-      if (typ->status & _LINKED_TYPE)
+      assert(err != 0 && ap != (va_list *)0);
+      if ((typ->status & _LINKED_TYPE) != 0)
 	{
 	  p = (TypeArgument *)malloc(sizeof(TypeArgument));
-	  if (p) 
+
+	  if (p != 0)
 	    {
-	      p->left  = _nc_Make_Argument(typ->left ,ap,err);
-	      p->right = _nc_Make_Argument(typ->right,ap,err);
+	      p->left = _nc_Make_Argument(typ->left, ap, err);
+	      p->right = _nc_Make_Argument(typ->right, ap, err);
 	      return p;
 	    }
 	  else
-	    *err += 1;
-      } else 
+	    {
+	      *err += 1;
+	    }
+	}
+      else
 	{
-	  assert(typ->makearg);
-	  if ( !(res=(TypeArgument *)typ->makearg(ap)) ) 
-	    *err += 1;
+	  assert(typ->makearg != (void *)0);
+	  if (!(res = (TypeArgument *)typ->makearg(ap)))
+	    {
+	      *err += 1;
+	    }
 	}
     }
   return res;
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  TypeArgument *_nc_Copy_Argument(const FIELDTYPE *typ,
 |                                                    const TypeArgument *argp,
 |                                                    int *err )
-|   
-|   Description   :  Create a copy of an argument structure for the specified 
+|
+|   Description   :  Create a copy of an argument structure for the specified
 |                    type.
 |
 |   Return Values :  Pointer to argument structure. Maybe NULL.
-|                    In case of an error in *err an error counter is increased. 
+|                    In case of an error in *err an error counter is increased.
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(TypeArgument*)
-_nc_Copy_Argument
-    (const FIELDTYPE *typ,
-     const TypeArgument *argp, int *err)
+NCURSES_EXPORT(TypeArgument *)
+_nc_Copy_Argument(const FIELDTYPE *typ, const TypeArgument *argp, int *err)
 {
   TypeArgument *res = (TypeArgument *)0;
   TypeArgument *p;
 
-  if ( typ && (typ->status & _HAS_ARGS) )
+  if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
     {
-      assert(err && argp);
-      if (typ->status & _LINKED_TYPE)
+      assert(err != 0 && argp != 0);
+      if ((typ->status & _LINKED_TYPE) != 0)
 	{
 	  p = (TypeArgument *)malloc(sizeof(TypeArgument));
-	  if (p)
+
+	  if (p != 0)
 	    {
-	      p->left  = _nc_Copy_Argument(typ,argp->left ,err);
-	      p->right = _nc_Copy_Argument(typ,argp->right,err);
+	      p->left = _nc_Copy_Argument(typ, argp->left, err);
+	      p->right = _nc_Copy_Argument(typ, argp->right, err);
 	      return p;
 	    }
 	  *err += 1;
-      } 
-      else 
+	}
+      else
 	{
-	  if (typ->copyarg)
+	  if (typ->copyarg != (void *)0)
 	    {
-	      if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp)))) 
-		*err += 1;
+	      if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp))))
+		{
+		  *err += 1;
+		}
 	    }
 	  else
-	    res = (TypeArgument *)argp;
+	    {
+	      res = (TypeArgument *)argp;
+	    }
 	}
     }
   return res;
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  void _nc_Free_Argument(const FIELDTYPE *typ,
 |                                           TypeArgument * argp )
-|   
+|
 |   Description   :  Release memory associated with the argument structure
 |                    for the given fieldtype.
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-_nc_Free_Argument
-(const FIELDTYPE * typ, TypeArgument * argp)
+_nc_Free_Argument(const FIELDTYPE *typ, TypeArgument *argp)
 {
-  if (!typ || !(typ->status & _HAS_ARGS)) 
-    return;
-  
-  if (typ->status & _LINKED_TYPE)
-    {
-      assert(argp);
-      _nc_Free_Argument(typ->left ,argp->left );
-      _nc_Free_Argument(typ->right,argp->right);
-      free(argp);
-    } 
-  else 
+  if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
     {
-      if (typ->freearg)
-	typ->freearg((void *)argp);
+      if ((typ->status & _LINKED_TYPE) != 0)
+	{
+	  assert(argp != 0);
+	  _nc_Free_Argument(typ->left, argp->left);
+	  _nc_Free_Argument(typ->right, argp->right);
+	  free(argp);
+	}
+      else
+	{
+	  if (typ->freearg != (void *)0)
+	    {
+	      typ->freearg((void *)argp);
+	    }
+	}
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  bool _nc_Copy_Type( FIELD *dst, FIELD const *src )
-|   
+|
 |   Description   :  Copy argument structure of field src to field dst
 |
 |   Return Values :  TRUE       - copy worked
 |                    FALSE      - error occurred
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(bool)
-_nc_Copy_Type
-(FIELD *dst, FIELD const *src)
+_nc_Copy_Type(FIELD *dst, FIELD const *src)
 {
   int err = 0;
 
-  assert(dst && src);
+  assert(dst != 0 && src != 0);
 
   dst->type = src->type;
-  dst->arg  = (void *)_nc_Copy_Argument(src->type,(TypeArgument *)(src->arg),&err);
+  dst->arg = (void *)_nc_Copy_Argument(src->type, (TypeArgument *)(src->arg), &err);
 
-  if (err)
+  if (err != 0)
     {
-      _nc_Free_Argument(dst->type,(TypeArgument *)(dst->arg));
+      _nc_Free_Argument(dst->type, (TypeArgument *)(dst->arg));
       dst->type = (FIELDTYPE *)0;
-      dst->arg  = (void *)0;
+      dst->arg = (void *)0;
       return FALSE;
     }
   else
     {
-      if (dst->type) 
-	dst->type->ref++;
+      if (dst->type != 0)
+	{
+	  dst->type->ref++;
+	}
       return TRUE;
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  void _nc_Free_Type( FIELD *field )
-|   
+|
 |   Description   :  Release Argument structure for this field
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-_nc_Free_Type (FIELD *field)
+_nc_Free_Type(FIELD *field)
 {
-  assert(field);
-  if (field->type) 
-    field->type->ref--;
-  _nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
+  assert(field != 0);
+  if (field->type != 0)
+    {
+      field->type->ref--;
+    }
+  _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  FIELD *new_field( int rows, int cols, 
+|   Facility      :  libnform
+|   Function      :  FIELD *new_field( int rows, int cols,
 |                                      int frow, int fcol,
 |                                      int nrow, int nbuf )
-|   
+|
 |   Description   :  Create a new field with this many 'rows' and 'cols',
 |                    starting at 'frow/fcol' in the subwindow of the form.
 |                    Allocate 'nrow' off-screen rows and 'nbuf' additional
 |                    buffers. If an error occurs, errno is set to
-|                    
+|
 |                    E_BAD_ARGUMENT - invalid argument
 |                    E_SYSTEM_ERROR - system error
 |
 |   Return Values :  Pointer to the new field or NULL if failure.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FIELD *)
-new_field
-(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
+new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
 {
+  static const FIELD_CELL blank = BLANK;
+  static const FIELD_CELL zeros = ZEROS;
+
   FIELD *New_Field = (FIELD *)0;
   int err = E_BAD_ARGUMENT;
 
-  if (rows>0  && 
-      cols>0  && 
-      frow>=0 && 
-      fcol>=0 && 
-      nrow>=0 && 
-      nbuf>=0 &&
-      ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
-      (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
-    {
-      *New_Field       = default_field;
-      New_Field->rows  = rows;
-      New_Field->cols  = cols;
+  T((T_CALLED("new_field(%d,%d,%d,%d,%d,%d)"), rows, cols, frow, fcol, nrow, nbuf));
+  if (rows > 0 &&
+      cols > 0 &&
+      frow >= 0 &&
+      fcol >= 0 &&
+      nrow >= 0 &&
+      nbuf >= 0 &&
+      ((err = E_SYSTEM_ERROR) != 0) &&	/* trick: this resets the default error */
+      (New_Field = (FIELD *)malloc(sizeof(FIELD))) != 0)
+    {
+      *New_Field = default_field;
+      New_Field->rows = rows;
+      New_Field->cols = cols;
       New_Field->drows = rows + nrow;
       New_Field->dcols = cols;
-      New_Field->frow  = frow;
-      New_Field->fcol  = fcol;
-      New_Field->nrow  = nrow;
-      New_Field->nbuf  = nbuf;
-      New_Field->link  = New_Field;
+      New_Field->frow = frow;
+      New_Field->fcol = fcol;
+      New_Field->nrow = nrow;
+      New_Field->nbuf = nbuf;
+      New_Field->link = New_Field;
+
+#if USE_WIDEC_SUPPORT
+      New_Field->working = newpad(1, Buffer_Length(New_Field) + 1);
+      New_Field->expanded = (char **)calloc(1 + (unsigned)rows, sizeof(char *));
+#endif
 
-      if (_nc_Copy_Type(New_Field,&default_field))
+      if (_nc_Copy_Type(New_Field, &default_field))
 	{
 	  size_t len;
 
 	  len = Total_Buffer_Size(New_Field);
-	  if ((New_Field->buf = (char *)malloc(len)))
+	  if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
 	    {
 	      /* Prefill buffers with blanks and insert terminating zeroes
-		 between buffers */
-	      int i;
+	         between buffers */
+	      int i, j;
+	      int cells = Buffer_Length(New_Field);
 
-	      memset(New_Field->buf,' ',len);
-	      for(i=0;i<=New_Field->nbuf;i++)
+	      for (i = 0; i <= New_Field->nbuf; i++)
 		{
-		  New_Field->buf[(New_Field->drows*New_Field->cols+1)*(i+1)-1]
-		    = '\0';
+		  FIELD_CELL *buffer = &(New_Field->buf[(cells + 1) * i]);
+
+		  for (j = 0; j < cells; ++j)
+		    {
+		      buffer[j] = blank;
+		    }
+		  buffer[j] = zeros;
 		}
-	      return New_Field;
+	      returnField(New_Field);
 	    }
 	}
     }
 
-  if (New_Field) 
+  if (New_Field)
     free_field(New_Field);
-  
-  SET_ERROR( err );
-  return (FIELD *)0;
+
+  SET_ERROR(err);
+  returnField((FIELD *)0);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int free_field( FIELD *field )
-|   
+|
 |   Description   :  Frees the storage allocated for the field.
 |
 |   Return Values :  E_OK           - success
@@ -324,28 +352,45 @@
 |                    E_CONNECTED    - field is connected
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-free_field (FIELD * field)
+free_field(FIELD *field)
 {
-  if (!field) 
-    RETURN(E_BAD_ARGUMENT);
-
-  if (field->form)
-    RETURN(E_CONNECTED);
-  
-  if (field == field->link)
+  T((T_CALLED("free_field(%p)"), field));
+  if (!field)
     {
-      if (field->buf) 
+      RETURN(E_BAD_ARGUMENT);
+    }
+  else if (field->form != 0)
+    {
+      RETURN(E_CONNECTED);
+    }
+  else if (field == field->link)
+    {
+      if (field->buf != 0)
 	free(field->buf);
     }
-  else 
+  else
     {
       FIELD *f;
 
-      for(f=field;f->link != field;f = f->link) 
-	{}
+      for (f = field; f->link != field; f = f->link)
+	{
+	}
       f->link = field->link;
     }
   _nc_Free_Type(field);
+#if USE_WIDEC_SUPPORT
+  if (field->expanded != 0)
+    {
+      int n;
+
+      for (n = 0; n <= field->nbuf; ++n)
+	{
+	  FreeIfNeeded(field->expanded[n]);
+	}
+      free(field->expanded);
+      (void)delwin(field->working);
+    }
+#endif
   free(field);
   RETURN(E_OK);
 }
diff -Naur ncurses-5.4.orig/form/fld_dup.c ncurses-5.4/form/fld_dup.c
--- ncurses-5.4.orig/form/fld_dup.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_dup.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,67 +32,69 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_dup.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_dup.c,v 1.10 2004/12/25 22:24:10 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FIELD *dup_field(FIELD *field, int frow, int fcol)
-|   
+|
 |   Description   :  Duplicates the field at the specified position. All
 |                    field attributes and the buffers are copied.
 |                    If an error occurs, errno is set to
-|                    
+|
 |                    E_BAD_ARGUMENT - invalid argument
 |                    E_SYSTEM_ERROR - system error
 |
 |   Return Values :  Pointer to the new field or NULL if failure
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FIELD *)
-dup_field (FIELD * field, int frow, int fcol)
+dup_field(FIELD *field, int frow, int fcol)
 {
   FIELD *New_Field = (FIELD *)0;
   int err = E_BAD_ARGUMENT;
 
-  if (field && (frow>=0) && (fcol>=0) && 
-      ((err=E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */
-      (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
+  T((T_CALLED("dup_field(%p,%d,%d)"), field, frow, fcol));
+  if (field && (frow >= 0) && (fcol >= 0) &&
+      ((err = E_SYSTEM_ERROR) != 0) &&	/* trick : this resets the default error */
+      (New_Field = (FIELD *)malloc(sizeof(FIELD))))
     {
-      *New_Field         = *_nc_Default_Field;
-      New_Field->frow    = frow;
-      New_Field->fcol    = fcol;
-      New_Field->link    = New_Field;
-      New_Field->rows    = field->rows;
-      New_Field->cols    = field->cols;
-      New_Field->nrow    = field->nrow;
-      New_Field->drows   = field->drows;
-      New_Field->dcols   = field->dcols;
+      *New_Field = *_nc_Default_Field;
+      New_Field->frow = frow;
+      New_Field->fcol = fcol;
+      New_Field->link = New_Field;
+      New_Field->rows = field->rows;
+      New_Field->cols = field->cols;
+      New_Field->nrow = field->nrow;
+      New_Field->drows = field->drows;
+      New_Field->dcols = field->dcols;
       New_Field->maxgrow = field->maxgrow;
-      New_Field->nbuf    = field->nbuf;
-      New_Field->just    = field->just;
-      New_Field->fore    = field->fore;
-      New_Field->back    = field->back;
-      New_Field->pad     = field->pad;
-      New_Field->opts    = field->opts;
-      New_Field->usrptr  = field->usrptr;
+      New_Field->nbuf = field->nbuf;
+      New_Field->just = field->just;
+      New_Field->fore = field->fore;
+      New_Field->back = field->back;
+      New_Field->pad = field->pad;
+      New_Field->opts = field->opts;
+      New_Field->usrptr = field->usrptr;
 
-      if (_nc_Copy_Type(New_Field,field))
+      if (_nc_Copy_Type(New_Field, field))
 	{
-	  size_t len;
+	  size_t i, len;
 
 	  len = Total_Buffer_Size(New_Field);
-	  if ( (New_Field->buf=(char *)malloc(len)) )
+	  if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
 	    {
-	      memcpy(New_Field->buf,field->buf,len);
-	      return New_Field;
+	      for (i = 0; i < len; ++i)
+		New_Field->buf[i] = field->buf[i];
+	      returnField(New_Field);
 	    }
 	}
     }
 
-  if (New_Field) 
+  if (New_Field)
     free_field(New_Field);
 
   SET_ERROR(err);
-  return (FIELD *)0;
+  returnField((FIELD *)0);
 }
 
 /* fld_dup.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_ftchoice.c ncurses-5.4/form/fld_ftchoice.c
--- ncurses-5.4.orig/form/fld_ftchoice.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_ftchoice.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_ftchoice.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_ftchoice.c,v 1.9 2004/12/11 21:44:57 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -47,12 +47,13 @@
 |                    E_BAD_ARGUMENT - invalid arguments
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_fieldtype_choice
-    (FIELDTYPE * typ,
-     bool (* const next_choice) (FIELD *,const void *),
-     bool (* const prev_choice) (FIELD *,const void *))
+set_fieldtype_choice(FIELDTYPE *typ,
+		     bool (*const next_choice) (FIELD *, const void *),
+		     bool (*const prev_choice) (FIELD *, const void *))
 {
-  if ( !typ || !next_choice || !prev_choice ) 
+  T((T_CALLED("set_fieldtype_choice(%p,%p,%p)"), typ, next_choice, prev_choice));
+
+  if (!typ || !next_choice || !prev_choice)
     RETURN(E_BAD_ARGUMENT);
 
   typ->status |= _HAS_CHOICE;
diff -Naur ncurses-5.4.orig/form/fld_ftlink.c ncurses-5.4/form/fld_ftlink.c
--- ncurses-5.4.orig/form/fld_ftlink.c	2003-11-08 20:45:36.000000000 +0000
+++ ncurses-5.4/form/fld_ftlink.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_ftlink.c,v 1.8 2003/11/08 20:45:36 tom Exp $")
+MODULE_ID("$Id: fld_ftlink.c,v 1.11 2004/12/25 22:24:10 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -49,37 +49,38 @@
 |   Return Values :  Fieldtype pointer or NULL if error occurred.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FIELDTYPE *)
-link_fieldtype 
-(FIELDTYPE * type1, FIELDTYPE * type2)
+link_fieldtype(FIELDTYPE *type1, FIELDTYPE *type2)
 {
   FIELDTYPE *nftyp = (FIELDTYPE *)0;
 
-  if ( type1 && type2 )
+  T((T_CALLED("link_fieldtype(%p,%p)"), type1, type2));
+  if (type1 && type2)
     {
       nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
+
       if (nftyp)
 	{
 	  *nftyp = *_nc_Default_FieldType;
 	  nftyp->status |= _LINKED_TYPE;
-	  if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS) )
+	  if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS))
 	    nftyp->status |= _HAS_ARGS;
-	  if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE) )
+	  if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE))
 	    nftyp->status |= _HAS_CHOICE;
-	  nftyp->left  = type1;
-	  nftyp->right = type2; 
+	  nftyp->left = type1;
+	  nftyp->right = type2;
 	  type1->ref++;
 	  type2->ref++;
 	}
       else
 	{
-	  SET_ERROR( E_SYSTEM_ERROR );
+	  SET_ERROR(E_SYSTEM_ERROR);
 	}
     }
   else
     {
-      SET_ERROR( E_BAD_ARGUMENT );
+      SET_ERROR(E_BAD_ARGUMENT);
     }
-  return nftyp;
+  returnFieldType(nftyp);
 }
 
 /* fld_ftlink.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_info.c ncurses-5.4/form/fld_info.c
--- ncurses-5.4.orig/form/fld_info.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_info.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_info.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_info.c,v 1.10 2004/12/11 22:24:57 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -47,24 +47,35 @@
 |                    E_BAD_ARGUMENT - invalid field pointer
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-field_info 
-    (const FIELD *field,
-     int *rows, int *cols, 
-     int *frow, int *fcol, 
-     int *nrow, int *nbuf)
+field_info(const FIELD *field,
+	   int *rows, int *cols,
+	   int *frow, int *fcol,
+	   int *nrow, int *nbuf)
 {
-  if (!field) 
+  T((T_CALLED("field_info(%p,%p,%p,%p,%p,%p,%p)"),
+     field,
+     rows, cols,
+     frow, fcol,
+     nrow, nbuf));
+
+  if (!field)
     RETURN(E_BAD_ARGUMENT);
 
-  if (rows) *rows = field->rows;
-  if (cols) *cols = field->cols;
-  if (frow) *frow = field->frow;
-  if (fcol) *fcol = field->fcol;
-  if (nrow) *nrow = field->nrow;
-  if (nbuf) *nbuf = field->nbuf;
+  if (rows)
+    *rows = field->rows;
+  if (cols)
+    *cols = field->cols;
+  if (frow)
+    *frow = field->frow;
+  if (fcol)
+    *fcol = field->fcol;
+  if (nrow)
+    *nrow = field->nrow;
+  if (nbuf)
+    *nbuf = field->nbuf;
   RETURN(E_OK);
 }
-	
+
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
 |   Function      :  int dynamic_field_info(const FIELD *field,
@@ -78,15 +89,19 @@
 |                    E_BAD_ARGUMENT - invalid argument
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-dynamic_field_info
-(const FIELD *field, int *drows, int *dcols, int *maxgrow)
+dynamic_field_info(const FIELD *field, int *drows, int *dcols, int *maxgrow)
 {
+  T((T_CALLED("dynamic_field_info(%p,%p,%p,%p)"), field, drows, dcols, maxgrow));
+
   if (!field)
     RETURN(E_BAD_ARGUMENT);
 
-  if (drows)   *drows   = field->drows;
-  if (dcols)   *dcols   = field->dcols;
-  if (maxgrow) *maxgrow = field->maxgrow;
+  if (drows)
+    *drows = field->drows;
+  if (dcols)
+    *dcols = field->dcols;
+  if (maxgrow)
+    *maxgrow = field->maxgrow;
 
   RETURN(E_OK);
 }
diff -Naur ncurses-5.4.orig/form/fld_just.c ncurses-5.4/form/fld_just.c
--- ncurses-5.4.orig/form/fld_just.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_just.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_just.c,v 1.8 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_just.c,v 1.11 2004/12/11 22:55:48 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -45,20 +45,22 @@
 |                    E_SYSTEM_ERROR  - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_field_just (FIELD * field, int just)
+set_field_just(FIELD *field, int just)
 {
   int res = E_BAD_ARGUMENT;
 
-  if ((just==NO_JUSTIFICATION)  ||
-      (just==JUSTIFY_LEFT)	||
-      (just==JUSTIFY_CENTER)	||
-      (just==JUSTIFY_RIGHT)	)
+  T((T_CALLED("set_field_just(%p,%d)"), field, just));
+
+  if ((just == NO_JUSTIFICATION) ||
+      (just == JUSTIFY_LEFT) ||
+      (just == JUSTIFY_CENTER) ||
+      (just == JUSTIFY_RIGHT))
     {
-      Normalize_Field( field );
+      Normalize_Field(field);
       if (field->just != just)
 	{
 	  field->just = just;
-	  res = _nc_Synchronize_Attributes( field );
+	  res = _nc_Synchronize_Attributes(field);
 	}
       else
 	res = E_OK;
@@ -75,9 +77,10 @@
 |   Return Values :  The justification type.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-field_just (const FIELD * field)
+field_just(const FIELD *field)
 {
-  return Normalize_Field( field )->just;
+  T((T_CALLED("field_just(%p)"), field));
+  returnCode(Normalize_Field(field)->just);
 }
 
 /* fld_just.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_link.c ncurses-5.4/form/fld_link.c
--- ncurses-5.4.orig/form/fld_link.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_link.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_link.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_link.c,v 1.9 2004/12/25 22:24:10 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -49,43 +49,47 @@
 |   Return Values :  Pointer to the new field or NULL if failure
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FIELD *)
-link_field (FIELD * field, int frow, int fcol)
+link_field(FIELD *field, int frow, int fcol)
 {
   FIELD *New_Field = (FIELD *)0;
   int err = E_BAD_ARGUMENT;
 
-  if (field && (frow>=0) && (fcol>=0) &&
-      ((err=E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
-      (New_Field = (FIELD *)malloc(sizeof(FIELD))) )
+  T((T_CALLED("link_field(%p,%d,%d)"), field, frow, fcol));
+  if (field && (frow >= 0) && (fcol >= 0) &&
+      ((err = E_SYSTEM_ERROR) != 0) &&	/* trick: this resets the default error */
+      (New_Field = (FIELD *)malloc(sizeof(FIELD))))
     {
-      *New_Field        = *_nc_Default_Field;
-      New_Field->frow   = frow;
-      New_Field->fcol   = fcol;
-      New_Field->link   = field->link;
-      field->link       = New_Field;
-      New_Field->buf    = field->buf;
-      New_Field->rows   = field->rows;
-      New_Field->cols   = field->cols;
-      New_Field->nrow   = field->nrow;
-      New_Field->nbuf   = field->nbuf;
-      New_Field->drows  = field->drows;
-      New_Field->dcols  = field->dcols;
-      New_Field->maxgrow= field->maxgrow;
-      New_Field->just   = field->just;
-      New_Field->fore   = field->fore;
-      New_Field->back   = field->back;
-      New_Field->pad    = field->pad;
-      New_Field->opts   = field->opts;
+      *New_Field = *_nc_Default_Field;
+      New_Field->frow = frow;
+      New_Field->fcol = fcol;
+
+      New_Field->link = field->link;
+      field->link = New_Field;
+
+      New_Field->buf = field->buf;
+      New_Field->rows = field->rows;
+      New_Field->cols = field->cols;
+      New_Field->nrow = field->nrow;
+      New_Field->nbuf = field->nbuf;
+      New_Field->drows = field->drows;
+      New_Field->dcols = field->dcols;
+      New_Field->maxgrow = field->maxgrow;
+      New_Field->just = field->just;
+      New_Field->fore = field->fore;
+      New_Field->back = field->back;
+      New_Field->pad = field->pad;
+      New_Field->opts = field->opts;
       New_Field->usrptr = field->usrptr;
-      if (_nc_Copy_Type(New_Field,field)) 
-	return New_Field;
+
+      if (_nc_Copy_Type(New_Field, field))
+	returnField(New_Field);
     }
 
-  if (New_Field) 
+  if (New_Field)
     free_field(New_Field);
 
-  SET_ERROR( err );
-  return (FIELD *)0;
+  SET_ERROR(err);
+  returnField((FIELD *)0);
 }
 
 /* fld_link.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_max.c ncurses-5.4/form/fld_max.c
--- ncurses-5.4.orig/form/fld_max.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_max.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_max.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_max.c,v 1.9 2004/12/11 21:51:54 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -45,17 +45,19 @@
 |                    E_BAD_ARGUMENT - invalid argument
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_max_field (FIELD *field, int maxgrow)
+set_max_field(FIELD *field, int maxgrow)
 {
-  if (!field || (maxgrow<0))
+  T((T_CALLED("set_max_field(%p,%d)"), field, maxgrow));
+
+  if (!field || (maxgrow < 0))
     RETURN(E_BAD_ARGUMENT);
   else
     {
       bool single_line_field = Single_Line_Field(field);
 
-      if (maxgrow>0)
+      if (maxgrow > 0)
 	{
-	  if (( single_line_field && (maxgrow < field->dcols)) ||
+	  if ((single_line_field && (maxgrow < field->dcols)) ||
 	      (!single_line_field && (maxgrow < field->drows)))
 	    RETURN(E_BAD_ARGUMENT);
 	}
@@ -63,13 +65,13 @@
       field->status &= ~_MAY_GROW;
       if (!(field->opts & O_STATIC))
 	{
-	  if ((maxgrow==0) ||
-	      ( single_line_field && (field->dcols < maxgrow)) ||
+	  if ((maxgrow == 0) ||
+	      (single_line_field && (field->dcols < maxgrow)) ||
 	      (!single_line_field && (field->drows < maxgrow)))
 	    field->status |= _MAY_GROW;
 	}
     }
   RETURN(E_OK);
 }
-		  
+
 /* fld_max.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_move.c ncurses-5.4/form/fld_move.c
--- ncurses-5.4.orig/form/fld_move.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_move.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_move.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_move.c,v 1.9 2004/12/11 21:52:44 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -46,12 +46,14 @@
 |                    E_CONNECTED     - field is connected
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-move_field (FIELD *field, int frow, int fcol)
+move_field(FIELD *field, int frow, int fcol)
 {
-  if ( !field || (frow<0) || (fcol<0) ) 
+  T((T_CALLED("move_field(%p,%d,%d)"), field, frow, fcol));
+
+  if (!field || (frow < 0) || (fcol < 0))
     RETURN(E_BAD_ARGUMENT);
 
-  if (field->form) 
+  if (field->form)
     RETURN(E_CONNECTED);
 
   field->frow = frow;
@@ -60,4 +62,3 @@
 }
 
 /* fld_move.c ends here */
-
diff -Naur ncurses-5.4.orig/form/fld_newftyp.c ncurses-5.4/form/fld_newftyp.c
--- ncurses-5.4.orig/form/fld_newftyp.c	2003-11-08 20:45:36.000000000 +0000
+++ ncurses-5.4/form/fld_newftyp.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,49 +32,52 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fld_newftyp.c,v 1.9 2003/11/08 20:45:36 tom Exp $")
+MODULE_ID("$Id: fld_newftyp.c,v 1.13 2004/12/25 22:24:10 tom Exp $")
 
-static FIELDTYPE const default_fieldtype = {
-  0,                   /* status                                      */
-  0L,                  /* reference count                             */
-  (FIELDTYPE *)0,      /* pointer to left  operand                    */
-  (FIELDTYPE *)0,      /* pointer to right operand                    */
-  NULL,                /* makearg function                            */
-  NULL,                /* copyarg function                            */
-  NULL,                /* freearg function                            */
-  NULL,                /* field validation function                   */
-  NULL,                /* Character check function                    */
-  NULL,                /* enumerate next function                     */
-  NULL                 /* enumerate previous function                 */
+static FIELDTYPE const default_fieldtype =
+{
+  0,				/* status                                      */
+  0L,				/* reference count                             */
+  (FIELDTYPE *)0,		/* pointer to left  operand                    */
+  (FIELDTYPE *)0,		/* pointer to right operand                    */
+  NULL,				/* makearg function                            */
+  NULL,				/* copyarg function                            */
+  NULL,				/* freearg function                            */
+  NULL,				/* field validation function                   */
+  NULL,				/* Character check function                    */
+  NULL,				/* enumerate next function                     */
+  NULL				/* enumerate previous function                 */
 };
 
-NCURSES_EXPORT_VAR(const FIELDTYPE*) _nc_Default_FieldType = &default_fieldtype;
-
+NCURSES_EXPORT_VAR(const FIELDTYPE *)
+_nc_Default_FieldType = &default_fieldtype;
+
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FIELDTYPE *new_fieldtype(
 |                       bool (* const field_check)(FIELD *,const void *),
-|                       bool (* const char_check) (int, const void *) ) 
-|   
+|                       bool (* const char_check) (int, const void *) )
+|
 |   Description   :  Create a new fieldtype. The application programmer must
 |                    write a field_check and a char_check function and give
 |                    them as input to this call.
-|                    If an error occurs, errno is set to                    
+|                    If an error occurs, errno is set to
 |                       E_BAD_ARGUMENT  - invalid arguments
 |                       E_SYSTEM_ERROR  - system error (no memory)
 |
 |   Return Values :  Fieldtype pointer or NULL if error occurred
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FIELDTYPE *)
-new_fieldtype (
- bool (* const field_check)(FIELD *,const void *),
- bool (* const char_check) (int,const void *) )
+new_fieldtype(bool (*const field_check) (FIELD *, const void *),
+	      bool (*const char_check) (int, const void *))
 {
   FIELDTYPE *nftyp = (FIELDTYPE *)0;
-  
-  if ( (field_check) || (char_check) )
+
+  T((T_CALLED("new_fieldtype(%p,%p)"), field_check, char_check));
+  if ((field_check) || (char_check))
     {
       nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
+
       if (nftyp)
 	{
 	  *nftyp = default_fieldtype;
@@ -83,20 +86,20 @@
 	}
       else
 	{
-	  SET_ERROR( E_SYSTEM_ERROR );
+	  SET_ERROR(E_SYSTEM_ERROR);
 	}
     }
   else
     {
-      SET_ERROR( E_BAD_ARGUMENT );
+      SET_ERROR(E_BAD_ARGUMENT);
     }
-  return nftyp;
+  returnFieldType(nftyp);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int free_fieldtype(FIELDTYPE *typ)
-|   
+|
 |   Description   :  Release the memory associated with this fieldtype.
 |
 |   Return Values :  E_OK            - success
@@ -104,12 +107,14 @@
 |                    E_BAD_ARGUMENT  - invalid fieldtype pointer
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-free_fieldtype (FIELDTYPE *typ)
+free_fieldtype(FIELDTYPE *typ)
 {
+  T((T_CALLED("free_fieldtype(%p)"), typ));
+
   if (!typ)
     RETURN(E_BAD_ARGUMENT);
 
-  if (typ->ref!=0)
+  if (typ->ref != 0)
     RETURN(E_CONNECTED);
 
   if (typ->status & _RESIDENT)
@@ -117,8 +122,10 @@
 
   if (typ->status & _LINKED_TYPE)
     {
-      if (typ->left ) typ->left->ref--;
-      if (typ->right) typ->right->ref--;
+      if (typ->left)
+	typ->left->ref--;
+      if (typ->right)
+	typ->right->ref--;
     }
   free(typ);
   RETURN(E_OK);
diff -Naur ncurses-5.4.orig/form/fld_opts.c ncurses-5.4/form/fld_opts.c
--- ncurses-5.4.orig/form/fld_opts.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_opts.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_opts.c,v 1.9 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_opts.c,v 1.11 2004/12/11 21:55:46 tom Exp $")
 
 /*----------------------------------------------------------------------------
   Field-Options manipulation routines
@@ -51,12 +51,15 @@
 |                    E_SYSTEM_ERROR  - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_field_opts (FIELD * field, Field_Options opts)
+set_field_opts(FIELD *field, Field_Options opts)
 {
   int res = E_BAD_ARGUMENT;
+
+  T((T_CALLED("set_field_opts(%p,%d)"), field, opts));
+
   opts &= ALL_FIELD_OPTS;
   if (!(opts & ~ALL_FIELD_OPTS))
-    res = _nc_Synchronize_Options( Normalize_Field(field), opts );
+    res = _nc_Synchronize_Options(Normalize_Field(field), opts);
   RETURN(res);
 }
 
@@ -69,9 +72,11 @@
 |   Return Values :  The options.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(Field_Options)
-field_opts (const FIELD * field)
+field_opts(const FIELD *field)
 {
-  return ALL_FIELD_OPTS & Normalize_Field( field )->opts;
+  T((T_CALLED("field_opts(%p)"), field));
+
+  returnCode(ALL_FIELD_OPTS & Normalize_Field(field)->opts);
 }
 
 /*---------------------------------------------------------------------------
@@ -87,15 +92,17 @@
 |                    E_SYSTEM_ERROR  - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-field_opts_on (FIELD * field, Field_Options opts)
+field_opts_on(FIELD *field, Field_Options opts)
 {
   int res = E_BAD_ARGUMENT;
 
+  T((T_CALLED("field_opts_on(%p,%d)"), field, opts));
+
   opts &= ALL_FIELD_OPTS;
   if (!(opts & ~ALL_FIELD_OPTS))
     {
-      Normalize_Field( field );
-      res = _nc_Synchronize_Options( field, field->opts | opts );
+      Normalize_Field(field);
+      res = _nc_Synchronize_Options(field, field->opts | opts);
     }
   RETURN(res);
 }
@@ -113,17 +120,19 @@
 |                    E_SYSTEM_ERROR  - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-field_opts_off (FIELD  * field, Field_Options opts)
+field_opts_off(FIELD *field, Field_Options opts)
 {
   int res = E_BAD_ARGUMENT;
 
+  T((T_CALLED("field_opts_off(%p,%d)"), field, opts));
+
   opts &= ALL_FIELD_OPTS;
   if (!(opts & ~ALL_FIELD_OPTS))
     {
-      Normalize_Field( field );
-      res = _nc_Synchronize_Options( field, field->opts & ~opts );
+      Normalize_Field(field);
+      res = _nc_Synchronize_Options(field, field->opts & ~opts);
     }
   RETURN(res);
-}	
+}
 
 /* fld_opts.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_pad.c ncurses-5.4/form/fld_pad.c
--- ncurses-5.4.orig/form/fld_pad.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_pad.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_pad.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_pad.c,v 1.9 2004/12/11 21:56:49 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -46,17 +46,19 @@
 |                    E_SYSTEM_ERROR - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_field_pad (FIELD  * field, int ch)
+set_field_pad(FIELD *field, int ch)
 {
   int res = E_BAD_ARGUMENT;
 
-  Normalize_Field( field );
-  if (isprint((unsigned char)ch))
+  T((T_CALLED("set_field_pad(%p,%d)"), field, ch));
+
+  Normalize_Field(field);
+  if (isprint(UChar(ch)))
     {
       if (field->pad != ch)
 	{
 	  field->pad = ch;
-	  res = _nc_Synchronize_Attributes( field );
+	  res = _nc_Synchronize_Attributes(field);
 	}
       else
 	res = E_OK;
@@ -73,9 +75,11 @@
 |   Return Values :  The pad character.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-field_pad (const FIELD * field)
+field_pad(const FIELD *field)
 {
-  return Normalize_Field( field )->pad;
+  T((T_CALLED("field_pad(%p)"), field));
+
+  returnCode(Normalize_Field(field)->pad);
 }
 
 /* fld_pad.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_page.c ncurses-5.4/form/fld_page.c
--- ncurses-5.4.orig/form/fld_page.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_page.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_page.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_page.c,v 1.9 2004/12/11 21:58:19 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -45,13 +45,15 @@
 |                    E_CONNECTED  - field is connected
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_new_page (FIELD * field, bool new_page_flag)
+set_new_page(FIELD *field, bool new_page_flag)
 {
+  T((T_CALLED("set_new_page(%p,%d)"), field, new_page_flag));
+
   Normalize_Field(field);
-  if (field->form) 
+  if (field->form)
     RETURN(E_CONNECTED);
 
-  if (new_page_flag) 
+  if (new_page_flag)
     field->status |= _NEWPAGE;
   else
     field->status &= ~_NEWPAGE;
@@ -70,9 +72,11 @@
 |                    FALSE - field doesn't start a new page
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(bool)
-new_page (const FIELD * field)
+new_page(const FIELD *field)
 {
-  return (Normalize_Field(field)->status & _NEWPAGE)  ? TRUE : FALSE;
+  T((T_CALLED("new_page(%p)"), field));
+
+  returnBool((Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE);
 }
 
 /* fld_page.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_stat.c ncurses-5.4/form/fld_stat.c
--- ncurses-5.4.orig/form/fld_stat.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_stat.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_stat.c,v 1.9 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_stat.c,v 1.11 2004/12/11 22:28:00 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -44,16 +44,18 @@
 |   Return Values :  E_OK            - success
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_field_status (FIELD * field, bool status)
+set_field_status(FIELD *field, bool status)
 {
-  Normalize_Field( field );
+  T((T_CALLED("set_field_status(%p,%d)"), field, status));
+
+  Normalize_Field(field);
 
   if (status)
     field->status |= _CHANGED;
   else
     field->status &= ~_CHANGED;
 
-  return(E_OK);
+  RETURN(E_OK);
 }
 
 /*---------------------------------------------------------------------------
@@ -67,9 +69,11 @@
 |                    FALSE - buffer has not been changed
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(bool)
-field_status (const FIELD * field)
+field_status(const FIELD *field)
 {
-  return ((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
+  T((T_CALLED("field_status(%p)"), field));
+
+  returnBool((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
 }
 
 /* fld_stat.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_type.c ncurses-5.4/form/fld_type.c
--- ncurses-5.4.orig/form/fld_type.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_type.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_type.c,v 1.12 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_type.c,v 1.15 2004/12/25 22:24:10 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -46,30 +46,32 @@
 |                    E_SYSTEM_ERROR - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_field_type (FIELD *field,FIELDTYPE *type, ...)
+set_field_type(FIELD *field, FIELDTYPE *type,...)
 {
   va_list ap;
   int res = E_SYSTEM_ERROR;
   int err = 0;
 
-  va_start(ap,type);
+  T((T_CALLED("set_field_type(%p,%p)"), field, type));
+
+  va_start(ap, type);
 
   Normalize_Field(field);
   _nc_Free_Type(field);
 
   field->type = type;
-  field->arg  = (void *)_nc_Make_Argument(field->type,&ap,&err);
+  field->arg = (void *)_nc_Make_Argument(field->type, &ap, &err);
 
   if (err)
     {
-      _nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
+      _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
       field->type = (FIELDTYPE *)0;
-      field->arg  = (void *)0;
+      field->arg = (void *)0;
     }
   else
     {
       res = E_OK;
-      if (field->type) 
+      if (field->type)
 	field->type->ref++;
     }
 
@@ -86,9 +88,10 @@
 |   Return Values :  Pointer to fieldtype of NULL if none is defined.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FIELDTYPE *)
-field_type (const FIELD * field)
+field_type(const FIELD *field)
 {
-  return Normalize_Field(field)->type;
+  T((T_CALLED("field_type(%p)"), field));
+  returnFieldType(Normalize_Field(field)->type);
 }
 
 /* fld_type.c ends here */
diff -Naur ncurses-5.4.orig/form/fld_user.c ncurses-5.4/form/fld_user.c
--- ncurses-5.4.orig/form/fld_user.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/fld_user.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: fld_user.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: fld_user.c,v 1.15 2004/12/25 22:24:50 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -44,9 +44,11 @@
 |   Return Values :  E_OK         - on success
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_field_userptr (FIELD * field, void  *usrptr)
+set_field_userptr(FIELD *field, void *usrptr)
 {
-  Normalize_Field( field )->usrptr = usrptr;
+  T((T_CALLED("set_field_userptr(%p,%p)"), field, usrptr));
+
+  Normalize_Field(field)->usrptr = usrptr;
   RETURN(E_OK);
 }
 
@@ -61,9 +63,10 @@
 |                    NULL is returned
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void *)
-field_userptr (const FIELD *field)
+field_userptr(const FIELD *field)
 {
-  return Normalize_Field( field )->usrptr;
+  T((T_CALLED("field_userptr(%p)"), field));
+  returnVoidPtr(Normalize_Field(field)->usrptr);
 }
 
 /* fld_user.c ends here */
diff -Naur ncurses-5.4.orig/form/form.h ncurses-5.4/form/form.h
--- ncurses-5.4.orig/form/form.h	2003-11-08 20:39:08.000000000 +0000
+++ ncurses-5.4/form/form.h	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -30,7 +30,7 @@
  *   Author:  Juergen Pfeifer, 1995,1997                                    *
  ****************************************************************************/
 
-/* $Id: form.h,v 0.17 2003/11/08 20:39:08 tom Exp $ */
+/* $Id: form.h,v 0.20 2004/12/04 22:22:10 tom Exp $ */
 
 #ifndef FORM_H
 #define FORM_H
@@ -42,6 +42,14 @@
   extern "C" {
 #endif
 
+#ifndef FORM_PRIV_H
+typedef void *FIELD_CELL;
+#endif
+
+#ifndef NCURSES_FIELD_INTERNALS
+#define NCURSES_FIELD_INTERNALS /* nothing */
+#endif
+
 typedef int Form_Options;
 typedef int Field_Options;
 
@@ -50,10 +58,10 @@
 	**********/
 
 typedef struct {
-  short	pmin;	  /* index of first field on page            */
-  short	pmax;	  /* index of last field on page             */
-  short	smin;	  /* index of top leftmost field on page     */
-  short	smax;	  /* index of bottom rightmost field on page */
+  short pmin;		/* index of first field on page			*/
+  short pmax;		/* index of last field on page			*/
+  short smin;		/* index of top leftmost field on page		*/
+  short smax;		/* index of bottom rightmost field on page	*/
 } _PAGE;
 
 	/**********
@@ -61,31 +69,40 @@
 	**********/
 
 typedef struct fieldnode {
-  unsigned short       	status;	  /* flags		        */
-  short			rows;	  /* size in rows		*/
-  short			cols;	  /* size in cols		*/
-  short			frow;	  /* first row		        */
-  short			fcol;	  /* first col		        */
-  int                   drows;    /* dynamic rows               */
-  int                   dcols;    /* dynamic cols               */
-  int                   maxgrow;  /* maximum field growth       */
-  int			nrow;	  /* off-screen rows	        */
-  short			nbuf;	  /* additional buffers	        */
-  short			just;	  /* justification	        */
-  short			page;	  /* page on form		*/
-  short			index;	  /* into form -> field	        */
-  int			pad;	  /* pad character	        */
-  chtype		fore;	  /* foreground attribute	*/
-  chtype		back;	  /* background attribute	*/
-  Field_Options		opts;	  /* options		        */
-  struct fieldnode *	snext;	  /* sorted order pointer	*/
-  struct fieldnode *	sprev;	  /* sorted order pointer	*/
-  struct fieldnode *	link;	  /* linked field chain	        */
-  struct formnode *	form;	  /* containing form	        */
-  struct typenode *	type;	  /* field type		        */
-  void *		arg;	  /* argument for type	        */
-  char *		buf;	  /* field buffers	        */
-  void *		usrptr;	  /* user pointer		*/
+  unsigned short	status;		/* flags			*/
+  short			rows;		/* size in rows			*/
+  short			cols;		/* size in cols			*/
+  short			frow;		/* first row			*/
+  short			fcol;		/* first col			*/
+  int			drows;		/* dynamic rows			*/
+  int			dcols;		/* dynamic cols			*/
+  int			maxgrow;	/* maximum field growth		*/
+  int			nrow;		/* off-screen rows		*/
+  short			nbuf;		/* additional buffers		*/
+  short			just;		/* justification		*/
+  short			page;		/* page on form			*/
+  short			index;		/* into form -> field		*/
+  int			pad;		/* pad character		*/
+  chtype		fore;		/* foreground attribute		*/
+  chtype		back;		/* background attribute		*/
+  Field_Options		opts;		/* options			*/
+  struct fieldnode *	snext;		/* sorted order pointer		*/
+  struct fieldnode *	sprev;		/* sorted order pointer		*/
+  struct fieldnode *	link;		/* linked field chain		*/
+  struct formnode *	form;		/* containing form		*/
+  struct typenode *	type;		/* field type			*/
+  void *		arg;		/* argument for type		*/
+  FIELD_CELL *		buf;		/* field buffers		*/
+  void *		usrptr;		/* user pointer			*/
+  /*
+   * The wide-character configuration requires extra information.  Because
+   * there are existing applications that manipulate the members of FIELD
+   * directly, we cannot make the struct opaque.  Offsets of members up to
+   * this point are the same in the narrow- and wide-character configuration.
+   * But note that the type of buf depends on the configuration, and is made
+   * opaque for that reason.
+   */
+  NCURSES_FIELD_INTERNALS
 } FIELD;
 
 	/**************
@@ -93,20 +110,20 @@
 	**************/
 
 typedef struct typenode {
-  unsigned short	status;	               /* flags		       */
-  long			ref;	               /* reference count      */
-  struct typenode *	left;	               /* ptr to operand for | */
-  struct typenode *	right;	               /* ptr to operand for | */
-
-  void* (*makearg)(va_list *);                 /* make fieldtype arg   */
-  void* (*copyarg)(const void *);              /* copy fieldtype arg   */
-  void  (*freearg)(void *);                    /* free fieldtype arg   */
+  unsigned short	status;			/* flags		*/
+  long			ref;			/* reference count	*/
+  struct typenode *	left;			/* ptr to operand for | */
+  struct typenode *	right;			/* ptr to operand for | */
+
+  void* (*makearg)(va_list *);			/* make fieldtype arg	*/
+  void* (*copyarg)(const void *);		/* copy fieldtype arg	*/
+  void	(*freearg)(void *);			/* free fieldtype arg	*/
 
-  bool	(*fcheck)(FIELD *,const void *);       /* field validation     */
-  bool	(*ccheck)(int,const void *);           /* character validation */
+  bool	(*fcheck)(FIELD *,const void *);	/* field validation	*/
+  bool	(*ccheck)(int,const void *);		/* character validation */
 
-  bool	(*next)(FIELD *,const void *);         /* enumerate next value */
-  bool	(*prev)(FIELD *,const void *);         /* enumerate prev value */
+  bool	(*next)(FIELD *,const void *);		/* enumerate next value */
+  bool	(*prev)(FIELD *,const void *);		/* enumerate prev value */
 
 } FIELDTYPE;
 
@@ -115,29 +132,29 @@
 	*********/
 
 typedef struct formnode {
-  unsigned short	status;	  /* flags		        */
-  short			rows;	  /* size in rows		*/
-  short			cols;	  /* size in cols		*/
-  int			currow;	  /* current row in field window*/
-  int			curcol;	  /* current col in field window*/
-  int			toprow;	  /* in scrollable field window	*/
-  int                   begincol; /* in horiz. scrollable field */
-  short			maxfield; /* number of fields	        */
-  short			maxpage;  /* number of pages	        */
-  short			curpage;  /* index into page	        */
-  Form_Options		opts;	  /* options		        */
-  WINDOW *		win;	  /* window		        */
-  WINDOW *		sub;	  /* subwindow		        */
-  WINDOW *		w;	  /* window for current field	*/
-  FIELD **		field;	  /* field [maxfield]	        */
-  FIELD *		current;  /* current field	        */
-  _PAGE *		page;	  /* page [maxpage]	        */
-  void *		usrptr;	  /* user pointer		*/
-
-  void                  (*forminit)(struct formnode *);
-  void                  (*formterm)(struct formnode *);
-  void                  (*fieldinit)(struct formnode *);
-  void                  (*fieldterm)(struct formnode *);
+  unsigned short	status;		/* flags			*/
+  short			rows;		/* size in rows			*/
+  short			cols;		/* size in cols			*/
+  int			currow;		/* current row in field window	*/
+  int			curcol;		/* current col in field window	*/
+  int			toprow;		/* in scrollable field window	*/
+  int			begincol;	/* in horiz. scrollable field	*/
+  short			maxfield;	/* number of fields		*/
+  short			maxpage;	/* number of pages		*/
+  short			curpage;	/* index into page		*/
+  Form_Options		opts;		/* options			*/
+  WINDOW *		win;		/* window			*/
+  WINDOW *		sub;		/* subwindow			*/
+  WINDOW *		w;		/* window for current field	*/
+  FIELD **		field;		/* field [maxfield]		*/
+  FIELD *		current;	/* current field		*/
+  _PAGE *		page;		/* page [maxpage]		*/
+  void *		usrptr;		/* user pointer			*/
+
+  void			(*forminit)(struct formnode *);
+  void			(*formterm)(struct formnode *);
+  void			(*fieldinit)(struct formnode *);
+  void			(*fieldterm)(struct formnode *);
 
 } FORM;
 
@@ -154,20 +171,20 @@
 #define JUSTIFY_RIGHT		(3)
 
 /* field options */
-#define O_VISIBLE		(0x0001)
-#define O_ACTIVE		(0x0002)
-#define O_PUBLIC		(0x0004)
-#define O_EDIT			(0x0008)
-#define O_WRAP			(0x0010)
-#define O_BLANK			(0x0020)
-#define O_AUTOSKIP		(0x0040)
-#define O_NULLOK		(0x0080)
-#define O_PASSOK		(0x0100)
-#define O_STATIC                (0x0200)
+#define O_VISIBLE		(0x0001U)
+#define O_ACTIVE		(0x0002U)
+#define O_PUBLIC		(0x0004U)
+#define O_EDIT			(0x0008U)
+#define O_WRAP			(0x0010U)
+#define O_BLANK			(0x0020U)
+#define O_AUTOSKIP		(0x0040U)
+#define O_NULLOK		(0x0080U)
+#define O_PASSOK		(0x0100U)
+#define O_STATIC		(0x0200U)
 
 /* form options */
-#define O_NL_OVERLOAD		(0x0001)
-#define O_BS_OVERLOAD		(0x0002)
+#define O_NL_OVERLOAD		(0x0001U)
+#define O_BS_OVERLOAD		(0x0002U)
 
 /* form driver commands */
 #define REQ_NEXT_PAGE	 (KEY_MAX + 1)	/* move to next page		*/
@@ -219,14 +236,14 @@
 #define REQ_SCR_BLINE	 (KEY_MAX + 44)	/* scroll field backward a line	*/
 #define REQ_SCR_FPAGE	 (KEY_MAX + 45)	/* scroll field forward a page	*/
 #define REQ_SCR_BPAGE	 (KEY_MAX + 46)	/* scroll field backward a page	*/
-#define REQ_SCR_FHPAGE   (KEY_MAX + 47) /* scroll field forward  half page */
-#define REQ_SCR_BHPAGE   (KEY_MAX + 48) /* scroll field backward half page */
-#define REQ_SCR_FCHAR    (KEY_MAX + 49) /* horizontal scroll char          */
-#define REQ_SCR_BCHAR    (KEY_MAX + 50) /* horizontal scroll char          */
-#define REQ_SCR_HFLINE   (KEY_MAX + 51) /* horizontal scroll line          */
-#define REQ_SCR_HBLINE   (KEY_MAX + 52) /* horizontal scroll line          */
-#define REQ_SCR_HFHALF   (KEY_MAX + 53) /* horizontal scroll half line     */
-#define REQ_SCR_HBHALF   (KEY_MAX + 54) /* horizontal scroll half line     */
+#define REQ_SCR_FHPAGE	 (KEY_MAX + 47) /* scroll field forward	 half page */
+#define REQ_SCR_BHPAGE	 (KEY_MAX + 48) /* scroll field backward half page */
+#define REQ_SCR_FCHAR	 (KEY_MAX + 49) /* horizontal scroll char	*/
+#define REQ_SCR_BCHAR	 (KEY_MAX + 50) /* horizontal scroll char	*/
+#define REQ_SCR_HFLINE	 (KEY_MAX + 51) /* horizontal scroll line	*/
+#define REQ_SCR_HBLINE	 (KEY_MAX + 52) /* horizontal scroll line	*/
+#define REQ_SCR_HFHALF	 (KEY_MAX + 53) /* horizontal scroll half line	*/
+#define REQ_SCR_HBHALF	 (KEY_MAX + 54) /* horizontal scroll half line	*/
 
 #define REQ_VALIDATION	 (KEY_MAX + 55)	/* validate field		*/
 #define REQ_NEXT_CHOICE	 (KEY_MAX + 56)	/* display next field choice	*/
@@ -255,15 +272,15 @@
 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
 
-        /************************************
+	/************************************
 	*  built-in additional field types  *
-        *  They are not defined in SVr4     *
+	*  They are not defined in SVr4     *
 	************************************/
 extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4;      /* Internet IP Version 4 address */
 
-        /*********************** 
-        *   Default objects    *
-        ***********************/ 
+	/***********************
+	*   Default objects    *
+	***********************/
 extern NCURSES_EXPORT_VAR(FORM *)	_nc_Default_Form;
 extern NCURSES_EXPORT_VAR(FIELD *)	_nc_Default_Field;
 
@@ -273,8 +290,9 @@
 	***********************/
 extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
 		    bool (* const field_check)(FIELD *,const void *),
-		    bool (* const char_check)(int,const void *)),
-                *link_fieldtype(FIELDTYPE *,FIELDTYPE *);
+		    bool (* const char_check)(int,const void *));
+extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype(
+		    FIELDTYPE *, FIELDTYPE *);
 
 extern NCURSES_EXPORT(int)	free_fieldtype (FIELDTYPE *);
 extern NCURSES_EXPORT(int)	set_fieldtype_arg (FIELDTYPE *,
@@ -326,7 +344,7 @@
 
 extern NCURSES_EXPORT(char *)	field_buffer (const FIELD *,int);
 
-extern NCURSES_EXPORT(Field_Options)	field_opts (const FIELD *); 
+extern NCURSES_EXPORT(Field_Options)	field_opts (const FIELD *);
 
 	/******************
 	*  FORM routines  *
diff -Naur ncurses-5.4.orig/form/form.priv.h ncurses-5.4/form/form.priv.h
--- ncurses-5.4.orig/form/form.priv.h	2003-11-08 20:38:51.000000000 +0000
+++ ncurses-5.4/form/form.priv.h	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -30,37 +30,65 @@
  *   Author:  Juergen Pfeifer, 1995,1997                                    *
  ****************************************************************************/
 
-/* $Id: form.priv.h,v 0.11 2003/11/08 20:38:51 tom Exp $ */
+/* $Id: form.priv.h,v 0.25 2005/03/05 23:47:26 tom Exp $ */
 
+#ifndef FORM_PRIV_H
+#define FORM_PRIV_H 1
+
+#include "curses.priv.h"
 #include "mf_common.h"
+
+#if USE_WIDEC_SUPPORT
+#include <wchar.h>
+#include <wctype.h>
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
+#endif
+
+#define FIELD_CELL NCURSES_CH_T
+
+#define NCURSES_FIELD_INTERNALS char** expanded; WINDOW *working;
+#define NCURSES_FIELD_EXTENSION , (char **)0, (WINDOW *)0
+
+#else
+
+#define FIELD_CELL char
+
+#define NCURSES_FIELD_EXTENSION /* nothing */
+
+#endif
+
 #include "form.h"
 
 /* form  status values */
-#define _OVLMODE         (0x04) /* Form is in overlay mode                */
-#define _WINDOW_MODIFIED (0x10) /* Current field window has been modified */
-#define _FCHECK_REQUIRED (0x20) /* Current field needs validation         */
+#define _OVLMODE         (0x04U) /* Form is in overlay mode                */
+#define _WINDOW_MODIFIED (0x10U) /* Current field window has been modified */
+#define _FCHECK_REQUIRED (0x20U) /* Current field needs validation         */
 
 /* field status values */
-#define _CHANGED         (0x01) /* Field has been changed                 */
-#define _NEWTOP          (0x02) /* Vertical scrolling occurred            */
-#define _NEWPAGE	 (0x04) /* field begins new page of form          */
-#define _MAY_GROW        (0x08) /* dynamic field may still grow           */
+#define _CHANGED         (0x01U) /* Field has been changed                 */
+#define _NEWTOP          (0x02U) /* Vertical scrolling occurred            */
+#define _NEWPAGE         (0x04U) /* field begins new page of form          */
+#define _MAY_GROW        (0x08U) /* dynamic field may still grow           */
 
 /* fieldtype status values */
-#define _LINKED_TYPE     (0x01) /* Type is a linked type                  */
-#define _HAS_ARGS        (0x02) /* Type has arguments                     */
-#define _HAS_CHOICE      (0x04) /* Type has choice methods                */
-#define _RESIDENT        (0x08) /* Type is built-in                       */
+#define _LINKED_TYPE     (0x01U) /* Type is a linked type                  */
+#define _HAS_ARGS        (0x02U) /* Type has arguments                     */
+#define _HAS_CHOICE      (0x04U) /* Type has choice methods                */
+#define _RESIDENT        (0x08U) /* Type is built-in                       */
 
 /* This are the field options required to be a selectable field in field
    navigation requests */
 #define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
 
 /* If form is NULL replace form argument by default-form */
-#define Normalize_Form(form)  ((form)=(form)?(form):_nc_Default_Form)
+#define Normalize_Form(form) \
+  ((form) = (form != 0) ? (form) : _nc_Default_Form)
 
 /* If field is NULL replace field argument by default-field */
-#define Normalize_Field(field)  ((field)=(field)?(field):_nc_Default_Field)
+#define Normalize_Field(field) \
+  ((field) = (field != 0) ? (field) : _nc_Default_Field)
 
 /* Retrieve forms window */
 #define Get_Form_Window(form) \
@@ -71,20 +99,22 @@
 
 /* Calculate the total size of all buffers for this field */
 #define Total_Buffer_Size(field) \
-   ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) )
+   ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) * sizeof(FIELD_CELL) )
 
 /* Logic to determine whether or not a field is single lined */
 #define Single_Line_Field(field) \
    (((field)->rows + (field)->nrow) == 1)
 
 /* Logic to determine whether or not a field is selectable */
-#define Field_Is_Selectable(f)     (((f)->opts & O_SELECTABLE)==O_SELECTABLE)
-#define Field_Is_Not_Selectable(f) (((f)->opts & O_SELECTABLE)!=O_SELECTABLE)
+#define Field_Is_Selectable(f)     (((unsigned)((f)->opts) & O_SELECTABLE)==O_SELECTABLE)
+#define Field_Is_Not_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)!=O_SELECTABLE)
 
-typedef struct typearg {
-  struct typearg *left;
-  struct typearg *right;
-} TypeArgument;
+typedef struct typearg
+  {
+    struct typearg *left;
+    struct typearg *right;
+  }
+TypeArgument;
 
 /* This is a dummy request code (normally invalid) to be used internally
    with the form_driver() routine to position to the first active field
@@ -96,7 +126,7 @@
 			O_NL_OVERLOAD  |\
 			O_BS_OVERLOAD   )
 
-#define ALL_FIELD_OPTS (           \
+#define ALL_FIELD_OPTS (Field_Options)( \
 			O_VISIBLE |\
 			O_ACTIVE  |\
 			O_PUBLIC  |\
@@ -108,23 +138,112 @@
 			O_PASSOK  |\
 			O_STATIC   )
 
-
 #define C_BLANK ' '
 #define is_blank(c) ((c)==C_BLANK)
 
+#define C_ZEROS '\0'
+
 extern NCURSES_EXPORT_VAR(const FIELDTYPE *) _nc_Default_FieldType;
 
-extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*,va_list*,int*);
-extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*,const TypeArgument*, int*);
-extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*,TypeArgument*);
+extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*, va_list*, int*);
+extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*, const TypeArgument*, int*);
+extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*, TypeArgument*);
 extern NCURSES_EXPORT(bool) _nc_Copy_Type (FIELD*, FIELD const *);
 extern NCURSES_EXPORT(void) _nc_Free_Type (FIELD *);
 
 extern NCURSES_EXPORT(int) _nc_Synchronize_Attributes (FIELD*);
-extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*,Field_Options);
-extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*,int,FIELD*);
+extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*, Field_Options);
+extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*, int, FIELD*);
 extern NCURSES_EXPORT(int) _nc_Refresh_Current_Field (FORM*);
 extern NCURSES_EXPORT(FIELD *) _nc_First_Active_Field (FORM*);
 extern NCURSES_EXPORT(bool) _nc_Internal_Validation (FORM*);
-extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*,FIELD*);
+extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*, FIELD*);
 extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);
+
+#if USE_WIDEC_SUPPORT
+extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *);
+#endif
+
+#ifdef TRACE
+
+#define returnField(code)	TRACE_RETURN(code,field)
+#define returnFieldPtr(code)	TRACE_RETURN(code,field_ptr)
+#define returnForm(code)	TRACE_RETURN(code,form)
+#define returnFieldType(code)	TRACE_RETURN(code,field_type)
+#define returnFormHook(code)	TRACE_RETURN(code,form_hook)
+
+extern NCURSES_EXPORT(FIELD **)	    _nc_retrace_field_ptr (FIELD **);
+extern NCURSES_EXPORT(FIELD *)	    _nc_retrace_field (FIELD *);
+extern NCURSES_EXPORT(FIELDTYPE *)  _nc_retrace_field_type (FIELDTYPE *);
+extern NCURSES_EXPORT(FORM *)  _nc_retrace_form (FORM *);
+extern NCURSES_EXPORT(Form_Hook)  _nc_retrace_form_hook (Form_Hook);
+
+#else /* !TRACE */
+
+#define returnFieldPtr(code)	return code
+#define returnFieldType(code)	return code
+#define returnField(code)	return code
+#define returnForm(code)	return code
+#define returnFormHook(code)	return code
+
+#endif /* TRACE/!TRACE */
+
+/*
+ * Use Check_CTYPE_Field() to simplify FIELDTYPE's that use only the ccheck()
+ * function.
+ */
+#if USE_WIDEC_SUPPORT
+#define Check_CTYPE_Field(result, buffer, width, ccheck) \
+  while (*buffer && *buffer == ' ') \
+    buffer++; \
+  if (*buffer) \
+    { \
+      bool blank = FALSE; \
+      int len; \
+      int n; \
+      wchar_t *list = _nc_Widen_String((char *)buffer, &len); \
+      if (list != 0) \
+	{ \
+	  result = TRUE; \
+	  for (n = 0; n < len; ++n) \
+	    { \
+	      if (blank) \
+		{ \
+		  if (list[n] != ' ') \
+		    { \
+		      result = FALSE; \
+		      break; \
+		    } \
+		} \
+	      else if (list[n] == ' ') \
+		{ \
+		  blank = TRUE; \
+		  result = (n + 1 >= width); \
+		} \
+	      else if (!ccheck(list[n], NULL)) \
+		{ \
+		  result = FALSE; \
+		  break; \
+		} \
+	    } \
+	  free(list); \
+	} \
+    }
+#else
+#define Check_CTYPE_Field(result, buffer, width, ccheck) \
+  while (*buffer && *buffer == ' ') \
+    buffer++; \
+  if (*buffer) \
+    { \
+      unsigned char *s = buffer; \
+      int l = -1; \
+      while (*buffer && ccheck(*buffer, NULL)) \
+	buffer++; \
+      l = (int)(buffer - s); \
+      while (*buffer && *buffer == ' ') \
+	buffer++; \
+      result = ((*buffer || (l < width)) ? FALSE : TRUE); \
+    }
+#endif
+
+#endif /* FORM_PRIV_H */
diff -Naur ncurses-5.4.orig/form/frm_cursor.c ncurses-5.4/form/frm_cursor.c
--- ncurses-5.4.orig/form/frm_cursor.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_cursor.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: frm_cursor.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_cursor.c,v 1.9 2004/12/11 22:01:03 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -49,16 +49,18 @@
 |                    E_NOT_POSTED              - Form is not posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-pos_form_cursor (FORM * form)
+pos_form_cursor(FORM *form)
 {
   int res;
 
+  T((T_CALLED("pos_form_cursor(%p)"), form));
+
   if (!form)
-   res = E_BAD_ARGUMENT;
+    res = E_BAD_ARGUMENT;
   else
     {
       if (!(form->status & _POSTED))
-        res = E_NOT_POSTED;
+	res = E_NOT_POSTED;
       else
 	res = _nc_Position_Form_Cursor(form);
     }
diff -Naur ncurses-5.4.orig/form/frm_data.c ncurses-5.4/form/frm_data.c
--- ncurses-5.4.orig/form/frm_data.c	2003-11-08 20:38:14.000000000 +0000
+++ ncurses-5.4/form/frm_data.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: frm_data.c,v 1.10 2003/11/08 20:38:14 tom Exp $")
+MODULE_ID("$Id: frm_data.c,v 1.13 2004/12/11 22:29:28 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -45,10 +45,12 @@
 |                    FALSE  - there are no off-screen data behind
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(bool)
-data_behind (const FORM *form)
+data_behind(const FORM *form)
 {
   bool result = FALSE;
 
+  T((T_CALLED("data_behind(%p)"), form));
+
   if (form && (form->status & _POSTED) && form->current)
     {
       FIELD *field;
@@ -56,42 +58,69 @@
       field = form->current;
       if (!Single_Line_Field(field))
 	{
-	  result = (form->toprow==0) ? FALSE : TRUE;
+	  result = (form->toprow == 0) ? FALSE : TRUE;
 	}
       else
 	{
-	  result = (form->begincol==0) ? FALSE : TRUE;
+	  result = (form->begincol == 0) ? FALSE : TRUE;
 	}
     }
-  return(result);
+  returnBool(result);
 }
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
-|   Function      :  static char * After_Last_Non_Pad_Position(
-|                                    char *buffer,
+|   Function      :  static char * Only_Padding(
+|                                    WINDOW *w,
 |                                    int len,
 |                                    int pad)
 |   
-|   Description   :  Find the last position in the buffer that doesn't
+|   Description   :  Test if 'length' cells starting at the current position
 |                    contain a padding character.
 |
-|   Return Values :  The pointer to this position 
+|   Return Values :  true if only padding cells are found
 +--------------------------------------------------------------------------*/
-INLINE 
-static char * After_Last_Non_Pad_Position(char *buffer, int len, int pad)
+INLINE static bool
+Only_Padding(WINDOW *w, int len, int pad)
 {
-  char *end = buffer + len;
-
-  assert(buffer && len>=0);
-  while ( (buffer < end) && (*(end-1)==pad) )
-    end--;
+  bool result = TRUE;
+  int y, x, j;
+  FIELD_CELL cell;
 
-  return end;
+  getyx(w, y, x);
+  for (j = 0; j < len; ++j)
+    {
+      if (wmove(w, y, x + j) != ERR)
+	{
+#if USE_WIDEC_SUPPORT
+	  if (win_wch(w, &cell) != ERR)
+	    {
+	      if ((chtype)CharOf(cell) != ChCharOf(pad)
+		  || cell.chars[1] != 0)
+		{
+		  result = FALSE;
+		  break;
+		}
+	    }
+#else
+	  cell = winch(w);
+	  if (ChCharOf(cell) != ChCharOf(pad))
+	    {
+	      result = FALSE;
+	      break;
+	    }
+#endif
+	}
+      else
+	{
+	  /* if an error, return true: no non-padding text found */
+	  break;
+	}
+    }
+  /* no need to reset the cursor position; caller does this */
+  return result;
 }
 
-#define SMALL_BUFFER_SIZE (80)
-
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
 |   Function      :  bool data_ahead(const FORM *form)
@@ -103,31 +132,21 @@
 |                    FALSE  - there are no off-screen data ahead
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(bool)
-data_ahead (const FORM *form)
+data_ahead(const FORM *form)
 {
   bool result = FALSE;
 
+  T((T_CALLED("data_ahead(%p)"), form));
+
   if (form && (form->status & _POSTED) && form->current)
     {
-      static char buffer[SMALL_BUFFER_SIZE + 1];
       FIELD *field;
-      bool large_buffer;
       bool cursor_moved = FALSE;
-      char *bp;
-      char *found_content;
       int pos;
 
       field = form->current;
       assert(form->w);
 
-      large_buffer = (field->cols > SMALL_BUFFER_SIZE);
-      if (large_buffer)
-	bp = (char *)malloc((size_t)(field->cols) + 1);
-      else
-	bp = buffer;
-
-      assert(bp);
-      
       if (Single_Line_Field(field))
 	{
 	  int check_len;
@@ -136,15 +155,12 @@
 	  while (pos < field->dcols)
 	    {
 	      check_len = field->dcols - pos;
-	      if ( check_len >= field->cols )
+	      if (check_len >= field->cols)
 		check_len = field->cols;
 	      cursor_moved = TRUE;
-	      wmove(form->w,0,pos);
-	      winnstr(form->w,bp,check_len);
-	      found_content = 
-		After_Last_Non_Pad_Position(bp,check_len,field->pad);
-	      if (found_content==bp)
-		  pos += field->cols;		  
+	      wmove(form->w, 0, pos);
+	      if (Only_Padding(form->w, check_len, field->pad))
+		pos += field->cols;
 	      else
 		{
 		  result = TRUE;
@@ -158,12 +174,9 @@
 	  while (pos < field->drows)
 	    {
 	      cursor_moved = TRUE;
-	      wmove(form->w,pos,0);
+	      wmove(form->w, pos, 0);
 	      pos++;
-	      winnstr(form->w,bp,field->cols);
-	      found_content = 
-		After_Last_Non_Pad_Position(bp,field->cols,field->pad);
-	      if (found_content!=bp)
+	      if (!Only_Padding(form->w, field->cols, field->pad))
 		{
 		  result = TRUE;
 		  break;
@@ -171,13 +184,10 @@
 	    }
 	}
 
-      if (large_buffer)
-	free(bp);
-
       if (cursor_moved)
-	wmove(form->w,form->currow,form->curcol);
+	wmove(form->w, form->currow, form->curcol);
     }
-  return(result);
+  returnBool(result);
 }
 
 /* frm_data.c ends here */
diff -Naur ncurses-5.4.orig/form/frm_def.c ncurses-5.4/form/frm_def.c
--- ncurses-5.4.orig/form/frm_def.c	2003-11-08 20:37:53.000000000 +0000
+++ ncurses-5.4/form/frm_def.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,32 +32,33 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_def.c,v 1.13 2003/11/08 20:37:53 tom Exp $")
+MODULE_ID("$Id: frm_def.c,v 1.17 2004/12/25 22:26:01 tom Exp $")
 
 /* this can't be readonly */
-static FORM default_form = {
-  0,                                    /* status     */
-  0,                                    /* rows       */
-  0,                                    /* cols       */
-  0,                                    /* currow     */
-  0,                                    /* curcol     */
-  0,                                    /* toprow     */
-  0,                                    /* begincol   */
-  -1,                                   /* maxfield   */
-  -1,                                   /* maxpage    */
-  -1,                                   /* curpage    */
-  ALL_FORM_OPTS,                        /* opts       */
-  (WINDOW *)0,                          /* win        */
-  (WINDOW *)0,                          /* sub        */
-  (WINDOW *)0,                          /* w          */
-  (FIELD **)0,                          /* field      */
-  (FIELD *)0,                           /* current    */
-  (_PAGE *)0,                           /* page       */
-  (char *)0,                            /* usrptr     */
-  NULL,			                /* forminit   */
-  NULL,                                 /* formterm   */
-  NULL,                                 /* fieldinit  */
-  NULL                                  /* fieldterm  */
+static FORM default_form =
+{
+  0,				/* status     */
+  0,				/* rows       */
+  0,				/* cols       */
+  0,				/* currow     */
+  0,				/* curcol     */
+  0,				/* toprow     */
+  0,				/* begincol   */
+  -1,				/* maxfield   */
+  -1,				/* maxpage    */
+  -1,				/* curpage    */
+  ALL_FORM_OPTS,		/* opts       */
+  (WINDOW *)0,			/* win        */
+  (WINDOW *)0,			/* sub        */
+  (WINDOW *)0,			/* w          */
+  (FIELD **)0,			/* field      */
+  (FIELD *)0,			/* current    */
+  (_PAGE *) 0,			/* page       */
+  (char *)0,			/* usrptr     */
+  NULL,				/* forminit   */
+  NULL,				/* formterm   */
+  NULL,				/* fieldinit  */
+  NULL				/* fieldterm  */
 };
 
 NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form;
@@ -74,39 +75,40 @@
 |
 |   Return Values :  New head of sorted fieldlist
 +--------------------------------------------------------------------------*/
-static FIELD *Insert_Field_By_Position(FIELD *newfield, FIELD *head)
+static FIELD *
+Insert_Field_By_Position(FIELD *newfield, FIELD *head)
 {
   FIELD *current, *newhead;
-  
+
   assert(newfield);
 
   if (!head)
-    { /* empty list is trivial */
+    {				/* empty list is trivial */
       newhead = newfield->snext = newfield->sprev = newfield;
     }
   else
     {
       newhead = current = head;
-      while((current->frow < newfield->frow) || 
-	    ((current->frow==newfield->frow) && 
-	     (current->fcol < newfield->fcol)) )
+      while ((current->frow < newfield->frow) ||
+	     ((current->frow == newfield->frow) &&
+	      (current->fcol < newfield->fcol)))
 	{
 	  current = current->snext;
-	  if (current==head)
-	    { /* We cycled through. Reset head to indicate that */
+	  if (current == head)
+	    {			/* We cycled through. Reset head to indicate that */
 	      head = (FIELD *)0;
 	      break;
 	    }
 	}
-      /* we leave the loop with current pointing to the field after newfield*/
-      newfield->snext	 = current;
-      newfield->sprev	 = current->sprev;
+      /* we leave the loop with current pointing to the field after newfield */
+      newfield->snext = current;
+      newfield->sprev = current->sprev;
       newfield->snext->sprev = newfield;
       newfield->sprev->snext = newfield;
-      if (current==head) 
+      if (current == head)
 	newhead = newfield;
     }
-  return(newhead);
+  return (newhead);
 }
 
 /*---------------------------------------------------------------------------
@@ -117,25 +119,26 @@
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Disconnect_Fields( FORM * form )
+static void
+Disconnect_Fields(FORM *form)
 {
   if (form->field)
     {
       FIELD **fields;
 
-      for(fields=form->field;*fields;fields++)
+      for (fields = form->field; *fields; fields++)
 	{
-	  if (form == (*fields)->form) 
+	  if (form == (*fields)->form)
 	    (*fields)->form = (FORM *)0;
 	}
-      
+
       form->rows = form->cols = 0;
       form->maxfield = form->maxpage = -1;
       form->field = (FIELD **)0;
-      if (form->page) 
+      if (form->page)
 	free(form->page);
-      form->page = (_PAGE *)0;
-    }	
+      form->page = (_PAGE *) 0;
+    }
 }
 
 /*---------------------------------------------------------------------------
@@ -149,82 +152,86 @@
 |                    E_BAD_ARGUMENT  - Invalid form pointer or field array
 |                    E_SYSTEM_ERROR  - not enough memory
 +--------------------------------------------------------------------------*/
-static int Connect_Fields(FORM  * form, FIELD ** fields)
+static int
+Connect_Fields(FORM *form, FIELD **fields)
 {
   int field_cnt, j;
   int page_nr;
   int maximum_row_in_field, maximum_col_in_field;
   _PAGE *pg;
-  
+
+  T((T_CALLED("Connect_Fields(%p,%p)"), form, fields));
+
   assert(form);
 
-  form->field    = fields;
+  form->field = fields;
   form->maxfield = 0;
-  form->maxpage  = 0;
+  form->maxpage = 0;
 
   if (!fields)
     RETURN(E_OK);
-  
+
   page_nr = 0;
   /* store formpointer in fields and count pages */
-  for(field_cnt=0;fields[field_cnt];field_cnt++)
+  for (field_cnt = 0; fields[field_cnt]; field_cnt++)
     {
-      if (fields[field_cnt]->form) 
+      if (fields[field_cnt]->form)
 	RETURN(E_CONNECTED);
-      if ( field_cnt==0 || 
-	  (fields[field_cnt]->status & _NEWPAGE)) 
+      if (field_cnt == 0 ||
+	  (fields[field_cnt]->status & _NEWPAGE))
 	page_nr++;
       fields[field_cnt]->form = form;
-    }	
-  if (field_cnt==0)
+    }
+  if (field_cnt == 0)
     RETURN(E_BAD_ARGUMENT);
-  
+
   /* allocate page structures */
-  if ( (pg = (_PAGE *)malloc(page_nr * sizeof(_PAGE))) != (_PAGE *)0 )
+  if ((pg = (_PAGE *) malloc(page_nr * sizeof(_PAGE))) != (_PAGE *) 0)
     {
       form->page = pg;
     }
   else
     RETURN(E_SYSTEM_ERROR);
-  
+
   /* Cycle through fields and calculate page boundaries as well as
      size of the form */
-  for(j=0;j<field_cnt;j++)
+  for (j = 0; j < field_cnt; j++)
     {
-      if (j==0) 
+      if (j == 0)
 	pg->pmin = j;
       else
 	{
 	  if (fields[j]->status & _NEWPAGE)
 	    {
-	      pg->pmax = j-1;
+	      pg->pmax = j - 1;
 	      pg++;
 	      pg->pmin = j;
 	    }
 	}
-      
+
       maximum_row_in_field = fields[j]->frow + fields[j]->rows;
       maximum_col_in_field = fields[j]->fcol + fields[j]->cols;
-      
-      if (form->rows < maximum_row_in_field) 
+
+      if (form->rows < maximum_row_in_field)
 	form->rows = maximum_row_in_field;
-      if (form->cols < maximum_col_in_field) 
+      if (form->cols < maximum_col_in_field)
 	form->cols = maximum_col_in_field;
     }
-  
-  pg->pmax       = field_cnt-1;
+
+  pg->pmax = field_cnt - 1;
   form->maxfield = field_cnt;
-  form->maxpage  = page_nr; 
-  
+  form->maxpage = page_nr;
+
   /* Sort fields on form pages */
-  for(page_nr = 0;page_nr < form->maxpage; page_nr++)
+  for (page_nr = 0; page_nr < form->maxpage; page_nr++)
     {
       FIELD *fld = (FIELD *)0;
-      for(j = form->page[page_nr].pmin;j <= form->page[page_nr].pmax;j++)
+
+      for (j = form->page[page_nr].pmin; j <= form->page[page_nr].pmax; j++)
 	{
 	  fields[j]->index = j;
-	  fields[j]->page  = page_nr;
-	  fld = Insert_Field_By_Position(fields[j],fld);
+	  fields[j]->page = page_nr;
+	  fld = Insert_Field_By_Position(fields[j], fld);
 	}
       form->page[page_nr].smin = fld->index;
       form->page[page_nr].smax = fld->sprev->index;
@@ -242,25 +249,27 @@
 |   Return Values :  E_OK            - success
 |                    any other       - error occurred
 +--------------------------------------------------------------------------*/
-INLINE static int Associate_Fields(FORM  *form, FIELD **fields)
+INLINE static int
+Associate_Fields(FORM *form, FIELD **fields)
 {
-  int res = Connect_Fields(form,fields);
+  int res = Connect_Fields(form, fields);
+
   if (res == E_OK)
     {
-      if (form->maxpage>0)
+      if (form->maxpage > 0)
 	{
 	  form->curpage = 0;
-	  form_driver(form,FIRST_ACTIVE_MAGIC);
+	  form_driver(form, FIRST_ACTIVE_MAGIC);
 	}
       else
 	{
 	  form->curpage = -1;
 	  form->current = (FIELD *)0;
-	} 
+	}
     }
-  return(res);
+  return (res);
 }
-			    
+
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
 |   Function      :  FORM *new_form( FIELD **fields )
@@ -270,16 +279,17 @@
 |   Return Values :  Pointer to form. NULL if error occurred.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FORM *)
-new_form (FIELD ** fields)
-{	
+new_form(FIELD **fields)
+{
   int err = E_SYSTEM_ERROR;
 
   FORM *form = (FORM *)malloc(sizeof(FORM));
-  
+
+  T((T_CALLED("new_form(%p)"), fields));
   if (form)
     {
       *form = *_nc_Default_Form;
-      if ((err=Associate_Fields(form,fields))!=E_OK)
+      if ((err = Associate_Fields(form, fields)) != E_OK)
 	{
 	  free_form(form);
 	  form = (FORM *)0;
@@ -288,8 +298,8 @@
 
   if (!form)
     SET_ERROR(err);
-  
-  return(form);
+
+  returnForm(form);
 }
 
 /*---------------------------------------------------------------------------
@@ -303,19 +313,21 @@
 |                    E_POSTED       - form is posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-free_form (FORM * form)
+free_form(FORM *form)
 {
-  if ( !form )	
+  T((T_CALLED("free_form(%p)"), form));
+
+  if (!form)
     RETURN(E_BAD_ARGUMENT);
 
-  if ( form->status & _POSTED)  
+  if (form->status & _POSTED)
     RETURN(E_POSTED);
-  
-  Disconnect_Fields( form );
-  if (form->page) 
+
+  Disconnect_Fields(form);
+  if (form->page)
     free(form->page);
   free(form);
-  
+
   RETURN(E_OK);
 }
 
@@ -330,26 +342,28 @@
 |                    E_POSTED          - form is posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_form_fields (FORM  * form, FIELD ** fields)
+set_form_fields(FORM *form, FIELD **fields)
 {
   FIELD **old;
   int res;
-  
-  if ( !form )	
+
+  T((T_CALLED("set_form_fields(%p,%p)"), form, fields));
+
+  if (!form)
     RETURN(E_BAD_ARGUMENT);
 
-  if ( form->status & _POSTED )	
+  if (form->status & _POSTED)
     RETURN(E_POSTED);
-  
+
   old = form->field;
-  Disconnect_Fields( form );
-  
-  if( (res = Associate_Fields( form, fields )) != E_OK )
-    Connect_Fields( form, old );
-  
+  Disconnect_Fields(form);
+
+  if ((res = Associate_Fields(form, fields)) != E_OK)
+    Connect_Fields(form, old);
+
   RETURN(res);
 }
-	
+
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
 |   Function      :  FIELD **form_fields( const FORM *form )
@@ -359,9 +373,10 @@
 |   Return Values :  Pointer to field array
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(FIELD **)
-form_fields (const FORM * form)
+form_fields(const FORM *form)
 {
-  return (Normalize_Form( form )->field);
+  T((T_CALLED("form_field(%p)"), form));
+  returnFieldPtr(Normalize_Form(form)->field);
 }
 
 /*---------------------------------------------------------------------------
@@ -373,9 +388,11 @@
 |   Return Values :  Number of fields, -1 if none are defined
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-field_count (const FORM * form)
+field_count(const FORM *form)
 {
-  return (Normalize_Form( form )->maxfield);
+  T((T_CALLED("field_count(%p)"), form));
+
+  returnCode(Normalize_Form(form)->maxfield);
 }
 
 /* frm_def.c ends here */
diff -Naur ncurses-5.4.orig/form/frm_driver.c ncurses-5.4/form/frm_driver.c
--- ncurses-5.4.orig/form/frm_driver.c	2003-12-06 17:22:42.000000000 +0000
+++ ncurses-5.4/form/frm_driver.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,11 +32,11 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_driver.c,v 1.45 2003/12/06 17:22:42 tom Exp $")
+MODULE_ID("$Id: frm_driver.c,v 1.68 2005/04/16 17:42:59 tom Exp $")
 
 /*----------------------------------------------------------------------------
   This is the core module of the form library. It contains the majority
-  of the driver routines as well as the form_driver function. 
+  of the driver routines as well as the form_driver function.
 
   Essentially this module is nearly the whole library. This is because
   all the functions in this module depends on some others in the module,
@@ -53,7 +53,7 @@
         The current field of the form is left and some new field is
         entered.
    c)   Intra-Field Navigation     ( all functions prefixed by IFN_ )
-        The current position in the current field is changed. 
+        The current position in the current field is changed.
    d)   Vertical Scrolling         ( all functions prefixed by VSC_ )
         Essentially this is a specialization of Intra-Field navigation.
         It has to check for a multi-line field.
@@ -87,7 +87,7 @@
 of the original SVr4 implementation, although in some areas it is quite
 clear that this isn't the most appropriate way. As far as possible this
 sources will allow you to build a forms lib that behaves quite similar
-to SVr4, but now and in the future we will give you better options. 
+to SVr4, but now and in the future we will give you better options.
 Perhaps at some time we will make this configurable at runtime.
 */
 
@@ -98,15 +98,27 @@
 /* Allow dynamic field growth also when navigating past the end */
 #define GROW_IF_NAVIGATE (1)
 
+#if USE_WIDEC_SUPPORT
+#define myADDNSTR(w, s, n) wadd_wchnstr(w, s, n)
+#define myINSNSTR(w, s, n) wins_wchnstr(w, s, n)
+#define myINNSTR(w, s, n)  fix_wchnstr(w, s, n)
+#define myWCWIDTH(w, y, x) cell_width(w, y, x)
+#else
+#define myADDNSTR(w, s, n) waddnstr(w, s, n)
+#define myINSNSTR(w, s, n) winsnstr(w, s, n)
+#define myINNSTR(w, s, n)  winnstr(w, s, n)
+#define myWCWIDTH(w, y, x) 1
+#endif
+
 /*----------------------------------------------------------------------------
   Forward references to some internally used static functions
   --------------------------------------------------------------------------*/
-static int Inter_Field_Navigation ( int (* const fct) (FORM *), FORM * form );
-static int FN_Next_Field (FORM * form);
-static int FN_Previous_Field (FORM * form);
+static int Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form);
+static int FN_Next_Field(FORM *form);
+static int FN_Previous_Field(FORM *form);
 static int FE_New_Line(FORM *);
 static int FE_Delete_Previous(FORM *);
-
+
 /*----------------------------------------------------------------------------
   Macro Definitions.
 
@@ -190,168 +202,282 @@
 #define First_Position_In_Current_Field(form) \
   (((form)->currow==0) && ((form)->curcol==0))
 
-
 #define Minimum(a,b) (((a)<=(b)) ? (a) : (b))
 #define Maximum(a,b) (((a)>=(b)) ? (a) : (b))
-
+
+/*----------------------------------------------------------------------------
+  Useful constants
+  --------------------------------------------------------------------------*/
+static FIELD_CELL myBLANK = BLANK;
+static FIELD_CELL myZEROS;
+
+/*----------------------------------------------------------------------------
+  Wide-character special functions
+  --------------------------------------------------------------------------*/
+#if USE_WIDEC_SUPPORT
+/* like winsnstr */
+static int
+wins_wchnstr(WINDOW *w, cchar_t *s, int n)
+{
+  int code = ERR;
+  int y, x;
+
+  while (n-- > 0)
+    {
+      getyx(w, y, x);
+      if ((code = wins_wch(w, s++)) != OK)
+	break;
+      if ((code = wmove(w, y, x + 1)) != OK)
+	break;
+    }
+  return code;
+}
+
+/* win_wchnstr is inconsistent with winnstr, since it returns OK rather than
+ * the number of items transferred.
+ */
+static int
+fix_wchnstr(WINDOW *w, cchar_t *s, int n)
+{
+  win_wchnstr(w, s, n);
+  return n;
+}
+
+/*
+ * Returns the column of the base of the given cell.
+ */
+static int
+cell_base(WINDOW *win, int y, int x)
+{
+  int result = x;
+
+  while (LEGALYX(win, y, x))
+    {
+      cchar_t *data = &(win->_line[y].text[x]);
+
+      if (isWidecBase(CHDEREF(data)) || !isWidecExt(CHDEREF(data)))
+	{
+	  result = x;
+	  break;
+	}
+      --x;
+    }
+  return result;
+}
+
+/*
+ * Returns the number of columns needed for the given cell in a window.
+ */
+static int
+cell_width(WINDOW *win, int y, int x)
+{
+  int result = 1;
+
+  if (LEGALYX(win, y, x))
+    {
+      cchar_t *data = &(win->_line[y].text[x]);
+
+      if (isWidecExt(CHDEREF(data)))
+	{
+	  /* recur, providing the number of columns to the next character */
+	  result = cell_width(win, y, x - 1);
+	}
+      else
+	{
+	  result = wcwidth(CharOf(CHDEREF(data)));
+	}
+    }
+  return result;
+}
+
+/*
+ * There is no wide-character function such as wdel_wch(), so we must find
+ * all of the cells that comprise a multi-column character and delete them
+ * one-by-one.
+ */
+static void
+delete_char(FORM *form)
+{
+  int cells = cell_width(form->w, form->currow, form->curcol);
+
+  form->curcol = cell_base(form->w, form->currow, form->curcol);
+  wmove(form->w, form->currow, form->curcol);
+  while (cells-- > 0)
+    {
+      wdelch(form->w);
+    }
+}
+#define DeleteChar(form) delete_char(form)
+#else
+#define DeleteChar(form) \
+	  wmove((form)->w, (form)->currow, (form)->curcol), \
+	  wdelch((form)->w)
+#endif
+
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static char *Get_Start_Of_Data(char * buf, int blen)
-|   
+|
 |   Description   :  Return pointer to first non-blank position in buffer.
 |                    If buffer is empty return pointer to buffer itself.
 |
 |   Return Values :  Pointer to first non-blank position in buffer
 +--------------------------------------------------------------------------*/
-INLINE static char *Get_Start_Of_Data(char * buf, int blen)
+INLINE static FIELD_CELL *
+Get_Start_Of_Data(FIELD_CELL *buf, int blen)
 {
-  char *p   = buf;
-  char *end = &buf[blen];
+  FIELD_CELL *p = buf;
+  FIELD_CELL *end = &buf[blen];
 
-  assert(buf && blen>=0);
-  while( (p < end) && is_blank(*p) ) 
+  assert(buf && blen >= 0);
+  while ((p < end) && ISBLANK(*p))
     p++;
-  return( (p==end) ? buf : p );
+  return ((p == end) ? buf : p);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static char *After_End_Of_Data(char * buf, int blen)
-|   
+|
 |   Description   :  Return pointer after last non-blank position in buffer.
 |                    If buffer is empty, return pointer to buffer itself.
 |
-|   Return Values :  Pointer to position after last non-blank position in 
+|   Return Values :  Pointer to position after last non-blank position in
 |                    buffer.
 +--------------------------------------------------------------------------*/
-INLINE static char *After_End_Of_Data(char * buf,int blen)
+INLINE static FIELD_CELL *
+After_End_Of_Data(FIELD_CELL *buf, int blen)
 {
-  char *p   = &buf[blen];
-  
-  assert(buf && blen>=0);
-  while( (p>buf) && is_blank(p[-1]) ) 
+  FIELD_CELL *p = &buf[blen];
+
+  assert(buf && blen >= 0);
+  while ((p > buf) && ISBLANK(p[-1]))
     p--;
-  return( p );
+  return (p);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static char *Get_First_Whitespace_Character(
 |                                     char * buf, int   blen)
-|   
+|
 |   Description   :  Position to the first whitespace character.
 |
 |   Return Values :  Pointer to first whitespace character in buffer.
 +--------------------------------------------------------------------------*/
-INLINE static char *Get_First_Whitespace_Character(char * buf, int blen)
+INLINE static FIELD_CELL *
+Get_First_Whitespace_Character(FIELD_CELL *buf, int blen)
 {
-  char *p   = buf;
-  char *end = &p[blen];
-  
-  assert(buf && blen>=0);
-  while( (p < end) && !is_blank(*p)) 
+  FIELD_CELL *p = buf;
+  FIELD_CELL *end = &p[blen];
+
+  assert(buf && blen >= 0);
+  while ((p < end) && !ISBLANK(*p))
     p++;
-  return( (p==end) ? buf : p );
+  return ((p == end) ? buf : p);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static char *After_Last_Whitespace_Character(
 |                                     char * buf, int blen)
-|   
+|
 |   Description   :  Get the position after the last whitespace character.
 |
-|   Return Values :  Pointer to position after last whitespace character in 
+|   Return Values :  Pointer to position after last whitespace character in
 |                    buffer.
 +--------------------------------------------------------------------------*/
-INLINE static char *After_Last_Whitespace_Character(char * buf, int blen)
+INLINE static FIELD_CELL *
+After_Last_Whitespace_Character(FIELD_CELL *buf, int blen)
 {
-  char *p   = &buf[blen];
-  
-  assert(buf && blen>=0);
-  while( (p>buf) && !is_blank(p[-1]) ) 
+  FIELD_CELL *p = &buf[blen];
+
+  assert(buf && blen >= 0);
+  while ((p > buf) && !ISBLANK(p[-1]))
     p--;
-  return( p );
+  return (p);
 }
 
 /* Set this to 1 to use the div_t version. This is a good idea if your
    compiler has an intrinsic div() support. Unfortunately GNU-C has it
-   not yet. 
+   not yet.
    N.B.: This only works if form->curcol follows immediately form->currow
-         and both are of type int. 
+         and both are of type int.
 */
 #define USE_DIV_T (0)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void Adjust_Cursor_Position(
 |                                       FORM * form, const char * pos)
-|   
-|   Description   :  Set current row and column of the form to values 
+|
+|   Description   :  Set current row and column of the form to values
 |                    corresponding to the buffer position.
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-INLINE static void Adjust_Cursor_Position(FORM * form, const char * pos)
+INLINE static void
+Adjust_Cursor_Position(FORM *form, const FIELD_CELL *pos)
 {
   FIELD *field;
   int idx;
 
   field = form->current;
-  assert( pos >= field->buf && field->dcols > 0);
-  idx = (int)( pos - field->buf );
+  assert(pos >= field->buf && field->dcols > 0);
+  idx = (int)(pos - field->buf);
 #if USE_DIV_T
-  *((div_t *)&(form->currow)) = div(idx,field->dcols);
+  *((div_t *) & (form->currow)) = div(idx, field->dcols);
 #else
   form->currow = idx / field->dcols;
   form->curcol = idx - field->cols * form->currow;
-#endif  
-  if ( field->drows < form->currow )
+#endif
+  if (field->drows < form->currow)
     form->currow = 0;
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void Buffer_To_Window(
 |                                      const FIELD  * field,
 |                                      WINDOW * win)
-|   
+|
 |   Description   :  Copy the buffer to the window. If it is a multi-line
 |                    field, the buffer is split to the lines of the
 |                    window without any editing.
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Buffer_To_Window(const FIELD  * field, WINDOW * win)
+static void
+Buffer_To_Window(const FIELD *field, WINDOW *win)
 {
   int width, height;
   int len;
   int row;
-  char *pBuffer;
+  FIELD_CELL *pBuffer;
 
   assert(win && field);
 
-  width  = getmaxx(win);
+  width = getmaxx(win);
   height = getmaxy(win);
 
-  for(row=0, pBuffer=field->buf; 
-      row < height; 
-      row++, pBuffer += width )
+  for (row = 0, pBuffer = field->buf;
+       row < height;
+       row++, pBuffer += width)
     {
-      if ((len = (int)( After_End_Of_Data( pBuffer, width ) - pBuffer )) > 0)
+      if ((len = (int)(After_End_Of_Data(pBuffer, width) - pBuffer)) > 0)
 	{
-	  wmove( win, row, 0 );
-	  waddnstr( win, pBuffer, len );
+	  wmove(win, row, 0);
+	  myADDNSTR(win, pBuffer, len);
 	}
-    }	
+    }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void Window_To_Buffer(
 |                                          WINDOW * win,
 |                                          FIELD  * field)
-|   
+|
 |   Description   :  Copy the content of the window into the buffer.
 |                    The multiple lines of a window are simply
 |                    concatenated into the buffer. Pad characters in
@@ -359,42 +485,48 @@
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Window_To_Buffer(WINDOW * win, FIELD  * field)
+static void
+Window_To_Buffer(WINDOW *win, FIELD *field)
 {
   int pad;
   int len = 0;
-  char *p;
+  FIELD_CELL *p;
   int row, height;
-  
-  assert(win && field && field->buf );
+
+  assert(win && field && field->buf);
 
   pad = field->pad;
   p = field->buf;
   height = getmaxy(win);
 
-  for(row=0; (row < height) && (row < field->drows); row++ )
+  for (row = 0; (row < height) && (row < field->drows); row++)
     {
-      wmove( win, row, 0 );
-      len += winnstr( win, p+len, field->dcols );
+      wmove(win, row, 0);
+      len += myINNSTR(win, p + len, field->dcols);
     }
-  p[len] = '\0';
+  p[len] = myZEROS;
 
   /* replace visual padding character by blanks in buffer */
   if (pad != C_BLANK)
     {
       int i;
-      for(i=0; i<len; i++, p++)
+
+      for (i = 0; i < len; i++, p++)
 	{
-	  if (*p==pad) 
-	    *p = C_BLANK;
+	  if ((unsigned long)CharOf(*p) == ChCharOf(pad)
+#if USE_WIDEC_SUPPORT
+	      && p->chars[1] == 0
+#endif
+	      && AttrOf(*p) == ChAttrOf(pad))
+	    *p = myBLANK;
 	}
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void Synchronize_Buffer(FORM * form)
-|   
+|
 |   Description   :  If there was a change, copy the content of the
 |                    window into the buffer, so the buffer is synchronized
 |                    with the windows content. We have to indicate that the
@@ -402,21 +534,22 @@
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-INLINE static void Synchronize_Buffer(FORM * form)
+INLINE static void
+Synchronize_Buffer(FORM *form)
 {
   if (form->status & _WINDOW_MODIFIED)
     {
       form->status &= ~_WINDOW_MODIFIED;
-      form->status |=  _FCHECK_REQUIRED;
-      Window_To_Buffer(form->w,form->current);
-      wmove(form->w,form->currow,form->curcol);
+      form->status |= _FCHECK_REQUIRED;
+      Window_To_Buffer(form->w, form->current);
+      wmove(form->w, form->currow, form->curcol);
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Field_Grown( FIELD *field, int amount)
-|   
+|
 |   Description   :  This function is called for growable dynamic fields
 |                    only. It has to increase the buffers and to allocate
 |                    a new window for this field.
@@ -427,7 +560,8 @@
 |   Return Values :  TRUE     - field successfully increased
 |                    FALSE    - there was some error
 +--------------------------------------------------------------------------*/
-static bool Field_Grown(FIELD * field, int amount)
+static bool
+Field_Grown(FIELD *field, int amount)
 {
   bool result = FALSE;
 
@@ -438,23 +572,23 @@
       int new_buflen;
       int old_dcols = field->dcols;
       int old_drows = field->drows;
-      char *oldbuf  = field->buf;
-      char *newbuf;
+      FIELD_CELL *oldbuf = field->buf;
+      FIELD_CELL *newbuf;
 
       int growth;
       FORM *form = field->form;
-      bool need_visual_update = ((form != (FORM *)0)      &&
+      bool need_visual_update = ((form != (FORM *)0) &&
 				 (form->status & _POSTED) &&
-				 (form->current==field));
-      
+				 (form->current == field));
+
       if (need_visual_update)
 	Synchronize_Buffer(form);
-      
+
       if (single_line_field)
 	{
 	  growth = field->cols * amount;
 	  if (field->maxgrow)
-	    growth = Minimum(field->maxgrow - field->dcols,growth);
+	    growth = Minimum(field->maxgrow - field->dcols, growth);
 	  field->dcols += growth;
 	  if (field->dcols == field->maxgrow)
 	    field->status &= ~_MAY_GROW;
@@ -463,96 +597,113 @@
 	{
 	  growth = (field->rows + field->nrow) * amount;
 	  if (field->maxgrow)
-	    growth = Minimum(field->maxgrow - field->drows,growth);
+	    growth = Minimum(field->maxgrow - field->drows, growth);
 	  field->drows += growth;
 	  if (field->drows == field->maxgrow)
 	    field->status &= ~_MAY_GROW;
 	}
       /* drows, dcols changed, so we get really the new buffer length */
       new_buflen = Buffer_Length(field);
-      newbuf=(char *)malloc((size_t)Total_Buffer_Size(field));
+      newbuf = (FIELD_CELL *)malloc(Total_Buffer_Size(field));
       if (!newbuf)
-	{ /* restore to previous state */
+	{
+	  /* restore to previous state */
 	  field->dcols = old_dcols;
 	  field->drows = old_drows;
-	  if (( single_line_field && (field->dcols!=field->maxgrow)) ||
-	      (!single_line_field && (field->drows!=field->maxgrow)))
+	  if ((single_line_field && (field->dcols != field->maxgrow)) ||
+	      (!single_line_field && (field->drows != field->maxgrow)))
 	    field->status |= _MAY_GROW;
-	  return FALSE;
 	}
       else
-	{ /* Copy all the buffers. This is the reason why we can't
-	     just use realloc().
-	     */
-	  int i;
-	  char *old_bp;
-	  char *new_bp;
-	  
+	{
+	  /* Copy all the buffers.  This is the reason why we can't just use
+	   * realloc().
+	   */
+	  int i, j;
+	  FIELD_CELL *old_bp;
+	  FIELD_CELL *new_bp;
+
+	  result = TRUE;	/* allow sharing of recovery on failure */
+
 	  field->buf = newbuf;
-	  for(i=0;i<=field->nbuf;i++)
+	  for (i = 0; i <= field->nbuf; i++)
+	    {
+	      new_bp = Address_Of_Nth_Buffer(field, i);
+	      old_bp = oldbuf + i * (1 + old_buflen);
+	      for (j = 0; j < old_buflen; ++j)
+		new_bp[j] = old_bp[j];
+	      while (j < new_buflen)
+		new_bp[j++] = myBLANK;
+	      new_bp[new_buflen] = myZEROS;
+	    }
+
+#if USE_WIDEC_SUPPORT
+	  if (wresize(field->working, 1, Buffer_Length(field) + 1) == ERR)
+	    result = FALSE;
+#endif
+
+	  if (need_visual_update && result)
 	    {
-	      new_bp = Address_Of_Nth_Buffer(field,i);
-	      old_bp = oldbuf + i*(1+old_buflen);
-	      memcpy(new_bp,old_bp,(size_t)old_buflen);
-	      if (new_buflen > old_buflen)
-		memset(new_bp + old_buflen,C_BLANK,
-		       (size_t)(new_buflen - old_buflen));
-	      *(new_bp + new_buflen) = '\0';
-	    }
-
-	  if (need_visual_update)
-	    { 	      
-	      WINDOW *new_window = newpad(field->drows,field->dcols);
-	      if (!new_window)
-		{ /* restore old state */
-		  field->dcols = old_dcols;
-		  field->drows = old_drows;
-		  field->buf   = oldbuf;
-		  if (( single_line_field              && 
-			(field->dcols!=field->maxgrow)) ||
-		      (!single_line_field              && 
-		       (field->drows!=field->maxgrow)))
-		    field->status |= _MAY_GROW;
-		  free( newbuf );
-		  return FALSE;
+	      WINDOW *new_window = newpad(field->drows, field->dcols);
+
+	      if (new_window != 0)
+		{
+		  assert(form != (FORM *)0);
+		  if (form->w)
+		    delwin(form->w);
+		  form->w = new_window;
+		  Set_Field_Window_Attributes(field, form->w);
+		  werase(form->w);
+		  Buffer_To_Window(field, form->w);
+		  untouchwin(form->w);
+		  wmove(form->w, form->currow, form->curcol);
 		}
-	      assert(form!=(FORM *)0);
-	      if (form->w)
-		delwin(form->w);
-	      form->w = new_window;
-	      Set_Field_Window_Attributes(field,form->w);
-	      werase(form->w);
-	      Buffer_To_Window(field,form->w);
-	      untouchwin(form->w);
-	      wmove(form->w,form->currow,form->curcol);
+	      else
+		result = FALSE;
 	    }
 
-	  free(oldbuf);
-	  /* reflect changes in linked fields */
-	  if (field != field->link)
-	    {
-	      FIELD *linked_field;
-	      for(linked_field = field->link;
-		  linked_field!= field;
-		  linked_field = linked_field->link)
+	  if (result)
+	    {
+	      free(oldbuf);
+	      /* reflect changes in linked fields */
+	      if (field != field->link)
 		{
-		  linked_field->buf   = field->buf;
-		  linked_field->drows = field->drows;
-		  linked_field->dcols = field->dcols;
+		  FIELD *linked_field;
+
+		  for (linked_field = field->link;
+		       linked_field != field;
+		       linked_field = linked_field->link)
+		    {
+		      linked_field->buf = field->buf;
+		      linked_field->drows = field->drows;
+		      linked_field->dcols = field->dcols;
+		    }
 		}
 	    }
-	  result = TRUE;
-	}	
+	  else
+	    {
+	      /* restore old state */
+	      field->dcols = old_dcols;
+	      field->drows = old_drows;
+	      field->buf = oldbuf;
+	      if ((single_line_field &&
+		   (field->dcols != field->maxgrow)) ||
+		  (!single_line_field &&
+		   (field->drows != field->maxgrow)))
+		field->status |= _MAY_GROW;
+	      free(newbuf);
+	    }
+	}
     }
-  return(result);
+  return (result);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int _nc_Position_Form_Cursor(FORM * form)
-|   
+|
 |   Description   :  Position the cursor in the window for the current
-|                    field to be in sync. with the currow and curcol 
+|                    field to be in sync. with the currow and curcol
 |                    values.
 |
 |   Return Values :  E_OK              - success
@@ -561,39 +712,39 @@
 |                                        field-window
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-_nc_Position_Form_Cursor (FORM * form)
+_nc_Position_Form_Cursor(FORM *form)
 {
-  FIELD  *field;
+  FIELD *field;
   WINDOW *formwin;
-  
+
   if (!form)
-    return(E_BAD_ARGUMENT);
+    return (E_BAD_ARGUMENT);
 
-  if (!form->w || !form->current) 
-    return(E_SYSTEM_ERROR);
+  if (!form->w || !form->current)
+    return (E_SYSTEM_ERROR);
 
-  field    = form->current;
-  formwin  = Get_Form_Window(form);
+  field = form->current;
+  formwin = Get_Form_Window(form);
 
-  wmove( form->w, form->currow, form->curcol );
-  if ( Has_Invisible_Parts(field) )
+  wmove(form->w, form->currow, form->curcol);
+  if (Has_Invisible_Parts(field))
     {
       /* in this case fieldwin isn't derived from formwin, so we have
-	 to move the cursor in formwin by hand... */
+         to move the cursor in formwin by hand... */
       wmove(formwin,
 	    field->frow + form->currow - form->toprow,
 	    field->fcol + form->curcol - form->begincol);
       wcursyncup(formwin);
     }
-  else 
+  else
     wcursyncup(form->w);
-  return(E_OK);
+  return (E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int _nc_Refresh_Current_Field(FORM * form)
-|   
+|
 |   Description   :  Propagate the changes in the fields window to the
 |                    window of the form.
 |
@@ -602,19 +753,21 @@
 |                    E_SYSTEM_ERROR    - general error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-_nc_Refresh_Current_Field (FORM * form)
+_nc_Refresh_Current_Field(FORM *form)
 {
   WINDOW *formwin;
-  FIELD  *field;
+  FIELD *field;
+
+  T((T_CALLED("_nc_Refresh_Current_Field(%p)"), form));
 
   if (!form)
     RETURN(E_BAD_ARGUMENT);
 
-  if (!form->w || !form->current) 
+  if (!form->w || !form->current)
     RETURN(E_SYSTEM_ERROR);
 
-  field    = form->current;
-  formwin  = Get_Form_Window(form);
+  field = form->current;
+  formwin = Get_Form_Window(form);
 
   if (field->opts & O_PUBLIC)
     {
@@ -623,13 +776,14 @@
 	  /* Again, in this case the fieldwin isn't derived from formwin,
 	     so we have to perform a copy operation. */
 	  if (Single_Line_Field(field))
-	    { /* horizontal scrolling */
+	    {
+	      /* horizontal scrolling */
 	      if (form->curcol < form->begincol)
-		  form->begincol = form->curcol;
+		form->begincol = form->curcol;
 	      else
 		{
 		  if (form->curcol >= (form->begincol + field->cols))
-		      form->begincol = form->curcol - field->cols + 1;
+		    form->begincol = form->curcol - field->cols + 1;
 		}
 	      copywin(form->w,
 		      formwin,
@@ -642,8 +796,9 @@
 		      0);
 	    }
 	  else
-	    { /* A multi-line, i.e. vertical scrolling field */
-	      int row_after_bottom,first_modified_row,first_unmodified_row;
+	    {
+	      /* A multi-line, i.e. vertical scrolling field */
+	      int row_after_bottom, first_modified_row, first_unmodified_row;
 
 	      if (field->drows > field->rows)
 		{
@@ -659,25 +814,27 @@
 		      field->status |= _NEWTOP;
 		    }
 		  if (field->status & _NEWTOP)
-		    { /* means we have to copy whole range */
+		    {
+		      /* means we have to copy whole range */
 		      first_modified_row = form->toprow;
 		      first_unmodified_row = first_modified_row + field->rows;
 		      field->status &= ~_NEWTOP;
 		    }
-		  else 
-		    { /* we try to optimize : finding the range of touched
-                         lines */
+		  else
+		    {
+		      /* we try to optimize : finding the range of touched
+		         lines */
 		      first_modified_row = form->toprow;
-		      while(first_modified_row < row_after_bottom)
+		      while (first_modified_row < row_after_bottom)
 			{
-			  if (is_linetouched(form->w,first_modified_row)) 
+			  if (is_linetouched(form->w, first_modified_row))
 			    break;
 			  first_modified_row++;
 			}
 		      first_unmodified_row = first_modified_row;
-		      while(first_unmodified_row < row_after_bottom)
+		      while (first_unmodified_row < row_after_bottom)
 			{
-			  if (!is_linetouched(form->w,first_unmodified_row)) 
+			  if (!is_linetouched(form->w, first_unmodified_row))
 			    break;
 			  first_unmodified_row++;
 			}
@@ -685,7 +842,7 @@
 		}
 	      else
 		{
-		  first_modified_row   = form->toprow;
+		  first_modified_row = form->toprow;
 		  first_unmodified_row = first_modified_row + field->rows;
 		}
 	      if (first_unmodified_row != first_modified_row)
@@ -702,45 +859,47 @@
 	  wsyncup(formwin);
 	}
       else
-	{ /* if the field-window is simply a derived window, i.e. contains
-	     no invisible parts, the whole thing is trivial 
-	  */
+	{
+	  /* if the field-window is simply a derived window, i.e. contains no
+	   * invisible parts, the whole thing is trivial
+	   */
 	  wsyncup(form->w);
 	}
     }
   untouchwin(form->w);
-  return _nc_Position_Form_Cursor(form);
+  returnCode(_nc_Position_Form_Cursor(form));
 }
-	
+
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void Perform_Justification(
 |                                        FIELD  * field,
 |                                        WINDOW * win)
-|   
-|   Description   :  Output field with requested justification 
+|
+|   Description   :  Output field with requested justification
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Perform_Justification(FIELD  * field, WINDOW * win)
+static void
+Perform_Justification(FIELD *field, WINDOW *win)
 {
-  char *bp;
+  FIELD_CELL *bp;
   int len;
-  int col  = 0;
+  int col = 0;
 
-  bp  = Get_Start_Of_Data(field->buf,Buffer_Length(field));
-  len = (int)(After_End_Of_Data(field->buf,Buffer_Length(field)) - bp);
+  bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
+  len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
 
-  if (len>0)
+  if (len > 0)
     {
       assert(win && (field->drows == 1) && (field->dcols == field->cols));
 
-      switch(field->just)
+      switch (field->just)
 	{
 	case JUSTIFY_LEFT:
 	  break;
 	case JUSTIFY_CENTER:
-	  col = (field->cols - len)/2;
+	  col = (field->cols - len) / 2;
 	  break;
 	case JUSTIFY_RIGHT:
 	  col = field->cols - len;
@@ -749,77 +908,79 @@
 	  break;
 	}
 
-      wmove(win,0,col);
-      waddnstr(win,bp,len);
+      wmove(win, 0, col);
+      myADDNSTR(win, bp, len);
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static void Undo_Justification(
 |                                     FIELD  * field,
 |                                     WINDOW * win)
-|   
+|
 |   Description   :  Display field without any justification, i.e.
 |                    left justified
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Undo_Justification(FIELD  * field, WINDOW * win)
+static void
+Undo_Justification(FIELD *field, WINDOW *win)
 {
-  char *bp;
+  FIELD_CELL *bp;
   int len;
 
-  bp  = Get_Start_Of_Data(field->buf,Buffer_Length(field));
-  len = (int)(After_End_Of_Data(field->buf,Buffer_Length(field))-bp);
+  bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
+  len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
 
-  if (len>0)
+  if (len > 0)
     {
       assert(win);
-      wmove(win,0,0);
-      waddnstr(win,bp,len);
+      wmove(win, 0, 0);
+      myADDNSTR(win, bp, len);
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Check_Char(
 |                                           FIELDTYPE * typ,
 |                                           int ch,
 |                                           TypeArgument *argp)
-|   
+|
 |   Description   :  Perform a single character check for character ch
-|                    according to the fieldtype instance.  
+|                    according to the fieldtype instance.
 |
 |   Return Values :  TRUE             - Character is valid
 |                    FALSE            - Character is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_Char(FIELDTYPE * typ, int ch, TypeArgument *argp)
+static bool
+Check_Char(FIELDTYPE *typ, int ch, TypeArgument *argp)
 {
-  if (typ) 
+  if (typ)
     {
       if (typ->status & _LINKED_TYPE)
 	{
 	  assert(argp);
-	  return(
-	    Check_Char(typ->left ,ch,argp->left ) ||
-	    Check_Char(typ->right,ch,argp->right) );
-	} 
-      else 
+	  return (
+		   Check_Char(typ->left, ch, argp->left) ||
+		   Check_Char(typ->right, ch, argp->right));
+	}
+      else
 	{
 	  if (typ->ccheck)
-	    return typ->ccheck(ch,(void *)argp);
+	    return typ->ccheck(ch, (void *)argp);
 	}
     }
-  return (isprint((unsigned char)ch) ? TRUE : FALSE);
+  return (!iscntrl(UChar(ch)) ? TRUE : FALSE);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Display_Or_Erase_Field(
 |                                           FIELD * field,
 |                                           bool bEraseFlag)
-|   
+|
 |   Description   :  Create a subwindow for the field and display the
 |                    buffer contents (apply justification if required)
 |                    or simply erase the field.
@@ -827,7 +988,8 @@
 |   Return Values :  E_OK           - on success
 |                    E_SYSTEM_ERROR - some error (typical no memory)
 +--------------------------------------------------------------------------*/
-static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
+static int
+Display_Or_Erase_Field(FIELD *field, bool bEraseFlag)
 {
   WINDOW *win;
   WINDOW *fwin;
@@ -836,17 +998,17 @@
     return E_SYSTEM_ERROR;
 
   fwin = Get_Form_Window(field->form);
-  win  = derwin(fwin,
-		field->rows,field->cols,field->frow,field->fcol);
+  win = derwin(fwin,
+	       field->rows, field->cols, field->frow, field->fcol);
 
-  if (!win) 
+  if (!win)
     return E_SYSTEM_ERROR;
   else
     {
       if (field->opts & O_VISIBLE)
-	Set_Field_Window_Attributes(field,win);
+	Set_Field_Window_Attributes(field, win);
       else
-	wattrset(win,getattrs(fwin));
+	wattrset(win, getattrs(fwin));
       werase(win);
     }
 
@@ -855,9 +1017,9 @@
       if (field->opts & O_PUBLIC)
 	{
 	  if (Justification_Allowed(field))
-	    Perform_Justification(field,win);
+	    Perform_Justification(field, win);
 	  else
-	    Buffer_To_Window(field,win);
+	    Buffer_To_Window(field, win);
 	}
       field->status &= ~_NEWTOP;
     }
@@ -871,156 +1033,157 @@
 #define Erase_Field(field)   Display_Or_Erase_Field(field,TRUE)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Synchronize_Field(FIELD * field)
-|   
+|
 |   Description   :  Synchronize the windows content with the value in
 |                    the buffer.
 |
 |   Return Values :  E_OK                - success
-|                    E_BAD_ARGUMENT      - invalid field pointer 
+|                    E_BAD_ARGUMENT      - invalid field pointer
 |                    E_SYSTEM_ERROR      - some severe basic error
 +--------------------------------------------------------------------------*/
-static int Synchronize_Field(FIELD * field)
+static int
+Synchronize_Field(FIELD *field)
 {
   FORM *form;
   int res = E_OK;
 
   if (!field)
-    return(E_BAD_ARGUMENT);
+    return (E_BAD_ARGUMENT);
 
-  if (((form=field->form) != (FORM *)0)
+  if (((form = field->form) != (FORM *)0)
       && Field_Really_Appears(field))
     {
       if (field == form->current)
-	{ 
-	  form->currow  = form->curcol = form->toprow = form->begincol = 0;
+	{
+	  form->currow = form->curcol = form->toprow = form->begincol = 0;
 	  werase(form->w);
-      
-	  if ( (field->opts & O_PUBLIC) && Justification_Allowed(field) )
-	    Undo_Justification( field, form->w );
+
+	  if ((field->opts & O_PUBLIC) && Justification_Allowed(field))
+	    Undo_Justification(field, form->w);
 	  else
-	    Buffer_To_Window( field, form->w );
-	  
+	    Buffer_To_Window(field, form->w);
+
 	  field->status |= _NEWTOP;
-	  res = _nc_Refresh_Current_Field( form );
+	  res = _nc_Refresh_Current_Field(form);
 	}
       else
-	res = Display_Field( field );
+	res = Display_Field(field);
     }
   field->status |= _CHANGED;
-  return(res);
+  return (res);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Synchronize_Linked_Fields(FIELD * field)
-|   
+|
 |   Description   :  Propagate the Synchronize_Field function to all linked
 |                    fields. The first error that occurs in the sequence
 |                    of updates is the return value.
 |
 |   Return Values :  E_OK                - success
-|                    E_BAD_ARGUMENT      - invalid field pointer 
+|                    E_BAD_ARGUMENT      - invalid field pointer
 |                    E_SYSTEM_ERROR      - some severe basic error
 +--------------------------------------------------------------------------*/
-static int Synchronize_Linked_Fields(FIELD * field)
+static int
+Synchronize_Linked_Fields(FIELD *field)
 {
   FIELD *linked_field;
   int res = E_OK;
   int syncres;
 
   if (!field)
-    return(E_BAD_ARGUMENT);
+    return (E_BAD_ARGUMENT);
 
   if (!field->link)
-    return(E_SYSTEM_ERROR);
+    return (E_SYSTEM_ERROR);
 
-  for(linked_field = field->link; 
-      linked_field!= field;
-      linked_field = linked_field->link )
+  for (linked_field = field->link;
+       linked_field != field;
+       linked_field = linked_field->link)
     {
-      if (((syncres=Synchronize_Field(linked_field)) != E_OK) &&
-	  (res==E_OK))
+      if (((syncres = Synchronize_Field(linked_field)) != E_OK) &&
+	  (res == E_OK))
 	res = syncres;
     }
-  return(res);
+  return (res);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int _nc_Synchronize_Attributes(FIELD * field)
-|   
+|
 |   Description   :  If a fields visual attributes have changed, this
 |                    routine is called to propagate those changes to the
-|                    screen.  
+|                    screen.
 |
 |   Return Values :  E_OK             - success
 |                    E_BAD_ARGUMENT   - invalid field pointer
 |                    E_SYSTEM_ERROR   - some severe basic error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-_nc_Synchronize_Attributes (FIELD * field)
+_nc_Synchronize_Attributes(FIELD *field)
 {
   FORM *form;
   int res = E_OK;
   WINDOW *formwin;
 
   if (!field)
-    return(E_BAD_ARGUMENT);
+    return (E_BAD_ARGUMENT);
 
-  if (((form=field->form) != (FORM *)0)
+  if (((form = field->form) != (FORM *)0)
       && Field_Really_Appears(field))
-    {    
-      if (form->current==field)
+    {
+      if (form->current == field)
 	{
 	  Synchronize_Buffer(form);
-	  Set_Field_Window_Attributes(field,form->w);
+	  Set_Field_Window_Attributes(field, form->w);
 	  werase(form->w);
 	  if (field->opts & O_PUBLIC)
 	    {
 	      if (Justification_Allowed(field))
-		Undo_Justification(field,form->w);
-	      else 
-		Buffer_To_Window(field,form->w);
-	    }
-	  else 
-	    {
-	      formwin = Get_Form_Window(form); 
-	      copywin(form->w,formwin,
-		      0,0,
-		      field->frow,field->fcol,
-		      field->rows-1,field->cols-1,0);
+		Undo_Justification(field, form->w);
+	      else
+		Buffer_To_Window(field, form->w);
+	    }
+	  else
+	    {
+	      formwin = Get_Form_Window(form);
+	      copywin(form->w, formwin,
+		      0, 0,
+		      field->frow, field->fcol,
+		      field->rows - 1, field->cols - 1, 0);
 	      wsyncup(formwin);
-	      Buffer_To_Window(field,form->w);
-	      field->status |= _NEWTOP; /* fake refresh to paint all */
+	      Buffer_To_Window(field, form->w);
+	      field->status |= _NEWTOP;		/* fake refresh to paint all */
 	      _nc_Refresh_Current_Field(form);
 	    }
 	}
-      else 
+      else
 	{
 	  res = Display_Field(field);
 	}
     }
-  return(res);
+  return (res);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int _nc_Synchronize_Options(FIELD * field,
 |                                                Field_Options newopts)
-|   
+|
 |   Description   :  If a fields options have changed, this routine is
 |                    called to propagate these changes to the screen and
 |                    to really change the behavior of the field.
 |
 |   Return Values :  E_OK                - success
-|                    E_BAD_ARGUMENT      - invalid field pointer 
+|                    E_BAD_ARGUMENT      - invalid field pointer
 |                    E_SYSTEM_ERROR      - some severe basic error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-_nc_Synchronize_Options
-(FIELD *field, Field_Options newopts)
+_nc_Synchronize_Options(FIELD *field, Field_Options newopts)
 {
   Field_Options oldopts;
   Field_Options changed_opts;
@@ -1028,19 +1191,19 @@
   int res = E_OK;
 
   if (!field)
-    return(E_BAD_ARGUMENT);
+    return (E_BAD_ARGUMENT);
 
-  oldopts      = field->opts;
+  oldopts = field->opts;
   changed_opts = oldopts ^ newopts;
-  field->opts  = newopts;
-  form         = field->form;
+  field->opts = newopts;
+  form = field->form;
 
   if (form)
     {
       if (form->current == field)
 	{
 	  field->opts = oldopts;
-	  return(E_CURRENT);
+	  return (E_CURRENT);
 	}
 
       if (form->status & _POSTED)
@@ -1070,12 +1233,13 @@
       int res2 = E_OK;
 
       if (newopts & O_STATIC)
-	{ /* the field becomes now static */
+	{
+	  /* the field becomes now static */
 	  field->status &= ~_MAY_GROW;
 	  /* if actually we have no hidden columns, justification may
 	     occur again */
-	  if (single_line_field                 &&
-	      (field->cols == field->dcols)     &&
+	  if (single_line_field &&
+	      (field->cols == field->dcols) &&
 	      (field->just != NO_JUSTIFICATION) &&
 	      Field_Really_Appears(field))
 	    {
@@ -1083,62 +1247,62 @@
 	    }
 	}
       else
-	{ /* field is no longer static */
-	  if ((field->maxgrow==0) ||
-	      ( single_line_field && (field->dcols < field->maxgrow)) ||
+	{
+	  /* field is no longer static */
+	  if ((field->maxgrow == 0) ||
+	      (single_line_field && (field->dcols < field->maxgrow)) ||
 	      (!single_line_field && (field->drows < field->maxgrow)))
 	    {
 	      field->status |= _MAY_GROW;
 	      /* a field with justification now changes its behavior,
-		 so we must redisplay it */
-	      if (single_line_field                 &&
+	         so we must redisplay it */
+	      if (single_line_field &&
 		  (field->just != NO_JUSTIFICATION) &&
 		  Field_Really_Appears(field))
 		{
 		  res2 = Display_Field(field);
-		}	 
-	    }     
+		}
+	    }
 	}
       if (res2 != E_OK)
 	res = res2;
     }
 
-  return(res);
+  return (res);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int _nc_Set_Current_Field(FORM  * form,
 |                                              FIELD * newfield)
-|   
+|
 |   Description   :  Make the newfield the new current field.
 |
 |   Return Values :  E_OK                - success
-|                    E_BAD_ARGUMENT      - invalid form or field pointer 
+|                    E_BAD_ARGUMENT      - invalid form or field pointer
 |                    E_SYSTEM_ERROR      - some severe basic error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-_nc_Set_Current_Field
-(FORM  *form, FIELD *newfield)
+_nc_Set_Current_Field(FORM *form, FIELD *newfield)
 {
-  FIELD  *field;
+  FIELD *field;
   WINDOW *new_window;
 
-  if (!form || !newfield || !form->current || (newfield->form!=form))
-    return(E_BAD_ARGUMENT);
+  if (!form || !newfield || !form->current || (newfield->form != form))
+    return (E_BAD_ARGUMENT);
 
-  if ( (form->status & _IN_DRIVER) )
-    return(E_BAD_STATE);
+  if ((form->status & _IN_DRIVER))
+    return (E_BAD_STATE);
 
   if (!(form->field))
-    return(E_NOT_CONNECTED);
+    return (E_NOT_CONNECTED);
 
   field = form->current;
- 
-  if ((field!=newfield) || 
+
+  if ((field != newfield) ||
       !(form->status & _POSTED))
     {
-      if ((form->w) && 
+      if ((form->w) &&
 	  (field->opts & O_VISIBLE) &&
 	  (field->form->curpage == field->page))
 	{
@@ -1147,18 +1311,18 @@
 	    {
 	      if (field->drows > field->rows)
 		{
-		  if (form->toprow==0)
+		  if (form->toprow == 0)
 		    field->status &= ~_NEWTOP;
-		  else 
+		  else
 		    field->status |= _NEWTOP;
-		} 
-	      else 
+		}
+	      else
 		{
 		  if (Justification_Allowed(field))
 		    {
-		      Window_To_Buffer(form->w,field);
+		      Window_To_Buffer(form->w, field);
 		      werase(form->w);
-		      Perform_Justification(field,form->w);
+		      Perform_Justification(field, form->w);
 		      wsyncup(form->w);
 		    }
 		}
@@ -1166,38 +1330,38 @@
 	  delwin(form->w);
 	  form->w = (WINDOW *)0;
 	}
-      
+
       field = newfield;
 
       if (Has_Invisible_Parts(field))
-	new_window = newpad(field->drows,field->dcols);
-      else 
+	new_window = newpad(field->drows, field->dcols);
+      else
 	new_window = derwin(Get_Form_Window(form),
-			    field->rows,field->cols,field->frow,field->fcol);
+			    field->rows, field->cols, field->frow, field->fcol);
 
-      if (!new_window) 
-	return(E_SYSTEM_ERROR);
+      if (!new_window)
+	return (E_SYSTEM_ERROR);
 
       form->current = field;
 
       if (form->w)
 	delwin(form->w);
-      form->w       = new_window;
+      form->w = new_window;
 
       form->status &= ~_WINDOW_MODIFIED;
-      Set_Field_Window_Attributes(field,form->w);
+      Set_Field_Window_Attributes(field, form->w);
 
       if (Has_Invisible_Parts(field))
 	{
 	  werase(form->w);
-	  Buffer_To_Window(field,form->w);
-	} 
-      else 
+	  Buffer_To_Window(field, form->w);
+	}
+      else
 	{
 	  if (Justification_Allowed(field))
 	    {
 	      werase(form->w);
-	      Undo_Justification(field,form->w);
+	      Undo_Justification(field, form->w);
 	      wsyncup(form->w);
 	    }
 	}
@@ -1206,417 +1370,461 @@
     }
 
   form->currow = form->curcol = form->toprow = form->begincol = 0;
-  return(E_OK);
+  return (E_OK);
 }
-
+
 /*----------------------------------------------------------------------------
   Intra-Field Navigation routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Next_Character(FORM * form)
-|   
+|
 |   Description   :  Move to the next character in the field. In a multi-line
 |                    field this wraps at the end of the line.
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - at the rightmost position
 +--------------------------------------------------------------------------*/
-static int IFN_Next_Character(FORM * form)
+static int
+IFN_Next_Character(FORM *form)
 {
   FIELD *field = form->current;
-  
-  if ((++(form->curcol))==field->dcols)
+  int step = myWCWIDTH(form->w, form->currow, form->curcol);
+
+  T((T_CALLED("IFN_Next_Character(%p)"), form));
+  if ((form->curcol += step) == field->dcols)
     {
-      if ((++(form->currow))==field->drows)
+      if ((++(form->currow)) == field->drows)
 	{
 #if GROW_IF_NAVIGATE
-	  if (!Single_Line_Field(field) && Field_Grown(field,1)) {
-	    form->curcol = 0;
-	    return(E_OK);
-	  }
+	  if (!Single_Line_Field(field) && Field_Grown(field, 1))
+	    {
+	      form->curcol = 0;
+	      returnCode(E_OK);
+	    }
 #endif
 	  form->currow--;
 #if GROW_IF_NAVIGATE
-	  if (Single_Line_Field(field) && Field_Grown(field,1))
-	    return(E_OK);
+	  if (Single_Line_Field(field) && Field_Grown(field, 1))
+	    returnCode(E_OK);
 #endif
-	  form->curcol--;
-	  return(E_REQUEST_DENIED);
+	  form->curcol -= step;
+	  returnCode(E_REQUEST_DENIED);
 	}
       form->curcol = 0;
     }
-  return(E_OK);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Previous_Character(FORM * form)
-|   
-|   Description   :  Move to the previous character in the field. In a 
-|                    multi-line field this wraps and the beginning of the 
+|
+|   Description   :  Move to the previous character in the field. In a
+|                    multi-line field this wraps and the beginning of the
 |                    line.
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - at the leftmost position
 +--------------------------------------------------------------------------*/
-static int IFN_Previous_Character(FORM * form)
+static int
+IFN_Previous_Character(FORM *form)
 {
-  if ((--(form->curcol))<0)
+  int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
+  int oldcol = form->curcol;
+
+  T((T_CALLED("IFN_Previous_Character(%p)"), form));
+  if ((form->curcol -= amount) < 0)
     {
-      if ((--(form->currow))<0)
+      if ((--(form->currow)) < 0)
 	{
 	  form->currow++;
-	  form->curcol++;
-	  return(E_REQUEST_DENIED);
+	  form->curcol = oldcol;
+	  returnCode(E_REQUEST_DENIED);
 	}
       form->curcol = form->current->dcols - 1;
     }
-  return(E_OK);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Next_Line(FORM * form)
-|   
+|
 |   Description   :  Move to the beginning of the next line in the field
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - at the last line
 +--------------------------------------------------------------------------*/
-static int IFN_Next_Line(FORM * form)
+static int
+IFN_Next_Line(FORM *form)
 {
   FIELD *field = form->current;
 
-  if ((++(form->currow))==field->drows)
+  T((T_CALLED("IFN_Next_Line(%p)"), form));
+  if ((++(form->currow)) == field->drows)
     {
 #if GROW_IF_NAVIGATE
-      if (!Single_Line_Field(field) && Field_Grown(field,1))
-	return(E_OK);
+      if (!Single_Line_Field(field) && Field_Grown(field, 1))
+	returnCode(E_OK);
 #endif
       form->currow--;
-      return(E_REQUEST_DENIED);
+      returnCode(E_REQUEST_DENIED);
     }
   form->curcol = 0;
-  return(E_OK);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Previous_Line(FORM * form)
-|   
+|
 |   Description   :  Move to the beginning of the previous line in the field
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - at the first line
 +--------------------------------------------------------------------------*/
-static int IFN_Previous_Line(FORM * form)
+static int
+IFN_Previous_Line(FORM *form)
 {
-  if ( (--(form->currow)) < 0 )
+  T((T_CALLED("IFN_Previous_Line(%p)"), form));
+  if ((--(form->currow)) < 0)
     {
       form->currow++;
-      return(E_REQUEST_DENIED);
+      returnCode(E_REQUEST_DENIED);
     }
   form->curcol = 0;
-  return(E_OK);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Next_Word(FORM * form)
-|   
+|
 |   Description   :  Move to the beginning of the next word in the field.
 |
 |   Return Values :  E_OK             - success
 |                    E_REQUEST_DENIED - there is no next word
 +--------------------------------------------------------------------------*/
-static int IFN_Next_Word(FORM * form)
+static int
+IFN_Next_Word(FORM *form)
 {
   FIELD *field = form->current;
-  char  *bp    = Address_Of_Current_Position_In_Buffer(form);
-  char  *s;
-  char  *t;
+  FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
+  FIELD_CELL *s;
+  FIELD_CELL *t;
+
+  T((T_CALLED("IFN_Next_Word(%p)"), form));
 
   /* We really need access to the data, so we have to synchronize */
   Synchronize_Buffer(form);
 
   /* Go to the first whitespace after the current position (including
      current position). This is then the starting point to look for the
-    next non-blank data */
-  s = Get_First_Whitespace_Character(bp,Buffer_Length(field) -
+     next non-blank data */
+  s = Get_First_Whitespace_Character(bp, Buffer_Length(field) -
 				     (int)(bp - field->buf));
 
   /* Find the start of the next word */
-  t = Get_Start_Of_Data(s,Buffer_Length(field) -
+  t = Get_Start_Of_Data(s, Buffer_Length(field) -
 			(int)(s - field->buf));
 #if !FRIENDLY_PREV_NEXT_WORD
-  if (s==t) 
-    return(E_REQUEST_DENIED);
+  if (s == t)
+    returnCode(E_REQUEST_DENIED);
   else
 #endif
     {
-      Adjust_Cursor_Position(form,t);
-      return(E_OK);
+      Adjust_Cursor_Position(form, t);
+      returnCode(E_OK);
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Previous_Word(FORM * form)
-|   
+|
 |   Description   :  Move to the beginning of the previous word in the field.
 |
 |   Return Values :  E_OK             - success
 |                    E_REQUEST_DENIED - there is no previous word
 +--------------------------------------------------------------------------*/
-static int IFN_Previous_Word(FORM * form)
+static int
+IFN_Previous_Word(FORM *form)
 {
   FIELD *field = form->current;
-  char  *bp    = Address_Of_Current_Position_In_Buffer(form);
-  char  *s;
-  char  *t;
-  bool  again = FALSE;
+  FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
+  FIELD_CELL *s;
+  FIELD_CELL *t;
+  bool again = FALSE;
+
+  T((T_CALLED("IFN_Previous_Word(%p)"), form));
 
   /* We really need access to the data, so we have to synchronize */
   Synchronize_Buffer(form);
 
-  s = After_End_Of_Data(field->buf,(int)(bp-field->buf));
+  s = After_End_Of_Data(field->buf, (int)(bp - field->buf));
   /* s points now right after the last non-blank in the buffer before bp.
      If bp was in a word, s equals bp. In this case we must find the last
      whitespace in the buffer before bp and repeat the game to really find
      the previous word! */
-  if (s==bp)
+  if (s == bp)
     again = TRUE;
-  
+
   /* And next call now goes backward to look for the last whitespace
      before that, pointing right after this, so it points to the begin
-     of the previous word. 
-  */
-  t = After_Last_Whitespace_Character(field->buf,(int)(s - field->buf));
+     of the previous word.
+   */
+  t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
 #if !FRIENDLY_PREV_NEXT_WORD
-  if (s==t) 
-    return(E_REQUEST_DENIED);
+  if (s == t)
+    returnCode(E_REQUEST_DENIED);
 #endif
   if (again)
-    { /* and do it again, replacing bp by t */
-      s = After_End_Of_Data(field->buf,(int)(t - field->buf));
-      t = After_Last_Whitespace_Character(field->buf,(int)(s - field->buf));
+    {
+      /* and do it again, replacing bp by t */
+      s = After_End_Of_Data(field->buf, (int)(t - field->buf));
+      t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
 #if !FRIENDLY_PREV_NEXT_WORD
-      if (s==t) 
-	return(E_REQUEST_DENIED);
+      if (s == t)
+	returnCode(E_REQUEST_DENIED);
 #endif
     }
-  Adjust_Cursor_Position(form,t);
-  return(E_OK);
+  Adjust_Cursor_Position(form, t);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Beginning_Of_Field(FORM * form)
-|   
+|
 |   Description   :  Place the cursor at the first non-pad character in
-|                    the field. 
+|                    the field.
 |
-|   Return Values :  E_OK             - success            
+|   Return Values :  E_OK             - success
 +--------------------------------------------------------------------------*/
-static int IFN_Beginning_Of_Field(FORM * form)
+static int
+IFN_Beginning_Of_Field(FORM *form)
 {
   FIELD *field = form->current;
 
+  T((T_CALLED("IFN_Beginning_Of_Field(%p)"), form));
   Synchronize_Buffer(form);
   Adjust_Cursor_Position(form,
-		 Get_Start_Of_Data(field->buf,Buffer_Length(field)));
-  return(E_OK);
+			 Get_Start_Of_Data(field->buf, Buffer_Length(field)));
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_End_Of_Field(FORM * form)
-|   
+|
 |   Description   :  Place the cursor after the last non-pad character in
 |                    the field. If the field occupies the last position in
-|                    the buffer, the cursor is positioned on the last 
+|                    the buffer, the cursor is positioned on the last
 |                    character.
 |
 |   Return Values :  E_OK              - success
 +--------------------------------------------------------------------------*/
-static int IFN_End_Of_Field(FORM * form)
+static int
+IFN_End_Of_Field(FORM *form)
 {
   FIELD *field = form->current;
-  char *pos;
+  FIELD_CELL *pos;
 
+  T((T_CALLED("IFN_End_Of_Field(%p)"), form));
   Synchronize_Buffer(form);
-  pos = After_End_Of_Data(field->buf,Buffer_Length(field));
-  if (pos==(field->buf + Buffer_Length(field)))
+  pos = After_End_Of_Data(field->buf, Buffer_Length(field));
+  if (pos == (field->buf + Buffer_Length(field)))
     pos--;
-  Adjust_Cursor_Position(form,pos);
-  return(E_OK);
+  Adjust_Cursor_Position(form, pos);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Beginning_Of_Line(FORM * form)
-|   
+|
 |   Description   :  Place the cursor on the first non-pad character in
 |                    the current line of the field.
 |
 |   Return Values :  E_OK         - success
 +--------------------------------------------------------------------------*/
-static int IFN_Beginning_Of_Line(FORM * form)
+static int
+IFN_Beginning_Of_Line(FORM *form)
 {
   FIELD *field = form->current;
 
+  T((T_CALLED("IFN_Beginning_Of_Line(%p)"), form));
   Synchronize_Buffer(form);
   Adjust_Cursor_Position(form,
-		 Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),
-				   field->dcols));
-  return(E_OK);
+			 Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),
+					   field->dcols));
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_End_Of_Line(FORM * form)
-|   
+|
 |   Description   :  Place the cursor after the last non-pad character in the
-|                    current line of the field. If the field occupies the 
+|                    current line of the field. If the field occupies the
 |                    last column in the line, the cursor is positioned on the
 |                    last character of the line.
 |
 |   Return Values :  E_OK        - success
 +--------------------------------------------------------------------------*/
-static int IFN_End_Of_Line(FORM * form)
+static int
+IFN_End_Of_Line(FORM *form)
 {
   FIELD *field = form->current;
-  char *pos;
-  char *bp;
+  FIELD_CELL *pos;
+  FIELD_CELL *bp;
 
+  T((T_CALLED("IFN_End_Of_Line(%p)"), form));
   Synchronize_Buffer(form);
-  bp  = Address_Of_Current_Row_In_Buffer(form); 
-  pos = After_End_Of_Data(bp,field->dcols);
+  bp = Address_Of_Current_Row_In_Buffer(form);
+  pos = After_End_Of_Data(bp, field->dcols);
   if (pos == (bp + field->dcols))
     pos--;
-  Adjust_Cursor_Position(form,pos);
-  return(E_OK);
+  Adjust_Cursor_Position(form, pos);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Left_Character(FORM * form)
-|   
+|
 |   Description   :  Move one character to the left in the current line.
-|                    This doesn't cycle.  
+|                    This doesn't cycle.
 |
 |   Return Values :  E_OK             - success
 |                    E_REQUEST_DENIED - already in first column
 +--------------------------------------------------------------------------*/
-static int IFN_Left_Character(FORM * form)
+static int
+IFN_Left_Character(FORM *form)
 {
-  if ( (--(form->curcol)) < 0 )
+  int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
+  int oldcol = form->curcol;
+
+  T((T_CALLED("IFN_Left_Character(%p)"), form));
+  if ((form->curcol -= amount) < 0)
     {
-      form->curcol++;
-      return(E_REQUEST_DENIED);
+      form->curcol = oldcol;
+      returnCode(E_REQUEST_DENIED);
     }
-  return(E_OK);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Right_Character(FORM * form)
-|   
+|
 |   Description   :  Move one character to the right in the current line.
 |                    This doesn't cycle.
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - already in last column
 +--------------------------------------------------------------------------*/
-static int IFN_Right_Character(FORM * form)
+static int
+IFN_Right_Character(FORM *form)
 {
-  if ( (++(form->curcol)) == form->current->dcols )
+  int amount = myWCWIDTH(form->w, form->currow, form->curcol);
+  int oldcol = form->curcol;
+
+  T((T_CALLED("IFN_Right_Character(%p)"), form));
+  if ((form->curcol += amount) >= form->current->dcols)
     {
 #if GROW_IF_NAVIGATE
       FIELD *field = form->current;
-      if (Single_Line_Field(field) && Field_Grown(field,1))
-	return(E_OK);
+
+      if (Single_Line_Field(field) && Field_Grown(field, 1))
+	returnCode(E_OK);
 #endif
-      --(form->curcol);
-      return(E_REQUEST_DENIED);
+      form->curcol = oldcol;
+      returnCode(E_REQUEST_DENIED);
     }
-  return(E_OK);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Up_Character(FORM * form)
-|   
+|
 |   Description   :  Move one line up. This doesn't cycle through the lines
 |                    of the field.
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - already in last column
 +--------------------------------------------------------------------------*/
-static int IFN_Up_Character(FORM * form)
+static int
+IFN_Up_Character(FORM *form)
 {
-  if ( (--(form->currow)) < 0 )
+  T((T_CALLED("IFN_Up_Character(%p)"), form));
+  if ((--(form->currow)) < 0)
     {
       form->currow++;
-      return(E_REQUEST_DENIED);
+      returnCode(E_REQUEST_DENIED);
     }
-  return(E_OK);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int IFN_Down_Character(FORM * form)
-|   
+|
 |   Description   :  Move one line down. This doesn't cycle through the
 |                    lines of the field.
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - already in last column
 +--------------------------------------------------------------------------*/
-static int IFN_Down_Character(FORM * form)
+static int
+IFN_Down_Character(FORM *form)
 {
   FIELD *field = form->current;
 
-  if ( (++(form->currow)) == field->drows )
+  T((T_CALLED("IFN_Down_Character(%p)"), form));
+  if ((++(form->currow)) == field->drows)
     {
 #if GROW_IF_NAVIGATE
-      if (!Single_Line_Field(field) && Field_Grown(field,1))
-	return(E_OK);
+      if (!Single_Line_Field(field) && Field_Grown(field, 1))
+	returnCode(E_OK);
 #endif
       --(form->currow);
-      return(E_REQUEST_DENIED);
+      returnCode(E_REQUEST_DENIED);
     }
-  return(E_OK);
+  returnCode(E_OK);
 }
 /*----------------------------------------------------------------------------
-  END of Intra-Field Navigation routines 
+  END of Intra-Field Navigation routines
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Vertical scrolling helper routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static int VSC_Generic(FORM *form, int lines)
+|   Facility      :  libnform
+|   Function      :  static int VSC_Generic(FORM *form, int nlines)
 |
-|   Description   :  Scroll multi-line field forward (lines>0) or
-|                    backward (lines<0) this many lines.
+|   Description   :  Scroll multi-line field forward (nlines>0) or
+|                    backward (nlines<0) this many lines.
 |
-|   Return Values :  E_OK              - success 
+|   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - can't scroll
 +--------------------------------------------------------------------------*/
-static int VSC_Generic(FORM *form, int lines)
+static int
+VSC_Generic(FORM *form, int nlines)
 {
   FIELD *field = form->current;
   int res = E_REQUEST_DENIED;
-  int rows_to_go = (lines > 0 ? lines : -lines);
+  int rows_to_go = (nlines > 0 ? nlines : -nlines);
 
-  if (lines > 0)
+  if (nlines > 0)
     {
-      if ( (rows_to_go + form->toprow) > (field->drows - field->rows) )
+      if ((rows_to_go + form->toprow) > (field->drows - field->rows))
 	rows_to_go = (field->drows - field->rows - form->toprow);
 
       if (rows_to_go > 0)
@@ -1630,7 +1838,7 @@
     {
       if (rows_to_go > form->toprow)
 	rows_to_go = form->toprow;
-      
+
       if (rows_to_go > 0)
 	{
 	  form->currow -= rows_to_go;
@@ -1638,29 +1846,30 @@
 	  res = E_OK;
 	}
     }
-  return(res);
+  return (res);
 }
 /*----------------------------------------------------------------------------
   End of Vertical scrolling helper routines
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Vertical scrolling routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Vertical_Scrolling(
 |                                           int (* const fct) (FORM *),
 |                                           FORM * form)
-|   
-|   Description   :  Performs the generic vertical scrolling routines. 
+|
+|   Description   :  Performs the generic vertical scrolling routines.
 |                    This has to check for a multi-line field and to set
 |                    the _NEWTOP flag if scrolling really occurred.
 |
 |   Return Values :  Propagated error code from low-level driver calls
 +--------------------------------------------------------------------------*/
-static int Vertical_Scrolling(int (* const fct) (FORM *), FORM * form)
+static int
+Vertical_Scrolling(int (*const fct) (FORM *), FORM *form)
 {
   int res = E_REQUEST_DENIED;
 
@@ -1670,299 +1879,327 @@
       if (res == E_OK)
 	form->current->status |= _NEWTOP;
     }
-  return(res);
+  return (res);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int VSC_Scroll_Line_Forward(FORM * form)
-|   
+|
 |   Description   :  Scroll multi-line field forward a line
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - no data ahead
 +--------------------------------------------------------------------------*/
-static int VSC_Scroll_Line_Forward(FORM * form)
+static int
+VSC_Scroll_Line_Forward(FORM *form)
 {
-  return VSC_Generic(form,1);
+  T((T_CALLED("VSC_Scroll_Line_Forward(%p)"), form));
+  returnCode(VSC_Generic(form, 1));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int VSC_Scroll_Line_Backward(FORM * form)
-|   
+|
 |   Description   :  Scroll multi-line field backward a line
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - no data behind
 +--------------------------------------------------------------------------*/
-static int VSC_Scroll_Line_Backward(FORM * form)
+static int
+VSC_Scroll_Line_Backward(FORM *form)
 {
-  return VSC_Generic(form,-1);
+  T((T_CALLED("VSC_Scroll_Line_Backward(%p)"), form));
+  returnCode(VSC_Generic(form, -1));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int VSC_Scroll_Page_Forward(FORM * form)
-|   
+|
 |   Description   :  Scroll a multi-line field forward a page
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - no data ahead
 +--------------------------------------------------------------------------*/
-static int VSC_Scroll_Page_Forward(FORM * form)
+static int
+VSC_Scroll_Page_Forward(FORM *form)
 {
-  return VSC_Generic(form,form->current->rows);
+  T((T_CALLED("VSC_Scroll_Page_Forward(%p)"), form));
+  returnCode(VSC_Generic(form, form->current->rows));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int VSC_Scroll_Half_Page_Forward(FORM * form)
-|   
+|
 |   Description   :  Scroll a multi-line field forward half a page
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - no data ahead
 +--------------------------------------------------------------------------*/
-static int VSC_Scroll_Half_Page_Forward(FORM * form)
+static int
+VSC_Scroll_Half_Page_Forward(FORM *form)
 {
-  return VSC_Generic(form,(form->current->rows + 1)/2);
+  T((T_CALLED("VSC_Scroll_Half_Page_Forward(%p)"), form));
+  returnCode(VSC_Generic(form, (form->current->rows + 1) / 2));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int VSC_Scroll_Page_Backward(FORM * form)
-|   
+|
 |   Description   :  Scroll a multi-line field backward a page
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - no data behind
 +--------------------------------------------------------------------------*/
-static int VSC_Scroll_Page_Backward(FORM * form)
+static int
+VSC_Scroll_Page_Backward(FORM *form)
 {
-  return VSC_Generic(form, -(form->current->rows));
+  T((T_CALLED("VSC_Scroll_Page_Backward(%p)"), form));
+  returnCode(VSC_Generic(form, -(form->current->rows)));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int VSC_Scroll_Half_Page_Backward(FORM * form)
-|   
+|
 |   Description   :  Scroll a multi-line field backward half a page
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - no data behind
 +--------------------------------------------------------------------------*/
-static int VSC_Scroll_Half_Page_Backward(FORM * form)
+static int
+VSC_Scroll_Half_Page_Backward(FORM *form)
 {
-  return VSC_Generic(form, -((form->current->rows + 1)/2));
+  T((T_CALLED("VSC_Scroll_Half_Page_Backward(%p)"), form));
+  returnCode(VSC_Generic(form, -((form->current->rows + 1) / 2)));
 }
 /*----------------------------------------------------------------------------
   End of Vertical scrolling routines
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Horizontal scrolling helper routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static int HSC_Generic(FORM *form, int columns)
+|   Facility      :  libnform
+|   Function      :  static int HSC_Generic(FORM *form, int ncolumns)
 |
-|   Description   :  Scroll single-line field forward (columns>0) or
-|                    backward (columns<0) this many columns.
+|   Description   :  Scroll single-line field forward (ncolumns>0) or
+|                    backward (ncolumns<0) this many columns.
 |
-|   Return Values :  E_OK              - success 
+|   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - can't scroll
 +--------------------------------------------------------------------------*/
-static int HSC_Generic(FORM *form, int columns)
+static int
+HSC_Generic(FORM *form, int ncolumns)
 {
   FIELD *field = form->current;
   int res = E_REQUEST_DENIED;
-  int cols_to_go = (columns > 0 ? columns : -columns);
+  int cols_to_go = (ncolumns > 0 ? ncolumns : -ncolumns);
 
-  if (columns > 0)
+  if (ncolumns > 0)
     {
       if ((cols_to_go + form->begincol) > (field->dcols - field->cols))
 	cols_to_go = field->dcols - field->cols - form->begincol;
-      
+
       if (cols_to_go > 0)
 	{
-	  form->curcol   += cols_to_go;
+	  form->curcol += cols_to_go;
 	  form->begincol += cols_to_go;
 	  res = E_OK;
 	}
     }
   else
     {
-      if ( cols_to_go > form->begincol )
+      if (cols_to_go > form->begincol)
 	cols_to_go = form->begincol;
 
       if (cols_to_go > 0)
 	{
-	  form->curcol   -= cols_to_go;
+	  form->curcol -= cols_to_go;
 	  form->begincol -= cols_to_go;
 	  res = E_OK;
 	}
     }
-  return(res);
+  return (res);
 }
 /*----------------------------------------------------------------------------
   End of Horizontal scrolling helper routines
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Horizontal scrolling routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Horizontal_Scrolling(
 |                                          int (* const fct) (FORM *),
 |                                          FORM * form)
-|   
-|   Description   :  Performs the generic horizontal scrolling routines. 
+|
+|   Description   :  Performs the generic horizontal scrolling routines.
 |                    This has to check for a single-line field.
 |
 |   Return Values :  Propagated error code from low-level driver calls
 +--------------------------------------------------------------------------*/
-static int Horizontal_Scrolling(int (* const fct) (FORM *), FORM * form)
+static int
+Horizontal_Scrolling(int (*const fct) (FORM *), FORM *form)
 {
   if (Single_Line_Field(form->current))
     return fct(form);
   else
-    return(E_REQUEST_DENIED);
+    return (E_REQUEST_DENIED);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int HSC_Scroll_Char_Forward(FORM * form)
-|   
+|
 |   Description   :  Scroll single-line field forward a character
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - no data ahead
 +--------------------------------------------------------------------------*/
-static int HSC_Scroll_Char_Forward(FORM *form)
+static int
+HSC_Scroll_Char_Forward(FORM *form)
 {
-  return HSC_Generic(form,1);
+  T((T_CALLED("HSC_Scroll_Char_Forward(%p)"), form));
+  returnCode(HSC_Generic(form, 1));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int HSC_Scroll_Char_Backward(FORM * form)
-|   
+|
 |   Description   :  Scroll single-line field backward a character
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - no data behind
 +--------------------------------------------------------------------------*/
-static int HSC_Scroll_Char_Backward(FORM *form)
+static int
+HSC_Scroll_Char_Backward(FORM *form)
 {
-  return HSC_Generic(form,-1);
+  T((T_CALLED("HSC_Scroll_Char_Backward(%p)"), form));
+  returnCode(HSC_Generic(form, -1));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int HSC_Horizontal_Line_Forward(FORM* form)
-|   
+|
 |   Description   :  Scroll single-line field forward a line
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - no data ahead
 +--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Line_Forward(FORM * form)
+static int
+HSC_Horizontal_Line_Forward(FORM *form)
 {
-  return HSC_Generic(form,form->current->cols);
+  T((T_CALLED("HSC_Horizontal_Line_Forward(%p)"), form));
+  returnCode(HSC_Generic(form, form->current->cols));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int HSC_Horizontal_Half_Line_Forward(FORM* form)
-|   
+|
 |   Description   :  Scroll single-line field forward half a line
 |
 |   Return Values :  E_OK               - success
 |                    E_REQUEST_DENIED   - no data ahead
 +--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Half_Line_Forward(FORM * form)
+static int
+HSC_Horizontal_Half_Line_Forward(FORM *form)
 {
-  return HSC_Generic(form,(form->current->cols + 1)/2);
+  T((T_CALLED("HSC_Horizontal_Half_Line_Forward(%p)"), form));
+  returnCode(HSC_Generic(form, (form->current->cols + 1) / 2));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int HSC_Horizontal_Line_Backward(FORM* form)
-|   
+|
 |   Description   :  Scroll single-line field backward a line
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - no data behind
 +--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Line_Backward(FORM * form)
+static int
+HSC_Horizontal_Line_Backward(FORM *form)
 {
-  return HSC_Generic(form,-(form->current->cols));
+  T((T_CALLED("HSC_Horizontal_Line_Backward(%p)"), form));
+  returnCode(HSC_Generic(form, -(form->current->cols)));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int HSC_Horizontal_Half_Line_Backward(FORM* form)
-|   
+|
 |   Description   :  Scroll single-line field backward half a line
 |
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - no data behind
 +--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Half_Line_Backward(FORM * form)
+static int
+HSC_Horizontal_Half_Line_Backward(FORM *form)
 {
-  return HSC_Generic(form,-((form->current->cols + 1)/2));
+  T((T_CALLED("HSC_Horizontal_Half_Line_Backward(%p)"), form));
+  returnCode(HSC_Generic(form, -((form->current->cols + 1) / 2)));
 }
 
 /*----------------------------------------------------------------------------
   End of Horizontal scrolling routines
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Helper routines for Field Editing
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Is_There_Room_For_A_Line(FORM * form)
-|   
+|
 |   Description   :  Check whether or not there is enough room in the
 |                    buffer to enter a whole line.
 |
 |   Return Values :  TRUE   - there is enough space
 |                    FALSE  - there is not enough space
 +--------------------------------------------------------------------------*/
-INLINE static bool Is_There_Room_For_A_Line(FORM * form)
+INLINE static bool
+Is_There_Room_For_A_Line(FORM *form)
 {
   FIELD *field = form->current;
-  char *begin_of_last_line, *s;
-  
+  FIELD_CELL *begin_of_last_line, *s;
+
   Synchronize_Buffer(form);
-  begin_of_last_line = Address_Of_Row_In_Buffer(field,(field->drows-1));
-  s  = After_End_Of_Data(begin_of_last_line,field->dcols);
-  return ((s==begin_of_last_line) ? TRUE : FALSE);
+  begin_of_last_line = Address_Of_Row_In_Buffer(field, (field->drows - 1));
+  s = After_End_Of_Data(begin_of_last_line, field->dcols);
+  return ((s == begin_of_last_line) ? TRUE : FALSE);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
-|   
+|
 |   Description   :  Checks whether or not there is room for a new character
 |                    in the current line.
 |
 |   Return Values :  TRUE    - there is room
 |                    FALSE   - there is not enough room (line full)
 +--------------------------------------------------------------------------*/
-INLINE static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
+INLINE static bool
+Is_There_Room_For_A_Char_In_Line(FORM *form)
 {
   int last_char_in_line;
 
-  wmove(form->w,form->currow,form->current->dcols-1);
-  last_char_in_line  = (int)(winch(form->w) & A_CHARTEXT);
-  wmove(form->w,form->currow,form->curcol);
+  wmove(form->w, form->currow, form->current->dcols - 1);
+  last_char_in_line = (int)(winch(form->w) & A_CHARTEXT);
+  wmove(form->w, form->currow, form->curcol);
   return (((last_char_in_line == form->current->pad) ||
 	   is_blank(last_char_in_line)) ? TRUE : FALSE);
 }
@@ -1971,85 +2208,90 @@
   !Is_There_Room_For_A_Char_In_Line(f)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Insert_String(
 |                                             FORM * form,
 |                                             int row,
 |                                             char *txt,
 |                                             int  len )
-|   
+|
 |   Description   :  Insert the 'len' characters beginning at pointer 'txt'
 |                    into the 'row' of the 'form'. The insertion occurs
 |                    on the beginning of the row, all other characters are
-|                    moved to the right. After the text a pad character will 
+|                    moved to the right. After the text a pad character will
 |                    be inserted to separate the text from the rest. If
 |                    necessary the insertion moves characters on the next
 |                    line to make place for the requested insertion string.
 |
-|   Return Values :  E_OK              - success 
+|   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  -
 |                    E_SYSTEM_ERROR    - system error
 +--------------------------------------------------------------------------*/
-static int Insert_String(FORM *form, int row, char *txt, int len)
-{ 
-  FIELD  *field    = form->current;
-  char *bp         = Address_Of_Row_In_Buffer(field,row);
-  int datalen      = (int)(After_End_Of_Data(bp,field->dcols) - bp);
-  int freelen      = field->dcols - datalen;
-  int requiredlen  = len+1;
-  char *split;
+static int
+Insert_String(FORM *form, int row, FIELD_CELL *txt, int len)
+{
+  FIELD *field = form->current;
+  FIELD_CELL *bp = Address_Of_Row_In_Buffer(field, row);
+  int datalen = (int)(After_End_Of_Data(bp, field->dcols) - bp);
+  int freelen = field->dcols - datalen;
+  int requiredlen = len + 1;
+  FIELD_CELL *split;
   int result = E_REQUEST_DENIED;
-  const char *Space = " ";
 
   if (freelen >= requiredlen)
     {
-      wmove(form->w,row,0);
-      winsnstr(form->w,txt,len);
-      wmove(form->w,row,len);
-      winsnstr(form->w,Space,1);
+      wmove(form->w, row, 0);
+      myINSNSTR(form->w, txt, len);
+      wmove(form->w, row, len);
+      myINSNSTR(form->w, &myBLANK, 1);
       return E_OK;
     }
   else
-    { /* we have to move characters on the next line. If we are on the
-	 last line this may work, if the field is growable */
+    {
+      /* we have to move characters on the next line. If we are on the
+         last line this may work, if the field is growable */
       if ((row == (field->drows - 1)) && Growable(field))
 	{
-	  if (!Field_Grown(field,1))
-	    return(E_SYSTEM_ERROR);
+	  if (!Field_Grown(field, 1))
+	    return (E_SYSTEM_ERROR);
 	  /* !!!Side-Effect : might be changed due to growth!!! */
-	  bp = Address_Of_Row_In_Buffer(field,row); 
+	  bp = Address_Of_Row_In_Buffer(field, row);
 	}
 
-      if (row < (field->drows - 1)) 
-	{ 
-	  split = After_Last_Whitespace_Character(bp,
-		    (int)(Get_Start_Of_Data(bp + field->dcols - requiredlen ,
-					    requiredlen) - bp));
+      if (row < (field->drows - 1))
+	{
+	  split =
+	    After_Last_Whitespace_Character(bp,
+					    (int)(Get_Start_Of_Data(bp
+								    + field->dcols
+								    - requiredlen,
+								    requiredlen)
+						  - bp));
 	  /* split points now to the first character of the portion of the
 	     line that must be moved to the next line */
-	  datalen = (int)(split-bp); /* + freelen has to stay on this line   */
-	  freelen = field->dcols - (datalen + freelen); /* for the next line */
+	  datalen = (int)(split - bp);	/* + freelen has to stay on this line   */
+	  freelen = field->dcols - (datalen + freelen);		/* for the next line */
 
-	  if ((result=Insert_String(form,row+1,split,freelen))==E_OK) 
+	  if ((result = Insert_String(form, row + 1, split, freelen)) == E_OK)
 	    {
-	      wmove(form->w,row,datalen);
+	      wmove(form->w, row, datalen);
 	      wclrtoeol(form->w);
-	      wmove(form->w,row,0);
-	      winsnstr(form->w,txt,len);
-	      wmove(form->w,row,len);
-	      winsnstr(form->w,Space,1);
+	      wmove(form->w, row, 0);
+	      myINSNSTR(form->w, txt, len);
+	      wmove(form->w, row, len);
+	      myINSNSTR(form->w, &myBLANK, 1);
 	      return E_OK;
 	    }
 	}
-      return(result);
+      return (result);
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Wrapping_Not_Necessary_Or_Wrapping_Ok(
 |                                             FORM * form)
-|   
+|
 |   Description   :  If a character has been entered into a field, it may
 |                    be that wrapping has to occur. This routine checks
 |                    whether or not wrapping is required and if so, performs
@@ -2060,40 +2302,43 @@
 |                    E_REQUEST_DENIED  -
 |                    E_SYSTEM_ERROR    - some system error
 +--------------------------------------------------------------------------*/
-static int Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM * form)
+static int
+Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM *form)
 {
-  FIELD  *field = form->current;
+  FIELD *field = form->current;
   int result = E_REQUEST_DENIED;
   bool Last_Row = ((field->drows - 1) == form->currow);
 
-  if ( (field->opts & O_WRAP)                     &&  /* wrapping wanted     */
-      (!Single_Line_Field(field))                 &&  /* must be multi-line  */
-      (There_Is_No_Room_For_A_Char_In_Line(form)) &&  /* line is full        */
-      (!Last_Row || Growable(field))               )  /* there are more lines*/
+  if ((field->opts & O_WRAP) &&	/* wrapping wanted     */
+      (!Single_Line_Field(field)) &&	/* must be multi-line  */
+      (There_Is_No_Room_For_A_Char_In_Line(form)) &&	/* line is full        */
+      (!Last_Row || Growable(field)))	/* there are more lines */
     {
-      char *bp;
-      char *split;
+      FIELD_CELL *bp;
+      FIELD_CELL *split;
       int chars_to_be_wrapped;
       int chars_to_remain_on_line;
+
       if (Last_Row)
-	{ /* the above logic already ensures, that in this case the field
+	{
+	  /* the above logic already ensures, that in this case the field
 	     is growable */
-	  if (!Field_Grown(field,1))
+	  if (!Field_Grown(field, 1))
 	    return E_SYSTEM_ERROR;
 	}
       bp = Address_Of_Current_Row_In_Buffer(form);
-      Window_To_Buffer(form->w,field);
-      split = After_Last_Whitespace_Character(bp,field->dcols);
+      Window_To_Buffer(form->w, field);
+      split = After_Last_Whitespace_Character(bp, field->dcols);
       /* split points to the first character of the sequence to be brought
          on the next line */
       chars_to_remain_on_line = (int)(split - bp);
-      chars_to_be_wrapped     = field->dcols - chars_to_remain_on_line;
+      chars_to_be_wrapped = field->dcols - chars_to_remain_on_line;
       if (chars_to_remain_on_line > 0)
 	{
-	  if ((result=Insert_String(form,form->currow+1,split,
-				    chars_to_be_wrapped)) == E_OK)
+	  if ((result = Insert_String(form, form->currow + 1, split,
+				      chars_to_be_wrapped)) == E_OK)
 	    {
-	      wmove(form->w,form->currow,chars_to_remain_on_line);
+	      wmove(form->w, form->currow, chars_to_remain_on_line);
 	      wclrtoeol(form->w);
 	      if (form->curcol >= chars_to_remain_on_line)
 		{
@@ -2105,29 +2350,28 @@
 	}
       else
 	return E_OK;
-      if (result!=E_OK)
+      if (result != E_OK)
 	{
-	  wmove(form->w,form->currow,form->curcol);
-	  wdelch(form->w);
-	  Window_To_Buffer(form->w,field);
+	  DeleteChar(form);
+	  Window_To_Buffer(form->w, field);
 	  result = E_REQUEST_DENIED;
 	}
     }
   else
-    result = E_OK; /* wrapping was not necessary */
-  return(result);
+    result = E_OK;		/* wrapping was not necessary */
+  return (result);
 }
-
+
 /*----------------------------------------------------------------------------
   Field Editing routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Field_Editing(
 |                                    int (* const fct) (FORM *),
 |                                    FORM * form)
-|   
+|
 |   Description   :  Generic routine for field editing requests. The driver
 |                    routines are only called for editable fields, the
 |                    _WINDOW_MODIFIED flag is set if editing occurred.
@@ -2136,30 +2380,31 @@
 |
 |   Return Values :  Error code from low level drivers.
 +--------------------------------------------------------------------------*/
-static int Field_Editing(int (* const fct) (FORM *), FORM * form)
+static int
+Field_Editing(int (*const fct) (FORM *), FORM *form)
 {
   int res = E_REQUEST_DENIED;
 
-  /* We have to deal here with the specific case of the overloaded 
+  /* We have to deal here with the specific case of the overloaded
      behavior of New_Line and Delete_Previous requests.
      They may end up in navigational requests if we are on the first
      character in a field. But navigation is also allowed on non-
      editable fields.
-  */ 
-  if ((fct==FE_Delete_Previous)            && 
-      (form->opts & O_BS_OVERLOAD)         &&
-      First_Position_In_Current_Field(form) )
+   */
+  if ((fct == FE_Delete_Previous) &&
+      (form->opts & O_BS_OVERLOAD) &&
+      First_Position_In_Current_Field(form))
     {
-      res = Inter_Field_Navigation(FN_Previous_Field,form);
+      res = Inter_Field_Navigation(FN_Previous_Field, form);
     }
   else
     {
-      if (fct==FE_New_Line)
+      if (fct == FE_New_Line)
 	{
-	  if ((form->opts & O_NL_OVERLOAD)         &&
+	  if ((form->opts & O_NL_OVERLOAD) &&
 	      First_Position_In_Current_Field(form))
 	    {
-	      res = Inter_Field_Navigation(FN_Next_Field,form);
+	      res = Inter_Field_Navigation(FN_Next_Field, form);
 	    }
 	  else
 	    /* FE_New_Line deals itself with the _WINDOW_MODIFIED flag */
@@ -2171,7 +2416,7 @@
 	  if (form->current->opts & O_EDIT)
 	    {
 	      res = fct(form);
-	      if (res==E_OK)
+	      if (res == E_OK)
 		form->status |= _WINDOW_MODIFIED;
 	    }
 	}
@@ -2180,11 +2425,11 @@
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_New_Line(FORM * form)
-|   
+|
 |   Description   :  Perform a new line request. This is rather complex
-|                    compared to other routines in this code due to the 
+|                    compared to other routines in this code due to the
 |                    rather difficult to understand description in the
 |                    manuals.
 |
@@ -2192,133 +2437,141 @@
 |                    E_REQUEST_DENIED   - new line not allowed
 |                    E_SYSTEM_ERROR     - system error
 +--------------------------------------------------------------------------*/
-static int FE_New_Line(FORM * form)
+static int
+FE_New_Line(FORM *form)
 {
-  FIELD  *field = form->current;
-  char *bp, *t;
-  bool Last_Row = ((field->drows - 1)==form->currow);
-  
-  if (form->status & _OVLMODE) 
+  FIELD *field = form->current;
+  FIELD_CELL *bp, *t;
+  bool Last_Row = ((field->drows - 1) == form->currow);
+
+  T((T_CALLED("FE_New_Line(%p)"), form));
+  if (form->status & _OVLMODE)
     {
-      if (Last_Row && 
+      if (Last_Row &&
 	  (!(Growable(field) && !Single_Line_Field(field))))
 	{
 	  if (!(form->opts & O_NL_OVERLOAD))
-	    return(E_REQUEST_DENIED);
-	  wmove(form->w,form->currow,form->curcol);
+	    returnCode(E_REQUEST_DENIED);
+	  wmove(form->w, form->currow, form->curcol);
 	  wclrtoeol(form->w);
 	  /* we have to set this here, although it is also
 	     handled in the generic routine. The reason is,
 	     that FN_Next_Field may fail, but the form is
 	     definitively changed */
 	  form->status |= _WINDOW_MODIFIED;
-	  return Inter_Field_Navigation(FN_Next_Field,form);
+	  returnCode(Inter_Field_Navigation(FN_Next_Field, form));
 	}
-      else 
+      else
 	{
-	  if (Last_Row && !Field_Grown(field,1))
-	    { /* N.B.: due to the logic in the 'if', LastRow==TRUE
-		 means here that the field is growable and not
-		 a single-line field */
-	      return(E_SYSTEM_ERROR);
+	  if (Last_Row && !Field_Grown(field, 1))
+	    {
+	      /* N.B.: due to the logic in the 'if', LastRow==TRUE
+	         means here that the field is growable and not
+	         a single-line field */
+	      returnCode(E_SYSTEM_ERROR);
 	    }
-	  wmove(form->w,form->currow,form->curcol);
+	  wmove(form->w, form->currow, form->curcol);
 	  wclrtoeol(form->w);
 	  form->currow++;
 	  form->curcol = 0;
 	  form->status |= _WINDOW_MODIFIED;
-	  return(E_OK);
+	  returnCode(E_OK);
 	}
     }
-  else 
-    { /* Insert Mode */
+  else
+    {
+      /* Insert Mode */
       if (Last_Row &&
 	  !(Growable(field) && !Single_Line_Field(field)))
 	{
 	  if (!(form->opts & O_NL_OVERLOAD))
-	    return(E_REQUEST_DENIED);
-	  return Inter_Field_Navigation(FN_Next_Field,form);
+	    returnCode(E_REQUEST_DENIED);
+	  returnCode(Inter_Field_Navigation(FN_Next_Field, form));
 	}
-      else 
+      else
 	{
 	  bool May_Do_It = !Last_Row && Is_There_Room_For_A_Line(form);
-	  
+
 	  if (!(May_Do_It || Growable(field)))
-	    return(E_REQUEST_DENIED);
-	  if (!May_Do_It && !Field_Grown(field,1))
-	    return(E_SYSTEM_ERROR);
-	  
-	  bp= Address_Of_Current_Position_In_Buffer(form);
-	  t = After_End_Of_Data(bp,field->dcols - form->curcol);
-	  wmove(form->w,form->currow,form->curcol);
+	    returnCode(E_REQUEST_DENIED);
+	  if (!May_Do_It && !Field_Grown(field, 1))
+	    returnCode(E_SYSTEM_ERROR);
+
+	  bp = Address_Of_Current_Position_In_Buffer(form);
+	  t = After_End_Of_Data(bp, field->dcols - form->curcol);
+	  wmove(form->w, form->currow, form->curcol);
 	  wclrtoeol(form->w);
 	  form->currow++;
-	  form->curcol=0;
-	  wmove(form->w,form->currow,form->curcol);
+	  form->curcol = 0;
+	  wmove(form->w, form->currow, form->curcol);
 	  winsertln(form->w);
-	  waddnstr(form->w,bp,(int)(t-bp));
+	  myADDNSTR(form->w, bp, (int)(t - bp));
 	  form->status |= _WINDOW_MODIFIED;
-	  return E_OK;
+	  returnCode(E_OK);
 	}
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_Insert_Character(FORM * form)
-|   
+|
 |   Description   :  Insert blank character at the cursor position
 |
 |   Return Values :  E_OK
 |                    E_REQUEST_DENIED
 +--------------------------------------------------------------------------*/
-static int FE_Insert_Character(FORM * form)
+static int
+FE_Insert_Character(FORM *form)
 {
   FIELD *field = form->current;
   int result = E_REQUEST_DENIED;
 
-  if (Check_Char(field->type,(int)C_BLANK,(TypeArgument *)(field->arg)))
+  T((T_CALLED("FE_Insert_Character(%p)"), form));
+  if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
     {
       bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
 
       if (There_Is_Room ||
 	  ((Single_Line_Field(field) && Growable(field))))
 	{
-	  if (!There_Is_Room && !Field_Grown(field,1))
-	    result =  E_SYSTEM_ERROR;
+	  if (!There_Is_Room && !Field_Grown(field, 1))
+	    result = E_SYSTEM_ERROR;
 	  else
 	    {
-	      winsch(form->w,(chtype)C_BLANK);
+	      winsch(form->w, (chtype)C_BLANK);
 	      result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form);
 	    }
 	}
     }
-  return result;
+  returnCode(result);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_Insert_Line(FORM * form)
-|   
+|
 |   Description   :  Insert a blank line at the cursor position
 |
 |   Return Values :  E_OK               - success
 |                    E_REQUEST_DENIED   - line can not be inserted
 +--------------------------------------------------------------------------*/
-static int FE_Insert_Line(FORM * form)
+static int
+FE_Insert_Line(FORM *form)
 {
   FIELD *field = form->current;
   int result = E_REQUEST_DENIED;
 
-  if (Check_Char(field->type,(int)C_BLANK,(TypeArgument *)(field->arg)))
+  T((T_CALLED("FE_Insert_Line(%p)"), form));
+  if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
     {
-      bool Maybe_Done = (form->currow!=(field->drows-1)) && 
-	                Is_There_Room_For_A_Line(form);
+      bool Maybe_Done = (form->currow != (field->drows - 1)) &&
+      Is_There_Room_For_A_Line(form);
 
       if (!Single_Line_Field(field) &&
 	  (Maybe_Done || Growable(field)))
 	{
-	  if (!Maybe_Done && !Field_Grown(field,1))
+	  if (!Maybe_Done && !Field_Grown(field, 1))
 	    result = E_SYSTEM_ERROR;
 	  else
 	    {
@@ -2328,28 +2581,29 @@
 	    }
 	}
     }
-  return result;
+  returnCode(result);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_Delete_Character(FORM * form)
-|   
+|
 |   Description   :  Delete character at the cursor position
 |
 |   Return Values :  E_OK    - success
 +--------------------------------------------------------------------------*/
-static int FE_Delete_Character(FORM * form)
+static int
+FE_Delete_Character(FORM *form)
 {
-  wmove(form->w,form->currow,form->curcol);
-  wdelch(form->w);
-  return E_OK;
+  T((T_CALLED("FE_Delete_Character(%p)"), form));
+  DeleteChar(form);
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_Delete_Previous(FORM * form)
-|   
+|
 |   Description   :  Delete character before cursor. Again this is a rather
 |                    difficult piece compared to others due to the overloading
 |                    semantics of backspace.
@@ -2359,304 +2613,329 @@
 |   Return Values :  E_OK                - success
 |                    E_REQUEST_DENIED    - Character can't be deleted
 +--------------------------------------------------------------------------*/
-static int FE_Delete_Previous(FORM * form)
+static int
+FE_Delete_Previous(FORM *form)
 {
-  FIELD  *field = form->current;
-  
+  FIELD *field = form->current;
+
+  T((T_CALLED("FE_Delete_Previous(%p)"), form));
   if (First_Position_In_Current_Field(form))
-    return E_REQUEST_DENIED;
+    returnCode(E_REQUEST_DENIED);
 
-  if ( (--(form->curcol))<0 )
+  if ((--(form->curcol)) < 0)
     {
-      char *this_line, *prev_line, *prev_end, *this_end;
-      
+      FIELD_CELL *this_line, *prev_line, *prev_end, *this_end;
+
       form->curcol++;
-      if (form->status & _OVLMODE) 
-	return E_REQUEST_DENIED;
-      
-      prev_line = Address_Of_Row_In_Buffer(field,(form->currow-1));
-      this_line = Address_Of_Row_In_Buffer(field,(form->currow));
+      if (form->status & _OVLMODE)
+	returnCode(E_REQUEST_DENIED);
+
+      prev_line = Address_Of_Row_In_Buffer(field, (form->currow - 1));
+      this_line = Address_Of_Row_In_Buffer(field, (form->currow));
       Synchronize_Buffer(form);
-      prev_end = After_End_Of_Data(prev_line,field->dcols);
-      this_end = After_End_Of_Data(this_line,field->dcols);
-      if ((int)(this_end-this_line) > 
-	  (field->cols-(int)(prev_end-prev_line))) 
-	return E_REQUEST_DENIED;
-      wmove(form->w,form->currow,form->curcol);
+      prev_end = After_End_Of_Data(prev_line, field->dcols);
+      this_end = After_End_Of_Data(this_line, field->dcols);
+      if ((int)(this_end - this_line) >
+	  (field->cols - (int)(prev_end - prev_line)))
+	returnCode(E_REQUEST_DENIED);
+      wmove(form->w, form->currow, form->curcol);
       wdeleteln(form->w);
-      Adjust_Cursor_Position(form,prev_end);
-      wmove(form->w,form->currow,form->curcol);
-      waddnstr(form->w,this_line,(int)(this_end-this_line));
-    } 
-  else 
+      Adjust_Cursor_Position(form, prev_end);
+      wmove(form->w, form->currow, form->curcol);
+      myADDNSTR(form->w, this_line, (int)(this_end - this_line));
+    }
+  else
     {
-      wmove(form->w,form->currow,form->curcol);
-      wdelch(form->w);
+      DeleteChar(form);
     }
-  return E_OK;
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_Delete_Line(FORM * form)
-|   
+|
 |   Description   :  Delete line at cursor position.
 |
 |   Return Values :  E_OK  - success
 +--------------------------------------------------------------------------*/
-static int FE_Delete_Line(FORM * form)
+static int
+FE_Delete_Line(FORM *form)
 {
+  T((T_CALLED("FE_Delete_Line(%p)"), form));
   form->curcol = 0;
   wdeleteln(form->w);
-  return E_OK;
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_Delete_Word(FORM * form)
-|   
+|
 |   Description   :  Delete word at cursor position
 |
 |   Return Values :  E_OK               - success
 |                    E_REQUEST_DENIED   - failure
 +--------------------------------------------------------------------------*/
-static int FE_Delete_Word(FORM * form)
+static int
+FE_Delete_Word(FORM *form)
 {
-  FIELD  *field = form->current;
-  char   *bp = Address_Of_Current_Row_In_Buffer(form);
-  char   *ep = bp + field->dcols;
-  char   *cp = bp + form->curcol;
-  char *s;
-  
+  FIELD *field = form->current;
+  FIELD_CELL *bp = Address_Of_Current_Row_In_Buffer(form);
+  FIELD_CELL *ep = bp + field->dcols;
+  FIELD_CELL *cp = bp + form->curcol;
+  FIELD_CELL *s;
+
+  T((T_CALLED("FE_Delete_Word(%p)"), form));
   Synchronize_Buffer(form);
-  if (is_blank(*cp)) 
-    return E_REQUEST_DENIED; /* not in word */
+  if (ISBLANK(*cp))
+    returnCode(E_REQUEST_DENIED);	/* not in word */
 
   /* move cursor to begin of word and erase to end of screen-line */
   Adjust_Cursor_Position(form,
-			 After_Last_Whitespace_Character(bp,form->curcol)); 
-  wmove(form->w,form->currow,form->curcol);
+			 After_Last_Whitespace_Character(bp, form->curcol));
+  wmove(form->w, form->currow, form->curcol);
   wclrtoeol(form->w);
 
   /* skip over word in buffer */
-  s = Get_First_Whitespace_Character(cp,(int)(ep-cp)); 
+  s = Get_First_Whitespace_Character(cp, (int)(ep - cp));
   /* to begin of next word    */
-  s = Get_Start_Of_Data(s,(int)(ep - s));
-  if ( (s!=cp) && !is_blank(*s))
+  s = Get_Start_Of_Data(s, (int)(ep - s));
+  if ((s != cp) && !ISBLANK(*s))
     {
       /* copy remaining line to window */
-      waddnstr(form->w,s,(int)(s - After_End_Of_Data(s,(int)(ep - s))));
+      myADDNSTR(form->w, s, (int)(s - After_End_Of_Data(s, (int)(ep - s))));
     }
-  return E_OK;
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_Clear_To_End_Of_Line(FORM * form)
-|   
+|
 |   Description   :  Clear to end of current line.
 |
 |   Return Values :  E_OK   - success
 +--------------------------------------------------------------------------*/
-static int FE_Clear_To_End_Of_Line(FORM * form)
+static int
+FE_Clear_To_End_Of_Line(FORM *form)
 {
-  wmove(form->w,form->currow,form->curcol);
+  T((T_CALLED("FE_Clear_To_End_Of_Line(%p)"), form));
+  wmove(form->w, form->currow, form->curcol);
   wclrtoeol(form->w);
-  return E_OK;
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_Clear_To_End_Of_Field(FORM * form)
-|   
+|
 |   Description   :  Clear to end of field.
 |
 |   Return Values :  E_OK   - success
 +--------------------------------------------------------------------------*/
-static int FE_Clear_To_End_Of_Field(FORM * form)
+static int
+FE_Clear_To_End_Of_Field(FORM *form)
 {
-  wmove(form->w,form->currow,form->curcol);
+  T((T_CALLED("FE_Clear_To_End_Of_Field(%p)"), form));
+  wmove(form->w, form->currow, form->curcol);
   wclrtobot(form->w);
-  return E_OK;
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FE_Clear_Field(FORM * form)
-|   
+|
 |   Description   :  Clear entire field.
 |
 |   Return Values :  E_OK   - success
 +--------------------------------------------------------------------------*/
-static int FE_Clear_Field(FORM * form)
+static int
+FE_Clear_Field(FORM *form)
 {
+  T((T_CALLED("FE_Clear_Field(%p)"), form));
   form->currow = form->curcol = 0;
   werase(form->w);
-  return E_OK;
+  returnCode(E_OK);
 }
 /*----------------------------------------------------------------------------
-  END of Field Editing routines 
+  END of Field Editing routines
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Edit Mode routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int EM_Overlay_Mode(FORM * form)
-|   
+|
 |   Description   :  Switch to overlay mode.
 |
 |   Return Values :  E_OK   - success
 +--------------------------------------------------------------------------*/
-static int EM_Overlay_Mode(FORM * form)
+static int
+EM_Overlay_Mode(FORM *form)
 {
+  T((T_CALLED("EM_Overlay_Mode(%p)"), form));
   form->status |= _OVLMODE;
-  return E_OK;
+  returnCode(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int EM_Insert_Mode(FORM * form)
-|   
+|
 |   Description   :  Switch to insert mode
 |
 |   Return Values :  E_OK   - success
 +--------------------------------------------------------------------------*/
-static int EM_Insert_Mode(FORM * form)
+static int
+EM_Insert_Mode(FORM *form)
 {
+  T((T_CALLED("EM_Insert_Mode(%p)"), form));
   form->status &= ~_OVLMODE;
-  return E_OK;
+  returnCode(E_OK);
 }
 
 /*----------------------------------------------------------------------------
-  END of Edit Mode routines 
+  END of Edit Mode routines
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Helper routines for Choice Requests
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Next_Choice(
 |                                            FIELDTYPE * typ,
 |                                            FIELD * field,
 |                                            TypeArgument *argp)
-|   
+|
 |   Description   :  Get the next field choice. For linked types this is
 |                    done recursively.
 |
 |   Return Values :  TRUE    - next choice successfully retrieved
 |                    FALSE   - couldn't retrieve next choice
 +--------------------------------------------------------------------------*/
-static bool Next_Choice(FIELDTYPE * typ, FIELD *field, TypeArgument *argp)
+static bool
+Next_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
 {
-  if (!typ || !(typ->status & _HAS_CHOICE)) 
+  if (!typ || !(typ->status & _HAS_CHOICE))
     return FALSE;
 
   if (typ->status & _LINKED_TYPE)
     {
       assert(argp);
-      return(
-	     Next_Choice(typ->left ,field,argp->left) ||
-	     Next_Choice(typ->right,field,argp->right) );
-    } 
+      return (
+	       Next_Choice(typ->left, field, argp->left) ||
+	       Next_Choice(typ->right, field, argp->right));
+    }
   else
     {
       assert(typ->next);
-      return typ->next(field,(void *)argp);
+      return typ->next(field, (void *)argp);
     }
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Previous_Choice(
 |                                                FIELDTYPE * typ,
 |                                                FIELD * field,
 |                                                TypeArgument *argp)
-|   
+|
 |   Description   :  Get the previous field choice. For linked types this
 |                    is done recursively.
 |
 |   Return Values :  TRUE    - previous choice successfully retrieved
 |                    FALSE   - couldn't retrieve previous choice
 +--------------------------------------------------------------------------*/
-static bool Previous_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+static bool
+Previous_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
 {
-  if (!typ || !(typ->status & _HAS_CHOICE)) 
+  if (!typ || !(typ->status & _HAS_CHOICE))
     return FALSE;
 
   if (typ->status & _LINKED_TYPE)
     {
       assert(argp);
-      return(
-	     Previous_Choice(typ->left ,field,argp->left) ||
-	     Previous_Choice(typ->right,field,argp->right));
-    } 
-  else 
+      return (
+	       Previous_Choice(typ->left, field, argp->left) ||
+	       Previous_Choice(typ->right, field, argp->right));
+    }
+  else
     {
       assert(typ->prev);
-      return typ->prev(field,(void *)argp);
+      return typ->prev(field, (void *)argp);
     }
 }
 /*----------------------------------------------------------------------------
   End of Helper routines for Choice Requests
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Routines for Choice Requests
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int CR_Next_Choice(FORM * form)
-|   
+|
 |   Description   :  Get the next field choice.
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - next choice couldn't be retrieved
 +--------------------------------------------------------------------------*/
-static int CR_Next_Choice(FORM * form)
+static int
+CR_Next_Choice(FORM *form)
 {
   FIELD *field = form->current;
+
+  T((T_CALLED("CR_Next_Choice(%p)"), form));
   Synchronize_Buffer(form);
-  return ((Next_Choice(field->type,field,(TypeArgument *)(field->arg))) ? 
-	  E_OK : E_REQUEST_DENIED);
+  returnCode((Next_Choice(field->type, field, (TypeArgument *)(field->arg)))
+	     ? E_OK
+	     : E_REQUEST_DENIED);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int CR_Previous_Choice(FORM * form)
-|   
+|
 |   Description   :  Get the previous field choice.
 |
 |   Return Values :  E_OK              - success
 |                    E_REQUEST_DENIED  - prev. choice couldn't be retrieved
 +--------------------------------------------------------------------------*/
-static int CR_Previous_Choice(FORM * form)
+static int
+CR_Previous_Choice(FORM *form)
 {
   FIELD *field = form->current;
+
+  T((T_CALLED("CR_Previous_Choice(%p)"), form));
   Synchronize_Buffer(form);
-  return ((Previous_Choice(field->type,field,(TypeArgument *)(field->arg))) ? 
-	  E_OK : E_REQUEST_DENIED);
+  returnCode((Previous_Choice(field->type, field, (TypeArgument *)(field->arg)))
+	     ? E_OK
+	     : E_REQUEST_DENIED);
 }
 /*----------------------------------------------------------------------------
   End of Routines for Choice Requests
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Helper routines for Field Validations.
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static bool Check_Field(
 |                                            FIELDTYPE * typ,
 |                                            FIELD * field,
 |                                            TypeArgument * argp)
-|   
+|
 |   Description   :  Check the field according to its fieldtype and its
 |                    actual arguments. For linked fieldtypes this is done
 |                    recursively.
@@ -2664,59 +2943,63 @@
 |   Return Values :  TRUE       - field is valid
 |                    FALSE      - field is invalid.
 +--------------------------------------------------------------------------*/
-static bool Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+static bool
+Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
 {
   if (typ)
     {
       if (field->opts & O_NULLOK)
 	{
-	  char *bp = field->buf;
+	  FIELD_CELL *bp = field->buf;
+
 	  assert(bp);
-	  while(is_blank(*bp))
-	    { bp++; }
-	  if (*bp == '\0') 
+	  while (ISBLANK(*bp))
+	    {
+	      bp++;
+	    }
+	  if (CharOf(*bp) == 0)
 	    return TRUE;
 	}
 
       if (typ->status & _LINKED_TYPE)
 	{
 	  assert(argp);
-	  return( 
-		 Check_Field(typ->left ,field,argp->left ) ||
-		 Check_Field(typ->right,field,argp->right) );
+	  return (
+		   Check_Field(typ->left, field, argp->left) ||
+		   Check_Field(typ->right, field, argp->right));
 	}
-      else 
+      else
 	{
 	  if (typ->fcheck)
-	    return typ->fcheck(field,(void *)argp);
+	    return typ->fcheck(field, (void *)argp);
 	}
     }
   return TRUE;
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  bool _nc_Internal_Validation(FORM * form )
-|   
-|   Description   :  Validate the current field of the form.  
+|
+|   Description   :  Validate the current field of the form.
 |
 |   Return Values :  TRUE  - field is valid
 |                    FALSE - field is invalid
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(bool)
-_nc_Internal_Validation (FORM *form)
+_nc_Internal_Validation(FORM *form)
 {
   FIELD *field;
 
-  field = form->current; 
-  
+  field = form->current;
+
   Synchronize_Buffer(form);
   if ((form->status & _FCHECK_REQUIRED) ||
       (!(field->opts & O_PASSOK)))
     {
-      if (!Check_Field(field->type,field,(TypeArgument *)(field->arg)))
+      if (!Check_Field(field->type, field, (TypeArgument *)(field->arg)))
 	return FALSE;
-      form->status  &= ~_FCHECK_REQUIRED;
+      form->status &= ~_FCHECK_REQUIRED;
       field->status |= _CHANGED;
       Synchronize_Linked_Fields(field);
     }
@@ -2725,67 +3008,71 @@
 /*----------------------------------------------------------------------------
   End of Helper routines for Field Validations.
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Routines for Field Validation.
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FV_Validation(FORM * form)
-|   
+|
 |   Description   :  Validate the current field of the form.
 |
 |   Return Values :  E_OK             - field valid
 |                    E_INVALID_FIELD  - field not valid
 +--------------------------------------------------------------------------*/
-static int FV_Validation(FORM * form)
+static int
+FV_Validation(FORM *form)
 {
+  T((T_CALLED("FV_Validation(%p)"), form));
   if (_nc_Internal_Validation(form))
-    return E_OK;
+    returnCode(E_OK);
   else
-    return E_INVALID_FIELD;
+    returnCode(E_INVALID_FIELD);
 }
 /*----------------------------------------------------------------------------
   End of routines for Field Validation.
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Helper routines for Inter-Field Navigation
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static FIELD *Next_Field_On_Page(FIELD * field)
-|   
-|   Description   :  Get the next field after the given field on the current 
+|
+|   Description   :  Get the next field after the given field on the current
 |                    page. The order of fields is the one defined by the
 |                    fields array. Only visible and active fields are
 |                    counted.
 |
 |   Return Values :  Pointer to the next field.
 +--------------------------------------------------------------------------*/
-INLINE static FIELD *Next_Field_On_Page(FIELD * field)
+INLINE static FIELD *
+Next_Field_On_Page(FIELD *field)
 {
-  FORM  *form = field->form;
+  FORM *form = field->form;
   FIELD **field_on_page = &form->field[field->index];
   FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
-  FIELD **last_on_page  = &form->field[form->page[form->curpage].pmax];
+  FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
 
   do
     {
-      field_on_page = 
-	(field_on_page==last_on_page) ? first_on_page : field_on_page + 1;
+      field_on_page =
+	(field_on_page == last_on_page) ? first_on_page : field_on_page + 1;
       if (Field_Is_Selectable(*field_on_page))
 	break;
-    } while(field!=(*field_on_page));  
-  return(*field_on_page);
+    }
+  while (field != (*field_on_page));
+  return (*field_on_page);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  FIELD* _nc_First_Active_Field(FORM * form)
-|   
+|
 |   Description   :  Get the first active field on the current page,
 |                    if there are such. If there are none, get the first
 |                    visible field on the page. If there are also none,
@@ -2793,17 +3080,18 @@
 |
 |   Return Values :  Pointer to calculated field.
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(FIELD*)
-_nc_First_Active_Field (FORM * form)
+NCURSES_EXPORT(FIELD *)
+_nc_First_Active_Field(FORM *form)
 {
   FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
   FIELD *proposed = Next_Field_On_Page(*last_on_page);
 
   if (proposed == *last_on_page)
-    { /* there might be the special situation, where there is no 
-	 active and visible field on the current page. We then select
-	 the first visible field on this readonly page
-      */
+    {
+      /* there might be the special situation, where there is no
+         active and visible field on the current page. We then select
+         the first visible field on this readonly page
+       */
       if (Field_Is_Not_Selectable(proposed))
 	{
 	  FIELD **field = &form->field[proposed->index];
@@ -2811,66 +3099,71 @@
 
 	  do
 	    {
-	      field = (field==last_on_page) ? first : field + 1;
+	      field = (field == last_on_page) ? first : field + 1;
 	      if (((*field)->opts & O_VISIBLE))
 		break;
-	    } while(proposed!=(*field));
-	  
+	    }
+	  while (proposed != (*field));
+
 	  proposed = *field;
 
-	  if ((proposed == *last_on_page) && !(proposed->opts&O_VISIBLE))
-	    { /* This means, there is also no visible field on the page.
-		 So we propose the first one and hope the very best... 
-		 Some very clever user has designed a readonly and invisible
-		 page on this form.
+	  if ((proposed == *last_on_page) && !(proposed->opts & O_VISIBLE))
+	    {
+	      /* This means, there is also no visible field on the page.
+	         So we propose the first one and hope the very best...
+	         Some very clever user has designed a readonly and invisible
+	         page on this form.
 	       */
 	      proposed = *first;
 	    }
 	}
     }
-  return(proposed);
+  return (proposed);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static FIELD *Previous_Field_On_Page(FIELD * field)
-|   
-|   Description   :  Get the previous field before the given field on the 
-|                    current page. The order of fields is the one defined by 
+|
+|   Description   :  Get the previous field before the given field on the
+|                    current page. The order of fields is the one defined by
 |                    the fields array. Only visible and active fields are
 |                    counted.
 |
 |   Return Values :  Pointer to the previous field.
 +--------------------------------------------------------------------------*/
-INLINE static FIELD *Previous_Field_On_Page(FIELD * field)
+INLINE static FIELD *
+Previous_Field_On_Page(FIELD *field)
 {
-  FORM  *form   = field->form;
+  FORM *form = field->form;
   FIELD **field_on_page = &form->field[field->index];
   FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
-  FIELD **last_on_page  = &form->field[form->page[form->curpage].pmax];
-  
+  FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+
   do
     {
-      field_on_page = 
-	(field_on_page==first_on_page) ? last_on_page : field_on_page - 1;
+      field_on_page =
+	(field_on_page == first_on_page) ? last_on_page : field_on_page - 1;
       if (Field_Is_Selectable(*field_on_page))
 	break;
-    } while(field!=(*field_on_page));
-  
+    }
+  while (field != (*field_on_page));
+
   return (*field_on_page);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static FIELD *Sorted_Next_Field(FIELD * field)
-|   
-|   Description   :  Get the next field after the given field on the current 
+|
+|   Description   :  Get the next field after the given field on the current
 |                    page. The order of fields is the one defined by the
 |                    (row,column) geometry, rows are major.
 |
 |   Return Values :  Pointer to the next field.
 +--------------------------------------------------------------------------*/
-INLINE static FIELD *Sorted_Next_Field(FIELD * field)
+INLINE static FIELD *
+Sorted_Next_Field(FIELD *field)
 {
   FIELD *field_on_page = field;
 
@@ -2879,22 +3172,24 @@
       field_on_page = field_on_page->snext;
       if (Field_Is_Selectable(field_on_page))
 	break;
-    } while(field_on_page!=field);
-  
+    }
+  while (field_on_page != field);
+
   return (field_on_page);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static FIELD *Sorted_Previous_Field(FIELD * field)
-|   
-|   Description   :  Get the previous field before the given field on the 
-|                    current page. The order of fields is the one defined 
+|
+|   Description   :  Get the previous field before the given field on the
+|                    current page. The order of fields is the one defined
 |                    by the (row,column) geometry, rows are major.
 |
 |   Return Values :  Pointer to the previous field.
 +--------------------------------------------------------------------------*/
-INLINE static FIELD *Sorted_Previous_Field(FIELD * field)
+INLINE static FIELD *
+Sorted_Previous_Field(FIELD *field)
 {
   FIELD *field_on_page = field;
 
@@ -2903,21 +3198,23 @@
       field_on_page = field_on_page->sprev;
       if (Field_Is_Selectable(field_on_page))
 	break;
-    } while(field_on_page!=field);
-  
+    }
+  while (field_on_page != field);
+
   return (field_on_page);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static FIELD *Left_Neighbor_Field(FIELD * field)
-|   
+|
 |   Description   :  Get the left neighbor of the field on the same line
 |                    and the same page. Cycles through the line.
 |
 |   Return Values :  Pointer to left neighbor field.
 +--------------------------------------------------------------------------*/
-INLINE static FIELD *Left_Neighbor_Field(FIELD * field)
+INLINE static FIELD *
+Left_Neighbor_Field(FIELD *field)
 {
   FIELD *field_on_page = field;
 
@@ -2925,25 +3222,27 @@
      immediately fails and the loop is left, positioned at the right
      neighbor. Otherwise we cycle backwards through the sorted field list
      until we enter the same line (from the right end).
-  */
+   */
   do
     {
       field_on_page = Sorted_Previous_Field(field_on_page);
-    } while(field_on_page->frow != field->frow);
-  
+    }
+  while (field_on_page->frow != field->frow);
+
   return (field_on_page);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static FIELD *Right_Neighbor_Field(FIELD * field)
-|   
+|
 |   Description   :  Get the right neighbor of the field on the same line
 |                    and the same page.
 |
 |   Return Values :  Pointer to right neighbor field.
 +--------------------------------------------------------------------------*/
-INLINE static FIELD *Right_Neighbor_Field(FIELD * field)
+INLINE static FIELD *
+Right_Neighbor_Field(FIELD *field)
 {
   FIELD *field_on_page = field;
 
@@ -2951,15 +3250,16 @@
   do
     {
       field_on_page = Sorted_Next_Field(field_on_page);
-    } while(field_on_page->frow != field->frow);
-  
+    }
+  while (field_on_page->frow != field->frow);
+
   return (field_on_page);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static FIELD *Upper_Neighbor_Field(FIELD * field)
-|   
+|
 |   Description   :  Because of the row-major nature of sorting the fields,
 |                    it is more difficult to define whats the upper neighbor
 |                    field really means. We define that it must be on a
@@ -2969,7 +3269,8 @@
 |
 |   Return Values :  Pointer to the upper neighbor field.
 +--------------------------------------------------------------------------*/
-static FIELD *Upper_Neighbor_Field(FIELD * field)
+static FIELD *
+Upper_Neighbor_Field(FIELD *field)
 {
   FIELD *field_on_page = field;
   int frow = field->frow;
@@ -2978,35 +3279,37 @@
   /* Walk back to the 'previous' line. The second term in the while clause
      just guarantees that we stop if we cycled through the line because
      there might be no 'previous' line if the page has just one line.
-  */
+   */
   do
     {
       field_on_page = Sorted_Previous_Field(field_on_page);
-    } while(field_on_page->frow==frow && field_on_page->fcol!=fcol);
-  
-  if (field_on_page->frow!=frow)
-    { /* We really found a 'previous' line. We are positioned at the
+    }
+  while (field_on_page->frow == frow && field_on_page->fcol != fcol);
+
+  if (field_on_page->frow != frow)
+    {
+      /* We really found a 'previous' line. We are positioned at the
          rightmost field on this line */
-      frow = field_on_page->frow; 
+      frow = field_on_page->frow;
 
-      /* We walk to the left as long as we are really right of the 
-	 field. */
-      while(field_on_page->frow==frow && field_on_page->fcol>fcol)
+      /* We walk to the left as long as we are really right of the
+         field. */
+      while (field_on_page->frow == frow && field_on_page->fcol > fcol)
 	field_on_page = Sorted_Previous_Field(field_on_page);
 
-      /* If we wrapped, just go to the right which is the first field on 
-	 the row */
-      if (field_on_page->frow!=frow)
+      /* If we wrapped, just go to the right which is the first field on
+         the row */
+      if (field_on_page->frow != frow)
 	field_on_page = Sorted_Next_Field(field_on_page);
     }
-  
+
   return (field_on_page);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static FIELD *Down_Neighbor_Field(FIELD * field)
-|   
+|
 |   Description   :  Because of the row-major nature of sorting the fields,
 |                    its more difficult to define whats the down neighbor
 |                    field really means. We define that it must be on a
@@ -3016,7 +3319,8 @@
 |
 |   Return Values :  Pointer to the upper neighbor field.
 +--------------------------------------------------------------------------*/
-static FIELD *Down_Neighbor_Field(FIELD * field)
+static FIELD *
+Down_Neighbor_Field(FIELD *field)
 {
   FIELD *field_on_page = field;
   int frow = field->frow;
@@ -3025,41 +3329,43 @@
   /* Walk forward to the 'next' line. The second term in the while clause
      just guarantees that we stop if we cycled through the line because
      there might be no 'next' line if the page has just one line.
-  */
+   */
   do
     {
       field_on_page = Sorted_Next_Field(field_on_page);
-    } while(field_on_page->frow==frow && field_on_page->fcol!=fcol);
+    }
+  while (field_on_page->frow == frow && field_on_page->fcol != fcol);
 
-  if (field_on_page->frow!=frow)
-    { /* We really found a 'next' line. We are positioned at the rightmost
+  if (field_on_page->frow != frow)
+    {
+      /* We really found a 'next' line. We are positioned at the rightmost
          field on this line */
       frow = field_on_page->frow;
 
-      /* We walk to the right as long as we are really left of the 
-	 field. */
-      while(field_on_page->frow==frow && field_on_page->fcol<fcol)
+      /* We walk to the right as long as we are really left of the
+         field. */
+      while (field_on_page->frow == frow && field_on_page->fcol < fcol)
 	field_on_page = Sorted_Next_Field(field_on_page);
 
-      /* If we wrapped, just go to the left which is the last field on 
-	 the row */
-      if (field_on_page->frow!=frow)
+      /* If we wrapped, just go to the left which is the last field on
+         the row */
+      if (field_on_page->frow != frow)
 	field_on_page = Sorted_Previous_Field(field_on_page);
     }
-  
-  return(field_on_page);
+
+  return (field_on_page);
 }
-
+
 /*----------------------------------------------------------------------------
   Inter-Field Navigation routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Inter_Field_Navigation(
 |                                           int (* const fct) (FORM *),
 |                                           FORM * form)
-|   
+|
 |   Description   :  Generic behavior for changing the current field, the
 |                    field is left and a new field is entered. So the field
 |                    must be validated and the field init/term hooks must
@@ -3069,228 +3375,253 @@
 |                    E_INVALID_FIELD     - field is invalid
 |                    some other          - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int Inter_Field_Navigation(int (* const fct) (FORM *),FORM *form)
+static int
+Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form)
 {
   int res;
 
-  if (!_nc_Internal_Validation(form)) 
+  if (!_nc_Internal_Validation(form))
     res = E_INVALID_FIELD;
   else
     {
-      Call_Hook(form,fieldterm);
+      Call_Hook(form, fieldterm);
       res = fct(form);
-      Call_Hook(form,fieldinit);
+      Call_Hook(form, fieldinit);
     }
   return res;
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Next_Field(FORM * form)
-|   
+|
 |   Description   :  Move to the next field on the current page of the form
 |
 |   Return Values :  E_OK                 - success
 |                    != E_OK              - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Next_Field(FORM * form)
+static int
+FN_Next_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-			       Next_Field_On_Page(form->current));
+  T((T_CALLED("FN_Next_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Next_Field_On_Page(form->current)));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Previous_Field(FORM * form)
-|   
-|   Description   :  Move to the previous field on the current page of the 
+|
+|   Description   :  Move to the previous field on the current page of the
 |                    form
 |
 |   Return Values :  E_OK                 - success
 |                    != E_OK              - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Previous_Field(FORM * form)
+static int
+FN_Previous_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-			       Previous_Field_On_Page(form->current));
+  T((T_CALLED("FN_Previous_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Previous_Field_On_Page(form->current)));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_First_Field(FORM * form)
-|   
+|
 |   Description   :  Move to the first field on the current page of the form
 |
 |   Return Values :  E_OK                 - success
 |                    != E_OK              - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_First_Field(FORM * form)
+static int
+FN_First_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-      Next_Field_On_Page(form->field[form->page[form->curpage].pmax]));
+  T((T_CALLED("FN_First_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Next_Field_On_Page(form->field[form->page[form->curpage].pmax])));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Last_Field(FORM * form)
-|   
+|
 |   Description   :  Move to the last field on the current page of the form
 |
 |   Return Values :  E_OK                 - success
 |                    != E_OK              - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Last_Field(FORM * form)
+static int
+FN_Last_Field(FORM *form)
 {
-  return 
-    _nc_Set_Current_Field(form,
-       Previous_Field_On_Page(form->field[form->page[form->curpage].pmin]));
+  T((T_CALLED("FN_Last_Field(%p)"), form));
+  returnCode(
+	      _nc_Set_Current_Field(form,
+				    Previous_Field_On_Page(form->field[form->page[form->curpage].pmin])));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Sorted_Next_Field(FORM * form)
-|   
+|
 |   Description   :  Move to the sorted next field on the current page
 |                    of the form.
 |
 |   Return Values :  E_OK            - success
 |                    != E_OK         - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Sorted_Next_Field(FORM * form)
+static int
+FN_Sorted_Next_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-			       Sorted_Next_Field(form->current));
+  T((T_CALLED("FN_Sorted_Next_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Sorted_Next_Field(form->current)));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Sorted_Previous_Field(FORM * form)
-|   
+|
 |   Description   :  Move to the sorted previous field on the current page
 |                    of the form.
 |
 |   Return Values :  E_OK            - success
 |                    != E_OK         - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Sorted_Previous_Field(FORM * form)
+static int
+FN_Sorted_Previous_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-			       Sorted_Previous_Field(form->current));
+  T((T_CALLED("FN_Sorted_Previous_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Sorted_Previous_Field(form->current)));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Sorted_First_Field(FORM * form)
-|   
+|
 |   Description   :  Move to the sorted first field on the current page
 |                    of the form.
 |
 |   Return Values :  E_OK            - success
 |                    != E_OK         - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Sorted_First_Field(FORM * form)
+static int
+FN_Sorted_First_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-	      Sorted_Next_Field(form->field[form->page[form->curpage].smax]));
+  T((T_CALLED("FN_Sorted_First_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Sorted_Next_Field(form->field[form->page[form->curpage].smax])));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Sorted_Last_Field(FORM * form)
-|   
+|
 |   Description   :  Move to the sorted last field on the current page
 |                    of the form.
 |
 |   Return Values :  E_OK            - success
 |                    != E_OK         - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Sorted_Last_Field(FORM * form)
+static int
+FN_Sorted_Last_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-	   Sorted_Previous_Field(form->field[form->page[form->curpage].smin]));
+  T((T_CALLED("FN_Sorted_Last_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Sorted_Previous_Field(form->field[form->page[form->curpage].smin])));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Left_Field(FORM * form)
-|   
+|
 |   Description   :  Get the field on the left of the current field on the
 |                    same line and the same page. Cycles through the line.
 |
 |   Return Values :  E_OK            - success
 |                    != E_OK         - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Left_Field(FORM * form)
+static int
+FN_Left_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-			       Left_Neighbor_Field(form->current));
+  T((T_CALLED("FN_Left_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Left_Neighbor_Field(form->current)));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Right_Field(FORM * form)
-|   
+|
 |   Description   :  Get the field on the right of the current field on the
 |                    same line and the same page. Cycles through the line.
 |
 |   Return Values :  E_OK            - success
 |                    != E_OK         - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Right_Field(FORM * form)
+static int
+FN_Right_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-			       Right_Neighbor_Field(form->current));
+  T((T_CALLED("FN_Right_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Right_Neighbor_Field(form->current)));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Up_Field(FORM * form)
-|   
+|
 |   Description   :  Get the upper neighbor of the current field. This
 |                    cycles through the page. See the comments of the
 |                    Upper_Neighbor_Field function to understand how
-|                    'upper' is defined. 
+|                    'upper' is defined.
 |
 |   Return Values :  E_OK            - success
 |                    != E_OK         - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Up_Field(FORM * form)
+static int
+FN_Up_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-			       Upper_Neighbor_Field(form->current));
+  T((T_CALLED("FN_Up_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Upper_Neighbor_Field(form->current)));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int FN_Down_Field(FORM * form)
-|   
+|
 |   Description   :  Get the down neighbor of the current field. This
 |                    cycles through the page. See the comments of the
 |                    Down_Neighbor_Field function to understand how
-|                    'down' is defined. 
+|                    'down' is defined.
 |
 |   Return Values :  E_OK            - success
 |                    != E_OK         - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int FN_Down_Field(FORM * form)
+static int
+FN_Down_Field(FORM *form)
 {
-  return _nc_Set_Current_Field(form,
-			       Down_Neighbor_Field(form->current));
+  T((T_CALLED("FN_Down_Field(%p)"), form));
+  returnCode(_nc_Set_Current_Field(form,
+				   Down_Neighbor_Field(form->current)));
 }
 /*----------------------------------------------------------------------------
-  END of Field Navigation routines 
+  END of Field Navigation routines
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Helper routines for Page Navigation
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int _nc_Set_Form_Page(FORM * form,
 |                                          int page,
 |                                          FIELD * field)
-|   
+|
 |   Description   :  Make the given page number the current page and make
 |                    the given field the current field on the page. If
 |                    for the field NULL is given, make the first field on
@@ -3301,12 +3632,11 @@
 |                    != E_OK             - error from subordinate call
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-_nc_Set_Form_Page
-(FORM * form, int page, FIELD * field)
+_nc_Set_Form_Page(FORM *form, int page, FIELD *field)
 {
   int res = E_OK;
 
-  if ((form->curpage!=page))
+  if ((form->curpage != page))
     {
       FIELD *last_field, *field_on_page;
 
@@ -3316,63 +3646,66 @@
       do
 	{
 	  if (field_on_page->opts & O_VISIBLE)
-	    if ((res=Display_Field(field_on_page))!=E_OK) 
-	      return(res);
+	    if ((res = Display_Field(field_on_page)) != E_OK)
+	      return (res);
 	  field_on_page = field_on_page->snext;
-	} while(field_on_page != last_field);
+	}
+      while (field_on_page != last_field);
 
       if (field)
-	res = _nc_Set_Current_Field(form,field);
+	res = _nc_Set_Current_Field(form, field);
       else
 	/* N.B.: we don't encapsulate this by Inter_Field_Navigation(),
 	   because this is already executed in a page navigation
-	   context that contains field navigation 
+	   context that contains field navigation
 	 */
 	res = FN_First_Field(form);
     }
-  return(res);
+  return (res);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Next_Page_Number(const FORM * form)
-|   
+|
 |   Description   :  Calculate the page number following the current page
 |                    number. This cycles if the highest page number is
-|                    reached.  
+|                    reached.
 |
 |   Return Values :  The next page number
 +--------------------------------------------------------------------------*/
-INLINE static int Next_Page_Number(const FORM * form)
+INLINE static int
+Next_Page_Number(const FORM *form)
 {
   return (form->curpage + 1) % form->maxpage;
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Previous_Page_Number(const FORM * form)
-|   
+|
 |   Description   :  Calculate the page number before the current page
 |                    number. This cycles if the first page number is
-|                    reached.  
+|                    reached.
 |
 |   Return Values :  The previous page number
 +--------------------------------------------------------------------------*/
-INLINE static int Previous_Page_Number(const FORM * form)
+INLINE static int
+Previous_Page_Number(const FORM *form)
 {
-  return (form->curpage!=0 ? form->curpage - 1 : form->maxpage - 1);
+  return (form->curpage != 0 ? form->curpage - 1 : form->maxpage - 1);
 }
-
+
 /*----------------------------------------------------------------------------
-  Page Navigation routines 
+  Page Navigation routines
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Page_Navigation(
 |                                               int (* const fct) (FORM *),
 |                                               FORM * form)
-|   
+|
 |   Description   :  Generic behavior for changing a page. This means
 |                    that the field is left and a new field is entered.
 |                    So the field must be validated and the field init/term
@@ -3383,90 +3716,100 @@
 |                    E_INVALID_FIELD     - field is invalid
 |                    some other          - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int Page_Navigation(int (* const fct) (FORM *), FORM * form)
+static int
+Page_Navigation(int (*const fct) (FORM *), FORM *form)
 {
   int res;
 
-  if (!_nc_Internal_Validation(form)) 
+  if (!_nc_Internal_Validation(form))
     res = E_INVALID_FIELD;
   else
     {
-      Call_Hook(form,fieldterm);
-      Call_Hook(form,formterm);
+      Call_Hook(form, fieldterm);
+      Call_Hook(form, formterm);
       res = fct(form);
-      Call_Hook(form,forminit);
-      Call_Hook(form,fieldinit);
+      Call_Hook(form, forminit);
+      Call_Hook(form, fieldinit);
     }
   return res;
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int PN_Next_Page(FORM * form)
-|   
+|
 |   Description   :  Move to the next page of the form
 |
 |   Return Values :  E_OK                - success
 |                    != E_OK             - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int PN_Next_Page(FORM * form)
-{ 
-  return _nc_Set_Form_Page(form,Next_Page_Number(form),(FIELD *)0);
+static int
+PN_Next_Page(FORM *form)
+{
+  T((T_CALLED("PN_Next_Page(%p)"), form));
+  returnCode(_nc_Set_Form_Page(form, Next_Page_Number(form), (FIELD *)0));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int PN_Previous_Page(FORM * form)
-|   
+|
 |   Description   :  Move to the previous page of the form
 |
 |   Return Values :  E_OK              - success
 |                    != E_OK           - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int PN_Previous_Page(FORM * form)
+static int
+PN_Previous_Page(FORM *form)
 {
-  return _nc_Set_Form_Page(form,Previous_Page_Number(form),(FIELD *)0);
+  T((T_CALLED("PN_Previous_Page(%p)"), form));
+  returnCode(_nc_Set_Form_Page(form, Previous_Page_Number(form), (FIELD *)0));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int PN_First_Page(FORM * form)
-|   
+|
 |   Description   :  Move to the first page of the form
 |
 |   Return Values :  E_OK              - success
 |                    != E_OK           - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int PN_First_Page(FORM * form)
+static int
+PN_First_Page(FORM *form)
 {
-  return _nc_Set_Form_Page(form,0,(FIELD *)0);
+  T((T_CALLED("PN_First_Page(%p)"), form));
+  returnCode(_nc_Set_Form_Page(form, 0, (FIELD *)0));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int PN_Last_Page(FORM * form)
-|   
+|
 |   Description   :  Move to the last page of the form
 |
 |   Return Values :  E_OK              - success
 |                    != E_OK           - error from subordinate call
 +--------------------------------------------------------------------------*/
-static int PN_Last_Page(FORM * form)
+static int
+PN_Last_Page(FORM *form)
 {
-  return _nc_Set_Form_Page(form,form->maxpage-1,(FIELD *)0);
+  T((T_CALLED("PN_Last_Page(%p)"), form));
+  returnCode(_nc_Set_Form_Page(form, form->maxpage - 1, (FIELD *)0));
 }
+
 /*----------------------------------------------------------------------------
-  END of Field Navigation routines 
+  END of Field Navigation routines
   --------------------------------------------------------------------------*/
-
+
 /*----------------------------------------------------------------------------
   Helper routines for the core form driver.
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  static int Data_Entry(FORM * form,int c)
-|   
+|
 |   Description   :  Enter character c into at the current position of the
 |                    current field of the form.
 |
@@ -3474,55 +3817,69 @@
 |                    E_REQUEST_DENIED  -
 |                    E_SYSTEM_ERROR    -
 +--------------------------------------------------------------------------*/
-static int Data_Entry(FORM * form, int c)
+static int
+Data_Entry(FORM *form, int c)
 {
-  FIELD  *field = form->current;
+  FIELD *field = form->current;
   int result = E_REQUEST_DENIED;
 
-  if ( (field->opts & O_EDIT) 
+  if ((field->opts & O_EDIT)
 #if FIX_FORM_INACTIVE_BUG
-       && (field->opts & O_ACTIVE) 
+      && (field->opts & O_ACTIVE)
 #endif
-       )
+    )
     {
-      if ( (field->opts & O_BLANK) &&
-	   First_Position_In_Current_Field(form) &&
-	   !(form->status & _FCHECK_REQUIRED) && 
-	   !(form->status & _WINDOW_MODIFIED) )
+      if ((field->opts & O_BLANK) &&
+	  First_Position_In_Current_Field(form) &&
+	  !(form->status & _FCHECK_REQUIRED) &&
+	  !(form->status & _WINDOW_MODIFIED))
 	werase(form->w);
 
       if (form->status & _OVLMODE)
 	{
-	  waddch(form->w,(chtype)c);
-	} 
-      else /* no _OVLMODE */ 
+	  waddch(form->w, (chtype)c);
+	}
+      else
+	/* no _OVLMODE */
 	{
 	  bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
 
 	  if (!(There_Is_Room ||
 		((Single_Line_Field(field) && Growable(field)))))
-	      return E_REQUEST_DENIED;
+	    return E_REQUEST_DENIED;
 
-	  if (!There_Is_Room && !Field_Grown(field,1))
+	  if (!There_Is_Room && !Field_Grown(field, 1))
 	    return E_SYSTEM_ERROR;
 
-	  winsch(form->w,(chtype)c);
+	  winsch(form->w, (chtype)c);
 	}
 
-      if ((result=Wrapping_Not_Necessary_Or_Wrapping_Ok(form))==E_OK)
+      if ((result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form)) == E_OK)
 	{
-	  bool End_Of_Field= (((field->drows-1)==form->currow) &&
-			      ((field->dcols-1)==form->curcol));
+	  bool End_Of_Field = (((field->drows - 1) == form->currow) &&
+			       ((field->dcols - 1) == form->curcol));
+
 	  form->status |= _WINDOW_MODIFIED;
 	  if (End_Of_Field && !Growable(field) && (field->opts & O_AUTOSKIP))
-	    result = Inter_Field_Navigation(FN_Next_Field,form);
+	    result = Inter_Field_Navigation(FN_Next_Field, form);
 	  else
 	    {
-	      if (End_Of_Field && Growable(field) && !Field_Grown(field,1))
+	      if (End_Of_Field && Growable(field) && !Field_Grown(field, 1))
 		result = E_SYSTEM_ERROR;
 	      else
 		{
+#if USE_WIDEC_SUPPORT
+		  /*
+		   * We have just added a byte to the form field.  It may have
+		   * been part of a multibyte character.  If it was, the
+		   * addch_used field is nonzero and we should not try to move
+		   * to a new column.
+		   */
+		  if (WINDOW_EXT(form->w, addch_used) == 0)
+		    IFN_Next_Character(form);
+#else
 		  IFN_Next_Character(form);
+#endif
 		  result = E_OK;
 		}
 	    }
@@ -3530,45 +3887,48 @@
     }
   return result;
 }
-
+
 /* Structure to describe the binding of a request code to a function.
    The member keycode codes the request value as well as the generic
    routine to use for the request. The code for the generic routine
    is coded in the upper 16 Bits while the request code is coded in
-   the lower 16 bits. 
+   the lower 16 bits.
 
    In terms of C++ you might think of a request as a class with a
    virtual method "perform". The different types of request are
    derived from this base class and overload (or not) the base class
    implementation of perform.
 */
-typedef struct {
-  int keycode;           /* must be at least 32 bit: hi:mode, lo: key */
-  int (*cmd)(FORM *);    /* low level driver routine for this key     */
-} Binding_Info;
+typedef struct
+{
+  int keycode;			/* must be at least 32 bit: hi:mode, lo: key */
+  int (*cmd) (FORM *);		/* low level driver routine for this key     */
+}
+Binding_Info;
 
 /* You may see this is the class-id of the request type class */
-#define ID_PN    (0x00000000)    /* Page navigation           */
-#define ID_FN    (0x00010000)    /* Inter-Field navigation    */
-#define ID_IFN   (0x00020000)    /* Intra-Field navigation    */
-#define ID_VSC   (0x00030000)    /* Vertical Scrolling        */
-#define ID_HSC   (0x00040000)    /* Horizontal Scrolling      */
-#define ID_FE    (0x00050000)    /* Field Editing             */
-#define ID_EM    (0x00060000)    /* Edit Mode                 */
-#define ID_FV    (0x00070000)    /* Field Validation          */
-#define ID_CH    (0x00080000)    /* Choice                    */
+#define ID_PN    (0x00000000)	/* Page navigation           */
+#define ID_FN    (0x00010000)	/* Inter-Field navigation    */
+#define ID_IFN   (0x00020000)	/* Intra-Field navigation    */
+#define ID_VSC   (0x00030000)	/* Vertical Scrolling        */
+#define ID_HSC   (0x00040000)	/* Horizontal Scrolling      */
+#define ID_FE    (0x00050000)	/* Field Editing             */
+#define ID_EM    (0x00060000)	/* Edit Mode                 */
+#define ID_FV    (0x00070000)	/* Field Validation          */
+#define ID_CH    (0x00080000)	/* Choice                    */
 #define ID_Mask  (0xffff0000)
 #define Key_Mask (0x0000ffff)
 #define ID_Shft  (16)
 
 /* This array holds all the Binding Infos */
-static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] = 
+/* *INDENT-OFF* */
+static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
 {
   { REQ_NEXT_PAGE    |ID_PN  ,PN_Next_Page},
   { REQ_PREV_PAGE    |ID_PN  ,PN_Previous_Page},
   { REQ_FIRST_PAGE   |ID_PN  ,PN_First_Page},
   { REQ_LAST_PAGE    |ID_PN  ,PN_Last_Page},
-  
+
   { REQ_NEXT_FIELD   |ID_FN  ,FN_Next_Field},
   { REQ_PREV_FIELD   |ID_FN  ,FN_Previous_Field},
   { REQ_FIRST_FIELD  |ID_FN  ,FN_First_Field},
@@ -3581,7 +3941,7 @@
   { REQ_RIGHT_FIELD  |ID_FN  ,FN_Right_Field},
   { REQ_UP_FIELD     |ID_FN  ,FN_Up_Field},
   { REQ_DOWN_FIELD   |ID_FN  ,FN_Down_Field},
-  
+
   { REQ_NEXT_CHAR    |ID_IFN ,IFN_Next_Character},
   { REQ_PREV_CHAR    |ID_IFN ,IFN_Previous_Character},
   { REQ_NEXT_LINE    |ID_IFN ,IFN_Next_Line},
@@ -3596,7 +3956,7 @@
   { REQ_RIGHT_CHAR   |ID_IFN ,IFN_Right_Character},
   { REQ_UP_CHAR      |ID_IFN ,IFN_Up_Character},
   { REQ_DOWN_CHAR    |ID_IFN ,IFN_Down_Character},
-  
+
   { REQ_NEW_LINE     |ID_FE  ,FE_New_Line},
   { REQ_INS_CHAR     |ID_FE  ,FE_Insert_Character},
   { REQ_INS_LINE     |ID_FE  ,FE_Insert_Line},
@@ -3607,34 +3967,35 @@
   { REQ_CLR_EOL      |ID_FE  ,FE_Clear_To_End_Of_Line},
   { REQ_CLR_EOF      |ID_FE  ,FE_Clear_To_End_Of_Field},
   { REQ_CLR_FIELD    |ID_FE  ,FE_Clear_Field},
-  
+
   { REQ_OVL_MODE     |ID_EM  ,EM_Overlay_Mode},
   { REQ_INS_MODE     |ID_EM  ,EM_Insert_Mode},
-  
+
   { REQ_SCR_FLINE    |ID_VSC ,VSC_Scroll_Line_Forward},
   { REQ_SCR_BLINE    |ID_VSC ,VSC_Scroll_Line_Backward},
   { REQ_SCR_FPAGE    |ID_VSC ,VSC_Scroll_Page_Forward},
   { REQ_SCR_BPAGE    |ID_VSC ,VSC_Scroll_Page_Backward},
   { REQ_SCR_FHPAGE   |ID_VSC ,VSC_Scroll_Half_Page_Forward},
   { REQ_SCR_BHPAGE   |ID_VSC ,VSC_Scroll_Half_Page_Backward},
-  
+
   { REQ_SCR_FCHAR    |ID_HSC ,HSC_Scroll_Char_Forward},
   { REQ_SCR_BCHAR    |ID_HSC ,HSC_Scroll_Char_Backward},
   { REQ_SCR_HFLINE   |ID_HSC ,HSC_Horizontal_Line_Forward},
   { REQ_SCR_HBLINE   |ID_HSC ,HSC_Horizontal_Line_Backward},
   { REQ_SCR_HFHALF   |ID_HSC ,HSC_Horizontal_Half_Line_Forward},
   { REQ_SCR_HBHALF   |ID_HSC ,HSC_Horizontal_Half_Line_Backward},
-  
+
   { REQ_VALIDATION   |ID_FV  ,FV_Validation},
 
   { REQ_NEXT_CHOICE  |ID_CH  ,CR_Next_Choice},
   { REQ_PREV_CHOICE  |ID_CH  ,CR_Previous_Choice}
 };
+/* *INDENT-ON* */
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int form_driver(FORM * form,int  c)
-|   
+|
 |   Description   :  This is the workhorse of the forms system. It checks
 |                    to determine whether the character c is a request or
 |                    data. If it is a request, the form driver executes
@@ -3656,126 +4017,143 @@
 |                    E_UNKNOWN_COMMAND - command not known
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-form_driver (FORM * form, int  c)
+form_driver(FORM *form, int c)
 {
-  const Binding_Info* BI = (Binding_Info *)0;
+  const Binding_Info *BI = (Binding_Info *) 0;
   int res = E_UNKNOWN_COMMAND;
 
+  T((T_CALLED("form_driver(%p,%d)"), form, c));
+
   if (!form)
     RETURN(E_BAD_ARGUMENT);
 
   if (!(form->field))
     RETURN(E_NOT_CONNECTED);
-  
+
   assert(form->page);
-  
-  if (c==FIRST_ACTIVE_MAGIC)
+
+  if (c == FIRST_ACTIVE_MAGIC)
     {
       form->current = _nc_First_Active_Field(form);
-      return E_OK;
+      RETURN(E_OK);
     }
-  
-  assert(form->current && 
-	 form->current->buf && 
+
+  assert(form->current &&
+	 form->current->buf &&
 	 (form->current->form == form)
-	);
-  
-  if ( form->status & _IN_DRIVER )
+    );
+
+  if (form->status & _IN_DRIVER)
     RETURN(E_BAD_STATE);
 
-  if ( !( form->status & _POSTED ) ) 
+  if (!(form->status & _POSTED))
     RETURN(E_NOT_POSTED);
-  
-  if ((c>=MIN_FORM_COMMAND && c<=MAX_FORM_COMMAND) &&
-      ((bindings[c-MIN_FORM_COMMAND].keycode & Key_Mask) == c))
-    BI = &(bindings[c-MIN_FORM_COMMAND]);
-  
+
+  if ((c >= MIN_FORM_COMMAND && c <= MAX_FORM_COMMAND) &&
+      ((bindings[c - MIN_FORM_COMMAND].keycode & Key_Mask) == c))
+    BI = &(bindings[c - MIN_FORM_COMMAND]);
+
   if (BI)
     {
-      typedef int (*Generic_Method)(int (* const)(FORM *),FORM *);
-      static const Generic_Method Generic_Methods[] = 
-	{
-	  Page_Navigation,         /* overloaded to call field&form hooks */
-	  Inter_Field_Navigation,  /* overloaded to call field hooks      */
-	  NULL,                    /* Intra-Field is generic              */
-	  Vertical_Scrolling,      /* Overloaded to check multi-line      */
-	  Horizontal_Scrolling,    /* Overloaded to check single-line     */
-	  Field_Editing,           /* Overloaded to mark modification     */
-	  NULL,                    /* Edit Mode is generic                */
-	  NULL,                    /* Field Validation is generic         */
-	  NULL                     /* Choice Request is generic           */
-	};
-      size_t nMethods = (sizeof(Generic_Methods)/sizeof(Generic_Methods[0]));
-      size_t method   = ((BI->keycode & ID_Mask) >> ID_Shft) & 0xffff;
-      
-      if ( (method >= nMethods) || !(BI->cmd) )
+      typedef int (*Generic_Method) (int (*const) (FORM *), FORM *);
+      static const Generic_Method Generic_Methods[] =
+      {
+	Page_Navigation,	/* overloaded to call field&form hooks */
+	Inter_Field_Navigation,	/* overloaded to call field hooks      */
+	NULL,			/* Intra-Field is generic              */
+	Vertical_Scrolling,	/* Overloaded to check multi-line      */
+	Horizontal_Scrolling,	/* Overloaded to check single-line     */
+	Field_Editing,		/* Overloaded to mark modification     */
+	NULL,			/* Edit Mode is generic                */
+	NULL,			/* Field Validation is generic         */
+	NULL			/* Choice Request is generic           */
+      };
+      size_t nMethods = (sizeof(Generic_Methods) / sizeof(Generic_Methods[0]));
+      size_t method = ((BI->keycode & ID_Mask) >> ID_Shft) & 0xffff;
+
+      if ((method >= nMethods) || !(BI->cmd))
 	res = E_SYSTEM_ERROR;
       else
 	{
 	  Generic_Method fct = Generic_Methods[method];
+
 	  if (fct)
-	    res = fct(BI->cmd,form);
+	    res = fct(BI->cmd, form);
 	  else
-	    res = (BI->cmd)(form);
+	    res = (BI->cmd) (form);
 	}
-    } 
-  else 
+    }
+  else if (!(c & (~(int)MAX_REGULAR_CHARACTER)))
     {
-      if (!(c & (~(int)MAX_REGULAR_CHARACTER)) &&
-	  isprint((unsigned char)c) &&                      
-	  Check_Char(form->current->type,c,
+      /*
+       * If we're using 8-bit characters, iscntrl+isprint cover the whole set.
+       * But with multibyte characters, there is a third possibility, i.e.,
+       * parts of characters that build up into printable characters which are
+       * not considered printable.
+       *
+       * FIXME: the wide-character branch should also use Check_Char().
+       */
+#if USE_WIDEC_SUPPORT
+      if (!iscntrl(UChar(c)))
+#else
+      if (isprint(UChar(c)) &&
+	  Check_Char(form->current->type, c,
 		     (TypeArgument *)(form->current->arg)))
-	res = Data_Entry(form,c);
+#endif
+	res = Data_Entry(form, c);
     }
   _nc_Refresh_Current_Field(form);
   RETURN(res);
 }
-
+
 /*----------------------------------------------------------------------------
   Field-Buffer manipulation routines.
-  The effects of setting a buffer is tightly coupled to the core of the form
+  The effects of setting a buffer are tightly coupled to the core of the form
   driver logic. This is especially true in the case of growable fields.
-  So I don't separate this into an own module. 
+  So I don't separate this into a separate module.
   --------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_buffer(FIELD *field,
 |                                         int buffer, char *value)
-|   
+|
 |   Description   :  Set the given buffer of the field to the given value.
 |                    Buffer 0 stores the displayed content of the field.
 |                    For dynamic fields this may grow the fieldbuffers if
 |                    the length of the value exceeds the current buffer
 |                    length. For buffer 0 only printable values are allowed.
 |                    For static fields, the value needs not to be zero ter-
-|                    minated. It is copied up to the length of the buffer.   
+|                    minated. It is copied up to the length of the buffer.
 |
 |   Return Values :  E_OK            - success
 |                    E_BAD_ARGUMENT  - invalid argument
 |                    E_SYSTEM_ERROR  - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_field_buffer
-(FIELD * field, int buffer, const char * value)
+set_field_buffer(FIELD *field, int buffer, const char *value)
 {
-  char *s, *p;
+  FIELD_CELL *p;
   int res = E_OK;
+  unsigned int i;
   unsigned int len;
 
-  if ( !field || !value || ((buffer < 0)||(buffer > field->nbuf)) )
+#if USE_WIDEC_SUPPORT
+  FIELD_CELL *widevalue = 0;
+#endif
+
+  T((T_CALLED("set_field_buffer(%p,%d,%s)"), field, buffer, _nc_visbuf(value)));
+
+  if (!field || !value || ((buffer < 0) || (buffer > field->nbuf)))
     RETURN(E_BAD_ARGUMENT);
 
-  len  = Buffer_Length(field);
+  len = Buffer_Length(field);
 
-  if (buffer==0)
+  if (buffer == 0)
     {
-      const char *v;
-      unsigned int i = 0;
-
-      for(v=value; *v && (i<len); v++,i++)
+      for (i = 0; (value[i] != '\0') && (i < len); ++i)
 	{
-	  if (!isprint((unsigned char)*v))
+	  if (iscntrl(UChar(value[i])))
 	    RETURN(E_BAD_ARGUMENT);
 	}
     }
@@ -3783,83 +4161,240 @@
   if (Growable(field))
     {
       /* for a growable field we must assume zero terminated strings, because
-	 somehow we have to detect the length of what should be copied.
-      */
+         somehow we have to detect the length of what should be copied.
+       */
       unsigned int vlen = strlen(value);
+
       if (vlen > len)
 	{
 	  if (!Field_Grown(field,
-			   (int)(1 + (vlen-len)/((field->rows+field->nrow)*field->cols))))
+			   (int)(1 + (vlen - len) / ((field->rows + field->nrow)
+						     * field->cols))))
 	    RETURN(E_SYSTEM_ERROR);
 
 	  /* in this case we also have to check, whether or not the remaining
 	     characters in value are also printable for buffer 0. */
-	  if (buffer==0)
+	  if (buffer == 0)
 	    {
-	      unsigned int i;
-	  
-	      for(i=len; i<vlen; i++)
-		if (!isprint((unsigned char)value[i]))
+	      for (i = len; i < vlen; i++)
+		if (iscntrl(UChar(value[i])))
 		  RETURN(E_BAD_ARGUMENT);
 	    }
 	  len = vlen;
 	}
     }
-  
-  p   = Address_Of_Nth_Buffer(field,buffer);
 
-#if HAVE_MEMCCPY
-  s = (char *) memccpy(p, value, 0, len);
+  p = Address_Of_Nth_Buffer(field, buffer);
+
+#if USE_WIDEC_SUPPORT
+  /*
+   * Use addstr's logic for converting a string to an array of cchar_t's.
+   * There should be a better way, but this handles nonspacing characters
+   * and other special cases that we really do not want to handle here.
+   */
+  wclear(field->working);
+  mvwaddstr(field->working, 0, 0, value);
+
+  if ((widevalue = (FIELD_CELL *)calloc(len, sizeof(FIELD_CELL))) == 0)
+    {
+      RETURN(E_SYSTEM_ERROR);
+    }
+  else
+    {
+      mvwin_wchnstr(field->working, 0, 0, widevalue, (int)len);
+      for (i = 0; i < len; ++i)
+	{
+	  if (CharEq(myZEROS, widevalue[i]))
+	    {
+	      while (i < len)
+		p[i++] = myBLANK;
+	      break;
+	    }
+	  p[i] = widevalue[i];
+	}
+      free(widevalue);
+    }
 #else
-  for(s=(char *)value; *s && (s < (value+len)); s++)
-    p[s-value] = *s;
-  if (s < (value+len))
+  for (i = 0; i < len; ++i)
     {
-      p[s-value] = *s++;
-      s = p + (s-value);
+      if (value[i] == '\0')
+	{
+	  while (i < len)
+	    p[i++] = myBLANK;
+	  break;
+	}
+      p[i] = value[i];
     }
-  else 
-    s=(char *)0;
 #endif
 
-  if (s) 
-    { /* this means, value was null terminated and not greater than the
-	 buffer. We have to pad with blanks. Please note that due to memccpy
-	 logic s points after the terminating null. */
-      s--; /* now we point to the terminator. */
-      assert(len >= (unsigned int)(s-p));
-      if (len > (unsigned int)(s-p))
-	memset(s,C_BLANK,len-(unsigned int)(s-p));
-    }
-
-  if (buffer==0)
+  if (buffer == 0)
     {
       int syncres;
-      if (((syncres=Synchronize_Field( field ))!=E_OK) && 
-	  (res==E_OK))
+
+      if (((syncres = Synchronize_Field(field)) != E_OK) &&
+	  (res == E_OK))
 	res = syncres;
-      if (((syncres=Synchronize_Linked_Fields(field ))!=E_OK) &&
-	  (res==E_OK))
+      if (((syncres = Synchronize_Linked_Fields(field)) != E_OK) &&
+	  (res == E_OK))
 	res = syncres;
     }
   RETURN(res);
-}		
+}
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  char *field_buffer(const FIELD *field,int buffer)
-|   
+|
 |   Description   :  Return the address of the buffer for the field.
 |
 |   Return Values :  Pointer to buffer or NULL if arguments were invalid.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(char *)
-field_buffer (const FIELD * field, int  buffer)
+field_buffer(const FIELD *field, int buffer)
 {
+  char *result = 0;
+
+  T((T_CALLED("field_buffer(%p,%d)"), field, buffer));
+
   if (field && (buffer >= 0) && (buffer <= field->nbuf))
-    return Address_Of_Nth_Buffer(field,buffer);
-  else
-    return (char *)0;
+    {
+#if USE_WIDEC_SUPPORT
+      FIELD_CELL *data = Address_Of_Nth_Buffer(field, buffer);
+      unsigned need = 0;
+      int size = Buffer_Length(field);
+      int n;
+
+      /* determine the number of bytes needed to store the expanded string */
+      for (n = 0; n < size; ++n)
+	{
+	  if (!isWidecExt(data[n]))
+	    {
+	      mbstate_t state;
+	      size_t next;
+
+	      init_mb(state);
+	      next = _nc_wcrtomb(0, data[n].chars[0], &state);
+	      if (!isEILSEQ(next))
+		{
+		  if (next != 0)
+		    need += next;
+		}
+	    }
+	}
+
+      /* allocate a place to store the expanded string */
+      if (field->expanded[buffer] != 0)
+	free(field->expanded[buffer]);
+      field->expanded[buffer] = typeMalloc(char, need + 1);
+
+      /* expand the multibyte data */
+      if ((result = field->expanded[buffer]) != 0)
+	{
+	  wclear(field->working);
+	  mvwadd_wchnstr(field->working, 0, 0, data, size);
+	  mvwinnstr(field->working, 0, 0, result, (int)need + 1);
+	}
+#else
+      result = Address_Of_Nth_Buffer(field, buffer);
+#endif
+    }
+  returnPtr(result);
+}
+
+#if USE_WIDEC_SUPPORT
+
+/* FIXME: see lib_get_wch.c */
+#if HAVE_MBTOWC && HAVE_MBLEN
+#define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
+#define count_mbytes(buffer,length,state) mblen(buffer,length)
+#define trans_mbytes(wch,buffer,length,state) \
+	(int) mbtowc(&wch, buffer, length)
+#elif HAVE_MBRTOWC && HAVE_MBRLEN
+#define NEED_STATE
+#define reset_mbytes(state) init_mb(state)
+#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
+#define trans_mbytes(wch,buffer,length,state) \
+	(int) mbrtowc(&wch, buffer, length, &state)
+#else
+make an error
+#endif
+
+/*---------------------------------------------------------------------------
+| Convert a multibyte string to a wide-character string.  The result must be
+| freed by the caller.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(wchar_t *)
+_nc_Widen_String(char *source, int *lengthp)
+{
+  wchar_t *result = 0;
+  wchar_t wch;
+  size_t given = strlen(source);
+  size_t tries;
+  int pass;
+  int status;
+
+#ifdef NEED_STATE
+  mbstate_t state;
+#endif
+
+  for (pass = 0; pass < 2; ++pass)
+    {
+      unsigned need = 0;
+      size_t passed = 0;
+
+      while (passed < given)
+	{
+	  bool found = FALSE;
+
+	  for (tries = 1, status = 0; tries <= (given - passed); ++tries)
+	    {
+	      int save = source[passed + tries];
+
+	      source[passed + tries] = 0;
+	      reset_mbytes(state);
+	      status = trans_mbytes(wch, source + passed, tries, state);
+	      source[passed + tries] = save;
+
+	      if (status > 0)
+		{
+		  found = TRUE;
+		  break;
+		}
+	    }
+	  if (found)
+	    {
+	      if (pass)
+		{
+		  result[need] = wch;
+		}
+	      passed += status;
+	      ++need;
+	    }
+	  else
+	    {
+	      if (pass)
+		{
+		  result[need] = source[passed];
+		}
+	      ++need;
+	      ++passed;
+	    }
+	}
+
+      if (!pass)
+	{
+	  if (!need)
+	    break;
+	  result = typeCalloc(wchar_t, need);
+
+	  *lengthp = need;
+	  if (result == 0)
+	    break;
+	}
+    }
+
+  return result;
 }
+#endif
 
 /* frm_driver.c ends here */
diff -Naur ncurses-5.4.orig/form/frm_hook.c ncurses-5.4/form/frm_hook.c
--- ncurses-5.4.orig/form/frm_hook.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_hook.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,12 +32,13 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_hook.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_hook.c,v 1.14 2004/12/25 22:37:27 tom Exp $")
 
 /* "Template" macro to generate function to set application specific hook */
 #define GEN_HOOK_SET_FUNCTION( typ, name ) \
 NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
 {\
+   T((T_CALLED("set_" #typ"_"#name"(%p,%p)"), form, func));\
    (Normalize_Form( form ) -> typ ## name) = func ;\
    RETURN(E_OK);\
 }
@@ -46,95 +47,96 @@
 #define GEN_HOOK_GET_FUNCTION( typ, name ) \
 NCURSES_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\
 {\
-   return ( Normalize_Form( form ) -> typ ## name );\
+   T((T_CALLED(#typ "_" #name "(%p)"), form));\
+   returnFormHook( Normalize_Form( form ) -> typ ## name );\
 }
-
+
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_init(FORM *form, Form_Hook f)
-|   
+|
 |   Description   :  Assigns an application defined initialization function
 |                    to be called when the form is posted and just after
 |                    the current field changes.
 |
 |   Return Values :  E_OK      - success
 +--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION(field,init)
+GEN_HOOK_SET_FUNCTION(field, init)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  Form_Hook field_init(const FORM *form)
-|   
+|
 |   Description   :  Retrieve field initialization routine address.
 |
 |   Return Values :  The address or NULL if no hook defined.
 +--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION(field,init)
+GEN_HOOK_GET_FUNCTION(field, init)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_field_term(FORM *form, Form_Hook f)
-|   
+|
 |   Description   :  Assigns an application defined finalization function
 |                    to be called when the form is unposted and just before
 |                    the current field changes.
 |
 |   Return Values :  E_OK      - success
 +--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION(field,term)
+GEN_HOOK_SET_FUNCTION(field, term)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  Form_Hook field_term(const FORM *form)
-|   
+|
 |   Description   :  Retrieve field finalization routine address.
 |
 |   Return Values :  The address or NULL if no hook defined.
 +--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION(field,term)
+GEN_HOOK_GET_FUNCTION(field, term)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_form_init(FORM *form, Form_Hook f)
-|   
+|
 |   Description   :  Assigns an application defined initialization function
 |                    to be called when the form is posted and just after
 |                    a page change.
 |
 |   Return Values :  E_OK       - success
 +--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION(form,init)
+GEN_HOOK_SET_FUNCTION(form, init)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  Form_Hook form_init(const FORM *form)
-|   
+|
 |   Description   :  Retrieve form initialization routine address.
 |
 |   Return Values :  The address or NULL if no hook defined.
 +--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION(form,init)
+GEN_HOOK_GET_FUNCTION(form, init)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  int set_form_term(FORM *form, Form_Hook f)
-|   
+|
 |   Description   :  Assigns an application defined finalization function
 |                    to be called when the form is unposted and just before
 |                    a page change.
 |
 |   Return Values :  E_OK       - success
 +--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION(form,term)
+GEN_HOOK_SET_FUNCTION(form, term)
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
+|   Facility      :  libnform
 |   Function      :  Form_Hook form_term(const FORM *form)
-|   
+|
 |   Description   :  Retrieve form finalization routine address.
 |
 |   Return Values :  The address or NULL if no hook defined.
 +--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION(form,term)
+GEN_HOOK_GET_FUNCTION(form, term)
 
 /* frm_hook.c ends here */
diff -Naur ncurses-5.4.orig/form/frm_opts.c ncurses-5.4/form/frm_opts.c
--- ncurses-5.4.orig/form/frm_opts.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_opts.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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 "form.priv.h"
 
-MODULE_ID("$Id: frm_opts.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_opts.c,v 1.14 2005/04/16 16:59:18 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -45,14 +45,16 @@
 |                    E_BAD_ARGUMENT    - invalid options
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_form_opts (FORM * form, Form_Options  opts)
+set_form_opts(FORM *form, Form_Options opts)
 {
+  T((T_CALLED("set_form_opts(%p,%d)"), form, opts));
+
   opts &= ALL_FORM_OPTS;
   if (opts & ~ALL_FORM_OPTS)
     RETURN(E_BAD_ARGUMENT);
   else
     {
-      Normalize_Form( form )->opts = opts;
+      Normalize_Form(form)->opts = opts;
       RETURN(E_OK);
     }
 }
@@ -66,9 +68,10 @@
 |   Return Values :  The option flags.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(Form_Options)
-form_opts (const FORM * form)
+form_opts(const FORM *form)
 {
-  return (Normalize_Form(form)->opts & ALL_FORM_OPTS);
+  T((T_CALLED("form_opts(%p)"), form));
+  returnCode((int)(Normalize_Form(form)->opts & ALL_FORM_OPTS));
 }
 
 /*---------------------------------------------------------------------------
@@ -82,14 +85,16 @@
 |                    E_BAD_ARGUMENT  - invalid options
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-form_opts_on (FORM * form, Form_Options opts)
+form_opts_on(FORM *form, Form_Options opts)
 {
+  T((T_CALLED("form_opts_on(%p,%d)"), form, opts));
+
   opts &= ALL_FORM_OPTS;
   if (opts & ~ALL_FORM_OPTS)
     RETURN(E_BAD_ARGUMENT);
   else
     {
-      Normalize_Form( form )->opts |= opts;	
+      Normalize_Form(form)->opts |= opts;
       RETURN(E_OK);
     }
 }
@@ -105,8 +110,10 @@
 |                    E_BAD_ARGUMENT  - invalid options
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-form_opts_off (FORM * form, Form_Options opts)
+form_opts_off(FORM *form, Form_Options opts)
 {
+  T((T_CALLED("form_opts_off(%p,%d)"), form, opts));
+
   opts &= ALL_FORM_OPTS;
   if (opts & ~ALL_FORM_OPTS)
     RETURN(E_BAD_ARGUMENT);
diff -Naur ncurses-5.4.orig/form/frm_page.c ncurses-5.4/form/frm_page.c
--- ncurses-5.4.orig/form/frm_page.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_page.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: frm_page.c,v 1.8 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_page.c,v 1.10 2004/12/11 22:08:21 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -47,35 +47,37 @@
 |                    E_SYSTEM_ERROR    - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_form_page (FORM * form, int page)
+set_form_page(FORM *form, int page)
 {
   int err = E_OK;
 
-  if ( !form || (page<0) || (page>=form->maxpage) )
+  T((T_CALLED("set_form_page(%p,%d)"), form, page));
+
+  if (!form || (page < 0) || (page >= form->maxpage))
     RETURN(E_BAD_ARGUMENT);
 
   if (!(form->status & _POSTED))
     {
       form->curpage = page;
       form->current = _nc_First_Active_Field(form);
-  }
+    }
   else
     {
-      if (form->status & _IN_DRIVER) 
+      if (form->status & _IN_DRIVER)
 	err = E_BAD_STATE;
       else
 	{
 	  if (form->curpage != page)
 	    {
-	      if (!_nc_Internal_Validation(form)) 
+	      if (!_nc_Internal_Validation(form))
 		err = E_INVALID_FIELD;
 	      else
 		{
-		  Call_Hook(form,fieldterm);
-		  Call_Hook(form,formterm);
-		  err = _nc_Set_Form_Page(form,page,(FIELD *)0);
-		  Call_Hook(form,forminit);
-		  Call_Hook(form,fieldinit);
+		  Call_Hook(form, fieldterm);
+		  Call_Hook(form, formterm);
+		  err = _nc_Set_Form_Page(form, page, (FIELD *)0);
+		  Call_Hook(form, forminit);
+		  Call_Hook(form, fieldinit);
 		  _nc_Refresh_Current_Field(form);
 		}
 	    }
@@ -94,9 +96,11 @@
 |                    -1    : invalid form pointer
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-form_page (const FORM * form)
+form_page(const FORM *form)
 {
-  return Normalize_Form(form)->curpage;
+  T((T_CALLED("form_page(%p)"), form));
+
+  returnCode(Normalize_Form(form)->curpage);
 }
 
 /* frm_page.c ends here */
diff -Naur ncurses-5.4.orig/form/frm_post.c ncurses-5.4/form/frm_post.c
--- ncurses-5.4.orig/form/frm_post.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_post.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: frm_post.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_post.c,v 1.9 2004/12/11 22:19:06 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -48,37 +48,39 @@
 |                    E_SYSTEM_ERROR    - system error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-post_form (FORM * form)
+post_form(FORM *form)
 {
   WINDOW *formwin;
   int err;
   int page;
 
+  T((T_CALLED("post_form(%p)"), form));
+
   if (!form)
     RETURN(E_BAD_ARGUMENT);
 
-  if (form->status & _POSTED)   
+  if (form->status & _POSTED)
     RETURN(E_POSTED);
 
   if (!(form->field))
     RETURN(E_NOT_CONNECTED);
-  
+
   formwin = Get_Form_Window(form);
-  if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin))) 
+  if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin)))
     RETURN(E_NO_ROOM);
 
   /* reset form->curpage to an invald value. This forces Set_Form_Page
      to do the page initialization which is required by post_form.
-  */
+   */
   page = form->curpage;
   form->curpage = -1;
-  if ((err = _nc_Set_Form_Page(form,page,form->current))!=E_OK)
+  if ((err = _nc_Set_Form_Page(form, page, form->current)) != E_OK)
     RETURN(err);
 
   form->status |= _POSTED;
 
-  Call_Hook(form,forminit);
-  Call_Hook(form,fieldinit);
+  Call_Hook(form, forminit);
+  Call_Hook(form, fieldinit);
 
   _nc_Refresh_Current_Field(form);
   RETURN(E_OK);
@@ -96,19 +98,21 @@
 |                    E_BAD_STATE     - called from a hook routine
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-unpost_form (FORM * form)
+unpost_form(FORM *form)
 {
+  T((T_CALLED("unpost_form(%p)"), form));
+
   if (!form)
     RETURN(E_BAD_ARGUMENT);
 
-  if (!(form->status & _POSTED)) 
+  if (!(form->status & _POSTED))
     RETURN(E_NOT_POSTED);
 
-  if (form->status & _IN_DRIVER) 
+  if (form->status & _IN_DRIVER)
     RETURN(E_BAD_STATE);
 
-  Call_Hook(form,fieldterm);
-  Call_Hook(form,formterm);
+  Call_Hook(form, fieldterm);
+  Call_Hook(form, formterm);
 
   werase(Get_Form_Window(form));
   delwin(form->w);
diff -Naur ncurses-5.4.orig/form/frm_req_name.c ncurses-5.4/form/frm_req_name.c
--- ncurses-5.4.orig/form/frm_req_name.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_req_name.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -37,71 +37,73 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: frm_req_name.c,v 1.10 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_req_name.c,v 1.15 2005/04/16 16:59:27 tom Exp $")
 
-static const char *request_names[ MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1 ] = {
-  "NEXT_PAGE"	 ,
-  "PREV_PAGE"	 ,
-  "FIRST_PAGE"	 ,
-  "LAST_PAGE"	 ,
-
-  "NEXT_FIELD"	 ,
-  "PREV_FIELD"	 ,
-  "FIRST_FIELD"	 ,
-  "LAST_FIELD"	 ,
-  "SNEXT_FIELD"	 ,
-  "SPREV_FIELD"	 ,
-  "SFIRST_FIELD" ,
-  "SLAST_FIELD"	 ,
-  "LEFT_FIELD"	 ,
-  "RIGHT_FIELD"	 ,
-  "UP_FIELD"	 ,
-  "DOWN_FIELD"	 ,
-
-  "NEXT_CHAR"	 ,
-  "PREV_CHAR"	 ,
-  "NEXT_LINE"	 ,
-  "PREV_LINE"	 ,
-  "NEXT_WORD"	 ,
-  "PREV_WORD"	 ,
-  "BEG_FIELD"	 ,
-  "END_FIELD"	 ,
-  "BEG_LINE"	 ,
-  "END_LINE"	 ,
-  "LEFT_CHAR"	 ,
-  "RIGHT_CHAR"	 ,
-  "UP_CHAR"	 ,
-  "DOWN_CHAR"	 ,
-
-  "NEW_LINE"	 ,
-  "INS_CHAR"	 ,
-  "INS_LINE"	 ,
-  "DEL_CHAR"	 ,
-  "DEL_PREV"	 ,
-  "DEL_LINE"	 ,
-  "DEL_WORD"	 ,
-  "CLR_EOL"	 ,
-  "CLR_EOF"	 ,
-  "CLR_FIELD"	 ,
-  "OVL_MODE"	 ,
-  "INS_MODE"	 ,
-  "SCR_FLINE"	 ,
-  "SCR_BLINE"	 ,
-  "SCR_FPAGE"	 ,
-  "SCR_BPAGE"	 ,
-  "SCR_FHPAGE"   ,
-  "SCR_BHPAGE"   ,
-  "SCR_FCHAR"    ,
-  "SCR_BCHAR"    ,
-  "SCR_HFLINE"   ,
-  "SCR_HBLINE"   ,
-  "SCR_HFHALF"   ,
-  "SCR_HBHALF"   ,
-
-  "VALIDATION"	 ,
-  "NEXT_CHOICE"	 ,
-  "PREV_CHOICE"	 
+static const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
+{
+  "NEXT_PAGE",
+  "PREV_PAGE",
+  "FIRST_PAGE",
+  "LAST_PAGE",
+
+  "NEXT_FIELD",
+  "PREV_FIELD",
+  "FIRST_FIELD",
+  "LAST_FIELD",
+  "SNEXT_FIELD",
+  "SPREV_FIELD",
+  "SFIRST_FIELD",
+  "SLAST_FIELD",
+  "LEFT_FIELD",
+  "RIGHT_FIELD",
+  "UP_FIELD",
+  "DOWN_FIELD",
+
+  "NEXT_CHAR",
+  "PREV_CHAR",
+  "NEXT_LINE",
+  "PREV_LINE",
+  "NEXT_WORD",
+  "PREV_WORD",
+  "BEG_FIELD",
+  "END_FIELD",
+  "BEG_LINE",
+  "END_LINE",
+  "LEFT_CHAR",
+  "RIGHT_CHAR",
+  "UP_CHAR",
+  "DOWN_CHAR",
+
+  "NEW_LINE",
+  "INS_CHAR",
+  "INS_LINE",
+  "DEL_CHAR",
+  "DEL_PREV",
+  "DEL_LINE",
+  "DEL_WORD",
+  "CLR_EOL",
+  "CLR_EOF",
+  "CLR_FIELD",
+  "OVL_MODE",
+  "INS_MODE",
+  "SCR_FLINE",
+  "SCR_BLINE",
+  "SCR_FPAGE",
+  "SCR_BPAGE",
+  "SCR_FHPAGE",
+  "SCR_BHPAGE",
+  "SCR_FCHAR",
+  "SCR_BCHAR",
+  "SCR_HFLINE",
+  "SCR_HBLINE",
+  "SCR_HFHALF",
+  "SCR_HBHALF",
+
+  "VALIDATION",
+  "NEXT_CHOICE",
+  "PREV_CHOICE"
 };
+
 #define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
 
 /*---------------------------------------------------------------------------
@@ -114,18 +116,19 @@
 |                    NULL                 - on invalid request code
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(const char *)
-form_request_name ( int request )
+form_request_name(int request)
 {
-  if ( (request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND) )
+  T((T_CALLED("form_request_name(%d)"), request));
+
+  if ((request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND))
     {
-      SET_ERROR (E_BAD_ARGUMENT);
-      return (const char *)0;
+      SET_ERROR(E_BAD_ARGUMENT);
+      returnCPtr((const char *)0);
     }
   else
-    return request_names[ request - MIN_FORM_COMMAND ];
+    returnCPtr(request_names[request - MIN_FORM_COMMAND]);
 }
 
-
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
 |   Function      :  int form_request_by_name (const char *str);
@@ -136,28 +139,30 @@
 |                    E_NO_MATCH       - request not found
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-form_request_by_name ( const char *str )
-{ 
+form_request_by_name(const char *str)
+{
   /* because the table is so small, it doesn't really hurt
      to run sequentially through it.
-  */
+   */
   unsigned int i = 0;
   char buf[16];
-  
+
+  T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
+
   if (str)
     {
-      strncpy(buf,str,sizeof(buf));
-      while( (i<sizeof(buf)) && (buf[i] != '\0') )
+      strncpy(buf, str, sizeof(buf));
+      while ((i < sizeof(buf)) && (buf[i] != '\0'))
 	{
 	  buf[i] = toupper(buf[i]);
 	  i++;
 	}
-      
-      for (i=0; i < A_SIZE; i++)
+
+      for (i = 0; i < A_SIZE; i++)
 	{
-	  if (strncmp(request_names[i],buf,sizeof(buf))==0)
-	    return MIN_FORM_COMMAND + i;
-	} 
+	  if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
+	    returnCode(MIN_FORM_COMMAND + (int) i);
+	}
     }
   RETURN(E_NO_MATCH);
 }
diff -Naur ncurses-5.4.orig/form/frm_scale.c ncurses-5.4/form/frm_scale.c
--- ncurses-5.4.orig/form/frm_scale.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_scale.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: frm_scale.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_scale.c,v 1.9 2004/12/11 22:12:34 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -45,19 +45,21 @@
 |                    E_NOT_CONNECTED   - no fields connected to form
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-scale_form (const FORM * form, int * rows, int * cols)
+scale_form(const FORM *form, int *rows, int *cols)
 {
-  if ( !form )
+  T((T_CALLED("scale_form(%p,%p,%p)"), form, rows, cols));
+
+  if (!form)
     RETURN(E_BAD_ARGUMENT);
 
-  if ( !(form->field) )
+  if (!(form->field))
     RETURN(E_NOT_CONNECTED);
-  
-  if (rows) 
+
+  if (rows)
     *rows = form->rows;
-  if (cols) 
+  if (cols)
     *cols = form->cols;
-  
+
   RETURN(E_OK);
 }
 
diff -Naur ncurses-5.4.orig/form/frm_sub.c ncurses-5.4/form/frm_sub.c
--- ncurses-5.4.orig/form/frm_sub.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_sub.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: frm_sub.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_sub.c,v 1.9 2004/12/11 22:13:39 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -44,14 +44,16 @@
 |                    E_POSTED   - form is posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_form_sub (FORM * form, WINDOW * win)
+set_form_sub(FORM *form, WINDOW *win)
 {
-  if (form && (form->status & _POSTED))	
+  T((T_CALLED("set_form_sub(%p,%p)"), form, win));
+
+  if (form && (form->status & _POSTED))
     RETURN(E_POSTED);
 
-  Normalize_Form( form )->sub = win;
+  Normalize_Form(form)->sub = win;
   RETURN(E_OK);
-}	
+}
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -62,10 +64,14 @@
 |   Return Values :  The pointer to the Subwindow.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(WINDOW *)
-form_sub (const FORM * form)
+form_sub(const FORM *form)
 {
-  const FORM* f = Normalize_Form( form );
-  return Get_Form_Window(f);
+  const FORM *f;
+
+  T((T_CALLED("form_sub(%p)"), form));
+
+  f = Normalize_Form(form);
+  returnWin(Get_Form_Window(f));
 }
 
 /* frm_sub.c ends here */
diff -Naur ncurses-5.4.orig/form/frm_user.c ncurses-5.4/form/frm_user.c
--- ncurses-5.4.orig/form/frm_user.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_user.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: frm_user.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_user.c,v 1.14 2004/12/25 22:37:56 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -44,8 +44,10 @@
 |   Return Values :  E_OK         - on success
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_form_userptr (FORM * form, void *usrptr)
+set_form_userptr(FORM *form, void *usrptr)
 {
+  T((T_CALLED("set_form_userptr(%p,%p)"), form, usrptr));
+
   Normalize_Form(form)->usrptr = usrptr;
   RETURN(E_OK);
 }
@@ -61,9 +63,10 @@
 |                    NULL is returned
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void *)
-form_userptr (const FORM * form)
+form_userptr(const FORM *form)
 {
-  return Normalize_Form(form)->usrptr;
+  T((T_CALLED("form_userptr(%p)"), form));
+  returnVoidPtr(Normalize_Form(form)->usrptr);
 }
 
 /* frm_user.c ends here */
diff -Naur ncurses-5.4.orig/form/frm_win.c ncurses-5.4/form/frm_win.c
--- ncurses-5.4.orig/form/frm_win.c	2003-10-25 15:17:08.000000000 +0000
+++ ncurses-5.4/form/frm_win.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
 
-MODULE_ID("$Id: frm_win.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
+MODULE_ID("$Id: frm_win.c,v 1.13 2004/12/11 22:15:27 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -44,14 +44,16 @@
 |                    E_POSTED   - form is posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_form_win (FORM * form, WINDOW * win)
+set_form_win(FORM *form, WINDOW *win)
 {
-  if (form && (form->status & _POSTED))	
+  T((T_CALLED("set_form_win(%p,%p)"), form, win));
+
+  if (form && (form->status & _POSTED))
     RETURN(E_POSTED);
 
-  Normalize_Form( form )->win = win;
+  Normalize_Form(form)->win = win;
   RETURN(E_OK);
-}	
+}
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -62,11 +64,14 @@
 |   Return Values :  The pointer to the Window or stdscr if there is none.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(WINDOW *)
-form_win (const FORM * form)
+form_win(const FORM *form)
 {
-  const FORM* f = Normalize_Form( form );
-  return (f->win ? f->win : stdscr);
+  const FORM *f;
+
+  T((T_CALLED("form_win(%p)"), form));
+
+  f = Normalize_Form(form);
+  returnWin(f->win ? f->win : stdscr);
 }
 
 /* frm_win.c ends here */
-
diff -Naur ncurses-5.4.orig/form/fty_alnum.c ncurses-5.4/form/fty_alnum.c
--- ncurses-5.4.orig/form/fty_alnum.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/form/fty_alnum.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,4 +1,3 @@
-
 /*
  * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
  * You may freely copy it for use as a template for your own field types.
@@ -13,42 +12,46 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_alnum.c,v 1.12 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: fty_alnum.c,v 1.17 2005/04/16 18:26:04 tom Exp $")
 
-typedef struct {
-  int width;
-} alnumARG;
+typedef struct
+  {
+    int width;
+  }
+thisARG;
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static void *Make_AlphaNumeric_Type(va_list *ap)
-|   
+|   Facility      :  libnform
+|   Function      :  static void *Make_This_Type(va_list *ap)
+|
 |   Description   :  Allocate structure for alphanumeric type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error
 +--------------------------------------------------------------------------*/
-static void *Make_AlphaNumeric_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
 {
-  alnumARG *argp = (alnumARG *)malloc(sizeof(alnumARG));
+  thisARG *argp = (thisARG *) malloc(sizeof(thisARG));
 
   if (argp)
-    argp->width = va_arg(*ap,int);
+    argp->width = va_arg(*ap, int);
 
   return ((void *)argp);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static void *Copy_AlphaNumericType(const void *argp)
-|   
-|   Description   :  Copy structure for alphanumeric type argument.  
+|   Facility      :  libnform
+|   Function      :  static void *Copy_ThisType(const void *argp)
+|
+|   Description   :  Copy structure for alphanumeric type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error.
 +--------------------------------------------------------------------------*/
-static void *Copy_AlphaNumeric_Type(const void *argp)
+static void *
+Copy_This_Type(const void *argp)
 {
-  const alnumARG *ap = (const alnumARG *)argp;
-  alnumARG *result = (alnumARG *)malloc(sizeof(alnumARG));
+  const thisARG *ap = (const thisARG *)argp;
+  thisARG *result = (thisARG *) malloc(sizeof(thisARG));
 
   if (result)
     *result = *ap;
@@ -57,81 +60,78 @@
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static void Free_AlphaNumeric_Type(void *argp)
-|   
+|   Facility      :  libnform
+|   Function      :  static void Free_This_Type(void *argp)
+|
 |   Description   :  Free structure for alphanumeric type argument.
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Free_AlphaNumeric_Type(void * argp)
+static void
+Free_This_Type(void *argp)
 {
-  if (argp) 
+  if (argp)
     free(argp);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static bool Check_AlphaNumeric_Field(
-|                                      FIELD *field,
+|   Facility      :  libnform
+|   Function      :  static bool Check_This_Character(
+|                                      int c,
 |                                      const void *argp)
-|   
-|   Description   :  Validate buffer content to be a valid alphanumeric value
 |
-|   Return Values :  TRUE  - field is valid
-|                    FALSE - field is invalid
+|   Description   :  Check a character for the alphanumeric type.
+|
+|   Return Values :  TRUE  - character is valid
+|                    FALSE - character is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_AlphaNumeric_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
 {
-  int width = ((const alnumARG *)argp)->width;
-  unsigned char *bp  = (unsigned char *)field_buffer(field,0);
-  int  l = -1;
-  unsigned char *s;
-
-  while(*bp && *bp==' ') 
-    bp++;
-  if (*bp)
-    {
-      s = bp;
-      while(*bp && isalnum(*bp)) 
-	bp++;
-      l = (int)(bp-s);
-      while(*bp && *bp==' ') 
-	bp++;
-    }
-  return ((*bp || (l < width)) ? FALSE : TRUE);
+#if USE_WIDEC_SUPPORT
+  if (iswalnum((wint_t) c))
+    return TRUE;
+#endif
+  return (isalnum(UChar(c)) ? TRUE : FALSE);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static bool Check_AlphaNumeric_Character(
-|                                      int c, 
-|                                      const void *argp )
-|   
-|   Description   :  Check a character for the alphanumeric type.
+|   Facility      :  libnform
+|   Function      :  static bool Check_This_Field(
+|                                      FIELD *field,
+|                                      const void *argp)
 |
-|   Return Values :  TRUE  - character is valid
-|                    FALSE - character is invalid
+|   Description   :  Validate buffer content to be a valid alphanumeric value
+|
+|   Return Values :  TRUE  - field is valid
+|                    FALSE - field is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_AlphaNumeric_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
 {
-  return (isalnum(c) ? TRUE : FALSE);
+  int width = ((const thisARG *)argp)->width;
+  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+  bool result = (width < 0);
+
+  Check_CTYPE_Field(result, bp, width, Check_This_Character);
+  return (result);
 }
 
-static FIELDTYPE typeALNUM = {
+static FIELDTYPE typeTHIS =
+{
   _HAS_ARGS | _RESIDENT,
-  1,                           /* this is mutable, so we can't be const */
+  1,				/* this is mutable, so we can't be const */
   (FIELDTYPE *)0,
   (FIELDTYPE *)0,
-  Make_AlphaNumeric_Type,
-  Copy_AlphaNumeric_Type,
-  Free_AlphaNumeric_Type,
-  Check_AlphaNumeric_Field,
-  Check_AlphaNumeric_Character,
+  Make_This_Type,
+  Copy_This_Type,
+  Free_This_Type,
+  Check_This_Field,
+  Check_This_Character,
   NULL,
   NULL
 };
 
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeALNUM;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeTHIS;
 
 /* fty_alnum.c ends here */
diff -Naur ncurses-5.4.orig/form/fty_alpha.c ncurses-5.4/form/fty_alpha.c
--- ncurses-5.4.orig/form/fty_alpha.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/form/fty_alpha.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,4 +1,3 @@
-
 /*
  * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
  * You may freely copy it for use as a template for your own field types.
@@ -13,126 +12,126 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_alpha.c,v 1.12 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: fty_alpha.c,v 1.19 2005/04/16 18:24:56 tom Exp $")
 
-typedef struct {
-  int width;
-} alphaARG;
+typedef struct
+  {
+    int width;
+  }
+thisARG;
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static void *Make_Alpha_Type(va_list *ap)
-|   
+|   Facility      :  libnform
+|   Function      :  static void *Make_This_Type(va_list *ap)
+|
 |   Description   :  Allocate structure for alpha type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error
 +--------------------------------------------------------------------------*/
-static void *Make_Alpha_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
 {
-  alphaARG *argp = (alphaARG *)malloc(sizeof(alphaARG));
+  thisARG *argp = (thisARG *) malloc(sizeof(thisARG));
+
   if (argp)
-    {
-      argp->width = va_arg(*ap,int);
-    }
+    argp->width = va_arg(*ap, int);
+
   return ((void *)argp);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static void *Copy_Alpha_Type(const void * argp)
-|   
-|   Description   :  Copy structure for alpha type argument.  
+|   Facility      :  libnform
+|   Function      :  static void *Copy_This_Type(const void * argp)
+|
+|   Description   :  Copy structure for alpha type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error.
 +--------------------------------------------------------------------------*/
-static void *Copy_Alpha_Type(const void * argp)
+static void *
+Copy_This_Type(const void *argp)
 {
-  const alphaARG *ap = (const alphaARG *)argp;
-  alphaARG *result = (alphaARG *)malloc(sizeof(alphaARG));
-  
+  const thisARG *ap = (const thisARG *)argp;
+  thisARG *result = (thisARG *) malloc(sizeof(thisARG));
+
   if (result)
-    {
-      *result = *ap;
-    }
+    *result = *ap;
+
   return ((void *)result);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static void Free_Alpha_Type( void * argp )
-|   
+|   Facility      :  libnform
+|   Function      :  static void Free_This_Type(void *argp)
+|
 |   Description   :  Free structure for alpha type argument.
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Free_Alpha_Type(void * argp)
+static void
+Free_This_Type(void *argp)
 {
-  if (argp) 
+  if (argp)
     free(argp);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static bool Check_Alpha_Field(
-|                                      FIELD * field,
-|                                      const void * argp)
-|   
-|   Description   :  Validate buffer content to be a valid alpha value
+|   Facility      :  libnform
+|   Function      :  static bool Check_This_Character(
+|                                      int c,
+|                                      const void *argp)
 |
-|   Return Values :  TRUE  - field is valid
-|                    FALSE - field is invalid
+|   Description   :  Check a character for the alpha type.
+|
+|   Return Values :  TRUE  - character is valid
+|                    FALSE - character is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_Alpha_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
 {
-  int width = ((const alphaARG *)argp)->width;
-  unsigned char *bp  = (unsigned char *)field_buffer(field,0);
-  int  l = -1;
-  unsigned char *s;
-
-  while(*bp && *bp==' ') 
-    bp++;
-  if (*bp)
-    {
-      s = bp;
-      while(*bp && isalpha(*bp)) 
-	bp++;
-      l = (int)(bp-s);
-      while(*bp && *bp==' ') 
-	bp++;
-    }
-  return ((*bp || (l < width)) ? FALSE : TRUE);
+#if USE_WIDEC_SUPPORT
+  if (iswalpha((wint_t)c))
+    return TRUE;
+#endif
+  return (isalpha(UChar(c)) ? TRUE : FALSE);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static bool Check_Alpha_Character(
-|                                      int c,
-|                                      const void * argp)
-|   
-|   Description   :  Check a character for the alpha type.
+|   Facility      :  libnform
+|   Function      :  static bool Check_This_Field(
+|                                      FIELD *field,
+|                                      const void *argp)
 |
-|   Return Values :  TRUE  - character is valid
-|                    FALSE - character is invalid
+|   Description   :  Validate buffer content to be a valid alpha value
+|
+|   Return Values :  TRUE  - field is valid
+|                    FALSE - field is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_Alpha_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
 {
-  return (isalpha(c) ? TRUE : FALSE);
+  int width = ((const thisARG *)argp)->width;
+  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+  bool result = (width < 0);
+
+  Check_CTYPE_Field(result, bp, width, Check_This_Character);
+  return (result);
 }
 
-static FIELDTYPE typeALPHA = {
+static FIELDTYPE typeTHIS =
+{
   _HAS_ARGS | _RESIDENT,
-  1,                           /* this is mutable, so we can't be const */
+  1,				/* this is mutable, so we can't be const */
   (FIELDTYPE *)0,
   (FIELDTYPE *)0,
-  Make_Alpha_Type,
-  Copy_Alpha_Type,
-  Free_Alpha_Type,
-  Check_Alpha_Field,
-  Check_Alpha_Character,
+  Make_This_Type,
+  Copy_This_Type,
+  Free_This_Type,
+  Check_This_Field,
+  Check_This_Character,
   NULL,
   NULL
 };
 
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeALPHA;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeTHIS;
 
 /* fty_alpha.c ends here */
diff -Naur ncurses-5.4.orig/form/fty_enum.c ncurses-5.4/form/fty_enum.c
--- ncurses-5.4.orig/form/fty_enum.c	2003-11-08 20:25:29.000000000 +0000
+++ ncurses-5.4/form/fty_enum.c	2005-05-13 04:09:50.000000000 +0000
@@ -13,14 +13,16 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_enum.c,v 1.18 2003/11/08 20:25:29 tom Exp $")
+MODULE_ID("$Id: fty_enum.c,v 1.19 2004/05/29 19:05:20 tom Exp $")
 
-typedef struct {
-  char **kwds;
-  int  count;
-  bool checkcase;
-  bool checkunique;
-} enumARG;
+typedef struct
+  {
+    char **kwds;
+    int count;
+    bool checkcase;
+    bool checkunique;
+  }
+enumARG;
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -30,7 +32,8 @@
 |
 |   Return Values :  Pointer to argument structure or NULL on error
 +--------------------------------------------------------------------------*/
-static void *Make_Enum_Type(va_list * ap)
+static void *
+Make_Enum_Type(va_list *ap)
 {
   enumARG *argp = (enumARG *)malloc(sizeof(enumARG));
 
@@ -40,14 +43,16 @@
       char **kp = (char **)0;
       int ccase, cunique;
 
-      argp->kwds        = va_arg(*ap,char **);
-      ccase             = va_arg(*ap,int);
-      cunique           = va_arg(*ap,int);
-      argp->checkcase   = ccase   ? TRUE : FALSE;
+      argp->kwds = va_arg(*ap, char **);
+      ccase = va_arg(*ap, int);
+      cunique = va_arg(*ap, int);
+
+      argp->checkcase = ccase ? TRUE : FALSE;
       argp->checkunique = cunique ? TRUE : FALSE;
 
       kp = argp->kwds;
-      while( kp && (*kp++) ) cnt++;
+      while (kp && (*kp++))
+	cnt++;
       argp->count = cnt;
     }
   return (void *)argp;
@@ -61,7 +66,8 @@
 |
 |   Return Values :  Pointer to argument structure or NULL on error.
 +--------------------------------------------------------------------------*/
-static void *Copy_Enum_Type(const void * argp)
+static void *
+Copy_Enum_Type(const void *argp)
 {
   enumARG *result = (enumARG *)0;
 
@@ -70,6 +76,7 @@
       const enumARG *ap = (const enumARG *)argp;
 
       result = (enumARG *)malloc(sizeof(enumARG));
+
       if (result)
 	*result = *ap;
     }
@@ -84,9 +91,10 @@
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Free_Enum_Type(void * argp)
+static void
+Free_Enum_Type(void *argp)
 {
-  if (argp) 
+  if (argp)
     free(argp);
 }
 
@@ -108,30 +116,33 @@
 |                    PARTIAL   - buffer matches partially
 |                    EXACT     - buffer matches exactly
 +--------------------------------------------------------------------------*/
-static int Compare(const unsigned char *s, const unsigned char *buf, 
-		   bool ccase)
+static int
+Compare(const unsigned char *s, const unsigned char *buf,
+	bool ccase)
 {
-  SKIP_SPACE(buf); /* Skip leading spaces in both texts */
+  SKIP_SPACE(buf);		/* Skip leading spaces in both texts */
   SKIP_SPACE(s);
 
-  if (*buf=='\0')
+  if (*buf == '\0')
     {
-      return (((*s)!='\0') ? NOMATCH : EXACT);
-    } 
-  else 
+      return (((*s) != '\0') ? NOMATCH : EXACT);
+    }
+  else
     {
       if (ccase)
 	{
-	  while(*s++ == *buf)
+	  while (*s++ == *buf)
 	    {
-	      if (*buf++=='\0') return EXACT;
-	    } 
-	} 
-      else 
+	      if (*buf++ == '\0')
+		return EXACT;
+	    }
+	}
+      else
 	{
-	  while(toupper(*s++)==toupper(*buf))
+	  while (toupper(*s++) == toupper(*buf))
 	    {
-	      if (*buf++=='\0') return EXACT;
+	      if (*buf++ == '\0')
+		return EXACT;
 	    }
 	}
     }
@@ -139,12 +150,12 @@
      matches with s. So if only blanks are following, we have a partial
      match otherwise there is no match */
   SKIP_SPACE(buf);
-  if (*buf) 
+  if (*buf)
     return NOMATCH;
 
   /* If it happens that the reference buffer is at its end, the partial
      match is actually an exact match. */
-  return ((s[-1]!='\0') ? PARTIAL : EXACT);
+  return ((s[-1] != '\0') ? PARTIAL : EXACT);
 }
 
 /*---------------------------------------------------------------------------
@@ -158,27 +169,28 @@
 |   Return Values :  TRUE  - field is valid
 |                    FALSE - field is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_Enum_Field(FIELD * field, const void  * argp)
+static bool
+Check_Enum_Field(FIELD *field, const void *argp)
 {
-  char **kwds       = ((const enumARG *)argp)->kwds;
-  bool ccase        = ((const enumARG *)argp)->checkcase;
-  bool unique       = ((const enumARG *)argp)->checkunique;
-  unsigned char *bp = (unsigned char *)field_buffer(field,0);
+  char **kwds = ((const enumARG *)argp)->kwds;
+  bool ccase = ((const enumARG *)argp)->checkcase;
+  bool unique = ((const enumARG *)argp)->checkunique;
+  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
   char *s, *t, *p;
   int res;
-  
-  while( kwds && (s=(*kwds++)) )
+
+  while (kwds && (s = (*kwds++)))
     {
-      if ((res=Compare((unsigned char *)s,bp,ccase))!=NOMATCH)
+      if ((res = Compare((unsigned char *)s, bp, ccase)) != NOMATCH)
 	{
-	  p=t=s; /* t is at least a partial match */
-	  if ((unique && res!=EXACT)) 
+	  p = t = s;		/* t is at least a partial match */
+	  if ((unique && res != EXACT))
 	    {
-	      while( kwds && (p = *kwds++) )
+	      while (kwds && (p = *kwds++))
 		{
-		  if ((res=Compare((unsigned char *)p,bp,ccase))!=NOMATCH)
+		  if ((res = Compare((unsigned char *)p, bp, ccase)) != NOMATCH)
 		    {
-		      if (res==EXACT)
+		      if (res == EXACT)
 			{
 			  t = p;
 			  break;
@@ -187,10 +199,10 @@
 			t = (char *)0;
 		    }
 		}
-	    }	  
+	    }
 	  if (t)
 	    {
-	      set_field_buffer(field,0,t);
+	      set_field_buffer(field, 0, t);
 	      return TRUE;
 	    }
 	  if (!p)
@@ -200,7 +212,8 @@
   return FALSE;
 }
 
-static const char *dummy[] = { (char *)0 };
+static const char *dummy[] =
+{(char *)0};
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -212,28 +225,30 @@
 |   Return Values :  TRUE  - next value found and loaded
 |                    FALSE - no next value loaded
 +--------------------------------------------------------------------------*/
-static bool Next_Enum(FIELD * field, const void * argp)
+static bool
+Next_Enum(FIELD *field, const void *argp)
 {
   const enumARG *args = (const enumARG *)argp;
-  char **kwds       = args->kwds;
-  bool ccase        = args->checkcase;
-  int cnt           = args->count;
-  unsigned char *bp = (unsigned char *)field_buffer(field,0);
-
-  if (kwds) {
-    while(cnt--)
-      {
-	if (Compare((unsigned char *)(*kwds++),bp,ccase)==EXACT) 
-	  break;
-      }
-    if (cnt<=0)
-      kwds = args->kwds;
-    if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
-      {
-	set_field_buffer(field,0,*kwds);
-	return TRUE;
-      }
-  }
+  char **kwds = args->kwds;
+  bool ccase = args->checkcase;
+  int cnt = args->count;
+  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+
+  if (kwds)
+    {
+      while (cnt--)
+	{
+	  if (Compare((unsigned char *)(*kwds++), bp, ccase) == EXACT)
+	    break;
+	}
+      if (cnt <= 0)
+	kwds = args->kwds;
+      if ((cnt >= 0) || (Compare((const unsigned char *)dummy, bp, ccase) == EXACT))
+	{
+	  set_field_buffer(field, 0, *kwds);
+	  return TRUE;
+	}
+    }
   return FALSE;
 }
 
@@ -248,37 +263,39 @@
 |   Return Values :  TRUE  - previous value found and loaded
 |                    FALSE - no previous value loaded
 +--------------------------------------------------------------------------*/
-static bool Previous_Enum(FIELD * field, const void * argp)
+static bool
+Previous_Enum(FIELD *field, const void *argp)
 {
   const enumARG *args = (const enumARG *)argp;
-  int cnt       = args->count;
-  char **kwds   = &args->kwds[cnt-1];
-  bool ccase    = args->checkcase;
-  unsigned char *bp = (unsigned char *)field_buffer(field,0);
-
-  if (kwds) {
-    while(cnt--)
-      {
-	if (Compare((unsigned char *)(*kwds--),bp,ccase)==EXACT) 
-	  break;
-      }
-    
-    if (cnt<=0)
-      kwds  = &args->kwds[args->count-1];
-    
-    if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
-      {
-	set_field_buffer(field,0,*kwds);
-	return TRUE;
-      }
-  }
+  int cnt = args->count;
+  char **kwds = &args->kwds[cnt - 1];
+  bool ccase = args->checkcase;
+  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+
+  if (kwds)
+    {
+      while (cnt--)
+	{
+	  if (Compare((unsigned char *)(*kwds--), bp, ccase) == EXACT)
+	    break;
+	}
+
+      if (cnt <= 0)
+	kwds = &args->kwds[args->count - 1];
+
+      if ((cnt >= 0) || (Compare((const unsigned char *)dummy, bp, ccase) == EXACT))
+	{
+	  set_field_buffer(field, 0, *kwds);
+	  return TRUE;
+	}
+    }
   return FALSE;
 }
 
-
-static FIELDTYPE typeENUM = {
+static FIELDTYPE typeENUM =
+{
   _HAS_ARGS | _HAS_CHOICE | _RESIDENT,
-  1,                           /* this is mutable, so we can't be const */
+  1,				/* this is mutable, so we can't be const */
   (FIELDTYPE *)0,
   (FIELDTYPE *)0,
   Make_Enum_Type,
@@ -290,6 +307,7 @@
   Previous_Enum
 };
 
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ENUM = &typeENUM;
+NCURSES_EXPORT_VAR(FIELDTYPE *)
+TYPE_ENUM = &typeENUM;
 
 /* fty_enum.c ends here */
diff -Naur ncurses-5.4.orig/form/fty_int.c ncurses-5.4/form/fty_int.c
--- ncurses-5.4.orig/form/fty_int.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/form/fty_int.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,4 +1,3 @@
-
 /*
  * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
  * You may freely copy it for use as a template for your own field types.
@@ -13,51 +12,61 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_int.c,v 1.13 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: fty_int.c,v 1.18 2005/04/16 18:20:00 tom Exp $")
 
-typedef struct {
-  int precision;
-  long low;
-  long high;
-} integerARG;
+#if USE_WIDEC_SUPPORT
+#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
+#else
+#define isDigit(c) isdigit(UChar(c))
+#endif
+
+typedef struct
+  {
+    int precision;
+    long low;
+    long high;
+  }
+thisARG;
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
-|   Function      :  static void *Make_Integer_Type( va_list * ap )
+|   Function      :  static void *Make_This_Type( va_list * ap )
 |   
 |   Description   :  Allocate structure for integer type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error
 +--------------------------------------------------------------------------*/
-static void *Make_Integer_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
 {
-  integerARG *argp = (integerARG *)malloc(sizeof(integerARG));
+  thisARG *argp = (thisARG *) malloc(sizeof(thisARG));
 
   if (argp)
     {
-      argp->precision = va_arg(*ap,int);
-      argp->low       = va_arg(*ap,long);
-      argp->high      = va_arg(*ap,long);
+      argp->precision = va_arg(*ap, int);
+      argp->low = va_arg(*ap, long);
+      argp->high = va_arg(*ap, long);
     }
   return (void *)argp;
 }
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
-|   Function      :  static void *Copy_Integer_Type(const void * argp)
+|   Function      :  static void *Copy_This_Type(const void * argp)
 |   
 |   Description   :  Copy structure for integer type argument.  
 |
 |   Return Values :  Pointer to argument structure or NULL on error.
 +--------------------------------------------------------------------------*/
-static void *Copy_Integer_Type(const void * argp)
+static void *
+Copy_This_Type(const void *argp)
 {
-  const integerARG *ap = (const integerARG *)argp;
-  integerARG *result = (integerARG *)0;
+  const thisARG *ap = (const thisARG *)argp;
+  thisARG *result = (thisARG *) 0;
 
   if (argp)
     {
-      result = (integerARG *)malloc(sizeof(integerARG));
+      result = (thisARG *) malloc(sizeof(thisARG));
       if (result)
 	*result = *ap;
     }
@@ -66,68 +75,115 @@
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
-|   Function      :  static void Free_Integer_Type(void * argp)
+|   Function      :  static void Free_This_Type(void * argp)
 |   
 |   Description   :  Free structure for integer type argument.
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Free_Integer_Type(void * argp)
+static void
+Free_This_Type(void *argp)
 {
-  if (argp) 
+  if (argp)
     free(argp);
 }
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
-|   Function      :  static bool Check_Integer_Field(
-|                                                    FIELD * field,
-|                                                    const void * argp)
+|   Function      :  static bool Check_This_Field(
+|                                                 FIELD * field,
+|                                                 const void * argp)
 |   
 |   Description   :  Validate buffer content to be a valid integer value
 |
 |   Return Values :  TRUE  - field is valid
 |                    FALSE - field is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_Integer_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
 {
-  const integerARG *argi = (const integerARG *)argp;
-  long low          = argi->low;
-  long high         = argi->high;
-  int prec          = argi->precision;
-  unsigned char *bp = (unsigned char *)field_buffer(field,0);
-  char *s           = (char *)bp;
+  const thisARG *argi = (const thisARG *)argp;
+  long low = argi->low;
+  long high = argi->high;
+  int prec = argi->precision;
+  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+  char *s = (char *)bp;
   long val;
   char buf[100];
+  bool result = FALSE;
 
-  while( *bp && *bp==' ') bp++;
+  while (*bp && *bp == ' ')
+    bp++;
   if (*bp)
     {
-      if (*bp=='-') bp++;
+      if (*bp == '-')
+	bp++;
+#if USE_WIDEC_SUPPORT
+      if (*bp)
+	{
+	  bool blank = FALSE;
+	  int len;
+	  int n;
+	  wchar_t *list = _nc_Widen_String((char *)bp, &len);
+
+	  if (list != 0)
+	    {
+	      result = TRUE;
+	      for (n = 0; n < len; ++n)
+		{
+		  if (blank)
+		    {
+		      if (list[n] != ' ')
+			{
+			  result = FALSE;
+			  break;
+			}
+		    }
+		  else if (list[n] == ' ')
+		    {
+		      blank = TRUE;
+		    }
+		  else if (!isDigit(list[n]))
+		    {
+		      result = FALSE;
+		      break;
+		    }
+		}
+	      free(list);
+	    }
+	}
+#else
       while (*bp)
 	{
-	  if (!isdigit(*bp)) break;
+	  if (!isdigit(UChar(*bp)))
+	    break;
 	  bp++;
 	}
-      while(*bp && *bp==' ') bp++;
-      if (*bp=='\0')
+      while (*bp && *bp == ' ')
+	bp++;
+      result = (*bp == '\0');
+#endif
+      if (result)
 	{
 	  val = atol(s);
-	  if (low<high)
+	  if (low < high)
 	    {
-	      if (val<low || val>high) return FALSE;
+	      if (val < low || val > high)
+		result = FALSE;
+	    }
+	  if (result)
+	    {
+	      sprintf(buf, "%.*ld", (prec > 0 ? prec : 0), val);
+	      set_field_buffer(field, 0, buf);
 	    }
-	  sprintf(buf,"%.*ld",(prec>0?prec:0),val);
-	  set_field_buffer(field,0,buf);
-	  return TRUE;
 	}
     }
-  return FALSE;
+  return (result);
 }
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
-|   Function      :  static bool Check_Integer_Character(
+|   Function      :  static bool Check_This_Character(
 |                                      int c,
 |                                      const void * argp)
 |   
@@ -136,25 +192,27 @@
 |   Return Values :  TRUE  - character is valid
 |                    FALSE - character is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_Integer_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
 {
-  return ((isdigit(c) || (c=='-')) ? TRUE : FALSE);
+  return ((isDigit(UChar(c)) || (c == '-')) ? TRUE : FALSE);
 }
 
-static FIELDTYPE typeINTEGER = {
+static FIELDTYPE typeTHIS =
+{
   _HAS_ARGS | _RESIDENT,
-  1,                           /* this is mutable, so we can't be const */
+  1,				/* this is mutable, so we can't be const */
   (FIELDTYPE *)0,
   (FIELDTYPE *)0,
-  Make_Integer_Type,
-  Copy_Integer_Type,
-  Free_Integer_Type,
-  Check_Integer_Field,
-  Check_Integer_Character,
+  Make_This_Type,
+  Copy_This_Type,
+  Free_This_Type,
+  Check_This_Field,
+  Check_This_Character,
   NULL,
   NULL
 };
 
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeINTEGER;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeTHIS;
 
 /* fty_int.c ends here */
diff -Naur ncurses-5.4.orig/form/fty_ipv4.c ncurses-5.4/form/fty_ipv4.c
--- ncurses-5.4.orig/form/fty_ipv4.c	2000-12-09 23:46:12.000000000 +0000
+++ ncurses-5.4/form/fty_ipv4.c	2005-05-13 04:09:50.000000000 +0000
@@ -13,7 +13,7 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_ipv4.c,v 1.4 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_ipv4.c,v 1.6 2004/05/29 19:13:48 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnform  
@@ -26,24 +26,25 @@
 |   Return Values :  TRUE  - field is valid
 |                    FALSE - field is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_IPV4_Field(FIELD * field, const void * argp GCC_UNUSED)
+static bool
+Check_IPV4_Field(FIELD *field, const void *argp GCC_UNUSED)
 {
-  char *bp = field_buffer(field,0);
+  char *bp = field_buffer(field, 0);
   int num = 0, len;
   unsigned int d1, d2, d3, d4;
 
-  if(isdigit((unsigned char)*bp)) /* Must start with digit */
+  if (isdigit(UChar(*bp)))	/* Must start with digit */
     {
       num = sscanf(bp, "%u.%u.%u.%u%n", &d1, &d2, &d3, &d4, &len);
       if (num == 4)
-        {
-          bp += len;            /* Make bp point to what sscanf() left */
-          while (*bp && isspace((unsigned char)*bp))
-            bp++;               /* Allow trailing whitespace */
-        }
+	{
+	  bp += len;		/* Make bp point to what sscanf() left */
+	  while (*bp && isspace(UChar(*bp)))
+	    bp++;		/* Allow trailing whitespace */
+	}
     }
   return ((num != 4 || *bp || d1 > 255 || d2 > 255
-                           || d3 > 255 || d4 > 255) ? FALSE : TRUE);
+	   || d3 > 255 || d4 > 255) ? FALSE : TRUE);
 }
 
 /*---------------------------------------------------------------------------
@@ -57,14 +58,16 @@
 |   Return Values :  TRUE  - character is valid
 |                    FALSE - character is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_IPV4_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_IPV4_Character(int c, const void *argp GCC_UNUSED)
 {
-  return ((isdigit(c) || (c=='.')) ? TRUE : FALSE);
+  return ((isdigit(UChar(c)) || (c == '.')) ? TRUE : FALSE);
 }
 
-static FIELDTYPE typeIPV4 = {
+static FIELDTYPE typeIPV4 =
+{
   _RESIDENT,
-  1,                           /* this is mutable, so we can't be const */
+  1,				/* this is mutable, so we can't be const */
   (FIELDTYPE *)0,
   (FIELDTYPE *)0,
   NULL,
diff -Naur ncurses-5.4.orig/form/fty_num.c ncurses-5.4/form/fty_num.c
--- ncurses-5.4.orig/form/fty_num.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/form/fty_num.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,4 +1,3 @@
-
 /*
  * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
  * You may freely copy it for use as a template for your own field types.
@@ -13,183 +12,251 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_num.c,v 1.16 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: fty_num.c,v 1.21 2005/04/16 18:21:10 tom Exp $")
 
 #if HAVE_LOCALE_H
 #include <locale.h>
 #endif
 
-typedef struct {
-  int    precision;
-  double low;
-  double high;
-  struct lconv* L;
-} numericARG;
+#if HAVE_LOCALE_H
+#define isDecimalPoint(c) ((c) == ((L && L->decimal_point) ? *(L->decimal_point) : '.'))
+#else
+#define isDecimalPoint(c) ((c) == '.')
+#endif
+
+#if USE_WIDEC_SUPPORT
+#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
+#else
+#define isDigit(c) isdigit(UChar(c))
+#endif
+
+typedef struct
+  {
+    int precision;
+    double low;
+    double high;
+    struct lconv *L;
+  }
+thisARG;
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static void *Make_Numeric_Type(va_list * ap)
-|   
+|   Facility      :  libnform
+|   Function      :  static void *Make_This_Type(va_list * ap)
+|
 |   Description   :  Allocate structure for numeric type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error
 +--------------------------------------------------------------------------*/
-static void *Make_Numeric_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
 {
-  numericARG *argn = (numericARG *)malloc(sizeof(numericARG));
+  thisARG *argn = (thisARG *) malloc(sizeof(thisARG));
 
   if (argn)
     {
-      argn->precision = va_arg(*ap,int);
-      argn->low       = va_arg(*ap,double);
-      argn->high      = va_arg(*ap,double);
+      argn->precision = va_arg(*ap, int);
+      argn->low = va_arg(*ap, double);
+      argn->high = va_arg(*ap, double);
+
 #if HAVE_LOCALE_H
-      argn->L         = localeconv();
+      argn->L = localeconv();
 #else
-      argn->L         = NULL;
+      argn->L = NULL;
 #endif
     }
   return (void *)argn;
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static void *Copy_Numeric_Type(const void * argp)
-|   
-|   Description   :  Copy structure for numeric type argument.  
+|   Facility      :  libnform
+|   Function      :  static void *Copy_This_Type(const void * argp)
+|
+|   Description   :  Copy structure for numeric type argument.
 |
 |   Return Values :  Pointer to argument structure or NULL on error.
 +--------------------------------------------------------------------------*/
-static void *Copy_Numeric_Type(const void * argp)
+static void *
+Copy_This_Type(const void *argp)
 {
-  const numericARG *ap = (const numericARG *)argp;
-  numericARG *result = (numericARG *)0;
+  const thisARG *ap = (const thisARG *)argp;
+  thisARG *result = (thisARG *) 0;
 
   if (argp)
     {
-      result = (numericARG *)malloc(sizeof(numericARG));
+      result = (thisARG *) malloc(sizeof(thisARG));
       if (result)
-	*result  = *ap;
+	*result = *ap;
     }
   return (void *)result;
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static void Free_Numeric_Type(void * argp)
-|   
+|   Facility      :  libnform
+|   Function      :  static void Free_This_Type(void * argp)
+|
 |   Description   :  Free structure for numeric type argument.
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Free_Numeric_Type(void * argp)
+static void
+Free_This_Type(void *argp)
 {
-  if (argp) 
+  if (argp)
     free(argp);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static bool Check_Numeric_Field(FIELD * field,
-|                                                    const void * argp)
-|   
+|   Facility      :  libnform
+|   Function      :  static bool Check_This_Field(FIELD * field,
+|                                                 const void * argp)
+|
 |   Description   :  Validate buffer content to be a valid numeric value
 |
 |   Return Values :  TRUE  - field is valid
 |                    FALSE - field is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_Numeric_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
 {
-  const numericARG *argn = (const numericARG *)argp;
-  double low          = argn->low;
-  double high         = argn->high;
-  int prec            = argn->precision;
-  unsigned char *bp   = (unsigned char *)field_buffer(field,0);
-  char *s             = (char *)bp;
-  double val          = 0.0;
-  struct lconv* L     = argn->L;
+  const thisARG *argn = (const thisARG *)argp;
+  double low = argn->low;
+  double high = argn->high;
+  int prec = argn->precision;
+  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+  char *s = (char *)bp;
+  double val = 0.0;
+  struct lconv *L = argn->L;
   char buf[64];
+  bool result = FALSE;
 
-  while(*bp && *bp==' ') bp++;
+  while (*bp && *bp == ' ')
+    bp++;
   if (*bp)
     {
-      if (*bp=='-' || *bp=='+')
+      if (*bp == '-' || *bp == '+')
 	bp++;
-      while(*bp)
+#if USE_WIDEC_SUPPORT
+      if (*bp)
 	{
-	  if (!isdigit(*bp)) break;
+	  bool blank = FALSE;
+	  int state = 0;
+	  int len;
+	  int n;
+	  wchar_t *list = _nc_Widen_String((char *)bp, &len);
+
+	  if (list != 0)
+	    {
+	      result = TRUE;
+	      for (n = 0; n < len; ++n)
+		{
+		  if (blank)
+		    {
+		      if (list[n] != ' ')
+			{
+			  result = FALSE;
+			  break;
+			}
+		    }
+		  else if (list[n] == ' ')
+		    {
+		      blank = TRUE;
+		    }
+		  else if (isDecimalPoint(list[n]))
+		    {
+		      if (++state > 1)
+			{
+			  result = FALSE;
+			  break;
+			}
+		    }
+		  else if (!isDigit(list[n]))
+		    {
+		      result = FALSE;
+		      break;
+		    }
+		}
+	      free(list);
+	    }
+	}
+#else
+      while (*bp)
+	{
+	  if (!isdigit(UChar(*bp)))
+	    break;
 	  bp++;
 	}
-      if (*bp==(
-#if HAVE_LOCALE_H
-		(L && L->decimal_point) ? *(L->decimal_point) :
-#endif
-		'.'))
+      if (isDecimalPoint(*bp))
 	{
 	  bp++;
-	  while(*bp)
+	  while (*bp)
 	    {
-	      if (!isdigit(*bp)) break;
+	      if (!isdigit(UChar(*bp)))
+		break;
 	      bp++;
 	    }
 	}
-      while(*bp && *bp==' ') bp++;
-      if (*bp=='\0')
+      while (*bp && *bp == ' ')
+	bp++;
+      result = (*bp == '\0');
+#endif
+      if (result)
 	{
 	  val = atof(s);
-	  if (low<high)
+	  if (low < high)
+	    {
+	      if (val < low || val > high)
+		result = FALSE;
+	    }
+	  if (result)
 	    {
-	      if (val<low || val>high) return FALSE;
+	      sprintf(buf, "%.*f", (prec > 0 ? prec : 0), val);
+	      set_field_buffer(field, 0, buf);
 	    }
-	  sprintf(buf,"%.*f",(prec>0?prec:0),val);
-	  set_field_buffer(field,0,buf);
-	  return TRUE;
 	}
     }
-  return FALSE;
+  return (result);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnform  
-|   Function      :  static bool Check_Numeric_Character(
+|   Facility      :  libnform
+|   Function      :  static bool Check_This_Character(
 |                                      int c,
 |                                      const void * argp)
-|   
+|
 |   Description   :  Check a character for the numeric type.
 |
 |   Return Values :  TRUE  - character is valid
 |                    FALSE - character is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_Numeric_Character(int c, const void * argp)
+static bool
+Check_This_Character(int c, const void *argp)
 {
-  const numericARG *argn = (const numericARG *)argp;
-  struct lconv* L  = argn->L;  
+  const thisARG *argn = (const thisARG *)argp;
+  struct lconv *L = argn->L;
 
-  return (isdigit(c)  || 
-	  c == '+'    || 
-	  c == '-'    || 
-	  c == (
-#if HAVE_LOCALE_H
-		(L && L->decimal_point) ? *(L->decimal_point) :
-#endif
-		'.')
-	  ) ? TRUE : FALSE;
+  return ((isDigit(c) ||
+	   c == '+' ||
+	   c == '-' ||
+	   isDecimalPoint(c))
+	  ? TRUE
+	  : FALSE);
 }
 
-static FIELDTYPE typeNUMERIC = {
+static FIELDTYPE typeTHIS =
+{
   _HAS_ARGS | _RESIDENT,
-  1,                           /* this is mutable, so we can't be const */
+  1,				/* this is mutable, so we can't be const */
   (FIELDTYPE *)0,
   (FIELDTYPE *)0,
-  Make_Numeric_Type,
-  Copy_Numeric_Type,
-  Free_Numeric_Type,
-  Check_Numeric_Field,
-  Check_Numeric_Character,
+  Make_This_Type,
+  Copy_This_Type,
+  Free_This_Type,
+  Check_This_Field,
+  Check_This_Character,
   NULL,
   NULL
 };
 
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeNUMERIC;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeTHIS;
 
 /* fty_num.c ends here */
diff -Naur ncurses-5.4.orig/form/fty_regex.c ncurses-5.4/form/fty_regex.c
--- ncurses-5.4.orig/form/fty_regex.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/form/fty_regex.c	2005-05-13 04:09:50.000000000 +0000
@@ -13,31 +13,34 @@
 
 #include "form.priv.h"
 
-MODULE_ID("$Id: fty_regex.c,v 1.17 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: fty_regex.c,v 1.18 2004/05/29 19:19:09 tom Exp $")
 
-#if HAVE_REGEX_H_FUNCS	/* We prefer POSIX regex */
+#if HAVE_REGEX_H_FUNCS		/* We prefer POSIX regex */
 #include <regex.h>
 
 typedef struct
-{
-  regex_t *pRegExp;
-  unsigned long *refCount;
-} RegExp_Arg;
+  {
+    regex_t *pRegExp;
+    unsigned long *refCount;
+  }
+RegExp_Arg;
 
 #elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
 #undef RETURN
 static int reg_errno;
 
-static char *RegEx_Init(char *instring)
+static char *
+RegEx_Init(char *instring)
 {
-	reg_errno = 0;
-	return instring;
+  reg_errno = 0;
+  return instring;
 }
 
-static char *RegEx_Error(int code)
+static char *
+RegEx_Error(int code)
 {
-	reg_errno = code;
-	return 0;
+  reg_errno = code;
+  return 0;
 }
 
 #define INIT 		register char *sp = RegEx_Init(instring);
@@ -57,7 +60,8 @@
 {
   char *compiled_expression;
   unsigned long *refCount;
-} RegExp_Arg;
+}
+RegExp_Arg;
 
 /* Maximum Length we allow for a compiled regular expression */
 #define MAX_RX_LEN   (2048)
@@ -73,20 +77,23 @@
 |
 |   Return Values :  Pointer to argument structure or NULL on error
 +--------------------------------------------------------------------------*/
-static void *Make_RegularExpression_Type(va_list * ap)
+static void *
+Make_RegularExpression_Type(va_list *ap)
 {
 #if HAVE_REGEX_H_FUNCS
-  char *rx = va_arg(*ap,char *);
+  char *rx = va_arg(*ap, char *);
   RegExp_Arg *preg;
 
-  preg = (RegExp_Arg*)malloc(sizeof(RegExp_Arg));
+  preg = (RegExp_Arg *)malloc(sizeof(RegExp_Arg));
+
   if (preg)
     {
-      if (((preg->pRegExp = (regex_t*)malloc(sizeof(regex_t))) != (regex_t*)0)
-       && !regcomp(preg->pRegExp,rx,
-		   (REG_EXTENDED | REG_NOSUB | REG_NEWLINE) ))
+      if (((preg->pRegExp = (regex_t *) malloc(sizeof(regex_t))) != 0)
+	  && !regcomp(preg->pRegExp, rx,
+		      (REG_EXTENDED | REG_NOSUB | REG_NEWLINE)))
 	{
 	  preg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
+
 	  *(preg->refCount) = 1;
 	}
       else
@@ -94,12 +101,12 @@
 	  if (preg->pRegExp)
 	    free(preg->pRegExp);
 	  free(preg);
-	  preg = (RegExp_Arg*)0;
+	  preg = (RegExp_Arg *)0;
 	}
     }
-  return((void *)preg);
+  return ((void *)preg);
 #elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
-  char *rx = va_arg(*ap,char *);
+  char *rx = va_arg(*ap, char *);
   RegExp_Arg *pArg;
 
   pArg = (RegExp_Arg *)malloc(sizeof(RegExp_Arg));
@@ -107,38 +114,44 @@
   if (pArg)
     {
       int blen = RX_INCREMENT;
+
       pArg->compiled_expression = NULL;
       pArg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
+
       *(pArg->refCount) = 1;
 
-      do {
-	char *buf = (char *)malloc(blen);
-	if (buf)
-	  {
+      do
+	{
+	  char *buf = (char *)malloc(blen);
+
+	  if (buf)
+	    {
 #if HAVE_REGEXP_H_FUNCS
-	    char *last_pos = compile (rx, buf, &buf[blen], '\0');
+	      char *last_pos = compile(rx, buf, &buf[blen], '\0');
+
 #else /* HAVE_REGEXPR_H_FUNCS */
-	    char *last_pos = compile (rx, buf, &buf[blen]);
+	      char *last_pos = compile(rx, buf, &buf[blen]);
 #endif
-	    if (reg_errno)
-	      {
-		free(buf);
-		if (reg_errno==50)
-		  blen += RX_INCREMENT;
-		else
-		  {
-		    free(pArg);
-		    pArg = NULL;
-		    break;
-		  }
-	      }
-	    else
-	      {
-		pArg->compiled_expression = buf;
-		break;
-	      }
-	  }
-      } while( blen <= MAX_RX_LEN );
+	      if (reg_errno)
+		{
+		  free(buf);
+		  if (reg_errno == 50)
+		    blen += RX_INCREMENT;
+		  else
+		    {
+		      free(pArg);
+		      pArg = NULL;
+		      break;
+		    }
+		}
+	      else
+		{
+		  pArg->compiled_expression = buf;
+		  break;
+		}
+	    }
+	}
+      while (blen <= MAX_RX_LEN);
     }
   if (pArg && !pArg->compiled_expression)
     {
@@ -160,7 +173,8 @@
 |
 |   Return Values :  Pointer to argument structure or NULL on error.
 +--------------------------------------------------------------------------*/
-static void *Copy_RegularExpression_Type(const void * argp)
+static void *
+Copy_RegularExpression_Type(const void *argp)
 {
 #if (HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS)
   const RegExp_Arg *ap = (const RegExp_Arg *)argp;
@@ -185,10 +199,12 @@
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-static void Free_RegularExpression_Type(void * argp)
+static void
+Free_RegularExpression_Type(void *argp)
 {
 #if HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
   RegExp_Arg *ap = (RegExp_Arg *)argp;
+
   if (ap)
     {
       if (--(*(ap->refCount)) == 0)
@@ -223,24 +239,33 @@
 |   Return Values :  TRUE  - field is valid
 |                    FALSE - field is invalid
 +--------------------------------------------------------------------------*/
-static bool Check_RegularExpression_Field(FIELD * field, const void  * argp)
+static bool
+Check_RegularExpression_Field(FIELD *field, const void *argp)
 {
   bool match = FALSE;
+
 #if HAVE_REGEX_H_FUNCS
-  const RegExp_Arg *ap = (const RegExp_Arg*)argp;
+  const RegExp_Arg *ap = (const RegExp_Arg *)argp;
+
   if (ap && ap->pRegExp)
-    match = (regexec(ap->pRegExp,field_buffer(field,0),0,NULL,0) ? FALSE:TRUE);
+    match = (regexec(ap->pRegExp, field_buffer(field, 0), 0, NULL, 0)
+	     ? FALSE
+	     : TRUE);
 #elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
   RegExp_Arg *ap = (RegExp_Arg *)argp;
+
   if (ap && ap->compiled_expression)
-    match = (step(field_buffer(field,0),ap->compiled_expression) ? TRUE:FALSE);
+    match = (step(field_buffer(field, 0), ap->compiled_expression)
+	     ? TRUE
+	     : FALSE);
 #endif
   return match;
 }
 
-static FIELDTYPE typeREGEXP = {
+static FIELDTYPE typeREGEXP =
+{
   _HAS_ARGS | _RESIDENT,
-  1,                           /* this is mutable, so we can't be const */
+  1,				/* this is mutable, so we can't be const */
   (FIELDTYPE *)0,
   (FIELDTYPE *)0,
   Make_RegularExpression_Type,
diff -Naur ncurses-5.4.orig/form/llib-lform ncurses-5.4/form/llib-lform
--- ncurses-5.4.orig/form/llib-lform	2002-08-31 19:59:34.000000000 +0000
+++ ncurses-5.4/form/llib-lform	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2002 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2002,2005 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            *
@@ -27,14 +27,41 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,2002              *
+ *  Author: Thomas E. Dickey       1996,1997,2002,2005                      *
  ****************************************************************************/
 /* LINTLIBRARY */
 
-/* ./fld_arg.c */
+/* ./f_trace.c */
 
 #include "form.priv.h"
 
+#undef _nc_retrace_field_ptr
+FIELD	**_nc_retrace_field_ptr(
+		FIELD	**code)
+		{ return(*(FIELD ***)0); }
+
+#undef _nc_retrace_field
+FIELD	*_nc_retrace_field(
+		FIELD	*code)
+		{ return(*(FIELD **)0); }
+
+#undef _nc_retrace_field_type
+FIELDTYPE *_nc_retrace_field_type(
+		FIELDTYPE *code)
+		{ return(*(FIELDTYPE **)0); }
+
+#undef _nc_retrace_form
+FORM	*_nc_retrace_form(
+		FORM	*code)
+		{ return(*(FORM **)0); }
+
+#undef _nc_retrace_form_hook
+Form_Hook _nc_retrace_form_hook(
+		Form_Hook code)
+		{ return(*(Form_Hook *)0); }
+
+/* ./fld_arg.c */
+
 #undef set_fieldtype_arg
 int	set_fieldtype_arg(
 		FIELDTYPE *typ, 
@@ -441,10 +468,12 @@
 		FIELD	*field)
 		{ return(*(int *)0); }
 
-typedef struct {
-  int keycode;           
-  int (*cmd)(FORM *);    
-} Binding_Info;
+typedef struct
+{
+  int keycode; 
+  int (*cmd) (FORM *); 
+}
+Binding_Info;
 
 #undef form_driver
 int	form_driver(
@@ -623,41 +652,49 @@
 
 /* ./fty_alnum.c */
 
-typedef struct {
-  int width;
-} alnumARG;
+typedef struct
+  {
+    int width;
+  }
+alnumARG;
 
 #undef TYPE_ALNUM
 FIELDTYPE *TYPE_ALNUM;
 
 /* ./fty_alpha.c */
 
-typedef struct {
-  int width;
-} alphaARG;
+typedef struct
+  {
+    int width;
+  }
+alphaARG;
 
 #undef TYPE_ALPHA
 FIELDTYPE *TYPE_ALPHA;
 
 /* ./fty_enum.c */
 
-typedef struct {
-  char **kwds;
-  int  count;
-  NCURSES_BOOL  checkcase;
-  NCURSES_BOOL  checkunique;
-} enumARG;
+typedef struct
+  {
+    char **kwds;
+    int count;
+    NCURSES_BOOL checkcase;
+    NCURSES_BOOL checkunique;
+  }
+enumARG;
 
 #undef TYPE_ENUM
 FIELDTYPE *TYPE_ENUM;
 
 /* ./fty_int.c */
 
-typedef struct {
-  int precision;
-  long low;
-  long high;
-} integerARG;
+typedef struct
+  {
+    int precision;
+    long low;
+    long high;
+  }
+integerARG;
 
 #undef TYPE_INTEGER
 FIELDTYPE *TYPE_INTEGER;
@@ -670,12 +707,14 @@
 
 #include <locale.h>
 
-typedef struct {
-  int    precision;
-  double low;
-  double high;
-  struct lconv* L;
-} numericARG;
+typedef struct
+  {
+    int precision;
+    double low;
+    double high;
+    struct lconv *L;
+  }
+numericARG;
 
 #undef TYPE_NUMERIC
 FIELDTYPE *TYPE_NUMERIC;
@@ -685,10 +724,11 @@
 #include <regex.h>
 
 typedef struct
-{
-  regex_t *pRegExp;
-  unsigned long *refCount;
-} RegExp_Arg;
+  {
+    regex_t *pRegExp;
+    unsigned long *refCount;
+  }
+RegExp_Arg;
 
 #undef TYPE_REGEXP
 FIELDTYPE *TYPE_REGEXP;
diff -Naur ncurses-5.4.orig/form/llib-lformw ncurses-5.4/form/llib-lformw
--- ncurses-5.4.orig/form/llib-lformw	2002-08-31 21:53:19.000000000 +0000
+++ ncurses-5.4/form/llib-lformw	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2002,2005 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            *
@@ -27,14 +27,41 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 2002                        *
+ *  Author: Thomas E. Dickey                    2002,2005                   *
  ****************************************************************************/
 /* LINTLIBRARY */
 
-/* ./fld_arg.c */
+/* ./f_trace.c */
 
 #include "form.priv.h"
 
+#undef _nc_retrace_field_ptr
+FIELD	**_nc_retrace_field_ptr(
+		FIELD	**code)
+		{ return(*(FIELD ***)0); }
+
+#undef _nc_retrace_field
+FIELD	*_nc_retrace_field(
+		FIELD	*code)
+		{ return(*(FIELD **)0); }
+
+#undef _nc_retrace_field_type
+FIELDTYPE *_nc_retrace_field_type(
+		FIELDTYPE *code)
+		{ return(*(FIELDTYPE **)0); }
+
+#undef _nc_retrace_form
+FORM	*_nc_retrace_form(
+		FORM	*code)
+		{ return(*(FORM **)0); }
+
+#undef _nc_retrace_form_hook
+Form_Hook _nc_retrace_form_hook(
+		Form_Hook code)
+		{ return(*(Form_Hook *)0); }
+
+/* ./fld_arg.c */
+
 #undef set_fieldtype_arg
 int	set_fieldtype_arg(
 		FIELDTYPE *typ, 
@@ -441,10 +468,12 @@
 		FIELD	*field)
 		{ return(*(int *)0); }
 
-typedef struct {
-  int keycode;           
-  int (*cmd)(FORM *);    
-} Binding_Info;
+typedef struct
+{
+  int keycode; 
+  int (*cmd) (FORM *); 
+}
+Binding_Info;
 
 #undef form_driver
 int	form_driver(
@@ -465,6 +494,12 @@
 		int	buffer)
 		{ return(*(char **)0); }
 
+#undef _nc_Widen_String
+wchar_t	*_nc_Widen_String(
+		char	*source, 
+		int	*lengthp)
+		{ return(*(wchar_t **)0); }
+
 /* ./frm_hook.c */
 
 #undef set_field_init
@@ -623,41 +658,49 @@
 
 /* ./fty_alnum.c */
 
-typedef struct {
-  int width;
-} alnumARG;
+typedef struct
+  {
+    int width;
+  }
+alnumARG;
 
 #undef TYPE_ALNUM
 FIELDTYPE *TYPE_ALNUM;
 
 /* ./fty_alpha.c */
 
-typedef struct {
-  int width;
-} alphaARG;
+typedef struct
+  {
+    int width;
+  }
+alphaARG;
 
 #undef TYPE_ALPHA
 FIELDTYPE *TYPE_ALPHA;
 
 /* ./fty_enum.c */
 
-typedef struct {
-  char **kwds;
-  int  count;
-  NCURSES_BOOL  checkcase;
-  NCURSES_BOOL  checkunique;
-} enumARG;
+typedef struct
+  {
+    char **kwds;
+    int count;
+    NCURSES_BOOL checkcase;
+    NCURSES_BOOL checkunique;
+  }
+enumARG;
 
 #undef TYPE_ENUM
 FIELDTYPE *TYPE_ENUM;
 
 /* ./fty_int.c */
 
-typedef struct {
-  int precision;
-  long low;
-  long high;
-} integerARG;
+typedef struct
+  {
+    int precision;
+    long low;
+    long high;
+  }
+integerARG;
 
 #undef TYPE_INTEGER
 FIELDTYPE *TYPE_INTEGER;
@@ -668,12 +711,16 @@
 
 /* ./fty_num.c */
 
-typedef struct {
-  int    precision;
-  double low;
-  double high;
-  struct lconv* L;
-} numericARG;
+#include <locale.h>
+
+typedef struct
+  {
+    int precision;
+    double low;
+    double high;
+    struct lconv *L;
+  }
+numericARG;
 
 #undef TYPE_NUMERIC
 FIELDTYPE *TYPE_NUMERIC;
@@ -683,10 +730,11 @@
 #include <regex.h>
 
 typedef struct
-{
-  regex_t *pRegExp;
-  unsigned long *refCount;
-} RegExp_Arg;
+  {
+    regex_t *pRegExp;
+    unsigned long *refCount;
+  }
+RegExp_Arg;
 
 #undef TYPE_REGEXP
 FIELDTYPE *TYPE_REGEXP;
diff -Naur ncurses-5.4.orig/form/modules ncurses-5.4/form/modules
--- ncurses-5.4.orig/form/modules	1999-02-19 00:27:47.000000000 +0000
+++ ncurses-5.4/form/modules	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: modules,v 1.13 1999/02/19 00:27:47 juergen Exp $
+# $Id: modules,v 1.14 2004/12/25 23:29:22 tom Exp $
 ##############################################################################
-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
+# Copyright (c) 1998,2004 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"), #
@@ -27,11 +27,12 @@
 # authorization.                                                             #
 ##############################################################################
 #
-# Author: Thomas E. Dickey <dickey@clark.net> 1996,1997
+# Author: Thomas E. Dickey
 #
 
 @ base
 # Library objects
+f_trace		lib		$(srcdir)	$(FORM_PRIV_H)
 fld_arg		lib		$(srcdir)	$(FORM_PRIV_H)
 fld_attr	lib		$(srcdir)	$(FORM_PRIV_H)
 fld_current	lib		$(srcdir)	$(FORM_PRIV_H)
diff -Naur ncurses-5.4.orig/include/curses.h.in ncurses-5.4/include/curses.h.in
--- ncurses-5.4.orig/include/curses.h.in	2004-01-14 23:50:12.000000000 +0000
+++ ncurses-5.4/include/curses.h.in	2005-05-13 04:09:54.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,10 +29,10 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Thomas E. Dickey 1996-on                                        *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
-/* $Id: curses.h.in,v 1.148 2004/01/14 23:50:12 tom Exp $ */
+/* $Id: curses.h.in,v 1.155 2005/04/02 15:29:44 tom Exp $ */
 
 #ifndef __NCURSES_H
 #define __NCURSES_H
@@ -55,9 +55,24 @@
 #undef  NCURSES_VERSION
 #define NCURSES_VERSION "@NCURSES_MAJOR@.@NCURSES_MINOR@"
 
+/*
+ * Identify the mouse encoding version.
+ */
+#define NCURSES_MOUSE_VERSION @NCURSES_MOUSE_VERSION@
+
+/*
+ * Definitions to facilitate DLL's.
+ */
 #include <ncurses_dll.h>
 
 /*
+ * User-definable tweak to disable the include of <stdbool.h>.
+ */
+#ifndef NCURSES_ENABLE_STDBOOL_H
+#define NCURSES_ENABLE_STDBOOL_H @cf_cv_header_stdbool_h@
+#endif
+
+/*
  * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
  * configured using --disable-macros.
  */
@@ -96,7 +111,13 @@
 #undef	NCURSES_CH_T
 #define NCURSES_CH_T @NCURSES_CH_T@
 
+#if @cf_cv_enable_lp64@ && defined(_LP64)
+typedef unsigned chtype;
+typedef unsigned mmask_t;
+#else
 typedef unsigned @cf_cv_typeof_chtype@ chtype;
+typedef unsigned long mmask_t;
+#endif
 
 #include <stdio.h>
 #include <unctrl.h>
@@ -132,7 +153,7 @@
 
 #else			/* c89, c99, etc. */
 
-#if @cf_cv_header_stdbool_h@
+#if NCURSES_ENABLE_STDBOOL_H
 #include <stdbool.h>
 /* use whatever the C compiler decides bool really is */
 #define NCURSES_BOOL bool
@@ -146,6 +167,9 @@
 
 #ifdef __cplusplus
 extern "C" {
+#define NCURSES_CAST(type,value) static_cast<type>(value)
+#else
+#define NCURSES_CAST(type,value) (type)(value)
 #endif
 
 /*
@@ -192,7 +216,7 @@
 extern NCURSES_EXPORT_VAR(chtype) acs_map[];
 #endif
 
-#define NCURSES_ACS(c)	(acs_map[(unsigned char)c])
+#define NCURSES_ACS(c)	(acs_map[NCURSES_CAST(unsigned char,c)])
 
 /* VT100 symbols begin here */
 #define ACS_ULCORNER	NCURSES_ACS('l') /* upper left corner */
@@ -310,6 +334,9 @@
 {
     attr_t	attr;
     wchar_t	chars[CCHARW_MAX];
+#if @NCURSES_EXT_COLORS@
+    int		ext_color;	/* color pair, must be more than 16-bits */
+#endif
 }
 cchar_t;
 
@@ -366,6 +393,9 @@
 
 #ifdef _XOPEN_SOURCE_EXTENDED
 	cchar_t  _bkgrnd;	/* current background char/attribute pair */
+#if @NCURSES_EXT_COLORS@
+	int	_color;		/* current color-pair for non-space character */
+#endif
 #endif
 };
 
@@ -808,8 +838,11 @@
 #define A_TOP		NCURSES_BITS(@cf_cv_1UL@,21)
 #define A_VERTICAL	NCURSES_BITS(@cf_cv_1UL@,22)
 
+/*
+ * These apply to the first 256 color pairs.
+ */
 #define COLOR_PAIR(n)	NCURSES_BITS(n, 0)
-#define PAIR_NUMBER(a)	((int)(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT))
+#define PAIR_NUMBER(a)	(NCURSES_CAST(int,(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
 
 /*
  * pseudo functions
@@ -851,11 +884,16 @@
 
 #define wstandout(win)      	(wattrset(win,A_STANDOUT))
 #define wstandend(win)      	(wattrset(win,A_NORMAL))
-#define wattr_set(win,a,p,opts) ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
 
-#define wattron(win,at)		wattr_on(win, (attr_t) at, (void *)0)
-#define wattroff(win,at)	wattr_off(win, (attr_t) at, (void *)0)
+#define wattron(win,at)		wattr_on(win, NCURSES_CAST(attr_t, at), NULL)
+#define wattroff(win,at)	wattr_off(win, NCURSES_CAST(attr_t, at), NULL)
+
+#if @NCURSES_EXT_COLORS@
+#define wattrset(win,at)	((win)->_color = PAIR_NUMBER(at), \
+				 (win)->_attrs = (at))
+#else
 #define wattrset(win,at)	((win)->_attrs = (at))
+#endif
 
 #define scroll(win)		wscrl(win,1)
 
@@ -940,7 +978,7 @@
 #define mvwgetnstr(win,y,x,str,n)	(wmove(win,y,x) == ERR ? ERR : wgetnstr(win,str,n))
 #define mvwgetstr(win,y,x,str)		(wmove(win,y,x) == ERR ? ERR : wgetstr(win,str))
 #define mvwhline(win,y,x,c,n)		(wmove(win,y,x) == ERR ? ERR : whline(win,c,n))
-#define mvwinch(win,y,x)		(wmove(win,y,x) == ERR ? (chtype)ERR : winch(win))
+#define mvwinch(win,y,x)		(wmove(win,y,x) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win))
 #define mvwinchnstr(win,y,x,s,n)	(wmove(win,y,x) == ERR ? ERR : winchnstr(win,s,n))
 #define mvwinchstr(win,y,x,s)		(wmove(win,y,x) == ERR ? ERR : winchstr(win,s))
 #define mvwinnstr(win,y,x,s,n)		(wmove(win,y,x) == ERR ? ERR : winnstr(win,s,n))
@@ -972,16 +1010,26 @@
 #define mvvline(y,x,c,n)		mvwvline(stdscr,y,x,c,n)
 
 /*
- * Some wide-character functions do not depend on the extensions.
+ * Some wide-character functions can be implemented without the extensions.
  */
 #define getbkgd(win)                    ((win)->_bkgd)
 
 #define slk_attr_off(a,v)		((v) ? ERR : slk_attroff(a))
 #define slk_attr_on(a,v)		((v) ? ERR : slk_attron(a))
 
+#if @NCURSES_EXT_COLORS@
+#define wattr_set(win,a,p,opts)		((win)->_attrs = ((a) & ~A_COLOR), \
+					 (win)->_color = (p), \
+					 OK)
+#define wattr_get(win,a,p,opts)		((void)((a) != 0 && (*(a) = (win)->_attrs)), \
+					 (void)((p) != 0 && (*(p) = (win)->_color)), \
+					 OK)
+#else
+#define wattr_set(win,a,p,opts)		((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
 #define wattr_get(win,a,p,opts)		((void)((a) != 0 && (*(a) = (win)->_attrs)), \
 					 (void)((p) != 0 && (*(p) = PAIR_NUMBER((win)->_attrs))), \
 					 OK)
+#endif
 
 /*
  * XSI curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
diff -Naur ncurses-5.4.orig/include/curses.tail ncurses-5.4/include/curses.tail
--- ncurses-5.4.orig/include/curses.tail	2002-11-02 20:26:26.000000000 +0000
+++ ncurses-5.4/include/curses.tail	2005-05-13 04:09:52.000000000 +0000
@@ -1,38 +1,77 @@
-/* $Id: curses.tail,v 1.8 2002/11/02 20:26:26 tom Exp $ */
+/* $Id: curses.tail,v 1.12 2005/03/27 00:09:51 tom Exp $ */
 
 /* mouse interface */
-#define NCURSES_MOUSE_VERSION	1
+
+#if NCURSES_MOUSE_VERSION > 1
+#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5))
+#else
+#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6))
+#endif
+
+#define	NCURSES_BUTTON_RELEASED	001L
+#define	NCURSES_BUTTON_PRESSED	002L
+#define	NCURSES_BUTTON_CLICKED	004L
+#define	NCURSES_DOUBLE_CLICKED	010L
+#define	NCURSES_TRIPLE_CLICKED	020L
+#define	NCURSES_RESERVED_EVENT	040L
 
 /* event masks */
-#define	BUTTON1_RELEASED	000000000001L
-#define	BUTTON1_PRESSED		000000000002L
-#define	BUTTON1_CLICKED		000000000004L
-#define	BUTTON1_DOUBLE_CLICKED	000000000010L
-#define	BUTTON1_TRIPLE_CLICKED	000000000020L
-#define BUTTON1_RESERVED_EVENT	000000000040L
-#define	BUTTON2_RELEASED	000000000100L
-#define	BUTTON2_PRESSED		000000000200L
-#define	BUTTON2_CLICKED		000000000400L
-#define	BUTTON2_DOUBLE_CLICKED	000000001000L
-#define	BUTTON2_TRIPLE_CLICKED	000000002000L
-#define BUTTON2_RESERVED_EVENT	000000004000L
-#define	BUTTON3_RELEASED	000000010000L
-#define	BUTTON3_PRESSED		000000020000L
-#define	BUTTON3_CLICKED		000000040000L
-#define	BUTTON3_DOUBLE_CLICKED	000000100000L
-#define	BUTTON3_TRIPLE_CLICKED	000000200000L
-#define BUTTON3_RESERVED_EVENT	000000400000L
-#define	BUTTON4_RELEASED	000001000000L
-#define	BUTTON4_PRESSED		000002000000L
-#define	BUTTON4_CLICKED		000004000000L
-#define	BUTTON4_DOUBLE_CLICKED	000010000000L
-#define	BUTTON4_TRIPLE_CLICKED	000020000000L
-#define BUTTON4_RESERVED_EVENT	000040000000L
-#define BUTTON_CTRL		000100000000L
-#define BUTTON_SHIFT		000200000000L
-#define BUTTON_ALT		000400000000L
-#define	ALL_MOUSE_EVENTS	000777777777L
-#define	REPORT_MOUSE_POSITION	001000000000L
+#define	BUTTON1_RELEASED	NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
+#define	BUTTON1_PRESSED		NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)
+#define	BUTTON1_CLICKED		NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED)
+#define	BUTTON1_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)
+#define	BUTTON1_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)
+
+#define	BUTTON2_RELEASED	NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED)
+#define	BUTTON2_PRESSED		NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED)
+#define	BUTTON2_CLICKED		NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED)
+#define	BUTTON2_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED)
+#define	BUTTON2_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED)
+
+#define	BUTTON3_RELEASED	NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED)
+#define	BUTTON3_PRESSED		NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED)
+#define	BUTTON3_CLICKED		NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED)
+#define	BUTTON3_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED)
+#define	BUTTON3_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED)
+
+#define	BUTTON4_RELEASED	NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED)
+#define	BUTTON4_PRESSED		NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED)
+#define	BUTTON4_CLICKED		NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED)
+#define	BUTTON4_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED)
+#define	BUTTON4_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED)
+
+/*
+ * In 32 bits the version-1 scheme does not provide enough space for a 5th
+ * button, unless we choose to change the ABI by omitting the reserved-events.
+ */
+#if NCURSES_MOUSE_VERSION > 1
+
+#define	BUTTON5_RELEASED	NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED)
+#define	BUTTON5_PRESSED		NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED)
+#define	BUTTON5_CLICKED		NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED)
+#define	BUTTON5_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED)
+#define	BUTTON5_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED)
+
+#define	BUTTON_CTRL		NCURSES_MOUSE_MASK(6, 0001L)
+#define	BUTTON_SHIFT		NCURSES_MOUSE_MASK(6, 0002L)
+#define	BUTTON_ALT		NCURSES_MOUSE_MASK(6, 0004L)
+#define	REPORT_MOUSE_POSITION	NCURSES_MOUSE_MASK(6, 0010L)
+
+#else
+
+#define	BUTTON1_RESERVED_EVENT	NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT)
+#define	BUTTON2_RESERVED_EVENT	NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT)
+#define	BUTTON3_RESERVED_EVENT	NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT)
+#define	BUTTON4_RESERVED_EVENT	NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT)
+
+#define	BUTTON_CTRL		NCURSES_MOUSE_MASK(5, 0001L)
+#define	BUTTON_SHIFT		NCURSES_MOUSE_MASK(5, 0002L)
+#define	BUTTON_ALT		NCURSES_MOUSE_MASK(5, 0004L)
+#define	REPORT_MOUSE_POSITION	NCURSES_MOUSE_MASK(5, 0010L)
+
+#endif
+
+#define	ALL_MOUSE_EVENTS	(REPORT_MOUSE_POSITION - 1)
 
 /* macros to extract single event-bits from masks */
 #define	BUTTON_RELEASE(e, x)		((e) & (001 << (6 * ((x) - 1))))
@@ -42,8 +81,6 @@
 #define	BUTTON_TRIPLE_CLICK(e, x)	((e) & (020 << (6 * ((x) - 1))))
 #define	BUTTON_RESERVED_EVENT(e, x)	((e) & (040 << (6 * ((x) - 1))))
 
-typedef unsigned long mmask_t;
-
 typedef struct
 {
     short id;		/* ID to distinguish multiple devices */
@@ -57,7 +94,7 @@
 extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *);
 extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int);
 extern NCURSES_EXPORT(int) mouseinterval (int);
-extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW* win,int* y, int* x, bool to_screen);
+extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool);
 extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool);              /* generated */
 
 #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
@@ -113,6 +150,7 @@
 extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable;		/* enable optimizations */
 #ifdef _XOPEN_SOURCE_EXTENDED
 extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *);
+extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *);
 #endif
 extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
 #define OPTIMIZE_MVCUR		0x01	/* cursor movement optimization */
diff -Naur ncurses-5.4.orig/include/curses.wide ncurses-5.4/include/curses.wide
--- ncurses-5.4.orig/include/curses.wide	2004-01-03 20:35:14.000000000 +0000
+++ ncurses-5.4/include/curses.wide	2005-05-13 04:09:50.000000000 +0000
@@ -1,7 +1,7 @@
 
 #ifdef _XOPEN_SOURCE_EXTENDED
 
-/* $Id: curses.wide,v 1.28 2004/01/03 20:35:14 tom Exp $ */
+/* $Id: curses.wide,v 1.29 2005/01/28 21:11:53 tom Exp $ */
 
 extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs;
 
@@ -188,11 +188,9 @@
 #define ins_wch(c)			wins_wch(stdscr,c)
 #define ins_wstr(t)			wins_wstr(stdscr,t)
 #define inwstr(c)			winwstr(stdscr,c)
-#define vid_attr(a,pair,opts)		vidattr(a)
 #define vline_set(c,n)			wvline_set(stdscr,c,n)
 #define wadd_wchstr(win,str)		wadd_wchnstr(win,str,-1)
 #define waddwstr(win,wstr)		waddnwstr(win,wstr,-1)
-#define wattr_set(win,a,p,opts) ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
 #define wget_wstr(w,t)			wgetn_wstr(w,t,-1)
 #define wgetbkgrnd(win,wch)		(*wch = win->_bkgrnd, OK)
 #define win_wchstr(w,c)			win_wchnstr(w,c,-1)
diff -Naur ncurses-5.4.orig/include/nc_alloc.h ncurses-5.4/include/nc_alloc.h
--- ncurses-5.4.orig/include/nc_alloc.h	2002-07-20 13:16:40.000000000 +0000
+++ ncurses-5.4/include/nc_alloc.h	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc.                        *
+ * Copyright (c) 1998-2004,2005 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,7 +29,7 @@
 /****************************************************************************
  *  Author: Thomas E. Dickey <dickey@clark.net> 1996,1997                   *
  ****************************************************************************/
-/* $Id: nc_alloc.h,v 1.11 2002/07/20 13:16:40 tom Exp $ */
+/* $Id: nc_alloc.h,v 1.13 2005/01/16 00:27:35 tom Exp $ */
 
 #ifndef NC_ALLOC_included
 #define NC_ALLOC_included 1
@@ -52,6 +52,13 @@
 #define HAVE_LIBDBMALLOC 0
 #endif
 
+#if HAVE_LIBMPATROL
+#include <mpatrol.h>    /* Memory-Patrol library */
+#else
+#undef  HAVE_LIBMPATROL
+#define HAVE_LIBMPATROL 0
+#endif
+
 #ifndef NO_LEAKS
 #define NO_LEAKS 0
 #endif
@@ -59,9 +66,9 @@
 #if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS
 #define HAVE_NC_FREEALL 1
 struct termtype;
-extern void _nc_free_and_exit(int) GCC_NORETURN;
-extern void _nc_free_tparm(void);
-extern void _nc_leaks_dump_entry(void);
+extern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN;
+extern NCURSES_EXPORT(void) _nc_free_tparm(void);
+extern NCURSES_EXPORT(void) _nc_leaks_dump_entry(void);
 #define ExitProgram(code) _nc_free_and_exit(code)
 #endif
 
diff -Naur ncurses-5.4.orig/include/ncurses_cfg.hin ncurses-5.4/include/ncurses_cfg.hin
--- ncurses-5.4.orig/include/ncurses_cfg.hin	2002-09-07 16:55:14.000000000 +0000
+++ ncurses-5.4/include/ncurses_cfg.hin	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc.                        *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -30,7 +30,7 @@
  *  Author: Thomas E. Dickey <dickey@clark.net> 1997                        *
  ****************************************************************************/
 /*
- * $Id: ncurses_cfg.hin,v 1.4 2002/09/07 16:55:14 tom Exp $
+ * $Id: ncurses_cfg.hin,v 1.7 2005/01/02 01:26:58 tom Exp $
  *
  * This is a template-file used to generate the "ncurses_cfg.h" file.
  *
@@ -59,4 +59,14 @@
 #endif
 #endif
 
+	/* On HP-UX, the C compiler doesn't grok mbstate_t without
+	   -D_XOPEN_SOURCE=500. However, this causes problems on
+	   IRIX. So, we #define mbstate_t to int in configure.in
+	   only for the C compiler if needed. */
+#ifndef __cplusplus
+#ifdef NEED_MBSTATE_T_DEF
+#define mbstate_t int
+#endif
+#endif
+
 #endif /* NC_CONFIG_H */
diff -Naur ncurses-5.4.orig/include/ncurses_defs ncurses-5.4/include/ncurses_defs
--- ncurses-5.4.orig/include/ncurses_defs	2004-01-18 01:03:24.000000000 +0000
+++ ncurses-5.4/include/ncurses_defs	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: ncurses_defs,v 1.21 2004/01/18 01:03:24 tom Exp $
+# $Id: ncurses_defs,v 1.27 2005/01/28 21:11:53 tom Exp $
 ##############################################################################
-# Copyright (c) 2000-2003,2004 Free Software Foundation, Inc.                #
+# Copyright (c) 2000-2004,2005 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"), #
@@ -59,17 +59,20 @@
 HAVE_GETOPT_H
 HAVE_GETTIMEOFDAY
 HAVE_GETTTYNAM
+HAVE_GPM_H
 HAVE_GPP_BUILTIN_H
 HAVE_GXX_BUILTIN_H
 HAVE_HAS_KEY
 HAVE_ISASCII
 HAVE_ISSETUGID
+HAVE_LANGINFO_CODESET
 HAVE_LIBC_H
 HAVE_LIBDBMALLOC
 HAVE_LIBDMALLOC
 HAVE_LIBFORM
 HAVE_LIBGPM
 HAVE_LIBMENU
+HAVE_LIBMPATROL
 HAVE_LIBPANEL
 HAVE_LIMITS_H
 HAVE_LINK
@@ -79,7 +82,6 @@
 HAVE_MBRLEN
 HAVE_MBRTOWC
 HAVE_MBTOWC
-HAVE_MEMCCPY
 HAVE_MENU_H
 HAVE_MKSTEMP
 HAVE_NANOSLEEP
@@ -132,11 +134,13 @@
 HAVE_VSSCANF
 HAVE_WCTOB 
 HAVE_WCTOMB
+HAVE_WCTYPE_H
 HAVE_WORKING_POLL
 HAVE_WRESIZE
 HAVE__DOSCAN
 MIXEDCASE_FILENAMES
 NCURSES_EXPANDED
+NCURSES_EXT_COLORS
 NCURSES_EXT_FUNCS
 NCURSES_NOMACROS
 NCURSES_NO_PADDING
diff -Naur ncurses-5.4.orig/include/term_entry.h ncurses-5.4/include/term_entry.h
--- ncurses-5.4.orig/include/term_entry.h	2001-03-24 21:53:10.000000000 +0000
+++ ncurses-5.4/include/term_entry.h	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2001,2004 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,9 +29,10 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1998-2004               *
  ****************************************************************************/
 
-/* $Id: term_entry.h,v 1.32 2001/03/24 21:53:10 tom Exp $ */
+/* $Id: term_entry.h,v 1.33 2004/07/05 11:51:16 tom Exp $ */
 
 /*
  *	term_entry.h -- interface to entry-manipulation code
@@ -56,7 +57,7 @@
         {
 	    char		*name;
 	    struct entry	*link;
-	    long	line;
+	    long		line;
         }
 	uses[MAX_USES];
 	int		ncrosslinks;
@@ -148,9 +149,11 @@
 /* comp_parse.c: entry list handling */
 extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
 extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
-extern NCURSES_EXPORT(int) _nc_resolve_uses (bool);
+extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
+extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
 extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
-extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *);
+extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
+extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE *, bool);
 
 /* trace_xnames.c */
 extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
diff -Naur ncurses-5.4.orig/include/tic.h ncurses-5.4/include/tic.h
--- ncurses-5.4.orig/include/tic.h	2003-12-27 19:05:32.000000000 +0000
+++ ncurses-5.4/include/tic.h	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,10 +29,11 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey 1996 on                                        *
  ****************************************************************************/
 
 /*
- * $Id: tic.h,v 1.46 2003/12/27 19:05:32 tom Exp $
+ * $Id: tic.h,v 1.49 2004/04/03 20:22:58 tom Exp $
  *	tic.h - Global variables and structures for the terminfo
  *			compiler.
  */
@@ -108,7 +109,7 @@
 #define DEBUG_LEVEL(n)	((n) << TRACE_SHIFT)
 
 #define set_trace_level(n) \
- 	_nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL), \
+	_nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL), \
 	_nc_tracing |= DEBUG_LEVEL(n)
 
 #ifdef TRACE
@@ -216,18 +217,18 @@
 #define NOTFOUND	((struct name_table_entry *) 0)
 
 /* out-of-band values for representing absent capabilities */
-#define ABSENT_BOOLEAN		(char)(-1)	/* 255 */
+#define ABSENT_BOOLEAN		((signed char)-1)	/* 255 */
 #define ABSENT_NUMERIC		(-1)
 #define ABSENT_STRING		(char *)0
 
 /* out-of-band values for representing cancels */
-#define CANCELLED_BOOLEAN	(char)(-2)	/* 254 */
+#define CANCELLED_BOOLEAN	((signed char)-2)	/* 254 */
 #define CANCELLED_NUMERIC	(-2)
 #define CANCELLED_STRING	(char *)(-1)
 
 #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
 #define VALID_NUMERIC(s) ((s) >= 0)
-#define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
+#define VALID_STRING(s)  ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
 
 /* termcap entries longer than this may break old binaries */
 #define MAX_TERMCAP_LENGTH	1023
@@ -278,7 +279,7 @@
 extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int);
 
 /* comp_scan.c: decode string from readable form */
-extern NCURSES_EXPORT(char) _nc_trans_string (char *, char *);
+extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *);
 
 /* captoinfo.c: capability conversion */
 extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const);
diff -Naur ncurses-5.4.orig/install-sh ncurses-5.4/install-sh
--- ncurses-5.4.orig/install-sh	1998-12-09 15:28:30.000000000 +0000
+++ ncurses-5.4/install-sh	2005-05-13 04:09:50.000000000 +0000
@@ -109,38 +109,39 @@
 	echo "install:	no input file specified"
 	exit 1
 else
-	true
+	:
 fi
 
 if [ x"$dir_arg" != x ]; then
 	dst=$src
 	src=""
-	
+
 	if [ -d $dst ]; then
 		instcmd=:
+		chmodcmd=""
 	else
-		instcmd=mkdir
+		instcmd=$mkdirprog
 	fi
 else
 
 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad 
+# might cause directories to be created, which would be especially bad
 # if $src (and thus $dsttmp) contains '*'.
 
 	if [ -f $src -o -d $src ]
 	then
-		true
+		:
 	else
 		echo "install:  $src does not exist"
 		exit 1
 	fi
-	
+
 	if [ x"$dst" = x ]
 	then
 		echo "install:	no destination specified"
 		exit 1
 	else
-		true
+		:
 	fi
 
 # If destination is a directory, append the input filename; if your system
@@ -150,7 +151,7 @@
 	then
 		dst="$dst"/`basename $src`
 	else
-		true
+		:
 	fi
 fi
 
@@ -162,8 +163,8 @@
 
 # Skip lots of stat calls in the usual case.
 if [ ! -d "$dstdir" ]; then
-defaultIFS='	
-'
+defaultIFS='
+	'
 IFS="${IFS-${defaultIFS}}"
 
 oIFS="${IFS}"
@@ -182,7 +183,7 @@
         then
 		$mkdirprog "${pathcomp}"
 	else
-		true
+		:
 	fi
 
 	pathcomp="${pathcomp}/"
@@ -193,29 +194,29 @@
 then
 	$doit $instcmd $dst &&
 
-	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
-	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
 else
 
 # If we're going to rename the final executable, determine the name now.
 
-	if [ x"$transformarg" = x ] 
+	if [ x"$transformarg" = x ]
 	then
 		dstfile=`basename $dst`
 	else
-		dstfile=`basename $dst $transformbasename | 
+		dstfile=`basename $dst $transformbasename |
 			sed $transformarg`$transformbasename
 	fi
 
 # don't allow the sed command to completely eliminate the filename
 
-	if [ x"$dstfile" = x ] 
+	if [ x"$dstfile" = x ]
 	then
 		dstfile=`basename $dst`
 	else
-		true
+		:
 	fi
 
 # Make a temp file name in the proper directory.
@@ -234,15 +235,15 @@
 # ignore errors from any of these, just make sure not to ignore
 # errors from the above "$doit $instcmd $src $dsttmp" command.
 
-	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
-	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
 
 # Now rename the file to the real destination.
 
 	$doit $rmcmd -f $dstdir/$dstfile &&
-	$doit $mvcmd $dsttmp $dstdir/$dstfile 
+	$doit $mvcmd $dsttmp $dstdir/$dstfile
 
 fi &&
 
diff -Naur ncurses-5.4.orig/man/Makefile.in ncurses-5.4/man/Makefile.in
--- ncurses-5.4.orig/man/Makefile.in	2003-12-20 18:41:10.000000000 +0000
+++ ncurses-5.4/man/Makefile.in	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.35 2003/12/20 18:41:10 tom Exp $
+# $Id: Makefile.in,v 1.36 2005/01/29 19:29:52 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2003,2005 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"), #
@@ -49,6 +49,7 @@
 all \
 sources :	terminfo.5
 depend :
+tags :
 
 $(DESTDIR)$(mandir) :
 	sh $(srcdir)/../mkinstalldirs $@
diff -Naur ncurses-5.4.orig/man/captoinfo.1m ncurses-5.4/man/captoinfo.1m
--- ncurses-5.4.orig/man/captoinfo.1m	2003-05-11 00:32:53.000000000 +0000
+++ ncurses-5.4/man/captoinfo.1m	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2003,2004 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            *
@@ -27,14 +27,14 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: captoinfo.1m,v 1.17 2003/05/11 00:32:53 tom Exp $
+.\" $Id: captoinfo.1m,v 1.18 2004/07/05 13:16:08 tom Exp $
 .TH captoinfo 1M ""
 .ds n 5
 .ds d @TERMINFO@
 .SH NAME
 \fBcaptoinfo\fR - convert a \fItermcap\fR description into a \fIterminfo\fR description
 .SH SYNOPSIS
-\fBcaptoinfo\fR [\fB\-v\fR\fIn\fR \fIwidth\fR]  [\fB\-V\fR] [\fB\-1\fR] [\fB\-w\fR \fIwidth\fR] \fIfile\fR . . .
+\fBcaptoinfo\fR [\fB-v\fR\fIn\fR \fIwidth\fR]  [\fB-V\fR] [\fB-1\fR] [\fB-w\fR \fIwidth\fR] \fIfile\fR . . .
 .SH DESCRIPTION
 \fBcaptoinfo\fR looks in \fIfile\fR for \fBtermcap\fR descriptions.  For each
 one found, an equivalent \fBterminfo\fR description is written to standard
@@ -47,18 +47,18 @@
 extracted from that file.  If the environment variable \fBTERMCAP\fR is not
 set, then the file \fB\*d\fR is read.
 .TP 5
-\fB\-v\fR
+\fB-v\fR
 print out tracing information on standard error as the program runs.
 .TP 5
-\fB\-V\fR
+\fB-V\fR
 print out the version of the program in use on standard error and exit.
 .TP 5
-\fB\-1\fR
+\fB-1\fR
 cause the fields to print out one to a line.  Otherwise, the fields
 will be printed several to a line to a maximum width of 60
 characters.
 .TP 5
-\fB\-w\fR
+\fB-w\fR
 change the output to \fIwidth\fR characters.
 .SH FILES
 .TP 20
@@ -172,11 +172,11 @@
 capabilities \fBmeml\fR (memory lock) and \fBmemu\fR (memory unlock).
 These will be discarded with a warning message.
 .SH NOTES
-This utility is actually a link to \fItic\fR(1M), running in \fI\-I\fR mode.
-You can use other \fItic\fR options such as \fB\-f\fR and  \fB\-x\fR.
+This utility is actually a link to \fItic\fR(1M), running in \fI-I\fR mode.
+You can use other \fItic\fR options such as \fB-f\fR and  \fB-x\fR.
 
 The trace option isn't identical to SVr4's.  Under SVr4, instead of following
-the \fB\-v\fR with a trace level n, you repeat it n times.
+the \fB-v\fR with a trace level n, you repeat it n times.
 .SH SEE ALSO
 \fBcurses\fR(3X), \fB@INFOCMP@\fR(1M), \fBterminfo\fR(\*n)
 .SH AUTHOR
diff -Naur ncurses-5.4.orig/man/curs_add_wchstr.3x ncurses-5.4/man/curs_add_wchstr.3x
--- ncurses-5.4.orig/man/curs_add_wchstr.3x	2003-12-27 18:53:41.000000000 +0000
+++ ncurses-5.4/man/curs_add_wchstr.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
+.\" Copyright (c) 2002-2004,2005 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            *
@@ -26,10 +26,9 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_add_wchstr.3x,v 1.2 2003/12/27 18:53:41 tom Exp $
+.\" $Id: curs_add_wchstr.3x,v 1.6 2005/01/02 01:28:49 tom Exp $
 .TH curs_add_wchstr 3X ""
 .SH NAME
-.PP
 \fBadd_wchstr\fR,
 \fBadd_wchnstr\fR,
 \fBwadd_wchstr\fR,
@@ -73,7 +72,7 @@
 they do not advance the current cursor position,
 they do not expand other control characters to ^-escapes,
 and they truncate the string if it crosses the right margin,
-rather then wrapping it around to the new line.
+rather than wrapping it around to the new line.
 .PP
 These routines end successfully
 on encountering a null \fIcchar_t\fR, or
@@ -88,7 +87,7 @@
 All these entry points are described in the XSI Curses standard, Issue 4.
 .SH SEE ALSO
 \fBcurses\fR(3X),
-\fBcurs_addchstr\fR(3X)
+\fBcurs_addchstr\fR(3X),
 \fBcurs_addwstr\fR(3X)
 .\"#
 .\"# The following sets edit modes for GNU EMACS
diff -Naur ncurses-5.4.orig/man/curs_addwstr.3x ncurses-5.4/man/curs_addwstr.3x
--- ncurses-5.4.orig/man/curs_addwstr.3x	2003-12-27 18:51:01.000000000 +0000
+++ ncurses-5.4/man/curs_addwstr.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
+.\" Copyright (c) 2002-2003,2004 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            *
@@ -26,7 +26,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_addwstr.3x,v 1.3 2003/12/27 18:51:01 tom Exp $
+.\" $Id: curs_addwstr.3x,v 1.4 2004/09/11 20:57:04 tom Exp $
 .TH curs_addwstr 3X ""
 .SH NAME
 \fBaddwstr\fR,
@@ -58,7 +58,8 @@
 \fBint mvwaddnwstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
 .fi
 .SH DESCRIPTION
-These routines write the characters of the (null-terminated) \fBwchar_t\fRcharacter string
+These routines write the characters of the
+(null-terminated) \fBwchar_t\fR character string
 \fIwstr\fR on the given window.
 It is similar to constructing a \fBcchar_t\fR for each wchar_t in the string,
 then calling \fBwadd_wch\fR for the resulting \fBcchar_t\fR.
diff -Naur ncurses-5.4.orig/man/curs_beep.3x ncurses-5.4/man/curs_beep.3x
--- ncurses-5.4.orig/man/curs_beep.3x	2003-12-27 18:44:30.000000000 +0000
+++ ncurses-5.4/man/curs_beep.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998,2003 Free Software Foundation, Inc.                   *
+.\" Copyright (c) 1998-2003,2005 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            *
@@ -26,7 +26,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_beep.3x,v 1.9 2003/12/27 18:44:30 tom Exp $
+.\" $Id: curs_beep.3x,v 1.10 2005/01/08 17:55:51 tom Exp $
 .TH curs_beep 3X ""
 .SH NAME
 \fBbeep\fR, \fBflash\fR - \fBcurses\fR bell and screen flash routines
@@ -51,8 +51,8 @@
 SVr4's beep and flash routines always returned \fBOK\fR, so it was not
 possible to tell when the beep or flash failed.
 .SH PORTABILITY
-These functions are defined in the XSI Curses standard, Issue 4.  Like SVr4, it
-specifies that they always return \fBOK\fR.
+These functions are described in the XSI Curses standard, Issue 4.
+Like SVr4, it specifies that they always return \fBOK\fR.
 .SH SEE ALSO
 \fBcurses\fR(3X)
 .\"#
diff -Naur ncurses-5.4.orig/man/curs_bkgrnd.3x ncurses-5.4/man/curs_bkgrnd.3x
--- ncurses-5.4.orig/man/curs_bkgrnd.3x	2002-02-23 23:23:42.000000000 +0000
+++ ncurses-5.4/man/curs_bkgrnd.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 2002 Free Software Foundation, Inc.                        *
+.\" Copyright (c) 2002,2004 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            *
@@ -26,10 +26,9 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_bkgrnd.3x,v 1.1 2002/02/23 23:23:42 tom Exp $
+.\" $Id: curs_bkgrnd.3x,v 1.2 2004/03/13 19:39:10 tom Exp $
 .TH curs_bkgrnd 3X ""
 .SH NAME
-.PP
 \fBbkgrnd\fR,
 \fBwbkgrnd\fR,
 \fBbkgrndset\fR,
diff -Naur ncurses-5.4.orig/man/curs_border_set.3x ncurses-5.4/man/curs_border_set.3x
--- ncurses-5.4.orig/man/curs_border_set.3x	2002-04-20 16:49:13.000000000 +0000
+++ ncurses-5.4/man/curs_border_set.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 2002 Free Software Foundation, Inc.                        *
+.\" Copyright (c) 2002,2004 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            *
@@ -26,10 +26,9 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_border_set.3x,v 1.3 2002/04/20 16:49:13 tom Exp $
+.\" $Id: curs_border_set.3x,v 1.4 2004/03/13 19:39:10 tom Exp $
 .TH curs_border_set 3X ""
 .SH NAME
-.PP
 \fBborder_set\fR,
 \fBwborder_set\fR,
 \fBbox_set\fR,
diff -Naur ncurses-5.4.orig/man/curs_color.3x ncurses-5.4/man/curs_color.3x
--- ncurses-5.4.orig/man/curs_color.3x	2002-02-16 22:38:32.000000000 +0000
+++ ncurses-5.4/man/curs_color.3x	2005-05-13 04:09:55.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2004,2005 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            *
@@ -26,7 +26,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_color.3x,v 1.19 2002/02/16 22:38:32 tom Exp $
+.\" $Id: curs_color.3x,v 1.25 2005/04/03 14:06:00 tom Exp $
 .TH curs_color 3X ""
 .SH NAME
 \fBstart_color\fR,
@@ -96,8 +96,10 @@
 .TP 5
 -
 The value of the second and
-third arguments must be between 0 and \fBCOLORS\fR (the 0 color pair is wired
-to white on black and cannot be changed).
+third arguments must be between 0 and \fBCOLORS\fR.
+Color pair 0 is assumed to be white on black,
+but is actually whatever the terminal implements before color is initialized.
+It cannot be modified by the application.
 .PP
 If the color-pair was previously
 initialized, the screen is refreshed and all occurrences of that color-pair
@@ -165,6 +167,21 @@
 All other routines return the integer \fBERR\fR upon failure and an \fBOK\fR
 (SVr4 specifies only "an integer value other than \fBERR\fR") upon successful
 completion.
+.PP
+X/Open defines no error conditions.
+This implementation will return \fBERR\fR on attempts to
+use color values outside the range 0 to COLORS-1
+(except for the default colors extension),
+or use color pairs outside the range 0 to COLOR_PAIR-1.
+Color values used in \fBinit_color\fP must be in the range 0 to 1000.
+.PP
+If the color table cannot be allocated,
+or if the terminal has not been initialized,
+\fBstart_color\fP returns ERR.
+If the screen has not been initialized, that is also an error.
+.PP
+An error is returned, e.g., from \fBinit_pair\fP, if \fBstart_color\fP was
+not first called.
 .SH NOTES
 In the \fIncurses\fR implementation, there is a separate color activation flag,
 color palette, color pairs table, and associated COLORS and COLOR_PAIRS counts
@@ -201,8 +218,12 @@
 .PP
 The assumption that \fBCOLOR_BLACK\fR is the default
 background color for all terminals can be modified using the
-\fBassume_default_colors\fP extension,
-
+\fBassume_default_colors\fP extension.
+.PP
+This implementation checks the pointers,
+e.g., for the values returned by
+\fBcolor_content\fP and \fBpair_content\fP,
+and will treat those as optional parameters when null.
 .SH SEE ALSO
 \fBcurses\fR(3X),
 \fBcurs_initscr\fR(3X),
diff -Naur ncurses-5.4.orig/man/curs_extend.3x ncurses-5.4/man/curs_extend.3x
--- ncurses-5.4.orig/man/curs_extend.3x	2003-10-25 20:33:16.000000000 +0000
+++ ncurses-5.4/man/curs_extend.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1999-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1999-2003,2004 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            *
@@ -28,7 +28,7 @@
 .\"
 .\" Author: Thomas E. Dickey 1999
 .\"
-.\" $Id: curs_extend.3x,v 1.12 2003/10/25 20:33:16 tom Exp $
+.\" $Id: curs_extend.3x,v 1.13 2004/07/05 13:16:08 tom Exp $
 .TH curs_extend 3X ""
 .SH NAME
 \fBcurses_version\fP,
@@ -56,7 +56,7 @@
 which may be compiled into the terminfo
 description, i.e., via the terminfo or termcap interfaces.
 Normally these names are available for use, since the essential decision
-is made by using the \fB\-x\fP option of \fItic\fP to compile
+is made by using the \fB-x\fP option of \fItic\fP to compile
 extended terminal definitions.
 However you can disable this feature
 to ensure compatibility with other implementations of curses.
diff -Naur ncurses-5.4.orig/man/curs_getch.3x ncurses-5.4/man/curs_getch.3x
--- ncurses-5.4.orig/man/curs_getch.3x	2003-12-27 18:46:06.000000000 +0000
+++ ncurses-5.4/man/curs_getch.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2003,2005 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            *
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_getch.3x,v 1.24 2003/12/27 18:46:06 tom Exp $
+.\" $Id: curs_getch.3x,v 1.26 2005/01/02 01:27:47 tom Exp $
 .TH curs_getch 3X ""
 .SH NAME
 \fBgetch\fR,
@@ -297,7 +297,7 @@
 \fBcurs_inopts\fR(3X),
 \fBcurs_mouse\fR(3X),
 \fBcurs_move\fR(3X),
-\fBcurs_refresh\fR(3X).
+\fBcurs_refresh\fR(3X),
 \fBresizeterm\fR(3X).
 .\"#
 .\"# The following sets edit modes for GNU EMACS
diff -Naur ncurses-5.4.orig/man/curs_in_wchstr.3x ncurses-5.4/man/curs_in_wchstr.3x
--- ncurses-5.4.orig/man/curs_in_wchstr.3x	2002-05-18 21:48:30.000000000 +0000
+++ ncurses-5.4/man/curs_in_wchstr.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 2002 Free Software Foundation, Inc.                        *
+.\" Copyright (c) 2002,2005 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            *
@@ -26,7 +26,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_in_wchstr.3x,v 1.2 2002/05/18 21:48:30 tom Exp $
+.\" $Id: curs_in_wchstr.3x,v 1.4 2005/01/02 01:27:19 tom Exp $
 .TH curs_in_wchstr 3X ""
 .SH NAME
 \fBin_wchstr\fR,
@@ -106,7 +106,7 @@
 .SH SEE ALSO
 Functions:
 \fBcurses\fR(3X),
-\fBcurs_in_wch\fR(3X)
+\fBcurs_in_wch\fR(3X),
 \fBcurs_instr\fR(3X),
 \fBcurs_inwstr\fR(3X)
 .\"#
diff -Naur ncurses-5.4.orig/man/curs_insstr.3x ncurses-5.4/man/curs_insstr.3x
--- ncurses-5.4.orig/man/curs_insstr.3x	2001-11-03 19:59:03.000000000 +0000
+++ ncurses-5.4/man/curs_insstr.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998,2000,2001 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2001,2004 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            *
@@ -26,7 +26,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_insstr.3x,v 1.12 2001/11/03 19:59:03 tom Exp $
+.\" $Id: curs_insstr.3x,v 1.14 2004/06/19 22:22:51 tom Exp $
 .TH curs_insstr 3X ""
 .SH NAME
 \fBinsstr\fR,
@@ -57,22 +57,18 @@
 \fBint mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n);\fR
 .br
 .SH DESCRIPTION
-These routines insert a character string (as many characters as will fit on the
-line) before the character under the cursor.  All characters to the right of
-the cursor are shifted right, with the possibility of the rightmost characters
-on the line being lost.  The cursor position does not change (after moving to
-\fIy\fR, \fIx\fR, if specified). The four routines with \fIn\fR as the last
-argument insert a leading substring of at most \fIn\fR characters.  If
-\fIn\fR<=0, then the entire string is inserted.
+These routines insert a character string
+(as many characters as will fit on the line)
+before the character under the cursor.
+All characters to the right of the cursor are shifted right
+with the possibility of the rightmost characters on the line being lost.
+The cursor position does not change
+(after moving to \fIy\fR, \fIx\fR, if specified).
+The functions with \fIn\fR as the last argument
+insert a leading substring of at most \fIn\fR characters.
+If \fIn\fR<=0, then the entire string is inserted.
 
-If a character in \fIstr\fR is a tab, newline, carriage return or
-backspace, the cursor is moved appropriately within the window.  A
-newline also does a \fBclrtoeol\fR before moving.  Tabs are considered
-to be at every eighth column.  If a character in \fIstr\fR is another
-control character, it is drawn in the \fB^\fR\fIX\fR notation.
-Calling \fBwinch\fR after adding a control character (and moving to
-it, if necessary) does not return the control character, but instead
-returns a character in the ^-representation of the control character.
+Special characters are handled as in \fBaddch\fP.
 .SH RETURN VALUE
 All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
 specifies only "an integer value other than \fBERR\fR") upon successful
@@ -85,8 +81,16 @@
 \fBEILSEQ\fR and \fBEILOVERFLOW\fR associated with extended-level conformance
 are not yet detected (this implementation does not yet support XPG4 multibyte
 characters).
+.LP
+The Single Unix Specification, Version 2 states that 
+\fBinsnstr\fP and \fBwinsnstr\fP perform wrapping.
+This is probably an error, since it makes this group of functions inconsistent.
+Also, no implementation of curses documents this inconsistency.
 .SH SEE ALSO
-\fBcurses\fR(3X), \fBcurs_clear\fR(3X), \fBcurs_inch\fR(3X).
+\fBcurses\fR(3X),
+\fBunctrl\fR(3X),
+\fBcurs_clear\fR(3X),
+\fBcurs_inch\fR(3X).
 .\"#
 .\"# The following sets edit modes for GNU EMACS
 .\"# Local Variables:
diff -Naur ncurses-5.4.orig/man/curs_inwstr.3x ncurses-5.4/man/curs_inwstr.3x
--- ncurses-5.4.orig/man/curs_inwstr.3x	2002-04-13 20:25:35.000000000 +0000
+++ ncurses-5.4/man/curs_inwstr.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 2002 Free Software Foundation, Inc.                        *
+.\" Copyright (c) 2002,2004 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            *
@@ -26,10 +26,9 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_inwstr.3x,v 1.2 2002/04/13 20:25:35 tom Exp $
+.\" $Id: curs_inwstr.3x,v 1.3 2004/03/13 19:39:10 tom Exp $
 .TH curs_inwstr 3 ""
 .SH NAME
-.PP
 \fBinwstr\fR,
 \fBinnwstr\fR,
 \fBwinwstr\fR,
diff -Naur ncurses-5.4.orig/man/curs_mouse.3x ncurses-5.4/man/curs_mouse.3x
--- ncurses-5.4.orig/man/curs_mouse.3x	2003-12-27 18:47:54.000000000 +0000
+++ ncurses-5.4/man/curs_mouse.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2003,2005 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            *
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_mouse.3x,v 1.24 2003/12/27 18:47:54 tom Exp $
+.\" $Id: curs_mouse.3x,v 1.26 2005/02/19 20:59:40 tom Exp $
 .TH curs_mouse 3X ""
 .SH NAME
 \fBgetmouse\fR, \fBungetmouse\fR,
@@ -85,7 +85,7 @@
 setting a nonzero mask may turn it on.
 Whether this happens is device-dependent.
 .PP
-Here are the mouse event type masks:
+Here are the mouse event type masks which may be defined:
 .PP
 .TS
 l l
@@ -97,26 +97,37 @@
 BUTTON1_CLICKED	mouse button 1 clicked
 BUTTON1_DOUBLE_CLICKED	mouse button 1 double clicked
 BUTTON1_TRIPLE_CLICKED	mouse button 1 triple clicked
+_
 BUTTON2_PRESSED	mouse button 2 down
 BUTTON2_RELEASED	mouse button 2 up
 BUTTON2_CLICKED	mouse button 2 clicked
 BUTTON2_DOUBLE_CLICKED	mouse button 2 double clicked
 BUTTON2_TRIPLE_CLICKED	mouse button 2 triple clicked
+_
 BUTTON3_PRESSED	mouse button 3 down
 BUTTON3_RELEASED	mouse button 3 up
 BUTTON3_CLICKED	mouse button 3 clicked
 BUTTON3_DOUBLE_CLICKED	mouse button 3 double clicked
 BUTTON3_TRIPLE_CLICKED	mouse button 3 triple clicked
+_
 BUTTON4_PRESSED	mouse button 4 down
 BUTTON4_RELEASED	mouse button 4 up
 BUTTON4_CLICKED	mouse button 4 clicked
 BUTTON4_DOUBLE_CLICKED	mouse button 4 double clicked
 BUTTON4_TRIPLE_CLICKED	mouse button 4 triple clicked
+_
+BUTTON5_PRESSED	mouse button 5 down
+BUTTON5_RELEASED	mouse button 5 up
+BUTTON5_CLICKED	mouse button 5 clicked
+BUTTON5_DOUBLE_CLICKED	mouse button 5 double clicked
+BUTTON5_TRIPLE_CLICKED	mouse button 5 triple clicked
+_
 BUTTON_SHIFT	shift was down during button state change
 BUTTON_CTRL	control was down during button state change
 BUTTON_ALT	alt was down during button state change
 ALL_MOUSE_EVENTS	report all button state changes
 REPORT_MOUSE_POSITION	report mouse movement
+_
 .TE
 .PP
 Once a class of mouse events have been made visible in a window,
@@ -172,8 +183,9 @@
 The \fBmouseinterval\fR function sets the maximum time (in thousands of a
 second) that can elapse between press and release events for them to
 be recognized as a click.
-Use \fBmouseinterval(-1)\fR to disable click resolution.
+Use \fBmouseinterval(0)\fR to disable click resolution.
 This function returns the previous interval value.
+Use \fBmouseinterval(-1)\fR to obtain the interval without altering it.
 The default is one sixth of a second.
 .PP
 Note that mouse events will be ignored when input is in cooked mode, and will
@@ -194,9 +206,22 @@
 curses, 4.4BSD curses, or any other previous version of curses.
 .PP
 The feature macro \fBNCURSES_MOUSE_VERSION\fR is provided so the preprocessor
-can be used to test whether these features are present (its value is 1).
+can be used to test whether these features are present.
 If the interface is changed, the value of \fBNCURSES_MOUSE_VERSION\fR will be
 incremented.
+These values for \fBNCURSES_MOUSE_VERSION\fR may be
+specified when configuring ncurses:
+.RS
+.TP 3
+1
+has definitions for reserved events.
+The mask uses 28 bits.
+.TP 3
+2
+adds definitions for button 5,
+removes the definitions for reserved events.
+The mask uses 29 bits.
+.RE
 .PP
 The order of the \fBMEVENT\fR structure members is not guaranteed.
 Additional fields may be added to the structure in the future.
diff -Naur ncurses-5.4.orig/man/curs_util.3x ncurses-5.4/man/curs_util.3x
--- ncurses-5.4.orig/man/curs_util.3x	2004-01-31 17:24:53.000000000 +0000
+++ ncurses-5.4/man/curs_util.3x	2005-05-13 04:09:58.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2004,2005 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            *
@@ -26,7 +26,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: curs_util.3x,v 1.12 2004/01/31 17:24:53 tom Exp $
+.\" $Id: curs_util.3x,v 1.13 2005/04/30 19:39:53 tom Exp $
 .TH curs_util 3X ""
 .SH NAME
 \fBdelay_output\fR,
@@ -133,6 +133,10 @@
 and may strip the parameter to 7 bits.
 This implementation uses 8 bits but does not modify the string to reflect
 locale.
+.PP
+The \fBkeyname\fP function may return the names of user-defined
+string capabilities which are defined in the terminfo entry via the \fB-x\fP
+option of \fBtic\fP.
 .SH SEE ALSO
 \fBcurses\fR(3X),
 \fBcurs_initscr\fR(3X),
diff -Naur ncurses-5.4.orig/man/default_colors.3x ncurses-5.4/man/default_colors.3x
--- ncurses-5.4.orig/man/default_colors.3x	2003-10-25 20:41:08.000000000 +0000
+++ ncurses-5.4/man/default_colors.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2003,2005 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            *
@@ -26,9 +26,9 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" Author: Thomas E. Dickey 1997,1999,2000
+.\" Author: Thomas E. Dickey 1997,1999,2000,2005
 .\"
-.\" $Id: default_colors.3x,v 1.17 2003/10/25 20:41:08 tom Exp $
+.\" $Id: default_colors.3x,v 1.18 2005/02/19 20:25:44 tom Exp $
 .TH default_colors 3X ""
 .SH NAME
 \fBuse_default_colors\fR,
@@ -107,6 +107,26 @@
 Associated with this extension, the \fBinit_pair\fR(3X) function accepts
 negative arguments to specify default foreground or background
 colors.
+.PP
+The \fIuse_default_colors()\fP function was added to support \fIded\fP.
+This is a full-screen application which uses curses to manage only part
+of the screen.  The bottom portion of the screen, which is of adjustable
+size, is left uncolored to display the results from shell commands.
+The top portion of the screen colors filenames using a scheme like the
+"color ls" programs.
+Attempting to manage the background color of the screen for this application
+would give unsatisfactory results for a variety of reasons.
+This extension was devised after
+noting that color xterm (and similar programs) provides a background color
+which does not necessarily correspond to any of the ANSI colors.
+While a special terminfo entry could be constructed using nine colors,
+there was no mechanism provided within curses to account for the related
+\fIorig_pair\fP and \fIback_color_erase\fP capabilities.
+.PP
+The \fIassume_default_colors()\fP function was added to solve
+a different problem: support for applications which would use
+environment variables and other configuration to bypass curses'
+notion of the terminal's default colors, setting specific values.
 .SH PORTABILITY
 These routines are specific to ncurses.  They were not supported on
 Version 7, BSD or System V implementations.  It is recommended that
diff -Naur ncurses-5.4.orig/man/define_key.3x ncurses-5.4/man/define_key.3x
--- ncurses-5.4.orig/man/define_key.3x	2003-10-25 20:33:16.000000000 +0000
+++ ncurses-5.4/man/define_key.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2003,2004 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            *
@@ -28,7 +28,7 @@
 .\"
 .\" Author: Thomas E. Dickey 1997
 .\"
-.\" $Id: define_key.3x,v 1.10 2003/10/25 20:33:16 tom Exp $
+.\" $Id: define_key.3x,v 1.11 2004/06/05 19:20:03 tom Exp $
 .TH define_key 3X ""
 .SH NAME
 \fBdefine_key\fP \- define a keycode
@@ -53,7 +53,8 @@
 Version 7, BSD or System V implementations.  It is recommended that
 any code depending on them be conditioned using NCURSES_VERSION.
 .SH SEE ALSO
-\fBkeyok\fR(3X).
+\fBkeyok\fR(3X),
+\fBkey_defined\fR(3X).
 .SH AUTHOR
 Thomas Dickey.
 .\"#
diff -Naur ncurses-5.4.orig/man/form_field_buffer.3x ncurses-5.4/man/form_field_buffer.3x
--- ncurses-5.4.orig/man/form_field_buffer.3x	2003-05-10 20:22:01.000000000 +0000
+++ ncurses-5.4/man/form_field_buffer.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2003,2004 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            *
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: form_field_buffer.3x,v 1.10 2003/05/10 20:22:01 tom Exp $
+.\" $Id: form_field_buffer.3x,v 1.11 2004/05/16 15:58:51 tom Exp $
 .TH form_field_buffer 3X ""
 .SH NAME
 \fBform_field_buffer\fR - field buffer control
@@ -84,6 +84,12 @@
 descriptions of the entry points.
 .SH NOTES
 The header file \fB<form.h>\fR automatically includes the header file
+
+When configured for wide-characters, \fBfield_buffer\fP returns a pointer
+to temporary storage (allocated and freed by the library).
+The application should not attempt to modify the data.
+It will be freed on the next call to \fBfield_buffer\fP to return the
+same buffer.
 \fB<curses.h>\fR.
 .SH PORTABILITY
 These routines emulate the System V forms library.  They were not supported on
diff -Naur ncurses-5.4.orig/man/infocmp.1m ncurses-5.4/man/infocmp.1m
--- ncurses-5.4.orig/man/infocmp.1m	2003-10-25 16:19:01.000000000 +0000
+++ ncurses-5.4/man/infocmp.1m	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2003,2004 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            *
@@ -27,14 +27,14 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: infocmp.1m,v 1.34 2003/10/25 16:19:01 tom Exp $
+.\" $Id: infocmp.1m,v 1.39 2004/08/28 22:43:49 tom Exp $
 .TH infocmp 1M ""
 .ds n 5
 .ds d @TERMINFO@
 .SH NAME
 \fBinfocmp\fR - compare or print out \fIterminfo\fR descriptions
 .SH SYNOPSIS
-\fBinfocmp\fR [\fB\-\
+\fBinfocmp\fR [\fB-\
 1\
 C\
 E\
@@ -56,11 +56,12 @@
 r\
 t\
 u\
+x\
 \fR]
 .br
-      [\fB\-v\fR \fIn\fR] [\fB\-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] [\fB\-R \fR\fBsubset\fR]
+      [\fB-v\fR \fIn\fR] [\fB-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] [\fB-R \fR\fBsubset\fR]
 .br
-      [\fB\-w\fR\ \fIwidth\fR] [\fB\-A\fR\ \fIdirectory\fR] [\fB\-B\fR\ \fIdirectory\fR]
+      [\fB-w\fR\ \fIwidth\fR] [\fB-A\fR\ \fIdirectory\fR] [\fB-B\fR\ \fIdirectory\fR]
 .br
       [\fItermname\fR...]
 .SH DESCRIPTION
@@ -72,9 +73,9 @@
 string fields.
 .SS Default Options
 If no options are specified and zero or one \fItermnames\fR are specified, the
-\fB\-I\fR option will be assumed.  If more than one \fItermname\fR is specified,
-the \fB\-d\fR option will be assumed.
-.SS Comparison Options [\-d] [\-c] [\-n]
+\fB-I\fR option will be assumed.  If more than one \fItermname\fR is specified,
+the \fB-d\fR option will be assumed.
+.SS Comparison Options [-d] [-c] [-n]
 \fBinfocmp\fR compares the \fBterminfo\fR description of the first terminal
 \fItermname\fR with each of the descriptions given by the entries for the other
 terminal's \fItermnames\fR.  If a capability is defined for only one of the
@@ -82,35 +83,35 @@
 \fBF\fR for boolean variables, \fB-1\fR for integer variables, and \fBNULL\fR
 for string variables.
 
-The \fB\-d\fR option produces a list of each capability that is different
+The \fB-d\fR option produces a list of each capability that is different
 between two entries.  This option is useful to show the difference between two
 entries, created by different people, for the same or similar terminals.
 
-The \fB\-c\fR option produces a list of each capability that is common between
+The \fB-c\fR option produces a list of each capability that is common between
 two entries.  Capabilities that are not set are ignored.  This option can be
-used as a quick check to see if the \fB\-u\fR option is worth using.
+used as a quick check to see if the \fB-u\fR option is worth using.
 
-The \fB\-n\fR option produces a list of each capability that is in neither
+The \fB-n\fR option produces a list of each capability that is in neither
 entry.  If no \fItermnames\fR are given, the environment variable \fBTERM\fR
 will be used for both of the \fItermnames\fR.  This can be used as a quick
 check to see if anything was left out of a description.
-.SS Source Listing Options [\-I] [\-L] [\-C] [\-r]
-The \fB\-I\fR, \fB\-L\fR, and \fB\-C\fR options will produce a source listing for
+.SS Source Listing Options [-I] [-L] [-C] [-r]
+The \fB-I\fR, \fB-L\fR, and \fB-C\fR options will produce a source listing for
 each terminal named.
 
 .TS
 center tab(/) ;
 l l .
-\fB\-I\fR/use the \fBterminfo\fR names
-\fB\-L\fR/use the long C variable name listed in <\fBterm.h\fR>
-\fB\-C\fR/use the \fBtermcap\fR names
-\fB\-r\fR/when using \fB\-C\fR, put out all capabilities in \fBtermcap\fR form
+\fB-I\fR/use the \fBterminfo\fR names
+\fB-L\fR/use the long C variable name listed in <\fBterm.h\fR>
+\fB-C\fR/use the \fBtermcap\fR names
+\fB-r\fR/when using \fB-C\fR, put out all capabilities in \fBtermcap\fR form
 .TE
 
 If no \fItermnames\fR are given, the environment variable \fBTERM\fR will be
 used for the terminal name.
 
-The source produced by the \fB\-C\fR option may be used directly as a
+The source produced by the \fB-C\fR option may be used directly as a
 \fBtermcap\fR entry, but not all parameterized strings can be changed to
 the \fBtermcap\fR format.  \fBinfocmp\fR will attempt to convert most of the
 parameterized information, and anything not converted will be plainly marked in
@@ -123,7 +124,7 @@
 All \fBtermcap\fR variables no longer supported by \fBterminfo\fR, but which
 are derivable from other \fBterminfo\fR variables, will be output.  Not all
 \fBterminfo\fR capabilities will be translated; only those variables which were
-part of \fBtermcap\fR will normally be output.  Specifying the \fB\-r\fR option
+part of \fBtermcap\fR will normally be output.  Specifying the \fB-r\fR option
 will take off this restriction, allowing all capabilities to be output in
 \fItermcap\fR form.
 
@@ -151,8 +152,8 @@
 \fB%p1%?%'x'%>%t%p1%'y'%+%;/%>xy\fR/concept
 \fB%p2\fR is printed before \fB%p1/%r\fR/hp
 .TE
-.SS Use= Option [\-u]
-The \fB\-u\fR option produces a \fBterminfo\fR source description of the first
+.SS Use= Option [-u]
+The \fB-u\fR option produces a \fBterminfo\fR source description of the first
 terminal \fItermname\fR which is relative to the sum of the descriptions given
 by the entries for the other terminals \fItermnames\fR.  It does this by
 analyzing the differences between the first \fItermname\fR and the other
@@ -187,29 +188,29 @@
 the compilation time, is specifying extra \fBuse=\fR fields that are
 superfluous.  \fBinfocmp\fR will flag any other \fItermname use=\fR fields that
 were not needed.
-.SS Changing Databases [\-A \fIdirectory\fR] [\-B \fIdirectory\fR]
+.SS Changing Databases [-A \fIdirectory\fR] [-B \fIdirectory\fR]
 The location of the compiled \fBterminfo\fR database is taken from the
 environment variable \fBTERMINFO\fR .  If the variable is not defined, or the
 terminal is not found in that location, the system \fBterminfo\fR database,
-in \fB@TERMINFO@\fR, will be used.  The options \fB\-A\fR
-and \fB\-B\fR may be used to override this location.  The \fB\-A\fR option will
-set \fBTERMINFO\fR for the first \fItermname\fR and the \fB\-B\fR option will
+in \fB@TERMINFO@\fR, will be used.  The options \fB-A\fR
+and \fB-B\fR may be used to override this location.  The \fB-A\fR option will
+set \fBTERMINFO\fR for the first \fItermname\fR and the \fB-B\fR option will
 set \fBTERMINFO\fR for the other \fItermnames\fR.  With this, it is possible to
 compare descriptions for a terminal with the same name located in two different
 databases.  This is useful for comparing descriptions for the same terminal
 created by different people.
 .SS Other Options
 .TP 5
-\fB\-1\fR
+\fB-1\fR
 causes the fields to be printed out one to a line.  Otherwise,
 the fields will be printed several to a line to a maximum width
 of 60 characters.
 .TP
-\fB\-a\fR
+\fB-a\fR
 tells \fBinfocmp\fP to retain commented-out capabilities rather than discarding
 them.  Capabilities are commented by prefixing them with a period.
 .TP 5
-\fB\-E\fR
+\fB-E\fR
 Dump the capabilities of the given terminal as tables, needed in
 the C initializer for a
 TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fR).
@@ -218,17 +219,17 @@
 The tables are all declared static, and are named according to the type
 and the name of the corresponding terminal entry.
 .sp
-Before ncurses 5.0, the split between the \fB\-e\fP and \fB\-E\fP
+Before ncurses 5.0, the split between the \fB-e\fP and \fB-E\fP
 options was not needed; but support for extended names required making
 the arrays of terminal capabilities separate from the TERMTYPE structure.
 .TP 5
-\fB\-e\fR
+\fB-e\fR
 Dump the capabilities of the given terminal as a C initializer for a
 TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fR).
 This option is useful for preparing versions of the curses library hardwired
 for a given terminal type.
 .TP 5
-\fB\-F\fR
+\fB-F\fR
 compare terminfo files.  This assumes that two following arguments are
 filenames.  The files are searched for pairwise matches between
 entries, with two entries considered to match if any of their names do.
@@ -237,21 +238,21 @@
 with exactly one match it includes a difference report.  Normally,
 to reduce the volume of the report, use references are
 not resolved before looking for differences, but resolution can be forced
-by also specifying \fB\-r\fR.
+by also specifying \fB-r\fR.
 .TP 5
-\fB\-f\fR
+\fB-f\fR
 Display complex terminfo strings which contain if/then/else/endif expressions
 indented for readability.
 .TP 5
-\fB\-G\fR
+\fB-G\fR
 Display constant literals in decimal form
 rather than their character equivalents.
 .TP 5
-\fB\-g\fR
+\fB-g\fR
 Display constant character literals in quoted form
 rather than their decimal equivalents.
 .TP 5
-\fB\-i\fR
+\fB-i\fR
 Analyze the initialization (\fBis1\fR, \fBis2\fR, \fBis3\fR), and reset
 (\fBrs1\fR, \fBrs2\fR, \fBrs3\fR), strings in the entry.  For each string, the
 code tries to analyze it into actions in terms of the other capabilities in the
@@ -275,6 +276,9 @@
 LL/home-down
 RSR/reset scroll region
 
+DECSTR/soft reset (VT320)
+S7C1T/7-bit controls (VT220)
+
 ISO DEC G0/enable DEC graphics for G0
 ISO UK G0/enable UK chars for G0
 ISO US G0/enable US chars for G0
@@ -286,6 +290,11 @@
 DECPNM/normal keypad mode
 DECANSI/enter ANSI mode
 
+ECMA[+-]AM/keyboard action mode
+ECMA[+-]IRM/insert replace mode
+ECMA[+-]SRM/send receive mode
+ECMA[+-]LNM/linefeed mode
+
 DEC[+-]CKM/application cursor keys
 DEC[+-]ANM/set VT52 mode
 DEC[+-]COLM/132-column mode
@@ -302,17 +311,17 @@
 
 An SGR0 designates an empty highlight sequence (equivalent to {SGR:NORMAL}).
 .TP 5
-\fB\-l\fR
+\fB-l\fR
 Set output format to terminfo.
 .TP 5
-\fB\-p\fR
+\fB-p\fR
 Ignore padding specifications when comparing strings.
 .TP 5
-\fB\-q\fR
+\fB-q\fR
 Make the comparison listing shorter by omitting subheadings, and using
 "-" for absent capabilities, "@" for canceled rather than "NULL".
 .TP 5
-\fB\-R\fR\fIsubset\fR
+\fB-R\fR\fIsubset\fR
 Restrict output to a given subset.  This option is for use with archaic
 versions of terminfo like those on SVr1, Ultrix, or HP/UX that do not support
 the full set of SVR4/XSI Curses terminfo; and variants such as AIX
@@ -321,8 +330,8 @@
 details.  You can also choose the subset "BSD" which selects only capabilities
 with termcap equivalents recognized by 4.4BSD.
 .TP
-\fB\-s \fR\fI[d|i|l|c]\fR
-The \fB\-s\fR option sorts the fields within each type according to the argument
+\fB-s \fR\fI[d|i|l|c]\fR
+The \fB-s\fR option sorts the fields within each type according to the argument
 below:
 .br
 .RS 5
@@ -340,59 +349,64 @@
 sort by the \fItermcap\fR name.
 .RE
 .IP
-If the \fB\-s\fR option is not given, the fields printed out will be
+If the \fB-s\fR option is not given, the fields printed out will be
 sorted alphabetically by the \fBterminfo\fR name within each type,
-except in the case of the \fB\-C\fR or the \fB\-L\fR options, which cause the
+except in the case of the \fB-C\fR or the \fB-L\fR options, which cause the
 sorting to be done by the \fBtermcap\fR name or the long C variable
 name, respectively.
 .TP 5
-\fB\-T\fR
+\fB-T\fR
 eliminates size-restrictions on the generated text.
 This is mainly useful for testing and analysis, since the compiled
 descriptions are limited (e.g., 1023 for termcap, 4096 for terminfo).
 .TP
-\fB\-t\fR
+\fB-t\fR
 tells \fBtic\fP to discard commented-out capabilities.
 Normally when translating from terminfo to termcap,
 untranslatable capabilities are commented-out.
 .TP 5
-\fB\-V\fR
+\fB-V\fR
 reports the version of ncurses which was used in this program, and exits.
 .TP 5
-\fB\-v\fR \fIn\fR
+\fB-v\fR \fIn\fR
 prints out tracing information on standard error as the program runs.
 Higher values of n induce greater verbosity.
 .TP 5
-\fB\-w\fR \fIwidth\fR
+\fB-w\fR \fIwidth\fR
 changes the output to \fIwidth\fR characters.
+.TP
+\fB-x\fR
+print information for user-defined capabilities.
+These are extensions to the terminfo repertoire which can be loaded
+using the \fB-x\fR option of \fBtic\fP.
 .SH FILES
 .TP 20
 \*d
 Compiled terminal description database.
 .SH EXTENSIONS
 The
-\fB\-E\fR,
-\fB\-F\fR,
-\fB\-G\fR,
-\fB\-R\fR,
-\fB\-T\fR,
-\fB\-V\fR,
-\fB\-a\fR,
-\fB\-e\fR,
-\fB\-f\fR,
-\fB\-g\fR,
-\fB\-i\fR,
-\fB\-l\fR,
-\fB\-p\fR,
-\fB\-q\fR and
-\fB\-t\fR
+\fB-E\fR,
+\fB-F\fR,
+\fB-G\fR,
+\fB-R\fR,
+\fB-T\fR,
+\fB-V\fR,
+\fB-a\fR,
+\fB-e\fR,
+\fB-f\fR,
+\fB-g\fR,
+\fB-i\fR,
+\fB-l\fR,
+\fB-p\fR,
+\fB-q\fR and
+\fB-t\fR
 options are not supported in SVr4 curses.
 
-The \fB\-r\fR option's notion of `termcap' capabilities is System V Release 4's.
+The \fB-r\fR option's notion of `termcap' capabilities is System V Release 4's.
 Actual BSD curses versions will have a more restricted set.  To see only the
-4.4BSD set, use \fB\-r\fR \fB\-RBSD\fR.
+4.4BSD set, use \fB-r\fR \fB-RBSD\fR.
 .SH BUGS
-The \fB\-F\fR option of \fBinfocmp\fR(1M) should be a \fBtoe\fR(1M) mode.
+The \fB-F\fR option of \fBinfocmp\fR(1M) should be a \fBtoe\fR(1M) mode.
 .SH SEE ALSO
 \fBinfocmp\fR(1M), \fBcaptoinfo\fR(1M), \fBinfotocap\fR(1M),
 \fBtic\fR(1M), \fBtoe\fR(1M),
diff -Naur ncurses-5.4.orig/man/infotocap.1m ncurses-5.4/man/infotocap.1m
--- ncurses-5.4.orig/man/infotocap.1m	2003-05-11 00:32:53.000000000 +0000
+++ ncurses-5.4/man/infotocap.1m	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1999-2000,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1999-2003,2004 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            *
@@ -27,40 +27,40 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: infotocap.1m,v 1.4 2003/05/11 00:32:53 tom Exp $
+.\" $Id: infotocap.1m,v 1.5 2004/07/05 13:16:08 tom Exp $
 .TH infotocap 1M ""
 .ds n 5
 .ds d @TERMINFO@
 .SH NAME
 \fBinfotocap\fR - convert a \fIterminfo\fR description into a \fItermcap\fR description
 .SH SYNOPSIS
-\fBinfotocap\fR [\fB\-v\fR\fIn\fR \fIwidth\fR]  [\fB\-V\fR] [\fB\-1\fR] [\fB\-w\fR \fIwidth\fR] \fIfile\fR . . .
+\fBinfotocap\fR [\fB-v\fR\fIn\fR \fIwidth\fR]  [\fB-V\fR] [\fB-1\fR] [\fB-w\fR \fIwidth\fR] \fIfile\fR . . .
 .SH DESCRIPTION
 \fBinfotocap\fR looks in \fIfile\fR for \fBterminfo\fR descriptions.  For each
 one found, an equivalent \fBtermcap\fR description is written to standard
 output.  Terminfo \fBuse\fR capabilities are translated directly to termcap
 \fBtc\fR capabilities.
 .TP 5
-\fB\-v\fR
+\fB-v\fR
 print out tracing information on standard error as the program runs.
 .TP 5
-\fB\-V\fR
+\fB-V\fR
 print out the version of the program in use on standard error and exit.
 .TP 5
-\fB\-1\fR
+\fB-1\fR
 cause the fields to print out one to a line.  Otherwise, the fields
 will be printed several to a line to a maximum width of 60
 characters.
 .TP 5
-\fB\-w\fR
+\fB-w\fR
 change the output to \fIwidth\fR characters.
 .SH FILES
 .TP 20
 \*d
 Compiled terminal description database.
 .SH NOTES
-This utility is actually a link to \fItic\fR(1M), running in \fI\-C\fR mode.
-You can use other \fItic\fR options such as \fB\-f\fR and  \fB\-x\fR.
+This utility is actually a link to \fItic\fR(1M), running in \fI-C\fR mode.
+You can use other \fItic\fR options such as \fB-f\fR and  \fB-x\fR.
 .SH SEE ALSO
 \fBcurses\fR(3X),
 \fBtic\fR(1M),
diff -Naur ncurses-5.4.orig/man/key_defined.3x ncurses-5.4/man/key_defined.3x
--- ncurses-5.4.orig/man/key_defined.3x	2003-05-17 23:24:45.000000000 +0000
+++ ncurses-5.4/man/key_defined.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 2003 Free Software Foundation, Inc.                        *
+.\" Copyright (c) 2003,2004 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            *
@@ -28,10 +28,10 @@
 .\"
 .\" Author: Thomas E. Dickey 2003
 .\"
-.\" $Id: key_defined.3x,v 1.2 2003/05/17 23:24:45 tom Exp $
+.\" $Id: key_defined.3x,v 1.3 2004/06/05 19:19:09 tom Exp $
 .TH key_defined 3X ""
 .SH NAME
-\fBdefine_key\fP \- define a keycode
+\fBkey_defined\fP \- check if a keycode is defined
 .SH SYNOPSIS
 \fB#include <curses.h>\fP
 
diff -Naur ncurses-5.4.orig/man/menu_spacing.3x ncurses-5.4/man/menu_spacing.3x
--- ncurses-5.4.orig/man/menu_spacing.3x	2001-08-04 20:36:16.000000000 +0000
+++ ncurses-5.4/man/menu_spacing.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1998,2001 Free Software Foundation, Inc.                   *
+.\" Copyright (c) 1998-2001,2004 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            *
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: menu_spacing.3x,v 1.6 2001/08/04 20:36:16 William.Setzer Exp $
+.\" $Id: menu_spacing.3x,v 1.8 2004/12/11 23:39:07 tom Exp $
 .TH menu_spacing 3X ""
 .SH NAME
 \fBmenu_spacing\fR - Control spacing between menu items.
@@ -51,7 +51,7 @@
 middle of this spacing area the pad character. The remaining parts are filled with
 spaces.
 \fBspc_rows\fR controls the number of rows that are used for an item. It must not be
-larger than 3. The menu system inserts then blank lines between item rows, these lines
+larger than 3. The menu system inserts the blank lines between item rows, these lines
 will contain the pad character in the appropriate positions.
 \fBspc_columns\fR controls the number of blanks between columns of items. It must not
 be larger than TABSIZE.
diff -Naur ncurses-5.4.orig/man/ncurses.3x ncurses-5.4/man/ncurses.3x
--- ncurses-5.4.orig/man/ncurses.3x	2004-01-11 01:45:54.000000000 +0000
+++ ncurses-5.4/man/ncurses.3x	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2004,2005 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            *
@@ -27,7 +27,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: ncurses.3x,v 1.70 2004/01/11 01:45:54 tom Exp $
+.\" $Id: ncurses.3x,v 1.74 2005/03/12 19:45:57 tom Exp $
 .hy 0
 .TH ncurses 3X ""
 .ds n 5
@@ -677,6 +677,13 @@
 If your application makes heavy use of multiple-clicking, you may
 wish to lengthen this default value because the timeout applies
 to the composed multi-click event as well as the individual clicks.
+.IP
+In addition to the environment variable,
+this implementation provides a global variable with the same name.
+Portable applications should not rely upon the presence of ESCDELAY
+in either form,
+but setting the environment variable rather than the global variable
+does not create problems when compiling an application.
 .TP 5
 HOME
 Tells \fBncurses\fR where your home directory is.
@@ -750,6 +757,24 @@
 disables output buffering, leaving the output in the original (usually
 line buffered) mode.
 .TP 5
+NCURSES_NO_UTF8_ACS
+During initialization, the \fBncurses\fR library
+checks for special cases where VT100 line-drawing (and the corresponding
+alternate character set capabilities) described in the terminfo are known
+to be missing.
+Specifically, when running in a UTF-8 locale,
+the Linux console emulator and the GNU screen program ignore these.
+Ncurses checks the TERM environment variable for these.
+For other special cases, you should set this environment variable.
+Doing this tells ncurses to use Unicode values which correspond to
+the VT100 line-drawing glyphs.
+That works for the special cases cited,
+and is likely to work for terminal emulators.
+.IP
+When setting this variable, you should set it to a nonzero value.
+Setting it to zero (or to a nonnumber)
+disables the special check for Linux and screen.
+.TP 5
 NCURSES_TRACE
 During initialization, the \fBncurses\fR debugging library
 checks the NCURSES_TRACE symbol.
@@ -828,7 +853,7 @@
 \fBterminfo\fR(\*n) and related pages whose names begin "curs_" for detailed routine
 descriptions.
 .SH EXTENSIONS
-The \fBncurses\fR library can be compiled with an option (\fB\-DUSE_GETCAP\fR)
+The \fBncurses\fR library can be compiled with an option (\fB-DUSE_GETCAP\fR)
 that falls back to the old-style /etc/termcap file if the terminal setup code
 cannot find a terminfo entry corresponding to \fBTERM\fR.  Use of this feature
 is not recommended, as it essentially includes an entire termcap compiler in
diff -Naur ncurses-5.4.orig/man/term.5 ncurses-5.4/man/term.5
--- ncurses-5.4.orig/man/term.5	2003-05-10 20:33:49.000000000 +0000
+++ ncurses-5.4/man/term.5	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2003,2004 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            *
@@ -26,7 +26,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: term.5,v 1.15 2003/05/10 20:33:49 jmc Exp $
+.\" $Id: term.5,v 1.16 2004/07/05 13:16:08 tom Exp $
 .TH TERM 5
 .ds n 5
 .ds d @TERMINFO@
@@ -83,7 +83,7 @@
 The first byte contains the least significant 8 bits of the value,
 and the second byte contains the most significant 8 bits.
 (Thus, the value represented is 256*second+first.)
-The value \-1 is represented by the two bytes 0377, 0377; other negative
+The value -1 is represented by the two bytes 0377, 0377; other negative
 values are illegal. This value generally
 means that the corresponding capability is missing from this terminal.
 Note that this format corresponds to the hardware of the \s-1VAX\s+1
@@ -112,11 +112,11 @@
 The numbers section is similar to the flags section.
 Each capability takes up two bytes,
 and is stored as a little-endian short integer.
-If the value represented is \-1, the capability is taken to be missing.
+If the value represented is -1, the capability is taken to be missing.
 .PP
 The strings section is also similar.
 Each capability is stored as a short integer, in the format above.
-A value of \-1 means the capability is missing.
+A value of -1 means the capability is missing.
 Otherwise, the value is taken as an offset from the beginning
 of the string table.
 Special characters in ^X or \ec notation are stored in their
diff -Naur ncurses-5.4.orig/man/terminfo.head ncurses-5.4/man/terminfo.head
--- ncurses-5.4.orig/man/terminfo.head	2002-08-17 23:37:10.000000000 +0000
+++ ncurses-5.4/man/terminfo.head	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2000,2002 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2002,2004 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            *
@@ -26,7 +26,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: terminfo.head,v 1.10 2002/08/17 23:37:10 tom Exp $
+.\" $Id: terminfo.head,v 1.12 2004/09/25 19:07:11 tom Exp $
 .TH TERMINFO 5 "" "" "File Formats"
 .ds n 5
 .ds d @TERMINFO@
@@ -59,6 +59,16 @@
 All names but the last should be in lower case and contain no blanks;
 the last name may well contain upper case and blanks for readability.
 .PP
+Lines beginning with a `#' in the first column are treated as comments.
+While comment lines are legal at any point, the output of \fIcaptoinfo\fP
+and \fIinfotocap\fP (aliases for \fItic\fP)
+will move comments so they occur only between entries.
+.PP
+Newlines and leading tabs may be used for formatting entries for readability.
+These are removed from parsed entries.
+The \fIinfocmp\ -f\fP option relies on this to format if-then-else expressions:
+the result can be read by \fItic\fP.
+.PP
 Terminal names (except for the last, verbose entry) should
 be chosen using the following conventions.
 The particular piece of hardware making up the terminal should
diff -Naur ncurses-5.4.orig/man/terminfo.tail ncurses-5.4/man/terminfo.tail
--- ncurses-5.4.orig/man/terminfo.tail	2003-01-05 22:47:05.000000000 +0000
+++ ncurses-5.4/man/terminfo.tail	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,6 @@
-.\" $Id: terminfo.tail,v 1.38 2003/01/05 22:47:05 tom Exp $
+.\" $Id: terminfo.tail,v 1.41 2004/07/05 13:08:56 tom Exp $
 .\" Beginning of terminfo.tail file
+.\" See "terminfo.head" for copyright.
 .ps +1
 .PP
 .SS A Sample Entry
@@ -271,22 +272,22 @@
 .DT
 .nf
 .ft CW
-.in -7
-	\s-133\||\|tty33\||\|tty\||\|model 33 teletype,
+.\".in -2
+\s-133\||\|tty33\||\|tty\||\|model 33 teletype,
 	bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os,\s+1
-.in +7
+.\".in +2
 .ft R
 .PP
-while the Lear Siegler \s-1ADM\-3\s0 is described as
+while the Lear Siegler \s-1ADM-3\s0 is described as
 .PP
 .DT
 .nf
 .ft CW
-.in -7
-	\s-1adm3\||\|3\||\|lsi adm3,
+.\".in -2
+\s-1adm3\||\|3\||\|lsi adm3,
 	am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
 	ind=^J, lines#24,\s+1
-.in +7
+.\".in +2
 .ft R
 .fi
 .PP
@@ -380,12 +381,24 @@
 add 1 to first two parameters (for ANSI terminals)
 .TP
 %? \fIexpr\fP %t \fIthenpart\fP %e \fIelsepart\fP %;
-if-then-else, %e \fIelsepart\fP is optional.
-else-if's are possible a la Algol 68:
-.br
+This forms an if-then-else.
+The %e \fIelsepart\fP is optional.
+Usually the %? \fIexpr\fP part pushes a value onto the stack,
+and %t pops it from the stack, testing if it is nonzero (true).
+If it is zero (false), control passes to the %e (else) part.
+.IP
+It is possible to form else-if's a la Algol 68:
+.RS
 %? c\d1\u %t b\d1\u %e c\d2\u %t b\d2\u %e c\d3\u %t b\d3\u %e c\d4\u %t b\d4\u %e %;
-.br
-c\di\u are conditions, b\di\u are bodies.
+.RE
+.IP
+where c\di\u are conditions, b\di\u are bodies.
+.IP
+Use the \fB-f\fP option of \fBtic\fP or \fBinfocmp\fP to see
+the structure of if-the-else's.
+Some strings, e.g., \fBsgr\fP can be very complicated when written
+on one line.
+The \fB-f\fP option splits the string into lines with the parts indented.
 .PP
 Binary operations are in postfix form with the operands in the usual order.
 That is, to get x-5 one would use "%gx%{5}%-".
@@ -801,6 +814,12 @@
 .fi
 .PP
 Remember that if you specify sgr, you must also specify sgr0.
+Also, some implementations rely on sgr being given if sgr0 is,
+Not all terminfo entries necessarily have an sgr string, however.
+Many terminfo entries are derived from termcap entries
+which have no sgr string.
+The only drawback to adding an sgr string is that termcap also
+assumes that sgr0 does not exit alternate character set mode.
 .PP
 Terminals with the ``magic cookie'' glitch
 .RB ( xmc )
@@ -1479,18 +1498,18 @@
 .SS Pitfalls of Long Entries
 .PP
 Long terminfo entries are unlikely to be a problem; to date, no entry has even
-approached terminfo's 4K string-table maximum.
+approached terminfo's 4096-byte string-table maximum.
 Unfortunately, the termcap
-translations are much more strictly limited (to 1K), thus termcap translations
+translations are much more strictly limited (to 1023 bytes), thus termcap translations
 of long terminfo entries can cause problems.
 .PP
-The man pages for 4.3BSD and older versions of tgetent() instruct the user to
-allocate a 1K buffer for the termcap entry.
+The man pages for 4.3BSD and older versions of \fBtgetent()\fP instruct the user to
+allocate a 1024-byte buffer for the termcap entry.
 The entry gets null-terminated by
 the termcap library, so that makes the maximum safe length for a termcap entry
 1k-1 (1023) bytes.
 Depending on what the application and the termcap library
-being used does, and where in the termcap file the terminal type that tgetent()
+being used does, and where in the termcap file the terminal type that \fBtgetent()\fP
 is searching for is, several bad things can happen.
 .PP
 Some termcap libraries print a warning message or exit if they find an
@@ -1511,7 +1530,7 @@
 affects more than just users of that particular terminal.
 This is the
 length of the entry as it exists in /etc/termcap, minus the
-backslash-newline pairs, which tgetent() strips out while reading it.
+backslash-newline pairs, which \fBtgetent()\fP strips out while reading it.
 Some termcap libraries strip off the final newline, too (GNU termcap does not).
 Now suppose:
 .TP 5
@@ -1527,12 +1546,12 @@
 if it's the entry it wants,
 .TP 5
 *
-and tgetent() is searching for a terminal type that either is the
+and \fBtgetent()\fP is searching for a terminal type that either is the
 long entry, appears in the termcap file after the long entry, or
-doesn't appear in the file at all (so that tgetent() has to search
+doesn't appear in the file at all (so that \fBtgetent()\fP has to search
 the whole termcap file).
 .PP
-Then tgetent() will overwrite memory, perhaps its stack, and probably core dump
+Then \fBtgetent()\fP will overwrite memory, perhaps its stack, and probably core dump
 the program.
 Programs like telnet are particularly vulnerable; modern telnets
 pass along values like the terminal type automatically.
@@ -1545,7 +1564,7 @@
 .PP
 The "after tc expansion" length will have a similar effect to the
 above, but only for people who actually set TERM to that terminal
-type, since tgetent() only does "tc" expansion once it's found the
+type, since \fBtgetent()\fP only does "tc" expansion once it's found the
 terminal type it was looking for, not while searching.
 .PP
 In summary, a termcap entry that is longer than 1023 bytes can cause,
@@ -1631,7 +1650,11 @@
 \*d/?/*
 files containing terminal descriptions
 .SH SEE ALSO
-\fBtic\fR(1M), \fBcurses\fR(3X), \fBprintf\fR(3S), \fBterm\fR(\*n).
+\fBtic\fR(1M),
+\fBinfocmp\fR(1M),
+\fBcurses\fR(3X),
+\fBprintf\fR(3S),
+\fBterm\fR(\*n).
 .SH AUTHORS
 Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
 Based on pcurses by Pavel Curtis.
diff -Naur ncurses-5.4.orig/man/tic.1m ncurses-5.4/man/tic.1m
--- ncurses-5.4.orig/man/tic.1m	2003-05-11 00:32:53.000000000 +0000
+++ ncurses-5.4/man/tic.1m	2005-05-13 04:09:58.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2004,2005 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            *
@@ -26,7 +26,7 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: tic.1m,v 1.35 2003/05/11 00:32:53 tom Exp $
+.\" $Id: tic.1m,v 1.38 2005/04/30 19:39:28 tom Exp $
 .TH tic 1M ""
 .ds n 5
 .ds d @TERMINFO@
@@ -34,7 +34,7 @@
 \fBtic\fR - the \fIterminfo\fR entry-description compiler
 .SH SYNOPSIS
 \fBtic\fR
-[\fB\-\
+[\fB-\
 1\
 C\
 G\
@@ -52,11 +52,11 @@
 t\
 x\
 \fR]
-[\fB\-e\fR \fInames\fR]
-[\fB\-o\fR \fIdir\fR]
-[\fB\-R\fR \fIsubset\fR]
-[\fB\-v\fR[\fIn\fR]]
-[\fB\-w\fR[\fIn\fR]]
+[\fB-e\fR \fInames\fR]
+[\fB-o\fR \fIdir\fR]
+[\fB-R\fR \fIsubset\fR]
+[\fB-v\fR[\fIn\fR]]
+[\fB-w\fR[\fIn\fR]]
 \fIfile\fR
 .br
 .SH DESCRIPTION
@@ -78,31 +78,33 @@
 directory first, look at \fI$HOME/.terminfo\fR if TERMINFO is not set, and
 finally look in \fI\*d\fR.
 .TP
-\fB\-1\fR
+\fB-1\fR
 restricts the output to a single column
 .TP
-\fB\-a\fR
+\fB-a\fR
 tells \fBtic\fP to retain commented-out capabilities rather than discarding
 them.  Capabilities are commented by prefixing them with a period.
-This sets the \fB\-x\fR option, because it treats the commented-out
+This sets the \fB-x\fR option, because it treats the commented-out
 entries as user-defined names.
+If the source is termcap, accept the 2-character names required by version 6.
+Otherwise these are ignored.
 .TP
-\fB\-C\fR
-Force source translation to termcap format.  Note: this differs from the \fB\-C\fR
+\fB-C\fR
+Force source translation to termcap format.  Note: this differs from the \fB-C\fR
 option of \fIinfocmp\fR(1M) in that it does not merely translate capability
 names, but also translates terminfo strings to termcap format.  Capabilities
 that are not translatable are left in the entry under their terminfo names
 but commented out with two preceding dots.
 .TP
-\fB\-c\fR
+\fB-c\fR
 tells \fBtic\fP to only check \fIfile\fR for errors, including syntax problems and
-bad use links.  If you specify \fB\-C\fR (\fB\-I\fR) with this option, the code
+bad use links.  If you specify \fB-C\fR (\fB-I\fR) with this option, the code
 will print warnings about entries which, after use resolution, are more than
 1023 (4096) bytes long.  Due to a fixed buffer length in older termcap
 libraries (and a documented limit in terminfo), these entries may cause core
 dumps.
 .TP
-\fB\-e \fR\fInames\fR
+\fB-e \fR\fInames\fR
 Limit writes and translations to the following comma-separated list of
 terminals.
 If any name or alias of a terminal matches one of the names in
@@ -110,28 +112,28 @@
 Otherwise no output will be generated for it.
 The option value is interpreted as a file containing the list if it
 contains a '/'.
-(Note: depending on how tic was compiled, this option may require \fB\-I\fR or \fB\-C\fR.)
+(Note: depending on how tic was compiled, this option may require \fB-I\fR or \fB-C\fR.)
 .TP
-\fB\-f\fR
+\fB-f\fR
 Display complex terminfo strings which contain if/then/else/endif expressions
 indented for readability.
 .TP
-\fB\-G\fR
+\fB-G\fR
 Display constant literals in decimal form
 rather than their character equivalents.
 .TP
-\fB\-g\fR
+\fB-g\fR
 Display constant character literals in quoted form
 rather than their decimal equivalents.
 .TP
-\fB\-I\fR
+\fB-I\fR
 Force source translation to terminfo format.
 .TP
-\fB\-L\fR
+\fB-L\fR
 Force source translation to terminfo format
 using the long C variable names listed in <\fBterm.h\fR>
 .TP
-\fB\-N\fR
+\fB-N\fR
 Disable smart defaults. 
 Normally, when translating from termcap to terminfo, the compiler makes
 a number of assumptions about the defaults of string capabilities
@@ -143,42 +145,42 @@
 This option forces a more literal translation that also preserves the
 obsolete capabilities.
 .TP
-\fB\-o\fR\fIdir\fR
+\fB-o\fR\fIdir\fR
 Write compiled entries to given directory.  Overrides the TERMINFO environment
 variable.
 .TP
-\fB\-R\fR\fIsubset\fR
+\fB-R\fR\fIsubset\fR
 Restrict output to a given subset.  This option is for use with archaic
 versions of terminfo like those on SVr1, Ultrix, or HP/UX that do not support
 the full set of SVR4/XSI Curses terminfo; and outright broken ports like AIX 3.x
 that have their own extensions incompatible with SVr4/XSI.  Available subsets
 are "SVr1", "Ultrix", "HP", "BSD" and "AIX"; see \fBterminfo\fR(\*n) for details.
 .TP
-\fB\-r\fR
+\fB-r\fR
 Force entry resolution (so there are no remaining tc capabilities) even
 when doing translation to termcap format.  This may be needed if you are
 preparing a termcap file for a termcap library (such as GNU termcap through
 version 1.3 or BSD termcap through 4.3BSD) that does not handle multiple
 tc capabilities per entry.
 .TP
-\fB\-s\fR
+\fB-s\fR
 Summarize the compile by showing the directory into which entries
 are written, and the number of entries which are compiled.
 .TP
-\fB\-T\fR
+\fB-T\fR
 eliminates size-restrictions on the generated text.
 This is mainly useful for testing and analysis, since the compiled
 descriptions are limited (e.g., 1023 for termcap, 4096 for terminfo).
 .TP
-\fB\-t\fR
+\fB-t\fR
 tells \fBtic\fP to discard commented-out capabilities.
 Normally when translating from terminfo to termcap,
 untranslatable capabilities are commented-out.
 .TP
-\fB\-V\fR
+\fB-V\fR
 reports the version of ncurses which was used in this program, and exits.
 .TP
-\fB\-v\fR\fIn\fR
+\fB-v\fR\fIn\fR
 specifies that (verbose) output be written to standard error trace
 information showing \fBtic\fR's progress.  The optional integer
 \fIn\fR is a number from 1 to 10, inclusive, indicating the desired
@@ -186,14 +188,16 @@
 level is 1.  If \fIn\fR is specified and greater than 1, the level of
 detail is increased.
 .TP
-\fB\-w\fR\fIn\fR
+\fB-w\fR\fIn\fR
 specifies the width of the output.
 .TP
-\fB\-x\fR
+\fB-x\fR
 Treat unknown capabilities as user-defined.
 That is, if you supply a capability name which \fBtic\fP does not recognize,
 it will infer its type (boolean, number or string) from the syntax and
 make an extended table entry for that.
+User-defined capability strings
+whose name begins with ``k'' are treated as function keys.
 .TP
 \fIfile\fR
 contains one or more \fBterminfo\fR terminal descriptions in source
@@ -274,25 +278,25 @@
 error messages, and can be parsed by GNU Emacs's compile facility.
 
 The
-\fB\-C\fR,
-\fB\-G\fR,
-\fB\-I\fR,
-\fB\-N\fR,
-\fB\-R\fR,
-\fB\-T\fR,
-\fB\-V\fR,
-\fB\-a\fR,
-\fB\-e\fR,
-\fB\-f\fR,
-\fB\-g\fR,
-\fB\-o\fR,
-\fB\-r\fR,
-\fB\-s\fR,
-\fB\-t\fR and
-\fB\-x\fR
+\fB-C\fR,
+\fB-G\fR,
+\fB-I\fR,
+\fB-N\fR,
+\fB-R\fR,
+\fB-T\fR,
+\fB-V\fR,
+\fB-a\fR,
+\fB-e\fR,
+\fB-f\fR,
+\fB-g\fR,
+\fB-o\fR,
+\fB-r\fR,
+\fB-s\fR,
+\fB-t\fR and
+\fB-x\fR
 options
 are not supported under SVr4.
-The SVr4 \fB\-c\fR mode does not report bad use links.
+The SVr4 \fB-c\fR mode does not report bad use links.
 
 System V does not compile entries to or read entries from your
 \fI$HOME/.terminfo\fR directory unless TERMINFO is explicitly set to it.
diff -Naur ncurses-5.4.orig/man/toe.1m ncurses-5.4/man/toe.1m
--- ncurses-5.4.orig/man/toe.1m	2003-05-11 00:32:53.000000000 +0000
+++ ncurses-5.4/man/toe.1m	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2003,2004 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            *
@@ -26,45 +26,45 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: toe.1m,v 1.12 2003/05/11 00:32:53 tom Exp $
+.\" $Id: toe.1m,v 1.13 2004/07/05 13:16:08 tom Exp $
 .TH toe 1M ""
 .ds n 5
 .ds d @TERMINFO@
 .SH NAME
 \fBtoe\fR - table of (terminfo) entries
 .SH SYNOPSIS
-\fBtoe\fR [\fB\-v\fR[\fIn\fR]] [\fB\-huUV\fR] \fIfile...\fR
+\fBtoe\fR [\fB-v\fR[\fIn\fR]] [\fB-huUV\fR] \fIfile...\fR
 .br
 .SH DESCRIPTION
 .PP
 With no options, \fBtoe\fR lists all available terminal types by primary name
 with descriptions.  File arguments specify the directories to be scanned; if no
 such arguments are given, your default terminfo directory is scanned.  If you
-also specify the \fB\-h\fR option, a directory header will be issued as each
+also specify the \fB-h\fR option, a directory header will be issued as each
 directory is entered.
 .PP
 There are other options intended for use by terminfo file maintainers:
 .TP
-\fB\-u\fR \fIfile\fR
+\fB-u\fR \fIfile\fR
 says to issue a report on dependencies in the given file. This report condenses
 the `use' relation: each line consists of the primary name of a terminal that
 has use capabilities, followed by a colon, followed by the
 whitespace-separated primary names of all terminals which occur in those use
 capabilities, followed by a newline
 .TP
-\fB\-U\fR \fIfile\fR
+\fB-U\fR \fIfile\fR
 says to issue a report on reverse dependencies in the given file. This report
 reverses the `use' relation: each line consists of the primary name of a
 terminal that occurs in use capabilities, followed by a colon, followed by the
 whitespace-separated primary names of all terminals which depend on it,
 followed by a newline.
 .TP
-\fB\-v\fR\fIn\fR
+\fB-v\fR\fIn\fR
 specifies that (verbose) output be written to standard error trace
 information showing \fBtoe\fR's progress.  The optional integer
 \fIn\fR is a number from 1 to 10, interpreted as for \fBtic\fR(1).
 .TP 5
-\fB\-V\fR
+\fB-V\fR
 reports the version of ncurses which was used in this program, and exits.
 .SH FILES
 .TP 5
diff -Naur ncurses-5.4.orig/man/tput.1 ncurses-5.4/man/tput.1
--- ncurses-5.4.orig/man/tput.1	2003-05-11 00:32:53.000000000 +0000
+++ ncurses-5.4/man/tput.1	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
 '\" t
 .\"***************************************************************************
-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2004,2005 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            *
@@ -27,70 +27,84 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: tput.1,v 1.20 2003/05/11 00:32:53 tom Exp $
+.\" $Id: tput.1,v 1.22 2005/01/08 17:44:26 tom Exp $
 .TH tput 1 ""
 .ds d @TERMINFO@
 .ds n 1
 .SH NAME
 \fBtput\fR, \fBreset\fR - initialize a terminal or query terminfo database
 .SH SYNOPSIS
-\fBtput\fR [\fB\-T\fR\fItype\fR] \fIcapname\fR [\fIparms\fR ... ]
+\fBtput\fR [\fB-T\fR\fItype\fR] \fIcapname\fR [\fIparms\fR ... ]
 .br
-\fBtput\fR [\fB\-T\fR\fItype\fR] \fBinit\fR
+\fBtput\fR [\fB-T\fR\fItype\fR] \fBinit\fR
 .br
-\fBtput\fR [\fB\-T\fR\fItype\fR] \fBreset\fR
+\fBtput\fR [\fB-T\fR\fItype\fR] \fBreset\fR
 .br
-\fBtput\fR [\fB\-T\fR\fItype\fR] \fBlongname\fR
+\fBtput\fR [\fB-T\fR\fItype\fR] \fBlongname\fR
 .br
-\fBtput \-S\fR  \fB<<\fR
+\fBtput -S\fR  \fB<<\fR
 .br
-\fBtput \-V\fR
+\fBtput -V\fR
 .br
 .SH DESCRIPTION
 The \fBtput\fR utility uses the \fBterminfo\fR database to make the
 values of terminal-dependent capabilities and information available to
 the shell (see \fBsh\fR(1)), to initialize or reset the terminal, or
-return the long name of the requested terminal type.  \fBtput\fR
-outputs a string if the attribute (\fIcap\fRability \fIname\fR) is of
-type string, or an integer if the attribute is of type integer.  If
-the attribute is of type boolean, \fBtput\fR simply sets the exit code
-(\fB0\fR for TRUE if the terminal has the capability, \fB1\fR for
-FALSE if it does not), and produces no output.  Before using a value
-returned on standard output, the user should test the exit code
-[\fB$?\fR, see \fBsh\fR(1)] to be sure it is \fB0\fR.
+return the long name of the requested terminal type.
+The result depends upon the capability's type:
+.RS
+.TP 5
+string
+\fBtput\fR writes the string to the standard output.
+No trailing newline is supplied.
+.TP
+integer
+\fBtput\fR writes the decimal value to the standard output,
+with a trailing newline.
+.TP
+boolean
+\fBtput\fR simply sets the exit code
+(\fB0\fR for TRUE if the terminal has the capability,
+\fB1\fR for FALSE if it does not),
+and writes nothing to the standard output.
+.RE
+.PP
+Before using a value returned on the standard output,
+the application should test the exit code
+(e.g., \fB$?\fR, see \fBsh\fR(1)) to be sure it is \fB0\fR.
 (See the \fBEXIT CODES\fR and \fBDIAGNOSTICS\fR sections.)
 For a complete list of capabilities
 and the \fIcapname\fR associated with each, see \fBterminfo\fR(\*n).
 .TP
-\fB\-T\fR\fItype\fR
+\fB-T\fR\fItype\fR
 indicates the \fItype\fR of terminal.  Normally this option is
 unnecessary, because the default is taken from the environment
-variable \fBTERM\fR.  If \fB\-T\fR is specified, then the shell
+variable \fBTERM\fR.  If \fB-T\fR is specified, then the shell
 variables \fBLINES\fR and \fBCOLUMNS\fR will be ignored,and the
 operating system will not be queried for the actual screen size.
 .TP
 \fIcapname\fR
-indicates the attribute from the \fBterminfo\fR database.  When
+indicates the capability from the \fBterminfo\fR database.  When
 \fBtermcap\fR support is compiled in, the \fBtermcap\fR name for
-the attribute is also accepted.
+the capability is also accepted.
 .TP
 \fIparms\fR
-If the attribute is a string that takes parameters, the arguments
+If the capability is a string that takes parameters, the arguments
 \fIparms\fR will be instantiated into the string.
-An all-numeric argument will be passed to the attribute as a number.
 .IP
+Most parameters are numbers.
 Only a few terminfo capabilities require string parameters;
 \fBtput\fR uses a table to decide which to pass as strings.
 Normally \fBtput\fR uses \fBtparm\fR (3X) to perform the substitution.
-If no parameters are given for the attribute,
+If no parameters are given for the capability,
 \fBtput\fR writes the string without performing the substitution.
 .TP
-\fB\-S\fR
+\fB-S\fR
 allows more than one capability per invocation of \fBtput\fR.  The
 capabilities must be passed to \fBtput\fR from the standard input
 instead of from the command line (see example).
 Only one \fIcapname\fR is allowed per line.
-The \fB\-S\fR option changes the
+The \fB-S\fR option changes the
 meaning of the \fB0\fR and \fB1\fR boolean and string exit codes (see the
 EXIT CODES section).
 .IP
@@ -98,12 +112,12 @@
 to decide whether to use \fBtparm\fR (3X),
 and how to interpret the parameters.
 .TP
-\fB\-V\fR
+\fB-V\fR
 reports the version of ncurses which was used in this program, and exits.
 .TP
 \fBinit\fR
 If the \fBterminfo\fR database is present and an entry for the user's
-terminal exists (see \fB\-T\fR\fItype\fR, above), the following will
+terminal exists (see \fB-T\fR\fItype\fR, above), the following will
 occur: (1) if present, the terminal's initialization strings will be
 output (\fBis1\fR, \fBis2\fR, \fBis3\fR, \fBif\fR, \fBiprog\fR), (2)
 any delays (e.g., newline) specified in the entry will be set in the
@@ -122,7 +136,7 @@
 .TP
 \fBlongname\fR
 If the \fBterminfo\fR database is present and an entry for the
-user's terminal exists (see \fB\-T\fR\fItype\fR above), then the long name
+user's terminal exists (see \fB-T\fR\fItype\fR above), then the long name
 of the terminal will be put out.  The long name is the last
 name in the first line of the terminal's description in the
 \fBterminfo\fR database [see \fBterm\fR(5)].
@@ -139,7 +153,7 @@
 the environmental variable \fBTERM\fR has been exported, as
 illustrated on the \fBprofile\fR(5) manual page.
 .TP 5
-\fBtput \-T5620 reset\fR
+\fBtput -T5620 reset\fR
 Reset an AT&T 5620 terminal, overriding the type of
 terminal in the environmental variable \fBTERM\fR.
 .TP 5
@@ -154,7 +168,7 @@
 \fBtput cols\fR
 Print the number of columns for the current terminal.
 .TP 5
-\fBtput \-T450 cols\fR
+\fBtput -T450 cols\fR
 Print the number of columns for the 450 terminal.
 .TP 5
 \fBbold=`tput smso` offbold=`tput rmso`\fR
@@ -178,7 +192,7 @@
 variable \fBTERM\fR.
 .PP
 .RS 5
-\fBtput \-S <<!\fR
+\fBtput -S <<!\fR
 .br
 \fB> clear\fR
 .br
@@ -200,12 +214,6 @@
 \fB\*d\fR
 compiled terminal description database
 .TP
-\fB/usr/include/curses.h\fR
-\fBcurses\fR(3X) header file
-.TP
-\fB/usr/include/term.h\fR
-\fBterminfo\fR header file
-.TP
 \fB@DATADIR@/tabset/*\fR
 tab settings for some terminals, in a format
 appropriate to be output to the terminal (escape
@@ -213,7 +221,7 @@
 information, see the "Tabs and Initialization"
 section of \fBterminfo\fR(5)
 .SH EXIT CODES
-If the \fB\-S\fR option is used,
+If the \fB-S\fR option is used,
 \fBtput\fR checks for errors from each line,
 and if any errors are found, will set the exit code to 4 plus the
 number of lines with errors.
@@ -221,7 +229,7 @@
 No indication of which line failed can be given so
 exit code \fB1\fR will never appear.  Exit codes \fB2\fR, \fB3\fR, and
 \fB4\fR retain their usual interpretation.
-If the \fB\-S\fR option is not used,
+If the \fB-S\fR option is not used,
 the exit code depends on the type of \fIcapname\fR:
 .RS 5
 .TP
@@ -241,7 +249,7 @@
 whether or not \fIcapname\fR is defined for this terminal \fItype\fR.
 To determine if \fIcapname\fR is defined for this terminal \fItype\fR,
 the user must test the value written to standard output.
-A value of \fB\-1\fR
+A value of \fB-1\fR
 means that \fIcapname\fR is not defined for this terminal \fItype\fR.
 .TP
 .I other
@@ -262,17 +270,17 @@
 \fB0\fR	T{
 (\fIcapname\fR is a numeric variable that is not specified in the
 \fBterminfo\fR(\*n) database for this terminal type, e.g.
-\fBtput \-T450 lines\fR and \fBtput \-T2621 xmc\fR)
+\fBtput -T450 lines\fR and \fBtput -T2621 xmc\fR)
 T}
 \fB1\fR	no error message is printed, see the \fBEXIT CODES\fR section.
 \fB2\fR	usage error
 \fB3\fR	unknown terminal \fItype\fR or no \fBterminfo\fR database
 \fB4\fR	unknown \fBterminfo\fR capability \fIcapname\fR
-\fB>4\fR	error occurred in \-S
+\fB>4\fR	error occurred in -S
 =
 .TE
 .SH PORTABILITY
-The \fBlongname\fR and \fB\-S\fR options, and the parameter-substitution
+The \fBlongname\fR and \fB-S\fR options, and the parameter-substitution
 features used in the \fBcup\fR example, are not supported in BSD curses or in
 AT&T/USL curses before SVr4.
 .SH SEE ALSO
diff -Naur ncurses-5.4.orig/man/tset.1 ncurses-5.4/man/tset.1
--- ncurses-5.4.orig/man/tset.1	2003-05-11 00:32:53.000000000 +0000
+++ ncurses-5.4/man/tset.1	2005-05-13 04:09:52.000000000 +0000
@@ -1,5 +1,5 @@
 .\"***************************************************************************
-.\" Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
+.\" Copyright (c) 1998-2004,2005 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            *
@@ -26,14 +26,14 @@
 .\" authorization.                                                           *
 .\"***************************************************************************
 .\"
-.\" $Id: tset.1,v 1.13 2003/05/11 00:32:53 tom Exp $
+.\" $Id: tset.1,v 1.15 2005/03/20 18:27:09 tom Exp $
 .TH tset 1 ""
 .SH NAME
 \fBtset\fR, \fBreset\fR - terminal initialization
 .SH SYNOPSIS
-tset [\-IQVqrs] [\-] [\-e \fIch\fR] [\-i \fIch\fR] [\-k \fIch\fR] [\-m \fImapping\fR] [\fIterminal\fR]
+\fBtset\fR [\fB-IQVcqrsw\fR] [\fB-\fR] [\fB-e\fR \fIch\fR] [\fB-i\fR \fIch\fR] [\fB-k\fR \fIch\fR] [\fB-m\fR \fImapping\fR] [\fIterminal\fR]
 .br
-reset [\-IQVqrs] [\-] [\-e \fIch\fR] [\-i \fIch\fR] [\-k \fIch\fR] [\-m \fImapping\fR] [\fIterminal\fR]
+\fBreset\fR [\fB-IQVcqrsw\fR] [\fB-\fR] [\fB-e\fR \fIch\fR] [\fB-i\fR \fIch\fR] [\fB-k\fR \fIch\fR] [\fB-m\fR \fImapping\fR] [\fIterminal\fR]
 .SH DESCRIPTION
 \&\fBTset\fR initializes terminals.
 \fBTset\fR first determines the type of terminal that you are using.
@@ -50,8 +50,10 @@
 .PP
 4. The default terminal type, ``unknown''.
 .PP
-If the terminal type was not specified on the command-line, the \fB\-m\fR
-option mappings are then applied (see below for more information).
+If the terminal type was not specified on the command-line, the \fB-m\fR
+option mappings are then applied (see the section
+.B TERMINAL TYPE MAPPING
+for more information).
 Then, if the terminal type begins with a question mark (``?''), the
 user is prompted for confirmation of the terminal type.  An empty
 response confirms the type, or, another type can be entered to specify
@@ -65,6 +67,9 @@
 Finally, if the erase, interrupt and line kill characters have changed,
 or are not set to their default values, their values are displayed to the
 standard error output.
+Use the \fB-c\fP or \fB-w\fP option to select only the window sizing
+versus the other initialization.
+If neither option is given, both are assumed.
 .PP
 When invoked as \fBreset\fR, \fBtset\fR sets cooked and echo modes,
 turns off cbreak and raw modes, turns on newline translation and
@@ -81,50 +86,64 @@
 .PP
 The options are as follows:
 .TP 5
-.B \-q
-The terminal type is displayed to the standard output, and the terminal is
-not initialized in any way.  The option `-' by itself is equivalent but
-archaic.
-.TP
-.B \-e
+.B -c
+Set control characters and modes.
+.B -e
 Set the erase character to \fIch\fR.
 .TP
-.B \-I
+.B -I
 Do not send the terminal or tab initialization strings to the terminal.
 .TP
-.B \-Q
-Don't display any values for the erase, interrupt and line kill characters.
-.TP
-.B \-V
-reports the version of ncurses which was used in this program, and exits.
-.TP
-.B \-i
+.B -i
 Set the interrupt character to \fIch\fR.
 .TP
-.B \-k
+.B -k
 Set the line kill character to \fIch\fR.
 .TP
-.B \-m
+.B -m
 Specify a mapping from a port type to a terminal.
-See below for more information.
+See the section
+.B TERMINAL TYPE MAPPING
+for more information.
+.TP
+.B -Q
+Do not display any values for the erase, interrupt and line kill characters.
+Normally \fBtset\fR displays the values for control characters which
+differ from the system's default values.
 .TP
-.B \-r
+.B -q
+The terminal type is displayed to the standard output, and the terminal is
+not initialized in any way.  The option `-' by itself is equivalent but
+archaic.
+.TP
+.B -r
 Print the terminal type to the standard error output.
 .TP
-.B \-s
+.B -s
 Print the sequence of shell commands to initialize the environment variable
 \fBTERM\fR to the standard output.
-See the section below on setting the environment for details.
+See the section
+.B SETTING THE ENVIRONMENT
+for details.
+.TP
+.B -V
+reports the version of ncurses which was used in this program, and exits.
+.TP
+.B -w
+Resize the window to match the size deduced via \fBsetupterm\fP.
+Normally this has no effect,
+unless \fBsetupterm\fP is not able to detect the window size.
 .PP
 The arguments for the \fB-e\fR, \fB-i\fR, and \fB-k\fR
 options may either be entered as actual characters or by using the `hat'
 notation, i.e. control-h may be specified as ``^H'' or ``^h''.
+.
 .SH SETTING THE ENVIRONMENT
 It is often desirable to enter the terminal type and information about
 the terminal's capabilities into the shell's environment.
-This is done using the \fB\-s\fR option.
+This is done using the \fB-s\fR option.
 .PP
-When the \fB\-s\fR option is specified, the commands to enter the information
+When the \fB-s\fR option is specified, the commands to enter the information
 into the shell's environment are written to the standard output.  If
 the \fBSHELL\fR environmental variable ends in ``csh'', the commands
 are for \fBcsh\fR, otherwise, they are for \fBsh\fR.
@@ -132,7 +151,7 @@
 \fBnoglob\fR, leaving it unset.  The following line in the \fB.login\fR
 or \fB.profile\fR files will initialize the environment correctly:
 
-    eval \`tset \-s options ... \`
+    eval \`tset -s options ... \`
 
 .SH TERMINAL TYPE MAPPING
 When the terminal is not hardwired into the system (or the current
@@ -142,13 +161,13 @@
 When \fBtset\fR is used in a startup script it is often desirable to
 provide information about the type of terminal used on such ports.
 .PP
-The purpose of the \fB\-m\fR option is to map
+The purpose of the \fB-m\fR option is to map
 from some set of conditions to a terminal type, that is, to
 tell \fBtset\fR
 ``If I'm on this port at a particular speed, guess that I'm on that
 kind of terminal''.
 .PP
-The argument to the \fB\-m\fR option consists of an optional port type, an
+The argument to the \fB-m\fR option consists of an optional port type, an
 optional operator, an optional baud rate specification, an optional
 colon (``:'') character and a terminal type.  The port type is a
 string (delimited by either the operator or the colon character).  The
@@ -159,7 +178,7 @@
 of the standard error output (which should be the control terminal).
 The terminal type is a string.
 .PP
-If the terminal type is not specified on the command line, the \fB\-m\fR
+If the terminal type is not specified on the command line, the \fB-m\fR
 mappings are applied to the terminal type.  If the port type and baud
 rate match the mapping, the terminal type specified in the mapping
 replaces the current type.  If more than one mapping is specified, the
@@ -174,16 +193,16 @@
 .PP
 If no baud rate is specified, the terminal type will match any baud rate.
 If no port type is specified, the terminal type will match any port type.
-For example, \fB\-m dialup:vt100 \-m :?xterm\fR
+For example, \fB-m dialup:vt100 -m :?xterm\fR
 will cause any dialup port, regardless of baud rate, to match the terminal
 type vt100, and any non-dialup port type to match the terminal type ?xterm.
 Note, because of the leading question mark, the user will be
 queried on a default port as to whether they are actually using an xterm
 terminal.
 .PP
-No whitespace characters are permitted in the \fB\-m\fR option argument.
+No whitespace characters are permitted in the \fB-m\fR option argument.
 Also, to avoid problems with meta-characters, it is suggested that the
-entire \fB\-m\fR option argument be placed within single quote characters,
+entire \fB-m\fR option argument be placed within single quote characters,
 and that \fBcsh\fR users insert a backslash character (``\e'') before
 any exclamation marks (``!'').
 .SH HISTORY
@@ -197,33 +216,33 @@
 \fBtset\fR's most important use).  This implementation behaves like 4.4BSD
 tset, with a few exceptions specified here.
 .PP
-The \fB\-S\fR option of BSD tset no longer works; it prints an error message to stderr
-and dies.  The \fB\-s\fR option only sets \fBTERM\fR, not \fBTERMCAP\fP.  Both these
+The \fB-S\fR option of BSD tset no longer works; it prints an error message to stderr
+and dies.  The \fB-s\fR option only sets \fBTERM\fR, not \fBTERMCAP\fP.  Both these
 changes are because the \fBTERMCAP\fR variable is no longer supported under
-terminfo-based \fBncurses\fR, which makes \fBtset \-S\fR useless (we made it die
+terminfo-based \fBncurses\fR, which makes \fBtset -S\fR useless (we made it die
 noisily rather than silently induce lossage).
 .PP
 There was an undocumented 4.4BSD feature that invoking tset via a link named
 `TSET` (or via any other name beginning with an upper-case letter) set the
 terminal to use upper-case only.  This feature has been omitted.
 .PP
-The \fB\-A\fR, \fB\-E\fR, \fB\-h\fR, \fB\-u\fR and \fB\-v\fR
+The \fB-A\fR, \fB-E\fR, \fB-h\fR, \fB-u\fR and \fB-v\fR
 options were deleted from the \fBtset\fR
 utility in 4.4BSD.
 None of them were documented in 4.3BSD and all are
 of limited utility at best.
-The \fB\-a\fR, -\fB\d\fR, and -\fB\p\fR options are similarly
+The \fB-a\fR, \fB-d\fR, and \fB-p\fR options are similarly
 not documented or useful, but were retained as they appear to be in
 widespread use.  It is strongly recommended that any usage of these
-three options be changed to use the \fB\-m\fR option instead.  The
--n option remains, but has no effect.  The \fB\-adnp\fR options are therefore
+three options be changed to use the \fB-m\fR option instead.  The
+-n option remains, but has no effect.  The \fB-adnp\fR options are therefore
 omitted from the usage summary above.
 .PP
-It is still permissible to specify the \fB\-e\fR, \fB\-i\fR, and \fB\-k\fR options without
+It is still permissible to specify the \fB-e\fR, \fB-i\fR, and \fB-k\fR options without
 arguments, although it is strongly recommended that such usage be fixed to
 explicitly specify the character.
 .PP
-As of 4.4BSD, executing \fBtset\fR as \fBreset\fR no longer implies the \fB\-Q\fR
+As of 4.4BSD, executing \fBtset\fR as \fBreset\fR no longer implies the \fB-Q\fR
 option.  Also, the interaction between the - option and the \fIterminal\fR
 argument in some historic implementations of \fBtset\fR has been removed.
 .SH ENVIRONMENT
@@ -240,6 +259,7 @@
 csh(1),
 sh(1),
 stty(1),
+setupterm(3),
 tty(4),
 termcap(5),
 ttys(5),
diff -Naur ncurses-5.4.orig/menu/Makefile.in ncurses-5.4/menu/Makefile.in
--- ncurses-5.4.orig/menu/Makefile.in	2003-11-01 22:44:33.000000000 +0000
+++ ncurses-5.4/menu/Makefile.in	2005-05-13 04:09:50.000000000 +0000
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.41 2003/11/01 22:44:33 tom Exp $
+# $Id: Makefile.in,v 1.42 2004/12/11 23:33:16 tom Exp $
 ##############################################################################
 # Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
 #                                                                            #
@@ -79,7 +79,7 @@
 CPP		= @CPP@
 CFLAGS		= @CFLAGS@
 
-CPPFLAGS	= -DHAVE_CONFIG_H @CPPFLAGS@
+CPPFLAGS	= -I@top_srcdir@/ncurses -DHAVE_CONFIG_H @CPPFLAGS@
 
 CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
 
diff -Naur ncurses-5.4.orig/menu/llib-lmenu ncurses-5.4/menu/llib-lmenu
--- ncurses-5.4.orig/menu/llib-lmenu	2002-08-31 20:00:48.000000000 +0000
+++ ncurses-5.4/menu/llib-lmenu	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999,2002 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1999-2002,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 1996-1999,2002              *
+ *  Author: Thomas E. Dickey        1996-2002,2005                          *
  ****************************************************************************/
 /* LINTLIBRARY */
 
@@ -132,6 +132,11 @@
 		MENU	*menu)
 		{ /* void */ }
 
+#undef _nc_Calculate_Text_Width
+int	_nc_Calculate_Text_Width(
+		const TEXT *item)
+		{ return(*(int *)0); }
+
 #undef _nc_Calculate_Item_Length_and_Width
 void	_nc_Calculate_Item_Length_and_Width(
 		MENU	*menu)
@@ -481,6 +486,38 @@
 		const MENU *menu)
 		{ return(*(WINDOW **)0); }
 
+/* ./m_trace.c */
+
+#undef _nc_retrace_item
+ITEM	*_nc_retrace_item(
+		ITEM	*code)
+		{ return(*(ITEM **)0); }
+
+#undef _nc_retrace_item_ptr
+ITEM	**_nc_retrace_item_ptr(
+		ITEM	**code)
+		{ return(*(ITEM ***)0); }
+
+#undef _nc_retrace_item_opts
+Item_Options _nc_retrace_item_opts(
+		Item_Options code)
+		{ return(*(Item_Options *)0); }
+
+#undef _nc_retrace_menu
+MENU	*_nc_retrace_menu(
+		MENU	*code)
+		{ return(*(MENU **)0); }
+
+#undef _nc_retrace_menu_hook
+Menu_Hook _nc_retrace_menu_hook(
+		Menu_Hook code)
+		{ return(*(Menu_Hook *)0); }
+
+#undef _nc_retrace_menu_opts
+Menu_Options _nc_retrace_menu_opts(
+		Menu_Options code)
+		{ return(*(Menu_Options *)0); }
+
 /* ./m_userptr.c */
 
 #undef set_menu_userptr
diff -Naur ncurses-5.4.orig/menu/llib-lmenuw ncurses-5.4/menu/llib-lmenuw
--- ncurses-5.4.orig/menu/llib-lmenuw	2002-08-31 21:54:21.000000000 +0000
+++ ncurses-5.4/menu/llib-lmenuw	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2002,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 2002                        *
+ *  Author: Thomas E. Dickey                    2002,2005                   *
  ****************************************************************************/
 /* LINTLIBRARY */
 
@@ -132,6 +132,11 @@
 		MENU	*menu)
 		{ /* void */ }
 
+#undef _nc_Calculate_Text_Width
+int	_nc_Calculate_Text_Width(
+		const TEXT *item)
+		{ return(*(int *)0); }
+
 #undef _nc_Calculate_Item_Length_and_Width
 void	_nc_Calculate_Item_Length_and_Width(
 		MENU	*menu)
@@ -481,6 +486,38 @@
 		const MENU *menu)
 		{ return(*(WINDOW **)0); }
 
+/* ./m_trace.c */
+
+#undef _nc_retrace_item
+ITEM	*_nc_retrace_item(
+		ITEM	*code)
+		{ return(*(ITEM **)0); }
+
+#undef _nc_retrace_item_ptr
+ITEM	**_nc_retrace_item_ptr(
+		ITEM	**code)
+		{ return(*(ITEM ***)0); }
+
+#undef _nc_retrace_item_opts
+Item_Options _nc_retrace_item_opts(
+		Item_Options code)
+		{ return(*(Item_Options *)0); }
+
+#undef _nc_retrace_menu
+MENU	*_nc_retrace_menu(
+		MENU	*code)
+		{ return(*(MENU **)0); }
+
+#undef _nc_retrace_menu_hook
+Menu_Hook _nc_retrace_menu_hook(
+		Menu_Hook code)
+		{ return(*(Menu_Hook *)0); }
+
+#undef _nc_retrace_menu_opts
+Menu_Options _nc_retrace_menu_opts(
+		Menu_Options code)
+		{ return(*(Menu_Options *)0); }
+
 /* ./m_userptr.c */
 
 #undef set_menu_userptr
diff -Naur ncurses-5.4.orig/menu/m_attribs.c ncurses-5.4/menu/m_attribs.c
--- ncurses-5.4.orig/menu/m_attribs.c	2003-11-08 20:54:20.000000000 +0000
+++ ncurses-5.4/menu/m_attribs.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_attribs.c,v 1.12 2003/11/08 20:54:20 tom Exp $")
+MODULE_ID("$Id: m_attribs.c,v 1.14 2004/12/11 23:29:12 tom Exp $")
 
 /* Macro to redraw menu if it is posted and changed */
 #define Refresh_Menu(menu) \
@@ -51,6 +51,7 @@
 #define GEN_MENU_ATTR_SET_FCT( name ) \
 NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU * menu, chtype attr)\
 {\
+   T((T_CALLED("set_menu_" #name "(%p,%s)"), menu, _traceattr(attr)));\
    if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\
       RETURN(E_BAD_ARGUMENT);\
    if (menu && ( menu -> name != attr))\
@@ -66,7 +67,8 @@
 #define GEN_MENU_ATTR_GET_FCT( name ) \
 NCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\
 {\
-   return (Normalize_Menu( menu ) -> name);\
+   T((T_CALLED("menu_" #name "(%p)"), menu));\
+   returnAttr(Normalize_Menu( menu ) -> name);\
 }
 
 /*---------------------------------------------------------------------------
@@ -81,7 +83,7 @@
 |   Return Values :  E_OK              - success
 |                    E_BAD_ARGUMENT    - an invalid value has been passed   
 +--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_SET_FCT( fore )
+GEN_MENU_ATTR_SET_FCT(fore)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -93,7 +95,7 @@
 |
 |   Return Values :  Attribute value
 +--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_GET_FCT( fore )
+GEN_MENU_ATTR_GET_FCT(fore)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -105,7 +107,7 @@
 |   Return Values :  E_OK             - success  
 |                    E_BAD_ARGUMENT   - an invalid value has been passed
 +--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_SET_FCT( back )
+GEN_MENU_ATTR_SET_FCT(back)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -116,7 +118,7 @@
 |
 |   Return Values :  Attribute value
 +--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_GET_FCT( back )
+GEN_MENU_ATTR_GET_FCT(back)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -127,7 +129,7 @@
 |   Return Values :  E_OK             - success
 |                    E_BAD_ARGUMENT   - an invalid value has been passed    
 +--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_SET_FCT( grey )
+GEN_MENU_ATTR_SET_FCT(grey)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -137,5 +139,5 @@
 |
 |   Return Values :  Attribute value
 +--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_GET_FCT( grey )
+GEN_MENU_ATTR_GET_FCT(grey)
 /* m_attribs.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_cursor.c ncurses-5.4/menu/m_cursor.c
--- ncurses-5.4.orig/menu/m_cursor.c	2003-10-25 15:23:42.000000000 +0000
+++ ncurses-5.4/menu/m_cursor.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_cursor.c,v 1.16 2003/10/25 15:23:42 tom Exp $")
+MODULE_ID("$Id: m_cursor.c,v 1.19 2004/12/25 22:03:00 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu
@@ -50,24 +50,23 @@
 |                    E_NOT_POSTED    - Menu is not posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-_nc_menu_cursor_pos
-(const MENU* menu, const ITEM* item, int* pY, int* pX)
+_nc_menu_cursor_pos(const MENU * menu, const ITEM * item, int *pY, int *pX)
 {
   if (!menu || !pX || !pY)
-    return(E_BAD_ARGUMENT);
+    return (E_BAD_ARGUMENT);
   else
     {
-      if ((ITEM*)0 == item)
+      if ((ITEM *) 0 == item)
 	item = menu->curitem;
-      assert(item!=(ITEM*)0);
+      assert(item != (ITEM *) 0);
 
-      if ( !( menu->status & _POSTED ) )
-	return(E_NOT_POSTED);
+      if (!(menu->status & _POSTED))
+	return (E_NOT_POSTED);
 
       *pX = item->x * (menu->spc_cols + menu->itemlen);
       *pY = (item->y - menu->toprow) * menu->spc_rows;
     }
-  return(E_OK);
+  return (E_OK);
 }
 
 /*---------------------------------------------------------------------------
@@ -81,24 +80,26 @@
 |                    E_NOT_POSTED    - Menu is not posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-pos_menu_cursor (const MENU * menu)
+pos_menu_cursor(const MENU * menu)
 {
   WINDOW *win, *sub;
   int x, y;
-  int err = _nc_menu_cursor_pos(menu,(ITEM*)0,&y,&x);
+  int err = _nc_menu_cursor_pos(menu, (ITEM *) 0, &y, &x);
 
-  if (E_OK==err)
+  T((T_CALLED("pos_menu_cursor(%p)"), menu));
+
+  if (E_OK == err)
     {
       win = menu->userwin ? menu->userwin : stdscr;
       sub = menu->usersub ? menu->usersub : win;
       assert(win && sub);
 
       if ((menu->opt & O_SHOWMATCH) && (menu->pindex > 0))
-	x += ( menu->pindex + menu->marklen - 1);
+	x += (menu->pindex + menu->marklen - 1);
 
-      wmove(sub,y,x);
+      wmove(sub, y, x);
 
-      if ( win != sub )
+      if (win != sub)
 	{
 	  wcursyncup(sub);
 	  wsyncup(sub);
diff -Naur ncurses-5.4.orig/menu/m_driver.c ncurses-5.4/menu/m_driver.c
--- ncurses-5.4.orig/menu/m_driver.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_driver.c	2005-05-13 04:09:56.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_driver.c,v 1.20 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_driver.c,v 1.24 2005/04/09 20:40:25 tom Exp $")
 
 /* Macros */
 
@@ -62,28 +62,31 @@
 |   Return Values :  TRUE   - if it is a substring
 |                    FALSE  - if it is not a substring
 +--------------------------------------------------------------------------*/
-static bool Is_Sub_String(
-			  bool  IgnoreCaseFlag,
-			  const char *part,
-			  const char *string
-			 )
+static bool
+Is_Sub_String(
+	       bool IgnoreCaseFlag,
+	       const char *part,
+	       const char *string
+)
 {
-  assert( part && string );
-  if ( IgnoreCaseFlag )
+  assert(part && string);
+  if (IgnoreCaseFlag)
     {
-      while(*string && *part)
+      while (*string && *part)
 	{
-	  if (toupper(*string++)!=toupper(*part)) break;
+	  if (toupper(*string++) != toupper(*part))
+	    break;
 	  part++;
 	}
     }
   else
     {
-      while( *string && *part )
-	if (*part != *string++) break;
+      while (*string && *part)
+	if (*part != *string++)
+	  break;
       part++;
     }
-  return ( (*part) ? FALSE : TRUE );
+  return ((*part) ? FALSE : TRUE);
 }
 
 /*---------------------------------------------------------------------------
@@ -113,73 +116,77 @@
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
 _nc_Match_Next_Character_In_Item_Name
-(MENU *menu, int ch, ITEM **item)
+(MENU * menu, int ch, ITEM ** item)
 {
   bool found = FALSE, passed = FALSE;
-  int  idx, last;
+  int idx, last;
+
+  T((T_CALLED("_nc_Match_Next_Character(%p,%d,%p)"), menu, ch, item));
 
-  assert( menu && item && *item);
+  assert(menu && item && *item);
   idx = (*item)->index;
 
-  if (ch && ch!=BS)
+  if (ch && ch != BS)
     {
       /* if we become to long, we need no further checking : there can't be
-	 a match ! */
-      if ((menu->pindex+1) > menu->namelen)
+         a match ! */
+      if ((menu->pindex + 1) > menu->namelen)
 	RETURN(E_NO_MATCH);
 
-      Add_Character_To_Pattern(menu,ch);
+      Add_Character_To_Pattern(menu, ch);
       /* we artificially position one item back, because in the do...while
-	 loop we start with the next item. This means, that with a new
-	 pattern search we always start the scan with the actual item. If
-	 we do a NEXT_PATTERN oder PREV_PATTERN search, we start with the
-	 one after or before the actual item. */
+         loop we start with the next item. This means, that with a new
+         pattern search we always start the scan with the actual item. If
+         we do a NEXT_PATTERN oder PREV_PATTERN search, we start with the
+         one after or before the actual item. */
       if (--idx < 0)
-	idx = menu->nitems-1;
+	idx = menu->nitems - 1;
     }
 
   last = idx;			/* this closes the cycle */
 
-  do{
-    if (ch==BS)
-      {			/* we have to go backward */
-	if (--idx < 0)
-	  idx = menu->nitems-1;
-      }
-    else
-      {			/* otherwise we always go forward */
-	if (++idx >= menu->nitems)
-	  idx = 0;
-      }
-    if (Is_Sub_String((menu->opt & O_IGNORECASE) != 0,
-		      menu->pattern,
-		      menu->items[idx]->name.str)
+  do
+    {
+      if (ch == BS)
+	{			/* we have to go backward */
+	  if (--idx < 0)
+	    idx = menu->nitems - 1;
+	}
+      else
+	{			/* otherwise we always go forward */
+	  if (++idx >= menu->nitems)
+	    idx = 0;
+	}
+      if (Is_Sub_String((menu->opt & O_IGNORECASE) != 0,
+			menu->pattern,
+			menu->items[idx]->name.str)
 	)
-      found = TRUE;
-    else
-      passed = TRUE;
-  } while (!found && (idx != last));
+	found = TRUE;
+      else
+	passed = TRUE;
+    }
+  while (!found && (idx != last));
 
   if (found)
     {
-      if (!((idx==(*item)->index) && passed))
+      if (!((idx == (*item)->index) && passed))
 	{
 	  *item = menu->items[idx];
 	  RETURN(E_OK);
 	}
       /* This point is reached, if we fully cycled through the item list
-	 and the only match we found is the starting item. With a NEXT_PATTERN
-	 or PREV_PATTERN scan this means, that there was no additional match.
-	 If we searched with an expanded new pattern, we should never reach
-	 this point, because if the expanded pattern matches also the actual
-	 item we will find it in the first attempt (passed==FALSE) and we
-	 will never cycle through the whole item array.
-	 */
-      assert( ch==0 || ch==BS );
+         and the only match we found is the starting item. With a NEXT_PATTERN
+         or PREV_PATTERN scan this means, that there was no additional match.
+         If we searched with an expanded new pattern, we should never reach
+         this point, because if the expanded pattern matches also the actual
+         item we will find it in the first attempt (passed==FALSE) and we
+         will never cycle through the whole item array.
+       */
+      assert(ch == 0 || ch == BS);
     }
   else
     {
-      if (ch && ch!=BS && menu->pindex>0)
+      if (ch && ch != BS && menu->pindex > 0)
 	{
 	  /* if we had no match with a new pattern, we have to restore it */
 	  Remove_Character_From_Pattern(menu);
@@ -201,7 +208,7 @@
 |                    E_NOT_POSTED    - menu is not posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-menu_driver (MENU * menu, int   c)
+menu_driver(MENU * menu, int c)
 {
 #define NAVIGATE(dir) \
   if (!item->dir)\
@@ -213,327 +220,332 @@
   ITEM *item;
   int my_top_row, rdiff;
 
+  T((T_CALLED("menu_driver(%p,%d)"), menu, c));
+
   if (!menu)
     RETURN(E_BAD_ARGUMENT);
 
-  if ( menu->status & _IN_DRIVER )
+  if (menu->status & _IN_DRIVER)
     RETURN(E_BAD_STATE);
-  if ( !( menu->status & _POSTED ) )
+  if (!(menu->status & _POSTED))
     RETURN(E_NOT_POSTED);
 
   item = menu->curitem;
 
-    my_top_row = menu->toprow;
-    assert(item);
+  my_top_row = menu->toprow;
+  assert(item);
 
-    if ((c > KEY_MAX) && (c<=MAX_MENU_COMMAND))
-      {
-	if (!((c==REQ_BACK_PATTERN)
-	      || (c==REQ_NEXT_MATCH) || (c==REQ_PREV_MATCH)))
-	  {
-	    assert( menu->pattern );
-	    Reset_Pattern(menu);
-	  }
-
-	switch(c)
-	  {
-	  case REQ_LEFT_ITEM:
+  if ((c > KEY_MAX) && (c <= MAX_MENU_COMMAND))
+    {
+      if (!((c == REQ_BACK_PATTERN)
+	    || (c == REQ_NEXT_MATCH) || (c == REQ_PREV_MATCH)))
+	{
+	  assert(menu->pattern);
+	  Reset_Pattern(menu);
+	}
+
+      switch (c)
+	{
+	case REQ_LEFT_ITEM:
 	    /*=================*/
-	    NAVIGATE(left);
-	    break;
+	  NAVIGATE(left);
+	  break;
 
-	  case REQ_RIGHT_ITEM:
+	case REQ_RIGHT_ITEM:
 	    /*==================*/
-	    NAVIGATE(right);
-	    break;
+	  NAVIGATE(right);
+	  break;
 
-	  case REQ_UP_ITEM:
+	case REQ_UP_ITEM:
 	    /*===============*/
-	    NAVIGATE(up);
-	    break;
+	  NAVIGATE(up);
+	  break;
 
-	  case REQ_DOWN_ITEM:
+	case REQ_DOWN_ITEM:
 	    /*=================*/
-	    NAVIGATE(down);
-	    break;
+	  NAVIGATE(down);
+	  break;
 
-	  case REQ_SCR_ULINE:
+	case REQ_SCR_ULINE:
 	    /*=================*/
 	  if (my_top_row == 0 || !(item->up))
-	      result = E_REQUEST_DENIED;
-	    else
-	      {
-		--my_top_row;
-		item = item->up;
-	      }
-	    break;
+	    result = E_REQUEST_DENIED;
+	  else
+	    {
+	      --my_top_row;
+	      item = item->up;
+	    }
+	  break;
 
-	  case REQ_SCR_DLINE:
+	case REQ_SCR_DLINE:
 	    /*=================*/
 	  if ((my_top_row + menu->arows >= menu->rows) || !(item->down))
-	      {
-		/* only if the menu has less items than rows, we can deny the
-		   request. Otherwise the epilogue of this routine adjusts the
-		   top row if necessary */
-		result = E_REQUEST_DENIED;
-	      }
-	  else {
-	    my_top_row++;
+	    {
+	      /* only if the menu has less items than rows, we can deny the
+	         request. Otherwise the epilogue of this routine adjusts the
+	         top row if necessary */
+	      result = E_REQUEST_DENIED;
+	    }
+	  else
+	    {
+	      my_top_row++;
 	      item = item->down;
-	  }
-	    break;
+	    }
+	  break;
 
-	  case REQ_SCR_DPAGE:
+	case REQ_SCR_DPAGE:
 	    /*=================*/
 	  rdiff = menu->rows - (menu->arows + my_top_row);
-	    if (rdiff > menu->arows)
-	      rdiff = menu->arows;
-	  if (rdiff<=0)
-	      result = E_REQUEST_DENIED;
-	    else
-	      {
-		my_top_row += rdiff;
-	      while(rdiff-- > 0 && item!=(ITEM*)0)
-		  item = item->down;
-	      }
-	    break;
+	  if (rdiff > menu->arows)
+	    rdiff = menu->arows;
+	  if (rdiff <= 0)
+	    result = E_REQUEST_DENIED;
+	  else
+	    {
+	      my_top_row += rdiff;
+	      while (rdiff-- > 0 && item != (ITEM *) 0)
+		item = item->down;
+	    }
+	  break;
 
-	  case REQ_SCR_UPAGE:
+	case REQ_SCR_UPAGE:
 	    /*=================*/
 	  rdiff = (menu->arows < my_top_row) ? menu->arows : my_top_row;
-	  if (rdiff<=0)
-	      result = E_REQUEST_DENIED;
-	    else
-	      {
-		my_top_row -= rdiff;
-	      while(rdiff-- && item!=(ITEM*)0)
-		  item = item->up;
-	      }
-	    break;
+	  if (rdiff <= 0)
+	    result = E_REQUEST_DENIED;
+	  else
+	    {
+	      my_top_row -= rdiff;
+	      while (rdiff-- && item != (ITEM *) 0)
+		item = item->up;
+	    }
+	  break;
 
-	  case REQ_FIRST_ITEM:
+	case REQ_FIRST_ITEM:
 	    /*==================*/
-	    item = menu->items[0];
-	    break;
+	  item = menu->items[0];
+	  break;
 
-	  case REQ_LAST_ITEM:
+	case REQ_LAST_ITEM:
 	    /*=================*/
-	    item = menu->items[menu->nitems-1];
-	    break;
+	  item = menu->items[menu->nitems - 1];
+	  break;
 
-	  case REQ_NEXT_ITEM:
+	case REQ_NEXT_ITEM:
 	    /*=================*/
-	    if ((item->index+1)>=menu->nitems)
-	      {
-		if (menu->opt & O_NONCYCLIC)
-		  result = E_REQUEST_DENIED;
-		else
-		  item = menu->items[0];
-	      }
-	    else
-	      item = menu->items[item->index + 1];
-	    break;
+	  if ((item->index + 1) >= menu->nitems)
+	    {
+	      if (menu->opt & O_NONCYCLIC)
+		result = E_REQUEST_DENIED;
+	      else
+		item = menu->items[0];
+	    }
+	  else
+	    item = menu->items[item->index + 1];
+	  break;
 
-	  case REQ_PREV_ITEM:
+	case REQ_PREV_ITEM:
 	    /*=================*/
-	    if (item->index<=0)
-	      {
-		if (menu->opt & O_NONCYCLIC)
-		  result = E_REQUEST_DENIED;
-		else
-		  item = menu->items[menu->nitems-1];
-	      }
-	    else
-	      item = menu->items[item->index - 1];
-	    break;
+	  if (item->index <= 0)
+	    {
+	      if (menu->opt & O_NONCYCLIC)
+		result = E_REQUEST_DENIED;
+	      else
+		item = menu->items[menu->nitems - 1];
+	    }
+	  else
+	    item = menu->items[item->index - 1];
+	  break;
 
-	  case REQ_TOGGLE_ITEM:
+	case REQ_TOGGLE_ITEM:
 	    /*===================*/
-	    if (menu->opt & O_ONEVALUE)
-	      {
-		result = E_REQUEST_DENIED;
-	      }
-	    else
-	      {
-		if (menu->curitem->opt & O_SELECTABLE)
-		  {
-		    menu->curitem->value = !menu->curitem->value;
-		    Move_And_Post_Item(menu,menu->curitem);
-		    _nc_Show_Menu(menu);
-		  }
-		else
-		  result = E_NOT_SELECTABLE;
-	      }
-	    break;
+	  if (menu->opt & O_ONEVALUE)
+	    {
+	      result = E_REQUEST_DENIED;
+	    }
+	  else
+	    {
+	      if (menu->curitem->opt & O_SELECTABLE)
+		{
+		  menu->curitem->value = !menu->curitem->value;
+		  Move_And_Post_Item(menu, menu->curitem);
+		  _nc_Show_Menu(menu);
+		}
+	      else
+		result = E_NOT_SELECTABLE;
+	    }
+	  break;
 
-	  case REQ_CLEAR_PATTERN:
+	case REQ_CLEAR_PATTERN:
 	    /*=====================*/
-	    /* already cleared in prologue */
-	    break;
+	  /* already cleared in prologue */
+	  break;
 
-	  case REQ_BACK_PATTERN:
+	case REQ_BACK_PATTERN:
 	    /*====================*/
-	    if (menu->pindex>0)
-	      {
-		assert(menu->pattern);
-		Remove_Character_From_Pattern(menu);
-		pos_menu_cursor( menu );
-	      }
-	    else
-	      result = E_REQUEST_DENIED;
-	    break;
+	  if (menu->pindex > 0)
+	    {
+	      assert(menu->pattern);
+	      Remove_Character_From_Pattern(menu);
+	      pos_menu_cursor(menu);
+	    }
+	  else
+	    result = E_REQUEST_DENIED;
+	  break;
 
-	  case REQ_NEXT_MATCH:
+	case REQ_NEXT_MATCH:
 	    /*==================*/
-	    assert(menu->pattern);
-	    if (menu->pattern[0])
-	      result = _nc_Match_Next_Character_In_Item_Name(menu,0,&item);
-	    else
-	      {
-		if ((item->index+1)<menu->nitems)
-		  item=menu->items[item->index+1];
-		else
-		  {
-		    if (menu->opt & O_NONCYCLIC)
-		      result = E_REQUEST_DENIED;
-		    else
-		      item = menu->items[0];
-		  }
-	      }
-	    break;
+	  assert(menu->pattern);
+	  if (menu->pattern[0])
+	    result = _nc_Match_Next_Character_In_Item_Name(menu, 0, &item);
+	  else
+	    {
+	      if ((item->index + 1) < menu->nitems)
+		item = menu->items[item->index + 1];
+	      else
+		{
+		  if (menu->opt & O_NONCYCLIC)
+		    result = E_REQUEST_DENIED;
+		  else
+		    item = menu->items[0];
+		}
+	    }
+	  break;
 
-	  case REQ_PREV_MATCH:
+	case REQ_PREV_MATCH:
 	    /*==================*/
-	    assert(menu->pattern);
-	    if (menu->pattern[0])
-	      result = _nc_Match_Next_Character_In_Item_Name(menu,BS,&item);
-	    else
-	      {
-		if (item->index)
-		  item = menu->items[item->index-1];
-		else
-		  {
-		    if (menu->opt & O_NONCYCLIC)
-		      result = E_REQUEST_DENIED;
-		    else
-		      item = menu->items[menu->nitems-1];
-		  }
-	      }
-	    break;
+	  assert(menu->pattern);
+	  if (menu->pattern[0])
+	    result = _nc_Match_Next_Character_In_Item_Name(menu, BS, &item);
+	  else
+	    {
+	      if (item->index)
+		item = menu->items[item->index - 1];
+	      else
+		{
+		  if (menu->opt & O_NONCYCLIC)
+		    result = E_REQUEST_DENIED;
+		  else
+		    item = menu->items[menu->nitems - 1];
+		}
+	    }
+	  break;
 
-	  default:
+	default:
 	    /*======*/
-	    result = E_UNKNOWN_COMMAND;
-	    break;
-	  }
-      }
-    else
-      {				/* not a command */
-	if ( !(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(c) )
-	  result = _nc_Match_Next_Character_In_Item_Name( menu, c, &item );
+	  result = E_UNKNOWN_COMMAND;
+	  break;
+	}
+    }
+  else
+    {				/* not a command */
+      if (!(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(UChar(c)))
+	result = _nc_Match_Next_Character_In_Item_Name(menu, c, &item);
 #ifdef NCURSES_MOUSE_VERSION
-        else if (KEY_MOUSE == c)
-	  {
-	    MEVENT	event;
-	    WINDOW* uwin = Get_Menu_UserWin(menu);
-
-	    getmouse(&event);
-	    if ((event.bstate & (BUTTON1_CLICKED         |
-				 BUTTON1_DOUBLE_CLICKED  |
-				 BUTTON1_TRIPLE_CLICKED   ))
-	     && wenclose(uwin,event.y, event.x))
-	      { /* we react only if the click was in the userwin, that means
-		 * inside the menu display area or at the decoration window.
-		 */
-		WINDOW* sub = Get_Menu_Window(menu);
-		int ry = event.y, rx = event.x; /* screen coordinates */
+      else if (KEY_MOUSE == c)
+	{
+	  MEVENT event;
+	  WINDOW *uwin = Get_Menu_UserWin(menu);
 
-		result = E_REQUEST_DENIED;
-		if (mouse_trafo(&ry,&rx,FALSE))
-		  { /* rx, ry are now "curses" coordinates */
-		    if (ry < sub->_begy)
-		      { /* we clicked above the display region; this is
-			 * interpreted as "scroll up" request
-			 */
-			if (event.bstate & BUTTON1_CLICKED)
-			  result = menu_driver(menu,REQ_SCR_ULINE);
-			else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
-			  result = menu_driver(menu,REQ_SCR_UPAGE);
-			else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
-			  result = menu_driver(menu,REQ_FIRST_ITEM);
-			RETURN(result);
-		      }
-		    else if (ry >= sub->_begy + sub->_maxy)
-		      { /* we clicked below the display region; this is
-			 * interpreted as "scroll down" request
-			 */
-			if (event.bstate & BUTTON1_CLICKED)
-			  result = menu_driver(menu,REQ_SCR_DLINE);
-			else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
-			  result = menu_driver(menu,REQ_SCR_DPAGE);
-			else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
-			  result = menu_driver(menu,REQ_LAST_ITEM);
-			RETURN(result);
-		      }
-		    else if (wenclose(sub,event.y,event.x))
-		      { /* Inside the area we try to find the hit item */
-			int i,x,y,err;
-			ry = event.y; rx = event.x;
-			if (wmouse_trafo(sub,&ry,&rx,FALSE))
-			  {
-			    for(i=0;i<menu->nitems;i++)
-			      {
-				err = _nc_menu_cursor_pos(menu,menu->items[i],
-							  &y, &x);
-				if (E_OK==err)
-				  {
-				    if ((ry==y)       &&
-					(rx>=x)       &&
-					(rx < x + menu->itemlen))
-				      {
-					item = menu->items[i];
-					result = E_OK;
-					break;
-				      }
-				  }
-			      }
-			    if (E_OK==result)
-			      { /* We found an item, now we can handle the click.
+	  getmouse(&event);
+	  if ((event.bstate & (BUTTON1_CLICKED |
+			       BUTTON1_DOUBLE_CLICKED |
+			       BUTTON1_TRIPLE_CLICKED))
+	      && wenclose(uwin, event.y, event.x))
+	    {			/* we react only if the click was in the userwin, that means
+				 * inside the menu display area or at the decoration window.
+				 */
+	      WINDOW *sub = Get_Menu_Window(menu);
+	      int ry = event.y, rx = event.x;	/* screen coordinates */
+
+	      result = E_REQUEST_DENIED;
+	      if (mouse_trafo(&ry, &rx, FALSE))
+		{		/* rx, ry are now "curses" coordinates */
+		  if (ry < sub->_begy)
+		    {		/* we clicked above the display region; this is
+				 * interpreted as "scroll up" request
+				 */
+		      if (event.bstate & BUTTON1_CLICKED)
+			result = menu_driver(menu, REQ_SCR_ULINE);
+		      else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+			result = menu_driver(menu, REQ_SCR_UPAGE);
+		      else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+			result = menu_driver(menu, REQ_FIRST_ITEM);
+		      RETURN(result);
+		    }
+		  else if (ry > sub->_begy + sub->_maxy)
+		    {		/* we clicked below the display region; this is
+				 * interpreted as "scroll down" request
+				 */
+		      if (event.bstate & BUTTON1_CLICKED)
+			result = menu_driver(menu, REQ_SCR_DLINE);
+		      else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+			result = menu_driver(menu, REQ_SCR_DPAGE);
+		      else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+			result = menu_driver(menu, REQ_LAST_ITEM);
+		      RETURN(result);
+		    }
+		  else if (wenclose(sub, event.y, event.x))
+		    {		/* Inside the area we try to find the hit item */
+		      int i, x, y, err;
+
+		      ry = event.y;
+		      rx = event.x;
+		      if (wmouse_trafo(sub, &ry, &rx, FALSE))
+			{
+			  for (i = 0; i < menu->nitems; i++)
+			    {
+			      err = _nc_menu_cursor_pos(menu, menu->items[i],
+							&y, &x);
+			      if (E_OK == err)
+				{
+				  if ((ry == y) &&
+				      (rx >= x) &&
+				      (rx < x + menu->itemlen))
+				    {
+				      item = menu->items[i];
+				      result = E_OK;
+				      break;
+				    }
+				}
+			    }
+			  if (E_OK == result)
+			    {	/* We found an item, now we can handle the click.
 				 * A single click just positions the menu cursor
 				 * to the clicked item. A double click toggles
 				 * the item.
 				 */
-				if (event.bstate & BUTTON1_DOUBLE_CLICKED)
-				  {
-				    _nc_New_TopRow_and_CurrentItem(menu,
-								   my_top_row,
-								   item);
-				    menu_driver(menu,REQ_TOGGLE_ITEM);
-				    result = E_UNKNOWN_COMMAND;
-				  }
-			      }
-			  }
-		      }
-		  }
-	      }
-	    else
-	        result = E_REQUEST_DENIED;
-	  }
+			      if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+				{
+				  _nc_New_TopRow_and_CurrentItem(menu,
+								 my_top_row,
+								 item);
+				  menu_driver(menu, REQ_TOGGLE_ITEM);
+				  result = E_UNKNOWN_COMMAND;
+				}
+			    }
+			}
+		    }
+		}
+	    }
+	  else
+	    result = E_REQUEST_DENIED;
+	}
 #endif /* NCURSES_MOUSE_VERSION */
-	else
-	  result = E_UNKNOWN_COMMAND;
-      }
+      else
+	result = E_UNKNOWN_COMMAND;
+    }
 
-  if (E_OK==result)
+  if (E_OK == result)
     {
-    /* Adjust the top row if it turns out that the current item unfortunately
-       doesn't appear in the menu window */
-    if ( item->y < my_top_row )
-      my_top_row = item->y;
-    else if ( item->y >= (my_top_row + menu->arows) )
-      my_top_row = item->y - menu->arows + 1;
+      /* Adjust the top row if it turns out that the current item unfortunately
+         doesn't appear in the menu window */
+      if (item->y < my_top_row)
+	my_top_row = item->y;
+      else if (item->y >= (my_top_row + menu->arows))
+	my_top_row = item->y - menu->arows + 1;
 
-    _nc_New_TopRow_and_CurrentItem( menu, my_top_row, item );
+      _nc_New_TopRow_and_CurrentItem(menu, my_top_row, item);
 
     }
 
diff -Naur ncurses-5.4.orig/menu/m_format.c ncurses-5.4/menu/m_format.c
--- ncurses-5.4.orig/menu/m_format.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_format.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,14 +37,14 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_format.c,v 1.12 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_format.c,v 1.15 2004/12/11 23:11:21 tom Exp $")
 
 #define minimum(a,b) ((a)<(b) ? (a): (b))
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_menu_format(MENU *menu, int rows, int cols)
-|   
+|
 |   Description   :  Sets the maximum number of rows and columns of items
 |                    that may be displayed at one time on a menu. If the
 |                    menu contains more items than can be displayed at
@@ -56,42 +56,44 @@
 |                    E_POSTED               - the menu is already posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_format (MENU *menu, int rows, int cols)
+set_menu_format(MENU * menu, int rows, int cols)
 {
   int total_rows, total_cols;
-  
-  if (rows<0 || cols<0) 
+
+  T((T_CALLED("set_menu_format(%p,%d,%d)"), menu, rows, cols));
+
+  if (rows < 0 || cols < 0)
     RETURN(E_BAD_ARGUMENT);
-  
+
   if (menu)
     {
-      if ( menu->status & _POSTED )
+      if (menu->status & _POSTED)
 	RETURN(E_POSTED);
-      
+
       if (!(menu->items))
 	RETURN(E_NOT_CONNECTED);
-      
-      if (rows==0) 
+
+      if (rows == 0)
 	rows = menu->frows;
-      if (cols==0) 
+      if (cols == 0)
 	cols = menu->fcols;
-      
+
       if (menu->pattern)
 	Reset_Pattern(menu);
-      
+
       menu->frows = rows;
       menu->fcols = cols;
-      
-      assert(rows>0 && cols>0);
-      total_rows = (menu->nitems - 1)/cols + 1;
-      total_cols = (menu->status & O_ROWMAJOR) ? 
-	minimum(menu->nitems,cols) :
-	  (menu->nitems-1)/total_rows + 1;
-      
-      menu->rows    = total_rows;
-      menu->cols    = total_cols;
-      menu->arows   = minimum(total_rows,rows); 
-      menu->toprow  = 0;	
+
+      assert(rows > 0 && cols > 0);
+      total_rows = (menu->nitems - 1) / cols + 1;
+      total_cols = (menu->opt & O_ROWMAJOR) ?
+	minimum(menu->nitems, cols) :
+	(menu->nitems - 1) / total_rows + 1;
+
+      menu->rows = total_rows;
+      menu->cols = total_cols;
+      menu->arows = minimum(total_rows, rows);
+      menu->toprow = 0;
       menu->curitem = *(menu->items);
       assert(menu->curitem);
       menu->status |= _LINK_NEEDED;
@@ -99,24 +101,26 @@
     }
   else
     {
-      if (rows>0) _nc_Default_Menu.frows = rows;
-      if (cols>0) _nc_Default_Menu.fcols = cols;
+      if (rows > 0)
+	_nc_Default_Menu.frows = rows;
+      if (cols > 0)
+	_nc_Default_Menu.fcols = cols;
     }
-  
+
   RETURN(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  void menu_format(const MENU *menu, int *rows, int *cols)
-|   
+|
 |   Description   :  Returns the maximum number of rows and columns that may
 |                    be displayed at one time on menu.
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-menu_format (const MENU *menu, int *rows, int *cols)
+menu_format(const MENU * menu, int *rows, int *cols)
 {
   if (rows)
     *rows = Normalize_Menu(menu)->frows;
diff -Naur ncurses-5.4.orig/menu/m_global.c ncurses-5.4/menu/m_global.c
--- ncurses-5.4.orig/menu/m_global.c	2003-11-08 20:53:01.000000000 +0000
+++ ncurses-5.4/menu/m_global.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -37,10 +37,10 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_global.c,v 1.16 2003/11/08 20:53:01 tom Exp $")
+MODULE_ID("$Id: m_global.c,v 1.20 2005/04/16 17:30:57 tom Exp $")
 
 static char mark[] = "-";
-
+/* *INDENT-OFF* */
 NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu = {
   16,				  /* Nr. of chars high */
   1,				  /* Nr. of chars wide */
@@ -95,6 +95,7 @@
   (ITEM *)0,		          /* up */
   (ITEM *)0		          /* down */
   };
+/* *INDENT-ON* */
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -105,24 +106,26 @@
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-INLINE static void ComputeMaximum_NameDesc_Lengths(MENU * menu)
+INLINE static void
+ComputeMaximum_NameDesc_Lengths(MENU * menu)
 {
-  unsigned MaximumNameLength        = 0;
+  unsigned MaximumNameLength = 0;
   unsigned MaximumDescriptionLength = 0;
   ITEM **items;
-  
+
   assert(menu && menu->items);
-  for( items = menu->items; *items ; items++ )
+  for (items = menu->items; *items; items++)
     {
-      if (items[0]->name.length > MaximumNameLength )
-	MaximumNameLength  = items[0]->name.length;
-      
+      if (items[0]->name.length > MaximumNameLength)
+	MaximumNameLength = items[0]->name.length;
+
       if (items[0]->description.length > MaximumDescriptionLength)
 	MaximumDescriptionLength = items[0]->description.length;
     }
-  
+
   menu->namelen = MaximumNameLength;
   menu->desclen = MaximumDescriptionLength;
+  T(("ComputeMaximum_NameDesc_Lengths %d,%d", menu->namelen, menu->desclen));
 }
 
 /*---------------------------------------------------------------------------
@@ -134,22 +137,23 @@
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-INLINE static void ResetConnectionInfo(MENU *menu, ITEM **items)
+INLINE static void
+ResetConnectionInfo(MENU * menu, ITEM ** items)
 {
   ITEM **item;
-  
+
   assert(menu && items);
-  for(item=items; *item; item++)
+  for (item = items; *item; item++)
     {
       (*item)->index = 0;
-      (*item)->imenu = (MENU *)0;		
+      (*item)->imenu = (MENU *) 0;
     }
   if (menu->pattern)
     free(menu->pattern);
   menu->pattern = (char *)0;
-  menu->pindex  = 0;
-  menu->items   = (ITEM **)0;
-  menu->nitems  = 0;
+  menu->pindex = 0;
+  menu->items = (ITEM **) 0;
+  menu->nitems = 0;
 }
 
 /*---------------------------------------------------------------------------
@@ -164,25 +168,25 @@
 |                    FALSE      - connection failed
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(bool)
-_nc_Connect_Items (MENU *menu, ITEM **items)
+_nc_Connect_Items(MENU * menu, ITEM ** items)
 {
   ITEM **item;
   unsigned int ItemCount = 0;
-  
-  if ( menu && items )
-    {    
-      for(item=items; *item ; item++)
+
+  if (menu && items)
+    {
+      for (item = items; *item; item++)
 	{
-	  if ( (*item)->imenu )
+	  if ((*item)->imenu)
 	    {
 	      /* if a item is already connected, reject connection */
 	      break;
 	    }
 	}
-      if (! (*item) )		
+      if (!(*item))
 	/* we reached the end, so there was no connected item */
 	{
-	  for(item=items; *item ; item++)
+	  for (item = items; *item; item++)
 	    {
 	      if (menu->opt & O_ONEVALUE)
 		{
@@ -190,31 +194,31 @@
 		}
 	      (*item)->index = ItemCount++;
 	      (*item)->imenu = menu;
-	    }			
+	    }
 	}
     }
   else
-    return(FALSE);
-  
+    return (FALSE);
+
   if (ItemCount != 0)
     {
-      menu->items  = items;
+      menu->items = items;
       menu->nitems = ItemCount;
       ComputeMaximum_NameDesc_Lengths(menu);
-      if ( (menu->pattern = (char *)malloc( (unsigned)(1 + menu->namelen))) )
+      if ((menu->pattern = typeMalloc(char, (unsigned)(1 + menu->namelen))))
 	{
-	  Reset_Pattern(menu);	
-	  set_menu_format(menu,menu->frows,menu->fcols);
+	  Reset_Pattern(menu);
+	  set_menu_format(menu, menu->frows, menu->fcols);
 	  menu->curitem = *items;
 	  menu->toprow = 0;
-	  return(TRUE);
+	  return (TRUE);
 	}
     }
-  
+
   /* If we fall through to this point, we have to reset all items connection 
      and inform about a reject connection */
-  ResetConnectionInfo( menu, items );
-  return(FALSE);
+  ResetConnectionInfo(menu, items);
+  return (FALSE);
 }
 
 /*---------------------------------------------------------------------------
@@ -226,14 +230,91 @@
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-_nc_Disconnect_Items (MENU * menu)
+_nc_Disconnect_Items(MENU * menu)
 {
   if (menu && menu->items)
-    ResetConnectionInfo( menu, menu->items );
+    ResetConnectionInfo(menu, menu->items);
 }
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
+|   Function      :  int _nc_Calculate_Text_Width(const TEXT * item)
+|   
+|   Description   :  Calculate the number of columns for a TEXT.
+|
+|   Return Values :  the width
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Calculate_Text_Width(const TEXT * item /*FIXME: limit length */ )
+{
+#if USE_WIDEC_SUPPORT
+  int result = item->length;
+  int count = mbstowcs(0, item->str, 0);
+  wchar_t *temp = 0;
+
+  T((T_CALLED("_nc_menu_text_width(%p)"), item));
+  if (count > 0
+      && (temp = typeMalloc(wchar_t, 2 + count)) != 0)
+    {
+      int n;
+
+      result = 0;
+      mbstowcs(temp, item->str, (unsigned)count);
+      for (n = 0; n < count; ++n)
+	{
+	  int test = wcwidth(temp[n]);
+
+	  if (test <= 0)
+	    test = 1;
+	  result += test;
+	}
+      free(temp);
+    }
+  returnCode(result);
+#else
+  return item->length;
+#endif
+}
+
+/* FIXME: this is experimental, should cache the results but don't want to
+ * modify the MENU struct to do this until it's complete.
+ */
+#if 0				/* USE_WIDEC_SUPPORT */
+static int
+calculate_actual_width(MENU * menu, bool name)
+{
+  int width = 0;
+  int check = 0;
+  ITEM **items;
+
+  assert(menu && menu->items);
+  for (items = menu->items; *items; items++)
+    {
+      if (name)
+	{
+	  check = _nc_Calculate_Text_Width(&((*items)->name));
+	}
+      else
+	{
+	  check = _nc_Calculate_Text_Width(&((*items)->description));
+	}
+      if (check > width)
+	width = check;
+    }
+
+  T(("calculate_actual_width %s = %d/%d",
+     name ? "name" : "desc",
+     width,
+     name ? menu->namelen : menu->desclen));
+  width += 2;			/* FIXME - need this? */
+  return width;
+}
+#else
+#define calculate_actual_width(menu, name) (name ? menu->namelen : menu->desclen)
+#endif
+
+/*---------------------------------------------------------------------------
+|   Facility      :  libnmenu  
 |   Function      :  void _nc_Calculate_Item_Length_and_Width(MENU *menu)
 |   
 |   Description   :  Calculate the length of an item and the width of the
@@ -242,23 +323,33 @@
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-_nc_Calculate_Item_Length_and_Width (MENU * menu)
+_nc_Calculate_Item_Length_and_Width(MENU * menu)
 {
   int l;
-  
+
   assert(menu);
 
-  menu->height  = 1 + menu->spc_rows * (menu->arows - 1);
+  menu->height = 1 + menu->spc_rows * (menu->arows - 1);
+
+  l = calculate_actual_width(menu, TRUE);
+  l += menu->marklen;
+
+  if ((menu->opt & O_SHOWDESC) && (menu->desclen > 0))
+    {
+      l += calculate_actual_width(menu, FALSE);
+      l += menu->spc_desc;
+    }
 
-  l = menu->namelen + menu->marklen;
-  if ( (menu->opt & O_SHOWDESC) && (menu->desclen > 0) )
-    l += (menu->desclen + menu->spc_desc);
-  
   menu->itemlen = l;
   l *= menu->cols;
-  l += (menu->cols-1)*menu->spc_cols; /* for the padding between the columns */
+  l += (menu->cols - 1) * menu->spc_cols;	/* for the padding between the columns */
   menu->width = l;
-}  
+
+  T(("_nc_CalculateItem_Length_and_Width columns %d, item %d, width %d",
+     menu->cols,
+     menu->itemlen,
+     menu->width));
+}
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -271,64 +362,64 @@
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-_nc_Link_Items (MENU * menu)
+_nc_Link_Items(MENU * menu)
 {
   if (menu && menu->items && *(menu->items))
     {
-      int i,j;
+      int i, j;
       ITEM *item;
       int Number_Of_Items = menu->nitems;
       int col = 0, row = 0;
       int Last_in_Row;
       int Last_in_Column;
       bool cycle = (menu->opt & O_NONCYCLIC) ? FALSE : TRUE;
-      
+
       menu->status &= ~_LINK_NEEDED;
-      
+
       if (menu->opt & O_ROWMAJOR)
 	{
 	  int Number_Of_Columns = menu->cols;
-	  
-	  for(i=0; i < Number_Of_Items; i++)
+
+	  for (i = 0; i < Number_Of_Items; i++)
 	    {
 	      item = menu->items[i];
-	      
-	      Last_in_Row = row * Number_Of_Columns + (Number_Of_Columns-1);
-	      
-	      item->left  = (col) ? 
-		/* if we are not in the leftmost column, we can use the
-		   predecessor in the items array */
-		menu->items[i-1] :
-		  (cycle ? menu->items[(Last_in_Row>=Number_Of_Items) ? 
-				       Number_Of_Items-1:
-				       Last_in_Row] : 
-		   (ITEM *)0 );
-	      
-	      item->right = (  (col < (Number_Of_Columns-1)) && 
-			     ((i+1) < Number_Of_Items) 
-			     ) ? 
-			       menu->items[i+1] :
-				 ( cycle ? menu->items[row * Number_Of_Columns] : 
-				  (ITEM *)0
-				  );
-	      
-	      Last_in_Column = (menu->rows-1) * Number_Of_Columns + col;
-	      
-	      item->up    = (row) ? menu->items[i-Number_Of_Columns] :
-		(cycle ? menu->items[(Last_in_Column>=Number_Of_Items) ?
-				     Number_Of_Items-1 : 
-				     Last_in_Column] : 
-		 (ITEM *)0);
-	      
-	      item->down  = ( (i+Number_Of_Columns) < Number_Of_Items ) 
-		? 
-		  menu->items[i + Number_Of_Columns] :
-		    (cycle ? menu->items[(row+1)<menu->rows ?
-					 Number_Of_Items-1:col] : 
-		     (ITEM *)0);
+
+	      Last_in_Row = row * Number_Of_Columns + (Number_Of_Columns - 1);
+
+	      item->left = (col) ?
+	      /* if we are not in the leftmost column, we can use the
+	         predecessor in the items array */
+		menu->items[i - 1] :
+		(cycle ? menu->items[(Last_in_Row >= Number_Of_Items) ?
+				     Number_Of_Items - 1 :
+				     Last_in_Row] :
+		 (ITEM *) 0);
+
+	      item->right = ((col < (Number_Of_Columns - 1)) &&
+			     ((i + 1) < Number_Of_Items)
+		)?
+		menu->items[i + 1] :
+		(cycle ? menu->items[row * Number_Of_Columns] :
+		 (ITEM *) 0
+		);
+
+	      Last_in_Column = (menu->rows - 1) * Number_Of_Columns + col;
+
+	      item->up = (row) ? menu->items[i - Number_Of_Columns] :
+		(cycle ? menu->items[(Last_in_Column >= Number_Of_Items) ?
+				     Number_Of_Items - 1 :
+				     Last_in_Column] :
+		 (ITEM *) 0);
+
+	      item->down = ((i + Number_Of_Columns) < Number_Of_Items)
+		?
+		menu->items[i + Number_Of_Columns] :
+		(cycle ? menu->items[(row + 1) < menu->rows ?
+				     Number_Of_Items - 1 : col] :
+		 (ITEM *) 0);
 	      item->x = col;
 	      item->y = row;
-	      if ( ++col == Number_Of_Columns )
+	      if (++col == Number_Of_Columns)
 		{
 		  row++;
 		  col = 0;
@@ -338,48 +429,48 @@
       else
 	{
 	  int Number_Of_Rows = menu->rows;
-	  
-	  for(j=0; j<Number_Of_Items; j++)
+
+	  for (j = 0; j < Number_Of_Items; j++)
 	    {
-	      item = menu->items[i=(col * Number_Of_Rows + row)];
-	      
-	      Last_in_Column = (menu->cols-1) * Number_Of_Rows + row;
-	      
-	      item->left  = (col) ? 
+	      item = menu->items[i = (col * Number_Of_Rows + row)];
+
+	      Last_in_Column = (menu->cols - 1) * Number_Of_Rows + row;
+
+	      item->left = (col) ?
 		menu->items[i - Number_Of_Rows] :
-		  (cycle ? (Last_in_Column >= Number_Of_Items ) ? 
-		   menu->items[Last_in_Column-Number_Of_Rows] : 
-		   menu->items[Last_in_Column] : 
-		   (ITEM *)0 );
-	      
-	      item->right = ((i + Number_Of_Rows) <Number_Of_Items) 
-		? 
-		  menu->items[i + Number_Of_Rows] :
-		    (cycle ? menu->items[row] : (ITEM *)0);
-	      
+		(cycle ? (Last_in_Column >= Number_Of_Items) ?
+		 menu->items[Last_in_Column - Number_Of_Rows] :
+		 menu->items[Last_in_Column] :
+		 (ITEM *) 0);
+
+	      item->right = ((i + Number_Of_Rows) < Number_Of_Items)
+		?
+		menu->items[i + Number_Of_Rows] :
+		(cycle ? menu->items[row] : (ITEM *) 0);
+
 	      Last_in_Row = col * Number_Of_Rows + (Number_Of_Rows - 1);
-	      
-	      item->up    = (row) ? 
-		menu->items[i-1] :
-		  (cycle ?
-		   menu->items[(Last_in_Row>=Number_Of_Items) ? 
-			       Number_Of_Items-1:
-			       Last_in_Row] :
-		   (ITEM *)0);
-	      
-	      item->down  = (row < (Number_Of_Rows-1)) 
-		? 
-		  (menu->items[((i+1)<Number_Of_Items) ? 
-			       i+1 :
-			       (col-1)*Number_Of_Rows + row + 1]) :
-				 (cycle ?
-				  menu->items[col * Number_Of_Rows] :
-				  (ITEM *)0
-				  );
-	      
+
+	      item->up = (row) ?
+		menu->items[i - 1] :
+		(cycle ?
+		 menu->items[(Last_in_Row >= Number_Of_Items) ?
+			     Number_Of_Items - 1 :
+			     Last_in_Row] :
+		 (ITEM *) 0);
+
+	      item->down = (row < (Number_Of_Rows - 1))
+		?
+		(menu->items[((i + 1) < Number_Of_Items) ?
+			     i + 1 :
+			     (col - 1) * Number_Of_Rows + row + 1]) :
+		(cycle ?
+		 menu->items[col * Number_Of_Rows] :
+		 (ITEM *) 0
+		);
+
 	      item->x = col;
 	      item->y = row;
-	      if ( (++row) == Number_Of_Rows )
+	      if ((++row) == Number_Of_Rows)
 		{
 		  col++;
 		  row = 0;
@@ -398,31 +489,31 @@
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-_nc_Show_Menu (const MENU *menu)
+_nc_Show_Menu(const MENU * menu)
 {
   WINDOW *win;
   int maxy, maxx;
-  
+
   assert(menu);
-  if ( (menu->status & _POSTED) && !(menu->status & _IN_DRIVER) )
+  if ((menu->status & _POSTED) && !(menu->status & _IN_DRIVER))
     {
       /* adjust the internal subwindow to start on the current top */
       assert(menu->sub);
-      mvderwin(menu->sub,menu->spc_rows * menu->toprow,0);
+      mvderwin(menu->sub, menu->spc_rows * menu->toprow, 0);
       win = Get_Menu_Window(menu);
-      
+
       maxy = getmaxy(win);
-      maxx = getmaxx(win);	 
-      
-      if (menu->height < maxy) 
+      maxx = getmaxx(win);
+
+      if (menu->height < maxy)
 	maxy = menu->height;
-      if (menu->width < maxx) 
+      if (menu->width < maxx)
 	maxx = menu->width;
-      
-      copywin(menu->sub,win,0,0,0,0,maxy-1,maxx-1,0);
+
+      copywin(menu->sub, win, 0, 0, 0, 0, maxy - 1, maxx - 1, 0);
       pos_menu_cursor(menu);
-    }	
-}	
+    }
+}
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -438,41 +529,41 @@
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-_nc_New_TopRow_and_CurrentItem
-(MENU *menu, int new_toprow, ITEM *new_current_item)
+  _nc_New_TopRow_and_CurrentItem
+  (MENU * menu, int new_toprow, ITEM * new_current_item)
 {
   ITEM *cur_item;
   bool mterm_called = FALSE;
   bool iterm_called = FALSE;
-  
+
   assert(menu);
   if (menu->status & _POSTED)
     {
       if (new_current_item != menu->curitem)
 	{
-	  Call_Hook(menu,itemterm);
+	  Call_Hook(menu, itemterm);
 	  iterm_called = TRUE;
 	}
       if (new_toprow != menu->toprow)
 	{
-	  Call_Hook(menu,menuterm);
+	  Call_Hook(menu, menuterm);
 	  mterm_called = TRUE;
-	}			
-      
-      cur_item  = menu->curitem;
+	}
+
+      cur_item = menu->curitem;
       assert(cur_item);
-      menu->toprow  = new_toprow;
-      menu->curitem = new_current_item;			
-      
+      menu->toprow = new_toprow;
+      menu->curitem = new_current_item;
+
       if (mterm_called)
 	{
-	  Call_Hook(menu,menuinit);
+	  Call_Hook(menu, menuinit);
 	}
       if (iterm_called)
 	{
 	  /* this means, move from the old current_item to the new one... */
-	  Move_To_Current_Item( menu, cur_item );
-	  Call_Hook(menu,iteminit);
+	  Move_To_Current_Item(menu, cur_item);
+	  Call_Hook(menu, iteminit);
 	}
       if (mterm_called || iterm_called)
 	{
@@ -482,8 +573,8 @@
 	pos_menu_cursor(menu);
     }
   else
-    { /* if we are not posted, this is quite simple */
-      menu->toprow  = new_toprow;
+    {				/* if we are not posted, this is quite simple */
+      menu->toprow = new_toprow;
       menu->curitem = new_current_item;
     }
 }
diff -Naur ncurses-5.4.orig/menu/m_hook.c ncurses-5.4/menu/m_hook.c
--- ncurses-5.4.orig/menu/m_hook.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_hook.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,12 +37,13 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_hook.c,v 1.11 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_hook.c,v 1.14 2004/12/25 21:39:52 tom Exp $")
 
 /* "Template" macro to generate function to set application specific hook */
 #define GEN_HOOK_SET_FUNCTION( typ, name ) \
 NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\
 {\
+   T((T_CALLED("set_" #typ "_" #name "(%p,%p)"), menu, func));\
    (Normalize_Menu(menu) -> typ ## name = func );\
    RETURN(E_OK);\
 }
@@ -51,7 +52,8 @@
 #define GEN_HOOK_GET_FUNCTION( typ, name ) \
 NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\
 {\
-   return (Normalize_Menu(menu) -> typ ## name);\
+   T((T_CALLED(#typ "_" #name "(%p)"), menu));\
+   returnMenuHook(Normalize_Menu(menu) -> typ ## name);\
 }
 
 /*---------------------------------------------------------------------------
@@ -63,7 +65,7 @@
 |
 |   Return Values :  E_OK               - success
 +--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( menu, init )		  
+GEN_HOOK_SET_FUNCTION(menu, init)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -75,7 +77,7 @@
 |
 |   Return Values :  Menu init function address or NULL
 +--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( menu, init )
+GEN_HOOK_GET_FUNCTION(menu, init)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -86,7 +88,7 @@
 |
 |   Return Values :  E_OK               - success
 +--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( menu, term )		  
+GEN_HOOK_SET_FUNCTION(menu, term)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -98,7 +100,7 @@
 |
 |   Return Values :  Menu finalization function address or NULL
 +--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( menu, term )
+GEN_HOOK_GET_FUNCTION(menu, term)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -109,7 +111,7 @@
 |
 |   Return Values :  E_OK               - success
 +--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( item, init )		  
+GEN_HOOK_SET_FUNCTION(item, init)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -121,7 +123,7 @@
 |
 |   Return Values :  Item init function address or NULL
 +--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( item, init )
+GEN_HOOK_GET_FUNCTION(item, init)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -132,7 +134,7 @@
 |
 |   Return Values :  E_OK               - success
 +--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( item, term )		  
+GEN_HOOK_SET_FUNCTION(item, term)
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -144,6 +146,6 @@
 |
 |   Return Values :  Item finalization function address or NULL
 +--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( item, term )
+GEN_HOOK_GET_FUNCTION(item, term)
 
 /* m_hook.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_item_cur.c ncurses-5.4/menu/m_item_cur.c
--- ncurses-5.4.orig/menu/m_item_cur.c	2003-10-25 15:23:42.000000000 +0000
+++ ncurses-5.4/menu/m_item_cur.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_cur.c,v 1.14 2003/10/25 15:23:42 tom Exp $")
+MODULE_ID("$Id: m_item_cur.c,v 1.17 2004/12/25 21:57:38 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -48,14 +48,16 @@
 |   Return Values :  E_OK                - success
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_current_item (MENU * menu, ITEM * item)
+set_current_item(MENU * menu, ITEM * item)
 {
-  if (menu && item && (item->imenu==menu))
+  T((T_CALLED("set_current_item(%p,%p)"), menu, item));
+
+  if (menu && item && (item->imenu == menu))
     {
-      if ( menu->status & _IN_DRIVER )
+      if (menu->status & _IN_DRIVER)
 	RETURN(E_BAD_STATE);
-      
-      assert( menu->curitem );
+
+      assert(menu->curitem);
       if (item != menu->curitem)
 	{
 	  if (menu->status & _LINK_NEEDED)
@@ -69,12 +71,12 @@
 	  assert(menu->pattern);
 	  Reset_Pattern(menu);
 	  /* adjust the window to make item visible and update the menu */
-	  Adjust_Current_Item(menu,menu->toprow,item);
+	  Adjust_Current_Item(menu, menu->toprow, item);
 	}
     }
   else
     RETURN(E_BAD_ARGUMENT);
-  
+
   RETURN(E_OK);
 }
 
@@ -87,9 +89,10 @@
 |   Return Values :  Item pointer or NULL if failure
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(ITEM *)
-current_item (const MENU * menu) 
+current_item(const MENU * menu)
 {
-  return (menu && menu->items) ? menu->curitem : (ITEM *)0;
+  T((T_CALLED("current_item(%p)"), menu));
+  returnItem((menu && menu->items) ? menu->curitem : (ITEM *) 0);
 }
 
 /*---------------------------------------------------------------------------
@@ -101,9 +104,10 @@
 |   Return Values :  The index or ERR if this is an invalid item pointer
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-item_index (const ITEM *item)
+item_index(const ITEM * item)
 {
-  return (item && item->imenu) ? item->index : ERR;
+  T((T_CALLED("item_index(%p)"), item));
+  returnCode((item && item->imenu) ? item->index : ERR);
 }
 
 /* m_item_cur.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_item_nam.c ncurses-5.4/menu/m_item_nam.c
--- ncurses-5.4.orig/menu/m_item_nam.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_item_nam.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_nam.c,v 1.12 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_item_nam.c,v 1.14 2004/12/25 21:41:54 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -48,11 +48,12 @@
 |   Return Values :  See above; returns NULL if item is invalid
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(const char *)
-item_name (const ITEM * item) 
+item_name(const ITEM * item)
 {
-  return ((item) ? item->name.str : (char *)0);
+  T((T_CALLED("item_name(%p)"), item));
+  returnCPtr((item) ? item->name.str : (char *)0);
 }
-		
+
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
 |   Function      :  char *item_description(const ITEM *item)
@@ -62,9 +63,10 @@
 |   Return Values :  See above; Returns NULL if item is invalid
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(const char *)
-item_description (const ITEM * item)
+item_description(const ITEM * item)
 {
-  return ((item) ? item->description.str : (char *)0);
+  T((T_CALLED("item_description(%p)"), item));
+  returnCPtr((item) ? item->description.str : (char *)0);
 }
 
 /* m_item_nam.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_item_new.c ncurses-5.4/menu/m_item_new.c
--- ncurses-5.4.orig/menu/m_item_new.c	2003-10-25 15:23:42.000000000 +0000
+++ ncurses-5.4/menu/m_item_new.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -38,7 +38,11 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_new.c,v 1.14 2003/10/25 15:23:42 tom Exp $")
+#if USE_WIDEC_SUPPORT
+#include <wctype.h>
+#endif
+
+MODULE_ID("$Id: m_item_new.c,v 1.25 2005/04/16 22:24:38 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -50,16 +54,44 @@
 |   Return Values :  TRUE     - if string is printable
 |                    FALSE    - if string contains non-printable characters
 +--------------------------------------------------------------------------*/
-static bool Is_Printable_String(const char *s)
+static bool
+Is_Printable_String(const char *s)
 {
+  int result = TRUE;
+
+#if USE_WIDEC_SUPPORT
+  int count = mbstowcs(0, s, 0);
+  wchar_t *temp = 0;
+
+  assert(s);
+
+  if (count > 0
+      && (temp = typeCalloc(wchar_t, (2 + count))) != 0)
+    {
+      int n;
+
+      mbstowcs(temp, s, (unsigned)count);
+      for (n = 0; n < count; ++n)
+	if (!iswprint(temp[n]))
+	  {
+	    result = FALSE;
+	    break;
+	  }
+      free(temp);
+    }
+#else
   assert(s);
-  while(*s)
+  while (*s)
     {
-      if (!isprint((unsigned char)*s))
-	return FALSE;
+      if (!isprint(UChar(*s)))
+	{
+	  result = FALSE;
+	  break;
+	}
       s++;
     }
-  return TRUE;
+#endif
+  return result;
 }
 
 /*---------------------------------------------------------------------------
@@ -73,41 +105,45 @@
 |   Return Values :  The item pointer or NULL if creation failed.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(ITEM *)
-new_item (const char *name, const char *description)
+new_item(const char *name, const char *description)
 {
   ITEM *item;
-  
-  if ( !name || (*name == '\0') || !Is_Printable_String(name) )
+
+  T((T_CALLED("new_item(\"%s\", \"%s\")"),
+     name ? name : "",
+     description ? description : ""));
+
+  if (!name || (*name == '\0') || !Is_Printable_String(name))
     {
-      item = (ITEM *)0;
-      SET_ERROR( E_BAD_ARGUMENT );
+      item = (ITEM *) 0;
+      SET_ERROR(E_BAD_ARGUMENT);
     }
   else
     {
-      item = (ITEM *)calloc(1,sizeof(ITEM));
+      item = (ITEM *) calloc(1, sizeof(ITEM));
       if (item)
 	{
-	  *item  = _nc_Default_Item; /* hope we have struct assignment */
-	  
-	  item->name.length	   = strlen(name);
-	  item->name.str 	   = name;
+	  *item = _nc_Default_Item;	/* hope we have struct assignment */
+
+	  item->name.length = strlen(name);
+	  item->name.str = name;
 
-	  if (description && (*description != '\0') && 
+	  if (description && (*description != '\0') &&
 	      Is_Printable_String(description))
 	    {
-	      item->description.length = strlen(description);	      
-	      item->description.str    = description;
+	      item->description.length = strlen(description);
+	      item->description.str = description;
 	    }
 	  else
 	    {
 	      item->description.length = 0;
-	      item->description.str    = (char *)0;
+	      item->description.str = (char *)0;
 	    }
 	}
       else
-	SET_ERROR( E_SYSTEM_ERROR );
-    }  
-  return(item);
+	SET_ERROR(E_SYSTEM_ERROR);
+    }
+  returnItem(item);
 }
 
 /*---------------------------------------------------------------------------
@@ -122,17 +158,19 @@
 |                    E_CONNECTED       - item is still connected to a menu    
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-free_item (ITEM * item)
+free_item(ITEM * item)
 {
+  T((T_CALLED("free_item(%p)"), item));
+
   if (!item)
-    RETURN( E_BAD_ARGUMENT );
+    RETURN(E_BAD_ARGUMENT);
 
   if (item->imenu)
-    RETURN( E_CONNECTED );
-  
+    RETURN(E_CONNECTED);
+
   free(item);
 
-  RETURN( E_OK );
+  RETURN(E_OK);
 }
 
 /*---------------------------------------------------------------------------
@@ -153,16 +191,18 @@
 |                    E_SYSTEM_ERROR     - no memory to store mark
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_mark (MENU * menu, const char * mark)
+set_menu_mark(MENU * menu, const char *mark)
 {
-  int l;
+  unsigned l;
+
+  T((T_CALLED("set_menu_mark(%p,%s)"), menu, _nc_visbuf(mark)));
 
-  if ( mark && (*mark != '\0') && Is_Printable_String(mark) )
+  if (mark && (*mark != '\0') && Is_Printable_String(mark))
     l = strlen(mark);
   else
     l = 0;
 
-  if ( menu )
+  if (menu)
     {
       char *old_mark = menu->mark;
       unsigned short old_status = menu->status;
@@ -171,13 +211,13 @@
 	{
 	  /* If the menu is already posted, the geometry is fixed. Then
 	     we can only accept a mark with exactly the same length */
-	  if (menu->marklen != l) 
+	  if (menu->marklen != (int)l)
 	    RETURN(E_BAD_ARGUMENT);
-	}	
+	}
       menu->marklen = l;
       if (l)
 	{
-	  menu->mark = (char *)malloc(l+1);
+	  menu->mark = (char *)malloc(l + 1);
 	  if (menu->mark)
 	    {
 	      strcpy(menu->mark, mark);
@@ -192,24 +232,24 @@
 	}
       else
 	menu->mark = (char *)0;
-      
+
       if ((old_status & _MARK_ALLOCATED) && old_mark)
 	free(old_mark);
 
       if (menu->status & _POSTED)
 	{
-	  _nc_Draw_Menu( menu );
-	  _nc_Show_Menu( menu );
+	  _nc_Draw_Menu(menu);
+	  _nc_Show_Menu(menu);
 	}
       else
 	{
 	  /* Recalculate the geometry */
-	  _nc_Calculate_Item_Length_and_Width( menu );			
+	  _nc_Calculate_Item_Length_and_Width(menu);
 	}
     }
   else
     {
-      return set_menu_mark(&_nc_Default_Menu, mark);
+      returnCode(set_menu_mark(&_nc_Default_Menu, mark));
     }
   RETURN(E_OK);
 }
@@ -223,9 +263,10 @@
 |   Return Values :  The marker string pointer or NULL if no marker defined
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(const char *)
-menu_mark (const MENU * menu)
+menu_mark(const MENU * menu)
 {
-  return Normalize_Menu( menu )->mark;
+  T((T_CALLED("menu_mark(%p)"), menu));
+  returnPtr(Normalize_Menu(menu)->mark);
 }
 
 /* m_item_new.c */
diff -Naur ncurses-5.4.orig/menu/m_item_opt.c ncurses-5.4/menu/m_item_opt.c
--- ncurses-5.4.orig/menu/m_item_opt.c	2003-11-08 20:50:19.000000000 +0000
+++ ncurses-5.4/menu/m_item_opt.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_opt.c,v 1.14 2003/11/08 20:50:19 tom Exp $")
+MODULE_ID("$Id: m_item_opt.c,v 1.17 2004/12/25 21:32:54 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -51,34 +51,36 @@
 |                    E_BAD_ARGUMENT  - invalid item options
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_item_opts (ITEM *item, Item_Options opts)
-{ 
+set_item_opts(ITEM * item, Item_Options opts)
+{
+  T((T_CALLED("set_menu_opts(%p,%d)"), item, opts));
+
   opts &= ALL_ITEM_OPTS;
 
   if (opts & ~ALL_ITEM_OPTS)
     RETURN(E_BAD_ARGUMENT);
-  
+
   if (item)
     {
       if (item->opt != opts)
-	{		
+	{
 	  MENU *menu = item->imenu;
-	  
+
 	  item->opt = opts;
-	  
+
 	  if ((!(opts & O_SELECTABLE)) && item->value)
 	    item->value = FALSE;
-	  
+
 	  if (menu && (menu->status & _POSTED))
 	    {
-	      Move_And_Post_Item( menu, item );
+	      Move_And_Post_Item(menu, item);
 	      _nc_Show_Menu(menu);
 	    }
 	}
     }
   else
     _nc_Default_Item.opt = opts;
-  
+
   RETURN(E_OK);
 }
 
@@ -92,18 +94,21 @@
 |                    E_BAD_ARGUMENT  - invalid options
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-item_opts_off (ITEM *item, Item_Options  opts)
-{ 
-  ITEM *citem = item; /* use a copy because set_item_opts must detect
-                         NULL item itself to adjust its behavior */
+item_opts_off(ITEM * item, Item_Options opts)
+{
+  ITEM *citem = item;		/* use a copy because set_item_opts must detect
+
+				   NULL item itself to adjust its behavior */
+
+  T((T_CALLED("item_opts_off(%p,%d)"), item, opts));
 
   if (opts & ~ALL_ITEM_OPTS)
     RETURN(E_BAD_ARGUMENT);
   else
     {
-      Normalize_Item(citem);    
+      Normalize_Item(citem);
       opts = citem->opt & ~(opts & ALL_ITEM_OPTS);
-      return set_item_opts( item, opts );
+      returnCode(set_item_opts(item, opts));
     }
 }
 
@@ -117,11 +122,14 @@
 |                    E_BAD_ARGUMENT  - invalid options
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-item_opts_on (ITEM *item, Item_Options opts)
+item_opts_on(ITEM * item, Item_Options opts)
 {
-  ITEM *citem = item; /* use a copy because set_item_opts must detect
-                         NULL item itself to adjust its behavior */
-  
+  ITEM *citem = item;		/* use a copy because set_item_opts must detect
+
+				   NULL item itself to adjust its behavior */
+
+  T((T_CALLED("item_opts_on(%p,%d)"), item, opts));
+
   opts &= ALL_ITEM_OPTS;
   if (opts & ~ALL_ITEM_OPTS)
     RETURN(E_BAD_ARGUMENT);
@@ -129,7 +137,7 @@
     {
       Normalize_Item(citem);
       opts = citem->opt | opts;
-      return set_item_opts( item, opts );
+      returnCode(set_item_opts(item, opts));
     }
 }
 
@@ -142,9 +150,10 @@
 |   Return Values :  Items options
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(Item_Options)
-item_opts (const ITEM * item)
+item_opts(const ITEM * item)
 {
-  return (ALL_ITEM_OPTS & Normalize_Item(item)->opt);
+  T((T_CALLED("item_opts(%p)"), item));
+  returnItemOpts(ALL_ITEM_OPTS & Normalize_Item(item)->opt);
 }
 
 /* m_item_opt.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_item_top.c ncurses-5.4/menu/m_item_top.c
--- ncurses-5.4.orig/menu/m_item_top.c	2003-11-08 20:51:53.000000000 +0000
+++ ncurses-5.4/menu/m_item_top.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_top.c,v 1.8 2003/11/08 20:51:53 tom Exp $")
+MODULE_ID("$Id: m_item_top.c,v 1.10 2004/12/11 23:29:34 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -50,35 +50,37 @@
 |                    E_NOT_CONNECTED  - there are no items for the menu
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_top_row (MENU * menu, int row)
+set_top_row(MENU * menu, int row)
 {
   ITEM *item;
-  
+
+  T((T_CALLED("set_top_row(%p,%d)"), menu, row));
+
   if (menu)
     {
-      if ( menu->status & _IN_DRIVER )
+      if (menu->status & _IN_DRIVER)
 	RETURN(E_BAD_STATE);
-      if (menu->items == (ITEM **)0)
+      if (menu->items == (ITEM **) 0)
 	RETURN(E_NOT_CONNECTED);
-      
-      if ((row<0) || (row > (menu->rows - menu->arows)))
+
+      if ((row < 0) || (row > (menu->rows - menu->arows)))
 	RETURN(E_BAD_ARGUMENT);
     }
   else
     RETURN(E_BAD_ARGUMENT);
-  
+
   if (row != menu->toprow)
     {
-      if (menu->status & _LINK_NEEDED) 
+      if (menu->status & _LINK_NEEDED)
 	_nc_Link_Items(menu);
-      
-      item = menu->items[ (menu->opt&O_ROWMAJOR) ? (row*menu->cols) : row ];
+
+      item = menu->items[(menu->opt & O_ROWMAJOR) ? (row * menu->cols) : row];
       assert(menu->pattern);
       Reset_Pattern(menu);
       _nc_New_TopRow_and_CurrentItem(menu, row, item);
     }
-  
-    RETURN(E_OK);
+
+  RETURN(E_OK);
 }
 
 /*---------------------------------------------------------------------------
@@ -90,15 +92,16 @@
 |   Return Values :  The row number or ERR if there is no row
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-top_row (const MENU * menu)
+top_row(const MENU * menu)
 {
+  T((T_CALLED("top_row(%p)"), menu));
   if (menu && menu->items && *(menu->items))
     {
-      assert( (menu->toprow>=0) && (menu->toprow < menu->rows) );
-      return menu->toprow;
+      assert((menu->toprow >= 0) && (menu->toprow < menu->rows));
+      returnCode(menu->toprow);
     }
   else
-    return(ERR);
+    returnCode(ERR);
 }
 
 /* m_item_top.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_item_use.c ncurses-5.4/menu/m_item_use.c
--- ncurses-5.4.orig/menu/m_item_use.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_item_use.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_use.c,v 1.13 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_item_use.c,v 1.16 2004/12/25 21:33:31 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -49,10 +49,11 @@
 |   Return Values :  E_OK               - success
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_item_userptr (ITEM * item, void * userptr)
+set_item_userptr(ITEM * item, void *userptr)
 {
+  T((T_CALLED("set_item_userptr(%p,%p)"), item, userptr));
   Normalize_Item(item)->userptr = userptr;
-  RETURN( E_OK );
+  RETURN(E_OK);
 }
 
 /*---------------------------------------------------------------------------
@@ -66,9 +67,10 @@
 |                    NULL is returned.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void *)
-item_userptr (const ITEM * item)
+item_userptr(const ITEM * item)
 {
-  return Normalize_Item(item)->userptr;
+  T((T_CALLED("item_userptr(%p)"), item));
+  returnVoidPtr(Normalize_Item(item)->userptr);
 }
 
 /* m_item_use.c */
diff -Naur ncurses-5.4.orig/menu/m_item_val.c ncurses-5.4/menu/m_item_val.c
--- ncurses-5.4.orig/menu/m_item_val.c	2003-11-08 20:51:29.000000000 +0000
+++ ncurses-5.4/menu/m_item_val.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_val.c,v 1.12 2003/11/08 20:51:29 tom Exp $")
+MODULE_ID("$Id: m_item_val.c,v 1.14 2004/12/11 23:29:34 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -53,18 +53,19 @@
 |                    E_REQUEST_DENIED  - not selectable or single valued menu
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_item_value (ITEM *item, bool value)
+set_item_value(ITEM * item, bool value)
 {
   MENU *menu;
-  
+
+  T((T_CALLED("set_item_value(%p,%d)"), item, value));
   if (item)
     {
       menu = item->imenu;
-      
+
       if ((!(item->opt & O_SELECTABLE)) ||
-	  (menu && (menu->opt & O_ONEVALUE))) 
+	  (menu && (menu->opt & O_ONEVALUE)))
 	RETURN(E_REQUEST_DENIED);
-      
+
       if (item->value ^ value)
 	{
 	  item->value = value ? TRUE : FALSE;
@@ -72,7 +73,7 @@
 	    {
 	      if (menu->status & _POSTED)
 		{
-		  Move_And_Post_Item(menu,item);
+		  Move_And_Post_Item(menu, item);
 		  _nc_Show_Menu(menu);
 		}
 	    }
@@ -80,7 +81,7 @@
     }
   else
     _nc_Default_Item.value = value;
-  
+
   RETURN(E_OK);
 }
 
@@ -94,9 +95,10 @@
 |                    FALSE  - if item is not selected
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(bool)
-item_value (const ITEM *item)
+item_value(const ITEM * item)
 {
-  return ((Normalize_Item(item)->value) ? TRUE : FALSE);
+  T((T_CALLED("item_value(%p)"), item));
+  returnBool((Normalize_Item(item)->value) ? TRUE : FALSE);
 }
 
 /* m_item_val.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_item_vis.c ncurses-5.4/menu/m_item_vis.c
--- ncurses-5.4.orig/menu/m_item_vis.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_item_vis.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_vis.c,v 1.13 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_item_vis.c,v 1.15 2004/12/25 21:40:09 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -50,18 +50,19 @@
 |                    FALSE if invisible
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(bool)
-item_visible (const ITEM * item)
+item_visible(const ITEM * item)
 {
   MENU *menu;
-  
-  if ( item                                               && 
-      (menu=item->imenu)                                  && 
-      (menu->status & _POSTED)                            &&
-      ( (menu->toprow + menu->arows) > (item->y) )        &&
-      ( item->y >= menu->toprow) )
-    return TRUE;
+
+  T((T_CALLED("item_visible(%p)"), item));
+  if (item &&
+      (menu = item->imenu) &&
+      (menu->status & _POSTED) &&
+      ((menu->toprow + menu->arows) > (item->y)) &&
+      (item->y >= menu->toprow))
+    returnBool(TRUE);
   else
-    return FALSE;
+    returnBool(FALSE);
 }
 
 /* m_item_vis.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_items.c ncurses-5.4/menu/m_items.c
--- ncurses-5.4.orig/menu/m_items.c	2003-11-08 20:50:58.000000000 +0000
+++ ncurses-5.4/menu/m_items.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_items.c,v 1.12 2003/11/08 20:50:58 tom Exp $")
+MODULE_ID("$Id: m_items.c,v 1.16 2005/01/16 01:02:23 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -53,26 +53,28 @@
 |                                     passed to the function
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_items (MENU * menu, ITEM ** items)
+set_menu_items(MENU * menu, ITEM ** items)
 {
+  T((T_CALLED("set_menu_items(%p,%p)"), menu, items));
+
   if (!menu || (items && !(*items)))
     RETURN(E_BAD_ARGUMENT);
-  
-  if ( menu->status & _POSTED )
+
+  if (menu->status & _POSTED)
     RETURN(E_POSTED);
-  
+
   if (menu->items)
     _nc_Disconnect_Items(menu);
-  
+
   if (items)
     {
-      if(!_nc_Connect_Items( menu, items )) 
+      if (!_nc_Connect_Items(menu, items))
 	RETURN(E_CONNECTED);
     }
-  
+
   menu->items = items;
   RETURN(E_OK);
-}		
+}
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -83,9 +85,10 @@
 |   Return Values :  NULL on error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(ITEM **)
-menu_items (const MENU *menu)
+menu_items(const MENU * menu)
 {
-  return(menu ? menu->items : (ITEM **)0);
+  T((T_CALLED("menu_items(%p)"), menu));
+  returnItemPtr(menu ? menu->items : (ITEM **) 0);
 }
 
 /*---------------------------------------------------------------------------
@@ -98,9 +101,10 @@
 |   Return Values :  Number of items or -1 to indicate error.
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-item_count (const MENU *menu)
+item_count(const MENU * menu)
 {
-  return(menu ? menu->nitems : -1);
+  T((T_CALLED("item_count(%p)"), menu));
+  returnCode(menu ? menu->nitems : -1);
 }
 
 /* m_items.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_new.c ncurses-5.4/menu/m_new.c
--- ncurses-5.4.orig/menu/m_new.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_new.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_new.c,v 1.13 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_new.c,v 1.16 2004/12/25 21:57:53 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -51,10 +51,11 @@
 |   Return Values :  NULL on error
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(MENU *)
-new_menu (ITEM ** items)
+new_menu(ITEM ** items)
 {
-  MENU *menu = (MENU *)calloc(1,sizeof(MENU));
-  
+  MENU *menu = (MENU *) calloc(1, sizeof(MENU));
+
+  T((T_CALLED("new_menu(%p)"), items));
   if (menu)
     {
       *menu = _nc_Default_Menu;
@@ -63,10 +64,10 @@
       menu->cols = menu->fcols;
       if (items && *items)
 	{
-	  if (!_nc_Connect_Items(menu,items))
+	  if (!_nc_Connect_Items(menu, items))
 	    {
 	      free(menu);
-	      menu = (MENU *)0;
+	      menu = (MENU *) 0;
 	    }
 	}
     }
@@ -74,7 +75,7 @@
   if (!menu)
     SET_ERROR(E_SYSTEM_ERROR);
 
-  return(menu);
+  returnMenu(menu);
 }
 
 /*---------------------------------------------------------------------------
@@ -89,17 +90,18 @@
 |                    E_POSTED           - Menu is already posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-free_menu (MENU * menu)
+free_menu(MENU * menu)
 {
+  T((T_CALLED("free_menu(%p)"), menu));
   if (!menu)
     RETURN(E_BAD_ARGUMENT);
-  
-  if ( menu->status & _POSTED )
+
+  if (menu->status & _POSTED)
     RETURN(E_POSTED);
-  
-  if (menu->items) 
+
+  if (menu->items)
     _nc_Disconnect_Items(menu);
-  
+
   if ((menu->status & _MARK_ALLOCATED) && menu->mark)
     free(menu->mark);
 
diff -Naur ncurses-5.4.orig/menu/m_opts.c ncurses-5.4/menu/m_opts.c
--- ncurses-5.4.orig/menu/m_opts.c	2003-11-08 20:50:19.000000000 +0000
+++ ncurses-5.4/menu/m_opts.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_opts.c,v 1.16 2003/11/08 20:50:19 tom Exp $")
+MODULE_ID("$Id: m_opts.c,v 1.19 2004/12/25 21:36:12 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu
@@ -53,8 +53,10 @@
 |                    E_POSTED       - menu is already posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_opts (MENU * menu, Menu_Options opts)
+set_menu_opts(MENU * menu, Menu_Options opts)
 {
+  T((T_CALLED("set_menu_opts(%p,%d)"), menu, opts));
+
   opts &= ALL_MENU_OPTS;
 
   if (opts & ~ALL_MENU_OPTS)
@@ -62,18 +64,18 @@
 
   if (menu)
     {
-      if ( menu->status & _POSTED )
+      if (menu->status & _POSTED)
 	RETURN(E_POSTED);
 
-      if ( (opts&O_ROWMAJOR) != (menu->opt&O_ROWMAJOR))
+      if ((opts & O_ROWMAJOR) != (menu->opt & O_ROWMAJOR))
 	{
 	  /* we need this only if the layout really changed ... */
 	  if (menu->items && menu->items[0])
 	    {
-	      menu->toprow  = 0;
+	      menu->toprow = 0;
 	      menu->curitem = menu->items[0];
 	      assert(menu->curitem);
-	      set_menu_format( menu, menu->frows, menu->fcols );
+	      set_menu_format(menu, menu->frows, menu->fcols);
 	    }
 	}
 
@@ -83,13 +85,13 @@
 	{
 	  ITEM **item;
 
-	  if ( ((item=menu->items) != (ITEM**)0) )
-	    for(;*item;item++)
+	  if (((item = menu->items) != (ITEM **) 0))
+	    for (; *item; item++)
 	      (*item)->value = FALSE;
 	}
 
       if (opts & O_SHOWDESC)	/* this also changes the geometry */
-	_nc_Calculate_Item_Length_and_Width( menu );
+	_nc_Calculate_Item_Length_and_Width(menu);
     }
   else
     _nc_Default_Menu.opt = opts;
@@ -111,10 +113,13 @@
 |                    E_POSTED       - menu is already posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-menu_opts_off (MENU *menu, Menu_Options  opts)
+menu_opts_off(MENU * menu, Menu_Options opts)
 {
-  MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
-                         NULL menu itself to adjust its behavior */
+  MENU *cmenu = menu;		/* use a copy because set_menu_opts must detect
+
+				   NULL menu itself to adjust its behavior */
+
+  T((T_CALLED("menu_opts_off(%p,%d)"), menu, opts));
 
   opts &= ALL_MENU_OPTS;
   if (opts & ~ALL_MENU_OPTS)
@@ -123,7 +128,7 @@
     {
       Normalize_Menu(cmenu);
       opts = cmenu->opt & ~opts;
-      return set_menu_opts( menu, opts );
+      returnCode(set_menu_opts(menu, opts));
     }
 }
 
@@ -141,10 +146,13 @@
 |                    E_POSTED       - menu is already posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-menu_opts_on (MENU * menu, Menu_Options opts)
+menu_opts_on(MENU * menu, Menu_Options opts)
 {
-  MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
-                         NULL menu itself to adjust its behavior */
+  MENU *cmenu = menu;		/* use a copy because set_menu_opts must detect
+
+				   NULL menu itself to adjust its behavior */
+
+  T((T_CALLED("menu_opts_on(%p,%d)"), menu, opts));
 
   opts &= ALL_MENU_OPTS;
   if (opts & ~ALL_MENU_OPTS)
@@ -153,7 +161,7 @@
     {
       Normalize_Menu(cmenu);
       opts = cmenu->opt | opts;
-      return set_menu_opts(menu, opts);
+      returnCode(set_menu_opts(menu, opts));
     }
 }
 
@@ -166,9 +174,10 @@
 |   Return Values :  Menu options
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(Menu_Options)
-menu_opts (const MENU *menu)
+menu_opts(const MENU * menu)
 {
-  return (ALL_MENU_OPTS & Normalize_Menu( menu )->opt);
+  T((T_CALLED("menu_opts(%p)"), menu));
+  returnMenuOpts(ALL_MENU_OPTS & Normalize_Menu(menu)->opt);
 }
 
 /* m_opts.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_pad.c ncurses-5.4/menu/m_pad.c
--- ncurses-5.4.orig/menu/m_pad.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_pad.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_pad.c,v 1.7 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_pad.c,v 1.10 2004/12/25 21:40:58 tom Exp $")
 
 /* Macro to redraw menu if it is posted and changed */
 #define Refresh_Menu(menu) \
@@ -59,18 +59,20 @@
 |                    E_BAD_ARGUMENT    - an invalid value has been passed
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_pad (MENU *menu, int pad)
+set_menu_pad(MENU * menu, int pad)
 {
-  bool do_refresh = (menu != (MENU*)0);
+  bool do_refresh = (menu != (MENU *) 0);
 
-  if (!isprint((unsigned char)pad))
+  T((T_CALLED("set_menu_pad(%p,%d)"), menu, pad));
+
+  if (!isprint(UChar(pad)))
     RETURN(E_BAD_ARGUMENT);
-  
-  Normalize_Menu( menu );
+
+  Normalize_Menu(menu);
   menu->pad = pad;
-  
+
   if (do_refresh)
-      Refresh_Menu( menu );
+    Refresh_Menu(menu);
 
   RETURN(E_OK);
 }
@@ -84,9 +86,10 @@
 |   Return Values :  The pad character
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-menu_pad (const MENU * menu)
+menu_pad(const MENU * menu)
 {
-  return (Normalize_Menu( menu ) -> pad);
+  T((T_CALLED("menu_pad(%p)"), menu));
+  returnCode(Normalize_Menu(menu)->pad);
 }
 
 /* m_pad.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_pattern.c ncurses-5.4/menu/m_pattern.c
--- ncurses-5.4.orig/menu/m_pattern.c	2003-12-06 17:22:10.000000000 +0000
+++ ncurses-5.4/menu/m_pattern.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_pattern.c,v 1.9 2003/12/06 17:22:10 tom Exp $")
+MODULE_ID("$Id: m_pattern.c,v 1.14 2005/04/16 17:53:16 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -51,9 +51,12 @@
 |                    PatternString - as expected
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(char *)
-menu_pattern (const MENU * menu)
+menu_pattern(const MENU * menu)
 {
-  return (char *)(menu ? (menu->pattern ? menu->pattern : "") : 0);
+  static char empty[] = "";
+
+  T((T_CALLED("menu_pattern(%p)"), menu));
+  returnPtr(menu ? (menu->pattern ? menu->pattern : empty) : 0);
 }
 
 /*---------------------------------------------------------------------------
@@ -70,49 +73,51 @@
 |                    E_NO_MATCH        - no item matches pattern
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_pattern (MENU *menu, const char *p)
+set_menu_pattern(MENU * menu, const char *p)
 {
   ITEM *matchitem;
-  int   matchpos;
-  
-  if (!menu || !p)	
+  int matchpos;
+
+  T((T_CALLED("set_menu_pattern(%p,%s)"), menu, _nc_visbuf(p)));
+
+  if (!menu || !p)
     RETURN(E_BAD_ARGUMENT);
-  
+
   if (!(menu->items))
     RETURN(E_NOT_CONNECTED);
-  
-  if ( menu->status & _IN_DRIVER )
+
+  if (menu->status & _IN_DRIVER)
     RETURN(E_BAD_STATE);
-  
+
   Reset_Pattern(menu);
-  
+
   if (!(*p))
     {
       pos_menu_cursor(menu);
       RETURN(E_OK);
     }
-  
-  if (menu->status & _LINK_NEEDED) 
+
+  if (menu->status & _LINK_NEEDED)
     _nc_Link_Items(menu);
-  
-  matchpos  = menu->toprow;
+
+  matchpos = menu->toprow;
   matchitem = menu->curitem;
   assert(matchitem);
-  
-  while(*p)
+
+  while (*p)
     {
-      if ( !isprint((unsigned char)(*p)) || 
-	  (_nc_Match_Next_Character_In_Item_Name(menu,*p,&matchitem) != E_OK) )
+      if (!isprint(UChar(*p)) ||
+	  (_nc_Match_Next_Character_In_Item_Name(menu, *p, &matchitem) != E_OK))
 	{
 	  Reset_Pattern(menu);
 	  pos_menu_cursor(menu);
 	  RETURN(E_NO_MATCH);
 	}
       p++;
-    }			
-  
+    }
+
   /* This is reached if there was a match. So we position to the new item */
-  Adjust_Current_Item(menu,matchpos,matchitem);
+  Adjust_Current_Item(menu, matchpos, matchitem);
   RETURN(E_OK);
 }
 
diff -Naur ncurses-5.4.orig/menu/m_post.c ncurses-5.4/menu/m_post.c
--- ncurses-5.4.orig/menu/m_post.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_post.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,113 +37,117 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_post.c,v 1.19 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_post.c,v 1.26 2004/12/25 23:57:04 tom Exp $")
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
-|   Function      :  void _nc_Post_Item(MENU *menu, ITEM *item)  
-|   
+|   Facility      :  libnmenu
+|   Function      :  void _nc_Post_Item(MENU *menu, ITEM *item)
+|
 |   Description   :  Draw the item in the menus window at the current
-|                    window position 
+|                    window position
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-_nc_Post_Item (const MENU * menu, const ITEM * item)
+_nc_Post_Item(const MENU * menu, const ITEM * item)
 {
   int i;
   chtype ch;
   int item_x, item_y;
   int count = 0;
-  bool isfore = FALSE, isback=FALSE, isgrey = FALSE;
-  
+  bool isfore = FALSE, isback = FALSE, isgrey = FALSE;
+  int name_len;
+  int desc_len;
+
   assert(menu->win);
-  
-  getyx(menu->win,item_y,item_x);
-  
+
+  getyx(menu->win, item_y, item_x);
+
   /* We need a marker iff
      - it is a onevalued menu and it is the current item
      - or it has a selection value
-     */
-  wattron(menu->win,menu->back);
-  if (item->value || (item==menu->curitem))
+   */
+  wattron(menu->win, menu->back);
+  if (item->value || (item == menu->curitem))
     {
-      if (menu->marklen) 
+      if (menu->marklen)
 	{
 	  /* In a multi selection menu we use the fore attribute
 	     for a selected marker that is not the current one.
 	     This improves visualization of the menu, because now
 	     always the 'normal' marker denotes the current
 	     item. */
-	  if (!(menu->opt & O_ONEVALUE) && item->value && item!=menu->curitem)
+	  if (!(menu->opt & O_ONEVALUE) && item->value && item != menu->curitem)
 	    {
-	      wattron(menu->win,menu->fore);
+	      wattron(menu->win, menu->fore);
 	      isfore = TRUE;
 	    }
-	  waddstr(menu->win,menu->mark);
+	  waddstr(menu->win, menu->mark);
 	  if (isfore)
 	    {
-	      wattron(menu->win,menu->fore);
+	      wattron(menu->win, menu->fore);
 	      isfore = FALSE;
 	    }
 	}
     }
-  else			/* otherwise we have to wipe out the marker area */ 
-    for(ch=' ',i=menu->marklen;i>0;i--) 
-      waddch(menu->win,ch);
-  wattroff(menu->win,menu->back);
+  else				/* otherwise we have to wipe out the marker area */
+    for (ch = ' ', i = menu->marklen; i > 0; i--)
+      waddch(menu->win, ch);
+  wattroff(menu->win, menu->back);
   count += menu->marklen;
 
   /* First we have to calculate the attribute depending on selectability
      and selection status
-     */
+   */
   if (!(item->opt & O_SELECTABLE))
     {
-      wattron(menu->win,menu->grey);
+      wattron(menu->win, menu->grey);
       isgrey = TRUE;
     }
   else
     {
-      if (item->value || item==menu->curitem)
+      if (item->value || item == menu->curitem)
 	{
-	  wattron(menu->win,menu->fore);
+	  wattron(menu->win, menu->fore);
 	  isfore = TRUE;
 	}
       else
 	{
-	  wattron(menu->win,menu->back);
+	  wattron(menu->win, menu->back);
 	  isback = TRUE;
 	}
     }
 
-  waddnstr(menu->win,item->name.str,item->name.length);
-  for(ch=' ',i=menu->namelen-item->name.length;i>0;i--)
+  waddnstr(menu->win, item->name.str, item->name.length);
+  name_len = _nc_Calculate_Text_Width(&(item->name));
+  for (ch = ' ', i = menu->namelen - name_len; i > 0; i--)
     {
-      waddch(menu->win,ch);
+      waddch(menu->win, ch);
     }
   count += menu->namelen;
 
   /* Show description if required and available */
-  if ( (menu->opt & O_SHOWDESC) && menu->desclen>0 )
+  if ((menu->opt & O_SHOWDESC) && menu->desclen > 0)
     {
-      int m = menu->spc_desc/2;
+      int m = menu->spc_desc / 2;
       int cy = -1, cx = -1;
 
-      for(ch=' ',i=0; i < menu->spc_desc; i++)
+      for (ch = ' ', i = 0; i < menu->spc_desc; i++)
 	{
-	  if (i==m)
+	  if (i == m)
 	    {
-	      waddch(menu->win,menu->pad);
-	      getyx(menu->win,cy,cx);
+	      waddch(menu->win, menu->pad);
+	      getyx(menu->win, cy, cx);
 	    }
 	  else
-	    waddch(menu->win,ch);
+	    waddch(menu->win, ch);
 	}
       if (item->description.length)
-	waddnstr(menu->win,item->description.str,item->description.length);
-      for(ch=' ',i=menu->desclen-item->description.length; i>0; i--)
+	waddnstr(menu->win, item->description.str, item->description.length);
+      desc_len = _nc_Calculate_Text_Width(&(item->description));
+      for (ch = ' ', i = menu->desclen - desc_len; i > 0; i--)
 	{
-	  waddch(menu->win,ch);
+	  waddch(menu->win, ch);
 	}
       count += menu->desclen + menu->spc_desc;
 
@@ -151,47 +155,49 @@
 	{
 	  int j, k, ncy, ncx;
 
-	  assert(cx>=0 && cy>=0);
-	  getyx(menu->win,ncy,ncx);
-	  if (isgrey) wattroff(menu->win,menu->grey);
-	  else if (isfore) wattroff(menu->win,menu->fore);
-	  wattron(menu->win,menu->back);
-	  for(j=1; j < menu->spc_rows;j++)
+	  assert(cx >= 0 && cy >= 0);
+	  getyx(menu->win, ncy, ncx);
+	  if (isgrey)
+	    wattroff(menu->win, menu->grey);
+	  else if (isfore)
+	    wattroff(menu->win, menu->fore);
+	  wattron(menu->win, menu->back);
+	  for (j = 1; j < menu->spc_rows; j++)
 	    {
-	      if ((item_y+j) < getmaxy(menu->win))
+	      if ((item_y + j) < getmaxy(menu->win))
 		{
-		  wmove (menu->win,item_y+j,item_x);
-		  for(k=0;k<count;k++)
-		    waddch(menu->win,' ');
+		  wmove(menu->win, item_y + j, item_x);
+		  for (k = 0; k < count; k++)
+		    waddch(menu->win, ' ');
 		}
-	      if ((cy+j) < getmaxy(menu->win))
-		mvwaddch(menu->win,cy+j,cx-1,menu->pad);
+	      if ((cy + j) < getmaxy(menu->win))
+		mvwaddch(menu->win, cy + j, cx - 1, menu->pad);
 	    }
-	  wmove(menu->win,ncy,ncx);
+	  wmove(menu->win, ncy, ncx);
 	  if (!isback)
-	    wattroff(menu->win,menu->back);
+	    wattroff(menu->win, menu->back);
 	}
     }
-  
+
   /* Remove attributes */
   if (isfore)
-    wattroff(menu->win,menu->fore);
+    wattroff(menu->win, menu->fore);
   if (isback)
-    wattroff(menu->win,menu->back);
+    wattroff(menu->win, menu->back);
   if (isgrey)
-    wattroff(menu->win,menu->grey);
-}	
+    wattroff(menu->win, menu->grey);
+}
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  void _nc_Draw_Menu(const MENU *)
-|   
+|
 |   Description   :  Display the menu in its windows
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void)
-_nc_Draw_Menu (const MENU * menu)
+_nc_Draw_Menu(const MENU * menu)
 {
   ITEM *item = menu->items[0];
   ITEM *lasthor, *lastvert;
@@ -202,75 +208,78 @@
   assert(item && menu->win);
 
   s_bkgd = getbkgd(menu->win);
-  wbkgdset(menu->win,menu->back);
+  wbkgdset(menu->win, menu->back);
   werase(menu->win);
-  wbkgdset(menu->win,s_bkgd);
+  wbkgdset(menu->win, s_bkgd);
 
-  lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item;  
+  lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : item;
 
   do
-    {  
-      wmove(menu->win,y,0);
+    {
+      wmove(menu->win, y, 0);
+
+      hitem = item;
+      lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : hitem;
 
-      hitem   = item;
-      lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem;
-      
       do
 	{
-	  _nc_Post_Item( menu, hitem);
+	  _nc_Post_Item(menu, hitem);
 
-	  wattron(menu->win,menu->back);
-	  if ( ((hitem = hitem->right) != lasthor) && hitem )
+	  wattron(menu->win, menu->back);
+	  if (((hitem = hitem->right) != lasthor) && hitem)
 	    {
-	      int i,j, cy, cx;
+	      int i, j, cy, cx;
 	      chtype ch = ' ';
 
-	      getyx(menu->win,cy,cx);
-	      for(j=0;j<menu->spc_rows;j++)
+	      getyx(menu->win, cy, cx);
+	      for (j = 0; j < menu->spc_rows; j++)
 		{
-		  wmove(menu->win,cy+j,cx);
-		  for(i=0; i < menu->spc_cols; i++)
+		  wmove(menu->win, cy + j, cx);
+		  for (i = 0; i < menu->spc_cols; i++)
 		    {
-		      waddch( menu->win,ch);
+		      waddch(menu->win, ch);
 		    }
 		}
-	      wmove(menu->win,cy,cx+menu->spc_cols);
+	      wmove(menu->win, cy, cx + menu->spc_cols);
 	    }
-	} while (hitem && (hitem != lasthor));
-      wattroff(menu->win,menu->back);
-      
+	}
+      while (hitem && (hitem != lasthor));
+      wattroff(menu->win, menu->back);
+
       item = item->down;
       y += menu->spc_rows;
-      
-    } while( item && (item != lastvert) );
+
+    }
+  while (item && (item != lastvert));
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int post_menu(MENU *)
-|   
+|
 |   Description   :  Post a menu to the screen. This makes it visible.
 |
 |   Return Values :  E_OK                - success
 |                    E_BAD_ARGUMENT      - not a valid menu pointer
 |                    E_SYSTEM_ERROR      - error in lower layers
-|                    E_NO_ROOM           - Menu to large for screen
 |                    E_NOT_CONNECTED     - No items connected to menu
 |                    E_BAD_STATE         - Menu in userexit routine
 |                    E_POSTED            - Menu already posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-post_menu (MENU * menu)
+post_menu(MENU * menu)
 {
+  T((T_CALLED("post_menu(%p)"), menu));
+
   if (!menu)
     RETURN(E_BAD_ARGUMENT);
-  
-  if ( menu->status & _IN_DRIVER )
+
+  if (menu->status & _IN_DRIVER)
     RETURN(E_BAD_STATE);
 
-  if ( menu->status & _POSTED )
+  if (menu->status & _POSTED)
     RETURN(E_POSTED);
-  
+
   if (menu->items && *(menu->items))
     {
       int y;
@@ -278,54 +287,50 @@
 
       WINDOW *win = Get_Menu_Window(menu);
       int maxy = getmaxy(win);
-      int maxx = getmaxx(win);
-      
-      if (maxx < menu->width || maxy < menu->height)
-	RETURN(E_NO_ROOM);
 
-      if ( (menu->win = newpad(h,menu->width)) )
+      if ((menu->win = newpad(h, menu->width)))
 	{
 	  y = (maxy >= h) ? h : maxy;
-	  if (y>=menu->height) 
+	  if (y >= menu->height)
 	    y = menu->height;
-	  if(!(menu->sub = subpad(menu->win,y,menu->width,0,0)))
+	  if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0)))
 	    RETURN(E_SYSTEM_ERROR);
 	}
-      else 
-	RETURN(E_SYSTEM_ERROR);	
-      
-      if (menu->status & _LINK_NEEDED) 
+      else
+	RETURN(E_SYSTEM_ERROR);
+
+      if (menu->status & _LINK_NEEDED)
 	_nc_Link_Items(menu);
     }
   else
     RETURN(E_NOT_CONNECTED);
-  
+
   menu->status |= _POSTED;
 
-  if (!(menu->opt&O_ONEVALUE))
+  if (!(menu->opt & O_ONEVALUE))
     {
       ITEM **items;
-  
-      for(items=menu->items;*items;items++)
+
+      for (items = menu->items; *items; items++)
 	{
 	  (*items)->value = FALSE;
 	}
     }
-  
+
   _nc_Draw_Menu(menu);
-  
-  Call_Hook(menu,menuinit);
-  Call_Hook(menu,iteminit);
-  
+
+  Call_Hook(menu, menuinit);
+  Call_Hook(menu, iteminit);
+
   _nc_Show_Menu(menu);
-  
+
   RETURN(E_OK);
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int unpost_menu(MENU *)
-|   
+|
 |   Description   :  Detach menu from screen
 |
 |   Return Values :  E_OK              - success
@@ -334,36 +339,38 @@
 |                    E_NOT_POSTED      - menu is not posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-unpost_menu (MENU * menu)
+unpost_menu(MENU * menu)
 {
   WINDOW *win;
-  
+
+  T((T_CALLED("unpost_menu(%p)"), menu));
+
   if (!menu)
     RETURN(E_BAD_ARGUMENT);
-  
-  if ( menu->status & _IN_DRIVER )
+
+  if (menu->status & _IN_DRIVER)
     RETURN(E_BAD_STATE);
 
-  if ( !( menu->status & _POSTED ) )
+  if (!(menu->status & _POSTED))
     RETURN(E_NOT_POSTED);
-  
-  Call_Hook(menu,itemterm);
-  Call_Hook(menu,menuterm);	
-  
+
+  Call_Hook(menu, itemterm);
+  Call_Hook(menu, menuterm);
+
   win = Get_Menu_Window(menu);
   werase(win);
   wsyncup(win);
-  
+
   assert(menu->sub);
   delwin(menu->sub);
   menu->sub = (WINDOW *)0;
-  
+
   assert(menu->win);
   delwin(menu->win);
   menu->win = (WINDOW *)0;
-  
+
   menu->status &= ~_POSTED;
-  
+
   RETURN(E_OK);
 }
 
diff -Naur ncurses-5.4.orig/menu/m_req_name.c ncurses-5.4/menu/m_req_name.c
--- ncurses-5.4.orig/menu/m_req_name.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_req_name.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -37,27 +37,29 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_req_name.c,v 1.15 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_req_name.c,v 1.19 2005/04/16 16:59:52 tom Exp $")
 
-static const char *request_names[ MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1 ] = {
-  "LEFT_ITEM"    ,
-  "RIGHT_ITEM"   ,
-  "UP_ITEM"      ,
-  "DOWN_ITEM"    ,
-  "SCR_ULINE"    ,
-  "SCR_DLINE"    ,
-  "SCR_DPAGE"    ,
-  "SCR_UPAGE"    ,
-  "FIRST_ITEM"   ,
-  "LAST_ITEM"    ,
-  "NEXT_ITEM"    ,
-  "PREV_ITEM"    ,
-  "TOGGLE_ITEM"  ,
+static const char *request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1] =
+{
+  "LEFT_ITEM",
+  "RIGHT_ITEM",
+  "UP_ITEM",
+  "DOWN_ITEM",
+  "SCR_ULINE",
+  "SCR_DLINE",
+  "SCR_DPAGE",
+  "SCR_UPAGE",
+  "FIRST_ITEM",
+  "LAST_ITEM",
+  "NEXT_ITEM",
+  "PREV_ITEM",
+  "TOGGLE_ITEM",
   "CLEAR_PATTERN",
-  "BACK_PATTERN" ,
-  "NEXT_MATCH"   ,
-  "PREV_MATCH"          
+  "BACK_PATTERN",
+  "NEXT_MATCH",
+  "PREV_MATCH"
 };
+
 #define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
 
 /*---------------------------------------------------------------------------
@@ -70,18 +72,18 @@
 |                    NULL                 - on invalid request code
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(const char *)
-menu_request_name ( int request )
+menu_request_name(int request)
 {
-  if ( (request < MIN_MENU_COMMAND) || (request > MAX_MENU_COMMAND) )
+  T((T_CALLED("menu_request_name(%d)"), request));
+  if ((request < MIN_MENU_COMMAND) || (request > MAX_MENU_COMMAND))
     {
       SET_ERROR(E_BAD_ARGUMENT);
-      return (const char *)0;
+      returnCPtr((const char *)0);
     }
   else
-    return request_names[ request - MIN_MENU_COMMAND ];
+    returnCPtr(request_names[request - MIN_MENU_COMMAND]);
 }
 
-
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
 |   Function      :  int menu_request_by_name (const char *str);
@@ -92,28 +94,30 @@
 |                    E_NO_MATCH       - request not found
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-menu_request_by_name ( const char *str )
-{ 
+menu_request_by_name(const char *str)
+{
   /* because the table is so small, it doesn't really hurt
      to run sequentially through it.
-  */
+   */
   unsigned int i = 0;
   char buf[16];
-  
+
+  T((T_CALLED("menu_request_by_name(%s)"), _nc_visbuf(str)));
+
   if (str)
     {
-      strncpy(buf,str,sizeof(buf));
-      while( (i<sizeof(buf)) && (buf[i] != '\0') )
+      strncpy(buf, str, sizeof(buf));
+      while ((i < sizeof(buf)) && (buf[i] != '\0'))
 	{
 	  buf[i] = toupper(buf[i]);
 	  i++;
 	}
-      
-      for (i=0; i < A_SIZE; i++)
+
+      for (i = 0; i < A_SIZE; i++)
 	{
-	  if (strncmp(request_names[i],buf,sizeof(buf))==0)
-	    return MIN_MENU_COMMAND + i;
-	} 
+	  if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
+	    returnCode(MIN_MENU_COMMAND + (int)i);
+	}
     }
   RETURN(E_NO_MATCH);
 }
diff -Naur ncurses-5.4.orig/menu/m_scale.c ncurses-5.4/menu/m_scale.c
--- ncurses-5.4.orig/menu/m_scale.c	2003-10-25 14:54:48.000000000 +0000
+++ ncurses-5.4/menu/m_scale.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_scale.c,v 1.7 2003/10/25 14:54:48 tom Exp $")
+MODULE_ID("$Id: m_scale.c,v 1.9 2004/12/11 23:29:34 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -51,11 +51,13 @@
 |                    E_NOT_CONNECTED       - no items are connected to menu
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-scale_menu (const MENU *menu, int *rows, int *cols)
+scale_menu(const MENU * menu, int *rows, int *cols)
 {
-  if (!menu) 
-    RETURN( E_BAD_ARGUMENT );
-  
+  T((T_CALLED("scale_menu(%p,%p,%p)"), menu, rows, cols));
+
+  if (!menu)
+    RETURN(E_BAD_ARGUMENT);
+
   if (menu->items && *(menu->items))
     {
       if (rows)
@@ -65,8 +67,7 @@
       RETURN(E_OK);
     }
   else
-    RETURN( E_NOT_CONNECTED );
+    RETURN(E_NOT_CONNECTED);
 }
 
 /* m_scale.c ends here */
-
diff -Naur ncurses-5.4.orig/menu/m_spacing.c ncurses-5.4/menu/m_spacing.c
--- ncurses-5.4.orig/menu/m_spacing.c	2003-11-08 20:49:06.000000000 +0000
+++ ncurses-5.4/menu/m_spacing.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_spacing.c,v 1.15 2003/11/08 20:49:06 tom Exp $")
+MODULE_ID("$Id: m_spacing.c,v 1.17 2004/12/11 23:29:34 tom Exp $")
 
 #define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8)
 #define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8)
@@ -52,10 +52,12 @@
 |   Return Values :  E_OK                 - on success
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_spacing
-(MENU *menu, int s_desc, int s_row, int s_col )
+set_menu_spacing(MENU * menu, int s_desc, int s_row, int s_col)
 {
-  MENU *m; /* split for ATAC workaround */
+  MENU *m;			/* split for ATAC workaround */
+
+  T((T_CALLED("set_menu_spacing(%p,%d,%d,%d)"), menu, s_desc, s_row, s_col));
+
   m = Normalize_Menu(menu);
 
   assert(m);
@@ -63,19 +65,18 @@
     RETURN(E_POSTED);
 
   if (((s_desc < 0) || (s_desc > MAX_SPC_DESC)) ||
-      ((s_row  < 0) || (s_row  > MAX_SPC_ROWS)) ||
-      ((s_col  < 0) || (s_col  > MAX_SPC_COLS)))
+      ((s_row < 0) || (s_row > MAX_SPC_ROWS)) ||
+      ((s_col < 0) || (s_col > MAX_SPC_COLS)))
     RETURN(E_BAD_ARGUMENT);
 
   m->spc_desc = s_desc ? s_desc : 1;
-  m->spc_rows = s_row  ? s_row  : 1;
-  m->spc_cols = s_col  ? s_col  : 1;
+  m->spc_rows = s_row ? s_row : 1;
+  m->spc_cols = s_col ? s_col : 1;
   _nc_Calculate_Item_Length_and_Width(m);
 
   RETURN(E_OK);
 }
 
-
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu
 |   Function      :  int menu_spacing (const MENU *,int *,int *,int *);
@@ -85,15 +86,21 @@
 |   Return Values :  E_OK             - on success
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-menu_spacing ( const MENU *menu, int* s_desc, int* s_row, int* s_col)
+menu_spacing(const MENU * menu, int *s_desc, int *s_row, int *s_col)
 {
-  const MENU *m; /* split for ATAC workaround */
+  const MENU *m;		/* split for ATAC workaround */
+
+  T((T_CALLED("menu_spacing(%p,%p,%p,%p)"), menu, s_desc, s_row, s_col));
+
   m = Normalize_Menu(menu);
 
   assert(m);
-  if (s_desc) *s_desc = m->spc_desc;
-  if (s_row)  *s_row  = m->spc_rows;
-  if (s_col)  *s_col  = m->spc_cols;
+  if (s_desc)
+    *s_desc = m->spc_desc;
+  if (s_row)
+    *s_row = m->spc_rows;
+  if (s_col)
+    *s_col = m->spc_cols;
 
   RETURN(E_OK);
 }
diff -Naur ncurses-5.4.orig/menu/m_sub.c ncurses-5.4/menu/m_sub.c
--- ncurses-5.4.orig/menu/m_sub.c	2003-10-25 15:23:42.000000000 +0000
+++ ncurses-5.4/menu/m_sub.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_sub.c,v 1.7 2003/10/25 15:23:42 tom Exp $")
+MODULE_ID("$Id: m_sub.c,v 1.10 2004/12/25 21:38:31 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -49,18 +49,20 @@
 |                    E_POSTED       - menu is already posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_sub (MENU *menu, WINDOW *win)
+set_menu_sub(MENU * menu, WINDOW *win)
 {
+  T((T_CALLED("set_menu_sub(%p,%p)"), menu, win));
+
   if (menu)
     {
-      if ( menu->status & _POSTED )
+      if (menu->status & _POSTED)
 	RETURN(E_POSTED);
       menu->usersub = win;
       _nc_Calculate_Item_Length_and_Width(menu);
     }
   else
     _nc_Default_Menu.usersub = win;
-  
+
   RETURN(E_OK);
 }
 
@@ -73,10 +75,12 @@
 |   Return Values :  NULL on error, otherwise a pointer to the window
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(WINDOW *)
-menu_sub (const MENU * menu)
+menu_sub(const MENU * menu)
 {
-  const MENU* m = Normalize_Menu(menu);
-  return Get_Menu_Window(m);
+  const MENU *m = Normalize_Menu(menu);
+
+  T((T_CALLED("menu_sub(%p)"), menu));
+  returnWin(Get_Menu_Window(m));
 }
 
 /* m_sub.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_trace.c ncurses-5.4/menu/m_trace.c
--- ncurses-5.4.orig/menu/m_trace.c	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/menu/m_trace.c	2005-05-13 04:09:50.000000000 +0000
@@ -0,0 +1,77 @@
+/****************************************************************************
+ * Copyright (c) 2004,2005 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"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *   Author:  Thomas E. Dickey                                              *
+ ****************************************************************************/
+
+#include "menu.priv.h"
+
+MODULE_ID("$Id: m_trace.c,v 1.3 2005/01/16 01:06:11 tom Exp $")
+
+NCURSES_EXPORT(ITEM *)
+_nc_retrace_item(ITEM * code)
+{
+  T((T_RETURN("%p"), code));
+  return code;
+}
+
+NCURSES_EXPORT(ITEM **)
+_nc_retrace_item_ptr(ITEM ** code)
+{
+  T((T_RETURN("%p"), code));
+  return code;
+}
+
+NCURSES_EXPORT(Item_Options)
+_nc_retrace_item_opts(Item_Options code)
+{
+  T((T_RETURN("%d"), code));
+  return code;
+}
+
+NCURSES_EXPORT(MENU *)
+_nc_retrace_menu(MENU * code)
+{
+  T((T_RETURN("%p"), code));
+  return code;
+}
+
+NCURSES_EXPORT(Menu_Hook)
+_nc_retrace_menu_hook(Menu_Hook code)
+{
+  T((T_RETURN("%p"), code));
+  return code;
+}
+
+NCURSES_EXPORT(Menu_Options)
+_nc_retrace_menu_opts(Menu_Options code)
+{
+  T((T_RETURN("%d"), code));
+  return code;
+}
diff -Naur ncurses-5.4.orig/menu/m_userptr.c ncurses-5.4/menu/m_userptr.c
--- ncurses-5.4.orig/menu/m_userptr.c	2003-10-25 15:23:42.000000000 +0000
+++ ncurses-5.4/menu/m_userptr.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_userptr.c,v 1.13 2003/10/25 15:23:42 tom Exp $")
+MODULE_ID("$Id: m_userptr.c,v 1.16 2004/12/25 21:38:55 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -49,10 +49,11 @@
 |   Return Values :  E_OK         - success
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_userptr (MENU * menu, void * userptr)
+set_menu_userptr(MENU * menu, void *userptr)
 {
+  T((T_CALLED("set_menu_userptr(%p,%p)"), menu, userptr));
   Normalize_Menu(menu)->userptr = userptr;
-  RETURN( E_OK );
+  RETURN(E_OK);
 }
 
 /*---------------------------------------------------------------------------
@@ -66,9 +67,10 @@
 |                    NULL is returned
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(void *)
-menu_userptr (const MENU * menu)
+menu_userptr(const MENU * menu)
 {
-  return( Normalize_Menu(menu)->userptr);
+  T((T_CALLED("menu_userptr(%p)"), menu));
+  returnVoidPtr(Normalize_Menu(menu)->userptr);
 }
 
 /* m_userptr.c ends here */
diff -Naur ncurses-5.4.orig/menu/m_win.c ncurses-5.4/menu/m_win.c
--- ncurses-5.4.orig/menu/m_win.c	2003-10-25 15:23:42.000000000 +0000
+++ ncurses-5.4/menu/m_win.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -37,7 +37,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_win.c,v 1.12 2003/10/25 15:23:42 tom Exp $")
+MODULE_ID("$Id: m_win.c,v 1.15 2004/12/25 21:39:20 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu  
@@ -49,18 +49,20 @@
 |                    E_POSTED           - menu is already posted
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(int)
-set_menu_win (MENU *menu, WINDOW *win)
+set_menu_win(MENU * menu, WINDOW *win)
 {
+  T((T_CALLED("set_menu_win(%p,%p)"), menu, win));
+
   if (menu)
     {
-      if ( menu->status & _POSTED )
+      if (menu->status & _POSTED)
 	RETURN(E_POSTED);
       menu->userwin = win;
       _nc_Calculate_Item_Length_and_Width(menu);
     }
   else
     _nc_Default_Menu.userwin = win;
-  
+
   RETURN(E_OK);
 }
 
@@ -73,10 +75,12 @@
 |   Return Values :  NULL on error, otherwise pointer to window
 +--------------------------------------------------------------------------*/
 NCURSES_EXPORT(WINDOW *)
-menu_win (const MENU *menu)
+menu_win(const MENU * menu)
 {
-  const MENU* m = Normalize_Menu(menu);
-  return (m->userwin ? m->userwin : stdscr);
+  const MENU *m = Normalize_Menu(menu);
+
+  T((T_CALLED("menu_win(%p)"), menu));
+  returnWin(m->userwin ? m->userwin : stdscr);
 }
 
 /* m_win.c ends here */
diff -Naur ncurses-5.4.orig/menu/menu.priv.h ncurses-5.4/menu/menu.priv.h
--- ncurses-5.4.orig/menu/menu.priv.h	2003-10-25 15:24:29.000000000 +0000
+++ ncurses-5.4/menu/menu.priv.h	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -30,7 +30,7 @@
  *   Author:  Juergen Pfeifer, 1995,1997                                    *
  ****************************************************************************/
 
-/* $Id: menu.priv.h,v 1.16 2003/10/25 15:24:29 tom Exp $ */
+/* $Id: menu.priv.h,v 1.22 2005/01/16 01:02:23 tom Exp $ */
 
 /***************************************************************************
 * Module menu.priv.h                                                       *
@@ -40,9 +40,7 @@
 #ifndef MENU_PRIV_H_incl
 #define MENU_PRIV_H_incl 1
 
-#include <ncurses_cfg.h>
-#include <curses.h>
-
+#include "curses.priv.h"
 #include "mf_common.h"
 #include "menu.h"
 
@@ -108,10 +106,13 @@
   { (menu)->pindex = 0; \
     (menu)->pattern[0] = '\0'; }
 
+#define UChar(c)	((unsigned char)(c))
+
 /* Internal functions. */
 extern NCURSES_EXPORT(void) _nc_Draw_Menu (const MENU *);
 extern NCURSES_EXPORT(void) _nc_Show_Menu (const MENU *);
 extern NCURSES_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *);
+extern NCURSES_EXPORT(int)  _nc_Calculate_Text_Width(const TEXT *);
 extern NCURSES_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *);
 extern NCURSES_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **);
 extern NCURSES_EXPORT(void) _nc_Disconnect_Items (MENU *);
@@ -121,4 +122,31 @@
 extern NCURSES_EXPORT(int)  _nc_menu_cursor_pos (const MENU* menu, const ITEM* item,
 				int* pY, int* pX);
 
+#ifdef TRACE
+
+#define returnItem(code)	TRACE_RETURN(code,item)
+#define returnItemPtr(code)	TRACE_RETURN(code,item_ptr)
+#define returnItemOpts(code)	TRACE_RETURN(code,item_opts)
+#define returnMenu(code)	TRACE_RETURN(code,menu)
+#define returnMenuHook(code)	TRACE_RETURN(code,menu_hook)
+#define returnMenuOpts(code)	TRACE_RETURN(code,menu_opts)
+
+extern NCURSES_EXPORT(ITEM *)	    _nc_retrace_item (ITEM *);
+extern NCURSES_EXPORT(ITEM **)	    _nc_retrace_item_ptr (ITEM **);
+extern NCURSES_EXPORT(Item_Options) _nc_retrace_item_opts (Item_Options);
+extern NCURSES_EXPORT(MENU *)	    _nc_retrace_menu (MENU *);
+extern NCURSES_EXPORT(Menu_Hook)    _nc_retrace_menu_hook (Menu_Hook);
+extern NCURSES_EXPORT(Menu_Options) _nc_retrace_menu_opts (Menu_Options);
+
+#else /* !TRACE */
+
+#define returnItem(code)	return code
+#define returnItemPtr(code)	return code
+#define returnItemOpts(code)	return code
+#define returnMenu(code)	return code
+#define returnMenuHook(code)	return code
+#define returnMenuOpts(code)	return code
+
+#endif /* TRACE/!TRACE */
+
 #endif /* MENU_PRIV_H_incl */
diff -Naur ncurses-5.4.orig/menu/mf_common.h ncurses-5.4/menu/mf_common.h
--- ncurses-5.4.orig/menu/mf_common.h	2003-10-25 15:24:29.000000000 +0000
+++ ncurses-5.4/menu/mf_common.h	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -30,7 +30,7 @@
  *   Author:  Juergen Pfeifer, 1995,1997                                    *
  ****************************************************************************/
 
-/* $Id: mf_common.h,v 0.19 2003/10/25 15:24:29 tom Exp $ */
+/* $Id: mf_common.h,v 0.21 2004/12/11 22:40:40 tom Exp $ */
 
 /* Common internal header for menu and form library */
 
@@ -71,16 +71,21 @@
 #define MAX_REGULAR_CHARACTER (0xff)
 
 #define SET_ERROR(code) (errno=(code))
-#define GET_ERROR() (errno)
-#define RETURN(code) return( SET_ERROR(code) )
+#define GET_ERROR()     (errno)
+
+#ifdef TRACE
+#define RETURN(code)    returnCode( SET_ERROR(code) )
+#else
+#define RETURN(code)    return( SET_ERROR(code) )
+#endif
 
 /* The few common values in the status fields for menus and forms */
-#define _POSTED         (0x01)  /* menu or form is posted                  */
-#define _IN_DRIVER      (0x02)  /* menu or form is processing hook routine */
+#define _POSTED         (0x01U)  /* menu or form is posted                  */
+#define _IN_DRIVER      (0x02U)  /* menu or form is processing hook routine */
 
 /* Call object hook */
 #define Call_Hook( object, handler ) \
-   if ( (object) && ((object)->handler) )\
+   if ( (object) != 0 && ((object)->handler) != (void *) 0 )\
    {\
 	(object)->status |= _IN_DRIVER;\
 	(object)->handler(object);\
diff -Naur ncurses-5.4.orig/menu/modules ncurses-5.4/menu/modules
--- ncurses-5.4.orig/menu/modules	1999-02-18 22:39:04.000000000 +0000
+++ ncurses-5.4/menu/modules	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: modules,v 1.14 1999/02/18 22:39:04 juergen Exp $
+# $Id: modules,v 1.16 2004/12/25 22:06:33 tom Exp $
 ##############################################################################
-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
+# Copyright (c) 1998,2004 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"), #
@@ -56,5 +56,6 @@
 m_scale		lib		$(srcdir)	$(MENU_PRIV_H)
 m_spacing	lib		$(srcdir)	$(MENU_PRIV_H)
 m_sub		lib		$(srcdir)	$(MENU_PRIV_H)
+m_trace		lib		$(srcdir)	$(MENU_PRIV_H)
 m_userptr	lib		$(srcdir)	$(MENU_PRIV_H)
 m_win		lib		$(srcdir)	$(MENU_PRIV_H)
diff -Naur ncurses-5.4.orig/misc/Makefile.in ncurses-5.4/misc/Makefile.in
--- ncurses-5.4.orig/misc/Makefile.in	2002-01-12 23:54:39.000000000 +0000
+++ ncurses-5.4/misc/Makefile.in	2005-05-13 04:09:50.000000000 +0000
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.34 2002/01/12 23:54:39 Robert.Joop Exp $
+# $Id: Makefile.in,v 1.36 2004/07/11 16:00:13 tom Exp $
 ##############################################################################
 # Copyright (c) 1998,2000,2001,2002 Free Software Foundation, Inc.           #
 #                                                                            #
@@ -68,7 +68,7 @@
 INSTALL_DATA	= @INSTALL_DATA@
 
 ################################################################################
-all :
+all :	terminfo.tmp
 
 depend :
 
@@ -76,7 +76,8 @@
 
 install : install.data
 
-install.data :	$(DESTDIR)$(libdir) \
+install.data :	terminfo.tmp \
+		$(DESTDIR)$(libdir) \
 		$(DESTDIR)$(ticdir) \
 		$(DESTDIR)$(tabsetdir)
 	DESTDIR=${DESTDIR} \
@@ -87,7 +88,7 @@
 	srcdir=${srcdir} \
 	datadir=${datadir} \
 	ticdir=${ticdir} \
-	source=${source} \
+	source=terminfo.tmp \
 	THIS_CC="$(CC)" \
 	THAT_CC="$(HOSTCC)" \
 	sh ./run_tic.sh
@@ -98,10 +99,19 @@
 			$(INSTALL_DATA) $$i $(DESTDIR)$(tabsetdir)/$$i; \
 			fi; done'
 
+terminfo.tmp : run_tic.sed $(source)
+	echo '** adjusting tabset paths'
+	sed -f run_tic.sed $(source) >terminfo.tmp
+
+run_tic.sed :
+	WHICH_XTERM=@WHICH_XTERM@ \
+	ticdir=${ticdir} \
+	sh $(srcdir)/gen_edit.sh >$@
+
 $(DESTDIR)$(libdir) \
 $(DESTDIR)$(tabsetdir) \
 $(DESTDIR)$(ticdir) :
-	sh $(srcdir)/../mkinstalldirs $@
+	sh $(top_srcdir)/mkinstalldirs $@
 
 uninstall : uninstall.data
 
@@ -114,6 +124,8 @@
 @MAKE_UPPER_TAGS@TAGS :
 
 mostlyclean :
+	-rm -f terminfo.tmp
+	-rm -f run_tic.sed
 	-rm -f core tags TAGS *~ *.bak *.ln *.atac trace
 
 clean :: mostlyclean
diff -Naur ncurses-5.4.orig/misc/gen_edit.sh ncurses-5.4/misc/gen_edit.sh
--- ncurses-5.4.orig/misc/gen_edit.sh	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/misc/gen_edit.sh	2005-05-13 04:09:50.000000000 +0000
@@ -0,0 +1,58 @@
+#!/bin/sh
+##############################################################################
+# Copyright (c) 2004 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"), #
+# to deal in the Software without restriction, including without limitation  #
+# the rights to use, copy, modify, merge, publish, distribute, distribute    #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the  #
+# following conditions:                                                      #
+#                                                                            #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software.                        #
+#                                                                            #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
+# DEALINGS IN THE SOFTWARE.                                                  #
+#                                                                            #
+# Except as contained in this notice, the name(s) of the above copyright     #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written               #
+# authorization.                                                             #
+##############################################################################
+#
+# Author: Thomas E. Dickey
+#
+# $Id: gen_edit.sh,v 1.1 2004/07/11 15:01:29 tom Exp $
+# Generate a sed-script for converting the terminfo.src to the form which will
+# be installed.
+#
+# Assumes:
+#	The leaf directory names (lib, tabset, terminfo)
+#
+
+: ${ticdir=@TERMINFO@}
+: ${xterm_new=@WHICH_XTERM@}
+
+# If we're not installing into /usr/share/, we'll have to adjust the location
+# of the tabset files in terminfo.src (which are in a parallel directory).
+TABSET=`echo $ticdir | sed -e 's%/terminfo$%/tabset%'`
+if test "x$TABSET" != "x/usr/share/tabset" ; then
+cat <<EOF
+s%/usr/share/tabset%$TABSET%g
+EOF
+fi
+
+if test "$xterm_new" != "xterm-new" ; then
+cat <<EOF
+/^# This is xterm for ncurses/,/^$/{
+	s/use=xterm-new,/use=$WHICH_XTERM,/
+}
+EOF
+fi
diff -Naur ncurses-5.4.orig/misc/indent.pro ncurses-5.4/misc/indent.pro
--- ncurses-5.4.orig/misc/indent.pro	2000-07-29 16:10:30.000000000 +0000
+++ ncurses-5.4/misc/indent.pro	1970-01-01 00:00:00.000000000 +0000
@@ -1,35 +0,0 @@
-/* Use this with indent 2.0 (2.1 is not acceptable, since it has more bugs) */
-/* indent 4 columns */
--i4
-/* tab stops every 8 columns */
--ts8
-/* cuddle 'else' */
--ce
-/* force blank lines after procedure body */
--bap
-/* do not force newline after comma in declaration */
--nbc
-/* do not force blank line after declarations */
--nbad
-/* format braces inline */
--br
-/* do not line up parentheses */
--lp
-/* put the type of a procedure on the line before its name */
--psl
-/* do not insert a space between procedure name and '(' */
--npcs
-/* leave preprocessor space */
--lps
-/* swallow optional blank lines */
--sob
-/* continuation indent of 0 spaces */
--ci0 
-/* force space before semicolon on same line */
--ss
-
-/* for vile */
--T size_t
--T LINE
--T BUFFER
--T WINDOW
diff -Naur ncurses-5.4.orig/misc/jpf-indent ncurses-5.4/misc/jpf-indent
--- ncurses-5.4.orig/misc/jpf-indent	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/misc/jpf-indent	2005-05-13 04:09:50.000000000 +0000
@@ -0,0 +1,87 @@
+#!/bin/sh
+# $Id: jpf-indent,v 1.3 2004/05/29 19:14:45 tom Exp $
+# indent ncurses source written by Juergen Pfeifer
+NOOP=no
+OPTS='
+-npro
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--brace-indent2
+--braces-after-if-line
+--continue-at-parentheses
+--indent-level2
+--line-length80
+--no-space-after-casts
+--no-space-after-function-call-names
+--parameter-indentation4
+--swallow-optional-blank-lines
+--tab-size8
+-T FIELD
+-T FIELDTYPE
+-T FIELD_CELL
+-T FORM
+-T INLINE
+-T RegExp_Arg 
+-T TypeArgument 
+-T WINDOW
+-T attr_t
+-T bool
+-T cchar_t
+-T chtype
+-T enumARG
+-T va_list
+-T wchar_t 
+'
+for name in $*
+do
+	case $name in
+	-v|-n)
+		NOOP=yes
+		OPTS="$OPTS -v"
+		;;
+	-*)
+		OPTS="$OPTS $name"
+		;;
+	*.[ch])
+		save="${name}".a$$
+		test="${name}".b$$
+		rm -f "$save" "$test"
+		mv "$name" "$save"
+		sed \
+			-e '/MODULE_ID(/s/)$/);/' \
+			-e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \
+			-e 's,\(\<NCURSES_EXPORT_VAR\>\),//\1,' \
+			"$save" >"$test"
+		cp "$test" "$name"
+		chmod u+w "$name"
+		# ${INDENT_PROG-indent} --version
+		${INDENT_PROG-indent} $OPTS "$name"
+		sed \
+			-e '/MODULE_ID(/s/);$/)/' \
+			-e 's,;[ 	]*//GCC_NORETURN;, GCC_NORETURN;,' \
+			-e 's,//\(\<NCURSES_EXPORT_VAR\>\),\1,' \
+			"$name" >"$test"
+		mv "$test" "$name"
+		rm -f "${name}~"
+		if test $NOOP = yes ; then
+			if (cmp -s "$name" "$save" ) then
+				echo "** no change: $name"
+			else
+				diff -u "$save" "$name"
+			fi
+			rm -f "$name"
+			mv "$save" "$name"
+		elif ( cmp -s "$name" "$save" ) ; then
+			echo "** unchanged $name"
+			rm -f "${name}"
+			mv "$save" "$name"
+		else
+			echo "** updated $name"
+			rm -f "$save"
+		fi
+		;;
+	*)
+		echo "** ignored:   $name"
+		;;
+	esac
+done
diff -Naur ncurses-5.4.orig/misc/ncu-indent ncurses-5.4/misc/ncu-indent
--- ncurses-5.4.orig/misc/ncu-indent	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/misc/ncu-indent	2005-05-13 04:09:50.000000000 +0000
@@ -0,0 +1,98 @@
+#!/bin/sh
+# $Id: ncu-indent,v 1.12 2004/11/23 00:45:48 tom Exp $
+NOOP=no
+OPTS='
+--blank-lines-after-procedures
+--braces-on-if-line
+--continuation-indentation0
+--continue-at-parentheses
+--cuddle-else
+--indent-level4
+--leave-preprocessor-space
+--no-blank-lines-after-commas
+--no-blank-lines-after-declarations
+--no-space-after-function-call-names
+--procnames-start-lines
+--space-special-semicolon
+--swallow-optional-blank-lines
+--tab-size8
+
+-T NCURSES_EXPORT_VAR
+-T SCREEN
+-T TERMTYPE
+-T attr_t
+-T cchar_t
+-T chtype
+-T inline
+-T wchar_t
+-T wint_t
+
+-T BUFFER
+-T CHARTYPE
+-T FILE
+-T GCC_NORETURN
+-T LINE
+-T MARK
+-T RETSIGTYPE 
+-T TBUFF
+-T WINDOW
+-T size_t
+-T va_list
+
+-T Cardinal
+-T Widget
+-T XtPointer
+'
+for name in $*
+do
+	case $name in
+	-v|-n)
+		NOOP=yes
+		OPTS="$OPTS -v"
+		;;
+	-*)
+		OPTS="$OPTS $name"
+		;;
+	*.[ch])
+		save="${name}".a$$
+		test="${name}".b$$
+		rm -f "$save" "$test"
+		mv "$name" "$save"
+		sed \
+			-e '/MODULE_ID(/s/)$/);/' \
+			-e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \
+			-e 's,\(\<NCURSES_EXPORT_VAR\>\),//\1,' \
+			"$save" >"$test"
+		cp "$test" "$name"
+		chmod u+w "$name"
+		# ${INDENT_PROG-indent} --version
+		${INDENT_PROG-indent} -npro $OPTS "$name"
+		sed \
+			-e '/MODULE_ID(/s/);$/)/' \
+			-e 's,;[ 	]*//GCC_NORETURN;, GCC_NORETURN;,' \
+			-e 's,//\(\<NCURSES_EXPORT_VAR\>\),\1,' \
+			"$name" >"$test"
+		mv "$test" "$name"
+		rm -f "${name}~"
+		if test $NOOP = yes ; then
+			if (cmp -s "$name" "$save" ) then
+				echo "** no change: $name"
+			else
+				diff -u "$save" "$name"
+			fi
+			rm -f "$name"
+			mv "$save" "$name"
+		elif ( cmp -s "$name" "$save" ) ; then
+			echo "** unchanged $name"
+			rm -f "${name}"
+			mv "$save" "$name"
+		else
+			echo "** updated $name"
+			rm -f "$save"
+		fi
+		;;
+	*)
+		echo "** ignored:   $name"
+		;;
+	esac
+done
diff -Naur ncurses-5.4.orig/misc/run_tic.in ncurses-5.4/misc/run_tic.in
--- ncurses-5.4.orig/misc/run_tic.in	2003-09-06 22:31:44.000000000 +0000
+++ ncurses-5.4/misc/run_tic.in	2005-05-13 04:09:52.000000000 +0000
@@ -1,6 +1,6 @@
 #!@SHELL@
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -29,7 +29,7 @@
 #
 # Author: Thomas E. Dickey 1996,2000
 #
-# $Id: run_tic.in,v 1.15 2003/09/06 22:31:44 Dan.Kegel Exp $
+# $Id: run_tic.in,v 1.18 2005/03/26 22:57:16 tom Exp $
 # This script is used to install terminfo.src using tic.  We use a script
 # because the path checking is too awkward to do in a makefile.
 #
@@ -54,6 +54,7 @@
 : ${LN_S="@LN_S@"}
 : ${THAT_CC=cc}
 : ${THIS_CC=cc}
+: ${ext_funcs=@NCURSES_EXT_FUNCS@}
 
 test -z "${DESTDIR}" && DESTDIR=
 
@@ -72,15 +73,17 @@
 SHLIB=
 fi
 
-#
+
 # set another env var that doesn't get reset when `shlib' runs, so `shlib' uses
 # the PATH we just set.
-#
-NEWPATH=$PATH
-export NEWPATH
-PROG_BIN_DIR=${DESTDIR}$bindir
-export PROG_BIN_DIR
+SHLIB_PATH=$PATH
+export SHLIB_PATH
 
+# set a variable to simplify environment update in shlib
+SHLIB_HOST=@host_os@
+export SHLIB_HOST
+
+# don't use user's TERMINFO variable
 TERMINFO=${DESTDIR}$ticdir ; export TERMINFO
 umask 022
 
@@ -93,26 +96,35 @@
 # the directory is actually a symbolic link.
 ( cd $TERMINFO && rm -fr ? 2>/dev/null )
 
-# If we're not installing into /usr/share/, we'll have to adjust the location
-# of the tabset files in terminfo.src (which are in a parallel directory).
-TABSET=`echo $ticdir | sed -e 's%/terminfo$%/tabset%'`
-if test "x$TABSET" != "x/usr/share/tabset" ; then
-	echo '** adjusting tabset paths'
-	TMP=${TMPDIR-/tmp}/$$
-	sed -e s%/usr/share/tabset%$TABSET%g $source >$TMP
-	trap "rm -f $TMP" 0 1 2 5 15
-	source=$TMP
-fi
+if test "$ext_funcs" = 1 ; then
+cat <<EOF
+Running tic to install $TERMINFO ...
+
+	You may see messages regarding extended capabilities, e.g., AX.
+	These are extended terminal capabilities which are compiled
+	using
+		tic -x
+	If you have ncurses 4.2 applications, you should read the INSTALL
+	document, and install the terminfo without the -x option.
 
+EOF
+if ( $SHLIB tic$suffix -x -s -o $TERMINFO $source )
+then
+	echo '** built new '$TERMINFO
+else
+	echo '? tic could not build '$TERMINFO
+	exit 1
+fi
+else
 cat <<EOF
 Running tic to install $TERMINFO ...
 
 	You may see messages regarding unknown capabilities, e.g., AX.
-	These are extended terminal capabilities which can be compiled
+	These are extended terminal capabilities which may be compiled
 	using
 		tic -x
-	Read the INSTALL document before doing this - it can cause
-	problems for older ncurses applications.
+	If you have ncurses 4.2 applications, you should read the INSTALL
+	document, and install the terminfo without the -x option.
 
 EOF
 if ( $SHLIB tic$suffix -s -o $TERMINFO $source )
@@ -122,6 +134,7 @@
 	echo '? tic could not build '$TERMINFO
 	exit 1
 fi
+fi
 
 # Make a symbolic link to provide compatibility with applications that expect
 # to find terminfo under /usr/lib.  That is, we'll _try_ to do that.  Not
diff -Naur ncurses-5.4.orig/misc/shlib ncurses-5.4/misc/shlib
--- ncurses-5.4.orig/misc/shlib	2003-07-19 22:58:14.000000000 +0000
+++ ncurses-5.4/misc/shlib	2005-05-13 04:09:52.000000000 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##############################################################################
-# Copyright (c) 1998,2000 Free Software Foundation, Inc.                     #
+# Copyright (c) 1998-2003,2005 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"), #
@@ -29,7 +29,7 @@
 #
 # Author: Thomas E. Dickey <dickey@clark.net> 1996
 #
-# $Id: shlib,v 1.7 2003/07/19 22:58:14 tom Exp $
+# $Id: shlib,v 1.9 2005/03/26 23:10:25 tom Exp $
 # Use this script as a wrapper when running executables linked to shared
 # libraries on systems that use the $LD_LIBRARY_PATH variable and don't embed
 # the soname's path within the linked executable (such as IRIX), e.g,
@@ -58,37 +58,83 @@
 # Special cases:
 #
 #	BeOS R4.5 uses $LIBRARY_PATH rather than $LD_LIBRARY_PATH.
-
+#	Cygwin uses $PATH
+#	Mac OS X uses $DYLD_LIBRARY_PATH
 #
-# Make sure that we use the PATH that was set in run_tic.sh
+# Other cases not handled by this script:
+#
+#	AIX uses $LIBPATH
+#	IRIX64 may use $LD_LIBRARY64_PATH or $LD_LIBRARYN32_PATH
+#	Solaris may use $LD_LIBRARY_PATH_64
 #
-if test X$NEWPATH != X ; then
-	PATH=$NEWPATH
+CDPATH=
+#
+# Make sure that we use the PATH that was set in run_tic.sh
+if test -n "$SHLIB_PATH" ; then
+	PATH=$SHLIB_PATH
 	export PATH
 fi
 
+# Find the lib-directory for this build tree
 q=""
-for p in lib ../lib
+for p in lib ../lib ../../lib ../../../lib
 do
 	if test -d $p; then
-		q="$p"
+		q=`cd $p; pwd`
+	elif test -f configure ; then
+		break
 	fi
 done
+
+# Set the environment variable.
 if test -n "$q" ; then
-	if test -n "$LD_LIBRARY_PATH"; then
-		LD_LIBRARY_PATH="$q:$LD_LIBRARY_PATH"
+	system=
+	if test -n "$SHLIB_HOST" ; then
+		system="$SHLIB_HOST"
+	elif test -n "$PATHEXT" ; then
+		system=cygwin
 	elif test -n "$LIBRARY_PATH" ; then
-		LIBRARY_PATH="$q:$LIBRARY_PATH"
+		system=beos
+	elif test -n "$DYLD_LIBRARY_PATH" ; then
+		system=darwin
+	elif test -n "$LD_LIBRARY_PATH"; then
+		system=unix
 	else
-		LD_LIBRARY_PATH="$q"
+		for r in $q/*.*
+		do
+			if test -f "$r"
+			then
+				case $r in
+				*.dll)
+					system=cygwin
+					;;
+				*.dylib)
+					system=darwin
+					;;
+				esac
+			fi
+			test -n "$system" && break
+		done
 	fi
-	export LD_LIBRARY_PATH
-fi
 
-# cygwin doesn't use LD_LIBRARY_PATH, but does use PATH
-if test -n "$PATHEXT" ; then
-	PATH=$LD_LIBRARY_PATH:$PATH;
-	export PATH
+	case .$system in
+	.cygwin*)
+		variable=PATH
+		;;
+	.beos*)
+		variable=LIBRARY_PATH
+		;;
+	.darwin*)
+		variable=DYLD_LIBRARY_PATH
+		;;
+	*)
+		variable=LD_LIBRARY_PATH
+		;;
+	esac
+
+	eval 'test -z "$'$variable'" && '$variable'=":"'
+	eval $variable'="$q:$'$variable'"'
+	eval 'export '$variable
 fi
 
 eval "$*"
diff -Naur ncurses-5.4.orig/misc/terminfo.src ncurses-5.4/misc/terminfo.src
--- ncurses-5.4.orig/misc/terminfo.src	2004-01-18 01:37:18.000000000 +0000
+++ ncurses-5.4/misc/terminfo.src	2005-05-13 04:09:59.000000000 +0000
@@ -4,12 +4,13 @@
 # Report bugs and new terminal descriptions to
 #	bug-ncurses@gnu.org
 #
-#	$Revision: 1.227 $
-#	$Date: 2004/01/18 01:37:18 $
+#	$Revision: 1.263 $
+#	$Date: 2005/05/07 19:58:26 $
 #
 # The original header is preserved below for reference.  It is noted that there
-# is a newer version which differs in some cosmetic details; we have decided
-# to not change the header unless there is also a change in content.
+# is a "newer" version which differs in some cosmetic details (but actually
+# stopped updates several years ago); we have decided to not change the header
+# unless there is also a change in content.
 #
 #------------------------------------------------------------------------------
 #	Version 10.2.1
@@ -291,7 +292,7 @@
 	bel=^G, clear=^L, cr=^M, cub1=^H, cud1=^J, ht=^I, kcub1=^H, 
 	kcud1=^J, nel=^M^J, .kbs=^H, 
 
-vanilla, 
+vanilla|dumb tty, 
 	OTbs, 
 	bel=^G, cr=^M, cud1=^J, ind=^J, 
 
@@ -329,7 +330,9 @@
 	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, 
 	khome=\E[H, 
 ansi+sgr|ansi graphic renditions, 
-	blink=\E[5m, invis=\E[8m, rev=\E[7m, sgr0=\E[0m, 
+	blink=\E[5m, invis=\E[8m, rev=\E[7m, 
+	sgr=\E[0%?%p3%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%;, 
+	sgr0=\E[0m, 
 ansi+sgrso|ansi standout only, 
 	rmso=\E[m, smso=\E[7m, 
 ansi+sgrul|ansi underline only, 
@@ -705,12 +708,12 @@
 	kf19=\E[33~, kf2=\E[[B, kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, 
 	kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
 	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
-	kspd=^Z, nel=^M^J, rc=\E8, rev=\E[7m, ri=\EM, rmir=\E[4l, 
-	rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]R, sc=\E7, 
+	kspd=^Z, nel=^M^J, rc=\E8, rev=\E[7m, ri=\EM, rmam=\E[?7l, 
+	rmir=\E[4l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]R, sc=\E7, 
 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, 
-	smir=\E[4h, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, 
-	u7=\E[6n, u8=\E[?6c, u9=\E[c, vpa=\E[%i%p1%dd, 
-	use=klone+sgr, use=ecma+color, 
+	smam=\E[?7h, smir=\E[4h, smul=\E[4m, tbc=\E[3g, 
+	u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?6c, u9=\E[c, 
+	vpa=\E[%i%p1%dd, use=klone+sgr, use=ecma+color, 
 
 linux-m|Linux console no color, 
 	colors@, pairs@, 
@@ -791,6 +794,63 @@
 	dim=\E[2m, invis=\E[8m, op=\E[37;40m, rmso=\E[27m, 
 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, use=mach, 
 
+# From: Marcus Brinkmann
+# http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/hurd/hurd/console/
+#
+# Comments in the original are summarized here:
+#
+# hurd uses 8-bit characters (km).
+#
+# Although it doesn't do XON/XOFF, we don't want padding characters (xon).
+#
+# Regarding compatibility to vt100:  hurd doesn't specify <xenl>, as we don't
+# have the eat_newline_glitch.  It doesn't support setting or removing tab
+# stops (hts/tbc).
+#
+# hurd uses ^H instead of \E[D for cub1, as only ^H implements <bw> and it is
+# one byte instead three.
+#
+# <ich1> is not included because hurd has insert mode.
+#
+# hurd doesn't use ^J for scrolling, because this could put things into the
+# scrollback buffer.
+#
+# gsbom/grbom are used to enable/disable real bold (not intensity bright) mode. 
+# This is a GNU extension.
+#
+# The original has commented-out ncv, but is restored here.
+#
+# Reading the source, RIS resets cnorm, but not xmous.
+hurd|The GNU Hurd console server, 
+	am, bce, bw, eo, km, mir, msgr, xon, 
+	colors#8, it#8, ncv#18, pairs#64, 
+	acsc=++\,\,--..00ii``aaffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
+	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, 
+	clear=\Ec, cnorm=\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, 
+	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B, 
+	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, 
+	cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[34l, dch=\E[%p1%dP, 
+	dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, 
+	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, flash=\Eg, 
+	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, ich=\E[%p1%d@, 
+	il=\E[%p1%dL, il1=\E[L, ind=\E[S, indn=\E[%p1%dS, 
+	invis=\E[8m, kb2=\E[G, kbs=\177, kcbt=\E[Z, kcub1=\EOD, 
+	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, 
+	kend=\E[4~, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, 
+	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
+	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, 
+	kf2=\EOQ, kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf5=\E[15~, 
+	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
+	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
+	kspd=^Z, nel=^M^J, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\E[T, 
+	rin=\E[%p1%dT, ritm=\E[23m, rmacs=\E[10m, rmir=\E[4l, 
+	rmso=\E[27m, rmul=\E[24m, rs1=\EM\E[?1000l, sc=\E7, 
+	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
+	sgr=\E[0%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, 
+	sgr0=\E[0m, sitm=\E[3m, smacs=\E[11m, smir=\E[4h, 
+	smso=\E[7m, smul=\E[4m, vpa=\E[%i%p1%dd, grbom=\E[>1l, 
+	gsbom=\E[>1h, 
+
 #### OSF Unix
 #
 
@@ -1464,7 +1524,7 @@
 # Entry for the DNARD OpenFirmware console, close to ANSI but not quite.
 #
 # (still unfinished, but good enough so far.)
-ofcons, 
+ofcons|DNARD OpenFirmware console, 
 	bw, 
 	cols#80, lines#30, 
 	bel=^G, blink=\2337;2m, bold=\2331m, clear=^L, cr=^M, 
@@ -1482,15 +1542,29 @@
 	sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m, 
 	sgr0=\2330m, 
 
-# NetBSD "wscons" emulator in vt220 mode
-# These are micro-minimal and probably need to be redone for real
-# after the manner of the pcvt entries.
+# NetBSD "wscons" emulator in vt220 mode.
+# This entry is based on the NetBSD termcap entry, correcting the ncv value.
+# The emulator renders underlined text in red.  Colors are otherwise usable.
+#
+# Testing the emulator and reading the source code (NetBSD 2.0), it appears
+# that "vt220" is inaccurate.  There are a few vt220-features, but most of the
+# vt220 screens in vttest do not work with this emulator.  For instance, it
+# identifies itself (primary DA response) as a vt220 with selective erase.  But
+# the selective erase feature does not work.  The secondary response is copied
+# from Kermit's emulation of vt220, does not correspond to actual vt220.  At
+# the level of detail in a termcap, it is a passable emulator, since ECH does
+# work.  Don't use it on a VMS system -TD
 wsvt25|NetBSD wscons in 25 line DEC VT220 mode, 
-	cols#80, lines#25, use=vt220, 
+	bce, msgr, 
+	colors#8, cols#80, it#8, lines#25, ncv#2, pairs#64, 
+	is2=\E[r\E[25;1H, kend=\E[8~, kf1=\E[11~, kf10=\E[21~, 
+	kf11=\E[23~, kf12=\E[24~, kf2=\E[12~, kf3=\E[13~, 
+	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, 
+	kf9=\E[20~, khome=\E[7~, op=\E[m, setab=\E[4%p1%dm, 
+	setaf=\E[3%p1%dm, use=vt220, 
 
 wsvt25m|NetBSD wscons in 25 line DEC VT220 mode with Meta, 
-	km, 
-	cols#80, lines#25, use=vt220, 
+	km, use=wsvt25, 
 
 # `rasterconsole' provided by 4.4BSD, NetBSD and OpenBSD on SPARC, and 
 # DECstation/pmax.
@@ -1563,31 +1637,34 @@
 	cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C, 
 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
 	cvvis=\E[=1C, dch=\E[%p1%dP, dch1=\E[P, dim=\E[30;1m, 
-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, 
-	hpa=\E[%i%p1%d`, ht=^I, ich=\E[%p1%d@, ich1=\E[@, 
-	il=\E[%p1%dL, il1=\E[L, ind=\E[S, indn=\E[%p1%dS, kb2=\E[E, 
-	kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, 
-	kcuu1=\E[A, kdch1=\177, kend=\E[F, kf1=\E[M, kf10=\E[V, 
-	kf11=\E[W, kf12=\E[X, kf13=\E[Y, kf14=\E[Z, kf15=\E[a, 
-	kf16=\E[b, kf17=\E[c, kf18=\E[d, kf19=\E[e, kf2=\E[N, 
-	kf20=\E[f, kf21=\E[g, kf22=\E[h, kf23=\E[i, kf24=\E[j, 
-	kf25=\E[k, kf26=\E[l, kf27=\E[m, kf28=\E[n, kf29=\E[o, 
-	kf3=\E[O, kf30=\E[p, kf31=\E[q, kf32=\E[r, kf33=\E[s, 
-	kf34=\E[t, kf35=\E[u, kf36=\E[v, kf37=\E[w, kf38=\E[x, 
-	kf39=\E[y, kf4=\E[P, kf40=\E[z, kf41=\E[@, kf42=\E[[, 
-	kf43=\E[\\, kf44=\E[], kf45=\E[\^, kf46=\E[_, kf47=\E[`, 
-	kf48=\E[{, kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, 
-	khome=\E[H, kich1=\E[L, knp=\E[G, kpp=\E[I, nel=\E[E, 
-	op=\E[x, rev=\E[7m, ri=\E[T, rin=\E[%p1%dT, rmso=\E[m, 
-	rs2=\E[x\E[m\Ec, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
+	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, 
+	home=\E[H, hpa=\E[%i%p1%d`, ht=^I, ich=\E[%p1%d@, 
+	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\E[S, 
+	indn=\E[%p1%dS, kb2=\E[E, kbs=^H, kcbt=\E[Z, kcub1=\E[D, 
+	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\177, kend=\E[F, 
+	kf1=\E[M, kf10=\E[V, kf11=\E[W, kf12=\E[X, kf13=\E[Y, 
+	kf14=\E[Z, kf15=\E[a, kf16=\E[b, kf17=\E[c, kf18=\E[d, 
+	kf19=\E[e, kf2=\E[N, kf20=\E[f, kf21=\E[g, kf22=\E[h, 
+	kf23=\E[i, kf24=\E[j, kf25=\E[k, kf26=\E[l, kf27=\E[m, 
+	kf28=\E[n, kf29=\E[o, kf3=\E[O, kf30=\E[p, kf31=\E[q, 
+	kf32=\E[r, kf33=\E[s, kf34=\E[t, kf35=\E[u, kf36=\E[v, 
+	kf37=\E[w, kf38=\E[x, kf39=\E[y, kf4=\E[P, kf40=\E[z, 
+	kf41=\E[@, kf42=\E[[, kf43=\E[\\, kf44=\E[], kf45=\E[\^, 
+	kf46=\E[_, kf47=\E[`, kf48=\E[{, kf5=\E[Q, kf6=\E[R, 
+	kf7=\E[S, kf8=\E[T, kf9=\E[U, khome=\E[H, kich1=\E[L, 
+	knp=\E[G, kpp=\E[I, nel=\E[E, op=\E[x, rc=\E8, rev=\E[7m, 
+	ri=\E[T, rin=\E[%p1%dT, rmso=\E[m, rs2=\E[x\E[m\Ec, sc=\E7, 
+	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
+	sgr=\E[0%?%p1%t;2;7%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;30;1%;%?%p6%t;1%;m, 
 	sgr0=\E[m, smso=\E[7m, vpa=\E[%i%p1%dd, 
 cons25|ansis|ansi80x25|freebsd console (25-line ansi mode), 
 	acsc=-\030.^Y0\333`\004a\260f\370g\361h\261i\025j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x\263y\363z\362~\371, 
 	use=cons25w, 
 cons25-m|ansis-mono|ansi80x25-mono|freebsd console (25-line mono ansi mode), 
 	colors@, pairs@, 
-	bold@, dim@, op@, rmul=\E[m, setab@, setaf@, smul=\E[4m, 
-	use=cons25, 
+	bold@, dim@, op@, rmul=\E[m, setab@, setaf@, 
+	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;m, 
+	smul=\E[4m, use=cons25, 
 cons30|ansi80x30|freebsd console (30-line ansi mode), 
 	lines#30, use=cons25, 
 cons30-m|ansi80x30-mono|freebsd console (30-line mono ansi mode), 
@@ -1609,7 +1686,9 @@
 	use=cons25w, 
 cons25r-m|pc3r-m|ibmpc3r-mono|cons25-koi8r-m|freebsd console w/koi8-r cyrillic (mono), 
 	colors@, pairs@, 
-	op@, rmul=\E[m, setab@, setaf@, smul=\E[4m, use=cons25r, 
+	op@, rmul=\E[m, setab@, setaf@, 
+	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;30;1%;%?%p6%t;1%;m, 
+	smul=\E[4m, use=cons25r, 
 cons50r|cons50-koi8r|freebsd console w/koi8-r cyrillic (50 lines), 
 	lines#50, use=cons25r, 
 cons50r-m|cons50-koi8r-m|freebsd console w/koi8-r cyrillic (50-line mono), 
@@ -1624,8 +1703,9 @@
 	use=cons25w, 
 cons25l1-m|cons25-iso-m|freebsd console w/iso 8859-1 chars (mono), 
 	colors@, pairs@, 
-	bold@, dim@, op@, rmul=\E[m, setab@, setaf@, smul=\E[4m, 
-	use=cons25l1, 
+	bold@, dim@, op@, rmul=\E[m, setab@, setaf@, 
+	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;m, 
+	smul=\E[4m, use=cons25l1, 
 cons50l1|cons50-iso8859|freebsd console w/iso 8859-1 chars (50 lines), 
 	lines#50, use=cons25l1, 
 cons50l1-m|cons50-iso-m|freebsd console w/iso 8859-1 chars (50-line mono), 
@@ -1705,11 +1785,27 @@
 
 #### DEC VT52
 # (<acsc>/<rmacs>/<smacs> capabilities aren't in DEC's official entry -- esr)
+#
+# Actually (TD pointed this out at the time the acsc string was added):
+# vt52 shouldn't define full acsc since most of the cells don't match.
+# see vt100 manual page A-31.  This is the list that does match:
+#	f degree
+#	g plus/minus
+#	h right-arrow
+#	k down-arrow
+#	m scan-1
+#	o scan-3
+#	q scan-5
+#	s scan-7
+# The line-drawing happens to work in several terminal emulators, but should
+# not be used as a guide to the capabilities of the vt52.  Note in particular
+# that vt52 does not support line-drawing characters (the scan-X values refer
+# to a crude plotting feature) -TD
 vt52|dec vt52, 
 	OTbs, 
 	cols#80, it#8, lines#24, 
-	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
-	bel=^G, clear=\EH\EJ, cr=^M, cub1=\ED, cud1=\EB, cuf1=\EC, 
+	acsc=ffgghhompoqqss.k, bel=^G, clear=\EH\EJ, cr=^M, 
+	cub1=\ED, cud1=\EB, cuf1=\EC, 
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c, cuu1=\EA, ed=\EJ, 
 	el=\EK, home=\EH, ht=^I, ind=^J, kbs=^H, kcub1=\ED, kcud1=\EB, 
 	kcuf1=\EC, kcuu1=\EA, nel=^M^J, ri=\EI, rmacs=\EG, smacs=\EF, 
@@ -1894,7 +1990,7 @@
 #
 # (vt100: I added <rmam>/<smam> based on the init string, also <OTbs>. -- esr)
 vt100|vt100-am|dec vt100 (w/advanced video), 
-	OTbs, am, msgr, xenl, xon, 
+	OTbs, am, mc5i, msgr, xenl, xon, 
 	cols#80, it#8, lines#24, vt#3, 
 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
 	bel=^G, blink=\E[5m$<2>, bold=\E[1m$<2>, 
@@ -1904,8 +2000,9 @@
 	cup=\E[%i%p1%d;%p2%dH$<5>, cuu=\E[%p1%dA, 
 	cuu1=\E[A$<2>, ed=\E[J$<50>, el=\E[K$<3>, el1=\E[1K$<3>, 
 	enacs=\E(B\E)0, home=\E[H, ht=^I, hts=\EH, ind=^J, kbs=^H, 
-	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, rc=\E8, 
-	rev=\E[7m$<2>, ri=\EM$<5>, rmacs=^O, rmam=\E[?7l, 
+	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, lf1=pf1, 
+	lf2=pf2, lf3=pf3, lf4=pf4, mc0=\E[0i, mc4=\E[4i, mc5=\E[5i, 
+	rc=\E8, rev=\E[7m$<2>, ri=\EM$<5>, rmacs=^O, rmam=\E[?7l, 
 	rmkx=\E[?1l\E>, rmso=\E[m$<2>, rmul=\E[m$<2>, 
 	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7, 
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;$<2>, 
@@ -1955,7 +2052,6 @@
 # This entry (or vt102-nsgr) is probably the right thing to use for
 # these.  
 vt102|dec vt102, 
-	mir, 
 	dch1=\E[P, dl1=\E[M, il1=\E[L, rmir=\E[4l, smir=\E[4h, 
 	use=vt100, 
 vt102-w|dec vt102 in wide mode, 
@@ -1974,7 +2070,9 @@
 	sgr@, sgr0=\E[m, use=vt102, 
 
 # VT125 Graphics CRT.  Clear screen also erases graphics
+# Some vt125's came configured with vt102 support.
 vt125|vt125 graphics terminal, 
+	mir, 
 	clear=\E[H\E[2J\EPpS(E)\E\\$<50>, use=vt100, 
 
 # This isn't a DEC entry, it came from University of Wisconsin.
@@ -2058,12 +2156,14 @@
 	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, 
 	kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf6=\E[17~, kf7=\E[18~, 
 	kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, khlp=\E[28~, 
-	khome=\E[H, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, krdo=\E[29~, 
-	kslt=\E[4~, lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, mc0=\E[i, 
-	mc4=\E[4i, mc5=\E[5i, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, 
+	kich1=\E[2~, knp=\E[6~, kpp=\E[5~, krdo=\E[29~, kslt=\E[4~, 
+	lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, mc0=\E[i, mc4=\E[4i, 
+	mc5=\E[5i, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, 
 	rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l, rmso=\E[27m, 
-	rmul=\E[24m, rs1=\E[?3l, sc=\E7, sgr0=\E[m, smacs=\E(0$<2>, 
-	smam=\E[?7h, smir=\E[4h, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
+	rmul=\E[24m, rs1=\E[?3l, sc=\E7, 
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
+	sgr0=\E[m, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h, 
+	smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
 vt220-w|vt200-w|DEC vt220 in wide mode, 
 	cols#132, 
 	rs3=\E[?3h, use=vt220, 
@@ -2089,12 +2189,13 @@
 	kfnd=\2331~, khlp=\23328~, khome=\233H, kich1=\2332~, 
 	knp=\2336~, kpp=\2335~, krdo=\23329~, kslt=\2334~, lf1=pf1, 
 	lf2=pf2, lf3=pf3, lf4=pf4, mc0=\233i, mc4=\2334i, mc5=\2335i, 
-	nel=\EE, rc=\E8, rev=\2337m, ri=\EM, rmacs=^O, rmam=\233?7l, 
-	rmir=\2334l, rmso=\23327m, rmul=\23324m, rs1=\233?3l, 
-	sc=\E7, sgr0=\233m, smacs=^N, smam=\233?7h, smir=\2334h, 
+	nel=\EE, rc=\E8, rev=\2337m, ri=\EM, rmacs=\E(B, 
+	rmam=\233?7l, rmir=\2334l, rmso=\23327m, rmul=\23324m, 
+	rs1=\233?3l, sc=\E7, 
+	sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
+	sgr0=\233m, smacs=\E(0, smam=\233?7h, smir=\2334h, 
 	smso=\2337m, smul=\2334m, tbc=\2333g, 
 
-#
 # vt220d:
 # This vt220 description regards F6--F10 as the second block of function keys
 # at the top of the keyboard.  This mapping follows the description given
@@ -2146,7 +2247,6 @@
 #vt320|DEC VT320 in vt100 emulation mode,
 #	use=vt220,
 
-#
 # Use v320n for SCO's LYRIX.  Otherwise, use Adam Thompson's vt320-nam.
 #
 vt320nam|v320n|DEC VT320 in vt100 emul. mode with NO AUTO WRAP mode, 
@@ -2179,7 +2279,7 @@
 	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, fsl=\E[0$}, 
 	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, 
 	il1=\E[L, ind=\ED, 
-	is2=\E>\E[?3l\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
 	kbs=\177, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
 	kdch1=\E[3~, kel=\E[4~, kf10=\E[21~, kf11=\E[23~, 
 	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
@@ -2191,25 +2291,27 @@
 	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B, 
 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, 
 	rmul=\E[m, 
-	rs2=\E>\E[?3l\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
-	sc=\E7, sgr0=\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h, 
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+	sc=\E7, 
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
+	sgr0=\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h, 
 	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
 	tsl=\E[1$}\E[H\E[K, use=vt220+keypad, 
 vt320-nam|vt300-nam|dec vt320 7 bit terminal with no am to make SAS happy, 
 	am@, 
-	is2=\E>\E[?3l\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
-	rs2=\E>\E[?3l\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
+	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
+	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
 	use=vt320, 
 # We have to init 132-col mode, not 80-col mode.
 vt320-w|vt300-w|dec vt320 wide 7 bit terminal, 
 	cols#132, wsl#132, 
-	is2=\E>\E[?3h\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
-	rs2=\E>\E[?3h\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+	is2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
 	use=vt320, 
 vt320-w-nam|vt300-w-nam|dec vt320 wide 7 bit terminal with no am, 
 	am@, 
-	is2=\E>\E[?3h\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
-	rs2=\E>\E[?3h\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
+	is2=\E>\E[?3h\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
+	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
 	use=vt320-w, 
 
 # VT330 and VT340 -- These are ReGIS and SIXEL graphics terminals
@@ -2240,21 +2342,23 @@
 	cnorm=\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, 
 	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J, 
 	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, 
-	cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[?25h, dch=\E[%p1%dP, 
-	dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
-	dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K, 
-	flash=\E[?5h\E[?5l$<200/>, fsl=\E[$}, home=\E[H, ht=^I, 
-	hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED, 
+	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, 
+	dl=\E[%p1%dM, dl1=\E[M, dsl=\E[2$~\r\E[1$}\E[K\E[$}, 
+	ed=\E[J, el=\E[K, flash=\E[?5h\E[?5l$<200/>, fsl=\E[$}, 
+	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, 
+	il1=\E[L, ind=\ED, 
 	is2=\E<\E F\E>\E[?1h\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
 	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~, 
 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, lf1=pf1, lf2=pf2, 
 	lf3=pf3, lf4=pf4, nel=^M\ED, rc=\E8, rev=\E[7m, 
-	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=^O, 
+	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B, 
 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, 
-	rmul=\E[24m, rs1=\E[?3l, sc=\E7, sgr0=\E[m, smacs=^N, 
-	smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, 
-	smul=\E[4m, tbc=\E[3g, tsl=\E[2$~\E[1$}\E[1;%dH, 
+	rmul=\E[24m, rs1=\E[?3l, sc=\E7, 
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
+	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smir=\E[4h, 
+	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
+	tsl=\E[2$~\E[1$}\E[1;%dH, 
 
 # DEC doesn't supply a vt400 description, so we add Daniel Glasser's
 # (originally written with vt420 as its primary name, and usable for it).
@@ -2286,8 +2390,8 @@
 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
 	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
-	cvvis=\E[?25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, 
-	dl1=\E[M, dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J$<10/>, 
+	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
+	dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J$<10/>, 
 	el=\E[K$<4/>, flash=\E[?5h\E[?5l$<200/>, fsl=\E[$}, 
 	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, 
 	il=\E[%p1%dL, il1=\E[L, ind=\ED, 
@@ -2296,11 +2400,12 @@
 	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~, 
 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, lf1=pf1, lf2=pf2, 
 	lf3=pf3, lf4=pf4, nel=^M\ED, rc=\E8, rev=\E[7m, 
-	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=^O, 
+	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B, 
 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, 
-	rmul=\E[24m, rs1=\E<\E[?3l\E[!p\E[?7h, sc=\E7, sgr0=\E[m, 
-	smacs=^N, smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=, 
-	smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
+	rmul=\E[24m, rs1=\E<\E[?3l\E[!p\E[?7h, sc=\E7, 
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
+	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smir=\E[4h, 
+	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
 	tsl=\E[2$~\E[1$}\E[1;%dH, 
 
 # (vt420: I removed <kf0>, it collided with <kf10>.  I also restored
@@ -2329,7 +2434,6 @@
 	sgr0=\E[m$<2>, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h, 
 	smkx=\E=, smso=\E[7m, smul=\E[4m, 
 
-#
 # DEC VT220 and up support DECUDK (user-defined keys).  DECUDK (i.e., pfx)
 # takes two parameters, the key and the string.  Translating the key is
 # straightforward (keys 1-5 are not defined on real terminals, though some
@@ -2493,12 +2597,17 @@
 	hts=\EH, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, 
 	use=vt220, use=ecma+color, 
 
-# PuTTY 0.51 (released 14 December 2000)
+# PuTTY 0.55 (released 3 August 2004)
 # http://www.chiark.greenend.org.uk/~sgtatham/putty/
 #
+# Comparing with 0.51, vttest is much better (only a few problems with the
+# cursor position reports and wrapping).
+#
+# PuTTY 0.51 (released 14 December 2000)
+#
 # This emulates vt100 + vt52 (plus a few vt220 features:  ech, SRM, DECTCEM, as
 # well as SCO and Atari, color palettes from Linux console).  Reading the code,
-# it is intended to be VT102 plus selected features By default, it sets $TERM
+# it is intended to be VT102 plus selected features.  By default, it sets $TERM
 # to xterm, which is incorrect, since several features are misimplemented:
 #
 #	Alt+key always sends ESC+key, so 'km' capability is removed.
@@ -2510,39 +2619,48 @@
 #
 # Several features such as backspace/delete are optional; this entry documents
 # the default behavior -TD
-putty|xterm clone (win32), 
-	am, bw, ccc, km, mir, msgr, xenl, 
-	colors#8, cols#80, it#8, lines#24, pairs#64, 
-	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
-	bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[?25l, 
-	clear=\E[H\E[2J, cnorm=\E[?25h, cr=^M, 
+
+putty|PuTTY terminal emulator, 
+	am, bce, bw, ccc, hs, mir, msgr, xenl, xon, 
+	colors#8, it#8, ncv#22, pairs#64, 
+	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
+	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, 
+	clear=\E[H\E[J, cnorm=\E[?25h, cr=^M, 
 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
-	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, enacs=\E)0, home=\E[H, 
-	hpa=\E[%i%p1%dG, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, 
-	ind=^J, 
-	initc=\E]P%?%p1%{9}%>%t%p1%{10}%-%'a'%+%c%e%p1%d%;%p2%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%p3%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%p4%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;, 
-	is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>, 
-	kbs=\177, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, 
-	kcuu1=\EOA, kdch1=\E[3~, kf1=\E[11~, kf10=\E[21~, 
-	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, 
-	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, 
-	kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, 
-	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, 
-	kf9=\E[20~, kfnd=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, 
-	kpp=\E[5~, kslt=\E[4~, oc=\E]R, op=\E[39;49m, rc=\E8, 
-	rev=\E[7m, ri=\EM, rmacs=^O, rmam=\E[?7l, 
-	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>, 
+	cud=\E[%p1%dB, cud1=\ED, cuf=\E[%p1%dC, cuf1=\E[C, 
+	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM, 
+	dch=\E[%p1%dP, dch1=\E[P, 
+	dispc=%?%p1%{8}%=%t\E%%G\342\227\230\E%%@%e%p1%{10}%=%t\E%%G\342\227\231\E%%@%e%p1%{12}%=%t\E%%G\342\231\0\E%%@%e%p1%{13}%=%t\E%%G\342\231\252\E%%@%e%p1%{14}%=%t\E%%G\342\231\253\E%%@%e%p1%{15}%=%t\E%%G\342\230\274\E%%@%e%p1%{27}%=%t\E%%G\342\206\220\E%%@%e%p1%{155}%=%t\E%%G\340\202\242\E%%@%e%p1%c%;, 
+	dl=\E[%p1%dM, dl1=\E[M, dsl=\E]0;\007, ech=\E[%p1%dX, 
+	ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, 
+	flash=\E[?5h\E[?5l, fsl=^G, home=\E[H, hpa=\E[%i%p1%dG, 
+	ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=^J, 
+	indn=\E[%p1%dS, 
+	initc=\E]P%p1%x%p2%{255}%*%{1000}%/%02x%p3%{255}%*%{1000}%/%02x%p4%{255}%*%{1000}%/%02x, 
+	is2=\E7\E[r\E[m\E[?7h\E[?1;4;6l\E[4l\E8\E>\E]R, 
+	kb2=\E[G, kbs=\177, kcan=^C, kcbt=\E[Z, kcub1=\E[D, 
+	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, 
+	kend=\E[4~, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, 
+	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
+	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, 
+	kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, kf4=\E[14~, 
+	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
+	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
+	kspd=^Z, nel=^M^J, oc=\E]R, op=\E[39;49m, rc=\E8, rev=\E[7m, 
+	ri=\EM, rin=\E[%p1%dT, rmacs=^O, rmam=\E[?7l, 
+	rmcup=\E[2J\E[?47l, rmir=\E[4l, rmpch=\E[10m, 
 	rmso=\E[27m, rmul=\E[24m, 
-	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>, sc=\E7, 
+	rs2=\E<\E["p\E[50;6"p\Ec\E[?3l\E]R\E[?1000l, 
+	s0ds=\E[10m, s1ds=\E[11m, s2ds=\E[12m, sc=\E7, 
 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
-	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
-	sgr0=\E[m, smacs=^N, smam=\E[?7h, smcup=\E7\E[?47h, 
-	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, 
-	tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, 
-	vpa=\E[%i%p1%dd, 
+	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
+	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E[?47h, 
+	smir=\E[4h, smpch=\E[11m, smso=\E[7m, smul=\E[4m, 
+	tbc=\E[3g, tsl=\E]0;, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?6c, 
+	u9=\E[c, vpa=\E[%i%p1%dd, 
+vt100-putty|Reset Putty to pure vt100, 
+	rs2=\E<\E["p\Ec\E[?3l\E]R\E[40"p\E[61"p\E[50;1;2"p, 
+	use=vt100, 
 
 # This entry is for Tera Term Pro version 2.3, for MS-Windows 95/NT written by
 # T. Teranishi dated Mar 10, 1998.  It is a free software terminal emulator
@@ -2840,86 +2958,125 @@
 
 # This version was released in XFree86 4.3.
 xterm-xf86-v43|xterm terminal emulator (XFree86 4.3 Window System), 
-	npc, 
 	kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, 
 	kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, 
-	kb2=\EOE, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, 
-	kcuu1=\EOA, kend=\EOF, kent=\EOM, kf1=\EOP, kf10=\E[21~, 
-	kf11=\E[23~, kf12=\E[24~, kf13=\EO2P, kf14=\EO2Q, 
-	kf15=\EO2R, kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, 
-	kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, 
-	kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, 
-	kf26=\EO5Q, kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~, 
-	kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, 
+	kbeg@, 
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
+	use=xterm-xf86-v40, 
+
+# This version was released in XFree86 4.4.
+xterm-xf86-v44|xterm terminal emulator (XFree86 4.4 Window System), 
+	cnorm=\E[?12l\E[?25h, cvvis=\E[?12;25h, indn=\E[%p1%dS, 
+	rin=\E[%p1%dT, use=xterm-xf86-v43, 
+
+# This is the most common alias for xterm-new.
+xterm-xfree86|xterm terminal emulator (XFree86), 
+	use=xterm-new, 
+#	use=xterm-old, 
+
+# This version is current (XFree86 xterm patch #192).
+xterm-new|modern xterm terminal emulator, 
+	npc, 
+	indn=\E[%p1%dS, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, 
+	kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, 
+	kRIT=\E[1;2C, kb2=\EOE, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, 
+	kcuf1=\EOC, kcuu1=\EOA, kend=\EOF, kent=\EOM, khome=\EOH, 
+	kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
+	rin=\E[%p1%dT, use=xterm+pcfkeys, use=xterm-basic, 
+#
+# This fragment describes as much of XFree86 xterm's "pc-style" function
+# keys as will fit into terminfo's 60 function keys.
+# From ctlseqs.ms:
+#    Code     Modifiers
+#  ---------------------------------
+#     2       Shift
+#     3       Alt
+#     4       Shift + Alt
+#     5       Control
+#     6       Shift + Control
+#     7       Alt + Control
+#     8       Shift + Alt + Control
+#  ---------------------------------
+# The meta key may also be used as a modifier in this scheme, adding another
+# bit to the parameter.
+xterm+pcfkeys|fragment for PC-style fkeys, 
+	kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, 
+	kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, kf16=\EO2S, 
+	kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, 
+	kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, 
+	kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, kf26=\EO5Q, 
+	kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~, kf3=\EOR, 
+	kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, 
 	kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, 
 	kf36=\E[24;5~, kf37=\EO6P, kf38=\EO6Q, kf39=\EO6R, 
 	kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~, 
 	kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, 
-	kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf5=\E[15~, 
-	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\EOH, 
-	kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
-	use=xterm-basic, 
-
-# This version is current (XFree86 xterm patch #180).
-xterm-xfree86|xterm-new|xterm terminal emulator (XFree86 4.4 Window System), 
-	cnorm=\E[?12l\E[?25h, cvvis=\E[?12;25h, indn=\E[%p1%dS, 
-	rin=\E[%p1%dT, use=xterm-xf86-v43, 
+	kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\EO3P, 
+	kf5=\E[15~, kf50=\EO3Q, kf51=\EO3R, kf52=\EO3S, 
+	kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, 
+	kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, 
+	kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\EO4P, 
+	kf62=\EO4Q, kf63=\EO4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
+	kDN=\E[1;2B, kDN5=\E[1;5B, kDN6=\E[1;6B, kLFT5=\E[1;5D, 
+	kLFT6=\E[1;6D, kRIT5=\E[1;5C, kRIT6=\E[1;6C, kUP=\E[1;2A, 
+	kUP5=\E[1;5A, kUP6=\E[1;6A, 
 #
 # This chunk is used for building the VT220/Sun/PC keyboard variants.
 xterm-basic|xterm terminal emulator - common (XFree86), 
-	am, bce, km, mc5i, mir, msgr, xenl, 
+	OTbs, am, bce, km, mc5i, mir, msgr, xenl, AX, 
 	colors#8, cols#80, it#8, lines#24, pairs#64, 
 	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
 	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, 
-	clear=\E[H\E[2J, cnorm=\E[?25h, cr=^M, 
+	clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M, 
 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
 	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, 
+	cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, 
+	dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, 
 	flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG, 
 	ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, 
 	ind=^J, invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>, kbs=^H, 
 	kdch1=\E[3~, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, meml=\El, 
-	memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, 
-	rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, 
-	rmso=\E[27m, rmul=\E[24m, rs1=\Ec, 
+	memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, 
+	rmacs=\E(B, rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, 
+	rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs1=\Ec, 
 	rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[4%p1%dm, 
 	setaf=\E[3%p1%dm, 
 	setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, 
 	setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, 
-	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E[?1049h, 
+	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m, 
+	sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smcup=\E[?1049h, 
 	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, 
 	tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, 
 	vpa=\E[%i%p1%dd, 
 
 # From: David J. MacKenzie <djm@va.pubnix.com>, 14 Nov 1997
+# In retrospect, something like xterm-r6 was intended here -TD
 xterm-xi|xterm on XI Graphics Accelerated X under BSD/OS 3.1, 
 	rmso=\E[m, rmul=\E[m, use=xterm-xf86-v33, 
 
 # This is one of the variants of XFree86 3.3 xterm, updated for 4.0 (T.Dickey)
 xterm-16color|xterm with 16 colors like aixterm, 
-	ncv#32, use=ibm+16color, use=xterm-xfree86, 
+	ncv#32, use=ibm+16color, use=xterm-new, 
 
 # These variants of XFree86 3.9.16 xterm are built as a configure option.
 xterm-256color|xterm with 256 colors, 
 	ccc, 
-	colors#256, ncv#32, pairs#256, 
+	colors#256, pairs#32767, 
 	initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, 
 	setab=\E[48;5;%p1%dm, setaf=\E[38;5;%p1%dm, 
 	setb=\E[48;5;%p1%dm, setf=\E[38;5;%p1%dm, 
-	use=xterm-xfree86, 
+	use=xterm-new, 
 xterm-88color|xterm with 88 colors, 
-	colors#88, pairs#88, use=xterm-256color, 
+	colors#88, pairs#7744, use=xterm-256color, 
 
 # These two are used to demonstrate the any-event mouse support, i.e., by
 # using an extended name "XM" which tells ncurses to put the terminal into
 # a special mode when initializing the xterm mouse.
 xterm-1002|testing xterm-mouse, 
-	XM=\E[?1002%?%p1%{1}%=%th%el%;, use=xterm-xfree86, 
+	XM=\E[?1002%?%p1%{1}%=%th%el%;, use=xterm-new, 
 xterm-1003|testing xterm-mouse, 
-	XM=\E[?1003%?%p1%{1}%=%th%el%;, use=xterm-xfree86, 
+	XM=\E[?1003%?%p1%{1}%=%th%el%;, use=xterm-new, 
 
 # This is another variant, for XFree86 4.0 xterm (T.Dickey)
 # This is an 8-bit version of xterm, which emulates DEC vt220 with ANSI color.
@@ -2931,21 +3088,21 @@
 #	CSI	\E [	\233
 #
 xterm-8bit|xterm terminal emulator 8-bit controls (X Window System), 
-	OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, 
+	OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, AX, 
 	colors#8, cols#80, it#8, lines#24, pairs#64, 
 	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
 	bel=^G, blink=\2335m, bold=\2331m, cbt=\233Z, 
-	civis=\233?25l, clear=\233H\2332J, cnorm=\233?25h, cr=^M, 
-	csr=\233%i%p1%d;%p2%dr, cub=\233%p1%dD, cub1=^H, 
-	cud=\233%p1%dB, cud1=^J, cuf=\233%p1%dC, cuf1=\233C, 
-	cup=\233%i%p1%d;%p2%dH, cuu=\233%p1%dA, cuu1=\233A, 
+	civis=\233?25l, clear=\233H\2332J, 
+	cnorm=\233?25l\233?25h, cr=^M, csr=\233%i%p1%d;%p2%dr, 
+	cub=\233%p1%dD, cub1=^H, cud=\233%p1%dB, cud1=^J, 
+	cuf=\233%p1%dC, cuf1=\233C, cup=\233%i%p1%d;%p2%dH, 
+	cuu=\233%p1%dA, cuu1=\233A, cvvis=\233?12;25h, 
 	dch=\233%p1%dP, dch1=\233P, dl=\233%p1%dM, dl1=\233M, 
 	ech=\233%p1%dX, ed=\233J, el=\233K, el1=\2331K, 
-	enacs=\E(B\E)0, flash=\233?5h$<100/>\233?5l, 
-	home=\233H, hpa=\233%i%p1%dG, ht=^I, hts=\210, 
-	ich=\233%p1%d@, il=\233%p1%dL, il1=\233L, ind=^J, 
-	invis=\2338m, 
-	is2=\E7\E G\233r\233m\233?7h\233?1;3;4;6l\2334l\E8\E>, 
+	flash=\233?5h$<100/>\233?5l, home=\233H, 
+	hpa=\233%i%p1%dG, ht=^I, hts=\210, ich=\233%p1%d@, 
+	il=\233%p1%dL, il1=\233L, ind=^J, invis=\2338m, 
+	is2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8, 
 	ka1=\217w, ka3=\217u, kb2=\217y, kbeg=\217E, kbs=^H, 
 	kc1=\217q, kc3=\217s, kcbt=\233Z, kcub1=\217D, kcud1=\217B, 
 	kcuf1=\217C, kcuu1=\217A, kdch1=\2333~, kend=\2334~, 
@@ -2957,18 +3114,18 @@
 	kf9=\23320~, khome=\2331~, kich1=\2332~, kmous=\233M, 
 	knp=\2336~, kpp=\2335~, mc0=\233i, mc4=\2334i, mc5=\2335i, 
 	meml=\El, memu=\Em, op=\23339;49m, rc=\E8, rev=\2337m, 
-	ri=\215, rmacs=^O, rmam=\233?7l, rmcup=\233?1049l, 
+	ri=\215, rmacs=\E(B, rmam=\233?7l, rmcup=\233?1049l, 
 	rmir=\2334l, rmkx=\233?1l\E>, rmso=\23327m, rmul=\23324m, 
 	rs1=\Ec, 
-	rs2=\E[62"p\E G\E7\233r\E8\233m\233?7h\233?1;3;4;6l\2334l\E>, 
+	rs2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8, 
 	sc=\E7, setab=\2334%p1%dm, setaf=\2333%p1%dm, 
 	setb=\2334%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, 
 	setf=\2333%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, 
-	sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
-	sgr0=\233m^O, smacs=^N, smam=\233?7h, smcup=\233?1049h, 
-	smir=\2334h, smkx=\233?1h\E=, smso=\2337m, smul=\2334m, 
-	tbc=\2333g, u6=\233[%i%d;%dR, u7=\E[6n, u8=\233[?1;2c, 
-	u9=\E[c, vpa=\233%i%p1%dd, 
+	sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;, 
+	sgr0=\233m\E(B, smacs=\E(0, smam=\233?7h, 
+	smcup=\233?1049h, smir=\2334h, smkx=\233?1h\E=, 
+	smso=\2337m, smul=\2334m, tbc=\2333g, u6=\233[%i%d;%dR, 
+	u7=\E[6n, u8=\233[?1;2c, u9=\E[c, vpa=\233%i%p1%dd, 
 
 xterm-hp|XFree86 xterm with hpterm function keys, 
 	kclr=\EJ, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, 
@@ -2987,7 +3144,7 @@
 	kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, khome=\E[H, 
 	kich1=\E[L, knp=\E[G, kpp=\E[I, use=xterm-basic, 
 
-# The xterm-xfree86 description has all of the features, but is not completely
+# The xterm-new description has all of the features, but is not completely
 # compatible with vt220.  If you are using a Sun or PC keyboard, set the
 # sunKeyboard resource to true:
 #	+ maps the editing keypad
@@ -2997,14 +3154,13 @@
 #	+ uses DEC-style control sequences for the application keypad.
 #	  
 xterm-vt220|XFree86 xterm emulating vt220, 
-	kbeg=\EOu, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, 
-	kcuu1=\EOA, kend=\E[4~, kf10=\E[21~, kf11=\E[23~, 
-	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
-	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, 
-	kf20=\E[34~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, 
-	kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~, 
-	kmous=\E[M, knp=\E[6~, kpp=\E[5~, use=xterm-basic, 
-	use=vt220+keypad, 
+	kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
+	kend=\E[4~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, 
+	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, 
+	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf20=\E[34~, 
+	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
+	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
+	use=xterm-basic, use=vt220+keypad, 
 
 xterm-vt52|XFree86 xterm emulating dec vt52, 
 	cols#80, it#8, lines#24, 
@@ -3023,8 +3179,7 @@
 
 # This is xterm for ncurses.
 xterm|xterm terminal emulator (X Window System), 
-	use=xterm-r6, 
-#	use=xterm-xfree86, 
+	use=xterm-new, 
 
 # These entries allow access to the X titlebar and icon name as a status line. 
 # Note that twm (and possibly window managers descended from it such as tvtwm, 
@@ -3054,8 +3209,10 @@
 	eslok, hs, 
 	acsc=++\,\,--..00ii``aaffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
 	csr=\E[%i%p1%d;%p2%dr, dsl=\E[?H, enacs=, fsl=\E[?F, 
-	kmous=\E[M, rc=\E8, rmacs=\E(B, sc=\E7, smacs=\E(0, 
-	tsl=\E[?E\E[?%i%dT, use=xterm-r6, use=ecma+color, 
+	kmous=\E[M, rc=\E8, rmacs=\E(B, rmam=\E[?7l, sc=\E7, 
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, 
+	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, 
+	tsl=\E[?E\E[?%i%p1%dT, use=xterm-r6, use=ecma+color, 
 kterm-color|kterm-co|kterm with ANSI colors, 
 	ncv@, use=kterm, use=ecma+color, 
 # See the note on ICH/ICH1 VERSUS RMIR/SMIR near the end of file
@@ -3150,7 +3307,7 @@
 # more of its bugs using vttest.
 #
 # However, note that bce and msgr are broken in this release.  Tabs (tbc and
-# hts) are broken as well.  Sometimes flash (as in xterm-xfree86) works.
+# hts) are broken as well.  Sometimes flash (as in xterm-new) works.
 #
 # kf1 and kf10 are not tested since they're assigned (hardcoded?) to menu
 # operations.  Shift-tab generates a distinct sequence so it can be argued
@@ -3164,9 +3321,13 @@
 #
 # bce and msgr are repaired.
 gnome-rh90|GNOME Terminal, 
-	bce, msgr, use=gnome-rh80, 
+	bce, msgr, 
+	hpa=\E[%i%p1%dG, kDC=\E[3;2~, kLFT=\EO2D, kRIT=\EO2C, 
+	kb2=\E[E, kcbt=\E[Z, kend=\EOF, khome=\EOH, tbc=\E[3g, 
+	vpa=\E[%i%p1%dd, use=xterm+pcfkeys, use=gnome-rh80, 
 
 gnome|GNOME Terminal, 
+	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h, 
 	use=gnome-rh90, 
 
 # This is kvt 0-18.7, shipped with Redhat 6.0 (though whether it supports bce
@@ -3197,14 +3358,21 @@
 #    vt220, which is doubly incorrect because it does not implement vt220
 #    control sequences except for a few special cases).  Treat it as a
 #    mildly-broken vt102.
+#
+# Update for konsole 1.3.2:
+#    The 1049 private mode works (but see the other xterm screens in vttest).
+#    Primary Device Attributes now returns the code for a vt100 with advanced
+#    video option.  Perhaps that's intended to be a "mildly-broken vt102".
 konsole-base|KDE console window, 
 	bce, km@, npc, 
 	bel@, blink=\E[5m, civis=\E[?25l, cnorm=\E[?25h, 
 	ech=\E[%p1%dX, flash=\E[?5h$<100/>\E[?5l, 
-	hpa=\E[%i%p1%dG, kbs@, kdch1@, kend@, kf1@, kf10@, kf11@, kf12@, 
-	kf13@, kf14@, kf15@, kf16@, kf17@, kf18@, kf19@, kf2@, kf20@, kf3@, 
-	kf4@, kf5@, kf6@, kf7@, kf8@, kf9@, kfnd@, khome@, kslt@, 
-	rmam=\E[?7l, rmso=\E[27m, rmul=\E[24m, 
+	hpa=\E[%i%p1%dG, indn=\E[%p1%dS, kbs=\177, kdch1@, 
+	kend=\E[4~, kf1@, kf10@, kf11@, kf12@, kf13@, kf14@, kf15@, kf16@, 
+	kf17@, kf18@, kf19@, kf2@, kf20@, kf3@, kf4@, kf5@, kf6@, kf7@, kf8@, 
+	kf9@, kfnd@, khome=\E[1~, kslt@, rin=\E[%p1%dT, rmam=\E[?7l, 
+	rmso=\E[27m, rmul=\E[24m, 
+	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h, 
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
 	smam=\E[?7h, vpa=\E[%i%p1%dd, use=ecma+color, 
 	use=xterm-r6, 
@@ -3221,7 +3389,10 @@
 # The value for kbs reflects local customization rather than the settings used
 # for XFree86 xterm.
 konsole-xf4x|KDE console window with keyboard for XFree86 4.x xterm, 
-	kbs=^H, kend=\EOF, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, 
+	kend=\EOF, kf1=\EOP, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, 
+	kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, 
+	kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, 
+	kf23=\E[23;2~, kf24=\E[24;2~, kf3=\EOR, kf4=\EOS, 
 	khome=\EOH, use=konsole-vt100, 
 # KDE's "vt100" keyboard has no relationship to any terminal that DEC made, but
 # it is still useful for deriving the other entries.
@@ -3237,7 +3408,47 @@
 	ncv#32, use=ibm+16color, use=konsole, 
 # make a default entry for konsole
 konsole|KDE console window, 
-	use=konsole-linux, 
+	use=konsole-xf4x, 
+
+# Based on mlterm 2.8.0's mlterm.ti, with corrections/additions from reading
+# the source code and running tack -TD
+#
+# This is nominally a vt102 emulator, with features borrowed from rxvt and
+# xterm.
+#
+# There are some problems with vttest:
+#	save/restore cursor doesn't restore character
+#	test of character sets leaves it in line-drawing mode.
+mlterm|multi lingual terminal emulator, 
+	am, eslok, km, mc5i, mir, msgr, npc, xenl, 
+	colors#8, cols#80, it#8, lines#24, pairs#64, 
+	acsc=00``aaffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
+	bel=^G, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[2J, cr=^M, 
+	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
+	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
+	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
+	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
+	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=, 
+	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, 
+	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=^J, indn=\E[%p1%dS, 
+	is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>, 
+	kbs=\177, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
+	kdch1=\E[3~, kend=\EOF, kent=\EOM, kf1=\E[11~, kf10=\E[21~, 
+	kf11=\E[23~, kf12=\E[24~, kf2=\E[12~, kf3=\E[13~, 
+	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, 
+	kf9=\E[20~, kfnd=\E[1~, khome=\EOH, kich1=\E[2~, 
+	kmous=\E[M, knp=\E[6~, kpp=\E[5~, kslt=\E[4~, mc0=\E[i, 
+	nel=\EE, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, 
+	rin=\E[%p1%dT, rmacs=\E(B, rmam=\E[?7l, 
+	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>, 
+	rmso=\E[m, rmul=\E[m, 
+	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l, 
+	sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, 
+	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smcup=\E7\E[?47h, 
+	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, 
+	tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, 
+	vpa=\E[%i%p1%dd, 
 
 # From: Thomas Dickey <dickey@clark.net> 04 Oct 1997
 # Updated: Oezguer Kesim <kesim@math.fu-berlin.de> 02 Nov 1997
@@ -3257,6 +3468,8 @@
 # rxvt is normally configured to look for "xterm" or "xterm-color" as $TERM.
 # Since rxvt is not really compatible with xterm, it should be configured as
 # "rxvt" (monochrome) and "rxvt-color". 
+#
+# removed dch/dch1 because they are inconsistent with bce/ech -TD
 rxvt-basic|rxvt terminal base (X Window System), 
 	OTbs, am, bce, eo, km, mir, msgr, xenl, xon, 
 	cols#80, it#8, lines#24, 
@@ -3266,33 +3479,111 @@
 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
 	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, 
-	el=\E[K, el1=\E[1K, enacs=\E(B\E)0, flash=\E[?5h\E[?5l, 
-	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, 
-	il=\E[%p1%dL, il1=\E[L, ind=^J, is1=\E[?47l\E=\E[?1l, 
-	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, 
-	kDC=\E[3$, kEND=\E[8$, kHOM=\E[7$, kLFT=\E[d, kNXT=\E[6$, 
-	kPRV=\E[5$, kRIT=\E[c, kbs=^H, kcbt=\E[Z, kcub1=\E[D, 
-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, 
-	kel=\E[8\^, kend=\E[8~, kf1=\E[11~, kf10=\E[21~, 
-	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, 
-	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, 
-	kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, 
-	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, 
-	kf9=\E[20~, kfnd=\E[1~, khome=\E[7~, kich1=\E[2~, 
-	kmous=\E[M, knp=\E[6~, kpp=\E[5~, kslt=\E[4~, rc=\E8, 
-	rev=\E[7m, ri=\EM, rmacs=^O, rmcup=\E[2J\E[?47l\E8, 
-	rmir=\E[4l, rmkx=\E>, rmso=\E[27m, rmul=\E[24m, 
+	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, 
+	enacs=\E(B\E)0, flash=\E[?5h\E[?5l, home=\E[H, ht=^I, 
+	hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, 
+	ind=^J, is1=\E[?47l\E=\E[?1l, 
+	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, kbs=^H, 
+	kcbt=\E[Z, kmous=\E[M, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, 
+	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E>, rmso=\E[27m, 
+	rmul=\E[24m, 
 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, 
-	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>, 
-	s0ds=\E(B, s1ds=\E(0, sc=\E7, sgr0=\E[0m\017, smacs=^N, 
-	smcup=\E7\E[?47h, smir=\E[4h, smkx=\E=, smso=\E[7m, 
-	smul=\E[4m, tbc=\E[3g, use=vt220+keypad, 
+	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h, 
+	s0ds=\E(B, s1ds=\E(0, sc=\E7, 
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
+	sgr0=\E[0m\017, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h, 
+	smkx=\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
+	use=vt220+keypad, use=rxvt+pcfkeys, 
+# Key Codes from rxvt reference:
+# 
+# Note: Shift + F1-F10 generates F11-F20
+# 
+# For the keypad, use Shift to temporarily override Application-Keypad
+# setting use Num_Lock to toggle Application-Keypad setting if Num_Lock
+# is off, escape sequences toggle Application-Keypad setting.
+# Also note that values of Home, End, Delete may have been compiled
+# differently on your system.
+# 
+#                   Normal       Shift        Control      Ctrl+Shift
+#  Tab              ^I           ESC [ Z      ^I           ESC [ Z
+#  BackSpace        ^H           ^?           ^?           ^?
+#  Find             ESC [ 1 ~    ESC [ 1 $    ESC [ 1 ^    ESC [ 1 @
+#  Insert           ESC [ 2 ~    paste        ESC [ 2 ^    ESC [ 2 @
+#  Execute          ESC [ 3 ~    ESC [ 3 $    ESC [ 3 ^    ESC [ 3 @
+#  Select           ESC [ 4 ~    ESC [ 4 $    ESC [ 4 ^    ESC [ 4 @
+#  Prior            ESC [ 5 ~    scroll-up    ESC [ 5 ^    ESC [ 5 @
+#  Next             ESC [ 6 ~    scroll-down  ESC [ 6 ^    ESC [ 6 @
+#  Home             ESC [ 7 ~    ESC [ 7 $    ESC [ 7 ^    ESC [ 7 @
+#  End              ESC [ 8 ~    ESC [ 8 $    ESC [ 8 ^    ESC [ 8 @
+#  Delete           ESC [ 3 ~    ESC [ 3 $    ESC [ 3 ^    ESC [ 3 @
+#  F1               ESC [ 11 ~   ESC [ 23 ~   ESC [ 11 ^   ESC [ 23 ^
+#  F2               ESC [ 12 ~   ESC [ 24 ~   ESC [ 12 ^   ESC [ 24 ^
+#  F3               ESC [ 13 ~   ESC [ 25 ~   ESC [ 13 ^   ESC [ 25 ^
+#  F4               ESC [ 14 ~   ESC [ 26 ~   ESC [ 14 ^   ESC [ 26 ^
+#  F5               ESC [ 15 ~   ESC [ 28 ~   ESC [ 15 ^   ESC [ 28 ^
+#  F6               ESC [ 17 ~   ESC [ 29 ~   ESC [ 17 ^   ESC [ 29 ^
+#  F7               ESC [ 18 ~   ESC [ 31 ~   ESC [ 18 ^   ESC [ 31 ^
+#  F8               ESC [ 19 ~   ESC [ 32 ~   ESC [ 19 ^   ESC [ 32 ^
+#  F9               ESC [ 20 ~   ESC [ 33 ~   ESC [ 20 ^   ESC [ 33 ^
+#  F10              ESC [ 21 ~   ESC [ 34 ~   ESC [ 21 ^   ESC [ 34 ^
+#  F11              ESC [ 23 ~   ESC [ 23 $   ESC [ 23 ^   ESC [ 23 @
+#  F12              ESC [ 24 ~   ESC [ 24 $   ESC [ 24 ^   ESC [ 24 @
+#  F13              ESC [ 25 ~   ESC [ 25 $   ESC [ 25 ^   ESC [ 25 @
+#  F14              ESC [ 26 ~   ESC [ 26 $   ESC [ 26 ^   ESC [ 26 @
+#  F15 (Help)       ESC [ 28 ~   ESC [ 28 $   ESC [ 28 ^   ESC [ 28 @
+#  F16 (Menu)       ESC [ 29 ~   ESC [ 29 $   ESC [ 29 ^   ESC [ 29 @
+#  F17              ESC [ 31 ~   ESC [ 31 $   ESC [ 31 ^   ESC [ 31 @
+#  F18              ESC [ 32 ~   ESC [ 32 $   ESC [ 32 ^   ESC [ 32 @
+#  F19              ESC [ 33 ~   ESC [ 33 $   ESC [ 33 ^   ESC [ 33 @
+#  F20              ESC [ 34 ~   ESC [ 34 $   ESC [ 34 ^   ESC [ 34 @
+#                                                          Application
+#  Up               ESC [ A      ESC [ a      ESC O a      ESC O A
+#  Down             ESC [ B      ESC [ b      ESC O b      ESC O B
+#  Right            ESC [ C      ESC [ c      ESC O c      ESC O C
+#  Left             ESC [ D      ESC [ d      ESC O d      ESC O D
+#  KP_Enter         ^M                                     ESC O M
+#  KP_F1            ESC O P                                ESC O P
+#  KP_F2            ESC O Q                                ESC O Q
+#  KP_F3            ESC O R                                ESC O R
+#  KP_F4            ESC O S                                ESC O S
+#  XK_KP_Multiply   *                                      ESC O j
+#  XK_KP_Add        +                                      ESC O k
+#  XK_KP_Separator  ,                                      ESC O l
+#  XK_KP_Subtract   -                                      ESC O m
+#  XK_KP_Decimal    .                                      ESC O n
+#  XK_KP_Divide     /                                      ESC O o
+#  XK_KP_0          0                                      ESC O p
+#  XK_KP_1          1                                      ESC O q
+#  XK_KP_2          2                                      ESC O r
+#  XK_KP_3          3                                      ESC O s
+#  XK_KP_4          4                                      ESC O t
+#  XK_KP_5          5                                      ESC O u
+#  XK_KP_6          6                                      ESC O v
+#  XK_KP_7          7                                      ESC O w
+#  XK_KP_8          8                                      ESC O x
+#  XK_KP_9          9                                      ESC O y
+rxvt+pcfkeys|fragment for PC-style fkeys, 
+	kDC=\E[3$, kEND=\E[8$, kHOM=\E[7$, kLFT=\E[d, kNXT=\E[6$, 
+	kPRV=\E[5$, kRIT=\E[c, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, 
+	kcuu1=\E[A, kdch1=\E[3~, kel=\E[8\^, kend=\E[8~, 
+	kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, 
+	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, 
+	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, 
+	kf20=\E[34~, kf21=\E[23$, kf22=\E[24$, kf23=\E[11\^, 
+	kf24=\E[12\^, kf25=\E[13\^, kf26=\E[14\^, kf27=\E[15\^, 
+	kf28=\E[17\^, kf29=\E[18\^, kf3=\E[13~, kf30=\E[19\^, 
+	kf31=\E[20\^, kf32=\E[21\^, kf33=\E[23\^, kf34=\E[24\^, 
+	kf35=\E[25\^, kf36=\E[26\^, kf37=\E[28\^, kf38=\E[29\^, 
+	kf39=\E[31\^, kf4=\E[14~, kf40=\E[32\^, kf41=\E[33\^, 
+	kf42=\E[34\^, kf43=\E[23@, kf44=\E[24@, kf5=\E[15~, 
+	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, 
+	khome=\E[7~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, kslt=\E[4~, 
+	kDN=\E[b, kDN5=\EOb, kDN6=\EOB, kLFT5=\EOd, kLFT6=\EOD, 
+	kRIT5=\EOc, kRIT6=\EOC, kUP=\E[a, kUP5=\EOa, kUP6=\EOA, 
 rxvt|rxvt terminal emulator (X Window System), 
 	ncv@, 
-	cvvis=\E[?25h, hpa=\E[%i%p1%dG, kf0=\E[21~, 
-	sgr0=\E[m\017, vpa=\E[%i%p1%dd, use=rxvt-basic, 
-	use=ecma+color, 
+	hpa=\E[%i%p1%dG, kf0=\E[21~, sgr0=\E[m\017, 
+	vpa=\E[%i%p1%dd, use=rxvt-basic, use=ecma+color, 
 rxvt-color|rxvt terminal emulator (X Window System), 
 	use=rxvt, 
 rxvt-xpm|rxvt terminal emulator (X Window System), 
@@ -3342,7 +3633,7 @@
 	rmacs=^O, rmam=\E[?7l, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, 
 	rmkx=, rmso=\E[27m, rmul=\E[24m, 
 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, 
-	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>, 
+	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h, 
 	sc=\E7, 
 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
 	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E7\E[?47h, 
@@ -3439,30 +3730,66 @@
 	cols#80, lines#24, use=xterm-sun, 
 
 # This is for the extensible terminal emulator on the X11R6 contrib tape.
+# It corresponds to emu's internal emulation:
+#	emu -term emu
+# emu's default sets TERM to "xterm", but that doesn't work well -TD
+# fixes: remove bogus rmacs/smacs, change oc to op, add bce, am -TD
+# fixes: add civis, cnorm, sgr -TD
 emu|emu native mode, 
-	mir, msgr, xon, 
+	am, bce, mir, msgr, xon, 
 	colors#15, cols#80, it#8, lines#24, pairs#64, vt#200, 
 	acsc=61a\202f\260g2j\213k\214l\215m\216n\217o\220q\222s\224t\225u\226v\227w\230x\231~\244, 
-	bel=^G, blink=\ES\EW, bold=\ES\EU, civis=\EZ, 
-	clear=\EP\EE0;0;, cnorm=\Ea, cr=^M, csr=\Ek%p1%d;%p2%d;, 
-	cub=\Eq-%p1%d;, cub1=^H, cud=\Ep%p1%d;, cud1=\EB, 
-	cuf=\Eq%p1%d;, cuf1=\ED, cup=\EE%p1%d;%p2%d;, 
-	cuu=\Ep-%p1%d;, cuu1=\EA, dch=\EI%p1%d;, dch1=\EI1;, 
-	dl=\ER%p1%d;, dl1=\ER1;, ech=\Ej%p1%d;, ed=\EN, el=\EK, 
-	el1=\EL, enacs=\0, home=\EE0;0;, ht=^I, hts=\Eh, 
-	il=\EQ%p1%d;, il1=\EQ1;, ind=\EG, is2=\ES\Er0;\Es0;, 
-	kbs=^H, kcub1=\EC, kcud1=\EB, kcuf1=\ED, kcuu1=\EA, 
-	kdch1=\177, kent=^M, kf0=\EF00, kf1=\EF01, kf10=\EF10, 
-	kf11=\EF11, kf12=\EF12, kf13=\EF13, kf14=\EF14, kf15=\EF15, 
-	kf16=\EF16, kf17=\EF17, kf18=\EF18, kf19=\EF19, kf2=\EF02, 
-	kf20=\EF20, kf3=\EF03, kf4=\EF04, kf5=\EF05, kf6=\EF06, 
-	kf7=\EF07, kf8=\EF08, kf9=\EF09, kfnd=\Efind, kich1=\Eins, 
-	knp=\Enext, kpp=\Eprior, kslt=\Esel, oc=\Es0;\Er0;, 
-	rev=\ES\ET, ri=\EF, rmacs=\0, rmir=\EX, rmso=\ES, rmul=\ES, 
+	bel=^G, blink=\EW, bold=\EU, civis=\EZ, clear=\EP\EE0;0;, 
+	cnorm=\Ea, cr=^M, csr=\Ek%p1%d;%p2%d;, cub=\Eq-%p1%d;, 
+	cub1=^H, cud=\Ep%p1%d;, cud1=\EB, cuf=\Eq%p1%d;, cuf1=\ED, 
+	cup=\EE%p1%d;%p2%d;, cuu=\Ep-%p1%d;, cuu1=\EA, 
+	dch=\EI%p1%d;, dch1=\EI1;, dl=\ER%p1%d;, dl1=\ER1;, 
+	ech=\Ej%p1%d;, ed=\EN, el=\EK, el1=\EL, home=\EE0;0;, ht=^I, 
+	hts=\Eh, il=\EQ%p1%d;, il1=\EQ1;, ind=\EG, 
+	is2=\ES\Er0;\Es0;, kbs=^H, kcub1=\EC, kcud1=\EB, kcuf1=\ED, 
+	kcuu1=\EA, kdch1=\177, kent=^M, kf0=\EF00, kf1=\EF01, 
+	kf10=\EF10, kf11=\EF11, kf12=\EF12, kf13=\EF13, kf14=\EF14, 
+	kf15=\EF15, kf16=\EF16, kf17=\EF17, kf18=\EF18, kf19=\EF19, 
+	kf2=\EF02, kf20=\EF20, kf3=\EF03, kf4=\EF04, kf5=\EF05, 
+	kf6=\EF06, kf7=\EF07, kf8=\EF08, kf9=\EF09, kfnd=\Efind, 
+	kich1=\Eins, knp=\Enext, kpp=\Eprior, kslt=\Esel, 
+	op=\Es0;\Er0;, rev=\ET, ri=\EF, rmir=\EX, rmso=\ES, rmul=\ES, 
 	rs2=\ES\Es0;\Er0;, setab=\Es%i%p1%d;, 
-	setaf=\Er%i%p1%d;, sgr0=\ES, smacs=\0, smir=\EY, 
-	smso=\ES\ET, smul=\ES\EV, tbc=\Ej, 
-
+	setaf=\Er%i%p1%d;, 
+	sgr=\ES%?%p1%t\ET%;%?%p2%t\EV%;%?%p3%t\ET%;%?%p4%t\EW%;%?%p6%t\EU%;, 
+	sgr0=\ES, smir=\EY, smso=\ET, smul=\EV, tbc=\Ej, 
+
+# vt220 Terminfo entry for the Emu emulation, corresponds to
+#	emu -term vt220
+# with NumLock set (to make the keypad transmit kf0-kf9).
+# fixes: add am, xenl, corrected sgr0 -TD
+emu-220|Emu-220 (vt200-7bit mode), 
+	am, xenl, xon, 
+	cols#80, it#8, lines#24, vt#200, 
+	acsc=aaffggjjkkllmmnnooqqssttuuvvwwxx~~, bel=^G, 
+	blink=\E[0;5m, bold=\E[0;1m, civis=\E[?25l, 
+	clear=\E[2J\E[H, cnorm=\E[?25h, cr=^M, 
+	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[1D, 
+	cud=\E[%p1%dB, cud1=\E[1B, cuf=\E[%p1%dC, cuf1=\E[1C, 
+	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[1A, 
+	dch=\E[%p1%dP, dch1=\E[1P, dl=\E[%p1%dM, dl1=\E[1M, 
+	ed=\E[0J, el=\E[0K, el1=\E[1K, enacs=\E)0, home=\E[H, ht=^I, 
+	hts=\EH, if=/usr/share/tabset/vt300, il=\E[%p1%dL, 
+	il1=\E[1L, ind=\ED, is2=\E>\E[?1l\E[?3l\E[4l\E[?7h, 
+	kbs=^H, kcmd=\E[29~, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, 
+	kcuu1=\E[A, kdch1=\E[3~, kent=\EOM, kf0=\EOp, kf1=\EOq, 
+	kf10=\EOl, kf11=\EOm, kf12=\EOn, kf13=\EOP, kf14=\EOQ, 
+	kf15=\EOR, kf16=\EOS, kf2=\EOr, kf26=\E[17~, kf27=\E[18~, 
+	kf28=\E[19~, kf29=\E[20~, kf3=\EOs, kf30=\E[21~, 
+	kf34=\E[26~, kf37=\E[31~, kf38=\E[32~, kf39=\E[33~, 
+	kf4=\EOt, kf40=\E[34~, kf5=\EOu, kf6=\EOv, kf7=\EOw, 
+	kf8=\EOx, kf9=\EOy, kfnd=\E[1~, khlp=\E[28~, kich1=\E[2~, 
+	knp=\E[6~, kpp=\E[5~, kslt=\E[4~, rc=\E8, rev=\E[0;7m, 
+	ri=\EM, rmacs=^O, rmcup=\E>, rmkx=\E>, rmso=\E[m, rmul=\E[m, 
+	rs2=\E[4l\E[34l\E[?1l\E[?3l\E[?5l\E[?7h, sc=\E7, 
+	sgr=\E[0%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
+	sgr0=\E[m, smacs=^N, smcup=\E[?1l\E=, smkx=\E=, 
+	smso=\E[0;7m, smul=\E[0;4m, tbc=\E[3g, 
 # A commercial product, Reportedly a version of Xterm with an OPEN LOOK UI,
 # print interface, ANSI X3.64 colour escape sequences, etc.  Newsgroup postings
 # indicate that it emulates more than one terminal, but incompletely.
@@ -3515,8 +3842,10 @@
 	il=\E[%p1%dL, il1=\E[L, ind=\E[S, indn=\E[%p1%dS, 
 	invis=\E[8m, is2=\E)0\017, kbs=^H, nel=\EE, rev=\E[7m, 
 	ri=\E[T, rin=\E[%p1%dT, rmacs=^O, rmir=\E[4l, rmso=\E[27m, 
-	rmul=\E[24m, sgr0=\E[m, smacs=^N, smir=\E[4h, smso=\E[7m, 
-	smul=\E[4m, vpa=\E[%i%p1%dd, 
+	rmul=\E[24m, 
+	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
+	sgr0=\E[m, smacs=^N, smir=\E[4h, smso=\E[7m, smul=\E[4m, 
+	vpa=\E[%i%p1%dd, 
 # mterm normally sets $TERM to "mterm"
 mterm|mouse-sun|Der Mouse term, 
 	am, bw, mir, 
@@ -3526,6 +3855,8 @@
 	home=^P, ht=^I, il1=^A, ind=^U, kbs=^H, ll=^R, nel=^M^U, ri=^W, 
 	rmir=^O, rmso=^T, smir=^Q, smso=^V, 
 # "mterm -type decansi" sets $TERM to "decansi"
+#
+# note: kdch1, kfnd, kslt are in the source code, but do not work -TD
 decansi|ANSI emulation with DEC compatibility hacks, 
 	am, mir, msgr, xenl, 
 	colors#8, it#8, pairs#64, 
@@ -3540,7 +3871,13 @@
 	home=\E[H, hpa=\E[%i%p1%d`, ht=^I, ich1=, il=\E[%p1%dL, 
 	il1=\E[L, ind=\E[S, indn=\E[%p1%dS, invis=\E[8m, 
 	is2=\E)0\E[r\017, kbs=^H, kcub1=\EOD, kcud1=\EOB, 
-	kcuf1=\EOC, kcuu1=\EOA, nel=\EE, op=\E[0m, rc=\E8, rev=\E[7m, 
+	kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kf1=\E[11~, 
+	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, 
+	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, 
+	kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, 
+	kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, 
+	kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, kich1=\E[2~, knp=\E[6~, 
+	kpp=\E[5~, kslt=\E[4~, nel=\EE, op=\E[0m, rc=\E8, rev=\E[7m, 
 	ri=\E[T, rin=\E[%p1%dT, rmacs=^O, rmam=\E[?7l, rmir=\E[4l, 
 	rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, sc=\E7, 
 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
@@ -3656,10 +3993,11 @@
 	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
 	nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, 
 	rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[23m, 
-	rmul=\E[24m, rs2=\Ec, sc=\E7, sgr0=\E[m, smacs=^N, 
-	smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[3m, 
-	smul=\E[4m, tbc=\E[3g, E0=\E(B, S0=\E(%p1%c, 
-	use=ecma+color, 
+	rmul=\E[24m, rs2=\Ec\E[?1000l\E[?25h, sc=\E7, 
+	sgr=\E[0%?%p6%t;1%;%?%p1%t;3%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
+	sgr0=\E[m, smacs=^N, smcup=\E[?1049h, smir=\E[4h, 
+	smkx=\E[?1h\E=, smso=\E[3m, smul=\E[4m, tbc=\E[3g, E0=\E(B, 
+	S0=\E(%p1%c, use=ecma+color, 
 # The bce and status-line entries are from screen 3.9.13 (and require some
 # changes to .screenrc).
 screen-bce|VT 100/ANSI X3.64 virtual terminal with bce, 
@@ -3691,12 +4029,12 @@
 #	xterm (-xfree86 or -r6) does not normally support kIC, kNXT and kPRV
 #	since the default translations override the built-in keycode
 #	translation.  They are suppressed here to show what is tested by tack.
-screen.xterm-xfree86|screen customized for XFree86 xterm, 
+screen.xterm-xfree86|screen.xterm-new|screen customized for modern xterm, 
 	bce@, bw, 
 	invis@, kIC@, kNXT@, kPRV@, kend=\E[4~, khome=\E[1~, meml@, 
 	memu@, 
-	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
-	use=xterm-xfree86, 
+	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m, 
+	use=xterm-new, 
 # xterm-r6 does not really support khome/kend unless it is propped up by
 # the translations resource.
 screen.xterm-r6|screen customized for X11R6 xterm, 
@@ -3800,11 +4138,11 @@
 	kf6=\E[23~, kf7=\E[24~, kf8=\E[25~, kf9=\E[26~, khlp=\E[1~, 
 	khome=\E[2~, knp=\E[6~, kpp=\E[3~, mc4=\E[4i, mc5=\E[5i, 
 	rc=\E8, rev=\E[7m, rf=/usr/share/tabset/vt100, ri=\EM, 
-	rmacs=^O, rmam=\E[?7l, rmcup=\E[2J\E8, rmir=\E[4l, 
+	rmacs=\E(B, rmam=\E[?7l, rmcup=\E[2J\E8, rmir=\E[4l, 
 	rmso=\E[27m, rmul=\E[24m, 
 	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;4;6l\E[4l\E>, sc=\E7, 
 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, 
-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E7, 
+	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smcup=\E7, 
 	smir=\E[4h, smso=\E[7m, smul=\E[4m, tbc=\E[3g, tsl=\E]0;, 
 	u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?62;1;6c, u9=\E[c, 
 ncsa|NCSA Telnet 2.7 for Macintosh in vt220-8 mode, 
@@ -7446,7 +7784,7 @@
 wy120|wyse120|wy150|wyse150|Wyse 120/150, 
 	am, bw, hs, km, mc5i, mir, msgr, xon, 
 	cols#80, it#8, lh#1, lines#24, lw#8, nlab#8, pb#9601, wsl#45, 
-	acsc=+/\,.0[Iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
+	acsc=+/\,.0[iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<50>, 
 	cnorm=\E`1, cr=^M, cub1=^H, cud1=^J, cuf1=^L, 
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<7>, 
@@ -7525,7 +7863,7 @@
 wy60|wyse60|Wyse 60, 
 	am, bw, hs, km, mc5i, mir, msgr, 
 	cols#80, lh#1, lines#24, lw#8, nlab#8, wsl#45, 
-	acsc=+/\,.0[Iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
+	acsc=+/\,.0[iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<100>, 
 	cnorm=\E`1, cr=^M, cub1=^H, cud1=^J, cuf1=^L, 
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, 
@@ -7694,7 +8032,7 @@
 wy99f|wy99fgt|wy-99fgt|Wyse WY-99GT (int'l PC keyboard), 
 	am, bw, hs, km, mc5i, mir, msgr, xon, 
 	cols#80, it#8, lines#25, wsl#46, 
-	acsc='x+y.wI~_vj(k'l&m%n)o9q*s8t-u.v\,w+x=, bel=^G, 
+	acsc='x+y.wi~_vj(k'l&m%n)o9q*s8t-u.v\,w+x=, bel=^G, 
 	blink=\EG2, cbt=\EI, civis=\E`0, clear=\E'\E(\032, 
 	cnorm=\E`4\E`1, cr=^M, cub1=^H, cud1=\Ej, cuf1=^L, 
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, 
@@ -7746,7 +8084,7 @@
 wy160|wyse160|Wyse 160, 
 	am, bw, hs, km, mc5i, mir, msgr, 
 	cols#80, lh#1, lines#24, lw#8, nlab#8, wsl#38, 
-	acsc=+/\,.0[Iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
+	acsc=+/\,.0[iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<30>, 
 	cnorm=\E`1, cr=^M, cub1=^H, cud1=^J, cuf1=^L, 
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<5>, 
@@ -8054,7 +8392,7 @@
 wy325|wyse325|Wyse epc, 
 	am, bw, hs, mc5i, mir, 
 	cols#80, lh#1, lines#24, lw#8, nlab#8, pb#9601, wsl#45, 
-	acsc=+/\,.0[Iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
+	acsc=+/\,.0[iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<50>, 
 	cnorm=\E`1, cr=^M, cub1=^H, cud1=^J, cuf1=^L, 
 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<7>, 
@@ -8609,8 +8947,8 @@
 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
 	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
-	cvvis=\E[?25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, 
-	dl1=\E[M, dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K, 
+	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
+	dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K, 
 	flash=\E[?5h\E[?5l, fsl=\E[$}, home=\E[H, ht=^I, hts=\EH, 
 	ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L$<3/>, ind=\ED, 
 	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
@@ -8683,15 +9021,20 @@
 # (The <blink>/<bold>/<rev>/<smacs>/<smul>/<smso> capabilities exist only to
 # tell ncurses that the corresponding highlights exist; it should use <sgr>,
 # which is the only method that will actually work for multiple highlights.)
+#
+# Update by TD - 2004: half of this was inconsistent.  Found documentation
+# and repaired most of the damage.  sgr0 is probably incorrect, but the
+# available documentation gives no clues for a workable string.
 avatar0|avatar terminal emulator level 0, 
 	am, bce, msgr, 
 	cols#80, it#8, lines#25, 
-	blink=^A^V\177, bold=^V^A^P, cr=^M, cub1=^V^E, cud1=^V^D, 
+	blink=^V^B, bold=^V^A^P, cr=^M, cub1=^V^E, cud1=^V^D, 
 	cuf1=^V^F, cup=\026\010%p1%c%p2%c, cuu1=^V^C, el=^V^G, 
-	ind=^J, invis=^V^A\0, rep=\031%p1%c%p2%d, rev=^A^Vp, 
-	rs2=^L, 
-	sgr=\026\001%{0}%?%p1%t%{112}%|%;%?%p2%t%{1}%|%;%?%p3%t%{112}%|%;%?%p4%t{128}%|%;%?%p6%t%{16}%|%;, 
-	sgr0=^V^A^G, smacs=, smso=^A^Vp, smul=^V^A, use=klone+acs, 
+	ind=^J, invis=^V^A\0, rep=\031%p1%c%p2%c, rev=^V^Ap, 
+	rmacs@, rs2=^L, 
+	sgr=%?%p1%p2%|%p3%|%p6%|%p7%|%t\026\001%?%p7%t%{128}%e%{0}%?%p1%t%{112}%|%;%?%p2%t%{1}%|%;%?%p3%t%{112}%|%;%?%p6%t%{16}%|%;%;%c%;%?%p4%t\026\002%;, 
+	sgr0=^V^A^G, smacs@, smso=^V^Ap, smul=^V^A^A, 
+	use=klone+acs, 
 # From: Eric S. Raymond <esr@snark.thyrsus.com> 1 Nov 1995
 avatar0+|avatar terminal emulator level 0+, 
 	dch1=^V^N, rmir=\026\n\0\0\0\0, smir=^V^I, use=avatar0, 
@@ -8712,10 +9055,9 @@
 	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, 
 	clear=^L, cnorm=\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, 
 	cub1=^H, cud1=^C, cuf1=^B, 
-	cup=\037%p2%{32}%+%c%p1%{32}%+%c, cuu1=^^, 
-	cvvis=\E[?25h, dch1=^W, dl=\E[%p1%dM, dl1=^Z, 
-	ech=\E[%p1%dX, ed=^F5, el=^P^P, ht=^I, il=\E[%p1%dL, il1=^K, 
-	ind=\ED, invis=\E[8m, 
+	cup=\037%p2%{32}%+%c%p1%{32}%+%c, cuu1=^^, dch1=^W, 
+	dl=\E[%p1%dM, dl1=^Z, ech=\E[%p1%dX, ed=^F5, el=^P^P, ht=^I, 
+	il=\E[%p1%dL, il1=^K, ind=\ED, invis=\E[8m, 
 	is2=\017\035\E(B\E)0\E[?7h\E[?3l\E[>8g, kbs=^H, 
 	kcub1=^B, kcud1=^N, kcuf1=^F, kcuu1=^P, khome=^A, nel=^M\ED, 
 	rc=\E8, rep=\030%p1%c%p2%c, rev=^R, ri=\EM, rmcup=, rmdc=, 
@@ -10510,15 +10852,66 @@
 # underline=01100000, rev=01010000, blink=01000010,dim=01000001,
 # invis=01000100 and %c is the logical or of desired attributes.
 # There is also a `tag bit' enabling attributes, set by \E) and unset by \E(.
+#
+# Update by TD - 2004:
+# Adapted from 
+#	http://www.cs.utk.edu/~shuford/terminal/adds_viewpoint_news.txt
+#
+# COMMANDS                        ASCII CODE
+# 
+# Address, Absolute               ESC,=,row,column
+# Beep                            BEL
+# Aux Port Enable                 ESC,@
+# Aux Port Disable                ESC,A
+# Backspace                       BS
+# Cursor back                     BS
+# Cursor down                     LF
+# Cursor forward                  FF
+# Cursor home                     RS
+# Cursor up                       VT
+# Cursor supress                  ETB
+# Cursor enable                   CAN
+# Erase to end of line            ESC,T
+# Erase to end of page            ESC,Y
+# Erase screen                    SUB
+# Keyboard lock                   SI
+# Keyboard unlock                 SO
+# Read current cursor position    ESC,?
+# Set Attribute                   ESC,0,x  (see below for values of x)
+# Tag bit reset                   ESC,(
+# Tag bit set                     ESC,)
+# Transparent Print on            ESC,3
+# Transparent Print off           ESC,4
+# 
+# 
+# ATTRIBUTES
+# 
+# Normal                          @	0100
+# Half Intensity                  A	0101
+# Blinking                        B	0102
+# Half Intensity Blinking         C	0103
+# Reverse Video                   P	0120
+# Reverse Video Half Intensity    Q	0121
+# Reverse Video Blinking          R	0122
+# Reverse Video Half Intensity
+#    Blinking                     S	0123
+# Underlined                      `	0140
+# Underlined Half Intensity       a	0141
+# Underlined Blinking             b	0142
+# Underlined Half Intensity
+#    Blinking                     c	0143
+# Video suppress                  D	0104
 vp3a+|viewpoint3a+|adds viewpoint 3a+, 
 	am, bw, 
 	cols#80, it#8, lines#24, 
-	civis=^W, clear=\E*$<80>, cnorm=^X, cr=^M, cub1=^H, cud1=^J, 
-	cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, 
-	ed=\EY$<80>, el=\ET, home=^^, ht=^I, ind=^J, kbs=^H, kcub1=^H, 
-	kcud1=^J, kcuf1=^L, kcuu1=^K, khome=^^, nel=^M^J, rmso=\E(, 
-	sgr=\E0%{64}%?%p1%tQ%|%;%?%p2%t%{96}%|%;%?%p3%tP%|%;%?%p4%t%{2}%|%;%?%p5%t%{1}%|%;%?%p7%tD%|%;%c\E), 
-	sgr0=\E(, smso=\E0Q\E), 
+	blink=\E0B\E), civis=^W, clear=\E*$<80>, cnorm=^X, cr=^M, 
+	cub1=^H, cud1=^J, cuf1=^L, 
+	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dim=\E0A\E), 
+	ed=\EY$<80>, el=\ET, home=^^, ht=^I, ind=^J, invis=\E0D\E), 
+	kbs=^H, kcub1=^H, kcud1=^J, kcuf1=^L, kcuu1=^K, khome=^^, 
+	nel=^M^J, rev=\E0P\E), rmso=\E(, 
+	sgr=%?%p1%p2%|%p3%|%p4%|%p5%|%p7%|%t\E0%{64}%?%p1%t%{17}%|%;%?%p2%t%{32}%|%;%?%p3%t%{16}%|%;%?%p4%t%{2}%|%;%?%p5%t%{1}%|%;%c%?%p7%tD%;\E)%e\E(%;, 
+	sgr0=\E(, smso=\E0Q\E), smul=\E0`\E), 
 vp60|viewpoint60|addsvp60|adds viewpoint60, 
 	use=regent40, 
 #
@@ -12360,11 +12753,11 @@
 	bw@, eslok, 
 	it#8, wsl#80, 
 	blink=\EG2, bold=\EG0, civis=\E.1, cnorm=\E.2, cud1=^V, 
-	cvvis=\E.2, dim=\EG@, dl1=\ER, dsl=\Ef\r, 
-	flash=\Eb$<200/>\Ed, il1=\EE, ip@, is2@, kclr=^^, kdch1=\EW, 
-	kdl1=\ER, ked=\EY, kel=\ET, kf0=^AI\r, kf10@, kich1=\EQ, 
-	kil1=\EE, mc4=\Ea, mc5=\E`, ri=\EJ, rmacs=\E%%, rmir=\Er\EO, 
-	smacs=\E$, smir=\EO\Eq, smso=\EG<, tsl=\Ef, use=f100, 
+	dim=\EG@, dl1=\ER, dsl=\Ef\r, flash=\Eb$<200/>\Ed, il1=\EE, 
+	ip@, is2@, kclr=^^, kdch1=\EW, kdl1=\ER, ked=\EY, kel=\ET, 
+	kf0=^AI\r, kf10@, kich1=\EQ, kil1=\EE, mc4=\Ea, mc5=\E`, 
+	ri=\EJ, rmacs=\E%%, rmir=\Er\EO, smacs=\E$, smir=\EO\Eq, 
+	smso=\EG<, tsl=\Ef, use=f100, 
 f110-14|Liberty Freedom 110 14inch, 
 	dch1@, use=f110, 
 f110-w|Liberty Freedom 110 - 132 cols, 
@@ -12380,8 +12773,8 @@
 	clear=^Z, cnorm=\E.1, cr=^M, 
 	csr=\Em0%p1%{32}%+%c%p2%{32}%+%c, cub1=^H, cud1=^V, 
 	cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, 
-	cvvis=\E.1, dch1=\EW, dim=\EG@, dl1=\ER, dsl=\Ef\r, ed=\EY, 
-	el=\ET, flash=\Eo$<200/>\En, fsl=^M, home=^^, 
+	dch1=\EW, dim=\EG@, dl1=\ER, dsl=\Ef\r, ed=\EY, el=\ET, 
+	flash=\Eo$<200/>\En, fsl=^M, home=^^, 
 	hpa=\E]%p1%{32}%+%c, hts=\E1, il1=\EE, ind=^J, kbs=^H, 
 	kclr=^^, kcub1=^H, kcud1=^V, kcuf1=^L, kcuu1=^K, kdch1=\EW, 
 	kdl1=\ER, ked=\EY, kel=\ET, kf0=^AI\r, kf1=^A@\r, kf2=^AA\r, 
@@ -13075,6 +13468,10 @@
 jaixterm-m|IBM Kanji AIXterm Monochrome Terminal Emulator, 
 	acsc@, use=aixterm-m, 
 
+# This flavor is adapted from xterm, in turn from aixterm documentation -TD
+aixterm-16color|IBM Aixterm Terminal Emulator with 16 colors, 
+	use=ibm+16color, use=aixterm, 
+
 #### Infoton/General Terminal Corp.
 #
 
@@ -13090,7 +13487,7 @@
 	OTbs, am, 
 	cols#80, lines#25, 
 	bel=^G, clear=\E[2J, cr=^M, cub1=^H, cud1=^J, cuf1=\E[C, 
-	cup=%i\E[%p1%3d;%p2%3dH, cuu1=\E[A, 
+	cup=\E[%i%p1%3d;%p2%3dH, cuu1=\E[A, 
 	dch1=\E[4h\E[2Q\E[P\E[4l\E[0Q, dl1=\E[M, el=\E[N, 
 	il1=\E[L, ind=^J, rmir=\E[4l\E[0Q, smir=\E[4h\E[2Q, 
 # (addrinfo: removed obsolete ":bc=^Z:" -- esr)
@@ -13098,8 +13495,7 @@
 	am, 
 	cols#80, lines#24, 
 	bel=^G, clear=^L, cr=^M, cub1=^Z, cud1=^J, cuf1=^Y, 
-	cup=\037%p1%{1}%-%c%p2%{1}%-%c, cuu1=^\, ed=^K, home=^H, 
-	ind=^J, ll=^H^\, 
+	cup=\037%p1%c%p2%c, cuu1=^\, ed=^K, home=^H, ind=^J, ll=^H^\, 
 # (infoton: used to have the no-ops <lh#0>, <lw#0>, <nlab#0> -- esr)
 infoton, 
 	am, 
@@ -14032,9 +14428,9 @@
 	cbt=\EI, civis=\E`0, clear=\014$<40>, cnorm=\E`5, 
 	cr=\r$<2>, cub1=\010$<2>, cud1=\n$<2>, cuf1=\006$<2>, 
 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c$<5>, cuu1=\032$<2>, 
-	cvvis=\E`5, dch1=\EW$<2>, dim=\EGp, dl1=\El$<2>, dsl=\E`c, 
-	ed=\Ek$<2>, el=\EK$<2>, fsl=^M, home=\036$<2>, ht=^I, 
-	hts=\E1, il1=\EM$<2>, ind=\n$<2>, invis=\EG1, 
+	dch1=\EW$<2>, dim=\EGp, dl1=\El$<2>, dsl=\E`c, ed=\Ek$<2>, 
+	el=\EK$<2>, fsl=^M, home=\036$<2>, ht=^I, hts=\E1, 
+	il1=\EM$<2>, ind=\n$<2>, invis=\EG1, 
 	is2=\Ee6\E~%$<100>\E+\E`\:\Ed/\E`1\EO\Ee4\Ec@0@\Ec@1A\EcB0\EcC1\Ee7$<100>, 
 	kDC=\El, kEND=\Ek, kHOM=^A, kPRT=\E7, kRIT=^F, ka1=^A, ka3=\EJ, 
 	kbs=^H, kc1=\ET, kc3=\EJ, kcub1=^U, kcud1=^J, kcuf1=^F, 
@@ -16217,9 +16613,16 @@
 	smso=\2337m, smul=\2334m, 
 
 # From: Henning 'Faroul' Peters <Faroul@beyond.kn-bremen.de>, 25 Sep 1999
+#
+# Pavel Fedin added
+#	Home    Shift+Left
+#	End     Shift+Right
+#	PgUp    Shift+Up
+#	PgDn    Shift+Down
 amiga-8bit|Amiga ANSI using 8-bit controls, 
 	acsc=, dl=\233%p1%dM, dl1=\233M, il=\233%p1%dL, il1=\233L, 
-	ind=\204, indn@, ri=\215, rin@, use=amiga-h, 
+	ind=\204, indn@, kend=\233 @, khome=\233 A, knp=\233S, 
+	kpp=\233T, ri=\215, rin@, use=amiga-h, 
 
 # From: Ruediger Kuhlmann <terminfo@ruediger-kuhlmann.de>, 18 Jul 2000
 # requires use of appropriate preferences settings.
@@ -16249,6 +16652,14 @@
 	sgr0=\E[0m\017\E[30;85;>15m, smcup=\E[?7h, smkx=\E[?1h, 
 	smso=\E[1m, smul=\E[4m, 
 
+# MorphOS on Genesi Pegasos
+# By Pavel Fedin <sonic_amiga@rambler.ru>
+morphos, 
+	acsc=, dl=\233%p1%dM, dl1=\233M, il=\233%p1%dL, il1=\233L, 
+	ind=\204, indn@, kend=\23345~, kf11=\23320~, kf12=\23321~, 
+	khome=\23344~, kich1=\23340~, knp=\23342~, kpp=\23341~, 
+	ri=\215, rin@, use=amiga-h, 
+
 # Commodore B-128 microcomputer from Doug Tyrol <det@HEL-ACE.ARPA>
 # 	I'm trying to write a termcap for a commodore b-128, and I'm
 # having a little trouble. I've had to map most of my control characters
@@ -16866,9 +17277,9 @@
 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D, 
 	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C, 
 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
-	cvvis=\E[?25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, 
-	dl1=\E[M, dsl=\E[1$}\E[2$~\n\E[0$}, ech=\E[%p1%dX, 
-	ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, 
+	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
+	dsl=\E[1$}\E[2$~\n\E[0$}, ech=\E[%p1%dX, ed=\E[J, 
+	el=\E[K, el1=\E[1K, enacs=\E(B\E)0, 
 	flash=\E[?5h$<50>\E[?5l, fsl=\E[0$}, home=\E[H, ht=^I, 
 	hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED, 
 	is1=\E[63;1"p\E[2h, 
@@ -16966,12 +17377,12 @@
 	clear=\233H\233J, cnorm=\233?25h, cr=^M, 
 	csr=\233%i%p1%d;%p2%dr, cub=\233%p1%dD, cud=\233%p1%dB, 
 	cuf=\233%p1%dC, cup=\233%i%p1%d;%p2%dH, cuu=\233%p1%dA, 
-	cvvis=\233?25h, dch=\233%p1%dP, dch1=\233P, 
-	dl=\233%p1%dM, dsl=\2331$}\2332$~\n\2330$}, 
-	ech=\233%p1%dX, ed=\233J, el=\233K, el1=\2331K, 
-	enacs=\E(B\E)0, flash=\233?5h$<50>\233?5l, fsl=\2330$}, 
-	home=\233H, ht=^I, hts=\EH, ich=\233%p1%d@, il=\233%p1%dL, 
-	ind=\ED, is1=\E[63;2"p\E[2h, 
+	dch=\233%p1%dP, dch1=\233P, dl=\233%p1%dM, 
+	dsl=\2331$}\2332$~\n\2330$}, ech=\233%p1%dX, ed=\233J, 
+	el=\233K, el1=\2331K, enacs=\E(B\E)0, 
+	flash=\233?5h$<50>\233?5l, fsl=\2330$}, home=\233H, 
+	ht=^I, hts=\EH, ich=\233%p1%d@, il=\233%p1%dL, ind=\ED, 
+	is1=\E[63;2"p\E[2h, 
 	is2=\E[?2h\E[?3l\E[?5l\E[?7h\E[?8h\E>\E[?1l\E G\E[?42l\E[?4l, 
 	is3=\2330$}\233?25h\2332l\233H\233J, ka1=\217w, 
 	ka3=\217y, kb2=\217u, kbs=^H, kc1=\217q, kc3=\217s, 
@@ -18214,16 +18625,16 @@
 	cbt=\E[Z, civis=\E[?25l, clear=\E[H\E[2J$<6>, 
 	cnorm=\E[?25h, cub=\E[%p1%dD, cud=\E[%p1%dB, 
 	cuf=\E[%p1%dC, cup=\E[%p1%i%p1%d;%p2%dH, cuu=\E[%p1%dA, 
-	cvvis=\E[?25h, dch=\E[%p1%dP$<250>, dch1=\E[P, 
-	dl=\E[%p1%dM, ech=\E[%p1%dX$<20>, ed=\E[J$<6>, el=\E[0K, 
-	el1=\E[1K, enacs=\E(B\E)0, ff=^L, flash=\E[?5h\E[?5l$<6>, 
+	dch=\E[%p1%dP$<250>, dch1=\E[P, dl=\E[%p1%dM, 
+	ech=\E[%p1%dX$<20>, ed=\E[J$<6>, el=\E[0K, el1=\E[1K, 
+	enacs=\E(B\E)0, ff=^L, flash=\E[?5h\E[?5l$<6>, 
 	hpa=\E[%p1%{1}%+%dG, hts=\E[0W, ich=\E[%p1%d@$<250>, 
 	il=\E[%p1%dL$<36>, ip=$<10>, is2=\E[1;24r\E[24;1H, 
 	kcmd=\E[29~, kdch1=\E[P, kent=^J, kf1=\E[17~, kf10=\E[28~, 
 	kf11=\E[29~, kf12=\E[31~, kf2=\E[18~, kf3=\E[19~, 
 	kf4=\E[20~, kf5=\E[21~, kf6=\E[23~, kf7=\E[24~, kf8=\E[25~, 
 	kf9=\E[26~, khome=\E[H, kich1=\E[@, knp=\E[S, kpp=\E[T, 
-	kprt=^X, prot=\E&, rmacs=\017$<2>, rs2=\E[!p, 
+	kprt=^X, prot=\E&, rmacs=\017$<2>, rs2=\E[!p, sgr@, 
 	smacs=\016$<2>, tbc=\E[3g, vpa=\E[%p1%{1}%+%dd, 
 	use=vt220, 
 #
@@ -20477,6 +20888,104 @@
 #	* add vt100+ and vt-utf8 entries -TD
 #	* add uwin entry -TD
 #
+# 2004-03-27
+#	* add sgr strings to several common entries lacking them, e.g.,
+#	  screen, to make the entries more portable -TD
+#	* remove cvvis from rxvt entry, since it is the same as cnorm -TD
+#	* similar fixups for cvvis/cnorm various entries -TD
+#
+# 2004-05-22
+#	* remove 'ncv' from xterm-256color (patch 188) -TD
+#
+# 2004-06-26
+#	* add mlterm -TD
+#	* add xterm-xf86-v44 -TD 
+#	* modify xterm-new aka xterm-xfree86 to accommodate luit, which relies
+#	  on G1 being used via an ISO-2022 escape sequence (report by
+#	  Juliusz Chroboczek) -TD
+#	* add 'hurd' entry -TD
+#
+# 2004-07-03
+#	* make xterm-xf86-v43 derived from xterm-xf86-v40 rather than
+#	  xterm-basic -TD
+#	* align with xterm #192's use of xterm-new -TD
+#	* update xterm-new and xterm-8bit for cvvis/cnorm strings -TD
+#	* make xterm-new the default "xterm" -TD
+#
+# 2004-07-10
+#	* minor fixes for emu -TD
+#	* add emu-220
+#	* add rmam/smam to linux (Trevor Van Bremen)
+#	* change wyse acsc strings to use 'i' map rather than 'I' -TD
+#	* fixes for avatar0 -TD
+#	* fixes for vp3a+ -TD
+#
+# 2004-07-17
+#	* add xterm-pc-fkeys -TD
+#	* review/update gnome and gnome-rh90 entries (prompted by
+#	  Redhat Bugzilla #122815) -TD
+#	* review/update konsole entries -TD
+#	* add sgr, correct sgr0 for kterm and mlterm -TD
+#	* correct tsl string in kterm -TD
+#
+# 2004-07-24
+#	* make ncsa-m rmacs/smacs consistent with sgr -TD
+#	* add sgr, rc/sc and ech to syscons entries -TD
+#	* add function-keys to decansi -TD
+#	* add sgr to mterm-ansi -TD
+#	* add sgr, civis, cnorm to emu -TD
+#	* correct/simplify cup in addrinfo -TD 
+#	* corrections for gnome and konsole entries
+#	  (Redhat Bugzilla #122815) -Hans de Goede
+#	* modify DEC entries (vt220, etc), to add sgr string, and to use
+#	  ISO-2022 strings for rmacs/smacs -TD
+#
+# 2004-07-31
+#	* rename xterm-pc-fkeys to xterm+pcfkeys -TD
+#
+# 2004-08-07
+#	* improved putty entry -Robert de Bath
+#
+# 2004-08-14
+#	* remove dch/dch1 from rxvt because they are implemented inconsistently
+#	  with the common usage of bce/ech -TD
+#	* remove khome from vt220 (vt220's have no home key) -TD
+#	* add rxvt+pcfkeys -TD
+#
+# 2004-08-21
+#	* modify several entries to ensure xterm mouse and cursor visibility
+#	  are reset in rs2 string:  hurd, putty, gnome, konsole-base, mlterm,
+#	  Eterm, screen.  (The xterm entries are left alone - old ones for
+#	  compatibility, and the new ones do not require this change) -TD
+#
+# 2004-08-28
+#	* add morphos entry -Pavel Fedin
+#	* modify amiga-8bit to add khome/kend/knp/kpp -Pavel Fedin
+#	* corrected \E[5?l to \E[?5l in vt320 entries -TD
+#
+# 2004-11-20
+#	* update wsvt25 entry -TD
+#
+# 2005-01-29
+#	* update pairs for xterm-88color and xterm-256color to reflect the
+#	  ncurses extended-color support -TD
+#
+# 2005-02-26
+#	* modify sgr/sgr0 in xterm-new to improve tgetent's derived "me" -TD
+#	* add aixterm-16color to demonstrate 16-color capability -TD
+#
+# 2005-04-23
+#	* add media-copy to vt100 -TD
+#	* corrected acsc string for vt52 -TD
+#
+# 2005-04-30
+#	* add kUP, kDN (user-defined shifted up/down arrow) definitions for
+#	  xterm-new -TD
+#	* add kUP5, kUP6, etc., for xterm-new and rxvt -TD
+#
+# 2005-05-07
+#	* re-corrected acsc string for vt52 -TD
+#
 # The following sets edit modes for GNU EMACS.
 # Local Variables:
 # fill-prefix:"\t"
diff -Naur ncurses-5.4.orig/mk-0th.awk ncurses-5.4/mk-0th.awk
--- ncurses-5.4.orig/mk-0th.awk	2002-08-31 21:36:54.000000000 +0000
+++ ncurses-5.4/mk-0th.awk	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: mk-0th.awk,v 1.14 2002/08/31 21:36:54 tom Exp $
+# $Id: mk-0th.awk,v 1.17 2005/01/22 16:31:40 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2001 Free Software Foundation, Inc.                     #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -33,22 +33,30 @@
 #
 # Variables:
 #	libname (library name, e.g., "ncurses", "panel", "forms", "menus")
+#	subsets (is used here to decide if wide-character code is used)
 #
 BEGIN	{
-		print  ""
-		print  "# generated by mk-0th.awk"
-		print  ""
-		print  ".SUFFIXES: .c .cc .h .i .ii"
-		print  ".c.i :"
-		printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
-		print  ".cc.ii :"
-		printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
-		print  ".h.i :"
-		printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
-		print  ""
+		using = 0;
 		found = 0;
 	}
 	!/^[@#]/ {
+		if (using == 0)
+		{
+			print  ""
+			print  "# generated by mk-0th.awk"
+			printf "#   libname:    %s\n", libname
+			printf "#   subsets:    %s\n", subsets
+			print  ""
+			print  ".SUFFIXES: .c .cc .h .i .ii"
+			print  ".c.i :"
+			printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
+			print  ".cc.ii :"
+			printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
+			print  ".h.i :"
+			printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
+			print  ""
+			using = 1;
+		}
 		if ( $0 != "" && $1 != "link_test" )
 		{
 			if ( found == 0 )
@@ -84,7 +92,7 @@
 			printf "\trm -f llib-l%s\n", libname
 			print  ""
 			printf "llib-l%s : $(C_SRC)\n", libname
-			printf "\tcproto -a -l -DLINT $(CPPFLAGS) $(C_SRC) >$@\n"
+			printf "\tcproto -a -l -DNCURSES_ENABLE_STDBOOL_H=0 -DLINT $(CPPFLAGS) $(C_SRC) >$@\n"
 			print  ""
 			print  "lintlib :"
 			printf "\tsh $(srcdir)/../misc/makellib %s $(CPPFLAGS)", libname
diff -Naur ncurses-5.4.orig/mk-1st.awk ncurses-5.4/mk-1st.awk
--- ncurses-5.4.orig/mk-1st.awk	2004-01-10 20:48:43.000000000 +0000
+++ ncurses-5.4/mk-1st.awk	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: mk-1st.awk,v 1.62 2004/01/10 20:48:43 tom Exp $
+# $Id: mk-1st.awk,v 1.64 2005/01/22 16:06:36 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -32,18 +32,20 @@
 # Generate list of objects for a given model library
 # Variables:
 #	name (library name, e.g., "ncurses", "panel", "forms", "menus")
+#	traces ("all" or "DEBUG", to control whether tracing is compiled in)
+#	MODEL (e.g., "DEBUG", uppercase; toupper is not portable)
 #	model (directory into which we compile, e.g., "obj")
 #	prefix (e.g., "lib", for Unix-style libraries)
 #	suffix (e.g., "_g.a", for debug libraries)
-#	MODEL (e.g., "DEBUG", uppercase; toupper is not portable)
-#	depend (optional dependencies for all objects, e.g, ncurses_cfg.h)
 #	subset ("none", "base", "base+ext_funcs" or "termlib")
-#	host (cross-compile host, if any)
 #	ShlibVer ("rel", "abi" or "auto", to augment DoLinks variable)
 #	ShlibVerInfix ("yes" or "no", determines location of version #)
 #	DoLinks ("yes", "reverse" or "no", flag to add symbolic links)
 #	rmSoLocs ("yes" or "no", flag to add extra clean target)
+#	ldconfig (path for this tool, if used)
 #	overwrite ("yes" or "no", flag to add link to libcurses.a
+#	depend (optional dependencies for all objects, e.g, ncurses_cfg.h)
+#	host (cross-compile host, if any)
 #
 # Notes:
 #	CLIXs nawk does not like underscores in command-line variable names.
@@ -111,12 +113,26 @@
 				if (found == 0) {
 					print  ""
 					printf "# generated by mk-1st.awk (subset=%s)\n", subset
+					printf "#  name:          %s\n", name 
+					printf "#  traces:        %s\n", traces 
+					printf "#  MODEL:         %s\n", MODEL 
+					printf "#  model:         %s\n", model 
+					printf "#  prefix:        %s\n", prefix 
+					printf "#  suffix:        %s\n", suffix 
+					printf "#  subset:        %s\n", subset 
+					printf "#  ShlibVer:      %s\n", ShlibVer 
+					printf "#  ShlibVerInfix: %s\n", ShlibVerInfix 
+					printf "#  DoLinks:       %s\n", DoLinks 
+					printf "#  rmSoLocs:      %s\n", rmSoLocs 
+					printf "#  ldconfig:      %s\n", ldconfig 
+					printf "#  overwrite:     %s\n", overwrite 
+					printf "#  depend:        %s\n", depend 
+					printf "#  host:          %s\n", host 
 					print  ""
 				}
 				using = 1
 			}
 			if ( subset == "termlib" || subset == "termlib+ext_tinfo" ) {
-				name  = "tinfo"
 				OBJS  = MODEL "_T"
 			} else {
 				OBJS  = MODEL
diff -Naur ncurses-5.4.orig/mk-2nd.awk ncurses-5.4/mk-2nd.awk
--- ncurses-5.4.orig/mk-2nd.awk	2003-11-01 22:42:50.000000000 +0000
+++ ncurses-5.4/mk-2nd.awk	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: mk-2nd.awk,v 1.15 2003/11/01 22:42:50 tom Exp $
+# $Id: mk-2nd.awk,v 1.19 2005/01/22 16:30:04 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -36,10 +36,14 @@
 # development.
 #
 # Variables:
-#	model
+#	model directory into which objects are compiled.
 #	MODEL (uppercase version of "model"; toupper is not portable)
 #	echo (yes iff we will show the $(CC) lines)
 #	subset ("none", "base", "base+ext_funcs" or "termlib")
+#	crenames ("yes" or "no", flag to control whether -c & -o options are used)
+#	cxxrenames ("yes" or "no", flag to control whether -c & -o options are used)
+#	traces ("all" or "DEBUG", to control whether tracing is compiled in)
+#	srcdir is expanded when "configure --srcdir" was used
 #
 # Fields in src/modules:
 #	$1 = module name
@@ -61,7 +65,14 @@
 				if (found == 0) {
 					print  ""
 					print  "# generated by mk-2nd.awk"
-					print  ""
+					printf "#   model:      %s\n", model
+					printf "#   MODEL:      %s\n", MODEL
+					printf "#   echo:       %s\n", echo 
+					printf "#   subset:     %s\n", subset
+					printf "#   crenames:   %s\n", crenames
+					printf "#   cxxrenames: %s\n", cxxrenames
+					printf "#   traces:     %s\n", traces
+					printf "#   srcdir:     %s\n", srcdir
 				}
 				using = 1
 			}
@@ -83,9 +94,11 @@
 				if ( $2 == "c++" ) {
 					compile="CXX"
 					suffix=".cc"
+					use_c_o=cxxrenames
 				} else {
 					compile="CC"
 					suffix=".c"
+					use_c_o=crenames
 				}
 				printf "../%s/%s$o :\t%s/%s%s", model, $1, $3, $1, suffix
 				for (n = 4; n <= NF; n++) printf " \\\n\t\t\t%s", $n
@@ -96,13 +109,31 @@
 					atsign="@"
 					printf "\t@echo 'compiling %s (%s)'\n", $1, model
 				}
+				printf "\t%s", atsign;
+				if ( use_c_o != "yes" ) {
+					printf "cd ../%s; ", model;
+				}
+				# The choice here is between
+				#	base+ext_funcs and
+				#	termlib+ext_tinfo
+				# but they may appear in the same value.
+				if ( subset ~ /base/ ) {
+					mycflags=""
+				} else if ( subset ~ /termlib/ ) {
+					mycflags=" -DUSE_TERMLIB"
+				}
+				printf "$(LIBTOOL_COMPILE) $(%s) $(CFLAGS_%s)%s -c ", compile, MODEL, mycflags
 				if ( $3 == "." || srcdir == "." ) {
 					dir = $3 "/"
 					sub("^\\$\\(srcdir\\)/","",dir);
 					sub("^\\./","",dir);
-					printf "\t%scd ../%s; $(LIBTOOL_COMPILE) $(%s) $(CFLAGS_%s) -c ../%s/%s%s%s", atsign, model, compile, MODEL, name, dir, $1, suffix
-				} else
-					printf "\t%scd ../%s; $(LIBTOOL_COMPILE) $(%s) $(CFLAGS_%s) -c %s/%s%s", atsign, model, compile, MODEL, $3, $1, suffix
+					printf "../%s/%s%s%s", name, dir, $1, suffix
+				} else {
+					printf "%s/%s%s", $3, $1, suffix
+				}
+				if ( use_c_o == "yes" ) {
+					printf " -o ../%s/%s$o", model, $1
+				}
 			} else {
 				printf "%s", $1
 				for (n = 2; n <= NF; n++) printf " %s", $n
diff -Naur ncurses-5.4.orig/ncurses/Makefile.in ncurses-5.4/ncurses/Makefile.in
--- ncurses-5.4.orig/ncurses/Makefile.in	2003-11-01 22:48:53.000000000 +0000
+++ ncurses-5.4/ncurses/Makefile.in	2005-05-13 04:09:59.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.91 2003/11/01 22:48:53 tom Exp $
+# $Id: Makefile.in,v 1.96 2005/05/07 18:57:05 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2004,2005 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"), #
@@ -92,8 +92,9 @@
 
 CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
 
+BUILD_CPPFLAGS	= -I../include @BUILD_CPPFLAGS@
 BUILD_CC	= @BUILD_CC@
-BUILD_CCFLAGS	= -DHAVE_CONFIG_H -I../ncurses -I$(srcdir) @BUILD_CPPFLAGS@ @BUILD_CFLAGS@
+BUILD_CCFLAGS	= -DHAVE_CONFIG_H -I../ncurses -I$(srcdir) -I$(INCDIR) $(BUILD_CPPFLAGS) @BUILD_CFLAGS@
 BUILD_LDFLAGS	= @BUILD_LDFLAGS@
 BUILD_LIBS	= @BUILD_LIBS@
 
@@ -155,7 +156,7 @@
 
 TEST_DEPS	= ../lib/@LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@
 TEST_ARGS	= -L../lib -lncurses@DFT_ARG_SUFFIX@
-TEST_LDFLAGS	= @LD_MODEL@ $(TEST_ARGS) @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
+TEST_LDFLAGS	= @LD_MODEL@ $(TEST_ARGS) @LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
 
 TEST_PROGS = \
 	captoinfo$x \
@@ -193,7 +194,7 @@
 		fgrep undef >$@
 
 init_keytry.h: make_keys$(BUILD_EXEEXT) keys.list
-	./make_keys keys.list > $@
+	./make_keys$(BUILD_EXEEXT) keys.list > $@
 
 keys.list :	$(tinfo)/MKkeys_list.sh
 	AWK=$(AWK) sh $(tinfo)/MKkeys_list.sh $(TERMINFO_CAPS) | sort >$@
@@ -230,10 +231,10 @@
 	echo | $(AWK) -f $(base)/MKunctrl.awk >$@
 
 tags:
-	ctags *.[ch]
+	ctags *.[ch] */*.[ch]
 
 @MAKE_UPPER_TAGS@TAGS:
-@MAKE_UPPER_TAGS@	etags *.[ch]
+@MAKE_UPPER_TAGS@	etags *.[ch] */*.[ch]
 
 mostlyclean ::
 	-rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
diff -Naur ncurses-5.4.orig/ncurses/base/MKkeyname.awk ncurses-5.4/ncurses/base/MKkeyname.awk
--- ncurses-5.4.orig/ncurses/base/MKkeyname.awk	2002-09-01 19:43:34.000000000 +0000
+++ ncurses-5.4/ncurses/base/MKkeyname.awk	2005-05-13 04:09:58.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: MKkeyname.awk,v 1.24 2002/09/01 19:43:34 tom Exp $
+# $Id: MKkeyname.awk,v 1.28 2005/04/30 19:26:25 tom Exp $
 ##############################################################################
-# Copyright (c) 1999-2001,2002 Free Software Foundation, Inc.                #
+# Copyright (c) 1999-2002,2005 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"), #
@@ -31,6 +31,7 @@
 	print ""
 	print "#include <curses.priv.h>"
 	print "#include <tic.h>"
+	print "#include <term_entry.h>"
 	print ""
 	print "const struct kn _nc_key_names[] = {"
 }
@@ -44,47 +45,74 @@
 	print ""
 	print "NCURSES_EXPORT(NCURSES_CONST char *) keyname (int c)"
 	print "{"
-	print "static char **table;"
-	print "int i;"
-	print "char name[20];"
-	print "char *p;"
-	print ""
-	print "\tif (c == -1) return \"-1\";"
-	print ""
-	print "\tfor (i = 0; _nc_key_names[i].name != 0; i++)"
-	print "\t\tif (_nc_key_names[i].code == c)"
-	print "\t\t\treturn (NCURSES_CONST char *)_nc_key_names[i].name;"
-	print "\tif (c < 0 || c >= 256) return 0;"
-	print ""
-	print "\tif (table == 0)"
-	print "\t\ttable = typeCalloc(char *, 256);"
-	print "\tif (table == 0)"
-	print "\t\treturn keyname(256);"
-	print ""
-	print "\tif (table[c] == 0) {"
-	print "\t\tp = name;"
-	print "\t\tif (c >= 128) {"
-	print "\t\t\tstrcpy(p, \"M-\");"
-	print "\t\t\tp += 2;"
-	print "\t\t\tc -= 128;"
-	print "\t\t}"
-	print "\t\tif (c < 32)"
-	print "\t\t\tsprintf(p, \"^%c\", c + '@');"
-	print "\t\telse if (c == 127)"
-	print "\t\t\tstrcpy(p, \"^?\");"
-	print "\t\telse"
-	print "\t\t\tsprintf(p, \"%c\", c);"
-	print "\t\ttable[c] = strdup(name);"
-	print "\t}"
-	print "\treturn (NCURSES_CONST char *)table[c];"
+	print "	static char **table;"
+	print "	int i;"
+	print "	char name[20];"
+	print "	char *p;"
+	print "	NCURSES_CONST char *result = 0;"
+	print ""
+	print "	if (c == -1) {"
+	print "		result = \"-1\";"
+	print "	} else {"
+	print "		for (i = 0; _nc_key_names[i].name != 0; i++) {"
+	print "			if (_nc_key_names[i].code == c) {"
+	print "				result = (NCURSES_CONST char *)_nc_key_names[i].name;"
+	print "				break;"
+	print "			}"
+	print "		}"
+	print ""
+	print "		if (result == 0 && (c >= 0 && c < 256)) {"
+	print "			if (table == 0)"
+	print "				table = typeCalloc(char *, 256);"
+	print "			if (table != 0) {"
+	print "				if (table[c] == 0) {"
+	print "					p = name;"
+	print "					if (c >= 128) {"
+	print "						strcpy(p, \"M-\");"
+	print "						p += 2;"
+	print "						c -= 128;"
+	print "					}"
+	print "					if (c < 32)"
+	print "						sprintf(p, \"^%c\", c + '@');"
+	print "					else if (c == 127)"
+	print "						strcpy(p, \"^?\");"
+	print "					else"
+	print "						sprintf(p, \"%c\", c);"
+	print "					table[c] = strdup(name);"
+	print "				}"
+	print "				result = table[c];"
+	print "			}"
+	print "#if NCURSES_EXT_FUNCS && NCURSES_XNAMES"
+	print "		} else if (result == 0 && cur_term != 0) {"
+	print "			int j, k;"
+	print "			char * bound;"
+	print "			TERMTYPE *tp = &(cur_term->type);"
+	print "			int save_trace = _nc_tracing;"
+	print ""
+	print "			_nc_tracing = 0;	/* prevent recursion via keybound() */"
+	print "			for (j = 0; (bound = keybound(c, j)) != 0; ++j) {"
+	print "				for(k = STRCOUNT; k < NUM_STRINGS(tp);  k++) {"
+	print "					if (tp->Strings[k] != 0 && !strcmp(bound, tp->Strings[k])) {"
+	print "						result = ExtStrname(tp, k, strnames);"
+	print "						break;"
+	print "					}"
+	print "				}"
+	print "				if (result != 0)"
+	print "					break;"
+	print "			}"
+	print "			_nc_tracing = save_trace;"
+	print "#endif"
+	print "		}"
+	print "	}"
+	print "	return result;"
 	print "}"
 	print ""
 	print "#if USE_WIDEC_SUPPORT"
 	print "NCURSES_EXPORT(NCURSES_CONST char *) key_name (wchar_t c)"
 	print "{"
-	print "\tNCURSES_CONST char *result = keyname((int)c);"
-	print "\tif (!strncmp(result, \"M-\", 2)) result = 0;"
-	print "\treturn result;"
+	print "	NCURSES_CONST char *result = keyname((int)c);"
+	print "	if (!strncmp(result, \"M-\", 2)) result = 0;"
+	print "	return result;"
 	print "}"
 	print "#endif"
 }
diff -Naur ncurses-5.4.orig/ncurses/base/MKunctrl.awk ncurses-5.4/ncurses/base/MKunctrl.awk
--- ncurses-5.4.orig/ncurses/base/MKunctrl.awk	2001-06-02 23:59:20.000000000 +0000
+++ ncurses-5.4/ncurses/base/MKunctrl.awk	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: MKunctrl.awk,v 1.9 2001/06/02 23:59:20 skimo Exp $
+# $Id: MKunctrl.awk,v 1.10 2004/04/03 22:50:37 tom Exp $
 ##############################################################################
-# Copyright (c) 1998,2000,2001 Free Software Foundation, Inc.                #
+# Copyright (c) 1998,2001,2004 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"), #
@@ -63,7 +63,10 @@
 			printf "%s", gap
 		}
 		print "};"
+		print "int check = ChCharOf(ch);"
 		print ""
-		print "\treturn (NCURSES_CONST char *)table[ChCharOf(ch)];"
+		print "\tif (check < 0 || check >= (int)SIZEOF(table)) return 0;"
+		print ""
+		print "\treturn (NCURSES_CONST char *)table[check];"
 		print "}"
 	}
diff -Naur ncurses-5.4.orig/ncurses/base/define_key.c ncurses-5.4/ncurses/base/define_key.c
--- ncurses-5.4.orig/ncurses/base/define_key.c	2003-05-17 23:28:05.000000000 +0000
+++ ncurses-5.4/ncurses/base/define_key.c	2005-05-13 04:09:58.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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: define_key.c,v 1.8 2003/05/17 23:28:05 tom Exp $")
+MODULE_ID("$Id: define_key.c,v 1.9 2005/04/30 16:21:26 tom Exp $")
 
 NCURSES_EXPORT(int)
 define_key(const char *str, int keycode)
@@ -40,7 +40,9 @@
     int code = ERR;
 
     T((T_CALLED("define_key(%s,%d)"), _nc_visbuf(str), keycode));
-    if (keycode > 0) {
+    if (SP == 0) {
+	code = ERR;
+    } else if (keycode > 0) {
 	if (str != 0) {
 	    define_key(str, 0);
 	} else if (has_key(keycode)) {
diff -Naur ncurses-5.4.orig/ncurses/base/keybound.c ncurses-5.4/ncurses/base/keybound.c
--- ncurses-5.4.orig/ncurses/base/keybound.c	2003-03-08 19:39:31.000000000 +0000
+++ ncurses-5.4/ncurses/base/keybound.c	2005-05-13 04:09:58.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999-2000,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2003,2005 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: keybound.c,v 1.4 2003/03/08 19:39:31 tom Exp $")
+MODULE_ID("$Id: keybound.c,v 1.5 2005/04/30 16:53:42 tom Exp $")
 
 /*
  * Returns the count'th string definition which is associated with the
@@ -42,6 +42,11 @@
 NCURSES_EXPORT(char *)
 keybound(int code, int count)
 {
+    char *result = 0;
+
     T((T_CALLED("keybound(%d,%d)"), code, count));
-    returnPtr(_nc_expand_try(SP->_keytry, code, &count, 0));
+    if (SP != 0) {
+	result = _nc_expand_try(SP->_keytry, code, &count, 0);
+    }
+    returnPtr(result);
 }
diff -Naur ncurses-5.4.orig/ncurses/base/lib_addch.c ncurses-5.4/ncurses/base/lib_addch.c
--- ncurses-5.4.orig/ncurses/base/lib_addch.c	2004-02-07 18:20:46.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_addch.c	2005-05-13 04:09:52.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -36,7 +36,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_addch.c,v 1.80 2004/02/07 18:20:46 tom Exp $")
+MODULE_ID("$Id: lib_addch.c,v 1.95 2005/03/27 16:52:16 tom Exp $")
 
 /*
  * Ugly microtweaking alert.  Everything from here to end of module is
@@ -49,29 +49,50 @@
  */
 
 /* Return bit mask for clearing color pair number if given ch has color */
-#define COLOR_MASK(ch) (~(attr_t)((ch)&A_COLOR?A_COLOR:0))
+#define COLOR_MASK(ch) (~(attr_t)((ch) & A_COLOR ? A_COLOR : 0))
 
 static inline NCURSES_CH_T
 render_char(WINDOW *win, NCURSES_CH_T ch)
 /* compute a rendition of the given char correct for the current context */
 {
     attr_t a = win->_attrs;
+    int pair = GetPair(ch);
 
-    if (ISBLANK(ch) && AttrOf(ch) == A_NORMAL) {
-	/* color in attrs has precedence over bkgrnd */
+    if (ISBLANK(ch)
+	&& AttrOf(ch) == A_NORMAL
+	&& pair == 0) {
+	/* color/pair in attrs has precedence over bkgrnd */
 	ch = win->_nc_bkgd;
-	SetAttr(ch, a | (AttrOf(win->_nc_bkgd) & COLOR_MASK(a)));
+	SetAttr(ch, a | AttrOf(win->_nc_bkgd));
+	if ((pair = GET_WINDOW_PAIR(win)) == 0)
+	    pair = GetPair(win->_nc_bkgd);
+	SetPair(ch, pair);
     } else {
 	/* color in attrs has precedence over bkgrnd */
 	a |= AttrOf(win->_nc_bkgd) & COLOR_MASK(a);
 	/* color in ch has precedence */
+	if (pair == 0) {
+	    if ((pair = GET_WINDOW_PAIR(win)) == 0)
+		pair = GetPair(win->_nc_bkgd);
+	}
+#if 0
+	if (pair > 255) {
+	    NCURSES_CH_T fixme = ch;
+	    SetPair(fixme, pair);
+	}
+#endif
 	AddAttr(ch, (a & COLOR_MASK(AttrOf(ch))));
+	SetPair(ch, pair);
     }
 
-    TR(TRACE_VIRTPUT, ("render_char bkg %s, attrs %s -> ch %s",
-		       _tracech_t2(1, CHREF(win->_nc_bkgd)),
-		       _traceattr(win->_attrs),
-		       _tracech_t2(3, CHREF(ch))));
+    TR(TRACE_VIRTPUT,
+       ("render_char bkg %s (%d), attrs %s (%d) -> ch %s (%d)",
+	_tracech_t2(1, CHREF(win->_nc_bkgd)),
+	GetPair(win->_nc_bkgd),
+	_traceattr(win->_attrs),
+	GET_WINDOW_PAIR(win),
+	_tracech_t2(3, CHREF(ch)),
+	GetPair(ch)));
 
     return (ch);
 }
@@ -99,9 +120,109 @@
 #define CHECK_POSITION(win, x, y)	/* nothing */
 #endif
 
+/*
+ * The _WRAPPED flag is useful only for telling an application that we've just
+ * wrapped the cursor.  We don't do anything with this flag except set it when
+ * wrapping, and clear it whenever we move the cursor.  If we try to wrap at
+ * the lower-right corner of a window, we cannot move the cursor (since that
+ * wouldn't be legal).  So we return an error (which is what SVr4 does). 
+ * Unlike SVr4, we can successfully add a character to the lower-right corner
+ * (Solaris 2.6 does this also, however).
+ */
+static int
+wrap_to_next_line(WINDOW *win)
+{
+    win->_flags |= _WRAPPED;
+    if (++win->_cury > win->_regbottom) {
+	win->_cury = win->_regbottom;
+	win->_curx = win->_maxx;
+	if (!win->_scroll)
+	    return (ERR);
+	scroll(win);
+    }
+    win->_curx = 0;
+    return (OK);
+}
+
+#if USE_WIDEC_SUPPORT
+static int waddch_literal(WINDOW *, NCURSES_CH_T);
+/*
+ * Fill the given number of cells with blanks using the current background
+ * rendition.  This saves/restores the current x-position.
+ */
+static void
+fill_cells(WINDOW *win, int count)
+{
+    NCURSES_CH_T blank = NewChar2(BLANK_TEXT, BLANK_ATTR);
+    int save_x = win->_curx;
+    int save_y = win->_cury;
+
+    while (count-- > 0) {
+	if (waddch_literal(win, blank) == ERR)
+	    break;
+    }
+    win->_curx = save_x;
+    win->_cury = save_y;
+}
+#endif
+
+/*
+ * Build up the bytes for a multibyte character, returning the length when
+ * complete (a positive number), -1 for error and -2 for incomplete.
+ */
+#if USE_WIDEC_SUPPORT
+NCURSES_EXPORT(int)
+_nc_build_wch(WINDOW *win, ARG_CH_T ch)
+{
+    char *buffer = WINDOW_EXT(win, addch_work);
+    int len;
+    int x = win->_curx;
+    int y = win->_cury;
+    mbstate_t state;
+    wchar_t result;
+
+    if ((WINDOW_EXT(win, addch_used) != 0) &&
+	(WINDOW_EXT(win, addch_x) != x ||
+	 WINDOW_EXT(win, addch_y) != y)) {
+	/* discard the incomplete multibyte character */
+	WINDOW_EXT(win, addch_used) = 0;
+	TR(TRACE_VIRTPUT,
+	   ("Alert discarded multibyte on move (%d,%d) -> (%d,%d)",
+	    WINDOW_EXT(win, addch_y), WINDOW_EXT(win, addch_x),
+	    y, x));
+    }
+    WINDOW_EXT(win, addch_x) = x;
+    WINDOW_EXT(win, addch_y) = y;
+
+    init_mb(state);
+    buffer[WINDOW_EXT(win, addch_used)] = CharOf(CHDEREF(ch));
+    WINDOW_EXT(win, addch_used) += 1;
+    buffer[WINDOW_EXT(win, addch_used)] = '\0';
+    if ((len = mbrtowc(&result,
+		       buffer,
+		       WINDOW_EXT(win, addch_used), &state)) > 0) {
+	attr_t attrs = AttrOf(CHDEREF(ch));
+	SetChar(CHDEREF(ch), result, attrs);
+	WINDOW_EXT(win, addch_used) = 0;
+    } else {
+	if (len == -1) {
+	    /*
+	     * An error occurred.  We could either discard everything,
+	     * or assume that the error was in the previous input.
+	     * Try the latter.
+	     */
+	    TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error"));
+	    buffer[0] = CharOf(CHDEREF(ch));
+	    WINDOW_EXT(win, addch_used) = 1;
+	}
+    }
+    return len;
+}
+#endif /* USE_WIDEC_SUPPORT */
+
 static
 #if !USE_WIDEC_SUPPORT		/* cannot be inline if it is recursive */
-  inline
+inline
 #endif
 int
 waddch_literal(WINDOW *win, NCURSES_CH_T ch)
@@ -115,18 +236,6 @@
 
     CHECK_POSITION(win, x, y);
 
-    /*
-     * If we're trying to add a character at the lower-right corner more
-     * than once, fail.  (Moving the cursor will clear the flag).
-     */
-#if 0				/* Solaris 2.6 allows updating the corner more than once */
-    if (win->_flags & _WRAPPED) {
-	if (x >= win->_maxx)
-	    return (ERR);
-	win->_flags &= ~_WRAPPED;
-    }
-#endif
-
     ch = render_char(win, ch);
 
     line = win->_line + y;
@@ -137,118 +246,120 @@
      * Build up multibyte characters until we have a wide-character.
      */
     if_WIDEC({
-	if (WINDOW_EXT(win, addch_used) == 0 && Charable(ch)) {
-	    WINDOW_EXT(win, addch_used) = 0;
-	} else {
-	    char *buffer = WINDOW_EXT(win, addch_work);
-	    int len;
-	    mbstate_t state;
-	    wchar_t result;
-
-	    if ((WINDOW_EXT(win, addch_used) != 0) &&
-		(WINDOW_EXT(win, addch_x) != x ||
-		 WINDOW_EXT(win, addch_y) != y)) {
-		/* discard the incomplete multibyte character */
-		WINDOW_EXT(win, addch_used) = 0;
-	    }
-	    WINDOW_EXT(win, addch_x) = x;
-	    WINDOW_EXT(win, addch_y) = y;
+	if (WINDOW_EXT(win, addch_used) != 0 || !Charable(ch)) {
+	    int len = _nc_build_wch(win, CHREF(ch));
 
-	    memset(&state, 0, sizeof(state));
-	    buffer[WINDOW_EXT(win, addch_used)] = CharOf(ch);
-	    WINDOW_EXT(win, addch_used) += 1;
-	    buffer[WINDOW_EXT(win, addch_used)] = '\0';
-	    if ((len = mbrtowc(&result,
-			       buffer,
-			       WINDOW_EXT(win, addch_used), &state)) > 0) {
-		attr_t attrs = AttrOf(ch);
-		SetChar(ch, result, attrs);
-		WINDOW_EXT(win, addch_used) = 0;
-		if (CharOf(ch) < 256) {
+	    if (len > 0) {
+		if (is8bits(CharOf(ch))) {
 		    const char *s = unctrl(CharOf(ch));
 		    if (s[1] != 0) {
 			return waddstr(win, s);
 		    }
 		}
 	    } else {
-		if (len == -1) {
-		    /*
-		     * An error occurred.  We could either discard everything,
-		     * or assume that the error was in the previous input.
-		     * Try the latter.
-		     */
-		    TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error"));
-		    buffer[0] = CharOf(ch);
-		    WINDOW_EXT(win, addch_used) = 1;
-		}
 		return OK;
 	    }
 	}
     });
 
     /*
-     * Handle non-spacing characters
+     * Non-spacing characters are added to the current cell.
+     *
+     * Spacing characters that are wider than one column require some display
+     * adjustments.
      */
     if_WIDEC({
-	if (wcwidth(CharOf(ch)) == 0) {
-	    int i;
+	int len = wcwidth(CharOf(ch));
+	int i;
+	int j;
+
+	if (len == 0) {		/* non-spacing */
 	    if ((x > 0 && y >= 0)
 		|| ((y = win->_cury - 1) >= 0 &&
 		    (x = win->_maxx) > 0)) {
 		wchar_t *chars = (win->_line[y].text[x - 1].chars);
 		for (i = 0; i < CCHARW_MAX; ++i) {
 		    if (chars[i] == 0) {
+			TR(TRACE_VIRTPUT,
+			   ("added non-spacing %d: %x",
+			    x, (int) CharOf(ch)));
 			chars[i] = CharOf(ch);
 			break;
 		    }
 		}
 	    }
 	    goto testwrapping;
+	} else if (len > 1) {	/* multi-column characters */
+	    /*
+	     * Check if the character will fit on the current line.  If it does
+	     * not fit, fill in the remainder of the line with blanks.  and
+	     * move to the next line.
+	     */
+	    if (len > win->_maxx + 1) {
+		TR(TRACE_VIRTPUT, ("character will not fit"));
+		return ERR;
+	    } else if (x + len > win->_maxx + 1) {
+		int count = win->_maxx + 1 - x;
+		TR(TRACE_VIRTPUT, ("fill %d remaining cells", count));
+		fill_cells(win, count);
+		if (wrap_to_next_line(win) == ERR)
+		    return ERR;
+		x = win->_curx;
+		y = win->_cury;
+	    }
+	    /*
+	     * Check for cells which are orphaned by adding this character, set
+	     * those to blanks.
+	     *
+	     * FIXME: this actually could fill j-i cells, more complicated to
+	     * setup though.
+	     */
+	    for (i = 0; i < len; ++i) {
+		if (isWidecBase(win->_line[y].text[i])) {
+		    break;
+		} else if (isWidecExt(win->_line[y].text[x + i])) {
+		    for (j = i; x + j <= win->_maxx; ++j) {
+			if (!isWidecExt(win->_line[y].text[x + j])) {
+			    TR(TRACE_VIRTPUT, ("fill %d orphan cells", j));
+			    fill_cells(win, j);
+			    break;
+			}
+		    }
+		    break;
+		}
+	    }
+	    /*
+	     * Finally, add the cells for this character.
+	     */
+	    for (i = 0; i < len; ++i) {
+		NCURSES_CH_T value = ch;
+		SetWidecExt(value, i);
+		TR(TRACE_VIRTPUT, ("multicolumn %d:%d", i + 1, len));
+		line->text[x] = value;
+		CHANGED_CELL(line, x);
+		++x;
+	    }
+	    goto testwrapping;
 	}
     });
+
+    /*
+     * Single-column characters.
+     */
     line->text[x++] = ch;
     /*
-     * Provide for multi-column characters
+     * This label is used only for wide-characters.
      */
-    if_WIDEC({
-	int len = wcwidth(CharOf(ch));
-	while (len-- > 1) {
-	    if (x + (len - 1) > win->_maxx) {
-		NCURSES_CH_T blank = NewChar2(BLANK_TEXT, BLANK_ATTR);
-		AddAttr(blank, AttrOf(ch));
-		if (waddch_literal(win, blank) != ERR)
-		    return waddch_literal(win, ch);
-		return ERR;
-	    }
-	    AddAttr(line->text[x++], WA_NAC);
-	    TR(TRACE_VIRTPUT, ("added NAC %d", x - 1));
-	}
-    }
+    if_WIDEC(
   testwrapping:
     );
 
-    TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracech_t(CHREF(ch))));
+    TR(TRACE_VIRTPUT, ("cell (%d, %d..%d) = %s",
+		       win->_cury, win->_curx, x - 1,
+		       _tracech_t(CHREF(ch))));
+
     if (x > win->_maxx) {
-	/*
-	 * The _WRAPPED flag is useful only for telling an application that
-	 * we've just wrapped the cursor.  We don't do anything with this flag
-	 * except set it when wrapping, and clear it whenever we move the
-	 * cursor.  If we try to wrap at the lower-right corner of a window, we
-	 * cannot move the cursor (since that wouldn't be legal).  So we return
-	 * an error (which is what SVr4 does).  Unlike SVr4, we can
-	 * successfully add a character to the lower-right corner (Solaris 2.6
-	 * does this also, however).
-	 */
-	win->_flags |= _WRAPPED;
-	if (++win->_cury > win->_regbottom) {
-	    win->_cury = win->_regbottom;
-	    win->_curx = win->_maxx;
-	    if (!win->_scroll)
-		return (ERR);
-	    scroll(win);
-	}
-	win->_curx = 0;
-	return (OK);
+	return wrap_to_next_line(win);
     }
     win->_curx = x;
     return OK;
@@ -260,7 +371,7 @@
 {
     int x, y;
     chtype t = CharOf(ch);
-    const char *s = 0;
+    const char *s = unctrl(t);
 
     /*
      * If we are using the alternate character set, forget about locale.
@@ -268,13 +379,20 @@
      * claims the code is printable, treat it that way.
      */
     if ((AttrOf(ch) & A_ALTCHARSET)
-	|| ((s = unctrl(t))[1] == 0 ||
-		(
-		isprint(t)
+	|| (
+#if USE_WIDEC_SUPPORT
+	       (SP != 0 && SP->_legacy_coding) &&
+#endif
+	       s[1] == 0
+	)
+	|| (
+	       isprint(t)
 #if USE_WIDEC_SUPPORT
-		|| WINDOW_EXT(win, addch_used)
+	       || ((SP == 0 || !SP->_legacy_coding) &&
+		   (WINDOW_EXT(win, addch_used)
+		    || !_nc_is_charable(CharOf(ch))))
 #endif
-		)))
+	))
 	return waddch_literal(win, ch);
 
     /*
@@ -360,7 +478,7 @@
 }
 
 /*
- * The versions below call _nc_synhook().  We wanted to avoid this in the
+ * The versions below call _nc_synchook().  We wanted to avoid this in the
  * version exported for string puts; they'll call _nc_synchook once at end
  * of run.
  */
diff -Naur ncurses-5.4.orig/ncurses/base/lib_addstr.c ncurses-5.4/ncurses/base/lib_addstr.c
--- ncurses-5.4.orig/ncurses/base/lib_addstr.c	2003-12-06 18:04:33.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_addstr.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -30,7 +30,7 @@
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
  *                                                                          *
- *  Rewritten 2001-2002 to support wide-characters by                       *
+ *  Rewritten 2001-2004 to support wide-characters by                       *
  *	Sven Verdoolaege                                                    *
  *	Thomas Dickey                                                       *
  ****************************************************************************/
@@ -44,7 +44,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_addstr.c,v 1.39 2003/12/06 18:04:33 tom Exp $")
+MODULE_ID("$Id: lib_addstr.c,v 1.43 2004/12/12 00:15:31 tom Exp $")
 
 NCURSES_EXPORT(int)
 waddnstr(WINDOW *win, const char *astr, int n)
@@ -119,7 +119,7 @@
 #if USE_WIDEC_SUPPORT
 
 NCURSES_EXPORT(int)
-_nc_wchstrlen(const cchar_t * s)
+_nc_wchstrlen(const cchar_t *s)
 {
     int result = 0;
     while (CharOf(s[result]) != L'\0') {
@@ -129,13 +129,14 @@
 }
 
 NCURSES_EXPORT(int)
-wadd_wchnstr(WINDOW *win, const cchar_t * astr, int n)
+wadd_wchnstr(WINDOW *win, const cchar_t *astr, int n)
 {
+    NCURSES_CH_T blank = NewChar(BLANK_TEXT);
     NCURSES_SIZE_T y = win->_cury;
     NCURSES_SIZE_T x = win->_curx;
     int code = OK;
     struct ldat *line;
-    int i, start, end;
+    int i, j, start, len, end;
 
     T((T_CALLED("wadd_wchnstr(%p,%s,%d)"), win, _nc_viscbuf(astr, n), n));
 
@@ -153,22 +154,58 @@
     line = &(win->_line[y]);
     start = x;
     end = x + n - 1;
-    if (isnac(line->text[x])) {
-	line->text[x - 1] = win->_nc_bkgd;
-	--start;
+
+    /*
+     * Reset orphaned cells of multi-column characters that extend up to the
+     * new string's location to blanks.
+     */
+    if (x > 0 && isWidecExt(line->text[x])) {
+	for (i = 0; i <= x; ++i) {
+	    if (!isWidecExt(line->text[x - i])) {
+		/* must be isWidecBase() */
+		start -= i;
+		while (i > 0) {
+		    line->text[x - i--] = _nc_render(win, blank);
+		}
+		break;
+	    }
+	}
     }
+
+    /*
+     * Copy the new string to the window.
+     */
     for (i = 0; i < n && x <= win->_maxx; ++i) {
-	line->text[x++] = astr[i];
-	if (wcwidth(CharOf(astr[i])) > 1) {
-	    if (x <= win->_maxx)
-		AddAttr(line->text[x++], WA_NAC);
-	    else
-		line->text[x - 1] = win->_nc_bkgd;
+	if (isWidecExt(astr[i]))
+	    continue;
+
+	len = wcwidth(CharOf(astr[i]));
+
+	if (x + len - 1 <= win->_maxx) {
+	    line->text[x] = _nc_render(win, astr[i]);
+	    if (len > 1) {
+		for (j = 0; j < len; ++j) {
+		    if (j != 0) {
+			line->text[x + j] = line->text[x];
+		    }
+		    SetWidecExt(line->text[x + j], j);
+		}
+	    }
+	    x += len;
+	    end += len - 1;
+	} else {
+	    break;
 	}
     }
-    if (x <= win->_maxx && isnac(line->text[x])) {
-	line->text[x] = win->_nc_bkgd;
+
+    /*
+     * Set orphaned cells of multi-column characters which lie after the new
+     * string to blanks.
+     */
+    while (x <= win->_maxx && isWidecExt(line->text[x])) {
+	line->text[x] = _nc_render(win, blank);
 	++end;
+	++x;
     }
     CHANGED_RANGE(line, start, end);
 
@@ -177,7 +214,7 @@
 }
 
 NCURSES_EXPORT(int)
-waddnwstr(WINDOW *win, const wchar_t * str, int n)
+waddnwstr(WINDOW *win, const wchar_t *str, int n)
 {
     int code = ERR;
 
diff -Naur ncurses-5.4.orig/ncurses/base/lib_beep.c ncurses-5.4/ncurses/base/lib_beep.c
--- ncurses-5.4.orig/ncurses/base/lib_beep.c	2000-12-10 02:43:26.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_beep.c	2005-05-13 04:09:56.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -41,7 +42,7 @@
 #include <curses.priv.h>
 #include <term.h>		/* beep, flash */
 
-MODULE_ID("$Id: lib_beep.c,v 1.9 2000/12/10 02:43:26 tom Exp $")
+MODULE_ID("$Id: lib_beep.c,v 1.10 2005/04/09 15:20:04 tom Exp $")
 
 /*
  *	beep()
@@ -59,7 +60,9 @@
     T((T_CALLED("beep()")));
 
     /* FIXME: should make sure that we are not in altchar mode */
-    if (bell) {
+    if (cur_term == 0) {
+	res = ERR;
+    } else if (bell) {
 	TPUTS_TRACE("bell");
 	res = putp(bell);
 	_nc_flush();
diff -Naur ncurses-5.4.orig/ncurses/base/lib_bkgd.c ncurses-5.4/ncurses/base/lib_bkgd.c
--- ncurses-5.4.orig/ncurses/base/lib_bkgd.c	2003-07-05 16:46:49.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_bkgd.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2001-2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,11 +29,14 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Juergen Pfeifer                         1997                    *
+ *     and: Sven Verdoolaege                        2000                    *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_bkgd.c,v 1.30 2003/07/05 16:46:49 tom Exp $")
+MODULE_ID("$Id: lib_bkgd.c,v 1.32 2005/04/16 18:03:48 tom Exp $")
 
 /*
  * Set the window's background information.
@@ -54,10 +57,23 @@
 	toggle_attr_off(win->_attrs, off);
 	toggle_attr_on(win->_attrs, on);
 
-	if (CharOf(CHDEREF(ch)) == L('\0'))
+#if NCURSES_EXT_COLORS
+	{
+	    int pair;
+
+	    if ((pair = GetPair(win->_nc_bkgd)) != 0)
+		SET_WINDOW_PAIR(win, 0);
+	    if ((pair = GetPair(CHDEREF(ch))) != 0)
+		SET_WINDOW_PAIR(win, pair);
+	}
+#endif
+
+	if (CharOf(CHDEREF(ch)) == L('\0')) {
 	    SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch)));
-	else
+	    SetPair(win->_nc_bkgd, GetPair(CHDEREF(ch)));
+	} else {
 	    win->_nc_bkgd = CHDEREF(ch);
+	}
 #if USE_WIDEC_SUPPORT
 	/*
 	 * If we're compiled for wide-character support, _bkgrnd is the
@@ -70,9 +86,11 @@
 	    int tmp;
 
 	    wgetbkgrnd(win, &wch);
-	    tmp = _nc_to_char(CharOf(wch));
+	    tmp = _nc_to_char((wint_t) CharOf(wch));
 
-	    win->_bkgd = ((tmp == EOF) ? ' ' : (chtype) tmp) | AttrOf(wch);
+	    win->_bkgd = (((tmp == EOF) ? ' ' : (chtype) tmp)
+			  | (AttrOf(wch) & ALL_BUT_COLOR)
+			  | COLOR_PAIR(GET_WINDOW_PAIR(win)));
 	}
 #endif
     }
diff -Naur ncurses-5.4.orig/ncurses/base/lib_chgat.c ncurses-5.4/ncurses/base/lib_chgat.c
--- ncurses-5.4.orig/ncurses/base/lib_chgat.c	2001-06-03 00:05:02.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_chgat.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2001,2005 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,8 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Sven Verdoolaege                        2001                    *
+ *     and: Thomas E. Dickey                        2005                    *
  ****************************************************************************/
 
 /*
@@ -40,11 +42,10 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_chgat.c,v 1.5 2001/06/03 00:05:02 skimo Exp $")
+MODULE_ID("$Id: lib_chgat.c,v 1.6 2005/01/29 21:46:12 tom Exp $")
 
 NCURSES_EXPORT(int)
-wchgat
-(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
+wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
 {
     int i;
 
@@ -53,8 +54,10 @@
     if (win) {
 	toggle_attr_on(attr, COLOR_PAIR(color));
 
-	for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++)
+	for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) {
 	    SetAttr(win->_line[win->_cury].text[i], attr);
+	    SetPair(win->_line[win->_cury].text[i], color);
+	}
 
 	returnCode(OK);
     } else
diff -Naur ncurses-5.4.orig/ncurses/base/lib_color.c ncurses-5.4/ncurses/base/lib_color.c
--- ncurses-5.4.orig/ncurses/base/lib_color.c	2002-09-28 20:40:05.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_color.c	2005-05-13 04:09:55.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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                 *
  ****************************************************************************/
 
 /* lib_color.c
@@ -41,7 +42,7 @@
 #include <term.h>
 #include <tic.h>
 
-MODULE_ID("$Id: lib_color.c,v 1.62 2002/09/28 20:40:05 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.73 2005/04/03 14:02:47 tom Exp $")
 
 /*
  * These should be screen structure members.  They need to be globals for
@@ -53,6 +54,8 @@
 
 #define DATA(r,g,b) {r,g,b, 0,0,0, 0}
 
+#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
+
 /*
  * Given a RGB range of 0..1000, we'll normally set the individual values
  * to about 2/3 of the maximum, leaving full-range for bold/bright colors.
@@ -222,7 +225,11 @@
 
     T((T_CALLED("start_color()")));
 
-    if (!SP->_coloron) {
+    if (SP == 0) {
+	result = ERR;
+    } else if (SP->_coloron) {
+	result = OK;
+    } else {
 
 	if (reset_color_pair() != TRUE) {
 	    set_foreground_color(default_fg(), _nc_outch);
@@ -233,9 +240,10 @@
 	    COLOR_PAIRS = SP->_pair_count = max_pairs;
 	    COLORS = SP->_color_count = max_colors;
 
-	    if ((SP->_color_pairs = typeCalloc(unsigned short,
-					         (unsigned) max_pairs)) != 0) {
-		if ((SP->_color_table = typeCalloc(color_t, max_colors)) != 0) {
+	    if ((SP->_color_pairs = TYPE_CALLOC(colorpair_t,
+						max_pairs)) != 0) {
+		if ((SP->_color_table = TYPE_CALLOC(color_t,
+						    max_colors)) != 0) {
 		    SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
 		    init_color_table();
 
@@ -244,13 +252,15 @@
 
 		    SP->_coloron = 1;
 		    result = OK;
-		} else {
+		} else if (SP->_color_pairs != 0) {
 		    FreeAndNull(SP->_color_pairs);
 		}
 	    }
+	} else {
+	    result = OK;
 	}
     }
-    returnCode(OK);
+    returnCode(result);
 }
 
 /* This function was originally written by Daniel Weaver <danw@znyx.com> */
@@ -298,21 +308,21 @@
 NCURSES_EXPORT(int)
 init_pair(short pair, short f, short b)
 {
-    unsigned result;
+    colorpair_t result;
 
     T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
 
-    if ((pair < 0) || (pair >= COLOR_PAIRS))
+    if ((pair < 0) || (pair >= COLOR_PAIRS) || SP == 0 || !SP->_coloron)
 	returnCode(ERR);
 #if NCURSES_EXT_FUNCS
     if (SP->_default_color) {
 	if (f < 0)
-	    f = C_MASK;
+	    f = COLOR_DEFAULT;
 	if (b < 0)
-	    b = C_MASK;
-	if (f >= COLORS && f != C_MASK)
+	    b = COLOR_DEFAULT;
+	if (f >= COLORS && !isDefaultColor(f))
 	    returnCode(ERR);
-	if (b >= COLORS && b != C_MASK)
+	if (b >= COLORS && !isDefaultColor(b))
 	    returnCode(ERR);
     } else
 #endif
@@ -332,13 +342,12 @@
     if (SP->_color_pairs[pair] != 0
 	&& SP->_color_pairs[pair] != result) {
 	int y, x;
-	attr_t z = COLOR_PAIR(pair);
 
 	for (y = 0; y <= curscr->_maxy; y++) {
 	    struct ldat *ptr = &(curscr->_line[y]);
 	    bool changed = FALSE;
 	    for (x = 0; x <= curscr->_maxx; x++) {
-		if ((AttrOf(ptr->text[x]) & A_COLOR) == z) {
+		if (GetPair(ptr->text[x]) == pair) {
 		    /* Set the old cell to zero to ensure it will be
 		       updated on the next doupdate() */
 		    SetChar(ptr->text[x], 0, 0);
@@ -351,8 +360,8 @@
 	}
     }
     SP->_color_pairs[pair] = result;
-    if ((int) (SP->_current_attr & A_COLOR) == COLOR_PAIR(pair))
-	SP->_current_attr |= A_COLOR;	/* force attribute update */
+    if (GET_SCREEN_PAIR(SP) == pair)
+	SET_SCREEN_PAIR(SP, ~0);	/* force attribute update */
 
     if (initialize_pair) {
 	const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
@@ -374,7 +383,7 @@
     returnCode(OK);
 }
 
-#define okRGB(n) ((n) >= 0 && (n) < 1000)
+#define okRGB(n) ((n) >= 0 && (n) <= 1000)
 
 NCURSES_EXPORT(int)
 init_color(short color, short r, short g, short b)
@@ -384,6 +393,8 @@
     T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
 
     if (initialize_color != NULL
+	&& SP != 0
+	&& SP->_coloron
 	&& (color >= 0 && color < COLORS)
 	&& (okRGB(r) && okRGB(g) && okRGB(b))) {
 
@@ -433,43 +444,75 @@
 NCURSES_EXPORT(int)
 color_content(short color, short *r, short *g, short *b)
 {
+    int result;
+
     T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b));
-    if (color < 0 || color >= COLORS)
-	returnCode(ERR);
+    if (color < 0 || color >= COLORS || SP == 0 || !SP->_coloron) {
+	result = ERR;
+    } else {
+	NCURSES_COLOR_T c_r = SP->_color_table[color].red;
+	NCURSES_COLOR_T c_g = SP->_color_table[color].green;
+	NCURSES_COLOR_T c_b = SP->_color_table[color].blue;
+
+	if (r)
+	    *r = c_r;
+	if (g)
+	    *g = c_g;
+	if (b)
+	    *b = c_b;
 
-    if (r)
-	*r = SP->_color_table[color].red;
-    if (g)
-	*g = SP->_color_table[color].green;
-    if (b)
-	*b = SP->_color_table[color].blue;
-    T(("...color_content(%d,%d,%d,%d)", color, *r, *g, *b));
-    returnCode(OK);
+	T(("...color_content(%d,%d,%d,%d)", color, c_r, c_g, c_b));
+	result = OK;
+    }
+    returnCode(result);
 }
 
 NCURSES_EXPORT(int)
 pair_content(short pair, short *f, short *b)
 {
+    int result;
+
     T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b));
 
-    if ((pair < 0) || (pair >= COLOR_PAIRS))
-	returnCode(ERR);
-    if (f)
-	*f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
-    if (b)
-	*b = (SP->_color_pairs[pair] & C_MASK);
+    if ((pair < 0) || (pair >= COLOR_PAIRS) || SP == 0 || !SP->_coloron) {
+	result = ERR;
+    } else {
+	NCURSES_COLOR_T fg = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
+	NCURSES_COLOR_T bg = (SP->_color_pairs[pair] & C_MASK);
 
-    T(("...pair_content(%d,%d,%d)", pair, *f, *b));
-    returnCode(OK);
+#if NCURSES_EXT_FUNCS
+	if (fg == COLOR_DEFAULT)
+	    fg = -1;
+	if (bg == COLOR_DEFAULT)
+	    bg = -1;
+#endif
+
+	if (f)
+	    *f = fg;
+	if (b)
+	    *b = bg;
+
+	T(("...pair_content(%d,%d,%d)", pair, fg, bg));
+	result = OK;
+    }
+    returnCode(result);
 }
 
+#define isDefaultPair(pair) ((pair) == 0)
+
 NCURSES_EXPORT(void)
 _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
 {
-    NCURSES_COLOR_T fg = C_MASK, bg = C_MASK;
+    NCURSES_COLOR_T fg = COLOR_DEFAULT;
+    NCURSES_COLOR_T bg = COLOR_DEFAULT;
     NCURSES_COLOR_T old_fg, old_bg;
 
-    if (pair < 0 || pair >= COLOR_PAIRS) {
+    if (pair < 0 ||
+	pair >= COLOR_PAIRS ||
+	((isDefaultPair(old_pair) &&
+	  isDefaultPair(pair)) &&
+	 (no_color_video <= 0 ||
+	  (no_color_video & 4) == 0))) {
 	return;
     } else if (pair != 0) {
 	if (set_color_pair) {
@@ -484,17 +527,21 @@
     if (old_pair >= 0
 	&& SP != 0
 	&& pair_content(old_pair, &old_fg, &old_bg) != ERR) {
-	if ((fg == C_MASK && old_fg != C_MASK)
-	    || (bg == C_MASK && old_bg != C_MASK)) {
+	if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
+	    || (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
 #if NCURSES_EXT_FUNCS
 	    /*
 	     * A minor optimization - but extension.  If "AX" is specified in
 	     * the terminal description, treat it as screen's indicator of ECMA
 	     * SGR 39 and SGR 49, and assume the two sequences are independent.
 	     */
-	    if (SP->_has_sgr_39_49 && old_bg == C_MASK && old_fg != C_MASK) {
+	    if (SP->_has_sgr_39_49
+		&& isDefaultColor(old_bg)
+		&& !isDefaultColor(old_fg)) {
 		tputs("\033[39m", 1, outc);
-	    } else if (SP->_has_sgr_39_49 && old_fg == C_MASK && old_bg != C_MASK) {
+	    } else if (SP->_has_sgr_39_49
+		       && isDefaultColor(old_fg)
+		       && !isDefaultColor(old_bg)) {
 		tputs("\033[49m", 1, outc);
 	    } else
 #endif
@@ -507,9 +554,9 @@
     }
 
 #if NCURSES_EXT_FUNCS
-    if (fg == C_MASK)
+    if (isDefaultColor(fg))
 	fg = default_fg();
-    if (bg == C_MASK)
+    if (isDefaultColor(bg))
 	bg = default_bg();
 #endif
 
@@ -522,10 +569,10 @@
     TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair,
 		     fg, bg));
 
-    if (fg != C_MASK) {
+    if (!isDefaultColor(fg)) {
 	set_foreground_color(fg, outc);
     }
-    if (bg != C_MASK) {
+    if (!isDefaultColor(bg)) {
 	set_background_color(bg, outc);
     }
 }
diff -Naur ncurses-5.4.orig/ncurses/base/lib_colorset.c ncurses-5.4/ncurses/base/lib_colorset.c
--- ncurses-5.4.orig/ncurses/base/lib_colorset.c	2003-12-07 00:15:27.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_colorset.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -27,7 +27,8 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Juergen Pfeifer, 1998                                           *
+ *  Author: Juergen Pfeifer,  1998                                          *
+ *     and: Thomas E. Dickey, 2005                                          *
  ****************************************************************************/
 
 /*
@@ -40,7 +41,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_colorset.c,v 1.10 2003/12/07 00:15:27 tom Exp $")
+MODULE_ID("$Id: lib_colorset.c,v 1.11 2005/01/29 21:40:51 tom Exp $")
 
 NCURSES_EXPORT(int)
 wcolor_set(WINDOW *win, short color_pair_number, void *opts)
@@ -50,9 +51,9 @@
 	&& !opts
 	&& (color_pair_number >= 0)
 	&& (color_pair_number < COLOR_PAIRS)) {
-	TR(TRACE_ATTRS, ("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
-	win->_attrs &= ALL_BUT_COLOR;
-	win->_attrs |= COLOR_PAIR(color_pair_number);
+	TR(TRACE_ATTRS, ("... current %ld", (long) GET_WINDOW_PAIR(win)));
+	SET_WINDOW_PAIR(win, color_pair_number);
+	if_EXT_COLORS(win->_color = color_pair_number);
 	returnCode(OK);
     } else
 	returnCode(ERR);
diff -Naur ncurses-5.4.orig/ncurses/base/lib_dft_fgbg.c ncurses-5.4/ncurses/base/lib_dft_fgbg.c
--- ncurses-5.4.orig/ncurses/base/lib_dft_fgbg.c	2000-12-10 02:43:27.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_dft_fgbg.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -27,13 +27,13 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 1997,1999                   *
+ *  Author: Thomas E. Dickey                                                *
  ****************************************************************************/
 
 #include <curses.priv.h>
 #include <term.h>
 
-MODULE_ID("$Id: lib_dft_fgbg.c,v 1.15 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.17 2005/01/29 21:42:15 tom Exp $")
 
 /*
  * Modify the behavior of color-pair 0 so that the library doesn't assume that
@@ -43,7 +43,7 @@
 use_default_colors(void)
 {
     T((T_CALLED("use_default_colors()")));
-    returnCode(assume_default_colors(C_MASK, C_MASK));
+    returnCode(assume_default_colors(-1, -1));
 }
 
 /*
@@ -61,11 +61,15 @@
     if (initialize_pair)	/* don't know how to handle this */
 	returnCode(ERR);
 
-    SP->_default_color = (fg < 0 || fg == C_MASK) || (bg < 0 || bg == C_MASK);
+    SP->_default_color = isDefaultColor(fg) || isDefaultColor(bg);
     SP->_has_sgr_39_49 = (tigetflag("AX") == TRUE);
-    SP->_default_fg = (fg >= 0) ? (fg & C_MASK) : C_MASK;
-    SP->_default_bg = (bg >= 0) ? (bg & C_MASK) : C_MASK;
-    if (SP->_color_pairs != 0)
+    SP->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : (fg & C_MASK);
+    SP->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : (bg & C_MASK);
+    if (SP->_color_pairs != 0) {
+	bool save = SP->_default_color;
+	SP->_default_color = TRUE;
 	init_pair(0, fg, bg);
+	SP->_default_color = save;
+    }
     returnCode(OK);
 }
diff -Naur ncurses-5.4.orig/ncurses/base/lib_freeall.c ncurses-5.4/ncurses/base/lib_freeall.c
--- ncurses-5.4.orig/ncurses/base/lib_freeall.c	2003-12-27 18:21:57.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_freeall.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,6 +32,7 @@
 
 #include <curses.priv.h>
 #include <term_entry.h>
+#include <tic.h>
 
 #if HAVE_NC_FREEALL
 
@@ -39,7 +40,7 @@
 extern int malloc_errfd;	/* FIXME */
 #endif
 
-MODULE_ID("$Id: lib_freeall.c,v 1.26 2003/12/27 18:21:57 tom Exp $")
+MODULE_ID("$Id: lib_freeall.c,v 1.32 2005/01/22 22:19:28 tom Exp $")
 
 /*
  * Free all ncurses data.  This is used for testing only (there's no practical
@@ -54,7 +55,9 @@
     T((T_CALLED("_nc_freeall()")));
 #if NO_LEAKS
     _nc_free_tparm();
-    FreeAndNull(_nc_oldnums);
+    if (_nc_oldnums != 0) {
+	FreeAndNull(_nc_oldnums);
+    }
 #endif
     if (SP != 0) {
 	while (_nc_windows != 0) {
@@ -82,6 +85,11 @@
 
     del_curterm(cur_term);
     _nc_free_entries(_nc_head);
+    _nc_get_type(0);
+    _nc_first_name(0);
+#if USE_WIDEC_SUPPORT
+    FreeIfNeeded(_nc_wacs);
+#endif
 
     if ((s = _nc_home_terminfo()) != 0)
 	free(s);
@@ -94,6 +102,8 @@
 #if HAVE_LIBDBMALLOC
     malloc_dump(malloc_errfd);
 #elif HAVE_LIBDMALLOC
+#elif HAVE_LIBMPATROL
+    __mp_summary();
 #elif HAVE_PURIFY
     purify_all_inuse();
 #endif
diff -Naur ncurses-5.4.orig/ncurses/base/lib_getch.c ncurses-5.4/ncurses/base/lib_getch.c
--- ncurses-5.4.orig/ncurses/base/lib_getch.c	2003-05-17 23:49:28.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_getch.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.71 2003/05/17 23:49:28 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.72 2005/01/22 22:05:39 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -466,7 +467,7 @@
     T((T_CALLED("wgetch(%p)"), win));
     code = _nc_wgetch(win,
 		      &value,
-		      SP->_use_meta
+		      (SP ? SP->_use_meta : 0)
 		      EVENTLIST_2nd((_nc_eventlist *) 0));
     if (code != ERR)
 	code = value;
diff -Naur ncurses-5.4.orig/ncurses/base/lib_insch.c ncurses-5.4/ncurses/base/lib_insch.c
--- ncurses-5.4.orig/ncurses/base/lib_insch.c	2002-11-23 21:41:05.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_insch.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -43,22 +43,26 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_insch.c,v 1.18 2002/11/23 21:41:05 tom Exp $")
+MODULE_ID("$Id: lib_insch.c,v 1.24 2005/02/26 19:27:28 tom Exp $")
 
 /*
  * Insert the given character, updating the current location to simplify
  * inserting a string.
  */
-void
+NCURSES_EXPORT(int)
 _nc_insert_ch(WINDOW *win, chtype ch)
 {
+    int code = OK;
     NCURSES_CH_T wch;
     int count;
+    NCURSES_CONST char *s;
 
     switch (ch) {
     case '\t':
-	for (count = (TABSIZE - (win->_curx % TABSIZE)); count > 0; count--)
-	    _nc_insert_ch(win, ' ');
+	for (count = (TABSIZE - (win->_curx % TABSIZE)); count > 0; count--) {
+	    if ((code = _nc_insert_ch(win, ' ')) != OK)
+		break;
+	}
 	break;
     case '\n':
     case '\r':
@@ -67,27 +71,49 @@
 	_nc_waddch_nosync(win, wch);
 	break;
     default:
-	if (is7bits(ch) && iscntrl(ch)) {
-	    _nc_insert_ch(win, '^');
-	    _nc_insert_ch(win, '@' + (ch));
-	} else if (win->_curx <= win->_maxx) {
-	    struct ldat *line = &(win->_line[win->_cury]);
-	    NCURSES_CH_T *end = &(line->text[win->_curx]);
-	    NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
-	    NCURSES_CH_T *temp2 = temp1 - 1;
-
+	if (
+#if USE_WIDEC_SUPPORT
+	       WINDOW_EXT(win, addch_used) == 0 &&
+#endif
+	       is8bits(ChCharOf(ch)) &&
+	       isprint(ChCharOf(ch))) {
+	    if (win->_curx <= win->_maxx) {
+		struct ldat *line = &(win->_line[win->_cury]);
+		NCURSES_CH_T *end = &(line->text[win->_curx]);
+		NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
+		NCURSES_CH_T *temp2 = temp1 - 1;
+
+		SetChar2(wch, ch);
+
+		CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+		while (temp1 > end)
+		    *temp1-- = *temp2--;
+
+		*temp1 = _nc_render(win, wch);
+		win->_curx++;
+	    }
+	} else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) {
+	    s = unctrl(ChCharOf(ch));
+	    while (*s != '\0') {
+		if ((code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s))) != OK)
+		    break;
+		++s;
+	    }
+	}
+#if USE_WIDEC_SUPPORT
+	else {
+	    /*
+	     * Handle multibyte characters here
+	     */
 	    SetChar2(wch, ch);
-
-	    CHANGED_TO_EOL(line, win->_curx, win->_maxx);
-	    while (temp1 > end)
-		*temp1-- = *temp2--;
-
-	    *temp1 = _nc_render(win, wch);
-
-	    win->_curx++;
+	    wch = _nc_render(win, wch);
+	    if (_nc_build_wch(win, &wch) >= 0)
+		code = wins_wch(win, &wch);
 	}
+#endif
 	break;
     }
+    return code;
 }
 
 NCURSES_EXPORT(int)
@@ -103,37 +129,11 @@
 	oy = win->_cury;
 	ox = win->_curx;
 
-	_nc_insert_ch(win, c);
-
-	win->_curx = ox;
-	win->_cury = oy;
-	_nc_synchook(win);
-	code = OK;
-    }
-    returnCode(code);
-}
-
-NCURSES_EXPORT(int)
-winsnstr(WINDOW *win, const char *s, int n)
-{
-    int code = ERR;
-    NCURSES_SIZE_T oy;
-    NCURSES_SIZE_T ox;
-    const unsigned char *str = (const unsigned char *) s;
-    const unsigned char *cp;
-
-    T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s, n), n));
+	code = _nc_insert_ch(win, c);
 
-    if (win != 0 && str != 0) {
-	oy = win->_cury;
-	ox = win->_curx;
-	for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
-	    _nc_insert_ch(win, (chtype) UChar(*cp));
-	}
 	win->_curx = ox;
 	win->_cury = oy;
 	_nc_synchook(win);
-	code = OK;
     }
     returnCode(code);
 }
diff -Naur ncurses-5.4.orig/ncurses/base/lib_insnstr.c ncurses-5.4/ncurses/base/lib_insnstr.c
--- ncurses-5.4.orig/ncurses/base/lib_insnstr.c	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_insnstr.c	2005-05-13 04:09:50.000000000 +0000
@@ -0,0 +1,68 @@
+/****************************************************************************
+ * Copyright (c) 2004 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"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/****************************************************************************
+ *  Author: Thomas E. Dickey                                                *
+ ****************************************************************************/
+
+/*
+**	lib_insnstr.c
+**
+**	The routine winsnstr().
+**
+*/
+
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_insnstr.c,v 1.1 2004/02/28 23:44:56 tom Exp $")
+
+NCURSES_EXPORT(int)
+winsnstr(WINDOW *win, const char *s, int n)
+{
+    int code = ERR;
+    NCURSES_SIZE_T oy;
+    NCURSES_SIZE_T ox;
+    const unsigned char *str = (const unsigned char *) s;
+    const unsigned char *cp;
+
+    T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s, n), n));
+
+    if (win != 0 && str != 0) {
+	oy = win->_cury;
+	ox = win->_curx;
+	for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
+	    _nc_insert_ch(win, (chtype) UChar(*cp));
+	}
+	win->_curx = ox;
+	win->_cury = oy;
+	_nc_synchook(win);
+	code = OK;
+    }
+    returnCode(code);
+}
diff -Naur ncurses-5.4.orig/ncurses/base/lib_instr.c ncurses-5.4/ncurses/base/lib_instr.c
--- ncurses-5.4.orig/ncurses/base/lib_instr.c	2002-10-05 23:23:05.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_instr.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_instr.c,v 1.12 2002/10/05 23:23:05 tom Exp $")
+MODULE_ID("$Id: lib_instr.c,v 1.14 2005/04/16 17:51:12 tom Exp $")
 
 NCURSES_EXPORT(int)
 winnstr(WINDOW *win, char *str, int n)
@@ -59,7 +60,47 @@
 	    n = win->_maxx - win->_curx + 1;
 
 	for (; i < n;) {
+#if USE_WIDEC_SUPPORT
+	    cchar_t *cell = &(win->_line[row].text[col]);
+	    wchar_t *wch;
+	    attr_t attrs;
+	    short pair;
+	    int n2;
+	    bool done = FALSE;
+	    mbstate_t state;
+	    size_t i3, n3;
+	    char *tmp;
+
+	    if (!isWidecExt(*cell)) {
+		n2 = getcchar(cell, 0, 0, 0, 0);
+		if (n2 > 0
+		    && (wch = typeCalloc(wchar_t, (unsigned) n2 + 1)) != 0) {
+		    if (getcchar(cell, wch, &attrs, &pair, 0) == OK) {
+
+			init_mb(state);
+			n3 = wcstombs(0, wch, 0);
+			if (isEILSEQ(n3) || (n3 == 0)) {
+			    ;
+			} else if ((int) (n3 + i) >= n) {
+			    done = TRUE;
+			} else if ((tmp = typeCalloc(char, n3 + 10)) == 0) {
+			    done = TRUE;
+			} else {
+			    init_mb(state);
+			    wcstombs(tmp, wch, n3);
+			    for (i3 = 0; i3 < n3; ++i3)
+				str[i++] = tmp[i3];
+			    free(tmp);
+			}
+		    }
+		    free(wch);
+		    if (done)
+			break;
+		}
+	    }
+#else
 	    str[i++] = CharOf(win->_line[row].text[col]);
+#endif
 	    if (++col > win->_maxx) {
 		col = 0;
 		if (++row > win->_maxy)
diff -Naur ncurses-5.4.orig/ncurses/base/lib_mouse.c ncurses-5.4/ncurses/base/lib_mouse.c
--- ncurses-5.4.orig/ncurses/base/lib_mouse.c	2003-11-08 21:50:50.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_mouse.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,15 +29,18 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Thomas E. Dickey 1996-2003                                      *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 /*
  * This module is intended to encapsulate ncurses's interface to pointing
  * devices.
  *
- * The first method used is xterm's internal mouse-tracking facility.
- * The second is Alessandro Rubini's GPM server.
+ * The primary method used is xterm's internal mouse-tracking facility.
+ * Additional methods depend on the platform:
+ *	Alessandro Rubini's GPM server (Linux)
+ *	sysmouse (FreeBSD)
+ *	special-purpose mouse interface for OS/2 EMX.
  *
  * Notes for implementors of new mouse-interface methods:
  *
@@ -76,7 +79,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_mouse.c,v 1.68 2003/11/08 21:50:50 tom Exp $")
+MODULE_ID("$Id: lib_mouse.c,v 1.74 2005/04/16 18:07:56 tom Exp $")
 
 #include <term.h>
 #include <tic.h>
@@ -86,8 +89,19 @@
 #undef buttons			/* term.h defines this, and gpm uses it! */
 #include <gpm.h>
 #include <linux/keyboard.h>	/* defines KG_* macros */
+/* use dynamic loader to avoid linkage dependency */
+#include <dlfcn.h>
+#ifdef RTLD_NOW
+#define my_RTLD RTLD_NOW
+#else
+#ifdef RTLD_LAZY
+#define my_RTLD RTLD_LAZY
+#else
+make an error
+#endif
 #endif
 #endif
+#endif				/* USE_GPM_SUPPORT */
 
 #if USE_SYSMOUSE
 #undef buttons			/* symbol conflict in consio.h */
@@ -99,29 +113,55 @@
 #else
 #include <machine/console.h>
 #endif
-#endif /* use_SYSMOUSE */
+#endif				/* use_SYSMOUSE */
 
 #define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
 
-#define	MASK_RELEASE(x)		((001 << (6 * ((x) - 1))))
-#define	MASK_PRESS(x)		((002 << (6 * ((x) - 1))))
-#define	MASK_CLICK(x)		((004 << (6 * ((x) - 1))))
-#define	MASK_DOUBLE_CLICK(x)	((010 << (6 * ((x) - 1))))
-#define	MASK_TRIPLE_CLICK(x)	((020 << (6 * ((x) - 1))))
-#define	MASK_RESERVED_EVENT(x)	((040 << (6 * ((x) - 1))))
-
-#define BUTTON_CLICKED  (BUTTON1_CLICKED  | BUTTON2_CLICKED  | BUTTON3_CLICKED)
-#define BUTTON_PRESSED  (BUTTON1_PRESSED  | BUTTON2_PRESSED  | BUTTON3_PRESSED)
-#define BUTTON_RELEASED (BUTTON1_RELEASED | BUTTON2_RELEASED | BUTTON3_RELEASED)
+#define	MASK_RELEASE(x)		NCURSES_MOUSE_MASK(x, 001)
+#define	MASK_PRESS(x)		NCURSES_MOUSE_MASK(x, 002)
+#define	MASK_CLICK(x)		NCURSES_MOUSE_MASK(x, 004)
+#define	MASK_DOUBLE_CLICK(x)	NCURSES_MOUSE_MASK(x, 010)
+#define	MASK_TRIPLE_CLICK(x)	NCURSES_MOUSE_MASK(x, 020)
+#define	MASK_RESERVED_EVENT(x)	NCURSES_MOUSE_MASK(x, 040)
+
+#if NCURSES_MOUSE_VERSION == 1
+#define BUTTON_CLICKED        (BUTTON1_CLICKED        | BUTTON2_CLICKED        | BUTTON3_CLICKED        | BUTTON4_CLICKED)
+#define BUTTON_PRESSED        (BUTTON1_PRESSED        | BUTTON2_PRESSED        | BUTTON3_PRESSED        | BUTTON4_PRESSED)
+#define BUTTON_RELEASED       (BUTTON1_RELEASED       | BUTTON2_RELEASED       | BUTTON3_RELEASED       | BUTTON4_RELEASED)
+#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED)
+#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED)
+#define MAX_BUTTONS  4
+#else
+#define BUTTON_CLICKED        (BUTTON1_CLICKED        | BUTTON2_CLICKED        | BUTTON3_CLICKED        | BUTTON4_CLICKED        | BUTTON5_CLICKED)
+#define BUTTON_PRESSED        (BUTTON1_PRESSED        | BUTTON2_PRESSED        | BUTTON3_PRESSED        | BUTTON4_PRESSED        | BUTTON5_PRESSED)
+#define BUTTON_RELEASED       (BUTTON1_RELEASED       | BUTTON2_RELEASED       | BUTTON3_RELEASED       | BUTTON4_RELEASED       | BUTTON5_RELEASED)
+#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED | BUTTON5_DOUBLE_CLICKED)
+#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED | BUTTON5_TRIPLE_CLICKED)
+#define MAX_BUTTONS  5
+#endif
 
 #define INVALID_EVENT	-1
 #define NORMAL_EVENT	0
 
 #if USE_GPM_SUPPORT
 #ifndef LINT
+
+#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(obj, #name))
+
 static Gpm_Connect gpm_connect;
-#endif
-#endif
+
+typedef int *TYPE_gpm_fd;
+typedef int (*TYPE_Gpm_Open) (Gpm_Connect *, int);
+typedef int (*TYPE_Gpm_Close) (void);
+typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
+
+static TYPE_gpm_fd my_gpm_fd;
+static TYPE_Gpm_Open my_Gpm_Open;
+static TYPE_Gpm_Close my_Gpm_Close;
+static TYPE_Gpm_GetEvent my_Gpm_GetEvent;
+
+#endif /* LINT */
+#endif /* USE_GPM_SUPPORT */
 
 static mmask_t eventmask;	/* current event mask */
 
@@ -247,12 +287,6 @@
     DosExit(EXIT_THREAD, 0L);
 }
 
-static void
-server_state(const int state)
-{				/* It would be nice to implement pointer-off and stop looping... */
-    mouse_activated = state;
-}
-
 #endif /* USE_EMX_MOUSE */
 
 #if USE_SYSMOUSE
@@ -312,7 +346,7 @@
 	work->y = the_mouse.u.data.y / SP->_sysmouse_char_height;
     }
 }
-#endif
+#endif /* USE_SYSMOUSE */
 
 static int initialized;
 
@@ -325,35 +359,104 @@
 	SP->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
 }
 
-#if !USE_EMX_MOUSE
 static void
 enable_xterm_mouse(int enable)
 {
+#if USE_EMX_MOUSE
+    mouse_activated = enable;
+#else
     putp(tparm(SP->_mouse_xtermcap, enable));
+#endif
 }
-#endif /* !USE_EMX_MOUSE */
 
-static void
-initialize_mousetype(void)
-{
-    static const char *xterm_kmous = "\033[M";
-
-    /* Try gpm first, because gpm may be configured to run in xterm */
 #if USE_GPM_SUPPORT
+static int
+allow_gpm_mouse(void)
+{
     /* GPM does printf's without checking if stdout is a terminal */
     if (isatty(fileno(stdout))) {
+	char *env = getenv("TERM");
+	/* GPM checks the beginning of the $TERM variable to decide if
+	 * it should pass xterm events through.  There is no real advantage
+	 * in allowing GPM to do this.
+	 */
+	if (env == 0 || strncmp(env, "xterm", 5))
+	    return TRUE;
+    }
+    return FALSE;
+}
+
+static int
+enable_gpm_mouse(int enable)
+{
+    int result;
+
+    if (enable) {
 	/* GPM: initialize connection to gpm server */
 	gpm_connect.eventMask = GPM_DOWN | GPM_UP;
 	gpm_connect.defaultMask = ~(gpm_connect.eventMask | GPM_HARD);
 	gpm_connect.minMod = 0;
-	gpm_connect.maxMod = ~((1 << KG_SHIFT) | (1 << KG_SHIFTL) | (1 << KG_SHIFTR));
-	if (Gpm_Open(&gpm_connect, 0) >= 0) {	/* returns the file-descriptor */
+	gpm_connect.maxMod = (unsigned short) (~((1 << KG_SHIFT) |
+						 (1 << KG_SHIFTL) |
+						 (1 << KG_SHIFTR)));
+	/*
+	 * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open.
+	 * The former is recognized by wscons (SunOS), and the latter by
+	 * xterm.  Those will not show up in ncurses' traces.
+	 */
+	result = (my_Gpm_Open(&gpm_connect, 0) >= 0);
+	T(("GPM open %s", result ? "succeeded" : "failed"));
+    } else {
+	/* GPM: close connection to gpm server */
+	my_Gpm_Close();
+	result = TRUE;
+	T(("GPM closed"));
+    }
+    return result;
+}
+#endif /* USE_GPM_SUPPORT */
+
+static void
+initialize_mousetype(void)
+{
+    static const char *xterm_kmous = "\033[M";
+
+    /* Try gpm first, because gpm may be configured to run in xterm */
+#if USE_GPM_SUPPORT
+    if (allow_gpm_mouse()) {
+	static bool first = TRUE;
+	static bool found = FALSE;
+
+	if (first) {
+	    void *obj;
+	    first = FALSE;
+
+	    if ((obj = dlopen("libgpm.so", my_RTLD)) != 0) {
+		if (GET_DLSYM(gpm_fd) == 0 ||
+		    GET_DLSYM(Gpm_Open) == 0 ||
+		    GET_DLSYM(Gpm_Close) == 0 ||
+		    GET_DLSYM(Gpm_GetEvent) == 0) {
+		    T(("GPM initialization failed: %s", dlerror()));
+		    dlclose(obj);
+		} else {
+		    found = TRUE;
+		}
+	    }
+	}
+
+	/*
+	 * The gpm_fd file-descriptor may be negative (xterm).  So we have to
+	 * maintain our notion of whether the mouse connection is active
+	 * without testing the file-descriptor.
+	 */
+	if (found && enable_gpm_mouse(TRUE)) {
 	    SP->_mouse_type = M_GPM;
-	    SP->_mouse_fd = gpm_fd;
+	    SP->_mouse_fd = *my_gpm_fd;
+	    T(("GPM mouse_fd %d", SP->_mouse_fd));
 	    return;
 	}
     }
-#endif
+#endif /* USE_GPM_SUPPORT */
 
     /* OS/2 VIO */
 #if USE_EMX_MOUSE
@@ -395,7 +498,7 @@
 	    }
 	}
     }
-#endif
+#endif /* USE_EMX_MOUSE */
 
 #if USE_SYSMOUSE
     {
@@ -475,13 +578,13 @@
     }
 }
 
-static void
+static bool
 _nc_mouse_init(void)
 /* initialize the mouse */
 {
     int i;
 
-    if (!initialized) {
+    if (!initialized && (SP != 0)) {
 	initialized = TRUE;
 
 	TR(MY_TRACE, ("_nc_mouse_init() called"));
@@ -493,6 +596,7 @@
 
 	T(("_nc_mouse_init() set mousetype to %d", SP->_mouse_type));
     }
+    return initialized;
 }
 
 /*
@@ -500,7 +604,7 @@
  * fifo_push() in lib_getch.c
  */
 static bool
-_nc_mouse_event(SCREEN * sp GCC_UNUSED)
+_nc_mouse_event(SCREEN *sp GCC_UNUSED)
 {
     bool result = FALSE;
 
@@ -530,7 +634,7 @@
 	    /* query server for event, return TRUE if we find one */
 	    Gpm_Event ev;
 
-	    if (Gpm_GetEvent(&ev) == 1) {
+	    if (my_Gpm_GetEvent(&ev) == 1) {
 		/* there's only one mouse... */
 		eventp->id = NORMAL_EVENT;
 
@@ -599,9 +703,10 @@
 }
 
 static bool
-_nc_mouse_inline(SCREEN * sp)
+_nc_mouse_inline(SCREEN *sp)
 /* mouse report received in the keyboard stream -- parse its info */
 {
+    int b;
     bool result = FALSE;
 
     TR(MY_TRACE, ("_nc_mouse_inline() called"));
@@ -639,8 +744,10 @@
 	 * (End quote)  By the time we get here, we've eaten the
 	 * key prefix.  FYI, the loop below is necessary because
 	 * mouse click info isn't guaranteed to present as a
-	 * single clist item.  It always does under Linux but often
-	 * fails to under Solaris.
+	 * single clist item.
+	 *
+	 * Wheel mice may return buttons 4 and 5 when the wheel is turned.
+	 * We encode those as button presses.
 	 */
 	for (grabbed = 0; grabbed < 3; grabbed += res) {
 
@@ -679,11 +786,19 @@
 
 	switch (kbuf[0] & 0x3) {
 	case 0x0:
-	    PRESS_POSITION(1);
+	    if (kbuf[0] & 64)
+		eventp->bstate = MASK_PRESS(4);
+	    else
+		PRESS_POSITION(1);
 	    break;
 
 	case 0x1:
-	    PRESS_POSITION(2);
+#if NCURSES_MOUSE_VERSION == 2
+	    if (kbuf[0] & 64)
+		eventp->bstate = MASK_PRESS(5);
+	    else
+#endif
+		PRESS_POSITION(2);
 	    break;
 
 	case 0x2:
@@ -700,12 +815,10 @@
 	     */
 	    if (prev & (BUTTON_PRESSED | BUTTON_RELEASED)) {
 		eventp->bstate = BUTTON_RELEASED;
-		if (!(prev & BUTTON1_PRESSED))
-		    eventp->bstate &= ~BUTTON1_RELEASED;
-		if (!(prev & BUTTON2_PRESSED))
-		    eventp->bstate &= ~BUTTON2_RELEASED;
-		if (!(prev & BUTTON3_PRESSED))
-		    eventp->bstate &= ~BUTTON3_RELEASED;
+		for (b = 1; b <= MAX_BUTTONS; ++b) {
+		    if (!(prev & MASK_PRESS(b)))
+			eventp->bstate &= ~MASK_RELEASE(b);
+		}
 	    } else {
 		/*
 		 * XFree86 xterm will return a stream of release-events to
@@ -751,7 +864,8 @@
     if (!on && !initialized)
 	return;
 
-    _nc_mouse_init();
+    if (!_nc_mouse_init())
+	return;
 
     if (on) {
 
@@ -761,15 +875,14 @@
 	    keyok(KEY_MOUSE, on);
 #endif
 	    TPUTS_TRACE("xterm mouse initialization");
-#if USE_EMX_MOUSE
-	    server_state(1);
-#else
 	    enable_xterm_mouse(1);
-#endif
 	    break;
 #if USE_GPM_SUPPORT
 	case M_GPM:
-	    SP->_mouse_fd = gpm_fd;
+	    if (enable_gpm_mouse(1)) {
+		SP->_mouse_fd = *my_gpm_fd;
+		T(("GPM mouse_fd %d", SP->_mouse_fd));
+	    }
 	    break;
 #endif
 #if USE_SYSMOUSE
@@ -794,14 +907,11 @@
 	switch (SP->_mouse_type) {
 	case M_XTERM:
 	    TPUTS_TRACE("xterm mouse deinitialization");
-#if USE_EMX_MOUSE
-	    server_state(0);
-#else
 	    enable_xterm_mouse(0);
-#endif
 	    break;
 #if USE_GPM_SUPPORT
 	case M_GPM:
+	    enable_gpm_mouse(0);
 	    break;
 #endif
 #if USE_SYSMOUSE
@@ -828,6 +938,7 @@
 {
     MEVENT *ep, *runp, *next, *prev = PREV(eventp);
     int n;
+    int b;
     bool merge;
 
     TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));
@@ -883,32 +994,27 @@
     do {
 	merge = FALSE;
 	for (ep = runp; (next = NEXT(ep)) != eventp; ep = next) {
+
+#define MASK_CHANGED(x) (!(ep->bstate & MASK_PRESS(x)) \
+		      == !(next->bstate & MASK_RELEASE(x)))
+
 	    if (ep->x == next->x && ep->y == next->y
 		&& (ep->bstate & BUTTON_PRESSED)
-		&& (!(ep->bstate & BUTTON1_PRESSED)
-		    == !(next->bstate & BUTTON1_RELEASED))
-		&& (!(ep->bstate & BUTTON2_PRESSED)
-		    == !(next->bstate & BUTTON2_RELEASED))
-		&& (!(ep->bstate & BUTTON3_PRESSED)
-		    == !(next->bstate & BUTTON3_RELEASED))
+		&& MASK_CHANGED(1)
+		&& MASK_CHANGED(2)
+		&& MASK_CHANGED(3)
+		&& MASK_CHANGED(4)
+#if NCURSES_MOUSE_VERSION == 2
+		&& MASK_CHANGED(5)
+#endif
 		) {
-		if ((eventmask & BUTTON1_CLICKED)
-		    && (ep->bstate & BUTTON1_PRESSED)) {
-		    ep->bstate &= ~BUTTON1_PRESSED;
-		    ep->bstate |= BUTTON1_CLICKED;
-		    merge = TRUE;
-		}
-		if ((eventmask & BUTTON2_CLICKED)
-		    && (ep->bstate & BUTTON2_PRESSED)) {
-		    ep->bstate &= ~BUTTON2_PRESSED;
-		    ep->bstate |= BUTTON2_CLICKED;
-		    merge = TRUE;
-		}
-		if ((eventmask & BUTTON3_CLICKED)
-		    && (ep->bstate & BUTTON3_PRESSED)) {
-		    ep->bstate &= ~BUTTON3_PRESSED;
-		    ep->bstate |= BUTTON3_CLICKED;
-		    merge = TRUE;
+		for (b = 1; b <= MAX_BUTTONS; ++b) {
+		    if ((eventmask & MASK_CLICK(b))
+			&& (ep->bstate & MASK_PRESS(b))) {
+			ep->bstate &= ~MASK_PRESS(b);
+			ep->bstate |= MASK_CLICK(b);
+			merge = TRUE;
+		    }
 		}
 		if (merge)
 		    next->id = INVALID_EVENT;
@@ -958,51 +1064,28 @@
 		/* merge click events forward */
 		if ((ep->bstate & BUTTON_CLICKED)
 		    && (follower->bstate & BUTTON_CLICKED)) {
-		    if ((eventmask & BUTTON1_DOUBLE_CLICKED)
-			&& (follower->bstate & BUTTON1_CLICKED)) {
-			follower->bstate &= ~BUTTON1_CLICKED;
-			follower->bstate |= BUTTON1_DOUBLE_CLICKED;
-			merge = TRUE;
-		    }
-		    if ((eventmask & BUTTON2_DOUBLE_CLICKED)
-			&& (follower->bstate & BUTTON2_CLICKED)) {
-			follower->bstate &= ~BUTTON2_CLICKED;
-			follower->bstate |= BUTTON2_DOUBLE_CLICKED;
-			merge = TRUE;
-		    }
-		    if ((eventmask & BUTTON3_DOUBLE_CLICKED)
-			&& (follower->bstate & BUTTON3_CLICKED)) {
-			follower->bstate &= ~BUTTON3_CLICKED;
-			follower->bstate |= BUTTON3_DOUBLE_CLICKED;
-			merge = TRUE;
+		    for (b = 1; b <= MAX_BUTTONS; ++b) {
+			if ((eventmask & MASK_DOUBLE_CLICK(b))
+			    && (follower->bstate & MASK_CLICK(b))) {
+			    follower->bstate &= ~MASK_CLICK(b);
+			    follower->bstate |= MASK_DOUBLE_CLICK(b);
+			    merge = TRUE;
+			}
 		    }
 		    if (merge)
 			ep->id = INVALID_EVENT;
 		}
 
 		/* merge double-click events forward */
-		if ((ep->bstate &
-		     (BUTTON1_DOUBLE_CLICKED
-		      | BUTTON2_DOUBLE_CLICKED
-		      | BUTTON3_DOUBLE_CLICKED))
+		if ((ep->bstate & BUTTON_DOUBLE_CLICKED)
 		    && (follower->bstate & BUTTON_CLICKED)) {
-		    if ((eventmask & BUTTON1_TRIPLE_CLICKED)
-			&& (follower->bstate & BUTTON1_CLICKED)) {
-			follower->bstate &= ~BUTTON1_CLICKED;
-			follower->bstate |= BUTTON1_TRIPLE_CLICKED;
-			merge = TRUE;
-		    }
-		    if ((eventmask & BUTTON2_TRIPLE_CLICKED)
-			&& (follower->bstate & BUTTON2_CLICKED)) {
-			follower->bstate &= ~BUTTON2_CLICKED;
-			follower->bstate |= BUTTON2_TRIPLE_CLICKED;
-			merge = TRUE;
-		    }
-		    if ((eventmask & BUTTON3_TRIPLE_CLICKED)
-			&& (follower->bstate & BUTTON3_CLICKED)) {
-			follower->bstate &= ~BUTTON3_CLICKED;
-			follower->bstate |= BUTTON3_TRIPLE_CLICKED;
-			merge = TRUE;
+		    for (b = 1; b <= MAX_BUTTONS; ++b) {
+			if ((eventmask & MASK_TRIPLE_CLICK(b))
+			    && (follower->bstate & MASK_CLICK(b))) {
+			    follower->bstate &= ~MASK_CLICK(b);
+			    follower->bstate |= MASK_TRIPLE_CLICK(b);
+			    merge = TRUE;
+			}
 		    }
 		    if (merge)
 			ep->id = INVALID_EVENT;
@@ -1050,7 +1133,7 @@
 }
 
 static void
-_nc_mouse_wrap(SCREEN * sp GCC_UNUSED)
+_nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
 /* release mouse -- called by endwin() before shellout/exit */
 {
     TR(MY_TRACE, ("_nc_mouse_wrap() called"));
@@ -1063,6 +1146,8 @@
 #if USE_GPM_SUPPORT
 	/* GPM: pass all mouse events to next client */
     case M_GPM:
+	if (eventmask)
+	    mouse_activate(FALSE);
 	break;
 #endif
 #if USE_SYSMOUSE
@@ -1076,7 +1161,7 @@
 }
 
 static void
-_nc_mouse_resume(SCREEN * sp GCC_UNUSED)
+_nc_mouse_resume(SCREEN *sp GCC_UNUSED)
 /* re-connect to mouse -- called by doupdate() after shellout */
 {
     TR(MY_TRACE, ("_nc_mouse_resume() called"));
@@ -1091,6 +1176,8 @@
 #if USE_GPM_SUPPORT
     case M_GPM:
 	/* GPM: reclaim our event set */
+	if (eventmask)
+	    mouse_activate(TRUE);
 	break;
 #endif
 
@@ -1164,15 +1251,14 @@
 	returnBits(0);
 
     _nc_mouse_init();
-    if (SP->_mouse_type != M_NONE) {
+    if (SP != 0 && SP->_mouse_type != M_NONE) {
 	eventmask = newmask &
 	    (REPORT_MOUSE_POSITION | BUTTON_ALT | BUTTON_CTRL | BUTTON_SHIFT
 	     | BUTTON_PRESSED
 	     | BUTTON_RELEASED
 	     | BUTTON_CLICKED
-	     | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
-	     | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
-	     | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
+	     | BUTTON_DOUBLE_CLICKED
+	     | BUTTON_TRIPLE_CLICKED);
 
 	mouse_activate(eventmask != 0);
 
diff -Naur ncurses-5.4.orig/ncurses/base/lib_move.c ncurses-5.4/ncurses/base/lib_move.c
--- ncurses-5.4.orig/ncurses/base/lib_move.c	2000-12-10 02:43:27.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_move.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2004 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                 *
  ****************************************************************************/
 
 /*
@@ -40,16 +41,14 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_move.c,v 1.11 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_move.c,v 1.12 2004/12/04 21:50:07 tom Exp $")
 
 NCURSES_EXPORT(int)
 wmove(WINDOW *win, int y, int x)
 {
     T((T_CALLED("wmove(%p,%d,%d)"), win, y, x));
 
-    if (win &&
-	x >= 0 && x <= win->_maxx &&
-	y >= 0 && y <= win->_maxy) {
+    if (LEGALYX(win, y, x)) {
 	win->_curx = (NCURSES_SIZE_T) x;
 	win->_cury = (NCURSES_SIZE_T) y;
 
diff -Naur ncurses-5.4.orig/ncurses/base/lib_newterm.c ncurses-5.4/ncurses/base/lib_newterm.c
--- ncurses-5.4.orig/ncurses/base/lib_newterm.c	2002-10-20 00:10:56.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_newterm.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2002,2004 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                 *
  ****************************************************************************/
 
 /*
@@ -47,7 +48,7 @@
 #include <term.h>		/* clear_screen, cup & friends, cur_term */
 #include <tic.h>
 
-MODULE_ID("$Id: lib_newterm.c,v 1.57 2002/10/20 00:10:56 Philippe.Blain Exp $")
+MODULE_ID("$Id: lib_newterm.c,v 1.58 2004/08/14 20:36:39 tom Exp $")
 
 #ifndef ONLCR			/* Allows compilation under the QNX 4.2 OS */
 #define ONLCR 0
@@ -102,7 +103,7 @@
 }
 
 NCURSES_EXPORT(SCREEN *)
-newterm(NCURSES_CONST char *name, FILE * ofp, FILE * ifp)
+newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
 {
     int errret;
     int slk_format = _nc_slk_format;
@@ -198,5 +199,13 @@
 
     _nc_signal_handler(TRUE);
 
+#if USE_SIZECHANGE
+    /*
+     * Pretend we received a SIGWINCH, just in case we're starting up in a
+     * terminal that cannot initialize its size properly (Debian #265631).
+     */
+    SP->_sig_winch = TRUE;
+#endif
+
     returnSP(SP);
 }
diff -Naur ncurses-5.4.orig/ncurses/base/lib_newwin.c ncurses-5.4/ncurses/base/lib_newwin.c
--- ncurses-5.4.orig/ncurses/base/lib_newwin.c	2002-08-18 00:12:30.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_newwin.c	2005-05-13 04:09:56.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_newwin.c,v 1.34 2002/08/18 00:12:30 tom Exp $")
+MODULE_ID("$Id: lib_newwin.c,v 1.36 2005/04/09 15:23:04 tom Exp $")
 
 static WINDOW *
 remove_window_from_screen(WINDOW *win)
@@ -120,9 +121,6 @@
     if (num_columns == 0)
 	num_columns = screen_columns - begx;
 
-    if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail)
-	returnWin(0);
-
     if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
 	returnWin(0);
 
@@ -212,6 +210,9 @@
 
     T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
 
+    if (SP == 0)
+	return 0;
+
     if (!dimension_limit(num_lines) || !dimension_limit(num_columns))
 	return 0;
 
diff -Naur ncurses-5.4.orig/ncurses/base/lib_pad.c ncurses-5.4/ncurses/base/lib_pad.c
--- ncurses-5.4.orig/ncurses/base/lib_pad.c	2002-08-03 23:29:26.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_pad.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2002,2003 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 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_pad.c,v 1.38 2002/08/03 23:29:26 Philippe.Blain Exp $")
+MODULE_ID("$Id: lib_pad.c,v 1.39 2004/10/23 18:48:09 tom Exp $")
 
 NCURSES_EXPORT(WINDOW *)
 newpad(int l, int c)
@@ -202,7 +202,7 @@
 	     */
 	    if (j == pmincol
 		&& j > 0
-		&& isnac(ch)) {
+		&& isWidecExt(ch)) {
 		SetChar(ch, L(' '), AttrOf(oline->text[j - 1]));
 	    }
 #endif
diff -Naur ncurses-5.4.orig/ncurses/base/lib_refresh.c ncurses-5.4/ncurses/base/lib_refresh.c
--- ncurses-5.4.orig/ncurses/base/lib_refresh.c	2002-05-26 00:17:04.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_refresh.c	2005-05-13 04:09:56.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2002,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -40,7 +41,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_refresh.c,v 1.32 2002/05/26 00:17:04 tom Exp $")
+MODULE_ID("$Id: lib_refresh.c,v 1.33 2005/04/09 15:20:58 tom Exp $")
 
 NCURSES_EXPORT(int)
 wrefresh(WINDOW *win)
@@ -49,7 +50,9 @@
 
     T((T_CALLED("wrefresh(%p)"), win));
 
-    if (win == curscr) {
+    if (win == 0) {
+	code = ERR;
+    } else if (win == curscr) {
 	curscr->_clear = TRUE;
 	code = doupdate();
     } else if ((code = wnoutrefresh(win)) == OK) {
diff -Naur ncurses-5.4.orig/ncurses/base/lib_scroll.c ncurses-5.4/ncurses/base/lib_scroll.c
--- ncurses-5.4.orig/ncurses/base/lib_scroll.c	2003-07-26 23:25:26.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_scroll.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2001,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -43,11 +43,14 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_scroll.c,v 1.24 2003/07/26 23:25:26 tom Exp $")
+MODULE_ID("$Id: lib_scroll.c,v 1.25 2004/12/11 18:28:51 tom Exp $")
 
 NCURSES_EXPORT(void)
-_nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top,
-		  NCURSES_SIZE_T const bottom, NCURSES_CH_T blank)
+_nc_scroll_window(WINDOW *win,
+		  int const n,
+		  NCURSES_SIZE_T const top,
+		  NCURSES_SIZE_T const bottom,
+		  NCURSES_CH_T blank)
 {
     int limit;
     int line;
@@ -110,6 +113,22 @@
 	}
     }
     touchline(win, top, bottom - top + 1);
+
+    if_WIDEC({
+	if (WINDOW_EXT(win, addch_used) != 0) {
+	    int next = WINDOW_EXT(win, addch_y) + n;
+	    if (next < 0 || next > win->_maxy) {
+		TR(TRACE_VIRTPUT,
+		   ("Alert discarded multibyte on scroll"));
+		WINDOW_EXT(win, addch_y) = 0;
+	    } else {
+		TR(TRACE_VIRTPUT, ("scrolled working position to %d,%d",
+				   WINDOW_EXT(win, addch_y),
+				   WINDOW_EXT(win, addch_x)));
+		WINDOW_EXT(win, addch_y) = next;
+	    }
+	}
+    })
 }
 
 NCURSES_EXPORT(int)
diff -Naur ncurses-5.4.orig/ncurses/base/lib_set_term.c ncurses-5.4/ncurses/base/lib_set_term.c
--- ncurses-5.4.orig/ncurses/base/lib_set_term.c	2003-11-15 23:57:01.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_set_term.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,7 +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-2003               *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 /*
@@ -44,10 +44,10 @@
 #include <term.h>		/* cur_term */
 #include <tic.h>
 
-MODULE_ID("$Id: lib_set_term.c,v 1.81 2003/11/15 23:57:01 tom Exp $")
+MODULE_ID("$Id: lib_set_term.c,v 1.85 2005/01/22 17:36:01 tom Exp $")
 
 NCURSES_EXPORT(SCREEN *)
-set_term(SCREEN * screenp)
+set_term(SCREEN *screenp)
 {
     SCREEN *oldSP;
 
@@ -81,7 +81,7 @@
  * Free the storage associated with the given SCREEN sp.
  */
 NCURSES_EXPORT(void)
-delscreen(SCREEN * sp)
+delscreen(SCREEN *sp)
 {
     SCREEN **scan = &_nc_screen_chain;
     int i;
@@ -118,6 +118,8 @@
     _nc_free_keytry(sp->_key_ok);
     sp->_key_ok = 0;
 
+    FreeIfNeeded(sp->_current_attr);
+
     FreeIfNeeded(sp->_color_table);
     FreeIfNeeded(sp->_color_pairs);
 
@@ -162,13 +164,13 @@
 #define N_RIPS SIZEOF(SP->_rippedoff)
 
 static bool
-no_mouse_event(SCREEN * sp GCC_UNUSED)
+no_mouse_event(SCREEN *sp GCC_UNUSED)
 {
     return FALSE;
 }
 
 static bool
-no_mouse_inline(SCREEN * sp GCC_UNUSED)
+no_mouse_inline(SCREEN *sp GCC_UNUSED)
 {
     return FALSE;
 }
@@ -180,12 +182,12 @@
 }
 
 static void
-no_mouse_resume(SCREEN * sp GCC_UNUSED)
+no_mouse_resume(SCREEN *sp GCC_UNUSED)
 {
 }
 
 static void
-no_mouse_wrap(SCREEN * sp GCC_UNUSED)
+no_mouse_wrap(SCREEN *sp GCC_UNUSED)
 {
 }
 
@@ -221,9 +223,13 @@
     if (!_nc_alloc_screen())
 	returnCode(ERR);
 
+    T(("created SP %p", SP));
     SP->_next_screen = _nc_screen_chain;
     _nc_screen_chain = SP;
 
+    if ((SP->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0)
+	returnCode(ERR);
+
 #ifdef __DJGPP__
     T(("setting output mode to binary"));
     fflush(output);
@@ -392,9 +398,9 @@
     SP->_screen_acs_fix = (_nc_unicode_locale() && _nc_locale_breaks_acs());
     {
 	char *env = _nc_get_locale();
-	SP->_posix_locale = ((env == 0)
-			     || !strcmp(env, "C")
-			     || !strcmp(env, "POSIX"));
+	SP->_legacy_coding = ((env == 0)
+			      || !strcmp(env, "C")
+			      || !strcmp(env, "POSIX"));
     }
 #endif
 
diff -Naur ncurses-5.4.orig/ncurses/base/lib_slk.c ncurses-5.4/ncurses/base/lib_slk.c
--- ncurses-5.4.orig/ncurses/base/lib_slk.c	2003-05-24 21:10:28.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_slk.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -27,8 +27,12 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *  Authors:                                                                *
+ *          Gerhard Fuernkranz                      1993 (original)         *
+ *          Zeyd M. Ben-Halim                       1992,1995 (sic)         *
+ *          Eric S. Raymond                                                 *
+ *          Juergen Pfeifer                         1996-on                 *
+ *          Thomas E. Dickey                                                *
  ****************************************************************************/
 
 /*
@@ -41,7 +45,7 @@
 #include <ctype.h>
 #include <term.h>		/* num_labels, label_*, plab_norm */
 
-MODULE_ID("$Id: lib_slk.c,v 1.28 2003/05/24 21:10:28 tom Exp $")
+MODULE_ID("$Id: lib_slk.c,v 1.30 2005/01/08 21:56:36 tom Exp $")
 
 /*
  * We'd like to move these into the screen context structure, but cannot,
@@ -109,9 +113,9 @@
      * work.
      */
     if ((no_color_video & 1) == 0)
-	SP->_slk->attr = A_STANDOUT;
+	SetAttr(SP->_slk->attr, A_STANDOUT);
     else
-	SP->_slk->attr = A_REVERSE;
+	SetAttr(SP->_slk->attr, A_REVERSE);
 
     SP->_slk->maxlab = ((num_labels > 0)
 			? num_labels
@@ -131,14 +135,15 @@
 
     max_length = SP->_slk->maxlen;
     for (i = 0; i < SP->_slk->labcnt; i++) {
+	size_t used = max_length + 1;
 
-	if ((SP->_slk->ent[i].ent_text = (char *)_nc_doalloc(0, max_length + 1)) == 0)
+	if ((SP->_slk->ent[i].ent_text = (char *) _nc_doalloc(0, used)) == 0)
 	    returnCode(slk_failed());
-	memset(SP->_slk->ent[i].ent_text, 0, max_length + 1);
+	memset(SP->_slk->ent[i].ent_text, 0, used);
 
-	if ((SP->_slk->ent[i].form_text = (char *)_nc_doalloc(0, max_length + 1)) == 0)
+	if ((SP->_slk->ent[i].form_text = (char *) _nc_doalloc(0, used)) == 0)
 	    returnCode(slk_failed());
-	memset(SP->_slk->ent[i].form_text, 0, max_length + 1);
+	memset(SP->_slk->ent[i].form_text, 0, used);
 
 	memset(SP->_slk->ent[i].form_text, ' ', max_length);
 	SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
diff -Naur ncurses-5.4.orig/ncurses/base/lib_slkatr_set.c ncurses-5.4/ncurses/base/lib_slkatr_set.c
--- ncurses-5.4.orig/ncurses/base/lib_slkatr_set.c	2003-10-25 15:27:03.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_slkatr_set.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -28,27 +28,31 @@
 
 /****************************************************************************
  *  Author:  Juergen Pfeifer, 1998                                          *
+ *     and:  Thomas E. Dickey 2005                                          *
  ****************************************************************************/
 
 /*
  *	lib_slkatr_set.c
  *	Soft key routines.
- *      Set the labels attributes
+ *	Set the label's attributes
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkatr_set.c,v 1.7 2003/10/25 15:27:03 tom Exp $")
+MODULE_ID("$Id: lib_slkatr_set.c,v 1.9 2005/01/08 22:59:37 tom Exp $")
 
 NCURSES_EXPORT(int)
-slk_attr_set
-(const attr_t attr, short color_pair_number, void *opts)
+slk_attr_set(const attr_t attr, short color_pair_number, void *opts)
 {
     T((T_CALLED("slk_attr_set(%s,%d)"), _traceattr(attr), color_pair_number));
 
     if (SP != 0 && SP->_slk != 0 && !opts &&
 	color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) {
-	SP->_slk->attr = attr;
-	toggle_attr_on(SP->_slk->attr, COLOR_PAIR(color_pair_number));
+	TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
+	SetAttr(SP->_slk->attr, attr);
+	if (color_pair_number > 0) {
+	    SetPair(SP->_slk->attr, color_pair_number);
+	}
+	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
 	returnCode(OK);
     } else
 	returnCode(ERR);
diff -Naur ncurses-5.4.orig/ncurses/base/lib_slkatrof.c ncurses-5.4/ncurses/base/lib_slkatrof.c
--- ncurses-5.4.orig/ncurses/base/lib_slkatrof.c	2000-12-10 02:43:27.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_slkatrof.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -27,8 +27,8 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *  Author:  Juergen Pfeifer, 1997                                          *
+ *     and:  Thomas E. Dickey 2005                                          *
  ****************************************************************************/
 
 /*
@@ -38,7 +38,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkatrof.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatrof.c,v 1.8 2005/01/08 23:01:32 tom Exp $")
 
 NCURSES_EXPORT(int)
 slk_attroff(const chtype attr)
@@ -46,7 +46,12 @@
     T((T_CALLED("slk_attroff(%s)"), _traceattr(attr)));
 
     if (SP != 0 && SP->_slk != 0) {
-	toggle_attr_off(SP->_slk->attr, attr);
+	TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
+	RemAttr(SP->_slk->attr, attr);
+	if ((attr & A_COLOR) != 0) {
+	    SetPair(SP->_slk->attr, 0);
+	}
+	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
 	returnCode(OK);
     } else
 	returnCode(ERR);
diff -Naur ncurses-5.4.orig/ncurses/base/lib_slkatron.c ncurses-5.4/ncurses/base/lib_slkatron.c
--- ncurses-5.4.orig/ncurses/base/lib_slkatron.c	2000-12-10 02:43:27.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_slkatron.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -27,8 +27,8 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *  Author:  Juergen Pfeifer, 1997                                          *
+ *     and:  Thomas E. Dickey 2005                                          *
  ****************************************************************************/
 
 /*
@@ -38,7 +38,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkatron.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatron.c,v 1.8 2005/01/08 23:02:01 tom Exp $")
 
 NCURSES_EXPORT(int)
 slk_attron(const chtype attr)
@@ -46,7 +46,12 @@
     T((T_CALLED("slk_attron(%s)"), _traceattr(attr)));
 
     if (SP != 0 && SP->_slk != 0) {
-	toggle_attr_on(SP->_slk->attr, attr);
+	TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
+	AddAttr(SP->_slk->attr, attr);
+	if ((attr & A_COLOR) != 0) {
+	    SetPair(SP->_slk->attr, PAIR_NUMBER(attr));
+	}
+	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
 	returnCode(OK);
     } else
 	returnCode(ERR);
diff -Naur ncurses-5.4.orig/ncurses/base/lib_slkatrset.c ncurses-5.4/ncurses/base/lib_slkatrset.c
--- ncurses-5.4.orig/ncurses/base/lib_slkatrset.c	2000-12-10 02:43:27.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_slkatrset.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -27,8 +27,8 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *  Author:  Juergen Pfeifer, 1997                                          *
+ *     and:  Thomas E. Dickey 2005                                          *
  ****************************************************************************/
 
 /*
@@ -38,7 +38,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkatrset.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkatrset.c,v 1.7 2005/01/08 21:46:47 tom Exp $")
 
 NCURSES_EXPORT(int)
 slk_attrset(const chtype attr)
@@ -46,7 +46,7 @@
     T((T_CALLED("slk_attrset(%s)"), _traceattr(attr)));
 
     if (SP != 0 && SP->_slk != 0) {
-	SP->_slk->attr = attr;
+	SetAttr(SP->_slk->attr, attr);
 	returnCode(OK);
     } else
 	returnCode(ERR);
diff -Naur ncurses-5.4.orig/ncurses/base/lib_slkattr.c ncurses-5.4/ncurses/base/lib_slkattr.c
--- ncurses-5.4.orig/ncurses/base/lib_slkattr.c	2000-12-10 02:43:27.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_slkattr.c	2005-05-13 04:09:50.000000000 +0000
@@ -27,8 +27,8 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *  Author:  Juergen Pfeifer, 1997                                          *
+ *     and:  Thomas E. Dickey 2005                                          *
  ****************************************************************************/
 
 /*
@@ -38,7 +38,7 @@
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkattr.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
+MODULE_ID("$Id: lib_slkattr.c,v 1.6 2005/01/08 21:44:28 tom Exp $")
 
 NCURSES_EXPORT(attr_t)
 slk_attr(void)
@@ -46,7 +46,11 @@
     T((T_CALLED("slk_attr()")));
 
     if (SP != 0 && SP->_slk != 0) {
-	returnAttr(SP->_slk->attr);
+	attr_t result = AttrOf(SP->_slk->attr) & ALL_BUT_COLOR;
+	int pair = GetPair(SP->_slk->attr);
+
+	result |= COLOR_PAIR(pair);
+	returnAttr(result);
     } else
 	returnAttr(0);
 }
diff -Naur ncurses-5.4.orig/ncurses/base/lib_slkcolor.c ncurses-5.4/ncurses/base/lib_slkcolor.c
--- ncurses-5.4.orig/ncurses/base/lib_slkcolor.c	2003-10-25 15:27:03.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_slkcolor.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -28,14 +28,17 @@
 
 /****************************************************************************
  *  Author:  Juergen Pfeifer, 1998                                          *
+ *     and:  Thomas E. Dickey 2005                                          *
  ****************************************************************************/
 
 /*
  *	lib_slkcolor.c
+ *	Soft key routines.
+ *	Set the label's color
  */
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_slkcolor.c,v 1.9 2003/10/25 15:27:03 tom Exp $")
+MODULE_ID("$Id: lib_slkcolor.c,v 1.12 2005/01/28 21:11:53 tom Exp $")
 
 NCURSES_EXPORT(int)
 slk_color(short color_pair_number)
@@ -44,8 +47,9 @@
 
     if (SP != 0 && SP->_slk != 0 &&
 	color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) {
-	T(("... current %ld", (long) PAIR_NUMBER(SP->_slk->attr)));
-	toggle_attr_on(SP->_slk->attr, COLOR_PAIR(color_pair_number));
+	TR(TRACE_ATTRS, ("... current is %s", _tracech_t(CHREF(SP->_slk->attr))));
+	SetPair(SP->_slk->attr, color_pair_number);
+	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
 	returnCode(OK);
     } else
 	returnCode(ERR);
diff -Naur ncurses-5.4.orig/ncurses/base/lib_slkrefr.c ncurses-5.4/ncurses/base/lib_slkrefr.c
--- ncurses-5.4.orig/ncurses/base/lib_slkrefr.c	2003-03-29 22:53:48.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_slkrefr.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,8 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Juergen Pfeifer                         1996-on                 *
+ *     and: Thomas E. Dickey                                                *
  ****************************************************************************/
 
 /*
@@ -38,7 +40,7 @@
 #include <curses.priv.h>
 #include <term.h>		/* num_labels, label_*, plab_norm */
 
-MODULE_ID("$Id: lib_slkrefr.c,v 1.11 2003/03/29 22:53:48 tom Exp $")
+MODULE_ID("$Id: lib_slkrefr.c,v 1.13 2005/01/08 21:46:31 tom Exp $")
 
 /*
  * Write the soft labels to the soft-key window.
@@ -59,10 +61,10 @@
 		    }
 		} else {
 		    wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
-		    if (SP && SP->_slk)
-			wattrset(slk->win, SP->_slk->attr);
-		    waddnstr(slk->win, slk->ent[i].form_text,
-			     MAX_SKEY_LEN(fmt));
+		    if (SP && SP->_slk) {
+			wattrset(slk->win, AttrOf(SP->_slk->attr));
+		    }
+		    waddstr(slk->win, slk->ent[i].form_text);
 		    /* if we simulate SLK's, it's looking much more
 		       natural to use the current ATTRIBUTE also
 		       for the label window */
diff -Naur ncurses-5.4.orig/ncurses/base/lib_slkset.c ncurses-5.4/ncurses/base/lib_slkset.c
--- ncurses-5.4.orig/ncurses/base/lib_slkset.c	2003-04-12 21:32:16.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_slkset.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -27,8 +27,8 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *  Author: Juergen Pfeifer                                                 *
+ *     and: Thomas E. Dickey                                                *
  ****************************************************************************/
 
 /*
@@ -38,14 +38,20 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_slkset.c,v 1.10 2003/04/12 21:32:16 tom Exp $")
+#if USE_WIDEC_SUPPORT
+#include <wctype.h>
+#endif
+
+MODULE_ID("$Id: lib_slkset.c,v 1.15 2005/04/16 17:47:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 slk_set(int i, const char *astr, int format)
 {
     SLK *slk = SP->_slk;
-    size_t len;
     int offset;
+    int numchrs;
+    int numcols;
+    int limit;
     const char *str = astr;
     const char *p;
 
@@ -55,24 +61,53 @@
 	returnCode(ERR);
     if (str == NULL)
 	str = "";
+    --i;			/* Adjust numbering of labels */
 
+    limit = MAX_SKEY_LEN(SP->slk_format);
     while (isspace(UChar(*str)))
 	str++;			/* skip over leading spaces  */
     p = str;
+
+#if USE_WIDEC_SUPPORT
+    numcols = 0;
+    while (*p != 0) {
+	mbstate_t state;
+	wchar_t wc;
+	size_t need;
+
+	init_mb(state);
+	need = mbrtowc(0, p, strlen(p), &state);
+	if (need == (size_t) -1)
+	    break;
+	mbrtowc(&wc, p, need, &state);
+	if (!iswprint((wint_t) wc))
+	    break;
+	if (wcwidth(wc) + numcols > limit)
+	    break;
+	numcols += wcwidth(wc);
+	p += need;
+    }
+    numchrs = (p - str);
+#else
     while (isprint(UChar(*p)))
 	p++;			/* The first non-print stops */
 
-    --i;			/* Adjust numbering of labels */
+    numcols = (p - str);
+    if (numcols > limit)
+	numcols = limit;
+    numchrs = numcols;
+#endif
 
-    len = (size_t) (p - str);
-    if (len > (size_t) slk->maxlen)
-	len = slk->maxlen;
-    if (len == 0)
-	slk->ent[i].ent_text[0] = 0;
-    else
-	strncpy(slk->ent[i].ent_text, str, len)[len] = 0;
-    memset(slk->ent[i].form_text, ' ', (unsigned) slk->maxlen);
-    slk->ent[i].ent_text[slk->maxlen] = 0;
+    FreeIfNeeded(slk->ent[i].ent_text);
+    if ((slk->ent[i].ent_text = strdup(str)) == 0)
+	returnCode(ERR);
+    slk->ent[i].ent_text[numchrs] = '\0';
+
+    if ((slk->ent[i].form_text = (char *) _nc_doalloc(slk->ent[i].form_text,
+						      (unsigned) (limit +
+								  numchrs + 1))
+	) == 0)
+	returnCode(ERR);
 
     switch (format) {
     default:
@@ -80,16 +115,28 @@
 	offset = 0;
 	break;
     case 1:			/* centered */
-	offset = (slk->maxlen - len) / 2;
+	offset = (limit - numcols) / 2;
 	break;
     case 2:			/* right-justified */
-	offset = slk->maxlen - len;
+	offset = limit - numcols;
 	break;
     }
+    if (offset <= 0)
+	offset = 0;
+    else
+	memset(slk->ent[i].form_text, ' ', (unsigned) offset);
+
     memcpy(slk->ent[i].form_text + offset,
 	   slk->ent[i].ent_text,
-	   len);
-    slk->ent[i].form_text[slk->maxlen] = 0;
+	   (unsigned) numchrs);
+
+    if (offset < limit) {
+	memset(slk->ent[i].form_text + offset + numchrs,
+	       ' ',
+	       (unsigned) (limit - (offset + numcols)));
+    }
+
+    slk->ent[i].form_text[numchrs - numcols + limit] = 0;
     slk->ent[i].dirty = TRUE;
     returnCode(OK);
 }
diff -Naur ncurses-5.4.orig/ncurses/base/lib_wattroff.c ncurses-5.4/ncurses/base/lib_wattroff.c
--- ncurses-5.4.orig/ncurses/base/lib_wattroff.c	2002-07-20 17:07:16.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_wattroff.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -41,14 +42,18 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_wattroff.c,v 1.7 2002/07/20 17:07:16 tom Exp $")
+MODULE_ID("$Id: lib_wattroff.c,v 1.8 2005/01/29 21:20:03 tom Exp $")
 
 NCURSES_EXPORT(int)
 wattr_off(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
 {
     T((T_CALLED("wattr_off(%p,%s)"), win, _traceattr(at)));
     if (win) {
-	T(("... current %s", _traceattr(win->_attrs)));
+	T(("... current %s (%d)", _traceattr(win->_attrs), GET_WINDOW_PAIR(win)));
+	if_EXT_COLORS({
+	    if (at & A_COLOR)
+		win->_color = 0;
+	});
 	toggle_attr_off(win->_attrs, at);
 	returnCode(OK);
     } else
diff -Naur ncurses-5.4.orig/ncurses/base/lib_wattron.c ncurses-5.4/ncurses/base/lib_wattron.c
--- ncurses-5.4.orig/ncurses/base/lib_wattron.c	2002-07-20 17:07:16.000000000 +0000
+++ ncurses-5.4/ncurses/base/lib_wattron.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -41,14 +42,18 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_wattron.c,v 1.7 2002/07/20 17:07:16 tom Exp $")
+MODULE_ID("$Id: lib_wattron.c,v 1.8 2005/01/29 21:23:08 tom Exp $")
 
 NCURSES_EXPORT(int)
 wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
 {
     T((T_CALLED("wattr_on(%p,%s)"), win, _traceattr(at)));
-    if (win) {
-	T(("... current %s", _traceattr(win->_attrs)));
+    if (win != 0) {
+	T(("... current %s (%d)", _traceattr(win->_attrs), GET_WINDOW_PAIR(win)));
+	if_EXT_COLORS({
+	    if (at & A_COLOR)
+		win->_color = PAIR_NUMBER(at);
+	});
 	toggle_attr_on(win->_attrs, at);
 	returnCode(OK);
     } else
diff -Naur ncurses-5.4.orig/ncurses/base/resizeterm.c ncurses-5.4/ncurses/base/resizeterm.c
--- ncurses-5.4.orig/ncurses/base/resizeterm.c	2002-12-28 01:21:34.000000000 +0000
+++ ncurses-5.4/ncurses/base/resizeterm.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2002,2004 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,18 +41,40 @@
 #include <curses.priv.h>
 #include <term.h>
 
-MODULE_ID("$Id: resizeterm.c,v 1.15 2002/12/28 01:21:34 tom Exp $")
+MODULE_ID("$Id: resizeterm.c,v 1.17 2004/07/31 20:24:38 tom Exp $")
 
 #define stolen_lines (screen_lines - SP->_lines_avail)
 
 static int current_lines;
 static int current_cols;
 
+#ifdef TRACE
+static void
+show_window_sizes(const char *name)
+{
+    WINDOWLIST *wp;
+
+    _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS,
+	    screen_lines, screen_columns);
+    for (wp = _nc_windows; wp != 0; wp = wp->next) {
+	_tracef("  window %p is %2d x %2d at %2d,%2d",
+		&(wp->win),
+		wp->win._maxy + 1,
+		wp->win._maxx + 1,
+		wp->win._begy,
+		wp->win._begx);
+    }
+}
+#endif
+
 NCURSES_EXPORT(bool)
 is_term_resized(int ToLines, int ToCols)
 {
-    return (ToLines != screen_lines
-	    || ToCols != screen_columns);
+    T((T_CALLED("is_term_resized(%d, %d)"), ToLines, ToCols));
+    returnCode(ToLines > 0
+	       && ToCols > 0
+	       && (ToLines != screen_lines
+		   || ToCols != screen_columns));
 }
 
 /*
@@ -162,6 +184,7 @@
 
 	    if (!(win->_flags & _ISPAD)) {
 		if (child_depth(win) == depth) {
+		    found = TRUE;
 		    if (adjust_window(win, ToLines, ToCols, stolen) != OK)
 			returnCode(ERR);
 		}
@@ -194,6 +217,7 @@
 
 	    if (!(win->_flags & _ISPAD)) {
 		if (parent_depth(win) == depth) {
+		    found = TRUE;
 		    if (adjust_window(win, ToLines, ToCols, stolen) != OK)
 			returnCode(ERR);
 		}
@@ -222,6 +246,10 @@
 	int myLines = current_lines = screen_lines;
 	int myCols = current_cols = screen_columns;
 
+#ifdef TRACE
+	if (_nc_tracing & TRACE_UPDATE)
+	    show_window_sizes("before");
+#endif
 	if (ToLines > screen_lines) {
 	    increase_size(myLines = ToLines, myCols, was_stolen);
 	    current_lines = myLines;
@@ -250,6 +278,13 @@
 	if (SP->newhash) {
 	    FreeAndNull(SP->newhash);
 	}
+#ifdef TRACE
+	if (_nc_tracing & TRACE_UPDATE) {
+	    LINES = ToLines - was_stolen;
+	    COLS = ToCols;
+	    show_window_sizes("after");
+	}
+#endif
     }
 
     /*
diff -Naur ncurses-5.4.orig/ncurses/base/tries.c ncurses-5.4/ncurses/base/tries.c
--- ncurses-5.4.orig/ncurses/base/tries.c	2003-05-17 23:11:24.000000000 +0000
+++ ncurses-5.4/ncurses/base/tries.c	2005-05-13 04:09:58.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: tries.c,v 1.19 2003/05/17 23:11:24 tom Exp $")
+MODULE_ID("$Id: tries.c,v 1.20 2005/04/30 19:14:18 tom Exp $")
 
 /*
  * Expand a keycode into the string that it corresponds to, returning null if
@@ -71,7 +71,7 @@
 	if ((result[len] = ptr->ch) == 0)
 	    *((unsigned char *) (result + len)) = 128;
 #ifdef TRACE
-	if (len == 0)
+	if (len == 0 && _nc_tracing != 0)
 	    _tracef("expand_key %s %s", _tracechar(code), _nc_visbuf(result));
 #endif
     }
diff -Naur ncurses-5.4.orig/ncurses/base/version.c ncurses-5.4/ncurses/base/version.c
--- ncurses-5.4.orig/ncurses/base/version.c	2004-01-10 21:18:17.000000000 +0000
+++ ncurses-5.4/ncurses/base/version.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999-2000,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2004,2005 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,11 +32,11 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: version.c,v 1.5 2004/01/10 21:18:17 tom Exp $")
+MODULE_ID("$Id: version.c,v 1.6 2005/01/02 01:23:54 tom Exp $")
 
 NCURSES_EXPORT(const char *)
 curses_version(void)
 {
     T((T_CALLED("curses_version()")));
-    returnPtr("ncurses " NCURSES_VERSION_STRING);
+    returnCPtr("ncurses " NCURSES_VERSION_STRING);
 }
diff -Naur ncurses-5.4.orig/ncurses/base/vsscanf.c ncurses-5.4/ncurses/base/vsscanf.c
--- ncurses-5.4.orig/ncurses/base/vsscanf.c	2003-05-24 21:10:28.000000000 +0000
+++ ncurses-5.4/ncurses/base/vsscanf.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -38,7 +38,7 @@
 
 #if !HAVE_VSSCANF
 
-MODULE_ID("$Id: vsscanf.c,v 1.17 2003/05/24 21:10:28 tom Exp $")
+MODULE_ID("$Id: vsscanf.c,v 1.18 2004/04/03 20:27:02 tom Exp $")
 
 #if !(HAVE_VFSCANF || HAVE__DOSCAN)
 
@@ -271,7 +271,7 @@
 				chunk = ctest;
 			    } else if ((otest = other_ch(format[n])) != oUnknown) {
 				other = otest;
-			    } else if (isalpha(format[n])) {
+			    } else if (isalpha(UChar(format[n]))) {
 				state = sFinal;
 				chunk = cError;
 			    }
diff -Naur ncurses-5.4.orig/ncurses/curses.priv.h ncurses-5.4/ncurses/curses.priv.h
--- ncurses-5.4.orig/ncurses/curses.priv.h	2004-02-01 01:05:58.000000000 +0000
+++ ncurses-5.4/ncurses/curses.priv.h	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,12 +29,12 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Thomas E. Dickey 1996-2002                                      *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 
 /*
- * $Id: curses.priv.h,v 1.255 2004/02/01 01:05:58 Stanislav.Ievlev Exp $
+ * $Id: curses.priv.h,v 1.282 2005/04/16 17:09:26 tom Exp $
  *
  *	curses.priv.h
  *
@@ -78,6 +78,11 @@
 # include <sys/param.h>
 #endif
 
+#include <assert.h>
+#include <stdio.h>
+
+#include <errno.h>
+
 #ifndef PATH_MAX
 # if defined(_POSIX_PATH_MAX)
 #  define PATH_MAX _POSIX_PATH_MAX
@@ -88,11 +93,6 @@
 # endif
 #endif
 
-#include <assert.h>
-#include <stdio.h>
-
-#include <errno.h>
-
 #if DECL_ERRNO
 extern int errno;
 #endif
@@ -210,14 +210,6 @@
 };
 
 /*
- * Definitions for color pairs
- */
-#define C_SHIFT 8		/* we need more bits than there are colors */
-#define C_MASK  ((1 << C_SHIFT) - 1)
-
-#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
-
-/*
  * Common/troublesome character definitions
  */
 #define L_BRACE '{'
@@ -259,6 +251,46 @@
 #include <curses.h>	/* we'll use -Ipath directive to get the right one! */
 #include <term.h>
 
+#if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT
+#define if_EXT_COLORS(stmt)	stmt
+#define NetPair(value,p)	(value).ext_color = (p), \
+				AttrOf(value) &= ALL_BUT_COLOR, \
+				AttrOf(value) |= (A_COLOR & COLOR_PAIR((p > 255) ? 255 : p))
+#define SetPair(value,p)	(value).ext_color = (p)
+#define GetPair(value)		(value).ext_color
+#define unColor(n)		(AttrOf(n) & ALL_BUT_COLOR)
+#define GET_WINDOW_PAIR(w)	(w)->_color
+#define SET_WINDOW_PAIR(w,p)	(w)->_color = (p)
+#define SameAttrOf(a,b)		(AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))
+#define VIDATTR(attr, pair)	vid_attr(attr, pair, 0)
+#else
+#define if_EXT_COLORS(stmt)	/* nothing */
+#define SetPair(value,p)	RemAttr(value, A_COLOR), \
+				SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p)))
+#define GetPair(value)		PAIR_NUMBER(AttrOf(value))
+#define unColor(n)		(AttrOf(n) & ALL_BUT_COLOR)
+#define GET_WINDOW_PAIR(w)	PAIR_NUMBER((w)->_attrs)
+#define SET_WINDOW_PAIR(w,p)	(w)->_attrs &= ALL_BUT_COLOR, \
+				(w)->_attrs |= (A_COLOR & COLOR_PAIR(p))
+#define SameAttrOf(a,b)		(AttrOf(a) == AttrOf(b))
+#define VIDATTR(attr, pair)	vidattr(attr)
+#endif
+
+#define SCREEN_ATTRS(s)		(*((s)->_current_attr))
+#define GET_SCREEN_PAIR(s)	GetPair(SCREEN_ATTRS(s))
+#define SET_SCREEN_PAIR(s,p)	SetPair(SCREEN_ATTRS(s), p)
+
+/*
+ * Definitions for color pairs
+ */
+typedef unsigned colorpair_t;	/* type big enough to store PAIR_OF() */
+#define C_SHIFT 9		/* we need more bits than there are colors */
+#define C_MASK			((1 << C_SHIFT) - 1)
+#define PAIR_OF(fg, bg)		((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
+#define isDefaultColor(c)	((c) >= COLOR_DEFAULT || (c) < 0)
+
+#define COLOR_DEFAULT		C_MASK
+
 struct ldat
 {
 	NCURSES_CH_T	*text;		/* text of the line */
@@ -279,9 +311,28 @@
 } MouseType;
 
 /*
- * Structure for soft labels.
+ * Structures for scrolling.
+ */
+
+typedef struct {
+	unsigned long hashval;
+	int oldcount, newcount;
+	int oldindex, newindex;
+} HASHMAP;
+
+/*
+ * Structures for soft labels.
  */
 
+struct _SLK;
+
+#ifdef USE_TERMLIB
+
+#undef NCURSES_CH_T		/* this is not a termlib feature */
+#define NCURSES_CH_T void	/* ...but we need a pointer in SCREEN */
+
+#else
+
 typedef struct
 {
 	char *ent_text;         /* text for the label */
@@ -291,7 +342,7 @@
 	char visible;           /* field is visible */
 } slk_ent;
 
-typedef struct {
+typedef struct _SLK {
 	char dirty;             /* all labels have changed */
 	char hidden;            /* soft labels are hidden */
 	WINDOW *win;
@@ -299,14 +350,10 @@
 	short  maxlab;          /* number of available labels */
 	short  labcnt;          /* number of allocated labels */
 	short  maxlen;          /* length of labels */
-	chtype attr;            /* soft label attribute */
+	NCURSES_CH_T attr;      /* soft label attribute */
 } SLK;
 
-typedef struct {
-	unsigned long hashval;
-	int oldcount, newcount;
-	int oldindex, newindex;
-} HASHMAP;
+#endif
 
 typedef	struct {
 	int	line;           /* lines to take, < 0 => from bottom*/
@@ -314,6 +361,10 @@
 	WINDOW *w;              /* maybe we need this for cleanup   */
 } ripoff_t;
 
+/*
+ * The SCREEN structure.
+ */
+
 struct screen {
 	int             _ifd;           /* input file ptr for screen        */
 	FILE            *_ofp;          /* output file ptr for screen       */
@@ -339,14 +390,14 @@
 	bool            _keypad_on;     /* keypad mode is currently on      */
 
 	bool		_called_wgetch;	/* check for recursion in wgetch()  */
-	int    	        _fifo[FIFO_SIZE];       /* input push-back buffer   */
+	int		_fifo[FIFO_SIZE];	/* input push-back buffer   */
 	short           _fifohead,      /* head of fifo queue               */
 	                _fifotail,      /* tail of fifo queue               */
 	                _fifopeek,      /* where to peek for next char      */
 	                _fifohold;      /* set if breakout marked           */
 
 	int             _endwin;        /* are we out of window mode?       */
-	attr_t          _current_attr;  /* terminal attribute current set   */
+	NCURSES_CH_T	*_current_attr; /* holds current attributes set     */
 	int             _coloron;       /* is color enabled?                */
 	int		_color_defs;	/* are colors modified		    */
 	int             _cursor;        /* visibility of the cursor         */
@@ -359,7 +410,7 @@
 	                                /* > 1 if in halfdelay mode         */
 	int             _echo;          /* True if echo on                  */
 	int             _use_meta;      /* use the meta key?                */
-	SLK             *_slk;          /* ptr to soft key struct / NULL    */
+	struct _SLK     *_slk;          /* ptr to soft key struct / NULL    */
         int             slk_format;     /* selected format for this screen  */
 	/* cursor movement costs; units are 10ths of milliseconds */
 #if NCURSES_NO_PADDING
@@ -409,7 +460,7 @@
 	/* used in lib_color.c */
 	color_t         *_color_table;  /* screen's color palette            */
 	int             _color_count;   /* count of colors in palette        */
-	unsigned short  *_color_pairs;  /* screen's color pair list          */
+	colorpair_t     *_color_pairs;  /* screen's color pair list          */
 	int             _pair_count;    /* count of color pairs              */
 #if NCURSES_EXT_FUNCS
 	bool            _default_color; /* use default colors                */
@@ -483,7 +534,7 @@
 
 	/* hashes for old and new lines */
 	unsigned long	*oldhash, *newhash;
-	HASHMAP 	*hashtab;
+	HASHMAP		*hashtab;
 	int		hashtab_len;
 
 	bool            _cleanup;	/* cleanup after int/quit signal */
@@ -493,9 +544,10 @@
 	 * UTF-8, but do not permit ACS at the same time (see tty_update.c).
 	 */
 #if USE_WIDEC_SUPPORT
-	bool		_posix_locale;
+	bool		_legacy_coding;
 	bool		_screen_acs_fix;
 #endif
+	bool		_screen_acs_map[ACS_LEN];
 };
 
 extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
@@ -509,17 +561,25 @@
 	WINDOWLIST *next;
 #ifdef _XOPEN_SOURCE_EXTENDED
 	char addch_work[(MB_LEN_MAX * 9) + 1];
-	int addch_used;
-	int addch_x;
-	int addch_y;
+	unsigned addch_used;	/* number of bytes in addch_work[] */
+	int addch_x;		/* x-position for addch_work[] */
+	int addch_y;		/* y-position for addch_work[] */
 #endif
 };
 
 #define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
 
+/* usually in <limits.h> */
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+
 /* The terminfo source is assumed to be 7-bit ASCII */
 #define is7bits(c)	((unsigned)(c) < 128)
 
+/* Checks for isprint() should be done on 8-bit characters (non-wide) */
+#define is8bits(c)	((unsigned)(c) <= UCHAR_MAX)
+
 #ifndef min
 #define min(a,b)	((a) > (b)  ?  (b)  :  (a))
 #endif
@@ -585,18 +645,31 @@
 #endif
 
 #if USE_WIDEC_SUPPORT /* { */
+#define isEILSEQ(status) ((status == (size_t)-1) && (errno == EILSEQ))
+
+#define init_mb(state)	memset(&state, 0, sizeof(state))
+
+#if NCURSES_EXT_COLORS
+#define NulColor	, 0
+#else
+#define NulColor	/* nothing */
+#endif
+
 #define NulChar		0,0,0,0	/* FIXME: see CCHARW_MAX */
 #define CharOf(c)	((c).chars[0])
 #define AttrOf(c)	((c).attr)
-#define AddAttr(c,a)	(c).attr |= a
-#define RemAttr(c,a)	(c).attr &= ~(a)
-#define SetAttr(c,a)	(c).attr = a
-#define NewChar(ch)	{ ChAttrOf(ch), { ChCharOf(ch), NulChar } }
-#define NewChar2(c,a)	{ a, { c, NulChar } }
+#define AddAttr(c,a)	AttrOf(c) |= a
+#define RemAttr(c,a)	AttrOf(c) &= ~(a)
+#define SetAttr(c,a)	AttrOf(c) = a
+#define NewChar(ch)	{ ChAttrOf(ch), { ChCharOf(ch), NulChar } NulColor }
+#define NewChar2(c,a)	{ a, { c, NulChar } NulColor }
 #define CharEq(a,b)	(!memcmp(&a, &b, sizeof(a)))
-#define SetChar(ch,c,a)	do { 							    \
+#define SetChar(ch,c,a) do {							    \
 			    NCURSES_CH_T *_cp = &ch;				    \
-			    memset(_cp,0,sizeof(ch)); _cp->chars[0] = c; _cp->attr = a; \
+			    memset(_cp, 0, sizeof(ch));				    \
+			    _cp->chars[0] = c;					    \
+			    _cp->attr = a;					    \
+			    if_EXT_COLORS(SetPair(ch, PAIR_NUMBER(a)));		    \
 			} while (0)
 #define CHREF(wch)	(&wch)
 #define CHDEREF(wch)	(*wch)
@@ -604,9 +677,9 @@
 #define CARG_CH_T	const NCURSES_CH_T *
 #define PUTC_DATA	char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
 			mbstate_t PUT_st; wchar_t PUTC_ch
-#define PUTC_INIT	memset (&PUT_st, '\0', sizeof (PUT_st));		    \
+#define PUTC_INIT	init_mb (PUT_st);					    \
 			PUTC_i = 0
-#define PUTC(ch,b)	do { if(!isnac(ch)) { 					    \
+#define PUTC(ch,b)	do { if(!isWidecExt(ch)) {				    \
 			if (Charable(ch)) {					    \
 			    fputc(CharOf(ch), b);				    \
 			    TRACE_OUTCHARS(1);					    \
@@ -627,14 +700,27 @@
 			    TRACE_OUTCHARS(PUTC_i);				    \
 			} } } while (0)
 
-#define BLANK		{ WA_NORMAL, ' ' }
+#define BLANK		{ WA_NORMAL, {' '} NulColor }
+#define ZEROS		{ WA_NORMAL, {'\0'} NulColor }
 #define ISBLANK(ch)	((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
 
-#define WA_NAC		1
-#define isnac(ch)	(AttrOf(ch) & WA_NAC)
+	/*
+	 * Wide characters cannot be represented in the A_CHARTEXT mask of
+	 * attr_t's but an application might have set a narrow character there.
+	 * But even in that case, it would only be a printable character, or
+	 * zero.  Otherwise we can use those bits to tell if a cell is the
+	 * first or extension part of a wide character.
+	 */
+#define WidecExt(ch)	(AttrOf(ch) & A_CHARTEXT)
+#define isWidecBase(ch)	(WidecExt(ch) == 1)
+#define isWidecExt(ch)	(WidecExt(ch) > 1 && WidecExt(ch) < 32)
+#define SetWidecExt(dst, ext)	AttrOf(dst) &= ~A_CHARTEXT,		\
+				AttrOf(dst) |= (ext + 1)
+
 #define if_WIDEC(code)  code
-#define Charable(ch)	((SP != 0 && SP->_posix_locale)			\
-			 || (!isnac(ch) &&				\
+#define Charable(ch)	((SP != 0 && SP->_legacy_coding)		\
+			 || (AttrOf(ch) & A_ALTCHARSET)			\
+			 || (!isWidecExt(ch) &&				\
 			     (ch).chars[1] == L'\0' &&			\
                              _nc_is_charable(CharOf(ch))))
 
@@ -657,9 +743,10 @@
 #define PUTC(a,b)	do { data = CharOf(ch); putc(data,b); } while (0)
 
 #define BLANK		(' '|A_NORMAL)
+#define ZEROS		('\0'|A_NORMAL)
 #define ISBLANK(ch)	(CharOf(ch) == ' ')
 
-#define isnac(ch)	(0)
+#define isWidecExt(ch)	(0)
 #define if_WIDEC(code) /* nothing */
 
 #define L(ch)		ch
@@ -674,6 +761,11 @@
 
 #define CHANGED     -1
 
+#define LEGALYX(w, y, x) \
+	      ((w) != 0 && \
+		((x) >= 0 && (x) <= (w)->_maxx && \
+		 (y) >= 0 && (y) <= (w)->_maxy))
+
 #define CHANGED_CELL(line,col) \
 	if (line->firstchar == _NOCHANGE) \
 		line->firstchar = line->lastchar = col; \
@@ -730,17 +822,21 @@
 #define TPUTS_TRACE(s)	_nc_tputs_trace = s;
 #define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
 
-#define returnAttr(code) TRACE_RETURN(code,attr_t)
-#define returnChar(code) TRACE_RETURN(code,chtype)
-#define returnBool(code) TRACE_RETURN(code,bool)
-#define returnBits(code) TRACE_RETURN(code,unsigned)
-#define returnCode(code) TRACE_RETURN(code,int)
-#define returnPtr(code)  TRACE_RETURN(code,ptr)
-#define returnSP(code)   TRACE_RETURN(code,sp)
-#define returnVoid       T((T_RETURN(""))); return
-#define returnWin(code)  TRACE_RETURN(code,win)
+#define returnAttr(code)	TRACE_RETURN(code,attr_t)
+#define returnBits(code)	TRACE_RETURN(code,unsigned)
+#define returnBool(code)	TRACE_RETURN(code,bool)
+#define returnCPtr(code)	TRACE_RETURN(code,cptr)
+#define returnCVoidPtr(code)	TRACE_RETURN(code,cvoid_ptr)
+#define returnChar(code)	TRACE_RETURN(code,chtype)
+#define returnCode(code)	TRACE_RETURN(code,int)
+#define returnPtr(code)		TRACE_RETURN(code,ptr)
+#define returnSP(code)		TRACE_RETURN(code,sp)
+#define returnVoid		T((T_RETURN(""))); return
+#define returnVoidPtr(code)	TRACE_RETURN(code,void_ptr)
+#define returnWin(code)		TRACE_RETURN(code,win)
 
 extern NCURSES_EXPORT(NCURSES_BOOL)     _nc_retrace_bool (NCURSES_BOOL);
+extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
 extern NCURSES_EXPORT(SCREEN *)         _nc_retrace_sp (SCREEN *);
 extern NCURSES_EXPORT(WINDOW *)         _nc_retrace_win (WINDOW *);
 extern NCURSES_EXPORT(attr_t)           _nc_retrace_attr_t (attr_t);
@@ -749,8 +845,10 @@
 extern NCURSES_EXPORT(char *)           _nc_varargs (const char *, va_list);
 extern NCURSES_EXPORT(chtype)           _nc_retrace_chtype (chtype);
 extern NCURSES_EXPORT(const char *)     _nc_altcharset_name(attr_t, chtype);
+extern NCURSES_EXPORT(const char *)     _nc_retrace_cptr (const char *);
 extern NCURSES_EXPORT(int)              _nc_retrace_int (int);
 extern NCURSES_EXPORT(unsigned)         _nc_retrace_unsigned (unsigned);
+extern NCURSES_EXPORT(void *)           _nc_retrace_void_ptr (void *);
 extern NCURSES_EXPORT(void)             _nc_fifo_dump (void);
 extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
 extern NCURSES_EXPORT_VAR(long)         _nc_outchars;
@@ -771,15 +869,18 @@
 #define TR(n, a)
 #define TPUTS_TRACE(s)
 
-#define returnAttr(code) return code
-#define returnBits(code) return code
-#define returnBool(code) return code
-#define returnChar(code) return code
-#define returnCode(code) return code
-#define returnPtr(code)  return code
-#define returnSP(code)   return code
-#define returnVoid       return
-#define returnWin(code)  return code
+#define returnAttr(code)	return code
+#define returnBits(code)	return code
+#define returnBool(code)	return code
+#define returnCPtr(code)	return code
+#define returnCVoidPtr(code)	return code
+#define returnChar(code)	return code
+#define returnCode(code)	return code
+#define returnPtr(code)		return code
+#define returnSP(code)		return code
+#define returnVoid		return
+#define returnVoidPtr(code)	return code
+#define returnWin(code)		return code
 
 #endif /* TRACE/!TRACE */
 
@@ -791,29 +892,23 @@
 	NCURSES_EXPORT(void) name (void) { }
 
 #define ALL_BUT_COLOR ((chtype)~(A_COLOR))
-#define IGNORE_COLOR_OFF FALSE
 #define NONBLANK_ATTR (A_NORMAL|A_BOLD|A_DIM|A_BLINK)
 #define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
 
 #define toggle_attr_on(S,at) {\
-   if (PAIR_NUMBER(at) > 0)\
+   if (PAIR_NUMBER(at) > 0) {\
       (S) = ((S) & ALL_BUT_COLOR) | (at);\
-   else\
+   } else {\
       (S) |= (at);\
+   }\
    TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
 
 
 #define toggle_attr_off(S,at) {\
-   if (IGNORE_COLOR_OFF == TRUE) {\
-      if (PAIR_NUMBER(at) == 0xff) /* turn off color */\
-	 (S) &= ~(at);\
-      else /* leave color alone */\
-	 (S) &= ~((at)&ALL_BUT_COLOR);\
+   if (PAIR_NUMBER(at) > 0) {\
+      (S) &= ~(at|A_COLOR);\
    } else {\
-      if (PAIR_NUMBER(at) > 0x00) /* turn off color */\
-	 (S) &= ~(at|A_COLOR);\
-      else /* leave color alone */\
-	 (S) &= ~(at);\
+      (S) &= ~(at);\
    }\
    TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
 
@@ -834,11 +929,11 @@
 		    : INFINITY)))
 
 #if USE_XMC_SUPPORT
-#define UpdateAttrs(a)	if (SP->_current_attr != (a)) { \
-				attr_t chg = SP->_current_attr; \
-				vidattr((a)); \
+#define UpdateAttrs(c)	if (!SameAttrOf(SCREEN_ATTRS(SP), c)) { \
+				attr_t chg = AttrOf(SCREEN_ATTRS(SP)); \
+				VIDATTR(AttrOf(c), GetPair(c)); \
 				if (magic_cookie_glitch > 0 \
-				 && XMC_CHANGES((chg ^ SP->_current_attr))) { \
+				 && XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(SP))))) { \
 					T(("%s @%d before glitch %d,%d", \
 						__FILE__, __LINE__, \
 						SP->_cursrow, \
@@ -847,8 +942,8 @@
 				} \
 			}
 #else
-#define UpdateAttrs(a)	if (SP->_current_attr != (a)) \
-				vidattr((a));
+#define UpdateAttrs(c)	if (!SameAttrOf(SCREEN_ATTRS(SP), c)) \
+				VIDATTR(AttrOf(c), GetPair(c));
 #endif
 
 /*
@@ -884,7 +979,7 @@
 
 #undef  UpdateAttrs
 #define UpdateAttrs(c) _nc_UpdateAttrs(c)
-extern NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype);
+extern NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T);
 
 #else
 
@@ -917,6 +1012,11 @@
 extern NCURSES_EXPORT(void) _nc_init_acs (void);	/* corresponds to traditional 'init_acs()' */
 extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int);  /* used by 'tack' program */
 
+/* lib_addch.c */
+#if USE_WIDEC_SUPPORT
+NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
+#endif
+
 /* lib_addstr.c */
 #if USE_WIDEC_SUPPORT
 extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *);
@@ -929,7 +1029,7 @@
 extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *));
 
 /* lib_insch.c */
-extern NCURSES_EXPORT(void) _nc_insert_ch(WINDOW *, chtype);
+extern NCURSES_EXPORT(int) _nc_insert_ch(WINDOW *, chtype);
 
 /* lib_mvcur.c */
 #define INFINITY	1000000	/* cost: too high to use */
@@ -955,6 +1055,7 @@
 extern NCURSES_EXPORT(char *) _nc_get_locale(void);
 extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
 extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(void);
+extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int , int *, bool);
 
 /* lib_wacs.c */
 #if USE_WIDEC_SUPPORT
@@ -975,16 +1076,6 @@
 extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
 extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
 
-extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
-extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
-extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
-
-extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
-
-extern NCURSES_EXPORT(void) _nc_screen_init (void);
-extern NCURSES_EXPORT(void) _nc_screen_resume (void);
-extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
-
 #if !HAVE_STRSTR
 #define strstr _nc_strstr
 extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *);
@@ -1000,7 +1091,6 @@
 extern NCURSES_EXPORT(int) _nc_remove_string (struct tries **, const char *);
 
 /* elsewhere ... */
-extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
 extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
 extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
 extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
@@ -1014,7 +1104,6 @@
 extern NCURSES_EXPORT(int) _nc_outch (int);
 extern NCURSES_EXPORT(int) _nc_setupscreen (short, short const, FILE *);
 extern NCURSES_EXPORT(int) _nc_timed_wait(int, int, int * EVENTLIST_2nd(_nc_eventlist *));
-extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
 extern NCURSES_EXPORT(void) _nc_do_color (int, int, bool, int (*)(int));
 extern NCURSES_EXPORT(void) _nc_flush (void);
 extern NCURSES_EXPORT(void) _nc_freeall (void);
@@ -1024,12 +1113,25 @@
 extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
 extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
 extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
-extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, short const, short const, NCURSES_CH_T);
 extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, bool);
 extern NCURSES_EXPORT(void) _nc_signal_handler (bool);
 extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
 extern NCURSES_EXPORT(void) _nc_trace_tries (struct tries *);
 
+#ifndef USE_TERMLIB
+extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
+extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
+extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, short const, short const, NCURSES_CH_T);
+#endif
+
+#if USE_WIDEC_SUPPORT
+#ifdef linux
+extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *);
+#else
+#define _nc_wcrtomb(s,wc,ps) wcrtomb(s,wc,ps)
+#endif
+#endif
+
 #if USE_SIZECHANGE
 extern NCURSES_EXPORT(void) _nc_update_screensize (void);
 #endif
diff -Naur ncurses-5.4.orig/ncurses/llib-lncurses ncurses-5.4/ncurses/llib-lncurses
--- ncurses-5.4.orig/ncurses/llib-lncurses	2004-01-31 16:16:48.000000000 +0000
+++ ncurses-5.4/ncurses/llib-lncurses	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey 1996-2003,2004                                 *
+ *  Author: Thomas E. Dickey 1996-2004,2005                                 *
  ****************************************************************************/
 /* LINTLIBRARY */
 
@@ -48,6 +48,8 @@
 
 /* ./tty/hashmap.c */
 
+#include <term.h>
+
 #undef _nc_hash_map
 void	_nc_hash_map(void)
 		{ /* void */ }
@@ -59,8 +61,8 @@
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n,
-		int	top,
+		int	n, 
+		int	top, 
 		int	bot)
 		{ /* void */ }
 
@@ -70,25 +72,25 @@
 
 #undef _nc_render
 chtype	_nc_render(
-		WINDOW	*win,
+		WINDOW	*win, 
 		chtype	ch)
 		{ return(*(chtype *)0); }
 
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const chtype c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -96,15 +98,15 @@
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win,
-		const char *astr,
+		WINDOW	*win, 
+		const char *astr, 
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win,
-		const chtype *astr,
+		WINDOW	*win, 
+		const chtype *astr, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -118,13 +120,13 @@
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win,
+		WINDOW	*win, 
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win,
+		WINDOW	*win, 
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -132,14 +134,14 @@
 
 #undef wborder
 int	wborder(
-		WINDOW	*win,
-		chtype	ls,
-		chtype	rs,
-		chtype	ts,
-		chtype	bs,
-		chtype	tl,
-		chtype	tr,
-		chtype	bl,
+		WINDOW	*win, 
+		chtype	ls, 
+		chtype	rs, 
+		chtype	ts, 
+		chtype	bs, 
+		chtype	tl, 
+		chtype	tr, 
+		chtype	bl, 
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -147,10 +149,10 @@
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win,
-		int	n,
-		attr_t	attr,
-		short	color,
+		WINDOW	*win, 
+		int	n, 
+		attr_t	attr, 
+		short	color, 
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -165,7 +167,7 @@
 
 #undef clearok
 int	clearok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -202,16 +204,16 @@
 
 #undef init_pair
 int	init_pair(
-		short	pair,
-		short	f,
+		short	pair, 
+		short	f, 
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color,
-		short	r,
-		short	g,
+		short	color, 
+		short	r, 
+		short	g, 
 		short	b)
 		{ return(*(int *)0); }
 
@@ -225,24 +227,24 @@
 
 #undef color_content
 int	color_content(
-		short	color,
-		short	*r,
-		short	*g,
+		short	color, 
+		short	*r, 
+		short	*g, 
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair,
-		short	*f,
+		short	pair, 
+		short	*f, 
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair,
-		int	pair,
-		NCURSES_BOOL reverse,
+		int	old_pair, 
+		int	pair, 
+		NCURSES_BOOL reverse, 
 		int	(*outc)(
 		int	p1))
 		{ /* void */ }
@@ -251,8 +253,8 @@
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win,
-		short	color_pair_number,
+		WINDOW	*win, 
+		short	color_pair_number, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -308,7 +310,7 @@
 
 #undef addchnstr
 int	addchnstr(
-		const chtype *a1,
+		const chtype *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -319,7 +321,7 @@
 
 #undef addnstr
 int	addnstr(
-		const char *a1,
+		const char *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -345,27 +347,27 @@
 
 #undef attr_get
 int	attr_get(
-		attr_t	*a1,
-		short	*a2,
+		attr_t	*a1, 
+		short	*a2, 
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
 int	attr_off(
-		attr_t	a1,
+		attr_t	a1, 
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
 int	attr_on(
-		attr_t	a1,
+		attr_t	a1, 
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
 int	attr_set(
-		attr_t	a1,
-		short	a2,
+		attr_t	a1, 
+		short	a2, 
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -381,28 +383,28 @@
 
 #undef border
 int	border(
-		chtype	a1,
-		chtype	a2,
-		chtype	a3,
-		chtype	a4,
-		chtype	a5,
-		chtype	a6,
-		chtype	a7,
+		chtype	a1, 
+		chtype	a2, 
+		chtype	a3, 
+		chtype	a4, 
+		chtype	a5, 
+		chtype	a6, 
+		chtype	a7, 
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
 int	box(
-		WINDOW	*a1,
-		chtype	a2,
+		WINDOW	*a1, 
+		chtype	a2, 
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
 int	chgat(
-		int	a1,
-		attr_t	a2,
-		short	a3,
+		int	a1, 
+		attr_t	a2, 
+		short	a3, 
 		const void *z)
 		{ return(*(int *)0); }
 
@@ -420,7 +422,7 @@
 
 #undef color_set
 int	color_set(
-		short	a1,
+		short	a1, 
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -457,7 +459,7 @@
 
 #undef getnstr
 int	getnstr(
-		char	*a1,
+		char	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -468,7 +470,7 @@
 
 #undef hline
 int	hline(
-		chtype	a1,
+		chtype	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -478,7 +480,7 @@
 
 #undef inchnstr
 int	inchnstr(
-		chtype	*a1,
+		chtype	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -489,7 +491,7 @@
 
 #undef innstr
 int	innstr(
-		char	*a1,
+		char	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -509,7 +511,7 @@
 
 #undef insnstr
 int	insnstr(
-		const char *a1,
+		const char *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -525,323 +527,323 @@
 
 #undef move
 int	move(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
 int	mvaddch(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
 int	mvaddchnstr(
-		int	a1,
-		int	a2,
-		const chtype *a3,
+		int	a1, 
+		int	a2, 
+		const chtype *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
 int	mvaddchstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
 int	mvaddnstr(
-		int	a1,
-		int	a2,
-		const char *a3,
+		int	a1, 
+		int	a2, 
+		const char *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
 int	mvaddstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
 int	mvchgat(
-		int	a1,
-		int	a2,
-		int	a3,
-		attr_t	a4,
-		short	a5,
+		int	a1, 
+		int	a2, 
+		int	a3, 
+		attr_t	a4, 
+		short	a5, 
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
 int	mvdelch(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
 int	mvgetch(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
 int	mvgetnstr(
-		int	a1,
-		int	a2,
-		char	*a3,
+		int	a1, 
+		int	a2, 
+		char	*a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
 int	mvgetstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
 int	mvhline(
-		int	a1,
-		int	a2,
-		chtype	a3,
+		int	a1, 
+		int	a2, 
+		chtype	a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
 chtype	mvinch(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
 int	mvinchnstr(
-		int	a1,
-		int	a2,
-		chtype	*a3,
+		int	a1, 
+		int	a2, 
+		chtype	*a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
 int	mvinchstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
 int	mvinnstr(
-		int	a1,
-		int	a2,
-		char	*a3,
+		int	a1, 
+		int	a2, 
+		char	*a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
 int	mvinsch(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
 int	mvinsnstr(
-		int	a1,
-		int	a2,
-		const char *a3,
+		int	a1, 
+		int	a2, 
+		const char *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
 int	mvinsstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
 int	mvinstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
 int	mvvline(
-		int	a1,
-		int	a2,
-		chtype	a3,
+		int	a1, 
+		int	a2, 
+		chtype	a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
 int	mvwaddch(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
 int	mvwaddchnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const chtype *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const chtype *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
 int	mvwaddchstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
 int	mvwaddnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const char *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const char *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
 int	mvwaddstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
 int	mvwchgat(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		int	a4,
-		attr_t	a5,
-		short	a6,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		int	a4, 
+		attr_t	a5, 
+		short	a6, 
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
 int	mvwdelch(
-		WINDOW	*a1,
-		int	a2,
+		WINDOW	*a1, 
+		int	a2, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
 int	mvwgetch(
-		WINDOW	*a1,
-		int	a2,
+		WINDOW	*a1, 
+		int	a2, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
 int	mvwgetnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		char	*a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		char	*a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
 int	mvwgetstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
 int	mvwhline(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		chtype	a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		chtype	a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
 chtype	mvwinch(
-		WINDOW	*a1,
-		int	a2,
+		WINDOW	*a1, 
+		int	a2, 
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
 int	mvwinchnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		chtype	*a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		chtype	*a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
 int	mvwinchstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
 int	mvwinnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		char	*a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		char	*a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
 int	mvwinsch(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
 int	mvwinsnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const char *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const char *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
 int	mvwinsstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
 int	mvwinstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
 int	mvwvline(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		chtype	a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		chtype	a4, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -871,7 +873,7 @@
 
 #undef setscrreg
 int	setscrreg(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -890,8 +892,8 @@
 
 #undef touchline
 int	touchline(
-		WINDOW	*a1,
-		int	a2,
+		WINDOW	*a1, 
+		int	a2, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -907,67 +909,67 @@
 
 #undef vline
 int	vline(
-		chtype	a1,
+		chtype	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef vw_printw
 int	vw_printw(
-		WINDOW	*a1,
-		const char *a2,
+		WINDOW	*a1, 
+		const char *a2, 
 		va_list	z)
 		{ return(*(int *)0); }
 
 #undef vw_scanw
 int	vw_scanw(
-		WINDOW	*a1,
-		char	*a2,
+		WINDOW	*a1, 
+		char	*a2, 
 		va_list	z)
 		{ return(*(int *)0); }
 
 #undef waddchstr
 int	waddchstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
 int	waddstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
 int	wattron(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
 int	wattroff(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
 int	wattrset(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
 int	wattr_get(
-		WINDOW	*a1,
-		attr_t	*a2,
-		short	*a3,
+		WINDOW	*a1, 
+		attr_t	*a2, 
+		short	*a3, 
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
 int	wattr_set(
-		WINDOW	*a1,
-		attr_t	a2,
-		short	a3,
+		WINDOW	*a1, 
+		attr_t	a2, 
+		short	a3, 
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -978,13 +980,13 @@
 
 #undef wgetstr
 int	wgetstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
 int	winchstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		chtype	*z)
 		{ return(*(int *)0); }
 
@@ -995,13 +997,13 @@
 
 #undef winsstr
 int	winsstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
 int	winstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		char	*z)
 		{ return(*(int *)0); }
 
@@ -1016,10 +1018,10 @@
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
-NCURSES_BOOL mouse_trafo(
-		int	*a1,
-		int	*a2,
-		NCURSES_BOOL z)
+NCURSES_BOOL	mouse_trafo(
+		int	*a1, 
+		int	*a2, 
+		NCURSES_BOOL	z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 /* ./base/lib_getch.c */
@@ -1031,8 +1033,8 @@
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win,
-		unsigned long *result,
+		WINDOW	*win, 
+		unsigned long *result, 
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1045,8 +1047,8 @@
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win,
-		char	*str,
+		WINDOW	*win, 
+		char	*str, 
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1054,8 +1056,8 @@
 
 #undef whline
 int	whline(
-		WINDOW	*win,
-		chtype	ch,
+		WINDOW	*win, 
+		chtype	ch, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1063,7 +1065,7 @@
 
 #undef immedok
 void	immedok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1071,8 +1073,8 @@
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win,
-		chtype	*str,
+		WINDOW	*win, 
+		chtype	*str, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1085,29 +1087,31 @@
 /* ./base/lib_insch.c */
 
 #undef _nc_insert_ch
-void	_nc_insert_ch(
-		WINDOW	*win,
+int	_nc_insert_ch(
+		WINDOW	*win, 
 		chtype	ch)
-		{ /* void */ }
+		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win,
+		WINDOW	*win, 
 		chtype	c)
 		{ return(*(int *)0); }
 
-#undef winsnstr
-int	winsnstr(
-		WINDOW	*win,
-		const char *s,
-		int	n)
-		{ return(*(int *)0); }
-
 /* ./base/lib_insdel.c */
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win,
+		WINDOW	*win, 
+		int	n)
+		{ return(*(int *)0); }
+
+/* ./base/lib_insnstr.c */
+
+#undef winsnstr
+int	winsnstr(
+		WINDOW	*win, 
+		const char *s, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1115,8 +1119,8 @@
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win,
-		char	*str,
+		WINDOW	*win, 
+		char	*str, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1130,7 +1134,7 @@
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1148,14 +1152,14 @@
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask,
+		mmask_t	newmask, 
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win,
-		int	y,
+		const WINDOW *win, 
+		int	y, 
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1170,9 +1174,9 @@
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win,
-		int	*pY,
-		int	*pX,
+		const WINDOW *win, 
+		int	*pY, 
+		int	*pX, 
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1180,8 +1184,8 @@
 
 #undef wmove
 int	wmove(
-		WINDOW	*win,
-		int	y,
+		WINDOW	*win, 
+		int	y, 
 		int	x)
 		{ return(*(int *)0); }
 
@@ -1189,7 +1193,7 @@
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap,
+		const char *const cap, 
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -1207,9 +1211,9 @@
 
 #undef mvcur
 int	mvcur(
-		int	yold,
-		int	xold,
-		int	ynew,
+		int	yold, 
+		int	xold, 
+		int	ynew, 
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -1220,8 +1224,8 @@
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win,
-		int	by,
+		WINDOW	*win, 
+		int	by, 
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -1233,8 +1237,8 @@
 
 #undef newterm
 SCREEN	*newterm(
-		char	*name,
-		FILE	*ofp,
+		char	*name, 
+		FILE	*ofp, 
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -1247,36 +1251,36 @@
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines,
-		int	num_columns,
-		int	begy,
+		int	num_lines, 
+		int	num_columns, 
+		int	begy, 
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig,
-		int	num_lines,
-		int	num_columns,
-		int	begy,
+		WINDOW	*orig, 
+		int	num_lines, 
+		int	num_columns, 
+		int	begy, 
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w,
-		int	l,
-		int	c,
-		int	y,
+		WINDOW	*w, 
+		int	l, 
+		int	c, 
+		int	y, 
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew
 WINDOW	*_nc_makenew(
-		int	num_lines,
-		int	num_columns,
-		int	begy,
-		int	begx,
+		int	num_lines, 
+		int	num_columns, 
+		int	begy, 
+		int	begx, 
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -1294,26 +1298,26 @@
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1,
+		const WINDOW *win1, 
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1,
+		const WINDOW *win1, 
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src,
-		WINDOW	*dst,
-		int	sminrow,
-		int	smincol,
-		int	dminrow,
-		int	dmincol,
-		int	dmaxrow,
-		int	dmaxcol,
+		const WINDOW *src, 
+		WINDOW	*dst, 
+		int	sminrow, 
+		int	smincol, 
+		int	dminrow, 
+		int	dmincol, 
+		int	dmaxrow, 
+		int	dmaxcol, 
 		int	over)
 		{ return(*(int *)0); }
 
@@ -1321,44 +1325,44 @@
 
 #undef newpad
 WINDOW	*newpad(
-		int	l,
+		int	l, 
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig,
-		int	l,
-		int	c,
-		int	begy,
+		WINDOW	*orig, 
+		int	l, 
+		int	c, 
+		int	begy, 
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win,
-		int	pminrow,
-		int	pmincol,
-		int	sminrow,
-		int	smincol,
-		int	smaxrow,
+		WINDOW	*win, 
+		int	pminrow, 
+		int	pmincol, 
+		int	sminrow, 
+		int	smincol, 
+		int	smaxrow, 
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win,
-		int	pminrow,
-		int	pmincol,
-		int	sminrow,
-		int	smincol,
-		int	smaxrow,
+		WINDOW	*win, 
+		int	pminrow, 
+		int	pmincol, 
+		int	sminrow, 
+		int	smincol, 
+		int	smaxrow, 
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad,
+		WINDOW	*pad, 
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -1366,38 +1370,38 @@
 
 #undef printw
 int	printw(
-		const char *fmt,
+		const char *fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win,
-		const char *fmt,
+		WINDOW	*win, 
+		const char *fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y,
-		int	x,
-		const char *fmt,
+		int	y, 
+		int	x, 
+		const char *fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win,
-		int	y,
-		int	x,
-		const char *fmt,
+		WINDOW	*win, 
+		int	y, 
+		int	x, 
+		const char *fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win,
-		const char *fmt,
+		WINDOW	*win, 
+		const char *fmt, 
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -1405,8 +1409,8 @@
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win,
-		int	beg,
+		WINDOW	*win, 
+		int	beg, 
 		int	num)
 		{ return(*(int *)0); }
 
@@ -1426,8 +1430,8 @@
 
 #undef restartterm
 int	restartterm(
-		char	*termp,
-		int	filenum,
+		char	*termp, 
+		int	filenum, 
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -1435,38 +1439,38 @@
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win,
-		char	*fmt,
+		WINDOW	*win, 
+		char	*fmt, 
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		char	*fmt,
+		char	*fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win,
-		char	*fmt,
+		WINDOW	*win, 
+		char	*fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y,
-		int	x,
-		char	*fmt,
+		int	y, 
+		int	x, 
+		char	*fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win,
-		int	y,
-		int	x,
-		char	*fmt,
+		WINDOW	*win, 
+		int	y, 
+		int	x, 
+		char	*fmt, 
 		...)
 		{ return(*(int *)0); }
 
@@ -1479,7 +1483,7 @@
 
 #undef putwin
 int	putwin(
-		WINDOW	*win,
+		WINDOW	*win, 
 		FILE	*filep)
 		{ return(*(int *)0); }
 
@@ -1507,16 +1511,16 @@
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win,
-		int const n,
-		short const top,
-		short const bottom,
+		WINDOW	*win, 
+		int const n, 
+		short const top, 
+		short const bottom, 
 		chtype	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win,
+		WINDOW	*win, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1524,7 +1528,7 @@
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1532,8 +1536,8 @@
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win,
-		int	top,
+		WINDOW	*win, 
+		int	top, 
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -1551,24 +1555,24 @@
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		short	slines,
-		short const scolumns,
+		short	slines, 
+		short const scolumns, 
 		FILE	*output)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line,
+		int	line, 
 		int	(*init)(
-		WINDOW	*p1,
+		WINDOW	*p1, 
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line,
+		int	line, 
 		int	(*init)(
-		WINDOW	*p1,
+		WINDOW	*p1, 
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -1579,7 +1583,7 @@
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin,
+		WINDOW	*stwin, 
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -1591,8 +1595,8 @@
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr,
-		short	color_pair_number,
+		const attr_t attr, 
+		short	color_pair_number, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -1664,8 +1668,8 @@
 
 #undef slk_set
 int	slk_set(
-		int	i,
-		const char *astr,
+		int	i, 
+		const char *astr, 
 		int	format)
 		{ return(*(int *)0); }
 
@@ -1679,7 +1683,7 @@
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win,
+		WINDOW	*win, 
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1690,9 +1694,9 @@
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win,
-		int	y,
-		int	n,
+		WINDOW	*win, 
+		int	y, 
+		int	n, 
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -1700,7 +1704,7 @@
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum,
+		int	bufnum, 
 		attr_t	newmode)
 		{ return(*(char **)0); }
 
@@ -1716,13 +1720,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr,
+		attr_t	attr, 
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum,
+		int	bufnum, 
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -1740,7 +1744,7 @@
 
 #undef _tracedump
 void	_tracedump(
-		const char *name,
+		const char *name, 
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -1775,7 +1779,7 @@
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode,
+		chtype	newmode, 
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -1793,8 +1797,8 @@
 
 #undef wvline
 int	wvline(
-		WINDOW	*win,
-		chtype	ch,
+		WINDOW	*win, 
+		chtype	ch, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1802,8 +1806,8 @@
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win,
-		attr_t	at,
+		WINDOW	*win, 
+		attr_t	at, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -1811,8 +1815,8 @@
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win,
-		attr_t	at,
+		WINDOW	*win, 
+		attr_t	at, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -1832,14 +1836,14 @@
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win,
-		int	y,
+		WINDOW	*win, 
+		int	y, 
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -1873,7 +1877,7 @@
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt,
+		const char *fmt, 
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -1888,9 +1892,9 @@
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n,
-		int	top,
-		int	bot,
+		int	n, 
+		int	top, 
+		int	bot, 
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -1913,9 +1917,13 @@
 
 /* ./trace/varargs.c */
 
+typedef enum {
+    atUnknown = 0, atInteger, atFloat, atPoint, atString
+} ARGTYPE;
+
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt,
+		const char *fmt, 
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -1943,7 +1951,7 @@
 
 #undef define_key
 int	define_key(
-		const char *str,
+		const char *str, 
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -1951,13 +1959,13 @@
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S,
+		attr_t	*S, 
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S,
+		attr_t	*S, 
 		attr_t	at)
 		{ /* void */ }
 
@@ -1987,7 +1995,7 @@
 
 #undef keybound
 char	*keybound(
-		int	code,
+		int	code, 
 		int	count)
 		{ return(*(char **)0); }
 
@@ -1995,7 +2003,7 @@
 
 #undef keyok
 int	keyok(
-		int	c,
+		int	c, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2007,7 +2015,7 @@
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg,
+		int	fg, 
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -2015,7 +2023,7 @@
 
 #undef mcprint
 int	mcprint(
-		char	*data,
+		char	*data, 
 		int	len)
 		{ return(*(int *)0); }
 
@@ -2023,19 +2031,19 @@
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines,
+		int	ToLines, 
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines,
+		int	ToLines, 
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines,
+		int	ToLines, 
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2050,41 +2058,37 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		struct tries *tree,
-		unsigned short code,
-		int	*count,
+		struct tries *tree, 
+		unsigned short code, 
+		int	*count, 
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		struct tries **tree,
+		struct tries **tree, 
 		unsigned short code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		struct tries **tree,
+		struct tries **tree, 
 		const char *string)
 		{ return(*(int *)0); }
 
-/* ./base/version.c */
-
-#undef curses_version
-const char *curses_version(void)
-		{ return(*(const char **)0); }
-
 /* ./base/wresize.c */
 
 #undef wresize
 int	wresize(
-		WINDOW	*win,
-		int	ToLines,
+		WINDOW	*win, 
+		int	ToLines, 
 		int	ToCols)
 		{ return(*(int *)0); }
 
 /* ./tinfo/access.c */
 
+#include <nc_alloc.h>
+
 #undef _nc_rootname
 char	*_nc_rootname(
 		char	*path)
@@ -2102,7 +2106,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path,
+		const char *path, 
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -2114,8 +2118,8 @@
 
 #undef _nc_add_to_try
 void	_nc_add_to_try(
-		struct tries **tree,
-		const char *str,
+		struct tries **tree, 
+		const char *str, 
 		unsigned short code)
 		{ /* void */ }
 
@@ -2138,13 +2142,13 @@
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep,
+		ENTRY	*const ep, 
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to,
+		TERMTYPE *const to, 
 		TERMTYPE *const from)
 		{ /* void */ }
 
@@ -2152,13 +2156,13 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to,
+		TERMTYPE *to, 
 		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst,
+		TERMTYPE *dst, 
 		TERMTYPE *src)
 		{ /* void */ }
 
@@ -2166,15 +2170,15 @@
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap,
-		const char *s,
+		const char *cap, 
+		const char *s, 
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap,
-		const char *str,
+		const char *cap, 
+		const char *str, 
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -2236,19 +2240,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt,
+		const char *const fmt, 
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt,
+		const char *const fmt, 
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt,
+		const char *const fmt, 
 		...)
 		{ /* void */ }
 
@@ -2256,8 +2260,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp,
-		NCURSES_BOOL tic_format,
+		const char *srcp, 
+		NCURSES_BOOL tic_format, 
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -2267,19 +2271,23 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string,
+		const char *string, 
 		const struct name_table_entry *const *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string,
-		int	type,
+		const char *string, 
+		int	type, 
 		const struct name_table_entry *table)
 		{ return(*(struct name_table_entry const **)0); }
 
 /* ./tinfo/comp_parse.c */
 
+#undef _nc_check_termtype2
+void	(*_nc_check_termtype2)(
+		TERMTYPE *p1, 
+		NCURSES_BOOL p2);
 #undef _nc_check_termtype
 void	(*_nc_check_termtype)(
 		TERMTYPE *p1);
@@ -2295,20 +2303,26 @@
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1,
+		char	*n1, 
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp,
-		char	*buf,
-		int	literal,
-		NCURSES_BOOL silent,
+		FILE	*fp, 
+		char	*buf, 
+		int	literal, 
+		NCURSES_BOOL silent, 
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
+#undef _nc_resolve_uses2
+int	_nc_resolve_uses2(
+		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL literal)
+		{ return(*(int *)0); }
+
 #undef _nc_resolve_uses
 int	_nc_resolve_uses(
 		NCURSES_BOOL fullresolve)
@@ -2331,16 +2345,22 @@
 #undef _nc_disable_period
 NCURSES_BOOL _nc_disable_period;
 
+#undef _nc_reset_input
+void	_nc_reset_input(
+		FILE	*fp, 
+		char	*buf)
+		{ /* void */ }
+
 #undef _nc_get_token
 int	_nc_get_token(
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_trans_string
-char	_nc_trans_string(
-		char	*ptr,
+int	_nc_trans_string(
+		char	*ptr, 
 		char	*last)
-		{ return(*(char *)0); }
+		{ return(*(int *)0); }
 
 #undef _nc_push_token
 void	_nc_push_token(
@@ -2352,17 +2372,11 @@
 		char	ch)
 		{ /* void */ }
 
-#undef _nc_reset_input
-void	_nc_reset_input(
-		FILE	*fp,
-		char	*buf)
-		{ /* void */ }
-
 /* ./tinfo/doalloc.c */
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp,
+		void	*oldp, 
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -2429,6 +2443,11 @@
 
 #include <termcap.h>
 
+struct speed {
+    int s; 
+    int sp; 
+};
+
 #undef _nc_baudrate
 int	_nc_baudrate(
 		int	OSpeed)
@@ -2524,13 +2543,13 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -2541,31 +2560,31 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win,
+		WINDOW	*win, 
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2617,13 +2636,15 @@
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 /* ./tinfo/lib_setup.c */
 
+#include <locale.h>
 #include <sys/ioctl.h>
+#include <langinfo.h>
 
 #undef ttytype
 char	ttytype[256];
@@ -2655,10 +2676,18 @@
 int	_nc_locale_breaks_acs(void)
 		{ return(*(int *)0); }
 
+#undef _nc_setupterm
+int	_nc_setupterm(
+		char	*tname, 
+		int	Filedes, 
+		int	*errret, 
+		NCURSES_BOOL reuse)
+		{ return(*(int *)0); }
+
 #undef setupterm
 int	setupterm(
-		char	*tname,
-		int	Filedes,
+		char	*tname, 
+		int	Filedes, 
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -2671,7 +2700,7 @@
 
 #undef tgetent
 int	tgetent(
-		char	*bufp,
+		char	*bufp, 
 		const char *name)
 		{ return(*(int *)0); }
 
@@ -2693,7 +2722,7 @@
 
 #undef tgetstr
 char	*tgetstr(
-		char	*id,
+		char	*id, 
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -2707,8 +2736,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string,
-		int	x,
+		const char *string, 
+		int	x, 
 		int	y)
 		{ return(*(char **)0); }
 
@@ -2731,19 +2760,27 @@
 
 /* ./tinfo/lib_tparm.c */
 
+typedef struct {
+    union {
+        int num;
+        char *str;
+    } data;
+    NCURSES_BOOL num_type;
+} stack_frame;
+
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string,
-		char	*p_is_s[9],
+		const char *string, 
+		char	*p_is_s[9], 
 		int	*popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		char	*string,
+		char	*string, 
 		...)
 		{ return(*(char **)0); }
 
@@ -2777,8 +2814,8 @@
 
 #undef tputs
 int	tputs(
-		const char *string,
-		int	affcnt,
+		const char *string, 
+		int	affcnt, 
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -2799,7 +2836,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt,
+		const char *fmt, 
 		...)
 		{ /* void */ }
 
@@ -2823,6 +2860,21 @@
 		char	*code)
 		{ return(*(char **)0); }
 
+#undef _nc_retrace_cptr
+const char *_nc_retrace_cptr(
+		const char *code)
+		{ return(*(const char **)0); }
+
+#undef _nc_retrace_cvoid_ptr
+void	*_nc_retrace_cvoid_ptr(
+		void	*code)
+		{ return(*(void **)0); }
+
+#undef _nc_retrace_void_ptr
+void	*_nc_retrace_void_ptr(
+		void	*code)
+		{ return(*(void **)0); }
+
 #undef _nc_retrace_sp
 SCREEN	*_nc_retrace_sp(
 		SCREEN	*code)
@@ -2835,6 +2887,11 @@
 
 /* ./trace/lib_tracebits.c */
 
+typedef struct {
+    unsigned int val;
+    const char *name;
+} BITNAMES;
+
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
 		struct termios *tty)
@@ -2891,8 +2948,8 @@
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		int	mode,
-		int	milliseconds,
+		int	mode, 
+		int	milliseconds, 
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -2905,8 +2962,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst,
-		const char *const name,
+		const char *const namelst, 
+		const char *const name, 
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -2929,17 +2986,22 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp,
-		int	literal,
+		struct entry *entryp, 
+		int	literal, 
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s,
+		const char *s, 
 		const char *t)
 		{ return(*(int *)0); }
 
+typedef struct {
+    const char *from;
+    const char *to;
+} assoc;
+
 /* ./tinfo/read_entry.c */
 
 #undef _nc_tic_dir
@@ -2954,22 +3016,25 @@
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename,
+		const char *const filename, 
 		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const tn,
-		char	*const filename,
+		const char *const tn, 
+		char	*const filename, 
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
+#include <sys/types.h>
+#include <sys/stat.h>
+
 #undef _nc_read_termcap_entry
 int	_nc_read_termcap_entry(
-		const char *const tn,
+		const char *const tn, 
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
@@ -2977,7 +3042,7 @@
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp,
+		FILE	*ofp, 
 		NCURSES_BOOL buffered)
 		{ /* void */ }
 
@@ -2985,46 +3050,51 @@
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst,
-		char	*src,
+		string_desc *dst, 
+		char	*src, 
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst,
+		string_desc *dst, 
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst,
+		string_desc *dst, 
 		string_desc *src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst,
+		string_desc *dst, 
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst,
+		string_desc *dst, 
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 /* ./trace/trace_buf.c */
 
+typedef struct {
+    char *text;
+    size_t size;
+} LIST;
+
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum,
+		int	bufnum, 
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum,
+		int	bufnum, 
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -3046,7 +3116,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum,
+		int	bufnum, 
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -3057,7 +3127,7 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf,
+		const char *buf, 
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -3076,3 +3146,9 @@
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
+
+/* ./base/version.c */
+
+#undef curses_version
+const char *curses_version(void)
+		{ return(*(const char **)0); }
diff -Naur ncurses-5.4.orig/ncurses/llib-lncursesw ncurses-5.4/ncurses/llib-lncursesw
--- ncurses-5.4.orig/ncurses/llib-lncursesw	2004-01-31 16:17:01.000000000 +0000
+++ ncurses-5.4/ncurses/llib-lncursesw	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2001-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 2001-2004,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey 2001-2004                                      *
+ *  Author: Thomas E. Dickey 2001-2005                                      *
  ****************************************************************************/
 /* LINTLIBRARY */
 
@@ -48,6 +48,8 @@
 
 /* ./tty/hashmap.c */
 
+#include <term.h>
+
 #undef _nc_hash_map
 void	_nc_hash_map(void)
 		{ /* void */ }
@@ -59,8 +61,8 @@
 
 #undef _nc_scroll_oldhash
 void	_nc_scroll_oldhash(
-		int	n,
-		int	top,
+		int	n, 
+		int	top, 
 		int	bot)
 		{ /* void */ }
 
@@ -70,25 +72,31 @@
 
 #undef _nc_render
 cchar_t	_nc_render(
-		WINDOW	*win,
+		WINDOW	*win, 
 		cchar_t	ch)
 		{ return(*(cchar_t *)0); }
 
+#undef _nc_build_wch
+int	_nc_build_wch(
+		WINDOW	*win, 
+		cchar_t	*ch)
+		{ return(*(int *)0); }
+
 #undef _nc_waddch_nosync
 int	_nc_waddch_nosync(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const cchar_t c)
 		{ return(*(int *)0); }
 
 #undef waddch
 int	waddch(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const chtype ch)
 		{ return(*(int *)0); }
 
 #undef wechochar
 int	wechochar(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -96,15 +104,15 @@
 
 #undef waddnstr
 int	waddnstr(
-		WINDOW	*win,
-		const char *astr,
+		WINDOW	*win, 
+		const char *astr, 
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddchnstr
 int	waddchnstr(
-		WINDOW	*win,
-		const chtype *astr,
+		WINDOW	*win, 
+		const chtype *astr, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -115,15 +123,15 @@
 
 #undef wadd_wchnstr
 int	wadd_wchnstr(
-		WINDOW	*win,
-		const cchar_t *astr,
+		WINDOW	*win, 
+		const cchar_t *astr, 
 		int	n)
 		{ return(*(int *)0); }
 
 #undef waddnwstr
 int	waddnwstr(
-		WINDOW	*win,
-		const wchar_t *str,
+		WINDOW	*win, 
+		const wchar_t *str, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -137,25 +145,25 @@
 
 #undef wbkgrndset
 void	wbkgrndset(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const cchar_t *ch)
 		{ /* void */ }
 
 #undef wbkgdset
 void	wbkgdset(
-		WINDOW	*win,
+		WINDOW	*win, 
 		chtype	ch)
 		{ /* void */ }
 
 #undef wbkgrnd
 int	wbkgrnd(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const cchar_t *ch)
 		{ return(*(int *)0); }
 
 #undef wbkgd
 int	wbkgd(
-		WINDOW	*win,
+		WINDOW	*win, 
 		chtype	ch)
 		{ return(*(int *)0); }
 
@@ -163,14 +171,14 @@
 
 #undef wborder
 int	wborder(
-		WINDOW	*win,
-		chtype	ls,
-		chtype	rs,
-		chtype	ts,
-		chtype	bs,
-		chtype	tl,
-		chtype	tr,
-		chtype	bl,
+		WINDOW	*win, 
+		chtype	ls, 
+		chtype	rs, 
+		chtype	ts, 
+		chtype	bs, 
+		chtype	tl, 
+		chtype	tr, 
+		chtype	bl, 
 		chtype	br)
 		{ return(*(int *)0); }
 
@@ -178,10 +186,10 @@
 
 #undef wchgat
 int	wchgat(
-		WINDOW	*win,
-		int	n,
-		attr_t	attr,
-		short	color,
+		WINDOW	*win, 
+		int	n, 
+		attr_t	attr, 
+		short	color, 
 		const void *opts)
 		{ return(*(int *)0); }
 
@@ -196,7 +204,7 @@
 
 #undef clearok
 int	clearok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -233,16 +241,16 @@
 
 #undef init_pair
 int	init_pair(
-		short	pair,
-		short	f,
+		short	pair, 
+		short	f, 
 		short	b)
 		{ return(*(int *)0); }
 
 #undef init_color
 int	init_color(
-		short	color,
-		short	r,
-		short	g,
+		short	color, 
+		short	r, 
+		short	g, 
 		short	b)
 		{ return(*(int *)0); }
 
@@ -256,24 +264,24 @@
 
 #undef color_content
 int	color_content(
-		short	color,
-		short	*r,
-		short	*g,
+		short	color, 
+		short	*r, 
+		short	*g, 
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef pair_content
 int	pair_content(
-		short	pair,
-		short	*f,
+		short	pair, 
+		short	*f, 
 		short	*b)
 		{ return(*(int *)0); }
 
 #undef _nc_do_color
 void	_nc_do_color(
-		int	old_pair,
-		int	pair,
-		NCURSES_BOOL reverse,
+		int	old_pair, 
+		int	pair, 
+		NCURSES_BOOL reverse, 
 		int	(*outc)(
 		int	p1))
 		{ /* void */ }
@@ -282,8 +290,8 @@
 
 #undef wcolor_set
 int	wcolor_set(
-		WINDOW	*win,
-		short	color_pair_number,
+		WINDOW	*win, 
+		short	color_pair_number, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -339,7 +347,7 @@
 
 #undef addchnstr
 int	addchnstr(
-		const chtype *a1,
+		const chtype *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -350,7 +358,7 @@
 
 #undef addnstr
 int	addnstr(
-		const char *a1,
+		const char *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -376,27 +384,27 @@
 
 #undef attr_get
 int	attr_get(
-		attr_t	*a1,
-		short	*a2,
+		attr_t	*a1, 
+		short	*a2, 
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_off
 int	attr_off(
-		attr_t	a1,
+		attr_t	a1, 
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_on
 int	attr_on(
-		attr_t	a1,
+		attr_t	a1, 
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef attr_set
 int	attr_set(
-		attr_t	a1,
-		short	a2,
+		attr_t	a1, 
+		short	a2, 
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -412,28 +420,28 @@
 
 #undef border
 int	border(
-		chtype	a1,
-		chtype	a2,
-		chtype	a3,
-		chtype	a4,
-		chtype	a5,
-		chtype	a6,
-		chtype	a7,
+		chtype	a1, 
+		chtype	a2, 
+		chtype	a3, 
+		chtype	a4, 
+		chtype	a5, 
+		chtype	a6, 
+		chtype	a7, 
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef box
 int	box(
-		WINDOW	*a1,
-		chtype	a2,
+		WINDOW	*a1, 
+		chtype	a2, 
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef chgat
 int	chgat(
-		int	a1,
-		attr_t	a2,
-		short	a3,
+		int	a1, 
+		attr_t	a2, 
+		short	a3, 
 		const void *z)
 		{ return(*(int *)0); }
 
@@ -451,7 +459,7 @@
 
 #undef color_set
 int	color_set(
-		short	a1,
+		short	a1, 
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -488,7 +496,7 @@
 
 #undef getnstr
 int	getnstr(
-		char	*a1,
+		char	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -499,7 +507,7 @@
 
 #undef hline
 int	hline(
-		chtype	a1,
+		chtype	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -509,7 +517,7 @@
 
 #undef inchnstr
 int	inchnstr(
-		chtype	*a1,
+		chtype	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -520,7 +528,7 @@
 
 #undef innstr
 int	innstr(
-		char	*a1,
+		char	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -540,7 +548,7 @@
 
 #undef insnstr
 int	insnstr(
-		const char *a1,
+		const char *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -556,323 +564,323 @@
 
 #undef move
 int	move(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddch
 int	mvaddch(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvaddchnstr
 int	mvaddchnstr(
-		int	a1,
-		int	a2,
-		const chtype *a3,
+		int	a1, 
+		int	a2, 
+		const chtype *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddchstr
 int	mvaddchstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnstr
 int	mvaddnstr(
-		int	a1,
-		int	a2,
-		const char *a3,
+		int	a1, 
+		int	a2, 
+		const char *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddstr
 int	mvaddstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvchgat
 int	mvchgat(
-		int	a1,
-		int	a2,
-		int	a3,
-		attr_t	a4,
-		short	a5,
+		int	a1, 
+		int	a2, 
+		int	a3, 
+		attr_t	a4, 
+		short	a5, 
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvdelch
 int	mvdelch(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetch
 int	mvgetch(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetnstr
 int	mvgetnstr(
-		int	a1,
-		int	a2,
-		char	*a3,
+		int	a1, 
+		int	a2, 
+		char	*a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvgetstr
 int	mvgetstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvhline
 int	mvhline(
-		int	a1,
-		int	a2,
-		chtype	a3,
+		int	a1, 
+		int	a2, 
+		chtype	a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinch
 chtype	mvinch(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvinchnstr
 int	mvinchnstr(
-		int	a1,
-		int	a2,
-		chtype	*a3,
+		int	a1, 
+		int	a2, 
+		chtype	*a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinchstr
 int	mvinchstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnstr
 int	mvinnstr(
-		int	a1,
-		int	a2,
-		char	*a3,
+		int	a1, 
+		int	a2, 
+		char	*a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsch
 int	mvinsch(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvinsnstr
 int	mvinsnstr(
-		int	a1,
-		int	a2,
-		const char *a3,
+		int	a1, 
+		int	a2, 
+		const char *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvinsstr
 int	mvinsstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvinstr
 int	mvinstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline
 int	mvvline(
-		int	a1,
-		int	a2,
-		chtype	a3,
+		int	a1, 
+		int	a2, 
+		chtype	a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddch
 int	mvwaddch(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const chtype z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchnstr
 int	mvwaddchnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const chtype *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const chtype *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddchstr
 int	mvwaddchstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnstr
 int	mvwaddnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const char *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const char *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddstr
 int	mvwaddstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwchgat
 int	mvwchgat(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		int	a4,
-		attr_t	a5,
-		short	a6,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		int	a4, 
+		attr_t	a5, 
+		short	a6, 
 		const void *z)
 		{ return(*(int *)0); }
 
 #undef mvwdelch
 int	mvwdelch(
-		WINDOW	*a1,
-		int	a2,
+		WINDOW	*a1, 
+		int	a2, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetch
 int	mvwgetch(
-		WINDOW	*a1,
-		int	a2,
+		WINDOW	*a1, 
+		int	a2, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetnstr
 int	mvwgetnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		char	*a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		char	*a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwgetstr
 int	mvwgetstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwhline
 int	mvwhline(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		chtype	a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		chtype	a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinch
 chtype	mvwinch(
-		WINDOW	*a1,
-		int	a2,
+		WINDOW	*a1, 
+		int	a2, 
 		int	z)
 		{ return(*(chtype *)0); }
 
 #undef mvwinchnstr
 int	mvwinchnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		chtype	*a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		chtype	*a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinchstr
 int	mvwinchstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		chtype	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnstr
 int	mvwinnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		char	*a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		char	*a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsch
 int	mvwinsch(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		chtype	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsnstr
 int	mvwinsnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const char *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const char *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwinsstr
 int	mvwinsstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef mvwinstr
 int	mvwinstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline
 int	mvwvline(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		chtype	a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		chtype	a4, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -902,19 +910,19 @@
 
 #undef setscrreg
 int	setscrreg(
-		int	a1,
+		int	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_off
 int	slk_attr_off(
-		const attr_t a1,
+		const attr_t a1, 
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef slk_attr_on
 int	slk_attr_on(
-		attr_t	a1,
+		attr_t	a1, 
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -933,8 +941,8 @@
 
 #undef touchline
 int	touchline(
-		WINDOW	*a1,
-		int	a2,
+		WINDOW	*a1, 
+		int	a2, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -950,67 +958,67 @@
 
 #undef vline
 int	vline(
-		chtype	a1,
+		chtype	a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef vw_printw
 int	vw_printw(
-		WINDOW	*a1,
-		const char *a2,
+		WINDOW	*a1, 
+		const char *a2, 
 		va_list	z)
 		{ return(*(int *)0); }
 
 #undef vw_scanw
 int	vw_scanw(
-		WINDOW	*a1,
-		char	*a2,
+		WINDOW	*a1, 
+		char	*a2, 
 		va_list	z)
 		{ return(*(int *)0); }
 
 #undef waddchstr
 int	waddchstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		const chtype *z)
 		{ return(*(int *)0); }
 
 #undef waddstr
 int	waddstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef wattron
 int	wattron(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattroff
 int	wattroff(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattrset
 int	wattrset(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wattr_get
 int	wattr_get(
-		WINDOW	*a1,
-		attr_t	*a2,
-		short	*a3,
+		WINDOW	*a1, 
+		attr_t	*a2, 
+		short	*a3, 
 		void	*z)
 		{ return(*(int *)0); }
 
 #undef wattr_set
 int	wattr_set(
-		WINDOW	*a1,
-		attr_t	a2,
-		short	a3,
+		WINDOW	*a1, 
+		attr_t	a2, 
+		short	a3, 
 		void	*z)
 		{ return(*(int *)0); }
 
@@ -1021,13 +1029,13 @@
 
 #undef wgetstr
 int	wgetstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		char	*z)
 		{ return(*(int *)0); }
 
 #undef winchstr
 int	winchstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		chtype	*z)
 		{ return(*(int *)0); }
 
@@ -1038,13 +1046,13 @@
 
 #undef winsstr
 int	winsstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		const char *z)
 		{ return(*(int *)0); }
 
 #undef winstr
 int	winstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		char	*z)
 		{ return(*(int *)0); }
 
@@ -1065,7 +1073,7 @@
 
 #undef add_wchnstr
 int	add_wchnstr(
-		const cchar_t *a1,
+		const cchar_t *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1076,7 +1084,7 @@
 
 #undef addnwstr
 int	addnwstr(
-		const wchar_t *a1,
+		const wchar_t *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1097,20 +1105,20 @@
 
 #undef border_set
 int	border_set(
-		const cchar_t *a1,
-		const cchar_t *a2,
-		const cchar_t *a3,
-		const cchar_t *a4,
-		const cchar_t *a5,
-		const cchar_t *a6,
-		const cchar_t *a7,
+		const cchar_t *a1, 
+		const cchar_t *a2, 
+		const cchar_t *a3, 
+		const cchar_t *a4, 
+		const cchar_t *a5, 
+		const cchar_t *a6, 
+		const cchar_t *a7, 
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef box_set
 int	box_set(
-		WINDOW	*a1,
-		const cchar_t *a2,
+		WINDOW	*a1, 
+		const cchar_t *a2, 
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
@@ -1136,13 +1144,13 @@
 
 #undef getn_wstr
 int	getn_wstr(
-		wint_t	*a1,
+		wint_t	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef hline_set
 int	hline_set(
-		const cchar_t *a1,
+		const cchar_t *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1153,7 +1161,7 @@
 
 #undef in_wchnstr
 int	in_wchnstr(
-		cchar_t	*a1,
+		cchar_t	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1164,13 +1172,13 @@
 
 #undef innwstr
 int	innwstr(
-		wchar_t	*a1,
+		wchar_t	*a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef ins_nwstr
 int	ins_nwstr(
-		const wchar_t *a1,
+		const wchar_t *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
@@ -1191,331 +1199,331 @@
 
 #undef mvadd_wch
 int	mvadd_wch(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchnstr
 int	mvadd_wchnstr(
-		int	a1,
-		int	a2,
-		const cchar_t *a3,
+		int	a1, 
+		int	a2, 
+		const cchar_t *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvadd_wchstr
 int	mvadd_wchstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvaddnwstr
 int	mvaddnwstr(
-		int	a1,
-		int	a2,
-		const wchar_t *a3,
+		int	a1, 
+		int	a2, 
+		const wchar_t *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvaddwstr
 int	mvaddwstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvget_wch
 int	mvget_wch(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvget_wstr
 int	mvget_wstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvgetn_wstr
 int	mvgetn_wstr(
-		int	a1,
-		int	a2,
-		wint_t	*a3,
+		int	a1, 
+		int	a2, 
+		wint_t	*a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvhline_set
 int	mvhline_set(
-		int	a1,
-		int	a2,
-		const cchar_t *a3,
+		int	a1, 
+		int	a2, 
+		const cchar_t *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wch
 int	mvin_wch(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchnstr
 int	mvin_wchnstr(
-		int	a1,
-		int	a2,
-		cchar_t	*a3,
+		int	a1, 
+		int	a2, 
+		cchar_t	*a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvin_wchstr
 int	mvin_wchstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvinnwstr
 int	mvinnwstr(
-		int	a1,
-		int	a2,
-		wchar_t	*a3,
+		int	a1, 
+		int	a2, 
+		wchar_t	*a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_nwstr
 int	mvins_nwstr(
-		int	a1,
-		int	a2,
-		const wchar_t *a3,
+		int	a1, 
+		int	a2, 
+		const wchar_t *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvins_wch
 int	mvins_wch(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvins_wstr
 int	mvins_wstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvinwstr
 int	mvinwstr(
-		int	a1,
-		int	a2,
+		int	a1, 
+		int	a2, 
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvvline_set
 int	mvvline_set(
-		int	a1,
-		int	a2,
-		const cchar_t *a3,
+		int	a1, 
+		int	a2, 
+		const cchar_t *a3, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wch
 int	mvwadd_wch(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchnstr
 int	mvwadd_wchnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const cchar_t *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const cchar_t *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwadd_wchstr
 int	mvwadd_wchstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwaddnwstr
 int	mvwaddnwstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const wchar_t *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const wchar_t *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwaddwstr
 int	mvwaddwstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wch
 int	mvwget_wch(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwget_wstr
 int	mvwget_wstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwgetn_wstr
 int	mvwgetn_wstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		wint_t	*a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		wint_t	*a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwhline_set
 int	mvwhline_set(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const cchar_t *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const cchar_t *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wch
 int	mvwin_wch(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchnstr
 int	mvwin_wchnstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		cchar_t	*a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		cchar_t	*a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwin_wchstr
 int	mvwin_wchstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwinnwstr
 int	mvwinnwstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		wchar_t	*a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		wchar_t	*a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_nwstr
 int	mvwins_nwstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const wchar_t *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const wchar_t *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wch
 int	mvwins_wch(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwins_wstr
 int	mvwins_wstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mvwinwstr
 int	mvwinwstr(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
 		wchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef mvwvline_set
 int	mvwvline_set(
-		WINDOW	*a1,
-		int	a2,
-		int	a3,
-		const cchar_t *a4,
+		WINDOW	*a1, 
+		int	a2, 
+		int	a3, 
+		const cchar_t *a4, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef vline_set
 int	vline_set(
-		const cchar_t *a1,
+		const cchar_t *a1, 
 		int	z)
 		{ return(*(int *)0); }
 
 #undef wadd_wchstr
 int	wadd_wchstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		const cchar_t *z)
 		{ return(*(int *)0); }
 
 #undef waddwstr
 int	waddwstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef wget_wstr
 int	wget_wstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		wint_t	*z)
 		{ return(*(int *)0); }
 
 #undef win_wchstr
 int	win_wchstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		cchar_t	*z)
 		{ return(*(int *)0); }
 
 #undef wins_wstr
 int	wins_wstr(
-		WINDOW	*a1,
+		WINDOW	*a1, 
 		const wchar_t *z)
 		{ return(*(int *)0); }
 
 #undef mouse_trafo
-NCURSES_BOOL mouse_trafo(
-		int	*a1,
-		int	*a2,
-		NCURSES_BOOL z)
+NCURSES_BOOL	mouse_trafo(
+		int	*a1, 
+		int	*a2, 
+		NCURSES_BOOL	z)
 		{ return(*(NCURSES_BOOL *)0); }
 
 /* ./base/lib_getch.c */
@@ -1527,8 +1535,8 @@
 
 #undef _nc_wgetch
 int	_nc_wgetch(
-		WINDOW	*win,
-		unsigned long *result,
+		WINDOW	*win, 
+		unsigned long *result, 
 		int	use_meta)
 		{ return(*(int *)0); }
 
@@ -1541,8 +1549,8 @@
 
 #undef wgetnstr
 int	wgetnstr(
-		WINDOW	*win,
-		char	*str,
+		WINDOW	*win, 
+		char	*str, 
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -1550,8 +1558,8 @@
 
 #undef whline
 int	whline(
-		WINDOW	*win,
-		chtype	ch,
+		WINDOW	*win, 
+		chtype	ch, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1559,7 +1567,7 @@
 
 #undef immedok
 void	immedok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -1567,8 +1575,8 @@
 
 #undef winchnstr
 int	winchnstr(
-		WINDOW	*win,
-		chtype	*str,
+		WINDOW	*win, 
+		chtype	*str, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1581,29 +1589,31 @@
 /* ./base/lib_insch.c */
 
 #undef _nc_insert_ch
-void	_nc_insert_ch(
-		WINDOW	*win,
+int	_nc_insert_ch(
+		WINDOW	*win, 
 		chtype	ch)
-		{ /* void */ }
+		{ return(*(int *)0); }
 
 #undef winsch
 int	winsch(
-		WINDOW	*win,
+		WINDOW	*win, 
 		chtype	c)
 		{ return(*(int *)0); }
 
-#undef winsnstr
-int	winsnstr(
-		WINDOW	*win,
-		const char *s,
-		int	n)
-		{ return(*(int *)0); }
-
 /* ./base/lib_insdel.c */
 
 #undef winsdelln
 int	winsdelln(
-		WINDOW	*win,
+		WINDOW	*win, 
+		int	n)
+		{ return(*(int *)0); }
+
+/* ./base/lib_insnstr.c */
+
+#undef winsnstr
+int	winsnstr(
+		WINDOW	*win, 
+		const char *s, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1611,8 +1621,8 @@
 
 #undef winnstr
 int	winnstr(
-		WINDOW	*win,
-		char	*str,
+		WINDOW	*win, 
+		char	*str, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -1626,7 +1636,7 @@
 
 #undef leaveok
 int	leaveok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -1644,14 +1654,14 @@
 
 #undef mousemask
 mmask_t	mousemask(
-		mmask_t	newmask,
+		mmask_t	newmask, 
 		mmask_t	*oldmask)
 		{ return(*(mmask_t *)0); }
 
 #undef wenclose
 NCURSES_BOOL wenclose(
-		const WINDOW *win,
-		int	y,
+		const WINDOW *win, 
+		int	y, 
 		int	x)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1666,9 +1676,9 @@
 
 #undef wmouse_trafo
 NCURSES_BOOL wmouse_trafo(
-		const WINDOW *win,
-		int	*pY,
-		int	*pX,
+		const WINDOW *win, 
+		int	*pY, 
+		int	*pX, 
 		NCURSES_BOOL to_screen)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -1676,8 +1686,8 @@
 
 #undef wmove
 int	wmove(
-		WINDOW	*win,
-		int	y,
+		WINDOW	*win, 
+		int	y, 
 		int	x)
 		{ return(*(int *)0); }
 
@@ -1685,7 +1695,7 @@
 
 #undef _nc_msec_cost
 int	_nc_msec_cost(
-		const char *const cap,
+		const char *const cap, 
 		int	affcnt)
 		{ return(*(int *)0); }
 
@@ -1703,9 +1713,9 @@
 
 #undef mvcur
 int	mvcur(
-		int	yold,
-		int	xold,
-		int	ynew,
+		int	yold, 
+		int	xold, 
+		int	ynew, 
 		int	xnew)
 		{ return(*(int *)0); }
 
@@ -1716,8 +1726,8 @@
 
 #undef mvwin
 int	mvwin(
-		WINDOW	*win,
-		int	by,
+		WINDOW	*win, 
+		int	by, 
 		int	bx)
 		{ return(*(int *)0); }
 
@@ -1729,8 +1739,8 @@
 
 #undef newterm
 SCREEN	*newterm(
-		char	*name,
-		FILE	*ofp,
+		char	*name, 
+		FILE	*ofp, 
 		FILE	*ifp)
 		{ return(*(SCREEN **)0); }
 
@@ -1743,36 +1753,36 @@
 
 #undef newwin
 WINDOW	*newwin(
-		int	num_lines,
-		int	num_columns,
-		int	begy,
+		int	num_lines, 
+		int	num_columns, 
+		int	begy, 
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef derwin
 WINDOW	*derwin(
-		WINDOW	*orig,
-		int	num_lines,
-		int	num_columns,
-		int	begy,
+		WINDOW	*orig, 
+		int	num_lines, 
+		int	num_columns, 
+		int	begy, 
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef subwin
 WINDOW	*subwin(
-		WINDOW	*w,
-		int	l,
-		int	c,
-		int	y,
+		WINDOW	*w, 
+		int	l, 
+		int	c, 
+		int	y, 
 		int	x)
 		{ return(*(WINDOW **)0); }
 
 #undef _nc_makenew
 WINDOW	*_nc_makenew(
-		int	num_lines,
-		int	num_columns,
-		int	begy,
-		int	begx,
+		int	num_lines, 
+		int	num_columns, 
+		int	begy, 
+		int	begx, 
 		int	flags)
 		{ return(*(WINDOW **)0); }
 
@@ -1790,26 +1800,26 @@
 
 #undef overlay
 int	overlay(
-		const WINDOW *win1,
+		const WINDOW *win1, 
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef overwrite
 int	overwrite(
-		const WINDOW *win1,
+		const WINDOW *win1, 
 		WINDOW	*win2)
 		{ return(*(int *)0); }
 
 #undef copywin
 int	copywin(
-		const WINDOW *src,
-		WINDOW	*dst,
-		int	sminrow,
-		int	smincol,
-		int	dminrow,
-		int	dmincol,
-		int	dmaxrow,
-		int	dmaxcol,
+		const WINDOW *src, 
+		WINDOW	*dst, 
+		int	sminrow, 
+		int	smincol, 
+		int	dminrow, 
+		int	dmincol, 
+		int	dmaxrow, 
+		int	dmaxcol, 
 		int	over)
 		{ return(*(int *)0); }
 
@@ -1817,44 +1827,44 @@
 
 #undef newpad
 WINDOW	*newpad(
-		int	l,
+		int	l, 
 		int	c)
 		{ return(*(WINDOW **)0); }
 
 #undef subpad
 WINDOW	*subpad(
-		WINDOW	*orig,
-		int	l,
-		int	c,
-		int	begy,
+		WINDOW	*orig, 
+		int	l, 
+		int	c, 
+		int	begy, 
 		int	begx)
 		{ return(*(WINDOW **)0); }
 
 #undef prefresh
 int	prefresh(
-		WINDOW	*win,
-		int	pminrow,
-		int	pmincol,
-		int	sminrow,
-		int	smincol,
-		int	smaxrow,
+		WINDOW	*win, 
+		int	pminrow, 
+		int	pmincol, 
+		int	sminrow, 
+		int	smincol, 
+		int	smaxrow, 
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pnoutrefresh
 int	pnoutrefresh(
-		WINDOW	*win,
-		int	pminrow,
-		int	pmincol,
-		int	sminrow,
-		int	smincol,
-		int	smaxrow,
+		WINDOW	*win, 
+		int	pminrow, 
+		int	pmincol, 
+		int	sminrow, 
+		int	smincol, 
+		int	smaxrow, 
 		int	smaxcol)
 		{ return(*(int *)0); }
 
 #undef pechochar
 int	pechochar(
-		WINDOW	*pad,
+		WINDOW	*pad, 
 		const chtype ch)
 		{ return(*(int *)0); }
 
@@ -1862,38 +1872,38 @@
 
 #undef printw
 int	printw(
-		const char *fmt,
+		const char *fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef wprintw
 int	wprintw(
-		WINDOW	*win,
-		const char *fmt,
+		WINDOW	*win, 
+		const char *fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef mvprintw
 int	mvprintw(
-		int	y,
-		int	x,
-		const char *fmt,
+		int	y, 
+		int	x, 
+		const char *fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwprintw
 int	mvwprintw(
-		WINDOW	*win,
-		int	y,
-		int	x,
-		const char *fmt,
+		WINDOW	*win, 
+		int	y, 
+		int	x, 
+		const char *fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef vwprintw
 int	vwprintw(
-		WINDOW	*win,
-		const char *fmt,
+		WINDOW	*win, 
+		const char *fmt, 
 		va_list	argp)
 		{ return(*(int *)0); }
 
@@ -1901,8 +1911,8 @@
 
 #undef wredrawln
 int	wredrawln(
-		WINDOW	*win,
-		int	beg,
+		WINDOW	*win, 
+		int	beg, 
 		int	num)
 		{ return(*(int *)0); }
 
@@ -1922,8 +1932,8 @@
 
 #undef restartterm
 int	restartterm(
-		char	*termp,
-		int	filenum,
+		char	*termp, 
+		int	filenum, 
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -1931,38 +1941,38 @@
 
 #undef vwscanw
 int	vwscanw(
-		WINDOW	*win,
-		char	*fmt,
+		WINDOW	*win, 
+		char	*fmt, 
 		va_list	argp)
 		{ return(*(int *)0); }
 
 #undef scanw
 int	scanw(
-		char	*fmt,
+		char	*fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef wscanw
 int	wscanw(
-		WINDOW	*win,
-		char	*fmt,
+		WINDOW	*win, 
+		char	*fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef mvscanw
 int	mvscanw(
-		int	y,
-		int	x,
-		char	*fmt,
+		int	y, 
+		int	x, 
+		char	*fmt, 
 		...)
 		{ return(*(int *)0); }
 
 #undef mvwscanw
 int	mvwscanw(
-		WINDOW	*win,
-		int	y,
-		int	x,
-		char	*fmt,
+		WINDOW	*win, 
+		int	y, 
+		int	x, 
+		char	*fmt, 
 		...)
 		{ return(*(int *)0); }
 
@@ -1975,7 +1985,7 @@
 
 #undef putwin
 int	putwin(
-		WINDOW	*win,
+		WINDOW	*win, 
 		FILE	*filep)
 		{ return(*(int *)0); }
 
@@ -2003,16 +2013,16 @@
 
 #undef _nc_scroll_window
 void	_nc_scroll_window(
-		WINDOW	*win,
-		int const n,
-		short const top,
-		short const bottom,
+		WINDOW	*win, 
+		int const n, 
+		short const top, 
+		short const bottom, 
 		cchar_t	blank)
 		{ /* void */ }
 
 #undef wscrl
 int	wscrl(
-		WINDOW	*win,
+		WINDOW	*win, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2020,7 +2030,7 @@
 
 #undef scrollok
 int	scrollok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2028,8 +2038,8 @@
 
 #undef wsetscrreg
 int	wsetscrreg(
-		WINDOW	*win,
-		int	top,
+		WINDOW	*win, 
+		int	top, 
 		int	bottom)
 		{ return(*(int *)0); }
 
@@ -2047,24 +2057,24 @@
 
 #undef _nc_setupscreen
 int	_nc_setupscreen(
-		short	slines,
-		short const scolumns,
+		short	slines, 
+		short const scolumns, 
 		FILE	*output)
 		{ return(*(int *)0); }
 
 #undef _nc_ripoffline
 int	_nc_ripoffline(
-		int	line,
+		int	line, 
 		int	(*init)(
-		WINDOW	*p1,
+		WINDOW	*p1, 
 		int	p2))
 		{ return(*(int *)0); }
 
 #undef ripoffline
 int	ripoffline(
-		int	line,
+		int	line, 
 		int	(*init)(
-		WINDOW	*p1,
+		WINDOW	*p1, 
 		int	p2))
 		{ return(*(int *)0); }
 
@@ -2075,7 +2085,7 @@
 
 #undef _nc_slk_initialize
 int	_nc_slk_initialize(
-		WINDOW	*stwin,
+		WINDOW	*stwin, 
 		int	cols)
 		{ return(*(int *)0); }
 
@@ -2087,8 +2097,8 @@
 
 #undef slk_attr_set
 int	slk_attr_set(
-		const attr_t attr,
-		short	color_pair_number,
+		const attr_t attr, 
+		short	color_pair_number, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2158,10 +2168,12 @@
 
 /* ./base/lib_slkset.c */
 
+#include <wctype.h>
+
 #undef slk_set
 int	slk_set(
-		int	i,
-		const char *astr,
+		int	i, 
+		const char *astr, 
 		int	format)
 		{ return(*(int *)0); }
 
@@ -2175,7 +2187,7 @@
 
 #undef is_linetouched
 NCURSES_BOOL is_linetouched(
-		WINDOW	*win,
+		WINDOW	*win, 
 		int	line)
 		{ return(*(NCURSES_BOOL *)0); }
 
@@ -2186,9 +2198,9 @@
 
 #undef wtouchln
 int	wtouchln(
-		WINDOW	*win,
-		int	y,
-		int	n,
+		WINDOW	*win, 
+		int	y, 
+		int	n, 
 		int	changed)
 		{ return(*(int *)0); }
 
@@ -2196,7 +2208,7 @@
 
 #undef _traceattr2
 char	*_traceattr2(
-		int	bufnum,
+		int	bufnum, 
 		attr_t	newmode)
 		{ return(*(char **)0); }
 
@@ -2212,13 +2224,13 @@
 
 #undef _nc_altcharset_name
 const char *_nc_altcharset_name(
-		attr_t	attr,
+		attr_t	attr, 
 		chtype	ch)
 		{ return(*(const char **)0); }
 
 #undef _tracechtype2
 char	*_tracechtype2(
-		int	bufnum,
+		int	bufnum, 
 		chtype	ch)
 		{ return(*(char **)0); }
 
@@ -2234,7 +2246,7 @@
 
 #undef _tracecchar_t2
 char	*_tracecchar_t2(
-		int	bufnum,
+		int	bufnum, 
 		const cchar_t *ch)
 		{ return(*(char **)0); }
 
@@ -2247,7 +2259,7 @@
 
 #undef _tracedump
 void	_tracedump(
-		const char *name,
+		const char *name, 
 		WINDOW	*win)
 		{ /* void */ }
 
@@ -2282,7 +2294,7 @@
 
 #undef vidputs
 int	vidputs(
-		chtype	newmode,
+		chtype	newmode, 
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -2300,8 +2312,8 @@
 
 #undef wvline
 int	wvline(
-		WINDOW	*win,
-		chtype	ch,
+		WINDOW	*win, 
+		chtype	ch, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2309,8 +2321,8 @@
 
 #undef wattr_off
 int	wattr_off(
-		WINDOW	*win,
-		attr_t	at,
+		WINDOW	*win, 
+		attr_t	at, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2318,8 +2330,8 @@
 
 #undef wattr_on
 int	wattr_on(
-		WINDOW	*win,
-		attr_t	at,
+		WINDOW	*win, 
+		attr_t	at, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2339,14 +2351,14 @@
 
 #undef mvderwin
 int	mvderwin(
-		WINDOW	*win,
-		int	y,
+		WINDOW	*win, 
+		int	y, 
 		int	x)
 		{ return(*(int *)0); }
 
 #undef syncok
 int	syncok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL bf)
 		{ return(*(int *)0); }
 
@@ -2380,7 +2392,7 @@
 
 #undef _nc_printf_string
 char	*_nc_printf_string(
-		const char *fmt,
+		const char *fmt, 
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2395,9 +2407,9 @@
 
 #undef _nc_scrolln
 int	_nc_scrolln(
-		int	n,
-		int	top,
-		int	bot,
+		int	n, 
+		int	top, 
+		int	bot, 
 		int	maxy)
 		{ return(*(int *)0); }
 
@@ -2420,9 +2432,13 @@
 
 /* ./trace/varargs.c */
 
+typedef enum {
+    atUnknown = 0, atInteger, atFloat, atPoint, atString
+} ARGTYPE;
+
 #undef _nc_varargs
 char	*_nc_varargs(
-		const char *fmt,
+		const char *fmt, 
 		va_list	ap)
 		{ return(*(char **)0); }
 
@@ -2467,13 +2483,13 @@
 
 #undef wadd_wch
 int	wadd_wch(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wecho_wchar
 int	wecho_wchar(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -2481,14 +2497,14 @@
 
 #undef wborder_set
 int	wborder_set(
-		WINDOW	*win,
-		const cchar_t *ls,
-		const cchar_t *rs,
-		const cchar_t *ts,
-		const cchar_t *bs,
-		const cchar_t *tl,
-		const cchar_t *tr,
-		const cchar_t *bl,
+		WINDOW	*win, 
+		const cchar_t *ls, 
+		const cchar_t *rs, 
+		const cchar_t *ts, 
+		const cchar_t *bs, 
+		const cchar_t *tl, 
+		const cchar_t *tr, 
+		const cchar_t *bl, 
 		const cchar_t *br)
 		{ return(*(int *)0); }
 
@@ -2496,19 +2512,19 @@
 
 #undef setcchar
 int	setcchar(
-		cchar_t	*wcval,
-		const wchar_t *wch,
-		const attr_t attrs,
-		short	color_pair,
+		cchar_t	*wcval, 
+		const wchar_t *wch, 
+		const attr_t attrs, 
+		short	color_pair, 
 		const void *opts)
 		{ return(*(int *)0); }
 
 #undef getcchar
 int	getcchar(
-		const cchar_t *wcval,
-		wchar_t	*wch,
-		attr_t	*attrs,
-		short	*color_pair,
+		const cchar_t *wcval, 
+		wchar_t	*wch, 
+		attr_t	*attrs, 
+		short	*color_pair, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2516,7 +2532,7 @@
 
 #undef wget_wch
 int	wget_wch(
-		WINDOW	*win,
+		WINDOW	*win, 
 		wint_t	*result)
 		{ return(*(int *)0); }
 
@@ -2536,8 +2552,8 @@
 
 #undef wgetn_wstr
 int	wgetn_wstr(
-		WINDOW	*win,
-		wint_t	*str,
+		WINDOW	*win, 
+		wint_t	*str, 
 		int	maxlen)
 		{ return(*(int *)0); }
 
@@ -2545,8 +2561,8 @@
 
 #undef whline_set
 int	whline_set(
-		WINDOW	*win,
-		const cchar_t *ch,
+		WINDOW	*win, 
+		const cchar_t *ch, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2554,7 +2570,7 @@
 
 #undef win_wch
 int	win_wch(
-		WINDOW	*win,
+		WINDOW	*win, 
 		cchar_t	*wcval)
 		{ return(*(int *)0); }
 
@@ -2562,8 +2578,8 @@
 
 #undef win_wchnstr
 int	win_wchnstr(
-		WINDOW	*win,
-		cchar_t	*wchstr,
+		WINDOW	*win, 
+		cchar_t	*wchstr, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2571,14 +2587,14 @@
 
 #undef wins_wch
 int	wins_wch(
-		WINDOW	*win,
+		WINDOW	*win, 
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
 #undef wins_nwstr
 int	wins_nwstr(
-		WINDOW	*win,
-		const wchar_t *wstr,
+		WINDOW	*win, 
+		const wchar_t *wstr, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2586,14 +2602,14 @@
 
 #undef winnwstr
 int	winnwstr(
-		WINDOW	*win,
-		wchar_t	*wstr,
+		WINDOW	*win, 
+		wchar_t	*wstr, 
 		int	n)
 		{ return(*(int *)0); }
 
 #undef winwstr
 int	winwstr(
-		WINDOW	*win,
+		WINDOW	*win, 
 		wchar_t	*wstr)
 		{ return(*(int *)0); }
 
@@ -2601,7 +2617,7 @@
 
 #undef pecho_wchar
 int	pecho_wchar(
-		WINDOW	*pad,
+		WINDOW	*pad, 
 		const cchar_t *wch)
 		{ return(*(int *)0); }
 
@@ -2609,13 +2625,20 @@
 
 #undef slk_wset
 int	slk_wset(
-		int	i,
-		const wchar_t *astr,
+		int	i, 
+		const wchar_t *astr, 
 		int	format)
 		{ return(*(int *)0); }
 
 /* ./widechar/lib_unget_wch.c */
 
+#undef _nc_wcrtomb
+size_t	_nc_wcrtomb(
+		char	*target, 
+		wchar_t	source, 
+		mbstate_t *state)
+		{ return(*(size_t *)0); }
+
 #undef unget_wch
 int	unget_wch(
 		const wchar_t wch)
@@ -2625,17 +2648,17 @@
 
 #undef vid_puts
 int	vid_puts(
-		attr_t	newmode,
-		short	pair,
-		void	*opts,
+		attr_t	newmode, 
+		short	pair, 
+		void	*opts, 
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
 
 #undef vid_attr
 int	vid_attr(
-		attr_t	newmode,
-		short	pair,
+		attr_t	newmode, 
+		short	pair, 
 		void	*opts)
 		{ return(*(int *)0); }
 
@@ -2647,8 +2670,8 @@
 
 #undef wvline_set
 int	wvline_set(
-		WINDOW	*win,
-		const cchar_t *ch,
+		WINDOW	*win, 
+		const cchar_t *ch, 
 		int	n)
 		{ return(*(int *)0); }
 
@@ -2672,7 +2695,7 @@
 
 #undef define_key
 int	define_key(
-		const char *str,
+		const char *str, 
 		int	keycode)
 		{ return(*(int *)0); }
 
@@ -2680,13 +2703,13 @@
 
 #undef _nc_toggle_attr_on
 void	_nc_toggle_attr_on(
-		attr_t	*S,
+		attr_t	*S, 
 		attr_t	at)
 		{ /* void */ }
 
 #undef _nc_toggle_attr_off
 void	_nc_toggle_attr_off(
-		attr_t	*S,
+		attr_t	*S, 
 		attr_t	at)
 		{ /* void */ }
 
@@ -2702,7 +2725,7 @@
 
 #undef _nc_UpdateAttrs
 void	_nc_UpdateAttrs(
-		chtype	c)
+		cchar_t	c)
 		{ /* void */ }
 
 /* ./base/key_defined.c */
@@ -2716,7 +2739,7 @@
 
 #undef keybound
 char	*keybound(
-		int	code,
+		int	code, 
 		int	count)
 		{ return(*(char **)0); }
 
@@ -2724,7 +2747,7 @@
 
 #undef keyok
 int	keyok(
-		int	c,
+		int	c, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -2736,7 +2759,7 @@
 
 #undef assume_default_colors
 int	assume_default_colors(
-		int	fg,
+		int	fg, 
 		int	bg)
 		{ return(*(int *)0); }
 
@@ -2744,7 +2767,7 @@
 
 #undef mcprint
 int	mcprint(
-		char	*data,
+		char	*data, 
 		int	len)
 		{ return(*(int *)0); }
 
@@ -2752,19 +2775,19 @@
 
 #undef is_term_resized
 NCURSES_BOOL is_term_resized(
-		int	ToLines,
+		int	ToLines, 
 		int	ToCols)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef resize_term
 int	resize_term(
-		int	ToLines,
+		int	ToLines, 
 		int	ToCols)
 		{ return(*(int *)0); }
 
 #undef resizeterm
 int	resizeterm(
-		int	ToLines,
+		int	ToLines, 
 		int	ToCols)
 		{ return(*(int *)0); }
 
@@ -2779,41 +2802,37 @@
 
 #undef _nc_expand_try
 char	*_nc_expand_try(
-		struct tries *tree,
-		unsigned short code,
-		int	*count,
+		struct tries *tree, 
+		unsigned short code, 
+		int	*count, 
 		size_t	len)
 		{ return(*(char **)0); }
 
 #undef _nc_remove_key
 int	_nc_remove_key(
-		struct tries **tree,
+		struct tries **tree, 
 		unsigned short code)
 		{ return(*(int *)0); }
 
 #undef _nc_remove_string
 int	_nc_remove_string(
-		struct tries **tree,
+		struct tries **tree, 
 		const char *string)
 		{ return(*(int *)0); }
 
-/* ./base/version.c */
-
-#undef curses_version
-const char *curses_version(void)
-		{ return(*(const char **)0); }
-
 /* ./base/wresize.c */
 
 #undef wresize
 int	wresize(
-		WINDOW	*win,
-		int	ToLines,
+		WINDOW	*win, 
+		int	ToLines, 
 		int	ToCols)
 		{ return(*(int *)0); }
 
 /* ./tinfo/access.c */
 
+#include <nc_alloc.h>
+
 #undef _nc_rootname
 char	*_nc_rootname(
 		char	*path)
@@ -2831,7 +2850,7 @@
 
 #undef _nc_access
 int	_nc_access(
-		const char *path,
+		const char *path, 
 		int	mode)
 		{ return(*(int *)0); }
 
@@ -2843,8 +2862,8 @@
 
 #undef _nc_add_to_try
 void	_nc_add_to_try(
-		struct tries **tree,
-		const char *str,
+		struct tries **tree, 
+		const char *str, 
 		unsigned short code)
 		{ /* void */ }
 
@@ -2867,13 +2886,13 @@
 
 #undef _nc_wrap_entry
 void	_nc_wrap_entry(
-		ENTRY	*const ep,
+		ENTRY	*const ep, 
 		NCURSES_BOOL copy_strings)
 		{ /* void */ }
 
 #undef _nc_merge_entry
 void	_nc_merge_entry(
-		TERMTYPE *const to,
+		TERMTYPE *const to, 
 		TERMTYPE *const from)
 		{ /* void */ }
 
@@ -2881,13 +2900,13 @@
 
 #undef _nc_align_termtype
 void	_nc_align_termtype(
-		TERMTYPE *to,
+		TERMTYPE *to, 
 		TERMTYPE *from)
 		{ /* void */ }
 
 #undef _nc_copy_termtype
 void	_nc_copy_termtype(
-		TERMTYPE *dst,
+		TERMTYPE *dst, 
 		TERMTYPE *src)
 		{ /* void */ }
 
@@ -2895,15 +2914,15 @@
 
 #undef _nc_captoinfo
 char	*_nc_captoinfo(
-		const char *cap,
-		const char *s,
+		const char *cap, 
+		const char *s, 
 		int const parameterized)
 		{ return(*(char **)0); }
 
 #undef _nc_infotocap
 char	*_nc_infotocap(
-		const char *cap,
-		const char *str,
+		const char *cap, 
+		const char *str, 
 		int const parameterized)
 		{ return(*(char **)0); }
 
@@ -2965,19 +2984,19 @@
 
 #undef _nc_warning
 void	_nc_warning(
-		const char *const fmt,
+		const char *const fmt, 
 		...)
 		{ /* void */ }
 
 #undef _nc_err_abort
 void	_nc_err_abort(
-		const char *const fmt,
+		const char *const fmt, 
 		...)
 		{ /* void */ }
 
 #undef _nc_syserr_abort
 void	_nc_syserr_abort(
-		const char *const fmt,
+		const char *const fmt, 
 		...)
 		{ /* void */ }
 
@@ -2985,8 +3004,8 @@
 
 #undef _nc_tic_expand
 char	*_nc_tic_expand(
-		const char *srcp,
-		NCURSES_BOOL tic_format,
+		const char *srcp, 
+		NCURSES_BOOL tic_format, 
 		int	numbers)
 		{ return(*(char **)0); }
 
@@ -2996,19 +3015,23 @@
 
 #undef _nc_find_entry
 struct name_table_entry const *_nc_find_entry(
-		const char *string,
+		const char *string, 
 		const struct name_table_entry *const *hash_table)
 		{ return(*(struct name_table_entry const **)0); }
 
 #undef _nc_find_type_entry
 struct name_table_entry const *_nc_find_type_entry(
-		const char *string,
-		int	type,
+		const char *string, 
+		int	type, 
 		const struct name_table_entry *table)
 		{ return(*(struct name_table_entry const **)0); }
 
 /* ./tinfo/comp_parse.c */
 
+#undef _nc_check_termtype2
+void	(*_nc_check_termtype2)(
+		TERMTYPE *p1, 
+		NCURSES_BOOL p2);
 #undef _nc_check_termtype
 void	(*_nc_check_termtype)(
 		TERMTYPE *p1);
@@ -3024,20 +3047,26 @@
 
 #undef _nc_entry_match
 NCURSES_BOOL _nc_entry_match(
-		char	*n1,
+		char	*n1, 
 		char	*n2)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_read_entry_source
 void	_nc_read_entry_source(
-		FILE	*fp,
-		char	*buf,
-		int	literal,
-		NCURSES_BOOL silent,
+		FILE	*fp, 
+		char	*buf, 
+		int	literal, 
+		NCURSES_BOOL silent, 
 		NCURSES_BOOL (*hook)(
 		ENTRY	*p1))
 		{ /* void */ }
 
+#undef _nc_resolve_uses2
+int	_nc_resolve_uses2(
+		NCURSES_BOOL fullresolve, 
+		NCURSES_BOOL literal)
+		{ return(*(int *)0); }
+
 #undef _nc_resolve_uses
 int	_nc_resolve_uses(
 		NCURSES_BOOL fullresolve)
@@ -3060,16 +3089,22 @@
 #undef _nc_disable_period
 NCURSES_BOOL _nc_disable_period;
 
+#undef _nc_reset_input
+void	_nc_reset_input(
+		FILE	*fp, 
+		char	*buf)
+		{ /* void */ }
+
 #undef _nc_get_token
 int	_nc_get_token(
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_trans_string
-char	_nc_trans_string(
-		char	*ptr,
+int	_nc_trans_string(
+		char	*ptr, 
 		char	*last)
-		{ return(*(char *)0); }
+		{ return(*(int *)0); }
 
 #undef _nc_push_token
 void	_nc_push_token(
@@ -3081,17 +3116,11 @@
 		char	ch)
 		{ /* void */ }
 
-#undef _nc_reset_input
-void	_nc_reset_input(
-		FILE	*fp,
-		char	*buf)
-		{ /* void */ }
-
 /* ./tinfo/doalloc.c */
 
 #undef _nc_doalloc
 void	*_nc_doalloc(
-		void	*oldp,
+		void	*oldp, 
 		size_t	amount)
 		{ return(*(void **)0); }
 
@@ -3158,6 +3187,11 @@
 
 #include <termcap.h>
 
+struct speed {
+    int s; 
+    int sp; 
+};
+
 #undef _nc_baudrate
 int	_nc_baudrate(
 		int	OSpeed)
@@ -3258,13 +3292,13 @@
 
 #undef idlok
 int	idlok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef idcok
 void	idcok(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ /* void */ }
 
@@ -3275,31 +3309,31 @@
 
 #undef nodelay
 int	nodelay(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef notimeout
 int	notimeout(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL f)
 		{ return(*(int *)0); }
 
 #undef wtimeout
 void	wtimeout(
-		WINDOW	*win,
+		WINDOW	*win, 
 		int	delay)
 		{ /* void */ }
 
 #undef keypad
 int	keypad(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 #undef meta
 int	meta(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
@@ -3351,13 +3385,15 @@
 
 #undef intrflush
 int	intrflush(
-		WINDOW	*win,
+		WINDOW	*win, 
 		NCURSES_BOOL flag)
 		{ return(*(int *)0); }
 
 /* ./tinfo/lib_setup.c */
 
+#include <locale.h>
 #include <sys/ioctl.h>
+#include <langinfo.h>
 
 #undef ttytype
 char	ttytype[256];
@@ -3389,10 +3425,18 @@
 int	_nc_locale_breaks_acs(void)
 		{ return(*(int *)0); }
 
+#undef _nc_setupterm
+int	_nc_setupterm(
+		char	*tname, 
+		int	Filedes, 
+		int	*errret, 
+		NCURSES_BOOL reuse)
+		{ return(*(int *)0); }
+
 #undef setupterm
 int	setupterm(
-		char	*tname,
-		int	Filedes,
+		char	*tname, 
+		int	Filedes, 
 		int	*errret)
 		{ return(*(int *)0); }
 
@@ -3405,7 +3449,7 @@
 
 #undef tgetent
 int	tgetent(
-		char	*bufp,
+		char	*bufp, 
 		const char *name)
 		{ return(*(int *)0); }
 
@@ -3427,7 +3471,7 @@
 
 #undef tgetstr
 char	*tgetstr(
-		char	*id,
+		char	*id, 
 		char	**area)
 		{ return(*(char **)0); }
 
@@ -3441,8 +3485,8 @@
 
 #undef tgoto
 char	*tgoto(
-		const char *string,
-		int	x,
+		const char *string, 
+		int	x, 
 		int	y)
 		{ return(*(char **)0); }
 
@@ -3465,19 +3509,27 @@
 
 /* ./tinfo/lib_tparm.c */
 
+typedef struct {
+    union {
+        int num;
+        char *str;
+    } data;
+    NCURSES_BOOL num_type;
+} stack_frame;
+
 #undef _nc_tparm_err
 int	_nc_tparm_err;
 
 #undef _nc_tparm_analyze
 int	_nc_tparm_analyze(
-		const char *string,
-		char	*p_is_s[9],
+		const char *string, 
+		char	*p_is_s[9], 
 		int	*popcount)
 		{ return(*(int *)0); }
 
 #undef tparm
 char	*tparm(
-		char	*string,
+		char	*string, 
 		...)
 		{ return(*(char **)0); }
 
@@ -3511,8 +3563,8 @@
 
 #undef tputs
 int	tputs(
-		const char *string,
-		int	affcnt,
+		const char *string, 
+		int	affcnt, 
 		int	(*outc)(
 		int	p1))
 		{ return(*(int *)0); }
@@ -3533,7 +3585,7 @@
 
 #undef _tracef
 void	_tracef(
-		const char *fmt,
+		const char *fmt, 
 		...)
 		{ /* void */ }
 
@@ -3557,6 +3609,21 @@
 		char	*code)
 		{ return(*(char **)0); }
 
+#undef _nc_retrace_cptr
+const char *_nc_retrace_cptr(
+		const char *code)
+		{ return(*(const char **)0); }
+
+#undef _nc_retrace_cvoid_ptr
+void	*_nc_retrace_cvoid_ptr(
+		void	*code)
+		{ return(*(void **)0); }
+
+#undef _nc_retrace_void_ptr
+void	*_nc_retrace_void_ptr(
+		void	*code)
+		{ return(*(void **)0); }
+
 #undef _nc_retrace_sp
 SCREEN	*_nc_retrace_sp(
 		SCREEN	*code)
@@ -3569,6 +3636,11 @@
 
 /* ./trace/lib_tracebits.c */
 
+typedef struct {
+    unsigned int val;
+    const char *name;
+} BITNAMES;
+
 #undef _nc_trace_ttymode
 char	*_nc_trace_ttymode(
 		struct termios *tty)
@@ -3625,8 +3697,8 @@
 
 #undef _nc_timed_wait
 int	_nc_timed_wait(
-		int	mode,
-		int	milliseconds,
+		int	mode, 
+		int	milliseconds, 
 		int	*timeleft)
 		{ return(*(int *)0); }
 
@@ -3639,8 +3711,8 @@
 
 #undef _nc_name_match
 int	_nc_name_match(
-		const char *const namelst,
-		const char *const name,
+		const char *const namelst, 
+		const char *const name, 
 		const char *const delim)
 		{ return(*(int *)0); }
 
@@ -3663,17 +3735,22 @@
 
 #undef _nc_parse_entry
 int	_nc_parse_entry(
-		struct entry *entryp,
-		int	literal,
+		struct entry *entryp, 
+		int	literal, 
 		NCURSES_BOOL silent)
 		{ return(*(int *)0); }
 
 #undef _nc_capcmp
 int	_nc_capcmp(
-		const char *s,
+		const char *s, 
 		const char *t)
 		{ return(*(int *)0); }
 
+typedef struct {
+    const char *from;
+    const char *to;
+} assoc;
+
 /* ./tinfo/read_entry.c */
 
 #undef _nc_tic_dir
@@ -3688,22 +3765,25 @@
 
 #undef _nc_read_file_entry
 int	_nc_read_file_entry(
-		const char *const filename,
+		const char *const filename, 
 		TERMTYPE *ptr)
 		{ return(*(int *)0); }
 
 #undef _nc_read_entry
 int	_nc_read_entry(
-		const char *const tn,
-		char	*const filename,
+		const char *const tn, 
+		char	*const filename, 
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
 /* ./tinfo/read_termcap.c */
 
+#include <sys/types.h>
+#include <sys/stat.h>
+
 #undef _nc_read_termcap_entry
 int	_nc_read_termcap_entry(
-		const char *const tn,
+		const char *const tn, 
 		TERMTYPE *const tp)
 		{ return(*(int *)0); }
 
@@ -3711,7 +3791,7 @@
 
 #undef _nc_set_buffer
 void	_nc_set_buffer(
-		FILE	*ofp,
+		FILE	*ofp, 
 		NCURSES_BOOL buffered)
 		{ /* void */ }
 
@@ -3719,46 +3799,51 @@
 
 #undef _nc_str_init
 string_desc *_nc_str_init(
-		string_desc *dst,
-		char	*src,
+		string_desc *dst, 
+		char	*src, 
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_null
 string_desc *_nc_str_null(
-		string_desc *dst,
+		string_desc *dst, 
 		size_t	len)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_str_copy
 string_desc *_nc_str_copy(
-		string_desc *dst,
+		string_desc *dst, 
 		string_desc *src)
 		{ return(*(string_desc **)0); }
 
 #undef _nc_safe_strcat
 NCURSES_BOOL _nc_safe_strcat(
-		string_desc *dst,
+		string_desc *dst, 
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 #undef _nc_safe_strcpy
 NCURSES_BOOL _nc_safe_strcpy(
-		string_desc *dst,
+		string_desc *dst, 
 		const char *src)
 		{ return(*(NCURSES_BOOL *)0); }
 
 /* ./trace/trace_buf.c */
 
+typedef struct {
+    char *text;
+    size_t size;
+} LIST;
+
 #undef _nc_trace_buf
 char	*_nc_trace_buf(
-		int	bufnum,
+		int	bufnum, 
 		size_t	want)
 		{ return(*(char **)0); }
 
 #undef _nc_trace_bufcat
 char	*_nc_trace_bufcat(
-		int	bufnum,
+		int	bufnum, 
 		const char *value)
 		{ return(*(char **)0); }
 
@@ -3780,7 +3865,7 @@
 
 #undef _nc_visbuf2
 const char *_nc_visbuf2(
-		int	bufnum,
+		int	bufnum, 
 		const char *buf)
 		{ return(*(const char **)0); }
 
@@ -3791,13 +3876,13 @@
 
 #undef _nc_visbufn
 const char *_nc_visbufn(
-		const char *buf,
+		const char *buf, 
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viswbuf2
 const char *_nc_viswbuf2(
-		int	bufnum,
+		int	bufnum, 
 		const wchar_t *buf)
 		{ return(*(const char **)0); }
 
@@ -3808,20 +3893,25 @@
 
 #undef _nc_viswbufn
 const char *_nc_viswbufn(
-		const wchar_t *buf,
+		const wchar_t *buf, 
 		int	len)
 		{ return(*(const char **)0); }
 
+#undef _nc_viswibuf
+const char *_nc_viswibuf(
+		const wint_t *buf)
+		{ return(*(const char **)0); }
+
 #undef _nc_viscbuf2
 const char *_nc_viscbuf2(
-		int	bufnum,
-		const cchar_t *buf,
+		int	bufnum, 
+		const cchar_t *buf, 
 		int	len)
 		{ return(*(const char **)0); }
 
 #undef _nc_viscbuf
 const char *_nc_viscbuf(
-		const cchar_t *buf,
+		const cchar_t *buf, 
 		int	len)
 		{ return(*(const char **)0); }
 
@@ -3840,3 +3930,9 @@
 #undef _nc_tic_written
 int	_nc_tic_written(void)
 		{ return(*(int *)0); }
+
+/* ./base/version.c */
+
+#undef curses_version
+const char *curses_version(void)
+		{ return(*(const char **)0); }
diff -Naur ncurses-5.4.orig/ncurses/modules ncurses-5.4/ncurses/modules
--- ncurses-5.4.orig/ncurses/modules	2004-01-10 19:08:23.000000000 +0000
+++ ncurses-5.4/ncurses/modules	2005-05-13 04:09:50.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: modules,v 1.100 2004/01/10 19:08:23 tom Exp $
+# $Id: modules,v 1.101 2004/02/29 01:18:06 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2003,2004 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"), #
@@ -61,6 +61,7 @@
 lib_initscr	lib		$(base)		$(INCDIR)/tic.h
 lib_insch	lib		$(base)
 lib_insdel	lib		$(base)
+lib_insnstr	lib		$(base)
 lib_instr	lib		$(base)
 lib_isendwin	lib		$(base)
 lib_leaveok	lib		$(base)
diff -Naur ncurses-5.4.orig/ncurses/tinfo/alloc_entry.c ncurses-5.4/ncurses/tinfo/alloc_entry.c
--- ncurses-5.4.orig/ncurses/tinfo/alloc_entry.c	2003-11-08 21:29:54.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/alloc_entry.c	2005-05-13 04:09:56.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,7 +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-2003               *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 /*
@@ -48,7 +48,7 @@
 #include <tic.h>
 #include <term_entry.h>
 
-MODULE_ID("$Id: alloc_entry.c,v 1.40 2003/11/08 21:29:54 tom Exp $")
+MODULE_ID("$Id: alloc_entry.c,v 1.44 2005/04/03 13:56:10 tom Exp $")
 
 #define ABSENT_OFFSET    -1
 #define CANCELLED_OFFSET -2
@@ -59,11 +59,18 @@
 static size_t next_free;	/* next free character in stringbuf */
 
 NCURSES_EXPORT(void)
-_nc_init_entry(TERMTYPE * const tp)
+_nc_init_entry(TERMTYPE *const tp)
 /* initialize a terminal type data block */
 {
     unsigned i;
 
+#if NO_LEAKS
+    if (tp == 0 && stringbuf != 0) {
+	FreeAndNull(stringbuf);
+	return;
+    }
+#endif
+
     if (stringbuf == 0)
 	stringbuf = (char *) malloc(MAX_STRTAB);
 
@@ -106,20 +113,32 @@
     return newp;
 }
 
+/* save a copy of string in the string buffer */
 NCURSES_EXPORT(char *)
 _nc_save_str(const char *const string)
-/* save a copy of string in the string buffer */
 {
+    char *result = 0;
     size_t old_next_free = next_free;
     size_t len = strlen(string) + 1;
 
-    if (next_free + len < MAX_STRTAB) {
+    if (len == 1 && next_free != 0) {
+	/*
+	 * Cheat a little by making an empty string point to the end of the
+	 * previous string.
+	 */
+	if (next_free < MAX_STRTAB) {
+	    result = (stringbuf + next_free - 1);
+	}
+    } else if (next_free + len < MAX_STRTAB) {
 	strcpy(&stringbuf[next_free], string);
 	DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
 	DEBUG(7, ("at location %d", (int) next_free));
 	next_free += len;
+	result = (stringbuf + old_next_free);
+    } else {
+	_nc_warning("Too much data, some is lost");
     }
-    return (stringbuf + old_next_free);
+    return result;
 }
 
 NCURSES_EXPORT(void)
@@ -211,7 +230,7 @@
 }
 
 NCURSES_EXPORT(void)
-_nc_merge_entry(TERMTYPE * const to, TERMTYPE * const from)
+_nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
 /* merge capabilities from `from' entry into `to' entry */
 {
     unsigned i;
@@ -220,7 +239,7 @@
     _nc_align_termtype(to, from);
 #endif
     for_each_boolean(i, from) {
-	if (to->Booleans[i] != CANCELLED_BOOLEAN) {
+	if (to->Booleans[i] != (char) CANCELLED_BOOLEAN) {
 	    int mergebool = from->Booleans[i];
 
 	    if (mergebool == CANCELLED_BOOLEAN)
diff -Naur ncurses-5.4.orig/ncurses/tinfo/captoinfo.c ncurses-5.4/ncurses/tinfo/captoinfo.c
--- ncurses-5.4.orig/ncurses/tinfo/captoinfo.c	2003-11-08 21:28:04.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/captoinfo.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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                 *
  ****************************************************************************/
 
 /*
@@ -92,7 +93,7 @@
 #include <ctype.h>
 #include <tic.h>
 
-MODULE_ID("$Id: captoinfo.c,v 1.45 2003/11/08 21:28:04 tom Exp $")
+MODULE_ID("$Id: captoinfo.c,v 1.46 2004/08/28 18:08:50 tom Exp $")
 
 #define MAX_PUSHED	16	/* max # args we can push onto the stack */
 
@@ -276,7 +277,7 @@
  *	% translations if 1
  *	pad translations if >=0
  */
-char *
+NCURSES_EXPORT(char *)
 _nc_captoinfo(const char *cap, const char *s, int const parameterized)
 {
     const char *capstart;
@@ -636,7 +637,7 @@
  * Convert a terminfo string to termcap format.  Parameters are as in
  * _nc_captoinfo().
  */
-char *
+NCURSES_EXPORT(char *)
 _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameterized)
 {
     int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
@@ -678,6 +679,7 @@
 	    --str;
 	} else if (str[0] == '%' && str[1] == '%') {	/* escaped '%' */
 	    bufptr = save_string(bufptr, "%%");
+	    ++str;
 	} else if (*str != '%' || (parameterized < 1)) {
 	    bufptr = save_char(bufptr, *str);
 	} else if (sscanf(str, "%%?%%{%d}%%>%%t%%{%d}%%+%%;", &c1, &c2) == 2) {
diff -Naur ncurses-5.4.orig/ncurses/tinfo/comp_error.c ncurses-5.4/ncurses/tinfo/comp_error.c
--- ncurses-5.4.orig/ncurses/tinfo/comp_error.c	2002-09-07 20:05:07.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/comp_error.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2002,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -40,7 +41,7 @@
 
 #include <tic.h>
 
-MODULE_ID("$Id: comp_error.c,v 1.25 2002/09/07 20:05:07 tom Exp $")
+MODULE_ID("$Id: comp_error.c,v 1.28 2005/01/22 21:31:48 tom Exp $")
 
 NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE;
 NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */
@@ -70,7 +71,14 @@
 NCURSES_EXPORT(void)
 _nc_get_type(char *name)
 {
-    strcpy(name, termtype != 0 ? termtype : "");
+#if NO_LEAKS
+    if (name == 0 && termtype != 0) {
+	FreeAndNull(termtype);
+	return;
+    }
+#endif
+    if (name != 0)
+	strcpy(name, termtype != 0 ? termtype : "");
 }
 
 static inline void
diff -Naur ncurses-5.4.orig/ncurses/tinfo/comp_parse.c ncurses-5.4/ncurses/tinfo/comp_parse.c
--- ncurses-5.4.orig/ncurses/tinfo/comp_parse.c	2003-10-25 22:25:36.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/comp_parse.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,18 +29,19 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 /*
  *	comp_parse.c -- parser driver loop and use handling.
  *
  *	_nc_read_entry_source(FILE *, literal, bool, bool (*hook)())
- *	_nc_resolve_uses(void)
+ *	_nc_resolve_uses2(void)
  *	_nc_free_entries(void)
  *
  *	Use this code by calling _nc_read_entry_source() on as many source
  *	files as you like (either terminfo or termcap syntax).  If you
- *	want use-resolution, call _nc_resolve_uses().  To free the list
+ *	want use-resolution, call _nc_resolve_uses2().  To free the list
  *	storage, do _nc_free_entries().
  *
  */
@@ -52,8 +53,12 @@
 #include <tic.h>
 #include <term_entry.h>
 
-MODULE_ID("$Id: comp_parse.c,v 1.57 2003/10/25 22:25:36 tom Exp $")
+MODULE_ID("$Id: comp_parse.c,v 1.59 2004/07/05 12:01:24 tom Exp $")
 
+static void sanity_check2(TERMTYPE *, bool);
+NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanity_check2;
+
+/* obsolete: 20040705 */
 static void sanity_check(TERMTYPE *);
 NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype) (TERMTYPE *) = sanity_check;
 
@@ -105,13 +110,7 @@
     ENTRY *ep, *next;
 
     for (ep = headp; ep; ep = next) {
-	/*
-	 * This conditional lets us disconnect storage from the list.
-	 * To do this, copy an entry out of the list, then null out
-	 * the string-table member in the original and any use entries
-	 * it references.
-	 */
-	FreeIfNeeded(ep->tterm.str_table);
+	_nc_free_termtype(&(ep->tterm));
 
 	next = ep->next;
 
@@ -188,10 +187,14 @@
 	 * use references to disk, so as to avoid chewing up a lot of
 	 * core when the resolution code could fetch entries off disk.
 	 */
-	if (hook != NULLHOOK && (*hook) (&thisentry))
+	if (hook != NULLHOOK && (*hook) (&thisentry)) {
 	    immediate++;
-	else
+	} else {
 	    enqueue(&thisentry);
+	    FreeIfNeeded(thisentry.tterm.Booleans);
+	    FreeIfNeeded(thisentry.tterm.Numbers);
+	    FreeIfNeeded(thisentry.tterm.Strings);
+	}
     }
 
     if (_nc_tail) {
@@ -211,7 +214,7 @@
 }
 
 NCURSES_EXPORT(int)
-_nc_resolve_uses(bool fullresolve)
+_nc_resolve_uses2(bool fullresolve, bool literal)
 /* try to resolve all use capabilities */
 {
     ENTRY *qp, *rp, *lastread = 0;
@@ -406,7 +409,7 @@
 	    for_entry_list(qp) {
 		_nc_curr_line = qp->startline;
 		_nc_set_type(_nc_first_name(qp->tterm.term_names));
-		_nc_check_termtype(&qp->tterm);
+		_nc_check_termtype2(&qp->tterm, literal);
 	    }
 	    DEBUG(2, ("SANITY CHECK FINISHED"));
 	}
@@ -414,6 +417,13 @@
     return (TRUE);
 }
 
+/* obsolete: 20040705 */
+NCURSES_EXPORT(int)
+_nc_resolve_uses(bool fullresolve)
+{
+    return _nc_resolve_uses2(fullresolve, FALSE);
+}
+
 /*
  * This bit of legerdemain turns all the terminfo variable names into
  * references to locations in the arrays Booleans, Numbers, and Strings ---
@@ -424,7 +434,7 @@
 #define CUR tp->
 
 static void
-sanity_check(TERMTYPE * tp)
+sanity_check2(TERMTYPE *tp, bool literal)
 {
     if (!PRESENT(exit_attribute_mode)) {
 #ifdef __UNUSED__		/* this casts too wide a net */
@@ -448,15 +458,17 @@
     /* we do this check/fix in postprocess_termcap(), but some packagers
      * prefer to bypass it...
      */
-    if (acs_chars == 0
-	&& enter_alt_charset_mode != 0
-	&& exit_alt_charset_mode != 0)
-	acs_chars = strdup(VT_ACSC);
+    if (!literal) {
+	if (acs_chars == 0
+	    && enter_alt_charset_mode != 0
+	    && exit_alt_charset_mode != 0)
+	    acs_chars = strdup(VT_ACSC);
+	ANDMISSING(enter_alt_charset_mode, acs_chars);
+	ANDMISSING(exit_alt_charset_mode, acs_chars);
+    }
 
     /* listed in structure-member order of first argument */
     PAIRED(enter_alt_charset_mode, exit_alt_charset_mode);
-    ANDMISSING(enter_alt_charset_mode, acs_chars);
-    ANDMISSING(exit_alt_charset_mode, acs_chars);
     ANDMISSING(enter_blink_mode, exit_attribute_mode);
     ANDMISSING(enter_bold_mode, exit_attribute_mode);
     PAIRED(exit_ca_mode, enter_ca_mode);
@@ -479,3 +491,10 @@
 #endif
     ANDMISSING(set_color_pair, initialize_pair);
 }
+
+/* obsolete: 20040705 */
+static void
+sanity_check(TERMTYPE *tp)
+{
+    sanity_check2(tp, FALSE);
+}
diff -Naur ncurses-5.4.orig/ncurses/tinfo/comp_scan.c ncurses-5.4/ncurses/tinfo/comp_scan.c
--- ncurses-5.4.orig/ncurses/tinfo/comp_scan.c	2003-12-14 00:32:40.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/comp_scan.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -50,7 +51,7 @@
 #include <term_entry.h>
 #include <tic.h>
 
-MODULE_ID("$Id: comp_scan.c,v 1.66 2003/12/14 00:32:40 tom Exp $")
+MODULE_ID("$Id: comp_scan.c,v 1.74 2005/04/16 16:42:09 tom Exp $")
 
 /*
  * Maximum length of string capability we'll accept before raising an error.
@@ -94,11 +95,193 @@
 _nc_disable_period = FALSE;	/* used by tic -a option */
 #endif
 
-static bool end_of_stream(void);
-static int last_char(void);
-static int next_char(void);
-static long stream_pos(void);
-static void push_back(char c);
+/*****************************************************************************
+ *
+ * Character-stream handling
+ *
+ *****************************************************************************/
+
+#define LEXBUFSIZ	1024
+
+static char *bufptr;		/* otherwise, the input buffer pointer */
+static char *bufstart;		/* start of buffer so we can compute offsets */
+static FILE *yyin;		/* scanner's input file descriptor */
+
+/*
+ *	_nc_reset_input()
+ *
+ *	Resets the input-reading routines.  Used on initialization,
+ *	or after a seek has been done.  Exactly one argument must be
+ *	non-null.
+ */
+
+NCURSES_EXPORT(void)
+_nc_reset_input(FILE *fp, char *buf)
+{
+    pushtype = NO_PUSHBACK;
+    if (pushname != 0)
+	pushname[0] = '\0';
+    yyin = fp;
+    bufstart = bufptr = buf;
+    _nc_curr_file_pos = 0L;
+    if (fp != 0)
+	_nc_curr_line = 0;
+    _nc_curr_col = 0;
+}
+
+/*
+ *	int last_char()
+ *
+ *	Returns the final nonblank character on the current input buffer
+ */
+static int
+last_char(void)
+{
+    size_t len = strlen(bufptr);
+    while (len--) {
+	if (!isspace(UChar(bufptr[len])))
+	    return bufptr[len];
+    }
+    return 0;
+}
+
+/*
+ *	int next_char()
+ *
+ *	Returns the next character in the input stream.  Comments and leading
+ *	white space are stripped.
+ *
+ *	The global state variable 'firstcolumn' is set TRUE if the character
+ *	returned is from the first column of the input line.
+ *
+ *	The global variable _nc_curr_line is incremented for each new line.
+ *	The global variable _nc_curr_file_pos is set to the file offset of the
+ *	beginning of each line.
+ */
+
+static int
+next_char(void)
+{
+    static char *result;
+    static size_t allocated;
+    int the_char;
+
+    if (!yyin) {
+	if (result != 0) {
+	    FreeAndNull(result);
+	    FreeAndNull(pushname);
+	    allocated = 0;
+	}
+	/*
+	 * An string with an embedded null will truncate the input.  This is
+	 * intentional (we don't read binary files here).
+	 */
+	if (bufptr == 0 || *bufptr == '\0')
+	    return (EOF);
+	if (*bufptr == '\n') {
+	    _nc_curr_line++;
+	    _nc_curr_col = 0;
+	} else if (*bufptr == '\t') {
+	    _nc_curr_col = (_nc_curr_col | 7);
+	}
+    } else if (!bufptr || !*bufptr) {
+	/*
+	 * In theory this could be recoded to do its I/O one character at a
+	 * time, saving the buffer space.  In practice, this turns out to be
+	 * quite hard to get completely right.  Try it and see.  If you
+	 * succeed, don't forget to hack push_back() correspondingly.
+	 */
+	size_t used;
+	size_t len;
+
+	do {
+	    bufstart = 0;
+	    used = 0;
+	    do {
+		if (used + (LEXBUFSIZ / 4) >= allocated) {
+		    allocated += (allocated + LEXBUFSIZ);
+		    result = typeRealloc(char, allocated, result);
+		    if (result == 0)
+			return (EOF);
+		}
+		if (used == 0)
+		    _nc_curr_file_pos = ftell(yyin);
+
+		if (fgets(result + used, (int) (allocated - used), yyin) != 0) {
+		    bufstart = result;
+		    if (used == 0) {
+			_nc_curr_line++;
+			_nc_curr_col = 0;
+		    }
+		} else {
+		    if (used != 0)
+			strcat(result, "\n");
+		}
+		if ((bufptr = bufstart) != 0) {
+		    used = strlen(bufptr);
+		    while (iswhite(*bufptr)) {
+			if (*bufptr == '\t') {
+			    _nc_curr_col = (_nc_curr_col | 7) + 1;
+			} else {
+			    _nc_curr_col++;
+			}
+			bufptr++;
+		    }
+
+		    /*
+		     * Treat a trailing <cr><lf> the same as a <newline> so we
+		     * can read files on OS/2, etc.
+		     */
+		    if ((len = strlen(bufptr)) > 1) {
+			if (bufptr[len - 1] == '\n'
+			    && bufptr[len - 2] == '\r') {
+			    len--;
+			    bufptr[len - 1] = '\n';
+			    bufptr[len] = '\0';
+			}
+		    }
+		} else {
+		    return (EOF);
+		}
+	    } while (bufptr[len - 1] != '\n');	/* complete a line */
+	} while (result[0] == '#');	/* ignore comments */
+    } else if (*bufptr == '\t') {
+	_nc_curr_col = (_nc_curr_col | 7);
+    }
+
+    first_column = (bufptr == bufstart);
+    if (first_column)
+	had_newline = FALSE;
+
+    _nc_curr_col++;
+    the_char = *bufptr++;
+    return UChar(the_char);
+}
+
+static void
+push_back(char c)
+/* push a character back onto the input stream */
+{
+    if (bufptr == bufstart)
+	_nc_syserr_abort("Can't backspace off beginning of line");
+    *--bufptr = c;
+    _nc_curr_col--;
+}
+
+static long
+stream_pos(void)
+/* return our current character position in the input stream */
+{
+    return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
+}
+
+static bool
+end_of_stream(void)
+/* are we at end of input? */
+{
+    return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
+	    ? TRUE : FALSE);
+}
 
 /* Assume we may be looking at a termcap-style continuation */
 static inline int
@@ -161,6 +344,10 @@
     long number;
     long token_start;
     unsigned found;
+#ifdef TRACE
+    int old_line;
+    int old_col;
+#endif
 
     if (pushtype != NO_PUSHBACK) {
 	int retval = pushtype;
@@ -178,6 +365,8 @@
     }
 
     if (end_of_stream()) {
+	yyin = 0;
+	next_char();		/* frees its allocated memory */
 	if (buffer != 0) {
 	    FreeAndNull(buffer);
 	}
@@ -194,6 +383,10 @@
 
     ch = eat_escaped_newline(ch);
 
+#ifdef TRACE
+    old_line = _nc_curr_line;
+    old_col = _nc_curr_col;
+#endif
     if (ch == EOF)
 	type = EOF;
     else {
@@ -219,13 +412,13 @@
 	}
 
 	/* have to make some punctuation chars legal for terminfo */
-	if (!isalnum(ch)
+	if (!isalnum(UChar(ch))
 #if NCURSES_EXT_FUNCS
 	    && !(ch == '.' && _nc_disable_period)
 #endif
 	    && !strchr(terminfo_punct, (char) ch)) {
 	    if (!silent)
-		_nc_warning("Illegal character (expected alphanumeric or %s) - %s",
+		_nc_warning("Illegal character (expected alphanumeric or %s) - '%s'",
 			    terminfo_punct, unctrl((chtype) ch));
 	    _nc_panic_mode(separator);
 	    goto start_token;
@@ -234,6 +427,10 @@
 	if (buffer == 0)
 	    buffer = typeMalloc(char, MAX_ENTRY_SIZE);
 
+#ifdef TRACE
+	old_line = _nc_curr_line;
+	old_col = _nc_curr_col;
+#endif
 	ptr = buffer;
 	*(ptr++) = ch;
 
@@ -247,7 +444,7 @@
 	    after_list = 0;
 	    while ((ch = next_char()) != '\n') {
 		if (ch == EOF) {
-		    _nc_err_abort(MSG_NO_MEMORY);
+		    _nc_err_abort(MSG_NO_INPUTS);
 		} else if (ch == '|') {
 		    after_list = ptr;
 		    if (after_name == 0)
@@ -351,7 +548,7 @@
 		had_newline = FALSE;
 	    }
 	    while ((ch = next_char()) != EOF) {
-		if (!isalnum(ch)) {
+		if (!isalnum(UChar(ch))) {
 		    if (_nc_syntax == SYN_TERMINFO) {
 			if (ch != '_')
 			    break;
@@ -416,7 +613,7 @@
 		/* just to get rid of the compiler warning */
 		type = UNDEF;
 		if (!silent)
-		    _nc_warning("Illegal character - %s", unctrl((chtype) ch));
+		    _nc_warning("Illegal character - '%s'", unctrl((chtype) ch));
 	    }
 	}			/* end else (first_column == FALSE) */
     }				/* end else (ch != EOF) */
@@ -427,6 +624,11 @@
     if (dot_flag == TRUE)
 	DEBUG(8, ("Commented out "));
 
+    if (_nc_tracing >= DEBUG_LEVEL(8)) {
+	_tracef("parsed %d.%d to %d.%d",
+		old_line, old_col,
+		_nc_curr_line, _nc_curr_col);
+    }
     if (_nc_tracing >= DEBUG_LEVEL(7)) {
 	switch (type) {
 	case BOOLEAN:
@@ -471,8 +673,9 @@
 	type = _nc_get_token(silent);
 
     DEBUG(3, ("token: `%s', class %d",
-	      _nc_curr_token.tk_name != 0 ? _nc_curr_token.tk_name :
-	      "<null>",
+	      ((_nc_curr_token.tk_name != 0)
+	       ? _nc_curr_token.tk_name
+	       : "<null>"),
 	      type));
 
     return (type);
@@ -497,7 +700,7 @@
  *
  */
 
-NCURSES_EXPORT(char)
+NCURSES_EXPORT(int)
 _nc_trans_string(char *ptr, char *last)
 {
     int count = 0;
@@ -518,7 +721,7 @@
 		_nc_err_abort(MSG_NO_INPUTS);
 
 	    if (!(is7bits(ch) && isprint(ch))) {
-		_nc_warning("Illegal ^ character - %s", unctrl(ch));
+		_nc_warning("Illegal ^ character - '%s'", unctrl(ch));
 	    }
 	    if (ch == '?') {
 		*(ptr++) = '\177';
@@ -613,7 +816,7 @@
 		    continue;
 
 		default:
-		    _nc_warning("Illegal character %s in \\ sequence",
+		    _nc_warning("Illegal character '%s' in \\ sequence",
 				unctrl(ch));
 		    /* FALLTHRU */
 		case '|':
@@ -623,13 +826,21 @@
 	}
 	/* end else if (ch == '\\') */
 	else if (ch == '\n' && (_nc_syntax == SYN_TERMINFO)) {
-	    /* newlines embedded in a terminfo string are ignored */
+	    /*
+	     * Newlines embedded in a terminfo string are ignored, provided
+	     * that the next line begins with whitespace.
+	     */
 	    ignored = TRUE;
 	} else {
 	    *(ptr++) = (char) ch;
 	}
 
 	if (!ignored) {
+	    if (_nc_curr_col <= 1) {
+		push_back(ch);
+		ch = '\n';
+		break;
+	    }
 	    last_ch = ch;
 	    count++;
 	}
@@ -687,172 +898,3 @@
 	    return;
     }
 }
-
-/*****************************************************************************
- *
- * Character-stream handling
- *
- *****************************************************************************/
-
-#define LEXBUFSIZ	1024
-
-static char *bufptr;		/* otherwise, the input buffer pointer */
-static char *bufstart;		/* start of buffer so we can compute offsets */
-static FILE *yyin;		/* scanner's input file descriptor */
-
-/*
- *	_nc_reset_input()
- *
- *	Resets the input-reading routines.  Used on initialization,
- *	or after a seek has been done.  Exactly one argument must be
- *	non-null.
- */
-
-NCURSES_EXPORT(void)
-_nc_reset_input(FILE *fp, char *buf)
-{
-    pushtype = NO_PUSHBACK;
-    if (pushname != 0)
-	pushname[0] = '\0';
-    yyin = fp;
-    bufstart = bufptr = buf;
-    _nc_curr_file_pos = 0L;
-    if (fp != 0)
-	_nc_curr_line = 0;
-    _nc_curr_col = 0;
-}
-
-/*
- *	int last_char()
- *
- *	Returns the final nonblank character on the current input buffer
- */
-static int
-last_char(void)
-{
-    size_t len = strlen(bufptr);
-    while (len--) {
-	if (!isspace(UChar(bufptr[len])))
-	    return bufptr[len];
-    }
-    return 0;
-}
-
-/*
- *	int next_char()
- *
- *	Returns the next character in the input stream.  Comments and leading
- *	white space are stripped.
- *
- *	The global state variable 'firstcolumn' is set TRUE if the character
- *	returned is from the first column of the input line.
- *
- *	The global variable _nc_curr_line is incremented for each new line.
- *	The global variable _nc_curr_file_pos is set to the file offset of the
- *	beginning of each line.
- */
-
-static int
-next_char(void)
-{
-    if (!yyin) {
-	/*
-	 * An string with an embedded null will truncate the input.  This is
-	 * intentional (we don't read binary files here).
-	 */
-	if (*bufptr == '\0')
-	    return (EOF);
-	if (*bufptr == '\n') {
-	    _nc_curr_line++;
-	    _nc_curr_col = 0;
-	}
-    } else if (!bufptr || !*bufptr) {
-	/*
-	 * In theory this could be recoded to do its I/O one character at a
-	 * time, saving the buffer space.  In practice, this turns out to be
-	 * quite hard to get completely right.  Try it and see.  If you
-	 * succeed, don't forget to hack push_back() correspondingly.
-	 */
-	static char *result;
-	static size_t allocated;
-	size_t used;
-	size_t len;
-
-	do {
-	    bufstart = 0;
-	    used = 0;
-	    do {
-		if (used + (LEXBUFSIZ / 4) >= allocated) {
-		    allocated += (allocated + LEXBUFSIZ);
-		    result = typeRealloc(char, allocated, result);
-		    if (result == 0)
-			return (EOF);
-		}
-		if (used == 0)
-		    _nc_curr_file_pos = ftell(yyin);
-
-		if (fgets(result + used, allocated - used, yyin) != 0) {
-		    bufstart = result;
-		    if (used == 0) {
-			_nc_curr_line++;
-			_nc_curr_col = 0;
-		    }
-		} else {
-		    if (used != 0)
-			strcat(result, "\n");
-		}
-		if ((bufptr = bufstart) != 0) {
-		    used = strlen(bufptr);
-		    while (iswhite(*bufptr))
-			bufptr++;
-
-		    /*
-		     * Treat a trailing <cr><lf> the same as a <newline> so we
-		     * can read files on OS/2, etc.
-		     */
-		    if ((len = strlen(bufptr)) > 1) {
-			if (bufptr[len - 1] == '\n'
-			    && bufptr[len - 2] == '\r') {
-			    len--;
-			    bufptr[len - 1] = '\n';
-			    bufptr[len] = '\0';
-			}
-		    }
-		} else {
-		    return (EOF);
-		}
-	    } while (bufptr[len - 1] != '\n');	/* complete a line */
-	} while (result[0] == '#');	/* ignore comments */
-    }
-
-    first_column = (bufptr == bufstart);
-    if (first_column)
-	had_newline = FALSE;
-
-    _nc_curr_col++;
-    return (*bufptr++);
-}
-
-static void
-push_back(char c)
-/* push a character back onto the input stream */
-{
-    if (bufptr == bufstart)
-	_nc_syserr_abort("Can't backspace off beginning of line");
-    *--bufptr = c;
-}
-
-static long
-stream_pos(void)
-/* return our current character position in the input stream */
-{
-    return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
-}
-
-static bool
-end_of_stream(void)
-/* are we at end of input? */
-{
-    return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
-	    ? TRUE : FALSE);
-}
diff -Naur ncurses-5.4.orig/ncurses/tinfo/init_keytry.c ncurses-5.4/ncurses/tinfo/init_keytry.c
--- ncurses-5.4.orig/ncurses/tinfo/init_keytry.c	2000-12-10 02:55:07.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/init_keytry.c	2005-05-13 04:09:58.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1999-2000,2005 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            *
@@ -28,11 +28,15 @@
 
 #include <curses.priv.h>
 
-#include <term.h>		/* keypad_xmit, keypad_local, meta_on, meta_off */
-			/* cursor_visible,cursor_normal,cursor_invisible */
+#include <term.h>
+/* keypad_xmit, keypad_local, meta_on, meta_off */
+/* cursor_visible,cursor_normal,cursor_invisible */
+
 #include <tic.h>		/* struct tinfo_fkeys */
 
-MODULE_ID("$Id: init_keytry.c,v 1.5 2000/12/10 02:55:07 tom Exp $")
+#include <term_entry.h>
+
+MODULE_ID("$Id: init_keytry.c,v 1.7 2005/04/30 19:32:03 tom Exp $")
 
 /*
 **      _nc_init_keytry()
@@ -69,12 +73,38 @@
      * mouse_activate() (which will call keyok()) are first called.
      */
 
-    for (n = 0; _nc_tinfo_fkeys[n].code; n++)
-	if (_nc_tinfo_fkeys[n].offset < STRCOUNT)
-	    _nc_add_to_try(&(SP->_keytry),
-			   CUR Strings[_nc_tinfo_fkeys[n].offset],
-			   _nc_tinfo_fkeys[n].code);
+    if (SP != 0) {
+	for (n = 0; _nc_tinfo_fkeys[n].code; n++) {
+	    if (_nc_tinfo_fkeys[n].offset < STRCOUNT) {
+		_nc_add_to_try(&(SP->_keytry),
+			       CUR Strings[_nc_tinfo_fkeys[n].offset],
+			       _nc_tinfo_fkeys[n].code);
+	    }
+	}
+#if NCURSES_XNAMES
+	/*
+	 * Add any of the extended strings to the tries if their name begins
+	 * with 'k', i.e., they follow the convention of other terminfo key
+	 * names.
+	 */
+	{
+	    TERMTYPE *tp = &(SP->_term->type);
+	    for (n = STRCOUNT; n < NUM_STRINGS(tp); ++n) {
+		char *name = ExtStrname(tp, n, strnames);
+		char *value = tp->Strings[n];
+		if (name != 0
+		    && *name == 'k'
+		    && value != 0
+		    && key_defined(value) == 0) {
+		    _nc_add_to_try(&(SP->_keytry),
+				   value,
+				   n - STRCOUNT + KEY_MAX);
+		}
+	    }
+	}
+#endif
 #ifdef TRACE
-    _nc_trace_tries(SP->_keytry);
+	_nc_trace_tries(SP->_keytry);
 #endif
+    }
 }
diff -Naur ncurses-5.4.orig/ncurses/tinfo/lib_acs.c ncurses-5.4/ncurses/tinfo/lib_acs.c
--- ncurses-5.4.orig/ncurses/tinfo/lib_acs.c	2002-12-28 16:26:46.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/lib_acs.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2002,2004 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,12 +29,13 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 #include <curses.priv.h>
 #include <term.h>		/* ena_acs, acs_chars */
 
-MODULE_ID("$Id: lib_acs.c,v 1.25 2002/12/28 16:26:46 tom Exp $")
+MODULE_ID("$Id: lib_acs.c,v 1.27 2004/10/16 15:42:40 tom Exp $")
 
 #if BROKEN_LINKER
 NCURSES_EXPORT_VAR(chtype *)
@@ -70,6 +71,7 @@
 	for (j = 1; j < ACS_LEN; ++j) {
 	    real_map[j] = 0;
 	    fake_map[j] = A_ALTCHARSET | j;
+	    SP->_screen_acs_map[j] = FALSE;
 	}
     } else {
 	for (j = 1; j < ACS_LEN; ++j) {
@@ -119,6 +121,9 @@
     if (_nc_unicode_locale() && _nc_locale_breaks_acs()) {
 	acs_chars = NULL;
 	ena_acs = NULL;
+	enter_alt_charset_mode = NULL;
+	exit_alt_charset_mode = NULL;
+	set_attributes = NULL;
     }
 #endif
 
@@ -134,6 +139,8 @@
 	while (i + 1 < length) {
 	    if (acs_chars[i] != 0 && UChar(acs_chars[i]) < ACS_LEN) {
 		real_map[UChar(acs_chars[i])] = UChar(acs_chars[i + 1]) | A_ALTCHARSET;
+		if (SP != 0)
+		    SP->_screen_acs_map[UChar(acs_chars[i])] = TRUE;
 	    }
 	    i += 2;
 	}
@@ -152,6 +159,10 @@
 	    }
 	}
 	show[m] = 0;
+	if (acs_chars == NULL || strcmp(acs_chars, show))
+	    _tracef("%s acs_chars %s",
+		    (acs_chars == NULL) ? "NULL" : "READ",
+		    _nc_visbuf(acs_chars));
 	_tracef("%s acs_chars %s",
 		(acs_chars == NULL)
 		? "NULL"
diff -Naur ncurses-5.4.orig/ncurses/tinfo/lib_data.c ncurses-5.4/ncurses/tinfo/lib_data.c
--- ncurses-5.4.orig/ncurses/tinfo/lib_data.c	2000-12-10 02:55:07.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/lib_data.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2000,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -40,18 +41,15 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_data.c,v 1.16 2000/12/10 02:55:07 tom Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.17 2005/01/22 17:39:22 tom Exp $")
 
 /*
  * OS/2's native linker complains if we don't initialize public data when
  * constructing a dll (reported by J.J.G.Ripoll).
  */
-NCURSES_EXPORT_VAR(WINDOW *)
-stdscr = 0;
-NCURSES_EXPORT_VAR(WINDOW *)
-curscr = 0;
-NCURSES_EXPORT_VAR(WINDOW *)
-newscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) curscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) newscr = 0;
 
 NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
 
@@ -66,7 +64,7 @@
  * module coupling that increases the size of the executable.
  */
 #if BROKEN_LINKER
-     static SCREEN *my_screen;
+static SCREEN *my_screen;
 
 NCURSES_EXPORT(SCREEN *)
 _nc_screen(void)
@@ -81,11 +79,11 @@
 }
 
 NCURSES_EXPORT(void)
-_nc_set_screen(SCREEN * sp)
+_nc_set_screen(SCREEN *sp)
 {
     my_screen = sp;
 }
 
 #else
-NCURSES_EXPORT_VAR(SCREEN *) SP = NULL;		/* Some linkers require initialized data... */
+NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
 #endif
diff -Naur ncurses-5.4.orig/ncurses/tinfo/lib_kernel.c ncurses-5.4/ncurses/tinfo/lib_kernel.c
--- ncurses-5.4.orig/ncurses/tinfo/lib_kernel.c	2003-01-26 00:24:53.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/lib_kernel.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,13 +48,13 @@
 #include <curses.priv.h>
 #include <term.h>		/* cur_term */
 
-MODULE_ID("$Id: lib_kernel.c,v 1.23 2003/01/26 00:24:53 tom Exp $")
+MODULE_ID("$Id: lib_kernel.c,v 1.24 2004/05/08 17:11:21 tom Exp $")
 
 static int
 _nc_vdisable(void)
 {
     int value = -1;
-#if defined(_POSIX_VDISABLE) && defined(HAVE_UNISTD_H)
+#if defined(_POSIX_VDISABLE) && HAVE_UNISTD_H
     value = _POSIX_VDISABLE;
 #endif
 #if defined(_PC_VDISABLE)
diff -Naur ncurses-5.4.orig/ncurses/tinfo/lib_napms.c ncurses-5.4/ncurses/tinfo/lib_napms.c
--- ncurses-5.4.orig/ncurses/tinfo/lib_napms.c	2003-11-30 00:54:29.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/lib_napms.c	2005-05-13 04:09:56.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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            *
@@ -49,7 +49,7 @@
 #endif
 #endif
 
-MODULE_ID("$Id: lib_napms.c,v 1.14 2003/11/30 00:54:29 Philippe.Blain Exp $")
+MODULE_ID("$Id: lib_napms.c,v 1.15 2005/04/03 13:58:14 tom Exp $")
 
 NCURSES_EXPORT(int)
 napms(int ms)
@@ -59,10 +59,9 @@
 #if HAVE_NANOSLEEP
     {
 	struct timespec request, remaining;
-	int err;
 	request.tv_sec = ms / 1000;
 	request.tv_nsec = (ms % 1000) * 1000000;
-	while ((err = nanosleep(&request, &remaining)) == -1
+	while (nanosleep(&request, &remaining) == -1
 	       && errno == EINTR) {
 	    request = remaining;
 	}
diff -Naur ncurses-5.4.orig/ncurses/tinfo/lib_options.c ncurses-5.4/ncurses/tinfo/lib_options.c
--- ncurses-5.4.orig/ncurses/tinfo/lib_options.c	2003-10-25 19:51:38.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/lib_options.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2005 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,7 +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-2003               *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 /*
@@ -43,7 +43,7 @@
 
 #include <term.h>
 
-MODULE_ID("$Id: lib_options.c,v 1.47 2003/10/25 19:51:38 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.48 2005/01/22 21:13:34 tom Exp $")
 
 NCURSES_EXPORT(int)
 idlok(WINDOW *win, bool flag)
@@ -159,43 +159,44 @@
 NCURSES_EXPORT(int)
 curs_set(int vis)
 {
-    int cursor = SP->_cursor;
+    int result = ERR;
 
     T((T_CALLED("curs_set(%d)"), vis));
+    if (SP != 0 && vis >= 0 && vis <= 2) {
+	int cursor = SP->_cursor;
 
-    if (vis < 0 || vis > 2)
-	returnCode(ERR);
-
-    if (vis == cursor)
-	returnCode(cursor);
-
-    switch (vis) {
-    case 2:
-	if (cursor_visible) {
-	    TPUTS_TRACE("cursor_visible");
-	    putp(cursor_visible);
-	} else
-	    returnCode(ERR);
-	break;
-    case 1:
-	if (cursor_normal) {
-	    TPUTS_TRACE("cursor_normal");
-	    putp(cursor_normal);
-	} else
-	    returnCode(ERR);
-	break;
-    case 0:
-	if (cursor_invisible) {
-	    TPUTS_TRACE("cursor_invisible");
-	    putp(cursor_invisible);
-	} else
-	    returnCode(ERR);
-	break;
+	if (vis == cursor) {
+	    result = cursor;
+	} else {
+	    result = (cursor == -1 ? 1 : cursor);
+	    switch (vis) {
+	    case 2:
+		if (cursor_visible) {
+		    TPUTS_TRACE("cursor_visible");
+		    putp(cursor_visible);
+		} else
+		    result = ERR;
+		break;
+	    case 1:
+		if (cursor_normal) {
+		    TPUTS_TRACE("cursor_normal");
+		    putp(cursor_normal);
+		} else
+		    result = ERR;
+		break;
+	    case 0:
+		if (cursor_invisible) {
+		    TPUTS_TRACE("cursor_invisible");
+		    putp(cursor_invisible);
+		} else
+		    result = ERR;
+		break;
+	    }
+	    SP->_cursor = vis;
+	    _nc_flush();
+	}
     }
-    SP->_cursor = vis;
-    _nc_flush();
-
-    returnCode(cursor == -1 ? 1 : cursor);
+    returnCode(result);
 }
 
 NCURSES_EXPORT(int)
@@ -258,10 +259,12 @@
 	_nc_flush();
     }
 
-    if (flag && SP != 0 && !SP->_tried) {
-	_nc_init_keytry();
-	SP->_tried = TRUE;
+    if (SP != 0) {
+	if (flag && !SP->_tried) {
+	    _nc_init_keytry();
+	    SP->_tried = TRUE;
+	}
+	SP->_keypad_on = flag;
     }
-    SP->_keypad_on = flag;
     return (OK);
 }
diff -Naur ncurses-5.4.orig/ncurses/tinfo/lib_setup.c ncurses-5.4/ncurses/tinfo/lib_setup.c
--- ncurses-5.4.orig/ncurses/tinfo/lib_setup.c	2003-12-27 18:24:26.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/lib_setup.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -47,9 +47,13 @@
 #define _POSIX_SOURCE
 #endif
 
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
 #include <term.h>		/* lines, columns, cur_term */
 
-MODULE_ID("$Id: lib_setup.c,v 1.79 2003/12/27 18:24:26 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.88 2005/03/12 19:41:45 tom Exp $")
 
 /****************************************************************************
  *
@@ -73,6 +77,10 @@
 # include <sys/ptem.h>
 #endif
 
+#if HAVE_LANGINFO_CODESET
+#include <langinfo.h>
+#endif
+
 /*
  * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
  * Solaris, IRIX) define TIOCGWINSZ and struct winsize.
@@ -205,11 +213,24 @@
 NCURSES_EXPORT(void)
 _nc_update_screensize(void)
 {
-    int my_lines, my_cols;
+    int old_lines = lines;
+    int new_lines;
+    int old_cols = columns;
+    int new_cols;
+
+    _nc_get_screensize(&new_lines, &new_cols);
 
-    _nc_get_screensize(&my_lines, &my_cols);
-    if (SP != 0 && SP->_resize != 0)
-	SP->_resize(my_lines, my_cols);
+    /*
+     * See is_term_resized() and resizeterm().
+     * We're doing it this way because those functions belong to the upper
+     * ncurses library, while this resides in the lower terminfo library.
+     */
+    if (SP != 0
+	&& SP->_resize != 0) {
+	if ((new_lines != old_lines) || (new_cols != old_cols))
+	    SP->_resize(new_lines, new_cols);
+	SP->_sig_winch = FALSE;
+    }
 }
 #endif
 
@@ -237,7 +258,7 @@
 
 #if USE_DATABASE || USE_TERMCAP
 static int
-grab_entry(const char *const tn, TERMTYPE * const tp)
+grab_entry(const char *const tn, TERMTYPE *const tp)
 /* return 1 if entry found, 0 if not found, -1 if database not accessible */
 {
 #if USE_DATABASE
@@ -318,18 +339,27 @@
 }
 
 /*
- * Check if we are running in a UTF-8 locale.
+ * Find the locale which is in effect.
  */
 NCURSES_EXPORT(char *)
 _nc_get_locale(void)
 {
     char *env;
+#if HAVE_LOCALE_H
+    /*
+     * This is preferable to using getenv() since it ensures that we are using
+     * the locale which was actually initialized by the application.
+     */
+    env = setlocale(LC_CTYPE, 0);
+#else
     if (((env = getenv("LC_ALL")) != 0 && *env != '\0')
 	|| ((env = getenv("LC_CTYPE")) != 0 && *env != '\0')
 	|| ((env = getenv("LANG")) != 0 && *env != '\0')) {
-	return env;
+	;
     }
-    return 0;
+#endif
+    T(("_nc_get_locale %s", _nc_visbuf(env)));
+    return env;
 }
 
 /*
@@ -338,14 +368,26 @@
 NCURSES_EXPORT(int)
 _nc_unicode_locale(void)
 {
+    int result = 0;
+#if HAVE_LANGINFO_CODESET
+    char *env = nl_langinfo(CODESET);
+    result = !strcmp(env, "UTF-8");
+    T(("_nc_unicode_locale(%s) ->%d", env, result));
+#else
     char *env = _nc_get_locale();
     if (env != 0) {
-	if (strstr(env, ".UTF-8") != 0)
-	    return 1;
+	if (strstr(env, ".UTF-8") != 0) {
+	    result = 1;
+	    T(("_nc_unicode_locale(%s) ->%d", env, result));
+	}
     }
-    return 0;
+#endif
+    return result;
 }
 
+#define CONTROL_N(s) ((s) != 0 && strstr(s, "\016") != 0)
+#define CONTROL_O(s) ((s) != 0 && strstr(s, "\017") != 0)
+
 /*
  * Check for known broken cases where a UTF-8 locale breaks the alternate
  * character set.
@@ -353,30 +395,33 @@
 NCURSES_EXPORT(int)
 _nc_locale_breaks_acs(void)
 {
-    char *env = getenv("TERM");
-    if (env != 0) {
+    char *env;
+
+    if ((env = getenv("NCURSES_NO_UTF8_ACS")) != 0) {
+	return atoi(env);
+    } else if ((env = getenv("TERM")) != 0) {
 	if (strstr(env, "linux"))
 	    return 1;		/* always broken */
 	if (strstr(env, "screen") != 0
 	    && ((env = getenv("TERMCAP")) != 0
 		&& strstr(env, "screen") != 0)
 	    && strstr(env, "hhII00") != 0) {
-	    return 1;
+	    if (CONTROL_N(enter_alt_charset_mode) ||
+		CONTROL_O(enter_alt_charset_mode) ||
+		CONTROL_N(set_attributes) ||
+		CONTROL_O(set_attributes))
+		return 1;
 	}
     }
     return 0;
 }
 
 /*
- *	setupterm(termname, Filedes, errret)
- *
- *	Find and read the appropriate object file for the terminal
- *	Make cur_term point to the structure.
- *
+ * This entrypoint is called from tgetent() to allow special a case of reusing
+ * the same TERMINAL data (see comment).
  */
-
 NCURSES_EXPORT(int)
-setupterm(NCURSES_CONST char *tname, int Filedes, int *errret)
+_nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
 {
     int status;
 
@@ -419,7 +464,8 @@
      * however applications that are working around the problem will still work
      * properly with this feature).
      */
-    if (cur_term != 0
+    if (reuse
+	&& cur_term != 0
 	&& cur_term->Filedes == Filedes
 	&& cur_term->_termname != 0
 	&& !strcmp(cur_term->_termname, tname)
@@ -500,3 +546,17 @@
     }
     returnCode(OK);
 }
+
+/*
+ *	setupterm(termname, Filedes, errret)
+ *
+ *	Find and read the appropriate object file for the terminal
+ *	Make cur_term point to the structure.
+ *
+ */
+
+NCURSES_EXPORT(int)
+setupterm(NCURSES_CONST char *tname, int Filedes, int *errret)
+{
+    return _nc_setupterm(tname, Filedes, errret, FALSE);
+}
diff -Naur ncurses-5.4.orig/ncurses/tinfo/lib_termcap.c ncurses-5.4/ncurses/tinfo/lib_termcap.c
--- ncurses-5.4.orig/ncurses/tinfo/lib_termcap.c	2003-05-24 21:10:28.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/lib_termcap.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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                 *
  *                                                                          *
  * some of the code in here was contributed by:                             *
  * Magnus Bengtsson, d6mbeng@dtek.chalmers.se (Nov'93)                      *
@@ -43,7 +44,7 @@
 
 #include <term_entry.h>
 
-MODULE_ID("$Id: lib_termcap.c,v 1.44 2003/05/24 21:10:28 tom Exp $")
+MODULE_ID("$Id: lib_termcap.c,v 1.49 2005/04/16 16:12:49 tom Exp $")
 
 #define CSI       233
 #define ESC       033		/* ^[ */
@@ -53,7 +54,7 @@
 NCURSES_EXPORT_VAR(char *) UP = 0;
 NCURSES_EXPORT_VAR(char *) BC = 0;
 
-static char *fix_me = 0;
+static char *fix_me = 0;	/* this holds the filtered sgr0 string */
 
 static char *
 set_attribute_9(int flag)
@@ -87,12 +88,45 @@
     return s;
 }
 
+/*
+ * Improve similar_sgr a little by moving the attr-string from the beginning
+ * to the end of the s-string.
+ */
+static bool
+rewrite_sgr(char *s, char *attr)
+{
+    if (s != 0) {
+	if (attr != 0) {
+	    unsigned len_s = strlen(s);
+	    unsigned len_a = strlen(attr);
+
+	    if (len_s > len_a && !strncmp(attr, s, len_a)) {
+		unsigned n;
+		TR(TRACE_DATABASE, ("rewrite:\n\t%s", s));
+		for (n = 0; n < len_s - len_a; ++n) {
+		    s[n] = s[n + len_a];
+		}
+		strcpy(s + n, attr);
+		TR(TRACE_DATABASE, ("to:\n\t%s", s));
+	    }
+	}
+	return TRUE;
+    }
+    return FALSE;		/* oops */
+}
+
 static bool
 similar_sgr(char *a, char *b)
 {
+    bool result = FALSE;
     int csi_a = is_csi(a);
     int csi_b = is_csi(b);
+    unsigned len_a;
+    unsigned len_b;
 
+    TR(TRACE_DATABASE, ("similar_sgr:\n\t%s\n\t%s",
+			_nc_visbuf2(1, a),
+			_nc_visbuf2(2, b)));
     if (csi_a != 0 && csi_b != 0 && csi_a == csi_b) {
 	a += csi_a;
 	b += csi_b;
@@ -101,7 +135,29 @@
 	    b = skip_zero(b);
 	}
     }
-    return strcmp(a, b) == 0;
+    len_a = strlen(a);
+    len_b = strlen(b);
+    if (len_a && len_b) {
+	if (len_a > len_b)
+	    result = (strncmp(a, b, len_b) == 0);
+	else
+	    result = (strncmp(a, b, len_a) == 0);
+    }
+    TR(TRACE_DATABASE, ("...similar_sgr: %d\n\t%s\n\t%s", result,
+			_nc_visbuf2(1, a),
+			_nc_visbuf2(2, b)));
+    return result;
+}
+
+static unsigned
+chop_out(char *string, unsigned i, unsigned j)
+{
+    TR(TRACE_DATABASE, ("chop_out %d..%d from %s", i, j, _nc_visbuf(string)));
+    while (string[j] != '\0') {
+	string[i++] = string[j++];
+    }
+    string[i] = '\0';
+    return i;
 }
 
 /***************************************************************************
@@ -124,14 +180,15 @@
 {
     int errcode;
 
+    START_TRACE();
     T((T_CALLED("tgetent()")));
 
-    setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode);
+    _nc_setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode, TRUE);
 
     PC = 0;
     UP = 0;
     BC = 0;
-    fix_me = 0;
+    fix_me = 0;			/* don't free it - application may still use */
 
     if (errcode == 1) {
 
@@ -157,56 +214,94 @@
 	 */
 	if (exit_attribute_mode != 0
 	    && set_attributes != 0) {
+	    bool found = FALSE;
 	    char *on = set_attribute_9(1);
 	    char *off = set_attribute_9(0);
+	    char *end = strdup(exit_attribute_mode);
 	    char *tmp;
 	    size_t i, j, k;
 
-	    if (similar_sgr(off, exit_attribute_mode)
-		&& !similar_sgr(off, on)) {
+	    TR(TRACE_DATABASE, ("checking if we can trim sgr0 based on sgr"));
+	    TR(TRACE_DATABASE, ("sgr0       %s", _nc_visbuf(end)));
+	    TR(TRACE_DATABASE, ("sgr(9:off) %s", _nc_visbuf(off)));
+	    TR(TRACE_DATABASE, ("sgr(9:on)  %s", _nc_visbuf(on)));
+
+	    if (!rewrite_sgr(on, enter_alt_charset_mode)
+		|| !rewrite_sgr(off, exit_alt_charset_mode)
+		|| !rewrite_sgr(end, exit_alt_charset_mode)) {
+		FreeIfNeeded(on);
+		FreeIfNeeded(off);
+		FreeIfNeeded(end);
+	    } else if (similar_sgr(off, end)
+		       && !similar_sgr(off, on)) {
 		TR(TRACE_DATABASE, ("adjusting sgr0 : %s", _nc_visbuf(off)));
 		FreeIfNeeded(fix_me);
 		fix_me = off;
-		for (i = 0; off[i] != '\0'; ++i) {
-		    if (on[i] != off[i]) {
-			j = strlen(off);
-			k = strlen(on);
-			while (j != 0
-			       && k != 0
-			       && off[j - 1] == on[k - 1]) {
-			    --j, --k;
-			}
-			while (off[j] != '\0') {
-			    off[i++] = off[j++];
+		/*
+		 * If rmacs is a substring of sgr(0), remove that chunk.
+		 */
+		if (exit_alt_charset_mode != 0) {
+		    j = strlen(off);
+		    k = strlen(exit_alt_charset_mode);
+		    if (j > k) {
+			for (i = 0; i <= (j - k); ++i) {
+			    if (!memcmp(exit_alt_charset_mode, off + i, k)) {
+				found = TRUE;
+				chop_out(off, i, i + k);
+				break;
+			    }
 			}
-			off[i] = '\0';
-			break;
 		    }
 		}
-		/* SGR 10 would reset to normal font */
-		if ((i = is_csi(off)) != 0
-		    && off[strlen(off) - 1] == 'm') {
-		    tmp = skip_zero(off + i);
-		    if (tmp[0] == '1'
-			&& skip_zero(tmp + 1) != tmp + 1) {
-			i = tmp - off;
-			if (off[i - 1] == ';')
-			    i--;
-			j = skip_zero(tmp + 1) - off;
-			while (off[j] != '\0') {
-			    off[i++] = off[j++];
+		/*
+		 * SGR 10 would reset to normal font.
+		 */
+		if (!found) {
+		    if ((i = is_csi(off)) != 0
+			&& off[strlen(off) - 1] == 'm') {
+			TR(TRACE_DATABASE, ("looking for SGR 10 in %s",
+					    _nc_visbuf(off)));
+			tmp = skip_zero(off + i);
+			if (tmp[0] == '1'
+			    && skip_zero(tmp + 1) != tmp + 1) {
+			    i = tmp - off;
+			    if (off[i - 1] == ';')
+				i--;
+			    j = skip_zero(tmp + 1) - off;
+			    i = chop_out(off, i, j);
+			    found = TRUE;
 			}
-			off[i] = '\0';
 		    }
 		}
-		TR(TRACE_DATABASE, ("...adjusted me : %s", _nc_visbuf(fix_me)));
+		if (!found
+		    && (tmp = strstr(end, off)) != 0) {
+		    i = tmp - end;
+		    j = strlen(off);
+		    tmp = strdup(end);
+		    chop_out(tmp, i, j);
+		    free(off);
+		    fix_me = tmp;
+		}
+		TR(TRACE_DATABASE, ("...adjusted sgr0 : %s", _nc_visbuf(fix_me)));
 		if (!strcmp(fix_me, exit_attribute_mode)) {
 		    TR(TRACE_DATABASE, ("...same result, discard"));
 		    free(fix_me);
 		    fix_me = 0;
 		}
+	    } else {
+		/*
+		 * Either the sgr does not reference alternate character set,
+		 * or it is incorrect.  That's too hard to decide right now.
+		 */
+		free(off);
 	    }
+	    free(end);
 	    free(on);
+	} else {
+	    /*
+	     * Possibly some applications are confused if sgr0 contains rmacs,
+	     * but that would be a different bug report -TD
+	     */
 	}
 
 	(void) baudrate();	/* sets ospeed as a side-effect */
diff -Naur ncurses-5.4.orig/ncurses/tinfo/name_match.c ncurses-5.4/ncurses/tinfo/name_match.c
--- ncurses-5.4.orig/ncurses/tinfo/name_match.c	2002-08-31 21:48:41.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/name_match.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999,2000,2001 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2004,2005 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 @@
 #include <term.h>
 #include <tic.h>
 
-MODULE_ID("$Id: name_match.c,v 1.12 2002/08/31 21:48:41 Philippe.Blain Exp $")
+MODULE_ID("$Id: name_match.c,v 1.15 2005/01/22 21:47:25 tom Exp $")
 
 /*
  *	_nc_first_name(char *names)
@@ -49,6 +49,14 @@
     static char *buf;
     register unsigned n;
 
+#if NO_LEAKS
+    if (sp == 0) {
+	if (buf != 0)
+	    FreeAndNull(buf);	/* for leak-testing */
+	return 0;
+    }
+#endif
+
     if (buf == 0)
 	buf = typeMalloc(char, MAX_NAME_SIZE + 1);
     for (n = 0; n < MAX_NAME_SIZE; n++) {
@@ -67,8 +75,7 @@
  */
 
 NCURSES_EXPORT(int)
-_nc_name_match
-(const char *const namelst, const char *const name, const char *const delim)
+_nc_name_match(const char *const namelst, const char *const name, const char *const delim)
 {
     const char *s, *d, *t;
     int code, found;
diff -Naur ncurses-5.4.orig/ncurses/tinfo/parse_entry.c ncurses-5.4/ncurses/tinfo/parse_entry.c
--- ncurses-5.4.orig/ncurses/tinfo/parse_entry.c	2003-11-08 21:57:09.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/parse_entry.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,7 +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-2003               *
+ *     and: Thomas E. Dickey                        1996-2004               *
  ****************************************************************************/
 
 /*
@@ -48,7 +48,7 @@
 #include <tic.h>
 #include <term_entry.h>
 
-MODULE_ID("$Id: parse_entry.c,v 1.60 2003/11/08 21:57:09 tom Exp $")
+MODULE_ID("$Id: parse_entry.c,v 1.61 2004/05/01 21:33:25 tom Exp $")
 
 #ifdef LINT
 static short const parametrized[] =
@@ -232,7 +232,11 @@
      * 2-character name, but was instead the first alias after that.
      */
     ptr = _nc_curr_token.tk_name;
-    if (_nc_syntax == SYN_TERMCAP) {
+    if (_nc_syntax == SYN_TERMCAP
+#if NCURSES_XNAMES
+	&& !_nc_user_definable
+#endif
+	) {
 	if (ptr[2] == '|') {
 	    ptr += 3;
 	    _nc_curr_token.tk_name[2] = '\0';
diff -Naur ncurses-5.4.orig/ncurses/tinfo/read_entry.c ncurses-5.4/ncurses/tinfo/read_entry.c
--- ncurses-5.4.orig/ncurses/tinfo/read_entry.c	2004-01-11 01:57:05.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/read_entry.c	2005-05-13 04:09:50.000000000 +0000
@@ -42,12 +42,14 @@
 #include <tic.h>
 #include <term_entry.h>
 
-MODULE_ID("$Id: read_entry.c,v 1.79 2004/01/11 01:57:05 tom Exp $")
+MODULE_ID("$Id: read_entry.c,v 1.80 2004/09/25 23:00:25 tom Exp $")
 
 #if !HAVE_TELL
 #define tell(fd) lseek(fd, 0, SEEK_CUR)		/* lseek() is POSIX, but not tell() */
 #endif
 
+#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
+
 /*
  *	int
  *	_nc_read_file_entry(filename, ptr)
@@ -146,13 +148,14 @@
     }
 }
 
-#define read_shorts(fd, buf, count) (read(fd, buf, (count)*2) == (count)*2)
+#define read_shorts(fd, buf, count) \
+	(read(fd, buf, (unsigned) (count)*2) == (int) (count)*2)
 
 #define even_boundary(value) \
     if ((value) % 2 != 0) read(fd, buf, 1)
 
 static int
-read_termtype(int fd, TERMTYPE * ptr)
+read_termtype(int fd, TERMTYPE *ptr)
 /* return 1 if read, 0 if not found or garbled */
 {
     int name_size, bool_count, num_count, str_count, str_size;
@@ -204,7 +207,7 @@
 	memset(buf + have, 0, want - have);
     }
     buf[want] = '\0';
-    ptr->term_names = typeCalloc(char, strlen(buf) + 1);
+    ptr->term_names = TYPE_CALLOC(char, strlen(buf) + 1);
     if (ptr->term_names == NULL) {
 	return (0);
     }
@@ -213,7 +216,7 @@
 	lseek(fd, (off_t) (have - MAX_NAME_SIZE), 1);
 
     /* grab the booleans */
-    if ((ptr->Booleans = typeCalloc(char, max(BOOLCOUNT, bool_count))) == 0
+    if ((ptr->Booleans = TYPE_CALLOC(char, max(BOOLCOUNT, bool_count))) == 0
 	|| read(fd, ptr->Booleans, (unsigned) bool_count) < bool_count) {
 	return (0);
     }
@@ -227,13 +230,13 @@
     even_boundary(name_size + bool_count);
 
     /* grab the numbers */
-    if ((ptr->Numbers = typeCalloc(short, max(NUMCOUNT, num_count))) == 0
+    if ((ptr->Numbers = TYPE_CALLOC(short, max(NUMCOUNT, num_count))) == 0
 	|| !read_shorts(fd, buf, num_count)) {
 	return (0);
     }
     convert_shorts(buf, ptr->Numbers, num_count);
 
-    if ((ptr->Strings = typeCalloc(char *, max(STRCOUNT, str_count))) == 0)
+    if ((ptr->Strings = TYPE_CALLOC(char *, max(STRCOUNT, str_count))) == 0)
 	  return (0);
 
     if (str_count) {
@@ -263,10 +266,10 @@
 	int ext_str_count = LOW_MSB(buf + 4);
 	int ext_str_size = LOW_MSB(buf + 6);
 	int ext_str_limit = LOW_MSB(buf + 8);
-	int need = (ext_bool_count + ext_num_count + ext_str_count);
+	unsigned need = (ext_bool_count + ext_num_count + ext_str_count);
 	int base = 0;
 
-	if (need >= (int) sizeof(buf)
+	if (need >= sizeof(buf)
 	    || ext_str_size >= (int) sizeof(buf)
 	    || ext_str_limit >= (int) sizeof(buf)
 	    || ext_bool_count < 0
@@ -317,7 +320,7 @@
 	if (ext_str_limit) {
 	    if ((ptr->ext_str_table = typeMalloc(char, ext_str_limit)) == 0)
 		  return (0);
-	    if (read(fd, ptr->ext_str_table, ext_str_limit) != ext_str_limit)
+	    if (read(fd, ptr->ext_str_table, (unsigned) ext_str_limit) != ext_str_limit)
 		return (0);
 	    TR(TRACE_DATABASE, ("first extended-string is %s", _nc_visbuf(ptr->ext_str_table)));
 	}
@@ -342,12 +345,14 @@
 	}
 
 	if (need) {
-	    if ((ptr->ext_Names = typeCalloc(char *, need)) == 0)
+	    if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0)
 		  return (0);
 	    TR(TRACE_DATABASE,
 	       ("ext_NAMES starting @%d in extended_strings, first = %s",
 		base, _nc_visbuf(ptr->ext_str_table + base)));
-	    convert_strings(buf + (2 * ext_str_count), ptr->ext_Names, need,
+	    convert_strings(buf + (2 * ext_str_count),
+			    ptr->ext_Names,
+			    (int) need,
 			    ext_str_limit, ptr->ext_str_table + base);
 	}
 
@@ -378,7 +383,7 @@
 }
 
 NCURSES_EXPORT(int)
-_nc_read_file_entry(const char *const filename, TERMTYPE * ptr)
+_nc_read_file_entry(const char *const filename, TERMTYPE *ptr)
 /* return 1 if read, 0 if not found or garbled */
 {
     int code, fd = -1;
@@ -403,7 +408,7 @@
  */
 static int
 _nc_read_tic_entry(char *const filename,
-		   const char *const dir, const char *ttn, TERMTYPE * const tp)
+		   const char *const dir, const char *ttn, TERMTYPE *const tp)
 {
     int need = 2 + strlen(dir) + strlen(ttn);
 
@@ -419,7 +424,7 @@
  */
 static int
 _nc_read_terminfo_dirs(const char *dirs, char *const filename, const char *const
-		       ttn, TERMTYPE * const tp)
+		       ttn, TERMTYPE *const tp)
 {
     char *list, *a;
     const char *b;
@@ -460,7 +465,7 @@
  */
 
 NCURSES_EXPORT(int)
-_nc_read_entry(const char *const tn, char *const filename, TERMTYPE * const tp)
+_nc_read_entry(const char *const tn, char *const filename, TERMTYPE *const tp)
 {
     char *envp;
     char ttn[PATH_MAX];
diff -Naur ncurses-5.4.orig/ncurses/tinfo/read_termcap.c ncurses-5.4/ncurses/tinfo/read_termcap.c
--- ncurses-5.4.orig/ncurses/tinfo/read_termcap.c	2003-11-08 20:22:45.000000000 +0000
+++ ncurses-5.4/ncurses/tinfo/read_termcap.c	2005-05-13 04:09:50.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -57,7 +57,7 @@
 #include <tic.h>
 #include <term_entry.h>
 
-MODULE_ID("$Id: read_termcap.c,v 1.61 2003/11/08 20:22:45 tom Exp $")
+MODULE_ID("$Id: read_termcap.c,v 1.66 2004/07/05 12:55:23 tom Exp $")
 
 #if !PURE_TERMINFO
 
@@ -74,10 +74,10 @@
 #define TC_SYS_ERR    -3
 #define TC_REF_LOOP   -4
 
-static char *
+static NCURSES_CONST char *
 get_termpath(void)
 {
-    char *result;
+    NCURSES_CONST char *result;
 
     if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == 0)
 	result = TERMPATH;
@@ -720,7 +720,7 @@
 	    if (*s == '\0') {
 		break;
 	    } else if (*s++ == '\n') {
-		while (isspace(*s))
+		while (isspace(UChar(*s)))
 		    s++;
 	    } else {
 		found = TRUE;
@@ -734,7 +734,7 @@
 		break;
 	    }
 	    base = s;
-	} else if (isgraph(ch)) {
+	} else if (isgraph(UChar(ch))) {
 	    found = TRUE;
 	}
     }
@@ -754,7 +754,7 @@
 
     while ((ch = *src++) != '\0') {
 	if (ch == '\\' && *src == '\n') {
-	    while (isspace(*src))
+	    while (isspace(UChar(*src)))
 		src++;
 	    continue;
 	}
@@ -784,7 +784,7 @@
     char pathbuf[PBUFSIZ];	/* holds raw path of filenames */
     char *pathvec[PVECSIZ];	/* to point to names in pathbuf */
     char **pvec;		/* holds usable tail of path vector */
-    char *termpath;
+    NCURSES_CONST char *termpath;
     string_desc desc;
 
     fname = pathvec;
@@ -932,7 +932,7 @@
 #endif /* !USE_GETCAP */
 
 NCURSES_EXPORT(int)
-_nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp)
+_nc_read_termcap_entry(const char *const tn, TERMTYPE *const tp)
 {
     int found = FALSE;
     ENTRY *ep;
@@ -1047,7 +1047,7 @@
      * Probably /etc/termcap is a symlink to /usr/share/misc/termcap.
      * Avoid reading the same file twice.
      */
-#ifdef HAVE_LINK
+#if HAVE_LINK
     for (j = 0; j < filecount; j++) {
 	bool omit = FALSE;
 	if (stat(termpaths[j], &test_stat[j]) != 0
@@ -1112,7 +1112,7 @@
 	return (ERR);
 
     /* resolve all use references */
-    _nc_resolve_uses(TRUE);
+    _nc_resolve_uses2(TRUE, FALSE);
 
     /* find a terminal matching tn, if we can */
 #if USE_GETCAP_CACHE
diff -Naur ncurses-5.4.orig/ncurses/trace/lib_trace.c ncurses-5.4/ncurses/trace/lib_trace.c
--- ncurses-5.4.orig/ncurses/trace/lib_trace.c	2003-11-23 00:39:30.000000000 +0000
+++ ncurses-5.4/ncurses/trace/lib_trace.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -40,9 +41,9 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_trace.c,v 1.53 2003/11/23 00:39:30 tom Exp $")
+MODULE_ID("$Id: lib_trace.c,v 1.58 2005/04/16 16:15:24 tom Exp $")
 
-NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0;	/* always define this */
+NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
 
 #ifdef TRACE
 NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace = "";
@@ -108,7 +109,7 @@
     va_list ap;
     bool before = FALSE;
     bool after = FALSE;
-    int doit = _nc_tracing;
+    unsigned doit = _nc_tracing;
     int save_err = errno;
 
     if (strlen(fmt) >= sizeof(Called) - 1) {
@@ -179,9 +180,33 @@
     return code;
 }
 
+/* Trace 'const char*' return-values */
+NCURSES_EXPORT(const char *)
+_nc_retrace_cptr(const char *code)
+{
+    T((T_RETURN("%s"), _nc_visbuf(code)));
+    return code;
+}
+
+/* Trace 'NCURSES_CONST void*' return-values */
+NCURSES_EXPORT(NCURSES_CONST void *)
+_nc_retrace_cvoid_ptr(NCURSES_CONST void *code)
+{
+    T((T_RETURN("%p"), code));
+    return code;
+}
+
+/* Trace 'void*' return-values */
+NCURSES_EXPORT(void *)
+_nc_retrace_void_ptr(void *code)
+{
+    T((T_RETURN("%p"), code));
+    return code;
+}
+
 /* Trace 'SCREEN *' return-values */
 NCURSES_EXPORT(SCREEN *)
-_nc_retrace_sp(SCREEN * code)
+_nc_retrace_sp(SCREEN *code)
 {
     T((T_RETURN("%p"), code));
     return code;
diff -Naur ncurses-5.4.orig/ncurses/trace/lib_traceatr.c ncurses-5.4/ncurses/trace/lib_traceatr.c
--- ncurses-5.4.orig/ncurses/trace/lib_traceatr.c	2004-01-25 22:31:38.000000000 +0000
+++ ncurses-5.4/ncurses/trace/lib_traceatr.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas Dickey 1996-2003                                         *
+ *  Author: Thomas Dickey                           1996-on                 *
  *     and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
  ****************************************************************************/
@@ -39,15 +39,33 @@
 #include <curses.priv.h>
 #include <term.h>		/* acs_chars */
 
-MODULE_ID("$Id: lib_traceatr.c,v 1.48 2004/01/25 22:31:38 tom Exp $")
+MODULE_ID("$Id: lib_traceatr.c,v 1.52 2005/04/16 16:43:00 tom Exp $")
 
-#define COLOR_OF(c) (c < 0 || c > 7 ? "default" : colors[c].name)
+#define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
 
 #ifdef TRACE
 
 static const char l_brace[] = {L_BRACE, 0};
 static const char r_brace[] = {R_BRACE, 0};
 
+static char *
+color_of(int c)
+{
+    static char buffer[2][80];
+    static int sel;
+    static int last = -1;
+
+    if (c != last) {
+	last = c;
+	sel = !sel;
+	if (c == COLOR_DEFAULT)
+	    strcpy(buffer[sel], "default");
+	else
+	    sprintf(buffer[sel], "color%d", c);
+    }
+    return buffer[sel];
+}
+
 NCURSES_EXPORT(char *)
 _traceattr2(int bufnum, attr_t newmode)
 {
@@ -220,7 +238,7 @@
     if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
 	(void) _nc_trace_bufcat(bufnum, found);
     } else
-	(void) _nc_trace_bufcat(bufnum, _tracechar(ChCharOf(ch)));
+	(void) _nc_trace_bufcat(bufnum, _tracechar((int)ChCharOf(ch)));
 
     if (ChAttrOf(ch) != A_NORMAL) {
 	(void) _nc_trace_bufcat(bufnum, " | ");
@@ -259,8 +277,9 @@
 	if ((found = _nc_altcharset_name(attr, CharOfD(ch))) != 0) {
 	    (void) _nc_trace_bufcat(bufnum, found);
 	    attr &= ~A_ALTCHARSET;
-	} else if (isnac(CHDEREF(ch))) {
+	} else if (isWidecExt(CHDEREF(ch))) {
 	    (void) _nc_trace_bufcat(bufnum, "{NAC}");
+	    attr &= ~A_CHARTEXT;
 	} else {
 	    PUTC_DATA;
 	    int n;
diff -Naur ncurses-5.4.orig/ncurses/trace/lib_tracechr.c ncurses-5.4/ncurses/trace/lib_tracechr.c
--- ncurses-5.4.orig/ncurses/trace/lib_tracechr.c	2003-06-14 11:05:42.000000000 +0000
+++ ncurses-5.4/ncurses/trace/lib_tracechr.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,21 +39,21 @@
 
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracechr.c,v 1.10 2003/06/14 11:05:42 tom Exp $")
+MODULE_ID("$Id: lib_tracechr.c,v 1.12 2005/04/16 16:55:46 tom Exp $")
 
 #ifdef TRACE
 NCURSES_EXPORT(char *)
 _tracechar(int ch)
 {
     static char result[40];
-    char *name;
+    NCURSES_CONST char *name;
 
     if (ch > KEY_MIN || ch < 0) {
 	name = keyname(ch);
 	if (name == 0 || *name == '\0')
 	    name = "NULL";
 	(void) sprintf(result, "'%.30s' = %#03o", name, ch);
-    } else if (!isprint(ch) || ch > 255) {
+    } else if (!is8bits(ch) || !isprint(UChar(ch))) {
 	/*
 	 * workaround for glibc bug:
 	 * sprintf changes the result from unctrl() to an empty string if it
@@ -60,7 +61,7 @@
 	 */
 	(void) sprintf(result, "%#03o", ch);
     } else {
-	name = unctrl(ch);
+	name = unctrl((chtype) ch);
 	if (name == 0 || *name == 0)
 	    name = "null";	/* shouldn't happen */
 	(void) sprintf(result, "'%.30s' = %#03o", name, ch);
diff -Naur ncurses-5.4.orig/ncurses/trace/lib_tracedmp.c ncurses-5.4/ncurses/trace/lib_tracedmp.c
--- ncurses-5.4.orig/ncurses/trace/lib_tracedmp.c	2002-09-22 22:21:38.000000000 +0000
+++ ncurses-5.4/ncurses/trace/lib_tracedmp.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2002,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey 1996-2001                                      *
+ *  Author: Thomas E. Dickey 1996-on                                        *
  *     and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
  ****************************************************************************/
@@ -39,7 +39,7 @@
 #include <curses.priv.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_tracedmp.c,v 1.25 2002/09/22 22:21:38 tom Exp $")
+MODULE_ID("$Id: lib_tracedmp.c,v 1.26 2005/01/29 16:23:51 tom Exp $")
 
 #ifdef TRACE
 NCURSES_EXPORT(void)
@@ -53,10 +53,13 @@
     /* compute narrowest possible display width */
     for (width = i = 0; i <= win->_maxy; ++i) {
 	n = 0;
-	for (j = 0; j <= win->_maxx; ++j)
+	for (j = 0; j <= win->_maxx; ++j) {
 	    if (CharOf(win->_line[i].text[j]) != L(' ')
-		|| AttrOf(win->_line[i].text[j]) != A_NORMAL)
+		|| AttrOf(win->_line[i].text[j]) != A_NORMAL
+		|| GetPair(win->_line[i].text[j]) != 0) {
 		n = j;
+	    }
+	}
 
 	if (n > width)
 	    width = n;
@@ -99,15 +102,25 @@
 	/* dump A_COLOR part, will screw up if there are more than 96 */
 	havecolors = FALSE;
 	for (j = 0; j < width; ++j)
-	    if (AttrOf(win->_line[n].text[j]) & A_COLOR) {
+	    if (GetPair(win->_line[n].text[j]) != 0) {
 		havecolors = TRUE;
 		break;
 	    }
 	if (havecolors) {
 	    ep = buf;
-	    for (j = 0; j < width; ++j)
-		ep[j] = UChar(AttrOf(win->_line[n].text[j]) >>
-			      NCURSES_ATTR_SHIFT) + ' ';
+	    for (j = 0; j < width; ++j) {
+		int pair = GetPair(win->_line[n].text[j]);
+		if (pair >= 52)
+		    ep[j] = '?';
+		else if (pair >= 36)
+		    ep[j] = pair + 'A';
+		else if (pair >= 10)
+		    ep[j] = pair + 'a';
+		else if (pair >= 1)
+		    ep[j] = pair + '0';
+		else
+		    ep[j] = ' ';
+	    }
 	    ep[j] = '\0';
 	    _tracef("%*s[%2d]%*s='%s'", (int) strlen(name),
 		    "colors", n, 8, " ", buf);
diff -Naur ncurses-5.4.orig/ncurses/trace/lib_tracemse.c ncurses-5.4/ncurses/trace/lib_tracemse.c
--- ncurses-5.4.orig/ncurses/trace/lib_tracemse.c	2002-01-12 22:32:25.000000000 +0000
+++ ncurses-5.4/ncurses/trace/lib_tracemse.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000,2001,2002 Free Software Foundation, Inc.         *
+ * Copyright (c) 1998-2002,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -37,7 +38,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_tracemse.c,v 1.10 2002/01/12 22:32:25 tom Exp $")
+MODULE_ID("$Id: lib_tracemse.c,v 1.11 2005/02/05 18:24:04 tom Exp $")
 
 #ifdef TRACE
 
@@ -50,35 +51,57 @@
 		   ep->id, ep->x, ep->y, ep->z, ep->bstate);
 
 #define SHOW(m, s) if ((ep->bstate & m) == m) strcat(strcat(buf, s), ", ")
+
     SHOW(BUTTON1_RELEASED, "release-1");
     SHOW(BUTTON1_PRESSED, "press-1");
     SHOW(BUTTON1_CLICKED, "click-1");
     SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1");
     SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1");
+#if NCURSES_MOUSE_VERSION == 1
     SHOW(BUTTON1_RESERVED_EVENT, "reserved-1");
+#endif
+
     SHOW(BUTTON2_RELEASED, "release-2");
     SHOW(BUTTON2_PRESSED, "press-2");
     SHOW(BUTTON2_CLICKED, "click-2");
     SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2");
     SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2");
+#if NCURSES_MOUSE_VERSION == 1
     SHOW(BUTTON2_RESERVED_EVENT, "reserved-2");
+#endif
+
     SHOW(BUTTON3_RELEASED, "release-3");
     SHOW(BUTTON3_PRESSED, "press-3");
     SHOW(BUTTON3_CLICKED, "click-3");
     SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3");
     SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3");
+#if NCURSES_MOUSE_VERSION == 1
     SHOW(BUTTON3_RESERVED_EVENT, "reserved-3");
+#endif
+
     SHOW(BUTTON4_RELEASED, "release-4");
     SHOW(BUTTON4_PRESSED, "press-4");
     SHOW(BUTTON4_CLICKED, "click-4");
     SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4");
     SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4");
+#if NCURSES_MOUSE_VERSION == 1
     SHOW(BUTTON4_RESERVED_EVENT, "reserved-4");
+#endif
+
+#if NCURSES_MOUSE_VERSION == 2
+    SHOW(BUTTON5_RELEASED, "release-5");
+    SHOW(BUTTON5_PRESSED, "press-5");
+    SHOW(BUTTON5_CLICKED, "click-5");
+    SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5");
+    SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5");
+#endif
+
     SHOW(BUTTON_CTRL, "ctrl");
     SHOW(BUTTON_SHIFT, "shift");
     SHOW(BUTTON_ALT, "alt");
     SHOW(ALL_MOUSE_EVENTS, "all-events");
     SHOW(REPORT_MOUSE_POSITION, "position");
+
 #undef SHOW
 
     if (buf[strlen(buf) - 1] == ' ')
diff -Naur ncurses-5.4.orig/ncurses/trace/visbuf.c ncurses-5.4/ncurses/trace/visbuf.c
--- ncurses-5.4.orig/ncurses/trace/visbuf.c	2004-02-03 01:16:37.000000000 +0000
+++ ncurses-5.4/ncurses/trace/visbuf.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2001-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 2001-2004,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey 1996-2004                                      *
+ *  Author: Thomas E. Dickey                        1996-on                 *
  *     and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
  ****************************************************************************/
@@ -41,7 +41,7 @@
 #include <tic.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: visbuf.c,v 1.9 2004/02/03 01:16:37 tom Exp $")
+MODULE_ID("$Id: visbuf.c,v 1.12 2005/01/29 21:26:07 tom Exp $")
 
 static char *
 _nc_vischar(char *tp, unsigned c)
@@ -129,7 +129,7 @@
 #if USE_WIDEC_SUPPORT
 #ifdef TRACE
 static const char *
-_nc_viswbuf2n(int bufnum, const wchar_t * buf, int len)
+_nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
 {
     char *vbuf;
     char *tp;
@@ -168,25 +168,47 @@
 }
 
 NCURSES_EXPORT(const char *)
-_nc_viswbuf2(int bufnum, const wchar_t * buf)
+_nc_viswbuf2(int bufnum, const wchar_t *buf)
 {
     return _nc_viswbuf2n(bufnum, buf, -1);
 }
 
 NCURSES_EXPORT(const char *)
-_nc_viswbuf(const wchar_t * buf)
+_nc_viswbuf(const wchar_t *buf)
 {
     return _nc_viswbuf2(0, buf);
 }
 
 NCURSES_EXPORT(const char *)
-_nc_viswbufn(const wchar_t * buf, int len)
+_nc_viswbufn(const wchar_t *buf, int len)
 {
     return _nc_viswbuf2n(0, buf, len);
 }
 
+/* this special case is used for wget_wstr() */
 NCURSES_EXPORT(const char *)
-_nc_viscbuf2(int bufnum, const cchar_t * buf, int len)
+_nc_viswibuf(const wint_t *buf)
+{
+    static wchar_t *mybuf;
+    static unsigned mylen;
+    unsigned n;
+
+    for (n = 0; buf[n] != 0; ++n) ;
+    if (mylen < ++n) {
+	mylen = n + 80;
+	if (mybuf != 0)
+	    mybuf = typeRealloc(wchar_t, mylen, mybuf);
+	else
+	    mybuf = typeMalloc(wchar_t, mylen);
+    }
+    for (n = 0; buf[n] != 0; ++n)
+	mybuf[n] = (wchar_t) buf[n];
+
+    return _nc_viswbuf2(0, mybuf);
+}
+
+NCURSES_EXPORT(const char *)
+_nc_viscbuf2(int bufnum, const cchar_t *buf, int len)
 {
     char *result = _nc_trace_buf(bufnum, BUFSIZ);
     int n;
@@ -198,7 +220,7 @@
 	len = _nc_wchstrlen(buf);
 
     for (n = 1; n < len; n++) {
-	if (AttrOf(buf[n]) != AttrOf(buf[0])) {
+	if (!SameAttrOf(buf[n], buf[0])) {
 	    same = FALSE;
 	    break;
 	}
@@ -218,7 +240,7 @@
 	    if ((found = _nc_altcharset_name(attr, CharOfD(buf))) != 0) {
 		result = _nc_trace_bufcat(bufnum, found);
 		attr &= ~A_ALTCHARSET;
-	    } else if (!isnac(CHDEREF(buf))) {
+	    } else if (!isWidecExt(CHDEREF(buf))) {
 		PUTC_DATA;
 
 		PUTC_INIT;
@@ -260,7 +282,7 @@
 }
 
 NCURSES_EXPORT(const char *)
-_nc_viscbuf(const cchar_t * buf, int len)
+_nc_viscbuf(const cchar_t *buf, int len)
 {
     return _nc_viscbuf2(0, buf, len);
 }
diff -Naur ncurses-5.4.orig/ncurses/tty/MKexpanded.sh ncurses-5.4/ncurses/tty/MKexpanded.sh
--- ncurses-5.4.orig/ncurses/tty/MKexpanded.sh	2000-12-10 00:24:33.000000000 +0000
+++ ncurses-5.4/ncurses/tty/MKexpanded.sh	2005-05-13 04:09:51.000000000 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 ##############################################################################
-# Copyright (c) 1998,2000 Free Software Foundation, Inc.                     #
+# Copyright (c) 1998-2000,2005 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"), #
@@ -29,7 +29,7 @@
 #
 # Author: Thomas E. Dickey <dickey@clark.net> 1997
 #
-# $Id: MKexpanded.sh,v 1.10 2000/12/10 00:24:33 tom Exp $
+# $Id: MKexpanded.sh,v 1.11 2005/01/02 01:06:40 tom Exp $
 #
 # Script to generate 'expanded.c', a dummy source that contains functions
 # corresponding to complex macros used in this library.  By making functions,
@@ -84,7 +84,7 @@
 {
 	return InsCharCost(count);
 }
-NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype c)
+NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T c)
 {
 	UpdateAttrs(c);
 }
diff -Naur ncurses-5.4.orig/ncurses/tty/hashmap.c ncurses-5.4/ncurses/tty/hashmap.c
--- ncurses-5.4.orig/ncurses/tty/hashmap.c	2002-09-07 18:13:15.000000000 +0000
+++ ncurses-5.4/ncurses/tty/hashmap.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2002,2005 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            *
@@ -70,7 +70,7 @@
 #include <curses.priv.h>
 #include <term.h>		/* for back_color_erase */
 
-MODULE_ID("$Id: hashmap.c,v 1.46 2002/09/07 18:13:15 tom Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.47 2005/01/29 21:27:58 tom Exp $")
 
 #ifdef HASHDEBUG
 
@@ -143,7 +143,7 @@
     NCURSES_CH_T blank = NewChar2(BLANK_TEXT, BLANK_ATTR);
 
     if (back_color_erase)
-	AddAttr(blank, (AttrOf(stdscr->_nc_bkgd) & A_COLOR));
+	SetPair(blank, GetPair(stdscr->_nc_bkgd));
 
     for (i = TEXTWIDTH; i > 0; i--)
 	if (!(CharEq(blank, *to++)))
diff -Naur ncurses-5.4.orig/ncurses/tty/lib_mvcur.c ncurses-5.4/ncurses/tty/lib_mvcur.c
--- ncurses-5.4.orig/ncurses/tty/lib_mvcur.c	2003-12-27 16:43:59.000000000 +0000
+++ ncurses-5.4/ncurses/tty/lib_mvcur.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -154,7 +155,7 @@
 #include <term.h>
 #include <ctype.h>
 
-MODULE_ID("$Id: lib_mvcur.c,v 1.97 2003/12/27 16:43:59 tom Exp $")
+MODULE_ID("$Id: lib_mvcur.c,v 1.102 2005/01/22 22:15:45 tom Exp $")
 
 #define WANT_CHAR(y, x)	SP->_newscr->_line[y].text[x]	/* desired state */
 #define BAUDRATE	cur_term->_baudrate	/* bits per second */
@@ -589,9 +590,11 @@
 		    && n > 0
 		    && n < (int) check.s_size
 		    && vcost == 0
-		    && str[0] == '\0'
-		    && isdigit(CharOf(WANT_CHAR(to_y, from_x))))
-		    ovw = FALSE;
+		    && str[0] == '\0') {
+		    int wanted = CharOf(WANT_CHAR(to_y, from_x));
+		    if (is8bits(wanted) && isdigit(wanted))
+			ovw = FALSE;
+		}
 #endif
 		/*
 		 * If we have no attribute changes, overwrite is cheaper.
@@ -606,7 +609,7 @@
 
 		    for (i = 0; i < n; i++) {
 			NCURSES_CH_T ch = WANT_CHAR(to_y, from_x + i);
-			if (AttrOf(ch) != SP->_current_attr
+			if (!SameAttrOf(ch, SCREEN_ATTRS(SP))
 #if USE_WIDEC_SUPPORT
 			    || !Charable(ch)
 #endif
@@ -845,7 +848,7 @@
 mvcur(int yold, int xold, int ynew, int xnew)
 /* optimized cursor move from (yold, xold) to (ynew, xnew) */
 {
-    attr_t oldattr;
+    NCURSES_CH_T oldattr;
     int code;
 
     TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%d,%d,%d,%d)"),
@@ -872,12 +875,12 @@
 	 * character set -- these have a strong tendency to screw up the CR &
 	 * LF used for local character motions!
 	 */
-	oldattr = SP->_current_attr;
-	if ((oldattr & A_ALTCHARSET)
-	    || (oldattr && !move_standout_mode)) {
+	oldattr = SCREEN_ATTRS(SP);
+	if ((AttrOf(oldattr) & A_ALTCHARSET)
+	    || (AttrOf(oldattr) && !move_standout_mode)) {
 	    TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
-			       oldattr, _traceattr(oldattr)));
-	    (void) vidattr(A_NORMAL);
+			       AttrOf(oldattr), _traceattr(AttrOf(oldattr))));
+	    (void) VIDATTR(A_NORMAL, 0);
 	}
 
 	if (xold >= screen_columns) {
@@ -927,10 +930,10 @@
 	/*
 	 * Restore attributes if we disabled them before moving.
 	 */
-	if (oldattr != SP->_current_attr) {
+	if (!SameAttrOf(oldattr, SCREEN_ATTRS(SP))) {
 	    TR(TRACE_CHARPUT, ("turning on (%#lx) %s after move",
-			       oldattr, _traceattr(oldattr)));
-	    (void) vidattr(oldattr);
+			       AttrOf(oldattr), _traceattr(AttrOf(oldattr))));
+	    (void) VIDATTR(AttrOf(oldattr), GetPair(oldattr));
 	}
     }
     returnCode(code);
diff -Naur ncurses-5.4.orig/ncurses/tty/lib_twait.c ncurses-5.4/ncurses/tty/lib_twait.c
--- ncurses-5.4.orig/ncurses/tty/lib_twait.c	2003-11-30 00:34:36.000000000 +0000
+++ ncurses-5.4/ncurses/tty/lib_twait.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -61,7 +61,7 @@
 # endif
 #endif
 
-MODULE_ID("$Id: lib_twait.c,v 1.49 2003/11/30 00:34:36 Philippe.Blain Exp $")
+MODULE_ID("$Id: lib_twait.c,v 1.50 2004/09/25 22:53:43 tom Exp $")
 
 static long
 _nc_gettime(bool first)
@@ -226,7 +226,7 @@
     }
 #endif
 
-    result = poll(fds, count, milliseconds);
+    result = poll(fds, (unsigned) count, milliseconds);
 
 #ifdef NCURSES_WGETCH_EVENTS
     if ((mode & 4) && evl) {
diff -Naur ncurses-5.4.orig/ncurses/tty/lib_vidattr.c ncurses-5.4/ncurses/tty/lib_vidattr.c
--- ncurses-5.4.orig/ncurses/tty/lib_vidattr.c	2001-08-26 00:40:46.000000000 +0000
+++ ncurses-5.4/ncurses/tty/lib_vidattr.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc.         *
+ * Copyright (c) 1998-2004,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -64,7 +65,7 @@
 #include <curses.priv.h>
 #include <term.h>
 
-MODULE_ID("$Id: lib_vidattr.c,v 1.39 2001/08/26 00:40:46 Philippe.Blain Exp $")
+MODULE_ID("$Id: lib_vidattr.c,v 1.44 2005/01/22 22:15:44 tom Exp $")
 
 #define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
 
@@ -87,8 +88,7 @@
 	}
 
 NCURSES_EXPORT(int)
-vidputs
-(chtype newmode, int (*outc) (int))
+vidputs(chtype newmode, int (*outc) (int))
 {
     static attr_t previous_attr = A_NORMAL;
     attr_t turn_on, turn_off;
@@ -105,7 +105,7 @@
 
     /* this allows us to go on whether or not newterm() has been called */
     if (SP)
-	previous_attr = SP->_current_attr;
+	previous_attr = AttrOf(SCREEN_ATTRS(SP));
 
     TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(previous_attr)));
 
@@ -177,7 +177,7 @@
 		    TurnOff(A_STANDOUT, exit_standout_mode);
 		}
 	    }
-	    previous_attr &= ~A_COLOR;
+	    previous_attr &= ALL_BUT_COLOR;
 	}
 
 	SetColorsIf((pair != 0) || fix_pair0, previous_attr);
@@ -194,7 +194,7 @@
 			(newmode & A_INVIS) != 0,
 			(newmode & A_PROTECT) != 0,
 			(newmode & A_ALTCHARSET) != 0), 1, outc);
-	    previous_attr &= ~A_COLOR;
+	    previous_attr &= ALL_BUT_COLOR;
 	}
 	SetColorsIf((pair != 0) || fix_pair0, previous_attr);
     } else {
@@ -213,8 +213,8 @@
 
 	if (turn_off && exit_attribute_mode) {
 	    doPut(exit_attribute_mode);
-	    turn_on |= (newmode & (chtype) (~A_COLOR));
-	    previous_attr &= ~A_COLOR;
+	    turn_on |= (newmode & ALL_BUT_COLOR);
+	    previous_attr &= ALL_BUT_COLOR;
 	}
 	SetColorsIf((pair != 0) || fix_pair0, previous_attr);
 
@@ -229,22 +229,12 @@
 	TurnOn(A_PROTECT,	enter_protected_mode);
 	TurnOn(A_INVIS,		enter_secure_mode);
 	TurnOn(A_UNDERLINE,	enter_underline_mode);
-#ifdef enter_horizontal_hl_mode
+#if USE_WIDEC_SUPPORT
 	TurnOn(A_HORIZONTAL,	enter_horizontal_hl_mode);
-#endif
-#ifdef enter_left_hl_mode
 	TurnOn(A_LEFT,		enter_left_hl_mode);
-#endif
-#ifdef enter_low_hl_mode
 	TurnOn(A_LOW,		enter_low_hl_mode);
-#endif
-#ifdef enter_right_hl_mode
 	TurnOn(A_RIGHT,		enter_right_hl_mode);
-#endif
-#ifdef enter_top_hl_mode
 	TurnOn(A_TOP,		enter_top_hl_mode);
-#endif
-#ifdef enter_vertical_hl_mode
 	TurnOn(A_VERTICAL,	enter_vertical_hl_mode);
 #endif
 	/* *INDENT-ON* */
@@ -255,7 +245,7 @@
 	newmode |= A_REVERSE;
 
     if (SP)
-	SP->_current_attr = newmode;
+	SetAttr(SCREEN_ATTRS(SP), newmode);
     else
 	previous_attr = newmode;
 
diff -Naur ncurses-5.4.orig/ncurses/tty/tty_display.h ncurses-5.4/ncurses/tty/tty_display.h
--- ncurses-5.4.orig/ncurses/tty/tty_display.h	2003-08-02 22:59:07.000000000 +0000
+++ ncurses-5.4/ncurses/tty/tty_display.h	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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            *
@@ -30,7 +30,7 @@
 #define TTY_DISPLAY_H 1
 
 /*
- * $Id: tty_display.h,v 1.5 2003/08/02 22:59:07 Philippe.Blain Exp $
+ * $Id: tty_display.h,v 1.6 2005/01/01 23:41:12 tom Exp $
  */
 extern NCURSES_EXPORT(bool) _nc_tty_beep (void);
 extern NCURSES_EXPORT(bool) _nc_tty_check_resize (void);
@@ -118,7 +118,7 @@
 		    : INFINITY)))
 
 #if USE_XMC_SUPPORT
-#define UpdateAttrs(c)	if (D->_current_attr != AttrOf(c)) { \
+#define UpdateAttrs(c)	if (!SameAttrOf(D->_current_attr, AttrOf(c))) { \
 				attr_t chg = D->_current_attr; \
 				vidattr(AttrOf(c)); \
 				if (magic_cookie_glitch > 0 \
@@ -131,7 +131,7 @@
 				} \
 			}
 #else
-#define UpdateAttrs(c)	if (D->_current_attr != AttrOf(c)) \
+#define UpdateAttrs(c)	if (!SameAttrOf(D->_current_attr, AttrOf(c))) \
 				vidattr(AttrOf(c));
 #endif
 
diff -Naur ncurses-5.4.orig/ncurses/tty/tty_update.c ncurses-5.4/ncurses/tty/tty_update.c
--- ncurses-5.4.orig/ncurses/tty/tty_update.c	2004-02-07 18:02:42.000000000 +0000
+++ ncurses-5.4/ncurses/tty/tty_update.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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,7 +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-2004                                      *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 /*-----------------------------------------------------------------
@@ -74,7 +74,7 @@
 #include <ctype.h>
 #include <term.h>
 
-MODULE_ID("$Id: tty_update.c,v 1.205 2004/02/07 18:02:42 tom Exp $")
+MODULE_ID("$Id: tty_update.c,v 1.219 2005/02/05 22:51:25 tom Exp $")
 
 /*
  * This define controls the line-breakout optimization.  Every once in a
@@ -89,6 +89,8 @@
 
 #define FILL_BCE() (SP->_coloron && !SP->_default_color && !back_color_erase)
 
+static const NCURSES_CH_T normal = NewChar2(BLANK_TEXT, BLANK_ATTR);
+
 /*
  * Enable checking to see if doupdate and friends are tracking the true
  * cursor position correctly.  NOTE: this is a debugging hack which will
@@ -183,7 +185,7 @@
     NCURSES_CH_T my_ch;
     PUTC_DATA;
     NCURSES_CH_T tilde;
-    NCURSES_ATTR_T attr = AttrOfD(ch);
+    NCURSES_CH_T attr = CHDEREF(ch);
 
     TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
 		       _tracech_t(ch),
@@ -192,7 +194,7 @@
     /*
      * If this is not a valid character, there is nothing more to do.
      */
-    if (isnac(CHDEREF(ch)))
+    if (isWidecExt(CHDEREF(ch)))
 	return;
     /*
      * Determine the number of character cells which the 'ch' value will use
@@ -201,8 +203,9 @@
     if ((chlen = wcwidth(CharOf(CHDEREF(ch)))) <= 0) {
 	static NCURSES_CH_T blank = NewChar(BLANK_TEXT);
 
-	if (isprint(CharOf(CHDEREF(ch)))
-	    || (SP->_posix_locale && CharOf(CHDEREF(ch)) >= 160)) {
+	if (is8bits(CharOf(CHDEREF(ch)))
+	    && (isprint(CharOf(CHDEREF(ch)))
+		|| (SP->_legacy_coding && CharOf(CHDEREF(ch)) >= 160))) {
 	    ;
 	} else {
 	    ch = CHREF(blank);
@@ -212,7 +215,7 @@
     }
 #endif
 
-    if ((attr & A_ALTCHARSET)
+    if ((AttrOf(attr) & A_ALTCHARSET)
 	&& SP->_acs_map != 0
 	&& CharOfD(ch) < ACS_LEN) {
 	my_ch = CHDEREF(ch);	/* work around const param */
@@ -224,21 +227,30 @@
 	 * normal one to be broken (by mis-design ;-).
 	 */
 	if (SP->_screen_acs_fix
-	    && SP->_acs_map[CharOf(my_ch)] & A_ALTCHARSET) {
-	    attr &= ~(A_ALTCHARSET);
+	    && SP->_screen_acs_map[CharOf(my_ch)]) {
+	    RemAttr(attr, A_ALTCHARSET);
 	    my_ch = _nc_wacs[CharOf(my_ch)];
 	}
 #endif
-	if (attr & A_ALTCHARSET) {
-	    chtype temp = UChar(SP->_acs_map[CharOfD(ch)]);
+	/*
+	 * If we (still) have alternate character set, it is the normal 8bit
+	 * flavor.  The _screen_acs_map[] array tells if the character was
+	 * really in acs_chars, needed because of the way wide/normal line
+	 * drawing flavors are integrated.
+	 */
+	if (AttrOf(attr) & A_ALTCHARSET) {
+	    int j = CharOfD(ch);
+	    chtype temp = UChar(SP->_acs_map[j]);
+
+	    if (!(SP->_screen_acs_map[j]))
+		RemAttr(attr, A_ALTCHARSET);
 	    if (temp != 0)
-		SetChar(my_ch, temp, attr);
-	    RemAttr(my_ch, A_ALTCHARSET);
+		SetChar(my_ch, temp, AttrOf(attr));
 	}
 	ch = CHREF(my_ch);
     }
     if (tilde_glitch && (CharOfD(ch) == L('~'))) {
-	SetChar(tilde, L('`'), attr);
+	SetChar(tilde, L('`'), AttrOf(attr));
 	ch = CHREF(tilde);
     }
 
@@ -404,13 +416,15 @@
 {
     if (!back_color_erase && SP->_coloron) {
 #if NCURSES_EXT_FUNCS
+	int pair;
+
 	if (!SP->_default_color)
 	    return FALSE;
 	if (SP->_default_fg != C_MASK || SP->_default_bg != C_MASK)
 	    return FALSE;
-	if (AttrOfD(ch) & A_COLOR) {
+	if ((pair = GetPair(CHDEREF(ch))) != 0) {
 	    short fg, bg;
-	    pair_content(PAIR_NUMBER(AttrOfD(ch)), &fg, &bg);
+	    pair_content(pair, &fg, &bg);
 	    if (fg != C_MASK || bg != C_MASK)
 		return FALSE;
 	}
@@ -471,7 +485,7 @@
 	    if (erase_chars
 		&& runcount > SP->_ech_cost + SP->_cup_ch_cost
 		&& can_clear_with(CHREF(ntext0))) {
-		UpdateAttrs(AttrOf(ntext0));
+		UpdateAttrs(ntext0);
 		putp(tparm(erase_chars, runcount));
 
 		/*
@@ -491,7 +505,7 @@
 		if (wrap_possible)
 		    rep_count--;
 
-		UpdateAttrs(AttrOf(ntext0));
+		UpdateAttrs(ntext0);
 		tputs(tparm(repeat_char, CharOf(ntext0), rep_count),
 		      rep_count, _nc_outch);
 		SP->_curscol += rep_count;
@@ -535,7 +549,7 @@
     if (otext != ntext
 	&& (last - first + 1) > SP->_inline_cost) {
 	for (j = first, same = 0; j <= last; j++) {
-	    if (!same && isnac(otext[j]))
+	    if (!same && isWidecExt(otext[j]))
 		continue;
 	    if (CharEq(otext[j], ntext[j])) {
 		same++;
@@ -833,7 +847,7 @@
      * Keep the physical screen in normal mode in case we get other
      * processes writing to the screen.
      */
-    UpdateAttrs(A_NORMAL);
+    UpdateAttrs(normal);
 
     _nc_flush();
     curscr->_attrs = newscr->_attrs;
@@ -928,7 +942,7 @@
     }
 
     if (needclear) {
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	TPUTS_TRACE("clr_eol");
 	if (clr_eol && SP->_el_cost <= (screen_columns - SP->_curscol)) {
 	    putp(clr_eol);
@@ -954,7 +968,7 @@
     row = SP->_cursrow;
     col = SP->_curscol;
 
-    UpdateAttrs(AttrOf(blank));
+    UpdateAttrs(blank);
     TPUTS_TRACE("clr_eos");
     tputs(clr_eos, screen_lines - row, _nc_outch);
 
@@ -1059,14 +1073,12 @@
     int n;
     bool attrchanged = FALSE;
 
-    TR(TRACE_UPDATE, ("TransformLine(%d) called", lineno));
+    TR(TRACE_UPDATE, (T_CALLED("TransformLine(%d)"), lineno));
 
     /* copy new hash value to old one */
     if (SP->oldhash && SP->newhash)
 	SP->oldhash[lineno] = SP->newhash[lineno];
 
-#define ColorOf(n) (AttrOf(n) & A_COLOR)
-#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
     /*
      * If we have colors, there is the possibility of having two color pairs
      * that display as the same colors.  For instance, Lynx does this.  Check
@@ -1074,24 +1086,19 @@
      * they are equivalent.
      */
     if (SP->_coloron) {
-	attr_t oldColor;
-	attr_t newColor;
 	int oldPair;
 	int newPair;
 
 	for (n = 0; n < screen_columns; n++) {
 	    if (!CharEq(newLine[n], oldLine[n])) {
-		oldColor = ColorOf(oldLine[n]);
-		newColor = ColorOf(newLine[n]);
-		if (oldColor != newColor
+		oldPair = GetPair(oldLine[n]);
+		newPair = GetPair(newLine[n]);
+		if (oldPair != newPair
 		    && unColor(oldLine[n]) == unColor(newLine[n])) {
-		    oldPair = PAIR_NUMBER(oldColor);
-		    newPair = PAIR_NUMBER(newColor);
 		    if (oldPair < COLOR_PAIRS
 			&& newPair < COLOR_PAIRS
 			&& SP->_color_pairs[oldPair] == SP->_color_pairs[newPair]) {
-			RemAttr(oldLine[n], A_COLOR);
-			AddAttr(oldLine[n], ColorOf(newLine[n]));
+			SetPair(oldLine[n], GetPair(newLine[n]));
 		    }
 		}
 	    }
@@ -1101,7 +1108,7 @@
     if (ceol_standout_glitch && clr_eol) {
 	firstChar = 0;
 	while (firstChar < screen_columns) {
-	    if (AttrOf(newLine[firstChar]) != AttrOf(oldLine[firstChar])) {
+	    if (!SameAttrOf(newLine[firstChar], oldLine[firstChar])) {
 		attrchanged = TRUE;
 		break;
 	    }
@@ -1193,12 +1200,12 @@
 		    if (nFirstChar >= screen_columns
 			&& SP->_el_cost <= SP->_el1_cost) {
 			GoTo(lineno, 0);
-			UpdateAttrs(AttrOf(blank));
+			UpdateAttrs(blank);
 			TPUTS_TRACE("clr_eol");
 			putp(clr_eol);
 		    } else {
 			GoTo(lineno, nFirstChar - 1);
-			UpdateAttrs(AttrOf(blank));
+			UpdateAttrs(blank);
 			TPUTS_TRACE("clr_bol");
 			putp(clr_bol);
 		    }
@@ -1214,8 +1221,10 @@
 		firstChar++;
 	}
 	/* if there wasn't one, we're done */
-	if (firstChar >= screen_columns)
+	if (firstChar >= screen_columns) {
+	    TR(TRACE_UPDATE, (T_RETURN("")));
 	    return;
+	}
 
 	blank = newLine[screen_columns - 1];
 
@@ -1234,6 +1243,7 @@
 		       newLine + firstChar,
 		       (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
 	    }
+	    TR(TRACE_UPDATE, (T_RETURN("")));
 	    return;
 	}
 
@@ -1273,7 +1283,7 @@
 	    /* can be -1 if no characters differ */
 	    while (CharEq(newLine[nLastChar], oldLine[oLastChar])) {
 		/* don't split a wide char */
-		if (isnac(newLine[nLastChar]) &&
+		if (isWidecExt(newLine[nLastChar]) &&
 		    !CharEq(newLine[nLastChar - 1], oldLine[oLastChar - 1]))
 		    break;
 		nLastChar--;
@@ -1291,8 +1301,11 @@
 	    if (oLastChar < nLastChar) {
 		int m = max(nLastNonblank, oLastNonblank);
 		GoTo(lineno, n + 1);
-		if (InsCharCost(nLastChar - oLastChar)
-		    > (m - n)) {
+		if (
+#if USE_WIDEC_SUPPORT
+		       isWidecExt(newLine[n + 1]) ||
+#endif
+		       InsCharCost(nLastChar - oLastChar) > (m - n)) {
 		    PutRange(oldLine, newLine, lineno, n + 1, m);
 		} else {
 		    InsStr(&newLine[n + 1], nLastChar - oLastChar);
@@ -1314,7 +1327,7 @@
 		     * setting the video attributes from
 		     * the last character on the row.
 		     */
-		    UpdateAttrs(AttrOf(blank));
+		    UpdateAttrs(blank);
 		    DelChar(oLastChar - nLastChar);
 		}
 	    }
@@ -1326,6 +1339,8 @@
 	memcpy(oldLine + firstChar,
 	       newLine + firstChar,
 	       (screen_columns - firstChar) * sizeof(NCURSES_CH_T));
+    TR(TRACE_UPDATE, (T_RETURN("")));
+    return;
 }
 
 /*
@@ -1346,7 +1361,7 @@
 #if NCURSES_EXT_FUNCS
     if (SP->_coloron
 	&& !SP->_default_color) {
-	_nc_do_color((int) COLOR_PAIR(SP->_current_attr), 0, FALSE, _nc_outch);
+	_nc_do_color(GET_SCREEN_PAIR(SP), 0, FALSE, _nc_outch);
 	if (!back_color_erase) {
 	    fast_clear = FALSE;
 	}
@@ -1355,7 +1370,7 @@
 
     if (fast_clear) {
 	if (clear_screen) {
-	    UpdateAttrs(AttrOf(blank));
+	    UpdateAttrs(blank);
 	    TPUTS_TRACE("clear_screen");
 	    putp(clear_screen);
 	    SP->_cursrow = SP->_curscol = 0;
@@ -1364,13 +1379,13 @@
 	    SP->_cursrow = SP->_curscol = -1;
 	    GoTo(0, 0);
 
-	    UpdateAttrs(AttrOf(blank));
+	    UpdateAttrs(blank);
 	    TPUTS_TRACE("clr_eos");
 	    tputs(clr_eos, screen_lines, _nc_outch);
 	} else if (clr_eol) {
 	    SP->_cursrow = SP->_curscol = -1;
 
-	    UpdateAttrs(AttrOf(blank));
+	    UpdateAttrs(blank);
 	    for (i = 0; i < screen_lines; i++) {
 		GoTo(i, 0);
 		TPUTS_TRACE("clr_eol");
@@ -1379,7 +1394,7 @@
 	    GoTo(0, 0);
 	}
     } else {
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	for (i = 0; i < screen_lines; i++) {
 	    GoTo(i, 0);
 	    for (j = 0; j < screen_columns; j++)
@@ -1515,34 +1530,34 @@
 
     if (n == 1 && scroll_forward && top == miny && bot == maxy) {
 	GoTo(bot, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	TPUTS_TRACE("scroll_forward");
 	putp(scroll_forward);
     } else if (n == 1 && delete_line && bot == maxy) {
 	GoTo(top, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	TPUTS_TRACE("delete_line");
 	putp(delete_line);
     } else if (parm_index && top == miny && bot == maxy) {
 	GoTo(bot, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	TPUTS_TRACE("parm_index");
 	tputs(tparm(parm_index, n, 0), n, _nc_outch);
     } else if (parm_delete_line && bot == maxy) {
 	GoTo(top, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	TPUTS_TRACE("parm_delete_line");
 	tputs(tparm(parm_delete_line, n, 0), n, _nc_outch);
     } else if (scroll_forward && top == miny && bot == maxy) {
 	GoTo(bot, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	for (i = 0; i < n; i++) {
 	    TPUTS_TRACE("scroll_forward");
 	    putp(scroll_forward);
 	}
     } else if (delete_line && bot == maxy) {
 	GoTo(top, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	for (i = 0; i < n; i++) {
 	    TPUTS_TRACE("delete_line");
 	    putp(delete_line);
@@ -1573,34 +1588,34 @@
 
     if (n == 1 && scroll_reverse && top == miny && bot == maxy) {
 	GoTo(top, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	TPUTS_TRACE("scroll_reverse");
 	putp(scroll_reverse);
     } else if (n == 1 && insert_line && bot == maxy) {
 	GoTo(top, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	TPUTS_TRACE("insert_line");
 	putp(insert_line);
     } else if (parm_rindex && top == miny && bot == maxy) {
 	GoTo(top, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	TPUTS_TRACE("parm_rindex");
 	tputs(tparm(parm_rindex, n, 0), n, _nc_outch);
     } else if (parm_insert_line && bot == maxy) {
 	GoTo(top, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	TPUTS_TRACE("parm_insert_line");
 	tputs(tparm(parm_insert_line, n, 0), n, _nc_outch);
     } else if (scroll_reverse && top == miny && bot == maxy) {
 	GoTo(top, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	for (i = 0; i < n; i++) {
 	    TPUTS_TRACE("scroll_reverse");
 	    putp(scroll_reverse);
 	}
     } else if (insert_line && bot == maxy) {
 	GoTo(top, 0);
-	UpdateAttrs(AttrOf(blank));
+	UpdateAttrs(blank);
 	for (i = 0; i < n; i++) {
 	    TPUTS_TRACE("insert_line");
 	    putp(insert_line);
@@ -1632,7 +1647,7 @@
 	return ERR;
 
     GoTo(del, 0);
-    UpdateAttrs(AttrOf(blank));
+    UpdateAttrs(blank);
     if (n == 1 && delete_line) {
 	TPUTS_TRACE("delete_line");
 	putp(delete_line);
@@ -1647,7 +1662,7 @@
     }
 
     GoTo(ins, 0);
-    UpdateAttrs(AttrOf(blank));
+    UpdateAttrs(blank);
     if (n == 1 && insert_line) {
 	TPUTS_TRACE("insert_line");
 	putp(insert_line);
@@ -1800,7 +1815,7 @@
 _nc_screen_resume(void)
 {
     /* make sure terminal is in a sane known state */
-    SP->_current_attr = A_NORMAL;
+    SetAttr(SCREEN_ATTRS(SP), A_NORMAL);
     newscr->_clear = TRUE;
 
     /* reset color pairs and definitions */
@@ -1848,7 +1863,7 @@
 NCURSES_EXPORT(void)
 _nc_screen_wrap(void)
 {
-    UpdateAttrs(A_NORMAL);
+    UpdateAttrs(normal);
 #if NCURSES_EXT_FUNCS
     if (SP->_coloron
 	&& !SP->_default_color) {
@@ -1871,7 +1886,7 @@
 NCURSES_EXPORT(void)
 _nc_do_xmc_glitch(attr_t previous)
 {
-    attr_t chg = XMC_CHANGES(previous ^ SP->_current_attr);
+    attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP)));
 
     while (chg != 0) {
 	if (chg & 1) {
diff -Naur ncurses-5.4.orig/ncurses/widechar/charable.c ncurses-5.4/ncurses/widechar/charable.c
--- ncurses-5.4.orig/ncurses/widechar/charable.c	2003-07-05 18:04:08.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/charable.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2003 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2003-2004,2005 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,13 +32,13 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: charable.c,v 1.2 2003/07/05 18:04:08 tom Exp $")
+MODULE_ID("$Id: charable.c,v 1.4 2005/04/16 18:08:56 tom Exp $")
 
 NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch)
 {
     bool result;
 #if HAVE_WCTOB
-    result = (wctob(ch) == ch);
+    result = (wctob((wint_t) ch) == ch);
 #else
     result = (_nc_to_char(ch) >= 0);
 #endif
@@ -67,10 +67,13 @@
 #if HAVE_BTOWC
     result = btowc(ch);
 #elif HAVE_MBTOWC
+    wchar_t convert;
     char temp[2];
     temp[0] = ch;
     temp[1] = '\0';
-    if (mbtowc((wchar_t *) (&result), temp, 1) != 1)
+    if (mbtowc(&convert, temp, 1) >= 0)
+	result = convert;
+    else
 	result = WEOF;
 #endif
     return result;
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_add_wch.c ncurses-5.4/ncurses/widechar/lib_add_wch.c
--- ncurses-5.4.orig/ncurses/widechar/lib_add_wch.c	2004-02-07 17:53:33.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_add_wch.c	2005-05-13 04:09:51.000000000 +0000
@@ -35,7 +35,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_add_wch.c,v 1.2 2004/02/07 17:53:33 tom Exp $")
+MODULE_ID("$Id: lib_add_wch.c,v 1.4 2004/09/19 00:33:51 tom Exp $")
 
 NCURSES_EXPORT(int)
 wadd_wch(WINDOW *win, const cchar_t * wch)
@@ -54,12 +54,12 @@
 		break;
 	    if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) {
 		code = ERR;
-		if (PUTC_ch < 256)
-		    code = waddch(win, UChar(PUTC_ch));
+		if (is8bits(PUTC_ch))
+		    code = waddch(win, UChar(PUTC_ch) | wch->attr);
 		break;
 	    }
 	    for (n = 0; n < PUTC_n; n++) {
-		if ((code = waddch(win, UChar(PUTC_buf[n]))) == ERR) {
+		if ((code = waddch(win, UChar(PUTC_buf[n]) | wch->attr)) == ERR) {
 		    break;
 		}
 	    }
@@ -89,12 +89,12 @@
 		break;
 	    if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) {
 		code = ERR;
-		if (PUTC_ch < 256)
-		    code = waddch(win, UChar(PUTC_ch));
+		if (is8bits(PUTC_ch))
+		    code = waddch(win, UChar(PUTC_ch) | wch->attr);
 		break;
 	    }
 	    for (n = 0; n < PUTC_n; n++) {
-		if ((code = waddch(win, UChar(PUTC_buf[n]))) == ERR) {
+		if ((code = waddch(win, UChar(PUTC_buf[n]) | wch->attr)) == ERR) {
 		    break;
 		}
 	    }
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_cchar.c ncurses-5.4/ncurses/widechar/lib_cchar.c
--- ncurses-5.4.orig/ncurses/widechar/lib_cchar.c	2003-05-25 00:07:41.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_cchar.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2001-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 2001-2004,2005 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            *
@@ -35,17 +35,20 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_cchar.c,v 1.8 2003/05/25 00:07:41 tom Exp $")
+MODULE_ID("$Id: lib_cchar.c,v 1.11 2005/01/29 21:29:16 tom Exp $")
 
 /* 
  * The SuSv2 description leaves some room for interpretation.  We'll assume wch
- * is L'\0' terminated, contains at most one character with strictly positive
- * width, which must be the first, and contains no characters of negative
- * width.
+ * points to a string which is L'\0' terminated, contains at least one
+ * character with strictly positive width, which must be the first, and
+ * contains no characters of negative width.
  */
 NCURSES_EXPORT(int)
-setcchar(cchar_t * wcval, const wchar_t * wch, const attr_t attrs,
-	 short color_pair, const void *opts)
+setcchar(cchar_t *wcval,
+	 const wchar_t *wch,
+	 const attr_t attrs,
+	 short color_pair,
+	 const void *opts)
 {
     int i;
     int len;
@@ -54,10 +57,13 @@
     TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%ld,%d,%p)"),
 		      wcval, _nc_viswbuf(wch), attrs, color_pair, opts));
 
-    if (opts != NULL || (len = wcslen(wch)) > CCHARW_MAX
+    len = wcslen(wch);
+    if (opts != NULL
 	|| (len > 1 && wcwidth(wch[0]) < 0)) {
 	code = ERR;
     } else {
+	if (len > CCHARW_MAX)
+	    len = CCHARW_MAX;
 
 	/*
 	 * If we have a following spacing-character, stop at that point.  We
@@ -73,7 +79,8 @@
 	memset(wcval, 0, sizeof(*wcval));
 
 	if (len != 0) {
-	    SetAttr(*wcval, attrs | color_pair);
+	    SetAttr(*wcval, attrs | COLOR_PAIR(color_pair));
+	    SetPair(CHDEREF(wcval), color_pair);
 	    memcpy(&wcval->chars, wch, len * sizeof(wchar_t));
 	    TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len,
 			      _tracecchar_t(wcval)));
@@ -85,8 +92,11 @@
 }
 
 NCURSES_EXPORT(int)
-getcchar(const cchar_t * wcval, wchar_t * wch, attr_t * attrs,
-	 short *color_pair, void *opts)
+getcchar(const cchar_t *wcval,
+	 wchar_t *wch,
+	 attr_t *attrs,
+	 short *color_pair,
+	 void *opts)
 {
     wchar_t *wp;
     int len;
@@ -105,8 +115,8 @@
 	} else if (attrs == 0 || color_pair == 0) {
 	    code = ERR;
 	} else if (len >= 0) {
-	    *attrs = AttrOf(*wcval);
-	    *color_pair = AttrOf(*wcval) & A_COLOR;
+	    *attrs = AttrOf(*wcval) & A_ATTRIBUTES;
+	    *color_pair = GetPair(*wcval);
 	    wmemcpy(wch, wcval->chars, (unsigned) len);
 	    wch[len] = L'\0';
 	    code = OK;
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_get_wch.c ncurses-5.4/ncurses/widechar/lib_get_wch.c
--- ncurses-5.4.orig/ncurses/widechar/lib_get_wch.c	2004-01-18 01:18:17.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_get_wch.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002,2004 Free Software Foundation, Inc.                   *
+ * Copyright (c) 2002-2004,2005 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            *
@@ -38,25 +38,26 @@
 */
 
 #include <curses.priv.h>
+#include <ctype.h>
 
-MODULE_ID("$Id: lib_get_wch.c,v 1.6 2004/01/18 01:18:17 tom Exp $")
+MODULE_ID("$Id: lib_get_wch.c,v 1.11 2005/04/16 18:02:56 tom Exp $")
 
 #if HAVE_MBTOWC && HAVE_MBLEN
 #define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
 #define count_mbytes(buffer,length,state) mblen(buffer,length)
 #define check_mbytes(wch,buffer,length,state) \
-	(int) mbtowc(&wch, buffer, count)
+	(int) mbtowc(&wch, buffer, length)
 #elif HAVE_MBRTOWC && HAVE_MBRLEN
-#define reset_mbytes(state) memset(&state, 0, sizeof(state))
+#define reset_mbytes(state) init_mb(state)
 #define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
 #define check_mbytes(wch,buffer,length,state) \
-	(int) mbrtowc(&wch, buffer, count, &state)
+	(int) mbrtowc(&wch, buffer, length, &state)
 #else
 make an error
 #endif
 
 NCURSES_EXPORT(int)
-wget_wch(WINDOW *win, wint_t * result)
+wget_wch(WINDOW *win, wint_t *result)
 {
     int code;
     char buffer[(MB_LEN_MAX * 9) + 1];	/* allow some redundant shifts */
@@ -87,12 +88,12 @@
 	     * would be worth the effort.
 	     */
 	    if (count != 0) {
-		ungetch(value);
+		ungetch((int) value);
 		code = ERR;
 	    }
 	    break;
 	} else if (count + 1 >= sizeof(buffer)) {
-	    ungetch(value);
+	    ungetch((int) value);
 	    code = ERR;
 	    break;
 	} else {
@@ -103,6 +104,7 @@
 		reset_mbytes(state);
 		if (check_mbytes(wch, buffer, count, state) != status) {
 		    code = ERR;	/* the two calls should match */
+		    ungetch((int) value);
 		}
 		value = wch;
 		break;
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_get_wstr.c ncurses-5.4/ncurses/widechar/lib_get_wstr.c
--- ncurses-5.4.orig/ncurses/widechar/lib_get_wstr.c	2003-05-17 21:33:03.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_get_wstr.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
+ * Copyright (c) 2002-2003,2004 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey 2002                                           *
+ *  Author: Thomas E. Dickey                                                *
  ****************************************************************************/
 
 /*
@@ -40,23 +40,38 @@
 #include <curses.priv.h>
 #include <term.h>
 
-MODULE_ID("$Id: lib_get_wstr.c,v 1.6 2003/05/17 21:33:03 tom Exp $")
+MODULE_ID("$Id: lib_get_wstr.c,v 1.8 2004/10/16 21:55:36 tom Exp $")
+
+static int
+wadd_wint(WINDOW *win, wint_t *src)
+{
+    cchar_t tmp;
+    wchar_t wch[2];
+
+    wch[0] = *src;
+    wch[1] = 0;
+    setcchar(&tmp, wch, A_NORMAL, 0, NULL);
+    return wadd_wch(win, &tmp);
+}
 
 /*
  * This wipes out the last character, no matter whether it was a tab, control
  * or other character, and handles reverse wraparound.
  */
-static wchar_t *
-WipeOut(WINDOW *win, int y, int x, wchar_t * first, wchar_t * last, bool echoed)
+static wint_t *
+WipeOut(WINDOW *win, int y, int x, wint_t *first, wint_t *last, bool echoed)
 {
     if (last > first) {
 	*--last = '\0';
 	if (echoed) {
 	    int y1 = win->_cury;
 	    int x1 = win->_curx;
+	    int n;
 
 	    wmove(win, y, x);
-	    waddwstr(win, first);
+	    for (n = 0; first[n] != 0; ++n) {
+		wadd_wint(win, first + n);
+	    }
 	    getyx(win, y, x);
 	    while (win->_cury < y1
 		   || (win->_cury == y1 && win->_curx < x1))
@@ -69,14 +84,14 @@
 }
 
 NCURSES_EXPORT(int)
-wgetn_wstr(WINDOW *win, wint_t * str, int maxlen)
+wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
 {
     TTY buf;
     bool oldnl, oldecho, oldraw, oldcbreak;
     wint_t erasec;
     wint_t killc;
-    wchar_t *oldstr;
-    wchar_t *tmpstr;
+    wint_t *oldstr = str;
+    wint_t *tmpstr = str;
     wint_t ch;
     int y, x, code;
 
@@ -99,10 +114,6 @@
     erasec = erasechar();
     killc = killchar();
 
-    assert(sizeof(wchar_t) == sizeof(wint_t));
-    oldstr = (wchar_t *) str;
-    tmpstr = (wchar_t *) str;
-
     getyx(win, y, x);
 
     if (is_wintouched(win) || (win->_flags & _HASMOVED))
@@ -160,10 +171,8 @@
 	    *tmpstr = 0;
 	    if (oldecho == TRUE) {
 		int oldy = win->_cury;
-		cchar_t tmp;
 
-		setcchar(&tmp, tmpstr - 1, A_NORMAL, 0, NULL);
-		if (wadd_wch(win, &tmp) == ERR) {
+		if (wadd_wint(win, tmpstr - 1) == ERR) {
 		    /*
 		     * We can't really use the lower-right corner for input,
 		     * since it'll mess up bookkeeping for erases.
@@ -210,13 +219,13 @@
     *tmpstr = 0;
     if (code == ERR) {
 	if (tmpstr == oldstr) {
-	    *tmpstr++ = (wchar_t) WEOF;
+	    *tmpstr++ = WEOF;
 	    *tmpstr = 0;
 	}
 	returnCode(ERR);
     }
 
-    T(("wgetn_wstr returns %s", _nc_viswbuf(oldstr)));
+    T(("wgetn_wstr returns %s", _nc_viswibuf(oldstr)));
 
     returnCode(OK);
 }
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_in_wch.c ncurses-5.4/ncurses/widechar/lib_in_wch.c
--- ncurses-5.4.orig/ncurses/widechar/lib_in_wch.c	2002-08-03 20:23:29.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_in_wch.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2002,2004 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Author: Thomas Dickey 2002                                               *
+ * Author: Thomas Dickey 2002,2004                                          *
  ****************************************************************************/
 
 /*
@@ -39,7 +39,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_in_wch.c,v 1.2 2002/08/03 20:23:29 tom Exp $")
+MODULE_ID("$Id: lib_in_wch.c,v 1.3 2004/05/16 00:13:52 tom Exp $")
 
 NCURSES_EXPORT(int)
 win_wch(WINDOW *win, cchar_t * wcval)
@@ -56,5 +56,6 @@
     } else {
 	code = ERR;
     }
-    returnCode(code);
+    TR(TRACE_CCALLS, (T_RETURN("%d"), code));
+    return (code);
 }
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_in_wchnstr.c ncurses-5.4/ncurses/widechar/lib_in_wchnstr.c
--- ncurses-5.4.orig/ncurses/widechar/lib_in_wchnstr.c	2002-08-03 20:38:45.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_in_wchnstr.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2002,2004 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Author: Thomas Dickey 2002                                               *
+ * Author: Thomas Dickey 2002,2004                                          *
  ****************************************************************************/
 
 /*
@@ -39,22 +39,28 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_in_wchnstr.c,v 1.2 2002/08/03 20:38:45 tom Exp $")
+MODULE_ID("$Id: lib_in_wchnstr.c,v 1.3 2004/05/16 00:12:30 tom Exp $")
 
 NCURSES_EXPORT(int)
 win_wchnstr(WINDOW *win, cchar_t * wchstr, int n)
 {
     int code = OK;
 
-    TR(TRACE_CCALLS, (T_CALLED("win_wchnstr(%p,%p,%d)"), win, wchstr, n));
+    TR(TRACE_CALLS, (T_CALLED("win_wchnstr(%p,%p,%d)"), win, wchstr, n));
     if (win != 0
 	&& wchstr != 0) {
+	int row, col;
+	int j;
+
+	getyx(win, row, col);
 
 	if (n < 0) {
 	    n = getmaxx(win) + 1 - getcurx(win);
 	}
-	while (n-- > 0)
-	    win_wch(win, wchstr++);
+	for (j = 0; j < n; ++j) {
+	    wchstr[j] = win->_line[row].text[col + j];
+	}
+	T(("result = %s", _nc_viscbuf(wchstr, n)));
     } else {
 	code = ERR;
     }
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_ins_wch.c ncurses-5.4/ncurses/widechar/lib_ins_wch.c
--- ncurses-5.4.orig/ncurses/widechar/lib_ins_wch.c	2003-03-29 21:52:29.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_ins_wch.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
+ * Copyright (c) 2002-2003,2005 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            *
@@ -39,20 +39,25 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_ins_wch.c,v 1.3 2003/03/29 21:52:29 tom Exp $")
+MODULE_ID("$Id: lib_ins_wch.c,v 1.6 2005/04/16 18:04:32 tom Exp $")
 
 /*
  * Insert the given character, updating the current location to simplify
  * inserting a string.
  */
-static void
-_nc_insert_wch(WINDOW *win, const cchar_t * wch)
+static int
+_nc_insert_wch(WINDOW *win, const cchar_t *wch)
 {
+    int cells = wcwidth(CharOf(CHDEREF(wch)));
+
+    if (cells <= 0)
+	cells = 1;
+
     if (win->_curx <= win->_maxx) {
 	struct ldat *line = &(win->_line[win->_cury]);
 	NCURSES_CH_T *end = &(line->text[win->_curx]);
 	NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
-	NCURSES_CH_T *temp2 = temp1 - 1;
+	NCURSES_CH_T *temp2 = temp1 - cells;
 
 	CHANGED_TO_EOL(line, win->_curx, win->_maxx);
 	while (temp1 > end)
@@ -62,10 +67,11 @@
 
 	win->_curx++;
     }
+    return OK;
 }
 
 NCURSES_EXPORT(int)
-wins_wch(WINDOW *win, const cchar_t * wch)
+wins_wch(WINDOW *win, const cchar_t *wch)
 {
     NCURSES_SIZE_T oy;
     NCURSES_SIZE_T ox;
@@ -77,18 +83,17 @@
 	oy = win->_cury;
 	ox = win->_curx;
 
-	_nc_insert_wch(win, wch);
+	code = _nc_insert_wch(win, wch);
 
 	win->_curx = ox;
 	win->_cury = oy;
 	_nc_synchook(win);
-	code = OK;
     }
     returnCode(code);
 }
 
 NCURSES_EXPORT(int)
-wins_nwstr(WINDOW *win, const wchar_t * wstr, int n)
+wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
 {
     int code = ERR;
     NCURSES_SIZE_T oy;
@@ -101,11 +106,14 @@
 	&& wstr != 0) {
 	if (n < 1)
 	    n = wcslen(wstr);
+	code = OK;
 	if (n > 0) {
 	    oy = win->_cury;
 	    ox = win->_curx;
 	    for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
-		if (wcwidth(*cp) > 1) {
+		int len = wcwidth(*cp);
+
+		if (len != 1) {
 		    cchar_t tmp_cchar;
 		    wchar_t tmp_wchar = *cp;
 		    memset(&tmp_cchar, 0, sizeof(tmp_cchar));
@@ -114,17 +122,19 @@
 				    WA_NORMAL,
 				    0,
 				    (void *) 0);
-		    _nc_insert_wch(win, &tmp_cchar);
+		    code = _nc_insert_wch(win, &tmp_cchar);
 		} else {
-		    _nc_insert_ch(win, *cp);	/* tabs, other ASCII stuff */
+		    /* tabs, other ASCII stuff */
+		    code = _nc_insert_ch(win, (chtype)(*cp));
 		}
+		if (code != OK)
+		    break;
 	    }
 
 	    win->_curx = ox;
 	    win->_cury = oy;
 	    _nc_synchook(win);
 	}
-	code = OK;
     }
     returnCode(code);
 }
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_inwstr.c ncurses-5.4/ncurses/widechar/lib_inwstr.c
--- ncurses-5.4.orig/ncurses/widechar/lib_inwstr.c	2002-10-06 00:56:36.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_inwstr.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2002,2004 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- * Author: Thomas Dickey 2002                                               *
+ * Author: Thomas Dickey                                                    *
  ****************************************************************************/
 
 /*
@@ -39,10 +39,10 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_inwstr.c,v 1.3 2002/10/06 00:56:36 tom Exp $")
+MODULE_ID("$Id: lib_inwstr.c,v 1.4 2004/10/23 20:41:28 tom Exp $")
 
 NCURSES_EXPORT(int)
-winnwstr(WINDOW *win, wchar_t * wstr, int n)
+winnwstr(WINDOW *win, wchar_t *wstr, int n)
 {
     int row, col, inx;
     int count = 0;
@@ -57,7 +57,7 @@
 
 	    text = win->_line[row].text;
 	    while (count < n && count != ERR) {
-		if (!isnac(text[col])) {
+		if (!isWidecExt(text[col])) {
 		    for (inx = 0; (inx < CCHARW_MAX)
 			 && ((wch = text[col].chars[inx]) != 0);
 			 ++inx) {
@@ -90,7 +90,7 @@
  * it does not define what happens for a negative count with winnwstr().
  */
 NCURSES_EXPORT(int)
-winwstr(WINDOW *win, wchar_t * wstr)
+winwstr(WINDOW *win, wchar_t *wstr)
 {
     int result = OK;
     T((T_CALLED("winwstr(%p,%p)"), win, wstr));
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_slk_wset.c ncurses-5.4/ncurses/widechar/lib_slk_wset.c
--- ncurses-5.4.orig/ncurses/widechar/lib_slk_wset.c	2004-01-03 21:14:03.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_slk_wset.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2003,2004 Free Software Foundation, Inc.                   *
+ * Copyright (c) 2003-2004,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey, 2003                                          *
+ *  Author: Thomas E. Dickey                                                *
  ****************************************************************************/
 
 /*
@@ -36,114 +36,37 @@
  */
 #include <curses.priv.h>
 
-#ifdef HAVE_WCTYPE_H
+#if HAVE_WCTYPE_H
 #include <wctype.h>
 #endif
 
-MODULE_ID("$Id: lib_slk_wset.c,v 1.6 2004/01/03 21:14:03 tom Exp $")
+MODULE_ID("$Id: lib_slk_wset.c,v 1.11 2005/01/16 01:03:53 tom Exp $")
 
 NCURSES_EXPORT(int)
-slk_wset(int i, const wchar_t * astr, int format)
+slk_wset(int i, const wchar_t *astr, int format)
 {
-    static wchar_t empty[] =
-    {L'\0'};
     int result = ERR;
-    SLK *slk = SP->_slk;
-    int offset;
     size_t arglen;
-    const wchar_t *p;
+    const wchar_t *str;
+    char *mystr;
+    mbstate_t state;
 
     T((T_CALLED("slk_wset(%d, %s, %d)"), i, _nc_viswbuf(astr), format));
 
-    if (astr == 0)
-	astr = empty;
-    arglen = wcslen(astr);
-    while (iswspace(*astr)) {
-	--arglen;
-	++astr;			/* skip over leading spaces  */
-    }
-    p = astr;
-    while (iswprint(*p))
-	p++;			/* The first non-print stops */
-
-    arglen = (size_t) (p - astr);
-
-    if (slk != NULL &&
-	i >= 1 &&
-	i <= slk->labcnt &&
-	format >= 0 &&
-	format <= 2) {
-	char *new_text;
-	size_t n;
-	size_t used = 0;
-	int mycols;
-	mbstate_t state;
-
-	--i;			/* Adjust numbering of labels */
-
-	/*
-	 * Reduce the actual number of columns to fit in the label field.
-	 */
-	while (arglen != 0 && wcswidth(astr, arglen) > slk->maxlen) {
-	    --arglen;
-	}
-	mycols = wcswidth(astr, arglen);
-
-	/*
-	 * translate the wide-character string to multibyte form.
-	 */
-	memset(&state, 0, sizeof(state));
-
-	if ((new_text = (char *) _nc_doalloc(0, MB_LEN_MAX * arglen)) == 0)
-	    returnCode(ERR);
-
-	for (n = 0; n < arglen; ++n) {
-	    used += wcrtomb(new_text + used, astr[n], &state);
-	}
-	new_text[used] = '\0';
-
-	if (used >= (size_t) (slk->maxlen + 1)) {
-	    if ((slk->ent[i].ent_text = (char *) _nc_doalloc(slk->ent[i].ent_text,
-							     used + 1)) == 0)
-		returnCode(ERR);
-	    if ((slk->ent[i].form_text = (char *) _nc_doalloc(slk->ent[i].form_text,
-							      used + 1)) == 0)
-		returnCode(ERR);
-	}
-
-	(void) strcpy(slk->ent[i].ent_text, new_text);
-	free(new_text);
-
-	sprintf(slk->ent[i].form_text, "%*s", (size_t) slk->maxlen, " ");
-
-	switch (format) {
-	default:
-	case 0:		/* left-aligned */
-	    offset = 0;
-	    break;
-	case 1:		/* centered */
-	    offset = (slk->maxlen - mycols) / 2;
-	    break;
-	case 2:		/* right-aligned */
-	    offset = slk->maxlen - mycols;
-	    break;
-	}
-	if (offset < 0)
-	    offset = 0;
-	strcpy(slk->ent[i].form_text + offset,
-	       slk->ent[i].ent_text);
-	/*
-	 * Pad the display with blanks on the right, unless it is already
-	 * right-aligned.
-	 */
-	if (format != 2 && mycols < slk->maxlen) {
-	    sprintf(slk->ent[i].form_text + offset + used,
-		    "%*s",
-		    slk->maxlen - (mycols - offset),
-		    " ");
+    init_mb(state);
+    str = astr;
+    if ((arglen = wcsrtombs(NULL, &str, 0, &state)) != (size_t) -1) {
+	if ((mystr = (char *) _nc_doalloc(0, arglen + 1)) != 0) {
+	    str = astr;
+	    if (wcsrtombs(mystr, &str, arglen, &state) != (size_t) -1) {
+		/* glibc documentation claims that the terminating L'\0'
+		 * is written, but it is not...
+		 */
+		mystr[arglen] = 0;
+		result = slk_set(i, mystr, format);
+	    }
+	    free(mystr);
 	}
-	slk->ent[i].dirty = TRUE;
-	result = OK;
     }
     returnCode(result);
 }
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_unget_wch.c ncurses-5.4/ncurses/widechar/lib_unget_wch.c
--- ncurses-5.4.orig/ncurses/widechar/lib_unget_wch.c	2003-07-05 19:46:51.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_unget_wch.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002,2003 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2002-2003,2004 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            *
@@ -39,7 +39,26 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_unget_wch.c,v 1.5 2003/07/05 19:46:51 tom Exp $")
+MODULE_ID("$Id: lib_unget_wch.c,v 1.7 2004/12/05 01:21:31 tom Exp $")
+
+#ifdef linux
+/*
+ * glibc's wcrtomb() function is broken - does not return the proper value
+ * when target is null (noted for glibc 2.3.2).  This is a workaround.
+ */
+NCURSES_EXPORT(size_t)
+_nc_wcrtomb(char *target, wchar_t source, mbstate_t * state)
+{
+    if (target == 0) {
+	wchar_t temp[2];
+	const wchar_t *tempp = temp;
+	temp[0] = source;
+	temp[1] = 0;
+	return wcsrtombs(NULL, &tempp, 0, state);
+    }
+    return wcrtomb(target, source, state);
+}
+#endif
 
 NCURSES_EXPORT(int)
 unget_wch(const wchar_t wch)
@@ -51,15 +70,15 @@
 
     T((T_CALLED("unget_wch(%#lx)"), (unsigned long) wch));
 
-    memset(&state, 0, sizeof(state));
-    length = wcrtomb(0, wch, &state);
+    init_mb(state);
+    length = _nc_wcrtomb(0, wch, &state);
 
     if (length != (size_t) (-1)
 	&& length != 0) {
 	char *string;
 
 	if ((string = (char *) malloc(length)) != 0) {
-	    memset(&state, 0, sizeof(state));
+	    init_mb(state);
 	    wcrtomb(string, wch, &state);
 
 	    for (n = (int) (length - 1); n >= 0; --n) {
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_vid_attr.c ncurses-5.4/ncurses/widechar/lib_vid_attr.c
--- ncurses-5.4.orig/ncurses/widechar/lib_vid_attr.c	2002-05-11 20:55:26.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_vid_attr.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2002-2004,2005 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            *
@@ -27,68 +27,248 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey 2002                                           *
+ *  Author: Thomas E. Dickey                                                *
  ****************************************************************************/
 
 #include <curses.priv.h>
 #include <term.h>
 
-MODULE_ID("$Id: lib_vid_attr.c,v 1.1 2002/05/11 20:55:26 tom Exp $")
+MODULE_ID("$Id: lib_vid_attr.c,v 1.3 2005/01/29 18:34:00 tom Exp $")
 
-#define set_color(mode, pair) mode &= ~A_COLOR; mode |= COLOR_PAIR(pair)
+#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
+
+#define TurnOn(mask,mode) \
+	if ((turn_on & mask) && mode) { doPut(mode); }
+
+#define TurnOff(mask,mode) \
+	if ((turn_off & mask) && mode) { doPut(mode); turn_off &= ~mask; }
+
+	/* if there is no current screen, assume we *can* do color */
+#define SetColorsIf(why, old_attr, old_pair) \
+	if (can_color && (why)) { \
+		TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, pair)); \
+		if ((pair != old_pair) \
+		 || (fix_pair0 && (pair == 0)) \
+		 || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
+			_nc_do_color(old_pair, pair, reverse, outc); \
+		} \
+	}
+
+#define set_color(mode, pair) mode &= ALL_BUT_COLOR; mode |= COLOR_PAIR(pair)
 
 NCURSES_EXPORT(int)
 vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
 {
+#if NCURSES_EXT_COLORS
+    static attr_t previous_attr = A_NORMAL;
+    static int previous_pair = 0;
+
+    attr_t turn_on, turn_off;
+    bool reverse = FALSE;
+    bool can_color = (SP == 0 || SP->_coloron);
+#if NCURSES_EXT_FUNCS
+    bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color);
+#else
+#define fix_pair0 FALSE
+#endif
+
+    T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair));
+
+    /* this allows us to go on whether or not newterm() has been called */
+    if (SP) {
+	previous_attr = AttrOf(SCREEN_ATTRS(SP));
+	previous_pair = GetPair(SCREEN_ATTRS(SP));
+    }
+
+    TR(TRACE_ATTRS, ("previous attribute was %s, %d",
+		     _traceattr(previous_attr), previous_pair));
+
+#if !USE_XMC_SUPPORT
+    if ((SP != 0)
+	&& (magic_cookie_glitch > 0))
+	newmode &= ~(SP->_xmc_suppress);
+#endif
+
+    /*
+     * If we have a terminal that cannot combine color with video
+     * attributes, use the colors in preference.
+     */
+    if ((pair != 0
+	 || fix_pair0)
+	&& (no_color_video > 0)) {
+	/*
+	 * If we had chosen the A_xxx definitions to correspond to the
+	 * no_color_video mask, we could simply shift it up and mask off the
+	 * attributes.  But we did not (actually copied Solaris' definitions).
+	 * However, this is still simpler/faster than a lookup table.
+	 *
+	 * The 63 corresponds to A_STANDOUT, A_UNDERLINE, A_REVERSE, A_BLINK,
+	 * A_DIM, A_BOLD which are 1:1 with no_color_video.  The bits that
+	 * correspond to A_INVIS, A_PROTECT (192) must be shifted up 1 and
+	 * A_ALTCHARSET (256) down 2 to line up.  We use the NCURSES_BITS
+	 * macro so this will work properly for the wide-character layout.
+	 */
+	unsigned value = no_color_video;
+	attr_t mask = NCURSES_BITS((value & 63)
+				   | ((value & 192) << 1)
+				   | ((value & 256) >> 2), 8);
+
+	if ((mask & A_REVERSE) != 0
+	    && (newmode & A_REVERSE) != 0) {
+	    reverse = TRUE;
+	    mask &= ~A_REVERSE;
+	}
+	newmode &= ~mask;
+    }
+
+    if (newmode == previous_attr
+	&& pair == previous_pair)
+	returnCode(OK);
+
+    if (reverse) {
+	newmode &= ~A_REVERSE;
+    }
+
+    turn_off = (~newmode & previous_attr) & ALL_BUT_COLOR;
+    turn_on = (newmode & ~previous_attr) & ALL_BUT_COLOR;
+
+    SetColorsIf(((pair == 0) && !fix_pair0), previous_attr, previous_pair);
+
+    if (newmode == A_NORMAL) {
+	if ((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
+	    doPut(exit_alt_charset_mode);
+	    previous_attr &= ~A_ALTCHARSET;
+	}
+	if (previous_attr) {
+	    if (exit_attribute_mode) {
+		doPut(exit_attribute_mode);
+	    } else {
+		if (!SP || SP->_use_rmul) {
+		    TurnOff(A_UNDERLINE, exit_underline_mode);
+		}
+		if (!SP || SP->_use_rmso) {
+		    TurnOff(A_STANDOUT, exit_standout_mode);
+		}
+	    }
+	    previous_attr &= ALL_BUT_COLOR;
+	    previous_pair = 0;
+	}
+
+	SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
+    } else if (set_attributes) {
+	if (turn_on || turn_off) {
+	    TPUTS_TRACE("set_attributes");
+	    tputs(tparm(set_attributes,
+			(newmode & A_STANDOUT) != 0,
+			(newmode & A_UNDERLINE) != 0,
+			(newmode & A_REVERSE) != 0,
+			(newmode & A_BLINK) != 0,
+			(newmode & A_DIM) != 0,
+			(newmode & A_BOLD) != 0,
+			(newmode & A_INVIS) != 0,
+			(newmode & A_PROTECT) != 0,
+			(newmode & A_ALTCHARSET) != 0), 1, outc);
+	    previous_attr &= ALL_BUT_COLOR;
+	    previous_pair = 0;
+	}
+	SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
+    } else {
+
+	TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off)));
+
+	TurnOff(A_ALTCHARSET, exit_alt_charset_mode);
+
+	if (!SP || SP->_use_rmul) {
+	    TurnOff(A_UNDERLINE, exit_underline_mode);
+	}
+
+	if (!SP || SP->_use_rmso) {
+	    TurnOff(A_STANDOUT, exit_standout_mode);
+	}
+
+	if (turn_off && exit_attribute_mode) {
+	    doPut(exit_attribute_mode);
+	    turn_on |= (newmode & ALL_BUT_COLOR);
+	    previous_attr &= ALL_BUT_COLOR;
+	    previous_pair = 0;
+	}
+	SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
+
+	TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on)));
+	/* *INDENT-OFF* */
+	TurnOn(A_ALTCHARSET,	enter_alt_charset_mode);
+	TurnOn(A_BLINK,		enter_blink_mode);
+	TurnOn(A_BOLD,		enter_bold_mode);
+	TurnOn(A_DIM,		enter_dim_mode);
+	TurnOn(A_REVERSE,	enter_reverse_mode);
+	TurnOn(A_STANDOUT,	enter_standout_mode);
+	TurnOn(A_PROTECT,	enter_protected_mode);
+	TurnOn(A_INVIS,		enter_secure_mode);
+	TurnOn(A_UNDERLINE,	enter_underline_mode);
+#if USE_WIDEC_SUPPORT
+	TurnOn(A_HORIZONTAL,	enter_horizontal_hl_mode);
+	TurnOn(A_LEFT,		enter_left_hl_mode);
+	TurnOn(A_LOW,		enter_low_hl_mode);
+	TurnOn(A_RIGHT,		enter_right_hl_mode);
+	TurnOn(A_TOP,		enter_top_hl_mode);
+	TurnOn(A_VERTICAL,	enter_vertical_hl_mode);
+#endif
+	/* *INDENT-ON* */
+
+    }
+
+    if (reverse)
+	newmode |= A_REVERSE;
+
+    if (SP) {
+	SetAttr(SCREEN_ATTRS(SP), newmode);
+	SetPair(SCREEN_ATTRS(SP), pair);
+    } else {
+	previous_attr = newmode;
+	previous_pair = pair;
+    }
+
+    returnCode(OK);
+#else
     T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair));
     set_color(newmode, pair);
     returnCode(vidputs(newmode, outc));
+#endif
 }
 
 #undef vid_attr
 NCURSES_EXPORT(int)
-vid_attr(attr_t newmode, short pair, void *opts GCC_UNUSED)
+vid_attr(attr_t newmode, short pair, void *opts)
 {
     T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), pair));
-    set_color(newmode, pair);
-    returnCode(vidputs(newmode, _nc_outch));
+    returnCode(vid_puts(newmode, pair, opts, _nc_outch));
 }
 
+/*
+ * This implementation uses the same mask values for A_xxx and WA_xxx, so
+ * we can use termattrs() for part of the logic.
+ */
 NCURSES_EXPORT(attr_t)
 term_attrs(void)
 {
-    attr_t attrs = WA_NORMAL;
+    attr_t attrs;
 
     T((T_CALLED("term_attrs()")));
-    if (enter_alt_charset_mode)
-	attrs |= WA_ALTCHARSET;
-
-    if (enter_blink_mode)
-	attrs |= WA_BLINK;
-
-    if (enter_bold_mode)
-	attrs |= WA_BOLD;
-
-    if (enter_dim_mode)
-	attrs |= WA_DIM;
-
-    if (enter_reverse_mode)
-	attrs |= WA_REVERSE;
-
-    if (enter_standout_mode)
-	attrs |= WA_STANDOUT;
-
-    if (enter_protected_mode)
-	attrs |= WA_PROTECT;
-
-    if (enter_secure_mode)
-	attrs |= WA_INVIS;
-
-    if (enter_underline_mode)
-	attrs |= WA_UNDERLINE;
+    attrs = termattrs();
 
-    if (SP->_coloron)
-	attrs |= A_COLOR;
+    /* these are only supported for wide-character mode */
+    if (enter_horizontal_hl_mode)
+	attrs |= WA_HORIZONTAL;
+    if (enter_left_hl_mode)
+	attrs |= WA_LEFT;
+    if (enter_low_hl_mode)
+	attrs |= WA_LOW;
+    if (enter_right_hl_mode)
+	attrs |= WA_RIGHT;
+    if (enter_top_hl_mode)
+	attrs |= WA_TOP;
+    if (enter_vertical_hl_mode)
+	attrs |= WA_VERTICAL;
 
     returnAttr(attrs);
 }
diff -Naur ncurses-5.4.orig/ncurses/widechar/lib_wunctrl.c ncurses-5.4/ncurses/widechar/lib_wunctrl.c
--- ncurses-5.4.orig/ncurses/widechar/lib_wunctrl.c	2003-07-05 17:01:43.000000000 +0000
+++ ncurses-5.4/ncurses/widechar/lib_wunctrl.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2001,2003 Free Software Foundation, Inc.                   *
+ * Copyright (c) 2001-2003,2005 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            *
@@ -37,16 +37,17 @@
 
 #if USE_WIDEC_SUPPORT
 
-MODULE_ID("$Id: lib_wunctrl.c,v 1.7 2003/07/05 17:01:43 tom Exp $")
+MODULE_ID("$Id: lib_wunctrl.c,v 1.8 2005/04/16 18:10:44 tom Exp $")
 
 NCURSES_EXPORT(wchar_t *)
-wunctrl(cchar_t * wc)
+wunctrl(cchar_t *wc)
 {
     static wchar_t str[5], *sp;
 
     if (Charable(*wc)) {
-	const char *p;
-	for (p = unctrl(_nc_to_char(CharOf(*wc))), sp = str; *p;)
+	const char *p = unctrl((unsigned) _nc_to_char((wint_t) CharOf(*wc)));
+
+	for (sp = str; *p;)
 	    *sp++ = _nc_to_widechar(*p++);
 	return str;
     } else
diff -Naur ncurses-5.4.orig/ncurses-5.4-20050319-patch.sh ncurses-5.4/ncurses-5.4-20050319-patch.sh
--- ncurses-5.4.orig/ncurses-5.4-20050319-patch.sh	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/ncurses-5.4-20050319-patch.sh	2005-05-13 04:09:47.000000000 +0000
@@ -0,0 +1,64418 @@
+#!/bin/sh
+# Use this script to patch ncurses 5.4 to 5.4 (20050319)
+# Run this script inside the ncurses 5.4 source directory et voila! Updated.
+
+if ( egrep '^NCURSES_MAJOR = 5$' dist.mk >/dev/null 2>&1 \
+  && egrep '^NCURSES_MINOR = 4$' dist.mk >/dev/null 2>&1 \
+  && egrep '^NCURSES_PATCH = 20040208$' dist.mk >/dev/null 2>&1 )
+then
+        echo patching...
+	rm -f misc/indent.pro
+else
+        echo 'This does not look like ncurses 5.4'
+        exit 1
+fi
+
+patch -p1 -i $0         # shell command = this script = inputfile for patch
+exit
+
+# ------------------------------------------------------------------------------
+# Ada95/gen/Makefile.in                                                     |   11 
+# Ada95/gen/gen.c                                                           | 1073 -
+# Ada95/gen/terminal_interface-curses-mouse.ads.m4                          |    6 
+# Ada95/gen/terminal_interface-curses.ads.m4                                |   10 
+# Ada95/samples/Makefile.in                                                 |   21 
+# Ada95/samples/ncurses2-acs_and_scroll.adb                                 |   15 
+# Ada95/samples/ncurses2-acs_display.adb                                    |   21 
+# Ada95/samples/ncurses2-attr_test.adb                                      |   11 
+# Ada95/samples/ncurses2-color_edit.adb                                     |    7 
+# Ada95/samples/ncurses2-demo_forms.adb                                     |   11 
+# Ada95/samples/ncurses2-demo_pad.adb                                       |   40 
+# Ada95/samples/ncurses2-demo_panels.adb                                    |   31 
+# Ada95/samples/ncurses2-getch_test.adb                                     |   12 
+# Ada95/samples/ncurses2-getopt.adb                                         |    9 
+# Ada95/samples/ncurses2-m.adb                                              |    5 
+# Ada95/samples/ncurses2-menu_test.adb                                      |    8 
+# Ada95/samples/ncurses2-overlap_test.adb                                   |    9 
+# Ada95/samples/ncurses2-slk_test.adb                                       |   12 
+# Ada95/samples/ncurses2-util.adb                                           |   10 
+# Ada95/samples/sample-curses_demo.adb                                      |    7 
+# Ada95/samples/sample-explanation.adb                                      |    9 
+# Ada95/samples/sample-form_demo-aux.adb                                    |   12 
+# Ada95/samples/sample-form_demo-handler.adb                                |    7 
+# Ada95/samples/sample-form_demo.adb                                        |   10 
+# Ada95/samples/sample-function_key_setting.adb                             |    7 
+# Ada95/samples/sample-header_handler.adb                                   |   17 
+# Ada95/samples/sample-keyboard_handler.adb                                 |   10 
+# Ada95/samples/sample-menu_demo-handler.adb                                |    7 
+# Ada95/samples/sample-menu_demo.adb                                        |   15 
+# Ada95/samples/sample-my_field_type.adb                                    |   10 
+# Ada95/samples/sample-text_io_demo.adb                                     |   11 
+# Ada95/src/Makefile.in                                                     |   13 
+# Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb |    7 
+# Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb     |    9 
+# Ada95/src/terminal_interface-curses-forms-field_types-user.adb            |   12 
+# Ada95/src/terminal_interface-curses-forms-field_types.adb                 |    7 
+# Ada95/src/terminal_interface-curses-forms.adb                             |   21 
+# Ada95/src/terminal_interface-curses-menus.adb                             |   25 
+# Ada95/src/terminal_interface-curses-mouse.adb                             |   12 
+# Ada95/src/terminal_interface-curses-panels.adb                            |    7 
+# Ada95/src/terminal_interface-curses-termcap.adb                           |    9 
+# Ada95/src/terminal_interface-curses-text_io.adb                           |   29 
+# Ada95/src/terminal_interface-curses-trace.adb_p                           |   10 
+# Ada95/src/terminal_interface-curses.adb                                   |   33 
+# INSTALL                                                                   |  110 
+# MANIFEST                                                                  |   10 
+# Makefile.in                                                               |    8 
+# NEWS                                                                      |  511 
+# README                                                                    |    4 
+# TO-DO                                                                     |    5 
+# aclocal.m4                                                                |  556 
+# c++/Makefile.in                                                           |   11 
+# c++/cursesm.cc                                                            |   10 
+# c++/cursesw.h                                                             |    6 
+# config.guess                                                              |  131 
+# config.sub                                                                |   95 
+# configure                                                                 | 6004 +++++-----
+# configure.in                                                              |  341 
+# dist.mk                                                                   |    4 
+# doc/html/ncurses-intro.html                                               |   22 
+# doc/ncurses-intro.doc                                                     |   31 
+# form/Makefile.in                                                          |    9 
+# form/fld_arg.c                                                            |   44 
+# form/fld_attr.c                                                           |   51 
+# form/fld_current.c                                                        |   77 
+# form/fld_def.c                                                            |  351 
+# form/fld_dup.c                                                            |   66 
+# form/fld_ftchoice.c                                                       |   15 
+# form/fld_ftlink.c                                                         |   25 
+# form/fld_info.c                                                           |   55 
+# form/fld_just.c                                                           |   25 
+# form/fld_link.c                                                           |   62 
+# form/fld_max.c                                                            |   20 
+# form/fld_move.c                                                           |   13 
+# form/fld_newftyp.c                                                        |   75 
+# form/fld_opts.c                                                           |   35 
+# form/fld_pad.c                                                            |   20 
+# form/fld_page.c                                                           |   18 
+# form/fld_stat.c                                                           |   18 
+# form/fld_type.c                                                           |   23 
+# form/fld_user.c                                                           |   15 
+# form/form.h                                                               |  206 
+# form/form.priv.h                                                          |  179 
+# form/frm_cursor.c                                                         |   12 
+# form/frm_data.c                                                           |  110 
+# form/frm_def.c                                                            |  235 
+# form/frm_driver.c                                                         | 2981 ++--
+# form/frm_hook.c                                                           |   58 
+# form/frm_opts.c                                                           |   25 
+# form/frm_page.c                                                           |   32 
+# form/frm_post.c                                                           |   34 
+# form/frm_req_name.c                                                       |  167 
+# form/frm_scale.c                                                          |   20 
+# form/frm_sub.c                                                            |   24 
+# form/frm_user.c                                                           |   13 
+# form/frm_win.c                                                            |   25 
+# form/fty_alnum.c                                                          |  132 
+# form/fty_alpha.c                                                          |  145 
+# form/fty_enum.c                                                           |  206 
+# form/fty_int.c                                                            |  164 
+# form/fty_ipv4.c                                                           |   31 
+# form/fty_num.c                                                            |  241 
+# form/fty_regex.c                                                          |  135 
+# form/llib-lform                                                           |  108 
+# form/llib-lformw                                                          |  116 
+# form/modules                                                              |    7 
+# include/curses.h.in                                                       |   51 
+# include/curses.tail                                                       |  104 
+# include/curses.wide                                                       |    4 
+# include/nc_alloc.h                                                        |   17 
+# include/ncurses_cfg.hin                                                   |   14 
+# include/ncurses_defs                                                      |   10 
+# include/term_entry.h                                                      |   13 
+# include/tic.h                                                             |   15 
+# install-sh                                                                |   49 
+# man/Makefile.in                                                           |    5 
+# man/captoinfo.1m                                                          |   20 
+# man/curs_add_wchstr.3x                                                    |    9 
+# man/curs_addwstr.3x                                                       |    7 
+# man/curs_beep.3x                                                          |    8 
+# man/curs_bkgrnd.3x                                                        |    5 
+# man/curs_border_set.3x                                                    |    5 
+# man/curs_color.3x                                                         |   32 
+# man/curs_extend.3x                                                        |    6 
+# man/curs_getch.3x                                                         |    6 
+# man/curs_in_wchstr.3x                                                     |    6 
+# man/curs_insstr.3x                                                        |   40 
+# man/curs_inwstr.3x                                                        |    5 
+# man/curs_mouse.3x                                                         |   35 
+# man/default_colors.3x                                                     |   26 
+# man/define_key.3x                                                         |    7 
+# man/form_field_buffer.3x                                                  |   10 
+# man/infocmp.1m                                                            |  150 
+# man/infotocap.1m                                                          |   18 
+# man/key_defined.3x                                                        |    6 
+# man/menu_spacing.3x                                                       |    6 
+# man/ncurses.3x                                                            |   31 
+# man/term.5                                                                |   10 
+# man/terminfo.head                                                         |   14 
+# man/terminfo.tail                                                         |   71 
+# man/tic.1m                                                                |  102 
+# man/toe.1m                                                                |   16 
+# man/tput.1                                                                |   94 
+# man/tset.1                                                                |   67 
+# menu/Makefile.in                                                          |    4 
+# menu/llib-lmenu                                                           |   41 
+# menu/llib-lmenuw                                                          |   41 
+# menu/m_attribs.c                                                          |   20 
+# menu/m_cursor.c                                                           |   33 
+# menu/m_driver.c                                                           |  646 -
+# menu/m_format.c                                                           |   68 
+# menu/m_global.c                                                           |  401 
+# menu/m_hook.c                                                             |   24 
+# menu/m_item_cur.c                                                         |   30 
+# menu/m_item_nam.c                                                         |   16 
+# menu/m_item_new.c                                                         |  125 
+# menu/m_item_opt.c                                                         |   57 
+# menu/m_item_top.c                                                         |   39 
+# menu/m_item_use.c                                                         |   14 
+# menu/m_item_val.c                                                         |   24 
+# menu/m_item_vis.c                                                         |   23 
+# menu/m_items.c                                                            |   32 
+# menu/m_new.c                                                              |   30 
+# menu/m_opts.c                                                             |   49 
+# menu/m_pad.c                                                              |   25 
+# menu/m_pattern.c                                                          |   51 
+# menu/m_post.c                                                             |  269 
+# menu/m_req_name.c                                                         |   74 
+# menu/m_scale.c                                                            |   17 
+# menu/m_spacing.c                                                          |   37 
+# menu/m_sub.c                                                              |   20 
+# menu/m_userptr.c                                                          |   14 
+# menu/m_win.c                                                              |   20 
+# menu/menu.priv.h                                                          |   38 
+# menu/mf_common.h                                                          |   19 
+# menu/modules                                                              |    5 
+# misc/Makefile.in                                                          |   22 
+# misc/run_tic.in                                                           |   39 
+# misc/shlib                                                                |   14 
+# misc/terminfo.src                                                         | 1043 +
+# mk-0th.awk                                                                |   36 
+# mk-1st.awk                                                                |   28 
+# mk-2nd.awk                                                                |   45 
+# ncurses-5.4-20050319/form/f_trace.c                                       |   70 
+# ncurses-5.4-20050319/menu/m_trace.c                                       |   77 
+# ncurses-5.4-20050319/misc/gen_edit.sh                                     |   58 
+# ncurses-5.4-20050319/misc/jpf-indent                                      |   87 
+# ncurses-5.4-20050319/misc/ncu-indent                                      |   98 
+# ncurses-5.4-20050319/ncurses/base/lib_insnstr.c                           |   68 
+# ncurses-5.4-20050319/test/linux-color.dat                                 |   21 
+# ncurses-5.4-20050319/test/xterm-16color.dat                               |   26 
+# ncurses-5.4-20050319/test/xterm-88color.dat                               |   98 
+# ncurses/Makefile.in                                                       |   11 
+# ncurses/base/MKunctrl.awk                                                 |    9 
+# ncurses/base/lib_addch.c                                                  |  311 
+# ncurses/base/lib_addstr.c                                                 |   73 
+# ncurses/base/lib_bkgd.c                                                   |   26 
+# ncurses/base/lib_chgat.c                                                  |   13 
+# ncurses/base/lib_color.c                                                  |  137 
+# ncurses/base/lib_colorset.c                                               |   13 
+# ncurses/base/lib_dft_fgbg.c                                               |   20 
+# ncurses/base/lib_freeall.c                                                |   16 
+# ncurses/base/lib_getch.c                                                  |    7 
+# ncurses/base/lib_insch.c                                                  |   98 
+# ncurses/base/lib_instr.c                                                  |   43 
+# ncurses/base/lib_mouse.c                                                  |  336 
+# ncurses/base/lib_move.c                                                   |    9 
+# ncurses/base/lib_newterm.c                                                |   15 
+# ncurses/base/lib_newwin.c                                                 |    7 
+# ncurses/base/lib_pad.c                                                    |    6 
+# ncurses/base/lib_scroll.c                                                 |   27 
+# ncurses/base/lib_set_term.c                                               |   30 
+# ncurses/base/lib_slk.c                                                    |   25 
+# ncurses/base/lib_slkatr_set.c                                             |   18 
+# ncurses/base/lib_slkatrof.c                                               |   15 
+# ncurses/base/lib_slkatron.c                                               |   15 
+# ncurses/base/lib_slkatrset.c                                              |   10 
+# ncurses/base/lib_slkattr.c                                                |   12 
+# ncurses/base/lib_slkcolor.c                                               |   12 
+# ncurses/base/lib_slkrefr.c                                                |   14 
+# ncurses/base/lib_slkset.c                                                 |   84 
+# ncurses/base/lib_wattroff.c                                               |   11 
+# ncurses/base/lib_wattron.c                                                |   13 
+# ncurses/base/resizeterm.c                                                 |   43 
+# ncurses/base/version.c                                                    |    6 
+# ncurses/base/vsscanf.c                                                    |    6 
+# ncurses/curses.priv.h                                                     |  300 
+# ncurses/llib-lncurses                                                     | 1006 -
+# ncurses/llib-lncursesw                                                    | 1396 +-
+# ncurses/modules                                                           |    5 
+# ncurses/tinfo/alloc_entry.c                                               |   35 
+# ncurses/tinfo/captoinfo.c                                                 |   10 
+# ncurses/tinfo/comp_error.c                                                |   14 
+# ncurses/tinfo/comp_parse.c                                                |   63 
+# ncurses/tinfo/comp_scan.c                                                 |  416 
+# ncurses/tinfo/init_keytry.c                                               |   18 
+# ncurses/tinfo/lib_acs.c                                                   |   15 
+# ncurses/tinfo/lib_data.c                                                  |   20 
+# ncurses/tinfo/lib_kernel.c                                                |    6 
+# ncurses/tinfo/lib_options.c                                               |   83 
+# ncurses/tinfo/lib_setup.c                                                 |  108 
+# ncurses/tinfo/lib_termcap.c                                               |  165 
+# ncurses/tinfo/name_match.c                                                |   15 
+# ncurses/tinfo/parse_entry.c                                               |   12 
+# ncurses/tinfo/read_entry.c                                                |   37 
+# ncurses/tinfo/read_termcap.c                                              |   22 
+# ncurses/trace/lib_trace.c                                                 |   33 
+# ncurses/trace/lib_traceatr.c                                              |   27 
+# ncurses/trace/lib_tracechr.c                                              |    8 
+# ncurses/trace/lib_tracedmp.c                                              |   31 
+# ncurses/trace/lib_tracemse.c                                              |   27 
+# ncurses/trace/visbuf.c                                                    |   44 
+# ncurses/tty/MKexpanded.sh                                                 |    6 
+# ncurses/tty/hashmap.c                                                     |    6 
+# ncurses/tty/lib_mvcur.c                                                   |   33 
+# ncurses/tty/lib_twait.c                                                   |    6 
+# ncurses/tty/lib_vidattr.c                                                 |   32 
+# ncurses/tty/tty_display.h                                                 |    8 
+# ncurses/tty/tty_update.c                                                  |  145 
+# ncurses/widechar/charable.c                                               |    9 
+# ncurses/widechar/lib_add_wch.c                                            |   14 
+# ncurses/widechar/lib_cchar.c                                              |   36 
+# ncurses/widechar/lib_get_wch.c                                            |   12 
+# ncurses/widechar/lib_get_wstr.c                                           |   45 
+# ncurses/widechar/lib_in_wch.c                                             |    9 
+# ncurses/widechar/lib_in_wchnstr.c                                         |   18 
+# ncurses/widechar/lib_ins_wch.c                                            |   36 
+# ncurses/widechar/lib_inwstr.c                                             |   12 
+# ncurses/widechar/lib_slk_wset.c                                           |  119 
+# ncurses/widechar/lib_unget_wch.c                                          |   29 
+# ncurses/widechar/lib_vid_attr.c                                           |  252 
+# panel/llib-lpanel                                                         |    9 
+# panel/llib-lpanelw                                                        |    9 
+# panel/p_above.c                                                           |   15 
+# panel/p_below.c                                                           |   15 
+# panel/p_bottom.c                                                          |   48 
+# panel/p_delete.c                                                          |   15 
+# panel/p_hidden.c                                                          |   15 
+# panel/p_hide.c                                                            |   19 
+# panel/p_move.c                                                            |   24 
+# panel/p_new.c                                                             |   58 
+# panel/p_replace.c                                                         |   25 
+# panel/p_show.c                                                            |   30 
+# panel/p_top.c                                                             |    9 
+# panel/p_update.c                                                          |   13 
+# panel/p_user.c                                                            |   22 
+# panel/p_win.c                                                             |   13 
+# panel/panel.c                                                             |   89 
+# panel/panel.priv.h                                                        |   14 
+# progs/Makefile.in                                                         |    6 
+# progs/dump_entry.c                                                        |   49 
+# progs/dump_entry.h                                                        |   20 
+# progs/infocmp.c                                                           |  206 
+# progs/tic.c                                                               |  220 
+# progs/tset.c                                                              |    6 
+# tack/Makefile.in                                                          |    4 
+# tack/charset.c                                                            |   50 
+# tack/control.c                                                            |   25 
+# tack/edit.c                                                               |    8 
+# tack/fun.c                                                                |    8 
+# tack/init.c                                                               |    8 
+# tack/output.c                                                             |    4 
+# tack/pad.c                                                                |   10 
+# tack/scan.c                                                               |   33 
+# tack/sync.c                                                               |   16 
+# tack/sysdep.c                                                             |   12 
+# tack/tack.c                                                               |   35 
+# tack/tack.h                                                               |  192 
+# test/Makefile.in                                                          |   77 
+# test/README                                                               |  143 
+# test/aclocal.m4                                                           |  393 
+# test/bs.c                                                                 |    4 
+# test/cardfile.c                                                           |  131 
+# test/color_set.c                                                          |   12 
+# test/configure                                                            |  977 +
+# test/configure.in                                                         |   20 
+# test/demo_forms.c                                                         |  124 
+# test/dots.c                                                               |   14 
+# test/edit_field.c                                                         |    4 
+# test/filter.c                                                             |    4 
+# test/gdc.c                                                                |   39 
+# test/ins_wide.c                                                           |  400 
+# test/inserts.c                                                            |  297 
+# test/lrtest.c                                                             |    8 
+# test/ncurses.c                                                            | 1635 ++
+# test/newdemo.c                                                            |    6 
+# test/test.priv.h                                                          |   10 
+# test/testcurs.c                                                           |    9 
+# test/tracemunch                                                           |   48 
+# test/view.c                                                               |   42 
+# test/worm.c                                                               |    4 
+# 331 files changed, 21062 insertions(+), 12077 deletions(-)
+# ------------------------------------------------------------------------------
+Index: Ada95/gen/Makefile.in
+--- ncurses-5.4-20040208/Ada95/gen/Makefile.in	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/gen/Makefile.in	2005-01-22 20:23:07.000000000 +0000
+@@ -1,5 +1,5 @@
+ ##############################################################################
+-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2004,2005 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"), #
+@@ -28,8 +28,7 @@
+ #
+ #  Author:  Juergen Pfeifer, 1996
+ #
+-#  Version Control
+-#  $Revision: 1.44 $
++#  $Id: Makefile.in,v 1.47 2005/01/22 20:23:07 tom Exp $
+ #
+ .SUFFIXES:
+ 
+@@ -152,7 +151,7 @@
+ 
+ all \
+ libs :	$(GEN_TARGETS)
+-	@
++	@echo made $@
+ 
+ sources:
+ 
+@@ -184,7 +183,7 @@
+ 	-@cd $(ADA_OBJECTS) && rm -f $(ALIB)[-.]*
+ 
+ gen$x:	gen.o
+-	@ECHO_LINK@ $(LINK) $(CFLAGS_NORMAL) gen.o $(LD_FLAGS) -o $@ $(LIB_CURSES)
++	@ECHO_LINK@ $(LINK) $(CFLAGS_NORMAL) gen.o $(LD_FLAGS) -o $@
+ 
+ gen.o:	$(srcdir)/gen.c
+ 	$(HOST_CC) $(CFLAGS_NORMAL) -c -o $@ $(srcdir)/gen.c
+@@ -431,7 +430,7 @@
+ 	@rm -rf html
+ 
+ html : adahtml $(HTML_DIR)/table.html
+-	@
++	@echo made $@
+ 
+ ###############################################################################
+ # The remainder of this file is automatically generated during configuration
+Index: Ada95/gen/gen.c
+--- ncurses-5.4-20040208/Ada95/gen/gen.c	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/gen/gen.c	2005-01-22 17:03:48.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998,2004,2005 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 @@
+ 
+ /*
+     Version Control
+-    $Revision: 1.36 $
++    $Id: gen.c,v 1.40 2005/01/22 17:03:48 tom Exp $
+   --------------------------------------------------------------------------*/
+ /*
+   This program generates various record structures and constants from the
+@@ -55,27 +55,31 @@
+ static const char *model = "";
+ static int little_endian = 0;
+ 
+-typedef struct {
+-  const char *name;
+-  unsigned long attr;
+-} name_attribute_pair;
++typedef struct
++  {
++    const char *name;
++    unsigned long attr;
++  }
++name_attribute_pair;
+ 
+-static int find_pos (char *s, unsigned len, int *low, int *high)
++static int
++find_pos(char *s, unsigned len, int *low, int *high)
+ {
+-  unsigned int i,j;
++  unsigned int i, j;
+   int l = 0;
+ 
+   *high = -1;
+-  *low  = 8*len;
++  *low = 8 * len;
+ 
+-  for(i=0; i < len; i++,s++)
++  for (i = 0; i < len; i++, s++)
+     {
+       if (*s)
+ 	{
+-	  for(j=0;j<8*sizeof(char);j++)
++	  for (j = 0; j < 8 * sizeof(char); j++)
++
+ 	    {
+-	      if ((( little_endian && ((*s)&0x01)) ||
+-		   (!little_endian && ((*s)&0x80))) )
++	      if (((little_endian && ((*s) & 0x01)) ||
++		   (!little_endian && ((*s) & 0x80))))
+ 		{
+ 		  if (l > *high)
+ 		    *high = l;
+@@ -102,212 +106,229 @@
+  * bit size, i.e. they fit into an (u)int or a (u)short.
+  */
+ static void
+-gen_reps
+-(const name_attribute_pair *nap, /* array of name_attribute_pair records */
+- const char *name,               /* name of the represented record type  */
+- int len,                        /* size of the record in bytes          */
+- int bias)
++  gen_reps
++  (const name_attribute_pair * nap,	/* array of name_attribute_pair records */
++   const char *name,		/* name of the represented record type  */
++   int len,			/* size of the record in bytes          */
++   int bias)
+ {
+-  int i,n,l,cnt = 0,low,high;
++  int i, n, l, cnt = 0, low, high;
+   int width = strlen(RES_NAME) + 3;
+   unsigned long a;
+   unsigned long mask = 0;
+ 
+-  assert (nap!=NULL);
++  assert(nap != NULL);
+ 
+-  for (i=0; nap[i].name != (char *)0; i++)
++  for (i = 0; nap[i].name != (char *)0; i++)
+     {
+       cnt++;
+       l = strlen(nap[i].name);
+-      if (l>width)
++      if (l > width)
+ 	width = l;
+     }
+-  assert (width > 0);
++  assert(width > 0);
+ 
+-  printf("   type %s is\n",name);
++  printf("   type %s is\n", name);
+   printf("      record\n");
+-  for (i=0; nap[i].name != (char *)0; i++)
++  for (i = 0; nap[i].name != (char *)0; i++)
+     {
+-      printf("         %-*s : Boolean;\n",width,nap[i].name);
++      printf("         %-*s : Boolean;\n", width, nap[i].name);
+     }
+   printf("      end record;\n");
+-  printf("   pragma Pack (%s);\n",name);
+-  printf("   pragma Convention (C, %s);\n\n",name);
++  printf("   pragma Convention (C, %s);\n\n", name);
+ 
+-  printf("   for %s use\n",name);
++  printf("   for %s use\n", name);
+   printf("      record\n");
+ 
+-  for (i=0; nap[i].name != (char *)0; i++)
++  for (i = 0; nap[i].name != (char *)0; i++)
+     {
+       a = nap[i].attr;
+       mask |= a;
+-      l = find_pos( (char *)&a,sizeof(a),&low,&high );
+-      if (l>=0)
+-	printf("         %-*s at 0 range %2d .. %2d;\n",width,nap[i].name,
+-	       low-bias,high-bias);
++      l = find_pos((char *)&a, sizeof(a), &low, &high);
++      if (l >= 0)
++	printf("         %-*s at 0 range %2d .. %2d;\n", width, nap[i].name,
++	       low - bias, high - bias);
+     }
+-  i = 1; n = cnt;
++  i = 1;
++  n = cnt;
+   printf("      end record;\n");
+-  printf("   for %s'Size use %d;\n", name, 8*len);
++  printf("   for %s'Size use %d;\n", name, 8 * len);
+   printf("   --  Please note: this rep. clause is generated and may be\n");
+   printf("   --               different on your system.");
+ }
+ 
+-
+-static void chtype_rep (const char *name, attr_t mask)
++static void
++chtype_rep(const char *name, attr_t mask)
+ {
+   attr_t x = -1;
+   attr_t t = x & mask;
+   int low, high;
+-  int l = find_pos ((char *)&t, sizeof(t), &low, &high);
+-  if (l>=0)
+-    printf("         %-5s at 0 range %2d .. %2d;\n",name,low,high);
++  int l = find_pos((char *)&t, sizeof(t), &low, &high);
++
++  if (l >= 0)
++    printf("         %-5s at 0 range %2d .. %2d;\n", name, low, high);
+ }
+ 
+-static void gen_chtype_rep(const char *name)
+-{
+-  printf("   for %s use\n      record\n",name);
+-  chtype_rep("Ch",A_CHARTEXT);
+-  chtype_rep("Color",A_COLOR);
+-  chtype_rep("Attr",(A_ATTRIBUTES&~A_COLOR));
+-  printf("      end record;\n   for %s'Size use %ld;\n", name, (long)(8*sizeof(chtype)));
++static void
++gen_chtype_rep(const char *name)
++{
++  printf("   for %s use\n      record\n", name);
++  chtype_rep("Ch", A_CHARTEXT);
++  chtype_rep("Color", A_COLOR);
++  chtype_rep("Attr", (A_ATTRIBUTES & ~A_COLOR));
++  printf("      end record;\n   for %s'Size use %ld;\n",
++	 name, (long)(8 * sizeof(chtype)));
++
+   printf("      --  Please note: this rep. clause is generated and may be\n");
+   printf("      --               different on your system.\n");
+ }
+ 
+-
+-static void mrep_rep (const char *name, void *rec)
++static void
++mrep_rep(const char *name, void *rec)
+ {
+   int low, high;
+   int l = find_pos((char *)rec, sizeof(MEVENT), &low, &high);
+-  if (l>=0)
+-    printf("         %-7s at 0 range %3d .. %3d;\n",name,low,high);
+-}
+ 
++  if (l >= 0)
++    printf("         %-7s at 0 range %3d .. %3d;\n", name, low, high);
++}
+ 
+-static void gen_mrep_rep(const char *name)
++static void
++gen_mrep_rep(const char *name)
+ {
+   MEVENT x;
+ 
+-  printf("   for %s use\n      record\n",name);
++  printf("   for %s use\n      record\n", name);
+ 
+-  memset(&x,0,sizeof(x));
++  memset(&x, 0, sizeof(x));
+   x.id = -1;
+-  mrep_rep("Id",&x);
++  mrep_rep("Id", &x);
+ 
+-  memset(&x,0,sizeof(x));
++  memset(&x, 0, sizeof(x));
+   x.x = -1;
+-  mrep_rep("X",&x);
++  mrep_rep("X", &x);
+ 
+-  memset(&x,0,sizeof(x));
++  memset(&x, 0, sizeof(x));
+   x.y = -1;
+-  mrep_rep("Y",&x);
++  mrep_rep("Y", &x);
+ 
+-  memset(&x,0,sizeof(x));
++  memset(&x, 0, sizeof(x));
+   x.z = -1;
+-  mrep_rep("Z",&x);
++  mrep_rep("Z", &x);
+ 
+-  memset(&x,0,sizeof(x));
++  memset(&x, 0, sizeof(x));
+   x.bstate = -1;
+-  mrep_rep("Bstate",&x);
++  mrep_rep("Bstate", &x);
+ 
+   printf("      end record;\n");
+   printf("      --  Please note: this rep. clause is generated and may be\n");
+   printf("      --               different on your system.\n");
+ }
+ 
+-static void gen_attr_set( const char *name )
++static void
++gen_attr_set(const char *name)
+ {
+   /* All of the A_xxx symbols are defined in ncurses, but not all are nonzero
+    * if "configure --enable-widec" is specified.
+    */
+-  static const name_attribute_pair nap[] = {
++  static const name_attribute_pair nap[] =
++  {
+ #if A_STANDOUT
+-    {"Stand_Out",               A_STANDOUT},
++    {"Stand_Out", A_STANDOUT},
+ #endif
+ #if A_UNDERLINE
+-    {"Under_Line",              A_UNDERLINE},
++    {"Under_Line", A_UNDERLINE},
+ #endif
+ #if A_REVERSE
+-    {"Reverse_Video",           A_REVERSE},
++    {"Reverse_Video", A_REVERSE},
+ #endif
+ #if A_BLINK
+-    {"Blink",                   A_BLINK},
++    {"Blink", A_BLINK},
+ #endif
+ #if A_DIM
+-    {"Dim_Character",           A_DIM},
++    {"Dim_Character", A_DIM},
+ #endif
+ #if A_BOLD
+-    {"Bold_Character",          A_BOLD},
++    {"Bold_Character", A_BOLD},
+ #endif
+ #if A_ALTCHARSET
+     {"Alternate_Character_Set", A_ALTCHARSET},
+ #endif
+ #if A_INVIS
+-    {"Invisible_Character",     A_INVIS},
++    {"Invisible_Character", A_INVIS},
+ #endif
+ #if A_PROTECT
+-    {"Protected_Character",     A_PROTECT},
++    {"Protected_Character", A_PROTECT},
+ #endif
+ #if A_HORIZONTAL
+-    {"Horizontal",              A_HORIZONTAL},
++    {"Horizontal", A_HORIZONTAL},
+ #endif
+ #if A_LEFT
+-    {"Left",                    A_LEFT},
++    {"Left", A_LEFT},
+ #endif
+ #if A_LOW
+-    {"Low",                     A_LOW},
++    {"Low", A_LOW},
+ #endif
+ #if A_RIGHT
+-    {"Right",                   A_RIGHT},
++    {"Right", A_RIGHT},
+ #endif
+ #if A_TOP
+-    {"Top",                     A_TOP},
++    {"Top", A_TOP},
+ #endif
+ #if A_VERTICAL
+-    {"Vertical",                A_VERTICAL},
++    {"Vertical", A_VERTICAL},
+ #endif
+-    {(char *)0,                 0}
++    {(char *)0, 0}
+   };
+   chtype attr = A_ATTRIBUTES & ~A_COLOR;
+-  int start=-1, len=0, i, set;
+-  for(i=0;i<(int)(8*sizeof(chtype));i++) {
+-    set = attr&1;
+-    if (set) {
+-      if (start<0)
+-	start = i;
+-      if (start>=0) {
+-	len++;
+-      }
++  int start = -1;
++  int len = 0;
++  int i, set;
++  for (i = 0; i < (int)(8 * sizeof(chtype)); i++)
++
++    {
++      set = attr & 1;
++      if (set)
++	{
++	  if (start < 0)
++	    start = i;
++	  if (start >= 0)
++	    {
++	      len++;
++	    }
++	}
++      attr = attr >> 1;
+     }
+-    attr = attr >> 1;
+-  }
+-  gen_reps (nap, name, (len+7)/8, little_endian?start:0);
++  gen_reps(nap, name, (len + 7) / 8, little_endian ? start : 0);
+ }
+ 
+-static void gen_trace(const char *name)
+-{  
+-  static const name_attribute_pair nap[] = {
+-    {"Times",               TRACE_TIMES},
+-    {"Tputs",               TRACE_TPUTS},
+-    {"Update",              TRACE_UPDATE},
+-    {"Cursor_Move",         TRACE_MOVE},
+-    {"Character_Output",    TRACE_CHARPUT},
+-    {"Calls",               TRACE_CALLS},
+-    {"Virtual_Puts",        TRACE_VIRTPUT},
+-    {"Input_Events",        TRACE_IEVENT},
+-    {"TTY_State",           TRACE_BITS},
+-    {"Internal_Calls",      TRACE_ICALLS},
+-    {"Character_Calls",     TRACE_CCALLS},
+-    {"Termcap_TermInfo",    TRACE_DATABASE},
+-    {(char *)0,                0}
++static void
++gen_trace(const char *name)
++{
++  static const name_attribute_pair nap[] =
++  {
++    {"Times", TRACE_TIMES},
++    {"Tputs", TRACE_TPUTS},
++    {"Update", TRACE_UPDATE},
++    {"Cursor_Move", TRACE_MOVE},
++    {"Character_Output", TRACE_CHARPUT},
++    {"Calls", TRACE_CALLS},
++    {"Virtual_Puts", TRACE_VIRTPUT},
++    {"Input_Events", TRACE_IEVENT},
++    {"TTY_State", TRACE_BITS},
++    {"Internal_Calls", TRACE_ICALLS},
++    {"Character_Calls", TRACE_CCALLS},
++    {"Termcap_TermInfo", TRACE_DATABASE},
++    {(char *)0, 0}
+   };
+-  gen_reps(nap,name,sizeof(int),0);
++  gen_reps(nap, name, sizeof(int), 0);
+ }
+ 
+-static void gen_menu_opt_rep(const char *name)
++static void
++gen_menu_opt_rep(const char *name)
+ {
+-  static const name_attribute_pair nap[] = {
++  static const name_attribute_pair nap[] =
++  {
+ #ifdef O_ONEVALUE
+     {"One_Valued", O_ONEVALUE},
+ #endif
+@@ -328,90 +349,99 @@
+ #endif
+     {(char *)0, 0}
+   };
+-  gen_reps (nap, name, sizeof(int),0);
++  gen_reps(nap, name, sizeof(int), 0);
+ }
+ 
+-static void gen_item_opt_rep(const char *name)
++static void
++gen_item_opt_rep(const char *name)
+ {
+-  static const name_attribute_pair nap[] = {
++  static const name_attribute_pair nap[] =
++  {
+ #ifdef O_SELECTABLE
+     {"Selectable", O_SELECTABLE},
+ #endif
+-    {(char *)0   , 0}
++    {(char *)0, 0}
+   };
+-  gen_reps (nap, name, sizeof(int),0);
++  gen_reps(nap, name, sizeof(int), 0);
+ }
+ 
+-static void gen_form_opt_rep(const char *name)
++static void
++gen_form_opt_rep(const char *name)
+ {
+-  static const name_attribute_pair nap[] = {
++  static const name_attribute_pair nap[] =
++  {
+ #ifdef O_NL_OVERLOAD
+     {"NL_Overload", O_NL_OVERLOAD},
+ #endif
+ #ifdef O_BS_OVERLOAD
+     {"BS_Overload", O_BS_OVERLOAD},
+ #endif
+-    {(char *)0    , 0}
++    {(char *)0, 0}
+   };
+-  gen_reps (nap, name, sizeof(int),0);
++  gen_reps(nap, name, sizeof(int), 0);
+ }
+ 
+ /*
+  * Generate the representation clause for the Field_Option_Set record
+  */
+-static void gen_field_opt_rep(const char *name)
++static void
++gen_field_opt_rep(const char *name)
+ {
+-  static const name_attribute_pair nap[] = {
++  static const name_attribute_pair nap[] =
++  {
+ #ifdef O_VISIBLE
+-    {"Visible",O_VISIBLE},
++    {"Visible", O_VISIBLE},
+ #endif
+ #ifdef O_ACTIVE
+-    {"Active",O_ACTIVE},
++    {"Active", O_ACTIVE},
+ #endif
+ #ifdef O_PUBLIC
+-    {"Public",O_PUBLIC},
++    {"Public", O_PUBLIC},
+ #endif
+ #ifdef O_EDIT
+-    {"Edit",O_EDIT},
++    {"Edit", O_EDIT},
+ #endif
+ #ifdef O_WRAP
+-    {"Wrap",O_WRAP},
++    {"Wrap", O_WRAP},
+ #endif
+ #ifdef O_BLANK
+-    {"Blank",O_BLANK},
++    {"Blank", O_BLANK},
+ #endif
+ #ifdef O_AUTOSKIP
+-    {"Auto_Skip",O_AUTOSKIP},
++    {"Auto_Skip", O_AUTOSKIP},
+ #endif
+ #ifdef O_NULLOK
+-    {"Null_Ok",O_NULLOK},
++    {"Null_Ok", O_NULLOK},
+ #endif
+ #ifdef O_PASSOK
+-    {"Pass_Ok",O_PASSOK},
++    {"Pass_Ok", O_PASSOK},
+ #endif
+ #ifdef O_STATIC
+-    {"Static",O_STATIC},
++    {"Static", O_STATIC},
+ #endif
+     {(char *)0, 0}
+   };
+-  gen_reps (nap, name, sizeof(int),0);
++  gen_reps(nap, name, sizeof(int), 0);
+ }
+ 
+ /*
+  * Generate a single key code constant definition.
+  */
+-static void keydef(const char *name, const char *old_name, int value, int mode)
++static void
++keydef(const char *name, const char *old_name, int value, int mode)
+ {
+-  if (mode==0) /* Generate the new name */
+-    printf("   %-30s : constant Special_Key_Code := 8#%3o#;\n",name,value);
++  if (mode == 0)		/* Generate the new name */
++    printf("   %-30s : constant Special_Key_Code := 8#%3o#;\n", name, value);
+   else
+-    { /* generate the old name, but only if it doesn't conflict with the old
+-       * name (Ada95 isn't case sensitive!)
+-       */
+-      const char *s = old_name; const char *t = name;
+-      while ( *s && *t && (toupper(*s++) == toupper(*t++)));
++    {				/* generate the old name, but only if it doesn't conflict with the old
++				 * name (Ada95 isn't case sensitive!)
++				 */
++      const char *s = old_name;
++      const char *t = name;
++
++      while (*s && *t && (toupper(*s++) == toupper(*t++)));
+       if (*s || *t)
+-	printf("   %-16s : Special_Key_Code renames %s;\n",old_name,name);
++	printf("   %-16s : Special_Key_Code renames %s;\n", old_name, name);
+     }
+ }
+ 
+@@ -422,298 +452,299 @@
+  * generated, given that the name wasn't already defined in the "nice"
+  * list.
+  */
+-static void gen_keydefs (int mode)
++static void
++gen_keydefs(int mode)
+ {
+   char buf[16];
+   char obuf[16];
+   int i;
+ 
+ #ifdef KEY_CODE_YES
+-  keydef("Key_Code_Yes","KEY_CODE_YES",KEY_CODE_YES,mode);
++  keydef("Key_Code_Yes", "KEY_CODE_YES", KEY_CODE_YES, mode);
+ #endif
+ #ifdef KEY_MIN
+-  keydef("Key_Min","KEY_MIN",KEY_MIN,mode);
++  keydef("Key_Min", "KEY_MIN", KEY_MIN, mode);
+ #endif
+ #ifdef KEY_BREAK
+-  keydef("Key_Break","KEY_BREAK",KEY_BREAK,mode);
++  keydef("Key_Break", "KEY_BREAK", KEY_BREAK, mode);
+ #endif
+ #ifdef KEY_DOWN
+-  keydef("Key_Cursor_Down","KEY_DOWN",KEY_DOWN,mode);
++  keydef("Key_Cursor_Down", "KEY_DOWN", KEY_DOWN, mode);
+ #endif
+ #ifdef KEY_UP
+-  keydef("Key_Cursor_Up","KEY_UP",KEY_UP,mode);
++  keydef("Key_Cursor_Up", "KEY_UP", KEY_UP, mode);
+ #endif
+ #ifdef KEY_LEFT
+-  keydef("Key_Cursor_Left","KEY_LEFT",KEY_LEFT,mode);
++  keydef("Key_Cursor_Left", "KEY_LEFT", KEY_LEFT, mode);
+ #endif
+ #ifdef KEY_RIGHT
+-  keydef("Key_Cursor_Right","KEY_RIGHT",KEY_RIGHT,mode);
++  keydef("Key_Cursor_Right", "KEY_RIGHT", KEY_RIGHT, mode);
+ #endif
+ #ifdef KEY_HOME
+-  keydef("Key_Home","KEY_HOME",KEY_HOME,mode);
++  keydef("Key_Home", "KEY_HOME", KEY_HOME, mode);
+ #endif
+ #ifdef KEY_BACKSPACE
+-  keydef("Key_Backspace","KEY_BACKSPACE",KEY_BACKSPACE,mode);
++  keydef("Key_Backspace", "KEY_BACKSPACE", KEY_BACKSPACE, mode);
+ #endif
+ #ifdef KEY_F0
+-  keydef("Key_F0","KEY_F0",KEY_F0,mode);
++  keydef("Key_F0", "KEY_F0", KEY_F0, mode);
+ #endif
+ #ifdef KEY_F
+-  for(i=1;i<=24;i++)
++  for (i = 1; i <= 24; i++)
+     {
+-      sprintf(buf ,"Key_F%d",i);
+-      sprintf(obuf,"KEY_F%d",i);
+-      keydef(buf,obuf,KEY_F(i),mode);
++      sprintf(buf, "Key_F%d", i);
++      sprintf(obuf, "KEY_F%d", i);
++      keydef(buf, obuf, KEY_F(i), mode);
+     }
+ #endif
+ #ifdef KEY_DL
+-  keydef("Key_Delete_Line","KEY_DL",KEY_DL,mode);
++  keydef("Key_Delete_Line", "KEY_DL", KEY_DL, mode);
+ #endif
+ #ifdef KEY_IL
+-  keydef("Key_Insert_Line","KEY_IL",KEY_IL,mode);
++  keydef("Key_Insert_Line", "KEY_IL", KEY_IL, mode);
+ #endif
+ #ifdef KEY_DC
+-  keydef("Key_Delete_Char","KEY_DC",KEY_DC,mode);
++  keydef("Key_Delete_Char", "KEY_DC", KEY_DC, mode);
+ #endif
+ #ifdef KEY_IC
+-  keydef("Key_Insert_Char","KEY_IC",KEY_IC,mode);
++  keydef("Key_Insert_Char", "KEY_IC", KEY_IC, mode);
+ #endif
+ #ifdef KEY_EIC
+-  keydef("Key_Exit_Insert_Mode","KEY_EIC",KEY_EIC,mode);
++  keydef("Key_Exit_Insert_Mode", "KEY_EIC", KEY_EIC, mode);
+ #endif
+ #ifdef KEY_CLEAR
+-  keydef("Key_Clear_Screen","KEY_CLEAR",KEY_CLEAR,mode);
++  keydef("Key_Clear_Screen", "KEY_CLEAR", KEY_CLEAR, mode);
+ #endif
+ #ifdef KEY_EOS
+-  keydef("Key_Clear_End_Of_Screen","KEY_EOS",KEY_EOS,mode);
++  keydef("Key_Clear_End_Of_Screen", "KEY_EOS", KEY_EOS, mode);
+ #endif
+ #ifdef KEY_EOL
+-  keydef("Key_Clear_End_Of_Line","KEY_EOL",KEY_EOL,mode);
++  keydef("Key_Clear_End_Of_Line", "KEY_EOL", KEY_EOL, mode);
+ #endif
+ #ifdef KEY_SF
+-  keydef("Key_Scroll_1_Forward","KEY_SF",KEY_SF,mode);
++  keydef("Key_Scroll_1_Forward", "KEY_SF", KEY_SF, mode);
+ #endif
+ #ifdef KEY_SR
+-  keydef("Key_Scroll_1_Backward","KEY_SR",KEY_SR,mode);
++  keydef("Key_Scroll_1_Backward", "KEY_SR", KEY_SR, mode);
+ #endif
+ #ifdef KEY_NPAGE
+-  keydef("Key_Next_Page","KEY_NPAGE",KEY_NPAGE,mode);
++  keydef("Key_Next_Page", "KEY_NPAGE", KEY_NPAGE, mode);
+ #endif
+ #ifdef KEY_PPAGE
+-  keydef("Key_Previous_Page","KEY_PPAGE",KEY_PPAGE,mode);
++  keydef("Key_Previous_Page", "KEY_PPAGE", KEY_PPAGE, mode);
+ #endif
+ #ifdef KEY_STAB
+-  keydef("Key_Set_Tab","KEY_STAB",KEY_STAB,mode);
++  keydef("Key_Set_Tab", "KEY_STAB", KEY_STAB, mode);
+ #endif
+ #ifdef KEY_CTAB
+-  keydef("Key_Clear_Tab","KEY_CTAB",KEY_CTAB,mode);
++  keydef("Key_Clear_Tab", "KEY_CTAB", KEY_CTAB, mode);
+ #endif
+ #ifdef KEY_CATAB
+-  keydef("Key_Clear_All_Tabs","KEY_CATAB",KEY_CATAB,mode);
++  keydef("Key_Clear_All_Tabs", "KEY_CATAB", KEY_CATAB, mode);
+ #endif
+ #ifdef KEY_ENTER
+-  keydef("Key_Enter_Or_Send","KEY_ENTER",KEY_ENTER,mode);
++  keydef("Key_Enter_Or_Send", "KEY_ENTER", KEY_ENTER, mode);
+ #endif
+ #ifdef KEY_SRESET
+-  keydef("Key_Soft_Reset","KEY_SRESET",KEY_SRESET,mode);
++  keydef("Key_Soft_Reset", "KEY_SRESET", KEY_SRESET, mode);
+ #endif
+ #ifdef KEY_RESET
+-  keydef("Key_Reset","KEY_RESET",KEY_RESET,mode);
++  keydef("Key_Reset", "KEY_RESET", KEY_RESET, mode);
+ #endif
+ #ifdef KEY_PRINT
+-  keydef("Key_Print","KEY_PRINT",KEY_PRINT,mode);
++  keydef("Key_Print", "KEY_PRINT", KEY_PRINT, mode);
+ #endif
+ #ifdef KEY_LL
+-  keydef("Key_Bottom","KEY_LL",KEY_LL,mode);
++  keydef("Key_Bottom", "KEY_LL", KEY_LL, mode);
+ #endif
+ #ifdef KEY_A1
+-  keydef("Key_Upper_Left_Of_Keypad","KEY_A1",KEY_A1,mode);
++  keydef("Key_Upper_Left_Of_Keypad", "KEY_A1", KEY_A1, mode);
+ #endif
+ #ifdef KEY_A3
+-  keydef("Key_Upper_Right_Of_Keypad","KEY_A3",KEY_A3,mode);
++  keydef("Key_Upper_Right_Of_Keypad", "KEY_A3", KEY_A3, mode);
+ #endif
+ #ifdef KEY_B2
+-  keydef("Key_Center_Of_Keypad","KEY_B2",KEY_B2,mode);
++  keydef("Key_Center_Of_Keypad", "KEY_B2", KEY_B2, mode);
+ #endif
+ #ifdef KEY_C1
+-  keydef("Key_Lower_Left_Of_Keypad","KEY_C1",KEY_C1,mode);
++  keydef("Key_Lower_Left_Of_Keypad", "KEY_C1", KEY_C1, mode);
+ #endif
+ #ifdef KEY_C3
+-  keydef("Key_Lower_Right_Of_Keypad","KEY_C3",KEY_C3,mode);
++  keydef("Key_Lower_Right_Of_Keypad", "KEY_C3", KEY_C3, mode);
+ #endif
+ #ifdef KEY_BTAB
+-  keydef("Key_Back_Tab","KEY_BTAB",KEY_BTAB,mode);
++  keydef("Key_Back_Tab", "KEY_BTAB", KEY_BTAB, mode);
+ #endif
+ #ifdef KEY_BEG
+-  keydef("Key_Beginning","KEY_BEG",KEY_BEG,mode);
++  keydef("Key_Beginning", "KEY_BEG", KEY_BEG, mode);
+ #endif
+ #ifdef KEY_CANCEL
+-  keydef("Key_Cancel","KEY_CANCEL",KEY_CANCEL,mode);
++  keydef("Key_Cancel", "KEY_CANCEL", KEY_CANCEL, mode);
+ #endif
+ #ifdef KEY_CLOSE
+-  keydef("Key_Close","KEY_CLOSE",KEY_CLOSE,mode);
++  keydef("Key_Close", "KEY_CLOSE", KEY_CLOSE, mode);
+ #endif
+ #ifdef KEY_COMMAND
+-  keydef("Key_Command","KEY_COMMAND",KEY_COMMAND,mode);
++  keydef("Key_Command", "KEY_COMMAND", KEY_COMMAND, mode);
+ #endif
+ #ifdef KEY_COPY
+-  keydef("Key_Copy","KEY_COPY",KEY_COPY,mode);
++  keydef("Key_Copy", "KEY_COPY", KEY_COPY, mode);
+ #endif
+ #ifdef KEY_CREATE
+-  keydef("Key_Create","KEY_CREATE",KEY_CREATE,mode);
++  keydef("Key_Create", "KEY_CREATE", KEY_CREATE, mode);
+ #endif
+ #ifdef KEY_END
+-  keydef("Key_End","KEY_END",KEY_END,mode);
++  keydef("Key_End", "KEY_END", KEY_END, mode);
+ #endif
+ #ifdef KEY_EXIT
+-  keydef("Key_Exit","KEY_EXIT",KEY_EXIT,mode);
++  keydef("Key_Exit", "KEY_EXIT", KEY_EXIT, mode);
+ #endif
+ #ifdef KEY_FIND
+-  keydef("Key_Find","KEY_FIND",KEY_FIND,mode);
++  keydef("Key_Find", "KEY_FIND", KEY_FIND, mode);
+ #endif
+ #ifdef KEY_HELP
+-  keydef("Key_Help","KEY_HELP",KEY_HELP,mode);
++  keydef("Key_Help", "KEY_HELP", KEY_HELP, mode);
+ #endif
+ #ifdef KEY_MARK
+-  keydef("Key_Mark","KEY_MARK",KEY_MARK,mode);
++  keydef("Key_Mark", "KEY_MARK", KEY_MARK, mode);
+ #endif
+ #ifdef KEY_MESSAGE
+-  keydef("Key_Message","KEY_MESSAGE",KEY_MESSAGE,mode);
++  keydef("Key_Message", "KEY_MESSAGE", KEY_MESSAGE, mode);
+ #endif
+ #ifdef KEY_MOVE
+-  keydef("Key_Move","KEY_MOVE",KEY_MOVE,mode);
++  keydef("Key_Move", "KEY_MOVE", KEY_MOVE, mode);
+ #endif
+ #ifdef KEY_NEXT
+-  keydef("Key_Next","KEY_NEXT",KEY_NEXT,mode);
++  keydef("Key_Next", "KEY_NEXT", KEY_NEXT, mode);
+ #endif
+ #ifdef KEY_OPEN
+-  keydef("Key_Open","KEY_OPEN",KEY_OPEN,mode);
++  keydef("Key_Open", "KEY_OPEN", KEY_OPEN, mode);
+ #endif
+ #ifdef KEY_OPTIONS
+-  keydef("Key_Options","KEY_OPTIONS",KEY_OPTIONS,mode);
++  keydef("Key_Options", "KEY_OPTIONS", KEY_OPTIONS, mode);
+ #endif
+ #ifdef KEY_PREVIOUS
+-  keydef("Key_Previous","KEY_PREVIOUS",KEY_PREVIOUS,mode);
++  keydef("Key_Previous", "KEY_PREVIOUS", KEY_PREVIOUS, mode);
+ #endif
+ #ifdef KEY_REDO
+-  keydef("Key_Redo","KEY_REDO",KEY_REDO,mode);
++  keydef("Key_Redo", "KEY_REDO", KEY_REDO, mode);
+ #endif
+ #ifdef KEY_REFERENCE
+-  keydef("Key_Reference","KEY_REFERENCE",KEY_REFERENCE,mode);
++  keydef("Key_Reference", "KEY_REFERENCE", KEY_REFERENCE, mode);
+ #endif
+ #ifdef KEY_REFRESH
+-  keydef("Key_Refresh","KEY_REFRESH",KEY_REFRESH,mode);
++  keydef("Key_Refresh", "KEY_REFRESH", KEY_REFRESH, mode);
+ #endif
+ #ifdef KEY_REPLACE
+-  keydef("Key_Replace","KEY_REPLACE",KEY_REPLACE,mode);
++  keydef("Key_Replace", "KEY_REPLACE", KEY_REPLACE, mode);
+ #endif
+ #ifdef KEY_RESTART
+-  keydef("Key_Restart","KEY_RESTART",KEY_RESTART,mode);
++  keydef("Key_Restart", "KEY_RESTART", KEY_RESTART, mode);
+ #endif
+ #ifdef KEY_RESUME
+-  keydef("Key_Resume","KEY_RESUME",KEY_RESUME,mode);
++  keydef("Key_Resume", "KEY_RESUME", KEY_RESUME, mode);
+ #endif
+ #ifdef KEY_SAVE
+-  keydef("Key_Save","KEY_SAVE",KEY_SAVE,mode);
++  keydef("Key_Save", "KEY_SAVE", KEY_SAVE, mode);
+ #endif
+ #ifdef KEY_SBEG
+-  keydef("Key_Shift_Begin","KEY_SBEG",KEY_SBEG,mode);
++  keydef("Key_Shift_Begin", "KEY_SBEG", KEY_SBEG, mode);
+ #endif
+ #ifdef KEY_SCANCEL
+-  keydef("Key_Shift_Cancel","KEY_SCANCEL",KEY_SCANCEL,mode);
++  keydef("Key_Shift_Cancel", "KEY_SCANCEL", KEY_SCANCEL, mode);
+ #endif
+ #ifdef KEY_SCOMMAND
+-  keydef("Key_Shift_Command","KEY_SCOMMAND",KEY_SCOMMAND,mode);
++  keydef("Key_Shift_Command", "KEY_SCOMMAND", KEY_SCOMMAND, mode);
+ #endif
+ #ifdef KEY_SCOPY
+-  keydef("Key_Shift_Copy","KEY_SCOPY",KEY_SCOPY,mode);
++  keydef("Key_Shift_Copy", "KEY_SCOPY", KEY_SCOPY, mode);
+ #endif
+ #ifdef KEY_SCREATE
+-  keydef("Key_Shift_Create","KEY_SCREATE",KEY_SCREATE,mode);
++  keydef("Key_Shift_Create", "KEY_SCREATE", KEY_SCREATE, mode);
+ #endif
+ #ifdef KEY_SDC
+-  keydef("Key_Shift_Delete_Char","KEY_SDC",KEY_SDC,mode);
++  keydef("Key_Shift_Delete_Char", "KEY_SDC", KEY_SDC, mode);
+ #endif
+ #ifdef KEY_SDL
+-  keydef("Key_Shift_Delete_Line","KEY_SDL",KEY_SDL,mode);
++  keydef("Key_Shift_Delete_Line", "KEY_SDL", KEY_SDL, mode);
+ #endif
+ #ifdef KEY_SELECT
+-  keydef("Key_Select","KEY_SELECT",KEY_SELECT,mode);
++  keydef("Key_Select", "KEY_SELECT", KEY_SELECT, mode);
+ #endif
+ #ifdef KEY_SEND
+-  keydef("Key_Shift_End","KEY_SEND",KEY_SEND,mode);
++  keydef("Key_Shift_End", "KEY_SEND", KEY_SEND, mode);
+ #endif
+ #ifdef KEY_SEOL
+-  keydef("Key_Shift_Clear_End_Of_Line","KEY_SEOL",KEY_SEOL,mode);
++  keydef("Key_Shift_Clear_End_Of_Line", "KEY_SEOL", KEY_SEOL, mode);
+ #endif
+ #ifdef KEY_SEXIT
+-  keydef("Key_Shift_Exit","KEY_SEXIT",KEY_SEXIT,mode);
++  keydef("Key_Shift_Exit", "KEY_SEXIT", KEY_SEXIT, mode);
+ #endif
+ #ifdef KEY_SFIND
+-  keydef("Key_Shift_Find","KEY_SFIND",KEY_SFIND,mode);
++  keydef("Key_Shift_Find", "KEY_SFIND", KEY_SFIND, mode);
+ #endif
+ #ifdef KEY_SHELP
+-  keydef("Key_Shift_Help","KEY_SHELP",KEY_SHELP,mode);
++  keydef("Key_Shift_Help", "KEY_SHELP", KEY_SHELP, mode);
+ #endif
+ #ifdef KEY_SHOME
+-  keydef("Key_Shift_Home","KEY_SHOME",KEY_SHOME,mode);
++  keydef("Key_Shift_Home", "KEY_SHOME", KEY_SHOME, mode);
+ #endif
+ #ifdef KEY_SIC
+-  keydef("Key_Shift_Insert_Char","KEY_SIC",KEY_SIC,mode);
++  keydef("Key_Shift_Insert_Char", "KEY_SIC", KEY_SIC, mode);
+ #endif
+ #ifdef KEY_SLEFT
+-  keydef("Key_Shift_Cursor_Left","KEY_SLEFT",KEY_SLEFT,mode);
++  keydef("Key_Shift_Cursor_Left", "KEY_SLEFT", KEY_SLEFT, mode);
+ #endif
+ #ifdef KEY_SMESSAGE
+-  keydef("Key_Shift_Message","KEY_SMESSAGE",KEY_SMESSAGE,mode);
++  keydef("Key_Shift_Message", "KEY_SMESSAGE", KEY_SMESSAGE, mode);
+ #endif
+ #ifdef KEY_SMOVE
+-  keydef("Key_Shift_Move","KEY_SMOVE",KEY_SMOVE,mode);
++  keydef("Key_Shift_Move", "KEY_SMOVE", KEY_SMOVE, mode);
+ #endif
+ #ifdef KEY_SNEXT
+-  keydef("Key_Shift_Next_Page","KEY_SNEXT",KEY_SNEXT,mode);
++  keydef("Key_Shift_Next_Page", "KEY_SNEXT", KEY_SNEXT, mode);
+ #endif
+ #ifdef KEY_SOPTIONS
+-  keydef("Key_Shift_Options","KEY_SOPTIONS",KEY_SOPTIONS,mode);
++  keydef("Key_Shift_Options", "KEY_SOPTIONS", KEY_SOPTIONS, mode);
+ #endif
+ #ifdef KEY_SPREVIOUS
+-  keydef("Key_Shift_Previous_Page","KEY_SPREVIOUS",KEY_SPREVIOUS,mode);
++  keydef("Key_Shift_Previous_Page", "KEY_SPREVIOUS", KEY_SPREVIOUS, mode);
+ #endif
+ #ifdef KEY_SPRINT
+-  keydef("Key_Shift_Print","KEY_SPRINT",KEY_SPRINT,mode);
++  keydef("Key_Shift_Print", "KEY_SPRINT", KEY_SPRINT, mode);
+ #endif
+ #ifdef KEY_SREDO
+-  keydef("Key_Shift_Redo","KEY_SREDO",KEY_SREDO,mode);
++  keydef("Key_Shift_Redo", "KEY_SREDO", KEY_SREDO, mode);
+ #endif
+ #ifdef KEY_SREPLACE
+-  keydef("Key_Shift_Replace","KEY_SREPLACE",KEY_SREPLACE,mode);
++  keydef("Key_Shift_Replace", "KEY_SREPLACE", KEY_SREPLACE, mode);
+ #endif
+ #ifdef KEY_SRIGHT
+-  keydef("Key_Shift_Cursor_Right","KEY_SRIGHT",KEY_SRIGHT,mode);
++  keydef("Key_Shift_Cursor_Right", "KEY_SRIGHT", KEY_SRIGHT, mode);
+ #endif
+ #ifdef KEY_SRSUME
+-  keydef("Key_Shift_Resume","KEY_SRSUME",KEY_SRSUME,mode);
++  keydef("Key_Shift_Resume", "KEY_SRSUME", KEY_SRSUME, mode);
+ #endif
+ #ifdef KEY_SSAVE
+-  keydef("Key_Shift_Save","KEY_SSAVE",KEY_SSAVE,mode);
++  keydef("Key_Shift_Save", "KEY_SSAVE", KEY_SSAVE, mode);
+ #endif
+ #ifdef KEY_SSUSPEND
+-  keydef("Key_Shift_Suspend","KEY_SSUSPEND",KEY_SSUSPEND,mode);
++  keydef("Key_Shift_Suspend", "KEY_SSUSPEND", KEY_SSUSPEND, mode);
+ #endif
+ #ifdef KEY_SUNDO
+-  keydef("Key_Shift_Undo","KEY_SUNDO",KEY_SUNDO,mode);
++  keydef("Key_Shift_Undo", "KEY_SUNDO", KEY_SUNDO, mode);
+ #endif
+ #ifdef KEY_SUSPEND
+-  keydef("Key_Suspend","KEY_SUSPEND",KEY_SUSPEND,mode);
++  keydef("Key_Suspend", "KEY_SUSPEND", KEY_SUSPEND, mode);
+ #endif
+ #ifdef KEY_UNDO
+-  keydef("Key_Undo","KEY_UNDO",KEY_UNDO,mode);
++  keydef("Key_Undo", "KEY_UNDO", KEY_UNDO, mode);
+ #endif
+ #ifdef KEY_MOUSE
+-  keydef("Key_Mouse","KEY_MOUSE",KEY_MOUSE,mode);
++  keydef("Key_Mouse", "KEY_MOUSE", KEY_MOUSE, mode);
+ #endif
+ #ifdef KEY_RESIZE
+-  keydef("Key_Resize","KEY_RESIZE",KEY_RESIZE,mode);
++  keydef("Key_Resize", "KEY_RESIZE", KEY_RESIZE, mode);
+ #endif
+ }
+ 
+@@ -722,120 +753,122 @@
+  * is a reference to the ACS character in the acs_map[] array and
+  * will be translated into an index.
+  */
+-static void acs_def (const char *name, chtype *a)
++static void
++acs_def(const char *name, chtype *a)
+ {
+   int c = a - &acs_map[0];
+-  printf("   %-24s : constant Character := ",name);
+-  if (isprint(c) && (c!='`'))
+-    printf("'%c';\n",c);
++
++  printf("   %-24s : constant Character := ", name);
++  if (isprint(c) && (c != '`'))
++    printf("'%c';\n", c);
+   else
+-    printf("Character'Val (%d);\n",c);
++    printf("Character'Val (%d);\n", c);
+ }
+ 
+ /*
+  * Generate the constants for the ACS characters
+  */
+-static void gen_acs (void)
++static void
++gen_acs(void)
+ {
+ #ifdef ACS_ULCORNER
+-  acs_def("ACS_Upper_Left_Corner",&ACS_ULCORNER);
++  acs_def("ACS_Upper_Left_Corner", &ACS_ULCORNER);
+ #endif
+ #ifdef ACS_LLCORNER
+-  acs_def("ACS_Lower_Left_Corner",&ACS_LLCORNER);
++  acs_def("ACS_Lower_Left_Corner", &ACS_LLCORNER);
+ #endif
+ #ifdef ACS_URCORNER
+-  acs_def("ACS_Upper_Right_Corner",&ACS_URCORNER);
++  acs_def("ACS_Upper_Right_Corner", &ACS_URCORNER);
+ #endif
+ #ifdef ACS_LRCORNER
+-  acs_def("ACS_Lower_Right_Corner",&ACS_LRCORNER);
++  acs_def("ACS_Lower_Right_Corner", &ACS_LRCORNER);
+ #endif
+ #ifdef ACS_LTEE
+-  acs_def("ACS_Left_Tee",&ACS_LTEE);
++  acs_def("ACS_Left_Tee", &ACS_LTEE);
+ #endif
+ #ifdef ACS_RTEE
+-  acs_def("ACS_Right_Tee",&ACS_RTEE);
++  acs_def("ACS_Right_Tee", &ACS_RTEE);
+ #endif
+ #ifdef ACS_BTEE
+-  acs_def("ACS_Bottom_Tee",&ACS_BTEE);
++  acs_def("ACS_Bottom_Tee", &ACS_BTEE);
+ #endif
+ #ifdef ACS_TTEE
+-  acs_def("ACS_Top_Tee",&ACS_TTEE);
++  acs_def("ACS_Top_Tee", &ACS_TTEE);
+ #endif
+ #ifdef ACS_HLINE
+-  acs_def("ACS_Horizontal_Line",&ACS_HLINE);
++  acs_def("ACS_Horizontal_Line", &ACS_HLINE);
+ #endif
+ #ifdef ACS_VLINE
+-  acs_def("ACS_Vertical_Line",&ACS_VLINE);
++  acs_def("ACS_Vertical_Line", &ACS_VLINE);
+ #endif
+ #ifdef ACS_PLUS
+-  acs_def("ACS_Plus_Symbol",&ACS_PLUS);
++  acs_def("ACS_Plus_Symbol", &ACS_PLUS);
+ #endif
+ #ifdef ACS_S1
+-  acs_def("ACS_Scan_Line_1",&ACS_S1);
++  acs_def("ACS_Scan_Line_1", &ACS_S1);
+ #endif
+ #ifdef ACS_S9
+-  acs_def("ACS_Scan_Line_9",&ACS_S9);
++  acs_def("ACS_Scan_Line_9", &ACS_S9);
+ #endif
+ #ifdef ACS_DIAMOND
+-  acs_def("ACS_Diamond",&ACS_DIAMOND);
++  acs_def("ACS_Diamond", &ACS_DIAMOND);
+ #endif
+ #ifdef ACS_CKBOARD
+-  acs_def("ACS_Checker_Board",&ACS_CKBOARD);
++  acs_def("ACS_Checker_Board", &ACS_CKBOARD);
+ #endif
+ #ifdef ACS_DEGREE
+-  acs_def("ACS_Degree",&ACS_DEGREE);
++  acs_def("ACS_Degree", &ACS_DEGREE);
+ #endif
+ #ifdef ACS_PLMINUS
+-  acs_def("ACS_Plus_Minus",&ACS_PLMINUS);
++  acs_def("ACS_Plus_Minus", &ACS_PLMINUS);
+ #endif
+ #ifdef ACS_BULLET
+-  acs_def("ACS_Bullet",&ACS_BULLET);
++  acs_def("ACS_Bullet", &ACS_BULLET);
+ #endif
+ #ifdef ACS_LARROW
+-  acs_def("ACS_Left_Arrow",&ACS_LARROW);
++  acs_def("ACS_Left_Arrow", &ACS_LARROW);
+ #endif
+ #ifdef ACS_RARROW
+-  acs_def("ACS_Right_Arrow",&ACS_RARROW);
++  acs_def("ACS_Right_Arrow", &ACS_RARROW);
+ #endif
+ #ifdef ACS_DARROW
+-  acs_def("ACS_Down_Arrow",&ACS_DARROW);
++  acs_def("ACS_Down_Arrow", &ACS_DARROW);
+ #endif
+ #ifdef ACS_UARROW
+-  acs_def("ACS_Up_Arrow",&ACS_UARROW);
++  acs_def("ACS_Up_Arrow", &ACS_UARROW);
+ #endif
+ #ifdef ACS_BOARD
+-  acs_def("ACS_Board_Of_Squares",&ACS_BOARD);
++  acs_def("ACS_Board_Of_Squares", &ACS_BOARD);
+ #endif
+ #ifdef ACS_LANTERN
+-  acs_def("ACS_Lantern",&ACS_LANTERN);
++  acs_def("ACS_Lantern", &ACS_LANTERN);
+ #endif
+ #ifdef ACS_BLOCK
+-  acs_def("ACS_Solid_Block",&ACS_BLOCK);
++  acs_def("ACS_Solid_Block", &ACS_BLOCK);
+ #endif
+ #ifdef ACS_S3
+-  acs_def("ACS_Scan_Line_3",&ACS_S3);
++  acs_def("ACS_Scan_Line_3", &ACS_S3);
+ #endif
+ #ifdef ACS_S7
+-  acs_def("ACS_Scan_Line_7",&ACS_S7);
++  acs_def("ACS_Scan_Line_7", &ACS_S7);
+ #endif
+ #ifdef ACS_LEQUAL
+-  acs_def("ACS_Less_Or_Equal",&ACS_LEQUAL);
++  acs_def("ACS_Less_Or_Equal", &ACS_LEQUAL);
+ #endif
+ #ifdef ACS_GEQUAL
+-  acs_def("ACS_Greater_Or_Equal",&ACS_GEQUAL);
++  acs_def("ACS_Greater_Or_Equal", &ACS_GEQUAL);
+ #endif
+ #ifdef ACS_PI
+-  acs_def("ACS_PI",&ACS_PI);
++  acs_def("ACS_PI", &ACS_PI);
+ #endif
+ #ifdef ACS_NEQUAL
+-  acs_def("ACS_Not_Equal",&ACS_NEQUAL);
++  acs_def("ACS_Not_Equal", &ACS_NEQUAL);
+ #endif
+ #ifdef ACS_STERLING
+-  acs_def("ACS_Sterling",&ACS_STERLING);
++  acs_def("ACS_Sterling", &ACS_STERLING);
+ #endif
+ }
+ 
+-
+ #define GEN_EVENT(name,value) \
+    printf("   %-25s : constant Event_Mask := 8#%011lo#;\n", \
+           #name, value)
+@@ -845,7 +878,8 @@
+           #name, name)
+ 
+ static
+-void gen_mouse_events(void)
++void
++gen_mouse_events(void)
+ {
+   mmask_t all1 = 0;
+   mmask_t all2 = 0;
+@@ -959,15 +993,15 @@
+ #endif
+ #ifdef REPORT_MOUSE_POSITION
+   GEN_MEVENT(REPORT_MOUSE_POSITION);
+-#endif   
++#endif
+ #ifdef ALL_MOUSE_EVENTS
+   GEN_MEVENT(ALL_MOUSE_EVENTS);
+ #endif
+ 
+-GEN_EVENT(BUTTON1_EVENTS,all1);
+-GEN_EVENT(BUTTON2_EVENTS,all2);
+-GEN_EVENT(BUTTON3_EVENTS,all3);
+-GEN_EVENT(BUTTON4_EVENTS,all4);
++  GEN_EVENT(BUTTON1_EVENTS, all1);
++  GEN_EVENT(BUTTON2_EVENTS, all2);
++  GEN_EVENT(BUTTON3_EVENTS, all3);
++  GEN_EVENT(BUTTON4_EVENTS, all4);
+ }
+ 
+ /*
+@@ -975,41 +1009,45 @@
+  * The name parameter is the name of the facility to be used in
+  * the comment.
+  */
+-static void prologue(const char *name)
++static void
++prologue(const char *name)
+ {
+-  printf("--  %s binding.\n",name);
++  printf("--  %s binding.\n", name);
+   printf("--  This module is generated. Please don't change it manually!\n");
+   printf("--  Run the generator instead.\n--  |");
+ 
+   printf("define(`M4_BIT_ORDER',`%s_Order_First')",
+-	 little_endian ? "Low":"High");
++	 little_endian ? "Low" : "High");
+ }
+ 
+ /*
+  * Write the prologue for the curses facility and make sure that
+  * KEY_MIN and KEY_MAX are defined for the rest of this source.
+  */
+-static void basedefs (void)
++static void
++basedefs(void)
+ {
+   prologue("curses");
+ #ifndef KEY_MAX
+ #  define KEY_MAX 0777
+ #endif
+-  printf("define(`M4_KEY_MAX',`8#%o#')",KEY_MAX);
++  printf("define(`M4_KEY_MAX',`8#%o#')", KEY_MAX);
+ #ifndef KEY_MIN
+ #  define KEY_MIN 0401
+ #endif
+-  if (KEY_MIN == 256) {
+-    fprintf(stderr,"Unexpected value for KEY_MIN: %d\n",KEY_MIN);
+-    exit(1);
+-  }
+-  printf("define(`M4_SPECIAL_FIRST',`8#%o#')",KEY_MIN - 1);
++  if (KEY_MIN == 256)
++    {
++      fprintf(stderr, "Unexpected value for KEY_MIN: %d\n", KEY_MIN);
++      exit(1);
++    }
++  printf("define(`M4_SPECIAL_FIRST',`8#%o#')", KEY_MIN - 1);
+ }
+ 
+ /*
+  * Write out the comment lines for the menu facility
+  */
+-static void menu_basedefs (void)
++static void
++menu_basedefs(void)
+ {
+   prologue("menu");
+ }
+@@ -1017,7 +1055,8 @@
+ /*
+  * Write out the comment lines for the form facility
+  */
+-static void form_basedefs (void)
++static void
++form_basedefs(void)
+ {
+   prologue("form");
+ }
+@@ -1025,7 +1064,8 @@
+ /*
+  * Write out the comment lines for the mouse facility
+  */
+-static void mouse_basedefs(void)
++static void
++mouse_basedefs(void)
+ {
+   prologue("mouse");
+ }
+@@ -1033,9 +1073,10 @@
+ /*
+  * Write the definition of a single color
+  */
+-static void color_def (const char *name, int value)
++static void
++color_def(const char *name, int value)
+ {
+-  printf("   %-16s : constant Color_Number := %d;\n",name,value);
++  printf("   %-16s : constant Color_Number := %d;\n", name, value);
+ }
+ 
+ #define HAVE_USE_DEFAULT_COLORS 1
+@@ -1043,87 +1084,93 @@
+ /*
+  * Generate all color definitions
+  */
+-static void gen_color (void)
++static void
++gen_color(void)
+ {
+ #ifdef HAVE_USE_DEFAULT_COLORS
+-  color_def ("Default_Color",-1);
++  color_def("Default_Color", -1);
+ #endif
+ #ifdef COLOR_BLACK
+-  color_def ("Black",COLOR_BLACK);
++  color_def("Black", COLOR_BLACK);
+ #endif
+ #ifdef COLOR_RED
+-  color_def ("Red",COLOR_RED);
++  color_def("Red", COLOR_RED);
+ #endif
+ #ifdef COLOR_GREEN
+-  color_def ("Green",COLOR_GREEN);
++  color_def("Green", COLOR_GREEN);
+ #endif
+ #ifdef COLOR_YELLOW
+-  color_def ("Yellow",COLOR_YELLOW);
++  color_def("Yellow", COLOR_YELLOW);
+ #endif
+ #ifdef COLOR_BLUE
+-  color_def ("Blue",COLOR_BLUE);
++  color_def("Blue", COLOR_BLUE);
+ #endif
+ #ifdef COLOR_MAGENTA
+-  color_def ("Magenta",COLOR_MAGENTA);
++  color_def("Magenta", COLOR_MAGENTA);
+ #endif
+ #ifdef COLOR_CYAN
+-  color_def ("Cyan",COLOR_CYAN);
++  color_def("Cyan", COLOR_CYAN);
+ #endif
+ #ifdef COLOR_WHITE
+-  color_def ("White",COLOR_WHITE);
++  color_def("White", COLOR_WHITE);
+ #endif
+ }
+ 
+ /*
+  * Generate the linker options for the base facility
+  */
+-static void gen_linkopts (void)
++static void
++gen_linkopts(void)
+ {
+-   printf("   pragma Linker_Options (\"-lncurses%s\");\n", model);
++  printf("   pragma Linker_Options (\"-lncurses%s\");\n", model);
+ }
+ 
+ /*
+  * Generate the linker options for the menu facility
+  */
+-static void gen_menu_linkopts (void)
++static void
++gen_menu_linkopts(void)
+ {
+-   printf("   pragma Linker_Options (\"-lmenu%s\");\n", model);
++  printf("   pragma Linker_Options (\"-lmenu%s\");\n", model);
+ }
+ 
+ /*
+  * Generate the linker options for the form facility
+  */
+-static void gen_form_linkopts (void)
++static void
++gen_form_linkopts(void)
+ {
+-   printf("   pragma Linker_Options (\"-lform%s\");\n", model);
++  printf("   pragma Linker_Options (\"-lform%s\");\n", model);
+ }
+ 
+ /*
+  * Generate the linker options for the panel facility
+  */
+-static void gen_panel_linkopts (void)
++static void
++gen_panel_linkopts(void)
+ {
+-   printf("   pragma Linker_Options (\"-lpanel%s\");\n", model);
++  printf("   pragma Linker_Options (\"-lpanel%s\");\n", model);
+ }
+ 
+-static void gen_version_info (void)
++static void
++gen_version_info(void)
+ {
+-  static const char* v1 =
+-    "   NC_Major_Version : constant := %d; --  Major version of the library\n";
+-  static const char* v2 =
+-    "   NC_Minor_Version : constant := %d; --  Minor version of the library\n";
+-  static const char* v3 =
+-    "   NC_Version : constant String := %c%d.%d%c;  --  Version of library\n";
++  static const char *v1 =
++  "   NC_Major_Version : constant := %d; --  Major version of the library\n";
++  static const char *v2 =
++  "   NC_Minor_Version : constant := %d; --  Minor version of the library\n";
++  static const char *v3 =
++  "   NC_Version : constant String := %c%d.%d%c;  --  Version of library\n";
+ 
+   printf(v1, NCURSES_VERSION_MAJOR);
+   printf(v2, NCURSES_VERSION_MINOR);
+-  printf(v3, '"',NCURSES_VERSION_MAJOR,NCURSES_VERSION_MINOR,'"');
++  printf(v3, '"', NCURSES_VERSION_MAJOR, NCURSES_VERSION_MINOR, '"');
+ }
+ 
+ static int
+-eti_gen(char*buf, int code, const char* name, int* etimin, int* etimax)
++eti_gen(char *buf, int code, const char *name, int *etimin, int *etimax)
+ {
+-  sprintf(buf,"   E_%-16s : constant Eti_Error := %d;\n",name,code);
++  sprintf(buf, "   E_%-16s : constant Eti_Error := %d;\n", name, code);
+   if (code < *etimin)
+     *etimin = code;
+   if (code > *etimax)
+@@ -1136,68 +1183,77 @@
+     o = offsetof(WINDOW, member);                                   \
+     if ((o%sizeof(itype) == 0)) {                                   \
+        printf("   Offset%-*s : constant Natural := %2ld; --  %s\n", \
+-              12, #member, o/sizeof(itype),#itype);                 \
++              12, #member, (long)(o/sizeof(itype)),#itype);         \
+     }                                                               \
+   }
+-  
++
+ static void
+ gen_offsets(void)
+ {
+   long o;
+-  const char* s_bool = "";
++  const char *s_bool = "";
+ 
+-  GEN_OFFSET(_maxy,short);
+-  GEN_OFFSET(_maxx,short);
+-  GEN_OFFSET(_begy,short);
+-  GEN_OFFSET(_begx,short);
+-  GEN_OFFSET(_cury,short);
+-  GEN_OFFSET(_curx,short);
+-  GEN_OFFSET(_yoffset,short);
+-  GEN_OFFSET(_pary,int);
+-  GEN_OFFSET(_parx,int);
+-  if (sizeof(bool) == sizeof(char)) {
+-    GEN_OFFSET(_notimeout,char);
+-    GEN_OFFSET(_clear,char);
+-    GEN_OFFSET(_leaveok,char);
+-    GEN_OFFSET(_scroll,char);
+-    GEN_OFFSET(_idlok,char);
+-    GEN_OFFSET(_idcok,char);
+-    GEN_OFFSET(_immed,char);
+-    GEN_OFFSET(_sync,char);
+-    GEN_OFFSET(_use_keypad,char);
+-    s_bool = "char";
+-  } else if (sizeof(bool) == sizeof(short)) {
+-    GEN_OFFSET(_notimeout,short);
+-    GEN_OFFSET(_clear,short);
+-    GEN_OFFSET(_leaveok,short);
+-    GEN_OFFSET(_scroll,short);
+-    GEN_OFFSET(_idlok,short);
+-    GEN_OFFSET(_idcok,short);
+-    GEN_OFFSET(_immed,short);
+-    GEN_OFFSET(_sync,short);
+-    GEN_OFFSET(_use_keypad,short);
+-    s_bool = "short";
+-  } else if (sizeof(bool) == sizeof(int)) {
+-    GEN_OFFSET(_notimeout,int);
+-    GEN_OFFSET(_clear,int);
+-    GEN_OFFSET(_leaveok,int);
+-    GEN_OFFSET(_scroll,int);
+-    GEN_OFFSET(_idlok,int);
+-    GEN_OFFSET(_idcok,int);
+-    GEN_OFFSET(_immed,int);
+-    GEN_OFFSET(_sync,int);
+-    GEN_OFFSET(_use_keypad,int);
+-    s_bool = "int";
+-  }
++  GEN_OFFSET(_maxy, short);
++  GEN_OFFSET(_maxx, short);
++  GEN_OFFSET(_begy, short);
++  GEN_OFFSET(_begx, short);
++  GEN_OFFSET(_cury, short);
++  GEN_OFFSET(_curx, short);
++  GEN_OFFSET(_yoffset, short);
++  GEN_OFFSET(_pary, int);
++  GEN_OFFSET(_parx, int);
++  if (sizeof(bool) == sizeof(char))
++    {
++      GEN_OFFSET(_notimeout, char);
++      GEN_OFFSET(_clear, char);
++      GEN_OFFSET(_leaveok, char);
++      GEN_OFFSET(_scroll, char);
++      GEN_OFFSET(_idlok, char);
++      GEN_OFFSET(_idcok, char);
++      GEN_OFFSET(_immed, char);
++      GEN_OFFSET(_sync, char);
++      GEN_OFFSET(_use_keypad, char);
++
++      s_bool = "char";
++    }
++  else if (sizeof(bool) == sizeof(short))
++    {
++      GEN_OFFSET(_notimeout, short);
++      GEN_OFFSET(_clear, short);
++      GEN_OFFSET(_leaveok, short);
++      GEN_OFFSET(_scroll, short);
++      GEN_OFFSET(_idlok, short);
++      GEN_OFFSET(_idcok, short);
++      GEN_OFFSET(_immed, short);
++      GEN_OFFSET(_sync, short);
++      GEN_OFFSET(_use_keypad, short);
++
++      s_bool = "short";
++    }
++  else if (sizeof(bool) == sizeof(int))
++    {
++      GEN_OFFSET(_notimeout, int);
++      GEN_OFFSET(_clear, int);
++      GEN_OFFSET(_leaveok, int);
++      GEN_OFFSET(_scroll, int);
++      GEN_OFFSET(_idlok, int);
++      GEN_OFFSET(_idcok, int);
++      GEN_OFFSET(_immed, int);
++      GEN_OFFSET(_sync, int);
++      GEN_OFFSET(_use_keypad, int);
++
++      s_bool = "int";
++    }
+   printf("   Sizeof%-*s : constant Natural := %2ld; --  %s\n",
+-	 12, "_bool", (long) sizeof(bool),"bool");
++	 12, "_bool", (long)sizeof(bool), "bool");
++
+   /* In ncurses _maxy and _maxx needs an offset for the "public"
+    * value
+    */
+   printf("   Offset%-*s : constant Natural := %2d; --  %s\n",
+-	 12, "_XY",1,"int");
++	 12, "_XY", 1, "int");
+   printf("\n");
+-  printf("   type Curses_Bool is mod 2 ** Interfaces.C.%s'Size;\n",s_bool);
++  printf("   type Curses_Bool is mod 2 ** Interfaces.C.%s'Size;\n", s_bool);
+ }
+ 
+ /*
+@@ -1213,7 +1269,8 @@
+  * The second character then denotes the specific output that should be
+  * generated for the selected facility.
+  */
+-int main(int argc, char *argv[])
++int
++main(int argc, char *argv[])
+ {
+   int x = 0x12345678;
+   char *s = (char *)&x;
+@@ -1221,216 +1278,226 @@
+   if (*s == 0x78)
+     little_endian = 1;
+ 
+-  if (argc!=4)
++  if (argc != 4)
+     exit(1);
+   model = *++argv;
+ 
+-  switch(argv[1][0])
++  switch (argv[1][0])
+     {
+-      /* ---------------------------------------------------------------*/   
+-    case 'B': /* The Base facility */
+-      switch(argv[2][0])
++      /* --------------------------------------------------------------- */
++    case 'B':			/* The Base facility */
++      switch (argv[2][0])
+ 	{
+-	case 'A': /* chtype translation into Ada95 record type */
++	case 'A':		/* chtype translation into Ada95 record type */
+ 	  gen_attr_set("Character_Attribute_Set");
+ 	  break;
+-	case 'K': /* translation of keycodes */
++	case 'K':		/* translation of keycodes */
+ 	  gen_keydefs(0);
+ 	  break;
+-	case 'B': /* write some initial comment lines */
++	case 'B':		/* write some initial comment lines */
+ 	  basedefs();
+ 	  break;
+-	case 'C': /* generate color constants */
++	case 'C':		/* generate color constants */
+ 	  gen_color();
+ 	  break;
+-	case 'D': /* generate displacements of fields in WINDOW struct. */
++	case 'D':		/* generate displacements of fields in WINDOW struct. */
+ 	  gen_offsets();
+ 	  break;
+-	case 'E': /* generate Mouse Event codes */
++	case 'E':		/* generate Mouse Event codes */
+ 	  gen_mouse_events();
+ 	  break;
+-	case 'M': /* generate constants for the ACS characters */
++	case 'M':		/* generate constants for the ACS characters */
+ 	  gen_acs();
+ 	  break;
+-	case 'L': /* generate the Linker_Options pragma */
++	case 'L':		/* generate the Linker_Options pragma */
+ 	  gen_linkopts();
+ 	  break;
+-	case 'O': /* generate definitions of the old key code names */
++	case 'O':		/* generate definitions of the old key code names */
+ 	  gen_keydefs(1);
+ 	  break;
+-	case 'R': /* generate representation clause for Attributed character */
++	case 'R':		/* generate representation clause for Attributed character */
+ 	  gen_chtype_rep("Attributed_Character");
+ 	  break;
+-	case 'V': /* generate version info */
++	case 'V':		/* generate version info */
+ 	  gen_version_info();
+ 	  break;
+-	case 'T': /* generate the Trace info */
++	case 'T':		/* generate the Trace info */
+ 	  gen_trace("Trace_Attribute_Set");
+ 	  break;
+ 	default:
+ 	  break;
+ 	}
+       break;
+-      /* ---------------------------------------------------------------*/   
+-    case 'M': /* The Menu facility */
+-      switch(argv[2][0])
++      /* --------------------------------------------------------------- */
++    case 'M':			/* The Menu facility */
++      switch (argv[2][0])
+ 	{
+-	case 'R': /* generate representation clause for Menu_Option_Set */
++	case 'R':		/* generate representation clause for Menu_Option_Set */
+ 	  gen_menu_opt_rep("Menu_Option_Set");
+ 	  break;
+-	case 'B': /* write some initial comment lines */
++	case 'B':		/* write some initial comment lines */
+ 	  menu_basedefs();
+ 	  break;
+-	case 'L': /* generate the Linker_Options pragma */
++	case 'L':		/* generate the Linker_Options pragma */
+ 	  gen_menu_linkopts();
+ 	  break;
+-	case 'I': /* generate representation clause for Item_Option_Set */
++	case 'I':		/* generate representation clause for Item_Option_Set */
+ 	  gen_item_opt_rep("Item_Option_Set");
+ 	  break;
+ 	default:
+ 	  break;
+ 	}
+       break;
+-      /* ---------------------------------------------------------------*/   
+-    case 'F': /* The Form facility */
+-      switch(argv[2][0])
++      /* --------------------------------------------------------------- */
++    case 'F':			/* The Form facility */
++      switch (argv[2][0])
+ 	{
+-	case 'R': /* generate representation clause for Form_Option_Set */
++	case 'R':		/* generate representation clause for Form_Option_Set */
+ 	  gen_form_opt_rep("Form_Option_Set");
+ 	  break;
+-	case 'B': /* write some initial comment lines */
++	case 'B':		/* write some initial comment lines */
+ 	  form_basedefs();
+ 	  break;
+-	case 'L': /* generate the Linker_Options pragma */
++	case 'L':		/* generate the Linker_Options pragma */
+ 	  gen_form_linkopts();
+ 	  break;
+-	case 'I': /* generate representation clause for Field_Option_Set */
++	case 'I':		/* generate representation clause for Field_Option_Set */
+ 	  gen_field_opt_rep("Field_Option_Set");
+ 	  break;
+ 	default:
+ 	  break;
+ 	}
+       break;
+-      /* ---------------------------------------------------------------*/   
+-    case 'P': /* The Pointer(=Mouse) facility */
+-      switch(argv[2][0]) {
+-	case 'B': /* write some initial comment lines */
++      /* --------------------------------------------------------------- */
++    case 'P':			/* The Pointer(=Mouse) facility */
++      switch (argv[2][0])
++	{
++	case 'B':		/* write some initial comment lines */
+ 	  mouse_basedefs();
+ 	  break;
+-	case 'M': /* generate representation clause for Mouse_Event */
++	case 'M':		/* generate representation clause for Mouse_Event */
+ 	  gen_mrep_rep("Mouse_Event");
+ 	  break;
+-	case 'L': /* generate the Linker_Options pragma */
++	case 'L':		/* generate the Linker_Options pragma */
+ 	  gen_panel_linkopts();
+ 	  break;
+ 	default:
+ 	  break;
+ 	}
+-	break;
+-      /* ---------------------------------------------------------------*/   
+-    case 'E' : /* chtype size detection */
+-      switch(argv[2][0]) {
+-      case 'C':
++      break;
++      /* --------------------------------------------------------------- */
++    case 'E':			/* chtype size detection */
++      switch (argv[2][0])
+ 	{
+-	  const char* fmt  = "   type    C_Chtype   is new %s;\n";
+-	  const char* afmt = "   type    C_AttrType is new %s;\n";
+-
+-	  if (sizeof(chtype)==sizeof(int)) {
+-	    if (sizeof(int)==sizeof(long))
+-	      printf(fmt,"C_ULong");
++	case 'C':
++	  {
++	    const char *fmt = "   type    C_Chtype   is new %s;\n";
++	    const char *afmt = "   type    C_AttrType is new %s;\n";
++
++	    if (sizeof(chtype) == sizeof(int))
++	      {
++		if (sizeof(int) == sizeof(long))
++		    printf(fmt, "C_ULong");
++
++		else
++		  printf(fmt, "C_UInt");
++	      }
++	    else if (sizeof(chtype) == sizeof(long))
++	      {
++		printf(fmt, "C_ULong");
++	      }
+ 	    else
+-	      printf(fmt,"C_UInt");
+-	  }
+-	  else if (sizeof(chtype)==sizeof(long)) {
+-	    printf(fmt,"C_ULong");
+-	  }
+-	  else
+-	    printf("Error\n");
++	      printf("Error\n");
+ 
+-	  if (sizeof(attr_t)==sizeof(int)) {
+-	    if (sizeof(int)==sizeof(long))
+-	      printf(afmt,"C_ULong");
++	    if (sizeof(attr_t) == sizeof(int))
++	      {
++		if (sizeof(int) == sizeof(long))
++		    printf(afmt, "C_ULong");
++
++		else
++		  printf(afmt, "C_UInt");
++	      }
++	    else if (sizeof(attr_t) == sizeof(long))
++	      {
++		printf(afmt, "C_ULong");
++	      }
+ 	    else
+-	      printf(afmt,"C_UInt");
+-	  }
+-	  else if (sizeof(attr_t)==sizeof(long)) {
+-	    printf(afmt,"C_ULong");
+-	  }
+-	  else
+-	    printf("Error\n");
++	      printf("Error\n");
+ 
+-	  printf("define(`CF_CURSES_OK',`%d')",OK);
+-	  printf("define(`CF_CURSES_ERR',`%d')",ERR);
+-	  printf("define(`CF_CURSES_TRUE',`%d')",TRUE);
+-	  printf("define(`CF_CURSES_FALSE',`%d')",FALSE);
+-	}
+-	break;
+-      case 'E':
+-	{
+-	  char* buf  = (char*)malloc(2048);
+-	  char* p    = buf;
+-	  int etimin = E_OK;
+-	  int etimax = E_OK;
+-	  if (p) {
+-	    p += eti_gen(p, E_OK, "Ok", &etimin, &etimax);
+-	    p += eti_gen(p, E_SYSTEM_ERROR,"System_Error", &etimin, &etimax);
+-	    p += eti_gen(p, E_BAD_ARGUMENT, "Bad_Argument", &etimin, &etimax);
+-	    p += eti_gen(p, E_POSTED, "Posted", &etimin, &etimax);
+-	    p += eti_gen(p, E_CONNECTED, "Connected", &etimin, &etimax);
+-	    p += eti_gen(p, E_BAD_STATE, "Bad_State", &etimin, &etimax);
+-	    p += eti_gen(p, E_NO_ROOM, "No_Room", &etimin, &etimax);
+-	    p += eti_gen(p, E_NOT_POSTED, "Not_Posted", &etimin, &etimax);
+-	    p += eti_gen(p, E_UNKNOWN_COMMAND,
+-			 "Unknown_Command", &etimin, &etimax);
+-	    p += eti_gen(p, E_NO_MATCH, "No_Match", &etimin, &etimax);
+-	    p += eti_gen(p, E_NOT_SELECTABLE,
+-			 "Not_Selectable", &etimin, &etimax);
+-	    p += eti_gen(p, E_NOT_CONNECTED,
+-			 "Not_Connected", &etimin, &etimax);
+-	    p += eti_gen(p, E_REQUEST_DENIED,
+-			 "Request_Denied", &etimin, &etimax);
+-	    p += eti_gen(p, E_INVALID_FIELD,
+-			 "Invalid_Field", &etimin, &etimax);
+-	    p += eti_gen(p, E_CURRENT,
+-			 "Current", &etimin, &etimax);
++	    printf("define(`CF_CURSES_OK',`%d')", OK);
++	    printf("define(`CF_CURSES_ERR',`%d')", ERR);
++	    printf("define(`CF_CURSES_TRUE',`%d')", TRUE);
++	    printf("define(`CF_CURSES_FALSE',`%d')", FALSE);
++	  }
++	  break;
++	case 'E':
++	  {
++	    char *buf = (char *)malloc(2048);
++	    char *p = buf;
++	    int etimin = E_OK;
++	    int etimax = E_OK;
++
++	    if (p)
++	      {
++		p += eti_gen(p, E_OK, "Ok", &etimin, &etimax);
++		p += eti_gen(p, E_SYSTEM_ERROR, "System_Error", &etimin, &etimax);
++		p += eti_gen(p, E_BAD_ARGUMENT, "Bad_Argument", &etimin, &etimax);
++		p += eti_gen(p, E_POSTED, "Posted", &etimin, &etimax);
++		p += eti_gen(p, E_CONNECTED, "Connected", &etimin, &etimax);
++		p += eti_gen(p, E_BAD_STATE, "Bad_State", &etimin, &etimax);
++		p += eti_gen(p, E_NO_ROOM, "No_Room", &etimin, &etimax);
++		p += eti_gen(p, E_NOT_POSTED, "Not_Posted", &etimin, &etimax);
++		p += eti_gen(p, E_UNKNOWN_COMMAND,
++			     "Unknown_Command", &etimin, &etimax);
++		p += eti_gen(p, E_NO_MATCH, "No_Match", &etimin, &etimax);
++		p += eti_gen(p, E_NOT_SELECTABLE,
++			     "Not_Selectable", &etimin, &etimax);
++		p += eti_gen(p, E_NOT_CONNECTED,
++			     "Not_Connected", &etimin, &etimax);
++		p += eti_gen(p, E_REQUEST_DENIED,
++			     "Request_Denied", &etimin, &etimax);
++		p += eti_gen(p, E_INVALID_FIELD,
++			     "Invalid_Field", &etimin, &etimax);
++		p += eti_gen(p, E_CURRENT,
++			     "Current", &etimin, &etimax);
++	      }
++	    printf("   subtype Eti_Error is C_Int range %d .. %d;\n\n",
++		   etimin, etimax);
++	    printf(buf);
+ 	  }
+-	  printf("   subtype Eti_Error is C_Int range %d .. %d;\n\n",
+-		 etimin,etimax);
+-	  printf(buf);
++	  break;
++	default:
++	  break;
+ 	}
+-	break;
+-      default:
+-	break;
+-      }
+       break;
+-      /* ---------------------------------------------------------------*/   
+-    case 'V' : /* plain version dump */
++      /* --------------------------------------------------------------- */
++    case 'V':			/* plain version dump */
+       {
+-	switch(argv[2][0]) {
+-	case '1': /* major version */
++	switch (argv[2][0])
++	  {
++	  case '1':		/* major version */
+ #ifdef NCURSES_VERSION_MAJOR
+-	  printf("%d",NCURSES_VERSION_MAJOR);
++	    printf("%d", NCURSES_VERSION_MAJOR);
+ #endif
+-	  break;
+-	case '2': /* minor version */
++	    break;
++	  case '2':		/* minor version */
+ #ifdef NCURSES_VERSION_MINOR
+-	  printf("%d",NCURSES_VERSION_MINOR);
++	    printf("%d", NCURSES_VERSION_MINOR);
+ #endif
+-	  break;
+-	case '3': /* patch level */
++	    break;
++	  case '3':		/* patch level */
+ #ifdef NCURSES_VERSION_PATCH
+-	  printf("%d",NCURSES_VERSION_PATCH);
++	    printf("%d", NCURSES_VERSION_PATCH);
+ #endif
+-	  break;
+-	default:
+-	  break;
+-	}
++	    break;
++	  default:
++	    break;
++	  }
+       }
+       break;
+-      /* ---------------------------------------------------------------*/	
++      /* --------------------------------------------------------------- */
+     default:
+       break;
+     }
+   return 0;
+ }
+-  
+Index: Ada95/gen/terminal_interface-curses-mouse.ads.m4
+--- ncurses-5.4-20040208/Ada95/gen/terminal_interface-curses-mouse.ads.m4	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/gen/terminal_interface-curses-mouse.ads.m4	2004-08-21 21:37:00.000000000 +0000
+@@ -10,7 +10,7 @@
+ --                                 S P E C                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -38,7 +38,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.22 $
++--  $Revision: 1.25 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ include(`Mouse_Base_Defs')
+@@ -169,7 +170,6 @@
+          Bstate  : Event_Mask;
+       end record;
+    pragma Convention (C, Mouse_Event);
+-   pragma Pack (Mouse_Event);
+ 
+ include(`Mouse_Event_Rep')
+    Generation_Bit_Order : constant System.Bit_Order := System.M4_BIT_ORDER;
+Index: Ada95/gen/terminal_interface-curses.ads.m4
+--- ncurses-5.4-20040208/Ada95/gen/terminal_interface-curses.ads.m4	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/gen/terminal_interface-curses.ads.m4	2004-08-21 21:37:00.000000000 +0000
+@@ -9,7 +9,7 @@
+ --                                 S P E C                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -37,7 +37,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.31 $
++--  $Revision: 1.35 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ include(`Base_Defs')
+@@ -59,11 +60,12 @@
+    subtype Column_Count is Column_Position range 1 .. Column_Position'Last;
+    --  Type to count columns. We do not allow null windows, so must be positive
+ 
+-   type Key_Code is new Natural;
++   type Key_Code is new Integer;
+    --  That is anything including real characters, special keys and logical
+    --  request codes.
+ 
+-   subtype Real_Key_Code is Key_Code range 0 .. M4_KEY_MAX;
++   --  FIXME: The "-1" should be Curses_Err
++   subtype Real_Key_Code is Key_Code range -1 .. M4_KEY_MAX;
+    --  This are the codes that potentially represent a real keystroke.
+    --  Not all codes may be possible on a specific terminal. To check the
+    --  availability of a special key, the Has_Key function is provided.
+Index: Ada95/samples/Makefile.in
+--- ncurses-5.4-20040208/Ada95/samples/Makefile.in	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/Makefile.in	2005-01-22 20:11:48.000000000 +0000
+@@ -1,5 +1,5 @@
+ ##############################################################################
+-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
++# Copyright (c) 1998-2004,2005 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"), #
+@@ -28,8 +28,7 @@
+ #
+ #  Author:  Juergen Pfeifer, 1996
+ #
+-#  Version Control
+-#  $Revision: 1.30 $
++#  $Id: Makefile.in,v 1.32 2005/01/22 20:11:48 tom Exp $
+ #
+ .SUFFIXES:
+ 
+@@ -84,7 +83,7 @@
+ ABASE        = $(ALIB)-curses
+ 
+ CARGS        =-cargs $(ADAFLAGS)
+-LARGS        =-largs -L../../lib @TEST_ARGS@ $(LD_FLAGS) -lAdaCurses @EXTRA_LIBS@
++LARGS        =-largs -L../../lib @TEST_ARGS@ $(LD_FLAGS) -lAdaCurses
+  
+ PROGS        = tour rain ncurses 
+ 
+@@ -111,19 +110,19 @@
+ 
+ 
+ all ::  tour$x rain$x ncurses$x
+-	@
++	@echo made $@
+ 
+ sources :
+-	@
++	@echo made $@
+ 
+ libs \
+ install \
+ install.libs ::
+-	@
++	@echo made $@
+ 
+ uninstall \
+ uninstall.libs ::
+-	@
++	@echo made $@
+ 
+ ncurses$x :
+ 	$(ADAMAKE) $(ADAMAKEFLAGS) ncurses $(CARGS) $(LARGS)
+@@ -138,7 +137,7 @@
+ 	$(ADAMAKE) $(ADAMAKEFLAGS) rain $(CARGS) $(LARGS)
+ 
+ mostlyclean:
+-	@
++	@echo made $@
+ 
+ clean :: mostlyclean
+ 	rm -f *.o *.ali b_t*.* *.s $(PROGS) a.out core b_*_test.c *.xr[bs] \
+@@ -148,6 +147,4 @@
+ 	rm -f Makefile
+ 
+ realclean :: distclean
+-	@
+-
+-
++	@echo made $@
+Index: Ada95/samples/ncurses2-acs_and_scroll.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-acs_and_scroll.adb	2000-12-02 22:31:22.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-acs_and_scroll.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.6 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ --  Windows and scrolling tester.
+@@ -224,8 +225,8 @@
+          );
+ 
+       buf : Bounded_String;
+-      do_keypad : Boolean := HaveKeyPad (curpw);
+-      do_scroll : Boolean := HaveScroll (curpw);
++      do_keypad : constant Boolean := HaveKeyPad (curpw);
++      do_scroll : constant Boolean := HaveScroll (curpw);
+ 
+       pos : Natural;
+ 
+@@ -331,8 +332,8 @@
+       res : pair;
+       i : Line_Position := 0;
+       j : Column_Position := 0;
+-      si : Line_Position := lri - uli + 1;
+-      sj : Column_Position := lrj - ulj + 1;
++      si : constant Line_Position := lri - uli + 1;
++      sj : constant Column_Position := lrj - ulj + 1;
+    begin
+       res.y := uli;
+       res.x := ulj;
+@@ -714,7 +715,7 @@
+ 
+    Allow_Scrolling (Mode => True);
+ 
+-   End_Mouse;
++   End_Mouse (Mask2);
+    Set_Raw_Mode (SwitchOn => True);
+    Erase;
+    End_Windows;
+Index: Ada95/samples/ncurses2-acs_display.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-acs_display.adb	2000-12-02 22:31:23.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-acs_display.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.4 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with ncurses2.util; use ncurses2.util;
+@@ -57,8 +58,8 @@
+ 
+ 
+    procedure show_upper_chars (first : Integer)  is
+-      C1 : Boolean := (first = 128);
+-      last : Integer := first + 31;
++      C1 : constant Boolean := (first = 128);
++      last : constant Integer := first + 31;
+       package p is new ncurses2.genericPuts (200);
+       use p;
+       use p.BS;
+@@ -91,9 +92,11 @@
+ 
+       for code in first .. last loop
+          declare
+-            row : Line_Position := Line_Position (4 + ((code - first) mod 16));
+-            col : Column_Position := Column_Position (((code - first) / 16) *
+-                                                      Integer (Columns) / 2);
++            row : constant Line_Position
++                := Line_Position (4 + ((code - first) mod 16));
++            col : constant Column_Position
++                := Column_Position (((code - first) / 16) *
++                                    Integer (Columns) / 2);
+             tmp3 : String (1 .. 3);
+             tmpx : String (1 .. Integer (Columns / 4));
+             reply : Key_Code;
+@@ -129,8 +132,8 @@
+                         code :  Attributed_Character)
+                        return Integer is
+       height : constant Integer := 16;
+-      row : Line_Position := Line_Position (4 + (N mod height));
+-      col : Column_Position := Column_Position ((N / height) *
++      row : constant Line_Position := Line_Position (4 + (N mod height));
++      col : constant Column_Position := Column_Position ((N / height) *
+                                                 Integer (Columns) / 2);
+       tmpx : String (1 .. Integer (Columns) / 3);
+    begin
+Index: Ada95/samples/ncurses2-attr_test.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-attr_test.adb	2001-07-21 21:34:37.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-attr_test.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2001,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.2 $
++--  $Revision: 1.5 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with ncurses2.util; use ncurses2.util;
+@@ -222,7 +223,7 @@
+             elsif ncv > 0 and has_A_COLOR (Get_Background) then
+                declare
+                   Color_Supported_Attributes :
+-                    Character_Attribute_Set := make_record (ncv);
++                    constant Character_Attribute_Set := make_record (ncv);
+                begin
+                   if intersect (Color_Supported_Attributes, attr) then
+                      Add (Str => " (NCV) ");
+@@ -236,7 +237,7 @@
+ 
+    procedure attr_getc (skip : out Integer; fg, bg : in out Color_Number;
+                                             result : out Boolean) is
+-      ch : Key_Code := Getchar;
++      ch : constant Key_Code := Getchar;
+       nc : constant Color_Number := Color_Number (Number_Of_Colors);
+       curscr : Window;
+       pragma Import (C, curscr, "curscr");
+@@ -293,7 +294,7 @@
+          --  row := 2; -- weird, row is set to 0 without this.
+          --  TODO delete the above line, it was a gdb quirk that confused me
+          if Has_Colors then declare
+-            pair : Color_Pair :=
++            pair : constant Color_Pair :=
+               Color_Pair (fg * Color_Number (Number_Of_Colors) + bg);
+          begin
+             --  Go though each color pair. Assume that the number of
+Index: Ada95/samples/ncurses2-color_edit.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-color_edit.adb	2000-12-02 22:31:24.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-color_edit.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.4 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with ncurses2.util; use ncurses2.util;
+@@ -101,7 +102,6 @@
+    current : Color_Number := 0;
+    field : RGB_Enum := Redx;
+    this_c : Key_Code := 0;
+-   last_c : Key_Code;
+ begin
+    Refresh;
+ 
+@@ -185,7 +185,6 @@
+ 
+       Move_Cursor (Line => 2 + Line_Position (current), Column => 0);
+ 
+-      last_c := this_c;
+       this_c := Getchar;
+       if Is_Digit (this_c) then
+          value := 0;
+Index: Ada95/samples/ncurses2-demo_forms.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-demo_forms.adb	2000-12-02 22:31:25.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-demo_forms.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.4 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with ncurses2.util; use ncurses2.util;
+@@ -282,7 +283,7 @@
+          );
+ 
+       c : Key_Code := Getchar (w);
+-      me : Field := Current (f);
++      me : constant Field := Current (f);
+ 
+    begin
+       if c = Character'Pos (']') mod 16#20# then
+@@ -314,7 +315,7 @@
+    end form_virtualize;
+ 
+    function my_form_driver (f : Form; c : Key_Code) return Boolean is
+-      flag : Driver_Result := Driver (f, F_Validate_Field);
++      flag : constant Driver_Result := Driver (f, F_Validate_Field);
+    begin
+       if c = Form_Request_Code'Last + 1
+         and flag = Form_Ok then
+@@ -328,7 +329,7 @@
+    function make_label (frow  : Line_Position;
+                         fcol  : Column_Position;
+                         label : String) return Field is
+-      f : Field := Create (1, label'Length, frow, fcol, 0, 0);
++      f : constant Field := Create (1, label'Length, frow, fcol, 0, 0);
+       o : Field_Option_Set := Get_Options (f);
+    begin
+       if f /= Null_Field then
+Index: Ada95/samples/ncurses2-demo_pad.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-demo_pad.adb	2000-12-02 22:31:26.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-demo_pad.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.5 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with ncurses2.util; use ncurses2.util;
+@@ -104,7 +105,7 @@
+       package myP is new System.Address_To_Access_Conversions (timeval);
+       use myP;
+ 
+-      t : Object_Pointer := new timeval;
++      t : constant Object_Pointer := new timeval;
+ 
+       function gettimeofday
+         (TP : System.Storage_Elements.Integer_Address;
+@@ -116,8 +117,13 @@
+                            (myP.To_Address (t)),
+                            System.Storage_Elements.To_Integer
+                            (myP.To_Address (null)));
+-      retval.seconds := Integer (t.tv_sec);
+-      retval.microseconds := Integer (t.tv_usec);
++      if tmp < 0 then
++         retval.seconds := 0;
++         retval.microseconds := 0;
++      else
++         retval.seconds := Integer (t.tv_sec);
++         retval.microseconds := Integer (t.tv_usec);
++      end if;
+       return retval;
+    end gettime;
+ 
+@@ -202,7 +208,7 @@
+          "Use <,> (or h,l) to grow/shrink the panner horizontally.     ");
+       legendsize : constant := 4;
+ 
+-      n : Integer := legendsize - Integer (Lines - line);
++      n : constant Integer := legendsize - Integer (Lines - line);
+    begin
+       if line < Lines and n >= 0 then
+          Move_Cursor (Line => line, Column => 0);
+@@ -216,9 +222,10 @@
+    end panner_legend;
+ 
+    procedure panner_legend (line : Line_Position) is
+-      tmp : Boolean;
+    begin
+-      tmp := panner_legend (line);
++      if not panner_legend (line) then
++         Beep;
++      end if;
+    end panner_legend;
+ 
+    procedure panner_h_cleanup (from_y : Line_Position;
+@@ -435,8 +442,8 @@
+             when Key_Cursor_Right =>
+                --  pan rightwards
+                --  if (basex + portx - (pymax > porty) < pxmax)
+-               if (basex + portx -
+-                   Column_Position (greater (pymax, porty)) < pxmax) then
++               if basex + portx -
++                   Column_Position (greater (pymax, porty)) < pxmax then
+                   --  if basex + portx  < pxmax or
+                   --      (pymax > porty and basex + portx - 1 < pxmax) then
+                   basex := basex + 1;
+@@ -455,8 +462,8 @@
+             when Key_Cursor_Down =>
+                --  pan downwards
+                --  same as if (basey + porty - (pxmax > portx) < pymax)
+-               if (basey + porty -
+-                   Line_Position (greater (pxmax, portx)) < pymax) then
++               if basey + porty -
++                   Line_Position (greater (pxmax, portx)) < pymax then
+                   --  if (basey + porty  < pymax) or
+                   --      (pxmax > portx and basey + porty - 1 < pymax) then
+                   basey := basey + 1;
+@@ -472,9 +479,10 @@
+             when   Character'Pos ('E') |
+               Key_End |
+               Key_Select =>
+-               basey := pymax - porty;
+-               if basey < 0 then --  basey := max(basey, 0);
++               if pymax < porty then
+                   basey := 0;
++               else
++                  basey := pymax - porty;
+                end if;
+ 
+             when others =>
+@@ -500,7 +508,7 @@
+          --  in C was ... pxmax > portx - 1
+          if scrollers and pxmax >= portx then
+             declare
+-               length : Column_Position := portx - top_x - 1;
++               length : constant Column_Position := portx - top_x - 1;
+                lowend, highend : Column_Position;
+             begin
+                --  Instead of using floats, I'll use integers only.
+@@ -527,7 +535,7 @@
+ 
+          if scrollers and pymax >= porty then
+             declare
+-               length : Line_Position := porty - top_y - 1;
++               length : constant Line_Position := porty - top_y - 1;
+                lowend, highend : Line_Position;
+             begin
+                lowend := top_y + (basey * length) / pymax;
+Index: Ada95/samples/ncurses2-demo_panels.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-demo_panels.adb	2000-12-02 22:31:37.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-demo_panels.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.4 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with ncurses2.util; use ncurses2.util;
+@@ -115,10 +116,10 @@
+    procedure wait_a_while (msec : Integer) is
+    begin
+       --  The C version had some #ifdef blocks here
+-      if nap_msec = 1 then
++      if msec = 1 then
+          Getchar;
+       else
+-         Nap_Milli_Seconds (nap_msec);
++         Nap_Milli_Seconds (msec);
+       end if;
+    end wait_a_while;
+ 
+@@ -137,8 +138,8 @@
+    use PUD;
+ 
+    procedure fill_panel (pan : Panel) is
+-      win : Window := Panel_Window (pan);
+-      num : Character := Get_User_Data (pan) (2);
++      win : constant Window := Panel_Window (pan);
++      num : constant Character := Get_User_Data (pan) (2);
+       tmp6 : String (1 .. 6) := "-panx-";
+       maxy : Line_Count;
+       maxx : Column_Count;
+@@ -158,7 +159,7 @@
+       end loop;
+    end fill_panel;
+ 
+-   modstr : array (0 .. 5) of String (1 .. 5) :=
++   modstr : constant array (0 .. 5) of String (1 .. 5) :=
+      ("test ",
+       "TEST ",
+       "(**) ",
+@@ -185,11 +186,11 @@
+    for y in 0 .. 4 loop
+       declare
+          p1, p2, p3, p4, p5 : Panel;
+-         U1 : User_Data_Access := new User_Data'("p1");
+-         U2 : User_Data_Access := new User_Data'("p2");
+-         U3 : User_Data_Access := new User_Data'("p3");
+-         U4 : User_Data_Access := new User_Data'("p4");
+-         U5 : User_Data_Access := new User_Data'("p5");
++         U1 : constant User_Data_Access := new User_Data'("p1");
++         U2 : constant User_Data_Access := new User_Data'("p2");
++         U3 : constant User_Data_Access := new User_Data'("p3");
++         U4 : constant User_Data_Access := new User_Data'("p4");
++         U5 : constant User_Data_Access := new User_Data'("p5");
+ 
+       begin
+          p1 := mkpanel (Red, Lines / 2 - 2, Columns / 8 + 1, 0, 0);
+@@ -295,8 +296,8 @@
+ 
+          for itmp in  0 ..  5 loop
+             declare
+-               w4 : Window := Panel_Window (p4);
+-               w5 : Window := Panel_Window (p5);
++               w4 : constant Window := Panel_Window (p4);
++               w5 : constant Window := Panel_Window (p5);
+             begin
+ 
+                saywhat ("m4; press any key to continue");
+@@ -364,7 +365,7 @@
+          rmpanel (p5);
+          pflush;
+          wait_a_while (nap_msec);
+-         if (nap_msec = 1) then
++         if nap_msec = 1 then
+             exit;
+          else
+             nap_msec := 100;
+Index: Ada95/samples/ncurses2-getch_test.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-getch_test.adb	2000-12-02 22:31:01.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-getch_test.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.5 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ --  Character input test
+@@ -96,6 +97,7 @@
+    y : Line_Position;
+    tmpx : Integer;
+    incount : Integer := 0;
++
+ begin
+    Refresh;
+    tmp2 := Start_Mouse (All_Events);
+@@ -135,7 +137,7 @@
+             Add (Ch => newl);
+          elsif c > 16#80# then --  TODO fix, use constant if possible
+             declare
+-               c2 : Character := Character'Val (c mod 16#80#);
++               c2 : constant Character := Character'Val (c mod 16#80#);
+             begin
+                if Ada.Characters.Handling.Is_Graphic (c2) then
+                   Add (Str => "M-");
+@@ -150,7 +152,7 @@
+                Add (Ch => newl);
+             end;
+          else declare
+-            c2 : Character := Character'Val (c mod 16#80#);
++            c2 : constant Character := Character'Val (c mod 16#80#);
+          begin
+             if Ada.Characters.Handling.Is_Graphic (c2) then
+                Add (Ch => c2);
+@@ -242,7 +244,7 @@
+       end loop;
+    end loop;
+ 
+-   tmp2 := Start_Mouse (No_Events);
++   End_Mouse (tmp2);
+    Set_Timeout_Mode (Mode => Blocking, Amount => 0); --  amount is ignored
+    Set_Raw_Mode (SwitchOn => False);
+    Set_NL_Mode (SwitchOn => True);
+Index: Ada95/samples/ncurses2-getopt.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-getopt.adb	2004-01-30 23:56:40.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-getopt.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.3 $
++--  $Revision: 1.6 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ --  A simplified version of the  GNU getopt function
+@@ -47,8 +48,6 @@
+ 
+ package body ncurses2.getopt is
+ 
+-   optopt : Character := '?';
+-
+    nextchar : Natural := 0;
+ 
+    --  Ncurses doesn't use the non option elements so we are spared
+@@ -104,13 +103,12 @@
+       --  Look at and handle the next short option-character.
+       declare
+          c : Character := argv (optind) (nextchar);
+-         temp : Natural :=
++         temp : constant Natural :=
+            Ada.Strings.Fixed.Index (optstring, String'(1 => c));
+       begin
+          if temp = 0 or c = ':' then
+             Put_Line (Standard_Error,
+                       argv (optind) & ": invalid option -- " & c);
+-            optopt := c;
+             c := '?';
+             return;
+          end if;
+@@ -134,7 +132,6 @@
+                   Put_Line (Standard_Error,
+                             argv (optind) &
+                             ": option requires an argument -- " & c);
+-                  optopt := c;
+                   if optstring (1) = ':'  then
+                      c := ':';
+                   else
+Index: Ada95/samples/ncurses2-m.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-m.adb	2004-01-30 23:56:51.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-m.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.2 $
++--  $Revision: 1.5 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ --  TODO use Default_Character where appropriate
+@@ -332,7 +333,7 @@
+                default_colors := True;
+             when 'e' =>
+                myio.Get (optarg.all, tmpi, length);
+-               if Integer (tmpi) > 3 then
++               if tmpi > 3 then
+                   usage;
+                   return 1;
+                end if;
+Index: Ada95/samples/ncurses2-menu_test.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-menu_test.adb	2000-12-02 22:31:04.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-menu_test.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.5 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with ncurses2.util; use ncurses2.util;
+@@ -92,6 +93,7 @@
+    items_a : Item_Array_Access := new Item_Array (1 .. animals'Last + 1);
+ 
+    tmp : Event_Mask;
++
+    procedure xAdd (l : Line_Position; c : Column_Position; s : String) is
+    begin
+       Add (Line => l, Column => c, Str => s);
+@@ -161,5 +163,5 @@
+ 
+    Delete (m);
+ 
+-   tmp := Start_Mouse (No_Events);
++   End_Mouse (tmp);
+ end ncurses2.menu_test;
+Index: Ada95/samples/ncurses2-overlap_test.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-overlap_test.adb	2000-12-02 22:31:05.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-overlap_test.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.4 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with ncurses2.util; use ncurses2.util;
+@@ -71,8 +72,8 @@
+       Get_Size (win, y1, x1);
+       for y in 0 .. y1 - 1 loop
+          for x in 0 .. x1 - 1 loop
+-            if (((x > (x1 - 1) / 3) and (x <= (2 * (x1 - 1)) / 3))
+-                or (((y > (y1 - 1) / 3) and (y <= (2 * (y1 - 1)) / 3)))) then
++            if ((x > (x1 - 1) / 3) and (x <= (2 * (x1 - 1)) / 3))
++                or (((y > (y1 - 1) / 3) and (y <= (2 * (y1 - 1)) / 3))) then
+                Move_Cursor (win, y, x);
+                Add (win, Ch => ch);
+             end if;
+Index: Ada95/samples/ncurses2-slk_test.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-slk_test.adb	2000-12-02 22:31:05.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-slk_test.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.6 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with ncurses2.util; use ncurses2.util;
+@@ -63,10 +64,13 @@
+                          Len : int) return int;
+       pragma Import (C, Wgetnstr, "wgetnstr");
+ 
+-      Txt : char_array (0 .. 10);
++      --  FIXME: how to construct "(Len > 0) ? Len : 80"?
++      Ask : constant Interfaces.C.size_t := Interfaces.C.size_t'Val (Len + 80);
++      Txt : char_array (0 .. Ask);
++
+    begin
+       Txt (0) := Interfaces.C.char'First;
+-      if Wgetnstr (Win, Txt, 8) = Curses_Err then
++      if Wgetnstr (Win, Txt, Txt'Length) = Curses_Err then
+          raise Curses_Exception;
+       end if;
+       Str := To_Unbounded_String (To_Ada (Txt, True));
+Index: Ada95/samples/ncurses2-util.adb
+--- ncurses-5.4-20040208/Ada95/samples/ncurses2-util.adb	2000-12-02 22:31:07.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/ncurses2-util.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
+ --  Version Control
+---  $Revision: 1.1 $
++--  $Revision: 1.5 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Terminal_Interface.Curses; use Terminal_Interface.Curses;
+@@ -104,9 +105,10 @@
+    end Getchar;
+ 
+    procedure Getchar (win : Window := Standard_Window) is
+-      x : Key_Code;
+    begin
+-      x := Getchar (win);
++      if Getchar (win) < 0 then
++         Beep;
++      end if;
+    end Getchar;
+ 
+ 
+Index: Ada95/samples/sample-curses_demo.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-curses_demo.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-curses_demo.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.12 $
++--  $Revision: 1.15 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Terminal_Interface.Curses; use Terminal_Interface.Curses;
+@@ -74,7 +75,7 @@
+          New_Item ("Mouse Demo"),
+          Null_Item);
+       M  : Menu := New_Menu (Itm);
+-      U1 : User_Data_Access := new User_Data'(4711);
++      U1 : constant User_Data_Access := new User_Data'(4711);
+       U2 : User_Data_Access;
+ 
+       function My_Driver (M : Menu;
+Index: Ada95/samples/sample-explanation.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-explanation.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-explanation.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.15 $
++--  $Revision: 1.18 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ --  Poor mans help system. This scans a sequential file for key lines and
+@@ -57,7 +58,7 @@
+    Help_Keys : constant String := "HELPKEYS";
+    In_Help   : constant String := "INHELP";
+ 
+-   File_Name : String := "explain.msg";
++   File_Name : constant String := "explain.msg";
+    F : File_Type;
+ 
+    type Help_Line;
+@@ -116,7 +117,7 @@
+       Current  : Help_Line_Access;
+       Top_Line : Help_Line_Access;
+ 
+-      Has_More : Boolean;
++      Has_More : Boolean := True;
+ 
+       procedure Unknown_Key
+       is
+Index: Ada95/samples/sample-form_demo-aux.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-form_demo-aux.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-form_demo-aux.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.13 $
++--  $Revision: 1.16 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
+@@ -198,7 +199,7 @@
+                   Text        : String) return Field
+    is
+       Fld : Field;
+-      C : Column_Count := Column_Count (Text'Length);
++      C : constant Column_Count := Column_Count (Text'Length);
+    begin
+       Fld := New_Field (1, C, Top, Left);
+       Set_Buffer (Fld, 0, Text);
+@@ -215,7 +216,7 @@
+                    Left        : Column_Position;
+                    Off_Screen  : Natural := 0) return Field
+    is
+-      Fld : Field := New_Field (Height, Width, Top, Left, Off_Screen);
++      Fld : constant Field := New_Field (Height, Width, Top, Left, Off_Screen);
+    begin
+       if Has_Colors then
+          Set_Foreground (Fld => Fld, Color => Form_Fore_Color);
+@@ -231,6 +232,9 @@
+                             P : Panel) return Boolean
+    is
+    begin
++      if P = Null_Panel then
++         raise Panel_Exception;
++      end if;
+       if K in User_Key_Code'Range and then K = QUIT then
+          if Driver (F, F_Validate_Field) = Form_Ok  then
+             return True;
+Index: Ada95/samples/sample-form_demo-handler.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-form_demo-handler.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-form_demo-handler.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.10 $
++--  $Revision: 1.13 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Sample.Form_Demo.Aux;
+@@ -72,7 +73,7 @@
+       end if;
+       loop
+          declare
+-            K : Key_Code := Aux.Get_Request (F, Pan, Handle_CRLF);
++            K : constant Key_Code := Aux.Get_Request (F, Pan, Handle_CRLF);
+             R : Driver_Result;
+          begin
+             if (K = 13 or else K = 10) and then not Handle_CRLF then
+Index: Ada95/samples/sample-form_demo.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-form_demo.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-form_demo.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,13 +35,13 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.10 $
++--  $Revision: 1.13 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Terminal_Interface.Curses; use Terminal_Interface.Curses;
+ with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms;
+ with Terminal_Interface.Curses.Forms.Field_User_Data;
+-with Terminal_Interface.Curses.Forms.Form_User_Data;
+ with Sample.My_Field_Type; use Sample.My_Field_Type;
+ with Sample.Explanation; use Sample.Explanation;
+ with Sample.Form_Demo.Aux; use Sample.Form_Demo.Aux;
+@@ -66,10 +66,6 @@
+      Terminal_Interface.Curses.Forms.Field_User_Data (User_Data,
+                                                       User_Access);
+ 
+-   package Frm_U is new
+-     Terminal_Interface.Curses.Forms.Form_User_Data (User_Data,
+-                                                     User_Access);
+-
+    type Weekday is (Sunday, Monday, Tuesday, Wednesday, Thursday,
+                     Friday, Saturday);
+ 
+Index: Ada95/samples/sample-function_key_setting.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-function_key_setting.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-function_key_setting.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.10 $
++--  $Revision: 1.13 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Unchecked_Deallocation;
+@@ -97,7 +98,7 @@
+       P.Help := Active_Context;
+       P.Notepad := Active_Notepad;
+       --  The notepad must now vanish and the new notepad is empty.
+-      if (P.Notepad /= Null_Panel) then
++      if P.Notepad /= Null_Panel then
+          Hide (P.Notepad);
+          Update_Panels;
+       end if;
+Index: Ada95/samples/sample-header_handler.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-header_handler.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-header_handler.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.11 $
++--  $Revision: 1.14 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Calendar; use Ada.Calendar;
+@@ -111,12 +112,12 @@
+          "November ",
+          "December ");
+ 
+-      Now : Time := Clock;
+-      Sec : Integer := Integer (Seconds (Now));
+-      Hour   : Integer := Sec / 3600;
+-      Minute : Integer := (Sec - Hour * 3600) / 60;
+-      Mon    : Month_Number := Month (Now);
+-      D      : Day_Number   := Day (Now);
++      Now    : constant Time         := Clock;
++      Sec    : constant Integer      := Integer (Seconds (Now));
++      Hour   : constant Integer      := Sec / 3600;
++      Minute : constant Integer      := (Sec - Hour * 3600) / 60;
++      Mon    : constant Month_Number := Month (Now);
++      D      : constant Day_Number   := Day (Now);
+    begin
+       if Header_Window /= Null_Window then
+          if Minute /= Display_Min or else Hour /= Display_Hour
+Index: Ada95/samples/sample-keyboard_handler.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-keyboard_handler.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-keyboard_handler.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.9 $
++--  $Revision: 1.12 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Strings; use Ada.Strings;
+@@ -95,6 +96,9 @@
+          is
+             Ch : Character;
+          begin
++            if P = Null_Panel then
++               raise Panel_Exception;
++            end if;
+             if C in User_Key_Code'Range and then C = QUIT then
+                if Driver (F, F_Validate_Field) = Form_Ok  then
+                   K := Key_None;
+@@ -102,7 +106,7 @@
+                end if;
+             elsif C in Normal_Key_Code'Range then
+                Ch := Character'Val (C);
+-               if (Ch = LF or else Ch = CR) then
++               if Ch = LF or else Ch = CR then
+                   if Driver (F, F_Validate_Field) = Form_Ok  then
+                      declare
+                         Buffer : String (1 .. Positive (Columns - 11));
+Index: Ada95/samples/sample-menu_demo-handler.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-menu_demo-handler.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-menu_demo-handler.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.12 $
++--  $Revision: 1.15 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Sample.Menu_Demo.Aux;
+@@ -75,7 +76,7 @@
+       loop
+          declare
+             K : Key_Code := Aux.Get_Request (M, Pan);
+-            R : Driver_Result := Driver (M, K);
++            R : constant Driver_Result := Driver (M, K);
+          begin
+             case R is
+                when Menu_Ok => null;
+Index: Ada95/samples/sample-menu_demo.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-menu_demo.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-menu_demo.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.13 $
++--  $Revision: 1.17 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Terminal_Interface.Curses; use Terminal_Interface.Curses;
+@@ -105,6 +106,12 @@
+                              P : Panel) return Boolean
+          is
+          begin
++            if M = Null_Menu then
++               raise Menu_Exception;
++            end if;
++            if P = Null_Panel then
++               raise Panel_Exception;
++            end if;
+             To_Change := No_Change;
+             if K in User_Key_Code'Range then
+                if K = QUIT then
+@@ -331,9 +338,9 @@
+          Null_Item);
+       M : Menu := New_Menu (Itm);
+ 
+-      U1 : User_Data_Access := new User_Data'(4711);
++      U1 : constant User_Data_Access := new User_Data'(4711);
+       U2 : User_Data_Access;
+-      U3 : User_Data_Access := new User_Data'(4712);
++      U3 : constant User_Data_Access := new User_Data'(4712);
+       U4 : User_Data_Access;
+ 
+       function My_Driver (M : Menu;
+Index: Ada95/samples/sample-my_field_type.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-my_field_type.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-my_field_type.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.9 $
++--  $Revision: 1.13 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms;
+@@ -45,11 +46,14 @@
+ --
+ package body Sample.My_Field_Type is
+ 
+-   --  That's simple. There are no field validity checks.
++   --  That's simple. There are minimal field validity checks.
+    function Field_Check (Fld : Field;
+                          Typ : My_Data) return Boolean
+    is
+    begin
++      if Fld = Null_Field or Typ.Ch = Character'Val (0) then
++         return False;
++      end if;
+       return True;
+    end Field_Check;
+ 
+Index: Ada95/samples/sample-text_io_demo.adb
+--- ncurses-5.4-20040208/Ada95/samples/sample-text_io_demo.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/samples/sample-text_io_demo.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control
+---  $Revision: 1.11 $
++--  $Revision: 1.14 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Numerics.Generic_Elementary_Functions;
+@@ -109,9 +110,9 @@
+       W : Window;
+       P : Panel := Create (Standard_Window);
+       K : Real_Key_Code;
+-      Im : Complex := (0.0, 1.0);
+-      Fx : Fix := 3.14;
+-      Dc : Dec := 2.72;
++      Im : constant Complex := (0.0, 1.0);
++      Fx : constant Fix := 3.14;
++      Dc : constant Dec := 2.72;
+       L : Md;
+ 
+    begin
+Index: Ada95/src/Makefile.in
+--- ncurses-5.4-20040208/Ada95/src/Makefile.in	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/Makefile.in	2004-08-21 21:29:50.000000000 +0000
+@@ -1,5 +1,5 @@
+ ##############################################################################
+-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
++# Copyright (c) 1998-2003,2004 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"), #
+@@ -28,8 +28,7 @@
+ #
+ #  Author:  Juergen Pfeifer, 1996
+ #
+-#  Version Control
+-#  $Revision: 1.28 $
++#  $Id: Makefile.in,v 1.30 2004/08/21 21:29:50 tom Exp $
+ #
+ .SUFFIXES:
+ 
+@@ -175,17 +174,17 @@
+ 	@sh -c 'for f in $(LIBALIS) $(GENALIS); do test -f $$f || touch $$f; done'
+ 
+ sources :
+-	@
++	@echo made $@
+ 
+ libs \
+ install \
+ install.libs \
+ uninstall \
+ uninstall.libs ::
+-	@
++	@echo made $@
+ 
+ generics: $(GENALIS)
+-	@
++	@echo made $@
+ 
+ mostlyclean ::
+ 	rm -f *.o *.ali b_t*.* *.s $(PROGS) a.out core b_*_test.c *.xr[bs] *.a
+@@ -232,7 +231,7 @@
+ 
+ $(ABASE)-trace.adb : $(srcdir)/$(ABASE)-trace.adb_p
+ 	rm -f $@
+-	$(ADAPREP) -DADA_TRACE=@ADA_TRACE@ $(srcdir)/$(ABASE)-trace.adb_p $@
++	$(ADAPREP) -DADA_TRACE=@ADA_TRACE@ -DPRAGMA_UNREF=@PRAGMA_UNREF@ $(srcdir)/$(ABASE)-trace.adb_p $@
+ 
+ $(ABASE)-trace.o: \
+ 		$(ABASE)-trace.ads \
+Index: Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.7 $
++--  $Revision: 1.10 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Characters.Handling; use Ada.Characters.Handling;
+@@ -54,7 +55,7 @@
+       I.Match_Must_Be_Unique := Must_Be_Unique;
+ 
+       for E in T'Range loop
+-         I.Names (J) := new String'(T'Image (T (E)));
++         I.Names (J) := new String'(T'Image (E));
+          --  The Image attribute defaults to upper case, so we have to handle
+          --  only the other ones...
+          if Set /= Upper_Case then
+Index: Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.10 $
++--  $Revision: 1.13 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Unchecked_Conversion;
+@@ -53,7 +54,7 @@
+                           Usr : System.Address) return C_Int
+    is
+       Result : Boolean;
+-      Udf    : User_Defined_Field_Type_With_Choice_Access :=
++      Udf    : constant User_Defined_Field_Type_With_Choice_Access :=
+         User_Defined_Field_Type_With_Choice_Access
+         (To_Argument_Access (Usr).Typ);
+    begin
+@@ -65,7 +66,7 @@
+                           Usr : System.Address) return C_Int
+    is
+       Result : Boolean;
+-      Udf    : User_Defined_Field_Type_With_Choice_Access :=
++      Udf    : constant User_Defined_Field_Type_With_Choice_Access :=
+         User_Defined_Field_Type_With_Choice_Access
+         (To_Argument_Access (Usr).Typ);
+    begin
+Index: Ada95/src/terminal_interface-curses-forms-field_types-user.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-forms-field_types-user.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-forms-field_types-user.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.10 $
++--  $Revision: 1.13 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Unchecked_Conversion;
+@@ -63,7 +64,8 @@
+       function Allocate_Arg (T : User_Defined_Field_Type'Class)
+                              return Argument_Access
+       is
+-         Ptr : Field_Type_Access := new User_Defined_Field_Type'Class'(T);
++         Ptr : constant Field_Type_Access
++             := new User_Defined_Field_Type'Class'(T);
+       begin
+          return new Argument'(Usr => System.Null_Address,
+                               Typ => Ptr,
+@@ -84,7 +86,7 @@
+                                  Usr : System.Address) return C_Int
+    is
+       Result : Boolean;
+-      Udf    : User_Defined_Field_Type_Access :=
++      Udf    : constant User_Defined_Field_Type_Access :=
+         User_Defined_Field_Type_Access (To_Argument_Access (Usr).Typ);
+    begin
+       Result := Field_Check (Fld, Udf.all);
+@@ -95,7 +97,7 @@
+                                 Usr : System.Address) return C_Int
+    is
+       Result : Boolean;
+-      Udf    : User_Defined_Field_Type_Access :=
++      Udf    : constant User_Defined_Field_Type_Access :=
+         User_Defined_Field_Type_Access (To_Argument_Access (Usr).Typ);
+    begin
+       Result := Character_Check (Character'Val (Ch), Udf.all);
+Index: Ada95/src/terminal_interface-curses-forms-field_types.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-forms-field_types.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-forms-field_types.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.14 $
++--  $Revision: 1.17 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Interfaces.C;
+@@ -144,7 +145,7 @@
+                            Typ : Field_Type'Class;
+                            Cft : C_Field_Type := C_Builtin_Router)
+    is
+-      Usr_Arg   : System.Address := Get_Arg (Fld);
++      Usr_Arg   : constant System.Address := Get_Arg (Fld);
+       Low_Level : constant C_Field_Type := Get_Fieldtype (Fld);
+       Arg : Argument_Access;
+       Res : Eti_Error;
+Index: Ada95/src/terminal_interface-curses-forms.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-forms.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-forms.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.22 $
++--  $Revision: 1.25 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Unchecked_Deallocation;
+@@ -330,7 +331,7 @@
+                                Opt : C_Int) return C_Int;
+       pragma Import (C, Set_Field_Opts, "set_field_opts");
+ 
+-      Opt : C_Int := FOS_2_CInt (Options);
++      Opt : constant C_Int := FOS_2_CInt (Options);
+       Res : Eti_Error;
+    begin
+       Res := Set_Field_Opts (Fld, Opt);
+@@ -353,7 +354,7 @@
+       pragma Import (C, Field_Opts_Off, "field_opts_off");
+ 
+       Err : Eti_Error;
+-      Opt : C_Int := FOS_2_CInt (Options);
++      Opt : constant C_Int := FOS_2_CInt (Options);
+    begin
+       if On then
+          Err := Field_Opts_On (Fld, Opt);
+@@ -373,7 +374,7 @@
+       function Field_Opts (Fld : Field) return C_Int;
+       pragma Import (C, Field_Opts, "field_opts");
+ 
+-      Res : C_Int := Field_Opts (Fld);
++      Res : constant C_Int := Field_Opts (Fld);
+    begin
+       Options := CInt_2_FOS (Res);
+    end Get_Options;
+@@ -845,7 +846,7 @@
+                               Opt : C_Int) return C_Int;
+       pragma Import (C, Set_Form_Opts, "set_form_opts");
+ 
+-      Opt : C_Int := FrmOS_2_CInt (Options);
++      Opt : constant C_Int := FrmOS_2_CInt (Options);
+       Res : Eti_Error;
+    begin
+       Res := Set_Form_Opts (Frm, Opt);
+@@ -868,7 +869,7 @@
+       pragma Import (C, Form_Opts_Off, "form_opts_off");
+ 
+       Err : Eti_Error;
+-      Opt : C_Int := FrmOS_2_CInt (Options);
++      Opt : constant C_Int := FrmOS_2_CInt (Options);
+    begin
+       if On then
+          Err := Form_Opts_On (Frm, Opt);
+@@ -888,7 +889,7 @@
+       function Form_Opts (Frm : Form) return C_Int;
+       pragma Import (C, Form_Opts, "form_opts");
+ 
+-      Res : C_Int := Form_Opts (Frm);
++      Res : constant C_Int := Form_Opts (Frm);
+    begin
+       Options := CInt_2_FrmOS (Res);
+    end Get_Options;
+@@ -995,7 +996,7 @@
+       function Frm_Driver (Frm : Form; Key : C_Int) return C_Int;
+       pragma Import (C, Frm_Driver, "form_driver");
+ 
+-      R : Eti_Error := Frm_Driver (Frm, C_Int (Key));
++      R : constant Eti_Error := Frm_Driver (Frm, C_Int (Key));
+    begin
+       if R /= E_Ok then
+          if R = E_Unknown_Command then
+@@ -1135,7 +1136,7 @@
+    begin
+       if FA /= null and then Free_Fields then
+          for I in FA'First .. (FA'Last - 1) loop
+-            if (FA (I) /= Null_Field) then
++            if FA (I) /= Null_Field then
+                Delete (FA (I));
+             end if;
+          end loop;
+Index: Ada95/src/terminal_interface-curses-menus.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-menus.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-menus.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.22 $
++--  $Revision: 1.25 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Ada.Unchecked_Deallocation;
+@@ -105,8 +106,8 @@
+       type Desc_String_Ptr is access Desc_String;
+       pragma Controlled (Desc_String_Ptr);
+ 
+-      Name_Str : Name_String_Ptr := new Name_String;
+-      Desc_Str : Desc_String_Ptr := new Desc_String;
++      Name_Str : constant Name_String_Ptr := new Name_String;
++      Desc_Str : constant Desc_String_Ptr := new Desc_String;
+       Name_Len, Desc_Len : size_t;
+       Result : Item;
+    begin
+@@ -194,7 +195,7 @@
+                               Opt : C_Int) return C_Int;
+       pragma Import (C, Set_Item_Opts, "set_item_opts");
+ 
+-      Opt : C_Int := IOS_2_CInt (Options);
++      Opt : constant C_Int := IOS_2_CInt (Options);
+       Res : Eti_Error;
+    begin
+       Res := Set_Item_Opts (Itm, Opt);
+@@ -214,7 +215,7 @@
+                               Opt : C_Int) return C_Int;
+       pragma Import (C, Item_Opts_Off, "item_opts_off");
+ 
+-      Opt : C_Int := IOS_2_CInt (Options);
++      Opt : constant C_Int := IOS_2_CInt (Options);
+       Err : Eti_Error;
+    begin
+       if On then
+@@ -233,7 +234,7 @@
+       function Item_Opts (Itm : Item) return C_Int;
+       pragma Import (C, Item_Opts, "item_opts");
+ 
+-      Res : C_Int := Item_Opts (Itm);
++      Res : constant C_Int := Item_Opts (Itm);
+    begin
+       Options := CInt_2_IOS (Res);
+    end Get_Options;
+@@ -374,7 +375,7 @@
+                               Opt : C_Int) return C_Int;
+       pragma Import (C, Set_Menu_Opts, "set_menu_opts");
+ 
+-      Opt : C_Int := MOS_2_CInt (Options);
++      Opt : constant C_Int := MOS_2_CInt (Options);
+       Res : Eti_Error;
+    begin
+       Res := Set_Menu_Opts (Men, Opt);
+@@ -394,7 +395,7 @@
+                               Opt : C_Int) return C_Int;
+       pragma Import (C, Menu_Opts_Off, "menu_opts_off");
+ 
+-      Opt : C_Int := MOS_2_CInt (Options);
++      Opt : constant C_Int := MOS_2_CInt (Options);
+       Err : Eti_Error;
+    begin
+       if On then
+@@ -413,7 +414,7 @@
+       function Menu_Opts (Men : Menu) return C_Int;
+       pragma Import (C, Menu_Opts, "menu_opts");
+ 
+-      Res : C_Int := Menu_Opts (Men);
++      Res : constant C_Int := Menu_Opts (Men);
+    begin
+       Options := CInt_2_MOS (Res);
+    end Get_Options;
+@@ -973,7 +974,7 @@
+                        Key : C_Int) return C_Int;
+       pragma Import (C, Driver, "menu_driver");
+ 
+-      R : Eti_Error := Driver (Men, C_Int (Key));
++      R : constant Eti_Error := Driver (Men, C_Int (Key));
+    begin
+       if R /= E_Ok then
+          case R is
+@@ -996,7 +997,7 @@
+    begin
+       if IA /= null and then Free_Items then
+          for I in IA'First .. (IA'Last - 1) loop
+-            if (IA (I) /= Null_Item) then
++            if IA (I) /= Null_Item then
+                Delete (IA (I));
+             end if;
+          end loop;
+Index: Ada95/src/terminal_interface-curses-mouse.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-mouse.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-mouse.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.18 $
++--  $Revision: 1.21 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with System;
+@@ -116,13 +117,18 @@
+       Old : aliased Event_Mask;
+    begin
+       R := MMask (Mask, Old'Access);
++      if R = No_Events then
++         Beep;
++      end if;
+       return Old;
+    end Start_Mouse;
+ 
+    procedure End_Mouse (Mask : in Event_Mask := No_Events)
+    is
+    begin
+-      null;
++      if Mask /= No_Events then
++         Beep;
++      end if;
+    end End_Mouse;
+ 
+    procedure Dispatch_Event (Mask   : in  Event_Mask;
+Index: Ada95/src/terminal_interface-curses-panels.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-panels.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-panels.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.10 $
++--  $Revision: 1.13 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
+@@ -104,7 +105,7 @@
+       function Panel_Win (Pan : Panel) return Window;
+       pragma Import (C, Panel_Win, "panel_window");
+ 
+-      Win : Window := Panel_Win (Pan);
++      Win : constant Window := Panel_Win (Pan);
+    begin
+       if Win = Null_Window then
+          raise Panel_Exception;
+Index: Ada95/src/terminal_interface-curses-termcap.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-termcap.adb	2004-01-30 23:57:01.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-termcap.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.6 $
++--  $Revision: 1.9 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ 
+@@ -52,7 +53,7 @@
+       pragma Import (C, tgetent, "tgetent");
+       NameTxt : char_array (0 .. Name'Length);
+       Length  : size_t;
+-      ignored : char_array (0 .. 0) := (0 => nul);
++      ignored : constant char_array (0 .. 0) := (0 => nul);
+       result  : C_Int;
+    begin
+       To_C (Name, NameTxt, Length);
+@@ -111,7 +112,7 @@
+       Length : size_t;
+       Txt2   : chars_ptr;
+       type t is new char_array (0 .. 1024); --  does it need to be 1024?
+-      Return_Buffer : t := (others => nul);
++      Return_Buffer : constant t := (others => nul);
+    begin
+       To_C (Name, Txt, Length);
+       Txt2 := tgetstr (Txt, char_array (Return_Buffer));
+@@ -132,7 +133,7 @@
+       Length : size_t;
+       Txt2   : chars_ptr;
+       type t is new char_array (0 .. 1024); --  does it need to be 1024?
+-      Phony_Txt : t := (others => nul);
++      Phony_Txt : constant t := (others => nul);
+    begin
+       To_C (Name, Txt, Length);
+       Txt2 := tgetstr (Txt, char_array (Phony_Txt));
+Index: Ada95/src/terminal_interface-curses-text_io.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-text_io.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-text_io.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.14 $
++--  $Revision: 1.17 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ package body Terminal_Interface.Curses.Text_IO is
+@@ -86,9 +87,9 @@
+       N_Cols  : Column_Count;
+    begin
+       Get_Size (Win, N_Lines, N_Cols);
+-      if Natural (N_Cols) > Natural (Count'Last) then
+-         raise Layout_Error;
+-      end if;
++      --  if Natural (N_Cols) > Natural (Count'Last) then
++      --     raise Layout_Error;
++      --  end if;
+       return Count (N_Cols);
+    end Line_Length;
+ 
+@@ -107,9 +108,9 @@
+          return 0;
+       else
+          Get_Size (Win, N_Lines, N_Cols);
+-         if Natural (N_Lines) > Natural (Count'Last) then
+-            raise Layout_Error;
+-         end if;
++         --  if Natural (N_Lines) > Natural (Count'Last) then
++         --     raise Layout_Error;
++         --  end if;
+          return Count (N_Lines);
+       end if;
+    end Page_Length;
+@@ -229,9 +230,9 @@
+    begin
+       Get_Cursor_Position (Win, Y, X);
+       N := Natural (X); N := N + 1;
+-      if N > Natural (Count'Last) then
+-         raise Layout_Error;
+-      end if;
++      --  if N > Natural (Count'Last) then
++      --     raise Layout_Error;
++      --  end if;
+       return Positive_Count (N);
+    end Col;
+ 
+@@ -249,9 +250,9 @@
+    begin
+       Get_Cursor_Position (Win, Y, X);
+       N := Natural (Y); N := N + 1;
+-      if N > Natural (Count'Last) then
+-         raise Layout_Error;
+-      end if;
++      --  if N > Natural (Count'Last) then
++      --     raise Layout_Error;
++      --  end if;
+       return Positive_Count (N);
+    end Line;
+ 
+Index: Ada95/src/terminal_interface-curses-trace.adb_p
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses-trace.adb_p	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses-trace.adb_p	2004-08-21 21:45:53.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 2000 Free Software Foundation, Inc.                        --
++-- Copyright (c) 2000,2004 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            --
+@@ -35,7 +35,7 @@
+ ------------------------------------------------------------------------------
+ --  Author:  Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.4 $
++--  $Revision: 1.5 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ #if ADA_TRACE then
+@@ -78,11 +78,17 @@
+    end Trace_Put;
+ #else
+    procedure Trace_On (x : Trace_Attribute_Set) is
++#if PRAGMA_UNREF
++   pragma Unreferenced (x);
++#end if;
+    begin
+       null;
+    end Trace_On;
+ 
+    procedure Trace_Put (str : String) is
++#if PRAGMA_UNREF
++   pragma Unreferenced (str);
++#end if;
+    begin
+       null;
+    end Trace_Put;
+Index: Ada95/src/terminal_interface-curses.adb
+--- ncurses-5.4-20040208/Ada95/src/terminal_interface-curses.adb	2003-10-25 15:39:18.000000000 +0000
++++ ncurses-5.4-20050319/Ada95/src/terminal_interface-curses.adb	2004-08-21 21:37:00.000000000 +0000
+@@ -7,7 +7,7 @@
+ --                                 B O D Y                                  --
+ --                                                                          --
+ ------------------------------------------------------------------------------
+--- Copyright (c) 1998 Free Software Foundation, Inc.                        --
++-- Copyright (c) 1998,2004 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            --
+@@ -35,7 +35,8 @@
+ ------------------------------------------------------------------------------
+ --  Author: Juergen Pfeifer, 1996
+ --  Version Control:
+---  $Revision: 1.29 $
++--  $Revision: 1.32 $
++--  $Date: 2004/08/21 21:37:00 $
+ --  Binding Version 01.00
+ ------------------------------------------------------------------------------
+ with System;
+@@ -373,7 +374,7 @@
+       function Dupwin (Win : Window) return Window;
+       pragma Import (C, Dupwin, "dupwin");
+ 
+-      W : Window := Dupwin (Win);
++      W : constant Window := Dupwin (Win);
+    begin
+       if W = Null_Window then
+          raise Curses_Exception;
+@@ -935,6 +936,9 @@
+       procedure No_Qiflush;
+       pragma Import (C, No_Qiflush, "noqiflush");
+    begin
++      if Win = Null_Window then
++         raise Curses_Exception;
++      end if;
+       if Flush then
+          Qiflush;
+       else
+@@ -1398,8 +1402,10 @@
+    is
+       --  Please note: in ncurses they are one off.
+       --  This might be different in other implementations of curses
+-      Y : C_Int := C_Int (W_Get_Short (Win, Offset_maxy)) + C_Int (Offset_XY);
+-      X : C_Int := C_Int (W_Get_Short (Win, Offset_maxx)) + C_Int (Offset_XY);
++      Y : constant C_Int := C_Int (W_Get_Short (Win, Offset_maxy))
++                          + C_Int (Offset_XY);
++      X : constant C_Int := C_Int (W_Get_Short (Win, Offset_maxx))
++                          + C_Int (Offset_XY);
+    begin
+       Number_Of_Lines   := Line_Count (Y);
+       Number_Of_Columns := Column_Count (X);
+@@ -1410,8 +1416,8 @@
+       Top_Left_Line   : out Line_Position;
+       Top_Left_Column : out Column_Position)
+    is
+-      Y : C_Short := W_Get_Short (Win, Offset_begy);
+-      X : C_Short := W_Get_Short (Win, Offset_begx);
++      Y : constant C_Short := W_Get_Short (Win, Offset_begy);
++      X : constant C_Short := W_Get_Short (Win, Offset_begx);
+    begin
+       Top_Left_Line   := Line_Position (Y);
+       Top_Left_Column := Column_Position (X);
+@@ -1422,8 +1428,8 @@
+       Line   : out Line_Position;
+       Column : out Column_Position)
+    is
+-      Y : C_Short := W_Get_Short (Win, Offset_cury);
+-      X : C_Short := W_Get_Short (Win, Offset_curx);
++      Y : constant C_Short := W_Get_Short (Win, Offset_cury);
++      X : constant C_Short := W_Get_Short (Win, Offset_curx);
+    begin
+       Line   := Line_Position (Y);
+       Column := Column_Position (X);
+@@ -1435,8 +1441,8 @@
+       Top_Left_Column    : out Column_Position;
+       Is_Not_A_Subwindow : out Boolean)
+    is
+-      Y : C_Int := W_Get_Int (Win, Offset_pary);
+-      X : C_Int := W_Get_Int (Win, Offset_parx);
++      Y : constant C_Int := W_Get_Int (Win, Offset_pary);
++      X : constant C_Int := W_Get_Int (Win, Offset_parx);
+    begin
+       if Y = -1 then
+          Top_Left_Line   := Line_Position'Last;
+@@ -1762,7 +1768,8 @@
+       pragma Import (C, Winchnstr, "winchnstr");
+ 
+       N   : Integer := Len;
+-      Txt : chtype_array (0 .. Str'Length) := (0 => Default_Character);
++      Txt : constant chtype_array (0 .. Str'Length)
++          := (0 => Default_Character);
+       Cnt : Natural := 0;
+    begin
+       if N < 0 then
+@@ -2457,7 +2464,7 @@
+       pragma Import (C, C_Assume_Default_Colors, "assume_default_colors");
+ 
+       Err : constant C_Int := C_Assume_Default_Colors (C_Int (Fore),
+-                                                       C_Int (Black));
++                                                       C_Int (Back));
+    begin
+       if Err = Curses_Err then
+          raise Curses_Exception;
+Index: INSTALL
+Prereq:  1.71 
+--- ncurses-5.4-20040208/INSTALL	2004-02-07 21:06:05.000000000 +0000
++++ ncurses-5.4-20050319/INSTALL	2005-02-05 19:28:55.000000000 +0000
+@@ -1,4 +1,4 @@
+--- $Id: INSTALL,v 1.71 2004/02/07 21:06:05 tom Exp $
++-- $Id: INSTALL,v 1.81 2005/02/05 19:28:55 tom Exp $
+ ---------------------------------------------------------------------
+              How to install Ncurses/Terminfo on your system
+ ---------------------------------------------------------------------
+@@ -19,12 +19,6 @@
+ If you are converting from BSD curses and do not have root access, be sure
+ to read the BSD CONVERSION NOTES section below.
+ 
+-If you are using a version of XFree86 xterm older than 3.1.2F, see the section
+-on RECENT XTERM VERSIONS below.
+-
+-If you are trying to build GNU Emacs using ncurses for terminal support,
+-read the USING NCURSES WITH EMACS section below.
+-
+ If you are trying to build applications using gpm with ncurses,
+ read the USING NCURSES WITH GPM section below.
+ 
+@@ -45,7 +39,7 @@
+ REQUIREMENTS:
+ ------------
+ 
+-You will need the following in order to build and install ncurses under UNIX:
++You will need the following to build and install ncurses under UNIX:
+ 
+ 	* ANSI C compiler  (gcc, for instance)
+ 	* sh               (bash will do)
+@@ -64,9 +58,10 @@
+     with it.
+ 
+     The --prefix option to configure changes the root directory for installing
+-    ncurses.  The default is in subdirectories of /usr/local.  Use
+-    --prefix=/usr to replace your default curses distribution.  This is the
+-    default for Linux and BSD/OS users.
++    ncurses.  The default is normally in subdirectories of /usr/local, except
++    for systems where ncurses is normally installed as a system library, e.g.,
++    Linux, the various BSD systems and Cygwin.  Use --prefix=/usr to replace
++    your default curses distribution.
+ 
+     The package gets installed beneath the --prefix directory as follows:
+ 
+@@ -77,9 +72,20 @@
+     In $(prefix)/include:      C header files
+     Under $(prefix)/man:       the manual pages
+ 
+-    Note however that the configure script attempts to locate previous
+-    installation of ncurses, and will set the default prefix according to where
+-    it finds the ncurses headers.
++    Note that the configure script attempts to locate previous installation of
++    ncurses, and will set the default prefix according to where it finds the
++    ncurses headers.
++
++    Do not use commands such as
++
++    	make install prefix=XXX
++
++    to change the prefix after configuration, since the prefix value is used
++    for some absolute pathnames such as TERMINFO.  Instead do this
++
++    	make install DESTDIR=XXX
++
++    See also the discussion of --with-install-prefix.
+ 
+ 2.  Type `./configure' in the top-level directory of the distribution to
+     configure ncurses for your operating system and create the Makefiles.
+@@ -379,6 +385,22 @@
+ 	For testing, generate functions for certain macros to make them visible
+ 	as such to the debugger.  See also the --disable-macros option.
+ 
++    --enable-ext-colors
++	Extend the cchar_t structure to allow more than 16 colors to be
++	encoded.  This applies only to the wide-character (--enable-widec)
++	configuration.
++
++	NOTE: this option is not yet complete (2005/1/29).
++
++	NOTE:  using this option will make libraries which are not binary-
++	compatible with libncursesw 5.4.  None of the interfaces change, but
++	applications which have an array of cchar_t's must be recompiled.
++
++    --enable-ext-mouse
++	Modify the encoding of mouse state to make room for a 5th mouse button.
++	That allows one to use ncurses with a wheel mouse with xterm or
++	similar X terminal emulators.
++
+     --enable-getcap
+ 	Use the 4.4BSD getcap code if available, or a bundled version of it to
+ 	fetch termcap entries.  Entries read in this way cannot use (make
+@@ -444,9 +466,9 @@
+ 	Turn on GCC compiler warnings.  There should be only a few.
+ 
+     --enable-widec
+-	Compile with experimental wide-character code.  This makes a different
+-	version of the libraries (e.g., libncursesw.so), which stores
+-	characters as wide-characters,
++	Compile with wide-character code.  This makes a different version of
++	the libraries (e.g., libncursesw.so), which stores characters as
++	wide-characters,
+ 
+ 	NOTE: applications compiled with this configuration are not compatible
+ 	with those built for 8-bit characters.  You cannot simply make a
+@@ -551,7 +573,11 @@
+     --with-install-prefix=XXX
+ 	Allows you to specify an alternate location for installing ncurses
+ 	after building it.  The value you specify is prepended to the "real"
+-	install location.  This simplifies making binary packages.
++	install location.  This simplifies making binary packages.  The
++	makefile variable DESTDIR is set by this option.  It is also possible
++	to use
++		make install DESTDIR=XXX
++	since the makefiles pass that variable to subordinate makes.
+ 
+ 	NOTE:  a few systems build shared libraries with fixed pathnames; this
+ 	option probably will not work for those configurations.
+@@ -657,12 +683,19 @@
+ 	Specify a search-list of terminfo directories which will be compiled
+ 	into the ncurses library (default: DATADIR/terminfo)
+ 
+-    --with-termlib
++    --with-termlib[=XXX]
+ 	When building the ncurses library, organize this as two parts:  the
+ 	curses library (libncurses) and the low-level terminfo library
+ 	(libtinfo).  This is done to accommodate applications that use only
+ 	the latter.  The terminfo library is about half the size of the total.
+ 
++	If an option value is given, that overrides the name of the terminfo
++	library.  For instance, if the wide-character version is built, the
++	terminfo library would be named libtinfow.  But the libtinfow interface
++	is upward compatible from libtinfo, so it would be possible to overlay
++	libtinfo.so with a "wide" version of libtinfow.so by renaming it with
++	this option.
++
+     --with-termpath=XXX
+ 	Specify a search-list of termcap files which will be compiled into the
+ 	ncurses library (default:  /etc/termcap:/usr/share/misc/termcap)
+@@ -698,6 +731,11 @@
+ 	programs (e.g., tic).  The test applications will still be built if you
+ 	type "make", though not if you simply do "make install".
+ 
++    --without-xterm-new
++	Tell the configure script to use "xterm-old" for the entry used in
++	the terminfo database.  This will work with variations such as
++	X11R5 and X11R6 xterm.
++
+ 
+ COMPATIBILITY WITH OLDER VERSIONS OF NCURSES:
+ --------------------------------------------
+@@ -1063,17 +1101,10 @@
+ ---------------------
+ 
+ 	The terminfo database file included with this distribution assumes you
+-	are running an XFree86 xterm based on X11R6 (i.e., xterm-r6).  The
+-	earlier X11R5 entry (xterm-r5) is provided as well.
+-
+-	If you are running XFree86 version 3.2 (actually 3.1.2F and up), you
+-	should consider using the xterm-xf86-v32 (or later, the most recent
+-	version is always named "xterm-xfree86") entry, which adds ANSI color
+-	and the VT220 capabilities which have been added in XFree86.  If you
+-	are running a mixed network, however, where this terminal description
+-	may be used on an older xterm, you may have problems, since
+-	applications that assume these capabilities will produce incorrect
+-	output on the older xterm (e.g., highlighting is not cleared).
++	are running a modern xterm based on XFree86 (i.e., xterm-new).  The
++	earlier X11R6 entry (xterm-r6) and X11R5 entry (xterm-r5) is provided
++	as well.  See the --without-xterm-new configure script option if you
++	are unable to update your system.
+ 
+ 
+ CONFIGURING FALLBACK ENTRIES:
+@@ -1186,17 +1217,6 @@
+ 	can't hard-link across them.  The --enable-symlinks option copes
+ 	with this by making tic use symbolic links.
+ 
+-USING NCURSES WITH EMACS:
+-	GNU Emacs has its own termcap support.  By default, it uses a mixture
+-	of those functions and code linked from the host system's libraries.
+-	You need to foil this and shut out the GNU termcap library entirely.
+-
+-	In order to do this, hack the Linux config file (s/linux.h) to contain
+-	a #define TERMINFO and set the symbol LIBS_TERMCAP to "-lncurses".
+-
+-	We have submitted such a change for the 19.30 release, so it may
+-	already be applied in your sources -- check for the #define TERMINFO.
+-
+ USING NCURSES WITH GPM:
+ 	Ncurses 4.1 and up can be configured to use GPM (General Purpose Mouse)
+ 	which is used on Linux console.  Be aware that GPM is commonly
+@@ -1210,13 +1230,9 @@
+ 		cc -o foo foo.o -lncurses -lgpm -lncurses
+ 
+ 	but the linker may not cooperate, producing mysterious errors.
+-	A patched version of gpm is available:
+-
+-		dickey.his.com:/ncurses/gpm-1.10-970125.tar.gz
++	See the FAQ:
+ 
+-	This patch is incorporated in gpm 1.12; however some integrators
+-	are slow to update this library.  Current distributions of gpm can
+-	be configured properly using the --without-curses option.
++	http://invisible-island.net/ncurses/ncurses.faq.html#using_gpm_lib
+ 
+ BUILDING NCURSES WITH A CROSS-COMPILER
+ 	Ncurses can be built with a cross-compiler.  Some parts must be built
+Index: MANIFEST
+--- ncurses-5.4-20040208/MANIFEST	2004-01-03 23:04:44.000000000 +0000
++++ ncurses-5.4-20050319/MANIFEST	2005-01-29 19:02:48.000000000 +0000
+@@ -433,6 +433,7 @@
+ ./doc/ncurses-intro.doc
+ ./form/Makefile.in
+ ./form/READ.ME
++./form/f_trace.c
+ ./form/fld_arg.c
+ ./form/fld_attr.c
+ ./form/fld_current.c
+@@ -663,6 +664,7 @@
+ ./menu/m_scale.c
+ ./menu/m_spacing.c
+ ./menu/m_sub.c
++./menu/m_trace.c
+ ./menu/m_userptr.c
+ ./menu/m_win.c
+ ./menu/menu.h
+@@ -677,11 +679,13 @@
+ ./misc/emx.src
+ ./misc/form.def
+ ./misc/form.ref
+-./misc/indent.pro
++./misc/gen_edit.sh
++./misc/jpf-indent
+ ./misc/makedef.cmd
+ ./misc/makellib
+ ./misc/menu.def
+ ./misc/menu.ref
++./misc/ncu-indent
+ ./misc/ncurses.def
+ ./misc/ncurses.ref
+ ./misc/panel.def
+@@ -738,6 +742,7 @@
+ ./ncurses/base/lib_initscr.c
+ ./ncurses/base/lib_insch.c
+ ./ncurses/base/lib_insdel.c
++./ncurses/base/lib_insnstr.c
+ ./ncurses/base/lib_instr.c
+ ./ncurses/base/lib_isendwin.c
+ ./ncurses/base/lib_leaveok.c
+@@ -973,6 +978,7 @@
+ ./test/inserts.c
+ ./test/keynames.c
+ ./test/knight.c
++./test/linux-color.dat
+ ./test/listused.sh
+ ./test/lrtest.c
+ ./test/modules
+@@ -990,3 +996,5 @@
+ ./test/view.c
+ ./test/worm.c
+ ./test/xmas.c
++./test/xterm-16color.dat
++./test/xterm-88color.dat
+Index: Makefile.in
+Prereq:  1.22 
+--- ncurses-5.4-20040208/Makefile.in	2001-10-27 18:17:22.000000000 +0000
++++ ncurses-5.4-20050319/Makefile.in	2005-01-29 19:30:06.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: Makefile.in,v 1.22 2001/10/27 18:17:22 tom Exp $
++# $Id: Makefile.in,v 1.24 2005/01/29 19:30:06 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
++# Copyright (c) 1998-2004,2005 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"), #
+@@ -65,6 +65,9 @@
+ 	@ echo ''
+ 	@ echo '** Configuration summary for NCURSES $(NCURSES_MAJOR).$(NCURSES_MINOR) $(NCURSES_PATCH):'
+ 	@ echo ''
++	@ echo '     extended funcs: '`test @NCURSES_EXT_FUNCS@ != 0 && echo yes || echo no`
++	@ echo '     xterm terminfo: '@WHICH_XTERM@
++	@ echo ''
+ 	@ echo '      bin directory: '$(bindir)
+ 	@ echo '      lib directory: '$(libdir)
+ 	@ echo '  include directory: '$(includedir)
+@@ -89,5 +92,6 @@
+ realclean \
+ depend \
+ sources \
++tags \
+ uninstall \
+ install ::
+Index: NEWS
+Prereq:  1.797 
+--- ncurses-5.4-20040208/NEWS	2004-02-08 21:15:26.000000000 +0000
++++ ncurses-5.4-20050319/NEWS	2005-03-19 23:23:04.000000000 +0000
+@@ -1,4 +1,4 @@
+--- $Id: NEWS,v 1.797 2004/02/08 21:15:26 tom Exp $
++-- $Id: NEWS,v 1.877 2005/03/19 23:23:04 tom Exp $
+ 
+ This is a log of changes that ncurses has gone through since Zeyd started
+ working with Pavel Curtis' original work, pcurses, in 1992.
+@@ -6,6 +6,512 @@
+ Changes through 1.9.9e are recorded by Zeyd M. Ben-Halim.
+ Changes since 1.9.9e are recorded by Thomas Dickey.
+ 
++20050319
++	+ modify ncurses.c 'd' test to make it work with 88-color
++	  configuration, i.e., by implementing scrolling.
++	+ improve scrolling in ncurses.c 'c' and 'C' tests, e.g., for 88-color
++	  configuration.
++
++20050312
++	+ change tracemunch to use strict checking.
++	+ modify ncurses.c 'p' test to test line-drawing within a pad.
++	+ implement environment variable NCURSES_NO_UTF8_ACS to support
++	  miscellaneous terminal emulators which ignore alternate character
++	  set escape sequences when in UTF-8 mode.
++
++20050305
++	+ change NCursesWindow::err_handler() to a virtual function (request by
++	  Steve Beal).
++	+ modify ftp_int.c and fty_num.c to handle wide characters (report by
++	  Wolfgang Gutjahr).
++	+ adapt fix for fty_alpha.c to fty_alnum.c, which also handled normal
++	  and wide characters inconsistently (report by Wolfgang Gutjahr).
++	+ update llib-* files to reflect internal interface additions/changes.
++
++20050226
++	+ improve test/configure script, adding tests for _XOPEN_SOURCE, etc.,
++	  from lynx.
++	+ add aixterm-16color terminfo entry -TD
++	+ modified xterm-new terminfo entry to work with tgetent() changes -TD
++	+ extended changes in tgetent() from 20040710 to allow the substring of
++	  sgr0 which matches rmacs to be at the beginning of the sgr0 string
++	  (request by Thomas Wolff, who says the visual effect in combination
++	  with pre-20040710 ncurses is improved).
++	+ fix off-by-one in winnstr() call which caused form field validation
++	  of multibyte characters to ignore the last character in a field.
++	+ correct logic in winsch() for inserting multibyte strings; the code
++	  would clear cells after the insertion rather than push them to the
++	  right (cf: 20040228).
++	+ fix an inconsistency in Check_Alpha_Field() between normal and wide
++	  character logic (report by Wolfgang Gutjahr).
++
++20050219
++	+ fix a bug in editing wide-characters in form library: deleting a
++	  nonwide character modified the previous wide-character.
++	+ update manpage to describe NCURSES_MOUSE_VERSION 2.
++	+ correct manpage description of mouseinterval() (Debian #280687).
++	+ add a note to default_colors.3x explaining why this extension was
++	  added (Debian #295083).
++	+ add traces to panel library.
++
++20050212
++	+ improve editing of wide-characters in form library:  left/right
++	  cursor movement, and single-character deletions work properly.
++	+ disable GPM mouse support when $TERM happens to be prefixed with
++	  "xterm".  Gpm_Open() would otherwise assert that it can deal with
++	  mouse events in this case.
++	+ modify GPM mouse support so it closes the server connection when
++	  the caller disables the mouse (report by Stanislav Ievlev).
++
++20050205
++	+ add traces for callback functions in form library.
++	+ add experimental configure option --enable-ext-mouse, which defines
++	  NCURSES_MOUSE_VERSION 2, and modifies the encoding of mouse events to
++	  support wheel mice, which may transmit buttons 4 and 5.  This works
++	  with xterm and similar X terminal emulators (prompted by question by
++	  Andreas Henningsson, this is also related to Debian #230990).
++	+ improve configure macros CF_XOPEN_SOURCE and CF_POSIX_C_SOURCE to
++	  avoid redefinition warnings on cygwin.
++
++20050129
++	+ merge remaining development changes for extended colors (mostly
++	  complete, does not appear to break other configurations).
++	+ add xterm-88color.dat (part of extended colors testing).
++	+ improve _tracedump() handling of color pairs past 96. 
++	+ modify return-value from start_color() to return OK if colors have
++	  already been started.
++	+ modify curs_color.3x list error conditions for init_pair(),
++	  pair_content() and color_content().
++	+ modify pair_content() to return -1 for consistency with init_pair()
++	  if it corresponds to the default-color.
++	+ change internal representation of default-color to allow application
++	  to use color number 255.  This does not affect the total number of
++	  color pairs which are allowed.
++	+ add a top-level tags rule.
++
++20050122
++	+ add a null-pointer check in wgetch() in case it is called without
++	  first calling initscr().
++	+ add some null-pointer checks for SP, which is not set by libtinfo.
++	+ modify misc/shlib to ensure that absolute pathnames are used.
++	+ modify test/Makefile.in, etc., to link test programs only against the
++	  libraries needed, e.g., omit form/menu/panel library for the ones
++	  that are curses-specific.
++	+ change SP->_current_attr to a pointer, adjust ifdef's to ensure that
++	  libtinfo.so and libtinfow.so have the same ABI.  The reason for this
++	  is that the corresponding data which belongs to the upper-level
++	  ncurses library has a different size in each model (report by
++	  Stanislav Ievlev).
++
++20050115
++	+ minor fixes to allow test-compiles with g++.
++	+ correct column value shown in tic's warnings, which did not account
++	  for leading whitespace.
++	+ add a check in _nc_trans_string() for improperly ended strings, i.e.,
++	  where a following line begins in column 1.
++	+ modify _nc_save_str() to return a null pointer on buffer overflow.
++	+ improve repainting while scrolling wide-character data (Eungkyu Song).
++
++20050108
++	+ merge some development changes to extend color capabilities.
++
++20050101
++	+ merge some development changes to extend color capabilities.
++	+ fix manpage typo (FreeBSD report docs/75544).
++	+ update config.guess, config.sub
++	> patches by Albert Chin-A-Young (for configure script):
++	+ improved fix to make mbstate_t recognized on HPUX 11i (cf: 
++	  20030705), making vsscanf() prototype visible on IRIX64.  Tested for
++	  on HP-UX 11i, Solaris 7, 8, 9, AIX 4.3.3, 5.2, Tru64 UNIX 4.0D, 5.1,
++	  IRIX64 6.5, Redhat Linux 7.1, 9, and RHEL 2.1, 3.0.
++	+ print the result of the --disable-home-terminfo option.
++	+ use -rpath when compiling with SGI C compiler.
++
++20041225
++	+ add trace calls to remaining public functions in form and menu
++	  libraries.
++	+ fix check for numeric digits in test/ncurses.c 'b' and 'B' tests.
++	+ fix typo in test/ncurses.c 'c' test from 20041218.
++
++20041218
++	+ revise test/ncurses.c 'c' color test to improve use for xterm-88color
++	  and xterm-256color, added 'C' test using the wide-character color_set
++	  and attr_set functions.
++
++20041211
++	+ modify configure script to work with Intel compiler.
++	+ fix an limit-check in wadd_wchnstr() which caused labels in the
++	  forms-demo to be one character short.
++	+ fix typo in curs_addchstr.3x (Jared Yanovich).
++	+ add trace calls to most functions in form and menu libraries.
++	+ update working-position for adding wide-characters when window is
++	  scrolled (prompted by related report by Eungkyu Song).
++
++20041204
++	+ replace some references on Linux to wcrtomb() which use it to obtain
++	  the length of a multibyte string with _nc_wcrtomb, since wcrtomb() is
++	  broken in glibc (see Debian #284260).
++	+ corrected length-computation in wide-character support for
++	  field_buffer().
++	+ some fixes to frm_driver.c to allow it to accept multibyte input.
++	+ modify configure script to work with Intel 8.0 compiler.
++
++20041127
++	+ amend change to setupterm() in 20030405 which would reuse the value
++	  of cur_term if the same output was selected.  This now reuses it only
++	  when setupterm() is called from tgetent(), which has no notion of
++	  separate SCREENs.  Note that tgetent() must be called after initscr()
++	  or newterm() to use this feature (Redhat Bugzilla #140326).
++	+ add a check in CF_BUILD_CC macro to ensure that developer has given
++	  the --with-build-cc option when cross-compiling (report by Alexandre
++	  Campo).
++	+ improved configure script checks for _XOPEN_SOURCE and
++	  _POSIX_C_SOURCE (fix for IRIX 5.3 from Georg Schwarz, _POSIX_C_SOURCE
++	  updates from lynx).
++	+ cosmetic fix to test/gdc.c to recolor the bottom edge of the box
++	  for consistency (comment by Dan Nelson).
++
++20041120
++	+ update wsvt25 terminfo entry -TD
++	+ modify test/ins_wide.c to test all flavors of ins_wstr().
++	+ ignore filler-cells in wadd_wchnstr() when adding a cchar_t array
++	  which consists of multi-column characters, since this function
++	  constructs them (cf: 20041023).
++	+ modify winnstr() to return multibyte character strings for the
++	  wide-character configuration.
++
++20041106
++	+ fixes to make slk_set() and slk_wset() accept and store multibyte
++	  or multicolumn characters.
++
++20041030
++	+ improve color optimization a little by making _nc_do_color() check
++	  if the old/new pairs are equivalent to the default pair 0.
++	+ modify assume_default_colors() to not require that
++	  use_default_colors() be called first.
++
++20041023
++	+ modify term_attrs() to use termattrs(), add the extended attributes
++	  such as enter_horizontal_hl_mode for WA_HORIZONTAL to term_attrs().
++	+ add logic in waddch_literal() to clear orphaned cells when one
++	  multi-column character partly overwrites another.
++	+ improved logic for clearing cells when a multi-column character
++	  must be wrapped to a new line.
++	+ revise storage of cells for multi-column characters to correct a
++	  problem with repainting.  In the old scheme, it was possible for
++	  doupdate() to decide that only part of a multi-column character
++	  should be repainted since the filler cells stored only an attribute
++	  to denote them as fillers, rather than the character value and the
++	  attribute.
++
++20041016
++	+ minor fixes for traces.
++	+ add SP->_screen_acs_map[], used to ensure that mapping of missing
++	  line-drawing characters is handled properly.  For example, ACS_DARROW
++	  is absent from xterm-new, and it was coincidentally displayed the
++	  same as ACS_BTEE.
++
++20041009
++	+ amend 20021221 workaround for broken acs to reset the sgr, rmacs
++	  and smacs strings as well.  Also modify the check for screen's
++	  limitations in that area to allow the multi-character shift-in
++	  and shift-out which seem to work.
++	+ change GPM initialization, using dl library to load it dynamically
++	  at runtime (Debian #110586).
++
++20041002
++	+ correct logic for color pair in setcchar() and getcchar() (patch by
++	  Marcin 'Qrczak' Kowalczyk).
++	+ add t/T commands to ncurses b/B tests to allow a different color to
++	  be tested for the attrset part of the test than is used in the
++	  background color.
++
++20040925
++	+ fix to make setcchar() to work when its wchar_t* parameter is
++	  pointing to a string which contains more data than can be converted.
++	+ modify wget_wstr() and example in ncurses.c to work if wchar_t and
++	  wint_t are different sizes (report by Marcin 'Qrczak' Kowalczyk).
++
++20040918
++	+ remove check in wget_wch() added to fix an infinite loop, appears to
++	  have been working around a transitory glibc bug, and interferes
++	  with normal operation (report by Marcin 'Qrczak' Kowalczyk).
++	+ correct wadd_wch() and wecho_wch(), which did not pass the rendition
++	  information (report by Marcin 'Qrczak' Kowalczyk).
++	+ fix aclocal.m4 so that the wide-character version of ncurses gets
++	  compiled as libncursesw.5.dylib, instead of libncurses.5w.dylib
++	  (adapted from patch by James J Ramsey).
++	+ change configure script for --with-caps option to indicate that it
++	  is no longer experimental.
++	+ change configure script to reflect the fact that --enable-widec has
++	  not been "experimental" since 5.3 (report by Bruno Lustosa).
++
++20040911
++	+ add 'B' test to ncurses.c, to exercise some wide-character functions.
++
++20040828
++	+ modify infocmp -i option to match 8-bit controls against its table
++	  entries, e.g., so it can analyze the xterm-8bit entry.
++	+ add morphos terminfo entry, improve amiga-8bit entry (Pavel Fedin).
++	+ correct translation of "%%" in terminfo format to termcap, e.g.,
++	  using "tic -C" (Redhat Bugzilla #130921).
++	+ modified configure script CF_XOPEN_SOURCE macro to ensure that if
++	  it defines _POSIX_C_SOURCE, that it defines it to a specific value
++	  (comp.os.stratus newsgroup comment).
++
++20040821
++	+ fixes to build with Ada95 binding with gnat 3.4 (all warnings are
++	  fatal, and gnat does not follow the guidelines for pragmas).
++	  However that did find a coding error in Assume_Default_Colors().
++	+ modify several terminfo entries to ensure xterm mouse and cursor
++	  visibility are reset in rs2 string:  hurd, putty, gnome,
++	  konsole-base, mlterm, Eterm, screen (Debian #265784, #55637).  The
++	  xterm entries are left alone - old ones for compatibility, and the
++	  new ones do not require this change. -TD
++
++20040814
++	+ fake a SIGWINCH in newterm() to accommodate buggy terminal emulators
++	  and window managers (Debian #265631).
++	> terminfo updates -TD
++	+ remove dch/dch1 from rxvt because they are implemented inconsistently
++	  with the common usage of bce/ech
++	+ remove khome from vt220 (vt220's have no home key)
++	+ add rxvt+pcfkeys
++
++20040807
++	+ modify test/ncurses.c 'b' test, adding v/V toggles to cycle through
++	  combinations of video attributes so that for instance bold and
++	  underline can be tested.  This made the legend too crowded, added
++	  a help window as well.
++	+ modify test/ncurses.c 'b' test to cycle through default colors if
++	  the -d option is set.
++	+ update putty terminfo entry (Robert de Bath).
++
++20040731
++	+ modify test/cardfile.c to allow it to read more data than can be
++	  displayed.
++	+ correct logic in resizeterm.c which kept it from processing all
++	  levels of window hierarchy (reports by Folkert van Heusden,
++	  Chris Share).
++
++20040724
++	+ modify "tic -cv" to ignore delays when comparing strings.  Also
++	  modify it to ignore a canceled sgr string, e.g., for terminals which
++	  cannot properly combine attributes in one control sequence.
++	+ corrections for gnome and konsole entries (Redhat Bugzilla #122815,
++	  patch by Hans de Goede)
++	> terminfo updates -TD
++	+ make ncsa-m rmacs/smacs consistent with sgr
++	+ add sgr, rc/sc and ech to syscons entries
++	+ add function-keys to decansi
++	+ add sgr to mterm-ansi
++	+ add sgr, civis, cnorm to emu
++	+ correct/simplify cup in addrinfo
++
++20040717
++	> terminfo updates -TD
++	+ add xterm-pc-fkeys
++	+ review/update gnome and gnome-rh90 entries (prompted by Redhat
++	  Bugzilla #122815).
++	+ review/update konsole entries
++	+ add sgr, correct sgr0 for kterm and mlterm
++	+ correct tsl string in kterm
++
++20040711
++	+ add configure option --without-xterm-new
++
++20040710
++	+ add check in wget_wch() for printable bytes that are not part of a
++	  multibyte character.
++	+ modify wadd_wchnstr() to render text using window's background
++	  attributes.
++	+ improve tic's check to compare sgr and sgr0.
++	+ fix c++ directory's .cc.i rule.
++	+ modify logic in tgetent() which adjusts the termcap "me" string
++	  to work with ISO-2022 string used in xterm-new (cf: 20010908).
++	+ modify tic's check for conflicting function keys to omit that if
++	  converting termcap to termcap format.
++	+ add -U option to tic and infocmp.
++	+ add rmam/smam to linux terminfo entry (Trevor Van Bremen)
++	> terminfo updates -TD
++	+ minor fixes for emu
++	+ add emu-220
++	+ change wyse acsc strings to use 'i' map rather than 'I'
++	+ fixes for avatar0
++	+ fixes for vp3a+
++
++20040703
++	+ use tic -x to install terminfo database -TD
++	+ add -x to infocmp's usage message.
++	+ correct field used for comparing O_ROWMAJOR in set_menu_format()
++	  (report/patch by Tony Li).
++	+ fix a missing nul check in set_field_buffer() from 20040508 changes.
++	> terminfo updates -TD
++	  + make xterm-xf86-v43 derived from xterm-xf86-v40 rather than
++	    xterm-basic -TD
++	  + align with xterm patch #192's use of xterm-new -TD
++	  + update xterm-new and xterm-8bit for cvvis/cnorm strings -TD
++	  + make xterm-new the default "xterm" entry -TD
++
++20040626
++	+ correct BUILD_CPPFLAGS substitution in ncurses/Makefile.in, to allow
++	  cross-compiling from a separate directory tree (report/patch by
++	  Dan Engel).
++	+ modify is_term_resized() to ensure that window sizes are nonzero,
++	  as documented in the manpage (report by Ian Collier).
++	+ modify CF_XOPEN_SOURCE configure macro to make Hurd port build
++	  (Debian #249214, report/patch by Jeff Bailey).
++	+ configure-script mods from xterm, e.g., updates to CF_ADD_CFLAGS
++	+ update config.guess, config.sub
++	> terminfo updates -TD
++	  + add mlterm
++	  + add xterm-xf86-v44
++	  + modify xterm-new aka xterm-xfree86 to accommodate luit, which
++	    relies on G1 being used via an ISO-2022 escape sequence (report by
++	    Juliusz Chroboczek)
++	  + add 'hurd' entry
++
++20040619
++	+ reconsidered winsnstr(), decided after comparing other
++	  implementations that wrapping is an X/Open documentation error.
++	+ modify test/inserts.c to test all flavors of insstr().
++
++20040605
++	+ add setlocale() calls to a few test programs which may require it:
++	  demo_forms.c, filter.c, ins_wide.c, inserts.c
++	+ correct a few misspelled function names in ncurses-intro.html (report
++	  by Tony Li).
++	+ correct internal name of key_defined() manpage, which conflicted with
++	  define_key().
++
++20040529
++	+ correct size of internal pad used for holding wide-character
++	  field_buffer() results.
++	+ modify data_ahead() to work with wide-characters.
++
++20040522
++	+ improve description of terminfo if-then-else expressions (suggested
++	  by Arne Thomassen).
++	+ improve test/ncurses.c 'd' test, allow it to use external file for
++	  initial palette (added xterm-16color.dat and linux-color.dat), and
++	  reset colors to the initial palette when starting/ending the test.
++	+ change limit-check in init_color() to allow r/g/b component to
++	  reach 1000 (cf: 20020928).
++
++20040516
++	+ modify form library to use cchar_t's rather than char's in the
++	  wide-character configuration for storing data for field buffers.
++	+ correct logic of win_wchnstr(), which did not work for more than
++	  one cell.
++
++20040508
++	+ replace memset/memcpy usage in form library with for-loops to
++	  simplify changing the datatype of FIELD.buf, part of wide-character
++	  changes.
++	+ fix some inconsistent use of #if/#ifdef (report by Alain Guibert).
++
++20040501
++	+ modify menu library to account for actual number of columns used by
++	  multibyte character strings, in the wide-character configuration
++	  (adapted from patch by Philipp Tomsich).
++	+ add "-x" option to infocmp like tic's "-x", for use in "-F"
++	  comparisons.  This modifies infocmp to only report extended
++	  capabilities if the -x option is given, making this more consistent
++	  with tic.  Some scripts may break, since infocmp previous gave this
++	  information without an option.
++	+ modify termcap-parsing to retain 2-character aliases at the beginning
++	  of an entry if the "-x" option is used in tic.
++
++20040424
++	+ minor compiler-warning and test-program fixes.
++
++20040417
++	+ modify tic's missing-sgr warning to apply to terminfo only.
++	+ free some memory leaks in tic.
++	+ remove check in post_menu() that prevented menus from extending
++	  beyond the screen (request by Max J. Werner).
++	+ remove check in newwin() that prevents allocating windows
++	  that extend beyond the screen.  Solaris curses does this.
++	+ add ifdef in test/color_set.c to allow it to compile with older
++	  curses.
++	+ add napms() calls to test/dots.c to make it not be a CPU hog.
++
++20040403
++	+ modify unctrl() to return null if its parameter does not correspond
++	  to an unsigned char.
++	+ add some limit-checks to guard isprint(), etc., from being used on
++	  values that do not fit into an unsigned char (report by Sami Farin).
++
++20040328
++	+ fix a typo in the _nc_get_locale() change.
++
++20040327
++	+ modify _nc_get_locale() to use setlocale() to query the program's
++	  current locale rather than using getenv().  This fixes a case in tin
++	  which relies on legacy treatment of 8-bit characters when the locale
++	  is not initialized (reported by Urs Jansen).
++	+ add sgr string to screen's and rxvt's terminfo entries -TD.
++	+ add a check in tic for terminfo entries having an sgr0 but no sgr
++	  string.  This confuses Tru64 and HPUX curses when combined with
++	  color, e.g., making them leave line-drawing characters in odd places.
++	+ correct casts used in ABSENT_BOOLEAN, CANCELLED_BOOLEAN, matches the
++	  original definitions used in Debian package to fix PowerPC bug before
++	  20030802 (Debian #237629).
++
++20040320
++	+ modify PutAttrChar() and PUTC() macro to improve use of
++	  A_ALTCHARSET attribute to prevent line-drawing characters from
++	  being lost in situations where the locale would otherwise treat the
++	  raw data as nonprintable (Debian #227879).
++
++20040313
++	+ fix a redefinition of CTRL() macro in test/view.c for AIX 5.2 (report
++	  by Jim Idle).
++	+ remove ".PP" after ".SH NAME" in a few manpages; this confuses
++	  some apropos script (Debian #237831).
++
++20040306
++	+ modify ncurses.c 'r' test so editing commands, like inserted text,
++	  set the field background, and the state of insert/overlay editing
++	  mode is shown in that test.
++	+ change syntax of dummy targets in Ada95 makefiles to work with pmake.
++	+ correct logic in test/ncurses.c 'b' for noncolor terminals which
++	  did not recognize a quit-command (cf: 20030419).
++
++20040228
++	+ modify _nc_insert_ch() to allow for its input to be part of a
++	  multibyte string.
++	+ split out lib_insnstr.c, to prepare to rewrite it.  X/Open states
++	  that this function performs wrapping, unlike all of the other
++	  insert-functions.  Currently it does not wrap.
++	+ check for nl_langinfo(CODESET), use it if available (report by
++	  Stanislav Ievlev).
++	+ split-out CF_BUILD_CC macro, actually did this for lynx first.
++	+ fixes for configure script CF_WITH_DBMALLOC and CF_WITH_DMALLOC,
++	  which happened to work with bash, but not with Bourne shell (report
++	  by Marco d'Itri via tin-dev).
++
++20040221
++	+ some changes to adapt the form library to wide characters, incomplete
++	  (request by Mike Aubury).
++	+ add symbol to curses.h which can be used to suppress include of
++	  stdbool.h, e.g.,
++	  	#define NCURSES_ENABLE_STDBOOL_H 0
++		#include <curses.h>
++	  (discussion on XFree86 mailing list).
++
++20040214
++	+ modify configure --with-termlib option to accept a value which sets
++	  the name of the terminfo library.  This would allow a packager to
++	  build libtinfow.so renamed to coincide with libtinfo.so (discussion
++	  with Stanislav Ievlev).
++	+ improve documentation of --with-install-prefix, --prefix and
++	  $(DESTDIR) in INSTALL (prompted by discussion with Paul Lew).
++	+ add configure check if the compiler can use -c -o options to rename
++	  its output file, use that to omit the 'cd' command which was used to
++	  ensure object files are created in a separate staging directory
++	  (prompted by comments by Johnny Wezel, Martin Mokrejs).
++
+ 20040208 5.4 release for upload to ftp.gnu.org
+ 	+ update TO-DO.
+ 
+@@ -6014,7 +6520,8 @@
+ 	+ added has_key()
+ 	+ added 't' to ncurses.c test.
+ 	+ moved delay_output() to lib_tputs.c
+-	+ removed tparam().
++	+ removed tparam() (was added in 1.9.9, but conflicts with emacs and
++	  is not part of X/Open Curses).
+ 	+ misc cursor & optimization fixes.
+ 
+ 960504	- snapshot
+Index: README
+Prereq:  1.21 
+--- ncurses-5.4-20040208/README	2003-02-08 19:36:39.000000000 +0000
++++ ncurses-5.4-20050319/README	2004-08-07 23:42:43.000000000 +0000
+@@ -1,4 +1,4 @@
+--- $Id: README,v 1.21 2003/02/08 19:36:39 tom Exp $
++-- $Id: README,v 1.22 2004/08/07 23:42:43 tom Exp $
+ -------------------------------------------------------------------------------
+ 		README file for the ncurses package
+ 
+@@ -64,7 +64,7 @@
+ In the `Ada95' directory, you'll find code and documentation for an
+ Ada95 binding of the curses API, to be used with the GNAT compiler.
+ This binding is built by a normal top-level `make' if configure detects
+-an usable version of GNAT (3.10 or above). It is not installed automatically.
++an usable version of GNAT (3.11 or above). It is not installed automatically.
+ See the Ada95 directory for more build and installation instructions and
+ for documentation of the binding.
+ 
+Index: TO-DO
+Prereq:  1.43 
+--- ncurses-5.4-20040208/TO-DO	2004-02-08 21:09:00.000000000 +0000
++++ ncurses-5.4-20050319/TO-DO	2004-03-07 02:04:20.000000000 +0000
+@@ -1,4 +1,4 @@
+--- $Id: TO-DO,v 1.43 2004/02/08 21:09:00 tom Exp $
++-- $Id: TO-DO,v 1.44 2004/03/07 02:04:20 tom Exp $
+ 
+ SHORT-TERM TO-DO ITEMS:
+ 
+@@ -6,9 +6,6 @@
+ 
+ * The form/menu libraries do not use wide-character features.
+ 
+-* Some users would like to build a single version of libtinfo which can be
+-  used from either libncursesw or libncurses.
+-
+ * libtool does not work with GNAT.
+ 
+ * The screen optimization has been tested only in an ad hoc manner.  We should
+Index: aclocal.m4
+Prereq:  1.333 
+--- ncurses-5.4-20040208/aclocal.m4	2004-01-30 20:59:56.000000000 +0000
++++ ncurses-5.4-20050319/aclocal.m4	2005-02-05 11:58:22.000000000 +0000
+@@ -1,5 +1,5 @@
+ dnl***************************************************************************
+-dnl Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++dnl Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
+ dnl                                                                          *
+ dnl Permission is hereby granted, free of charge, to any person obtaining a  *
+ dnl copy of this software and associated documentation files (the            *
+@@ -26,15 +26,38 @@
+ dnl authorization.                                                           *
+ dnl***************************************************************************
+ dnl
+-dnl Author: Thomas E. Dickey 1995-2003
++dnl Author: Thomas E. Dickey 1995-on
+ dnl
+-dnl $Id: aclocal.m4,v 1.333 2004/01/30 20:59:56 tom Exp $
++dnl $Id: aclocal.m4,v 1.352 2005/02/05 11:58:22 tom Exp $
+ dnl Macros used in NCURSES auto-configuration script.
+ dnl
+ dnl See http://invisible-island.net/autoconf/ for additional information.
+ dnl
+ dnl ---------------------------------------------------------------------------
+ dnl ---------------------------------------------------------------------------
++dnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
++dnl -------------------
++dnl Inserted as requested by gettext 0.10.40
++dnl File from /usr/share/aclocal
++dnl codeset.m4
++dnl ====================
++dnl serial AM1
++dnl
++dnl From Bruno Haible.
++AC_DEFUN([AM_LANGINFO_CODESET],
++[
++  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
++    [AC_TRY_LINK([#include <langinfo.h>],
++      [char* cs = nl_langinfo(CODESET);],
++      am_cv_langinfo_codeset=yes,
++      am_cv_langinfo_codeset=no)
++    ])
++  if test $am_cv_langinfo_codeset = yes; then
++    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
++      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
++  fi
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_ADA_INCLUDE_DIRS version: 4 updated: 2002/12/01 00:12:15
+ dnl -------------------
+ dnl Construct the list of include-options for the C programs in the Ada95
+@@ -59,18 +82,44 @@
+ AC_SUBST(ACPPFLAGS)
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_ADD_CFLAGS version: 5 updated: 2002/12/01 00:12:15
++dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30
+ dnl -------------
+ dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
+ dnl The second parameter if given makes this macro verbose.
++dnl
++dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
++dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
++dnl confused by the quotes (which require backslashes to keep them usable).
+ AC_DEFUN([CF_ADD_CFLAGS],
+ [
++cf_fix_cppflags=no
+ cf_new_cflags=
+ cf_new_cppflags=
++cf_new_extra_cppflags=
++
+ for cf_add_cflags in $1
+ do
++case $cf_fix_cppflags in
++no)
+ 	case $cf_add_cflags in #(vi
+ 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
++		case $cf_add_cflags in
++		-D*)
++			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
++
++			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++			&& test -z "${cf_tst_cflags}" \
++			&& cf_fix_cppflags=yes
++
++			if test $cf_fix_cppflags = yes ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			elif test "${cf_tst_cflags}" = "\"'" ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			fi
++			;;
++		esac
+ 		case "$CPPFLAGS" in
+ 		*$cf_add_cflags) #(vi
+ 			;;
+@@ -83,6 +132,17 @@
+ 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ 		;;
+ 	esac
++	;;
++yes)
++	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++
++	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
++
++	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++	&& test -z "${cf_tst_cflags}" \
++	&& cf_fix_cppflags=no
++	;;
++esac
+ done
+ 
+ if test -n "$cf_new_cflags" ; then
+@@ -95,6 +155,13 @@
+ 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
+ fi
+ 
++if test -n "$cf_new_extra_cppflags" ; then
++	ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
++	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
++fi
++
++AC_SUBST(EXTRA_CPPFLAGS)
++
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+ dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
+@@ -282,6 +349,77 @@
+ fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
++dnl CF_BUILD_CC version: 4 updated: 2004/11/27 16:03:59
++dnl -----------
++dnl If we're cross-compiling, allow the user to override the tools and their
++dnl options.  The configure script is oriented toward identifying the host
++dnl compiler, etc., but we need a build compiler to generate parts of the
++dnl source.
++dnl
++dnl $1 = default for $CPPFLAGS
++dnl $2 = default for $LIBS
++AC_DEFUN([CF_BUILD_CC],[
++AC_REQUIRE([CF_PROG_EXT])
++if test "$cross_compiling" = yes ; then
++	# defaults that we might want to override
++	: ${BUILD_CC:='$(CC)'}
++	: ${BUILD_CPP:='$(CC) -E'}
++	: ${BUILD_CFLAGS:=''}
++	: ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
++	: ${BUILD_LDFLAGS:=''}
++	: ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
++	: ${BUILD_EXEEXT:='$x'}
++	: ${BUILD_OBJEXT:='o'}
++	AC_ARG_WITH(build-cc,
++		[  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
++		[BUILD_CC="$withval"],
++		[AC_CHECK_PROGS(BUILD_CC, $CC gcc cc)])
++	AC_ARG_WITH(build-cpp,
++		[  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
++		[BUILD_CPP="$withval"],
++		[BUILD_CPP='$(CC) -E'])
++	AC_ARG_WITH(build-cflags,
++		[  --with-build-cflags=XXX the build C compiler-flags],
++		[BUILD_CFLAGS="$withval"])
++	AC_ARG_WITH(build-cppflags,
++		[  --with-build-cppflags=XXX the build C preprocessor-flags],
++		[BUILD_CPPFLAGS="$withval"])
++	AC_ARG_WITH(build-ldflags,
++		[  --with-build-ldflags=XXX the build linker-flags],
++		[BUILD_LDFLAGS="$withval"])
++	AC_ARG_WITH(build-libs,
++		[  --with-build-libs=XXX   the build libraries],
++		[BUILD_LIBS="$withval"])
++	# this assumes we're on Unix.
++	BUILD_EXEEXT=
++	BUILD_OBJEXT=o
++
++	if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '$(CC)' ) ; then
++		AC_MSG_ERROR([Cross-build requires two compilers.
++Use --with-build-cc to specify the native compiler.])
++	fi
++
++else
++	: ${BUILD_CC:='$(CC)'}
++	: ${BUILD_CPP:='$(CPP)'}
++	: ${BUILD_CFLAGS:='$(CFLAGS)'}
++	: ${BUILD_CPPFLAGS:='$(CPPFLAGS)'}
++	: ${BUILD_LDFLAGS:='$(LDFLAGS)'}
++	: ${BUILD_LIBS:='$(LIBS)'}
++	: ${BUILD_EXEEXT:='$x'}
++	: ${BUILD_OBJEXT:='o'}
++fi
++
++AC_SUBST(BUILD_CC)
++AC_SUBST(BUILD_CPP)
++AC_SUBST(BUILD_CFLAGS)
++AC_SUBST(BUILD_CPPFLAGS)
++AC_SUBST(BUILD_LDFLAGS)
++AC_SUBST(BUILD_LIBS)
++AC_SUBST(BUILD_EXEEXT)
++AC_SUBST(BUILD_OBJEXT)
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_CFG_DEFAULTS version: 6 updated: 2003/07/12 15:15:19
+ dnl ---------------
+ dnl Determine the default configuration into which we'll install ncurses.  This
+@@ -359,7 +497,7 @@
+ test "$cf_cv_cgetent" = yes && AC_DEFINE(HAVE_BSD_CGETENT)
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_CHECK_CACHE version: 9 updated: 2004/01/30 15:59:13
++dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
+ dnl --------------
+ dnl Check if we're accidentally using a cache from a different machine.
+ dnl Derive the system name, as a check for reusing the autoconf cache.
+@@ -373,7 +511,7 @@
+ dnl autoconf 2.5x broke compatibility with autoconf 2.13
+ AC_DEFUN([CF_CHECK_CACHE],
+ [
+-if test -f $srcdir/config.guess ; then
++if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
+ 	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
+ 	system_name="$host_os"
+ else
+@@ -627,6 +765,41 @@
+ CXXFLAGS="$cf_save_CXXFLAGS"
+ ])
+ dnl ---------------------------------------------------------------------------
++dnl CF_FUNC_DLSYM version: 1 updated: 2004/06/16 20:52:45
++dnl -------------
++dnl Test for dlsym() and related functions, as well as libdl.
++dnl
++dnl Sets
++dnl	$cf_have_dlsym
++dnl	$cf_have_libdl
++AC_DEFUN([CF_FUNC_DLSYM],[
++cf_have_dlsym=no
++AC_CHECK_FUNC(dlsym,cf_have_dlsym=yes,[
++
++cf_have_libdl=no
++AC_CHECK_LIB(dl,dlsym,[
++	cf_have_dlsym=yes
++	cf_have_libdl=yes])])
++
++if test "$cf_have_dlsym" = yes ; then
++	test "$cf_have_libdl" = yes && LIBS="-ldl $LIBS"
++
++	AC_MSG_CHECKING(whether able to link to dl*() functions)
++	AC_TRY_LINK([#include <dlfcn.h>],[
++		void *obj;
++		if ((obj = dlopen("filename", 0)) != 0) {
++			if (dlsym(obj, "symbolname") == 0) {
++			dlclose(obj);
++			}
++		}],[
++		AC_DEFINE(HAVE_LIBDL)],[
++		AC_MSG_ERROR(Cannot link test program for libdl)])
++	AC_MSG_RESULT(ok)
++else
++	AC_MSG_ERROR(Cannot find dlsym function)
++fi
++])
++dnl ---------------------------------------------------------------------------
+ dnl CF_FUNC_MEMMOVE version: 5 updated: 2000/08/12 23:18:52
+ dnl ---------------
+ dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
+@@ -850,7 +1023,7 @@
+ fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_GCC_WARNINGS version: 15 updated: 2003/07/05 18:42:30
++dnl CF_GCC_WARNINGS version: 18 updated: 2004/12/03 20:51:07
+ dnl ---------------
+ dnl Check if the compiler supports useful warning options.  There's a few that
+ dnl we don't use, simply because they're too noisy:
+@@ -862,10 +1035,36 @@
+ dnl		is enabled for ncurses using "--enable-const".
+ dnl	-pedantic
+ dnl
++dnl Parameter:
++dnl	$1 is an optional list of gcc warning flags that a particular
++dnl		application might want to use, e.g., "no-unused" for
++dnl		-Wno-unused
++dnl Special:
++dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
++dnl
+ AC_DEFUN([CF_GCC_WARNINGS],
+ [
++AC_REQUIRE([CF_INTEL_COMPILER])
+ AC_REQUIRE([CF_GCC_VERSION])
+-if test "$GCC" = yes
++if test "$INTEL_COMPILER" = yes
++then
++# The "-wdXXX" options suppress warnings:
++# remark #1419: external declaration in primary source file
++# remark #193: zero used for undefined preprocessing identifier
++# remark #593: variable "curs_sb_left_arrow" was set but never used
++# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
++# remark #869: parameter "tw" was never referenced
++# remark #981: operands are evaluated in unspecified order
++# warning #269: invalid format string conversion
++	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall \
++ -wd1419 \
++ -wd193 \
++ -wd279 \
++ -wd593 \
++ -wd810 \
++ -wd869 \
++ -wd981"
++elif test "$GCC" = yes
+ then
+ 	cat > conftest.$ac_ext <<EOF
+ #line __oline__ "configure"
+@@ -887,7 +1086,7 @@
+ 		Wpointer-arith \
+ 		Wshadow \
+ 		Wstrict-prototypes \
+-		Wundef $cf_warn_CONST
++		Wundef $cf_warn_CONST $1
+ 	do
+ 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+ 		if AC_TRY_EVAL(ac_compile); then
+@@ -913,10 +1112,43 @@
+ AC_SUBST(EXTRA_CFLAGS)
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_GNAT_TRY_RUN version: 2 updated: 1998/07/19 00:25:18
++dnl CF_GNAT_TRY_LINK version: 1 updated: 2004/08/21 19:02:08
++dnl ----------------
++dnl Verify that a test program compiles/links with GNAT.
++dnl $cf_ada_make is set to the program that compiles/links
++dnl $ADAFLAGS may be set to the GNAT flags.
++dnl
++dnl $1 is the text of the spec
++dnl $2 is the text of the body
++dnl $3 is the shell command to execute if successful
++dnl $4 is the shell command to execute if not successful
++AC_DEFUN([CF_GNAT_TRY_LINK],
++[
++rm -f conftest*
++cat >>conftest.ads <<CF_EOF
++$1
++CF_EOF
++cat >>conftest.adb <<CF_EOF
++$2
++CF_EOF
++if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
++ifelse($3,,      :,[      $3])
++ifelse($4,,,[else
++   $4])
++fi
++rm -f conftest*
++])dnl
++dnl ---------------------------------------------------------------------------
++dnl CF_GNAT_TRY_RUN version: 3 updated: 2004/08/21 19:02:08
+ dnl ---------------
+ dnl Verify that a test program compiles and runs with GNAT
+ dnl $cf_ada_make is set to the program that compiles/links
++dnl $ADAFLAGS may be set to the GNAT flags.
++dnl
++dnl $1 is the text of the spec
++dnl $2 is the text of the body
++dnl $3 is the shell command to execute if successful
++dnl $4 is the shell command to execute if not successful
+ AC_DEFUN([CF_GNAT_TRY_RUN],
+ [
+ rm -f conftest*
+@@ -926,7 +1158,7 @@
+ cat >>conftest.adb <<CF_EOF
+ $2
+ CF_EOF
+-if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then
++if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
+    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
+ ifelse($3,,      :,[      $3])
+ ifelse($4,,,[   else
+@@ -967,7 +1199,7 @@
+ esac
+ ])
+ dnl ---------------------------------------------------------------------------
+-dnl CF_GNU_SOURCE version: 3 updated: 2000/10/29 23:30:53
++dnl CF_GNU_SOURCE version: 4 updated: 2004/12/03 20:43:00
+ dnl -------------
+ dnl Check if we must define _GNU_SOURCE to get a reasonable value for
+ dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
+@@ -977,6 +1209,9 @@
+ dnl Well, yes we could work around it...
+ AC_DEFUN([CF_GNU_SOURCE],
+ [
++AC_REQUIRE([CF_INTEL_COMPILER])
++
++if test "$INTEL_COMPILER" = no ; then
+ AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
+ AC_TRY_COMPILE([#include <sys/types.h>],[
+ #ifndef _XOPEN_SOURCE
+@@ -995,6 +1230,7 @@
+ 	])
+ ])
+ test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
++fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+ dnl CF_GPP_LIBRARY version: 8 updated: 2003/02/02 01:41:46
+@@ -1087,6 +1323,40 @@
+ AC_SUBST(CPPFLAGS)
+ ])dnl
+ dnl ---------------------------------------------------------------------------
++dnl CF_INTEL_COMPILER version: 1 updated: 2004/12/03 20:27:48
++dnl -----------------
++dnl Check if the given compiler is really the Intel compiler for Linux.
++dnl It tries to imitate gcc, but does not return an error when it finds a
++dnl mismatch between prototypes, e.g., as exercised by CF_MISSING_CHECK.
++dnl
++dnl This macro should be run "soon" after AC_PROG_CC, to ensure that it is
++dnl not mistaken for gcc.
++AC_DEFUN([CF_INTEL_COMPILER],[
++AC_REQUIRE([AC_PROG_CC])
++
++INTEL_COMPILER=no
++
++if test "$GCC" = yes ; then
++	case $host_os in
++	linux*|gnu*)
++		AC_MSG_CHECKING(if this is really Intel compiler)
++		cf_save_CFLAGS="$CFLAGS"
++		CFLAGS="$CFLAGS -no-gcc"
++		AC_TRY_COMPILE([],[
++#ifdef __INTEL_COMPILER
++#else
++make an error
++#endif
++],[INTEL_COMPILER=yes
++cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
++],[])
++		CFLAGS="$cf_save_CFLAGS"
++		AC_MSG_RESULT($INTEL_COMPILER)
++		;;
++	esac
++fi
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_ISASCII version: 3 updated: 2000/08/12 23:18:52
+ dnl ----------
+ dnl Check if we have either a function or macro for 'isascii()'.
+@@ -1138,7 +1408,7 @@
+ 	AC_SUBST(LIB_PREFIX)
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_LIB_RULES version: 30 updated: 2004/01/10 15:50:50
++dnl CF_LIB_RULES version: 35 updated: 2004/09/18 17:54:16
+ dnl ------------
+ dnl Append definitions and rules for the given models to the subdirectory
+ dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
+@@ -1170,13 +1440,33 @@
+ 				case "$cf_cv_shlib_version" in #(vi
+ 				rel) #(vi
+ 					case "$cf_cv_system_name" in #(vi
+-					darwin*) cf_suffix='.$(REL_VERSION)'"$cf_suffix" ;; #(vi
++					darwin*)
++					case .${LIB_SUFFIX} in
++					.w*)
++						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
++						cf_suffix=w'.$(REL_VERSION)'"$cf_suffix"
++						;;
++					*)
++						cf_suffix='.$(REL_VERSION)'"$cf_suffix"
++						;;
++					esac
++					;; #(vi
+ 					*) cf_suffix="$cf_suffix"'.$(REL_VERSION)' ;;
+ 					esac
+ 					;;
+ 				abi)
+ 					case "$cf_cv_system_name" in #(vi
+-					darwin*) cf_suffix='.$(ABI_VERSION)'"$cf_suffix" ;; #(vi
++					darwin*)
++					case .${LIB_SUFFIX} in
++					.w*)
++						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
++						cf_suffix=w'.$(ABI_VERSION)'"$cf_suffix"
++						;;
++					*)
++						cf_suffix='.$(ABI_VERSION)'"$cf_suffix"
++						;;
++					esac
++					;; #(vi
+ 					*) cf_suffix="$cf_suffix"'.$(ABI_VERSION)' ;;
+ 					esac
+ 					;;
+@@ -1199,7 +1489,7 @@
+ 			cf_subsets="$LIB_SUBSETS"
+ 			cf_termlib=`echo "$cf_subsets" |sed -e 's/ .*$//'`
+ 			if test "$cf_termlib" != "$cf_subsets" ; then
+-				cf_item=`echo $LIBS_TO_MAKE |sed -e s%$LIB_NAME%$TINFO_NAME%g`
++				cf_item=`echo $LIBS_TO_MAKE |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
+ 				LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
+ 			fi
+ 		else
+@@ -1226,6 +1516,22 @@
+ 			CF_LIB_SUFFIX($cf_item,cf_suffix)
+ 			CF_OBJ_SUBDIR($cf_item,cf_subdir)
+ 
++			# Test for case where we build libtinfo with a different name.
++			cf_libname=$cf_dir
++			if test $cf_dir = ncurses ; then
++				case $cf_subset in
++				*base*)
++					;;
++				termlib*)
++					cf_libname=$TINFO_LIB_SUFFIX
++					if test -n "${DFT_ARG_SUFFIX}" ; then
++						# undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
++						cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
++					fi
++				;;
++				esac
++			fi
++
+ 			# These dependencies really are for development, not
+ 			# builds, but they are useful in porting, too.
+ 			cf_depend="../include/ncurses_cfg.h"
+@@ -1241,8 +1547,22 @@
+ 				cf_depend="$cf_depend $cf_reldir/curses.priv.h"
+ 			fi
+ 
++ 			cf_dir_suffix=
++ 			old_cf_suffix="$cf_suffix"
++ 			if test "$cf_cv_shlib_version_infix" = yes ; then
++			if test -n "$LIB_SUFFIX" ; then
++				case $LIB_SUFFIX in
++				w*)
++					cf_libname=`echo $cf_libname | sed 's/w$//'`
++					cf_suffix=`echo $cf_suffix | sed 's/^w//'`
++					cf_dir_suffix=w
++					;;
++				esac
++			fi
++ 			fi
++
+ 			$AWK -f $srcdir/mk-1st.awk \
+-				name=$cf_dir \
++				name=${cf_libname}${cf_dir_suffix} \
+ 				traces=$LIB_TRACING \
+ 				MODEL=$CF_ITEM \
+ 				model=$cf_subdir \
+@@ -1258,6 +1578,9 @@
+ 				depend="$cf_depend" \
+ 				host="$host" \
+ 				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
++
++			cf_suffix="$old_cf_suffix"
++
+ 			for cf_subdir2 in $cf_subdirs lib
+ 			do
+ 				test $cf_subdir = $cf_subdir2 && break
+@@ -1271,6 +1594,8 @@
+ 				subset=$cf_subset \
+ 				srcdir=$srcdir \
+ 				echo=$WITH_ECHO \
++				crenames=$cf_cv_prog_CC_c_o \
++				cxxrenames=$cf_cv_prog_CXX_c_o \
+ 				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
+ 			cf_subdirs="$cf_subdirs $cf_subdir"
+ 			done
+@@ -2346,6 +2671,14 @@
+ fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
++dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
++dnl ----------
++dnl Write a debug message to config.log, along with the line number in the
++dnl configure script.
++AC_DEFUN([CF_MSG_LOG],[
++echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
+ dnl ----------------
+ dnl Check if the given variable is a number.  If not, report an error.
+@@ -2429,6 +2762,65 @@
+ esac
+ ])dnl
+ dnl ---------------------------------------------------------------------------
++dnl CF_POSIX_C_SOURCE version: 3 updated: 2005/02/04 06:56:22
++dnl -----------------
++dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
++dnl
++dnl	POSIX.1-1990				_POSIX_SOURCE
++dnl	POSIX.1-1990 and			_POSIX_SOURCE and
++dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
++dnl		Bindings Option
++dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
++dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
++dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
++dnl
++dnl Parameters:
++dnl	$1 is the nominal value for _POSIX_C_SOURCE
++AC_DEFUN([CF_POSIX_C_SOURCE],
++[
++cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
++AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
++	CF_MSG_LOG(if the symbol is already defined go no further)
++	AC_TRY_COMPILE([#include <sys/types.h>],[
++#ifndef _POSIX_C_SOURCE
++make an error
++#endif],
++	[cf_cv_posix_c_source=no],
++	[cf_want_posix_source=no
++	 case .$cf_POSIX_C_SOURCE in
++	 .[[12]]??*)
++		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
++		;;
++	 .2)
++		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
++		cf_want_posix_source=yes
++		;;
++	 .*)
++		cf_want_posix_source=yes
++		;;
++	 esac
++	 if test "$cf_want_posix_source" = yes ; then
++		AC_TRY_COMPILE([#include <sys/types.h>],[
++#ifdef _POSIX_SOURCE
++make an error
++#endif],[],
++		cf_cv_posix_c_source="$cf_cv_posix_c_source -U_POSIX_SOURCE -D_POSIX_SOURCE")
++	 fi
++	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
++	 cf_save="$CPPFLAGS"
++	 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
++	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
++	 AC_TRY_COMPILE([#include <sys/types.h>],[
++#ifndef _POSIX_C_SOURCE
++make an error
++#endif],,
++	[cf_cv_posix_c_source=no])
++	CPPFLAGS="$cf_save"
++	])
++])
++test "$cf_cv_posix_c_source" != no && CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_PREDEFINE version: 1 updated: 2003/07/26 17:53:56
+ dnl ------------
+ dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
+@@ -2462,6 +2854,45 @@
+ fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
++dnl CF_PROG_CC_C_O version: 1 updated: 2004/02/14 15:00:43
++dnl --------------
++dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
++dnl the output file can be renamed, and allows for a shell variable that can
++dnl be used later.  The parameter is either CC or CXX.  The result is the
++dnl cache variable:
++dnl	$cf_cv_prog_CC_c_o
++dnl	$cf_cv_prog_CXX_c_o
++AC_DEFUN([CF_PROG_CC_C_O],
++[AC_REQUIRE([AC_PROG_CC])dnl
++AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
++AC_CACHE_VAL(cf_cv_prog_$1_c_o,
++[
++cat > conftest.$ac_ext <<CF_EOF
++#include <stdio.h>
++int main()
++{
++	return 0;
++}
++CF_EOF
++# We do the test twice because some compilers refuse to overwrite an
++# existing .o file with -o, though they will create one.
++ac_try='[$]$1 -c conftest.$ac_ext -o conftest2.$ac_objext >&AC_FD_CC'
++if AC_TRY_EVAL(ac_try) &&
++  test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
++then
++  eval cf_cv_prog_$1_c_o=yes
++else
++  eval cf_cv_prog_$1_c_o=no
++fi
++rm -f conftest*
++])dnl
++if test $cf_cv_prog_$1_c_o = yes; then
++  AC_MSG_RESULT([yes])
++else
++  AC_MSG_RESULT([no])
++fi
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
+ dnl -----------
+ dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
+@@ -2559,7 +2990,7 @@
+ esac
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_SHARED_OPTS version: 30 updated: 2003/12/27 20:48:07
++dnl CF_SHARED_OPTS version: 31 updated: 2005/01/01 16:39:44
+ dnl --------------
+ dnl Attempt to determine the appropriate CC/LD options for creating a shared
+ dnl library.
+@@ -2661,8 +3092,13 @@
+ 		;;
+ 	irix*)
+ 		if test "$cf_cv_ld_rpath" = yes ; then
+-			cf_ld_rpath_opt="-Wl,-rpath,"
+-			EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
++			if test "$GCC" = yes; then
++				cf_ld_rpath_opt="-Wl,-rpath,"
++				EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
++			else
++				cf_ld_rpath_opt="-rpath "
++				EXTRA_LDFLAGS="-rpath \$(libdir) $EXTRA_LDFLAGS"
++			fi
+ 		fi
+ 		# tested with IRIX 5.2 and 'cc'.
+ 		if test "$GCC" != yes; then
+@@ -2904,7 +3340,7 @@
+ fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_SRC_MODULES version: 15 updated: 2004/01/10 16:05:16
++dnl CF_SRC_MODULES version: 17 updated: 2005/01/22 15:26:37
+ dnl --------------
+ dnl For each parameter, test if the source-directory exists, and if it contains
+ dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
+@@ -2924,9 +3360,6 @@
+ 	TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
+ fi
+ 
+-# dependencies and linker-arguments for utility-programs
+-test "$with_termlib" != yes && PROG_ARGS="$TEST_ARGS"
+-
+ cf_cv_src_modules=
+ for cf_dir in $1
+ do
+@@ -2970,9 +3403,6 @@
+ AC_SUBST(TEST_DEPS)
+ AC_SUBST(TEST_ARGS)
+ 
+-PROG_ARGS="-L${LIB_DIR} $PROG_ARGS"
+-AC_SUBST(PROG_ARGS)
+-
+ SRC_SUBDIRS="man include"
+ for cf_dir in $cf_cv_src_modules
+ do
+@@ -3356,33 +3786,37 @@
+ ])
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_WITH_DBMALLOC version: 2 updated: 2002/12/29 21:11:45
++dnl CF_WITH_DBMALLOC version: 4 updated: 2004/02/28 05:49:27
+ dnl ----------------
+-dnl Configure-option for dbmalloc
++dnl Configure-option for dbmalloc.  The optional parameter is used to override
++dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
+ AC_DEFUN([CF_WITH_DBMALLOC],[
+ AC_MSG_CHECKING(if you want to link with dbmalloc for testing)
+ AC_ARG_WITH(dbmalloc,
+-	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
++	[  --with-dbmalloc         use Conor Cahill's dbmalloc library],
+ 	[with_dbmalloc=$withval],
+ 	[with_dbmalloc=no])
+ AC_MSG_RESULT($with_dbmalloc)
+-if test $with_dbmalloc = yes ; then
+-	AC_CHECK_LIB(dbmalloc,debug_malloc)
++if test "$with_dbmalloc" = yes ; then
++	AC_CHECK_HEADER(dbmalloc.h,
++		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))])
+ fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_WITH_DMALLOC version: 2 updated: 2002/12/29 21:11:45
++dnl CF_WITH_DMALLOC version: 4 updated: 2004/02/28 05:49:27
+ dnl ---------------
+-dnl Configure-option for dmalloc
++dnl Configure-option for dmalloc.  The optional parameter is used to override
++dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
+ AC_DEFUN([CF_WITH_DMALLOC],[
+ AC_MSG_CHECKING(if you want to link with dmalloc for testing)
+ AC_ARG_WITH(dmalloc,
+-	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
++	[  --with-dmalloc          use Gray Watson's dmalloc library],
+ 	[with_dmalloc=$withval],
+ 	[with_dmalloc=no])
+ AC_MSG_RESULT($with_dmalloc)
+-if test $with_dmalloc = yes ; then
+-	AC_CHECK_LIB(dmalloc,dmalloc_debug)
++if test "$with_dmalloc" = yes ; then
++	AC_CHECK_HEADER(dmalloc.h,
++		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))])
+ fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+@@ -3631,22 +4065,35 @@
+ fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_XOPEN_SOURCE version: 11 updated: 2004/01/26 20:58:41
++dnl CF_XOPEN_SOURCE version: 16 updated: 2005/02/04 06:56:22
+ dnl ---------------
+ dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
+ dnl or adapt to the vendor's definitions to get equivalent functionality.
++dnl
++dnl Parameters:
++dnl	$1 is the nominal value for _XOPEN_SOURCE
++dnl	$2 is the nominal value for _POSIX_C_SOURCE
+ AC_DEFUN([CF_XOPEN_SOURCE],[
++
++cf_XOPEN_SOURCE=ifelse($1,,500,$1)
++cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
++
+ case $host_os in #(vi
+ freebsd*) #(vi
+-	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600"
++	# 5.x headers associate
++	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
++	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
++	cf_POSIX_C_SOURCE=200112L
++	cf_XOPEN_SOURCE=600
++	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+ 	;;
+ hpux*) #(vi
+ 	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
+ 	;;
+-irix6.*) #(vi
++irix[[56]].*) #(vi
+ 	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
+ 	;;
+-linux*) #(vi
++linux*|gnu*) #(vi
+ 	CF_GNU_SOURCE
+ 	;;
+ mirbsd*) #(vi
+@@ -3675,37 +4122,18 @@
+ #endif],
+ 	[cf_cv_xopen_source=no],
+ 	[cf_save="$CPPFLAGS"
+-	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
++	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+ 	 AC_TRY_COMPILE([#include <sys/types.h>],[
+ #ifdef _XOPEN_SOURCE
+ make an error
+ #endif],
+ 	[cf_cv_xopen_source=no],
+-	[cf_cv_xopen_source=yes])
+-	CPPFLAGS="$cf_save"
+-	])
+-])
+-test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
+-
+-	# FreeBSD 5.x headers demand this...
+-	AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_xopen_source,[
+-	AC_TRY_COMPILE([#include <sys/types.h>],[
+-#ifndef _POSIX_C_SOURCE
+-make an error
+-#endif],
+-	[cf_cv_xopen_source=no],
+-	[cf_save="$CPPFLAGS"
+-	 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
+-	 AC_TRY_COMPILE([#include <sys/types.h>],[
+-#ifdef _POSIX_C_SOURCE
+-make an error
+-#endif],
+-	[cf_cv_xopen_source=no],
+-	[cf_cv_xopen_source=yes])
++	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
+ 	CPPFLAGS="$cf_save"
+ 	])
+ ])
+-test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
++test "$cf_cv_xopen_source" != no && CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE -D_XOPEN_SOURCE=$cf_cv_xopen_source"
++	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
+ 	;;
+ esac
+ ])
+Index: c++/Makefile.in
+Prereq:  1.72 
+--- ncurses-5.4-20040208/c++/Makefile.in	2004-01-16 22:44:56.000000000 +0000
++++ ncurses-5.4-20050319/c++/Makefile.in	2005-01-29 19:28:54.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: Makefile.in,v 1.72 2004/01/16 22:44:56 tom Exp $
++# $Id: Makefile.in,v 1.75 2005/01/29 19:28:54 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2004,2005 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"), #
+@@ -67,7 +67,7 @@
+ RANLIB		= @LIB_PREP@
+ 
+ CXX		= @CXX@
+-CPP		= @CPP@
++CPP		= @CXXCPP@
+ CXXFLAGS	= @CXXFLAGS@
+ CXXLIBS		= @CXXLIBS@
+ 
+@@ -108,7 +108,7 @@
+ LINK_SHARED	= $(LINK_FLAGS)
+ 
+ LDFLAGS		= @TEST_ARGS@ @LDFLAGS@ \
+-	@LD_MODEL@ @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ $(CXXLIBS)
++	@LD_MODEL@ @LIBS@ @LOCAL_LDFLAGS@ $(CXXLIBS)
+ 
+ LDFLAGS_LIBTOOL	= $(LDFLAGS) $(CFLAGS_LIBTOOL)
+ LDFLAGS_NORMAL	= $(LDFLAGS) $(CFLAGS_NORMAL)
+@@ -130,6 +130,9 @@
+ 
+ depend :
+ 
++tags:
++	ctags *.[h] *.cc
++
+ # Build a conventional library for installing, since a shared library would
+ # pull in all of the ncurses libraries (panel, menu, form, ncurses) as direct
+ # dependencies.
+Index: c++/cursesm.cc
+Prereq:  1.18 
+--- ncurses-5.4-20040208/c++/cursesm.cc	2003-10-25 15:04:46.000000000 +0000
++++ ncurses-5.4-20050319/c++/cursesm.cc	2005-02-05 16:01:52.000000000 +0000
+@@ -1,6 +1,6 @@
+ // * this is for making emacs happy: -*-Mode: C++;-*-
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2005 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            *
+@@ -35,7 +35,7 @@
+ #include "cursesm.h"
+ #include "cursesapp.h"
+ 
+-MODULE_ID("$Id: cursesm.cc,v 1.18 2003/10/25 15:04:46 tom Exp $")
++MODULE_ID("$Id: cursesm.cc,v 1.19 2005/02/05 16:01:52 tom Exp $")
+ 
+ NCursesMenuItem::~NCursesMenuItem() {
+   if (item)
+@@ -45,7 +45,7 @@
+ bool
+ NCursesMenuItem::action() {
+   return FALSE;
+-};
++}
+ 
+ NCursesMenuCallbackItem::~NCursesMenuCallbackItem() {
+ }
+@@ -290,9 +290,9 @@
+   post();
+   show();
+   refresh();
+-  
++
+   while (!b_action && ((drvCmnd = virtualize((c=getKey()))) != CMD_QUIT)) {
+-    
++
+     switch((err=driver(drvCmnd))) {
+     case E_REQUEST_DENIED:
+       On_Request_Denied(c);
+Index: c++/cursesw.h
+Prereq:  1.30 
+--- ncurses-5.4-20040208/c++/cursesw.h	2004-02-08 00:11:54.000000000 +0000
++++ ncurses-5.4-20050319/c++/cursesw.h	2005-03-05 23:51:01.000000000 +0000
+@@ -1,6 +1,6 @@
+ // * This makes emacs happy -*-Mode: C++;-*-
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -30,7 +30,7 @@
+ #ifndef NCURSES_CURSESW_H_incl
+ #define NCURSES_CURSESW_H_incl 1
+ 
+-// $Id: cursesw.h,v 1.30 2004/02/08 00:11:54 tom Exp $
++// $Id: cursesw.h,v 1.31 2005/03/05 23:51:01 tom Exp $
+ 
+ #include <etip.h>
+ #include <stdarg.h>
+@@ -715,7 +715,7 @@
+   NCursesWindow(WINDOW* win, int cols);
+ 
+ protected:
+-  void           err_handler(const char *) const THROWS(NCursesException);
++  virtual void   err_handler(const char *) const THROWS(NCursesException);
+   // Signal an error with the given message text.
+ 
+   static long count;        // count of all active windows:
+Index: config.guess
+--- ncurses-5.4-20040208/config.guess	2004-01-07 00:58:42.000000000 +0000
++++ ncurses-5.4-20050319/config.guess	2005-01-01 21:46:25.000000000 +0000
+@@ -1,9 +1,9 @@
+ #! /bin/sh
+ # Attempt to guess a canonical system name.
+ #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+-#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
++#   2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 
+-timestamp='2004-01-05'
++timestamp='2004-11-12'
+ 
+ # This file is free software; you can redistribute it and/or modify it
+ # under the terms of the GNU General Public License as published by
+@@ -53,7 +53,7 @@
+ GNU config.guess ($timestamp)
+ 
+ Originally written by Per Bothner.
+-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
++Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ 
+ This is free software; see the source for copying conditions.  There is NO
+@@ -197,15 +197,21 @@
+ 	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ 	echo "${machine}-${os}${release}"
+ 	exit 0 ;;
++    amd64:OpenBSD:*:*)
++	echo x86_64-unknown-openbsd${UNAME_RELEASE}
++	exit 0 ;;
+     amiga:OpenBSD:*:*)
+ 	echo m68k-unknown-openbsd${UNAME_RELEASE}
+ 	exit 0 ;;
+-    arc:OpenBSD:*:*)
+-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
++    cats:OpenBSD:*:*)
++	echo arm-unknown-openbsd${UNAME_RELEASE}
+ 	exit 0 ;;
+     hp300:OpenBSD:*:*)
+ 	echo m68k-unknown-openbsd${UNAME_RELEASE}
+ 	exit 0 ;;
++    luna88k:OpenBSD:*:*)
++    	echo m88k-unknown-openbsd${UNAME_RELEASE}
++	exit 0 ;;
+     mac68k:OpenBSD:*:*)
+ 	echo m68k-unknown-openbsd${UNAME_RELEASE}
+ 	exit 0 ;;
+@@ -221,28 +227,33 @@
+     mvmeppc:OpenBSD:*:*)
+ 	echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ 	exit 0 ;;
+-    pegasos:OpenBSD:*:*)
+-	echo powerpc-unknown-openbsd${UNAME_RELEASE}
+-	exit 0 ;;
+-    pmax:OpenBSD:*:*)
+-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+-	exit 0 ;;
+     sgi:OpenBSD:*:*)
+-	echo mipseb-unknown-openbsd${UNAME_RELEASE}
++	echo mips64-unknown-openbsd${UNAME_RELEASE}
+ 	exit 0 ;;
+     sun3:OpenBSD:*:*)
+ 	echo m68k-unknown-openbsd${UNAME_RELEASE}
+ 	exit 0 ;;
+-    wgrisc:OpenBSD:*:*)
+-	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+-	exit 0 ;;
+     *:OpenBSD:*:*)
+ 	echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+ 	exit 0 ;;
++    *:ekkoBSD:*:*)
++	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
++	exit 0 ;;
++    macppc:MirBSD:*:*)
++	echo powerppc-unknown-mirbsd${UNAME_RELEASE}
++	exit 0 ;;
++    *:MirBSD:*:*)
++	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
++	exit 0 ;;
+     alpha:OSF1:*:*)
+-	if test $UNAME_RELEASE = "V4.0"; then
++	case $UNAME_RELEASE in
++	*4.0)
+ 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+-	fi
++		;;
++	*5.*)
++	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
++		;;
++	esac
+ 	# According to Compaq, /usr/sbin/psrinfo has been available on
+ 	# OSF/1 and Tru64 systems produced since 1995.  I hope that
+ 	# covers most systems running today.  This code pipes the CPU
+@@ -280,14 +291,12 @@
+ 	    "EV7.9 (21364A)")
+ 		UNAME_MACHINE="alphaev79" ;;
+ 	esac
++	# A Pn.n version is a patched version.
+ 	# A Vn.n version is a released version.
+ 	# A Tn.n version is a released field test version.
+ 	# A Xn.n version is an unreleased experimental baselevel.
+ 	# 1.2 uses "1.2" for uname -r.
+-	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+-	exit 0 ;;
+-    Alpha*:OpenVMS:*:*)
+-	echo alpha-hp-vms
++	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ 	exit 0 ;;
+     Alpha\ *:Windows_NT*:*)
+ 	# How do we know it's Interix rather than the generic POSIX subsystem?
+@@ -310,8 +319,11 @@
+     *:OS/390:*:*)
+ 	echo i370-ibm-openedition
+ 	exit 0 ;;
++    *:z/VM:*:*)
++	echo s390-ibm-zvmoe
++	exit 0 ;;
+     *:OS400:*:*)
+-	echo powerpc-ibm-os400
++        echo powerpc-ibm-os400
+ 	exit 0 ;;
+     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ 	echo arm-acorn-riscix${UNAME_RELEASE}
+@@ -333,7 +345,7 @@
+     DRS?6000:unix:4.0:6*)
+ 	echo sparc-icl-nx6
+ 	exit 0 ;;
+-    DRS?6000:UNIX_SV:4.2*:7*)
++    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ 	case `/usr/bin/uname -p` in
+ 	    sparc) echo sparc-icl-nx7 && exit 0 ;;
+ 	esac ;;
+@@ -405,6 +417,9 @@
+     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+         echo m68k-unknown-mint${UNAME_RELEASE}
+         exit 0 ;;
++    m68k:machten:*:*)
++	echo m68k-apple-machten${UNAME_RELEASE}
++	exit 0 ;;
+     powerpc:machten:*:*)
+ 	echo powerpc-apple-machten${UNAME_RELEASE}
+ 	exit 0 ;;
+@@ -740,18 +755,18 @@
+ 	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ 	exit 0 ;;
+     *:UNICOS/mp:*:*)
+-	echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
++	echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ 	exit 0 ;;
+     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ 	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+-	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+-	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+-	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+-	exit 0 ;;
++        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
++        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
++        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
++        exit 0 ;;
+     5000:UNIX_System_V:4.*:*)
+-	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+-	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+-	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
++        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
++        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
++        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ 	exit 0 ;;
+     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+@@ -763,21 +778,7 @@
+ 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ 	exit 0 ;;
+     *:FreeBSD:*:*)
+-	# Determine whether the default compiler uses glibc.
+-	eval $set_cc_for_build
+-	sed 's/^	//' << EOF >$dummy.c
+-	#include <features.h>
+-	#if __GLIBC__ >= 2
+-	LIBC=gnu
+-	#else
+-	LIBC=
+-	#endif
+-EOF
+-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+-	# GNU/KFreeBSD systems have a "k" prefix to indicate we are using
+-	# FreeBSD's kernel, but not the complete OS.
+-	case ${LIBC} in gnu) kernel_only='k' ;; esac
+-	echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
++	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ 	exit 0 ;;
+     i*:CYGWIN*:*)
+ 	echo ${UNAME_MACHINE}-pc-cygwin
+@@ -826,9 +827,18 @@
+     cris:Linux:*:*)
+ 	echo cris-axis-linux-gnu
+ 	exit 0 ;;
++    crisv32:Linux:*:*)
++	echo crisv32-axis-linux-gnu
++	exit 0 ;;
++    frv:Linux:*:*)
++    	echo frv-unknown-linux-gnu
++	exit 0 ;;
+     ia64:Linux:*:*)
+ 	echo ${UNAME_MACHINE}-unknown-linux-gnu
+ 	exit 0 ;;
++    m32r*:Linux:*:*)
++	echo ${UNAME_MACHINE}-unknown-linux-gnu
++	exit 0 ;;
+     m68*:Linux:*:*)
+ 	echo ${UNAME_MACHINE}-unknown-linux-gnu
+ 	exit 0 ;;
+@@ -905,7 +915,7 @@
+ 	echo ${UNAME_MACHINE}-ibm-linux
+ 	exit 0 ;;
+     sh64*:Linux:*:*)
+-	echo ${UNAME_MACHINE}-unknown-linux-gnu
++    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+ 	exit 0 ;;
+     sh*:Linux:*:*)
+ 	echo ${UNAME_MACHINE}-unknown-linux-gnu
+@@ -997,7 +1007,7 @@
+     i*86:atheos:*:*)
+ 	echo ${UNAME_MACHINE}-unknown-atheos
+ 	exit 0 ;;
+-    i*86:syllable:*:*)
++	i*86:syllable:*:*)
+ 	echo ${UNAME_MACHINE}-pc-syllable
+ 	exit 0 ;;
+     i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+@@ -1069,9 +1079,9 @@
+     M680?0:D-NIX:5.3:*)
+ 	echo m68k-diab-dnix
+ 	exit 0 ;;
+-    M68*:*:R3V[567]*:*)
++    M68*:*:R3V[5678]*:*)
+ 	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+-    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
++    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ 	OS_REL=''
+ 	test -r /etc/.relid \
+ 	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+@@ -1169,9 +1179,10 @@
+ 	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ 	exit 0 ;;
+     *:Darwin:*:*)
+-	case `uname -p` in
++	UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
++	case $UNAME_PROCESSOR in
+ 	    *86) UNAME_PROCESSOR=i686 ;;
+-	    powerpc) UNAME_PROCESSOR=powerpc ;;
++	    unknown) UNAME_PROCESSOR=powerpc ;;
+ 	esac
+ 	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ 	exit 0 ;;
+@@ -1228,10 +1239,20 @@
+ 	echo pdp10-unknown-its
+ 	exit 0 ;;
+     SEI:*:*:SEIUX)
+-	echo mips-sei-seiux${UNAME_RELEASE}
++        echo mips-sei-seiux${UNAME_RELEASE}
++	exit 0 ;;
++    *:DragonFly:*:*)
++	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ 	exit 0 ;;
+-    *:DRAGONFLY:*:*)
+-	echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE}
++    *:*VMS:*:*)
++    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
++	case "${UNAME_MACHINE}" in
++	    A*) echo alpha-dec-vms && exit 0 ;;
++	    I*) echo ia64-dec-vms && exit 0 ;;
++	    V*) echo vax-dec-vms && exit 0 ;;
++	esac ;;
++    *:XENIX:*:SysV)
++	echo i386-pc-xenix
+ 	exit 0 ;;
+ esac
+ 
+Index: config.sub
+--- ncurses-5.4-20040208/config.sub	2004-01-07 01:00:46.000000000 +0000
++++ ncurses-5.4-20050319/config.sub	2005-01-01 21:46:34.000000000 +0000
+@@ -1,9 +1,9 @@
+ #! /bin/sh
+ # Configuration validation subroutine script.
+ #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+-#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
++#   2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ 
+-timestamp='2004-01-05'
++timestamp='2004-11-30'
+ 
+ # This file is (in principle) common to ALL GNU software.
+ # The presence of a machine in this file suggests that SOME GNU software
+@@ -70,7 +70,7 @@
+ version="\
+ GNU config.sub ($timestamp)
+ 
+-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
++Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+ 
+ This is free software; see the source for copying conditions.  There is NO
+@@ -145,7 +145,7 @@
+ 	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ 	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ 	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+-	-apple | -axis)
++	-apple | -axis | -knuth | -cray)
+ 		os=
+ 		basic_machine=$1
+ 		;;
+@@ -237,7 +237,7 @@
+ 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ 	| i370 | i860 | i960 | ia64 \
+ 	| ip2k | iq2000 \
+-	| m32r | m68000 | m68k | m88k | mcore \
++	| m32r | m32rle | m68000 | m68k | m88k | mcore \
+ 	| mips | mipsbe | mipseb | mipsel | mipsle \
+ 	| mips16 \
+ 	| mips64 | mips64el \
+@@ -262,12 +262,12 @@
+ 	| pyramid \
+ 	| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ 	| sh64 | sh64le \
+-	| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
++	| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \
+ 	| strongarm \
+ 	| tahoe | thumb | tic4x | tic80 | tron \
+ 	| v850 | v850e \
+ 	| we32k \
+-	| x86 | xscale | xstormy16 | xtensa \
++	| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
+ 	| z8k)
+ 		basic_machine=$basic_machine-unknown
+ 		;;
+@@ -283,8 +283,8 @@
+ 	# because (1) that's what they normally are, and
+ 	# (2) the word "unknown" tends to confuse beginning users.
+ 	i*86 | x86_64)
+-		basic_machine=$basic_machine-pc
+-		;;
++	  basic_machine=$basic_machine-pc
++	  ;;
+ 	# Object if more than one company name word.
+ 	*-*-*)
+ 		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+@@ -300,7 +300,7 @@
+ 	| avr-* \
+ 	| bs2000-* \
+ 	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+-	| clipper-* | cydra-* \
++	| clipper-* | craynv-* | cydra-* \
+ 	| d10v-* | d30v-* | dlx-* \
+ 	| elxsi-* \
+ 	| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+@@ -308,7 +308,7 @@
+ 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ 	| i*86-* | i860-* | i960-* | ia64-* \
+ 	| ip2k-* | iq2000-* \
+-	| m32r-* \
++	| m32r-* | m32rle-* \
+ 	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ 	| m88110-* | m88k-* | mcore-* \
+ 	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+@@ -326,8 +326,9 @@
+ 	| mipsisa64sb1-* | mipsisa64sb1el-* \
+ 	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ 	| mipstx39-* | mipstx39el-* \
++	| mmix-* \
+ 	| msp430-* \
+-	| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
++	| none-* | np1-* | ns16k-* | ns32k-* \
+ 	| orion-* \
+ 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+@@ -336,14 +337,14 @@
+ 	| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+ 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ 	| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+-	| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
++	| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ 	| tahoe-* | thumb-* \
+ 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ 	| tron-* \
+ 	| v850-* | v850e-* | vax-* \
+ 	| we32k-* \
+-	| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
+-	| xtensa-* \
++	| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
++	| xstormy16-* | xtensa-* \
+ 	| ymp-* \
+ 	| z8k-*)
+ 		;;
+@@ -363,6 +364,9 @@
+ 		basic_machine=a29k-amd
+ 		os=-udi
+ 		;;
++    	abacus)
++		basic_machine=abacus-unknown
++		;;
+ 	adobe68k)
+ 		basic_machine=m68010-adobe
+ 		os=-scout
+@@ -442,12 +446,27 @@
+ 		basic_machine=j90-cray
+ 		os=-unicos
+ 		;;
++	craynv)
++		basic_machine=craynv-cray
++		os=-unicosmp
++		;;
++	cr16c)
++		basic_machine=cr16c-unknown
++		os=-elf
++		;;
+ 	crds | unos)
+ 		basic_machine=m68k-crds
+ 		;;
++	crisv32 | crisv32-* | etraxfs*)
++		basic_machine=crisv32-axis
++		;;
+ 	cris | cris-* | etrax*)
+ 		basic_machine=cris-axis
+ 		;;
++	crx)
++		basic_machine=crx-unknown
++		os=-elf
++		;;
+ 	da30 | da30-*)
+ 		basic_machine=m68k-da30
+ 		;;
+@@ -470,6 +489,10 @@
+ 		basic_machine=m88k-motorola
+ 		os=-sysv3
+ 		;;
++	djgpp)
++		basic_machine=i586-pc
++		os=-msdosdjgpp
++		;;
+ 	dpx20 | dpx20-*)
+ 		basic_machine=rs6000-bull
+ 		os=-bosx
+@@ -648,10 +671,6 @@
+ 	mips3*)
+ 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ 		;;
+-	mmix*)
+-		basic_machine=mmix-knuth
+-		os=-mmixware
+-		;;
+ 	monitor)
+ 		basic_machine=m68k-rom68k
+ 		os=-coff
+@@ -732,10 +751,6 @@
+ 	np1)
+ 		basic_machine=np1-gould
+ 		;;
+-	nv1)
+-		basic_machine=nv1-cray
+-		os=-unicosmp
+-		;;
+ 	nsr-tandem)
+ 		basic_machine=nsr-tandem
+ 		;;
+@@ -1018,6 +1033,10 @@
+ 		basic_machine=hppa1.1-winbond
+ 		os=-proelf
+ 		;;
++	xbox)
++		basic_machine=i686-pc
++		os=-mingw32
++		;;
+ 	xps | xps100)
+ 		basic_machine=xps100-honeywell
+ 		;;
+@@ -1048,6 +1067,9 @@
+ 	romp)
+ 		basic_machine=romp-ibm
+ 		;;
++	mmix)
++		basic_machine=mmix-knuth
++		;;
+ 	rs6000)
+ 		basic_machine=rs6000-ibm
+ 		;;
+@@ -1070,7 +1092,7 @@
+ 	sh64)
+ 		basic_machine=sh64-unknown
+ 		;;
+-	sparc | sparcv9 | sparcv9b)
++	sparc | sparcv8 | sparcv9 | sparcv9b)
+ 		basic_machine=sparc-sun
+ 		;;
+ 	cydra)
+@@ -1114,8 +1136,8 @@
+ if [ x"$os" != x"" ]
+ then
+ case $os in
+-	# First match some system type aliases
+-	# that might get confused with valid system types.
++        # First match some system type aliases
++        # that might get confused with valid system types.
+ 	# -solaris* is a basic system type, with this one exception.
+ 	-solaris1 | -solaris1.*)
+ 		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+@@ -1143,8 +1165,9 @@
+ 	      | -aos* \
+ 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+-	      | -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
+-	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
++	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
++	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
++	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ 	      | -chorusos* | -chorusrdb* \
+@@ -1194,7 +1217,7 @@
+ 	-opened*)
+ 		os=-openedition
+ 		;;
+-	-os400*)
++        -os400*)
+ 		os=-os400
+ 		;;
+ 	-wince*)
+@@ -1243,7 +1266,7 @@
+ 	-sinix*)
+ 		os=-sysv4
+ 		;;
+-	-tpf*)
++        -tpf*)
+ 		os=-tpf
+ 		;;
+ 	-triton*)
+@@ -1282,6 +1305,9 @@
+ 	-kaos*)
+ 		os=-kaos
+ 		;;
++	-zvmoe)
++		os=-zvmoe
++		;;
+ 	-none)
+ 		;;
+ 	*)
+@@ -1313,9 +1339,9 @@
+ 	arm*-semi)
+ 		os=-aout
+ 		;;
+-	c4x-* | tic4x-*)
+-		os=-coff
+-		;;
++    c4x-* | tic4x-*)
++        os=-coff
++        ;;
+ 	# This must come before the *-dec entry.
+ 	pdp10-*)
+ 		os=-tops20
+@@ -1362,6 +1388,9 @@
+ 	*-ibm)
+ 		os=-aix
+ 		;;
++    	*-knuth)
++		os=-mmixware
++		;;
+ 	*-wec)
+ 		os=-proelf
+ 		;;
+Index: configure
+--- ncurses-5.4-20040208/configure	2004-02-01 01:03:42.000000000 +0000
++++ ncurses-5.4-20050319/configure	2005-02-05 19:41:07.000000000 +0000
+@@ -1,5 +1,5 @@
+ #! /bin/sh
+-# From configure.in Revision: 1.312 .
++# From configure.in Revision: 1.331 .
+ # Guess values for system-dependent variables and create Makefiles.
+ # Generated by Autoconf 2.52.20030208.
+ #
+@@ -666,6 +666,7 @@
+   --with-install-prefix   prefixes actual install-location ($DESTDIR)
+ Build-Tools Needed to Compile Temporary Applications for Cross-compiling:
+   --with-build-cc=XXX     the build C compiler ($BUILD_CC)
++  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)
+   --with-build-cflags=XXX the build C compiler-flags
+   --with-build-cppflags=XXX the build C preprocessor-flags
+   --with-build-ldflags=XXX the build linker-flags
+@@ -677,8 +678,8 @@
+   --with-debug            generate debug-libraries (default)
+   --with-profile          generate profile-libraries
+   --with-termlib          generate separate terminfo library
+-  --with-dbmalloc         test: use Conor Cahill's dbmalloc library
+-  --with-dmalloc          test: use Gray Watson's dmalloc library
++  --with-dbmalloc         use Conor Cahill's dbmalloc library
++  --with-dmalloc          use Gray Watson's dmalloc library
+   --with-gpm              use Alessandro Rubini's GPM library
+   --with-sysmouse         use sysmouse (FreeBSD console)
+   --enable-rpath          use rpath option when generating shared libraries
+@@ -688,6 +689,7 @@
+   --disable-database      do not use terminfo, only fallbacks/termcap
+   --with-database=XXX     specify terminfo source to install
+   --with-fallbacks=XXX    specify list of fallback terminal descriptions
++  --without-xterm-new     specify if xterm terminfo should be old version
+   --with-terminfo-dirs=XXX specify list of terminfo directories (default: DATADIR/terminfo)
+   --with-default-terminfo-dir=DIR default terminfo directory (default: DATADIR/terminfo)
+   --disable-big-core      assume machine has little memory
+@@ -696,9 +698,12 @@
+   --enable-getcap         fast termcap load, no xrefs to terminfo
+   --enable-getcap-cache   cache translated termcaps in ~/.terminfo
+   --disable-home-terminfo drop ~/.terminfo from terminfo search-path
++  --disable-root-environ  limit environment when running as root
+   --enable-symlinks       make tic use symbolic links not hard links
+   --enable-broken_linker  compile with broken-linker support code
++  --enable-widec          compile with wide-char/UTF-8 code
+   --with-bool=TYPE        override fallback type of bool variable
++  --with-caps=alt         compile with alternate Caps file
+   --with-ospeed=TYPE      override type of ospeed variable
+   --enable-bsdpad         recognize BSD-style prefix padding
+   --with-rcs-ids          compile-in RCS identifiers
+@@ -718,16 +723,15 @@
+ Development Code:
+   --with-develop          enable all development options
+   --enable-hard-tabs      compile with hard-tabs code
+-  --disable-root-environ  limit environment when running as root
+   --enable-xmc-glitch     compile with limited support for xmc
+ Experimental Code:
+   --disable-assumed-color do not assume anything about default-colors
+   --disable-hashmap       compile without hashmap scrolling-optimization
+   --enable-colorfgbg      compile with $COLORFGBG code
++  --enable-ext-colors     compile for experimental 256-color support
++  --enable-ext-mouse      compile for experimental mouse-encoding
+   --enable-safe-sprintf   compile with experimental safe-sprintf code
+   --disable-scroll-hints  compile without scroll-hints code
+-  --enable-widec          compile with experimental wide-char/UTF-8 code
+-  --with-caps=alt         compile with experimental alternate Caps file
+ Testing/development Options:
+   --enable-echo           build: display "compiling" commands (default)
+   --enable-warnings       build: turn on GCC compiler warnings
+@@ -936,7 +940,7 @@
+ fi
+ for ac_site_file in $CONFIG_SITE; do
+   if test -r "$ac_site_file"; then
+-    { echo "$as_me:939: loading site script $ac_site_file" >&5
++    { echo "$as_me:943: loading site script $ac_site_file" >&5
+ echo "$as_me: loading site script $ac_site_file" >&6;}
+     cat "$ac_site_file" >&5
+     . "$ac_site_file"
+@@ -947,7 +951,7 @@
+   # Some versions of bash will fail to source /dev/null (special
+   # files actually), so we avoid doing that.
+   if test -f "$cache_file"; then
+-    { echo "$as_me:950: loading cache $cache_file" >&5
++    { echo "$as_me:954: loading cache $cache_file" >&5
+ echo "$as_me: loading cache $cache_file" >&6;}
+     case $cache_file in
+       [\\/]* | ?:[\\/]* ) . $cache_file;;
+@@ -955,7 +959,7 @@
+     esac
+   fi
+ else
+-  { echo "$as_me:958: creating cache $cache_file" >&5
++  { echo "$as_me:962: creating cache $cache_file" >&5
+ echo "$as_me: creating cache $cache_file" >&6;}
+   >$cache_file
+ fi
+@@ -971,21 +975,21 @@
+   eval ac_new_val="\$ac_env_${ac_var}_value"
+   case $ac_old_set,$ac_new_set in
+     set,)
+-      { echo "$as_me:974: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
++      { echo "$as_me:978: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+ echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+       ac_cache_corrupted=: ;;
+     ,set)
+-      { echo "$as_me:978: error: \`$ac_var' was not set in the previous run" >&5
++      { echo "$as_me:982: error: \`$ac_var' was not set in the previous run" >&5
+ echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+       ac_cache_corrupted=: ;;
+     ,);;
+     *)
+       if test "x$ac_old_val" != "x$ac_new_val"; then
+-        { echo "$as_me:984: error: \`$ac_var' has changed since the previous run:" >&5
++        { echo "$as_me:988: error: \`$ac_var' has changed since the previous run:" >&5
+ echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+-        { echo "$as_me:986:   former value:  $ac_old_val" >&5
++        { echo "$as_me:990:   former value:  $ac_old_val" >&5
+ echo "$as_me:   former value:  $ac_old_val" >&2;}
+-        { echo "$as_me:988:   current value: $ac_new_val" >&5
++        { echo "$as_me:992:   current value: $ac_new_val" >&5
+ echo "$as_me:   current value: $ac_new_val" >&2;}
+         ac_cache_corrupted=:
+       fi;;
+@@ -1004,9 +1008,9 @@
+   fi
+ done
+ if $ac_cache_corrupted; then
+-  { echo "$as_me:1007: error: changes in the environment can compromise the build" >&5
++  { echo "$as_me:1011: error: changes in the environment can compromise the build" >&5
+ echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+-  { { echo "$as_me:1009: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
++  { { echo "$as_me:1013: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+ echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+@@ -1026,10 +1030,10 @@
+ echo "#! $SHELL" >conftest.sh
+ echo  "exit 0"   >>conftest.sh
+ chmod +x conftest.sh
+-if { (echo "$as_me:1029: PATH=\".;.\"; conftest.sh") >&5
++if { (echo "$as_me:1033: PATH=\".;.\"; conftest.sh") >&5
+   (PATH=".;."; conftest.sh) 2>&5
+   ac_status=$?
+-  echo "$as_me:1032: \$? = $ac_status" >&5
++  echo "$as_me:1036: \$? = $ac_status" >&5
+   (exit $ac_status); }; then
+   ac_path_separator=';'
+ else
+@@ -1046,7 +1050,7 @@
+ cf_cv_abi_version=${NCURSES_MAJOR}
+ cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
+ cf_cv_timestamp=`date`
+-echo "$as_me:1049: result: Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp)" >&5
++echo "$as_me:1053: result: Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp)" >&5
+ echo "${ECHO_T}Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp)" >&6
+ 
+ test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
+@@ -1054,7 +1058,7 @@
+ # Check whether --with-rel-version or --without-rel-version was given.
+ if test "${with_rel_version+set}" = set; then
+   withval="$with_rel_version"
+-  { echo "$as_me:1057: WARNING: overriding release version $cf_cv_rel_version to $withval" >&5
++  { echo "$as_me:1061: WARNING: overriding release version $cf_cv_rel_version to $withval" >&5
+ echo "$as_me: WARNING: overriding release version $cf_cv_rel_version to $withval" >&2;}
+  cf_cv_rel_version=$withval
+ fi;
+@@ -1067,13 +1071,13 @@
+   [0-9]*) #(vi
+  	;;
+   *)
+-	{ { echo "$as_me:1070: error: Release major-version is not a number: $NCURSES_MAJOR" >&5
++	{ { echo "$as_me:1074: error: Release major-version is not a number: $NCURSES_MAJOR" >&5
+ echo "$as_me: error: Release major-version is not a number: $NCURSES_MAJOR" >&2;}
+    { (exit 1); exit 1; }; }
+  	;;
+   esac
+ else
+-  { { echo "$as_me:1076: error: Release major-version value is empty" >&5
++  { { echo "$as_me:1080: error: Release major-version value is empty" >&5
+ echo "$as_me: error: Release major-version value is empty" >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+@@ -1083,13 +1087,13 @@
+   [0-9]*) #(vi
+  	;;
+   *)
+-	{ { echo "$as_me:1086: error: Release minor-version is not a number: $NCURSES_MINOR" >&5
++	{ { echo "$as_me:1090: error: Release minor-version is not a number: $NCURSES_MINOR" >&5
+ echo "$as_me: error: Release minor-version is not a number: $NCURSES_MINOR" >&2;}
+    { (exit 1); exit 1; }; }
+  	;;
+   esac
+ else
+-  { { echo "$as_me:1092: error: Release minor-version value is empty" >&5
++  { { echo "$as_me:1096: error: Release minor-version value is empty" >&5
+ echo "$as_me: error: Release minor-version value is empty" >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+@@ -1099,7 +1103,7 @@
+ # Check whether --with-abi-version or --without-abi-version was given.
+ if test "${with_abi_version+set}" = set; then
+   withval="$with_abi_version"
+-  { echo "$as_me:1102: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&5
++  { echo "$as_me:1106: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&5
+ echo "$as_me: WARNING: overriding ABI version $cf_cv_abi_version to $withval" >&2;}
+  cf_cv_abi_version=$withval
+ fi;
+@@ -1109,13 +1113,13 @@
+   [0-9]*) #(vi
+  	;;
+   *)
+-	{ { echo "$as_me:1112: error: ABI version is not a number: $cf_cv_abi_version" >&5
++	{ { echo "$as_me:1116: error: ABI version is not a number: $cf_cv_abi_version" >&5
+ echo "$as_me: error: ABI version is not a number: $cf_cv_abi_version" >&2;}
+    { (exit 1); exit 1; }; }
+  	;;
+   esac
+ else
+-  { { echo "$as_me:1118: error: ABI version value is empty" >&5
++  { { echo "$as_me:1122: error: ABI version value is empty" >&5
+ echo "$as_me: error: ABI version value is empty" >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+@@ -1137,7 +1141,7 @@
+   fi
+ done
+ if test -z "$ac_aux_dir"; then
+-  { { echo "$as_me:1140: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
++  { { echo "$as_me:1144: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+ echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+@@ -1147,11 +1151,11 @@
+ 
+ # Make sure we can run config.sub.
+ $ac_config_sub sun4 >/dev/null 2>&1 ||
+-  { { echo "$as_me:1150: error: cannot run $ac_config_sub" >&5
++  { { echo "$as_me:1154: error: cannot run $ac_config_sub" >&5
+ echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+    { (exit 1); exit 1; }; }
+ 
+-echo "$as_me:1154: checking build system type" >&5
++echo "$as_me:1158: checking build system type" >&5
+ echo $ECHO_N "checking build system type... $ECHO_C" >&6
+ if test "${ac_cv_build+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1160,23 +1164,23 @@
+ test -z "$ac_cv_build_alias" &&
+   ac_cv_build_alias=`$ac_config_guess`
+ test -z "$ac_cv_build_alias" &&
+-  { { echo "$as_me:1163: error: cannot guess build type; you must specify one" >&5
++  { { echo "$as_me:1167: error: cannot guess build type; you must specify one" >&5
+ echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+    { (exit 1); exit 1; }; }
+ ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+-  { { echo "$as_me:1167: error: $ac_config_sub $ac_cv_build_alias failed." >&5
++  { { echo "$as_me:1171: error: $ac_config_sub $ac_cv_build_alias failed." >&5
+ echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed." >&2;}
+    { (exit 1); exit 1; }; }
+ 
+ fi
+-echo "$as_me:1172: result: $ac_cv_build" >&5
++echo "$as_me:1176: result: $ac_cv_build" >&5
+ echo "${ECHO_T}$ac_cv_build" >&6
+ build=$ac_cv_build
+ build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ 
+-echo "$as_me:1179: checking host system type" >&5
++echo "$as_me:1183: checking host system type" >&5
+ echo $ECHO_N "checking host system type... $ECHO_C" >&6
+ if test "${ac_cv_host+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1185,20 +1189,20 @@
+ test -z "$ac_cv_host_alias" &&
+   ac_cv_host_alias=$ac_cv_build_alias
+ ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+-  { { echo "$as_me:1188: error: $ac_config_sub $ac_cv_host_alias failed" >&5
++  { { echo "$as_me:1192: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+ echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+    { (exit 1); exit 1; }; }
+ 
+ fi
+-echo "$as_me:1193: result: $ac_cv_host" >&5
++echo "$as_me:1197: result: $ac_cv_host" >&5
+ echo "${ECHO_T}$ac_cv_host" >&6
+ host=$ac_cv_host
+ host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+ host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+ host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ 
+-if test -f $srcdir/config.guess ; then
+-	echo "$as_me:1201: checking target system type" >&5
++if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
++	echo "$as_me:1205: checking target system type" >&5
+ echo $ECHO_N "checking target system type... $ECHO_C" >&6
+ if test "${ac_cv_target+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1207,12 +1211,12 @@
+ test "x$ac_cv_target_alias" = "x" &&
+   ac_cv_target_alias=$ac_cv_host_alias
+ ac_cv_target=`$ac_config_sub $ac_cv_target_alias` ||
+-  { { echo "$as_me:1210: error: $ac_config_sub $ac_cv_target_alias failed" >&5
++  { { echo "$as_me:1214: error: $ac_config_sub $ac_cv_target_alias failed" >&5
+ echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;}
+    { (exit 1); exit 1; }; }
+ 
+ fi
+-echo "$as_me:1215: result: $ac_cv_target" >&5
++echo "$as_me:1219: result: $ac_cv_target" >&5
+ echo "${ECHO_T}$ac_cv_target" >&6
+ target=$ac_cv_target
+ target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+@@ -1243,13 +1247,13 @@
+ fi
+ 
+ test -z "$system_name" && system_name="$cf_cv_system_name"
+-test -n "$cf_cv_system_name" && echo "$as_me:1246: result: Configuring for $cf_cv_system_name" >&5
++test -n "$cf_cv_system_name" && echo "$as_me:1250: result: Configuring for $cf_cv_system_name" >&5
+ echo "${ECHO_T}Configuring for $cf_cv_system_name" >&6
+ 
+ if test ".$system_name" != ".$cf_cv_system_name" ; then
+-	echo "$as_me:1250: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
++	echo "$as_me:1254: result: Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&5
+ echo "${ECHO_T}Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)" >&6
+-	{ { echo "$as_me:1252: error: \"Please remove config.cache and try again.\"" >&5
++	{ { echo "$as_me:1256: error: \"Please remove config.cache and try again.\"" >&5
+ echo "$as_me: error: \"Please remove config.cache and try again.\"" >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+@@ -1257,7 +1261,7 @@
+ # Check whether --with-system-type or --without-system-type was given.
+ if test "${with_system_type+set}" = set; then
+   withval="$with_system_type"
+-  { echo "$as_me:1260: WARNING: overriding system type to $withval" >&5
++  { echo "$as_me:1264: WARNING: overriding system type to $withval" >&5
+ echo "$as_me: WARNING: overriding system type to $withval" >&2;}
+  cf_cv_system_name=$withval
+ fi;
+@@ -1267,7 +1271,7 @@
+ 
+ ###	Default install-location
+ 
+-echo "$as_me:1270: checking for prefix" >&5
++echo "$as_me:1274: checking for prefix" >&5
+ echo $ECHO_N "checking for prefix... $ECHO_C" >&6
+ if test "x$prefix" = "xNONE" ; then
+ 	case "$cf_cv_system_name" in
+@@ -1279,11 +1283,11 @@
+ 		;;
+ 	esac
+ fi
+-echo "$as_me:1282: result: $prefix" >&5
++echo "$as_me:1286: result: $prefix" >&5
+ echo "${ECHO_T}$prefix" >&6
+ 
+ if test "x$prefix" = "xNONE" ; then
+-echo "$as_me:1286: checking for default include-directory" >&5
++echo "$as_me:1290: checking for default include-directory" >&5
+ echo $ECHO_N "checking for default include-directory... $ECHO_C" >&6
+ test -n "$verbose" && echo 1>&6
+ for cf_symbol in \
+@@ -1306,7 +1310,7 @@
+ 	fi
+ 	test -n "$verbose"  && echo "	tested $cf_dir" 1>&6
+ done
+-echo "$as_me:1309: result: $includedir" >&5
++echo "$as_me:1313: result: $includedir" >&5
+ echo "${ECHO_T}$includedir" >&6
+ fi
+ 
+@@ -1319,7 +1323,7 @@
+ if test -n "$ac_tool_prefix"; then
+   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+ set dummy ${ac_tool_prefix}gcc; ac_word=$2
+-echo "$as_me:1322: checking for $ac_word" >&5
++echo "$as_me:1326: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_CC+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1334,7 +1338,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+-echo "$as_me:1337: found $ac_dir/$ac_word" >&5
++echo "$as_me:1341: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -1342,10 +1346,10 @@
+ fi
+ CC=$ac_cv_prog_CC
+ if test -n "$CC"; then
+-  echo "$as_me:1345: result: $CC" >&5
++  echo "$as_me:1349: result: $CC" >&5
+ echo "${ECHO_T}$CC" >&6
+ else
+-  echo "$as_me:1348: result: no" >&5
++  echo "$as_me:1352: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -1354,7 +1358,7 @@
+   ac_ct_CC=$CC
+   # Extract the first word of "gcc", so it can be a program name with args.
+ set dummy gcc; ac_word=$2
+-echo "$as_me:1357: checking for $ac_word" >&5
++echo "$as_me:1361: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1369,7 +1373,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_ac_ct_CC="gcc"
+-echo "$as_me:1372: found $ac_dir/$ac_word" >&5
++echo "$as_me:1376: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -1377,10 +1381,10 @@
+ fi
+ ac_ct_CC=$ac_cv_prog_ac_ct_CC
+ if test -n "$ac_ct_CC"; then
+-  echo "$as_me:1380: result: $ac_ct_CC" >&5
++  echo "$as_me:1384: result: $ac_ct_CC" >&5
+ echo "${ECHO_T}$ac_ct_CC" >&6
+ else
+-  echo "$as_me:1383: result: no" >&5
++  echo "$as_me:1387: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -1393,7 +1397,7 @@
+   if test -n "$ac_tool_prefix"; then
+   # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+ set dummy ${ac_tool_prefix}cc; ac_word=$2
+-echo "$as_me:1396: checking for $ac_word" >&5
++echo "$as_me:1400: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_CC+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1408,7 +1412,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+-echo "$as_me:1411: found $ac_dir/$ac_word" >&5
++echo "$as_me:1415: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -1416,10 +1420,10 @@
+ fi
+ CC=$ac_cv_prog_CC
+ if test -n "$CC"; then
+-  echo "$as_me:1419: result: $CC" >&5
++  echo "$as_me:1423: result: $CC" >&5
+ echo "${ECHO_T}$CC" >&6
+ else
+-  echo "$as_me:1422: result: no" >&5
++  echo "$as_me:1426: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -1428,7 +1432,7 @@
+   ac_ct_CC=$CC
+   # Extract the first word of "cc", so it can be a program name with args.
+ set dummy cc; ac_word=$2
+-echo "$as_me:1431: checking for $ac_word" >&5
++echo "$as_me:1435: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1443,7 +1447,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_ac_ct_CC="cc"
+-echo "$as_me:1446: found $ac_dir/$ac_word" >&5
++echo "$as_me:1450: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -1451,10 +1455,10 @@
+ fi
+ ac_ct_CC=$ac_cv_prog_ac_ct_CC
+ if test -n "$ac_ct_CC"; then
+-  echo "$as_me:1454: result: $ac_ct_CC" >&5
++  echo "$as_me:1458: result: $ac_ct_CC" >&5
+ echo "${ECHO_T}$ac_ct_CC" >&6
+ else
+-  echo "$as_me:1457: result: no" >&5
++  echo "$as_me:1461: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -1467,7 +1471,7 @@
+ if test -z "$CC"; then
+   # Extract the first word of "cc", so it can be a program name with args.
+ set dummy cc; ac_word=$2
+-echo "$as_me:1470: checking for $ac_word" >&5
++echo "$as_me:1474: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_CC+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1487,7 +1491,7 @@
+   continue
+ fi
+ ac_cv_prog_CC="cc"
+-echo "$as_me:1490: found $ac_dir/$ac_word" >&5
++echo "$as_me:1494: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -1509,10 +1513,10 @@
+ fi
+ CC=$ac_cv_prog_CC
+ if test -n "$CC"; then
+-  echo "$as_me:1512: result: $CC" >&5
++  echo "$as_me:1516: result: $CC" >&5
+ echo "${ECHO_T}$CC" >&6
+ else
+-  echo "$as_me:1515: result: no" >&5
++  echo "$as_me:1519: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -1523,7 +1527,7 @@
+   do
+     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+ set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+-echo "$as_me:1526: checking for $ac_word" >&5
++echo "$as_me:1530: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_CC+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1538,7 +1542,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+-echo "$as_me:1541: found $ac_dir/$ac_word" >&5
++echo "$as_me:1545: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -1546,10 +1550,10 @@
+ fi
+ CC=$ac_cv_prog_CC
+ if test -n "$CC"; then
+-  echo "$as_me:1549: result: $CC" >&5
++  echo "$as_me:1553: result: $CC" >&5
+ echo "${ECHO_T}$CC" >&6
+ else
+-  echo "$as_me:1552: result: no" >&5
++  echo "$as_me:1556: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -1562,7 +1566,7 @@
+ do
+   # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+-echo "$as_me:1565: checking for $ac_word" >&5
++echo "$as_me:1569: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -1577,7 +1581,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+-echo "$as_me:1580: found $ac_dir/$ac_word" >&5
++echo "$as_me:1584: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -1585,10 +1589,10 @@
+ fi
+ ac_ct_CC=$ac_cv_prog_ac_ct_CC
+ if test -n "$ac_ct_CC"; then
+-  echo "$as_me:1588: result: $ac_ct_CC" >&5
++  echo "$as_me:1592: result: $ac_ct_CC" >&5
+ echo "${ECHO_T}$ac_ct_CC" >&6
+ else
+-  echo "$as_me:1591: result: no" >&5
++  echo "$as_me:1595: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -1600,32 +1604,32 @@
+ 
+ fi
+ 
+-test -z "$CC" && { { echo "$as_me:1603: error: no acceptable cc found in \$PATH" >&5
++test -z "$CC" && { { echo "$as_me:1607: error: no acceptable cc found in \$PATH" >&5
+ echo "$as_me: error: no acceptable cc found in \$PATH" >&2;}
+    { (exit 1); exit 1; }; }
+ 
+ # Provide some information about the compiler.
+-echo "$as_me:1608:" \
++echo "$as_me:1612:" \
+      "checking for C compiler version" >&5
+ ac_compiler=`set X $ac_compile; echo $2`
+-{ (eval echo "$as_me:1611: \"$ac_compiler --version </dev/null >&5\"") >&5
++{ (eval echo "$as_me:1615: \"$ac_compiler --version </dev/null >&5\"") >&5
+   (eval $ac_compiler --version </dev/null >&5) 2>&5
+   ac_status=$?
+-  echo "$as_me:1614: \$? = $ac_status" >&5
++  echo "$as_me:1618: \$? = $ac_status" >&5
+   (exit $ac_status); }
+-{ (eval echo "$as_me:1616: \"$ac_compiler -v </dev/null >&5\"") >&5
++{ (eval echo "$as_me:1620: \"$ac_compiler -v </dev/null >&5\"") >&5
+   (eval $ac_compiler -v </dev/null >&5) 2>&5
+   ac_status=$?
+-  echo "$as_me:1619: \$? = $ac_status" >&5
++  echo "$as_me:1623: \$? = $ac_status" >&5
+   (exit $ac_status); }
+-{ (eval echo "$as_me:1621: \"$ac_compiler -V </dev/null >&5\"") >&5
++{ (eval echo "$as_me:1625: \"$ac_compiler -V </dev/null >&5\"") >&5
+   (eval $ac_compiler -V </dev/null >&5) 2>&5
+   ac_status=$?
+-  echo "$as_me:1624: \$? = $ac_status" >&5
++  echo "$as_me:1628: \$? = $ac_status" >&5
+   (exit $ac_status); }
+ 
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 1628 "configure"
++#line 1632 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -1641,13 +1645,13 @@
+ # Try to create an executable without -o first, disregard a.out.
+ # It will help us diagnose broken compilers, and finding out an intuition
+ # of exeext.
+-echo "$as_me:1644: checking for C compiler default output" >&5
++echo "$as_me:1648: checking for C compiler default output" >&5
+ echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6
+ ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+-if { (eval echo "$as_me:1647: \"$ac_link_default\"") >&5
++if { (eval echo "$as_me:1651: \"$ac_link_default\"") >&5
+   (eval $ac_link_default) 2>&5
+   ac_status=$?
+-  echo "$as_me:1650: \$? = $ac_status" >&5
++  echo "$as_me:1654: \$? = $ac_status" >&5
+   (exit $ac_status); }; then
+   # Find the output, starting from the most likely.  This scheme is
+ # not robust to junk in `.', hence go to wildcards (a.*) only as a last
+@@ -1670,34 +1674,34 @@
+ else
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+-{ { echo "$as_me:1673: error: C compiler cannot create executables" >&5
++{ { echo "$as_me:1677: error: C compiler cannot create executables" >&5
+ echo "$as_me: error: C compiler cannot create executables" >&2;}
+    { (exit 77); exit 77; }; }
+ fi
+ 
+ ac_exeext=$ac_cv_exeext
+-echo "$as_me:1679: result: $ac_file" >&5
++echo "$as_me:1683: result: $ac_file" >&5
+ echo "${ECHO_T}$ac_file" >&6
+ 
+ # Check the compiler produces executables we can run.  If not, either
+ # the compiler is broken, or we cross compile.
+-echo "$as_me:1684: checking whether the C compiler works" >&5
++echo "$as_me:1688: checking whether the C compiler works" >&5
+ echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+ # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+ # If not cross compiling, check that we can run a simple program.
+ if test "$cross_compiling" != yes; then
+   if { ac_try='./$ac_file'
+-  { (eval echo "$as_me:1690: \"$ac_try\"") >&5
++  { (eval echo "$as_me:1694: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:1693: \$? = $ac_status" >&5
++  echo "$as_me:1697: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+     cross_compiling=no
+   else
+     if test "$cross_compiling" = maybe; then
+ 	cross_compiling=yes
+     else
+-	{ { echo "$as_me:1700: error: cannot run C compiled programs.
++	{ { echo "$as_me:1704: error: cannot run C compiled programs.
+ If you meant to cross compile, use \`--host'." >&5
+ echo "$as_me: error: cannot run C compiled programs.
+ If you meant to cross compile, use \`--host'." >&2;}
+@@ -1705,24 +1709,24 @@
+     fi
+   fi
+ fi
+-echo "$as_me:1708: result: yes" >&5
++echo "$as_me:1712: result: yes" >&5
+ echo "${ECHO_T}yes" >&6
+ 
+ rm -f a.out a.exe conftest$ac_cv_exeext
+ ac_clean_files=$ac_clean_files_save
+ # Check the compiler produces executables we can run.  If not, either
+ # the compiler is broken, or we cross compile.
+-echo "$as_me:1715: checking whether we are cross compiling" >&5
++echo "$as_me:1719: checking whether we are cross compiling" >&5
+ echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+-echo "$as_me:1717: result: $cross_compiling" >&5
++echo "$as_me:1721: result: $cross_compiling" >&5
+ echo "${ECHO_T}$cross_compiling" >&6
+ 
+-echo "$as_me:1720: checking for executable suffix" >&5
++echo "$as_me:1724: checking for executable suffix" >&5
+ echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6
+-if { (eval echo "$as_me:1722: \"$ac_link\"") >&5
++if { (eval echo "$as_me:1726: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:1725: \$? = $ac_status" >&5
++  echo "$as_me:1729: \$? = $ac_status" >&5
+   (exit $ac_status); }; then
+   # If both `conftest.exe' and `conftest' are `present' (well, observable)
+ # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+@@ -1738,25 +1742,25 @@
+   esac
+ done
+ else
+-  { { echo "$as_me:1741: error: cannot compute EXEEXT: cannot compile and link" >&5
++  { { echo "$as_me:1745: error: cannot compute EXEEXT: cannot compile and link" >&5
+ echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+ 
+ rm -f conftest$ac_cv_exeext
+-echo "$as_me:1747: result: $ac_cv_exeext" >&5
++echo "$as_me:1751: result: $ac_cv_exeext" >&5
+ echo "${ECHO_T}$ac_cv_exeext" >&6
+ 
+ rm -f conftest.$ac_ext
+ EXEEXT=$ac_cv_exeext
+ ac_exeext=$EXEEXT
+-echo "$as_me:1753: checking for object suffix" >&5
++echo "$as_me:1757: checking for object suffix" >&5
+ echo $ECHO_N "checking for object suffix... $ECHO_C" >&6
+ if test "${ac_cv_objext+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 1759 "configure"
++#line 1763 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -1768,10 +1772,10 @@
+ }
+ _ACEOF
+ rm -f conftest.o conftest.obj
+-if { (eval echo "$as_me:1771: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:1775: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:1774: \$? = $ac_status" >&5
++  echo "$as_me:1778: \$? = $ac_status" >&5
+   (exit $ac_status); }; then
+   for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+   case $ac_file in
+@@ -1783,24 +1787,24 @@
+ else
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+-{ { echo "$as_me:1786: error: cannot compute OBJEXT: cannot compile" >&5
++{ { echo "$as_me:1790: error: cannot compute OBJEXT: cannot compile" >&5
+ echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+ 
+ rm -f conftest.$ac_cv_objext conftest.$ac_ext
+ fi
+-echo "$as_me:1793: result: $ac_cv_objext" >&5
++echo "$as_me:1797: result: $ac_cv_objext" >&5
+ echo "${ECHO_T}$ac_cv_objext" >&6
+ OBJEXT=$ac_cv_objext
+ ac_objext=$OBJEXT
+-echo "$as_me:1797: checking whether we are using the GNU C compiler" >&5
++echo "$as_me:1801: checking whether we are using the GNU C compiler" >&5
+ echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+ if test "${ac_cv_c_compiler_gnu+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 1803 "configure"
++#line 1807 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -1815,16 +1819,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:1818: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:1822: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:1821: \$? = $ac_status" >&5
++  echo "$as_me:1825: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:1824: \"$ac_try\"") >&5
++  { (eval echo "$as_me:1828: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:1827: \$? = $ac_status" >&5
++  echo "$as_me:1831: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_compiler_gnu=yes
+ else
+@@ -1836,19 +1840,19 @@
+ ac_cv_c_compiler_gnu=$ac_compiler_gnu
+ 
+ fi
+-echo "$as_me:1839: result: $ac_cv_c_compiler_gnu" >&5
++echo "$as_me:1843: result: $ac_cv_c_compiler_gnu" >&5
+ echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+ GCC=`test $ac_compiler_gnu = yes && echo yes`
+ ac_test_CFLAGS=${CFLAGS+set}
+ ac_save_CFLAGS=$CFLAGS
+ CFLAGS="-g"
+-echo "$as_me:1845: checking whether $CC accepts -g" >&5
++echo "$as_me:1849: checking whether $CC accepts -g" >&5
+ echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+ if test "${ac_cv_prog_cc_g+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 1851 "configure"
++#line 1855 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -1860,16 +1864,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:1863: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:1867: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:1866: \$? = $ac_status" >&5
++  echo "$as_me:1870: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:1869: \"$ac_try\"") >&5
++  { (eval echo "$as_me:1873: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:1872: \$? = $ac_status" >&5
++  echo "$as_me:1876: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_prog_cc_g=yes
+ else
+@@ -1879,7 +1883,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+-echo "$as_me:1882: result: $ac_cv_prog_cc_g" >&5
++echo "$as_me:1886: result: $ac_cv_prog_cc_g" >&5
+ echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+ if test "$ac_test_CFLAGS" = set; then
+   CFLAGS=$ac_save_CFLAGS
+@@ -1906,16 +1910,16 @@
+ #endif
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:1909: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:1913: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:1912: \$? = $ac_status" >&5
++  echo "$as_me:1916: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:1915: \"$ac_try\"") >&5
++  { (eval echo "$as_me:1919: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:1918: \$? = $ac_status" >&5
++  echo "$as_me:1922: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   for ac_declaration in \
+    ''\
+@@ -1927,7 +1931,7 @@
+    'void exit (int);'
+ do
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 1930 "configure"
++#line 1934 "configure"
+ #include "confdefs.h"
+ #include <stdlib.h>
+ $ac_declaration
+@@ -1940,16 +1944,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:1943: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:1947: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:1946: \$? = $ac_status" >&5
++  echo "$as_me:1950: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:1949: \"$ac_try\"") >&5
++  { (eval echo "$as_me:1953: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:1952: \$? = $ac_status" >&5
++  echo "$as_me:1956: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   :
+ else
+@@ -1959,7 +1963,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 1962 "configure"
++#line 1966 "configure"
+ #include "confdefs.h"
+ $ac_declaration
+ int
+@@ -1971,16 +1975,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:1974: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:1978: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:1977: \$? = $ac_status" >&5
++  echo "$as_me:1981: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:1980: \"$ac_try\"") >&5
++  { (eval echo "$as_me:1984: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:1983: \$? = $ac_status" >&5
++  echo "$as_me:1987: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   break
+ else
+@@ -2009,11 +2013,11 @@
+ 
+ GCC_VERSION=none
+ if test "$GCC" = yes ; then
+-	echo "$as_me:2012: checking version of $CC" >&5
++	echo "$as_me:2016: checking version of $CC" >&5
+ echo $ECHO_N "checking version of $CC... $ECHO_C" >&6
+ 	GCC_VERSION="`${CC} --version|sed -e '2,$d' -e 's/^[^0-9.]*//' -e 's/[^0-9.].*//'`"
+ 	test -z "$GCC_VERSION" && GCC_VERSION=unknown
+-	echo "$as_me:2016: result: $GCC_VERSION" >&5
++	echo "$as_me:2020: result: $GCC_VERSION" >&5
+ echo "${ECHO_T}$GCC_VERSION" >&6
+ fi
+ 
+@@ -2022,7 +2026,7 @@
+ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+-echo "$as_me:2025: checking how to run the C preprocessor" >&5
++echo "$as_me:2029: checking how to run the C preprocessor" >&5
+ echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+ # On Suns, sometimes $CPP names a directory.
+ if test -n "$CPP" && test -d "$CPP"; then
+@@ -2043,18 +2047,18 @@
+   # On the NeXT, cc -E runs the code through the compiler's parser,
+   # not just through cpp. "Syntax error" is here to catch this case.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 2046 "configure"
++#line 2050 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+                      Syntax error
+ _ACEOF
+-if { (eval echo "$as_me:2051: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:2055: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:2057: \$? = $ac_status" >&5
++  echo "$as_me:2061: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+@@ -2077,17 +2081,17 @@
+   # OK, works on sane cases.  Now check whether non-existent headers
+   # can be detected and how.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 2080 "configure"
++#line 2084 "configure"
+ #include "confdefs.h"
+ #include <ac_nonexistent.h>
+ _ACEOF
+-if { (eval echo "$as_me:2084: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:2088: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:2090: \$? = $ac_status" >&5
++  echo "$as_me:2094: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+@@ -2124,7 +2128,7 @@
+ else
+   ac_cv_prog_CPP=$CPP
+ fi
+-echo "$as_me:2127: result: $CPP" >&5
++echo "$as_me:2131: result: $CPP" >&5
+ echo "${ECHO_T}$CPP" >&6
+ ac_preproc_ok=false
+ for ac_c_preproc_warn_flag in '' yes
+@@ -2134,18 +2138,18 @@
+   # On the NeXT, cc -E runs the code through the compiler's parser,
+   # not just through cpp. "Syntax error" is here to catch this case.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 2137 "configure"
++#line 2141 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+                      Syntax error
+ _ACEOF
+-if { (eval echo "$as_me:2142: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:2146: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:2148: \$? = $ac_status" >&5
++  echo "$as_me:2152: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+@@ -2168,17 +2172,17 @@
+   # OK, works on sane cases.  Now check whether non-existent headers
+   # can be detected and how.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 2171 "configure"
++#line 2175 "configure"
+ #include "confdefs.h"
+ #include <ac_nonexistent.h>
+ _ACEOF
+-if { (eval echo "$as_me:2175: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:2179: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:2181: \$? = $ac_status" >&5
++  echo "$as_me:2185: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+@@ -2206,7 +2210,7 @@
+ if $ac_preproc_ok; then
+   :
+ else
+-  { { echo "$as_me:2209: error: C preprocessor \"$CPP\" fails sanity check" >&5
++  { { echo "$as_me:2213: error: C preprocessor \"$CPP\" fails sanity check" >&5
+ echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+@@ -2218,14 +2222,14 @@
+ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ 
+ if test $ac_cv_c_compiler_gnu = yes; then
+-    echo "$as_me:2221: checking whether $CC needs -traditional" >&5
++    echo "$as_me:2225: checking whether $CC needs -traditional" >&5
+ echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6
+ if test "${ac_cv_prog_gcc_traditional+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+     ac_pattern="Autoconf.*'x'"
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 2228 "configure"
++#line 2232 "configure"
+ #include "confdefs.h"
+ #include <sgtty.h>
+ int Autoconf = TIOCGETP;
+@@ -2240,7 +2244,7 @@
+ 
+   if test $ac_cv_prog_gcc_traditional = no; then
+     cat >conftest.$ac_ext <<_ACEOF
+-#line 2243 "configure"
++#line 2247 "configure"
+ #include "confdefs.h"
+ #include <termio.h>
+ int Autoconf = TCGETA;
+@@ -2253,19 +2257,61 @@
+ 
+   fi
+ fi
+-echo "$as_me:2256: result: $ac_cv_prog_gcc_traditional" >&5
++echo "$as_me:2260: result: $ac_cv_prog_gcc_traditional" >&5
+ echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6
+   if test $ac_cv_prog_gcc_traditional = yes; then
+     CC="$CC -traditional"
+   fi
+ fi
+ 
+-echo "$as_me:2263: checking for POSIXized ISC" >&5
++echo "$as_me:2267: checking whether $CC understands -c and -o together" >&5
++echo $ECHO_N "checking whether $CC understands -c and -o together... $ECHO_C" >&6
++if test "${cf_cv_prog_CC_c_o+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++
++cat > conftest.$ac_ext <<CF_EOF
++#include <stdio.h>
++int main()
++{
++	return 0;
++}
++CF_EOF
++# We do the test twice because some compilers refuse to overwrite an
++# existing .o file with -o, though they will create one.
++ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
++if { (eval echo "$as_me:2283: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:2286: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++  test -f conftest2.$ac_objext && { (eval echo "$as_me:2288: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:2291: \$? = $ac_status" >&5
++  (exit $ac_status); };
++then
++  eval cf_cv_prog_CC_c_o=yes
++else
++  eval cf_cv_prog_CC_c_o=no
++fi
++rm -f conftest*
++
++fi
++if test $cf_cv_prog_CC_c_o = yes; then
++  echo "$as_me:2302: result: yes" >&5
++echo "${ECHO_T}yes" >&6
++else
++  echo "$as_me:2305: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
++echo "$as_me:2309: checking for POSIXized ISC" >&5
+ echo $ECHO_N "checking for POSIXized ISC... $ECHO_C" >&6
+ if test -d /etc/conf/kconfig.d &&
+    grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
+ then
+-  echo "$as_me:2268: result: yes" >&5
++  echo "$as_me:2314: result: yes" >&5
+ echo "${ECHO_T}yes" >&6
+   ISC=yes # If later tests want to check for ISC.
+ 
+@@ -2279,12 +2325,12 @@
+     CC="$CC -Xp"
+   fi
+ else
+-  echo "$as_me:2282: result: no" >&5
++  echo "$as_me:2328: result: no" >&5
+ echo "${ECHO_T}no" >&6
+   ISC=
+ fi
+ 
+-echo "$as_me:2287: checking for ${CC-cc} option to accept ANSI C" >&5
++echo "$as_me:2333: checking for ${CC-cc} option to accept ANSI C" >&5
+ echo $ECHO_N "checking for ${CC-cc} option to accept ANSI C... $ECHO_C" >&6
+ if test "${cf_cv_ansi_cc+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -2309,12 +2355,34 @@
+ 	-Xc
+ do
+ 
++cf_fix_cppflags=no
+ cf_new_cflags=
+ cf_new_cppflags=
++cf_new_extra_cppflags=
++
+ for cf_add_cflags in $cf_arg
+ do
++case $cf_fix_cppflags in
++no)
+ 	case $cf_add_cflags in #(vi
+ 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
++		case $cf_add_cflags in
++		-D*)
++			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
++
++			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++			&& test -z "${cf_tst_cflags}" \
++			&& cf_fix_cppflags=yes
++
++			if test $cf_fix_cppflags = yes ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			elif test "${cf_tst_cflags}" = "\"'" ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			fi
++			;;
++		esac
+ 		case "$CPPFLAGS" in
+ 		*$cf_add_cflags) #(vi
+ 			;;
+@@ -2327,6 +2395,17 @@
+ 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ 		;;
+ 	esac
++	;;
++yes)
++	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++
++	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
++
++	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++	&& test -z "${cf_tst_cflags}" \
++	&& cf_fix_cppflags=no
++	;;
++esac
+ done
+ 
+ if test -n "$cf_new_cflags" ; then
+@@ -2339,8 +2418,13 @@
+ 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
+ fi
+ 
++if test -n "$cf_new_extra_cppflags" ; then
++
++	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
++fi
++
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 2343 "configure"
++#line 2427 "configure"
+ #include "confdefs.h"
+ 
+ #ifndef CC_HAS_PROTOS
+@@ -2361,16 +2445,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:2364: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:2448: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:2367: \$? = $ac_status" >&5
++  echo "$as_me:2451: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:2370: \"$ac_try\"") >&5
++  { (eval echo "$as_me:2454: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:2373: \$? = $ac_status" >&5
++  echo "$as_me:2457: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_ansi_cc="$cf_arg"; break
+ else
+@@ -2383,18 +2467,40 @@
+ CPPFLAGS="$cf_save_CPPFLAGS"
+ 
+ fi
+-echo "$as_me:2386: result: $cf_cv_ansi_cc" >&5
++echo "$as_me:2470: result: $cf_cv_ansi_cc" >&5
+ echo "${ECHO_T}$cf_cv_ansi_cc" >&6
+ 
+ if test "$cf_cv_ansi_cc" != "no"; then
+ if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
+ 
++cf_fix_cppflags=no
+ cf_new_cflags=
+ cf_new_cppflags=
++cf_new_extra_cppflags=
++
+ for cf_add_cflags in $cf_cv_ansi_cc
+ do
++case $cf_fix_cppflags in
++no)
+ 	case $cf_add_cflags in #(vi
+ 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
++		case $cf_add_cflags in
++		-D*)
++			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
++
++			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++			&& test -z "${cf_tst_cflags}" \
++			&& cf_fix_cppflags=yes
++
++			if test $cf_fix_cppflags = yes ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			elif test "${cf_tst_cflags}" = "\"'" ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			fi
++			;;
++		esac
+ 		case "$CPPFLAGS" in
+ 		*$cf_add_cflags) #(vi
+ 			;;
+@@ -2407,6 +2513,17 @@
+ 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ 		;;
+ 	esac
++	;;
++yes)
++	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++
++	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
++
++	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++	&& test -z "${cf_tst_cflags}" \
++	&& cf_fix_cppflags=no
++	;;
++esac
+ done
+ 
+ if test -n "$cf_new_cflags" ; then
+@@ -2419,6 +2536,11 @@
+ 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
+ fi
+ 
++if test -n "$cf_new_extra_cppflags" ; then
++
++	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
++fi
++
+ else
+ 	cat >>confdefs.h <<\EOF
+ #define CC_HAS_PROTOS 1
+@@ -2428,7 +2550,7 @@
+ fi
+ 
+ if test "$cf_cv_ansi_cc" = "no"; then
+-	{ { echo "$as_me:2431: error: Your compiler does not appear to recognize prototypes.
++	{ { echo "$as_me:2553: error: Your compiler does not appear to recognize prototypes.
+ You have the following choices:
+ 	a. adjust your compiler options
+ 	b. get an up-to-date compiler
+@@ -2468,7 +2590,7 @@
+ *) LDPATH=$PATH:/sbin:/usr/sbin
+   # Extract the first word of "ldconfig", so it can be a program name with args.
+ set dummy ldconfig; ac_word=$2
+-echo "$as_me:2471: checking for $ac_word" >&5
++echo "$as_me:2593: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_path_LDCONFIG+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -2485,7 +2607,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   if $as_executable_p "$ac_dir/$ac_word"; then
+    ac_cv_path_LDCONFIG="$ac_dir/$ac_word"
+-   echo "$as_me:2488: found $ac_dir/$ac_word" >&5
++   echo "$as_me:2610: found $ac_dir/$ac_word" >&5
+    break
+ fi
+ done
+@@ -2496,10 +2618,10 @@
+ LDCONFIG=$ac_cv_path_LDCONFIG
+ 
+ if test -n "$LDCONFIG"; then
+-  echo "$as_me:2499: result: $LDCONFIG" >&5
++  echo "$as_me:2621: result: $LDCONFIG" >&5
+ echo "${ECHO_T}$LDCONFIG" >&6
+ else
+-  echo "$as_me:2502: result: no" >&5
++  echo "$as_me:2624: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -2507,7 +2629,7 @@
+ esac
+ fi
+ 
+-echo "$as_me:2510: checking if you want to ensure bool is consistent with C++" >&5
++echo "$as_me:2632: checking if you want to ensure bool is consistent with C++" >&5
+ echo $ECHO_N "checking if you want to ensure bool is consistent with C++... $ECHO_C" >&6
+ 
+ # Check whether --with-cxx or --without-cxx was given.
+@@ -2517,7 +2639,7 @@
+ else
+   cf_with_cxx=yes
+ fi;
+-echo "$as_me:2520: result: $cf_with_cxx" >&5
++echo "$as_me:2642: result: $cf_with_cxx" >&5
+ echo "${ECHO_T}$cf_with_cxx" >&6
+ if test "X$cf_with_cxx" = Xno ; then
+ 	CXX=""
+@@ -2534,7 +2656,7 @@
+   do
+     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+ set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+-echo "$as_me:2537: checking for $ac_word" >&5
++echo "$as_me:2659: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_CXX+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -2549,7 +2671,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+-echo "$as_me:2552: found $ac_dir/$ac_word" >&5
++echo "$as_me:2674: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -2557,10 +2679,10 @@
+ fi
+ CXX=$ac_cv_prog_CXX
+ if test -n "$CXX"; then
+-  echo "$as_me:2560: result: $CXX" >&5
++  echo "$as_me:2682: result: $CXX" >&5
+ echo "${ECHO_T}$CXX" >&6
+ else
+-  echo "$as_me:2563: result: no" >&5
++  echo "$as_me:2685: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -2573,7 +2695,7 @@
+ do
+   # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+-echo "$as_me:2576: checking for $ac_word" >&5
++echo "$as_me:2698: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -2588,7 +2710,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_ac_ct_CXX="$ac_prog"
+-echo "$as_me:2591: found $ac_dir/$ac_word" >&5
++echo "$as_me:2713: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -2596,10 +2718,10 @@
+ fi
+ ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+ if test -n "$ac_ct_CXX"; then
+-  echo "$as_me:2599: result: $ac_ct_CXX" >&5
++  echo "$as_me:2721: result: $ac_ct_CXX" >&5
+ echo "${ECHO_T}$ac_ct_CXX" >&6
+ else
+-  echo "$as_me:2602: result: no" >&5
++  echo "$as_me:2724: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -2611,32 +2733,32 @@
+ fi
+ 
+ # Provide some information about the compiler.
+-echo "$as_me:2614:" \
++echo "$as_me:2736:" \
+      "checking for C++ compiler version" >&5
+ ac_compiler=`set X $ac_compile; echo $2`
+-{ (eval echo "$as_me:2617: \"$ac_compiler --version </dev/null >&5\"") >&5
++{ (eval echo "$as_me:2739: \"$ac_compiler --version </dev/null >&5\"") >&5
+   (eval $ac_compiler --version </dev/null >&5) 2>&5
+   ac_status=$?
+-  echo "$as_me:2620: \$? = $ac_status" >&5
++  echo "$as_me:2742: \$? = $ac_status" >&5
+   (exit $ac_status); }
+-{ (eval echo "$as_me:2622: \"$ac_compiler -v </dev/null >&5\"") >&5
++{ (eval echo "$as_me:2744: \"$ac_compiler -v </dev/null >&5\"") >&5
+   (eval $ac_compiler -v </dev/null >&5) 2>&5
+   ac_status=$?
+-  echo "$as_me:2625: \$? = $ac_status" >&5
++  echo "$as_me:2747: \$? = $ac_status" >&5
+   (exit $ac_status); }
+-{ (eval echo "$as_me:2627: \"$ac_compiler -V </dev/null >&5\"") >&5
++{ (eval echo "$as_me:2749: \"$ac_compiler -V </dev/null >&5\"") >&5
+   (eval $ac_compiler -V </dev/null >&5) 2>&5
+   ac_status=$?
+-  echo "$as_me:2630: \$? = $ac_status" >&5
++  echo "$as_me:2752: \$? = $ac_status" >&5
+   (exit $ac_status); }
+ 
+-echo "$as_me:2633: checking whether we are using the GNU C++ compiler" >&5
++echo "$as_me:2755: checking whether we are using the GNU C++ compiler" >&5
+ echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
+ if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 2639 "configure"
++#line 2761 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -2651,16 +2773,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:2654: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:2776: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:2657: \$? = $ac_status" >&5
++  echo "$as_me:2779: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:2660: \"$ac_try\"") >&5
++  { (eval echo "$as_me:2782: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:2663: \$? = $ac_status" >&5
++  echo "$as_me:2785: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_compiler_gnu=yes
+ else
+@@ -2672,19 +2794,19 @@
+ ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+ 
+ fi
+-echo "$as_me:2675: result: $ac_cv_cxx_compiler_gnu" >&5
++echo "$as_me:2797: result: $ac_cv_cxx_compiler_gnu" >&5
+ echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
+ GXX=`test $ac_compiler_gnu = yes && echo yes`
+ ac_test_CXXFLAGS=${CXXFLAGS+set}
+ ac_save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="-g"
+-echo "$as_me:2681: checking whether $CXX accepts -g" >&5
++echo "$as_me:2803: checking whether $CXX accepts -g" >&5
+ echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
+ if test "${ac_cv_prog_cxx_g+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 2687 "configure"
++#line 2809 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -2696,16 +2818,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:2699: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:2821: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:2702: \$? = $ac_status" >&5
++  echo "$as_me:2824: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:2705: \"$ac_try\"") >&5
++  { (eval echo "$as_me:2827: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:2708: \$? = $ac_status" >&5
++  echo "$as_me:2830: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_prog_cxx_g=yes
+ else
+@@ -2715,7 +2837,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+-echo "$as_me:2718: result: $ac_cv_prog_cxx_g" >&5
++echo "$as_me:2840: result: $ac_cv_prog_cxx_g" >&5
+ echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
+ if test "$ac_test_CXXFLAGS" = set; then
+   CXXFLAGS=$ac_save_CXXFLAGS
+@@ -2742,7 +2864,7 @@
+    'void exit (int);'
+ do
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 2745 "configure"
++#line 2867 "configure"
+ #include "confdefs.h"
+ #include <stdlib.h>
+ $ac_declaration
+@@ -2755,16 +2877,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:2758: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:2880: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:2761: \$? = $ac_status" >&5
++  echo "$as_me:2883: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:2764: \"$ac_try\"") >&5
++  { (eval echo "$as_me:2886: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:2767: \$? = $ac_status" >&5
++  echo "$as_me:2889: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   :
+ else
+@@ -2774,7 +2896,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 2777 "configure"
++#line 2899 "configure"
+ #include "confdefs.h"
+ $ac_declaration
+ int
+@@ -2786,16 +2908,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:2789: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:2911: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:2792: \$? = $ac_status" >&5
++  echo "$as_me:2914: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:2795: \"$ac_try\"") >&5
++  { (eval echo "$as_me:2917: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:2798: \$? = $ac_status" >&5
++  echo "$as_me:2920: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   break
+ else
+@@ -2821,7 +2943,7 @@
+ 	if test "$CXX" = "g++" ; then
+ 		# Extract the first word of "g++", so it can be a program name with args.
+ set dummy g++; ac_word=$2
+-echo "$as_me:2824: checking for $ac_word" >&5
++echo "$as_me:2946: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_path_CXX+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -2838,7 +2960,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   if $as_executable_p "$ac_dir/$ac_word"; then
+    ac_cv_path_CXX="$ac_dir/$ac_word"
+-   echo "$as_me:2841: found $ac_dir/$ac_word" >&5
++   echo "$as_me:2963: found $ac_dir/$ac_word" >&5
+    break
+ fi
+ done
+@@ -2849,16 +2971,16 @@
+ CXX=$ac_cv_path_CXX
+ 
+ if test -n "$CXX"; then
+-  echo "$as_me:2852: result: $CXX" >&5
++  echo "$as_me:2974: result: $CXX" >&5
+ echo "${ECHO_T}$CXX" >&6
+ else
+-  echo "$as_me:2855: result: no" >&5
++  echo "$as_me:2977: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+ 	fi
+ 	if test "$CXX" = "g++" ; then
+-		{ echo "$as_me:2861: WARNING: ignoring hardcoded g++" >&5
++		{ echo "$as_me:2983: WARNING: ignoring hardcoded g++" >&5
+ echo "$as_me: WARNING: ignoring hardcoded g++" >&2;}
+ 		cf_with_cxx=no; CXX=""; GXX="";
+ 	fi
+@@ -2866,10 +2988,10 @@
+ 
+ GXX_VERSION=none
+ if test "$GXX" = yes; then
+-	echo "$as_me:2869: checking version of g++" >&5
++	echo "$as_me:2991: checking version of g++" >&5
+ echo $ECHO_N "checking version of g++... $ECHO_C" >&6
+ 	GXX_VERSION="`${CXX-g++} --version|sed -e '2,$d'`"
+-	echo "$as_me:2872: result: $GXX_VERSION" >&5
++	echo "$as_me:2994: result: $GXX_VERSION" >&5
+ echo "${ECHO_T}$GXX_VERSION" >&6
+ fi
+ 
+@@ -2877,12 +2999,12 @@
+ 1*|2.[0-6]*)
+ 	GXX=""; CXX=""; ac_cv_cxx_compiler_gnu=no
+ 	cf_cxx_library=no
+-	{ echo "$as_me:2880: WARNING: templates do not work" >&5
++	{ echo "$as_me:3002: WARNING: templates do not work" >&5
+ echo "$as_me: WARNING: templates do not work" >&2;}
+ 	;;
+ esac
+ 
+-echo "$as_me:2885: checking if you want to build C++ binding and demo" >&5
++echo "$as_me:3007: checking if you want to build C++ binding and demo" >&5
+ echo $ECHO_N "checking if you want to build C++ binding and demo... $ECHO_C" >&6
+ 
+ # Check whether --with-cxx-binding or --without-cxx-binding was given.
+@@ -2892,10 +3014,10 @@
+ else
+   cf_with_cxx_binding=$cf_with_cxx
+ fi;
+-echo "$as_me:2895: result: $cf_with_cxx_binding" >&5
++echo "$as_me:3017: result: $cf_with_cxx_binding" >&5
+ echo "${ECHO_T}$cf_with_cxx_binding" >&6
+ 
+-echo "$as_me:2898: checking if you want to build with Ada95" >&5
++echo "$as_me:3020: checking if you want to build with Ada95" >&5
+ echo $ECHO_N "checking if you want to build with Ada95... $ECHO_C" >&6
+ 
+ # Check whether --with-ada or --without-ada was given.
+@@ -2905,10 +3027,10 @@
+ else
+   cf_with_ada=yes
+ fi;
+-echo "$as_me:2908: result: $cf_with_ada" >&5
++echo "$as_me:3030: result: $cf_with_ada" >&5
+ echo "${ECHO_T}$cf_with_ada" >&6
+ 
+-echo "$as_me:2911: checking if you want to build programs such as tic" >&5
++echo "$as_me:3033: checking if you want to build programs such as tic" >&5
+ echo $ECHO_N "checking if you want to build programs such as tic... $ECHO_C" >&6
+ 
+ # Check whether --with-progs or --without-progs was given.
+@@ -2918,10 +3040,10 @@
+ else
+   cf_with_progs=yes
+ fi;
+-echo "$as_me:2921: result: $cf_with_progs" >&5
++echo "$as_me:3043: result: $cf_with_progs" >&5
+ echo "${ECHO_T}$cf_with_progs" >&6
+ 
+-echo "$as_me:2924: checking if you wish to install curses.h" >&5
++echo "$as_me:3046: checking if you wish to install curses.h" >&5
+ echo $ECHO_N "checking if you wish to install curses.h... $ECHO_C" >&6
+ 
+ # Check whether --with-curses-h or --without-curses-h was given.
+@@ -2931,7 +3053,7 @@
+ else
+   with_curses_h=yes
+ fi;
+-echo "$as_me:2934: result: $with_curses_h" >&5
++echo "$as_me:3056: result: $with_curses_h" >&5
+ echo "${ECHO_T}$with_curses_h" >&6
+ 
+ modules_to_build="ncurses"
+@@ -2957,7 +3079,7 @@
+ do
+   # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+-echo "$as_me:2960: checking for $ac_word" >&5
++echo "$as_me:3082: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_AWK+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -2972,7 +3094,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_AWK="$ac_prog"
+-echo "$as_me:2975: found $ac_dir/$ac_word" >&5
++echo "$as_me:3097: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -2980,17 +3102,17 @@
+ fi
+ AWK=$ac_cv_prog_AWK
+ if test -n "$AWK"; then
+-  echo "$as_me:2983: result: $AWK" >&5
++  echo "$as_me:3105: result: $AWK" >&5
+ echo "${ECHO_T}$AWK" >&6
+ else
+-  echo "$as_me:2986: result: no" >&5
++  echo "$as_me:3108: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+   test -n "$AWK" && break
+ done
+ 
+-echo "$as_me:2993: checking whether ${MAKE-make} sets \${MAKE}" >&5
++echo "$as_me:3115: checking whether ${MAKE-make} sets \${MAKE}" >&5
+ echo $ECHO_N "checking whether ${MAKE-make} sets \${MAKE}... $ECHO_C" >&6
+ set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'`
+ if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
+@@ -3010,11 +3132,11 @@
+ rm -f conftest.make
+ fi
+ if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+-  echo "$as_me:3013: result: yes" >&5
++  echo "$as_me:3135: result: yes" >&5
+ echo "${ECHO_T}yes" >&6
+   SET_MAKE=
+ else
+-  echo "$as_me:3017: result: no" >&5
++  echo "$as_me:3139: result: no" >&5
+ echo "${ECHO_T}no" >&6
+   SET_MAKE="MAKE=${MAKE-make}"
+ fi
+@@ -3031,7 +3153,7 @@
+ # AFS /usr/afsws/bin/install, which mishandles nonexistent args
+ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+ # ./install, which can be erroneously created by make from ./install.sh.
+-echo "$as_me:3034: checking for a BSD compatible install" >&5
++echo "$as_me:3156: checking for a BSD compatible install" >&5
+ echo $ECHO_N "checking for a BSD compatible install... $ECHO_C" >&6
+ if test -z "$INSTALL"; then
+ if test "${ac_cv_path_install+set}" = set; then
+@@ -3080,7 +3202,7 @@
+     INSTALL=$ac_install_sh
+   fi
+ fi
+-echo "$as_me:3083: result: $INSTALL" >&5
++echo "$as_me:3205: result: $INSTALL" >&5
+ echo "${ECHO_T}$INSTALL" >&6
+ 
+ # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+@@ -3101,7 +3223,7 @@
+   ;;
+ esac
+ 
+-echo "$as_me:3104: checking for long file names" >&5
++echo "$as_me:3226: checking for long file names" >&5
+ echo $ECHO_N "checking for long file names... $ECHO_C" >&6
+ if test "${ac_cv_sys_long_file_names+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3140,7 +3262,7 @@
+   rm -rf $ac_xdir 2>/dev/null
+ done
+ fi
+-echo "$as_me:3143: result: $ac_cv_sys_long_file_names" >&5
++echo "$as_me:3265: result: $ac_cv_sys_long_file_names" >&5
+ echo "${ECHO_T}$ac_cv_sys_long_file_names" >&6
+ if test $ac_cv_sys_long_file_names = yes; then
+ 
+@@ -3150,7 +3272,7 @@
+ 
+ fi
+ 
+-echo "$as_me:3153: checking if filesystem supports mixed-case filenames" >&5
++echo "$as_me:3275: checking if filesystem supports mixed-case filenames" >&5
+ echo $ECHO_N "checking if filesystem supports mixed-case filenames... $ECHO_C" >&6
+ if test "${cf_cv_mixedcase+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3177,26 +3299,26 @@
+ fi
+ 
+ fi
+-echo "$as_me:3180: result: $cf_cv_mixedcase" >&5
++echo "$as_me:3302: result: $cf_cv_mixedcase" >&5
+ echo "${ECHO_T}$cf_cv_mixedcase" >&6
+ test "$cf_cv_mixedcase" = yes && cat >>confdefs.h <<\EOF
+ #define MIXEDCASE_FILENAMES 1
+ EOF
+ 
+-echo "$as_me:3186: checking whether ln -s works" >&5
++echo "$as_me:3308: checking whether ln -s works" >&5
+ echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
+ LN_S=$as_ln_s
+ if test "$LN_S" = "ln -s"; then
+-  echo "$as_me:3190: result: yes" >&5
++  echo "$as_me:3312: result: yes" >&5
+ echo "${ECHO_T}yes" >&6
+ else
+-  echo "$as_me:3193: result: no, using $LN_S" >&5
++  echo "$as_me:3315: result: no, using $LN_S" >&5
+ echo "${ECHO_T}no, using $LN_S" >&6
+ fi
+ 
+ # Extract the first word of "ctags", so it can be a program name with args.
+ set dummy ctags; ac_word=$2
+-echo "$as_me:3199: checking for $ac_word" >&5
++echo "$as_me:3321: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_MAKE_LOWER_TAGS+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3211,7 +3333,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_MAKE_LOWER_TAGS="yes"
+-echo "$as_me:3214: found $ac_dir/$ac_word" >&5
++echo "$as_me:3336: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3220,17 +3342,17 @@
+ fi
+ MAKE_LOWER_TAGS=$ac_cv_prog_MAKE_LOWER_TAGS
+ if test -n "$MAKE_LOWER_TAGS"; then
+-  echo "$as_me:3223: result: $MAKE_LOWER_TAGS" >&5
++  echo "$as_me:3345: result: $MAKE_LOWER_TAGS" >&5
+ echo "${ECHO_T}$MAKE_LOWER_TAGS" >&6
+ else
+-  echo "$as_me:3226: result: no" >&5
++  echo "$as_me:3348: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+ if test "$cf_cv_mixedcase" = yes ; then
+ 	# Extract the first word of "etags", so it can be a program name with args.
+ set dummy etags; ac_word=$2
+-echo "$as_me:3233: checking for $ac_word" >&5
++echo "$as_me:3355: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_MAKE_UPPER_TAGS+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3245,7 +3367,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_MAKE_UPPER_TAGS="yes"
+-echo "$as_me:3248: found $ac_dir/$ac_word" >&5
++echo "$as_me:3370: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3254,10 +3376,10 @@
+ fi
+ MAKE_UPPER_TAGS=$ac_cv_prog_MAKE_UPPER_TAGS
+ if test -n "$MAKE_UPPER_TAGS"; then
+-  echo "$as_me:3257: result: $MAKE_UPPER_TAGS" >&5
++  echo "$as_me:3379: result: $MAKE_UPPER_TAGS" >&5
+ echo "${ECHO_T}$MAKE_UPPER_TAGS" >&6
+ else
+-  echo "$as_me:3260: result: no" >&5
++  echo "$as_me:3382: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3281,7 +3403,7 @@
+ do
+   # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+-echo "$as_me:3284: checking for $ac_word" >&5
++echo "$as_me:3406: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_LINT+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3296,7 +3418,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_LINT="$ac_prog"
+-echo "$as_me:3299: found $ac_dir/$ac_word" >&5
++echo "$as_me:3421: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3304,10 +3426,10 @@
+ fi
+ LINT=$ac_cv_prog_LINT
+ if test -n "$LINT"; then
+-  echo "$as_me:3307: result: $LINT" >&5
++  echo "$as_me:3429: result: $LINT" >&5
+ echo "${ECHO_T}$LINT" >&6
+ else
+-  echo "$as_me:3310: result: no" >&5
++  echo "$as_me:3432: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3318,7 +3440,7 @@
+ do
+   # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+-echo "$as_me:3321: checking for $ac_word" >&5
++echo "$as_me:3443: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_MAN+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3333,7 +3455,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_MAN="$ac_prog"
+-echo "$as_me:3336: found $ac_dir/$ac_word" >&5
++echo "$as_me:3458: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3341,10 +3463,10 @@
+ fi
+ MAN=$ac_cv_prog_MAN
+ if test -n "$MAN"; then
+-  echo "$as_me:3344: result: $MAN" >&5
++  echo "$as_me:3466: result: $MAN" >&5
+ echo "${ECHO_T}$MAN" >&6
+ else
+-  echo "$as_me:3347: result: no" >&5
++  echo "$as_me:3469: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3354,7 +3476,7 @@
+ if test -n "$ac_tool_prefix"; then
+   # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+ set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+-echo "$as_me:3357: checking for $ac_word" >&5
++echo "$as_me:3479: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_RANLIB+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3369,7 +3491,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+-echo "$as_me:3372: found $ac_dir/$ac_word" >&5
++echo "$as_me:3494: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3377,10 +3499,10 @@
+ fi
+ RANLIB=$ac_cv_prog_RANLIB
+ if test -n "$RANLIB"; then
+-  echo "$as_me:3380: result: $RANLIB" >&5
++  echo "$as_me:3502: result: $RANLIB" >&5
+ echo "${ECHO_T}$RANLIB" >&6
+ else
+-  echo "$as_me:3383: result: no" >&5
++  echo "$as_me:3505: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3389,7 +3511,7 @@
+   ac_ct_RANLIB=$RANLIB
+   # Extract the first word of "ranlib", so it can be a program name with args.
+ set dummy ranlib; ac_word=$2
+-echo "$as_me:3392: checking for $ac_word" >&5
++echo "$as_me:3514: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3404,7 +3526,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+-echo "$as_me:3407: found $ac_dir/$ac_word" >&5
++echo "$as_me:3529: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3413,10 +3535,10 @@
+ fi
+ ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+ if test -n "$ac_ct_RANLIB"; then
+-  echo "$as_me:3416: result: $ac_ct_RANLIB" >&5
++  echo "$as_me:3538: result: $ac_ct_RANLIB" >&5
+ echo "${ECHO_T}$ac_ct_RANLIB" >&6
+ else
+-  echo "$as_me:3419: result: no" >&5
++  echo "$as_me:3541: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3428,7 +3550,7 @@
+ if test -n "$ac_tool_prefix"; then
+   # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args.
+ set dummy ${ac_tool_prefix}ld; ac_word=$2
+-echo "$as_me:3431: checking for $ac_word" >&5
++echo "$as_me:3553: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_LD+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3443,7 +3565,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_LD="${ac_tool_prefix}ld"
+-echo "$as_me:3446: found $ac_dir/$ac_word" >&5
++echo "$as_me:3568: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3451,10 +3573,10 @@
+ fi
+ LD=$ac_cv_prog_LD
+ if test -n "$LD"; then
+-  echo "$as_me:3454: result: $LD" >&5
++  echo "$as_me:3576: result: $LD" >&5
+ echo "${ECHO_T}$LD" >&6
+ else
+-  echo "$as_me:3457: result: no" >&5
++  echo "$as_me:3579: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3463,7 +3585,7 @@
+   ac_ct_LD=$LD
+   # Extract the first word of "ld", so it can be a program name with args.
+ set dummy ld; ac_word=$2
+-echo "$as_me:3466: checking for $ac_word" >&5
++echo "$as_me:3588: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_ac_ct_LD+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3478,7 +3600,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_ac_ct_LD="ld"
+-echo "$as_me:3481: found $ac_dir/$ac_word" >&5
++echo "$as_me:3603: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3487,10 +3609,10 @@
+ fi
+ ac_ct_LD=$ac_cv_prog_ac_ct_LD
+ if test -n "$ac_ct_LD"; then
+-  echo "$as_me:3490: result: $ac_ct_LD" >&5
++  echo "$as_me:3612: result: $ac_ct_LD" >&5
+ echo "${ECHO_T}$ac_ct_LD" >&6
+ else
+-  echo "$as_me:3493: result: no" >&5
++  echo "$as_me:3615: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3502,7 +3624,7 @@
+ if test -n "$ac_tool_prefix"; then
+   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+ set dummy ${ac_tool_prefix}ar; ac_word=$2
+-echo "$as_me:3505: checking for $ac_word" >&5
++echo "$as_me:3627: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_AR+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3517,7 +3639,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+-echo "$as_me:3520: found $ac_dir/$ac_word" >&5
++echo "$as_me:3642: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3525,10 +3647,10 @@
+ fi
+ AR=$ac_cv_prog_AR
+ if test -n "$AR"; then
+-  echo "$as_me:3528: result: $AR" >&5
++  echo "$as_me:3650: result: $AR" >&5
+ echo "${ECHO_T}$AR" >&6
+ else
+-  echo "$as_me:3531: result: no" >&5
++  echo "$as_me:3653: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3537,7 +3659,7 @@
+   ac_ct_AR=$AR
+   # Extract the first word of "ar", so it can be a program name with args.
+ set dummy ar; ac_word=$2
+-echo "$as_me:3540: checking for $ac_word" >&5
++echo "$as_me:3662: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3552,7 +3674,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_ac_ct_AR="ar"
+-echo "$as_me:3555: found $ac_dir/$ac_word" >&5
++echo "$as_me:3677: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3561,10 +3683,10 @@
+ fi
+ ac_ct_AR=$ac_cv_prog_ac_ct_AR
+ if test -n "$ac_ct_AR"; then
+-  echo "$as_me:3564: result: $ac_ct_AR" >&5
++  echo "$as_me:3686: result: $ac_ct_AR" >&5
+ echo "${ECHO_T}$ac_ct_AR" >&6
+ else
+-  echo "$as_me:3567: result: no" >&5
++  echo "$as_me:3689: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3577,10 +3699,10 @@
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+-echo "$as_me:3580: checking for archiver options (symbol AR_OPTS)" >&5
++echo "$as_me:3702: checking for archiver options (symbol AR_OPTS)" >&5
+ echo $ECHO_N "checking for archiver options (symbol AR_OPTS)... $ECHO_C" >&6
+ test -z "$AR_OPTS" && AR_OPTS=rv
+-echo "$as_me:3583: result: $AR_OPTS" >&5
++echo "$as_me:3705: result: $AR_OPTS" >&5
+ echo "${ECHO_T}$AR_OPTS" >&6
+ 
+ cf_cv_subst_AR_OPTS=$AR_OPTS
+@@ -3588,7 +3710,7 @@
+ 
+ AR_OPTS=${cf_cv_subst_AR_OPTS}
+ 
+-echo "$as_me:3591: checking for makeflags variable" >&5
++echo "$as_me:3713: checking for makeflags variable" >&5
+ echo $ECHO_N "checking for makeflags variable... $ECHO_C" >&6
+ if test "${cf_cv_makeflags+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3621,10 +3743,10 @@
+ 	rm -f cf_makeflags.tmp
+ 
+ fi
+-echo "$as_me:3624: result: $cf_cv_makeflags" >&5
++echo "$as_me:3746: result: $cf_cv_makeflags" >&5
+ echo "${ECHO_T}$cf_cv_makeflags" >&6
+ 
+-echo "$as_me:3627: checking if you have specified an install-prefix" >&5
++echo "$as_me:3749: checking if you have specified an install-prefix" >&5
+ echo $ECHO_N "checking if you have specified an install-prefix... $ECHO_C" >&6
+ 
+ # Check whether --with-install-prefix or --without-install-prefix was given.
+@@ -3637,7 +3759,7 @@
+ 		;;
+ 	esac
+ fi;
+-echo "$as_me:3640: result: $DESTDIR" >&5
++echo "$as_me:3762: result: $DESTDIR" >&5
+ echo "${ECHO_T}$DESTDIR" >&6
+ 
+ ###############################################################################
+@@ -3645,13 +3767,17 @@
+ # If we're cross-compiling, allow the user to override the tools and their
+ # options.  The configure script is oriented toward identifying the host
+ # compiler, etc., but we need a build compiler to generate parts of the source.
+-: ${BUILD_CC:='$(CC)'}
+-: ${BUILD_CFLAGS:='$(CFLAGS)'}
+-: ${BUILD_CPPFLAGS:='$(CPPFLAGS)'}
+-: ${BUILD_LDFLAGS:='$(LDFLAGS)'}
+-: ${BUILD_LIBS:='$(LIBS)'}
+-: ${BUILD_EXEEXT:='$x'}
++
+ if test "$cross_compiling" = yes ; then
++	# defaults that we might want to override
++	: ${BUILD_CC:='$(CC)'}
++	: ${BUILD_CPP:='$(CC) -E'}
++	: ${BUILD_CFLAGS:=''}
++	: ${BUILD_CPPFLAGS:=''}
++	: ${BUILD_LDFLAGS:=''}
++	: ${BUILD_LIBS:=''}
++	: ${BUILD_EXEEXT:='$x'}
++	: ${BUILD_OBJEXT:='o'}
+ 
+ # Check whether --with-build-cc or --without-build-cc was given.
+ if test "${with_build_cc+set}" = set; then
+@@ -3662,7 +3788,7 @@
+ do
+   # Extract the first word of "$ac_prog", so it can be a program name with args.
+ set dummy $ac_prog; ac_word=$2
+-echo "$as_me:3665: checking for $ac_word" >&5
++echo "$as_me:3791: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_BUILD_CC+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3677,7 +3803,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_BUILD_CC="$ac_prog"
+-echo "$as_me:3680: found $ac_dir/$ac_word" >&5
++echo "$as_me:3806: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -3685,10 +3811,10 @@
+ fi
+ BUILD_CC=$ac_cv_prog_BUILD_CC
+ if test -n "$BUILD_CC"; then
+-  echo "$as_me:3688: result: $BUILD_CC" >&5
++  echo "$as_me:3814: result: $BUILD_CC" >&5
+ echo "${ECHO_T}$BUILD_CC" >&6
+ else
+-  echo "$as_me:3691: result: no" >&5
++  echo "$as_me:3817: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -3697,6 +3823,14 @@
+ 
+ fi;
+ 
++# Check whether --with-build-cpp or --without-build-cpp was given.
++if test "${with_build_cpp+set}" = set; then
++  withval="$with_build_cpp"
++  BUILD_CPP="$withval"
++else
++  BUILD_CPP='$(CC) -E'
++fi;
++
+ # Check whether --with-build-cflags or --without-build-cflags was given.
+ if test "${with_build_cflags+set}" = set; then
+   withval="$with_build_cflags"
+@@ -3720,7 +3854,27 @@
+   withval="$with_build_libs"
+   BUILD_LIBS="$withval"
+ fi;
++	# this assumes we're on Unix.
+ 	BUILD_EXEEXT=
++	BUILD_OBJEXT=o
++
++	if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '$(CC)' ) ; then
++		{ { echo "$as_me:3862: error: Cross-build requires two compilers.
++Use --with-build-cc to specify the native compiler." >&5
++echo "$as_me: error: Cross-build requires two compilers.
++Use --with-build-cc to specify the native compiler." >&2;}
++   { (exit 1); exit 1; }; }
++	fi
++
++else
++	: ${BUILD_CC:='$(CC)'}
++	: ${BUILD_CPP:='$(CPP)'}
++	: ${BUILD_CFLAGS:='$(CFLAGS)'}
++	: ${BUILD_CPPFLAGS:='$(CPPFLAGS)'}
++	: ${BUILD_LDFLAGS:='$(LDFLAGS)'}
++	: ${BUILD_LIBS:='$(LIBS)'}
++	: ${BUILD_EXEEXT:='$x'}
++	: ${BUILD_OBJEXT:='o'}
+ fi
+ 
+ ###############################################################################
+@@ -3746,7 +3900,7 @@
+ LIB_INSTALL=
+ LIB_UNINSTALL=
+ 
+-echo "$as_me:3749: checking if you want to build libraries with libtool" >&5
++echo "$as_me:3903: checking if you want to build libraries with libtool" >&5
+ echo $ECHO_N "checking if you want to build libraries with libtool... $ECHO_C" >&6
+ 
+ # Check whether --with-libtool or --without-libtool was given.
+@@ -3756,7 +3910,7 @@
+ else
+   with_libtool=no
+ fi;
+-echo "$as_me:3759: result: $with_libtool" >&5
++echo "$as_me:3913: result: $with_libtool" >&5
+ echo "${ECHO_T}$with_libtool" >&6
+ if test "$with_libtool" != "no"; then
+ 
+@@ -3781,7 +3935,7 @@
+   with_libtool=`echo $with_libtool | sed -e s%NONE%$ac_default_prefix%`
+   ;;
+ *)
+-  { { echo "$as_me:3784: error: expected a pathname, not \"$with_libtool\"" >&5
++  { { echo "$as_me:3938: error: expected a pathname, not \"$with_libtool\"" >&5
+ echo "$as_me: error: expected a pathname, not \"$with_libtool\"" >&2;}
+    { (exit 1); exit 1; }; }
+   ;;
+@@ -3791,7 +3945,7 @@
+ 	else
+  		# Extract the first word of "libtool", so it can be a program name with args.
+ set dummy libtool; ac_word=$2
+-echo "$as_me:3794: checking for $ac_word" >&5
++echo "$as_me:3948: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_path_LIBTOOL+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -3808,7 +3962,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   if $as_executable_p "$ac_dir/$ac_word"; then
+    ac_cv_path_LIBTOOL="$ac_dir/$ac_word"
+-   echo "$as_me:3811: found $ac_dir/$ac_word" >&5
++   echo "$as_me:3965: found $ac_dir/$ac_word" >&5
+    break
+ fi
+ done
+@@ -3819,16 +3973,16 @@
+ LIBTOOL=$ac_cv_path_LIBTOOL
+ 
+ if test -n "$LIBTOOL"; then
+-  echo "$as_me:3822: result: $LIBTOOL" >&5
++  echo "$as_me:3976: result: $LIBTOOL" >&5
+ echo "${ECHO_T}$LIBTOOL" >&6
+ else
+-  echo "$as_me:3825: result: no" >&5
++  echo "$as_me:3979: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+  	fi
+  	if test -z "$LIBTOOL" ; then
+- 		{ { echo "$as_me:3831: error: Cannot find libtool" >&5
++ 		{ { echo "$as_me:3985: error: Cannot find libtool" >&5
+ echo "$as_me: error: Cannot find libtool" >&2;}
+    { (exit 1); exit 1; }; }
+  	fi
+@@ -3843,17 +3997,17 @@
+ 	LIB_PREP=:
+ 
+ 	# Show the version of libtool
+-	echo "$as_me:3846: checking version of libtool" >&5
++	echo "$as_me:4000: checking version of libtool" >&5
+ echo $ECHO_N "checking version of libtool... $ECHO_C" >&6
+ 
+ 	# Save the version in a cache variable - this is not entirely a good
+ 	# thing, but the version string from libtool is very ugly, and for
+ 	# bug reports it might be useful to have the original string.
+ 	cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '2,$d' -e 's/([^)]*)//g' -e 's/^[^1-9]*//' -e 's/[^0-9.].*//'`
+-	echo "$as_me:3853: result: $cf_cv_libtool_version" >&5
++	echo "$as_me:4007: result: $cf_cv_libtool_version" >&5
+ echo "${ECHO_T}$cf_cv_libtool_version" >&6
+ 	if test -z "$cf_cv_libtool_version" ; then
+-		{ { echo "$as_me:3856: error: This is not libtool" >&5
++		{ { echo "$as_me:4010: error: This is not libtool" >&5
+ echo "$as_me: error: This is not libtool" >&2;}
+    { (exit 1); exit 1; }; }
+ 	fi
+@@ -3880,7 +4034,7 @@
+ 
+ else
+ 
+-echo "$as_me:3883: checking if you want to build shared libraries" >&5
++echo "$as_me:4037: checking if you want to build shared libraries" >&5
+ echo $ECHO_N "checking if you want to build shared libraries... $ECHO_C" >&6
+ 
+ # Check whether --with-shared or --without-shared was given.
+@@ -3890,11 +4044,11 @@
+ else
+   with_shared=no
+ fi;
+-echo "$as_me:3893: result: $with_shared" >&5
++echo "$as_me:4047: result: $with_shared" >&5
+ echo "${ECHO_T}$with_shared" >&6
+ test "$with_shared" = "yes" && cf_list_models="$cf_list_models shared"
+ 
+-echo "$as_me:3897: checking if you want to build static libraries" >&5
++echo "$as_me:4051: checking if you want to build static libraries" >&5
+ echo $ECHO_N "checking if you want to build static libraries... $ECHO_C" >&6
+ 
+ # Check whether --with-normal or --without-normal was given.
+@@ -3904,11 +4058,11 @@
+ else
+   with_normal=yes
+ fi;
+-echo "$as_me:3907: result: $with_normal" >&5
++echo "$as_me:4061: result: $with_normal" >&5
+ echo "${ECHO_T}$with_normal" >&6
+ test "$with_normal" = "yes" && cf_list_models="$cf_list_models normal"
+ 
+-echo "$as_me:3911: checking if you want to build debug libraries" >&5
++echo "$as_me:4065: checking if you want to build debug libraries" >&5
+ echo $ECHO_N "checking if you want to build debug libraries... $ECHO_C" >&6
+ 
+ # Check whether --with-debug or --without-debug was given.
+@@ -3918,11 +4072,11 @@
+ else
+   with_debug=yes
+ fi;
+-echo "$as_me:3921: result: $with_debug" >&5
++echo "$as_me:4075: result: $with_debug" >&5
+ echo "${ECHO_T}$with_debug" >&6
+ test "$with_debug" = "yes" && cf_list_models="$cf_list_models debug"
+ 
+-echo "$as_me:3925: checking if you want to build profiling libraries" >&5
++echo "$as_me:4079: checking if you want to build profiling libraries" >&5
+ echo $ECHO_N "checking if you want to build profiling libraries... $ECHO_C" >&6
+ 
+ # Check whether --with-profile or --without-profile was given.
+@@ -3932,7 +4086,7 @@
+ else
+   with_profile=no
+ fi;
+-echo "$as_me:3935: result: $with_profile" >&5
++echo "$as_me:4089: result: $with_profile" >&5
+ echo "${ECHO_T}$with_profile" >&6
+ test "$with_profile" = "yes" && cf_list_models="$cf_list_models profile"
+ 
+@@ -3940,19 +4094,19 @@
+ 
+ ###############################################################################
+ 
+-echo "$as_me:3943: checking for specified models" >&5
++echo "$as_me:4097: checking for specified models" >&5
+ echo $ECHO_N "checking for specified models... $ECHO_C" >&6
+ test -z "$cf_list_models" && cf_list_models=normal
+ test "$with_libtool" != "no" && cf_list_models=libtool
+-echo "$as_me:3947: result: $cf_list_models" >&5
++echo "$as_me:4101: result: $cf_list_models" >&5
+ echo "${ECHO_T}$cf_list_models" >&6
+ 
+ ### Use the first model as the default, and save its suffix for use in building
+ ### up test-applications.
+-echo "$as_me:3952: checking for default model" >&5
++echo "$as_me:4106: checking for default model" >&5
+ echo $ECHO_N "checking for default model... $ECHO_C" >&6
+ DFT_LWR_MODEL=`echo "$cf_list_models" | $AWK '{print $1}'`
+-echo "$as_me:3955: result: $DFT_LWR_MODEL" >&5
++echo "$as_me:4109: result: $DFT_LWR_MODEL" >&5
+ echo "${ECHO_T}$DFT_LWR_MODEL" >&6
+ 
+ DFT_UPR_MODEL=`echo "$DFT_LWR_MODEL" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+@@ -3976,7 +4130,7 @@
+ 
+ ###############################################################################
+ 
+-echo "$as_me:3979: checking if you want to build a separate terminfo library" >&5
++echo "$as_me:4133: checking if you want to build a separate terminfo library" >&5
+ echo $ECHO_N "checking if you want to build a separate terminfo library... $ECHO_C" >&6
+ 
+ # Check whether --with-termlib or --without-termlib was given.
+@@ -3986,12 +4140,12 @@
+ else
+   with_termlib=no
+ fi;
+-echo "$as_me:3989: result: $with_termlib" >&5
++echo "$as_me:4143: result: $with_termlib" >&5
+ echo "${ECHO_T}$with_termlib" >&6
+ 
+ ### Checks for special libraries, must be done up-front.
+ 
+-echo "$as_me:3994: checking if you want to link with dbmalloc for testing" >&5
++echo "$as_me:4148: checking if you want to link with dbmalloc for testing" >&5
+ echo $ECHO_N "checking if you want to link with dbmalloc for testing... $ECHO_C" >&6
+ 
+ # Check whether --with-dbmalloc or --without-dbmalloc was given.
+@@ -4001,11 +4155,49 @@
+ else
+   with_dbmalloc=no
+ fi;
+-echo "$as_me:4004: result: $with_dbmalloc" >&5
++echo "$as_me:4158: result: $with_dbmalloc" >&5
+ echo "${ECHO_T}$with_dbmalloc" >&6
+-if test $with_dbmalloc = yes ; then
++if test "$with_dbmalloc" = yes ; then
++	echo "$as_me:4161: checking for dbmalloc.h" >&5
++echo $ECHO_N "checking for dbmalloc.h... $ECHO_C" >&6
++if test "${ac_cv_header_dbmalloc_h+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++  cat >conftest.$ac_ext <<_ACEOF
++#line 4167 "configure"
++#include "confdefs.h"
++#include <dbmalloc.h>
++_ACEOF
++if { (eval echo "$as_me:4171: \"$ac_cpp conftest.$ac_ext\"") >&5
++  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++  ac_status=$?
++  egrep -v '^ *\+' conftest.er1 >conftest.err
++  rm -f conftest.er1
++  cat conftest.err >&5
++  echo "$as_me:4177: \$? = $ac_status" >&5
++  (exit $ac_status); } >/dev/null; then
++  if test -s conftest.err; then
++    ac_cpp_err=$ac_c_preproc_warn_flag
++  else
++    ac_cpp_err=
++  fi
++else
++  ac_cpp_err=yes
++fi
++if test -z "$ac_cpp_err"; then
++  ac_cv_header_dbmalloc_h=yes
++else
++  echo "$as_me: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++  ac_cv_header_dbmalloc_h=no
++fi
++rm -f conftest.err conftest.$ac_ext
++fi
++echo "$as_me:4196: result: $ac_cv_header_dbmalloc_h" >&5
++echo "${ECHO_T}$ac_cv_header_dbmalloc_h" >&6
++if test $ac_cv_header_dbmalloc_h = yes; then
+ 
+-echo "$as_me:4008: checking for debug_malloc in -ldbmalloc" >&5
++echo "$as_me:4200: checking for debug_malloc in -ldbmalloc" >&5
+ echo $ECHO_N "checking for debug_malloc in -ldbmalloc... $ECHO_C" >&6
+ if test "${ac_cv_lib_dbmalloc_debug_malloc+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -4013,7 +4205,7 @@
+   ac_check_lib_save_LIBS=$LIBS
+ LIBS="-ldbmalloc  $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 4016 "configure"
++#line 4208 "configure"
+ #include "confdefs.h"
+ 
+ /* Override any gcc2 internal prototype to avoid an error.  */
+@@ -4032,16 +4224,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:4035: \"$ac_link\"") >&5
++if { (eval echo "$as_me:4227: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:4038: \$? = $ac_status" >&5
++  echo "$as_me:4230: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:4041: \"$ac_try\"") >&5
++  { (eval echo "$as_me:4233: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:4044: \$? = $ac_status" >&5
++  echo "$as_me:4236: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_lib_dbmalloc_debug_malloc=yes
+ else
+@@ -4052,7 +4244,7 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+-echo "$as_me:4055: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
++echo "$as_me:4247: result: $ac_cv_lib_dbmalloc_debug_malloc" >&5
+ echo "${ECHO_T}$ac_cv_lib_dbmalloc_debug_malloc" >&6
+ if test $ac_cv_lib_dbmalloc_debug_malloc = yes; then
+   cat >>confdefs.h <<EOF
+@@ -4065,7 +4257,9 @@
+ 
+ fi
+ 
+-echo "$as_me:4068: checking if you want to link with dmalloc for testing" >&5
++fi
++
++echo "$as_me:4262: checking if you want to link with dmalloc for testing" >&5
+ echo $ECHO_N "checking if you want to link with dmalloc for testing... $ECHO_C" >&6
+ 
+ # Check whether --with-dmalloc or --without-dmalloc was given.
+@@ -4075,11 +4269,49 @@
+ else
+   with_dmalloc=no
+ fi;
+-echo "$as_me:4078: result: $with_dmalloc" >&5
++echo "$as_me:4272: result: $with_dmalloc" >&5
+ echo "${ECHO_T}$with_dmalloc" >&6
+-if test $with_dmalloc = yes ; then
++if test "$with_dmalloc" = yes ; then
++	echo "$as_me:4275: checking for dmalloc.h" >&5
++echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6
++if test "${ac_cv_header_dmalloc_h+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++  cat >conftest.$ac_ext <<_ACEOF
++#line 4281 "configure"
++#include "confdefs.h"
++#include <dmalloc.h>
++_ACEOF
++if { (eval echo "$as_me:4285: \"$ac_cpp conftest.$ac_ext\"") >&5
++  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++  ac_status=$?
++  egrep -v '^ *\+' conftest.er1 >conftest.err
++  rm -f conftest.er1
++  cat conftest.err >&5
++  echo "$as_me:4291: \$? = $ac_status" >&5
++  (exit $ac_status); } >/dev/null; then
++  if test -s conftest.err; then
++    ac_cpp_err=$ac_c_preproc_warn_flag
++  else
++    ac_cpp_err=
++  fi
++else
++  ac_cpp_err=yes
++fi
++if test -z "$ac_cpp_err"; then
++  ac_cv_header_dmalloc_h=yes
++else
++  echo "$as_me: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++  ac_cv_header_dmalloc_h=no
++fi
++rm -f conftest.err conftest.$ac_ext
++fi
++echo "$as_me:4310: result: $ac_cv_header_dmalloc_h" >&5
++echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6
++if test $ac_cv_header_dmalloc_h = yes; then
+ 
+-echo "$as_me:4082: checking for dmalloc_debug in -ldmalloc" >&5
++echo "$as_me:4314: checking for dmalloc_debug in -ldmalloc" >&5
+ echo $ECHO_N "checking for dmalloc_debug in -ldmalloc... $ECHO_C" >&6
+ if test "${ac_cv_lib_dmalloc_dmalloc_debug+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -4087,7 +4319,7 @@
+   ac_check_lib_save_LIBS=$LIBS
+ LIBS="-ldmalloc  $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 4090 "configure"
++#line 4322 "configure"
+ #include "confdefs.h"
+ 
+ /* Override any gcc2 internal prototype to avoid an error.  */
+@@ -4106,16 +4338,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:4109: \"$ac_link\"") >&5
++if { (eval echo "$as_me:4341: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:4112: \$? = $ac_status" >&5
++  echo "$as_me:4344: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:4115: \"$ac_try\"") >&5
++  { (eval echo "$as_me:4347: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:4118: \$? = $ac_status" >&5
++  echo "$as_me:4350: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_lib_dmalloc_dmalloc_debug=yes
+ else
+@@ -4126,7 +4358,7 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+-echo "$as_me:4129: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
++echo "$as_me:4361: result: $ac_cv_lib_dmalloc_dmalloc_debug" >&5
+ echo "${ECHO_T}$ac_cv_lib_dmalloc_dmalloc_debug" >&6
+ if test $ac_cv_lib_dmalloc_dmalloc_debug = yes; then
+   cat >>confdefs.h <<EOF
+@@ -4139,21 +4371,23 @@
+ 
+ fi
+ 
++fi
++
+ SHLIB_LIST=""
+-echo "$as_me:4143: checking if you want to link with the gpm mouse library" >&5
+-echo $ECHO_N "checking if you want to link with the gpm mouse library... $ECHO_C" >&6
++echo "$as_me:4377: checking if you want to link with the GPM mouse library" >&5
++echo $ECHO_N "checking if you want to link with the GPM mouse library... $ECHO_C" >&6
+ 
+ # Check whether --with-gpm or --without-gpm was given.
+ if test "${with_gpm+set}" = set; then
+   withval="$with_gpm"
+   with_gpm=$withval
+ else
+-  with_gpm=no
++  with_gpm=maybe
+ fi;
+-echo "$as_me:4153: result: $with_gpm" >&5
++echo "$as_me:4387: result: $with_gpm" >&5
+ echo "${ECHO_T}$with_gpm" >&6
+-if test "$with_gpm" = yes ; then
+-	echo "$as_me:4156: checking for Gpm_Open in -lgpm" >&5
++if test "$with_gpm" != no ; then
++	echo "$as_me:4390: checking for Gpm_Open in -lgpm" >&5
+ echo $ECHO_N "checking for Gpm_Open in -lgpm... $ECHO_C" >&6
+ if test "${ac_cv_lib_gpm_Gpm_Open+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -4161,7 +4395,7 @@
+   ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lgpm  $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 4164 "configure"
++#line 4398 "configure"
+ #include "confdefs.h"
+ 
+ /* Override any gcc2 internal prototype to avoid an error.  */
+@@ -4180,16 +4414,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:4183: \"$ac_link\"") >&5
++if { (eval echo "$as_me:4417: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:4186: \$? = $ac_status" >&5
++  echo "$as_me:4420: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:4189: \"$ac_try\"") >&5
++  { (eval echo "$as_me:4423: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:4192: \$? = $ac_status" >&5
++  echo "$as_me:4426: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_lib_gpm_Gpm_Open=yes
+ else
+@@ -4200,36 +4434,27 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+-echo "$as_me:4203: result: $ac_cv_lib_gpm_Gpm_Open" >&5
++echo "$as_me:4437: result: $ac_cv_lib_gpm_Gpm_Open" >&5
+ echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Open" >&6
+ if test $ac_cv_lib_gpm_Gpm_Open = yes; then
+ 
+-		EXTRA_LIBS="-lgpm -lncurses $EXTRA_LIBS"
+-		SHLIB_LIST="-lgpm $SHLIB_LIST"
+-		cat >>confdefs.h <<\EOF
+-#define HAVE_LIBGPM 1
+-EOF
+-
+-for ac_header in gpm.h
+-do
+-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+-echo "$as_me:4216: checking for $ac_header" >&5
+-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+-if eval "test \"\${$as_ac_Header+set}\" = set"; then
++		echo "$as_me:4441: checking for gpm.h" >&5
++echo $ECHO_N "checking for gpm.h... $ECHO_C" >&6
++if test "${ac_cv_header_gpm_h+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 4222 "configure"
++#line 4447 "configure"
+ #include "confdefs.h"
+-#include <$ac_header>
++#include <gpm.h>
+ _ACEOF
+-if { (eval echo "$as_me:4226: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:4451: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:4232: \$? = $ac_status" >&5
++  echo "$as_me:4457: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+@@ -4240,119 +4465,377 @@
+   ac_cpp_err=yes
+ fi
+ if test -z "$ac_cpp_err"; then
+-  eval "$as_ac_Header=yes"
++  ac_cv_header_gpm_h=yes
+ else
+   echo "$as_me: failed program was:" >&5
+   cat conftest.$ac_ext >&5
+-  eval "$as_ac_Header=no"
++  ac_cv_header_gpm_h=no
+ fi
+ rm -f conftest.err conftest.$ac_ext
+ fi
+-echo "$as_me:4251: result: `eval echo '${'$as_ac_Header'}'`" >&5
+-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+-  cat >>confdefs.h <<EOF
+-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
++echo "$as_me:4476: result: $ac_cv_header_gpm_h" >&5
++echo "${ECHO_T}$ac_cv_header_gpm_h" >&6
++if test $ac_cv_header_gpm_h = yes; then
++
++			cat >>confdefs.h <<\EOF
++#define HAVE_GPM_H 1
+ EOF
+ 
+-fi
+-done
++			with_gpm=yes
+ 
+ else
+-  { echo "$as_me:4262: WARNING: Cannot link with gpm library - read the FAQ" >&5
+-echo "$as_me: WARNING: Cannot link with gpm library - read the FAQ" >&2;}
++
++			if test "$with_gpm" = yes ; then
++				{ { echo "$as_me:4489: error: Cannot find GPM header" >&5
++echo "$as_me: error: Cannot find GPM header" >&2;}
++   { (exit 1); exit 1; }; }
++			fi
++
+ fi
+ 
++else
++
++		if test "$with_gpm" = yes ; then
++			{ { echo "$as_me:4499: error: Cannot link with GPM library" >&5
++echo "$as_me: error: Cannot link with GPM library" >&2;}
++   { (exit 1); exit 1; }; }
++		fi
++		with_gpm=no
++
+ fi
+ 
+-# not everyone has "test -c"
+-if test -c /dev/sysmouse 2>/dev/null ; then
+-echo "$as_me:4270: checking if you want to use sysmouse" >&5
+-echo $ECHO_N "checking if you want to use sysmouse... $ECHO_C" >&6
++	if test "$with_gpm" = yes ; then
+ 
+-# Check whether --with-sysmouse or --without-sysmouse was given.
+-if test "${with_sysmouse+set}" = set; then
+-  withval="$with_sysmouse"
+-  cf_with_sysmouse=$withval
++cf_have_dlsym=no
++echo "$as_me:4510: checking for dlsym" >&5
++echo $ECHO_N "checking for dlsym... $ECHO_C" >&6
++if test "${ac_cv_func_dlsym+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+-  cf_with_sysmouse=maybe
+-fi;
+-	if test "$cf_with_sysmouse" != no ; then
+-	cat >conftest.$ac_ext <<_ACEOF
+-#line 4282 "configure"
++  cat >conftest.$ac_ext <<_ACEOF
++#line 4516 "configure"
+ #include "confdefs.h"
+-
+-#include <osreldate.h>
+-#if (__FreeBSD_version >= 400017)
+-#include <sys/consio.h>
+-#include <sys/fbio.h>
+-#else
+-#include <machine/console.h>
++/* System header to define __stub macros and hopefully few prototypes,
++    which can conflict with char dlsym (); below.  */
++#include <assert.h>
++/* Override any gcc2 internal prototype to avoid an error.  */
++#ifdef __cplusplus
++extern "C"
+ #endif
++/* We use char because int might match the return type of a gcc2
++   builtin and then its argument prototype would still apply.  */
++char dlsym ();
++char (*f) ();
+ 
+ int
+ main ()
+ {
+-
+-	struct mouse_info the_mouse;
+-	ioctl(0, CONS_MOUSECTL, &the_mouse);
++/* The GNU C library defines this for functions which it implements
++    to always fail with ENOSYS.  Some functions are actually named
++    something starting with __ and the normal name is an alias.  */
++#if defined (__stub_dlsym) || defined (__stub___dlsym)
++choke me
++#else
++f = dlsym;
++#endif
+ 
+   ;
+   return 0;
+ }
+ _ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:4305: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:4547: \"$ac_link\"") >&5
++  (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:4308: \$? = $ac_status" >&5
++  echo "$as_me:4550: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:4311: \"$ac_try\"") >&5
++         { ac_try='test -s conftest$ac_exeext'
++  { (eval echo "$as_me:4553: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:4314: \$? = $ac_status" >&5
++  echo "$as_me:4556: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+-  cf_with_sysmouse=yes
++  ac_cv_func_dlsym=yes
+ else
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+-cf_with_sysmouse=no
++ac_cv_func_dlsym=no
+ fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-	fi
+-echo "$as_me:4324: result: $cf_with_sysmouse" >&5
+-echo "${ECHO_T}$cf_with_sysmouse" >&6
+-test "$cf_with_sysmouse" = yes && cat >>confdefs.h <<\EOF
+-#define USE_SYSMOUSE 1
+-EOF
+-
++rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
++echo "$as_me:4566: result: $ac_cv_func_dlsym" >&5
++echo "${ECHO_T}$ac_cv_func_dlsym" >&6
++if test $ac_cv_func_dlsym = yes; then
++  cf_have_dlsym=yes
++else
+ 
+-if test X"$CC_G_OPT" = X"" ; then
+-	CC_G_OPT='-g'
+-	test -n "$GCC" && test "${ac_cv_prog_cc_g}" != yes && CC_G_OPT=''
++cf_have_libdl=no
++echo "$as_me:4573: checking for dlsym in -ldl" >&5
++echo $ECHO_N "checking for dlsym in -ldl... $ECHO_C" >&6
++if test "${ac_cv_lib_dl_dlsym+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++  ac_check_lib_save_LIBS=$LIBS
++LIBS="-ldl  $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++#line 4581 "configure"
++#include "confdefs.h"
++
++/* Override any gcc2 internal prototype to avoid an error.  */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++   builtin and then its argument prototype would still apply.  */
++char dlsym ();
++int
++main ()
++{
++dlsym ();
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:4600: \"$ac_link\"") >&5
++  (eval $ac_link) 2>&5
++  ac_status=$?
++  echo "$as_me:4603: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest$ac_exeext'
++  { (eval echo "$as_me:4606: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:4609: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  ac_cv_lib_dl_dlsym=yes
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++ac_cv_lib_dl_dlsym=no
++fi
++rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
+ fi
++echo "$as_me:4620: result: $ac_cv_lib_dl_dlsym" >&5
++echo "${ECHO_T}$ac_cv_lib_dl_dlsym" >&6
++if test $ac_cv_lib_dl_dlsym = yes; then
+ 
+-if test X"$CXX_G_OPT" = X"" ; then
+-	CXX_G_OPT='-g'
+-	test -n "$GXX" && test "${ac_cv_prog_cxx_g}" != yes && CXX_G_OPT=''
++	cf_have_dlsym=yes
++	cf_have_libdl=yes
+ fi
+ 
+-echo "$as_me:4342: checking for default loader flags" >&5
+-echo $ECHO_N "checking for default loader flags... $ECHO_C" >&6
+-case $DFT_LWR_MODEL in
+-libtool) LD_MODEL=''   ;;
+-normal)  LD_MODEL=''   ;;
+-debug)   LD_MODEL=$CC_G_OPT ;;
+-profile) LD_MODEL='-pg';;
+-shared)  LD_MODEL=''   ;;
+-esac
+-echo "$as_me:4351: result: $LD_MODEL" >&5
+-echo "${ECHO_T}$LD_MODEL" >&6
++fi
+ 
+-echo "$as_me:4354: checking if rpath option should be used" >&5
+-echo $ECHO_N "checking if rpath option should be used... $ECHO_C" >&6
++if test "$cf_have_dlsym" = yes ; then
++	test "$cf_have_libdl" = yes && LIBS="-ldl $LIBS"
++
++	echo "$as_me:4633: checking whether able to link to dl*() functions" >&5
++echo $ECHO_N "checking whether able to link to dl*() functions... $ECHO_C" >&6
++	cat >conftest.$ac_ext <<_ACEOF
++#line 4636 "configure"
++#include "confdefs.h"
++#include <dlfcn.h>
++int
++main ()
++{
++
++		void *obj;
++		if ((obj = dlopen("filename", 0)) != 0) {
++			if (dlsym(obj, "symbolname") == 0) {
++			dlclose(obj);
++			}
++		}
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:4654: \"$ac_link\"") >&5
++  (eval $ac_link) 2>&5
++  ac_status=$?
++  echo "$as_me:4657: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest$ac_exeext'
++  { (eval echo "$as_me:4660: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:4663: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++
++		cat >>confdefs.h <<\EOF
++#define HAVE_LIBDL 1
++EOF
++
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++
++		{ { echo "$as_me:4674: error: Cannot link test program for libdl" >&5
++echo "$as_me: error: Cannot link test program for libdl" >&2;}
++   { (exit 1); exit 1; }; }
++fi
++rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
++	echo "$as_me:4679: result: ok" >&5
++echo "${ECHO_T}ok" >&6
++else
++	{ { echo "$as_me:4682: error: Cannot find dlsym function" >&5
++echo "$as_me: error: Cannot find dlsym function" >&2;}
++   { (exit 1); exit 1; }; }
++fi
++
++		SHLIB_LIST="-ldl $SHLIB_LIST"
++		cat >>confdefs.h <<\EOF
++#define HAVE_LIBGPM 1
++EOF
++
++		echo "$as_me:4692: checking for Gpm_Wgetch in -lgpm" >&5
++echo $ECHO_N "checking for Gpm_Wgetch in -lgpm... $ECHO_C" >&6
++if test "${ac_cv_lib_gpm_Gpm_Wgetch+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++  ac_check_lib_save_LIBS=$LIBS
++LIBS="-lgpm  $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++#line 4700 "configure"
++#include "confdefs.h"
++
++/* Override any gcc2 internal prototype to avoid an error.  */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++   builtin and then its argument prototype would still apply.  */
++char Gpm_Wgetch ();
++int
++main ()
++{
++Gpm_Wgetch ();
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:4719: \"$ac_link\"") >&5
++  (eval $ac_link) 2>&5
++  ac_status=$?
++  echo "$as_me:4722: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest$ac_exeext'
++  { (eval echo "$as_me:4725: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:4728: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  ac_cv_lib_gpm_Gpm_Wgetch=yes
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++ac_cv_lib_gpm_Gpm_Wgetch=no
++fi
++rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:4739: result: $ac_cv_lib_gpm_Gpm_Wgetch" >&5
++echo "${ECHO_T}$ac_cv_lib_gpm_Gpm_Wgetch" >&6
++if test $ac_cv_lib_gpm_Gpm_Wgetch = yes; then
++
++			{ echo "$as_me:4743: WARNING: GPM library is already linked with curses - read the FAQ" >&5
++echo "$as_me: WARNING: GPM library is already linked with curses - read the FAQ" >&2;}
++
++fi
++
++	fi
++fi
++
++# not everyone has "test -c"
++if test -c /dev/sysmouse 2>/dev/null ; then
++echo "$as_me:4753: checking if you want to use sysmouse" >&5
++echo $ECHO_N "checking if you want to use sysmouse... $ECHO_C" >&6
++
++# Check whether --with-sysmouse or --without-sysmouse was given.
++if test "${with_sysmouse+set}" = set; then
++  withval="$with_sysmouse"
++  cf_with_sysmouse=$withval
++else
++  cf_with_sysmouse=maybe
++fi;
++	if test "$cf_with_sysmouse" != no ; then
++	cat >conftest.$ac_ext <<_ACEOF
++#line 4765 "configure"
++#include "confdefs.h"
++
++#include <osreldate.h>
++#if (__FreeBSD_version >= 400017)
++#include <sys/consio.h>
++#include <sys/fbio.h>
++#else
++#include <machine/console.h>
++#endif
++
++int
++main ()
++{
++
++	struct mouse_info the_mouse;
++	ioctl(0, CONS_MOUSECTL, &the_mouse);
++
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:4788: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:4791: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:4794: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:4797: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_with_sysmouse=yes
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_with_sysmouse=no
++fi
++rm -f conftest.$ac_objext conftest.$ac_ext
++	fi
++echo "$as_me:4807: result: $cf_with_sysmouse" >&5
++echo "${ECHO_T}$cf_with_sysmouse" >&6
++test "$cf_with_sysmouse" = yes && cat >>confdefs.h <<\EOF
++#define USE_SYSMOUSE 1
++EOF
++
++fi
++
++if test X"$CC_G_OPT" = X"" ; then
++	CC_G_OPT='-g'
++	test -n "$GCC" && test "${ac_cv_prog_cc_g}" != yes && CC_G_OPT=''
++fi
++
++if test X"$CXX_G_OPT" = X"" ; then
++	CXX_G_OPT='-g'
++	test -n "$GXX" && test "${ac_cv_prog_cxx_g}" != yes && CXX_G_OPT=''
++fi
++
++echo "$as_me:4825: checking for default loader flags" >&5
++echo $ECHO_N "checking for default loader flags... $ECHO_C" >&6
++case $DFT_LWR_MODEL in
++libtool) LD_MODEL=''   ;;
++normal)  LD_MODEL=''   ;;
++debug)   LD_MODEL=$CC_G_OPT ;;
++profile) LD_MODEL='-pg';;
++shared)  LD_MODEL=''   ;;
++esac
++echo "$as_me:4834: result: $LD_MODEL" >&5
++echo "${ECHO_T}$LD_MODEL" >&6
++
++echo "$as_me:4837: checking if rpath option should be used" >&5
++echo $ECHO_N "checking if rpath option should be used... $ECHO_C" >&6
+ 
+ # Check whether --enable-rpath or --disable-rpath was given.
+ if test "${enable_rpath+set}" = set; then
+@@ -4361,7 +4844,7 @@
+ else
+   cf_cv_ld_rpath=no
+ fi;
+-echo "$as_me:4364: result: $cf_cv_ld_rpath" >&5
++echo "$as_me:4847: result: $cf_cv_ld_rpath" >&5
+ echo "${ECHO_T}$cf_cv_ld_rpath" >&6
+ 
+ 	LOCAL_LDFLAGS=
+@@ -4371,7 +4854,7 @@
+ 
+ 	cf_cv_do_symlinks=no
+ 
+-	echo "$as_me:4374: checking if release/abi version should be used for shared libs" >&5
++	echo "$as_me:4857: checking if release/abi version should be used for shared libs" >&5
+ echo $ECHO_N "checking if release/abi version should be used for shared libs... $ECHO_C" >&6
+ 
+ # Check whether --with-shlib-version or --without-shlib-version was given.
+@@ -4386,7 +4869,7 @@
+ 		cf_cv_shlib_version=$withval
+ 		;;
+ 	*)
+-		{ { echo "$as_me:4389: error: option value must be one of: rel, abi, auto or no" >&5
++		{ { echo "$as_me:4872: error: option value must be one of: rel, abi, auto or no" >&5
+ echo "$as_me: error: option value must be one of: rel, abi, auto or no" >&2;}
+    { (exit 1); exit 1; }; }
+ 		;;
+@@ -4395,7 +4878,7 @@
+ else
+   cf_cv_shlib_version=auto
+ fi;
+-	echo "$as_me:4398: result: $cf_cv_shlib_version" >&5
++	echo "$as_me:4881: result: $cf_cv_shlib_version" >&5
+ echo "${ECHO_T}$cf_cv_shlib_version" >&6
+ 
+ 	cf_cv_rm_so_locs=no
+@@ -4404,14 +4887,14 @@
+ 	CC_SHARED_OPTS=
+ 	if test "$GCC" = yes
+ 	then
+-		echo "$as_me:4407: checking which $CC option to use" >&5
++		echo "$as_me:4890: checking which $CC option to use" >&5
+ echo $ECHO_N "checking which $CC option to use... $ECHO_C" >&6
+ 		cf_save_CFLAGS="$CFLAGS"
+ 		for CC_SHARED_OPTS in -fPIC -fpic ''
+ 		do
+ 			CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
+ 			cat >conftest.$ac_ext <<_ACEOF
+-#line 4414 "configure"
++#line 4897 "configure"
+ #include "confdefs.h"
+ #include <stdio.h>
+ int
+@@ -4423,16 +4906,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:4426: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:4909: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:4429: \$? = $ac_status" >&5
++  echo "$as_me:4912: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:4432: \"$ac_try\"") >&5
++  { (eval echo "$as_me:4915: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:4435: \$? = $ac_status" >&5
++  echo "$as_me:4918: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   break
+ else
+@@ -4441,7 +4924,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ 		done
+-		echo "$as_me:4444: result: $CC_SHARED_OPTS" >&5
++		echo "$as_me:4927: result: $CC_SHARED_OPTS" >&5
+ echo "${ECHO_T}$CC_SHARED_OPTS" >&6
+ 		CFLAGS="$cf_save_CFLAGS"
+ 	fi
+@@ -4480,8 +4963,13 @@
+ 		;;
+ 	irix*)
+ 		if test "$cf_cv_ld_rpath" = yes ; then
+-			cf_ld_rpath_opt="-Wl,-rpath,"
+-			EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
++			if test "$GCC" = yes; then
++				cf_ld_rpath_opt="-Wl,-rpath,"
++				EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
++			else
++				cf_ld_rpath_opt="-rpath "
++				EXTRA_LDFLAGS="-rpath \$(libdir) $EXTRA_LDFLAGS"
++			fi
+ 		fi
+ 		# tested with IRIX 5.2 and 'cc'.
+ 		if test "$GCC" != yes; then
+@@ -4625,7 +5113,7 @@
+ 			test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
+ 			;;
+ 		*)
+-			{ echo "$as_me:4628: WARNING: ignored --with-shlib-version" >&5
++			{ echo "$as_me:5116: WARNING: ignored --with-shlib-version" >&5
+ echo "$as_me: WARNING: ignored --with-shlib-version" >&2;}
+ 			;;
+ 		esac
+@@ -4633,12 +5121,12 @@
+ 	esac
+ 
+ 	if test -n "$cf_ld_rpath_opt" ; then
+-		echo "$as_me:4636: checking if we need a space after rpath option" >&5
++		echo "$as_me:5124: checking if we need a space after rpath option" >&5
+ echo $ECHO_N "checking if we need a space after rpath option... $ECHO_C" >&6
+ 		cf_save_LIBS="$LIBS"
+ 		LIBS="$LIBS ${cf_ld_rpath_opt}$libdir"
+ 		cat >conftest.$ac_ext <<_ACEOF
+-#line 4641 "configure"
++#line 5129 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -4650,16 +5138,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:4653: \"$ac_link\"") >&5
++if { (eval echo "$as_me:5141: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:4656: \$? = $ac_status" >&5
++  echo "$as_me:5144: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:4659: \"$ac_try\"") >&5
++  { (eval echo "$as_me:5147: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:4662: \$? = $ac_status" >&5
++  echo "$as_me:5150: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_rpath_space=no
+ else
+@@ -4669,7 +5157,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ 		LIBS="$cf_save_LIBS"
+-		echo "$as_me:4672: result: $cf_rpath_space" >&5
++		echo "$as_me:5160: result: $cf_rpath_space" >&5
+ echo "${ECHO_T}$cf_rpath_space" >&6
+ 		test "$cf_rpath_space" = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
+ 		MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
+@@ -4678,7 +5166,7 @@
+ if test "$CC_SHARED_OPTS" = "unknown"; then
+ 	for model in $cf_list_models; do
+ 		if test "$model" = "shared"; then
+-			{ { echo "$as_me:4681: error: Shared libraries are not supported in this version" >&5
++			{ { echo "$as_me:5169: error: Shared libraries are not supported in this version" >&5
+ echo "$as_me: error: Shared libraries are not supported in this version" >&2;}
+    { (exit 1); exit 1; }; }
+ 		fi
+@@ -4688,7 +5176,7 @@
+ ###############################################################################
+ 
+ ###	use option --disable-overwrite to leave out the link to -lcurses
+-echo "$as_me:4691: checking if you wish to install ncurses overwriting curses" >&5
++echo "$as_me:5179: checking if you wish to install ncurses overwriting curses" >&5
+ echo $ECHO_N "checking if you wish to install ncurses overwriting curses... $ECHO_C" >&6
+ 
+ # Check whether --enable-overwrite or --disable-overwrite was given.
+@@ -4698,10 +5186,10 @@
+ else
+   if test "$prefix" = "/usr" ; then with_overwrite=yes; else with_overwrite=no; fi
+ fi;
+-echo "$as_me:4701: result: $with_overwrite" >&5
++echo "$as_me:5189: result: $with_overwrite" >&5
+ echo "${ECHO_T}$with_overwrite" >&6
+ 
+-echo "$as_me:4704: checking if external terminfo-database is used" >&5
++echo "$as_me:5192: checking if external terminfo-database is used" >&5
+ echo $ECHO_N "checking if external terminfo-database is used... $ECHO_C" >&6
+ 
+ # Check whether --enable-database or --disable-database was given.
+@@ -4711,7 +5199,7 @@
+ else
+   use_database=yes
+ fi;
+-echo "$as_me:4714: result: $use_database" >&5
++echo "$as_me:5202: result: $use_database" >&5
+ echo "${ECHO_T}$use_database" >&6
+ 
+ case $host_os in #(vi
+@@ -4733,7 +5221,7 @@
+ #define USE_DATABASE 1
+ EOF
+ 
+-	echo "$as_me:4736: checking which terminfo source-file will be installed" >&5
++	echo "$as_me:5224: checking which terminfo source-file will be installed" >&5
+ echo $ECHO_N "checking which terminfo source-file will be installed... $ECHO_C" >&6
+ 
+ # Check whether --enable-database or --disable-database was given.
+@@ -4741,11 +5229,11 @@
+   enableval="$enable_database"
+   TERMINFO_SRC=$withval
+ fi;
+-	echo "$as_me:4744: result: $TERMINFO_SRC" >&5
++	echo "$as_me:5232: result: $TERMINFO_SRC" >&5
+ echo "${ECHO_T}$TERMINFO_SRC" >&6
+ fi
+ 
+-echo "$as_me:4748: checking for list of fallback descriptions" >&5
++echo "$as_me:5236: checking for list of fallback descriptions" >&5
+ echo $ECHO_N "checking for list of fallback descriptions... $ECHO_C" >&6
+ 
+ # Check whether --with-fallbacks or --without-fallbacks was given.
+@@ -4755,17 +5243,35 @@
+ else
+   with_fallback=
+ fi;
+-echo "$as_me:4758: result: $with_fallback" >&5
++echo "$as_me:5246: result: $with_fallback" >&5
+ echo "${ECHO_T}$with_fallback" >&6
+ FALLBACK_LIST=`echo "$with_fallback" | sed -e 's/,/ /g'`
+ 
++echo "$as_me:5250: checking if you want modern xterm or antique" >&5
++echo $ECHO_N "checking if you want modern xterm or antique... $ECHO_C" >&6
++
++# Check whether --with-xterm-new or --without-xterm-new was given.
++if test "${with_xterm_new+set}" = set; then
++  withval="$with_xterm_new"
++  with_xterm_new=$withval
++else
++  with_xterm_new=yes
++fi;
++case $with_xterm_new in
++no)	with_xterm_new=xterm-old;;
++*)	with_xterm_new=xterm-new;;
++esac
++echo "$as_me:5264: result: $with_xterm_new" >&5
++echo "${ECHO_T}$with_xterm_new" >&6
++WHICH_XTERM=$with_xterm_new
++
+ MAKE_TERMINFO=
+ if test "$use_database" = no ; then
+ 	TERMINFO="${datadir}/terminfo"
+ 	MAKE_TERMINFO="#"
+ else
+ 
+-echo "$as_me:4768: checking for list of terminfo directories" >&5
++echo "$as_me:5274: checking for list of terminfo directories" >&5
+ echo $ECHO_N "checking for list of terminfo directories... $ECHO_C" >&6
+ 
+ # Check whether --with-terminfo-dirs or --without-terminfo-dirs was given.
+@@ -4799,7 +5305,7 @@
+   cf_src_path=`echo $cf_src_path | sed -e s%NONE%$ac_default_prefix%`
+   ;;
+ *)
+-  { { echo "$as_me:4802: error: expected a pathname, not \"$cf_src_path\"" >&5
++  { { echo "$as_me:5308: error: expected a pathname, not \"$cf_src_path\"" >&5
+ echo "$as_me: error: expected a pathname, not \"$cf_src_path\"" >&2;}
+    { (exit 1); exit 1; }; }
+   ;;
+@@ -4812,13 +5318,13 @@
+ 
+ eval 'TERMINFO_DIRS="$cf_dst_path"'
+ 
+-echo "$as_me:4815: result: $TERMINFO_DIRS" >&5
++echo "$as_me:5321: result: $TERMINFO_DIRS" >&5
+ echo "${ECHO_T}$TERMINFO_DIRS" >&6
+ test -n "$TERMINFO_DIRS" && cat >>confdefs.h <<EOF
+ #define TERMINFO_DIRS "$TERMINFO_DIRS"
+ EOF
+ 
+-echo "$as_me:4821: checking for default terminfo directory" >&5
++echo "$as_me:5327: checking for default terminfo directory" >&5
+ echo $ECHO_N "checking for default terminfo directory... $ECHO_C" >&6
+ 
+ # Check whether --with-default-terminfo-dir or --without-default-terminfo-dir was given.
+@@ -4847,7 +5353,7 @@
+   withval=`echo $withval | sed -e s%NONE%$ac_default_prefix%`
+   ;;
+ *)
+-  { { echo "$as_me:4850: error: expected a pathname, not \"$withval\"" >&5
++  { { echo "$as_me:5356: error: expected a pathname, not \"$withval\"" >&5
+ echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
+    { (exit 1); exit 1; }; }
+   ;;
+@@ -4855,7 +5361,7 @@
+ 
+ eval TERMINFO="$withval"
+ 
+-echo "$as_me:4858: result: $TERMINFO" >&5
++echo "$as_me:5364: result: $TERMINFO" >&5
+ echo "${ECHO_T}$TERMINFO" >&6
+ cat >>confdefs.h <<EOF
+ #define TERMINFO "$TERMINFO"
+@@ -4865,7 +5371,7 @@
+ 
+ ###	use option --disable-big-core to make tic run on small machines
+ ###	We need 4Mb, check if we can allocate 50% more than that.
+-echo "$as_me:4868: checking if big-core option selected" >&5
++echo "$as_me:5374: checking if big-core option selected" >&5
+ echo $ECHO_N "checking if big-core option selected... $ECHO_C" >&6
+ 
+ # Check whether --enable-big-core or --disable-big-core was given.
+@@ -4877,7 +5383,7 @@
+   with_big_core=no
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 4880 "configure"
++#line 5386 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdlib.h>
+@@ -4891,15 +5397,15 @@
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:4894: \"$ac_link\"") >&5
++if { (eval echo "$as_me:5400: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:4897: \$? = $ac_status" >&5
++  echo "$as_me:5403: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:4899: \"$ac_try\"") >&5
++  { (eval echo "$as_me:5405: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:4902: \$? = $ac_status" >&5
++  echo "$as_me:5408: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   with_big_core=yes
+ else
+@@ -4911,14 +5417,14 @@
+ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+ fi
+ fi;
+-echo "$as_me:4914: result: $with_big_core" >&5
++echo "$as_me:5420: result: $with_big_core" >&5
+ echo "${ECHO_T}$with_big_core" >&6
+ test "$with_big_core" = "yes" && cat >>confdefs.h <<\EOF
+ #define HAVE_BIG_CORE 1
+ EOF
+ 
+ ###	use option --enable-termcap to compile in the termcap fallback support
+-echo "$as_me:4921: checking if you want termcap-fallback support" >&5
++echo "$as_me:5427: checking if you want termcap-fallback support" >&5
+ echo $ECHO_N "checking if you want termcap-fallback support... $ECHO_C" >&6
+ 
+ # Check whether --enable-termcap or --disable-termcap was given.
+@@ -4928,13 +5434,13 @@
+ else
+   with_termcap=no
+ fi;
+-echo "$as_me:4931: result: $with_termcap" >&5
++echo "$as_me:5437: result: $with_termcap" >&5
+ echo "${ECHO_T}$with_termcap" >&6
+ 
+ if test "$with_termcap" != "yes" ; then
+ 	if test "$use_database" = no ; then
+ 		if test -z "$with_fallback" ; then
+-			{ { echo "$as_me:4937: error: You have disabled the database w/o specifying fallbacks" >&5
++			{ { echo "$as_me:5443: error: You have disabled the database w/o specifying fallbacks" >&5
+ echo "$as_me: error: You have disabled the database w/o specifying fallbacks" >&2;}
+    { (exit 1); exit 1; }; }
+ 		fi
+@@ -4949,7 +5455,7 @@
+ #define USE_TERMCAP 1
+ EOF
+ 
+-echo "$as_me:4952: checking for list of termcap files" >&5
++echo "$as_me:5458: checking for list of termcap files" >&5
+ echo $ECHO_N "checking for list of termcap files... $ECHO_C" >&6
+ 
+ # Check whether --with-termpath or --without-termpath was given.
+@@ -4983,7 +5489,7 @@
+   cf_src_path=`echo $cf_src_path | sed -e s%NONE%$ac_default_prefix%`
+   ;;
+ *)
+-  { { echo "$as_me:4986: error: expected a pathname, not \"$cf_src_path\"" >&5
++  { { echo "$as_me:5492: error: expected a pathname, not \"$cf_src_path\"" >&5
+ echo "$as_me: error: expected a pathname, not \"$cf_src_path\"" >&2;}
+    { (exit 1); exit 1; }; }
+   ;;
+@@ -4996,14 +5502,14 @@
+ 
+ eval 'TERMPATH="$cf_dst_path"'
+ 
+-echo "$as_me:4999: result: $TERMPATH" >&5
++echo "$as_me:5505: result: $TERMPATH" >&5
+ echo "${ECHO_T}$TERMPATH" >&6
+ test -n "$TERMPATH" && cat >>confdefs.h <<EOF
+ #define TERMPATH "$TERMPATH"
+ EOF
+ 
+ ###	use option --enable-getcap to use a hacked getcap for reading termcaps
+-echo "$as_me:5006: checking if fast termcap-loader is needed" >&5
++echo "$as_me:5512: checking if fast termcap-loader is needed" >&5
+ echo $ECHO_N "checking if fast termcap-loader is needed... $ECHO_C" >&6
+ 
+ # Check whether --enable-getcap or --disable-getcap was given.
+@@ -5013,13 +5519,13 @@
+ else
+   with_getcap=no
+ fi;
+-echo "$as_me:5016: result: $with_getcap" >&5
++echo "$as_me:5522: result: $with_getcap" >&5
+ echo "${ECHO_T}$with_getcap" >&6
+ test "$with_getcap" = "yes" && cat >>confdefs.h <<\EOF
+ #define USE_GETCAP 1
+ EOF
+ 
+-echo "$as_me:5022: checking if translated termcaps will be cached in ~/.terminfo" >&5
++echo "$as_me:5528: checking if translated termcaps will be cached in ~/.terminfo" >&5
+ echo $ECHO_N "checking if translated termcaps will be cached in ~/.terminfo... $ECHO_C" >&6
+ 
+ # Check whether --enable-getcap-cache or --disable-getcap-cache was given.
+@@ -5029,7 +5535,7 @@
+ else
+   with_getcap_cache=no
+ fi;
+-echo "$as_me:5032: result: $with_getcap_cache" >&5
++echo "$as_me:5538: result: $with_getcap_cache" >&5
+ echo "${ECHO_T}$with_getcap_cache" >&6
+ test "$with_getcap_cache" = "yes" && cat >>confdefs.h <<\EOF
+ #define USE_GETCAP_CACHE 1
+@@ -5038,7 +5544,7 @@
+ fi
+ 
+ ###   Use option --disable-home-terminfo to completely remove ~/.terminfo
+-echo "$as_me:5041: checking if ~/.terminfo is wanted" >&5
++echo "$as_me:5547: checking if ~/.terminfo is wanted" >&5
+ echo $ECHO_N "checking if ~/.terminfo is wanted... $ECHO_C" >&6
+ 
+ # Check whether --enable-home-terminfo or --disable-home-terminfo was given.
+@@ -5048,10 +5554,28 @@
+ else
+   with_home_terminfo=yes
+ fi;
++echo "$as_me:5557: result: $with_home_terminfo" >&5
++echo "${ECHO_T}$with_home_terminfo" >&6
+ test "$with_home_terminfo" = "yes" && cat >>confdefs.h <<\EOF
+ #define USE_HOME_TERMINFO 1
+ EOF
+ 
++echo "$as_me:5563: checking if you want to use restrict environment when running as root" >&5
++echo $ECHO_N "checking if you want to use restrict environment when running as root... $ECHO_C" >&6
++
++# Check whether --enable-root-environ or --disable-root-environ was given.
++if test "${enable_root_environ+set}" = set; then
++  enableval="$enable_root_environ"
++  with_root_environ=$enableval
++else
++  with_root_environ=yes
++fi;
++echo "$as_me:5573: result: $with_root_environ" >&5
++echo "${ECHO_T}$with_root_environ" >&6
++test "$with_root_environ" = yes && cat >>confdefs.h <<\EOF
++#define USE_ROOT_ENVIRON 1
++EOF
++
+ ###   Use option --enable-symlinks to make tic use symlinks, not hard links
+ ###   to reduce storage requirements for the terminfo database.
+ 
+@@ -5060,13 +5584,13 @@
+ 	unlink
+ do
+ as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+-echo "$as_me:5063: checking for $ac_func" >&5
++echo "$as_me:5587: checking for $ac_func" >&5
+ echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_var+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 5069 "configure"
++#line 5593 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char $ac_func (); below.  */
+@@ -5097,16 +5621,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:5100: \"$ac_link\"") >&5
++if { (eval echo "$as_me:5624: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:5103: \$? = $ac_status" >&5
++  echo "$as_me:5627: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:5106: \"$ac_try\"") >&5
++  { (eval echo "$as_me:5630: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:5109: \$? = $ac_status" >&5
++  echo "$as_me:5633: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   eval "$as_ac_var=yes"
+ else
+@@ -5116,7 +5640,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:5119: result: `eval echo '${'$as_ac_var'}'`" >&5
++echo "$as_me:5643: result: `eval echo '${'$as_ac_var'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+ if test `eval echo '${'$as_ac_var'}'` = yes; then
+   cat >>confdefs.h <<EOF
+@@ -5133,13 +5657,13 @@
+ 		symlink
+ do
+ as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+-echo "$as_me:5136: checking for $ac_func" >&5
++echo "$as_me:5660: checking for $ac_func" >&5
+ echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_var+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 5142 "configure"
++#line 5666 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char $ac_func (); below.  */
+@@ -5170,16 +5694,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:5173: \"$ac_link\"") >&5
++if { (eval echo "$as_me:5697: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:5176: \$? = $ac_status" >&5
++  echo "$as_me:5700: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:5179: \"$ac_try\"") >&5
++  { (eval echo "$as_me:5703: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:5182: \$? = $ac_status" >&5
++  echo "$as_me:5706: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   eval "$as_ac_var=yes"
+ else
+@@ -5189,7 +5713,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:5192: result: `eval echo '${'$as_ac_var'}'`" >&5
++echo "$as_me:5716: result: `eval echo '${'$as_ac_var'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+ if test `eval echo '${'$as_ac_var'}'` = yes; then
+   cat >>confdefs.h <<EOF
+@@ -5200,7 +5724,7 @@
+ done
+ 
+ else
+-	echo "$as_me:5203: checking if link/symlink functions work" >&5
++	echo "$as_me:5727: checking if link/symlink functions work" >&5
+ echo $ECHO_N "checking if link/symlink functions work... $ECHO_C" >&6
+ if test "${cf_cv_link_funcs+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -5213,7 +5737,7 @@
+ 			eval 'ac_cv_func_'$cf_func'=error'
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 5216 "configure"
++#line 5740 "configure"
+ #include "confdefs.h"
+ 
+ #include <sys/types.h>
+@@ -5243,15 +5767,15 @@
+ 
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:5246: \"$ac_link\"") >&5
++if { (eval echo "$as_me:5770: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:5249: \$? = $ac_status" >&5
++  echo "$as_me:5773: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:5251: \"$ac_try\"") >&5
++  { (eval echo "$as_me:5775: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:5254: \$? = $ac_status" >&5
++  echo "$as_me:5778: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+ 
+ 			cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
+@@ -5269,7 +5793,7 @@
+ 		test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
+ 
+ fi
+-echo "$as_me:5272: result: $cf_cv_link_funcs" >&5
++echo "$as_me:5796: result: $cf_cv_link_funcs" >&5
+ echo "${ECHO_T}$cf_cv_link_funcs" >&6
+ 	test "$ac_cv_func_link"    = yes && cat >>confdefs.h <<\EOF
+ #define HAVE_LINK 1
+@@ -5285,27 +5809,27 @@
+ with_symlinks=no
+ 
+ if test "$ac_cv_func_link" != yes ; then
+-    echo "$as_me:5288: checking if tic should use symbolic links" >&5
++    echo "$as_me:5812: checking if tic should use symbolic links" >&5
+ echo $ECHO_N "checking if tic should use symbolic links... $ECHO_C" >&6
+     if test "$ac_cv_func_symlink" = yes ; then
+     	with_symlinks=yes
+     else
+     	with_symlinks=no
+     fi
+-    echo "$as_me:5295: result: $with_symlinks" >&5
++    echo "$as_me:5819: result: $with_symlinks" >&5
+ echo "${ECHO_T}$with_symlinks" >&6
+ elif test "$ac_cv_func_symlink" != yes ; then
+-    echo "$as_me:5298: checking if tic should use hard links" >&5
++    echo "$as_me:5822: checking if tic should use hard links" >&5
+ echo $ECHO_N "checking if tic should use hard links... $ECHO_C" >&6
+     if test "$ac_cv_func_link" = yes ; then
+     	with_links=yes
+     else
+     	with_links=no
+     fi
+-    echo "$as_me:5305: result: $with_links" >&5
++    echo "$as_me:5829: result: $with_links" >&5
+ echo "${ECHO_T}$with_links" >&6
+ else
+-    echo "$as_me:5308: checking if tic should use symbolic links" >&5
++    echo "$as_me:5832: checking if tic should use symbolic links" >&5
+ echo $ECHO_N "checking if tic should use symbolic links... $ECHO_C" >&6
+ 
+ # Check whether --enable-symlinks or --disable-symlinks was given.
+@@ -5315,7 +5839,7 @@
+ else
+   with_symlinks=no
+ fi;
+-    echo "$as_me:5318: result: $with_symlinks" >&5
++    echo "$as_me:5842: result: $with_symlinks" >&5
+ echo "${ECHO_T}$with_symlinks" >&6
+ fi
+ 
+@@ -5328,7 +5852,7 @@
+ EOF
+ 
+ ###   use option --enable-broken-linker to force on use of broken-linker support
+-echo "$as_me:5331: checking if you want broken-linker support code" >&5
++echo "$as_me:5855: checking if you want broken-linker support code" >&5
+ echo $ECHO_N "checking if you want broken-linker support code... $ECHO_C" >&6
+ 
+ # Check whether --enable-broken_linker or --disable-broken_linker was given.
+@@ -5338,7 +5862,7 @@
+ else
+   with_broken_linker=${BROKEN_LINKER-no}
+ fi;
+-echo "$as_me:5341: result: $with_broken_linker" >&5
++echo "$as_me:5865: result: $with_broken_linker" >&5
+ echo "${ECHO_T}$with_broken_linker" >&6
+ 
+ BROKEN_LINKER=0
+@@ -5362,1774 +5886,1901 @@
+ 	esac
+ fi
+ 
+-###   use option --with-bool to override bool's type
+-echo "$as_me:5366: checking for type of bool" >&5
+-echo $ECHO_N "checking for type of bool... $ECHO_C" >&6
++###   use option --enable-widec to turn on use of wide-character support
++NCURSES_CH_T=chtype
++NCURSES_LIBUTF8=0
+ 
+-# Check whether --with-bool or --without-bool was given.
+-if test "${with_bool+set}" = set; then
+-  withval="$with_bool"
+-  NCURSES_BOOL="$withval"
+-else
+-  NCURSES_BOOL=auto
+-fi;
+-echo "$as_me:5376: result: $NCURSES_BOOL" >&5
+-echo "${ECHO_T}$NCURSES_BOOL" >&6
++NEED_WCHAR_H=0
++NCURSES_MBSTATE_T=0
++NCURSES_WCHAR_T=0
++NCURSES_WINT_T=0
+ 
+-###   use option --with-ospeed to override ospeed's type
+-echo "$as_me:5380: checking for type of ospeed" >&5
+-echo $ECHO_N "checking for type of ospeed... $ECHO_C" >&6
++# Check to define _XOPEN_SOURCE "automatically"
+ 
+-# Check whether --with-ospeed or --without-ospeed was given.
+-if test "${with_ospeed+set}" = set; then
+-  withval="$with_ospeed"
+-  NCURSES_OSPEED="$withval"
+-else
+-  NCURSES_OSPEED=short
+-fi;
+-echo "$as_me:5390: result: $NCURSES_OSPEED" >&5
+-echo "${ECHO_T}$NCURSES_OSPEED" >&6
++INTEL_COMPILER=no
+ 
+-###   use option --enable-bsdpad to have tputs process BSD-style prefix padding
+-echo "$as_me:5394: checking if tputs should process BSD-style prefix padding" >&5
+-echo $ECHO_N "checking if tputs should process BSD-style prefix padding... $ECHO_C" >&6
++if test "$GCC" = yes ; then
++	case $host_os in
++	linux*|gnu*)
++		echo "$as_me:5905: checking if this is really Intel compiler" >&5
++echo $ECHO_N "checking if this is really Intel compiler... $ECHO_C" >&6
++		cf_save_CFLAGS="$CFLAGS"
++		CFLAGS="$CFLAGS -no-gcc"
++		cat >conftest.$ac_ext <<_ACEOF
++#line 5910 "configure"
++#include "confdefs.h"
+ 
+-# Check whether --enable-bsdpad or --disable-bsdpad was given.
+-if test "${enable_bsdpad+set}" = set; then
+-  enableval="$enable_bsdpad"
+-  with_bsdpad=$enableval
+-else
+-  with_bsdpad=no
+-fi;
+-echo "$as_me:5404: result: $with_bsdpad" >&5
+-echo "${ECHO_T}$with_bsdpad" >&6
+-test "$with_bsdpad" = yes && cat >>confdefs.h <<\EOF
+-#define BSD_TPUTS 1
+-EOF
++int
++main ()
++{
+ 
+-### Enable compiling-in rcs id's
+-echo "$as_me:5411: checking if RCS identifiers should be compiled-in" >&5
+-echo $ECHO_N "checking if RCS identifiers should be compiled-in... $ECHO_C" >&6
++#ifdef __INTEL_COMPILER
++#else
++make an error
++#endif
++
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:5927: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:5930: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:5933: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:5936: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  INTEL_COMPILER=yes
++cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
+ 
+-# Check whether --with-rcs-ids or --without-rcs-ids was given.
+-if test "${with_rcs_ids+set}" = set; then
+-  withval="$with_rcs_ids"
+-  with_rcs_ids=$withval
+ else
+-  with_rcs_ids=no
+-fi;
+-echo "$as_me:5421: result: $with_rcs_ids" >&5
+-echo "${ECHO_T}$with_rcs_ids" >&6
+-test "$with_rcs_ids" = yes && cat >>confdefs.h <<\EOF
+-#define USE_RCS_IDS 1
+-EOF
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++fi
++rm -f conftest.$ac_objext conftest.$ac_ext
++		CFLAGS="$cf_save_CFLAGS"
++		echo "$as_me:5947: result: $INTEL_COMPILER" >&5
++echo "${ECHO_T}$INTEL_COMPILER" >&6
++		;;
++	esac
++fi
+ 
+-###############################################################################
++cf_XOPEN_SOURCE=500
++cf_POSIX_C_SOURCE=199506L
+ 
+-echo "$as_me:5429: checking format of man-pages" >&5
+-echo $ECHO_N "checking format of man-pages... $ECHO_C" >&6
++case $host_os in #(vi
++freebsd*) #(vi
++	# 5.x headers associate
++	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
++	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
++	cf_POSIX_C_SOURCE=200112L
++	cf_XOPEN_SOURCE=600
++	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
++	;;
++hpux*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
++	;;
++irix[56].*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
++	;;
++linux*|gnu*) #(vi
+ 
+-# Check whether --with-manpage-format or --without-manpage-format was given.
+-if test "${with_manpage_format+set}" = set; then
+-  withval="$with_manpage_format"
+-  MANPAGE_FORMAT=$withval
++if test "$INTEL_COMPILER" = no ; then
++echo "$as_me:5974: checking if we must define _GNU_SOURCE" >&5
++echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
++if test "${cf_cv_gnu_source+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+-  MANPAGE_FORMAT=unknown
+-fi;
+ 
+-test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
+-MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
++cat >conftest.$ac_ext <<_ACEOF
++#line 5981 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int
++main ()
++{
+ 
+-cf_unknown=
++#ifndef _XOPEN_SOURCE
++make an error
++#endif
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:5996: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:5999: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6002: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6005: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_cv_gnu_source=no
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_save="$CPPFLAGS"
++	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
++	 cat >conftest.$ac_ext <<_ACEOF
++#line 6014 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int
++main ()
++{
+ 
+-case $MANPAGE_FORMAT in
+-unknown)
+-  if test -z "$MANPATH" ; then
+-    MANPATH="/usr/man:/usr/share/man"
+-  fi
++#ifdef _XOPEN_SOURCE
++make an error
++#endif
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6029: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6032: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6035: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6038: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_cv_gnu_source=no
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_cv_gnu_source=yes
++fi
++rm -f conftest.$ac_objext conftest.$ac_ext
++	CPPFLAGS="$cf_save"
+ 
+-  # look for the 'date' man-page (it's most likely to be installed!)
+-  MANPAGE_FORMAT=
+-  cf_preform=no
+-  cf_catonly=yes
+-  cf_example=date
++fi
++rm -f conftest.$ac_objext conftest.$ac_ext
+ 
+-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
+-  for cf_dir in $MANPATH; do
+-    test -z "$cf_dir" && cf_dir=/usr/man
+-    for cf_name in $cf_dir/man*/$cf_example.[01]* $cf_dir/cat*/$cf_example.[01]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
+-    do
+-      cf_test=`echo $cf_name | sed -e 's/*//'`
+-      if test "x$cf_test" = "x$cf_name" ; then
++fi
++echo "$as_me:6053: result: $cf_cv_gnu_source" >&5
++echo "${ECHO_T}$cf_cv_gnu_source" >&6
++test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
++fi
+ 
+-	case "$cf_name" in
+-	*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
+-	*.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
+-	*.0)	MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
+-	*)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
+-	esac
++	;;
++mirbsd*) #(vi
++	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
++	;;
++netbsd*) #(vi
++	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
++	;;
++openbsd*) #(vi
++	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
++	;;
++osf[45]*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
++	;;
++sco*) #(vi
++	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
++	;;
++solaris*) #(vi
++	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
++	;;
++*)
++	echo "$as_me:6078: checking if we should define _XOPEN_SOURCE" >&5
++echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
++if test "${cf_cv_xopen_source+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
+ 
+-	case "$cf_name" in
+-	$cf_dir/man*)
+-	  cf_catonly=no
+-	  ;;
+-	$cf_dir/cat*)
+-	  cf_preform=yes
+-	  ;;
+-	esac
+-	break
+-      fi
++	cat >conftest.$ac_ext <<_ACEOF
++#line 6085 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int
++main ()
++{
+ 
+-      # if we found a match in either man* or cat*, stop looking
+-      if test -n "$MANPAGE_FORMAT" ; then
+-	cf_found=no
+-	test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
+-	test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
+-	case "$cf_name" in
+-	$cf_dir/cat*)
+-	  cf_found=yes
+-	  ;;
+-	esac
+-	test $cf_found=yes && break
+-      fi
+-    done
+-    # only check the first directory in $MANPATH where we find manpages
+-    if test -n "$MANPAGE_FORMAT" ; then
+-       break
+-    fi
+-  done
+-  # if we did not find the example, just assume it is normal
+-  test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
+-  IFS="$ac_save_ifs"
+-  ;;
+-*)
+-  for cf_option in $MANPAGE_FORMAT; do
+-     case $cf_option in #(vi
+-     gzip|compress|BSDI|normal|formatted|catonly)
+-       ;;
+-     *)
+-       cf_unknown="$cf_unknown $cf_option"
+-       ;;
+-     esac
+-  done
+-  ;;
+-esac
++#ifndef _XOPEN_SOURCE
++make an error
++#endif
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6100: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6103: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6106: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6109: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_cv_xopen_source=no
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_save="$CPPFLAGS"
++	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
++	 cat >conftest.$ac_ext <<_ACEOF
++#line 6118 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int
++main ()
++{
++
++#ifdef _XOPEN_SOURCE
++make an error
++#endif
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6133: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6136: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6139: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6142: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_cv_xopen_source=no
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_cv_xopen_source=$cf_XOPEN_SOURCE
++fi
++rm -f conftest.$ac_objext conftest.$ac_ext
++	CPPFLAGS="$cf_save"
+ 
+-echo "$as_me:5518: result: $MANPAGE_FORMAT" >&5
+-echo "${ECHO_T}$MANPAGE_FORMAT" >&6
+-if test -n "$cf_unknown" ; then
+-  { echo "$as_me:5521: WARNING: Unexpected manpage-format $cf_unknown" >&5
+-echo "$as_me: WARNING: Unexpected manpage-format $cf_unknown" >&2;}
+ fi
++rm -f conftest.$ac_objext conftest.$ac_ext
+ 
+-echo "$as_me:5525: checking for manpage renaming" >&5
+-echo $ECHO_N "checking for manpage renaming... $ECHO_C" >&6
++fi
++echo "$as_me:6157: result: $cf_cv_xopen_source" >&5
++echo "${ECHO_T}$cf_cv_xopen_source" >&6
++test "$cf_cv_xopen_source" != no && CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE -D_XOPEN_SOURCE=$cf_cv_xopen_source"
+ 
+-# Check whether --with-manpage-renames or --without-manpage-renames was given.
+-if test "${with_manpage_renames+set}" = set; then
+-  withval="$with_manpage_renames"
+-  MANPAGE_RENAMES=$withval
++cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
++echo "$as_me:6162: checking if we should define _POSIX_C_SOURCE" >&5
++echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
++if test "${cf_cv_posix_c_source+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+-  MANPAGE_RENAMES=yes
+-fi;
+ 
+-case ".$MANPAGE_RENAMES" in #(vi
+-.no) #(vi
+-  ;;
+-.|.yes)
+-  # Debian 'man' program?
+-  if test -f /etc/debian_version ; then
+-    MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
+-  else
+-    MANPAGE_RENAMES=no
+-  fi
+-  ;;
+-esac
++echo "(line 6168) testing if the symbol is already defined go no further ..." 1>&5
+ 
+-if test "$MANPAGE_RENAMES" != no ; then
+-  if test -f $srcdir/man/$MANPAGE_RENAMES ; then
+-    MANPAGE_RENAMES=`cd $srcdir/man && pwd`/$MANPAGE_RENAMES
+-  elif test ! -f $MANPAGE_RENAMES ; then
+-    { { echo "$as_me:5553: error: not a filename: $MANPAGE_RENAMES" >&5
+-echo "$as_me: error: not a filename: $MANPAGE_RENAMES" >&2;}
+-   { (exit 1); exit 1; }; }
+-  fi
++	cat >conftest.$ac_ext <<_ACEOF
++#line 6171 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int
++main ()
++{
+ 
+-  test ! -d man && mkdir man
++#ifndef _POSIX_C_SOURCE
++make an error
++#endif
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6186: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6189: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6192: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6195: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_cv_posix_c_source=no
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_want_posix_source=no
++	 case .$cf_POSIX_C_SOURCE in
++	 .[12]??*)
++		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
++		;;
++	 .2)
++		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
++		cf_want_posix_source=yes
++		;;
++	 .*)
++		cf_want_posix_source=yes
++		;;
++	 esac
++	 if test "$cf_want_posix_source" = yes ; then
++		cat >conftest.$ac_ext <<_ACEOF
++#line 6216 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int
++main ()
++{
+ 
+-  # Construct a sed-script to perform renaming within man-pages
+-  if test -n "$MANPAGE_RENAMES" ; then
+-    test ! -d man && mkdir man
+-    sh $srcdir/man/make_sed.sh $MANPAGE_RENAMES >man/edit_man.sed
+-  fi
++#ifdef _POSIX_SOURCE
++make an error
++#endif
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6231: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6234: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6237: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6240: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  :
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_cv_posix_c_source="$cf_cv_posix_c_source -U_POSIX_SOURCE -D_POSIX_SOURCE"
+ fi
++rm -f conftest.$ac_objext conftest.$ac_ext
++	 fi
+ 
+-echo "$as_me:5567: result: $MANPAGE_RENAMES" >&5
+-echo "${ECHO_T}$MANPAGE_RENAMES" >&6
++echo "(line 6251) testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
+ 
+-echo "$as_me:5570: checking if manpage aliases will be installed" >&5
+-echo $ECHO_N "checking if manpage aliases will be installed... $ECHO_C" >&6
++	 cf_save="$CPPFLAGS"
++	 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
+ 
+-# Check whether --with-manpage-aliases or --without-manpage-aliases was given.
+-if test "${with_manpage_aliases+set}" = set; then
+-  withval="$with_manpage_aliases"
+-  MANPAGE_ALIASES=$withval
+-else
+-  MANPAGE_ALIASES=yes
+-fi;
++echo "(line 6256) testing if the second compile does not leave our definition intact error ..." 1>&5
+ 
+-echo "$as_me:5581: result: $MANPAGE_ALIASES" >&5
+-echo "${ECHO_T}$MANPAGE_ALIASES" >&6
++	 cat >conftest.$ac_ext <<_ACEOF
++#line 6259 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int
++main ()
++{
+ 
+-if test "$LN_S" = "ln -s"; then
+-	cf_use_symlinks=yes
++#ifndef _POSIX_C_SOURCE
++make an error
++#endif
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6274: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6277: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6280: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6283: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  :
+ else
+-	cf_use_symlinks=no
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_cv_posix_c_source=no
+ fi
++rm -f conftest.$ac_objext conftest.$ac_ext
++	CPPFLAGS="$cf_save"
+ 
+-MANPAGE_SYMLINKS=no
+-if test "$MANPAGE_ALIASES" = yes ; then
+-echo "$as_me:5592: checking if manpage symlinks should be used" >&5
+-echo $ECHO_N "checking if manpage symlinks should be used... $ECHO_C" >&6
+-
+-# Check whether --with-manpage-symlinks or --without-manpage-symlinks was given.
+-if test "${with_manpage_symlinks+set}" = set; then
+-  withval="$with_manpage_symlinks"
+-  MANPAGE_SYMLINKS=$withval
+-else
+-  MANPAGE_SYMLINKS=$cf_use_symlinks
+-fi;
+-
+-if test "$$cf_use_symlinks" = no; then
+-if test "$MANPAGE_SYMLINKS" = yes ; then
+-	{ echo "$as_me:5605: WARNING: cannot make symlinks" >&5
+-echo "$as_me: WARNING: cannot make symlinks" >&2;}
+-	MANPAGE_SYMLINKS=no
+-fi
+ fi
++rm -f conftest.$ac_objext conftest.$ac_ext
+ 
+-echo "$as_me:5611: result: $MANPAGE_SYMLINKS" >&5
+-echo "${ECHO_T}$MANPAGE_SYMLINKS" >&6
+ fi
++echo "$as_me:6298: result: $cf_cv_posix_c_source" >&5
++echo "${ECHO_T}$cf_cv_posix_c_source" >&6
++test "$cf_cv_posix_c_source" != no && CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
+ 
+-echo "$as_me:5615: checking for manpage tbl" >&5
+-echo $ECHO_N "checking for manpage tbl... $ECHO_C" >&6
+-
+-# Check whether --with-manpage-tbl or --without-manpage-tbl was given.
+-if test "${with_manpage_tbl+set}" = set; then
+-  withval="$with_manpage_tbl"
+-  MANPAGE_TBL=$withval
+-else
+-  MANPAGE_TBL=no
+-fi;
+-
+-echo "$as_me:5626: result: $MANPAGE_TBL" >&5
+-echo "${ECHO_T}$MANPAGE_TBL" >&6
+-
+-  if test "$prefix" = "NONE" ; then
+-     cf_prefix="$ac_default_prefix"
+-  else
+-     cf_prefix="$prefix"
+-  fi
++	;;
++esac
+ 
+-  case "$MANPAGE_FORMAT" in # (vi
+-  *catonly*) # (vi
+-    cf_format=yes
+-    cf_inboth=no
+-    ;;
+-  *formatted*) # (vi
+-    cf_format=yes
+-    cf_inboth=yes
+-    ;;
+-  *)
+-    cf_format=no
+-    cf_inboth=no
+-    ;;
+-  esac
++# Checks for CODESET support.
+ 
+-test ! -d man && mkdir man
++  echo "$as_me:6307: checking for nl_langinfo and CODESET" >&5
++echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
++if test "${am_cv_langinfo_codeset+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++  cat >conftest.$ac_ext <<_ACEOF
++#line 6313 "configure"
++#include "confdefs.h"
++#include <langinfo.h>
++int
++main ()
++{
++char* cs = nl_langinfo(CODESET);
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:6325: \"$ac_link\"") >&5
++  (eval $ac_link) 2>&5
++  ac_status=$?
++  echo "$as_me:6328: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest$ac_exeext'
++  { (eval echo "$as_me:6331: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6334: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  am_cv_langinfo_codeset=yes
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++am_cv_langinfo_codeset=no
++fi
++rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ 
+-cf_so_strip=
+-cf_compress=
+-case "$MANPAGE_FORMAT" in #(vi
+-*compress*) #(vi
+-	cf_so_strip="Z"
+-	cf_compress=compress
+-  ;;
+-*gzip*) #(vi
+-	cf_so_strip="gz"
+-	cf_compress=gzip
+-  ;;
+-esac
++fi
++echo "$as_me:6345: result: $am_cv_langinfo_codeset" >&5
++echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
++  if test $am_cv_langinfo_codeset = yes; then
+ 
+-cf_edit_man=man/edit_man.sh
++cat >>confdefs.h <<\EOF
++#define HAVE_LANGINFO_CODESET 1
++EOF
+ 
+-cat >$cf_edit_man <<CF_EOF
+-#! /bin/sh
+-# this script is generated by the configure-script CF_MAN_PAGES macro.
+-prefix="$cf_prefix"
+-datadir="$datadir"
+-NCURSES_OSPEED="$NCURSES_OSPEED"
+-TERMINFO="$TERMINFO"
+-MKDIRS="sh `cd $srcdir && pwd`/mkinstalldirs"
+-INSTALL="$INSTALL"
+-INSTALL_DATA="$INSTALL_DATA"
+-transform="$program_transform_name"
++  fi
+ 
+-TMP=\${TMPDIR-/tmp}/man\$\$
+-trap "rm -f \$TMP" 0 1 2 5 15
++# use these variables to work around a defect in gcc's fixincludes.
++NCURSES_OK_WCHAR_T=
++NCURSES_OK_WINT_T=
+ 
+-form=\$1
+-shift || exit 1
++echo "$as_me:6359: checking if you want wide-character code" >&5
++echo $ECHO_N "checking if you want wide-character code... $ECHO_C" >&6
+ 
+-verb=\$1
+-shift || exit 1
++# Check whether --enable-widec or --disable-widec was given.
++if test "${enable_widec+set}" = set; then
++  enableval="$enable_widec"
++  with_widec=$enableval
++else
++  with_widec=no
++fi;
++echo "$as_me:6369: result: $with_widec" >&5
++echo "${ECHO_T}$with_widec" >&6
++if test "$with_widec" = yes ; then
++	LIB_SUFFIX="w${LIB_SUFFIX}"
++	cat >>confdefs.h <<\EOF
++#define USE_WIDEC_SUPPORT 1
++EOF
+ 
+-mandir=\$1
+-shift || exit 1
++echo "$as_me:6377: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
++echo $ECHO_N "checking if we must define _XOPEN_SOURCE_EXTENDED... $ECHO_C" >&6
++cat >conftest.$ac_ext <<_ACEOF
++#line 6380 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
+ 
+-srcdir=\$1
+-shift || exit 1
++int
++main ()
++{
+ 
+-if test "\$form" = normal ; then
+-	if test "$cf_format" = yes ; then
+-	if test "$cf_inboth" = no ; then
+-		sh \$0 format \$verb \$mandir \$srcdir \$*
+-		exit $?
+-	fi
+-	fi
+-	cf_subdir=\$mandir/man
+-	cf_tables=$MANPAGE_TBL
++#ifndef _XOPEN_SOURCE_EXTENDED
++make an error
++#endif
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6396: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6399: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6402: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6405: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_result=no
+ else
+-	cf_subdir=\$mandir/cat
+-	cf_tables=yes
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_result=yes
+ fi
++rm -f conftest.$ac_objext conftest.$ac_ext
++echo "$as_me:6414: result: $cf_result" >&5
++echo "${ECHO_T}$cf_result" >&6
+ 
+-# process the list of source-files
+-for i in \$* ; do
+-case \$i in #(vi
+-*.orig|*.rej) ;; #(vi
+-*.[0-9]*)
+-	section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
+-	if test \$verb = installing ; then
+-	if test ! -d \$cf_subdir\${section} ; then
+-		\$MKDIRS \$cf_subdir\$section
+-	fi
+-	fi
+-	aliases=
+-	source=\`basename \$i\`
+-	inalias=\$source
+-	test ! -f \$inalias && inalias="\$srcdir/\$inalias"
+-	if test ! -f \$inalias ; then
+-		echo .. skipped \$source
+-		continue
+-	fi
+-CF_EOF
++if test "$cf_result" = yes ; then
++	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
++elif test "x" != "x" ; then
++	echo "$as_me:6420: checking checking for compatible value versus " >&5
++echo $ECHO_N "checking checking for compatible value versus ... $ECHO_C" >&6
++	cat >conftest.$ac_ext <<_ACEOF
++#line 6423 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
+ 
+-if test "$MANPAGE_ALIASES" != no ; then
+-cat >>$cf_edit_man <<CF_EOF
+-	aliases=\`sed -f \$srcdir/manlinks.sed \$inalias | sort -u\`
+-CF_EOF
+-fi
++int
++main ()
++{
+ 
+-if test "$MANPAGE_RENAMES" = no ; then
+-cat >>$cf_edit_man <<CF_EOF
+-	# perform program transformations for section 1 man pages
+-	if test \$section = 1 ; then
+-		target=\$cf_subdir\${section}/\`echo \$source|sed "\${transform}"\`
+-	else
+-		target=\$cf_subdir\${section}/\$source
+-	fi
+-CF_EOF
++#if _XOPEN_SOURCE_EXTENDED- < 0
++make an error
++#endif
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6439: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6442: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6445: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6448: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_result=yes
+ else
+-cat >>$cf_edit_man <<CF_EOF
+-	target=\`grep "^\$source" $MANPAGE_RENAMES | $AWK '{print \$2}'\`
+-	if test -z "\$target" ; then
+-		echo '? missing rename for '\$source
+-		target="\$source"
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_result=no
++fi
++rm -f conftest.$ac_objext conftest.$ac_ext
++	echo "$as_me:6457: result: $cf_result" >&5
++echo "${ECHO_T}$cf_result" >&6
++	if test "$cf_result" = no ; then
++		# perhaps we can override it - try...
++		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED="
+ 	fi
+-	target="\$cf_subdir\${section}/\${target}"
+-CF_EOF
+ fi
+ 
+-	# replace variables in man page
++	# with_overwrite=no
++	NCURSES_CH_T=cchar_t
+ 
+-	for cf_name in  captoinfo clear infocmp infotocap tic toe tput
+-	do
+-cat >>$cf_edit_man <<CF_EOF
+-	prog_$cf_name=\`echo $cf_name|sed "\${transform}"\`
+-CF_EOF
+-	done
++for ac_func in putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc
++do
++as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
++echo "$as_me:6471: checking for $ac_func" >&5
++echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
++if eval "test \"\${$as_ac_var+set}\" = set"; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++  cat >conftest.$ac_ext <<_ACEOF
++#line 6477 "configure"
++#include "confdefs.h"
++/* System header to define __stub macros and hopefully few prototypes,
++    which can conflict with char $ac_func (); below.  */
++#include <assert.h>
++/* Override any gcc2 internal prototype to avoid an error.  */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++   builtin and then its argument prototype would still apply.  */
++char $ac_func ();
++char (*f) ();
+ 
+-cat >>$cf_edit_man <<CF_EOF
+-	sed	-e "s,@DATADIR@,\$datadir," \\
+-		-e "s,@TERMINFO@,\$TERMINFO," \\
+-		-e "s,@NCURSES_OSPEED@,\$NCURSES_OSPEED," \\
+-CF_EOF
++int
++main ()
++{
++/* The GNU C library defines this for functions which it implements
++    to always fail with ENOSYS.  Some functions are actually named
++    something starting with __ and the normal name is an alias.  */
++#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
++choke me
++#else
++f = $ac_func;
++#endif
+ 
+-	for cf_name in  captoinfo clear infocmp infotocap tic toe tput
+-	do
+-		cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
+-cat >>$cf_edit_man <<CF_EOF
+-		-e "s,@$cf_NAME@,\$prog_$cf_name," \\
+-CF_EOF
+-	done
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:6508: \"$ac_link\"") >&5
++  (eval $ac_link) 2>&5
++  ac_status=$?
++  echo "$as_me:6511: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest$ac_exeext'
++  { (eval echo "$as_me:6514: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6517: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  eval "$as_ac_var=yes"
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++eval "$as_ac_var=no"
++fi
++rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
++fi
++echo "$as_me:6527: result: `eval echo '${'$as_ac_var'}'`" >&5
++echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
++if test `eval echo '${'$as_ac_var'}'` = yes; then
++  cat >>confdefs.h <<EOF
++#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
++EOF
+ 
+-if test -f $MANPAGE_RENAMES ; then
+-cat >>$cf_edit_man <<CF_EOF
+-		< \$i | sed -f $srcdir/edit_man.sed >\$TMP
+-CF_EOF
++fi
++done
++
++	if test "$ac_cv_func_putwc" != yes ; then
++
++echo "$as_me:6539: checking for putwc in libutf8" >&5
++echo $ECHO_N "checking for putwc in libutf8... $ECHO_C" >&6
++if test "${cf_cv_libutf8+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+-cat >>$cf_edit_man <<CF_EOF
+-		< \$i >\$TMP
+-CF_EOF
++
++	cf_save_LIBS="$LIBS"
++	LIBS="-lutf8 $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++#line 6548 "configure"
++#include "confdefs.h"
++
++#include <libutf8.h>
++int
++main ()
++{
++putwc(0,0);
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:6561: \"$ac_link\"") >&5
++  (eval $ac_link) 2>&5
++  ac_status=$?
++  echo "$as_me:6564: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest$ac_exeext'
++  { (eval echo "$as_me:6567: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6570: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_cv_libutf8=yes
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_cv_libutf8=no
+ fi
++rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
++	LIBS="$cf_save_LIBS"
+ 
+-cat >>$cf_edit_man <<CF_EOF
+-if test \$cf_tables = yes ; then
+-	tbl \$TMP >\$TMP.out
+-	mv \$TMP.out \$TMP
+ fi
+-CF_EOF
++echo "$as_me:6582: result: $cf_cv_libutf8" >&5
++echo "${ECHO_T}$cf_cv_libutf8" >&6
+ 
+-if test $with_curses_h != yes ; then
+-cat >>$cf_edit_man <<CF_EOF
+-	sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
+-	mv \$TMP.out \$TMP
+-CF_EOF
++if test "$cf_cv_libutf8" = yes ; then
++	cat >>confdefs.h <<\EOF
++#define HAVE_LIBUTF8_H 1
++EOF
++
++	LIBS="-lutf8 $LIBS"
+ fi
+ 
+-cat >>$cf_edit_man <<CF_EOF
+-	if test \$form = format ; then
+-		nroff -man \$TMP >\$TMP.out
+-		mv \$TMP.out \$TMP
++		if test "$cf_cv_libutf8" = yes ; then
++			NCURSES_LIBUTF8=1
++		fi
+ 	fi
+-CF_EOF
+ 
+-if test -n "$cf_compress" ; then
+-cat >>$cf_edit_man <<CF_EOF
+-	if test \$verb = installing ; then
+-	if ( $cf_compress -f \$TMP )
+-	then
+-		mv \$TMP.$cf_so_strip \$TMP
+-	fi
+-	fi
+-	target="\$target.$cf_so_strip"
+-CF_EOF
+-fi
++# This is needed on Tru64 5.0 to declare mbstate_t
++echo "$as_me:6599: checking if we must include wchar.h to declare mbstate_t" >&5
++echo $ECHO_N "checking if we must include wchar.h to declare mbstate_t... $ECHO_C" >&6
++if test "${cf_cv_mbstate_t+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
+ 
+-case "$MANPAGE_FORMAT" in #(vi
+-*BSDI*)
+-cat >>$cf_edit_man <<CF_EOF
+-	if test \$form = format ; then
+-		# BSDI installs only .0 suffixes in the cat directories
+-		target="\`echo \$target|sed -e 's/\.[1-9]\+[a-z]*/.0/'\`"
+-	fi
+-CF_EOF
+-  ;;
+-esac
++cat >conftest.$ac_ext <<_ACEOF
++#line 6606 "configure"
++#include "confdefs.h"
+ 
+-cat >>$cf_edit_man <<CF_EOF
+-	suffix=\`basename \$target | sed -e 's%^[^.]*%%'\`
+-	if test \$verb = installing ; then
+-		echo \$verb \$target
+-		\$INSTALL_DATA \$TMP \$target
+-		test -n "\$aliases" && (
+-			cd \$cf_subdir\${section} && (
+-				source=\`echo \$target |sed -e 's%^.*/\([^/][^/]*/[^/][^/]*$\)%\1%'\`
+-				test -n "$cf_so_strip" && source=\`echo \$source |sed -e 's%\.$cf_so_strip\$%%'\`
+-				target=\`basename \$target\`
+-				for cf_alias in \$aliases
+-				do
+-					if test \$section = 1 ; then
+-						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
+-					fi
++#include <stdlib.h>
++#include <stdarg.h>
++#include <stdio.h>
++#ifdef HAVE_LIBUTF8_H
++#include <libutf8.h>
++#endif
++int
++main ()
++{
++mbstate_t state
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6624: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6627: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6630: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6633: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_cv_mbstate_t=no
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cat >conftest.$ac_ext <<_ACEOF
++#line 6640 "configure"
++#include "confdefs.h"
+ 
+-					if test "$MANPAGE_SYMLINKS" = yes ; then
+-						if test -f \$cf_alias\${suffix} ; then
+-							if ( cmp -s \$target \$cf_alias\${suffix} )
+-							then
+-								continue
+-							fi
+-						fi
+-						echo .. \$verb alias \$cf_alias\${suffix}
+-						rm -f \$cf_alias\${suffix}
+-						$LN_S \$target \$cf_alias\${suffix}
+-					elif test "\$target" != "\$cf_alias\${suffix}" ; then
+-						echo ".so \$source" >\$TMP
+-CF_EOF
+-if test -n "$cf_compress" ; then
+-cat >>$cf_edit_man <<CF_EOF
+-						if test -n "$cf_so_strip" ; then
+-							$cf_compress -f \$TMP
+-							mv \$TMP.$cf_so_strip \$TMP
+-						fi
+-CF_EOF
++#include <stdlib.h>
++#include <stdarg.h>
++#include <stdio.h>
++#include <wchar.h>
++#ifdef HAVE_LIBUTF8_H
++#include <libutf8.h>
++#endif
++int
++main ()
++{
++mbstate_t value
++  ;
++  return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:6659: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:6662: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++         { ac_try='test -s conftest.$ac_objext'
++  { (eval echo "$as_me:6665: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:6668: \$? = $ac_status" >&5
++  (exit $ac_status); }; }; then
++  cf_cv_mbstate_t=yes
++else
++  echo "$as_me: failed program was:" >&5
++cat conftest.$ac_ext >&5
++cf_cv_mbstate_t=unknown
+ fi
+-cat >>$cf_edit_man <<CF_EOF
+-						echo .. \$verb alias \$cf_alias\${suffix}
+-						rm -f \$cf_alias\${suffix}
+-						\$INSTALL_DATA \$TMP \$cf_alias\${suffix}
+-					fi
+-				done
+-			)
+-		)
+-	elif test \$verb = removing ; then
+-		echo \$verb \$target
+-		rm -f \$target
+-		test -n "\$aliases" && (
+-			cd \$cf_subdir\${section} && (
+-				for cf_alias in \$aliases
+-				do
+-					if test \$section = 1 ; then
+-						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
+-					fi
+-
+-					echo .. \$verb alias \$cf_alias\${suffix}
+-					rm -f \$cf_alias\${suffix}
+-				done
+-			)
+-		)
+-	else
+-#		echo ".hy 0"
+-		cat \$TMP
+-	fi
+-	;;
+-esac
+-done
+-
+-if test $cf_inboth = yes ; then
+-if test \$form != format ; then
+-	sh \$0 format \$verb \$mandir \$srcdir \$*
++rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
++rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
++echo "$as_me:6680: result: $cf_cv_mbstate_t" >&5
++echo "${ECHO_T}$cf_cv_mbstate_t" >&6
+ 
+-exit 0
+-CF_EOF
+-chmod 755 $cf_edit_man
+-
+-###############################################################################
+-
+-### Note that some functions (such as const) are normally disabled anyway.
+-echo "$as_me:5914: checking if you want to build with function extensions" >&5
+-echo $ECHO_N "checking if you want to build with function extensions... $ECHO_C" >&6
+-
+-# Check whether --enable-ext-funcs or --disable-ext-funcs was given.
+-if test "${enable_ext_funcs+set}" = set; then
+-  enableval="$enable_ext_funcs"
+-  with_ext_funcs=$enableval
+-else
+-  with_ext_funcs=yes
+-fi;
+-echo "$as_me:5924: result: $with_ext_funcs" >&5
+-echo "${ECHO_T}$with_ext_funcs" >&6
+-if test "$with_ext_funcs" = yes ; then
+-	NCURSES_EXT_FUNCS=1
+-	cat >>confdefs.h <<\EOF
+-#define HAVE_CURSES_VERSION 1
+-EOF
+-
+-	cat >>confdefs.h <<\EOF
+-#define HAVE_HAS_KEY 1
+-EOF
+-
+-	cat >>confdefs.h <<\EOF
+-#define HAVE_RESIZETERM 1
+-EOF
+-
+-	cat >>confdefs.h <<\EOF
+-#define HAVE_RESIZE_TERM 1
+-EOF
+-
+-	cat >>confdefs.h <<\EOF
+-#define HAVE_USE_DEFAULT_COLORS 1
+-EOF
+-
+-	cat >>confdefs.h <<\EOF
+-#define HAVE_WRESIZE 1
+-EOF
+-
++if test "$cf_cv_mbstate_t" = yes ; then
+ 	cat >>confdefs.h <<\EOF
+-#define NCURSES_EXT_FUNCS 1
++#define NEED_WCHAR_H 1
+ EOF
+ 
+-else
+-	NCURSES_EXT_FUNCS=0
++	NEED_WCHAR_H=1
+ fi
+ 
+-###   use option --enable-const to turn on use of const beyond that in XSI.
+-echo "$as_me:5961: checking for extended use of const keyword" >&5
+-echo $ECHO_N "checking for extended use of const keyword... $ECHO_C" >&6
+-
+-# Check whether --enable-const or --disable-const was given.
+-if test "${enable_const+set}" = set; then
+-  enableval="$enable_const"
+-  with_ext_const=$enableval
+-else
+-  with_ext_const=no
+-fi;
+-echo "$as_me:5971: result: $with_ext_const" >&5
+-echo "${ECHO_T}$with_ext_const" >&6
+-NCURSES_CONST='/*nothing*/'
+-if test "$with_ext_const" = yes ; then
+-	NCURSES_CONST=const
++# if we do not find mbstate_t in either place, use substitution to provide a fallback.
++if test "$cf_cv_mbstate_t" = unknown ; then
++	NCURSES_MBSTATE_T=1
+ fi
+ 
+-echo "$as_me:5978: checking if you want \$NCURSES_NO_PADDING code" >&5
+-echo $ECHO_N "checking if you want \$NCURSES_NO_PADDING code... $ECHO_C" >&6
+-
+-# Check whether --enable-no-padding or --disable-no-padding was given.
+-if test "${enable_no_padding+set}" = set; then
+-  enableval="$enable_no_padding"
+-  with_no_padding=$enableval
+-else
+-  with_no_padding=$with_ext_funcs
+-fi;
+-echo "$as_me:5988: result: $with_no_padding" >&5
+-echo "${ECHO_T}$with_no_padding" >&6
+-test "$with_no_padding" = yes && cat >>confdefs.h <<\EOF
+-#define NCURSES_NO_PADDING 1
+-EOF
+-
+-###   use option --enable-sigwinch to turn on use of SIGWINCH logic
+-echo "$as_me:5995: checking if you want SIGWINCH handler" >&5
+-echo $ECHO_N "checking if you want SIGWINCH handler... $ECHO_C" >&6
+-
+-# Check whether --enable-sigwinch or --disable-sigwinch was given.
+-if test "${enable_sigwinch+set}" = set; then
+-  enableval="$enable_sigwinch"
+-  with_sigwinch=$enableval
++# This is needed on Tru64 5.0 to declare wchar_t
++echo "$as_me:6697: checking if we must include wchar.h to declare wchar_t" >&5
++echo $ECHO_N "checking if we must include wchar.h to declare wchar_t... $ECHO_C" >&6
++if test "${cf_cv_wchar_t+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+-  with_sigwinch=$with_ext_funcs
+-fi;
+-echo "$as_me:6005: result: $with_sigwinch" >&5
+-echo "${ECHO_T}$with_sigwinch" >&6
+-test "$with_sigwinch" = yes && cat >>confdefs.h <<\EOF
+-#define USE_SIGWINCH 1
+-EOF
+ 
+-###   use option --enable-tcap-names to allow user to define new capabilities
+-echo "$as_me:6012: checking if you want user-definable terminal capabilities like termcap" >&5
+-echo $ECHO_N "checking if you want user-definable terminal capabilities like termcap... $ECHO_C" >&6
++cat >conftest.$ac_ext <<_ACEOF
++#line 6704 "configure"
++#include "confdefs.h"
+ 
+-# Check whether --enable-tcap-names or --disable-tcap-names was given.
+-if test "${enable_tcap_names+set}" = set; then
+-  enableval="$enable_tcap_names"
+-  with_tcap_names=$enableval
+-else
+-  with_tcap_names=$with_ext_funcs
+-fi;
+-echo "$as_me:6022: result: $with_tcap_names" >&5
+-echo "${ECHO_T}$with_tcap_names" >&6
+-NCURSES_XNAMES=0
+-test "$with_tcap_names" = yes && NCURSES_XNAMES=1
+-
+-###############################################################################
+-# These options are relatively safe to experiment with.
+-
+-echo "$as_me:6030: checking if you want all development code" >&5
+-echo $ECHO_N "checking if you want all development code... $ECHO_C" >&6
+-
+-# Check whether --with-develop or --without-develop was given.
+-if test "${with_develop+set}" = set; then
+-  withval="$with_develop"
+-  with_develop=$withval
+-else
+-  with_develop=no
+-fi;
+-echo "$as_me:6040: result: $with_develop" >&5
+-echo "${ECHO_T}$with_develop" >&6
+-
+-###   use option --enable-hard-tabs to turn on use of hard-tabs optimize
+-echo "$as_me:6044: checking if you want hard-tabs code" >&5
+-echo $ECHO_N "checking if you want hard-tabs code... $ECHO_C" >&6
+-
+-# Check whether --enable-hard-tabs or --disable-hard-tabs was given.
+-if test "${enable_hard_tabs+set}" = set; then
+-  enableval="$enable_hard_tabs"
+-  with_hardtabs=$enableval
+-else
+-  with_hardtabs=$with_develop
+-fi;
+-echo "$as_me:6054: result: $with_hardtabs" >&5
+-echo "${ECHO_T}$with_hardtabs" >&6
+-test "$with_hardtabs" = yes && cat >>confdefs.h <<\EOF
+-#define USE_HARD_TABS 1
+-EOF
+-
+-echo "$as_me:6060: checking if you want to use restrict environment when running as root" >&5
+-echo $ECHO_N "checking if you want to use restrict environment when running as root... $ECHO_C" >&6
+-
+-# Check whether --enable-root-environ or --disable-root-environ was given.
+-if test "${enable_root_environ+set}" = set; then
+-  enableval="$enable_root_environ"
+-  with_root_environ=$enableval
+-else
+-  with_root_environ=yes
+-fi;
+-echo "$as_me:6070: result: $with_root_environ" >&5
+-echo "${ECHO_T}$with_root_environ" >&6
+-test "$with_root_environ" = yes && cat >>confdefs.h <<\EOF
+-#define USE_ROOT_ENVIRON 1
+-EOF
+-
+-###   use option --enable-xmc-glitch to turn on use of magic-cookie optimize
+-echo "$as_me:6077: checking if you want limited support for xmc" >&5
+-echo $ECHO_N "checking if you want limited support for xmc... $ECHO_C" >&6
+-
+-# Check whether --enable-xmc-glitch or --disable-xmc-glitch was given.
+-if test "${enable_xmc_glitch+set}" = set; then
+-  enableval="$enable_xmc_glitch"
+-  with_xmc_glitch=$enableval
+-else
+-  with_xmc_glitch=$with_develop
+-fi;
+-echo "$as_me:6087: result: $with_xmc_glitch" >&5
+-echo "${ECHO_T}$with_xmc_glitch" >&6
+-test "$with_xmc_glitch" = yes && cat >>confdefs.h <<\EOF
+-#define USE_XMC_SUPPORT 1
+-EOF
+-
+-###############################################################################
+-# These are just experimental, probably should not be in a package:
+-
+-echo "$as_me:6096: checking if you do not want to assume colors are white-on-black" >&5
+-echo $ECHO_N "checking if you do not want to assume colors are white-on-black... $ECHO_C" >&6
+-
+-# Check whether --enable-assumed-color or --disable-assumed-color was given.
+-if test "${enable_assumed_color+set}" = set; then
+-  enableval="$enable_assumed_color"
+-  with_assumed_color=$enableval
+-else
+-  with_assumed_color=yes
+-fi;
+-echo "$as_me:6106: result: $with_assumed_color" >&5
+-echo "${ECHO_T}$with_assumed_color" >&6
+-test "$with_assumed_color" = yes && cat >>confdefs.h <<\EOF
+-#define USE_ASSUMED_COLOR 1
+-EOF
+-
+-###   use option --enable-hashmap to turn on use of hashmap scrolling logic
+-echo "$as_me:6113: checking if you want hashmap scrolling-optimization code" >&5
+-echo $ECHO_N "checking if you want hashmap scrolling-optimization code... $ECHO_C" >&6
+-
+-# Check whether --enable-hashmap or --disable-hashmap was given.
+-if test "${enable_hashmap+set}" = set; then
+-  enableval="$enable_hashmap"
+-  with_hashmap=$enableval
+-else
+-  with_hashmap=yes
+-fi;
+-echo "$as_me:6123: result: $with_hashmap" >&5
+-echo "${ECHO_T}$with_hashmap" >&6
+-test "$with_hashmap" = yes && cat >>confdefs.h <<\EOF
+-#define USE_HASHMAP 1
+-EOF
+-
+-###   use option --enable-colorfgbg to turn on use of $COLORFGBG environment
+-echo "$as_me:6130: checking if you want colorfgbg code" >&5
+-echo $ECHO_N "checking if you want colorfgbg code... $ECHO_C" >&6
+-
+-# Check whether --enable-colorfgbg or --disable-colorfgbg was given.
+-if test "${enable_colorfgbg+set}" = set; then
+-  enableval="$enable_colorfgbg"
+-  with_colorfgbg=$enableval
+-else
+-  with_colorfgbg=no
+-fi;
+-echo "$as_me:6140: result: $with_colorfgbg" >&5
+-echo "${ECHO_T}$with_colorfgbg" >&6
+-test "$with_colorfgbg" = yes && cat >>confdefs.h <<\EOF
+-#define USE_COLORFGBG 1
+-EOF
+-
+-echo "$as_me:6146: checking if you want experimental safe-sprintf code" >&5
+-echo $ECHO_N "checking if you want experimental safe-sprintf code... $ECHO_C" >&6
+-
+-# Check whether --enable-safe-sprintf or --disable-safe-sprintf was given.
+-if test "${enable_safe_sprintf+set}" = set; then
+-  enableval="$enable_safe_sprintf"
+-  with_safe_sprintf=$enableval
+-else
+-  with_safe_sprintf=no
+-fi;
+-echo "$as_me:6156: result: $with_safe_sprintf" >&5
+-echo "${ECHO_T}$with_safe_sprintf" >&6
+-test "$with_safe_sprintf" = yes && cat >>confdefs.h <<\EOF
+-#define USE_SAFE_SPRINTF 1
+-EOF
+-
+-###   use option --disable-scroll-hints to turn off use of scroll-hints scrolling logic
+-# when hashmap is used scroll hints are useless
+-if test "$with_hashmap" = no ; then
+-echo "$as_me:6165: checking if you want to experiment without scrolling-hints code" >&5
+-echo $ECHO_N "checking if you want to experiment without scrolling-hints code... $ECHO_C" >&6
+-
+-# Check whether --enable-scroll-hints or --disable-scroll-hints was given.
+-if test "${enable_scroll_hints+set}" = set; then
+-  enableval="$enable_scroll_hints"
+-  with_scroll_hints=$enableval
+-else
+-  with_scroll_hints=yes
+-fi;
+-echo "$as_me:6175: result: $with_scroll_hints" >&5
+-echo "${ECHO_T}$with_scroll_hints" >&6
+-test "$with_scroll_hints" = yes && cat >>confdefs.h <<\EOF
+-#define USE_SCROLL_HINTS 1
+-EOF
+-
+-fi
+-
+-###   use option --enable-widec to turn on use of wide-character support
+-NCURSES_CH_T=chtype
+-NCURSES_LIBUTF8=0
+-
+-NEED_WCHAR_H=0
+-NCURSES_MBSTATE_T=0
+-NCURSES_WCHAR_T=0
+-NCURSES_WINT_T=0
+-
+-# Check to define _XOPEN_SOURCE "automatically"
+-
+-case $host_os in #(vi
+-freebsd*) #(vi
+-	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600"
+-	;;
+-hpux*) #(vi
+-	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
+-	;;
+-irix6.*) #(vi
+-	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
+-	;;
+-linux*) #(vi
+-
+-echo "$as_me:6206: checking if we must define _GNU_SOURCE" >&5
+-echo $ECHO_N "checking if we must define _GNU_SOURCE... $ECHO_C" >&6
+-if test "${cf_cv_gnu_source+set}" = set; then
+-  echo $ECHO_N "(cached) $ECHO_C" >&6
+-else
+-
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 6213 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
++#include <stdlib.h>
++#include <stdarg.h>
++#include <stdio.h>
++#ifdef HAVE_LIBUTF8_H
++#include <libutf8.h>
++#endif
+ int
+ main ()
+ {
+-
+-#ifndef _XOPEN_SOURCE
+-make an error
+-#endif
++wchar_t state
+   ;
+   return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6228: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:6722: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:6231: \$? = $ac_status" >&5
++  echo "$as_me:6725: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6234: \"$ac_try\"") >&5
++  { (eval echo "$as_me:6728: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:6237: \$? = $ac_status" >&5
++  echo "$as_me:6731: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+-  cf_cv_gnu_source=no
++  cf_cv_wchar_t=no
+ else
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+-cf_save="$CPPFLAGS"
+-	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+-	 cat >conftest.$ac_ext <<_ACEOF
+-#line 6246 "configure"
++cat >conftest.$ac_ext <<_ACEOF
++#line 6738 "configure"
+ #include "confdefs.h"
+-#include <sys/types.h>
++
++#include <stdlib.h>
++#include <stdarg.h>
++#include <stdio.h>
++#include <wchar.h>
++#ifdef HAVE_LIBUTF8_H
++#include <libutf8.h>
++#endif
+ int
+ main ()
+ {
+-
+-#ifdef _XOPEN_SOURCE
+-make an error
+-#endif
++wchar_t value
+   ;
+   return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6261: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:6757: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:6264: \$? = $ac_status" >&5
++  echo "$as_me:6760: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6267: \"$ac_try\"") >&5
++  { (eval echo "$as_me:6763: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:6270: \$? = $ac_status" >&5
++  echo "$as_me:6766: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+-  cf_cv_gnu_source=no
++  cf_cv_wchar_t=yes
+ else
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+-cf_cv_gnu_source=yes
++cf_cv_wchar_t=unknown
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+-	CPPFLAGS="$cf_save"
+-
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+-
+ fi
+-echo "$as_me:6285: result: $cf_cv_gnu_source" >&5
+-echo "${ECHO_T}$cf_cv_gnu_source" >&6
+-test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
++echo "$as_me:6778: result: $cf_cv_wchar_t" >&5
++echo "${ECHO_T}$cf_cv_wchar_t" >&6
+ 
+-	;;
+-mirbsd*) #(vi
+-	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
+-	;;
+-netbsd*) #(vi
+-	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
+-	;;
+-openbsd*) #(vi
+-	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+-	;;
+-osf[45]*) #(vi
+-	CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
+-	;;
+-sco*) #(vi
+-	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+-	;;
+-solaris*) #(vi
+-	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
+-	;;
+-*)
+-	echo "$as_me:6309: checking if we should define _XOPEN_SOURCE" >&5
+-echo $ECHO_N "checking if we should define _XOPEN_SOURCE... $ECHO_C" >&6
+-if test "${cf_cv_xopen_source+set}" = set; then
+-  echo $ECHO_N "(cached) $ECHO_C" >&6
+-else
++if test "$cf_cv_wchar_t" = yes ; then
++	cat >>confdefs.h <<\EOF
++#define NEED_WCHAR_H 1
++EOF
+ 
+-	cat >conftest.$ac_ext <<_ACEOF
+-#line 6316 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
+-int
+-main ()
+-{
+-
+-#ifndef _XOPEN_SOURCE
+-make an error
+-#endif
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6331: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6334: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6337: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6340: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_cv_xopen_source=no
+-else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_save="$CPPFLAGS"
+-	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
+-	 cat >conftest.$ac_ext <<_ACEOF
+-#line 6349 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
+-int
+-main ()
+-{
+-
+-#ifdef _XOPEN_SOURCE
+-make an error
+-#endif
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6364: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6367: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6370: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6373: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_cv_xopen_source=no
+-else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_cv_xopen_source=yes
+-fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-	CPPFLAGS="$cf_save"
++	NEED_WCHAR_H=1
++fi
+ 
++# if we do not find wchar_t in either place, use substitution to provide a fallback.
++if test "$cf_cv_wchar_t" = unknown ; then
++	NCURSES_WCHAR_T=1
+ fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+ 
++# if we find wchar_t in either place, use substitution to provide a fallback.
++if test "$cf_cv_wchar_t" != unknown ; then
++	NCURSES_OK_WCHAR_T=1
+ fi
+-echo "$as_me:6388: result: $cf_cv_xopen_source" >&5
+-echo "${ECHO_T}$cf_cv_xopen_source" >&6
+-test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
+ 
+-	# FreeBSD 5.x headers demand this...
+-	echo "$as_me:6393: checking if we should define _POSIX_C_SOURCE" >&5
+-echo $ECHO_N "checking if we should define _POSIX_C_SOURCE... $ECHO_C" >&6
+-if test "${cf_cv_xopen_source+set}" = set; then
++# This is needed on Tru64 5.0 to declare wint_t
++echo "$as_me:6800: checking if we must include wchar.h to declare wint_t" >&5
++echo $ECHO_N "checking if we must include wchar.h to declare wint_t... $ECHO_C" >&6
++if test "${cf_cv_wint_t+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+-	cat >conftest.$ac_ext <<_ACEOF
+-#line 6400 "configure"
++cat >conftest.$ac_ext <<_ACEOF
++#line 6807 "configure"
+ #include "confdefs.h"
+-#include <sys/types.h>
++
++#include <stdlib.h>
++#include <stdarg.h>
++#include <stdio.h>
++#ifdef HAVE_LIBUTF8_H
++#include <libutf8.h>
++#endif
+ int
+ main ()
+ {
+-
+-#ifndef _POSIX_C_SOURCE
+-make an error
+-#endif
++wint_t state
+   ;
+   return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6415: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:6825: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:6418: \$? = $ac_status" >&5
++  echo "$as_me:6828: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6421: \"$ac_try\"") >&5
++  { (eval echo "$as_me:6831: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:6424: \$? = $ac_status" >&5
++  echo "$as_me:6834: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+-  cf_cv_xopen_source=no
++  cf_cv_wint_t=no
+ else
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+-cf_save="$CPPFLAGS"
+-	 CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
+-	 cat >conftest.$ac_ext <<_ACEOF
+-#line 6433 "configure"
++cat >conftest.$ac_ext <<_ACEOF
++#line 6841 "configure"
+ #include "confdefs.h"
+-#include <sys/types.h>
++
++#include <stdlib.h>
++#include <stdarg.h>
++#include <stdio.h>
++#include <wchar.h>
++#ifdef HAVE_LIBUTF8_H
++#include <libutf8.h>
++#endif
+ int
+ main ()
+ {
+-
+-#ifdef _POSIX_C_SOURCE
+-make an error
+-#endif
++wint_t value
+   ;
+   return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6448: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:6860: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:6451: \$? = $ac_status" >&5
++  echo "$as_me:6863: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6454: \"$ac_try\"") >&5
++  { (eval echo "$as_me:6866: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:6457: \$? = $ac_status" >&5
++  echo "$as_me:6869: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+-  cf_cv_xopen_source=no
++  cf_cv_wint_t=yes
+ else
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+-cf_cv_xopen_source=yes
++cf_cv_wint_t=unknown
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+-	CPPFLAGS="$cf_save"
+-
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+-
+ fi
+-echo "$as_me:6472: result: $cf_cv_xopen_source" >&5
+-echo "${ECHO_T}$cf_cv_xopen_source" >&6
+-test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
+-	;;
+-esac
+-
+-# use these variables to work around a defect in gcc's fixincludes.
+-NCURSES_OK_WCHAR_T=
+-NCURSES_OK_WINT_T=
+-
+-echo "$as_me:6482: checking if you want experimental wide-character code" >&5
+-echo $ECHO_N "checking if you want experimental wide-character code... $ECHO_C" >&6
++echo "$as_me:6881: result: $cf_cv_wint_t" >&5
++echo "${ECHO_T}$cf_cv_wint_t" >&6
+ 
+-# Check whether --enable-widec or --disable-widec was given.
+-if test "${enable_widec+set}" = set; then
+-  enableval="$enable_widec"
+-  with_widec=$enableval
+-else
+-  with_widec=no
+-fi;
+-echo "$as_me:6492: result: $with_widec" >&5
+-echo "${ECHO_T}$with_widec" >&6
+-if test "$with_widec" = yes ; then
+-	LIB_SUFFIX="w${LIB_SUFFIX}"
++if test "$cf_cv_wint_t" = yes ; then
+ 	cat >>confdefs.h <<\EOF
+-#define USE_WIDEC_SUPPORT 1
++#define NEED_WCHAR_H 1
+ EOF
+ 
+-echo "$as_me:6500: checking if we must define _XOPEN_SOURCE" >&5
+-echo $ECHO_N "checking if we must define _XOPEN_SOURCE... $ECHO_C" >&6
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 6503 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
+-
+-int
+-main ()
+-{
++	NEED_WCHAR_H=1
++fi
+ 
+-#ifndef _XOPEN_SOURCE
+-make an error
+-#endif
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6519: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6522: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6525: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6528: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_result=no
+-else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_result=yes
++# if we do not find wint_t in either place, use substitution to provide a fallback.
++if test "$cf_cv_wint_t" = unknown ; then
++	NCURSES_WINT_T=1
+ fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-echo "$as_me:6537: result: $cf_result" >&5
+-echo "${ECHO_T}$cf_result" >&6
+ 
+-if test "$cf_result" = yes ; then
+-	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
+-elif test "x500" != "x" ; then
+-	echo "$as_me:6543: checking checking for compatible value versus 500" >&5
+-echo $ECHO_N "checking checking for compatible value versus 500... $ECHO_C" >&6
+-	cat >conftest.$ac_ext <<_ACEOF
+-#line 6546 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
++# if we find wint_t in either place, use substitution to provide a fallback.
++if test "$cf_cv_wint_t" != unknown ; then
++	NCURSES_OK_WINT_T=1
++fi
+ 
+-int
+-main ()
+-{
++	if test "$NCURSES_MBSTATE_T" != 0; then
++		cat >>confdefs.h <<\EOF
++#define NEED_MBSTATE_T_DEF 1
++EOF
+ 
+-#if _XOPEN_SOURCE-500 < 0
+-make an error
+-#endif
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6562: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6565: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6568: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6571: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_result=yes
+-else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_result=no
+-fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-	echo "$as_me:6580: result: $cf_result" >&5
+-echo "${ECHO_T}$cf_result" >&6
+-	if test "$cf_result" = no ; then
+-		# perhaps we can override it - try...
+-		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
+ 	fi
+ fi
+ 
+-echo "$as_me:6588: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
+-echo $ECHO_N "checking if we must define _XOPEN_SOURCE_EXTENDED... $ECHO_C" >&6
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 6591 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
+-
+-int
+-main ()
+-{
++###   use option --with-bool to override bool's type
++echo "$as_me:6911: checking for type of bool" >&5
++echo $ECHO_N "checking for type of bool... $ECHO_C" >&6
+ 
+-#ifndef _XOPEN_SOURCE_EXTENDED
+-make an error
+-#endif
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6607: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6610: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6613: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6616: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_result=no
++# Check whether --with-bool or --without-bool was given.
++if test "${with_bool+set}" = set; then
++  withval="$with_bool"
++  NCURSES_BOOL="$withval"
+ else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_result=yes
+-fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-echo "$as_me:6625: result: $cf_result" >&5
+-echo "${ECHO_T}$cf_result" >&6
++  NCURSES_BOOL=auto
++fi;
++echo "$as_me:6921: result: $NCURSES_BOOL" >&5
++echo "${ECHO_T}$NCURSES_BOOL" >&6
+ 
+-if test "$cf_result" = yes ; then
+-	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
+-elif test "x" != "x" ; then
+-	echo "$as_me:6631: checking checking for compatible value versus " >&5
+-echo $ECHO_N "checking checking for compatible value versus ... $ECHO_C" >&6
+-	cat >conftest.$ac_ext <<_ACEOF
+-#line 6634 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
++echo "$as_me:6924: checking for alternate terminal capabilities file" >&5
++echo $ECHO_N "checking for alternate terminal capabilities file... $ECHO_C" >&6
+ 
+-int
+-main ()
+-{
++# Check whether --with-caps or --without-caps was given.
++if test "${with_caps+set}" = set; then
++  withval="$with_caps"
++  TERMINFO_CAPS=Caps.$withval
++else
++  TERMINFO_CAPS=Caps
++fi;
++test -f ${srcdir}/include/${TERMINFO_CAPS} || TERMINFO_CAPS=Caps
++echo "$as_me:6935: result: $TERMINFO_CAPS" >&5
++echo "${ECHO_T}$TERMINFO_CAPS" >&6
+ 
+-#if _XOPEN_SOURCE_EXTENDED- < 0
+-make an error
+-#endif
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6650: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6653: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6656: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6659: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_result=yes
++###   use option --with-ospeed to override ospeed's type
++echo "$as_me:6939: checking for type of ospeed" >&5
++echo $ECHO_N "checking for type of ospeed... $ECHO_C" >&6
++
++# Check whether --with-ospeed or --without-ospeed was given.
++if test "${with_ospeed+set}" = set; then
++  withval="$with_ospeed"
++  NCURSES_OSPEED="$withval"
+ else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_result=no
++  NCURSES_OSPEED=short
++fi;
++echo "$as_me:6949: result: $NCURSES_OSPEED" >&5
++echo "${ECHO_T}$NCURSES_OSPEED" >&6
++
++###   use option --enable-bsdpad to have tputs process BSD-style prefix padding
++echo "$as_me:6953: checking if tputs should process BSD-style prefix padding" >&5
++echo $ECHO_N "checking if tputs should process BSD-style prefix padding... $ECHO_C" >&6
++
++# Check whether --enable-bsdpad or --disable-bsdpad was given.
++if test "${enable_bsdpad+set}" = set; then
++  enableval="$enable_bsdpad"
++  with_bsdpad=$enableval
++else
++  with_bsdpad=no
++fi;
++echo "$as_me:6963: result: $with_bsdpad" >&5
++echo "${ECHO_T}$with_bsdpad" >&6
++test "$with_bsdpad" = yes && cat >>confdefs.h <<\EOF
++#define BSD_TPUTS 1
++EOF
++
++### Enable compiling-in rcs id's
++echo "$as_me:6970: checking if RCS identifiers should be compiled-in" >&5
++echo $ECHO_N "checking if RCS identifiers should be compiled-in... $ECHO_C" >&6
++
++# Check whether --with-rcs-ids or --without-rcs-ids was given.
++if test "${with_rcs_ids+set}" = set; then
++  withval="$with_rcs_ids"
++  with_rcs_ids=$withval
++else
++  with_rcs_ids=no
++fi;
++echo "$as_me:6980: result: $with_rcs_ids" >&5
++echo "${ECHO_T}$with_rcs_ids" >&6
++test "$with_rcs_ids" = yes && cat >>confdefs.h <<\EOF
++#define USE_RCS_IDS 1
++EOF
++
++###############################################################################
++
++echo "$as_me:6988: checking format of man-pages" >&5
++echo $ECHO_N "checking format of man-pages... $ECHO_C" >&6
++
++# Check whether --with-manpage-format or --without-manpage-format was given.
++if test "${with_manpage_format+set}" = set; then
++  withval="$with_manpage_format"
++  MANPAGE_FORMAT=$withval
++else
++  MANPAGE_FORMAT=unknown
++fi;
++
++test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
++MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
++
++cf_unknown=
++
++case $MANPAGE_FORMAT in
++unknown)
++  if test -z "$MANPATH" ; then
++    MANPATH="/usr/man:/usr/share/man"
++  fi
++
++  # look for the 'date' man-page (it's most likely to be installed!)
++  MANPAGE_FORMAT=
++  cf_preform=no
++  cf_catonly=yes
++  cf_example=date
++
++  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
++  for cf_dir in $MANPATH; do
++    test -z "$cf_dir" && cf_dir=/usr/man
++    for cf_name in $cf_dir/man*/$cf_example.[01]* $cf_dir/cat*/$cf_example.[01]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
++    do
++      cf_test=`echo $cf_name | sed -e 's/*//'`
++      if test "x$cf_test" = "x$cf_name" ; then
++
++	case "$cf_name" in
++	*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
++	*.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
++	*.0)	MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
++	*)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
++	esac
++
++	case "$cf_name" in
++	$cf_dir/man*)
++	  cf_catonly=no
++	  ;;
++	$cf_dir/cat*)
++	  cf_preform=yes
++	  ;;
++	esac
++	break
++      fi
++
++      # if we found a match in either man* or cat*, stop looking
++      if test -n "$MANPAGE_FORMAT" ; then
++	cf_found=no
++	test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
++	test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
++	case "$cf_name" in
++	$cf_dir/cat*)
++	  cf_found=yes
++	  ;;
++	esac
++	test $cf_found=yes && break
++      fi
++    done
++    # only check the first directory in $MANPATH where we find manpages
++    if test -n "$MANPAGE_FORMAT" ; then
++       break
++    fi
++  done
++  # if we did not find the example, just assume it is normal
++  test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
++  IFS="$ac_save_ifs"
++  ;;
++*)
++  for cf_option in $MANPAGE_FORMAT; do
++     case $cf_option in #(vi
++     gzip|compress|BSDI|normal|formatted|catonly)
++       ;;
++     *)
++       cf_unknown="$cf_unknown $cf_option"
++       ;;
++     esac
++  done
++  ;;
++esac
++
++echo "$as_me:7077: result: $MANPAGE_FORMAT" >&5
++echo "${ECHO_T}$MANPAGE_FORMAT" >&6
++if test -n "$cf_unknown" ; then
++  { echo "$as_me:7080: WARNING: Unexpected manpage-format $cf_unknown" >&5
++echo "$as_me: WARNING: Unexpected manpage-format $cf_unknown" >&2;}
+ fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-	echo "$as_me:6668: result: $cf_result" >&5
+-echo "${ECHO_T}$cf_result" >&6
+-	if test "$cf_result" = no ; then
+-		# perhaps we can override it - try...
+-		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED="
+-	fi
++
++echo "$as_me:7084: checking for manpage renaming" >&5
++echo $ECHO_N "checking for manpage renaming... $ECHO_C" >&6
++
++# Check whether --with-manpage-renames or --without-manpage-renames was given.
++if test "${with_manpage_renames+set}" = set; then
++  withval="$with_manpage_renames"
++  MANPAGE_RENAMES=$withval
++else
++  MANPAGE_RENAMES=yes
++fi;
++
++case ".$MANPAGE_RENAMES" in #(vi
++.no) #(vi
++  ;;
++.|.yes)
++  # Debian 'man' program?
++  if test -f /etc/debian_version ; then
++    MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
++  else
++    MANPAGE_RENAMES=no
++  fi
++  ;;
++esac
++
++if test "$MANPAGE_RENAMES" != no ; then
++  if test -f $srcdir/man/$MANPAGE_RENAMES ; then
++    MANPAGE_RENAMES=`cd $srcdir/man && pwd`/$MANPAGE_RENAMES
++  elif test ! -f $MANPAGE_RENAMES ; then
++    { { echo "$as_me:7112: error: not a filename: $MANPAGE_RENAMES" >&5
++echo "$as_me: error: not a filename: $MANPAGE_RENAMES" >&2;}
++   { (exit 1); exit 1; }; }
++  fi
++
++  test ! -d man && mkdir man
++
++  # Construct a sed-script to perform renaming within man-pages
++  if test -n "$MANPAGE_RENAMES" ; then
++    test ! -d man && mkdir man
++    sh $srcdir/man/make_sed.sh $MANPAGE_RENAMES >man/edit_man.sed
++  fi
+ fi
+ 
+-	# with_overwrite=no
+-	NCURSES_CH_T=cchar_t
++echo "$as_me:7126: result: $MANPAGE_RENAMES" >&5
++echo "${ECHO_T}$MANPAGE_RENAMES" >&6
+ 
+-for ac_func in putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc
+-do
+-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+-echo "$as_me:6682: checking for $ac_func" >&5
+-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+-if eval "test \"\${$as_ac_var+set}\" = set"; then
+-  echo $ECHO_N "(cached) $ECHO_C" >&6
++echo "$as_me:7129: checking if manpage aliases will be installed" >&5
++echo $ECHO_N "checking if manpage aliases will be installed... $ECHO_C" >&6
++
++# Check whether --with-manpage-aliases or --without-manpage-aliases was given.
++if test "${with_manpage_aliases+set}" = set; then
++  withval="$with_manpage_aliases"
++  MANPAGE_ALIASES=$withval
+ else
+-  cat >conftest.$ac_ext <<_ACEOF
+-#line 6688 "configure"
+-#include "confdefs.h"
+-/* System header to define __stub macros and hopefully few prototypes,
+-    which can conflict with char $ac_func (); below.  */
+-#include <assert.h>
+-/* Override any gcc2 internal prototype to avoid an error.  */
+-#ifdef __cplusplus
+-extern "C"
+-#endif
+-/* We use char because int might match the return type of a gcc2
+-   builtin and then its argument prototype would still apply.  */
+-char $ac_func ();
+-char (*f) ();
++  MANPAGE_ALIASES=yes
++fi;
+ 
+-int
+-main ()
+-{
+-/* The GNU C library defines this for functions which it implements
+-    to always fail with ENOSYS.  Some functions are actually named
+-    something starting with __ and the normal name is an alias.  */
+-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+-choke me
+-#else
+-f = $ac_func;
+-#endif
++echo "$as_me:7140: result: $MANPAGE_ALIASES" >&5
++echo "${ECHO_T}$MANPAGE_ALIASES" >&6
+ 
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:6719: \"$ac_link\"") >&5
+-  (eval $ac_link) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6722: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:6725: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6728: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  eval "$as_ac_var=yes"
++if test "$LN_S" = "ln -s"; then
++	cf_use_symlinks=yes
+ else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-eval "$as_ac_var=no"
++	cf_use_symlinks=no
+ fi
+-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
++
++MANPAGE_SYMLINKS=no
++if test "$MANPAGE_ALIASES" = yes ; then
++echo "$as_me:7151: checking if manpage symlinks should be used" >&5
++echo $ECHO_N "checking if manpage symlinks should be used... $ECHO_C" >&6
++
++# Check whether --with-manpage-symlinks or --without-manpage-symlinks was given.
++if test "${with_manpage_symlinks+set}" = set; then
++  withval="$with_manpage_symlinks"
++  MANPAGE_SYMLINKS=$withval
++else
++  MANPAGE_SYMLINKS=$cf_use_symlinks
++fi;
++
++if test "$$cf_use_symlinks" = no; then
++if test "$MANPAGE_SYMLINKS" = yes ; then
++	{ echo "$as_me:7164: WARNING: cannot make symlinks" >&5
++echo "$as_me: WARNING: cannot make symlinks" >&2;}
++	MANPAGE_SYMLINKS=no
++fi
++fi
++
++echo "$as_me:7170: result: $MANPAGE_SYMLINKS" >&5
++echo "${ECHO_T}$MANPAGE_SYMLINKS" >&6
++fi
++
++echo "$as_me:7174: checking for manpage tbl" >&5
++echo $ECHO_N "checking for manpage tbl... $ECHO_C" >&6
++
++# Check whether --with-manpage-tbl or --without-manpage-tbl was given.
++if test "${with_manpage_tbl+set}" = set; then
++  withval="$with_manpage_tbl"
++  MANPAGE_TBL=$withval
++else
++  MANPAGE_TBL=no
++fi;
++
++echo "$as_me:7185: result: $MANPAGE_TBL" >&5
++echo "${ECHO_T}$MANPAGE_TBL" >&6
++
++  if test "$prefix" = "NONE" ; then
++     cf_prefix="$ac_default_prefix"
++  else
++     cf_prefix="$prefix"
++  fi
++
++  case "$MANPAGE_FORMAT" in # (vi
++  *catonly*) # (vi
++    cf_format=yes
++    cf_inboth=no
++    ;;
++  *formatted*) # (vi
++    cf_format=yes
++    cf_inboth=yes
++    ;;
++  *)
++    cf_format=no
++    cf_inboth=no
++    ;;
++  esac
++
++test ! -d man && mkdir man
++
++cf_so_strip=
++cf_compress=
++case "$MANPAGE_FORMAT" in #(vi
++*compress*) #(vi
++	cf_so_strip="Z"
++	cf_compress=compress
++  ;;
++*gzip*) #(vi
++	cf_so_strip="gz"
++	cf_compress=gzip
++  ;;
++esac
++
++cf_edit_man=man/edit_man.sh
++
++cat >$cf_edit_man <<CF_EOF
++#! /bin/sh
++# this script is generated by the configure-script CF_MAN_PAGES macro.
++prefix="$cf_prefix"
++datadir="$datadir"
++NCURSES_OSPEED="$NCURSES_OSPEED"
++TERMINFO="$TERMINFO"
++MKDIRS="sh `cd $srcdir && pwd`/mkinstalldirs"
++INSTALL="$INSTALL"
++INSTALL_DATA="$INSTALL_DATA"
++transform="$program_transform_name"
++
++TMP=\${TMPDIR-/tmp}/man\$\$
++trap "rm -f \$TMP" 0 1 2 5 15
++
++form=\$1
++shift || exit 1
++
++verb=\$1
++shift || exit 1
++
++mandir=\$1
++shift || exit 1
++
++srcdir=\$1
++shift || exit 1
++
++if test "\$form" = normal ; then
++	if test "$cf_format" = yes ; then
++	if test "$cf_inboth" = no ; then
++		sh \$0 format \$verb \$mandir \$srcdir \$*
++		exit $?
++	fi
++	fi
++	cf_subdir=\$mandir/man
++	cf_tables=$MANPAGE_TBL
++else
++	cf_subdir=\$mandir/cat
++	cf_tables=yes
++fi
++
++# process the list of source-files
++for i in \$* ; do
++case \$i in #(vi
++*.orig|*.rej) ;; #(vi
++*.[0-9]*)
++	section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
++	if test \$verb = installing ; then
++	if test ! -d \$cf_subdir\${section} ; then
++		\$MKDIRS \$cf_subdir\$section
++	fi
++	fi
++	aliases=
++	source=\`basename \$i\`
++	inalias=\$source
++	test ! -f \$inalias && inalias="\$srcdir/\$inalias"
++	if test ! -f \$inalias ; then
++		echo .. skipped \$source
++		continue
++	fi
++CF_EOF
++
++if test "$MANPAGE_ALIASES" != no ; then
++cat >>$cf_edit_man <<CF_EOF
++	aliases=\`sed -f \$srcdir/manlinks.sed \$inalias | sort -u\`
++CF_EOF
++fi
++
++if test "$MANPAGE_RENAMES" = no ; then
++cat >>$cf_edit_man <<CF_EOF
++	# perform program transformations for section 1 man pages
++	if test \$section = 1 ; then
++		target=\$cf_subdir\${section}/\`echo \$source|sed "\${transform}"\`
++	else
++		target=\$cf_subdir\${section}/\$source
++	fi
++CF_EOF
++else
++cat >>$cf_edit_man <<CF_EOF
++	target=\`grep "^\$source" $MANPAGE_RENAMES | $AWK '{print \$2}'\`
++	if test -z "\$target" ; then
++		echo '? missing rename for '\$source
++		target="\$source"
++	fi
++	target="\$cf_subdir\${section}/\${target}"
++CF_EOF
+ fi
+-echo "$as_me:6738: result: `eval echo '${'$as_ac_var'}'`" >&5
+-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+-if test `eval echo '${'$as_ac_var'}'` = yes; then
+-  cat >>confdefs.h <<EOF
+-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+-EOF
+ 
+-fi
+-done
++	# replace variables in man page
+ 
+-	if test "$ac_cv_func_putwc" != yes ; then
++	for cf_name in  captoinfo clear infocmp infotocap tic toe tput
++	do
++cat >>$cf_edit_man <<CF_EOF
++	prog_$cf_name=\`echo $cf_name|sed "\${transform}"\`
++CF_EOF
++	done
+ 
+-echo "$as_me:6750: checking for putwc in libutf8" >&5
+-echo $ECHO_N "checking for putwc in libutf8... $ECHO_C" >&6
+-if test "${cf_cv_libutf8+set}" = set; then
+-  echo $ECHO_N "(cached) $ECHO_C" >&6
+-else
++cat >>$cf_edit_man <<CF_EOF
++	sed	-e "s,@DATADIR@,\$datadir," \\
++		-e "s,@TERMINFO@,\$TERMINFO," \\
++		-e "s,@NCURSES_OSPEED@,\$NCURSES_OSPEED," \\
++CF_EOF
+ 
+-	cf_save_LIBS="$LIBS"
+-	LIBS="-lutf8 $LIBS"
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 6759 "configure"
+-#include "confdefs.h"
++	for cf_name in  captoinfo clear infocmp infotocap tic toe tput
++	do
++		cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
++cat >>$cf_edit_man <<CF_EOF
++		-e "s,@$cf_NAME@,\$prog_$cf_name," \\
++CF_EOF
++	done
+ 
+-#include <libutf8.h>
+-int
+-main ()
+-{
+-putwc(0,0);
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:6772: \"$ac_link\"") >&5
+-  (eval $ac_link) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6775: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:6778: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6781: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_cv_libutf8=yes
++if test -f $MANPAGE_RENAMES ; then
++cat >>$cf_edit_man <<CF_EOF
++		< \$i | sed -f $srcdir/edit_man.sed >\$TMP
++CF_EOF
+ else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_cv_libutf8=no
++cat >>$cf_edit_man <<CF_EOF
++		< \$i >\$TMP
++CF_EOF
+ fi
+-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+-	LIBS="$cf_save_LIBS"
+ 
++cat >>$cf_edit_man <<CF_EOF
++if test \$cf_tables = yes ; then
++	tbl \$TMP >\$TMP.out
++	mv \$TMP.out \$TMP
+ fi
+-echo "$as_me:6793: result: $cf_cv_libutf8" >&5
+-echo "${ECHO_T}$cf_cv_libutf8" >&6
+-
+-if test "$cf_cv_libutf8" = yes ; then
+-	cat >>confdefs.h <<\EOF
+-#define HAVE_LIBUTF8_H 1
+-EOF
++CF_EOF
+ 
+-	LIBS="-lutf8 $LIBS"
++if test $with_curses_h != yes ; then
++cat >>$cf_edit_man <<CF_EOF
++	sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
++	mv \$TMP.out \$TMP
++CF_EOF
+ fi
+ 
+-		if test "$cf_cv_libutf8" = yes ; then
+-			NCURSES_LIBUTF8=1
+-		fi
++cat >>$cf_edit_man <<CF_EOF
++	if test \$form = format ; then
++		nroff -man \$TMP >\$TMP.out
++		mv \$TMP.out \$TMP
+ 	fi
++CF_EOF
+ 
+-# This is needed on Tru64 5.0 to declare mbstate_t
+-echo "$as_me:6810: checking if we must include wchar.h to declare mbstate_t" >&5
+-echo $ECHO_N "checking if we must include wchar.h to declare mbstate_t... $ECHO_C" >&6
+-if test "${cf_cv_mbstate_t+set}" = set; then
+-  echo $ECHO_N "(cached) $ECHO_C" >&6
+-else
++if test -n "$cf_compress" ; then
++cat >>$cf_edit_man <<CF_EOF
++	if test \$verb = installing ; then
++	if ( $cf_compress -f \$TMP )
++	then
++		mv \$TMP.$cf_so_strip \$TMP
++	fi
++	fi
++	target="\$target.$cf_so_strip"
++CF_EOF
++fi
+ 
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 6817 "configure"
+-#include "confdefs.h"
++case "$MANPAGE_FORMAT" in #(vi
++*BSDI*)
++cat >>$cf_edit_man <<CF_EOF
++	if test \$form = format ; then
++		# BSDI installs only .0 suffixes in the cat directories
++		target="\`echo \$target|sed -e 's/\.[1-9]\+[a-z]*/.0/'\`"
++	fi
++CF_EOF
++  ;;
++esac
+ 
+-#include <stdlib.h>
+-#include <stdarg.h>
+-#include <stdio.h>
+-#ifdef HAVE_LIBUTF8_H
+-#include <libutf8.h>
+-#endif
+-int
+-main ()
+-{
+-mbstate_t state
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6835: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6838: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6841: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6844: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_cv_mbstate_t=no
+-else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 6851 "configure"
+-#include "confdefs.h"
++cat >>$cf_edit_man <<CF_EOF
++	suffix=\`basename \$target | sed -e 's%^[^.]*%%'\`
++	if test \$verb = installing ; then
++		echo \$verb \$target
++		\$INSTALL_DATA \$TMP \$target
++		test -n "\$aliases" && (
++			cd \$cf_subdir\${section} && (
++				source=\`echo \$target |sed -e 's%^.*/\([^/][^/]*/[^/][^/]*$\)%\1%'\`
++				test -n "$cf_so_strip" && source=\`echo \$source |sed -e 's%\.$cf_so_strip\$%%'\`
++				target=\`basename \$target\`
++				for cf_alias in \$aliases
++				do
++					if test \$section = 1 ; then
++						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
++					fi
+ 
+-#include <stdlib.h>
+-#include <stdarg.h>
+-#include <stdio.h>
+-#include <wchar.h>
+-#ifdef HAVE_LIBUTF8_H
+-#include <libutf8.h>
+-#endif
+-int
+-main ()
+-{
+-mbstate_t value
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6870: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6873: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6876: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6879: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_cv_mbstate_t=yes
+-else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_cv_mbstate_t=unknown
++					if test "$MANPAGE_SYMLINKS" = yes ; then
++						if test -f \$cf_alias\${suffix} ; then
++							if ( cmp -s \$target \$cf_alias\${suffix} )
++							then
++								continue
++							fi
++						fi
++						echo .. \$verb alias \$cf_alias\${suffix}
++						rm -f \$cf_alias\${suffix}
++						$LN_S \$target \$cf_alias\${suffix}
++					elif test "\$target" != "\$cf_alias\${suffix}" ; then
++						echo ".so \$source" >\$TMP
++CF_EOF
++if test -n "$cf_compress" ; then
++cat >>$cf_edit_man <<CF_EOF
++						if test -n "$cf_so_strip" ; then
++							$cf_compress -f \$TMP
++							mv \$TMP.$cf_so_strip \$TMP
++						fi
++CF_EOF
+ fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
++cat >>$cf_edit_man <<CF_EOF
++						echo .. \$verb alias \$cf_alias\${suffix}
++						rm -f \$cf_alias\${suffix}
++						\$INSTALL_DATA \$TMP \$cf_alias\${suffix}
++					fi
++				done
++			)
++		)
++	elif test \$verb = removing ; then
++		echo \$verb \$target
++		rm -f \$target
++		test -n "\$aliases" && (
++			cd \$cf_subdir\${section} && (
++				for cf_alias in \$aliases
++				do
++					if test \$section = 1 ; then
++						cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
++					fi
++
++					echo .. \$verb alias \$cf_alias\${suffix}
++					rm -f \$cf_alias\${suffix}
++				done
++			)
++		)
++	else
++#		echo ".hy 0"
++		cat \$TMP
++	fi
++	;;
++esac
++done
++
++if test $cf_inboth = yes ; then
++if test \$form != format ; then
++	sh \$0 format \$verb \$mandir \$srcdir \$*
+ fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+-echo "$as_me:6891: result: $cf_cv_mbstate_t" >&5
+-echo "${ECHO_T}$cf_cv_mbstate_t" >&6
+ 
+-if test "$cf_cv_mbstate_t" = yes ; then
++exit 0
++CF_EOF
++chmod 755 $cf_edit_man
++
++###############################################################################
++
++### Note that some functions (such as const) are normally disabled anyway.
++echo "$as_me:7473: checking if you want to build with function extensions" >&5
++echo $ECHO_N "checking if you want to build with function extensions... $ECHO_C" >&6
++
++# Check whether --enable-ext-funcs or --disable-ext-funcs was given.
++if test "${enable_ext_funcs+set}" = set; then
++  enableval="$enable_ext_funcs"
++  with_ext_funcs=$enableval
++else
++  with_ext_funcs=yes
++fi;
++echo "$as_me:7483: result: $with_ext_funcs" >&5
++echo "${ECHO_T}$with_ext_funcs" >&6
++if test "$with_ext_funcs" = yes ; then
++	NCURSES_EXT_FUNCS=1
+ 	cat >>confdefs.h <<\EOF
+-#define NEED_WCHAR_H 1
++#define HAVE_CURSES_VERSION 1
+ EOF
+ 
+-	NEED_WCHAR_H=1
++	cat >>confdefs.h <<\EOF
++#define HAVE_HAS_KEY 1
++EOF
++
++	cat >>confdefs.h <<\EOF
++#define HAVE_RESIZETERM 1
++EOF
++
++	cat >>confdefs.h <<\EOF
++#define HAVE_RESIZE_TERM 1
++EOF
++
++	cat >>confdefs.h <<\EOF
++#define HAVE_USE_DEFAULT_COLORS 1
++EOF
++
++	cat >>confdefs.h <<\EOF
++#define HAVE_WRESIZE 1
++EOF
++
++	cat >>confdefs.h <<\EOF
++#define NCURSES_EXT_FUNCS 1
++EOF
++
++else
++	NCURSES_EXT_FUNCS=0
+ fi
+ 
+-# if we do not find mbstate_t in either place, use substitution to provide a fallback.
+-if test "$cf_cv_mbstate_t" = unknown ; then
+-	NCURSES_MBSTATE_T=1
++###   use option --enable-const to turn on use of const beyond that in XSI.
++echo "$as_me:7520: checking for extended use of const keyword" >&5
++echo $ECHO_N "checking for extended use of const keyword... $ECHO_C" >&6
++
++# Check whether --enable-const or --disable-const was given.
++if test "${enable_const+set}" = set; then
++  enableval="$enable_const"
++  with_ext_const=$enableval
++else
++  with_ext_const=no
++fi;
++echo "$as_me:7530: result: $with_ext_const" >&5
++echo "${ECHO_T}$with_ext_const" >&6
++NCURSES_CONST='/*nothing*/'
++if test "$with_ext_const" = yes ; then
++	NCURSES_CONST=const
+ fi
+ 
+-# This is needed on Tru64 5.0 to declare wchar_t
+-echo "$as_me:6908: checking if we must include wchar.h to declare wchar_t" >&5
+-echo $ECHO_N "checking if we must include wchar.h to declare wchar_t... $ECHO_C" >&6
+-if test "${cf_cv_wchar_t+set}" = set; then
+-  echo $ECHO_N "(cached) $ECHO_C" >&6
++echo "$as_me:7537: checking if you want \$NCURSES_NO_PADDING code" >&5
++echo $ECHO_N "checking if you want \$NCURSES_NO_PADDING code... $ECHO_C" >&6
++
++# Check whether --enable-no-padding or --disable-no-padding was given.
++if test "${enable_no_padding+set}" = set; then
++  enableval="$enable_no_padding"
++  with_no_padding=$enableval
+ else
++  with_no_padding=$with_ext_funcs
++fi;
++echo "$as_me:7547: result: $with_no_padding" >&5
++echo "${ECHO_T}$with_no_padding" >&6
++test "$with_no_padding" = yes && cat >>confdefs.h <<\EOF
++#define NCURSES_NO_PADDING 1
++EOF
+ 
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 6915 "configure"
+-#include "confdefs.h"
++###   use option --enable-sigwinch to turn on use of SIGWINCH logic
++echo "$as_me:7554: checking if you want SIGWINCH handler" >&5
++echo $ECHO_N "checking if you want SIGWINCH handler... $ECHO_C" >&6
+ 
+-#include <stdlib.h>
+-#include <stdarg.h>
+-#include <stdio.h>
+-#ifdef HAVE_LIBUTF8_H
+-#include <libutf8.h>
+-#endif
+-int
+-main ()
+-{
+-wchar_t state
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6933: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6936: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6939: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6942: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_cv_wchar_t=no
++# Check whether --enable-sigwinch or --disable-sigwinch was given.
++if test "${enable_sigwinch+set}" = set; then
++  enableval="$enable_sigwinch"
++  with_sigwinch=$enableval
+ else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 6949 "configure"
+-#include "confdefs.h"
++  with_sigwinch=$with_ext_funcs
++fi;
++echo "$as_me:7564: result: $with_sigwinch" >&5
++echo "${ECHO_T}$with_sigwinch" >&6
++test "$with_sigwinch" = yes && cat >>confdefs.h <<\EOF
++#define USE_SIGWINCH 1
++EOF
+ 
+-#include <stdlib.h>
+-#include <stdarg.h>
+-#include <stdio.h>
+-#include <wchar.h>
+-#ifdef HAVE_LIBUTF8_H
+-#include <libutf8.h>
+-#endif
+-int
+-main ()
+-{
+-wchar_t value
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:6968: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6971: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:6974: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:6977: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_cv_wchar_t=yes
++###   use option --enable-tcap-names to allow user to define new capabilities
++echo "$as_me:7571: checking if you want user-definable terminal capabilities like termcap" >&5
++echo $ECHO_N "checking if you want user-definable terminal capabilities like termcap... $ECHO_C" >&6
++
++# Check whether --enable-tcap-names or --disable-tcap-names was given.
++if test "${enable_tcap_names+set}" = set; then
++  enableval="$enable_tcap_names"
++  with_tcap_names=$enableval
+ else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_cv_wchar_t=unknown
+-fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-fi
+-echo "$as_me:6989: result: $cf_cv_wchar_t" >&5
+-echo "${ECHO_T}$cf_cv_wchar_t" >&6
++  with_tcap_names=$with_ext_funcs
++fi;
++echo "$as_me:7581: result: $with_tcap_names" >&5
++echo "${ECHO_T}$with_tcap_names" >&6
++NCURSES_XNAMES=0
++test "$with_tcap_names" = yes && NCURSES_XNAMES=1
+ 
+-if test "$cf_cv_wchar_t" = yes ; then
+-	cat >>confdefs.h <<\EOF
+-#define NEED_WCHAR_H 1
+-EOF
++###############################################################################
++# These options are relatively safe to experiment with.
+ 
+-	NEED_WCHAR_H=1
+-fi
++echo "$as_me:7589: checking if you want all development code" >&5
++echo $ECHO_N "checking if you want all development code... $ECHO_C" >&6
+ 
+-# if we do not find wchar_t in either place, use substitution to provide a fallback.
+-if test "$cf_cv_wchar_t" = unknown ; then
+-	NCURSES_WCHAR_T=1
+-fi
++# Check whether --with-develop or --without-develop was given.
++if test "${with_develop+set}" = set; then
++  withval="$with_develop"
++  with_develop=$withval
++else
++  with_develop=no
++fi;
++echo "$as_me:7599: result: $with_develop" >&5
++echo "${ECHO_T}$with_develop" >&6
+ 
+-# if we find wchar_t in either place, use substitution to provide a fallback.
+-if test "$cf_cv_wchar_t" != unknown ; then
+-	NCURSES_OK_WCHAR_T=1
+-fi
++###   use option --enable-hard-tabs to turn on use of hard-tabs optimize
++echo "$as_me:7603: checking if you want hard-tabs code" >&5
++echo $ECHO_N "checking if you want hard-tabs code... $ECHO_C" >&6
+ 
+-# This is needed on Tru64 5.0 to declare wint_t
+-echo "$as_me:7011: checking if we must include wchar.h to declare wint_t" >&5
+-echo $ECHO_N "checking if we must include wchar.h to declare wint_t... $ECHO_C" >&6
+-if test "${cf_cv_wint_t+set}" = set; then
+-  echo $ECHO_N "(cached) $ECHO_C" >&6
++# Check whether --enable-hard-tabs or --disable-hard-tabs was given.
++if test "${enable_hard_tabs+set}" = set; then
++  enableval="$enable_hard_tabs"
++  with_hardtabs=$enableval
+ else
++  with_hardtabs=$with_develop
++fi;
++echo "$as_me:7613: result: $with_hardtabs" >&5
++echo "${ECHO_T}$with_hardtabs" >&6
++test "$with_hardtabs" = yes && cat >>confdefs.h <<\EOF
++#define USE_HARD_TABS 1
++EOF
+ 
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 7018 "configure"
+-#include "confdefs.h"
++###   use option --enable-xmc-glitch to turn on use of magic-cookie optimize
++echo "$as_me:7620: checking if you want limited support for xmc" >&5
++echo $ECHO_N "checking if you want limited support for xmc... $ECHO_C" >&6
+ 
+-#include <stdlib.h>
+-#include <stdarg.h>
+-#include <stdio.h>
+-#ifdef HAVE_LIBUTF8_H
+-#include <libutf8.h>
+-#endif
+-int
+-main ()
+-{
+-wint_t state
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:7036: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:7039: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:7042: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:7045: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_cv_wint_t=no
++# Check whether --enable-xmc-glitch or --disable-xmc-glitch was given.
++if test "${enable_xmc_glitch+set}" = set; then
++  enableval="$enable_xmc_glitch"
++  with_xmc_glitch=$enableval
++else
++  with_xmc_glitch=$with_develop
++fi;
++echo "$as_me:7630: result: $with_xmc_glitch" >&5
++echo "${ECHO_T}$with_xmc_glitch" >&6
++test "$with_xmc_glitch" = yes && cat >>confdefs.h <<\EOF
++#define USE_XMC_SUPPORT 1
++EOF
++
++###############################################################################
++# These are just experimental, probably should not be in a package:
++
++echo "$as_me:7639: checking if you do not want to assume colors are white-on-black" >&5
++echo $ECHO_N "checking if you do not want to assume colors are white-on-black... $ECHO_C" >&6
++
++# Check whether --enable-assumed-color or --disable-assumed-color was given.
++if test "${enable_assumed_color+set}" = set; then
++  enableval="$enable_assumed_color"
++  with_assumed_color=$enableval
+ else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cat >conftest.$ac_ext <<_ACEOF
+-#line 7052 "configure"
+-#include "confdefs.h"
++  with_assumed_color=yes
++fi;
++echo "$as_me:7649: result: $with_assumed_color" >&5
++echo "${ECHO_T}$with_assumed_color" >&6
++test "$with_assumed_color" = yes && cat >>confdefs.h <<\EOF
++#define USE_ASSUMED_COLOR 1
++EOF
+ 
+-#include <stdlib.h>
+-#include <stdarg.h>
+-#include <stdio.h>
+-#include <wchar.h>
+-#ifdef HAVE_LIBUTF8_H
+-#include <libutf8.h>
+-#endif
+-int
+-main ()
+-{
+-wint_t value
+-  ;
+-  return 0;
+-}
+-_ACEOF
+-rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:7071: \"$ac_compile\"") >&5
+-  (eval $ac_compile) 2>&5
+-  ac_status=$?
+-  echo "$as_me:7074: \$? = $ac_status" >&5
+-  (exit $ac_status); } &&
+-         { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:7077: \"$ac_try\"") >&5
+-  (eval $ac_try) 2>&5
+-  ac_status=$?
+-  echo "$as_me:7080: \$? = $ac_status" >&5
+-  (exit $ac_status); }; }; then
+-  cf_cv_wint_t=yes
++###   use option --enable-hashmap to turn on use of hashmap scrolling logic
++echo "$as_me:7656: checking if you want hashmap scrolling-optimization code" >&5
++echo $ECHO_N "checking if you want hashmap scrolling-optimization code... $ECHO_C" >&6
++
++# Check whether --enable-hashmap or --disable-hashmap was given.
++if test "${enable_hashmap+set}" = set; then
++  enableval="$enable_hashmap"
++  with_hashmap=$enableval
+ else
+-  echo "$as_me: failed program was:" >&5
+-cat conftest.$ac_ext >&5
+-cf_cv_wint_t=unknown
+-fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-fi
+-rm -f conftest.$ac_objext conftest.$ac_ext
+-fi
+-echo "$as_me:7092: result: $cf_cv_wint_t" >&5
+-echo "${ECHO_T}$cf_cv_wint_t" >&6
++  with_hashmap=yes
++fi;
++echo "$as_me:7666: result: $with_hashmap" >&5
++echo "${ECHO_T}$with_hashmap" >&6
++test "$with_hashmap" = yes && cat >>confdefs.h <<\EOF
++#define USE_HASHMAP 1
++EOF
+ 
+-if test "$cf_cv_wint_t" = yes ; then
++###   use option --enable-colorfgbg to turn on use of $COLORFGBG environment
++echo "$as_me:7673: checking if you want colorfgbg code" >&5
++echo $ECHO_N "checking if you want colorfgbg code... $ECHO_C" >&6
++
++# Check whether --enable-colorfgbg or --disable-colorfgbg was given.
++if test "${enable_colorfgbg+set}" = set; then
++  enableval="$enable_colorfgbg"
++  with_colorfgbg=$enableval
++else
++  with_colorfgbg=no
++fi;
++echo "$as_me:7683: result: $with_colorfgbg" >&5
++echo "${ECHO_T}$with_colorfgbg" >&6
++test "$with_colorfgbg" = yes && cat >>confdefs.h <<\EOF
++#define USE_COLORFGBG 1
++EOF
++
++###   use option --enable-ext-colors to turn on use of colors beyond 16.
++echo "$as_me:7690: checking if you want to use experimental extended colors" >&5
++echo $ECHO_N "checking if you want to use experimental extended colors... $ECHO_C" >&6
++
++# Check whether --enable-ext-colors or --disable-ext-colors was given.
++if test "${enable_ext_colors+set}" = set; then
++  enableval="$enable_ext_colors"
++  with_ext_colors=$enableval
++else
++  with_ext_colors=no
++fi;
++echo "$as_me:7700: result: $with_ext_colors" >&5
++echo "${ECHO_T}$with_ext_colors" >&6
++NCURSES_EXT_COLORS=0
++if test "$with_ext_colors" = yes ; then
++	if test "$with_widec" != yes ; then
++		{ echo "$as_me:7705: WARNING: This option applies only to wide-character library" >&5
++echo "$as_me: WARNING: This option applies only to wide-character library" >&2;}
++	else
++		# cannot be ABI 5 since it changes sizeof(cchar_t)
++		case $cf_cv_rel_version in
++		5.*)
++			cf_cv_rel_version=6.0
++			cf_cv_abi_version=6
++			{ echo "$as_me:7713: WARNING: Overriding ABI version to $cf_cv_abi_version" >&5
++echo "$as_me: WARNING: Overriding ABI version to $cf_cv_abi_version" >&2;}
++			;;
++		esac
++	fi
++	NCURSES_EXT_COLORS=1
+ 	cat >>confdefs.h <<\EOF
+-#define NEED_WCHAR_H 1
++#define NCURSES_EXT_COLORS 1
+ EOF
+ 
+-	NEED_WCHAR_H=1
+ fi
+ 
+-# if we do not find wint_t in either place, use substitution to provide a fallback.
+-if test "$cf_cv_wint_t" = unknown ; then
+-	NCURSES_WINT_T=1
+-fi
++###   use option --enable-ext-mouse to modify coding to support 5-button mice
++echo "$as_me:7726: checking if you want to use experimental extended mouse encoding" >&5
++echo $ECHO_N "checking if you want to use experimental extended mouse encoding... $ECHO_C" >&6
+ 
+-# if we find wint_t in either place, use substitution to provide a fallback.
+-if test "$cf_cv_wint_t" != unknown ; then
+-	NCURSES_OK_WINT_T=1
++# Check whether --enable-ext-mouse or --disable-ext-mouse was given.
++if test "${enable_ext_mouse+set}" = set; then
++  enableval="$enable_ext_mouse"
++  with_ext_mouse=$enableval
++else
++  with_ext_mouse=no
++fi;
++echo "$as_me:7736: result: $with_ext_mouse" >&5
++echo "${ECHO_T}$with_ext_mouse" >&6
++NCURSES_MOUSE_VERSION=1
++if test "$with_ext_mouse" = yes ; then
++	NCURSES_MOUSE_VERSION=2
+ fi
+ 
+-fi
++echo "$as_me:7743: checking if you want experimental safe-sprintf code" >&5
++echo $ECHO_N "checking if you want experimental safe-sprintf code... $ECHO_C" >&6
++
++# Check whether --enable-safe-sprintf or --disable-safe-sprintf was given.
++if test "${enable_safe_sprintf+set}" = set; then
++  enableval="$enable_safe_sprintf"
++  with_safe_sprintf=$enableval
++else
++  with_safe_sprintf=no
++fi;
++echo "$as_me:7753: result: $with_safe_sprintf" >&5
++echo "${ECHO_T}$with_safe_sprintf" >&6
++test "$with_safe_sprintf" = yes && cat >>confdefs.h <<\EOF
++#define USE_SAFE_SPRINTF 1
++EOF
+ 
+-echo "$as_me:7115: checking for terminal capabilities file" >&5
+-echo $ECHO_N "checking for terminal capabilities file... $ECHO_C" >&6
++###   use option --disable-scroll-hints to turn off use of scroll-hints scrolling logic
++# when hashmap is used scroll hints are useless
++if test "$with_hashmap" = no ; then
++echo "$as_me:7762: checking if you want to experiment without scrolling-hints code" >&5
++echo $ECHO_N "checking if you want to experiment without scrolling-hints code... $ECHO_C" >&6
+ 
+-# Check whether --with-caps or --without-caps was given.
+-if test "${with_caps+set}" = set; then
+-  withval="$with_caps"
+-  TERMINFO_CAPS=Caps.$withval
++# Check whether --enable-scroll-hints or --disable-scroll-hints was given.
++if test "${enable_scroll_hints+set}" = set; then
++  enableval="$enable_scroll_hints"
++  with_scroll_hints=$enableval
+ else
+-  TERMINFO_CAPS=Caps
++  with_scroll_hints=yes
+ fi;
+-test -f ${srcdir}/include/${TERMINFO_CAPS} || TERMINFO_CAPS=Caps
+-echo "$as_me:7126: result: $TERMINFO_CAPS" >&5
+-echo "${ECHO_T}$TERMINFO_CAPS" >&6
++echo "$as_me:7772: result: $with_scroll_hints" >&5
++echo "${ECHO_T}$with_scroll_hints" >&6
++test "$with_scroll_hints" = yes && cat >>confdefs.h <<\EOF
++#define USE_SCROLL_HINTS 1
++EOF
++
++fi
+ 
+ ###############################################################################
+ 
+ ###	use option --disable-echo to suppress full display compiling commands
+-echo "$as_me:7132: checking if you want to display full commands during build" >&5
++echo "$as_me:7783: checking if you want to display full commands during build" >&5
+ echo $ECHO_N "checking if you want to display full commands during build... $ECHO_C" >&6
+ 
+ # Check whether --enable-echo or --disable-echo was given.
+@@ -7145,11 +7796,11 @@
+ 	ECHO_LINK='@ echo linking $@ ... ;'
+ 	test -n "$LIBTOOL" && LIBTOOL="$LIBTOOL --silent"
+ fi
+-echo "$as_me:7148: result: $with_echo" >&5
++echo "$as_me:7799: result: $with_echo" >&5
+ echo "${ECHO_T}$with_echo" >&6
+ 
+ ###	use option --enable-warnings to turn on all gcc warnings
+-echo "$as_me:7152: checking if you want to see compiler warnings" >&5
++echo "$as_me:7803: checking if you want to see compiler warnings" >&5
+ echo $ECHO_N "checking if you want to see compiler warnings... $ECHO_C" >&6
+ 
+ # Check whether --enable-warnings or --disable-warnings was given.
+@@ -7157,19 +7808,37 @@
+   enableval="$enable_warnings"
+   with_warnings=$enableval
+ fi;
+-echo "$as_me:7160: result: $with_warnings" >&5
++echo "$as_me:7811: result: $with_warnings" >&5
+ echo "${ECHO_T}$with_warnings" >&6
+ 
+ if test -n "$with_warnings"; then
+  	ADAFLAGS="$ADAFLAGS -gnatg"
+ 
+-if test "$GCC" = yes
++if test "$INTEL_COMPILER" = yes
++then
++# The "-wdXXX" options suppress warnings:
++# remark #1419: external declaration in primary source file
++# remark #193: zero used for undefined preprocessing identifier
++# remark #593: variable "curs_sb_left_arrow" was set but never used
++# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
++# remark #869: parameter "tw" was never referenced
++# remark #981: operands are evaluated in unspecified order
++# warning #269: invalid format string conversion
++	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall \
++ -wd1419 \
++ -wd193 \
++ -wd279 \
++ -wd593 \
++ -wd810 \
++ -wd869 \
++ -wd981"
++elif test "$GCC" = yes
+ then
+ 	cat > conftest.$ac_ext <<EOF
+-#line 7169 "configure"
++#line 7838 "configure"
+ int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
+ EOF
+-	{ echo "$as_me:7172: checking for $CC warning options..." >&5
++	{ echo "$as_me:7841: checking for $CC warning options..." >&5
+ echo "$as_me: checking for $CC warning options..." >&6;}
+ 	cf_save_CFLAGS="$CFLAGS"
+ 	EXTRA_CFLAGS="-W -Wall"
+@@ -7189,12 +7858,12 @@
+ 		Wundef $cf_warn_CONST
+ 	do
+ 		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
+-		if { (eval echo "$as_me:7192: \"$ac_compile\"") >&5
++		if { (eval echo "$as_me:7861: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:7195: \$? = $ac_status" >&5
++  echo "$as_me:7864: \$? = $ac_status" >&5
+   (exit $ac_status); }; then
+-			test -n "$verbose" && echo "$as_me:7197: result: ... -$cf_opt" >&5
++			test -n "$verbose" && echo "$as_me:7866: result: ... -$cf_opt" >&5
+ echo "${ECHO_T}... -$cf_opt" >&6
+ 			case $cf_opt in #(vi
+ 			Wcast-qual) #(vi
+@@ -7236,10 +7905,10 @@
+ EOF
+ if test "$GCC" = yes
+ then
+-	{ echo "$as_me:7239: checking for $CC __attribute__ directives..." >&5
++	{ echo "$as_me:7908: checking for $CC __attribute__ directives..." >&5
+ echo "$as_me: checking for $CC __attribute__ directives..." >&6;}
+ cat > conftest.$ac_ext <<EOF
+-#line 7242 "configure"
++#line 7911 "configure"
+ #include "confdefs.h"
+ #include "conftest.h"
+ #include "conftest.i"
+@@ -7277,12 +7946,12 @@
+ EOF
+ 			;;
+ 		esac
+-		if { (eval echo "$as_me:7280: \"$ac_compile\"") >&5
++		if { (eval echo "$as_me:7949: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:7283: \$? = $ac_status" >&5
++  echo "$as_me:7952: \$? = $ac_status" >&5
+   (exit $ac_status); }; then
+-			test -n "$verbose" && echo "$as_me:7285: result: ... $cf_attribute" >&5
++			test -n "$verbose" && echo "$as_me:7954: result: ... $cf_attribute" >&5
+ echo "${ECHO_T}... $cf_attribute" >&6
+ 			cat conftest.h >>confdefs.h
+ 		fi
+@@ -7294,7 +7963,7 @@
+ fi
+ 
+ ###	use option --enable-assertions to turn on generation of assertion code
+-echo "$as_me:7297: checking if you want to enable runtime assertions" >&5
++echo "$as_me:7966: checking if you want to enable runtime assertions" >&5
+ echo $ECHO_N "checking if you want to enable runtime assertions... $ECHO_C" >&6
+ 
+ # Check whether --enable-assertions or --disable-assertions was given.
+@@ -7304,7 +7973,7 @@
+ else
+   with_assertions=no
+ fi;
+-echo "$as_me:7307: result: $with_assertions" >&5
++echo "$as_me:7976: result: $with_assertions" >&5
+ echo "${ECHO_T}$with_assertions" >&6
+ if test -n "$GCC"
+ then
+@@ -7365,7 +8034,7 @@
+ 	;;
+ esac
+ 
+-echo "$as_me:7368: checking whether to add trace feature to all models" >&5
++echo "$as_me:8037: checking whether to add trace feature to all models" >&5
+ echo $ECHO_N "checking whether to add trace feature to all models... $ECHO_C" >&6
+ 
+ # Check whether --with-trace or --without-trace was given.
+@@ -7375,19 +8044,41 @@
+ else
+   cf_with_trace=$cf_all_traces
+ fi;
+-echo "$as_me:7378: result: $with_trace" >&5
++echo "$as_me:8047: result: $with_trace" >&5
+ echo "${ECHO_T}$with_trace" >&6
+ 
+ if test "$cf_with_trace" = yes ; then
+ 	LIB_TRACING=all
+ 	ADA_TRACE=TRUE
+ 
++cf_fix_cppflags=no
+ cf_new_cflags=
+ cf_new_cppflags=
++cf_new_extra_cppflags=
++
+ for cf_add_cflags in -DTRACE
+ do
++case $cf_fix_cppflags in
++no)
+ 	case $cf_add_cflags in #(vi
+ 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
++		case $cf_add_cflags in
++		-D*)
++			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
++
++			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++			&& test -z "${cf_tst_cflags}" \
++			&& cf_fix_cppflags=yes
++
++			if test $cf_fix_cppflags = yes ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			elif test "${cf_tst_cflags}" = "\"'" ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			fi
++			;;
++		esac
+ 		case "$CPPFLAGS" in
+ 		*$cf_add_cflags) #(vi
+ 			;;
+@@ -7400,6 +8091,17 @@
+ 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ 		;;
+ 	esac
++	;;
++yes)
++	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++
++	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
++
++	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++	&& test -z "${cf_tst_cflags}" \
++	&& cf_fix_cppflags=no
++	;;
++esac
+ done
+ 
+ if test -n "$cf_new_cflags" ; then
+@@ -7412,19 +8114,24 @@
+ 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
+ fi
+ 
++if test -n "$cf_new_extra_cppflags" ; then
++
++	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
++fi
++
+ else
+ 	LIB_TRACING=DEBUG
+ 	ADA_TRACE=FALSE
+ fi
+ 
+ ###	Checks for libraries.
+-echo "$as_me:7421: checking for gettimeofday" >&5
++echo "$as_me:8128: checking for gettimeofday" >&5
+ echo $ECHO_N "checking for gettimeofday... $ECHO_C" >&6
+ if test "${ac_cv_func_gettimeofday+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 7427 "configure"
++#line 8134 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char gettimeofday (); below.  */
+@@ -7455,16 +8162,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:7458: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8165: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:7461: \$? = $ac_status" >&5
++  echo "$as_me:8168: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:7464: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8171: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:7467: \$? = $ac_status" >&5
++  echo "$as_me:8174: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_func_gettimeofday=yes
+ else
+@@ -7474,7 +8181,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:7477: result: $ac_cv_func_gettimeofday" >&5
++echo "$as_me:8184: result: $ac_cv_func_gettimeofday" >&5
+ echo "${ECHO_T}$ac_cv_func_gettimeofday" >&6
+ if test $ac_cv_func_gettimeofday = yes; then
+   cat >>confdefs.h <<\EOF
+@@ -7483,7 +8190,7 @@
+ 
+ else
+ 
+-echo "$as_me:7486: checking for gettimeofday in -lbsd" >&5
++echo "$as_me:8193: checking for gettimeofday in -lbsd" >&5
+ echo $ECHO_N "checking for gettimeofday in -lbsd... $ECHO_C" >&6
+ if test "${ac_cv_lib_bsd_gettimeofday+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -7491,7 +8198,7 @@
+   ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lbsd  $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 7494 "configure"
++#line 8201 "configure"
+ #include "confdefs.h"
+ 
+ /* Override any gcc2 internal prototype to avoid an error.  */
+@@ -7510,16 +8217,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:7513: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8220: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:7516: \$? = $ac_status" >&5
++  echo "$as_me:8223: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:7519: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8226: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:7522: \$? = $ac_status" >&5
++  echo "$as_me:8229: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_lib_bsd_gettimeofday=yes
+ else
+@@ -7530,7 +8237,7 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+-echo "$as_me:7533: result: $ac_cv_lib_bsd_gettimeofday" >&5
++echo "$as_me:8240: result: $ac_cv_lib_bsd_gettimeofday" >&5
+ echo "${ECHO_T}$ac_cv_lib_bsd_gettimeofday" >&6
+ if test $ac_cv_lib_bsd_gettimeofday = yes; then
+   cat >>confdefs.h <<\EOF
+@@ -7542,14 +8249,14 @@
+ 
+ fi
+ 
+-echo "$as_me:7545: checking if -lm needed for math functions" >&5
++echo "$as_me:8252: checking if -lm needed for math functions" >&5
+ echo $ECHO_N "checking if -lm needed for math functions... $ECHO_C" >&6
+ if test "${cf_cv_need_libm+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 7552 "configure"
++#line 8259 "configure"
+ #include "confdefs.h"
+ 
+ 	#include <stdio.h>
+@@ -7564,16 +8271,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:7567: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8274: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:7570: \$? = $ac_status" >&5
++  echo "$as_me:8277: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:7573: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8280: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:7576: \$? = $ac_status" >&5
++  echo "$as_me:8283: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_need_libm=no
+ else
+@@ -7583,7 +8290,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:7586: result: $cf_cv_need_libm" >&5
++echo "$as_me:8293: result: $cf_cv_need_libm" >&5
+ echo "${ECHO_T}$cf_cv_need_libm" >&6
+ if test "$cf_cv_need_libm" = yes
+ then
+@@ -7591,13 +8298,13 @@
+ fi
+ 
+ ###	Checks for header files.
+-echo "$as_me:7594: checking for ANSI C header files" >&5
++echo "$as_me:8301: checking for ANSI C header files" >&5
+ echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+ if test "${ac_cv_header_stdc+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 7600 "configure"
++#line 8307 "configure"
+ #include "confdefs.h"
+ #include <stdlib.h>
+ #include <stdarg.h>
+@@ -7605,13 +8312,13 @@
+ #include <float.h>
+ 
+ _ACEOF
+-if { (eval echo "$as_me:7608: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:8315: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:7614: \$? = $ac_status" >&5
++  echo "$as_me:8321: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+@@ -7633,7 +8340,7 @@
+ if test $ac_cv_header_stdc = yes; then
+   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 7636 "configure"
++#line 8343 "configure"
+ #include "confdefs.h"
+ #include <string.h>
+ 
+@@ -7651,7 +8358,7 @@
+ if test $ac_cv_header_stdc = yes; then
+   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 7654 "configure"
++#line 8361 "configure"
+ #include "confdefs.h"
+ #include <stdlib.h>
+ 
+@@ -7672,7 +8379,7 @@
+   :
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 7675 "configure"
++#line 8382 "configure"
+ #include "confdefs.h"
+ #include <ctype.h>
+ #if ((' ' & 0x0FF) == 0x020)
+@@ -7698,15 +8405,15 @@
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:7701: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8408: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:7704: \$? = $ac_status" >&5
++  echo "$as_me:8411: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:7706: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8413: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:7709: \$? = $ac_status" >&5
++  echo "$as_me:8416: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   :
+ else
+@@ -7719,7 +8426,7 @@
+ fi
+ fi
+ fi
+-echo "$as_me:7722: result: $ac_cv_header_stdc" >&5
++echo "$as_me:8429: result: $ac_cv_header_stdc" >&5
+ echo "${ECHO_T}$ac_cv_header_stdc" >&6
+ if test $ac_cv_header_stdc = yes; then
+ 
+@@ -7732,13 +8439,13 @@
+ ac_header_dirent=no
+ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+   as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+-echo "$as_me:7735: checking for $ac_hdr that defines DIR" >&5
++echo "$as_me:8442: checking for $ac_hdr that defines DIR" >&5
+ echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_Header+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 7741 "configure"
++#line 8448 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #include <$ac_hdr>
+@@ -7753,16 +8460,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:7756: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:8463: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:7759: \$? = $ac_status" >&5
++  echo "$as_me:8466: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:7762: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8469: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:7765: \$? = $ac_status" >&5
++  echo "$as_me:8472: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   eval "$as_ac_Header=yes"
+ else
+@@ -7772,7 +8479,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+-echo "$as_me:7775: result: `eval echo '${'$as_ac_Header'}'`" >&5
++echo "$as_me:8482: result: `eval echo '${'$as_ac_Header'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ if test `eval echo '${'$as_ac_Header'}'` = yes; then
+   cat >>confdefs.h <<EOF
+@@ -7785,7 +8492,7 @@
+ done
+ # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+ if test $ac_header_dirent = dirent.h; then
+-  echo "$as_me:7788: checking for opendir in -ldir" >&5
++  echo "$as_me:8495: checking for opendir in -ldir" >&5
+ echo $ECHO_N "checking for opendir in -ldir... $ECHO_C" >&6
+ if test "${ac_cv_lib_dir_opendir+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -7793,7 +8500,7 @@
+   ac_check_lib_save_LIBS=$LIBS
+ LIBS="-ldir  $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 7796 "configure"
++#line 8503 "configure"
+ #include "confdefs.h"
+ 
+ /* Override any gcc2 internal prototype to avoid an error.  */
+@@ -7812,16 +8519,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:7815: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8522: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:7818: \$? = $ac_status" >&5
++  echo "$as_me:8525: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:7821: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8528: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:7824: \$? = $ac_status" >&5
++  echo "$as_me:8531: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_lib_dir_opendir=yes
+ else
+@@ -7832,14 +8539,14 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+-echo "$as_me:7835: result: $ac_cv_lib_dir_opendir" >&5
++echo "$as_me:8542: result: $ac_cv_lib_dir_opendir" >&5
+ echo "${ECHO_T}$ac_cv_lib_dir_opendir" >&6
+ if test $ac_cv_lib_dir_opendir = yes; then
+   LIBS="$LIBS -ldir"
+ fi
+ 
+ else
+-  echo "$as_me:7842: checking for opendir in -lx" >&5
++  echo "$as_me:8549: checking for opendir in -lx" >&5
+ echo $ECHO_N "checking for opendir in -lx... $ECHO_C" >&6
+ if test "${ac_cv_lib_x_opendir+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -7847,7 +8554,7 @@
+   ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lx  $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 7850 "configure"
++#line 8557 "configure"
+ #include "confdefs.h"
+ 
+ /* Override any gcc2 internal prototype to avoid an error.  */
+@@ -7866,16 +8573,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:7869: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8576: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:7872: \$? = $ac_status" >&5
++  echo "$as_me:8579: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:7875: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8582: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:7878: \$? = $ac_status" >&5
++  echo "$as_me:8585: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_lib_x_opendir=yes
+ else
+@@ -7886,7 +8593,7 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+-echo "$as_me:7889: result: $ac_cv_lib_x_opendir" >&5
++echo "$as_me:8596: result: $ac_cv_lib_x_opendir" >&5
+ echo "${ECHO_T}$ac_cv_lib_x_opendir" >&6
+ if test $ac_cv_lib_x_opendir = yes; then
+   LIBS="$LIBS -lx"
+@@ -7894,13 +8601,13 @@
+ 
+ fi
+ 
+-echo "$as_me:7897: checking whether time.h and sys/time.h may both be included" >&5
++echo "$as_me:8604: checking whether time.h and sys/time.h may both be included" >&5
+ echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
+ if test "${ac_cv_header_time+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 7903 "configure"
++#line 8610 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #include <sys/time.h>
+@@ -7916,16 +8623,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:7919: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:8626: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:7922: \$? = $ac_status" >&5
++  echo "$as_me:8629: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:7925: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8632: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:7928: \$? = $ac_status" >&5
++  echo "$as_me:8635: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_header_time=yes
+ else
+@@ -7935,7 +8642,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+-echo "$as_me:7938: result: $ac_cv_header_time" >&5
++echo "$as_me:8645: result: $ac_cv_header_time" >&5
+ echo "${ECHO_T}$ac_cv_header_time" >&6
+ if test $ac_cv_header_time = yes; then
+ 
+@@ -7945,14 +8652,14 @@
+ 
+ fi
+ 
+-echo "$as_me:7948: checking for regular-expression headers" >&5
++echo "$as_me:8655: checking for regular-expression headers" >&5
+ echo $ECHO_N "checking for regular-expression headers... $ECHO_C" >&6
+ if test "${cf_cv_regex+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 7955 "configure"
++#line 8662 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #include <regex.h>
+@@ -7970,16 +8677,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:7973: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8680: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:7976: \$? = $ac_status" >&5
++  echo "$as_me:8683: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:7979: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8686: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:7982: \$? = $ac_status" >&5
++  echo "$as_me:8689: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_regex="regex.h"
+ else
+@@ -7987,7 +8694,7 @@
+ cat conftest.$ac_ext >&5
+ 
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 7990 "configure"
++#line 8697 "configure"
+ #include "confdefs.h"
+ #include <regexp.h>
+ int
+@@ -8002,16 +8709,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:8005: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8712: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:8008: \$? = $ac_status" >&5
++  echo "$as_me:8715: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:8011: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8718: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8014: \$? = $ac_status" >&5
++  echo "$as_me:8721: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_regex="regexp.h"
+ else
+@@ -8021,7 +8728,7 @@
+ 		cf_save_LIBS="$LIBS"
+ 		LIBS="-lgen $LIBS"
+ 		cat >conftest.$ac_ext <<_ACEOF
+-#line 8024 "configure"
++#line 8731 "configure"
+ #include "confdefs.h"
+ #include <regexpr.h>
+ int
+@@ -8036,16 +8743,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:8039: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8746: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:8042: \$? = $ac_status" >&5
++  echo "$as_me:8749: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:8045: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8752: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8048: \$? = $ac_status" >&5
++  echo "$as_me:8755: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_regex="regexpr.h"
+ else
+@@ -8061,7 +8768,7 @@
+ 
+ fi
+ 
+-echo "$as_me:8064: result: $cf_cv_regex" >&5
++echo "$as_me:8771: result: $cf_cv_regex" >&5
+ echo "${ECHO_T}$cf_cv_regex" >&6
+ case $cf_cv_regex in
+ 	regex.h)   cat >>confdefs.h <<\EOF
+@@ -8097,23 +8804,23 @@
+ wctype.h
+ do
+ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+-echo "$as_me:8100: checking for $ac_header" >&5
++echo "$as_me:8807: checking for $ac_header" >&5
+ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_Header+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 8106 "configure"
++#line 8813 "configure"
+ #include "confdefs.h"
+ #include <$ac_header>
+ _ACEOF
+-if { (eval echo "$as_me:8110: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:8817: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:8116: \$? = $ac_status" >&5
++  echo "$as_me:8823: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+@@ -8132,7 +8839,7 @@
+ fi
+ rm -f conftest.err conftest.$ac_ext
+ fi
+-echo "$as_me:8135: result: `eval echo '${'$as_ac_Header'}'`" >&5
++echo "$as_me:8842: result: `eval echo '${'$as_ac_Header'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ if test `eval echo '${'$as_ac_Header'}'` = yes; then
+   cat >>confdefs.h <<EOF
+@@ -8146,7 +8853,7 @@
+ # Note: even non-Posix ISC needs <sys/bsdtypes.h> to declare fd_set
+ if test "$ISC" = yes ; then
+ 
+-echo "$as_me:8149: checking for main in -lcposix" >&5
++echo "$as_me:8856: checking for main in -lcposix" >&5
+ echo $ECHO_N "checking for main in -lcposix... $ECHO_C" >&6
+ if test "${ac_cv_lib_cposix_main+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -8154,7 +8861,7 @@
+   ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lcposix  $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 8157 "configure"
++#line 8864 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -8166,16 +8873,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:8169: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8876: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:8172: \$? = $ac_status" >&5
++  echo "$as_me:8879: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:8175: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8882: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8178: \$? = $ac_status" >&5
++  echo "$as_me:8885: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_lib_cposix_main=yes
+ else
+@@ -8186,7 +8893,7 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+-echo "$as_me:8189: result: $ac_cv_lib_cposix_main" >&5
++echo "$as_me:8896: result: $ac_cv_lib_cposix_main" >&5
+ echo "${ECHO_T}$ac_cv_lib_cposix_main" >&6
+ if test $ac_cv_lib_cposix_main = yes; then
+   cat >>confdefs.h <<EOF
+@@ -8197,7 +8904,7 @@
+ 
+ fi
+ 
+-	echo "$as_me:8200: checking for bzero in -linet" >&5
++	echo "$as_me:8907: checking for bzero in -linet" >&5
+ echo $ECHO_N "checking for bzero in -linet... $ECHO_C" >&6
+ if test "${ac_cv_lib_inet_bzero+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -8205,7 +8912,7 @@
+   ac_check_lib_save_LIBS=$LIBS
+ LIBS="-linet  $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 8208 "configure"
++#line 8915 "configure"
+ #include "confdefs.h"
+ 
+ /* Override any gcc2 internal prototype to avoid an error.  */
+@@ -8224,16 +8931,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:8227: \"$ac_link\"") >&5
++if { (eval echo "$as_me:8934: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:8230: \$? = $ac_status" >&5
++  echo "$as_me:8937: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:8233: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8940: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8236: \$? = $ac_status" >&5
++  echo "$as_me:8943: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_lib_inet_bzero=yes
+ else
+@@ -8244,21 +8951,21 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+-echo "$as_me:8247: result: $ac_cv_lib_inet_bzero" >&5
++echo "$as_me:8954: result: $ac_cv_lib_inet_bzero" >&5
+ echo "${ECHO_T}$ac_cv_lib_inet_bzero" >&6
+ if test $ac_cv_lib_inet_bzero = yes; then
+   LIBS="$LIBS -linet"
+ fi
+ fi
+ 
+-echo "$as_me:8254: checking if sys/time.h works with sys/select.h" >&5
++echo "$as_me:8961: checking if sys/time.h works with sys/select.h" >&5
+ echo $ECHO_N "checking if sys/time.h works with sys/select.h... $ECHO_C" >&6
+ if test "${cf_cv_sys_time_select+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 8261 "configure"
++#line 8968 "configure"
+ #include "confdefs.h"
+ 
+ #include <sys/types.h>
+@@ -8278,16 +8985,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:8281: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:8988: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:8284: \$? = $ac_status" >&5
++  echo "$as_me:8991: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:8287: \"$ac_try\"") >&5
++  { (eval echo "$as_me:8994: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8290: \$? = $ac_status" >&5
++  echo "$as_me:8997: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_sys_time_select=yes
+ else
+@@ -8299,7 +9006,7 @@
+ 
+ fi
+ 
+-echo "$as_me:8302: result: $cf_cv_sys_time_select" >&5
++echo "$as_me:9009: result: $cf_cv_sys_time_select" >&5
+ echo "${ECHO_T}$cf_cv_sys_time_select" >&6
+ test "$cf_cv_sys_time_select" = yes && cat >>confdefs.h <<\EOF
+ #define HAVE_SYS_TIME_SELECT 1
+@@ -8312,7 +9019,7 @@
+ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ 
+-echo "$as_me:8315: checking for $CC option to accept ANSI C" >&5
++echo "$as_me:9022: checking for $CC option to accept ANSI C" >&5
+ echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+ if test "${ac_cv_prog_cc_stdc+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -8320,7 +9027,7 @@
+   ac_cv_prog_cc_stdc=no
+ ac_save_CC=$CC
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 8323 "configure"
++#line 9030 "configure"
+ #include "confdefs.h"
+ #include <stdarg.h>
+ #include <stdio.h>
+@@ -8369,16 +9076,16 @@
+ do
+   CC="$ac_save_CC $ac_arg"
+   rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:8372: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:9079: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:8375: \$? = $ac_status" >&5
++  echo "$as_me:9082: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:8378: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9085: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8381: \$? = $ac_status" >&5
++  echo "$as_me:9088: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_prog_cc_stdc=$ac_arg
+ break
+@@ -8395,21 +9102,21 @@
+ 
+ case "x$ac_cv_prog_cc_stdc" in
+   x|xno)
+-    echo "$as_me:8398: result: none needed" >&5
++    echo "$as_me:9105: result: none needed" >&5
+ echo "${ECHO_T}none needed" >&6 ;;
+   *)
+-    echo "$as_me:8401: result: $ac_cv_prog_cc_stdc" >&5
++    echo "$as_me:9108: result: $ac_cv_prog_cc_stdc" >&5
+ echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+     CC="$CC $ac_cv_prog_cc_stdc" ;;
+ esac
+ 
+-echo "$as_me:8406: checking for an ANSI C-conforming const" >&5
++echo "$as_me:9113: checking for an ANSI C-conforming const" >&5
+ echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+ if test "${ac_cv_c_const+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 8412 "configure"
++#line 9119 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -8467,16 +9174,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:8470: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:9177: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:8473: \$? = $ac_status" >&5
++  echo "$as_me:9180: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:8476: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9183: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8479: \$? = $ac_status" >&5
++  echo "$as_me:9186: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_c_const=yes
+ else
+@@ -8486,7 +9193,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+-echo "$as_me:8489: result: $ac_cv_c_const" >&5
++echo "$as_me:9196: result: $ac_cv_c_const" >&5
+ echo "${ECHO_T}$ac_cv_c_const" >&6
+ if test $ac_cv_c_const = no; then
+ 
+@@ -8496,7 +9203,7 @@
+ 
+ fi
+ 
+-echo "$as_me:8499: checking for inline" >&5
++echo "$as_me:9206: checking for inline" >&5
+ echo $ECHO_N "checking for inline... $ECHO_C" >&6
+ if test "${ac_cv_c_inline+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -8504,7 +9211,7 @@
+   ac_cv_c_inline=no
+ for ac_kw in inline __inline__ __inline; do
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 8507 "configure"
++#line 9214 "configure"
+ #include "confdefs.h"
+ #ifndef __cplusplus
+ static $ac_kw int static_foo () {return 0; }
+@@ -8513,16 +9220,16 @@
+ 
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:8516: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:9223: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:8519: \$? = $ac_status" >&5
++  echo "$as_me:9226: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:8522: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9229: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8525: \$? = $ac_status" >&5
++  echo "$as_me:9232: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_c_inline=$ac_kw; break
+ else
+@@ -8533,7 +9240,7 @@
+ done
+ 
+ fi
+-echo "$as_me:8536: result: $ac_cv_c_inline" >&5
++echo "$as_me:9243: result: $ac_cv_c_inline" >&5
+ echo "${ECHO_T}$ac_cv_c_inline" >&6
+ case $ac_cv_c_inline in
+   inline | yes) ;;
+@@ -8552,14 +9259,14 @@
+ #define CC_HAS_INLINE_FUNCS 1
+ EOF
+ 
+-echo "$as_me:8555: checking if unsigned literals are legal" >&5
++echo "$as_me:9262: checking if unsigned literals are legal" >&5
+ echo $ECHO_N "checking if unsigned literals are legal... $ECHO_C" >&6
+ if test "${cf_cv_unsigned_literals+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 8562 "configure"
++#line 9269 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -8571,16 +9278,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:8574: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:9281: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:8577: \$? = $ac_status" >&5
++  echo "$as_me:9284: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:8580: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9287: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8583: \$? = $ac_status" >&5
++  echo "$as_me:9290: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_unsigned_literals=yes
+ else
+@@ -8592,10 +9299,10 @@
+ 
+ fi
+ 
+-echo "$as_me:8595: result: $cf_cv_unsigned_literals" >&5
++echo "$as_me:9302: result: $cf_cv_unsigned_literals" >&5
+ echo "${ECHO_T}$cf_cv_unsigned_literals" >&6
+ 
+-echo "$as_me:8598: checking for type of chtype" >&5
++echo "$as_me:9305: checking for type of chtype" >&5
+ echo $ECHO_N "checking for type of chtype... $ECHO_C" >&6
+ if test "${cf_cv_typeof_chtype+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -8605,7 +9312,7 @@
+   cf_cv_typeof_chtype=long
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 8608 "configure"
++#line 9315 "configure"
+ #include "confdefs.h"
+ 
+ #ifdef USE_WIDEC_SUPPORT
+@@ -8652,15 +9359,15 @@
+ 
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:8655: \"$ac_link\"") >&5
++if { (eval echo "$as_me:9362: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:8658: \$? = $ac_status" >&5
++  echo "$as_me:9365: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:8660: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9367: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8663: \$? = $ac_status" >&5
++  echo "$as_me:9370: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_typeof_chtype=`cat cf_test.out`
+ else
+@@ -8675,7 +9382,7 @@
+ 
+ fi
+ 
+-echo "$as_me:8678: result: $cf_cv_typeof_chtype" >&5
++echo "$as_me:9385: result: $cf_cv_typeof_chtype" >&5
+ echo "${ECHO_T}$cf_cv_typeof_chtype" >&6
+ 
+ cat >>confdefs.h <<EOF
+@@ -8688,14 +9395,14 @@
+ 
+ ###	Checks for external-data
+ 
+-echo "$as_me:8691: checking if external errno is declared" >&5
++echo "$as_me:9398: checking if external errno is declared" >&5
+ echo $ECHO_N "checking if external errno is declared... $ECHO_C" >&6
+ if test "${cf_cv_dcl_errno+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+     cat >conftest.$ac_ext <<_ACEOF
+-#line 8698 "configure"
++#line 9405 "configure"
+ #include "confdefs.h"
+ 
+ #ifdef HAVE_STDLIB_H
+@@ -8713,16 +9420,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:8716: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:9423: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:8719: \$? = $ac_status" >&5
++  echo "$as_me:9426: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:8722: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9429: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8725: \$? = $ac_status" >&5
++  echo "$as_me:9432: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_dcl_errno=yes
+ else
+@@ -8733,7 +9440,7 @@
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ 
+ fi
+-echo "$as_me:8736: result: $cf_cv_dcl_errno" >&5
++echo "$as_me:9443: result: $cf_cv_dcl_errno" >&5
+ echo "${ECHO_T}$cf_cv_dcl_errno" >&6
+ 
+ if test "$cf_cv_dcl_errno" = no ; then
+@@ -8748,14 +9455,14 @@
+ 
+ # It's possible (for near-UNIX clones) that the data doesn't exist
+ 
+-echo "$as_me:8751: checking if external errno exists" >&5
++echo "$as_me:9458: checking if external errno exists" >&5
+ echo $ECHO_N "checking if external errno exists... $ECHO_C" >&6
+ if test "${cf_cv_have_errno+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+     cat >conftest.$ac_ext <<_ACEOF
+-#line 8758 "configure"
++#line 9465 "configure"
+ #include "confdefs.h"
+ 
+ #undef errno
+@@ -8770,16 +9477,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:8773: \"$ac_link\"") >&5
++if { (eval echo "$as_me:9480: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:8776: \$? = $ac_status" >&5
++  echo "$as_me:9483: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:8779: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9486: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8782: \$? = $ac_status" >&5
++  echo "$as_me:9489: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_have_errno=yes
+ else
+@@ -8790,7 +9497,7 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ 
+ fi
+-echo "$as_me:8793: result: $cf_cv_have_errno" >&5
++echo "$as_me:9500: result: $cf_cv_have_errno" >&5
+ echo "${ECHO_T}$cf_cv_have_errno" >&6
+ 
+ if test "$cf_cv_have_errno" = yes ; then
+@@ -8803,7 +9510,7 @@
+ 
+ fi
+ 
+-echo "$as_me:8806: checking if data-only library module links" >&5
++echo "$as_me:9513: checking if data-only library module links" >&5
+ echo $ECHO_N "checking if data-only library module links... $ECHO_C" >&6
+ if test "${cf_cv_link_dataonly+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -8811,20 +9518,20 @@
+ 
+ 	rm -f conftest.a
+ 	cat >conftest.$ac_ext <<EOF
+-#line 8814 "configure"
++#line 9521 "configure"
+ int	testdata[3] = { 123, 456, 789 };
+ EOF
+-	if { (eval echo "$as_me:8817: \"$ac_compile\"") >&5
++	if { (eval echo "$as_me:9524: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:8820: \$? = $ac_status" >&5
++  echo "$as_me:9527: \$? = $ac_status" >&5
+   (exit $ac_status); } ; then
+ 		mv conftest.o data.o && \
+ 		( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
+ 	fi
+ 	rm -f conftest.$ac_ext data.o
+ 	cat >conftest.$ac_ext <<EOF
+-#line 8827 "configure"
++#line 9534 "configure"
+ int	testfunc()
+ {
+ #if defined(NeXT)
+@@ -8837,10 +9544,10 @@
+ #endif
+ }
+ EOF
+-	if { (eval echo "$as_me:8840: \"$ac_compile\"") >&5
++	if { (eval echo "$as_me:9547: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:8843: \$? = $ac_status" >&5
++  echo "$as_me:9550: \$? = $ac_status" >&5
+   (exit $ac_status); }; then
+ 		mv conftest.o func.o && \
+ 		( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
+@@ -8853,7 +9560,7 @@
+   cf_cv_link_dataonly=unknown
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 8856 "configure"
++#line 9563 "configure"
+ #include "confdefs.h"
+ 
+ 	int main()
+@@ -8864,15 +9571,15 @@
+ 
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:8867: \"$ac_link\"") >&5
++if { (eval echo "$as_me:9574: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:8870: \$? = $ac_status" >&5
++  echo "$as_me:9577: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:8872: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9579: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8875: \$? = $ac_status" >&5
++  echo "$as_me:9582: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_link_dataonly=yes
+ else
+@@ -8887,7 +9594,7 @@
+ 
+ fi
+ 
+-echo "$as_me:8890: result: $cf_cv_link_dataonly" >&5
++echo "$as_me:9597: result: $cf_cv_link_dataonly" >&5
+ echo "${ECHO_T}$cf_cv_link_dataonly" >&6
+ 
+ if test "$cf_cv_link_dataonly" = no ; then
+@@ -8906,7 +9613,6 @@
+ geteuid \
+ getttynam \
+ issetugid \
+-memccpy \
+ nanosleep \
+ poll \
+ remove \
+@@ -8924,13 +9630,13 @@
+ 
+ do
+ as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+-echo "$as_me:8927: checking for $ac_func" >&5
++echo "$as_me:9633: checking for $ac_func" >&5
+ echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_var+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 8933 "configure"
++#line 9639 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char $ac_func (); below.  */
+@@ -8961,16 +9667,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:8964: \"$ac_link\"") >&5
++if { (eval echo "$as_me:9670: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:8967: \$? = $ac_status" >&5
++  echo "$as_me:9673: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:8970: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9676: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:8973: \$? = $ac_status" >&5
++  echo "$as_me:9679: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   eval "$as_ac_var=yes"
+ else
+@@ -8980,7 +9686,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:8983: result: `eval echo '${'$as_ac_var'}'`" >&5
++echo "$as_me:9689: result: `eval echo '${'$as_ac_var'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+ if test `eval echo '${'$as_ac_var'}'` = yes; then
+   cat >>confdefs.h <<EOF
+@@ -8992,14 +9698,14 @@
+ 
+ if test "$with_getcap" = "yes" ; then
+ 
+-echo "$as_me:8995: checking for terminal-capability database functions" >&5
++echo "$as_me:9701: checking for terminal-capability database functions" >&5
+ echo $ECHO_N "checking for terminal-capability database functions... $ECHO_C" >&6
+ if test "${cf_cv_cgetent+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 9002 "configure"
++#line 9708 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdlib.h>
+@@ -9019,16 +9725,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:9022: \"$ac_link\"") >&5
++if { (eval echo "$as_me:9728: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:9025: \$? = $ac_status" >&5
++  echo "$as_me:9731: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:9028: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9734: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9031: \$? = $ac_status" >&5
++  echo "$as_me:9737: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_cgetent=yes
+ else
+@@ -9040,7 +9746,7 @@
+ 
+ fi
+ 
+-echo "$as_me:9043: result: $cf_cv_cgetent" >&5
++echo "$as_me:9749: result: $cf_cv_cgetent" >&5
+ echo "${ECHO_T}$cf_cv_cgetent" >&6
+ test "$cf_cv_cgetent" = yes && cat >>confdefs.h <<\EOF
+ #define HAVE_BSD_CGETENT 1
+@@ -9048,14 +9754,14 @@
+ 
+ fi
+ 
+-echo "$as_me:9051: checking for isascii" >&5
++echo "$as_me:9757: checking for isascii" >&5
+ echo $ECHO_N "checking for isascii... $ECHO_C" >&6
+ if test "${cf_cv_have_isascii+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 9058 "configure"
++#line 9764 "configure"
+ #include "confdefs.h"
+ #include <ctype.h>
+ int
+@@ -9067,16 +9773,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:9070: \"$ac_link\"") >&5
++if { (eval echo "$as_me:9776: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:9073: \$? = $ac_status" >&5
++  echo "$as_me:9779: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:9076: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9782: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9079: \$? = $ac_status" >&5
++  echo "$as_me:9785: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_have_isascii=yes
+ else
+@@ -9087,17 +9793,17 @@
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ 
+ fi
+-echo "$as_me:9090: result: $cf_cv_have_isascii" >&5
++echo "$as_me:9796: result: $cf_cv_have_isascii" >&5
+ echo "${ECHO_T}$cf_cv_have_isascii" >&6
+ test "$cf_cv_have_isascii" = yes && cat >>confdefs.h <<\EOF
+ #define HAVE_ISASCII 1
+ EOF
+ 
+ if test "$ac_cv_func_sigaction" = yes; then
+-echo "$as_me:9097: checking whether sigaction needs _POSIX_SOURCE" >&5
++echo "$as_me:9803: checking whether sigaction needs _POSIX_SOURCE" >&5
+ echo $ECHO_N "checking whether sigaction needs _POSIX_SOURCE... $ECHO_C" >&6
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 9100 "configure"
++#line 9806 "configure"
+ #include "confdefs.h"
+ 
+ #include <sys/types.h>
+@@ -9111,16 +9817,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:9114: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:9820: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:9117: \$? = $ac_status" >&5
++  echo "$as_me:9823: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:9120: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9826: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9123: \$? = $ac_status" >&5
++  echo "$as_me:9829: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   sigact_bad=no
+ else
+@@ -9128,7 +9834,7 @@
+ cat conftest.$ac_ext >&5
+ 
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 9131 "configure"
++#line 9837 "configure"
+ #include "confdefs.h"
+ 
+ #define _POSIX_SOURCE
+@@ -9143,16 +9849,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:9146: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:9852: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:9149: \$? = $ac_status" >&5
++  echo "$as_me:9855: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:9152: \"$ac_try\"") >&5
++  { (eval echo "$as_me:9858: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9155: \$? = $ac_status" >&5
++  echo "$as_me:9861: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   sigact_bad=yes
+ 	 cat >>confdefs.h <<\EOF
+@@ -9167,7 +9873,7 @@
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+-echo "$as_me:9170: result: $sigact_bad" >&5
++echo "$as_me:9876: result: $sigact_bad" >&5
+ echo "${ECHO_T}$sigact_bad" >&6
+ fi
+ 
+@@ -9178,23 +9884,23 @@
+ 
+ do
+ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+-echo "$as_me:9181: checking for $ac_header" >&5
++echo "$as_me:9887: checking for $ac_header" >&5
+ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_Header+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 9187 "configure"
++#line 9893 "configure"
+ #include "confdefs.h"
+ #include <$ac_header>
+ _ACEOF
+-if { (eval echo "$as_me:9191: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:9897: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:9197: \$? = $ac_status" >&5
++  echo "$as_me:9903: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+@@ -9213,7 +9919,7 @@
+ fi
+ rm -f conftest.err conftest.$ac_ext
+ fi
+-echo "$as_me:9216: result: `eval echo '${'$as_ac_Header'}'`" >&5
++echo "$as_me:9922: result: `eval echo '${'$as_ac_Header'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ if test `eval echo '${'$as_ac_Header'}'` = yes; then
+   cat >>confdefs.h <<EOF
+@@ -9228,23 +9934,23 @@
+ for ac_header in sys/termio.h
+ do
+ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+-echo "$as_me:9231: checking for $ac_header" >&5
++echo "$as_me:9937: checking for $ac_header" >&5
+ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_Header+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 9237 "configure"
++#line 9943 "configure"
+ #include "confdefs.h"
+ #include <$ac_header>
+ _ACEOF
+-if { (eval echo "$as_me:9241: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:9947: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:9247: \$? = $ac_status" >&5
++  echo "$as_me:9953: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+@@ -9263,7 +9969,7 @@
+ fi
+ rm -f conftest.err conftest.$ac_ext
+ fi
+-echo "$as_me:9266: result: `eval echo '${'$as_ac_Header'}'`" >&5
++echo "$as_me:9972: result: `eval echo '${'$as_ac_Header'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ if test `eval echo '${'$as_ac_Header'}'` = yes; then
+   cat >>confdefs.h <<EOF
+@@ -9281,10 +9987,10 @@
+ 	*)	termios_bad=maybe ;;
+ 	esac
+ 	if test "$termios_bad" = maybe ; then
+-	echo "$as_me:9284: checking whether termios.h needs _POSIX_SOURCE" >&5
++	echo "$as_me:9990: checking whether termios.h needs _POSIX_SOURCE" >&5
+ echo $ECHO_N "checking whether termios.h needs _POSIX_SOURCE... $ECHO_C" >&6
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 9287 "configure"
++#line 9993 "configure"
+ #include "confdefs.h"
+ #include <termios.h>
+ int
+@@ -9296,16 +10002,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:9299: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:10005: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:9302: \$? = $ac_status" >&5
++  echo "$as_me:10008: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:9305: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10011: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9308: \$? = $ac_status" >&5
++  echo "$as_me:10014: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   termios_bad=no
+ else
+@@ -9313,7 +10019,7 @@
+ cat conftest.$ac_ext >&5
+ 
+ 		cat >conftest.$ac_ext <<_ACEOF
+-#line 9316 "configure"
++#line 10022 "configure"
+ #include "confdefs.h"
+ 
+ #define _POSIX_SOURCE
+@@ -9327,16 +10033,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:9330: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:10036: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:9333: \$? = $ac_status" >&5
++  echo "$as_me:10039: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:9336: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10042: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9339: \$? = $ac_status" >&5
++  echo "$as_me:10045: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   termios_bad=unknown
+ else
+@@ -9351,19 +10057,19 @@
+ 
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+-	echo "$as_me:9354: result: $termios_bad" >&5
++	echo "$as_me:10060: result: $termios_bad" >&5
+ echo "${ECHO_T}$termios_bad" >&6
+ 	fi
+ fi
+ 
+-echo "$as_me:9359: checking for tcgetattr" >&5
++echo "$as_me:10065: checking for tcgetattr" >&5
+ echo $ECHO_N "checking for tcgetattr... $ECHO_C" >&6
+ if test "${cf_cv_have_tcgetattr+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 9366 "configure"
++#line 10072 "configure"
+ #include "confdefs.h"
+ 
+ #include <sys/types.h>
+@@ -9391,16 +10097,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:9394: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10100: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:9397: \$? = $ac_status" >&5
++  echo "$as_me:10103: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:9400: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10106: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9403: \$? = $ac_status" >&5
++  echo "$as_me:10109: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_have_tcgetattr=yes
+ else
+@@ -9410,20 +10116,20 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:9413: result: $cf_cv_have_tcgetattr" >&5
++echo "$as_me:10119: result: $cf_cv_have_tcgetattr" >&5
+ echo "${ECHO_T}$cf_cv_have_tcgetattr" >&6
+ test "$cf_cv_have_tcgetattr" = yes && cat >>confdefs.h <<\EOF
+ #define HAVE_TCGETATTR 1
+ EOF
+ 
+-echo "$as_me:9419: checking for vsscanf function or workaround" >&5
++echo "$as_me:10125: checking for vsscanf function or workaround" >&5
+ echo $ECHO_N "checking for vsscanf function or workaround... $ECHO_C" >&6
+ if test "${cf_cv_func_vsscanf+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 9426 "configure"
++#line 10132 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdarg.h>
+@@ -9439,16 +10145,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:9442: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10148: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:9445: \$? = $ac_status" >&5
++  echo "$as_me:10151: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:9448: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10154: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9451: \$? = $ac_status" >&5
++  echo "$as_me:10157: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_func_vsscanf=vsscanf
+ else
+@@ -9456,7 +10162,7 @@
+ cat conftest.$ac_ext >&5
+ 
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 9459 "configure"
++#line 10165 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdarg.h>
+@@ -9478,16 +10184,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:9481: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10187: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:9484: \$? = $ac_status" >&5
++  echo "$as_me:10190: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:9487: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10193: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9490: \$? = $ac_status" >&5
++  echo "$as_me:10196: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_func_vsscanf=vfscanf
+ else
+@@ -9495,7 +10201,7 @@
+ cat conftest.$ac_ext >&5
+ 
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 9498 "configure"
++#line 10204 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdarg.h>
+@@ -9517,16 +10223,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:9520: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10226: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:9523: \$? = $ac_status" >&5
++  echo "$as_me:10229: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:9526: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10232: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9529: \$? = $ac_status" >&5
++  echo "$as_me:10235: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_func_vsscanf=_doscan
+ else
+@@ -9541,7 +10247,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:9544: result: $cf_cv_func_vsscanf" >&5
++echo "$as_me:10250: result: $cf_cv_func_vsscanf" >&5
+ echo "${ECHO_T}$cf_cv_func_vsscanf" >&6
+ 
+ case $cf_cv_func_vsscanf in #(vi
+@@ -9559,7 +10265,7 @@
+ ;;
+ esac
+ 
+-echo "$as_me:9562: checking for working mkstemp" >&5
++echo "$as_me:10268: checking for working mkstemp" >&5
+ echo $ECHO_N "checking for working mkstemp... $ECHO_C" >&6
+ if test "${cf_cv_func_mkstemp+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -9567,13 +10273,13 @@
+ 
+ rm -f conftest*
+ if test "$cross_compiling" = yes; then
+-  echo "$as_me:9570: checking for mkstemp" >&5
++  echo "$as_me:10276: checking for mkstemp" >&5
+ echo $ECHO_N "checking for mkstemp... $ECHO_C" >&6
+ if test "${ac_cv_func_mkstemp+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 9576 "configure"
++#line 10282 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char mkstemp (); below.  */
+@@ -9604,16 +10310,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:9607: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10313: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:9610: \$? = $ac_status" >&5
++  echo "$as_me:10316: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:9613: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10319: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9616: \$? = $ac_status" >&5
++  echo "$as_me:10322: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_func_mkstemp=yes
+ else
+@@ -9623,12 +10329,12 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:9626: result: $ac_cv_func_mkstemp" >&5
++echo "$as_me:10332: result: $ac_cv_func_mkstemp" >&5
+ echo "${ECHO_T}$ac_cv_func_mkstemp" >&6
+ 
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 9631 "configure"
++#line 10337 "configure"
+ #include "confdefs.h"
+ 
+ #include <sys/types.h>
+@@ -9666,15 +10372,15 @@
+ 
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:9669: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10375: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:9672: \$? = $ac_status" >&5
++  echo "$as_me:10378: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:9674: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10380: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9677: \$? = $ac_status" >&5
++  echo "$as_me:10383: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_func_mkstemp=yes
+ 
+@@ -9689,7 +10395,7 @@
+ fi
+ 
+ fi
+-echo "$as_me:9692: result: $cf_cv_func_mkstemp" >&5
++echo "$as_me:10398: result: $cf_cv_func_mkstemp" >&5
+ echo "${ECHO_T}$cf_cv_func_mkstemp" >&6
+ if test "$cf_cv_func_mkstemp" = yes ; then
+ 	cat >>confdefs.h <<\EOF
+@@ -9706,21 +10412,21 @@
+ fi
+ 
+ if test "$cross_compiling" = yes ; then
+-	{ echo "$as_me:9709: WARNING: cross compiling: assume setvbuf params not reversed" >&5
++	{ echo "$as_me:10415: WARNING: cross compiling: assume setvbuf params not reversed" >&5
+ echo "$as_me: WARNING: cross compiling: assume setvbuf params not reversed" >&2;}
+ else
+-	echo "$as_me:9712: checking whether setvbuf arguments are reversed" >&5
++	echo "$as_me:10418: checking whether setvbuf arguments are reversed" >&5
+ echo $ECHO_N "checking whether setvbuf arguments are reversed... $ECHO_C" >&6
+ if test "${ac_cv_func_setvbuf_reversed+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   if test "$cross_compiling" = yes; then
+-  { { echo "$as_me:9718: error: cannot run test program while cross compiling" >&5
++  { { echo "$as_me:10424: error: cannot run test program while cross compiling" >&5
+ echo "$as_me: error: cannot run test program while cross compiling" >&2;}
+    { (exit 1); exit 1; }; }
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 9723 "configure"
++#line 10429 "configure"
+ #include "confdefs.h"
+ #include <stdio.h>
+ /* If setvbuf has the reversed format, exit 0. */
+@@ -9737,15 +10443,15 @@
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:9740: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10446: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:9743: \$? = $ac_status" >&5
++  echo "$as_me:10449: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:9745: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10451: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9748: \$? = $ac_status" >&5
++  echo "$as_me:10454: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_func_setvbuf_reversed=yes
+ else
+@@ -9758,7 +10464,7 @@
+ fi
+ rm -f core core.* *.core
+ fi
+-echo "$as_me:9761: result: $ac_cv_func_setvbuf_reversed" >&5
++echo "$as_me:10467: result: $ac_cv_func_setvbuf_reversed" >&5
+ echo "${ECHO_T}$ac_cv_func_setvbuf_reversed" >&6
+ if test $ac_cv_func_setvbuf_reversed = yes; then
+ 
+@@ -9769,13 +10475,13 @@
+ fi
+ 
+ fi
+-echo "$as_me:9772: checking return type of signal handlers" >&5
++echo "$as_me:10478: checking return type of signal handlers" >&5
+ echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6
+ if test "${ac_cv_type_signal+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 9778 "configure"
++#line 10484 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #include <signal.h>
+@@ -9797,16 +10503,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:9800: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:10506: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:9803: \$? = $ac_status" >&5
++  echo "$as_me:10509: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:9806: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10512: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9809: \$? = $ac_status" >&5
++  echo "$as_me:10515: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_type_signal=void
+ else
+@@ -9816,21 +10522,21 @@
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+-echo "$as_me:9819: result: $ac_cv_type_signal" >&5
++echo "$as_me:10525: result: $ac_cv_type_signal" >&5
+ echo "${ECHO_T}$ac_cv_type_signal" >&6
+ 
+ cat >>confdefs.h <<EOF
+ #define RETSIGTYPE $ac_cv_type_signal
+ EOF
+ 
+-echo "$as_me:9826: checking for type sigaction_t" >&5
++echo "$as_me:10532: checking for type sigaction_t" >&5
+ echo $ECHO_N "checking for type sigaction_t... $ECHO_C" >&6
+ if test "${cf_cv_type_sigaction+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ 
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 9833 "configure"
++#line 10539 "configure"
+ #include "confdefs.h"
+ 
+ #include <signal.h>
+@@ -9843,16 +10549,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:9846: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:10552: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:9849: \$? = $ac_status" >&5
++  echo "$as_me:10555: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:9852: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10558: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9855: \$? = $ac_status" >&5
++  echo "$as_me:10561: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_type_sigaction=yes
+ else
+@@ -9863,13 +10569,13 @@
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+ 
+-echo "$as_me:9866: result: $cf_cv_type_sigaction" >&5
++echo "$as_me:10572: result: $cf_cv_type_sigaction" >&5
+ echo "${ECHO_T}$cf_cv_type_sigaction" >&6
+ test "$cf_cv_type_sigaction" = yes && cat >>confdefs.h <<\EOF
+ #define HAVE_TYPE_SIGACTION 1
+ EOF
+ 
+-echo "$as_me:9872: checking declaration of size-change" >&5
++echo "$as_me:10578: checking declaration of size-change" >&5
+ echo $ECHO_N "checking declaration of size-change... $ECHO_C" >&6
+ if test "${cf_cv_sizechange+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -9884,7 +10590,7 @@
+     CPPFLAGS="$cf_save_CPPFLAGS"
+     test -n "$cf_opts" && CPPFLAGS="$CPPFLAGS -D$cf_opts"
+     cat >conftest.$ac_ext <<_ACEOF
+-#line 9887 "configure"
++#line 10593 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #ifdef HAVE_TERMIOS_H
+@@ -9928,16 +10634,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:9931: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:10637: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:9934: \$? = $ac_status" >&5
++  echo "$as_me:10640: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:9937: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10643: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:9940: \$? = $ac_status" >&5
++  echo "$as_me:10646: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_sizechange=yes
+ else
+@@ -9956,7 +10662,7 @@
+ done
+ 
+ fi
+-echo "$as_me:9959: result: $cf_cv_sizechange" >&5
++echo "$as_me:10665: result: $cf_cv_sizechange" >&5
+ echo "${ECHO_T}$cf_cv_sizechange" >&6
+ if test "$cf_cv_sizechange" != no ; then
+ 	cat >>confdefs.h <<\EOF
+@@ -9973,13 +10679,13 @@
+ 	esac
+ fi
+ 
+-echo "$as_me:9976: checking for memmove" >&5
++echo "$as_me:10682: checking for memmove" >&5
+ echo $ECHO_N "checking for memmove... $ECHO_C" >&6
+ if test "${ac_cv_func_memmove+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 9982 "configure"
++#line 10688 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char memmove (); below.  */
+@@ -10010,16 +10716,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:10013: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10719: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:10016: \$? = $ac_status" >&5
++  echo "$as_me:10722: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:10019: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10725: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10022: \$? = $ac_status" >&5
++  echo "$as_me:10728: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_func_memmove=yes
+ else
+@@ -10029,19 +10735,19 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:10032: result: $ac_cv_func_memmove" >&5
++echo "$as_me:10738: result: $ac_cv_func_memmove" >&5
+ echo "${ECHO_T}$ac_cv_func_memmove" >&6
+ if test $ac_cv_func_memmove = yes; then
+   :
+ else
+ 
+-echo "$as_me:10038: checking for bcopy" >&5
++echo "$as_me:10744: checking for bcopy" >&5
+ echo $ECHO_N "checking for bcopy... $ECHO_C" >&6
+ if test "${ac_cv_func_bcopy+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 10044 "configure"
++#line 10750 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char bcopy (); below.  */
+@@ -10072,16 +10778,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:10075: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10781: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:10078: \$? = $ac_status" >&5
++  echo "$as_me:10784: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:10081: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10787: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10084: \$? = $ac_status" >&5
++  echo "$as_me:10790: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_cv_func_bcopy=yes
+ else
+@@ -10091,11 +10797,11 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ fi
+-echo "$as_me:10094: result: $ac_cv_func_bcopy" >&5
++echo "$as_me:10800: result: $ac_cv_func_bcopy" >&5
+ echo "${ECHO_T}$ac_cv_func_bcopy" >&6
+ if test $ac_cv_func_bcopy = yes; then
+ 
+-	echo "$as_me:10098: checking if bcopy does overlapping moves" >&5
++	echo "$as_me:10804: checking if bcopy does overlapping moves" >&5
+ echo $ECHO_N "checking if bcopy does overlapping moves... $ECHO_C" >&6
+ if test "${cf_cv_good_bcopy+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -10105,7 +10811,7 @@
+   cf_cv_good_bcopy=unknown
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 10108 "configure"
++#line 10814 "configure"
+ #include "confdefs.h"
+ 
+ int main() {
+@@ -10119,15 +10825,15 @@
+ 
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:10122: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10828: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:10125: \$? = $ac_status" >&5
++  echo "$as_me:10831: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:10127: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10833: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10130: \$? = $ac_status" >&5
++  echo "$as_me:10836: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_good_bcopy=yes
+ else
+@@ -10140,7 +10846,7 @@
+ fi
+ 
+ fi
+-echo "$as_me:10143: result: $cf_cv_good_bcopy" >&5
++echo "$as_me:10849: result: $cf_cv_good_bcopy" >&5
+ echo "${ECHO_T}$cf_cv_good_bcopy" >&6
+ 
+ else
+@@ -10161,7 +10867,7 @@
+ 
+ fi
+ 
+-echo "$as_me:10164: checking if poll really works" >&5
++echo "$as_me:10870: checking if poll really works" >&5
+ echo $ECHO_N "checking if poll really works... $ECHO_C" >&6
+ if test "${cf_cv_working_poll+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -10171,7 +10877,7 @@
+   cf_cv_working_poll=unknown
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 10174 "configure"
++#line 10880 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdio.h>
+@@ -10192,15 +10898,15 @@
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:10195: \"$ac_link\"") >&5
++if { (eval echo "$as_me:10901: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:10198: \$? = $ac_status" >&5
++  echo "$as_me:10904: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:10200: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10906: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10203: \$? = $ac_status" >&5
++  echo "$as_me:10909: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_working_poll=yes
+ else
+@@ -10212,7 +10918,7 @@
+ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+ fi
+ fi
+-echo "$as_me:10215: result: $cf_cv_working_poll" >&5
++echo "$as_me:10921: result: $cf_cv_working_poll" >&5
+ echo "${ECHO_T}$cf_cv_working_poll" >&6
+ test "$cf_cv_working_poll" = "yes" && cat >>confdefs.h <<\EOF
+ #define HAVE_WORKING_POLL 1
+@@ -10225,7 +10931,7 @@
+ 
+ # Just in case, check if the C compiler has a bool type.
+ 
+-echo "$as_me:10228: checking if we should include stdbool.h" >&5
++echo "$as_me:10934: checking if we should include stdbool.h" >&5
+ echo $ECHO_N "checking if we should include stdbool.h... $ECHO_C" >&6
+ 
+ if test "${cf_cv_header_stdbool_h+set}" = set; then
+@@ -10233,7 +10939,7 @@
+ else
+ 
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 10236 "configure"
++#line 10942 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -10245,23 +10951,23 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:10248: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:10954: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:10251: \$? = $ac_status" >&5
++  echo "$as_me:10957: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:10254: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10960: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10257: \$? = $ac_status" >&5
++  echo "$as_me:10963: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_header_stdbool_h=0
+ else
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 10264 "configure"
++#line 10970 "configure"
+ #include "confdefs.h"
+ 
+ #ifndef __BEOS__
+@@ -10277,16 +10983,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:10280: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:10986: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:10283: \$? = $ac_status" >&5
++  echo "$as_me:10989: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:10286: \"$ac_try\"") >&5
++  { (eval echo "$as_me:10992: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10289: \$? = $ac_status" >&5
++  echo "$as_me:10995: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_header_stdbool_h=1
+ else
+@@ -10300,13 +11006,13 @@
+ fi
+ 
+ if test "$cf_cv_header_stdbool_h" = 1
+-then	echo "$as_me:10303: result: yes" >&5
++then	echo "$as_me:11009: result: yes" >&5
+ echo "${ECHO_T}yes" >&6
+-else	echo "$as_me:10305: result: no" >&5
++else	echo "$as_me:11011: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+-echo "$as_me:10309: checking for builtin bool type" >&5
++echo "$as_me:11015: checking for builtin bool type" >&5
+ echo $ECHO_N "checking for builtin bool type... $ECHO_C" >&6
+ 
+ if test "${cf_cv_cc_bool_type+set}" = set; then
+@@ -10314,7 +11020,7 @@
+ else
+ 
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 10317 "configure"
++#line 11023 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdio.h>
+@@ -10329,16 +11035,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:10332: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:11038: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:10335: \$? = $ac_status" >&5
++  echo "$as_me:11041: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:10338: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11044: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10341: \$? = $ac_status" >&5
++  echo "$as_me:11047: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_cc_bool_type=1
+ else
+@@ -10351,9 +11057,9 @@
+ fi
+ 
+ if test "$cf_cv_cc_bool_type" = 1
+-then	echo "$as_me:10354: result: yes" >&5
++then	echo "$as_me:11060: result: yes" >&5
+ echo "${ECHO_T}yes" >&6
+-else	echo "$as_me:10356: result: no" >&5
++else	echo "$as_me:11062: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -10374,7 +11080,7 @@
+ 	cf_stdcpp_libname=stdc++
+ 	;;
+ esac
+-echo "$as_me:10377: checking for library $cf_stdcpp_libname" >&5
++echo "$as_me:11083: checking for library $cf_stdcpp_libname" >&5
+ echo $ECHO_N "checking for library $cf_stdcpp_libname... $ECHO_C" >&6
+ if test "${cf_cv_libstdcpp+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -10383,7 +11089,7 @@
+ 	cf_save="$LIBS"
+ 	LIBS="$LIBS -l$cf_stdcpp_libname"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 10386 "configure"
++#line 11092 "configure"
+ #include "confdefs.h"
+ 
+ #include <strstream.h>
+@@ -10399,16 +11105,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:10402: \"$ac_link\"") >&5
++if { (eval echo "$as_me:11108: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:10405: \$? = $ac_status" >&5
++  echo "$as_me:11111: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:10408: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11114: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10411: \$? = $ac_status" >&5
++  echo "$as_me:11117: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_libstdcpp=yes
+ else
+@@ -10420,11 +11126,53 @@
+ 	LIBS="$cf_save"
+ 
+ fi
+-echo "$as_me:10423: result: $cf_cv_libstdcpp" >&5
++echo "$as_me:11129: result: $cf_cv_libstdcpp" >&5
+ echo "${ECHO_T}$cf_cv_libstdcpp" >&6
+ test "$cf_cv_libstdcpp" = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
+ fi
+ 
++	echo "$as_me:11134: checking whether $CXX understands -c and -o together" >&5
++echo $ECHO_N "checking whether $CXX understands -c and -o together... $ECHO_C" >&6
++if test "${cf_cv_prog_CXX_c_o+set}" = set; then
++  echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++
++cat > conftest.$ac_ext <<CF_EOF
++#include <stdio.h>
++int main()
++{
++	return 0;
++}
++CF_EOF
++# We do the test twice because some compilers refuse to overwrite an
++# existing .o file with -o, though they will create one.
++ac_try='$CXX -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
++if { (eval echo "$as_me:11150: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:11153: \$? = $ac_status" >&5
++  (exit $ac_status); } &&
++  test -f conftest2.$ac_objext && { (eval echo "$as_me:11155: \"$ac_try\"") >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  echo "$as_me:11158: \$? = $ac_status" >&5
++  (exit $ac_status); };
++then
++  eval cf_cv_prog_CXX_c_o=yes
++else
++  eval cf_cv_prog_CXX_c_o=no
++fi
++rm -f conftest*
++
++fi
++if test $cf_cv_prog_CXX_c_o = yes; then
++  echo "$as_me:11169: result: yes" >&5
++echo "${ECHO_T}yes" >&6
++else
++  echo "$as_me:11172: result: no" >&5
++echo "${ECHO_T}no" >&6
++fi
++
+ 	case $GXX_VERSION in
+ 	1*|2.0-6*)
+ 		cf_cxx_library=yes
+@@ -10441,12 +11189,12 @@
+ 	;;
+ esac
+ if test "$GXX" = yes; then
+-	echo "$as_me:10444: checking for lib$cf_gpp_libname" >&5
++	echo "$as_me:11192: checking for lib$cf_gpp_libname" >&5
+ echo $ECHO_N "checking for lib$cf_gpp_libname... $ECHO_C" >&6
+ 	cf_save="$LIBS"
+ 	LIBS="$LIBS -l$cf_gpp_libname"
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 10449 "configure"
++#line 11197 "configure"
+ #include "confdefs.h"
+ 
+ #include <$cf_gpp_libname/builtin.h>
+@@ -10460,16 +11208,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:10463: \"$ac_link\"") >&5
++if { (eval echo "$as_me:11211: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:10466: \$? = $ac_status" >&5
++  echo "$as_me:11214: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:10469: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11217: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10472: \$? = $ac_status" >&5
++  echo "$as_me:11220: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cxx_library=yes
+ 	 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
+@@ -10488,7 +11236,7 @@
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 10491 "configure"
++#line 11239 "configure"
+ #include "confdefs.h"
+ 
+ #include <builtin.h>
+@@ -10502,16 +11250,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:10505: \"$ac_link\"") >&5
++if { (eval echo "$as_me:11253: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:10508: \$? = $ac_status" >&5
++  echo "$as_me:11256: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:10511: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11259: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10514: \$? = $ac_status" >&5
++  echo "$as_me:11262: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cxx_library=yes
+ 	 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
+@@ -10528,7 +11276,7 @@
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ 	LIBS="$cf_save"
+-	echo "$as_me:10531: result: $cf_cxx_library" >&5
++	echo "$as_me:11279: result: $cf_cxx_library" >&5
+ echo "${ECHO_T}$cf_cxx_library" >&6
+ fi
+ 
+@@ -10543,7 +11291,7 @@
+ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+-echo "$as_me:10546: checking how to run the C++ preprocessor" >&5
++echo "$as_me:11294: checking how to run the C++ preprocessor" >&5
+ echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
+ if test -z "$CXXCPP"; then
+   if test "${ac_cv_prog_CXXCPP+set}" = set; then
+@@ -10560,18 +11308,18 @@
+   # On the NeXT, cc -E runs the code through the compiler's parser,
+   # not just through cpp. "Syntax error" is here to catch this case.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 10563 "configure"
++#line 11311 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+                      Syntax error
+ _ACEOF
+-if { (eval echo "$as_me:10568: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:11316: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:10574: \$? = $ac_status" >&5
++  echo "$as_me:11322: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_cxx_preproc_warn_flag
+@@ -10594,17 +11342,17 @@
+   # OK, works on sane cases.  Now check whether non-existent headers
+   # can be detected and how.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 10597 "configure"
++#line 11345 "configure"
+ #include "confdefs.h"
+ #include <ac_nonexistent.h>
+ _ACEOF
+-if { (eval echo "$as_me:10601: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:11349: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:10607: \$? = $ac_status" >&5
++  echo "$as_me:11355: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_cxx_preproc_warn_flag
+@@ -10641,7 +11389,7 @@
+ else
+   ac_cv_prog_CXXCPP=$CXXCPP
+ fi
+-echo "$as_me:10644: result: $CXXCPP" >&5
++echo "$as_me:11392: result: $CXXCPP" >&5
+ echo "${ECHO_T}$CXXCPP" >&6
+ ac_preproc_ok=false
+ for ac_cxx_preproc_warn_flag in '' yes
+@@ -10651,18 +11399,18 @@
+   # On the NeXT, cc -E runs the code through the compiler's parser,
+   # not just through cpp. "Syntax error" is here to catch this case.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 10654 "configure"
++#line 11402 "configure"
+ #include "confdefs.h"
+ #include <assert.h>
+                      Syntax error
+ _ACEOF
+-if { (eval echo "$as_me:10659: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:11407: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:10665: \$? = $ac_status" >&5
++  echo "$as_me:11413: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_cxx_preproc_warn_flag
+@@ -10685,17 +11433,17 @@
+   # OK, works on sane cases.  Now check whether non-existent headers
+   # can be detected and how.
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 10688 "configure"
++#line 11436 "configure"
+ #include "confdefs.h"
+ #include <ac_nonexistent.h>
+ _ACEOF
+-if { (eval echo "$as_me:10692: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:11440: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:10698: \$? = $ac_status" >&5
++  echo "$as_me:11446: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_cxx_preproc_warn_flag
+@@ -10723,7 +11471,7 @@
+ if $ac_preproc_ok; then
+   :
+ else
+-  { { echo "$as_me:10726: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&5
++  { { echo "$as_me:11474: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&5
+ echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+@@ -10737,23 +11485,23 @@
+ for ac_header in typeinfo
+ do
+ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+-echo "$as_me:10740: checking for $ac_header" >&5
++echo "$as_me:11488: checking for $ac_header" >&5
+ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_Header+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 10746 "configure"
++#line 11494 "configure"
+ #include "confdefs.h"
+ #include <$ac_header>
+ _ACEOF
+-if { (eval echo "$as_me:10750: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:11498: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:10756: \$? = $ac_status" >&5
++  echo "$as_me:11504: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_cxx_preproc_warn_flag
+@@ -10772,7 +11520,7 @@
+ fi
+ rm -f conftest.err conftest.$ac_ext
+ fi
+-echo "$as_me:10775: result: `eval echo '${'$as_ac_Header'}'`" >&5
++echo "$as_me:11523: result: `eval echo '${'$as_ac_Header'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ if test `eval echo '${'$as_ac_Header'}'` = yes; then
+   cat >>confdefs.h <<EOF
+@@ -10782,7 +11530,7 @@
+ fi
+ done
+ 
+-echo "$as_me:10785: checking if we should include stdbool.h" >&5
++echo "$as_me:11533: checking if we should include stdbool.h" >&5
+ echo $ECHO_N "checking if we should include stdbool.h... $ECHO_C" >&6
+ 
+ if test "${cf_cv_header_stdbool_h+set}" = set; then
+@@ -10790,7 +11538,7 @@
+ else
+ 
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 10793 "configure"
++#line 11541 "configure"
+ #include "confdefs.h"
+ 
+ int
+@@ -10802,23 +11550,23 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:10805: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:11553: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:10808: \$? = $ac_status" >&5
++  echo "$as_me:11556: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:10811: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11559: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10814: \$? = $ac_status" >&5
++  echo "$as_me:11562: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_header_stdbool_h=0
+ else
+   echo "$as_me: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 10821 "configure"
++#line 11569 "configure"
+ #include "confdefs.h"
+ 
+ #ifndef __BEOS__
+@@ -10834,16 +11582,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:10837: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:11585: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:10840: \$? = $ac_status" >&5
++  echo "$as_me:11588: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:10843: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11591: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10846: \$? = $ac_status" >&5
++  echo "$as_me:11594: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_header_stdbool_h=1
+ else
+@@ -10857,13 +11605,13 @@
+ fi
+ 
+ if test "$cf_cv_header_stdbool_h" = 1
+-then	echo "$as_me:10860: result: yes" >&5
++then	echo "$as_me:11608: result: yes" >&5
+ echo "${ECHO_T}yes" >&6
+-else	echo "$as_me:10862: result: no" >&5
++else	echo "$as_me:11610: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+-echo "$as_me:10866: checking for builtin bool type" >&5
++echo "$as_me:11614: checking for builtin bool type" >&5
+ echo $ECHO_N "checking for builtin bool type... $ECHO_C" >&6
+ 
+ if test "${cf_cv_builtin_bool+set}" = set; then
+@@ -10871,7 +11619,7 @@
+ else
+ 
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 10874 "configure"
++#line 11622 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdio.h>
+@@ -10886,16 +11634,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:10889: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:11637: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:10892: \$? = $ac_status" >&5
++  echo "$as_me:11640: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:10895: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11643: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10898: \$? = $ac_status" >&5
++  echo "$as_me:11646: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_builtin_bool=1
+ else
+@@ -10908,13 +11656,13 @@
+ fi
+ 
+ if test "$cf_cv_builtin_bool" = 1
+-then	echo "$as_me:10911: result: yes" >&5
++then	echo "$as_me:11659: result: yes" >&5
+ echo "${ECHO_T}yes" >&6
+-else	echo "$as_me:10913: result: no" >&5
++else	echo "$as_me:11661: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+-echo "$as_me:10917: checking for size of bool" >&5
++echo "$as_me:11665: checking for size of bool" >&5
+ echo $ECHO_N "checking for size of bool... $ECHO_C" >&6
+ if test "${cf_cv_type_of_bool+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -10925,7 +11673,7 @@
+   cf_cv_type_of_bool=unknown
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 10928 "configure"
++#line 11676 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdlib.h>
+@@ -10967,15 +11715,15 @@
+ 
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:10970: \"$ac_link\"") >&5
++if { (eval echo "$as_me:11718: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:10973: \$? = $ac_status" >&5
++  echo "$as_me:11721: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:10975: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11723: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:10978: \$? = $ac_status" >&5
++  echo "$as_me:11726: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_type_of_bool=`cat cf_test.out`
+ 		 if test -z "$cf_cv_type_of_bool"; then
+@@ -10993,18 +11741,18 @@
+ fi
+ 
+ 	rm -f cf_test.out
+-echo "$as_me:10996: result: $cf_cv_type_of_bool" >&5
++echo "$as_me:11744: result: $cf_cv_type_of_bool" >&5
+ echo "${ECHO_T}$cf_cv_type_of_bool" >&6
+ if test "$cf_cv_type_of_bool" = unknown ; then
+ 	case .$NCURSES_BOOL in #(vi
+ 	.auto|.) NCURSES_BOOL=unsigned;;
+ 	esac
+-	{ echo "$as_me:11002: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
++	{ echo "$as_me:11750: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
+ echo "$as_me: WARNING: Assuming $NCURSES_BOOL for type of bool" >&2;}
+ 	cf_cv_type_of_bool=$NCURSES_BOOL
+ fi
+ 
+-echo "$as_me:11007: checking for special defines needed for etip.h" >&5
++echo "$as_me:11755: checking for special defines needed for etip.h" >&5
+ echo $ECHO_N "checking for special defines needed for etip.h... $ECHO_C" >&6
+ cf_save_CXXFLAGS="$CXXFLAGS"
+ cf_result="none"
+@@ -11016,7 +11764,7 @@
+ 	test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
+ 	test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
+ cat >conftest.$ac_ext <<_ACEOF
+-#line 11019 "configure"
++#line 11767 "configure"
+ #include "confdefs.h"
+ 
+ #include <etip.h.in>
+@@ -11030,16 +11778,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+-if { (eval echo "$as_me:11033: \"$ac_compile\"") >&5
++if { (eval echo "$as_me:11781: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>&5
+   ac_status=$?
+-  echo "$as_me:11036: \$? = $ac_status" >&5
++  echo "$as_me:11784: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest.$ac_objext'
+-  { (eval echo "$as_me:11039: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11787: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:11042: \$? = $ac_status" >&5
++  echo "$as_me:11790: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+ 
+ 	test -n "$cf_math" && cat >>confdefs.h <<EOF
+@@ -11060,12 +11808,12 @@
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ done
+ done
+-echo "$as_me:11063: result: $cf_result" >&5
++echo "$as_me:11811: result: $cf_result" >&5
+ echo "${ECHO_T}$cf_result" >&6
+ CXXFLAGS="$cf_save_CXXFLAGS"
+ 
+ if test -n "$CXX"; then
+-echo "$as_me:11068: checking if $CXX accepts parameter initialization" >&5
++echo "$as_me:11816: checking if $CXX accepts parameter initialization" >&5
+ echo $ECHO_N "checking if $CXX accepts parameter initialization... $ECHO_C" >&6
+ if test "${cf_cv_cpp_param_init+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -11081,7 +11829,7 @@
+   cf_cv_cpp_param_init=unknown
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 11084 "configure"
++#line 11832 "configure"
+ #include "confdefs.h"
+ 
+ class TEST {
+@@ -11100,15 +11848,15 @@
+ 
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:11103: \"$ac_link\"") >&5
++if { (eval echo "$as_me:11851: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:11106: \$? = $ac_status" >&5
++  echo "$as_me:11854: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:11108: \"$ac_try\"") >&5
++  { (eval echo "$as_me:11856: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:11111: \$? = $ac_status" >&5
++  echo "$as_me:11859: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_cpp_param_init=yes
+ else
+@@ -11126,7 +11874,7 @@
+ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+ 
+ fi
+-echo "$as_me:11129: result: $cf_cv_cpp_param_init" >&5
++echo "$as_me:11877: result: $cf_cv_cpp_param_init" >&5
+ echo "${ECHO_T}$cf_cv_cpp_param_init" >&6
+ fi
+ test "$cf_cv_cpp_param_init" = yes && cat >>confdefs.h <<\EOF
+@@ -11144,23 +11892,23 @@
+ for ac_header in strstream.h
+ do
+ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+-echo "$as_me:11147: checking for $ac_header" >&5
++echo "$as_me:11895: checking for $ac_header" >&5
+ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_Header+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 11153 "configure"
++#line 11901 "configure"
+ #include "confdefs.h"
+ #include <$ac_header>
+ _ACEOF
+-if { (eval echo "$as_me:11157: \"$ac_cpp conftest.$ac_ext\"") >&5
++if { (eval echo "$as_me:11905: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   egrep -v '^ *\+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+-  echo "$as_me:11163: \$? = $ac_status" >&5
++  echo "$as_me:11911: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_cxx_preproc_warn_flag
+@@ -11179,7 +11927,7 @@
+ fi
+ rm -f conftest.err conftest.$ac_ext
+ fi
+-echo "$as_me:11182: result: `eval echo '${'$as_ac_Header'}'`" >&5
++echo "$as_me:11930: result: `eval echo '${'$as_ac_Header'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ if test `eval echo '${'$as_ac_Header'}'` = yes; then
+   cat >>confdefs.h <<EOF
+@@ -11189,7 +11937,7 @@
+ fi
+ done
+ 
+-echo "$as_me:11192: checking if $CXX supports vscan function" >&5
++echo "$as_me:11940: checking if $CXX supports vscan function" >&5
+ echo $ECHO_N "checking if $CXX supports vscan function... $ECHO_C" >&6
+ if test "${cf_cv_cpp_vscan_func+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -11203,7 +11951,7 @@
+ 	strstream_cast)	cf_vscan_defs=USE_STRSTREAM_VSCAN_CAST ;;
+ 	esac
+ 	cat >conftest.$ac_ext <<_ACEOF
+-#line 11206 "configure"
++#line 11954 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdio.h>
+@@ -11248,16 +11996,16 @@
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+-if { (eval echo "$as_me:11251: \"$ac_link\"") >&5
++if { (eval echo "$as_me:11999: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:11254: \$? = $ac_status" >&5
++  echo "$as_me:12002: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+          { ac_try='test -s conftest$ac_exeext'
+-  { (eval echo "$as_me:11257: \"$ac_try\"") >&5
++  { (eval echo "$as_me:12005: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:11260: \$? = $ac_status" >&5
++  echo "$as_me:12008: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_cpp_vscan_func=$cf_vscan_func; break
+ else
+@@ -11270,7 +12018,7 @@
+ 	done
+ 
+ fi
+-echo "$as_me:11273: result: $cf_cv_cpp_vscan_func" >&5
++echo "$as_me:12021: result: $cf_cv_cpp_vscan_func" >&5
+ echo "${ECHO_T}$cf_cv_cpp_vscan_func" >&6
+ 
+ ac_ext=cc
+@@ -11352,7 +12100,7 @@
+ 	else
+ 		if test "$cf_cv_header_stdbool_h" = 1 ; then
+ 
+-echo "$as_me:11355: checking for size of bool" >&5
++echo "$as_me:12103: checking for size of bool" >&5
+ echo $ECHO_N "checking for size of bool... $ECHO_C" >&6
+ if test "${cf_cv_type_of_bool+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -11363,7 +12111,7 @@
+   cf_cv_type_of_bool=unknown
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+-#line 11366 "configure"
++#line 12114 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdlib.h>
+@@ -11405,15 +12153,15 @@
+ 
+ _ACEOF
+ rm -f conftest$ac_exeext
+-if { (eval echo "$as_me:11408: \"$ac_link\"") >&5
++if { (eval echo "$as_me:12156: \"$ac_link\"") >&5
+   (eval $ac_link) 2>&5
+   ac_status=$?
+-  echo "$as_me:11411: \$? = $ac_status" >&5
++  echo "$as_me:12159: \$? = $ac_status" >&5
+   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+-  { (eval echo "$as_me:11413: \"$ac_try\"") >&5
++  { (eval echo "$as_me:12161: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+-  echo "$as_me:11416: \$? = $ac_status" >&5
++  echo "$as_me:12164: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   cf_cv_type_of_bool=`cat cf_test.out`
+ 		 if test -z "$cf_cv_type_of_bool"; then
+@@ -11431,25 +12179,25 @@
+ fi
+ 
+ 	rm -f cf_test.out
+-echo "$as_me:11434: result: $cf_cv_type_of_bool" >&5
++echo "$as_me:12182: result: $cf_cv_type_of_bool" >&5
+ echo "${ECHO_T}$cf_cv_type_of_bool" >&6
+ if test "$cf_cv_type_of_bool" = unknown ; then
+ 	case .$NCURSES_BOOL in #(vi
+ 	.auto|.) NCURSES_BOOL=unsigned;;
+ 	esac
+-	{ echo "$as_me:11440: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
++	{ echo "$as_me:12188: WARNING: Assuming $NCURSES_BOOL for type of bool" >&5
+ echo "$as_me: WARNING: Assuming $NCURSES_BOOL for type of bool" >&2;}
+ 	cf_cv_type_of_bool=$NCURSES_BOOL
+ fi
+ 
+ 		else
+-			echo "$as_me:11446: checking for fallback type of bool" >&5
++			echo "$as_me:12194: checking for fallback type of bool" >&5
+ echo $ECHO_N "checking for fallback type of bool... $ECHO_C" >&6
+ 			case "$host_cpu" in #(vi
+ 			i?86)	cf_cv_type_of_bool=char	;; #(vi
+ 			*)	cf_cv_type_of_bool=int	;;
+ 			esac
+-			echo "$as_me:11452: result: $cf_cv_type_of_bool" >&5
++			echo "$as_me:12200: result: $cf_cv_type_of_bool" >&5
+ echo "${ECHO_T}$cf_cv_type_of_bool" >&6
+ 		fi
+ 	fi
+@@ -11478,7 +12226,7 @@
+ cf_ada_make=gnatmake
+ # Extract the first word of "$cf_ada_make", so it can be a program name with args.
+ set dummy $cf_ada_make; ac_word=$2
+-echo "$as_me:11481: checking for $ac_word" >&5
++echo "$as_me:12229: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_gnat_exists+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -11493,7 +12241,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_gnat_exists="yes"
+-echo "$as_me:11496: found $ac_dir/$ac_word" >&5
++echo "$as_me:12244: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -11502,10 +12250,10 @@
+ fi
+ gnat_exists=$ac_cv_prog_gnat_exists
+ if test -n "$gnat_exists"; then
+-  echo "$as_me:11505: result: $gnat_exists" >&5
++  echo "$as_me:12253: result: $gnat_exists" >&5
+ echo "${ECHO_T}$gnat_exists" >&6
+ else
+-  echo "$as_me:11508: result: no" >&5
++  echo "$as_me:12256: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -11513,11 +12261,11 @@
+    cf_ada_make=
+ else
+ 
+-echo "$as_me:11516: checking for gnat version" >&5
++echo "$as_me:12264: checking for gnat version" >&5
+ echo $ECHO_N "checking for gnat version... $ECHO_C" >&6
+ cf_gnat_version=`${cf_ada_make-gnatmake} -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\
+   sed -e '2,$d' -e 's/[^0-9 \.]//g' -e 's/^[ ]*//' -e 's/ .*//'`
+-echo "$as_me:11520: result: $cf_gnat_version" >&5
++echo "$as_me:12268: result: $cf_gnat_version" >&5
+ echo "${ECHO_T}$cf_gnat_version" >&6
+ 
+ case $cf_gnat_version in
+@@ -11540,7 +12288,7 @@
+ 
+    # Extract the first word of "m4", so it can be a program name with args.
+ set dummy m4; ac_word=$2
+-echo "$as_me:11543: checking for $ac_word" >&5
++echo "$as_me:12291: checking for $ac_word" >&5
+ echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+ if test "${ac_cv_prog_M4_exists+set}" = set; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+@@ -11555,7 +12303,7 @@
+   test -z "$ac_dir" && ac_dir=.
+   $as_executable_p "$ac_dir/$ac_word" || continue
+ ac_cv_prog_M4_exists="yes"
+-echo "$as_me:11558: found $ac_dir/$ac_word" >&5
++echo "$as_me:12306: found $ac_dir/$ac_word" >&5
+ break
+ done
+ 
+@@ -11564,10 +12312,10 @@
+ fi
+ M4_exists=$ac_cv_prog_M4_exists
+ if test -n "$M4_exists"; then
+-  echo "$as_me:11567: result: $M4_exists" >&5
++  echo "$as_me:12315: result: $M4_exists" >&5
+ echo "${ECHO_T}$M4_exists" >&6
+ else
+-  echo "$as_me:11570: result: no" >&5
++  echo "$as_me:12318: result: no" >&5
+ echo "${ECHO_T}no" >&6
+ fi
+ 
+@@ -11576,7 +12324,7 @@
+       echo Ada95 binding required program m4 not found. Ada95 binding disabled.
+    fi
+    if test "$cf_cv_prog_gnat_correct" = yes; then
+-      echo "$as_me:11579: checking if GNAT works" >&5
++      echo "$as_me:12327: checking if GNAT works" >&5
+ echo $ECHO_N "checking if GNAT works... $ECHO_C" >&6
+ 
+ rm -f conftest*
+@@ -11593,7 +12341,7 @@
+    GNAT.OS_Lib.OS_Exit (0);
+ end conftest;
+ CF_EOF
+-if ( $cf_ada_make conftest 1>&5 2>&1 ) ; then
++if ( $cf_ada_make $ADAFLAGS conftest 1>&5 2>&1 ) ; then
+    if ( ./conftest 1>&5 2>&1 ) ; then
+       cf_cv_prog_gnat_correct=yes
+    else
+@@ -11604,13 +12352,50 @@
+ fi
+ rm -f conftest*
+ 
+-      echo "$as_me:11607: result: $cf_cv_prog_gnat_correct" >&5
++      echo "$as_me:12355: result: $cf_cv_prog_gnat_correct" >&5
+ echo "${ECHO_T}$cf_cv_prog_gnat_correct" >&6
+    fi
+ fi
+ if test	"$cf_cv_prog_gnat_correct" = yes; then
+    ADAFLAGS="-O3 -gnatpn $ADAFLAGS"
+ 
++   echo "$as_me:12362: checking if GNAT pragma Unreferenced works" >&5
++echo $ECHO_N "checking if GNAT pragma Unreferenced works... $ECHO_C" >&6
++
++rm -f conftest*
++cat >>conftest.ads <<CF_EOF
++procedure conftest;
++CF_EOF
++cat >>conftest.adb <<CF_EOF
++with Text_IO;
++with GNAT.OS_Lib;
++procedure conftest is
++   test : Integer;
++   pragma Unreferenced (test);
++begin
++   test := 1;
++   Text_IO.Put ("Hello World");
++   Text_IO.New_Line;
++   GNAT.OS_Lib.OS_Exit (0);
++end conftest;
++CF_EOF
++if ( $cf_ada_make $ADAFLAGS conftest 1>&5 2>&1 ) ; then
++      cf_cv_pragma_unreferenced=yes
++else
++   cf_cv_pragma_unreferenced=no
++fi
++rm -f conftest*
++
++   echo "$as_me:12389: result: $cf_cv_pragma_unreferenced" >&5
++echo "${ECHO_T}$cf_cv_pragma_unreferenced" >&6
++
++   # if the pragma is supported, use it (needed in the Trace code).
++   if test $cf_cv_pragma_unreferenced = yes ; then
++      PRAGMA_UNREF=TRUE
++   else
++      PRAGMA_UNREF=FALSE
++   fi
++
+ # Check whether --with-ada-compiler or --without-ada-compiler was given.
+ if test "${with_ada_compiler+set}" = set; then
+   withval="$with_ada_compiler"
+@@ -11647,7 +12432,7 @@
+   withval=`echo $withval | sed -e s%NONE%$ac_default_prefix%`
+   ;;
+ *)
+-  { { echo "$as_me:11650: error: expected a pathname, not \"$withval\"" >&5
++  { { echo "$as_me:12435: error: expected a pathname, not \"$withval\"" >&5
+ echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
+    { (exit 1); exit 1; }; }
+   ;;
+@@ -11681,7 +12466,7 @@
+   withval=`echo $withval | sed -e s%NONE%$ac_default_prefix%`
+   ;;
+ *)
+-  { { echo "$as_me:11684: error: expected a pathname, not \"$withval\"" >&5
++  { { echo "$as_me:12469: error: expected a pathname, not \"$withval\"" >&5
+ echo "$as_me: error: expected a pathname, not \"$withval\"" >&2;}
+    { (exit 1); exit 1; }; }
+   ;;
+@@ -11694,9 +12479,9 @@
+ 
+ ### Construct the library-subsets, if any, from this set of keywords:
+ ### none, base, ext_funcs, ext_tinfo, termlib, widechar (see CF_LIB_RULES).
+-echo "$as_me:11697: checking for library subsets" >&5
++echo "$as_me:12482: checking for library subsets" >&5
+ echo $ECHO_N "checking for library subsets... $ECHO_C" >&6
+-if test "$with_termlib" = yes ; then
++if test "$with_termlib" != no ; then
+ 	LIB_SUBSETS="termlib"
+ 	test "$with_ext_funcs" = yes && LIB_SUBSETS="${LIB_SUBSETS}+ext_tinfo"
+ 	LIB_SUBSETS="${LIB_SUBSETS} "
+@@ -11707,7 +12492,7 @@
+ LIB_SUBSETS="${LIB_SUBSETS}base"
+ test "$with_widec"     = yes && LIB_SUBSETS="${LIB_SUBSETS}+widechar"
+ test "$with_ext_funcs" = yes && LIB_SUBSETS="${LIB_SUBSETS}+ext_funcs"
+-echo "$as_me:11710: result: $LIB_SUBSETS" >&5
++echo "$as_me:12495: result: $LIB_SUBSETS" >&5
+ echo "${ECHO_T}$LIB_SUBSETS" >&6
+ 
+ ### Construct the list of include-directories to be generated
+@@ -11745,7 +12530,7 @@
+ fi
+ 
+ ### Build up pieces for makefile rules
+-echo "$as_me:11748: checking default library suffix" >&5
++echo "$as_me:12533: checking default library suffix" >&5
+ echo $ECHO_N "checking default library suffix... $ECHO_C" >&6
+ 
+ 	case $DFT_LWR_MODEL in
+@@ -11756,10 +12541,10 @@
+ 	shared)  DFT_ARG_SUFFIX=''   ;;
+ 	esac
+ 	test -n "$LIB_SUFFIX" && DFT_ARG_SUFFIX="${LIB_SUFFIX}${DFT_ARG_SUFFIX}"
+-echo "$as_me:11759: result: $DFT_ARG_SUFFIX" >&5
++echo "$as_me:12544: result: $DFT_ARG_SUFFIX" >&5
+ echo "${ECHO_T}$DFT_ARG_SUFFIX" >&6
+ 
+-echo "$as_me:11762: checking default library-dependency suffix" >&5
++echo "$as_me:12547: checking default library-dependency suffix" >&5
+ echo $ECHO_N "checking default library-dependency suffix... $ECHO_C" >&6
+ 
+ 	case $DFT_LWR_MODEL in
+@@ -11788,10 +12573,10 @@
+ 		;;
+ 	esac
+ fi
+-echo "$as_me:11791: result: $DFT_DEP_SUFFIX" >&5
++echo "$as_me:12576: result: $DFT_DEP_SUFFIX" >&5
+ echo "${ECHO_T}$DFT_DEP_SUFFIX" >&6
+ 
+-echo "$as_me:11794: checking default object directory" >&5
++echo "$as_me:12579: checking default object directory" >&5
+ echo $ECHO_N "checking default object directory... $ECHO_C" >&6
+ 
+ 	case $DFT_LWR_MODEL in
+@@ -11807,12 +12592,12 @@
+ 			DFT_OBJ_SUBDIR='obj_s' ;;
+ 		esac
+ 	esac
+-echo "$as_me:11810: result: $DFT_OBJ_SUBDIR" >&5
++echo "$as_me:12595: result: $DFT_OBJ_SUBDIR" >&5
+ echo "${ECHO_T}$DFT_OBJ_SUBDIR" >&6
+ 
+ # libtool thinks it can make c++ shared libraries (perhaps only g++)
+ if test "$cf_with_cxx" = yes ; then
+-echo "$as_me:11815: checking c++ library-dependency suffix" >&5
++echo "$as_me:12600: checking c++ library-dependency suffix" >&5
+ echo $ECHO_N "checking c++ library-dependency suffix... $ECHO_C" >&6
+ if test "$with_libtool" != "no"; then
+ 	CXX_LIB_SUFFIX=$DFT_DEP_SUFFIX
+@@ -11838,22 +12623,44 @@
+ 	esac
+ 	test -n "$LIB_SUFFIX" && CXX_LIB_SUFFIX="${LIB_SUFFIX}${CXX_LIB_SUFFIX}"
+ fi
+-echo "$as_me:11841: result: $CXX_LIB_SUFFIX" >&5
++echo "$as_me:12626: result: $CXX_LIB_SUFFIX" >&5
+ echo "${ECHO_T}$CXX_LIB_SUFFIX" >&6
+ 
+ fi
+ 
++### Set up low-level terminfo dependencies for makefiles.
+ TINFO_LIST="$SHLIB_LIST"
+-if test "$with_libtool" = no ; then
+-	test "$with_termlib" = yes && SHLIB_LIST="$SHLIB_LIST -ltinfo${LIB_SUFFIX}"
++if test "$with_termlib" != no ; then
++
++	if test "$with_termlib" != yes ; then
++		TINFO_NAME=$with_termlib
++		TINFO_ARG_SUFFIX="${with_termlib}`echo ${DFT_ARG_SUFFIX}|sed -e "s/^${LIB_SUFFIX}//"`"
++		TINFO_DEP_SUFFIX="${with_termlib}`echo ${DFT_DEP_SUFFIX}|sed -e "s/^${LIB_SUFFIX}//"`"
++		TINFO_LIB_SUFFIX="${with_termlib}"
++	else
++		TINFO_ARG_SUFFIX="${TINFO_NAME}${DFT_ARG_SUFFIX}"
++		TINFO_DEP_SUFFIX="${TINFO_NAME}${DFT_DEP_SUFFIX}"
++		TINFO_LIB_SUFFIX="${TINFO_NAME}${LIB_SUFFIX}"
++	fi
++
++	TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TINFO_DEP_SUFFIX}"
++	if test "$DFT_LWR_MODEL" = "libtool"; then
++		TEST_ARGS="${TEST_DEPS}"
++	else
++		TEST_ARGS="-l${TINFO_ARG_SUFFIX}"
++		TINFO_ARGS="-L${LIB_DIR} $TEST_ARGS"
++		SHLIB_LIST="$SHLIB_LIST -l${TINFO_LIB_SUFFIX}"
++	fi
++else
++	TINFO_ARGS="-L${LIB_DIR} -l${LIB_NAME}${DFT_ARG_SUFFIX}"
+ fi
+ 
+-echo "$as_me:11851: checking where we will install curses.h" >&5
++echo "$as_me:12658: checking where we will install curses.h" >&5
+ echo $ECHO_N "checking where we will install curses.h... $ECHO_C" >&6
+ test "$with_overwrite" = no && \
+ test "x$includedir" = 'x${prefix}/include' && \
+ 	includedir='$(prefix)/include/ncurses'${LIB_SUFFIX}
+-echo "$as_me:11856: result: $includedir" >&5
++echo "$as_me:12663: result: $includedir" >&5
+ echo "${ECHO_T}$includedir" >&6
+ 
+ ### Resolve a conflict between normal and wide-curses by forcing applications
+@@ -11861,24 +12668,11 @@
+ if test "$with_overwrite" != no ; then
+ if test "$NCURSES_LIBUTF8" = 1 ; then
+ 	NCURSES_LIBUTF8='defined(HAVE_LIBUTF8_H)'
+-	{ echo "$as_me:11864: WARNING: Wide-character applications must define HAVE_LIBUTF8_H to include curses.h" >&5
++	{ echo "$as_me:12671: WARNING: Wide-character applications must define HAVE_LIBUTF8_H to include curses.h" >&5
+ echo "$as_me: WARNING: Wide-character applications must define HAVE_LIBUTF8_H to include curses.h" >&2;}
+ fi
+ fi
+ 
+-### Set up low-level terminfo dependencies for makefiles.  Note that we
+-### could override this.
+-if test "$with_termlib" = yes ; then
+-	TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TINFO_NAME}${DFT_DEP_SUFFIX}"
+-	if test "$DFT_LWR_MODEL" = "libtool"; then
+-		TEST_ARGS="${TEST_DEPS}"
+-	else
+-		TEST_ARGS="-l${TINFO_NAME}${DFT_ARG_SUFFIX}"
+-	fi
+-fi
+-PROG_DEPS="$TEST_DEPS"
+-PROG_ARGS="$TEST_ARGS"
+-
+ ### predefined stuff for the test programs
+ cat >>confdefs.h <<\EOF
+ #define HAVE_SLK_COLOR 1
+@@ -11887,7 +12681,7 @@
+ ### Construct the list of subdirectories for which we'll customize makefiles
+ ### with the appropriate compile-rules.
+ 
+-echo "$as_me:11890: checking for src modules" >&5
++echo "$as_me:12684: checking for src modules" >&5
+ echo $ECHO_N "checking for src modules... $ECHO_C" >&6
+ 
+ # dependencies and linker-arguments for test-programs
+@@ -11898,9 +12692,6 @@
+ 	TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
+ fi
+ 
+-# dependencies and linker-arguments for utility-programs
+-test "$with_termlib" != yes && PROG_ARGS="$TEST_ARGS"
+-
+ cf_cv_src_modules=
+ for cf_dir in $modules_to_build
+ do
+@@ -11947,12 +12738,10 @@
+ 		fi
+ 	fi
+ done
+-echo "$as_me:11950: result: $cf_cv_src_modules" >&5
++echo "$as_me:12741: result: $cf_cv_src_modules" >&5
+ echo "${ECHO_T}$cf_cv_src_modules" >&6
+ TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
+ 
+-PROG_ARGS="-L${LIB_DIR} $PROG_ARGS"
+-
+ SRC_SUBDIRS="man include"
+ for cf_dir in $cf_cv_src_modules
+ do
+@@ -12021,12 +12810,34 @@
+ 
+ ### Now that we're done running tests, add the compiler-warnings, if any
+ 
++cf_fix_cppflags=no
+ cf_new_cflags=
+ cf_new_cppflags=
++cf_new_extra_cppflags=
++
+ for cf_add_cflags in $EXTRA_CFLAGS
+ do
++case $cf_fix_cppflags in
++no)
+ 	case $cf_add_cflags in #(vi
+ 	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
++		case $cf_add_cflags in
++		-D*)
++			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
++
++			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++			&& test -z "${cf_tst_cflags}" \
++			&& cf_fix_cppflags=yes
++
++			if test $cf_fix_cppflags = yes ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			elif test "${cf_tst_cflags}" = "\"'" ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			fi
++			;;
++		esac
+ 		case "$CPPFLAGS" in
+ 		*$cf_add_cflags) #(vi
+ 			;;
+@@ -12039,6 +12850,17 @@
+ 		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+ 		;;
+ 	esac
++	;;
++yes)
++	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++
++	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
++
++	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++	&& test -z "${cf_tst_cflags}" \
++	&& cf_fix_cppflags=no
++	;;
++esac
+ done
+ 
+ if test -n "$cf_new_cflags" ; then
+@@ -12051,6 +12873,11 @@
+ 	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
+ fi
+ 
++if test -n "$cf_new_extra_cppflags" ; then
++
++	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
++fi
++
+ ################################################################################
+ test "$use_database" = yes && SUB_MAKEFILES="$SUB_MAKEFILES misc/run_tic.sh:misc/run_tic.in"
+ ac_config_files="$ac_config_files include/MKterm.h.awk include/curses.head:include/curses.h.in include/termcap.h include/unctrl.h $SUB_MAKEFILES Makefile"
+@@ -12134,7 +12961,7 @@
+ : ${CONFIG_STATUS=./config.status}
+ ac_clean_files_save=$ac_clean_files
+ ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+-{ echo "$as_me:12137: creating $CONFIG_STATUS" >&5
++{ echo "$as_me:12964: creating $CONFIG_STATUS" >&5
+ echo "$as_me: creating $CONFIG_STATUS" >&6;}
+ cat >$CONFIG_STATUS <<_ACEOF
+ #! $SHELL
+@@ -12310,7 +13137,7 @@
+     echo "$ac_cs_version"; exit 0 ;;
+   --he | --h)
+     # Conflict between --help and --header
+-    { { echo "$as_me:12313: error: ambiguous option: $1
++    { { echo "$as_me:13140: error: ambiguous option: $1
+ Try \`$0 --help' for more information." >&5
+ echo "$as_me: error: ambiguous option: $1
+ Try \`$0 --help' for more information." >&2;}
+@@ -12329,7 +13156,7 @@
+     ac_need_defaults=false;;
+ 
+   # This is an error.
+-  -*) { { echo "$as_me:12332: error: unrecognized option: $1
++  -*) { { echo "$as_me:13159: error: unrecognized option: $1
+ Try \`$0 --help' for more information." >&5
+ echo "$as_me: error: unrecognized option: $1
+ Try \`$0 --help' for more information." >&2;}
+@@ -12369,6 +13196,7 @@
+ 
+ AWK="$AWK"
+ CF_LIST_MODELS="$cf_list_models"
++DFT_ARG_SUFFIX="$DFT_ARG_SUFFIX"
+ DFT_LWR_MODEL="$DFT_LWR_MODEL"
+ LDCONFIG="$LDCONFIG"
+ LIB_NAME="$LIB_NAME"
+@@ -12379,12 +13207,16 @@
+ NCURSES_OSPEED="$NCURSES_OSPEED"
+ SRC_SUBDIRS="$SRC_SUBDIRS"
+ TERMINFO="$TERMINFO"
++TINFO_ARG_SUFFIX="$TINFO_ARG_SUFFIX"
++TINFO_LIB_SUFFIX="$TINFO_LIB_SUFFIX"
+ TINFO_NAME="$TINFO_NAME"
+ WITH_CURSES_H="$with_curses_h"
+ WITH_ECHO="$with_echo"
+ WITH_OVERWRITE="$with_overwrite"
+ cf_cv_abi_version="$cf_cv_abi_version"
+ cf_cv_do_symlinks="$cf_cv_do_symlinks"
++cf_cv_prog_CC_c_o=$cf_cv_prog_CC_c_o
++cf_cv_prog_CXX_c_o=$cf_cv_prog_CXX_c_o
+ cf_cv_rel_version="$cf_cv_rel_version"
+ cf_cv_rm_so_locs="$cf_cv_rm_so_locs"
+ cf_cv_shlib_version="$cf_cv_shlib_version"
+@@ -12409,7 +13241,7 @@
+   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+   "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
+   "include/ncurses_cfg.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/ncurses_cfg.h:include/ncurses_cfg.hin" ;;
+-  *) { { echo "$as_me:12412: error: invalid argument: $ac_config_target" >&5
++  *) { { echo "$as_me:13244: error: invalid argument: $ac_config_target" >&5
+ echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+    { (exit 1); exit 1; }; };;
+   esac
+@@ -12519,6 +13351,7 @@
+ s,@EXEEXT@,$EXEEXT,;t t
+ s,@OBJEXT@,$OBJEXT,;t t
+ s,@CPP@,$CPP,;t t
++s,@EXTRA_CPPFLAGS@,$EXTRA_CPPFLAGS,;t t
+ s,@PROG_EXT@,$PROG_EXT,;t t
+ s,@LDCONFIG@,$LDCONFIG,;t t
+ s,@CXX@,$CXX,;t t
+@@ -12545,11 +13378,13 @@
+ s,@cf_cv_makeflags@,$cf_cv_makeflags,;t t
+ s,@DESTDIR@,$DESTDIR,;t t
+ s,@BUILD_CC@,$BUILD_CC,;t t
++s,@BUILD_CPP@,$BUILD_CPP,;t t
+ s,@BUILD_CFLAGS@,$BUILD_CFLAGS,;t t
+ s,@BUILD_CPPFLAGS@,$BUILD_CPPFLAGS,;t t
+ s,@BUILD_LDFLAGS@,$BUILD_LDFLAGS,;t t
+ s,@BUILD_LIBS@,$BUILD_LIBS,;t t
+ s,@BUILD_EXEEXT@,$BUILD_EXEEXT,;t t
++s,@BUILD_OBJEXT@,$BUILD_OBJEXT,;t t
+ s,@cf_list_models@,$cf_list_models,;t t
+ s,@LIBTOOL@,$LIBTOOL,;t t
+ s,@LIBTOOL_CXX@,$LIBTOOL_CXX,;t t
+@@ -12582,17 +13417,12 @@
+ s,@TERMINFO_SRC@,$TERMINFO_SRC,;t t
+ s,@PATHSEP@,$PATHSEP,;t t
+ s,@FALLBACK_LIST@,$FALLBACK_LIST,;t t
++s,@WHICH_XTERM@,$WHICH_XTERM,;t t
+ s,@TERMINFO_DIRS@,$TERMINFO_DIRS,;t t
+ s,@TERMINFO@,$TERMINFO,;t t
+ s,@MAKE_TERMINFO@,$MAKE_TERMINFO,;t t
+ s,@TERMPATH@,$TERMPATH,;t t
+ s,@BROKEN_LINKER@,$BROKEN_LINKER,;t t
+-s,@NCURSES_BOOL@,$NCURSES_BOOL,;t t
+-s,@NCURSES_OSPEED@,$NCURSES_OSPEED,;t t
+-s,@MANPAGE_RENAMES@,$MANPAGE_RENAMES,;t t
+-s,@NCURSES_EXT_FUNCS@,$NCURSES_EXT_FUNCS,;t t
+-s,@NCURSES_CONST@,$NCURSES_CONST,;t t
+-s,@NCURSES_XNAMES@,$NCURSES_XNAMES,;t t
+ s,@NCURSES_CH_T@,$NCURSES_CH_T,;t t
+ s,@NCURSES_LIBUTF8@,$NCURSES_LIBUTF8,;t t
+ s,@NEED_WCHAR_H@,$NEED_WCHAR_H,;t t
+@@ -12601,7 +13431,15 @@
+ s,@NCURSES_WINT_T@,$NCURSES_WINT_T,;t t
+ s,@NCURSES_OK_WCHAR_T@,$NCURSES_OK_WCHAR_T,;t t
+ s,@NCURSES_OK_WINT_T@,$NCURSES_OK_WINT_T,;t t
++s,@NCURSES_BOOL@,$NCURSES_BOOL,;t t
+ s,@TERMINFO_CAPS@,$TERMINFO_CAPS,;t t
++s,@NCURSES_OSPEED@,$NCURSES_OSPEED,;t t
++s,@MANPAGE_RENAMES@,$MANPAGE_RENAMES,;t t
++s,@NCURSES_EXT_FUNCS@,$NCURSES_EXT_FUNCS,;t t
++s,@NCURSES_CONST@,$NCURSES_CONST,;t t
++s,@NCURSES_XNAMES@,$NCURSES_XNAMES,;t t
++s,@NCURSES_EXT_COLORS@,$NCURSES_EXT_COLORS,;t t
++s,@NCURSES_MOUSE_VERSION@,$NCURSES_MOUSE_VERSION,;t t
+ s,@ECHO_LINK@,$ECHO_LINK,;t t
+ s,@EXTRA_CFLAGS@,$EXTRA_CFLAGS,;t t
+ s,@ADA_TRACE@,$ADA_TRACE,;t t
+@@ -12623,6 +13461,7 @@
+ s,@ADAFLAGS@,$ADAFLAGS,;t t
+ s,@cf_compile_generics@,$cf_compile_generics,;t t
+ s,@cf_generic_objects@,$cf_generic_objects,;t t
++s,@PRAGMA_UNREF@,$PRAGMA_UNREF,;t t
+ s,@ADA_INCLUDE@,$ADA_INCLUDE,;t t
+ s,@ADA_OBJECTS@,$ADA_OBJECTS,;t t
+ s,@ACPPFLAGS@,$ACPPFLAGS,;t t
+@@ -12630,12 +13469,14 @@
+ s,@DFT_DEP_SUFFIX@,$DFT_DEP_SUFFIX,;t t
+ s,@DFT_OBJ_SUBDIR@,$DFT_OBJ_SUBDIR,;t t
+ s,@CXX_LIB_SUFFIX@,$CXX_LIB_SUFFIX,;t t
+-s,@EXTRA_LIBS@,$EXTRA_LIBS,;t t
++s,@TINFO_ARG_SUFFIX@,$TINFO_ARG_SUFFIX,;t t
++s,@TINFO_DEP_SUFFIX@,$TINFO_DEP_SUFFIX,;t t
++s,@TINFO_LIB_SUFFIX@,$TINFO_LIB_SUFFIX,;t t
++s,@TINFO_ARGS@,$TINFO_ARGS,;t t
+ s,@TINFO_LIST@,$TINFO_LIST,;t t
+ s,@SHLIB_LIST@,$SHLIB_LIST,;t t
+ s,@TEST_DEPS@,$TEST_DEPS,;t t
+ s,@TEST_ARGS@,$TEST_ARGS,;t t
+-s,@PROG_ARGS@,$PROG_ARGS,;t t
+ s,@ADA_SUBDIRS@,$ADA_SUBDIRS,;t t
+ s,@DIRS_TO_MAKE@,$DIRS_TO_MAKE,;t t
+ CEOF
+@@ -12752,7 +13593,7 @@
+   esac
+ 
+   if test x"$ac_file" != x-; then
+-    { echo "$as_me:12755: creating $ac_file" >&5
++    { echo "$as_me:13596: creating $ac_file" >&5
+ echo "$as_me: creating $ac_file" >&6;}
+     rm -f "$ac_file"
+   fi
+@@ -12770,7 +13611,7 @@
+       -) echo $tmp/stdin ;;
+       [\\/$]*)
+          # Absolute (can't be DOS-style, as IFS=:)
+-         test -f "$f" || { { echo "$as_me:12773: error: cannot find input file: $f" >&5
++         test -f "$f" || { { echo "$as_me:13614: error: cannot find input file: $f" >&5
+ echo "$as_me: error: cannot find input file: $f" >&2;}
+    { (exit 1); exit 1; }; }
+          echo $f;;
+@@ -12783,7 +13624,7 @@
+            echo $srcdir/$f
+          else
+            # /dev/null tree
+-           { { echo "$as_me:12786: error: cannot find input file: $f" >&5
++           { { echo "$as_me:13627: error: cannot find input file: $f" >&5
+ echo "$as_me: error: cannot find input file: $f" >&2;}
+    { (exit 1); exit 1; }; }
+          fi;;
+@@ -12849,7 +13690,7 @@
+   * )   ac_file_in=$ac_file.in ;;
+   esac
+ 
+-  test x"$ac_file" != x- && { echo "$as_me:12852: creating $ac_file" >&5
++  test x"$ac_file" != x- && { echo "$as_me:13693: creating $ac_file" >&5
+ echo "$as_me: creating $ac_file" >&6;}
+ 
+   # First look for the input files in the build tree, otherwise in the
+@@ -12860,7 +13701,7 @@
+       -) echo $tmp/stdin ;;
+       [\\/$]*)
+          # Absolute (can't be DOS-style, as IFS=:)
+-         test -f "$f" || { { echo "$as_me:12863: error: cannot find input file: $f" >&5
++         test -f "$f" || { { echo "$as_me:13704: error: cannot find input file: $f" >&5
+ echo "$as_me: error: cannot find input file: $f" >&2;}
+    { (exit 1); exit 1; }; }
+          echo $f;;
+@@ -12873,7 +13714,7 @@
+            echo $srcdir/$f
+          else
+            # /dev/null tree
+-           { { echo "$as_me:12876: error: cannot find input file: $f" >&5
++           { { echo "$as_me:13717: error: cannot find input file: $f" >&5
+ echo "$as_me: error: cannot find input file: $f" >&2;}
+    { (exit 1); exit 1; }; }
+          fi;;
+@@ -12931,7 +13772,7 @@
+   rm -f $tmp/in
+   if test x"$ac_file" != x-; then
+     if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
+-      { echo "$as_me:12934: $ac_file is unchanged" >&5
++      { echo "$as_me:13775: $ac_file is unchanged" >&5
+ echo "$as_me: $ac_file is unchanged" >&6;}
+     else
+       ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+@@ -13026,13 +13867,33 @@
+ 				case "$cf_cv_shlib_version" in #(vi
+ 				rel) #(vi
+ 					case "$cf_cv_system_name" in #(vi
+-					darwin*) cf_suffix='.$(REL_VERSION)'"$cf_suffix" ;; #(vi
++					darwin*)
++					case .${LIB_SUFFIX} in
++					.w*)
++						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
++						cf_suffix=w'.$(REL_VERSION)'"$cf_suffix"
++						;;
++					*)
++						cf_suffix='.$(REL_VERSION)'"$cf_suffix"
++						;;
++					esac
++					;; #(vi
+ 					*) cf_suffix="$cf_suffix"'.$(REL_VERSION)' ;;
+ 					esac
+ 					;;
+ 				abi)
+ 					case "$cf_cv_system_name" in #(vi
+-					darwin*) cf_suffix='.$(ABI_VERSION)'"$cf_suffix" ;; #(vi
++					darwin*)
++					case .${LIB_SUFFIX} in
++					.w*)
++						cf_suffix=`echo $cf_suffix | sed 's/^w//'`
++						cf_suffix=w'.$(ABI_VERSION)'"$cf_suffix"
++						;;
++					*)
++						cf_suffix='.$(ABI_VERSION)'"$cf_suffix"
++						;;
++					esac
++					;; #(vi
+ 					*) cf_suffix="$cf_suffix"'.$(ABI_VERSION)' ;;
+ 					esac
+ 					;;
+@@ -13055,7 +13916,7 @@
+ 			cf_subsets="$LIB_SUBSETS"
+ 			cf_termlib=`echo "$cf_subsets" |sed -e 's/ .*$//'`
+ 			if test "$cf_termlib" != "$cf_subsets" ; then
+-				cf_item=`echo $LIBS_TO_MAKE |sed -e s%$LIB_NAME%$TINFO_NAME%g`
++				cf_item=`echo $LIBS_TO_MAKE |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
+ 				LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
+ 			fi
+ 		else
+@@ -13115,6 +13976,22 @@
+ 		esac
+ 	esac
+ 
++			# Test for case where we build libtinfo with a different name.
++			cf_libname=$cf_dir
++			if test $cf_dir = ncurses ; then
++				case $cf_subset in
++				*base*)
++					;;
++				termlib*)
++					cf_libname=$TINFO_LIB_SUFFIX
++					if test -n "${DFT_ARG_SUFFIX}" ; then
++						# undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
++						cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
++					fi
++				;;
++				esac
++			fi
++
+ 			# These dependencies really are for development, not
+ 			# builds, but they are useful in porting, too.
+ 			cf_depend="../include/ncurses_cfg.h"
+@@ -13130,8 +14007,22 @@
+ 				cf_depend="$cf_depend $cf_reldir/curses.priv.h"
+ 			fi
+ 
++ 			cf_dir_suffix=
++ 			old_cf_suffix="$cf_suffix"
++ 			if test "$cf_cv_shlib_version_infix" = yes ; then
++			if test -n "$LIB_SUFFIX" ; then
++				case $LIB_SUFFIX in
++				w*)
++					cf_libname=`echo $cf_libname | sed 's/w$//'`
++					cf_suffix=`echo $cf_suffix | sed 's/^w//'`
++					cf_dir_suffix=w
++					;;
++				esac
++			fi
++ 			fi
++
+ 			$AWK -f $srcdir/mk-1st.awk \
+-				name=$cf_dir \
++				name=${cf_libname}${cf_dir_suffix} \
+ 				traces=$LIB_TRACING \
+ 				MODEL=$CF_ITEM \
+ 				model=$cf_subdir \
+@@ -13147,6 +14038,9 @@
+ 				depend="$cf_depend" \
+ 				host="$host" \
+ 				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
++
++			cf_suffix="$old_cf_suffix"
++
+ 			for cf_subdir2 in $cf_subdirs lib
+ 			do
+ 				test $cf_subdir = $cf_subdir2 && break
+@@ -13160,6 +14054,8 @@
+ 				subset=$cf_subset \
+ 				srcdir=$srcdir \
+ 				echo=$WITH_ECHO \
++				crenames=$cf_cv_prog_CC_c_o \
++				cxxrenames=$cf_cv_prog_CXX_c_o \
+ 				$srcdir/$cf_dir/modules >>$cf_dir/Makefile
+ 			cf_subdirs="$cf_subdirs $cf_subdir"
+ 			done
+Index: configure.in
+Prereq:  1.312 
+--- ncurses-5.4-20040208/configure.in	2004-01-24 19:29:13.000000000 +0000
++++ ncurses-5.4-20050319/configure.in	2005-02-05 18:14:41.000000000 +0000
+@@ -1,5 +1,5 @@
+ dnl***************************************************************************
+-dnl Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++dnl Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
+ dnl                                                                          *
+ dnl Permission is hereby granted, free of charge, to any person obtaining a  *
+ dnl copy of this software and associated documentation files (the            *
+@@ -28,14 +28,14 @@
+ dnl
+ dnl Author: Thomas E. Dickey 1995-on
+ dnl
+-dnl $Id: configure.in,v 1.312 2004/01/24 19:29:13 tom Exp $
++dnl $Id: configure.in,v 1.331 2005/02/05 18:14:41 tom Exp $
+ dnl Process this file with autoconf to produce a configure script.
+ dnl
+ dnl See http://invisible-island.net/autoconf/ for additional information.
+ dnl
+ dnl ---------------------------------------------------------------------------
+ AC_PREREQ(2.13.20020210)
+-AC_REVISION($Revision: 1.312 $)
++AC_REVISION($Revision: 1.331 $)
+ AC_INIT(ncurses/base/lib_initscr.c)
+ AC_CONFIG_HEADER(include/ncurses_cfg.h:include/ncurses_cfg.hin)
+ 
+@@ -62,6 +62,7 @@
+ 
+ AC_PROG_CPP
+ AC_PROG_GCC_TRADITIONAL
++CF_PROG_CC_C_O(CC)
+ AC_ISC_POSIX
+ CF_ANSI_CC_REQD
+ CF_PROG_EXT
+@@ -180,37 +181,7 @@
+ # If we're cross-compiling, allow the user to override the tools and their
+ # options.  The configure script is oriented toward identifying the host
+ # compiler, etc., but we need a build compiler to generate parts of the source.
+-: ${BUILD_CC:='$(CC)'}
+-: ${BUILD_CFLAGS:='$(CFLAGS)'}
+-: ${BUILD_CPPFLAGS:='$(CPPFLAGS)'}
+-: ${BUILD_LDFLAGS:='$(LDFLAGS)'}
+-: ${BUILD_LIBS:='$(LIBS)'}
+-: ${BUILD_EXEEXT:='$x'}
+-if test "$cross_compiling" = yes ; then
+-	AC_ARG_WITH(build-cc,
+-		[  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
+-		[BUILD_CC="$withval"],
+-		[AC_CHECK_PROGS(BUILD_CC, $CC gcc cc)])
+-	AC_ARG_WITH(build-cflags,
+-		[  --with-build-cflags=XXX the build C compiler-flags],
+-		[BUILD_CFLAGS="$withval"])
+-	AC_ARG_WITH(build-cppflags,
+-		[  --with-build-cppflags=XXX the build C preprocessor-flags],
+-		[BUILD_CPPFLAGS="$withval"])
+-	AC_ARG_WITH(build-ldflags,
+-		[  --with-build-ldflags=XXX the build linker-flags],
+-		[BUILD_LDFLAGS="$withval"])
+-	AC_ARG_WITH(build-libs,
+-		[  --with-build-libs=XXX   the build libraries],
+-		[BUILD_LIBS="$withval"])
+-	BUILD_EXEEXT=
+-fi
+-AC_SUBST(BUILD_CC)
+-AC_SUBST(BUILD_CFLAGS)
+-AC_SUBST(BUILD_CPPFLAGS)
+-AC_SUBST(BUILD_LDFLAGS)
+-AC_SUBST(BUILD_LIBS)
+-AC_SUBST(BUILD_EXEEXT)
++CF_BUILD_CC
+ 
+ ###############################################################################
+ CF_HELP_MESSAGE(Options to Specify the Libraries Built/Used:)
+@@ -310,19 +281,36 @@
+ CF_WITH_DMALLOC
+ 
+ SHLIB_LIST=""
+-AC_MSG_CHECKING(if you want to link with the gpm mouse library)
++AC_MSG_CHECKING(if you want to link with the GPM mouse library)
+ AC_ARG_WITH(gpm,
+ 	[  --with-gpm              use Alessandro Rubini's GPM library],
+ 	[with_gpm=$withval],
+-	[with_gpm=no])
++	[with_gpm=maybe])
+ AC_MSG_RESULT($with_gpm)
+-if test "$with_gpm" = yes ; then
++if test "$with_gpm" != no ; then
+ 	AC_CHECK_LIB(gpm,Gpm_Open,[
+-		EXTRA_LIBS="-lgpm -lncurses $EXTRA_LIBS"
+-		SHLIB_LIST="-lgpm $SHLIB_LIST"
++		AC_CHECK_HEADER(gpm.h,[
++			AC_DEFINE(HAVE_GPM_H)
++			with_gpm=yes
++		],[
++			if test "$with_gpm" = yes ; then
++				AC_ERROR(Cannot find GPM header)
++			fi
++		])
++	],[
++		if test "$with_gpm" = yes ; then
++			AC_ERROR(Cannot link with GPM library)
++		fi
++		with_gpm=no
++	])
++	if test "$with_gpm" = yes ; then
++		CF_FUNC_DLSYM
++		SHLIB_LIST="-ldl $SHLIB_LIST"
+ 		AC_DEFINE(HAVE_LIBGPM)
+-		AC_CHECK_HEADERS(gpm.h)
+-	],AC_MSG_WARN(Cannot link with gpm library - read the FAQ))
++		AC_CHECK_LIB(gpm,Gpm_Wgetch,[
++			AC_MSG_WARN(GPM library is already linked with curses - read the FAQ)
++		])
++	fi
+ fi
+ 
+ CF_WITH_SYSMOUSE
+@@ -415,6 +403,19 @@
+ FALLBACK_LIST=`echo "$with_fallback" | sed -e 's/,/ /g'`
+ AC_SUBST(FALLBACK_LIST)
+ 
++AC_MSG_CHECKING(if you want modern xterm or antique)
++AC_ARG_WITH(xterm-new,
++	[  --without-xterm-new     specify if xterm terminfo should be old version],
++	[with_xterm_new=$withval],
++	[with_xterm_new=yes])
++case $with_xterm_new in
++no)	with_xterm_new=xterm-old;;
++*)	with_xterm_new=xterm-new;;
++esac
++AC_MSG_RESULT($with_xterm_new)
++WHICH_XTERM=$with_xterm_new
++AC_SUBST(WHICH_XTERM)
++
+ MAKE_TERMINFO=
+ if test "$use_database" = no ; then
+ 	TERMINFO="${datadir}/terminfo"
+@@ -517,8 +518,17 @@
+ 	[  --disable-home-terminfo drop ~/.terminfo from terminfo search-path],
+ 	[with_home_terminfo=$enableval],
+ 	[with_home_terminfo=yes])
++AC_MSG_RESULT($with_home_terminfo)
+ test "$with_home_terminfo" = "yes" && AC_DEFINE(USE_HOME_TERMINFO)
+ 
++AC_MSG_CHECKING(if you want to use restrict environment when running as root)
++AC_ARG_ENABLE(root-environ,
++	[  --disable-root-environ  limit environment when running as root],
++	[with_root_environ=$enableval],
++	[with_root_environ=yes])
++AC_MSG_RESULT($with_root_environ)
++test "$with_root_environ" = yes && AC_DEFINE(USE_ROOT_ENVIRON)
++
+ ###   Use option --enable-symlinks to make tic use symlinks, not hard links
+ ###   to reduce storage requirements for the terminfo database.
+ CF_LINK_FUNCS
+@@ -577,6 +587,63 @@
+ fi
+ AC_SUBST(BROKEN_LINKER)
+ 
++###   use option --enable-widec to turn on use of wide-character support
++NCURSES_CH_T=chtype
++NCURSES_LIBUTF8=0
++
++NEED_WCHAR_H=0
++NCURSES_MBSTATE_T=0
++NCURSES_WCHAR_T=0
++NCURSES_WINT_T=0
++
++# Check to define _XOPEN_SOURCE "automatically"
++CF_XOPEN_SOURCE
++
++# Checks for CODESET support.
++AM_LANGINFO_CODESET
++
++# use these variables to work around a defect in gcc's fixincludes.
++NCURSES_OK_WCHAR_T=
++NCURSES_OK_WINT_T=
++
++AC_MSG_CHECKING(if you want wide-character code)
++AC_ARG_ENABLE(widec,
++	[  --enable-widec          compile with wide-char/UTF-8 code],
++	[with_widec=$enableval],
++	[with_widec=no])
++AC_MSG_RESULT($with_widec)
++if test "$with_widec" = yes ; then
++	LIB_SUFFIX="w${LIB_SUFFIX}"
++	AC_DEFINE(USE_WIDEC_SUPPORT)
++	CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
++	# with_overwrite=no
++	NCURSES_CH_T=cchar_t
++	AC_CHECK_FUNCS(putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc)
++	if test "$ac_cv_func_putwc" != yes ; then
++		CF_LIBUTF8
++		if test "$cf_cv_libutf8" = yes ; then
++			NCURSES_LIBUTF8=1
++		fi
++	fi
++	CF_WCHAR_TYPE(mbstate_t, NCURSES_MBSTATE_T)
++	CF_WCHAR_TYPE(wchar_t,   NCURSES_WCHAR_T,   NCURSES_OK_WCHAR_T)
++	CF_WCHAR_TYPE(wint_t,    NCURSES_WINT_T,    NCURSES_OK_WINT_T)
++
++	if test "$NCURSES_MBSTATE_T" != 0; then
++		AC_DEFINE(NEED_MBSTATE_T_DEF)
++	fi
++fi
++AC_SUBST(NCURSES_CH_T)
++AC_SUBST(NCURSES_LIBUTF8)
++
++AC_SUBST(NEED_WCHAR_H)
++AC_SUBST(NCURSES_MBSTATE_T)
++AC_SUBST(NCURSES_WCHAR_T)
++AC_SUBST(NCURSES_WINT_T)
++
++AC_SUBST(NCURSES_OK_WCHAR_T)
++AC_SUBST(NCURSES_OK_WINT_T)
++
+ ###   use option --with-bool to override bool's type
+ AC_MSG_CHECKING(for type of bool)
+ AC_ARG_WITH(bool,
+@@ -586,6 +653,15 @@
+ AC_MSG_RESULT($NCURSES_BOOL)
+ AC_SUBST(NCURSES_BOOL)
+ 
++AC_MSG_CHECKING(for alternate terminal capabilities file)
++AC_ARG_WITH(caps,
++	[  --with-caps=alt         compile with alternate Caps file],
++	[TERMINFO_CAPS=Caps.$withval],
++	[TERMINFO_CAPS=Caps])
++test -f ${srcdir}/include/${TERMINFO_CAPS} || TERMINFO_CAPS=Caps
++AC_MSG_RESULT($TERMINFO_CAPS)
++AC_SUBST(TERMINFO_CAPS)
++
+ ###   use option --with-ospeed to override ospeed's type
+ AC_MSG_CHECKING(for type of ospeed)
+ AC_ARG_WITH(ospeed,
+@@ -700,14 +776,6 @@
+ AC_MSG_RESULT($with_hardtabs)
+ test "$with_hardtabs" = yes && AC_DEFINE(USE_HARD_TABS)
+ 
+-AC_MSG_CHECKING(if you want to use restrict environment when running as root)
+-AC_ARG_ENABLE(root-environ,
+-	[  --disable-root-environ  limit environment when running as root],
+-	[with_root_environ=$enableval],
+-	[with_root_environ=yes])
+-AC_MSG_RESULT($with_root_environ)
+-test "$with_root_environ" = yes && AC_DEFINE(USE_ROOT_ENVIRON)
+-
+ ###   use option --enable-xmc-glitch to turn on use of magic-cookie optimize
+ AC_MSG_CHECKING(if you want limited support for xmc)
+ AC_ARG_ENABLE(xmc-glitch,
+@@ -747,6 +815,45 @@
+ AC_MSG_RESULT($with_colorfgbg)
+ test "$with_colorfgbg" = yes && AC_DEFINE(USE_COLORFGBG)
+ 
++###   use option --enable-ext-colors to turn on use of colors beyond 16.
++AC_MSG_CHECKING(if you want to use experimental extended colors)
++AC_ARG_ENABLE(ext-colors,
++	[  --enable-ext-colors     compile for experimental 256-color support],
++	[with_ext_colors=$enableval],
++	[with_ext_colors=no])
++AC_MSG_RESULT($with_ext_colors)
++NCURSES_EXT_COLORS=0
++if test "$with_ext_colors" = yes ; then
++	if test "$with_widec" != yes ; then
++		AC_MSG_WARN(This option applies only to wide-character library)
++	else
++		# cannot be ABI 5 since it changes sizeof(cchar_t)
++		case $cf_cv_rel_version in
++		5.*)
++			cf_cv_rel_version=6.0
++			cf_cv_abi_version=6
++			AC_MSG_WARN(Overriding ABI version to $cf_cv_abi_version)
++			;;
++		esac
++	fi
++	NCURSES_EXT_COLORS=1
++	AC_DEFINE(NCURSES_EXT_COLORS)
++fi
++AC_SUBST(NCURSES_EXT_COLORS)
++
++###   use option --enable-ext-mouse to modify coding to support 5-button mice
++AC_MSG_CHECKING(if you want to use experimental extended mouse encoding)
++AC_ARG_ENABLE(ext-mouse,
++	[  --enable-ext-mouse      compile for experimental mouse-encoding],
++	[with_ext_mouse=$enableval],
++	[with_ext_mouse=no])
++AC_MSG_RESULT($with_ext_mouse)
++NCURSES_MOUSE_VERSION=1
++if test "$with_ext_mouse" = yes ; then
++	NCURSES_MOUSE_VERSION=2
++fi
++AC_SUBST(NCURSES_MOUSE_VERSION)
++
+ AC_MSG_CHECKING(if you want experimental safe-sprintf code)
+ AC_ARG_ENABLE(safe-sprintf,
+ 	[  --enable-safe-sprintf   compile with experimental safe-sprintf code],
+@@ -767,66 +874,6 @@
+ test "$with_scroll_hints" = yes && AC_DEFINE(USE_SCROLL_HINTS)
+ fi
+ 
+-###   use option --enable-widec to turn on use of wide-character support
+-NCURSES_CH_T=chtype
+-NCURSES_LIBUTF8=0
+-
+-NEED_WCHAR_H=0
+-NCURSES_MBSTATE_T=0
+-NCURSES_WCHAR_T=0
+-NCURSES_WINT_T=0
+-
+-# Check to define _XOPEN_SOURCE "automatically"
+-CF_XOPEN_SOURCE
+-
+-# use these variables to work around a defect in gcc's fixincludes.
+-NCURSES_OK_WCHAR_T=
+-NCURSES_OK_WINT_T=
+-
+-AC_MSG_CHECKING(if you want experimental wide-character code)
+-AC_ARG_ENABLE(widec,
+-	[  --enable-widec          compile with experimental wide-char/UTF-8 code],
+-	[with_widec=$enableval],
+-	[with_widec=no])
+-AC_MSG_RESULT($with_widec)
+-if test "$with_widec" = yes ; then
+-	LIB_SUFFIX="w${LIB_SUFFIX}"
+-	AC_DEFINE(USE_WIDEC_SUPPORT)
+-	CF_PREDEFINE(_XOPEN_SOURCE,500)
+-	CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
+-	# with_overwrite=no
+-	NCURSES_CH_T=cchar_t
+-	AC_CHECK_FUNCS(putwc btowc wctob mbtowc wctomb mblen mbrlen mbrtowc)
+-	if test "$ac_cv_func_putwc" != yes ; then
+-		CF_LIBUTF8
+-		if test "$cf_cv_libutf8" = yes ; then
+-			NCURSES_LIBUTF8=1
+-		fi
+-	fi
+-	CF_WCHAR_TYPE(mbstate_t, NCURSES_MBSTATE_T)
+-	CF_WCHAR_TYPE(wchar_t,   NCURSES_WCHAR_T,   NCURSES_OK_WCHAR_T)
+-	CF_WCHAR_TYPE(wint_t,    NCURSES_WINT_T,    NCURSES_OK_WINT_T)
+-fi
+-AC_SUBST(NCURSES_CH_T)
+-AC_SUBST(NCURSES_LIBUTF8)
+-
+-AC_SUBST(NEED_WCHAR_H)
+-AC_SUBST(NCURSES_MBSTATE_T)
+-AC_SUBST(NCURSES_WCHAR_T)
+-AC_SUBST(NCURSES_WINT_T)
+-
+-AC_SUBST(NCURSES_OK_WCHAR_T)
+-AC_SUBST(NCURSES_OK_WINT_T)
+-
+-AC_MSG_CHECKING(for terminal capabilities file)
+-AC_ARG_WITH(caps,
+-	[  --with-caps=alt         compile with experimental alternate Caps file],
+-	[TERMINFO_CAPS=Caps.$withval],
+-	[TERMINFO_CAPS=Caps])
+-test -f ${srcdir}/include/${TERMINFO_CAPS} || TERMINFO_CAPS=Caps
+-AC_MSG_RESULT($TERMINFO_CAPS)
+-AC_SUBST(TERMINFO_CAPS)
+-
+ ###############################################################################
+ CF_HELP_MESSAGE(Testing/development Options:)
+ 
+@@ -983,7 +1030,6 @@
+ geteuid \
+ getttynam \
+ issetugid \
+-memccpy \
+ nanosleep \
+ poll \
+ remove \
+@@ -1042,6 +1088,7 @@
+ if test -n "$CXX" ; then
+ 	AC_LANG_CPLUSPLUS
+ 	CF_STDCPP_LIBRARY
++	CF_PROG_CC_C_O(CXX)
+ 
+ 	case $GXX_VERSION in
+ 	1*|2.[0-6]*)
+@@ -1168,6 +1215,28 @@
+ if test	"$cf_cv_prog_gnat_correct" = yes; then
+    ADAFLAGS="-O3 -gnatpn $ADAFLAGS"
+ 
++   AC_MSG_CHECKING(if GNAT pragma Unreferenced works)
++   CF_GNAT_TRY_LINK([procedure conftest;],
++[with Text_IO;
++with GNAT.OS_Lib;
++procedure conftest is
++   test : Integer;
++   pragma Unreferenced (test);
++begin
++   test := 1;
++   Text_IO.Put ("Hello World");
++   Text_IO.New_Line;
++   GNAT.OS_Lib.OS_Exit (0);
++end conftest;],[cf_cv_pragma_unreferenced=yes],[cf_cv_pragma_unreferenced=no])
++   AC_MSG_RESULT($cf_cv_pragma_unreferenced)
++
++   # if the pragma is supported, use it (needed in the Trace code).
++   if test $cf_cv_pragma_unreferenced = yes ; then
++      PRAGMA_UNREF=TRUE
++   else
++      PRAGMA_UNREF=FALSE
++   fi
++
+    AC_ARG_WITH(ada-compiler,
+ 	[  --with-ada-compiler=CMD specify Ada95 compiler command (default gnatmake)],
+ 	[cf_ada_compiler=$withval],
+@@ -1181,6 +1250,7 @@
+    AC_SUBST(ADAFLAGS)
+    AC_SUBST(cf_compile_generics)
+    AC_SUBST(cf_generic_objects)
++   AC_SUBST(PRAGMA_UNREF)
+ 
+    CF_WITH_PATH(ada-include,
+        [  --with-ada-include=DIR  Ada includes are in DIR],
+@@ -1202,7 +1272,7 @@
+ ### Construct the library-subsets, if any, from this set of keywords:
+ ### none, base, ext_funcs, ext_tinfo, termlib, widechar (see CF_LIB_RULES).
+ AC_MSG_CHECKING(for library subsets)
+-if test "$with_termlib" = yes ; then
++if test "$with_termlib" != no ; then
+ 	LIB_SUBSETS="termlib"
+ 	test "$with_ext_funcs" = yes && LIB_SUBSETS="${LIB_SUBSETS}+ext_tinfo"
+ 	LIB_SUBSETS="${LIB_SUBSETS} "
+@@ -1254,10 +1324,36 @@
+ AC_SUBST(CXX_LIB_SUFFIX)
+ fi
+ 
++### Set up low-level terminfo dependencies for makefiles.
+ TINFO_LIST="$SHLIB_LIST"
+-if test "$with_libtool" = no ; then
+-	test "$with_termlib" = yes && SHLIB_LIST="$SHLIB_LIST -ltinfo${LIB_SUFFIX}"
++if test "$with_termlib" != no ; then
++
++	if test "$with_termlib" != yes ; then
++		TINFO_NAME=$with_termlib
++		TINFO_ARG_SUFFIX="${with_termlib}`echo ${DFT_ARG_SUFFIX}|sed -e "s/^${LIB_SUFFIX}//"`"
++		TINFO_DEP_SUFFIX="${with_termlib}`echo ${DFT_DEP_SUFFIX}|sed -e "s/^${LIB_SUFFIX}//"`"
++		TINFO_LIB_SUFFIX="${with_termlib}"
++	else
++		TINFO_ARG_SUFFIX="${TINFO_NAME}${DFT_ARG_SUFFIX}"
++		TINFO_DEP_SUFFIX="${TINFO_NAME}${DFT_DEP_SUFFIX}"
++		TINFO_LIB_SUFFIX="${TINFO_NAME}${LIB_SUFFIX}"
++	fi
++
++	TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TINFO_DEP_SUFFIX}"
++	if test "$DFT_LWR_MODEL" = "libtool"; then
++		TEST_ARGS="${TEST_DEPS}"
++	else
++		TEST_ARGS="-l${TINFO_ARG_SUFFIX}"
++		TINFO_ARGS="-L${LIB_DIR} $TEST_ARGS"
++		SHLIB_LIST="$SHLIB_LIST -l${TINFO_LIB_SUFFIX}"
++	fi
++else
++	TINFO_ARGS="-L${LIB_DIR} -l${LIB_NAME}${DFT_ARG_SUFFIX}"
+ fi
++AC_SUBST(TINFO_ARG_SUFFIX)
++AC_SUBST(TINFO_DEP_SUFFIX)
++AC_SUBST(TINFO_LIB_SUFFIX)
++AC_SUBST(TINFO_ARGS)
+ 
+ AC_MSG_CHECKING(where we will install curses.h)
+ test "$with_overwrite" = no && \
+@@ -1274,23 +1370,9 @@
+ fi
+ fi
+ 
+-AC_SUBST(EXTRA_LIBS)
+ AC_SUBST(TINFO_LIST)
+ AC_SUBST(SHLIB_LIST)
+ 
+-### Set up low-level terminfo dependencies for makefiles.  Note that we
+-### could override this.
+-if test "$with_termlib" = yes ; then
+-	TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TINFO_NAME}${DFT_DEP_SUFFIX}"
+-	if test "$DFT_LWR_MODEL" = "libtool"; then
+-		TEST_ARGS="${TEST_DEPS}"
+-	else
+-		TEST_ARGS="-l${TINFO_NAME}${DFT_ARG_SUFFIX}"
+-	fi
+-fi
+-PROG_DEPS="$TEST_DEPS"
+-PROG_ARGS="$TEST_ARGS"
+-
+ ### predefined stuff for the test programs
+ AC_DEFINE(HAVE_SLK_COLOR)
+ 
+@@ -1323,6 +1405,7 @@
+ 
+ AWK="$AWK"
+ CF_LIST_MODELS="$cf_list_models"
++DFT_ARG_SUFFIX="$DFT_ARG_SUFFIX"
+ DFT_LWR_MODEL="$DFT_LWR_MODEL"
+ LDCONFIG="$LDCONFIG"
+ LIB_NAME="$LIB_NAME"
+@@ -1333,12 +1416,16 @@
+ NCURSES_OSPEED="$NCURSES_OSPEED"
+ SRC_SUBDIRS="$SRC_SUBDIRS"
+ TERMINFO="$TERMINFO"
++TINFO_ARG_SUFFIX="$TINFO_ARG_SUFFIX"
++TINFO_LIB_SUFFIX="$TINFO_LIB_SUFFIX"
+ TINFO_NAME="$TINFO_NAME"
+ WITH_CURSES_H="$with_curses_h"
+ WITH_ECHO="$with_echo"
+ WITH_OVERWRITE="$with_overwrite"
+ cf_cv_abi_version="$cf_cv_abi_version"
+ cf_cv_do_symlinks="$cf_cv_do_symlinks"
++cf_cv_prog_CC_c_o=$cf_cv_prog_CC_c_o
++cf_cv_prog_CXX_c_o=$cf_cv_prog_CXX_c_o
+ cf_cv_rel_version="$cf_cv_rel_version"
+ cf_cv_rm_so_locs="$cf_cv_rm_so_locs"
+ cf_cv_shlib_version="$cf_cv_shlib_version"
+Index: dist.mk
+Prereq:  1.402 
+--- ncurses-5.4-20040208/dist.mk	2004-02-08 20:56:43.000000000 +0000
++++ ncurses-5.4-20050319/dist.mk	2005-03-19 16:16:46.000000000 +0000
+@@ -1,4 +1,4 @@
+-# $Id: dist.mk,v 1.402 2004/02/08 20:56:43 tom Exp $
++# $Id: dist.mk,v 1.460 2005/03/19 16:16:46 tom Exp $
+ # Makefile for creating ncurses distributions.
+ #
+ # This only needs to be used directly as a makefile by developers, but
+@@ -10,7 +10,7 @@
+ # These define the major/minor/patch versions of ncurses.
+ NCURSES_MAJOR = 5
+ NCURSES_MINOR = 4
+-NCURSES_PATCH = 20040208
++NCURSES_PATCH = 20050319
+ 
+ # We don't append the patch to the version, since this only applies to releases
+ VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
+Index: doc/html/ncurses-intro.html
+Prereq:  1.39 
+--- ncurses-5.4-20040208/doc/html/ncurses-intro.html	2003-10-25 16:19:24.000000000 +0000
++++ ncurses-5.4-20050319/doc/html/ncurses-intro.html	2004-06-05 19:10:10.000000000 +0000
+@@ -1,6 +1,6 @@
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
+ <!--
+-  $Id: ncurses-intro.html,v 1.39 2003/10/25 16:19:24 tom Exp $
++  $Id: ncurses-intro.html,v 1.40 2004/06/05 19:10:10 tom Exp $
+ -->
+ <HTML>
+ <HEAD>
+@@ -687,7 +687,7 @@
+ occurs a message is written to standard error and the program
+ exits. Otherwise it returns a pointer to stdscr.  A few functions may be
+ called before initscr (<CODE>slk_init()</CODE>, <CODE>filter()</CODE>,
+-<CODE>ripofflines()</CODE>, <CODE>use_env()</CODE>, and, if you are using multiple
++<CODE>ripoffline()</CODE>, <CODE>use_env()</CODE>, and, if you are using multiple
+ terminals, <CODE>newterm()</CODE>.)
+ <DT> <CODE>endwin()</CODE>
+ <DD> Your program should always call <CODE>endwin()</CODE> before exiting or
+@@ -729,7 +729,7 @@
+ structures.  <CODE>wrefresh()</CODE> copies the named window  to the physical
+ terminal screen,  taking  into account  what is already
+ there in  order to  do optimizations.  <CODE>refresh()</CODE> does a
+-refresh of <CODE>stdscr()</CODE>.   Unless <CODE>leaveok()</CODE> has been
++refresh of <CODE>stdscr</CODE>.   Unless <CODE>leaveok()</CODE> has been
+ enabled, the physical cursor of the terminal is left at  the
+ location of the window's cursor.
+ <DT> <CODE>doupdate()</CODE> and <CODE>wnoutrefresh(win)</CODE>
+@@ -1017,7 +1017,7 @@
+ 
+ The really clean way to handle this is to use the panels library.  If,
+ when you want a screen update, you do <CODE>update_panels()</CODE>, it will
+-do all the necessary <CODE>wnoutrfresh()</CODE> calls for whatever panel
++do all the necessary <CODE>wnoutrefresh()</CODE> calls for whatever panel
+ stacking order you have defined.  Then you can do one <CODE>doupdate()</CODE>
+ and there will be a <EM>single</EM> burst of physical I/O that will do
+ all your updates.
+@@ -1219,10 +1219,10 @@
+ <LI>Initialize <CODE>curses</CODE>.
+ <LI>Create the menu items, using <CODE>new_item()</CODE>.
+ <LI>Create the menu using <CODE>new_menu()</CODE>.
+-<LI>Post the menu using <CODE>menu_post()</CODE>.
++<LI>Post the menu using <CODE>post_menu()</CODE>.
+ <LI>Refresh the screen.
+ <LI>Process user requests via an input loop.
+-<LI>Unpost the menu using <CODE>menu_unpost()</CODE>.
++<LI>Unpost the menu using <CODE>unpost_menu()</CODE>.
+ <LI>Free the menu, using <CODE>free_menu()</CODE>.
+ <LI>Free the items using <CODE>free_item()</CODE>.
+ <LI>Terminate <CODE>curses</CODE>.
+@@ -1305,8 +1305,8 @@
+ By default, both windows are <CODE>stdscr</CODE>.  You can set them with the
+ functions in <CODE>menu_win(3x)</CODE>. <P>
+ 
+-When you call <CODE>menu_post()</CODE>, you write the menu to its
+-subwindow.  When you call <CODE>menu_unpost()</CODE>, you erase the
++When you call <CODE>post_menu()</CODE>, you write the menu to its
++subwindow.  When you call <CODE>unpost_menu()</CODE>, you erase the
+ subwindow, However, neither of these actually modifies the screen.  To
+ do that, call <CODE>wrefresh()</CODE> or some equivalent.
+ 
+@@ -1438,10 +1438,10 @@
+ <LI>Initialize <CODE>curses</CODE>.
+ <LI>Create the form fields, using <CODE>new_field()</CODE>.
+ <LI>Create the form using <CODE>new_form()</CODE>.
+-<LI>Post the form using <CODE>form_post()</CODE>.
++<LI>Post the form using <CODE>post_form()</CODE>.
+ <LI>Refresh the screen.
+ <LI>Process user requests via an input loop.
+-<LI>Unpost the form using <CODE>form_unpost()</CODE>.
++<LI>Unpost the form using <CODE>unpost_form()</CODE>.
+ <LI>Free the form, using <CODE>free_form()</CODE>.
+ <LI>Free the fields using <CODE>free_field()</CODE>.
+ <LI>Terminate <CODE>curses</CODE>.
+@@ -1477,7 +1477,7 @@
+ greater). Note that these coordinates are relative to the form
+ subwindow, which will coincide with <CODE>stdscr</CODE> by default but
+ need not be <CODE>stdscr</CODE> if you've done an explicit
+-<CODE>set_form_window()</CODE> call. <P>
++<CODE>set_form_win()</CODE> call. <P>
+ 
+ The fifth argument allows you to specify a number of off-screen rows.  If
+ this is zero, the entire field will always be displayed.  If it is
+Index: doc/ncurses-intro.doc
+--- ncurses-5.4-20040208/doc/ncurses-intro.doc	2003-10-25 16:15:12.000000000 +0000
++++ ncurses-5.4-20050319/doc/ncurses-intro.doc	2004-06-05 19:23:21.000000000 +0000
+@@ -609,7 +609,7 @@
+           refresh()  will  clear the screen. If an error occurs a message
+           is  written  to standard error and the program exits. Otherwise
+           it  returns  a pointer to stdscr. A few functions may be called
+-          before initscr (slk_init(), filter(), ripofflines(), use_env(),
++          before  initscr (slk_init(), filter(), ripoffline(), use_env(),
+           and, if you are using multiple terminals, newterm().)
+ 
+    endwin()
+@@ -651,10 +651,9 @@
+           the   terminal,   as  other  routines  merely  manipulate  data
+           structures.  wrefresh() copies the named window to the physical
+           terminal  screen,  taking into account what is already there in
+-          order   to  do  optimizations.  refresh()  does  a  refresh  of
+-          stdscr().  Unless  leaveok()  has  been  enabled,  the physical
+-          cursor  of the terminal is left at the location of the window's
+-          cursor.
++          order  to do optimizations. refresh() does a refresh of stdscr.
++          Unless  leaveok()  has been enabled, the physical cursor of the
++          terminal is left at the location of the window's cursor.
+ 
+    doupdate() and wnoutrefresh(win)
+           These two functions allow multiple updates with more efficiency
+@@ -929,7 +928,7 @@
+ 
+    The  really clean way to handle this is to use the panels library. If,
+    when  you want a screen update, you do update_panels(), it will do all
+-   the  necessary  wnoutrfresh()  calls for whatever panel stacking order
++   the  necessary  wnoutrefresh() calls for whatever panel stacking order
+    you  have  defined. Then you can do one doupdate() and there will be a
+    single burst of physical I/O that will do all your updates.
+ 
+@@ -1115,10 +1114,10 @@
+     1. Initialize curses.
+     2. Create the menu items, using new_item().
+     3. Create the menu using new_menu().
+-    4. Post the menu using menu_post().
++    4. Post the menu using post_menu().
+     5. Refresh the screen.
+     6. Process user requests via an input loop.
+-    7. Unpost the menu using menu_unpost().
++    7. Unpost the menu using unpost_menu().
+     8. Free the menu, using free_menu().
+     9. Free the items using free_item().
+    10. Terminate curses.
+@@ -1198,8 +1197,8 @@
+    By  default,  both  windows  are  stdscr.  You  can  set them with the
+    functions in menu_win(3x).
+ 
+-   When  you  call menu_post(), you write the menu to its subwindow. When
+-   you  call  menu_unpost(), you erase the subwindow, However, neither of
++   When  you  call post_menu(), you write the menu to its subwindow. When
++   you  call  unpost_menu(), you erase the subwindow, However, neither of
+    these  actually  modifies  the  screen. To do that, call wrefresh() or
+    some equivalent.
+ 
+@@ -1315,10 +1314,10 @@
+     1. Initialize curses.
+     2. Create the form fields, using new_field().
+     3. Create the form using new_form().
+-    4. Post the form using form_post().
++    4. Post the form using post_form().
+     5. Refresh the screen.
+     6. Process user requests via an input loop.
+-    7. Unpost the form using form_unpost().
++    7. Unpost the form using unpost_form().
+     8. Free the form, using free_form().
+     9. Free the fields using free_field().
+    10. Terminate curses.
+@@ -1350,7 +1349,7 @@
+    the  screen  (the  third  and  fourth arguments, which must be zero or
+    greater).  Note  that  these  coordinates  are  relative  to  the form
+    subwindow,  which will coincide with stdscr by default but need not be
+-   stdscr if you've done an explicit set_form_window() call.
++   stdscr if you've done an explicit set_form_win() call.
+ 
+    The  fifth argument allows you to specify a number of off-screen rows.
+    If  this  is zero, the entire field will always be displayed. If it is
+@@ -2345,9 +2344,9 @@
+ 
+    O_NL_OVERLOAD
+           Enable  overloading  of  REQ_NEW_LINE  as  described in Editing
+-          Requests.  The  value  of  this  option  is  ignored on dynamic
+-          fields  that  have  not reached their size limit; these have no
+-          last line, so the circumstances for triggering a REQ_NEXT_FIELD
++          Requests. The value of this option is ignored on dynamic fields
++          that  have  not  reached  their  size limit; these have no last
++          line,  so  the  circumstances  for  triggering a REQ_NEXT_FIELD
+           never arise.
+ 
+    O_BS_OVERLOAD
+Index: form/Makefile.in
+Prereq:  1.40 
+--- ncurses-5.4-20040208/form/Makefile.in	2003-11-01 22:44:33.000000000 +0000
++++ ncurses-5.4-20050319/form/Makefile.in	2004-05-08 19:14:14.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: Makefile.in,v 1.40 2003/11/01 22:44:33 tom Exp $
++# $Id: Makefile.in,v 1.41 2004/05/08 19:14:14 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2003,2004 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"), #
+@@ -79,8 +79,7 @@
+ CPP		= @CPP@
+ CFLAGS		= @CFLAGS@
+ 
+-CPPFLAGS	= @CPPFLAGS@ \
+-		  -DHAVE_CONFIG_H 
++CPPFLAGS	= -I@top_srcdir@/ncurses -DHAVE_CONFIG_H @CPPFLAGS@
+ 
+ CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
+ 
+@@ -116,7 +115,7 @@
+ LINT_LIBS	= -lform -lncurses @LIBS@
+ 
+ AUTO_SRC	= \
+-		../include/form.h  
++		../include/form.h
+ 
+ ################################################################################
+ all \
+Index: form/f_trace.c
+--- /dev/null	2004-09-12 00:40:36.000000000 +0000
++++ ncurses-5.4-20050319/form/f_trace.c	2004-12-25 23:28:49.000000000 +0000
+@@ -0,0 +1,70 @@
++/****************************************************************************
++ * Copyright (c) 2004 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"), to deal in the Software without restriction, including      *
++ * without limitation the rights to use, copy, modify, merge, publish,      *
++ * distribute, distribute with modifications, sublicense, and/or sell       *
++ * copies of the Software, and to permit persons to whom the Software is    *
++ * furnished to do so, subject to the following conditions:                 *
++ *                                                                          *
++ * The above copyright notice and this permission notice shall be included  *
++ * in all copies or substantial portions of the Software.                   *
++ *                                                                          *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
++ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
++ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
++ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
++ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
++ *                                                                          *
++ * Except as contained in this notice, the name(s) of the above copyright   *
++ * holders shall not be used in advertising or otherwise to promote the     *
++ * sale, use or other dealings in this Software without prior written       *
++ * authorization.                                                           *
++ ****************************************************************************/
++
++/****************************************************************************
++ *   Author:  Thomas E. Dickey                                              *
++ ****************************************************************************/
++
++#include "form.priv.h"
++
++MODULE_ID("$Id: f_trace.c,v 1.1 2004/12/25 23:28:49 tom Exp $")
++
++NCURSES_EXPORT(FIELD **)
++_nc_retrace_field_ptr(FIELD **code)
++{
++  T((T_RETURN("%p"), code));
++  return code;
++}
++
++NCURSES_EXPORT(FIELD *)
++_nc_retrace_field(FIELD *code)
++{
++  T((T_RETURN("%p"), code));
++  return code;
++}
++
++NCURSES_EXPORT(FIELDTYPE *)
++_nc_retrace_field_type(FIELDTYPE *code)
++{
++  T((T_RETURN("%p"), code));
++  return code;
++}
++
++NCURSES_EXPORT(FORM *)
++_nc_retrace_form(FORM *code)
++{
++  T((T_RETURN("%p"), code));
++  return code;
++}
++
++NCURSES_EXPORT(Form_Hook)
++_nc_retrace_form_hook(Form_Hook code)
++{
++  T((T_RETURN("%p"), code));
++  return code;
++}
+Index: form/fld_arg.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_arg.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_arg.c	2004-12-25 22:20:18.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,16 +32,16 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_arg.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_arg.c,v 1.11 2004/12/25 22:20:18 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int set_fieldtype_arg(
+ |                            FIELDTYPE *typ,
+ |                            void * (* const make_arg)(va_list *),
+ |                            void * (* const copy_arg)(const void *),
+ |                            void   (* const free_arg)(void *) )
+-|   
++|
+ |   Description   :  Connects to the type additional arguments necessary
+ |                    for a set_field_type call. The various function pointer
+ |                    arguments are:
+@@ -61,34 +61,38 @@
+ |                    E_BAD_ARGUMENT - invalid argument
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_fieldtype_arg
+-    (FIELDTYPE * typ,
+-     void * (* const make_arg)(va_list *),
+-     void * (* const copy_arg)(const void *),
+-     void   (* const free_arg)(void *))
++set_fieldtype_arg(FIELDTYPE *typ,
++		  void *(*const make_arg)(va_list *),
++		  void *(*const copy_arg)(const void *),
++		  void (*const free_arg) (void *))
+ {
+-  if ( !typ || !make_arg )
+-    RETURN(E_BAD_ARGUMENT);
++  T((T_CALLED("set_fieldtype_arg(%p,%p,%p,%p)"),
++     typ, make_arg, copy_arg, free_arg));
+ 
+-  typ->status |= _HAS_ARGS;
+-  typ->makearg = make_arg;
+-  typ->copyarg = copy_arg;
+-  typ->freearg = free_arg;
+-  RETURN(E_OK);
++  if (typ != 0 && make_arg != (void *)0)
++    {
++      typ->status |= _HAS_ARGS;
++      typ->makearg = make_arg;
++      typ->copyarg = copy_arg;
++      typ->freearg = free_arg;
++      RETURN(E_OK);
++    }
++  RETURN(E_BAD_ARGUMENT);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  void *field_arg(const FIELD *field)
+-|   
++|
+ |   Description   :  Retrieve pointer to the fields argument structure.
+ |
+ |   Return Values :  Pointer to structure or NULL if none is defined.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void *)
+-field_arg (const FIELD * field)
++field_arg(const FIELD *field)
+ {
+-  return Normalize_Field(field)->arg;
++  T((T_CALLED("field_arg(%p)"), field));
++  returnVoidPtr(Normalize_Field(field)->arg);
+ }
+ 
+ /* fld_arg.c ends here */
+Index: form/fld_attr.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_attr.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_attr.c	2004-12-11 21:33:15.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_attr.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_attr.c,v 1.10 2004/12/11 21:33:15 tom Exp $")
+ 
+ /*----------------------------------------------------------------------------
+   Field-Attribute manipulation routines
+@@ -42,16 +42,22 @@
+ NCURSES_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\
+ {\
+    int res = E_BAD_ARGUMENT;\
++   T((T_CALLED("set_field_" #name "(%p,%s)"), field, _traceattr(attr)));\
+    if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\
+      {\
+        Normalize_Field( field );\
+-       if ((field -> name) != attr)\
+-         {\
+-           field -> name = attr;\
+-           res = _nc_Synchronize_Attributes( field );\
+-         }\
+-       else\
+-	 res = E_OK;\
++       if (field != 0) \
++	 { \
++	 if ((field -> name) != attr)\
++	   {\
++	     field -> name = attr;\
++	     res = _nc_Synchronize_Attributes( field );\
++	   }\
++	 else\
++	   {\
++	     res = E_OK;\
++	   }\
++	 }\
+      }\
+    RETURN(res);\
+ }
+@@ -60,13 +66,14 @@
+ #define GEN_FIELD_ATTR_GET_FCT( name ) \
+ NCURSES_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\
+ {\
+-   return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
++   T((T_CALLED("field_" #name "(%p)"), field));\
++   returnAttr( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int set_field_fore(FIELD *field, chtype attr)
+-|   
++|
+ |   Description   :  Sets the foreground of the field used to display the
+ |                    field contents.
+ |
+@@ -74,22 +81,22 @@
+ |                    E_BAD_ARGUMENT   - invalid attributes
+ |                    E_SYSTEM_ERROR   - system error
+ +--------------------------------------------------------------------------*/
+-GEN_FIELD_ATTR_SET_FCT( fore )
++GEN_FIELD_ATTR_SET_FCT(fore)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  chtype field_fore(const FIELD *)
+-|   
++|
+ |   Description   :  Retrieve fields foreground attribute
+ |
+ |   Return Values :  The foreground attribute
+ +--------------------------------------------------------------------------*/
+-GEN_FIELD_ATTR_GET_FCT( fore )
++GEN_FIELD_ATTR_GET_FCT(fore)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int set_field_back(FIELD *field, chtype attr)
+-|   
++|
+ |   Description   :  Sets the background of the field used to display the
+ |                    fields extend.
+ |
+@@ -97,16 +104,16 @@
+ |                    E_BAD_ARGUMENT   - invalid attributes
+ |                    E_SYSTEM_ERROR   - system error
+ +--------------------------------------------------------------------------*/
+-GEN_FIELD_ATTR_SET_FCT( back )
++GEN_FIELD_ATTR_SET_FCT(back)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform
+-|   Function      :  chtype field_back(const 
+-|   
++|   Function      :  chtype field_back(const
++|
+ |   Description   :  Retrieve fields background attribute
+ |
+ |   Return Values :  The background attribute
+ +--------------------------------------------------------------------------*/
+-GEN_FIELD_ATTR_GET_FCT( back )
++GEN_FIELD_ATTR_GET_FCT(back)
+ 
+ /* fld_attr.c ends here */
+Index: form/fld_current.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_current.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_current.c	2004-12-25 22:40:13.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,12 +32,12 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_current.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_current.c,v 1.11 2004/12/25 22:40:13 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int set_current_field(FORM  * form,FIELD * field)
+-|   
++|
+ |   Description   :  Set the current field of the form to the specified one.
+ |
+ |   Return Values :  E_OK              - success
+@@ -48,46 +48,53 @@
+ |                    E_SYSTEM_ERROR    - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_current_field (FORM  * form, FIELD * field)
++set_current_field(FORM *form, FIELD *field)
+ {
+   int err = E_OK;
+ 
+-  if ( !form || !field )
+-    RETURN(E_BAD_ARGUMENT);
+-
+-  if ( (form != field->form) || Field_Is_Not_Selectable(field) )
+-    RETURN(E_REQUEST_DENIED);
+-
+-  if (!(form->status & _POSTED))
++  T((T_CALLED("set_current_field(%p,%p)"), form, field));
++  if (form == 0 || field == 0)
++    {
++      RETURN(E_BAD_ARGUMENT);
++    }
++  else if ((form != field->form) || Field_Is_Not_Selectable(field))
++    {
++      RETURN(E_REQUEST_DENIED);
++    }
++  else if ((form->status & _POSTED) == 0)
+     {
+       form->current = field;
+       form->curpage = field->page;
+-  }
++    }
+   else
+     {
+-      if (form->status & _IN_DRIVER) 
+-	err = E_BAD_STATE;
++      if ((form->status & _IN_DRIVER) != 0)
++	{
++	  err = E_BAD_STATE;
++	}
+       else
+ 	{
+ 	  if (form->current != field)
+ 	    {
+-	      if (!_nc_Internal_Validation(form)) 
+-	       err = E_INVALID_FIELD;
++	      if (!_nc_Internal_Validation(form))
++		{
++		  err = E_INVALID_FIELD;
++		}
+ 	      else
+ 		{
+-		  Call_Hook(form,fieldterm);
++		  Call_Hook(form, fieldterm);
+ 		  if (field->page != form->curpage)
+ 		    {
+-		      Call_Hook(form,formterm);
+-		      err = _nc_Set_Form_Page(form,field->page,field);
+-		      Call_Hook(form,forminit);
+-		    } 
+-		  else 
++		      Call_Hook(form, formterm);
++		      err = _nc_Set_Form_Page(form, (int)field->page, field);
++		      Call_Hook(form, forminit);
++		    }
++		  else
+ 		    {
+-		      err = _nc_Set_Current_Field(form,field);
++		      err = _nc_Set_Current_Field(form, field);
+ 		    }
+-		  Call_Hook(form,fieldinit);
+-		  _nc_Refresh_Current_Field(form);
++		  Call_Hook(form, fieldinit);
++		  (void)_nc_Refresh_Current_Field(form);
+ 		}
+ 	    }
+ 	}
+@@ -96,23 +103,24 @@
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  FIELD *current_field(const FORM * form)
+-|   
++|
+ |   Description   :  Return the current field.
+ |
+ |   Return Values :  Pointer to the current field.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(FIELD *)
+-current_field (const FORM * form)
++current_field(const FORM *form)
+ {
+-  return Normalize_Form(form)->current;
++  T((T_CALLED("current_field(%p)"), form));
++  returnField(Normalize_Form(form)->current);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int field_index(const FIELD * field)
+-|   
++|
+ |   Description   :  Return the index of the field in the field-array of
+ |                    the form.
+ |
+@@ -120,9 +128,10 @@
+ |                    -1     : fieldpointer invalid or field not connected
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-field_index (const FIELD * field)
++field_index(const FIELD *field)
+ {
+-  return ( (field && field->form) ? field->index : -1 );
++  T((T_CALLED("field_index(%p)"), field));
++  returnCode((field != 0 && field->form != 0) ? (int)field->index : -1);
+ }
+ 
+ /* fld_current.c ends here */
+Index: form/fld_def.c
+Prereq:  1.17 
+--- ncurses-5.4-20040208/form/fld_def.c	2003-11-08 21:15:02.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_def.c	2005-01-16 01:02:23.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,291 +32,319 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_def.c,v 1.17 2003/11/08 21:15:02 Jonathon.Gray Exp $")
++MODULE_ID("$Id: fld_def.c,v 1.32 2005/01/16 01:02:23 tom Exp $")
+ 
+ /* this can't be readonly */
+-static FIELD default_field = {
+-  0,                       /* status */
+-  0,                       /* rows   */
+-  0,                       /* cols   */
+-  0,                       /* frow   */
+-  0,                       /* fcol   */
+-  0,                       /* drows  */
+-  0,                       /* dcols  */
+-  0,                       /* maxgrow*/
+-  0,                       /* nrow   */
+-  0,                       /* nbuf   */
+-  NO_JUSTIFICATION,        /* just   */
+-  0,                       /* page   */
+-  0,                       /* index  */
+-  (int)' ',                /* pad    */
+-  A_NORMAL,                /* fore   */
+-  A_NORMAL,                /* back   */
+-  ALL_FIELD_OPTS,          /* opts   */
+-  (FIELD *)0,              /* snext  */
+-  (FIELD *)0,              /* sprev  */
+-  (FIELD *)0,              /* link   */
+-  (FORM *)0,               /* form   */
+-  (FIELDTYPE *)0,          /* type   */
+-  (char *)0,               /* arg    */ 
+-  (char *)0,               /* buf    */
+-  (char *)0                /* usrptr */
++static FIELD default_field =
++{
++  0,				/* status  */
++  0,				/* rows    */
++  0,				/* cols    */
++  0,				/* frow    */
++  0,				/* fcol    */
++  0,				/* drows   */
++  0,				/* dcols   */
++  0,				/* maxgrow */
++  0,				/* nrow    */
++  0,				/* nbuf    */
++  NO_JUSTIFICATION,		/* just    */
++  0,				/* page    */
++  0,				/* index   */
++  (int)' ',			/* pad     */
++  A_NORMAL,			/* fore    */
++  A_NORMAL,			/* back    */
++  ALL_FIELD_OPTS,		/* opts    */
++  (FIELD *)0,			/* snext   */
++  (FIELD *)0,			/* sprev   */
++  (FIELD *)0,			/* link    */
++  (FORM *)0,			/* form    */
++  (FIELDTYPE *)0,		/* type    */
++  (char *)0,			/* arg     */
++  (FIELD_CELL *)0,		/* buf     */
++  (char *)0			/* usrptr  */
++  NCURSES_FIELD_EXTENSION
+ };
+ 
+-NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field = &default_field;
+-
++NCURSES_EXPORT_VAR(FIELD *)
++_nc_Default_Field = &default_field;
++
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  TypeArgument *_nc_Make_Argument(
+ |                              const FIELDTYPE *typ,
+ |                              va_list *ap,
+ |                              int *err )
+-|   
++|
+ |   Description   :  Create an argument structure for the specified type.
+ |                    Use the type-dependent argument list to construct
+ |                    it.
+ |
+ |   Return Values :  Pointer to argument structure. Maybe NULL.
+-|                    In case of an error in *err an error counter is increased. 
++|                    In case of an error in *err an error counter is increased.
+ +--------------------------------------------------------------------------*/
+-NCURSES_EXPORT(TypeArgument*)
+-_nc_Make_Argument
+-(const FIELDTYPE *typ, va_list *ap, int *err)
++NCURSES_EXPORT(TypeArgument *)
++_nc_Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err)
+ {
+-  TypeArgument *res = (TypeArgument *)0; 
++  TypeArgument *res = (TypeArgument *)0;
+   TypeArgument *p;
+ 
+-  if (typ && (typ->status & _HAS_ARGS))
++  if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
+     {
+-      assert(err && ap);
+-      if (typ->status & _LINKED_TYPE)
++      assert(err != 0 && ap != (va_list *)0);
++      if ((typ->status & _LINKED_TYPE) != 0)
+ 	{
+ 	  p = (TypeArgument *)malloc(sizeof(TypeArgument));
+-	  if (p) 
++
++	  if (p != 0)
+ 	    {
+-	      p->left  = _nc_Make_Argument(typ->left ,ap,err);
+-	      p->right = _nc_Make_Argument(typ->right,ap,err);
++	      p->left = _nc_Make_Argument(typ->left, ap, err);
++	      p->right = _nc_Make_Argument(typ->right, ap, err);
+ 	      return p;
+ 	    }
+ 	  else
+-	    *err += 1;
+-      } else 
++	    {
++	      *err += 1;
++	    }
++	}
++      else
+ 	{
+-	  assert(typ->makearg);
+-	  if ( !(res=(TypeArgument *)typ->makearg(ap)) ) 
+-	    *err += 1;
++	  assert(typ->makearg != (void *)0);
++	  if (!(res = (TypeArgument *)typ->makearg(ap)))
++	    {
++	      *err += 1;
++	    }
+ 	}
+     }
+   return res;
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  TypeArgument *_nc_Copy_Argument(const FIELDTYPE *typ,
+ |                                                    const TypeArgument *argp,
+ |                                                    int *err )
+-|   
+-|   Description   :  Create a copy of an argument structure for the specified 
++|
++|   Description   :  Create a copy of an argument structure for the specified
+ |                    type.
+ |
+ |   Return Values :  Pointer to argument structure. Maybe NULL.
+-|                    In case of an error in *err an error counter is increased. 
++|                    In case of an error in *err an error counter is increased.
+ +--------------------------------------------------------------------------*/
+-NCURSES_EXPORT(TypeArgument*)
+-_nc_Copy_Argument
+-    (const FIELDTYPE *typ,
+-     const TypeArgument *argp, int *err)
++NCURSES_EXPORT(TypeArgument *)
++_nc_Copy_Argument(const FIELDTYPE *typ, const TypeArgument *argp, int *err)
+ {
+   TypeArgument *res = (TypeArgument *)0;
+   TypeArgument *p;
+ 
+-  if ( typ && (typ->status & _HAS_ARGS) )
++  if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
+     {
+-      assert(err && argp);
+-      if (typ->status & _LINKED_TYPE)
++      assert(err != 0 && argp != 0);
++      if ((typ->status & _LINKED_TYPE) != 0)
+ 	{
+ 	  p = (TypeArgument *)malloc(sizeof(TypeArgument));
+-	  if (p)
++
++	  if (p != 0)
+ 	    {
+-	      p->left  = _nc_Copy_Argument(typ,argp->left ,err);
+-	      p->right = _nc_Copy_Argument(typ,argp->right,err);
++	      p->left = _nc_Copy_Argument(typ, argp->left, err);
++	      p->right = _nc_Copy_Argument(typ, argp->right, err);
+ 	      return p;
+ 	    }
+ 	  *err += 1;
+-      } 
+-      else 
++	}
++      else
+ 	{
+-	  if (typ->copyarg)
++	  if (typ->copyarg != (void *)0)
+ 	    {
+-	      if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp)))) 
+-		*err += 1;
++	      if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp))))
++		{
++		  *err += 1;
++		}
+ 	    }
+ 	  else
+-	    res = (TypeArgument *)argp;
++	    {
++	      res = (TypeArgument *)argp;
++	    }
+ 	}
+     }
+   return res;
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  void _nc_Free_Argument(const FIELDTYPE *typ,
+ |                                           TypeArgument * argp )
+-|   
++|
+ |   Description   :  Release memory associated with the argument structure
+ |                    for the given fieldtype.
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-_nc_Free_Argument
+-(const FIELDTYPE * typ, TypeArgument * argp)
++_nc_Free_Argument(const FIELDTYPE *typ, TypeArgument *argp)
+ {
+-  if (!typ || !(typ->status & _HAS_ARGS)) 
+-    return;
+-  
+-  if (typ->status & _LINKED_TYPE)
+-    {
+-      assert(argp);
+-      _nc_Free_Argument(typ->left ,argp->left );
+-      _nc_Free_Argument(typ->right,argp->right);
+-      free(argp);
+-    } 
+-  else 
++  if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
+     {
+-      if (typ->freearg)
+-	typ->freearg((void *)argp);
++      if ((typ->status & _LINKED_TYPE) != 0)
++	{
++	  assert(argp != 0);
++	  _nc_Free_Argument(typ->left, argp->left);
++	  _nc_Free_Argument(typ->right, argp->right);
++	  free(argp);
++	}
++      else
++	{
++	  if (typ->freearg != (void *)0)
++	    {
++	      typ->freearg((void *)argp);
++	    }
++	}
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  bool _nc_Copy_Type( FIELD *dst, FIELD const *src )
+-|   
++|
+ |   Description   :  Copy argument structure of field src to field dst
+ |
+ |   Return Values :  TRUE       - copy worked
+ |                    FALSE      - error occurred
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(bool)
+-_nc_Copy_Type
+-(FIELD *dst, FIELD const *src)
++_nc_Copy_Type(FIELD *dst, FIELD const *src)
+ {
+   int err = 0;
+ 
+-  assert(dst && src);
++  assert(dst != 0 && src != 0);
+ 
+   dst->type = src->type;
+-  dst->arg  = (void *)_nc_Copy_Argument(src->type,(TypeArgument *)(src->arg),&err);
++  dst->arg = (void *)_nc_Copy_Argument(src->type, (TypeArgument *)(src->arg), &err);
+ 
+-  if (err)
++  if (err != 0)
+     {
+-      _nc_Free_Argument(dst->type,(TypeArgument *)(dst->arg));
++      _nc_Free_Argument(dst->type, (TypeArgument *)(dst->arg));
+       dst->type = (FIELDTYPE *)0;
+-      dst->arg  = (void *)0;
++      dst->arg = (void *)0;
+       return FALSE;
+     }
+   else
+     {
+-      if (dst->type) 
+-	dst->type->ref++;
++      if (dst->type != 0)
++	{
++	  dst->type->ref++;
++	}
+       return TRUE;
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  void _nc_Free_Type( FIELD *field )
+-|   
++|
+ |   Description   :  Release Argument structure for this field
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-_nc_Free_Type (FIELD *field)
++_nc_Free_Type(FIELD *field)
+ {
+-  assert(field);
+-  if (field->type) 
+-    field->type->ref--;
+-  _nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
++  assert(field != 0);
++  if (field->type != 0)
++    {
++      field->type->ref--;
++    }
++  _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  FIELD *new_field( int rows, int cols, 
++|   Facility      :  libnform
++|   Function      :  FIELD *new_field( int rows, int cols,
+ |                                      int frow, int fcol,
+ |                                      int nrow, int nbuf )
+-|   
++|
+ |   Description   :  Create a new field with this many 'rows' and 'cols',
+ |                    starting at 'frow/fcol' in the subwindow of the form.
+ |                    Allocate 'nrow' off-screen rows and 'nbuf' additional
+ |                    buffers. If an error occurs, errno is set to
+-|                    
++|
+ |                    E_BAD_ARGUMENT - invalid argument
+ |                    E_SYSTEM_ERROR - system error
+ |
+ |   Return Values :  Pointer to the new field or NULL if failure.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(FIELD *)
+-new_field
+-(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
++new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
+ {
++  static const FIELD_CELL blank = BLANK;
++  static const FIELD_CELL zeros = ZEROS;
++
+   FIELD *New_Field = (FIELD *)0;
+   int err = E_BAD_ARGUMENT;
+ 
+-  if (rows>0  && 
+-      cols>0  && 
+-      frow>=0 && 
+-      fcol>=0 && 
+-      nrow>=0 && 
+-      nbuf>=0 &&
+-      ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
+-      (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
+-    {
+-      *New_Field       = default_field;
+-      New_Field->rows  = rows;
+-      New_Field->cols  = cols;
++  T((T_CALLED("new_field(%d,%d,%d,%d,%d,%d)"), rows, cols, frow, fcol, nrow, nbuf));
++  if (rows > 0 &&
++      cols > 0 &&
++      frow >= 0 &&
++      fcol >= 0 &&
++      nrow >= 0 &&
++      nbuf >= 0 &&
++      ((err = E_SYSTEM_ERROR) != 0) &&	/* trick: this resets the default error */
++      (New_Field = (FIELD *)malloc(sizeof(FIELD))) != 0)
++    {
++      *New_Field = default_field;
++      New_Field->rows = rows;
++      New_Field->cols = cols;
+       New_Field->drows = rows + nrow;
+       New_Field->dcols = cols;
+-      New_Field->frow  = frow;
+-      New_Field->fcol  = fcol;
+-      New_Field->nrow  = nrow;
+-      New_Field->nbuf  = nbuf;
+-      New_Field->link  = New_Field;
++      New_Field->frow = frow;
++      New_Field->fcol = fcol;
++      New_Field->nrow = nrow;
++      New_Field->nbuf = nbuf;
++      New_Field->link = New_Field;
++
++#if USE_WIDEC_SUPPORT
++      New_Field->working = newpad(1, Buffer_Length(New_Field) + 1);
++      New_Field->expanded = (char **)calloc(1 + rows, sizeof(char *));
++#endif
+ 
+-      if (_nc_Copy_Type(New_Field,&default_field))
++      if (_nc_Copy_Type(New_Field, &default_field))
+ 	{
+ 	  size_t len;
+ 
+ 	  len = Total_Buffer_Size(New_Field);
+-	  if ((New_Field->buf = (char *)malloc(len)))
++	  if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
+ 	    {
+ 	      /* Prefill buffers with blanks and insert terminating zeroes
+-		 between buffers */
+-	      int i;
++	         between buffers */
++	      int i, j;
++	      int cells = Buffer_Length(New_Field);
+ 
+-	      memset(New_Field->buf,' ',len);
+-	      for(i=0;i<=New_Field->nbuf;i++)
++	      for (i = 0; i <= New_Field->nbuf; i++)
+ 		{
+-		  New_Field->buf[(New_Field->drows*New_Field->cols+1)*(i+1)-1]
+-		    = '\0';
++		  FIELD_CELL *buffer = &(New_Field->buf[(cells + 1) * i]);
++
++		  for (j = 0; j < cells; ++j)
++		    {
++		      buffer[j] = blank;
++		    }
++		  buffer[j] = zeros;
+ 		}
+-	      return New_Field;
++	      returnField(New_Field);
+ 	    }
+ 	}
+     }
+ 
+-  if (New_Field) 
++  if (New_Field)
+     free_field(New_Field);
+-  
+-  SET_ERROR( err );
+-  return (FIELD *)0;
++
++  SET_ERROR(err);
++  returnField((FIELD *)0);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int free_field( FIELD *field )
+-|   
++|
+ |   Description   :  Frees the storage allocated for the field.
+ |
+ |   Return Values :  E_OK           - success
+@@ -324,28 +352,45 @@
+ |                    E_CONNECTED    - field is connected
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-free_field (FIELD * field)
++free_field(FIELD *field)
+ {
+-  if (!field) 
+-    RETURN(E_BAD_ARGUMENT);
+-
+-  if (field->form)
+-    RETURN(E_CONNECTED);
+-  
+-  if (field == field->link)
++  T((T_CALLED("free_field(%p)"), field));
++  if (!field)
+     {
+-      if (field->buf) 
++      RETURN(E_BAD_ARGUMENT);
++    }
++  else if (field->form != 0)
++    {
++      RETURN(E_CONNECTED);
++    }
++  else if (field == field->link)
++    {
++      if (field->buf != 0)
+ 	free(field->buf);
+     }
+-  else 
++  else
+     {
+       FIELD *f;
+ 
+-      for(f=field;f->link != field;f = f->link) 
+-	{}
++      for (f = field; f->link != field; f = f->link)
++	{
++	}
+       f->link = field->link;
+     }
+   _nc_Free_Type(field);
++#if USE_WIDEC_SUPPORT
++  if (field->expanded != 0)
++    {
++      int n;
++
++      for (n = 0; n <= field->nbuf; ++n)
++	{
++	  FreeIfNeeded(field->expanded[n]);
++	}
++      free(field->expanded);
++      (void)delwin(field->working);
++    }
++#endif
+   free(field);
+   RETURN(E_OK);
+ }
+Index: form/fld_dup.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_dup.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_dup.c	2004-12-25 22:24:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,67 +32,69 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_dup.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_dup.c,v 1.10 2004/12/25 22:24:10 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  FIELD *dup_field(FIELD *field, int frow, int fcol)
+-|   
++|
+ |   Description   :  Duplicates the field at the specified position. All
+ |                    field attributes and the buffers are copied.
+ |                    If an error occurs, errno is set to
+-|                    
++|
+ |                    E_BAD_ARGUMENT - invalid argument
+ |                    E_SYSTEM_ERROR - system error
+ |
+ |   Return Values :  Pointer to the new field or NULL if failure
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(FIELD *)
+-dup_field (FIELD * field, int frow, int fcol)
++dup_field(FIELD *field, int frow, int fcol)
+ {
+   FIELD *New_Field = (FIELD *)0;
+   int err = E_BAD_ARGUMENT;
+ 
+-  if (field && (frow>=0) && (fcol>=0) && 
+-      ((err=E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */
+-      (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
++  T((T_CALLED("dup_field(%p,%d,%d)"), field, frow, fcol));
++  if (field && (frow >= 0) && (fcol >= 0) &&
++      ((err = E_SYSTEM_ERROR) != 0) &&	/* trick : this resets the default error */
++      (New_Field = (FIELD *)malloc(sizeof(FIELD))))
+     {
+-      *New_Field         = *_nc_Default_Field;
+-      New_Field->frow    = frow;
+-      New_Field->fcol    = fcol;
+-      New_Field->link    = New_Field;
+-      New_Field->rows    = field->rows;
+-      New_Field->cols    = field->cols;
+-      New_Field->nrow    = field->nrow;
+-      New_Field->drows   = field->drows;
+-      New_Field->dcols   = field->dcols;
++      *New_Field = *_nc_Default_Field;
++      New_Field->frow = frow;
++      New_Field->fcol = fcol;
++      New_Field->link = New_Field;
++      New_Field->rows = field->rows;
++      New_Field->cols = field->cols;
++      New_Field->nrow = field->nrow;
++      New_Field->drows = field->drows;
++      New_Field->dcols = field->dcols;
+       New_Field->maxgrow = field->maxgrow;
+-      New_Field->nbuf    = field->nbuf;
+-      New_Field->just    = field->just;
+-      New_Field->fore    = field->fore;
+-      New_Field->back    = field->back;
+-      New_Field->pad     = field->pad;
+-      New_Field->opts    = field->opts;
+-      New_Field->usrptr  = field->usrptr;
++      New_Field->nbuf = field->nbuf;
++      New_Field->just = field->just;
++      New_Field->fore = field->fore;
++      New_Field->back = field->back;
++      New_Field->pad = field->pad;
++      New_Field->opts = field->opts;
++      New_Field->usrptr = field->usrptr;
+ 
+-      if (_nc_Copy_Type(New_Field,field))
++      if (_nc_Copy_Type(New_Field, field))
+ 	{
+-	  size_t len;
++	  size_t i, len;
+ 
+ 	  len = Total_Buffer_Size(New_Field);
+-	  if ( (New_Field->buf=(char *)malloc(len)) )
++	  if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
+ 	    {
+-	      memcpy(New_Field->buf,field->buf,len);
+-	      return New_Field;
++	      for (i = 0; i < len; ++i)
++		New_Field->buf[i] = field->buf[i];
++	      returnField(New_Field);
+ 	    }
+ 	}
+     }
+ 
+-  if (New_Field) 
++  if (New_Field)
+     free_field(New_Field);
+ 
+   SET_ERROR(err);
+-  return (FIELD *)0;
++  returnField((FIELD *)0);
+ }
+ 
+ /* fld_dup.c ends here */
+Index: form/fld_ftchoice.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_ftchoice.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_ftchoice.c	2004-12-11 21:44:57.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_ftchoice.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_ftchoice.c,v 1.9 2004/12/11 21:44:57 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -47,12 +47,13 @@
+ |                    E_BAD_ARGUMENT - invalid arguments
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_fieldtype_choice
+-    (FIELDTYPE * typ,
+-     bool (* const next_choice) (FIELD *,const void *),
+-     bool (* const prev_choice) (FIELD *,const void *))
++set_fieldtype_choice(FIELDTYPE *typ,
++		     bool (*const next_choice) (FIELD *, const void *),
++		     bool (*const prev_choice) (FIELD *, const void *))
+ {
+-  if ( !typ || !next_choice || !prev_choice ) 
++  T((T_CALLED("set_fieldtype_choice(%p,%p,%p)"), typ, next_choice, prev_choice));
++
++  if (!typ || !next_choice || !prev_choice)
+     RETURN(E_BAD_ARGUMENT);
+ 
+   typ->status |= _HAS_CHOICE;
+Index: form/fld_ftlink.c
+Prereq:  1.8 
+--- ncurses-5.4-20040208/form/fld_ftlink.c	2003-11-08 20:45:36.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_ftlink.c	2004-12-25 22:24:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_ftlink.c,v 1.8 2003/11/08 20:45:36 tom Exp $")
++MODULE_ID("$Id: fld_ftlink.c,v 1.11 2004/12/25 22:24:10 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -49,37 +49,38 @@
+ |   Return Values :  Fieldtype pointer or NULL if error occurred.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(FIELDTYPE *)
+-link_fieldtype 
+-(FIELDTYPE * type1, FIELDTYPE * type2)
++link_fieldtype(FIELDTYPE *type1, FIELDTYPE *type2)
+ {
+   FIELDTYPE *nftyp = (FIELDTYPE *)0;
+ 
+-  if ( type1 && type2 )
++  T((T_CALLED("link_fieldtype(%p,%p)"), type1, type2));
++  if (type1 && type2)
+     {
+       nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
++
+       if (nftyp)
+ 	{
+ 	  *nftyp = *_nc_Default_FieldType;
+ 	  nftyp->status |= _LINKED_TYPE;
+-	  if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS) )
++	  if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS))
+ 	    nftyp->status |= _HAS_ARGS;
+-	  if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE) )
++	  if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE))
+ 	    nftyp->status |= _HAS_CHOICE;
+-	  nftyp->left  = type1;
+-	  nftyp->right = type2; 
++	  nftyp->left = type1;
++	  nftyp->right = type2;
+ 	  type1->ref++;
+ 	  type2->ref++;
+ 	}
+       else
+ 	{
+-	  SET_ERROR( E_SYSTEM_ERROR );
++	  SET_ERROR(E_SYSTEM_ERROR);
+ 	}
+     }
+   else
+     {
+-      SET_ERROR( E_BAD_ARGUMENT );
++      SET_ERROR(E_BAD_ARGUMENT);
+     }
+-  return nftyp;
++  returnFieldType(nftyp);
+ }
+ 
+ /* fld_ftlink.c ends here */
+Index: form/fld_info.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_info.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_info.c	2004-12-11 22:24:57.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_info.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_info.c,v 1.10 2004/12/11 22:24:57 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -47,24 +47,35 @@
+ |                    E_BAD_ARGUMENT - invalid field pointer
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-field_info 
+-    (const FIELD *field,
+-     int *rows, int *cols, 
+-     int *frow, int *fcol, 
+-     int *nrow, int *nbuf)
++field_info(const FIELD *field,
++	   int *rows, int *cols,
++	   int *frow, int *fcol,
++	   int *nrow, int *nbuf)
+ {
+-  if (!field) 
++  T((T_CALLED("field_info(%p,%p,%p,%p,%p,%p,%p)"),
++     field,
++     rows, cols,
++     frow, fcol,
++     nrow, nbuf));
++
++  if (!field)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if (rows) *rows = field->rows;
+-  if (cols) *cols = field->cols;
+-  if (frow) *frow = field->frow;
+-  if (fcol) *fcol = field->fcol;
+-  if (nrow) *nrow = field->nrow;
+-  if (nbuf) *nbuf = field->nbuf;
++  if (rows)
++    *rows = field->rows;
++  if (cols)
++    *cols = field->cols;
++  if (frow)
++    *frow = field->frow;
++  if (fcol)
++    *fcol = field->fcol;
++  if (nrow)
++    *nrow = field->nrow;
++  if (nbuf)
++    *nbuf = field->nbuf;
+   RETURN(E_OK);
+ }
+-	
++
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+ |   Function      :  int dynamic_field_info(const FIELD *field,
+@@ -78,15 +89,19 @@
+ |                    E_BAD_ARGUMENT - invalid argument
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-dynamic_field_info
+-(const FIELD *field, int *drows, int *dcols, int *maxgrow)
++dynamic_field_info(const FIELD *field, int *drows, int *dcols, int *maxgrow)
+ {
++  T((T_CALLED("dynamic_field_info(%p,%p,%p,%p)"), field, drows, dcols, maxgrow));
++
+   if (!field)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if (drows)   *drows   = field->drows;
+-  if (dcols)   *dcols   = field->dcols;
+-  if (maxgrow) *maxgrow = field->maxgrow;
++  if (drows)
++    *drows = field->drows;
++  if (dcols)
++    *dcols = field->dcols;
++  if (maxgrow)
++    *maxgrow = field->maxgrow;
+ 
+   RETURN(E_OK);
+ }
+Index: form/fld_just.c
+Prereq:  1.8 
+--- ncurses-5.4-20040208/form/fld_just.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_just.c	2004-12-11 22:55:48.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_just.c,v 1.8 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_just.c,v 1.11 2004/12/11 22:55:48 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -45,20 +45,22 @@
+ |                    E_SYSTEM_ERROR  - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_field_just (FIELD * field, int just)
++set_field_just(FIELD *field, int just)
+ {
+   int res = E_BAD_ARGUMENT;
+ 
+-  if ((just==NO_JUSTIFICATION)  ||
+-      (just==JUSTIFY_LEFT)	||
+-      (just==JUSTIFY_CENTER)	||
+-      (just==JUSTIFY_RIGHT)	)
++  T((T_CALLED("set_field_just(%p,%d)"), field, just));
++
++  if ((just == NO_JUSTIFICATION) ||
++      (just == JUSTIFY_LEFT) ||
++      (just == JUSTIFY_CENTER) ||
++      (just == JUSTIFY_RIGHT))
+     {
+-      Normalize_Field( field );
++      Normalize_Field(field);
+       if (field->just != just)
+ 	{
+ 	  field->just = just;
+-	  res = _nc_Synchronize_Attributes( field );
++	  res = _nc_Synchronize_Attributes(field);
+ 	}
+       else
+ 	res = E_OK;
+@@ -75,9 +77,10 @@
+ |   Return Values :  The justification type.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-field_just (const FIELD * field)
++field_just(const FIELD *field)
+ {
+-  return Normalize_Field( field )->just;
++  T((T_CALLED("field_just(%p)"), field));
++  returnCode(Normalize_Field(field)->just);
+ }
+ 
+ /* fld_just.c ends here */
+Index: form/fld_link.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_link.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_link.c	2004-12-25 22:24:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_link.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_link.c,v 1.9 2004/12/25 22:24:10 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -49,43 +49,47 @@
+ |   Return Values :  Pointer to the new field or NULL if failure
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(FIELD *)
+-link_field (FIELD * field, int frow, int fcol)
++link_field(FIELD *field, int frow, int fcol)
+ {
+   FIELD *New_Field = (FIELD *)0;
+   int err = E_BAD_ARGUMENT;
+ 
+-  if (field && (frow>=0) && (fcol>=0) &&
+-      ((err=E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
+-      (New_Field = (FIELD *)malloc(sizeof(FIELD))) )
++  T((T_CALLED("link_field(%p,%d,%d)"), field, frow, fcol));
++  if (field && (frow >= 0) && (fcol >= 0) &&
++      ((err = E_SYSTEM_ERROR) != 0) &&	/* trick: this resets the default error */
++      (New_Field = (FIELD *)malloc(sizeof(FIELD))))
+     {
+-      *New_Field        = *_nc_Default_Field;
+-      New_Field->frow   = frow;
+-      New_Field->fcol   = fcol;
+-      New_Field->link   = field->link;
+-      field->link       = New_Field;
+-      New_Field->buf    = field->buf;
+-      New_Field->rows   = field->rows;
+-      New_Field->cols   = field->cols;
+-      New_Field->nrow   = field->nrow;
+-      New_Field->nbuf   = field->nbuf;
+-      New_Field->drows  = field->drows;
+-      New_Field->dcols  = field->dcols;
+-      New_Field->maxgrow= field->maxgrow;
+-      New_Field->just   = field->just;
+-      New_Field->fore   = field->fore;
+-      New_Field->back   = field->back;
+-      New_Field->pad    = field->pad;
+-      New_Field->opts   = field->opts;
++      *New_Field = *_nc_Default_Field;
++      New_Field->frow = frow;
++      New_Field->fcol = fcol;
++
++      New_Field->link = field->link;
++      field->link = New_Field;
++
++      New_Field->buf = field->buf;
++      New_Field->rows = field->rows;
++      New_Field->cols = field->cols;
++      New_Field->nrow = field->nrow;
++      New_Field->nbuf = field->nbuf;
++      New_Field->drows = field->drows;
++      New_Field->dcols = field->dcols;
++      New_Field->maxgrow = field->maxgrow;
++      New_Field->just = field->just;
++      New_Field->fore = field->fore;
++      New_Field->back = field->back;
++      New_Field->pad = field->pad;
++      New_Field->opts = field->opts;
+       New_Field->usrptr = field->usrptr;
+-      if (_nc_Copy_Type(New_Field,field)) 
+-	return New_Field;
++
++      if (_nc_Copy_Type(New_Field, field))
++	returnField(New_Field);
+     }
+ 
+-  if (New_Field) 
++  if (New_Field)
+     free_field(New_Field);
+ 
+-  SET_ERROR( err );
+-  return (FIELD *)0;
++  SET_ERROR(err);
++  returnField((FIELD *)0);
+ }
+ 
+ /* fld_link.c ends here */
+Index: form/fld_max.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_max.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_max.c	2004-12-11 21:51:54.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_max.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_max.c,v 1.9 2004/12/11 21:51:54 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -45,17 +45,19 @@
+ |                    E_BAD_ARGUMENT - invalid argument
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_max_field (FIELD *field, int maxgrow)
++set_max_field(FIELD *field, int maxgrow)
+ {
+-  if (!field || (maxgrow<0))
++  T((T_CALLED("set_max_field(%p,%d)"), field, maxgrow));
++
++  if (!field || (maxgrow < 0))
+     RETURN(E_BAD_ARGUMENT);
+   else
+     {
+       bool single_line_field = Single_Line_Field(field);
+ 
+-      if (maxgrow>0)
++      if (maxgrow > 0)
+ 	{
+-	  if (( single_line_field && (maxgrow < field->dcols)) ||
++	  if ((single_line_field && (maxgrow < field->dcols)) ||
+ 	      (!single_line_field && (maxgrow < field->drows)))
+ 	    RETURN(E_BAD_ARGUMENT);
+ 	}
+@@ -63,13 +65,13 @@
+       field->status &= ~_MAY_GROW;
+       if (!(field->opts & O_STATIC))
+ 	{
+-	  if ((maxgrow==0) ||
+-	      ( single_line_field && (field->dcols < maxgrow)) ||
++	  if ((maxgrow == 0) ||
++	      (single_line_field && (field->dcols < maxgrow)) ||
+ 	      (!single_line_field && (field->drows < maxgrow)))
+ 	    field->status |= _MAY_GROW;
+ 	}
+     }
+   RETURN(E_OK);
+ }
+-		  
++
+ /* fld_max.c ends here */
+Index: form/fld_move.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_move.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_move.c	2004-12-11 21:52:44.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_move.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_move.c,v 1.9 2004/12/11 21:52:44 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -46,12 +46,14 @@
+ |                    E_CONNECTED     - field is connected
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-move_field (FIELD *field, int frow, int fcol)
++move_field(FIELD *field, int frow, int fcol)
+ {
+-  if ( !field || (frow<0) || (fcol<0) ) 
++  T((T_CALLED("move_field(%p,%d,%d)"), field, frow, fcol));
++
++  if (!field || (frow < 0) || (fcol < 0))
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if (field->form) 
++  if (field->form)
+     RETURN(E_CONNECTED);
+ 
+   field->frow = frow;
+@@ -60,4 +62,3 @@
+ }
+ 
+ /* fld_move.c ends here */
+-
+Index: form/fld_newftyp.c
+Prereq:  1.9 
+--- ncurses-5.4-20040208/form/fld_newftyp.c	2003-11-08 20:45:36.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_newftyp.c	2004-12-25 22:24:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,49 +32,52 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_newftyp.c,v 1.9 2003/11/08 20:45:36 tom Exp $")
++MODULE_ID("$Id: fld_newftyp.c,v 1.13 2004/12/25 22:24:10 tom Exp $")
+ 
+-static FIELDTYPE const default_fieldtype = {
+-  0,                   /* status                                      */
+-  0L,                  /* reference count                             */
+-  (FIELDTYPE *)0,      /* pointer to left  operand                    */
+-  (FIELDTYPE *)0,      /* pointer to right operand                    */
+-  NULL,                /* makearg function                            */
+-  NULL,                /* copyarg function                            */
+-  NULL,                /* freearg function                            */
+-  NULL,                /* field validation function                   */
+-  NULL,                /* Character check function                    */
+-  NULL,                /* enumerate next function                     */
+-  NULL                 /* enumerate previous function                 */
++static FIELDTYPE const default_fieldtype =
++{
++  0,				/* status                                      */
++  0L,				/* reference count                             */
++  (FIELDTYPE *)0,		/* pointer to left  operand                    */
++  (FIELDTYPE *)0,		/* pointer to right operand                    */
++  NULL,				/* makearg function                            */
++  NULL,				/* copyarg function                            */
++  NULL,				/* freearg function                            */
++  NULL,				/* field validation function                   */
++  NULL,				/* Character check function                    */
++  NULL,				/* enumerate next function                     */
++  NULL				/* enumerate previous function                 */
+ };
+ 
+-NCURSES_EXPORT_VAR(const FIELDTYPE*) _nc_Default_FieldType = &default_fieldtype;
+-
++NCURSES_EXPORT_VAR(const FIELDTYPE *)
++_nc_Default_FieldType = &default_fieldtype;
++
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  FIELDTYPE *new_fieldtype(
+ |                       bool (* const field_check)(FIELD *,const void *),
+-|                       bool (* const char_check) (int, const void *) ) 
+-|   
++|                       bool (* const char_check) (int, const void *) )
++|
+ |   Description   :  Create a new fieldtype. The application programmer must
+ |                    write a field_check and a char_check function and give
+ |                    them as input to this call.
+-|                    If an error occurs, errno is set to                    
++|                    If an error occurs, errno is set to
+ |                       E_BAD_ARGUMENT  - invalid arguments
+ |                       E_SYSTEM_ERROR  - system error (no memory)
+ |
+ |   Return Values :  Fieldtype pointer or NULL if error occurred
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(FIELDTYPE *)
+-new_fieldtype (
+- bool (* const field_check)(FIELD *,const void *),
+- bool (* const char_check) (int,const void *) )
++new_fieldtype(bool (*const field_check) (FIELD *, const void *),
++	      bool (*const char_check) (int, const void *))
+ {
+   FIELDTYPE *nftyp = (FIELDTYPE *)0;
+-  
+-  if ( (field_check) || (char_check) )
++
++  T((T_CALLED("new_fieldtype(%p,%p)"), field_check, char_check));
++  if ((field_check) || (char_check))
+     {
+       nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
++
+       if (nftyp)
+ 	{
+ 	  *nftyp = default_fieldtype;
+@@ -83,20 +86,20 @@
+ 	}
+       else
+ 	{
+-	  SET_ERROR( E_SYSTEM_ERROR );
++	  SET_ERROR(E_SYSTEM_ERROR);
+ 	}
+     }
+   else
+     {
+-      SET_ERROR( E_BAD_ARGUMENT );
++      SET_ERROR(E_BAD_ARGUMENT);
+     }
+-  return nftyp;
++  returnFieldType(nftyp);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int free_fieldtype(FIELDTYPE *typ)
+-|   
++|
+ |   Description   :  Release the memory associated with this fieldtype.
+ |
+ |   Return Values :  E_OK            - success
+@@ -104,12 +107,14 @@
+ |                    E_BAD_ARGUMENT  - invalid fieldtype pointer
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-free_fieldtype (FIELDTYPE *typ)
++free_fieldtype(FIELDTYPE *typ)
+ {
++  T((T_CALLED("free_fieldtype(%p)"), typ));
++
+   if (!typ)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if (typ->ref!=0)
++  if (typ->ref != 0)
+     RETURN(E_CONNECTED);
+ 
+   if (typ->status & _RESIDENT)
+@@ -117,8 +122,10 @@
+ 
+   if (typ->status & _LINKED_TYPE)
+     {
+-      if (typ->left ) typ->left->ref--;
+-      if (typ->right) typ->right->ref--;
++      if (typ->left)
++	typ->left->ref--;
++      if (typ->right)
++	typ->right->ref--;
+     }
+   free(typ);
+   RETURN(E_OK);
+Index: form/fld_opts.c
+Prereq:  1.9 
+--- ncurses-5.4-20040208/form/fld_opts.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_opts.c	2004-12-11 21:55:46.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_opts.c,v 1.9 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_opts.c,v 1.11 2004/12/11 21:55:46 tom Exp $")
+ 
+ /*----------------------------------------------------------------------------
+   Field-Options manipulation routines
+@@ -51,12 +51,15 @@
+ |                    E_SYSTEM_ERROR  - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_field_opts (FIELD * field, Field_Options opts)
++set_field_opts(FIELD *field, Field_Options opts)
+ {
+   int res = E_BAD_ARGUMENT;
++
++  T((T_CALLED("set_field_opts(%p,%d)"), field, opts));
++
+   opts &= ALL_FIELD_OPTS;
+   if (!(opts & ~ALL_FIELD_OPTS))
+-    res = _nc_Synchronize_Options( Normalize_Field(field), opts );
++    res = _nc_Synchronize_Options(Normalize_Field(field), opts);
+   RETURN(res);
+ }
+ 
+@@ -69,9 +72,11 @@
+ |   Return Values :  The options.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(Field_Options)
+-field_opts (const FIELD * field)
++field_opts(const FIELD *field)
+ {
+-  return ALL_FIELD_OPTS & Normalize_Field( field )->opts;
++  T((T_CALLED("field_opts(%p)"), field));
++
++  returnCode(ALL_FIELD_OPTS & Normalize_Field(field)->opts);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -87,15 +92,17 @@
+ |                    E_SYSTEM_ERROR  - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-field_opts_on (FIELD * field, Field_Options opts)
++field_opts_on(FIELD *field, Field_Options opts)
+ {
+   int res = E_BAD_ARGUMENT;
+ 
++  T((T_CALLED("field_opts_on(%p,%d)"), field, opts));
++
+   opts &= ALL_FIELD_OPTS;
+   if (!(opts & ~ALL_FIELD_OPTS))
+     {
+-      Normalize_Field( field );
+-      res = _nc_Synchronize_Options( field, field->opts | opts );
++      Normalize_Field(field);
++      res = _nc_Synchronize_Options(field, field->opts | opts);
+     }
+   RETURN(res);
+ }
+@@ -113,17 +120,19 @@
+ |                    E_SYSTEM_ERROR  - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-field_opts_off (FIELD  * field, Field_Options opts)
++field_opts_off(FIELD *field, Field_Options opts)
+ {
+   int res = E_BAD_ARGUMENT;
+ 
++  T((T_CALLED("field_opts_off(%p,%d)"), field, opts));
++
+   opts &= ALL_FIELD_OPTS;
+   if (!(opts & ~ALL_FIELD_OPTS))
+     {
+-      Normalize_Field( field );
+-      res = _nc_Synchronize_Options( field, field->opts & ~opts );
++      Normalize_Field(field);
++      res = _nc_Synchronize_Options(field, field->opts & ~opts);
+     }
+   RETURN(res);
+-}	
++}
+ 
+ /* fld_opts.c ends here */
+Index: form/fld_pad.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_pad.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_pad.c	2004-12-11 21:56:49.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_pad.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_pad.c,v 1.9 2004/12/11 21:56:49 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -46,17 +46,19 @@
+ |                    E_SYSTEM_ERROR - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_field_pad (FIELD  * field, int ch)
++set_field_pad(FIELD *field, int ch)
+ {
+   int res = E_BAD_ARGUMENT;
+ 
+-  Normalize_Field( field );
+-  if (isprint((unsigned char)ch))
++  T((T_CALLED("set_field_pad(%p,%d)"), field, ch));
++
++  Normalize_Field(field);
++  if (isprint(UChar(ch)))
+     {
+       if (field->pad != ch)
+ 	{
+ 	  field->pad = ch;
+-	  res = _nc_Synchronize_Attributes( field );
++	  res = _nc_Synchronize_Attributes(field);
+ 	}
+       else
+ 	res = E_OK;
+@@ -73,9 +75,11 @@
+ |   Return Values :  The pad character.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-field_pad (const FIELD * field)
++field_pad(const FIELD *field)
+ {
+-  return Normalize_Field( field )->pad;
++  T((T_CALLED("field_pad(%p)"), field));
++
++  returnCode(Normalize_Field(field)->pad);
+ }
+ 
+ /* fld_pad.c ends here */
+Index: form/fld_page.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/fld_page.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_page.c	2004-12-11 21:58:19.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_page.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_page.c,v 1.9 2004/12/11 21:58:19 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -45,13 +45,15 @@
+ |                    E_CONNECTED  - field is connected
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_new_page (FIELD * field, bool new_page_flag)
++set_new_page(FIELD *field, bool new_page_flag)
+ {
++  T((T_CALLED("set_new_page(%p,%d)"), field, new_page_flag));
++
+   Normalize_Field(field);
+-  if (field->form) 
++  if (field->form)
+     RETURN(E_CONNECTED);
+ 
+-  if (new_page_flag) 
++  if (new_page_flag)
+     field->status |= _NEWPAGE;
+   else
+     field->status &= ~_NEWPAGE;
+@@ -70,9 +72,11 @@
+ |                    FALSE - field doesn't start a new page
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(bool)
+-new_page (const FIELD * field)
++new_page(const FIELD *field)
+ {
+-  return (Normalize_Field(field)->status & _NEWPAGE)  ? TRUE : FALSE;
++  T((T_CALLED("new_page(%p)"), field));
++
++  returnBool((Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE);
+ }
+ 
+ /* fld_page.c ends here */
+Index: form/fld_stat.c
+Prereq:  1.9 
+--- ncurses-5.4-20040208/form/fld_stat.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_stat.c	2004-12-11 22:28:00.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_stat.c,v 1.9 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_stat.c,v 1.11 2004/12/11 22:28:00 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -44,16 +44,18 @@
+ |   Return Values :  E_OK            - success
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_field_status (FIELD * field, bool status)
++set_field_status(FIELD *field, bool status)
+ {
+-  Normalize_Field( field );
++  T((T_CALLED("set_field_status(%p,%d)"), field, status));
++
++  Normalize_Field(field);
+ 
+   if (status)
+     field->status |= _CHANGED;
+   else
+     field->status &= ~_CHANGED;
+ 
+-  return(E_OK);
++  RETURN(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -67,9 +69,11 @@
+ |                    FALSE - buffer has not been changed
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(bool)
+-field_status (const FIELD * field)
++field_status(const FIELD *field)
+ {
+-  return ((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
++  T((T_CALLED("field_status(%p)"), field));
++
++  returnBool((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
+ }
+ 
+ /* fld_stat.c ends here */
+Index: form/fld_type.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/form/fld_type.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_type.c	2004-12-25 22:24:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_type.c,v 1.12 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_type.c,v 1.15 2004/12/25 22:24:10 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -46,30 +46,32 @@
+ |                    E_SYSTEM_ERROR - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_field_type (FIELD *field,FIELDTYPE *type, ...)
++set_field_type(FIELD *field, FIELDTYPE *type,...)
+ {
+   va_list ap;
+   int res = E_SYSTEM_ERROR;
+   int err = 0;
+ 
+-  va_start(ap,type);
++  T((T_CALLED("set_field_type(%p,%p)"), field, type));
++
++  va_start(ap, type);
+ 
+   Normalize_Field(field);
+   _nc_Free_Type(field);
+ 
+   field->type = type;
+-  field->arg  = (void *)_nc_Make_Argument(field->type,&ap,&err);
++  field->arg = (void *)_nc_Make_Argument(field->type, &ap, &err);
+ 
+   if (err)
+     {
+-      _nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
++      _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
+       field->type = (FIELDTYPE *)0;
+-      field->arg  = (void *)0;
++      field->arg = (void *)0;
+     }
+   else
+     {
+       res = E_OK;
+-      if (field->type) 
++      if (field->type)
+ 	field->type->ref++;
+     }
+ 
+@@ -86,9 +88,10 @@
+ |   Return Values :  Pointer to fieldtype of NULL if none is defined.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(FIELDTYPE *)
+-field_type (const FIELD * field)
++field_type(const FIELD *field)
+ {
+-  return Normalize_Field(field)->type;
++  T((T_CALLED("field_type(%p)"), field));
++  returnFieldType(Normalize_Field(field)->type);
+ }
+ 
+ /* fld_type.c ends here */
+Index: form/fld_user.c
+Prereq:  1.11 
+--- ncurses-5.4-20040208/form/fld_user.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/fld_user.c	2004-12-25 22:24:50.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: fld_user.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: fld_user.c,v 1.15 2004/12/25 22:24:50 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -44,9 +44,11 @@
+ |   Return Values :  E_OK         - on success
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_field_userptr (FIELD * field, void  *usrptr)
++set_field_userptr(FIELD *field, void *usrptr)
+ {
+-  Normalize_Field( field )->usrptr = usrptr;
++  T((T_CALLED("set_field_userptr(%p,%p)"), field, usrptr));
++
++  Normalize_Field(field)->usrptr = usrptr;
+   RETURN(E_OK);
+ }
+ 
+@@ -61,9 +63,10 @@
+ |                    NULL is returned
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void *)
+-field_userptr (const FIELD *field)
++field_userptr(const FIELD *field)
+ {
+-  return Normalize_Field( field )->usrptr;
++  T((T_CALLED("field_userptr(%p)"), field));
++  returnVoidPtr(Normalize_Field(field)->usrptr);
+ }
+ 
+ /* fld_user.c ends here */
+Index: form/form.h
+Prereq:  0.17 
+--- ncurses-5.4-20040208/form/form.h	2003-11-08 20:39:08.000000000 +0000
++++ ncurses-5.4-20050319/form/form.h	2004-12-04 22:22:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -30,7 +30,7 @@
+  *   Author:  Juergen Pfeifer, 1995,1997                                    *
+  ****************************************************************************/
+ 
+-/* $Id: form.h,v 0.17 2003/11/08 20:39:08 tom Exp $ */
++/* $Id: form.h,v 0.20 2004/12/04 22:22:10 tom Exp $ */
+ 
+ #ifndef FORM_H
+ #define FORM_H
+@@ -42,6 +42,14 @@
+   extern "C" {
+ #endif
+ 
++#ifndef FORM_PRIV_H
++typedef void *FIELD_CELL;
++#endif
++
++#ifndef NCURSES_FIELD_INTERNALS
++#define NCURSES_FIELD_INTERNALS /* nothing */
++#endif
++
+ typedef int Form_Options;
+ typedef int Field_Options;
+ 
+@@ -50,10 +58,10 @@
+ 	**********/
+ 
+ typedef struct {
+-  short	pmin;	  /* index of first field on page            */
+-  short	pmax;	  /* index of last field on page             */
+-  short	smin;	  /* index of top leftmost field on page     */
+-  short	smax;	  /* index of bottom rightmost field on page */
++  short pmin;		/* index of first field on page			*/
++  short pmax;		/* index of last field on page			*/
++  short smin;		/* index of top leftmost field on page		*/
++  short smax;		/* index of bottom rightmost field on page	*/
+ } _PAGE;
+ 
+ 	/**********
+@@ -61,31 +69,40 @@
+ 	**********/
+ 
+ typedef struct fieldnode {
+-  unsigned short       	status;	  /* flags		        */
+-  short			rows;	  /* size in rows		*/
+-  short			cols;	  /* size in cols		*/
+-  short			frow;	  /* first row		        */
+-  short			fcol;	  /* first col		        */
+-  int                   drows;    /* dynamic rows               */
+-  int                   dcols;    /* dynamic cols               */
+-  int                   maxgrow;  /* maximum field growth       */
+-  int			nrow;	  /* off-screen rows	        */
+-  short			nbuf;	  /* additional buffers	        */
+-  short			just;	  /* justification	        */
+-  short			page;	  /* page on form		*/
+-  short			index;	  /* into form -> field	        */
+-  int			pad;	  /* pad character	        */
+-  chtype		fore;	  /* foreground attribute	*/
+-  chtype		back;	  /* background attribute	*/
+-  Field_Options		opts;	  /* options		        */
+-  struct fieldnode *	snext;	  /* sorted order pointer	*/
+-  struct fieldnode *	sprev;	  /* sorted order pointer	*/
+-  struct fieldnode *	link;	  /* linked field chain	        */
+-  struct formnode *	form;	  /* containing form	        */
+-  struct typenode *	type;	  /* field type		        */
+-  void *		arg;	  /* argument for type	        */
+-  char *		buf;	  /* field buffers	        */
+-  void *		usrptr;	  /* user pointer		*/
++  unsigned short	status;		/* flags			*/
++  short			rows;		/* size in rows			*/
++  short			cols;		/* size in cols			*/
++  short			frow;		/* first row			*/
++  short			fcol;		/* first col			*/
++  int			drows;		/* dynamic rows			*/
++  int			dcols;		/* dynamic cols			*/
++  int			maxgrow;	/* maximum field growth		*/
++  int			nrow;		/* off-screen rows		*/
++  short			nbuf;		/* additional buffers		*/
++  short			just;		/* justification		*/
++  short			page;		/* page on form			*/
++  short			index;		/* into form -> field		*/
++  int			pad;		/* pad character		*/
++  chtype		fore;		/* foreground attribute		*/
++  chtype		back;		/* background attribute		*/
++  Field_Options		opts;		/* options			*/
++  struct fieldnode *	snext;		/* sorted order pointer		*/
++  struct fieldnode *	sprev;		/* sorted order pointer		*/
++  struct fieldnode *	link;		/* linked field chain		*/
++  struct formnode *	form;		/* containing form		*/
++  struct typenode *	type;		/* field type			*/
++  void *		arg;		/* argument for type		*/
++  FIELD_CELL *		buf;		/* field buffers		*/
++  void *		usrptr;		/* user pointer			*/
++  /*
++   * The wide-character configuration requires extra information.  Because
++   * there are existing applications that manipulate the members of FIELD
++   * directly, we cannot make the struct opaque.  Offsets of members up to
++   * this point are the same in the narrow- and wide-character configuration.
++   * But note that the type of buf depends on the configuration, and is made
++   * opaque for that reason.
++   */
++  NCURSES_FIELD_INTERNALS
+ } FIELD;
+ 
+ 	/**************
+@@ -93,20 +110,20 @@
+ 	**************/
+ 
+ typedef struct typenode {
+-  unsigned short	status;	               /* flags		       */
+-  long			ref;	               /* reference count      */
+-  struct typenode *	left;	               /* ptr to operand for | */
+-  struct typenode *	right;	               /* ptr to operand for | */
+-
+-  void* (*makearg)(va_list *);                 /* make fieldtype arg   */
+-  void* (*copyarg)(const void *);              /* copy fieldtype arg   */
+-  void  (*freearg)(void *);                    /* free fieldtype arg   */
++  unsigned short	status;			/* flags		*/
++  long			ref;			/* reference count	*/
++  struct typenode *	left;			/* ptr to operand for | */
++  struct typenode *	right;			/* ptr to operand for | */
++
++  void* (*makearg)(va_list *);			/* make fieldtype arg	*/
++  void* (*copyarg)(const void *);		/* copy fieldtype arg	*/
++  void	(*freearg)(void *);			/* free fieldtype arg	*/
+ 
+-  bool	(*fcheck)(FIELD *,const void *);       /* field validation     */
+-  bool	(*ccheck)(int,const void *);           /* character validation */
++  bool	(*fcheck)(FIELD *,const void *);	/* field validation	*/
++  bool	(*ccheck)(int,const void *);		/* character validation */
+ 
+-  bool	(*next)(FIELD *,const void *);         /* enumerate next value */
+-  bool	(*prev)(FIELD *,const void *);         /* enumerate prev value */
++  bool	(*next)(FIELD *,const void *);		/* enumerate next value */
++  bool	(*prev)(FIELD *,const void *);		/* enumerate prev value */
+ 
+ } FIELDTYPE;
+ 
+@@ -115,29 +132,29 @@
+ 	*********/
+ 
+ typedef struct formnode {
+-  unsigned short	status;	  /* flags		        */
+-  short			rows;	  /* size in rows		*/
+-  short			cols;	  /* size in cols		*/
+-  int			currow;	  /* current row in field window*/
+-  int			curcol;	  /* current col in field window*/
+-  int			toprow;	  /* in scrollable field window	*/
+-  int                   begincol; /* in horiz. scrollable field */
+-  short			maxfield; /* number of fields	        */
+-  short			maxpage;  /* number of pages	        */
+-  short			curpage;  /* index into page	        */
+-  Form_Options		opts;	  /* options		        */
+-  WINDOW *		win;	  /* window		        */
+-  WINDOW *		sub;	  /* subwindow		        */
+-  WINDOW *		w;	  /* window for current field	*/
+-  FIELD **		field;	  /* field [maxfield]	        */
+-  FIELD *		current;  /* current field	        */
+-  _PAGE *		page;	  /* page [maxpage]	        */
+-  void *		usrptr;	  /* user pointer		*/
+-
+-  void                  (*forminit)(struct formnode *);
+-  void                  (*formterm)(struct formnode *);
+-  void                  (*fieldinit)(struct formnode *);
+-  void                  (*fieldterm)(struct formnode *);
++  unsigned short	status;		/* flags			*/
++  short			rows;		/* size in rows			*/
++  short			cols;		/* size in cols			*/
++  int			currow;		/* current row in field window	*/
++  int			curcol;		/* current col in field window	*/
++  int			toprow;		/* in scrollable field window	*/
++  int			begincol;	/* in horiz. scrollable field	*/
++  short			maxfield;	/* number of fields		*/
++  short			maxpage;	/* number of pages		*/
++  short			curpage;	/* index into page		*/
++  Form_Options		opts;		/* options			*/
++  WINDOW *		win;		/* window			*/
++  WINDOW *		sub;		/* subwindow			*/
++  WINDOW *		w;		/* window for current field	*/
++  FIELD **		field;		/* field [maxfield]		*/
++  FIELD *		current;	/* current field		*/
++  _PAGE *		page;		/* page [maxpage]		*/
++  void *		usrptr;		/* user pointer			*/
++
++  void			(*forminit)(struct formnode *);
++  void			(*formterm)(struct formnode *);
++  void			(*fieldinit)(struct formnode *);
++  void			(*fieldterm)(struct formnode *);
+ 
+ } FORM;
+ 
+@@ -154,20 +171,20 @@
+ #define JUSTIFY_RIGHT		(3)
+ 
+ /* field options */
+-#define O_VISIBLE		(0x0001)
+-#define O_ACTIVE		(0x0002)
+-#define O_PUBLIC		(0x0004)
+-#define O_EDIT			(0x0008)
+-#define O_WRAP			(0x0010)
+-#define O_BLANK			(0x0020)
+-#define O_AUTOSKIP		(0x0040)
+-#define O_NULLOK		(0x0080)
+-#define O_PASSOK		(0x0100)
+-#define O_STATIC                (0x0200)
++#define O_VISIBLE		(0x0001U)
++#define O_ACTIVE		(0x0002U)
++#define O_PUBLIC		(0x0004U)
++#define O_EDIT			(0x0008U)
++#define O_WRAP			(0x0010U)
++#define O_BLANK			(0x0020U)
++#define O_AUTOSKIP		(0x0040U)
++#define O_NULLOK		(0x0080U)
++#define O_PASSOK		(0x0100U)
++#define O_STATIC		(0x0200U)
+ 
+ /* form options */
+-#define O_NL_OVERLOAD		(0x0001)
+-#define O_BS_OVERLOAD		(0x0002)
++#define O_NL_OVERLOAD		(0x0001U)
++#define O_BS_OVERLOAD		(0x0002U)
+ 
+ /* form driver commands */
+ #define REQ_NEXT_PAGE	 (KEY_MAX + 1)	/* move to next page		*/
+@@ -219,14 +236,14 @@
+ #define REQ_SCR_BLINE	 (KEY_MAX + 44)	/* scroll field backward a line	*/
+ #define REQ_SCR_FPAGE	 (KEY_MAX + 45)	/* scroll field forward a page	*/
+ #define REQ_SCR_BPAGE	 (KEY_MAX + 46)	/* scroll field backward a page	*/
+-#define REQ_SCR_FHPAGE   (KEY_MAX + 47) /* scroll field forward  half page */
+-#define REQ_SCR_BHPAGE   (KEY_MAX + 48) /* scroll field backward half page */
+-#define REQ_SCR_FCHAR    (KEY_MAX + 49) /* horizontal scroll char          */
+-#define REQ_SCR_BCHAR    (KEY_MAX + 50) /* horizontal scroll char          */
+-#define REQ_SCR_HFLINE   (KEY_MAX + 51) /* horizontal scroll line          */
+-#define REQ_SCR_HBLINE   (KEY_MAX + 52) /* horizontal scroll line          */
+-#define REQ_SCR_HFHALF   (KEY_MAX + 53) /* horizontal scroll half line     */
+-#define REQ_SCR_HBHALF   (KEY_MAX + 54) /* horizontal scroll half line     */
++#define REQ_SCR_FHPAGE	 (KEY_MAX + 47) /* scroll field forward	 half page */
++#define REQ_SCR_BHPAGE	 (KEY_MAX + 48) /* scroll field backward half page */
++#define REQ_SCR_FCHAR	 (KEY_MAX + 49) /* horizontal scroll char	*/
++#define REQ_SCR_BCHAR	 (KEY_MAX + 50) /* horizontal scroll char	*/
++#define REQ_SCR_HFLINE	 (KEY_MAX + 51) /* horizontal scroll line	*/
++#define REQ_SCR_HBLINE	 (KEY_MAX + 52) /* horizontal scroll line	*/
++#define REQ_SCR_HFHALF	 (KEY_MAX + 53) /* horizontal scroll half line	*/
++#define REQ_SCR_HBHALF	 (KEY_MAX + 54) /* horizontal scroll half line	*/
+ 
+ #define REQ_VALIDATION	 (KEY_MAX + 55)	/* validate field		*/
+ #define REQ_NEXT_CHOICE	 (KEY_MAX + 56)	/* display next field choice	*/
+@@ -255,15 +272,15 @@
+ extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
+ extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
+ 
+-        /************************************
++	/************************************
+ 	*  built-in additional field types  *
+-        *  They are not defined in SVr4     *
++	*  They are not defined in SVr4     *
+ 	************************************/
+ extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4;      /* Internet IP Version 4 address */
+ 
+-        /*********************** 
+-        *   Default objects    *
+-        ***********************/ 
++	/***********************
++	*   Default objects    *
++	***********************/
+ extern NCURSES_EXPORT_VAR(FORM *)	_nc_Default_Form;
+ extern NCURSES_EXPORT_VAR(FIELD *)	_nc_Default_Field;
+ 
+@@ -273,8 +290,9 @@
+ 	***********************/
+ extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
+ 		    bool (* const field_check)(FIELD *,const void *),
+-		    bool (* const char_check)(int,const void *)),
+-                *link_fieldtype(FIELDTYPE *,FIELDTYPE *);
++		    bool (* const char_check)(int,const void *));
++extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype(
++		    FIELDTYPE *, FIELDTYPE *);
+ 
+ extern NCURSES_EXPORT(int)	free_fieldtype (FIELDTYPE *);
+ extern NCURSES_EXPORT(int)	set_fieldtype_arg (FIELDTYPE *,
+@@ -326,7 +344,7 @@
+ 
+ extern NCURSES_EXPORT(char *)	field_buffer (const FIELD *,int);
+ 
+-extern NCURSES_EXPORT(Field_Options)	field_opts (const FIELD *); 
++extern NCURSES_EXPORT(Field_Options)	field_opts (const FIELD *);
+ 
+ 	/******************
+ 	*  FORM routines  *
+Index: form/form.priv.h
+Prereq:  0.11 
+--- ncurses-5.4-20040208/form/form.priv.h	2003-11-08 20:38:51.000000000 +0000
++++ ncurses-5.4-20050319/form/form.priv.h	2005-03-05 23:47:26.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -30,37 +30,65 @@
+  *   Author:  Juergen Pfeifer, 1995,1997                                    *
+  ****************************************************************************/
+ 
+-/* $Id: form.priv.h,v 0.11 2003/11/08 20:38:51 tom Exp $ */
++/* $Id: form.priv.h,v 0.25 2005/03/05 23:47:26 tom Exp $ */
+ 
++#ifndef FORM_PRIV_H
++#define FORM_PRIV_H 1
++
++#include "curses.priv.h"
+ #include "mf_common.h"
++
++#if USE_WIDEC_SUPPORT
++#include <wchar.h>
++#include <wctype.h>
++
++#ifndef MB_LEN_MAX
++#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
++#endif
++
++#define FIELD_CELL NCURSES_CH_T
++
++#define NCURSES_FIELD_INTERNALS char** expanded; WINDOW *working;
++#define NCURSES_FIELD_EXTENSION , (char **)0, (WINDOW *)0
++
++#else
++
++#define FIELD_CELL char
++
++#define NCURSES_FIELD_EXTENSION /* nothing */
++
++#endif
++
+ #include "form.h"
+ 
+ /* form  status values */
+-#define _OVLMODE         (0x04) /* Form is in overlay mode                */
+-#define _WINDOW_MODIFIED (0x10) /* Current field window has been modified */
+-#define _FCHECK_REQUIRED (0x20) /* Current field needs validation         */
++#define _OVLMODE         (0x04U) /* Form is in overlay mode                */
++#define _WINDOW_MODIFIED (0x10U) /* Current field window has been modified */
++#define _FCHECK_REQUIRED (0x20U) /* Current field needs validation         */
+ 
+ /* field status values */
+-#define _CHANGED         (0x01) /* Field has been changed                 */
+-#define _NEWTOP          (0x02) /* Vertical scrolling occurred            */
+-#define _NEWPAGE	 (0x04) /* field begins new page of form          */
+-#define _MAY_GROW        (0x08) /* dynamic field may still grow           */
++#define _CHANGED         (0x01U) /* Field has been changed                 */
++#define _NEWTOP          (0x02U) /* Vertical scrolling occurred            */
++#define _NEWPAGE         (0x04U) /* field begins new page of form          */
++#define _MAY_GROW        (0x08U) /* dynamic field may still grow           */
+ 
+ /* fieldtype status values */
+-#define _LINKED_TYPE     (0x01) /* Type is a linked type                  */
+-#define _HAS_ARGS        (0x02) /* Type has arguments                     */
+-#define _HAS_CHOICE      (0x04) /* Type has choice methods                */
+-#define _RESIDENT        (0x08) /* Type is built-in                       */
++#define _LINKED_TYPE     (0x01U) /* Type is a linked type                  */
++#define _HAS_ARGS        (0x02U) /* Type has arguments                     */
++#define _HAS_CHOICE      (0x04U) /* Type has choice methods                */
++#define _RESIDENT        (0x08U) /* Type is built-in                       */
+ 
+ /* This are the field options required to be a selectable field in field
+    navigation requests */
+ #define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
+ 
+ /* If form is NULL replace form argument by default-form */
+-#define Normalize_Form(form)  ((form)=(form)?(form):_nc_Default_Form)
++#define Normalize_Form(form) \
++  ((form) = (form != 0) ? (form) : _nc_Default_Form)
+ 
+ /* If field is NULL replace field argument by default-field */
+-#define Normalize_Field(field)  ((field)=(field)?(field):_nc_Default_Field)
++#define Normalize_Field(field) \
++  ((field) = (field != 0) ? (field) : _nc_Default_Field)
+ 
+ /* Retrieve forms window */
+ #define Get_Form_Window(form) \
+@@ -71,20 +99,22 @@
+ 
+ /* Calculate the total size of all buffers for this field */
+ #define Total_Buffer_Size(field) \
+-   ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) )
++   ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) * sizeof(FIELD_CELL) )
+ 
+ /* Logic to determine whether or not a field is single lined */
+ #define Single_Line_Field(field) \
+    (((field)->rows + (field)->nrow) == 1)
+ 
+ /* Logic to determine whether or not a field is selectable */
+-#define Field_Is_Selectable(f)     (((f)->opts & O_SELECTABLE)==O_SELECTABLE)
+-#define Field_Is_Not_Selectable(f) (((f)->opts & O_SELECTABLE)!=O_SELECTABLE)
++#define Field_Is_Selectable(f)     (((unsigned)((f)->opts) & O_SELECTABLE)==O_SELECTABLE)
++#define Field_Is_Not_Selectable(f) (((unsigned)((f)->opts) & O_SELECTABLE)!=O_SELECTABLE)
+ 
+-typedef struct typearg {
+-  struct typearg *left;
+-  struct typearg *right;
+-} TypeArgument;
++typedef struct typearg
++  {
++    struct typearg *left;
++    struct typearg *right;
++  }
++TypeArgument;
+ 
+ /* This is a dummy request code (normally invalid) to be used internally
+    with the form_driver() routine to position to the first active field
+@@ -96,7 +126,7 @@
+ 			O_NL_OVERLOAD  |\
+ 			O_BS_OVERLOAD   )
+ 
+-#define ALL_FIELD_OPTS (           \
++#define ALL_FIELD_OPTS (Field_Options)( \
+ 			O_VISIBLE |\
+ 			O_ACTIVE  |\
+ 			O_PUBLIC  |\
+@@ -108,23 +138,112 @@
+ 			O_PASSOK  |\
+ 			O_STATIC   )
+ 
+-
+ #define C_BLANK ' '
+ #define is_blank(c) ((c)==C_BLANK)
+ 
++#define C_ZEROS '\0'
++
+ extern NCURSES_EXPORT_VAR(const FIELDTYPE *) _nc_Default_FieldType;
+ 
+-extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*,va_list*,int*);
+-extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*,const TypeArgument*, int*);
+-extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*,TypeArgument*);
++extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*, va_list*, int*);
++extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*, const TypeArgument*, int*);
++extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*, TypeArgument*);
+ extern NCURSES_EXPORT(bool) _nc_Copy_Type (FIELD*, FIELD const *);
+ extern NCURSES_EXPORT(void) _nc_Free_Type (FIELD *);
+ 
+ extern NCURSES_EXPORT(int) _nc_Synchronize_Attributes (FIELD*);
+-extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*,Field_Options);
+-extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*,int,FIELD*);
++extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*, Field_Options);
++extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*, int, FIELD*);
+ extern NCURSES_EXPORT(int) _nc_Refresh_Current_Field (FORM*);
+ extern NCURSES_EXPORT(FIELD *) _nc_First_Active_Field (FORM*);
+ extern NCURSES_EXPORT(bool) _nc_Internal_Validation (FORM*);
+-extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*,FIELD*);
++extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*, FIELD*);
+ extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);
++
++#if USE_WIDEC_SUPPORT
++extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *);
++#endif
++
++#ifdef TRACE
++
++#define returnField(code)	TRACE_RETURN(code,field)
++#define returnFieldPtr(code)	TRACE_RETURN(code,field_ptr)
++#define returnForm(code)	TRACE_RETURN(code,form)
++#define returnFieldType(code)	TRACE_RETURN(code,field_type)
++#define returnFormHook(code)	TRACE_RETURN(code,form_hook)
++
++extern NCURSES_EXPORT(FIELD **)	    _nc_retrace_field_ptr (FIELD **);
++extern NCURSES_EXPORT(FIELD *)	    _nc_retrace_field (FIELD *);
++extern NCURSES_EXPORT(FIELDTYPE *)  _nc_retrace_field_type (FIELDTYPE *);
++extern NCURSES_EXPORT(FORM *)  _nc_retrace_form (FORM *);
++extern NCURSES_EXPORT(Form_Hook)  _nc_retrace_form_hook (Form_Hook);
++
++#else /* !TRACE */
++
++#define returnFieldPtr(code)	return code
++#define returnFieldType(code)	return code
++#define returnField(code)	return code
++#define returnForm(code)	return code
++#define returnFormHook(code)	return code
++
++#endif /* TRACE/!TRACE */
++
++/*
++ * Use Check_CTYPE_Field() to simplify FIELDTYPE's that use only the ccheck()
++ * function.
++ */
++#if USE_WIDEC_SUPPORT
++#define Check_CTYPE_Field(result, buffer, width, ccheck) \
++  while (*buffer && *buffer == ' ') \
++    buffer++; \
++  if (*buffer) \
++    { \
++      bool blank = FALSE; \
++      int len; \
++      int n; \
++      wchar_t *list = _nc_Widen_String((char *)buffer, &len); \
++      if (list != 0) \
++	{ \
++	  result = TRUE; \
++	  for (n = 0; n < len; ++n) \
++	    { \
++	      if (blank) \
++		{ \
++		  if (list[n] != ' ') \
++		    { \
++		      result = FALSE; \
++		      break; \
++		    } \
++		} \
++	      else if (list[n] == ' ') \
++		{ \
++		  blank = TRUE; \
++		  result = (n + 1 >= width); \
++		} \
++	      else if (!ccheck(list[n], NULL)) \
++		{ \
++		  result = FALSE; \
++		  break; \
++		} \
++	    } \
++	  free(list); \
++	} \
++    }
++#else
++#define Check_CTYPE_Field(result, buffer, width, ccheck) \
++  while (*buffer && *buffer == ' ') \
++    buffer++; \
++  if (*buffer) \
++    { \
++      unsigned char *s = buffer; \
++      int l = -1; \
++      while (*buffer && ccheck(*buffer, NULL)) \
++	buffer++; \
++      l = (int)(buffer - s); \
++      while (*buffer && *buffer == ' ') \
++	buffer++; \
++      result = ((*buffer || (l < width)) ? FALSE : TRUE); \
++    }
++#endif
++
++#endif /* FORM_PRIV_H */
+Index: form/frm_cursor.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/frm_cursor.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_cursor.c	2004-12-11 22:01:03.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_cursor.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_cursor.c,v 1.9 2004/12/11 22:01:03 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -49,16 +49,18 @@
+ |                    E_NOT_POSTED              - Form is not posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-pos_form_cursor (FORM * form)
++pos_form_cursor(FORM *form)
+ {
+   int res;
+ 
++  T((T_CALLED("pos_form_cursor(%p)"), form));
++
+   if (!form)
+-   res = E_BAD_ARGUMENT;
++    res = E_BAD_ARGUMENT;
+   else
+     {
+       if (!(form->status & _POSTED))
+-        res = E_NOT_POSTED;
++	res = E_NOT_POSTED;
+       else
+ 	res = _nc_Position_Form_Cursor(form);
+     }
+Index: form/frm_data.c
+Prereq:  1.10 
+--- ncurses-5.4-20040208/form/frm_data.c	2003-11-08 20:38:14.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_data.c	2004-12-11 22:29:28.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_data.c,v 1.10 2003/11/08 20:38:14 tom Exp $")
++MODULE_ID("$Id: frm_data.c,v 1.13 2004/12/11 22:29:28 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -45,10 +45,12 @@
+ |                    FALSE  - there are no off-screen data behind
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(bool)
+-data_behind (const FORM *form)
++data_behind(const FORM *form)
+ {
+   bool result = FALSE;
+ 
++  T((T_CALLED("data_behind(%p)"), form));
++
+   if (form && (form->status & _POSTED) && form->current)
+     {
+       FIELD *field;
+@@ -56,42 +58,69 @@
+       field = form->current;
+       if (!Single_Line_Field(field))
+ 	{
+-	  result = (form->toprow==0) ? FALSE : TRUE;
++	  result = (form->toprow == 0) ? FALSE : TRUE;
+ 	}
+       else
+ 	{
+-	  result = (form->begincol==0) ? FALSE : TRUE;
++	  result = (form->begincol == 0) ? FALSE : TRUE;
+ 	}
+     }
+-  return(result);
++  returnBool(result);
+ }
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+-|   Function      :  static char * After_Last_Non_Pad_Position(
+-|                                    char *buffer,
++|   Function      :  static char * Only_Padding(
++|                                    WINDOW *w,
+ |                                    int len,
+ |                                    int pad)
+ |   
+-|   Description   :  Find the last position in the buffer that doesn't
++|   Description   :  Test if 'length' cells starting at the current position
+ |                    contain a padding character.
+ |
+-|   Return Values :  The pointer to this position 
++|   Return Values :  true if only padding cells are found
+ +--------------------------------------------------------------------------*/
+-INLINE 
+-static char * After_Last_Non_Pad_Position(char *buffer, int len, int pad)
++INLINE static bool
++Only_Padding(WINDOW *w, int len, int pad)
+ {
+-  char *end = buffer + len;
+-
+-  assert(buffer && len>=0);
+-  while ( (buffer < end) && (*(end-1)==pad) )
+-    end--;
++  bool result = TRUE;
++  int y, x, j;
++  FIELD_CELL cell;
+ 
+-  return end;
++  getyx(w, y, x);
++  for (j = 0; j < len; ++j)
++    {
++      if (wmove(w, y, x + j) != ERR)
++	{
++#if USE_WIDEC_SUPPORT
++	  if (win_wch(w, &cell) != ERR)
++	    {
++	      if ((chtype)CharOf(cell) != ChCharOf(pad)
++		  || cell.chars[1] != 0)
++		{
++		  result = FALSE;
++		  break;
++		}
++	    }
++#else
++	  cell = winch(w);
++	  if (ChCharOf(cell) != ChCharOf(pad))
++	    {
++	      result = FALSE;
++	      break;
++	    }
++#endif
++	}
++      else
++	{
++	  /* if an error, return true: no non-padding text found */
++	  break;
++	}
++    }
++  /* no need to reset the cursor position; caller does this */
++  return result;
+ }
+ 
+-#define SMALL_BUFFER_SIZE (80)
+-
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+ |   Function      :  bool data_ahead(const FORM *form)
+@@ -103,31 +132,21 @@
+ |                    FALSE  - there are no off-screen data ahead
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(bool)
+-data_ahead (const FORM *form)
++data_ahead(const FORM *form)
+ {
+   bool result = FALSE;
+ 
++  T((T_CALLED("data_ahead(%p)"), form));
++
+   if (form && (form->status & _POSTED) && form->current)
+     {
+-      static char buffer[SMALL_BUFFER_SIZE + 1];
+       FIELD *field;
+-      bool large_buffer;
+       bool cursor_moved = FALSE;
+-      char *bp;
+-      char *found_content;
+       int pos;
+ 
+       field = form->current;
+       assert(form->w);
+ 
+-      large_buffer = (field->cols > SMALL_BUFFER_SIZE);
+-      if (large_buffer)
+-	bp = (char *)malloc((size_t)(field->cols) + 1);
+-      else
+-	bp = buffer;
+-
+-      assert(bp);
+-      
+       if (Single_Line_Field(field))
+ 	{
+ 	  int check_len;
+@@ -136,15 +155,12 @@
+ 	  while (pos < field->dcols)
+ 	    {
+ 	      check_len = field->dcols - pos;
+-	      if ( check_len >= field->cols )
++	      if (check_len >= field->cols)
+ 		check_len = field->cols;
+ 	      cursor_moved = TRUE;
+-	      wmove(form->w,0,pos);
+-	      winnstr(form->w,bp,check_len);
+-	      found_content = 
+-		After_Last_Non_Pad_Position(bp,check_len,field->pad);
+-	      if (found_content==bp)
+-		  pos += field->cols;		  
++	      wmove(form->w, 0, pos);
++	      if (Only_Padding(form->w, check_len, field->pad))
++		pos += field->cols;
+ 	      else
+ 		{
+ 		  result = TRUE;
+@@ -158,12 +174,9 @@
+ 	  while (pos < field->drows)
+ 	    {
+ 	      cursor_moved = TRUE;
+-	      wmove(form->w,pos,0);
++	      wmove(form->w, pos, 0);
+ 	      pos++;
+-	      winnstr(form->w,bp,field->cols);
+-	      found_content = 
+-		After_Last_Non_Pad_Position(bp,field->cols,field->pad);
+-	      if (found_content!=bp)
++	      if (!Only_Padding(form->w, field->cols, field->pad))
+ 		{
+ 		  result = TRUE;
+ 		  break;
+@@ -171,13 +184,10 @@
+ 	    }
+ 	}
+ 
+-      if (large_buffer)
+-	free(bp);
+-
+       if (cursor_moved)
+-	wmove(form->w,form->currow,form->curcol);
++	wmove(form->w, form->currow, form->curcol);
+     }
+-  return(result);
++  returnBool(result);
+ }
+ 
+ /* frm_data.c ends here */
+Index: form/frm_def.c
+Prereq:  1.13 
+--- ncurses-5.4-20040208/form/frm_def.c	2003-11-08 20:37:53.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_def.c	2004-12-25 22:26:01.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,32 +32,33 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_def.c,v 1.13 2003/11/08 20:37:53 tom Exp $")
++MODULE_ID("$Id: frm_def.c,v 1.17 2004/12/25 22:26:01 tom Exp $")
+ 
+ /* this can't be readonly */
+-static FORM default_form = {
+-  0,                                    /* status     */
+-  0,                                    /* rows       */
+-  0,                                    /* cols       */
+-  0,                                    /* currow     */
+-  0,                                    /* curcol     */
+-  0,                                    /* toprow     */
+-  0,                                    /* begincol   */
+-  -1,                                   /* maxfield   */
+-  -1,                                   /* maxpage    */
+-  -1,                                   /* curpage    */
+-  ALL_FORM_OPTS,                        /* opts       */
+-  (WINDOW *)0,                          /* win        */
+-  (WINDOW *)0,                          /* sub        */
+-  (WINDOW *)0,                          /* w          */
+-  (FIELD **)0,                          /* field      */
+-  (FIELD *)0,                           /* current    */
+-  (_PAGE *)0,                           /* page       */
+-  (char *)0,                            /* usrptr     */
+-  NULL,			                /* forminit   */
+-  NULL,                                 /* formterm   */
+-  NULL,                                 /* fieldinit  */
+-  NULL                                  /* fieldterm  */
++static FORM default_form =
++{
++  0,				/* status     */
++  0,				/* rows       */
++  0,				/* cols       */
++  0,				/* currow     */
++  0,				/* curcol     */
++  0,				/* toprow     */
++  0,				/* begincol   */
++  -1,				/* maxfield   */
++  -1,				/* maxpage    */
++  -1,				/* curpage    */
++  ALL_FORM_OPTS,		/* opts       */
++  (WINDOW *)0,			/* win        */
++  (WINDOW *)0,			/* sub        */
++  (WINDOW *)0,			/* w          */
++  (FIELD **)0,			/* field      */
++  (FIELD *)0,			/* current    */
++  (_PAGE *) 0,			/* page       */
++  (char *)0,			/* usrptr     */
++  NULL,				/* forminit   */
++  NULL,				/* formterm   */
++  NULL,				/* fieldinit  */
++  NULL				/* fieldterm  */
+ };
+ 
+ NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form;
+@@ -74,39 +75,40 @@
+ |
+ |   Return Values :  New head of sorted fieldlist
+ +--------------------------------------------------------------------------*/
+-static FIELD *Insert_Field_By_Position(FIELD *newfield, FIELD *head)
++static FIELD *
++Insert_Field_By_Position(FIELD *newfield, FIELD *head)
+ {
+   FIELD *current, *newhead;
+-  
++
+   assert(newfield);
+ 
+   if (!head)
+-    { /* empty list is trivial */
++    {				/* empty list is trivial */
+       newhead = newfield->snext = newfield->sprev = newfield;
+     }
+   else
+     {
+       newhead = current = head;
+-      while((current->frow < newfield->frow) || 
+-	    ((current->frow==newfield->frow) && 
+-	     (current->fcol < newfield->fcol)) )
++      while ((current->frow < newfield->frow) ||
++	     ((current->frow == newfield->frow) &&
++	      (current->fcol < newfield->fcol)))
+ 	{
+ 	  current = current->snext;
+-	  if (current==head)
+-	    { /* We cycled through. Reset head to indicate that */
++	  if (current == head)
++	    {			/* We cycled through. Reset head to indicate that */
+ 	      head = (FIELD *)0;
+ 	      break;
+ 	    }
+ 	}
+-      /* we leave the loop with current pointing to the field after newfield*/
+-      newfield->snext	 = current;
+-      newfield->sprev	 = current->sprev;
++      /* we leave the loop with current pointing to the field after newfield */
++      newfield->snext = current;
++      newfield->sprev = current->sprev;
+       newfield->snext->sprev = newfield;
+       newfield->sprev->snext = newfield;
+-      if (current==head) 
++      if (current == head)
+ 	newhead = newfield;
+     }
+-  return(newhead);
++  return (newhead);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -117,25 +119,26 @@
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Disconnect_Fields( FORM * form )
++static void
++Disconnect_Fields(FORM *form)
+ {
+   if (form->field)
+     {
+       FIELD **fields;
+ 
+-      for(fields=form->field;*fields;fields++)
++      for (fields = form->field; *fields; fields++)
+ 	{
+-	  if (form == (*fields)->form) 
++	  if (form == (*fields)->form)
+ 	    (*fields)->form = (FORM *)0;
+ 	}
+-      
++
+       form->rows = form->cols = 0;
+       form->maxfield = form->maxpage = -1;
+       form->field = (FIELD **)0;
+-      if (form->page) 
++      if (form->page)
+ 	free(form->page);
+-      form->page = (_PAGE *)0;
+-    }	
++      form->page = (_PAGE *) 0;
++    }
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -149,82 +152,86 @@
+ |                    E_BAD_ARGUMENT  - Invalid form pointer or field array
+ |                    E_SYSTEM_ERROR  - not enough memory
+ +--------------------------------------------------------------------------*/
+-static int Connect_Fields(FORM  * form, FIELD ** fields)
++static int
++Connect_Fields(FORM *form, FIELD **fields)
+ {
+   int field_cnt, j;
+   int page_nr;
+   int maximum_row_in_field, maximum_col_in_field;
+   _PAGE *pg;
+-  
++
++  T((T_CALLED("Connect_Fields(%p,%p)"), form, fields));
++
+   assert(form);
+ 
+-  form->field    = fields;
++  form->field = fields;
+   form->maxfield = 0;
+-  form->maxpage  = 0;
++  form->maxpage = 0;
+ 
+   if (!fields)
+     RETURN(E_OK);
+-  
++
+   page_nr = 0;
+   /* store formpointer in fields and count pages */
+-  for(field_cnt=0;fields[field_cnt];field_cnt++)
++  for (field_cnt = 0; fields[field_cnt]; field_cnt++)
+     {
+-      if (fields[field_cnt]->form) 
++      if (fields[field_cnt]->form)
+ 	RETURN(E_CONNECTED);
+-      if ( field_cnt==0 || 
+-	  (fields[field_cnt]->status & _NEWPAGE)) 
++      if (field_cnt == 0 ||
++	  (fields[field_cnt]->status & _NEWPAGE))
+ 	page_nr++;
+       fields[field_cnt]->form = form;
+-    }	
+-  if (field_cnt==0)
++    }
++  if (field_cnt == 0)
+     RETURN(E_BAD_ARGUMENT);
+-  
++
+   /* allocate page structures */
+-  if ( (pg = (_PAGE *)malloc(page_nr * sizeof(_PAGE))) != (_PAGE *)0 )
++  if ((pg = (_PAGE *) malloc(page_nr * sizeof(_PAGE))) != (_PAGE *) 0)
+     {
+       form->page = pg;
+     }
+   else
+     RETURN(E_SYSTEM_ERROR);
+-  
++
+   /* Cycle through fields and calculate page boundaries as well as
+      size of the form */
+-  for(j=0;j<field_cnt;j++)
++  for (j = 0; j < field_cnt; j++)
+     {
+-      if (j==0) 
++      if (j == 0)
+ 	pg->pmin = j;
+       else
+ 	{
+ 	  if (fields[j]->status & _NEWPAGE)
+ 	    {
+-	      pg->pmax = j-1;
++	      pg->pmax = j - 1;
+ 	      pg++;
+ 	      pg->pmin = j;
+ 	    }
+ 	}
+-      
++
+       maximum_row_in_field = fields[j]->frow + fields[j]->rows;
+       maximum_col_in_field = fields[j]->fcol + fields[j]->cols;
+-      
+-      if (form->rows < maximum_row_in_field) 
++
++      if (form->rows < maximum_row_in_field)
+ 	form->rows = maximum_row_in_field;
+-      if (form->cols < maximum_col_in_field) 
++      if (form->cols < maximum_col_in_field)
+ 	form->cols = maximum_col_in_field;
+     }
+-  
+-  pg->pmax       = field_cnt-1;
++
++  pg->pmax = field_cnt - 1;
+   form->maxfield = field_cnt;
+-  form->maxpage  = page_nr; 
+-  
++  form->maxpage = page_nr;
++
+   /* Sort fields on form pages */
+-  for(page_nr = 0;page_nr < form->maxpage; page_nr++)
++  for (page_nr = 0; page_nr < form->maxpage; page_nr++)
+     {
+       FIELD *fld = (FIELD *)0;
+-      for(j = form->page[page_nr].pmin;j <= form->page[page_nr].pmax;j++)
++
++      for (j = form->page[page_nr].pmin; j <= form->page[page_nr].pmax; j++)
+ 	{
+ 	  fields[j]->index = j;
+-	  fields[j]->page  = page_nr;
+-	  fld = Insert_Field_By_Position(fields[j],fld);
++	  fields[j]->page = page_nr;
++	  fld = Insert_Field_By_Position(fields[j], fld);
+ 	}
+       form->page[page_nr].smin = fld->index;
+       form->page[page_nr].smax = fld->sprev->index;
+@@ -242,25 +249,27 @@
+ |   Return Values :  E_OK            - success
+ |                    any other       - error occurred
+ +--------------------------------------------------------------------------*/
+-INLINE static int Associate_Fields(FORM  *form, FIELD **fields)
++INLINE static int
++Associate_Fields(FORM *form, FIELD **fields)
+ {
+-  int res = Connect_Fields(form,fields);
++  int res = Connect_Fields(form, fields);
++
+   if (res == E_OK)
+     {
+-      if (form->maxpage>0)
++      if (form->maxpage > 0)
+ 	{
+ 	  form->curpage = 0;
+-	  form_driver(form,FIRST_ACTIVE_MAGIC);
++	  form_driver(form, FIRST_ACTIVE_MAGIC);
+ 	}
+       else
+ 	{
+ 	  form->curpage = -1;
+ 	  form->current = (FIELD *)0;
+-	} 
++	}
+     }
+-  return(res);
++  return (res);
+ }
+-			    
++
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+ |   Function      :  FORM *new_form( FIELD **fields )
+@@ -270,16 +279,17 @@
+ |   Return Values :  Pointer to form. NULL if error occurred.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(FORM *)
+-new_form (FIELD ** fields)
+-{	
++new_form(FIELD **fields)
++{
+   int err = E_SYSTEM_ERROR;
+ 
+   FORM *form = (FORM *)malloc(sizeof(FORM));
+-  
++
++  T((T_CALLED("new_form(%p)"), fields));
+   if (form)
+     {
+       *form = *_nc_Default_Form;
+-      if ((err=Associate_Fields(form,fields))!=E_OK)
++      if ((err = Associate_Fields(form, fields)) != E_OK)
+ 	{
+ 	  free_form(form);
+ 	  form = (FORM *)0;
+@@ -288,8 +298,8 @@
+ 
+   if (!form)
+     SET_ERROR(err);
+-  
+-  return(form);
++
++  returnForm(form);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -303,19 +313,21 @@
+ |                    E_POSTED       - form is posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-free_form (FORM * form)
++free_form(FORM *form)
+ {
+-  if ( !form )	
++  T((T_CALLED("free_form(%p)"), form));
++
++  if (!form)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if ( form->status & _POSTED)  
++  if (form->status & _POSTED)
+     RETURN(E_POSTED);
+-  
+-  Disconnect_Fields( form );
+-  if (form->page) 
++
++  Disconnect_Fields(form);
++  if (form->page)
+     free(form->page);
+   free(form);
+-  
++
+   RETURN(E_OK);
+ }
+ 
+@@ -330,26 +342,28 @@
+ |                    E_POSTED          - form is posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_form_fields (FORM  * form, FIELD ** fields)
++set_form_fields(FORM *form, FIELD **fields)
+ {
+   FIELD **old;
+   int res;
+-  
+-  if ( !form )	
++
++  T((T_CALLED("set_form_fields(%p,%p)"), form, fields));
++
++  if (!form)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if ( form->status & _POSTED )	
++  if (form->status & _POSTED)
+     RETURN(E_POSTED);
+-  
++
+   old = form->field;
+-  Disconnect_Fields( form );
+-  
+-  if( (res = Associate_Fields( form, fields )) != E_OK )
+-    Connect_Fields( form, old );
+-  
++  Disconnect_Fields(form);
++
++  if ((res = Associate_Fields(form, fields)) != E_OK)
++    Connect_Fields(form, old);
++
+   RETURN(res);
+ }
+-	
++
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+ |   Function      :  FIELD **form_fields( const FORM *form )
+@@ -359,9 +373,10 @@
+ |   Return Values :  Pointer to field array
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(FIELD **)
+-form_fields (const FORM * form)
++form_fields(const FORM *form)
+ {
+-  return (Normalize_Form( form )->field);
++  T((T_CALLED("form_field(%p)"), form));
++  returnFieldPtr(Normalize_Form(form)->field);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -373,9 +388,11 @@
+ |   Return Values :  Number of fields, -1 if none are defined
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-field_count (const FORM * form)
++field_count(const FORM *form)
+ {
+-  return (Normalize_Form( form )->maxfield);
++  T((T_CALLED("field_count(%p)"), form));
++
++  returnCode(Normalize_Form(form)->maxfield);
+ }
+ 
+ /* frm_def.c ends here */
+Index: form/frm_driver.c
+Prereq:  1.45 
+--- ncurses-5.4-20040208/form/frm_driver.c	2003-12-06 17:22:42.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_driver.c	2005-02-26 21:30:08.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,11 +32,11 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_driver.c,v 1.45 2003/12/06 17:22:42 tom Exp $")
++MODULE_ID("$Id: frm_driver.c,v 1.67 2005/02/26 21:30:08 tom Exp $")
+ 
+ /*----------------------------------------------------------------------------
+   This is the core module of the form library. It contains the majority
+-  of the driver routines as well as the form_driver function. 
++  of the driver routines as well as the form_driver function.
+ 
+   Essentially this module is nearly the whole library. This is because
+   all the functions in this module depends on some others in the module,
+@@ -53,7 +53,7 @@
+         The current field of the form is left and some new field is
+         entered.
+    c)   Intra-Field Navigation     ( all functions prefixed by IFN_ )
+-        The current position in the current field is changed. 
++        The current position in the current field is changed.
+    d)   Vertical Scrolling         ( all functions prefixed by VSC_ )
+         Essentially this is a specialization of Intra-Field navigation.
+         It has to check for a multi-line field.
+@@ -87,7 +87,7 @@
+ of the original SVr4 implementation, although in some areas it is quite
+ clear that this isn't the most appropriate way. As far as possible this
+ sources will allow you to build a forms lib that behaves quite similar
+-to SVr4, but now and in the future we will give you better options. 
++to SVr4, but now and in the future we will give you better options.
+ Perhaps at some time we will make this configurable at runtime.
+ */
+ 
+@@ -98,15 +98,27 @@
+ /* Allow dynamic field growth also when navigating past the end */
+ #define GROW_IF_NAVIGATE (1)
+ 
++#if USE_WIDEC_SUPPORT
++#define myADDNSTR(w, s, n) wadd_wchnstr(w, s, n)
++#define myINSNSTR(w, s, n) wins_wchnstr(w, s, n)
++#define myINNSTR(w, s, n)  fix_wchnstr(w, s, n)
++#define myWCWIDTH(w, y, x) cell_width(w, y, x)
++#else
++#define myADDNSTR(w, s, n) waddnstr(w, s, n)
++#define myINSNSTR(w, s, n) winsnstr(w, s, n)
++#define myINNSTR(w, s, n)  winnstr(w, s, n)
++#define myWCWIDTH(w, y, x) 1
++#endif
++
+ /*----------------------------------------------------------------------------
+   Forward references to some internally used static functions
+   --------------------------------------------------------------------------*/
+-static int Inter_Field_Navigation ( int (* const fct) (FORM *), FORM * form );
+-static int FN_Next_Field (FORM * form);
+-static int FN_Previous_Field (FORM * form);
++static int Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form);
++static int FN_Next_Field(FORM *form);
++static int FN_Previous_Field(FORM *form);
+ static int FE_New_Line(FORM *);
+ static int FE_Delete_Previous(FORM *);
+-
++
+ /*----------------------------------------------------------------------------
+   Macro Definitions.
+ 
+@@ -190,168 +202,282 @@
+ #define First_Position_In_Current_Field(form) \
+   (((form)->currow==0) && ((form)->curcol==0))
+ 
+-
+ #define Minimum(a,b) (((a)<=(b)) ? (a) : (b))
+ #define Maximum(a,b) (((a)>=(b)) ? (a) : (b))
+-
++
++/*----------------------------------------------------------------------------
++  Useful constants
++  --------------------------------------------------------------------------*/
++static FIELD_CELL myBLANK = BLANK;
++static FIELD_CELL myZEROS;
++
++/*----------------------------------------------------------------------------
++  Wide-character special functions
++  --------------------------------------------------------------------------*/
++#if USE_WIDEC_SUPPORT
++/* like winsnstr */
++static int
++wins_wchnstr(WINDOW *w, cchar_t *s, int n)
++{
++  int code = ERR;
++  int y, x;
++
++  while (n-- > 0)
++    {
++      getyx(w, y, x);
++      if ((code = wins_wch(w, s++)) != OK)
++	break;
++      if ((code = wmove(w, y, x + 1)) != OK)
++	break;
++    }
++  return code;
++}
++
++/* win_wchnstr is inconsistent with winnstr, since it returns OK rather than
++ * the number of items transferred.
++ */
++static int
++fix_wchnstr(WINDOW *w, cchar_t *s, int n)
++{
++  win_wchnstr(w, s, n);
++  return n;
++}
++
++/*
++ * Returns the column of the base of the given cell.
++ */
++static int
++cell_base(WINDOW *win, int y, int x)
++{
++  int result = x;
++
++  while (LEGALYX(win, y, x))
++    {
++      cchar_t *data = &(win->_line[y].text[x]);
++
++      if (isWidecBase(CHDEREF(data)) || !isWidecExt(CHDEREF(data)))
++	{
++	  result = x;
++	  break;
++	}
++      --x;
++    }
++  return result;
++}
++
++/*
++ * Returns the number of columns needed for the given cell in a window.
++ */
++static int
++cell_width(WINDOW *win, int y, int x)
++{
++  int result = 1;
++
++  if (LEGALYX(win, y, x))
++    {
++      cchar_t *data = &(win->_line[y].text[x]);
++
++      if (isWidecExt(CHDEREF(data)))
++	{
++	  /* recur, providing the number of columns to the next character */
++	  result = cell_width(win, y, x - 1);
++	}
++      else
++	{
++	  result = wcwidth(CharOf(CHDEREF(data)));
++	}
++    }
++  return result;
++}
++
++/*
++ * There is no wide-character function such as wdel_wch(), so we must find
++ * all of the cells that comprise a multi-column character and delete them
++ * one-by-one.
++ */
++static void
++delete_char(FORM *form)
++{
++  int cells = cell_width(form->w, form->currow, form->curcol);
++
++  form->curcol = cell_base(form->w, form->currow, form->curcol);
++  wmove(form->w, form->currow, form->curcol);
++  while (cells-- > 0)
++    {
++      wdelch(form->w);
++    }
++}
++#define DeleteChar(form) delete_char(form)
++#else
++#define DeleteChar(form) \
++	  wmove((form)->w, (form)->currow, (form)->curcol), \
++	  wdelch((form)->w)
++#endif
++
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static char *Get_Start_Of_Data(char * buf, int blen)
+-|   
++|
+ |   Description   :  Return pointer to first non-blank position in buffer.
+ |                    If buffer is empty return pointer to buffer itself.
+ |
+ |   Return Values :  Pointer to first non-blank position in buffer
+ +--------------------------------------------------------------------------*/
+-INLINE static char *Get_Start_Of_Data(char * buf, int blen)
++INLINE static FIELD_CELL *
++Get_Start_Of_Data(FIELD_CELL *buf, int blen)
+ {
+-  char *p   = buf;
+-  char *end = &buf[blen];
++  FIELD_CELL *p = buf;
++  FIELD_CELL *end = &buf[blen];
+ 
+-  assert(buf && blen>=0);
+-  while( (p < end) && is_blank(*p) ) 
++  assert(buf && blen >= 0);
++  while ((p < end) && ISBLANK(*p))
+     p++;
+-  return( (p==end) ? buf : p );
++  return ((p == end) ? buf : p);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static char *After_End_Of_Data(char * buf, int blen)
+-|   
++|
+ |   Description   :  Return pointer after last non-blank position in buffer.
+ |                    If buffer is empty, return pointer to buffer itself.
+ |
+-|   Return Values :  Pointer to position after last non-blank position in 
++|   Return Values :  Pointer to position after last non-blank position in
+ |                    buffer.
+ +--------------------------------------------------------------------------*/
+-INLINE static char *After_End_Of_Data(char * buf,int blen)
++INLINE static FIELD_CELL *
++After_End_Of_Data(FIELD_CELL *buf, int blen)
+ {
+-  char *p   = &buf[blen];
+-  
+-  assert(buf && blen>=0);
+-  while( (p>buf) && is_blank(p[-1]) ) 
++  FIELD_CELL *p = &buf[blen];
++
++  assert(buf && blen >= 0);
++  while ((p > buf) && ISBLANK(p[-1]))
+     p--;
+-  return( p );
++  return (p);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static char *Get_First_Whitespace_Character(
+ |                                     char * buf, int   blen)
+-|   
++|
+ |   Description   :  Position to the first whitespace character.
+ |
+ |   Return Values :  Pointer to first whitespace character in buffer.
+ +--------------------------------------------------------------------------*/
+-INLINE static char *Get_First_Whitespace_Character(char * buf, int blen)
++INLINE static FIELD_CELL *
++Get_First_Whitespace_Character(FIELD_CELL *buf, int blen)
+ {
+-  char *p   = buf;
+-  char *end = &p[blen];
+-  
+-  assert(buf && blen>=0);
+-  while( (p < end) && !is_blank(*p)) 
++  FIELD_CELL *p = buf;
++  FIELD_CELL *end = &p[blen];
++
++  assert(buf && blen >= 0);
++  while ((p < end) && !ISBLANK(*p))
+     p++;
+-  return( (p==end) ? buf : p );
++  return ((p == end) ? buf : p);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static char *After_Last_Whitespace_Character(
+ |                                     char * buf, int blen)
+-|   
++|
+ |   Description   :  Get the position after the last whitespace character.
+ |
+-|   Return Values :  Pointer to position after last whitespace character in 
++|   Return Values :  Pointer to position after last whitespace character in
+ |                    buffer.
+ +--------------------------------------------------------------------------*/
+-INLINE static char *After_Last_Whitespace_Character(char * buf, int blen)
++INLINE static FIELD_CELL *
++After_Last_Whitespace_Character(FIELD_CELL *buf, int blen)
+ {
+-  char *p   = &buf[blen];
+-  
+-  assert(buf && blen>=0);
+-  while( (p>buf) && !is_blank(p[-1]) ) 
++  FIELD_CELL *p = &buf[blen];
++
++  assert(buf && blen >= 0);
++  while ((p > buf) && !ISBLANK(p[-1]))
+     p--;
+-  return( p );
++  return (p);
+ }
+ 
+ /* Set this to 1 to use the div_t version. This is a good idea if your
+    compiler has an intrinsic div() support. Unfortunately GNU-C has it
+-   not yet. 
++   not yet.
+    N.B.: This only works if form->curcol follows immediately form->currow
+-         and both are of type int. 
++         and both are of type int.
+ */
+ #define USE_DIV_T (0)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static void Adjust_Cursor_Position(
+ |                                       FORM * form, const char * pos)
+-|   
+-|   Description   :  Set current row and column of the form to values 
++|
++|   Description   :  Set current row and column of the form to values
+ |                    corresponding to the buffer position.
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-INLINE static void Adjust_Cursor_Position(FORM * form, const char * pos)
++INLINE static void
++Adjust_Cursor_Position(FORM *form, const FIELD_CELL *pos)
+ {
+   FIELD *field;
+   int idx;
+ 
+   field = form->current;
+-  assert( pos >= field->buf && field->dcols > 0);
+-  idx = (int)( pos - field->buf );
++  assert(pos >= field->buf && field->dcols > 0);
++  idx = (int)(pos - field->buf);
+ #if USE_DIV_T
+-  *((div_t *)&(form->currow)) = div(idx,field->dcols);
++  *((div_t *) & (form->currow)) = div(idx, field->dcols);
+ #else
+   form->currow = idx / field->dcols;
+   form->curcol = idx - field->cols * form->currow;
+-#endif  
+-  if ( field->drows < form->currow )
++#endif
++  if (field->drows < form->currow)
+     form->currow = 0;
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static void Buffer_To_Window(
+ |                                      const FIELD  * field,
+ |                                      WINDOW * win)
+-|   
++|
+ |   Description   :  Copy the buffer to the window. If it is a multi-line
+ |                    field, the buffer is split to the lines of the
+ |                    window without any editing.
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Buffer_To_Window(const FIELD  * field, WINDOW * win)
++static void
++Buffer_To_Window(const FIELD *field, WINDOW *win)
+ {
+   int width, height;
+   int len;
+   int row;
+-  char *pBuffer;
++  FIELD_CELL *pBuffer;
+ 
+   assert(win && field);
+ 
+-  width  = getmaxx(win);
++  width = getmaxx(win);
+   height = getmaxy(win);
+ 
+-  for(row=0, pBuffer=field->buf; 
+-      row < height; 
+-      row++, pBuffer += width )
++  for (row = 0, pBuffer = field->buf;
++       row < height;
++       row++, pBuffer += width)
+     {
+-      if ((len = (int)( After_End_Of_Data( pBuffer, width ) - pBuffer )) > 0)
++      if ((len = (int)(After_End_Of_Data(pBuffer, width) - pBuffer)) > 0)
+ 	{
+-	  wmove( win, row, 0 );
+-	  waddnstr( win, pBuffer, len );
++	  wmove(win, row, 0);
++	  myADDNSTR(win, pBuffer, len);
+ 	}
+-    }	
++    }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static void Window_To_Buffer(
+ |                                          WINDOW * win,
+ |                                          FIELD  * field)
+-|   
++|
+ |   Description   :  Copy the content of the window into the buffer.
+ |                    The multiple lines of a window are simply
+ |                    concatenated into the buffer. Pad characters in
+@@ -359,42 +485,48 @@
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Window_To_Buffer(WINDOW * win, FIELD  * field)
++static void
++Window_To_Buffer(WINDOW *win, FIELD *field)
+ {
+   int pad;
+   int len = 0;
+-  char *p;
++  FIELD_CELL *p;
+   int row, height;
+-  
+-  assert(win && field && field->buf );
++
++  assert(win && field && field->buf);
+ 
+   pad = field->pad;
+   p = field->buf;
+   height = getmaxy(win);
+ 
+-  for(row=0; (row < height) && (row < field->drows); row++ )
++  for (row = 0; (row < height) && (row < field->drows); row++)
+     {
+-      wmove( win, row, 0 );
+-      len += winnstr( win, p+len, field->dcols );
++      wmove(win, row, 0);
++      len += myINNSTR(win, p + len, field->dcols);
+     }
+-  p[len] = '\0';
++  p[len] = myZEROS;
+ 
+   /* replace visual padding character by blanks in buffer */
+   if (pad != C_BLANK)
+     {
+       int i;
+-      for(i=0; i<len; i++, p++)
++
++      for (i = 0; i < len; i++, p++)
+ 	{
+-	  if (*p==pad) 
+-	    *p = C_BLANK;
++	  if ((unsigned long)CharOf(*p) == ChCharOf(pad)
++#if USE_WIDEC_SUPPORT
++	      && p->chars[1] == 0
++#endif
++	      && AttrOf(*p) == ChAttrOf(pad))
++	    *p = myBLANK;
+ 	}
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static void Synchronize_Buffer(FORM * form)
+-|   
++|
+ |   Description   :  If there was a change, copy the content of the
+ |                    window into the buffer, so the buffer is synchronized
+ |                    with the windows content. We have to indicate that the
+@@ -402,21 +534,22 @@
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-INLINE static void Synchronize_Buffer(FORM * form)
++INLINE static void
++Synchronize_Buffer(FORM *form)
+ {
+   if (form->status & _WINDOW_MODIFIED)
+     {
+       form->status &= ~_WINDOW_MODIFIED;
+-      form->status |=  _FCHECK_REQUIRED;
+-      Window_To_Buffer(form->w,form->current);
+-      wmove(form->w,form->currow,form->curcol);
++      form->status |= _FCHECK_REQUIRED;
++      Window_To_Buffer(form->w, form->current);
++      wmove(form->w, form->currow, form->curcol);
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static bool Field_Grown( FIELD *field, int amount)
+-|   
++|
+ |   Description   :  This function is called for growable dynamic fields
+ |                    only. It has to increase the buffers and to allocate
+ |                    a new window for this field.
+@@ -427,7 +560,8 @@
+ |   Return Values :  TRUE     - field successfully increased
+ |                    FALSE    - there was some error
+ +--------------------------------------------------------------------------*/
+-static bool Field_Grown(FIELD * field, int amount)
++static bool
++Field_Grown(FIELD *field, int amount)
+ {
+   bool result = FALSE;
+ 
+@@ -438,23 +572,23 @@
+       int new_buflen;
+       int old_dcols = field->dcols;
+       int old_drows = field->drows;
+-      char *oldbuf  = field->buf;
+-      char *newbuf;
++      FIELD_CELL *oldbuf = field->buf;
++      FIELD_CELL *newbuf;
+ 
+       int growth;
+       FORM *form = field->form;
+-      bool need_visual_update = ((form != (FORM *)0)      &&
++      bool need_visual_update = ((form != (FORM *)0) &&
+ 				 (form->status & _POSTED) &&
+-				 (form->current==field));
+-      
++				 (form->current == field));
++
+       if (need_visual_update)
+ 	Synchronize_Buffer(form);
+-      
++
+       if (single_line_field)
+ 	{
+ 	  growth = field->cols * amount;
+ 	  if (field->maxgrow)
+-	    growth = Minimum(field->maxgrow - field->dcols,growth);
++	    growth = Minimum(field->maxgrow - field->dcols, growth);
+ 	  field->dcols += growth;
+ 	  if (field->dcols == field->maxgrow)
+ 	    field->status &= ~_MAY_GROW;
+@@ -463,96 +597,113 @@
+ 	{
+ 	  growth = (field->rows + field->nrow) * amount;
+ 	  if (field->maxgrow)
+-	    growth = Minimum(field->maxgrow - field->drows,growth);
++	    growth = Minimum(field->maxgrow - field->drows, growth);
+ 	  field->drows += growth;
+ 	  if (field->drows == field->maxgrow)
+ 	    field->status &= ~_MAY_GROW;
+ 	}
+       /* drows, dcols changed, so we get really the new buffer length */
+       new_buflen = Buffer_Length(field);
+-      newbuf=(char *)malloc((size_t)Total_Buffer_Size(field));
++      newbuf = (FIELD_CELL *)malloc(Total_Buffer_Size(field));
+       if (!newbuf)
+-	{ /* restore to previous state */
++	{
++	  /* restore to previous state */
+ 	  field->dcols = old_dcols;
+ 	  field->drows = old_drows;
+-	  if (( single_line_field && (field->dcols!=field->maxgrow)) ||
+-	      (!single_line_field && (field->drows!=field->maxgrow)))
++	  if ((single_line_field && (field->dcols != field->maxgrow)) ||
++	      (!single_line_field && (field->drows != field->maxgrow)))
+ 	    field->status |= _MAY_GROW;
+-	  return FALSE;
+ 	}
+       else
+-	{ /* Copy all the buffers. This is the reason why we can't
+-	     just use realloc().
+-	     */
+-	  int i;
+-	  char *old_bp;
+-	  char *new_bp;
+-	  
++	{
++	  /* Copy all the buffers.  This is the reason why we can't just use
++	   * realloc().
++	   */
++	  int i, j;
++	  FIELD_CELL *old_bp;
++	  FIELD_CELL *new_bp;
++
++	  result = TRUE;	/* allow sharing of recovery on failure */
++
+ 	  field->buf = newbuf;
+-	  for(i=0;i<=field->nbuf;i++)
++	  for (i = 0; i <= field->nbuf; i++)
++	    {
++	      new_bp = Address_Of_Nth_Buffer(field, i);
++	      old_bp = oldbuf + i * (1 + old_buflen);
++	      for (j = 0; j < old_buflen; ++j)
++		new_bp[j] = old_bp[j];
++	      while (j < new_buflen)
++		new_bp[j++] = myBLANK;
++	      new_bp[new_buflen] = myZEROS;
++	    }
++
++#if USE_WIDEC_SUPPORT
++	  if (wresize(field->working, 1, Buffer_Length(field) + 1) == ERR)
++	    result = FALSE;
++#endif
++
++	  if (need_visual_update && result)
+ 	    {
+-	      new_bp = Address_Of_Nth_Buffer(field,i);
+-	      old_bp = oldbuf + i*(1+old_buflen);
+-	      memcpy(new_bp,old_bp,(size_t)old_buflen);
+-	      if (new_buflen > old_buflen)
+-		memset(new_bp + old_buflen,C_BLANK,
+-		       (size_t)(new_buflen - old_buflen));
+-	      *(new_bp + new_buflen) = '\0';
+-	    }
+-
+-	  if (need_visual_update)
+-	    { 	      
+-	      WINDOW *new_window = newpad(field->drows,field->dcols);
+-	      if (!new_window)
+-		{ /* restore old state */
+-		  field->dcols = old_dcols;
+-		  field->drows = old_drows;
+-		  field->buf   = oldbuf;
+-		  if (( single_line_field              && 
+-			(field->dcols!=field->maxgrow)) ||
+-		      (!single_line_field              && 
+-		       (field->drows!=field->maxgrow)))
+-		    field->status |= _MAY_GROW;
+-		  free( newbuf );
+-		  return FALSE;
++	      WINDOW *new_window = newpad(field->drows, field->dcols);
++
++	      if (new_window != 0)
++		{
++		  assert(form != (FORM *)0);
++		  if (form->w)
++		    delwin(form->w);
++		  form->w = new_window;
++		  Set_Field_Window_Attributes(field, form->w);
++		  werase(form->w);
++		  Buffer_To_Window(field, form->w);
++		  untouchwin(form->w);
++		  wmove(form->w, form->currow, form->curcol);
+ 		}
+-	      assert(form!=(FORM *)0);
+-	      if (form->w)
+-		delwin(form->w);
+-	      form->w = new_window;
+-	      Set_Field_Window_Attributes(field,form->w);
+-	      werase(form->w);
+-	      Buffer_To_Window(field,form->w);
+-	      untouchwin(form->w);
+-	      wmove(form->w,form->currow,form->curcol);
++	      else
++		result = FALSE;
+ 	    }
+ 
+-	  free(oldbuf);
+-	  /* reflect changes in linked fields */
+-	  if (field != field->link)
+-	    {
+-	      FIELD *linked_field;
+-	      for(linked_field = field->link;
+-		  linked_field!= field;
+-		  linked_field = linked_field->link)
++	  if (result)
++	    {
++	      free(oldbuf);
++	      /* reflect changes in linked fields */
++	      if (field != field->link)
+ 		{
+-		  linked_field->buf   = field->buf;
+-		  linked_field->drows = field->drows;
+-		  linked_field->dcols = field->dcols;
++		  FIELD *linked_field;
++
++		  for (linked_field = field->link;
++		       linked_field != field;
++		       linked_field = linked_field->link)
++		    {
++		      linked_field->buf = field->buf;
++		      linked_field->drows = field->drows;
++		      linked_field->dcols = field->dcols;
++		    }
+ 		}
+ 	    }
+-	  result = TRUE;
+-	}	
++	  else
++	    {
++	      /* restore old state */
++	      field->dcols = old_dcols;
++	      field->drows = old_drows;
++	      field->buf = oldbuf;
++	      if ((single_line_field &&
++		   (field->dcols != field->maxgrow)) ||
++		  (!single_line_field &&
++		   (field->drows != field->maxgrow)))
++		field->status |= _MAY_GROW;
++	      free(newbuf);
++	    }
++	}
+     }
+-  return(result);
++  return (result);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int _nc_Position_Form_Cursor(FORM * form)
+-|   
++|
+ |   Description   :  Position the cursor in the window for the current
+-|                    field to be in sync. with the currow and curcol 
++|                    field to be in sync. with the currow and curcol
+ |                    values.
+ |
+ |   Return Values :  E_OK              - success
+@@ -561,39 +712,39 @@
+ |                                        field-window
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-_nc_Position_Form_Cursor (FORM * form)
++_nc_Position_Form_Cursor(FORM *form)
+ {
+-  FIELD  *field;
++  FIELD *field;
+   WINDOW *formwin;
+-  
++
+   if (!form)
+-    return(E_BAD_ARGUMENT);
++    return (E_BAD_ARGUMENT);
+ 
+-  if (!form->w || !form->current) 
+-    return(E_SYSTEM_ERROR);
++  if (!form->w || !form->current)
++    return (E_SYSTEM_ERROR);
+ 
+-  field    = form->current;
+-  formwin  = Get_Form_Window(form);
++  field = form->current;
++  formwin = Get_Form_Window(form);
+ 
+-  wmove( form->w, form->currow, form->curcol );
+-  if ( Has_Invisible_Parts(field) )
++  wmove(form->w, form->currow, form->curcol);
++  if (Has_Invisible_Parts(field))
+     {
+       /* in this case fieldwin isn't derived from formwin, so we have
+-	 to move the cursor in formwin by hand... */
++         to move the cursor in formwin by hand... */
+       wmove(formwin,
+ 	    field->frow + form->currow - form->toprow,
+ 	    field->fcol + form->curcol - form->begincol);
+       wcursyncup(formwin);
+     }
+-  else 
++  else
+     wcursyncup(form->w);
+-  return(E_OK);
++  return (E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int _nc_Refresh_Current_Field(FORM * form)
+-|   
++|
+ |   Description   :  Propagate the changes in the fields window to the
+ |                    window of the form.
+ |
+@@ -602,19 +753,21 @@
+ |                    E_SYSTEM_ERROR    - general error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-_nc_Refresh_Current_Field (FORM * form)
++_nc_Refresh_Current_Field(FORM *form)
+ {
+   WINDOW *formwin;
+-  FIELD  *field;
++  FIELD *field;
++
++  T((T_CALLED("_nc_Refresh_Current_Field(%p)"), form));
+ 
+   if (!form)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if (!form->w || !form->current) 
++  if (!form->w || !form->current)
+     RETURN(E_SYSTEM_ERROR);
+ 
+-  field    = form->current;
+-  formwin  = Get_Form_Window(form);
++  field = form->current;
++  formwin = Get_Form_Window(form);
+ 
+   if (field->opts & O_PUBLIC)
+     {
+@@ -623,13 +776,14 @@
+ 	  /* Again, in this case the fieldwin isn't derived from formwin,
+ 	     so we have to perform a copy operation. */
+ 	  if (Single_Line_Field(field))
+-	    { /* horizontal scrolling */
++	    {
++	      /* horizontal scrolling */
+ 	      if (form->curcol < form->begincol)
+-		  form->begincol = form->curcol;
++		form->begincol = form->curcol;
+ 	      else
+ 		{
+ 		  if (form->curcol >= (form->begincol + field->cols))
+-		      form->begincol = form->curcol - field->cols + 1;
++		    form->begincol = form->curcol - field->cols + 1;
+ 		}
+ 	      copywin(form->w,
+ 		      formwin,
+@@ -642,8 +796,9 @@
+ 		      0);
+ 	    }
+ 	  else
+-	    { /* A multi-line, i.e. vertical scrolling field */
+-	      int row_after_bottom,first_modified_row,first_unmodified_row;
++	    {
++	      /* A multi-line, i.e. vertical scrolling field */
++	      int row_after_bottom, first_modified_row, first_unmodified_row;
+ 
+ 	      if (field->drows > field->rows)
+ 		{
+@@ -659,25 +814,27 @@
+ 		      field->status |= _NEWTOP;
+ 		    }
+ 		  if (field->status & _NEWTOP)
+-		    { /* means we have to copy whole range */
++		    {
++		      /* means we have to copy whole range */
+ 		      first_modified_row = form->toprow;
+ 		      first_unmodified_row = first_modified_row + field->rows;
+ 		      field->status &= ~_NEWTOP;
+ 		    }
+-		  else 
+-		    { /* we try to optimize : finding the range of touched
+-                         lines */
++		  else
++		    {
++		      /* we try to optimize : finding the range of touched
++		         lines */
+ 		      first_modified_row = form->toprow;
+-		      while(first_modified_row < row_after_bottom)
++		      while (first_modified_row < row_after_bottom)
+ 			{
+-			  if (is_linetouched(form->w,first_modified_row)) 
++			  if (is_linetouched(form->w, first_modified_row))
+ 			    break;
+ 			  first_modified_row++;
+ 			}
+ 		      first_unmodified_row = first_modified_row;
+-		      while(first_unmodified_row < row_after_bottom)
++		      while (first_unmodified_row < row_after_bottom)
+ 			{
+-			  if (!is_linetouched(form->w,first_unmodified_row)) 
++			  if (!is_linetouched(form->w, first_unmodified_row))
+ 			    break;
+ 			  first_unmodified_row++;
+ 			}
+@@ -685,7 +842,7 @@
+ 		}
+ 	      else
+ 		{
+-		  first_modified_row   = form->toprow;
++		  first_modified_row = form->toprow;
+ 		  first_unmodified_row = first_modified_row + field->rows;
+ 		}
+ 	      if (first_unmodified_row != first_modified_row)
+@@ -702,45 +859,47 @@
+ 	  wsyncup(formwin);
+ 	}
+       else
+-	{ /* if the field-window is simply a derived window, i.e. contains
+-	     no invisible parts, the whole thing is trivial 
+-	  */
++	{
++	  /* if the field-window is simply a derived window, i.e. contains no
++	   * invisible parts, the whole thing is trivial
++	   */
+ 	  wsyncup(form->w);
+ 	}
+     }
+   untouchwin(form->w);
+-  return _nc_Position_Form_Cursor(form);
++  returnCode(_nc_Position_Form_Cursor(form));
+ }
+-	
++
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static void Perform_Justification(
+ |                                        FIELD  * field,
+ |                                        WINDOW * win)
+-|   
+-|   Description   :  Output field with requested justification 
++|
++|   Description   :  Output field with requested justification
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Perform_Justification(FIELD  * field, WINDOW * win)
++static void
++Perform_Justification(FIELD *field, WINDOW *win)
+ {
+-  char *bp;
++  FIELD_CELL *bp;
+   int len;
+-  int col  = 0;
++  int col = 0;
+ 
+-  bp  = Get_Start_Of_Data(field->buf,Buffer_Length(field));
+-  len = (int)(After_End_Of_Data(field->buf,Buffer_Length(field)) - bp);
++  bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
++  len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
+ 
+-  if (len>0)
++  if (len > 0)
+     {
+       assert(win && (field->drows == 1) && (field->dcols == field->cols));
+ 
+-      switch(field->just)
++      switch (field->just)
+ 	{
+ 	case JUSTIFY_LEFT:
+ 	  break;
+ 	case JUSTIFY_CENTER:
+-	  col = (field->cols - len)/2;
++	  col = (field->cols - len) / 2;
+ 	  break;
+ 	case JUSTIFY_RIGHT:
+ 	  col = field->cols - len;
+@@ -749,77 +908,79 @@
+ 	  break;
+ 	}
+ 
+-      wmove(win,0,col);
+-      waddnstr(win,bp,len);
++      wmove(win, 0, col);
++      myADDNSTR(win, bp, len);
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static void Undo_Justification(
+ |                                     FIELD  * field,
+ |                                     WINDOW * win)
+-|   
++|
+ |   Description   :  Display field without any justification, i.e.
+ |                    left justified
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Undo_Justification(FIELD  * field, WINDOW * win)
++static void
++Undo_Justification(FIELD *field, WINDOW *win)
+ {
+-  char *bp;
++  FIELD_CELL *bp;
+   int len;
+ 
+-  bp  = Get_Start_Of_Data(field->buf,Buffer_Length(field));
+-  len = (int)(After_End_Of_Data(field->buf,Buffer_Length(field))-bp);
++  bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
++  len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
+ 
+-  if (len>0)
++  if (len > 0)
+     {
+       assert(win);
+-      wmove(win,0,0);
+-      waddnstr(win,bp,len);
++      wmove(win, 0, 0);
++      myADDNSTR(win, bp, len);
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static bool Check_Char(
+ |                                           FIELDTYPE * typ,
+ |                                           int ch,
+ |                                           TypeArgument *argp)
+-|   
++|
+ |   Description   :  Perform a single character check for character ch
+-|                    according to the fieldtype instance.  
++|                    according to the fieldtype instance.
+ |
+ |   Return Values :  TRUE             - Character is valid
+ |                    FALSE            - Character is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_Char(FIELDTYPE * typ, int ch, TypeArgument *argp)
++static bool
++Check_Char(FIELDTYPE *typ, int ch, TypeArgument *argp)
+ {
+-  if (typ) 
++  if (typ)
+     {
+       if (typ->status & _LINKED_TYPE)
+ 	{
+ 	  assert(argp);
+-	  return(
+-	    Check_Char(typ->left ,ch,argp->left ) ||
+-	    Check_Char(typ->right,ch,argp->right) );
+-	} 
+-      else 
++	  return (
++		   Check_Char(typ->left, ch, argp->left) ||
++		   Check_Char(typ->right, ch, argp->right));
++	}
++      else
+ 	{
+ 	  if (typ->ccheck)
+-	    return typ->ccheck(ch,(void *)argp);
++	    return typ->ccheck(ch, (void *)argp);
+ 	}
+     }
+-  return (isprint((unsigned char)ch) ? TRUE : FALSE);
++  return (!iscntrl(UChar(ch)) ? TRUE : FALSE);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Display_Or_Erase_Field(
+ |                                           FIELD * field,
+ |                                           bool bEraseFlag)
+-|   
++|
+ |   Description   :  Create a subwindow for the field and display the
+ |                    buffer contents (apply justification if required)
+ |                    or simply erase the field.
+@@ -827,7 +988,8 @@
+ |   Return Values :  E_OK           - on success
+ |                    E_SYSTEM_ERROR - some error (typical no memory)
+ +--------------------------------------------------------------------------*/
+-static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
++static int
++Display_Or_Erase_Field(FIELD *field, bool bEraseFlag)
+ {
+   WINDOW *win;
+   WINDOW *fwin;
+@@ -836,17 +998,17 @@
+     return E_SYSTEM_ERROR;
+ 
+   fwin = Get_Form_Window(field->form);
+-  win  = derwin(fwin,
+-		field->rows,field->cols,field->frow,field->fcol);
++  win = derwin(fwin,
++	       field->rows, field->cols, field->frow, field->fcol);
+ 
+-  if (!win) 
++  if (!win)
+     return E_SYSTEM_ERROR;
+   else
+     {
+       if (field->opts & O_VISIBLE)
+-	Set_Field_Window_Attributes(field,win);
++	Set_Field_Window_Attributes(field, win);
+       else
+-	wattrset(win,getattrs(fwin));
++	wattrset(win, getattrs(fwin));
+       werase(win);
+     }
+ 
+@@ -855,9 +1017,9 @@
+       if (field->opts & O_PUBLIC)
+ 	{
+ 	  if (Justification_Allowed(field))
+-	    Perform_Justification(field,win);
++	    Perform_Justification(field, win);
+ 	  else
+-	    Buffer_To_Window(field,win);
++	    Buffer_To_Window(field, win);
+ 	}
+       field->status &= ~_NEWTOP;
+     }
+@@ -871,156 +1033,157 @@
+ #define Erase_Field(field)   Display_Or_Erase_Field(field,TRUE)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Synchronize_Field(FIELD * field)
+-|   
++|
+ |   Description   :  Synchronize the windows content with the value in
+ |                    the buffer.
+ |
+ |   Return Values :  E_OK                - success
+-|                    E_BAD_ARGUMENT      - invalid field pointer 
++|                    E_BAD_ARGUMENT      - invalid field pointer
+ |                    E_SYSTEM_ERROR      - some severe basic error
+ +--------------------------------------------------------------------------*/
+-static int Synchronize_Field(FIELD * field)
++static int
++Synchronize_Field(FIELD *field)
+ {
+   FORM *form;
+   int res = E_OK;
+ 
+   if (!field)
+-    return(E_BAD_ARGUMENT);
++    return (E_BAD_ARGUMENT);
+ 
+-  if (((form=field->form) != (FORM *)0)
++  if (((form = field->form) != (FORM *)0)
+       && Field_Really_Appears(field))
+     {
+       if (field == form->current)
+-	{ 
+-	  form->currow  = form->curcol = form->toprow = form->begincol = 0;
++	{
++	  form->currow = form->curcol = form->toprow = form->begincol = 0;
+ 	  werase(form->w);
+-      
+-	  if ( (field->opts & O_PUBLIC) && Justification_Allowed(field) )
+-	    Undo_Justification( field, form->w );
++
++	  if ((field->opts & O_PUBLIC) && Justification_Allowed(field))
++	    Undo_Justification(field, form->w);
+ 	  else
+-	    Buffer_To_Window( field, form->w );
+-	  
++	    Buffer_To_Window(field, form->w);
++
+ 	  field->status |= _NEWTOP;
+-	  res = _nc_Refresh_Current_Field( form );
++	  res = _nc_Refresh_Current_Field(form);
+ 	}
+       else
+-	res = Display_Field( field );
++	res = Display_Field(field);
+     }
+   field->status |= _CHANGED;
+-  return(res);
++  return (res);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Synchronize_Linked_Fields(FIELD * field)
+-|   
++|
+ |   Description   :  Propagate the Synchronize_Field function to all linked
+ |                    fields. The first error that occurs in the sequence
+ |                    of updates is the return value.
+ |
+ |   Return Values :  E_OK                - success
+-|                    E_BAD_ARGUMENT      - invalid field pointer 
++|                    E_BAD_ARGUMENT      - invalid field pointer
+ |                    E_SYSTEM_ERROR      - some severe basic error
+ +--------------------------------------------------------------------------*/
+-static int Synchronize_Linked_Fields(FIELD * field)
++static int
++Synchronize_Linked_Fields(FIELD *field)
+ {
+   FIELD *linked_field;
+   int res = E_OK;
+   int syncres;
+ 
+   if (!field)
+-    return(E_BAD_ARGUMENT);
++    return (E_BAD_ARGUMENT);
+ 
+   if (!field->link)
+-    return(E_SYSTEM_ERROR);
++    return (E_SYSTEM_ERROR);
+ 
+-  for(linked_field = field->link; 
+-      linked_field!= field;
+-      linked_field = linked_field->link )
++  for (linked_field = field->link;
++       linked_field != field;
++       linked_field = linked_field->link)
+     {
+-      if (((syncres=Synchronize_Field(linked_field)) != E_OK) &&
+-	  (res==E_OK))
++      if (((syncres = Synchronize_Field(linked_field)) != E_OK) &&
++	  (res == E_OK))
+ 	res = syncres;
+     }
+-  return(res);
++  return (res);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int _nc_Synchronize_Attributes(FIELD * field)
+-|   
++|
+ |   Description   :  If a fields visual attributes have changed, this
+ |                    routine is called to propagate those changes to the
+-|                    screen.  
++|                    screen.
+ |
+ |   Return Values :  E_OK             - success
+ |                    E_BAD_ARGUMENT   - invalid field pointer
+ |                    E_SYSTEM_ERROR   - some severe basic error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-_nc_Synchronize_Attributes (FIELD * field)
++_nc_Synchronize_Attributes(FIELD *field)
+ {
+   FORM *form;
+   int res = E_OK;
+   WINDOW *formwin;
+ 
+   if (!field)
+-    return(E_BAD_ARGUMENT);
++    return (E_BAD_ARGUMENT);
+ 
+-  if (((form=field->form) != (FORM *)0)
++  if (((form = field->form) != (FORM *)0)
+       && Field_Really_Appears(field))
+-    {    
+-      if (form->current==field)
++    {
++      if (form->current == field)
+ 	{
+ 	  Synchronize_Buffer(form);
+-	  Set_Field_Window_Attributes(field,form->w);
++	  Set_Field_Window_Attributes(field, form->w);
+ 	  werase(form->w);
+ 	  if (field->opts & O_PUBLIC)
+ 	    {
+ 	      if (Justification_Allowed(field))
+-		Undo_Justification(field,form->w);
+-	      else 
+-		Buffer_To_Window(field,form->w);
+-	    }
+-	  else 
+-	    {
+-	      formwin = Get_Form_Window(form); 
+-	      copywin(form->w,formwin,
+-		      0,0,
+-		      field->frow,field->fcol,
+-		      field->rows-1,field->cols-1,0);
++		Undo_Justification(field, form->w);
++	      else
++		Buffer_To_Window(field, form->w);
++	    }
++	  else
++	    {
++	      formwin = Get_Form_Window(form);
++	      copywin(form->w, formwin,
++		      0, 0,
++		      field->frow, field->fcol,
++		      field->rows - 1, field->cols - 1, 0);
+ 	      wsyncup(formwin);
+-	      Buffer_To_Window(field,form->w);
+-	      field->status |= _NEWTOP; /* fake refresh to paint all */
++	      Buffer_To_Window(field, form->w);
++	      field->status |= _NEWTOP;		/* fake refresh to paint all */
+ 	      _nc_Refresh_Current_Field(form);
+ 	    }
+ 	}
+-      else 
++      else
+ 	{
+ 	  res = Display_Field(field);
+ 	}
+     }
+-  return(res);
++  return (res);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int _nc_Synchronize_Options(FIELD * field,
+ |                                                Field_Options newopts)
+-|   
++|
+ |   Description   :  If a fields options have changed, this routine is
+ |                    called to propagate these changes to the screen and
+ |                    to really change the behavior of the field.
+ |
+ |   Return Values :  E_OK                - success
+-|                    E_BAD_ARGUMENT      - invalid field pointer 
++|                    E_BAD_ARGUMENT      - invalid field pointer
+ |                    E_SYSTEM_ERROR      - some severe basic error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-_nc_Synchronize_Options
+-(FIELD *field, Field_Options newopts)
++_nc_Synchronize_Options(FIELD *field, Field_Options newopts)
+ {
+   Field_Options oldopts;
+   Field_Options changed_opts;
+@@ -1028,19 +1191,19 @@
+   int res = E_OK;
+ 
+   if (!field)
+-    return(E_BAD_ARGUMENT);
++    return (E_BAD_ARGUMENT);
+ 
+-  oldopts      = field->opts;
++  oldopts = field->opts;
+   changed_opts = oldopts ^ newopts;
+-  field->opts  = newopts;
+-  form         = field->form;
++  field->opts = newopts;
++  form = field->form;
+ 
+   if (form)
+     {
+       if (form->current == field)
+ 	{
+ 	  field->opts = oldopts;
+-	  return(E_CURRENT);
++	  return (E_CURRENT);
+ 	}
+ 
+       if (form->status & _POSTED)
+@@ -1070,12 +1233,13 @@
+       int res2 = E_OK;
+ 
+       if (newopts & O_STATIC)
+-	{ /* the field becomes now static */
++	{
++	  /* the field becomes now static */
+ 	  field->status &= ~_MAY_GROW;
+ 	  /* if actually we have no hidden columns, justification may
+ 	     occur again */
+-	  if (single_line_field                 &&
+-	      (field->cols == field->dcols)     &&
++	  if (single_line_field &&
++	      (field->cols == field->dcols) &&
+ 	      (field->just != NO_JUSTIFICATION) &&
+ 	      Field_Really_Appears(field))
+ 	    {
+@@ -1083,62 +1247,62 @@
+ 	    }
+ 	}
+       else
+-	{ /* field is no longer static */
+-	  if ((field->maxgrow==0) ||
+-	      ( single_line_field && (field->dcols < field->maxgrow)) ||
++	{
++	  /* field is no longer static */
++	  if ((field->maxgrow == 0) ||
++	      (single_line_field && (field->dcols < field->maxgrow)) ||
+ 	      (!single_line_field && (field->drows < field->maxgrow)))
+ 	    {
+ 	      field->status |= _MAY_GROW;
+ 	      /* a field with justification now changes its behavior,
+-		 so we must redisplay it */
+-	      if (single_line_field                 &&
++	         so we must redisplay it */
++	      if (single_line_field &&
+ 		  (field->just != NO_JUSTIFICATION) &&
+ 		  Field_Really_Appears(field))
+ 		{
+ 		  res2 = Display_Field(field);
+-		}	 
+-	    }     
++		}
++	    }
+ 	}
+       if (res2 != E_OK)
+ 	res = res2;
+     }
+ 
+-  return(res);
++  return (res);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int _nc_Set_Current_Field(FORM  * form,
+ |                                              FIELD * newfield)
+-|   
++|
+ |   Description   :  Make the newfield the new current field.
+ |
+ |   Return Values :  E_OK                - success
+-|                    E_BAD_ARGUMENT      - invalid form or field pointer 
++|                    E_BAD_ARGUMENT      - invalid form or field pointer
+ |                    E_SYSTEM_ERROR      - some severe basic error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-_nc_Set_Current_Field
+-(FORM  *form, FIELD *newfield)
++_nc_Set_Current_Field(FORM *form, FIELD *newfield)
+ {
+-  FIELD  *field;
++  FIELD *field;
+   WINDOW *new_window;
+ 
+-  if (!form || !newfield || !form->current || (newfield->form!=form))
+-    return(E_BAD_ARGUMENT);
++  if (!form || !newfield || !form->current || (newfield->form != form))
++    return (E_BAD_ARGUMENT);
+ 
+-  if ( (form->status & _IN_DRIVER) )
+-    return(E_BAD_STATE);
++  if ((form->status & _IN_DRIVER))
++    return (E_BAD_STATE);
+ 
+   if (!(form->field))
+-    return(E_NOT_CONNECTED);
++    return (E_NOT_CONNECTED);
+ 
+   field = form->current;
+- 
+-  if ((field!=newfield) || 
++
++  if ((field != newfield) ||
+       !(form->status & _POSTED))
+     {
+-      if ((form->w) && 
++      if ((form->w) &&
+ 	  (field->opts & O_VISIBLE) &&
+ 	  (field->form->curpage == field->page))
+ 	{
+@@ -1147,18 +1311,18 @@
+ 	    {
+ 	      if (field->drows > field->rows)
+ 		{
+-		  if (form->toprow==0)
++		  if (form->toprow == 0)
+ 		    field->status &= ~_NEWTOP;
+-		  else 
++		  else
+ 		    field->status |= _NEWTOP;
+-		} 
+-	      else 
++		}
++	      else
+ 		{
+ 		  if (Justification_Allowed(field))
+ 		    {
+-		      Window_To_Buffer(form->w,field);
++		      Window_To_Buffer(form->w, field);
+ 		      werase(form->w);
+-		      Perform_Justification(field,form->w);
++		      Perform_Justification(field, form->w);
+ 		      wsyncup(form->w);
+ 		    }
+ 		}
+@@ -1166,38 +1330,38 @@
+ 	  delwin(form->w);
+ 	  form->w = (WINDOW *)0;
+ 	}
+-      
++
+       field = newfield;
+ 
+       if (Has_Invisible_Parts(field))
+-	new_window = newpad(field->drows,field->dcols);
+-      else 
++	new_window = newpad(field->drows, field->dcols);
++      else
+ 	new_window = derwin(Get_Form_Window(form),
+-			    field->rows,field->cols,field->frow,field->fcol);
++			    field->rows, field->cols, field->frow, field->fcol);
+ 
+-      if (!new_window) 
+-	return(E_SYSTEM_ERROR);
++      if (!new_window)
++	return (E_SYSTEM_ERROR);
+ 
+       form->current = field;
+ 
+       if (form->w)
+ 	delwin(form->w);
+-      form->w       = new_window;
++      form->w = new_window;
+ 
+       form->status &= ~_WINDOW_MODIFIED;
+-      Set_Field_Window_Attributes(field,form->w);
++      Set_Field_Window_Attributes(field, form->w);
+ 
+       if (Has_Invisible_Parts(field))
+ 	{
+ 	  werase(form->w);
+-	  Buffer_To_Window(field,form->w);
+-	} 
+-      else 
++	  Buffer_To_Window(field, form->w);
++	}
++      else
+ 	{
+ 	  if (Justification_Allowed(field))
+ 	    {
+ 	      werase(form->w);
+-	      Undo_Justification(field,form->w);
++	      Undo_Justification(field, form->w);
+ 	      wsyncup(form->w);
+ 	    }
+ 	}
+@@ -1206,417 +1370,461 @@
+     }
+ 
+   form->currow = form->curcol = form->toprow = form->begincol = 0;
+-  return(E_OK);
++  return (E_OK);
+ }
+-
++
+ /*----------------------------------------------------------------------------
+   Intra-Field Navigation routines
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Next_Character(FORM * form)
+-|   
++|
+ |   Description   :  Move to the next character in the field. In a multi-line
+ |                    field this wraps at the end of the line.
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - at the rightmost position
+ +--------------------------------------------------------------------------*/
+-static int IFN_Next_Character(FORM * form)
++static int
++IFN_Next_Character(FORM *form)
+ {
+   FIELD *field = form->current;
+-  
+-  if ((++(form->curcol))==field->dcols)
++  int step = myWCWIDTH(form->w, form->currow, form->curcol);
++
++  T((T_CALLED("IFN_Next_Character(%p)"), form));
++  if ((form->curcol += step) == field->dcols)
+     {
+-      if ((++(form->currow))==field->drows)
++      if ((++(form->currow)) == field->drows)
+ 	{
+ #if GROW_IF_NAVIGATE
+-	  if (!Single_Line_Field(field) && Field_Grown(field,1)) {
+-	    form->curcol = 0;
+-	    return(E_OK);
+-	  }
++	  if (!Single_Line_Field(field) && Field_Grown(field, 1))
++	    {
++	      form->curcol = 0;
++	      returnCode(E_OK);
++	    }
+ #endif
+ 	  form->currow--;
+ #if GROW_IF_NAVIGATE
+-	  if (Single_Line_Field(field) && Field_Grown(field,1))
+-	    return(E_OK);
++	  if (Single_Line_Field(field) && Field_Grown(field, 1))
++	    returnCode(E_OK);
+ #endif
+-	  form->curcol--;
+-	  return(E_REQUEST_DENIED);
++	  form->curcol -= step;
++	  returnCode(E_REQUEST_DENIED);
+ 	}
+       form->curcol = 0;
+     }
+-  return(E_OK);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Previous_Character(FORM * form)
+-|   
+-|   Description   :  Move to the previous character in the field. In a 
+-|                    multi-line field this wraps and the beginning of the 
++|
++|   Description   :  Move to the previous character in the field. In a
++|                    multi-line field this wraps and the beginning of the
+ |                    line.
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - at the leftmost position
+ +--------------------------------------------------------------------------*/
+-static int IFN_Previous_Character(FORM * form)
++static int
++IFN_Previous_Character(FORM *form)
+ {
+-  if ((--(form->curcol))<0)
++  int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
++  int oldcol = form->curcol;
++
++  T((T_CALLED("IFN_Previous_Character(%p)"), form));
++  if ((form->curcol -= amount) < 0)
+     {
+-      if ((--(form->currow))<0)
++      if ((--(form->currow)) < 0)
+ 	{
+ 	  form->currow++;
+-	  form->curcol++;
+-	  return(E_REQUEST_DENIED);
++	  form->curcol = oldcol;
++	  returnCode(E_REQUEST_DENIED);
+ 	}
+       form->curcol = form->current->dcols - 1;
+     }
+-  return(E_OK);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Next_Line(FORM * form)
+-|   
++|
+ |   Description   :  Move to the beginning of the next line in the field
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - at the last line
+ +--------------------------------------------------------------------------*/
+-static int IFN_Next_Line(FORM * form)
++static int
++IFN_Next_Line(FORM *form)
+ {
+   FIELD *field = form->current;
+ 
+-  if ((++(form->currow))==field->drows)
++  T((T_CALLED("IFN_Next_Line(%p)"), form));
++  if ((++(form->currow)) == field->drows)
+     {
+ #if GROW_IF_NAVIGATE
+-      if (!Single_Line_Field(field) && Field_Grown(field,1))
+-	return(E_OK);
++      if (!Single_Line_Field(field) && Field_Grown(field, 1))
++	returnCode(E_OK);
+ #endif
+       form->currow--;
+-      return(E_REQUEST_DENIED);
++      returnCode(E_REQUEST_DENIED);
+     }
+   form->curcol = 0;
+-  return(E_OK);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Previous_Line(FORM * form)
+-|   
++|
+ |   Description   :  Move to the beginning of the previous line in the field
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - at the first line
+ +--------------------------------------------------------------------------*/
+-static int IFN_Previous_Line(FORM * form)
++static int
++IFN_Previous_Line(FORM *form)
+ {
+-  if ( (--(form->currow)) < 0 )
++  T((T_CALLED("IFN_Previous_Line(%p)"), form));
++  if ((--(form->currow)) < 0)
+     {
+       form->currow++;
+-      return(E_REQUEST_DENIED);
++      returnCode(E_REQUEST_DENIED);
+     }
+   form->curcol = 0;
+-  return(E_OK);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Next_Word(FORM * form)
+-|   
++|
+ |   Description   :  Move to the beginning of the next word in the field.
+ |
+ |   Return Values :  E_OK             - success
+ |                    E_REQUEST_DENIED - there is no next word
+ +--------------------------------------------------------------------------*/
+-static int IFN_Next_Word(FORM * form)
++static int
++IFN_Next_Word(FORM *form)
+ {
+   FIELD *field = form->current;
+-  char  *bp    = Address_Of_Current_Position_In_Buffer(form);
+-  char  *s;
+-  char  *t;
++  FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
++  FIELD_CELL *s;
++  FIELD_CELL *t;
++
++  T((T_CALLED("IFN_Next_Word(%p)"), form));
+ 
+   /* We really need access to the data, so we have to synchronize */
+   Synchronize_Buffer(form);
+ 
+   /* Go to the first whitespace after the current position (including
+      current position). This is then the starting point to look for the
+-    next non-blank data */
+-  s = Get_First_Whitespace_Character(bp,Buffer_Length(field) -
++     next non-blank data */
++  s = Get_First_Whitespace_Character(bp, Buffer_Length(field) -
+ 				     (int)(bp - field->buf));
+ 
+   /* Find the start of the next word */
+-  t = Get_Start_Of_Data(s,Buffer_Length(field) -
++  t = Get_Start_Of_Data(s, Buffer_Length(field) -
+ 			(int)(s - field->buf));
+ #if !FRIENDLY_PREV_NEXT_WORD
+-  if (s==t) 
+-    return(E_REQUEST_DENIED);
++  if (s == t)
++    returnCode(E_REQUEST_DENIED);
+   else
+ #endif
+     {
+-      Adjust_Cursor_Position(form,t);
+-      return(E_OK);
++      Adjust_Cursor_Position(form, t);
++      returnCode(E_OK);
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Previous_Word(FORM * form)
+-|   
++|
+ |   Description   :  Move to the beginning of the previous word in the field.
+ |
+ |   Return Values :  E_OK             - success
+ |                    E_REQUEST_DENIED - there is no previous word
+ +--------------------------------------------------------------------------*/
+-static int IFN_Previous_Word(FORM * form)
++static int
++IFN_Previous_Word(FORM *form)
+ {
+   FIELD *field = form->current;
+-  char  *bp    = Address_Of_Current_Position_In_Buffer(form);
+-  char  *s;
+-  char  *t;
+-  bool  again = FALSE;
++  FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
++  FIELD_CELL *s;
++  FIELD_CELL *t;
++  bool again = FALSE;
++
++  T((T_CALLED("IFN_Previous_Word(%p)"), form));
+ 
+   /* We really need access to the data, so we have to synchronize */
+   Synchronize_Buffer(form);
+ 
+-  s = After_End_Of_Data(field->buf,(int)(bp-field->buf));
++  s = After_End_Of_Data(field->buf, (int)(bp - field->buf));
+   /* s points now right after the last non-blank in the buffer before bp.
+      If bp was in a word, s equals bp. In this case we must find the last
+      whitespace in the buffer before bp and repeat the game to really find
+      the previous word! */
+-  if (s==bp)
++  if (s == bp)
+     again = TRUE;
+-  
++
+   /* And next call now goes backward to look for the last whitespace
+      before that, pointing right after this, so it points to the begin
+-     of the previous word. 
+-  */
+-  t = After_Last_Whitespace_Character(field->buf,(int)(s - field->buf));
++     of the previous word.
++   */
++  t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
+ #if !FRIENDLY_PREV_NEXT_WORD
+-  if (s==t) 
+-    return(E_REQUEST_DENIED);
++  if (s == t)
++    returnCode(E_REQUEST_DENIED);
+ #endif
+   if (again)
+-    { /* and do it again, replacing bp by t */
+-      s = After_End_Of_Data(field->buf,(int)(t - field->buf));
+-      t = After_Last_Whitespace_Character(field->buf,(int)(s - field->buf));
++    {
++      /* and do it again, replacing bp by t */
++      s = After_End_Of_Data(field->buf, (int)(t - field->buf));
++      t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
+ #if !FRIENDLY_PREV_NEXT_WORD
+-      if (s==t) 
+-	return(E_REQUEST_DENIED);
++      if (s == t)
++	returnCode(E_REQUEST_DENIED);
+ #endif
+     }
+-  Adjust_Cursor_Position(form,t);
+-  return(E_OK);
++  Adjust_Cursor_Position(form, t);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Beginning_Of_Field(FORM * form)
+-|   
++|
+ |   Description   :  Place the cursor at the first non-pad character in
+-|                    the field. 
++|                    the field.
+ |
+-|   Return Values :  E_OK             - success            
++|   Return Values :  E_OK             - success
+ +--------------------------------------------------------------------------*/
+-static int IFN_Beginning_Of_Field(FORM * form)
++static int
++IFN_Beginning_Of_Field(FORM *form)
+ {
+   FIELD *field = form->current;
+ 
++  T((T_CALLED("IFN_Beginning_Of_Field(%p)"), form));
+   Synchronize_Buffer(form);
+   Adjust_Cursor_Position(form,
+-		 Get_Start_Of_Data(field->buf,Buffer_Length(field)));
+-  return(E_OK);
++			 Get_Start_Of_Data(field->buf, Buffer_Length(field)));
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_End_Of_Field(FORM * form)
+-|   
++|
+ |   Description   :  Place the cursor after the last non-pad character in
+ |                    the field. If the field occupies the last position in
+-|                    the buffer, the cursor is positioned on the last 
++|                    the buffer, the cursor is positioned on the last
+ |                    character.
+ |
+ |   Return Values :  E_OK              - success
+ +--------------------------------------------------------------------------*/
+-static int IFN_End_Of_Field(FORM * form)
++static int
++IFN_End_Of_Field(FORM *form)
+ {
+   FIELD *field = form->current;
+-  char *pos;
++  FIELD_CELL *pos;
+ 
++  T((T_CALLED("IFN_End_Of_Field(%p)"), form));
+   Synchronize_Buffer(form);
+-  pos = After_End_Of_Data(field->buf,Buffer_Length(field));
+-  if (pos==(field->buf + Buffer_Length(field)))
++  pos = After_End_Of_Data(field->buf, Buffer_Length(field));
++  if (pos == (field->buf + Buffer_Length(field)))
+     pos--;
+-  Adjust_Cursor_Position(form,pos);
+-  return(E_OK);
++  Adjust_Cursor_Position(form, pos);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Beginning_Of_Line(FORM * form)
+-|   
++|
+ |   Description   :  Place the cursor on the first non-pad character in
+ |                    the current line of the field.
+ |
+ |   Return Values :  E_OK         - success
+ +--------------------------------------------------------------------------*/
+-static int IFN_Beginning_Of_Line(FORM * form)
++static int
++IFN_Beginning_Of_Line(FORM *form)
+ {
+   FIELD *field = form->current;
+ 
++  T((T_CALLED("IFN_Beginning_Of_Line(%p)"), form));
+   Synchronize_Buffer(form);
+   Adjust_Cursor_Position(form,
+-		 Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),
+-				   field->dcols));
+-  return(E_OK);
++			 Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),
++					   field->dcols));
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_End_Of_Line(FORM * form)
+-|   
++|
+ |   Description   :  Place the cursor after the last non-pad character in the
+-|                    current line of the field. If the field occupies the 
++|                    current line of the field. If the field occupies the
+ |                    last column in the line, the cursor is positioned on the
+ |                    last character of the line.
+ |
+ |   Return Values :  E_OK        - success
+ +--------------------------------------------------------------------------*/
+-static int IFN_End_Of_Line(FORM * form)
++static int
++IFN_End_Of_Line(FORM *form)
+ {
+   FIELD *field = form->current;
+-  char *pos;
+-  char *bp;
++  FIELD_CELL *pos;
++  FIELD_CELL *bp;
+ 
++  T((T_CALLED("IFN_End_Of_Line(%p)"), form));
+   Synchronize_Buffer(form);
+-  bp  = Address_Of_Current_Row_In_Buffer(form); 
+-  pos = After_End_Of_Data(bp,field->dcols);
++  bp = Address_Of_Current_Row_In_Buffer(form);
++  pos = After_End_Of_Data(bp, field->dcols);
+   if (pos == (bp + field->dcols))
+     pos--;
+-  Adjust_Cursor_Position(form,pos);
+-  return(E_OK);
++  Adjust_Cursor_Position(form, pos);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Left_Character(FORM * form)
+-|   
++|
+ |   Description   :  Move one character to the left in the current line.
+-|                    This doesn't cycle.  
++|                    This doesn't cycle.
+ |
+ |   Return Values :  E_OK             - success
+ |                    E_REQUEST_DENIED - already in first column
+ +--------------------------------------------------------------------------*/
+-static int IFN_Left_Character(FORM * form)
++static int
++IFN_Left_Character(FORM *form)
+ {
+-  if ( (--(form->curcol)) < 0 )
++  int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
++  int oldcol = form->curcol;
++
++  T((T_CALLED("IFN_Left_Character(%p)"), form));
++  if ((form->curcol -= amount) < 0)
+     {
+-      form->curcol++;
+-      return(E_REQUEST_DENIED);
++      form->curcol = oldcol;
++      returnCode(E_REQUEST_DENIED);
+     }
+-  return(E_OK);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Right_Character(FORM * form)
+-|   
++|
+ |   Description   :  Move one character to the right in the current line.
+ |                    This doesn't cycle.
+ |
+ |   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - already in last column
+ +--------------------------------------------------------------------------*/
+-static int IFN_Right_Character(FORM * form)
++static int
++IFN_Right_Character(FORM *form)
+ {
+-  if ( (++(form->curcol)) == form->current->dcols )
++  int amount = myWCWIDTH(form->w, form->currow, form->curcol);
++  int oldcol = form->curcol;
++
++  T((T_CALLED("IFN_Right_Character(%p)"), form));
++  if ((form->curcol += amount) >= form->current->dcols)
+     {
+ #if GROW_IF_NAVIGATE
+       FIELD *field = form->current;
+-      if (Single_Line_Field(field) && Field_Grown(field,1))
+-	return(E_OK);
++
++      if (Single_Line_Field(field) && Field_Grown(field, 1))
++	returnCode(E_OK);
+ #endif
+-      --(form->curcol);
+-      return(E_REQUEST_DENIED);
++      form->curcol = oldcol;
++      returnCode(E_REQUEST_DENIED);
+     }
+-  return(E_OK);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Up_Character(FORM * form)
+-|   
++|
+ |   Description   :  Move one line up. This doesn't cycle through the lines
+ |                    of the field.
+ |
+ |   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - already in last column
+ +--------------------------------------------------------------------------*/
+-static int IFN_Up_Character(FORM * form)
++static int
++IFN_Up_Character(FORM *form)
+ {
+-  if ( (--(form->currow)) < 0 )
++  T((T_CALLED("IFN_Up_Character(%p)"), form));
++  if ((--(form->currow)) < 0)
+     {
+       form->currow++;
+-      return(E_REQUEST_DENIED);
++      returnCode(E_REQUEST_DENIED);
+     }
+-  return(E_OK);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int IFN_Down_Character(FORM * form)
+-|   
++|
+ |   Description   :  Move one line down. This doesn't cycle through the
+ |                    lines of the field.
+ |
+ |   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - already in last column
+ +--------------------------------------------------------------------------*/
+-static int IFN_Down_Character(FORM * form)
++static int
++IFN_Down_Character(FORM *form)
+ {
+   FIELD *field = form->current;
+ 
+-  if ( (++(form->currow)) == field->drows )
++  T((T_CALLED("IFN_Down_Character(%p)"), form));
++  if ((++(form->currow)) == field->drows)
+     {
+ #if GROW_IF_NAVIGATE
+-      if (!Single_Line_Field(field) && Field_Grown(field,1))
+-	return(E_OK);
++      if (!Single_Line_Field(field) && Field_Grown(field, 1))
++	returnCode(E_OK);
+ #endif
+       --(form->currow);
+-      return(E_REQUEST_DENIED);
++      returnCode(E_REQUEST_DENIED);
+     }
+-  return(E_OK);
++  returnCode(E_OK);
+ }
+ /*----------------------------------------------------------------------------
+-  END of Intra-Field Navigation routines 
++  END of Intra-Field Navigation routines
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Vertical scrolling helper routines
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static int VSC_Generic(FORM *form, int lines)
++|   Facility      :  libnform
++|   Function      :  static int VSC_Generic(FORM *form, int nlines)
+ |
+-|   Description   :  Scroll multi-line field forward (lines>0) or
+-|                    backward (lines<0) this many lines.
++|   Description   :  Scroll multi-line field forward (nlines>0) or
++|                    backward (nlines<0) this many lines.
+ |
+-|   Return Values :  E_OK              - success 
++|   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - can't scroll
+ +--------------------------------------------------------------------------*/
+-static int VSC_Generic(FORM *form, int lines)
++static int
++VSC_Generic(FORM *form, int nlines)
+ {
+   FIELD *field = form->current;
+   int res = E_REQUEST_DENIED;
+-  int rows_to_go = (lines > 0 ? lines : -lines);
++  int rows_to_go = (nlines > 0 ? nlines : -nlines);
+ 
+-  if (lines > 0)
++  if (nlines > 0)
+     {
+-      if ( (rows_to_go + form->toprow) > (field->drows - field->rows) )
++      if ((rows_to_go + form->toprow) > (field->drows - field->rows))
+ 	rows_to_go = (field->drows - field->rows - form->toprow);
+ 
+       if (rows_to_go > 0)
+@@ -1630,7 +1838,7 @@
+     {
+       if (rows_to_go > form->toprow)
+ 	rows_to_go = form->toprow;
+-      
++
+       if (rows_to_go > 0)
+ 	{
+ 	  form->currow -= rows_to_go;
+@@ -1638,29 +1846,30 @@
+ 	  res = E_OK;
+ 	}
+     }
+-  return(res);
++  return (res);
+ }
+ /*----------------------------------------------------------------------------
+   End of Vertical scrolling helper routines
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Vertical scrolling routines
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Vertical_Scrolling(
+ |                                           int (* const fct) (FORM *),
+ |                                           FORM * form)
+-|   
+-|   Description   :  Performs the generic vertical scrolling routines. 
++|
++|   Description   :  Performs the generic vertical scrolling routines.
+ |                    This has to check for a multi-line field and to set
+ |                    the _NEWTOP flag if scrolling really occurred.
+ |
+ |   Return Values :  Propagated error code from low-level driver calls
+ +--------------------------------------------------------------------------*/
+-static int Vertical_Scrolling(int (* const fct) (FORM *), FORM * form)
++static int
++Vertical_Scrolling(int (*const fct) (FORM *), FORM *form)
+ {
+   int res = E_REQUEST_DENIED;
+ 
+@@ -1670,299 +1879,327 @@
+       if (res == E_OK)
+ 	form->current->status |= _NEWTOP;
+     }
+-  return(res);
++  return (res);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int VSC_Scroll_Line_Forward(FORM * form)
+-|   
++|
+ |   Description   :  Scroll multi-line field forward a line
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - no data ahead
+ +--------------------------------------------------------------------------*/
+-static int VSC_Scroll_Line_Forward(FORM * form)
++static int
++VSC_Scroll_Line_Forward(FORM *form)
+ {
+-  return VSC_Generic(form,1);
++  T((T_CALLED("VSC_Scroll_Line_Forward(%p)"), form));
++  returnCode(VSC_Generic(form, 1));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int VSC_Scroll_Line_Backward(FORM * form)
+-|   
++|
+ |   Description   :  Scroll multi-line field backward a line
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - no data behind
+ +--------------------------------------------------------------------------*/
+-static int VSC_Scroll_Line_Backward(FORM * form)
++static int
++VSC_Scroll_Line_Backward(FORM *form)
+ {
+-  return VSC_Generic(form,-1);
++  T((T_CALLED("VSC_Scroll_Line_Backward(%p)"), form));
++  returnCode(VSC_Generic(form, -1));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int VSC_Scroll_Page_Forward(FORM * form)
+-|   
++|
+ |   Description   :  Scroll a multi-line field forward a page
+ |
+ |   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - no data ahead
+ +--------------------------------------------------------------------------*/
+-static int VSC_Scroll_Page_Forward(FORM * form)
++static int
++VSC_Scroll_Page_Forward(FORM *form)
+ {
+-  return VSC_Generic(form,form->current->rows);
++  T((T_CALLED("VSC_Scroll_Page_Forward(%p)"), form));
++  returnCode(VSC_Generic(form, form->current->rows));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int VSC_Scroll_Half_Page_Forward(FORM * form)
+-|   
++|
+ |   Description   :  Scroll a multi-line field forward half a page
+ |
+ |   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - no data ahead
+ +--------------------------------------------------------------------------*/
+-static int VSC_Scroll_Half_Page_Forward(FORM * form)
++static int
++VSC_Scroll_Half_Page_Forward(FORM *form)
+ {
+-  return VSC_Generic(form,(form->current->rows + 1)/2);
++  T((T_CALLED("VSC_Scroll_Half_Page_Forward(%p)"), form));
++  returnCode(VSC_Generic(form, (form->current->rows + 1) / 2));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int VSC_Scroll_Page_Backward(FORM * form)
+-|   
++|
+ |   Description   :  Scroll a multi-line field backward a page
+ |
+ |   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - no data behind
+ +--------------------------------------------------------------------------*/
+-static int VSC_Scroll_Page_Backward(FORM * form)
++static int
++VSC_Scroll_Page_Backward(FORM *form)
+ {
+-  return VSC_Generic(form, -(form->current->rows));
++  T((T_CALLED("VSC_Scroll_Page_Backward(%p)"), form));
++  returnCode(VSC_Generic(form, -(form->current->rows)));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int VSC_Scroll_Half_Page_Backward(FORM * form)
+-|   
++|
+ |   Description   :  Scroll a multi-line field backward half a page
+ |
+ |   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - no data behind
+ +--------------------------------------------------------------------------*/
+-static int VSC_Scroll_Half_Page_Backward(FORM * form)
++static int
++VSC_Scroll_Half_Page_Backward(FORM *form)
+ {
+-  return VSC_Generic(form, -((form->current->rows + 1)/2));
++  T((T_CALLED("VSC_Scroll_Half_Page_Backward(%p)"), form));
++  returnCode(VSC_Generic(form, -((form->current->rows + 1) / 2)));
+ }
+ /*----------------------------------------------------------------------------
+   End of Vertical scrolling routines
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Horizontal scrolling helper routines
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static int HSC_Generic(FORM *form, int columns)
++|   Facility      :  libnform
++|   Function      :  static int HSC_Generic(FORM *form, int ncolumns)
+ |
+-|   Description   :  Scroll single-line field forward (columns>0) or
+-|                    backward (columns<0) this many columns.
++|   Description   :  Scroll single-line field forward (ncolumns>0) or
++|                    backward (ncolumns<0) this many columns.
+ |
+-|   Return Values :  E_OK              - success 
++|   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - can't scroll
+ +--------------------------------------------------------------------------*/
+-static int HSC_Generic(FORM *form, int columns)
++static int
++HSC_Generic(FORM *form, int ncolumns)
+ {
+   FIELD *field = form->current;
+   int res = E_REQUEST_DENIED;
+-  int cols_to_go = (columns > 0 ? columns : -columns);
++  int cols_to_go = (ncolumns > 0 ? ncolumns : -ncolumns);
+ 
+-  if (columns > 0)
++  if (ncolumns > 0)
+     {
+       if ((cols_to_go + form->begincol) > (field->dcols - field->cols))
+ 	cols_to_go = field->dcols - field->cols - form->begincol;
+-      
++
+       if (cols_to_go > 0)
+ 	{
+-	  form->curcol   += cols_to_go;
++	  form->curcol += cols_to_go;
+ 	  form->begincol += cols_to_go;
+ 	  res = E_OK;
+ 	}
+     }
+   else
+     {
+-      if ( cols_to_go > form->begincol )
++      if (cols_to_go > form->begincol)
+ 	cols_to_go = form->begincol;
+ 
+       if (cols_to_go > 0)
+ 	{
+-	  form->curcol   -= cols_to_go;
++	  form->curcol -= cols_to_go;
+ 	  form->begincol -= cols_to_go;
+ 	  res = E_OK;
+ 	}
+     }
+-  return(res);
++  return (res);
+ }
+ /*----------------------------------------------------------------------------
+   End of Horizontal scrolling helper routines
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Horizontal scrolling routines
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Horizontal_Scrolling(
+ |                                          int (* const fct) (FORM *),
+ |                                          FORM * form)
+-|   
+-|   Description   :  Performs the generic horizontal scrolling routines. 
++|
++|   Description   :  Performs the generic horizontal scrolling routines.
+ |                    This has to check for a single-line field.
+ |
+ |   Return Values :  Propagated error code from low-level driver calls
+ +--------------------------------------------------------------------------*/
+-static int Horizontal_Scrolling(int (* const fct) (FORM *), FORM * form)
++static int
++Horizontal_Scrolling(int (*const fct) (FORM *), FORM *form)
+ {
+   if (Single_Line_Field(form->current))
+     return fct(form);
+   else
+-    return(E_REQUEST_DENIED);
++    return (E_REQUEST_DENIED);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int HSC_Scroll_Char_Forward(FORM * form)
+-|   
++|
+ |   Description   :  Scroll single-line field forward a character
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - no data ahead
+ +--------------------------------------------------------------------------*/
+-static int HSC_Scroll_Char_Forward(FORM *form)
++static int
++HSC_Scroll_Char_Forward(FORM *form)
+ {
+-  return HSC_Generic(form,1);
++  T((T_CALLED("HSC_Scroll_Char_Forward(%p)"), form));
++  returnCode(HSC_Generic(form, 1));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int HSC_Scroll_Char_Backward(FORM * form)
+-|   
++|
+ |   Description   :  Scroll single-line field backward a character
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - no data behind
+ +--------------------------------------------------------------------------*/
+-static int HSC_Scroll_Char_Backward(FORM *form)
++static int
++HSC_Scroll_Char_Backward(FORM *form)
+ {
+-  return HSC_Generic(form,-1);
++  T((T_CALLED("HSC_Scroll_Char_Backward(%p)"), form));
++  returnCode(HSC_Generic(form, -1));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int HSC_Horizontal_Line_Forward(FORM* form)
+-|   
++|
+ |   Description   :  Scroll single-line field forward a line
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - no data ahead
+ +--------------------------------------------------------------------------*/
+-static int HSC_Horizontal_Line_Forward(FORM * form)
++static int
++HSC_Horizontal_Line_Forward(FORM *form)
+ {
+-  return HSC_Generic(form,form->current->cols);
++  T((T_CALLED("HSC_Horizontal_Line_Forward(%p)"), form));
++  returnCode(HSC_Generic(form, form->current->cols));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int HSC_Horizontal_Half_Line_Forward(FORM* form)
+-|   
++|
+ |   Description   :  Scroll single-line field forward half a line
+ |
+ |   Return Values :  E_OK               - success
+ |                    E_REQUEST_DENIED   - no data ahead
+ +--------------------------------------------------------------------------*/
+-static int HSC_Horizontal_Half_Line_Forward(FORM * form)
++static int
++HSC_Horizontal_Half_Line_Forward(FORM *form)
+ {
+-  return HSC_Generic(form,(form->current->cols + 1)/2);
++  T((T_CALLED("HSC_Horizontal_Half_Line_Forward(%p)"), form));
++  returnCode(HSC_Generic(form, (form->current->cols + 1) / 2));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int HSC_Horizontal_Line_Backward(FORM* form)
+-|   
++|
+ |   Description   :  Scroll single-line field backward a line
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - no data behind
+ +--------------------------------------------------------------------------*/
+-static int HSC_Horizontal_Line_Backward(FORM * form)
++static int
++HSC_Horizontal_Line_Backward(FORM *form)
+ {
+-  return HSC_Generic(form,-(form->current->cols));
++  T((T_CALLED("HSC_Horizontal_Line_Backward(%p)"), form));
++  returnCode(HSC_Generic(form, -(form->current->cols)));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int HSC_Horizontal_Half_Line_Backward(FORM* form)
+-|   
++|
+ |   Description   :  Scroll single-line field backward half a line
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - no data behind
+ +--------------------------------------------------------------------------*/
+-static int HSC_Horizontal_Half_Line_Backward(FORM * form)
++static int
++HSC_Horizontal_Half_Line_Backward(FORM *form)
+ {
+-  return HSC_Generic(form,-((form->current->cols + 1)/2));
++  T((T_CALLED("HSC_Horizontal_Half_Line_Backward(%p)"), form));
++  returnCode(HSC_Generic(form, -((form->current->cols + 1) / 2)));
+ }
+ 
+ /*----------------------------------------------------------------------------
+   End of Horizontal scrolling routines
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Helper routines for Field Editing
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static bool Is_There_Room_For_A_Line(FORM * form)
+-|   
++|
+ |   Description   :  Check whether or not there is enough room in the
+ |                    buffer to enter a whole line.
+ |
+ |   Return Values :  TRUE   - there is enough space
+ |                    FALSE  - there is not enough space
+ +--------------------------------------------------------------------------*/
+-INLINE static bool Is_There_Room_For_A_Line(FORM * form)
++INLINE static bool
++Is_There_Room_For_A_Line(FORM *form)
+ {
+   FIELD *field = form->current;
+-  char *begin_of_last_line, *s;
+-  
++  FIELD_CELL *begin_of_last_line, *s;
++
+   Synchronize_Buffer(form);
+-  begin_of_last_line = Address_Of_Row_In_Buffer(field,(field->drows-1));
+-  s  = After_End_Of_Data(begin_of_last_line,field->dcols);
+-  return ((s==begin_of_last_line) ? TRUE : FALSE);
++  begin_of_last_line = Address_Of_Row_In_Buffer(field, (field->drows - 1));
++  s = After_End_Of_Data(begin_of_last_line, field->dcols);
++  return ((s == begin_of_last_line) ? TRUE : FALSE);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
+-|   
++|
+ |   Description   :  Checks whether or not there is room for a new character
+ |                    in the current line.
+ |
+ |   Return Values :  TRUE    - there is room
+ |                    FALSE   - there is not enough room (line full)
+ +--------------------------------------------------------------------------*/
+-INLINE static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
++INLINE static bool
++Is_There_Room_For_A_Char_In_Line(FORM *form)
+ {
+   int last_char_in_line;
+ 
+-  wmove(form->w,form->currow,form->current->dcols-1);
+-  last_char_in_line  = (int)(winch(form->w) & A_CHARTEXT);
+-  wmove(form->w,form->currow,form->curcol);
++  wmove(form->w, form->currow, form->current->dcols - 1);
++  last_char_in_line = (int)(winch(form->w) & A_CHARTEXT);
++  wmove(form->w, form->currow, form->curcol);
+   return (((last_char_in_line == form->current->pad) ||
+ 	   is_blank(last_char_in_line)) ? TRUE : FALSE);
+ }
+@@ -1971,85 +2208,90 @@
+   !Is_There_Room_For_A_Char_In_Line(f)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Insert_String(
+ |                                             FORM * form,
+ |                                             int row,
+ |                                             char *txt,
+ |                                             int  len )
+-|   
++|
+ |   Description   :  Insert the 'len' characters beginning at pointer 'txt'
+ |                    into the 'row' of the 'form'. The insertion occurs
+ |                    on the beginning of the row, all other characters are
+-|                    moved to the right. After the text a pad character will 
++|                    moved to the right. After the text a pad character will
+ |                    be inserted to separate the text from the rest. If
+ |                    necessary the insertion moves characters on the next
+ |                    line to make place for the requested insertion string.
+ |
+-|   Return Values :  E_OK              - success 
++|   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  -
+ |                    E_SYSTEM_ERROR    - system error
+ +--------------------------------------------------------------------------*/
+-static int Insert_String(FORM *form, int row, char *txt, int len)
+-{ 
+-  FIELD  *field    = form->current;
+-  char *bp         = Address_Of_Row_In_Buffer(field,row);
+-  int datalen      = (int)(After_End_Of_Data(bp,field->dcols) - bp);
+-  int freelen      = field->dcols - datalen;
+-  int requiredlen  = len+1;
+-  char *split;
++static int
++Insert_String(FORM *form, int row, FIELD_CELL *txt, int len)
++{
++  FIELD *field = form->current;
++  FIELD_CELL *bp = Address_Of_Row_In_Buffer(field, row);
++  int datalen = (int)(After_End_Of_Data(bp, field->dcols) - bp);
++  int freelen = field->dcols - datalen;
++  int requiredlen = len + 1;
++  FIELD_CELL *split;
+   int result = E_REQUEST_DENIED;
+-  const char *Space = " ";
+ 
+   if (freelen >= requiredlen)
+     {
+-      wmove(form->w,row,0);
+-      winsnstr(form->w,txt,len);
+-      wmove(form->w,row,len);
+-      winsnstr(form->w,Space,1);
++      wmove(form->w, row, 0);
++      myINSNSTR(form->w, txt, len);
++      wmove(form->w, row, len);
++      myINSNSTR(form->w, &myBLANK, 1);
+       return E_OK;
+     }
+   else
+-    { /* we have to move characters on the next line. If we are on the
+-	 last line this may work, if the field is growable */
++    {
++      /* we have to move characters on the next line. If we are on the
++         last line this may work, if the field is growable */
+       if ((row == (field->drows - 1)) && Growable(field))
+ 	{
+-	  if (!Field_Grown(field,1))
+-	    return(E_SYSTEM_ERROR);
++	  if (!Field_Grown(field, 1))
++	    return (E_SYSTEM_ERROR);
+ 	  /* !!!Side-Effect : might be changed due to growth!!! */
+-	  bp = Address_Of_Row_In_Buffer(field,row); 
++	  bp = Address_Of_Row_In_Buffer(field, row);
+ 	}
+ 
+-      if (row < (field->drows - 1)) 
+-	{ 
+-	  split = After_Last_Whitespace_Character(bp,
+-		    (int)(Get_Start_Of_Data(bp + field->dcols - requiredlen ,
+-					    requiredlen) - bp));
++      if (row < (field->drows - 1))
++	{
++	  split =
++	    After_Last_Whitespace_Character(bp,
++					    (int)(Get_Start_Of_Data(bp
++								    + field->dcols
++								    - requiredlen,
++								    requiredlen)
++						  - bp));
+ 	  /* split points now to the first character of the portion of the
+ 	     line that must be moved to the next line */
+-	  datalen = (int)(split-bp); /* + freelen has to stay on this line   */
+-	  freelen = field->dcols - (datalen + freelen); /* for the next line */
++	  datalen = (int)(split - bp);	/* + freelen has to stay on this line   */
++	  freelen = field->dcols - (datalen + freelen);		/* for the next line */
+ 
+-	  if ((result=Insert_String(form,row+1,split,freelen))==E_OK) 
++	  if ((result = Insert_String(form, row + 1, split, freelen)) == E_OK)
+ 	    {
+-	      wmove(form->w,row,datalen);
++	      wmove(form->w, row, datalen);
+ 	      wclrtoeol(form->w);
+-	      wmove(form->w,row,0);
+-	      winsnstr(form->w,txt,len);
+-	      wmove(form->w,row,len);
+-	      winsnstr(form->w,Space,1);
++	      wmove(form->w, row, 0);
++	      myINSNSTR(form->w, txt, len);
++	      wmove(form->w, row, len);
++	      myINSNSTR(form->w, &myBLANK, 1);
+ 	      return E_OK;
+ 	    }
+ 	}
+-      return(result);
++      return (result);
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Wrapping_Not_Necessary_Or_Wrapping_Ok(
+ |                                             FORM * form)
+-|   
++|
+ |   Description   :  If a character has been entered into a field, it may
+ |                    be that wrapping has to occur. This routine checks
+ |                    whether or not wrapping is required and if so, performs
+@@ -2060,40 +2302,43 @@
+ |                    E_REQUEST_DENIED  -
+ |                    E_SYSTEM_ERROR    - some system error
+ +--------------------------------------------------------------------------*/
+-static int Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM * form)
++static int
++Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM *form)
+ {
+-  FIELD  *field = form->current;
++  FIELD *field = form->current;
+   int result = E_REQUEST_DENIED;
+   bool Last_Row = ((field->drows - 1) == form->currow);
+ 
+-  if ( (field->opts & O_WRAP)                     &&  /* wrapping wanted     */
+-      (!Single_Line_Field(field))                 &&  /* must be multi-line  */
+-      (There_Is_No_Room_For_A_Char_In_Line(form)) &&  /* line is full        */
+-      (!Last_Row || Growable(field))               )  /* there are more lines*/
++  if ((field->opts & O_WRAP) &&	/* wrapping wanted     */
++      (!Single_Line_Field(field)) &&	/* must be multi-line  */
++      (There_Is_No_Room_For_A_Char_In_Line(form)) &&	/* line is full        */
++      (!Last_Row || Growable(field)))	/* there are more lines */
+     {
+-      char *bp;
+-      char *split;
++      FIELD_CELL *bp;
++      FIELD_CELL *split;
+       int chars_to_be_wrapped;
+       int chars_to_remain_on_line;
++
+       if (Last_Row)
+-	{ /* the above logic already ensures, that in this case the field
++	{
++	  /* the above logic already ensures, that in this case the field
+ 	     is growable */
+-	  if (!Field_Grown(field,1))
++	  if (!Field_Grown(field, 1))
+ 	    return E_SYSTEM_ERROR;
+ 	}
+       bp = Address_Of_Current_Row_In_Buffer(form);
+-      Window_To_Buffer(form->w,field);
+-      split = After_Last_Whitespace_Character(bp,field->dcols);
++      Window_To_Buffer(form->w, field);
++      split = After_Last_Whitespace_Character(bp, field->dcols);
+       /* split points to the first character of the sequence to be brought
+          on the next line */
+       chars_to_remain_on_line = (int)(split - bp);
+-      chars_to_be_wrapped     = field->dcols - chars_to_remain_on_line;
++      chars_to_be_wrapped = field->dcols - chars_to_remain_on_line;
+       if (chars_to_remain_on_line > 0)
+ 	{
+-	  if ((result=Insert_String(form,form->currow+1,split,
+-				    chars_to_be_wrapped)) == E_OK)
++	  if ((result = Insert_String(form, form->currow + 1, split,
++				      chars_to_be_wrapped)) == E_OK)
+ 	    {
+-	      wmove(form->w,form->currow,chars_to_remain_on_line);
++	      wmove(form->w, form->currow, chars_to_remain_on_line);
+ 	      wclrtoeol(form->w);
+ 	      if (form->curcol >= chars_to_remain_on_line)
+ 		{
+@@ -2105,29 +2350,28 @@
+ 	}
+       else
+ 	return E_OK;
+-      if (result!=E_OK)
++      if (result != E_OK)
+ 	{
+-	  wmove(form->w,form->currow,form->curcol);
+-	  wdelch(form->w);
+-	  Window_To_Buffer(form->w,field);
++	  DeleteChar(form);
++	  Window_To_Buffer(form->w, field);
+ 	  result = E_REQUEST_DENIED;
+ 	}
+     }
+   else
+-    result = E_OK; /* wrapping was not necessary */
+-  return(result);
++    result = E_OK;		/* wrapping was not necessary */
++  return (result);
+ }
+-
++
+ /*----------------------------------------------------------------------------
+   Field Editing routines
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Field_Editing(
+ |                                    int (* const fct) (FORM *),
+ |                                    FORM * form)
+-|   
++|
+ |   Description   :  Generic routine for field editing requests. The driver
+ |                    routines are only called for editable fields, the
+ |                    _WINDOW_MODIFIED flag is set if editing occurred.
+@@ -2136,30 +2380,31 @@
+ |
+ |   Return Values :  Error code from low level drivers.
+ +--------------------------------------------------------------------------*/
+-static int Field_Editing(int (* const fct) (FORM *), FORM * form)
++static int
++Field_Editing(int (*const fct) (FORM *), FORM *form)
+ {
+   int res = E_REQUEST_DENIED;
+ 
+-  /* We have to deal here with the specific case of the overloaded 
++  /* We have to deal here with the specific case of the overloaded
+      behavior of New_Line and Delete_Previous requests.
+      They may end up in navigational requests if we are on the first
+      character in a field. But navigation is also allowed on non-
+      editable fields.
+-  */ 
+-  if ((fct==FE_Delete_Previous)            && 
+-      (form->opts & O_BS_OVERLOAD)         &&
+-      First_Position_In_Current_Field(form) )
++   */
++  if ((fct == FE_Delete_Previous) &&
++      (form->opts & O_BS_OVERLOAD) &&
++      First_Position_In_Current_Field(form))
+     {
+-      res = Inter_Field_Navigation(FN_Previous_Field,form);
++      res = Inter_Field_Navigation(FN_Previous_Field, form);
+     }
+   else
+     {
+-      if (fct==FE_New_Line)
++      if (fct == FE_New_Line)
+ 	{
+-	  if ((form->opts & O_NL_OVERLOAD)         &&
++	  if ((form->opts & O_NL_OVERLOAD) &&
+ 	      First_Position_In_Current_Field(form))
+ 	    {
+-	      res = Inter_Field_Navigation(FN_Next_Field,form);
++	      res = Inter_Field_Navigation(FN_Next_Field, form);
+ 	    }
+ 	  else
+ 	    /* FE_New_Line deals itself with the _WINDOW_MODIFIED flag */
+@@ -2171,7 +2416,7 @@
+ 	  if (form->current->opts & O_EDIT)
+ 	    {
+ 	      res = fct(form);
+-	      if (res==E_OK)
++	      if (res == E_OK)
+ 		form->status |= _WINDOW_MODIFIED;
+ 	    }
+ 	}
+@@ -2180,11 +2425,11 @@
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_New_Line(FORM * form)
+-|   
++|
+ |   Description   :  Perform a new line request. This is rather complex
+-|                    compared to other routines in this code due to the 
++|                    compared to other routines in this code due to the
+ |                    rather difficult to understand description in the
+ |                    manuals.
+ |
+@@ -2192,133 +2437,141 @@
+ |                    E_REQUEST_DENIED   - new line not allowed
+ |                    E_SYSTEM_ERROR     - system error
+ +--------------------------------------------------------------------------*/
+-static int FE_New_Line(FORM * form)
++static int
++FE_New_Line(FORM *form)
+ {
+-  FIELD  *field = form->current;
+-  char *bp, *t;
+-  bool Last_Row = ((field->drows - 1)==form->currow);
+-  
+-  if (form->status & _OVLMODE) 
++  FIELD *field = form->current;
++  FIELD_CELL *bp, *t;
++  bool Last_Row = ((field->drows - 1) == form->currow);
++
++  T((T_CALLED("FE_New_Line(%p)"), form));
++  if (form->status & _OVLMODE)
+     {
+-      if (Last_Row && 
++      if (Last_Row &&
+ 	  (!(Growable(field) && !Single_Line_Field(field))))
+ 	{
+ 	  if (!(form->opts & O_NL_OVERLOAD))
+-	    return(E_REQUEST_DENIED);
+-	  wmove(form->w,form->currow,form->curcol);
++	    returnCode(E_REQUEST_DENIED);
++	  wmove(form->w, form->currow, form->curcol);
+ 	  wclrtoeol(form->w);
+ 	  /* we have to set this here, although it is also
+ 	     handled in the generic routine. The reason is,
+ 	     that FN_Next_Field may fail, but the form is
+ 	     definitively changed */
+ 	  form->status |= _WINDOW_MODIFIED;
+-	  return Inter_Field_Navigation(FN_Next_Field,form);
++	  returnCode(Inter_Field_Navigation(FN_Next_Field, form));
+ 	}
+-      else 
++      else
+ 	{
+-	  if (Last_Row && !Field_Grown(field,1))
+-	    { /* N.B.: due to the logic in the 'if', LastRow==TRUE
+-		 means here that the field is growable and not
+-		 a single-line field */
+-	      return(E_SYSTEM_ERROR);
++	  if (Last_Row && !Field_Grown(field, 1))
++	    {
++	      /* N.B.: due to the logic in the 'if', LastRow==TRUE
++	         means here that the field is growable and not
++	         a single-line field */
++	      returnCode(E_SYSTEM_ERROR);
+ 	    }
+-	  wmove(form->w,form->currow,form->curcol);
++	  wmove(form->w, form->currow, form->curcol);
+ 	  wclrtoeol(form->w);
+ 	  form->currow++;
+ 	  form->curcol = 0;
+ 	  form->status |= _WINDOW_MODIFIED;
+-	  return(E_OK);
++	  returnCode(E_OK);
+ 	}
+     }
+-  else 
+-    { /* Insert Mode */
++  else
++    {
++      /* Insert Mode */
+       if (Last_Row &&
+ 	  !(Growable(field) && !Single_Line_Field(field)))
+ 	{
+ 	  if (!(form->opts & O_NL_OVERLOAD))
+-	    return(E_REQUEST_DENIED);
+-	  return Inter_Field_Navigation(FN_Next_Field,form);
++	    returnCode(E_REQUEST_DENIED);
++	  returnCode(Inter_Field_Navigation(FN_Next_Field, form));
+ 	}
+-      else 
++      else
+ 	{
+ 	  bool May_Do_It = !Last_Row && Is_There_Room_For_A_Line(form);
+-	  
++
+ 	  if (!(May_Do_It || Growable(field)))
+-	    return(E_REQUEST_DENIED);
+-	  if (!May_Do_It && !Field_Grown(field,1))
+-	    return(E_SYSTEM_ERROR);
+-	  
+-	  bp= Address_Of_Current_Position_In_Buffer(form);
+-	  t = After_End_Of_Data(bp,field->dcols - form->curcol);
+-	  wmove(form->w,form->currow,form->curcol);
++	    returnCode(E_REQUEST_DENIED);
++	  if (!May_Do_It && !Field_Grown(field, 1))
++	    returnCode(E_SYSTEM_ERROR);
++
++	  bp = Address_Of_Current_Position_In_Buffer(form);
++	  t = After_End_Of_Data(bp, field->dcols - form->curcol);
++	  wmove(form->w, form->currow, form->curcol);
+ 	  wclrtoeol(form->w);
+ 	  form->currow++;
+-	  form->curcol=0;
+-	  wmove(form->w,form->currow,form->curcol);
++	  form->curcol = 0;
++	  wmove(form->w, form->currow, form->curcol);
+ 	  winsertln(form->w);
+-	  waddnstr(form->w,bp,(int)(t-bp));
++	  myADDNSTR(form->w, bp, (int)(t - bp));
+ 	  form->status |= _WINDOW_MODIFIED;
+-	  return E_OK;
++	  returnCode(E_OK);
+ 	}
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_Insert_Character(FORM * form)
+-|   
++|
+ |   Description   :  Insert blank character at the cursor position
+ |
+ |   Return Values :  E_OK
+ |                    E_REQUEST_DENIED
+ +--------------------------------------------------------------------------*/
+-static int FE_Insert_Character(FORM * form)
++static int
++FE_Insert_Character(FORM *form)
+ {
+   FIELD *field = form->current;
+   int result = E_REQUEST_DENIED;
+ 
+-  if (Check_Char(field->type,(int)C_BLANK,(TypeArgument *)(field->arg)))
++  T((T_CALLED("FE_Insert_Character(%p)"), form));
++  if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
+     {
+       bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
+ 
+       if (There_Is_Room ||
+ 	  ((Single_Line_Field(field) && Growable(field))))
+ 	{
+-	  if (!There_Is_Room && !Field_Grown(field,1))
+-	    result =  E_SYSTEM_ERROR;
++	  if (!There_Is_Room && !Field_Grown(field, 1))
++	    result = E_SYSTEM_ERROR;
+ 	  else
+ 	    {
+-	      winsch(form->w,(chtype)C_BLANK);
++	      winsch(form->w, (chtype)C_BLANK);
+ 	      result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form);
+ 	    }
+ 	}
+     }
+-  return result;
++  returnCode(result);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_Insert_Line(FORM * form)
+-|   
++|
+ |   Description   :  Insert a blank line at the cursor position
+ |
+ |   Return Values :  E_OK               - success
+ |                    E_REQUEST_DENIED   - line can not be inserted
+ +--------------------------------------------------------------------------*/
+-static int FE_Insert_Line(FORM * form)
++static int
++FE_Insert_Line(FORM *form)
+ {
+   FIELD *field = form->current;
+   int result = E_REQUEST_DENIED;
+ 
+-  if (Check_Char(field->type,(int)C_BLANK,(TypeArgument *)(field->arg)))
++  T((T_CALLED("FE_Insert_Line(%p)"), form));
++  if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
+     {
+-      bool Maybe_Done = (form->currow!=(field->drows-1)) && 
+-	                Is_There_Room_For_A_Line(form);
++      bool Maybe_Done = (form->currow != (field->drows - 1)) &&
++      Is_There_Room_For_A_Line(form);
+ 
+       if (!Single_Line_Field(field) &&
+ 	  (Maybe_Done || Growable(field)))
+ 	{
+-	  if (!Maybe_Done && !Field_Grown(field,1))
++	  if (!Maybe_Done && !Field_Grown(field, 1))
+ 	    result = E_SYSTEM_ERROR;
+ 	  else
+ 	    {
+@@ -2328,28 +2581,29 @@
+ 	    }
+ 	}
+     }
+-  return result;
++  returnCode(result);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_Delete_Character(FORM * form)
+-|   
++|
+ |   Description   :  Delete character at the cursor position
+ |
+ |   Return Values :  E_OK    - success
+ +--------------------------------------------------------------------------*/
+-static int FE_Delete_Character(FORM * form)
++static int
++FE_Delete_Character(FORM *form)
+ {
+-  wmove(form->w,form->currow,form->curcol);
+-  wdelch(form->w);
+-  return E_OK;
++  T((T_CALLED("FE_Delete_Character(%p)"), form));
++  DeleteChar(form);
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_Delete_Previous(FORM * form)
+-|   
++|
+ |   Description   :  Delete character before cursor. Again this is a rather
+ |                    difficult piece compared to others due to the overloading
+ |                    semantics of backspace.
+@@ -2359,304 +2613,329 @@
+ |   Return Values :  E_OK                - success
+ |                    E_REQUEST_DENIED    - Character can't be deleted
+ +--------------------------------------------------------------------------*/
+-static int FE_Delete_Previous(FORM * form)
++static int
++FE_Delete_Previous(FORM *form)
+ {
+-  FIELD  *field = form->current;
+-  
++  FIELD *field = form->current;
++
++  T((T_CALLED("FE_Delete_Previous(%p)"), form));
+   if (First_Position_In_Current_Field(form))
+-    return E_REQUEST_DENIED;
++    returnCode(E_REQUEST_DENIED);
+ 
+-  if ( (--(form->curcol))<0 )
++  if ((--(form->curcol)) < 0)
+     {
+-      char *this_line, *prev_line, *prev_end, *this_end;
+-      
++      FIELD_CELL *this_line, *prev_line, *prev_end, *this_end;
++
+       form->curcol++;
+-      if (form->status & _OVLMODE) 
+-	return E_REQUEST_DENIED;
+-      
+-      prev_line = Address_Of_Row_In_Buffer(field,(form->currow-1));
+-      this_line = Address_Of_Row_In_Buffer(field,(form->currow));
++      if (form->status & _OVLMODE)
++	returnCode(E_REQUEST_DENIED);
++
++      prev_line = Address_Of_Row_In_Buffer(field, (form->currow - 1));
++      this_line = Address_Of_Row_In_Buffer(field, (form->currow));
+       Synchronize_Buffer(form);
+-      prev_end = After_End_Of_Data(prev_line,field->dcols);
+-      this_end = After_End_Of_Data(this_line,field->dcols);
+-      if ((int)(this_end-this_line) > 
+-	  (field->cols-(int)(prev_end-prev_line))) 
+-	return E_REQUEST_DENIED;
+-      wmove(form->w,form->currow,form->curcol);
++      prev_end = After_End_Of_Data(prev_line, field->dcols);
++      this_end = After_End_Of_Data(this_line, field->dcols);
++      if ((int)(this_end - this_line) >
++	  (field->cols - (int)(prev_end - prev_line)))
++	returnCode(E_REQUEST_DENIED);
++      wmove(form->w, form->currow, form->curcol);
+       wdeleteln(form->w);
+-      Adjust_Cursor_Position(form,prev_end);
+-      wmove(form->w,form->currow,form->curcol);
+-      waddnstr(form->w,this_line,(int)(this_end-this_line));
+-    } 
+-  else 
++      Adjust_Cursor_Position(form, prev_end);
++      wmove(form->w, form->currow, form->curcol);
++      myADDNSTR(form->w, this_line, (int)(this_end - this_line));
++    }
++  else
+     {
+-      wmove(form->w,form->currow,form->curcol);
+-      wdelch(form->w);
++      DeleteChar(form);
+     }
+-  return E_OK;
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_Delete_Line(FORM * form)
+-|   
++|
+ |   Description   :  Delete line at cursor position.
+ |
+ |   Return Values :  E_OK  - success
+ +--------------------------------------------------------------------------*/
+-static int FE_Delete_Line(FORM * form)
++static int
++FE_Delete_Line(FORM *form)
+ {
++  T((T_CALLED("FE_Delete_Line(%p)"), form));
+   form->curcol = 0;
+   wdeleteln(form->w);
+-  return E_OK;
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_Delete_Word(FORM * form)
+-|   
++|
+ |   Description   :  Delete word at cursor position
+ |
+ |   Return Values :  E_OK               - success
+ |                    E_REQUEST_DENIED   - failure
+ +--------------------------------------------------------------------------*/
+-static int FE_Delete_Word(FORM * form)
++static int
++FE_Delete_Word(FORM *form)
+ {
+-  FIELD  *field = form->current;
+-  char   *bp = Address_Of_Current_Row_In_Buffer(form);
+-  char   *ep = bp + field->dcols;
+-  char   *cp = bp + form->curcol;
+-  char *s;
+-  
++  FIELD *field = form->current;
++  FIELD_CELL *bp = Address_Of_Current_Row_In_Buffer(form);
++  FIELD_CELL *ep = bp + field->dcols;
++  FIELD_CELL *cp = bp + form->curcol;
++  FIELD_CELL *s;
++
++  T((T_CALLED("FE_Delete_Word(%p)"), form));
+   Synchronize_Buffer(form);
+-  if (is_blank(*cp)) 
+-    return E_REQUEST_DENIED; /* not in word */
++  if (ISBLANK(*cp))
++    returnCode(E_REQUEST_DENIED);	/* not in word */
+ 
+   /* move cursor to begin of word and erase to end of screen-line */
+   Adjust_Cursor_Position(form,
+-			 After_Last_Whitespace_Character(bp,form->curcol)); 
+-  wmove(form->w,form->currow,form->curcol);
++			 After_Last_Whitespace_Character(bp, form->curcol));
++  wmove(form->w, form->currow, form->curcol);
+   wclrtoeol(form->w);
+ 
+   /* skip over word in buffer */
+-  s = Get_First_Whitespace_Character(cp,(int)(ep-cp)); 
++  s = Get_First_Whitespace_Character(cp, (int)(ep - cp));
+   /* to begin of next word    */
+-  s = Get_Start_Of_Data(s,(int)(ep - s));
+-  if ( (s!=cp) && !is_blank(*s))
++  s = Get_Start_Of_Data(s, (int)(ep - s));
++  if ((s != cp) && !ISBLANK(*s))
+     {
+       /* copy remaining line to window */
+-      waddnstr(form->w,s,(int)(s - After_End_Of_Data(s,(int)(ep - s))));
++      myADDNSTR(form->w, s, (int)(s - After_End_Of_Data(s, (int)(ep - s))));
+     }
+-  return E_OK;
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_Clear_To_End_Of_Line(FORM * form)
+-|   
++|
+ |   Description   :  Clear to end of current line.
+ |
+ |   Return Values :  E_OK   - success
+ +--------------------------------------------------------------------------*/
+-static int FE_Clear_To_End_Of_Line(FORM * form)
++static int
++FE_Clear_To_End_Of_Line(FORM *form)
+ {
+-  wmove(form->w,form->currow,form->curcol);
++  T((T_CALLED("FE_Clear_To_End_Of_Line(%p)"), form));
++  wmove(form->w, form->currow, form->curcol);
+   wclrtoeol(form->w);
+-  return E_OK;
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_Clear_To_End_Of_Field(FORM * form)
+-|   
++|
+ |   Description   :  Clear to end of field.
+ |
+ |   Return Values :  E_OK   - success
+ +--------------------------------------------------------------------------*/
+-static int FE_Clear_To_End_Of_Field(FORM * form)
++static int
++FE_Clear_To_End_Of_Field(FORM *form)
+ {
+-  wmove(form->w,form->currow,form->curcol);
++  T((T_CALLED("FE_Clear_To_End_Of_Field(%p)"), form));
++  wmove(form->w, form->currow, form->curcol);
+   wclrtobot(form->w);
+-  return E_OK;
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FE_Clear_Field(FORM * form)
+-|   
++|
+ |   Description   :  Clear entire field.
+ |
+ |   Return Values :  E_OK   - success
+ +--------------------------------------------------------------------------*/
+-static int FE_Clear_Field(FORM * form)
++static int
++FE_Clear_Field(FORM *form)
+ {
++  T((T_CALLED("FE_Clear_Field(%p)"), form));
+   form->currow = form->curcol = 0;
+   werase(form->w);
+-  return E_OK;
++  returnCode(E_OK);
+ }
+ /*----------------------------------------------------------------------------
+-  END of Field Editing routines 
++  END of Field Editing routines
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Edit Mode routines
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int EM_Overlay_Mode(FORM * form)
+-|   
++|
+ |   Description   :  Switch to overlay mode.
+ |
+ |   Return Values :  E_OK   - success
+ +--------------------------------------------------------------------------*/
+-static int EM_Overlay_Mode(FORM * form)
++static int
++EM_Overlay_Mode(FORM *form)
+ {
++  T((T_CALLED("EM_Overlay_Mode(%p)"), form));
+   form->status |= _OVLMODE;
+-  return E_OK;
++  returnCode(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int EM_Insert_Mode(FORM * form)
+-|   
++|
+ |   Description   :  Switch to insert mode
+ |
+ |   Return Values :  E_OK   - success
+ +--------------------------------------------------------------------------*/
+-static int EM_Insert_Mode(FORM * form)
++static int
++EM_Insert_Mode(FORM *form)
+ {
++  T((T_CALLED("EM_Insert_Mode(%p)"), form));
+   form->status &= ~_OVLMODE;
+-  return E_OK;
++  returnCode(E_OK);
+ }
+ 
+ /*----------------------------------------------------------------------------
+-  END of Edit Mode routines 
++  END of Edit Mode routines
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Helper routines for Choice Requests
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static bool Next_Choice(
+ |                                            FIELDTYPE * typ,
+ |                                            FIELD * field,
+ |                                            TypeArgument *argp)
+-|   
++|
+ |   Description   :  Get the next field choice. For linked types this is
+ |                    done recursively.
+ |
+ |   Return Values :  TRUE    - next choice successfully retrieved
+ |                    FALSE   - couldn't retrieve next choice
+ +--------------------------------------------------------------------------*/
+-static bool Next_Choice(FIELDTYPE * typ, FIELD *field, TypeArgument *argp)
++static bool
++Next_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+ {
+-  if (!typ || !(typ->status & _HAS_CHOICE)) 
++  if (!typ || !(typ->status & _HAS_CHOICE))
+     return FALSE;
+ 
+   if (typ->status & _LINKED_TYPE)
+     {
+       assert(argp);
+-      return(
+-	     Next_Choice(typ->left ,field,argp->left) ||
+-	     Next_Choice(typ->right,field,argp->right) );
+-    } 
++      return (
++	       Next_Choice(typ->left, field, argp->left) ||
++	       Next_Choice(typ->right, field, argp->right));
++    }
+   else
+     {
+       assert(typ->next);
+-      return typ->next(field,(void *)argp);
++      return typ->next(field, (void *)argp);
+     }
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static bool Previous_Choice(
+ |                                                FIELDTYPE * typ,
+ |                                                FIELD * field,
+ |                                                TypeArgument *argp)
+-|   
++|
+ |   Description   :  Get the previous field choice. For linked types this
+ |                    is done recursively.
+ |
+ |   Return Values :  TRUE    - previous choice successfully retrieved
+ |                    FALSE   - couldn't retrieve previous choice
+ +--------------------------------------------------------------------------*/
+-static bool Previous_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
++static bool
++Previous_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+ {
+-  if (!typ || !(typ->status & _HAS_CHOICE)) 
++  if (!typ || !(typ->status & _HAS_CHOICE))
+     return FALSE;
+ 
+   if (typ->status & _LINKED_TYPE)
+     {
+       assert(argp);
+-      return(
+-	     Previous_Choice(typ->left ,field,argp->left) ||
+-	     Previous_Choice(typ->right,field,argp->right));
+-    } 
+-  else 
++      return (
++	       Previous_Choice(typ->left, field, argp->left) ||
++	       Previous_Choice(typ->right, field, argp->right));
++    }
++  else
+     {
+       assert(typ->prev);
+-      return typ->prev(field,(void *)argp);
++      return typ->prev(field, (void *)argp);
+     }
+ }
+ /*----------------------------------------------------------------------------
+   End of Helper routines for Choice Requests
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Routines for Choice Requests
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int CR_Next_Choice(FORM * form)
+-|   
++|
+ |   Description   :  Get the next field choice.
+ |
+ |   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - next choice couldn't be retrieved
+ +--------------------------------------------------------------------------*/
+-static int CR_Next_Choice(FORM * form)
++static int
++CR_Next_Choice(FORM *form)
+ {
+   FIELD *field = form->current;
++
++  T((T_CALLED("CR_Next_Choice(%p)"), form));
+   Synchronize_Buffer(form);
+-  return ((Next_Choice(field->type,field,(TypeArgument *)(field->arg))) ? 
+-	  E_OK : E_REQUEST_DENIED);
++  returnCode((Next_Choice(field->type, field, (TypeArgument *)(field->arg)))
++	     ? E_OK
++	     : E_REQUEST_DENIED);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int CR_Previous_Choice(FORM * form)
+-|   
++|
+ |   Description   :  Get the previous field choice.
+ |
+ |   Return Values :  E_OK              - success
+ |                    E_REQUEST_DENIED  - prev. choice couldn't be retrieved
+ +--------------------------------------------------------------------------*/
+-static int CR_Previous_Choice(FORM * form)
++static int
++CR_Previous_Choice(FORM *form)
+ {
+   FIELD *field = form->current;
++
++  T((T_CALLED("CR_Previous_Choice(%p)"), form));
+   Synchronize_Buffer(form);
+-  return ((Previous_Choice(field->type,field,(TypeArgument *)(field->arg))) ? 
+-	  E_OK : E_REQUEST_DENIED);
++  returnCode((Previous_Choice(field->type, field, (TypeArgument *)(field->arg)))
++	     ? E_OK
++	     : E_REQUEST_DENIED);
+ }
+ /*----------------------------------------------------------------------------
+   End of Routines for Choice Requests
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Helper routines for Field Validations.
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static bool Check_Field(
+ |                                            FIELDTYPE * typ,
+ |                                            FIELD * field,
+ |                                            TypeArgument * argp)
+-|   
++|
+ |   Description   :  Check the field according to its fieldtype and its
+ |                    actual arguments. For linked fieldtypes this is done
+ |                    recursively.
+@@ -2664,59 +2943,63 @@
+ |   Return Values :  TRUE       - field is valid
+ |                    FALSE      - field is invalid.
+ +--------------------------------------------------------------------------*/
+-static bool Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
++static bool
++Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+ {
+   if (typ)
+     {
+       if (field->opts & O_NULLOK)
+ 	{
+-	  char *bp = field->buf;
++	  FIELD_CELL *bp = field->buf;
++
+ 	  assert(bp);
+-	  while(is_blank(*bp))
+-	    { bp++; }
+-	  if (*bp == '\0') 
++	  while (ISBLANK(*bp))
++	    {
++	      bp++;
++	    }
++	  if (CharOf(*bp) == 0)
+ 	    return TRUE;
+ 	}
+ 
+       if (typ->status & _LINKED_TYPE)
+ 	{
+ 	  assert(argp);
+-	  return( 
+-		 Check_Field(typ->left ,field,argp->left ) ||
+-		 Check_Field(typ->right,field,argp->right) );
++	  return (
++		   Check_Field(typ->left, field, argp->left) ||
++		   Check_Field(typ->right, field, argp->right));
+ 	}
+-      else 
++      else
+ 	{
+ 	  if (typ->fcheck)
+-	    return typ->fcheck(field,(void *)argp);
++	    return typ->fcheck(field, (void *)argp);
+ 	}
+     }
+   return TRUE;
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  bool _nc_Internal_Validation(FORM * form )
+-|   
+-|   Description   :  Validate the current field of the form.  
++|
++|   Description   :  Validate the current field of the form.
+ |
+ |   Return Values :  TRUE  - field is valid
+ |                    FALSE - field is invalid
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(bool)
+-_nc_Internal_Validation (FORM *form)
++_nc_Internal_Validation(FORM *form)
+ {
+   FIELD *field;
+ 
+-  field = form->current; 
+-  
++  field = form->current;
++
+   Synchronize_Buffer(form);
+   if ((form->status & _FCHECK_REQUIRED) ||
+       (!(field->opts & O_PASSOK)))
+     {
+-      if (!Check_Field(field->type,field,(TypeArgument *)(field->arg)))
++      if (!Check_Field(field->type, field, (TypeArgument *)(field->arg)))
+ 	return FALSE;
+-      form->status  &= ~_FCHECK_REQUIRED;
++      form->status &= ~_FCHECK_REQUIRED;
+       field->status |= _CHANGED;
+       Synchronize_Linked_Fields(field);
+     }
+@@ -2725,67 +3008,71 @@
+ /*----------------------------------------------------------------------------
+   End of Helper routines for Field Validations.
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Routines for Field Validation.
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FV_Validation(FORM * form)
+-|   
++|
+ |   Description   :  Validate the current field of the form.
+ |
+ |   Return Values :  E_OK             - field valid
+ |                    E_INVALID_FIELD  - field not valid
+ +--------------------------------------------------------------------------*/
+-static int FV_Validation(FORM * form)
++static int
++FV_Validation(FORM *form)
+ {
++  T((T_CALLED("FV_Validation(%p)"), form));
+   if (_nc_Internal_Validation(form))
+-    return E_OK;
++    returnCode(E_OK);
+   else
+-    return E_INVALID_FIELD;
++    returnCode(E_INVALID_FIELD);
+ }
+ /*----------------------------------------------------------------------------
+   End of routines for Field Validation.
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Helper routines for Inter-Field Navigation
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static FIELD *Next_Field_On_Page(FIELD * field)
+-|   
+-|   Description   :  Get the next field after the given field on the current 
++|
++|   Description   :  Get the next field after the given field on the current
+ |                    page. The order of fields is the one defined by the
+ |                    fields array. Only visible and active fields are
+ |                    counted.
+ |
+ |   Return Values :  Pointer to the next field.
+ +--------------------------------------------------------------------------*/
+-INLINE static FIELD *Next_Field_On_Page(FIELD * field)
++INLINE static FIELD *
++Next_Field_On_Page(FIELD *field)
+ {
+-  FORM  *form = field->form;
++  FORM *form = field->form;
+   FIELD **field_on_page = &form->field[field->index];
+   FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
+-  FIELD **last_on_page  = &form->field[form->page[form->curpage].pmax];
++  FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+ 
+   do
+     {
+-      field_on_page = 
+-	(field_on_page==last_on_page) ? first_on_page : field_on_page + 1;
++      field_on_page =
++	(field_on_page == last_on_page) ? first_on_page : field_on_page + 1;
+       if (Field_Is_Selectable(*field_on_page))
+ 	break;
+-    } while(field!=(*field_on_page));  
+-  return(*field_on_page);
++    }
++  while (field != (*field_on_page));
++  return (*field_on_page);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  FIELD* _nc_First_Active_Field(FORM * form)
+-|   
++|
+ |   Description   :  Get the first active field on the current page,
+ |                    if there are such. If there are none, get the first
+ |                    visible field on the page. If there are also none,
+@@ -2793,17 +3080,18 @@
+ |
+ |   Return Values :  Pointer to calculated field.
+ +--------------------------------------------------------------------------*/
+-NCURSES_EXPORT(FIELD*)
+-_nc_First_Active_Field (FORM * form)
++NCURSES_EXPORT(FIELD *)
++_nc_First_Active_Field(FORM *form)
+ {
+   FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+   FIELD *proposed = Next_Field_On_Page(*last_on_page);
+ 
+   if (proposed == *last_on_page)
+-    { /* there might be the special situation, where there is no 
+-	 active and visible field on the current page. We then select
+-	 the first visible field on this readonly page
+-      */
++    {
++      /* there might be the special situation, where there is no
++         active and visible field on the current page. We then select
++         the first visible field on this readonly page
++       */
+       if (Field_Is_Not_Selectable(proposed))
+ 	{
+ 	  FIELD **field = &form->field[proposed->index];
+@@ -2811,66 +3099,71 @@
+ 
+ 	  do
+ 	    {
+-	      field = (field==last_on_page) ? first : field + 1;
++	      field = (field == last_on_page) ? first : field + 1;
+ 	      if (((*field)->opts & O_VISIBLE))
+ 		break;
+-	    } while(proposed!=(*field));
+-	  
++	    }
++	  while (proposed != (*field));
++
+ 	  proposed = *field;
+ 
+-	  if ((proposed == *last_on_page) && !(proposed->opts&O_VISIBLE))
+-	    { /* This means, there is also no visible field on the page.
+-		 So we propose the first one and hope the very best... 
+-		 Some very clever user has designed a readonly and invisible
+-		 page on this form.
++	  if ((proposed == *last_on_page) && !(proposed->opts & O_VISIBLE))
++	    {
++	      /* This means, there is also no visible field on the page.
++	         So we propose the first one and hope the very best...
++	         Some very clever user has designed a readonly and invisible
++	         page on this form.
+ 	       */
+ 	      proposed = *first;
+ 	    }
+ 	}
+     }
+-  return(proposed);
++  return (proposed);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static FIELD *Previous_Field_On_Page(FIELD * field)
+-|   
+-|   Description   :  Get the previous field before the given field on the 
+-|                    current page. The order of fields is the one defined by 
++|
++|   Description   :  Get the previous field before the given field on the
++|                    current page. The order of fields is the one defined by
+ |                    the fields array. Only visible and active fields are
+ |                    counted.
+ |
+ |   Return Values :  Pointer to the previous field.
+ +--------------------------------------------------------------------------*/
+-INLINE static FIELD *Previous_Field_On_Page(FIELD * field)
++INLINE static FIELD *
++Previous_Field_On_Page(FIELD *field)
+ {
+-  FORM  *form   = field->form;
++  FORM *form = field->form;
+   FIELD **field_on_page = &form->field[field->index];
+   FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
+-  FIELD **last_on_page  = &form->field[form->page[form->curpage].pmax];
+-  
++  FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
++
+   do
+     {
+-      field_on_page = 
+-	(field_on_page==first_on_page) ? last_on_page : field_on_page - 1;
++      field_on_page =
++	(field_on_page == first_on_page) ? last_on_page : field_on_page - 1;
+       if (Field_Is_Selectable(*field_on_page))
+ 	break;
+-    } while(field!=(*field_on_page));
+-  
++    }
++  while (field != (*field_on_page));
++
+   return (*field_on_page);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static FIELD *Sorted_Next_Field(FIELD * field)
+-|   
+-|   Description   :  Get the next field after the given field on the current 
++|
++|   Description   :  Get the next field after the given field on the current
+ |                    page. The order of fields is the one defined by the
+ |                    (row,column) geometry, rows are major.
+ |
+ |   Return Values :  Pointer to the next field.
+ +--------------------------------------------------------------------------*/
+-INLINE static FIELD *Sorted_Next_Field(FIELD * field)
++INLINE static FIELD *
++Sorted_Next_Field(FIELD *field)
+ {
+   FIELD *field_on_page = field;
+ 
+@@ -2879,22 +3172,24 @@
+       field_on_page = field_on_page->snext;
+       if (Field_Is_Selectable(field_on_page))
+ 	break;
+-    } while(field_on_page!=field);
+-  
++    }
++  while (field_on_page != field);
++
+   return (field_on_page);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static FIELD *Sorted_Previous_Field(FIELD * field)
+-|   
+-|   Description   :  Get the previous field before the given field on the 
+-|                    current page. The order of fields is the one defined 
++|
++|   Description   :  Get the previous field before the given field on the
++|                    current page. The order of fields is the one defined
+ |                    by the (row,column) geometry, rows are major.
+ |
+ |   Return Values :  Pointer to the previous field.
+ +--------------------------------------------------------------------------*/
+-INLINE static FIELD *Sorted_Previous_Field(FIELD * field)
++INLINE static FIELD *
++Sorted_Previous_Field(FIELD *field)
+ {
+   FIELD *field_on_page = field;
+ 
+@@ -2903,21 +3198,23 @@
+       field_on_page = field_on_page->sprev;
+       if (Field_Is_Selectable(field_on_page))
+ 	break;
+-    } while(field_on_page!=field);
+-  
++    }
++  while (field_on_page != field);
++
+   return (field_on_page);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static FIELD *Left_Neighbor_Field(FIELD * field)
+-|   
++|
+ |   Description   :  Get the left neighbor of the field on the same line
+ |                    and the same page. Cycles through the line.
+ |
+ |   Return Values :  Pointer to left neighbor field.
+ +--------------------------------------------------------------------------*/
+-INLINE static FIELD *Left_Neighbor_Field(FIELD * field)
++INLINE static FIELD *
++Left_Neighbor_Field(FIELD *field)
+ {
+   FIELD *field_on_page = field;
+ 
+@@ -2925,25 +3222,27 @@
+      immediately fails and the loop is left, positioned at the right
+      neighbor. Otherwise we cycle backwards through the sorted field list
+      until we enter the same line (from the right end).
+-  */
++   */
+   do
+     {
+       field_on_page = Sorted_Previous_Field(field_on_page);
+-    } while(field_on_page->frow != field->frow);
+-  
++    }
++  while (field_on_page->frow != field->frow);
++
+   return (field_on_page);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static FIELD *Right_Neighbor_Field(FIELD * field)
+-|   
++|
+ |   Description   :  Get the right neighbor of the field on the same line
+ |                    and the same page.
+ |
+ |   Return Values :  Pointer to right neighbor field.
+ +--------------------------------------------------------------------------*/
+-INLINE static FIELD *Right_Neighbor_Field(FIELD * field)
++INLINE static FIELD *
++Right_Neighbor_Field(FIELD *field)
+ {
+   FIELD *field_on_page = field;
+ 
+@@ -2951,15 +3250,16 @@
+   do
+     {
+       field_on_page = Sorted_Next_Field(field_on_page);
+-    } while(field_on_page->frow != field->frow);
+-  
++    }
++  while (field_on_page->frow != field->frow);
++
+   return (field_on_page);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static FIELD *Upper_Neighbor_Field(FIELD * field)
+-|   
++|
+ |   Description   :  Because of the row-major nature of sorting the fields,
+ |                    it is more difficult to define whats the upper neighbor
+ |                    field really means. We define that it must be on a
+@@ -2969,7 +3269,8 @@
+ |
+ |   Return Values :  Pointer to the upper neighbor field.
+ +--------------------------------------------------------------------------*/
+-static FIELD *Upper_Neighbor_Field(FIELD * field)
++static FIELD *
++Upper_Neighbor_Field(FIELD *field)
+ {
+   FIELD *field_on_page = field;
+   int frow = field->frow;
+@@ -2978,35 +3279,37 @@
+   /* Walk back to the 'previous' line. The second term in the while clause
+      just guarantees that we stop if we cycled through the line because
+      there might be no 'previous' line if the page has just one line.
+-  */
++   */
+   do
+     {
+       field_on_page = Sorted_Previous_Field(field_on_page);
+-    } while(field_on_page->frow==frow && field_on_page->fcol!=fcol);
+-  
+-  if (field_on_page->frow!=frow)
+-    { /* We really found a 'previous' line. We are positioned at the
++    }
++  while (field_on_page->frow == frow && field_on_page->fcol != fcol);
++
++  if (field_on_page->frow != frow)
++    {
++      /* We really found a 'previous' line. We are positioned at the
+          rightmost field on this line */
+-      frow = field_on_page->frow; 
++      frow = field_on_page->frow;
+ 
+-      /* We walk to the left as long as we are really right of the 
+-	 field. */
+-      while(field_on_page->frow==frow && field_on_page->fcol>fcol)
++      /* We walk to the left as long as we are really right of the
++         field. */
++      while (field_on_page->frow == frow && field_on_page->fcol > fcol)
+ 	field_on_page = Sorted_Previous_Field(field_on_page);
+ 
+-      /* If we wrapped, just go to the right which is the first field on 
+-	 the row */
+-      if (field_on_page->frow!=frow)
++      /* If we wrapped, just go to the right which is the first field on
++         the row */
++      if (field_on_page->frow != frow)
+ 	field_on_page = Sorted_Next_Field(field_on_page);
+     }
+-  
++
+   return (field_on_page);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static FIELD *Down_Neighbor_Field(FIELD * field)
+-|   
++|
+ |   Description   :  Because of the row-major nature of sorting the fields,
+ |                    its more difficult to define whats the down neighbor
+ |                    field really means. We define that it must be on a
+@@ -3016,7 +3319,8 @@
+ |
+ |   Return Values :  Pointer to the upper neighbor field.
+ +--------------------------------------------------------------------------*/
+-static FIELD *Down_Neighbor_Field(FIELD * field)
++static FIELD *
++Down_Neighbor_Field(FIELD *field)
+ {
+   FIELD *field_on_page = field;
+   int frow = field->frow;
+@@ -3025,41 +3329,43 @@
+   /* Walk forward to the 'next' line. The second term in the while clause
+      just guarantees that we stop if we cycled through the line because
+      there might be no 'next' line if the page has just one line.
+-  */
++   */
+   do
+     {
+       field_on_page = Sorted_Next_Field(field_on_page);
+-    } while(field_on_page->frow==frow && field_on_page->fcol!=fcol);
++    }
++  while (field_on_page->frow == frow && field_on_page->fcol != fcol);
+ 
+-  if (field_on_page->frow!=frow)
+-    { /* We really found a 'next' line. We are positioned at the rightmost
++  if (field_on_page->frow != frow)
++    {
++      /* We really found a 'next' line. We are positioned at the rightmost
+          field on this line */
+       frow = field_on_page->frow;
+ 
+-      /* We walk to the right as long as we are really left of the 
+-	 field. */
+-      while(field_on_page->frow==frow && field_on_page->fcol<fcol)
++      /* We walk to the right as long as we are really left of the
++         field. */
++      while (field_on_page->frow == frow && field_on_page->fcol < fcol)
+ 	field_on_page = Sorted_Next_Field(field_on_page);
+ 
+-      /* If we wrapped, just go to the left which is the last field on 
+-	 the row */
+-      if (field_on_page->frow!=frow)
++      /* If we wrapped, just go to the left which is the last field on
++         the row */
++      if (field_on_page->frow != frow)
+ 	field_on_page = Sorted_Previous_Field(field_on_page);
+     }
+-  
+-  return(field_on_page);
++
++  return (field_on_page);
+ }
+-
++
+ /*----------------------------------------------------------------------------
+   Inter-Field Navigation routines
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Inter_Field_Navigation(
+ |                                           int (* const fct) (FORM *),
+ |                                           FORM * form)
+-|   
++|
+ |   Description   :  Generic behavior for changing the current field, the
+ |                    field is left and a new field is entered. So the field
+ |                    must be validated and the field init/term hooks must
+@@ -3069,228 +3375,253 @@
+ |                    E_INVALID_FIELD     - field is invalid
+ |                    some other          - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int Inter_Field_Navigation(int (* const fct) (FORM *),FORM *form)
++static int
++Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form)
+ {
+   int res;
+ 
+-  if (!_nc_Internal_Validation(form)) 
++  if (!_nc_Internal_Validation(form))
+     res = E_INVALID_FIELD;
+   else
+     {
+-      Call_Hook(form,fieldterm);
++      Call_Hook(form, fieldterm);
+       res = fct(form);
+-      Call_Hook(form,fieldinit);
++      Call_Hook(form, fieldinit);
+     }
+   return res;
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Next_Field(FORM * form)
+-|   
++|
+ |   Description   :  Move to the next field on the current page of the form
+ |
+ |   Return Values :  E_OK                 - success
+ |                    != E_OK              - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Next_Field(FORM * form)
++static int
++FN_Next_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-			       Next_Field_On_Page(form->current));
++  T((T_CALLED("FN_Next_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Next_Field_On_Page(form->current)));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Previous_Field(FORM * form)
+-|   
+-|   Description   :  Move to the previous field on the current page of the 
++|
++|   Description   :  Move to the previous field on the current page of the
+ |                    form
+ |
+ |   Return Values :  E_OK                 - success
+ |                    != E_OK              - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Previous_Field(FORM * form)
++static int
++FN_Previous_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-			       Previous_Field_On_Page(form->current));
++  T((T_CALLED("FN_Previous_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Previous_Field_On_Page(form->current)));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_First_Field(FORM * form)
+-|   
++|
+ |   Description   :  Move to the first field on the current page of the form
+ |
+ |   Return Values :  E_OK                 - success
+ |                    != E_OK              - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_First_Field(FORM * form)
++static int
++FN_First_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-      Next_Field_On_Page(form->field[form->page[form->curpage].pmax]));
++  T((T_CALLED("FN_First_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Next_Field_On_Page(form->field[form->page[form->curpage].pmax])));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Last_Field(FORM * form)
+-|   
++|
+ |   Description   :  Move to the last field on the current page of the form
+ |
+ |   Return Values :  E_OK                 - success
+ |                    != E_OK              - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Last_Field(FORM * form)
++static int
++FN_Last_Field(FORM *form)
+ {
+-  return 
+-    _nc_Set_Current_Field(form,
+-       Previous_Field_On_Page(form->field[form->page[form->curpage].pmin]));
++  T((T_CALLED("FN_Last_Field(%p)"), form));
++  returnCode(
++	      _nc_Set_Current_Field(form,
++				    Previous_Field_On_Page(form->field[form->page[form->curpage].pmin])));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Sorted_Next_Field(FORM * form)
+-|   
++|
+ |   Description   :  Move to the sorted next field on the current page
+ |                    of the form.
+ |
+ |   Return Values :  E_OK            - success
+ |                    != E_OK         - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Sorted_Next_Field(FORM * form)
++static int
++FN_Sorted_Next_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-			       Sorted_Next_Field(form->current));
++  T((T_CALLED("FN_Sorted_Next_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Sorted_Next_Field(form->current)));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Sorted_Previous_Field(FORM * form)
+-|   
++|
+ |   Description   :  Move to the sorted previous field on the current page
+ |                    of the form.
+ |
+ |   Return Values :  E_OK            - success
+ |                    != E_OK         - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Sorted_Previous_Field(FORM * form)
++static int
++FN_Sorted_Previous_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-			       Sorted_Previous_Field(form->current));
++  T((T_CALLED("FN_Sorted_Previous_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Sorted_Previous_Field(form->current)));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Sorted_First_Field(FORM * form)
+-|   
++|
+ |   Description   :  Move to the sorted first field on the current page
+ |                    of the form.
+ |
+ |   Return Values :  E_OK            - success
+ |                    != E_OK         - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Sorted_First_Field(FORM * form)
++static int
++FN_Sorted_First_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-	      Sorted_Next_Field(form->field[form->page[form->curpage].smax]));
++  T((T_CALLED("FN_Sorted_First_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Sorted_Next_Field(form->field[form->page[form->curpage].smax])));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Sorted_Last_Field(FORM * form)
+-|   
++|
+ |   Description   :  Move to the sorted last field on the current page
+ |                    of the form.
+ |
+ |   Return Values :  E_OK            - success
+ |                    != E_OK         - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Sorted_Last_Field(FORM * form)
++static int
++FN_Sorted_Last_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-	   Sorted_Previous_Field(form->field[form->page[form->curpage].smin]));
++  T((T_CALLED("FN_Sorted_Last_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Sorted_Previous_Field(form->field[form->page[form->curpage].smin])));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Left_Field(FORM * form)
+-|   
++|
+ |   Description   :  Get the field on the left of the current field on the
+ |                    same line and the same page. Cycles through the line.
+ |
+ |   Return Values :  E_OK            - success
+ |                    != E_OK         - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Left_Field(FORM * form)
++static int
++FN_Left_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-			       Left_Neighbor_Field(form->current));
++  T((T_CALLED("FN_Left_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Left_Neighbor_Field(form->current)));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Right_Field(FORM * form)
+-|   
++|
+ |   Description   :  Get the field on the right of the current field on the
+ |                    same line and the same page. Cycles through the line.
+ |
+ |   Return Values :  E_OK            - success
+ |                    != E_OK         - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Right_Field(FORM * form)
++static int
++FN_Right_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-			       Right_Neighbor_Field(form->current));
++  T((T_CALLED("FN_Right_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Right_Neighbor_Field(form->current)));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Up_Field(FORM * form)
+-|   
++|
+ |   Description   :  Get the upper neighbor of the current field. This
+ |                    cycles through the page. See the comments of the
+ |                    Upper_Neighbor_Field function to understand how
+-|                    'upper' is defined. 
++|                    'upper' is defined.
+ |
+ |   Return Values :  E_OK            - success
+ |                    != E_OK         - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Up_Field(FORM * form)
++static int
++FN_Up_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-			       Upper_Neighbor_Field(form->current));
++  T((T_CALLED("FN_Up_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Upper_Neighbor_Field(form->current)));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int FN_Down_Field(FORM * form)
+-|   
++|
+ |   Description   :  Get the down neighbor of the current field. This
+ |                    cycles through the page. See the comments of the
+ |                    Down_Neighbor_Field function to understand how
+-|                    'down' is defined. 
++|                    'down' is defined.
+ |
+ |   Return Values :  E_OK            - success
+ |                    != E_OK         - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int FN_Down_Field(FORM * form)
++static int
++FN_Down_Field(FORM *form)
+ {
+-  return _nc_Set_Current_Field(form,
+-			       Down_Neighbor_Field(form->current));
++  T((T_CALLED("FN_Down_Field(%p)"), form));
++  returnCode(_nc_Set_Current_Field(form,
++				   Down_Neighbor_Field(form->current)));
+ }
+ /*----------------------------------------------------------------------------
+-  END of Field Navigation routines 
++  END of Field Navigation routines
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Helper routines for Page Navigation
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int _nc_Set_Form_Page(FORM * form,
+ |                                          int page,
+ |                                          FIELD * field)
+-|   
++|
+ |   Description   :  Make the given page number the current page and make
+ |                    the given field the current field on the page. If
+ |                    for the field NULL is given, make the first field on
+@@ -3301,12 +3632,11 @@
+ |                    != E_OK             - error from subordinate call
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-_nc_Set_Form_Page
+-(FORM * form, int page, FIELD * field)
++_nc_Set_Form_Page(FORM *form, int page, FIELD *field)
+ {
+   int res = E_OK;
+ 
+-  if ((form->curpage!=page))
++  if ((form->curpage != page))
+     {
+       FIELD *last_field, *field_on_page;
+ 
+@@ -3316,63 +3646,66 @@
+       do
+ 	{
+ 	  if (field_on_page->opts & O_VISIBLE)
+-	    if ((res=Display_Field(field_on_page))!=E_OK) 
+-	      return(res);
++	    if ((res = Display_Field(field_on_page)) != E_OK)
++	      return (res);
+ 	  field_on_page = field_on_page->snext;
+-	} while(field_on_page != last_field);
++	}
++      while (field_on_page != last_field);
+ 
+       if (field)
+-	res = _nc_Set_Current_Field(form,field);
++	res = _nc_Set_Current_Field(form, field);
+       else
+ 	/* N.B.: we don't encapsulate this by Inter_Field_Navigation(),
+ 	   because this is already executed in a page navigation
+-	   context that contains field navigation 
++	   context that contains field navigation
+ 	 */
+ 	res = FN_First_Field(form);
+     }
+-  return(res);
++  return (res);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Next_Page_Number(const FORM * form)
+-|   
++|
+ |   Description   :  Calculate the page number following the current page
+ |                    number. This cycles if the highest page number is
+-|                    reached.  
++|                    reached.
+ |
+ |   Return Values :  The next page number
+ +--------------------------------------------------------------------------*/
+-INLINE static int Next_Page_Number(const FORM * form)
++INLINE static int
++Next_Page_Number(const FORM *form)
+ {
+   return (form->curpage + 1) % form->maxpage;
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Previous_Page_Number(const FORM * form)
+-|   
++|
+ |   Description   :  Calculate the page number before the current page
+ |                    number. This cycles if the first page number is
+-|                    reached.  
++|                    reached.
+ |
+ |   Return Values :  The previous page number
+ +--------------------------------------------------------------------------*/
+-INLINE static int Previous_Page_Number(const FORM * form)
++INLINE static int
++Previous_Page_Number(const FORM *form)
+ {
+-  return (form->curpage!=0 ? form->curpage - 1 : form->maxpage - 1);
++  return (form->curpage != 0 ? form->curpage - 1 : form->maxpage - 1);
+ }
+-
++
+ /*----------------------------------------------------------------------------
+-  Page Navigation routines 
++  Page Navigation routines
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Page_Navigation(
+ |                                               int (* const fct) (FORM *),
+ |                                               FORM * form)
+-|   
++|
+ |   Description   :  Generic behavior for changing a page. This means
+ |                    that the field is left and a new field is entered.
+ |                    So the field must be validated and the field init/term
+@@ -3383,90 +3716,100 @@
+ |                    E_INVALID_FIELD     - field is invalid
+ |                    some other          - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int Page_Navigation(int (* const fct) (FORM *), FORM * form)
++static int
++Page_Navigation(int (*const fct) (FORM *), FORM *form)
+ {
+   int res;
+ 
+-  if (!_nc_Internal_Validation(form)) 
++  if (!_nc_Internal_Validation(form))
+     res = E_INVALID_FIELD;
+   else
+     {
+-      Call_Hook(form,fieldterm);
+-      Call_Hook(form,formterm);
++      Call_Hook(form, fieldterm);
++      Call_Hook(form, formterm);
+       res = fct(form);
+-      Call_Hook(form,forminit);
+-      Call_Hook(form,fieldinit);
++      Call_Hook(form, forminit);
++      Call_Hook(form, fieldinit);
+     }
+   return res;
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int PN_Next_Page(FORM * form)
+-|   
++|
+ |   Description   :  Move to the next page of the form
+ |
+ |   Return Values :  E_OK                - success
+ |                    != E_OK             - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int PN_Next_Page(FORM * form)
+-{ 
+-  return _nc_Set_Form_Page(form,Next_Page_Number(form),(FIELD *)0);
++static int
++PN_Next_Page(FORM *form)
++{
++  T((T_CALLED("PN_Next_Page(%p)"), form));
++  returnCode(_nc_Set_Form_Page(form, Next_Page_Number(form), (FIELD *)0));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int PN_Previous_Page(FORM * form)
+-|   
++|
+ |   Description   :  Move to the previous page of the form
+ |
+ |   Return Values :  E_OK              - success
+ |                    != E_OK           - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int PN_Previous_Page(FORM * form)
++static int
++PN_Previous_Page(FORM *form)
+ {
+-  return _nc_Set_Form_Page(form,Previous_Page_Number(form),(FIELD *)0);
++  T((T_CALLED("PN_Previous_Page(%p)"), form));
++  returnCode(_nc_Set_Form_Page(form, Previous_Page_Number(form), (FIELD *)0));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int PN_First_Page(FORM * form)
+-|   
++|
+ |   Description   :  Move to the first page of the form
+ |
+ |   Return Values :  E_OK              - success
+ |                    != E_OK           - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int PN_First_Page(FORM * form)
++static int
++PN_First_Page(FORM *form)
+ {
+-  return _nc_Set_Form_Page(form,0,(FIELD *)0);
++  T((T_CALLED("PN_First_Page(%p)"), form));
++  returnCode(_nc_Set_Form_Page(form, 0, (FIELD *)0));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int PN_Last_Page(FORM * form)
+-|   
++|
+ |   Description   :  Move to the last page of the form
+ |
+ |   Return Values :  E_OK              - success
+ |                    != E_OK           - error from subordinate call
+ +--------------------------------------------------------------------------*/
+-static int PN_Last_Page(FORM * form)
++static int
++PN_Last_Page(FORM *form)
+ {
+-  return _nc_Set_Form_Page(form,form->maxpage-1,(FIELD *)0);
++  T((T_CALLED("PN_Last_Page(%p)"), form));
++  returnCode(_nc_Set_Form_Page(form, form->maxpage - 1, (FIELD *)0));
+ }
++
+ /*----------------------------------------------------------------------------
+-  END of Field Navigation routines 
++  END of Field Navigation routines
+   --------------------------------------------------------------------------*/
+-
++
+ /*----------------------------------------------------------------------------
+   Helper routines for the core form driver.
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  static int Data_Entry(FORM * form,int c)
+-|   
++|
+ |   Description   :  Enter character c into at the current position of the
+ |                    current field of the form.
+ |
+@@ -3474,55 +3817,69 @@
+ |                    E_REQUEST_DENIED  -
+ |                    E_SYSTEM_ERROR    -
+ +--------------------------------------------------------------------------*/
+-static int Data_Entry(FORM * form, int c)
++static int
++Data_Entry(FORM *form, int c)
+ {
+-  FIELD  *field = form->current;
++  FIELD *field = form->current;
+   int result = E_REQUEST_DENIED;
+ 
+-  if ( (field->opts & O_EDIT) 
++  if ((field->opts & O_EDIT)
+ #if FIX_FORM_INACTIVE_BUG
+-       && (field->opts & O_ACTIVE) 
++      && (field->opts & O_ACTIVE)
+ #endif
+-       )
++    )
+     {
+-      if ( (field->opts & O_BLANK) &&
+-	   First_Position_In_Current_Field(form) &&
+-	   !(form->status & _FCHECK_REQUIRED) && 
+-	   !(form->status & _WINDOW_MODIFIED) )
++      if ((field->opts & O_BLANK) &&
++	  First_Position_In_Current_Field(form) &&
++	  !(form->status & _FCHECK_REQUIRED) &&
++	  !(form->status & _WINDOW_MODIFIED))
+ 	werase(form->w);
+ 
+       if (form->status & _OVLMODE)
+ 	{
+-	  waddch(form->w,(chtype)c);
+-	} 
+-      else /* no _OVLMODE */ 
++	  waddch(form->w, (chtype)c);
++	}
++      else
++	/* no _OVLMODE */
+ 	{
+ 	  bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
+ 
+ 	  if (!(There_Is_Room ||
+ 		((Single_Line_Field(field) && Growable(field)))))
+-	      return E_REQUEST_DENIED;
++	    return E_REQUEST_DENIED;
+ 
+-	  if (!There_Is_Room && !Field_Grown(field,1))
++	  if (!There_Is_Room && !Field_Grown(field, 1))
+ 	    return E_SYSTEM_ERROR;
+ 
+-	  winsch(form->w,(chtype)c);
++	  winsch(form->w, (chtype)c);
+ 	}
+ 
+-      if ((result=Wrapping_Not_Necessary_Or_Wrapping_Ok(form))==E_OK)
++      if ((result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form)) == E_OK)
+ 	{
+-	  bool End_Of_Field= (((field->drows-1)==form->currow) &&
+-			      ((field->dcols-1)==form->curcol));
++	  bool End_Of_Field = (((field->drows - 1) == form->currow) &&
++			       ((field->dcols - 1) == form->curcol));
++
+ 	  form->status |= _WINDOW_MODIFIED;
+ 	  if (End_Of_Field && !Growable(field) && (field->opts & O_AUTOSKIP))
+-	    result = Inter_Field_Navigation(FN_Next_Field,form);
++	    result = Inter_Field_Navigation(FN_Next_Field, form);
+ 	  else
+ 	    {
+-	      if (End_Of_Field && Growable(field) && !Field_Grown(field,1))
++	      if (End_Of_Field && Growable(field) && !Field_Grown(field, 1))
+ 		result = E_SYSTEM_ERROR;
+ 	      else
+ 		{
++#if USE_WIDEC_SUPPORT
++		  /*
++		   * We have just added a byte to the form field.  It may have
++		   * been part of a multibyte character.  If it was, the
++		   * addch_used field is nonzero and we should not try to move
++		   * to a new column.
++		   */
++		  if (WINDOW_EXT(form->w, addch_used) == 0)
++		    IFN_Next_Character(form);
++#else
+ 		  IFN_Next_Character(form);
++#endif
+ 		  result = E_OK;
+ 		}
+ 	    }
+@@ -3530,45 +3887,48 @@
+     }
+   return result;
+ }
+-
++
+ /* Structure to describe the binding of a request code to a function.
+    The member keycode codes the request value as well as the generic
+    routine to use for the request. The code for the generic routine
+    is coded in the upper 16 Bits while the request code is coded in
+-   the lower 16 bits. 
++   the lower 16 bits.
+ 
+    In terms of C++ you might think of a request as a class with a
+    virtual method "perform". The different types of request are
+    derived from this base class and overload (or not) the base class
+    implementation of perform.
+ */
+-typedef struct {
+-  int keycode;           /* must be at least 32 bit: hi:mode, lo: key */
+-  int (*cmd)(FORM *);    /* low level driver routine for this key     */
+-} Binding_Info;
++typedef struct
++{
++  int keycode;			/* must be at least 32 bit: hi:mode, lo: key */
++  int (*cmd) (FORM *);		/* low level driver routine for this key     */
++}
++Binding_Info;
+ 
+ /* You may see this is the class-id of the request type class */
+-#define ID_PN    (0x00000000)    /* Page navigation           */
+-#define ID_FN    (0x00010000)    /* Inter-Field navigation    */
+-#define ID_IFN   (0x00020000)    /* Intra-Field navigation    */
+-#define ID_VSC   (0x00030000)    /* Vertical Scrolling        */
+-#define ID_HSC   (0x00040000)    /* Horizontal Scrolling      */
+-#define ID_FE    (0x00050000)    /* Field Editing             */
+-#define ID_EM    (0x00060000)    /* Edit Mode                 */
+-#define ID_FV    (0x00070000)    /* Field Validation          */
+-#define ID_CH    (0x00080000)    /* Choice                    */
++#define ID_PN    (0x00000000)	/* Page navigation           */
++#define ID_FN    (0x00010000)	/* Inter-Field navigation    */
++#define ID_IFN   (0x00020000)	/* Intra-Field navigation    */
++#define ID_VSC   (0x00030000)	/* Vertical Scrolling        */
++#define ID_HSC   (0x00040000)	/* Horizontal Scrolling      */
++#define ID_FE    (0x00050000)	/* Field Editing             */
++#define ID_EM    (0x00060000)	/* Edit Mode                 */
++#define ID_FV    (0x00070000)	/* Field Validation          */
++#define ID_CH    (0x00080000)	/* Choice                    */
+ #define ID_Mask  (0xffff0000)
+ #define Key_Mask (0x0000ffff)
+ #define ID_Shft  (16)
+ 
+ /* This array holds all the Binding Infos */
+-static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] = 
++/* *INDENT-OFF* */
++static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
+ {
+   { REQ_NEXT_PAGE    |ID_PN  ,PN_Next_Page},
+   { REQ_PREV_PAGE    |ID_PN  ,PN_Previous_Page},
+   { REQ_FIRST_PAGE   |ID_PN  ,PN_First_Page},
+   { REQ_LAST_PAGE    |ID_PN  ,PN_Last_Page},
+-  
++
+   { REQ_NEXT_FIELD   |ID_FN  ,FN_Next_Field},
+   { REQ_PREV_FIELD   |ID_FN  ,FN_Previous_Field},
+   { REQ_FIRST_FIELD  |ID_FN  ,FN_First_Field},
+@@ -3581,7 +3941,7 @@
+   { REQ_RIGHT_FIELD  |ID_FN  ,FN_Right_Field},
+   { REQ_UP_FIELD     |ID_FN  ,FN_Up_Field},
+   { REQ_DOWN_FIELD   |ID_FN  ,FN_Down_Field},
+-  
++
+   { REQ_NEXT_CHAR    |ID_IFN ,IFN_Next_Character},
+   { REQ_PREV_CHAR    |ID_IFN ,IFN_Previous_Character},
+   { REQ_NEXT_LINE    |ID_IFN ,IFN_Next_Line},
+@@ -3596,7 +3956,7 @@
+   { REQ_RIGHT_CHAR   |ID_IFN ,IFN_Right_Character},
+   { REQ_UP_CHAR      |ID_IFN ,IFN_Up_Character},
+   { REQ_DOWN_CHAR    |ID_IFN ,IFN_Down_Character},
+-  
++
+   { REQ_NEW_LINE     |ID_FE  ,FE_New_Line},
+   { REQ_INS_CHAR     |ID_FE  ,FE_Insert_Character},
+   { REQ_INS_LINE     |ID_FE  ,FE_Insert_Line},
+@@ -3607,34 +3967,35 @@
+   { REQ_CLR_EOL      |ID_FE  ,FE_Clear_To_End_Of_Line},
+   { REQ_CLR_EOF      |ID_FE  ,FE_Clear_To_End_Of_Field},
+   { REQ_CLR_FIELD    |ID_FE  ,FE_Clear_Field},
+-  
++
+   { REQ_OVL_MODE     |ID_EM  ,EM_Overlay_Mode},
+   { REQ_INS_MODE     |ID_EM  ,EM_Insert_Mode},
+-  
++
+   { REQ_SCR_FLINE    |ID_VSC ,VSC_Scroll_Line_Forward},
+   { REQ_SCR_BLINE    |ID_VSC ,VSC_Scroll_Line_Backward},
+   { REQ_SCR_FPAGE    |ID_VSC ,VSC_Scroll_Page_Forward},
+   { REQ_SCR_BPAGE    |ID_VSC ,VSC_Scroll_Page_Backward},
+   { REQ_SCR_FHPAGE   |ID_VSC ,VSC_Scroll_Half_Page_Forward},
+   { REQ_SCR_BHPAGE   |ID_VSC ,VSC_Scroll_Half_Page_Backward},
+-  
++
+   { REQ_SCR_FCHAR    |ID_HSC ,HSC_Scroll_Char_Forward},
+   { REQ_SCR_BCHAR    |ID_HSC ,HSC_Scroll_Char_Backward},
+   { REQ_SCR_HFLINE   |ID_HSC ,HSC_Horizontal_Line_Forward},
+   { REQ_SCR_HBLINE   |ID_HSC ,HSC_Horizontal_Line_Backward},
+   { REQ_SCR_HFHALF   |ID_HSC ,HSC_Horizontal_Half_Line_Forward},
+   { REQ_SCR_HBHALF   |ID_HSC ,HSC_Horizontal_Half_Line_Backward},
+-  
++
+   { REQ_VALIDATION   |ID_FV  ,FV_Validation},
+ 
+   { REQ_NEXT_CHOICE  |ID_CH  ,CR_Next_Choice},
+   { REQ_PREV_CHOICE  |ID_CH  ,CR_Previous_Choice}
+ };
++/* *INDENT-ON* */
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int form_driver(FORM * form,int  c)
+-|   
++|
+ |   Description   :  This is the workhorse of the forms system. It checks
+ |                    to determine whether the character c is a request or
+ |                    data. If it is a request, the form driver executes
+@@ -3656,126 +4017,143 @@
+ |                    E_UNKNOWN_COMMAND - command not known
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-form_driver (FORM * form, int  c)
++form_driver(FORM *form, int c)
+ {
+-  const Binding_Info* BI = (Binding_Info *)0;
++  const Binding_Info *BI = (Binding_Info *) 0;
+   int res = E_UNKNOWN_COMMAND;
+ 
++  T((T_CALLED("form_driver(%p,%d)"), form, c));
++
+   if (!form)
+     RETURN(E_BAD_ARGUMENT);
+ 
+   if (!(form->field))
+     RETURN(E_NOT_CONNECTED);
+-  
++
+   assert(form->page);
+-  
+-  if (c==FIRST_ACTIVE_MAGIC)
++
++  if (c == FIRST_ACTIVE_MAGIC)
+     {
+       form->current = _nc_First_Active_Field(form);
+-      return E_OK;
++      RETURN(E_OK);
+     }
+-  
+-  assert(form->current && 
+-	 form->current->buf && 
++
++  assert(form->current &&
++	 form->current->buf &&
+ 	 (form->current->form == form)
+-	);
+-  
+-  if ( form->status & _IN_DRIVER )
++    );
++
++  if (form->status & _IN_DRIVER)
+     RETURN(E_BAD_STATE);
+ 
+-  if ( !( form->status & _POSTED ) ) 
++  if (!(form->status & _POSTED))
+     RETURN(E_NOT_POSTED);
+-  
+-  if ((c>=MIN_FORM_COMMAND && c<=MAX_FORM_COMMAND) &&
+-      ((bindings[c-MIN_FORM_COMMAND].keycode & Key_Mask) == c))
+-    BI = &(bindings[c-MIN_FORM_COMMAND]);
+-  
++
++  if ((c >= MIN_FORM_COMMAND && c <= MAX_FORM_COMMAND) &&
++      ((bindings[c - MIN_FORM_COMMAND].keycode & Key_Mask) == c))
++    BI = &(bindings[c - MIN_FORM_COMMAND]);
++
+   if (BI)
+     {
+-      typedef int (*Generic_Method)(int (* const)(FORM *),FORM *);
+-      static const Generic_Method Generic_Methods[] = 
+-	{
+-	  Page_Navigation,         /* overloaded to call field&form hooks */
+-	  Inter_Field_Navigation,  /* overloaded to call field hooks      */
+-	  NULL,                    /* Intra-Field is generic              */
+-	  Vertical_Scrolling,      /* Overloaded to check multi-line      */
+-	  Horizontal_Scrolling,    /* Overloaded to check single-line     */
+-	  Field_Editing,           /* Overloaded to mark modification     */
+-	  NULL,                    /* Edit Mode is generic                */
+-	  NULL,                    /* Field Validation is generic         */
+-	  NULL                     /* Choice Request is generic           */
+-	};
+-      size_t nMethods = (sizeof(Generic_Methods)/sizeof(Generic_Methods[0]));
+-      size_t method   = ((BI->keycode & ID_Mask) >> ID_Shft) & 0xffff;
+-      
+-      if ( (method >= nMethods) || !(BI->cmd) )
++      typedef int (*Generic_Method) (int (*const) (FORM *), FORM *);
++      static const Generic_Method Generic_Methods[] =
++      {
++	Page_Navigation,	/* overloaded to call field&form hooks */
++	Inter_Field_Navigation,	/* overloaded to call field hooks      */
++	NULL,			/* Intra-Field is generic              */
++	Vertical_Scrolling,	/* Overloaded to check multi-line      */
++	Horizontal_Scrolling,	/* Overloaded to check single-line     */
++	Field_Editing,		/* Overloaded to mark modification     */
++	NULL,			/* Edit Mode is generic                */
++	NULL,			/* Field Validation is generic         */
++	NULL			/* Choice Request is generic           */
++      };
++      size_t nMethods = (sizeof(Generic_Methods) / sizeof(Generic_Methods[0]));
++      size_t method = ((BI->keycode & ID_Mask) >> ID_Shft) & 0xffff;
++
++      if ((method >= nMethods) || !(BI->cmd))
+ 	res = E_SYSTEM_ERROR;
+       else
+ 	{
+ 	  Generic_Method fct = Generic_Methods[method];
++
+ 	  if (fct)
+-	    res = fct(BI->cmd,form);
++	    res = fct(BI->cmd, form);
+ 	  else
+-	    res = (BI->cmd)(form);
++	    res = (BI->cmd) (form);
+ 	}
+-    } 
+-  else 
++    }
++  else if (!(c & (~(int)MAX_REGULAR_CHARACTER)))
+     {
+-      if (!(c & (~(int)MAX_REGULAR_CHARACTER)) &&
+-	  isprint((unsigned char)c) &&                      
+-	  Check_Char(form->current->type,c,
++      /*
++       * If we're using 8-bit characters, iscntrl+isprint cover the whole set.
++       * But with multibyte characters, there is a third possibility, i.e.,
++       * parts of characters that build up into printable characters which are
++       * not considered printable.
++       *
++       * FIXME: the wide-character branch should also use Check_Char().
++       */
++#if USE_WIDEC_SUPPORT
++      if (!iscntrl(UChar(c)))
++#else
++      if (isprint(UChar(c)) &&
++	  Check_Char(form->current->type, c,
+ 		     (TypeArgument *)(form->current->arg)))
+-	res = Data_Entry(form,c);
++#endif
++	res = Data_Entry(form, c);
+     }
+   _nc_Refresh_Current_Field(form);
+   RETURN(res);
+ }
+-
++
+ /*----------------------------------------------------------------------------
+   Field-Buffer manipulation routines.
+-  The effects of setting a buffer is tightly coupled to the core of the form
++  The effects of setting a buffer are tightly coupled to the core of the form
+   driver logic. This is especially true in the case of growable fields.
+-  So I don't separate this into an own module. 
++  So I don't separate this into a separate module.
+   --------------------------------------------------------------------------*/
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int set_field_buffer(FIELD *field,
+ |                                         int buffer, char *value)
+-|   
++|
+ |   Description   :  Set the given buffer of the field to the given value.
+ |                    Buffer 0 stores the displayed content of the field.
+ |                    For dynamic fields this may grow the fieldbuffers if
+ |                    the length of the value exceeds the current buffer
+ |                    length. For buffer 0 only printable values are allowed.
+ |                    For static fields, the value needs not to be zero ter-
+-|                    minated. It is copied up to the length of the buffer.   
++|                    minated. It is copied up to the length of the buffer.
+ |
+ |   Return Values :  E_OK            - success
+ |                    E_BAD_ARGUMENT  - invalid argument
+ |                    E_SYSTEM_ERROR  - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_field_buffer
+-(FIELD * field, int buffer, const char * value)
++set_field_buffer(FIELD *field, int buffer, const char *value)
+ {
+-  char *s, *p;
++  FIELD_CELL *p;
+   int res = E_OK;
++  unsigned int i;
+   unsigned int len;
+ 
+-  if ( !field || !value || ((buffer < 0)||(buffer > field->nbuf)) )
++#if USE_WIDEC_SUPPORT
++  FIELD_CELL *widevalue = 0;
++#endif
++
++  T((T_CALLED("set_field_buffer(%p,%d,%s)"), field, buffer, _nc_visbuf(value)));
++
++  if (!field || !value || ((buffer < 0) || (buffer > field->nbuf)))
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  len  = Buffer_Length(field);
++  len = Buffer_Length(field);
+ 
+-  if (buffer==0)
++  if (buffer == 0)
+     {
+-      const char *v;
+-      unsigned int i = 0;
+-
+-      for(v=value; *v && (i<len); v++,i++)
++      for (i = 0; (value[i] != '\0') && (i < len); ++i)
+ 	{
+-	  if (!isprint((unsigned char)*v))
++	  if (iscntrl(UChar(value[i])))
+ 	    RETURN(E_BAD_ARGUMENT);
+ 	}
+     }
+@@ -3783,83 +4161,240 @@
+   if (Growable(field))
+     {
+       /* for a growable field we must assume zero terminated strings, because
+-	 somehow we have to detect the length of what should be copied.
+-      */
++         somehow we have to detect the length of what should be copied.
++       */
+       unsigned int vlen = strlen(value);
++
+       if (vlen > len)
+ 	{
+ 	  if (!Field_Grown(field,
+-			   (int)(1 + (vlen-len)/((field->rows+field->nrow)*field->cols))))
++			   (int)(1 + (vlen - len) / ((field->rows + field->nrow)
++						     * field->cols))))
+ 	    RETURN(E_SYSTEM_ERROR);
+ 
+ 	  /* in this case we also have to check, whether or not the remaining
+ 	     characters in value are also printable for buffer 0. */
+-	  if (buffer==0)
++	  if (buffer == 0)
+ 	    {
+-	      unsigned int i;
+-	  
+-	      for(i=len; i<vlen; i++)
+-		if (!isprint((unsigned char)value[i]))
++	      for (i = len; i < vlen; i++)
++		if (iscntrl(UChar(value[i])))
+ 		  RETURN(E_BAD_ARGUMENT);
+ 	    }
+ 	  len = vlen;
+ 	}
+     }
+-  
+-  p   = Address_Of_Nth_Buffer(field,buffer);
+ 
+-#if HAVE_MEMCCPY
+-  s = (char *) memccpy(p, value, 0, len);
++  p = Address_Of_Nth_Buffer(field, buffer);
++
++#if USE_WIDEC_SUPPORT
++  /*
++   * Use addstr's logic for converting a string to an array of cchar_t's.
++   * There should be a better way, but this handles nonspacing characters
++   * and other special cases that we really do not want to handle here.
++   */
++  wclear(field->working);
++  mvwaddstr(field->working, 0, 0, value);
++
++  if ((widevalue = (FIELD_CELL *)calloc(len, sizeof(FIELD_CELL))) == 0)
++    {
++      RETURN(E_SYSTEM_ERROR);
++    }
++  else
++    {
++      mvwin_wchnstr(field->working, 0, 0, widevalue, len);
++      for (i = 0; i < len; ++i)
++	{
++	  if (CharEq(myZEROS, widevalue[i]))
++	    {
++	      while (i < len)
++		p[i++] = myBLANK;
++	      break;
++	    }
++	  p[i] = widevalue[i];
++	}
++      free(widevalue);
++    }
+ #else
+-  for(s=(char *)value; *s && (s < (value+len)); s++)
+-    p[s-value] = *s;
+-  if (s < (value+len))
++  for (i = 0; i < len; ++i)
+     {
+-      p[s-value] = *s++;
+-      s = p + (s-value);
++      if (value[i] == '\0')
++	{
++	  while (i < len)
++	    p[i++] = myBLANK;
++	  break;
++	}
++      p[i] = value[i];
+     }
+-  else 
+-    s=(char *)0;
+ #endif
+ 
+-  if (s) 
+-    { /* this means, value was null terminated and not greater than the
+-	 buffer. We have to pad with blanks. Please note that due to memccpy
+-	 logic s points after the terminating null. */
+-      s--; /* now we point to the terminator. */
+-      assert(len >= (unsigned int)(s-p));
+-      if (len > (unsigned int)(s-p))
+-	memset(s,C_BLANK,len-(unsigned int)(s-p));
+-    }
+-
+-  if (buffer==0)
++  if (buffer == 0)
+     {
+       int syncres;
+-      if (((syncres=Synchronize_Field( field ))!=E_OK) && 
+-	  (res==E_OK))
++
++      if (((syncres = Synchronize_Field(field)) != E_OK) &&
++	  (res == E_OK))
+ 	res = syncres;
+-      if (((syncres=Synchronize_Linked_Fields(field ))!=E_OK) &&
+-	  (res==E_OK))
++      if (((syncres = Synchronize_Linked_Fields(field)) != E_OK) &&
++	  (res == E_OK))
+ 	res = syncres;
+     }
+   RETURN(res);
+-}		
++}
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  char *field_buffer(const FIELD *field,int buffer)
+-|   
++|
+ |   Description   :  Return the address of the buffer for the field.
+ |
+ |   Return Values :  Pointer to buffer or NULL if arguments were invalid.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(char *)
+-field_buffer (const FIELD * field, int  buffer)
++field_buffer(const FIELD *field, int buffer)
+ {
++  char *result = 0;
++
++  T((T_CALLED("field_buffer(%p,%d)"), field, buffer));
++
+   if (field && (buffer >= 0) && (buffer <= field->nbuf))
+-    return Address_Of_Nth_Buffer(field,buffer);
+-  else
+-    return (char *)0;
++    {
++#if USE_WIDEC_SUPPORT
++      FIELD_CELL *data = Address_Of_Nth_Buffer(field, buffer);
++      unsigned need = 0;
++      int size = Buffer_Length(field);
++      int n;
++
++      /* determine the number of bytes needed to store the expanded string */
++      for (n = 0; n < size; ++n)
++	{
++	  if (!isWidecExt(data[n]))
++	    {
++	      mbstate_t state;
++	      size_t next;
++
++	      init_mb(state);
++	      next = _nc_wcrtomb(0, data[n].chars[0], &state);
++	      if (!isEILSEQ(next))
++		{
++		  if (next != 0)
++		    need += next;
++		}
++	    }
++	}
++
++      /* allocate a place to store the expanded string */
++      if (field->expanded[buffer] != 0)
++	free(field->expanded[buffer]);
++      field->expanded[buffer] = typeMalloc(char, need + 1);
++
++      /* expand the multibyte data */
++      if ((result = field->expanded[buffer]) != 0)
++	{
++	  wclear(field->working);
++	  mvwadd_wchnstr(field->working, 0, 0, data, size);
++	  mvwinnstr(field->working, 0, 0, result, need + 1);
++	}
++#else
++      result = Address_Of_Nth_Buffer(field, buffer);
++#endif
++    }
++  returnPtr(result);
++}
++
++#if USE_WIDEC_SUPPORT
++
++/* FIXME: see lib_get_wch.c */
++#if HAVE_MBTOWC && HAVE_MBLEN
++#define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
++#define count_mbytes(buffer,length,state) mblen(buffer,length)
++#define trans_mbytes(wch,buffer,length,state) \
++	(int) mbtowc(&wch, buffer, length)
++#elif HAVE_MBRTOWC && HAVE_MBRLEN
++#define NEED_STATE
++#define reset_mbytes(state) init_mb(state)
++#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
++#define trans_mbytes(wch,buffer,length,state) \
++	(int) mbrtowc(&wch, buffer, length, &state)
++#else
++make an error
++#endif
++
++/*---------------------------------------------------------------------------
++| Convert a multibyte string to a wide-character string.  The result must be
++| freed by the caller.
+++--------------------------------------------------------------------------*/
++NCURSES_EXPORT(wchar_t *)
++_nc_Widen_String(char *source, int *lengthp)
++{
++  wchar_t *result = 0;
++  wchar_t wch;
++  size_t given = strlen(source);
++  size_t tries;
++  int pass;
++  int status;
++
++#ifdef NEED_STATE
++  mbstate_t state;
++#endif
++
++  for (pass = 0; pass < 2; ++pass)
++    {
++      int need = 0;
++      size_t passed = 0;
++
++      while (passed < given)
++	{
++	  bool found = FALSE;
++
++	  for (tries = 1, status = 0; tries <= (given - passed); ++tries)
++	    {
++	      int save = source[passed + tries];
++
++	      source[passed + tries] = 0;
++	      reset_mbytes(state);
++	      status = trans_mbytes(wch, source + passed, tries, state);
++	      source[passed + tries] = save;
++
++	      if (status > 0)
++		{
++		  found = TRUE;
++		  break;
++		}
++	    }
++	  if (found)
++	    {
++	      if (pass)
++		{
++		  result[need] = wch;
++		}
++	      passed += status;
++	      ++need;
++	    }
++	  else
++	    {
++	      if (pass)
++		{
++		  result[need] = source[passed];
++		}
++	      ++need;
++	      ++passed;
++	    }
++	}
++
++      if (!pass)
++	{
++	  if (!need)
++	    break;
++	  result = typeCalloc(wchar_t, need);
++
++	  *lengthp = need;
++	  if (result == 0)
++	    break;
++	}
++    }
++
++  return result;
+ }
++#endif
+ 
+ /* frm_driver.c ends here */
+Index: form/frm_hook.c
+Prereq:  1.11 
+--- ncurses-5.4-20040208/form/frm_hook.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_hook.c	2004-12-25 22:37:27.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,12 +32,13 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_hook.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_hook.c,v 1.14 2004/12/25 22:37:27 tom Exp $")
+ 
+ /* "Template" macro to generate function to set application specific hook */
+ #define GEN_HOOK_SET_FUNCTION( typ, name ) \
+ NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
+ {\
++   T((T_CALLED("set_" #typ"_"#name"(%p,%p)"), form, func));\
+    (Normalize_Form( form ) -> typ ## name) = func ;\
+    RETURN(E_OK);\
+ }
+@@ -46,95 +47,96 @@
+ #define GEN_HOOK_GET_FUNCTION( typ, name ) \
+ NCURSES_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\
+ {\
+-   return ( Normalize_Form( form ) -> typ ## name );\
++   T((T_CALLED(#typ "_" #name "(%p)"), form));\
++   returnFormHook( Normalize_Form( form ) -> typ ## name );\
+ }
+-
++
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int set_field_init(FORM *form, Form_Hook f)
+-|   
++|
+ |   Description   :  Assigns an application defined initialization function
+ |                    to be called when the form is posted and just after
+ |                    the current field changes.
+ |
+ |   Return Values :  E_OK      - success
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_SET_FUNCTION(field,init)
++GEN_HOOK_SET_FUNCTION(field, init)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  Form_Hook field_init(const FORM *form)
+-|   
++|
+ |   Description   :  Retrieve field initialization routine address.
+ |
+ |   Return Values :  The address or NULL if no hook defined.
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_GET_FUNCTION(field,init)
++GEN_HOOK_GET_FUNCTION(field, init)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int set_field_term(FORM *form, Form_Hook f)
+-|   
++|
+ |   Description   :  Assigns an application defined finalization function
+ |                    to be called when the form is unposted and just before
+ |                    the current field changes.
+ |
+ |   Return Values :  E_OK      - success
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_SET_FUNCTION(field,term)
++GEN_HOOK_SET_FUNCTION(field, term)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  Form_Hook field_term(const FORM *form)
+-|   
++|
+ |   Description   :  Retrieve field finalization routine address.
+ |
+ |   Return Values :  The address or NULL if no hook defined.
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_GET_FUNCTION(field,term)
++GEN_HOOK_GET_FUNCTION(field, term)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int set_form_init(FORM *form, Form_Hook f)
+-|   
++|
+ |   Description   :  Assigns an application defined initialization function
+ |                    to be called when the form is posted and just after
+ |                    a page change.
+ |
+ |   Return Values :  E_OK       - success
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_SET_FUNCTION(form,init)
++GEN_HOOK_SET_FUNCTION(form, init)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  Form_Hook form_init(const FORM *form)
+-|   
++|
+ |   Description   :  Retrieve form initialization routine address.
+ |
+ |   Return Values :  The address or NULL if no hook defined.
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_GET_FUNCTION(form,init)
++GEN_HOOK_GET_FUNCTION(form, init)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  int set_form_term(FORM *form, Form_Hook f)
+-|   
++|
+ |   Description   :  Assigns an application defined finalization function
+ |                    to be called when the form is unposted and just before
+ |                    a page change.
+ |
+ |   Return Values :  E_OK       - success
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_SET_FUNCTION(form,term)
++GEN_HOOK_SET_FUNCTION(form, term)
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
++|   Facility      :  libnform
+ |   Function      :  Form_Hook form_term(const FORM *form)
+-|   
++|
+ |   Description   :  Retrieve form finalization routine address.
+ |
+ |   Return Values :  The address or NULL if no hook defined.
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_GET_FUNCTION(form,term)
++GEN_HOOK_GET_FUNCTION(form, term)
+ 
+ /* frm_hook.c ends here */
+Index: form/frm_opts.c
+Prereq:  1.11 
+--- ncurses-5.4-20040208/form/frm_opts.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_opts.c	2004-12-11 22:06:03.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_opts.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_opts.c,v 1.13 2004/12/11 22:06:03 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -45,14 +45,16 @@
+ |                    E_BAD_ARGUMENT    - invalid options
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_form_opts (FORM * form, Form_Options  opts)
++set_form_opts(FORM *form, Form_Options opts)
+ {
++  T((T_CALLED("set_form_opts(%p,%d)"), form, opts));
++
+   opts &= ALL_FORM_OPTS;
+   if (opts & ~ALL_FORM_OPTS)
+     RETURN(E_BAD_ARGUMENT);
+   else
+     {
+-      Normalize_Form( form )->opts = opts;
++      Normalize_Form(form)->opts = opts;
+       RETURN(E_OK);
+     }
+ }
+@@ -66,9 +68,10 @@
+ |   Return Values :  The option flags.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(Form_Options)
+-form_opts (const FORM * form)
++form_opts(const FORM *form)
+ {
+-  return (Normalize_Form(form)->opts & ALL_FORM_OPTS);
++  T((T_CALLED("form_opts(%p)"), form));
++  returnCode(Normalize_Form(form)->opts & ALL_FORM_OPTS);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -82,14 +85,16 @@
+ |                    E_BAD_ARGUMENT  - invalid options
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-form_opts_on (FORM * form, Form_Options opts)
++form_opts_on(FORM *form, Form_Options opts)
+ {
++  T((T_CALLED("form_opts_on(%p,%d)"), form, opts));
++
+   opts &= ALL_FORM_OPTS;
+   if (opts & ~ALL_FORM_OPTS)
+     RETURN(E_BAD_ARGUMENT);
+   else
+     {
+-      Normalize_Form( form )->opts |= opts;	
++      Normalize_Form(form)->opts |= opts;
+       RETURN(E_OK);
+     }
+ }
+@@ -105,8 +110,10 @@
+ |                    E_BAD_ARGUMENT  - invalid options
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-form_opts_off (FORM * form, Form_Options opts)
++form_opts_off(FORM *form, Form_Options opts)
+ {
++  T((T_CALLED("form_opts_off(%p,%d)"), form, opts));
++
+   opts &= ALL_FORM_OPTS;
+   if (opts & ~ALL_FORM_OPTS)
+     RETURN(E_BAD_ARGUMENT);
+Index: form/frm_page.c
+Prereq:  1.8 
+--- ncurses-5.4-20040208/form/frm_page.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_page.c	2004-12-11 22:08:21.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_page.c,v 1.8 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_page.c,v 1.10 2004/12/11 22:08:21 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -47,35 +47,37 @@
+ |                    E_SYSTEM_ERROR    - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_form_page (FORM * form, int page)
++set_form_page(FORM *form, int page)
+ {
+   int err = E_OK;
+ 
+-  if ( !form || (page<0) || (page>=form->maxpage) )
++  T((T_CALLED("set_form_page(%p,%d)"), form, page));
++
++  if (!form || (page < 0) || (page >= form->maxpage))
+     RETURN(E_BAD_ARGUMENT);
+ 
+   if (!(form->status & _POSTED))
+     {
+       form->curpage = page;
+       form->current = _nc_First_Active_Field(form);
+-  }
++    }
+   else
+     {
+-      if (form->status & _IN_DRIVER) 
++      if (form->status & _IN_DRIVER)
+ 	err = E_BAD_STATE;
+       else
+ 	{
+ 	  if (form->curpage != page)
+ 	    {
+-	      if (!_nc_Internal_Validation(form)) 
++	      if (!_nc_Internal_Validation(form))
+ 		err = E_INVALID_FIELD;
+ 	      else
+ 		{
+-		  Call_Hook(form,fieldterm);
+-		  Call_Hook(form,formterm);
+-		  err = _nc_Set_Form_Page(form,page,(FIELD *)0);
+-		  Call_Hook(form,forminit);
+-		  Call_Hook(form,fieldinit);
++		  Call_Hook(form, fieldterm);
++		  Call_Hook(form, formterm);
++		  err = _nc_Set_Form_Page(form, page, (FIELD *)0);
++		  Call_Hook(form, forminit);
++		  Call_Hook(form, fieldinit);
+ 		  _nc_Refresh_Current_Field(form);
+ 		}
+ 	    }
+@@ -94,9 +96,11 @@
+ |                    -1    : invalid form pointer
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-form_page (const FORM * form)
++form_page(const FORM *form)
+ {
+-  return Normalize_Form(form)->curpage;
++  T((T_CALLED("form_page(%p)"), form));
++
++  returnCode(Normalize_Form(form)->curpage);
+ }
+ 
+ /* frm_page.c ends here */
+Index: form/frm_post.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/frm_post.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_post.c	2004-12-11 22:19:06.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_post.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_post.c,v 1.9 2004/12/11 22:19:06 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -48,37 +48,39 @@
+ |                    E_SYSTEM_ERROR    - system error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-post_form (FORM * form)
++post_form(FORM *form)
+ {
+   WINDOW *formwin;
+   int err;
+   int page;
+ 
++  T((T_CALLED("post_form(%p)"), form));
++
+   if (!form)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if (form->status & _POSTED)   
++  if (form->status & _POSTED)
+     RETURN(E_POSTED);
+ 
+   if (!(form->field))
+     RETURN(E_NOT_CONNECTED);
+-  
++
+   formwin = Get_Form_Window(form);
+-  if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin))) 
++  if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin)))
+     RETURN(E_NO_ROOM);
+ 
+   /* reset form->curpage to an invald value. This forces Set_Form_Page
+      to do the page initialization which is required by post_form.
+-  */
++   */
+   page = form->curpage;
+   form->curpage = -1;
+-  if ((err = _nc_Set_Form_Page(form,page,form->current))!=E_OK)
++  if ((err = _nc_Set_Form_Page(form, page, form->current)) != E_OK)
+     RETURN(err);
+ 
+   form->status |= _POSTED;
+ 
+-  Call_Hook(form,forminit);
+-  Call_Hook(form,fieldinit);
++  Call_Hook(form, forminit);
++  Call_Hook(form, fieldinit);
+ 
+   _nc_Refresh_Current_Field(form);
+   RETURN(E_OK);
+@@ -96,19 +98,21 @@
+ |                    E_BAD_STATE     - called from a hook routine
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-unpost_form (FORM * form)
++unpost_form(FORM *form)
+ {
++  T((T_CALLED("unpost_form(%p)"), form));
++
+   if (!form)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if (!(form->status & _POSTED)) 
++  if (!(form->status & _POSTED))
+     RETURN(E_NOT_POSTED);
+ 
+-  if (form->status & _IN_DRIVER) 
++  if (form->status & _IN_DRIVER)
+     RETURN(E_BAD_STATE);
+ 
+-  Call_Hook(form,fieldterm);
+-  Call_Hook(form,formterm);
++  Call_Hook(form, fieldterm);
++  Call_Hook(form, formterm);
+ 
+   werase(Get_Form_Window(form));
+   delwin(form->w);
+Index: form/frm_req_name.c
+Prereq:  1.10 
+--- ncurses-5.4-20040208/form/frm_req_name.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_req_name.c	2004-12-11 23:49:32.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,71 +37,73 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_req_name.c,v 1.10 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_req_name.c,v 1.14 2004/12/11 23:49:32 tom Exp $")
+ 
+-static const char *request_names[ MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1 ] = {
+-  "NEXT_PAGE"	 ,
+-  "PREV_PAGE"	 ,
+-  "FIRST_PAGE"	 ,
+-  "LAST_PAGE"	 ,
+-
+-  "NEXT_FIELD"	 ,
+-  "PREV_FIELD"	 ,
+-  "FIRST_FIELD"	 ,
+-  "LAST_FIELD"	 ,
+-  "SNEXT_FIELD"	 ,
+-  "SPREV_FIELD"	 ,
+-  "SFIRST_FIELD" ,
+-  "SLAST_FIELD"	 ,
+-  "LEFT_FIELD"	 ,
+-  "RIGHT_FIELD"	 ,
+-  "UP_FIELD"	 ,
+-  "DOWN_FIELD"	 ,
+-
+-  "NEXT_CHAR"	 ,
+-  "PREV_CHAR"	 ,
+-  "NEXT_LINE"	 ,
+-  "PREV_LINE"	 ,
+-  "NEXT_WORD"	 ,
+-  "PREV_WORD"	 ,
+-  "BEG_FIELD"	 ,
+-  "END_FIELD"	 ,
+-  "BEG_LINE"	 ,
+-  "END_LINE"	 ,
+-  "LEFT_CHAR"	 ,
+-  "RIGHT_CHAR"	 ,
+-  "UP_CHAR"	 ,
+-  "DOWN_CHAR"	 ,
+-
+-  "NEW_LINE"	 ,
+-  "INS_CHAR"	 ,
+-  "INS_LINE"	 ,
+-  "DEL_CHAR"	 ,
+-  "DEL_PREV"	 ,
+-  "DEL_LINE"	 ,
+-  "DEL_WORD"	 ,
+-  "CLR_EOL"	 ,
+-  "CLR_EOF"	 ,
+-  "CLR_FIELD"	 ,
+-  "OVL_MODE"	 ,
+-  "INS_MODE"	 ,
+-  "SCR_FLINE"	 ,
+-  "SCR_BLINE"	 ,
+-  "SCR_FPAGE"	 ,
+-  "SCR_BPAGE"	 ,
+-  "SCR_FHPAGE"   ,
+-  "SCR_BHPAGE"   ,
+-  "SCR_FCHAR"    ,
+-  "SCR_BCHAR"    ,
+-  "SCR_HFLINE"   ,
+-  "SCR_HBLINE"   ,
+-  "SCR_HFHALF"   ,
+-  "SCR_HBHALF"   ,
+-
+-  "VALIDATION"	 ,
+-  "NEXT_CHOICE"	 ,
+-  "PREV_CHOICE"	 
++static const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
++{
++  "NEXT_PAGE",
++  "PREV_PAGE",
++  "FIRST_PAGE",
++  "LAST_PAGE",
++
++  "NEXT_FIELD",
++  "PREV_FIELD",
++  "FIRST_FIELD",
++  "LAST_FIELD",
++  "SNEXT_FIELD",
++  "SPREV_FIELD",
++  "SFIRST_FIELD",
++  "SLAST_FIELD",
++  "LEFT_FIELD",
++  "RIGHT_FIELD",
++  "UP_FIELD",
++  "DOWN_FIELD",
++
++  "NEXT_CHAR",
++  "PREV_CHAR",
++  "NEXT_LINE",
++  "PREV_LINE",
++  "NEXT_WORD",
++  "PREV_WORD",
++  "BEG_FIELD",
++  "END_FIELD",
++  "BEG_LINE",
++  "END_LINE",
++  "LEFT_CHAR",
++  "RIGHT_CHAR",
++  "UP_CHAR",
++  "DOWN_CHAR",
++
++  "NEW_LINE",
++  "INS_CHAR",
++  "INS_LINE",
++  "DEL_CHAR",
++  "DEL_PREV",
++  "DEL_LINE",
++  "DEL_WORD",
++  "CLR_EOL",
++  "CLR_EOF",
++  "CLR_FIELD",
++  "OVL_MODE",
++  "INS_MODE",
++  "SCR_FLINE",
++  "SCR_BLINE",
++  "SCR_FPAGE",
++  "SCR_BPAGE",
++  "SCR_FHPAGE",
++  "SCR_BHPAGE",
++  "SCR_FCHAR",
++  "SCR_BCHAR",
++  "SCR_HFLINE",
++  "SCR_HBLINE",
++  "SCR_HFHALF",
++  "SCR_HBHALF",
++
++  "VALIDATION",
++  "NEXT_CHOICE",
++  "PREV_CHOICE"
+ };
++
+ #define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
+ 
+ /*---------------------------------------------------------------------------
+@@ -114,18 +116,19 @@
+ |                    NULL                 - on invalid request code
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(const char *)
+-form_request_name ( int request )
++form_request_name(int request)
+ {
+-  if ( (request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND) )
++  T((T_CALLED("form_request_name(%d)"), request));
++
++  if ((request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND))
+     {
+-      SET_ERROR (E_BAD_ARGUMENT);
+-      return (const char *)0;
++      SET_ERROR(E_BAD_ARGUMENT);
++      returnCPtr((const char *)0);
+     }
+   else
+-    return request_names[ request - MIN_FORM_COMMAND ];
++    returnCPtr(request_names[request - MIN_FORM_COMMAND]);
+ }
+ 
+-
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+ |   Function      :  int form_request_by_name (const char *str);
+@@ -136,28 +139,30 @@
+ |                    E_NO_MATCH       - request not found
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-form_request_by_name ( const char *str )
+-{ 
++form_request_by_name(const char *str)
++{
+   /* because the table is so small, it doesn't really hurt
+      to run sequentially through it.
+-  */
++   */
+   unsigned int i = 0;
+   char buf[16];
+-  
++
++  T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
++
+   if (str)
+     {
+-      strncpy(buf,str,sizeof(buf));
+-      while( (i<sizeof(buf)) && (buf[i] != '\0') )
++      strncpy(buf, str, sizeof(buf));
++      while ((i < sizeof(buf)) && (buf[i] != '\0'))
+ 	{
+ 	  buf[i] = toupper(buf[i]);
+ 	  i++;
+ 	}
+-      
+-      for (i=0; i < A_SIZE; i++)
++
++      for (i = 0; i < A_SIZE; i++)
+ 	{
+-	  if (strncmp(request_names[i],buf,sizeof(buf))==0)
+-	    return MIN_FORM_COMMAND + i;
+-	} 
++	  if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
++	    returnCode(MIN_FORM_COMMAND + i);
++	}
+     }
+   RETURN(E_NO_MATCH);
+ }
+Index: form/frm_scale.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/frm_scale.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_scale.c	2004-12-11 22:12:34.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_scale.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_scale.c,v 1.9 2004/12/11 22:12:34 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -45,19 +45,21 @@
+ |                    E_NOT_CONNECTED   - no fields connected to form
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-scale_form (const FORM * form, int * rows, int * cols)
++scale_form(const FORM *form, int *rows, int *cols)
+ {
+-  if ( !form )
++  T((T_CALLED("scale_form(%p,%p,%p)"), form, rows, cols));
++
++  if (!form)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if ( !(form->field) )
++  if (!(form->field))
+     RETURN(E_NOT_CONNECTED);
+-  
+-  if (rows) 
++
++  if (rows)
+     *rows = form->rows;
+-  if (cols) 
++  if (cols)
+     *cols = form->cols;
+-  
++
+   RETURN(E_OK);
+ }
+ 
+Index: form/frm_sub.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/form/frm_sub.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_sub.c	2004-12-11 22:13:39.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_sub.c,v 1.7 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_sub.c,v 1.9 2004/12/11 22:13:39 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -44,14 +44,16 @@
+ |                    E_POSTED   - form is posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_form_sub (FORM * form, WINDOW * win)
++set_form_sub(FORM *form, WINDOW *win)
+ {
+-  if (form && (form->status & _POSTED))	
++  T((T_CALLED("set_form_sub(%p,%p)"), form, win));
++
++  if (form && (form->status & _POSTED))
+     RETURN(E_POSTED);
+ 
+-  Normalize_Form( form )->sub = win;
++  Normalize_Form(form)->sub = win;
+   RETURN(E_OK);
+-}	
++}
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -62,10 +64,14 @@
+ |   Return Values :  The pointer to the Subwindow.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(WINDOW *)
+-form_sub (const FORM * form)
++form_sub(const FORM *form)
+ {
+-  const FORM* f = Normalize_Form( form );
+-  return Get_Form_Window(f);
++  const FORM *f;
++
++  T((T_CALLED("form_sub(%p)"), form));
++
++  f = Normalize_Form(form);
++  returnWin(Get_Form_Window(f));
+ }
+ 
+ /* frm_sub.c ends here */
+Index: form/frm_user.c
+Prereq:  1.11 
+--- ncurses-5.4-20040208/form/frm_user.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_user.c	2004-12-25 22:37:56.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_user.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_user.c,v 1.14 2004/12/25 22:37:56 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -44,8 +44,10 @@
+ |   Return Values :  E_OK         - on success
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_form_userptr (FORM * form, void *usrptr)
++set_form_userptr(FORM *form, void *usrptr)
+ {
++  T((T_CALLED("set_form_userptr(%p,%p)"), form, usrptr));
++
+   Normalize_Form(form)->usrptr = usrptr;
+   RETURN(E_OK);
+ }
+@@ -61,9 +63,10 @@
+ |                    NULL is returned
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void *)
+-form_userptr (const FORM * form)
++form_userptr(const FORM *form)
+ {
+-  return Normalize_Form(form)->usrptr;
++  T((T_CALLED("form_userptr(%p)"), form));
++  returnVoidPtr(Normalize_Form(form)->usrptr);
+ }
+ 
+ /* frm_user.c ends here */
+Index: form/frm_win.c
+Prereq:  1.11 
+--- ncurses-5.4-20040208/form/frm_win.c	2003-10-25 15:17:08.000000000 +0000
++++ ncurses-5.4-20050319/form/frm_win.c	2004-12-11 22:15:27.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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 "form.priv.h"
+ 
+-MODULE_ID("$Id: frm_win.c,v 1.11 2003/10/25 15:17:08 tom Exp $")
++MODULE_ID("$Id: frm_win.c,v 1.13 2004/12/11 22:15:27 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -44,14 +44,16 @@
+ |                    E_POSTED   - form is posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_form_win (FORM * form, WINDOW * win)
++set_form_win(FORM *form, WINDOW *win)
+ {
+-  if (form && (form->status & _POSTED))	
++  T((T_CALLED("set_form_win(%p,%p)"), form, win));
++
++  if (form && (form->status & _POSTED))
+     RETURN(E_POSTED);
+ 
+-  Normalize_Form( form )->win = win;
++  Normalize_Form(form)->win = win;
+   RETURN(E_OK);
+-}	
++}
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -62,11 +64,14 @@
+ |   Return Values :  The pointer to the Window or stdscr if there is none.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(WINDOW *)
+-form_win (const FORM * form)
++form_win(const FORM *form)
+ {
+-  const FORM* f = Normalize_Form( form );
+-  return (f->win ? f->win : stdscr);
++  const FORM *f;
++
++  T((T_CALLED("form_win(%p)"), form));
++
++  f = Normalize_Form(form);
++  returnWin(f->win ? f->win : stdscr);
+ }
+ 
+ /* frm_win.c ends here */
+-
+Index: form/fty_alnum.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/form/fty_alnum.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/form/fty_alnum.c	2005-03-05 21:41:55.000000000 +0000
+@@ -1,4 +1,3 @@
+-
+ /*
+  * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
+  * You may freely copy it for use as a template for your own field types.
+@@ -13,42 +12,46 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fty_alnum.c,v 1.12 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: fty_alnum.c,v 1.16 2005/03/05 21:41:55 tom Exp $")
+ 
+-typedef struct {
+-  int width;
+-} alnumARG;
++typedef struct
++  {
++    int width;
++  }
++thisARG;
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static void *Make_AlphaNumeric_Type(va_list *ap)
+-|   
++|   Facility      :  libnform
++|   Function      :  static void *Make_This_Type(va_list *ap)
++|
+ |   Description   :  Allocate structure for alphanumeric type argument.
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error
+ +--------------------------------------------------------------------------*/
+-static void *Make_AlphaNumeric_Type(va_list * ap)
++static void *
++Make_This_Type(va_list *ap)
+ {
+-  alnumARG *argp = (alnumARG *)malloc(sizeof(alnumARG));
++  thisARG *argp = (thisARG *) malloc(sizeof(thisARG));
+ 
+   if (argp)
+-    argp->width = va_arg(*ap,int);
++    argp->width = va_arg(*ap, int);
+ 
+   return ((void *)argp);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static void *Copy_AlphaNumericType(const void *argp)
+-|   
+-|   Description   :  Copy structure for alphanumeric type argument.  
++|   Facility      :  libnform
++|   Function      :  static void *Copy_ThisType(const void *argp)
++|
++|   Description   :  Copy structure for alphanumeric type argument.
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error.
+ +--------------------------------------------------------------------------*/
+-static void *Copy_AlphaNumeric_Type(const void *argp)
++static void *
++Copy_This_Type(const void *argp)
+ {
+-  const alnumARG *ap = (const alnumARG *)argp;
+-  alnumARG *result = (alnumARG *)malloc(sizeof(alnumARG));
++  const thisARG *ap = (const thisARG *)argp;
++  thisARG *result = (thisARG *) malloc(sizeof(thisARG));
+ 
+   if (result)
+     *result = *ap;
+@@ -57,81 +60,78 @@
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static void Free_AlphaNumeric_Type(void *argp)
+-|   
++|   Facility      :  libnform
++|   Function      :  static void Free_This_Type(void *argp)
++|
+ |   Description   :  Free structure for alphanumeric type argument.
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Free_AlphaNumeric_Type(void * argp)
++static void
++Free_This_Type(void *argp)
+ {
+-  if (argp) 
++  if (argp)
+     free(argp);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static bool Check_AlphaNumeric_Field(
+-|                                      FIELD *field,
++|   Facility      :  libnform
++|   Function      :  static bool Check_This_Character(
++|                                      int c,
+ |                                      const void *argp)
+-|   
+-|   Description   :  Validate buffer content to be a valid alphanumeric value
+ |
+-|   Return Values :  TRUE  - field is valid
+-|                    FALSE - field is invalid
++|   Description   :  Check a character for the alphanumeric type.
++|
++|   Return Values :  TRUE  - character is valid
++|                    FALSE - character is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_AlphaNumeric_Field(FIELD * field, const void * argp)
++static bool
++Check_This_Character(int c, const void *argp GCC_UNUSED)
+ {
+-  int width = ((const alnumARG *)argp)->width;
+-  unsigned char *bp  = (unsigned char *)field_buffer(field,0);
+-  int  l = -1;
+-  unsigned char *s;
+-
+-  while(*bp && *bp==' ') 
+-    bp++;
+-  if (*bp)
+-    {
+-      s = bp;
+-      while(*bp && isalnum(*bp)) 
+-	bp++;
+-      l = (int)(bp-s);
+-      while(*bp && *bp==' ') 
+-	bp++;
+-    }
+-  return ((*bp || (l < width)) ? FALSE : TRUE);
++#if USE_WIDEC_SUPPORT
++  if (iswalnum(c))
++    return TRUE;
++#endif
++  return (isalnum(UChar(c)) ? TRUE : FALSE);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static bool Check_AlphaNumeric_Character(
+-|                                      int c, 
+-|                                      const void *argp )
+-|   
+-|   Description   :  Check a character for the alphanumeric type.
++|   Facility      :  libnform
++|   Function      :  static bool Check_This_Field(
++|                                      FIELD *field,
++|                                      const void *argp)
+ |
+-|   Return Values :  TRUE  - character is valid
+-|                    FALSE - character is invalid
++|   Description   :  Validate buffer content to be a valid alphanumeric value
++|
++|   Return Values :  TRUE  - field is valid
++|                    FALSE - field is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_AlphaNumeric_Character(int c, const void * argp GCC_UNUSED)
++static bool
++Check_This_Field(FIELD *field, const void *argp)
+ {
+-  return (isalnum(c) ? TRUE : FALSE);
++  int width = ((const thisARG *)argp)->width;
++  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
++  bool result = (width < 0);
++
++  Check_CTYPE_Field(result, bp, width, Check_This_Character);
++  return (result);
+ }
+ 
+-static FIELDTYPE typeALNUM = {
++static FIELDTYPE typeTHIS =
++{
+   _HAS_ARGS | _RESIDENT,
+-  1,                           /* this is mutable, so we can't be const */
++  1,				/* this is mutable, so we can't be const */
+   (FIELDTYPE *)0,
+   (FIELDTYPE *)0,
+-  Make_AlphaNumeric_Type,
+-  Copy_AlphaNumeric_Type,
+-  Free_AlphaNumeric_Type,
+-  Check_AlphaNumeric_Field,
+-  Check_AlphaNumeric_Character,
++  Make_This_Type,
++  Copy_This_Type,
++  Free_This_Type,
++  Check_This_Field,
++  Check_This_Character,
+   NULL,
+   NULL
+ };
+ 
+-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeALNUM;
++NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeTHIS;
+ 
+ /* fty_alnum.c ends here */
+Index: form/fty_alpha.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/form/fty_alpha.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/form/fty_alpha.c	2005-03-05 21:42:00.000000000 +0000
+@@ -1,4 +1,3 @@
+-
+ /*
+  * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
+  * You may freely copy it for use as a template for your own field types.
+@@ -13,126 +12,126 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fty_alpha.c,v 1.12 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: fty_alpha.c,v 1.18 2005/03/05 21:42:00 tom Exp $")
+ 
+-typedef struct {
+-  int width;
+-} alphaARG;
++typedef struct
++  {
++    int width;
++  }
++thisARG;
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static void *Make_Alpha_Type(va_list *ap)
+-|   
++|   Facility      :  libnform
++|   Function      :  static void *Make_This_Type(va_list *ap)
++|
+ |   Description   :  Allocate structure for alpha type argument.
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error
+ +--------------------------------------------------------------------------*/
+-static void *Make_Alpha_Type(va_list * ap)
++static void *
++Make_This_Type(va_list *ap)
+ {
+-  alphaARG *argp = (alphaARG *)malloc(sizeof(alphaARG));
++  thisARG *argp = (thisARG *) malloc(sizeof(thisARG));
++
+   if (argp)
+-    {
+-      argp->width = va_arg(*ap,int);
+-    }
++    argp->width = va_arg(*ap, int);
++
+   return ((void *)argp);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static void *Copy_Alpha_Type(const void * argp)
+-|   
+-|   Description   :  Copy structure for alpha type argument.  
++|   Facility      :  libnform
++|   Function      :  static void *Copy_This_Type(const void * argp)
++|
++|   Description   :  Copy structure for alpha type argument.
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error.
+ +--------------------------------------------------------------------------*/
+-static void *Copy_Alpha_Type(const void * argp)
++static void *
++Copy_This_Type(const void *argp)
+ {
+-  const alphaARG *ap = (const alphaARG *)argp;
+-  alphaARG *result = (alphaARG *)malloc(sizeof(alphaARG));
+-  
++  const thisARG *ap = (const thisARG *)argp;
++  thisARG *result = (thisARG *) malloc(sizeof(thisARG));
++
+   if (result)
+-    {
+-      *result = *ap;
+-    }
++    *result = *ap;
++
+   return ((void *)result);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static void Free_Alpha_Type( void * argp )
+-|   
++|   Facility      :  libnform
++|   Function      :  static void Free_This_Type(void *argp)
++|
+ |   Description   :  Free structure for alpha type argument.
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Free_Alpha_Type(void * argp)
++static void
++Free_This_Type(void *argp)
+ {
+-  if (argp) 
++  if (argp)
+     free(argp);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static bool Check_Alpha_Field(
+-|                                      FIELD * field,
+-|                                      const void * argp)
+-|   
+-|   Description   :  Validate buffer content to be a valid alpha value
++|   Facility      :  libnform
++|   Function      :  static bool Check_This_Character(
++|                                      int c,
++|                                      const void *argp)
+ |
+-|   Return Values :  TRUE  - field is valid
+-|                    FALSE - field is invalid
++|   Description   :  Check a character for the alpha type.
++|
++|   Return Values :  TRUE  - character is valid
++|                    FALSE - character is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_Alpha_Field(FIELD * field, const void * argp)
++static bool
++Check_This_Character(int c, const void *argp GCC_UNUSED)
+ {
+-  int width = ((const alphaARG *)argp)->width;
+-  unsigned char *bp  = (unsigned char *)field_buffer(field,0);
+-  int  l = -1;
+-  unsigned char *s;
+-
+-  while(*bp && *bp==' ') 
+-    bp++;
+-  if (*bp)
+-    {
+-      s = bp;
+-      while(*bp && isalpha(*bp)) 
+-	bp++;
+-      l = (int)(bp-s);
+-      while(*bp && *bp==' ') 
+-	bp++;
+-    }
+-  return ((*bp || (l < width)) ? FALSE : TRUE);
++#if USE_WIDEC_SUPPORT
++  if (iswalpha(c))
++    return TRUE;
++#endif
++  return (isalpha(UChar(c)) ? TRUE : FALSE);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static bool Check_Alpha_Character(
+-|                                      int c,
+-|                                      const void * argp)
+-|   
+-|   Description   :  Check a character for the alpha type.
++|   Facility      :  libnform
++|   Function      :  static bool Check_This_Field(
++|                                      FIELD *field,
++|                                      const void *argp)
+ |
+-|   Return Values :  TRUE  - character is valid
+-|                    FALSE - character is invalid
++|   Description   :  Validate buffer content to be a valid alpha value
++|
++|   Return Values :  TRUE  - field is valid
++|                    FALSE - field is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_Alpha_Character(int c, const void * argp GCC_UNUSED)
++static bool
++Check_This_Field(FIELD *field, const void *argp)
+ {
+-  return (isalpha(c) ? TRUE : FALSE);
++  int width = ((const thisARG *)argp)->width;
++  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
++  bool result = (width < 0);
++
++  Check_CTYPE_Field(result, bp, width, Check_This_Character);
++  return (result);
+ }
+ 
+-static FIELDTYPE typeALPHA = {
++static FIELDTYPE typeTHIS =
++{
+   _HAS_ARGS | _RESIDENT,
+-  1,                           /* this is mutable, so we can't be const */
++  1,				/* this is mutable, so we can't be const */
+   (FIELDTYPE *)0,
+   (FIELDTYPE *)0,
+-  Make_Alpha_Type,
+-  Copy_Alpha_Type,
+-  Free_Alpha_Type,
+-  Check_Alpha_Field,
+-  Check_Alpha_Character,
++  Make_This_Type,
++  Copy_This_Type,
++  Free_This_Type,
++  Check_This_Field,
++  Check_This_Character,
+   NULL,
+   NULL
+ };
+ 
+-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeALPHA;
++NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeTHIS;
+ 
+ /* fty_alpha.c ends here */
+Index: form/fty_enum.c
+Prereq:  1.18 
+--- ncurses-5.4-20040208/form/fty_enum.c	2003-11-08 20:25:29.000000000 +0000
++++ ncurses-5.4-20050319/form/fty_enum.c	2004-05-29 19:05:20.000000000 +0000
+@@ -13,14 +13,16 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fty_enum.c,v 1.18 2003/11/08 20:25:29 tom Exp $")
++MODULE_ID("$Id: fty_enum.c,v 1.19 2004/05/29 19:05:20 tom Exp $")
+ 
+-typedef struct {
+-  char **kwds;
+-  int  count;
+-  bool checkcase;
+-  bool checkunique;
+-} enumARG;
++typedef struct
++  {
++    char **kwds;
++    int count;
++    bool checkcase;
++    bool checkunique;
++  }
++enumARG;
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -30,7 +32,8 @@
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error
+ +--------------------------------------------------------------------------*/
+-static void *Make_Enum_Type(va_list * ap)
++static void *
++Make_Enum_Type(va_list *ap)
+ {
+   enumARG *argp = (enumARG *)malloc(sizeof(enumARG));
+ 
+@@ -40,14 +43,16 @@
+       char **kp = (char **)0;
+       int ccase, cunique;
+ 
+-      argp->kwds        = va_arg(*ap,char **);
+-      ccase             = va_arg(*ap,int);
+-      cunique           = va_arg(*ap,int);
+-      argp->checkcase   = ccase   ? TRUE : FALSE;
++      argp->kwds = va_arg(*ap, char **);
++      ccase = va_arg(*ap, int);
++      cunique = va_arg(*ap, int);
++
++      argp->checkcase = ccase ? TRUE : FALSE;
+       argp->checkunique = cunique ? TRUE : FALSE;
+ 
+       kp = argp->kwds;
+-      while( kp && (*kp++) ) cnt++;
++      while (kp && (*kp++))
++	cnt++;
+       argp->count = cnt;
+     }
+   return (void *)argp;
+@@ -61,7 +66,8 @@
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error.
+ +--------------------------------------------------------------------------*/
+-static void *Copy_Enum_Type(const void * argp)
++static void *
++Copy_Enum_Type(const void *argp)
+ {
+   enumARG *result = (enumARG *)0;
+ 
+@@ -70,6 +76,7 @@
+       const enumARG *ap = (const enumARG *)argp;
+ 
+       result = (enumARG *)malloc(sizeof(enumARG));
++
+       if (result)
+ 	*result = *ap;
+     }
+@@ -84,9 +91,10 @@
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Free_Enum_Type(void * argp)
++static void
++Free_Enum_Type(void *argp)
+ {
+-  if (argp) 
++  if (argp)
+     free(argp);
+ }
+ 
+@@ -108,30 +116,33 @@
+ |                    PARTIAL   - buffer matches partially
+ |                    EXACT     - buffer matches exactly
+ +--------------------------------------------------------------------------*/
+-static int Compare(const unsigned char *s, const unsigned char *buf, 
+-		   bool ccase)
++static int
++Compare(const unsigned char *s, const unsigned char *buf,
++	bool ccase)
+ {
+-  SKIP_SPACE(buf); /* Skip leading spaces in both texts */
++  SKIP_SPACE(buf);		/* Skip leading spaces in both texts */
+   SKIP_SPACE(s);
+ 
+-  if (*buf=='\0')
++  if (*buf == '\0')
+     {
+-      return (((*s)!='\0') ? NOMATCH : EXACT);
+-    } 
+-  else 
++      return (((*s) != '\0') ? NOMATCH : EXACT);
++    }
++  else
+     {
+       if (ccase)
+ 	{
+-	  while(*s++ == *buf)
++	  while (*s++ == *buf)
+ 	    {
+-	      if (*buf++=='\0') return EXACT;
+-	    } 
+-	} 
+-      else 
++	      if (*buf++ == '\0')
++		return EXACT;
++	    }
++	}
++      else
+ 	{
+-	  while(toupper(*s++)==toupper(*buf))
++	  while (toupper(*s++) == toupper(*buf))
+ 	    {
+-	      if (*buf++=='\0') return EXACT;
++	      if (*buf++ == '\0')
++		return EXACT;
+ 	    }
+ 	}
+     }
+@@ -139,12 +150,12 @@
+      matches with s. So if only blanks are following, we have a partial
+      match otherwise there is no match */
+   SKIP_SPACE(buf);
+-  if (*buf) 
++  if (*buf)
+     return NOMATCH;
+ 
+   /* If it happens that the reference buffer is at its end, the partial
+      match is actually an exact match. */
+-  return ((s[-1]!='\0') ? PARTIAL : EXACT);
++  return ((s[-1] != '\0') ? PARTIAL : EXACT);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -158,27 +169,28 @@
+ |   Return Values :  TRUE  - field is valid
+ |                    FALSE - field is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_Enum_Field(FIELD * field, const void  * argp)
++static bool
++Check_Enum_Field(FIELD *field, const void *argp)
+ {
+-  char **kwds       = ((const enumARG *)argp)->kwds;
+-  bool ccase        = ((const enumARG *)argp)->checkcase;
+-  bool unique       = ((const enumARG *)argp)->checkunique;
+-  unsigned char *bp = (unsigned char *)field_buffer(field,0);
++  char **kwds = ((const enumARG *)argp)->kwds;
++  bool ccase = ((const enumARG *)argp)->checkcase;
++  bool unique = ((const enumARG *)argp)->checkunique;
++  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
+   char *s, *t, *p;
+   int res;
+-  
+-  while( kwds && (s=(*kwds++)) )
++
++  while (kwds && (s = (*kwds++)))
+     {
+-      if ((res=Compare((unsigned char *)s,bp,ccase))!=NOMATCH)
++      if ((res = Compare((unsigned char *)s, bp, ccase)) != NOMATCH)
+ 	{
+-	  p=t=s; /* t is at least a partial match */
+-	  if ((unique && res!=EXACT)) 
++	  p = t = s;		/* t is at least a partial match */
++	  if ((unique && res != EXACT))
+ 	    {
+-	      while( kwds && (p = *kwds++) )
++	      while (kwds && (p = *kwds++))
+ 		{
+-		  if ((res=Compare((unsigned char *)p,bp,ccase))!=NOMATCH)
++		  if ((res = Compare((unsigned char *)p, bp, ccase)) != NOMATCH)
+ 		    {
+-		      if (res==EXACT)
++		      if (res == EXACT)
+ 			{
+ 			  t = p;
+ 			  break;
+@@ -187,10 +199,10 @@
+ 			t = (char *)0;
+ 		    }
+ 		}
+-	    }	  
++	    }
+ 	  if (t)
+ 	    {
+-	      set_field_buffer(field,0,t);
++	      set_field_buffer(field, 0, t);
+ 	      return TRUE;
+ 	    }
+ 	  if (!p)
+@@ -200,7 +212,8 @@
+   return FALSE;
+ }
+ 
+-static const char *dummy[] = { (char *)0 };
++static const char *dummy[] =
++{(char *)0};
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -212,28 +225,30 @@
+ |   Return Values :  TRUE  - next value found and loaded
+ |                    FALSE - no next value loaded
+ +--------------------------------------------------------------------------*/
+-static bool Next_Enum(FIELD * field, const void * argp)
++static bool
++Next_Enum(FIELD *field, const void *argp)
+ {
+   const enumARG *args = (const enumARG *)argp;
+-  char **kwds       = args->kwds;
+-  bool ccase        = args->checkcase;
+-  int cnt           = args->count;
+-  unsigned char *bp = (unsigned char *)field_buffer(field,0);
+-
+-  if (kwds) {
+-    while(cnt--)
+-      {
+-	if (Compare((unsigned char *)(*kwds++),bp,ccase)==EXACT) 
+-	  break;
+-      }
+-    if (cnt<=0)
+-      kwds = args->kwds;
+-    if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
+-      {
+-	set_field_buffer(field,0,*kwds);
+-	return TRUE;
+-      }
+-  }
++  char **kwds = args->kwds;
++  bool ccase = args->checkcase;
++  int cnt = args->count;
++  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
++
++  if (kwds)
++    {
++      while (cnt--)
++	{
++	  if (Compare((unsigned char *)(*kwds++), bp, ccase) == EXACT)
++	    break;
++	}
++      if (cnt <= 0)
++	kwds = args->kwds;
++      if ((cnt >= 0) || (Compare((const unsigned char *)dummy, bp, ccase) == EXACT))
++	{
++	  set_field_buffer(field, 0, *kwds);
++	  return TRUE;
++	}
++    }
+   return FALSE;
+ }
+ 
+@@ -248,37 +263,39 @@
+ |   Return Values :  TRUE  - previous value found and loaded
+ |                    FALSE - no previous value loaded
+ +--------------------------------------------------------------------------*/
+-static bool Previous_Enum(FIELD * field, const void * argp)
++static bool
++Previous_Enum(FIELD *field, const void *argp)
+ {
+   const enumARG *args = (const enumARG *)argp;
+-  int cnt       = args->count;
+-  char **kwds   = &args->kwds[cnt-1];
+-  bool ccase    = args->checkcase;
+-  unsigned char *bp = (unsigned char *)field_buffer(field,0);
+-
+-  if (kwds) {
+-    while(cnt--)
+-      {
+-	if (Compare((unsigned char *)(*kwds--),bp,ccase)==EXACT) 
+-	  break;
+-      }
+-    
+-    if (cnt<=0)
+-      kwds  = &args->kwds[args->count-1];
+-    
+-    if ((cnt>=0) || (Compare((const unsigned char *)dummy,bp,ccase)==EXACT))
+-      {
+-	set_field_buffer(field,0,*kwds);
+-	return TRUE;
+-      }
+-  }
++  int cnt = args->count;
++  char **kwds = &args->kwds[cnt - 1];
++  bool ccase = args->checkcase;
++  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
++
++  if (kwds)
++    {
++      while (cnt--)
++	{
++	  if (Compare((unsigned char *)(*kwds--), bp, ccase) == EXACT)
++	    break;
++	}
++
++      if (cnt <= 0)
++	kwds = &args->kwds[args->count - 1];
++
++      if ((cnt >= 0) || (Compare((const unsigned char *)dummy, bp, ccase) == EXACT))
++	{
++	  set_field_buffer(field, 0, *kwds);
++	  return TRUE;
++	}
++    }
+   return FALSE;
+ }
+ 
+-
+-static FIELDTYPE typeENUM = {
++static FIELDTYPE typeENUM =
++{
+   _HAS_ARGS | _HAS_CHOICE | _RESIDENT,
+-  1,                           /* this is mutable, so we can't be const */
++  1,				/* this is mutable, so we can't be const */
+   (FIELDTYPE *)0,
+   (FIELDTYPE *)0,
+   Make_Enum_Type,
+@@ -290,6 +307,7 @@
+   Previous_Enum
+ };
+ 
+-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ENUM = &typeENUM;
++NCURSES_EXPORT_VAR(FIELDTYPE *)
++TYPE_ENUM = &typeENUM;
+ 
+ /* fty_enum.c ends here */
+Index: form/fty_int.c
+Prereq:  1.13 
+--- ncurses-5.4-20040208/form/fty_int.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/form/fty_int.c	2005-03-06 00:20:48.000000000 +0000
+@@ -1,4 +1,3 @@
+-
+ /*
+  * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
+  * You may freely copy it for use as a template for your own field types.
+@@ -13,51 +12,61 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fty_int.c,v 1.13 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: fty_int.c,v 1.17 2005/03/06 00:20:48 tom Exp $")
+ 
+-typedef struct {
+-  int precision;
+-  long low;
+-  long high;
+-} integerARG;
++#if USE_WIDEC_SUPPORT
++#define isDigit(c) (iswdigit(c) || isdigit(UChar(c)))
++#else
++#define isDigit(c) isdigit(UChar(c))
++#endif
++
++typedef struct
++  {
++    int precision;
++    long low;
++    long high;
++  }
++thisARG;
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+-|   Function      :  static void *Make_Integer_Type( va_list * ap )
++|   Function      :  static void *Make_This_Type( va_list * ap )
+ |   
+ |   Description   :  Allocate structure for integer type argument.
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error
+ +--------------------------------------------------------------------------*/
+-static void *Make_Integer_Type(va_list * ap)
++static void *
++Make_This_Type(va_list *ap)
+ {
+-  integerARG *argp = (integerARG *)malloc(sizeof(integerARG));
++  thisARG *argp = (thisARG *) malloc(sizeof(thisARG));
+ 
+   if (argp)
+     {
+-      argp->precision = va_arg(*ap,int);
+-      argp->low       = va_arg(*ap,long);
+-      argp->high      = va_arg(*ap,long);
++      argp->precision = va_arg(*ap, int);
++      argp->low = va_arg(*ap, long);
++      argp->high = va_arg(*ap, long);
+     }
+   return (void *)argp;
+ }
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+-|   Function      :  static void *Copy_Integer_Type(const void * argp)
++|   Function      :  static void *Copy_This_Type(const void * argp)
+ |   
+ |   Description   :  Copy structure for integer type argument.  
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error.
+ +--------------------------------------------------------------------------*/
+-static void *Copy_Integer_Type(const void * argp)
++static void *
++Copy_This_Type(const void *argp)
+ {
+-  const integerARG *ap = (const integerARG *)argp;
+-  integerARG *result = (integerARG *)0;
++  const thisARG *ap = (const thisARG *)argp;
++  thisARG *result = (thisARG *) 0;
+ 
+   if (argp)
+     {
+-      result = (integerARG *)malloc(sizeof(integerARG));
++      result = (thisARG *) malloc(sizeof(thisARG));
+       if (result)
+ 	*result = *ap;
+     }
+@@ -66,68 +75,115 @@
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+-|   Function      :  static void Free_Integer_Type(void * argp)
++|   Function      :  static void Free_This_Type(void * argp)
+ |   
+ |   Description   :  Free structure for integer type argument.
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Free_Integer_Type(void * argp)
++static void
++Free_This_Type(void *argp)
+ {
+-  if (argp) 
++  if (argp)
+     free(argp);
+ }
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+-|   Function      :  static bool Check_Integer_Field(
+-|                                                    FIELD * field,
+-|                                                    const void * argp)
++|   Function      :  static bool Check_This_Field(
++|                                                 FIELD * field,
++|                                                 const void * argp)
+ |   
+ |   Description   :  Validate buffer content to be a valid integer value
+ |
+ |   Return Values :  TRUE  - field is valid
+ |                    FALSE - field is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_Integer_Field(FIELD * field, const void * argp)
++static bool
++Check_This_Field(FIELD *field, const void *argp)
+ {
+-  const integerARG *argi = (const integerARG *)argp;
+-  long low          = argi->low;
+-  long high         = argi->high;
+-  int prec          = argi->precision;
+-  unsigned char *bp = (unsigned char *)field_buffer(field,0);
+-  char *s           = (char *)bp;
++  const thisARG *argi = (const thisARG *)argp;
++  long low = argi->low;
++  long high = argi->high;
++  int prec = argi->precision;
++  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
++  char *s = (char *)bp;
+   long val;
+   char buf[100];
++  bool result = FALSE;
+ 
+-  while( *bp && *bp==' ') bp++;
++  while (*bp && *bp == ' ')
++    bp++;
+   if (*bp)
+     {
+-      if (*bp=='-') bp++;
++      if (*bp == '-')
++	bp++;
++#if USE_WIDEC_SUPPORT
++      if (*bp)
++	{
++	  bool blank = FALSE;
++	  int len;
++	  int n;
++	  wchar_t *list = _nc_Widen_String((char *)bp, &len);
++
++	  if (list != 0)
++	    {
++	      result = TRUE;
++	      for (n = 0; n < len; ++n)
++		{
++		  if (blank)
++		    {
++		      if (list[n] != ' ')
++			{
++			  result = FALSE;
++			  break;
++			}
++		    }
++		  else if (list[n] == ' ')
++		    {
++		      blank = TRUE;
++		    }
++		  else if (!isDigit(list[n]))
++		    {
++		      result = FALSE;
++		      break;
++		    }
++		}
++	      free(list);
++	    }
++	}
++#else
+       while (*bp)
+ 	{
+-	  if (!isdigit(*bp)) break;
++	  if (!isdigit(UChar(*bp)))
++	    break;
+ 	  bp++;
+ 	}
+-      while(*bp && *bp==' ') bp++;
+-      if (*bp=='\0')
++      while (*bp && *bp == ' ')
++	bp++;
++      result = (*bp == '\0');
++#endif
++      if (result)
+ 	{
+ 	  val = atol(s);
+-	  if (low<high)
++	  if (low < high)
+ 	    {
+-	      if (val<low || val>high) return FALSE;
++	      if (val < low || val > high)
++		result = FALSE;
++	    }
++	  if (result)
++	    {
++	      sprintf(buf, "%.*ld", (prec > 0 ? prec : 0), val);
++	      set_field_buffer(field, 0, buf);
+ 	    }
+-	  sprintf(buf,"%.*ld",(prec>0?prec:0),val);
+-	  set_field_buffer(field,0,buf);
+-	  return TRUE;
+ 	}
+     }
+-  return FALSE;
++  return (result);
+ }
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+-|   Function      :  static bool Check_Integer_Character(
++|   Function      :  static bool Check_This_Character(
+ |                                      int c,
+ |                                      const void * argp)
+ |   
+@@ -136,25 +192,27 @@
+ |   Return Values :  TRUE  - character is valid
+ |                    FALSE - character is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_Integer_Character(int c, const void * argp GCC_UNUSED)
++static bool
++Check_This_Character(int c, const void *argp GCC_UNUSED)
+ {
+-  return ((isdigit(c) || (c=='-')) ? TRUE : FALSE);
++  return ((isDigit(UChar(c)) || (c == '-')) ? TRUE : FALSE);
+ }
+ 
+-static FIELDTYPE typeINTEGER = {
++static FIELDTYPE typeTHIS =
++{
+   _HAS_ARGS | _RESIDENT,
+-  1,                           /* this is mutable, so we can't be const */
++  1,				/* this is mutable, so we can't be const */
+   (FIELDTYPE *)0,
+   (FIELDTYPE *)0,
+-  Make_Integer_Type,
+-  Copy_Integer_Type,
+-  Free_Integer_Type,
+-  Check_Integer_Field,
+-  Check_Integer_Character,
++  Make_This_Type,
++  Copy_This_Type,
++  Free_This_Type,
++  Check_This_Field,
++  Check_This_Character,
+   NULL,
+   NULL
+ };
+ 
+-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeINTEGER;
++NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeTHIS;
+ 
+ /* fty_int.c ends here */
+Index: form/fty_ipv4.c
+Prereq:  1.4 
+--- ncurses-5.4-20040208/form/fty_ipv4.c	2000-12-09 23:46:12.000000000 +0000
++++ ncurses-5.4-20050319/form/fty_ipv4.c	2004-05-29 19:13:48.000000000 +0000
+@@ -13,7 +13,7 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fty_ipv4.c,v 1.4 2000/12/09 23:46:12 tom Exp $")
++MODULE_ID("$Id: fty_ipv4.c,v 1.6 2004/05/29 19:13:48 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnform  
+@@ -26,24 +26,25 @@
+ |   Return Values :  TRUE  - field is valid
+ |                    FALSE - field is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_IPV4_Field(FIELD * field, const void * argp GCC_UNUSED)
++static bool
++Check_IPV4_Field(FIELD *field, const void *argp GCC_UNUSED)
+ {
+-  char *bp = field_buffer(field,0);
++  char *bp = field_buffer(field, 0);
+   int num = 0, len;
+   unsigned int d1, d2, d3, d4;
+ 
+-  if(isdigit((unsigned char)*bp)) /* Must start with digit */
++  if (isdigit(UChar(*bp)))	/* Must start with digit */
+     {
+       num = sscanf(bp, "%u.%u.%u.%u%n", &d1, &d2, &d3, &d4, &len);
+       if (num == 4)
+-        {
+-          bp += len;            /* Make bp point to what sscanf() left */
+-          while (*bp && isspace((unsigned char)*bp))
+-            bp++;               /* Allow trailing whitespace */
+-        }
++	{
++	  bp += len;		/* Make bp point to what sscanf() left */
++	  while (*bp && isspace(UChar(*bp)))
++	    bp++;		/* Allow trailing whitespace */
++	}
+     }
+   return ((num != 4 || *bp || d1 > 255 || d2 > 255
+-                           || d3 > 255 || d4 > 255) ? FALSE : TRUE);
++	   || d3 > 255 || d4 > 255) ? FALSE : TRUE);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -57,14 +58,16 @@
+ |   Return Values :  TRUE  - character is valid
+ |                    FALSE - character is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_IPV4_Character(int c, const void * argp GCC_UNUSED)
++static bool
++Check_IPV4_Character(int c, const void *argp GCC_UNUSED)
+ {
+-  return ((isdigit(c) || (c=='.')) ? TRUE : FALSE);
++  return ((isdigit(UChar(c)) || (c == '.')) ? TRUE : FALSE);
+ }
+ 
+-static FIELDTYPE typeIPV4 = {
++static FIELDTYPE typeIPV4 =
++{
+   _RESIDENT,
+-  1,                           /* this is mutable, so we can't be const */
++  1,				/* this is mutable, so we can't be const */
+   (FIELDTYPE *)0,
+   (FIELDTYPE *)0,
+   NULL,
+Index: form/fty_num.c
+Prereq:  1.16 
+--- ncurses-5.4-20040208/form/fty_num.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/form/fty_num.c	2005-03-06 00:15:59.000000000 +0000
+@@ -1,4 +1,3 @@
+-
+ /*
+  * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
+  * You may freely copy it for use as a template for your own field types.
+@@ -13,183 +12,251 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fty_num.c,v 1.16 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: fty_num.c,v 1.20 2005/03/06 00:15:59 tom Exp $")
+ 
+ #if HAVE_LOCALE_H
+ #include <locale.h>
+ #endif
+ 
+-typedef struct {
+-  int    precision;
+-  double low;
+-  double high;
+-  struct lconv* L;
+-} numericARG;
++#if HAVE_LOCALE_H
++#define isDecimalPoint(c) ((c) == ((L && L->decimal_point) ? *(L->decimal_point) : '.'))
++#else
++#define isDecimalPoint(c) ((c) == '.')
++#endif
++
++#if USE_WIDEC_SUPPORT
++#define isDigit(c) (iswdigit(c) || isdigit(UChar(c)))
++#else
++#define isDigit(c) isdigit(UChar(c))
++#endif
++
++typedef struct
++  {
++    int precision;
++    double low;
++    double high;
++    struct lconv *L;
++  }
++thisARG;
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static void *Make_Numeric_Type(va_list * ap)
+-|   
++|   Facility      :  libnform
++|   Function      :  static void *Make_This_Type(va_list * ap)
++|
+ |   Description   :  Allocate structure for numeric type argument.
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error
+ +--------------------------------------------------------------------------*/
+-static void *Make_Numeric_Type(va_list * ap)
++static void *
++Make_This_Type(va_list *ap)
+ {
+-  numericARG *argn = (numericARG *)malloc(sizeof(numericARG));
++  thisARG *argn = (thisARG *) malloc(sizeof(thisARG));
+ 
+   if (argn)
+     {
+-      argn->precision = va_arg(*ap,int);
+-      argn->low       = va_arg(*ap,double);
+-      argn->high      = va_arg(*ap,double);
++      argn->precision = va_arg(*ap, int);
++      argn->low = va_arg(*ap, double);
++      argn->high = va_arg(*ap, double);
++
+ #if HAVE_LOCALE_H
+-      argn->L         = localeconv();
++      argn->L = localeconv();
+ #else
+-      argn->L         = NULL;
++      argn->L = NULL;
+ #endif
+     }
+   return (void *)argn;
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static void *Copy_Numeric_Type(const void * argp)
+-|   
+-|   Description   :  Copy structure for numeric type argument.  
++|   Facility      :  libnform
++|   Function      :  static void *Copy_This_Type(const void * argp)
++|
++|   Description   :  Copy structure for numeric type argument.
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error.
+ +--------------------------------------------------------------------------*/
+-static void *Copy_Numeric_Type(const void * argp)
++static void *
++Copy_This_Type(const void *argp)
+ {
+-  const numericARG *ap = (const numericARG *)argp;
+-  numericARG *result = (numericARG *)0;
++  const thisARG *ap = (const thisARG *)argp;
++  thisARG *result = (thisARG *) 0;
+ 
+   if (argp)
+     {
+-      result = (numericARG *)malloc(sizeof(numericARG));
++      result = (thisARG *) malloc(sizeof(thisARG));
+       if (result)
+-	*result  = *ap;
++	*result = *ap;
+     }
+   return (void *)result;
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static void Free_Numeric_Type(void * argp)
+-|   
++|   Facility      :  libnform
++|   Function      :  static void Free_This_Type(void * argp)
++|
+ |   Description   :  Free structure for numeric type argument.
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Free_Numeric_Type(void * argp)
++static void
++Free_This_Type(void *argp)
+ {
+-  if (argp) 
++  if (argp)
+     free(argp);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static bool Check_Numeric_Field(FIELD * field,
+-|                                                    const void * argp)
+-|   
++|   Facility      :  libnform
++|   Function      :  static bool Check_This_Field(FIELD * field,
++|                                                 const void * argp)
++|
+ |   Description   :  Validate buffer content to be a valid numeric value
+ |
+ |   Return Values :  TRUE  - field is valid
+ |                    FALSE - field is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_Numeric_Field(FIELD * field, const void * argp)
++static bool
++Check_This_Field(FIELD *field, const void *argp)
+ {
+-  const numericARG *argn = (const numericARG *)argp;
+-  double low          = argn->low;
+-  double high         = argn->high;
+-  int prec            = argn->precision;
+-  unsigned char *bp   = (unsigned char *)field_buffer(field,0);
+-  char *s             = (char *)bp;
+-  double val          = 0.0;
+-  struct lconv* L     = argn->L;
++  const thisARG *argn = (const thisARG *)argp;
++  double low = argn->low;
++  double high = argn->high;
++  int prec = argn->precision;
++  unsigned char *bp = (unsigned char *)field_buffer(field, 0);
++  char *s = (char *)bp;
++  double val = 0.0;
++  struct lconv *L = argn->L;
+   char buf[64];
++  bool result = FALSE;
+ 
+-  while(*bp && *bp==' ') bp++;
++  while (*bp && *bp == ' ')
++    bp++;
+   if (*bp)
+     {
+-      if (*bp=='-' || *bp=='+')
++      if (*bp == '-' || *bp == '+')
+ 	bp++;
+-      while(*bp)
++#if USE_WIDEC_SUPPORT
++      if (*bp)
+ 	{
+-	  if (!isdigit(*bp)) break;
++	  bool blank = FALSE;
++	  int state = 0;
++	  int len;
++	  int n;
++	  wchar_t *list = _nc_Widen_String((char *)bp, &len);
++
++	  if (list != 0)
++	    {
++	      result = TRUE;
++	      for (n = 0; n < len; ++n)
++		{
++		  if (blank)
++		    {
++		      if (list[n] != ' ')
++			{
++			  result = FALSE;
++			  break;
++			}
++		    }
++		  else if (list[n] == ' ')
++		    {
++		      blank = TRUE;
++		    }
++		  else if (isDecimalPoint(list[n]))
++		    {
++		      if (++state > 1)
++			{
++			  result = FALSE;
++			  break;
++			}
++		    }
++		  else if (!isDigit(list[n]))
++		    {
++		      result = FALSE;
++		      break;
++		    }
++		}
++	      free(list);
++	    }
++	}
++#else
++      while (*bp)
++	{
++	  if (!isdigit(UChar(*bp)))
++	    break;
+ 	  bp++;
+ 	}
+-      if (*bp==(
+-#if HAVE_LOCALE_H
+-		(L && L->decimal_point) ? *(L->decimal_point) :
+-#endif
+-		'.'))
++      if (isDecimalPoint(*bp))
+ 	{
+ 	  bp++;
+-	  while(*bp)
++	  while (*bp)
+ 	    {
+-	      if (!isdigit(*bp)) break;
++	      if (!isdigit(UChar(*bp)))
++		break;
+ 	      bp++;
+ 	    }
+ 	}
+-      while(*bp && *bp==' ') bp++;
+-      if (*bp=='\0')
++      while (*bp && *bp == ' ')
++	bp++;
++      result = (*bp == '\0');
++#endif
++      if (result)
+ 	{
+ 	  val = atof(s);
+-	  if (low<high)
++	  if (low < high)
++	    {
++	      if (val < low || val > high)
++		result = FALSE;
++	    }
++	  if (result)
+ 	    {
+-	      if (val<low || val>high) return FALSE;
++	      sprintf(buf, "%.*f", (prec > 0 ? prec : 0), val);
++	      set_field_buffer(field, 0, buf);
+ 	    }
+-	  sprintf(buf,"%.*f",(prec>0?prec:0),val);
+-	  set_field_buffer(field,0,buf);
+-	  return TRUE;
+ 	}
+     }
+-  return FALSE;
++  return (result);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnform  
+-|   Function      :  static bool Check_Numeric_Character(
++|   Facility      :  libnform
++|   Function      :  static bool Check_This_Character(
+ |                                      int c,
+ |                                      const void * argp)
+-|   
++|
+ |   Description   :  Check a character for the numeric type.
+ |
+ |   Return Values :  TRUE  - character is valid
+ |                    FALSE - character is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_Numeric_Character(int c, const void * argp)
++static bool
++Check_This_Character(int c, const void *argp)
+ {
+-  const numericARG *argn = (const numericARG *)argp;
+-  struct lconv* L  = argn->L;  
++  const thisARG *argn = (const thisARG *)argp;
++  struct lconv *L = argn->L;
+ 
+-  return (isdigit(c)  || 
+-	  c == '+'    || 
+-	  c == '-'    || 
+-	  c == (
+-#if HAVE_LOCALE_H
+-		(L && L->decimal_point) ? *(L->decimal_point) :
+-#endif
+-		'.')
+-	  ) ? TRUE : FALSE;
++  return ((isDigit(c) ||
++	   c == '+' ||
++	   c == '-' ||
++	   isDecimalPoint(c))
++	  ? TRUE
++	  : FALSE);
+ }
+ 
+-static FIELDTYPE typeNUMERIC = {
++static FIELDTYPE typeTHIS =
++{
+   _HAS_ARGS | _RESIDENT,
+-  1,                           /* this is mutable, so we can't be const */
++  1,				/* this is mutable, so we can't be const */
+   (FIELDTYPE *)0,
+   (FIELDTYPE *)0,
+-  Make_Numeric_Type,
+-  Copy_Numeric_Type,
+-  Free_Numeric_Type,
+-  Check_Numeric_Field,
+-  Check_Numeric_Character,
++  Make_This_Type,
++  Copy_This_Type,
++  Free_This_Type,
++  Check_This_Field,
++  Check_This_Character,
+   NULL,
+   NULL
+ };
+ 
+-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeNUMERIC;
++NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeTHIS;
+ 
+ /* fty_num.c ends here */
+Index: form/fty_regex.c
+Prereq:  1.17 
+--- ncurses-5.4-20040208/form/fty_regex.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/form/fty_regex.c	2004-05-29 19:19:09.000000000 +0000
+@@ -13,31 +13,34 @@
+ 
+ #include "form.priv.h"
+ 
+-MODULE_ID("$Id: fty_regex.c,v 1.17 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: fty_regex.c,v 1.18 2004/05/29 19:19:09 tom Exp $")
+ 
+-#if HAVE_REGEX_H_FUNCS	/* We prefer POSIX regex */
++#if HAVE_REGEX_H_FUNCS		/* We prefer POSIX regex */
+ #include <regex.h>
+ 
+ typedef struct
+-{
+-  regex_t *pRegExp;
+-  unsigned long *refCount;
+-} RegExp_Arg;
++  {
++    regex_t *pRegExp;
++    unsigned long *refCount;
++  }
++RegExp_Arg;
+ 
+ #elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+ #undef RETURN
+ static int reg_errno;
+ 
+-static char *RegEx_Init(char *instring)
++static char *
++RegEx_Init(char *instring)
+ {
+-	reg_errno = 0;
+-	return instring;
++  reg_errno = 0;
++  return instring;
+ }
+ 
+-static char *RegEx_Error(int code)
++static char *
++RegEx_Error(int code)
+ {
+-	reg_errno = code;
+-	return 0;
++  reg_errno = code;
++  return 0;
+ }
+ 
+ #define INIT 		register char *sp = RegEx_Init(instring);
+@@ -57,7 +60,8 @@
+ {
+   char *compiled_expression;
+   unsigned long *refCount;
+-} RegExp_Arg;
++}
++RegExp_Arg;
+ 
+ /* Maximum Length we allow for a compiled regular expression */
+ #define MAX_RX_LEN   (2048)
+@@ -73,20 +77,23 @@
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error
+ +--------------------------------------------------------------------------*/
+-static void *Make_RegularExpression_Type(va_list * ap)
++static void *
++Make_RegularExpression_Type(va_list *ap)
+ {
+ #if HAVE_REGEX_H_FUNCS
+-  char *rx = va_arg(*ap,char *);
++  char *rx = va_arg(*ap, char *);
+   RegExp_Arg *preg;
+ 
+-  preg = (RegExp_Arg*)malloc(sizeof(RegExp_Arg));
++  preg = (RegExp_Arg *)malloc(sizeof(RegExp_Arg));
++
+   if (preg)
+     {
+-      if (((preg->pRegExp = (regex_t*)malloc(sizeof(regex_t))) != (regex_t*)0)
+-       && !regcomp(preg->pRegExp,rx,
+-		   (REG_EXTENDED | REG_NOSUB | REG_NEWLINE) ))
++      if (((preg->pRegExp = (regex_t *) malloc(sizeof(regex_t))) != 0)
++	  && !regcomp(preg->pRegExp, rx,
++		      (REG_EXTENDED | REG_NOSUB | REG_NEWLINE)))
+ 	{
+ 	  preg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
++
+ 	  *(preg->refCount) = 1;
+ 	}
+       else
+@@ -94,12 +101,12 @@
+ 	  if (preg->pRegExp)
+ 	    free(preg->pRegExp);
+ 	  free(preg);
+-	  preg = (RegExp_Arg*)0;
++	  preg = (RegExp_Arg *)0;
+ 	}
+     }
+-  return((void *)preg);
++  return ((void *)preg);
+ #elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+-  char *rx = va_arg(*ap,char *);
++  char *rx = va_arg(*ap, char *);
+   RegExp_Arg *pArg;
+ 
+   pArg = (RegExp_Arg *)malloc(sizeof(RegExp_Arg));
+@@ -107,38 +114,44 @@
+   if (pArg)
+     {
+       int blen = RX_INCREMENT;
++
+       pArg->compiled_expression = NULL;
+       pArg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
++
+       *(pArg->refCount) = 1;
+ 
+-      do {
+-	char *buf = (char *)malloc(blen);
+-	if (buf)
+-	  {
++      do
++	{
++	  char *buf = (char *)malloc(blen);
++
++	  if (buf)
++	    {
+ #if HAVE_REGEXP_H_FUNCS
+-	    char *last_pos = compile (rx, buf, &buf[blen], '\0');
++	      char *last_pos = compile(rx, buf, &buf[blen], '\0');
++
+ #else /* HAVE_REGEXPR_H_FUNCS */
+-	    char *last_pos = compile (rx, buf, &buf[blen]);
++	      char *last_pos = compile(rx, buf, &buf[blen]);
+ #endif
+-	    if (reg_errno)
+-	      {
+-		free(buf);
+-		if (reg_errno==50)
+-		  blen += RX_INCREMENT;
+-		else
+-		  {
+-		    free(pArg);
+-		    pArg = NULL;
+-		    break;
+-		  }
+-	      }
+-	    else
+-	      {
+-		pArg->compiled_expression = buf;
+-		break;
+-	      }
+-	  }
+-      } while( blen <= MAX_RX_LEN );
++	      if (reg_errno)
++		{
++		  free(buf);
++		  if (reg_errno == 50)
++		    blen += RX_INCREMENT;
++		  else
++		    {
++		      free(pArg);
++		      pArg = NULL;
++		      break;
++		    }
++		}
++	      else
++		{
++		  pArg->compiled_expression = buf;
++		  break;
++		}
++	    }
++	}
++      while (blen <= MAX_RX_LEN);
+     }
+   if (pArg && !pArg->compiled_expression)
+     {
+@@ -160,7 +173,8 @@
+ |
+ |   Return Values :  Pointer to argument structure or NULL on error.
+ +--------------------------------------------------------------------------*/
+-static void *Copy_RegularExpression_Type(const void * argp)
++static void *
++Copy_RegularExpression_Type(const void *argp)
+ {
+ #if (HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS)
+   const RegExp_Arg *ap = (const RegExp_Arg *)argp;
+@@ -185,10 +199,12 @@
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-static void Free_RegularExpression_Type(void * argp)
++static void
++Free_RegularExpression_Type(void *argp)
+ {
+ #if HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+   RegExp_Arg *ap = (RegExp_Arg *)argp;
++
+   if (ap)
+     {
+       if (--(*(ap->refCount)) == 0)
+@@ -223,24 +239,33 @@
+ |   Return Values :  TRUE  - field is valid
+ |                    FALSE - field is invalid
+ +--------------------------------------------------------------------------*/
+-static bool Check_RegularExpression_Field(FIELD * field, const void  * argp)
++static bool
++Check_RegularExpression_Field(FIELD *field, const void *argp)
+ {
+   bool match = FALSE;
++
+ #if HAVE_REGEX_H_FUNCS
+-  const RegExp_Arg *ap = (const RegExp_Arg*)argp;
++  const RegExp_Arg *ap = (const RegExp_Arg *)argp;
++
+   if (ap && ap->pRegExp)
+-    match = (regexec(ap->pRegExp,field_buffer(field,0),0,NULL,0) ? FALSE:TRUE);
++    match = (regexec(ap->pRegExp, field_buffer(field, 0), 0, NULL, 0)
++	     ? FALSE
++	     : TRUE);
+ #elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
+   RegExp_Arg *ap = (RegExp_Arg *)argp;
++
+   if (ap && ap->compiled_expression)
+-    match = (step(field_buffer(field,0),ap->compiled_expression) ? TRUE:FALSE);
++    match = (step(field_buffer(field, 0), ap->compiled_expression)
++	     ? TRUE
++	     : FALSE);
+ #endif
+   return match;
+ }
+ 
+-static FIELDTYPE typeREGEXP = {
++static FIELDTYPE typeREGEXP =
++{
+   _HAS_ARGS | _RESIDENT,
+-  1,                           /* this is mutable, so we can't be const */
++  1,				/* this is mutable, so we can't be const */
+   (FIELDTYPE *)0,
+   (FIELDTYPE *)0,
+   Make_RegularExpression_Type,
+Index: form/llib-lform
+--- ncurses-5.4-20040208/form/llib-lform	2002-08-31 19:59:34.000000000 +0000
++++ ncurses-5.4-20050319/form/llib-lform	2005-03-05 19:41:01.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2002 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2002,2005 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            *
+@@ -27,14 +27,41 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,2002              *
++ *  Author: Thomas E. Dickey       1996,1997,2002,2005                      *
+  ****************************************************************************/
+ /* LINTLIBRARY */
+ 
+-/* ./fld_arg.c */
++/* ./f_trace.c */
+ 
+ #include "form.priv.h"
+ 
++#undef _nc_retrace_field_ptr
++FIELD	**_nc_retrace_field_ptr(
++		FIELD	**code)
++		{ return(*(FIELD ***)0); }
++
++#undef _nc_retrace_field
++FIELD	*_nc_retrace_field(
++		FIELD	*code)
++		{ return(*(FIELD **)0); }
++
++#undef _nc_retrace_field_type
++FIELDTYPE *_nc_retrace_field_type(
++		FIELDTYPE *code)
++		{ return(*(FIELDTYPE **)0); }
++
++#undef _nc_retrace_form
++FORM	*_nc_retrace_form(
++		FORM	*code)
++		{ return(*(FORM **)0); }
++
++#undef _nc_retrace_form_hook
++Form_Hook _nc_retrace_form_hook(
++		Form_Hook code)
++		{ return(*(Form_Hook *)0); }
++
++/* ./fld_arg.c */
++
+ #undef set_fieldtype_arg
+ int	set_fieldtype_arg(
+ 		FIELDTYPE *typ, 
+@@ -441,10 +468,12 @@
+ 		FIELD	*field)
+ 		{ return(*(int *)0); }
+ 
+-typedef struct {
+-  int keycode;           
+-  int (*cmd)(FORM *);    
+-} Binding_Info;
++typedef struct
++{
++  int keycode; 
++  int (*cmd) (FORM *); 
++}
++Binding_Info;
+ 
+ #undef form_driver
+ int	form_driver(
+@@ -623,41 +652,49 @@
+ 
+ /* ./fty_alnum.c */
+ 
+-typedef struct {
+-  int width;
+-} alnumARG;
++typedef struct
++  {
++    int width;
++  }
++alnumARG;
+ 
+ #undef TYPE_ALNUM
+ FIELDTYPE *TYPE_ALNUM;
+ 
+ /* ./fty_alpha.c */
+ 
+-typedef struct {
+-  int width;
+-} alphaARG;
++typedef struct
++  {
++    int width;
++  }
++alphaARG;
+ 
+ #undef TYPE_ALPHA
+ FIELDTYPE *TYPE_ALPHA;
+ 
+ /* ./fty_enum.c */
+ 
+-typedef struct {
+-  char **kwds;
+-  int  count;
+-  NCURSES_BOOL  checkcase;
+-  NCURSES_BOOL  checkunique;
+-} enumARG;
++typedef struct
++  {
++    char **kwds;
++    int count;
++    NCURSES_BOOL checkcase;
++    NCURSES_BOOL checkunique;
++  }
++enumARG;
+ 
+ #undef TYPE_ENUM
+ FIELDTYPE *TYPE_ENUM;
+ 
+ /* ./fty_int.c */
+ 
+-typedef struct {
+-  int precision;
+-  long low;
+-  long high;
+-} integerARG;
++typedef struct
++  {
++    int precision;
++    long low;
++    long high;
++  }
++integerARG;
+ 
+ #undef TYPE_INTEGER
+ FIELDTYPE *TYPE_INTEGER;
+@@ -670,12 +707,14 @@
+ 
+ #include <locale.h>
+ 
+-typedef struct {
+-  int    precision;
+-  double low;
+-  double high;
+-  struct lconv* L;
+-} numericARG;
++typedef struct
++  {
++    int precision;
++    double low;
++    double high;
++    struct lconv *L;
++  }
++numericARG;
+ 
+ #undef TYPE_NUMERIC
+ FIELDTYPE *TYPE_NUMERIC;
+@@ -685,10 +724,11 @@
+ #include <regex.h>
+ 
+ typedef struct
+-{
+-  regex_t *pRegExp;
+-  unsigned long *refCount;
+-} RegExp_Arg;
++  {
++    regex_t *pRegExp;
++    unsigned long *refCount;
++  }
++RegExp_Arg;
+ 
+ #undef TYPE_REGEXP
+ FIELDTYPE *TYPE_REGEXP;
+Index: form/llib-lformw
+--- ncurses-5.4-20040208/form/llib-lformw	2002-08-31 21:53:19.000000000 +0000
++++ ncurses-5.4-20050319/form/llib-lformw	2005-03-05 19:32:57.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
++ * Copyright (c) 2002,2005 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            *
+@@ -27,14 +27,41 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey <dickey@clark.net> 2002                        *
++ *  Author: Thomas E. Dickey                    2002,2005                   *
+  ****************************************************************************/
+ /* LINTLIBRARY */
+ 
+-/* ./fld_arg.c */
++/* ./f_trace.c */
+ 
+ #include "form.priv.h"
+ 
++#undef _nc_retrace_field_ptr
++FIELD	**_nc_retrace_field_ptr(
++		FIELD	**code)
++		{ return(*(FIELD ***)0); }
++
++#undef _nc_retrace_field
++FIELD	*_nc_retrace_field(
++		FIELD	*code)
++		{ return(*(FIELD **)0); }
++
++#undef _nc_retrace_field_type
++FIELDTYPE *_nc_retrace_field_type(
++		FIELDTYPE *code)
++		{ return(*(FIELDTYPE **)0); }
++
++#undef _nc_retrace_form
++FORM	*_nc_retrace_form(
++		FORM	*code)
++		{ return(*(FORM **)0); }
++
++#undef _nc_retrace_form_hook
++Form_Hook _nc_retrace_form_hook(
++		Form_Hook code)
++		{ return(*(Form_Hook *)0); }
++
++/* ./fld_arg.c */
++
+ #undef set_fieldtype_arg
+ int	set_fieldtype_arg(
+ 		FIELDTYPE *typ, 
+@@ -441,10 +468,12 @@
+ 		FIELD	*field)
+ 		{ return(*(int *)0); }
+ 
+-typedef struct {
+-  int keycode;           
+-  int (*cmd)(FORM *);    
+-} Binding_Info;
++typedef struct
++{
++  int keycode; 
++  int (*cmd) (FORM *); 
++}
++Binding_Info;
+ 
+ #undef form_driver
+ int	form_driver(
+@@ -465,6 +494,12 @@
+ 		int	buffer)
+ 		{ return(*(char **)0); }
+ 
++#undef _nc_Widen_String
++wchar_t	*_nc_Widen_String(
++		char	*source, 
++		int	*lengthp)
++		{ return(*(wchar_t **)0); }
++
+ /* ./frm_hook.c */
+ 
+ #undef set_field_init
+@@ -623,41 +658,49 @@
+ 
+ /* ./fty_alnum.c */
+ 
+-typedef struct {
+-  int width;
+-} alnumARG;
++typedef struct
++  {
++    int width;
++  }
++alnumARG;
+ 
+ #undef TYPE_ALNUM
+ FIELDTYPE *TYPE_ALNUM;
+ 
+ /* ./fty_alpha.c */
+ 
+-typedef struct {
+-  int width;
+-} alphaARG;
++typedef struct
++  {
++    int width;
++  }
++alphaARG;
+ 
+ #undef TYPE_ALPHA
+ FIELDTYPE *TYPE_ALPHA;
+ 
+ /* ./fty_enum.c */
+ 
+-typedef struct {
+-  char **kwds;
+-  int  count;
+-  NCURSES_BOOL  checkcase;
+-  NCURSES_BOOL  checkunique;
+-} enumARG;
++typedef struct
++  {
++    char **kwds;
++    int count;
++    NCURSES_BOOL checkcase;
++    NCURSES_BOOL checkunique;
++  }
++enumARG;
+ 
+ #undef TYPE_ENUM
+ FIELDTYPE *TYPE_ENUM;
+ 
+ /* ./fty_int.c */
+ 
+-typedef struct {
+-  int precision;
+-  long low;
+-  long high;
+-} integerARG;
++typedef struct
++  {
++    int precision;
++    long low;
++    long high;
++  }
++integerARG;
+ 
+ #undef TYPE_INTEGER
+ FIELDTYPE *TYPE_INTEGER;
+@@ -668,12 +711,16 @@
+ 
+ /* ./fty_num.c */
+ 
+-typedef struct {
+-  int    precision;
+-  double low;
+-  double high;
+-  struct lconv* L;
+-} numericARG;
++#include <locale.h>
++
++typedef struct
++  {
++    int precision;
++    double low;
++    double high;
++    struct lconv *L;
++  }
++numericARG;
+ 
+ #undef TYPE_NUMERIC
+ FIELDTYPE *TYPE_NUMERIC;
+@@ -683,10 +730,11 @@
+ #include <regex.h>
+ 
+ typedef struct
+-{
+-  regex_t *pRegExp;
+-  unsigned long *refCount;
+-} RegExp_Arg;
++  {
++    regex_t *pRegExp;
++    unsigned long *refCount;
++  }
++RegExp_Arg;
+ 
+ #undef TYPE_REGEXP
+ FIELDTYPE *TYPE_REGEXP;
+Index: form/modules
+Prereq:  1.13 
+--- ncurses-5.4-20040208/form/modules	1999-02-19 00:27:47.000000000 +0000
++++ ncurses-5.4-20050319/form/modules	2004-12-25 23:29:22.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: modules,v 1.13 1999/02/19 00:27:47 juergen Exp $
++# $Id: modules,v 1.14 2004/12/25 23:29:22 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
++# Copyright (c) 1998,2004 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"), #
+@@ -27,11 +27,12 @@
+ # authorization.                                                             #
+ ##############################################################################
+ #
+-# Author: Thomas E. Dickey <dickey@clark.net> 1996,1997
++# Author: Thomas E. Dickey
+ #
+ 
+ @ base
+ # Library objects
++f_trace		lib		$(srcdir)	$(FORM_PRIV_H)
+ fld_arg		lib		$(srcdir)	$(FORM_PRIV_H)
+ fld_attr	lib		$(srcdir)	$(FORM_PRIV_H)
+ fld_current	lib		$(srcdir)	$(FORM_PRIV_H)
+Index: include/curses.h.in
+Prereq:  1.148 
+--- ncurses-5.4-20040208/include/curses.h.in	2004-01-14 23:50:12.000000000 +0000
++++ ncurses-5.4-20050319/include/curses.h.in	2005-02-05 18:17:35.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,10 +29,10 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+- *     and: Thomas E. Dickey 1996-on                                        *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+-/* $Id: curses.h.in,v 1.148 2004/01/14 23:50:12 tom Exp $ */
++/* $Id: curses.h.in,v 1.153 2005/02/05 18:17:35 tom Exp $ */
+ 
+ #ifndef __NCURSES_H
+ #define __NCURSES_H
+@@ -55,9 +55,24 @@
+ #undef  NCURSES_VERSION
+ #define NCURSES_VERSION "@NCURSES_MAJOR@.@NCURSES_MINOR@"
+ 
++/*
++ * Identify the mouse encoding version.
++ */
++#define NCURSES_MOUSE_VERSION @NCURSES_MOUSE_VERSION@
++
++/*
++ * Definitions to facilitate DLL's.
++ */
+ #include <ncurses_dll.h>
+ 
+ /*
++ * User-definable tweak to disable the include of <stdbool.h>.
++ */
++#ifndef NCURSES_ENABLE_STDBOOL_H
++#define NCURSES_ENABLE_STDBOOL_H @cf_cv_header_stdbool_h@
++#endif
++
++/*
+  * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
+  * configured using --disable-macros.
+  */
+@@ -132,7 +147,7 @@
+ 
+ #else			/* c89, c99, etc. */
+ 
+-#if @cf_cv_header_stdbool_h@
++#if NCURSES_ENABLE_STDBOOL_H
+ #include <stdbool.h>
+ /* use whatever the C compiler decides bool really is */
+ #define NCURSES_BOOL bool
+@@ -310,6 +325,9 @@
+ {
+     attr_t	attr;
+     wchar_t	chars[CCHARW_MAX];
++#if @NCURSES_EXT_COLORS@
++    int		ext_color;	/* color pair, must be more than 16-bits */
++#endif
+ }
+ cchar_t;
+ 
+@@ -366,6 +384,9 @@
+ 
+ #ifdef _XOPEN_SOURCE_EXTENDED
+ 	cchar_t  _bkgrnd;	/* current background char/attribute pair */
++#if @NCURSES_EXT_COLORS@
++	int	_color;		/* current color-pair for non-space character */
++#endif
+ #endif
+ };
+ 
+@@ -808,6 +829,9 @@
+ #define A_TOP		NCURSES_BITS(@cf_cv_1UL@,21)
+ #define A_VERTICAL	NCURSES_BITS(@cf_cv_1UL@,22)
+ 
++/*
++ * These apply to the first 256 color pairs.
++ */
+ #define COLOR_PAIR(n)	NCURSES_BITS(n, 0)
+ #define PAIR_NUMBER(a)	((int)(((a) & A_COLOR) >> NCURSES_ATTR_SHIFT))
+ 
+@@ -851,11 +875,16 @@
+ 
+ #define wstandout(win)      	(wattrset(win,A_STANDOUT))
+ #define wstandend(win)      	(wattrset(win,A_NORMAL))
+-#define wattr_set(win,a,p,opts) ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
+ 
+ #define wattron(win,at)		wattr_on(win, (attr_t) at, (void *)0)
+ #define wattroff(win,at)	wattr_off(win, (attr_t) at, (void *)0)
++
++#if @NCURSES_EXT_COLORS@
++#define wattrset(win,at)	((win)->_color = PAIR_NUMBER(at), \
++				 (win)->_attrs = (at))
++#else
+ #define wattrset(win,at)	((win)->_attrs = (at))
++#endif
+ 
+ #define scroll(win)		wscrl(win,1)
+ 
+@@ -972,16 +1001,26 @@
+ #define mvvline(y,x,c,n)		mvwvline(stdscr,y,x,c,n)
+ 
+ /*
+- * Some wide-character functions do not depend on the extensions.
++ * Some wide-character functions can be implemented without the extensions.
+  */
+ #define getbkgd(win)                    ((win)->_bkgd)
+ 
+ #define slk_attr_off(a,v)		((v) ? ERR : slk_attroff(a))
+ #define slk_attr_on(a,v)		((v) ? ERR : slk_attron(a))
+ 
++#if @NCURSES_EXT_COLORS@
++#define wattr_set(win,a,p,opts)		((win)->_attrs = ((a) & ~A_COLOR), \
++					 (win)->_color = (p), \
++					 OK)
++#define wattr_get(win,a,p,opts)		((void)((a) != 0 && (*(a) = (win)->_attrs)), \
++					 (void)((p) != 0 && (*(p) = (win)->_color)), \
++					 OK)
++#else
++#define wattr_set(win,a,p,opts)		((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
+ #define wattr_get(win,a,p,opts)		((void)((a) != 0 && (*(a) = (win)->_attrs)), \
+ 					 (void)((p) != 0 && (*(p) = PAIR_NUMBER((win)->_attrs))), \
+ 					 OK)
++#endif
+ 
+ /*
+  * XSI curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
+Index: include/curses.tail
+Prereq:  1.8 
+--- ncurses-5.4-20040208/include/curses.tail	2002-11-02 20:26:26.000000000 +0000
++++ ncurses-5.4-20050319/include/curses.tail	2005-02-05 19:20:16.000000000 +0000
+@@ -1,38 +1,77 @@
+-/* $Id: curses.tail,v 1.8 2002/11/02 20:26:26 tom Exp $ */
++/* $Id: curses.tail,v 1.11 2005/02/05 19:20:16 tom Exp $ */
+ 
+ /* mouse interface */
+-#define NCURSES_MOUSE_VERSION	1
++
++#if NCURSES_MOUSE_VERSION > 1
++#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5))
++#else
++#define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6))
++#endif
++
++#define	NCURSES_BUTTON_RELEASED	001L
++#define	NCURSES_BUTTON_PRESSED	002L
++#define	NCURSES_BUTTON_CLICKED	004L
++#define	NCURSES_DOUBLE_CLICKED	010L
++#define	NCURSES_TRIPLE_CLICKED	020L
++#define	NCURSES_RESERVED_EVENT	040L
+ 
+ /* event masks */
+-#define	BUTTON1_RELEASED	000000000001L
+-#define	BUTTON1_PRESSED		000000000002L
+-#define	BUTTON1_CLICKED		000000000004L
+-#define	BUTTON1_DOUBLE_CLICKED	000000000010L
+-#define	BUTTON1_TRIPLE_CLICKED	000000000020L
+-#define BUTTON1_RESERVED_EVENT	000000000040L
+-#define	BUTTON2_RELEASED	000000000100L
+-#define	BUTTON2_PRESSED		000000000200L
+-#define	BUTTON2_CLICKED		000000000400L
+-#define	BUTTON2_DOUBLE_CLICKED	000000001000L
+-#define	BUTTON2_TRIPLE_CLICKED	000000002000L
+-#define BUTTON2_RESERVED_EVENT	000000004000L
+-#define	BUTTON3_RELEASED	000000010000L
+-#define	BUTTON3_PRESSED		000000020000L
+-#define	BUTTON3_CLICKED		000000040000L
+-#define	BUTTON3_DOUBLE_CLICKED	000000100000L
+-#define	BUTTON3_TRIPLE_CLICKED	000000200000L
+-#define BUTTON3_RESERVED_EVENT	000000400000L
+-#define	BUTTON4_RELEASED	000001000000L
+-#define	BUTTON4_PRESSED		000002000000L
+-#define	BUTTON4_CLICKED		000004000000L
+-#define	BUTTON4_DOUBLE_CLICKED	000010000000L
+-#define	BUTTON4_TRIPLE_CLICKED	000020000000L
+-#define BUTTON4_RESERVED_EVENT	000040000000L
+-#define BUTTON_CTRL		000100000000L
+-#define BUTTON_SHIFT		000200000000L
+-#define BUTTON_ALT		000400000000L
+-#define	ALL_MOUSE_EVENTS	000777777777L
+-#define	REPORT_MOUSE_POSITION	001000000000L
++#define	BUTTON1_RELEASED	NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
++#define	BUTTON1_PRESSED		NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)
++#define	BUTTON1_CLICKED		NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED)
++#define	BUTTON1_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)
++#define	BUTTON1_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)
++
++#define	BUTTON2_RELEASED	NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED)
++#define	BUTTON2_PRESSED		NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED)
++#define	BUTTON2_CLICKED		NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED)
++#define	BUTTON2_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED)
++#define	BUTTON2_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED)
++
++#define	BUTTON3_RELEASED	NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED)
++#define	BUTTON3_PRESSED		NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED)
++#define	BUTTON3_CLICKED		NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED)
++#define	BUTTON3_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED)
++#define	BUTTON3_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED)
++
++#define	BUTTON4_RELEASED	NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED)
++#define	BUTTON4_PRESSED		NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED)
++#define	BUTTON4_CLICKED		NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED)
++#define	BUTTON4_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED)
++#define	BUTTON4_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED)
++
++/*
++ * In 32 bits the version-1 scheme does not provide enough space for a 5th
++ * button, unless we choose to change the ABI by omitting the reserved-events.
++ */
++#if NCURSES_MOUSE_VERSION > 1
++
++#define	BUTTON5_RELEASED	NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED)
++#define	BUTTON5_PRESSED		NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED)
++#define	BUTTON5_CLICKED		NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED)
++#define	BUTTON5_DOUBLE_CLICKED	NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED)
++#define	BUTTON5_TRIPLE_CLICKED	NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED)
++
++#define	BUTTON_CTRL		NCURSES_MOUSE_MASK(6, 0001L)
++#define	BUTTON_SHIFT		NCURSES_MOUSE_MASK(6, 0002L)
++#define	BUTTON_ALT		NCURSES_MOUSE_MASK(6, 0004L)
++#define	REPORT_MOUSE_POSITION	NCURSES_MOUSE_MASK(6, 0010L)
++
++#else
++
++#define	BUTTON1_RESERVED_EVENT	NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT)
++#define	BUTTON2_RESERVED_EVENT	NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT)
++#define	BUTTON3_RESERVED_EVENT	NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT)
++#define	BUTTON4_RESERVED_EVENT	NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT)
++
++#define	BUTTON_CTRL		NCURSES_MOUSE_MASK(5, 0001L)
++#define	BUTTON_SHIFT		NCURSES_MOUSE_MASK(5, 0002L)
++#define	BUTTON_ALT		NCURSES_MOUSE_MASK(5, 0004L)
++#define	REPORT_MOUSE_POSITION	NCURSES_MOUSE_MASK(5, 0010L)
++
++#endif
++
++#define	ALL_MOUSE_EVENTS	(REPORT_MOUSE_POSITION - 1)
+ 
+ /* macros to extract single event-bits from masks */
+ #define	BUTTON_RELEASE(e, x)		((e) & (001 << (6 * ((x) - 1))))
+@@ -57,7 +96,7 @@
+ extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *);
+ extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int);
+ extern NCURSES_EXPORT(int) mouseinterval (int);
+-extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW* win,int* y, int* x, bool to_screen);
++extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool);
+ extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool);              /* generated */
+ 
+ #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
+@@ -113,6 +152,7 @@
+ extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable;		/* enable optimizations */
+ #ifdef _XOPEN_SOURCE_EXTENDED
+ extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *);
++extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *);
+ #endif
+ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
+ #define OPTIMIZE_MVCUR		0x01	/* cursor movement optimization */
+Index: include/curses.wide
+Prereq:  1.28 
+--- ncurses-5.4-20040208/include/curses.wide	2004-01-03 20:35:14.000000000 +0000
++++ ncurses-5.4-20050319/include/curses.wide	2005-01-28 21:11:53.000000000 +0000
+@@ -1,7 +1,7 @@
+ 
+ #ifdef _XOPEN_SOURCE_EXTENDED
+ 
+-/* $Id: curses.wide,v 1.28 2004/01/03 20:35:14 tom Exp $ */
++/* $Id: curses.wide,v 1.29 2005/01/28 21:11:53 tom Exp $ */
+ 
+ extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs;
+ 
+@@ -188,11 +188,9 @@
+ #define ins_wch(c)			wins_wch(stdscr,c)
+ #define ins_wstr(t)			wins_wstr(stdscr,t)
+ #define inwstr(c)			winwstr(stdscr,c)
+-#define vid_attr(a,pair,opts)		vidattr(a)
+ #define vline_set(c,n)			wvline_set(stdscr,c,n)
+ #define wadd_wchstr(win,str)		wadd_wchnstr(win,str,-1)
+ #define waddwstr(win,wstr)		waddnwstr(win,wstr,-1)
+-#define wattr_set(win,a,p,opts) ((win)->_attrs = (((a) & ~A_COLOR) | COLOR_PAIR(p)), OK)
+ #define wget_wstr(w,t)			wgetn_wstr(w,t,-1)
+ #define wgetbkgrnd(win,wch)		(*wch = win->_bkgrnd, OK)
+ #define win_wchstr(w,c)			win_wchnstr(w,c,-1)
+Index: include/nc_alloc.h
+Prereq:  1.11 
+--- ncurses-5.4-20040208/include/nc_alloc.h	2002-07-20 13:16:40.000000000 +0000
++++ ncurses-5.4-20050319/include/nc_alloc.h	2005-01-16 00:27:35.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998 Free Software Foundation, Inc.                        *
++ * Copyright (c) 1998-2004,2005 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,7 +29,7 @@
+ /****************************************************************************
+  *  Author: Thomas E. Dickey <dickey@clark.net> 1996,1997                   *
+  ****************************************************************************/
+-/* $Id: nc_alloc.h,v 1.11 2002/07/20 13:16:40 tom Exp $ */
++/* $Id: nc_alloc.h,v 1.13 2005/01/16 00:27:35 tom Exp $ */
+ 
+ #ifndef NC_ALLOC_included
+ #define NC_ALLOC_included 1
+@@ -52,6 +52,13 @@
+ #define HAVE_LIBDBMALLOC 0
+ #endif
+ 
++#if HAVE_LIBMPATROL
++#include <mpatrol.h>    /* Memory-Patrol library */
++#else
++#undef  HAVE_LIBMPATROL
++#define HAVE_LIBMPATROL 0
++#endif
++
+ #ifndef NO_LEAKS
+ #define NO_LEAKS 0
+ #endif
+@@ -59,9 +66,9 @@
+ #if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS
+ #define HAVE_NC_FREEALL 1
+ struct termtype;
+-extern void _nc_free_and_exit(int) GCC_NORETURN;
+-extern void _nc_free_tparm(void);
+-extern void _nc_leaks_dump_entry(void);
++extern NCURSES_EXPORT(void) _nc_free_and_exit(int) GCC_NORETURN;
++extern NCURSES_EXPORT(void) _nc_free_tparm(void);
++extern NCURSES_EXPORT(void) _nc_leaks_dump_entry(void);
+ #define ExitProgram(code) _nc_free_and_exit(code)
+ #endif
+ 
+Index: include/ncurses_cfg.hin
+Prereq:  1.4 
+--- ncurses-5.4-20040208/include/ncurses_cfg.hin	2002-09-07 16:55:14.000000000 +0000
++++ ncurses-5.4-20050319/include/ncurses_cfg.hin	2005-01-02 01:26:58.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998 Free Software Foundation, Inc.                        *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -30,7 +30,7 @@
+  *  Author: Thomas E. Dickey <dickey@clark.net> 1997                        *
+  ****************************************************************************/
+ /*
+- * $Id: ncurses_cfg.hin,v 1.4 2002/09/07 16:55:14 tom Exp $
++ * $Id: ncurses_cfg.hin,v 1.7 2005/01/02 01:26:58 tom Exp $
+  *
+  * This is a template-file used to generate the "ncurses_cfg.h" file.
+  *
+@@ -59,4 +59,14 @@
+ #endif
+ #endif
+ 
++	/* On HP-UX, the C compiler doesn't grok mbstate_t without
++	   -D_XOPEN_SOURCE=500. However, this causes problems on
++	   IRIX. So, we #define mbstate_t to int in configure.in
++	   only for the C compiler if needed. */
++#ifndef __cplusplus
++#ifdef NEED_MBSTATE_T_DEF
++#define mbstate_t int
++#endif
++#endif
++
+ #endif /* NC_CONFIG_H */
+Index: include/ncurses_defs
+Prereq:  1.21 
+--- ncurses-5.4-20040208/include/ncurses_defs	2004-01-18 01:03:24.000000000 +0000
++++ ncurses-5.4-20050319/include/ncurses_defs	2005-01-28 21:11:53.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: ncurses_defs,v 1.21 2004/01/18 01:03:24 tom Exp $
++# $Id: ncurses_defs,v 1.27 2005/01/28 21:11:53 tom Exp $
+ ##############################################################################
+-# Copyright (c) 2000-2003,2004 Free Software Foundation, Inc.                #
++# Copyright (c) 2000-2004,2005 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"), #
+@@ -59,17 +59,20 @@
+ HAVE_GETOPT_H
+ HAVE_GETTIMEOFDAY
+ HAVE_GETTTYNAM
++HAVE_GPM_H
+ HAVE_GPP_BUILTIN_H
+ HAVE_GXX_BUILTIN_H
+ HAVE_HAS_KEY
+ HAVE_ISASCII
+ HAVE_ISSETUGID
++HAVE_LANGINFO_CODESET
+ HAVE_LIBC_H
+ HAVE_LIBDBMALLOC
+ HAVE_LIBDMALLOC
+ HAVE_LIBFORM
+ HAVE_LIBGPM
+ HAVE_LIBMENU
++HAVE_LIBMPATROL
+ HAVE_LIBPANEL
+ HAVE_LIMITS_H
+ HAVE_LINK
+@@ -79,7 +82,6 @@
+ HAVE_MBRLEN
+ HAVE_MBRTOWC
+ HAVE_MBTOWC
+-HAVE_MEMCCPY
+ HAVE_MENU_H
+ HAVE_MKSTEMP
+ HAVE_NANOSLEEP
+@@ -132,11 +134,13 @@
+ HAVE_VSSCANF
+ HAVE_WCTOB 
+ HAVE_WCTOMB
++HAVE_WCTYPE_H
+ HAVE_WORKING_POLL
+ HAVE_WRESIZE
+ HAVE__DOSCAN
+ MIXEDCASE_FILENAMES
+ NCURSES_EXPANDED
++NCURSES_EXT_COLORS
+ NCURSES_EXT_FUNCS
+ NCURSES_NOMACROS
+ NCURSES_NO_PADDING
+Index: include/term_entry.h
+Prereq:  1.32 
+--- ncurses-5.4-20040208/include/term_entry.h	2001-03-24 21:53:10.000000000 +0000
++++ ncurses-5.4-20050319/include/term_entry.h	2004-07-05 11:51:16.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2001,2004 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,9 +29,10 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *     and: Thomas E. Dickey                        1998-2004               *
+  ****************************************************************************/
+ 
+-/* $Id: term_entry.h,v 1.32 2001/03/24 21:53:10 tom Exp $ */
++/* $Id: term_entry.h,v 1.33 2004/07/05 11:51:16 tom Exp $ */
+ 
+ /*
+  *	term_entry.h -- interface to entry-manipulation code
+@@ -56,7 +57,7 @@
+         {
+ 	    char		*name;
+ 	    struct entry	*link;
+-	    long	line;
++	    long		line;
+         }
+ 	uses[MAX_USES];
+ 	int		ncrosslinks;
+@@ -148,9 +149,11 @@
+ /* comp_parse.c: entry list handling */
+ extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
+ extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
+-extern NCURSES_EXPORT(int) _nc_resolve_uses (bool);
++extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
++extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
+ extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
+-extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *);
++extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
++extern NCURSES_IMPEXP void NCURSES_API (*_nc_check_termtype2)(TERMTYPE *, bool);
+ 
+ /* trace_xnames.c */
+ extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
+Index: include/tic.h
+Prereq:  1.46 
+--- ncurses-5.4-20040208/include/tic.h	2003-12-27 19:05:32.000000000 +0000
++++ ncurses-5.4-20050319/include/tic.h	2004-04-03 20:22:58.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,10 +29,11 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *     and: Thomas E. Dickey 1996 on                                        *
+  ****************************************************************************/
+ 
+ /*
+- * $Id: tic.h,v 1.46 2003/12/27 19:05:32 tom Exp $
++ * $Id: tic.h,v 1.49 2004/04/03 20:22:58 tom Exp $
+  *	tic.h - Global variables and structures for the terminfo
+  *			compiler.
+  */
+@@ -108,7 +109,7 @@
+ #define DEBUG_LEVEL(n)	((n) << TRACE_SHIFT)
+ 
+ #define set_trace_level(n) \
+- 	_nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL), \
++	_nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL), \
+ 	_nc_tracing |= DEBUG_LEVEL(n)
+ 
+ #ifdef TRACE
+@@ -216,18 +217,18 @@
+ #define NOTFOUND	((struct name_table_entry *) 0)
+ 
+ /* out-of-band values for representing absent capabilities */
+-#define ABSENT_BOOLEAN		(char)(-1)	/* 255 */
++#define ABSENT_BOOLEAN		((signed char)-1)	/* 255 */
+ #define ABSENT_NUMERIC		(-1)
+ #define ABSENT_STRING		(char *)0
+ 
+ /* out-of-band values for representing cancels */
+-#define CANCELLED_BOOLEAN	(char)(-2)	/* 254 */
++#define CANCELLED_BOOLEAN	((signed char)-2)	/* 254 */
+ #define CANCELLED_NUMERIC	(-2)
+ #define CANCELLED_STRING	(char *)(-1)
+ 
+ #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
+ #define VALID_NUMERIC(s) ((s) >= 0)
+-#define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
++#define VALID_STRING(s)  ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
+ 
+ /* termcap entries longer than this may break old binaries */
+ #define MAX_TERMCAP_LENGTH	1023
+@@ -278,7 +279,7 @@
+ extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int);
+ 
+ /* comp_scan.c: decode string from readable form */
+-extern NCURSES_EXPORT(char) _nc_trans_string (char *, char *);
++extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *);
+ 
+ /* captoinfo.c: capability conversion */
+ extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const);
+Index: install-sh
+--- ncurses-5.4-20040208/install-sh	1998-12-09 15:28:30.000000000 +0000
++++ ncurses-5.4-20050319/install-sh	2001-06-22 14:37:33.000000000 +0000
+@@ -109,38 +109,39 @@
+ 	echo "install:	no input file specified"
+ 	exit 1
+ else
+-	true
++	:
+ fi
+ 
+ if [ x"$dir_arg" != x ]; then
+ 	dst=$src
+ 	src=""
+-	
++
+ 	if [ -d $dst ]; then
+ 		instcmd=:
++		chmodcmd=""
+ 	else
+-		instcmd=mkdir
++		instcmd=$mkdirprog
+ 	fi
+ else
+ 
+ # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+-# might cause directories to be created, which would be especially bad 
++# might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ 
+ 	if [ -f $src -o -d $src ]
+ 	then
+-		true
++		:
+ 	else
+ 		echo "install:  $src does not exist"
+ 		exit 1
+ 	fi
+-	
++
+ 	if [ x"$dst" = x ]
+ 	then
+ 		echo "install:	no destination specified"
+ 		exit 1
+ 	else
+-		true
++		:
+ 	fi
+ 
+ # If destination is a directory, append the input filename; if your system
+@@ -150,7 +151,7 @@
+ 	then
+ 		dst="$dst"/`basename $src`
+ 	else
+-		true
++		:
+ 	fi
+ fi
+ 
+@@ -162,8 +163,8 @@
+ 
+ # Skip lots of stat calls in the usual case.
+ if [ ! -d "$dstdir" ]; then
+-defaultIFS='	
+-'
++defaultIFS='
++	'
+ IFS="${IFS-${defaultIFS}}"
+ 
+ oIFS="${IFS}"
+@@ -182,7 +183,7 @@
+         then
+ 		$mkdirprog "${pathcomp}"
+ 	else
+-		true
++		:
+ 	fi
+ 
+ 	pathcomp="${pathcomp}/"
+@@ -193,29 +194,29 @@
+ then
+ 	$doit $instcmd $dst &&
+ 
+-	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+-	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
++	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
++	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
++	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
++	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
+ else
+ 
+ # If we're going to rename the final executable, determine the name now.
+ 
+-	if [ x"$transformarg" = x ] 
++	if [ x"$transformarg" = x ]
+ 	then
+ 		dstfile=`basename $dst`
+ 	else
+-		dstfile=`basename $dst $transformbasename | 
++		dstfile=`basename $dst $transformbasename |
+ 			sed $transformarg`$transformbasename
+ 	fi
+ 
+ # don't allow the sed command to completely eliminate the filename
+ 
+-	if [ x"$dstfile" = x ] 
++	if [ x"$dstfile" = x ]
+ 	then
+ 		dstfile=`basename $dst`
+ 	else
+-		true
++		:
+ 	fi
+ 
+ # Make a temp file name in the proper directory.
+@@ -234,15 +235,15 @@
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $instcmd $src $dsttmp" command.
+ 
+-	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+-	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+-	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+-	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
++	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
++	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
++	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
++	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
+ 
+ # Now rename the file to the real destination.
+ 
+ 	$doit $rmcmd -f $dstdir/$dstfile &&
+-	$doit $mvcmd $dsttmp $dstdir/$dstfile 
++	$doit $mvcmd $dsttmp $dstdir/$dstfile
+ 
+ fi &&
+ 
+Index: man/Makefile.in
+Prereq:  1.35 
+--- ncurses-5.4-20040208/man/Makefile.in	2003-12-20 18:41:10.000000000 +0000
++++ ncurses-5.4-20050319/man/Makefile.in	2005-01-29 19:29:52.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: Makefile.in,v 1.35 2003/12/20 18:41:10 tom Exp $
++# $Id: Makefile.in,v 1.36 2005/01/29 19:29:52 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2003,2005 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"), #
+@@ -49,6 +49,7 @@
+ all \
+ sources :	terminfo.5
+ depend :
++tags :
+ 
+ $(DESTDIR)$(mandir) :
+ 	sh $(srcdir)/../mkinstalldirs $@
+Index: man/captoinfo.1m
+Prereq:  1.17 
+--- ncurses-5.4-20040208/man/captoinfo.1m	2003-05-11 00:32:53.000000000 +0000
++++ ncurses-5.4-20050319/man/captoinfo.1m	2004-07-05 13:16:08.000000000 +0000
+@@ -1,6 +1,6 @@
+ '\" t
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2004 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            *
+@@ -27,14 +27,14 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: captoinfo.1m,v 1.17 2003/05/11 00:32:53 tom Exp $
++.\" $Id: captoinfo.1m,v 1.18 2004/07/05 13:16:08 tom Exp $
+ .TH captoinfo 1M ""
+ .ds n 5
+ .ds d @TERMINFO@
+ .SH NAME
+ \fBcaptoinfo\fR - convert a \fItermcap\fR description into a \fIterminfo\fR description
+ .SH SYNOPSIS
+-\fBcaptoinfo\fR [\fB\-v\fR\fIn\fR \fIwidth\fR]  [\fB\-V\fR] [\fB\-1\fR] [\fB\-w\fR \fIwidth\fR] \fIfile\fR . . .
++\fBcaptoinfo\fR [\fB-v\fR\fIn\fR \fIwidth\fR]  [\fB-V\fR] [\fB-1\fR] [\fB-w\fR \fIwidth\fR] \fIfile\fR . . .
+ .SH DESCRIPTION
+ \fBcaptoinfo\fR looks in \fIfile\fR for \fBtermcap\fR descriptions.  For each
+ one found, an equivalent \fBterminfo\fR description is written to standard
+@@ -47,18 +47,18 @@
+ extracted from that file.  If the environment variable \fBTERMCAP\fR is not
+ set, then the file \fB\*d\fR is read.
+ .TP 5
+-\fB\-v\fR
++\fB-v\fR
+ print out tracing information on standard error as the program runs.
+ .TP 5
+-\fB\-V\fR
++\fB-V\fR
+ print out the version of the program in use on standard error and exit.
+ .TP 5
+-\fB\-1\fR
++\fB-1\fR
+ cause the fields to print out one to a line.  Otherwise, the fields
+ will be printed several to a line to a maximum width of 60
+ characters.
+ .TP 5
+-\fB\-w\fR
++\fB-w\fR
+ change the output to \fIwidth\fR characters.
+ .SH FILES
+ .TP 20
+@@ -172,11 +172,11 @@
+ capabilities \fBmeml\fR (memory lock) and \fBmemu\fR (memory unlock).
+ These will be discarded with a warning message.
+ .SH NOTES
+-This utility is actually a link to \fItic\fR(1M), running in \fI\-I\fR mode.
+-You can use other \fItic\fR options such as \fB\-f\fR and  \fB\-x\fR.
++This utility is actually a link to \fItic\fR(1M), running in \fI-I\fR mode.
++You can use other \fItic\fR options such as \fB-f\fR and  \fB-x\fR.
+ 
+ The trace option isn't identical to SVr4's.  Under SVr4, instead of following
+-the \fB\-v\fR with a trace level n, you repeat it n times.
++the \fB-v\fR with a trace level n, you repeat it n times.
+ .SH SEE ALSO
+ \fBcurses\fR(3X), \fB@INFOCMP@\fR(1M), \fBterminfo\fR(\*n)
+ .SH AUTHOR
+Index: man/curs_add_wchstr.3x
+Prereq:  1.2 
+--- ncurses-5.4-20040208/man/curs_add_wchstr.3x	2003-12-27 18:53:41.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_add_wchstr.3x	2005-01-02 01:28:49.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
++.\" Copyright (c) 2002-2004,2005 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            *
+@@ -26,10 +26,9 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_add_wchstr.3x,v 1.2 2003/12/27 18:53:41 tom Exp $
++.\" $Id: curs_add_wchstr.3x,v 1.6 2005/01/02 01:28:49 tom Exp $
+ .TH curs_add_wchstr 3X ""
+ .SH NAME
+-.PP
+ \fBadd_wchstr\fR,
+ \fBadd_wchnstr\fR,
+ \fBwadd_wchstr\fR,
+@@ -73,7 +72,7 @@
+ they do not advance the current cursor position,
+ they do not expand other control characters to ^-escapes,
+ and they truncate the string if it crosses the right margin,
+-rather then wrapping it around to the new line.
++rather than wrapping it around to the new line.
+ .PP
+ These routines end successfully
+ on encountering a null \fIcchar_t\fR, or
+@@ -88,7 +87,7 @@
+ All these entry points are described in the XSI Curses standard, Issue 4.
+ .SH SEE ALSO
+ \fBcurses\fR(3X),
+-\fBcurs_addchstr\fR(3X)
++\fBcurs_addchstr\fR(3X),
+ \fBcurs_addwstr\fR(3X)
+ .\"#
+ .\"# The following sets edit modes for GNU EMACS
+Index: man/curs_addwstr.3x
+Prereq:  1.3 
+--- ncurses-5.4-20040208/man/curs_addwstr.3x	2003-12-27 18:51:01.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_addwstr.3x	2004-09-11 20:57:04.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
++.\" Copyright (c) 2002-2003,2004 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            *
+@@ -26,7 +26,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_addwstr.3x,v 1.3 2003/12/27 18:51:01 tom Exp $
++.\" $Id: curs_addwstr.3x,v 1.4 2004/09/11 20:57:04 tom Exp $
+ .TH curs_addwstr 3X ""
+ .SH NAME
+ \fBaddwstr\fR,
+@@ -58,7 +58,8 @@
+ \fBint mvwaddnwstr(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, const wchar_t *\fR\fIwstr\fR\fB, int \fR\fIn\fR\fB);\fR
+ .fi
+ .SH DESCRIPTION
+-These routines write the characters of the (null-terminated) \fBwchar_t\fRcharacter string
++These routines write the characters of the
++(null-terminated) \fBwchar_t\fR character string
+ \fIwstr\fR on the given window.
+ It is similar to constructing a \fBcchar_t\fR for each wchar_t in the string,
+ then calling \fBwadd_wch\fR for the resulting \fBcchar_t\fR.
+Index: man/curs_beep.3x
+Prereq:  1.9 
+--- ncurses-5.4-20040208/man/curs_beep.3x	2003-12-27 18:44:30.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_beep.3x	2005-01-08 17:55:51.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998,2003 Free Software Foundation, Inc.                   *
++.\" Copyright (c) 1998-2003,2005 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            *
+@@ -26,7 +26,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_beep.3x,v 1.9 2003/12/27 18:44:30 tom Exp $
++.\" $Id: curs_beep.3x,v 1.10 2005/01/08 17:55:51 tom Exp $
+ .TH curs_beep 3X ""
+ .SH NAME
+ \fBbeep\fR, \fBflash\fR - \fBcurses\fR bell and screen flash routines
+@@ -51,8 +51,8 @@
+ SVr4's beep and flash routines always returned \fBOK\fR, so it was not
+ possible to tell when the beep or flash failed.
+ .SH PORTABILITY
+-These functions are defined in the XSI Curses standard, Issue 4.  Like SVr4, it
+-specifies that they always return \fBOK\fR.
++These functions are described in the XSI Curses standard, Issue 4.
++Like SVr4, it specifies that they always return \fBOK\fR.
+ .SH SEE ALSO
+ \fBcurses\fR(3X)
+ .\"#
+Index: man/curs_bkgrnd.3x
+Prereq:  1.1 
+--- ncurses-5.4-20040208/man/curs_bkgrnd.3x	2002-02-23 23:23:42.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_bkgrnd.3x	2004-03-13 19:39:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 2002 Free Software Foundation, Inc.                        *
++.\" Copyright (c) 2002,2004 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            *
+@@ -26,10 +26,9 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_bkgrnd.3x,v 1.1 2002/02/23 23:23:42 tom Exp $
++.\" $Id: curs_bkgrnd.3x,v 1.2 2004/03/13 19:39:10 tom Exp $
+ .TH curs_bkgrnd 3X ""
+ .SH NAME
+-.PP
+ \fBbkgrnd\fR,
+ \fBwbkgrnd\fR,
+ \fBbkgrndset\fR,
+Index: man/curs_border_set.3x
+Prereq:  1.3 
+--- ncurses-5.4-20040208/man/curs_border_set.3x	2002-04-20 16:49:13.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_border_set.3x	2004-03-13 19:39:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 2002 Free Software Foundation, Inc.                        *
++.\" Copyright (c) 2002,2004 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            *
+@@ -26,10 +26,9 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_border_set.3x,v 1.3 2002/04/20 16:49:13 tom Exp $
++.\" $Id: curs_border_set.3x,v 1.4 2004/03/13 19:39:10 tom Exp $
+ .TH curs_border_set 3X ""
+ .SH NAME
+-.PP
+ \fBborder_set\fR,
+ \fBwborder_set\fR,
+ \fBbox_set\fR,
+Index: man/curs_color.3x
+Prereq:  1.19 
+--- ncurses-5.4-20040208/man/curs_color.3x	2002-02-16 22:38:32.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_color.3x	2005-01-29 14:34:56.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2004,2005 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            *
+@@ -26,7 +26,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_color.3x,v 1.19 2002/02/16 22:38:32 tom Exp $
++.\" $Id: curs_color.3x,v 1.24 2005/01/29 14:34:56 tom Exp $
+ .TH curs_color 3X ""
+ .SH NAME
+ \fBstart_color\fR,
+@@ -96,8 +96,10 @@
+ .TP 5
+ -
+ The value of the second and
+-third arguments must be between 0 and \fBCOLORS\fR (the 0 color pair is wired
+-to white on black and cannot be changed).
++third arguments must be between 0 and \fBCOLORS\fR.
++Color pair 0 is assumed to be white on black,
++but is actually whatever the terminal implements before color is initialized.
++It cannot be modified by the application.
+ .PP
+ If the color-pair was previously
+ initialized, the screen is refreshed and all occurrences of that color-pair
+@@ -165,6 +167,20 @@
+ All other routines return the integer \fBERR\fR upon failure and an \fBOK\fR
+ (SVr4 specifies only "an integer value other than \fBERR\fR") upon successful
+ completion.
++.PP
++X/Open defines no error conditions.
++This implementation will return \fBERR\fR on attempts to
++use color values outside the range 0 to COLORS-1
++(except for the default colors extension),
++or use color pairs outside the range 0 to COLOR_PAIR-1.
++Color values used in \fBinit_color\fP must be in the range 0 to 1000.
++.PP
++If the terminal does not support colors,
++\fBstart_color\fP returns ERR.
++If the screen has not been initialized, that is also an error.
++.PP
++An error is returned, e.g., from \fBinit_pair\fP, if \fBstart_color\fP was
++not first called.
+ .SH NOTES
+ In the \fIncurses\fR implementation, there is a separate color activation flag,
+ color palette, color pairs table, and associated COLORS and COLOR_PAIRS counts
+@@ -201,8 +217,12 @@
+ .PP
+ The assumption that \fBCOLOR_BLACK\fR is the default
+ background color for all terminals can be modified using the
+-\fBassume_default_colors\fP extension,
+-
++\fBassume_default_colors\fP extension.
++.PP
++This implementation checks the pointers,
++e.g., for the values returned by
++\fBcolor_content\fP and \fBpair_content\fP,
++and will treat those as optional parameters when null.
+ .SH SEE ALSO
+ \fBcurses\fR(3X),
+ \fBcurs_initscr\fR(3X),
+Index: man/curs_extend.3x
+Prereq:  1.12 
+--- ncurses-5.4-20040208/man/curs_extend.3x	2003-10-25 20:33:16.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_extend.3x	2004-07-05 13:16:08.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1999-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1999-2003,2004 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            *
+@@ -28,7 +28,7 @@
+ .\"
+ .\" Author: Thomas E. Dickey 1999
+ .\"
+-.\" $Id: curs_extend.3x,v 1.12 2003/10/25 20:33:16 tom Exp $
++.\" $Id: curs_extend.3x,v 1.13 2004/07/05 13:16:08 tom Exp $
+ .TH curs_extend 3X ""
+ .SH NAME
+ \fBcurses_version\fP,
+@@ -56,7 +56,7 @@
+ which may be compiled into the terminfo
+ description, i.e., via the terminfo or termcap interfaces.
+ Normally these names are available for use, since the essential decision
+-is made by using the \fB\-x\fP option of \fItic\fP to compile
++is made by using the \fB-x\fP option of \fItic\fP to compile
+ extended terminal definitions.
+ However you can disable this feature
+ to ensure compatibility with other implementations of curses.
+Index: man/curs_getch.3x
+Prereq:  1.24 
+--- ncurses-5.4-20040208/man/curs_getch.3x	2003-12-27 18:46:06.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_getch.3x	2005-01-02 01:27:47.000000000 +0000
+@@ -1,6 +1,6 @@
+ '\" t
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2005 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            *
+@@ -27,7 +27,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_getch.3x,v 1.24 2003/12/27 18:46:06 tom Exp $
++.\" $Id: curs_getch.3x,v 1.26 2005/01/02 01:27:47 tom Exp $
+ .TH curs_getch 3X ""
+ .SH NAME
+ \fBgetch\fR,
+@@ -297,7 +297,7 @@
+ \fBcurs_inopts\fR(3X),
+ \fBcurs_mouse\fR(3X),
+ \fBcurs_move\fR(3X),
+-\fBcurs_refresh\fR(3X).
++\fBcurs_refresh\fR(3X),
+ \fBresizeterm\fR(3X).
+ .\"#
+ .\"# The following sets edit modes for GNU EMACS
+Index: man/curs_in_wchstr.3x
+Prereq:  1.2 
+--- ncurses-5.4-20040208/man/curs_in_wchstr.3x	2002-05-18 21:48:30.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_in_wchstr.3x	2005-01-02 01:27:19.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 2002 Free Software Foundation, Inc.                        *
++.\" Copyright (c) 2002,2005 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            *
+@@ -26,7 +26,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_in_wchstr.3x,v 1.2 2002/05/18 21:48:30 tom Exp $
++.\" $Id: curs_in_wchstr.3x,v 1.4 2005/01/02 01:27:19 tom Exp $
+ .TH curs_in_wchstr 3X ""
+ .SH NAME
+ \fBin_wchstr\fR,
+@@ -106,7 +106,7 @@
+ .SH SEE ALSO
+ Functions:
+ \fBcurses\fR(3X),
+-\fBcurs_in_wch\fR(3X)
++\fBcurs_in_wch\fR(3X),
+ \fBcurs_instr\fR(3X),
+ \fBcurs_inwstr\fR(3X)
+ .\"#
+Index: man/curs_insstr.3x
+Prereq:  1.12 
+--- ncurses-5.4-20040208/man/curs_insstr.3x	2001-11-03 19:59:03.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_insstr.3x	2004-06-19 22:22:51.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998,2000,2001 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2001,2004 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            *
+@@ -26,7 +26,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_insstr.3x,v 1.12 2001/11/03 19:59:03 tom Exp $
++.\" $Id: curs_insstr.3x,v 1.14 2004/06/19 22:22:51 tom Exp $
+ .TH curs_insstr 3X ""
+ .SH NAME
+ \fBinsstr\fR,
+@@ -57,22 +57,18 @@
+ \fBint mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n);\fR
+ .br
+ .SH DESCRIPTION
+-These routines insert a character string (as many characters as will fit on the
+-line) before the character under the cursor.  All characters to the right of
+-the cursor are shifted right, with the possibility of the rightmost characters
+-on the line being lost.  The cursor position does not change (after moving to
+-\fIy\fR, \fIx\fR, if specified). The four routines with \fIn\fR as the last
+-argument insert a leading substring of at most \fIn\fR characters.  If
+-\fIn\fR<=0, then the entire string is inserted.
++These routines insert a character string
++(as many characters as will fit on the line)
++before the character under the cursor.
++All characters to the right of the cursor are shifted right
++with the possibility of the rightmost characters on the line being lost.
++The cursor position does not change
++(after moving to \fIy\fR, \fIx\fR, if specified).
++The functions with \fIn\fR as the last argument
++insert a leading substring of at most \fIn\fR characters.
++If \fIn\fR<=0, then the entire string is inserted.
+ 
+-If a character in \fIstr\fR is a tab, newline, carriage return or
+-backspace, the cursor is moved appropriately within the window.  A
+-newline also does a \fBclrtoeol\fR before moving.  Tabs are considered
+-to be at every eighth column.  If a character in \fIstr\fR is another
+-control character, it is drawn in the \fB^\fR\fIX\fR notation.
+-Calling \fBwinch\fR after adding a control character (and moving to
+-it, if necessary) does not return the control character, but instead
+-returns a character in the ^-representation of the control character.
++Special characters are handled as in \fBaddch\fP.
+ .SH RETURN VALUE
+ All routines that return an integer return \fBERR\fR upon failure and OK (SVr4
+ specifies only "an integer value other than \fBERR\fR") upon successful
+@@ -85,8 +81,16 @@
+ \fBEILSEQ\fR and \fBEILOVERFLOW\fR associated with extended-level conformance
+ are not yet detected (this implementation does not yet support XPG4 multibyte
+ characters).
++.LP
++The Single Unix Specification, Version 2 states that 
++\fBinsnstr\fP and \fBwinsnstr\fP perform wrapping.
++This is probably an error, since it makes this group of functions inconsistent.
++Also, no implementation of curses documents this inconsistency.
+ .SH SEE ALSO
+-\fBcurses\fR(3X), \fBcurs_clear\fR(3X), \fBcurs_inch\fR(3X).
++\fBcurses\fR(3X),
++\fBunctrl\fR(3X),
++\fBcurs_clear\fR(3X),
++\fBcurs_inch\fR(3X).
+ .\"#
+ .\"# The following sets edit modes for GNU EMACS
+ .\"# Local Variables:
+Index: man/curs_inwstr.3x
+Prereq:  1.2 
+--- ncurses-5.4-20040208/man/curs_inwstr.3x	2002-04-13 20:25:35.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_inwstr.3x	2004-03-13 19:39:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 2002 Free Software Foundation, Inc.                        *
++.\" Copyright (c) 2002,2004 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            *
+@@ -26,10 +26,9 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_inwstr.3x,v 1.2 2002/04/13 20:25:35 tom Exp $
++.\" $Id: curs_inwstr.3x,v 1.3 2004/03/13 19:39:10 tom Exp $
+ .TH curs_inwstr 3 ""
+ .SH NAME
+-.PP
+ \fBinwstr\fR,
+ \fBinnwstr\fR,
+ \fBwinwstr\fR,
+Index: man/curs_mouse.3x
+Prereq:  1.24 
+--- ncurses-5.4-20040208/man/curs_mouse.3x	2003-12-27 18:47:54.000000000 +0000
++++ ncurses-5.4-20050319/man/curs_mouse.3x	2005-02-19 20:59:40.000000000 +0000
+@@ -1,6 +1,6 @@
+ '\" t
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2005 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            *
+@@ -27,7 +27,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: curs_mouse.3x,v 1.24 2003/12/27 18:47:54 tom Exp $
++.\" $Id: curs_mouse.3x,v 1.26 2005/02/19 20:59:40 tom Exp $
+ .TH curs_mouse 3X ""
+ .SH NAME
+ \fBgetmouse\fR, \fBungetmouse\fR,
+@@ -85,7 +85,7 @@
+ setting a nonzero mask may turn it on.
+ Whether this happens is device-dependent.
+ .PP
+-Here are the mouse event type masks:
++Here are the mouse event type masks which may be defined:
+ .PP
+ .TS
+ l l
+@@ -97,26 +97,37 @@
+ BUTTON1_CLICKED	mouse button 1 clicked
+ BUTTON1_DOUBLE_CLICKED	mouse button 1 double clicked
+ BUTTON1_TRIPLE_CLICKED	mouse button 1 triple clicked
++_
+ BUTTON2_PRESSED	mouse button 2 down
+ BUTTON2_RELEASED	mouse button 2 up
+ BUTTON2_CLICKED	mouse button 2 clicked
+ BUTTON2_DOUBLE_CLICKED	mouse button 2 double clicked
+ BUTTON2_TRIPLE_CLICKED	mouse button 2 triple clicked
++_
+ BUTTON3_PRESSED	mouse button 3 down
+ BUTTON3_RELEASED	mouse button 3 up
+ BUTTON3_CLICKED	mouse button 3 clicked
+ BUTTON3_DOUBLE_CLICKED	mouse button 3 double clicked
+ BUTTON3_TRIPLE_CLICKED	mouse button 3 triple clicked
++_
+ BUTTON4_PRESSED	mouse button 4 down
+ BUTTON4_RELEASED	mouse button 4 up
+ BUTTON4_CLICKED	mouse button 4 clicked
+ BUTTON4_DOUBLE_CLICKED	mouse button 4 double clicked
+ BUTTON4_TRIPLE_CLICKED	mouse button 4 triple clicked
++_
++BUTTON5_PRESSED	mouse button 5 down
++BUTTON5_RELEASED	mouse button 5 up
++BUTTON5_CLICKED	mouse button 5 clicked
++BUTTON5_DOUBLE_CLICKED	mouse button 5 double clicked
++BUTTON5_TRIPLE_CLICKED	mouse button 5 triple clicked
++_
+ BUTTON_SHIFT	shift was down during button state change
+ BUTTON_CTRL	control was down during button state change
+ BUTTON_ALT	alt was down during button state change
+ ALL_MOUSE_EVENTS	report all button state changes
+ REPORT_MOUSE_POSITION	report mouse movement
++_
+ .TE
+ .PP
+ Once a class of mouse events have been made visible in a window,
+@@ -172,8 +183,9 @@
+ The \fBmouseinterval\fR function sets the maximum time (in thousands of a
+ second) that can elapse between press and release events for them to
+ be recognized as a click.
+-Use \fBmouseinterval(-1)\fR to disable click resolution.
++Use \fBmouseinterval(0)\fR to disable click resolution.
+ This function returns the previous interval value.
++Use \fBmouseinterval(-1)\fR to obtain the interval without altering it.
+ The default is one sixth of a second.
+ .PP
+ Note that mouse events will be ignored when input is in cooked mode, and will
+@@ -194,9 +206,22 @@
+ curses, 4.4BSD curses, or any other previous version of curses.
+ .PP
+ The feature macro \fBNCURSES_MOUSE_VERSION\fR is provided so the preprocessor
+-can be used to test whether these features are present (its value is 1).
++can be used to test whether these features are present.
+ If the interface is changed, the value of \fBNCURSES_MOUSE_VERSION\fR will be
+ incremented.
++These values for \fBNCURSES_MOUSE_VERSION\fR may be
++specified when configuring ncurses:
++.RS
++.TP 3
++1
++has definitions for reserved events.
++The mask uses 28 bits.
++.TP 3
++2
++adds definitions for button 5,
++removes the definitions for reserved events.
++The mask uses 29 bits.
++.RE
+ .PP
+ The order of the \fBMEVENT\fR structure members is not guaranteed.
+ Additional fields may be added to the structure in the future.
+Index: man/default_colors.3x
+Prereq:  1.17 
+--- ncurses-5.4-20040208/man/default_colors.3x	2003-10-25 20:41:08.000000000 +0000
++++ ncurses-5.4-20050319/man/default_colors.3x	2005-02-19 20:25:44.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2005 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            *
+@@ -26,9 +26,9 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" Author: Thomas E. Dickey 1997,1999,2000
++.\" Author: Thomas E. Dickey 1997,1999,2000,2005
+ .\"
+-.\" $Id: default_colors.3x,v 1.17 2003/10/25 20:41:08 tom Exp $
++.\" $Id: default_colors.3x,v 1.18 2005/02/19 20:25:44 tom Exp $
+ .TH default_colors 3X ""
+ .SH NAME
+ \fBuse_default_colors\fR,
+@@ -107,6 +107,26 @@
+ Associated with this extension, the \fBinit_pair\fR(3X) function accepts
+ negative arguments to specify default foreground or background
+ colors.
++.PP
++The \fIuse_default_colors()\fP function was added to support \fIded\fP.
++This is a full-screen application which uses curses to manage only part
++of the screen.  The bottom portion of the screen, which is of adjustable
++size, is left uncolored to display the results from shell commands.
++The top portion of the screen colors filenames using a scheme like the
++"color ls" programs.
++Attempting to manage the background color of the screen for this application
++would give unsatisfactory results for a variety of reasons.
++This extension was devised after
++noting that color xterm (and similar programs) provides a background color
++which does not necessarily correspond to any of the ANSI colors.
++While a special terminfo entry could be constructed using nine colors,
++there was no mechanism provided within curses to account for the related
++\fIorig_pair\fP and \fIback_color_erase\fP capabilities.
++.PP
++The \fIassume_default_colors()\fP function was added to solve
++a different problem: support for applications which would use
++environment variables and other configuration to bypass curses'
++notion of the terminal's default colors, setting specific values.
+ .SH PORTABILITY
+ These routines are specific to ncurses.  They were not supported on
+ Version 7, BSD or System V implementations.  It is recommended that
+Index: man/define_key.3x
+Prereq:  1.10 
+--- ncurses-5.4-20040208/man/define_key.3x	2003-10-25 20:33:16.000000000 +0000
++++ ncurses-5.4-20050319/man/define_key.3x	2004-06-05 19:20:03.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2004 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            *
+@@ -28,7 +28,7 @@
+ .\"
+ .\" Author: Thomas E. Dickey 1997
+ .\"
+-.\" $Id: define_key.3x,v 1.10 2003/10/25 20:33:16 tom Exp $
++.\" $Id: define_key.3x,v 1.11 2004/06/05 19:20:03 tom Exp $
+ .TH define_key 3X ""
+ .SH NAME
+ \fBdefine_key\fP \- define a keycode
+@@ -53,7 +53,8 @@
+ Version 7, BSD or System V implementations.  It is recommended that
+ any code depending on them be conditioned using NCURSES_VERSION.
+ .SH SEE ALSO
+-\fBkeyok\fR(3X).
++\fBkeyok\fR(3X),
++\fBkey_defined\fR(3X).
+ .SH AUTHOR
+ Thomas Dickey.
+ .\"#
+Index: man/form_field_buffer.3x
+Prereq:  1.10 
+--- ncurses-5.4-20040208/man/form_field_buffer.3x	2003-05-10 20:22:01.000000000 +0000
++++ ncurses-5.4-20050319/man/form_field_buffer.3x	2004-05-16 15:58:51.000000000 +0000
+@@ -1,6 +1,6 @@
+ '\" t
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2004 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            *
+@@ -27,7 +27,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: form_field_buffer.3x,v 1.10 2003/05/10 20:22:01 tom Exp $
++.\" $Id: form_field_buffer.3x,v 1.11 2004/05/16 15:58:51 tom Exp $
+ .TH form_field_buffer 3X ""
+ .SH NAME
+ \fBform_field_buffer\fR - field buffer control
+@@ -84,6 +84,12 @@
+ descriptions of the entry points.
+ .SH NOTES
+ The header file \fB<form.h>\fR automatically includes the header file
++
++When configured for wide-characters, \fBfield_buffer\fP returns a pointer
++to temporary storage (allocated and freed by the library).
++The application should not attempt to modify the data.
++It will be freed on the next call to \fBfield_buffer\fP to return the
++same buffer.
+ \fB<curses.h>\fR.
+ .SH PORTABILITY
+ These routines emulate the System V forms library.  They were not supported on
+Index: man/infocmp.1m
+Prereq:  1.34 
+--- ncurses-5.4-20040208/man/infocmp.1m	2003-10-25 16:19:01.000000000 +0000
++++ ncurses-5.4-20050319/man/infocmp.1m	2004-08-28 22:43:49.000000000 +0000
+@@ -1,6 +1,6 @@
+ '\" t
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2004 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            *
+@@ -27,14 +27,14 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: infocmp.1m,v 1.34 2003/10/25 16:19:01 tom Exp $
++.\" $Id: infocmp.1m,v 1.39 2004/08/28 22:43:49 tom Exp $
+ .TH infocmp 1M ""
+ .ds n 5
+ .ds d @TERMINFO@
+ .SH NAME
+ \fBinfocmp\fR - compare or print out \fIterminfo\fR descriptions
+ .SH SYNOPSIS
+-\fBinfocmp\fR [\fB\-\
++\fBinfocmp\fR [\fB-\
+ 1\
+ C\
+ E\
+@@ -56,11 +56,12 @@
+ r\
+ t\
+ u\
++x\
+ \fR]
+ .br
+-      [\fB\-v\fR \fIn\fR] [\fB\-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] [\fB\-R \fR\fBsubset\fR]
++      [\fB-v\fR \fIn\fR] [\fB-s d\fR| \fBi\fR| \fBl\fR| \fBc\fR] [\fB-R \fR\fBsubset\fR]
+ .br
+-      [\fB\-w\fR\ \fIwidth\fR] [\fB\-A\fR\ \fIdirectory\fR] [\fB\-B\fR\ \fIdirectory\fR]
++      [\fB-w\fR\ \fIwidth\fR] [\fB-A\fR\ \fIdirectory\fR] [\fB-B\fR\ \fIdirectory\fR]
+ .br
+       [\fItermname\fR...]
+ .SH DESCRIPTION
+@@ -72,9 +73,9 @@
+ string fields.
+ .SS Default Options
+ If no options are specified and zero or one \fItermnames\fR are specified, the
+-\fB\-I\fR option will be assumed.  If more than one \fItermname\fR is specified,
+-the \fB\-d\fR option will be assumed.
+-.SS Comparison Options [\-d] [\-c] [\-n]
++\fB-I\fR option will be assumed.  If more than one \fItermname\fR is specified,
++the \fB-d\fR option will be assumed.
++.SS Comparison Options [-d] [-c] [-n]
+ \fBinfocmp\fR compares the \fBterminfo\fR description of the first terminal
+ \fItermname\fR with each of the descriptions given by the entries for the other
+ terminal's \fItermnames\fR.  If a capability is defined for only one of the
+@@ -82,35 +83,35 @@
+ \fBF\fR for boolean variables, \fB-1\fR for integer variables, and \fBNULL\fR
+ for string variables.
+ 
+-The \fB\-d\fR option produces a list of each capability that is different
++The \fB-d\fR option produces a list of each capability that is different
+ between two entries.  This option is useful to show the difference between two
+ entries, created by different people, for the same or similar terminals.
+ 
+-The \fB\-c\fR option produces a list of each capability that is common between
++The \fB-c\fR option produces a list of each capability that is common between
+ two entries.  Capabilities that are not set are ignored.  This option can be
+-used as a quick check to see if the \fB\-u\fR option is worth using.
++used as a quick check to see if the \fB-u\fR option is worth using.
+ 
+-The \fB\-n\fR option produces a list of each capability that is in neither
++The \fB-n\fR option produces a list of each capability that is in neither
+ entry.  If no \fItermnames\fR are given, the environment variable \fBTERM\fR
+ will be used for both of the \fItermnames\fR.  This can be used as a quick
+ check to see if anything was left out of a description.
+-.SS Source Listing Options [\-I] [\-L] [\-C] [\-r]
+-The \fB\-I\fR, \fB\-L\fR, and \fB\-C\fR options will produce a source listing for
++.SS Source Listing Options [-I] [-L] [-C] [-r]
++The \fB-I\fR, \fB-L\fR, and \fB-C\fR options will produce a source listing for
+ each terminal named.
+ 
+ .TS
+ center tab(/) ;
+ l l .
+-\fB\-I\fR/use the \fBterminfo\fR names
+-\fB\-L\fR/use the long C variable name listed in <\fBterm.h\fR>
+-\fB\-C\fR/use the \fBtermcap\fR names
+-\fB\-r\fR/when using \fB\-C\fR, put out all capabilities in \fBtermcap\fR form
++\fB-I\fR/use the \fBterminfo\fR names
++\fB-L\fR/use the long C variable name listed in <\fBterm.h\fR>
++\fB-C\fR/use the \fBtermcap\fR names
++\fB-r\fR/when using \fB-C\fR, put out all capabilities in \fBtermcap\fR form
+ .TE
+ 
+ If no \fItermnames\fR are given, the environment variable \fBTERM\fR will be
+ used for the terminal name.
+ 
+-The source produced by the \fB\-C\fR option may be used directly as a
++The source produced by the \fB-C\fR option may be used directly as a
+ \fBtermcap\fR entry, but not all parameterized strings can be changed to
+ the \fBtermcap\fR format.  \fBinfocmp\fR will attempt to convert most of the
+ parameterized information, and anything not converted will be plainly marked in
+@@ -123,7 +124,7 @@
+ All \fBtermcap\fR variables no longer supported by \fBterminfo\fR, but which
+ are derivable from other \fBterminfo\fR variables, will be output.  Not all
+ \fBterminfo\fR capabilities will be translated; only those variables which were
+-part of \fBtermcap\fR will normally be output.  Specifying the \fB\-r\fR option
++part of \fBtermcap\fR will normally be output.  Specifying the \fB-r\fR option
+ will take off this restriction, allowing all capabilities to be output in
+ \fItermcap\fR form.
+ 
+@@ -151,8 +152,8 @@
+ \fB%p1%?%'x'%>%t%p1%'y'%+%;/%>xy\fR/concept
+ \fB%p2\fR is printed before \fB%p1/%r\fR/hp
+ .TE
+-.SS Use= Option [\-u]
+-The \fB\-u\fR option produces a \fBterminfo\fR source description of the first
++.SS Use= Option [-u]
++The \fB-u\fR option produces a \fBterminfo\fR source description of the first
+ terminal \fItermname\fR which is relative to the sum of the descriptions given
+ by the entries for the other terminals \fItermnames\fR.  It does this by
+ analyzing the differences between the first \fItermname\fR and the other
+@@ -187,29 +188,29 @@
+ the compilation time, is specifying extra \fBuse=\fR fields that are
+ superfluous.  \fBinfocmp\fR will flag any other \fItermname use=\fR fields that
+ were not needed.
+-.SS Changing Databases [\-A \fIdirectory\fR] [\-B \fIdirectory\fR]
++.SS Changing Databases [-A \fIdirectory\fR] [-B \fIdirectory\fR]
+ The location of the compiled \fBterminfo\fR database is taken from the
+ environment variable \fBTERMINFO\fR .  If the variable is not defined, or the
+ terminal is not found in that location, the system \fBterminfo\fR database,
+-in \fB@TERMINFO@\fR, will be used.  The options \fB\-A\fR
+-and \fB\-B\fR may be used to override this location.  The \fB\-A\fR option will
+-set \fBTERMINFO\fR for the first \fItermname\fR and the \fB\-B\fR option will
++in \fB@TERMINFO@\fR, will be used.  The options \fB-A\fR
++and \fB-B\fR may be used to override this location.  The \fB-A\fR option will
++set \fBTERMINFO\fR for the first \fItermname\fR and the \fB-B\fR option will
+ set \fBTERMINFO\fR for the other \fItermnames\fR.  With this, it is possible to
+ compare descriptions for a terminal with the same name located in two different
+ databases.  This is useful for comparing descriptions for the same terminal
+ created by different people.
+ .SS Other Options
+ .TP 5
+-\fB\-1\fR
++\fB-1\fR
+ causes the fields to be printed out one to a line.  Otherwise,
+ the fields will be printed several to a line to a maximum width
+ of 60 characters.
+ .TP
+-\fB\-a\fR
++\fB-a\fR
+ tells \fBinfocmp\fP to retain commented-out capabilities rather than discarding
+ them.  Capabilities are commented by prefixing them with a period.
+ .TP 5
+-\fB\-E\fR
++\fB-E\fR
+ Dump the capabilities of the given terminal as tables, needed in
+ the C initializer for a
+ TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fR).
+@@ -218,17 +219,17 @@
+ The tables are all declared static, and are named according to the type
+ and the name of the corresponding terminal entry.
+ .sp
+-Before ncurses 5.0, the split between the \fB\-e\fP and \fB\-E\fP
++Before ncurses 5.0, the split between the \fB-e\fP and \fB-E\fP
+ options was not needed; but support for extended names required making
+ the arrays of terminal capabilities separate from the TERMTYPE structure.
+ .TP 5
+-\fB\-e\fR
++\fB-e\fR
+ Dump the capabilities of the given terminal as a C initializer for a
+ TERMTYPE structure (the terminal capability structure in the \fB<term.h>\fR).
+ This option is useful for preparing versions of the curses library hardwired
+ for a given terminal type.
+ .TP 5
+-\fB\-F\fR
++\fB-F\fR
+ compare terminfo files.  This assumes that two following arguments are
+ filenames.  The files are searched for pairwise matches between
+ entries, with two entries considered to match if any of their names do.
+@@ -237,21 +238,21 @@
+ with exactly one match it includes a difference report.  Normally,
+ to reduce the volume of the report, use references are
+ not resolved before looking for differences, but resolution can be forced
+-by also specifying \fB\-r\fR.
++by also specifying \fB-r\fR.
+ .TP 5
+-\fB\-f\fR
++\fB-f\fR
+ Display complex terminfo strings which contain if/then/else/endif expressions
+ indented for readability.
+ .TP 5
+-\fB\-G\fR
++\fB-G\fR
+ Display constant literals in decimal form
+ rather than their character equivalents.
+ .TP 5
+-\fB\-g\fR
++\fB-g\fR
+ Display constant character literals in quoted form
+ rather than their decimal equivalents.
+ .TP 5
+-\fB\-i\fR
++\fB-i\fR
+ Analyze the initialization (\fBis1\fR, \fBis2\fR, \fBis3\fR), and reset
+ (\fBrs1\fR, \fBrs2\fR, \fBrs3\fR), strings in the entry.  For each string, the
+ code tries to analyze it into actions in terms of the other capabilities in the
+@@ -275,6 +276,9 @@
+ LL/home-down
+ RSR/reset scroll region
+ 
++DECSTR/soft reset (VT320)
++S7C1T/7-bit controls (VT220)
++
+ ISO DEC G0/enable DEC graphics for G0
+ ISO UK G0/enable UK chars for G0
+ ISO US G0/enable US chars for G0
+@@ -286,6 +290,11 @@
+ DECPNM/normal keypad mode
+ DECANSI/enter ANSI mode
+ 
++ECMA[+-]AM/keyboard action mode
++ECMA[+-]IRM/insert replace mode
++ECMA[+-]SRM/send receive mode
++ECMA[+-]LNM/linefeed mode
++
+ DEC[+-]CKM/application cursor keys
+ DEC[+-]ANM/set VT52 mode
+ DEC[+-]COLM/132-column mode
+@@ -302,17 +311,17 @@
+ 
+ An SGR0 designates an empty highlight sequence (equivalent to {SGR:NORMAL}).
+ .TP 5
+-\fB\-l\fR
++\fB-l\fR
+ Set output format to terminfo.
+ .TP 5
+-\fB\-p\fR
++\fB-p\fR
+ Ignore padding specifications when comparing strings.
+ .TP 5
+-\fB\-q\fR
++\fB-q\fR
+ Make the comparison listing shorter by omitting subheadings, and using
+ "-" for absent capabilities, "@" for canceled rather than "NULL".
+ .TP 5
+-\fB\-R\fR\fIsubset\fR
++\fB-R\fR\fIsubset\fR
+ Restrict output to a given subset.  This option is for use with archaic
+ versions of terminfo like those on SVr1, Ultrix, or HP/UX that do not support
+ the full set of SVR4/XSI Curses terminfo; and variants such as AIX
+@@ -321,8 +330,8 @@
+ details.  You can also choose the subset "BSD" which selects only capabilities
+ with termcap equivalents recognized by 4.4BSD.
+ .TP
+-\fB\-s \fR\fI[d|i|l|c]\fR
+-The \fB\-s\fR option sorts the fields within each type according to the argument
++\fB-s \fR\fI[d|i|l|c]\fR
++The \fB-s\fR option sorts the fields within each type according to the argument
+ below:
+ .br
+ .RS 5
+@@ -340,59 +349,64 @@
+ sort by the \fItermcap\fR name.
+ .RE
+ .IP
+-If the \fB\-s\fR option is not given, the fields printed out will be
++If the \fB-s\fR option is not given, the fields printed out will be
+ sorted alphabetically by the \fBterminfo\fR name within each type,
+-except in the case of the \fB\-C\fR or the \fB\-L\fR options, which cause the
++except in the case of the \fB-C\fR or the \fB-L\fR options, which cause the
+ sorting to be done by the \fBtermcap\fR name or the long C variable
+ name, respectively.
+ .TP 5
+-\fB\-T\fR
++\fB-T\fR
+ eliminates size-restrictions on the generated text.
+ This is mainly useful for testing and analysis, since the compiled
+ descriptions are limited (e.g., 1023 for termcap, 4096 for terminfo).
+ .TP
+-\fB\-t\fR
++\fB-t\fR
+ tells \fBtic\fP to discard commented-out capabilities.
+ Normally when translating from terminfo to termcap,
+ untranslatable capabilities are commented-out.
+ .TP 5
+-\fB\-V\fR
++\fB-V\fR
+ reports the version of ncurses which was used in this program, and exits.
+ .TP 5
+-\fB\-v\fR \fIn\fR
++\fB-v\fR \fIn\fR
+ prints out tracing information on standard error as the program runs.
+ Higher values of n induce greater verbosity.
+ .TP 5
+-\fB\-w\fR \fIwidth\fR
++\fB-w\fR \fIwidth\fR
+ changes the output to \fIwidth\fR characters.
++.TP
++\fB-x\fR
++print information for user-defined capabilities.
++These are extensions to the terminfo repertoire which can be loaded
++using the \fB-x\fR option of \fBtic\fP.
+ .SH FILES
+ .TP 20
+ \*d
+ Compiled terminal description database.
+ .SH EXTENSIONS
+ The
+-\fB\-E\fR,
+-\fB\-F\fR,
+-\fB\-G\fR,
+-\fB\-R\fR,
+-\fB\-T\fR,
+-\fB\-V\fR,
+-\fB\-a\fR,
+-\fB\-e\fR,
+-\fB\-f\fR,
+-\fB\-g\fR,
+-\fB\-i\fR,
+-\fB\-l\fR,
+-\fB\-p\fR,
+-\fB\-q\fR and
+-\fB\-t\fR
++\fB-E\fR,
++\fB-F\fR,
++\fB-G\fR,
++\fB-R\fR,
++\fB-T\fR,
++\fB-V\fR,
++\fB-a\fR,
++\fB-e\fR,
++\fB-f\fR,
++\fB-g\fR,
++\fB-i\fR,
++\fB-l\fR,
++\fB-p\fR,
++\fB-q\fR and
++\fB-t\fR
+ options are not supported in SVr4 curses.
+ 
+-The \fB\-r\fR option's notion of `termcap' capabilities is System V Release 4's.
++The \fB-r\fR option's notion of `termcap' capabilities is System V Release 4's.
+ Actual BSD curses versions will have a more restricted set.  To see only the
+-4.4BSD set, use \fB\-r\fR \fB\-RBSD\fR.
++4.4BSD set, use \fB-r\fR \fB-RBSD\fR.
+ .SH BUGS
+-The \fB\-F\fR option of \fBinfocmp\fR(1M) should be a \fBtoe\fR(1M) mode.
++The \fB-F\fR option of \fBinfocmp\fR(1M) should be a \fBtoe\fR(1M) mode.
+ .SH SEE ALSO
+ \fBinfocmp\fR(1M), \fBcaptoinfo\fR(1M), \fBinfotocap\fR(1M),
+ \fBtic\fR(1M), \fBtoe\fR(1M),
+Index: man/infotocap.1m
+Prereq:  1.4 
+--- ncurses-5.4-20040208/man/infotocap.1m	2003-05-11 00:32:53.000000000 +0000
++++ ncurses-5.4-20050319/man/infotocap.1m	2004-07-05 13:16:08.000000000 +0000
+@@ -1,6 +1,6 @@
+ '\" t
+ .\"***************************************************************************
+-.\" Copyright (c) 1999-2000,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1999-2003,2004 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            *
+@@ -27,40 +27,40 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: infotocap.1m,v 1.4 2003/05/11 00:32:53 tom Exp $
++.\" $Id: infotocap.1m,v 1.5 2004/07/05 13:16:08 tom Exp $
+ .TH infotocap 1M ""
+ .ds n 5
+ .ds d @TERMINFO@
+ .SH NAME
+ \fBinfotocap\fR - convert a \fIterminfo\fR description into a \fItermcap\fR description
+ .SH SYNOPSIS
+-\fBinfotocap\fR [\fB\-v\fR\fIn\fR \fIwidth\fR]  [\fB\-V\fR] [\fB\-1\fR] [\fB\-w\fR \fIwidth\fR] \fIfile\fR . . .
++\fBinfotocap\fR [\fB-v\fR\fIn\fR \fIwidth\fR]  [\fB-V\fR] [\fB-1\fR] [\fB-w\fR \fIwidth\fR] \fIfile\fR . . .
+ .SH DESCRIPTION
+ \fBinfotocap\fR looks in \fIfile\fR for \fBterminfo\fR descriptions.  For each
+ one found, an equivalent \fBtermcap\fR description is written to standard
+ output.  Terminfo \fBuse\fR capabilities are translated directly to termcap
+ \fBtc\fR capabilities.
+ .TP 5
+-\fB\-v\fR
++\fB-v\fR
+ print out tracing information on standard error as the program runs.
+ .TP 5
+-\fB\-V\fR
++\fB-V\fR
+ print out the version of the program in use on standard error and exit.
+ .TP 5
+-\fB\-1\fR
++\fB-1\fR
+ cause the fields to print out one to a line.  Otherwise, the fields
+ will be printed several to a line to a maximum width of 60
+ characters.
+ .TP 5
+-\fB\-w\fR
++\fB-w\fR
+ change the output to \fIwidth\fR characters.
+ .SH FILES
+ .TP 20
+ \*d
+ Compiled terminal description database.
+ .SH NOTES
+-This utility is actually a link to \fItic\fR(1M), running in \fI\-C\fR mode.
+-You can use other \fItic\fR options such as \fB\-f\fR and  \fB\-x\fR.
++This utility is actually a link to \fItic\fR(1M), running in \fI-C\fR mode.
++You can use other \fItic\fR options such as \fB-f\fR and  \fB-x\fR.
+ .SH SEE ALSO
+ \fBcurses\fR(3X),
+ \fBtic\fR(1M),
+Index: man/key_defined.3x
+Prereq:  1.2 
+--- ncurses-5.4-20040208/man/key_defined.3x	2003-05-17 23:24:45.000000000 +0000
++++ ncurses-5.4-20050319/man/key_defined.3x	2004-06-05 19:19:09.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 2003 Free Software Foundation, Inc.                        *
++.\" Copyright (c) 2003,2004 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            *
+@@ -28,10 +28,10 @@
+ .\"
+ .\" Author: Thomas E. Dickey 2003
+ .\"
+-.\" $Id: key_defined.3x,v 1.2 2003/05/17 23:24:45 tom Exp $
++.\" $Id: key_defined.3x,v 1.3 2004/06/05 19:19:09 tom Exp $
+ .TH key_defined 3X ""
+ .SH NAME
+-\fBdefine_key\fP \- define a keycode
++\fBkey_defined\fP \- check if a keycode is defined
+ .SH SYNOPSIS
+ \fB#include <curses.h>\fP
+ 
+Index: man/menu_spacing.3x
+Prereq:  1.6 
+--- ncurses-5.4-20040208/man/menu_spacing.3x	2001-08-04 20:36:16.000000000 +0000
++++ ncurses-5.4-20050319/man/menu_spacing.3x	2004-12-11 23:39:07.000000000 +0000
+@@ -1,6 +1,6 @@
+ '\" t
+ .\"***************************************************************************
+-.\" Copyright (c) 1998,2001 Free Software Foundation, Inc.                   *
++.\" Copyright (c) 1998-2001,2004 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            *
+@@ -27,7 +27,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: menu_spacing.3x,v 1.6 2001/08/04 20:36:16 William.Setzer Exp $
++.\" $Id: menu_spacing.3x,v 1.8 2004/12/11 23:39:07 tom Exp $
+ .TH menu_spacing 3X ""
+ .SH NAME
+ \fBmenu_spacing\fR - Control spacing between menu items.
+@@ -51,7 +51,7 @@
+ middle of this spacing area the pad character. The remaining parts are filled with
+ spaces.
+ \fBspc_rows\fR controls the number of rows that are used for an item. It must not be
+-larger than 3. The menu system inserts then blank lines between item rows, these lines
++larger than 3. The menu system inserts the blank lines between item rows, these lines
+ will contain the pad character in the appropriate positions.
+ \fBspc_columns\fR controls the number of blanks between columns of items. It must not
+ be larger than TABSIZE.
+Index: man/ncurses.3x
+Prereq:  1.70 
+--- ncurses-5.4-20040208/man/ncurses.3x	2004-01-11 01:45:54.000000000 +0000
++++ ncurses-5.4-20050319/man/ncurses.3x	2005-03-12 19:45:57.000000000 +0000
+@@ -1,6 +1,6 @@
+ '\" t
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2004,2005 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            *
+@@ -27,7 +27,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: ncurses.3x,v 1.70 2004/01/11 01:45:54 tom Exp $
++.\" $Id: ncurses.3x,v 1.74 2005/03/12 19:45:57 tom Exp $
+ .hy 0
+ .TH ncurses 3X ""
+ .ds n 5
+@@ -677,6 +677,13 @@
+ If your application makes heavy use of multiple-clicking, you may
+ wish to lengthen this default value because the timeout applies
+ to the composed multi-click event as well as the individual clicks.
++.IP
++In addition to the environment variable,
++this implementation provides a global variable with the same name.
++Portable applications should not rely upon the presence of ESCDELAY
++in either form,
++but setting the environment variable rather than the global variable
++does not create problems when compiling an application.
+ .TP 5
+ HOME
+ Tells \fBncurses\fR where your home directory is.
+@@ -750,6 +757,24 @@
+ disables output buffering, leaving the output in the original (usually
+ line buffered) mode.
+ .TP 5
++NCURSES_NO_UTF8_ACS
++During initialization, the \fBncurses\fR library
++checks for special cases where VT100 line-drawing (and the corresponding
++alternate character set capabilities) described in the terminfo are known
++to be missing.
++Specifically, when running in a UTF-8 locale,
++the Linux console emulator and the GNU screen program ignore these.
++Ncurses checks the TERM environment variable for these.
++For other special cases, you should set this environment variable.
++Doing this tells ncurses to use Unicode values which correspond to
++the VT100 line-drawing glyphs.
++That works for the special cases cited,
++and is likely to work for terminal emulators.
++.IP
++When setting this variable, you should set it to a nonzero value.
++Setting it to zero (or to a nonnumber)
++disables the special check for Linux and screen.
++.TP 5
+ NCURSES_TRACE
+ During initialization, the \fBncurses\fR debugging library
+ checks the NCURSES_TRACE symbol.
+@@ -828,7 +853,7 @@
+ \fBterminfo\fR(\*n) and related pages whose names begin "curs_" for detailed routine
+ descriptions.
+ .SH EXTENSIONS
+-The \fBncurses\fR library can be compiled with an option (\fB\-DUSE_GETCAP\fR)
++The \fBncurses\fR library can be compiled with an option (\fB-DUSE_GETCAP\fR)
+ that falls back to the old-style /etc/termcap file if the terminal setup code
+ cannot find a terminfo entry corresponding to \fBTERM\fR.  Use of this feature
+ is not recommended, as it essentially includes an entire termcap compiler in
+Index: man/term.5
+Prereq:  1.15 
+--- ncurses-5.4-20040208/man/term.5	2003-05-10 20:33:49.000000000 +0000
++++ ncurses-5.4-20050319/man/term.5	2004-07-05 13:16:08.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2004 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            *
+@@ -26,7 +26,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: term.5,v 1.15 2003/05/10 20:33:49 jmc Exp $
++.\" $Id: term.5,v 1.16 2004/07/05 13:16:08 tom Exp $
+ .TH TERM 5
+ .ds n 5
+ .ds d @TERMINFO@
+@@ -83,7 +83,7 @@
+ The first byte contains the least significant 8 bits of the value,
+ and the second byte contains the most significant 8 bits.
+ (Thus, the value represented is 256*second+first.)
+-The value \-1 is represented by the two bytes 0377, 0377; other negative
++The value -1 is represented by the two bytes 0377, 0377; other negative
+ values are illegal. This value generally
+ means that the corresponding capability is missing from this terminal.
+ Note that this format corresponds to the hardware of the \s-1VAX\s+1
+@@ -112,11 +112,11 @@
+ The numbers section is similar to the flags section.
+ Each capability takes up two bytes,
+ and is stored as a little-endian short integer.
+-If the value represented is \-1, the capability is taken to be missing.
++If the value represented is -1, the capability is taken to be missing.
+ .PP
+ The strings section is also similar.
+ Each capability is stored as a short integer, in the format above.
+-A value of \-1 means the capability is missing.
++A value of -1 means the capability is missing.
+ Otherwise, the value is taken as an offset from the beginning
+ of the string table.
+ Special characters in ^X or \ec notation are stored in their
+Index: man/terminfo.head
+Prereq:  1.10 
+--- ncurses-5.4-20040208/man/terminfo.head	2002-08-17 23:37:10.000000000 +0000
++++ ncurses-5.4-20050319/man/terminfo.head	2004-09-25 19:07:11.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2000,2002 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2002,2004 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            *
+@@ -26,7 +26,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: terminfo.head,v 1.10 2002/08/17 23:37:10 tom Exp $
++.\" $Id: terminfo.head,v 1.12 2004/09/25 19:07:11 tom Exp $
+ .TH TERMINFO 5 "" "" "File Formats"
+ .ds n 5
+ .ds d @TERMINFO@
+@@ -59,6 +59,16 @@
+ All names but the last should be in lower case and contain no blanks;
+ the last name may well contain upper case and blanks for readability.
+ .PP
++Lines beginning with a `#' in the first column are treated as comments.
++While comment lines are legal at any point, the output of \fIcaptoinfo\fP
++and \fIinfotocap\fP (aliases for \fItic\fP)
++will move comments so they occur only between entries.
++.PP
++Newlines and leading tabs may be used for formatting entries for readability.
++These are removed from parsed entries.
++The \fIinfocmp\ -f\fP option relies on this to format if-then-else expressions:
++the result can be read by \fItic\fP.
++.PP
+ Terminal names (except for the last, verbose entry) should
+ be chosen using the following conventions.
+ The particular piece of hardware making up the terminal should
+Index: man/terminfo.tail
+Prereq:  1.38 
+--- ncurses-5.4-20040208/man/terminfo.tail	2003-01-05 22:47:05.000000000 +0000
++++ ncurses-5.4-20050319/man/terminfo.tail	2004-07-05 13:08:56.000000000 +0000
+@@ -1,5 +1,6 @@
+-.\" $Id: terminfo.tail,v 1.38 2003/01/05 22:47:05 tom Exp $
++.\" $Id: terminfo.tail,v 1.41 2004/07/05 13:08:56 tom Exp $
+ .\" Beginning of terminfo.tail file
++.\" See "terminfo.head" for copyright.
+ .ps +1
+ .PP
+ .SS A Sample Entry
+@@ -271,22 +272,22 @@
+ .DT
+ .nf
+ .ft CW
+-.in -7
+-	\s-133\||\|tty33\||\|tty\||\|model 33 teletype,
++.\".in -2
++\s-133\||\|tty33\||\|tty\||\|model 33 teletype,
+ 	bel=^G, cols#72, cr=^M, cud1=^J, hc, ind=^J, os,\s+1
+-.in +7
++.\".in +2
+ .ft R
+ .PP
+-while the Lear Siegler \s-1ADM\-3\s0 is described as
++while the Lear Siegler \s-1ADM-3\s0 is described as
+ .PP
+ .DT
+ .nf
+ .ft CW
+-.in -7
+-	\s-1adm3\||\|3\||\|lsi adm3,
++.\".in -2
++\s-1adm3\||\|3\||\|lsi adm3,
+ 	am, bel=^G, clear=^Z, cols#80, cr=^M, cub1=^H, cud1=^J,
+ 	ind=^J, lines#24,\s+1
+-.in +7
++.\".in +2
+ .ft R
+ .fi
+ .PP
+@@ -380,12 +381,24 @@
+ add 1 to first two parameters (for ANSI terminals)
+ .TP
+ %? \fIexpr\fP %t \fIthenpart\fP %e \fIelsepart\fP %;
+-if-then-else, %e \fIelsepart\fP is optional.
+-else-if's are possible a la Algol 68:
+-.br
++This forms an if-then-else.
++The %e \fIelsepart\fP is optional.
++Usually the %? \fIexpr\fP part pushes a value onto the stack,
++and %t pops it from the stack, testing if it is nonzero (true).
++If it is zero (false), control passes to the %e (else) part.
++.IP
++It is possible to form else-if's a la Algol 68:
++.RS
+ %? c\d1\u %t b\d1\u %e c\d2\u %t b\d2\u %e c\d3\u %t b\d3\u %e c\d4\u %t b\d4\u %e %;
+-.br
+-c\di\u are conditions, b\di\u are bodies.
++.RE
++.IP
++where c\di\u are conditions, b\di\u are bodies.
++.IP
++Use the \fB-f\fP option of \fBtic\fP or \fBinfocmp\fP to see
++the structure of if-the-else's.
++Some strings, e.g., \fBsgr\fP can be very complicated when written
++on one line.
++The \fB-f\fP option splits the string into lines with the parts indented.
+ .PP
+ Binary operations are in postfix form with the operands in the usual order.
+ That is, to get x-5 one would use "%gx%{5}%-".
+@@ -801,6 +814,12 @@
+ .fi
+ .PP
+ Remember that if you specify sgr, you must also specify sgr0.
++Also, some implementations rely on sgr being given if sgr0 is,
++Not all terminfo entries necessarily have an sgr string, however.
++Many terminfo entries are derived from termcap entries
++which have no sgr string.
++The only drawback to adding an sgr string is that termcap also
++assumes that sgr0 does not exit alternate character set mode.
+ .PP
+ Terminals with the ``magic cookie'' glitch
+ .RB ( xmc )
+@@ -1479,18 +1498,18 @@
+ .SS Pitfalls of Long Entries
+ .PP
+ Long terminfo entries are unlikely to be a problem; to date, no entry has even
+-approached terminfo's 4K string-table maximum.
++approached terminfo's 4096-byte string-table maximum.
+ Unfortunately, the termcap
+-translations are much more strictly limited (to 1K), thus termcap translations
++translations are much more strictly limited (to 1023 bytes), thus termcap translations
+ of long terminfo entries can cause problems.
+ .PP
+-The man pages for 4.3BSD and older versions of tgetent() instruct the user to
+-allocate a 1K buffer for the termcap entry.
++The man pages for 4.3BSD and older versions of \fBtgetent()\fP instruct the user to
++allocate a 1024-byte buffer for the termcap entry.
+ The entry gets null-terminated by
+ the termcap library, so that makes the maximum safe length for a termcap entry
+ 1k-1 (1023) bytes.
+ Depending on what the application and the termcap library
+-being used does, and where in the termcap file the terminal type that tgetent()
++being used does, and where in the termcap file the terminal type that \fBtgetent()\fP
+ is searching for is, several bad things can happen.
+ .PP
+ Some termcap libraries print a warning message or exit if they find an
+@@ -1511,7 +1530,7 @@
+ affects more than just users of that particular terminal.
+ This is the
+ length of the entry as it exists in /etc/termcap, minus the
+-backslash-newline pairs, which tgetent() strips out while reading it.
++backslash-newline pairs, which \fBtgetent()\fP strips out while reading it.
+ Some termcap libraries strip off the final newline, too (GNU termcap does not).
+ Now suppose:
+ .TP 5
+@@ -1527,12 +1546,12 @@
+ if it's the entry it wants,
+ .TP 5
+ *
+-and tgetent() is searching for a terminal type that either is the
++and \fBtgetent()\fP is searching for a terminal type that either is the
+ long entry, appears in the termcap file after the long entry, or
+-doesn't appear in the file at all (so that tgetent() has to search
++doesn't appear in the file at all (so that \fBtgetent()\fP has to search
+ the whole termcap file).
+ .PP
+-Then tgetent() will overwrite memory, perhaps its stack, and probably core dump
++Then \fBtgetent()\fP will overwrite memory, perhaps its stack, and probably core dump
+ the program.
+ Programs like telnet are particularly vulnerable; modern telnets
+ pass along values like the terminal type automatically.
+@@ -1545,7 +1564,7 @@
+ .PP
+ The "after tc expansion" length will have a similar effect to the
+ above, but only for people who actually set TERM to that terminal
+-type, since tgetent() only does "tc" expansion once it's found the
++type, since \fBtgetent()\fP only does "tc" expansion once it's found the
+ terminal type it was looking for, not while searching.
+ .PP
+ In summary, a termcap entry that is longer than 1023 bytes can cause,
+@@ -1631,7 +1650,11 @@
+ \*d/?/*
+ files containing terminal descriptions
+ .SH SEE ALSO
+-\fBtic\fR(1M), \fBcurses\fR(3X), \fBprintf\fR(3S), \fBterm\fR(\*n).
++\fBtic\fR(1M),
++\fBinfocmp\fR(1M),
++\fBcurses\fR(3X),
++\fBprintf\fR(3S),
++\fBterm\fR(\*n).
+ .SH AUTHORS
+ Zeyd M. Ben-Halim, Eric S. Raymond, Thomas E. Dickey.
+ Based on pcurses by Pavel Curtis.
+Index: man/tic.1m
+Prereq:  1.35 
+--- ncurses-5.4-20040208/man/tic.1m	2003-05-11 00:32:53.000000000 +0000
++++ ncurses-5.4-20050319/man/tic.1m	2004-07-05 13:09:39.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2004 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            *
+@@ -26,7 +26,7 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: tic.1m,v 1.35 2003/05/11 00:32:53 tom Exp $
++.\" $Id: tic.1m,v 1.37 2004/07/05 13:09:39 tom Exp $
+ .TH tic 1M ""
+ .ds n 5
+ .ds d @TERMINFO@
+@@ -34,7 +34,7 @@
+ \fBtic\fR - the \fIterminfo\fR entry-description compiler
+ .SH SYNOPSIS
+ \fBtic\fR
+-[\fB\-\
++[\fB-\
+ 1\
+ C\
+ G\
+@@ -52,11 +52,11 @@
+ t\
+ x\
+ \fR]
+-[\fB\-e\fR \fInames\fR]
+-[\fB\-o\fR \fIdir\fR]
+-[\fB\-R\fR \fIsubset\fR]
+-[\fB\-v\fR[\fIn\fR]]
+-[\fB\-w\fR[\fIn\fR]]
++[\fB-e\fR \fInames\fR]
++[\fB-o\fR \fIdir\fR]
++[\fB-R\fR \fIsubset\fR]
++[\fB-v\fR[\fIn\fR]]
++[\fB-w\fR[\fIn\fR]]
+ \fIfile\fR
+ .br
+ .SH DESCRIPTION
+@@ -78,31 +78,33 @@
+ directory first, look at \fI$HOME/.terminfo\fR if TERMINFO is not set, and
+ finally look in \fI\*d\fR.
+ .TP
+-\fB\-1\fR
++\fB-1\fR
+ restricts the output to a single column
+ .TP
+-\fB\-a\fR
++\fB-a\fR
+ tells \fBtic\fP to retain commented-out capabilities rather than discarding
+ them.  Capabilities are commented by prefixing them with a period.
+-This sets the \fB\-x\fR option, because it treats the commented-out
++This sets the \fB-x\fR option, because it treats the commented-out
+ entries as user-defined names.
++If the source is termcap, accept the 2-character names required by version 6.
++Otherwise these are ignored.
+ .TP
+-\fB\-C\fR
+-Force source translation to termcap format.  Note: this differs from the \fB\-C\fR
++\fB-C\fR
++Force source translation to termcap format.  Note: this differs from the \fB-C\fR
+ option of \fIinfocmp\fR(1M) in that it does not merely translate capability
+ names, but also translates terminfo strings to termcap format.  Capabilities
+ that are not translatable are left in the entry under their terminfo names
+ but commented out with two preceding dots.
+ .TP
+-\fB\-c\fR
++\fB-c\fR
+ tells \fBtic\fP to only check \fIfile\fR for errors, including syntax problems and
+-bad use links.  If you specify \fB\-C\fR (\fB\-I\fR) with this option, the code
++bad use links.  If you specify \fB-C\fR (\fB-I\fR) with this option, the code
+ will print warnings about entries which, after use resolution, are more than
+ 1023 (4096) bytes long.  Due to a fixed buffer length in older termcap
+ libraries (and a documented limit in terminfo), these entries may cause core
+ dumps.
+ .TP
+-\fB\-e \fR\fInames\fR
++\fB-e \fR\fInames\fR
+ Limit writes and translations to the following comma-separated list of
+ terminals.
+ If any name or alias of a terminal matches one of the names in
+@@ -110,28 +112,28 @@
+ Otherwise no output will be generated for it.
+ The option value is interpreted as a file containing the list if it
+ contains a '/'.
+-(Note: depending on how tic was compiled, this option may require \fB\-I\fR or \fB\-C\fR.)
++(Note: depending on how tic was compiled, this option may require \fB-I\fR or \fB-C\fR.)
+ .TP
+-\fB\-f\fR
++\fB-f\fR
+ Display complex terminfo strings which contain if/then/else/endif expressions
+ indented for readability.
+ .TP
+-\fB\-G\fR
++\fB-G\fR
+ Display constant literals in decimal form
+ rather than their character equivalents.
+ .TP
+-\fB\-g\fR
++\fB-g\fR
+ Display constant character literals in quoted form
+ rather than their decimal equivalents.
+ .TP
+-\fB\-I\fR
++\fB-I\fR
+ Force source translation to terminfo format.
+ .TP
+-\fB\-L\fR
++\fB-L\fR
+ Force source translation to terminfo format
+ using the long C variable names listed in <\fBterm.h\fR>
+ .TP
+-\fB\-N\fR
++\fB-N\fR
+ Disable smart defaults. 
+ Normally, when translating from termcap to terminfo, the compiler makes
+ a number of assumptions about the defaults of string capabilities
+@@ -143,42 +145,42 @@
+ This option forces a more literal translation that also preserves the
+ obsolete capabilities.
+ .TP
+-\fB\-o\fR\fIdir\fR
++\fB-o\fR\fIdir\fR
+ Write compiled entries to given directory.  Overrides the TERMINFO environment
+ variable.
+ .TP
+-\fB\-R\fR\fIsubset\fR
++\fB-R\fR\fIsubset\fR
+ Restrict output to a given subset.  This option is for use with archaic
+ versions of terminfo like those on SVr1, Ultrix, or HP/UX that do not support
+ the full set of SVR4/XSI Curses terminfo; and outright broken ports like AIX 3.x
+ that have their own extensions incompatible with SVr4/XSI.  Available subsets
+ are "SVr1", "Ultrix", "HP", "BSD" and "AIX"; see \fBterminfo\fR(\*n) for details.
+ .TP
+-\fB\-r\fR
++\fB-r\fR
+ Force entry resolution (so there are no remaining tc capabilities) even
+ when doing translation to termcap format.  This may be needed if you are
+ preparing a termcap file for a termcap library (such as GNU termcap through
+ version 1.3 or BSD termcap through 4.3BSD) that does not handle multiple
+ tc capabilities per entry.
+ .TP
+-\fB\-s\fR
++\fB-s\fR
+ Summarize the compile by showing the directory into which entries
+ are written, and the number of entries which are compiled.
+ .TP
+-\fB\-T\fR
++\fB-T\fR
+ eliminates size-restrictions on the generated text.
+ This is mainly useful for testing and analysis, since the compiled
+ descriptions are limited (e.g., 1023 for termcap, 4096 for terminfo).
+ .TP
+-\fB\-t\fR
++\fB-t\fR
+ tells \fBtic\fP to discard commented-out capabilities.
+ Normally when translating from terminfo to termcap,
+ untranslatable capabilities are commented-out.
+ .TP
+-\fB\-V\fR
++\fB-V\fR
+ reports the version of ncurses which was used in this program, and exits.
+ .TP
+-\fB\-v\fR\fIn\fR
++\fB-v\fR\fIn\fR
+ specifies that (verbose) output be written to standard error trace
+ information showing \fBtic\fR's progress.  The optional integer
+ \fIn\fR is a number from 1 to 10, inclusive, indicating the desired
+@@ -186,10 +188,10 @@
+ level is 1.  If \fIn\fR is specified and greater than 1, the level of
+ detail is increased.
+ .TP
+-\fB\-w\fR\fIn\fR
++\fB-w\fR\fIn\fR
+ specifies the width of the output.
+ .TP
+-\fB\-x\fR
++\fB-x\fR
+ Treat unknown capabilities as user-defined.
+ That is, if you supply a capability name which \fBtic\fP does not recognize,
+ it will infer its type (boolean, number or string) from the syntax and
+@@ -274,25 +276,25 @@
+ error messages, and can be parsed by GNU Emacs's compile facility.
+ 
+ The
+-\fB\-C\fR,
+-\fB\-G\fR,
+-\fB\-I\fR,
+-\fB\-N\fR,
+-\fB\-R\fR,
+-\fB\-T\fR,
+-\fB\-V\fR,
+-\fB\-a\fR,
+-\fB\-e\fR,
+-\fB\-f\fR,
+-\fB\-g\fR,
+-\fB\-o\fR,
+-\fB\-r\fR,
+-\fB\-s\fR,
+-\fB\-t\fR and
+-\fB\-x\fR
++\fB-C\fR,
++\fB-G\fR,
++\fB-I\fR,
++\fB-N\fR,
++\fB-R\fR,
++\fB-T\fR,
++\fB-V\fR,
++\fB-a\fR,
++\fB-e\fR,
++\fB-f\fR,
++\fB-g\fR,
++\fB-o\fR,
++\fB-r\fR,
++\fB-s\fR,
++\fB-t\fR and
++\fB-x\fR
+ options
+ are not supported under SVr4.
+-The SVr4 \fB\-c\fR mode does not report bad use links.
++The SVr4 \fB-c\fR mode does not report bad use links.
+ 
+ System V does not compile entries to or read entries from your
+ \fI$HOME/.terminfo\fR directory unless TERMINFO is explicitly set to it.
+Index: man/toe.1m
+Prereq:  1.12 
+--- ncurses-5.4-20040208/man/toe.1m	2003-05-11 00:32:53.000000000 +0000
++++ ncurses-5.4-20050319/man/toe.1m	2004-07-05 13:16:08.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2004 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            *
+@@ -26,45 +26,45 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: toe.1m,v 1.12 2003/05/11 00:32:53 tom Exp $
++.\" $Id: toe.1m,v 1.13 2004/07/05 13:16:08 tom Exp $
+ .TH toe 1M ""
+ .ds n 5
+ .ds d @TERMINFO@
+ .SH NAME
+ \fBtoe\fR - table of (terminfo) entries
+ .SH SYNOPSIS
+-\fBtoe\fR [\fB\-v\fR[\fIn\fR]] [\fB\-huUV\fR] \fIfile...\fR
++\fBtoe\fR [\fB-v\fR[\fIn\fR]] [\fB-huUV\fR] \fIfile...\fR
+ .br
+ .SH DESCRIPTION
+ .PP
+ With no options, \fBtoe\fR lists all available terminal types by primary name
+ with descriptions.  File arguments specify the directories to be scanned; if no
+ such arguments are given, your default terminfo directory is scanned.  If you
+-also specify the \fB\-h\fR option, a directory header will be issued as each
++also specify the \fB-h\fR option, a directory header will be issued as each
+ directory is entered.
+ .PP
+ There are other options intended for use by terminfo file maintainers:
+ .TP
+-\fB\-u\fR \fIfile\fR
++\fB-u\fR \fIfile\fR
+ says to issue a report on dependencies in the given file. This report condenses
+ the `use' relation: each line consists of the primary name of a terminal that
+ has use capabilities, followed by a colon, followed by the
+ whitespace-separated primary names of all terminals which occur in those use
+ capabilities, followed by a newline
+ .TP
+-\fB\-U\fR \fIfile\fR
++\fB-U\fR \fIfile\fR
+ says to issue a report on reverse dependencies in the given file. This report
+ reverses the `use' relation: each line consists of the primary name of a
+ terminal that occurs in use capabilities, followed by a colon, followed by the
+ whitespace-separated primary names of all terminals which depend on it,
+ followed by a newline.
+ .TP
+-\fB\-v\fR\fIn\fR
++\fB-v\fR\fIn\fR
+ specifies that (verbose) output be written to standard error trace
+ information showing \fBtoe\fR's progress.  The optional integer
+ \fIn\fR is a number from 1 to 10, interpreted as for \fBtic\fR(1).
+ .TP 5
+-\fB\-V\fR
++\fB-V\fR
+ reports the version of ncurses which was used in this program, and exits.
+ .SH FILES
+ .TP 5
+Index: man/tput.1
+Prereq:  1.20 
+--- ncurses-5.4-20040208/man/tput.1	2003-05-11 00:32:53.000000000 +0000
++++ ncurses-5.4-20050319/man/tput.1	2005-01-08 17:44:26.000000000 +0000
+@@ -1,6 +1,6 @@
+ '\" t
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2004,2005 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            *
+@@ -27,70 +27,84 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: tput.1,v 1.20 2003/05/11 00:32:53 tom Exp $
++.\" $Id: tput.1,v 1.22 2005/01/08 17:44:26 tom Exp $
+ .TH tput 1 ""
+ .ds d @TERMINFO@
+ .ds n 1
+ .SH NAME
+ \fBtput\fR, \fBreset\fR - initialize a terminal or query terminfo database
+ .SH SYNOPSIS
+-\fBtput\fR [\fB\-T\fR\fItype\fR] \fIcapname\fR [\fIparms\fR ... ]
++\fBtput\fR [\fB-T\fR\fItype\fR] \fIcapname\fR [\fIparms\fR ... ]
+ .br
+-\fBtput\fR [\fB\-T\fR\fItype\fR] \fBinit\fR
++\fBtput\fR [\fB-T\fR\fItype\fR] \fBinit\fR
+ .br
+-\fBtput\fR [\fB\-T\fR\fItype\fR] \fBreset\fR
++\fBtput\fR [\fB-T\fR\fItype\fR] \fBreset\fR
+ .br
+-\fBtput\fR [\fB\-T\fR\fItype\fR] \fBlongname\fR
++\fBtput\fR [\fB-T\fR\fItype\fR] \fBlongname\fR
+ .br
+-\fBtput \-S\fR  \fB<<\fR
++\fBtput -S\fR  \fB<<\fR
+ .br
+-\fBtput \-V\fR
++\fBtput -V\fR
+ .br
+ .SH DESCRIPTION
+ The \fBtput\fR utility uses the \fBterminfo\fR database to make the
+ values of terminal-dependent capabilities and information available to
+ the shell (see \fBsh\fR(1)), to initialize or reset the terminal, or
+-return the long name of the requested terminal type.  \fBtput\fR
+-outputs a string if the attribute (\fIcap\fRability \fIname\fR) is of
+-type string, or an integer if the attribute is of type integer.  If
+-the attribute is of type boolean, \fBtput\fR simply sets the exit code
+-(\fB0\fR for TRUE if the terminal has the capability, \fB1\fR for
+-FALSE if it does not), and produces no output.  Before using a value
+-returned on standard output, the user should test the exit code
+-[\fB$?\fR, see \fBsh\fR(1)] to be sure it is \fB0\fR.
++return the long name of the requested terminal type.
++The result depends upon the capability's type:
++.RS
++.TP 5
++string
++\fBtput\fR writes the string to the standard output.
++No trailing newline is supplied.
++.TP
++integer
++\fBtput\fR writes the decimal value to the standard output,
++with a trailing newline.
++.TP
++boolean
++\fBtput\fR simply sets the exit code
++(\fB0\fR for TRUE if the terminal has the capability,
++\fB1\fR for FALSE if it does not),
++and writes nothing to the standard output.
++.RE
++.PP
++Before using a value returned on the standard output,
++the application should test the exit code
++(e.g., \fB$?\fR, see \fBsh\fR(1)) to be sure it is \fB0\fR.
+ (See the \fBEXIT CODES\fR and \fBDIAGNOSTICS\fR sections.)
+ For a complete list of capabilities
+ and the \fIcapname\fR associated with each, see \fBterminfo\fR(\*n).
+ .TP
+-\fB\-T\fR\fItype\fR
++\fB-T\fR\fItype\fR
+ indicates the \fItype\fR of terminal.  Normally this option is
+ unnecessary, because the default is taken from the environment
+-variable \fBTERM\fR.  If \fB\-T\fR is specified, then the shell
++variable \fBTERM\fR.  If \fB-T\fR is specified, then the shell
+ variables \fBLINES\fR and \fBCOLUMNS\fR will be ignored,and the
+ operating system will not be queried for the actual screen size.
+ .TP
+ \fIcapname\fR
+-indicates the attribute from the \fBterminfo\fR database.  When
++indicates the capability from the \fBterminfo\fR database.  When
+ \fBtermcap\fR support is compiled in, the \fBtermcap\fR name for
+-the attribute is also accepted.
++the capability is also accepted.
+ .TP
+ \fIparms\fR
+-If the attribute is a string that takes parameters, the arguments
++If the capability is a string that takes parameters, the arguments
+ \fIparms\fR will be instantiated into the string.
+-An all-numeric argument will be passed to the attribute as a number.
+ .IP
++Most parameters are numbers.
+ Only a few terminfo capabilities require string parameters;
+ \fBtput\fR uses a table to decide which to pass as strings.
+ Normally \fBtput\fR uses \fBtparm\fR (3X) to perform the substitution.
+-If no parameters are given for the attribute,
++If no parameters are given for the capability,
+ \fBtput\fR writes the string without performing the substitution.
+ .TP
+-\fB\-S\fR
++\fB-S\fR
+ allows more than one capability per invocation of \fBtput\fR.  The
+ capabilities must be passed to \fBtput\fR from the standard input
+ instead of from the command line (see example).
+ Only one \fIcapname\fR is allowed per line.
+-The \fB\-S\fR option changes the
++The \fB-S\fR option changes the
+ meaning of the \fB0\fR and \fB1\fR boolean and string exit codes (see the
+ EXIT CODES section).
+ .IP
+@@ -98,12 +112,12 @@
+ to decide whether to use \fBtparm\fR (3X),
+ and how to interpret the parameters.
+ .TP
+-\fB\-V\fR
++\fB-V\fR
+ reports the version of ncurses which was used in this program, and exits.
+ .TP
+ \fBinit\fR
+ If the \fBterminfo\fR database is present and an entry for the user's
+-terminal exists (see \fB\-T\fR\fItype\fR, above), the following will
++terminal exists (see \fB-T\fR\fItype\fR, above), the following will
+ occur: (1) if present, the terminal's initialization strings will be
+ output (\fBis1\fR, \fBis2\fR, \fBis3\fR, \fBif\fR, \fBiprog\fR), (2)
+ any delays (e.g., newline) specified in the entry will be set in the
+@@ -122,7 +136,7 @@
+ .TP
+ \fBlongname\fR
+ If the \fBterminfo\fR database is present and an entry for the
+-user's terminal exists (see \fB\-T\fR\fItype\fR above), then the long name
++user's terminal exists (see \fB-T\fR\fItype\fR above), then the long name
+ of the terminal will be put out.  The long name is the last
+ name in the first line of the terminal's description in the
+ \fBterminfo\fR database [see \fBterm\fR(5)].
+@@ -139,7 +153,7 @@
+ the environmental variable \fBTERM\fR has been exported, as
+ illustrated on the \fBprofile\fR(5) manual page.
+ .TP 5
+-\fBtput \-T5620 reset\fR
++\fBtput -T5620 reset\fR
+ Reset an AT&T 5620 terminal, overriding the type of
+ terminal in the environmental variable \fBTERM\fR.
+ .TP 5
+@@ -154,7 +168,7 @@
+ \fBtput cols\fR
+ Print the number of columns for the current terminal.
+ .TP 5
+-\fBtput \-T450 cols\fR
++\fBtput -T450 cols\fR
+ Print the number of columns for the 450 terminal.
+ .TP 5
+ \fBbold=`tput smso` offbold=`tput rmso`\fR
+@@ -178,7 +192,7 @@
+ variable \fBTERM\fR.
+ .PP
+ .RS 5
+-\fBtput \-S <<!\fR
++\fBtput -S <<!\fR
+ .br
+ \fB> clear\fR
+ .br
+@@ -200,12 +214,6 @@
+ \fB\*d\fR
+ compiled terminal description database
+ .TP
+-\fB/usr/include/curses.h\fR
+-\fBcurses\fR(3X) header file
+-.TP
+-\fB/usr/include/term.h\fR
+-\fBterminfo\fR header file
+-.TP
+ \fB@DATADIR@/tabset/*\fR
+ tab settings for some terminals, in a format
+ appropriate to be output to the terminal (escape
+@@ -213,7 +221,7 @@
+ information, see the "Tabs and Initialization"
+ section of \fBterminfo\fR(5)
+ .SH EXIT CODES
+-If the \fB\-S\fR option is used,
++If the \fB-S\fR option is used,
+ \fBtput\fR checks for errors from each line,
+ and if any errors are found, will set the exit code to 4 plus the
+ number of lines with errors.
+@@ -221,7 +229,7 @@
+ No indication of which line failed can be given so
+ exit code \fB1\fR will never appear.  Exit codes \fB2\fR, \fB3\fR, and
+ \fB4\fR retain their usual interpretation.
+-If the \fB\-S\fR option is not used,
++If the \fB-S\fR option is not used,
+ the exit code depends on the type of \fIcapname\fR:
+ .RS 5
+ .TP
+@@ -241,7 +249,7 @@
+ whether or not \fIcapname\fR is defined for this terminal \fItype\fR.
+ To determine if \fIcapname\fR is defined for this terminal \fItype\fR,
+ the user must test the value written to standard output.
+-A value of \fB\-1\fR
++A value of \fB-1\fR
+ means that \fIcapname\fR is not defined for this terminal \fItype\fR.
+ .TP
+ .I other
+@@ -262,17 +270,17 @@
+ \fB0\fR	T{
+ (\fIcapname\fR is a numeric variable that is not specified in the
+ \fBterminfo\fR(\*n) database for this terminal type, e.g.
+-\fBtput \-T450 lines\fR and \fBtput \-T2621 xmc\fR)
++\fBtput -T450 lines\fR and \fBtput -T2621 xmc\fR)
+ T}
+ \fB1\fR	no error message is printed, see the \fBEXIT CODES\fR section.
+ \fB2\fR	usage error
+ \fB3\fR	unknown terminal \fItype\fR or no \fBterminfo\fR database
+ \fB4\fR	unknown \fBterminfo\fR capability \fIcapname\fR
+-\fB>4\fR	error occurred in \-S
++\fB>4\fR	error occurred in -S
+ =
+ .TE
+ .SH PORTABILITY
+-The \fBlongname\fR and \fB\-S\fR options, and the parameter-substitution
++The \fBlongname\fR and \fB-S\fR options, and the parameter-substitution
+ features used in the \fBcup\fR example, are not supported in BSD curses or in
+ AT&T/USL curses before SVr4.
+ .SH SEE ALSO
+Index: man/tset.1
+Prereq:  1.13 
+--- ncurses-5.4-20040208/man/tset.1	2003-05-11 00:32:53.000000000 +0000
++++ ncurses-5.4-20050319/man/tset.1	2004-07-05 13:16:08.000000000 +0000
+@@ -1,5 +1,5 @@
+ .\"***************************************************************************
+-.\" Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
++.\" Copyright (c) 1998-2003,2004 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            *
+@@ -26,14 +26,15 @@
+ .\" authorization.                                                           *
+ .\"***************************************************************************
+ .\"
+-.\" $Id: tset.1,v 1.13 2003/05/11 00:32:53 tom Exp $
++.\" $Id: tset.1,v 1.14 2004/07/05 13:16:08 tom Exp $
+ .TH tset 1 ""
+ .SH NAME
+ \fBtset\fR, \fBreset\fR - terminal initialization
+ .SH SYNOPSIS
+-tset [\-IQVqrs] [\-] [\-e \fIch\fR] [\-i \fIch\fR] [\-k \fIch\fR] [\-m \fImapping\fR] [\fIterminal\fR]
++\fBtset\fR [\fB-IQVqrs\fR] [\fB-\fR] [\fB-e\fR \fIch\fR] [\fB-i\fR \fIch\fR] [\fB-k\fR \fIch\fR] [\fB-m\fR \fImapping\fR] [\fIterminal\fR]
+ .br
+-reset [\-IQVqrs] [\-] [\-e \fIch\fR] [\-i \fIch\fR] [\-k \fIch\fR] [\-m \fImapping\fR] [\fIterminal\fR]
++A
++\fBreset\fR [\fB-IQVqrs\fR] [\fB-\fR] [\fB-e\fR \fIch\fR] [\fB-i\fR \fIch\fR] [\fB-k\fR \fIch\fR] [\fB-m\fR \fImapping\fR] [\fIterminal\fR]
+ .SH DESCRIPTION
+ \&\fBTset\fR initializes terminals.
+ \fBTset\fR first determines the type of terminal that you are using.
+@@ -50,7 +51,7 @@
+ .PP
+ 4. The default terminal type, ``unknown''.
+ .PP
+-If the terminal type was not specified on the command-line, the \fB\-m\fR
++If the terminal type was not specified on the command-line, the \fB-m\fR
+ option mappings are then applied (see below for more information).
+ Then, if the terminal type begins with a question mark (``?''), the
+ user is prompted for confirmation of the terminal type.  An empty
+@@ -81,37 +82,37 @@
+ .PP
+ The options are as follows:
+ .TP 5
+-.B \-q
++.B -q
+ The terminal type is displayed to the standard output, and the terminal is
+ not initialized in any way.  The option `-' by itself is equivalent but
+ archaic.
+ .TP
+-.B \-e
++.B -e
+ Set the erase character to \fIch\fR.
+ .TP
+-.B \-I
++.B -I
+ Do not send the terminal or tab initialization strings to the terminal.
+ .TP
+-.B \-Q
++.B -Q
+ Don't display any values for the erase, interrupt and line kill characters.
+ .TP
+-.B \-V
++.B -V
+ reports the version of ncurses which was used in this program, and exits.
+ .TP
+-.B \-i
++.B -i
+ Set the interrupt character to \fIch\fR.
+ .TP
+-.B \-k
++.B -k
+ Set the line kill character to \fIch\fR.
+ .TP
+-.B \-m
++.B -m
+ Specify a mapping from a port type to a terminal.
+ See below for more information.
+ .TP
+-.B \-r
++.B -r
+ Print the terminal type to the standard error output.
+ .TP
+-.B \-s
++.B -s
+ Print the sequence of shell commands to initialize the environment variable
+ \fBTERM\fR to the standard output.
+ See the section below on setting the environment for details.
+@@ -122,9 +123,9 @@
+ .SH SETTING THE ENVIRONMENT
+ It is often desirable to enter the terminal type and information about
+ the terminal's capabilities into the shell's environment.
+-This is done using the \fB\-s\fR option.
++This is done using the \fB-s\fR option.
+ .PP
+-When the \fB\-s\fR option is specified, the commands to enter the information
++When the \fB-s\fR option is specified, the commands to enter the information
+ into the shell's environment are written to the standard output.  If
+ the \fBSHELL\fR environmental variable ends in ``csh'', the commands
+ are for \fBcsh\fR, otherwise, they are for \fBsh\fR.
+@@ -132,7 +133,7 @@
+ \fBnoglob\fR, leaving it unset.  The following line in the \fB.login\fR
+ or \fB.profile\fR files will initialize the environment correctly:
+ 
+-    eval \`tset \-s options ... \`
++    eval \`tset -s options ... \`
+ 
+ .SH TERMINAL TYPE MAPPING
+ When the terminal is not hardwired into the system (or the current
+@@ -142,13 +143,13 @@
+ When \fBtset\fR is used in a startup script it is often desirable to
+ provide information about the type of terminal used on such ports.
+ .PP
+-The purpose of the \fB\-m\fR option is to map
++The purpose of the \fB-m\fR option is to map
+ from some set of conditions to a terminal type, that is, to
+ tell \fBtset\fR
+ ``If I'm on this port at a particular speed, guess that I'm on that
+ kind of terminal''.
+ .PP
+-The argument to the \fB\-m\fR option consists of an optional port type, an
++The argument to the \fB-m\fR option consists of an optional port type, an
+ optional operator, an optional baud rate specification, an optional
+ colon (``:'') character and a terminal type.  The port type is a
+ string (delimited by either the operator or the colon character).  The
+@@ -159,7 +160,7 @@
+ of the standard error output (which should be the control terminal).
+ The terminal type is a string.
+ .PP
+-If the terminal type is not specified on the command line, the \fB\-m\fR
++If the terminal type is not specified on the command line, the \fB-m\fR
+ mappings are applied to the terminal type.  If the port type and baud
+ rate match the mapping, the terminal type specified in the mapping
+ replaces the current type.  If more than one mapping is specified, the
+@@ -174,16 +175,16 @@
+ .PP
+ If no baud rate is specified, the terminal type will match any baud rate.
+ If no port type is specified, the terminal type will match any port type.
+-For example, \fB\-m dialup:vt100 \-m :?xterm\fR
++For example, \fB-m dialup:vt100 -m :?xterm\fR
+ will cause any dialup port, regardless of baud rate, to match the terminal
+ type vt100, and any non-dialup port type to match the terminal type ?xterm.
+ Note, because of the leading question mark, the user will be
+ queried on a default port as to whether they are actually using an xterm
+ terminal.
+ .PP
+-No whitespace characters are permitted in the \fB\-m\fR option argument.
++No whitespace characters are permitted in the \fB-m\fR option argument.
+ Also, to avoid problems with meta-characters, it is suggested that the
+-entire \fB\-m\fR option argument be placed within single quote characters,
++entire \fB-m\fR option argument be placed within single quote characters,
+ and that \fBcsh\fR users insert a backslash character (``\e'') before
+ any exclamation marks (``!'').
+ .SH HISTORY
+@@ -197,33 +198,33 @@
+ \fBtset\fR's most important use).  This implementation behaves like 4.4BSD
+ tset, with a few exceptions specified here.
+ .PP
+-The \fB\-S\fR option of BSD tset no longer works; it prints an error message to stderr
+-and dies.  The \fB\-s\fR option only sets \fBTERM\fR, not \fBTERMCAP\fP.  Both these
++The \fB-S\fR option of BSD tset no longer works; it prints an error message to stderr
++and dies.  The \fB-s\fR option only sets \fBTERM\fR, not \fBTERMCAP\fP.  Both these
+ changes are because the \fBTERMCAP\fR variable is no longer supported under
+-terminfo-based \fBncurses\fR, which makes \fBtset \-S\fR useless (we made it die
++terminfo-based \fBncurses\fR, which makes \fBtset -S\fR useless (we made it die
+ noisily rather than silently induce lossage).
+ .PP
+ There was an undocumented 4.4BSD feature that invoking tset via a link named
+ `TSET` (or via any other name beginning with an upper-case letter) set the
+ terminal to use upper-case only.  This feature has been omitted.
+ .PP
+-The \fB\-A\fR, \fB\-E\fR, \fB\-h\fR, \fB\-u\fR and \fB\-v\fR
++The \fB-A\fR, \fB-E\fR, \fB-h\fR, \fB-u\fR and \fB-v\fR
+ options were deleted from the \fBtset\fR
+ utility in 4.4BSD.
+ None of them were documented in 4.3BSD and all are
+ of limited utility at best.
+-The \fB\-a\fR, -\fB\d\fR, and -\fB\p\fR options are similarly
++The \fB-a\fR, \fB-d\fR, and \fB-p\fR options are similarly
+ not documented or useful, but were retained as they appear to be in
+ widespread use.  It is strongly recommended that any usage of these
+-three options be changed to use the \fB\-m\fR option instead.  The
+--n option remains, but has no effect.  The \fB\-adnp\fR options are therefore
++three options be changed to use the \fB-m\fR option instead.  The
++-n option remains, but has no effect.  The \fB-adnp\fR options are therefore
+ omitted from the usage summary above.
+ .PP
+-It is still permissible to specify the \fB\-e\fR, \fB\-i\fR, and \fB\-k\fR options without
++It is still permissible to specify the \fB-e\fR, \fB-i\fR, and \fB-k\fR options without
+ arguments, although it is strongly recommended that such usage be fixed to
+ explicitly specify the character.
+ .PP
+-As of 4.4BSD, executing \fBtset\fR as \fBreset\fR no longer implies the \fB\-Q\fR
++As of 4.4BSD, executing \fBtset\fR as \fBreset\fR no longer implies the \fB-Q\fR
+ option.  Also, the interaction between the - option and the \fIterminal\fR
+ argument in some historic implementations of \fBtset\fR has been removed.
+ .SH ENVIRONMENT
+Index: menu/Makefile.in
+Prereq:  1.41 
+--- ncurses-5.4-20040208/menu/Makefile.in	2003-11-01 22:44:33.000000000 +0000
++++ ncurses-5.4-20050319/menu/Makefile.in	2004-12-11 23:33:16.000000000 +0000
+@@ -1,4 +1,4 @@
+-# $Id: Makefile.in,v 1.41 2003/11/01 22:44:33 tom Exp $
++# $Id: Makefile.in,v 1.42 2004/12/11 23:33:16 tom Exp $
+ ##############################################################################
+ # Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+ #                                                                            #
+@@ -79,7 +79,7 @@
+ CPP		= @CPP@
+ CFLAGS		= @CFLAGS@
+ 
+-CPPFLAGS	= -DHAVE_CONFIG_H @CPPFLAGS@
++CPPFLAGS	= -I@top_srcdir@/ncurses -DHAVE_CONFIG_H @CPPFLAGS@
+ 
+ CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
+ 
+Index: menu/llib-lmenu
+--- ncurses-5.4-20040208/menu/llib-lmenu	2002-08-31 20:00:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/llib-lmenu	2005-03-05 19:42:46.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1999,2002 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1999-2002,2005 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey <dickey@clark.net> 1996-1999,2002              *
++ *  Author: Thomas E. Dickey        1996-2002,2005                          *
+  ****************************************************************************/
+ /* LINTLIBRARY */
+ 
+@@ -132,6 +132,11 @@
+ 		MENU	*menu)
+ 		{ /* void */ }
+ 
++#undef _nc_Calculate_Text_Width
++int	_nc_Calculate_Text_Width(
++		const TEXT *item)
++		{ return(*(int *)0); }
++
+ #undef _nc_Calculate_Item_Length_and_Width
+ void	_nc_Calculate_Item_Length_and_Width(
+ 		MENU	*menu)
+@@ -481,6 +486,38 @@
+ 		const MENU *menu)
+ 		{ return(*(WINDOW **)0); }
+ 
++/* ./m_trace.c */
++
++#undef _nc_retrace_item
++ITEM	*_nc_retrace_item(
++		ITEM	*code)
++		{ return(*(ITEM **)0); }
++
++#undef _nc_retrace_item_ptr
++ITEM	**_nc_retrace_item_ptr(
++		ITEM	**code)
++		{ return(*(ITEM ***)0); }
++
++#undef _nc_retrace_item_opts
++Item_Options _nc_retrace_item_opts(
++		Item_Options code)
++		{ return(*(Item_Options *)0); }
++
++#undef _nc_retrace_menu
++MENU	*_nc_retrace_menu(
++		MENU	*code)
++		{ return(*(MENU **)0); }
++
++#undef _nc_retrace_menu_hook
++Menu_Hook _nc_retrace_menu_hook(
++		Menu_Hook code)
++		{ return(*(Menu_Hook *)0); }
++
++#undef _nc_retrace_menu_opts
++Menu_Options _nc_retrace_menu_opts(
++		Menu_Options code)
++		{ return(*(Menu_Options *)0); }
++
+ /* ./m_userptr.c */
+ 
+ #undef set_menu_userptr
+Index: menu/llib-lmenuw
+--- ncurses-5.4-20040208/menu/llib-lmenuw	2002-08-31 21:54:21.000000000 +0000
++++ ncurses-5.4-20050319/menu/llib-lmenuw	2005-03-05 19:33:53.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
++ * Copyright (c) 2002,2005 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey <dickey@clark.net> 2002                        *
++ *  Author: Thomas E. Dickey                    2002,2005                   *
+  ****************************************************************************/
+ /* LINTLIBRARY */
+ 
+@@ -132,6 +132,11 @@
+ 		MENU	*menu)
+ 		{ /* void */ }
+ 
++#undef _nc_Calculate_Text_Width
++int	_nc_Calculate_Text_Width(
++		const TEXT *item)
++		{ return(*(int *)0); }
++
+ #undef _nc_Calculate_Item_Length_and_Width
+ void	_nc_Calculate_Item_Length_and_Width(
+ 		MENU	*menu)
+@@ -481,6 +486,38 @@
+ 		const MENU *menu)
+ 		{ return(*(WINDOW **)0); }
+ 
++/* ./m_trace.c */
++
++#undef _nc_retrace_item
++ITEM	*_nc_retrace_item(
++		ITEM	*code)
++		{ return(*(ITEM **)0); }
++
++#undef _nc_retrace_item_ptr
++ITEM	**_nc_retrace_item_ptr(
++		ITEM	**code)
++		{ return(*(ITEM ***)0); }
++
++#undef _nc_retrace_item_opts
++Item_Options _nc_retrace_item_opts(
++		Item_Options code)
++		{ return(*(Item_Options *)0); }
++
++#undef _nc_retrace_menu
++MENU	*_nc_retrace_menu(
++		MENU	*code)
++		{ return(*(MENU **)0); }
++
++#undef _nc_retrace_menu_hook
++Menu_Hook _nc_retrace_menu_hook(
++		Menu_Hook code)
++		{ return(*(Menu_Hook *)0); }
++
++#undef _nc_retrace_menu_opts
++Menu_Options _nc_retrace_menu_opts(
++		Menu_Options code)
++		{ return(*(Menu_Options *)0); }
++
+ /* ./m_userptr.c */
+ 
+ #undef set_menu_userptr
+Index: menu/m_attribs.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/menu/m_attribs.c	2003-11-08 20:54:20.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_attribs.c	2004-12-11 23:29:12.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_attribs.c,v 1.12 2003/11/08 20:54:20 tom Exp $")
++MODULE_ID("$Id: m_attribs.c,v 1.14 2004/12/11 23:29:12 tom Exp $")
+ 
+ /* Macro to redraw menu if it is posted and changed */
+ #define Refresh_Menu(menu) \
+@@ -51,6 +51,7 @@
+ #define GEN_MENU_ATTR_SET_FCT( name ) \
+ NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU * menu, chtype attr)\
+ {\
++   T((T_CALLED("set_menu_" #name "(%p,%s)"), menu, _traceattr(attr)));\
+    if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\
+       RETURN(E_BAD_ARGUMENT);\
+    if (menu && ( menu -> name != attr))\
+@@ -66,7 +67,8 @@
+ #define GEN_MENU_ATTR_GET_FCT( name ) \
+ NCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\
+ {\
+-   return (Normalize_Menu( menu ) -> name);\
++   T((T_CALLED("menu_" #name "(%p)"), menu));\
++   returnAttr(Normalize_Menu( menu ) -> name);\
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -81,7 +83,7 @@
+ |   Return Values :  E_OK              - success
+ |                    E_BAD_ARGUMENT    - an invalid value has been passed   
+ +--------------------------------------------------------------------------*/
+-GEN_MENU_ATTR_SET_FCT( fore )
++GEN_MENU_ATTR_SET_FCT(fore)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -93,7 +95,7 @@
+ |
+ |   Return Values :  Attribute value
+ +--------------------------------------------------------------------------*/
+-GEN_MENU_ATTR_GET_FCT( fore )
++GEN_MENU_ATTR_GET_FCT(fore)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -105,7 +107,7 @@
+ |   Return Values :  E_OK             - success  
+ |                    E_BAD_ARGUMENT   - an invalid value has been passed
+ +--------------------------------------------------------------------------*/
+-GEN_MENU_ATTR_SET_FCT( back )
++GEN_MENU_ATTR_SET_FCT(back)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -116,7 +118,7 @@
+ |
+ |   Return Values :  Attribute value
+ +--------------------------------------------------------------------------*/
+-GEN_MENU_ATTR_GET_FCT( back )
++GEN_MENU_ATTR_GET_FCT(back)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -127,7 +129,7 @@
+ |   Return Values :  E_OK             - success
+ |                    E_BAD_ARGUMENT   - an invalid value has been passed    
+ +--------------------------------------------------------------------------*/
+-GEN_MENU_ATTR_SET_FCT( grey )
++GEN_MENU_ATTR_SET_FCT(grey)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -137,5 +139,5 @@
+ |
+ |   Return Values :  Attribute value
+ +--------------------------------------------------------------------------*/
+-GEN_MENU_ATTR_GET_FCT( grey )
++GEN_MENU_ATTR_GET_FCT(grey)
+ /* m_attribs.c ends here */
+Index: menu/m_cursor.c
+Prereq:  1.16 
+--- ncurses-5.4-20040208/menu/m_cursor.c	2003-10-25 15:23:42.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_cursor.c	2004-12-25 22:03:00.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_cursor.c,v 1.16 2003/10/25 15:23:42 tom Exp $")
++MODULE_ID("$Id: m_cursor.c,v 1.19 2004/12/25 22:03:00 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu
+@@ -50,24 +50,23 @@
+ |                    E_NOT_POSTED    - Menu is not posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-_nc_menu_cursor_pos
+-(const MENU* menu, const ITEM* item, int* pY, int* pX)
++_nc_menu_cursor_pos(const MENU * menu, const ITEM * item, int *pY, int *pX)
+ {
+   if (!menu || !pX || !pY)
+-    return(E_BAD_ARGUMENT);
++    return (E_BAD_ARGUMENT);
+   else
+     {
+-      if ((ITEM*)0 == item)
++      if ((ITEM *) 0 == item)
+ 	item = menu->curitem;
+-      assert(item!=(ITEM*)0);
++      assert(item != (ITEM *) 0);
+ 
+-      if ( !( menu->status & _POSTED ) )
+-	return(E_NOT_POSTED);
++      if (!(menu->status & _POSTED))
++	return (E_NOT_POSTED);
+ 
+       *pX = item->x * (menu->spc_cols + menu->itemlen);
+       *pY = (item->y - menu->toprow) * menu->spc_rows;
+     }
+-  return(E_OK);
++  return (E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -81,24 +80,26 @@
+ |                    E_NOT_POSTED    - Menu is not posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-pos_menu_cursor (const MENU * menu)
++pos_menu_cursor(const MENU * menu)
+ {
+   WINDOW *win, *sub;
+   int x, y;
+-  int err = _nc_menu_cursor_pos(menu,(ITEM*)0,&y,&x);
++  int err = _nc_menu_cursor_pos(menu, (ITEM *) 0, &y, &x);
+ 
+-  if (E_OK==err)
++  T((T_CALLED("pos_menu_cursor(%p)"), menu));
++
++  if (E_OK == err)
+     {
+       win = menu->userwin ? menu->userwin : stdscr;
+       sub = menu->usersub ? menu->usersub : win;
+       assert(win && sub);
+ 
+       if ((menu->opt & O_SHOWMATCH) && (menu->pindex > 0))
+-	x += ( menu->pindex + menu->marklen - 1);
++	x += (menu->pindex + menu->marklen - 1);
+ 
+-      wmove(sub,y,x);
++      wmove(sub, y, x);
+ 
+-      if ( win != sub )
++      if (win != sub)
+ 	{
+ 	  wcursyncup(sub);
+ 	  wsyncup(sub);
+Index: menu/m_driver.c
+Prereq:  1.20 
+--- ncurses-5.4-20040208/menu/m_driver.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_driver.c	2004-12-11 23:10:49.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_driver.c,v 1.20 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_driver.c,v 1.23 2004/12/11 23:10:49 tom Exp $")
+ 
+ /* Macros */
+ 
+@@ -62,28 +62,31 @@
+ |   Return Values :  TRUE   - if it is a substring
+ |                    FALSE  - if it is not a substring
+ +--------------------------------------------------------------------------*/
+-static bool Is_Sub_String(
+-			  bool  IgnoreCaseFlag,
+-			  const char *part,
+-			  const char *string
+-			 )
++static bool
++Is_Sub_String(
++	       bool IgnoreCaseFlag,
++	       const char *part,
++	       const char *string
++)
+ {
+-  assert( part && string );
+-  if ( IgnoreCaseFlag )
++  assert(part && string);
++  if (IgnoreCaseFlag)
+     {
+-      while(*string && *part)
++      while (*string && *part)
+ 	{
+-	  if (toupper(*string++)!=toupper(*part)) break;
++	  if (toupper(*string++) != toupper(*part))
++	    break;
+ 	  part++;
+ 	}
+     }
+   else
+     {
+-      while( *string && *part )
+-	if (*part != *string++) break;
++      while (*string && *part)
++	if (*part != *string++)
++	  break;
+       part++;
+     }
+-  return ( (*part) ? FALSE : TRUE );
++  return ((*part) ? FALSE : TRUE);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -113,73 +116,77 @@
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+ _nc_Match_Next_Character_In_Item_Name
+-(MENU *menu, int ch, ITEM **item)
++(MENU * menu, int ch, ITEM ** item)
+ {
+   bool found = FALSE, passed = FALSE;
+-  int  idx, last;
++  int idx, last;
++
++  T((T_CALLED("_nc_Match_Next_Character(%p,%d,%p)"), menu, ch, item));
+ 
+-  assert( menu && item && *item);
++  assert(menu && item && *item);
+   idx = (*item)->index;
+ 
+-  if (ch && ch!=BS)
++  if (ch && ch != BS)
+     {
+       /* if we become to long, we need no further checking : there can't be
+-	 a match ! */
+-      if ((menu->pindex+1) > menu->namelen)
++         a match ! */
++      if ((menu->pindex + 1) > menu->namelen)
+ 	RETURN(E_NO_MATCH);
+ 
+-      Add_Character_To_Pattern(menu,ch);
++      Add_Character_To_Pattern(menu, ch);
+       /* we artificially position one item back, because in the do...while
+-	 loop we start with the next item. This means, that with a new
+-	 pattern search we always start the scan with the actual item. If
+-	 we do a NEXT_PATTERN oder PREV_PATTERN search, we start with the
+-	 one after or before the actual item. */
++         loop we start with the next item. This means, that with a new
++         pattern search we always start the scan with the actual item. If
++         we do a NEXT_PATTERN oder PREV_PATTERN search, we start with the
++         one after or before the actual item. */
+       if (--idx < 0)
+-	idx = menu->nitems-1;
++	idx = menu->nitems - 1;
+     }
+ 
+   last = idx;			/* this closes the cycle */
+ 
+-  do{
+-    if (ch==BS)
+-      {			/* we have to go backward */
+-	if (--idx < 0)
+-	  idx = menu->nitems-1;
+-      }
+-    else
+-      {			/* otherwise we always go forward */
+-	if (++idx >= menu->nitems)
+-	  idx = 0;
+-      }
+-    if (Is_Sub_String((menu->opt & O_IGNORECASE) != 0,
+-		      menu->pattern,
+-		      menu->items[idx]->name.str)
++  do
++    {
++      if (ch == BS)
++	{			/* we have to go backward */
++	  if (--idx < 0)
++	    idx = menu->nitems - 1;
++	}
++      else
++	{			/* otherwise we always go forward */
++	  if (++idx >= menu->nitems)
++	    idx = 0;
++	}
++      if (Is_Sub_String((menu->opt & O_IGNORECASE) != 0,
++			menu->pattern,
++			menu->items[idx]->name.str)
+ 	)
+-      found = TRUE;
+-    else
+-      passed = TRUE;
+-  } while (!found && (idx != last));
++	found = TRUE;
++      else
++	passed = TRUE;
++    }
++  while (!found && (idx != last));
+ 
+   if (found)
+     {
+-      if (!((idx==(*item)->index) && passed))
++      if (!((idx == (*item)->index) && passed))
+ 	{
+ 	  *item = menu->items[idx];
+ 	  RETURN(E_OK);
+ 	}
+       /* This point is reached, if we fully cycled through the item list
+-	 and the only match we found is the starting item. With a NEXT_PATTERN
+-	 or PREV_PATTERN scan this means, that there was no additional match.
+-	 If we searched with an expanded new pattern, we should never reach
+-	 this point, because if the expanded pattern matches also the actual
+-	 item we will find it in the first attempt (passed==FALSE) and we
+-	 will never cycle through the whole item array.
+-	 */
+-      assert( ch==0 || ch==BS );
++         and the only match we found is the starting item. With a NEXT_PATTERN
++         or PREV_PATTERN scan this means, that there was no additional match.
++         If we searched with an expanded new pattern, we should never reach
++         this point, because if the expanded pattern matches also the actual
++         item we will find it in the first attempt (passed==FALSE) and we
++         will never cycle through the whole item array.
++       */
++      assert(ch == 0 || ch == BS);
+     }
+   else
+     {
+-      if (ch && ch!=BS && menu->pindex>0)
++      if (ch && ch != BS && menu->pindex > 0)
+ 	{
+ 	  /* if we had no match with a new pattern, we have to restore it */
+ 	  Remove_Character_From_Pattern(menu);
+@@ -201,7 +208,7 @@
+ |                    E_NOT_POSTED    - menu is not posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-menu_driver (MENU * menu, int   c)
++menu_driver(MENU * menu, int c)
+ {
+ #define NAVIGATE(dir) \
+   if (!item->dir)\
+@@ -213,327 +220,332 @@
+   ITEM *item;
+   int my_top_row, rdiff;
+ 
++  T((T_CALLED("menu_driver(%p,%d)"), menu, c));
++
+   if (!menu)
+     RETURN(E_BAD_ARGUMENT);
+ 
+-  if ( menu->status & _IN_DRIVER )
++  if (menu->status & _IN_DRIVER)
+     RETURN(E_BAD_STATE);
+-  if ( !( menu->status & _POSTED ) )
++  if (!(menu->status & _POSTED))
+     RETURN(E_NOT_POSTED);
+ 
+   item = menu->curitem;
+ 
+-    my_top_row = menu->toprow;
+-    assert(item);
++  my_top_row = menu->toprow;
++  assert(item);
+ 
+-    if ((c > KEY_MAX) && (c<=MAX_MENU_COMMAND))
+-      {
+-	if (!((c==REQ_BACK_PATTERN)
+-	      || (c==REQ_NEXT_MATCH) || (c==REQ_PREV_MATCH)))
+-	  {
+-	    assert( menu->pattern );
+-	    Reset_Pattern(menu);
+-	  }
+-
+-	switch(c)
+-	  {
+-	  case REQ_LEFT_ITEM:
++  if ((c > KEY_MAX) && (c <= MAX_MENU_COMMAND))
++    {
++      if (!((c == REQ_BACK_PATTERN)
++	    || (c == REQ_NEXT_MATCH) || (c == REQ_PREV_MATCH)))
++	{
++	  assert(menu->pattern);
++	  Reset_Pattern(menu);
++	}
++
++      switch (c)
++	{
++	case REQ_LEFT_ITEM:
+ 	    /*=================*/
+-	    NAVIGATE(left);
+-	    break;
++	  NAVIGATE(left);
++	  break;
+ 
+-	  case REQ_RIGHT_ITEM:
++	case REQ_RIGHT_ITEM:
+ 	    /*==================*/
+-	    NAVIGATE(right);
+-	    break;
++	  NAVIGATE(right);
++	  break;
+ 
+-	  case REQ_UP_ITEM:
++	case REQ_UP_ITEM:
+ 	    /*===============*/
+-	    NAVIGATE(up);
+-	    break;
++	  NAVIGATE(up);
++	  break;
+ 
+-	  case REQ_DOWN_ITEM:
++	case REQ_DOWN_ITEM:
+ 	    /*=================*/
+-	    NAVIGATE(down);
+-	    break;
++	  NAVIGATE(down);
++	  break;
+ 
+-	  case REQ_SCR_ULINE:
++	case REQ_SCR_ULINE:
+ 	    /*=================*/
+ 	  if (my_top_row == 0 || !(item->up))
+-	      result = E_REQUEST_DENIED;
+-	    else
+-	      {
+-		--my_top_row;
+-		item = item->up;
+-	      }
+-	    break;
++	    result = E_REQUEST_DENIED;
++	  else
++	    {
++	      --my_top_row;
++	      item = item->up;
++	    }
++	  break;
+ 
+-	  case REQ_SCR_DLINE:
++	case REQ_SCR_DLINE:
+ 	    /*=================*/
+ 	  if ((my_top_row + menu->arows >= menu->rows) || !(item->down))
+-	      {
+-		/* only if the menu has less items than rows, we can deny the
+-		   request. Otherwise the epilogue of this routine adjusts the
+-		   top row if necessary */
+-		result = E_REQUEST_DENIED;
+-	      }
+-	  else {
+-	    my_top_row++;
++	    {
++	      /* only if the menu has less items than rows, we can deny the
++	         request. Otherwise the epilogue of this routine adjusts the
++	         top row if necessary */
++	      result = E_REQUEST_DENIED;
++	    }
++	  else
++	    {
++	      my_top_row++;
+ 	      item = item->down;
+-	  }
+-	    break;
++	    }
++	  break;
+ 
+-	  case REQ_SCR_DPAGE:
++	case REQ_SCR_DPAGE:
+ 	    /*=================*/
+ 	  rdiff = menu->rows - (menu->arows + my_top_row);
+-	    if (rdiff > menu->arows)
+-	      rdiff = menu->arows;
+-	  if (rdiff<=0)
+-	      result = E_REQUEST_DENIED;
+-	    else
+-	      {
+-		my_top_row += rdiff;
+-	      while(rdiff-- > 0 && item!=(ITEM*)0)
+-		  item = item->down;
+-	      }
+-	    break;
++	  if (rdiff > menu->arows)
++	    rdiff = menu->arows;
++	  if (rdiff <= 0)
++	    result = E_REQUEST_DENIED;
++	  else
++	    {
++	      my_top_row += rdiff;
++	      while (rdiff-- > 0 && item != (ITEM *) 0)
++		item = item->down;
++	    }
++	  break;
+ 
+-	  case REQ_SCR_UPAGE:
++	case REQ_SCR_UPAGE:
+ 	    /*=================*/
+ 	  rdiff = (menu->arows < my_top_row) ? menu->arows : my_top_row;
+-	  if (rdiff<=0)
+-	      result = E_REQUEST_DENIED;
+-	    else
+-	      {
+-		my_top_row -= rdiff;
+-	      while(rdiff-- && item!=(ITEM*)0)
+-		  item = item->up;
+-	      }
+-	    break;
++	  if (rdiff <= 0)
++	    result = E_REQUEST_DENIED;
++	  else
++	    {
++	      my_top_row -= rdiff;
++	      while (rdiff-- && item != (ITEM *) 0)
++		item = item->up;
++	    }
++	  break;
+ 
+-	  case REQ_FIRST_ITEM:
++	case REQ_FIRST_ITEM:
+ 	    /*==================*/
+-	    item = menu->items[0];
+-	    break;
++	  item = menu->items[0];
++	  break;
+ 
+-	  case REQ_LAST_ITEM:
++	case REQ_LAST_ITEM:
+ 	    /*=================*/
+-	    item = menu->items[menu->nitems-1];
+-	    break;
++	  item = menu->items[menu->nitems - 1];
++	  break;
+ 
+-	  case REQ_NEXT_ITEM:
++	case REQ_NEXT_ITEM:
+ 	    /*=================*/
+-	    if ((item->index+1)>=menu->nitems)
+-	      {
+-		if (menu->opt & O_NONCYCLIC)
+-		  result = E_REQUEST_DENIED;
+-		else
+-		  item = menu->items[0];
+-	      }
+-	    else
+-	      item = menu->items[item->index + 1];
+-	    break;
++	  if ((item->index + 1) >= menu->nitems)
++	    {
++	      if (menu->opt & O_NONCYCLIC)
++		result = E_REQUEST_DENIED;
++	      else
++		item = menu->items[0];
++	    }
++	  else
++	    item = menu->items[item->index + 1];
++	  break;
+ 
+-	  case REQ_PREV_ITEM:
++	case REQ_PREV_ITEM:
+ 	    /*=================*/
+-	    if (item->index<=0)
+-	      {
+-		if (menu->opt & O_NONCYCLIC)
+-		  result = E_REQUEST_DENIED;
+-		else
+-		  item = menu->items[menu->nitems-1];
+-	      }
+-	    else
+-	      item = menu->items[item->index - 1];
+-	    break;
++	  if (item->index <= 0)
++	    {
++	      if (menu->opt & O_NONCYCLIC)
++		result = E_REQUEST_DENIED;
++	      else
++		item = menu->items[menu->nitems - 1];
++	    }
++	  else
++	    item = menu->items[item->index - 1];
++	  break;
+ 
+-	  case REQ_TOGGLE_ITEM:
++	case REQ_TOGGLE_ITEM:
+ 	    /*===================*/
+-	    if (menu->opt & O_ONEVALUE)
+-	      {
+-		result = E_REQUEST_DENIED;
+-	      }
+-	    else
+-	      {
+-		if (menu->curitem->opt & O_SELECTABLE)
+-		  {
+-		    menu->curitem->value = !menu->curitem->value;
+-		    Move_And_Post_Item(menu,menu->curitem);
+-		    _nc_Show_Menu(menu);
+-		  }
+-		else
+-		  result = E_NOT_SELECTABLE;
+-	      }
+-	    break;
++	  if (menu->opt & O_ONEVALUE)
++	    {
++	      result = E_REQUEST_DENIED;
++	    }
++	  else
++	    {
++	      if (menu->curitem->opt & O_SELECTABLE)
++		{
++		  menu->curitem->value = !menu->curitem->value;
++		  Move_And_Post_Item(menu, menu->curitem);
++		  _nc_Show_Menu(menu);
++		}
++	      else
++		result = E_NOT_SELECTABLE;
++	    }
++	  break;
+ 
+-	  case REQ_CLEAR_PATTERN:
++	case REQ_CLEAR_PATTERN:
+ 	    /*=====================*/
+-	    /* already cleared in prologue */
+-	    break;
++	  /* already cleared in prologue */
++	  break;
+ 
+-	  case REQ_BACK_PATTERN:
++	case REQ_BACK_PATTERN:
+ 	    /*====================*/
+-	    if (menu->pindex>0)
+-	      {
+-		assert(menu->pattern);
+-		Remove_Character_From_Pattern(menu);
+-		pos_menu_cursor( menu );
+-	      }
+-	    else
+-	      result = E_REQUEST_DENIED;
+-	    break;
++	  if (menu->pindex > 0)
++	    {
++	      assert(menu->pattern);
++	      Remove_Character_From_Pattern(menu);
++	      pos_menu_cursor(menu);
++	    }
++	  else
++	    result = E_REQUEST_DENIED;
++	  break;
+ 
+-	  case REQ_NEXT_MATCH:
++	case REQ_NEXT_MATCH:
+ 	    /*==================*/
+-	    assert(menu->pattern);
+-	    if (menu->pattern[0])
+-	      result = _nc_Match_Next_Character_In_Item_Name(menu,0,&item);
+-	    else
+-	      {
+-		if ((item->index+1)<menu->nitems)
+-		  item=menu->items[item->index+1];
+-		else
+-		  {
+-		    if (menu->opt & O_NONCYCLIC)
+-		      result = E_REQUEST_DENIED;
+-		    else
+-		      item = menu->items[0];
+-		  }
+-	      }
+-	    break;
++	  assert(menu->pattern);
++	  if (menu->pattern[0])
++	    result = _nc_Match_Next_Character_In_Item_Name(menu, 0, &item);
++	  else
++	    {
++	      if ((item->index + 1) < menu->nitems)
++		item = menu->items[item->index + 1];
++	      else
++		{
++		  if (menu->opt & O_NONCYCLIC)
++		    result = E_REQUEST_DENIED;
++		  else
++		    item = menu->items[0];
++		}
++	    }
++	  break;
+ 
+-	  case REQ_PREV_MATCH:
++	case REQ_PREV_MATCH:
+ 	    /*==================*/
+-	    assert(menu->pattern);
+-	    if (menu->pattern[0])
+-	      result = _nc_Match_Next_Character_In_Item_Name(menu,BS,&item);
+-	    else
+-	      {
+-		if (item->index)
+-		  item = menu->items[item->index-1];
+-		else
+-		  {
+-		    if (menu->opt & O_NONCYCLIC)
+-		      result = E_REQUEST_DENIED;
+-		    else
+-		      item = menu->items[menu->nitems-1];
+-		  }
+-	      }
+-	    break;
++	  assert(menu->pattern);
++	  if (menu->pattern[0])
++	    result = _nc_Match_Next_Character_In_Item_Name(menu, BS, &item);
++	  else
++	    {
++	      if (item->index)
++		item = menu->items[item->index - 1];
++	      else
++		{
++		  if (menu->opt & O_NONCYCLIC)
++		    result = E_REQUEST_DENIED;
++		  else
++		    item = menu->items[menu->nitems - 1];
++		}
++	    }
++	  break;
+ 
+-	  default:
++	default:
+ 	    /*======*/
+-	    result = E_UNKNOWN_COMMAND;
+-	    break;
+-	  }
+-      }
+-    else
+-      {				/* not a command */
+-	if ( !(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(c) )
+-	  result = _nc_Match_Next_Character_In_Item_Name( menu, c, &item );
++	  result = E_UNKNOWN_COMMAND;
++	  break;
++	}
++    }
++  else
++    {				/* not a command */
++      if (!(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(UChar(c)))
++	result = _nc_Match_Next_Character_In_Item_Name(menu, c, &item);
+ #ifdef NCURSES_MOUSE_VERSION
+-        else if (KEY_MOUSE == c)
+-	  {
+-	    MEVENT	event;
+-	    WINDOW* uwin = Get_Menu_UserWin(menu);
+-
+-	    getmouse(&event);
+-	    if ((event.bstate & (BUTTON1_CLICKED         |
+-				 BUTTON1_DOUBLE_CLICKED  |
+-				 BUTTON1_TRIPLE_CLICKED   ))
+-	     && wenclose(uwin,event.y, event.x))
+-	      { /* we react only if the click was in the userwin, that means
+-		 * inside the menu display area or at the decoration window.
+-		 */
+-		WINDOW* sub = Get_Menu_Window(menu);
+-		int ry = event.y, rx = event.x; /* screen coordinates */
++      else if (KEY_MOUSE == c)
++	{
++	  MEVENT event;
++	  WINDOW *uwin = Get_Menu_UserWin(menu);
+ 
+-		result = E_REQUEST_DENIED;
+-		if (mouse_trafo(&ry,&rx,FALSE))
+-		  { /* rx, ry are now "curses" coordinates */
+-		    if (ry < sub->_begy)
+-		      { /* we clicked above the display region; this is
+-			 * interpreted as "scroll up" request
+-			 */
+-			if (event.bstate & BUTTON1_CLICKED)
+-			  result = menu_driver(menu,REQ_SCR_ULINE);
+-			else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+-			  result = menu_driver(menu,REQ_SCR_UPAGE);
+-			else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+-			  result = menu_driver(menu,REQ_FIRST_ITEM);
+-			RETURN(result);
+-		      }
+-		    else if (ry >= sub->_begy + sub->_maxy)
+-		      { /* we clicked below the display region; this is
+-			 * interpreted as "scroll down" request
+-			 */
+-			if (event.bstate & BUTTON1_CLICKED)
+-			  result = menu_driver(menu,REQ_SCR_DLINE);
+-			else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+-			  result = menu_driver(menu,REQ_SCR_DPAGE);
+-			else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+-			  result = menu_driver(menu,REQ_LAST_ITEM);
+-			RETURN(result);
+-		      }
+-		    else if (wenclose(sub,event.y,event.x))
+-		      { /* Inside the area we try to find the hit item */
+-			int i,x,y,err;
+-			ry = event.y; rx = event.x;
+-			if (wmouse_trafo(sub,&ry,&rx,FALSE))
+-			  {
+-			    for(i=0;i<menu->nitems;i++)
+-			      {
+-				err = _nc_menu_cursor_pos(menu,menu->items[i],
+-							  &y, &x);
+-				if (E_OK==err)
+-				  {
+-				    if ((ry==y)       &&
+-					(rx>=x)       &&
+-					(rx < x + menu->itemlen))
+-				      {
+-					item = menu->items[i];
+-					result = E_OK;
+-					break;
+-				      }
+-				  }
+-			      }
+-			    if (E_OK==result)
+-			      { /* We found an item, now we can handle the click.
++	  getmouse(&event);
++	  if ((event.bstate & (BUTTON1_CLICKED |
++			       BUTTON1_DOUBLE_CLICKED |
++			       BUTTON1_TRIPLE_CLICKED))
++	      && wenclose(uwin, event.y, event.x))
++	    {			/* we react only if the click was in the userwin, that means
++				 * inside the menu display area or at the decoration window.
++				 */
++	      WINDOW *sub = Get_Menu_Window(menu);
++	      int ry = event.y, rx = event.x;	/* screen coordinates */
++
++	      result = E_REQUEST_DENIED;
++	      if (mouse_trafo(&ry, &rx, FALSE))
++		{		/* rx, ry are now "curses" coordinates */
++		  if (ry < sub->_begy)
++		    {		/* we clicked above the display region; this is
++				 * interpreted as "scroll up" request
++				 */
++		      if (event.bstate & BUTTON1_CLICKED)
++			result = menu_driver(menu, REQ_SCR_ULINE);
++		      else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
++			result = menu_driver(menu, REQ_SCR_UPAGE);
++		      else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
++			result = menu_driver(menu, REQ_FIRST_ITEM);
++		      RETURN(result);
++		    }
++		  else if (ry >= sub->_begy + sub->_maxy)
++		    {		/* we clicked below the display region; this is
++				 * interpreted as "scroll down" request
++				 */
++		      if (event.bstate & BUTTON1_CLICKED)
++			result = menu_driver(menu, REQ_SCR_DLINE);
++		      else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
++			result = menu_driver(menu, REQ_SCR_DPAGE);
++		      else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
++			result = menu_driver(menu, REQ_LAST_ITEM);
++		      RETURN(result);
++		    }
++		  else if (wenclose(sub, event.y, event.x))
++		    {		/* Inside the area we try to find the hit item */
++		      int i, x, y, err;
++
++		      ry = event.y;
++		      rx = event.x;
++		      if (wmouse_trafo(sub, &ry, &rx, FALSE))
++			{
++			  for (i = 0; i < menu->nitems; i++)
++			    {
++			      err = _nc_menu_cursor_pos(menu, menu->items[i],
++							&y, &x);
++			      if (E_OK == err)
++				{
++				  if ((ry == y) &&
++				      (rx >= x) &&
++				      (rx < x + menu->itemlen))
++				    {
++				      item = menu->items[i];
++				      result = E_OK;
++				      break;
++				    }
++				}
++			    }
++			  if (E_OK == result)
++			    {	/* We found an item, now we can handle the click.
+ 				 * A single click just positions the menu cursor
+ 				 * to the clicked item. A double click toggles
+ 				 * the item.
+ 				 */
+-				if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+-				  {
+-				    _nc_New_TopRow_and_CurrentItem(menu,
+-								   my_top_row,
+-								   item);
+-				    menu_driver(menu,REQ_TOGGLE_ITEM);
+-				    result = E_UNKNOWN_COMMAND;
+-				  }
+-			      }
+-			  }
+-		      }
+-		  }
+-	      }
+-	    else
+-	        result = E_REQUEST_DENIED;
+-	  }
++			      if (event.bstate & BUTTON1_DOUBLE_CLICKED)
++				{
++				  _nc_New_TopRow_and_CurrentItem(menu,
++								 my_top_row,
++								 item);
++				  menu_driver(menu, REQ_TOGGLE_ITEM);
++				  result = E_UNKNOWN_COMMAND;
++				}
++			    }
++			}
++		    }
++		}
++	    }
++	  else
++	    result = E_REQUEST_DENIED;
++	}
+ #endif /* NCURSES_MOUSE_VERSION */
+-	else
+-	  result = E_UNKNOWN_COMMAND;
+-      }
++      else
++	result = E_UNKNOWN_COMMAND;
++    }
+ 
+-  if (E_OK==result)
++  if (E_OK == result)
+     {
+-    /* Adjust the top row if it turns out that the current item unfortunately
+-       doesn't appear in the menu window */
+-    if ( item->y < my_top_row )
+-      my_top_row = item->y;
+-    else if ( item->y >= (my_top_row + menu->arows) )
+-      my_top_row = item->y - menu->arows + 1;
++      /* Adjust the top row if it turns out that the current item unfortunately
++         doesn't appear in the menu window */
++      if (item->y < my_top_row)
++	my_top_row = item->y;
++      else if (item->y >= (my_top_row + menu->arows))
++	my_top_row = item->y - menu->arows + 1;
+ 
+-    _nc_New_TopRow_and_CurrentItem( menu, my_top_row, item );
++      _nc_New_TopRow_and_CurrentItem(menu, my_top_row, item);
+ 
+     }
+ 
+Index: menu/m_format.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/menu/m_format.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_format.c	2004-12-11 23:11:21.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,14 +37,14 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_format.c,v 1.12 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_format.c,v 1.15 2004/12/11 23:11:21 tom Exp $")
+ 
+ #define minimum(a,b) ((a)<(b) ? (a): (b))
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnmenu  
++|   Facility      :  libnmenu
+ |   Function      :  int set_menu_format(MENU *menu, int rows, int cols)
+-|   
++|
+ |   Description   :  Sets the maximum number of rows and columns of items
+ |                    that may be displayed at one time on a menu. If the
+ |                    menu contains more items than can be displayed at
+@@ -56,42 +56,44 @@
+ |                    E_POSTED               - the menu is already posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_format (MENU *menu, int rows, int cols)
++set_menu_format(MENU * menu, int rows, int cols)
+ {
+   int total_rows, total_cols;
+-  
+-  if (rows<0 || cols<0) 
++
++  T((T_CALLED("set_menu_format(%p,%d,%d)"), menu, rows, cols));
++
++  if (rows < 0 || cols < 0)
+     RETURN(E_BAD_ARGUMENT);
+-  
++
+   if (menu)
+     {
+-      if ( menu->status & _POSTED )
++      if (menu->status & _POSTED)
+ 	RETURN(E_POSTED);
+-      
++
+       if (!(menu->items))
+ 	RETURN(E_NOT_CONNECTED);
+-      
+-      if (rows==0) 
++
++      if (rows == 0)
+ 	rows = menu->frows;
+-      if (cols==0) 
++      if (cols == 0)
+ 	cols = menu->fcols;
+-      
++
+       if (menu->pattern)
+ 	Reset_Pattern(menu);
+-      
++
+       menu->frows = rows;
+       menu->fcols = cols;
+-      
+-      assert(rows>0 && cols>0);
+-      total_rows = (menu->nitems - 1)/cols + 1;
+-      total_cols = (menu->status & O_ROWMAJOR) ? 
+-	minimum(menu->nitems,cols) :
+-	  (menu->nitems-1)/total_rows + 1;
+-      
+-      menu->rows    = total_rows;
+-      menu->cols    = total_cols;
+-      menu->arows   = minimum(total_rows,rows); 
+-      menu->toprow  = 0;	
++
++      assert(rows > 0 && cols > 0);
++      total_rows = (menu->nitems - 1) / cols + 1;
++      total_cols = (menu->opt & O_ROWMAJOR) ?
++	minimum(menu->nitems, cols) :
++	(menu->nitems - 1) / total_rows + 1;
++
++      menu->rows = total_rows;
++      menu->cols = total_cols;
++      menu->arows = minimum(total_rows, rows);
++      menu->toprow = 0;
+       menu->curitem = *(menu->items);
+       assert(menu->curitem);
+       menu->status |= _LINK_NEEDED;
+@@ -99,24 +101,26 @@
+     }
+   else
+     {
+-      if (rows>0) _nc_Default_Menu.frows = rows;
+-      if (cols>0) _nc_Default_Menu.fcols = cols;
++      if (rows > 0)
++	_nc_Default_Menu.frows = rows;
++      if (cols > 0)
++	_nc_Default_Menu.fcols = cols;
+     }
+-  
++
+   RETURN(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnmenu  
++|   Facility      :  libnmenu
+ |   Function      :  void menu_format(const MENU *menu, int *rows, int *cols)
+-|   
++|
+ |   Description   :  Returns the maximum number of rows and columns that may
+ |                    be displayed at one time on menu.
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-menu_format (const MENU *menu, int *rows, int *cols)
++menu_format(const MENU * menu, int *rows, int *cols)
+ {
+   if (rows)
+     *rows = Normalize_Menu(menu)->frows;
+Index: menu/m_global.c
+Prereq:  1.16 
+--- ncurses-5.4-20040208/menu/m_global.c	2003-11-08 20:53:01.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_global.c	2005-01-16 01:02:23.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -37,10 +37,10 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_global.c,v 1.16 2003/11/08 20:53:01 tom Exp $")
++MODULE_ID("$Id: m_global.c,v 1.19 2005/01/16 01:02:23 tom Exp $")
+ 
+ static char mark[] = "-";
+-
++/* *INDENT-OFF* */
+ NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu = {
+   16,				  /* Nr. of chars high */
+   1,				  /* Nr. of chars wide */
+@@ -95,6 +95,7 @@
+   (ITEM *)0,		          /* up */
+   (ITEM *)0		          /* down */
+   };
++/* *INDENT-ON* */
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -105,24 +106,26 @@
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-INLINE static void ComputeMaximum_NameDesc_Lengths(MENU * menu)
++INLINE static void
++ComputeMaximum_NameDesc_Lengths(MENU * menu)
+ {
+-  unsigned MaximumNameLength        = 0;
++  unsigned MaximumNameLength = 0;
+   unsigned MaximumDescriptionLength = 0;
+   ITEM **items;
+-  
++
+   assert(menu && menu->items);
+-  for( items = menu->items; *items ; items++ )
++  for (items = menu->items; *items; items++)
+     {
+-      if (items[0]->name.length > MaximumNameLength )
+-	MaximumNameLength  = items[0]->name.length;
+-      
++      if (items[0]->name.length > MaximumNameLength)
++	MaximumNameLength = items[0]->name.length;
++
+       if (items[0]->description.length > MaximumDescriptionLength)
+ 	MaximumDescriptionLength = items[0]->description.length;
+     }
+-  
++
+   menu->namelen = MaximumNameLength;
+   menu->desclen = MaximumDescriptionLength;
++  T(("ComputeMaximum_NameDesc_Lengths %d,%d", menu->namelen, menu->desclen));
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -134,22 +137,23 @@
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+-INLINE static void ResetConnectionInfo(MENU *menu, ITEM **items)
++INLINE static void
++ResetConnectionInfo(MENU * menu, ITEM ** items)
+ {
+   ITEM **item;
+-  
++
+   assert(menu && items);
+-  for(item=items; *item; item++)
++  for (item = items; *item; item++)
+     {
+       (*item)->index = 0;
+-      (*item)->imenu = (MENU *)0;		
++      (*item)->imenu = (MENU *) 0;
+     }
+   if (menu->pattern)
+     free(menu->pattern);
+   menu->pattern = (char *)0;
+-  menu->pindex  = 0;
+-  menu->items   = (ITEM **)0;
+-  menu->nitems  = 0;
++  menu->pindex = 0;
++  menu->items = (ITEM **) 0;
++  menu->nitems = 0;
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -164,25 +168,25 @@
+ |                    FALSE      - connection failed
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(bool)
+-_nc_Connect_Items (MENU *menu, ITEM **items)
++_nc_Connect_Items(MENU * menu, ITEM ** items)
+ {
+   ITEM **item;
+   unsigned int ItemCount = 0;
+-  
+-  if ( menu && items )
+-    {    
+-      for(item=items; *item ; item++)
++
++  if (menu && items)
++    {
++      for (item = items; *item; item++)
+ 	{
+-	  if ( (*item)->imenu )
++	  if ((*item)->imenu)
+ 	    {
+ 	      /* if a item is already connected, reject connection */
+ 	      break;
+ 	    }
+ 	}
+-      if (! (*item) )		
++      if (!(*item))
+ 	/* we reached the end, so there was no connected item */
+ 	{
+-	  for(item=items; *item ; item++)
++	  for (item = items; *item; item++)
+ 	    {
+ 	      if (menu->opt & O_ONEVALUE)
+ 		{
+@@ -190,31 +194,31 @@
+ 		}
+ 	      (*item)->index = ItemCount++;
+ 	      (*item)->imenu = menu;
+-	    }			
++	    }
+ 	}
+     }
+   else
+-    return(FALSE);
+-  
++    return (FALSE);
++
+   if (ItemCount != 0)
+     {
+-      menu->items  = items;
++      menu->items = items;
+       menu->nitems = ItemCount;
+       ComputeMaximum_NameDesc_Lengths(menu);
+-      if ( (menu->pattern = (char *)malloc( (unsigned)(1 + menu->namelen))) )
++      if ((menu->pattern = typeMalloc(char, (unsigned)(1 + menu->namelen))))
+ 	{
+-	  Reset_Pattern(menu);	
+-	  set_menu_format(menu,menu->frows,menu->fcols);
++	  Reset_Pattern(menu);
++	  set_menu_format(menu, menu->frows, menu->fcols);
+ 	  menu->curitem = *items;
+ 	  menu->toprow = 0;
+-	  return(TRUE);
++	  return (TRUE);
+ 	}
+     }
+-  
++
+   /* If we fall through to this point, we have to reset all items connection 
+      and inform about a reject connection */
+-  ResetConnectionInfo( menu, items );
+-  return(FALSE);
++  ResetConnectionInfo(menu, items);
++  return (FALSE);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -226,14 +230,91 @@
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-_nc_Disconnect_Items (MENU * menu)
++_nc_Disconnect_Items(MENU * menu)
+ {
+   if (menu && menu->items)
+-    ResetConnectionInfo( menu, menu->items );
++    ResetConnectionInfo(menu, menu->items);
+ }
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
++|   Function      :  int _nc_Calculate_Text_Width(const TEXT * item)
++|   
++|   Description   :  Calculate the number of columns for a TEXT.
++|
++|   Return Values :  the width
+++--------------------------------------------------------------------------*/
++NCURSES_EXPORT(int)
++_nc_Calculate_Text_Width(const TEXT * item /*FIXME: limit length */ )
++{
++#if USE_WIDEC_SUPPORT
++  int result = item->length;
++  int count = mbstowcs(0, item->str, 0);
++  wchar_t *temp = 0;
++
++  T((T_CALLED("_nc_menu_text_width(%p)"), item));
++  if (count > 0
++      && (temp = typeMalloc(wchar_t, 2 + count)) != 0)
++    {
++      int n;
++
++      result = 0;
++      mbstowcs(temp, item->str, count);
++      for (n = 0; n < count; ++n)
++	{
++	  int test = wcwidth(temp[n]);
++
++	  if (test <= 0)
++	    test = 1;
++	  result += test;
++	}
++      free(temp);
++    }
++  returnCode(result);
++#else
++  return item->length;
++#endif
++}
++
++/* FIXME: this is experimental, should cache the results but don't want to
++ * modify the MENU struct to do this until it's complete.
++ */
++#if 0				/* USE_WIDEC_SUPPORT */
++static int
++calculate_actual_width(MENU * menu, bool name)
++{
++  int width = 0;
++  int check = 0;
++  ITEM **items;
++
++  assert(menu && menu->items);
++  for (items = menu->items; *items; items++)
++    {
++      if (name)
++	{
++	  check = _nc_Calculate_Text_Width(&((*items)->name));
++	}
++      else
++	{
++	  check = _nc_Calculate_Text_Width(&((*items)->description));
++	}
++      if (check > width)
++	width = check;
++    }
++
++  T(("calculate_actual_width %s = %d/%d",
++     name ? "name" : "desc",
++     width,
++     name ? menu->namelen : menu->desclen));
++  width += 2;			/* FIXME - need this? */
++  return width;
++}
++#else
++#define calculate_actual_width(menu, name) (name ? menu->namelen : menu->desclen)
++#endif
++
++/*---------------------------------------------------------------------------
++|   Facility      :  libnmenu  
+ |   Function      :  void _nc_Calculate_Item_Length_and_Width(MENU *menu)
+ |   
+ |   Description   :  Calculate the length of an item and the width of the
+@@ -242,23 +323,33 @@
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-_nc_Calculate_Item_Length_and_Width (MENU * menu)
++_nc_Calculate_Item_Length_and_Width(MENU * menu)
+ {
+   int l;
+-  
++
+   assert(menu);
+ 
+-  menu->height  = 1 + menu->spc_rows * (menu->arows - 1);
++  menu->height = 1 + menu->spc_rows * (menu->arows - 1);
++
++  l = calculate_actual_width(menu, TRUE);
++  l += menu->marklen;
++
++  if ((menu->opt & O_SHOWDESC) && (menu->desclen > 0))
++    {
++      l += calculate_actual_width(menu, FALSE);
++      l += menu->spc_desc;
++    }
+ 
+-  l = menu->namelen + menu->marklen;
+-  if ( (menu->opt & O_SHOWDESC) && (menu->desclen > 0) )
+-    l += (menu->desclen + menu->spc_desc);
+-  
+   menu->itemlen = l;
+   l *= menu->cols;
+-  l += (menu->cols-1)*menu->spc_cols; /* for the padding between the columns */
++  l += (menu->cols - 1) * menu->spc_cols;	/* for the padding between the columns */
+   menu->width = l;
+-}  
++
++  T(("_nc_CalculateItem_Length_and_Width columns %d, item %d, width %d",
++     menu->cols,
++     menu->itemlen,
++     menu->width));
++}
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -271,64 +362,64 @@
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-_nc_Link_Items (MENU * menu)
++_nc_Link_Items(MENU * menu)
+ {
+   if (menu && menu->items && *(menu->items))
+     {
+-      int i,j;
++      int i, j;
+       ITEM *item;
+       int Number_Of_Items = menu->nitems;
+       int col = 0, row = 0;
+       int Last_in_Row;
+       int Last_in_Column;
+       bool cycle = (menu->opt & O_NONCYCLIC) ? FALSE : TRUE;
+-      
++
+       menu->status &= ~_LINK_NEEDED;
+-      
++
+       if (menu->opt & O_ROWMAJOR)
+ 	{
+ 	  int Number_Of_Columns = menu->cols;
+-	  
+-	  for(i=0; i < Number_Of_Items; i++)
++
++	  for (i = 0; i < Number_Of_Items; i++)
+ 	    {
+ 	      item = menu->items[i];
+-	      
+-	      Last_in_Row = row * Number_Of_Columns + (Number_Of_Columns-1);
+-	      
+-	      item->left  = (col) ? 
+-		/* if we are not in the leftmost column, we can use the
+-		   predecessor in the items array */
+-		menu->items[i-1] :
+-		  (cycle ? menu->items[(Last_in_Row>=Number_Of_Items) ? 
+-				       Number_Of_Items-1:
+-				       Last_in_Row] : 
+-		   (ITEM *)0 );
+-	      
+-	      item->right = (  (col < (Number_Of_Columns-1)) && 
+-			     ((i+1) < Number_Of_Items) 
+-			     ) ? 
+-			       menu->items[i+1] :
+-				 ( cycle ? menu->items[row * Number_Of_Columns] : 
+-				  (ITEM *)0
+-				  );
+-	      
+-	      Last_in_Column = (menu->rows-1) * Number_Of_Columns + col;
+-	      
+-	      item->up    = (row) ? menu->items[i-Number_Of_Columns] :
+-		(cycle ? menu->items[(Last_in_Column>=Number_Of_Items) ?
+-				     Number_Of_Items-1 : 
+-				     Last_in_Column] : 
+-		 (ITEM *)0);
+-	      
+-	      item->down  = ( (i+Number_Of_Columns) < Number_Of_Items ) 
+-		? 
+-		  menu->items[i + Number_Of_Columns] :
+-		    (cycle ? menu->items[(row+1)<menu->rows ?
+-					 Number_Of_Items-1:col] : 
+-		     (ITEM *)0);
++
++	      Last_in_Row = row * Number_Of_Columns + (Number_Of_Columns - 1);
++
++	      item->left = (col) ?
++	      /* if we are not in the leftmost column, we can use the
++	         predecessor in the items array */
++		menu->items[i - 1] :
++		(cycle ? menu->items[(Last_in_Row >= Number_Of_Items) ?
++				     Number_Of_Items - 1 :
++				     Last_in_Row] :
++		 (ITEM *) 0);
++
++	      item->right = ((col < (Number_Of_Columns - 1)) &&
++			     ((i + 1) < Number_Of_Items)
++		)?
++		menu->items[i + 1] :
++		(cycle ? menu->items[row * Number_Of_Columns] :
++		 (ITEM *) 0
++		);
++
++	      Last_in_Column = (menu->rows - 1) * Number_Of_Columns + col;
++
++	      item->up = (row) ? menu->items[i - Number_Of_Columns] :
++		(cycle ? menu->items[(Last_in_Column >= Number_Of_Items) ?
++				     Number_Of_Items - 1 :
++				     Last_in_Column] :
++		 (ITEM *) 0);
++
++	      item->down = ((i + Number_Of_Columns) < Number_Of_Items)
++		?
++		menu->items[i + Number_Of_Columns] :
++		(cycle ? menu->items[(row + 1) < menu->rows ?
++				     Number_Of_Items - 1 : col] :
++		 (ITEM *) 0);
+ 	      item->x = col;
+ 	      item->y = row;
+-	      if ( ++col == Number_Of_Columns )
++	      if (++col == Number_Of_Columns)
+ 		{
+ 		  row++;
+ 		  col = 0;
+@@ -338,48 +429,48 @@
+       else
+ 	{
+ 	  int Number_Of_Rows = menu->rows;
+-	  
+-	  for(j=0; j<Number_Of_Items; j++)
++
++	  for (j = 0; j < Number_Of_Items; j++)
+ 	    {
+-	      item = menu->items[i=(col * Number_Of_Rows + row)];
+-	      
+-	      Last_in_Column = (menu->cols-1) * Number_Of_Rows + row;
+-	      
+-	      item->left  = (col) ? 
++	      item = menu->items[i = (col * Number_Of_Rows + row)];
++
++	      Last_in_Column = (menu->cols - 1) * Number_Of_Rows + row;
++
++	      item->left = (col) ?
+ 		menu->items[i - Number_Of_Rows] :
+-		  (cycle ? (Last_in_Column >= Number_Of_Items ) ? 
+-		   menu->items[Last_in_Column-Number_Of_Rows] : 
+-		   menu->items[Last_in_Column] : 
+-		   (ITEM *)0 );
+-	      
+-	      item->right = ((i + Number_Of_Rows) <Number_Of_Items) 
+-		? 
+-		  menu->items[i + Number_Of_Rows] :
+-		    (cycle ? menu->items[row] : (ITEM *)0);
+-	      
++		(cycle ? (Last_in_Column >= Number_Of_Items) ?
++		 menu->items[Last_in_Column - Number_Of_Rows] :
++		 menu->items[Last_in_Column] :
++		 (ITEM *) 0);
++
++	      item->right = ((i + Number_Of_Rows) < Number_Of_Items)
++		?
++		menu->items[i + Number_Of_Rows] :
++		(cycle ? menu->items[row] : (ITEM *) 0);
++
+ 	      Last_in_Row = col * Number_Of_Rows + (Number_Of_Rows - 1);
+-	      
+-	      item->up    = (row) ? 
+-		menu->items[i-1] :
+-		  (cycle ?
+-		   menu->items[(Last_in_Row>=Number_Of_Items) ? 
+-			       Number_Of_Items-1:
+-			       Last_in_Row] :
+-		   (ITEM *)0);
+-	      
+-	      item->down  = (row < (Number_Of_Rows-1)) 
+-		? 
+-		  (menu->items[((i+1)<Number_Of_Items) ? 
+-			       i+1 :
+-			       (col-1)*Number_Of_Rows + row + 1]) :
+-				 (cycle ?
+-				  menu->items[col * Number_Of_Rows] :
+-				  (ITEM *)0
+-				  );
+-	      
++
++	      item->up = (row) ?
++		menu->items[i - 1] :
++		(cycle ?
++		 menu->items[(Last_in_Row >= Number_Of_Items) ?
++			     Number_Of_Items - 1 :
++			     Last_in_Row] :
++		 (ITEM *) 0);
++
++	      item->down = (row < (Number_Of_Rows - 1))
++		?
++		(menu->items[((i + 1) < Number_Of_Items) ?
++			     i + 1 :
++			     (col - 1) * Number_Of_Rows + row + 1]) :
++		(cycle ?
++		 menu->items[col * Number_Of_Rows] :
++		 (ITEM *) 0
++		);
++
+ 	      item->x = col;
+ 	      item->y = row;
+-	      if ( (++row) == Number_Of_Rows )
++	      if ((++row) == Number_Of_Rows)
+ 		{
+ 		  col++;
+ 		  row = 0;
+@@ -398,31 +489,31 @@
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-_nc_Show_Menu (const MENU *menu)
++_nc_Show_Menu(const MENU * menu)
+ {
+   WINDOW *win;
+   int maxy, maxx;
+-  
++
+   assert(menu);
+-  if ( (menu->status & _POSTED) && !(menu->status & _IN_DRIVER) )
++  if ((menu->status & _POSTED) && !(menu->status & _IN_DRIVER))
+     {
+       /* adjust the internal subwindow to start on the current top */
+       assert(menu->sub);
+-      mvderwin(menu->sub,menu->spc_rows * menu->toprow,0);
++      mvderwin(menu->sub, menu->spc_rows * menu->toprow, 0);
+       win = Get_Menu_Window(menu);
+-      
++
+       maxy = getmaxy(win);
+-      maxx = getmaxx(win);	 
+-      
+-      if (menu->height < maxy) 
++      maxx = getmaxx(win);
++
++      if (menu->height < maxy)
+ 	maxy = menu->height;
+-      if (menu->width < maxx) 
++      if (menu->width < maxx)
+ 	maxx = menu->width;
+-      
+-      copywin(menu->sub,win,0,0,0,0,maxy-1,maxx-1,0);
++
++      copywin(menu->sub, win, 0, 0, 0, 0, maxy - 1, maxx - 1, 0);
+       pos_menu_cursor(menu);
+-    }	
+-}	
++    }
++}
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -438,41 +529,41 @@
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-_nc_New_TopRow_and_CurrentItem
+-(MENU *menu, int new_toprow, ITEM *new_current_item)
++  _nc_New_TopRow_and_CurrentItem
++  (MENU * menu, int new_toprow, ITEM * new_current_item)
+ {
+   ITEM *cur_item;
+   bool mterm_called = FALSE;
+   bool iterm_called = FALSE;
+-  
++
+   assert(menu);
+   if (menu->status & _POSTED)
+     {
+       if (new_current_item != menu->curitem)
+ 	{
+-	  Call_Hook(menu,itemterm);
++	  Call_Hook(menu, itemterm);
+ 	  iterm_called = TRUE;
+ 	}
+       if (new_toprow != menu->toprow)
+ 	{
+-	  Call_Hook(menu,menuterm);
++	  Call_Hook(menu, menuterm);
+ 	  mterm_called = TRUE;
+-	}			
+-      
+-      cur_item  = menu->curitem;
++	}
++
++      cur_item = menu->curitem;
+       assert(cur_item);
+-      menu->toprow  = new_toprow;
+-      menu->curitem = new_current_item;			
+-      
++      menu->toprow = new_toprow;
++      menu->curitem = new_current_item;
++
+       if (mterm_called)
+ 	{
+-	  Call_Hook(menu,menuinit);
++	  Call_Hook(menu, menuinit);
+ 	}
+       if (iterm_called)
+ 	{
+ 	  /* this means, move from the old current_item to the new one... */
+-	  Move_To_Current_Item( menu, cur_item );
+-	  Call_Hook(menu,iteminit);
++	  Move_To_Current_Item(menu, cur_item);
++	  Call_Hook(menu, iteminit);
+ 	}
+       if (mterm_called || iterm_called)
+ 	{
+@@ -482,8 +573,8 @@
+ 	pos_menu_cursor(menu);
+     }
+   else
+-    { /* if we are not posted, this is quite simple */
+-      menu->toprow  = new_toprow;
++    {				/* if we are not posted, this is quite simple */
++      menu->toprow = new_toprow;
+       menu->curitem = new_current_item;
+     }
+ }
+Index: menu/m_hook.c
+Prereq:  1.11 
+--- ncurses-5.4-20040208/menu/m_hook.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_hook.c	2004-12-25 21:39:52.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,12 +37,13 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_hook.c,v 1.11 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_hook.c,v 1.14 2004/12/25 21:39:52 tom Exp $")
+ 
+ /* "Template" macro to generate function to set application specific hook */
+ #define GEN_HOOK_SET_FUNCTION( typ, name ) \
+ NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\
+ {\
++   T((T_CALLED("set_" #typ "_" #name "(%p,%p)"), menu, func));\
+    (Normalize_Menu(menu) -> typ ## name = func );\
+    RETURN(E_OK);\
+ }
+@@ -51,7 +52,8 @@
+ #define GEN_HOOK_GET_FUNCTION( typ, name ) \
+ NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\
+ {\
+-   return (Normalize_Menu(menu) -> typ ## name);\
++   T((T_CALLED(#typ "_" #name "(%p)"), menu));\
++   returnMenuHook(Normalize_Menu(menu) -> typ ## name);\
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -63,7 +65,7 @@
+ |
+ |   Return Values :  E_OK               - success
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_SET_FUNCTION( menu, init )		  
++GEN_HOOK_SET_FUNCTION(menu, init)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -75,7 +77,7 @@
+ |
+ |   Return Values :  Menu init function address or NULL
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_GET_FUNCTION( menu, init )
++GEN_HOOK_GET_FUNCTION(menu, init)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -86,7 +88,7 @@
+ |
+ |   Return Values :  E_OK               - success
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_SET_FUNCTION( menu, term )		  
++GEN_HOOK_SET_FUNCTION(menu, term)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -98,7 +100,7 @@
+ |
+ |   Return Values :  Menu finalization function address or NULL
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_GET_FUNCTION( menu, term )
++GEN_HOOK_GET_FUNCTION(menu, term)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -109,7 +111,7 @@
+ |
+ |   Return Values :  E_OK               - success
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_SET_FUNCTION( item, init )		  
++GEN_HOOK_SET_FUNCTION(item, init)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -121,7 +123,7 @@
+ |
+ |   Return Values :  Item init function address or NULL
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_GET_FUNCTION( item, init )
++GEN_HOOK_GET_FUNCTION(item, init)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -132,7 +134,7 @@
+ |
+ |   Return Values :  E_OK               - success
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_SET_FUNCTION( item, term )		  
++GEN_HOOK_SET_FUNCTION(item, term)
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -144,6 +146,6 @@
+ |
+ |   Return Values :  Item finalization function address or NULL
+ +--------------------------------------------------------------------------*/
+-GEN_HOOK_GET_FUNCTION( item, term )
++GEN_HOOK_GET_FUNCTION(item, term)
+ 
+ /* m_hook.c ends here */
+Index: menu/m_item_cur.c
+Prereq:  1.14 
+--- ncurses-5.4-20040208/menu/m_item_cur.c	2003-10-25 15:23:42.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_item_cur.c	2004-12-25 21:57:38.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_item_cur.c,v 1.14 2003/10/25 15:23:42 tom Exp $")
++MODULE_ID("$Id: m_item_cur.c,v 1.17 2004/12/25 21:57:38 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -48,14 +48,16 @@
+ |   Return Values :  E_OK                - success
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_current_item (MENU * menu, ITEM * item)
++set_current_item(MENU * menu, ITEM * item)
+ {
+-  if (menu && item && (item->imenu==menu))
++  T((T_CALLED("set_current_item(%p,%p)"), menu, item));
++
++  if (menu && item && (item->imenu == menu))
+     {
+-      if ( menu->status & _IN_DRIVER )
++      if (menu->status & _IN_DRIVER)
+ 	RETURN(E_BAD_STATE);
+-      
+-      assert( menu->curitem );
++
++      assert(menu->curitem);
+       if (item != menu->curitem)
+ 	{
+ 	  if (menu->status & _LINK_NEEDED)
+@@ -69,12 +71,12 @@
+ 	  assert(menu->pattern);
+ 	  Reset_Pattern(menu);
+ 	  /* adjust the window to make item visible and update the menu */
+-	  Adjust_Current_Item(menu,menu->toprow,item);
++	  Adjust_Current_Item(menu, menu->toprow, item);
+ 	}
+     }
+   else
+     RETURN(E_BAD_ARGUMENT);
+-  
++
+   RETURN(E_OK);
+ }
+ 
+@@ -87,9 +89,10 @@
+ |   Return Values :  Item pointer or NULL if failure
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(ITEM *)
+-current_item (const MENU * menu) 
++current_item(const MENU * menu)
+ {
+-  return (menu && menu->items) ? menu->curitem : (ITEM *)0;
++  T((T_CALLED("current_item(%p)"), menu));
++  returnItem((menu && menu->items) ? menu->curitem : (ITEM *) 0);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -101,9 +104,10 @@
+ |   Return Values :  The index or ERR if this is an invalid item pointer
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-item_index (const ITEM *item)
++item_index(const ITEM * item)
+ {
+-  return (item && item->imenu) ? item->index : ERR;
++  T((T_CALLED("item_index(%p)"), item));
++  returnCode((item && item->imenu) ? item->index : ERR);
+ }
+ 
+ /* m_item_cur.c ends here */
+Index: menu/m_item_nam.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/menu/m_item_nam.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_item_nam.c	2004-12-25 21:41:54.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_item_nam.c,v 1.12 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_item_nam.c,v 1.14 2004/12/25 21:41:54 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -48,11 +48,12 @@
+ |   Return Values :  See above; returns NULL if item is invalid
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(const char *)
+-item_name (const ITEM * item) 
++item_name(const ITEM * item)
+ {
+-  return ((item) ? item->name.str : (char *)0);
++  T((T_CALLED("item_name(%p)"), item));
++  returnCPtr((item) ? item->name.str : (char *)0);
+ }
+-		
++
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+ |   Function      :  char *item_description(const ITEM *item)
+@@ -62,9 +63,10 @@
+ |   Return Values :  See above; Returns NULL if item is invalid
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(const char *)
+-item_description (const ITEM * item)
++item_description(const ITEM * item)
+ {
+-  return ((item) ? item->description.str : (char *)0);
++  T((T_CALLED("item_description(%p)"), item));
++  returnCPtr((item) ? item->description.str : (char *)0);
+ }
+ 
+ /* m_item_nam.c ends here */
+Index: menu/m_item_new.c
+Prereq:  1.14 
+--- ncurses-5.4-20040208/menu/m_item_new.c	2003-10-25 15:23:42.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_item_new.c	2005-01-16 01:02:23.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -38,7 +38,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_item_new.c,v 1.14 2003/10/25 15:23:42 tom Exp $")
++MODULE_ID("$Id: m_item_new.c,v 1.22 2005/01/16 01:02:23 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -50,16 +50,48 @@
+ |   Return Values :  TRUE     - if string is printable
+ |                    FALSE    - if string contains non-printable characters
+ +--------------------------------------------------------------------------*/
+-static bool Is_Printable_String(const char *s)
++static bool
++Is_Printable_String(const char *s)
+ {
++  int result = TRUE;
++
++#if USE_WIDEC_SUPPORT
++  int count = mbstowcs(0, s, 0);
++  wchar_t *temp = 0;
++
++  assert(s);
++
++  if (count > 0
++      && (temp = typeMalloc(wchar_t, (2 + count))) != 0)
++    {
++      int n;
++
++      mbstowcs(temp, s, count);
++      for (n = 0; n < count; ++n)
++	{
++	  int test = wcwidth(temp[n]);
++
++	  if (test <= 0)
++	    {
++	      result = FALSE;
++	      break;
++	    }
++	}
++      free(temp);
++    }
++#else
+   assert(s);
+-  while(*s)
++  while (*s)
+     {
+-      if (!isprint((unsigned char)*s))
+-	return FALSE;
++      if (!isprint(UChar(*s)))
++	{
++	  result = FALSE;
++	  break;
++	}
+       s++;
+     }
+-  return TRUE;
++#endif
++  return result;
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -73,41 +105,45 @@
+ |   Return Values :  The item pointer or NULL if creation failed.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(ITEM *)
+-new_item (const char *name, const char *description)
++new_item(const char *name, const char *description)
+ {
+   ITEM *item;
+-  
+-  if ( !name || (*name == '\0') || !Is_Printable_String(name) )
++
++  T((T_CALLED("new_item(\"%s\", \"%s\")"),
++     name ? name : "",
++     description ? description : ""));
++
++  if (!name || (*name == '\0') || !Is_Printable_String(name))
+     {
+-      item = (ITEM *)0;
+-      SET_ERROR( E_BAD_ARGUMENT );
++      item = (ITEM *) 0;
++      SET_ERROR(E_BAD_ARGUMENT);
+     }
+   else
+     {
+-      item = (ITEM *)calloc(1,sizeof(ITEM));
++      item = (ITEM *) calloc(1, sizeof(ITEM));
+       if (item)
+ 	{
+-	  *item  = _nc_Default_Item; /* hope we have struct assignment */
+-	  
+-	  item->name.length	   = strlen(name);
+-	  item->name.str 	   = name;
++	  *item = _nc_Default_Item;	/* hope we have struct assignment */
++
++	  item->name.length = strlen(name);
++	  item->name.str = name;
+ 
+-	  if (description && (*description != '\0') && 
++	  if (description && (*description != '\0') &&
+ 	      Is_Printable_String(description))
+ 	    {
+-	      item->description.length = strlen(description);	      
+-	      item->description.str    = description;
++	      item->description.length = strlen(description);
++	      item->description.str = description;
+ 	    }
+ 	  else
+ 	    {
+ 	      item->description.length = 0;
+-	      item->description.str    = (char *)0;
++	      item->description.str = (char *)0;
+ 	    }
+ 	}
+       else
+-	SET_ERROR( E_SYSTEM_ERROR );
+-    }  
+-  return(item);
++	SET_ERROR(E_SYSTEM_ERROR);
++    }
++  returnItem(item);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -122,17 +158,19 @@
+ |                    E_CONNECTED       - item is still connected to a menu    
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-free_item (ITEM * item)
++free_item(ITEM * item)
+ {
++  T((T_CALLED("free_item(%p)"), item));
++
+   if (!item)
+-    RETURN( E_BAD_ARGUMENT );
++    RETURN(E_BAD_ARGUMENT);
+ 
+   if (item->imenu)
+-    RETURN( E_CONNECTED );
+-  
++    RETURN(E_CONNECTED);
++
+   free(item);
+ 
+-  RETURN( E_OK );
++  RETURN(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -153,16 +191,18 @@
+ |                    E_SYSTEM_ERROR     - no memory to store mark
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_mark (MENU * menu, const char * mark)
++set_menu_mark(MENU * menu, const char *mark)
+ {
+   int l;
+ 
+-  if ( mark && (*mark != '\0') && Is_Printable_String(mark) )
++  T((T_CALLED("set_menu_mark(%p,%s)"), menu, _nc_visbuf(mark)));
++
++  if (mark && (*mark != '\0') && Is_Printable_String(mark))
+     l = strlen(mark);
+   else
+     l = 0;
+ 
+-  if ( menu )
++  if (menu)
+     {
+       char *old_mark = menu->mark;
+       unsigned short old_status = menu->status;
+@@ -171,13 +211,13 @@
+ 	{
+ 	  /* If the menu is already posted, the geometry is fixed. Then
+ 	     we can only accept a mark with exactly the same length */
+-	  if (menu->marklen != l) 
++	  if (menu->marklen != l)
+ 	    RETURN(E_BAD_ARGUMENT);
+-	}	
++	}
+       menu->marklen = l;
+       if (l)
+ 	{
+-	  menu->mark = (char *)malloc(l+1);
++	  menu->mark = (char *)malloc(l + 1);
+ 	  if (menu->mark)
+ 	    {
+ 	      strcpy(menu->mark, mark);
+@@ -192,24 +232,24 @@
+ 	}
+       else
+ 	menu->mark = (char *)0;
+-      
++
+       if ((old_status & _MARK_ALLOCATED) && old_mark)
+ 	free(old_mark);
+ 
+       if (menu->status & _POSTED)
+ 	{
+-	  _nc_Draw_Menu( menu );
+-	  _nc_Show_Menu( menu );
++	  _nc_Draw_Menu(menu);
++	  _nc_Show_Menu(menu);
+ 	}
+       else
+ 	{
+ 	  /* Recalculate the geometry */
+-	  _nc_Calculate_Item_Length_and_Width( menu );			
++	  _nc_Calculate_Item_Length_and_Width(menu);
+ 	}
+     }
+   else
+     {
+-      return set_menu_mark(&_nc_Default_Menu, mark);
++      returnCode(set_menu_mark(&_nc_Default_Menu, mark));
+     }
+   RETURN(E_OK);
+ }
+@@ -223,9 +263,10 @@
+ |   Return Values :  The marker string pointer or NULL if no marker defined
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(const char *)
+-menu_mark (const MENU * menu)
++menu_mark(const MENU * menu)
+ {
+-  return Normalize_Menu( menu )->mark;
++  T((T_CALLED("menu_mark(%p)"), menu));
++  returnPtr(Normalize_Menu(menu)->mark);
+ }
+ 
+ /* m_item_new.c */
+Index: menu/m_item_opt.c
+Prereq:  1.14 
+--- ncurses-5.4-20040208/menu/m_item_opt.c	2003-11-08 20:50:19.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_item_opt.c	2004-12-25 21:32:54.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_item_opt.c,v 1.14 2003/11/08 20:50:19 tom Exp $")
++MODULE_ID("$Id: m_item_opt.c,v 1.17 2004/12/25 21:32:54 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -51,34 +51,36 @@
+ |                    E_BAD_ARGUMENT  - invalid item options
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_item_opts (ITEM *item, Item_Options opts)
+-{ 
++set_item_opts(ITEM * item, Item_Options opts)
++{
++  T((T_CALLED("set_menu_opts(%p,%d)"), item, opts));
++
+   opts &= ALL_ITEM_OPTS;
+ 
+   if (opts & ~ALL_ITEM_OPTS)
+     RETURN(E_BAD_ARGUMENT);
+-  
++
+   if (item)
+     {
+       if (item->opt != opts)
+-	{		
++	{
+ 	  MENU *menu = item->imenu;
+-	  
++
+ 	  item->opt = opts;
+-	  
++
+ 	  if ((!(opts & O_SELECTABLE)) && item->value)
+ 	    item->value = FALSE;
+-	  
++
+ 	  if (menu && (menu->status & _POSTED))
+ 	    {
+-	      Move_And_Post_Item( menu, item );
++	      Move_And_Post_Item(menu, item);
+ 	      _nc_Show_Menu(menu);
+ 	    }
+ 	}
+     }
+   else
+     _nc_Default_Item.opt = opts;
+-  
++
+   RETURN(E_OK);
+ }
+ 
+@@ -92,18 +94,21 @@
+ |                    E_BAD_ARGUMENT  - invalid options
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-item_opts_off (ITEM *item, Item_Options  opts)
+-{ 
+-  ITEM *citem = item; /* use a copy because set_item_opts must detect
+-                         NULL item itself to adjust its behavior */
++item_opts_off(ITEM * item, Item_Options opts)
++{
++  ITEM *citem = item;		/* use a copy because set_item_opts must detect
++
++				   NULL item itself to adjust its behavior */
++
++  T((T_CALLED("item_opts_off(%p,%d)"), item, opts));
+ 
+   if (opts & ~ALL_ITEM_OPTS)
+     RETURN(E_BAD_ARGUMENT);
+   else
+     {
+-      Normalize_Item(citem);    
++      Normalize_Item(citem);
+       opts = citem->opt & ~(opts & ALL_ITEM_OPTS);
+-      return set_item_opts( item, opts );
++      returnCode(set_item_opts(item, opts));
+     }
+ }
+ 
+@@ -117,11 +122,14 @@
+ |                    E_BAD_ARGUMENT  - invalid options
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-item_opts_on (ITEM *item, Item_Options opts)
++item_opts_on(ITEM * item, Item_Options opts)
+ {
+-  ITEM *citem = item; /* use a copy because set_item_opts must detect
+-                         NULL item itself to adjust its behavior */
+-  
++  ITEM *citem = item;		/* use a copy because set_item_opts must detect
++
++				   NULL item itself to adjust its behavior */
++
++  T((T_CALLED("item_opts_on(%p,%d)"), item, opts));
++
+   opts &= ALL_ITEM_OPTS;
+   if (opts & ~ALL_ITEM_OPTS)
+     RETURN(E_BAD_ARGUMENT);
+@@ -129,7 +137,7 @@
+     {
+       Normalize_Item(citem);
+       opts = citem->opt | opts;
+-      return set_item_opts( item, opts );
++      returnCode(set_item_opts(item, opts));
+     }
+ }
+ 
+@@ -142,9 +150,10 @@
+ |   Return Values :  Items options
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(Item_Options)
+-item_opts (const ITEM * item)
++item_opts(const ITEM * item)
+ {
+-  return (ALL_ITEM_OPTS & Normalize_Item(item)->opt);
++  T((T_CALLED("item_opts(%p)"), item));
++  returnItemOpts(ALL_ITEM_OPTS & Normalize_Item(item)->opt);
+ }
+ 
+ /* m_item_opt.c ends here */
+Index: menu/m_item_top.c
+Prereq:  1.8 
+--- ncurses-5.4-20040208/menu/m_item_top.c	2003-11-08 20:51:53.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_item_top.c	2004-12-11 23:29:34.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_item_top.c,v 1.8 2003/11/08 20:51:53 tom Exp $")
++MODULE_ID("$Id: m_item_top.c,v 1.10 2004/12/11 23:29:34 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -50,35 +50,37 @@
+ |                    E_NOT_CONNECTED  - there are no items for the menu
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_top_row (MENU * menu, int row)
++set_top_row(MENU * menu, int row)
+ {
+   ITEM *item;
+-  
++
++  T((T_CALLED("set_top_row(%p,%d)"), menu, row));
++
+   if (menu)
+     {
+-      if ( menu->status & _IN_DRIVER )
++      if (menu->status & _IN_DRIVER)
+ 	RETURN(E_BAD_STATE);
+-      if (menu->items == (ITEM **)0)
++      if (menu->items == (ITEM **) 0)
+ 	RETURN(E_NOT_CONNECTED);
+-      
+-      if ((row<0) || (row > (menu->rows - menu->arows)))
++
++      if ((row < 0) || (row > (menu->rows - menu->arows)))
+ 	RETURN(E_BAD_ARGUMENT);
+     }
+   else
+     RETURN(E_BAD_ARGUMENT);
+-  
++
+   if (row != menu->toprow)
+     {
+-      if (menu->status & _LINK_NEEDED) 
++      if (menu->status & _LINK_NEEDED)
+ 	_nc_Link_Items(menu);
+-      
+-      item = menu->items[ (menu->opt&O_ROWMAJOR) ? (row*menu->cols) : row ];
++
++      item = menu->items[(menu->opt & O_ROWMAJOR) ? (row * menu->cols) : row];
+       assert(menu->pattern);
+       Reset_Pattern(menu);
+       _nc_New_TopRow_and_CurrentItem(menu, row, item);
+     }
+-  
+-    RETURN(E_OK);
++
++  RETURN(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -90,15 +92,16 @@
+ |   Return Values :  The row number or ERR if there is no row
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-top_row (const MENU * menu)
++top_row(const MENU * menu)
+ {
++  T((T_CALLED("top_row(%p)"), menu));
+   if (menu && menu->items && *(menu->items))
+     {
+-      assert( (menu->toprow>=0) && (menu->toprow < menu->rows) );
+-      return menu->toprow;
++      assert((menu->toprow >= 0) && (menu->toprow < menu->rows));
++      returnCode(menu->toprow);
+     }
+   else
+-    return(ERR);
++    returnCode(ERR);
+ }
+ 
+ /* m_item_top.c ends here */
+Index: menu/m_item_use.c
+Prereq:  1.13 
+--- ncurses-5.4-20040208/menu/m_item_use.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_item_use.c	2004-12-25 21:33:31.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_item_use.c,v 1.13 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_item_use.c,v 1.16 2004/12/25 21:33:31 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -49,10 +49,11 @@
+ |   Return Values :  E_OK               - success
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_item_userptr (ITEM * item, void * userptr)
++set_item_userptr(ITEM * item, void *userptr)
+ {
++  T((T_CALLED("set_item_userptr(%p,%p)"), item, userptr));
+   Normalize_Item(item)->userptr = userptr;
+-  RETURN( E_OK );
++  RETURN(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -66,9 +67,10 @@
+ |                    NULL is returned.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void *)
+-item_userptr (const ITEM * item)
++item_userptr(const ITEM * item)
+ {
+-  return Normalize_Item(item)->userptr;
++  T((T_CALLED("item_userptr(%p)"), item));
++  returnVoidPtr(Normalize_Item(item)->userptr);
+ }
+ 
+ /* m_item_use.c */
+Index: menu/m_item_val.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/menu/m_item_val.c	2003-11-08 20:51:29.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_item_val.c	2004-12-11 23:29:34.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_item_val.c,v 1.12 2003/11/08 20:51:29 tom Exp $")
++MODULE_ID("$Id: m_item_val.c,v 1.14 2004/12/11 23:29:34 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -53,18 +53,19 @@
+ |                    E_REQUEST_DENIED  - not selectable or single valued menu
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_item_value (ITEM *item, bool value)
++set_item_value(ITEM * item, bool value)
+ {
+   MENU *menu;
+-  
++
++  T((T_CALLED("set_item_value(%p,%d)"), item, value));
+   if (item)
+     {
+       menu = item->imenu;
+-      
++
+       if ((!(item->opt & O_SELECTABLE)) ||
+-	  (menu && (menu->opt & O_ONEVALUE))) 
++	  (menu && (menu->opt & O_ONEVALUE)))
+ 	RETURN(E_REQUEST_DENIED);
+-      
++
+       if (item->value ^ value)
+ 	{
+ 	  item->value = value ? TRUE : FALSE;
+@@ -72,7 +73,7 @@
+ 	    {
+ 	      if (menu->status & _POSTED)
+ 		{
+-		  Move_And_Post_Item(menu,item);
++		  Move_And_Post_Item(menu, item);
+ 		  _nc_Show_Menu(menu);
+ 		}
+ 	    }
+@@ -80,7 +81,7 @@
+     }
+   else
+     _nc_Default_Item.value = value;
+-  
++
+   RETURN(E_OK);
+ }
+ 
+@@ -94,9 +95,10 @@
+ |                    FALSE  - if item is not selected
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(bool)
+-item_value (const ITEM *item)
++item_value(const ITEM * item)
+ {
+-  return ((Normalize_Item(item)->value) ? TRUE : FALSE);
++  T((T_CALLED("item_value(%p)"), item));
++  returnBool((Normalize_Item(item)->value) ? TRUE : FALSE);
+ }
+ 
+ /* m_item_val.c ends here */
+Index: menu/m_item_vis.c
+Prereq:  1.13 
+--- ncurses-5.4-20040208/menu/m_item_vis.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_item_vis.c	2004-12-25 21:40:09.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_item_vis.c,v 1.13 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_item_vis.c,v 1.15 2004/12/25 21:40:09 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -50,18 +50,19 @@
+ |                    FALSE if invisible
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(bool)
+-item_visible (const ITEM * item)
++item_visible(const ITEM * item)
+ {
+   MENU *menu;
+-  
+-  if ( item                                               && 
+-      (menu=item->imenu)                                  && 
+-      (menu->status & _POSTED)                            &&
+-      ( (menu->toprow + menu->arows) > (item->y) )        &&
+-      ( item->y >= menu->toprow) )
+-    return TRUE;
++
++  T((T_CALLED("item_visible(%p)"), item));
++  if (item &&
++      (menu = item->imenu) &&
++      (menu->status & _POSTED) &&
++      ((menu->toprow + menu->arows) > (item->y)) &&
++      (item->y >= menu->toprow))
++    returnBool(TRUE);
+   else
+-    return FALSE;
++    returnBool(FALSE);
+ }
+ 
+ /* m_item_vis.c ends here */
+Index: menu/m_items.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/menu/m_items.c	2003-11-08 20:50:58.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_items.c	2005-01-16 01:02:23.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_items.c,v 1.12 2003/11/08 20:50:58 tom Exp $")
++MODULE_ID("$Id: m_items.c,v 1.16 2005/01/16 01:02:23 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -53,26 +53,28 @@
+ |                                     passed to the function
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_items (MENU * menu, ITEM ** items)
++set_menu_items(MENU * menu, ITEM ** items)
+ {
++  T((T_CALLED("set_menu_items(%p,%p)"), menu, items));
++
+   if (!menu || (items && !(*items)))
+     RETURN(E_BAD_ARGUMENT);
+-  
+-  if ( menu->status & _POSTED )
++
++  if (menu->status & _POSTED)
+     RETURN(E_POSTED);
+-  
++
+   if (menu->items)
+     _nc_Disconnect_Items(menu);
+-  
++
+   if (items)
+     {
+-      if(!_nc_Connect_Items( menu, items )) 
++      if (!_nc_Connect_Items(menu, items))
+ 	RETURN(E_CONNECTED);
+     }
+-  
++
+   menu->items = items;
+   RETURN(E_OK);
+-}		
++}
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -83,9 +85,10 @@
+ |   Return Values :  NULL on error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(ITEM **)
+-menu_items (const MENU *menu)
++menu_items(const MENU * menu)
+ {
+-  return(menu ? menu->items : (ITEM **)0);
++  T((T_CALLED("menu_items(%p)"), menu));
++  returnItemPtr(menu ? menu->items : (ITEM **) 0);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -98,9 +101,10 @@
+ |   Return Values :  Number of items or -1 to indicate error.
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-item_count (const MENU *menu)
++item_count(const MENU * menu)
+ {
+-  return(menu ? menu->nitems : -1);
++  T((T_CALLED("item_count(%p)"), menu));
++  returnCode(menu ? menu->nitems : -1);
+ }
+ 
+ /* m_items.c ends here */
+Index: menu/m_new.c
+Prereq:  1.13 
+--- ncurses-5.4-20040208/menu/m_new.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_new.c	2004-12-25 21:57:53.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_new.c,v 1.13 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_new.c,v 1.16 2004/12/25 21:57:53 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -51,10 +51,11 @@
+ |   Return Values :  NULL on error
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(MENU *)
+-new_menu (ITEM ** items)
++new_menu(ITEM ** items)
+ {
+-  MENU *menu = (MENU *)calloc(1,sizeof(MENU));
+-  
++  MENU *menu = (MENU *) calloc(1, sizeof(MENU));
++
++  T((T_CALLED("new_menu(%p)"), items));
+   if (menu)
+     {
+       *menu = _nc_Default_Menu;
+@@ -63,10 +64,10 @@
+       menu->cols = menu->fcols;
+       if (items && *items)
+ 	{
+-	  if (!_nc_Connect_Items(menu,items))
++	  if (!_nc_Connect_Items(menu, items))
+ 	    {
+ 	      free(menu);
+-	      menu = (MENU *)0;
++	      menu = (MENU *) 0;
+ 	    }
+ 	}
+     }
+@@ -74,7 +75,7 @@
+   if (!menu)
+     SET_ERROR(E_SYSTEM_ERROR);
+ 
+-  return(menu);
++  returnMenu(menu);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -89,17 +90,18 @@
+ |                    E_POSTED           - Menu is already posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-free_menu (MENU * menu)
++free_menu(MENU * menu)
+ {
++  T((T_CALLED("free_menu(%p)"), menu));
+   if (!menu)
+     RETURN(E_BAD_ARGUMENT);
+-  
+-  if ( menu->status & _POSTED )
++
++  if (menu->status & _POSTED)
+     RETURN(E_POSTED);
+-  
+-  if (menu->items) 
++
++  if (menu->items)
+     _nc_Disconnect_Items(menu);
+-  
++
+   if ((menu->status & _MARK_ALLOCATED) && menu->mark)
+     free(menu->mark);
+ 
+Index: menu/m_opts.c
+Prereq:  1.16 
+--- ncurses-5.4-20040208/menu/m_opts.c	2003-11-08 20:50:19.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_opts.c	2004-12-25 21:36:12.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_opts.c,v 1.16 2003/11/08 20:50:19 tom Exp $")
++MODULE_ID("$Id: m_opts.c,v 1.19 2004/12/25 21:36:12 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu
+@@ -53,8 +53,10 @@
+ |                    E_POSTED       - menu is already posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_opts (MENU * menu, Menu_Options opts)
++set_menu_opts(MENU * menu, Menu_Options opts)
+ {
++  T((T_CALLED("set_menu_opts(%p,%d)"), menu, opts));
++
+   opts &= ALL_MENU_OPTS;
+ 
+   if (opts & ~ALL_MENU_OPTS)
+@@ -62,18 +64,18 @@
+ 
+   if (menu)
+     {
+-      if ( menu->status & _POSTED )
++      if (menu->status & _POSTED)
+ 	RETURN(E_POSTED);
+ 
+-      if ( (opts&O_ROWMAJOR) != (menu->opt&O_ROWMAJOR))
++      if ((opts & O_ROWMAJOR) != (menu->opt & O_ROWMAJOR))
+ 	{
+ 	  /* we need this only if the layout really changed ... */
+ 	  if (menu->items && menu->items[0])
+ 	    {
+-	      menu->toprow  = 0;
++	      menu->toprow = 0;
+ 	      menu->curitem = menu->items[0];
+ 	      assert(menu->curitem);
+-	      set_menu_format( menu, menu->frows, menu->fcols );
++	      set_menu_format(menu, menu->frows, menu->fcols);
+ 	    }
+ 	}
+ 
+@@ -83,13 +85,13 @@
+ 	{
+ 	  ITEM **item;
+ 
+-	  if ( ((item=menu->items) != (ITEM**)0) )
+-	    for(;*item;item++)
++	  if (((item = menu->items) != (ITEM **) 0))
++	    for (; *item; item++)
+ 	      (*item)->value = FALSE;
+ 	}
+ 
+       if (opts & O_SHOWDESC)	/* this also changes the geometry */
+-	_nc_Calculate_Item_Length_and_Width( menu );
++	_nc_Calculate_Item_Length_and_Width(menu);
+     }
+   else
+     _nc_Default_Menu.opt = opts;
+@@ -111,10 +113,13 @@
+ |                    E_POSTED       - menu is already posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-menu_opts_off (MENU *menu, Menu_Options  opts)
++menu_opts_off(MENU * menu, Menu_Options opts)
+ {
+-  MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+-                         NULL menu itself to adjust its behavior */
++  MENU *cmenu = menu;		/* use a copy because set_menu_opts must detect
++
++				   NULL menu itself to adjust its behavior */
++
++  T((T_CALLED("menu_opts_off(%p,%d)"), menu, opts));
+ 
+   opts &= ALL_MENU_OPTS;
+   if (opts & ~ALL_MENU_OPTS)
+@@ -123,7 +128,7 @@
+     {
+       Normalize_Menu(cmenu);
+       opts = cmenu->opt & ~opts;
+-      return set_menu_opts( menu, opts );
++      returnCode(set_menu_opts(menu, opts));
+     }
+ }
+ 
+@@ -141,10 +146,13 @@
+ |                    E_POSTED       - menu is already posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-menu_opts_on (MENU * menu, Menu_Options opts)
++menu_opts_on(MENU * menu, Menu_Options opts)
+ {
+-  MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+-                         NULL menu itself to adjust its behavior */
++  MENU *cmenu = menu;		/* use a copy because set_menu_opts must detect
++
++				   NULL menu itself to adjust its behavior */
++
++  T((T_CALLED("menu_opts_on(%p,%d)"), menu, opts));
+ 
+   opts &= ALL_MENU_OPTS;
+   if (opts & ~ALL_MENU_OPTS)
+@@ -153,7 +161,7 @@
+     {
+       Normalize_Menu(cmenu);
+       opts = cmenu->opt | opts;
+-      return set_menu_opts(menu, opts);
++      returnCode(set_menu_opts(menu, opts));
+     }
+ }
+ 
+@@ -166,9 +174,10 @@
+ |   Return Values :  Menu options
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(Menu_Options)
+-menu_opts (const MENU *menu)
++menu_opts(const MENU * menu)
+ {
+-  return (ALL_MENU_OPTS & Normalize_Menu( menu )->opt);
++  T((T_CALLED("menu_opts(%p)"), menu));
++  returnMenuOpts(ALL_MENU_OPTS & Normalize_Menu(menu)->opt);
+ }
+ 
+ /* m_opts.c ends here */
+Index: menu/m_pad.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/menu/m_pad.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_pad.c	2004-12-25 21:40:58.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_pad.c,v 1.7 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_pad.c,v 1.10 2004/12/25 21:40:58 tom Exp $")
+ 
+ /* Macro to redraw menu if it is posted and changed */
+ #define Refresh_Menu(menu) \
+@@ -59,18 +59,20 @@
+ |                    E_BAD_ARGUMENT    - an invalid value has been passed
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_pad (MENU *menu, int pad)
++set_menu_pad(MENU * menu, int pad)
+ {
+-  bool do_refresh = (menu != (MENU*)0);
++  bool do_refresh = (menu != (MENU *) 0);
+ 
+-  if (!isprint((unsigned char)pad))
++  T((T_CALLED("set_menu_pad(%p,%d)"), menu, pad));
++
++  if (!isprint(UChar(pad)))
+     RETURN(E_BAD_ARGUMENT);
+-  
+-  Normalize_Menu( menu );
++
++  Normalize_Menu(menu);
+   menu->pad = pad;
+-  
++
+   if (do_refresh)
+-      Refresh_Menu( menu );
++    Refresh_Menu(menu);
+ 
+   RETURN(E_OK);
+ }
+@@ -84,9 +86,10 @@
+ |   Return Values :  The pad character
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-menu_pad (const MENU * menu)
++menu_pad(const MENU * menu)
+ {
+-  return (Normalize_Menu( menu ) -> pad);
++  T((T_CALLED("menu_pad(%p)"), menu));
++  returnCode(Normalize_Menu(menu)->pad);
+ }
+ 
+ /* m_pad.c ends here */
+Index: menu/m_pattern.c
+Prereq:  1.9 
+--- ncurses-5.4-20040208/menu/m_pattern.c	2003-12-06 17:22:10.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_pattern.c	2004-12-25 21:41:37.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_pattern.c,v 1.9 2003/12/06 17:22:10 tom Exp $")
++MODULE_ID("$Id: m_pattern.c,v 1.13 2004/12/25 21:41:37 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -51,9 +51,10 @@
+ |                    PatternString - as expected
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(char *)
+-menu_pattern (const MENU * menu)
++menu_pattern(const MENU * menu)
+ {
+-  return (char *)(menu ? (menu->pattern ? menu->pattern : "") : 0);
++  T((T_CALLED("menu_pattern(%p)"), menu));
++  returnPtr((char *)(menu ? (menu->pattern ? menu->pattern : "") : 0));
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -70,49 +71,51 @@
+ |                    E_NO_MATCH        - no item matches pattern
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_pattern (MENU *menu, const char *p)
++set_menu_pattern(MENU * menu, const char *p)
+ {
+   ITEM *matchitem;
+-  int   matchpos;
+-  
+-  if (!menu || !p)	
++  int matchpos;
++
++  T((T_CALLED("set_menu_pattern(%p,%s)"), menu, _nc_visbuf(p)));
++
++  if (!menu || !p)
+     RETURN(E_BAD_ARGUMENT);
+-  
++
+   if (!(menu->items))
+     RETURN(E_NOT_CONNECTED);
+-  
+-  if ( menu->status & _IN_DRIVER )
++
++  if (menu->status & _IN_DRIVER)
+     RETURN(E_BAD_STATE);
+-  
++
+   Reset_Pattern(menu);
+-  
++
+   if (!(*p))
+     {
+       pos_menu_cursor(menu);
+       RETURN(E_OK);
+     }
+-  
+-  if (menu->status & _LINK_NEEDED) 
++
++  if (menu->status & _LINK_NEEDED)
+     _nc_Link_Items(menu);
+-  
+-  matchpos  = menu->toprow;
++
++  matchpos = menu->toprow;
+   matchitem = menu->curitem;
+   assert(matchitem);
+-  
+-  while(*p)
++
++  while (*p)
+     {
+-      if ( !isprint((unsigned char)(*p)) || 
+-	  (_nc_Match_Next_Character_In_Item_Name(menu,*p,&matchitem) != E_OK) )
++      if (!isprint(UChar(*p)) ||
++	  (_nc_Match_Next_Character_In_Item_Name(menu, *p, &matchitem) != E_OK))
+ 	{
+ 	  Reset_Pattern(menu);
+ 	  pos_menu_cursor(menu);
+ 	  RETURN(E_NO_MATCH);
+ 	}
+       p++;
+-    }			
+-  
++    }
++
+   /* This is reached if there was a match. So we position to the new item */
+-  Adjust_Current_Item(menu,matchpos,matchitem);
++  Adjust_Current_Item(menu, matchpos, matchitem);
+   RETURN(E_OK);
+ }
+ 
+Index: menu/m_post.c
+Prereq:  1.19 
+--- ncurses-5.4-20040208/menu/m_post.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_post.c	2004-12-25 23:57:04.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,113 +37,117 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_post.c,v 1.19 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_post.c,v 1.26 2004/12/25 23:57:04 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnmenu  
+-|   Function      :  void _nc_Post_Item(MENU *menu, ITEM *item)  
+-|   
++|   Facility      :  libnmenu
++|   Function      :  void _nc_Post_Item(MENU *menu, ITEM *item)
++|
+ |   Description   :  Draw the item in the menus window at the current
+-|                    window position 
++|                    window position
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-_nc_Post_Item (const MENU * menu, const ITEM * item)
++_nc_Post_Item(const MENU * menu, const ITEM * item)
+ {
+   int i;
+   chtype ch;
+   int item_x, item_y;
+   int count = 0;
+-  bool isfore = FALSE, isback=FALSE, isgrey = FALSE;
+-  
++  bool isfore = FALSE, isback = FALSE, isgrey = FALSE;
++  int name_len;
++  int desc_len;
++
+   assert(menu->win);
+-  
+-  getyx(menu->win,item_y,item_x);
+-  
++
++  getyx(menu->win, item_y, item_x);
++
+   /* We need a marker iff
+      - it is a onevalued menu and it is the current item
+      - or it has a selection value
+-     */
+-  wattron(menu->win,menu->back);
+-  if (item->value || (item==menu->curitem))
++   */
++  wattron(menu->win, menu->back);
++  if (item->value || (item == menu->curitem))
+     {
+-      if (menu->marklen) 
++      if (menu->marklen)
+ 	{
+ 	  /* In a multi selection menu we use the fore attribute
+ 	     for a selected marker that is not the current one.
+ 	     This improves visualization of the menu, because now
+ 	     always the 'normal' marker denotes the current
+ 	     item. */
+-	  if (!(menu->opt & O_ONEVALUE) && item->value && item!=menu->curitem)
++	  if (!(menu->opt & O_ONEVALUE) && item->value && item != menu->curitem)
+ 	    {
+-	      wattron(menu->win,menu->fore);
++	      wattron(menu->win, menu->fore);
+ 	      isfore = TRUE;
+ 	    }
+-	  waddstr(menu->win,menu->mark);
++	  waddstr(menu->win, menu->mark);
+ 	  if (isfore)
+ 	    {
+-	      wattron(menu->win,menu->fore);
++	      wattron(menu->win, menu->fore);
+ 	      isfore = FALSE;
+ 	    }
+ 	}
+     }
+-  else			/* otherwise we have to wipe out the marker area */ 
+-    for(ch=' ',i=menu->marklen;i>0;i--) 
+-      waddch(menu->win,ch);
+-  wattroff(menu->win,menu->back);
++  else				/* otherwise we have to wipe out the marker area */
++    for (ch = ' ', i = menu->marklen; i > 0; i--)
++      waddch(menu->win, ch);
++  wattroff(menu->win, menu->back);
+   count += menu->marklen;
+ 
+   /* First we have to calculate the attribute depending on selectability
+      and selection status
+-     */
++   */
+   if (!(item->opt & O_SELECTABLE))
+     {
+-      wattron(menu->win,menu->grey);
++      wattron(menu->win, menu->grey);
+       isgrey = TRUE;
+     }
+   else
+     {
+-      if (item->value || item==menu->curitem)
++      if (item->value || item == menu->curitem)
+ 	{
+-	  wattron(menu->win,menu->fore);
++	  wattron(menu->win, menu->fore);
+ 	  isfore = TRUE;
+ 	}
+       else
+ 	{
+-	  wattron(menu->win,menu->back);
++	  wattron(menu->win, menu->back);
+ 	  isback = TRUE;
+ 	}
+     }
+ 
+-  waddnstr(menu->win,item->name.str,item->name.length);
+-  for(ch=' ',i=menu->namelen-item->name.length;i>0;i--)
++  waddnstr(menu->win, item->name.str, item->name.length);
++  name_len = _nc_Calculate_Text_Width(&(item->name));
++  for (ch = ' ', i = menu->namelen - name_len; i > 0; i--)
+     {
+-      waddch(menu->win,ch);
++      waddch(menu->win, ch);
+     }
+   count += menu->namelen;
+ 
+   /* Show description if required and available */
+-  if ( (menu->opt & O_SHOWDESC) && menu->desclen>0 )
++  if ((menu->opt & O_SHOWDESC) && menu->desclen > 0)
+     {
+-      int m = menu->spc_desc/2;
++      int m = menu->spc_desc / 2;
+       int cy = -1, cx = -1;
+ 
+-      for(ch=' ',i=0; i < menu->spc_desc; i++)
++      for (ch = ' ', i = 0; i < menu->spc_desc; i++)
+ 	{
+-	  if (i==m)
++	  if (i == m)
+ 	    {
+-	      waddch(menu->win,menu->pad);
+-	      getyx(menu->win,cy,cx);
++	      waddch(menu->win, menu->pad);
++	      getyx(menu->win, cy, cx);
+ 	    }
+ 	  else
+-	    waddch(menu->win,ch);
++	    waddch(menu->win, ch);
+ 	}
+       if (item->description.length)
+-	waddnstr(menu->win,item->description.str,item->description.length);
+-      for(ch=' ',i=menu->desclen-item->description.length; i>0; i--)
++	waddnstr(menu->win, item->description.str, item->description.length);
++      desc_len = _nc_Calculate_Text_Width(&(item->description));
++      for (ch = ' ', i = menu->desclen - desc_len; i > 0; i--)
+ 	{
+-	  waddch(menu->win,ch);
++	  waddch(menu->win, ch);
+ 	}
+       count += menu->desclen + menu->spc_desc;
+ 
+@@ -151,47 +155,49 @@
+ 	{
+ 	  int j, k, ncy, ncx;
+ 
+-	  assert(cx>=0 && cy>=0);
+-	  getyx(menu->win,ncy,ncx);
+-	  if (isgrey) wattroff(menu->win,menu->grey);
+-	  else if (isfore) wattroff(menu->win,menu->fore);
+-	  wattron(menu->win,menu->back);
+-	  for(j=1; j < menu->spc_rows;j++)
++	  assert(cx >= 0 && cy >= 0);
++	  getyx(menu->win, ncy, ncx);
++	  if (isgrey)
++	    wattroff(menu->win, menu->grey);
++	  else if (isfore)
++	    wattroff(menu->win, menu->fore);
++	  wattron(menu->win, menu->back);
++	  for (j = 1; j < menu->spc_rows; j++)
+ 	    {
+-	      if ((item_y+j) < getmaxy(menu->win))
++	      if ((item_y + j) < getmaxy(menu->win))
+ 		{
+-		  wmove (menu->win,item_y+j,item_x);
+-		  for(k=0;k<count;k++)
+-		    waddch(menu->win,' ');
++		  wmove(menu->win, item_y + j, item_x);
++		  for (k = 0; k < count; k++)
++		    waddch(menu->win, ' ');
+ 		}
+-	      if ((cy+j) < getmaxy(menu->win))
+-		mvwaddch(menu->win,cy+j,cx-1,menu->pad);
++	      if ((cy + j) < getmaxy(menu->win))
++		mvwaddch(menu->win, cy + j, cx - 1, menu->pad);
+ 	    }
+-	  wmove(menu->win,ncy,ncx);
++	  wmove(menu->win, ncy, ncx);
+ 	  if (!isback)
+-	    wattroff(menu->win,menu->back);
++	    wattroff(menu->win, menu->back);
+ 	}
+     }
+-  
++
+   /* Remove attributes */
+   if (isfore)
+-    wattroff(menu->win,menu->fore);
++    wattroff(menu->win, menu->fore);
+   if (isback)
+-    wattroff(menu->win,menu->back);
++    wattroff(menu->win, menu->back);
+   if (isgrey)
+-    wattroff(menu->win,menu->grey);
+-}	
++    wattroff(menu->win, menu->grey);
++}
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnmenu  
++|   Facility      :  libnmenu
+ |   Function      :  void _nc_Draw_Menu(const MENU *)
+-|   
++|
+ |   Description   :  Display the menu in its windows
+ |
+ |   Return Values :  -
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void)
+-_nc_Draw_Menu (const MENU * menu)
++_nc_Draw_Menu(const MENU * menu)
+ {
+   ITEM *item = menu->items[0];
+   ITEM *lasthor, *lastvert;
+@@ -202,75 +208,78 @@
+   assert(item && menu->win);
+ 
+   s_bkgd = getbkgd(menu->win);
+-  wbkgdset(menu->win,menu->back);
++  wbkgdset(menu->win, menu->back);
+   werase(menu->win);
+-  wbkgdset(menu->win,s_bkgd);
++  wbkgdset(menu->win, s_bkgd);
+ 
+-  lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item;  
++  lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : item;
+ 
+   do
+-    {  
+-      wmove(menu->win,y,0);
++    {
++      wmove(menu->win, y, 0);
++
++      hitem = item;
++      lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : hitem;
+ 
+-      hitem   = item;
+-      lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem;
+-      
+       do
+ 	{
+-	  _nc_Post_Item( menu, hitem);
++	  _nc_Post_Item(menu, hitem);
+ 
+-	  wattron(menu->win,menu->back);
+-	  if ( ((hitem = hitem->right) != lasthor) && hitem )
++	  wattron(menu->win, menu->back);
++	  if (((hitem = hitem->right) != lasthor) && hitem)
+ 	    {
+-	      int i,j, cy, cx;
++	      int i, j, cy, cx;
+ 	      chtype ch = ' ';
+ 
+-	      getyx(menu->win,cy,cx);
+-	      for(j=0;j<menu->spc_rows;j++)
++	      getyx(menu->win, cy, cx);
++	      for (j = 0; j < menu->spc_rows; j++)
+ 		{
+-		  wmove(menu->win,cy+j,cx);
+-		  for(i=0; i < menu->spc_cols; i++)
++		  wmove(menu->win, cy + j, cx);
++		  for (i = 0; i < menu->spc_cols; i++)
+ 		    {
+-		      waddch( menu->win,ch);
++		      waddch(menu->win, ch);
+ 		    }
+ 		}
+-	      wmove(menu->win,cy,cx+menu->spc_cols);
++	      wmove(menu->win, cy, cx + menu->spc_cols);
+ 	    }
+-	} while (hitem && (hitem != lasthor));
+-      wattroff(menu->win,menu->back);
+-      
++	}
++      while (hitem && (hitem != lasthor));
++      wattroff(menu->win, menu->back);
++
+       item = item->down;
+       y += menu->spc_rows;
+-      
+-    } while( item && (item != lastvert) );
++
++    }
++  while (item && (item != lastvert));
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnmenu  
++|   Facility      :  libnmenu
+ |   Function      :  int post_menu(MENU *)
+-|   
++|
+ |   Description   :  Post a menu to the screen. This makes it visible.
+ |
+ |   Return Values :  E_OK                - success
+ |                    E_BAD_ARGUMENT      - not a valid menu pointer
+ |                    E_SYSTEM_ERROR      - error in lower layers
+-|                    E_NO_ROOM           - Menu to large for screen
+ |                    E_NOT_CONNECTED     - No items connected to menu
+ |                    E_BAD_STATE         - Menu in userexit routine
+ |                    E_POSTED            - Menu already posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-post_menu (MENU * menu)
++post_menu(MENU * menu)
+ {
++  T((T_CALLED("post_menu(%p)"), menu));
++
+   if (!menu)
+     RETURN(E_BAD_ARGUMENT);
+-  
+-  if ( menu->status & _IN_DRIVER )
++
++  if (menu->status & _IN_DRIVER)
+     RETURN(E_BAD_STATE);
+ 
+-  if ( menu->status & _POSTED )
++  if (menu->status & _POSTED)
+     RETURN(E_POSTED);
+-  
++
+   if (menu->items && *(menu->items))
+     {
+       int y;
+@@ -278,54 +287,50 @@
+ 
+       WINDOW *win = Get_Menu_Window(menu);
+       int maxy = getmaxy(win);
+-      int maxx = getmaxx(win);
+-      
+-      if (maxx < menu->width || maxy < menu->height)
+-	RETURN(E_NO_ROOM);
+ 
+-      if ( (menu->win = newpad(h,menu->width)) )
++      if ((menu->win = newpad(h, menu->width)))
+ 	{
+ 	  y = (maxy >= h) ? h : maxy;
+-	  if (y>=menu->height) 
++	  if (y >= menu->height)
+ 	    y = menu->height;
+-	  if(!(menu->sub = subpad(menu->win,y,menu->width,0,0)))
++	  if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0)))
+ 	    RETURN(E_SYSTEM_ERROR);
+ 	}
+-      else 
+-	RETURN(E_SYSTEM_ERROR);	
+-      
+-      if (menu->status & _LINK_NEEDED) 
++      else
++	RETURN(E_SYSTEM_ERROR);
++
++      if (menu->status & _LINK_NEEDED)
+ 	_nc_Link_Items(menu);
+     }
+   else
+     RETURN(E_NOT_CONNECTED);
+-  
++
+   menu->status |= _POSTED;
+ 
+-  if (!(menu->opt&O_ONEVALUE))
++  if (!(menu->opt & O_ONEVALUE))
+     {
+       ITEM **items;
+-  
+-      for(items=menu->items;*items;items++)
++
++      for (items = menu->items; *items; items++)
+ 	{
+ 	  (*items)->value = FALSE;
+ 	}
+     }
+-  
++
+   _nc_Draw_Menu(menu);
+-  
+-  Call_Hook(menu,menuinit);
+-  Call_Hook(menu,iteminit);
+-  
++
++  Call_Hook(menu, menuinit);
++  Call_Hook(menu, iteminit);
++
+   _nc_Show_Menu(menu);
+-  
++
+   RETURN(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+-|   Facility      :  libnmenu  
++|   Facility      :  libnmenu
+ |   Function      :  int unpost_menu(MENU *)
+-|   
++|
+ |   Description   :  Detach menu from screen
+ |
+ |   Return Values :  E_OK              - success
+@@ -334,36 +339,38 @@
+ |                    E_NOT_POSTED      - menu is not posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-unpost_menu (MENU * menu)
++unpost_menu(MENU * menu)
+ {
+   WINDOW *win;
+-  
++
++  T((T_CALLED("unpost_menu(%p)"), menu));
++
+   if (!menu)
+     RETURN(E_BAD_ARGUMENT);
+-  
+-  if ( menu->status & _IN_DRIVER )
++
++  if (menu->status & _IN_DRIVER)
+     RETURN(E_BAD_STATE);
+ 
+-  if ( !( menu->status & _POSTED ) )
++  if (!(menu->status & _POSTED))
+     RETURN(E_NOT_POSTED);
+-  
+-  Call_Hook(menu,itemterm);
+-  Call_Hook(menu,menuterm);	
+-  
++
++  Call_Hook(menu, itemterm);
++  Call_Hook(menu, menuterm);
++
+   win = Get_Menu_Window(menu);
+   werase(win);
+   wsyncup(win);
+-  
++
+   assert(menu->sub);
+   delwin(menu->sub);
+   menu->sub = (WINDOW *)0;
+-  
++
+   assert(menu->win);
+   delwin(menu->win);
+   menu->win = (WINDOW *)0;
+-  
++
+   menu->status &= ~_POSTED;
+-  
++
+   RETURN(E_OK);
+ }
+ 
+Index: menu/m_req_name.c
+Prereq:  1.15 
+--- ncurses-5.4-20040208/menu/m_req_name.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_req_name.c	2004-12-25 21:42:21.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,27 +37,29 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_req_name.c,v 1.15 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_req_name.c,v 1.18 2004/12/25 21:42:21 tom Exp $")
+ 
+-static const char *request_names[ MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1 ] = {
+-  "LEFT_ITEM"    ,
+-  "RIGHT_ITEM"   ,
+-  "UP_ITEM"      ,
+-  "DOWN_ITEM"    ,
+-  "SCR_ULINE"    ,
+-  "SCR_DLINE"    ,
+-  "SCR_DPAGE"    ,
+-  "SCR_UPAGE"    ,
+-  "FIRST_ITEM"   ,
+-  "LAST_ITEM"    ,
+-  "NEXT_ITEM"    ,
+-  "PREV_ITEM"    ,
+-  "TOGGLE_ITEM"  ,
++static const char *request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1] =
++{
++  "LEFT_ITEM",
++  "RIGHT_ITEM",
++  "UP_ITEM",
++  "DOWN_ITEM",
++  "SCR_ULINE",
++  "SCR_DLINE",
++  "SCR_DPAGE",
++  "SCR_UPAGE",
++  "FIRST_ITEM",
++  "LAST_ITEM",
++  "NEXT_ITEM",
++  "PREV_ITEM",
++  "TOGGLE_ITEM",
+   "CLEAR_PATTERN",
+-  "BACK_PATTERN" ,
+-  "NEXT_MATCH"   ,
+-  "PREV_MATCH"          
++  "BACK_PATTERN",
++  "NEXT_MATCH",
++  "PREV_MATCH"
+ };
++
+ #define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
+ 
+ /*---------------------------------------------------------------------------
+@@ -70,18 +72,18 @@
+ |                    NULL                 - on invalid request code
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(const char *)
+-menu_request_name ( int request )
++menu_request_name(int request)
+ {
+-  if ( (request < MIN_MENU_COMMAND) || (request > MAX_MENU_COMMAND) )
++  T((T_CALLED("menu_request_name(%d)"), request));
++  if ((request < MIN_MENU_COMMAND) || (request > MAX_MENU_COMMAND))
+     {
+       SET_ERROR(E_BAD_ARGUMENT);
+-      return (const char *)0;
++      returnCPtr((const char *)0);
+     }
+   else
+-    return request_names[ request - MIN_MENU_COMMAND ];
++    returnCPtr(request_names[request - MIN_MENU_COMMAND]);
+ }
+ 
+-
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+ |   Function      :  int menu_request_by_name (const char *str);
+@@ -92,28 +94,30 @@
+ |                    E_NO_MATCH       - request not found
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-menu_request_by_name ( const char *str )
+-{ 
++menu_request_by_name(const char *str)
++{
+   /* because the table is so small, it doesn't really hurt
+      to run sequentially through it.
+-  */
++   */
+   unsigned int i = 0;
+   char buf[16];
+-  
++
++  T((T_CALLED("menu_request_by_name(%s)"), _nc_visbuf(str)));
++
+   if (str)
+     {
+-      strncpy(buf,str,sizeof(buf));
+-      while( (i<sizeof(buf)) && (buf[i] != '\0') )
++      strncpy(buf, str, sizeof(buf));
++      while ((i < sizeof(buf)) && (buf[i] != '\0'))
+ 	{
+ 	  buf[i] = toupper(buf[i]);
+ 	  i++;
+ 	}
+-      
+-      for (i=0; i < A_SIZE; i++)
++
++      for (i = 0; i < A_SIZE; i++)
+ 	{
+-	  if (strncmp(request_names[i],buf,sizeof(buf))==0)
+-	    return MIN_MENU_COMMAND + i;
+-	} 
++	  if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
++	    returnCode(MIN_MENU_COMMAND + i);
++	}
+     }
+   RETURN(E_NO_MATCH);
+ }
+Index: menu/m_scale.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/menu/m_scale.c	2003-10-25 14:54:48.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_scale.c	2004-12-11 23:29:34.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_scale.c,v 1.7 2003/10/25 14:54:48 tom Exp $")
++MODULE_ID("$Id: m_scale.c,v 1.9 2004/12/11 23:29:34 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -51,11 +51,13 @@
+ |                    E_NOT_CONNECTED       - no items are connected to menu
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-scale_menu (const MENU *menu, int *rows, int *cols)
++scale_menu(const MENU * menu, int *rows, int *cols)
+ {
+-  if (!menu) 
+-    RETURN( E_BAD_ARGUMENT );
+-  
++  T((T_CALLED("scale_menu(%p,%p,%p)"), menu, rows, cols));
++
++  if (!menu)
++    RETURN(E_BAD_ARGUMENT);
++
+   if (menu->items && *(menu->items))
+     {
+       if (rows)
+@@ -65,8 +67,7 @@
+       RETURN(E_OK);
+     }
+   else
+-    RETURN( E_NOT_CONNECTED );
++    RETURN(E_NOT_CONNECTED);
+ }
+ 
+ /* m_scale.c ends here */
+-
+Index: menu/m_spacing.c
+Prereq:  1.15 
+--- ncurses-5.4-20040208/menu/m_spacing.c	2003-11-08 20:49:06.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_spacing.c	2004-12-11 23:29:34.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_spacing.c,v 1.15 2003/11/08 20:49:06 tom Exp $")
++MODULE_ID("$Id: m_spacing.c,v 1.17 2004/12/11 23:29:34 tom Exp $")
+ 
+ #define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8)
+ #define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8)
+@@ -52,10 +52,12 @@
+ |   Return Values :  E_OK                 - on success
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_spacing
+-(MENU *menu, int s_desc, int s_row, int s_col )
++set_menu_spacing(MENU * menu, int s_desc, int s_row, int s_col)
+ {
+-  MENU *m; /* split for ATAC workaround */
++  MENU *m;			/* split for ATAC workaround */
++
++  T((T_CALLED("set_menu_spacing(%p,%d,%d,%d)"), menu, s_desc, s_row, s_col));
++
+   m = Normalize_Menu(menu);
+ 
+   assert(m);
+@@ -63,19 +65,18 @@
+     RETURN(E_POSTED);
+ 
+   if (((s_desc < 0) || (s_desc > MAX_SPC_DESC)) ||
+-      ((s_row  < 0) || (s_row  > MAX_SPC_ROWS)) ||
+-      ((s_col  < 0) || (s_col  > MAX_SPC_COLS)))
++      ((s_row < 0) || (s_row > MAX_SPC_ROWS)) ||
++      ((s_col < 0) || (s_col > MAX_SPC_COLS)))
+     RETURN(E_BAD_ARGUMENT);
+ 
+   m->spc_desc = s_desc ? s_desc : 1;
+-  m->spc_rows = s_row  ? s_row  : 1;
+-  m->spc_cols = s_col  ? s_col  : 1;
++  m->spc_rows = s_row ? s_row : 1;
++  m->spc_cols = s_col ? s_col : 1;
+   _nc_Calculate_Item_Length_and_Width(m);
+ 
+   RETURN(E_OK);
+ }
+ 
+-
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu
+ |   Function      :  int menu_spacing (const MENU *,int *,int *,int *);
+@@ -85,15 +86,21 @@
+ |   Return Values :  E_OK             - on success
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-menu_spacing ( const MENU *menu, int* s_desc, int* s_row, int* s_col)
++menu_spacing(const MENU * menu, int *s_desc, int *s_row, int *s_col)
+ {
+-  const MENU *m; /* split for ATAC workaround */
++  const MENU *m;		/* split for ATAC workaround */
++
++  T((T_CALLED("menu_spacing(%p,%p,%p,%p)"), menu, s_desc, s_row, s_col));
++
+   m = Normalize_Menu(menu);
+ 
+   assert(m);
+-  if (s_desc) *s_desc = m->spc_desc;
+-  if (s_row)  *s_row  = m->spc_rows;
+-  if (s_col)  *s_col  = m->spc_cols;
++  if (s_desc)
++    *s_desc = m->spc_desc;
++  if (s_row)
++    *s_row = m->spc_rows;
++  if (s_col)
++    *s_col = m->spc_cols;
+ 
+   RETURN(E_OK);
+ }
+Index: menu/m_sub.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/menu/m_sub.c	2003-10-25 15:23:42.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_sub.c	2004-12-25 21:38:31.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_sub.c,v 1.7 2003/10/25 15:23:42 tom Exp $")
++MODULE_ID("$Id: m_sub.c,v 1.10 2004/12/25 21:38:31 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -49,18 +49,20 @@
+ |                    E_POSTED       - menu is already posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_sub (MENU *menu, WINDOW *win)
++set_menu_sub(MENU * menu, WINDOW *win)
+ {
++  T((T_CALLED("set_menu_sub(%p,%p)"), menu, win));
++
+   if (menu)
+     {
+-      if ( menu->status & _POSTED )
++      if (menu->status & _POSTED)
+ 	RETURN(E_POSTED);
+       menu->usersub = win;
+       _nc_Calculate_Item_Length_and_Width(menu);
+     }
+   else
+     _nc_Default_Menu.usersub = win;
+-  
++
+   RETURN(E_OK);
+ }
+ 
+@@ -73,10 +75,12 @@
+ |   Return Values :  NULL on error, otherwise a pointer to the window
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(WINDOW *)
+-menu_sub (const MENU * menu)
++menu_sub(const MENU * menu)
+ {
+-  const MENU* m = Normalize_Menu(menu);
+-  return Get_Menu_Window(m);
++  const MENU *m = Normalize_Menu(menu);
++
++  T((T_CALLED("menu_sub(%p)"), menu));
++  returnWin(Get_Menu_Window(m));
+ }
+ 
+ /* m_sub.c ends here */
+Index: menu/m_trace.c
+--- /dev/null	2004-09-12 00:40:36.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_trace.c	2005-01-16 01:06:11.000000000 +0000
+@@ -0,0 +1,77 @@
++/****************************************************************************
++ * Copyright (c) 2004,2005 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"), to deal in the Software without restriction, including      *
++ * without limitation the rights to use, copy, modify, merge, publish,      *
++ * distribute, distribute with modifications, sublicense, and/or sell       *
++ * copies of the Software, and to permit persons to whom the Software is    *
++ * furnished to do so, subject to the following conditions:                 *
++ *                                                                          *
++ * The above copyright notice and this permission notice shall be included  *
++ * in all copies or substantial portions of the Software.                   *
++ *                                                                          *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
++ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
++ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
++ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
++ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
++ *                                                                          *
++ * Except as contained in this notice, the name(s) of the above copyright   *
++ * holders shall not be used in advertising or otherwise to promote the     *
++ * sale, use or other dealings in this Software without prior written       *
++ * authorization.                                                           *
++ ****************************************************************************/
++
++/****************************************************************************
++ *   Author:  Thomas E. Dickey                                              *
++ ****************************************************************************/
++
++#include "menu.priv.h"
++
++MODULE_ID("$Id: m_trace.c,v 1.3 2005/01/16 01:06:11 tom Exp $")
++
++NCURSES_EXPORT(ITEM *)
++_nc_retrace_item(ITEM * code)
++{
++  T((T_RETURN("%p"), code));
++  return code;
++}
++
++NCURSES_EXPORT(ITEM **)
++_nc_retrace_item_ptr(ITEM ** code)
++{
++  T((T_RETURN("%p"), code));
++  return code;
++}
++
++NCURSES_EXPORT(Item_Options)
++_nc_retrace_item_opts(Item_Options code)
++{
++  T((T_RETURN("%d"), code));
++  return code;
++}
++
++NCURSES_EXPORT(MENU *)
++_nc_retrace_menu(MENU * code)
++{
++  T((T_RETURN("%p"), code));
++  return code;
++}
++
++NCURSES_EXPORT(Menu_Hook)
++_nc_retrace_menu_hook(Menu_Hook code)
++{
++  T((T_RETURN("%p"), code));
++  return code;
++}
++
++NCURSES_EXPORT(Menu_Options)
++_nc_retrace_menu_opts(Menu_Options code)
++{
++  T((T_RETURN("%d"), code));
++  return code;
++}
+Index: menu/m_userptr.c
+Prereq:  1.13 
+--- ncurses-5.4-20040208/menu/m_userptr.c	2003-10-25 15:23:42.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_userptr.c	2004-12-25 21:38:55.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_userptr.c,v 1.13 2003/10/25 15:23:42 tom Exp $")
++MODULE_ID("$Id: m_userptr.c,v 1.16 2004/12/25 21:38:55 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -49,10 +49,11 @@
+ |   Return Values :  E_OK         - success
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_userptr (MENU * menu, void * userptr)
++set_menu_userptr(MENU * menu, void *userptr)
+ {
++  T((T_CALLED("set_menu_userptr(%p,%p)"), menu, userptr));
+   Normalize_Menu(menu)->userptr = userptr;
+-  RETURN( E_OK );
++  RETURN(E_OK);
+ }
+ 
+ /*---------------------------------------------------------------------------
+@@ -66,9 +67,10 @@
+ |                    NULL is returned
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(void *)
+-menu_userptr (const MENU * menu)
++menu_userptr(const MENU * menu)
+ {
+-  return( Normalize_Menu(menu)->userptr);
++  T((T_CALLED("menu_userptr(%p)"), menu));
++  returnVoidPtr(Normalize_Menu(menu)->userptr);
+ }
+ 
+ /* m_userptr.c ends here */
+Index: menu/m_win.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/menu/m_win.c	2003-10-25 15:23:42.000000000 +0000
++++ ncurses-5.4-20050319/menu/m_win.c	2004-12-25 21:39:20.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -37,7 +37,7 @@
+ 
+ #include "menu.priv.h"
+ 
+-MODULE_ID("$Id: m_win.c,v 1.12 2003/10/25 15:23:42 tom Exp $")
++MODULE_ID("$Id: m_win.c,v 1.15 2004/12/25 21:39:20 tom Exp $")
+ 
+ /*---------------------------------------------------------------------------
+ |   Facility      :  libnmenu  
+@@ -49,18 +49,20 @@
+ |                    E_POSTED           - menu is already posted
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(int)
+-set_menu_win (MENU *menu, WINDOW *win)
++set_menu_win(MENU * menu, WINDOW *win)
+ {
++  T((T_CALLED("set_menu_win(%p,%p)"), menu, win));
++
+   if (menu)
+     {
+-      if ( menu->status & _POSTED )
++      if (menu->status & _POSTED)
+ 	RETURN(E_POSTED);
+       menu->userwin = win;
+       _nc_Calculate_Item_Length_and_Width(menu);
+     }
+   else
+     _nc_Default_Menu.userwin = win;
+-  
++
+   RETURN(E_OK);
+ }
+ 
+@@ -73,10 +75,12 @@
+ |   Return Values :  NULL on error, otherwise pointer to window
+ +--------------------------------------------------------------------------*/
+ NCURSES_EXPORT(WINDOW *)
+-menu_win (const MENU *menu)
++menu_win(const MENU * menu)
+ {
+-  const MENU* m = Normalize_Menu(menu);
+-  return (m->userwin ? m->userwin : stdscr);
++  const MENU *m = Normalize_Menu(menu);
++
++  T((T_CALLED("menu_win(%p)"), menu));
++  returnWin(m->userwin ? m->userwin : stdscr);
+ }
+ 
+ /* m_win.c ends here */
+Index: menu/menu.priv.h
+Prereq:  1.16 
+--- ncurses-5.4-20040208/menu/menu.priv.h	2003-10-25 15:24:29.000000000 +0000
++++ ncurses-5.4-20050319/menu/menu.priv.h	2005-01-16 01:02:23.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -30,7 +30,7 @@
+  *   Author:  Juergen Pfeifer, 1995,1997                                    *
+  ****************************************************************************/
+ 
+-/* $Id: menu.priv.h,v 1.16 2003/10/25 15:24:29 tom Exp $ */
++/* $Id: menu.priv.h,v 1.22 2005/01/16 01:02:23 tom Exp $ */
+ 
+ /***************************************************************************
+ * Module menu.priv.h                                                       *
+@@ -40,9 +40,7 @@
+ #ifndef MENU_PRIV_H_incl
+ #define MENU_PRIV_H_incl 1
+ 
+-#include <ncurses_cfg.h>
+-#include <curses.h>
+-
++#include "curses.priv.h"
+ #include "mf_common.h"
+ #include "menu.h"
+ 
+@@ -108,10 +106,13 @@
+   { (menu)->pindex = 0; \
+     (menu)->pattern[0] = '\0'; }
+ 
++#define UChar(c)	((unsigned char)(c))
++
+ /* Internal functions. */
+ extern NCURSES_EXPORT(void) _nc_Draw_Menu (const MENU *);
+ extern NCURSES_EXPORT(void) _nc_Show_Menu (const MENU *);
+ extern NCURSES_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *);
++extern NCURSES_EXPORT(int)  _nc_Calculate_Text_Width(const TEXT *);
+ extern NCURSES_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *);
+ extern NCURSES_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **);
+ extern NCURSES_EXPORT(void) _nc_Disconnect_Items (MENU *);
+@@ -121,4 +122,31 @@
+ extern NCURSES_EXPORT(int)  _nc_menu_cursor_pos (const MENU* menu, const ITEM* item,
+ 				int* pY, int* pX);
+ 
++#ifdef TRACE
++
++#define returnItem(code)	TRACE_RETURN(code,item)
++#define returnItemPtr(code)	TRACE_RETURN(code,item_ptr)
++#define returnItemOpts(code)	TRACE_RETURN(code,item_opts)
++#define returnMenu(code)	TRACE_RETURN(code,menu)
++#define returnMenuHook(code)	TRACE_RETURN(code,menu_hook)
++#define returnMenuOpts(code)	TRACE_RETURN(code,menu_opts)
++
++extern NCURSES_EXPORT(ITEM *)	    _nc_retrace_item (ITEM *);
++extern NCURSES_EXPORT(ITEM **)	    _nc_retrace_item_ptr (ITEM **);
++extern NCURSES_EXPORT(Item_Options) _nc_retrace_item_opts (Item_Options);
++extern NCURSES_EXPORT(MENU *)	    _nc_retrace_menu (MENU *);
++extern NCURSES_EXPORT(Menu_Hook)    _nc_retrace_menu_hook (Menu_Hook);
++extern NCURSES_EXPORT(Menu_Options) _nc_retrace_menu_opts (Menu_Options);
++
++#else /* !TRACE */
++
++#define returnItem(code)	return code
++#define returnItemPtr(code)	return code
++#define returnItemOpts(code)	return code
++#define returnMenu(code)	return code
++#define returnMenuHook(code)	return code
++#define returnMenuOpts(code)	return code
++
++#endif /* TRACE/!TRACE */
++
+ #endif /* MENU_PRIV_H_incl */
+Index: menu/mf_common.h
+Prereq:  0.19 
+--- ncurses-5.4-20040208/menu/mf_common.h	2003-10-25 15:24:29.000000000 +0000
++++ ncurses-5.4-20050319/menu/mf_common.h	2004-12-11 22:40:40.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -30,7 +30,7 @@
+  *   Author:  Juergen Pfeifer, 1995,1997                                    *
+  ****************************************************************************/
+ 
+-/* $Id: mf_common.h,v 0.19 2003/10/25 15:24:29 tom Exp $ */
++/* $Id: mf_common.h,v 0.21 2004/12/11 22:40:40 tom Exp $ */
+ 
+ /* Common internal header for menu and form library */
+ 
+@@ -71,16 +71,21 @@
+ #define MAX_REGULAR_CHARACTER (0xff)
+ 
+ #define SET_ERROR(code) (errno=(code))
+-#define GET_ERROR() (errno)
+-#define RETURN(code) return( SET_ERROR(code) )
++#define GET_ERROR()     (errno)
++
++#ifdef TRACE
++#define RETURN(code)    returnCode( SET_ERROR(code) )
++#else
++#define RETURN(code)    return( SET_ERROR(code) )
++#endif
+ 
+ /* The few common values in the status fields for menus and forms */
+-#define _POSTED         (0x01)  /* menu or form is posted                  */
+-#define _IN_DRIVER      (0x02)  /* menu or form is processing hook routine */
++#define _POSTED         (0x01U)  /* menu or form is posted                  */
++#define _IN_DRIVER      (0x02U)  /* menu or form is processing hook routine */
+ 
+ /* Call object hook */
+ #define Call_Hook( object, handler ) \
+-   if ( (object) && ((object)->handler) )\
++   if ( (object) != 0 && ((object)->handler) != (void *) 0 )\
+    {\
+ 	(object)->status |= _IN_DRIVER;\
+ 	(object)->handler(object);\
+Index: menu/modules
+Prereq:  1.14 
+--- ncurses-5.4-20040208/menu/modules	1999-02-18 22:39:04.000000000 +0000
++++ ncurses-5.4-20050319/menu/modules	2004-12-25 22:06:33.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: modules,v 1.14 1999/02/18 22:39:04 juergen Exp $
++# $Id: modules,v 1.16 2004/12/25 22:06:33 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998 Free Software Foundation, Inc.                          #
++# Copyright (c) 1998,2004 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"), #
+@@ -56,5 +56,6 @@
+ m_scale		lib		$(srcdir)	$(MENU_PRIV_H)
+ m_spacing	lib		$(srcdir)	$(MENU_PRIV_H)
+ m_sub		lib		$(srcdir)	$(MENU_PRIV_H)
++m_trace		lib		$(srcdir)	$(MENU_PRIV_H)
+ m_userptr	lib		$(srcdir)	$(MENU_PRIV_H)
+ m_win		lib		$(srcdir)	$(MENU_PRIV_H)
+Index: misc/Makefile.in
+Prereq:  1.34 
+--- ncurses-5.4-20040208/misc/Makefile.in	2002-01-12 23:54:39.000000000 +0000
++++ ncurses-5.4-20050319/misc/Makefile.in	2004-07-11 16:00:13.000000000 +0000
+@@ -1,4 +1,4 @@
+-# $Id: Makefile.in,v 1.34 2002/01/12 23:54:39 Robert.Joop Exp $
++# $Id: Makefile.in,v 1.36 2004/07/11 16:00:13 tom Exp $
+ ##############################################################################
+ # Copyright (c) 1998,2000,2001,2002 Free Software Foundation, Inc.           #
+ #                                                                            #
+@@ -68,7 +68,7 @@
+ INSTALL_DATA	= @INSTALL_DATA@
+ 
+ ################################################################################
+-all :
++all :	terminfo.tmp
+ 
+ depend :
+ 
+@@ -76,7 +76,8 @@
+ 
+ install : install.data
+ 
+-install.data :	$(DESTDIR)$(libdir) \
++install.data :	terminfo.tmp \
++		$(DESTDIR)$(libdir) \
+ 		$(DESTDIR)$(ticdir) \
+ 		$(DESTDIR)$(tabsetdir)
+ 	DESTDIR=${DESTDIR} \
+@@ -87,7 +88,7 @@
+ 	srcdir=${srcdir} \
+ 	datadir=${datadir} \
+ 	ticdir=${ticdir} \
+-	source=${source} \
++	source=terminfo.tmp \
+ 	THIS_CC="$(CC)" \
+ 	THAT_CC="$(HOSTCC)" \
+ 	sh ./run_tic.sh
+@@ -98,10 +99,19 @@
+ 			$(INSTALL_DATA) $$i $(DESTDIR)$(tabsetdir)/$$i; \
+ 			fi; done'
+ 
++terminfo.tmp : run_tic.sed $(source)
++	echo '** adjusting tabset paths'
++	sed -f run_tic.sed $(source) >terminfo.tmp
++
++run_tic.sed :
++	WHICH_XTERM=@WHICH_XTERM@ \
++	ticdir=${ticdir} \
++	sh $(srcdir)/gen_edit.sh >$@
++
+ $(DESTDIR)$(libdir) \
+ $(DESTDIR)$(tabsetdir) \
+ $(DESTDIR)$(ticdir) :
+-	sh $(srcdir)/../mkinstalldirs $@
++	sh $(top_srcdir)/mkinstalldirs $@
+ 
+ uninstall : uninstall.data
+ 
+@@ -114,6 +124,8 @@
+ @MAKE_UPPER_TAGS@TAGS :
+ 
+ mostlyclean :
++	-rm -f terminfo.tmp
++	-rm -f run_tic.sed
+ 	-rm -f core tags TAGS *~ *.bak *.ln *.atac trace
+ 
+ clean :: mostlyclean
+Index: misc/gen_edit.sh
+--- /dev/null	2004-09-12 00:40:36.000000000 +0000
++++ ncurses-5.4-20050319/misc/gen_edit.sh	2004-07-11 15:01:29.000000000 +0000
+@@ -0,0 +1,58 @@
++#!/bin/sh
++##############################################################################
++# Copyright (c) 2004 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"), #
++# to deal in the Software without restriction, including without limitation  #
++# the rights to use, copy, modify, merge, publish, distribute, distribute    #
++# with modifications, sublicense, and/or sell copies of the Software, and to #
++# permit persons to whom the Software is furnished to do so, subject to the  #
++# following conditions:                                                      #
++#                                                                            #
++# The above copyright notice and this permission notice shall be included in #
++# all copies or substantial portions of the Software.                        #
++#                                                                            #
++# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
++# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
++# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
++# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
++# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
++# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
++# DEALINGS IN THE SOFTWARE.                                                  #
++#                                                                            #
++# Except as contained in this notice, the name(s) of the above copyright     #
++# holders shall not be used in advertising or otherwise to promote the sale, #
++# use or other dealings in this Software without prior written               #
++# authorization.                                                             #
++##############################################################################
++#
++# Author: Thomas E. Dickey
++#
++# $Id: gen_edit.sh,v 1.1 2004/07/11 15:01:29 tom Exp $
++# Generate a sed-script for converting the terminfo.src to the form which will
++# be installed.
++#
++# Assumes:
++#	The leaf directory names (lib, tabset, terminfo)
++#
++
++: ${ticdir=@TERMINFO@}
++: ${xterm_new=@WHICH_XTERM@}
++
++# If we're not installing into /usr/share/, we'll have to adjust the location
++# of the tabset files in terminfo.src (which are in a parallel directory).
++TABSET=`echo $ticdir | sed -e 's%/terminfo$%/tabset%'`
++if test "x$TABSET" != "x/usr/share/tabset" ; then
++cat <<EOF
++s%/usr/share/tabset%$TABSET%g
++EOF
++fi
++
++if test "$xterm_new" != "xterm-new" ; then
++cat <<EOF
++/^# This is xterm for ncurses/,/^$/{
++	s/use=xterm-new,/use=$WHICH_XTERM,/
++}
++EOF
++fi
+Index: misc/jpf-indent
+--- /dev/null	2004-09-12 00:40:36.000000000 +0000
++++ ncurses-5.4-20050319/misc/jpf-indent	2004-05-29 19:14:45.000000000 +0000
+@@ -0,0 +1,87 @@
++#!/bin/sh
++# $Id: jpf-indent,v 1.3 2004/05/29 19:14:45 tom Exp $
++# indent ncurses source written by Juergen Pfeifer
++NOOP=no
++OPTS='
++-npro
++--blank-lines-after-declarations
++--blank-lines-after-procedures
++--brace-indent2
++--braces-after-if-line
++--continue-at-parentheses
++--indent-level2
++--line-length80
++--no-space-after-casts
++--no-space-after-function-call-names
++--parameter-indentation4
++--swallow-optional-blank-lines
++--tab-size8
++-T FIELD
++-T FIELDTYPE
++-T FIELD_CELL
++-T FORM
++-T INLINE
++-T RegExp_Arg 
++-T TypeArgument 
++-T WINDOW
++-T attr_t
++-T bool
++-T cchar_t
++-T chtype
++-T enumARG
++-T va_list
++-T wchar_t 
++'
++for name in $*
++do
++	case $name in
++	-v|-n)
++		NOOP=yes
++		OPTS="$OPTS -v"
++		;;
++	-*)
++		OPTS="$OPTS $name"
++		;;
++	*.[ch])
++		save="${name}".a$$
++		test="${name}".b$$
++		rm -f "$save" "$test"
++		mv "$name" "$save"
++		sed \
++			-e '/MODULE_ID(/s/)$/);/' \
++			-e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \
++			-e 's,\(\<NCURSES_EXPORT_VAR\>\),//\1,' \
++			"$save" >"$test"
++		cp "$test" "$name"
++		chmod u+w "$name"
++		# ${INDENT_PROG-indent} --version
++		${INDENT_PROG-indent} $OPTS "$name"
++		sed \
++			-e '/MODULE_ID(/s/);$/)/' \
++			-e 's,;[ 	]*//GCC_NORETURN;, GCC_NORETURN;,' \
++			-e 's,//\(\<NCURSES_EXPORT_VAR\>\),\1,' \
++			"$name" >"$test"
++		mv "$test" "$name"
++		rm -f "${name}~"
++		if test $NOOP = yes ; then
++			if (cmp -s "$name" "$save" ) then
++				echo "** no change: $name"
++			else
++				diff -u "$save" "$name"
++			fi
++			rm -f "$name"
++			mv "$save" "$name"
++		elif ( cmp -s "$name" "$save" ) ; then
++			echo "** unchanged $name"
++			rm -f "${name}"
++			mv "$save" "$name"
++		else
++			echo "** updated $name"
++			rm -f "$save"
++		fi
++		;;
++	*)
++		echo "** ignored:   $name"
++		;;
++	esac
++done
+Index: misc/ncu-indent
+--- /dev/null	2004-09-12 00:40:36.000000000 +0000
++++ ncurses-5.4-20050319/misc/ncu-indent	2004-11-23 00:45:48.000000000 +0000
+@@ -0,0 +1,98 @@
++#!/bin/sh
++# $Id: ncu-indent,v 1.12 2004/11/23 00:45:48 tom Exp $
++NOOP=no
++OPTS='
++--blank-lines-after-procedures
++--braces-on-if-line
++--continuation-indentation0
++--continue-at-parentheses
++--cuddle-else
++--indent-level4
++--leave-preprocessor-space
++--no-blank-lines-after-commas
++--no-blank-lines-after-declarations
++--no-space-after-function-call-names
++--procnames-start-lines
++--space-special-semicolon
++--swallow-optional-blank-lines
++--tab-size8
++
++-T NCURSES_EXPORT_VAR
++-T SCREEN
++-T TERMTYPE
++-T attr_t
++-T cchar_t
++-T chtype
++-T inline
++-T wchar_t
++-T wint_t
++
++-T BUFFER
++-T CHARTYPE
++-T FILE
++-T GCC_NORETURN
++-T LINE
++-T MARK
++-T RETSIGTYPE 
++-T TBUFF
++-T WINDOW
++-T size_t
++-T va_list
++
++-T Cardinal
++-T Widget
++-T XtPointer
++'
++for name in $*
++do
++	case $name in
++	-v|-n)
++		NOOP=yes
++		OPTS="$OPTS -v"
++		;;
++	-*)
++		OPTS="$OPTS $name"
++		;;
++	*.[ch])
++		save="${name}".a$$
++		test="${name}".b$$
++		rm -f "$save" "$test"
++		mv "$name" "$save"
++		sed \
++			-e '/MODULE_ID(/s/)$/);/' \
++			-e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \
++			-e 's,\(\<NCURSES_EXPORT_VAR\>\),//\1,' \
++			"$save" >"$test"
++		cp "$test" "$name"
++		chmod u+w "$name"
++		# ${INDENT_PROG-indent} --version
++		${INDENT_PROG-indent} -npro $OPTS "$name"
++		sed \
++			-e '/MODULE_ID(/s/);$/)/' \
++			-e 's,;[ 	]*//GCC_NORETURN;, GCC_NORETURN;,' \
++			-e 's,//\(\<NCURSES_EXPORT_VAR\>\),\1,' \
++			"$name" >"$test"
++		mv "$test" "$name"
++		rm -f "${name}~"
++		if test $NOOP = yes ; then
++			if (cmp -s "$name" "$save" ) then
++				echo "** no change: $name"
++			else
++				diff -u "$save" "$name"
++			fi
++			rm -f "$name"
++			mv "$save" "$name"
++		elif ( cmp -s "$name" "$save" ) ; then
++			echo "** unchanged $name"
++			rm -f "${name}"
++			mv "$save" "$name"
++		else
++			echo "** updated $name"
++			rm -f "$save"
++		fi
++		;;
++	*)
++		echo "** ignored:   $name"
++		;;
++	esac
++done
+Index: misc/run_tic.in
+Prereq:  1.15 
+--- ncurses-5.4-20040208/misc/run_tic.in	2003-09-06 22:31:44.000000000 +0000
++++ ncurses-5.4-20050319/misc/run_tic.in	2004-07-11 15:11:14.000000000 +0000
+@@ -29,7 +29,7 @@
+ #
+ # Author: Thomas E. Dickey 1996,2000
+ #
+-# $Id: run_tic.in,v 1.15 2003/09/06 22:31:44 Dan.Kegel Exp $
++# $Id: run_tic.in,v 1.17 2004/07/11 15:11:14 tom Exp $
+ # This script is used to install terminfo.src using tic.  We use a script
+ # because the path checking is too awkward to do in a makefile.
+ #
+@@ -54,6 +54,7 @@
+ : ${LN_S="@LN_S@"}
+ : ${THAT_CC=cc}
+ : ${THIS_CC=cc}
++: ${ext_funcs=@NCURSES_EXT_FUNCS@}
+ 
+ test -z "${DESTDIR}" && DESTDIR=
+ 
+@@ -93,26 +94,35 @@
+ # the directory is actually a symbolic link.
+ ( cd $TERMINFO && rm -fr ? 2>/dev/null )
+ 
+-# If we're not installing into /usr/share/, we'll have to adjust the location
+-# of the tabset files in terminfo.src (which are in a parallel directory).
+-TABSET=`echo $ticdir | sed -e 's%/terminfo$%/tabset%'`
+-if test "x$TABSET" != "x/usr/share/tabset" ; then
+-	echo '** adjusting tabset paths'
+-	TMP=${TMPDIR-/tmp}/$$
+-	sed -e s%/usr/share/tabset%$TABSET%g $source >$TMP
+-	trap "rm -f $TMP" 0 1 2 5 15
+-	source=$TMP
+-fi
++if test "$ext_funcs" = 1 ; then
++cat <<EOF
++Running tic to install $TERMINFO ...
++
++	You may see messages regarding extended capabilities, e.g., AX.
++	These are extended terminal capabilities which are compiled
++	using
++		tic -x
++	If you have ncurses 4.2 applications, you should read the INSTALL
++	document, and install the terminfo without the -x option.
+ 
++EOF
++if ( $SHLIB tic$suffix -x -s -o $TERMINFO $source )
++then
++	echo '** built new '$TERMINFO
++else
++	echo '? tic could not build '$TERMINFO
++	exit 1
++fi
++else
+ cat <<EOF
+ Running tic to install $TERMINFO ...
+ 
+ 	You may see messages regarding unknown capabilities, e.g., AX.
+-	These are extended terminal capabilities which can be compiled
++	These are extended terminal capabilities which may be compiled
+ 	using
+ 		tic -x
+-	Read the INSTALL document before doing this - it can cause
+-	problems for older ncurses applications.
++	If you have ncurses 4.2 applications, you should read the INSTALL
++	document, and install the terminfo without the -x option.
+ 
+ EOF
+ if ( $SHLIB tic$suffix -s -o $TERMINFO $source )
+@@ -122,6 +132,7 @@
+ 	echo '? tic could not build '$TERMINFO
+ 	exit 1
+ fi
++fi
+ 
+ # Make a symbolic link to provide compatibility with applications that expect
+ # to find terminfo under /usr/lib.  That is, we'll _try_ to do that.  Not
+Index: misc/shlib
+Prereq:  1.7 
+--- ncurses-5.4-20040208/misc/shlib	2003-07-19 22:58:14.000000000 +0000
++++ ncurses-5.4-20050319/misc/shlib	2005-01-22 20:59:44.000000000 +0000
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+ ##############################################################################
+-# Copyright (c) 1998,2000 Free Software Foundation, Inc.                     #
++# Copyright (c) 1998-2000,2003 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"), #
+@@ -29,7 +29,7 @@
+ #
+ # Author: Thomas E. Dickey <dickey@clark.net> 1996
+ #
+-# $Id: shlib,v 1.7 2003/07/19 22:58:14 tom Exp $
++# $Id: shlib,v 1.8 2005/01/22 20:59:44 tom Exp $
+ # Use this script as a wrapper when running executables linked to shared
+ # libraries on systems that use the $LD_LIBRARY_PATH variable and don't embed
+ # the soname's path within the linked executable (such as IRIX), e.g,
+@@ -58,7 +58,9 @@
+ # Special cases:
+ #
+ #	BeOS R4.5 uses $LIBRARY_PATH rather than $LD_LIBRARY_PATH.
+-
++#	Cygwin uses $PATH
++#
++CDPATH=
+ #
+ # Make sure that we use the PATH that was set in run_tic.sh
+ #
+@@ -68,10 +70,12 @@
+ fi
+ 
+ q=""
+-for p in lib ../lib
++for p in lib ../lib ../../lib ../../../lib
+ do
+ 	if test -d $p; then
+-		q="$p"
++		q=`cd $p; pwd`
++	elif test -f configure ; then
++		break
+ 	fi
+ done
+ if test -n "$q" ; then
+Index: misc/terminfo.src
+--- ncurses-5.4-20040208/misc/terminfo.src	2004-01-18 01:37:18.000000000 +0000
++++ ncurses-5.4-20050319/misc/terminfo.src	2005-02-26 23:46:26.000000000 +0000
+@@ -4,12 +4,13 @@
+ # Report bugs and new terminal descriptions to
+ #	bug-ncurses@gnu.org
+ #
+-#	$Revision: 1.227 $
+-#	$Date: 2004/01/18 01:37:18 $
++#	$Revision: 1.260 $
++#	$Date: 2005/02/26 23:46:26 $
+ #
+ # The original header is preserved below for reference.  It is noted that there
+-# is a newer version which differs in some cosmetic details; we have decided
+-# to not change the header unless there is also a change in content.
++# is a "newer" version which differs in some cosmetic details (but actually
++# stopped updates several years ago); we have decided to not change the header
++# unless there is also a change in content.
+ #
+ #------------------------------------------------------------------------------
+ #	Version 10.2.1
+@@ -291,7 +292,7 @@
+ 	bel=^G, clear=^L, cr=^M, cub1=^H, cud1=^J, ht=^I, kcub1=^H, 
+ 	kcud1=^J, nel=^M^J, .kbs=^H, 
+ 
+-vanilla, 
++vanilla|dumb tty, 
+ 	OTbs, 
+ 	bel=^G, cr=^M, cud1=^J, ind=^J, 
+ 
+@@ -329,7 +330,9 @@
+ 	kbs=^H, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, 
+ 	khome=\E[H, 
+ ansi+sgr|ansi graphic renditions, 
+-	blink=\E[5m, invis=\E[8m, rev=\E[7m, sgr0=\E[0m, 
++	blink=\E[5m, invis=\E[8m, rev=\E[7m, 
++	sgr=\E[0%?%p3%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%;, 
++	sgr0=\E[0m, 
+ ansi+sgrso|ansi standout only, 
+ 	rmso=\E[m, smso=\E[7m, 
+ ansi+sgrul|ansi underline only, 
+@@ -705,12 +708,12 @@
+ 	kf19=\E[33~, kf2=\E[[B, kf20=\E[34~, kf3=\E[[C, kf4=\E[[D, 
+ 	kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
+ 	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
+-	kspd=^Z, nel=^M^J, rc=\E8, rev=\E[7m, ri=\EM, rmir=\E[4l, 
+-	rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]R, sc=\E7, 
++	kspd=^Z, nel=^M^J, rc=\E8, rev=\E[7m, ri=\EM, rmam=\E[?7l, 
++	rmir=\E[4l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec\E]R, sc=\E7, 
+ 	sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, 
+-	smir=\E[4h, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, 
+-	u7=\E[6n, u8=\E[?6c, u9=\E[c, vpa=\E[%i%p1%dd, 
+-	use=klone+sgr, use=ecma+color, 
++	smam=\E[?7h, smir=\E[4h, smul=\E[4m, tbc=\E[3g, 
++	u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?6c, u9=\E[c, 
++	vpa=\E[%i%p1%dd, use=klone+sgr, use=ecma+color, 
+ 
+ linux-m|Linux console no color, 
+ 	colors@, pairs@, 
+@@ -791,6 +794,63 @@
+ 	dim=\E[2m, invis=\E[8m, op=\E[37;40m, rmso=\E[27m, 
+ 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, use=mach, 
+ 
++# From: Marcus Brinkmann
++# http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/hurd/hurd/console/
++#
++# Comments in the original are summarized here:
++#
++# hurd uses 8-bit characters (km).
++#
++# Although it doesn't do XON/XOFF, we don't want padding characters (xon).
++#
++# Regarding compatibility to vt100:  hurd doesn't specify <xenl>, as we don't
++# have the eat_newline_glitch.  It doesn't support setting or removing tab
++# stops (hts/tbc).
++#
++# hurd uses ^H instead of \E[D for cub1, as only ^H implements <bw> and it is
++# one byte instead three.
++#
++# <ich1> is not included because hurd has insert mode.
++#
++# hurd doesn't use ^J for scrolling, because this could put things into the
++# scrollback buffer.
++#
++# gsbom/grbom are used to enable/disable real bold (not intensity bright) mode. 
++# This is a GNU extension.
++#
++# The original has commented-out ncv, but is restored here.
++#
++# Reading the source, RIS resets cnorm, but not xmous.
++hurd|The GNU Hurd console server, 
++	am, bce, bw, eo, km, mir, msgr, xon, 
++	colors#8, it#8, ncv#18, pairs#64, 
++	acsc=++\,\,--..00ii``aaffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
++	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, 
++	clear=\Ec, cnorm=\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, 
++	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\E[B, 
++	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, 
++	cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[34l, dch=\E[%p1%dP, 
++	dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, 
++	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, flash=\Eg, 
++	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, ich=\E[%p1%d@, 
++	il=\E[%p1%dL, il1=\E[L, ind=\E[S, indn=\E[%p1%dS, 
++	invis=\E[8m, kb2=\E[G, kbs=\177, kcbt=\E[Z, kcub1=\EOD, 
++	kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, 
++	kend=\E[4~, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, 
++	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
++	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, 
++	kf2=\EOQ, kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf5=\E[15~, 
++	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
++	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
++	kspd=^Z, nel=^M^J, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\E[T, 
++	rin=\E[%p1%dT, ritm=\E[23m, rmacs=\E[10m, rmir=\E[4l, 
++	rmso=\E[27m, rmul=\E[24m, rs1=\EM\E[?1000l, sc=\E7, 
++	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
++	sgr=\E[0%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m, 
++	sgr0=\E[0m, sitm=\E[3m, smacs=\E[11m, smir=\E[4h, 
++	smso=\E[7m, smul=\E[4m, vpa=\E[%i%p1%dd, grbom=\E[>1l, 
++	gsbom=\E[>1h, 
++
+ #### OSF Unix
+ #
+ 
+@@ -1464,7 +1524,7 @@
+ # Entry for the DNARD OpenFirmware console, close to ANSI but not quite.
+ #
+ # (still unfinished, but good enough so far.)
+-ofcons, 
++ofcons|DNARD OpenFirmware console, 
+ 	bw, 
+ 	cols#80, lines#30, 
+ 	bel=^G, blink=\2337;2m, bold=\2331m, clear=^L, cr=^M, 
+@@ -1482,15 +1542,29 @@
+ 	sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m, 
+ 	sgr0=\2330m, 
+ 
+-# NetBSD "wscons" emulator in vt220 mode
+-# These are micro-minimal and probably need to be redone for real
+-# after the manner of the pcvt entries.
++# NetBSD "wscons" emulator in vt220 mode.
++# This entry is based on the NetBSD termcap entry, correcting the ncv value.
++# The emulator renders underlined text in red.  Colors are otherwise usable.
++#
++# Testing the emulator and reading the source code (NetBSD 2.0), it appears
++# that "vt220" is inaccurate.  There are a few vt220-features, but most of the
++# vt220 screens in vttest do not work with this emulator.  For instance, it
++# identifies itself (primary DA response) as a vt220 with selective erase.  But
++# the selective erase feature does not work.  The secondary response is copied
++# from Kermit's emulation of vt220, does not correspond to actual vt220.  At
++# the level of detail in a termcap, it is a passable emulator, since ECH does
++# work.  Don't use it on a VMS system -TD
+ wsvt25|NetBSD wscons in 25 line DEC VT220 mode, 
+-	cols#80, lines#25, use=vt220, 
++	bce, msgr, 
++	colors#8, cols#80, it#8, lines#25, ncv#2, pairs#64, 
++	is2=\E[r\E[25;1H, kend=\E[8~, kf1=\E[11~, kf10=\E[21~, 
++	kf11=\E[23~, kf12=\E[24~, kf2=\E[12~, kf3=\E[13~, 
++	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, 
++	kf9=\E[20~, khome=\E[7~, op=\E[m, setab=\E[4%p1%dm, 
++	setaf=\E[3%p1%dm, use=vt220, 
+ 
+ wsvt25m|NetBSD wscons in 25 line DEC VT220 mode with Meta, 
+-	km, 
+-	cols#80, lines#25, use=vt220, 
++	km, use=wsvt25, 
+ 
+ # `rasterconsole' provided by 4.4BSD, NetBSD and OpenBSD on SPARC, and 
+ # DECstation/pmax.
+@@ -1563,31 +1637,34 @@
+ 	cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C, 
+ 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
+ 	cvvis=\E[=1C, dch=\E[%p1%dP, dch1=\E[P, dim=\E[30;1m, 
+-	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, home=\E[H, 
+-	hpa=\E[%i%p1%d`, ht=^I, ich=\E[%p1%d@, ich1=\E[@, 
+-	il=\E[%p1%dL, il1=\E[L, ind=\E[S, indn=\E[%p1%dS, kb2=\E[E, 
+-	kbs=^H, kcbt=\E[Z, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, 
+-	kcuu1=\E[A, kdch1=\177, kend=\E[F, kf1=\E[M, kf10=\E[V, 
+-	kf11=\E[W, kf12=\E[X, kf13=\E[Y, kf14=\E[Z, kf15=\E[a, 
+-	kf16=\E[b, kf17=\E[c, kf18=\E[d, kf19=\E[e, kf2=\E[N, 
+-	kf20=\E[f, kf21=\E[g, kf22=\E[h, kf23=\E[i, kf24=\E[j, 
+-	kf25=\E[k, kf26=\E[l, kf27=\E[m, kf28=\E[n, kf29=\E[o, 
+-	kf3=\E[O, kf30=\E[p, kf31=\E[q, kf32=\E[r, kf33=\E[s, 
+-	kf34=\E[t, kf35=\E[u, kf36=\E[v, kf37=\E[w, kf38=\E[x, 
+-	kf39=\E[y, kf4=\E[P, kf40=\E[z, kf41=\E[@, kf42=\E[[, 
+-	kf43=\E[\\, kf44=\E[], kf45=\E[\^, kf46=\E[_, kf47=\E[`, 
+-	kf48=\E[{, kf5=\E[Q, kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, 
+-	khome=\E[H, kich1=\E[L, knp=\E[G, kpp=\E[I, nel=\E[E, 
+-	op=\E[x, rev=\E[7m, ri=\E[T, rin=\E[%p1%dT, rmso=\E[m, 
+-	rs2=\E[x\E[m\Ec, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
++	dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, 
++	home=\E[H, hpa=\E[%i%p1%d`, ht=^I, ich=\E[%p1%d@, 
++	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=\E[S, 
++	indn=\E[%p1%dS, kb2=\E[E, kbs=^H, kcbt=\E[Z, kcub1=\E[D, 
++	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\177, kend=\E[F, 
++	kf1=\E[M, kf10=\E[V, kf11=\E[W, kf12=\E[X, kf13=\E[Y, 
++	kf14=\E[Z, kf15=\E[a, kf16=\E[b, kf17=\E[c, kf18=\E[d, 
++	kf19=\E[e, kf2=\E[N, kf20=\E[f, kf21=\E[g, kf22=\E[h, 
++	kf23=\E[i, kf24=\E[j, kf25=\E[k, kf26=\E[l, kf27=\E[m, 
++	kf28=\E[n, kf29=\E[o, kf3=\E[O, kf30=\E[p, kf31=\E[q, 
++	kf32=\E[r, kf33=\E[s, kf34=\E[t, kf35=\E[u, kf36=\E[v, 
++	kf37=\E[w, kf38=\E[x, kf39=\E[y, kf4=\E[P, kf40=\E[z, 
++	kf41=\E[@, kf42=\E[[, kf43=\E[\\, kf44=\E[], kf45=\E[\^, 
++	kf46=\E[_, kf47=\E[`, kf48=\E[{, kf5=\E[Q, kf6=\E[R, 
++	kf7=\E[S, kf8=\E[T, kf9=\E[U, khome=\E[H, kich1=\E[L, 
++	knp=\E[G, kpp=\E[I, nel=\E[E, op=\E[x, rc=\E8, rev=\E[7m, 
++	ri=\E[T, rin=\E[%p1%dT, rmso=\E[m, rs2=\E[x\E[m\Ec, sc=\E7, 
++	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
++	sgr=\E[0%?%p1%t;2;7%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;30;1%;%?%p6%t;1%;m, 
+ 	sgr0=\E[m, smso=\E[7m, vpa=\E[%i%p1%dd, 
+ cons25|ansis|ansi80x25|freebsd console (25-line ansi mode), 
+ 	acsc=-\030.^Y0\333`\004a\260f\370g\361h\261i\025j\331k\277l\332m\300n\305q\304t\303u\264v\301w\302x\263y\363z\362~\371, 
+ 	use=cons25w, 
+ cons25-m|ansis-mono|ansi80x25-mono|freebsd console (25-line mono ansi mode), 
+ 	colors@, pairs@, 
+-	bold@, dim@, op@, rmul=\E[m, setab@, setaf@, smul=\E[4m, 
+-	use=cons25, 
++	bold@, dim@, op@, rmul=\E[m, setab@, setaf@, 
++	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;m, 
++	smul=\E[4m, use=cons25, 
+ cons30|ansi80x30|freebsd console (30-line ansi mode), 
+ 	lines#30, use=cons25, 
+ cons30-m|ansi80x30-mono|freebsd console (30-line mono ansi mode), 
+@@ -1609,7 +1686,9 @@
+ 	use=cons25w, 
+ cons25r-m|pc3r-m|ibmpc3r-mono|cons25-koi8r-m|freebsd console w/koi8-r cyrillic (mono), 
+ 	colors@, pairs@, 
+-	op@, rmul=\E[m, setab@, setaf@, smul=\E[4m, use=cons25r, 
++	op@, rmul=\E[m, setab@, setaf@, 
++	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;30;1%;%?%p6%t;1%;m, 
++	smul=\E[4m, use=cons25r, 
+ cons50r|cons50-koi8r|freebsd console w/koi8-r cyrillic (50 lines), 
+ 	lines#50, use=cons25r, 
+ cons50r-m|cons50-koi8r-m|freebsd console w/koi8-r cyrillic (50-line mono), 
+@@ -1624,8 +1703,9 @@
+ 	use=cons25w, 
+ cons25l1-m|cons25-iso-m|freebsd console w/iso 8859-1 chars (mono), 
+ 	colors@, pairs@, 
+-	bold@, dim@, op@, rmul=\E[m, setab@, setaf@, smul=\E[4m, 
+-	use=cons25l1, 
++	bold@, dim@, op@, rmul=\E[m, setab@, setaf@, 
++	sgr=\E[0%?%p1%t;2;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;m, 
++	smul=\E[4m, use=cons25l1, 
+ cons50l1|cons50-iso8859|freebsd console w/iso 8859-1 chars (50 lines), 
+ 	lines#50, use=cons25l1, 
+ cons50l1-m|cons50-iso-m|freebsd console w/iso 8859-1 chars (50-line mono), 
+@@ -2058,12 +2138,14 @@
+ 	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\EOQ, 
+ 	kf20=\E[34~, kf3=\EOR, kf4=\EOS, kf6=\E[17~, kf7=\E[18~, 
+ 	kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, khlp=\E[28~, 
+-	khome=\E[H, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, krdo=\E[29~, 
+-	kslt=\E[4~, lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, mc0=\E[i, 
+-	mc4=\E[4i, mc5=\E[5i, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, 
++	kich1=\E[2~, knp=\E[6~, kpp=\E[5~, krdo=\E[29~, kslt=\E[4~, 
++	lf1=pf1, lf2=pf2, lf3=pf3, lf4=pf4, mc0=\E[i, mc4=\E[4i, 
++	mc5=\E[5i, nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, 
+ 	rmacs=\E(B$<4>, rmam=\E[?7l, rmir=\E[4l, rmso=\E[27m, 
+-	rmul=\E[24m, rs1=\E[?3l, sc=\E7, sgr0=\E[m, smacs=\E(0$<2>, 
+-	smam=\E[?7h, smir=\E[4h, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
++	rmul=\E[24m, rs1=\E[?3l, sc=\E7, 
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
++	sgr0=\E[m, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h, 
++	smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
+ vt220-w|vt200-w|DEC vt220 in wide mode, 
+ 	cols#132, 
+ 	rs3=\E[?3h, use=vt220, 
+@@ -2089,12 +2171,13 @@
+ 	kfnd=\2331~, khlp=\23328~, khome=\233H, kich1=\2332~, 
+ 	knp=\2336~, kpp=\2335~, krdo=\23329~, kslt=\2334~, lf1=pf1, 
+ 	lf2=pf2, lf3=pf3, lf4=pf4, mc0=\233i, mc4=\2334i, mc5=\2335i, 
+-	nel=\EE, rc=\E8, rev=\2337m, ri=\EM, rmacs=^O, rmam=\233?7l, 
+-	rmir=\2334l, rmso=\23327m, rmul=\23324m, rs1=\233?3l, 
+-	sc=\E7, sgr0=\233m, smacs=^N, smam=\233?7h, smir=\2334h, 
++	nel=\EE, rc=\E8, rev=\2337m, ri=\EM, rmacs=\E(B, 
++	rmam=\233?7l, rmir=\2334l, rmso=\23327m, rmul=\23324m, 
++	rs1=\233?3l, sc=\E7, 
++	sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
++	sgr0=\233m, smacs=\E(0, smam=\233?7h, smir=\2334h, 
+ 	smso=\2337m, smul=\2334m, tbc=\2333g, 
+ 
+-#
+ # vt220d:
+ # This vt220 description regards F6--F10 as the second block of function keys
+ # at the top of the keyboard.  This mapping follows the description given
+@@ -2146,7 +2229,6 @@
+ #vt320|DEC VT320 in vt100 emulation mode,
+ #	use=vt220,
+ 
+-#
+ # Use v320n for SCO's LYRIX.  Otherwise, use Adam Thompson's vt320-nam.
+ #
+ vt320nam|v320n|DEC VT320 in vt100 emul. mode with NO AUTO WRAP mode, 
+@@ -2179,7 +2261,7 @@
+ 	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, fsl=\E[0$}, 
+ 	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, 
+ 	il1=\E[L, ind=\ED, 
+-	is2=\E>\E[?3l\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
++	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+ 	kbs=\177, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
+ 	kdch1=\E[3~, kel=\E[4~, kf10=\E[21~, kf11=\E[23~, 
+ 	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
+@@ -2191,25 +2273,27 @@
+ 	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B, 
+ 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[m, 
+ 	rmul=\E[m, 
+-	rs2=\E>\E[?3l\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+-	sc=\E7, sgr0=\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h, 
++	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
++	sc=\E7, 
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
++	sgr0=\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h, 
+ 	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
+ 	tsl=\E[1$}\E[H\E[K, use=vt220+keypad, 
+ vt320-nam|vt300-nam|dec vt320 7 bit terminal with no am to make SAS happy, 
+ 	am@, 
+-	is2=\E>\E[?3l\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
+-	rs2=\E>\E[?3l\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
++	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
++	rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
+ 	use=vt320, 
+ # We have to init 132-col mode, not 80-col mode.
+ vt320-w|vt300-w|dec vt320 wide 7 bit terminal, 
+ 	cols#132, wsl#132, 
+-	is2=\E>\E[?3h\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+-	rs2=\E>\E[?3h\E[?4l\E[5?l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
++	is2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
++	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+ 	use=vt320, 
+ vt320-w-nam|vt300-w-nam|dec vt320 wide 7 bit terminal with no am, 
+ 	am@, 
+-	is2=\E>\E[?3h\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
+-	rs2=\E>\E[?3h\E[?4l\E[5?l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
++	is2=\E>\E[?3h\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
++	rs2=\E>\E[?3h\E[?4l\E[?5l\E[?7l\E[?8h\E[1;24r\E[24;1H, 
+ 	use=vt320-w, 
+ 
+ # VT330 and VT340 -- These are ReGIS and SIXEL graphics terminals
+@@ -2240,21 +2324,23 @@
+ 	cnorm=\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, 
+ 	cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J, 
+ 	cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, 
+-	cuu=\E[%p1%dA, cuu1=\E[A, cvvis=\E[?25h, dch=\E[%p1%dP, 
+-	dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
+-	dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K, 
+-	flash=\E[?5h\E[?5l$<200/>, fsl=\E[$}, home=\E[H, ht=^I, 
+-	hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED, 
++	cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P, 
++	dl=\E[%p1%dM, dl1=\E[M, dsl=\E[2$~\r\E[1$}\E[K\E[$}, 
++	ed=\E[J, el=\E[K, flash=\E[?5h\E[?5l$<200/>, fsl=\E[$}, 
++	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, 
++	il1=\E[L, ind=\ED, 
+ 	is2=\E<\E F\E>\E[?1h\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+ 	kbs=^H, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
+ 	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~, 
+ 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, lf1=pf1, lf2=pf2, 
+ 	lf3=pf3, lf4=pf4, nel=^M\ED, rc=\E8, rev=\E[7m, 
+-	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=^O, 
++	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B, 
+ 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, 
+-	rmul=\E[24m, rs1=\E[?3l, sc=\E7, sgr0=\E[m, smacs=^N, 
+-	smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, 
+-	smul=\E[4m, tbc=\E[3g, tsl=\E[2$~\E[1$}\E[1;%dH, 
++	rmul=\E[24m, rs1=\E[?3l, sc=\E7, 
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
++	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smir=\E[4h, 
++	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
++	tsl=\E[2$~\E[1$}\E[1;%dH, 
+ 
+ # DEC doesn't supply a vt400 description, so we add Daniel Glasser's
+ # (originally written with vt420 as its primary name, and usable for it).
+@@ -2286,8 +2372,8 @@
+ 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
+ 	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
+ 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
+-	cvvis=\E[?25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, 
+-	dl1=\E[M, dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J$<10/>, 
++	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
++	dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J$<10/>, 
+ 	el=\E[K$<4/>, flash=\E[?5h\E[?5l$<200/>, fsl=\E[$}, 
+ 	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, 
+ 	il=\E[%p1%dL, il1=\E[L, ind=\ED, 
+@@ -2296,11 +2382,12 @@
+ 	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf6=\E[17~, 
+ 	kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, lf1=pf1, lf2=pf2, 
+ 	lf3=pf3, lf4=pf4, nel=^M\ED, rc=\E8, rev=\E[7m, 
+-	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=^O, 
++	rf=/usr/share/tabset/vt300, ri=\EM, rmacs=\E(B, 
+ 	rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, 
+-	rmul=\E[24m, rs1=\E<\E[?3l\E[!p\E[?7h, sc=\E7, sgr0=\E[m, 
+-	smacs=^N, smam=\E[?7h, smir=\E[4h, smkx=\E[?1h\E=, 
+-	smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
++	rmul=\E[24m, rs1=\E<\E[?3l\E[!p\E[?7h, sc=\E7, 
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;$<2>, 
++	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smir=\E[4h, 
++	smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
+ 	tsl=\E[2$~\E[1$}\E[1;%dH, 
+ 
+ # (vt420: I removed <kf0>, it collided with <kf10>.  I also restored
+@@ -2329,7 +2416,6 @@
+ 	sgr0=\E[m$<2>, smacs=\E(0$<2>, smam=\E[?7h, smir=\E[4h, 
+ 	smkx=\E=, smso=\E[7m, smul=\E[4m, 
+ 
+-#
+ # DEC VT220 and up support DECUDK (user-defined keys).  DECUDK (i.e., pfx)
+ # takes two parameters, the key and the string.  Translating the key is
+ # straightforward (keys 1-5 are not defined on real terminals, though some
+@@ -2493,12 +2579,17 @@
+ 	hts=\EH, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, 
+ 	use=vt220, use=ecma+color, 
+ 
+-# PuTTY 0.51 (released 14 December 2000)
++# PuTTY 0.55 (released 3 August 2004)
+ # http://www.chiark.greenend.org.uk/~sgtatham/putty/
+ #
++# Comparing with 0.51, vttest is much better (only a few problems with the
++# cursor position reports and wrapping).
++#
++# PuTTY 0.51 (released 14 December 2000)
++#
+ # This emulates vt100 + vt52 (plus a few vt220 features:  ech, SRM, DECTCEM, as
+ # well as SCO and Atari, color palettes from Linux console).  Reading the code,
+-# it is intended to be VT102 plus selected features By default, it sets $TERM
++# it is intended to be VT102 plus selected features.  By default, it sets $TERM
+ # to xterm, which is incorrect, since several features are misimplemented:
+ #
+ #	Alt+key always sends ESC+key, so 'km' capability is removed.
+@@ -2510,39 +2601,48 @@
+ #
+ # Several features such as backspace/delete are optional; this entry documents
+ # the default behavior -TD
+-putty|xterm clone (win32), 
+-	am, bw, ccc, km, mir, msgr, xenl, 
+-	colors#8, cols#80, it#8, lines#24, pairs#64, 
+-	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
+-	bel=^G, blink=\E[5m, bold=\E[1m, civis=\E[?25l, 
+-	clear=\E[H\E[2J, cnorm=\E[?25h, cr=^M, 
++
++putty|PuTTY terminal emulator, 
++	am, bce, bw, ccc, hs, mir, msgr, xenl, xon, 
++	colors#8, it#8, ncv#22, pairs#64, 
++	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
++	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, 
++	clear=\E[H\E[J, cnorm=\E[?25h, cr=^M, 
+ 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
+-	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
+-	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
+-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
+-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, enacs=\E)0, home=\E[H, 
+-	hpa=\E[%i%p1%dG, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, 
+-	ind=^J, 
+-	initc=\E]P%?%p1%{9}%>%t%p1%{10}%-%'a'%+%c%e%p1%d%;%p2%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%p3%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%p4%{255}%&%Pr%gr%{16}%/%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;%gr%{15}%&%Px%?%gx%{9}%>%t%gx%{10}%-%'A'%+%c%e%gx%d%;, 
+-	is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>, 
+-	kbs=\177, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, 
+-	kcuu1=\EOA, kdch1=\E[3~, kf1=\E[11~, kf10=\E[21~, 
+-	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, 
+-	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, 
+-	kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, 
+-	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, 
+-	kf9=\E[20~, kfnd=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, 
+-	kpp=\E[5~, kslt=\E[4~, oc=\E]R, op=\E[39;49m, rc=\E8, 
+-	rev=\E[7m, ri=\EM, rmacs=^O, rmam=\E[?7l, 
+-	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>, 
++	cud=\E[%p1%dB, cud1=\ED, cuf=\E[%p1%dC, cuf1=\E[C, 
++	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM, 
++	dch=\E[%p1%dP, dch1=\E[P, 
++	dispc=%?%p1%{8}%=%t\E%%G\342\227\230\E%%@%e%p1%{10}%=%t\E%%G\342\227\231\E%%@%e%p1%{12}%=%t\E%%G\342\231\0\E%%@%e%p1%{13}%=%t\E%%G\342\231\252\E%%@%e%p1%{14}%=%t\E%%G\342\231\253\E%%@%e%p1%{15}%=%t\E%%G\342\230\274\E%%@%e%p1%{27}%=%t\E%%G\342\206\220\E%%@%e%p1%{155}%=%t\E%%G\340\202\242\E%%@%e%p1%c%;, 
++	dl=\E[%p1%dM, dl1=\E[M, dsl=\E]0;\007, ech=\E[%p1%dX, 
++	ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, 
++	flash=\E[?5h\E[?5l, fsl=^G, home=\E[H, hpa=\E[%i%p1%dG, 
++	ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=^J, 
++	indn=\E[%p1%dS, 
++	initc=\E]P%p1%x%p2%{255}%*%{1000}%/%02x%p3%{255}%*%{1000}%/%02x%p4%{255}%*%{1000}%/%02x, 
++	is2=\E7\E[r\E[m\E[?7h\E[?1;4;6l\E[4l\E8\E>\E]R, 
++	kb2=\E[G, kbs=\177, kcan=^C, kcbt=\E[Z, kcub1=\E[D, 
++	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, 
++	kend=\E[4~, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, 
++	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
++	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, 
++	kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, kf4=\E[14~, 
++	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
++	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
++	kspd=^Z, nel=^M^J, oc=\E]R, op=\E[39;49m, rc=\E8, rev=\E[7m, 
++	ri=\EM, rin=\E[%p1%dT, rmacs=^O, rmam=\E[?7l, 
++	rmcup=\E[2J\E[?47l, rmir=\E[4l, rmpch=\E[10m, 
+ 	rmso=\E[27m, rmul=\E[24m, 
+-	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>, sc=\E7, 
++	rs2=\E<\E["p\E[50;6"p\Ec\E[?3l\E]R\E[?1000l, 
++	s0ds=\E[10m, s1ds=\E[11m, s2ds=\E[12m, sc=\E7, 
+ 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
+-	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
+-	sgr0=\E[m, smacs=^N, smam=\E[?7h, smcup=\E7\E[?47h, 
+-	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, 
+-	tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, 
+-	vpa=\E[%i%p1%dd, 
++	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
++	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E[?47h, 
++	smir=\E[4h, smpch=\E[11m, smso=\E[7m, smul=\E[4m, 
++	tbc=\E[3g, tsl=\E]0;, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?6c, 
++	u9=\E[c, vpa=\E[%i%p1%dd, 
++vt100-putty|Reset Putty to pure vt100, 
++	rs2=\E<\E["p\Ec\E[?3l\E]R\E[40"p\E[61"p\E[50;1;2"p, 
++	use=vt100, 
+ 
+ # This entry is for Tera Term Pro version 2.3, for MS-Windows 95/NT written by
+ # T. Teranishi dated Mar 10, 1998.  It is a free software terminal emulator
+@@ -2840,86 +2940,122 @@
+ 
+ # This version was released in XFree86 4.3.
+ xterm-xf86-v43|xterm terminal emulator (XFree86 4.3 Window System), 
+-	npc, 
+ 	kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, 
+ 	kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, 
+-	kb2=\EOE, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, 
+-	kcuu1=\EOA, kend=\EOF, kent=\EOM, kf1=\EOP, kf10=\E[21~, 
+-	kf11=\E[23~, kf12=\E[24~, kf13=\EO2P, kf14=\EO2Q, 
+-	kf15=\EO2R, kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, 
+-	kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, 
+-	kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, 
+-	kf26=\EO5Q, kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~, 
+-	kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, 
++	kbeg@, 
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
++	use=xterm-xf86-v40, 
++
++# This version was released in XFree86 4.4.
++xterm-xf86-v44|xterm terminal emulator (XFree86 4.4 Window System), 
++	cnorm=\E[?12l\E[?25h, cvvis=\E[?12;25h, indn=\E[%p1%dS, 
++	rin=\E[%p1%dT, use=xterm-xf86-v43, 
++
++# This is the most common alias for xterm-new.
++xterm-xfree86|xterm terminal emulator (XFree86), 
++	use=xterm-new, 
++#	use=xterm-old, 
++
++# This version is current (XFree86 xterm patch #192).
++xterm-new|modern xterm terminal emulator, 
++	npc, 
++	indn=\E[%p1%dS, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, 
++	kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, 
++	kRIT=\E[1;2C, kb2=\EOE, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, 
++	kcuf1=\EOC, kcuu1=\EOA, kend=\EOF, kent=\EOM, khome=\EOH, 
++	kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
++	rin=\E[%p1%dT, use=xterm+pcfkeys, use=xterm-basic, 
++#
++# This fragment describes as much of XFree86 xterm's "pc-style" function
++# keys as will fit into terminfo's 60 function keys.
++# From ctlseqs.ms:
++#    Code     Modifiers
++#  ---------------------------------
++#     2       Shift
++#     3       Alt
++#     4       Shift + Alt
++#     5       Control
++#     6       Shift + Control
++#     7       Alt + Control
++#     8       Shift + Alt + Control
++#  ---------------------------------
++# The meta key may also be used as a modifier in this scheme, adding another
++# bit to the parameter.
++xterm+pcfkeys|fragment for PC-style fkeys, 
++	kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, 
++	kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, kf16=\EO2S, 
++	kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, 
++	kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, 
++	kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P, kf26=\EO5Q, 
++	kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~, kf3=\EOR, 
++	kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, 
+ 	kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, 
+ 	kf36=\E[24;5~, kf37=\EO6P, kf38=\EO6Q, kf39=\EO6R, 
+ 	kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~, 
+ 	kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, 
+-	kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf5=\E[15~, 
+-	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\EOH, 
+-	kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
+-	use=xterm-basic, 
+-
+-# This version is current (XFree86 xterm patch #180).
+-xterm-xfree86|xterm-new|xterm terminal emulator (XFree86 4.4 Window System), 
+-	cnorm=\E[?12l\E[?25h, cvvis=\E[?12;25h, indn=\E[%p1%dS, 
+-	rin=\E[%p1%dT, use=xterm-xf86-v43, 
++	kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\EO3P, 
++	kf5=\E[15~, kf50=\EO3Q, kf51=\EO3R, kf52=\EO3S, 
++	kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, 
++	kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, 
++	kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\EO4P, 
++	kf62=\EO4Q, kf63=\EO4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
+ #
+ # This chunk is used for building the VT220/Sun/PC keyboard variants.
+ xterm-basic|xterm terminal emulator - common (XFree86), 
+-	am, bce, km, mc5i, mir, msgr, xenl, 
++	OTbs, am, bce, km, mc5i, mir, msgr, xenl, AX, 
+ 	colors#8, cols#80, it#8, lines#24, pairs#64, 
+ 	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
+ 	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, 
+-	clear=\E[H\E[2J, cnorm=\E[?25h, cr=^M, 
++	clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M, 
+ 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
+ 	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
+ 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
+-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
+-	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, 
++	cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, 
++	dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, 
+ 	flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG, 
+ 	ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, 
+ 	ind=^J, invis=\E[8m, is2=\E[!p\E[?3;4l\E[4l\E>, kbs=^H, 
+ 	kdch1=\E[3~, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, meml=\El, 
+-	memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, 
+-	rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, 
+-	rmso=\E[27m, rmul=\E[24m, rs1=\Ec, 
++	memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, 
++	rmacs=\E(B, rmam=\E[?7l, rmcup=\E[?1049l, rmir=\E[4l, 
++	rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs1=\Ec, 
+ 	rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[4%p1%dm, 
+ 	setaf=\E[3%p1%dm, 
+ 	setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, 
+ 	setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, 
+-	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
+-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E[?1049h, 
++	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m, 
++	sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smcup=\E[?1049h, 
+ 	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, 
+ 	tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, 
+ 	vpa=\E[%i%p1%dd, 
+ 
+ # From: David J. MacKenzie <djm@va.pubnix.com>, 14 Nov 1997
++# In retrospect, something like xterm-r6 was intended here -TD
+ xterm-xi|xterm on XI Graphics Accelerated X under BSD/OS 3.1, 
+ 	rmso=\E[m, rmul=\E[m, use=xterm-xf86-v33, 
+ 
+ # This is one of the variants of XFree86 3.3 xterm, updated for 4.0 (T.Dickey)
+ xterm-16color|xterm with 16 colors like aixterm, 
+-	ncv#32, use=ibm+16color, use=xterm-xfree86, 
++	ncv#32, use=ibm+16color, use=xterm-new, 
+ 
+ # These variants of XFree86 3.9.16 xterm are built as a configure option.
+ xterm-256color|xterm with 256 colors, 
+ 	ccc, 
+-	colors#256, ncv#32, pairs#256, 
++	colors#256, pairs#32767, 
+ 	initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, 
+ 	setab=\E[48;5;%p1%dm, setaf=\E[38;5;%p1%dm, 
+ 	setb=\E[48;5;%p1%dm, setf=\E[38;5;%p1%dm, 
+-	use=xterm-xfree86, 
++	use=xterm-new, 
+ xterm-88color|xterm with 88 colors, 
+-	colors#88, pairs#88, use=xterm-256color, 
++	colors#88, pairs#7744, use=xterm-256color, 
+ 
+ # These two are used to demonstrate the any-event mouse support, i.e., by
+ # using an extended name "XM" which tells ncurses to put the terminal into
+ # a special mode when initializing the xterm mouse.
+ xterm-1002|testing xterm-mouse, 
+-	XM=\E[?1002%?%p1%{1}%=%th%el%;, use=xterm-xfree86, 
++	XM=\E[?1002%?%p1%{1}%=%th%el%;, use=xterm-new, 
+ xterm-1003|testing xterm-mouse, 
+-	XM=\E[?1003%?%p1%{1}%=%th%el%;, use=xterm-xfree86, 
++	XM=\E[?1003%?%p1%{1}%=%th%el%;, use=xterm-new, 
+ 
+ # This is another variant, for XFree86 4.0 xterm (T.Dickey)
+ # This is an 8-bit version of xterm, which emulates DEC vt220 with ANSI color.
+@@ -2931,21 +3067,21 @@
+ #	CSI	\E [	\233
+ #
+ xterm-8bit|xterm terminal emulator 8-bit controls (X Window System), 
+-	OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, 
++	OTbs, am, bce, km, mc5i, mir, msgr, npc, xenl, AX, 
+ 	colors#8, cols#80, it#8, lines#24, pairs#64, 
+ 	acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
+ 	bel=^G, blink=\2335m, bold=\2331m, cbt=\233Z, 
+-	civis=\233?25l, clear=\233H\2332J, cnorm=\233?25h, cr=^M, 
+-	csr=\233%i%p1%d;%p2%dr, cub=\233%p1%dD, cub1=^H, 
+-	cud=\233%p1%dB, cud1=^J, cuf=\233%p1%dC, cuf1=\233C, 
+-	cup=\233%i%p1%d;%p2%dH, cuu=\233%p1%dA, cuu1=\233A, 
++	civis=\233?25l, clear=\233H\2332J, 
++	cnorm=\233?25l\233?25h, cr=^M, csr=\233%i%p1%d;%p2%dr, 
++	cub=\233%p1%dD, cub1=^H, cud=\233%p1%dB, cud1=^J, 
++	cuf=\233%p1%dC, cuf1=\233C, cup=\233%i%p1%d;%p2%dH, 
++	cuu=\233%p1%dA, cuu1=\233A, cvvis=\233?12;25h, 
+ 	dch=\233%p1%dP, dch1=\233P, dl=\233%p1%dM, dl1=\233M, 
+ 	ech=\233%p1%dX, ed=\233J, el=\233K, el1=\2331K, 
+-	enacs=\E(B\E)0, flash=\233?5h$<100/>\233?5l, 
+-	home=\233H, hpa=\233%i%p1%dG, ht=^I, hts=\210, 
+-	ich=\233%p1%d@, il=\233%p1%dL, il1=\233L, ind=^J, 
+-	invis=\2338m, 
+-	is2=\E7\E G\233r\233m\233?7h\233?1;3;4;6l\2334l\E8\E>, 
++	flash=\233?5h$<100/>\233?5l, home=\233H, 
++	hpa=\233%i%p1%dG, ht=^I, hts=\210, ich=\233%p1%d@, 
++	il=\233%p1%dL, il1=\233L, ind=^J, invis=\2338m, 
++	is2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8, 
+ 	ka1=\217w, ka3=\217u, kb2=\217y, kbeg=\217E, kbs=^H, 
+ 	kc1=\217q, kc3=\217s, kcbt=\233Z, kcub1=\217D, kcud1=\217B, 
+ 	kcuf1=\217C, kcuu1=\217A, kdch1=\2333~, kend=\2334~, 
+@@ -2957,18 +3093,18 @@
+ 	kf9=\23320~, khome=\2331~, kich1=\2332~, kmous=\233M, 
+ 	knp=\2336~, kpp=\2335~, mc0=\233i, mc4=\2334i, mc5=\2335i, 
+ 	meml=\El, memu=\Em, op=\23339;49m, rc=\E8, rev=\2337m, 
+-	ri=\215, rmacs=^O, rmam=\233?7l, rmcup=\233?1049l, 
++	ri=\215, rmacs=\E(B, rmam=\233?7l, rmcup=\233?1049l, 
+ 	rmir=\2334l, rmkx=\233?1l\E>, rmso=\23327m, rmul=\23324m, 
+ 	rs1=\Ec, 
+-	rs2=\E[62"p\E G\E7\233r\E8\233m\233?7h\233?1;3;4;6l\2334l\E>, 
++	rs2=\E[62"p\E G\233m\233?7h\E>\E7\233?1;3;4;6l\2334l\233r\E8, 
+ 	sc=\E7, setab=\2334%p1%dm, setaf=\2333%p1%dm, 
+ 	setb=\2334%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, 
+ 	setf=\2333%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m, 
+-	sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
+-	sgr0=\233m^O, smacs=^N, smam=\233?7h, smcup=\233?1049h, 
+-	smir=\2334h, smkx=\233?1h\E=, smso=\2337m, smul=\2334m, 
+-	tbc=\2333g, u6=\233[%i%d;%dR, u7=\E[6n, u8=\233[?1;2c, 
+-	u9=\E[c, vpa=\233%i%p1%dd, 
++	sgr=\2330%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;, 
++	sgr0=\233m\E(B, smacs=\E(0, smam=\233?7h, 
++	smcup=\233?1049h, smir=\2334h, smkx=\233?1h\E=, 
++	smso=\2337m, smul=\2334m, tbc=\2333g, u6=\233[%i%d;%dR, 
++	u7=\E[6n, u8=\233[?1;2c, u9=\E[c, vpa=\233%i%p1%dd, 
+ 
+ xterm-hp|XFree86 xterm with hpterm function keys, 
+ 	kclr=\EJ, kcub1=\ED, kcud1=\EB, kcuf1=\EC, kcuu1=\EA, 
+@@ -2987,7 +3123,7 @@
+ 	kf6=\E[R, kf7=\E[S, kf8=\E[T, kf9=\E[U, khome=\E[H, 
+ 	kich1=\E[L, knp=\E[G, kpp=\E[I, use=xterm-basic, 
+ 
+-# The xterm-xfree86 description has all of the features, but is not completely
++# The xterm-new description has all of the features, but is not completely
+ # compatible with vt220.  If you are using a Sun or PC keyboard, set the
+ # sunKeyboard resource to true:
+ #	+ maps the editing keypad
+@@ -2997,14 +3133,13 @@
+ #	+ uses DEC-style control sequences for the application keypad.
+ #	  
+ xterm-vt220|XFree86 xterm emulating vt220, 
+-	kbeg=\EOu, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, 
+-	kcuu1=\EOA, kend=\E[4~, kf10=\E[21~, kf11=\E[23~, 
+-	kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, 
+-	kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, 
+-	kf20=\E[34~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, 
+-	kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~, 
+-	kmous=\E[M, knp=\E[6~, kpp=\E[5~, use=xterm-basic, 
+-	use=vt220+keypad, 
++	kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
++	kend=\E[4~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, 
++	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, 
++	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf20=\E[34~, 
++	kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, 
++	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
++	use=xterm-basic, use=vt220+keypad, 
+ 
+ xterm-vt52|XFree86 xterm emulating dec vt52, 
+ 	cols#80, it#8, lines#24, 
+@@ -3023,8 +3158,7 @@
+ 
+ # This is xterm for ncurses.
+ xterm|xterm terminal emulator (X Window System), 
+-	use=xterm-r6, 
+-#	use=xterm-xfree86, 
++	use=xterm-new, 
+ 
+ # These entries allow access to the X titlebar and icon name as a status line. 
+ # Note that twm (and possibly window managers descended from it such as tvtwm, 
+@@ -3054,8 +3188,10 @@
+ 	eslok, hs, 
+ 	acsc=++\,\,--..00ii``aaffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
+ 	csr=\E[%i%p1%d;%p2%dr, dsl=\E[?H, enacs=, fsl=\E[?F, 
+-	kmous=\E[M, rc=\E8, rmacs=\E(B, sc=\E7, smacs=\E(0, 
+-	tsl=\E[?E\E[?%i%dT, use=xterm-r6, use=ecma+color, 
++	kmous=\E[M, rc=\E8, rmacs=\E(B, rmam=\E[?7l, sc=\E7, 
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, 
++	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, 
++	tsl=\E[?E\E[?%i%p1%dT, use=xterm-r6, use=ecma+color, 
+ kterm-color|kterm-co|kterm with ANSI colors, 
+ 	ncv@, use=kterm, use=ecma+color, 
+ # See the note on ICH/ICH1 VERSUS RMIR/SMIR near the end of file
+@@ -3150,7 +3286,7 @@
+ # more of its bugs using vttest.
+ #
+ # However, note that bce and msgr are broken in this release.  Tabs (tbc and
+-# hts) are broken as well.  Sometimes flash (as in xterm-xfree86) works.
++# hts) are broken as well.  Sometimes flash (as in xterm-new) works.
+ #
+ # kf1 and kf10 are not tested since they're assigned (hardcoded?) to menu
+ # operations.  Shift-tab generates a distinct sequence so it can be argued
+@@ -3164,9 +3300,13 @@
+ #
+ # bce and msgr are repaired.
+ gnome-rh90|GNOME Terminal, 
+-	bce, msgr, use=gnome-rh80, 
++	bce, msgr, 
++	hpa=\E[%i%p1%dG, kDC=\E[3;2~, kLFT=\EO2D, kRIT=\EO2C, 
++	kb2=\E[E, kcbt=\E[Z, kend=\EOF, khome=\EOH, tbc=\E[3g, 
++	vpa=\E[%i%p1%dd, use=xterm+pcfkeys, use=gnome-rh80, 
+ 
+ gnome|GNOME Terminal, 
++	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h, 
+ 	use=gnome-rh90, 
+ 
+ # This is kvt 0-18.7, shipped with Redhat 6.0 (though whether it supports bce
+@@ -3197,14 +3337,21 @@
+ #    vt220, which is doubly incorrect because it does not implement vt220
+ #    control sequences except for a few special cases).  Treat it as a
+ #    mildly-broken vt102.
++#
++# Update for konsole 1.3.2:
++#    The 1049 private mode works (but see the other xterm screens in vttest).
++#    Primary Device Attributes now returns the code for a vt100 with advanced
++#    video option.  Perhaps that's intended to be a "mildly-broken vt102".
+ konsole-base|KDE console window, 
+ 	bce, km@, npc, 
+ 	bel@, blink=\E[5m, civis=\E[?25l, cnorm=\E[?25h, 
+ 	ech=\E[%p1%dX, flash=\E[?5h$<100/>\E[?5l, 
+-	hpa=\E[%i%p1%dG, kbs@, kdch1@, kend@, kf1@, kf10@, kf11@, kf12@, 
+-	kf13@, kf14@, kf15@, kf16@, kf17@, kf18@, kf19@, kf2@, kf20@, kf3@, 
+-	kf4@, kf5@, kf6@, kf7@, kf8@, kf9@, kfnd@, khome@, kslt@, 
+-	rmam=\E[?7l, rmso=\E[27m, rmul=\E[24m, 
++	hpa=\E[%i%p1%dG, indn=\E[%p1%dS, kbs=\177, kdch1@, 
++	kend=\E[4~, kf1@, kf10@, kf11@, kf12@, kf13@, kf14@, kf15@, kf16@, 
++	kf17@, kf18@, kf19@, kf2@, kf20@, kf3@, kf4@, kf5@, kf6@, kf7@, kf8@, 
++	kf9@, kfnd@, khome=\E[1~, kslt@, rin=\E[%p1%dT, rmam=\E[?7l, 
++	rmso=\E[27m, rmul=\E[24m, 
++	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h, 
+ 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
+ 	smam=\E[?7h, vpa=\E[%i%p1%dd, use=ecma+color, 
+ 	use=xterm-r6, 
+@@ -3221,7 +3368,10 @@
+ # The value for kbs reflects local customization rather than the settings used
+ # for XFree86 xterm.
+ konsole-xf4x|KDE console window with keyboard for XFree86 4.x xterm, 
+-	kbs=^H, kend=\EOF, kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, 
++	kend=\EOF, kf1=\EOP, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R, 
++	kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, 
++	kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, 
++	kf23=\E[23;2~, kf24=\E[24;2~, kf3=\EOR, kf4=\EOS, 
+ 	khome=\EOH, use=konsole-vt100, 
+ # KDE's "vt100" keyboard has no relationship to any terminal that DEC made, but
+ # it is still useful for deriving the other entries.
+@@ -3237,7 +3387,47 @@
+ 	ncv#32, use=ibm+16color, use=konsole, 
+ # make a default entry for konsole
+ konsole|KDE console window, 
+-	use=konsole-linux, 
++	use=konsole-xf4x, 
++
++# Based on mlterm 2.8.0's mlterm.ti, with corrections/additions from reading
++# the source code and running tack -TD
++#
++# This is nominally a vt102 emulator, with features borrowed from rxvt and
++# xterm.
++#
++# There are some problems with vttest:
++#	save/restore cursor doesn't restore character
++#	test of character sets leaves it in line-drawing mode.
++mlterm|multi lingual terminal emulator, 
++	am, eslok, km, mc5i, mir, msgr, npc, xenl, 
++	colors#8, cols#80, it#8, lines#24, pairs#64, 
++	acsc=00``aaffgghhjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, 
++	bel=^G, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[2J, cr=^M, 
++	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
++	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
++	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
++	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
++	ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K, enacs=, 
++	home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, 
++	ich1=\E[@, il=\E[%p1%dL, il1=\E[L, ind=^J, indn=\E[%p1%dS, 
++	is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>, 
++	kbs=\177, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, 
++	kdch1=\E[3~, kend=\EOF, kent=\EOM, kf1=\E[11~, kf10=\E[21~, 
++	kf11=\E[23~, kf12=\E[24~, kf2=\E[12~, kf3=\E[13~, 
++	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, 
++	kf9=\E[20~, kfnd=\E[1~, khome=\EOH, kich1=\E[2~, 
++	kmous=\E[M, knp=\E[6~, kpp=\E[5~, kslt=\E[4~, mc0=\E[i, 
++	nel=\EE, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, 
++	rin=\E[%p1%dT, rmacs=\E(B, rmam=\E[?7l, 
++	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>, 
++	rmso=\E[m, rmul=\E[m, 
++	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l, 
++	sc=\E7, setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, 
++	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smcup=\E7\E[?47h, 
++	smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, 
++	tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c, 
++	vpa=\E[%i%p1%dd, 
+ 
+ # From: Thomas Dickey <dickey@clark.net> 04 Oct 1997
+ # Updated: Oezguer Kesim <kesim@math.fu-berlin.de> 02 Nov 1997
+@@ -3257,6 +3447,8 @@
+ # rxvt is normally configured to look for "xterm" or "xterm-color" as $TERM.
+ # Since rxvt is not really compatible with xterm, it should be configured as
+ # "rxvt" (monochrome) and "rxvt-color". 
++#
++# removed dch/dch1 because they are inconsistent with bce/ech -TD
+ rxvt-basic|rxvt terminal base (X Window System), 
+ 	OTbs, am, bce, eo, km, mir, msgr, xenl, xon, 
+ 	cols#80, it#8, lines#24, 
+@@ -3266,33 +3458,110 @@
+ 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
+ 	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
+ 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
+-	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, 
+-	el=\E[K, el1=\E[1K, enacs=\E(B\E)0, flash=\E[?5h\E[?5l, 
+-	home=\E[H, ht=^I, hts=\EH, ich=\E[%p1%d@, ich1=\E[@, 
+-	il=\E[%p1%dL, il1=\E[L, ind=^J, is1=\E[?47l\E=\E[?1l, 
+-	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, 
+-	kDC=\E[3$, kEND=\E[8$, kHOM=\E[7$, kLFT=\E[d, kNXT=\E[6$, 
+-	kPRV=\E[5$, kRIT=\E[c, kbs=^H, kcbt=\E[Z, kcub1=\E[D, 
+-	kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A, kdch1=\E[3~, 
+-	kel=\E[8\^, kend=\E[8~, kf1=\E[11~, kf10=\E[21~, 
+-	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, 
+-	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, 
+-	kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, 
+-	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, 
+-	kf9=\E[20~, kfnd=\E[1~, khome=\E[7~, kich1=\E[2~, 
+-	kmous=\E[M, knp=\E[6~, kpp=\E[5~, kslt=\E[4~, rc=\E8, 
+-	rev=\E[7m, ri=\EM, rmacs=^O, rmcup=\E[2J\E[?47l\E8, 
+-	rmir=\E[4l, rmkx=\E>, rmso=\E[27m, rmul=\E[24m, 
++	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K, 
++	enacs=\E(B\E)0, flash=\E[?5h\E[?5l, home=\E[H, ht=^I, 
++	hts=\EH, ich=\E[%p1%d@, ich1=\E[@, il=\E[%p1%dL, il1=\E[L, 
++	ind=^J, is1=\E[?47l\E=\E[?1l, 
++	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, kbs=^H, 
++	kcbt=\E[Z, kmous=\E[M, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, 
++	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E>, rmso=\E[27m, 
++	rmul=\E[24m, 
+ 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, 
+-	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>, 
+-	s0ds=\E(B, s1ds=\E(0, sc=\E7, sgr0=\E[0m\017, smacs=^N, 
+-	smcup=\E7\E[?47h, smir=\E[4h, smkx=\E=, smso=\E[7m, 
+-	smul=\E[4m, tbc=\E[3g, use=vt220+keypad, 
++	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h, 
++	s0ds=\E(B, s1ds=\E(0, sc=\E7, 
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
++	sgr0=\E[0m\017, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h, 
++	smkx=\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, 
++	use=vt220+keypad, use=rxvt+pcfkeys, 
++# Key Codes from rxvt reference:
++# 
++# Note: Shift + F1-F10 generates F11-F20
++# 
++# For the keypad, use Shift to temporarily override Application-Keypad
++# setting use Num_Lock to toggle Application-Keypad setting if Num_Lock
++# is off, escape sequences toggle Application-Keypad setting.
++# Also note that values of Home, End, Delete may have been compiled
++# differently on your system.
++# 
++#                   Normal       Shift        Control      Ctrl+Shift
++#  Tab              ^I           ESC [ Z      ^I           ESC [ Z
++#  BackSpace        ^H           ^?           ^?           ^?
++#  Find             ESC [ 1 ~    ESC [ 1 $    ESC [ 1 ^    ESC [ 1 @
++#  Insert           ESC [ 2 ~    paste        ESC [ 2 ^    ESC [ 2 @
++#  Execute          ESC [ 3 ~    ESC [ 3 $    ESC [ 3 ^    ESC [ 3 @
++#  Select           ESC [ 4 ~    ESC [ 4 $    ESC [ 4 ^    ESC [ 4 @
++#  Prior            ESC [ 5 ~    scroll-up    ESC [ 5 ^    ESC [ 5 @
++#  Next             ESC [ 6 ~    scroll-down  ESC [ 6 ^    ESC [ 6 @
++#  Home             ESC [ 7 ~    ESC [ 7 $    ESC [ 7 ^    ESC [ 7 @
++#  End              ESC [ 8 ~    ESC [ 8 $    ESC [ 8 ^    ESC [ 8 @
++#  Delete           ESC [ 3 ~    ESC [ 3 $    ESC [ 3 ^    ESC [ 3 @
++#  F1               ESC [ 11 ~   ESC [ 23 ~   ESC [ 11 ^   ESC [ 23 ^
++#  F2               ESC [ 12 ~   ESC [ 24 ~   ESC [ 12 ^   ESC [ 24 ^
++#  F3               ESC [ 13 ~   ESC [ 25 ~   ESC [ 13 ^   ESC [ 25 ^
++#  F4               ESC [ 14 ~   ESC [ 26 ~   ESC [ 14 ^   ESC [ 26 ^
++#  F5               ESC [ 15 ~   ESC [ 28 ~   ESC [ 15 ^   ESC [ 28 ^
++#  F6               ESC [ 17 ~   ESC [ 29 ~   ESC [ 17 ^   ESC [ 29 ^
++#  F7               ESC [ 18 ~   ESC [ 31 ~   ESC [ 18 ^   ESC [ 31 ^
++#  F8               ESC [ 19 ~   ESC [ 32 ~   ESC [ 19 ^   ESC [ 32 ^
++#  F9               ESC [ 20 ~   ESC [ 33 ~   ESC [ 20 ^   ESC [ 33 ^
++#  F10              ESC [ 21 ~   ESC [ 34 ~   ESC [ 21 ^   ESC [ 34 ^
++#  F11              ESC [ 23 ~   ESC [ 23 $   ESC [ 23 ^   ESC [ 23 @
++#  F12              ESC [ 24 ~   ESC [ 24 $   ESC [ 24 ^   ESC [ 24 @
++#  F13              ESC [ 25 ~   ESC [ 25 $   ESC [ 25 ^   ESC [ 25 @
++#  F14              ESC [ 26 ~   ESC [ 26 $   ESC [ 26 ^   ESC [ 26 @
++#  F15 (Help)       ESC [ 28 ~   ESC [ 28 $   ESC [ 28 ^   ESC [ 28 @
++#  F16 (Menu)       ESC [ 29 ~   ESC [ 29 $   ESC [ 29 ^   ESC [ 29 @
++#  F17              ESC [ 31 ~   ESC [ 31 $   ESC [ 31 ^   ESC [ 31 @
++#  F18              ESC [ 32 ~   ESC [ 32 $   ESC [ 32 ^   ESC [ 32 @
++#  F19              ESC [ 33 ~   ESC [ 33 $   ESC [ 33 ^   ESC [ 33 @
++#  F20              ESC [ 34 ~   ESC [ 34 $   ESC [ 34 ^   ESC [ 34 @
++#                                                          Application
++#  Up               ESC [ A      ESC [ a      ESC O a      ESC O A
++#  Down             ESC [ B      ESC [ b      ESC O b      ESC O B
++#  Right            ESC [ C      ESC [ c      ESC O c      ESC O C
++#  Left             ESC [ D      ESC [ d      ESC O d      ESC O D
++#  KP_Enter         ^M                                     ESC O M
++#  KP_F1            ESC O P                                ESC O P
++#  KP_F2            ESC O Q                                ESC O Q
++#  KP_F3            ESC O R                                ESC O R
++#  KP_F4            ESC O S                                ESC O S
++#  XK_KP_Multiply   *                                      ESC O j
++#  XK_KP_Add        +                                      ESC O k
++#  XK_KP_Separator  ,                                      ESC O l
++#  XK_KP_Subtract   -                                      ESC O m
++#  XK_KP_Decimal    .                                      ESC O n
++#  XK_KP_Divide     /                                      ESC O o
++#  XK_KP_0          0                                      ESC O p
++#  XK_KP_1          1                                      ESC O q
++#  XK_KP_2          2                                      ESC O r
++#  XK_KP_3          3                                      ESC O s
++#  XK_KP_4          4                                      ESC O t
++#  XK_KP_5          5                                      ESC O u
++#  XK_KP_6          6                                      ESC O v
++#  XK_KP_7          7                                      ESC O w
++#  XK_KP_8          8                                      ESC O x
++#  XK_KP_9          9                                      ESC O y
++rxvt+pcfkeys|fragment for PC-style fkeys, 
++	kDC=\E[3$, kEND=\E[8$, kHOM=\E[7$, kLFT=\E[d, kNXT=\E[6$, 
++	kPRV=\E[5$, kRIT=\E[c, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, 
++	kcuu1=\E[A, kdch1=\E[3~, kel=\E[8\^, kend=\E[8~, 
++	kf1=\E[11~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, 
++	kf13=\E[25~, kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, 
++	kf17=\E[31~, kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, 
++	kf20=\E[34~, kf21=\E[23$, kf22=\E[24$, kf23=\E[11\^, 
++	kf24=\E[12\^, kf25=\E[13\^, kf26=\E[14\^, kf27=\E[15\^, 
++	kf28=\E[17\^, kf29=\E[18\^, kf3=\E[13~, kf30=\E[19\^, 
++	kf31=\E[20\^, kf32=\E[21\^, kf33=\E[23\^, kf34=\E[24\^, 
++	kf35=\E[25\^, kf36=\E[26\^, kf37=\E[28\^, kf38=\E[29\^, 
++	kf39=\E[31\^, kf4=\E[14~, kf40=\E[32\^, kf41=\E[33\^, 
++	kf42=\E[34\^, kf43=\E[23@, kf44=\E[24@, kf5=\E[15~, 
++	kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, 
++	khome=\E[7~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~, kslt=\E[4~, 
++	kDN=\E[b, kUP=\E[a, 
+ rxvt|rxvt terminal emulator (X Window System), 
+ 	ncv@, 
+-	cvvis=\E[?25h, hpa=\E[%i%p1%dG, kf0=\E[21~, 
+-	sgr0=\E[m\017, vpa=\E[%i%p1%dd, use=rxvt-basic, 
+-	use=ecma+color, 
++	hpa=\E[%i%p1%dG, kf0=\E[21~, sgr0=\E[m\017, 
++	vpa=\E[%i%p1%dd, use=rxvt-basic, use=ecma+color, 
+ rxvt-color|rxvt terminal emulator (X Window System), 
+ 	use=rxvt, 
+ rxvt-xpm|rxvt terminal emulator (X Window System), 
+@@ -3342,7 +3611,7 @@
+ 	rmacs=^O, rmam=\E[?7l, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, 
+ 	rmkx=, rmso=\E[27m, rmul=\E[24m, 
+ 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, 
+-	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>, 
++	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h, 
+ 	sc=\E7, 
+ 	sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
+ 	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E7\E[?47h, 
+@@ -3439,30 +3708,66 @@
+ 	cols#80, lines#24, use=xterm-sun, 
+ 
+ # This is for the extensible terminal emulator on the X11R6 contrib tape.
++# It corresponds to emu's internal emulation:
++#	emu -term emu
++# emu's default sets TERM to "xterm", but that doesn't work well -TD
++# fixes: remove bogus rmacs/smacs, change oc to op, add bce, am -TD
++# fixes: add civis, cnorm, sgr -TD
+ emu|emu native mode, 
+-	mir, msgr, xon, 
++	am, bce, mir, msgr, xon, 
+ 	colors#15, cols#80, it#8, lines#24, pairs#64, vt#200, 
+ 	acsc=61a\202f\260g2j\213k\214l\215m\216n\217o\220q\222s\224t\225u\226v\227w\230x\231~\244, 
+-	bel=^G, blink=\ES\EW, bold=\ES\EU, civis=\EZ, 
+-	clear=\EP\EE0;0;, cnorm=\Ea, cr=^M, csr=\Ek%p1%d;%p2%d;, 
+-	cub=\Eq-%p1%d;, cub1=^H, cud=\Ep%p1%d;, cud1=\EB, 
+-	cuf=\Eq%p1%d;, cuf1=\ED, cup=\EE%p1%d;%p2%d;, 
+-	cuu=\Ep-%p1%d;, cuu1=\EA, dch=\EI%p1%d;, dch1=\EI1;, 
+-	dl=\ER%p1%d;, dl1=\ER1;, ech=\Ej%p1%d;, ed=\EN, el=\EK, 
+-	el1=\EL, enacs=\0, home=\EE0;0;, ht=^I, hts=\Eh, 
+-	il=\EQ%p1%d;, il1=\EQ1;, ind=\EG, is2=\ES\Er0;\Es0;, 
+-	kbs=^H, kcub1=\EC, kcud1=\EB, kcuf1=\ED, kcuu1=\EA, 
+-	kdch1=\177, kent=^M, kf0=\EF00, kf1=\EF01, kf10=\EF10, 
+-	kf11=\EF11, kf12=\EF12, kf13=\EF13, kf14=\EF14, kf15=\EF15, 
+-	kf16=\EF16, kf17=\EF17, kf18=\EF18, kf19=\EF19, kf2=\EF02, 
+-	kf20=\EF20, kf3=\EF03, kf4=\EF04, kf5=\EF05, kf6=\EF06, 
+-	kf7=\EF07, kf8=\EF08, kf9=\EF09, kfnd=\Efind, kich1=\Eins, 
+-	knp=\Enext, kpp=\Eprior, kslt=\Esel, oc=\Es0;\Er0;, 
+-	rev=\ES\ET, ri=\EF, rmacs=\0, rmir=\EX, rmso=\ES, rmul=\ES, 
++	bel=^G, blink=\EW, bold=\EU, civis=\EZ, clear=\EP\EE0;0;, 
++	cnorm=\Ea, cr=^M, csr=\Ek%p1%d;%p2%d;, cub=\Eq-%p1%d;, 
++	cub1=^H, cud=\Ep%p1%d;, cud1=\EB, cuf=\Eq%p1%d;, cuf1=\ED, 
++	cup=\EE%p1%d;%p2%d;, cuu=\Ep-%p1%d;, cuu1=\EA, 
++	dch=\EI%p1%d;, dch1=\EI1;, dl=\ER%p1%d;, dl1=\ER1;, 
++	ech=\Ej%p1%d;, ed=\EN, el=\EK, el1=\EL, home=\EE0;0;, ht=^I, 
++	hts=\Eh, il=\EQ%p1%d;, il1=\EQ1;, ind=\EG, 
++	is2=\ES\Er0;\Es0;, kbs=^H, kcub1=\EC, kcud1=\EB, kcuf1=\ED, 
++	kcuu1=\EA, kdch1=\177, kent=^M, kf0=\EF00, kf1=\EF01, 
++	kf10=\EF10, kf11=\EF11, kf12=\EF12, kf13=\EF13, kf14=\EF14, 
++	kf15=\EF15, kf16=\EF16, kf17=\EF17, kf18=\EF18, kf19=\EF19, 
++	kf2=\EF02, kf20=\EF20, kf3=\EF03, kf4=\EF04, kf5=\EF05, 
++	kf6=\EF06, kf7=\EF07, kf8=\EF08, kf9=\EF09, kfnd=\Efind, 
++	kich1=\Eins, knp=\Enext, kpp=\Eprior, kslt=\Esel, 
++	op=\Es0;\Er0;, rev=\ET, ri=\EF, rmir=\EX, rmso=\ES, rmul=\ES, 
+ 	rs2=\ES\Es0;\Er0;, setab=\Es%i%p1%d;, 
+-	setaf=\Er%i%p1%d;, sgr0=\ES, smacs=\0, smir=\EY, 
+-	smso=\ES\ET, smul=\ES\EV, tbc=\Ej, 
+-
++	setaf=\Er%i%p1%d;, 
++	sgr=\ES%?%p1%t\ET%;%?%p2%t\EV%;%?%p3%t\ET%;%?%p4%t\EW%;%?%p6%t\EU%;, 
++	sgr0=\ES, smir=\EY, smso=\ET, smul=\EV, tbc=\Ej, 
++
++# vt220 Terminfo entry for the Emu emulation, corresponds to
++#	emu -term vt220
++# with NumLock set (to make the keypad transmit kf0-kf9).
++# fixes: add am, xenl, corrected sgr0 -TD
++emu-220|Emu-220 (vt200-7bit mode), 
++	am, xenl, xon, 
++	cols#80, it#8, lines#24, vt#200, 
++	acsc=aaffggjjkkllmmnnooqqssttuuvvwwxx~~, bel=^G, 
++	blink=\E[0;5m, bold=\E[0;1m, civis=\E[?25l, 
++	clear=\E[2J\E[H, cnorm=\E[?25h, cr=^M, 
++	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[1D, 
++	cud=\E[%p1%dB, cud1=\E[1B, cuf=\E[%p1%dC, cuf1=\E[1C, 
++	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[1A, 
++	dch=\E[%p1%dP, dch1=\E[1P, dl=\E[%p1%dM, dl1=\E[1M, 
++	ed=\E[0J, el=\E[0K, el1=\E[1K, enacs=\E)0, home=\E[H, ht=^I, 
++	hts=\EH, if=/usr/share/tabset/vt300, il=\E[%p1%dL, 
++	il1=\E[1L, ind=\ED, is2=\E>\E[?1l\E[?3l\E[4l\E[?7h, 
++	kbs=^H, kcmd=\E[29~, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, 
++	kcuu1=\E[A, kdch1=\E[3~, kent=\EOM, kf0=\EOp, kf1=\EOq, 
++	kf10=\EOl, kf11=\EOm, kf12=\EOn, kf13=\EOP, kf14=\EOQ, 
++	kf15=\EOR, kf16=\EOS, kf2=\EOr, kf26=\E[17~, kf27=\E[18~, 
++	kf28=\E[19~, kf29=\E[20~, kf3=\EOs, kf30=\E[21~, 
++	kf34=\E[26~, kf37=\E[31~, kf38=\E[32~, kf39=\E[33~, 
++	kf4=\EOt, kf40=\E[34~, kf5=\EOu, kf6=\EOv, kf7=\EOw, 
++	kf8=\EOx, kf9=\EOy, kfnd=\E[1~, khlp=\E[28~, kich1=\E[2~, 
++	knp=\E[6~, kpp=\E[5~, kslt=\E[4~, rc=\E8, rev=\E[0;7m, 
++	ri=\EM, rmacs=^O, rmcup=\E>, rmkx=\E>, rmso=\E[m, rmul=\E[m, 
++	rs2=\E[4l\E[34l\E[?1l\E[?3l\E[?5l\E[?7h, sc=\E7, 
++	sgr=\E[0%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p6%t;1%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
++	sgr0=\E[m, smacs=^N, smcup=\E[?1l\E=, smkx=\E=, 
++	smso=\E[0;7m, smul=\E[0;4m, tbc=\E[3g, 
+ # A commercial product, Reportedly a version of Xterm with an OPEN LOOK UI,
+ # print interface, ANSI X3.64 colour escape sequences, etc.  Newsgroup postings
+ # indicate that it emulates more than one terminal, but incompletely.
+@@ -3515,8 +3820,10 @@
+ 	il=\E[%p1%dL, il1=\E[L, ind=\E[S, indn=\E[%p1%dS, 
+ 	invis=\E[8m, is2=\E)0\017, kbs=^H, nel=\EE, rev=\E[7m, 
+ 	ri=\E[T, rin=\E[%p1%dT, rmacs=^O, rmir=\E[4l, rmso=\E[27m, 
+-	rmul=\E[24m, sgr0=\E[m, smacs=^N, smir=\E[4h, smso=\E[7m, 
+-	smul=\E[4m, vpa=\E[%i%p1%dd, 
++	rmul=\E[24m, 
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p7%t;8%;m%?%p9%t\016%e\017%;, 
++	sgr0=\E[m, smacs=^N, smir=\E[4h, smso=\E[7m, smul=\E[4m, 
++	vpa=\E[%i%p1%dd, 
+ # mterm normally sets $TERM to "mterm"
+ mterm|mouse-sun|Der Mouse term, 
+ 	am, bw, mir, 
+@@ -3526,6 +3833,8 @@
+ 	home=^P, ht=^I, il1=^A, ind=^U, kbs=^H, ll=^R, nel=^M^U, ri=^W, 
+ 	rmir=^O, rmso=^T, smir=^Q, smso=^V, 
+ # "mterm -type decansi" sets $TERM to "decansi"
++#
++# note: kdch1, kfnd, kslt are in the source code, but do not work -TD
+ decansi|ANSI emulation with DEC compatibility hacks, 
+ 	am, mir, msgr, xenl, 
+ 	colors#8, it#8, pairs#64, 
+@@ -3540,7 +3849,13 @@
+ 	home=\E[H, hpa=\E[%i%p1%d`, ht=^I, ich1=, il=\E[%p1%dL, 
+ 	il1=\E[L, ind=\E[S, indn=\E[%p1%dS, invis=\E[8m, 
+ 	is2=\E)0\E[r\017, kbs=^H, kcub1=\EOD, kcud1=\EOB, 
+-	kcuf1=\EOC, kcuu1=\EOA, nel=\EE, op=\E[0m, rc=\E8, rev=\E[7m, 
++	kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kf1=\E[11~, 
++	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, 
++	kf14=\E[26~, kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, 
++	kf18=\E[32~, kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, 
++	kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, 
++	kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, kich1=\E[2~, knp=\E[6~, 
++	kpp=\E[5~, kslt=\E[4~, nel=\EE, op=\E[0m, rc=\E8, rev=\E[7m, 
+ 	ri=\E[T, rin=\E[%p1%dT, rmacs=^O, rmam=\E[?7l, rmir=\E[4l, 
+ 	rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, sc=\E7, 
+ 	setab=\E[4%p1%dm, setaf=\E[3%p1%dm, 
+@@ -3656,10 +3971,11 @@
+ 	khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~, 
+ 	nel=\EE, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O, 
+ 	rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[23m, 
+-	rmul=\E[24m, rs2=\Ec, sc=\E7, sgr0=\E[m, smacs=^N, 
+-	smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[3m, 
+-	smul=\E[4m, tbc=\E[3g, E0=\E(B, S0=\E(%p1%c, 
+-	use=ecma+color, 
++	rmul=\E[24m, rs2=\Ec\E[?1000l\E[?25h, sc=\E7, 
++	sgr=\E[0%?%p6%t;1%;%?%p1%t;3%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
++	sgr0=\E[m, smacs=^N, smcup=\E[?1049h, smir=\E[4h, 
++	smkx=\E[?1h\E=, smso=\E[3m, smul=\E[4m, tbc=\E[3g, E0=\E(B, 
++	S0=\E(%p1%c, use=ecma+color, 
+ # The bce and status-line entries are from screen 3.9.13 (and require some
+ # changes to .screenrc).
+ screen-bce|VT 100/ANSI X3.64 virtual terminal with bce, 
+@@ -3691,12 +4007,12 @@
+ #	xterm (-xfree86 or -r6) does not normally support kIC, kNXT and kPRV
+ #	since the default translations override the built-in keycode
+ #	translation.  They are suppressed here to show what is tested by tack.
+-screen.xterm-xfree86|screen customized for XFree86 xterm, 
++screen.xterm-xfree86|screen.xterm-new|screen customized for modern xterm, 
+ 	bce@, bw, 
+ 	invis@, kIC@, kNXT@, kPRV@, kend=\E[4~, khome=\E[1~, meml@, 
+ 	memu@, 
+-	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;, 
+-	use=xterm-xfree86, 
++	sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m, 
++	use=xterm-new, 
+ # xterm-r6 does not really support khome/kend unless it is propped up by
+ # the translations resource.
+ screen.xterm-r6|screen customized for X11R6 xterm, 
+@@ -3800,11 +4116,11 @@
+ 	kf6=\E[23~, kf7=\E[24~, kf8=\E[25~, kf9=\E[26~, khlp=\E[1~, 
+ 	khome=\E[2~, knp=\E[6~, kpp=\E[3~, mc4=\E[4i, mc5=\E[5i, 
+ 	rc=\E8, rev=\E[7m, rf=/usr/share/tabset/vt100, ri=\EM, 
+-	rmacs=^O, rmam=\E[?7l, rmcup=\E[2J\E8, rmir=\E[4l, 
++	rmacs=\E(B, rmam=\E[?7l, rmcup=\E[2J\E8, rmir=\E[4l, 
+ 	rmso=\E[27m, rmul=\E[24m, 
+ 	rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;4;6l\E[4l\E>, sc=\E7, 
+ 	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p4%t;5%;%?%p1%p3%|%t;7%;m%?%p9%t\E(0%e\E(B%;, 
+-	sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smcup=\E7, 
++	sgr0=\E[m\E(B, smacs=\E(0, smam=\E[?7h, smcup=\E7, 
+ 	smir=\E[4h, smso=\E[7m, smul=\E[4m, tbc=\E[3g, tsl=\E]0;, 
+ 	u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?62;1;6c, u9=\E[c, 
+ ncsa|NCSA Telnet 2.7 for Macintosh in vt220-8 mode, 
+@@ -7446,7 +7762,7 @@
+ wy120|wyse120|wy150|wyse150|Wyse 120/150, 
+ 	am, bw, hs, km, mc5i, mir, msgr, xon, 
+ 	cols#80, it#8, lh#1, lines#24, lw#8, nlab#8, pb#9601, wsl#45, 
+-	acsc=+/\,.0[Iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
++	acsc=+/\,.0[iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
+ 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<50>, 
+ 	cnorm=\E`1, cr=^M, cub1=^H, cud1=^J, cuf1=^L, 
+ 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<7>, 
+@@ -7525,7 +7841,7 @@
+ wy60|wyse60|Wyse 60, 
+ 	am, bw, hs, km, mc5i, mir, msgr, 
+ 	cols#80, lh#1, lines#24, lw#8, nlab#8, wsl#45, 
+-	acsc=+/\,.0[Iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
++	acsc=+/\,.0[iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
+ 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<100>, 
+ 	cnorm=\E`1, cr=^M, cub1=^H, cud1=^J, cuf1=^L, 
+ 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, 
+@@ -7694,7 +8010,7 @@
+ wy99f|wy99fgt|wy-99fgt|Wyse WY-99GT (int'l PC keyboard), 
+ 	am, bw, hs, km, mc5i, mir, msgr, xon, 
+ 	cols#80, it#8, lines#25, wsl#46, 
+-	acsc='x+y.wI~_vj(k'l&m%n)o9q*s8t-u.v\,w+x=, bel=^G, 
++	acsc='x+y.wi~_vj(k'l&m%n)o9q*s8t-u.v\,w+x=, bel=^G, 
+ 	blink=\EG2, cbt=\EI, civis=\E`0, clear=\E'\E(\032, 
+ 	cnorm=\E`4\E`1, cr=^M, cub1=^H, cud1=\Ej, cuf1=^L, 
+ 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, 
+@@ -7746,7 +8062,7 @@
+ wy160|wyse160|Wyse 160, 
+ 	am, bw, hs, km, mc5i, mir, msgr, 
+ 	cols#80, lh#1, lines#24, lw#8, nlab#8, wsl#38, 
+-	acsc=+/\,.0[Iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
++	acsc=+/\,.0[iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
+ 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<30>, 
+ 	cnorm=\E`1, cr=^M, cub1=^H, cud1=^J, cuf1=^L, 
+ 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<5>, 
+@@ -8054,7 +8370,7 @@
+ wy325|wyse325|Wyse epc, 
+ 	am, bw, hs, mc5i, mir, 
+ 	cols#80, lh#1, lines#24, lw#8, nlab#8, pb#9601, wsl#45, 
+-	acsc=+/\,.0[Iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
++	acsc=+/\,.0[iha2fxgqh1jYk?lZm@nEqDtCu4vAwBx3yszr{c~~, 
+ 	bel=^G, blink=\EG2, cbt=\EI, civis=\E`0, clear=\E+$<50>, 
+ 	cnorm=\E`1, cr=^M, cub1=^H, cud1=^J, cuf1=^L, 
+ 	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dch1=\EW$<7>, 
+@@ -8609,8 +8925,8 @@
+ 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, 
+ 	cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, 
+ 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
+-	cvvis=\E[?25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, 
+-	dl1=\E[M, dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K, 
++	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
++	dsl=\E[2$~\r\E[1$}\E[K\E[$}, ed=\E[J, el=\E[K, 
+ 	flash=\E[?5h\E[?5l, fsl=\E[$}, home=\E[H, ht=^I, hts=\EH, 
+ 	ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L$<3/>, ind=\ED, 
+ 	is2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h\E[1;24r\E[24;1H, 
+@@ -8683,15 +8999,20 @@
+ # (The <blink>/<bold>/<rev>/<smacs>/<smul>/<smso> capabilities exist only to
+ # tell ncurses that the corresponding highlights exist; it should use <sgr>,
+ # which is the only method that will actually work for multiple highlights.)
++#
++# Update by TD - 2004: half of this was inconsistent.  Found documentation
++# and repaired most of the damage.  sgr0 is probably incorrect, but the
++# available documentation gives no clues for a workable string.
+ avatar0|avatar terminal emulator level 0, 
+ 	am, bce, msgr, 
+ 	cols#80, it#8, lines#25, 
+-	blink=^A^V\177, bold=^V^A^P, cr=^M, cub1=^V^E, cud1=^V^D, 
++	blink=^V^B, bold=^V^A^P, cr=^M, cub1=^V^E, cud1=^V^D, 
+ 	cuf1=^V^F, cup=\026\010%p1%c%p2%c, cuu1=^V^C, el=^V^G, 
+-	ind=^J, invis=^V^A\0, rep=\031%p1%c%p2%d, rev=^A^Vp, 
+-	rs2=^L, 
+-	sgr=\026\001%{0}%?%p1%t%{112}%|%;%?%p2%t%{1}%|%;%?%p3%t%{112}%|%;%?%p4%t{128}%|%;%?%p6%t%{16}%|%;, 
+-	sgr0=^V^A^G, smacs=, smso=^A^Vp, smul=^V^A, use=klone+acs, 
++	ind=^J, invis=^V^A\0, rep=\031%p1%c%p2%c, rev=^V^Ap, 
++	rmacs@, rs2=^L, 
++	sgr=%?%p1%p2%|%p3%|%p6%|%p7%|%t\026\001%?%p7%t%{128}%e%{0}%?%p1%t%{112}%|%;%?%p2%t%{1}%|%;%?%p3%t%{112}%|%;%?%p6%t%{16}%|%;%;%c%;%?%p4%t\026\002%;, 
++	sgr0=^V^A^G, smacs@, smso=^V^Ap, smul=^V^A^A, 
++	use=klone+acs, 
+ # From: Eric S. Raymond <esr@snark.thyrsus.com> 1 Nov 1995
+ avatar0+|avatar terminal emulator level 0+, 
+ 	dch1=^V^N, rmir=\026\n\0\0\0\0, smir=^V^I, use=avatar0, 
+@@ -8712,10 +9033,9 @@
+ 	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, 
+ 	clear=^L, cnorm=\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, 
+ 	cub1=^H, cud1=^C, cuf1=^B, 
+-	cup=\037%p2%{32}%+%c%p1%{32}%+%c, cuu1=^^, 
+-	cvvis=\E[?25h, dch1=^W, dl=\E[%p1%dM, dl1=^Z, 
+-	ech=\E[%p1%dX, ed=^F5, el=^P^P, ht=^I, il=\E[%p1%dL, il1=^K, 
+-	ind=\ED, invis=\E[8m, 
++	cup=\037%p2%{32}%+%c%p1%{32}%+%c, cuu1=^^, dch1=^W, 
++	dl=\E[%p1%dM, dl1=^Z, ech=\E[%p1%dX, ed=^F5, el=^P^P, ht=^I, 
++	il=\E[%p1%dL, il1=^K, ind=\ED, invis=\E[8m, 
+ 	is2=\017\035\E(B\E)0\E[?7h\E[?3l\E[>8g, kbs=^H, 
+ 	kcub1=^B, kcud1=^N, kcuf1=^F, kcuu1=^P, khome=^A, nel=^M\ED, 
+ 	rc=\E8, rep=\030%p1%c%p2%c, rev=^R, ri=\EM, rmcup=, rmdc=, 
+@@ -10510,15 +10830,66 @@
+ # underline=01100000, rev=01010000, blink=01000010,dim=01000001,
+ # invis=01000100 and %c is the logical or of desired attributes.
+ # There is also a `tag bit' enabling attributes, set by \E) and unset by \E(.
++#
++# Update by TD - 2004:
++# Adapted from 
++#	http://www.cs.utk.edu/~shuford/terminal/adds_viewpoint_news.txt
++#
++# COMMANDS                        ASCII CODE
++# 
++# Address, Absolute               ESC,=,row,column
++# Beep                            BEL
++# Aux Port Enable                 ESC,@
++# Aux Port Disable                ESC,A
++# Backspace                       BS
++# Cursor back                     BS
++# Cursor down                     LF
++# Cursor forward                  FF
++# Cursor home                     RS
++# Cursor up                       VT
++# Cursor supress                  ETB
++# Cursor enable                   CAN
++# Erase to end of line            ESC,T
++# Erase to end of page            ESC,Y
++# Erase screen                    SUB
++# Keyboard lock                   SI
++# Keyboard unlock                 SO
++# Read current cursor position    ESC,?
++# Set Attribute                   ESC,0,x  (see below for values of x)
++# Tag bit reset                   ESC,(
++# Tag bit set                     ESC,)
++# Transparent Print on            ESC,3
++# Transparent Print off           ESC,4
++# 
++# 
++# ATTRIBUTES
++# 
++# Normal                          @	0100
++# Half Intensity                  A	0101
++# Blinking                        B	0102
++# Half Intensity Blinking         C	0103
++# Reverse Video                   P	0120
++# Reverse Video Half Intensity    Q	0121
++# Reverse Video Blinking          R	0122
++# Reverse Video Half Intensity
++#    Blinking                     S	0123
++# Underlined                      `	0140
++# Underlined Half Intensity       a	0141
++# Underlined Blinking             b	0142
++# Underlined Half Intensity
++#    Blinking                     c	0143
++# Video suppress                  D	0104
+ vp3a+|viewpoint3a+|adds viewpoint 3a+, 
+ 	am, bw, 
+ 	cols#80, it#8, lines#24, 
+-	civis=^W, clear=\E*$<80>, cnorm=^X, cr=^M, cub1=^H, cud1=^J, 
+-	cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, 
+-	ed=\EY$<80>, el=\ET, home=^^, ht=^I, ind=^J, kbs=^H, kcub1=^H, 
+-	kcud1=^J, kcuf1=^L, kcuu1=^K, khome=^^, nel=^M^J, rmso=\E(, 
+-	sgr=\E0%{64}%?%p1%tQ%|%;%?%p2%t%{96}%|%;%?%p3%tP%|%;%?%p4%t%{2}%|%;%?%p5%t%{1}%|%;%?%p7%tD%|%;%c\E), 
+-	sgr0=\E(, smso=\E0Q\E), 
++	blink=\E0B\E), civis=^W, clear=\E*$<80>, cnorm=^X, cr=^M, 
++	cub1=^H, cud1=^J, cuf1=^L, 
++	cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, dim=\E0A\E), 
++	ed=\EY$<80>, el=\ET, home=^^, ht=^I, ind=^J, invis=\E0D\E), 
++	kbs=^H, kcub1=^H, kcud1=^J, kcuf1=^L, kcuu1=^K, khome=^^, 
++	nel=^M^J, rev=\E0P\E), rmso=\E(, 
++	sgr=%?%p1%p2%|%p3%|%p4%|%p5%|%p7%|%t\E0%{64}%?%p1%t%{17}%|%;%?%p2%t%{32}%|%;%?%p3%t%{16}%|%;%?%p4%t%{2}%|%;%?%p5%t%{1}%|%;%c%?%p7%tD%;\E)%e\E(%;, 
++	sgr0=\E(, smso=\E0Q\E), smul=\E0`\E), 
+ vp60|viewpoint60|addsvp60|adds viewpoint60, 
+ 	use=regent40, 
+ #
+@@ -12360,11 +12731,11 @@
+ 	bw@, eslok, 
+ 	it#8, wsl#80, 
+ 	blink=\EG2, bold=\EG0, civis=\E.1, cnorm=\E.2, cud1=^V, 
+-	cvvis=\E.2, dim=\EG@, dl1=\ER, dsl=\Ef\r, 
+-	flash=\Eb$<200/>\Ed, il1=\EE, ip@, is2@, kclr=^^, kdch1=\EW, 
+-	kdl1=\ER, ked=\EY, kel=\ET, kf0=^AI\r, kf10@, kich1=\EQ, 
+-	kil1=\EE, mc4=\Ea, mc5=\E`, ri=\EJ, rmacs=\E%%, rmir=\Er\EO, 
+-	smacs=\E$, smir=\EO\Eq, smso=\EG<, tsl=\Ef, use=f100, 
++	dim=\EG@, dl1=\ER, dsl=\Ef\r, flash=\Eb$<200/>\Ed, il1=\EE, 
++	ip@, is2@, kclr=^^, kdch1=\EW, kdl1=\ER, ked=\EY, kel=\ET, 
++	kf0=^AI\r, kf10@, kich1=\EQ, kil1=\EE, mc4=\Ea, mc5=\E`, 
++	ri=\EJ, rmacs=\E%%, rmir=\Er\EO, smacs=\E$, smir=\EO\Eq, 
++	smso=\EG<, tsl=\Ef, use=f100, 
+ f110-14|Liberty Freedom 110 14inch, 
+ 	dch1@, use=f110, 
+ f110-w|Liberty Freedom 110 - 132 cols, 
+@@ -12380,8 +12751,8 @@
+ 	clear=^Z, cnorm=\E.1, cr=^M, 
+ 	csr=\Em0%p1%{32}%+%c%p2%{32}%+%c, cub1=^H, cud1=^V, 
+ 	cuf1=^L, cup=\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=^K, 
+-	cvvis=\E.1, dch1=\EW, dim=\EG@, dl1=\ER, dsl=\Ef\r, ed=\EY, 
+-	el=\ET, flash=\Eo$<200/>\En, fsl=^M, home=^^, 
++	dch1=\EW, dim=\EG@, dl1=\ER, dsl=\Ef\r, ed=\EY, el=\ET, 
++	flash=\Eo$<200/>\En, fsl=^M, home=^^, 
+ 	hpa=\E]%p1%{32}%+%c, hts=\E1, il1=\EE, ind=^J, kbs=^H, 
+ 	kclr=^^, kcub1=^H, kcud1=^V, kcuf1=^L, kcuu1=^K, kdch1=\EW, 
+ 	kdl1=\ER, ked=\EY, kel=\ET, kf0=^AI\r, kf1=^A@\r, kf2=^AA\r, 
+@@ -13075,6 +13446,10 @@
+ jaixterm-m|IBM Kanji AIXterm Monochrome Terminal Emulator, 
+ 	acsc@, use=aixterm-m, 
+ 
++# This flavor is adapted from xterm, in turn from aixterm documentation -TD
++aixterm-16color|IBM Aixterm Terminal Emulator with 16 colors, 
++	use=ibm+16color, use=aixterm, 
++
+ #### Infoton/General Terminal Corp.
+ #
+ 
+@@ -13090,7 +13465,7 @@
+ 	OTbs, am, 
+ 	cols#80, lines#25, 
+ 	bel=^G, clear=\E[2J, cr=^M, cub1=^H, cud1=^J, cuf1=\E[C, 
+-	cup=%i\E[%p1%3d;%p2%3dH, cuu1=\E[A, 
++	cup=\E[%i%p1%3d;%p2%3dH, cuu1=\E[A, 
+ 	dch1=\E[4h\E[2Q\E[P\E[4l\E[0Q, dl1=\E[M, el=\E[N, 
+ 	il1=\E[L, ind=^J, rmir=\E[4l\E[0Q, smir=\E[4h\E[2Q, 
+ # (addrinfo: removed obsolete ":bc=^Z:" -- esr)
+@@ -13098,8 +13473,7 @@
+ 	am, 
+ 	cols#80, lines#24, 
+ 	bel=^G, clear=^L, cr=^M, cub1=^Z, cud1=^J, cuf1=^Y, 
+-	cup=\037%p1%{1}%-%c%p2%{1}%-%c, cuu1=^\, ed=^K, home=^H, 
+-	ind=^J, ll=^H^\, 
++	cup=\037%p1%c%p2%c, cuu1=^\, ed=^K, home=^H, ind=^J, ll=^H^\, 
+ # (infoton: used to have the no-ops <lh#0>, <lw#0>, <nlab#0> -- esr)
+ infoton, 
+ 	am, 
+@@ -14032,9 +14406,9 @@
+ 	cbt=\EI, civis=\E`0, clear=\014$<40>, cnorm=\E`5, 
+ 	cr=\r$<2>, cub1=\010$<2>, cud1=\n$<2>, cuf1=\006$<2>, 
+ 	cup=\EY%p1%{32}%+%c%p2%{32}%+%c$<5>, cuu1=\032$<2>, 
+-	cvvis=\E`5, dch1=\EW$<2>, dim=\EGp, dl1=\El$<2>, dsl=\E`c, 
+-	ed=\Ek$<2>, el=\EK$<2>, fsl=^M, home=\036$<2>, ht=^I, 
+-	hts=\E1, il1=\EM$<2>, ind=\n$<2>, invis=\EG1, 
++	dch1=\EW$<2>, dim=\EGp, dl1=\El$<2>, dsl=\E`c, ed=\Ek$<2>, 
++	el=\EK$<2>, fsl=^M, home=\036$<2>, ht=^I, hts=\E1, 
++	il1=\EM$<2>, ind=\n$<2>, invis=\EG1, 
+ 	is2=\Ee6\E~%$<100>\E+\E`\:\Ed/\E`1\EO\Ee4\Ec@0@\Ec@1A\EcB0\EcC1\Ee7$<100>, 
+ 	kDC=\El, kEND=\Ek, kHOM=^A, kPRT=\E7, kRIT=^F, ka1=^A, ka3=\EJ, 
+ 	kbs=^H, kc1=\ET, kc3=\EJ, kcub1=^U, kcud1=^J, kcuf1=^F, 
+@@ -16217,9 +16591,16 @@
+ 	smso=\2337m, smul=\2334m, 
+ 
+ # From: Henning 'Faroul' Peters <Faroul@beyond.kn-bremen.de>, 25 Sep 1999
++#
++# Pavel Fedin added
++#	Home    Shift+Left
++#	End     Shift+Right
++#	PgUp    Shift+Up
++#	PgDn    Shift+Down
+ amiga-8bit|Amiga ANSI using 8-bit controls, 
+ 	acsc=, dl=\233%p1%dM, dl1=\233M, il=\233%p1%dL, il1=\233L, 
+-	ind=\204, indn@, ri=\215, rin@, use=amiga-h, 
++	ind=\204, indn@, kend=\233 @, khome=\233 A, knp=\233S, 
++	kpp=\233T, ri=\215, rin@, use=amiga-h, 
+ 
+ # From: Ruediger Kuhlmann <terminfo@ruediger-kuhlmann.de>, 18 Jul 2000
+ # requires use of appropriate preferences settings.
+@@ -16249,6 +16630,14 @@
+ 	sgr0=\E[0m\017\E[30;85;>15m, smcup=\E[?7h, smkx=\E[?1h, 
+ 	smso=\E[1m, smul=\E[4m, 
+ 
++# MorphOS on Genesi Pegasos
++# By Pavel Fedin <sonic_amiga@rambler.ru>
++morphos, 
++	acsc=, dl=\233%p1%dM, dl1=\233M, il=\233%p1%dL, il1=\233L, 
++	ind=\204, indn@, kend=\23345~, kf11=\23320~, kf12=\23321~, 
++	khome=\23344~, kich1=\23340~, knp=\23342~, kpp=\23341~, 
++	ri=\215, rin@, use=amiga-h, 
++
+ # Commodore B-128 microcomputer from Doug Tyrol <det@HEL-ACE.ARPA>
+ # 	I'm trying to write a termcap for a commodore b-128, and I'm
+ # having a little trouble. I've had to map most of my control characters
+@@ -16866,9 +17255,9 @@
+ 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\E[D, 
+ 	cud=\E[%p1%dB, cud1=\E[B, cuf=\E[%p1%dC, cuf1=\E[C, 
+ 	cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, 
+-	cvvis=\E[?25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, 
+-	dl1=\E[M, dsl=\E[1$}\E[2$~\n\E[0$}, ech=\E[%p1%dX, 
+-	ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, 
++	dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, 
++	dsl=\E[1$}\E[2$~\n\E[0$}, ech=\E[%p1%dX, ed=\E[J, 
++	el=\E[K, el1=\E[1K, enacs=\E(B\E)0, 
+ 	flash=\E[?5h$<50>\E[?5l, fsl=\E[0$}, home=\E[H, ht=^I, 
+ 	hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\ED, 
+ 	is1=\E[63;1"p\E[2h, 
+@@ -16966,12 +17355,12 @@
+ 	clear=\233H\233J, cnorm=\233?25h, cr=^M, 
+ 	csr=\233%i%p1%d;%p2%dr, cub=\233%p1%dD, cud=\233%p1%dB, 
+ 	cuf=\233%p1%dC, cup=\233%i%p1%d;%p2%dH, cuu=\233%p1%dA, 
+-	cvvis=\233?25h, dch=\233%p1%dP, dch1=\233P, 
+-	dl=\233%p1%dM, dsl=\2331$}\2332$~\n\2330$}, 
+-	ech=\233%p1%dX, ed=\233J, el=\233K, el1=\2331K, 
+-	enacs=\E(B\E)0, flash=\233?5h$<50>\233?5l, fsl=\2330$}, 
+-	home=\233H, ht=^I, hts=\EH, ich=\233%p1%d@, il=\233%p1%dL, 
+-	ind=\ED, is1=\E[63;2"p\E[2h, 
++	dch=\233%p1%dP, dch1=\233P, dl=\233%p1%dM, 
++	dsl=\2331$}\2332$~\n\2330$}, ech=\233%p1%dX, ed=\233J, 
++	el=\233K, el1=\2331K, enacs=\E(B\E)0, 
++	flash=\233?5h$<50>\233?5l, fsl=\2330$}, home=\233H, 
++	ht=^I, hts=\EH, ich=\233%p1%d@, il=\233%p1%dL, ind=\ED, 
++	is1=\E[63;2"p\E[2h, 
+ 	is2=\E[?2h\E[?3l\E[?5l\E[?7h\E[?8h\E>\E[?1l\E G\E[?42l\E[?4l, 
+ 	is3=\2330$}\233?25h\2332l\233H\233J, ka1=\217w, 
+ 	ka3=\217y, kb2=\217u, kbs=^H, kc1=\217q, kc3=\217s, 
+@@ -18214,16 +18603,16 @@
+ 	cbt=\E[Z, civis=\E[?25l, clear=\E[H\E[2J$<6>, 
+ 	cnorm=\E[?25h, cub=\E[%p1%dD, cud=\E[%p1%dB, 
+ 	cuf=\E[%p1%dC, cup=\E[%p1%i%p1%d;%p2%dH, cuu=\E[%p1%dA, 
+-	cvvis=\E[?25h, dch=\E[%p1%dP$<250>, dch1=\E[P, 
+-	dl=\E[%p1%dM, ech=\E[%p1%dX$<20>, ed=\E[J$<6>, el=\E[0K, 
+-	el1=\E[1K, enacs=\E(B\E)0, ff=^L, flash=\E[?5h\E[?5l$<6>, 
++	dch=\E[%p1%dP$<250>, dch1=\E[P, dl=\E[%p1%dM, 
++	ech=\E[%p1%dX$<20>, ed=\E[J$<6>, el=\E[0K, el1=\E[1K, 
++	enacs=\E(B\E)0, ff=^L, flash=\E[?5h\E[?5l$<6>, 
+ 	hpa=\E[%p1%{1}%+%dG, hts=\E[0W, ich=\E[%p1%d@$<250>, 
+ 	il=\E[%p1%dL$<36>, ip=$<10>, is2=\E[1;24r\E[24;1H, 
+ 	kcmd=\E[29~, kdch1=\E[P, kent=^J, kf1=\E[17~, kf10=\E[28~, 
+ 	kf11=\E[29~, kf12=\E[31~, kf2=\E[18~, kf3=\E[19~, 
+ 	kf4=\E[20~, kf5=\E[21~, kf6=\E[23~, kf7=\E[24~, kf8=\E[25~, 
+ 	kf9=\E[26~, khome=\E[H, kich1=\E[@, knp=\E[S, kpp=\E[T, 
+-	kprt=^X, prot=\E&, rmacs=\017$<2>, rs2=\E[!p, 
++	kprt=^X, prot=\E&, rmacs=\017$<2>, rs2=\E[!p, sgr@, 
+ 	smacs=\016$<2>, tbc=\E[3g, vpa=\E[%p1%{1}%+%dd, 
+ 	use=vt220, 
+ #
+@@ -20477,6 +20866,92 @@
+ #	* add vt100+ and vt-utf8 entries -TD
+ #	* add uwin entry -TD
+ #
++# 2004-03-27
++#	* add sgr strings to several common entries lacking them, e.g.,
++#	  screen, to make the entries more portable -TD
++#	* remove cvvis from rxvt entry, since it is the same as cnorm -TD
++#	* similar fixups for cvvis/cnorm various entries -TD
++#
++# 2004-05-22
++#	* remove 'ncv' from xterm-256color (patch 188) -TD
++#
++# 2004-06-26
++#	* add mlterm -TD
++#	* add xterm-xf86-v44 -TD 
++#	* modify xterm-new aka xterm-xfree86 to accommodate luit, which relies
++#	  on G1 being used via an ISO-2022 escape sequence (report by
++#	  Juliusz Chroboczek) -TD
++#	* add 'hurd' entry -TD
++#
++# 2004-07-03
++#	* make xterm-xf86-v43 derived from xterm-xf86-v40 rather than
++#	  xterm-basic -TD
++#	* align with xterm #192's use of xterm-new -TD
++#	* update xterm-new and xterm-8bit for cvvis/cnorm strings -TD
++#	* make xterm-new the default "xterm" -TD
++#
++# 2004-07-10
++#	* minor fixes for emu -TD
++#	* add emu-220
++#	* add rmam/smam to linux (Trevor Van Bremen)
++#	* change wyse acsc strings to use 'i' map rather than 'I' -TD
++#	* fixes for avatar0 -TD
++#	* fixes for vp3a+ -TD
++#
++# 2004-07-17
++#	* add xterm-pc-fkeys -TD
++#	* review/update gnome and gnome-rh90 entries (prompted by
++#	  Redhat Bugzilla #122815) -TD
++#	* review/update konsole entries -TD
++#	* add sgr, correct sgr0 for kterm and mlterm -TD
++#	* correct tsl string in kterm -TD
++#
++# 2004-07-24
++#	* make ncsa-m rmacs/smacs consistent with sgr -TD
++#	* add sgr, rc/sc and ech to syscons entries -TD
++#	* add function-keys to decansi -TD
++#	* add sgr to mterm-ansi -TD
++#	* add sgr, civis, cnorm to emu -TD
++#	* correct/simplify cup in addrinfo -TD 
++#	* corrections for gnome and konsole entries
++#	  (Redhat Bugzilla #122815) -Hans de Goede
++#	* modify DEC entries (vt220, etc), to add sgr string, and to use
++#	  ISO-2022 strings for rmacs/smacs -TD
++#
++# 2004-07-31
++#	* rename xterm-pc-fkeys to xterm+pcfkeys -TD
++#
++# 2004-08-07
++#	* improved putty entry -Robert de Bath
++#
++# 2004-08-14
++#	* remove dch/dch1 from rxvt because they are implemented inconsistently
++#	  with the common usage of bce/ech -TD
++#	* remove khome from vt220 (vt220's have no home key) -TD
++#	* add rxvt+pcfkeys -TD
++#
++# 2004-08-21
++#	* modify several entries to ensure xterm mouse and cursor visibility
++#	  are reset in rs2 string:  hurd, putty, gnome, konsole-base, mlterm,
++#	  Eterm, screen.  (The xterm entries are left alone - old ones for
++#	  compatibility, and the new ones do not require this change) -TD
++#
++# 2004-08-28
++#	* add morphos entry -Pavel Fedin
++#	* modify amiga-8bit to add khome/kend/knp/kpp -Pavel Fedin
++#	* corrected \E[5?l to \E[?5l in vt320 entries -TD
++#
++# 2004-11-20
++#	* update wsvt25 entry -TD
++#
++# 2005-01-29
++#	* update pairs for xterm-88color and xterm-256color to reflect the
++#	  ncurses extended-color support -TD
++#
++# 2005-02-26
++#	* modify sgr/sgr0 in xterm-new to improve tgetent's derived "me" -TD
++#	* add aixterm-16color to demonstrate 16-color capability -TD
++#
+ # The following sets edit modes for GNU EMACS.
+ # Local Variables:
+ # fill-prefix:"\t"
+Index: mk-0th.awk
+Prereq:  1.14 
+--- ncurses-5.4-20040208/mk-0th.awk	2002-08-31 21:36:54.000000000 +0000
++++ ncurses-5.4-20050319/mk-0th.awk	2005-01-22 16:31:40.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: mk-0th.awk,v 1.14 2002/08/31 21:36:54 tom Exp $
++# $Id: mk-0th.awk,v 1.17 2005/01/22 16:31:40 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2001 Free Software Foundation, Inc.                     #
++# Copyright (c) 1998-2004,2005 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"), #
+@@ -33,22 +33,30 @@
+ #
+ # Variables:
+ #	libname (library name, e.g., "ncurses", "panel", "forms", "menus")
++#	subsets (is used here to decide if wide-character code is used)
+ #
+ BEGIN	{
+-		print  ""
+-		print  "# generated by mk-0th.awk"
+-		print  ""
+-		print  ".SUFFIXES: .c .cc .h .i .ii"
+-		print  ".c.i :"
+-		printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
+-		print  ".cc.ii :"
+-		printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
+-		print  ".h.i :"
+-		printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
+-		print  ""
++		using = 0;
+ 		found = 0;
+ 	}
+ 	!/^[@#]/ {
++		if (using == 0)
++		{
++			print  ""
++			print  "# generated by mk-0th.awk"
++			printf "#   libname:    %s\n", libname
++			printf "#   subsets:    %s\n", subsets
++			print  ""
++			print  ".SUFFIXES: .c .cc .h .i .ii"
++			print  ".c.i :"
++			printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
++			print  ".cc.ii :"
++			printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
++			print  ".h.i :"
++			printf "\t$(CPP) $(CPPFLAGS) $< >$@\n"
++			print  ""
++			using = 1;
++		}
+ 		if ( $0 != "" && $1 != "link_test" )
+ 		{
+ 			if ( found == 0 )
+@@ -84,7 +92,7 @@
+ 			printf "\trm -f llib-l%s\n", libname
+ 			print  ""
+ 			printf "llib-l%s : $(C_SRC)\n", libname
+-			printf "\tcproto -a -l -DLINT $(CPPFLAGS) $(C_SRC) >$@\n"
++			printf "\tcproto -a -l -DNCURSES_ENABLE_STDBOOL_H=0 -DLINT $(CPPFLAGS) $(C_SRC) >$@\n"
+ 			print  ""
+ 			print  "lintlib :"
+ 			printf "\tsh $(srcdir)/../misc/makellib %s $(CPPFLAGS)", libname
+Index: mk-1st.awk
+Prereq:  1.62 
+--- ncurses-5.4-20040208/mk-1st.awk	2004-01-10 20:48:43.000000000 +0000
++++ ncurses-5.4-20050319/mk-1st.awk	2005-01-22 16:06:36.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: mk-1st.awk,v 1.62 2004/01/10 20:48:43 tom Exp $
++# $Id: mk-1st.awk,v 1.64 2005/01/22 16:06:36 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2004,2005 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"), #
+@@ -32,18 +32,20 @@
+ # Generate list of objects for a given model library
+ # Variables:
+ #	name (library name, e.g., "ncurses", "panel", "forms", "menus")
++#	traces ("all" or "DEBUG", to control whether tracing is compiled in)
++#	MODEL (e.g., "DEBUG", uppercase; toupper is not portable)
+ #	model (directory into which we compile, e.g., "obj")
+ #	prefix (e.g., "lib", for Unix-style libraries)
+ #	suffix (e.g., "_g.a", for debug libraries)
+-#	MODEL (e.g., "DEBUG", uppercase; toupper is not portable)
+-#	depend (optional dependencies for all objects, e.g, ncurses_cfg.h)
+ #	subset ("none", "base", "base+ext_funcs" or "termlib")
+-#	host (cross-compile host, if any)
+ #	ShlibVer ("rel", "abi" or "auto", to augment DoLinks variable)
+ #	ShlibVerInfix ("yes" or "no", determines location of version #)
+ #	DoLinks ("yes", "reverse" or "no", flag to add symbolic links)
+ #	rmSoLocs ("yes" or "no", flag to add extra clean target)
++#	ldconfig (path for this tool, if used)
+ #	overwrite ("yes" or "no", flag to add link to libcurses.a
++#	depend (optional dependencies for all objects, e.g, ncurses_cfg.h)
++#	host (cross-compile host, if any)
+ #
+ # Notes:
+ #	CLIXs nawk does not like underscores in command-line variable names.
+@@ -111,12 +113,26 @@
+ 				if (found == 0) {
+ 					print  ""
+ 					printf "# generated by mk-1st.awk (subset=%s)\n", subset
++					printf "#  name:          %s\n", name 
++					printf "#  traces:        %s\n", traces 
++					printf "#  MODEL:         %s\n", MODEL 
++					printf "#  model:         %s\n", model 
++					printf "#  prefix:        %s\n", prefix 
++					printf "#  suffix:        %s\n", suffix 
++					printf "#  subset:        %s\n", subset 
++					printf "#  ShlibVer:      %s\n", ShlibVer 
++					printf "#  ShlibVerInfix: %s\n", ShlibVerInfix 
++					printf "#  DoLinks:       %s\n", DoLinks 
++					printf "#  rmSoLocs:      %s\n", rmSoLocs 
++					printf "#  ldconfig:      %s\n", ldconfig 
++					printf "#  overwrite:     %s\n", overwrite 
++					printf "#  depend:        %s\n", depend 
++					printf "#  host:          %s\n", host 
+ 					print  ""
+ 				}
+ 				using = 1
+ 			}
+ 			if ( subset == "termlib" || subset == "termlib+ext_tinfo" ) {
+-				name  = "tinfo"
+ 				OBJS  = MODEL "_T"
+ 			} else {
+ 				OBJS  = MODEL
+Index: mk-2nd.awk
+Prereq:  1.15 
+--- ncurses-5.4-20040208/mk-2nd.awk	2003-11-01 22:42:50.000000000 +0000
++++ ncurses-5.4-20050319/mk-2nd.awk	2005-01-22 16:30:04.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: mk-2nd.awk,v 1.15 2003/11/01 22:42:50 tom Exp $
++# $Id: mk-2nd.awk,v 1.19 2005/01/22 16:30:04 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2004,2005 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"), #
+@@ -36,10 +36,14 @@
+ # development.
+ #
+ # Variables:
+-#	model
++#	model directory into which objects are compiled.
+ #	MODEL (uppercase version of "model"; toupper is not portable)
+ #	echo (yes iff we will show the $(CC) lines)
+ #	subset ("none", "base", "base+ext_funcs" or "termlib")
++#	crenames ("yes" or "no", flag to control whether -c & -o options are used)
++#	cxxrenames ("yes" or "no", flag to control whether -c & -o options are used)
++#	traces ("all" or "DEBUG", to control whether tracing is compiled in)
++#	srcdir is expanded when "configure --srcdir" was used
+ #
+ # Fields in src/modules:
+ #	$1 = module name
+@@ -61,7 +65,14 @@
+ 				if (found == 0) {
+ 					print  ""
+ 					print  "# generated by mk-2nd.awk"
+-					print  ""
++					printf "#   model:      %s\n", model
++					printf "#   MODEL:      %s\n", MODEL
++					printf "#   echo:       %s\n", echo 
++					printf "#   subset:     %s\n", subset
++					printf "#   crenames:   %s\n", crenames
++					printf "#   cxxrenames: %s\n", cxxrenames
++					printf "#   traces:     %s\n", traces
++					printf "#   srcdir:     %s\n", srcdir
+ 				}
+ 				using = 1
+ 			}
+@@ -83,9 +94,11 @@
+ 				if ( $2 == "c++" ) {
+ 					compile="CXX"
+ 					suffix=".cc"
++					use_c_o=cxxrenames
+ 				} else {
+ 					compile="CC"
+ 					suffix=".c"
++					use_c_o=crenames
+ 				}
+ 				printf "../%s/%s$o :\t%s/%s%s", model, $1, $3, $1, suffix
+ 				for (n = 4; n <= NF; n++) printf " \\\n\t\t\t%s", $n
+@@ -96,13 +109,31 @@
+ 					atsign="@"
+ 					printf "\t@echo 'compiling %s (%s)'\n", $1, model
+ 				}
++				printf "\t%s", atsign;
++				if ( use_c_o != "yes" ) {
++					printf "cd ../%s; ", model;
++				}
++				# The choice here is between
++				#	base+ext_funcs and
++				#	termlib+ext_tinfo
++				# but they may appear in the same value.
++				if ( subset ~ /base/ ) {
++					mycflags=""
++				} else if ( subset ~ /termlib/ ) {
++					mycflags=" -DUSE_TERMLIB"
++				}
++				printf "$(LIBTOOL_COMPILE) $(%s) $(CFLAGS_%s)%s -c ", compile, MODEL, mycflags
+ 				if ( $3 == "." || srcdir == "." ) {
+ 					dir = $3 "/"
+ 					sub("^\\$\\(srcdir\\)/","",dir);
+ 					sub("^\\./","",dir);
+-					printf "\t%scd ../%s; $(LIBTOOL_COMPILE) $(%s) $(CFLAGS_%s) -c ../%s/%s%s%s", atsign, model, compile, MODEL, name, dir, $1, suffix
+-				} else
+-					printf "\t%scd ../%s; $(LIBTOOL_COMPILE) $(%s) $(CFLAGS_%s) -c %s/%s%s", atsign, model, compile, MODEL, $3, $1, suffix
++					printf "../%s/%s%s%s", name, dir, $1, suffix
++				} else {
++					printf "%s/%s%s", $3, $1, suffix
++				}
++				if ( use_c_o == "yes" ) {
++					printf " -o ../%s/%s$o", model, $1
++				}
+ 			} else {
+ 				printf "%s", $1
+ 				for (n = 2; n <= NF; n++) printf " %s", $n
+Index: ncurses/Makefile.in
+Prereq:  1.91 
+--- ncurses-5.4-20040208/ncurses/Makefile.in	2003-11-01 22:48:53.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/Makefile.in	2004-08-14 17:20:11.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: Makefile.in,v 1.91 2003/11/01 22:48:53 tom Exp $
++# $Id: Makefile.in,v 1.94 2004/08/14 17:20:11 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2003,2004 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"), #
+@@ -92,8 +92,9 @@
+ 
+ CCFLAGS		= $(CPPFLAGS) $(CFLAGS)
+ 
++BUILD_CPPFLAGS	= -I../include @BUILD_CPPFLAGS@
+ BUILD_CC	= @BUILD_CC@
+-BUILD_CCFLAGS	= -DHAVE_CONFIG_H -I../ncurses -I$(srcdir) @BUILD_CPPFLAGS@ @BUILD_CFLAGS@
++BUILD_CCFLAGS	= -DHAVE_CONFIG_H -I../ncurses -I$(srcdir) -I$(INCDIR) $(BUILD_CPPFLAGS) @BUILD_CFLAGS@
+ BUILD_LDFLAGS	= @BUILD_LDFLAGS@
+ BUILD_LIBS	= @BUILD_LIBS@
+ 
+@@ -230,10 +231,10 @@
+ 	echo | $(AWK) -f $(base)/MKunctrl.awk >$@
+ 
+ tags:
+-	ctags *.[ch]
++	ctags *.[ch] */*.[ch]
+ 
+ @MAKE_UPPER_TAGS@TAGS:
+-@MAKE_UPPER_TAGS@	etags *.[ch]
++@MAKE_UPPER_TAGS@	etags *.[ch] */*.[ch]
+ 
+ mostlyclean ::
+ 	-rm -f core tags TAGS *~ *.bak *.i *.ln *.atac trace
+Index: ncurses/base/MKunctrl.awk
+Prereq:  1.9 
+--- ncurses-5.4-20040208/ncurses/base/MKunctrl.awk	2001-06-02 23:59:20.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/MKunctrl.awk	2004-04-03 22:50:37.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: MKunctrl.awk,v 1.9 2001/06/02 23:59:20 skimo Exp $
++# $Id: MKunctrl.awk,v 1.10 2004/04/03 22:50:37 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998,2000,2001 Free Software Foundation, Inc.                #
++# Copyright (c) 1998,2001,2004 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"), #
+@@ -63,7 +63,10 @@
+ 			printf "%s", gap
+ 		}
+ 		print "};"
++		print "int check = ChCharOf(ch);"
+ 		print ""
+-		print "\treturn (NCURSES_CONST char *)table[ChCharOf(ch)];"
++		print "\tif (check < 0 || check >= (int)SIZEOF(table)) return 0;"
++		print ""
++		print "\treturn (NCURSES_CONST char *)table[check];"
+ 		print "}"
+ 	}
+Index: ncurses/base/lib_addch.c
+Prereq:  1.80 
+--- ncurses-5.4-20040208/ncurses/base/lib_addch.c	2004-02-07 18:20:46.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_addch.c	2005-02-26 18:17:01.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -36,7 +36,7 @@
+ #include <curses.priv.h>
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_addch.c,v 1.80 2004/02/07 18:20:46 tom Exp $")
++MODULE_ID("$Id: lib_addch.c,v 1.89 2005/02/26 18:17:01 tom Exp $")
+ 
+ /*
+  * Ugly microtweaking alert.  Everything from here to end of module is
+@@ -49,29 +49,50 @@
+  */
+ 
+ /* Return bit mask for clearing color pair number if given ch has color */
+-#define COLOR_MASK(ch) (~(attr_t)((ch)&A_COLOR?A_COLOR:0))
++#define COLOR_MASK(ch) (~(attr_t)((ch) & A_COLOR ? A_COLOR : 0))
+ 
+ static inline NCURSES_CH_T
+ render_char(WINDOW *win, NCURSES_CH_T ch)
+ /* compute a rendition of the given char correct for the current context */
+ {
+     attr_t a = win->_attrs;
++    int pair = GetPair(ch);
+ 
+-    if (ISBLANK(ch) && AttrOf(ch) == A_NORMAL) {
+-	/* color in attrs has precedence over bkgrnd */
++    if (ISBLANK(ch)
++	&& AttrOf(ch) == A_NORMAL
++	&& pair == 0) {
++	/* color/pair in attrs has precedence over bkgrnd */
+ 	ch = win->_nc_bkgd;
+-	SetAttr(ch, a | (AttrOf(win->_nc_bkgd) & COLOR_MASK(a)));
++	SetAttr(ch, a | AttrOf(win->_nc_bkgd));
++	if ((pair = GET_WINDOW_PAIR(win)) == 0)
++	    pair = GetPair(win->_nc_bkgd);
++	SetPair(ch, pair);
+     } else {
+ 	/* color in attrs has precedence over bkgrnd */
+ 	a |= AttrOf(win->_nc_bkgd) & COLOR_MASK(a);
+ 	/* color in ch has precedence */
++	if (pair == 0) {
++	    if ((pair = GET_WINDOW_PAIR(win)) == 0)
++		pair = GetPair(win->_nc_bkgd);
++	}
++#if 0
++	if (pair > 255) {
++	    NCURSES_CH_T fixme = ch;
++	    SetPair(fixme, pair);
++	}
++#endif
+ 	AddAttr(ch, (a & COLOR_MASK(AttrOf(ch))));
++	SetPair(ch, pair);
+     }
+ 
+-    TR(TRACE_VIRTPUT, ("render_char bkg %s, attrs %s -> ch %s",
+-		       _tracech_t2(1, CHREF(win->_nc_bkgd)),
+-		       _traceattr(win->_attrs),
+-		       _tracech_t2(3, CHREF(ch))));
++    TR(TRACE_VIRTPUT,
++       ("render_char bkg %s (%d), attrs %s (%d) -> ch %s (%d)",
++	_tracech_t2(1, CHREF(win->_nc_bkgd)),
++	GetPair(win->_nc_bkgd),
++	_traceattr(win->_attrs),
++	GET_WINDOW_PAIR(win),
++	_tracech_t2(3, CHREF(ch)),
++	GetPair(ch)));
+ 
+     return (ch);
+ }
+@@ -99,9 +120,107 @@
+ #define CHECK_POSITION(win, x, y)	/* nothing */
+ #endif
+ 
++/*
++ * The _WRAPPED flag is useful only for telling an application that we've just
++ * wrapped the cursor.  We don't do anything with this flag except set it when
++ * wrapping, and clear it whenever we move the cursor.  If we try to wrap at
++ * the lower-right corner of a window, we cannot move the cursor (since that
++ * wouldn't be legal).  So we return an error (which is what SVr4 does). 
++ * Unlike SVr4, we can successfully add a character to the lower-right corner
++ * (Solaris 2.6 does this also, however).
++ */
++static int
++wrap_to_next_line(WINDOW *win)
++{
++    win->_flags |= _WRAPPED;
++    if (++win->_cury > win->_regbottom) {
++	win->_cury = win->_regbottom;
++	win->_curx = win->_maxx;
++	if (!win->_scroll)
++	    return (ERR);
++	scroll(win);
++    }
++    win->_curx = 0;
++    return (OK);
++}
++
++#if USE_WIDEC_SUPPORT
++static int waddch_literal(WINDOW *, NCURSES_CH_T);
++/*
++ * Fill the given number of cells with blanks using the current background
++ * rendition.  This saves/restores the current x-position.
++ */
++static void
++fill_cells(WINDOW *win, int count)
++{
++    NCURSES_CH_T blank = NewChar2(BLANK_TEXT, BLANK_ATTR);
++    int save_x = win->_curx;
++
++    while (count-- > 0) {
++	if (waddch_literal(win, blank) == ERR)
++	    break;
++    }
++    win->_curx = save_x;
++}
++#endif
++
++/*
++ * Build up the bytes for a multibyte character, returning the length when
++ * complete (a positive number), -1 for error and -2 for incomplete.
++ */
++#if USE_WIDEC_SUPPORT
++NCURSES_EXPORT(int)
++_nc_build_wch(WINDOW *win, ARG_CH_T ch)
++{
++    char *buffer = WINDOW_EXT(win, addch_work);
++    int len;
++    int x = win->_curx;
++    int y = win->_cury;
++    mbstate_t state;
++    wchar_t result;
++
++    if ((WINDOW_EXT(win, addch_used) != 0) &&
++	(WINDOW_EXT(win, addch_x) != x ||
++	 WINDOW_EXT(win, addch_y) != y)) {
++	/* discard the incomplete multibyte character */
++	WINDOW_EXT(win, addch_used) = 0;
++	TR(TRACE_VIRTPUT,
++	   ("Alert discarded multibyte on move (%d,%d) -> (%d,%d)",
++	    WINDOW_EXT(win, addch_y), WINDOW_EXT(win, addch_x),
++	    y, x));
++    }
++    WINDOW_EXT(win, addch_x) = x;
++    WINDOW_EXT(win, addch_y) = y;
++
++    init_mb(state);
++    buffer[WINDOW_EXT(win, addch_used)] = CharOf(CHDEREF(ch));
++    WINDOW_EXT(win, addch_used) += 1;
++    buffer[WINDOW_EXT(win, addch_used)] = '\0';
++    if ((len = mbrtowc(&result,
++		       buffer,
++		       WINDOW_EXT(win, addch_used), &state)) > 0) {
++	attr_t attrs = AttrOf(CHDEREF(ch));
++	SetChar(CHDEREF(ch), result, attrs);
++	WINDOW_EXT(win, addch_used) = 0;
++    } else {
++	if (len == -1) {
++	    /*
++	     * An error occurred.  We could either discard everything,
++	     * or assume that the error was in the previous input.
++	     * Try the latter.
++	     */
++	    TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error"));
++	    buffer[0] = CharOf(CHDEREF(ch));
++	    WINDOW_EXT(win, addch_used) = 1;
++	}
++    }
++    return len;
++}
++#endif /* USE_WIDEC_SUPPORT */
++
+ static
+ #if !USE_WIDEC_SUPPORT		/* cannot be inline if it is recursive */
+-  inline
++inline
+ #endif
+ int
+ waddch_literal(WINDOW *win, NCURSES_CH_T ch)
+@@ -115,18 +234,6 @@
+ 
+     CHECK_POSITION(win, x, y);
+ 
+-    /*
+-     * If we're trying to add a character at the lower-right corner more
+-     * than once, fail.  (Moving the cursor will clear the flag).
+-     */
+-#if 0				/* Solaris 2.6 allows updating the corner more than once */
+-    if (win->_flags & _WRAPPED) {
+-	if (x >= win->_maxx)
+-	    return (ERR);
+-	win->_flags &= ~_WRAPPED;
+-    }
+-#endif
+-
+     ch = render_char(win, ch);
+ 
+     line = win->_line + y;
+@@ -137,118 +244,120 @@
+      * Build up multibyte characters until we have a wide-character.
+      */
+     if_WIDEC({
+-	if (WINDOW_EXT(win, addch_used) == 0 && Charable(ch)) {
+-	    WINDOW_EXT(win, addch_used) = 0;
+-	} else {
+-	    char *buffer = WINDOW_EXT(win, addch_work);
+-	    int len;
+-	    mbstate_t state;
+-	    wchar_t result;
+-
+-	    if ((WINDOW_EXT(win, addch_used) != 0) &&
+-		(WINDOW_EXT(win, addch_x) != x ||
+-		 WINDOW_EXT(win, addch_y) != y)) {
+-		/* discard the incomplete multibyte character */
+-		WINDOW_EXT(win, addch_used) = 0;
+-	    }
+-	    WINDOW_EXT(win, addch_x) = x;
+-	    WINDOW_EXT(win, addch_y) = y;
++	if (WINDOW_EXT(win, addch_used) != 0 || !Charable(ch)) {
++	    int len = _nc_build_wch(win, CHREF(ch));
+ 
+-	    memset(&state, 0, sizeof(state));
+-	    buffer[WINDOW_EXT(win, addch_used)] = CharOf(ch);
+-	    WINDOW_EXT(win, addch_used) += 1;
+-	    buffer[WINDOW_EXT(win, addch_used)] = '\0';
+-	    if ((len = mbrtowc(&result,
+-			       buffer,
+-			       WINDOW_EXT(win, addch_used), &state)) > 0) {
+-		attr_t attrs = AttrOf(ch);
+-		SetChar(ch, result, attrs);
+-		WINDOW_EXT(win, addch_used) = 0;
+-		if (CharOf(ch) < 256) {
++	    if (len > 0) {
++		if (is8bits(CharOf(ch))) {
+ 		    const char *s = unctrl(CharOf(ch));
+ 		    if (s[1] != 0) {
+ 			return waddstr(win, s);
+ 		    }
+ 		}
+ 	    } else {
+-		if (len == -1) {
+-		    /*
+-		     * An error occurred.  We could either discard everything,
+-		     * or assume that the error was in the previous input.
+-		     * Try the latter.
+-		     */
+-		    TR(TRACE_VIRTPUT, ("Alert! mbrtowc returns error"));
+-		    buffer[0] = CharOf(ch);
+-		    WINDOW_EXT(win, addch_used) = 1;
+-		}
+ 		return OK;
+ 	    }
+ 	}
+     });
+ 
+     /*
+-     * Handle non-spacing characters
++     * Non-spacing characters are added to the current cell.
++     *
++     * Spacing characters that are wider than one column require some display
++     * adjustments.
+      */
+     if_WIDEC({
+-	if (wcwidth(CharOf(ch)) == 0) {
+-	    int i;
++	int len = wcwidth(CharOf(ch));
++	int i;
++	int j;
++
++	if (len == 0) {		/* non-spacing */
+ 	    if ((x > 0 && y >= 0)
+ 		|| ((y = win->_cury - 1) >= 0 &&
+ 		    (x = win->_maxx) > 0)) {
+ 		wchar_t *chars = (win->_line[y].text[x - 1].chars);
+ 		for (i = 0; i < CCHARW_MAX; ++i) {
+ 		    if (chars[i] == 0) {
++			TR(TRACE_VIRTPUT,
++			   ("added non-spacing %d: %x",
++			    x, (int) CharOf(ch)));
+ 			chars[i] = CharOf(ch);
+ 			break;
+ 		    }
+ 		}
+ 	    }
+ 	    goto testwrapping;
++	} else if (len > 1) {	/* multi-column characters */
++	    /*
++	     * Check if the character will fit on the current line.  If it does
++	     * not fit, fill in the remainder of the line with blanks.  and
++	     * move to the next line.
++	     */
++	    if (len > win->_maxx) {
++		TR(TRACE_VIRTPUT, ("character will not fit"));
++		return ERR;
++	    } else if (x + len > win->_maxx) {
++		int count = win->_maxx + 1 - x;
++		TR(TRACE_VIRTPUT, ("fill %d remaining cells", count));
++		fill_cells(win, count);
++		if (wrap_to_next_line(win) == ERR)
++		    return ERR;
++		x = win->_curx;
++		y = win->_cury;
++	    }
++	    /*
++	     * Check for cells which are orphaned by adding this character, set
++	     * those to blanks.
++	     *
++	     * FIXME: this actually could fill j-i cells, more complicated to
++	     * setup though.
++	     */
++	    for (i = 0; i < len; ++i) {
++		if (isWidecBase(win->_line[y].text[i])) {
++		    break;
++		} else if (isWidecExt(win->_line[y].text[x + i])) {
++		    for (j = i; x + j <= win->_maxx; ++j) {
++			if (!isWidecExt(win->_line[y].text[x + j])) {
++			    TR(TRACE_VIRTPUT, ("fill %d orphan cells", j));
++			    fill_cells(win, j);
++			    break;
++			}
++		    }
++		    break;
++		}
++	    }
++	    /*
++	     * Finally, add the cells for this character.
++	     */
++	    for (i = 0; i < len; ++i) {
++		NCURSES_CH_T value = ch;
++		SetWidecExt(value, i);
++		TR(TRACE_VIRTPUT, ("multicolumn %d:%d", i + 1, len));
++		line->text[x] = value;
++		CHANGED_CELL(line, x);
++		++x;
++	    }
++	    goto testwrapping;
+ 	}
+     });
++
++    /*
++     * Single-column characters.
++     */
+     line->text[x++] = ch;
+     /*
+-     * Provide for multi-column characters
++     * This label is used only for wide-characters.
+      */
+-    if_WIDEC({
+-	int len = wcwidth(CharOf(ch));
+-	while (len-- > 1) {
+-	    if (x + (len - 1) > win->_maxx) {
+-		NCURSES_CH_T blank = NewChar2(BLANK_TEXT, BLANK_ATTR);
+-		AddAttr(blank, AttrOf(ch));
+-		if (waddch_literal(win, blank) != ERR)
+-		    return waddch_literal(win, ch);
+-		return ERR;
+-	    }
+-	    AddAttr(line->text[x++], WA_NAC);
+-	    TR(TRACE_VIRTPUT, ("added NAC %d", x - 1));
+-	}
+-    }
++    if_WIDEC(
+   testwrapping:
+     );
+ 
+-    TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracech_t(CHREF(ch))));
++    TR(TRACE_VIRTPUT, ("cell (%d, %d..%d) = %s",
++		       win->_cury, win->_curx, x - 1,
++		       _tracech_t(CHREF(ch))));
++
+     if (x > win->_maxx) {
+-	/*
+-	 * The _WRAPPED flag is useful only for telling an application that
+-	 * we've just wrapped the cursor.  We don't do anything with this flag
+-	 * except set it when wrapping, and clear it whenever we move the
+-	 * cursor.  If we try to wrap at the lower-right corner of a window, we
+-	 * cannot move the cursor (since that wouldn't be legal).  So we return
+-	 * an error (which is what SVr4 does).  Unlike SVr4, we can
+-	 * successfully add a character to the lower-right corner (Solaris 2.6
+-	 * does this also, however).
+-	 */
+-	win->_flags |= _WRAPPED;
+-	if (++win->_cury > win->_regbottom) {
+-	    win->_cury = win->_regbottom;
+-	    win->_curx = win->_maxx;
+-	    if (!win->_scroll)
+-		return (ERR);
+-	    scroll(win);
+-	}
+-	win->_curx = 0;
+-	return (OK);
++	return wrap_to_next_line(win);
+     }
+     win->_curx = x;
+     return OK;
+@@ -269,12 +378,12 @@
+      */
+     if ((AttrOf(ch) & A_ALTCHARSET)
+ 	|| ((s = unctrl(t))[1] == 0 ||
+-		(
++	    (
+ 		isprint(t)
+ #if USE_WIDEC_SUPPORT
+ 		|| WINDOW_EXT(win, addch_used)
+ #endif
+-		)))
++	    )))
+ 	return waddch_literal(win, ch);
+ 
+     /*
+Index: ncurses/base/lib_addstr.c
+Prereq:  1.39 
+--- ncurses-5.4-20040208/ncurses/base/lib_addstr.c	2003-12-06 18:04:33.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_addstr.c	2004-12-12 00:15:31.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -30,7 +30,7 @@
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+  *                                                                          *
+- *  Rewritten 2001-2002 to support wide-characters by                       *
++ *  Rewritten 2001-2004 to support wide-characters by                       *
+  *	Sven Verdoolaege                                                    *
+  *	Thomas Dickey                                                       *
+  ****************************************************************************/
+@@ -44,7 +44,7 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_addstr.c,v 1.39 2003/12/06 18:04:33 tom Exp $")
++MODULE_ID("$Id: lib_addstr.c,v 1.43 2004/12/12 00:15:31 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ waddnstr(WINDOW *win, const char *astr, int n)
+@@ -119,7 +119,7 @@
+ #if USE_WIDEC_SUPPORT
+ 
+ NCURSES_EXPORT(int)
+-_nc_wchstrlen(const cchar_t * s)
++_nc_wchstrlen(const cchar_t *s)
+ {
+     int result = 0;
+     while (CharOf(s[result]) != L'\0') {
+@@ -129,13 +129,14 @@
+ }
+ 
+ NCURSES_EXPORT(int)
+-wadd_wchnstr(WINDOW *win, const cchar_t * astr, int n)
++wadd_wchnstr(WINDOW *win, const cchar_t *astr, int n)
+ {
++    NCURSES_CH_T blank = NewChar(BLANK_TEXT);
+     NCURSES_SIZE_T y = win->_cury;
+     NCURSES_SIZE_T x = win->_curx;
+     int code = OK;
+     struct ldat *line;
+-    int i, start, end;
++    int i, j, start, len, end;
+ 
+     T((T_CALLED("wadd_wchnstr(%p,%s,%d)"), win, _nc_viscbuf(astr, n), n));
+ 
+@@ -153,22 +154,58 @@
+     line = &(win->_line[y]);
+     start = x;
+     end = x + n - 1;
+-    if (isnac(line->text[x])) {
+-	line->text[x - 1] = win->_nc_bkgd;
+-	--start;
++
++    /*
++     * Reset orphaned cells of multi-column characters that extend up to the
++     * new string's location to blanks.
++     */
++    if (x > 0 && isWidecExt(line->text[x])) {
++	for (i = 0; i <= x; ++i) {
++	    if (!isWidecExt(line->text[x - i])) {
++		/* must be isWidecBase() */
++		start -= i;
++		while (i > 0) {
++		    line->text[x - i--] = _nc_render(win, blank);
++		}
++		break;
++	    }
++	}
+     }
++
++    /*
++     * Copy the new string to the window.
++     */
+     for (i = 0; i < n && x <= win->_maxx; ++i) {
+-	line->text[x++] = astr[i];
+-	if (wcwidth(CharOf(astr[i])) > 1) {
+-	    if (x <= win->_maxx)
+-		AddAttr(line->text[x++], WA_NAC);
+-	    else
+-		line->text[x - 1] = win->_nc_bkgd;
++	if (isWidecExt(astr[i]))
++	    continue;
++
++	len = wcwidth(CharOf(astr[i]));
++
++	if (x + len - 1 <= win->_maxx) {
++	    line->text[x] = _nc_render(win, astr[i]);
++	    if (len > 1) {
++		for (j = 0; j < len; ++j) {
++		    if (j != 0) {
++			line->text[x + j] = line->text[x];
++		    }
++		    SetWidecExt(line->text[x + j], j);
++		}
++	    }
++	    x += len;
++	    end += len - 1;
++	} else {
++	    break;
+ 	}
+     }
+-    if (x <= win->_maxx && isnac(line->text[x])) {
+-	line->text[x] = win->_nc_bkgd;
++
++    /*
++     * Set orphaned cells of multi-column characters which lie after the new
++     * string to blanks.
++     */
++    while (x <= win->_maxx && isWidecExt(line->text[x])) {
++	line->text[x] = _nc_render(win, blank);
+ 	++end;
++	++x;
+     }
+     CHANGED_RANGE(line, start, end);
+ 
+@@ -177,7 +214,7 @@
+ }
+ 
+ NCURSES_EXPORT(int)
+-waddnwstr(WINDOW *win, const wchar_t * str, int n)
++waddnwstr(WINDOW *win, const wchar_t *str, int n)
+ {
+     int code = ERR;
+ 
+Index: ncurses/base/lib_bkgd.c
+Prereq:  1.30 
+--- ncurses-5.4-20040208/ncurses/base/lib_bkgd.c	2003-07-05 16:46:49.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_bkgd.c	2005-01-29 18:51:38.000000000 +0000
+@@ -29,11 +29,14 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *     and: Juergen Pfeifer                         1997                    *
++ *     and: Sven Verdoolaege                        2000                    *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_bkgd.c,v 1.30 2003/07/05 16:46:49 tom Exp $")
++MODULE_ID("$Id: lib_bkgd.c,v 1.31 2005/01/29 18:51:38 tom Exp $")
+ 
+ /*
+  * Set the window's background information.
+@@ -54,10 +57,23 @@
+ 	toggle_attr_off(win->_attrs, off);
+ 	toggle_attr_on(win->_attrs, on);
+ 
+-	if (CharOf(CHDEREF(ch)) == L('\0'))
++#if NCURSES_EXT_COLORS
++	{
++	    int pair;
++
++	    if ((pair = GetPair(win->_nc_bkgd)) != 0)
++		SET_WINDOW_PAIR(win, 0);
++	    if ((pair = GetPair(CHDEREF(ch))) != 0)
++		SET_WINDOW_PAIR(win, pair);
++	}
++#endif
++
++	if (CharOf(CHDEREF(ch)) == L('\0')) {
+ 	    SetChar(win->_nc_bkgd, BLANK_TEXT, AttrOf(CHDEREF(ch)));
+-	else
++	    SetPair(win->_nc_bkgd, GetPair(CHDEREF(ch)));
++	} else {
+ 	    win->_nc_bkgd = CHDEREF(ch);
++	}
+ #if USE_WIDEC_SUPPORT
+ 	/*
+ 	 * If we're compiled for wide-character support, _bkgrnd is the
+@@ -72,7 +88,9 @@
+ 	    wgetbkgrnd(win, &wch);
+ 	    tmp = _nc_to_char(CharOf(wch));
+ 
+-	    win->_bkgd = ((tmp == EOF) ? ' ' : (chtype) tmp) | AttrOf(wch);
++	    win->_bkgd = (((tmp == EOF) ? ' ' : (chtype) tmp)
++			  | (AttrOf(wch) & ALL_BUT_COLOR)
++			  | COLOR_PAIR(GET_WINDOW_PAIR(win)));
+ 	}
+ #endif
+     }
+Index: ncurses/base/lib_chgat.c
+Prereq:  1.5 
+--- ncurses-5.4-20040208/ncurses/base/lib_chgat.c	2001-06-03 00:05:02.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_chgat.c	2005-01-29 21:46:12.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2001,2005 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,8 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *     and: Sven Verdoolaege                        2001                    *
++ *     and: Thomas E. Dickey                        2005                    *
+  ****************************************************************************/
+ 
+ /*
+@@ -40,11 +42,10 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_chgat.c,v 1.5 2001/06/03 00:05:02 skimo Exp $")
++MODULE_ID("$Id: lib_chgat.c,v 1.6 2005/01/29 21:46:12 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-wchgat
+-(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
++wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
+ {
+     int i;
+ 
+@@ -53,8 +54,10 @@
+     if (win) {
+ 	toggle_attr_on(attr, COLOR_PAIR(color));
+ 
+-	for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++)
++	for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++) {
+ 	    SetAttr(win->_line[win->_cury].text[i], attr);
++	    SetPair(win->_line[win->_cury].text[i], color);
++	}
+ 
+ 	returnCode(OK);
+     } else
+Index: ncurses/base/lib_color.c
+Prereq:  1.62 
+--- ncurses-5.4-20040208/ncurses/base/lib_color.c	2002-09-28 20:40:05.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_color.c	2005-01-29 14:30:54.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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                 *
+  ****************************************************************************/
+ 
+ /* lib_color.c
+@@ -41,7 +42,7 @@
+ #include <term.h>
+ #include <tic.h>
+ 
+-MODULE_ID("$Id: lib_color.c,v 1.62 2002/09/28 20:40:05 tom Exp $")
++MODULE_ID("$Id: lib_color.c,v 1.72 2005/01/29 14:30:54 tom Exp $")
+ 
+ /*
+  * These should be screen structure members.  They need to be globals for
+@@ -53,6 +54,8 @@
+ 
+ #define DATA(r,g,b) {r,g,b, 0,0,0, 0}
+ 
++#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
++
+ /*
+  * Given a RGB range of 0..1000, we'll normally set the individual values
+  * to about 2/3 of the maximum, leaving full-range for bold/bright colors.
+@@ -222,7 +225,11 @@
+ 
+     T((T_CALLED("start_color()")));
+ 
+-    if (!SP->_coloron) {
++    if (SP == 0) {
++	result = ERR;
++    } else if (SP->_coloron) {
++	result = OK;
++    } else {
+ 
+ 	if (reset_color_pair() != TRUE) {
+ 	    set_foreground_color(default_fg(), _nc_outch);
+@@ -233,9 +240,10 @@
+ 	    COLOR_PAIRS = SP->_pair_count = max_pairs;
+ 	    COLORS = SP->_color_count = max_colors;
+ 
+-	    if ((SP->_color_pairs = typeCalloc(unsigned short,
+-					         (unsigned) max_pairs)) != 0) {
+-		if ((SP->_color_table = typeCalloc(color_t, max_colors)) != 0) {
++	    if ((SP->_color_pairs = TYPE_CALLOC(colorpair_t,
++						max_pairs)) != 0) {
++		if ((SP->_color_table = TYPE_CALLOC(color_t,
++						    max_colors)) != 0) {
+ 		    SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
+ 		    init_color_table();
+ 
+@@ -244,7 +252,7 @@
+ 
+ 		    SP->_coloron = 1;
+ 		    result = OK;
+-		} else {
++		} else if (SP->_color_pairs != 0) {
+ 		    FreeAndNull(SP->_color_pairs);
+ 		}
+ 	    }
+@@ -298,21 +306,21 @@
+ NCURSES_EXPORT(int)
+ init_pair(short pair, short f, short b)
+ {
+-    unsigned result;
++    colorpair_t result;
+ 
+     T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
+ 
+-    if ((pair < 0) || (pair >= COLOR_PAIRS))
++    if ((pair < 0) || (pair >= COLOR_PAIRS) || SP == 0 || !SP->_coloron)
+ 	returnCode(ERR);
+ #if NCURSES_EXT_FUNCS
+     if (SP->_default_color) {
+ 	if (f < 0)
+-	    f = C_MASK;
++	    f = COLOR_DEFAULT;
+ 	if (b < 0)
+-	    b = C_MASK;
+-	if (f >= COLORS && f != C_MASK)
++	    b = COLOR_DEFAULT;
++	if (f >= COLORS && !isDefaultColor(f))
+ 	    returnCode(ERR);
+-	if (b >= COLORS && b != C_MASK)
++	if (b >= COLORS && !isDefaultColor(b))
+ 	    returnCode(ERR);
+     } else
+ #endif
+@@ -332,13 +340,12 @@
+     if (SP->_color_pairs[pair] != 0
+ 	&& SP->_color_pairs[pair] != result) {
+ 	int y, x;
+-	attr_t z = COLOR_PAIR(pair);
+ 
+ 	for (y = 0; y <= curscr->_maxy; y++) {
+ 	    struct ldat *ptr = &(curscr->_line[y]);
+ 	    bool changed = FALSE;
+ 	    for (x = 0; x <= curscr->_maxx; x++) {
+-		if ((AttrOf(ptr->text[x]) & A_COLOR) == z) {
++		if (GetPair(ptr->text[x]) == pair) {
+ 		    /* Set the old cell to zero to ensure it will be
+ 		       updated on the next doupdate() */
+ 		    SetChar(ptr->text[x], 0, 0);
+@@ -351,8 +358,8 @@
+ 	}
+     }
+     SP->_color_pairs[pair] = result;
+-    if ((int) (SP->_current_attr & A_COLOR) == COLOR_PAIR(pair))
+-	SP->_current_attr |= A_COLOR;	/* force attribute update */
++    if (GET_SCREEN_PAIR(SP) == pair)
++	SET_SCREEN_PAIR(SP, ~0);	/* force attribute update */
+ 
+     if (initialize_pair) {
+ 	const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
+@@ -374,7 +381,7 @@
+     returnCode(OK);
+ }
+ 
+-#define okRGB(n) ((n) >= 0 && (n) < 1000)
++#define okRGB(n) ((n) >= 0 && (n) <= 1000)
+ 
+ NCURSES_EXPORT(int)
+ init_color(short color, short r, short g, short b)
+@@ -384,6 +391,8 @@
+     T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
+ 
+     if (initialize_color != NULL
++	&& SP != 0
++	&& SP->_coloron
+ 	&& (color >= 0 && color < COLORS)
+ 	&& (okRGB(r) && okRGB(g) && okRGB(b))) {
+ 
+@@ -433,43 +442,75 @@
+ NCURSES_EXPORT(int)
+ color_content(short color, short *r, short *g, short *b)
+ {
++    int result;
++
+     T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b));
+-    if (color < 0 || color >= COLORS)
+-	returnCode(ERR);
++    if (color < 0 || color >= COLORS || SP == 0 || !SP->_coloron) {
++	result = ERR;
++    } else {
++	NCURSES_COLOR_T c_r = SP->_color_table[color].red;
++	NCURSES_COLOR_T c_g = SP->_color_table[color].green;
++	NCURSES_COLOR_T c_b = SP->_color_table[color].blue;
++
++	if (r)
++	    *r = c_r;
++	if (g)
++	    *g = c_g;
++	if (b)
++	    *b = c_b;
+ 
+-    if (r)
+-	*r = SP->_color_table[color].red;
+-    if (g)
+-	*g = SP->_color_table[color].green;
+-    if (b)
+-	*b = SP->_color_table[color].blue;
+-    T(("...color_content(%d,%d,%d,%d)", color, *r, *g, *b));
+-    returnCode(OK);
++	T(("...color_content(%d,%d,%d,%d)", color, c_r, c_g, c_b));
++	result = OK;
++    }
++    returnCode(result);
+ }
+ 
+ NCURSES_EXPORT(int)
+ pair_content(short pair, short *f, short *b)
+ {
++    int result;
++
+     T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b));
+ 
+-    if ((pair < 0) || (pair >= COLOR_PAIRS))
+-	returnCode(ERR);
+-    if (f)
+-	*f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
+-    if (b)
+-	*b = (SP->_color_pairs[pair] & C_MASK);
++    if ((pair < 0) || (pair >= COLOR_PAIRS) || SP == 0 || !SP->_coloron) {
++	result = ERR;
++    } else {
++	NCURSES_COLOR_T fg = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
++	NCURSES_COLOR_T bg = (SP->_color_pairs[pair] & C_MASK);
+ 
+-    T(("...pair_content(%d,%d,%d)", pair, *f, *b));
+-    returnCode(OK);
++#if NCURSES_EXT_FUNCS
++	if (fg == COLOR_DEFAULT)
++	    fg = -1;
++	if (bg == COLOR_DEFAULT)
++	    bg = -1;
++#endif
++
++	if (f)
++	    *f = fg;
++	if (b)
++	    *b = bg;
++
++	T(("...pair_content(%d,%d,%d)", pair, fg, bg));
++	result = OK;
++    }
++    returnCode(result);
+ }
+ 
++#define isDefaultPair(pair) ((pair) == 0)
++
+ NCURSES_EXPORT(void)
+ _nc_do_color(int old_pair, int pair, bool reverse, int (*outc) (int))
+ {
+-    NCURSES_COLOR_T fg = C_MASK, bg = C_MASK;
++    NCURSES_COLOR_T fg = COLOR_DEFAULT;
++    NCURSES_COLOR_T bg = COLOR_DEFAULT;
+     NCURSES_COLOR_T old_fg, old_bg;
+ 
+-    if (pair < 0 || pair >= COLOR_PAIRS) {
++    if (pair < 0 ||
++	pair >= COLOR_PAIRS ||
++	((isDefaultPair(old_pair) &&
++	  isDefaultPair(pair)) &&
++	 (no_color_video <= 0 ||
++	  (no_color_video & 4) == 0))) {
+ 	return;
+     } else if (pair != 0) {
+ 	if (set_color_pair) {
+@@ -484,17 +525,21 @@
+     if (old_pair >= 0
+ 	&& SP != 0
+ 	&& pair_content(old_pair, &old_fg, &old_bg) != ERR) {
+-	if ((fg == C_MASK && old_fg != C_MASK)
+-	    || (bg == C_MASK && old_bg != C_MASK)) {
++	if ((isDefaultColor(fg) && !isDefaultColor(old_fg))
++	    || (isDefaultColor(bg) && !isDefaultColor(old_bg))) {
+ #if NCURSES_EXT_FUNCS
+ 	    /*
+ 	     * A minor optimization - but extension.  If "AX" is specified in
+ 	     * the terminal description, treat it as screen's indicator of ECMA
+ 	     * SGR 39 and SGR 49, and assume the two sequences are independent.
+ 	     */
+-	    if (SP->_has_sgr_39_49 && old_bg == C_MASK && old_fg != C_MASK) {
++	    if (SP->_has_sgr_39_49
++		&& isDefaultColor(old_bg)
++		&& !isDefaultColor(old_fg)) {
+ 		tputs("\033[39m", 1, outc);
+-	    } else if (SP->_has_sgr_39_49 && old_fg == C_MASK && old_bg != C_MASK) {
++	    } else if (SP->_has_sgr_39_49
++		       && isDefaultColor(old_fg)
++		       && !isDefaultColor(old_bg)) {
+ 		tputs("\033[49m", 1, outc);
+ 	    } else
+ #endif
+@@ -507,9 +552,9 @@
+     }
+ 
+ #if NCURSES_EXT_FUNCS
+-    if (fg == C_MASK)
++    if (isDefaultColor(fg))
+ 	fg = default_fg();
+-    if (bg == C_MASK)
++    if (isDefaultColor(bg))
+ 	bg = default_bg();
+ #endif
+ 
+@@ -522,10 +567,10 @@
+     TR(TRACE_ATTRS, ("setting colors: pair = %d, fg = %d, bg = %d", pair,
+ 		     fg, bg));
+ 
+-    if (fg != C_MASK) {
++    if (!isDefaultColor(fg)) {
+ 	set_foreground_color(fg, outc);
+     }
+-    if (bg != C_MASK) {
++    if (!isDefaultColor(bg)) {
+ 	set_background_color(bg, outc);
+     }
+ }
+Index: ncurses/base/lib_colorset.c
+Prereq:  1.10 
+--- ncurses-5.4-20040208/ncurses/base/lib_colorset.c	2003-12-07 00:15:27.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_colorset.c	2005-01-29 21:40:51.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2005 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            *
+@@ -27,7 +27,8 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Juergen Pfeifer, 1998                                           *
++ *  Author: Juergen Pfeifer,  1998                                          *
++ *     and: Thomas E. Dickey, 2005                                          *
+  ****************************************************************************/
+ 
+ /*
+@@ -40,7 +41,7 @@
+ #include <curses.priv.h>
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_colorset.c,v 1.10 2003/12/07 00:15:27 tom Exp $")
++MODULE_ID("$Id: lib_colorset.c,v 1.11 2005/01/29 21:40:51 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ wcolor_set(WINDOW *win, short color_pair_number, void *opts)
+@@ -50,9 +51,9 @@
+ 	&& !opts
+ 	&& (color_pair_number >= 0)
+ 	&& (color_pair_number < COLOR_PAIRS)) {
+-	TR(TRACE_ATTRS, ("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
+-	win->_attrs &= ALL_BUT_COLOR;
+-	win->_attrs |= COLOR_PAIR(color_pair_number);
++	TR(TRACE_ATTRS, ("... current %ld", (long) GET_WINDOW_PAIR(win)));
++	SET_WINDOW_PAIR(win, color_pair_number);
++	if_EXT_COLORS(win->_color = color_pair_number);
+ 	returnCode(OK);
+     } else
+ 	returnCode(ERR);
+Index: ncurses/base/lib_dft_fgbg.c
+Prereq:  1.15 
+--- ncurses-5.4-20040208/ncurses/base/lib_dft_fgbg.c	2000-12-10 02:43:27.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_dft_fgbg.c	2005-01-29 21:42:15.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -27,13 +27,13 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey <dickey@clark.net> 1997,1999                   *
++ *  Author: Thomas E. Dickey                                                *
+  ****************************************************************************/
+ 
+ #include <curses.priv.h>
+ #include <term.h>
+ 
+-MODULE_ID("$Id: lib_dft_fgbg.c,v 1.15 2000/12/10 02:43:27 tom Exp $")
++MODULE_ID("$Id: lib_dft_fgbg.c,v 1.17 2005/01/29 21:42:15 tom Exp $")
+ 
+ /*
+  * Modify the behavior of color-pair 0 so that the library doesn't assume that
+@@ -43,7 +43,7 @@
+ use_default_colors(void)
+ {
+     T((T_CALLED("use_default_colors()")));
+-    returnCode(assume_default_colors(C_MASK, C_MASK));
++    returnCode(assume_default_colors(-1, -1));
+ }
+ 
+ /*
+@@ -61,11 +61,15 @@
+     if (initialize_pair)	/* don't know how to handle this */
+ 	returnCode(ERR);
+ 
+-    SP->_default_color = (fg < 0 || fg == C_MASK) || (bg < 0 || bg == C_MASK);
++    SP->_default_color = isDefaultColor(fg) || isDefaultColor(bg);
+     SP->_has_sgr_39_49 = (tigetflag("AX") == TRUE);
+-    SP->_default_fg = (fg >= 0) ? (fg & C_MASK) : C_MASK;
+-    SP->_default_bg = (bg >= 0) ? (bg & C_MASK) : C_MASK;
+-    if (SP->_color_pairs != 0)
++    SP->_default_fg = isDefaultColor(fg) ? COLOR_DEFAULT : (fg & C_MASK);
++    SP->_default_bg = isDefaultColor(bg) ? COLOR_DEFAULT : (bg & C_MASK);
++    if (SP->_color_pairs != 0) {
++	bool save = SP->_default_color;
++	SP->_default_color = TRUE;
+ 	init_pair(0, fg, bg);
++	SP->_default_color = save;
++    }
+     returnCode(OK);
+ }
+Index: ncurses/base/lib_freeall.c
+Prereq:  1.26 
+--- ncurses-5.4-20040208/ncurses/base/lib_freeall.c	2003-12-27 18:21:57.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_freeall.c	2005-01-22 22:19:28.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,6 +32,7 @@
+ 
+ #include <curses.priv.h>
+ #include <term_entry.h>
++#include <tic.h>
+ 
+ #if HAVE_NC_FREEALL
+ 
+@@ -39,7 +40,7 @@
+ extern int malloc_errfd;	/* FIXME */
+ #endif
+ 
+-MODULE_ID("$Id: lib_freeall.c,v 1.26 2003/12/27 18:21:57 tom Exp $")
++MODULE_ID("$Id: lib_freeall.c,v 1.32 2005/01/22 22:19:28 tom Exp $")
+ 
+ /*
+  * Free all ncurses data.  This is used for testing only (there's no practical
+@@ -54,7 +55,9 @@
+     T((T_CALLED("_nc_freeall()")));
+ #if NO_LEAKS
+     _nc_free_tparm();
+-    FreeAndNull(_nc_oldnums);
++    if (_nc_oldnums != 0) {
++	FreeAndNull(_nc_oldnums);
++    }
+ #endif
+     if (SP != 0) {
+ 	while (_nc_windows != 0) {
+@@ -82,6 +85,11 @@
+ 
+     del_curterm(cur_term);
+     _nc_free_entries(_nc_head);
++    _nc_get_type(0);
++    _nc_first_name(0);
++#if USE_WIDEC_SUPPORT
++    FreeIfNeeded(_nc_wacs);
++#endif
+ 
+     if ((s = _nc_home_terminfo()) != 0)
+ 	free(s);
+@@ -94,6 +102,8 @@
+ #if HAVE_LIBDBMALLOC
+     malloc_dump(malloc_errfd);
+ #elif HAVE_LIBDMALLOC
++#elif HAVE_LIBMPATROL
++    __mp_summary();
+ #elif HAVE_PURIFY
+     purify_all_inuse();
+ #endif
+Index: ncurses/base/lib_getch.c
+Prereq:  1.71 
+--- ncurses-5.4-20040208/ncurses/base/lib_getch.c	2003-05-17 23:49:28.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_getch.c	2005-01-22 22:05:39.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -40,7 +41,7 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_getch.c,v 1.71 2003/05/17 23:49:28 tom Exp $")
++MODULE_ID("$Id: lib_getch.c,v 1.72 2005/01/22 22:05:39 tom Exp $")
+ 
+ #include <fifo_defs.h>
+ 
+@@ -466,7 +467,7 @@
+     T((T_CALLED("wgetch(%p)"), win));
+     code = _nc_wgetch(win,
+ 		      &value,
+-		      SP->_use_meta
++		      (SP ? SP->_use_meta : 0)
+ 		      EVENTLIST_2nd((_nc_eventlist *) 0));
+     if (code != ERR)
+ 	code = value;
+Index: ncurses/base/lib_insch.c
+Prereq:  1.18 
+--- ncurses-5.4-20040208/ncurses/base/lib_insch.c	2002-11-23 21:41:05.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_insch.c	2005-02-26 19:27:28.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -43,22 +43,26 @@
+ #include <curses.priv.h>
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_insch.c,v 1.18 2002/11/23 21:41:05 tom Exp $")
++MODULE_ID("$Id: lib_insch.c,v 1.24 2005/02/26 19:27:28 tom Exp $")
+ 
+ /*
+  * Insert the given character, updating the current location to simplify
+  * inserting a string.
+  */
+-void
++NCURSES_EXPORT(int)
+ _nc_insert_ch(WINDOW *win, chtype ch)
+ {
++    int code = OK;
+     NCURSES_CH_T wch;
+     int count;
++    NCURSES_CONST char *s;
+ 
+     switch (ch) {
+     case '\t':
+-	for (count = (TABSIZE - (win->_curx % TABSIZE)); count > 0; count--)
+-	    _nc_insert_ch(win, ' ');
++	for (count = (TABSIZE - (win->_curx % TABSIZE)); count > 0; count--) {
++	    if ((code = _nc_insert_ch(win, ' ')) != OK)
++		break;
++	}
+ 	break;
+     case '\n':
+     case '\r':
+@@ -67,27 +71,49 @@
+ 	_nc_waddch_nosync(win, wch);
+ 	break;
+     default:
+-	if (is7bits(ch) && iscntrl(ch)) {
+-	    _nc_insert_ch(win, '^');
+-	    _nc_insert_ch(win, '@' + (ch));
+-	} else if (win->_curx <= win->_maxx) {
+-	    struct ldat *line = &(win->_line[win->_cury]);
+-	    NCURSES_CH_T *end = &(line->text[win->_curx]);
+-	    NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
+-	    NCURSES_CH_T *temp2 = temp1 - 1;
+-
++	if (
++#if USE_WIDEC_SUPPORT
++	       WINDOW_EXT(win, addch_used) == 0 &&
++#endif
++	       is8bits(ChCharOf(ch)) &&
++	       isprint(ChCharOf(ch))) {
++	    if (win->_curx <= win->_maxx) {
++		struct ldat *line = &(win->_line[win->_cury]);
++		NCURSES_CH_T *end = &(line->text[win->_curx]);
++		NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
++		NCURSES_CH_T *temp2 = temp1 - 1;
++
++		SetChar2(wch, ch);
++
++		CHANGED_TO_EOL(line, win->_curx, win->_maxx);
++		while (temp1 > end)
++		    *temp1-- = *temp2--;
++
++		*temp1 = _nc_render(win, wch);
++		win->_curx++;
++	    }
++	} else if (is8bits(ChCharOf(ch)) && iscntrl(ChCharOf(ch))) {
++	    s = unctrl(ChCharOf(ch));
++	    while (*s != '\0') {
++		if ((code = _nc_insert_ch(win, ChAttrOf(ch) | UChar(*s))) != OK)
++		    break;
++		++s;
++	    }
++	}
++#if USE_WIDEC_SUPPORT
++	else {
++	    /*
++	     * Handle multibyte characters here
++	     */
+ 	    SetChar2(wch, ch);
+-
+-	    CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+-	    while (temp1 > end)
+-		*temp1-- = *temp2--;
+-
+-	    *temp1 = _nc_render(win, wch);
+-
+-	    win->_curx++;
++	    wch = _nc_render(win, wch);
++	    if (_nc_build_wch(win, &wch) >= 0)
++		code = wins_wch(win, &wch);
+ 	}
++#endif
+ 	break;
+     }
++    return code;
+ }
+ 
+ NCURSES_EXPORT(int)
+@@ -103,37 +129,11 @@
+ 	oy = win->_cury;
+ 	ox = win->_curx;
+ 
+-	_nc_insert_ch(win, c);
+-
+-	win->_curx = ox;
+-	win->_cury = oy;
+-	_nc_synchook(win);
+-	code = OK;
+-    }
+-    returnCode(code);
+-}
+-
+-NCURSES_EXPORT(int)
+-winsnstr(WINDOW *win, const char *s, int n)
+-{
+-    int code = ERR;
+-    NCURSES_SIZE_T oy;
+-    NCURSES_SIZE_T ox;
+-    const unsigned char *str = (const unsigned char *) s;
+-    const unsigned char *cp;
+-
+-    T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s, n), n));
++	code = _nc_insert_ch(win, c);
+ 
+-    if (win != 0 && str != 0) {
+-	oy = win->_cury;
+-	ox = win->_curx;
+-	for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
+-	    _nc_insert_ch(win, (chtype) UChar(*cp));
+-	}
+ 	win->_curx = ox;
+ 	win->_cury = oy;
+ 	_nc_synchook(win);
+-	code = OK;
+     }
+     returnCode(code);
+ }
+Index: ncurses/base/lib_insnstr.c
+--- /dev/null	2004-09-12 00:40:36.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_insnstr.c	2004-02-28 23:44:56.000000000 +0000
+@@ -0,0 +1,68 @@
++/****************************************************************************
++ * Copyright (c) 2004 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"), to deal in the Software without restriction, including      *
++ * without limitation the rights to use, copy, modify, merge, publish,      *
++ * distribute, distribute with modifications, sublicense, and/or sell       *
++ * copies of the Software, and to permit persons to whom the Software is    *
++ * furnished to do so, subject to the following conditions:                 *
++ *                                                                          *
++ * The above copyright notice and this permission notice shall be included  *
++ * in all copies or substantial portions of the Software.                   *
++ *                                                                          *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
++ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
++ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
++ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
++ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
++ *                                                                          *
++ * Except as contained in this notice, the name(s) of the above copyright   *
++ * holders shall not be used in advertising or otherwise to promote the     *
++ * sale, use or other dealings in this Software without prior written       *
++ * authorization.                                                           *
++ ****************************************************************************/
++
++/****************************************************************************
++ *  Author: Thomas E. Dickey                                                *
++ ****************************************************************************/
++
++/*
++**	lib_insnstr.c
++**
++**	The routine winsnstr().
++**
++*/
++
++#include <curses.priv.h>
++#include <ctype.h>
++
++MODULE_ID("$Id: lib_insnstr.c,v 1.1 2004/02/28 23:44:56 tom Exp $")
++
++NCURSES_EXPORT(int)
++winsnstr(WINDOW *win, const char *s, int n)
++{
++    int code = ERR;
++    NCURSES_SIZE_T oy;
++    NCURSES_SIZE_T ox;
++    const unsigned char *str = (const unsigned char *) s;
++    const unsigned char *cp;
++
++    T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s, n), n));
++
++    if (win != 0 && str != 0) {
++	oy = win->_cury;
++	ox = win->_curx;
++	for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
++	    _nc_insert_ch(win, (chtype) UChar(*cp));
++	}
++	win->_curx = ox;
++	win->_cury = oy;
++	_nc_synchook(win);
++	code = OK;
++    }
++    returnCode(code);
++}
+Index: ncurses/base/lib_instr.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/ncurses/base/lib_instr.c	2002-10-05 23:23:05.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_instr.c	2004-11-20 21:43:09.000000000 +0000
+@@ -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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -40,7 +41,7 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_instr.c,v 1.12 2002/10/05 23:23:05 tom Exp $")
++MODULE_ID("$Id: lib_instr.c,v 1.13 2004/11/20 21:43:09 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ winnstr(WINDOW *win, char *str, int n)
+@@ -59,7 +60,47 @@
+ 	    n = win->_maxx - win->_curx + 1;
+ 
+ 	for (; i < n;) {
++#if USE_WIDEC_SUPPORT
++	    cchar_t *cell = &(win->_line[row].text[col]);
++	    wchar_t *wch;
++	    attr_t attrs;
++	    short pair;
++	    int n2;
++	    bool done = FALSE;
++	    mbstate_t state;
++	    size_t i3, n3;
++	    char *tmp;
++
++	    if (!isWidecExt(*cell)) {
++		n2 = getcchar(cell, 0, 0, 0, 0);
++		if (n2 > 0
++		    && (wch = typeCalloc(wchar_t, n2 + 1)) != 0) {
++		    if (getcchar(cell, wch, &attrs, &pair, 0) == OK) {
++
++			init_mb(state);
++			n3 = wcstombs(0, wch, 0);
++			if (isEILSEQ(n3) || (n3 == 0)) {
++			    ;
++			} else if ((int) (n3 + i) >= n) {
++			    done = TRUE;
++			} else if ((tmp = typeCalloc(char, n3 + 10)) == 0) {
++			    done = TRUE;
++			} else {
++			    init_mb(state);
++			    wcstombs(tmp, wch, n3);
++			    for (i3 = 0; i3 < n3; ++i3)
++				str[i++] = tmp[i3];
++			    free(tmp);
++			}
++		    }
++		    free(wch);
++		    if (done)
++			break;
++		}
++	    }
++#else
+ 	    str[i++] = CharOf(win->_line[row].text[col]);
++#endif
+ 	    if (++col > win->_maxx) {
+ 		col = 0;
+ 		if (++row > win->_maxy)
+Index: ncurses/base/lib_mouse.c
+Prereq:  1.68 
+--- ncurses-5.4-20040208/ncurses/base/lib_mouse.c	2003-11-08 21:50:50.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_mouse.c	2005-02-12 20:43:24.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,15 +29,18 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+- *     and: Thomas E. Dickey 1996-2003                                      *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ /*
+  * This module is intended to encapsulate ncurses's interface to pointing
+  * devices.
+  *
+- * The first method used is xterm's internal mouse-tracking facility.
+- * The second is Alessandro Rubini's GPM server.
++ * The primary method used is xterm's internal mouse-tracking facility.
++ * Additional methods depend on the platform:
++ *	Alessandro Rubini's GPM server (Linux)
++ *	sysmouse (FreeBSD)
++ *	special-purpose mouse interface for OS/2 EMX.
+  *
+  * Notes for implementors of new mouse-interface methods:
+  *
+@@ -76,7 +79,7 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_mouse.c,v 1.68 2003/11/08 21:50:50 tom Exp $")
++MODULE_ID("$Id: lib_mouse.c,v 1.72 2005/02/12 20:43:24 tom Exp $")
+ 
+ #include <term.h>
+ #include <tic.h>
+@@ -86,8 +89,19 @@
+ #undef buttons			/* term.h defines this, and gpm uses it! */
+ #include <gpm.h>
+ #include <linux/keyboard.h>	/* defines KG_* macros */
++/* use dynamic loader to avoid linkage dependency */
++#include <dlfcn.h>
++#ifdef RTLD_NOW
++#define my_RTLD RTLD_NOW
++#else
++#ifdef RTLD_LAZY
++#define my_RTLD RTLD_LAZY
++#else
++make an error
++#endif
+ #endif
+ #endif
++#endif				/* USE_GPM_SUPPORT */
+ 
+ #if USE_SYSMOUSE
+ #undef buttons			/* symbol conflict in consio.h */
+@@ -99,29 +113,55 @@
+ #else
+ #include <machine/console.h>
+ #endif
+-#endif /* use_SYSMOUSE */
++#endif				/* use_SYSMOUSE */
+ 
+ #define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
+ 
+-#define	MASK_RELEASE(x)		((001 << (6 * ((x) - 1))))
+-#define	MASK_PRESS(x)		((002 << (6 * ((x) - 1))))
+-#define	MASK_CLICK(x)		((004 << (6 * ((x) - 1))))
+-#define	MASK_DOUBLE_CLICK(x)	((010 << (6 * ((x) - 1))))
+-#define	MASK_TRIPLE_CLICK(x)	((020 << (6 * ((x) - 1))))
+-#define	MASK_RESERVED_EVENT(x)	((040 << (6 * ((x) - 1))))
+-
+-#define BUTTON_CLICKED  (BUTTON1_CLICKED  | BUTTON2_CLICKED  | BUTTON3_CLICKED)
+-#define BUTTON_PRESSED  (BUTTON1_PRESSED  | BUTTON2_PRESSED  | BUTTON3_PRESSED)
+-#define BUTTON_RELEASED (BUTTON1_RELEASED | BUTTON2_RELEASED | BUTTON3_RELEASED)
++#define	MASK_RELEASE(x)		NCURSES_MOUSE_MASK(x, 001)
++#define	MASK_PRESS(x)		NCURSES_MOUSE_MASK(x, 002)
++#define	MASK_CLICK(x)		NCURSES_MOUSE_MASK(x, 004)
++#define	MASK_DOUBLE_CLICK(x)	NCURSES_MOUSE_MASK(x, 010)
++#define	MASK_TRIPLE_CLICK(x)	NCURSES_MOUSE_MASK(x, 020)
++#define	MASK_RESERVED_EVENT(x)	NCURSES_MOUSE_MASK(x, 040)
++
++#if NCURSES_MOUSE_VERSION == 1
++#define BUTTON_CLICKED        (BUTTON1_CLICKED        | BUTTON2_CLICKED        | BUTTON3_CLICKED        | BUTTON4_CLICKED)
++#define BUTTON_PRESSED        (BUTTON1_PRESSED        | BUTTON2_PRESSED        | BUTTON3_PRESSED        | BUTTON4_PRESSED)
++#define BUTTON_RELEASED       (BUTTON1_RELEASED       | BUTTON2_RELEASED       | BUTTON3_RELEASED       | BUTTON4_RELEASED)
++#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED)
++#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED)
++#define MAX_BUTTONS  4
++#else
++#define BUTTON_CLICKED        (BUTTON1_CLICKED        | BUTTON2_CLICKED        | BUTTON3_CLICKED        | BUTTON4_CLICKED        | BUTTON5_CLICKED)
++#define BUTTON_PRESSED        (BUTTON1_PRESSED        | BUTTON2_PRESSED        | BUTTON3_PRESSED        | BUTTON4_PRESSED        | BUTTON5_PRESSED)
++#define BUTTON_RELEASED       (BUTTON1_RELEASED       | BUTTON2_RELEASED       | BUTTON3_RELEASED       | BUTTON4_RELEASED       | BUTTON5_RELEASED)
++#define BUTTON_DOUBLE_CLICKED (BUTTON1_DOUBLE_CLICKED | BUTTON2_DOUBLE_CLICKED | BUTTON3_DOUBLE_CLICKED | BUTTON4_DOUBLE_CLICKED | BUTTON5_DOUBLE_CLICKED)
++#define BUTTON_TRIPLE_CLICKED (BUTTON1_TRIPLE_CLICKED | BUTTON2_TRIPLE_CLICKED | BUTTON3_TRIPLE_CLICKED | BUTTON4_TRIPLE_CLICKED | BUTTON5_TRIPLE_CLICKED)
++#define MAX_BUTTONS  5
++#endif
+ 
+ #define INVALID_EVENT	-1
+ #define NORMAL_EVENT	0
+ 
+ #if USE_GPM_SUPPORT
+ #ifndef LINT
++
++#define GET_DLSYM(name) (my_##name = (TYPE_##name) dlsym(obj, #name))
++
+ static Gpm_Connect gpm_connect;
+-#endif
+-#endif
++
++typedef int *TYPE_gpm_fd;
++typedef int (*TYPE_Gpm_Open) (Gpm_Connect *, int);
++typedef int (*TYPE_Gpm_Close) (void);
++typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *);
++
++static TYPE_gpm_fd my_gpm_fd;
++static TYPE_Gpm_Open my_Gpm_Open;
++static TYPE_Gpm_Close my_Gpm_Close;
++static TYPE_Gpm_GetEvent my_Gpm_GetEvent;
++
++#endif /* LINT */
++#endif /* USE_GPM_SUPPORT */
+ 
+ static mmask_t eventmask;	/* current event mask */
+ 
+@@ -247,12 +287,6 @@
+     DosExit(EXIT_THREAD, 0L);
+ }
+ 
+-static void
+-server_state(const int state)
+-{				/* It would be nice to implement pointer-off and stop looping... */
+-    mouse_activated = state;
+-}
+-
+ #endif /* USE_EMX_MOUSE */
+ 
+ #if USE_SYSMOUSE
+@@ -312,7 +346,7 @@
+ 	work->y = the_mouse.u.data.y / SP->_sysmouse_char_height;
+     }
+ }
+-#endif
++#endif /* USE_SYSMOUSE */
+ 
+ static int initialized;
+ 
+@@ -325,35 +359,104 @@
+ 	SP->_mouse_xtermcap = "\033[?1000%?%p1%{1}%=%th%el%;";
+ }
+ 
+-#if !USE_EMX_MOUSE
+ static void
+ enable_xterm_mouse(int enable)
+ {
++#if USE_EMX_MOUSE
++    mouse_activated = enable;
++#else
+     putp(tparm(SP->_mouse_xtermcap, enable));
++#endif
+ }
+-#endif /* !USE_EMX_MOUSE */
+ 
+-static void
+-initialize_mousetype(void)
+-{
+-    static const char *xterm_kmous = "\033[M";
+-
+-    /* Try gpm first, because gpm may be configured to run in xterm */
+ #if USE_GPM_SUPPORT
++static int
++allow_gpm_mouse(void)
++{
+     /* GPM does printf's without checking if stdout is a terminal */
+     if (isatty(fileno(stdout))) {
++	char *env = getenv("TERM");
++	/* GPM checks the beginning of the $TERM variable to decide if
++	 * it should pass xterm events through.  There is no real advantage
++	 * in allowing GPM to do this.
++	 */
++	if (env == 0 || strncmp(env, "xterm", 5))
++	    return TRUE;
++    }
++    return FALSE;
++}
++
++static int
++enable_gpm_mouse(int enable)
++{
++    int result;
++
++    if (enable) {
+ 	/* GPM: initialize connection to gpm server */
+ 	gpm_connect.eventMask = GPM_DOWN | GPM_UP;
+ 	gpm_connect.defaultMask = ~(gpm_connect.eventMask | GPM_HARD);
+ 	gpm_connect.minMod = 0;
+-	gpm_connect.maxMod = ~((1 << KG_SHIFT) | (1 << KG_SHIFTL) | (1 << KG_SHIFTR));
+-	if (Gpm_Open(&gpm_connect, 0) >= 0) {	/* returns the file-descriptor */
++	gpm_connect.maxMod = ~((1 << KG_SHIFT) |
++			       (1 << KG_SHIFTL) |
++			       (1 << KG_SHIFTR));
++	/*
++	 * Note: GPM hardcodes \E[?1001s and \E[?1000h during its open.
++	 * The former is recognized by wscons (SunOS), and the latter by
++	 * xterm.  Those will not show up in ncurses' traces.
++	 */
++	result = (my_Gpm_Open(&gpm_connect, 0) >= 0);
++	T(("GPM open %s", result ? "succeeded" : "failed"));
++    } else {
++	/* GPM: close connection to gpm server */
++	my_Gpm_Close();
++	result = TRUE;
++	T(("GPM closed"));
++    }
++    return result;
++}
++#endif /* USE_GPM_SUPPORT */
++
++static void
++initialize_mousetype(void)
++{
++    static const char *xterm_kmous = "\033[M";
++
++    /* Try gpm first, because gpm may be configured to run in xterm */
++#if USE_GPM_SUPPORT
++    if (allow_gpm_mouse()) {
++	static bool first = TRUE;
++	static bool found = FALSE;
++
++	if (first) {
++	    void *obj;
++	    first = FALSE;
++
++	    if ((obj = dlopen("libgpm.so", my_RTLD)) != 0) {
++		if (GET_DLSYM(gpm_fd) == 0 ||
++		    GET_DLSYM(Gpm_Open) == 0 ||
++		    GET_DLSYM(Gpm_Close) == 0 ||
++		    GET_DLSYM(Gpm_GetEvent) == 0) {
++		    T(("GPM initialization failed: %s", dlerror()));
++		    dlclose(obj);
++		} else {
++		    found = TRUE;
++		}
++	    }
++	}
++
++	/*
++	 * The gpm_fd file-descriptor may be negative (xterm).  So we have to
++	 * maintain our notion of whether the mouse connection is active
++	 * without testing the file-descriptor.
++	 */
++	if (found && enable_gpm_mouse(TRUE)) {
+ 	    SP->_mouse_type = M_GPM;
+-	    SP->_mouse_fd = gpm_fd;
++	    SP->_mouse_fd = *my_gpm_fd;
++	    T(("GPM mouse_fd %d", SP->_mouse_fd));
+ 	    return;
+ 	}
+     }
+-#endif
++#endif /* USE_GPM_SUPPORT */
+ 
+     /* OS/2 VIO */
+ #if USE_EMX_MOUSE
+@@ -395,7 +498,7 @@
+ 	    }
+ 	}
+     }
+-#endif
++#endif /* USE_EMX_MOUSE */
+ 
+ #if USE_SYSMOUSE
+     {
+@@ -500,7 +603,7 @@
+  * fifo_push() in lib_getch.c
+  */
+ static bool
+-_nc_mouse_event(SCREEN * sp GCC_UNUSED)
++_nc_mouse_event(SCREEN *sp GCC_UNUSED)
+ {
+     bool result = FALSE;
+ 
+@@ -530,7 +633,7 @@
+ 	    /* query server for event, return TRUE if we find one */
+ 	    Gpm_Event ev;
+ 
+-	    if (Gpm_GetEvent(&ev) == 1) {
++	    if (my_Gpm_GetEvent(&ev) == 1) {
+ 		/* there's only one mouse... */
+ 		eventp->id = NORMAL_EVENT;
+ 
+@@ -599,9 +702,10 @@
+ }
+ 
+ static bool
+-_nc_mouse_inline(SCREEN * sp)
++_nc_mouse_inline(SCREEN *sp)
+ /* mouse report received in the keyboard stream -- parse its info */
+ {
++    int b;
+     bool result = FALSE;
+ 
+     TR(MY_TRACE, ("_nc_mouse_inline() called"));
+@@ -639,8 +743,10 @@
+ 	 * (End quote)  By the time we get here, we've eaten the
+ 	 * key prefix.  FYI, the loop below is necessary because
+ 	 * mouse click info isn't guaranteed to present as a
+-	 * single clist item.  It always does under Linux but often
+-	 * fails to under Solaris.
++	 * single clist item.
++	 *
++	 * Wheel mice may return buttons 4 and 5 when the wheel is turned.
++	 * We encode those as button presses.
+ 	 */
+ 	for (grabbed = 0; grabbed < 3; grabbed += res) {
+ 
+@@ -679,11 +785,19 @@
+ 
+ 	switch (kbuf[0] & 0x3) {
+ 	case 0x0:
+-	    PRESS_POSITION(1);
++	    if (kbuf[0] & 64)
++		eventp->bstate = MASK_PRESS(4);
++	    else
++		PRESS_POSITION(1);
+ 	    break;
+ 
+ 	case 0x1:
+-	    PRESS_POSITION(2);
++#if NCURSES_MOUSE_VERSION == 2
++	    if (kbuf[0] & 64)
++		eventp->bstate = MASK_PRESS(5);
++	    else
++#endif
++		PRESS_POSITION(2);
+ 	    break;
+ 
+ 	case 0x2:
+@@ -700,12 +814,10 @@
+ 	     */
+ 	    if (prev & (BUTTON_PRESSED | BUTTON_RELEASED)) {
+ 		eventp->bstate = BUTTON_RELEASED;
+-		if (!(prev & BUTTON1_PRESSED))
+-		    eventp->bstate &= ~BUTTON1_RELEASED;
+-		if (!(prev & BUTTON2_PRESSED))
+-		    eventp->bstate &= ~BUTTON2_RELEASED;
+-		if (!(prev & BUTTON3_PRESSED))
+-		    eventp->bstate &= ~BUTTON3_RELEASED;
++		for (b = 1; b <= MAX_BUTTONS; ++b) {
++		    if (!(prev & MASK_PRESS(b)))
++			eventp->bstate &= ~MASK_RELEASE(b);
++		}
+ 	    } else {
+ 		/*
+ 		 * XFree86 xterm will return a stream of release-events to
+@@ -761,15 +873,14 @@
+ 	    keyok(KEY_MOUSE, on);
+ #endif
+ 	    TPUTS_TRACE("xterm mouse initialization");
+-#if USE_EMX_MOUSE
+-	    server_state(1);
+-#else
+ 	    enable_xterm_mouse(1);
+-#endif
+ 	    break;
+ #if USE_GPM_SUPPORT
+ 	case M_GPM:
+-	    SP->_mouse_fd = gpm_fd;
++	    if (enable_gpm_mouse(1)) {
++		SP->_mouse_fd = *my_gpm_fd;
++		T(("GPM mouse_fd %d", SP->_mouse_fd));
++	    }
+ 	    break;
+ #endif
+ #if USE_SYSMOUSE
+@@ -794,14 +905,11 @@
+ 	switch (SP->_mouse_type) {
+ 	case M_XTERM:
+ 	    TPUTS_TRACE("xterm mouse deinitialization");
+-#if USE_EMX_MOUSE
+-	    server_state(0);
+-#else
+ 	    enable_xterm_mouse(0);
+-#endif
+ 	    break;
+ #if USE_GPM_SUPPORT
+ 	case M_GPM:
++	    enable_gpm_mouse(0);
+ 	    break;
+ #endif
+ #if USE_SYSMOUSE
+@@ -828,6 +936,7 @@
+ {
+     MEVENT *ep, *runp, *next, *prev = PREV(eventp);
+     int n;
++    int b;
+     bool merge;
+ 
+     TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));
+@@ -883,32 +992,27 @@
+     do {
+ 	merge = FALSE;
+ 	for (ep = runp; (next = NEXT(ep)) != eventp; ep = next) {
++
++#define MASK_CHANGED(x) (!(ep->bstate & MASK_PRESS(x)) \
++		      == !(next->bstate & MASK_RELEASE(x)))
++
+ 	    if (ep->x == next->x && ep->y == next->y
+ 		&& (ep->bstate & BUTTON_PRESSED)
+-		&& (!(ep->bstate & BUTTON1_PRESSED)
+-		    == !(next->bstate & BUTTON1_RELEASED))
+-		&& (!(ep->bstate & BUTTON2_PRESSED)
+-		    == !(next->bstate & BUTTON2_RELEASED))
+-		&& (!(ep->bstate & BUTTON3_PRESSED)
+-		    == !(next->bstate & BUTTON3_RELEASED))
++		&& MASK_CHANGED(1)
++		&& MASK_CHANGED(2)
++		&& MASK_CHANGED(3)
++		&& MASK_CHANGED(4)
++#if NCURSES_MOUSE_VERSION == 2
++		&& MASK_CHANGED(5)
++#endif
+ 		) {
+-		if ((eventmask & BUTTON1_CLICKED)
+-		    && (ep->bstate & BUTTON1_PRESSED)) {
+-		    ep->bstate &= ~BUTTON1_PRESSED;
+-		    ep->bstate |= BUTTON1_CLICKED;
+-		    merge = TRUE;
+-		}
+-		if ((eventmask & BUTTON2_CLICKED)
+-		    && (ep->bstate & BUTTON2_PRESSED)) {
+-		    ep->bstate &= ~BUTTON2_PRESSED;
+-		    ep->bstate |= BUTTON2_CLICKED;
+-		    merge = TRUE;
+-		}
+-		if ((eventmask & BUTTON3_CLICKED)
+-		    && (ep->bstate & BUTTON3_PRESSED)) {
+-		    ep->bstate &= ~BUTTON3_PRESSED;
+-		    ep->bstate |= BUTTON3_CLICKED;
+-		    merge = TRUE;
++		for (b = 1; b <= MAX_BUTTONS; ++b) {
++		    if ((eventmask & MASK_CLICK(b))
++			&& (ep->bstate & MASK_PRESS(b))) {
++			ep->bstate &= ~MASK_PRESS(b);
++			ep->bstate |= MASK_CLICK(b);
++			merge = TRUE;
++		    }
+ 		}
+ 		if (merge)
+ 		    next->id = INVALID_EVENT;
+@@ -958,51 +1062,28 @@
+ 		/* merge click events forward */
+ 		if ((ep->bstate & BUTTON_CLICKED)
+ 		    && (follower->bstate & BUTTON_CLICKED)) {
+-		    if ((eventmask & BUTTON1_DOUBLE_CLICKED)
+-			&& (follower->bstate & BUTTON1_CLICKED)) {
+-			follower->bstate &= ~BUTTON1_CLICKED;
+-			follower->bstate |= BUTTON1_DOUBLE_CLICKED;
+-			merge = TRUE;
+-		    }
+-		    if ((eventmask & BUTTON2_DOUBLE_CLICKED)
+-			&& (follower->bstate & BUTTON2_CLICKED)) {
+-			follower->bstate &= ~BUTTON2_CLICKED;
+-			follower->bstate |= BUTTON2_DOUBLE_CLICKED;
+-			merge = TRUE;
+-		    }
+-		    if ((eventmask & BUTTON3_DOUBLE_CLICKED)
+-			&& (follower->bstate & BUTTON3_CLICKED)) {
+-			follower->bstate &= ~BUTTON3_CLICKED;
+-			follower->bstate |= BUTTON3_DOUBLE_CLICKED;
+-			merge = TRUE;
++		    for (b = 1; b <= MAX_BUTTONS; ++b) {
++			if ((eventmask & MASK_DOUBLE_CLICK(b))
++			    && (follower->bstate & MASK_CLICK(b))) {
++			    follower->bstate &= ~MASK_CLICK(b);
++			    follower->bstate |= MASK_DOUBLE_CLICK(b);
++			    merge = TRUE;
++			}
+ 		    }
+ 		    if (merge)
+ 			ep->id = INVALID_EVENT;
+ 		}
+ 
+ 		/* merge double-click events forward */
+-		if ((ep->bstate &
+-		     (BUTTON1_DOUBLE_CLICKED
+-		      | BUTTON2_DOUBLE_CLICKED
+-		      | BUTTON3_DOUBLE_CLICKED))
++		if ((ep->bstate & BUTTON_DOUBLE_CLICKED)
+ 		    && (follower->bstate & BUTTON_CLICKED)) {
+-		    if ((eventmask & BUTTON1_TRIPLE_CLICKED)
+-			&& (follower->bstate & BUTTON1_CLICKED)) {
+-			follower->bstate &= ~BUTTON1_CLICKED;
+-			follower->bstate |= BUTTON1_TRIPLE_CLICKED;
+-			merge = TRUE;
+-		    }
+-		    if ((eventmask & BUTTON2_TRIPLE_CLICKED)
+-			&& (follower->bstate & BUTTON2_CLICKED)) {
+-			follower->bstate &= ~BUTTON2_CLICKED;
+-			follower->bstate |= BUTTON2_TRIPLE_CLICKED;
+-			merge = TRUE;
+-		    }
+-		    if ((eventmask & BUTTON3_TRIPLE_CLICKED)
+-			&& (follower->bstate & BUTTON3_CLICKED)) {
+-			follower->bstate &= ~BUTTON3_CLICKED;
+-			follower->bstate |= BUTTON3_TRIPLE_CLICKED;
+-			merge = TRUE;
++		    for (b = 1; b <= MAX_BUTTONS; ++b) {
++			if ((eventmask & MASK_TRIPLE_CLICK(b))
++			    && (follower->bstate & MASK_CLICK(b))) {
++			    follower->bstate &= ~MASK_CLICK(b);
++			    follower->bstate |= MASK_TRIPLE_CLICK(b);
++			    merge = TRUE;
++			}
+ 		    }
+ 		    if (merge)
+ 			ep->id = INVALID_EVENT;
+@@ -1050,7 +1131,7 @@
+ }
+ 
+ static void
+-_nc_mouse_wrap(SCREEN * sp GCC_UNUSED)
++_nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
+ /* release mouse -- called by endwin() before shellout/exit */
+ {
+     TR(MY_TRACE, ("_nc_mouse_wrap() called"));
+@@ -1063,6 +1144,8 @@
+ #if USE_GPM_SUPPORT
+ 	/* GPM: pass all mouse events to next client */
+     case M_GPM:
++	if (eventmask)
++	    mouse_activate(FALSE);
+ 	break;
+ #endif
+ #if USE_SYSMOUSE
+@@ -1076,7 +1159,7 @@
+ }
+ 
+ static void
+-_nc_mouse_resume(SCREEN * sp GCC_UNUSED)
++_nc_mouse_resume(SCREEN *sp GCC_UNUSED)
+ /* re-connect to mouse -- called by doupdate() after shellout */
+ {
+     TR(MY_TRACE, ("_nc_mouse_resume() called"));
+@@ -1091,6 +1174,8 @@
+ #if USE_GPM_SUPPORT
+     case M_GPM:
+ 	/* GPM: reclaim our event set */
++	if (eventmask)
++	    mouse_activate(TRUE);
+ 	break;
+ #endif
+ 
+@@ -1170,9 +1255,8 @@
+ 	     | BUTTON_PRESSED
+ 	     | BUTTON_RELEASED
+ 	     | BUTTON_CLICKED
+-	     | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
+-	     | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
+-	     | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
++	     | BUTTON_DOUBLE_CLICKED
++	     | BUTTON_TRIPLE_CLICKED);
+ 
+ 	mouse_activate(eventmask != 0);
+ 
+Index: ncurses/base/lib_move.c
+Prereq:  1.11 
+--- ncurses-5.4-20040208/ncurses/base/lib_move.c	2000-12-10 02:43:27.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_move.c	2004-12-04 21:50:07.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2004 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -40,16 +41,14 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_move.c,v 1.11 2000/12/10 02:43:27 tom Exp $")
++MODULE_ID("$Id: lib_move.c,v 1.12 2004/12/04 21:50:07 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ wmove(WINDOW *win, int y, int x)
+ {
+     T((T_CALLED("wmove(%p,%d,%d)"), win, y, x));
+ 
+-    if (win &&
+-	x >= 0 && x <= win->_maxx &&
+-	y >= 0 && y <= win->_maxy) {
++    if (LEGALYX(win, y, x)) {
+ 	win->_curx = (NCURSES_SIZE_T) x;
+ 	win->_cury = (NCURSES_SIZE_T) y;
+ 
+Index: ncurses/base/lib_newterm.c
+Prereq:  1.57 
+--- ncurses-5.4-20040208/ncurses/base/lib_newterm.c	2002-10-20 00:10:56.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_newterm.c	2004-08-14 20:36:39.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2002,2004 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -47,7 +48,7 @@
+ #include <term.h>		/* clear_screen, cup & friends, cur_term */
+ #include <tic.h>
+ 
+-MODULE_ID("$Id: lib_newterm.c,v 1.57 2002/10/20 00:10:56 Philippe.Blain Exp $")
++MODULE_ID("$Id: lib_newterm.c,v 1.58 2004/08/14 20:36:39 tom Exp $")
+ 
+ #ifndef ONLCR			/* Allows compilation under the QNX 4.2 OS */
+ #define ONLCR 0
+@@ -102,7 +103,7 @@
+ }
+ 
+ NCURSES_EXPORT(SCREEN *)
+-newterm(NCURSES_CONST char *name, FILE * ofp, FILE * ifp)
++newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
+ {
+     int errret;
+     int slk_format = _nc_slk_format;
+@@ -198,5 +199,13 @@
+ 
+     _nc_signal_handler(TRUE);
+ 
++#if USE_SIZECHANGE
++    /*
++     * Pretend we received a SIGWINCH, just in case we're starting up in a
++     * terminal that cannot initialize its size properly (Debian #265631).
++     */
++    SP->_sig_winch = TRUE;
++#endif
++
+     returnSP(SP);
+ }
+Index: ncurses/base/lib_newwin.c
+Prereq:  1.34 
+--- ncurses-5.4-20040208/ncurses/base/lib_newwin.c	2002-08-18 00:12:30.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_newwin.c	2004-04-10 23:42:00.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2002,2004 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 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_newwin.c,v 1.34 2002/08/18 00:12:30 tom Exp $")
++MODULE_ID("$Id: lib_newwin.c,v 1.35 2004/04/10 23:42:00 tom Exp $")
+ 
+ static WINDOW *
+ remove_window_from_screen(WINDOW *win)
+@@ -120,9 +120,6 @@
+     if (num_columns == 0)
+ 	num_columns = screen_columns - begx;
+ 
+-    if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail)
+-	returnWin(0);
+-
+     if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
+ 	returnWin(0);
+ 
+Index: ncurses/base/lib_pad.c
+Prereq:  1.38 
+--- ncurses-5.4-20040208/ncurses/base/lib_pad.c	2002-08-03 23:29:26.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_pad.c	2004-10-23 18:48:09.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2002,2003 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 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_pad.c,v 1.38 2002/08/03 23:29:26 Philippe.Blain Exp $")
++MODULE_ID("$Id: lib_pad.c,v 1.39 2004/10/23 18:48:09 tom Exp $")
+ 
+ NCURSES_EXPORT(WINDOW *)
+ newpad(int l, int c)
+@@ -202,7 +202,7 @@
+ 	     */
+ 	    if (j == pmincol
+ 		&& j > 0
+-		&& isnac(ch)) {
++		&& isWidecExt(ch)) {
+ 		SetChar(ch, L(' '), AttrOf(oline->text[j - 1]));
+ 	    }
+ #endif
+Index: ncurses/base/lib_scroll.c
+Prereq:  1.24 
+--- ncurses-5.4-20040208/ncurses/base/lib_scroll.c	2003-07-26 23:25:26.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_scroll.c	2004-12-11 18:28:51.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2001,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -43,11 +43,14 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_scroll.c,v 1.24 2003/07/26 23:25:26 tom Exp $")
++MODULE_ID("$Id: lib_scroll.c,v 1.25 2004/12/11 18:28:51 tom Exp $")
+ 
+ NCURSES_EXPORT(void)
+-_nc_scroll_window(WINDOW *win, int const n, NCURSES_SIZE_T const top,
+-		  NCURSES_SIZE_T const bottom, NCURSES_CH_T blank)
++_nc_scroll_window(WINDOW *win,
++		  int const n,
++		  NCURSES_SIZE_T const top,
++		  NCURSES_SIZE_T const bottom,
++		  NCURSES_CH_T blank)
+ {
+     int limit;
+     int line;
+@@ -110,6 +113,22 @@
+ 	}
+     }
+     touchline(win, top, bottom - top + 1);
++
++    if_WIDEC({
++	if (WINDOW_EXT(win, addch_used) != 0) {
++	    int next = WINDOW_EXT(win, addch_y) + n;
++	    if (next < 0 || next > win->_maxy) {
++		TR(TRACE_VIRTPUT,
++		   ("Alert discarded multibyte on scroll"));
++		WINDOW_EXT(win, addch_y) = 0;
++	    } else {
++		TR(TRACE_VIRTPUT, ("scrolled working position to %d,%d",
++				   WINDOW_EXT(win, addch_y),
++				   WINDOW_EXT(win, addch_x)));
++		WINDOW_EXT(win, addch_y) = next;
++	    }
++	}
++    })
+ }
+ 
+ NCURSES_EXPORT(int)
+Index: ncurses/base/lib_set_term.c
+Prereq:  1.81 
+--- ncurses-5.4-20040208/ncurses/base/lib_set_term.c	2003-11-15 23:57:01.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_set_term.c	2005-01-22 17:36:01.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,7 +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-2003               *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -44,10 +44,10 @@
+ #include <term.h>		/* cur_term */
+ #include <tic.h>
+ 
+-MODULE_ID("$Id: lib_set_term.c,v 1.81 2003/11/15 23:57:01 tom Exp $")
++MODULE_ID("$Id: lib_set_term.c,v 1.85 2005/01/22 17:36:01 tom Exp $")
+ 
+ NCURSES_EXPORT(SCREEN *)
+-set_term(SCREEN * screenp)
++set_term(SCREEN *screenp)
+ {
+     SCREEN *oldSP;
+ 
+@@ -81,7 +81,7 @@
+  * Free the storage associated with the given SCREEN sp.
+  */
+ NCURSES_EXPORT(void)
+-delscreen(SCREEN * sp)
++delscreen(SCREEN *sp)
+ {
+     SCREEN **scan = &_nc_screen_chain;
+     int i;
+@@ -118,6 +118,8 @@
+     _nc_free_keytry(sp->_key_ok);
+     sp->_key_ok = 0;
+ 
++    FreeIfNeeded(sp->_current_attr);
++
+     FreeIfNeeded(sp->_color_table);
+     FreeIfNeeded(sp->_color_pairs);
+ 
+@@ -162,13 +164,13 @@
+ #define N_RIPS SIZEOF(SP->_rippedoff)
+ 
+ static bool
+-no_mouse_event(SCREEN * sp GCC_UNUSED)
++no_mouse_event(SCREEN *sp GCC_UNUSED)
+ {
+     return FALSE;
+ }
+ 
+ static bool
+-no_mouse_inline(SCREEN * sp GCC_UNUSED)
++no_mouse_inline(SCREEN *sp GCC_UNUSED)
+ {
+     return FALSE;
+ }
+@@ -180,12 +182,12 @@
+ }
+ 
+ static void
+-no_mouse_resume(SCREEN * sp GCC_UNUSED)
++no_mouse_resume(SCREEN *sp GCC_UNUSED)
+ {
+ }
+ 
+ static void
+-no_mouse_wrap(SCREEN * sp GCC_UNUSED)
++no_mouse_wrap(SCREEN *sp GCC_UNUSED)
+ {
+ }
+ 
+@@ -221,9 +223,13 @@
+     if (!_nc_alloc_screen())
+ 	returnCode(ERR);
+ 
++    T(("created SP %p", SP));
+     SP->_next_screen = _nc_screen_chain;
+     _nc_screen_chain = SP;
+ 
++    if ((SP->_current_attr = typeCalloc(NCURSES_CH_T, 1)) == 0)
++	returnCode(ERR);
++
+ #ifdef __DJGPP__
+     T(("setting output mode to binary"));
+     fflush(output);
+@@ -392,9 +398,9 @@
+     SP->_screen_acs_fix = (_nc_unicode_locale() && _nc_locale_breaks_acs());
+     {
+ 	char *env = _nc_get_locale();
+-	SP->_posix_locale = ((env == 0)
+-			     || !strcmp(env, "C")
+-			     || !strcmp(env, "POSIX"));
++	SP->_legacy_coding = ((env == 0)
++			      || !strcmp(env, "C")
++			      || !strcmp(env, "POSIX"));
+     }
+ #endif
+ 
+Index: ncurses/base/lib_slk.c
+Prereq:  1.28 
+--- ncurses-5.4-20040208/ncurses/base/lib_slk.c	2003-05-24 21:10:28.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_slk.c	2005-01-08 21:56:36.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -27,8 +27,12 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *  Authors:                                                                *
++ *          Gerhard Fuernkranz                      1993 (original)         *
++ *          Zeyd M. Ben-Halim                       1992,1995 (sic)         *
++ *          Eric S. Raymond                                                 *
++ *          Juergen Pfeifer                         1996-on                 *
++ *          Thomas E. Dickey                                                *
+  ****************************************************************************/
+ 
+ /*
+@@ -41,7 +45,7 @@
+ #include <ctype.h>
+ #include <term.h>		/* num_labels, label_*, plab_norm */
+ 
+-MODULE_ID("$Id: lib_slk.c,v 1.28 2003/05/24 21:10:28 tom Exp $")
++MODULE_ID("$Id: lib_slk.c,v 1.30 2005/01/08 21:56:36 tom Exp $")
+ 
+ /*
+  * We'd like to move these into the screen context structure, but cannot,
+@@ -109,9 +113,9 @@
+      * work.
+      */
+     if ((no_color_video & 1) == 0)
+-	SP->_slk->attr = A_STANDOUT;
++	SetAttr(SP->_slk->attr, A_STANDOUT);
+     else
+-	SP->_slk->attr = A_REVERSE;
++	SetAttr(SP->_slk->attr, A_REVERSE);
+ 
+     SP->_slk->maxlab = ((num_labels > 0)
+ 			? num_labels
+@@ -131,14 +135,15 @@
+ 
+     max_length = SP->_slk->maxlen;
+     for (i = 0; i < SP->_slk->labcnt; i++) {
++	size_t used = max_length + 1;
+ 
+-	if ((SP->_slk->ent[i].ent_text = (char *)_nc_doalloc(0, max_length + 1)) == 0)
++	if ((SP->_slk->ent[i].ent_text = (char *) _nc_doalloc(0, used)) == 0)
+ 	    returnCode(slk_failed());
+-	memset(SP->_slk->ent[i].ent_text, 0, max_length + 1);
++	memset(SP->_slk->ent[i].ent_text, 0, used);
+ 
+-	if ((SP->_slk->ent[i].form_text = (char *)_nc_doalloc(0, max_length + 1)) == 0)
++	if ((SP->_slk->ent[i].form_text = (char *) _nc_doalloc(0, used)) == 0)
+ 	    returnCode(slk_failed());
+-	memset(SP->_slk->ent[i].form_text, 0, max_length + 1);
++	memset(SP->_slk->ent[i].form_text, 0, used);
+ 
+ 	memset(SP->_slk->ent[i].form_text, ' ', max_length);
+ 	SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
+Index: ncurses/base/lib_slkatr_set.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/ncurses/base/lib_slkatr_set.c	2003-10-25 15:27:03.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_slkatr_set.c	2005-01-28 21:11:53.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2005 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            *
+@@ -28,27 +28,31 @@
+ 
+ /****************************************************************************
+  *  Author:  Juergen Pfeifer, 1998                                          *
++ *     and:  Thomas E. Dickey 2005                                          *
+  ****************************************************************************/
+ 
+ /*
+  *	lib_slkatr_set.c
+  *	Soft key routines.
+- *      Set the labels attributes
++ *	Set the label's attributes
+  */
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_slkatr_set.c,v 1.7 2003/10/25 15:27:03 tom Exp $")
++MODULE_ID("$Id: lib_slkatr_set.c,v 1.9 2005/01/08 22:59:37 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-slk_attr_set
+-(const attr_t attr, short color_pair_number, void *opts)
++slk_attr_set(const attr_t attr, short color_pair_number, void *opts)
+ {
+     T((T_CALLED("slk_attr_set(%s,%d)"), _traceattr(attr), color_pair_number));
+ 
+     if (SP != 0 && SP->_slk != 0 && !opts &&
+ 	color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) {
+-	SP->_slk->attr = attr;
+-	toggle_attr_on(SP->_slk->attr, COLOR_PAIR(color_pair_number));
++	TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
++	SetAttr(SP->_slk->attr, attr);
++	if (color_pair_number > 0) {
++	    SetPair(SP->_slk->attr, color_pair_number);
++	}
++	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
+ 	returnCode(OK);
+     } else
+ 	returnCode(ERR);
+Index: ncurses/base/lib_slkatrof.c
+Prereq:  1.6 
+--- ncurses-5.4-20040208/ncurses/base/lib_slkatrof.c	2000-12-10 02:43:27.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_slkatrof.c	2005-01-08 23:01:32.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -27,8 +27,8 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *  Author:  Juergen Pfeifer, 1997                                          *
++ *     and:  Thomas E. Dickey 2005                                          *
+  ****************************************************************************/
+ 
+ /*
+@@ -38,7 +38,7 @@
+  */
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_slkatrof.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
++MODULE_ID("$Id: lib_slkatrof.c,v 1.8 2005/01/08 23:01:32 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ slk_attroff(const chtype attr)
+@@ -46,7 +46,12 @@
+     T((T_CALLED("slk_attroff(%s)"), _traceattr(attr)));
+ 
+     if (SP != 0 && SP->_slk != 0) {
+-	toggle_attr_off(SP->_slk->attr, attr);
++	TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
++	RemAttr(SP->_slk->attr, attr);
++	if ((attr & A_COLOR) != 0) {
++	    SetPair(SP->_slk->attr, 0);
++	}
++	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
+ 	returnCode(OK);
+     } else
+ 	returnCode(ERR);
+Index: ncurses/base/lib_slkatron.c
+Prereq:  1.6 
+--- ncurses-5.4-20040208/ncurses/base/lib_slkatron.c	2000-12-10 02:43:27.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_slkatron.c	2005-01-08 23:02:01.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -27,8 +27,8 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *  Author:  Juergen Pfeifer, 1997                                          *
++ *     and:  Thomas E. Dickey 2005                                          *
+  ****************************************************************************/
+ 
+ /*
+@@ -38,7 +38,7 @@
+  */
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_slkatron.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
++MODULE_ID("$Id: lib_slkatron.c,v 1.8 2005/01/08 23:02:01 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ slk_attron(const chtype attr)
+@@ -46,7 +46,12 @@
+     T((T_CALLED("slk_attron(%s)"), _traceattr(attr)));
+ 
+     if (SP != 0 && SP->_slk != 0) {
+-	toggle_attr_on(SP->_slk->attr, attr);
++	TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr))));
++	AddAttr(SP->_slk->attr, attr);
++	if ((attr & A_COLOR) != 0) {
++	    SetPair(SP->_slk->attr, PAIR_NUMBER(attr));
++	}
++	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
+ 	returnCode(OK);
+     } else
+ 	returnCode(ERR);
+Index: ncurses/base/lib_slkatrset.c
+Prereq:  1.6 
+--- ncurses-5.4-20040208/ncurses/base/lib_slkatrset.c	2000-12-10 02:43:27.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_slkatrset.c	2005-01-08 21:46:47.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -27,8 +27,8 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *  Author:  Juergen Pfeifer, 1997                                          *
++ *     and:  Thomas E. Dickey 2005                                          *
+  ****************************************************************************/
+ 
+ /*
+@@ -38,7 +38,7 @@
+  */
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_slkatrset.c,v 1.6 2000/12/10 02:43:27 tom Exp $")
++MODULE_ID("$Id: lib_slkatrset.c,v 1.7 2005/01/08 21:46:47 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ slk_attrset(const chtype attr)
+@@ -46,7 +46,7 @@
+     T((T_CALLED("slk_attrset(%s)"), _traceattr(attr)));
+ 
+     if (SP != 0 && SP->_slk != 0) {
+-	SP->_slk->attr = attr;
++	SetAttr(SP->_slk->attr, attr);
+ 	returnCode(OK);
+     } else
+ 	returnCode(ERR);
+Index: ncurses/base/lib_slkattr.c
+Prereq:  1.5 
+--- ncurses-5.4-20040208/ncurses/base/lib_slkattr.c	2000-12-10 02:43:27.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_slkattr.c	2005-01-08 21:44:28.000000000 +0000
+@@ -27,8 +27,8 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *  Author:  Juergen Pfeifer, 1997                                          *
++ *     and:  Thomas E. Dickey 2005                                          *
+  ****************************************************************************/
+ 
+ /*
+@@ -38,7 +38,7 @@
+  */
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_slkattr.c,v 1.5 2000/12/10 02:43:27 tom Exp $")
++MODULE_ID("$Id: lib_slkattr.c,v 1.6 2005/01/08 21:44:28 tom Exp $")
+ 
+ NCURSES_EXPORT(attr_t)
+ slk_attr(void)
+@@ -46,7 +46,11 @@
+     T((T_CALLED("slk_attr()")));
+ 
+     if (SP != 0 && SP->_slk != 0) {
+-	returnAttr(SP->_slk->attr);
++	attr_t result = AttrOf(SP->_slk->attr) & ALL_BUT_COLOR;
++	int pair = GetPair(SP->_slk->attr);
++
++	result |= COLOR_PAIR(pair);
++	returnAttr(result);
+     } else
+ 	returnAttr(0);
+ }
+Index: ncurses/base/lib_slkcolor.c
+Prereq:  1.9 
+--- ncurses-5.4-20040208/ncurses/base/lib_slkcolor.c	2003-10-25 15:27:03.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_slkcolor.c	2005-01-28 21:11:53.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2005 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            *
+@@ -28,14 +28,17 @@
+ 
+ /****************************************************************************
+  *  Author:  Juergen Pfeifer, 1998                                          *
++ *     and:  Thomas E. Dickey 2005                                          *
+  ****************************************************************************/
+ 
+ /*
+  *	lib_slkcolor.c
++ *	Soft key routines.
++ *	Set the label's color
+  */
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_slkcolor.c,v 1.9 2003/10/25 15:27:03 tom Exp $")
++MODULE_ID("$Id: lib_slkcolor.c,v 1.12 2005/01/28 21:11:53 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ slk_color(short color_pair_number)
+@@ -44,8 +47,9 @@
+ 
+     if (SP != 0 && SP->_slk != 0 &&
+ 	color_pair_number >= 0 && color_pair_number < COLOR_PAIRS) {
+-	T(("... current %ld", (long) PAIR_NUMBER(SP->_slk->attr)));
+-	toggle_attr_on(SP->_slk->attr, COLOR_PAIR(color_pair_number));
++	TR(TRACE_ATTRS, ("... current is %s", _tracech_t(CHREF(SP->_slk->attr))));
++	SetPair(SP->_slk->attr, color_pair_number);
++	TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr))));
+ 	returnCode(OK);
+     } else
+ 	returnCode(ERR);
+Index: ncurses/base/lib_slkrefr.c
+Prereq:  1.11 
+--- ncurses-5.4-20040208/ncurses/base/lib_slkrefr.c	2003-03-29 22:53:48.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_slkrefr.c	2005-01-08 21:46:31.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,8 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *     and: Juergen Pfeifer                         1996-on                 *
++ *     and: Thomas E. Dickey                                                *
+  ****************************************************************************/
+ 
+ /*
+@@ -38,7 +40,7 @@
+ #include <curses.priv.h>
+ #include <term.h>		/* num_labels, label_*, plab_norm */
+ 
+-MODULE_ID("$Id: lib_slkrefr.c,v 1.11 2003/03/29 22:53:48 tom Exp $")
++MODULE_ID("$Id: lib_slkrefr.c,v 1.13 2005/01/08 21:46:31 tom Exp $")
+ 
+ /*
+  * Write the soft labels to the soft-key window.
+@@ -59,10 +61,10 @@
+ 		    }
+ 		} else {
+ 		    wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
+-		    if (SP && SP->_slk)
+-			wattrset(slk->win, SP->_slk->attr);
+-		    waddnstr(slk->win, slk->ent[i].form_text,
+-			     MAX_SKEY_LEN(fmt));
++		    if (SP && SP->_slk) {
++			wattrset(slk->win, AttrOf(SP->_slk->attr));
++		    }
++		    waddstr(slk->win, slk->ent[i].form_text);
+ 		    /* if we simulate SLK's, it's looking much more
+ 		       natural to use the current ATTRIBUTE also
+ 		       for the label window */
+Index: ncurses/base/lib_slkset.c
+Prereq:  1.10 
+--- ncurses-5.4-20040208/ncurses/base/lib_slkset.c	2003-04-12 21:32:16.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_slkset.c	2005-01-16 01:09:13.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -27,8 +27,8 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *  Author: Juergen Pfeifer                                                 *
++ *     and: Thomas E. Dickey                                                *
+  ****************************************************************************/
+ 
+ /*
+@@ -38,14 +38,20 @@
+ #include <curses.priv.h>
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_slkset.c,v 1.10 2003/04/12 21:32:16 tom Exp $")
++#if USE_WIDEC_SUPPORT
++#include <wctype.h>
++#endif
++
++MODULE_ID("$Id: lib_slkset.c,v 1.13 2005/01/16 01:09:13 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ slk_set(int i, const char *astr, int format)
+ {
+     SLK *slk = SP->_slk;
+-    size_t len;
+     int offset;
++    int numchrs;
++    int numcols;
++    int limit;
+     const char *str = astr;
+     const char *p;
+ 
+@@ -55,24 +61,52 @@
+ 	returnCode(ERR);
+     if (str == NULL)
+ 	str = "";
++    --i;			/* Adjust numbering of labels */
+ 
++    limit = MAX_SKEY_LEN(SP->slk_format);
+     while (isspace(UChar(*str)))
+ 	str++;			/* skip over leading spaces  */
+     p = str;
++
++#if USE_WIDEC_SUPPORT
++    numcols = 0;
++    while (*p != 0) {
++	mbstate_t state;
++	wchar_t wc;
++	size_t need;
++
++	init_mb(state);
++	need = mbrtowc(0, p, strlen(p), &state);
++	if (need == (size_t) -1)
++	    break;
++	mbrtowc(&wc, p, need, &state);
++	if (!iswprint(wc))
++	    break;
++	if (wcwidth(wc) + numcols > limit)
++	    break;
++	numcols += wcwidth(wc);
++	p += need;
++    }
++    numchrs = (p - str);
++#else
+     while (isprint(UChar(*p)))
+ 	p++;			/* The first non-print stops */
+ 
+-    --i;			/* Adjust numbering of labels */
++    numcols = (p - str);
++    if (numcols > limit)
++	numcols = limit;
++    numchrs = numcols;
++#endif
+ 
+-    len = (size_t) (p - str);
+-    if (len > (size_t) slk->maxlen)
+-	len = slk->maxlen;
+-    if (len == 0)
+-	slk->ent[i].ent_text[0] = 0;
+-    else
+-	strncpy(slk->ent[i].ent_text, str, len)[len] = 0;
+-    memset(slk->ent[i].form_text, ' ', (unsigned) slk->maxlen);
+-    slk->ent[i].ent_text[slk->maxlen] = 0;
++    FreeIfNeeded(slk->ent[i].ent_text);
++    if ((slk->ent[i].ent_text = strdup(str)) == 0)
++	returnCode(ERR);
++    slk->ent[i].ent_text[numchrs] = '\0';
++
++    if ((slk->ent[i].form_text = (char *) _nc_doalloc(slk->ent[i].form_text,
++						      limit + numchrs + 1)
++	) == 0)
++	returnCode(ERR);
+ 
+     switch (format) {
+     default:
+@@ -80,16 +114,28 @@
+ 	offset = 0;
+ 	break;
+     case 1:			/* centered */
+-	offset = (slk->maxlen - len) / 2;
++	offset = (limit - numcols) / 2;
+ 	break;
+     case 2:			/* right-justified */
+-	offset = slk->maxlen - len;
++	offset = limit - numcols;
+ 	break;
+     }
++    if (offset <= 0)
++	offset = 0;
++    else
++	memset(slk->ent[i].form_text, ' ', offset);
++
+     memcpy(slk->ent[i].form_text + offset,
+ 	   slk->ent[i].ent_text,
+-	   len);
+-    slk->ent[i].form_text[slk->maxlen] = 0;
++	   numchrs);
++
++    if (offset < limit) {
++	memset(slk->ent[i].form_text + offset + numchrs,
++	       ' ',
++	       limit - (offset + numcols));
++    }
++
++    slk->ent[i].form_text[numchrs - numcols + limit] = 0;
+     slk->ent[i].dirty = TRUE;
+     returnCode(OK);
+ }
+Index: ncurses/base/lib_wattroff.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/ncurses/base/lib_wattroff.c	2002-07-20 17:07:16.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_wattroff.c	2005-01-29 21:20:03.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -41,14 +42,18 @@
+ #include <curses.priv.h>
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_wattroff.c,v 1.7 2002/07/20 17:07:16 tom Exp $")
++MODULE_ID("$Id: lib_wattroff.c,v 1.8 2005/01/29 21:20:03 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ wattr_off(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
+ {
+     T((T_CALLED("wattr_off(%p,%s)"), win, _traceattr(at)));
+     if (win) {
+-	T(("... current %s", _traceattr(win->_attrs)));
++	T(("... current %s (%d)", _traceattr(win->_attrs), GET_WINDOW_PAIR(win)));
++	if_EXT_COLORS({
++	    if (at & A_COLOR)
++		win->_color = 0;
++	});
+ 	toggle_attr_off(win->_attrs, at);
+ 	returnCode(OK);
+     } else
+Index: ncurses/base/lib_wattron.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/ncurses/base/lib_wattron.c	2002-07-20 17:07:16.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/lib_wattron.c	2005-01-29 21:23:08.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -41,14 +42,18 @@
+ #include <curses.priv.h>
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_wattron.c,v 1.7 2002/07/20 17:07:16 tom Exp $")
++MODULE_ID("$Id: lib_wattron.c,v 1.8 2005/01/29 21:23:08 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ wattr_on(WINDOW *win, attr_t at, void *opts GCC_UNUSED)
+ {
+     T((T_CALLED("wattr_on(%p,%s)"), win, _traceattr(at)));
+-    if (win) {
+-	T(("... current %s", _traceattr(win->_attrs)));
++    if (win != 0) {
++	T(("... current %s (%d)", _traceattr(win->_attrs), GET_WINDOW_PAIR(win)));
++	if_EXT_COLORS({
++	    if (at & A_COLOR)
++		win->_color = PAIR_NUMBER(at);
++	});
+ 	toggle_attr_on(win->_attrs, at);
+ 	returnCode(OK);
+     } else
+Index: ncurses/base/resizeterm.c
+Prereq:  1.15 
+--- ncurses-5.4-20040208/ncurses/base/resizeterm.c	2002-12-28 01:21:34.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/resizeterm.c	2004-07-31 20:24:38.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2002,2004 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,18 +41,40 @@
+ #include <curses.priv.h>
+ #include <term.h>
+ 
+-MODULE_ID("$Id: resizeterm.c,v 1.15 2002/12/28 01:21:34 tom Exp $")
++MODULE_ID("$Id: resizeterm.c,v 1.17 2004/07/31 20:24:38 tom Exp $")
+ 
+ #define stolen_lines (screen_lines - SP->_lines_avail)
+ 
+ static int current_lines;
+ static int current_cols;
+ 
++#ifdef TRACE
++static void
++show_window_sizes(const char *name)
++{
++    WINDOWLIST *wp;
++
++    _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS,
++	    screen_lines, screen_columns);
++    for (wp = _nc_windows; wp != 0; wp = wp->next) {
++	_tracef("  window %p is %2d x %2d at %2d,%2d",
++		&(wp->win),
++		wp->win._maxy + 1,
++		wp->win._maxx + 1,
++		wp->win._begy,
++		wp->win._begx);
++    }
++}
++#endif
++
+ NCURSES_EXPORT(bool)
+ is_term_resized(int ToLines, int ToCols)
+ {
+-    return (ToLines != screen_lines
+-	    || ToCols != screen_columns);
++    T((T_CALLED("is_term_resized(%d, %d)"), ToLines, ToCols));
++    returnCode(ToLines > 0
++	       && ToCols > 0
++	       && (ToLines != screen_lines
++		   || ToCols != screen_columns));
+ }
+ 
+ /*
+@@ -162,6 +184,7 @@
+ 
+ 	    if (!(win->_flags & _ISPAD)) {
+ 		if (child_depth(win) == depth) {
++		    found = TRUE;
+ 		    if (adjust_window(win, ToLines, ToCols, stolen) != OK)
+ 			returnCode(ERR);
+ 		}
+@@ -194,6 +217,7 @@
+ 
+ 	    if (!(win->_flags & _ISPAD)) {
+ 		if (parent_depth(win) == depth) {
++		    found = TRUE;
+ 		    if (adjust_window(win, ToLines, ToCols, stolen) != OK)
+ 			returnCode(ERR);
+ 		}
+@@ -222,6 +246,10 @@
+ 	int myLines = current_lines = screen_lines;
+ 	int myCols = current_cols = screen_columns;
+ 
++#ifdef TRACE
++	if (_nc_tracing & TRACE_UPDATE)
++	    show_window_sizes("before");
++#endif
+ 	if (ToLines > screen_lines) {
+ 	    increase_size(myLines = ToLines, myCols, was_stolen);
+ 	    current_lines = myLines;
+@@ -250,6 +278,13 @@
+ 	if (SP->newhash) {
+ 	    FreeAndNull(SP->newhash);
+ 	}
++#ifdef TRACE
++	if (_nc_tracing & TRACE_UPDATE) {
++	    LINES = ToLines - was_stolen;
++	    COLS = ToCols;
++	    show_window_sizes("after");
++	}
++#endif
+     }
+ 
+     /*
+Index: ncurses/base/version.c
+Prereq:  1.5 
+--- ncurses-5.4-20040208/ncurses/base/version.c	2004-01-10 21:18:17.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/version.c	2005-01-02 01:23:54.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1999-2000,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 1999-2004,2005 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,11 +32,11 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: version.c,v 1.5 2004/01/10 21:18:17 tom Exp $")
++MODULE_ID("$Id: version.c,v 1.6 2005/01/02 01:23:54 tom Exp $")
+ 
+ NCURSES_EXPORT(const char *)
+ curses_version(void)
+ {
+     T((T_CALLED("curses_version()")));
+-    returnPtr("ncurses " NCURSES_VERSION_STRING);
++    returnCPtr("ncurses " NCURSES_VERSION_STRING);
+ }
+Index: ncurses/base/vsscanf.c
+Prereq:  1.17 
+--- ncurses-5.4-20040208/ncurses/base/vsscanf.c	2003-05-24 21:10:28.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/base/vsscanf.c	2004-04-03 20:27:02.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -38,7 +38,7 @@
+ 
+ #if !HAVE_VSSCANF
+ 
+-MODULE_ID("$Id: vsscanf.c,v 1.17 2003/05/24 21:10:28 tom Exp $")
++MODULE_ID("$Id: vsscanf.c,v 1.18 2004/04/03 20:27:02 tom Exp $")
+ 
+ #if !(HAVE_VFSCANF || HAVE__DOSCAN)
+ 
+@@ -271,7 +271,7 @@
+ 				chunk = ctest;
+ 			    } else if ((otest = other_ch(format[n])) != oUnknown) {
+ 				other = otest;
+-			    } else if (isalpha(format[n])) {
++			    } else if (isalpha(UChar(format[n]))) {
+ 				state = sFinal;
+ 				chunk = cError;
+ 			    }
+Index: ncurses/curses.priv.h
+Prereq:  1.255 
+--- ncurses-5.4-20040208/ncurses/curses.priv.h	2004-02-01 01:05:58.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/curses.priv.h	2005-03-05 20:18:47.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,12 +29,12 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+- *     and: Thomas E. Dickey 1996-2002                                      *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ 
+ /*
+- * $Id: curses.priv.h,v 1.255 2004/02/01 01:05:58 Stanislav.Ievlev Exp $
++ * $Id: curses.priv.h,v 1.281 2005/03/05 20:18:47 tom Exp $
+  *
+  *	curses.priv.h
+  *
+@@ -78,6 +78,11 @@
+ # include <sys/param.h>
+ #endif
+ 
++#include <assert.h>
++#include <stdio.h>
++
++#include <errno.h>
++
+ #ifndef PATH_MAX
+ # if defined(_POSIX_PATH_MAX)
+ #  define PATH_MAX _POSIX_PATH_MAX
+@@ -88,11 +93,6 @@
+ # endif
+ #endif
+ 
+-#include <assert.h>
+-#include <stdio.h>
+-
+-#include <errno.h>
+-
+ #if DECL_ERRNO
+ extern int errno;
+ #endif
+@@ -210,14 +210,6 @@
+ };
+ 
+ /*
+- * Definitions for color pairs
+- */
+-#define C_SHIFT 8		/* we need more bits than there are colors */
+-#define C_MASK  ((1 << C_SHIFT) - 1)
+-
+-#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
+-
+-/*
+  * Common/troublesome character definitions
+  */
+ #define L_BRACE '{'
+@@ -259,6 +251,46 @@
+ #include <curses.h>	/* we'll use -Ipath directive to get the right one! */
+ #include <term.h>
+ 
++#if NCURSES_EXT_COLORS && USE_WIDEC_SUPPORT
++#define if_EXT_COLORS(stmt)	stmt
++#define NetPair(value,p)	(value).ext_color = (p), \
++				AttrOf(value) &= ALL_BUT_COLOR, \
++				AttrOf(value) |= (A_COLOR & COLOR_PAIR((p > 255) ? 255 : p))
++#define SetPair(value,p)	(value).ext_color = (p)
++#define GetPair(value)		(value).ext_color
++#define unColor(n)		(AttrOf(n) & ALL_BUT_COLOR)
++#define GET_WINDOW_PAIR(w)	(w)->_color
++#define SET_WINDOW_PAIR(w,p)	(w)->_color = (p)
++#define SameAttrOf(a,b)		(AttrOf(a) == AttrOf(b) && GetPair(a) == GetPair(b))
++#define VIDATTR(attr, pair)	vid_attr(attr, pair, 0)
++#else
++#define if_EXT_COLORS(stmt)	/* nothing */
++#define SetPair(value,p)	RemAttr(value, A_COLOR), \
++				SetAttr(value, AttrOf(value) | (A_COLOR & COLOR_PAIR(p)))
++#define GetPair(value)		PAIR_NUMBER(AttrOf(value))
++#define unColor(n)		(AttrOf(n) & ALL_BUT_COLOR)
++#define GET_WINDOW_PAIR(w)	PAIR_NUMBER((w)->_attrs)
++#define SET_WINDOW_PAIR(w,p)	(w)->_attrs &= ALL_BUT_COLOR, \
++				(w)->_attrs |= (A_COLOR & COLOR_PAIR(p))
++#define SameAttrOf(a,b)		(AttrOf(a) == AttrOf(b))
++#define VIDATTR(attr, pair)	vidattr(attr)
++#endif
++
++#define SCREEN_ATTRS(s)		(*((s)->_current_attr))
++#define GET_SCREEN_PAIR(s)	GetPair(SCREEN_ATTRS(s))
++#define SET_SCREEN_PAIR(s,p)	SetPair(SCREEN_ATTRS(s), p)
++
++/*
++ * Definitions for color pairs
++ */
++typedef unsigned colorpair_t;	/* type big enough to store PAIR_OF() */
++#define C_SHIFT 9		/* we need more bits than there are colors */
++#define C_MASK			((1 << C_SHIFT) - 1)
++#define PAIR_OF(fg, bg)		((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
++#define isDefaultColor(c)	((c) >= COLOR_DEFAULT || (c) < 0)
++
++#define COLOR_DEFAULT		C_MASK
++
+ struct ldat
+ {
+ 	NCURSES_CH_T	*text;		/* text of the line */
+@@ -279,9 +311,28 @@
+ } MouseType;
+ 
+ /*
+- * Structure for soft labels.
++ * Structures for scrolling.
++ */
++
++typedef struct {
++	unsigned long hashval;
++	int oldcount, newcount;
++	int oldindex, newindex;
++} HASHMAP;
++
++/*
++ * Structures for soft labels.
+  */
+ 
++struct _SLK;
++
++#ifdef USE_TERMLIB
++
++#undef NCURSES_CH_T		/* this is not a termlib feature */
++#define NCURSES_CH_T void	/* ...but we need a pointer in SCREEN */
++
++#else
++
+ typedef struct
+ {
+ 	char *ent_text;         /* text for the label */
+@@ -291,7 +342,7 @@
+ 	char visible;           /* field is visible */
+ } slk_ent;
+ 
+-typedef struct {
++typedef struct _SLK {
+ 	char dirty;             /* all labels have changed */
+ 	char hidden;            /* soft labels are hidden */
+ 	WINDOW *win;
+@@ -299,14 +350,10 @@
+ 	short  maxlab;          /* number of available labels */
+ 	short  labcnt;          /* number of allocated labels */
+ 	short  maxlen;          /* length of labels */
+-	chtype attr;            /* soft label attribute */
++	NCURSES_CH_T attr;      /* soft label attribute */
+ } SLK;
+ 
+-typedef struct {
+-	unsigned long hashval;
+-	int oldcount, newcount;
+-	int oldindex, newindex;
+-} HASHMAP;
++#endif
+ 
+ typedef	struct {
+ 	int	line;           /* lines to take, < 0 => from bottom*/
+@@ -314,6 +361,10 @@
+ 	WINDOW *w;              /* maybe we need this for cleanup   */
+ } ripoff_t;
+ 
++/*
++ * The SCREEN structure.
++ */
++
+ struct screen {
+ 	int             _ifd;           /* input file ptr for screen        */
+ 	FILE            *_ofp;          /* output file ptr for screen       */
+@@ -339,14 +390,14 @@
+ 	bool            _keypad_on;     /* keypad mode is currently on      */
+ 
+ 	bool		_called_wgetch;	/* check for recursion in wgetch()  */
+-	int    	        _fifo[FIFO_SIZE];       /* input push-back buffer   */
++	int		_fifo[FIFO_SIZE];	/* input push-back buffer   */
+ 	short           _fifohead,      /* head of fifo queue               */
+ 	                _fifotail,      /* tail of fifo queue               */
+ 	                _fifopeek,      /* where to peek for next char      */
+ 	                _fifohold;      /* set if breakout marked           */
+ 
+ 	int             _endwin;        /* are we out of window mode?       */
+-	attr_t          _current_attr;  /* terminal attribute current set   */
++	NCURSES_CH_T	*_current_attr; /* holds current attributes set     */
+ 	int             _coloron;       /* is color enabled?                */
+ 	int		_color_defs;	/* are colors modified		    */
+ 	int             _cursor;        /* visibility of the cursor         */
+@@ -359,7 +410,7 @@
+ 	                                /* > 1 if in halfdelay mode         */
+ 	int             _echo;          /* True if echo on                  */
+ 	int             _use_meta;      /* use the meta key?                */
+-	SLK             *_slk;          /* ptr to soft key struct / NULL    */
++	struct _SLK     *_slk;          /* ptr to soft key struct / NULL    */
+         int             slk_format;     /* selected format for this screen  */
+ 	/* cursor movement costs; units are 10ths of milliseconds */
+ #if NCURSES_NO_PADDING
+@@ -409,7 +460,7 @@
+ 	/* used in lib_color.c */
+ 	color_t         *_color_table;  /* screen's color palette            */
+ 	int             _color_count;   /* count of colors in palette        */
+-	unsigned short  *_color_pairs;  /* screen's color pair list          */
++	colorpair_t     *_color_pairs;  /* screen's color pair list          */
+ 	int             _pair_count;    /* count of color pairs              */
+ #if NCURSES_EXT_FUNCS
+ 	bool            _default_color; /* use default colors                */
+@@ -483,7 +534,7 @@
+ 
+ 	/* hashes for old and new lines */
+ 	unsigned long	*oldhash, *newhash;
+-	HASHMAP 	*hashtab;
++	HASHMAP		*hashtab;
+ 	int		hashtab_len;
+ 
+ 	bool            _cleanup;	/* cleanup after int/quit signal */
+@@ -493,9 +544,10 @@
+ 	 * UTF-8, but do not permit ACS at the same time (see tty_update.c).
+ 	 */
+ #if USE_WIDEC_SUPPORT
+-	bool		_posix_locale;
++	bool		_legacy_coding;
+ 	bool		_screen_acs_fix;
+ #endif
++	bool		_screen_acs_map[ACS_LEN];
+ };
+ 
+ extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain;
+@@ -509,17 +561,25 @@
+ 	WINDOWLIST *next;
+ #ifdef _XOPEN_SOURCE_EXTENDED
+ 	char addch_work[(MB_LEN_MAX * 9) + 1];
+-	int addch_used;
+-	int addch_x;
+-	int addch_y;
++	int addch_used;		/* number of bytes in addch_work[] */
++	int addch_x;		/* x-position for addch_work[] */
++	int addch_y;		/* y-position for addch_work[] */
+ #endif
+ };
+ 
+ #define WINDOW_EXT(win,field) (((WINDOWLIST *)(win))->field)
+ 
++/* usually in <limits.h> */
++#ifndef UCHAR_MAX
++#define UCHAR_MAX 255
++#endif
++
+ /* The terminfo source is assumed to be 7-bit ASCII */
+ #define is7bits(c)	((unsigned)(c) < 128)
+ 
++/* Checks for isprint() should be done on 8-bit characters (non-wide) */
++#define is8bits(c)	((unsigned)(c) <= UCHAR_MAX)
++
+ #ifndef min
+ #define min(a,b)	((a) > (b)  ?  (b)  :  (a))
+ #endif
+@@ -585,18 +645,31 @@
+ #endif
+ 
+ #if USE_WIDEC_SUPPORT /* { */
++#define isEILSEQ(status) ((status == (size_t)-1) && (errno == EILSEQ))
++
++#define init_mb(state)	memset(&state, 0, sizeof(state))
++
++#if NCURSES_EXT_COLORS
++#define NulColor	, 0
++#else
++#define NulColor	/* nothing */
++#endif
++
+ #define NulChar		0,0,0,0	/* FIXME: see CCHARW_MAX */
+ #define CharOf(c)	((c).chars[0])
+ #define AttrOf(c)	((c).attr)
+-#define AddAttr(c,a)	(c).attr |= a
+-#define RemAttr(c,a)	(c).attr &= ~(a)
+-#define SetAttr(c,a)	(c).attr = a
+-#define NewChar(ch)	{ ChAttrOf(ch), { ChCharOf(ch), NulChar } }
+-#define NewChar2(c,a)	{ a, { c, NulChar } }
++#define AddAttr(c,a)	AttrOf(c) |= a
++#define RemAttr(c,a)	AttrOf(c) &= ~(a)
++#define SetAttr(c,a)	AttrOf(c) = a
++#define NewChar(ch)	{ ChAttrOf(ch), { ChCharOf(ch), NulChar } NulColor }
++#define NewChar2(c,a)	{ a, { c, NulChar } NulColor }
+ #define CharEq(a,b)	(!memcmp(&a, &b, sizeof(a)))
+-#define SetChar(ch,c,a)	do { 							    \
++#define SetChar(ch,c,a) do {							    \
+ 			    NCURSES_CH_T *_cp = &ch;				    \
+-			    memset(_cp,0,sizeof(ch)); _cp->chars[0] = c; _cp->attr = a; \
++			    memset(_cp, 0, sizeof(ch));				    \
++			    _cp->chars[0] = c;					    \
++			    _cp->attr = a;					    \
++			    if_EXT_COLORS(SetPair(ch, PAIR_NUMBER(a)));		    \
+ 			} while (0)
+ #define CHREF(wch)	(&wch)
+ #define CHDEREF(wch)	(*wch)
+@@ -604,9 +677,9 @@
+ #define CARG_CH_T	const NCURSES_CH_T *
+ #define PUTC_DATA	char PUTC_buf[MB_LEN_MAX]; int PUTC_i, PUTC_n; \
+ 			mbstate_t PUT_st; wchar_t PUTC_ch
+-#define PUTC_INIT	memset (&PUT_st, '\0', sizeof (PUT_st));		    \
++#define PUTC_INIT	init_mb (PUT_st);					    \
+ 			PUTC_i = 0
+-#define PUTC(ch,b)	do { if(!isnac(ch)) { 					    \
++#define PUTC(ch,b)	do { if(!isWidecExt(ch)) {				    \
+ 			if (Charable(ch)) {					    \
+ 			    fputc(CharOf(ch), b);				    \
+ 			    TRACE_OUTCHARS(1);					    \
+@@ -627,14 +700,27 @@
+ 			    TRACE_OUTCHARS(PUTC_i);				    \
+ 			} } } while (0)
+ 
+-#define BLANK		{ WA_NORMAL, ' ' }
++#define BLANK		{ WA_NORMAL, {' '} NulColor }
++#define ZEROS		{ WA_NORMAL, {'\0'} NulColor }
+ #define ISBLANK(ch)	((ch).chars[0] == L' ' && (ch).chars[1] == L'\0')
+ 
+-#define WA_NAC		1
+-#define isnac(ch)	(AttrOf(ch) & WA_NAC)
++	/*
++	 * Wide characters cannot be represented in the A_CHARTEXT mask of
++	 * attr_t's but an application might have set a narrow character there.
++	 * But even in that case, it would only be a printable character, or
++	 * zero.  Otherwise we can use those bits to tell if a cell is the
++	 * first or extension part of a wide character.
++	 */
++#define WidecExt(ch)	(AttrOf(ch) & A_CHARTEXT)
++#define isWidecBase(ch)	(WidecExt(ch) == 1)
++#define isWidecExt(ch)	(WidecExt(ch) > 1 && WidecExt(ch) < 32)
++#define SetWidecExt(dst, ext)	AttrOf(dst) &= ~A_CHARTEXT,		\
++				AttrOf(dst) |= (ext + 1)
++
+ #define if_WIDEC(code)  code
+-#define Charable(ch)	((SP != 0 && SP->_posix_locale)			\
+-			 || (!isnac(ch) &&				\
++#define Charable(ch)	((SP != 0 && SP->_legacy_coding)		\
++			 || (AttrOf(ch) & A_ALTCHARSET)			\
++			 || (!isWidecExt(ch) &&				\
+ 			     (ch).chars[1] == L'\0' &&			\
+                              _nc_is_charable(CharOf(ch))))
+ 
+@@ -657,9 +743,10 @@
+ #define PUTC(a,b)	do { data = CharOf(ch); putc(data,b); } while (0)
+ 
+ #define BLANK		(' '|A_NORMAL)
++#define ZEROS		('\0'|A_NORMAL)
+ #define ISBLANK(ch)	(CharOf(ch) == ' ')
+ 
+-#define isnac(ch)	(0)
++#define isWidecExt(ch)	(0)
+ #define if_WIDEC(code) /* nothing */
+ 
+ #define L(ch)		ch
+@@ -674,6 +761,11 @@
+ 
+ #define CHANGED     -1
+ 
++#define LEGALYX(w, y, x) \
++	      ((w) != 0 && \
++		((x) >= 0 && (x) <= (w)->_maxx && \
++		 (y) >= 0 && (y) <= (w)->_maxy))
++
+ #define CHANGED_CELL(line,col) \
+ 	if (line->firstchar == _NOCHANGE) \
+ 		line->firstchar = line->lastchar = col; \
+@@ -730,17 +822,21 @@
+ #define TPUTS_TRACE(s)	_nc_tputs_trace = s;
+ #define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
+ 
+-#define returnAttr(code) TRACE_RETURN(code,attr_t)
+-#define returnChar(code) TRACE_RETURN(code,chtype)
+-#define returnBool(code) TRACE_RETURN(code,bool)
+-#define returnBits(code) TRACE_RETURN(code,unsigned)
+-#define returnCode(code) TRACE_RETURN(code,int)
+-#define returnPtr(code)  TRACE_RETURN(code,ptr)
+-#define returnSP(code)   TRACE_RETURN(code,sp)
+-#define returnVoid       T((T_RETURN(""))); return
+-#define returnWin(code)  TRACE_RETURN(code,win)
++#define returnAttr(code)	TRACE_RETURN(code,attr_t)
++#define returnBits(code)	TRACE_RETURN(code,unsigned)
++#define returnBool(code)	TRACE_RETURN(code,bool)
++#define returnCPtr(code)	TRACE_RETURN(code,cptr)
++#define returnCVoidPtr(code)	TRACE_RETURN(code,cvoid_ptr)
++#define returnChar(code)	TRACE_RETURN(code,chtype)
++#define returnCode(code)	TRACE_RETURN(code,int)
++#define returnPtr(code)		TRACE_RETURN(code,ptr)
++#define returnSP(code)		TRACE_RETURN(code,sp)
++#define returnVoid		T((T_RETURN(""))); return
++#define returnVoidPtr(code)	TRACE_RETURN(code,void_ptr)
++#define returnWin(code)		TRACE_RETURN(code,win)
+ 
+ extern NCURSES_EXPORT(NCURSES_BOOL)     _nc_retrace_bool (NCURSES_BOOL);
++extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *);
+ extern NCURSES_EXPORT(SCREEN *)         _nc_retrace_sp (SCREEN *);
+ extern NCURSES_EXPORT(WINDOW *)         _nc_retrace_win (WINDOW *);
+ extern NCURSES_EXPORT(attr_t)           _nc_retrace_attr_t (attr_t);
+@@ -749,8 +845,10 @@
+ extern NCURSES_EXPORT(char *)           _nc_varargs (const char *, va_list);
+ extern NCURSES_EXPORT(chtype)           _nc_retrace_chtype (chtype);
+ extern NCURSES_EXPORT(const char *)     _nc_altcharset_name(attr_t, chtype);
++extern NCURSES_EXPORT(const char *)     _nc_retrace_cptr (const char *);
+ extern NCURSES_EXPORT(int)              _nc_retrace_int (int);
+ extern NCURSES_EXPORT(unsigned)         _nc_retrace_unsigned (unsigned);
++extern NCURSES_EXPORT(void *)           _nc_retrace_void_ptr (void *);
+ extern NCURSES_EXPORT(void)             _nc_fifo_dump (void);
+ extern NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace;
+ extern NCURSES_EXPORT_VAR(long)         _nc_outchars;
+@@ -771,15 +869,18 @@
+ #define TR(n, a)
+ #define TPUTS_TRACE(s)
+ 
+-#define returnAttr(code) return code
+-#define returnBits(code) return code
+-#define returnBool(code) return code
+-#define returnChar(code) return code
+-#define returnCode(code) return code
+-#define returnPtr(code)  return code
+-#define returnSP(code)   return code
+-#define returnVoid       return
+-#define returnWin(code)  return code
++#define returnAttr(code)	return code
++#define returnBits(code)	return code
++#define returnBool(code)	return code
++#define returnCPtr(code)	return code
++#define returnCVoidPtr(code)	return code
++#define returnChar(code)	return code
++#define returnCode(code)	return code
++#define returnPtr(code)		return code
++#define returnSP(code)		return code
++#define returnVoid		return
++#define returnVoidPtr(code)	return code
++#define returnWin(code)		return code
+ 
+ #endif /* TRACE/!TRACE */
+ 
+@@ -791,29 +892,23 @@
+ 	NCURSES_EXPORT(void) name (void) { }
+ 
+ #define ALL_BUT_COLOR ((chtype)~(A_COLOR))
+-#define IGNORE_COLOR_OFF FALSE
+ #define NONBLANK_ATTR (A_NORMAL|A_BOLD|A_DIM|A_BLINK)
+ #define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
+ 
+ #define toggle_attr_on(S,at) {\
+-   if (PAIR_NUMBER(at) > 0)\
++   if (PAIR_NUMBER(at) > 0) {\
+       (S) = ((S) & ALL_BUT_COLOR) | (at);\
+-   else\
++   } else {\
+       (S) |= (at);\
++   }\
+    TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
+ 
+ 
+ #define toggle_attr_off(S,at) {\
+-   if (IGNORE_COLOR_OFF == TRUE) {\
+-      if (PAIR_NUMBER(at) == 0xff) /* turn off color */\
+-	 (S) &= ~(at);\
+-      else /* leave color alone */\
+-	 (S) &= ~((at)&ALL_BUT_COLOR);\
++   if (PAIR_NUMBER(at) > 0) {\
++      (S) &= ~(at|A_COLOR);\
+    } else {\
+-      if (PAIR_NUMBER(at) > 0x00) /* turn off color */\
+-	 (S) &= ~(at|A_COLOR);\
+-      else /* leave color alone */\
+-	 (S) &= ~(at);\
++      (S) &= ~(at);\
+    }\
+    TR(TRACE_ATTRS, ("new attribute is %s", _traceattr((S))));}
+ 
+@@ -834,11 +929,11 @@
+ 		    : INFINITY)))
+ 
+ #if USE_XMC_SUPPORT
+-#define UpdateAttrs(a)	if (SP->_current_attr != (a)) { \
+-				attr_t chg = SP->_current_attr; \
+-				vidattr((a)); \
++#define UpdateAttrs(c)	if (!SameAttrOf(SCREEN_ATTRS(SP), c)) { \
++				attr_t chg = AttrOf(SCREEN_ATTRS(SP)); \
++				VIDATTR(AttrOf(c), GetPair(c)); \
+ 				if (magic_cookie_glitch > 0 \
+-				 && XMC_CHANGES((chg ^ SP->_current_attr))) { \
++				 && XMC_CHANGES((chg ^ AttrOf(SCREEN_ATTRS(SP))))) { \
+ 					T(("%s @%d before glitch %d,%d", \
+ 						__FILE__, __LINE__, \
+ 						SP->_cursrow, \
+@@ -847,8 +942,8 @@
+ 				} \
+ 			}
+ #else
+-#define UpdateAttrs(a)	if (SP->_current_attr != (a)) \
+-				vidattr((a));
++#define UpdateAttrs(c)	if (!SameAttrOf(SCREEN_ATTRS(SP), c)) \
++				VIDATTR(AttrOf(c), GetPair(c));
+ #endif
+ 
+ /*
+@@ -884,7 +979,7 @@
+ 
+ #undef  UpdateAttrs
+ #define UpdateAttrs(c) _nc_UpdateAttrs(c)
+-extern NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype);
++extern NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T);
+ 
+ #else
+ 
+@@ -917,6 +1012,11 @@
+ extern NCURSES_EXPORT(void) _nc_init_acs (void);	/* corresponds to traditional 'init_acs()' */
+ extern NCURSES_EXPORT(int) _nc_msec_cost (const char *const, int);  /* used by 'tack' program */
+ 
++/* lib_addch.c */
++#if USE_WIDEC_SUPPORT
++NCURSES_EXPORT(int) _nc_build_wch(WINDOW *win, ARG_CH_T ch);
++#endif
++
+ /* lib_addstr.c */
+ #if USE_WIDEC_SUPPORT
+ extern NCURSES_EXPORT(int) _nc_wchstrlen(const cchar_t *);
+@@ -929,7 +1029,7 @@
+ extern NCURSES_EXPORT(int) _nc_wgetch(WINDOW *, unsigned long *, int EVENTLIST_2nd(_nc_eventlist *));
+ 
+ /* lib_insch.c */
+-extern NCURSES_EXPORT(void) _nc_insert_ch(WINDOW *, chtype);
++extern NCURSES_EXPORT(int) _nc_insert_ch(WINDOW *, chtype);
+ 
+ /* lib_mvcur.c */
+ #define INFINITY	1000000	/* cost: too high to use */
+@@ -955,6 +1055,7 @@
+ extern NCURSES_EXPORT(char *) _nc_get_locale(void);
+ extern NCURSES_EXPORT(int) _nc_unicode_locale(void);
+ extern NCURSES_EXPORT(int) _nc_locale_breaks_acs(void);
++extern NCURSES_EXPORT(int) _nc_setupterm(NCURSES_CONST char *, int , int *, bool);
+ 
+ /* lib_wacs.c */
+ #if USE_WIDEC_SUPPORT
+@@ -975,16 +1076,6 @@
+ extern NCURSES_EXPORT(bool) _nc_safe_strcat (string_desc *, const char *);
+ extern NCURSES_EXPORT(bool) _nc_safe_strcpy (string_desc *, const char *);
+ 
+-extern NCURSES_EXPORT(void) _nc_mvcur_init (void);
+-extern NCURSES_EXPORT(void) _nc_mvcur_resume (void);
+-extern NCURSES_EXPORT(void) _nc_mvcur_wrap (void);
+-
+-extern NCURSES_EXPORT(int) _nc_scrolln (int, int, int, int);
+-
+-extern NCURSES_EXPORT(void) _nc_screen_init (void);
+-extern NCURSES_EXPORT(void) _nc_screen_resume (void);
+-extern NCURSES_EXPORT(void) _nc_screen_wrap (void);
+-
+ #if !HAVE_STRSTR
+ #define strstr _nc_strstr
+ extern NCURSES_EXPORT(char *) _nc_strstr (const char *, const char *);
+@@ -1000,7 +1091,6 @@
+ extern NCURSES_EXPORT(int) _nc_remove_string (struct tries **, const char *);
+ 
+ /* elsewhere ... */
+-extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
+ extern NCURSES_EXPORT(WINDOW *) _nc_makenew (int, int, int, int, int);
+ extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
+ extern NCURSES_EXPORT(char *) _nc_trace_buf (int, size_t);
+@@ -1014,7 +1104,6 @@
+ extern NCURSES_EXPORT(int) _nc_outch (int);
+ extern NCURSES_EXPORT(int) _nc_setupscreen (short, short const, FILE *);
+ extern NCURSES_EXPORT(int) _nc_timed_wait(int, int, int * EVENTLIST_2nd(_nc_eventlist *));
+-extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
+ extern NCURSES_EXPORT(void) _nc_do_color (int, int, bool, int (*)(int));
+ extern NCURSES_EXPORT(void) _nc_flush (void);
+ extern NCURSES_EXPORT(void) _nc_freeall (void);
+@@ -1024,12 +1113,25 @@
+ extern NCURSES_EXPORT(void) _nc_make_oldhash (int i);
+ extern NCURSES_EXPORT(void) _nc_scroll_oldhash (int n, int top, int bot);
+ extern NCURSES_EXPORT(void) _nc_scroll_optimize (void);
+-extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, short const, short const, NCURSES_CH_T);
+ extern NCURSES_EXPORT(void) _nc_set_buffer (FILE *, bool);
+ extern NCURSES_EXPORT(void) _nc_signal_handler (bool);
+ extern NCURSES_EXPORT(void) _nc_synchook (WINDOW *);
+ extern NCURSES_EXPORT(void) _nc_trace_tries (struct tries *);
+ 
++#ifndef USE_TERMLIB
++extern NCURSES_EXPORT(NCURSES_CH_T) _nc_render (WINDOW *, NCURSES_CH_T);
++extern NCURSES_EXPORT(int) _nc_waddch_nosync (WINDOW *, const NCURSES_CH_T);
++extern NCURSES_EXPORT(void) _nc_scroll_window (WINDOW *, int const, short const, short const, NCURSES_CH_T);
++#endif
++
++#if USE_WIDEC_SUPPORT
++#ifdef linux
++extern NCURSES_EXPORT(size_t) _nc_wcrtomb (char *, wchar_t, mbstate_t *);
++#else
++#define _nc_wcrtomb(s,wc,ps) wcrtomb(s,wc,ps)
++#endif
++#endif
++
+ #if USE_SIZECHANGE
+ extern NCURSES_EXPORT(void) _nc_update_screensize (void);
+ #endif
+Index: ncurses/llib-lncurses
+--- ncurses-5.4-20040208/ncurses/llib-lncurses	2004-01-31 16:16:48.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/llib-lncurses	2005-03-05 19:53:55.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey 1996-2003,2004                                 *
++ *  Author: Thomas E. Dickey 1996-2004,2005                                 *
+  ****************************************************************************/
+ /* LINTLIBRARY */
+ 
+@@ -48,6 +48,8 @@
+ 
+ /* ./tty/hashmap.c */
+ 
++#include <term.h>
++
+ #undef _nc_hash_map
+ void	_nc_hash_map(void)
+ 		{ /* void */ }
+@@ -59,8 +61,8 @@
+ 
+ #undef _nc_scroll_oldhash
+ void	_nc_scroll_oldhash(
+-		int	n,
+-		int	top,
++		int	n, 
++		int	top, 
+ 		int	bot)
+ 		{ /* void */ }
+ 
+@@ -70,25 +72,25 @@
+ 
+ #undef _nc_render
+ chtype	_nc_render(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		chtype	ch)
+ 		{ return(*(chtype *)0); }
+ 
+ #undef _nc_waddch_nosync
+ int	_nc_waddch_nosync(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const chtype c)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddch
+ int	waddch(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const chtype ch)
+ 		{ return(*(int *)0); }
+ 
+ #undef wechochar
+ int	wechochar(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const chtype ch)
+ 		{ return(*(int *)0); }
+ 
+@@ -96,15 +98,15 @@
+ 
+ #undef waddnstr
+ int	waddnstr(
+-		WINDOW	*win,
+-		const char *astr,
++		WINDOW	*win, 
++		const char *astr, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddchnstr
+ int	waddchnstr(
+-		WINDOW	*win,
+-		const chtype *astr,
++		WINDOW	*win, 
++		const chtype *astr, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -118,13 +120,13 @@
+ 
+ #undef wbkgdset
+ void	wbkgdset(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		chtype	ch)
+ 		{ /* void */ }
+ 
+ #undef wbkgd
+ int	wbkgd(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		chtype	ch)
+ 		{ return(*(int *)0); }
+ 
+@@ -132,14 +134,14 @@
+ 
+ #undef wborder
+ int	wborder(
+-		WINDOW	*win,
+-		chtype	ls,
+-		chtype	rs,
+-		chtype	ts,
+-		chtype	bs,
+-		chtype	tl,
+-		chtype	tr,
+-		chtype	bl,
++		WINDOW	*win, 
++		chtype	ls, 
++		chtype	rs, 
++		chtype	ts, 
++		chtype	bs, 
++		chtype	tl, 
++		chtype	tr, 
++		chtype	bl, 
+ 		chtype	br)
+ 		{ return(*(int *)0); }
+ 
+@@ -147,10 +149,10 @@
+ 
+ #undef wchgat
+ int	wchgat(
+-		WINDOW	*win,
+-		int	n,
+-		attr_t	attr,
+-		short	color,
++		WINDOW	*win, 
++		int	n, 
++		attr_t	attr, 
++		short	color, 
+ 		const void *opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -165,7 +167,7 @@
+ 
+ #undef clearok
+ int	clearok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -202,16 +204,16 @@
+ 
+ #undef init_pair
+ int	init_pair(
+-		short	pair,
+-		short	f,
++		short	pair, 
++		short	f, 
+ 		short	b)
+ 		{ return(*(int *)0); }
+ 
+ #undef init_color
+ int	init_color(
+-		short	color,
+-		short	r,
+-		short	g,
++		short	color, 
++		short	r, 
++		short	g, 
+ 		short	b)
+ 		{ return(*(int *)0); }
+ 
+@@ -225,24 +227,24 @@
+ 
+ #undef color_content
+ int	color_content(
+-		short	color,
+-		short	*r,
+-		short	*g,
++		short	color, 
++		short	*r, 
++		short	*g, 
+ 		short	*b)
+ 		{ return(*(int *)0); }
+ 
+ #undef pair_content
+ int	pair_content(
+-		short	pair,
+-		short	*f,
++		short	pair, 
++		short	*f, 
+ 		short	*b)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_do_color
+ void	_nc_do_color(
+-		int	old_pair,
+-		int	pair,
+-		NCURSES_BOOL reverse,
++		int	old_pair, 
++		int	pair, 
++		NCURSES_BOOL reverse, 
+ 		int	(*outc)(
+ 		int	p1))
+ 		{ /* void */ }
+@@ -251,8 +253,8 @@
+ 
+ #undef wcolor_set
+ int	wcolor_set(
+-		WINDOW	*win,
+-		short	color_pair_number,
++		WINDOW	*win, 
++		short	color_pair_number, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -308,7 +310,7 @@
+ 
+ #undef addchnstr
+ int	addchnstr(
+-		const chtype *a1,
++		const chtype *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -319,7 +321,7 @@
+ 
+ #undef addnstr
+ int	addnstr(
+-		const char *a1,
++		const char *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -345,27 +347,27 @@
+ 
+ #undef attr_get
+ int	attr_get(
+-		attr_t	*a1,
+-		short	*a2,
++		attr_t	*a1, 
++		short	*a2, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef attr_off
+ int	attr_off(
+-		attr_t	a1,
++		attr_t	a1, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef attr_on
+ int	attr_on(
+-		attr_t	a1,
++		attr_t	a1, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef attr_set
+ int	attr_set(
+-		attr_t	a1,
+-		short	a2,
++		attr_t	a1, 
++		short	a2, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -381,28 +383,28 @@
+ 
+ #undef border
+ int	border(
+-		chtype	a1,
+-		chtype	a2,
+-		chtype	a3,
+-		chtype	a4,
+-		chtype	a5,
+-		chtype	a6,
+-		chtype	a7,
++		chtype	a1, 
++		chtype	a2, 
++		chtype	a3, 
++		chtype	a4, 
++		chtype	a5, 
++		chtype	a6, 
++		chtype	a7, 
+ 		chtype	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef box
+ int	box(
+-		WINDOW	*a1,
+-		chtype	a2,
++		WINDOW	*a1, 
++		chtype	a2, 
+ 		chtype	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef chgat
+ int	chgat(
+-		int	a1,
+-		attr_t	a2,
+-		short	a3,
++		int	a1, 
++		attr_t	a2, 
++		short	a3, 
+ 		const void *z)
+ 		{ return(*(int *)0); }
+ 
+@@ -420,7 +422,7 @@
+ 
+ #undef color_set
+ int	color_set(
+-		short	a1,
++		short	a1, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -457,7 +459,7 @@
+ 
+ #undef getnstr
+ int	getnstr(
+-		char	*a1,
++		char	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -468,7 +470,7 @@
+ 
+ #undef hline
+ int	hline(
+-		chtype	a1,
++		chtype	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -478,7 +480,7 @@
+ 
+ #undef inchnstr
+ int	inchnstr(
+-		chtype	*a1,
++		chtype	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -489,7 +491,7 @@
+ 
+ #undef innstr
+ int	innstr(
+-		char	*a1,
++		char	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -509,7 +511,7 @@
+ 
+ #undef insnstr
+ int	insnstr(
+-		const char *a1,
++		const char *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -525,323 +527,323 @@
+ 
+ #undef move
+ int	move(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddch
+ int	mvaddch(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const chtype z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddchnstr
+ int	mvaddchnstr(
+-		int	a1,
+-		int	a2,
+-		const chtype *a3,
++		int	a1, 
++		int	a2, 
++		const chtype *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddchstr
+ int	mvaddchstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const chtype *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddnstr
+ int	mvaddnstr(
+-		int	a1,
+-		int	a2,
+-		const char *a3,
++		int	a1, 
++		int	a2, 
++		const char *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddstr
+ int	mvaddstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvchgat
+ int	mvchgat(
+-		int	a1,
+-		int	a2,
+-		int	a3,
+-		attr_t	a4,
+-		short	a5,
++		int	a1, 
++		int	a2, 
++		int	a3, 
++		attr_t	a4, 
++		short	a5, 
+ 		const void *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvdelch
+ int	mvdelch(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvgetch
+ int	mvgetch(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvgetnstr
+ int	mvgetnstr(
+-		int	a1,
+-		int	a2,
+-		char	*a3,
++		int	a1, 
++		int	a2, 
++		char	*a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvgetstr
+ int	mvgetstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvhline
+ int	mvhline(
+-		int	a1,
+-		int	a2,
+-		chtype	a3,
++		int	a1, 
++		int	a2, 
++		chtype	a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinch
+ chtype	mvinch(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(chtype *)0); }
+ 
+ #undef mvinchnstr
+ int	mvinchnstr(
+-		int	a1,
+-		int	a2,
+-		chtype	*a3,
++		int	a1, 
++		int	a2, 
++		chtype	*a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinchstr
+ int	mvinchstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		chtype	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinnstr
+ int	mvinnstr(
+-		int	a1,
+-		int	a2,
+-		char	*a3,
++		int	a1, 
++		int	a2, 
++		char	*a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinsch
+ int	mvinsch(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		chtype	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinsnstr
+ int	mvinsnstr(
+-		int	a1,
+-		int	a2,
+-		const char *a3,
++		int	a1, 
++		int	a2, 
++		const char *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinsstr
+ int	mvinsstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinstr
+ int	mvinstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvvline
+ int	mvvline(
+-		int	a1,
+-		int	a2,
+-		chtype	a3,
++		int	a1, 
++		int	a2, 
++		chtype	a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddch
+ int	mvwaddch(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const chtype z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddchnstr
+ int	mvwaddchnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const chtype *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const chtype *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddchstr
+ int	mvwaddchstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const chtype *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddnstr
+ int	mvwaddnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const char *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const char *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddstr
+ int	mvwaddstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwchgat
+ int	mvwchgat(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		int	a4,
+-		attr_t	a5,
+-		short	a6,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		int	a4, 
++		attr_t	a5, 
++		short	a6, 
+ 		const void *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwdelch
+ int	mvwdelch(
+-		WINDOW	*a1,
+-		int	a2,
++		WINDOW	*a1, 
++		int	a2, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwgetch
+ int	mvwgetch(
+-		WINDOW	*a1,
+-		int	a2,
++		WINDOW	*a1, 
++		int	a2, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwgetnstr
+ int	mvwgetnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		char	*a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		char	*a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwgetstr
+ int	mvwgetstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwhline
+ int	mvwhline(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		chtype	a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		chtype	a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinch
+ chtype	mvwinch(
+-		WINDOW	*a1,
+-		int	a2,
++		WINDOW	*a1, 
++		int	a2, 
+ 		int	z)
+ 		{ return(*(chtype *)0); }
+ 
+ #undef mvwinchnstr
+ int	mvwinchnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		chtype	*a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		chtype	*a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinchstr
+ int	mvwinchstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		chtype	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinnstr
+ int	mvwinnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		char	*a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		char	*a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinsch
+ int	mvwinsch(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		chtype	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinsnstr
+ int	mvwinsnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const char *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const char *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinsstr
+ int	mvwinsstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinstr
+ int	mvwinstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwvline
+ int	mvwvline(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		chtype	a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		chtype	a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -871,7 +873,7 @@
+ 
+ #undef setscrreg
+ int	setscrreg(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -890,8 +892,8 @@
+ 
+ #undef touchline
+ int	touchline(
+-		WINDOW	*a1,
+-		int	a2,
++		WINDOW	*a1, 
++		int	a2, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -907,67 +909,67 @@
+ 
+ #undef vline
+ int	vline(
+-		chtype	a1,
++		chtype	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef vw_printw
+ int	vw_printw(
+-		WINDOW	*a1,
+-		const char *a2,
++		WINDOW	*a1, 
++		const char *a2, 
+ 		va_list	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef vw_scanw
+ int	vw_scanw(
+-		WINDOW	*a1,
+-		char	*a2,
++		WINDOW	*a1, 
++		char	*a2, 
+ 		va_list	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddchstr
+ int	waddchstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		const chtype *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddstr
+ int	waddstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattron
+ int	wattron(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattroff
+ int	wattroff(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattrset
+ int	wattrset(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattr_get
+ int	wattr_get(
+-		WINDOW	*a1,
+-		attr_t	*a2,
+-		short	*a3,
++		WINDOW	*a1, 
++		attr_t	*a2, 
++		short	*a3, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattr_set
+ int	wattr_set(
+-		WINDOW	*a1,
+-		attr_t	a2,
+-		short	a3,
++		WINDOW	*a1, 
++		attr_t	a2, 
++		short	a3, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -978,13 +980,13 @@
+ 
+ #undef wgetstr
+ int	wgetstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef winchstr
+ int	winchstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		chtype	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -995,13 +997,13 @@
+ 
+ #undef winsstr
+ int	winsstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef winstr
+ int	winstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1016,10 +1018,10 @@
+ 		{ return(*(int *)0); }
+ 
+ #undef mouse_trafo
+-NCURSES_BOOL mouse_trafo(
+-		int	*a1,
+-		int	*a2,
+-		NCURSES_BOOL z)
++NCURSES_BOOL	mouse_trafo(
++		int	*a1, 
++		int	*a2, 
++		NCURSES_BOOL	z)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ /* ./base/lib_getch.c */
+@@ -1031,8 +1033,8 @@
+ 
+ #undef _nc_wgetch
+ int	_nc_wgetch(
+-		WINDOW	*win,
+-		unsigned long *result,
++		WINDOW	*win, 
++		unsigned long *result, 
+ 		int	use_meta)
+ 		{ return(*(int *)0); }
+ 
+@@ -1045,8 +1047,8 @@
+ 
+ #undef wgetnstr
+ int	wgetnstr(
+-		WINDOW	*win,
+-		char	*str,
++		WINDOW	*win, 
++		char	*str, 
+ 		int	maxlen)
+ 		{ return(*(int *)0); }
+ 
+@@ -1054,8 +1056,8 @@
+ 
+ #undef whline
+ int	whline(
+-		WINDOW	*win,
+-		chtype	ch,
++		WINDOW	*win, 
++		chtype	ch, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1063,7 +1065,7 @@
+ 
+ #undef immedok
+ void	immedok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ /* void */ }
+ 
+@@ -1071,8 +1073,8 @@
+ 
+ #undef winchnstr
+ int	winchnstr(
+-		WINDOW	*win,
+-		chtype	*str,
++		WINDOW	*win, 
++		chtype	*str, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1085,29 +1087,31 @@
+ /* ./base/lib_insch.c */
+ 
+ #undef _nc_insert_ch
+-void	_nc_insert_ch(
+-		WINDOW	*win,
++int	_nc_insert_ch(
++		WINDOW	*win, 
+ 		chtype	ch)
+-		{ /* void */ }
++		{ return(*(int *)0); }
+ 
+ #undef winsch
+ int	winsch(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		chtype	c)
+ 		{ return(*(int *)0); }
+ 
+-#undef winsnstr
+-int	winsnstr(
+-		WINDOW	*win,
+-		const char *s,
+-		int	n)
+-		{ return(*(int *)0); }
+-
+ /* ./base/lib_insdel.c */
+ 
+ #undef winsdelln
+ int	winsdelln(
+-		WINDOW	*win,
++		WINDOW	*win, 
++		int	n)
++		{ return(*(int *)0); }
++
++/* ./base/lib_insnstr.c */
++
++#undef winsnstr
++int	winsnstr(
++		WINDOW	*win, 
++		const char *s, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1115,8 +1119,8 @@
+ 
+ #undef winnstr
+ int	winnstr(
+-		WINDOW	*win,
+-		char	*str,
++		WINDOW	*win, 
++		char	*str, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1130,7 +1134,7 @@
+ 
+ #undef leaveok
+ int	leaveok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -1148,14 +1152,14 @@
+ 
+ #undef mousemask
+ mmask_t	mousemask(
+-		mmask_t	newmask,
++		mmask_t	newmask, 
+ 		mmask_t	*oldmask)
+ 		{ return(*(mmask_t *)0); }
+ 
+ #undef wenclose
+ NCURSES_BOOL wenclose(
+-		const WINDOW *win,
+-		int	y,
++		const WINDOW *win, 
++		int	y, 
+ 		int	x)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+@@ -1170,9 +1174,9 @@
+ 
+ #undef wmouse_trafo
+ NCURSES_BOOL wmouse_trafo(
+-		const WINDOW *win,
+-		int	*pY,
+-		int	*pX,
++		const WINDOW *win, 
++		int	*pY, 
++		int	*pX, 
+ 		NCURSES_BOOL to_screen)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+@@ -1180,8 +1184,8 @@
+ 
+ #undef wmove
+ int	wmove(
+-		WINDOW	*win,
+-		int	y,
++		WINDOW	*win, 
++		int	y, 
+ 		int	x)
+ 		{ return(*(int *)0); }
+ 
+@@ -1189,7 +1193,7 @@
+ 
+ #undef _nc_msec_cost
+ int	_nc_msec_cost(
+-		const char *const cap,
++		const char *const cap, 
+ 		int	affcnt)
+ 		{ return(*(int *)0); }
+ 
+@@ -1207,9 +1211,9 @@
+ 
+ #undef mvcur
+ int	mvcur(
+-		int	yold,
+-		int	xold,
+-		int	ynew,
++		int	yold, 
++		int	xold, 
++		int	ynew, 
+ 		int	xnew)
+ 		{ return(*(int *)0); }
+ 
+@@ -1220,8 +1224,8 @@
+ 
+ #undef mvwin
+ int	mvwin(
+-		WINDOW	*win,
+-		int	by,
++		WINDOW	*win, 
++		int	by, 
+ 		int	bx)
+ 		{ return(*(int *)0); }
+ 
+@@ -1233,8 +1237,8 @@
+ 
+ #undef newterm
+ SCREEN	*newterm(
+-		char	*name,
+-		FILE	*ofp,
++		char	*name, 
++		FILE	*ofp, 
+ 		FILE	*ifp)
+ 		{ return(*(SCREEN **)0); }
+ 
+@@ -1247,36 +1251,36 @@
+ 
+ #undef newwin
+ WINDOW	*newwin(
+-		int	num_lines,
+-		int	num_columns,
+-		int	begy,
++		int	num_lines, 
++		int	num_columns, 
++		int	begy, 
+ 		int	begx)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef derwin
+ WINDOW	*derwin(
+-		WINDOW	*orig,
+-		int	num_lines,
+-		int	num_columns,
+-		int	begy,
++		WINDOW	*orig, 
++		int	num_lines, 
++		int	num_columns, 
++		int	begy, 
+ 		int	begx)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef subwin
+ WINDOW	*subwin(
+-		WINDOW	*w,
+-		int	l,
+-		int	c,
+-		int	y,
++		WINDOW	*w, 
++		int	l, 
++		int	c, 
++		int	y, 
+ 		int	x)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef _nc_makenew
+ WINDOW	*_nc_makenew(
+-		int	num_lines,
+-		int	num_columns,
+-		int	begy,
+-		int	begx,
++		int	num_lines, 
++		int	num_columns, 
++		int	begy, 
++		int	begx, 
+ 		int	flags)
+ 		{ return(*(WINDOW **)0); }
+ 
+@@ -1294,26 +1298,26 @@
+ 
+ #undef overlay
+ int	overlay(
+-		const WINDOW *win1,
++		const WINDOW *win1, 
+ 		WINDOW	*win2)
+ 		{ return(*(int *)0); }
+ 
+ #undef overwrite
+ int	overwrite(
+-		const WINDOW *win1,
++		const WINDOW *win1, 
+ 		WINDOW	*win2)
+ 		{ return(*(int *)0); }
+ 
+ #undef copywin
+ int	copywin(
+-		const WINDOW *src,
+-		WINDOW	*dst,
+-		int	sminrow,
+-		int	smincol,
+-		int	dminrow,
+-		int	dmincol,
+-		int	dmaxrow,
+-		int	dmaxcol,
++		const WINDOW *src, 
++		WINDOW	*dst, 
++		int	sminrow, 
++		int	smincol, 
++		int	dminrow, 
++		int	dmincol, 
++		int	dmaxrow, 
++		int	dmaxcol, 
+ 		int	over)
+ 		{ return(*(int *)0); }
+ 
+@@ -1321,44 +1325,44 @@
+ 
+ #undef newpad
+ WINDOW	*newpad(
+-		int	l,
++		int	l, 
+ 		int	c)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef subpad
+ WINDOW	*subpad(
+-		WINDOW	*orig,
+-		int	l,
+-		int	c,
+-		int	begy,
++		WINDOW	*orig, 
++		int	l, 
++		int	c, 
++		int	begy, 
+ 		int	begx)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef prefresh
+ int	prefresh(
+-		WINDOW	*win,
+-		int	pminrow,
+-		int	pmincol,
+-		int	sminrow,
+-		int	smincol,
+-		int	smaxrow,
++		WINDOW	*win, 
++		int	pminrow, 
++		int	pmincol, 
++		int	sminrow, 
++		int	smincol, 
++		int	smaxrow, 
+ 		int	smaxcol)
+ 		{ return(*(int *)0); }
+ 
+ #undef pnoutrefresh
+ int	pnoutrefresh(
+-		WINDOW	*win,
+-		int	pminrow,
+-		int	pmincol,
+-		int	sminrow,
+-		int	smincol,
+-		int	smaxrow,
++		WINDOW	*win, 
++		int	pminrow, 
++		int	pmincol, 
++		int	sminrow, 
++		int	smincol, 
++		int	smaxrow, 
+ 		int	smaxcol)
+ 		{ return(*(int *)0); }
+ 
+ #undef pechochar
+ int	pechochar(
+-		WINDOW	*pad,
++		WINDOW	*pad, 
+ 		const chtype ch)
+ 		{ return(*(int *)0); }
+ 
+@@ -1366,38 +1370,38 @@
+ 
+ #undef printw
+ int	printw(
+-		const char *fmt,
++		const char *fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef wprintw
+ int	wprintw(
+-		WINDOW	*win,
+-		const char *fmt,
++		WINDOW	*win, 
++		const char *fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvprintw
+ int	mvprintw(
+-		int	y,
+-		int	x,
+-		const char *fmt,
++		int	y, 
++		int	x, 
++		const char *fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwprintw
+ int	mvwprintw(
+-		WINDOW	*win,
+-		int	y,
+-		int	x,
+-		const char *fmt,
++		WINDOW	*win, 
++		int	y, 
++		int	x, 
++		const char *fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef vwprintw
+ int	vwprintw(
+-		WINDOW	*win,
+-		const char *fmt,
++		WINDOW	*win, 
++		const char *fmt, 
+ 		va_list	argp)
+ 		{ return(*(int *)0); }
+ 
+@@ -1405,8 +1409,8 @@
+ 
+ #undef wredrawln
+ int	wredrawln(
+-		WINDOW	*win,
+-		int	beg,
++		WINDOW	*win, 
++		int	beg, 
+ 		int	num)
+ 		{ return(*(int *)0); }
+ 
+@@ -1426,8 +1430,8 @@
+ 
+ #undef restartterm
+ int	restartterm(
+-		char	*termp,
+-		int	filenum,
++		char	*termp, 
++		int	filenum, 
+ 		int	*errret)
+ 		{ return(*(int *)0); }
+ 
+@@ -1435,38 +1439,38 @@
+ 
+ #undef vwscanw
+ int	vwscanw(
+-		WINDOW	*win,
+-		char	*fmt,
++		WINDOW	*win, 
++		char	*fmt, 
+ 		va_list	argp)
+ 		{ return(*(int *)0); }
+ 
+ #undef scanw
+ int	scanw(
+-		char	*fmt,
++		char	*fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef wscanw
+ int	wscanw(
+-		WINDOW	*win,
+-		char	*fmt,
++		WINDOW	*win, 
++		char	*fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvscanw
+ int	mvscanw(
+-		int	y,
+-		int	x,
+-		char	*fmt,
++		int	y, 
++		int	x, 
++		char	*fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwscanw
+ int	mvwscanw(
+-		WINDOW	*win,
+-		int	y,
+-		int	x,
+-		char	*fmt,
++		WINDOW	*win, 
++		int	y, 
++		int	x, 
++		char	*fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+@@ -1479,7 +1483,7 @@
+ 
+ #undef putwin
+ int	putwin(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		FILE	*filep)
+ 		{ return(*(int *)0); }
+ 
+@@ -1507,16 +1511,16 @@
+ 
+ #undef _nc_scroll_window
+ void	_nc_scroll_window(
+-		WINDOW	*win,
+-		int const n,
+-		short const top,
+-		short const bottom,
++		WINDOW	*win, 
++		int const n, 
++		short const top, 
++		short const bottom, 
+ 		chtype	blank)
+ 		{ /* void */ }
+ 
+ #undef wscrl
+ int	wscrl(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1524,7 +1528,7 @@
+ 
+ #undef scrollok
+ int	scrollok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -1532,8 +1536,8 @@
+ 
+ #undef wsetscrreg
+ int	wsetscrreg(
+-		WINDOW	*win,
+-		int	top,
++		WINDOW	*win, 
++		int	top, 
+ 		int	bottom)
+ 		{ return(*(int *)0); }
+ 
+@@ -1551,24 +1555,24 @@
+ 
+ #undef _nc_setupscreen
+ int	_nc_setupscreen(
+-		short	slines,
+-		short const scolumns,
++		short	slines, 
++		short const scolumns, 
+ 		FILE	*output)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_ripoffline
+ int	_nc_ripoffline(
+-		int	line,
++		int	line, 
+ 		int	(*init)(
+-		WINDOW	*p1,
++		WINDOW	*p1, 
+ 		int	p2))
+ 		{ return(*(int *)0); }
+ 
+ #undef ripoffline
+ int	ripoffline(
+-		int	line,
++		int	line, 
+ 		int	(*init)(
+-		WINDOW	*p1,
++		WINDOW	*p1, 
+ 		int	p2))
+ 		{ return(*(int *)0); }
+ 
+@@ -1579,7 +1583,7 @@
+ 
+ #undef _nc_slk_initialize
+ int	_nc_slk_initialize(
+-		WINDOW	*stwin,
++		WINDOW	*stwin, 
+ 		int	cols)
+ 		{ return(*(int *)0); }
+ 
+@@ -1591,8 +1595,8 @@
+ 
+ #undef slk_attr_set
+ int	slk_attr_set(
+-		const attr_t attr,
+-		short	color_pair_number,
++		const attr_t attr, 
++		short	color_pair_number, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -1664,8 +1668,8 @@
+ 
+ #undef slk_set
+ int	slk_set(
+-		int	i,
+-		const char *astr,
++		int	i, 
++		const char *astr, 
+ 		int	format)
+ 		{ return(*(int *)0); }
+ 
+@@ -1679,7 +1683,7 @@
+ 
+ #undef is_linetouched
+ NCURSES_BOOL is_linetouched(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		int	line)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+@@ -1690,9 +1694,9 @@
+ 
+ #undef wtouchln
+ int	wtouchln(
+-		WINDOW	*win,
+-		int	y,
+-		int	n,
++		WINDOW	*win, 
++		int	y, 
++		int	n, 
+ 		int	changed)
+ 		{ return(*(int *)0); }
+ 
+@@ -1700,7 +1704,7 @@
+ 
+ #undef _traceattr2
+ char	*_traceattr2(
+-		int	bufnum,
++		int	bufnum, 
+ 		attr_t	newmode)
+ 		{ return(*(char **)0); }
+ 
+@@ -1716,13 +1720,13 @@
+ 
+ #undef _nc_altcharset_name
+ const char *_nc_altcharset_name(
+-		attr_t	attr,
++		attr_t	attr, 
+ 		chtype	ch)
+ 		{ return(*(const char **)0); }
+ 
+ #undef _tracechtype2
+ char	*_tracechtype2(
+-		int	bufnum,
++		int	bufnum, 
+ 		chtype	ch)
+ 		{ return(*(char **)0); }
+ 
+@@ -1740,7 +1744,7 @@
+ 
+ #undef _tracedump
+ void	_tracedump(
+-		const char *name,
++		const char *name, 
+ 		WINDOW	*win)
+ 		{ /* void */ }
+ 
+@@ -1775,7 +1779,7 @@
+ 
+ #undef vidputs
+ int	vidputs(
+-		chtype	newmode,
++		chtype	newmode, 
+ 		int	(*outc)(
+ 		int	p1))
+ 		{ return(*(int *)0); }
+@@ -1793,8 +1797,8 @@
+ 
+ #undef wvline
+ int	wvline(
+-		WINDOW	*win,
+-		chtype	ch,
++		WINDOW	*win, 
++		chtype	ch, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1802,8 +1806,8 @@
+ 
+ #undef wattr_off
+ int	wattr_off(
+-		WINDOW	*win,
+-		attr_t	at,
++		WINDOW	*win, 
++		attr_t	at, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -1811,8 +1815,8 @@
+ 
+ #undef wattr_on
+ int	wattr_on(
+-		WINDOW	*win,
+-		attr_t	at,
++		WINDOW	*win, 
++		attr_t	at, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -1832,14 +1836,14 @@
+ 
+ #undef mvderwin
+ int	mvderwin(
+-		WINDOW	*win,
+-		int	y,
++		WINDOW	*win, 
++		int	y, 
+ 		int	x)
+ 		{ return(*(int *)0); }
+ 
+ #undef syncok
+ int	syncok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL bf)
+ 		{ return(*(int *)0); }
+ 
+@@ -1873,7 +1877,7 @@
+ 
+ #undef _nc_printf_string
+ char	*_nc_printf_string(
+-		const char *fmt,
++		const char *fmt, 
+ 		va_list	ap)
+ 		{ return(*(char **)0); }
+ 
+@@ -1888,9 +1892,9 @@
+ 
+ #undef _nc_scrolln
+ int	_nc_scrolln(
+-		int	n,
+-		int	top,
+-		int	bot,
++		int	n, 
++		int	top, 
++		int	bot, 
+ 		int	maxy)
+ 		{ return(*(int *)0); }
+ 
+@@ -1913,9 +1917,13 @@
+ 
+ /* ./trace/varargs.c */
+ 
++typedef enum {
++    atUnknown = 0, atInteger, atFloat, atPoint, atString
++} ARGTYPE;
++
+ #undef _nc_varargs
+ char	*_nc_varargs(
+-		const char *fmt,
++		const char *fmt, 
+ 		va_list	ap)
+ 		{ return(*(char **)0); }
+ 
+@@ -1943,7 +1951,7 @@
+ 
+ #undef define_key
+ int	define_key(
+-		const char *str,
++		const char *str, 
+ 		int	keycode)
+ 		{ return(*(int *)0); }
+ 
+@@ -1951,13 +1959,13 @@
+ 
+ #undef _nc_toggle_attr_on
+ void	_nc_toggle_attr_on(
+-		attr_t	*S,
++		attr_t	*S, 
+ 		attr_t	at)
+ 		{ /* void */ }
+ 
+ #undef _nc_toggle_attr_off
+ void	_nc_toggle_attr_off(
+-		attr_t	*S,
++		attr_t	*S, 
+ 		attr_t	at)
+ 		{ /* void */ }
+ 
+@@ -1987,7 +1995,7 @@
+ 
+ #undef keybound
+ char	*keybound(
+-		int	code,
++		int	code, 
+ 		int	count)
+ 		{ return(*(char **)0); }
+ 
+@@ -1995,7 +2003,7 @@
+ 
+ #undef keyok
+ int	keyok(
+-		int	c,
++		int	c, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -2007,7 +2015,7 @@
+ 
+ #undef assume_default_colors
+ int	assume_default_colors(
+-		int	fg,
++		int	fg, 
+ 		int	bg)
+ 		{ return(*(int *)0); }
+ 
+@@ -2015,7 +2023,7 @@
+ 
+ #undef mcprint
+ int	mcprint(
+-		char	*data,
++		char	*data, 
+ 		int	len)
+ 		{ return(*(int *)0); }
+ 
+@@ -2023,19 +2031,19 @@
+ 
+ #undef is_term_resized
+ NCURSES_BOOL is_term_resized(
+-		int	ToLines,
++		int	ToLines, 
+ 		int	ToCols)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ #undef resize_term
+ int	resize_term(
+-		int	ToLines,
++		int	ToLines, 
+ 		int	ToCols)
+ 		{ return(*(int *)0); }
+ 
+ #undef resizeterm
+ int	resizeterm(
+-		int	ToLines,
++		int	ToLines, 
+ 		int	ToCols)
+ 		{ return(*(int *)0); }
+ 
+@@ -2050,41 +2058,37 @@
+ 
+ #undef _nc_expand_try
+ char	*_nc_expand_try(
+-		struct tries *tree,
+-		unsigned short code,
+-		int	*count,
++		struct tries *tree, 
++		unsigned short code, 
++		int	*count, 
+ 		size_t	len)
+ 		{ return(*(char **)0); }
+ 
+ #undef _nc_remove_key
+ int	_nc_remove_key(
+-		struct tries **tree,
++		struct tries **tree, 
+ 		unsigned short code)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_remove_string
+ int	_nc_remove_string(
+-		struct tries **tree,
++		struct tries **tree, 
+ 		const char *string)
+ 		{ return(*(int *)0); }
+ 
+-/* ./base/version.c */
+-
+-#undef curses_version
+-const char *curses_version(void)
+-		{ return(*(const char **)0); }
+-
+ /* ./base/wresize.c */
+ 
+ #undef wresize
+ int	wresize(
+-		WINDOW	*win,
+-		int	ToLines,
++		WINDOW	*win, 
++		int	ToLines, 
+ 		int	ToCols)
+ 		{ return(*(int *)0); }
+ 
+ /* ./tinfo/access.c */
+ 
++#include <nc_alloc.h>
++
+ #undef _nc_rootname
+ char	*_nc_rootname(
+ 		char	*path)
+@@ -2102,7 +2106,7 @@
+ 
+ #undef _nc_access
+ int	_nc_access(
+-		const char *path,
++		const char *path, 
+ 		int	mode)
+ 		{ return(*(int *)0); }
+ 
+@@ -2114,8 +2118,8 @@
+ 
+ #undef _nc_add_to_try
+ void	_nc_add_to_try(
+-		struct tries **tree,
+-		const char *str,
++		struct tries **tree, 
++		const char *str, 
+ 		unsigned short code)
+ 		{ /* void */ }
+ 
+@@ -2138,13 +2142,13 @@
+ 
+ #undef _nc_wrap_entry
+ void	_nc_wrap_entry(
+-		ENTRY	*const ep,
++		ENTRY	*const ep, 
+ 		NCURSES_BOOL copy_strings)
+ 		{ /* void */ }
+ 
+ #undef _nc_merge_entry
+ void	_nc_merge_entry(
+-		TERMTYPE *const to,
++		TERMTYPE *const to, 
+ 		TERMTYPE *const from)
+ 		{ /* void */ }
+ 
+@@ -2152,13 +2156,13 @@
+ 
+ #undef _nc_align_termtype
+ void	_nc_align_termtype(
+-		TERMTYPE *to,
++		TERMTYPE *to, 
+ 		TERMTYPE *from)
+ 		{ /* void */ }
+ 
+ #undef _nc_copy_termtype
+ void	_nc_copy_termtype(
+-		TERMTYPE *dst,
++		TERMTYPE *dst, 
+ 		TERMTYPE *src)
+ 		{ /* void */ }
+ 
+@@ -2166,15 +2170,15 @@
+ 
+ #undef _nc_captoinfo
+ char	*_nc_captoinfo(
+-		const char *cap,
+-		const char *s,
++		const char *cap, 
++		const char *s, 
+ 		int const parameterized)
+ 		{ return(*(char **)0); }
+ 
+ #undef _nc_infotocap
+ char	*_nc_infotocap(
+-		const char *cap,
+-		const char *str,
++		const char *cap, 
++		const char *str, 
+ 		int const parameterized)
+ 		{ return(*(char **)0); }
+ 
+@@ -2236,19 +2240,19 @@
+ 
+ #undef _nc_warning
+ void	_nc_warning(
+-		const char *const fmt,
++		const char *const fmt, 
+ 		...)
+ 		{ /* void */ }
+ 
+ #undef _nc_err_abort
+ void	_nc_err_abort(
+-		const char *const fmt,
++		const char *const fmt, 
+ 		...)
+ 		{ /* void */ }
+ 
+ #undef _nc_syserr_abort
+ void	_nc_syserr_abort(
+-		const char *const fmt,
++		const char *const fmt, 
+ 		...)
+ 		{ /* void */ }
+ 
+@@ -2256,8 +2260,8 @@
+ 
+ #undef _nc_tic_expand
+ char	*_nc_tic_expand(
+-		const char *srcp,
+-		NCURSES_BOOL tic_format,
++		const char *srcp, 
++		NCURSES_BOOL tic_format, 
+ 		int	numbers)
+ 		{ return(*(char **)0); }
+ 
+@@ -2267,19 +2271,23 @@
+ 
+ #undef _nc_find_entry
+ struct name_table_entry const *_nc_find_entry(
+-		const char *string,
++		const char *string, 
+ 		const struct name_table_entry *const *hash_table)
+ 		{ return(*(struct name_table_entry const **)0); }
+ 
+ #undef _nc_find_type_entry
+ struct name_table_entry const *_nc_find_type_entry(
+-		const char *string,
+-		int	type,
++		const char *string, 
++		int	type, 
+ 		const struct name_table_entry *table)
+ 		{ return(*(struct name_table_entry const **)0); }
+ 
+ /* ./tinfo/comp_parse.c */
+ 
++#undef _nc_check_termtype2
++void	(*_nc_check_termtype2)(
++		TERMTYPE *p1, 
++		NCURSES_BOOL p2);
+ #undef _nc_check_termtype
+ void	(*_nc_check_termtype)(
+ 		TERMTYPE *p1);
+@@ -2295,20 +2303,26 @@
+ 
+ #undef _nc_entry_match
+ NCURSES_BOOL _nc_entry_match(
+-		char	*n1,
++		char	*n1, 
+ 		char	*n2)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ #undef _nc_read_entry_source
+ void	_nc_read_entry_source(
+-		FILE	*fp,
+-		char	*buf,
+-		int	literal,
+-		NCURSES_BOOL silent,
++		FILE	*fp, 
++		char	*buf, 
++		int	literal, 
++		NCURSES_BOOL silent, 
+ 		NCURSES_BOOL (*hook)(
+ 		ENTRY	*p1))
+ 		{ /* void */ }
+ 
++#undef _nc_resolve_uses2
++int	_nc_resolve_uses2(
++		NCURSES_BOOL fullresolve, 
++		NCURSES_BOOL literal)
++		{ return(*(int *)0); }
++
+ #undef _nc_resolve_uses
+ int	_nc_resolve_uses(
+ 		NCURSES_BOOL fullresolve)
+@@ -2331,16 +2345,22 @@
+ #undef _nc_disable_period
+ NCURSES_BOOL _nc_disable_period;
+ 
++#undef _nc_reset_input
++void	_nc_reset_input(
++		FILE	*fp, 
++		char	*buf)
++		{ /* void */ }
++
+ #undef _nc_get_token
+ int	_nc_get_token(
+ 		NCURSES_BOOL silent)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_trans_string
+-char	_nc_trans_string(
+-		char	*ptr,
++int	_nc_trans_string(
++		char	*ptr, 
+ 		char	*last)
+-		{ return(*(char *)0); }
++		{ return(*(int *)0); }
+ 
+ #undef _nc_push_token
+ void	_nc_push_token(
+@@ -2352,17 +2372,11 @@
+ 		char	ch)
+ 		{ /* void */ }
+ 
+-#undef _nc_reset_input
+-void	_nc_reset_input(
+-		FILE	*fp,
+-		char	*buf)
+-		{ /* void */ }
+-
+ /* ./tinfo/doalloc.c */
+ 
+ #undef _nc_doalloc
+ void	*_nc_doalloc(
+-		void	*oldp,
++		void	*oldp, 
+ 		size_t	amount)
+ 		{ return(*(void **)0); }
+ 
+@@ -2429,6 +2443,11 @@
+ 
+ #include <termcap.h>
+ 
++struct speed {
++    int s; 
++    int sp; 
++};
++
+ #undef _nc_baudrate
+ int	_nc_baudrate(
+ 		int	OSpeed)
+@@ -2524,13 +2543,13 @@
+ 
+ #undef idlok
+ int	idlok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+ #undef idcok
+ void	idcok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ /* void */ }
+ 
+@@ -2541,31 +2560,31 @@
+ 
+ #undef nodelay
+ int	nodelay(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+ #undef notimeout
+ int	notimeout(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL f)
+ 		{ return(*(int *)0); }
+ 
+ #undef wtimeout
+ void	wtimeout(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		int	delay)
+ 		{ /* void */ }
+ 
+ #undef keypad
+ int	keypad(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+ #undef meta
+ int	meta(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -2617,13 +2636,15 @@
+ 
+ #undef intrflush
+ int	intrflush(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+ /* ./tinfo/lib_setup.c */
+ 
++#include <locale.h>
+ #include <sys/ioctl.h>
++#include <langinfo.h>
+ 
+ #undef ttytype
+ char	ttytype[256];
+@@ -2655,10 +2676,18 @@
+ int	_nc_locale_breaks_acs(void)
+ 		{ return(*(int *)0); }
+ 
++#undef _nc_setupterm
++int	_nc_setupterm(
++		char	*tname, 
++		int	Filedes, 
++		int	*errret, 
++		NCURSES_BOOL reuse)
++		{ return(*(int *)0); }
++
+ #undef setupterm
+ int	setupterm(
+-		char	*tname,
+-		int	Filedes,
++		char	*tname, 
++		int	Filedes, 
+ 		int	*errret)
+ 		{ return(*(int *)0); }
+ 
+@@ -2671,7 +2700,7 @@
+ 
+ #undef tgetent
+ int	tgetent(
+-		char	*bufp,
++		char	*bufp, 
+ 		const char *name)
+ 		{ return(*(int *)0); }
+ 
+@@ -2693,7 +2722,7 @@
+ 
+ #undef tgetstr
+ char	*tgetstr(
+-		char	*id,
++		char	*id, 
+ 		char	**area)
+ 		{ return(*(char **)0); }
+ 
+@@ -2707,8 +2736,8 @@
+ 
+ #undef tgoto
+ char	*tgoto(
+-		const char *string,
+-		int	x,
++		const char *string, 
++		int	x, 
+ 		int	y)
+ 		{ return(*(char **)0); }
+ 
+@@ -2731,19 +2760,27 @@
+ 
+ /* ./tinfo/lib_tparm.c */
+ 
++typedef struct {
++    union {
++        int num;
++        char *str;
++    } data;
++    NCURSES_BOOL num_type;
++} stack_frame;
++
+ #undef _nc_tparm_err
+ int	_nc_tparm_err;
+ 
+ #undef _nc_tparm_analyze
+ int	_nc_tparm_analyze(
+-		const char *string,
+-		char	*p_is_s[9],
++		const char *string, 
++		char	*p_is_s[9], 
+ 		int	*popcount)
+ 		{ return(*(int *)0); }
+ 
+ #undef tparm
+ char	*tparm(
+-		char	*string,
++		char	*string, 
+ 		...)
+ 		{ return(*(char **)0); }
+ 
+@@ -2777,8 +2814,8 @@
+ 
+ #undef tputs
+ int	tputs(
+-		const char *string,
+-		int	affcnt,
++		const char *string, 
++		int	affcnt, 
+ 		int	(*outc)(
+ 		int	p1))
+ 		{ return(*(int *)0); }
+@@ -2799,7 +2836,7 @@
+ 
+ #undef _tracef
+ void	_tracef(
+-		const char *fmt,
++		const char *fmt, 
+ 		...)
+ 		{ /* void */ }
+ 
+@@ -2823,6 +2860,21 @@
+ 		char	*code)
+ 		{ return(*(char **)0); }
+ 
++#undef _nc_retrace_cptr
++const char *_nc_retrace_cptr(
++		const char *code)
++		{ return(*(const char **)0); }
++
++#undef _nc_retrace_cvoid_ptr
++void	*_nc_retrace_cvoid_ptr(
++		void	*code)
++		{ return(*(void **)0); }
++
++#undef _nc_retrace_void_ptr
++void	*_nc_retrace_void_ptr(
++		void	*code)
++		{ return(*(void **)0); }
++
+ #undef _nc_retrace_sp
+ SCREEN	*_nc_retrace_sp(
+ 		SCREEN	*code)
+@@ -2835,6 +2887,11 @@
+ 
+ /* ./trace/lib_tracebits.c */
+ 
++typedef struct {
++    unsigned int val;
++    const char *name;
++} BITNAMES;
++
+ #undef _nc_trace_ttymode
+ char	*_nc_trace_ttymode(
+ 		struct termios *tty)
+@@ -2891,8 +2948,8 @@
+ 
+ #undef _nc_timed_wait
+ int	_nc_timed_wait(
+-		int	mode,
+-		int	milliseconds,
++		int	mode, 
++		int	milliseconds, 
+ 		int	*timeleft)
+ 		{ return(*(int *)0); }
+ 
+@@ -2905,8 +2962,8 @@
+ 
+ #undef _nc_name_match
+ int	_nc_name_match(
+-		const char *const namelst,
+-		const char *const name,
++		const char *const namelst, 
++		const char *const name, 
+ 		const char *const delim)
+ 		{ return(*(int *)0); }
+ 
+@@ -2929,17 +2986,22 @@
+ 
+ #undef _nc_parse_entry
+ int	_nc_parse_entry(
+-		struct entry *entryp,
+-		int	literal,
++		struct entry *entryp, 
++		int	literal, 
+ 		NCURSES_BOOL silent)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_capcmp
+ int	_nc_capcmp(
+-		const char *s,
++		const char *s, 
+ 		const char *t)
+ 		{ return(*(int *)0); }
+ 
++typedef struct {
++    const char *from;
++    const char *to;
++} assoc;
++
+ /* ./tinfo/read_entry.c */
+ 
+ #undef _nc_tic_dir
+@@ -2954,22 +3016,25 @@
+ 
+ #undef _nc_read_file_entry
+ int	_nc_read_file_entry(
+-		const char *const filename,
++		const char *const filename, 
+ 		TERMTYPE *ptr)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_read_entry
+ int	_nc_read_entry(
+-		const char *const tn,
+-		char	*const filename,
++		const char *const tn, 
++		char	*const filename, 
+ 		TERMTYPE *const tp)
+ 		{ return(*(int *)0); }
+ 
+ /* ./tinfo/read_termcap.c */
+ 
++#include <sys/types.h>
++#include <sys/stat.h>
++
+ #undef _nc_read_termcap_entry
+ int	_nc_read_termcap_entry(
+-		const char *const tn,
++		const char *const tn, 
+ 		TERMTYPE *const tp)
+ 		{ return(*(int *)0); }
+ 
+@@ -2977,7 +3042,7 @@
+ 
+ #undef _nc_set_buffer
+ void	_nc_set_buffer(
+-		FILE	*ofp,
++		FILE	*ofp, 
+ 		NCURSES_BOOL buffered)
+ 		{ /* void */ }
+ 
+@@ -2985,46 +3050,51 @@
+ 
+ #undef _nc_str_init
+ string_desc *_nc_str_init(
+-		string_desc *dst,
+-		char	*src,
++		string_desc *dst, 
++		char	*src, 
+ 		size_t	len)
+ 		{ return(*(string_desc **)0); }
+ 
+ #undef _nc_str_null
+ string_desc *_nc_str_null(
+-		string_desc *dst,
++		string_desc *dst, 
+ 		size_t	len)
+ 		{ return(*(string_desc **)0); }
+ 
+ #undef _nc_str_copy
+ string_desc *_nc_str_copy(
+-		string_desc *dst,
++		string_desc *dst, 
+ 		string_desc *src)
+ 		{ return(*(string_desc **)0); }
+ 
+ #undef _nc_safe_strcat
+ NCURSES_BOOL _nc_safe_strcat(
+-		string_desc *dst,
++		string_desc *dst, 
+ 		const char *src)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ #undef _nc_safe_strcpy
+ NCURSES_BOOL _nc_safe_strcpy(
+-		string_desc *dst,
++		string_desc *dst, 
+ 		const char *src)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ /* ./trace/trace_buf.c */
+ 
++typedef struct {
++    char *text;
++    size_t size;
++} LIST;
++
+ #undef _nc_trace_buf
+ char	*_nc_trace_buf(
+-		int	bufnum,
++		int	bufnum, 
+ 		size_t	want)
+ 		{ return(*(char **)0); }
+ 
+ #undef _nc_trace_bufcat
+ char	*_nc_trace_bufcat(
+-		int	bufnum,
++		int	bufnum, 
+ 		const char *value)
+ 		{ return(*(char **)0); }
+ 
+@@ -3046,7 +3116,7 @@
+ 
+ #undef _nc_visbuf2
+ const char *_nc_visbuf2(
+-		int	bufnum,
++		int	bufnum, 
+ 		const char *buf)
+ 		{ return(*(const char **)0); }
+ 
+@@ -3057,7 +3127,7 @@
+ 
+ #undef _nc_visbufn
+ const char *_nc_visbufn(
+-		const char *buf,
++		const char *buf, 
+ 		int	len)
+ 		{ return(*(const char **)0); }
+ 
+@@ -3076,3 +3146,9 @@
+ #undef _nc_tic_written
+ int	_nc_tic_written(void)
+ 		{ return(*(int *)0); }
++
++/* ./base/version.c */
++
++#undef curses_version
++const char *curses_version(void)
++		{ return(*(const char **)0); }
+Index: ncurses/llib-lncursesw
+--- ncurses-5.4-20040208/ncurses/llib-lncursesw	2004-01-31 16:17:01.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/llib-lncursesw	2005-03-05 20:05:38.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2001-2003,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 2001-2004,2005 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey 2001-2004                                      *
++ *  Author: Thomas E. Dickey 2001-2005                                      *
+  ****************************************************************************/
+ /* LINTLIBRARY */
+ 
+@@ -48,6 +48,8 @@
+ 
+ /* ./tty/hashmap.c */
+ 
++#include <term.h>
++
+ #undef _nc_hash_map
+ void	_nc_hash_map(void)
+ 		{ /* void */ }
+@@ -59,8 +61,8 @@
+ 
+ #undef _nc_scroll_oldhash
+ void	_nc_scroll_oldhash(
+-		int	n,
+-		int	top,
++		int	n, 
++		int	top, 
+ 		int	bot)
+ 		{ /* void */ }
+ 
+@@ -70,25 +72,31 @@
+ 
+ #undef _nc_render
+ cchar_t	_nc_render(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		cchar_t	ch)
+ 		{ return(*(cchar_t *)0); }
+ 
++#undef _nc_build_wch
++int	_nc_build_wch(
++		WINDOW	*win, 
++		cchar_t	*ch)
++		{ return(*(int *)0); }
++
+ #undef _nc_waddch_nosync
+ int	_nc_waddch_nosync(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const cchar_t c)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddch
+ int	waddch(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const chtype ch)
+ 		{ return(*(int *)0); }
+ 
+ #undef wechochar
+ int	wechochar(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const chtype ch)
+ 		{ return(*(int *)0); }
+ 
+@@ -96,15 +104,15 @@
+ 
+ #undef waddnstr
+ int	waddnstr(
+-		WINDOW	*win,
+-		const char *astr,
++		WINDOW	*win, 
++		const char *astr, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddchnstr
+ int	waddchnstr(
+-		WINDOW	*win,
+-		const chtype *astr,
++		WINDOW	*win, 
++		const chtype *astr, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -115,15 +123,15 @@
+ 
+ #undef wadd_wchnstr
+ int	wadd_wchnstr(
+-		WINDOW	*win,
+-		const cchar_t *astr,
++		WINDOW	*win, 
++		const cchar_t *astr, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddnwstr
+ int	waddnwstr(
+-		WINDOW	*win,
+-		const wchar_t *str,
++		WINDOW	*win, 
++		const wchar_t *str, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -137,25 +145,25 @@
+ 
+ #undef wbkgrndset
+ void	wbkgrndset(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const cchar_t *ch)
+ 		{ /* void */ }
+ 
+ #undef wbkgdset
+ void	wbkgdset(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		chtype	ch)
+ 		{ /* void */ }
+ 
+ #undef wbkgrnd
+ int	wbkgrnd(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const cchar_t *ch)
+ 		{ return(*(int *)0); }
+ 
+ #undef wbkgd
+ int	wbkgd(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		chtype	ch)
+ 		{ return(*(int *)0); }
+ 
+@@ -163,14 +171,14 @@
+ 
+ #undef wborder
+ int	wborder(
+-		WINDOW	*win,
+-		chtype	ls,
+-		chtype	rs,
+-		chtype	ts,
+-		chtype	bs,
+-		chtype	tl,
+-		chtype	tr,
+-		chtype	bl,
++		WINDOW	*win, 
++		chtype	ls, 
++		chtype	rs, 
++		chtype	ts, 
++		chtype	bs, 
++		chtype	tl, 
++		chtype	tr, 
++		chtype	bl, 
+ 		chtype	br)
+ 		{ return(*(int *)0); }
+ 
+@@ -178,10 +186,10 @@
+ 
+ #undef wchgat
+ int	wchgat(
+-		WINDOW	*win,
+-		int	n,
+-		attr_t	attr,
+-		short	color,
++		WINDOW	*win, 
++		int	n, 
++		attr_t	attr, 
++		short	color, 
+ 		const void *opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -196,7 +204,7 @@
+ 
+ #undef clearok
+ int	clearok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -233,16 +241,16 @@
+ 
+ #undef init_pair
+ int	init_pair(
+-		short	pair,
+-		short	f,
++		short	pair, 
++		short	f, 
+ 		short	b)
+ 		{ return(*(int *)0); }
+ 
+ #undef init_color
+ int	init_color(
+-		short	color,
+-		short	r,
+-		short	g,
++		short	color, 
++		short	r, 
++		short	g, 
+ 		short	b)
+ 		{ return(*(int *)0); }
+ 
+@@ -256,24 +264,24 @@
+ 
+ #undef color_content
+ int	color_content(
+-		short	color,
+-		short	*r,
+-		short	*g,
++		short	color, 
++		short	*r, 
++		short	*g, 
+ 		short	*b)
+ 		{ return(*(int *)0); }
+ 
+ #undef pair_content
+ int	pair_content(
+-		short	pair,
+-		short	*f,
++		short	pair, 
++		short	*f, 
+ 		short	*b)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_do_color
+ void	_nc_do_color(
+-		int	old_pair,
+-		int	pair,
+-		NCURSES_BOOL reverse,
++		int	old_pair, 
++		int	pair, 
++		NCURSES_BOOL reverse, 
+ 		int	(*outc)(
+ 		int	p1))
+ 		{ /* void */ }
+@@ -282,8 +290,8 @@
+ 
+ #undef wcolor_set
+ int	wcolor_set(
+-		WINDOW	*win,
+-		short	color_pair_number,
++		WINDOW	*win, 
++		short	color_pair_number, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -339,7 +347,7 @@
+ 
+ #undef addchnstr
+ int	addchnstr(
+-		const chtype *a1,
++		const chtype *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -350,7 +358,7 @@
+ 
+ #undef addnstr
+ int	addnstr(
+-		const char *a1,
++		const char *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -376,27 +384,27 @@
+ 
+ #undef attr_get
+ int	attr_get(
+-		attr_t	*a1,
+-		short	*a2,
++		attr_t	*a1, 
++		short	*a2, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef attr_off
+ int	attr_off(
+-		attr_t	a1,
++		attr_t	a1, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef attr_on
+ int	attr_on(
+-		attr_t	a1,
++		attr_t	a1, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef attr_set
+ int	attr_set(
+-		attr_t	a1,
+-		short	a2,
++		attr_t	a1, 
++		short	a2, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -412,28 +420,28 @@
+ 
+ #undef border
+ int	border(
+-		chtype	a1,
+-		chtype	a2,
+-		chtype	a3,
+-		chtype	a4,
+-		chtype	a5,
+-		chtype	a6,
+-		chtype	a7,
++		chtype	a1, 
++		chtype	a2, 
++		chtype	a3, 
++		chtype	a4, 
++		chtype	a5, 
++		chtype	a6, 
++		chtype	a7, 
+ 		chtype	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef box
+ int	box(
+-		WINDOW	*a1,
+-		chtype	a2,
++		WINDOW	*a1, 
++		chtype	a2, 
+ 		chtype	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef chgat
+ int	chgat(
+-		int	a1,
+-		attr_t	a2,
+-		short	a3,
++		int	a1, 
++		attr_t	a2, 
++		short	a3, 
+ 		const void *z)
+ 		{ return(*(int *)0); }
+ 
+@@ -451,7 +459,7 @@
+ 
+ #undef color_set
+ int	color_set(
+-		short	a1,
++		short	a1, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -488,7 +496,7 @@
+ 
+ #undef getnstr
+ int	getnstr(
+-		char	*a1,
++		char	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -499,7 +507,7 @@
+ 
+ #undef hline
+ int	hline(
+-		chtype	a1,
++		chtype	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -509,7 +517,7 @@
+ 
+ #undef inchnstr
+ int	inchnstr(
+-		chtype	*a1,
++		chtype	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -520,7 +528,7 @@
+ 
+ #undef innstr
+ int	innstr(
+-		char	*a1,
++		char	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -540,7 +548,7 @@
+ 
+ #undef insnstr
+ int	insnstr(
+-		const char *a1,
++		const char *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -556,323 +564,323 @@
+ 
+ #undef move
+ int	move(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddch
+ int	mvaddch(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const chtype z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddchnstr
+ int	mvaddchnstr(
+-		int	a1,
+-		int	a2,
+-		const chtype *a3,
++		int	a1, 
++		int	a2, 
++		const chtype *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddchstr
+ int	mvaddchstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const chtype *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddnstr
+ int	mvaddnstr(
+-		int	a1,
+-		int	a2,
+-		const char *a3,
++		int	a1, 
++		int	a2, 
++		const char *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddstr
+ int	mvaddstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvchgat
+ int	mvchgat(
+-		int	a1,
+-		int	a2,
+-		int	a3,
+-		attr_t	a4,
+-		short	a5,
++		int	a1, 
++		int	a2, 
++		int	a3, 
++		attr_t	a4, 
++		short	a5, 
+ 		const void *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvdelch
+ int	mvdelch(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvgetch
+ int	mvgetch(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvgetnstr
+ int	mvgetnstr(
+-		int	a1,
+-		int	a2,
+-		char	*a3,
++		int	a1, 
++		int	a2, 
++		char	*a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvgetstr
+ int	mvgetstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvhline
+ int	mvhline(
+-		int	a1,
+-		int	a2,
+-		chtype	a3,
++		int	a1, 
++		int	a2, 
++		chtype	a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinch
+ chtype	mvinch(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(chtype *)0); }
+ 
+ #undef mvinchnstr
+ int	mvinchnstr(
+-		int	a1,
+-		int	a2,
+-		chtype	*a3,
++		int	a1, 
++		int	a2, 
++		chtype	*a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinchstr
+ int	mvinchstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		chtype	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinnstr
+ int	mvinnstr(
+-		int	a1,
+-		int	a2,
+-		char	*a3,
++		int	a1, 
++		int	a2, 
++		char	*a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinsch
+ int	mvinsch(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		chtype	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinsnstr
+ int	mvinsnstr(
+-		int	a1,
+-		int	a2,
+-		const char *a3,
++		int	a1, 
++		int	a2, 
++		const char *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinsstr
+ int	mvinsstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinstr
+ int	mvinstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvvline
+ int	mvvline(
+-		int	a1,
+-		int	a2,
+-		chtype	a3,
++		int	a1, 
++		int	a2, 
++		chtype	a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddch
+ int	mvwaddch(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const chtype z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddchnstr
+ int	mvwaddchnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const chtype *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const chtype *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddchstr
+ int	mvwaddchstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const chtype *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddnstr
+ int	mvwaddnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const char *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const char *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddstr
+ int	mvwaddstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwchgat
+ int	mvwchgat(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		int	a4,
+-		attr_t	a5,
+-		short	a6,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		int	a4, 
++		attr_t	a5, 
++		short	a6, 
+ 		const void *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwdelch
+ int	mvwdelch(
+-		WINDOW	*a1,
+-		int	a2,
++		WINDOW	*a1, 
++		int	a2, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwgetch
+ int	mvwgetch(
+-		WINDOW	*a1,
+-		int	a2,
++		WINDOW	*a1, 
++		int	a2, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwgetnstr
+ int	mvwgetnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		char	*a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		char	*a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwgetstr
+ int	mvwgetstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwhline
+ int	mvwhline(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		chtype	a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		chtype	a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinch
+ chtype	mvwinch(
+-		WINDOW	*a1,
+-		int	a2,
++		WINDOW	*a1, 
++		int	a2, 
+ 		int	z)
+ 		{ return(*(chtype *)0); }
+ 
+ #undef mvwinchnstr
+ int	mvwinchnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		chtype	*a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		chtype	*a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinchstr
+ int	mvwinchstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		chtype	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinnstr
+ int	mvwinnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		char	*a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		char	*a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinsch
+ int	mvwinsch(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		chtype	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinsnstr
+ int	mvwinsnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const char *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const char *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinsstr
+ int	mvwinsstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinstr
+ int	mvwinstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwvline
+ int	mvwvline(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		chtype	a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		chtype	a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -902,19 +910,19 @@
+ 
+ #undef setscrreg
+ int	setscrreg(
+-		int	a1,
++		int	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef slk_attr_off
+ int	slk_attr_off(
+-		const attr_t a1,
++		const attr_t a1, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef slk_attr_on
+ int	slk_attr_on(
+-		attr_t	a1,
++		attr_t	a1, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -933,8 +941,8 @@
+ 
+ #undef touchline
+ int	touchline(
+-		WINDOW	*a1,
+-		int	a2,
++		WINDOW	*a1, 
++		int	a2, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -950,67 +958,67 @@
+ 
+ #undef vline
+ int	vline(
+-		chtype	a1,
++		chtype	a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef vw_printw
+ int	vw_printw(
+-		WINDOW	*a1,
+-		const char *a2,
++		WINDOW	*a1, 
++		const char *a2, 
+ 		va_list	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef vw_scanw
+ int	vw_scanw(
+-		WINDOW	*a1,
+-		char	*a2,
++		WINDOW	*a1, 
++		char	*a2, 
+ 		va_list	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddchstr
+ int	waddchstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		const chtype *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddstr
+ int	waddstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattron
+ int	wattron(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattroff
+ int	wattroff(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattrset
+ int	wattrset(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattr_get
+ int	wattr_get(
+-		WINDOW	*a1,
+-		attr_t	*a2,
+-		short	*a3,
++		WINDOW	*a1, 
++		attr_t	*a2, 
++		short	*a3, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wattr_set
+ int	wattr_set(
+-		WINDOW	*a1,
+-		attr_t	a2,
+-		short	a3,
++		WINDOW	*a1, 
++		attr_t	a2, 
++		short	a3, 
+ 		void	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1021,13 +1029,13 @@
+ 
+ #undef wgetstr
+ int	wgetstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef winchstr
+ int	winchstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		chtype	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1038,13 +1046,13 @@
+ 
+ #undef winsstr
+ int	winsstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		const char *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef winstr
+ int	winstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		char	*z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1065,7 +1073,7 @@
+ 
+ #undef add_wchnstr
+ int	add_wchnstr(
+-		const cchar_t *a1,
++		const cchar_t *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1076,7 +1084,7 @@
+ 
+ #undef addnwstr
+ int	addnwstr(
+-		const wchar_t *a1,
++		const wchar_t *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1097,20 +1105,20 @@
+ 
+ #undef border_set
+ int	border_set(
+-		const cchar_t *a1,
+-		const cchar_t *a2,
+-		const cchar_t *a3,
+-		const cchar_t *a4,
+-		const cchar_t *a5,
+-		const cchar_t *a6,
+-		const cchar_t *a7,
++		const cchar_t *a1, 
++		const cchar_t *a2, 
++		const cchar_t *a3, 
++		const cchar_t *a4, 
++		const cchar_t *a5, 
++		const cchar_t *a6, 
++		const cchar_t *a7, 
+ 		const cchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef box_set
+ int	box_set(
+-		WINDOW	*a1,
+-		const cchar_t *a2,
++		WINDOW	*a1, 
++		const cchar_t *a2, 
+ 		const cchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1136,13 +1144,13 @@
+ 
+ #undef getn_wstr
+ int	getn_wstr(
+-		wint_t	*a1,
++		wint_t	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef hline_set
+ int	hline_set(
+-		const cchar_t *a1,
++		const cchar_t *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1153,7 +1161,7 @@
+ 
+ #undef in_wchnstr
+ int	in_wchnstr(
+-		cchar_t	*a1,
++		cchar_t	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1164,13 +1172,13 @@
+ 
+ #undef innwstr
+ int	innwstr(
+-		wchar_t	*a1,
++		wchar_t	*a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef ins_nwstr
+ int	ins_nwstr(
+-		const wchar_t *a1,
++		const wchar_t *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+@@ -1191,331 +1199,331 @@
+ 
+ #undef mvadd_wch
+ int	mvadd_wch(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const cchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvadd_wchnstr
+ int	mvadd_wchnstr(
+-		int	a1,
+-		int	a2,
+-		const cchar_t *a3,
++		int	a1, 
++		int	a2, 
++		const cchar_t *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvadd_wchstr
+ int	mvadd_wchstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const cchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddnwstr
+ int	mvaddnwstr(
+-		int	a1,
+-		int	a2,
+-		const wchar_t *a3,
++		int	a1, 
++		int	a2, 
++		const wchar_t *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvaddwstr
+ int	mvaddwstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const wchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvget_wch
+ int	mvget_wch(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		wint_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvget_wstr
+ int	mvget_wstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		wint_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvgetn_wstr
+ int	mvgetn_wstr(
+-		int	a1,
+-		int	a2,
+-		wint_t	*a3,
++		int	a1, 
++		int	a2, 
++		wint_t	*a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvhline_set
+ int	mvhline_set(
+-		int	a1,
+-		int	a2,
+-		const cchar_t *a3,
++		int	a1, 
++		int	a2, 
++		const cchar_t *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvin_wch
+ int	mvin_wch(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		cchar_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvin_wchnstr
+ int	mvin_wchnstr(
+-		int	a1,
+-		int	a2,
+-		cchar_t	*a3,
++		int	a1, 
++		int	a2, 
++		cchar_t	*a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvin_wchstr
+ int	mvin_wchstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		cchar_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinnwstr
+ int	mvinnwstr(
+-		int	a1,
+-		int	a2,
+-		wchar_t	*a3,
++		int	a1, 
++		int	a2, 
++		wchar_t	*a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvins_nwstr
+ int	mvins_nwstr(
+-		int	a1,
+-		int	a2,
+-		const wchar_t *a3,
++		int	a1, 
++		int	a2, 
++		const wchar_t *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvins_wch
+ int	mvins_wch(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const cchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvins_wstr
+ int	mvins_wstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		const wchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvinwstr
+ int	mvinwstr(
+-		int	a1,
+-		int	a2,
++		int	a1, 
++		int	a2, 
+ 		wchar_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvvline_set
+ int	mvvline_set(
+-		int	a1,
+-		int	a2,
+-		const cchar_t *a3,
++		int	a1, 
++		int	a2, 
++		const cchar_t *a3, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwadd_wch
+ int	mvwadd_wch(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const cchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwadd_wchnstr
+ int	mvwadd_wchnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const cchar_t *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const cchar_t *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwadd_wchstr
+ int	mvwadd_wchstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const cchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddnwstr
+ int	mvwaddnwstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const wchar_t *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const wchar_t *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwaddwstr
+ int	mvwaddwstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const wchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwget_wch
+ int	mvwget_wch(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		wint_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwget_wstr
+ int	mvwget_wstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		wint_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwgetn_wstr
+ int	mvwgetn_wstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		wint_t	*a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		wint_t	*a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwhline_set
+ int	mvwhline_set(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const cchar_t *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const cchar_t *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwin_wch
+ int	mvwin_wch(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		cchar_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwin_wchnstr
+ int	mvwin_wchnstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		cchar_t	*a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		cchar_t	*a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwin_wchstr
+ int	mvwin_wchstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		cchar_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinnwstr
+ int	mvwinnwstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		wchar_t	*a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		wchar_t	*a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwins_nwstr
+ int	mvwins_nwstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const wchar_t *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const wchar_t *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwins_wch
+ int	mvwins_wch(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const cchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwins_wstr
+ int	mvwins_wstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		const wchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwinwstr
+ int	mvwinwstr(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
+ 		wchar_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwvline_set
+ int	mvwvline_set(
+-		WINDOW	*a1,
+-		int	a2,
+-		int	a3,
+-		const cchar_t *a4,
++		WINDOW	*a1, 
++		int	a2, 
++		int	a3, 
++		const cchar_t *a4, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef vline_set
+ int	vline_set(
+-		const cchar_t *a1,
++		const cchar_t *a1, 
+ 		int	z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wadd_wchstr
+ int	wadd_wchstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		const cchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef waddwstr
+ int	waddwstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		const wchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wget_wstr
+ int	wget_wstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		wint_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef win_wchstr
+ int	win_wchstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		cchar_t	*z)
+ 		{ return(*(int *)0); }
+ 
+ #undef wins_wstr
+ int	wins_wstr(
+-		WINDOW	*a1,
++		WINDOW	*a1, 
+ 		const wchar_t *z)
+ 		{ return(*(int *)0); }
+ 
+ #undef mouse_trafo
+-NCURSES_BOOL mouse_trafo(
+-		int	*a1,
+-		int	*a2,
+-		NCURSES_BOOL z)
++NCURSES_BOOL	mouse_trafo(
++		int	*a1, 
++		int	*a2, 
++		NCURSES_BOOL	z)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ /* ./base/lib_getch.c */
+@@ -1527,8 +1535,8 @@
+ 
+ #undef _nc_wgetch
+ int	_nc_wgetch(
+-		WINDOW	*win,
+-		unsigned long *result,
++		WINDOW	*win, 
++		unsigned long *result, 
+ 		int	use_meta)
+ 		{ return(*(int *)0); }
+ 
+@@ -1541,8 +1549,8 @@
+ 
+ #undef wgetnstr
+ int	wgetnstr(
+-		WINDOW	*win,
+-		char	*str,
++		WINDOW	*win, 
++		char	*str, 
+ 		int	maxlen)
+ 		{ return(*(int *)0); }
+ 
+@@ -1550,8 +1558,8 @@
+ 
+ #undef whline
+ int	whline(
+-		WINDOW	*win,
+-		chtype	ch,
++		WINDOW	*win, 
++		chtype	ch, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1559,7 +1567,7 @@
+ 
+ #undef immedok
+ void	immedok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ /* void */ }
+ 
+@@ -1567,8 +1575,8 @@
+ 
+ #undef winchnstr
+ int	winchnstr(
+-		WINDOW	*win,
+-		chtype	*str,
++		WINDOW	*win, 
++		chtype	*str, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1581,29 +1589,31 @@
+ /* ./base/lib_insch.c */
+ 
+ #undef _nc_insert_ch
+-void	_nc_insert_ch(
+-		WINDOW	*win,
++int	_nc_insert_ch(
++		WINDOW	*win, 
+ 		chtype	ch)
+-		{ /* void */ }
++		{ return(*(int *)0); }
+ 
+ #undef winsch
+ int	winsch(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		chtype	c)
+ 		{ return(*(int *)0); }
+ 
+-#undef winsnstr
+-int	winsnstr(
+-		WINDOW	*win,
+-		const char *s,
+-		int	n)
+-		{ return(*(int *)0); }
+-
+ /* ./base/lib_insdel.c */
+ 
+ #undef winsdelln
+ int	winsdelln(
+-		WINDOW	*win,
++		WINDOW	*win, 
++		int	n)
++		{ return(*(int *)0); }
++
++/* ./base/lib_insnstr.c */
++
++#undef winsnstr
++int	winsnstr(
++		WINDOW	*win, 
++		const char *s, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1611,8 +1621,8 @@
+ 
+ #undef winnstr
+ int	winnstr(
+-		WINDOW	*win,
+-		char	*str,
++		WINDOW	*win, 
++		char	*str, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -1626,7 +1636,7 @@
+ 
+ #undef leaveok
+ int	leaveok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -1644,14 +1654,14 @@
+ 
+ #undef mousemask
+ mmask_t	mousemask(
+-		mmask_t	newmask,
++		mmask_t	newmask, 
+ 		mmask_t	*oldmask)
+ 		{ return(*(mmask_t *)0); }
+ 
+ #undef wenclose
+ NCURSES_BOOL wenclose(
+-		const WINDOW *win,
+-		int	y,
++		const WINDOW *win, 
++		int	y, 
+ 		int	x)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+@@ -1666,9 +1676,9 @@
+ 
+ #undef wmouse_trafo
+ NCURSES_BOOL wmouse_trafo(
+-		const WINDOW *win,
+-		int	*pY,
+-		int	*pX,
++		const WINDOW *win, 
++		int	*pY, 
++		int	*pX, 
+ 		NCURSES_BOOL to_screen)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+@@ -1676,8 +1686,8 @@
+ 
+ #undef wmove
+ int	wmove(
+-		WINDOW	*win,
+-		int	y,
++		WINDOW	*win, 
++		int	y, 
+ 		int	x)
+ 		{ return(*(int *)0); }
+ 
+@@ -1685,7 +1695,7 @@
+ 
+ #undef _nc_msec_cost
+ int	_nc_msec_cost(
+-		const char *const cap,
++		const char *const cap, 
+ 		int	affcnt)
+ 		{ return(*(int *)0); }
+ 
+@@ -1703,9 +1713,9 @@
+ 
+ #undef mvcur
+ int	mvcur(
+-		int	yold,
+-		int	xold,
+-		int	ynew,
++		int	yold, 
++		int	xold, 
++		int	ynew, 
+ 		int	xnew)
+ 		{ return(*(int *)0); }
+ 
+@@ -1716,8 +1726,8 @@
+ 
+ #undef mvwin
+ int	mvwin(
+-		WINDOW	*win,
+-		int	by,
++		WINDOW	*win, 
++		int	by, 
+ 		int	bx)
+ 		{ return(*(int *)0); }
+ 
+@@ -1729,8 +1739,8 @@
+ 
+ #undef newterm
+ SCREEN	*newterm(
+-		char	*name,
+-		FILE	*ofp,
++		char	*name, 
++		FILE	*ofp, 
+ 		FILE	*ifp)
+ 		{ return(*(SCREEN **)0); }
+ 
+@@ -1743,36 +1753,36 @@
+ 
+ #undef newwin
+ WINDOW	*newwin(
+-		int	num_lines,
+-		int	num_columns,
+-		int	begy,
++		int	num_lines, 
++		int	num_columns, 
++		int	begy, 
+ 		int	begx)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef derwin
+ WINDOW	*derwin(
+-		WINDOW	*orig,
+-		int	num_lines,
+-		int	num_columns,
+-		int	begy,
++		WINDOW	*orig, 
++		int	num_lines, 
++		int	num_columns, 
++		int	begy, 
+ 		int	begx)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef subwin
+ WINDOW	*subwin(
+-		WINDOW	*w,
+-		int	l,
+-		int	c,
+-		int	y,
++		WINDOW	*w, 
++		int	l, 
++		int	c, 
++		int	y, 
+ 		int	x)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef _nc_makenew
+ WINDOW	*_nc_makenew(
+-		int	num_lines,
+-		int	num_columns,
+-		int	begy,
+-		int	begx,
++		int	num_lines, 
++		int	num_columns, 
++		int	begy, 
++		int	begx, 
+ 		int	flags)
+ 		{ return(*(WINDOW **)0); }
+ 
+@@ -1790,26 +1800,26 @@
+ 
+ #undef overlay
+ int	overlay(
+-		const WINDOW *win1,
++		const WINDOW *win1, 
+ 		WINDOW	*win2)
+ 		{ return(*(int *)0); }
+ 
+ #undef overwrite
+ int	overwrite(
+-		const WINDOW *win1,
++		const WINDOW *win1, 
+ 		WINDOW	*win2)
+ 		{ return(*(int *)0); }
+ 
+ #undef copywin
+ int	copywin(
+-		const WINDOW *src,
+-		WINDOW	*dst,
+-		int	sminrow,
+-		int	smincol,
+-		int	dminrow,
+-		int	dmincol,
+-		int	dmaxrow,
+-		int	dmaxcol,
++		const WINDOW *src, 
++		WINDOW	*dst, 
++		int	sminrow, 
++		int	smincol, 
++		int	dminrow, 
++		int	dmincol, 
++		int	dmaxrow, 
++		int	dmaxcol, 
+ 		int	over)
+ 		{ return(*(int *)0); }
+ 
+@@ -1817,44 +1827,44 @@
+ 
+ #undef newpad
+ WINDOW	*newpad(
+-		int	l,
++		int	l, 
+ 		int	c)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef subpad
+ WINDOW	*subpad(
+-		WINDOW	*orig,
+-		int	l,
+-		int	c,
+-		int	begy,
++		WINDOW	*orig, 
++		int	l, 
++		int	c, 
++		int	begy, 
+ 		int	begx)
+ 		{ return(*(WINDOW **)0); }
+ 
+ #undef prefresh
+ int	prefresh(
+-		WINDOW	*win,
+-		int	pminrow,
+-		int	pmincol,
+-		int	sminrow,
+-		int	smincol,
+-		int	smaxrow,
++		WINDOW	*win, 
++		int	pminrow, 
++		int	pmincol, 
++		int	sminrow, 
++		int	smincol, 
++		int	smaxrow, 
+ 		int	smaxcol)
+ 		{ return(*(int *)0); }
+ 
+ #undef pnoutrefresh
+ int	pnoutrefresh(
+-		WINDOW	*win,
+-		int	pminrow,
+-		int	pmincol,
+-		int	sminrow,
+-		int	smincol,
+-		int	smaxrow,
++		WINDOW	*win, 
++		int	pminrow, 
++		int	pmincol, 
++		int	sminrow, 
++		int	smincol, 
++		int	smaxrow, 
+ 		int	smaxcol)
+ 		{ return(*(int *)0); }
+ 
+ #undef pechochar
+ int	pechochar(
+-		WINDOW	*pad,
++		WINDOW	*pad, 
+ 		const chtype ch)
+ 		{ return(*(int *)0); }
+ 
+@@ -1862,38 +1872,38 @@
+ 
+ #undef printw
+ int	printw(
+-		const char *fmt,
++		const char *fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef wprintw
+ int	wprintw(
+-		WINDOW	*win,
+-		const char *fmt,
++		WINDOW	*win, 
++		const char *fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvprintw
+ int	mvprintw(
+-		int	y,
+-		int	x,
+-		const char *fmt,
++		int	y, 
++		int	x, 
++		const char *fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwprintw
+ int	mvwprintw(
+-		WINDOW	*win,
+-		int	y,
+-		int	x,
+-		const char *fmt,
++		WINDOW	*win, 
++		int	y, 
++		int	x, 
++		const char *fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef vwprintw
+ int	vwprintw(
+-		WINDOW	*win,
+-		const char *fmt,
++		WINDOW	*win, 
++		const char *fmt, 
+ 		va_list	argp)
+ 		{ return(*(int *)0); }
+ 
+@@ -1901,8 +1911,8 @@
+ 
+ #undef wredrawln
+ int	wredrawln(
+-		WINDOW	*win,
+-		int	beg,
++		WINDOW	*win, 
++		int	beg, 
+ 		int	num)
+ 		{ return(*(int *)0); }
+ 
+@@ -1922,8 +1932,8 @@
+ 
+ #undef restartterm
+ int	restartterm(
+-		char	*termp,
+-		int	filenum,
++		char	*termp, 
++		int	filenum, 
+ 		int	*errret)
+ 		{ return(*(int *)0); }
+ 
+@@ -1931,38 +1941,38 @@
+ 
+ #undef vwscanw
+ int	vwscanw(
+-		WINDOW	*win,
+-		char	*fmt,
++		WINDOW	*win, 
++		char	*fmt, 
+ 		va_list	argp)
+ 		{ return(*(int *)0); }
+ 
+ #undef scanw
+ int	scanw(
+-		char	*fmt,
++		char	*fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef wscanw
+ int	wscanw(
+-		WINDOW	*win,
+-		char	*fmt,
++		WINDOW	*win, 
++		char	*fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvscanw
+ int	mvscanw(
+-		int	y,
+-		int	x,
+-		char	*fmt,
++		int	y, 
++		int	x, 
++		char	*fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+ #undef mvwscanw
+ int	mvwscanw(
+-		WINDOW	*win,
+-		int	y,
+-		int	x,
+-		char	*fmt,
++		WINDOW	*win, 
++		int	y, 
++		int	x, 
++		char	*fmt, 
+ 		...)
+ 		{ return(*(int *)0); }
+ 
+@@ -1975,7 +1985,7 @@
+ 
+ #undef putwin
+ int	putwin(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		FILE	*filep)
+ 		{ return(*(int *)0); }
+ 
+@@ -2003,16 +2013,16 @@
+ 
+ #undef _nc_scroll_window
+ void	_nc_scroll_window(
+-		WINDOW	*win,
+-		int const n,
+-		short const top,
+-		short const bottom,
++		WINDOW	*win, 
++		int const n, 
++		short const top, 
++		short const bottom, 
+ 		cchar_t	blank)
+ 		{ /* void */ }
+ 
+ #undef wscrl
+ int	wscrl(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -2020,7 +2030,7 @@
+ 
+ #undef scrollok
+ int	scrollok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -2028,8 +2038,8 @@
+ 
+ #undef wsetscrreg
+ int	wsetscrreg(
+-		WINDOW	*win,
+-		int	top,
++		WINDOW	*win, 
++		int	top, 
+ 		int	bottom)
+ 		{ return(*(int *)0); }
+ 
+@@ -2047,24 +2057,24 @@
+ 
+ #undef _nc_setupscreen
+ int	_nc_setupscreen(
+-		short	slines,
+-		short const scolumns,
++		short	slines, 
++		short const scolumns, 
+ 		FILE	*output)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_ripoffline
+ int	_nc_ripoffline(
+-		int	line,
++		int	line, 
+ 		int	(*init)(
+-		WINDOW	*p1,
++		WINDOW	*p1, 
+ 		int	p2))
+ 		{ return(*(int *)0); }
+ 
+ #undef ripoffline
+ int	ripoffline(
+-		int	line,
++		int	line, 
+ 		int	(*init)(
+-		WINDOW	*p1,
++		WINDOW	*p1, 
+ 		int	p2))
+ 		{ return(*(int *)0); }
+ 
+@@ -2075,7 +2085,7 @@
+ 
+ #undef _nc_slk_initialize
+ int	_nc_slk_initialize(
+-		WINDOW	*stwin,
++		WINDOW	*stwin, 
+ 		int	cols)
+ 		{ return(*(int *)0); }
+ 
+@@ -2087,8 +2097,8 @@
+ 
+ #undef slk_attr_set
+ int	slk_attr_set(
+-		const attr_t attr,
+-		short	color_pair_number,
++		const attr_t attr, 
++		short	color_pair_number, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -2158,10 +2168,12 @@
+ 
+ /* ./base/lib_slkset.c */
+ 
++#include <wctype.h>
++
+ #undef slk_set
+ int	slk_set(
+-		int	i,
+-		const char *astr,
++		int	i, 
++		const char *astr, 
+ 		int	format)
+ 		{ return(*(int *)0); }
+ 
+@@ -2175,7 +2187,7 @@
+ 
+ #undef is_linetouched
+ NCURSES_BOOL is_linetouched(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		int	line)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+@@ -2186,9 +2198,9 @@
+ 
+ #undef wtouchln
+ int	wtouchln(
+-		WINDOW	*win,
+-		int	y,
+-		int	n,
++		WINDOW	*win, 
++		int	y, 
++		int	n, 
+ 		int	changed)
+ 		{ return(*(int *)0); }
+ 
+@@ -2196,7 +2208,7 @@
+ 
+ #undef _traceattr2
+ char	*_traceattr2(
+-		int	bufnum,
++		int	bufnum, 
+ 		attr_t	newmode)
+ 		{ return(*(char **)0); }
+ 
+@@ -2212,13 +2224,13 @@
+ 
+ #undef _nc_altcharset_name
+ const char *_nc_altcharset_name(
+-		attr_t	attr,
++		attr_t	attr, 
+ 		chtype	ch)
+ 		{ return(*(const char **)0); }
+ 
+ #undef _tracechtype2
+ char	*_tracechtype2(
+-		int	bufnum,
++		int	bufnum, 
+ 		chtype	ch)
+ 		{ return(*(char **)0); }
+ 
+@@ -2234,7 +2246,7 @@
+ 
+ #undef _tracecchar_t2
+ char	*_tracecchar_t2(
+-		int	bufnum,
++		int	bufnum, 
+ 		const cchar_t *ch)
+ 		{ return(*(char **)0); }
+ 
+@@ -2247,7 +2259,7 @@
+ 
+ #undef _tracedump
+ void	_tracedump(
+-		const char *name,
++		const char *name, 
+ 		WINDOW	*win)
+ 		{ /* void */ }
+ 
+@@ -2282,7 +2294,7 @@
+ 
+ #undef vidputs
+ int	vidputs(
+-		chtype	newmode,
++		chtype	newmode, 
+ 		int	(*outc)(
+ 		int	p1))
+ 		{ return(*(int *)0); }
+@@ -2300,8 +2312,8 @@
+ 
+ #undef wvline
+ int	wvline(
+-		WINDOW	*win,
+-		chtype	ch,
++		WINDOW	*win, 
++		chtype	ch, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -2309,8 +2321,8 @@
+ 
+ #undef wattr_off
+ int	wattr_off(
+-		WINDOW	*win,
+-		attr_t	at,
++		WINDOW	*win, 
++		attr_t	at, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -2318,8 +2330,8 @@
+ 
+ #undef wattr_on
+ int	wattr_on(
+-		WINDOW	*win,
+-		attr_t	at,
++		WINDOW	*win, 
++		attr_t	at, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -2339,14 +2351,14 @@
+ 
+ #undef mvderwin
+ int	mvderwin(
+-		WINDOW	*win,
+-		int	y,
++		WINDOW	*win, 
++		int	y, 
+ 		int	x)
+ 		{ return(*(int *)0); }
+ 
+ #undef syncok
+ int	syncok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL bf)
+ 		{ return(*(int *)0); }
+ 
+@@ -2380,7 +2392,7 @@
+ 
+ #undef _nc_printf_string
+ char	*_nc_printf_string(
+-		const char *fmt,
++		const char *fmt, 
+ 		va_list	ap)
+ 		{ return(*(char **)0); }
+ 
+@@ -2395,9 +2407,9 @@
+ 
+ #undef _nc_scrolln
+ int	_nc_scrolln(
+-		int	n,
+-		int	top,
+-		int	bot,
++		int	n, 
++		int	top, 
++		int	bot, 
+ 		int	maxy)
+ 		{ return(*(int *)0); }
+ 
+@@ -2420,9 +2432,13 @@
+ 
+ /* ./trace/varargs.c */
+ 
++typedef enum {
++    atUnknown = 0, atInteger, atFloat, atPoint, atString
++} ARGTYPE;
++
+ #undef _nc_varargs
+ char	*_nc_varargs(
+-		const char *fmt,
++		const char *fmt, 
+ 		va_list	ap)
+ 		{ return(*(char **)0); }
+ 
+@@ -2467,13 +2483,13 @@
+ 
+ #undef wadd_wch
+ int	wadd_wch(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const cchar_t *wch)
+ 		{ return(*(int *)0); }
+ 
+ #undef wecho_wchar
+ int	wecho_wchar(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const cchar_t *wch)
+ 		{ return(*(int *)0); }
+ 
+@@ -2481,14 +2497,14 @@
+ 
+ #undef wborder_set
+ int	wborder_set(
+-		WINDOW	*win,
+-		const cchar_t *ls,
+-		const cchar_t *rs,
+-		const cchar_t *ts,
+-		const cchar_t *bs,
+-		const cchar_t *tl,
+-		const cchar_t *tr,
+-		const cchar_t *bl,
++		WINDOW	*win, 
++		const cchar_t *ls, 
++		const cchar_t *rs, 
++		const cchar_t *ts, 
++		const cchar_t *bs, 
++		const cchar_t *tl, 
++		const cchar_t *tr, 
++		const cchar_t *bl, 
+ 		const cchar_t *br)
+ 		{ return(*(int *)0); }
+ 
+@@ -2496,19 +2512,19 @@
+ 
+ #undef setcchar
+ int	setcchar(
+-		cchar_t	*wcval,
+-		const wchar_t *wch,
+-		const attr_t attrs,
+-		short	color_pair,
++		cchar_t	*wcval, 
++		const wchar_t *wch, 
++		const attr_t attrs, 
++		short	color_pair, 
+ 		const void *opts)
+ 		{ return(*(int *)0); }
+ 
+ #undef getcchar
+ int	getcchar(
+-		const cchar_t *wcval,
+-		wchar_t	*wch,
+-		attr_t	*attrs,
+-		short	*color_pair,
++		const cchar_t *wcval, 
++		wchar_t	*wch, 
++		attr_t	*attrs, 
++		short	*color_pair, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -2516,7 +2532,7 @@
+ 
+ #undef wget_wch
+ int	wget_wch(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		wint_t	*result)
+ 		{ return(*(int *)0); }
+ 
+@@ -2536,8 +2552,8 @@
+ 
+ #undef wgetn_wstr
+ int	wgetn_wstr(
+-		WINDOW	*win,
+-		wint_t	*str,
++		WINDOW	*win, 
++		wint_t	*str, 
+ 		int	maxlen)
+ 		{ return(*(int *)0); }
+ 
+@@ -2545,8 +2561,8 @@
+ 
+ #undef whline_set
+ int	whline_set(
+-		WINDOW	*win,
+-		const cchar_t *ch,
++		WINDOW	*win, 
++		const cchar_t *ch, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -2554,7 +2570,7 @@
+ 
+ #undef win_wch
+ int	win_wch(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		cchar_t	*wcval)
+ 		{ return(*(int *)0); }
+ 
+@@ -2562,8 +2578,8 @@
+ 
+ #undef win_wchnstr
+ int	win_wchnstr(
+-		WINDOW	*win,
+-		cchar_t	*wchstr,
++		WINDOW	*win, 
++		cchar_t	*wchstr, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -2571,14 +2587,14 @@
+ 
+ #undef wins_wch
+ int	wins_wch(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		const cchar_t *wch)
+ 		{ return(*(int *)0); }
+ 
+ #undef wins_nwstr
+ int	wins_nwstr(
+-		WINDOW	*win,
+-		const wchar_t *wstr,
++		WINDOW	*win, 
++		const wchar_t *wstr, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -2586,14 +2602,14 @@
+ 
+ #undef winnwstr
+ int	winnwstr(
+-		WINDOW	*win,
+-		wchar_t	*wstr,
++		WINDOW	*win, 
++		wchar_t	*wstr, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+ #undef winwstr
+ int	winwstr(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		wchar_t	*wstr)
+ 		{ return(*(int *)0); }
+ 
+@@ -2601,7 +2617,7 @@
+ 
+ #undef pecho_wchar
+ int	pecho_wchar(
+-		WINDOW	*pad,
++		WINDOW	*pad, 
+ 		const cchar_t *wch)
+ 		{ return(*(int *)0); }
+ 
+@@ -2609,13 +2625,20 @@
+ 
+ #undef slk_wset
+ int	slk_wset(
+-		int	i,
+-		const wchar_t *astr,
++		int	i, 
++		const wchar_t *astr, 
+ 		int	format)
+ 		{ return(*(int *)0); }
+ 
+ /* ./widechar/lib_unget_wch.c */
+ 
++#undef _nc_wcrtomb
++size_t	_nc_wcrtomb(
++		char	*target, 
++		wchar_t	source, 
++		mbstate_t *state)
++		{ return(*(size_t *)0); }
++
+ #undef unget_wch
+ int	unget_wch(
+ 		const wchar_t wch)
+@@ -2625,17 +2648,17 @@
+ 
+ #undef vid_puts
+ int	vid_puts(
+-		attr_t	newmode,
+-		short	pair,
+-		void	*opts,
++		attr_t	newmode, 
++		short	pair, 
++		void	*opts, 
+ 		int	(*outc)(
+ 		int	p1))
+ 		{ return(*(int *)0); }
+ 
+ #undef vid_attr
+ int	vid_attr(
+-		attr_t	newmode,
+-		short	pair,
++		attr_t	newmode, 
++		short	pair, 
+ 		void	*opts)
+ 		{ return(*(int *)0); }
+ 
+@@ -2647,8 +2670,8 @@
+ 
+ #undef wvline_set
+ int	wvline_set(
+-		WINDOW	*win,
+-		const cchar_t *ch,
++		WINDOW	*win, 
++		const cchar_t *ch, 
+ 		int	n)
+ 		{ return(*(int *)0); }
+ 
+@@ -2672,7 +2695,7 @@
+ 
+ #undef define_key
+ int	define_key(
+-		const char *str,
++		const char *str, 
+ 		int	keycode)
+ 		{ return(*(int *)0); }
+ 
+@@ -2680,13 +2703,13 @@
+ 
+ #undef _nc_toggle_attr_on
+ void	_nc_toggle_attr_on(
+-		attr_t	*S,
++		attr_t	*S, 
+ 		attr_t	at)
+ 		{ /* void */ }
+ 
+ #undef _nc_toggle_attr_off
+ void	_nc_toggle_attr_off(
+-		attr_t	*S,
++		attr_t	*S, 
+ 		attr_t	at)
+ 		{ /* void */ }
+ 
+@@ -2702,7 +2725,7 @@
+ 
+ #undef _nc_UpdateAttrs
+ void	_nc_UpdateAttrs(
+-		chtype	c)
++		cchar_t	c)
+ 		{ /* void */ }
+ 
+ /* ./base/key_defined.c */
+@@ -2716,7 +2739,7 @@
+ 
+ #undef keybound
+ char	*keybound(
+-		int	code,
++		int	code, 
+ 		int	count)
+ 		{ return(*(char **)0); }
+ 
+@@ -2724,7 +2747,7 @@
+ 
+ #undef keyok
+ int	keyok(
+-		int	c,
++		int	c, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -2736,7 +2759,7 @@
+ 
+ #undef assume_default_colors
+ int	assume_default_colors(
+-		int	fg,
++		int	fg, 
+ 		int	bg)
+ 		{ return(*(int *)0); }
+ 
+@@ -2744,7 +2767,7 @@
+ 
+ #undef mcprint
+ int	mcprint(
+-		char	*data,
++		char	*data, 
+ 		int	len)
+ 		{ return(*(int *)0); }
+ 
+@@ -2752,19 +2775,19 @@
+ 
+ #undef is_term_resized
+ NCURSES_BOOL is_term_resized(
+-		int	ToLines,
++		int	ToLines, 
+ 		int	ToCols)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ #undef resize_term
+ int	resize_term(
+-		int	ToLines,
++		int	ToLines, 
+ 		int	ToCols)
+ 		{ return(*(int *)0); }
+ 
+ #undef resizeterm
+ int	resizeterm(
+-		int	ToLines,
++		int	ToLines, 
+ 		int	ToCols)
+ 		{ return(*(int *)0); }
+ 
+@@ -2779,41 +2802,37 @@
+ 
+ #undef _nc_expand_try
+ char	*_nc_expand_try(
+-		struct tries *tree,
+-		unsigned short code,
+-		int	*count,
++		struct tries *tree, 
++		unsigned short code, 
++		int	*count, 
+ 		size_t	len)
+ 		{ return(*(char **)0); }
+ 
+ #undef _nc_remove_key
+ int	_nc_remove_key(
+-		struct tries **tree,
++		struct tries **tree, 
+ 		unsigned short code)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_remove_string
+ int	_nc_remove_string(
+-		struct tries **tree,
++		struct tries **tree, 
+ 		const char *string)
+ 		{ return(*(int *)0); }
+ 
+-/* ./base/version.c */
+-
+-#undef curses_version
+-const char *curses_version(void)
+-		{ return(*(const char **)0); }
+-
+ /* ./base/wresize.c */
+ 
+ #undef wresize
+ int	wresize(
+-		WINDOW	*win,
+-		int	ToLines,
++		WINDOW	*win, 
++		int	ToLines, 
+ 		int	ToCols)
+ 		{ return(*(int *)0); }
+ 
+ /* ./tinfo/access.c */
+ 
++#include <nc_alloc.h>
++
+ #undef _nc_rootname
+ char	*_nc_rootname(
+ 		char	*path)
+@@ -2831,7 +2850,7 @@
+ 
+ #undef _nc_access
+ int	_nc_access(
+-		const char *path,
++		const char *path, 
+ 		int	mode)
+ 		{ return(*(int *)0); }
+ 
+@@ -2843,8 +2862,8 @@
+ 
+ #undef _nc_add_to_try
+ void	_nc_add_to_try(
+-		struct tries **tree,
+-		const char *str,
++		struct tries **tree, 
++		const char *str, 
+ 		unsigned short code)
+ 		{ /* void */ }
+ 
+@@ -2867,13 +2886,13 @@
+ 
+ #undef _nc_wrap_entry
+ void	_nc_wrap_entry(
+-		ENTRY	*const ep,
++		ENTRY	*const ep, 
+ 		NCURSES_BOOL copy_strings)
+ 		{ /* void */ }
+ 
+ #undef _nc_merge_entry
+ void	_nc_merge_entry(
+-		TERMTYPE *const to,
++		TERMTYPE *const to, 
+ 		TERMTYPE *const from)
+ 		{ /* void */ }
+ 
+@@ -2881,13 +2900,13 @@
+ 
+ #undef _nc_align_termtype
+ void	_nc_align_termtype(
+-		TERMTYPE *to,
++		TERMTYPE *to, 
+ 		TERMTYPE *from)
+ 		{ /* void */ }
+ 
+ #undef _nc_copy_termtype
+ void	_nc_copy_termtype(
+-		TERMTYPE *dst,
++		TERMTYPE *dst, 
+ 		TERMTYPE *src)
+ 		{ /* void */ }
+ 
+@@ -2895,15 +2914,15 @@
+ 
+ #undef _nc_captoinfo
+ char	*_nc_captoinfo(
+-		const char *cap,
+-		const char *s,
++		const char *cap, 
++		const char *s, 
+ 		int const parameterized)
+ 		{ return(*(char **)0); }
+ 
+ #undef _nc_infotocap
+ char	*_nc_infotocap(
+-		const char *cap,
+-		const char *str,
++		const char *cap, 
++		const char *str, 
+ 		int const parameterized)
+ 		{ return(*(char **)0); }
+ 
+@@ -2965,19 +2984,19 @@
+ 
+ #undef _nc_warning
+ void	_nc_warning(
+-		const char *const fmt,
++		const char *const fmt, 
+ 		...)
+ 		{ /* void */ }
+ 
+ #undef _nc_err_abort
+ void	_nc_err_abort(
+-		const char *const fmt,
++		const char *const fmt, 
+ 		...)
+ 		{ /* void */ }
+ 
+ #undef _nc_syserr_abort
+ void	_nc_syserr_abort(
+-		const char *const fmt,
++		const char *const fmt, 
+ 		...)
+ 		{ /* void */ }
+ 
+@@ -2985,8 +3004,8 @@
+ 
+ #undef _nc_tic_expand
+ char	*_nc_tic_expand(
+-		const char *srcp,
+-		NCURSES_BOOL tic_format,
++		const char *srcp, 
++		NCURSES_BOOL tic_format, 
+ 		int	numbers)
+ 		{ return(*(char **)0); }
+ 
+@@ -2996,19 +3015,23 @@
+ 
+ #undef _nc_find_entry
+ struct name_table_entry const *_nc_find_entry(
+-		const char *string,
++		const char *string, 
+ 		const struct name_table_entry *const *hash_table)
+ 		{ return(*(struct name_table_entry const **)0); }
+ 
+ #undef _nc_find_type_entry
+ struct name_table_entry const *_nc_find_type_entry(
+-		const char *string,
+-		int	type,
++		const char *string, 
++		int	type, 
+ 		const struct name_table_entry *table)
+ 		{ return(*(struct name_table_entry const **)0); }
+ 
+ /* ./tinfo/comp_parse.c */
+ 
++#undef _nc_check_termtype2
++void	(*_nc_check_termtype2)(
++		TERMTYPE *p1, 
++		NCURSES_BOOL p2);
+ #undef _nc_check_termtype
+ void	(*_nc_check_termtype)(
+ 		TERMTYPE *p1);
+@@ -3024,20 +3047,26 @@
+ 
+ #undef _nc_entry_match
+ NCURSES_BOOL _nc_entry_match(
+-		char	*n1,
++		char	*n1, 
+ 		char	*n2)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ #undef _nc_read_entry_source
+ void	_nc_read_entry_source(
+-		FILE	*fp,
+-		char	*buf,
+-		int	literal,
+-		NCURSES_BOOL silent,
++		FILE	*fp, 
++		char	*buf, 
++		int	literal, 
++		NCURSES_BOOL silent, 
+ 		NCURSES_BOOL (*hook)(
+ 		ENTRY	*p1))
+ 		{ /* void */ }
+ 
++#undef _nc_resolve_uses2
++int	_nc_resolve_uses2(
++		NCURSES_BOOL fullresolve, 
++		NCURSES_BOOL literal)
++		{ return(*(int *)0); }
++
+ #undef _nc_resolve_uses
+ int	_nc_resolve_uses(
+ 		NCURSES_BOOL fullresolve)
+@@ -3060,16 +3089,22 @@
+ #undef _nc_disable_period
+ NCURSES_BOOL _nc_disable_period;
+ 
++#undef _nc_reset_input
++void	_nc_reset_input(
++		FILE	*fp, 
++		char	*buf)
++		{ /* void */ }
++
+ #undef _nc_get_token
+ int	_nc_get_token(
+ 		NCURSES_BOOL silent)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_trans_string
+-char	_nc_trans_string(
+-		char	*ptr,
++int	_nc_trans_string(
++		char	*ptr, 
+ 		char	*last)
+-		{ return(*(char *)0); }
++		{ return(*(int *)0); }
+ 
+ #undef _nc_push_token
+ void	_nc_push_token(
+@@ -3081,17 +3116,11 @@
+ 		char	ch)
+ 		{ /* void */ }
+ 
+-#undef _nc_reset_input
+-void	_nc_reset_input(
+-		FILE	*fp,
+-		char	*buf)
+-		{ /* void */ }
+-
+ /* ./tinfo/doalloc.c */
+ 
+ #undef _nc_doalloc
+ void	*_nc_doalloc(
+-		void	*oldp,
++		void	*oldp, 
+ 		size_t	amount)
+ 		{ return(*(void **)0); }
+ 
+@@ -3158,6 +3187,11 @@
+ 
+ #include <termcap.h>
+ 
++struct speed {
++    int s; 
++    int sp; 
++};
++
+ #undef _nc_baudrate
+ int	_nc_baudrate(
+ 		int	OSpeed)
+@@ -3258,13 +3292,13 @@
+ 
+ #undef idlok
+ int	idlok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+ #undef idcok
+ void	idcok(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ /* void */ }
+ 
+@@ -3275,31 +3309,31 @@
+ 
+ #undef nodelay
+ int	nodelay(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+ #undef notimeout
+ int	notimeout(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL f)
+ 		{ return(*(int *)0); }
+ 
+ #undef wtimeout
+ void	wtimeout(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		int	delay)
+ 		{ /* void */ }
+ 
+ #undef keypad
+ int	keypad(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+ #undef meta
+ int	meta(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+@@ -3351,13 +3385,15 @@
+ 
+ #undef intrflush
+ int	intrflush(
+-		WINDOW	*win,
++		WINDOW	*win, 
+ 		NCURSES_BOOL flag)
+ 		{ return(*(int *)0); }
+ 
+ /* ./tinfo/lib_setup.c */
+ 
++#include <locale.h>
+ #include <sys/ioctl.h>
++#include <langinfo.h>
+ 
+ #undef ttytype
+ char	ttytype[256];
+@@ -3389,10 +3425,18 @@
+ int	_nc_locale_breaks_acs(void)
+ 		{ return(*(int *)0); }
+ 
++#undef _nc_setupterm
++int	_nc_setupterm(
++		char	*tname, 
++		int	Filedes, 
++		int	*errret, 
++		NCURSES_BOOL reuse)
++		{ return(*(int *)0); }
++
+ #undef setupterm
+ int	setupterm(
+-		char	*tname,
+-		int	Filedes,
++		char	*tname, 
++		int	Filedes, 
+ 		int	*errret)
+ 		{ return(*(int *)0); }
+ 
+@@ -3405,7 +3449,7 @@
+ 
+ #undef tgetent
+ int	tgetent(
+-		char	*bufp,
++		char	*bufp, 
+ 		const char *name)
+ 		{ return(*(int *)0); }
+ 
+@@ -3427,7 +3471,7 @@
+ 
+ #undef tgetstr
+ char	*tgetstr(
+-		char	*id,
++		char	*id, 
+ 		char	**area)
+ 		{ return(*(char **)0); }
+ 
+@@ -3441,8 +3485,8 @@
+ 
+ #undef tgoto
+ char	*tgoto(
+-		const char *string,
+-		int	x,
++		const char *string, 
++		int	x, 
+ 		int	y)
+ 		{ return(*(char **)0); }
+ 
+@@ -3465,19 +3509,27 @@
+ 
+ /* ./tinfo/lib_tparm.c */
+ 
++typedef struct {
++    union {
++        int num;
++        char *str;
++    } data;
++    NCURSES_BOOL num_type;
++} stack_frame;
++
+ #undef _nc_tparm_err
+ int	_nc_tparm_err;
+ 
+ #undef _nc_tparm_analyze
+ int	_nc_tparm_analyze(
+-		const char *string,
+-		char	*p_is_s[9],
++		const char *string, 
++		char	*p_is_s[9], 
+ 		int	*popcount)
+ 		{ return(*(int *)0); }
+ 
+ #undef tparm
+ char	*tparm(
+-		char	*string,
++		char	*string, 
+ 		...)
+ 		{ return(*(char **)0); }
+ 
+@@ -3511,8 +3563,8 @@
+ 
+ #undef tputs
+ int	tputs(
+-		const char *string,
+-		int	affcnt,
++		const char *string, 
++		int	affcnt, 
+ 		int	(*outc)(
+ 		int	p1))
+ 		{ return(*(int *)0); }
+@@ -3533,7 +3585,7 @@
+ 
+ #undef _tracef
+ void	_tracef(
+-		const char *fmt,
++		const char *fmt, 
+ 		...)
+ 		{ /* void */ }
+ 
+@@ -3557,6 +3609,21 @@
+ 		char	*code)
+ 		{ return(*(char **)0); }
+ 
++#undef _nc_retrace_cptr
++const char *_nc_retrace_cptr(
++		const char *code)
++		{ return(*(const char **)0); }
++
++#undef _nc_retrace_cvoid_ptr
++void	*_nc_retrace_cvoid_ptr(
++		void	*code)
++		{ return(*(void **)0); }
++
++#undef _nc_retrace_void_ptr
++void	*_nc_retrace_void_ptr(
++		void	*code)
++		{ return(*(void **)0); }
++
+ #undef _nc_retrace_sp
+ SCREEN	*_nc_retrace_sp(
+ 		SCREEN	*code)
+@@ -3569,6 +3636,11 @@
+ 
+ /* ./trace/lib_tracebits.c */
+ 
++typedef struct {
++    unsigned int val;
++    const char *name;
++} BITNAMES;
++
+ #undef _nc_trace_ttymode
+ char	*_nc_trace_ttymode(
+ 		struct termios *tty)
+@@ -3625,8 +3697,8 @@
+ 
+ #undef _nc_timed_wait
+ int	_nc_timed_wait(
+-		int	mode,
+-		int	milliseconds,
++		int	mode, 
++		int	milliseconds, 
+ 		int	*timeleft)
+ 		{ return(*(int *)0); }
+ 
+@@ -3639,8 +3711,8 @@
+ 
+ #undef _nc_name_match
+ int	_nc_name_match(
+-		const char *const namelst,
+-		const char *const name,
++		const char *const namelst, 
++		const char *const name, 
+ 		const char *const delim)
+ 		{ return(*(int *)0); }
+ 
+@@ -3663,17 +3735,22 @@
+ 
+ #undef _nc_parse_entry
+ int	_nc_parse_entry(
+-		struct entry *entryp,
+-		int	literal,
++		struct entry *entryp, 
++		int	literal, 
+ 		NCURSES_BOOL silent)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_capcmp
+ int	_nc_capcmp(
+-		const char *s,
++		const char *s, 
+ 		const char *t)
+ 		{ return(*(int *)0); }
+ 
++typedef struct {
++    const char *from;
++    const char *to;
++} assoc;
++
+ /* ./tinfo/read_entry.c */
+ 
+ #undef _nc_tic_dir
+@@ -3688,22 +3765,25 @@
+ 
+ #undef _nc_read_file_entry
+ int	_nc_read_file_entry(
+-		const char *const filename,
++		const char *const filename, 
+ 		TERMTYPE *ptr)
+ 		{ return(*(int *)0); }
+ 
+ #undef _nc_read_entry
+ int	_nc_read_entry(
+-		const char *const tn,
+-		char	*const filename,
++		const char *const tn, 
++		char	*const filename, 
+ 		TERMTYPE *const tp)
+ 		{ return(*(int *)0); }
+ 
+ /* ./tinfo/read_termcap.c */
+ 
++#include <sys/types.h>
++#include <sys/stat.h>
++
+ #undef _nc_read_termcap_entry
+ int	_nc_read_termcap_entry(
+-		const char *const tn,
++		const char *const tn, 
+ 		TERMTYPE *const tp)
+ 		{ return(*(int *)0); }
+ 
+@@ -3711,7 +3791,7 @@
+ 
+ #undef _nc_set_buffer
+ void	_nc_set_buffer(
+-		FILE	*ofp,
++		FILE	*ofp, 
+ 		NCURSES_BOOL buffered)
+ 		{ /* void */ }
+ 
+@@ -3719,46 +3799,51 @@
+ 
+ #undef _nc_str_init
+ string_desc *_nc_str_init(
+-		string_desc *dst,
+-		char	*src,
++		string_desc *dst, 
++		char	*src, 
+ 		size_t	len)
+ 		{ return(*(string_desc **)0); }
+ 
+ #undef _nc_str_null
+ string_desc *_nc_str_null(
+-		string_desc *dst,
++		string_desc *dst, 
+ 		size_t	len)
+ 		{ return(*(string_desc **)0); }
+ 
+ #undef _nc_str_copy
+ string_desc *_nc_str_copy(
+-		string_desc *dst,
++		string_desc *dst, 
+ 		string_desc *src)
+ 		{ return(*(string_desc **)0); }
+ 
+ #undef _nc_safe_strcat
+ NCURSES_BOOL _nc_safe_strcat(
+-		string_desc *dst,
++		string_desc *dst, 
+ 		const char *src)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ #undef _nc_safe_strcpy
+ NCURSES_BOOL _nc_safe_strcpy(
+-		string_desc *dst,
++		string_desc *dst, 
+ 		const char *src)
+ 		{ return(*(NCURSES_BOOL *)0); }
+ 
+ /* ./trace/trace_buf.c */
+ 
++typedef struct {
++    char *text;
++    size_t size;
++} LIST;
++
+ #undef _nc_trace_buf
+ char	*_nc_trace_buf(
+-		int	bufnum,
++		int	bufnum, 
+ 		size_t	want)
+ 		{ return(*(char **)0); }
+ 
+ #undef _nc_trace_bufcat
+ char	*_nc_trace_bufcat(
+-		int	bufnum,
++		int	bufnum, 
+ 		const char *value)
+ 		{ return(*(char **)0); }
+ 
+@@ -3780,7 +3865,7 @@
+ 
+ #undef _nc_visbuf2
+ const char *_nc_visbuf2(
+-		int	bufnum,
++		int	bufnum, 
+ 		const char *buf)
+ 		{ return(*(const char **)0); }
+ 
+@@ -3791,13 +3876,13 @@
+ 
+ #undef _nc_visbufn
+ const char *_nc_visbufn(
+-		const char *buf,
++		const char *buf, 
+ 		int	len)
+ 		{ return(*(const char **)0); }
+ 
+ #undef _nc_viswbuf2
+ const char *_nc_viswbuf2(
+-		int	bufnum,
++		int	bufnum, 
+ 		const wchar_t *buf)
+ 		{ return(*(const char **)0); }
+ 
+@@ -3808,20 +3893,25 @@
+ 
+ #undef _nc_viswbufn
+ const char *_nc_viswbufn(
+-		const wchar_t *buf,
++		const wchar_t *buf, 
+ 		int	len)
+ 		{ return(*(const char **)0); }
+ 
++#undef _nc_viswibuf
++const char *_nc_viswibuf(
++		const wint_t *buf)
++		{ return(*(const char **)0); }
++
+ #undef _nc_viscbuf2
+ const char *_nc_viscbuf2(
+-		int	bufnum,
+-		const cchar_t *buf,
++		int	bufnum, 
++		const cchar_t *buf, 
+ 		int	len)
+ 		{ return(*(const char **)0); }
+ 
+ #undef _nc_viscbuf
+ const char *_nc_viscbuf(
+-		const cchar_t *buf,
++		const cchar_t *buf, 
+ 		int	len)
+ 		{ return(*(const char **)0); }
+ 
+@@ -3840,3 +3930,9 @@
+ #undef _nc_tic_written
+ int	_nc_tic_written(void)
+ 		{ return(*(int *)0); }
++
++/* ./base/version.c */
++
++#undef curses_version
++const char *curses_version(void)
++		{ return(*(const char **)0); }
+Index: ncurses/modules
+Prereq:  1.100 
+--- ncurses-5.4-20040208/ncurses/modules	2004-01-10 19:08:23.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/modules	2004-02-29 01:18:06.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: modules,v 1.100 2004/01/10 19:08:23 tom Exp $
++# $Id: modules,v 1.101 2004/02/29 01:18:06 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2003,2004 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"), #
+@@ -61,6 +61,7 @@
+ lib_initscr	lib		$(base)		$(INCDIR)/tic.h
+ lib_insch	lib		$(base)
+ lib_insdel	lib		$(base)
++lib_insnstr	lib		$(base)
+ lib_instr	lib		$(base)
+ lib_isendwin	lib		$(base)
+ lib_leaveok	lib		$(base)
+Index: ncurses/tinfo/alloc_entry.c
+Prereq:  1.40 
+--- ncurses-5.4-20040208/ncurses/tinfo/alloc_entry.c	2003-11-08 21:29:54.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/alloc_entry.c	2005-01-16 00:32:18.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,7 +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-2003               *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -48,7 +48,7 @@
+ #include <tic.h>
+ #include <term_entry.h>
+ 
+-MODULE_ID("$Id: alloc_entry.c,v 1.40 2003/11/08 21:29:54 tom Exp $")
++MODULE_ID("$Id: alloc_entry.c,v 1.43 2005/01/16 00:32:18 tom Exp $")
+ 
+ #define ABSENT_OFFSET    -1
+ #define CANCELLED_OFFSET -2
+@@ -59,11 +59,18 @@
+ static size_t next_free;	/* next free character in stringbuf */
+ 
+ NCURSES_EXPORT(void)
+-_nc_init_entry(TERMTYPE * const tp)
++_nc_init_entry(TERMTYPE *const tp)
+ /* initialize a terminal type data block */
+ {
+     unsigned i;
+ 
++#if NO_LEAKS
++    if (tp == 0 && stringbuf != 0) {
++	FreeAndNull(stringbuf);
++	return;
++    }
++#endif
++
+     if (stringbuf == 0)
+ 	stringbuf = (char *) malloc(MAX_STRTAB);
+ 
+@@ -106,20 +113,32 @@
+     return newp;
+ }
+ 
++/* save a copy of string in the string buffer */
+ NCURSES_EXPORT(char *)
+ _nc_save_str(const char *const string)
+-/* save a copy of string in the string buffer */
+ {
++    char *result = 0;
+     size_t old_next_free = next_free;
+     size_t len = strlen(string) + 1;
+ 
+-    if (next_free + len < MAX_STRTAB) {
++    if (len == 1 && next_free != 0) {
++	/*
++	 * Cheat a little by making an empty string point to the end of the
++	 * previous string.
++	 */
++	if (next_free < MAX_STRTAB) {
++	    result = (stringbuf + next_free - 1);
++	}
++    } else if (next_free + len < MAX_STRTAB) {
+ 	strcpy(&stringbuf[next_free], string);
+ 	DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
+ 	DEBUG(7, ("at location %d", (int) next_free));
+ 	next_free += len;
++	result = (stringbuf + old_next_free);
++    } else {
++	_nc_warning("Too much data, some is lost");
+     }
+-    return (stringbuf + old_next_free);
++    return result;
+ }
+ 
+ NCURSES_EXPORT(void)
+@@ -211,7 +230,7 @@
+ }
+ 
+ NCURSES_EXPORT(void)
+-_nc_merge_entry(TERMTYPE * const to, TERMTYPE * const from)
++_nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
+ /* merge capabilities from `from' entry into `to' entry */
+ {
+     unsigned i;
+Index: ncurses/tinfo/captoinfo.c
+Prereq:  1.45 
+--- ncurses-5.4-20040208/ncurses/tinfo/captoinfo.c	2003-11-08 21:28:04.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/captoinfo.c	2004-08-28 18:08:50.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -92,7 +93,7 @@
+ #include <ctype.h>
+ #include <tic.h>
+ 
+-MODULE_ID("$Id: captoinfo.c,v 1.45 2003/11/08 21:28:04 tom Exp $")
++MODULE_ID("$Id: captoinfo.c,v 1.46 2004/08/28 18:08:50 tom Exp $")
+ 
+ #define MAX_PUSHED	16	/* max # args we can push onto the stack */
+ 
+@@ -276,7 +277,7 @@
+  *	% translations if 1
+  *	pad translations if >=0
+  */
+-char *
++NCURSES_EXPORT(char *)
+ _nc_captoinfo(const char *cap, const char *s, int const parameterized)
+ {
+     const char *capstart;
+@@ -636,7 +637,7 @@
+  * Convert a terminfo string to termcap format.  Parameters are as in
+  * _nc_captoinfo().
+  */
+-char *
++NCURSES_EXPORT(char *)
+ _nc_infotocap(const char *cap GCC_UNUSED, const char *str, int const parameterized)
+ {
+     int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
+@@ -678,6 +679,7 @@
+ 	    --str;
+ 	} else if (str[0] == '%' && str[1] == '%') {	/* escaped '%' */
+ 	    bufptr = save_string(bufptr, "%%");
++	    ++str;
+ 	} else if (*str != '%' || (parameterized < 1)) {
+ 	    bufptr = save_char(bufptr, *str);
+ 	} else if (sscanf(str, "%%?%%{%d}%%>%%t%%{%d}%%+%%;", &c1, &c2) == 2) {
+Index: ncurses/tinfo/comp_error.c
+Prereq:  1.25 
+--- ncurses-5.4-20040208/ncurses/tinfo/comp_error.c	2002-09-07 20:05:07.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/comp_error.c	2005-01-22 21:31:48.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2002,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -40,7 +41,7 @@
+ 
+ #include <tic.h>
+ 
+-MODULE_ID("$Id: comp_error.c,v 1.25 2002/09/07 20:05:07 tom Exp $")
++MODULE_ID("$Id: comp_error.c,v 1.28 2005/01/22 21:31:48 tom Exp $")
+ 
+ NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings = FALSE;
+ NCURSES_EXPORT_VAR(int) _nc_curr_line = 0; /* current line # in input */
+@@ -70,7 +71,14 @@
+ NCURSES_EXPORT(void)
+ _nc_get_type(char *name)
+ {
+-    strcpy(name, termtype != 0 ? termtype : "");
++#if NO_LEAKS
++    if (name == 0 && termtype != 0) {
++	FreeAndNull(termtype);
++	return;
++    }
++#endif
++    if (name != 0)
++	strcpy(name, termtype != 0 ? termtype : "");
+ }
+ 
+ static inline void
+Index: ncurses/tinfo/comp_parse.c
+Prereq:  1.57 
+--- ncurses-5.4-20040208/ncurses/tinfo/comp_parse.c	2003-10-25 22:25:36.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/comp_parse.c	2004-07-05 12:01:24.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,18 +29,19 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ /*
+  *	comp_parse.c -- parser driver loop and use handling.
+  *
+  *	_nc_read_entry_source(FILE *, literal, bool, bool (*hook)())
+- *	_nc_resolve_uses(void)
++ *	_nc_resolve_uses2(void)
+  *	_nc_free_entries(void)
+  *
+  *	Use this code by calling _nc_read_entry_source() on as many source
+  *	files as you like (either terminfo or termcap syntax).  If you
+- *	want use-resolution, call _nc_resolve_uses().  To free the list
++ *	want use-resolution, call _nc_resolve_uses2().  To free the list
+  *	storage, do _nc_free_entries().
+  *
+  */
+@@ -52,8 +53,12 @@
+ #include <tic.h>
+ #include <term_entry.h>
+ 
+-MODULE_ID("$Id: comp_parse.c,v 1.57 2003/10/25 22:25:36 tom Exp $")
++MODULE_ID("$Id: comp_parse.c,v 1.59 2004/07/05 12:01:24 tom Exp $")
+ 
++static void sanity_check2(TERMTYPE *, bool);
++NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype2) (TERMTYPE *, bool) = sanity_check2;
++
++/* obsolete: 20040705 */
+ static void sanity_check(TERMTYPE *);
+ NCURSES_IMPEXP void NCURSES_API(*_nc_check_termtype) (TERMTYPE *) = sanity_check;
+ 
+@@ -105,13 +110,7 @@
+     ENTRY *ep, *next;
+ 
+     for (ep = headp; ep; ep = next) {
+-	/*
+-	 * This conditional lets us disconnect storage from the list.
+-	 * To do this, copy an entry out of the list, then null out
+-	 * the string-table member in the original and any use entries
+-	 * it references.
+-	 */
+-	FreeIfNeeded(ep->tterm.str_table);
++	_nc_free_termtype(&(ep->tterm));
+ 
+ 	next = ep->next;
+ 
+@@ -188,10 +187,14 @@
+ 	 * use references to disk, so as to avoid chewing up a lot of
+ 	 * core when the resolution code could fetch entries off disk.
+ 	 */
+-	if (hook != NULLHOOK && (*hook) (&thisentry))
++	if (hook != NULLHOOK && (*hook) (&thisentry)) {
+ 	    immediate++;
+-	else
++	} else {
+ 	    enqueue(&thisentry);
++	    FreeIfNeeded(thisentry.tterm.Booleans);
++	    FreeIfNeeded(thisentry.tterm.Numbers);
++	    FreeIfNeeded(thisentry.tterm.Strings);
++	}
+     }
+ 
+     if (_nc_tail) {
+@@ -211,7 +214,7 @@
+ }
+ 
+ NCURSES_EXPORT(int)
+-_nc_resolve_uses(bool fullresolve)
++_nc_resolve_uses2(bool fullresolve, bool literal)
+ /* try to resolve all use capabilities */
+ {
+     ENTRY *qp, *rp, *lastread = 0;
+@@ -406,7 +409,7 @@
+ 	    for_entry_list(qp) {
+ 		_nc_curr_line = qp->startline;
+ 		_nc_set_type(_nc_first_name(qp->tterm.term_names));
+-		_nc_check_termtype(&qp->tterm);
++		_nc_check_termtype2(&qp->tterm, literal);
+ 	    }
+ 	    DEBUG(2, ("SANITY CHECK FINISHED"));
+ 	}
+@@ -414,6 +417,13 @@
+     return (TRUE);
+ }
+ 
++/* obsolete: 20040705 */
++NCURSES_EXPORT(int)
++_nc_resolve_uses(bool fullresolve)
++{
++    return _nc_resolve_uses2(fullresolve, FALSE);
++}
++
+ /*
+  * This bit of legerdemain turns all the terminfo variable names into
+  * references to locations in the arrays Booleans, Numbers, and Strings ---
+@@ -424,7 +434,7 @@
+ #define CUR tp->
+ 
+ static void
+-sanity_check(TERMTYPE * tp)
++sanity_check2(TERMTYPE *tp, bool literal)
+ {
+     if (!PRESENT(exit_attribute_mode)) {
+ #ifdef __UNUSED__		/* this casts too wide a net */
+@@ -448,15 +458,17 @@
+     /* we do this check/fix in postprocess_termcap(), but some packagers
+      * prefer to bypass it...
+      */
+-    if (acs_chars == 0
+-	&& enter_alt_charset_mode != 0
+-	&& exit_alt_charset_mode != 0)
+-	acs_chars = strdup(VT_ACSC);
++    if (!literal) {
++	if (acs_chars == 0
++	    && enter_alt_charset_mode != 0
++	    && exit_alt_charset_mode != 0)
++	    acs_chars = strdup(VT_ACSC);
++	ANDMISSING(enter_alt_charset_mode, acs_chars);
++	ANDMISSING(exit_alt_charset_mode, acs_chars);
++    }
+ 
+     /* listed in structure-member order of first argument */
+     PAIRED(enter_alt_charset_mode, exit_alt_charset_mode);
+-    ANDMISSING(enter_alt_charset_mode, acs_chars);
+-    ANDMISSING(exit_alt_charset_mode, acs_chars);
+     ANDMISSING(enter_blink_mode, exit_attribute_mode);
+     ANDMISSING(enter_bold_mode, exit_attribute_mode);
+     PAIRED(exit_ca_mode, enter_ca_mode);
+@@ -479,3 +491,10 @@
+ #endif
+     ANDMISSING(set_color_pair, initialize_pair);
+ }
++
++/* obsolete: 20040705 */
++static void
++sanity_check(TERMTYPE *tp)
++{
++    sanity_check2(tp, FALSE);
++}
+Index: ncurses/tinfo/comp_scan.c
+Prereq:  1.66 
+--- ncurses-5.4-20040208/ncurses/tinfo/comp_scan.c	2003-12-14 00:32:40.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/comp_scan.c	2005-01-15 23:52:31.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -50,7 +51,7 @@
+ #include <term_entry.h>
+ #include <tic.h>
+ 
+-MODULE_ID("$Id: comp_scan.c,v 1.66 2003/12/14 00:32:40 tom Exp $")
++MODULE_ID("$Id: comp_scan.c,v 1.73 2005/01/15 23:52:31 tom Exp $")
+ 
+ /*
+  * Maximum length of string capability we'll accept before raising an error.
+@@ -94,11 +95,193 @@
+ _nc_disable_period = FALSE;	/* used by tic -a option */
+ #endif
+ 
+-static bool end_of_stream(void);
+-static int last_char(void);
+-static int next_char(void);
+-static long stream_pos(void);
+-static void push_back(char c);
++/*****************************************************************************
++ *
++ * Character-stream handling
++ *
++ *****************************************************************************/
++
++#define LEXBUFSIZ	1024
++
++static char *bufptr;		/* otherwise, the input buffer pointer */
++static char *bufstart;		/* start of buffer so we can compute offsets */
++static FILE *yyin;		/* scanner's input file descriptor */
++
++/*
++ *	_nc_reset_input()
++ *
++ *	Resets the input-reading routines.  Used on initialization,
++ *	or after a seek has been done.  Exactly one argument must be
++ *	non-null.
++ */
++
++NCURSES_EXPORT(void)
++_nc_reset_input(FILE *fp, char *buf)
++{
++    pushtype = NO_PUSHBACK;
++    if (pushname != 0)
++	pushname[0] = '\0';
++    yyin = fp;
++    bufstart = bufptr = buf;
++    _nc_curr_file_pos = 0L;
++    if (fp != 0)
++	_nc_curr_line = 0;
++    _nc_curr_col = 0;
++}
++
++/*
++ *	int last_char()
++ *
++ *	Returns the final nonblank character on the current input buffer
++ */
++static int
++last_char(void)
++{
++    size_t len = strlen(bufptr);
++    while (len--) {
++	if (!isspace(UChar(bufptr[len])))
++	    return bufptr[len];
++    }
++    return 0;
++}
++
++/*
++ *	int next_char()
++ *
++ *	Returns the next character in the input stream.  Comments and leading
++ *	white space are stripped.
++ *
++ *	The global state variable 'firstcolumn' is set TRUE if the character
++ *	returned is from the first column of the input line.
++ *
++ *	The global variable _nc_curr_line is incremented for each new line.
++ *	The global variable _nc_curr_file_pos is set to the file offset of the
++ *	beginning of each line.
++ */
++
++static int
++next_char(void)
++{
++    static char *result;
++    static size_t allocated;
++    int the_char;
++
++    if (!yyin) {
++	if (result != 0) {
++	    FreeAndNull(result);
++	    FreeAndNull(pushname);
++	    allocated = 0;
++	}
++	/*
++	 * An string with an embedded null will truncate the input.  This is
++	 * intentional (we don't read binary files here).
++	 */
++	if (bufptr == 0 || *bufptr == '\0')
++	    return (EOF);
++	if (*bufptr == '\n') {
++	    _nc_curr_line++;
++	    _nc_curr_col = 0;
++	} else if (*bufptr == '\t') {
++	    _nc_curr_col = (_nc_curr_col | 7);
++	}
++    } else if (!bufptr || !*bufptr) {
++	/*
++	 * In theory this could be recoded to do its I/O one character at a
++	 * time, saving the buffer space.  In practice, this turns out to be
++	 * quite hard to get completely right.  Try it and see.  If you
++	 * succeed, don't forget to hack push_back() correspondingly.
++	 */
++	size_t used;
++	size_t len;
++
++	do {
++	    bufstart = 0;
++	    used = 0;
++	    do {
++		if (used + (LEXBUFSIZ / 4) >= allocated) {
++		    allocated += (allocated + LEXBUFSIZ);
++		    result = typeRealloc(char, allocated, result);
++		    if (result == 0)
++			return (EOF);
++		}
++		if (used == 0)
++		    _nc_curr_file_pos = ftell(yyin);
++
++		if (fgets(result + used, allocated - used, yyin) != 0) {
++		    bufstart = result;
++		    if (used == 0) {
++			_nc_curr_line++;
++			_nc_curr_col = 0;
++		    }
++		} else {
++		    if (used != 0)
++			strcat(result, "\n");
++		}
++		if ((bufptr = bufstart) != 0) {
++		    used = strlen(bufptr);
++		    while (iswhite(*bufptr)) {
++			if (*bufptr == '\t') {
++			    _nc_curr_col = (_nc_curr_col | 7) + 1;
++			} else {
++			    _nc_curr_col++;
++			}
++			bufptr++;
++		    }
++
++		    /*
++		     * Treat a trailing <cr><lf> the same as a <newline> so we
++		     * can read files on OS/2, etc.
++		     */
++		    if ((len = strlen(bufptr)) > 1) {
++			if (bufptr[len - 1] == '\n'
++			    && bufptr[len - 2] == '\r') {
++			    len--;
++			    bufptr[len - 1] = '\n';
++			    bufptr[len] = '\0';
++			}
++		    }
++		} else {
++		    return (EOF);
++		}
++	    } while (bufptr[len - 1] != '\n');	/* complete a line */
++	} while (result[0] == '#');	/* ignore comments */
++    } else if (*bufptr == '\t') {
++	_nc_curr_col = (_nc_curr_col | 7);
++    }
++
++    first_column = (bufptr == bufstart);
++    if (first_column)
++	had_newline = FALSE;
++
++    _nc_curr_col++;
++    the_char = *bufptr++;
++    return UChar(the_char);
++}
++
++static void
++push_back(char c)
++/* push a character back onto the input stream */
++{
++    if (bufptr == bufstart)
++	_nc_syserr_abort("Can't backspace off beginning of line");
++    *--bufptr = c;
++    _nc_curr_col--;
++}
++
++static long
++stream_pos(void)
++/* return our current character position in the input stream */
++{
++    return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
++}
++
++static bool
++end_of_stream(void)
++/* are we at end of input? */
++{
++    return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
++	    ? TRUE : FALSE);
++}
+ 
+ /* Assume we may be looking at a termcap-style continuation */
+ static inline int
+@@ -161,6 +344,10 @@
+     long number;
+     long token_start;
+     unsigned found;
++#ifdef TRACE
++    int old_line;
++    int old_col;
++#endif
+ 
+     if (pushtype != NO_PUSHBACK) {
+ 	int retval = pushtype;
+@@ -178,6 +365,8 @@
+     }
+ 
+     if (end_of_stream()) {
++	yyin = 0;
++	next_char();		/* frees its allocated memory */
+ 	if (buffer != 0) {
+ 	    FreeAndNull(buffer);
+ 	}
+@@ -194,6 +383,10 @@
+ 
+     ch = eat_escaped_newline(ch);
+ 
++#ifdef TRACE
++    old_line = _nc_curr_line;
++    old_col = _nc_curr_col;
++#endif
+     if (ch == EOF)
+ 	type = EOF;
+     else {
+@@ -219,13 +412,13 @@
+ 	}
+ 
+ 	/* have to make some punctuation chars legal for terminfo */
+-	if (!isalnum(ch)
++	if (!isalnum(UChar(ch))
+ #if NCURSES_EXT_FUNCS
+ 	    && !(ch == '.' && _nc_disable_period)
+ #endif
+ 	    && !strchr(terminfo_punct, (char) ch)) {
+ 	    if (!silent)
+-		_nc_warning("Illegal character (expected alphanumeric or %s) - %s",
++		_nc_warning("Illegal character (expected alphanumeric or %s) - '%s'",
+ 			    terminfo_punct, unctrl((chtype) ch));
+ 	    _nc_panic_mode(separator);
+ 	    goto start_token;
+@@ -234,6 +427,10 @@
+ 	if (buffer == 0)
+ 	    buffer = typeMalloc(char, MAX_ENTRY_SIZE);
+ 
++#ifdef TRACE
++	old_line = _nc_curr_line;
++	old_col = _nc_curr_col;
++#endif
+ 	ptr = buffer;
+ 	*(ptr++) = ch;
+ 
+@@ -247,7 +444,7 @@
+ 	    after_list = 0;
+ 	    while ((ch = next_char()) != '\n') {
+ 		if (ch == EOF) {
+-		    _nc_err_abort(MSG_NO_MEMORY);
++		    _nc_err_abort(MSG_NO_INPUTS);
+ 		} else if (ch == '|') {
+ 		    after_list = ptr;
+ 		    if (after_name == 0)
+@@ -351,7 +548,7 @@
+ 		had_newline = FALSE;
+ 	    }
+ 	    while ((ch = next_char()) != EOF) {
+-		if (!isalnum(ch)) {
++		if (!isalnum(UChar(ch))) {
+ 		    if (_nc_syntax == SYN_TERMINFO) {
+ 			if (ch != '_')
+ 			    break;
+@@ -416,7 +613,7 @@
+ 		/* just to get rid of the compiler warning */
+ 		type = UNDEF;
+ 		if (!silent)
+-		    _nc_warning("Illegal character - %s", unctrl((chtype) ch));
++		    _nc_warning("Illegal character - '%s'", unctrl((chtype) ch));
+ 	    }
+ 	}			/* end else (first_column == FALSE) */
+     }				/* end else (ch != EOF) */
+@@ -427,6 +624,11 @@
+     if (dot_flag == TRUE)
+ 	DEBUG(8, ("Commented out "));
+ 
++    if (_nc_tracing >= DEBUG_LEVEL(8)) {
++	_tracef("parsed %d.%d to %d.%d",
++		old_line, old_col,
++		_nc_curr_line, _nc_curr_col);
++    }
+     if (_nc_tracing >= DEBUG_LEVEL(7)) {
+ 	switch (type) {
+ 	case BOOLEAN:
+@@ -471,8 +673,9 @@
+ 	type = _nc_get_token(silent);
+ 
+     DEBUG(3, ("token: `%s', class %d",
+-	      _nc_curr_token.tk_name != 0 ? _nc_curr_token.tk_name :
+-	      "<null>",
++	      ((_nc_curr_token.tk_name != 0)
++	       ? _nc_curr_token.tk_name
++	       : "<null>"),
+ 	      type));
+ 
+     return (type);
+@@ -497,7 +700,7 @@
+  *
+  */
+ 
+-NCURSES_EXPORT(char)
++NCURSES_EXPORT(int)
+ _nc_trans_string(char *ptr, char *last)
+ {
+     int count = 0;
+@@ -518,7 +721,7 @@
+ 		_nc_err_abort(MSG_NO_INPUTS);
+ 
+ 	    if (!(is7bits(ch) && isprint(ch))) {
+-		_nc_warning("Illegal ^ character - %s", unctrl(ch));
++		_nc_warning("Illegal ^ character - '%s'", unctrl(ch));
+ 	    }
+ 	    if (ch == '?') {
+ 		*(ptr++) = '\177';
+@@ -613,7 +816,7 @@
+ 		    continue;
+ 
+ 		default:
+-		    _nc_warning("Illegal character %s in \\ sequence",
++		    _nc_warning("Illegal character '%s' in \\ sequence",
+ 				unctrl(ch));
+ 		    /* FALLTHRU */
+ 		case '|':
+@@ -623,13 +826,21 @@
+ 	}
+ 	/* end else if (ch == '\\') */
+ 	else if (ch == '\n' && (_nc_syntax == SYN_TERMINFO)) {
+-	    /* newlines embedded in a terminfo string are ignored */
++	    /*
++	     * Newlines embedded in a terminfo string are ignored, provided
++	     * that the next line begins with whitespace.
++	     */
+ 	    ignored = TRUE;
+ 	} else {
+ 	    *(ptr++) = (char) ch;
+ 	}
+ 
+ 	if (!ignored) {
++	    if (_nc_curr_col <= 1) {
++		push_back(ch);
++		ch = '\n';
++		break;
++	    }
+ 	    last_ch = ch;
+ 	    count++;
+ 	}
+@@ -687,172 +898,3 @@
+ 	    return;
+     }
+ }
+-
+-/*****************************************************************************
+- *
+- * Character-stream handling
+- *
+- *****************************************************************************/
+-
+-#define LEXBUFSIZ	1024
+-
+-static char *bufptr;		/* otherwise, the input buffer pointer */
+-static char *bufstart;		/* start of buffer so we can compute offsets */
+-static FILE *yyin;		/* scanner's input file descriptor */
+-
+-/*
+- *	_nc_reset_input()
+- *
+- *	Resets the input-reading routines.  Used on initialization,
+- *	or after a seek has been done.  Exactly one argument must be
+- *	non-null.
+- */
+-
+-NCURSES_EXPORT(void)
+-_nc_reset_input(FILE *fp, char *buf)
+-{
+-    pushtype = NO_PUSHBACK;
+-    if (pushname != 0)
+-	pushname[0] = '\0';
+-    yyin = fp;
+-    bufstart = bufptr = buf;
+-    _nc_curr_file_pos = 0L;
+-    if (fp != 0)
+-	_nc_curr_line = 0;
+-    _nc_curr_col = 0;
+-}
+-
+-/*
+- *	int last_char()
+- *
+- *	Returns the final nonblank character on the current input buffer
+- */
+-static int
+-last_char(void)
+-{
+-    size_t len = strlen(bufptr);
+-    while (len--) {
+-	if (!isspace(UChar(bufptr[len])))
+-	    return bufptr[len];
+-    }
+-    return 0;
+-}
+-
+-/*
+- *	int next_char()
+- *
+- *	Returns the next character in the input stream.  Comments and leading
+- *	white space are stripped.
+- *
+- *	The global state variable 'firstcolumn' is set TRUE if the character
+- *	returned is from the first column of the input line.
+- *
+- *	The global variable _nc_curr_line is incremented for each new line.
+- *	The global variable _nc_curr_file_pos is set to the file offset of the
+- *	beginning of each line.
+- */
+-
+-static int
+-next_char(void)
+-{
+-    if (!yyin) {
+-	/*
+-	 * An string with an embedded null will truncate the input.  This is
+-	 * intentional (we don't read binary files here).
+-	 */
+-	if (*bufptr == '\0')
+-	    return (EOF);
+-	if (*bufptr == '\n') {
+-	    _nc_curr_line++;
+-	    _nc_curr_col = 0;
+-	}
+-    } else if (!bufptr || !*bufptr) {
+-	/*
+-	 * In theory this could be recoded to do its I/O one character at a
+-	 * time, saving the buffer space.  In practice, this turns out to be
+-	 * quite hard to get completely right.  Try it and see.  If you
+-	 * succeed, don't forget to hack push_back() correspondingly.
+-	 */
+-	static char *result;
+-	static size_t allocated;
+-	size_t used;
+-	size_t len;
+-
+-	do {
+-	    bufstart = 0;
+-	    used = 0;
+-	    do {
+-		if (used + (LEXBUFSIZ / 4) >= allocated) {
+-		    allocated += (allocated + LEXBUFSIZ);
+-		    result = typeRealloc(char, allocated, result);
+-		    if (result == 0)
+-			return (EOF);
+-		}
+-		if (used == 0)
+-		    _nc_curr_file_pos = ftell(yyin);
+-
+-		if (fgets(result + used, allocated - used, yyin) != 0) {
+-		    bufstart = result;
+-		    if (used == 0) {
+-			_nc_curr_line++;
+-			_nc_curr_col = 0;
+-		    }
+-		} else {
+-		    if (used != 0)
+-			strcat(result, "\n");
+-		}
+-		if ((bufptr = bufstart) != 0) {
+-		    used = strlen(bufptr);
+-		    while (iswhite(*bufptr))
+-			bufptr++;
+-
+-		    /*
+-		     * Treat a trailing <cr><lf> the same as a <newline> so we
+-		     * can read files on OS/2, etc.
+-		     */
+-		    if ((len = strlen(bufptr)) > 1) {
+-			if (bufptr[len - 1] == '\n'
+-			    && bufptr[len - 2] == '\r') {
+-			    len--;
+-			    bufptr[len - 1] = '\n';
+-			    bufptr[len] = '\0';
+-			}
+-		    }
+-		} else {
+-		    return (EOF);
+-		}
+-	    } while (bufptr[len - 1] != '\n');	/* complete a line */
+-	} while (result[0] == '#');	/* ignore comments */
+-    }
+-
+-    first_column = (bufptr == bufstart);
+-    if (first_column)
+-	had_newline = FALSE;
+-
+-    _nc_curr_col++;
+-    return (*bufptr++);
+-}
+-
+-static void
+-push_back(char c)
+-/* push a character back onto the input stream */
+-{
+-    if (bufptr == bufstart)
+-	_nc_syserr_abort("Can't backspace off beginning of line");
+-    *--bufptr = c;
+-}
+-
+-static long
+-stream_pos(void)
+-/* return our current character position in the input stream */
+-{
+-    return (yyin ? ftell(yyin) : (bufptr ? bufptr - bufstart : 0));
+-}
+-
+-static bool
+-end_of_stream(void)
+-/* are we at end of input? */
+-{
+-    return ((yyin ? feof(yyin) : (bufptr && *bufptr == '\0'))
+-	    ? TRUE : FALSE);
+-}
+Index: ncurses/tinfo/init_keytry.c
+Prereq:  1.5 
+--- ncurses-5.4-20040208/ncurses/tinfo/init_keytry.c	2000-12-10 02:55:07.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/init_keytry.c	2005-01-22 21:17:40.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1999,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1999-2000,2005 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 @@
+ 			/* cursor_visible,cursor_normal,cursor_invisible */
+ #include <tic.h>		/* struct tinfo_fkeys */
+ 
+-MODULE_ID("$Id: init_keytry.c,v 1.5 2000/12/10 02:55:07 tom Exp $")
++MODULE_ID("$Id: init_keytry.c,v 1.6 2005/01/22 21:17:40 tom Exp $")
+ 
+ /*
+ **      _nc_init_keytry()
+@@ -69,12 +69,14 @@
+      * mouse_activate() (which will call keyok()) are first called.
+      */
+ 
+-    for (n = 0; _nc_tinfo_fkeys[n].code; n++)
+-	if (_nc_tinfo_fkeys[n].offset < STRCOUNT)
+-	    _nc_add_to_try(&(SP->_keytry),
+-			   CUR Strings[_nc_tinfo_fkeys[n].offset],
+-			   _nc_tinfo_fkeys[n].code);
++    if (SP != 0) {
++	for (n = 0; _nc_tinfo_fkeys[n].code; n++)
++	    if (_nc_tinfo_fkeys[n].offset < STRCOUNT)
++		_nc_add_to_try(&(SP->_keytry),
++			       CUR Strings[_nc_tinfo_fkeys[n].offset],
++			       _nc_tinfo_fkeys[n].code);
+ #ifdef TRACE
+-    _nc_trace_tries(SP->_keytry);
++	_nc_trace_tries(SP->_keytry);
+ #endif
++    }
+ }
+Index: ncurses/tinfo/lib_acs.c
+Prereq:  1.25 
+--- ncurses-5.4-20040208/ncurses/tinfo/lib_acs.c	2002-12-28 16:26:46.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/lib_acs.c	2004-10-16 15:42:40.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2002,2004 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,12 +29,13 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ #include <curses.priv.h>
+ #include <term.h>		/* ena_acs, acs_chars */
+ 
+-MODULE_ID("$Id: lib_acs.c,v 1.25 2002/12/28 16:26:46 tom Exp $")
++MODULE_ID("$Id: lib_acs.c,v 1.27 2004/10/16 15:42:40 tom Exp $")
+ 
+ #if BROKEN_LINKER
+ NCURSES_EXPORT_VAR(chtype *)
+@@ -70,6 +71,7 @@
+ 	for (j = 1; j < ACS_LEN; ++j) {
+ 	    real_map[j] = 0;
+ 	    fake_map[j] = A_ALTCHARSET | j;
++	    SP->_screen_acs_map[j] = FALSE;
+ 	}
+     } else {
+ 	for (j = 1; j < ACS_LEN; ++j) {
+@@ -119,6 +121,9 @@
+     if (_nc_unicode_locale() && _nc_locale_breaks_acs()) {
+ 	acs_chars = NULL;
+ 	ena_acs = NULL;
++	enter_alt_charset_mode = NULL;
++	exit_alt_charset_mode = NULL;
++	set_attributes = NULL;
+     }
+ #endif
+ 
+@@ -134,6 +139,8 @@
+ 	while (i + 1 < length) {
+ 	    if (acs_chars[i] != 0 && UChar(acs_chars[i]) < ACS_LEN) {
+ 		real_map[UChar(acs_chars[i])] = UChar(acs_chars[i + 1]) | A_ALTCHARSET;
++		if (SP != 0)
++		    SP->_screen_acs_map[UChar(acs_chars[i])] = TRUE;
+ 	    }
+ 	    i += 2;
+ 	}
+@@ -152,6 +159,10 @@
+ 	    }
+ 	}
+ 	show[m] = 0;
++	if (acs_chars == NULL || strcmp(acs_chars, show))
++	    _tracef("%s acs_chars %s",
++		    (acs_chars == NULL) ? "NULL" : "READ",
++		    _nc_visbuf(acs_chars));
+ 	_tracef("%s acs_chars %s",
+ 		(acs_chars == NULL)
+ 		? "NULL"
+Index: ncurses/tinfo/lib_data.c
+Prereq:  1.16 
+--- ncurses-5.4-20040208/ncurses/tinfo/lib_data.c	2000-12-10 02:55:07.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/lib_data.c	2005-01-22 17:39:22.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,1999,2000 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2000,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -40,18 +41,15 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_data.c,v 1.16 2000/12/10 02:55:07 tom Exp $")
++MODULE_ID("$Id: lib_data.c,v 1.17 2005/01/22 17:39:22 tom Exp $")
+ 
+ /*
+  * OS/2's native linker complains if we don't initialize public data when
+  * constructing a dll (reported by J.J.G.Ripoll).
+  */
+-NCURSES_EXPORT_VAR(WINDOW *)
+-stdscr = 0;
+-NCURSES_EXPORT_VAR(WINDOW *)
+-curscr = 0;
+-NCURSES_EXPORT_VAR(WINDOW *)
+-newscr = 0;
++NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0;
++NCURSES_EXPORT_VAR(WINDOW *) curscr = 0;
++NCURSES_EXPORT_VAR(WINDOW *) newscr = 0;
+ 
+ NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
+ 
+@@ -66,7 +64,7 @@
+  * module coupling that increases the size of the executable.
+  */
+ #if BROKEN_LINKER
+-     static SCREEN *my_screen;
++static SCREEN *my_screen;
+ 
+ NCURSES_EXPORT(SCREEN *)
+ _nc_screen(void)
+@@ -81,11 +79,11 @@
+ }
+ 
+ NCURSES_EXPORT(void)
+-_nc_set_screen(SCREEN * sp)
++_nc_set_screen(SCREEN *sp)
+ {
+     my_screen = sp;
+ }
+ 
+ #else
+-NCURSES_EXPORT_VAR(SCREEN *) SP = NULL;		/* Some linkers require initialized data... */
++NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
+ #endif
+Index: ncurses/tinfo/lib_kernel.c
+Prereq:  1.23 
+--- ncurses-5.4-20040208/ncurses/tinfo/lib_kernel.c	2003-01-26 00:24:53.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/lib_kernel.c	2004-05-08 17:11:21.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2000,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,13 +48,13 @@
+ #include <curses.priv.h>
+ #include <term.h>		/* cur_term */
+ 
+-MODULE_ID("$Id: lib_kernel.c,v 1.23 2003/01/26 00:24:53 tom Exp $")
++MODULE_ID("$Id: lib_kernel.c,v 1.24 2004/05/08 17:11:21 tom Exp $")
+ 
+ static int
+ _nc_vdisable(void)
+ {
+     int value = -1;
+-#if defined(_POSIX_VDISABLE) && defined(HAVE_UNISTD_H)
++#if defined(_POSIX_VDISABLE) && HAVE_UNISTD_H
+     value = _POSIX_VDISABLE;
+ #endif
+ #if defined(_PC_VDISABLE)
+Index: ncurses/tinfo/lib_options.c
+Prereq:  1.47 
+--- ncurses-5.4-20040208/ncurses/tinfo/lib_options.c	2003-10-25 19:51:38.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/lib_options.c	2005-01-22 21:13:34.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2005 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,7 +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-2003               *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -43,7 +43,7 @@
+ 
+ #include <term.h>
+ 
+-MODULE_ID("$Id: lib_options.c,v 1.47 2003/10/25 19:51:38 tom Exp $")
++MODULE_ID("$Id: lib_options.c,v 1.48 2005/01/22 21:13:34 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ idlok(WINDOW *win, bool flag)
+@@ -159,43 +159,44 @@
+ NCURSES_EXPORT(int)
+ curs_set(int vis)
+ {
+-    int cursor = SP->_cursor;
++    int result = ERR;
+ 
+     T((T_CALLED("curs_set(%d)"), vis));
++    if (SP != 0 && vis >= 0 && vis <= 2) {
++	int cursor = SP->_cursor;
+ 
+-    if (vis < 0 || vis > 2)
+-	returnCode(ERR);
+-
+-    if (vis == cursor)
+-	returnCode(cursor);
+-
+-    switch (vis) {
+-    case 2:
+-	if (cursor_visible) {
+-	    TPUTS_TRACE("cursor_visible");
+-	    putp(cursor_visible);
+-	} else
+-	    returnCode(ERR);
+-	break;
+-    case 1:
+-	if (cursor_normal) {
+-	    TPUTS_TRACE("cursor_normal");
+-	    putp(cursor_normal);
+-	} else
+-	    returnCode(ERR);
+-	break;
+-    case 0:
+-	if (cursor_invisible) {
+-	    TPUTS_TRACE("cursor_invisible");
+-	    putp(cursor_invisible);
+-	} else
+-	    returnCode(ERR);
+-	break;
++	if (vis == cursor) {
++	    result = cursor;
++	} else {
++	    result = (cursor == -1 ? 1 : cursor);
++	    switch (vis) {
++	    case 2:
++		if (cursor_visible) {
++		    TPUTS_TRACE("cursor_visible");
++		    putp(cursor_visible);
++		} else
++		    result = ERR;
++		break;
++	    case 1:
++		if (cursor_normal) {
++		    TPUTS_TRACE("cursor_normal");
++		    putp(cursor_normal);
++		} else
++		    result = ERR;
++		break;
++	    case 0:
++		if (cursor_invisible) {
++		    TPUTS_TRACE("cursor_invisible");
++		    putp(cursor_invisible);
++		} else
++		    result = ERR;
++		break;
++	    }
++	    SP->_cursor = vis;
++	    _nc_flush();
++	}
+     }
+-    SP->_cursor = vis;
+-    _nc_flush();
+-
+-    returnCode(cursor == -1 ? 1 : cursor);
++    returnCode(result);
+ }
+ 
+ NCURSES_EXPORT(int)
+@@ -258,10 +259,12 @@
+ 	_nc_flush();
+     }
+ 
+-    if (flag && SP != 0 && !SP->_tried) {
+-	_nc_init_keytry();
+-	SP->_tried = TRUE;
++    if (SP != 0) {
++	if (flag && !SP->_tried) {
++	    _nc_init_keytry();
++	    SP->_tried = TRUE;
++	}
++	SP->_keypad_on = flag;
+     }
+-    SP->_keypad_on = flag;
+     return (OK);
+ }
+Index: ncurses/tinfo/lib_setup.c
+Prereq:  1.79 
+--- ncurses-5.4-20040208/ncurses/tinfo/lib_setup.c	2003-12-27 18:24:26.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/lib_setup.c	2005-03-12 19:41:45.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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            *
+@@ -47,9 +47,13 @@
+ #define _POSIX_SOURCE
+ #endif
+ 
++#if HAVE_LOCALE_H
++#include <locale.h>
++#endif
++
+ #include <term.h>		/* lines, columns, cur_term */
+ 
+-MODULE_ID("$Id: lib_setup.c,v 1.79 2003/12/27 18:24:26 tom Exp $")
++MODULE_ID("$Id: lib_setup.c,v 1.88 2005/03/12 19:41:45 tom Exp $")
+ 
+ /****************************************************************************
+  *
+@@ -73,6 +77,10 @@
+ # include <sys/ptem.h>
+ #endif
+ 
++#if HAVE_LANGINFO_CODESET
++#include <langinfo.h>
++#endif
++
+ /*
+  * SCO defines TIOCGSIZE and the corresponding struct.  Other systems (SunOS,
+  * Solaris, IRIX) define TIOCGWINSZ and struct winsize.
+@@ -205,11 +213,24 @@
+ NCURSES_EXPORT(void)
+ _nc_update_screensize(void)
+ {
+-    int my_lines, my_cols;
++    int old_lines = lines;
++    int new_lines;
++    int old_cols = columns;
++    int new_cols;
++
++    _nc_get_screensize(&new_lines, &new_cols);
+ 
+-    _nc_get_screensize(&my_lines, &my_cols);
+-    if (SP != 0 && SP->_resize != 0)
+-	SP->_resize(my_lines, my_cols);
++    /*
++     * See is_term_resized() and resizeterm().
++     * We're doing it this way because those functions belong to the upper
++     * ncurses library, while this resides in the lower terminfo library.
++     */
++    if (SP != 0
++	&& SP->_resize != 0) {
++	if ((new_lines != old_lines) || (new_cols != old_cols))
++	    SP->_resize(new_lines, new_cols);
++	SP->_sig_winch = FALSE;
++    }
+ }
+ #endif
+ 
+@@ -237,7 +258,7 @@
+ 
+ #if USE_DATABASE || USE_TERMCAP
+ static int
+-grab_entry(const char *const tn, TERMTYPE * const tp)
++grab_entry(const char *const tn, TERMTYPE *const tp)
+ /* return 1 if entry found, 0 if not found, -1 if database not accessible */
+ {
+ #if USE_DATABASE
+@@ -318,18 +339,27 @@
+ }
+ 
+ /*
+- * Check if we are running in a UTF-8 locale.
++ * Find the locale which is in effect.
+  */
+ NCURSES_EXPORT(char *)
+ _nc_get_locale(void)
+ {
+     char *env;
++#if HAVE_LOCALE_H
++    /*
++     * This is preferable to using getenv() since it ensures that we are using
++     * the locale which was actually initialized by the application.
++     */
++    env = setlocale(LC_CTYPE, 0);
++#else
+     if (((env = getenv("LC_ALL")) != 0 && *env != '\0')
+ 	|| ((env = getenv("LC_CTYPE")) != 0 && *env != '\0')
+ 	|| ((env = getenv("LANG")) != 0 && *env != '\0')) {
+-	return env;
++	;
+     }
+-    return 0;
++#endif
++    T(("_nc_get_locale %s", _nc_visbuf(env)));
++    return env;
+ }
+ 
+ /*
+@@ -338,14 +368,26 @@
+ NCURSES_EXPORT(int)
+ _nc_unicode_locale(void)
+ {
++    int result = 0;
++#if HAVE_LANGINFO_CODESET
++    char *env = nl_langinfo(CODESET);
++    result = !strcmp(env, "UTF-8");
++    T(("_nc_unicode_locale(%s) ->%d", env, result));
++#else
+     char *env = _nc_get_locale();
+     if (env != 0) {
+-	if (strstr(env, ".UTF-8") != 0)
+-	    return 1;
++	if (strstr(env, ".UTF-8") != 0) {
++	    result = 1;
++	    T(("_nc_unicode_locale(%s) ->%d", env, result));
++	}
+     }
+-    return 0;
++#endif
++    return result;
+ }
+ 
++#define CONTROL_N(s) ((s) != 0 && strstr(s, "\016") != 0)
++#define CONTROL_O(s) ((s) != 0 && strstr(s, "\017") != 0)
++
+ /*
+  * Check for known broken cases where a UTF-8 locale breaks the alternate
+  * character set.
+@@ -353,30 +395,33 @@
+ NCURSES_EXPORT(int)
+ _nc_locale_breaks_acs(void)
+ {
+-    char *env = getenv("TERM");
+-    if (env != 0) {
++    char *env;
++
++    if ((env = getenv("NCURSES_NO_UTF8_ACS")) != 0) {
++	return atoi(env);
++    } else if ((env = getenv("TERM")) != 0) {
+ 	if (strstr(env, "linux"))
+ 	    return 1;		/* always broken */
+ 	if (strstr(env, "screen") != 0
+ 	    && ((env = getenv("TERMCAP")) != 0
+ 		&& strstr(env, "screen") != 0)
+ 	    && strstr(env, "hhII00") != 0) {
+-	    return 1;
++	    if (CONTROL_N(enter_alt_charset_mode) ||
++		CONTROL_O(enter_alt_charset_mode) ||
++		CONTROL_N(set_attributes) ||
++		CONTROL_O(set_attributes))
++		return 1;
+ 	}
+     }
+     return 0;
+ }
+ 
+ /*
+- *	setupterm(termname, Filedes, errret)
+- *
+- *	Find and read the appropriate object file for the terminal
+- *	Make cur_term point to the structure.
+- *
++ * This entrypoint is called from tgetent() to allow special a case of reusing
++ * the same TERMINAL data (see comment).
+  */
+-
+ NCURSES_EXPORT(int)
+-setupterm(NCURSES_CONST char *tname, int Filedes, int *errret)
++_nc_setupterm(NCURSES_CONST char *tname, int Filedes, int *errret, bool reuse)
+ {
+     int status;
+ 
+@@ -419,7 +464,8 @@
+      * however applications that are working around the problem will still work
+      * properly with this feature).
+      */
+-    if (cur_term != 0
++    if (reuse
++	&& cur_term != 0
+ 	&& cur_term->Filedes == Filedes
+ 	&& cur_term->_termname != 0
+ 	&& !strcmp(cur_term->_termname, tname)
+@@ -500,3 +546,17 @@
+     }
+     returnCode(OK);
+ }
++
++/*
++ *	setupterm(termname, Filedes, errret)
++ *
++ *	Find and read the appropriate object file for the terminal
++ *	Make cur_term point to the structure.
++ *
++ */
++
++NCURSES_EXPORT(int)
++setupterm(NCURSES_CONST char *tname, int Filedes, int *errret)
++{
++    return _nc_setupterm(tname, Filedes, errret, FALSE);
++}
+Index: ncurses/tinfo/lib_termcap.c
+Prereq:  1.44 
+--- ncurses-5.4-20040208/ncurses/tinfo/lib_termcap.c	2003-05-24 21:10:28.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/lib_termcap.c	2005-02-26 23:25:53.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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                 *
+  *                                                                          *
+  * some of the code in here was contributed by:                             *
+  * Magnus Bengtsson, d6mbeng@dtek.chalmers.se (Nov'93)                      *
+@@ -43,7 +44,7 @@
+ 
+ #include <term_entry.h>
+ 
+-MODULE_ID("$Id: lib_termcap.c,v 1.44 2003/05/24 21:10:28 tom Exp $")
++MODULE_ID("$Id: lib_termcap.c,v 1.48 2005/02/26 23:25:53 tom Exp $")
+ 
+ #define CSI       233
+ #define ESC       033		/* ^[ */
+@@ -53,7 +54,7 @@
+ NCURSES_EXPORT_VAR(char *) UP = 0;
+ NCURSES_EXPORT_VAR(char *) BC = 0;
+ 
+-static char *fix_me = 0;
++static char *fix_me = 0;	/* this holds the filtered sgr0 string */
+ 
+ static char *
+ set_attribute_9(int flag)
+@@ -87,12 +88,45 @@
+     return s;
+ }
+ 
++/*
++ * Improve similar_sgr a little by moving the attr-string from the beginning
++ * to the end of the s-string.
++ */
++static bool
++rewrite_sgr(char *s, char *attr)
++{
++    if (s != 0) {
++	if (attr != 0) {
++	    int len_s = strlen(s);
++	    int len_a = strlen(attr);
++
++	    if (len_s > len_a && !strncmp(attr, s, len_a)) {
++		int n;
++		TR(TRACE_DATABASE, ("rewrite:\n\t%s", s));
++		for (n = 0; n < len_s - len_a; ++n) {
++		    s[n] = s[n + len_a];
++		}
++		strcpy(s + n, attr);
++		TR(TRACE_DATABASE, ("to:\n\t%s", s));
++	    }
++	}
++	return TRUE;
++    }
++    return FALSE;		/* oops */
++}
++
+ static bool
+ similar_sgr(char *a, char *b)
+ {
++    bool result = FALSE;
+     int csi_a = is_csi(a);
+     int csi_b = is_csi(b);
++    unsigned len_a;
++    unsigned len_b;
+ 
++    TR(TRACE_DATABASE, ("similar_sgr:\n\t%s\n\t%s",
++			_nc_visbuf2(1, a),
++			_nc_visbuf2(2, b)));
+     if (csi_a != 0 && csi_b != 0 && csi_a == csi_b) {
+ 	a += csi_a;
+ 	b += csi_b;
+@@ -101,7 +135,29 @@
+ 	    b = skip_zero(b);
+ 	}
+     }
+-    return strcmp(a, b) == 0;
++    len_a = strlen(a);
++    len_b = strlen(b);
++    if (len_a && len_b) {
++	if (len_a > len_b)
++	    result = (strncmp(a, b, len_b) == 0);
++	else
++	    result = (strncmp(a, b, len_a) == 0);
++    }
++    TR(TRACE_DATABASE, ("...similar_sgr: %d\n\t%s\n\t%s", result,
++			_nc_visbuf2(1, a),
++			_nc_visbuf2(2, b)));
++    return result;
++}
++
++static unsigned
++chop_out(char *string, unsigned i, unsigned j)
++{
++    TR(TRACE_DATABASE, ("chop_out %d..%d from %s", i, j, _nc_visbuf(string)));
++    while (string[j] != '\0') {
++	string[i++] = string[j++];
++    }
++    string[i] = '\0';
++    return i;
+ }
+ 
+ /***************************************************************************
+@@ -124,14 +180,15 @@
+ {
+     int errcode;
+ 
++    START_TRACE();
+     T((T_CALLED("tgetent()")));
+ 
+-    setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode);
++    _nc_setupterm((NCURSES_CONST char *) name, STDOUT_FILENO, &errcode, TRUE);
+ 
+     PC = 0;
+     UP = 0;
+     BC = 0;
+-    fix_me = 0;
++    fix_me = 0;			/* don't free it - application may still use */
+ 
+     if (errcode == 1) {
+ 
+@@ -157,56 +214,94 @@
+ 	 */
+ 	if (exit_attribute_mode != 0
+ 	    && set_attributes != 0) {
++	    bool found = FALSE;
+ 	    char *on = set_attribute_9(1);
+ 	    char *off = set_attribute_9(0);
++	    char *end = strdup(exit_attribute_mode);
+ 	    char *tmp;
+ 	    size_t i, j, k;
+ 
+-	    if (similar_sgr(off, exit_attribute_mode)
+-		&& !similar_sgr(off, on)) {
++	    TR(TRACE_DATABASE, ("checking if we can trim sgr0 based on sgr"));
++	    TR(TRACE_DATABASE, ("sgr0       %s", _nc_visbuf(end)));
++	    TR(TRACE_DATABASE, ("sgr(9:off) %s", _nc_visbuf(off)));
++	    TR(TRACE_DATABASE, ("sgr(9:on)  %s", _nc_visbuf(on)));
++
++	    if (!rewrite_sgr(on, enter_alt_charset_mode)
++		|| !rewrite_sgr(off, exit_alt_charset_mode)
++		|| !rewrite_sgr(end, exit_alt_charset_mode)) {
++		FreeIfNeeded(on);
++		FreeIfNeeded(off);
++		FreeIfNeeded(end);
++	    } else if (similar_sgr(off, end)
++		       && !similar_sgr(off, on)) {
+ 		TR(TRACE_DATABASE, ("adjusting sgr0 : %s", _nc_visbuf(off)));
+ 		FreeIfNeeded(fix_me);
+ 		fix_me = off;
+-		for (i = 0; off[i] != '\0'; ++i) {
+-		    if (on[i] != off[i]) {
+-			j = strlen(off);
+-			k = strlen(on);
+-			while (j != 0
+-			       && k != 0
+-			       && off[j - 1] == on[k - 1]) {
+-			    --j, --k;
+-			}
+-			while (off[j] != '\0') {
+-			    off[i++] = off[j++];
++		/*
++		 * If rmacs is a substring of sgr(0), remove that chunk.
++		 */
++		if (exit_alt_charset_mode != 0) {
++		    j = strlen(off);
++		    k = strlen(exit_alt_charset_mode);
++		    if (j > k) {
++			for (i = 0; i <= (j - k); ++i) {
++			    if (!memcmp(exit_alt_charset_mode, off + i, k)) {
++				found = TRUE;
++				chop_out(off, i, i + k);
++				break;
++			    }
+ 			}
+-			off[i] = '\0';
+-			break;
+ 		    }
+ 		}
+-		/* SGR 10 would reset to normal font */
+-		if ((i = is_csi(off)) != 0
+-		    && off[strlen(off) - 1] == 'm') {
+-		    tmp = skip_zero(off + i);
+-		    if (tmp[0] == '1'
+-			&& skip_zero(tmp + 1) != tmp + 1) {
+-			i = tmp - off;
+-			if (off[i - 1] == ';')
+-			    i--;
+-			j = skip_zero(tmp + 1) - off;
+-			while (off[j] != '\0') {
+-			    off[i++] = off[j++];
++		/*
++		 * SGR 10 would reset to normal font.
++		 */
++		if (!found) {
++		    if ((i = is_csi(off)) != 0
++			&& off[strlen(off) - 1] == 'm') {
++			TR(TRACE_DATABASE, ("looking for SGR 10 in %s",
++					    _nc_visbuf(off)));
++			tmp = skip_zero(off + i);
++			if (tmp[0] == '1'
++			    && skip_zero(tmp + 1) != tmp + 1) {
++			    i = tmp - off;
++			    if (off[i - 1] == ';')
++				i--;
++			    j = skip_zero(tmp + 1) - off;
++			    i = chop_out(off, i, j);
++			    found = TRUE;
+ 			}
+-			off[i] = '\0';
+ 		    }
+ 		}
+-		TR(TRACE_DATABASE, ("...adjusted me : %s", _nc_visbuf(fix_me)));
++		if (!found
++		    && (tmp = strstr(end, off)) != 0) {
++		    i = tmp - end;
++		    j = strlen(off);
++		    tmp = strdup(end);
++		    chop_out(tmp, i, j);
++		    free(off);
++		    fix_me = tmp;
++		}
++		TR(TRACE_DATABASE, ("...adjusted sgr0 : %s", _nc_visbuf(fix_me)));
+ 		if (!strcmp(fix_me, exit_attribute_mode)) {
+ 		    TR(TRACE_DATABASE, ("...same result, discard"));
+ 		    free(fix_me);
+ 		    fix_me = 0;
+ 		}
++	    } else {
++		/*
++		 * Either the sgr does not reference alternate character set,
++		 * or it is incorrect.  That's too hard to decide right now.
++		 */
++		free(off);
+ 	    }
++	    free(end);
+ 	    free(on);
++	} else {
++	    /*
++	     * Possibly some applications are confused if sgr0 contains rmacs,
++	     * but that would be a different bug report -TD
++	     */
+ 	}
+ 
+ 	(void) baudrate();	/* sets ospeed as a side-effect */
+Index: ncurses/tinfo/name_match.c
+Prereq:  1.12 
+--- ncurses-5.4-20040208/ncurses/tinfo/name_match.c	2002-08-31 21:48:41.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/name_match.c	2005-01-22 21:47:25.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1999,2000,2001 Free Software Foundation, Inc.              *
++ * Copyright (c) 1999-2004,2005 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 @@
+ #include <term.h>
+ #include <tic.h>
+ 
+-MODULE_ID("$Id: name_match.c,v 1.12 2002/08/31 21:48:41 Philippe.Blain Exp $")
++MODULE_ID("$Id: name_match.c,v 1.15 2005/01/22 21:47:25 tom Exp $")
+ 
+ /*
+  *	_nc_first_name(char *names)
+@@ -49,6 +49,14 @@
+     static char *buf;
+     register unsigned n;
+ 
++#if NO_LEAKS
++    if (sp == 0) {
++	if (buf != 0)
++	    FreeAndNull(buf);	/* for leak-testing */
++	return 0;
++    }
++#endif
++
+     if (buf == 0)
+ 	buf = typeMalloc(char, MAX_NAME_SIZE + 1);
+     for (n = 0; n < MAX_NAME_SIZE; n++) {
+@@ -67,8 +75,7 @@
+  */
+ 
+ NCURSES_EXPORT(int)
+-_nc_name_match
+-(const char *const namelst, const char *const name, const char *const delim)
++_nc_name_match(const char *const namelst, const char *const name, const char *const delim)
+ {
+     const char *s, *d, *t;
+     int code, found;
+Index: ncurses/tinfo/parse_entry.c
+Prereq:  1.60 
+--- ncurses-5.4-20040208/ncurses/tinfo/parse_entry.c	2003-11-08 21:57:09.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/parse_entry.c	2004-05-01 21:33:25.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,7 +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-2003               *
++ *     and: Thomas E. Dickey                        1996-2004               *
+  ****************************************************************************/
+ 
+ /*
+@@ -48,7 +48,7 @@
+ #include <tic.h>
+ #include <term_entry.h>
+ 
+-MODULE_ID("$Id: parse_entry.c,v 1.60 2003/11/08 21:57:09 tom Exp $")
++MODULE_ID("$Id: parse_entry.c,v 1.61 2004/05/01 21:33:25 tom Exp $")
+ 
+ #ifdef LINT
+ static short const parametrized[] =
+@@ -232,7 +232,11 @@
+      * 2-character name, but was instead the first alias after that.
+      */
+     ptr = _nc_curr_token.tk_name;
+-    if (_nc_syntax == SYN_TERMCAP) {
++    if (_nc_syntax == SYN_TERMCAP
++#if NCURSES_XNAMES
++	&& !_nc_user_definable
++#endif
++	) {
+ 	if (ptr[2] == '|') {
+ 	    ptr += 3;
+ 	    _nc_curr_token.tk_name[2] = '\0';
+Index: ncurses/tinfo/read_entry.c
+Prereq:  1.79 
+--- ncurses-5.4-20040208/ncurses/tinfo/read_entry.c	2004-01-11 01:57:05.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/read_entry.c	2004-09-25 23:00:25.000000000 +0000
+@@ -42,12 +42,14 @@
+ #include <tic.h>
+ #include <term_entry.h>
+ 
+-MODULE_ID("$Id: read_entry.c,v 1.79 2004/01/11 01:57:05 tom Exp $")
++MODULE_ID("$Id: read_entry.c,v 1.80 2004/09/25 23:00:25 tom Exp $")
+ 
+ #if !HAVE_TELL
+ #define tell(fd) lseek(fd, 0, SEEK_CUR)		/* lseek() is POSIX, but not tell() */
+ #endif
+ 
++#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
++
+ /*
+  *	int
+  *	_nc_read_file_entry(filename, ptr)
+@@ -146,13 +148,14 @@
+     }
+ }
+ 
+-#define read_shorts(fd, buf, count) (read(fd, buf, (count)*2) == (count)*2)
++#define read_shorts(fd, buf, count) \
++	(read(fd, buf, (unsigned) (count)*2) == (int) (count)*2)
+ 
+ #define even_boundary(value) \
+     if ((value) % 2 != 0) read(fd, buf, 1)
+ 
+ static int
+-read_termtype(int fd, TERMTYPE * ptr)
++read_termtype(int fd, TERMTYPE *ptr)
+ /* return 1 if read, 0 if not found or garbled */
+ {
+     int name_size, bool_count, num_count, str_count, str_size;
+@@ -204,7 +207,7 @@
+ 	memset(buf + have, 0, want - have);
+     }
+     buf[want] = '\0';
+-    ptr->term_names = typeCalloc(char, strlen(buf) + 1);
++    ptr->term_names = TYPE_CALLOC(char, strlen(buf) + 1);
+     if (ptr->term_names == NULL) {
+ 	return (0);
+     }
+@@ -213,7 +216,7 @@
+ 	lseek(fd, (off_t) (have - MAX_NAME_SIZE), 1);
+ 
+     /* grab the booleans */
+-    if ((ptr->Booleans = typeCalloc(char, max(BOOLCOUNT, bool_count))) == 0
++    if ((ptr->Booleans = TYPE_CALLOC(char, max(BOOLCOUNT, bool_count))) == 0
+ 	|| read(fd, ptr->Booleans, (unsigned) bool_count) < bool_count) {
+ 	return (0);
+     }
+@@ -227,13 +230,13 @@
+     even_boundary(name_size + bool_count);
+ 
+     /* grab the numbers */
+-    if ((ptr->Numbers = typeCalloc(short, max(NUMCOUNT, num_count))) == 0
++    if ((ptr->Numbers = TYPE_CALLOC(short, max(NUMCOUNT, num_count))) == 0
+ 	|| !read_shorts(fd, buf, num_count)) {
+ 	return (0);
+     }
+     convert_shorts(buf, ptr->Numbers, num_count);
+ 
+-    if ((ptr->Strings = typeCalloc(char *, max(STRCOUNT, str_count))) == 0)
++    if ((ptr->Strings = TYPE_CALLOC(char *, max(STRCOUNT, str_count))) == 0)
+ 	  return (0);
+ 
+     if (str_count) {
+@@ -263,10 +266,10 @@
+ 	int ext_str_count = LOW_MSB(buf + 4);
+ 	int ext_str_size = LOW_MSB(buf + 6);
+ 	int ext_str_limit = LOW_MSB(buf + 8);
+-	int need = (ext_bool_count + ext_num_count + ext_str_count);
++	unsigned need = (ext_bool_count + ext_num_count + ext_str_count);
+ 	int base = 0;
+ 
+-	if (need >= (int) sizeof(buf)
++	if (need >= sizeof(buf)
+ 	    || ext_str_size >= (int) sizeof(buf)
+ 	    || ext_str_limit >= (int) sizeof(buf)
+ 	    || ext_bool_count < 0
+@@ -317,7 +320,7 @@
+ 	if (ext_str_limit) {
+ 	    if ((ptr->ext_str_table = typeMalloc(char, ext_str_limit)) == 0)
+ 		  return (0);
+-	    if (read(fd, ptr->ext_str_table, ext_str_limit) != ext_str_limit)
++	    if (read(fd, ptr->ext_str_table, (unsigned) ext_str_limit) != ext_str_limit)
+ 		return (0);
+ 	    TR(TRACE_DATABASE, ("first extended-string is %s", _nc_visbuf(ptr->ext_str_table)));
+ 	}
+@@ -342,12 +345,14 @@
+ 	}
+ 
+ 	if (need) {
+-	    if ((ptr->ext_Names = typeCalloc(char *, need)) == 0)
++	    if ((ptr->ext_Names = TYPE_CALLOC(char *, need)) == 0)
+ 		  return (0);
+ 	    TR(TRACE_DATABASE,
+ 	       ("ext_NAMES starting @%d in extended_strings, first = %s",
+ 		base, _nc_visbuf(ptr->ext_str_table + base)));
+-	    convert_strings(buf + (2 * ext_str_count), ptr->ext_Names, need,
++	    convert_strings(buf + (2 * ext_str_count),
++			    ptr->ext_Names,
++			    (int) need,
+ 			    ext_str_limit, ptr->ext_str_table + base);
+ 	}
+ 
+@@ -378,7 +383,7 @@
+ }
+ 
+ NCURSES_EXPORT(int)
+-_nc_read_file_entry(const char *const filename, TERMTYPE * ptr)
++_nc_read_file_entry(const char *const filename, TERMTYPE *ptr)
+ /* return 1 if read, 0 if not found or garbled */
+ {
+     int code, fd = -1;
+@@ -403,7 +408,7 @@
+  */
+ static int
+ _nc_read_tic_entry(char *const filename,
+-		   const char *const dir, const char *ttn, TERMTYPE * const tp)
++		   const char *const dir, const char *ttn, TERMTYPE *const tp)
+ {
+     int need = 2 + strlen(dir) + strlen(ttn);
+ 
+@@ -419,7 +424,7 @@
+  */
+ static int
+ _nc_read_terminfo_dirs(const char *dirs, char *const filename, const char *const
+-		       ttn, TERMTYPE * const tp)
++		       ttn, TERMTYPE *const tp)
+ {
+     char *list, *a;
+     const char *b;
+@@ -460,7 +465,7 @@
+  */
+ 
+ NCURSES_EXPORT(int)
+-_nc_read_entry(const char *const tn, char *const filename, TERMTYPE * const tp)
++_nc_read_entry(const char *const tn, char *const filename, TERMTYPE *const tp)
+ {
+     char *envp;
+     char ttn[PATH_MAX];
+Index: ncurses/tinfo/read_termcap.c
+Prereq:  1.61 
+--- ncurses-5.4-20040208/ncurses/tinfo/read_termcap.c	2003-11-08 20:22:45.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tinfo/read_termcap.c	2004-07-05 12:55:23.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -57,7 +57,7 @@
+ #include <tic.h>
+ #include <term_entry.h>
+ 
+-MODULE_ID("$Id: read_termcap.c,v 1.61 2003/11/08 20:22:45 tom Exp $")
++MODULE_ID("$Id: read_termcap.c,v 1.66 2004/07/05 12:55:23 tom Exp $")
+ 
+ #if !PURE_TERMINFO
+ 
+@@ -74,10 +74,10 @@
+ #define TC_SYS_ERR    -3
+ #define TC_REF_LOOP   -4
+ 
+-static char *
++static NCURSES_CONST char *
+ get_termpath(void)
+ {
+-    char *result;
++    NCURSES_CONST char *result;
+ 
+     if (!use_terminfo_vars() || (result = getenv("TERMPATH")) == 0)
+ 	result = TERMPATH;
+@@ -720,7 +720,7 @@
+ 	    if (*s == '\0') {
+ 		break;
+ 	    } else if (*s++ == '\n') {
+-		while (isspace(*s))
++		while (isspace(UChar(*s)))
+ 		    s++;
+ 	    } else {
+ 		found = TRUE;
+@@ -734,7 +734,7 @@
+ 		break;
+ 	    }
+ 	    base = s;
+-	} else if (isgraph(ch)) {
++	} else if (isgraph(UChar(ch))) {
+ 	    found = TRUE;
+ 	}
+     }
+@@ -754,7 +754,7 @@
+ 
+     while ((ch = *src++) != '\0') {
+ 	if (ch == '\\' && *src == '\n') {
+-	    while (isspace(*src))
++	    while (isspace(UChar(*src)))
+ 		src++;
+ 	    continue;
+ 	}
+@@ -784,7 +784,7 @@
+     char pathbuf[PBUFSIZ];	/* holds raw path of filenames */
+     char *pathvec[PVECSIZ];	/* to point to names in pathbuf */
+     char **pvec;		/* holds usable tail of path vector */
+-    char *termpath;
++    NCURSES_CONST char *termpath;
+     string_desc desc;
+ 
+     fname = pathvec;
+@@ -932,7 +932,7 @@
+ #endif /* !USE_GETCAP */
+ 
+ NCURSES_EXPORT(int)
+-_nc_read_termcap_entry(const char *const tn, TERMTYPE * const tp)
++_nc_read_termcap_entry(const char *const tn, TERMTYPE *const tp)
+ {
+     int found = FALSE;
+     ENTRY *ep;
+@@ -1047,7 +1047,7 @@
+      * Probably /etc/termcap is a symlink to /usr/share/misc/termcap.
+      * Avoid reading the same file twice.
+      */
+-#ifdef HAVE_LINK
++#if HAVE_LINK
+     for (j = 0; j < filecount; j++) {
+ 	bool omit = FALSE;
+ 	if (stat(termpaths[j], &test_stat[j]) != 0
+@@ -1112,7 +1112,7 @@
+ 	return (ERR);
+ 
+     /* resolve all use references */
+-    _nc_resolve_uses(TRUE);
++    _nc_resolve_uses2(TRUE, FALSE);
+ 
+     /* find a terminal matching tn, if we can */
+ #if USE_GETCAP_CACHE
+Index: ncurses/trace/lib_trace.c
+Prereq:  1.53 
+--- ncurses-5.4-20040208/ncurses/trace/lib_trace.c	2003-11-23 00:39:30.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/trace/lib_trace.c	2005-02-19 17:13:49.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -40,9 +41,9 @@
+ 
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_trace.c,v 1.53 2003/11/23 00:39:30 tom Exp $")
++MODULE_ID("$Id: lib_trace.c,v 1.57 2005/02/19 17:13:49 tom Exp $")
+ 
+-NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0;	/* always define this */
++NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */
+ 
+ #ifdef TRACE
+ NCURSES_EXPORT_VAR(const char *) _nc_tputs_trace = "";
+@@ -179,9 +180,33 @@
+     return code;
+ }
+ 
++/* Trace 'const char*' return-values */
++NCURSES_EXPORT(const char *)
++_nc_retrace_cptr(const char *code)
++{
++    T((T_RETURN("%s"), _nc_visbuf(code)));
++    return code;
++}
++
++/* Trace 'NCURSES_CONST void*' return-values */
++NCURSES_EXPORT(NCURSES_CONST void *)
++_nc_retrace_cvoid_ptr(NCURSES_CONST void *code)
++{
++    T((T_RETURN("%p"), code));
++    return code;
++}
++
++/* Trace 'void*' return-values */
++NCURSES_EXPORT(void *)
++_nc_retrace_void_ptr(void *code)
++{
++    T((T_RETURN("%p"), code));
++    return code;
++}
++
+ /* Trace 'SCREEN *' return-values */
+ NCURSES_EXPORT(SCREEN *)
+-_nc_retrace_sp(SCREEN * code)
++_nc_retrace_sp(SCREEN *code)
+ {
+     T((T_RETURN("%p"), code));
+     return code;
+Index: ncurses/trace/lib_traceatr.c
+Prereq:  1.48 
+--- ncurses-5.4-20040208/ncurses/trace/lib_traceatr.c	2004-01-25 22:31:38.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/trace/lib_traceatr.c	2005-01-29 00:50:23.000000000 +0000
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas Dickey 1996-2003                                         *
++ *  Author: Thomas Dickey                           1996-on                 *
+  *     and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+  ****************************************************************************/
+@@ -39,15 +39,33 @@
+ #include <curses.priv.h>
+ #include <term.h>		/* acs_chars */
+ 
+-MODULE_ID("$Id: lib_traceatr.c,v 1.48 2004/01/25 22:31:38 tom Exp $")
++MODULE_ID("$Id: lib_traceatr.c,v 1.50 2004/10/23 20:43:04 tom Exp $")
+ 
+-#define COLOR_OF(c) (c < 0 || c > 7 ? "default" : colors[c].name)
++#define COLOR_OF(c) ((c < 0) ? "default" : (c > 7 ? color_of(c) : colors[c].name))
+ 
+ #ifdef TRACE
+ 
+ static const char l_brace[] = {L_BRACE, 0};
+ static const char r_brace[] = {R_BRACE, 0};
+ 
++static char *
++color_of(int c)
++{
++    static char buffer[2][80];
++    static int sel;
++    static int last = -1;
++
++    if (c != last) {
++	last = c;
++	sel = !sel;
++	if (c == COLOR_DEFAULT)
++	    strcpy(buffer[sel], "default");
++	else
++	    sprintf(buffer[sel], "color%d", c);
++    }
++    return buffer[sel];
++}
++
+ NCURSES_EXPORT(char *)
+ _traceattr2(int bufnum, attr_t newmode)
+ {
+@@ -259,8 +277,9 @@
+ 	if ((found = _nc_altcharset_name(attr, CharOfD(ch))) != 0) {
+ 	    (void) _nc_trace_bufcat(bufnum, found);
+ 	    attr &= ~A_ALTCHARSET;
+-	} else if (isnac(CHDEREF(ch))) {
++	} else if (isWidecExt(CHDEREF(ch))) {
+ 	    (void) _nc_trace_bufcat(bufnum, "{NAC}");
++	    attr &= ~A_CHARTEXT;
+ 	} else {
+ 	    PUTC_DATA;
+ 	    int n;
+Index: ncurses/trace/lib_tracechr.c
+Prereq:  1.10 
+--- ncurses-5.4-20040208/ncurses/trace/lib_tracechr.c	2003-06-14 11:05:42.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/trace/lib_tracechr.c	2004-04-03 22:45:03.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -38,21 +38,21 @@
+ 
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_tracechr.c,v 1.10 2003/06/14 11:05:42 tom Exp $")
++MODULE_ID("$Id: lib_tracechr.c,v 1.11 2004/04/03 22:45:03 tom Exp $")
+ 
+ #ifdef TRACE
+ NCURSES_EXPORT(char *)
+ _tracechar(int ch)
+ {
+     static char result[40];
+-    char *name;
++    NCURSES_CONST char *name;
+ 
+     if (ch > KEY_MIN || ch < 0) {
+ 	name = keyname(ch);
+ 	if (name == 0 || *name == '\0')
+ 	    name = "NULL";
+ 	(void) sprintf(result, "'%.30s' = %#03o", name, ch);
+-    } else if (!isprint(ch) || ch > 255) {
++    } else if (!is8bits(ch) || !isprint(UChar(ch))) {
+ 	/*
+ 	 * workaround for glibc bug:
+ 	 * sprintf changes the result from unctrl() to an empty string if it
+Index: ncurses/trace/lib_tracedmp.c
+Prereq:  1.25 
+--- ncurses-5.4-20040208/ncurses/trace/lib_tracedmp.c	2002-09-22 22:21:38.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/trace/lib_tracedmp.c	2005-01-29 16:23:51.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2002,2005 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey 1996-2001                                      *
++ *  Author: Thomas E. Dickey 1996-on                                        *
+  *     and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+  ****************************************************************************/
+@@ -39,7 +39,7 @@
+ #include <curses.priv.h>
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_tracedmp.c,v 1.25 2002/09/22 22:21:38 tom Exp $")
++MODULE_ID("$Id: lib_tracedmp.c,v 1.26 2005/01/29 16:23:51 tom Exp $")
+ 
+ #ifdef TRACE
+ NCURSES_EXPORT(void)
+@@ -53,10 +53,13 @@
+     /* compute narrowest possible display width */
+     for (width = i = 0; i <= win->_maxy; ++i) {
+ 	n = 0;
+-	for (j = 0; j <= win->_maxx; ++j)
++	for (j = 0; j <= win->_maxx; ++j) {
+ 	    if (CharOf(win->_line[i].text[j]) != L(' ')
+-		|| AttrOf(win->_line[i].text[j]) != A_NORMAL)
++		|| AttrOf(win->_line[i].text[j]) != A_NORMAL
++		|| GetPair(win->_line[i].text[j]) != 0) {
+ 		n = j;
++	    }
++	}
+ 
+ 	if (n > width)
+ 	    width = n;
+@@ -99,15 +102,25 @@
+ 	/* dump A_COLOR part, will screw up if there are more than 96 */
+ 	havecolors = FALSE;
+ 	for (j = 0; j < width; ++j)
+-	    if (AttrOf(win->_line[n].text[j]) & A_COLOR) {
++	    if (GetPair(win->_line[n].text[j]) != 0) {
+ 		havecolors = TRUE;
+ 		break;
+ 	    }
+ 	if (havecolors) {
+ 	    ep = buf;
+-	    for (j = 0; j < width; ++j)
+-		ep[j] = UChar(AttrOf(win->_line[n].text[j]) >>
+-			      NCURSES_ATTR_SHIFT) + ' ';
++	    for (j = 0; j < width; ++j) {
++		int pair = GetPair(win->_line[n].text[j]);
++		if (pair >= 52)
++		    ep[j] = '?';
++		else if (pair >= 36)
++		    ep[j] = pair + 'A';
++		else if (pair >= 10)
++		    ep[j] = pair + 'a';
++		else if (pair >= 1)
++		    ep[j] = pair + '0';
++		else
++		    ep[j] = ' ';
++	    }
+ 	    ep[j] = '\0';
+ 	    _tracef("%*s[%2d]%*s='%s'", (int) strlen(name),
+ 		    "colors", n, 8, " ", buf);
+Index: ncurses/trace/lib_tracemse.c
+Prereq:  1.10 
+--- ncurses-5.4-20040208/ncurses/trace/lib_tracemse.c	2002-01-12 22:32:25.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/trace/lib_tracemse.c	2005-02-05 18:24:04.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000,2001,2002 Free Software Foundation, Inc.         *
++ * Copyright (c) 1998-2002,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -37,7 +38,7 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_tracemse.c,v 1.10 2002/01/12 22:32:25 tom Exp $")
++MODULE_ID("$Id: lib_tracemse.c,v 1.11 2005/02/05 18:24:04 tom Exp $")
+ 
+ #ifdef TRACE
+ 
+@@ -50,35 +51,57 @@
+ 		   ep->id, ep->x, ep->y, ep->z, ep->bstate);
+ 
+ #define SHOW(m, s) if ((ep->bstate & m) == m) strcat(strcat(buf, s), ", ")
++
+     SHOW(BUTTON1_RELEASED, "release-1");
+     SHOW(BUTTON1_PRESSED, "press-1");
+     SHOW(BUTTON1_CLICKED, "click-1");
+     SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1");
+     SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1");
++#if NCURSES_MOUSE_VERSION == 1
+     SHOW(BUTTON1_RESERVED_EVENT, "reserved-1");
++#endif
++
+     SHOW(BUTTON2_RELEASED, "release-2");
+     SHOW(BUTTON2_PRESSED, "press-2");
+     SHOW(BUTTON2_CLICKED, "click-2");
+     SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2");
+     SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2");
++#if NCURSES_MOUSE_VERSION == 1
+     SHOW(BUTTON2_RESERVED_EVENT, "reserved-2");
++#endif
++
+     SHOW(BUTTON3_RELEASED, "release-3");
+     SHOW(BUTTON3_PRESSED, "press-3");
+     SHOW(BUTTON3_CLICKED, "click-3");
+     SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3");
+     SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3");
++#if NCURSES_MOUSE_VERSION == 1
+     SHOW(BUTTON3_RESERVED_EVENT, "reserved-3");
++#endif
++
+     SHOW(BUTTON4_RELEASED, "release-4");
+     SHOW(BUTTON4_PRESSED, "press-4");
+     SHOW(BUTTON4_CLICKED, "click-4");
+     SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4");
+     SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4");
++#if NCURSES_MOUSE_VERSION == 1
+     SHOW(BUTTON4_RESERVED_EVENT, "reserved-4");
++#endif
++
++#if NCURSES_MOUSE_VERSION == 2
++    SHOW(BUTTON5_RELEASED, "release-5");
++    SHOW(BUTTON5_PRESSED, "press-5");
++    SHOW(BUTTON5_CLICKED, "click-5");
++    SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5");
++    SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5");
++#endif
++
+     SHOW(BUTTON_CTRL, "ctrl");
+     SHOW(BUTTON_SHIFT, "shift");
+     SHOW(BUTTON_ALT, "alt");
+     SHOW(ALL_MOUSE_EVENTS, "all-events");
+     SHOW(REPORT_MOUSE_POSITION, "position");
++
+ #undef SHOW
+ 
+     if (buf[strlen(buf) - 1] == ' ')
+Index: ncurses/trace/visbuf.c
+Prereq:  1.9 
+--- ncurses-5.4-20040208/ncurses/trace/visbuf.c	2004-02-03 01:16:37.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/trace/visbuf.c	2005-01-29 21:26:07.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2001-2003,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 2001-2004,2005 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey 1996-2004                                      *
++ *  Author: Thomas E. Dickey                        1996-on                 *
+  *     and: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+  ****************************************************************************/
+@@ -41,7 +41,7 @@
+ #include <tic.h>
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: visbuf.c,v 1.9 2004/02/03 01:16:37 tom Exp $")
++MODULE_ID("$Id: visbuf.c,v 1.12 2005/01/29 21:26:07 tom Exp $")
+ 
+ static char *
+ _nc_vischar(char *tp, unsigned c)
+@@ -129,7 +129,7 @@
+ #if USE_WIDEC_SUPPORT
+ #ifdef TRACE
+ static const char *
+-_nc_viswbuf2n(int bufnum, const wchar_t * buf, int len)
++_nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
+ {
+     char *vbuf;
+     char *tp;
+@@ -168,25 +168,47 @@
+ }
+ 
+ NCURSES_EXPORT(const char *)
+-_nc_viswbuf2(int bufnum, const wchar_t * buf)
++_nc_viswbuf2(int bufnum, const wchar_t *buf)
+ {
+     return _nc_viswbuf2n(bufnum, buf, -1);
+ }
+ 
+ NCURSES_EXPORT(const char *)
+-_nc_viswbuf(const wchar_t * buf)
++_nc_viswbuf(const wchar_t *buf)
+ {
+     return _nc_viswbuf2(0, buf);
+ }
+ 
+ NCURSES_EXPORT(const char *)
+-_nc_viswbufn(const wchar_t * buf, int len)
++_nc_viswbufn(const wchar_t *buf, int len)
+ {
+     return _nc_viswbuf2n(0, buf, len);
+ }
+ 
++/* this special case is used for wget_wstr() */
+ NCURSES_EXPORT(const char *)
+-_nc_viscbuf2(int bufnum, const cchar_t * buf, int len)
++_nc_viswibuf(const wint_t *buf)
++{
++    static wchar_t *mybuf;
++    static unsigned mylen;
++    unsigned n;
++
++    for (n = 0; buf[n] != 0; ++n) ;
++    if (mylen < ++n) {
++	mylen = n + 80;
++	if (mybuf != 0)
++	    mybuf = typeRealloc(wchar_t, mylen, mybuf);
++	else
++	    mybuf = typeMalloc(wchar_t, mylen);
++    }
++    for (n = 0; buf[n] != 0; ++n)
++	mybuf[n] = (wchar_t) buf[n];
++
++    return _nc_viswbuf2(0, mybuf);
++}
++
++NCURSES_EXPORT(const char *)
++_nc_viscbuf2(int bufnum, const cchar_t *buf, int len)
+ {
+     char *result = _nc_trace_buf(bufnum, BUFSIZ);
+     int n;
+@@ -198,7 +220,7 @@
+ 	len = _nc_wchstrlen(buf);
+ 
+     for (n = 1; n < len; n++) {
+-	if (AttrOf(buf[n]) != AttrOf(buf[0])) {
++	if (!SameAttrOf(buf[n], buf[0])) {
+ 	    same = FALSE;
+ 	    break;
+ 	}
+@@ -218,7 +240,7 @@
+ 	    if ((found = _nc_altcharset_name(attr, CharOfD(buf))) != 0) {
+ 		result = _nc_trace_bufcat(bufnum, found);
+ 		attr &= ~A_ALTCHARSET;
+-	    } else if (!isnac(CHDEREF(buf))) {
++	    } else if (!isWidecExt(CHDEREF(buf))) {
+ 		PUTC_DATA;
+ 
+ 		PUTC_INIT;
+@@ -260,7 +282,7 @@
+ }
+ 
+ NCURSES_EXPORT(const char *)
+-_nc_viscbuf(const cchar_t * buf, int len)
++_nc_viscbuf(const cchar_t *buf, int len)
+ {
+     return _nc_viscbuf2(0, buf, len);
+ }
+Index: ncurses/tty/MKexpanded.sh
+Prereq:  1.10 
+--- ncurses-5.4-20040208/ncurses/tty/MKexpanded.sh	2000-12-10 00:24:33.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tty/MKexpanded.sh	2005-01-02 01:06:40.000000000 +0000
+@@ -1,6 +1,6 @@
+ #! /bin/sh
+ ##############################################################################
+-# Copyright (c) 1998,2000 Free Software Foundation, Inc.                     #
++# Copyright (c) 1998-2000,2005 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"), #
+@@ -29,7 +29,7 @@
+ #
+ # Author: Thomas E. Dickey <dickey@clark.net> 1997
+ #
+-# $Id: MKexpanded.sh,v 1.10 2000/12/10 00:24:33 tom Exp $
++# $Id: MKexpanded.sh,v 1.11 2005/01/02 01:06:40 tom Exp $
+ #
+ # Script to generate 'expanded.c', a dummy source that contains functions
+ # corresponding to complex macros used in this library.  By making functions,
+@@ -84,7 +84,7 @@
+ {
+ 	return InsCharCost(count);
+ }
+-NCURSES_EXPORT(void) _nc_UpdateAttrs (chtype c)
++NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T c)
+ {
+ 	UpdateAttrs(c);
+ }
+Index: ncurses/tty/hashmap.c
+Prereq:  1.46 
+--- ncurses-5.4-20040208/ncurses/tty/hashmap.c	2002-09-07 18:13:15.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tty/hashmap.c	2005-01-29 21:27:58.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2002,2005 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            *
+@@ -70,7 +70,7 @@
+ #include <curses.priv.h>
+ #include <term.h>		/* for back_color_erase */
+ 
+-MODULE_ID("$Id: hashmap.c,v 1.46 2002/09/07 18:13:15 tom Exp $")
++MODULE_ID("$Id: hashmap.c,v 1.47 2005/01/29 21:27:58 tom Exp $")
+ 
+ #ifdef HASHDEBUG
+ 
+@@ -143,7 +143,7 @@
+     NCURSES_CH_T blank = NewChar2(BLANK_TEXT, BLANK_ATTR);
+ 
+     if (back_color_erase)
+-	AddAttr(blank, (AttrOf(stdscr->_nc_bkgd) & A_COLOR));
++	SetPair(blank, GetPair(stdscr->_nc_bkgd));
+ 
+     for (i = TEXTWIDTH; i > 0; i--)
+ 	if (!(CharEq(blank, *to++)))
+Index: ncurses/tty/lib_mvcur.c
+Prereq:  1.97 
+--- ncurses-5.4-20040208/ncurses/tty/lib_mvcur.c	2003-12-27 16:43:59.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tty/lib_mvcur.c	2005-01-22 22:15:45.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -154,7 +155,7 @@
+ #include <term.h>
+ #include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_mvcur.c,v 1.97 2003/12/27 16:43:59 tom Exp $")
++MODULE_ID("$Id: lib_mvcur.c,v 1.102 2005/01/22 22:15:45 tom Exp $")
+ 
+ #define WANT_CHAR(y, x)	SP->_newscr->_line[y].text[x]	/* desired state */
+ #define BAUDRATE	cur_term->_baudrate	/* bits per second */
+@@ -589,9 +590,11 @@
+ 		    && n > 0
+ 		    && n < (int) check.s_size
+ 		    && vcost == 0
+-		    && str[0] == '\0'
+-		    && isdigit(CharOf(WANT_CHAR(to_y, from_x))))
+-		    ovw = FALSE;
++		    && str[0] == '\0') {
++		    int wanted = CharOf(WANT_CHAR(to_y, from_x));
++		    if (is8bits(wanted) && isdigit(wanted))
++			ovw = FALSE;
++		}
+ #endif
+ 		/*
+ 		 * If we have no attribute changes, overwrite is cheaper.
+@@ -606,7 +609,7 @@
+ 
+ 		    for (i = 0; i < n; i++) {
+ 			NCURSES_CH_T ch = WANT_CHAR(to_y, from_x + i);
+-			if (AttrOf(ch) != SP->_current_attr
++			if (!SameAttrOf(ch, SCREEN_ATTRS(SP))
+ #if USE_WIDEC_SUPPORT
+ 			    || !Charable(ch)
+ #endif
+@@ -845,7 +848,7 @@
+ mvcur(int yold, int xold, int ynew, int xnew)
+ /* optimized cursor move from (yold, xold) to (ynew, xnew) */
+ {
+-    attr_t oldattr;
++    NCURSES_CH_T oldattr;
+     int code;
+ 
+     TR(TRACE_CALLS | TRACE_MOVE, (T_CALLED("mvcur(%d,%d,%d,%d)"),
+@@ -872,12 +875,12 @@
+ 	 * character set -- these have a strong tendency to screw up the CR &
+ 	 * LF used for local character motions!
+ 	 */
+-	oldattr = SP->_current_attr;
+-	if ((oldattr & A_ALTCHARSET)
+-	    || (oldattr && !move_standout_mode)) {
++	oldattr = SCREEN_ATTRS(SP);
++	if ((AttrOf(oldattr) & A_ALTCHARSET)
++	    || (AttrOf(oldattr) && !move_standout_mode)) {
+ 	    TR(TRACE_CHARPUT, ("turning off (%#lx) %s before move",
+-			       oldattr, _traceattr(oldattr)));
+-	    (void) vidattr(A_NORMAL);
++			       AttrOf(oldattr), _traceattr(AttrOf(oldattr))));
++	    (void) VIDATTR(A_NORMAL, 0);
+ 	}
+ 
+ 	if (xold >= screen_columns) {
+@@ -927,10 +930,10 @@
+ 	/*
+ 	 * Restore attributes if we disabled them before moving.
+ 	 */
+-	if (oldattr != SP->_current_attr) {
++	if (!SameAttrOf(oldattr, SCREEN_ATTRS(SP))) {
+ 	    TR(TRACE_CHARPUT, ("turning on (%#lx) %s after move",
+-			       oldattr, _traceattr(oldattr)));
+-	    (void) vidattr(oldattr);
++			       AttrOf(oldattr), _traceattr(AttrOf(oldattr))));
++	    (void) VIDATTR(AttrOf(oldattr), GetPair(oldattr));
+ 	}
+     }
+     returnCode(code);
+Index: ncurses/tty/lib_twait.c
+Prereq:  1.49 
+--- ncurses-5.4-20040208/ncurses/tty/lib_twait.c	2003-11-30 00:34:36.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tty/lib_twait.c	2004-09-25 22:53:43.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -61,7 +61,7 @@
+ # endif
+ #endif
+ 
+-MODULE_ID("$Id: lib_twait.c,v 1.49 2003/11/30 00:34:36 Philippe.Blain Exp $")
++MODULE_ID("$Id: lib_twait.c,v 1.50 2004/09/25 22:53:43 tom Exp $")
+ 
+ static long
+ _nc_gettime(bool first)
+@@ -226,7 +226,7 @@
+     }
+ #endif
+ 
+-    result = poll(fds, count, milliseconds);
++    result = poll(fds, (unsigned) count, milliseconds);
+ 
+ #ifdef NCURSES_WGETCH_EVENTS
+     if ((mode & 4) && evl) {
+Index: ncurses/tty/lib_vidattr.c
+Prereq:  1.39 
+--- ncurses-5.4-20040208/ncurses/tty/lib_vidattr.c	2001-08-26 00:40:46.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tty/lib_vidattr.c	2005-01-22 22:15:44.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc.         *
++ * Copyright (c) 1998-2004,2005 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -64,7 +65,7 @@
+ #include <curses.priv.h>
+ #include <term.h>
+ 
+-MODULE_ID("$Id: lib_vidattr.c,v 1.39 2001/08/26 00:40:46 Philippe.Blain Exp $")
++MODULE_ID("$Id: lib_vidattr.c,v 1.44 2005/01/22 22:15:44 tom Exp $")
+ 
+ #define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
+ 
+@@ -87,8 +88,7 @@
+ 	}
+ 
+ NCURSES_EXPORT(int)
+-vidputs
+-(chtype newmode, int (*outc) (int))
++vidputs(chtype newmode, int (*outc) (int))
+ {
+     static attr_t previous_attr = A_NORMAL;
+     attr_t turn_on, turn_off;
+@@ -105,7 +105,7 @@
+ 
+     /* this allows us to go on whether or not newterm() has been called */
+     if (SP)
+-	previous_attr = SP->_current_attr;
++	previous_attr = AttrOf(SCREEN_ATTRS(SP));
+ 
+     TR(TRACE_ATTRS, ("previous attribute was %s", _traceattr(previous_attr)));
+ 
+@@ -177,7 +177,7 @@
+ 		    TurnOff(A_STANDOUT, exit_standout_mode);
+ 		}
+ 	    }
+-	    previous_attr &= ~A_COLOR;
++	    previous_attr &= ALL_BUT_COLOR;
+ 	}
+ 
+ 	SetColorsIf((pair != 0) || fix_pair0, previous_attr);
+@@ -194,7 +194,7 @@
+ 			(newmode & A_INVIS) != 0,
+ 			(newmode & A_PROTECT) != 0,
+ 			(newmode & A_ALTCHARSET) != 0), 1, outc);
+-	    previous_attr &= ~A_COLOR;
++	    previous_attr &= ALL_BUT_COLOR;
+ 	}
+ 	SetColorsIf((pair != 0) || fix_pair0, previous_attr);
+     } else {
+@@ -213,8 +213,8 @@
+ 
+ 	if (turn_off && exit_attribute_mode) {
+ 	    doPut(exit_attribute_mode);
+-	    turn_on |= (newmode & (chtype) (~A_COLOR));
+-	    previous_attr &= ~A_COLOR;
++	    turn_on |= (newmode & ALL_BUT_COLOR);
++	    previous_attr &= ALL_BUT_COLOR;
+ 	}
+ 	SetColorsIf((pair != 0) || fix_pair0, previous_attr);
+ 
+@@ -229,22 +229,12 @@
+ 	TurnOn(A_PROTECT,	enter_protected_mode);
+ 	TurnOn(A_INVIS,		enter_secure_mode);
+ 	TurnOn(A_UNDERLINE,	enter_underline_mode);
+-#ifdef enter_horizontal_hl_mode
++#if USE_WIDEC_SUPPORT
+ 	TurnOn(A_HORIZONTAL,	enter_horizontal_hl_mode);
+-#endif
+-#ifdef enter_left_hl_mode
+ 	TurnOn(A_LEFT,		enter_left_hl_mode);
+-#endif
+-#ifdef enter_low_hl_mode
+ 	TurnOn(A_LOW,		enter_low_hl_mode);
+-#endif
+-#ifdef enter_right_hl_mode
+ 	TurnOn(A_RIGHT,		enter_right_hl_mode);
+-#endif
+-#ifdef enter_top_hl_mode
+ 	TurnOn(A_TOP,		enter_top_hl_mode);
+-#endif
+-#ifdef enter_vertical_hl_mode
+ 	TurnOn(A_VERTICAL,	enter_vertical_hl_mode);
+ #endif
+ 	/* *INDENT-ON* */
+@@ -255,7 +245,7 @@
+ 	newmode |= A_REVERSE;
+ 
+     if (SP)
+-	SP->_current_attr = newmode;
++	SetAttr(SCREEN_ATTRS(SP), newmode);
+     else
+ 	previous_attr = newmode;
+ 
+Index: ncurses/tty/tty_display.h
+Prereq:  1.5 
+--- ncurses-5.4-20040208/ncurses/tty/tty_display.h	2003-08-02 22:59:07.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tty/tty_display.h	2005-01-01 23:41:12.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -30,7 +30,7 @@
+ #define TTY_DISPLAY_H 1
+ 
+ /*
+- * $Id: tty_display.h,v 1.5 2003/08/02 22:59:07 Philippe.Blain Exp $
++ * $Id: tty_display.h,v 1.6 2005/01/01 23:41:12 tom Exp $
+  */
+ extern NCURSES_EXPORT(bool) _nc_tty_beep (void);
+ extern NCURSES_EXPORT(bool) _nc_tty_check_resize (void);
+@@ -118,7 +118,7 @@
+ 		    : INFINITY)))
+ 
+ #if USE_XMC_SUPPORT
+-#define UpdateAttrs(c)	if (D->_current_attr != AttrOf(c)) { \
++#define UpdateAttrs(c)	if (!SameAttrOf(D->_current_attr, AttrOf(c))) { \
+ 				attr_t chg = D->_current_attr; \
+ 				vidattr(AttrOf(c)); \
+ 				if (magic_cookie_glitch > 0 \
+@@ -131,7 +131,7 @@
+ 				} \
+ 			}
+ #else
+-#define UpdateAttrs(c)	if (D->_current_attr != AttrOf(c)) \
++#define UpdateAttrs(c)	if (!SameAttrOf(D->_current_attr, AttrOf(c))) \
+ 				vidattr(AttrOf(c));
+ #endif
+ 
+Index: ncurses/tty/tty_update.c
+Prereq:  1.205 
+--- ncurses-5.4-20040208/ncurses/tty/tty_update.c	2004-02-07 18:02:42.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/tty/tty_update.c	2005-02-05 22:51:25.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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,7 +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-2004                                      *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ /*-----------------------------------------------------------------
+@@ -74,7 +74,7 @@
+ #include <ctype.h>
+ #include <term.h>
+ 
+-MODULE_ID("$Id: tty_update.c,v 1.205 2004/02/07 18:02:42 tom Exp $")
++MODULE_ID("$Id: tty_update.c,v 1.219 2005/02/05 22:51:25 tom Exp $")
+ 
+ /*
+  * This define controls the line-breakout optimization.  Every once in a
+@@ -89,6 +89,8 @@
+ 
+ #define FILL_BCE() (SP->_coloron && !SP->_default_color && !back_color_erase)
+ 
++static const NCURSES_CH_T normal = NewChar2(BLANK_TEXT, BLANK_ATTR);
++
+ /*
+  * Enable checking to see if doupdate and friends are tracking the true
+  * cursor position correctly.  NOTE: this is a debugging hack which will
+@@ -183,7 +185,7 @@
+     NCURSES_CH_T my_ch;
+     PUTC_DATA;
+     NCURSES_CH_T tilde;
+-    NCURSES_ATTR_T attr = AttrOfD(ch);
++    NCURSES_CH_T attr = CHDEREF(ch);
+ 
+     TR(TRACE_CHARPUT, ("PutAttrChar(%s) at (%d, %d)",
+ 		       _tracech_t(ch),
+@@ -192,7 +194,7 @@
+     /*
+      * If this is not a valid character, there is nothing more to do.
+      */
+-    if (isnac(CHDEREF(ch)))
++    if (isWidecExt(CHDEREF(ch)))
+ 	return;
+     /*
+      * Determine the number of character cells which the 'ch' value will use
+@@ -201,8 +203,9 @@
+     if ((chlen = wcwidth(CharOf(CHDEREF(ch)))) <= 0) {
+ 	static NCURSES_CH_T blank = NewChar(BLANK_TEXT);
+ 
+-	if (isprint(CharOf(CHDEREF(ch)))
+-	    || (SP->_posix_locale && CharOf(CHDEREF(ch)) >= 160)) {
++	if (is8bits(CharOf(CHDEREF(ch)))
++	    && (isprint(CharOf(CHDEREF(ch)))
++		|| (SP->_legacy_coding && CharOf(CHDEREF(ch)) >= 160))) {
+ 	    ;
+ 	} else {
+ 	    ch = CHREF(blank);
+@@ -212,7 +215,7 @@
+     }
+ #endif
+ 
+-    if ((attr & A_ALTCHARSET)
++    if ((AttrOf(attr) & A_ALTCHARSET)
+ 	&& SP->_acs_map != 0
+ 	&& CharOfD(ch) < ACS_LEN) {
+ 	my_ch = CHDEREF(ch);	/* work around const param */
+@@ -224,21 +227,30 @@
+ 	 * normal one to be broken (by mis-design ;-).
+ 	 */
+ 	if (SP->_screen_acs_fix
+-	    && SP->_acs_map[CharOf(my_ch)] & A_ALTCHARSET) {
+-	    attr &= ~(A_ALTCHARSET);
++	    && SP->_screen_acs_map[CharOf(my_ch)]) {
++	    RemAttr(attr, A_ALTCHARSET);
+ 	    my_ch = _nc_wacs[CharOf(my_ch)];
+ 	}
+ #endif
+-	if (attr & A_ALTCHARSET) {
+-	    chtype temp = UChar(SP->_acs_map[CharOfD(ch)]);
++	/*
++	 * If we (still) have alternate character set, it is the normal 8bit
++	 * flavor.  The _screen_acs_map[] array tells if the character was
++	 * really in acs_chars, needed because of the way wide/normal line
++	 * drawing flavors are integrated.
++	 */
++	if (AttrOf(attr) & A_ALTCHARSET) {
++	    int j = CharOfD(ch);
++	    chtype temp = UChar(SP->_acs_map[j]);
++
++	    if (!(SP->_screen_acs_map[j]))
++		RemAttr(attr, A_ALTCHARSET);
+ 	    if (temp != 0)
+-		SetChar(my_ch, temp, attr);
+-	    RemAttr(my_ch, A_ALTCHARSET);
++		SetChar(my_ch, temp, AttrOf(attr));
+ 	}
+ 	ch = CHREF(my_ch);
+     }
+     if (tilde_glitch && (CharOfD(ch) == L('~'))) {
+-	SetChar(tilde, L('`'), attr);
++	SetChar(tilde, L('`'), AttrOf(attr));
+ 	ch = CHREF(tilde);
+     }
+ 
+@@ -404,13 +416,15 @@
+ {
+     if (!back_color_erase && SP->_coloron) {
+ #if NCURSES_EXT_FUNCS
++	int pair;
++
+ 	if (!SP->_default_color)
+ 	    return FALSE;
+ 	if (SP->_default_fg != C_MASK || SP->_default_bg != C_MASK)
+ 	    return FALSE;
+-	if (AttrOfD(ch) & A_COLOR) {
++	if ((pair = GetPair(CHDEREF(ch))) != 0) {
+ 	    short fg, bg;
+-	    pair_content(PAIR_NUMBER(AttrOfD(ch)), &fg, &bg);
++	    pair_content(pair, &fg, &bg);
+ 	    if (fg != C_MASK || bg != C_MASK)
+ 		return FALSE;
+ 	}
+@@ -471,7 +485,7 @@
+ 	    if (erase_chars
+ 		&& runcount > SP->_ech_cost + SP->_cup_ch_cost
+ 		&& can_clear_with(CHREF(ntext0))) {
+-		UpdateAttrs(AttrOf(ntext0));
++		UpdateAttrs(ntext0);
+ 		putp(tparm(erase_chars, runcount));
+ 
+ 		/*
+@@ -491,7 +505,7 @@
+ 		if (wrap_possible)
+ 		    rep_count--;
+ 
+-		UpdateAttrs(AttrOf(ntext0));
++		UpdateAttrs(ntext0);
+ 		tputs(tparm(repeat_char, CharOf(ntext0), rep_count),
+ 		      rep_count, _nc_outch);
+ 		SP->_curscol += rep_count;
+@@ -535,7 +549,7 @@
+     if (otext != ntext
+ 	&& (last - first + 1) > SP->_inline_cost) {
+ 	for (j = first, same = 0; j <= last; j++) {
+-	    if (!same && isnac(otext[j]))
++	    if (!same && isWidecExt(otext[j]))
+ 		continue;
+ 	    if (CharEq(otext[j], ntext[j])) {
+ 		same++;
+@@ -833,7 +847,7 @@
+      * Keep the physical screen in normal mode in case we get other
+      * processes writing to the screen.
+      */
+-    UpdateAttrs(A_NORMAL);
++    UpdateAttrs(normal);
+ 
+     _nc_flush();
+     curscr->_attrs = newscr->_attrs;
+@@ -928,7 +942,7 @@
+     }
+ 
+     if (needclear) {
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	TPUTS_TRACE("clr_eol");
+ 	if (clr_eol && SP->_el_cost <= (screen_columns - SP->_curscol)) {
+ 	    putp(clr_eol);
+@@ -954,7 +968,7 @@
+     row = SP->_cursrow;
+     col = SP->_curscol;
+ 
+-    UpdateAttrs(AttrOf(blank));
++    UpdateAttrs(blank);
+     TPUTS_TRACE("clr_eos");
+     tputs(clr_eos, screen_lines - row, _nc_outch);
+ 
+@@ -1059,14 +1073,12 @@
+     int n;
+     bool attrchanged = FALSE;
+ 
+-    TR(TRACE_UPDATE, ("TransformLine(%d) called", lineno));
++    TR(TRACE_UPDATE, (T_CALLED("TransformLine(%d)"), lineno));
+ 
+     /* copy new hash value to old one */
+     if (SP->oldhash && SP->newhash)
+ 	SP->oldhash[lineno] = SP->newhash[lineno];
+ 
+-#define ColorOf(n) (AttrOf(n) & A_COLOR)
+-#define unColor(n) (AttrOf(n) & ALL_BUT_COLOR)
+     /*
+      * If we have colors, there is the possibility of having two color pairs
+      * that display as the same colors.  For instance, Lynx does this.  Check
+@@ -1074,24 +1086,19 @@
+      * they are equivalent.
+      */
+     if (SP->_coloron) {
+-	attr_t oldColor;
+-	attr_t newColor;
+ 	int oldPair;
+ 	int newPair;
+ 
+ 	for (n = 0; n < screen_columns; n++) {
+ 	    if (!CharEq(newLine[n], oldLine[n])) {
+-		oldColor = ColorOf(oldLine[n]);
+-		newColor = ColorOf(newLine[n]);
+-		if (oldColor != newColor
++		oldPair = GetPair(oldLine[n]);
++		newPair = GetPair(newLine[n]);
++		if (oldPair != newPair
+ 		    && unColor(oldLine[n]) == unColor(newLine[n])) {
+-		    oldPair = PAIR_NUMBER(oldColor);
+-		    newPair = PAIR_NUMBER(newColor);
+ 		    if (oldPair < COLOR_PAIRS
+ 			&& newPair < COLOR_PAIRS
+ 			&& SP->_color_pairs[oldPair] == SP->_color_pairs[newPair]) {
+-			RemAttr(oldLine[n], A_COLOR);
+-			AddAttr(oldLine[n], ColorOf(newLine[n]));
++			SetPair(oldLine[n], GetPair(newLine[n]));
+ 		    }
+ 		}
+ 	    }
+@@ -1101,7 +1108,7 @@
+     if (ceol_standout_glitch && clr_eol) {
+ 	firstChar = 0;
+ 	while (firstChar < screen_columns) {
+-	    if (AttrOf(newLine[firstChar]) != AttrOf(oldLine[firstChar])) {
++	    if (!SameAttrOf(newLine[firstChar], oldLine[firstChar])) {
+ 		attrchanged = TRUE;
+ 		break;
+ 	    }
+@@ -1193,12 +1200,12 @@
+ 		    if (nFirstChar >= screen_columns
+ 			&& SP->_el_cost <= SP->_el1_cost) {
+ 			GoTo(lineno, 0);
+-			UpdateAttrs(AttrOf(blank));
++			UpdateAttrs(blank);
+ 			TPUTS_TRACE("clr_eol");
+ 			putp(clr_eol);
+ 		    } else {
+ 			GoTo(lineno, nFirstChar - 1);
+-			UpdateAttrs(AttrOf(blank));
++			UpdateAttrs(blank);
+ 			TPUTS_TRACE("clr_bol");
+ 			putp(clr_bol);
+ 		    }
+@@ -1214,8 +1221,10 @@
+ 		firstChar++;
+ 	}
+ 	/* if there wasn't one, we're done */
+-	if (firstChar >= screen_columns)
++	if (firstChar >= screen_columns) {
++	    TR(TRACE_UPDATE, (T_RETURN("")));
+ 	    return;
++	}
+ 
+ 	blank = newLine[screen_columns - 1];
+ 
+@@ -1234,6 +1243,7 @@
+ 		       newLine + firstChar,
+ 		       (nLastChar - firstChar + 1) * sizeof(NCURSES_CH_T));
+ 	    }
++	    TR(TRACE_UPDATE, (T_RETURN("")));
+ 	    return;
+ 	}
+ 
+@@ -1273,7 +1283,7 @@
+ 	    /* can be -1 if no characters differ */
+ 	    while (CharEq(newLine[nLastChar], oldLine[oLastChar])) {
+ 		/* don't split a wide char */
+-		if (isnac(newLine[nLastChar]) &&
++		if (isWidecExt(newLine[nLastChar]) &&
+ 		    !CharEq(newLine[nLastChar - 1], oldLine[oLastChar - 1]))
+ 		    break;
+ 		nLastChar--;
+@@ -1291,8 +1301,11 @@
+ 	    if (oLastChar < nLastChar) {
+ 		int m = max(nLastNonblank, oLastNonblank);
+ 		GoTo(lineno, n + 1);
+-		if (InsCharCost(nLastChar - oLastChar)
+-		    > (m - n)) {
++		if (
++#if USE_WIDEC_SUPPORT
++		       isWidecExt(newLine[n + 1]) ||
++#endif
++		       InsCharCost(nLastChar - oLastChar) > (m - n)) {
+ 		    PutRange(oldLine, newLine, lineno, n + 1, m);
+ 		} else {
+ 		    InsStr(&newLine[n + 1], nLastChar - oLastChar);
+@@ -1314,7 +1327,7 @@
+ 		     * setting the video attributes from
+ 		     * the last character on the row.
+ 		     */
+-		    UpdateAttrs(AttrOf(blank));
++		    UpdateAttrs(blank);
+ 		    DelChar(oLastChar - nLastChar);
+ 		}
+ 	    }
+@@ -1326,6 +1339,8 @@
+ 	memcpy(oldLine + firstChar,
+ 	       newLine + firstChar,
+ 	       (screen_columns - firstChar) * sizeof(NCURSES_CH_T));
++    TR(TRACE_UPDATE, (T_RETURN("")));
++    return;
+ }
+ 
+ /*
+@@ -1346,7 +1361,7 @@
+ #if NCURSES_EXT_FUNCS
+     if (SP->_coloron
+ 	&& !SP->_default_color) {
+-	_nc_do_color((int) COLOR_PAIR(SP->_current_attr), 0, FALSE, _nc_outch);
++	_nc_do_color(GET_SCREEN_PAIR(SP), 0, FALSE, _nc_outch);
+ 	if (!back_color_erase) {
+ 	    fast_clear = FALSE;
+ 	}
+@@ -1355,7 +1370,7 @@
+ 
+     if (fast_clear) {
+ 	if (clear_screen) {
+-	    UpdateAttrs(AttrOf(blank));
++	    UpdateAttrs(blank);
+ 	    TPUTS_TRACE("clear_screen");
+ 	    putp(clear_screen);
+ 	    SP->_cursrow = SP->_curscol = 0;
+@@ -1364,13 +1379,13 @@
+ 	    SP->_cursrow = SP->_curscol = -1;
+ 	    GoTo(0, 0);
+ 
+-	    UpdateAttrs(AttrOf(blank));
++	    UpdateAttrs(blank);
+ 	    TPUTS_TRACE("clr_eos");
+ 	    tputs(clr_eos, screen_lines, _nc_outch);
+ 	} else if (clr_eol) {
+ 	    SP->_cursrow = SP->_curscol = -1;
+ 
+-	    UpdateAttrs(AttrOf(blank));
++	    UpdateAttrs(blank);
+ 	    for (i = 0; i < screen_lines; i++) {
+ 		GoTo(i, 0);
+ 		TPUTS_TRACE("clr_eol");
+@@ -1379,7 +1394,7 @@
+ 	    GoTo(0, 0);
+ 	}
+     } else {
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	for (i = 0; i < screen_lines; i++) {
+ 	    GoTo(i, 0);
+ 	    for (j = 0; j < screen_columns; j++)
+@@ -1515,34 +1530,34 @@
+ 
+     if (n == 1 && scroll_forward && top == miny && bot == maxy) {
+ 	GoTo(bot, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	TPUTS_TRACE("scroll_forward");
+ 	putp(scroll_forward);
+     } else if (n == 1 && delete_line && bot == maxy) {
+ 	GoTo(top, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	TPUTS_TRACE("delete_line");
+ 	putp(delete_line);
+     } else if (parm_index && top == miny && bot == maxy) {
+ 	GoTo(bot, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	TPUTS_TRACE("parm_index");
+ 	tputs(tparm(parm_index, n, 0), n, _nc_outch);
+     } else if (parm_delete_line && bot == maxy) {
+ 	GoTo(top, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	TPUTS_TRACE("parm_delete_line");
+ 	tputs(tparm(parm_delete_line, n, 0), n, _nc_outch);
+     } else if (scroll_forward && top == miny && bot == maxy) {
+ 	GoTo(bot, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	for (i = 0; i < n; i++) {
+ 	    TPUTS_TRACE("scroll_forward");
+ 	    putp(scroll_forward);
+ 	}
+     } else if (delete_line && bot == maxy) {
+ 	GoTo(top, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	for (i = 0; i < n; i++) {
+ 	    TPUTS_TRACE("delete_line");
+ 	    putp(delete_line);
+@@ -1573,34 +1588,34 @@
+ 
+     if (n == 1 && scroll_reverse && top == miny && bot == maxy) {
+ 	GoTo(top, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	TPUTS_TRACE("scroll_reverse");
+ 	putp(scroll_reverse);
+     } else if (n == 1 && insert_line && bot == maxy) {
+ 	GoTo(top, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	TPUTS_TRACE("insert_line");
+ 	putp(insert_line);
+     } else if (parm_rindex && top == miny && bot == maxy) {
+ 	GoTo(top, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	TPUTS_TRACE("parm_rindex");
+ 	tputs(tparm(parm_rindex, n, 0), n, _nc_outch);
+     } else if (parm_insert_line && bot == maxy) {
+ 	GoTo(top, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	TPUTS_TRACE("parm_insert_line");
+ 	tputs(tparm(parm_insert_line, n, 0), n, _nc_outch);
+     } else if (scroll_reverse && top == miny && bot == maxy) {
+ 	GoTo(top, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	for (i = 0; i < n; i++) {
+ 	    TPUTS_TRACE("scroll_reverse");
+ 	    putp(scroll_reverse);
+ 	}
+     } else if (insert_line && bot == maxy) {
+ 	GoTo(top, 0);
+-	UpdateAttrs(AttrOf(blank));
++	UpdateAttrs(blank);
+ 	for (i = 0; i < n; i++) {
+ 	    TPUTS_TRACE("insert_line");
+ 	    putp(insert_line);
+@@ -1632,7 +1647,7 @@
+ 	return ERR;
+ 
+     GoTo(del, 0);
+-    UpdateAttrs(AttrOf(blank));
++    UpdateAttrs(blank);
+     if (n == 1 && delete_line) {
+ 	TPUTS_TRACE("delete_line");
+ 	putp(delete_line);
+@@ -1647,7 +1662,7 @@
+     }
+ 
+     GoTo(ins, 0);
+-    UpdateAttrs(AttrOf(blank));
++    UpdateAttrs(blank);
+     if (n == 1 && insert_line) {
+ 	TPUTS_TRACE("insert_line");
+ 	putp(insert_line);
+@@ -1800,7 +1815,7 @@
+ _nc_screen_resume(void)
+ {
+     /* make sure terminal is in a sane known state */
+-    SP->_current_attr = A_NORMAL;
++    SetAttr(SCREEN_ATTRS(SP), A_NORMAL);
+     newscr->_clear = TRUE;
+ 
+     /* reset color pairs and definitions */
+@@ -1848,7 +1863,7 @@
+ NCURSES_EXPORT(void)
+ _nc_screen_wrap(void)
+ {
+-    UpdateAttrs(A_NORMAL);
++    UpdateAttrs(normal);
+ #if NCURSES_EXT_FUNCS
+     if (SP->_coloron
+ 	&& !SP->_default_color) {
+@@ -1871,7 +1886,7 @@
+ NCURSES_EXPORT(void)
+ _nc_do_xmc_glitch(attr_t previous)
+ {
+-    attr_t chg = XMC_CHANGES(previous ^ SP->_current_attr);
++    attr_t chg = XMC_CHANGES(previous ^ AttrOf(SCREEN_ATTRS(SP)));
+ 
+     while (chg != 0) {
+ 	if (chg & 1) {
+Index: ncurses/widechar/charable.c
+Prereq:  1.2 
+--- ncurses-5.4-20040208/ncurses/widechar/charable.c	2003-07-05 18:04:08.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/charable.c	2004-09-25 21:03:44.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2003 Free Software Foundation, Inc.                        *
++ * Copyright (c) 2003,2004 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: charable.c,v 1.2 2003/07/05 18:04:08 tom Exp $")
++MODULE_ID("$Id: charable.c,v 1.3 2004/09/25 21:03:44 tom Exp $")
+ 
+ NCURSES_EXPORT(bool) _nc_is_charable(wchar_t ch)
+ {
+@@ -67,10 +67,13 @@
+ #if HAVE_BTOWC
+     result = btowc(ch);
+ #elif HAVE_MBTOWC
++    wchar_t convert;
+     char temp[2];
+     temp[0] = ch;
+     temp[1] = '\0';
+-    if (mbtowc((wchar_t *) (&result), temp, 1) != 1)
++    if (mbtowc(&convert, temp, 1) >= 0)
++	result = convert;
++    else
+ 	result = WEOF;
+ #endif
+     return result;
+Index: ncurses/widechar/lib_add_wch.c
+Prereq:  1.2 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_add_wch.c	2004-02-07 17:53:33.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_add_wch.c	2004-09-19 00:33:51.000000000 +0000
+@@ -35,7 +35,7 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_add_wch.c,v 1.2 2004/02/07 17:53:33 tom Exp $")
++MODULE_ID("$Id: lib_add_wch.c,v 1.4 2004/09/19 00:33:51 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ wadd_wch(WINDOW *win, const cchar_t * wch)
+@@ -54,12 +54,12 @@
+ 		break;
+ 	    if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) {
+ 		code = ERR;
+-		if (PUTC_ch < 256)
+-		    code = waddch(win, UChar(PUTC_ch));
++		if (is8bits(PUTC_ch))
++		    code = waddch(win, UChar(PUTC_ch) | wch->attr);
+ 		break;
+ 	    }
+ 	    for (n = 0; n < PUTC_n; n++) {
+-		if ((code = waddch(win, UChar(PUTC_buf[n]))) == ERR) {
++		if ((code = waddch(win, UChar(PUTC_buf[n]) | wch->attr)) == ERR) {
+ 		    break;
+ 		}
+ 	    }
+@@ -89,12 +89,12 @@
+ 		break;
+ 	    if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) {
+ 		code = ERR;
+-		if (PUTC_ch < 256)
+-		    code = waddch(win, UChar(PUTC_ch));
++		if (is8bits(PUTC_ch))
++		    code = waddch(win, UChar(PUTC_ch) | wch->attr);
+ 		break;
+ 	    }
+ 	    for (n = 0; n < PUTC_n; n++) {
+-		if ((code = waddch(win, UChar(PUTC_buf[n]))) == ERR) {
++		if ((code = waddch(win, UChar(PUTC_buf[n]) | wch->attr)) == ERR) {
+ 		    break;
+ 		}
+ 	    }
+Index: ncurses/widechar/lib_cchar.c
+Prereq:  1.8 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_cchar.c	2003-05-25 00:07:41.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_cchar.c	2005-01-29 21:29:16.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2001-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 2001-2004,2005 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            *
+@@ -35,17 +35,20 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_cchar.c,v 1.8 2003/05/25 00:07:41 tom Exp $")
++MODULE_ID("$Id: lib_cchar.c,v 1.11 2005/01/29 21:29:16 tom Exp $")
+ 
+ /* 
+  * The SuSv2 description leaves some room for interpretation.  We'll assume wch
+- * is L'\0' terminated, contains at most one character with strictly positive
+- * width, which must be the first, and contains no characters of negative
+- * width.
++ * points to a string which is L'\0' terminated, contains at least one
++ * character with strictly positive width, which must be the first, and
++ * contains no characters of negative width.
+  */
+ NCURSES_EXPORT(int)
+-setcchar(cchar_t * wcval, const wchar_t * wch, const attr_t attrs,
+-	 short color_pair, const void *opts)
++setcchar(cchar_t *wcval,
++	 const wchar_t *wch,
++	 const attr_t attrs,
++	 short color_pair,
++	 const void *opts)
+ {
+     int i;
+     int len;
+@@ -54,10 +57,13 @@
+     TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%ld,%d,%p)"),
+ 		      wcval, _nc_viswbuf(wch), attrs, color_pair, opts));
+ 
+-    if (opts != NULL || (len = wcslen(wch)) > CCHARW_MAX
++    len = wcslen(wch);
++    if (opts != NULL
+ 	|| (len > 1 && wcwidth(wch[0]) < 0)) {
+ 	code = ERR;
+     } else {
++	if (len > CCHARW_MAX)
++	    len = CCHARW_MAX;
+ 
+ 	/*
+ 	 * If we have a following spacing-character, stop at that point.  We
+@@ -73,7 +79,8 @@
+ 	memset(wcval, 0, sizeof(*wcval));
+ 
+ 	if (len != 0) {
+-	    SetAttr(*wcval, attrs | color_pair);
++	    SetAttr(*wcval, attrs | COLOR_PAIR(color_pair));
++	    SetPair(CHDEREF(wcval), color_pair);
+ 	    memcpy(&wcval->chars, wch, len * sizeof(wchar_t));
+ 	    TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len,
+ 			      _tracecchar_t(wcval)));
+@@ -85,8 +92,11 @@
+ }
+ 
+ NCURSES_EXPORT(int)
+-getcchar(const cchar_t * wcval, wchar_t * wch, attr_t * attrs,
+-	 short *color_pair, void *opts)
++getcchar(const cchar_t *wcval,
++	 wchar_t *wch,
++	 attr_t *attrs,
++	 short *color_pair,
++	 void *opts)
+ {
+     wchar_t *wp;
+     int len;
+@@ -105,8 +115,8 @@
+ 	} else if (attrs == 0 || color_pair == 0) {
+ 	    code = ERR;
+ 	} else if (len >= 0) {
+-	    *attrs = AttrOf(*wcval);
+-	    *color_pair = AttrOf(*wcval) & A_COLOR;
++	    *attrs = AttrOf(*wcval) & A_ATTRIBUTES;
++	    *color_pair = GetPair(*wcval);
+ 	    wmemcpy(wch, wcval->chars, (unsigned) len);
+ 	    wch[len] = L'\0';
+ 	    code = OK;
+Index: ncurses/widechar/lib_get_wch.c
+Prereq:  1.6 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_get_wch.c	2004-01-18 01:18:17.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_get_wch.c	2004-11-20 21:53:47.000000000 +0000
+@@ -38,25 +38,26 @@
+ */
+ 
+ #include <curses.priv.h>
++#include <ctype.h>
+ 
+-MODULE_ID("$Id: lib_get_wch.c,v 1.6 2004/01/18 01:18:17 tom Exp $")
++MODULE_ID("$Id: lib_get_wch.c,v 1.10 2004/11/20 21:53:47 tom Exp $")
+ 
+ #if HAVE_MBTOWC && HAVE_MBLEN
+ #define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
+ #define count_mbytes(buffer,length,state) mblen(buffer,length)
+ #define check_mbytes(wch,buffer,length,state) \
+-	(int) mbtowc(&wch, buffer, count)
++	(int) mbtowc(&wch, buffer, length)
+ #elif HAVE_MBRTOWC && HAVE_MBRLEN
+-#define reset_mbytes(state) memset(&state, 0, sizeof(state))
++#define reset_mbytes(state) init_mb(state)
+ #define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
+ #define check_mbytes(wch,buffer,length,state) \
+-	(int) mbrtowc(&wch, buffer, count, &state)
++	(int) mbrtowc(&wch, buffer, length, &state)
+ #else
+ make an error
+ #endif
+ 
+ NCURSES_EXPORT(int)
+-wget_wch(WINDOW *win, wint_t * result)
++wget_wch(WINDOW *win, wint_t *result)
+ {
+     int code;
+     char buffer[(MB_LEN_MAX * 9) + 1];	/* allow some redundant shifts */
+@@ -103,6 +104,7 @@
+ 		reset_mbytes(state);
+ 		if (check_mbytes(wch, buffer, count, state) != status) {
+ 		    code = ERR;	/* the two calls should match */
++		    ungetch(value);
+ 		}
+ 		value = wch;
+ 		break;
+Index: ncurses/widechar/lib_get_wstr.c
+Prereq:  1.6 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_get_wstr.c	2003-05-17 21:33:03.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_get_wstr.c	2004-10-16 21:55:36.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
++ * Copyright (c) 2002-2003,2004 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey 2002                                           *
++ *  Author: Thomas E. Dickey                                                *
+  ****************************************************************************/
+ 
+ /*
+@@ -40,23 +40,38 @@
+ #include <curses.priv.h>
+ #include <term.h>
+ 
+-MODULE_ID("$Id: lib_get_wstr.c,v 1.6 2003/05/17 21:33:03 tom Exp $")
++MODULE_ID("$Id: lib_get_wstr.c,v 1.8 2004/10/16 21:55:36 tom Exp $")
++
++static int
++wadd_wint(WINDOW *win, wint_t *src)
++{
++    cchar_t tmp;
++    wchar_t wch[2];
++
++    wch[0] = *src;
++    wch[1] = 0;
++    setcchar(&tmp, wch, A_NORMAL, 0, NULL);
++    return wadd_wch(win, &tmp);
++}
+ 
+ /*
+  * This wipes out the last character, no matter whether it was a tab, control
+  * or other character, and handles reverse wraparound.
+  */
+-static wchar_t *
+-WipeOut(WINDOW *win, int y, int x, wchar_t * first, wchar_t * last, bool echoed)
++static wint_t *
++WipeOut(WINDOW *win, int y, int x, wint_t *first, wint_t *last, bool echoed)
+ {
+     if (last > first) {
+ 	*--last = '\0';
+ 	if (echoed) {
+ 	    int y1 = win->_cury;
+ 	    int x1 = win->_curx;
++	    int n;
+ 
+ 	    wmove(win, y, x);
+-	    waddwstr(win, first);
++	    for (n = 0; first[n] != 0; ++n) {
++		wadd_wint(win, first + n);
++	    }
+ 	    getyx(win, y, x);
+ 	    while (win->_cury < y1
+ 		   || (win->_cury == y1 && win->_curx < x1))
+@@ -69,14 +84,14 @@
+ }
+ 
+ NCURSES_EXPORT(int)
+-wgetn_wstr(WINDOW *win, wint_t * str, int maxlen)
++wgetn_wstr(WINDOW *win, wint_t *str, int maxlen)
+ {
+     TTY buf;
+     bool oldnl, oldecho, oldraw, oldcbreak;
+     wint_t erasec;
+     wint_t killc;
+-    wchar_t *oldstr;
+-    wchar_t *tmpstr;
++    wint_t *oldstr = str;
++    wint_t *tmpstr = str;
+     wint_t ch;
+     int y, x, code;
+ 
+@@ -99,10 +114,6 @@
+     erasec = erasechar();
+     killc = killchar();
+ 
+-    assert(sizeof(wchar_t) == sizeof(wint_t));
+-    oldstr = (wchar_t *) str;
+-    tmpstr = (wchar_t *) str;
+-
+     getyx(win, y, x);
+ 
+     if (is_wintouched(win) || (win->_flags & _HASMOVED))
+@@ -160,10 +171,8 @@
+ 	    *tmpstr = 0;
+ 	    if (oldecho == TRUE) {
+ 		int oldy = win->_cury;
+-		cchar_t tmp;
+ 
+-		setcchar(&tmp, tmpstr - 1, A_NORMAL, 0, NULL);
+-		if (wadd_wch(win, &tmp) == ERR) {
++		if (wadd_wint(win, tmpstr - 1) == ERR) {
+ 		    /*
+ 		     * We can't really use the lower-right corner for input,
+ 		     * since it'll mess up bookkeeping for erases.
+@@ -210,13 +219,13 @@
+     *tmpstr = 0;
+     if (code == ERR) {
+ 	if (tmpstr == oldstr) {
+-	    *tmpstr++ = (wchar_t) WEOF;
++	    *tmpstr++ = WEOF;
+ 	    *tmpstr = 0;
+ 	}
+ 	returnCode(ERR);
+     }
+ 
+-    T(("wgetn_wstr returns %s", _nc_viswbuf(oldstr)));
++    T(("wgetn_wstr returns %s", _nc_viswibuf(oldstr)));
+ 
+     returnCode(OK);
+ }
+Index: ncurses/widechar/lib_in_wch.c
+Prereq:  1.2 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_in_wch.c	2002-08-03 20:23:29.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_in_wch.c	2004-05-16 00:13:52.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
++ * Copyright (c) 2002,2004 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- * Author: Thomas Dickey 2002                                               *
++ * Author: Thomas Dickey 2002,2004                                          *
+  ****************************************************************************/
+ 
+ /*
+@@ -39,7 +39,7 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_in_wch.c,v 1.2 2002/08/03 20:23:29 tom Exp $")
++MODULE_ID("$Id: lib_in_wch.c,v 1.3 2004/05/16 00:13:52 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ win_wch(WINDOW *win, cchar_t * wcval)
+@@ -56,5 +56,6 @@
+     } else {
+ 	code = ERR;
+     }
+-    returnCode(code);
++    TR(TRACE_CCALLS, (T_RETURN("%d"), code));
++    return (code);
+ }
+Index: ncurses/widechar/lib_in_wchnstr.c
+Prereq:  1.2 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_in_wchnstr.c	2002-08-03 20:38:45.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_in_wchnstr.c	2004-05-16 00:12:30.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
++ * Copyright (c) 2002,2004 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- * Author: Thomas Dickey 2002                                               *
++ * Author: Thomas Dickey 2002,2004                                          *
+  ****************************************************************************/
+ 
+ /*
+@@ -39,22 +39,28 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_in_wchnstr.c,v 1.2 2002/08/03 20:38:45 tom Exp $")
++MODULE_ID("$Id: lib_in_wchnstr.c,v 1.3 2004/05/16 00:12:30 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+ win_wchnstr(WINDOW *win, cchar_t * wchstr, int n)
+ {
+     int code = OK;
+ 
+-    TR(TRACE_CCALLS, (T_CALLED("win_wchnstr(%p,%p,%d)"), win, wchstr, n));
++    TR(TRACE_CALLS, (T_CALLED("win_wchnstr(%p,%p,%d)"), win, wchstr, n));
+     if (win != 0
+ 	&& wchstr != 0) {
++	int row, col;
++	int j;
++
++	getyx(win, row, col);
+ 
+ 	if (n < 0) {
+ 	    n = getmaxx(win) + 1 - getcurx(win);
+ 	}
+-	while (n-- > 0)
+-	    win_wch(win, wchstr++);
++	for (j = 0; j < n; ++j) {
++	    wchstr[j] = win->_line[row].text[col + j];
++	}
++	T(("result = %s", _nc_viscbuf(wchstr, n)));
+     } else {
+ 	code = ERR;
+     }
+Index: ncurses/widechar/lib_ins_wch.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_ins_wch.c	2003-03-29 21:52:29.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_ins_wch.c	2005-02-26 20:02:40.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002,2003 Free Software Foundation, Inc.                   *
++ * Copyright (c) 2002-2003,2005 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            *
+@@ -39,20 +39,25 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_ins_wch.c,v 1.3 2003/03/29 21:52:29 tom Exp $")
++MODULE_ID("$Id: lib_ins_wch.c,v 1.5 2005/02/26 20:02:40 tom Exp $")
+ 
+ /*
+  * Insert the given character, updating the current location to simplify
+  * inserting a string.
+  */
+-static void
+-_nc_insert_wch(WINDOW *win, const cchar_t * wch)
++static int
++_nc_insert_wch(WINDOW *win, const cchar_t *wch)
+ {
++    int cells = wcwidth(CharOf(CHDEREF(wch)));
++
++    if (cells <= 0)
++	cells = 1;
++
+     if (win->_curx <= win->_maxx) {
+ 	struct ldat *line = &(win->_line[win->_cury]);
+ 	NCURSES_CH_T *end = &(line->text[win->_curx]);
+ 	NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
+-	NCURSES_CH_T *temp2 = temp1 - 1;
++	NCURSES_CH_T *temp2 = temp1 - cells;
+ 
+ 	CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+ 	while (temp1 > end)
+@@ -62,10 +67,11 @@
+ 
+ 	win->_curx++;
+     }
++    return OK;
+ }
+ 
+ NCURSES_EXPORT(int)
+-wins_wch(WINDOW *win, const cchar_t * wch)
++wins_wch(WINDOW *win, const cchar_t *wch)
+ {
+     NCURSES_SIZE_T oy;
+     NCURSES_SIZE_T ox;
+@@ -77,18 +83,17 @@
+ 	oy = win->_cury;
+ 	ox = win->_curx;
+ 
+-	_nc_insert_wch(win, wch);
++	code = _nc_insert_wch(win, wch);
+ 
+ 	win->_curx = ox;
+ 	win->_cury = oy;
+ 	_nc_synchook(win);
+-	code = OK;
+     }
+     returnCode(code);
+ }
+ 
+ NCURSES_EXPORT(int)
+-wins_nwstr(WINDOW *win, const wchar_t * wstr, int n)
++wins_nwstr(WINDOW *win, const wchar_t *wstr, int n)
+ {
+     int code = ERR;
+     NCURSES_SIZE_T oy;
+@@ -101,11 +106,14 @@
+ 	&& wstr != 0) {
+ 	if (n < 1)
+ 	    n = wcslen(wstr);
++	code = OK;
+ 	if (n > 0) {
+ 	    oy = win->_cury;
+ 	    ox = win->_curx;
+ 	    for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
+-		if (wcwidth(*cp) > 1) {
++		int len = wcwidth(*cp);
++
++		if (len != 1) {
+ 		    cchar_t tmp_cchar;
+ 		    wchar_t tmp_wchar = *cp;
+ 		    memset(&tmp_cchar, 0, sizeof(tmp_cchar));
+@@ -114,17 +122,19 @@
+ 				    WA_NORMAL,
+ 				    0,
+ 				    (void *) 0);
+-		    _nc_insert_wch(win, &tmp_cchar);
++		    code = _nc_insert_wch(win, &tmp_cchar);
+ 		} else {
+-		    _nc_insert_ch(win, *cp);	/* tabs, other ASCII stuff */
++		    /* tabs, other ASCII stuff */
++		    code = _nc_insert_ch(win, *cp);
+ 		}
++		if (code != OK)
++		    break;
+ 	    }
+ 
+ 	    win->_curx = ox;
+ 	    win->_cury = oy;
+ 	    _nc_synchook(win);
+ 	}
+-	code = OK;
+     }
+     returnCode(code);
+ }
+Index: ncurses/widechar/lib_inwstr.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_inwstr.c	2002-10-06 00:56:36.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_inwstr.c	2004-10-23 20:41:28.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
++ * Copyright (c) 2002,2004 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- * Author: Thomas Dickey 2002                                               *
++ * Author: Thomas Dickey                                                    *
+  ****************************************************************************/
+ 
+ /*
+@@ -39,10 +39,10 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_inwstr.c,v 1.3 2002/10/06 00:56:36 tom Exp $")
++MODULE_ID("$Id: lib_inwstr.c,v 1.4 2004/10/23 20:41:28 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-winnwstr(WINDOW *win, wchar_t * wstr, int n)
++winnwstr(WINDOW *win, wchar_t *wstr, int n)
+ {
+     int row, col, inx;
+     int count = 0;
+@@ -57,7 +57,7 @@
+ 
+ 	    text = win->_line[row].text;
+ 	    while (count < n && count != ERR) {
+-		if (!isnac(text[col])) {
++		if (!isWidecExt(text[col])) {
+ 		    for (inx = 0; (inx < CCHARW_MAX)
+ 			 && ((wch = text[col].chars[inx]) != 0);
+ 			 ++inx) {
+@@ -90,7 +90,7 @@
+  * it does not define what happens for a negative count with winnwstr().
+  */
+ NCURSES_EXPORT(int)
+-winwstr(WINDOW *win, wchar_t * wstr)
++winwstr(WINDOW *win, wchar_t *wstr)
+ {
+     int result = OK;
+     T((T_CALLED("winwstr(%p,%p)"), win, wstr));
+Index: ncurses/widechar/lib_slk_wset.c
+Prereq:  1.6 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_slk_wset.c	2004-01-03 21:14:03.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_slk_wset.c	2005-01-16 01:03:53.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2003,2004 Free Software Foundation, Inc.                   *
++ * Copyright (c) 2003-2004,2005 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey, 2003                                          *
++ *  Author: Thomas E. Dickey                                                *
+  ****************************************************************************/
+ 
+ /*
+@@ -36,114 +36,37 @@
+  */
+ #include <curses.priv.h>
+ 
+-#ifdef HAVE_WCTYPE_H
++#if HAVE_WCTYPE_H
+ #include <wctype.h>
+ #endif
+ 
+-MODULE_ID("$Id: lib_slk_wset.c,v 1.6 2004/01/03 21:14:03 tom Exp $")
++MODULE_ID("$Id: lib_slk_wset.c,v 1.11 2005/01/16 01:03:53 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-slk_wset(int i, const wchar_t * astr, int format)
++slk_wset(int i, const wchar_t *astr, int format)
+ {
+-    static wchar_t empty[] =
+-    {L'\0'};
+     int result = ERR;
+-    SLK *slk = SP->_slk;
+-    int offset;
+     size_t arglen;
+-    const wchar_t *p;
++    const wchar_t *str;
++    char *mystr;
++    mbstate_t state;
+ 
+     T((T_CALLED("slk_wset(%d, %s, %d)"), i, _nc_viswbuf(astr), format));
+ 
+-    if (astr == 0)
+-	astr = empty;
+-    arglen = wcslen(astr);
+-    while (iswspace(*astr)) {
+-	--arglen;
+-	++astr;			/* skip over leading spaces  */
+-    }
+-    p = astr;
+-    while (iswprint(*p))
+-	p++;			/* The first non-print stops */
+-
+-    arglen = (size_t) (p - astr);
+-
+-    if (slk != NULL &&
+-	i >= 1 &&
+-	i <= slk->labcnt &&
+-	format >= 0 &&
+-	format <= 2) {
+-	char *new_text;
+-	size_t n;
+-	size_t used = 0;
+-	int mycols;
+-	mbstate_t state;
+-
+-	--i;			/* Adjust numbering of labels */
+-
+-	/*
+-	 * Reduce the actual number of columns to fit in the label field.
+-	 */
+-	while (arglen != 0 && wcswidth(astr, arglen) > slk->maxlen) {
+-	    --arglen;
+-	}
+-	mycols = wcswidth(astr, arglen);
+-
+-	/*
+-	 * translate the wide-character string to multibyte form.
+-	 */
+-	memset(&state, 0, sizeof(state));
+-
+-	if ((new_text = (char *) _nc_doalloc(0, MB_LEN_MAX * arglen)) == 0)
+-	    returnCode(ERR);
+-
+-	for (n = 0; n < arglen; ++n) {
+-	    used += wcrtomb(new_text + used, astr[n], &state);
+-	}
+-	new_text[used] = '\0';
+-
+-	if (used >= (size_t) (slk->maxlen + 1)) {
+-	    if ((slk->ent[i].ent_text = (char *) _nc_doalloc(slk->ent[i].ent_text,
+-							     used + 1)) == 0)
+-		returnCode(ERR);
+-	    if ((slk->ent[i].form_text = (char *) _nc_doalloc(slk->ent[i].form_text,
+-							      used + 1)) == 0)
+-		returnCode(ERR);
+-	}
+-
+-	(void) strcpy(slk->ent[i].ent_text, new_text);
+-	free(new_text);
+-
+-	sprintf(slk->ent[i].form_text, "%*s", (size_t) slk->maxlen, " ");
+-
+-	switch (format) {
+-	default:
+-	case 0:		/* left-aligned */
+-	    offset = 0;
+-	    break;
+-	case 1:		/* centered */
+-	    offset = (slk->maxlen - mycols) / 2;
+-	    break;
+-	case 2:		/* right-aligned */
+-	    offset = slk->maxlen - mycols;
+-	    break;
+-	}
+-	if (offset < 0)
+-	    offset = 0;
+-	strcpy(slk->ent[i].form_text + offset,
+-	       slk->ent[i].ent_text);
+-	/*
+-	 * Pad the display with blanks on the right, unless it is already
+-	 * right-aligned.
+-	 */
+-	if (format != 2 && mycols < slk->maxlen) {
+-	    sprintf(slk->ent[i].form_text + offset + used,
+-		    "%*s",
+-		    slk->maxlen - (mycols - offset),
+-		    " ");
++    init_mb(state);
++    str = astr;
++    if ((arglen = wcsrtombs(NULL, &str, 0, &state)) != (size_t) -1) {
++	if ((mystr = (char *) _nc_doalloc(0, arglen + 1)) != 0) {
++	    str = astr;
++	    if (wcsrtombs(mystr, &str, arglen, &state) != (size_t) -1) {
++		/* glibc documentation claims that the terminating L'\0'
++		 * is written, but it is not...
++		 */
++		mystr[arglen] = 0;
++		result = slk_set(i, mystr, format);
++	    }
++	    free(mystr);
+ 	}
+-	slk->ent[i].dirty = TRUE;
+-	result = OK;
+     }
+     returnCode(result);
+ }
+Index: ncurses/widechar/lib_unget_wch.c
+Prereq:  1.5 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_unget_wch.c	2003-07-05 19:46:51.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_unget_wch.c	2004-12-05 01:21:31.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002,2003 Free Software Foundation, Inc.                        *
++ * Copyright (c) 2002-2003,2004 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            *
+@@ -39,7 +39,26 @@
+ 
+ #include <curses.priv.h>
+ 
+-MODULE_ID("$Id: lib_unget_wch.c,v 1.5 2003/07/05 19:46:51 tom Exp $")
++MODULE_ID("$Id: lib_unget_wch.c,v 1.7 2004/12/05 01:21:31 tom Exp $")
++
++#ifdef linux
++/*
++ * glibc's wcrtomb() function is broken - does not return the proper value
++ * when target is null (noted for glibc 2.3.2).  This is a workaround.
++ */
++NCURSES_EXPORT(size_t)
++_nc_wcrtomb(char *target, wchar_t source, mbstate_t * state)
++{
++    if (target == 0) {
++	wchar_t temp[2];
++	const wchar_t *tempp = temp;
++	temp[0] = source;
++	temp[1] = 0;
++	return wcsrtombs(NULL, &tempp, 0, state);
++    }
++    return wcrtomb(target, source, state);
++}
++#endif
+ 
+ NCURSES_EXPORT(int)
+ unget_wch(const wchar_t wch)
+@@ -51,15 +70,15 @@
+ 
+     T((T_CALLED("unget_wch(%#lx)"), (unsigned long) wch));
+ 
+-    memset(&state, 0, sizeof(state));
+-    length = wcrtomb(0, wch, &state);
++    init_mb(state);
++    length = _nc_wcrtomb(0, wch, &state);
+ 
+     if (length != (size_t) (-1)
+ 	&& length != 0) {
+ 	char *string;
+ 
+ 	if ((string = (char *) malloc(length)) != 0) {
+-	    memset(&state, 0, sizeof(state));
++	    init_mb(state);
+ 	    wcrtomb(string, wch, &state);
+ 
+ 	    for (n = (int) (length - 1); n >= 0; --n) {
+Index: ncurses/widechar/lib_vid_attr.c
+Prereq:  1.1 
+--- ncurses-5.4-20040208/ncurses/widechar/lib_vid_attr.c	2002-05-11 20:55:26.000000000 +0000
++++ ncurses-5.4-20050319/ncurses/widechar/lib_vid_attr.c	2005-01-29 18:34:00.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
++ * Copyright (c) 2002-2004,2005 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            *
+@@ -27,68 +27,248 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey 2002                                           *
++ *  Author: Thomas E. Dickey                                                *
+  ****************************************************************************/
+ 
+ #include <curses.priv.h>
+ #include <term.h>
+ 
+-MODULE_ID("$Id: lib_vid_attr.c,v 1.1 2002/05/11 20:55:26 tom Exp $")
++MODULE_ID("$Id: lib_vid_attr.c,v 1.3 2005/01/29 18:34:00 tom Exp $")
+ 
+-#define set_color(mode, pair) mode &= ~A_COLOR; mode |= COLOR_PAIR(pair)
++#define doPut(mode) TPUTS_TRACE(#mode); tputs(mode, 1, outc)
++
++#define TurnOn(mask,mode) \
++	if ((turn_on & mask) && mode) { doPut(mode); }
++
++#define TurnOff(mask,mode) \
++	if ((turn_off & mask) && mode) { doPut(mode); turn_off &= ~mask; }
++
++	/* if there is no current screen, assume we *can* do color */
++#define SetColorsIf(why, old_attr, old_pair) \
++	if (can_color && (why)) { \
++		TR(TRACE_ATTRS, ("old pair = %d -- new pair = %d", old_pair, pair)); \
++		if ((pair != old_pair) \
++		 || (fix_pair0 && (pair == 0)) \
++		 || (reverse ^ ((old_attr & A_REVERSE) != 0))) { \
++			_nc_do_color(old_pair, pair, reverse, outc); \
++		} \
++	}
++
++#define set_color(mode, pair) mode &= ALL_BUT_COLOR; mode |= COLOR_PAIR(pair)
+ 
+ NCURSES_EXPORT(int)
+ vid_puts(attr_t newmode, short pair, void *opts GCC_UNUSED, int (*outc) (int))
+ {
++#if NCURSES_EXT_COLORS
++    static attr_t previous_attr = A_NORMAL;
++    static int previous_pair = 0;
++
++    attr_t turn_on, turn_off;
++    bool reverse = FALSE;
++    bool can_color = (SP == 0 || SP->_coloron);
++#if NCURSES_EXT_FUNCS
++    bool fix_pair0 = (SP != 0 && SP->_coloron && !SP->_default_color);
++#else
++#define fix_pair0 FALSE
++#endif
++
++    T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair));
++
++    /* this allows us to go on whether or not newterm() has been called */
++    if (SP) {
++	previous_attr = AttrOf(SCREEN_ATTRS(SP));
++	previous_pair = GetPair(SCREEN_ATTRS(SP));
++    }
++
++    TR(TRACE_ATTRS, ("previous attribute was %s, %d",
++		     _traceattr(previous_attr), previous_pair));
++
++#if !USE_XMC_SUPPORT
++    if ((SP != 0)
++	&& (magic_cookie_glitch > 0))
++	newmode &= ~(SP->_xmc_suppress);
++#endif
++
++    /*
++     * If we have a terminal that cannot combine color with video
++     * attributes, use the colors in preference.
++     */
++    if ((pair != 0
++	 || fix_pair0)
++	&& (no_color_video > 0)) {
++	/*
++	 * If we had chosen the A_xxx definitions to correspond to the
++	 * no_color_video mask, we could simply shift it up and mask off the
++	 * attributes.  But we did not (actually copied Solaris' definitions).
++	 * However, this is still simpler/faster than a lookup table.
++	 *
++	 * The 63 corresponds to A_STANDOUT, A_UNDERLINE, A_REVERSE, A_BLINK,
++	 * A_DIM, A_BOLD which are 1:1 with no_color_video.  The bits that
++	 * correspond to A_INVIS, A_PROTECT (192) must be shifted up 1 and
++	 * A_ALTCHARSET (256) down 2 to line up.  We use the NCURSES_BITS
++	 * macro so this will work properly for the wide-character layout.
++	 */
++	unsigned value = no_color_video;
++	attr_t mask = NCURSES_BITS((value & 63)
++				   | ((value & 192) << 1)
++				   | ((value & 256) >> 2), 8);
++
++	if ((mask & A_REVERSE) != 0
++	    && (newmode & A_REVERSE) != 0) {
++	    reverse = TRUE;
++	    mask &= ~A_REVERSE;
++	}
++	newmode &= ~mask;
++    }
++
++    if (newmode == previous_attr
++	&& pair == previous_pair)
++	returnCode(OK);
++
++    if (reverse) {
++	newmode &= ~A_REVERSE;
++    }
++
++    turn_off = (~newmode & previous_attr) & ALL_BUT_COLOR;
++    turn_on = (newmode & ~previous_attr) & ALL_BUT_COLOR;
++
++    SetColorsIf(((pair == 0) && !fix_pair0), previous_attr, previous_pair);
++
++    if (newmode == A_NORMAL) {
++	if ((previous_attr & A_ALTCHARSET) && exit_alt_charset_mode) {
++	    doPut(exit_alt_charset_mode);
++	    previous_attr &= ~A_ALTCHARSET;
++	}
++	if (previous_attr) {
++	    if (exit_attribute_mode) {
++		doPut(exit_attribute_mode);
++	    } else {
++		if (!SP || SP->_use_rmul) {
++		    TurnOff(A_UNDERLINE, exit_underline_mode);
++		}
++		if (!SP || SP->_use_rmso) {
++		    TurnOff(A_STANDOUT, exit_standout_mode);
++		}
++	    }
++	    previous_attr &= ALL_BUT_COLOR;
++	    previous_pair = 0;
++	}
++
++	SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
++    } else if (set_attributes) {
++	if (turn_on || turn_off) {
++	    TPUTS_TRACE("set_attributes");
++	    tputs(tparm(set_attributes,
++			(newmode & A_STANDOUT) != 0,
++			(newmode & A_UNDERLINE) != 0,
++			(newmode & A_REVERSE) != 0,
++			(newmode & A_BLINK) != 0,
++			(newmode & A_DIM) != 0,
++			(newmode & A_BOLD) != 0,
++			(newmode & A_INVIS) != 0,
++			(newmode & A_PROTECT) != 0,
++			(newmode & A_ALTCHARSET) != 0), 1, outc);
++	    previous_attr &= ALL_BUT_COLOR;
++	    previous_pair = 0;
++	}
++	SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
++    } else {
++
++	TR(TRACE_ATTRS, ("turning %s off", _traceattr(turn_off)));
++
++	TurnOff(A_ALTCHARSET, exit_alt_charset_mode);
++
++	if (!SP || SP->_use_rmul) {
++	    TurnOff(A_UNDERLINE, exit_underline_mode);
++	}
++
++	if (!SP || SP->_use_rmso) {
++	    TurnOff(A_STANDOUT, exit_standout_mode);
++	}
++
++	if (turn_off && exit_attribute_mode) {
++	    doPut(exit_attribute_mode);
++	    turn_on |= (newmode & ALL_BUT_COLOR);
++	    previous_attr &= ALL_BUT_COLOR;
++	    previous_pair = 0;
++	}
++	SetColorsIf((pair != 0) || fix_pair0, previous_attr, previous_pair);
++
++	TR(TRACE_ATTRS, ("turning %s on", _traceattr(turn_on)));
++	/* *INDENT-OFF* */
++	TurnOn(A_ALTCHARSET,	enter_alt_charset_mode);
++	TurnOn(A_BLINK,		enter_blink_mode);
++	TurnOn(A_BOLD,		enter_bold_mode);
++	TurnOn(A_DIM,		enter_dim_mode);
++	TurnOn(A_REVERSE,	enter_reverse_mode);
++	TurnOn(A_STANDOUT,	enter_standout_mode);
++	TurnOn(A_PROTECT,	enter_protected_mode);
++	TurnOn(A_INVIS,		enter_secure_mode);
++	TurnOn(A_UNDERLINE,	enter_underline_mode);
++#if USE_WIDEC_SUPPORT
++	TurnOn(A_HORIZONTAL,	enter_horizontal_hl_mode);
++	TurnOn(A_LEFT,		enter_left_hl_mode);
++	TurnOn(A_LOW,		enter_low_hl_mode);
++	TurnOn(A_RIGHT,		enter_right_hl_mode);
++	TurnOn(A_TOP,		enter_top_hl_mode);
++	TurnOn(A_VERTICAL,	enter_vertical_hl_mode);
++#endif
++	/* *INDENT-ON* */
++
++    }
++
++    if (reverse)
++	newmode |= A_REVERSE;
++
++    if (SP) {
++	SetAttr(SCREEN_ATTRS(SP), newmode);
++	SetPair(SCREEN_ATTRS(SP), pair);
++    } else {
++	previous_attr = newmode;
++	previous_pair = pair;
++    }
++
++    returnCode(OK);
++#else
+     T((T_CALLED("vid_puts(%s,%d)"), _traceattr(newmode), pair));
+     set_color(newmode, pair);
+     returnCode(vidputs(newmode, outc));
++#endif
+ }
+ 
+ #undef vid_attr
+ NCURSES_EXPORT(int)
+-vid_attr(attr_t newmode, short pair, void *opts GCC_UNUSED)
++vid_attr(attr_t newmode, short pair, void *opts)
+ {
+     T((T_CALLED("vid_attr(%s,%d)"), _traceattr(newmode), pair));
+-    set_color(newmode, pair);
+-    returnCode(vidputs(newmode, _nc_outch));
++    returnCode(vid_puts(newmode, pair, opts, _nc_outch));
+ }
+ 
++/*
++ * This implementation uses the same mask values for A_xxx and WA_xxx, so
++ * we can use termattrs() for part of the logic.
++ */
+ NCURSES_EXPORT(attr_t)
+ term_attrs(void)
+ {
+-    attr_t attrs = WA_NORMAL;
++    attr_t attrs;
+ 
+     T((T_CALLED("term_attrs()")));
+-    if (enter_alt_charset_mode)
+-	attrs |= WA_ALTCHARSET;
+-
+-    if (enter_blink_mode)
+-	attrs |= WA_BLINK;
+-
+-    if (enter_bold_mode)
+-	attrs |= WA_BOLD;
+-
+-    if (enter_dim_mode)
+-	attrs |= WA_DIM;
+-
+-    if (enter_reverse_mode)
+-	attrs |= WA_REVERSE;
+-
+-    if (enter_standout_mode)
+-	attrs |= WA_STANDOUT;
+-
+-    if (enter_protected_mode)
+-	attrs |= WA_PROTECT;
+-
+-    if (enter_secure_mode)
+-	attrs |= WA_INVIS;
+-
+-    if (enter_underline_mode)
+-	attrs |= WA_UNDERLINE;
++    attrs = termattrs();
+ 
+-    if (SP->_coloron)
+-	attrs |= A_COLOR;
++    /* these are only supported for wide-character mode */
++    if (enter_horizontal_hl_mode)
++	attrs |= WA_HORIZONTAL;
++    if (enter_left_hl_mode)
++	attrs |= WA_LEFT;
++    if (enter_low_hl_mode)
++	attrs |= WA_LOW;
++    if (enter_right_hl_mode)
++	attrs |= WA_RIGHT;
++    if (enter_top_hl_mode)
++	attrs |= WA_TOP;
++    if (enter_vertical_hl_mode)
++	attrs |= WA_VERTICAL;
+ 
+     returnAttr(attrs);
+ }
+Index: panel/llib-lpanel
+--- ncurses-5.4-20040208/panel/llib-lpanel	2002-08-31 20:02:07.000000000 +0000
++++ ncurses-5.4-20050319/panel/llib-lpanel	2005-03-05 19:54:50.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2002 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2002,2005 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey <dickey@clark.net> 1997,2002                   *
++ *  Author: Thomas E. Dickey        1997,2002,2005                          *
+  ****************************************************************************/
+ /* LINTLIBRARY */
+ 
+@@ -35,6 +35,11 @@
+ 
+ #include "panel.priv.h"
+ 
++#undef _nc_retrace_panel
++PANEL	*_nc_retrace_panel(
++		PANEL	*pan)
++		{ return(*(PANEL **)0); }
++
+ #undef _nc_my_visbuf
+ const char *_nc_my_visbuf(
+ 		const void *ptr)
+Index: panel/llib-lpanelw
+--- ncurses-5.4-20040208/panel/llib-lpanelw	2002-08-31 21:55:11.000000000 +0000
++++ ncurses-5.4-20050319/panel/llib-lpanelw	2005-03-05 19:36:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
++ * Copyright (c) 2002,2005 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            *
+@@ -27,7 +27,7 @@
+  ****************************************************************************/
+ 
+ /****************************************************************************
+- *  Author: Thomas E. Dickey <dickey@clark.net> 2002                        *
++ *  Author: Thomas E. Dickey                    2002,2005                   *
+  ****************************************************************************/
+ /* LINTLIBRARY */
+ 
+@@ -35,6 +35,11 @@
+ 
+ #include "panel.priv.h"
+ 
++#undef _nc_retrace_panel
++PANEL	*_nc_retrace_panel(
++		PANEL	*pan)
++		{ return(*(PANEL **)0); }
++
+ #undef _nc_my_visbuf
+ const char *_nc_my_visbuf(
+ 		const void *ptr)
+Index: panel/p_above.c
+Prereq:  1.4 
+--- ncurses-5.4-20040208/panel/p_above.c	2000-12-10 02:20:44.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_above.c	2005-02-19 16:44:57.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -35,17 +35,18 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_above.c,v 1.4 2000/12/10 02:20:44 tom Exp $")
++MODULE_ID("$Id: p_above.c,v 1.6 2005/02/19 16:44:57 tom Exp $")
+ 
+ NCURSES_EXPORT(PANEL *)
+-panel_above (const PANEL *pan)
++panel_above(const PANEL * pan)
+ {
+-  if(!pan)
++  T((T_CALLED("panel_above(%p)"), pan));
++  if (!pan)
+     {
+       /* if top and bottom are equal, we have no or only the pseudo panel;
+-	 if not, we return the panel above the pseudo panel */
+-      return(EMPTY_STACK() ? (PANEL*)0 : _nc_bottom_panel->above);
++         if not, we return the panel above the pseudo panel */
++      returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_bottom_panel->above);
+     }
+   else
+-    return(pan->above);
++    returnPanel(pan->above);
+ }
+Index: panel/p_below.c
+Prereq:  1.4 
+--- ncurses-5.4-20040208/panel/p_below.c	2000-12-10 02:20:44.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_below.c	2005-02-19 16:45:10.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -35,19 +35,20 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_below.c,v 1.4 2000/12/10 02:20:44 tom Exp $")
++MODULE_ID("$Id: p_below.c,v 1.6 2005/02/19 16:45:10 tom Exp $")
+ 
+-NCURSES_EXPORT(PANEL*)
+-panel_below (const PANEL *pan)
++NCURSES_EXPORT(PANEL *)
++panel_below(const PANEL * pan)
+ {
+-  if(!pan)
++  T((T_CALLED("panel_below(%p)"), pan));
++  if (!pan)
+     {
+       /* if top and bottom are equal, we have no or only the pseudo panel */
+-      return(EMPTY_STACK() ? (PANEL*)0 : _nc_top_panel);
++      returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_top_panel);
+     }
+   else
+     {
+       /* we must not return the pseudo panel */
+-      return(Is_Pseudo(pan->below) ? (PANEL*) 0 : pan->below);
++      returnPanel(Is_Pseudo(pan->below) ? (PANEL *) 0 : pan->below);
+     }
+ }
+Index: panel/p_bottom.c
+Prereq:  1.9 
+--- ncurses-5.4-20040208/panel/p_bottom.c	2001-02-24 23:46:33.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_bottom.c	2005-02-19 16:38:16.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,35 +36,37 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_bottom.c,v 1.9 2001/02/24 23:46:33 tom Exp $")
++MODULE_ID("$Id: p_bottom.c,v 1.11 2005/02/19 16:38:16 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-bottom_panel (PANEL *pan)
++bottom_panel(PANEL * pan)
+ {
+   int err = OK;
+ 
+-  if (pan) {
++  T((T_CALLED("bottom_panel(%p)"), pan));
++  if (pan)
++    {
++      if (!Is_Bottom(pan))
++	{
++
++	  dBug(("--> bottom_panel %s", USER_PTR(pan->user)));
++
++	  HIDE_PANEL(pan, err, OK);
++	  assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
++
++	  dStack("<lb%d>", 1, pan);
++
++	  pan->below = _nc_bottom_panel;
++	  pan->above = _nc_bottom_panel->above;
++	  if (pan->above)
++	    pan->above->below = pan;
++	  _nc_bottom_panel->above = pan;
+ 
+-    if(!Is_Bottom(pan)) {
+-      
+-      dBug(("--> bottom_panel %s", USER_PTR(pan->user)));
+-     
+-      HIDE_PANEL(pan,err,OK);
+-      assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
+-      
+-      dStack("<lb%d>",1,pan);      
+-      
+-      pan->below = _nc_bottom_panel;
+-      pan->above = _nc_bottom_panel->above;
+-      if (pan->above)
+-	pan->above->below = pan;
+-      _nc_bottom_panel->above = pan;
+-      
+-      dStack("<lb%d>",9,pan);
++	  dStack("<lb%d>", 9, pan);
++	}
+     }
+-  }
+   else
+     err = ERR;
+-  
+-  return(err);
++
++  returnCode(err);
+ }
+Index: panel/p_delete.c
+Prereq:  1.6 
+--- ncurses-5.4-20040208/panel/p_delete.c	2001-02-24 23:46:41.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_delete.c	2005-02-19 16:38:45.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,19 +36,22 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_delete.c,v 1.6 2001/02/24 23:46:41 tom Exp $")
++MODULE_ID("$Id: p_delete.c,v 1.8 2005/02/19 16:38:45 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-del_panel (PANEL *pan)
++del_panel(PANEL * pan)
+ {
+   int err = OK;
+-  if(pan)
++
++  T((T_CALLED("del_panel(%p)"), pan));
++  if (pan)
+     {
+       dBug(("--> del_panel %s", USER_PTR(pan->user)));
+-      HIDE_PANEL(pan,err,OK);
++      HIDE_PANEL(pan, err, OK);
+       free((void *)pan);
+     }
+   else
+     err = ERR;
+-  return(err);
++
++  returnCode(err);
+ }
+Index: panel/p_hidden.c
+Prereq:  1.5 
+--- ncurses-5.4-20040208/panel/p_hidden.c	2000-12-10 02:20:44.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_hidden.c	2005-02-19 16:39:17.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,12 +36,13 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_hidden.c,v 1.5 2000/12/10 02:20:44 tom Exp $")
++MODULE_ID("$Id: p_hidden.c,v 1.7 2005/02/19 16:39:17 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-panel_hidden (const PANEL *pan)
++panel_hidden(const PANEL * pan)
+ {
+-  if(!pan)
+-    return(ERR);
+-  return(IS_LINKED(pan) ? FALSE : TRUE);
+-} 
++  T((T_CALLED("panel_hidden(%p)"), pan));
++  if (!pan)
++    returnCode(ERR);
++  returnCode(IS_LINKED(pan) ? FALSE : TRUE);
++}
+Index: panel/p_hide.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/panel/p_hide.c	2001-02-24 23:46:45.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_hide.c	2005-02-19 16:39:41.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,22 +36,23 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_hide.c,v 1.7 2001/02/24 23:46:45 tom Exp $")
++MODULE_ID("$Id: p_hide.c,v 1.9 2005/02/19 16:39:41 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-hide_panel (register PANEL *pan)
++hide_panel(register PANEL * pan)
+ {
+   int err = OK;
+ 
+-  if(!pan)
+-    return(ERR);
++  T((T_CALLED("hide_panel(%p)"), pan));
++  if (!pan)
++    returnCode(ERR);
+ 
+   dBug(("--> hide_panel %s", USER_PTR(pan->user)));
+-  dStack("<u%d>",1,pan);
++  dStack("<u%d>", 1, pan);
+ 
+-  HIDE_PANEL(pan,err,ERR);
++  HIDE_PANEL(pan, err, ERR);
+ 
+-  dStack("<u%d>",9,pan);
++  dStack("<u%d>", 9, pan);
+ 
+-  return(err);
++  returnCode(err);
+ }
+Index: panel/p_move.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/panel/p_move.c	2001-02-24 23:41:35.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_move.c	2005-02-19 16:46:49.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,21 +36,21 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_move.c,v 1.7 2001/02/24 23:41:35 tom Exp $")
++MODULE_ID("$Id: p_move.c,v 1.9 2005/02/19 16:46:49 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-move_panel (PANEL *pan, int starty, int startx)
++move_panel(PANEL * pan, int starty, int startx)
+ {
+-  if(!pan)
+-    return(ERR);
++  T((T_CALLED("move_panel(%p,%d,%d)"), pan, starty, startx));
+ 
+-  if (IS_LINKED(pan)) {
+-    Touchpan(pan);
+-    PANEL_UPDATE(pan,(PANEL*)0);
+-  }
++  if (!pan)
++    returnCode(ERR);
+ 
+-  if (mvwin(pan->win,starty,startx))
+-    return(ERR);
++  if (IS_LINKED(pan))
++    {
++      Touchpan(pan);
++      PANEL_UPDATE(pan, (PANEL *) 0);
++    }
+ 
+-  return(OK);
++  returnCode(mvwin(pan->win, starty, startx));
+ }
+Index: panel/p_new.c
+Prereq:  1.6 
+--- ncurses-5.4-20040208/panel/p_new.c	2000-12-10 02:20:44.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_new.c	2005-02-19 16:41:03.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,61 +36,65 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_new.c,v 1.6 2000/12/10 02:20:44 tom Exp $")
++MODULE_ID("$Id: p_new.c,v 1.8 2005/02/19 16:41:03 tom Exp $")
+ 
+ #ifdef TRACE
+-static char* stdscr_id;
+-static char* new_id;
++static char *stdscr_id;
++static char *new_id;
+ #endif
+ 
+ /*+-------------------------------------------------------------------------
+   Get root (i.e. stdscr's) panel.
+   Establish the pseudo panel for stdscr if necessary.
+ --------------------------------------------------------------------------*/
+-static PANEL*
++static PANEL *
+ root_panel(void)
+ {
+-  if(_nc_stdscr_pseudo_panel == (PANEL*)0)
++  if (_nc_stdscr_pseudo_panel == (PANEL *) 0)
+     {
+-      
++
+       assert(stdscr && !_nc_bottom_panel && !_nc_top_panel);
+-      _nc_stdscr_pseudo_panel = (PANEL*)malloc(sizeof(PANEL));
+-      if (_nc_stdscr_pseudo_panel != 0) {
+-	PANEL* pan  = _nc_stdscr_pseudo_panel;
+-	WINDOW* win = stdscr;
+-	pan->win = win;
+-	pan->below   = (PANEL*)0;
+-	pan->above   = (PANEL*)0;
++      _nc_stdscr_pseudo_panel = (PANEL *) malloc(sizeof(PANEL));
++      if (_nc_stdscr_pseudo_panel != 0)
++	{
++	  PANEL *pan = _nc_stdscr_pseudo_panel;
++	  WINDOW *win = stdscr;
++
++	  pan->win = win;
++	  pan->below = (PANEL *) 0;
++	  pan->above = (PANEL *) 0;
+ #ifdef TRACE
+-	if (!stdscr_id)
+-	  stdscr_id = strdup("stdscr");
+-	pan->user = stdscr_id;
++	  if (!stdscr_id)
++	    stdscr_id = strdup("stdscr");
++	  pan->user = stdscr_id;
+ #else
+-	pan->user = (void*)0;
++	  pan->user = (void *)0;
+ #endif
+-	_nc_bottom_panel = _nc_top_panel = pan;
+-      }
++	  _nc_bottom_panel = _nc_top_panel = pan;
++	}
+     }
+   return _nc_stdscr_pseudo_panel;
+ }
+ 
+ NCURSES_EXPORT(PANEL *)
+-new_panel (WINDOW *win)
++new_panel(WINDOW *win)
+ {
+-  PANEL *pan = (PANEL*)0;
++  PANEL *pan = (PANEL *) 0;
++
++  T((T_CALLED("new_panel(%p)"), win));
+ 
+   if (!win)
+-    return(pan);
++    returnPanel(pan);
+ 
+   if (!_nc_stdscr_pseudo_panel)
+     (void)root_panel();
+   assert(_nc_stdscr_pseudo_panel);
+ 
+-  if (!(win->_flags & _ISPAD) && (pan = (PANEL*)malloc(sizeof(PANEL))))
++  if (!(win->_flags & _ISPAD) && (pan = (PANEL *) malloc(sizeof(PANEL))))
+     {
+       pan->win = win;
+-      pan->above = (PANEL *)0;
+-      pan->below = (PANEL *)0;
++      pan->above = (PANEL *) 0;
++      pan->below = (PANEL *) 0;
+ #ifdef TRACE
+       if (!new_id)
+ 	new_id = strdup("new");
+@@ -100,5 +104,5 @@
+ #endif
+       (void)show_panel(pan);
+     }
+-  return(pan);
++  returnPanel(pan);
+ }
+Index: panel/p_replace.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/panel/p_replace.c	2001-02-24 23:41:38.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_replace.c	2005-02-19 16:41:31.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,20 +36,23 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_replace.c,v 1.7 2001/02/24 23:41:38 tom Exp $")
++MODULE_ID("$Id: p_replace.c,v 1.9 2005/02/19 16:41:31 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-replace_panel (PANEL *pan, WINDOW *win)
++replace_panel(PANEL * pan, WINDOW *win)
+ {
+-  if(!pan)
+-    return(ERR);
++  T((T_CALLED("replace_panel(%p,%p)"), pan, win));
++
++  if (!pan)
++    returnCode(ERR);
++
++  if (IS_LINKED(pan))
++    {
++      Touchpan(pan);
++      PANEL_UPDATE(pan, (PANEL *) 0);
++    }
+ 
+-  if (IS_LINKED(pan)) {
+-    Touchpan(pan);
+-    PANEL_UPDATE(pan,(PANEL*)0);
+-  }
+-  
+   pan->win = win;
+ 
+-  return(OK);
++  returnCode(OK);
+ }
+Index: panel/p_show.c
+Prereq:  1.9 
+--- ncurses-5.4-20040208/panel/p_show.c	2001-02-24 23:46:50.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_show.c	2005-02-19 16:42:02.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,32 +36,34 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_show.c,v 1.9 2001/02/24 23:46:50 tom Exp $")
++MODULE_ID("$Id: p_show.c,v 1.11 2005/02/19 16:42:02 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-show_panel (PANEL *pan)
+-{ 
++show_panel(PANEL * pan)
++{
+   int err = OK;
+ 
+-  if(!pan)
+-    return(ERR);
++  T((T_CALLED("show_panel(%p)"), pan));
++
++  if (!pan)
++    returnCode(ERR);
+ 
+   if (Is_Top(pan))
+-    return(OK);
++    returnCode(OK);
+ 
+   dBug(("--> show_panel %s", USER_PTR(pan->user)));
+ 
+-  HIDE_PANEL(pan,err,OK);
++  HIDE_PANEL(pan, err, OK);
+ 
+-  dStack("<lt%d>",1,pan);
++  dStack("<lt%d>", 1, pan);
+   assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
+ 
+   _nc_top_panel->above = pan;
+-  pan->below = _nc_top_panel;  
+-  pan->above = (PANEL *)0;
++  pan->below = _nc_top_panel;
++  pan->above = (PANEL *) 0;
+   _nc_top_panel = pan;
+-  
+-  dStack("<lt%d>",9,pan);
+ 
+-  return(OK);
++  dStack("<lt%d>", 9, pan);
++
++  returnCode(OK);
+ }
+Index: panel/p_top.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/panel/p_top.c	2000-12-10 02:20:44.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_top.c	2005-02-19 16:42:23.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,10 +36,11 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_top.c,v 1.3 2000/12/10 02:20:44 tom Exp $")
++MODULE_ID("$Id: p_top.c,v 1.5 2005/02/19 16:42:23 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-top_panel (PANEL *pan)
++top_panel(PANEL * pan)
+ {
+-  return(show_panel(pan));
++  T((T_CALLED("top_panel(%p)"), pan));
++  returnCode(show_panel(pan));
+ }
+Index: panel/p_update.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/panel/p_update.c	2001-02-24 23:41:42.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_update.c	2005-02-19 16:49:47.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,18 +36,19 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_update.c,v 1.7 2001/02/24 23:41:42 tom Exp $")
++MODULE_ID("$Id: p_update.c,v 1.9 2005/02/19 16:49:47 tom Exp $")
+ 
+ NCURSES_EXPORT(void)
+-update_panels (void)
++update_panels(void)
+ {
+   PANEL *pan;
+ 
++  T((T_CALLED("update_panels()")));
+   dBug(("--> update_panels"));
+   pan = _nc_bottom_panel;
+-  while(pan && pan->above)
++  while (pan && pan->above)
+     {
+-      PANEL_UPDATE(pan,pan->above);
++      PANEL_UPDATE(pan, pan->above);
+       pan = pan->above;
+     }
+ 
+@@ -57,4 +58,6 @@
+       Wnoutrefresh(pan);
+       pan = pan->above;
+     }
++
++  returnVoid;
+ }
+Index: panel/p_user.c
+Prereq:  1.4 
+--- ncurses-5.4-20040208/panel/p_user.c	2000-12-10 02:20:44.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_user.c	2005-02-19 16:52:44.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,21 +36,21 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_user.c,v 1.4 2000/12/10 02:20:44 tom Exp $")
++MODULE_ID("$Id: p_user.c,v 1.6 2005/02/19 16:52:44 tom Exp $")
+ 
+ NCURSES_EXPORT(int)
+-set_panel_userptr
+-(PANEL *pan, NCURSES_CONST void *uptr)
++set_panel_userptr(PANEL * pan, NCURSES_CONST void *uptr)
+ {
+-  if(!pan)
+-    return(ERR);
++  T((T_CALLED("set_panel_userptr(%p,%p)"), pan, uptr));
++  if (!pan)
++    returnCode(ERR);
+   pan->user = uptr;
+-  return(OK);
++  returnCode(OK);
+ }
+ 
+-NCURSES_EXPORT(NCURSES_CONST void*)
+-panel_userptr (const PANEL *pan)
++NCURSES_EXPORT(NCURSES_CONST void *)
++panel_userptr(const PANEL * pan)
+ {
+-  return(pan ? pan->user : (NCURSES_CONST void *)0);
++  T((T_CALLED("panel_userptr(%p)"), pan));
++  returnCVoidPtr(pan ? pan->user : (NCURSES_CONST void *)0);
+ }
+-
+Index: panel/p_win.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/panel/p_win.c	2000-12-10 02:20:43.000000000 +0000
++++ ncurses-5.4-20050319/panel/p_win.c	2005-02-19 16:44:16.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2000,2005 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            *
+@@ -36,14 +36,11 @@
+  */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: p_win.c,v 1.3 2000/12/10 02:20:43 tom Exp $")
++MODULE_ID("$Id: p_win.c,v 1.5 2005/02/19 16:44:16 tom Exp $")
+ 
+ NCURSES_EXPORT(WINDOW *)
+-panel_window (const PANEL *pan)
++panel_window(const PANEL * pan)
+ {
+-  return(pan ? pan->win : (WINDOW *)0);
++  T((T_CALLED("panel_window(%p)"), pan));
++  returnWin(pan ? pan->win : (WINDOW *)0);
+ }
+-
+-
+-
+-
+Index: panel/panel.c
+Prereq:  1.20 
+--- ncurses-5.4-20040208/panel/panel.c	2001-02-24 23:17:26.000000000 +0000
++++ ncurses-5.4-20050319/panel/panel.c	2005-02-19 18:04:31.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2004,2005 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,37 +34,51 @@
+ /* panel.c -- implementation of panels library, some core routines */
+ #include "panel.priv.h"
+ 
+-MODULE_ID("$Id: panel.c,v 1.20 2001/02/24 23:17:26 tom Exp $")
++MODULE_ID("$Id: panel.c,v 1.23 2005/02/19 18:04:31 tom Exp $")
+ 
++/*+-------------------------------------------------------------------------
++	_nc_retrace_panel (pan)
++--------------------------------------------------------------------------*/
++#ifdef TRACE
++NCURSES_EXPORT(PANEL *)
++_nc_retrace_panel(PANEL * pan)
++{
++  T((T_RETURN("%p"), pan));
++  return pan;
++}
++#endif
++
++/*+-------------------------------------------------------------------------
++	_nc_my_visbuf(ptr)
++--------------------------------------------------------------------------*/
+ #ifdef TRACE
+ #ifndef TRACE_TXT
+ NCURSES_EXPORT(const char *)
+-_nc_my_visbuf (const void *ptr)
++_nc_my_visbuf(const void *ptr)
+ {
+-	char temp[32];
+-	if (ptr != 0)
+-		sprintf(temp, "ptr:%p", ptr);
+-	else
+-		strcpy(temp, "<null>");
+-	return _nc_visbuf(temp);
++  char temp[32];
++
++  if (ptr != 0)
++    sprintf(temp, "ptr:%p", ptr);
++  else
++    strcpy(temp, "<null>");
++  return _nc_visbuf(temp);
+ }
+ #endif
+ #endif
+ 
+-
+ /*+-------------------------------------------------------------------------
+ 	dPanel(text,pan)
+ --------------------------------------------------------------------------*/
+ #ifdef TRACE
+ NCURSES_EXPORT(void)
+-_nc_dPanel 
+-(const char *text, const PANEL *pan)
++_nc_dPanel(const char *text, const PANEL * pan)
+ {
+-	_tracef("%s id=%s b=%s a=%s y=%d x=%d",
+-		text, USER_PTR(pan->user),
+-		(pan->below) ?  USER_PTR(pan->below->user) : "--",
+-		(pan->above) ?  USER_PTR(pan->above->user) : "--",
+-		PSTARTY(pan), PSTARTX(pan));
++  _tracef("%s id=%s b=%s a=%s y=%d x=%d",
++	  text, USER_PTR(pan->user),
++	  (pan->below) ? USER_PTR(pan->below->user) : "--",
++	  (pan->above) ? USER_PTR(pan->above->user) : "--",
++	  PSTARTY(pan), PSTARTX(pan));
+ }
+ #endif
+ 
+@@ -73,21 +87,20 @@
+ --------------------------------------------------------------------------*/
+ #ifdef TRACE
+ NCURSES_EXPORT(void)
+-_nc_dStack 
+-(const char *fmt, int num, const PANEL *pan)
++_nc_dStack(const char *fmt, int num, const PANEL * pan)
+ {
+   char s80[80];
+ 
+-  sprintf(s80,fmt,num,pan);
+-  _tracef("%s b=%s t=%s",s80,
+-	  (_nc_bottom_panel) ?  USER_PTR(_nc_bottom_panel->user) : "--",
+-	  (_nc_top_panel)    ?  USER_PTR(_nc_top_panel->user)    : "--");
+-  if(pan)
++  sprintf(s80, fmt, num, pan);
++  _tracef("%s b=%s t=%s", s80,
++	  (_nc_bottom_panel) ? USER_PTR(_nc_bottom_panel->user) : "--",
++	  (_nc_top_panel) ? USER_PTR(_nc_top_panel->user) : "--");
++  if (pan)
+     _tracef("pan id=%s", USER_PTR(pan->user));
+   pan = _nc_bottom_panel;
+-  while(pan)
++  while (pan)
+     {
+-      dPanel("stk",pan);
++      dPanel("stk", pan);
+       pan = pan->above;
+     }
+ }
+@@ -98,9 +111,9 @@
+ --------------------------------------------------------------------------*/
+ #ifdef TRACE
+ NCURSES_EXPORT(void)
+-_nc_Wnoutrefresh (const PANEL *pan)
++_nc_Wnoutrefresh(const PANEL * pan)
+ {
+-  dPanel("wnoutrefresh",pan);
++  dPanel("wnoutrefresh", pan);
+   wnoutrefresh(pan->win);
+ }
+ #endif
+@@ -110,9 +123,9 @@
+ --------------------------------------------------------------------------*/
+ #ifdef TRACE
+ NCURSES_EXPORT(void)
+-_nc_Touchpan (const PANEL *pan)
++_nc_Touchpan(const PANEL * pan)
+ {
+-  dPanel("Touchpan",pan);
++  dPanel("Touchpan", pan);
+   touchwin(pan->win);
+ }
+ #endif
+@@ -122,19 +135,23 @@
+ --------------------------------------------------------------------------*/
+ #ifdef TRACE
+ NCURSES_EXPORT(void)
+-_nc_Touchline 
+-(const PANEL *pan, int start, int count)
++_nc_Touchline(const PANEL * pan, int start, int count)
+ {
+   char s80[80];
+-  sprintf(s80,"Touchline s=%d c=%d",start,count);
+-  dPanel(s80,pan);
+-  touchline(pan->win,start,count);
++
++  sprintf(s80, "Touchline s=%d c=%d", start, count);
++  dPanel(s80, pan);
++  touchline(pan->win, start, count);
+ }
+ #endif
+ 
+ #ifndef TRACE
+ #  ifndef __GNUC__
+      /* Some C compilers need something defined in a source file */
+-     void _nc_dummy_panel(void) { }
++extern void _nc_dummy_panel(void);
++void
++_nc_dummy_panel(void)
++{
++}
+ #  endif
+ #endif
+Index: panel/panel.priv.h
+Prereq:  1.19 
+--- ncurses-5.4-20040208/panel/panel.priv.h	2001-06-02 23:31:05.000000000 +0000
++++ ncurses-5.4-20050319/panel/panel.priv.h	2005-02-19 17:16:54.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 2000 Free Software Foundation, Inc.                        *
++ * Copyright (c) 1998-2001,2005 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            *
+@@ -26,7 +26,7 @@
+  * authorization.                                                           *
+  ****************************************************************************/
+ 
+-/* $Id: panel.priv.h,v 1.19 2001/06/02 23:31:05 tom Exp $ */
++/* $Id: panel.priv.h,v 1.20 2005/02/19 17:16:54 tom Exp $ */
+ 
+ #ifndef NCURSES_PANEL_PRIV_H
+ #define NCURSES_PANEL_PRIV_H 1
+@@ -72,6 +72,9 @@
+ #    define USER_PTR(ptr) _nc_my_visbuf((const char *)ptr)
+ #  endif
+ 
++#  define returnPanel(code)	TRACE_RETURN(code,panel)
++
++   extern NCURSES_EXPORT(PANEL *) _nc_retrace_panel (PANEL *);
+    extern NCURSES_EXPORT(void) _nc_dPanel (const char*, const PANEL*);
+    extern NCURSES_EXPORT(void) _nc_dStack (const char*, int, const PANEL*);
+    extern NCURSES_EXPORT(void) _nc_Wnoutrefresh (const PANEL*);
+@@ -85,6 +88,7 @@
+ #  define Touchpan(pan) _nc_Touchpan(pan)
+ #  define Touchline(pan,start,count) _nc_Touchline(pan,start,count)
+ #else /* !TRACE */
++#  define returnPanel(code)	return code
+ #  define dBug(x)
+ #  define dPanel(text,pan)
+ #  define dStack(fmt,num,pan)
+@@ -98,7 +102,7 @@
+ #define _nc_bottom_panel _nc_panelhook()->bottom_panel
+ 
+ #define EMPTY_STACK() (_nc_top_panel==_nc_bottom_panel)
+-#define Is_Bottom(p)  (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_bottom_panel->above==(p))) 
++#define Is_Bottom(p)  (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_bottom_panel->above==(p)))
+ #define Is_Top(p) (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_top_panel==(p)))
+ #define Is_Pseudo(p) ((p) && ((p)==_nc_bottom_panel))
+ 
+@@ -138,9 +142,9 @@
+ /*+-------------------------------------------------------------------------
+ 	Walk through the panel stack starting at the given location and
+         check for intersections; overlapping panels are "touched", so they
+-        are incrementally overwriting cells that should be hidden. 
++        are incrementally overwriting cells that should be hidden.
+         If the "touch" flag is set, the panel gets touched before it is
+-        updated. 
++        updated.
+ ---------------------------------------------------------------------------*/
+ #define PANEL_UPDATE(pan,panstart)\
+ {  PANEL* pan2 = ((panstart) ? (panstart) : _nc_bottom_panel);\
+Index: progs/Makefile.in
+Prereq:  1.62 
+--- ncurses-5.4-20040208/progs/Makefile.in	2003-11-01 22:45:57.000000000 +0000
++++ ncurses-5.4-20050319/progs/Makefile.in	2005-01-22 20:11:48.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: Makefile.in,v 1.62 2003/11/01 22:45:57 tom Exp $
++# $Id: Makefile.in,v 1.64 2005/01/22 20:11:48 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2003,2005 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"), #
+@@ -95,7 +95,7 @@
+ LD		= @LD@
+ LINK		= @LINK_PROGS@ $(LIBTOOL_LINK) $(CC)
+ LDFLAGS		= @EXTRA_LDFLAGS@ \
+-		@PROG_ARGS@ @LDFLAGS@ @LD_MODEL@ @LIBS@ @EXTRA_LIBS@
++		@TINFO_ARGS@ @LDFLAGS@ @LD_MODEL@ @LIBS@
+ 
+ LDFLAGS_LIBTOOL	= $(LDFLAGS) $(CFLAGS_LIBTOOL)
+ LDFLAGS_NORMAL	= $(LDFLAGS) $(CFLAGS_NORMAL)
+Index: progs/dump_entry.c
+Prereq:  1.66 
+--- ncurses-5.4-20040208/progs/dump_entry.c	2003-05-24 22:43:59.000000000 +0000
++++ ncurses-5.4-20050319/progs/dump_entry.c	2004-09-25 22:39:25.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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            *
+@@ -39,7 +39,7 @@
+ #include "termsort.c"		/* this C file is generated */
+ #include <parametrized.h>	/* so is this */
+ 
+-MODULE_ID("$Id: dump_entry.c,v 1.66 2003/05/24 22:43:59 tom Exp $")
++MODULE_ID("$Id: dump_entry.c,v 1.67 2004/09/25 22:39:25 tom Exp $")
+ 
+ #define INDENT			8
+ #define DISCARD(string) string = ABSENT_STRING
+@@ -63,7 +63,7 @@
+ static DYNBUF tmpbuf;
+ 
+ /* indirection pointers for implementing sort and display modes */
+-static const int *bool_indirect, *num_indirect, *str_indirect;
++static const PredIdx *bool_indirect, *num_indirect, *str_indirect;
+ static NCURSES_CONST char *const *bool_names;
+ static NCURSES_CONST char *const *num_names;
+ static NCURSES_CONST char *const *str_names;
+@@ -262,7 +262,7 @@
+ static TERMTYPE *cur_type;
+ 
+ static int
+-dump_predicate(int type, int idx)
++dump_predicate(PredType type, PredIdx idx)
+ /* predicate function to use for ordinary decompilation */
+ {
+     switch (type) {
+@@ -282,7 +282,7 @@
+     return (FALSE);		/* pacify compiler */
+ }
+ 
+-static void set_obsolete_termcaps(TERMTYPE * tp);
++static void set_obsolete_termcaps(TERMTYPE *tp);
+ 
+ /* is this the index of a function key string? */
+ #define FNKEY(i)	(((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268))
+@@ -296,7 +296,7 @@
+ #define STR_IDX(name)  (&(name) - &(CUR Strings[0]))
+ 
+ static bool
+-version_filter(int type, int idx)
++version_filter(PredType type, PredIdx idx)
+ /* filter out capabilities we may want to suppress */
+ {
+     switch (tversion) {
+@@ -499,20 +499,20 @@
+ }
+ 
+ int
+-fmt_entry(TERMTYPE * tterm,
+-	  int (*pred) (int type, int idx),
++fmt_entry(TERMTYPE *tterm,
++	  PredFunc pred,
+ 	  bool content_only,
+ 	  bool suppress_untranslatable,
+ 	  bool infodump,
+ 	  int numbers)
+ {
+-    int i, j;
++    PredIdx i, j;
+     char buffer[MAX_TERMINFO_LENGTH];
+     NCURSES_CONST char *name;
+     int predval, len;
+-    int num_bools = 0;
+-    int num_values = 0;
+-    int num_strings = 0;
++    PredIdx num_bools = 0;
++    PredIdx num_values = 0;
++    PredIdx num_strings = 0;
+     bool outcount = 0;
+ 
+ #define WRAP_CONCAT	\
+@@ -786,7 +786,7 @@
+ }
+ 
+ static bool
+-kill_string(TERMTYPE * tterm, char *cap)
++kill_string(TERMTYPE *tterm, char *cap)
+ {
+     int n;
+     for (n = 0; n < NUM_STRINGS(tterm); ++n) {
+@@ -799,9 +799,9 @@
+ }
+ 
+ static char *
+-find_string(TERMTYPE * tterm, char *name)
++find_string(TERMTYPE *tterm, char *name)
+ {
+-    int n;
++    PredIdx n;
+     for (n = 0; n < NUM_STRINGS(tterm); ++n) {
+ 	if (version_filter(STRING, n)
+ 	    && !strcmp(name, strnames[n])) {
+@@ -820,7 +820,7 @@
+  * make it smaller.
+  */
+ static int
+-kill_labels(TERMTYPE * tterm, int target)
++kill_labels(TERMTYPE *tterm, int target)
+ {
+     int n;
+     int result = 0;
+@@ -845,7 +845,7 @@
+  * make it smaller.
+  */
+ static int
+-kill_fkeys(TERMTYPE * tterm, int target)
++kill_fkeys(TERMTYPE *tterm, int target)
+ {
+     int n;
+     int result = 0;
+@@ -874,12 +874,12 @@
+ #define SHOW_WHY if (!already_used) PRINTF
+ 
+ int
+-dump_entry(TERMTYPE * tterm,
++dump_entry(TERMTYPE *tterm,
+ 	   bool suppress_untranslatable,
+ 	   bool limited,
+ 	   int already_used,
+ 	   int numbers,
+-	   int (*pred) (int type, int idx))
++	   PredFunc pred)
+ /* dump a single entry */
+ {
+     int len, critlen;
+@@ -982,11 +982,12 @@
+ }
+ 
+ void
+-compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp
+-	      GCC_UNUSED, bool quiet)
++compare_entry(void (*hook) (PredType t, PredIdx i, const char *name),
++	      TERMTYPE *tp GCC_UNUSED,
++	      bool quiet)
+ /* compare two entries */
+ {
+-    int i, j;
++    PredIdx i, j;
+     NCURSES_CONST char *name;
+ 
+     if (!quiet)
+@@ -1041,7 +1042,7 @@
+ #define CUR tp->
+ 
+ static void
+-set_obsolete_termcaps(TERMTYPE * tp)
++set_obsolete_termcaps(TERMTYPE *tp)
+ {
+ #include "capdefaults.c"
+ }
+@@ -1051,7 +1052,7 @@
+  * unique.
+  */
+ void
+-repair_acsc(TERMTYPE * tp)
++repair_acsc(TERMTYPE *tp)
+ {
+     if (VALID_STRING(acs_chars)) {
+ 	size_t n, m;
+Index: progs/dump_entry.h
+--- ncurses-5.4-20040208/progs/dump_entry.h	2002-08-11 00:19:45.000000000 +0000
++++ ncurses-5.4-20050319/progs/dump_entry.h	2004-12-04 15:37:17.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998,1999 Free Software Foundation, Inc.                   *
++ * Copyright (c) 1998-2002,2004 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,13 +29,19 @@
+ /****************************************************************************
+  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
+  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
++ *     and: Thomas E. Dickey                        1996-on                 *
+  ****************************************************************************/
+ 
+ 
+ /*
++ * $Id: dump_entry.h,v 1.27 2004/12/04 15:37:17 tom Exp $
++ *
+  * Dump control definitions and variables
+  */
+ 
++#ifndef DUMP_ENTRY_H
++#define DUMP_ENTRY_H 1
++
+ /* capability output formats */
+ #define F_TERMINFO	0	/* use terminfo names */
+ #define F_VARIABLE	1	/* use C variable names */
+@@ -56,12 +62,18 @@
+ #define CMP_STRING	2	/* comparison on strings */
+ #define CMP_USE		3	/* comparison on use capabilities */
+ 
++typedef unsigned PredType;
++typedef int PredIdx;
++typedef int (*PredFunc)(PredType, PredIdx);
++
+ extern NCURSES_CONST char *nametrans(const char *);
+ extern void dump_init(const char *, int, int, int, int, bool);
+-extern int fmt_entry(TERMTYPE *, int (*)(int, int), bool, bool, bool, int);
+-extern int dump_entry(TERMTYPE *, bool, bool, int, int, int (*)(int, int));
++extern int fmt_entry(TERMTYPE *, PredFunc, bool, bool, bool, int);
++extern int dump_entry(TERMTYPE *, bool, bool, int, int, PredFunc);
+ extern int dump_uses(const char *, bool);
+-extern void compare_entry(void (*)(int, int, const char *), TERMTYPE *, bool);
++extern void compare_entry(void (*)(PredType, PredIdx, const char *), TERMTYPE *, bool);
+ extern void repair_acsc(TERMTYPE * tp);
+ 
+ #define FAIL	-1
++
++#endif /* DUMP_ENTRY_H */
+Index: progs/infocmp.c
+Prereq:  1.71 
+--- ncurses-5.4-20040208/progs/infocmp.c	2003-10-18 18:01:54.000000000 +0000
++++ ncurses-5.4-20050319/progs/infocmp.c	2004-12-04 15:38:26.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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                 *
+  ****************************************************************************/
+ 
+ /*
+@@ -41,7 +42,7 @@
+ #include <term_entry.h>
+ #include <dump_entry.h>
+ 
+-MODULE_ID("$Id: infocmp.c,v 1.71 2003/10/18 18:01:54 tom Exp $")
++MODULE_ID("$Id: infocmp.c,v 1.77 2004/12/04 15:38:26 tom Exp $")
+ 
+ #define L_CURL "{"
+ #define R_CURL "}"
+@@ -66,6 +67,7 @@
+ 
+ static bool limited = TRUE;	/* "-r" option is not set */
+ static bool quiet = FALSE;
++static bool literal = FALSE;
+ static const char *bool_sep = ":";
+ static const char *s_absent = "NULL";
+ static const char *s_cancel = "NULL";
+@@ -87,11 +89,10 @@
+ 
+ #if NO_LEAKS
+ #undef ExitProgram
+-static void
+-ExitProgram(int code) GCC_NORETURN;
++static void ExitProgram(int code) GCC_NORETURN;
+ /* prototype is to get gcc to accept the noreturn attribute */
+-     static void
+-       ExitProgram(int code)
++static void
++ExitProgram(int code)
+ {
+     while (termcount-- > 0)
+ 	_nc_free_termtype(&entries[termcount].tterm);
+@@ -120,7 +121,7 @@
+  ***************************************************************************/
+ 
+ static int
+-capcmp(unsigned idx, const char *s, const char *t)
++capcmp(PredIdx idx, const char *s, const char *t)
+ /* capability comparison function */
+ {
+     if (!VALID_STRING(s) && !VALID_STRING(t))
+@@ -135,7 +136,7 @@
+ }
+ 
+ static int
+-use_predicate(int type, int idx)
++use_predicate(unsigned type, PredIdx idx)
+ /* predicate function to use for use decompilation */
+ {
+     ENTRY *ep;
+@@ -245,7 +246,7 @@
+ }
+ 
+ static bool
+-entryeq(TERMTYPE * t1, TERMTYPE * t2)
++entryeq(TERMTYPE *t1, TERMTYPE *t2)
+ /* are two entries equivalent? */
+ {
+     unsigned i;
+@@ -332,7 +333,7 @@
+ }
+ 
+ static void
+-compare_predicate(int type, int idx, const char *name)
++compare_predicate(PredType type, PredIdx idx, const char *name)
+ /* predicate function to use for entry difference reports */
+ {
+     register ENTRY *e1 = &entries[0];
+@@ -474,14 +475,26 @@
+     {"\033)A", "ISO UK G1"},	/* enable UK chars for G1 */
+     {"\033)B", "ISO US G1"},	/* enable US chars for G1 */
+ 
+-    /* these are DEC private modes widely supported by emulators */
++    /* these are DEC private controls widely supported by emulators */
+     {"\033=", "DECPAM"},	/* application keypad mode */
+     {"\033>", "DECPNM"},	/* normal keypad mode */
+     {"\033<", "DECANSI"},	/* enter ANSI mode */
++    {"\033[!p", "DECSTR"},	/* soft reset */
++    {"\033 F", "S7C1T"},	/* 7-bit controls */
+ 
+     {(char *) 0, (char *) 0}
+ };
+ 
++static const assoc std_modes[] =
++/* ECMA \E[ ... [hl] modes recognized by many emulators */
++{
++    {"2", "AM"},		/* keyboard action mode */
++    {"4", "IRM"},		/* insert/replace mode */
++    {"12", "SRM"},		/* send/receive mode */
++    {"20", "LNM"},		/* linefeed mode */
++    {(char *) 0, (char *) 0}
++};
++
+ static const assoc private_modes[] =
+ /* DEC \E[ ... [hl] modes recognized by many emulators */
+ {
+@@ -532,13 +545,25 @@
+     {(char *) 0, (char *) 0}
+ };
+ 
++static int
++skip_csi(const char *cap)
++{
++    int result = 0;
++    if (cap[0] == '\033' && cap[1] == '[')
++	result = 2;
++    else if (UChar(cap[0]) == 0233)
++	result = 1;
++    return result;
++}
++
+ static void
+-analyze_string(const char *name, const char *cap, TERMTYPE * tp)
++analyze_string(const char *name, const char *cap, TERMTYPE *tp)
+ {
+     char buf[MAX_TERMINFO_LENGTH];
+     char buf2[MAX_TERMINFO_LENGTH];
+     const char *sp, *ep;
+     const assoc *ap;
++    int tp_lines = tp->Numbers[2];
+ 
+     if (cap == ABSENT_STRING || cap == CANCELLED_STRING)
+ 	return;
+@@ -547,6 +572,7 @@
+     buf[0] = '\0';
+     for (sp = cap; *sp; sp++) {
+ 	int i;
++	int csi;
+ 	size_t len = 0;
+ 	const char *expansion = 0;
+ 
+@@ -586,26 +612,68 @@
+ 	}
+ 
+ 	/* now check the standard capabilities */
+-	if (!expansion)
++	if (!expansion) {
++	    csi = skip_csi(sp);
+ 	    for (ap = std_caps; ap->from; ap++) {
+-		len = strlen(ap->from);
++		size_t adj = csi ? 2 : 0;
+ 
+-		if (strncmp(ap->from, sp, len) == 0) {
++		len = strlen(ap->from);
++		if (len > adj
++		    && strncmp(ap->from + adj, sp + csi, len - adj) == 0) {
+ 		    expansion = ap->to;
++		    len -= adj;
++		    len += csi;
+ 		    break;
+ 		}
+ 	    }
++	}
++
++	/* now check for standard-mode sequences */
++	if (!expansion
++	    && (csi = skip_csi(sp)) != 0
++	    && (len = strspn(sp + csi, "0123456789;"))
++	    && ((sp[csi + len] == 'h') || (sp[csi + len] == 'l'))) {
++	    char buf3[MAX_TERMINFO_LENGTH];
++
++	    (void) strcpy(buf2, (sp[csi + len] == 'h') ? "ECMA+" : "ECMA-");
++	    (void) strncpy(buf3, sp + csi, len);
++	    len += csi + 1;
++	    buf3[len] = '\0';
++
++	    ep = strtok(buf3, ";");
++	    do {
++		bool found = FALSE;
++
++		for (ap = std_modes; ap->from; ap++) {
++		    size_t tlen = strlen(ap->from);
++
++		    if (strncmp(ap->from, ep, tlen) == 0) {
++			(void) strcat(buf2, ap->to);
++			found = TRUE;
++			break;
++		    }
++		}
++
++		if (!found)
++		    (void) strcat(buf2, ep);
++		(void) strcat(buf2, ";");
++	    } while
++		((ep = strtok((char *) 0, ";")));
++	    buf2[strlen(buf2) - 1] = '\0';
++	    expansion = buf2;
++	}
+ 
+ 	/* now check for private-mode sequences */
+ 	if (!expansion
+-	    && sp[0] == '\033' && sp[1] == '[' && sp[2] == '?'
+-	    && (len = strspn(sp + 3, "0123456789;"))
+-	    && ((sp[3 + len] == 'h') || (sp[3 + len] == 'l'))) {
++	    && (csi = skip_csi(sp)) != 0
++	    && sp[csi] == '?'
++	    && (len = strspn(sp + csi + 1, "0123456789;"))
++	    && ((sp[csi + 1 + len] == 'h') || (sp[csi + 1 + len] == 'l'))) {
+ 	    char buf3[MAX_TERMINFO_LENGTH];
+ 
+-	    (void) strcpy(buf2, (sp[3 + len] == 'h') ? "DEC+" : "DEC-");
+-	    (void) strncpy(buf3, sp + 3, len);
+-	    len += 4;
++	    (void) strcpy(buf2, (sp[csi + 1 + len] == 'h') ? "DEC+" : "DEC-");
++	    (void) strncpy(buf3, sp + csi + 1, len);
++	    len += csi + 2;
+ 	    buf3[len] = '\0';
+ 
+ 	    ep = strtok(buf3, ";");
+@@ -633,14 +701,14 @@
+ 
+ 	/* now check for ECMA highlight sequences */
+ 	if (!expansion
+-	    && sp[0] == '\033' && sp[1] == '['
+-	    && (len = strspn(sp + 2, "0123456789;"))
+-	    && sp[2 + len] == 'm') {
++	    && (csi = skip_csi(sp)) != 0
++	    && (len = strspn(sp + csi, "0123456789;")) != 0
++	    && sp[csi + len] == 'm') {
+ 	    char buf3[MAX_TERMINFO_LENGTH];
+ 
+ 	    (void) strcpy(buf2, "SGR:");
+-	    (void) strncpy(buf3, sp + 2, len);
+-	    len += 3;
++	    (void) strncpy(buf3, sp + csi, len);
++	    len += csi + 1;
+ 	    buf3[len] = '\0';
+ 
+ 	    ep = strtok(buf3, ";");
+@@ -666,20 +734,46 @@
+ 	    buf2[strlen(buf2) - 1] = '\0';
+ 	    expansion = buf2;
+ 	}
++
++	if (!expansion
++	    && (csi = skip_csi(sp)) != 0
++	    && sp[csi] == 'm') {
++	    len = csi + 1;
++	    (void) strcpy(buf2, "SGR:");
++	    strcat(buf2, ecma_highlights[0].to);
++	    expansion = buf2;
++	}
++
+ 	/* now check for scroll region reset */
+-	if (!expansion) {
+-	    (void) sprintf(buf2, "\033[1;%dr", tp->Numbers[2]);
+-	    len = strlen(buf2);
+-	    if (strncmp(buf2, sp, len) == 0)
++	if (!expansion
++	    && (csi = skip_csi(sp)) != 0) {
++	    if (sp[csi] == 'r') {
+ 		expansion = "RSR";
++		len = 1;
++	    } else {
++		(void) sprintf(buf2, "1;%dr", tp_lines);
++		len = strlen(buf2);
++		if (strncmp(buf2, sp + csi, len) == 0)
++		    expansion = "RSR";
++	    }
++	    len += csi;
+ 	}
+ 
+ 	/* now check for home-down */
+-	if (!expansion) {
+-	    (void) sprintf(buf2, "\033[%d;1H", tp->Numbers[2]);
++	if (!expansion
++	    && (csi = skip_csi(sp)) != 0) {
++	    (void) sprintf(buf2, "%d;1H", tp_lines);
+ 	    len = strlen(buf2);
+-	    if (strncmp(buf2, sp, len) == 0)
++	    if (strncmp(buf2, sp + csi, len) == 0) {
+ 		expansion = "LL";
++	    } else {
++		(void) sprintf(buf2, "%dH", tp_lines);
++		len = strlen(buf2);
++		if (strncmp(buf2, sp + csi, len) == 0) {
++		    expansion = "LL";
++		}
++	    }
++	    len += csi;
+ 	}
+ 
+ 	/* now look at the expansion we got, if any */
+@@ -723,13 +817,13 @@
+ 
+ 	/* parse entries out of the source file */
+ 	_nc_set_source(argv[n]);
+-	_nc_read_entry_source(stdin, NULL, TRUE, FALSE, NULLHOOK);
++	_nc_read_entry_source(stdin, NULL, TRUE, literal, NULLHOOK);
+ 
+ 	if (itrace)
+ 	    (void) fprintf(stderr, "Resolving file %d...\n", n - 0);
+ 
+ 	/* maybe do use resolution */
+-	if (!_nc_resolve_uses(!limited)) {
++	if (!_nc_resolve_uses2(!limited, literal)) {
+ 	    (void) fprintf(stderr,
+ 			   "There are unresolved use entries in %s:\n",
+ 			   argv[n]);
+@@ -898,6 +992,7 @@
+ 	,"  -L    use long names"
+ 	,"  -R subset (see manpage)"
+ 	,"  -T    eliminate size limits (test)"
++	,"  -U    eliminate post-processing of entries"
+ 	,"  -V    print version"
+ #if NCURSES_XNAMES
+ 	,"  -a    with -F, list commented-out caps"
+@@ -923,6 +1018,9 @@
+ 	,"  -u    produce source with 'use='"
+ 	,"  -v number  (verbose)"
+ 	,"  -w number  (width)"
++#if NCURSES_XNAMES
++	,"  -x    treat unknown capabilities as user-defined"
++#endif
+     };
+     const size_t first = 3;
+     const size_t last = SIZEOF(tbl);
+@@ -973,7 +1071,7 @@
+ 
+ /* dump C initializers for the terminal type */
+ static void
+-dump_initializers(TERMTYPE * term)
++dump_initializers(TERMTYPE *term)
+ {
+     unsigned n;
+     int size;
+@@ -1030,7 +1128,7 @@
+ 	    str = "CANCELLED_BOOLEAN";
+ 	    break;
+ 	}
+-	(void) printf("\t/* %3d: %-8s */\t%s,\n",
++	(void) printf("\t/* %3u: %-8s */\t%s,\n",
+ 		      n, ExtBoolname(term, n, boolnames), str);
+     }
+     (void) printf("%s;\n", R_CURL);
+@@ -1051,14 +1149,14 @@
+ 	    str = buf;
+ 	    break;
+ 	}
+-	(void) printf("\t/* %3d: %-8s */\t%s,\n", n,
++	(void) printf("\t/* %3u: %-8s */\t%s,\n", n,
+ 		      ExtNumname(term, n, numnames), str);
+     }
+     (void) printf("%s;\n", R_CURL);
+ 
+-    size = sizeof(TERMTYPE)
+-	+ (NUM_BOOLEANS(term) * sizeof(term->Booleans[0]))
+-	+ (NUM_NUMBERS(term) * sizeof(term->Numbers[0]));
++    size = (sizeof(TERMTYPE)
++	    + (NUM_BOOLEANS(term) * sizeof(term->Booleans[0]))
++	    + (NUM_NUMBERS(term) * sizeof(term->Numbers[0])));
+ 
+     (void) printf("static char * %s[] = %s\n", name_initializer("string"), L_CURL);
+ 
+@@ -1071,7 +1169,7 @@
+ 	else {
+ 	    str = string_variable(ExtStrname(term, n, strnames));
+ 	}
+-	(void) printf("\t/* %3d: %-8s */\t%s,\n", n,
++	(void) printf("\t/* %3u: %-8s */\t%s,\n", n,
+ 		      ExtStrname(term, n, strnames), str);
+     }
+     (void) printf("%s;\n", R_CURL);
+@@ -1083,15 +1181,15 @@
+ 	(void) printf("static char * %s[] = %s\n",
+ 		      name_initializer("string_ext"), L_CURL);
+ 	for (n = BOOLCOUNT; n < NUM_BOOLEANS(term); ++n) {
+-	    (void) printf("\t/* %3d: bool */\t\"%s\",\n",
++	    (void) printf("\t/* %3u: bool */\t\"%s\",\n",
+ 			  n, ExtBoolname(term, n, boolnames));
+ 	}
+ 	for (n = NUMCOUNT; n < NUM_NUMBERS(term); ++n) {
+-	    (void) printf("\t/* %3d: num */\t\"%s\",\n",
++	    (void) printf("\t/* %3u: num */\t\"%s\",\n",
+ 			  n, ExtNumname(term, n, numnames));
+ 	}
+ 	for (n = STRCOUNT; n < NUM_STRINGS(term); ++n) {
+-	    (void) printf("\t/* %3d: str */\t\"%s\",\n",
++	    (void) printf("\t/* %3u: str */\t\"%s\",\n",
+ 			  n, ExtStrname(term, n, strnames));
+ 	}
+ 	(void) printf("%s;\n", R_CURL);
+@@ -1101,7 +1199,7 @@
+ 
+ /* dump C initializers for the terminal type */
+ static void
+-dump_termtype(TERMTYPE * term)
++dump_termtype(TERMTYPE *term)
+ {
+     (void) printf("\t%s\n\t\t%s,\n", L_CURL, name_initializer("alias"));
+     (void) printf("\t\t(char *)0,\t/* pointer to string table */\n");
+@@ -1186,9 +1284,13 @@
+     /* where is the terminfo database location going to default to? */
+     restdir = firstdir = 0;
+ 
++#if NCURSES_XNAMES
++    use_extended_names(FALSE);
++#endif
++
+     while ((c = getopt(argc,
+ 		       argv,
+-		       "1A:aB:CcdEeFfGgIiLlnpqR:rs:TtuVv:w:")) != EOF)
++		       "1A:aB:CcdEeFfGgIiLlnpqR:rs:TtUuVv:w:x")) != EOF)
+ 	switch (c) {
+ 	case '1':
+ 	    mwidth = 0;
+@@ -1319,6 +1421,10 @@
+ 	    break;
+ #endif
+ 
++	case 'U':
++	    literal = TRUE;
++	    break;
++
+ 	case 'u':
+ 	    compare = C_USEALL;
+ 	    break;
+@@ -1336,6 +1442,12 @@
+ 	    mwidth = optarg_to_number();
+ 	    break;
+ 
++#if NCURSES_XNAMES
++	case 'x':
++	    use_extended_names(TRUE);
++	    break;
++#endif
++
+ 	default:
+ 	    usage();
+ 	}
+Index: progs/tic.c
+Prereq:  1.109 
+--- ncurses-5.4-20040208/progs/tic.c	2003-12-06 17:36:57.000000000 +0000
++++ ncurses-5.4-20050319/progs/tic.c	2004-12-04 15:35:59.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2003,2004 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,20 +45,46 @@
+ #include <term_entry.h>
+ #include <transform.h>
+ 
+-MODULE_ID("$Id: tic.c,v 1.109 2003/12/06 17:36:57 tom Exp $")
++MODULE_ID("$Id: tic.c,v 1.117 2004/12/04 15:35:59 tom Exp $")
+ 
+ const char *_nc_progname = "tic";
+ 
+ static FILE *log_fp;
+ static FILE *tmp_fp;
++static bool capdump = FALSE;	/* running as infotocap? */
++static bool infodump = FALSE;	/* running as captoinfo? */
+ static bool showsummary = FALSE;
+ static const char *to_remove;
+-static int tparm_errs;
+ 
+-static void (*save_check_termtype) (TERMTYPE *);
+-static void check_termtype(TERMTYPE * tt);
++static void (*save_check_termtype) (TERMTYPE *, bool);
++static void check_termtype(TERMTYPE *tt, bool);
+ 
+-static const char usage_string[] = "[-V] [-v[n]] [-e names] [-o dir] [-R name] [-CILNTcfrswx1] source-file\n";
++static const char usage_string[] = "\
++[-e names] \
++[-o dir] \
++[-R name] \
++[-v[n]] \
++[-V] \
++[-w[n]] \
++[-\
++1\
++a\
++C\
++c\
++f\
++G\
++g\
++I\
++L\
++N\
++r\
++s\
++T\
++t\
++U\
++x\
++] \
++source-file\n";
+ 
+ static void
+ cleanup(void)
+@@ -109,6 +135,7 @@
+ #if NCURSES_XNAMES
+ 	"  -t         suppress commented-out capabilities",
+ #endif
++	"  -U         suppress post-processing of entries",
+ 	"  -V         print version",
+ 	"  -v[n]      set verbosity level",
+ 	"  -w[n]      set format width for translation output",
+@@ -381,7 +408,7 @@
+     if (showsummary) {
+ 	fprintf(log_fp, "Entries that will be compiled:\n");
+ 	for (n = 0; dst[n] != 0; n++)
+-	    fprintf(log_fp, "%d:%s\n", n + 1, dst[n]);
++	    fprintf(log_fp, "%u:%s\n", n + 1, dst[n]);
+     }
+     return dst;
+ }
+@@ -436,9 +463,8 @@
+ 
+     int width = 60;
+     bool formatted = FALSE;	/* reformat complex strings? */
++    bool literal = FALSE;	/* suppress post-processing? */
+     int numbers = 0;		/* format "%'char'" to/from "%{number}" */
+-    bool infodump = FALSE;	/* running as captoinfo? */
+-    bool capdump = FALSE;	/* running as infotocap? */
+     bool forceresolve = FALSE;	/* force resolution */
+     bool limited = TRUE;
+     char *tversion = (char *) NULL;
+@@ -470,7 +496,7 @@
+      * be optional.
+      */
+     while ((this_opt = getopt(argc, argv,
+-			      "0123456789CILNR:TVace:fGgo:rstvwx")) != EOF) {
++			      "0123456789CILNR:TUVace:fGgo:rstvwx")) != EOF) {
+ 	if (isdigit(this_opt)) {
+ 	    switch (last_opt) {
+ 	    case 'v':
+@@ -505,6 +531,7 @@
+ 	    break;
+ 	case 'N':
+ 	    smart_defaults = FALSE;
++	    literal = TRUE;
+ 	    break;
+ 	case 'R':
+ 	    tversion = optarg;
+@@ -512,6 +539,9 @@
+ 	case 'T':
+ 	    limited = FALSE;
+ 	    break;
++	case 'U':
++	    literal = TRUE;
++	    break;
+ 	case 'V':
+ 	    puts(curses_version());
+ 	    return EXIT_SUCCESS;
+@@ -567,8 +597,8 @@
+     set_trace_level(debug_level);
+ 
+     if (_nc_tracing) {
+-	save_check_termtype = _nc_check_termtype;
+-	_nc_check_termtype = check_termtype;
++	save_check_termtype = _nc_check_termtype2;
++	_nc_check_termtype2 = check_termtype;
+     }
+ #if !HAVE_BIG_CORE
+     /*
+@@ -585,7 +615,7 @@
+ 	(void) fprintf(stderr,
+ 		       "Sorry, -e can't be used without -I or -C\n");
+ 	cleanup();
+-	return EXIT_FAILURE;
++	ExitProgram(EXIT_FAILURE);
+     }
+ #endif /* HAVE_BIG_CORE */
+ 
+@@ -597,7 +627,7 @@
+ 		    _nc_progname,
+ 		    _nc_progname,
+ 		    usage_string);
+-	    return EXIT_FAILURE;
++	    ExitProgram(EXIT_FAILURE);
+ 	}
+     } else {
+ 	if (infodump == TRUE) {
+@@ -628,7 +658,7 @@
+ 		    _nc_progname,
+ 		    usage_string);
+ 	    cleanup();
+-	    return EXIT_FAILURE;
++	    ExitProgram(EXIT_FAILURE);
+ 	}
+     }
+ 
+@@ -653,14 +683,16 @@
+ 	_nc_set_writedir(outdir);
+ #endif /* HAVE_BIG_CORE */
+     _nc_read_entry_source(tmp_fp, (char *) NULL,
+-			  !smart_defaults, FALSE,
+-			  (check_only || infodump || capdump) ? NULLHOOK : immedhook);
++			  !smart_defaults || literal, FALSE,
++			  ((check_only || infodump || capdump)
++			   ? NULLHOOK
++			   : immedhook));
+ 
+     /* do use resolution */
+     if (check_only || (!infodump && !capdump) || forceresolve) {
+-	if (!_nc_resolve_uses(TRUE) && !check_only) {
++	if (!_nc_resolve_uses2(TRUE, literal) && !check_only) {
+ 	    cleanup();
+-	    return EXIT_FAILURE;
++	    ExitProgram(EXIT_FAILURE);
+ 	}
+     }
+ 
+@@ -754,7 +786,7 @@
+ 	    fprintf(log_fp, "No entries written\n");
+     }
+     cleanup();
+-    return (EXIT_SUCCESS);
++    ExitProgram(EXIT_SUCCESS);
+ }
+ 
+ /*
+@@ -772,7 +804,7 @@
+  * Check if the alternate character-set capabilities are consistent.
+  */
+ static void
+-check_acs(TERMTYPE * tp)
++check_acs(TERMTYPE *tp)
+ {
+     if (VALID_STRING(acs_chars)) {
+ 	const char *boxes = "lmkjtuvwqxn";
+@@ -808,7 +840,7 @@
+  * Check if the color capabilities are consistent
+  */
+ static void
+-check_colors(TERMTYPE * tp)
++check_colors(TERMTYPE *tp)
+ {
+     if ((max_colors > 0) != (max_pairs > 0)
+ 	|| ((max_colors > max_pairs) && (initialize_pair == 0)))
+@@ -821,12 +853,12 @@
+ 
+     if (VALID_STRING(set_foreground)
+ 	&& VALID_STRING(set_a_foreground)
+-	&& !strcmp(set_foreground, set_a_foreground))
++	&& !_nc_capcmp(set_foreground, set_a_foreground))
+ 	_nc_warning("expected setf/setaf to be different");
+ 
+     if (VALID_STRING(set_background)
+ 	&& VALID_STRING(set_a_background)
+-	&& !strcmp(set_background, set_a_background))
++	&& !_nc_capcmp(set_background, set_a_background))
+ 	_nc_warning("expected setb/setab to be different");
+ 
+     /* see: has_colors() */
+@@ -877,7 +909,7 @@
+  * is mapped inconsistently.
+  */
+ static void
+-check_keypad(TERMTYPE * tp)
++check_keypad(TERMTYPE *tp)
+ {
+     char show[80];
+ 
+@@ -1075,7 +1107,7 @@
+  * markers.
+  */
+ static void
+-check_params(TERMTYPE * tp, const char *name, char *value)
++check_params(TERMTYPE *tp, const char *name, char *value)
+ {
+     int expected = expected_params(name);
+     int actual = 0;
+@@ -1200,20 +1232,22 @@
+     return TRUE;
+ }
+ 
+-static void
+-check_sgr(TERMTYPE * tp, char *zero, int num, char *cap, const char *name)
++static char *
++check_sgr(TERMTYPE *tp, char *zero, int num, char *cap, const char *name)
+ {
+-    char *test = tparm(set_attributes,
+-		       num == 1,
+-		       num == 2,
+-		       num == 3,
+-		       num == 4,
+-		       num == 5,
+-		       num == 6,
+-		       num == 7,
+-		       num == 8,
+-		       num == 9);
+-    tparm_errs += _nc_tparm_err;
++    char *test;
++
++    _nc_tparm_err = 0;
++    test = tparm(set_attributes,
++		 num == 1,
++		 num == 2,
++		 num == 3,
++		 num == 4,
++		 num == 5,
++		 num == 6,
++		 num == 7,
++		 num == 8,
++		 num == 9);
+     if (test != 0) {
+ 	if (PRESENT(cap)) {
+ 	    if (!similar_sgr(num, test, cap)) {
+@@ -1222,12 +1256,15 @@
+ 			    name, _nc_visbuf2(1, cap),
+ 			    num, _nc_visbuf2(2, test));
+ 	    }
+-	} else if (strcmp(test, zero)) {
++	} else if (_nc_capcmp(test, zero)) {
+ 	    _nc_warning("sgr(%d) present, but not %s", num, name);
+ 	}
+     } else if (PRESENT(cap)) {
+ 	_nc_warning("sgr(%d) missing, but %s present", num, name);
+     }
++    if (_nc_tparm_err)
++	_nc_warning("stack error in sgr(%d) string", num);
++    return test;
+ }
+ 
+ #define CHECK_SGR(num,name) check_sgr(tp, zero, num, name, #name)
+@@ -1236,7 +1273,7 @@
+  * logic that reads a terminfo entry)
+  */
+ static void
+-check_termtype(TERMTYPE * tp)
++check_termtype(TERMTYPE *tp, bool literal)
+ {
+     bool conflict = FALSE;
+     unsigned j, k;
+@@ -1247,37 +1284,39 @@
+      * a given string (e.g., KEY_END and KEY_LL).  But curses will only
+      * return one (the last one assigned).
+      */
+-    memset(fkeys, 0, sizeof(fkeys));
+-    for (j = 0; _nc_tinfo_fkeys[j].code; j++) {
+-	char *a = tp->Strings[_nc_tinfo_fkeys[j].offset];
+-	bool first = TRUE;
+-	if (!VALID_STRING(a))
+-	    continue;
+-	for (k = j + 1; _nc_tinfo_fkeys[k].code; k++) {
+-	    char *b = tp->Strings[_nc_tinfo_fkeys[k].offset];
+-	    if (!VALID_STRING(b)
+-		|| fkeys[k])
++    if (!(_nc_syntax == SYN_TERMCAP && capdump)) {
++	memset(fkeys, 0, sizeof(fkeys));
++	for (j = 0; _nc_tinfo_fkeys[j].code; j++) {
++	    char *a = tp->Strings[_nc_tinfo_fkeys[j].offset];
++	    bool first = TRUE;
++	    if (!VALID_STRING(a))
+ 		continue;
+-	    if (!strcmp(a, b)) {
+-		fkeys[j] = 1;
+-		fkeys[k] = 1;
+-		if (first) {
+-		    if (!conflict) {
+-			_nc_warning("Conflicting key definitions (using the last)");
+-			conflict = TRUE;
++	    for (k = j + 1; _nc_tinfo_fkeys[k].code; k++) {
++		char *b = tp->Strings[_nc_tinfo_fkeys[k].offset];
++		if (!VALID_STRING(b)
++		    || fkeys[k])
++		    continue;
++		if (!_nc_capcmp(a, b)) {
++		    fkeys[j] = 1;
++		    fkeys[k] = 1;
++		    if (first) {
++			if (!conflict) {
++			    _nc_warning("Conflicting key definitions (using the last)");
++			    conflict = TRUE;
++			}
++			fprintf(stderr, "... %s is the same as %s",
++				keyname((int) _nc_tinfo_fkeys[j].code),
++				keyname((int) _nc_tinfo_fkeys[k].code));
++			first = FALSE;
++		    } else {
++			fprintf(stderr, ", %s",
++				keyname((int) _nc_tinfo_fkeys[k].code));
+ 		    }
+-		    fprintf(stderr, "... %s is the same as %s",
+-			    keyname(_nc_tinfo_fkeys[j].code),
+-			    keyname(_nc_tinfo_fkeys[k].code));
+-		    first = FALSE;
+-		} else {
+-		    fprintf(stderr, ", %s",
+-			    keyname(_nc_tinfo_fkeys[k].code));
+ 		}
+ 	    }
++	    if (!first)
++		fprintf(stderr, "\n");
+ 	}
+-	if (!first)
+-	    fprintf(stderr, "\n");
+     }
+ 
+     for (j = 0; j < NUM_STRINGS(tp); j++) {
+@@ -1298,7 +1337,7 @@
+     ANDMISSING(cursor_visible, cursor_normal);
+ 
+     if (PRESENT(cursor_visible) && PRESENT(cursor_normal)
+-	&& !strcmp(cursor_visible, cursor_normal))
++	&& !_nc_capcmp(cursor_visible, cursor_normal))
+ 	_nc_warning("cursor_visible is same as cursor_normal");
+ 
+     /*
+@@ -1309,23 +1348,36 @@
+     ANDMISSING(change_scroll_region, save_cursor);
+     ANDMISSING(change_scroll_region, restore_cursor);
+ 
+-    tparm_errs = 0;
+     if (PRESENT(set_attributes)) {
+-	char *zero = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, 0);
++	char *zero = 0;
+ 
+-	zero = strdup(zero);
+-	CHECK_SGR(1, enter_standout_mode);
+-	CHECK_SGR(2, enter_underline_mode);
+-	CHECK_SGR(3, enter_reverse_mode);
+-	CHECK_SGR(4, enter_blink_mode);
+-	CHECK_SGR(5, enter_dim_mode);
+-	CHECK_SGR(6, enter_bold_mode);
+-	CHECK_SGR(7, enter_secure_mode);
+-	CHECK_SGR(8, enter_protected_mode);
+-	CHECK_SGR(9, enter_alt_charset_mode);
+-	free(zero);
+-	if (tparm_errs)
+-	    _nc_warning("stack error in sgr string");
++	_nc_tparm_err = 0;
++	if (PRESENT(exit_attribute_mode)) {
++	    zero = strdup(CHECK_SGR(0, exit_attribute_mode));
++	} else {
++	    zero = strdup(tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, 0));
++	}
++	if (_nc_tparm_err)
++	    _nc_warning("stack error in sgr(0) string");
++
++	if (zero != 0) {
++	    CHECK_SGR(1, enter_standout_mode);
++	    CHECK_SGR(2, enter_underline_mode);
++	    CHECK_SGR(3, enter_reverse_mode);
++	    CHECK_SGR(4, enter_blink_mode);
++	    CHECK_SGR(5, enter_dim_mode);
++	    CHECK_SGR(6, enter_bold_mode);
++	    CHECK_SGR(7, enter_secure_mode);
++	    CHECK_SGR(8, enter_protected_mode);
++	    CHECK_SGR(9, enter_alt_charset_mode);
++	    free(zero);
++	} else {
++	    _nc_warning("sgr(0) did not return a value");
++	}
++    } else if (PRESENT(exit_attribute_mode) &&
++	       set_attributes != CANCELLED_STRING) {
++	if (_nc_syntax == SYN_TERMINFO)
++	    _nc_warning("missing sgr string");
+     }
+ 
+     /*
+@@ -1343,5 +1395,5 @@
+      * Finally, do the non-verbose checks
+      */
+     if (save_check_termtype != 0)
+-	save_check_termtype(tp);
++	save_check_termtype(tp, literal);
+ }
+Index: progs/tset.c
+Prereq:  0.56 
+--- ncurses-5.4-20040208/progs/tset.c	2003-12-06 17:21:01.000000000 +0000
++++ ncurses-5.4-20050319/progs/tset.c	2004-12-04 15:39:11.000000000 +0000
+@@ -103,7 +103,7 @@
+ #include <dump_entry.h>
+ #include <transform.h>
+ 
+-MODULE_ID("$Id: tset.c,v 0.56 2003/12/06 17:21:01 tom Exp $")
++MODULE_ID("$Id: tset.c,v 0.57 2004/12/04 15:39:11 tom Exp $")
+ 
+ extern char **environ;
+ 
+@@ -1021,9 +1021,9 @@
+ 	(void) fprintf(stderr, "backspace.\n");
+     else if (newer < 040) {
+ 	newer ^= 0100;
+-	(void) fprintf(stderr, "control-%c (^%c).\n", newer, newer);
++	(void) fprintf(stderr, "control-%c (^%c).\n", UChar(newer), UChar(newer));
+     } else
+-	(void) fprintf(stderr, "%c.\n", newer);
++	(void) fprintf(stderr, "%c.\n", UChar(newer));
+ }
+ #endif
+ 
+Index: tack/Makefile.in
+Prereq:  1.31 
+--- ncurses-5.4-20040208/tack/Makefile.in	2003-11-01 22:46:24.000000000 +0000
++++ ncurses-5.4-20050319/tack/Makefile.in	2005-01-22 20:03:05.000000000 +0000
+@@ -1,4 +1,4 @@
+-# $Id: Makefile.in,v 1.31 2003/11/01 22:46:24 tom Exp $
++# $Id: Makefile.in,v 1.33 2005/01/22 20:03:05 tom Exp $
+ # Makefile for tack
+ #
+ # The variable 'srcdir' refers to the source-distribution, and can be set with
+@@ -64,7 +64,7 @@
+ LD		= @LD@
+ LINK		= @LINK_PROGS@ $(LIBTOOL_LINK) $(CC)
+ LDFLAGS		= @EXTRA_LDFLAGS@ \
+-		@PROG_ARGS@ @LDFLAGS@ @LD_MODEL@ @LIBS@ @EXTRA_LIBS@
++		@TINFO_ARGS@ @LDFLAGS@ @LD_MODEL@ @LIBS@
+ 
+ LDFLAGS_LIBTOOL	= $(LDFLAGS) $(CFLAGS_LIBTOOL)
+ LDFLAGS_NORMAL	= $(LDFLAGS) $(CFLAGS_NORMAL)
+Index: tack/charset.c
+Prereq:  1.8 
+--- ncurses-5.4-20040208/tack/charset.c	2001-06-18 18:44:26.000000000 +0000
++++ ncurses-5.4-20050319/tack/charset.c	2004-09-25 21:52:42.000000000 +0000
+@@ -1,18 +1,18 @@
+ /*
+ ** Copyright (C) 1991, 1997-2000 Free Software Foundation, Inc.
+-** 
++**
+ ** This file is part of TACK.
+-** 
++**
+ ** TACK is free software; you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation; either version 2, or (at your option)
+ ** any later version.
+-** 
++**
+ ** TACK is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ ** GNU General Public License for more details.
+-** 
++**
+ ** You should have received a copy of the GNU General Public License
+ ** along with TACK; see the file COPYING.  If not, write to
+ ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+@@ -21,7 +21,7 @@
+ 
+ #include <tack.h>
+ 
+-MODULE_ID("$Id: charset.c,v 1.8 2001/06/18 18:44:26 tom Exp $")
++MODULE_ID("$Id: charset.c,v 1.9 2004/09/25 21:52:42 tom Exp $")
+ 
+ /*
+ 	Menu definitions for alternate character set and SGR tests.
+@@ -194,7 +194,7 @@
+ }
+ 
+ 
+-void 
++void
+ eat_cookie(void)
+ {				/* put a blank if this is not a magic cookie
+ 				   terminal */
+@@ -203,7 +203,7 @@
+ }
+ 
+ 
+-void 
++void
+ put_mode(char *s)
+ {				/* send the attribute string (with or without
+ 				   % execution) */
+@@ -285,7 +285,7 @@
+ 	}
+ 	put_crlf();
+ 
+-#ifdef max_attributes 
++#ifdef max_attributes
+ 	if (max_attributes >= 0) {
+ 		sprintf(temp, "(ma) Maximum attributes %d  ", max_attributes);
+ 		ptext(temp);
+@@ -488,20 +488,20 @@
+ #ifdef ACS_ULCORNER
+ 	maybe_wait(5);
+ 	put_mode(enter_alt_charset_mode);
+-	put_this(ACS_ULCORNER);
+-	put_this(ACS_TTEE);
+-	put_this(ACS_URCORNER);
+-	put_this(ACS_ULCORNER);
+-	put_this(ACS_HLINE);
+-	put_this(ACS_URCORNER);
++	put_that(ACS_ULCORNER);
++	put_that(ACS_TTEE);
++	put_that(ACS_URCORNER);
++	put_that(ACS_ULCORNER);
++	put_that(ACS_HLINE);
++	put_that(ACS_URCORNER);
+ 	char_count += 6;
+ 	put_mode(exit_alt_charset_mode);
+ 	put_crlf();
+ 	put_mode(enter_alt_charset_mode);
+-	put_this(ACS_LTEE);
+-	put_this(ACS_PLUS);
+-	put_this(ACS_RTEE);
+-	put_this(ACS_VLINE);
++	put_that(ACS_LTEE);
++	put_that(ACS_PLUS);
++	put_that(ACS_RTEE);
++	put_that(ACS_VLINE);
+ 	if (magic_cookie_glitch >= 1)
+ 		put_this(' ');
+ 	else {
+@@ -509,18 +509,18 @@
+ 		put_this(' ');
+ 		put_mode(enter_alt_charset_mode);
+ 	}
+-	put_this(ACS_VLINE);
++	put_that(ACS_VLINE);
+ 	char_count += 6;
+ 	put_mode(exit_alt_charset_mode);
+ 	put_str("   Here are 2 boxes");
+ 	put_crlf();
+ 	put_mode(enter_alt_charset_mode);
+-	put_this(ACS_LLCORNER);
+-	put_this(ACS_BTEE);
+-	put_this(ACS_LRCORNER);
+-	put_this(ACS_LLCORNER);
+-	put_this(ACS_HLINE);
+-	put_this(ACS_LRCORNER);
++	put_that(ACS_LLCORNER);
++	put_that(ACS_BTEE);
++	put_that(ACS_LRCORNER);
++	put_that(ACS_LLCORNER);
++	put_that(ACS_HLINE);
++	put_that(ACS_LRCORNER);
+ 	char_count += 6;
+ 	put_mode(exit_alt_charset_mode);
+ 	put_crlf();
+Index: tack/control.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/tack/control.c	2000-03-04 21:10:59.000000000 +0000
++++ ncurses-5.4-20050319/tack/control.c	2004-12-04 16:12:38.000000000 +0000
+@@ -25,7 +25,7 @@
+ #include <sys/time.h>
+ #endif
+ 
+-MODULE_ID("$Id: control.c,v 1.3 2000/03/04 21:10:59 tom Exp $")
++MODULE_ID("$Id: control.c,v 1.5 2004/12/04 16:12:38 tom Exp $")
+ 
+ /* terminfo test program control subroutines */
+ 
+@@ -40,11 +40,11 @@
+ 
+ char txt_longer_test_time[80];	/* +) use longer time */
+ char txt_shorter_test_time[80];	/* -) use shorter time */
+-int pad_test_duration = 1;	/* number of seconds for a pad test */
++static int pad_test_duration = 1;	/* number of seconds for a pad test */
+ int auto_pad_mode;		/* run the time tests */
+ int no_alarm_event;		/* TRUE if the alarm has not gone off yet */
+-int usec_run_time;		/* length of last test in microseconds */
+-MY_TIMER stop_watch[MAX_TIMERS]; /* Hold the start timers */
++unsigned long usec_run_time;	/* length of last test in microseconds */
++static MY_TIMER stop_watch[MAX_TIMERS]; /* Hold the start timers */
+ 
+ char txt_longer_augment[80];	/* >) use bigger augment */
+ char txt_shorter_augment[80];	/* <) use smaller augment */
+@@ -67,15 +67,12 @@
+ int txp;			/* number of entries used */
+ int tx_characters;		/* printing characters sent by test */
+ int tx_cps;			/* characters per second */
+-struct test_list *tx_source;	/* The test that generated this data */
+-
+-extern struct test_menu pad_menu;	/* Pad menu structure */
+-extern struct test_list pad_test_list[];
++static struct test_list *tx_source;	/* The test that generated this data */
+ 
+ #define RESULT_BLOCK		1024
+ static int blocks;		/* number of result blocks available */
+ static struct test_results *results;	/* pointer to next available */
+-struct test_results *pads[STRCOUNT];	/* save pad results here */
++static struct test_results *pads[STRCOUNT];	/* save pad results here */
+ 
+ /*
+ **	event_start(number)
+@@ -500,7 +497,7 @@
+ 		ptext(temp);
+ 		while (r) {
+ 			sprintf(temp, "$<%d>", r->delay / 1000);
+-			put_columns(temp, strlen(temp), 10);
++			put_columns(temp, (int) strlen(temp), 10);
+ 			r = r->next;
+ 		}
+ 		r = pads[x];
+@@ -508,7 +505,7 @@
+ 			if (r->reps > 1) {
+ 				delay = r->delay / (r->reps * 100);
+ 				sprintf(temp, "$<%d.%d*>", delay / 10, delay % 10);
+-				put_columns(temp, strlen(temp), 10);
++				put_columns(temp, (int) strlen(temp), 10);
+ 			}
+ 			r = r->next;
+ 		}
+@@ -544,9 +541,9 @@
+ 			put_crlf();
+ 		}
+ 	}
+-	sprintf(tbuf, "%011u", usec_run_time);
+-	sprintf(temp, "Test time: %d.%s, characters per second %d, characters %d",
+-		usec_run_time / 1000000, &tbuf[5], tx_cps, tx_characters);
++	sprintf(tbuf, "%011lu", usec_run_time);
++	sprintf(temp, "Test time: %lu.%s, characters per second %d, characters %d",
++		usec_run_time / 1000000UL, &tbuf[5], tx_cps, tx_characters);
+ 	ptextln(temp);
+ 	for (i = 0; i < txp; i++) {
+ 		if ((j = get_string_cap_byvalue(tx_cap[i])) >= 0) {
+Index: tack/edit.c
+Prereq:  1.8 
+--- ncurses-5.4-20040208/tack/edit.c	2001-06-18 18:44:32.000000000 +0000
++++ ncurses-5.4-20050319/tack/edit.c	2004-12-04 16:09:20.000000000 +0000
+@@ -23,7 +23,7 @@
+ #include <time.h>
+ #include <tic.h>
+ 
+-MODULE_ID("$Id: edit.c,v 1.8 2001/06/18 18:44:32 tom Exp $")
++MODULE_ID("$Id: edit.c,v 1.9 2004/12/04 16:09:20 tom Exp $")
+ 
+ /*
+  * Terminfo edit features
+@@ -52,7 +52,7 @@
+ };
+ 
+ static char change_pad_text[MAX_CHANGES][80];
+-struct test_list change_pad_list[MAX_CHANGES] = {
++static struct test_list change_pad_list[MAX_CHANGES] = {
+ 	{MENU_LAST, 0, 0, 0, 0, 0, 0}
+ };
+ 
+@@ -65,15 +65,13 @@
+ 	build_change_menu, change_pad_list, 0, 0, 0
+ };
+ 
+-extern struct test_results *pads[STRCOUNT];	/* save pad results here */
+-
+ static TERMTYPE	original_term;		/* terminal type description */
+ 
+ static char flag_boolean[BOOLCOUNT];	/* flags for booleans */
+ static char flag_numerics[NUMCOUNT];	/* flags for numerics */
+ static char flag_strings[STRCOUNT];	/* flags for strings */
+ static int xon_index;			/* Subscript for (xon) */
+-int xon_shadow;
++static int xon_shadow;
+ 
+ static int start_display;		/* the display has just started */
+ static int display_lines;		/* number of lines displayed */
+Index: tack/fun.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/tack/fun.c	2000-03-04 20:29:21.000000000 +0000
++++ ncurses-5.4-20050319/tack/fun.c	2004-12-04 16:03:41.000000000 +0000
+@@ -21,7 +21,7 @@
+ 
+ #include <tack.h>
+ 
+-MODULE_ID("$Id: fun.c,v 1.3 2000/03/04 20:29:21 tom Exp $")
++MODULE_ID("$Id: fun.c,v 1.5 2004/12/04 16:03:41 tom Exp $")
+ 
+ /*
+  * Test the function keys on the terminal.  The code for echo tests
+@@ -58,10 +58,6 @@
+ 
+ #define MAX_STRINGS STRCOUNT
+ 
+-/* scan code externals */
+-extern int scan_max;		/* length of longest scan code */
+-extern char **scan_up, **scan_down, **scan_name;
+-extern int *scan_tested, *scan_length;
+ 
+ /* local definitions */
+ static const char *fk_name[MAX_STRINGS];
+@@ -102,7 +98,7 @@
+ 			if (fk_label[i]) {
+ 				sprintf(outbuf, "%s %s",
+ 					fk_name[i] ? fk_name[i] : "??", fk_label[i]);
+-				put_columns(outbuf, strlen(outbuf), 16);
++				put_columns(outbuf, (int) strlen(outbuf), 16);
+ 			}
+ 		}
+ 		put_newlines(2);
+Index: tack/init.c
+Prereq:  1.4 
+--- ncurses-5.4-20040208/tack/init.c	2003-09-20 19:40:57.000000000 +0000
++++ ncurses-5.4-20050319/tack/init.c	2004-12-04 16:11:46.000000000 +0000
+@@ -22,7 +22,7 @@
+ 
+ #include <tack.h>
+ 
+-MODULE_ID("$Id: init.c,v 1.4 2003/09/20 19:40:57 tom Exp $")
++MODULE_ID("$Id: init.c,v 1.5 2004/12/04 16:11:46 tom Exp $")
+ 
+ #if NCURSES_VERSION_MAJOR >= 5 || NCURSES_VERSION_PATCH >= 981219
+ #define _nc_get_curterm(p) _nc_get_tty_mode(p)
+@@ -170,7 +170,11 @@
+ 	report_cap("ACK   (u8)", user8);
+ #endif
+ 
+-	sprintf(temp, "\nTerminal size: %d x %d.  Baud rate: %ld.  Frame size: %d.%d", columns, lines, tty_baud_rate, tty_frame_size >> 1, (tty_frame_size & 1) * 5);
++	sprintf(temp, "\nTerminal size: %d x %d.  Baud rate: %u.  Frame size: %d.%d",
++		columns, lines,
++		tty_baud_rate,
++		tty_frame_size >> 1,
++		(tty_frame_size & 1) * 5);
+ 	putln(temp);
+ }
+ 
+Index: tack/output.c
+Prereq:  1.8 
+--- ncurses-5.4-20040208/tack/output.c	2003-10-25 20:43:43.000000000 +0000
++++ ncurses-5.4-20050319/tack/output.c	2004-12-04 15:41:31.000000000 +0000
+@@ -23,7 +23,7 @@
+ #include <tack.h>
+ #include <time.h>
+ 
+-MODULE_ID("$Id: output.c,v 1.8 2003/10/25 20:43:43 tom Exp $")
++MODULE_ID("$Id: output.c,v 1.9 2004/12/04 15:41:31 tom Exp $")
+ 
+ /* globals */
+ long char_sent;			/* number of characters sent */
+@@ -34,7 +34,7 @@
+ int can_go_home;		/* TRUE if we can fashion a home command */
+ int can_clear_screen;		/* TRUE if we can somehow clear the screen */
+ int raw_characters_sent;	/* Total output characters */
+-int log_count;			/* Number of characters on a log line */
++static int log_count;		/* Number of characters on a log line */
+ 
+ /* translate mode default strings */
+ #define TM_carriage_return	TM_string[0].value
+Index: tack/pad.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/tack/pad.c	2003-10-18 22:11:29.000000000 +0000
++++ ncurses-5.4-20050319/tack/pad.c	2004-12-04 16:09:20.000000000 +0000
+@@ -21,7 +21,7 @@
+ 
+ #include <tack.h>
+ 
+-MODULE_ID("$Id: pad.c,v 1.3 2003/10/18 22:11:29 tom Exp $")
++MODULE_ID("$Id: pad.c,v 1.5 2004/12/04 16:09:20 tom Exp $")
+ 
+ /* test the pad counts on the terminal */
+ 
+@@ -61,8 +61,6 @@
+ static void pad_smacs(struct test_list *, int *, int *);
+ static void pad_crash(struct test_list *, int *, int *);
+ 
+-extern struct test_menu change_pad_menu;
+-
+ /*
+    Any command found in this list, executed from a "Done" prompt
+    will force the default action to repeat rather than next.
+@@ -168,10 +166,8 @@
+ 	{MENU_LAST, 0, 0, 0, 0, 0, 0}
+ };
+ 
+-extern int test_complete;	/* counts number of tests completed */
+-
+ /* globals */
+-int hzcc;			/* horizontal character count */
++static int hzcc;		/* horizontal character count */
+ char letter;			/* current character being displayed */
+ int letter_number;		/* points into letters[] */
+ int augment, repeats;		/* number of characters (or lines) effected */
+@@ -1759,7 +1755,7 @@
+ 			put_str(every_line);
+ 		}
+ 		tt_putparm(change_scroll_region, 1, 0, lines - 1);
+-		tt_putparm(cursor_address, 1, lines - 1, strlen(every_line));
++		tt_putparm(cursor_address, 1, lines - 1, (int) strlen(every_line));
+ 	} while(still_testing());
+ 	pad_test_shutdown(t, 0);
+ 	put_str("  ");
+Index: tack/scan.c
+Prereq:  1.2 
+--- ncurses-5.4-20040208/tack/scan.c	1999-08-21 23:09:35.000000000 +0000
++++ ncurses-5.4-20050319/tack/scan.c	2004-12-04 16:06:02.000000000 +0000
+@@ -22,24 +22,25 @@
+ 
+ #include <tack.h>
+ 
+-MODULE_ID("$Id: scan.c,v 1.2 1999/08/21 23:09:35 tom Exp $")
++MODULE_ID("$Id: scan.c,v 1.4 2004/12/04 16:06:02 tom Exp $")
+ 
+-int scan_max;			/* length of longest scan code */
++unsigned scan_max;		/* length of longest scan code */
+ char **scan_up, **scan_down, **scan_name;
+-int *scan_tested, *scan_length, *scan_value;
++unsigned *scan_tested, *scan_length;
++static unsigned *scan_value;
+ 
+ static int shift_state;
+ static char *str;
+ static int debug_char_count;
+ 
+-#define SHIFT_KEY 0x100
++#define SHIFT_KEY   0x100
+ #define CONTROL_KEY 0x200
+-#define META_KEY 0x400
+-#define CAPS_LOCK 0x800
++#define META_KEY    0x400
++#define CAPS_LOCK   0x800
+ 
+ static const struct {
+ 	const char *name;
+-	int type;
++	unsigned type;
+ }  scan_special[] = {
+ 	{"<shift>", SHIFT_KEY},
+ 	{"<left shift>", SHIFT_KEY},
+@@ -102,6 +103,7 @@
+ 	char *s, *sl;
+ 	FILE *fp;
+ 	int ch, i, j;
++	unsigned len;
+ 	char home[512];
+ 
+ 	if ((str = getenv("HOME")))
+@@ -140,9 +142,9 @@
+ 	scan_up = (char **) malloc(sizeof(char *) * MAX_SCAN);
+ 	scan_down = (char **) malloc(sizeof(char *) * MAX_SCAN);
+ 	scan_name = (char **) malloc(sizeof(char *) * MAX_SCAN);
+-	scan_tested = (int *) malloc(sizeof(int *) * MAX_SCAN);
+-	scan_length = (int *) malloc(sizeof(int *) * MAX_SCAN);
+-	scan_value = (int *) malloc(sizeof(int *) * MAX_SCAN);
++	scan_tested = (unsigned *) malloc(sizeof(unsigned *) * MAX_SCAN);
++	scan_length = (unsigned *) malloc(sizeof(unsigned *) * MAX_SCAN);
++	scan_value = (unsigned *) malloc(sizeof(unsigned *) * MAX_SCAN);
+ 	scan_up[0] = scan_down[0] = scan_name[0] = (char *) 0;
+ 	str = (char *) malloc(4096);	/* buffer space */
+ 	sl = str + 4000;	/* an upper limit */
+@@ -165,11 +167,11 @@
+ 		scan_name[i] = str;
+ 
+ 		scan_length[i] = strlen(scan_down[i]);
+-		ch = strlen(scan_up[i]) + scan_length[i];
+-		if (ch > scan_max)
+-			scan_max = ch;
++		len = strlen(scan_up[i]) + scan_length[i];
++		if (len > scan_max)
++			scan_max = len;
+ 
+-		scan_value[i] = scan_name[i][0];
++		scan_value[i] = UChar(scan_name[i][0]);
+ 		if (scan_name[i][1])	/* multi-character name */
+ 			for (j = 0; scan_special[j].name; j++) {
+ 				if (!strcmp(scan_name[i], scan_special[j].name)) {
+@@ -202,7 +204,8 @@
+ scan_key(void)
+ {				/* read a key and translate scan mode to
+ 				   ASCII */
+-	int i, j, ch;
++	unsigned i;
++	int j, ch;
+ 	char buf[64];
+ 
+ 	for (i = 1;; i++) {
+Index: tack/sync.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/tack/sync.c	2001-06-16 17:55:48.000000000 +0000
++++ ncurses-5.4-20050319/tack/sync.c	2004-12-04 15:57:42.000000000 +0000
+@@ -22,7 +22,7 @@
+ #include <tack.h>
+ #include <time.h>
+ 
+-MODULE_ID("$Id: sync.c,v 1.3 2001/06/16 17:55:48 tom Exp $")
++MODULE_ID("$Id: sync.c,v 1.4 2004/12/04 15:57:42 tom Exp $")
+ 
+ /* terminal-synchronization and performance tests */
+ 
+@@ -31,7 +31,7 @@
+ static void sync_clear(struct test_list *, int *, int *);
+ static void sync_summary(struct test_list *, int *, int *);
+ 
+-struct test_list sync_test_list[] = {
++static struct test_list sync_test_list[] = {
+ 	{MENU_NEXT, 0, 0, 0, "b) baud rate test", sync_home, 0},
+ 	{MENU_NEXT, 0, 0, 0, "l) scroll performance", sync_lines, 0},
+ 	{MENU_NEXT, 0, 0, 0, "c) clear screen performance", sync_clear, 0},
+@@ -48,16 +48,16 @@
+ };
+ 
+ int tty_can_sync;		/* TRUE if tty_sync_error() returned FALSE */
+-int tty_newline_rate;		/* The number of newlines per second */
+-int tty_clear_rate;		/* The number of clear-screens per second */
++static int tty_newline_rate;	/* The number of newlines per second */
++static int tty_clear_rate;	/* The number of clear-screens per second */
+ int tty_cps;			/* The number of characters per second */
+ 
+ #define TTY_ACK_SIZE 64
+ 
+-int ACK_terminator;		/* terminating ACK character */
+-int ACK_length;			/* length of ACK string */
+-const char *tty_ENQ;		/* enquire string */
+-char tty_ACK[TTY_ACK_SIZE];	/* ACK response, set by tty_sync_error() */
++static int ACK_terminator;	/* terminating ACK character */
++static int ACK_length;		/* length of ACK string */
++static const char *tty_ENQ;	/* enquire string */
++static char tty_ACK[TTY_ACK_SIZE]; /* ACK response, set by tty_sync_error() */
+ 
+ /*****************************************************************************
+  *
+Index: tack/sysdep.c
+Prereq:  1.11 
+--- ncurses-5.4-20040208/tack/sysdep.c	2002-04-21 19:40:43.000000000 +0000
++++ ncurses-5.4-20050319/tack/sysdep.c	2004-12-04 16:06:42.000000000 +0000
+@@ -46,7 +46,7 @@
+ #endif
+ #endif
+ 
+-MODULE_ID("$Id: sysdep.c,v 1.11 2002/04/21 19:40:43 tom Exp $")
++MODULE_ID("$Id: sysdep.c,v 1.13 2004/12/04 16:06:42 tom Exp $")
+ 
+ #if DECL_ERRNO
+ extern int errno;
+@@ -60,7 +60,7 @@
+ 
+ /* globals */
+ int tty_frame_size;		/* asynch frame size times 2 */
+-unsigned long tty_baud_rate;	/* baud rate - bits per second */
++unsigned tty_baud_rate;		/* baud rate - bits per second */
+ int not_a_tty;			/* TRUE if output is not a tty (i.e. pipe) */
+ int nodelay_read;		/* TRUE if NDELAY is set */
+ 
+@@ -179,8 +179,8 @@
+ #endif	/* NL1 */
+ 		break;
+ 	}
+-	if (!(new_modes.c_oflag & ~OPOST))
+-		new_modes.c_oflag &= ~OPOST;
++	if (!(new_modes.c_oflag & (unsigned long) ~OPOST))
++		new_modes.c_oflag &= (unsigned long) ~OPOST;
+ #else
+ 	new_modes.sg_flags |= RAW;
+ 	if (not_a_tty)
+@@ -396,7 +396,7 @@
+ 		if (ask > max) {
+ 			ask = max;
+ 		}
+-		if ((got = read(fileno(stdin), s, ask))) {
++		if ((got = read(fileno(stdin), s, (unsigned) ask))) {
+ 			s += got;
+ 		} else {
+ 			break;
+@@ -497,5 +497,5 @@
+ {
+ 	signal(SIGALRM, alarm_event);
+ 	no_alarm_event = 1;
+-	(void) alarm(seconds);
++	(void) alarm((unsigned) seconds);
+ }
+Index: tack/tack.c
+Prereq:  1.2 
+--- ncurses-5.4-20040208/tack/tack.c	2001-10-28 01:05:35.000000000 +0000
++++ ncurses-5.4-20050319/tack/tack.c	2004-12-04 16:12:06.000000000 +0000
+@@ -21,7 +21,7 @@
+ 
+ #include <tack.h>
+ 
+-MODULE_ID("$Id: tack.c,v 1.2 2001/10/28 01:05:35 tom Exp $")
++MODULE_ID("$Id: tack.c,v 1.3 2004/12/04 16:12:06 tom Exp $")
+ 
+ /*
+    This program is designed to test terminfo, not curses.  Therefore
+@@ -62,14 +62,12 @@
+  *
+  *****************************************************************************/
+ 
+-extern struct test_menu sync_menu;
+-
+ static void tools_hex_echo(struct test_list *, int *, int *);
+ static void tools_debug(struct test_list *, int *, int *);
+ 
+ static char hex_echo_menu_entry[80];
+ 
+-struct test_list tools_test_list[] = {
++static struct test_list tools_test_list[] = {
+ 	{0, 0, 0, 0, "s) ANSI status reports", tools_status, 0},
+ 	{0, 0, 0, 0, "g) ANSI SGR modes (bold, underline, reverse)", tools_sgr, 0},
+ 	{0, 0, 0, 0, "c) ANSI character sets", tools_charset, 0},
+@@ -83,7 +81,7 @@
+ 	{MENU_LAST, 0, 0, 0, 0, 0, 0}
+ };
+ 
+-struct test_menu tools_menu = {
++static struct test_menu tools_menu = {
+ 	0, 'q', 0, "Tools Menu", "tools",
+ 	0, 0, tools_test_list, 0, 0, 0
+ };
+@@ -115,24 +113,18 @@
+ 	tty_show_state, tty_test_list, 0, 0, 0
+ };
+ 
+-extern struct test_list edit_test_list[];
+-
+ struct test_menu edit_menu = {
+ 	0, 'q', 0, "Edit terminfo menu",
+ 	"edit", 0,
+ 	0, edit_test_list, 0, 0, 0
+ };
+ 
+-extern struct test_list mode_test_list[];
+-
+-struct test_menu mode_menu = {
++static struct test_menu mode_menu = {
+ 	0, 'n', 0, "Test modes and glitches:",
+ 	"mode", "n) run standard tests",
+ 	0, mode_test_list, 0, 0, 0
+ };
+ 
+-extern struct test_list acs_test_list[];
+-
+ static struct test_menu acs_menu = {
+ 	0, 'n', 0,
+ 	"Test alternate character set and graphics rendition:",
+@@ -140,17 +132,13 @@
+ 	0, acs_test_list, 0, 0, 0
+ };
+ 
+-extern struct test_list color_test_list[];
+-
+-struct test_menu color_menu = {
++static struct test_menu color_menu = {
+ 	0, 'n', 0,
+ 	"Test color:",
+ 	"color", "n) run standard tests",
+ 	0, color_test_list, 0, 0, 0
+ };
+ 
+-extern struct test_list crum_test_list[];
+-
+ static struct test_menu crum_menu = {
+ 	0, 'n', 0,
+ 	"Test cursor movement:",
+@@ -158,8 +146,6 @@
+ 	0, crum_test_list, 0, 0, 0
+ };
+ 
+-extern struct test_list funkey_test_list[];
+-
+ static struct test_menu funkey_menu = {
+ 	0, 'n', 0,
+ 	"Test function keys:",
+@@ -167,8 +153,6 @@
+ 	sync_test, funkey_test_list, 0, 0, 0
+ };
+ 
+-extern struct test_list printer_test_list[];
+-
+ static struct test_menu printer_menu = {
+ 	0, 'n', 0,
+ 	"Test printer:",
+@@ -177,7 +161,6 @@
+ };
+ 
+ static void pad_gen(struct test_list *, int *, int *);
+-extern struct test_list pad_test_list[];
+ 
+ static struct test_menu pad_menu = {
+ 	0, 'n', 0,
+@@ -203,7 +186,7 @@
+ };
+ 
+ 
+-struct test_menu normal_menu = {
++static struct test_menu normal_menu = {
+ 	0, 'n', 0, "Main test menu",
+ 	"test", "n) run standard tests",
+ 	0, normal_test_list, 0, 0, 0
+@@ -216,7 +199,7 @@
+ 
+ static char logging_menu_entry[80] = "l) start logging";
+ 
+-struct test_list start_test_list[] = {
++static struct test_list start_test_list[] = {
+ 	{0, 0, 0, 0, "b) display basic information", start_basic, 0},
+ 	{0, 0, 0, 0, "m) change modes", start_modes, 0},
+ 	{0, 0, 0, 0, "t) tools", start_tools, 0},
+@@ -226,7 +209,7 @@
+ };
+ 	
+ 
+-struct test_menu start_menu = {
++static struct test_menu start_menu = {
+ 	0, 'n', 0, "Main Menu", "tack", 0,
+ 	0, start_test_list, 0, 0, 0
+ };
+@@ -319,7 +302,7 @@
+ {
+ 	put_crlf();
+ 	(void) sprintf(temp,
+-		"Accepting %d bits, UNIX delays %d, XON/XOFF %sabled, speed %ld, translate %s, scan-code mode %s.",
++		"Accepting %d bits, UNIX delays %d, XON/XOFF %sabled, speed %u, translate %s, scan-code mode %s.",
+ 		(char_mask == ALLOW_PARITY) ? 8 : 7,
+ 		select_delay_type,
+ 		select_xon_xoff ? "en" : "dis",
+Index: tack/tack.h
+Prereq:  1.10 
+--- ncurses-5.4-20040208/tack/tack.h	2003-10-18 22:26:59.000000000 +0000
++++ ncurses-5.4-20050319/tack/tack.h	2004-12-04 16:10:12.000000000 +0000
+@@ -19,7 +19,7 @@
+ ** Boston, MA 02111-1307, USA.
+ */
+ 
+-/* $Id: tack.h,v 1.10 2003/10/18 22:26:59 tom Exp $ */
++/* $Id: tack.h,v 1.12 2004/12/04 16:10:12 tom Exp $ */
+ 
+ #ifndef NCURSES_TACK_H_incl
+ #define NCURSES_TACK_H_incl 1
+@@ -77,9 +77,9 @@
+ extern int tty_can_sync;
+ extern int total_pads_sent;	/* count pad characters sent */
+ extern int total_caps_sent;	/* count caps sent */
+-extern int total_printing_characters;	/* count printing characters sent */
++extern int total_printing_characters; /* count printing characters sent */
+ extern int no_alarm_event;	/* TRUE if the alarm has not gone off yet */
+-extern int usec_run_time;	/* length of last test in microseconds */
++extern unsigned long usec_run_time; /* length of last test in microseconds */
+ extern int raw_characters_sent;	/* Total output characters */
+ 
+ /* Stopwatch event timers */
+@@ -129,7 +129,7 @@
+ extern int select_xon_xoff;
+ 
+ extern int tty_frame_size;
+-extern unsigned long tty_baud_rate;
++extern unsigned tty_baud_rate;
+ extern int tty_cps;		/* The number of characters per second */
+ extern int not_a_tty, nodelay_read;
+ extern int send_reset_init;
+@@ -268,138 +268,156 @@
+ 
+ #define REQUEST_PROMPT 256
+ 
+-extern char prompt_string[80];	/* menu prompt storage */
+-extern struct test_menu edit_menu;
+-extern struct test_list *augment_test;
+-
+ /* tack.c */
++extern struct test_menu edit_menu;
+ extern void show_usage(char *);
+ extern void print_version(void);
+ 
+ /* output.c */
+-extern void tt_tputs(const char *, int);
+-extern void tt_putp(const char *);
+-extern void tt_putparm(NCURSES_CONST char *, int, int, int);
+-extern int tc_putp(const char *);
++extern char *expand(const char *);
++extern char *expand_command(const char *);
++extern char *expand_to(char *, int);
++extern char *hex_expand_to(char *, int);
++extern char *print_expand(char *);
++extern int getchp(int);
++extern int getnext(int);
+ extern int tc_putch(int);
+-extern void putchp(int);
++extern int tc_putp(const char *);
++extern int wait_here(void);
++extern void go_home(void);
++extern void home_down(void);
++extern void maybe_wait(int);
++extern void ptext(const char *);
++extern void ptextln(const char *);
++extern void put_clear(void);
++extern void put_columns(const char *, int, int);
+ extern void put_cr(void);
+ extern void put_crlf(void);
+-extern void put_clear(void);
+ extern void put_dec(char *, int);
+-extern void put_str(const char *);
+-extern void put_lf(void);
+ extern void put_ind(void);
++extern void put_lf(void);
+ extern void put_newlines(int);
+-extern void put_columns(const char *, int, int);
++extern void put_str(const char *);
+ extern void put_this(int);
++extern void putchp(int);
+ extern void putln(const char *);
+-extern void ptext(const char *);
+-extern void ptextln(const char *);
+-extern void home_down(void);
+-extern void go_home(void);
+-extern void three_digit(char *, int);
+-extern int getchp(int);
+-extern char *expand(const char *);
+-extern char *expand_to(char *, int);
+-extern char *expand_command(const char *);
+-extern char *hex_expand_to(char *, int);
+-extern char *print_expand(char *);
+-extern void maybe_wait(int);
+-extern int wait_here(void);
+ extern void read_string(char *, int);
+-extern int getnext(int);
++extern void three_digit(char *, int);
++extern void tt_putp(const char *);
++extern void tt_putparm(NCURSES_CONST char *, int, int, int);
++extern void tt_tputs(const char *, int);
++
++#define put_that(n) put_this((int) (n))
+ 
+ /* control.c */
+-extern void event_start(int);
+-extern long event_time(int);
++extern struct test_list color_test_list[];
+ extern char *liberated(char *);
+-extern void page_loop(void);
+-extern void control_init(void);
++extern char txt_longer_augment[80];
++extern char txt_longer_test_time[80];
++extern char txt_shorter_augment[80];
++extern char txt_shorter_test_time[80];
+ extern int msec_cost(const char *const, int);
+ extern int skip_pad_test(struct test_list *, int *, int *, const char *);
+-extern void pad_test_startup(int);
++extern int sliding_scale(int, int, int);
+ extern int still_testing(void);
+-extern void pad_test_shutdown(struct test_list *, int);
++extern long event_time(int);
++extern void control_init(void);
+ extern void dump_test_stats(struct test_list *, int *, int *);
++extern void event_start(int);
++extern void longer_augment(struct test_list *, int *, int *);
+ extern void longer_test_time(struct test_list *, int *, int *);
+-extern void shorter_test_time(struct test_list *, int *, int *);
+-extern char txt_longer_test_time[80];
+-extern char txt_shorter_test_time[80];
++extern void pad_test_shutdown(struct test_list *, int);
++extern void pad_test_startup(int);
++extern void page_loop(void);
+ extern void set_augment_txt(void);
+-extern void longer_augment(struct test_list *, int *, int *);
+ extern void shorter_augment(struct test_list *, int *, int *);
+-extern char txt_longer_augment[80];
+-extern char txt_shorter_augment[80];
+-extern int sliding_scale(int, int, int);
+-
+-/* sync.c */
+-extern void verify_time(void);
+-extern int tty_sync_error(void);
+-extern void flush_input(void);
+-extern void sync_test(struct test_menu *);
+-extern void sync_handshake(struct test_list *, int *, int *);
++extern void shorter_test_time(struct test_list *, int *, int *);
+ 
+ /* charset.c */
++extern struct test_list acs_test_list[];
+ extern void set_attr(int);
+ extern void eat_cookie(void);
+ extern void put_mode(char *);
+ 
+-/* init.c */
+-extern void reset_init(void);
+-extern void display_basic(void);
+-extern void put_name(const char *, const char *);
+-extern void charset_can_test(void);
+-extern void curses_setup(char *);
+-extern void bye_kids(int);
+-
+-/* scan.c */
+-extern int scan_key(void);
+-extern void scan_init(char *fn);
++/* crum.c */
++extern struct test_list crum_test_list[];
+ 
+ /* ansi.c */
+ extern void tools_status(struct test_list *, int *, int *);
+ extern void tools_charset(struct test_list *, int *, int *);
+ extern void tools_sgr(struct test_list *, int *, int *);
+ 
+-/* pad.c */
++/* edit.c */
++extern struct test_menu change_pad_menu;
++extern struct test_list edit_test_list[];
++extern char *get_string_cap_byname(const char *, const char **);
++extern int cap_match(const char *names, const char *cap);
++extern int get_string_cap_byvalue(const char *);
++extern int user_modified(void);
++extern void can_test(const char *, int);
++extern void cap_index(const char *, int *);
++extern void edit_init(void);
++extern void save_info(struct test_list *, int *, int *);
++extern void show_report(struct test_list *, int *, int *);
+ 
+ /* fun.c */
++extern struct test_list funkey_test_list[];
++extern struct test_list printer_test_list[];
+ extern void enter_key(const char *, char *, char *);
+ extern int tty_meta_prep(void);
+ extern void tools_report(struct test_list *, int *, int *);
+ 
++/* init.c */
++extern void reset_init(void);
++extern void display_basic(void);
++extern void put_name(const char *, const char *);
++extern void charset_can_test(void);
++extern void curses_setup(char *);
++extern void bye_kids(int);
++
++/* scan.c */
++extern char **scan_up, **scan_down, **scan_name;
++extern int scan_key(void);
++extern unsigned scan_max;	/* length of longest scan code */
++extern unsigned *scan_tested, *scan_length;
++extern void scan_init(char *fn);
++
+ /* sysdep.c */
+-extern void tty_set(void);
+-extern void tty_raw(int, int);
+-extern void tty_init(void);
+-extern void tty_reset(void);
+-extern void spin_flush(void);
++extern int initial_stty_query(int);
++extern int stty_query(int);
++extern void ignoresig(void);
+ extern void read_key(char *, int);
+ extern void set_alarm_clock(int);
+-extern void ignoresig(void);
+-extern int stty_query(int);
+-extern int initial_stty_query(int);
+-
+-/* edit.c */
+-extern int user_modified(void);
+-extern void save_info(struct test_list *, int *, int *);
+-extern void can_test(const char *, int);
+-extern void cap_index(const char *, int *);
+-extern int cap_match(const char *names, const char *cap);
+-extern void edit_init(void);
+-extern char *get_string_cap_byname(const char *, const char **);
+-extern int get_string_cap_byvalue(const char *);
+-extern void show_report(struct test_list *, int *, int *);
++extern void spin_flush(void);
++extern void tty_init(void);
++extern void tty_raw(int, int);
++extern void tty_reset(void);
++extern void tty_set(void);
+ 
+ /* menu.c */
+-extern void menu_prompt(void);
+-extern void menu_can_scan(const struct test_menu *);
+-extern void menu_display(struct test_menu *, int *);
++extern char prompt_string[80];	/* menu prompt storage */
++extern int subtest_menu(struct test_list *, int *, int *);
++extern struct test_list *augment_test;
+ extern void generic_done_message(struct test_list *, int *, int *);
+-extern void pad_done_message(struct test_list *, int *, int *);
++extern void menu_can_scan(const struct test_menu *);
+ extern void menu_clear_screen(struct test_list *, int *, int *);
++extern void menu_display(struct test_menu *, int *);
++extern void menu_prompt(void);
+ extern void menu_reset_init(struct test_list *, int *, int *);
+-extern int subtest_menu(struct test_list *, int *, int *);
++extern void pad_done_message(struct test_list *, int *, int *);
++
++/* modes.c */
++extern struct test_list mode_test_list[];
++
++/* pad.c */
++extern struct test_list pad_test_list[];
++
++/* sync.c */
++extern struct test_menu sync_menu;
++extern int tty_sync_error(void);
++extern void flush_input(void);
++extern void sync_handshake(struct test_list *, int *, int *);
++extern void sync_test(struct test_menu *);
++extern void verify_time(void);
+ 
+ #endif /* NCURSES_TACK_H_incl */
+Index: test/Makefile.in
+Prereq:  1.77 
+--- ncurses-5.4-20040208/test/Makefile.in	2003-12-07 01:36:16.000000000 +0000
++++ ncurses-5.4-20050319/test/Makefile.in	2005-01-29 19:27:15.000000000 +0000
+@@ -1,6 +1,6 @@
+-# $Id: Makefile.in,v 1.77 2003/12/07 01:36:16 tom Exp $
++# $Id: Makefile.in,v 1.81 2005/01/29 19:27:15 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
++# Copyright (c) 1998-2003,2005 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"), #
+@@ -77,7 +77,7 @@
+ LD		= @LD@
+ LINK		= @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) $(CFLAGS)
+ 
+-LDFLAGS		= @LD_MODEL@ @TEST_ARGS@ @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
++LDFLAGS		= @LD_MODEL@ @LOCAL_LDFLAGS@ @LDFLAGS@
+ 
+ LDFLAGS_LIBTOOL	= $(LDFLAGS) $(CFLAGS_LIBTOOL)
+ LDFLAGS_NORMAL	= $(LDFLAGS) $(CFLAGS_NORMAL)
+@@ -85,7 +85,17 @@
+ LDFLAGS_PROFILE	= $(LDFLAGS) $(CFLAGS_PROFILE)
+ LDFLAGS_SHARED	= $(LDFLAGS) $(CFLAGS_SHARED) @LD_SHARED_OPTS@
+ 
+-LDFLAGS_DEFAULT	= $(LDFLAGS_@DFT_UPR_MODEL@)
++# use these for linking with all of the libraries
++LIBS_DEFAULT	= @TEST_ARGS@ @LIBS@
++LDFLAGS_DEFAULT	= $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_DEFAULT)
++
++# use these for linking with the (n)curses library
++LIBS_CURSES	= `echo "@TEST_ARGS@ @LIBS@" | sed -e 's/-lform.*-lpanel[^ ]*//'`
++LDFLAGS_CURSES	= $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_CURSES)
++
++# use these for linking with the tinfo library if we have it, or curses library if not
++LIBS_TINFO	= @TINFO_ARGS@ @LIBS@
++LDFLAGS_TINFO	= $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_TINFO)
+ 
+ LINT		= @LINT@
+ LINT_OPTS	= @LINT_OPTS@
+@@ -131,29 +141,32 @@
+ 
+ sources:
+ 
++tags:
++	ctags *.[ch]
++
+ background$x: $(MODEL)/background$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/background$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/background$o $(LDFLAGS_CURSES)
+ 
+ blue$x: $(MODEL)/blue$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/blue$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/blue$o $(LDFLAGS_CURSES)
+ 
+ bs$x: $(MODEL)/bs$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/bs$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/bs$o $(LDFLAGS_CURSES)
+ 
+ cardfile$x: $(MODEL)/cardfile$o $(LOCAL_LIBS)
+ 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/cardfile$o $(LDFLAGS_DEFAULT)
+ 
+ color_set$x: $(MODEL)/color_set$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/color_set$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/color_set$o $(LDFLAGS_CURSES)
+ 
+ demo_defkey$x: $(MODEL)/demo_defkey$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_defkey$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_defkey$o $(LDFLAGS_CURSES)
+ 
+ demo_forms$x: $(MODEL)/demo_forms$o $(MODEL)/edit_field$o $(LOCAL_LIBS)
+ 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_forms$o $(MODEL)/edit_field$o $(LDFLAGS_DEFAULT)
+ 
+ demo_keyok$x: $(MODEL)/demo_keyok$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_keyok$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_keyok$o $(LDFLAGS_CURSES)
+ 
+ demo_menus$x: $(MODEL)/demo_menus$o $(LOCAL_LIBS)
+ 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_menus$o $(LDFLAGS_DEFAULT)
+@@ -162,76 +175,76 @@
+ 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_panels$o $(LDFLAGS_DEFAULT)
+ 
+ ditto$x: $(MODEL)/ditto$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ditto$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ditto$o $(LDFLAGS_CURSES)
+ 
+ dots$x: $(MODEL)/dots$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/dots$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/dots$o $(LDFLAGS_TINFO)
+ 
+ filter$x: $(MODEL)/filter$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/filter$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/filter$o $(LDFLAGS_CURSES)
+ 
+ firework$x: $(MODEL)/firework$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/firework$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/firework$o $(LDFLAGS_CURSES)
+ 
+ firstlast$x: $(MODEL)/firstlast$o $(LOCAL_LIBS)
+ 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/firstlast$o $(LDFLAGS_DEFAULT)
+ 
+ gdc$x: $(MODEL)/gdc$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/gdc$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/gdc$o $(LDFLAGS_CURSES)
+ 
+ hanoi$x: $(MODEL)/hanoi$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hanoi$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hanoi$o $(LDFLAGS_CURSES)
+ 
+ hashtest$x: $(MODEL)/hashtest$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hashtest$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hashtest$o $(LDFLAGS_CURSES)
+ 
+ inserts$x: $(MODEL)/inserts$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/inserts$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/inserts$o $(LDFLAGS_CURSES)
+ 
+ ins_wide$x: $(MODEL)/ins_wide$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ins_wide$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ins_wide$o $(LDFLAGS_CURSES)
+ 
+ keynames$x: $(MODEL)/keynames$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/keynames$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/keynames$o $(LDFLAGS_TINFO)
+ 
+ knight$x: $(MODEL)/knight$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/knight$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/knight$o $(LDFLAGS_CURSES)
+ 
+ lrtest$x: $(MODEL)/lrtest$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/lrtest$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/lrtest$o $(LDFLAGS_CURSES)
+ 
+ ncurses$x: $(MODEL)/ncurses$o $(LOCAL_LIBS)
+ 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ncurses$o $(LDFLAGS_DEFAULT)
+ 
+ newdemo$x: $(MODEL)/newdemo$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/newdemo$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/newdemo$o $(LDFLAGS_CURSES)
+ 
+ rain$x: $(MODEL)/rain$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/rain$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/rain$o $(LDFLAGS_CURSES)
+ 
+ railroad$x: $(MODEL)/railroad$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/railroad$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/railroad$o $(LDFLAGS_TINFO)
+ 
+ tclock$x: $(MODEL)/tclock$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/tclock$o $(LDFLAGS_DEFAULT) $(MATH_LIB)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/tclock$o $(LDFLAGS_CURSES) $(MATH_LIB)
+ 
+ testaddch$x: $(MODEL)/testaddch$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testaddch$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testaddch$o $(LDFLAGS_CURSES)
+ 
+ testcurs$x: $(MODEL)/testcurs$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testcurs$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testcurs$o $(LDFLAGS_CURSES)
+ 
+ testscanw$x: $(MODEL)/testscanw$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testscanw$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testscanw$o $(LDFLAGS_CURSES)
+ 
+ view$x: $(MODEL)/view$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/view$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/view$o $(LDFLAGS_CURSES)
+ 
+ worm$x: $(MODEL)/worm$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/worm$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/worm$o $(LDFLAGS_CURSES)
+ 
+ xmas$x: $(MODEL)/xmas$o $(LOCAL_LIBS)
+-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/xmas$o $(LDFLAGS_DEFAULT)
++	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/xmas$o $(LDFLAGS_CURSES)
+ 
+ libs \
+ install \
+Index: test/README
+Prereq:  1.15 
+--- ncurses-5.4-20040208/test/README	2003-07-05 19:17:49.000000000 +0000
++++ ncurses-5.4-20050319/test/README	2005-03-05 23:34:38.000000000 +0000
+@@ -1,4 +1,4 @@
+--- $Id: README,v 1.15 2003/07/05 19:17:49 tom Exp $
++-- $Id: README,v 1.22 2005/03/05 23:34:38 tom Exp $
+ -------------------------------------------------------------------------------
+ 
+ The programs in this directory are designed to test your newest toy :-)
+@@ -36,14 +36,14 @@
+ TYPE_ALPHA			test: demo_forms ncurses
+ TYPE_ENUM			test: demo_forms
+ TYPE_INTEGER			test: demo_forms
+-TYPE_IPV4			-
++TYPE_IPV4			test: demo_forms
+ TYPE_NUMERIC			test: demo_forms
+ TYPE_REGEXP			test: demo_forms
+ current_field			test: demo_forms edit_field ncurses
+-data_ahead			-
+-data_behind			-
++data_ahead			test: demo_forms
++data_behind			test: demo_forms
+ dup_field			-
+-dynamic_field_info		-
++dynamic_field_info		test: demo_forms
+ field_arg			-
+ field_back			-
+ field_buffer			test: cardfile demo_forms edit_field ncurses
+@@ -54,7 +54,7 @@
+ field_init			-
+ field_just			-
+ field_opts			test: demo_forms ncurses
+-field_opts_off			test: cardfile
++field_opts_off			test: cardfile demo_forms
+ field_opts_on			-
+ field_pad			-
+ field_status			-
+@@ -75,7 +75,7 @@
+ form_userptr			-
+ form_win			test: cardfile demo_forms edit_field ncurses
+ free_field			test: cardfile demo_forms ncurses
+-free_fieldtype			-
++free_fieldtype			test: ncurses
+ free_form			test: cardfile demo_forms ncurses
+ link_field			-
+ link_fieldtype			-
+@@ -109,7 +109,7 @@
+ set_form_term			-
+ set_form_userptr		-
+ set_form_win			test: cardfile demo_forms ncurses
+-set_max_field			-
++set_max_field			test: demo_forms
+ set_new_page			test: demo_forms
+ unpost_form			test: cardfile demo_forms ncurses
+ 
+@@ -184,18 +184,18 @@
+ ----------
+ BC				-
+ COLORS				test: ncurses xmas
+-COLOR_PAIR			test: blue bs demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
++COLOR_PAIR			test: background blue bs cardfile demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
+ COLOR_PAIRS			test: ncurses newdemo
+ COLS				test: cardfile demo_defkey demo_forms demo_keyok edit_field firework hashtest ins_wide inserts lrtest ncurses newdemo rain tclock testcurs view worm
+ ESCDELAY			lib: ncurses
+ LINES				test: cardfile demo_defkey demo_keyok edit_field firework hanoi hashtest ins_wide inserts lrtest ncurses newdemo rain tclock testcurs view worm xmas
+-PAIR_NUMBER			lib: ncurses
++PAIR_NUMBER			test: ncurses
+ PC				lib: ncurses
+ SP				lib: ncurses
+ TABSIZE				lib: menu
+ UP				-
+ acs_map				test: gdc ins_wide inserts knight ncurses newdemo testcurs
+-add_wch				-
++add_wch				test: ncurses
+ add_wchnstr			test: ncurses
+ add_wchstr			test: view
+ addch				test: blue bs ditto hashtest ncurses testaddch view worm
+@@ -204,21 +204,21 @@
+ addnstr				-
+ addnwstr			-
+ addstr				test: blue bs cardfile gdc hanoi lrtest ncurses
+-addwstr				-
++addwstr				test: ncurses
+ assume_default_colors		test: ncurses
+-attr_get			-
++attr_get			test: ncurses
+ attr_off			test: ncurses
+ attr_on				test: ncurses
+-attr_set			-
++attr_set			test: ncurses
+ attroff				test: filter gdc ncurses tclock
+ attron				test: bs filter gdc ncurses
+ attrset				test: bs firework gdc hanoi ncurses rain tclock testaddch testcurs
+ baudrate			lib: ncurses
+ beep				test: blue bs cardfile demo_forms edit_field hanoi ins_wide inserts knight ncurses tclock testcurs view xmas
+-bkgd				test: demo_forms ncurses tclock view
+-bkgdset				test: ncurses testaddch
+-bkgrnd				-
+-bkgrndset			-
++bkgd				test: background cardfile demo_forms ncurses tclock view
++bkgdset				test: background ncurses testaddch
++bkgrnd				test: ncurses
++bkgrndset			test: ncurses
+ boolcodes			progs: dump_entry
+ boolfnames			progs: dump_entry
+ boolnames			progs: dump_entry infocmp
+@@ -227,14 +227,14 @@
+ box				test: cardfile demo_forms edit_field ins_wide inserts lrtest ncurses newdemo testcurs
+ box_set				test: ncurses
+ can_change_color		test: ncurses
+-cbreak				test: blue bs cardfile demo_defkey demo_forms demo_keyok ditto filter firework gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo tclock testcurs view worm xmas
++cbreak				test: background blue bs cardfile color_set demo_defkey demo_forms demo_keyok ditto filter firework gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo tclock testcurs view worm xmas
+ chgat				-
+ clear				test: blue bs gdc ncurses testcurs xmas
+ clearok				test: bs knight
+ clrtobot			test: ncurses
+ clrtoeol			test: blue bs hanoi hashtest ncurses view
+ color_content			test: ncurses
+-color_set			-
++color_set			test: color_set ncurses
+ copywin				test: testcurs
+ cur_term			test: dots lrtest progs: clear tic tput tset
+ curs_set			test: firework gdc hanoi lrtest newdemo rain tclock testcurs worm xmas
+@@ -248,14 +248,14 @@
+ delch				-
+ deleteln			-
+ delscreen			-
+-delwin				test: cardfile demo_forms edit_field ncurses newdemo testcurs
+-derwin				test: cardfile demo_forms ncurses
++delwin				test: cardfile demo_forms edit_field ins_wide inserts ncurses newdemo testcurs
++derwin				test: cardfile demo_forms ins_wide inserts ncurses
+ doupdate			test: cardfile edit_field ins_wide inserts knight ncurses
+ dupwin				test: edit_field
+ echo				test: bs hanoi ncurses testcurs testscanw
+ echo_wchar			test: ncurses
+ echochar			test: ncurses
+-endwin				test: blue bs cardfile demo_defkey demo_forms demo_keyok ditto filter firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo rain tclock testaddch testcurs testscanw view worm xmas
++endwin				test: background blue bs cardfile color_set demo_defkey demo_forms demo_keyok ditto filter firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo rain tclock testaddch testcurs testscanw view worm xmas
+ erase				test: cardfile filter firework firstlast hanoi lrtest ncurses tclock testcurs
+ erasechar			lib: ncurses
+ erasewchar			-
+@@ -265,16 +265,16 @@
+ get_wch				-
+ get_wstr			-
+ getbkgd				test: ncurses
+-getbkgrnd			-
+-getcchar			test: view
+-getch				test: blue bs ditto firework firstlast hanoi hashtest lrtest rain tclock testaddch testcurs view worm xmas
++getbkgrnd			test: ncurses
++getcchar			test: ncurses view
++getch				test: background blue bs color_set ditto firework firstlast hanoi hashtest lrtest rain tclock testaddch testcurs view worm xmas
+ getmouse			test: bs knight ncurses
+ getn_wstr			-
+ getnstr				test: filter ncurses
+ getstr				-
+ getwin				test: ncurses
+ halfdelay			test: view
+-has_colors			test: bs demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testcurs view worm xmas
++has_colors			test: background bs cardfile color_set demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testcurs view worm xmas
+ has_ic				test: lrtest
+ has_il				lib: ncurses
+ has_key				lib: ncurses
+@@ -290,18 +290,18 @@
+ inchnstr			-
+ inchstr				-
+ init_color			test: ncurses
+-init_pair			test: blue bs demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
+-initscr				test: blue bs cardfile demo_defkey demo_forms demo_keyok firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo rain tclock testaddch testcurs testscanw view worm xmas
++init_pair			test: background blue bs cardfile color_set demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
++initscr				test: background blue bs cardfile color_set demo_defkey demo_forms demo_keyok firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo rain tclock testaddch testcurs testscanw view worm xmas
+ innstr				-
+ innwstr				-
+-ins_nwstr			-
+-ins_wch				-
+-ins_wstr			-
+-insch				-
++ins_nwstr			test: ins_wide
++ins_wch				test: ins_wide
++ins_wstr			test: ins_wide
++insch				test: ins_wide inserts
+ insdelln			-
+ insertln			-
+-insnstr				-
+-insstr				-
++insnstr				test: inserts
++insstr				test: inserts
+ instr				-
+ intrflush			test: demo_forms
+ inwstr				-
+@@ -321,10 +321,10 @@
+ longname			test: testcurs progs: tput
+ mcprint				-
+ meta				test: ncurses
+-mouse_trafo			-
++mouse_trafo			lib: menu
+ mouseinterval			-
+ mousemask			test: bs knight ncurses
+-move				test: blue bs cardfile gdc hanoi hashtest knight lrtest ncurses testscanw view worm xmas
++move				test: blue bs cardfile gdc hanoi hashtest ins_wide inserts knight lrtest ncurses testscanw view worm xmas
+ mvadd_wch			test: ncurses
+ mvadd_wchnstr			-
+ mvadd_wchstr			-
+@@ -355,12 +355,12 @@
+ mvinchstr			-
+ mvinnstr			-
+ mvinnwstr			-
+-mvins_nwstr			-
+-mvins_wch			-
+-mvins_wstr			-
+-mvinsch				-
+-mvinsnstr			-
+-mvinsstr			-
++mvins_nwstr			test: ins_wide
++mvins_wch			test: ins_wide
++mvins_wstr			test: ins_wide
++mvinsch				test: ins_wide inserts
++mvinsnstr			test: inserts
++mvinsstr			test: inserts
+ mvinstr				-
+ mvinwstr			-
+ mvprintw			test: bs firework hanoi ncurses tclock view
+@@ -368,7 +368,7 @@
+ mvvline				test: ncurses
+ mvvline_set			test: ncurses
+ mvwadd_wch			-
+-mvwadd_wchnstr			-
++mvwadd_wchnstr			lib: form
+ mvwadd_wchstr			-
+ mvwaddch			test: newdemo testcurs xmas
+ mvwaddchnstr			-
+@@ -389,18 +389,18 @@
+ mvwhline_set			-
+ mvwin				test: cardfile testcurs xmas
+ mvwin_wch			-
+-mvwin_wchnstr			-
++mvwin_wchnstr			lib: form
+ mvwin_wchstr			-
+ mvwinch				test: newdemo testcurs
+ mvwinchnstr			-
+ mvwinchstr			-
+ mvwinnstr			test: testcurs
+ mvwinnwstr			-
+-mvwins_nwstr			-
++mvwins_nwstr			test: ins_wide
+ mvwins_wch			test: ins_wide
+ mvwins_wstr			test: ins_wide
+ mvwinsch			test: ins_wide inserts
+-mvwinsnstr			-
++mvwinsnstr			test: inserts
+ mvwinsstr			test: inserts testcurs
+ mvwinstr			-
+ mvwinwstr			-
+@@ -408,7 +408,7 @@
+ mvwscanw			test: testcurs
+ mvwvline			test: ins_wide inserts
+ mvwvline_set			-
+-napms				test: firework gdc hanoi lrtest ncurses newdemo railroad rain tclock testcurs view worm xmas progs: tset
++napms				test: dots firework gdc hanoi lrtest ncurses newdemo railroad rain tclock testcurs view worm xmas progs: tset
+ newpad				test: edit_field ncurses testcurs
+ newscr				lib: ncurses
+ newterm				test: ditto filter gdc
+@@ -416,7 +416,7 @@
+ nl				test: demo_forms ncurses rain testcurs
+ nocbreak			test: testcurs
+ nodelay				test: firework gdc lrtest ncurses newdemo rain tclock view xmas
+-noecho				test: bs cardfile demo_defkey demo_forms demo_keyok ditto firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses rain tclock testcurs view worm xmas
++noecho				test: background bs cardfile color_set demo_defkey demo_forms demo_keyok ditto firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses rain tclock testcurs view worm xmas
+ nonl				test: bs demo_forms hashtest ncurses view worm xmas
+ noqiflush			-
+ noraw				test: demo_forms ncurses testcurs
+@@ -427,11 +427,12 @@
+ ospeed				progs: tset
+ overlay				test: testcurs xmas
+ overwrite			test: ncurses
+-pair_content			lib: ncurses
++pair_content			test: background color_set
++pecho_wchar			-
+ pechochar			-
+ pnoutrefresh			test: edit_field ncurses
+ prefresh			test: testcurs
+-printw				test: blue bs demo_defkey demo_keyok filter ncurses testcurs testscanw view
++printw				test: background blue bs color_set demo_defkey demo_keyok filter ncurses testcurs testscanw view
+ putp				progs: tput
+ putwin				test: ncurses
+ qiflush				-
+@@ -478,7 +479,7 @@
+ slk_wset			test: ncurses
+ standend			test: blue gdc ncurses worm
+ standout			test: blue ncurses
+-start_color			test: blue bs demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
++start_color			test: background blue bs cardfile color_set demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
+ stdscr				test: bs demo_forms ditto filter firework gdc hanoi hashtest ins_wide inserts knight lrtest ncurses rain tclock testcurs testscanw view xmas
+ strcodes			progs: dump_entry
+ strfnames			progs: dump_entry
+@@ -486,7 +487,7 @@
+ subpad				test: testcurs
+ subwin				test: ncurses newdemo testcurs
+ syncok				-
+-term_attrs			-
++term_attrs			test: ncurses
+ termattrs			test: ncurses testcurs
+ termname			test: testcurs
+ tgetent				test: railroad
+@@ -499,7 +500,7 @@
+ tigetstr			test: blue demo_defkey testcurs progs: tput
+ timeout				test: rain
+ touchline			lib: ncurses
+-touchwin			test: edit_field filter firstlast ncurses xmas
++touchwin			test: edit_field filter firstlast ins_wide inserts ncurses xmas
+ tparm				test: dots progs: tic tput
+ tputs				test: dots railroad progs: clear tset
+ trace				test: hanoi hashtest lrtest ncurses testcurs view worm
+@@ -509,7 +510,7 @@
+ unget_wch			-
+ ungetch				test: bs knight
+ ungetmouse			-
+-untouchwin			-
++untouchwin			lib: form
+ use_default_colors		test: filter firework gdc hanoi knight ncurses rain tclock worm xmas
+ use_env				progs: tput
+ use_extended_names		progs: infocmp tic
+@@ -524,23 +525,23 @@
+ vwprintw			lib: ncurses
+ vwscanw				lib: ncurses
+ wadd_wch			lib: ncurses
+-wadd_wchnstr			lib: ncurses
++wadd_wchnstr			lib: form
+ wadd_wchstr			-
+-waddch				test: firstlast knight ncurses
++waddch				test: demo_forms firstlast knight ncurses
+ waddchnstr			lib: ncurses
+ waddchstr			-
+-waddnstr			lib: form
++waddnstr			lib: menu
+ waddnwstr			test: ncurses
+ waddstr				test: demo_forms edit_field firstlast ins_wide knight ncurses testcurs
+ waddwstr			test: ins_wide
+ wattr_get			-
+-wattr_off			lib: menu
+-wattr_on			lib: menu
++wattr_off			lib: ncurses
++wattr_on			lib: ncurses
+ wattr_set			-
+ wattroff			test: demo_forms ncurses testcurs xmas
+ wattron				test: testcurs xmas
+ wattrset			test: demo_forms ncurses newdemo testcurs xmas
+-wbkgd				test: demo_forms ncurses newdemo testcurs
++wbkgd				test: cardfile demo_forms ncurses newdemo testcurs
+ wbkgdset			test: ins_wide inserts ncurses
+ wbkgrnd				lib: ncurses
+ wbkgrndset			lib: ncurses
+@@ -566,22 +567,22 @@
+ wgetstr				-
+ whline				test: testcurs
+ whline_set			lib: ncurses
+-win_wch				lib: ncurses
+-win_wchnstr			lib: ncurses
++win_wch				lib: form
++win_wchnstr			lib: form
+ win_wchstr			-
+ winch				test: knight testcurs
+ winchnstr			lib: ncurses
+ winchstr			-
+ winnstr				test: demo_defkey
+ winnwstr			lib: ncurses
+-wins_nwstr			lib: ncurses
+-wins_wch			lib: ncurses
+-wins_wstr			-
+-winsch				test: testcurs
+-winsdelln			lib: form
++wins_nwstr			test: ins_wide
++wins_wch			test: ins_wide
++wins_wstr			test: ins_wide
++winsch				test: ins_wide inserts testcurs
++winsdelln			lib: ncurses
+ winsertln			test: testcurs
+-winsnstr			lib: form
+-winsstr				-
++winsnstr			test: inserts
++winsstr				test: inserts
+ winstr				-
+ winwstr				lib: ncurses
+ wmouse_trafo			lib: menu
+@@ -599,7 +600,7 @@
+ wsyncdown			lib: ncurses
+ wsyncup				lib: form
+ wtimeout			test: ncurses
+-wtouchln			lib: form
++wtouchln			lib: ncurses
+ wunctrl				-
+ wvline				test: testcurs
+ wvline_set			lib: ncurses
+Index: test/aclocal.m4
+Prereq:  1.6 
+--- ncurses-5.4-20040208/test/aclocal.m4	2003-10-19 00:09:23.000000000 +0000
++++ ncurses-5.4-20050319/test/aclocal.m4	2005-02-27 00:02:01.000000000 +0000
+@@ -1,6 +1,88 @@
+-dnl $Id: aclocal.m4,v 1.6 2003/10/19 00:09:23 tom Exp $
++dnl $Id: aclocal.m4,v 1.8 2005/02/27 00:02:01 tom Exp $
+ dnl ---------------------------------------------------------------------------
+ dnl ---------------------------------------------------------------------------
++dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30
++dnl -------------
++dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
++dnl The second parameter if given makes this macro verbose.
++dnl
++dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
++dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
++dnl confused by the quotes (which require backslashes to keep them usable).
++AC_DEFUN([CF_ADD_CFLAGS],
++[
++cf_fix_cppflags=no
++cf_new_cflags=
++cf_new_cppflags=
++cf_new_extra_cppflags=
++
++for cf_add_cflags in $1
++do
++case $cf_fix_cppflags in
++no)
++	case $cf_add_cflags in #(vi
++	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
++		case $cf_add_cflags in
++		-D*)
++			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
++
++			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++			&& test -z "${cf_tst_cflags}" \
++			&& cf_fix_cppflags=yes
++
++			if test $cf_fix_cppflags = yes ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			elif test "${cf_tst_cflags}" = "\"'" ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			fi
++			;;
++		esac
++		case "$CPPFLAGS" in
++		*$cf_add_cflags) #(vi
++			;;
++		*) #(vi
++			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
++			;;
++		esac
++		;;
++	*)
++		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
++		;;
++	esac
++	;;
++yes)
++	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++
++	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
++
++	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++	&& test -z "${cf_tst_cflags}" \
++	&& cf_fix_cppflags=no
++	;;
++esac
++done
++
++if test -n "$cf_new_cflags" ; then
++	ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
++	CFLAGS="$CFLAGS $cf_new_cflags"
++fi
++
++if test -n "$cf_new_cppflags" ; then
++	ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
++	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
++fi
++
++if test -n "$cf_new_extra_cppflags" ; then
++	ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
++	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
++fi
++
++AC_SUBST(EXTRA_CPPFLAGS)
++
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_ADD_INCDIR version: 4 updated: 2002/12/21 14:25:52
+ dnl -------------
+ dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
+@@ -39,7 +121,77 @@
+ done
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_CHECK_CACHE version: 7 updated: 2001/12/19 00:50:10
++dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
++dnl ----------------
++dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
++dnl in the sharutils 4.2 distribution.
++AC_DEFUN([CF_ANSI_CC_CHECK],
++[
++AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
++cf_cv_ansi_cc=no
++cf_save_CFLAGS="$CFLAGS"
++cf_save_CPPFLAGS="$CPPFLAGS"
++# Don't try gcc -ansi; that turns off useful extensions and
++# breaks some systems' header files.
++# AIX			-qlanglvl=ansi
++# Ultrix and OSF/1	-std1
++# HP-UX			-Aa -D_HPUX_SOURCE
++# SVR4			-Xc
++# UnixWare 1.2		(cannot use -Xc, since ANSI/POSIX clashes)
++for cf_arg in "-DCC_HAS_PROTOS" \
++	"" \
++	-qlanglvl=ansi \
++	-std1 \
++	-Ae \
++	"-Aa -D_HPUX_SOURCE" \
++	-Xc
++do
++	CF_ADD_CFLAGS($cf_arg)
++	AC_TRY_COMPILE(
++[
++#ifndef CC_HAS_PROTOS
++#if !defined(__STDC__) || (__STDC__ != 1)
++choke me
++#endif
++#endif
++],[
++	int test (int i, double x);
++	struct s1 {int (*f) (int a);};
++	struct s2 {int (*f) (double a);};],
++	[cf_cv_ansi_cc="$cf_arg"; break])
++done
++CFLAGS="$cf_save_CFLAGS"
++CPPFLAGS="$cf_save_CPPFLAGS"
++])
++
++if test "$cf_cv_ansi_cc" != "no"; then
++if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
++	CF_ADD_CFLAGS($cf_cv_ansi_cc)
++else
++	AC_DEFINE(CC_HAS_PROTOS)
++fi
++fi
++])dnl
++dnl ---------------------------------------------------------------------------
++dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44
++dnl ---------------
++dnl For programs that must use an ANSI compiler, obtain compiler options that
++dnl will make it recognize prototypes.  We'll do preprocessor checks in other
++dnl macros, since tools such as unproto can fake prototypes, but only part of
++dnl the preprocessor.
++AC_DEFUN([CF_ANSI_CC_REQD],
++[AC_REQUIRE([CF_ANSI_CC_CHECK])
++if test "$cf_cv_ansi_cc" = "no"; then
++	AC_ERROR(
++[Your compiler does not appear to recognize prototypes.
++You have the following choices:
++	a. adjust your compiler options
++	b. get an up-to-date compiler
++	c. use a wrapper such as unproto])
++fi
++])dnl
++dnl ---------------------------------------------------------------------------
++dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
+ dnl --------------
+ dnl Check if we're accidentally using a cache from a different machine.
+ dnl Derive the system name, as a check for reusing the autoconf cache.
+@@ -48,9 +200,12 @@
+ dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
+ dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
+ dnl which is useful in cross-compiles.
++dnl
++dnl Note: we would use $ac_config_sub, but that is one of the places where
++dnl autoconf 2.5x broke compatibility with autoconf 2.13
+ AC_DEFUN([CF_CHECK_CACHE],
+ [
+-if test -f $srcdir/config.guess ; then
++if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
+ 	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
+ 	system_name="$host_os"
+ else
+@@ -157,12 +312,13 @@
+ 
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_CURSES_LIBS version: 22 updated: 2002/10/27 18:21:42
++dnl CF_CURSES_LIBS version: 23 updated: 2003/11/06 19:59:57
+ dnl --------------
+ dnl Look for the curses libraries.  Older curses implementations may require
+ dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
+ AC_DEFUN([CF_CURSES_LIBS],[
+ 
++AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
+ AC_MSG_CHECKING(if we have identified curses libraries)
+ AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
+ 	[initscr(); tgoto("?", 0,0)],
+@@ -281,7 +437,7 @@
+ dnl "dirname" is not portable, so we fake it with a shell script.
+ AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_FIND_LIBRARY version: 7 updated: 2000/04/13 21:38:04
++dnl CF_FIND_LIBRARY version: 8 updated: 2004/11/23 20:14:58
+ dnl ---------------
+ dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
+ dnl prefer a standard location, and use -L options only if we do not find the
+@@ -291,7 +447,7 @@
+ dnl	$3 = includes
+ dnl	$4 = code fragment to compile/link
+ dnl	$5 = corresponding function-name
+-dnl	$6 = flag, nonnull if failure causes an error-exit
++dnl	$6 = flag, nonnull if failure should not cause an error-exit
+ dnl
+ dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
+ dnl to use a -L option.
+@@ -353,7 +509,7 @@
+ test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
+ ])
+ dnl ---------------------------------------------------------------------------
+-dnl CF_GNU_SOURCE version: 3 updated: 2000/10/29 23:30:53
++dnl CF_GNU_SOURCE version: 4 updated: 2004/12/03 20:43:00
+ dnl -------------
+ dnl Check if we must define _GNU_SOURCE to get a reasonable value for
+ dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
+@@ -363,6 +519,9 @@
+ dnl Well, yes we could work around it...
+ AC_DEFUN([CF_GNU_SOURCE],
+ [
++AC_REQUIRE([CF_INTEL_COMPILER])
++
++if test "$INTEL_COMPILER" = no ; then
+ AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
+ AC_TRY_COMPILE([#include <sys/types.h>],[
+ #ifndef _XOPEN_SOURCE
+@@ -381,6 +540,7 @@
+ 	])
+ ])
+ test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
++fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+ dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
+@@ -412,12 +572,54 @@
+ test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
+ ])dnl
+ dnl ---------------------------------------------------------------------------
++dnl CF_INTEL_COMPILER version: 1 updated: 2004/12/03 20:27:48
++dnl -----------------
++dnl Check if the given compiler is really the Intel compiler for Linux.
++dnl It tries to imitate gcc, but does not return an error when it finds a
++dnl mismatch between prototypes, e.g., as exercised by CF_MISSING_CHECK.
++dnl
++dnl This macro should be run "soon" after AC_PROG_CC, to ensure that it is
++dnl not mistaken for gcc.
++AC_DEFUN([CF_INTEL_COMPILER],[
++AC_REQUIRE([AC_PROG_CC])
++
++INTEL_COMPILER=no
++
++if test "$GCC" = yes ; then
++	case $host_os in
++	linux*|gnu*)
++		AC_MSG_CHECKING(if this is really Intel compiler)
++		cf_save_CFLAGS="$CFLAGS"
++		CFLAGS="$CFLAGS -no-gcc"
++		AC_TRY_COMPILE([],[
++#ifdef __INTEL_COMPILER
++#else
++make an error
++#endif
++],[INTEL_COMPILER=yes
++cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
++],[])
++		CFLAGS="$cf_save_CFLAGS"
++		AC_MSG_RESULT($INTEL_COMPILER)
++		;;
++	esac
++fi
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
+ dnl ---------------
+ dnl Construct a search-list for a nonstandard library-file
+ AC_DEFUN([CF_LIBRARY_PATH],
+ [CF_SUBDIR_PATH($1,$2,lib)])dnl
+ dnl ---------------------------------------------------------------------------
++dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
++dnl ----------
++dnl Write a debug message to config.log, along with the line number in the
++dnl configure script.
++AC_DEFUN([CF_MSG_LOG],[
++echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_NCURSES_CC_CHECK version: 3 updated: 2003/01/12 18:59:28
+ dnl -------------------
+ dnl Check if we can compile with ncurses' header file
+@@ -451,7 +653,7 @@
+ 	,[$1=no])
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_NCURSES_CPPFLAGS version: 16 updated: 2002/12/29 18:30:46
++dnl CF_NCURSES_CPPFLAGS version: 17 updated: 2003/11/06 19:59:57
+ dnl -------------------
+ dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
+ dnl the CPPFLAGS variable so we can include its header.
+@@ -475,6 +677,7 @@
+ AC_DEFUN([CF_NCURSES_CPPFLAGS],
+ [AC_REQUIRE([CF_WITH_CURSES_DIR])
+ 
++AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
+ cf_ncuhdr_root=ifelse($1,,ncurses,$1)
+ 
+ test -n "$cf_cv_curses_dir" && \
+@@ -549,7 +752,7 @@
+ CF_NCURSES_VERSION
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_NCURSES_LIBS version: 11 updated: 2002/12/22 14:22:25
++dnl CF_NCURSES_LIBS version: 12 updated: 2004/04/27 16:26:05
+ dnl ---------------
+ dnl Look for the ncurses library.  This is a little complicated on Linux,
+ dnl because it may be linked with the gpm (general purpose mouse) library.
+@@ -579,7 +782,9 @@
+ freebsd*)
+ 	# This is only necessary if you are linking against an obsolete
+ 	# version of ncurses (but it should do no harm, since it's static).
+-	AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
++	if test "$cf_nculib_root" = ncurses ; then
++		AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
++	fi
+ 	;;
+ esac
+ 
+@@ -615,13 +820,14 @@
+ AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_NCURSES_VERSION version: 10 updated: 2002/10/27 18:21:42
++dnl CF_NCURSES_VERSION version: 11 updated: 2003/11/06 19:59:57
+ dnl ------------------
+ dnl Check for the version of ncurses, to aid in reporting bugs, etc.
+ dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
+ dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
+ AC_DEFUN([CF_NCURSES_VERSION],
+ [
++AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
+ AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
+ 	cf_cv_ncurses_version=no
+ 	cf_tempfile=out$$
+@@ -707,37 +913,63 @@
+ esac
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+-dnl CF_PREDEFINE version: 1 updated: 2003/07/26 17:53:56
+-dnl ------------
+-dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
+-dnl
+-dnl $1 = symbol to test
+-dnl $2 = value (if any) to use for a predefinition
+-AC_DEFUN([CF_PREDEFINE],
++dnl CF_POSIX_C_SOURCE version: 3 updated: 2005/02/04 06:56:22
++dnl -----------------
++dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
++dnl
++dnl	POSIX.1-1990				_POSIX_SOURCE
++dnl	POSIX.1-1990 and			_POSIX_SOURCE and
++dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
++dnl		Bindings Option
++dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
++dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
++dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
++dnl
++dnl Parameters:
++dnl	$1 is the nominal value for _POSIX_C_SOURCE
++AC_DEFUN([CF_POSIX_C_SOURCE],
+ [
+-AC_MSG_CHECKING(if we must define $1)
+-AC_TRY_COMPILE([#include <sys/types.h>
+-],[
+-#ifndef $1
++cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
++AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
++	CF_MSG_LOG(if the symbol is already defined go no further)
++	AC_TRY_COMPILE([#include <sys/types.h>],[
++#ifndef _POSIX_C_SOURCE
+ make an error
+-#endif],[cf_result=no],[cf_result=yes])
+-AC_MSG_RESULT($cf_result)
+-
+-if test "$cf_result" = yes ; then
+-	CPPFLAGS="$CPPFLAGS ifelse($2,,-D$1,[-D$1=$2])"
+-elif test "x$2" != "x" ; then
+-	AC_MSG_CHECKING(checking for compatible value versus $2)
+-	AC_TRY_COMPILE([#include <sys/types.h>
+-],[
+-#if $1-$2 < 0
++#endif],
++	[cf_cv_posix_c_source=no],
++	[cf_want_posix_source=no
++	 case .$cf_POSIX_C_SOURCE in
++	 .[[12]]??*)
++		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
++		;;
++	 .2)
++		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
++		cf_want_posix_source=yes
++		;;
++	 .*)
++		cf_want_posix_source=yes
++		;;
++	 esac
++	 if test "$cf_want_posix_source" = yes ; then
++		AC_TRY_COMPILE([#include <sys/types.h>],[
++#ifdef _POSIX_SOURCE
+ make an error
+-#endif],[cf_result=yes],[cf_result=no])
+-	AC_MSG_RESULT($cf_result)
+-	if test "$cf_result" = no ; then
+-		# perhaps we can override it - try...
+-		CPPFLAGS="$CPPFLAGS -D$1=$2"
+-	fi
+-fi
++#endif],[],
++		cf_cv_posix_c_source="$cf_cv_posix_c_source -U_POSIX_SOURCE -D_POSIX_SOURCE")
++	 fi
++	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
++	 cf_save="$CPPFLAGS"
++	 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
++	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
++	 AC_TRY_COMPILE([#include <sys/types.h>],[
++#ifndef _POSIX_C_SOURCE
++make an error
++#endif],,
++	[cf_cv_posix_c_source=no])
++	CPPFLAGS="$cf_save"
++	])
++])
++test "$cf_cv_posix_c_source" != no && CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
+ ])dnl
+ dnl ---------------------------------------------------------------------------
+ dnl CF_SUBDIR_PATH version: 3 updated: 2002/12/29 18:30:46
+@@ -862,6 +1094,13 @@
+ fi
+ ])dnl
+ dnl ---------------------------------------------------------------------------
++dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14
++dnl ----------
++dnl Use AC_VERBOSE w/o the warnings
++AC_DEFUN([CF_VERBOSE],
++[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
++])dnl
++dnl ---------------------------------------------------------------------------
+ dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
+ dnl ------------------
+ dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
+@@ -873,3 +1112,79 @@
+ 	 cf_cv_curses_dir=$withval],
+ 	[cf_cv_curses_dir=no])
+ ])dnl
++dnl ---------------------------------------------------------------------------
++dnl CF_XOPEN_SOURCE version: 17 updated: 2005/02/06 12:07:45
++dnl ---------------
++dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
++dnl or adapt to the vendor's definitions to get equivalent functionality.
++dnl
++dnl Parameters:
++dnl	$1 is the nominal value for _XOPEN_SOURCE
++dnl	$2 is the nominal value for _POSIX_C_SOURCE
++AC_DEFUN([CF_XOPEN_SOURCE],[
++
++cf_XOPEN_SOURCE=ifelse($1,,500,$1)
++cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
++
++case $host_os in #(vi
++aix[[45]]*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
++	;;
++freebsd*) #(vi
++	# 5.x headers associate
++	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
++	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
++	cf_POSIX_C_SOURCE=200112L
++	cf_XOPEN_SOURCE=600
++	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
++	;;
++hpux*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
++	;;
++irix[[56]].*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
++	;;
++linux*|gnu*) #(vi
++	CF_GNU_SOURCE
++	;;
++mirbsd*) #(vi
++	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
++	;;
++netbsd*) #(vi
++	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
++	;;
++openbsd*) #(vi
++	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
++	;;
++osf[[45]]*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
++	;;
++sco*) #(vi
++	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
++	;;
++solaris*) #(vi
++	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
++	;;
++*)
++	AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
++	AC_TRY_COMPILE([#include <sys/types.h>],[
++#ifndef _XOPEN_SOURCE
++make an error
++#endif],
++	[cf_cv_xopen_source=no],
++	[cf_save="$CPPFLAGS"
++	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
++	 AC_TRY_COMPILE([#include <sys/types.h>],[
++#ifdef _XOPEN_SOURCE
++make an error
++#endif],
++	[cf_cv_xopen_source=no],
++	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
++	CPPFLAGS="$cf_save"
++	])
++])
++test "$cf_cv_xopen_source" != no && CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE -D_XOPEN_SOURCE=$cf_cv_xopen_source"
++	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
++	;;
++esac
++])
+Index: test/bs.c
+Prereq:  1.39 
+--- ncurses-5.4-20040208/test/bs.c	2003-12-06 18:10:13.000000000 +0000
++++ ncurses-5.4-20050319/test/bs.c	2004-04-11 00:00:53.000000000 +0000
+@@ -7,7 +7,7 @@
+  * v2.0 featuring strict ANSI/POSIX conformance, November 1993.
+  * v2.1 with ncurses mouse support, September 1995
+  *
+- * $Id: bs.c,v 1.39 2003/12/06 18:10:13 tom Exp $
++ * $Id: bs.c,v 1.40 2004/04/11 00:00:53 tom Exp $
+  */
+ 
+ #include <time.h>
+@@ -249,7 +249,7 @@
+ 
+ /* VARARGS1 */
+ static void
+-prompt(int n, const char *f, const char *s)
++prompt(int n, NCURSES_CONST char *f, const char *s)
+ /* print a message at the prompt line */
+ {
+     (void) move(PROMPTLINE + n, 0);
+Index: test/cardfile.c
+Prereq:  1.23 
+--- ncurses-5.4-20040208/test/cardfile.c	2003-04-26 16:43:56.000000000 +0000
++++ ncurses-5.4-20050319/test/cardfile.c	2004-11-06 19:33:39.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1999-2002,2003 Free Software Foundation, Inc.              *
++ * Copyright (c) 1999-2003,2004 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            *
+@@ -27,9 +27,9 @@
+  ****************************************************************************/
+ 
+ /*
+- * Author: Thomas E. Dickey <dickey@clark.net> 1999
++ * Author: Thomas E. Dickey
+  *
+- * $Id: cardfile.c,v 1.23 2003/04/26 16:43:56 tom Exp $
++ * $Id: cardfile.c,v 1.27 2004/11/06 19:33:39 tom Exp $
+  *
+  * File format: text beginning in column 1 is a title; other text is content.
+  */
+@@ -43,6 +43,10 @@
+ 
+ #define VISIBLE_CARDS 10
+ #define OFFSET_CARD 2
++#define pair_1 1
++#define pair_2 2
++
++#define isVisible(cardp) ((cardp)->panel != 0)
+ 
+ enum {
+     MY_CTRL_x = MAX_FORM_COMMAND
+@@ -61,6 +65,7 @@
+ } CARD;
+ 
+ static CARD *all_cards;
++static bool try_color = FALSE;
+ static char default_name[] = "cardfile.dat";
+ 
+ #if !HAVE_STRDUP
+@@ -238,7 +243,8 @@
+     if (first) {
+ 	if (depth && first->link)
+ 	    order_cards(first->link, depth - 1);
+-	top_panel(first->panel);
++	if (isVisible(first))
++	    top_panel(first->panel);
+     }
+ }
+ 
+@@ -248,8 +254,13 @@
+ static CARD *
+ next_card(CARD * now)
+ {
+-    if (now->link)
+-	now = now->link;
++    if (now->link != 0) {
++	CARD *tst = now->link;
++	if (isVisible(tst))
++	    now = tst;
++	else
++	    tst = next_card(tst);
++    }
+     return now;
+ }
+ 
+@@ -260,9 +271,24 @@
+ prev_card(CARD * now)
+ {
+     CARD *p;
+-    for (p = all_cards; p != 0; p = p->link)
+-	if (p->link == now)
++    for (p = all_cards; p != 0; p = p->link) {
++	if (p->link == now) {
++	    if (!isVisible(p))
++		p = prev_card(p);
+ 	    return p;
++	}
++    }
++    return now;
++}
++
++/*
++ * Returns the first card in the list that we will display.
++ */
++static CARD *
++first_card(CARD * now)
++{
++    if (!isVisible(now))
++	now = next_card(now);
+     return now;
+ }
+ 
+@@ -355,23 +381,38 @@
+     WINDOW *win;
+     CARD *p;
+     CARD *top_card;
+-    int visible_cards = count_cards();
+-    int panel_wide = COLS - (visible_cards * OFFSET_CARD);
+-    int panel_high = LINES - (visible_cards * OFFSET_CARD) - 5;
+-    int form_wide = panel_wide - 2;
+-    int form_high = panel_high - 2;
+-    int y = (visible_cards - 1) * OFFSET_CARD;
+-    int x = 0;
++    int visible_cards;
++    int panel_wide;
++    int panel_high;
++    int form_wide;
++    int form_high;
++    int y;
++    int x;
+     int ch = ERR;
+     int last_ch;
+     int finished = FALSE;
+ 
+     show_legend();
+ 
++    /* decide how many cards we can display */
++    visible_cards = count_cards();
++    while (
++	      (panel_wide = COLS - (visible_cards * OFFSET_CARD)) < 10 ||
++	      (panel_high = LINES - (visible_cards * OFFSET_CARD) - 5) < 5) {
++	--visible_cards;
++    }
++    form_wide = panel_wide - 2;
++    form_high = panel_high - 2;
++    y = (visible_cards - 1) * OFFSET_CARD;
++    x = 0;
++
+     /* make a panel for each CARD */
+     for (p = all_cards; p != 0; p = p->link) {
+ 
+-	win = newwin(panel_high, panel_wide, y, x);
++	if ((win = newwin(panel_high, panel_wide, y, x)) == 0)
++	    break;
++
++	wbkgd(win, COLOR_PAIR(pair_2));
+ 	keypad(win, TRUE);
+ 	p->panel = new_panel(win);
+ 	box(win, 0, 0);
+@@ -385,7 +426,8 @@
+ 	x += OFFSET_CARD;
+     }
+ 
+-    order_cards(top_card = all_cards, visible_cards);
++    top_card = first_card(all_cards);
++    order_cards(top_card, visible_cards);
+ 
+     while (!finished) {
+ 	update_panels();
+@@ -432,6 +474,8 @@
+ 		    FIELD **oldf = form_fields(p->form);
+ 		    WINDOW *olds = form_sub(p->form);
+ 
++		    if (!isVisible(p))
++			continue;
+ 		    win = form_win(p->form);
+ 
+ 		    /* move and resize the card as needed
+@@ -483,15 +527,17 @@
+ 	p = all_cards;
+ 	all_cards = all_cards->link;
+ 
+-	f = form_fields(p->form);
+-	count = field_count(p->form);
++	if (isVisible(p)) {
++	    f = form_fields(p->form);
++	    count = field_count(p->form);
+ 
+-	unpost_form(p->form);	/* ...so we can free it */
+-	free_form(p->form);	/* this also disconnects the fields */
++	    unpost_form(p->form);	/* ...so we can free it */
++	    free_form(p->form);	/* this also disconnects the fields */
+ 
+-	free_form_fields(f);
++	    free_form_fields(f);
+ 
+-	del_panel(p->panel);
++	    del_panel(p->panel);
++	}
+ 	free(p->title);
+ 	free(p->content);
+ 	free(p);
+@@ -499,6 +545,22 @@
+ #endif
+ }
+ 
++static void
++usage(void)
++{
++    static const char *msg[] =
++    {
++	"Usage: view [options] file"
++	,""
++	,"Options:"
++	," -c       use color if terminal supports it"
++    };
++    size_t n;
++    for (n = 0; n < SIZEOF(msg); n++)
++	fprintf(stderr, "%s\n", msg[n]);
++    ExitProgram(EXIT_FAILURE);
++}
++
+ /*******************************************************************************/
+ 
+ int
+@@ -508,11 +570,32 @@
+ 
+     setlocale(LC_ALL, "");
+ 
++    while ((n = getopt(argc, argv, "c")) != EOF) {
++	switch (n) {
++	case 'c':
++	    try_color = TRUE;
++	    break;
++	default:
++	    usage();
++	}
++    }
++
+     initscr();
+     cbreak();
+     noecho();
+ 
+-    if (argc > 1) {
++    if (try_color) {
++	if (has_colors()) {
++	    start_color();
++	    init_pair(pair_1, COLOR_WHITE, COLOR_BLUE);
++	    init_pair(pair_2, COLOR_WHITE, COLOR_CYAN);
++	    bkgd(COLOR_PAIR(pair_1));
++	} else {
++	    try_color = FALSE;
++	}
++    }
++
++    if (optind + 1 == argc) {
+ 	for (n = 1; n < argc; n++)
+ 	    read_data(argv[n]);
+ 	if (count_cards() == 0)
+Index: test/color_set.c
+Prereq:  1.2 
+--- ncurses-5.4-20040208/test/color_set.c	2003-12-07 00:08:47.000000000 +0000
++++ ncurses-5.4-20050319/test/color_set.c	2004-04-10 20:10:28.000000000 +0000
+@@ -1,9 +1,11 @@
+ /*
+- * $Id: color_set.c,v 1.2 2003/12/07 00:08:47 tom Exp $
++ * $Id: color_set.c,v 1.3 2004/04/10 20:10:28 tom Exp $
+  */
+ 
+ #include <test.priv.h>
+ 
++#ifdef HAVE_COLOR_SET
++
+ #define SHOW(n) ((n) == ERR ? "ERR" : "OK")
+ 
+ int
+@@ -53,3 +55,11 @@
+ 
+     ExitProgram(EXIT_SUCCESS);
+ }
++#else
++int
++main(void)
++{
++    printf("This program requires the curses color_set function\n");
++    ExitProgram(EXIT_FAILURE);
++}
++#endif
+Index: test/configure
+--- ncurses-5.4-20040208/test/configure	2004-01-31 00:07:15.000000000 +0000
++++ ncurses-5.4-20050319/test/configure	2005-02-27 00:02:25.000000000 +0000
+@@ -553,7 +553,7 @@
+ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+ 
+ 
+-if test -f $srcdir/config.guess ; then
++if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
+ 	
+ # Make sure we can run config.sub.
+ if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
+@@ -945,7 +945,6 @@
+ DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'`	
+ DFT_UPR_MODEL="NORMAL"			
+ ECHO_LINK='@ echo linking $@ ... ;'	
+-EXTRA_LIBS=""				
+ LD="ld"					
+ LDFLAGS_SHARED=""			
+ LD_MODEL=""				
+@@ -963,6 +962,7 @@
+ MATH_LIB="-lm"				
+ TEST_ARGS=""				
+ TEST_DEPS=""				
++TINFO_ARGS='$(LIBS_CURSES)'		
+ cf_cv_abi_version=""			
+ cf_cv_rel_version=""			
+ 
+@@ -1089,14 +1089,304 @@
+ ac_objext=$ac_cv_objext
+ 
+ 
++
++echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6
++echo "configure:1095: checking for ${CC-cc} option to accept ANSI C" >&5
++if eval "test \"`echo '$''{'cf_cv_ansi_cc'+set}'`\" = set"; then
++  echo $ac_n "(cached) $ac_c" 1>&6
++else
++  
++cf_cv_ansi_cc=no
++cf_save_CFLAGS="$CFLAGS"
++cf_save_CPPFLAGS="$CPPFLAGS"
++# Don't try gcc -ansi; that turns off useful extensions and
++# breaks some systems' header files.
++# AIX			-qlanglvl=ansi
++# Ultrix and OSF/1	-std1
++# HP-UX			-Aa -D_HPUX_SOURCE
++# SVR4			-Xc
++# UnixWare 1.2		(cannot use -Xc, since ANSI/POSIX clashes)
++for cf_arg in "-DCC_HAS_PROTOS" \
++	"" \
++	-qlanglvl=ansi \
++	-std1 \
++	-Ae \
++	"-Aa -D_HPUX_SOURCE" \
++	-Xc
++do
++	
++cf_fix_cppflags=no
++cf_new_cflags=
++cf_new_cppflags=
++cf_new_extra_cppflags=
++
++for cf_add_cflags in $cf_arg
++do
++case $cf_fix_cppflags in
++no)
++	case $cf_add_cflags in #(vi
++	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
++		case $cf_add_cflags in
++		-D*)
++			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
++
++			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++			&& test -z "${cf_tst_cflags}" \
++			&& cf_fix_cppflags=yes
++
++			if test $cf_fix_cppflags = yes ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			elif test "${cf_tst_cflags}" = "\"'" ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			fi
++			;;
++		esac
++		case "$CPPFLAGS" in
++		*$cf_add_cflags) #(vi
++			;;
++		*) #(vi
++			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
++			;;
++		esac
++		;;
++	*)
++		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
++		;;
++	esac
++	;;
++yes)
++	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++
++	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
++
++	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++	&& test -z "${cf_tst_cflags}" \
++	&& cf_fix_cppflags=no
++	;;
++esac
++done
++
++if test -n "$cf_new_cflags" ; then
++	
++	CFLAGS="$CFLAGS $cf_new_cflags"
++fi
++
++if test -n "$cf_new_cppflags" ; then
++	
++	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
++fi
++
++if test -n "$cf_new_extra_cppflags" ; then
++	
++	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
++fi
++
++
++
++
++	cat > conftest.$ac_ext <<EOF
++#line 1191 "configure"
++#include "confdefs.h"
++
++#ifndef CC_HAS_PROTOS
++#if !defined(__STDC__) || (__STDC__ != 1)
++choke me
++#endif
++#endif
++
++int main() {
++
++	int test (int i, double x);
++	struct s1 {int (*f) (int a);};
++	struct s2 {int (*f) (double a);};
++; return 0; }
++EOF
++if { (eval echo configure:1207: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++  rm -rf conftest*
++  cf_cv_ansi_cc="$cf_arg"; break
++else
++  echo "configure: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++fi
++rm -f conftest*
++done
++CFLAGS="$cf_save_CFLAGS"
++CPPFLAGS="$cf_save_CPPFLAGS"
++
++fi
++
++echo "$ac_t""$cf_cv_ansi_cc" 1>&6
++
++if test "$cf_cv_ansi_cc" != "no"; then
++if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
++	
++cf_fix_cppflags=no
++cf_new_cflags=
++cf_new_cppflags=
++cf_new_extra_cppflags=
++
++for cf_add_cflags in $cf_cv_ansi_cc
++do
++case $cf_fix_cppflags in
++no)
++	case $cf_add_cflags in #(vi
++	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
++		case $cf_add_cflags in
++		-D*)
++			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
++
++			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++			&& test -z "${cf_tst_cflags}" \
++			&& cf_fix_cppflags=yes
++
++			if test $cf_fix_cppflags = yes ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			elif test "${cf_tst_cflags}" = "\"'" ; then
++				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++				continue
++			fi
++			;;
++		esac
++		case "$CPPFLAGS" in
++		*$cf_add_cflags) #(vi
++			;;
++		*) #(vi
++			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
++			;;
++		esac
++		;;
++	*)
++		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
++		;;
++	esac
++	;;
++yes)
++	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
++
++	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
++
++	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
++	&& test -z "${cf_tst_cflags}" \
++	&& cf_fix_cppflags=no
++	;;
++esac
++done
++
++if test -n "$cf_new_cflags" ; then
++	
++	CFLAGS="$CFLAGS $cf_new_cflags"
++fi
++
++if test -n "$cf_new_cppflags" ; then
++	
++	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
++fi
++
++if test -n "$cf_new_extra_cppflags" ; then
++	
++	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
++fi
++
++
++
++
++else
++	cat >> confdefs.h <<\EOF
++#define CC_HAS_PROTOS 1
++EOF
++
++fi
++fi
++
++
++if test "$cf_cv_ansi_cc" = "no"; then
++	{ echo "configure: error: Your compiler does not appear to recognize prototypes.
++You have the following choices:
++	a. adjust your compiler options
++	b. get an up-to-date compiler
++	c. use a wrapper such as unproto" 1>&2; exit 1; }
++fi
++
++
++
++
++INTEL_COMPILER=no
++
++if test "$GCC" = yes ; then
++	case $host_os in
++	linux*|gnu*)
++		echo $ac_n "checking if this is really Intel compiler""... $ac_c" 1>&6
++echo "configure:1323: checking if this is really Intel compiler" >&5
++		cf_save_CFLAGS="$CFLAGS"
++		CFLAGS="$CFLAGS -no-gcc"
++		cat > conftest.$ac_ext <<EOF
++#line 1327 "configure"
++#include "confdefs.h"
++
++int main() {
++
++#ifdef __INTEL_COMPILER
++#else
++make an error
++#endif
++
++; return 0; }
++EOF
++if { (eval echo configure:1339: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++  rm -rf conftest*
++  INTEL_COMPILER=yes
++cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
++
++else
++  echo "configure: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++fi
++rm -f conftest*
++		CFLAGS="$cf_save_CFLAGS"
++		echo "$ac_t""$INTEL_COMPILER" 1>&6
++		;;
++	esac
++fi
++
++
++
++cf_XOPEN_SOURCE=500
++cf_POSIX_C_SOURCE=199506L
++
++case $host_os in #(vi
++aix[45]*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
++	;;
++freebsd*) #(vi
++	# 5.x headers associate
++	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
++	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
++	cf_POSIX_C_SOURCE=200112L
++	cf_XOPEN_SOURCE=600
++	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
++	;;
++hpux*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
++	;;
++irix[56].*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
++	;;
++linux*|gnu*) #(vi
++	
++
++
++if test "$INTEL_COMPILER" = no ; then
+ echo $ac_n "checking if we must define _GNU_SOURCE""... $ac_c" 1>&6
+-echo "configure:1094: checking if we must define _GNU_SOURCE" >&5
++echo "configure:1384: checking if we must define _GNU_SOURCE" >&5
+ if eval "test \"`echo '$''{'cf_cv_gnu_source'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   
+ cat > conftest.$ac_ext <<EOF
+-#line 1100 "configure"
++#line 1390 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ int main() {
+@@ -1106,7 +1396,7 @@
+ #endif
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1110: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1400: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_cv_gnu_source=no
+ else
+@@ -1116,7 +1406,7 @@
+   cf_save="$CPPFLAGS"
+ 	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+ 	 cat > conftest.$ac_ext <<EOF
+-#line 1120 "configure"
++#line 1410 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ int main() {
+@@ -1126,7 +1416,7 @@
+ #endif
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1130: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1420: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_cv_gnu_source=no
+ else
+@@ -1145,6 +1435,189 @@
+ 
+ echo "$ac_t""$cf_cv_gnu_source" 1>&6
+ test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
++fi
++
++	;;
++mirbsd*) #(vi
++	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
++	;;
++netbsd*) #(vi
++	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
++	;;
++openbsd*) #(vi
++	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
++	;;
++osf[45]*) #(vi
++	CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
++	;;
++sco*) #(vi
++	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
++	;;
++solaris*) #(vi
++	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
++	;;
++*)
++	echo $ac_n "checking if we should define _XOPEN_SOURCE""... $ac_c" 1>&6
++echo "configure:1462: checking if we should define _XOPEN_SOURCE" >&5
++if eval "test \"`echo '$''{'cf_cv_xopen_source'+set}'`\" = set"; then
++  echo $ac_n "(cached) $ac_c" 1>&6
++else
++  
++	cat > conftest.$ac_ext <<EOF
++#line 1468 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int main() {
++
++#ifndef _XOPEN_SOURCE
++make an error
++#endif
++; return 0; }
++EOF
++if { (eval echo configure:1478: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++  rm -rf conftest*
++  cf_cv_xopen_source=no
++else
++  echo "configure: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++  rm -rf conftest*
++  cf_save="$CPPFLAGS"
++	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
++	 cat > conftest.$ac_ext <<EOF
++#line 1488 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int main() {
++
++#ifdef _XOPEN_SOURCE
++make an error
++#endif
++; return 0; }
++EOF
++if { (eval echo configure:1498: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++  rm -rf conftest*
++  cf_cv_xopen_source=no
++else
++  echo "configure: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++  rm -rf conftest*
++  cf_cv_xopen_source=$cf_XOPEN_SOURCE
++fi
++rm -f conftest*
++	CPPFLAGS="$cf_save"
++	
++fi
++rm -f conftest*
++
++fi
++
++echo "$ac_t""$cf_cv_xopen_source" 1>&6
++test "$cf_cv_xopen_source" != no && CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE -D_XOPEN_SOURCE=$cf_cv_xopen_source"
++	
++cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
++echo $ac_n "checking if we should define _POSIX_C_SOURCE""... $ac_c" 1>&6
++echo "configure:1520: checking if we should define _POSIX_C_SOURCE" >&5
++if eval "test \"`echo '$''{'cf_cv_posix_c_source'+set}'`\" = set"; then
++  echo $ac_n "(cached) $ac_c" 1>&6
++else
++  
++	
++echo "(line 1526) testing if the symbol is already defined go no further ..." 1>&5
++
++	cat > conftest.$ac_ext <<EOF
++#line 1529 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int main() {
++
++#ifndef _POSIX_C_SOURCE
++make an error
++#endif
++; return 0; }
++EOF
++if { (eval echo configure:1539: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++  rm -rf conftest*
++  cf_cv_posix_c_source=no
++else
++  echo "configure: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++  rm -rf conftest*
++  cf_want_posix_source=no
++	 case .$cf_POSIX_C_SOURCE in
++	 .[12]??*)
++		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
++		;;
++	 .2)
++		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
++		cf_want_posix_source=yes
++		;;
++	 .*)
++		cf_want_posix_source=yes
++		;;
++	 esac
++	 if test "$cf_want_posix_source" = yes ; then
++		cat > conftest.$ac_ext <<EOF
++#line 1561 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int main() {
++
++#ifdef _POSIX_SOURCE
++make an error
++#endif
++; return 0; }
++EOF
++if { (eval echo configure:1571: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++  :
++else
++  echo "configure: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++  rm -rf conftest*
++  cf_cv_posix_c_source="$cf_cv_posix_c_source -U_POSIX_SOURCE -D_POSIX_SOURCE"
++fi
++rm -f conftest*
++	 fi
++	 
++echo "(line 1582) testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
++
++	 cf_save="$CPPFLAGS"
++	 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
++	 
++echo "(line 1587) testing if the second compile does not leave our definition intact error ..." 1>&5
++
++	 cat > conftest.$ac_ext <<EOF
++#line 1590 "configure"
++#include "confdefs.h"
++#include <sys/types.h>
++int main() {
++
++#ifndef _POSIX_C_SOURCE
++make an error
++#endif
++; return 0; }
++EOF
++if { (eval echo configure:1600: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++  :
++else
++  echo "configure: failed program was:" >&5
++  cat conftest.$ac_ext >&5
++  rm -rf conftest*
++  cf_cv_posix_c_source=no
++fi
++rm -f conftest*
++	CPPFLAGS="$cf_save"
++	
++fi
++rm -f conftest*
++
++fi
++
++echo "$ac_t""$cf_cv_posix_c_source" 1>&6
++test "$cf_cv_posix_c_source" != no && CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
++
++	;;
++esac
++
+ 
+ 
+ 
+@@ -1212,7 +1685,7 @@
+ 	
+ 
+ echo $ac_n "checking for extra include directories""... $ac_c" 1>&6
+-echo "configure:1216: checking for extra include directories" >&5
++echo "configure:1689: checking for extra include directories" >&5
+ if eval "test \"`echo '$''{'cf_cv_curses_incdir'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1236,7 +1709,7 @@
+ test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
+ 
+ echo $ac_n "checking if we have identified curses headers""... $ac_c" 1>&6
+-echo "configure:1240: checking if we have identified curses headers" >&5
++echo "configure:1713: checking if we have identified curses headers" >&5
+ if eval "test \"`echo '$''{'cf_cv_ncurses_header'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1249,14 +1722,14 @@
+ 	ncurses/ncurses.h
+ do
+ cat > conftest.$ac_ext <<EOF
+-#line 1253 "configure"
++#line 1726 "configure"
+ #include "confdefs.h"
+ #include <${cf_header}>
+ int main() {
+ initscr(); tgoto("?", 0,0)
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1260: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:1733: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_cv_ncurses_header=$cf_header; break
+ else
+@@ -1279,17 +1752,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:1283: checking for $ac_hdr" >&5
++echo "configure:1756: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 1288 "configure"
++#line 1761 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:1293: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:1766: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -1319,7 +1792,7 @@
+ 
+ 	
+ echo $ac_n "checking for ncurses version""... $ac_c" 1>&6
+-echo "configure:1323: checking for ncurses version" >&5
++echo "configure:1796: checking for ncurses version" >&5
+ if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1345,7 +1818,7 @@
+ #endif
+ EOF
+ 	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
+-	{ (eval echo configure:1349: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
++	{ (eval echo configure:1822: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
+ 	if test -f conftest.out ; then
+ 		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
+ 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
+@@ -1354,7 +1827,7 @@
+ 
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 1358 "configure"
++#line 1831 "configure"
+ #include "confdefs.h"
+ 
+ #include <${cf_cv_ncurses_header-curses.h}>
+@@ -1378,7 +1851,7 @@
+ 	exit(0);
+ }
+ EOF
+-if { (eval echo configure:1382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
++if { (eval echo configure:1855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+ then
+   
+ 	cf_cv_ncurses_version=`cat $cf_tempfile`
+@@ -1402,16 +1875,16 @@
+ 	
+ 
+ echo $ac_n "checking if we have identified curses libraries""... $ac_c" 1>&6
+-echo "configure:1406: checking if we have identified curses libraries" >&5
++echo "configure:1879: checking if we have identified curses libraries" >&5
+ cat > conftest.$ac_ext <<EOF
+-#line 1408 "configure"
++#line 1881 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr(); tgoto("?", 0,0)
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1415: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1888: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   cf_result=yes
+ else
+@@ -1427,7 +1900,7 @@
+ case $host_os in #(vi
+ freebsd*) #(vi
+ 	echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
+-echo "configure:1431: checking for tgoto in -lmytinfo" >&5
++echo "configure:1904: checking for tgoto in -lmytinfo" >&5
+ ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -1435,7 +1908,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lmytinfo  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 1439 "configure"
++#line 1912 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -1446,7 +1919,7 @@
+ tgoto()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1923: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -1469,7 +1942,7 @@
+ 	;;
+ hpux10.*|hpux11.*) #(vi
+ 	echo $ac_n "checking for initscr in -lcur_colr""... $ac_c" 1>&6
+-echo "configure:1473: checking for initscr in -lcur_colr" >&5
++echo "configure:1946: checking for initscr in -lcur_colr" >&5
+ ac_lib_var=`echo cur_colr'_'initscr | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -1477,7 +1950,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lcur_colr  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 1481 "configure"
++#line 1954 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -1488,7 +1961,7 @@
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1492: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:1965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -1511,7 +1984,7 @@
+   echo "$ac_t""no" 1>&6
+ 
+ 	echo $ac_n "checking for initscr in -lHcurses""... $ac_c" 1>&6
+-echo "configure:1515: checking for initscr in -lHcurses" >&5
++echo "configure:1988: checking for initscr in -lHcurses" >&5
+ ac_lib_var=`echo Hcurses'_'initscr | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -1519,7 +1992,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lHcurses  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 1523 "configure"
++#line 1996 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -1530,7 +2003,7 @@
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2007: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -1583,12 +2056,12 @@
+ 	# Check for library containing tgoto.  Do this before curses library
+ 	# because it may be needed to link the test-case for initscr.
+ 	echo $ac_n "checking for tgoto""... $ac_c" 1>&6
+-echo "configure:1587: checking for tgoto" >&5
++echo "configure:2060: checking for tgoto" >&5
+ if eval "test \"`echo '$''{'ac_cv_func_tgoto'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 1592 "configure"
++#line 2065 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char tgoto(); below.  */
+@@ -1611,7 +2084,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_func_tgoto=yes"
+ else
+@@ -1632,7 +2105,7 @@
+ 		for cf_term_lib in $cf_check_list termcap termlib unknown
+ 		do
+ 			echo $ac_n "checking for tgoto in -l$cf_term_lib""... $ac_c" 1>&6
+-echo "configure:1636: checking for tgoto in -l$cf_term_lib" >&5
++echo "configure:2109: checking for tgoto in -l$cf_term_lib" >&5
+ ac_lib_var=`echo $cf_term_lib'_'tgoto | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -1640,7 +2113,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-l$cf_term_lib  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 1644 "configure"
++#line 2117 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -1651,7 +2124,7 @@
+ tgoto()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2128: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -1681,7 +2154,7 @@
+ 	for cf_curs_lib in $cf_check_list xcurses jcurses unknown
+ 	do
+ 		echo $ac_n "checking for initscr in -l$cf_curs_lib""... $ac_c" 1>&6
+-echo "configure:1685: checking for initscr in -l$cf_curs_lib" >&5
++echo "configure:2158: checking for initscr in -l$cf_curs_lib" >&5
+ ac_lib_var=`echo $cf_curs_lib'_'initscr | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -1689,7 +2162,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-l$cf_curs_lib  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 1693 "configure"
++#line 2166 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -1700,7 +2173,7 @@
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1704: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -1726,16 +2199,16 @@
+ 	LIBS="-l$cf_curs_lib $cf_save_LIBS"
+ 	if test "$cf_term_lib" = unknown ; then
+ 		echo $ac_n "checking if we can link with $cf_curs_lib library""... $ac_c" 1>&6
+-echo "configure:1730: checking if we can link with $cf_curs_lib library" >&5
++echo "configure:2203: checking if we can link with $cf_curs_lib library" >&5
+ 		cat > conftest.$ac_ext <<EOF
+-#line 1732 "configure"
++#line 2205 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   cf_result=yes
+ else
+@@ -1751,16 +2224,16 @@
+ 		:
+ 	elif test "$cf_term_lib" != predefined ; then
+ 		echo $ac_n "checking if we need both $cf_curs_lib and $cf_term_lib libraries""... $ac_c" 1>&6
+-echo "configure:1755: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
++echo "configure:2228: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
+ 		cat > conftest.$ac_ext <<EOF
+-#line 1757 "configure"
++#line 2230 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr(); tgoto((char *)0, 0, 0);
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   cf_result=no
+ else
+@@ -1770,14 +2243,14 @@
+   
+ 			LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
+ 			cat > conftest.$ac_ext <<EOF
+-#line 1774 "configure"
++#line 2247 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   cf_result=yes
+ else
+@@ -1807,7 +2280,7 @@
+ CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
+ 
+ echo $ac_n "checking for $cf_ncuhdr_root header in include-path""... $ac_c" 1>&6
+-echo "configure:1811: checking for $cf_ncuhdr_root header in include-path" >&5
++echo "configure:2284: checking for $cf_ncuhdr_root header in include-path" >&5
+ if eval "test \"`echo '$''{'cf_cv_ncurses_h'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1818,7 +2291,7 @@
+ 	do
+ 		
+ 	cat > conftest.$ac_ext <<EOF
+-#line 1822 "configure"
++#line 2295 "configure"
+ #include "confdefs.h"
+ 
+ 
+@@ -1839,7 +2312,7 @@
+ 	
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:2316: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_cv_ncurses_h=$cf_header
+ 	
+@@ -1862,7 +2335,7 @@
+ 	cf_cv_ncurses_header=$cf_cv_ncurses_h
+ else
+ echo $ac_n "checking for $cf_ncuhdr_root include-path""... $ac_c" 1>&6
+-echo "configure:1866: checking for $cf_ncuhdr_root include-path" >&5
++echo "configure:2339: checking for $cf_ncuhdr_root include-path" >&5
+ if eval "test \"`echo '$''{'cf_cv_ncurses_h2'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -1957,14 +2430,14 @@
+ 				cf_save_CPPFLAGS="$CPPFLAGS"
+ 				CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+ 				cat > conftest.$ac_ext <<EOF
+-#line 1961 "configure"
++#line 2434 "configure"
+ #include "confdefs.h"
+ #include <stdio.h>
+ int main() {
+ printf("Hello")
+ ; return 0; }
+ EOF
+-if { (eval echo configure:1968: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:2441: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   :
+ else
+   echo "configure: failed program was:" >&5
+@@ -1991,7 +2464,7 @@
+ 		do
+ 			
+ 	cat > conftest.$ac_ext <<EOF
+-#line 1995 "configure"
++#line 2468 "configure"
+ #include "confdefs.h"
+ 
+ 
+@@ -2012,7 +2485,7 @@
+ 	
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:2489: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_cv_ncurses_h2=$cf_header
+ 	
+@@ -2059,14 +2532,14 @@
+ 				cf_save_CPPFLAGS="$CPPFLAGS"
+ 				CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+ 				cat > conftest.$ac_ext <<EOF
+-#line 2063 "configure"
++#line 2536 "configure"
+ #include "confdefs.h"
+ #include <stdio.h>
+ int main() {
+ printf("Hello")
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2070: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:2543: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   :
+ else
+   echo "configure: failed program was:" >&5
+@@ -2121,7 +2594,7 @@
+ 
+ 
+ echo $ac_n "checking for ncurses version""... $ac_c" 1>&6
+-echo "configure:2125: checking for ncurses version" >&5
++echo "configure:2598: checking for ncurses version" >&5
+ if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -2147,7 +2620,7 @@
+ #endif
+ EOF
+ 	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
+-	{ (eval echo configure:2151: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
++	{ (eval echo configure:2624: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
+ 	if test -f conftest.out ; then
+ 		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
+ 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
+@@ -2156,7 +2629,7 @@
+ 
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 2160 "configure"
++#line 2633 "configure"
+ #include "confdefs.h"
+ 
+ #include <${cf_cv_ncurses_header-curses.h}>
+@@ -2180,7 +2653,7 @@
+ 	exit(0);
+ }
+ EOF
+-if { (eval echo configure:2184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
++if { (eval echo configure:2657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+ then
+   
+ 	cf_cv_ncurses_version=`cat $cf_tempfile`
+@@ -2211,7 +2684,7 @@
+ cf_ncurses_LIBS=""
+ cf_ncurses_SAVE="$LIBS"
+ echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
+-echo "configure:2215: checking for Gpm_Open in -lgpm" >&5
++echo "configure:2688: checking for Gpm_Open in -lgpm" >&5
+ ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -2219,7 +2692,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lgpm  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 2223 "configure"
++#line 2696 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -2230,7 +2703,7 @@
+ Gpm_Open()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -2246,7 +2719,7 @@
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+   echo "$ac_t""yes" 1>&6
+   echo $ac_n "checking for initscr in -lgpm""... $ac_c" 1>&6
+-echo "configure:2250: checking for initscr in -lgpm" >&5
++echo "configure:2723: checking for initscr in -lgpm" >&5
+ ac_lib_var=`echo gpm'_'initscr | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -2254,7 +2727,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lgpm  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 2258 "configure"
++#line 2731 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -2265,7 +2738,7 @@
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -2295,8 +2768,9 @@
+ freebsd*)
+ 	# This is only necessary if you are linking against an obsolete
+ 	# version of ncurses (but it should do no harm, since it's static).
+-	echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
+-echo "configure:2300: checking for tgoto in -lmytinfo" >&5
++	if test "$cf_nculib_root" = ncurses ; then
++		echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
++echo "configure:2774: checking for tgoto in -lmytinfo" >&5
+ ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -2304,7 +2778,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lmytinfo  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 2308 "configure"
++#line 2782 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -2315,7 +2789,7 @@
+ tgoto()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -2335,6 +2809,7 @@
+   echo "$ac_t""no" 1>&6
+ fi
+ 
++	fi
+ 	;;
+ esac
+ 
+@@ -2348,12 +2823,12 @@
+ 	eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
+ 	cf_libdir=""
+ 	echo $ac_n "checking for initscr""... $ac_c" 1>&6
+-echo "configure:2352: checking for initscr" >&5
++echo "configure:2827: checking for initscr" >&5
+ if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 2357 "configure"
++#line 2832 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char initscr(); below.  */
+@@ -2376,7 +2851,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_func_initscr=yes"
+ else
+@@ -2396,17 +2871,17 @@
+ 
+ 		cf_save_LIBS="$LIBS"
+ 		echo $ac_n "checking for initscr in -l$cf_nculib_root""... $ac_c" 1>&6
+-echo "configure:2400: checking for initscr in -l$cf_nculib_root" >&5
++echo "configure:2875: checking for initscr in -l$cf_nculib_root" >&5
+ 		LIBS="-l$cf_nculib_root $LIBS"
+ 		cat > conftest.$ac_ext <<EOF
+-#line 2403 "configure"
++#line 2878 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   echo "$ac_t""yes" 1>&6
+ 			 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+@@ -2475,17 +2950,17 @@
+ 			for cf_libdir in $cf_search
+ 			do
+ 				echo $ac_n "checking for -l$cf_nculib_root in $cf_libdir""... $ac_c" 1>&6
+-echo "configure:2479: checking for -l$cf_nculib_root in $cf_libdir" >&5
++echo "configure:2954: checking for -l$cf_nculib_root in $cf_libdir" >&5
+ 				LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
+ 				cat > conftest.$ac_ext <<EOF
+-#line 2482 "configure"
++#line 2957 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:2964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   echo "$ac_t""yes" 1>&6
+ 			 		 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+@@ -2516,7 +2991,7 @@
+ 
+ if test -n "$cf_ncurses_LIBS" ; then
+ 	echo $ac_n "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS""... $ac_c" 1>&6
+-echo "configure:2520: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
++echo "configure:2995: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
+ 	cf_ncurses_SAVE="$LIBS"
+ 	for p in $cf_ncurses_LIBS ; do
+ 		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
+@@ -2525,14 +3000,14 @@
+ 		fi
+ 	done
+ 	cat > conftest.$ac_ext <<EOF
+-#line 2529 "configure"
++#line 3004 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   echo "$ac_t""yes" 1>&6
+ else
+@@ -2559,14 +3034,14 @@
+ 	cf_cv_libtype=w
+ 	
+ echo $ac_n "checking for multibyte character support""... $ac_c" 1>&6
+-echo "configure:2563: checking for multibyte character support" >&5
++echo "configure:3038: checking for multibyte character support" >&5
+ if eval "test \"`echo '$''{'cf_cv_utf8_lib'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   
+ 	cf_save_LIBS="$LIBS"
+ 	cat > conftest.$ac_ext <<EOF
+-#line 2570 "configure"
++#line 3045 "configure"
+ #include "confdefs.h"
+ 
+ #include <stdlib.h>
+@@ -2574,7 +3049,7 @@
+ putwc(0,0);
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   cf_cv_utf8_lib=yes
+ else
+@@ -2583,7 +3058,7 @@
+   rm -rf conftest*
+   LIBS="-lutf8 $LIBS"
+ 	 cat > conftest.$ac_ext <<EOF
+-#line 2587 "configure"
++#line 3062 "configure"
+ #include "confdefs.h"
+ 
+ #include <libutf8.h>
+@@ -2591,7 +3066,7 @@
+ putwc(0,0);
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   cf_cv_utf8_lib=add-on
+ else
+@@ -2620,128 +3095,6 @@
+ fi
+ 
+ 	
+-echo $ac_n "checking if we must define _XOPEN_SOURCE""... $ac_c" 1>&6
+-echo "configure:2625: checking if we must define _XOPEN_SOURCE" >&5
+-cat > conftest.$ac_ext <<EOF
+-#line 2627 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
+-
+-int main() {
+-
+-#ifndef _XOPEN_SOURCE
+-make an error
+-#endif
+-; return 0; }
+-EOF
+-if { (eval echo configure:2638: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+-  rm -rf conftest*
+-  cf_result=no
+-else
+-  echo "configure: failed program was:" >&5
+-  cat conftest.$ac_ext >&5
+-  rm -rf conftest*
+-  cf_result=yes
+-fi
+-rm -f conftest*
+-echo "$ac_t""$cf_result" 1>&6
+-
+-if test "$cf_result" = yes ; then
+-	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
+-elif test "x500" != "x" ; then
+-	echo $ac_n "checking checking for compatible value versus 500""... $ac_c" 1>&6
+-echo "configure:2654: checking checking for compatible value versus 500" >&5
+-	cat > conftest.$ac_ext <<EOF
+-#line 2656 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
+-
+-int main() {
+-
+-#if _XOPEN_SOURCE-500 < 0
+-make an error
+-#endif
+-; return 0; }
+-EOF
+-if { (eval echo configure:2667: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+-  rm -rf conftest*
+-  cf_result=yes
+-else
+-  echo "configure: failed program was:" >&5
+-  cat conftest.$ac_ext >&5
+-  rm -rf conftest*
+-  cf_result=no
+-fi
+-rm -f conftest*
+-	echo "$ac_t""$cf_result" 1>&6
+-	if test "$cf_result" = no ; then
+-		# perhaps we can override it - try...
+-		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
+-	fi
+-fi
+-
+-	
+-echo $ac_n "checking if we must define _XOPEN_SOURCE_EXTENDED""... $ac_c" 1>&6
+-echo "configure:2686: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
+-cat > conftest.$ac_ext <<EOF
+-#line 2688 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
+-
+-int main() {
+-
+-#ifndef _XOPEN_SOURCE_EXTENDED
+-make an error
+-#endif
+-; return 0; }
+-EOF
+-if { (eval echo configure:2699: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+-  rm -rf conftest*
+-  cf_result=no
+-else
+-  echo "configure: failed program was:" >&5
+-  cat conftest.$ac_ext >&5
+-  rm -rf conftest*
+-  cf_result=yes
+-fi
+-rm -f conftest*
+-echo "$ac_t""$cf_result" 1>&6
+-
+-if test "$cf_result" = yes ; then
+-	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
+-elif test "x" != "x" ; then
+-	echo $ac_n "checking checking for compatible value versus ""... $ac_c" 1>&6
+-echo "configure:2715: checking checking for compatible value versus " >&5
+-	cat > conftest.$ac_ext <<EOF
+-#line 2717 "configure"
+-#include "confdefs.h"
+-#include <sys/types.h>
+-
+-int main() {
+-
+-#if _XOPEN_SOURCE_EXTENDED- < 0
+-make an error
+-#endif
+-; return 0; }
+-EOF
+-if { (eval echo configure:2728: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+-  rm -rf conftest*
+-  cf_result=yes
+-else
+-  echo "configure: failed program was:" >&5
+-  cat conftest.$ac_ext >&5
+-  rm -rf conftest*
+-  cf_result=no
+-fi
+-rm -f conftest*
+-	echo "$ac_t""$cf_result" 1>&6
+-	if test "$cf_result" = no ; then
+-		# perhaps we can override it - try...
+-		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED="
+-	fi
+-fi
+-
+-	
+ 
+ cf_ncuhdr_root=ncursesw
+ 
+@@ -2750,7 +3103,7 @@
+ CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
+ 
+ echo $ac_n "checking for $cf_ncuhdr_root header in include-path""... $ac_c" 1>&6
+-echo "configure:2754: checking for $cf_ncuhdr_root header in include-path" >&5
++echo "configure:3107: checking for $cf_ncuhdr_root header in include-path" >&5
+ if eval "test \"`echo '$''{'cf_cv_ncurses_h'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -2761,7 +3114,7 @@
+ 	do
+ 		
+ 	cat > conftest.$ac_ext <<EOF
+-#line 2765 "configure"
++#line 3118 "configure"
+ #include "confdefs.h"
+ 
+ 
+@@ -2790,7 +3143,7 @@
+ 	
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2794: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:3147: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_cv_ncurses_h=$cf_header
+ 	
+@@ -2813,7 +3166,7 @@
+ 	cf_cv_ncurses_header=$cf_cv_ncurses_h
+ else
+ echo $ac_n "checking for $cf_ncuhdr_root include-path""... $ac_c" 1>&6
+-echo "configure:2817: checking for $cf_ncuhdr_root include-path" >&5
++echo "configure:3170: checking for $cf_ncuhdr_root include-path" >&5
+ if eval "test \"`echo '$''{'cf_cv_ncurses_h2'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -2908,14 +3261,14 @@
+ 				cf_save_CPPFLAGS="$CPPFLAGS"
+ 				CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+ 				cat > conftest.$ac_ext <<EOF
+-#line 2912 "configure"
++#line 3265 "configure"
+ #include "confdefs.h"
+ #include <stdio.h>
+ int main() {
+ printf("Hello")
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2919: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:3272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   :
+ else
+   echo "configure: failed program was:" >&5
+@@ -2942,7 +3295,7 @@
+ 		do
+ 			
+ 	cat > conftest.$ac_ext <<EOF
+-#line 2946 "configure"
++#line 3299 "configure"
+ #include "confdefs.h"
+ 
+ 
+@@ -2971,7 +3324,7 @@
+ 	
+ ; return 0; }
+ EOF
+-if { (eval echo configure:2975: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:3328: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_cv_ncurses_h2=$cf_header
+ 	
+@@ -3018,14 +3371,14 @@
+ 				cf_save_CPPFLAGS="$CPPFLAGS"
+ 				CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
+ 				cat > conftest.$ac_ext <<EOF
+-#line 3022 "configure"
++#line 3375 "configure"
+ #include "confdefs.h"
+ #include <stdio.h>
+ int main() {
+ printf("Hello")
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3029: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:3382: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   :
+ else
+   echo "configure: failed program was:" >&5
+@@ -3080,7 +3433,7 @@
+ 
+ 
+ echo $ac_n "checking for ncurses version""... $ac_c" 1>&6
+-echo "configure:3084: checking for ncurses version" >&5
++echo "configure:3437: checking for ncurses version" >&5
+ if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -3106,7 +3459,7 @@
+ #endif
+ EOF
+ 	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
+-	{ (eval echo configure:3110: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
++	{ (eval echo configure:3463: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
+ 	if test -f conftest.out ; then
+ 		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
+ 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
+@@ -3115,7 +3468,7 @@
+ 
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3119 "configure"
++#line 3472 "configure"
+ #include "confdefs.h"
+ 
+ #include <${cf_cv_ncurses_header-curses.h}>
+@@ -3139,7 +3492,7 @@
+ 	exit(0);
+ }
+ EOF
+-if { (eval echo configure:3143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
++if { (eval echo configure:3496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+ then
+   
+ 	cf_cv_ncurses_version=`cat $cf_tempfile`
+@@ -3170,7 +3523,7 @@
+ cf_ncurses_LIBS=""
+ cf_ncurses_SAVE="$LIBS"
+ echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
+-echo "configure:3174: checking for Gpm_Open in -lgpm" >&5
++echo "configure:3527: checking for Gpm_Open in -lgpm" >&5
+ ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -3178,7 +3531,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lgpm  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 3182 "configure"
++#line 3535 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -3189,7 +3542,7 @@
+ Gpm_Open()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3205,7 +3558,7 @@
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+   echo "$ac_t""yes" 1>&6
+   echo $ac_n "checking for initscr in -lgpm""... $ac_c" 1>&6
+-echo "configure:3209: checking for initscr in -lgpm" >&5
++echo "configure:3562: checking for initscr in -lgpm" >&5
+ ac_lib_var=`echo gpm'_'initscr | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -3213,7 +3566,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lgpm  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 3217 "configure"
++#line 3570 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -3224,7 +3577,7 @@
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3581: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3254,8 +3607,9 @@
+ freebsd*)
+ 	# This is only necessary if you are linking against an obsolete
+ 	# version of ncurses (but it should do no harm, since it's static).
+-	echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
+-echo "configure:3259: checking for tgoto in -lmytinfo" >&5
++	if test "$cf_nculib_root" = ncurses ; then
++		echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
++echo "configure:3613: checking for tgoto in -lmytinfo" >&5
+ ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -3263,7 +3617,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lmytinfo  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 3267 "configure"
++#line 3621 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -3274,7 +3628,7 @@
+ tgoto()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3294,6 +3648,7 @@
+   echo "$ac_t""no" 1>&6
+ fi
+ 
++	fi
+ 	;;
+ esac
+ 
+@@ -3307,12 +3662,12 @@
+ 	eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
+ 	cf_libdir=""
+ 	echo $ac_n "checking for initscr""... $ac_c" 1>&6
+-echo "configure:3311: checking for initscr" >&5
++echo "configure:3666: checking for initscr" >&5
+ if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3316 "configure"
++#line 3671 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char initscr(); below.  */
+@@ -3335,7 +3690,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3339: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_func_initscr=yes"
+ else
+@@ -3355,17 +3710,17 @@
+ 
+ 		cf_save_LIBS="$LIBS"
+ 		echo $ac_n "checking for initscr in -l$cf_nculib_root""... $ac_c" 1>&6
+-echo "configure:3359: checking for initscr in -l$cf_nculib_root" >&5
++echo "configure:3714: checking for initscr in -l$cf_nculib_root" >&5
+ 		LIBS="-l$cf_nculib_root $LIBS"
+ 		cat > conftest.$ac_ext <<EOF
+-#line 3362 "configure"
++#line 3717 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   echo "$ac_t""yes" 1>&6
+ 			 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+@@ -3434,17 +3789,17 @@
+ 			for cf_libdir in $cf_search
+ 			do
+ 				echo $ac_n "checking for -l$cf_nculib_root in $cf_libdir""... $ac_c" 1>&6
+-echo "configure:3438: checking for -l$cf_nculib_root in $cf_libdir" >&5
++echo "configure:3793: checking for -l$cf_nculib_root in $cf_libdir" >&5
+ 				LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
+ 				cat > conftest.$ac_ext <<EOF
+-#line 3441 "configure"
++#line 3796 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3448: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   echo "$ac_t""yes" 1>&6
+ 			 		 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
+@@ -3475,7 +3830,7 @@
+ 
+ if test -n "$cf_ncurses_LIBS" ; then
+ 	echo $ac_n "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS""... $ac_c" 1>&6
+-echo "configure:3479: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
++echo "configure:3834: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
+ 	cf_ncurses_SAVE="$LIBS"
+ 	for p in $cf_ncurses_LIBS ; do
+ 		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
+@@ -3484,14 +3839,14 @@
+ 		fi
+ 	done
+ 	cat > conftest.$ac_ext <<EOF
+-#line 3488 "configure"
++#line 3843 "configure"
+ #include "confdefs.h"
+ #include <${cf_cv_ncurses_header-curses.h}>
+ int main() {
+ initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   echo "$ac_t""yes" 1>&6
+ else
+@@ -3518,27 +3873,27 @@
+ 
+ 
+ 
+-echo $ac_n "checking for form_driver in -lform$cf_cv_libtype""... $ac_c" 1>&6
+-echo "configure:3523: checking for form_driver in -lform$cf_cv_libtype" >&5
+-ac_lib_var=`echo form$cf_cv_libtype'_'form_driver | sed 'y%./+-%__p_%'`
++echo $ac_n "checking for new_panel in -lpanel$cf_cv_libtype""... $ac_c" 1>&6
++echo "configure:3878: checking for new_panel in -lpanel$cf_cv_libtype" >&5
++ac_lib_var=`echo panel$cf_cv_libtype'_'new_panel | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   ac_save_LIBS="$LIBS"
+-LIBS="-lform$cf_cv_libtype  $LIBS"
++LIBS="-lpanel$cf_cv_libtype  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 3531 "configure"
++#line 3886 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+     builtin and then its argument prototype would still apply.  */
+-char form_driver();
++char new_panel();
+ 
+ int main() {
+-form_driver()
++new_panel()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3542: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3553,20 +3908,20 @@
+ fi
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+   echo "$ac_t""yes" 1>&6
+-    ac_tr_lib=HAVE_LIB`echo form$cf_cv_libtype | sed -e 's/[^a-zA-Z0-9_]/_/g' \
++    ac_tr_lib=HAVE_LIB`echo panel$cf_cv_libtype | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+     -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+   cat >> confdefs.h <<EOF
+ #define $ac_tr_lib 1
+ EOF
+ 
+-  LIBS="-lform$cf_cv_libtype $LIBS"
++  LIBS="-lpanel$cf_cv_libtype $LIBS"
+ 
+ else
+   echo "$ac_t""no" 1>&6
+ fi
+ 
+ echo $ac_n "checking for menu_driver in -lmenu$cf_cv_libtype""... $ac_c" 1>&6
+-echo "configure:3570: checking for menu_driver in -lmenu$cf_cv_libtype" >&5
++echo "configure:3925: checking for menu_driver in -lmenu$cf_cv_libtype" >&5
+ ac_lib_var=`echo menu$cf_cv_libtype'_'menu_driver | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+@@ -3574,7 +3929,7 @@
+   ac_save_LIBS="$LIBS"
+ LIBS="-lmenu$cf_cv_libtype  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 3578 "configure"
++#line 3933 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+@@ -3585,7 +3940,7 @@
+ menu_driver()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3944: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3612,27 +3967,27 @@
+   echo "$ac_t""no" 1>&6
+ fi
+ 
+-echo $ac_n "checking for new_panel in -lpanel$cf_cv_libtype""... $ac_c" 1>&6
+-echo "configure:3617: checking for new_panel in -lpanel$cf_cv_libtype" >&5
+-ac_lib_var=`echo panel$cf_cv_libtype'_'new_panel | sed 'y%./+-%__p_%'`
++echo $ac_n "checking for form_driver in -lform$cf_cv_libtype""... $ac_c" 1>&6
++echo "configure:3972: checking for form_driver in -lform$cf_cv_libtype" >&5
++ac_lib_var=`echo form$cf_cv_libtype'_'form_driver | sed 'y%./+-%__p_%'`
+ if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   ac_save_LIBS="$LIBS"
+-LIBS="-lpanel$cf_cv_libtype  $LIBS"
++LIBS="-lform$cf_cv_libtype  $LIBS"
+ cat > conftest.$ac_ext <<EOF
+-#line 3625 "configure"
++#line 3980 "configure"
+ #include "confdefs.h"
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ /* We use char because int might match the return type of a gcc2
+     builtin and then its argument prototype would still apply.  */
+-char new_panel();
++char form_driver();
+ 
+ int main() {
+-new_panel()
++form_driver()
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:3991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_lib_$ac_lib_var=yes"
+ else
+@@ -3647,13 +4002,13 @@
+ fi
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+   echo "$ac_t""yes" 1>&6
+-    ac_tr_lib=HAVE_LIB`echo panel$cf_cv_libtype | sed -e 's/[^a-zA-Z0-9_]/_/g' \
++    ac_tr_lib=HAVE_LIB`echo form$cf_cv_libtype | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+     -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+   cat >> confdefs.h <<EOF
+ #define $ac_tr_lib 1
+ EOF
+ 
+-  LIBS="-lpanel$cf_cv_libtype $LIBS"
++  LIBS="-lform$cf_cv_libtype $LIBS"
+ 
+ else
+   echo "$ac_t""no" 1>&6
+@@ -3661,12 +4016,12 @@
+ 
+ 
+ echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
+-echo "configure:3665: checking return type of signal handlers" >&5
++echo "configure:4020: checking return type of signal handlers" >&5
+ if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3670 "configure"
++#line 4025 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #include <signal.h>
+@@ -3683,7 +4038,7 @@
+ int i;
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3687: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:4042: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   ac_cv_type_signal=void
+ else
+@@ -3703,12 +4058,12 @@
+ 
+ 
+ echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+-echo "configure:3707: checking for ANSI C header files" >&5
++echo "configure:4062: checking for ANSI C header files" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3712 "configure"
++#line 4067 "configure"
+ #include "confdefs.h"
+ #include <stdlib.h>
+ #include <stdarg.h>
+@@ -3716,7 +4071,7 @@
+ #include <float.h>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:3720: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:4075: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -3733,7 +4088,7 @@
+ if test $ac_cv_header_stdc = yes; then
+   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat > conftest.$ac_ext <<EOF
+-#line 3737 "configure"
++#line 4092 "configure"
+ #include "confdefs.h"
+ #include <string.h>
+ EOF
+@@ -3751,7 +4106,7 @@
+ if test $ac_cv_header_stdc = yes; then
+   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat > conftest.$ac_ext <<EOF
+-#line 3755 "configure"
++#line 4110 "configure"
+ #include "confdefs.h"
+ #include <stdlib.h>
+ EOF
+@@ -3772,7 +4127,7 @@
+   :
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3776 "configure"
++#line 4131 "configure"
+ #include "confdefs.h"
+ #include <ctype.h>
+ #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+@@ -3783,7 +4138,7 @@
+ exit (0); }
+ 
+ EOF
+-if { (eval echo configure:3787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
++if { (eval echo configure:4142: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+ then
+   :
+ else
+@@ -3807,12 +4162,12 @@
+ fi
+ 
+ echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
+-echo "configure:3811: checking whether time.h and sys/time.h may both be included" >&5
++echo "configure:4166: checking whether time.h and sys/time.h may both be included" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3816 "configure"
++#line 4171 "configure"
+ #include "confdefs.h"
+ #include <sys/types.h>
+ #include <sys/time.h>
+@@ -3821,7 +4176,7 @@
+ struct tm *tp;
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3825: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:4180: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   ac_cv_header_time=yes
+ else
+@@ -3858,17 +4213,17 @@
+ do
+ ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+ echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+-echo "configure:3862: checking for $ac_hdr" >&5
++echo "configure:4217: checking for $ac_hdr" >&5
+ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3867 "configure"
++#line 4222 "configure"
+ #include "confdefs.h"
+ #include <$ac_hdr>
+ EOF
+ ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+-{ (eval echo configure:3872: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
++{ (eval echo configure:4227: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+ if test -z "$ac_err"; then
+   rm -rf conftest*
+@@ -3911,12 +4266,12 @@
+ 
+ do
+ echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+-echo "configure:3915: checking for $ac_func" >&5
++echo "configure:4270: checking for $ac_func" >&5
+ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 3920 "configure"
++#line 4275 "configure"
+ #include "confdefs.h"
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char $ac_func(); below.  */
+@@ -3939,7 +4294,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3943: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4298: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   eval "ac_cv_func_$ac_func=yes"
+ else
+@@ -3965,7 +4320,7 @@
+ 
+ 
+ cat > conftest.$ac_ext <<EOF
+-#line 3969 "configure"
++#line 4324 "configure"
+ #include "confdefs.h"
+ 
+ #include <${cf_cv_ncurses_header-curses.h}>
+@@ -3986,7 +4341,7 @@
+ 	
+ ; return 0; }
+ EOF
+-if { (eval echo configure:3990: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   cat >> confdefs.h <<\EOF
+ #define NCURSES_EXT_FUNCS 1
+@@ -4000,13 +4355,13 @@
+ 
+ 
+ echo $ac_n "checking if sys/time.h works with sys/select.h""... $ac_c" 1>&6
+-echo "configure:4004: checking if sys/time.h works with sys/select.h" >&5
++echo "configure:4359: checking if sys/time.h works with sys/select.h" >&5
+ if eval "test \"`echo '$''{'cf_cv_sys_time_select'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+   
+ cat > conftest.$ac_ext <<EOF
+-#line 4010 "configure"
++#line 4365 "configure"
+ #include "confdefs.h"
+ 
+ #include <sys/types.h>
+@@ -4021,7 +4376,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4025: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:4380: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_cv_sys_time_select=yes
+ else
+@@ -4042,7 +4397,7 @@
+ 
+ 
+ echo $ac_n "checking for function curses_version""... $ac_c" 1>&6
+-echo "configure:4046: checking for function curses_version" >&5
++echo "configure:4401: checking for function curses_version" >&5
+ if eval "test \"`echo '$''{'cf_cv_func_curses_version'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -4051,7 +4406,7 @@
+   cf_cv_func_curses_version=unknown
+ else
+   cat > conftest.$ac_ext <<EOF
+-#line 4055 "configure"
++#line 4410 "configure"
+ #include "confdefs.h"
+ 
+ #include <${cf_cv_ncurses_header-curses.h}>
+@@ -4063,7 +4418,7 @@
+ }
+ 
+ EOF
+-if { (eval echo configure:4067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
++if { (eval echo configure:4422: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+ then
+   cf_cv_func_curses_version=yes
+ 
+@@ -4088,7 +4443,7 @@
+ 
+ 
+ echo $ac_n "checking for alternate character set array""... $ac_c" 1>&6
+-echo "configure:4092: checking for alternate character set array" >&5
++echo "configure:4447: checking for alternate character set array" >&5
+ if eval "test \"`echo '$''{'cf_cv_curses_acs_map'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -4097,7 +4452,7 @@
+ for name in acs_map _acs_map __acs_map _nc_acs_map
+ do
+ cat > conftest.$ac_ext <<EOF
+-#line 4101 "configure"
++#line 4456 "configure"
+ #include "confdefs.h"
+ 
+ #include <${cf_cv_ncurses_header-curses.h}>
+@@ -4108,7 +4463,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4467: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   cf_cv_curses_acs_map=$name; break
+ else
+@@ -4129,7 +4484,7 @@
+ 
+ 
+ echo $ac_n "checking for wide alternate character set array""... $ac_c" 1>&6
+-echo "configure:4133: checking for wide alternate character set array" >&5
++echo "configure:4488: checking for wide alternate character set array" >&5
+ if eval "test \"`echo '$''{'cf_cv_curses_wacs_map'+set}'`\" = set"; then
+   echo $ac_n "(cached) $ac_c" 1>&6
+ else
+@@ -4138,7 +4493,7 @@
+ 	for name in wacs_map _wacs_map __wacs_map _nc_wacs
+ 	do
+ 	cat > conftest.$ac_ext <<EOF
+-#line 4142 "configure"
++#line 4497 "configure"
+ #include "confdefs.h"
+ 
+ #ifndef _XOPEN_SOURCE_EXTENDED
+@@ -4149,7 +4504,7 @@
+ $name['k'] = *WACS_PLUS
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
++if { (eval echo configure:4508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   rm -rf conftest*
+   cf_cv_curses_wacs_map=$name
+ 	 break
+@@ -4165,9 +4520,9 @@
+ 
+ 
+ echo $ac_n "checking for type attr_t in ${cf_cv_ncurses_header-curses.h}""... $ac_c" 1>&6
+-echo "configure:4169: checking for type attr_t in ${cf_cv_ncurses_header-curses.h}" >&5
++echo "configure:4524: checking for type attr_t in ${cf_cv_ncurses_header-curses.h}" >&5
+ cat > conftest.$ac_ext <<EOF
+-#line 4171 "configure"
++#line 4526 "configure"
+ #include "confdefs.h"
+ 
+ #ifndef _XOPEN_SOURCE_EXTENDED
+@@ -4180,7 +4535,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4184: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:4539: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_result=yes
+ else
+@@ -4208,9 +4563,9 @@
+ 
+ 
+ echo $ac_n "checking for type mbstate_t in ${cf_cv_ncurses_header-curses.h}""... $ac_c" 1>&6
+-echo "configure:4212: checking for type mbstate_t in ${cf_cv_ncurses_header-curses.h}" >&5
++echo "configure:4567: checking for type mbstate_t in ${cf_cv_ncurses_header-curses.h}" >&5
+ cat > conftest.$ac_ext <<EOF
+-#line 4214 "configure"
++#line 4569 "configure"
+ #include "confdefs.h"
+ 
+ #ifndef _XOPEN_SOURCE_EXTENDED
+@@ -4223,7 +4578,7 @@
+ 
+ ; return 0; }
+ EOF
+-if { (eval echo configure:4227: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
++if { (eval echo configure:4582: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+   rm -rf conftest*
+   cf_result=yes
+ else
+@@ -4250,6 +4605,9 @@
+ fi
+ 
+ 
++TEST_ARGS="$LIBS"
++LIBS=
++
+ 
+ trap '' 1 2 15
+ cat > confcache <<\EOF
+@@ -4397,7 +4755,6 @@
+ s%@DFT_OBJ_SUBDIR@%$DFT_OBJ_SUBDIR%g
+ s%@DFT_UPR_MODEL@%$DFT_UPR_MODEL%g
+ s%@ECHO_LINK@%$ECHO_LINK%g
+-s%@EXTRA_LIBS@%$EXTRA_LIBS%g
+ s%@LD@%$LD%g
+ s%@LDFLAGS_SHARED@%$LDFLAGS_SHARED%g
+ s%@LD_MODEL@%$LD_MODEL%g
+@@ -4415,10 +4772,12 @@
+ s%@MATH_LIB@%$MATH_LIB%g
+ s%@TEST_ARGS@%$TEST_ARGS%g
+ s%@TEST_DEPS@%$TEST_DEPS%g
++s%@TINFO_ARGS@%$TINFO_ARGS%g
+ s%@cf_cv_abi_version@%$cf_cv_abi_version%g
+ s%@cf_cv_rel_version@%$cf_cv_rel_version%g
+ s%@EXEEXT@%$EXEEXT%g
+ s%@OBJEXT@%$OBJEXT%g
++s%@EXTRA_CPPFLAGS@%$EXTRA_CPPFLAGS%g
+ 
+ CEOF
+ EOF
+Index: test/configure.in
+Prereq:  1.47 
+--- ncurses-5.4-20040208/test/configure.in	2004-01-31 00:07:01.000000000 +0000
++++ ncurses-5.4-20050319/test/configure.in	2005-02-26 23:58:27.000000000 +0000
+@@ -1,5 +1,5 @@
+ dnl***************************************************************************
+-dnl Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++dnl Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
+ dnl                                                                          *
+ dnl Permission is hereby granted, free of charge, to any person obtaining a  *
+ dnl copy of this software and associated documentation files (the            *
+@@ -28,7 +28,7 @@
+ dnl
+ dnl Author: Thomas E. Dickey 1996, etc.
+ dnl
+-dnl $Id: configure.in,v 1.47 2004/01/31 00:07:01 tom Exp $
++dnl $Id: configure.in,v 1.51 2005/02/26 23:58:27 tom Exp $
+ dnl This is a simple configuration-script for the ncurses test programs that
+ dnl allows the test-directory to be separately configured against a reference
+ dnl system (i.e., sysvr4 curses)
+@@ -58,7 +58,6 @@
+ DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'`	AC_SUBST(DFT_OBJ_SUBDIR)
+ DFT_UPR_MODEL="NORMAL"			AC_SUBST(DFT_UPR_MODEL)
+ ECHO_LINK='@ echo linking $@ ... ;'	AC_SUBST(ECHO_LINK)
+-EXTRA_LIBS=""				AC_SUBST(EXTRA_LIBS)
+ LD="ld"					AC_SUBST(LD)
+ LDFLAGS_SHARED=""			AC_SUBST(LDFLAGS_SHARED)
+ LD_MODEL=""				AC_SUBST(LD_MODEL)
+@@ -76,6 +75,7 @@
+ MATH_LIB="-lm"				AC_SUBST(MATH_LIB)
+ TEST_ARGS=""				AC_SUBST(TEST_ARGS)
+ TEST_DEPS=""				AC_SUBST(TEST_DEPS)
++TINFO_ARGS='$(LIBS_CURSES)'		AC_SUBST(TINFO_ARGS)
+ cf_cv_abi_version=""			AC_SUBST(cf_cv_abi_version)
+ cf_cv_rel_version=""			AC_SUBST(cf_cv_rel_version)
+ 
+@@ -84,7 +84,10 @@
+ 
+ AC_EXEEXT
+ AC_OBJEXT
+-CF_GNU_SOURCE
++
++CF_ANSI_CC_REQD
++CF_XOPEN_SOURCE
++
+ CF_WITH_CURSES_DIR
+ 
+ dnl SunOS 4.x
+@@ -118,8 +121,6 @@
+ ncursesw)
+ 	cf_cv_libtype=w
+ 	CF_UTF8_LIB
+-	CF_PREDEFINE(_XOPEN_SOURCE,500)
+-	CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
+ 	CF_NCURSES_CPPFLAGS(ncursesw)
+ 	CF_NCURSES_LIBS(ncursesw)
+ 	LIB_NAME=ncursesw
+@@ -131,9 +132,9 @@
+ 
+ dnl Autoconf builds up the $LIBS in reverse order
+ 
+-AC_CHECK_LIB(form$cf_cv_libtype,form_driver)
+-AC_CHECK_LIB(menu$cf_cv_libtype,menu_driver)
+ AC_CHECK_LIB(panel$cf_cv_libtype,new_panel)
++AC_CHECK_LIB(menu$cf_cv_libtype,menu_driver)
++AC_CHECK_LIB(form$cf_cv_libtype,form_driver)
+ 
+ AC_TYPE_SIGNAL
+ 
+@@ -193,6 +194,9 @@
+ CF_CURSES_CHECK_TYPE(attr_t,long)
+ CF_CURSES_CHECK_TYPE(mbstate_t,long)
+ 
++TEST_ARGS="$LIBS"
++LIBS=
++
+ dnl ---------------------------------------------------------------------------
+ 
+ AC_OUTPUT(Makefile,[
+Index: test/demo_forms.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/test/demo_forms.c	2003-05-03 22:08:20.000000000 +0000
++++ ncurses-5.4-20050319/test/demo_forms.c	2005-03-06 00:27:27.000000000 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * $Id: demo_forms.c,v 1.3 2003/05/03 22:08:20 tom Exp $
++ * $Id: demo_forms.c,v 1.10 2005/03/06 00:27:27 tom Exp $
+  *
+  * Demonstrate a variety of functions from the form library.
+  * Thomas Dickey - 2003/4/26
+@@ -7,14 +7,8 @@
+ /*
+ TYPE_ALNUM			-
+ TYPE_ENUM			-
+-TYPE_INTEGER			-
+-TYPE_IPV4			-
+-TYPE_NUMERIC			-
+ TYPE_REGEXP			-
+-data_ahead			-
+-data_behind			-
+ dup_field			-
+-dynamic_field_info		-
+ field_arg			-
+ field_back			-
+ field_count			-
+@@ -63,6 +57,10 @@
+ 
+ #include <edit_field.h>
+ 
++static int d_option = 0;
++static int m_value = 0;
++static int o_value = 0;
++
+ static FIELD *
+ make_label(int frow, int fcol, NCURSES_CONST char *label)
+ {
+@@ -81,11 +79,15 @@
+ static FIELD *
+ make_field(int frow, int fcol, int rows, int cols)
+ {
+-    FIELD *f = new_field(rows, cols, frow, fcol, 0, 1);
++    FIELD *f = new_field(rows, cols, frow, fcol, o_value, 1);
+ 
+     if (f) {
+ 	set_field_back(f, A_UNDERLINE);
+ 	set_field_userptr(f, (void *) 0);
++	if (d_option) {
++	    field_opts_off(f, O_STATIC);
++	    set_max_field(f, m_value);
++	}
+     }
+     return (f);
+ }
+@@ -151,12 +153,18 @@
+     FIELDTYPE *type;
+     char *buffer;
+     int nbuf;
++    int field_rows, field_cols, field_max;
+ 
+     if (has_colors()) {
+ 	wbkgd(win, COLOR_PAIR(1));
+     }
+     werase(win);
+-    wprintw(win, "Cursor: %d,%d\n", form->currow, form->curcol);
++    wprintw(win, "Cursor: %d,%d", form->currow, form->curcol);
++    if (data_ahead(form))
++	waddstr(win, " ahead");
++    if (data_behind(form))
++	waddstr(win, " behind");
++    waddch(win, '\n');
+     if ((field = current_field(form)) != 0) {
+ 	wprintw(win, "Field %d:", field_index(field));
+ 	if ((type = field_type(field)) != 0) {
+@@ -168,6 +176,8 @@
+ 		waddstr(win, "ENUM");
+ 	    else if (type == TYPE_INTEGER)
+ 		waddstr(win, "INTEGER");
++	    else if (type == TYPE_IPV4)
++		waddstr(win, "IPV4");
+ 	    else if (type == TYPE_NUMERIC)
+ 		waddstr(win, "NUMERIC");
+ 	    else if (type == TYPE_REGEXP)
+@@ -175,6 +185,11 @@
+ 	    else
+ 		waddstr(win, "other");
+ 	}
++	if (dynamic_field_info(field, &field_rows, &field_cols, &field_max)
++	    != ERR) {
++	    wprintw(win, " size %dx%d (max %d)",
++		    field_rows, field_cols, field_max);
++	}
+ 	waddstr(win, "\n");
+ 	for (nbuf = 0; nbuf <= 2; ++nbuf) {
+ 	    if ((buffer = field_buffer(field, nbuf)) != 0) {
+@@ -207,23 +222,48 @@
+     refresh();
+ 
+     /* describe the form */
+-    for (pg = 0; pg < 3; ++pg) {
++    for (pg = 0; pg < 4; ++pg) {
+ 	char label[80];
+ 	sprintf(label, "Sample Form Page %d", pg + 1);
+ 	f[n++] = make_label(0, 15, label);
+ 	set_new_page(f[n - 1], TRUE);
+ 
+-	f[n++] = make_label(2, 0, "Last Name");
+-	f[n++] = make_field(3, 0, 1, 18);
+-	set_field_type(f[n - 1], TYPE_ALPHA, 1);
+-
+-	f[n++] = make_label(2, 20, "First Name");
+-	f[n++] = make_field(3, 20, 1, 12);
+-	set_field_type(f[n - 1], TYPE_ALPHA, 1);
+-
+-	f[n++] = make_label(2, 34, "Middle Name");
+-	f[n++] = make_field(3, 34, 1, 12);
+-	set_field_type(f[n - 1], TYPE_ALPHA, 1);
++	switch (pg) {
++	default:
++	    f[n++] = make_label(2, 0, "Last Name");
++	    f[n++] = make_field(3, 0, 1, 18);
++	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
++
++	    f[n++] = make_label(2, 20, "First Name");
++	    f[n++] = make_field(3, 20, 1, 12);
++	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
++
++	    f[n++] = make_label(2, 34, "Middle Name");
++	    f[n++] = make_field(3, 34, 1, 12);
++	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
++	    break;
++	case 2:
++	    f[n++] = make_label(2, 0, "Host Name");
++	    f[n++] = make_field(3, 0, 1, 18);
++	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
++
++	    f[n++] = make_label(2, 20, "IP Address");
++	    f[n++] = make_field(3, 20, 1, 12);
++	    set_field_type(f[n - 1], TYPE_IPV4, 1);
++
++	    break;
++
++	case 3:
++	    f[n++] = make_label(2, 0, "Four digits");
++	    f[n++] = make_field(3, 0, 1, 18);
++	    set_field_type(f[n - 1], TYPE_INTEGER, 4, 0, 0);
++
++	    f[n++] = make_label(2, 20, "Numeric");
++	    f[n++] = make_field(3, 20, 1, 12);
++	    set_field_type(f[n - 1], TYPE_NUMERIC, 3, -10000.0, 100000000.0);
++
++	    break;
++	}
+ 
+ 	f[n++] = make_label(5, 0, "Comments");
+ 	f[n++] = make_field(6, 0, 4, 46);
+@@ -262,9 +302,47 @@
+     nl();
+ }
+ 
++static void
++usage(void)
++{
++    static const char *tbl[] =
++    {
++	"Usage: demo_forms [options]"
++	,""
++	," -d        make fields dynamic"
++	," -m value  set maximum size of dynamic fields"
++	," -o value  specify number of offscreen rows in new_field()"
++    };
++    unsigned int j;
++    for (j = 0; j < SIZEOF(tbl); ++j)
++	fprintf(stderr, "%s\n", tbl[j]);
++    exit(EXIT_FAILURE);
++}
++
+ int
+-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
++main(int argc, char *argv[])
+ {
++    int ch;
++
++    setlocale(LC_ALL, "");
++
++    while ((ch = getopt(argc, argv, "dm:o:")) != EOF) {
++	switch (ch) {
++	case 'd':
++	    d_option = TRUE;
++	    break;
++	case 'm':
++	    m_value = atoi(optarg);
++	    break;
++	case 'o':
++	    o_value = atoi(optarg);
++	    break;
++	default:
++	    usage();
++
++	}
++    }
++
+     initscr();
+     cbreak();
+     noecho();
+@@ -283,7 +361,7 @@
+     demo_forms();
+ 
+     endwin();
+-    return EXIT_SUCCESS;
++    ExitProgram(EXIT_SUCCESS);
+ }
+ #else
+ int
+Index: test/dots.c
+Prereq:  1.8 
+--- ncurses-5.4-20040208/test/dots.c	2002-04-06 21:33:42.000000000 +0000
++++ ncurses-5.4-20050319/test/dots.c	2004-04-10 23:58:46.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1999-2001,2002 Free Software Foundation, Inc.              *
++ * Copyright (c) 1999-2002,2004 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,7 +29,7 @@
+ /*
+  * Author: Thomas E. Dickey <dickey@clark.net> 1999
+  *
+- * $Id: dots.c,v 1.8 2002/04/06 21:33:42 tom Exp $
++ * $Id: dots.c,v 1.9 2004/04/10 23:58:46 tom Exp $
+  *
+  * A simple demo of the terminfo interface.
+  */
+@@ -127,12 +127,16 @@
+ 		tputs(tparm2(set_a_foreground, z), 1, outc);
+ 	    } else {
+ 		tputs(tparm2(set_a_background, z), 1, outc);
++		napms(1);
+ 	    }
+ 	} else if (valid(exit_attribute_mode)
+ 		   && valid(enter_reverse_mode)) {
+-	    if (ranf() <= 0.01)
+-		outs((ranf() > 0.6) ? enter_reverse_mode :
+-		     exit_attribute_mode);
++	    if (ranf() <= 0.01) {
++		outs((ranf() > 0.6)
++		     ? enter_reverse_mode
++		     : exit_attribute_mode);
++		napms(1);
++	    }
+ 	}
+ 	outc(p);
+ 	fflush(stdout);
+Index: test/edit_field.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/test/edit_field.c	2003-05-17 23:16:13.000000000 +0000
++++ ncurses-5.4-20050319/test/edit_field.c	2004-05-29 22:49:23.000000000 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * $Id: edit_field.c,v 1.7 2003/05/17 23:16:13 tom Exp $
++ * $Id: edit_field.c,v 1.8 2004/05/29 22:49:23 tom Exp $
+  *
+  * A wrapper for form_driver() which keeps track of the user's editing changes
+  * for each field, and makes the result available as a null-terminated string
+@@ -181,7 +181,7 @@
+ 
+     keypad(help, TRUE);
+     keypad(data, TRUE);
+-    waddstr(data, "Defined form-traversal keys:\n");
++    waddstr(data, "Defined form edit/traversal keys:\n");
+     for (n = 0; n < SIZEOF(commands); ++n) {
+ 	const char *name;
+ #ifdef NCURSES_VERSION
+Index: test/filter.c
+Prereq:  1.7 
+--- ncurses-5.4-20040208/test/filter.c	2002-03-23 23:02:15.000000000 +0000
++++ ncurses-5.4-20050319/test/filter.c	2004-06-05 21:57:30.000000000 +0000
+@@ -29,7 +29,7 @@
+ /*
+  * Author:  Thomas E. Dickey <dickey@clark.net> 1998
+  *
+- * $Id: filter.c,v 1.7 2002/03/23 23:02:15 tom Exp $
++ * $Id: filter.c,v 1.8 2004/06/05 21:57:30 tom Exp $
+  */
+ #include <test.priv.h>
+ 
+@@ -67,6 +67,8 @@
+     char buffer[80];
+     attr_t underline;
+ 
++    setlocale(LC_ALL, "");
++
+     filter();
+     (void) newterm((char *) 0, stdout, stdin);
+     cbreak();
+Index: test/gdc.c
+Prereq:  1.23 
+--- ncurses-5.4-20040208/test/gdc.c	2002-08-10 19:20:14.000000000 +0000
++++ ncurses-5.4-20050319/test/gdc.c	2004-11-24 12:09:36.000000000 +0000
+@@ -6,7 +6,7 @@
+  * modified 10-18-89 for curses (jrl)
+  * 10-18-89 added signal handling
+  *
+- * $Id: gdc.c,v 1.23 2002/08/10 19:20:14 tom Exp $
++ * $Id: gdc.c,v 1.25 2004/11/24 12:09:36 tom Exp $
+  */
+ 
+ #include <time.h>
+@@ -18,6 +18,10 @@
+ #define XLENGTH	54
+ #define YDEPTH	5
+ 
++#define PAIR_DIGITS 1
++#define PAIR_OTHERS 2
++#define PAIR_FRAMES 3
++
+ static short disp[11] =
+ {
+     075557, 011111, 071747, 071717, 055711,
+@@ -41,13 +45,13 @@
+ }
+ 
+ static void
+-drawbox(void)
++drawbox(bool scrolling)
+ {
+     chtype bottom[XLENGTH + 1];
+     int n;
+ 
+     if (hascolor)
+-	attrset(COLOR_PAIR(3));
++	attrset(COLOR_PAIR(PAIR_FRAMES));
+ 
+     mvaddch(YBASE - 1, XBASE - 1, ACS_ULCORNER);
+     hline(ACS_HLINE, XLENGTH);
+@@ -55,8 +59,11 @@
+ 
+     mvaddch(YBASE + YDEPTH, XBASE - 1, ACS_LLCORNER);
+     mvinchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH);
+-    for (n = 0; n < XLENGTH; n++)
++    for (n = 0; n < XLENGTH; n++) {
++	if (!scrolling)
++	    bottom[n] &= ~A_COLOR;
+ 	bottom[n] = ACS_HLINE | (bottom[n] & (A_ATTRIBUTES | A_COLOR));
++    }
+     mvaddchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH);
+     mvaddch(YBASE + YDEPTH, XBASE + XLENGTH, ACS_LRCORNER);
+ 
+@@ -67,7 +74,7 @@
+     vline(ACS_VLINE, YDEPTH);
+ 
+     if (hascolor)
+-	attrset(COLOR_PAIR(2));
++	attrset(COLOR_PAIR(PAIR_OTHERS));
+ }
+ 
+ static void
+@@ -75,13 +82,13 @@
+ {
+     if (on) {
+ 	if (hascolor) {
+-	    attron(COLOR_PAIR(1));
++	    attron(COLOR_PAIR(PAIR_DIGITS));
+ 	} else {
+ 	    attron(A_STANDOUT);
+ 	}
+     } else {
+ 	if (hascolor) {
+-	    attron(COLOR_PAIR(2));
++	    attron(COLOR_PAIR(PAIR_OTHERS));
+ 	} else {
+ 	    attroff(A_STANDOUT);
+ 	}
+@@ -182,10 +189,10 @@
+ 	if (use_default_colors() == OK)
+ 	    bg = -1;
+ #endif
+-	init_pair(1, COLOR_BLACK, COLOR_RED);
+-	init_pair(2, COLOR_RED, bg);
+-	init_pair(3, COLOR_WHITE, bg);
+-	attrset(COLOR_PAIR(2));
++	init_pair(PAIR_DIGITS, COLOR_BLACK, COLOR_RED);
++	init_pair(PAIR_OTHERS, COLOR_RED, bg);
++	init_pair(PAIR_FRAMES, COLOR_WHITE, bg);
++	attrset(COLOR_PAIR(PAIR_OTHERS));
+     }
+ 
+   restart:
+@@ -193,7 +200,7 @@
+ 	older[j] = newer[j] = next[j] = 0;
+ 
+     clear();
+-    drawbox();
++    drawbox(FALSE);
+ 
+     do {
+ 	char buf[30];
+@@ -239,17 +246,17 @@
+ 		}
+ 		if (!s) {
+ 		    if (scrol)
+-			drawbox();
++			drawbox(TRUE);
+ 		    refresh();
+ 		    /*
+ 		     * If we're scrolling, space out the refreshes to fake
+ 		     * movement.  That's 7 frames, or 6 intervals, which would
+ 		     * be 166 msec if we spread it out over a second.  It looks
+-		     * better (but will well on a slow terminal, e.g., less
++		     * better (but will work on a slow terminal, e.g., less
+ 		     * than 9600bd) to squeeze that into a half-second, and use
+ 		     * half of 170 msec to ensure that the program doesn't eat
+ 		     * a lot of time when asking what time it is, at the top of
+-		     * this loop -TD
++		     * this loop -T.Dickey
+ 		     */
+ 		    if (scrol)
+ 			napms(85);
+@@ -263,7 +270,7 @@
+ 	mvaddstr(16, 30, buf);
+ 
+ 	move(6, 0);
+-	drawbox();
++	drawbox(FALSE);
+ 	refresh();
+ 
+ 	/*
+Index: test/ins_wide.c
+Prereq:  1.3 
+--- ncurses-5.4-20040208/test/ins_wide.c	2003-08-09 22:07:23.000000000 +0000
++++ ncurses-5.4-20050319/test/ins_wide.c	2004-11-21 00:25:05.000000000 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * $Id: ins_wide.c,v 1.3 2003/08/09 22:07:23 tom Exp $
++ * $Id: ins_wide.c,v 1.5 2004/11/21 00:25:05 tom Exp $
+  *
+  * Demonstrate the wins_wstr() and wins_wch functions.
+  * Thomas Dickey - 2002/11/23
+@@ -16,27 +16,66 @@
+ 
+ #include <test.priv.h>
+ 
++#if USE_WIDEC_SUPPORT
++
++/* definitions to make it simpler to compare with inserts.c */
++#define InsNStr    ins_nwstr
++#define InsStr     ins_wstr
++#define MvInsNStr  mvins_nwstr
++#define MvInsStr   mvins_wstr
++#define MvWInsNStr mvwins_nwstr
++#define MvWInsStr  mvwins_wstr
++#define WInsNStr   wins_nwstr
++#define WInsStr    wins_wstr
++
+ #define TABSIZE 8
+ 
+-#if USE_WIDEC_SUPPORT
+-static int margin = (2 * TABSIZE) - 1;
++typedef enum {
++    oDefault = 0,
++    oMove = 1,
++    oWindow = 2,
++    oMoveWindow = 3
++} Options;
++
++static bool m_opt = FALSE;
++static bool w_opt = FALSE;
++static int n_opt = -1;
+ 
+ static void
+-legend(WINDOW *win, wchar_t * buffer, int length)
++legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
+ {
++    NCURSES_CONST char *showstate;
++
++    switch (state) {
++    default:
++    case oDefault:
++	showstate = "";
++	break;
++    case oMove:
++	showstate = " (mvXXX)";
++	break;
++    case oWindow:
++	showstate = " (winXXX)";
++	break;
++    case oMoveWindow:
++	showstate = " (mvwinXXX)";
++	break;
++    }
++
+     wmove(win, 0, 0);
+     wprintw(win,
+-	    "The Strings/Chars displays should match.  Enter any characters.\n");
++	    "The Strings/Chars displays should match.  Enter any characters, except:\n");
+     wprintw(win,
+-	    "Use down-arrow or ^N to repeat on the next line, 'q' to exit.\n");
++	    "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
+     wclrtoeol(win);
+-    wprintw(win, "Inserted %d characters <", length);
++    wprintw(win, "Level %d,%s inserted %d characters <", level,
++	    showstate, length);
+     waddwstr(win, buffer);
+     waddstr(win, ">");
+ }
+ 
+ static int
+-ColOf(wchar_t * buffer, int length)
++ColOf(wchar_t *buffer, int length, int margin)
+ {
+     int n;
+     int result;
+@@ -63,7 +102,7 @@
+ 	    result += 2;
+ 	    break;
+ 	default:
+-	    ++result;
++	    result += wcwidth(ch);
+ 	    if (ch < 32)
+ 		++result;
+ 	    break;
+@@ -72,36 +111,126 @@
+     return result;
+ }
+ 
+-int
+-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
++static int
++ConvertCh(chtype source, cchar_t *target)
+ {
+-    cchar_t tmp_cchar;
+     wchar_t tmp_wchar[2];
++
++    tmp_wchar[0] = source;
++    tmp_wchar[1] = 0;
++    if (setcchar(target, tmp_wchar, A_NORMAL, 0, (void *) 0) == ERR) {
++	beep();
++	return FALSE;
++    }
++    return TRUE;
++}
++
++static int
++MvWInsCh(WINDOW *win, int y, int x, chtype ch)
++{
++    int code;
++    cchar_t tmp_cchar;
++
++    if (ConvertCh(ch, &tmp_cchar)) {
++	code = mvwins_wch(win, y, x, &tmp_cchar);
++    } else {
++	code = mvwinsch(win, y, x, ch);
++    }
++    return code;
++}
++
++static int
++MvInsCh(int y, int x, chtype ch)
++{
++    int code;
++    cchar_t tmp_cchar;
++
++    if (ConvertCh(ch, &tmp_cchar)) {
++	code = mvins_wch(y, x, &tmp_cchar);
++    } else {
++	code = mvinsch(y, x, ch);
++    }
++    return code;
++}
++
++static int
++WInsCh(WINDOW *win, chtype ch)
++{
++    int code;
++    cchar_t tmp_cchar;
++
++    if (ConvertCh(ch, &tmp_cchar)) {
++	code = wins_wch(win, &tmp_cchar);
++    } else {
++	code = winsch(win, ch);
++    }
++    return code;
++}
++
++static int
++InsCh(chtype ch)
++{
++    int code;
++    cchar_t tmp_cchar;
++
++    if (ConvertCh(ch, &tmp_cchar)) {
++	code = ins_wch(&tmp_cchar);
++    } else {
++	code = insch(ch);
++    }
++    return code;
++}
++
++#define LEN(n) ((length - (n) > n_opt) ? n_opt : (length - (n)))
++static void
++test_inserts(int level)
++{
++    static bool first = TRUE;
++
+     wint_t ch;
+     int code;
+     int limit;
+     int row = 1;
+     int col;
++    int row2, col2;
+     int length;
+     wchar_t buffer[BUFSIZ];
+-    WINDOW *work;
+-    WINDOW *show;
+-
+-    putenv("TABSIZE=8");
+-    initscr();
+-    (void) cbreak();		/* take input chars one at a time, no wait for \n */
+-    (void) noecho();		/* don't echo input */
+-    keypad(stdscr, TRUE);
++    WINDOW *look = 0;
++    WINDOW *work = 0;
++    WINDOW *show = 0;
++    int margin = (2 * TABSIZE) - 1;
++    Options option = ((m_opt ? oMove : oDefault)
++		      | ((w_opt || (level > 0)) ? oWindow : oDefault));
++
++    if (first) {
++	static char cmd[80];
++	setlocale(LC_ALL, "");
++
++	putenv(strcpy(cmd, "TABSIZE=8"));
++
++	initscr();
++	(void) cbreak();	/* take input chars one at a time, no wait for \n */
++	(void) noecho();	/* don't echo input */
++	keypad(stdscr, TRUE);
++    }
+ 
+     limit = LINES - 5;
+-    work = newwin(limit, COLS, 0, 0);
+-    show = newwin(4, COLS, limit + 1, 0);
++    if (level > 0) {
++	look = newwin(limit, COLS - (2 * (level - 1)), 0, level - 1);
++	work = newwin(limit - 2, COLS - (2 * level), 1, level);
++	show = newwin(4, COLS, limit + 1, 0);
++	box(look, 0, 0);
++	wnoutrefresh(look);
++	limit -= 2;
++    } else {
++	work = stdscr;
++	show = derwin(stdscr, 4, COLS, limit + 1, 0);
++    }
+     keypad(work, TRUE);
+ 
+     for (col = margin + 1; col < COLS; col += TABSIZE)
+ 	mvwvline(work, row, col, '.', limit - 2);
+ 
+-    box(work, 0, 0);
+     mvwvline(work, row, margin, ACS_VLINE, limit - 2);
+     mvwvline(work, row, margin + 1, ACS_VLINE, limit - 2);
+     limit /= 2;
+@@ -111,7 +240,7 @@
+     wnoutrefresh(work);
+ 
+     buffer[length = 0] = '\0';
+-    legend(show, buffer, length);
++    legend(show, level, option, buffer, length);
+     wnoutrefresh(show);
+ 
+     doupdate();
+@@ -128,8 +257,7 @@
+ 
+     while ((code = wget_wch(work, &ch)) != ERR) {
+ 
+-	switch (code) {
+-	case KEY_CODE_YES:
++	if (code == KEY_CODE_YES) {
+ 	    switch (ch) {
+ 	    case KEY_DOWN:
+ 		ch = CTRL('N');
+@@ -141,70 +269,222 @@
+ 		beep();
+ 		continue;
+ 	    }
++	} else if (code == ERR) {
++	    beep();
+ 	    break;
+ 	}
+ 	if (ch == 'q')
+ 	    break;
+ 
+ 	wmove(work, row, margin + 1);
+-	if (ch == CTRL('N')) {
++	switch (ch) {
++	case 'w':
++	    test_inserts(level + 1);
++
++	    touchwin(look);
++	    touchwin(work);
++	    touchwin(show);
++
++	    wnoutrefresh(look);
++	    wnoutrefresh(work);
++	    wnoutrefresh(show);
++
++	    doupdate();
++	    break;
++	case CTRL('N'):
+ 	    if (row < limit) {
+ 		++row;
+ 		/* put the whole string in, all at once */
+-		mvwins_wstr(work, row, margin + 1, buffer);
++		col2 = margin + 1;
++		switch (option) {
++		case oDefault:
++		    if (n_opt > 1) {
++			for (col = 0; col < length; col += n_opt) {
++			    col2 = ColOf(buffer, col, margin);
++			    if (move(row, col2) != ERR) {
++				InsNStr(buffer + col, LEN(col));
++			    }
++			}
++		    } else {
++			if (move(row, col2) != ERR) {
++			    InsStr(buffer);
++			}
++		    }
++		    break;
++		case oMove:
++		    if (n_opt > 1) {
++			for (col = 0; col < length; col += n_opt) {
++			    col2 = ColOf(buffer, col, margin);
++			    MvInsNStr(row, col2, buffer + col, LEN(col));
++			}
++		    } else {
++			MvInsStr(row, col2, buffer);
++		    }
++		    break;
++		case oWindow:
++		    if (n_opt > 1) {
++			for (col = 0; col < length; col += n_opt) {
++			    col2 = ColOf(buffer, col, margin);
++			    if (wmove(work, row, col2) != ERR) {
++				WInsNStr(work, buffer + col, LEN(col));
++			    }
++			}
++		    } else {
++			if (wmove(work, row, col2) != ERR) {
++			    WInsStr(work, buffer);
++			}
++		    }
++		    break;
++		case oMoveWindow:
++		    if (n_opt > 1) {
++			for (col = 0; col < length; col += n_opt) {
++			    col2 = ColOf(buffer, col, margin);
++			    MvWInsNStr(work, row, col2, buffer + col, LEN(col));
++			}
++		    } else {
++			MvWInsStr(work, row, col2, buffer);
++		    }
++		    break;
++		}
+ 
+ 		/* do the corresponding single-character insertion */
++		row2 = limit + row;
+ 		for (col = 0; col < length; ++col) {
+-		    memset(&tmp_cchar, 0, sizeof(tmp_cchar));
+-		    if (setcchar(&tmp_cchar,
+-				 &(buffer[col]),
+-				 A_NORMAL,
+-				 0,
+-				 (void *) 0) != ERR) {
+-			mvwins_wch(work, limit + row, ColOf(buffer, col), &tmp_cchar);
+-		    } else {
+-			beep();	/* even for tabs! */
+-			mvwinsch(work,
+-				 limit + row,
+-				 ColOf(buffer, col), buffer[col]);
++		    col2 = ColOf(buffer, col, margin);
++		    switch (option) {
++		    case oDefault:
++			if (move(row2, col2) != ERR) {
++			    InsCh(buffer[col]);
++			}
++			break;
++		    case oMove:
++			MvInsCh(row2, col2, buffer[col]);
++			break;
++		    case oWindow:
++			if (wmove(work, row2, col2) != ERR) {
++			    WInsCh(work, buffer[col]);
++			}
++			break;
++		    case oMoveWindow:
++			MvWInsCh(work, row2, col2, buffer[col]);
++			break;
+ 		    }
+ 		}
+ 	    } else {
+ 		beep();
+ 	    }
+-	} else {
++	    break;
++	case KEY_BACKSPACE:
++	    ch = '\b';
++	    /* FALLTHRU */
++	default:
+ 	    buffer[length++] = ch;
+ 	    buffer[length] = '\0';
++
+ 	    /* put the string in, one character at a time */
+-	    mvwins_wstr(work,
+-			row,
+-			ColOf(buffer, length - 1), buffer + length - 1);
++	    col = ColOf(buffer, length - 1, margin);
++	    switch (option) {
++	    case oDefault:
++		if (move(row, col) != ERR) {
++		    InsStr(buffer + length - 1);
++		}
++		break;
++	    case oMove:
++		MvInsStr(row, col, buffer + length - 1);
++		break;
++	    case oWindow:
++		if (wmove(work, row, col) != ERR) {
++		    WInsStr(work, buffer + length - 1);
++		}
++		break;
++	    case oMoveWindow:
++		MvWInsStr(work, row, col, buffer + length - 1);
++		break;
++	    }
+ 
+ 	    /* do the corresponding single-character insertion */
+-	    tmp_wchar[0] = ch;
+-	    tmp_wchar[1] = 0;
+-	    if (setcchar(&tmp_cchar,
+-			 tmp_wchar,
+-			 A_NORMAL,
+-			 0,
+-			 (void *) 0) != ERR) {
+-		mvwins_wch(work,
+-			   limit + row,
+-			   ColOf(buffer, length - 1), &tmp_cchar);
+-	    } else {
+-		beep();		/* even for tabs! */
+-		mvwinsch(work,
+-			 limit + row,
+-			 ColOf(buffer, length - 1), ch);
++	    switch (option) {
++	    case oDefault:
++		if (move(limit + row, col) != ERR) {
++		    InsCh(ch);
++		}
++		break;
++	    case oMove:
++		MvInsCh(limit + row, col, ch);
++		break;
++	    case oWindow:
++		if (wmove(work, limit + row, col) != ERR) {
++		    WInsCh(work, ch);
++		}
++		break;
++	    case oMoveWindow:
++		MvWInsCh(work, limit + row, col, ch);
++		break;
+ 	    }
++
+ 	    wnoutrefresh(work);
+ 
+-	    legend(show, buffer, length);
++	    legend(show, level, option, buffer, length);
+ 	    wnoutrefresh(show);
+ 
+ 	    doupdate();
++	    break;
++	}
++    }
++    if (level > 0) {
++	delwin(show);
++	delwin(work);
++	delwin(look);
++    }
++}
++
++static void
++usage(void)
++{
++    static const char *tbl[] =
++    {
++	"Usage: inserts [options]"
++	,""
++	,"Options:"
++	,"  -n NUM  limit string-inserts to NUM bytes on ^N replay"
++	,"  -m      perform wmove/move separately from insert-functions"
++	,"  -w      use window-parameter even when stdscr would be implied"
++    };
++    unsigned n;
++    for (n = 0; n < SIZEOF(tbl); ++n)
++	fprintf(stderr, "%s\n", tbl[n]);
++    ExitProgram(EXIT_FAILURE);
++}
++
++int
++main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
++{
++    int ch;
++
++    setlocale(LC_ALL, "");
++
++    while ((ch = getopt(argc, argv, "mn:w")) != EOF) {
++	switch (ch) {
++	case 'm':
++	    m_opt = TRUE;
++	    break;
++	case 'n':
++	    n_opt = atoi(optarg);
++	    if (n_opt == 0)
++		n_opt = -1;
++	    break;
++	case 'w':
++	    w_opt = TRUE;
++	    break;
++	default:
++	    usage();
++	    break;
+ 	}
+     }
++    if (optind < argc)
++	usage();
++
++    test_inserts(0);
+     endwin();
+     ExitProgram(EXIT_SUCCESS);
+ }
+Index: test/inserts.c
+Prereq:  1.5 
+--- ncurses-5.4-20040208/test/inserts.c	2003-08-09 22:07:06.000000000 +0000
++++ ncurses-5.4-20050319/test/inserts.c	2004-11-21 00:23:19.000000000 +0000
+@@ -1,5 +1,5 @@
+ /*
+- * $Id: inserts.c,v 1.5 2003/08/09 22:07:06 tom Exp $
++ * $Id: inserts.c,v 1.12 2004/11/21 00:23:19 tom Exp $
+  *
+  * Demonstrate the winsstr() and winsch functions.
+  * Thomas Dickey - 2002/10/19
+@@ -7,24 +7,66 @@
+ 
+ #include <test.priv.h>
+ 
++#define InsNStr    insnstr
++#define InsStr     insstr
++#define MvInsNStr  mvinsnstr
++#define MvInsStr   mvinsstr
++#define MvWInsNStr mvwinsnstr
++#define MvWInsStr  mvwinsstr
++#define WInsNStr   winsnstr
++#define WInsStr    winsstr
++
++#define InsCh      insch
++#define MvInsCh    mvinsch
++#define MvWInsCh   mvwinsch
++#define WInsCh     winsch
++
+ #define TABSIZE 8
+ 
+-static int margin = (2 * TABSIZE) - 1;
++typedef enum {
++    oDefault = 0,
++    oMove = 1,
++    oWindow = 2,
++    oMoveWindow = 3
++} Options;
++
++static bool m_opt = FALSE;
++static bool w_opt = FALSE;
++static int n_opt = -1;
+ 
+ static void
+-legend(WINDOW *win, char *buffer, int length)
++legend(WINDOW *win, int level, Options state, char *buffer, int length)
+ {
++    NCURSES_CONST char *showstate;
++
++    switch (state) {
++    default:
++    case oDefault:
++	showstate = "";
++	break;
++    case oMove:
++	showstate = " (mvXXX)";
++	break;
++    case oWindow:
++	showstate = " (winXXX)";
++	break;
++    case oMoveWindow:
++	showstate = " (mvwinXXX)";
++	break;
++    }
++
+     wmove(win, 0, 0);
+     wprintw(win,
+-	    "The Strings/Chars displays should match.  Enter any characters.\n");
++	    "The Strings/Chars displays should match.  Enter any characters, except:\n");
+     wprintw(win,
+-	    "Use down-arrow or ^N to repeat on the next line, 'q' to exit.\n");
++	    "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
+     wclrtoeol(win);
+-    wprintw(win, "Inserted %d characters <%s>", length, buffer);
++    wprintw(win, "Level %d,%s inserted %d characters <%s>", level,
++	    showstate, length, buffer);
+ }
+ 
+ static int
+-ColOf(char *buffer, int length)
++ColOf(char *buffer, int length, int margin)
+ {
+     int n;
+     int result;
+@@ -60,33 +102,55 @@
+     return result;
+ }
+ 
+-int
+-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
++#define LEN(n) ((length - (n) > n_opt) ? n_opt : (length - (n)))
++static void
++test_inserts(int level)
+ {
++    static bool first = TRUE;
++
+     int ch;
+     int limit;
+     int row = 1;
+     int col;
++    int row2, col2;
+     int length;
+     char buffer[BUFSIZ];
+-    WINDOW *work;
+-    WINDOW *show;
+-
+-    putenv("TABSIZE=8");
+-    initscr();
+-    (void) cbreak();		/* take input chars one at a time, no wait for \n */
+-    (void) noecho();		/* don't echo input */
+-    keypad(stdscr, TRUE);
++    WINDOW *look = 0;
++    WINDOW *work = 0;
++    WINDOW *show = 0;
++    int margin = (2 * TABSIZE) - 1;
++    Options option = ((m_opt ? oMove : oDefault)
++		      | ((w_opt || (level > 0)) ? oWindow : oDefault));
++
++    if (first) {
++	static char cmd[80];
++	setlocale(LC_ALL, "");
++
++	putenv(strcpy(cmd, "TABSIZE=8"));
++
++	initscr();
++	(void) cbreak();	/* take input chars one at a time, no wait for \n */
++	(void) noecho();	/* don't echo input */
++	keypad(stdscr, TRUE);
++    }
+ 
+     limit = LINES - 5;
+-    work = newwin(limit, COLS, 0, 0);
+-    show = newwin(4, COLS, limit + 1, 0);
++    if (level > 0) {
++	look = newwin(limit, COLS - (2 * (level - 1)), 0, level - 1);
++	work = newwin(limit - 2, COLS - (2 * level), 1, level);
++	show = newwin(4, COLS, limit + 1, 0);
++	box(look, 0, 0);
++	wnoutrefresh(look);
++	limit -= 2;
++    } else {
++	work = stdscr;
++	show = derwin(stdscr, 4, COLS, limit + 1, 0);
++    }
+     keypad(work, TRUE);
+ 
+     for (col = margin + 1; col < COLS; col += TABSIZE)
+ 	mvwvline(work, row, col, '.', limit - 2);
+ 
+-    box(work, 0, 0);
+     mvwvline(work, row, margin, ACS_VLINE, limit - 2);
+     mvwvline(work, row, margin + 1, ACS_VLINE, limit - 2);
+     limit /= 2;
+@@ -96,7 +160,7 @@
+     wnoutrefresh(work);
+ 
+     buffer[length = 0] = '\0';
+-    legend(show, buffer, length);
++    legend(show, level, option, buffer, length);
+     wnoutrefresh(show);
+ 
+     doupdate();
+@@ -112,18 +176,104 @@
+     }
+ 
+     while ((ch = wgetch(work)) != 'q') {
++	if (ch == ERR) {
++	    beep();
++	    break;
++	}
+ 	wmove(work, row, margin + 1);
+ 	switch (ch) {
++	case 'w':
++	    test_inserts(level + 1);
++
++	    touchwin(look);
++	    touchwin(work);
++	    touchwin(show);
++
++	    wnoutrefresh(look);
++	    wnoutrefresh(work);
++	    wnoutrefresh(show);
++
++	    doupdate();
++	    break;
+ 	case CTRL('N'):
+ 	case KEY_DOWN:
+ 	    if (row < limit) {
+ 		++row;
+ 		/* put the whole string in, all at once */
+-		mvwinsstr(work, row, margin + 1, buffer);
++		col2 = margin + 1;
++		switch (option) {
++		case oDefault:
++		    if (n_opt > 1) {
++			for (col = 0; col < length; col += n_opt) {
++			    col2 = ColOf(buffer, col, margin);
++			    if (move(row, col2) != ERR) {
++				InsNStr(buffer + col, LEN(col));
++			    }
++			}
++		    } else {
++			if (move(row, col2) != ERR) {
++			    InsStr(buffer);
++			}
++		    }
++		    break;
++		case oMove:
++		    if (n_opt > 1) {
++			for (col = 0; col < length; col += n_opt) {
++			    col2 = ColOf(buffer, col, margin);
++			    MvInsNStr(row, col2, buffer + col, LEN(col));
++			}
++		    } else {
++			MvInsStr(row, col2, buffer);
++		    }
++		    break;
++		case oWindow:
++		    if (n_opt > 1) {
++			for (col = 0; col < length; col += n_opt) {
++			    col2 = ColOf(buffer, col, margin);
++			    if (wmove(work, row, col2) != ERR) {
++				WInsNStr(work, buffer + col, LEN(col));
++			    }
++			}
++		    } else {
++			if (wmove(work, row, col2) != ERR) {
++			    WInsStr(work, buffer);
++			}
++		    }
++		    break;
++		case oMoveWindow:
++		    if (n_opt > 1) {
++			for (col = 0; col < length; col += n_opt) {
++			    col2 = ColOf(buffer, col, margin);
++			    MvWInsNStr(work, row, col2, buffer + col, LEN(col));
++			}
++		    } else {
++			MvWInsStr(work, row, col2, buffer);
++		    }
++		    break;
++		}
+ 
+ 		/* do the corresponding single-character insertion */
++		row2 = limit + row;
+ 		for (col = 0; col < length; ++col) {
+-		    mvwinsch(work, limit + row, ColOf(buffer, col), buffer[col]);
++		    col2 = ColOf(buffer, col, margin);
++		    switch (option) {
++		    case oDefault:
++			if (move(row2, col2) != ERR) {
++			    InsCh(buffer[col]);
++			}
++			break;
++		    case oMove:
++			MvInsCh(row2, col2, buffer[col]);
++			break;
++		    case oWindow:
++			if (wmove(work, row2, col2) != ERR) {
++			    WInsCh(work, buffer[col]);
++			}
++			break;
++		    case oMoveWindow:
++			MvWInsCh(work, row2, col2, buffer[col]);
++			break;
++		    }
+ 		}
+ 	    } else {
+ 		beep();
+@@ -139,24 +289,111 @@
+ 	    }
+ 	    buffer[length++] = ch;
+ 	    buffer[length] = '\0';
++
+ 	    /* put the string in, one character at a time */
+-	    mvwinsstr(work,
+-		      row,
+-		      ColOf(buffer, length - 1), buffer + length - 1);
++	    col = ColOf(buffer, length - 1, margin);
++	    switch (option) {
++	    case oDefault:
++		if (move(row, col) != ERR) {
++		    InsStr(buffer + length - 1);
++		}
++		break;
++	    case oMove:
++		MvInsStr(row, col, buffer + length - 1);
++		break;
++	    case oWindow:
++		if (wmove(work, row, col) != ERR) {
++		    WInsStr(work, buffer + length - 1);
++		}
++		break;
++	    case oMoveWindow:
++		MvWInsStr(work, row, col, buffer + length - 1);
++		break;
++	    }
+ 
+ 	    /* do the corresponding single-character insertion */
+-	    mvwinsch(work,
+-		     limit + row,
+-		     ColOf(buffer, length - 1), ch);
++	    switch (option) {
++	    case oDefault:
++		if (move(limit + row, col) != ERR) {
++		    InsCh(ch);
++		}
++		break;
++	    case oMove:
++		MvInsCh(limit + row, col, ch);
++		break;
++	    case oWindow:
++		if (wmove(work, limit + row, col) != ERR) {
++		    WInsCh(work, ch);
++		}
++		break;
++	    case oMoveWindow:
++		MvWInsCh(work, limit + row, col, ch);
++		break;
++	    }
++
+ 	    wnoutrefresh(work);
+ 
+-	    legend(show, buffer, length);
++	    legend(show, level, option, buffer, length);
+ 	    wnoutrefresh(show);
+ 
+ 	    doupdate();
+ 	    break;
+ 	}
+     }
++    if (level > 0) {
++	delwin(show);
++	delwin(work);
++	delwin(look);
++    }
++}
++
++static void
++usage(void)
++{
++    static const char *tbl[] =
++    {
++	"Usage: inserts [options]"
++	,""
++	,"Options:"
++	,"  -n NUM  limit string-inserts to NUM bytes on ^N replay"
++	,"  -m      perform wmove/move separately from insert-functions"
++	,"  -w      use window-parameter even when stdscr would be implied"
++    };
++    unsigned n;
++    for (n = 0; n < SIZEOF(tbl); ++n)
++	fprintf(stderr, "%s\n", tbl[n]);
++    ExitProgram(EXIT_FAILURE);
++}
++
++int
++main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
++{
++    int ch;
++
++    setlocale(LC_ALL, "");
++
++    while ((ch = getopt(argc, argv, "mn:w")) != EOF) {
++	switch (ch) {
++	case 'm':
++	    m_opt = TRUE;
++	    break;
++	case 'n':
++	    n_opt = atoi(optarg);
++	    if (n_opt == 0)
++		n_opt = -1;
++	    break;
++	case 'w':
++	    w_opt = TRUE;
++	    break;
++	default:
++	    usage();
++	    break;
++	}
++    }
++    if (optind < argc)
++	usage();
++
++    test_inserts(0);
+     endwin();
+     ExitProgram(EXIT_SUCCESS);
+ }
+Index: test/linux-color.dat
+--- /dev/null	2004-09-12 00:40:36.000000000 +0000
++++ ncurses-5.4-20050319/test/linux-color.dat	2004-05-22 23:42:45.000000000 +0000
+@@ -0,0 +1,21 @@
++# $Id: linux-color.dat,v 1.1 2004/05/22 23:42:45 tom Exp $
++# These values are derived from linux/drivers/char/vt.c (default_red[],
++# default_grn[] and default_blu[]), commented
++/* the default colour table, for VGA+ colour systems */
++scale:255
++0:	  0	  0	  0
++1:	170	  0	  0
++2:	  0	170	  0
++3:	170	 85	  0
++4:	  0	  0	170
++5:	170	  0	170
++6:	  0	170	170
++7:	170	170	170
++8:	 85	 85	 85
++9:	255	 85	 85
++10:	 85	255	 85
++11:	255	255	 85
++12:	 85	 85	255
++13:	255	 85	255
++14:	 85	255	255
++15:	255	255	255
+Index: test/lrtest.c
+Prereq:  1.19 
+--- ncurses-5.4-20040208/test/lrtest.c	2002-07-13 16:55:50.000000000 +0000
++++ ncurses-5.4-20050319/test/lrtest.c	2004-08-07 16:08:01.000000000 +0000
+@@ -2,12 +2,12 @@
+  * Test lower-right-hand corner access
+  *
+  * originally by Eric S. Raymond <esr@thyrsus.com>, written for animation
+- * and resizing -TD
++ * and resizing -T.Dickey
+  *
+  * This can't be part of the ncurses test-program, because ncurses rips off the
+  * bottom line to do labels.
+  *
+- * $Id: lrtest.c,v 1.19 2002/07/13 16:55:50 tom Exp $
++ * $Id: lrtest.c,v 1.20 2004/08/07 16:08:01 tom Exp $
+  */
+ 
+ #include <test.priv.h>
+@@ -22,7 +22,7 @@
+  * really write to all positions properly.
+  */
+ static void
+-show(MARK * m)
++show(MARK *m)
+ {
+     mvaddch(m->y, m->x, m->value);
+     if (m->mode == 0) {		/* along the x-direction */
+@@ -120,7 +120,7 @@
+ 	    else if (ch == 'T')
+ 		trace(0);
+ 	    else if (ch == 't')
+-		trace(TRACE_CALLS|TRACE_ICALLS|TRACE_UPDATE);
++		trace(TRACE_CALLS | TRACE_ICALLS | TRACE_UPDATE);
+ #endif
+ #ifdef KEY_RESIZE
+ 	    else if (ch == KEY_RESIZE) {
+Index: test/ncurses.c
+Prereq:  1.202 
+--- ncurses-5.4-20040208/test/ncurses.c	2004-02-07 20:24:08.000000000 +0000
++++ ncurses-5.4-20050319/test/ncurses.c	2005-03-19 23:21:46.000000000 +0000
+@@ -1,5 +1,5 @@
+ /****************************************************************************
+- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
++ * Copyright (c) 1998-2004,2005 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: Eric S. Raymond <esr@snark.thyrsus.com> 1993
+            Thomas E. Dickey (beginning revision 1.27 in 1996).
+ 
+-$Id: ncurses.c,v 1.202 2004/02/07 20:24:08 tom Exp $
++$Id: ncurses.c,v 1.245 2005/03/19 23:21:46 tom Exp $
+ 
+ ***************************************************************************/
+ 
+@@ -114,10 +114,21 @@
+ 
+ #undef max_colors
+ static int max_colors;		/* the actual number of colors we'll use */
++static int min_colors;		/* the minimum color code */
+ 
+ #undef max_pairs
+ static int max_pairs;		/* ...and the number of color pairs */
+ 
++typedef struct {
++    short red;
++    short green;
++    short blue;
++} RGB_DATA;
++
++static RGB_DATA *all_colors;
++
++static void main_menu(bool);
++
+ /* The behavior of mvhline, mvvline for negative/zero length is unspecified,
+  * though we can rely on negative x/y values to stop the macro.
+  */
+@@ -232,7 +243,7 @@
+ 
+ #if USE_WIDEC_SUPPORT
+ static int
+-wGet_wchar(WINDOW *win, wint_t * result)
++wGet_wchar(WINDOW *win, wint_t *result)
+ {
+     int c;
+ #ifdef TRACE
+@@ -257,11 +268,12 @@
+ 
+ /* replaces wgetn_wstr(), since we want to be able to edit values */
+ static void
+-wGet_wstring(WINDOW *win, wchar_t * buffer, int limit)
++wGet_wstring(WINDOW *win, wchar_t *buffer, int limit)
+ {
+     int y0, x0, x;
+     wint_t ch;
+     bool done = FALSE;
++    bool fkey = FALSE;
+ 
+     echo();
+     getyx(win, y0, x0);
+@@ -271,32 +283,46 @@
+     while (!done) {
+ 	if (x > (int) wcslen(buffer))
+ 	    x = (int) wcslen(buffer);
++
++	/* clear the "window' */
++	wmove(win, y0, x0);
++	wprintw(win, "%*s", limit, " ");
++
++	/* write the existing buffer contents */
+ 	wmove(win, y0, x0);
+ 	waddnwstr(win, buffer, limit);
+-	if (x < limit)
+-	    wprintw(win, "%*s", limit - x, " ");
+-	wmove(win, y0, x0 + x);
++
++	/* positions the cursor past character 'x' */
++	wmove(win, y0, x0);
++	waddnwstr(win, buffer, x);
++
+ 	switch (wGet_wchar(win, &ch)) {
+ 	case KEY_CODE_YES:
++	    fkey = TRUE;
+ 	    switch (ch) {
+ 	    case KEY_ENTER:
+ 		ch = '\n';
++		fkey = FALSE;
+ 		break;
+ 	    case KEY_BACKSPACE:
+ 	    case KEY_DC:
+ 		ch = '\b';
++		fkey = FALSE;
+ 		break;
+ 	    case KEY_LEFT:
+ 	    case KEY_RIGHT:
+ 		break;
+ 	    default:
+-		ch = (wint_t) - 1;
++		ch = (wint_t) -1;
+ 		break;
+ 	    }
++	    break;
+ 	case OK:
++	    fkey = FALSE;
+ 	    break;
+ 	default:
+-	    ch = (wint_t) - 1;
++	    ch = (wint_t) -1;
++	    fkey = TRUE;
+ 	    break;
+ 	}
+ 
+@@ -321,14 +347,14 @@
+ 	    if (x > 0) {
+ 		--x;
+ 	    } else {
+-		flash();
++		beep();
+ 	    }
+ 	    break;
+ 	case KEY_RIGHT:
+ 	    ++x;
+ 	    break;
+ 	default:
+-	    if (!isprint(ch) || ch >= KEY_MIN) {
++	    if (fkey) {
+ 		beep();
+ 	    } else if ((int) wcslen(buffer) < limit) {
+ 		int j;
+@@ -337,7 +363,7 @@
+ 		}
+ 		buffer[x++] = ch;
+ 	    } else {
+-		flash();
++		beep();
+ 	    }
+ 	}
+     }
+@@ -387,35 +413,57 @@
+ 		   ep->id, ep->x, ep->y, ep->z, ep->bstate);
+ 
+ #define SHOW(m, s) if ((ep->bstate & m)==m) {strcat(buf,s); strcat(buf, ", ");}
++
+     SHOW(BUTTON1_RELEASED, "release-1");
+     SHOW(BUTTON1_PRESSED, "press-1");
+     SHOW(BUTTON1_CLICKED, "click-1");
+     SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1");
+     SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1");
++#if NCURSES_MOUSE_VERSION == 1
+     SHOW(BUTTON1_RESERVED_EVENT, "reserved-1");
++#endif
++
+     SHOW(BUTTON2_RELEASED, "release-2");
+     SHOW(BUTTON2_PRESSED, "press-2");
+     SHOW(BUTTON2_CLICKED, "click-2");
+     SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2");
+     SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2");
++#if NCURSES_MOUSE_VERSION == 1
+     SHOW(BUTTON2_RESERVED_EVENT, "reserved-2");
++#endif
++
+     SHOW(BUTTON3_RELEASED, "release-3");
+     SHOW(BUTTON3_PRESSED, "press-3");
+     SHOW(BUTTON3_CLICKED, "click-3");
+     SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3");
+     SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3");
++#if NCURSES_MOUSE_VERSION == 1
+     SHOW(BUTTON3_RESERVED_EVENT, "reserved-3");
++#endif
++
+     SHOW(BUTTON4_RELEASED, "release-4");
+     SHOW(BUTTON4_PRESSED, "press-4");
+     SHOW(BUTTON4_CLICKED, "click-4");
+     SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4");
+     SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4");
++#if NCURSES_MOUSE_VERSION == 1
+     SHOW(BUTTON4_RESERVED_EVENT, "reserved-4");
++#endif
++
++#if NCURSES_MOUSE_VERSION == 2
++    SHOW(BUTTON5_RELEASED, "release-5");
++    SHOW(BUTTON5_PRESSED, "press-5");
++    SHOW(BUTTON5_CLICKED, "click-5");
++    SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5");
++    SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5");
++#endif
++
+     SHOW(BUTTON_CTRL, "ctrl");
+     SHOW(BUTTON_SHIFT, "shift");
+     SHOW(BUTTON_ALT, "alt");
+     SHOW(ALL_MOUSE_EVENTS, "all-events");
+     SHOW(REPORT_MOUSE_POSITION, "position");
++
+ #undef SHOW
+ 
+     if (buf[strlen(buf) - 1] == ' ')
+@@ -785,7 +833,7 @@
+ #endif /* KEY_RESIZE */
+ 
+ static char *
+-wcstos(const wchar_t * src)
++wcstos(const wchar_t *src)
+ {
+     int need;
+     mbstate_t state;
+@@ -807,7 +855,8 @@
+ static void
+ wget_wch_test(int level, WINDOW *win, int delay)
+ {
+-    wchar_t buf[BUFSIZ];
++    wchar_t wchar_buf[BUFSIZ];
++    wint_t wint_buf[BUFSIZ];
+     int first_y, first_x;
+     wint_t c;
+     int incount = 0;
+@@ -850,13 +899,21 @@
+ 	} else if (c == 'g') {
+ 	    waddstr(win, "getstr test: ");
+ 	    echo();
+-	    wgetn_wstr(win, (wint_t *) buf, sizeof(buf) - 1);
++	    code = wgetn_wstr(win, wint_buf, sizeof(wint_buf) - 1);
+ 	    noecho();
+-	    if ((temp = wcstos(buf)) != 0) {
+-		wprintw(win, "I saw %d characters:\n\t`%s'.", wcslen(buf), temp);
+-		free(temp);
++	    if (code == ERR) {
++		wprintw(win, "wgetn_wstr returns an error.");
+ 	    } else {
+-		wprintw(win, "I saw %d characters (cannot convert).", wcslen(buf));
++		int n;
++		for (n = 0; (wchar_buf[n] = wint_buf[n]) != 0; ++n) ;
++		if ((temp = wcstos(wchar_buf)) != 0) {
++		    wprintw(win, "I saw %d characters:\n\t`%s'.",
++			    wcslen(wchar_buf), temp);
++		    free(temp);
++		} else {
++		    wprintw(win, "I saw %d characters (cannot convert).",
++			    wcslen(wchar_buf));
++		}
+ 	    }
+ 	    wclrtoeol(win);
+ 	    wgetch_wrap(win, first_y);
+@@ -954,7 +1011,99 @@
+ #define MAX_ATTRSTRING 31
+ #define LEN_ATTRSTRING 26
+ 
+-static char attr_test_string[] = "abcde fghij klmno pqrst uvwxy z";
++static char attr_test_string[MAX_ATTRSTRING + 1];
++
++static void
++attr_legend(WINDOW *helpwin)
++{
++    int row = 1;
++    int col = 1;
++
++    mvwprintw(helpwin, row++, col,
++	      "q or ESC to exit.");
++    mvwprintw(helpwin, row++, col,
++	      "^L repaints.");
++    ++row;
++    mvwprintw(helpwin, row++, col,
++	      "Modify the test strings:");
++    mvwprintw(helpwin, row++, col,
++	      "  A digit sets gaps on each side of displayed attributes");
++    mvwprintw(helpwin, row++, col,
++	      "  </> shifts the text left/right. ");
++    ++row;
++    mvwprintw(helpwin, row++, col,
++	      "Toggles:");
++    if (has_colors()) {
++	mvwprintw(helpwin, row++, col,
++		  "  f/F/b/F toggle foreground/background background color");
++	mvwprintw(helpwin, row++, col,
++		  "  t/T     toggle text/background color attribute");
++    }
++    mvwprintw(helpwin, row++, col,
++	      "  a/A     toggle ACS (alternate character set) mapping");
++    mvwprintw(helpwin, row++, col,
++	      "  v/V     toggle video attribute to combine with each line");
++}
++
++static void
++show_color_attr(int fg, int bg, int tx)
++{
++    if (has_colors()) {
++	printw("  Colors (fg %d, bg %d", fg, bg);
++	if (tx >= 0)
++	    printw(", text %d", tx);
++	printw("),");
++    }
++}
++
++static bool
++cycle_color_attr(int ch, int *fg, int *bg, int *tx)
++{
++    bool error = FALSE;
++
++    if (has_colors()) {
++	switch (ch) {
++	case 'f':
++	    *fg = (*fg + 1);
++	    break;
++	case 'F':
++	    *fg = (*fg - 1);
++	    break;
++	case 'b':
++	    *bg = (*bg + 1);
++	    break;
++	case 'B':
++	    *bg = (*bg - 1);
++	    break;
++	case 't':
++	    *tx = (*tx + 1);
++	    break;
++	case 'T':
++	    *tx = (*tx - 1);
++	    break;
++	default:
++	    beep();
++	    error = TRUE;
++	    break;
++	}
++	if (*fg >= COLORS)
++	    *fg = min_colors;
++	if (*fg < min_colors)
++	    *fg = COLORS - 1;
++	if (*bg >= COLORS)
++	    *bg = min_colors;
++	if (*bg < min_colors)
++	    *bg = COLORS - 1;
++	if (*tx >= COLORS)
++	    *tx = -1;
++	if (*tx < -1)
++	    *tx = COLORS - 1;
++    } else {
++	beep();
++	error = TRUE;
++    }
++    return error;
++}
+ 
+ static void
+ adjust_attr_string(int adjust)
+@@ -964,7 +1113,7 @@
+ 
+     if (first >= ' ' && last <= '~') {	/* 32..126 */
+ 	int j, k;
+-	for (j = 0, k = first; k <= last; ++j, ++k) {
++	for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
+ 	    attr_test_string[j] = k;
+ 	    if (((k + 1 - first) % 5) == 0) {
+ 		++j;
+@@ -980,132 +1129,160 @@
+     }
+ }
+ 
++static void
++init_attr_string(void)
++{
++    attr_test_string[0] = 'a';
++    adjust_attr_string(0);
++}
++
+ static int
+-show_attr(int row, int skip, chtype attr, const char *name)
++show_attr(int row, int skip, bool arrow, chtype attr, const char *name)
+ {
+     int ncv = tigetnum("ncv");
+     chtype test = attr & ~A_ALTCHARSET;
+ 
++    if (arrow)
++	mvprintw(row, 5, "-->");
+     mvprintw(row, 8, "%s mode:", name);
+     mvprintw(row, 24, "|");
+     if (skip)
+ 	printw("%*s", skip, " ");
+-    attrset(attr);
+     /*
+-     * If we're to write a string in the alternate character set, it is not
+-     * sufficient to just set A_ALTCHARSET.  We have to perform the mapping
+-     * that corresponds.  This is not needed for vt100-compatible devices
+-     * because the acs_map[] is 1:1, but for PC-style devices such as Linux
+-     * console, the acs_map[] is scattered about the range.
+-     *
+-     * The addch/addstr functions do not themselves do this mapping, since it
+-     * is possible to turn off the A_ALTCHARSET flag for the characters which
+-     * are added, and it would be an unexpected result to have the mapped
+-     * characters visible on the screen.
++     * Just for testing, write text using the alternate character set one
++     * character at a time (to pass its rendition directly), and use the
++     * string operation for the other attributes.
+      */
+     if (attr & A_ALTCHARSET) {
+ 	const char *s;
+-	int ch;
++	chtype ch;
+ 
+ 	for (s = attr_test_string; *s != '\0'; ++s) {
+ 	    ch = UChar(*s);
+-	    addch(ch);
++	    addch(ch | attr);
+ 	}
+     } else {
++	attrset(attr);
+ 	addstr(attr_test_string);
++	attroff(attr);
+     }
+-    attroff(attr);
+     if (skip)
+ 	printw("%*s", skip, " ");
+     printw("|");
+     if (test != A_NORMAL) {
+ 	if (!(termattrs() & test)) {
+ 	    printw(" (N/A)");
+-	} else if (ncv > 0 && (getbkgd(stdscr) & A_COLOR)) {
+-	    static const chtype table[] =
+-	    {
+-		A_STANDOUT,
+-		A_UNDERLINE,
+-		A_REVERSE,
+-		A_BLINK,
+-		A_DIM,
+-		A_BOLD,
+-		A_INVIS,
+-		A_PROTECT,
+-		A_ALTCHARSET
+-	    };
+-	    unsigned n;
+-	    bool found = FALSE;
+-	    for (n = 0; n < SIZEOF(table); n++) {
+-		if ((table[n] & attr) != 0
+-		    && ((1 << n) & ncv) != 0) {
+-		    found = TRUE;
+-		    break;
++	} else {
++	    if (ncv > 0 && (getbkgd(stdscr) & A_COLOR)) {
++		static const chtype table[] =
++		{
++		    A_STANDOUT,
++		    A_UNDERLINE,
++		    A_REVERSE,
++		    A_BLINK,
++		    A_DIM,
++		    A_BOLD,
++		    A_INVIS,
++		    A_PROTECT,
++		    A_ALTCHARSET
++		};
++		unsigned n;
++		bool found = FALSE;
++		for (n = 0; n < SIZEOF(table); n++) {
++		    if ((table[n] & attr) != 0
++			&& ((1 << n) & ncv) != 0) {
++			found = TRUE;
++			break;
++		    }
+ 		}
++		if (found)
++		    printw(" (NCV)");
+ 	    }
+-	    if (found)
+-		printw(" (NCV)");
++	    if ((termattrs() & test) != test)
++		printw(" (Part)");
+ 	}
+     }
+     return row + 2;
+ }
++/* *INDENT-OFF* */
++static const struct {
++    attr_t			attr;
++    NCURSES_CONST char *	name;
++} attrs_to_test[] = {
++    { A_STANDOUT,	"STANDOUT" },
++    { A_REVERSE,	"REVERSE" },
++    { A_BOLD,		"BOLD" },
++    { A_UNDERLINE,	"UNDERLINE" },
++    { A_DIM,		"DIM" },
++    { A_BLINK,		"BLINK" },
++    { A_PROTECT,	"PROTECT" },
++    { A_INVIS,		"INVISIBLE" },
++    { A_NORMAL,		"NORMAL" },
++};
++/* *INDENT-ON* */
+ 
+ static bool
+-attr_getc(int *skip, int *fg, int *bg, int *ac)
++attr_getc(int *skip, int *fg, int *bg, int *tx, int *ac, unsigned *kc)
+ {
+-    int ch = Getchar();
++    bool result = TRUE;
++    bool error = FALSE;
++    WINDOW *helpwin;
+ 
+-    if (isdigit(ch)) {
+-	*skip = (ch - '0');
+-    } else if (ch == CTRL('L')) {
+-	touchwin(stdscr);
+-	touchwin(curscr);
+-	wrefresh(curscr);
+-    } else {
+-	switch (ch) {
+-	case 'a':
+-	    *ac = 0;
+-	    break;
+-	case 'A':
+-	    *ac = A_ALTCHARSET;
+-	    break;
+-	case '<':
+-	    adjust_attr_string(-1);
+-	    break;
+-	case '>':
+-	    adjust_attr_string(1);
+-	    break;
+-	default:
+-	    if (has_colors()) {
+-		switch (ch) {
+-		case 'f':
+-		    *fg = (*fg + 1);
+-		    break;
+-		case 'F':
+-		    *fg = (*fg - 1);
+-		    break;
+-		case 'b':
+-		    *bg = (*bg + 1);
+-		    break;
+-		case 'B':
+-		    *bg = (*bg - 1);
+-		    break;
+-		default:
+-		    return FALSE;
++    do {
++	int ch = Getchar();
++
++	error = FALSE;
++	if (ch < 256 && isdigit(ch)) {
++	    *skip = (ch - '0');
++	} else {
++	    switch (ch) {
++	    case CTRL('L'):
++		touchwin(stdscr);
++		touchwin(curscr);
++		wrefresh(curscr);
++		break;
++	    case '?':
++		if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
++		    box(helpwin, 0, 0);
++		    attr_legend(helpwin);
++		    wGetchar(helpwin);
++		    delwin(helpwin);
+ 		}
+-		if (*fg >= max_colors)
+-		    *fg = 0;
+-		if (*fg < 0)
+-		    *fg = max_colors - 1;
+-		if (*bg >= max_colors)
+-		    *bg = 0;
+-		if (*bg < 0)
+-		    *bg = max_colors - 1;
++		break;
++	    case 'a':
++		*ac = 0;
++		break;
++	    case 'A':
++		*ac = A_ALTCHARSET;
++		break;
++	    case 'v':
++		if (*kc == 0)
++		    *kc = SIZEOF(attrs_to_test) - 1;
++		else
++		    *kc -= 1;
++		break;
++	    case 'V':
++		*kc += 1;
++		if (*kc >= SIZEOF(attrs_to_test))
++		    *kc = 0;
++		break;
++	    case '<':
++		adjust_attr_string(-1);
++		break;
++	    case '>':
++		adjust_attr_string(1);
++		break;
++	    case 'q':
++	    case ESCAPE:
++		result = FALSE;
++		break;
++	    default:
++		error = cycle_color_attr(ch, fg, bg, tx);
++		break;
+ 	    }
+-	    break;
+ 	}
+-    }
+-    return TRUE;
++    } while (error);
++    return result;
+ }
+ 
+ static void
+@@ -1116,26 +1293,40 @@
+     int skip = tigetnum("xmc");
+     int fg = COLOR_BLACK;	/* color pair 0 is special */
+     int bg = COLOR_BLACK;
++    int tx = -1;
+     int ac = 0;
+-    bool *pairs = (bool *) calloc(max_pairs, sizeof(bool));
+-    pairs[0] = TRUE;
++    unsigned j, k;
+ 
+     if (skip < 0)
+ 	skip = 0;
+ 
+     n = skip;			/* make it easy */
++    k = SIZEOF(attrs_to_test) - 1;
++    init_attr_string();
+ 
+     do {
+ 	int row = 2;
+-	int normal = A_NORMAL | BLANK;
++	chtype normal = A_NORMAL | BLANK;
++	chtype extras = ac;
+ 
+ 	if (has_colors()) {
+-	    int pair = (fg * max_colors) + bg;
+-	    if (!pairs[pair]) {
+-		init_pair(pair, fg, bg);
+-		pairs[pair] = TRUE;
++	    int pair = (fg != COLOR_BLACK || bg != COLOR_BLACK);
++	    if (pair != 0) {
++		pair = 1;
++		if (init_pair(pair, fg, bg) == ERR) {
++		    beep();
++		} else {
++		    normal |= COLOR_PAIR(pair);
++		}
++	    }
++	    if (tx >= 0) {
++		pair = 2;
++		if (init_pair(pair, tx, bg) == ERR) {
++		    beep();
++		} else {
++		    extras |= COLOR_PAIR(pair);
++		}
+ 	    }
+-	    normal |= COLOR_PAIR(pair);
+ 	}
+ 	bkgd(normal);
+ 	bkgdset(normal);
+@@ -1144,38 +1335,305 @@
+ 	box(stdscr, 0, 0);
+ 	mvaddstr(0, 20, "Character attribute test display");
+ 
+-	row = show_attr(row, n, ac | A_STANDOUT, "STANDOUT");
+-	row = show_attr(row, n, ac | A_REVERSE, "REVERSE");
+-	row = show_attr(row, n, ac | A_BOLD, "BOLD");
+-	row = show_attr(row, n, ac | A_UNDERLINE, "UNDERLINE");
+-	row = show_attr(row, n, ac | A_DIM, "DIM");
+-	row = show_attr(row, n, ac | A_BLINK, "BLINK");
+-	row = show_attr(row, n, ac | A_PROTECT, "PROTECT");
+-	row = show_attr(row, n, ac | A_INVIS, "INVISIBLE");
+-	row = show_attr(row, n, ac | A_NORMAL, "NORMAL");
++	for (j = 0; j < SIZEOF(attrs_to_test); ++j) {
++	    row = show_attr(row, n, j == k,
++			    extras |
++			    attrs_to_test[j].attr |
++			    attrs_to_test[k].attr,
++			    attrs_to_test[j].name);
++	}
+ 
+ 	mvprintw(row, 8,
+ 		 "This terminal does %shave the magic-cookie glitch",
+ 		 tigetnum("xmc") > -1 ? "" : "not ");
+-	mvprintw(row + 1, 8,
+-		 "Enter a digit to set gaps on each side of displayed attributes");
+-	mvprintw(row + 2, 8,
+-		 "^L repaints, </> shifts, ");
+-	if (has_colors())
+-	    printw("f/F/b/F toggle color (now %d/%d), a/A ACS (%d)",
+-		   fg, bg, ac != 0);
+-	else
+-	    printw("a/A ACS (%d)", ac != 0);
++	mvprintw(row + 1, 8, "Enter '?' for help.");
++	show_color_attr(fg, bg, tx);
++	printw("  ACS (%d)", ac != 0);
+ 
+ 	refresh();
+-    } while (attr_getc(&n, &fg, &bg, &ac));
++    } while (attr_getc(&n, &fg, &bg, &tx, &ac, &k));
+ 
+-    free((char *) pairs);
+     bkgdset(A_NORMAL | BLANK);
+     erase();
+     endwin();
+ }
+ 
++#if USE_WIDEC_SUPPORT
++static wchar_t wide_attr_test_string[MAX_ATTRSTRING + 1];
++
++static void
++wide_adjust_attr_string(int adjust)
++{
++    int first = ((int) UChar(wide_attr_test_string[0])) + adjust;
++    int last = first + LEN_ATTRSTRING;
++
++    if (first >= ' ' && last <= '~') {	/* 32..126 */
++	int j, k;
++	for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
++	    wide_attr_test_string[j] = k;
++	    if (((k + 1 - first) % 5) == 0) {
++		++j;
++		if (j < MAX_ATTRSTRING)
++		    wide_attr_test_string[j] = ' ';
++	    }
++	}
++	while (j < MAX_ATTRSTRING)
++	    wide_attr_test_string[j++] = ' ';
++	wide_attr_test_string[j] = '\0';
++    } else {
++	beep();
++    }
++}
++
++static void
++wide_init_attr_string(void)
++{
++    wide_attr_test_string[0] = 'a';
++    wide_adjust_attr_string(0);
++}
++
++static void
++set_wide_background(short pair)
++{
++    cchar_t normal;
++    wchar_t blank[2];
++
++    blank[0] = ' ';
++    blank[1] = 0;
++    setcchar(&normal, blank, A_NORMAL, pair, 0);
++    bkgrnd(&normal);
++    bkgrndset(&normal);
++}
++
++static attr_t
++get_wide_background(void)
++{
++    attr_t result = A_NORMAL;
++    attr_t attr;
++    cchar_t ch;
++    short pair;
++    wchar_t wch;
++
++    if (getbkgrnd(&ch) != ERR) {
++	if (getcchar(&ch, &wch, &attr, &pair, 0) != ERR) {
++	    result = attr;
++	}
++    }
++    return result;
++}
++
++static int
++wide_show_attr(int row, int skip, bool arrow, chtype attr, short pair, const char *name)
++{
++    int ncv = tigetnum("ncv");
++    chtype test = attr & ~WA_ALTCHARSET;
++
++    if (arrow)
++	mvprintw(row, 5, "-->");
++    mvprintw(row, 8, "%s mode:", name);
++    mvprintw(row, 24, "|");
++    if (skip)
++	printw("%*s", skip, " ");
++
++    /*
++     * Just for testing, write text using the alternate character set one
++     * character at a time (to pass its rendition directly), and use the
++     * string operation for the other attributes.
++     */
++    if (attr & WA_ALTCHARSET) {
++	const wchar_t *s;
++	cchar_t ch;
++
++	for (s = wide_attr_test_string; *s != L'\0'; ++s) {
++	    wchar_t fill[2];
++	    fill[0] = *s;
++	    fill[1] = L'\0';
++	    setcchar(&ch, fill, attr, pair, 0);
++	    add_wch(&ch);
++	}
++    } else {
++	attr_t old_attr;
++	short old_pair;
++
++	attr_get(&old_attr, &old_pair, 0);
++	attr_set(attr, pair, 0);
++	addwstr(wide_attr_test_string);
++	attr_set(old_attr, old_pair, 0);
++    }
++    if (skip)
++	printw("%*s", skip, " ");
++    printw("|");
++    if (test != A_NORMAL) {
++	if (!(term_attrs() & test)) {
++	    printw(" (N/A)");
++	} else {
++	    if (ncv > 0 && (get_wide_background() & A_COLOR)) {
++		static const attr_t table[] =
++		{
++		    WA_STANDOUT,
++		    WA_UNDERLINE,
++		    WA_REVERSE,
++		    WA_BLINK,
++		    WA_DIM,
++		    WA_BOLD,
++		    WA_INVIS,
++		    WA_PROTECT,
++		    WA_ALTCHARSET
++		};
++		unsigned n;
++		bool found = FALSE;
++		for (n = 0; n < SIZEOF(table); n++) {
++		    if ((table[n] & attr) != 0
++			&& ((1 << n) & ncv) != 0) {
++			found = TRUE;
++			break;
++		    }
++		}
++		if (found)
++		    printw(" (NCV)");
++	    }
++	    if ((term_attrs() & test) != test)
++		printw(" (Part)");
++	}
++    }
++    return row + 2;
++}
++
++static bool
++wide_attr_getc(int *skip, int *fg, int *bg, int *tx, int *ac, unsigned *kc)
++{
++    bool result = TRUE;
++    bool error = FALSE;
++    WINDOW *helpwin;
++
++    do {
++	int ch = Getchar();
++
++	error = FALSE;
++	if (ch < 256 && isdigit(ch)) {
++	    *skip = (ch - '0');
++	} else {
++	    switch (ch) {
++	    case CTRL('L'):
++		touchwin(stdscr);
++		touchwin(curscr);
++		wrefresh(curscr);
++		break;
++	    case '?':
++		if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
++		    box_set(helpwin, 0, 0);
++		    attr_legend(helpwin);
++		    wGetchar(helpwin);
++		    delwin(helpwin);
++		}
++		break;
++	    case 'a':
++		*ac = 0;
++		break;
++	    case 'A':
++		*ac = A_ALTCHARSET;
++		break;
++	    case 'v':
++		if (*kc == 0)
++		    *kc = SIZEOF(attrs_to_test) - 1;
++		else
++		    *kc -= 1;
++		break;
++	    case 'V':
++		*kc += 1;
++		if (*kc >= SIZEOF(attrs_to_test))
++		    *kc = 0;
++		break;
++	    case '<':
++		wide_adjust_attr_string(-1);
++		break;
++	    case '>':
++		wide_adjust_attr_string(1);
++		break;
++	    case 'q':
++	    case ESCAPE:
++		result = FALSE;
++		break;
++	    default:
++		error = cycle_color_attr(ch, fg, bg, tx);
++		break;
++	    }
++	}
++    } while (error);
++    return result;
++}
++
++static void
++wide_attr_test(void)
++/* test text attributes using wide-character calls */
++{
++    int n;
++    int skip = tigetnum("xmc");
++    int fg = COLOR_BLACK;	/* color pair 0 is special */
++    int bg = COLOR_BLACK;
++    int tx = -1;
++    int ac = 0;
++    unsigned j, k;
++
++    if (skip < 0)
++	skip = 0;
++
++    n = skip;			/* make it easy */
++    k = SIZEOF(attrs_to_test) - 1;
++    wide_init_attr_string();
++
++    do {
++	int row = 2;
++	short pair = 0;
++	short extras = 0;
++
++	if (has_colors()) {
++	    pair = (fg != COLOR_BLACK || bg != COLOR_BLACK);
++	    if (pair != 0) {
++		pair = 1;
++		if (init_pair(pair, fg, bg) == ERR) {
++		    beep();
++		}
++	    }
++	    extras = pair;
++	    if (tx >= 0) {
++		extras = 2;
++		if (init_pair(extras, tx, bg) == ERR) {
++		    beep();
++		}
++	    }
++	}
++	set_wide_background(pair);
++	erase();
++
++	box_set(stdscr, 0, 0);
++	mvaddstr(0, 20, "Character attribute test display");
++
++	for (j = 0; j < SIZEOF(attrs_to_test); ++j) {
++	    row = wide_show_attr(row, n, j == k,
++				 ac |
++				 attrs_to_test[j].attr |
++				 attrs_to_test[k].attr,
++				 extras,
++				 attrs_to_test[j].name);
++	}
++
++	mvprintw(row, 8,
++		 "This terminal does %shave the magic-cookie glitch",
++		 tigetnum("xmc") > -1 ? "" : "not ");
++	mvprintw(row + 1, 8, "Enter '?' for help.");
++	show_color_attr(fg, bg, tx);
++	printw("  ACS (%d)", ac != 0);
++
++	refresh();
++    } while (wide_attr_getc(&n, &fg, &bg, &tx, &ac, &k));
++
++    set_wide_background(0);
++    erase();
++    endwin();
++}
++#endif
++
+ /****************************************************************************
+  *
+  * Color support tests
+@@ -1203,55 +1661,378 @@
+ };
+ 
+ static void
+-show_color_name(int y, int x, int color)
++show_color_name(int y, int x, int color, bool wide)
+ {
+-    if (max_colors > 8)
+-	mvprintw(y, x, "%02d   ", color);
+-    else
+-	mvaddstr(y, x, the_color_names[color]);
++    if (move(y, x) != ERR) {
++	char temp[80];
++	int width = 8;
++
++	if (wide) {
++	    sprintf(temp, "%02d", color);
++	    width = 4;
++	} else if (color >= 8) {
++	    sprintf(temp, "[%02d]", color);
++	} else {
++	    strcpy(temp, the_color_names[color]);
++	}
++	printw("%-*.*s", width, width, temp);
++    }
+ }
+ 
+ static void
++color_legend(WINDOW *helpwin)
++{
++    int row = 1;
++    int col = 1;
++
++    mvwprintw(helpwin, row++, col,
++	      "q or ESC to exit.");
++    ++row;
++    mvwprintw(helpwin, row++, col,
++	      "Use up/down arrow to scroll through the display if it is");
++    mvwprintw(helpwin, row++, col,
++	      "longer than one screen. Control/N and Control/P can be used");
++    mvwprintw(helpwin, row++, col,
++	      "in place up up/down arrow.  Use pageup/pagedown to scroll a");
++    mvwprintw(helpwin, row++, col,
++	      "full screen; control/B and control/F can be used here.");
++    ++row;
++    mvwprintw(helpwin, row++, col,
++	      "Toggles:");
++    mvwprintw(helpwin, row++, col,
++	      "  b/B     toggle bold off/on");
++    mvwprintw(helpwin, row++, col,
++	      "  n/N     toggle text/number on/off");
++    mvwprintw(helpwin, row++, col,
++	      "  w/W     toggle width between 8/16 colors");
++}
++
++#define set_color_test(name, value) if (name != value) { name = value; base_row = 0; }
++
++/* generate a color test pattern */
++static void
+ color_test(void)
++{
++    int c;
++    int i;
++    int top = 0, width;
++    int base_row = 0;
++    int grid_top = top + 3;
++    int page_size = (LINES - grid_top);
++    int pairs_max = PAIR_NUMBER(A_COLOR) + 1;
++    int row_limit;
++    int per_row;
++    char numbered[80];
++    const char *hello;
++    bool done = FALSE;
++    bool opt_bold = FALSE;
++    bool opt_wide = FALSE;
++    bool opt_nums = FALSE;
++    WINDOW *helpwin;
++
++    if (pairs_max > COLOR_PAIRS)
++	pairs_max = COLOR_PAIRS;
++
++    while (!done) {
++	int shown = 0;
++
++	/* this assumes an 80-column line */
++	if (opt_wide) {
++	    width = 4;
++	    hello = "Test";
++	    per_row = (COLORS > 8) ? 16 : 8;
++	} else {
++	    width = 8;
++	    hello = "Hello";
++	    per_row = 8;
++	}
++
++	row_limit = (pairs_max + per_row - 1) / per_row;
++
++	move(0, 0);
++	(void) printw("There are %d color pairs and %d colors\n",
++		      pairs_max, COLORS);
++
++	clrtobot();
++	(void) mvprintw(top + 1, 0,
++			"%dx%d matrix of foreground/background colors, bold *%s*\n",
++			row_limit,
++			per_row,
++			opt_bold ? "on" : "off");
++
++	/* show color names/numbers across the top */
++	for (i = 0; i < per_row; i++)
++	    show_color_name(top + 2, (i + 1) * width, i, opt_wide);
++
++	/* show a grid of colors, with color names/ numbers on the left */
++	for (i = (base_row * per_row); i < pairs_max; i++) {
++	    int row = grid_top + (i / per_row) - base_row;
++	    int col = (i % per_row + 1) * width;
++	    int pair = i;
++
++	    if (row >= 0 && move(row, col) != ERR) {
++		init_pair(pair, i % COLORS, i / COLORS);
++		attron((attr_t) COLOR_PAIR(pair));
++		if (opt_bold)
++		    attron((attr_t) A_BOLD);
++
++		if (opt_nums) {
++		    sprintf(numbered, "{%02X}", i);
++		    hello = numbered;
++		}
++		printw("%-*.*s", width, width, hello);
++		attrset(A_NORMAL);
++
++		if ((i % per_row) == 0 && (i % COLORS) == 0) {
++		    show_color_name(row, 0, i / COLORS, opt_wide);
++		}
++		++shown;
++	    } else if (shown) {
++		break;
++	    }
++	}
++
++	switch (c = wGetchar(stdscr)) {
++	case 'b':
++	    opt_bold = FALSE;
++	    break;
++	case 'B':
++	    opt_bold = TRUE;
++	    break;
++	case 'n':
++	    opt_nums = FALSE;
++	    break;
++	case 'N':
++	    opt_nums = TRUE;
++	    break;
++	case ESCAPE:
++	case 'q':
++	    done = TRUE;
++	    continue;
++	case 'w':
++	    set_color_test(opt_wide, FALSE);
++	    break;
++	case 'W':
++	    set_color_test(opt_wide, TRUE);
++	    break;
++	case CTRL('p'):
++	case KEY_UP:
++	    if (base_row <= 0) {
++		beep();
++	    } else {
++		base_row -= 1;
++	    }
++	    break;
++	case CTRL('n'):
++	case KEY_DOWN:
++	    if (base_row + page_size >= row_limit) {
++		beep();
++	    } else {
++		base_row += 1;
++	    }
++	    break;
++	case CTRL('b'):
++	case KEY_PREVIOUS:
++	case KEY_PPAGE:
++	    if (base_row <= 0) {
++		beep();
++	    } else {
++		base_row -= (page_size - 1);
++		if (base_row < 0)
++		    base_row = 0;
++	    }
++	    break;
++	case CTRL('f'):
++	case KEY_NEXT:
++	case KEY_NPAGE:
++	    if (base_row + page_size >= row_limit) {
++		beep();
++	    } else {
++		base_row += page_size - 1;
++		if (base_row + page_size >= row_limit) {
++		    base_row = row_limit - page_size - 1;
++		}
++	    }
++	    break;
++	case '?':
++	    if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
++		box(helpwin, 0, 0);
++		color_legend(helpwin);
++		wGetchar(helpwin);
++		delwin(helpwin);
++	    }
++	    break;
++	default:
++	    beep();
++	    continue;
++	}
++    }
++
++    erase();
++    endwin();
++}
++
++#if USE_WIDEC_SUPPORT
+ /* generate a color test pattern */
++static void
++wide_color_test(void)
+ {
++    int c;
+     int i;
+-    int base, top, width;
++    int top = 0, width;
++    int base_row = 0;
++    int grid_top = top + 3;
++    int page_size = (LINES - grid_top);
++    int pairs_max = COLOR_PAIRS;
++    int row_limit;
++    int per_row;
++    char numbered[80];
+     const char *hello;
++    bool done = FALSE;
++    bool opt_bold = FALSE;
++    bool opt_wide = FALSE;
++    bool opt_nums = FALSE;
++    WINDOW *helpwin;
+ 
+-    refresh();
+-    (void) printw("There are %d color pairs\n", COLOR_PAIRS);
++    while (!done) {
++	int shown = 0;
++
++	/* this assumes an 80-column line */
++	if (opt_wide) {
++	    width = 4;
++	    hello = "Test";
++	    per_row = (COLORS > 8) ? 16 : 8;
++	} else {
++	    width = 8;
++	    hello = "Hello";
++	    per_row = 8;
++	}
+ 
+-    width = (max_colors > 8) ? 4 : 8;
+-    hello = (max_colors > 8) ? "Test" : "Hello";
++	row_limit = (pairs_max + per_row - 1) / per_row;
++
++	move(0, 0);
++	(void) printw("There are %d color pairs and %d colors\n",
++		      pairs_max, COLORS);
+ 
+-    for (base = 0; base < 2; base++) {
+-	top = (max_colors > 8) ? 0 : base * (max_colors + 3);
+ 	clrtobot();
+ 	(void) mvprintw(top + 1, 0,
+-			"%dx%d matrix of foreground/background colors, bright *%s*\n",
+-			max_colors, max_colors,
+-			base ? "on" : "off");
+-	for (i = 0; i < max_colors; i++)
+-	    show_color_name(top + 2, (i + 1) * width, i);
+-	for (i = 0; i < max_colors; i++)
+-	    show_color_name(top + 3 + i, 0, i);
+-	for (i = 1; i < max_pairs; i++) {
+-	    init_pair(i, i % max_colors, i / max_colors);
+-	    attron((attr_t) COLOR_PAIR(i));
+-	    if (base)
+-		attron((attr_t) A_BOLD);
+-	    mvaddstr(top + 3 + (i / max_colors), (i % max_colors + 1) *
+-		     width, hello);
+-	    attrset(A_NORMAL);
++			"%dx%d matrix of foreground/background colors, bold *%s*\n",
++			row_limit,
++			per_row,
++			opt_bold ? "on" : "off");
++
++	/* show color names/numbers across the top */
++	for (i = 0; i < per_row; i++)
++	    show_color_name(top + 2, (i + 1) * width, i, opt_wide);
++
++	/* show a grid of colors, with color names/ numbers on the left */
++	for (i = (base_row * per_row); i < pairs_max; i++) {
++	    int row = grid_top + (i / per_row) - base_row;
++	    int col = (i % per_row + 1) * width;
++	    int pair = i;
++
++	    if (row >= 0 && move(row, col) != ERR) {
++		init_pair(pair, i % COLORS, i / COLORS);
++		color_set(pair, NULL);
++		if (opt_bold)
++		    attr_on((attr_t) A_BOLD, NULL);
++
++		if (opt_nums) {
++		    sprintf(numbered, "{%02X}", i);
++		    hello = numbered;
++		}
++		printw("%-*.*s", width, width, hello);
++		attr_set(A_NORMAL, 0, NULL);
++
++		if ((i % per_row) == 0 && (i % COLORS) == 0) {
++		    show_color_name(row, 0, i / COLORS, opt_wide);
++		}
++		++shown;
++	    } else if (shown) {
++		break;
++	    }
++	}
++
++	switch (c = wGetchar(stdscr)) {
++	case 'b':
++	    opt_bold = FALSE;
++	    break;
++	case 'B':
++	    opt_bold = TRUE;
++	    break;
++	case 'n':
++	    opt_nums = FALSE;
++	    break;
++	case 'N':
++	    opt_nums = TRUE;
++	    break;
++	case ESCAPE:
++	case 'q':
++	    done = TRUE;
++	    continue;
++	case 'w':
++	    set_color_test(opt_wide, FALSE);
++	    break;
++	case 'W':
++	    set_color_test(opt_wide, TRUE);
++	    break;
++	case CTRL('p'):
++	case KEY_UP:
++	    if (base_row <= 0) {
++		beep();
++	    } else {
++		base_row -= 1;
++	    }
++	    break;
++	case CTRL('n'):
++	case KEY_DOWN:
++	    if (base_row + page_size >= row_limit) {
++		beep();
++	    } else {
++		base_row += 1;
++	    }
++	    break;
++	case CTRL('b'):
++	case KEY_PREVIOUS:
++	case KEY_PPAGE:
++	    if (base_row <= 0) {
++		beep();
++	    } else {
++		base_row -= (page_size - 1);
++		if (base_row < 0)
++		    base_row = 0;
++	    }
++	    break;
++	case CTRL('f'):
++	case KEY_NEXT:
++	case KEY_NPAGE:
++	    if (base_row + page_size >= row_limit) {
++		beep();
++	    } else {
++		base_row += page_size - 1;
++		if (base_row + page_size >= row_limit) {
++		    base_row = row_limit - page_size - 1;
++		}
++	    }
++	    break;
++	case '?':
++	    if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
++		box(helpwin, 0, 0);
++		color_legend(helpwin);
++		wGetchar(helpwin);
++		delwin(helpwin);
++	    }
++	    break;
++	default:
++	    beep();
++	    continue;
+ 	}
+-	if ((max_colors > 8) || base)
+-	    Pause();
+     }
+ 
+     erase();
+     endwin();
+ }
++#endif /* USE_WIDEC_SUPPORT */
+ 
+ static void
+ change_color(int current, int field, int value, int usebase)
+@@ -1280,12 +2061,28 @@
+ }
+ 
+ static void
++init_all_colors(void)
++{
++    int c;
++    for (c = 0; c < COLORS; ++c)
++	init_color(c,
++		   all_colors[c].red,
++		   all_colors[c].green,
++		   all_colors[c].blue);
++}
++
++#define scaled_rgb(n) ((255 * (n)) / 1000)
++
++static void
+ color_edit(void)
+ /* display the color test pattern, without trying to edit colors */
+ {
+     int i, this_c = 0, value = 0, current = 0, field = 0;
+     int last_c;
++    int top_color = 0;
++    int page_size = (LINES - 6);
+ 
++    init_all_colors();
+     refresh();
+ 
+     for (i = 0; i < max_colors; i++)
+@@ -1300,23 +2097,19 @@
+ 	mvaddstr(0, 20, "Color RGB Value Editing");
+ 	attroff(A_BOLD);
+ 
+-	for (i = 0; i < max_colors; i++) {
+-	    mvprintw(2 + i, 0, "%c %-8s:",
++	for (i = top_color;
++	     (i - top_color < page_size)
++	     && (i < max_colors); i++) {
++	    char numeric[80];
++	    sprintf(numeric, "[%d]", i);
++	    mvprintw(2 + i - top_color, 0, "%c %-8s:",
+ 		     (i == current ? '>' : ' '),
+ 		     (i < (int) SIZEOF(the_color_names)
+-		      ? the_color_names[i] : ""));
++		      ? the_color_names[i] : numeric));
+ 	    attrset(COLOR_PAIR(i));
+ 	    addstr("        ");
+ 	    attrset(A_NORMAL);
+ 
+-	    /*
+-	     * Note: this refresh should *not* be necessary!  It works around
+-	     * a bug in attribute handling that apparently causes the A_NORMAL
+-	     * attribute sets to interfere with the actual emission of the
+-	     * color setting somehow.  This needs to be fixed.
+-	     */
+-	    refresh();
+-
+ 	    color_content(i, &red, &green, &blue);
+ 	    addstr("   R = ");
+ 	    if (current == i && field == 0)
+@@ -1337,26 +2130,47 @@
+ 	    if (current == i && field == 2)
+ 		attrset(A_NORMAL);
+ 	    attrset(A_NORMAL);
+-	    addstr(")");
++	    printw(" ( %3d %3d %3d )",
++		   scaled_rgb(red),
++		   scaled_rgb(green),
++		   scaled_rgb(blue));
+ 	}
+ 
+-	mvaddstr(max_colors + 3, 0,
++	mvaddstr(LINES - 3, 0,
+ 		 "Use up/down to select a color, left/right to change fields.");
+-	mvaddstr(max_colors + 4, 0,
++	mvaddstr(LINES - 2, 0,
+ 		 "Modify field by typing nnn=, nnn-, or nnn+.  ? for help.");
+ 
+-	move(2 + current, 0);
++	move(2 + current - top_color, 0);
+ 
+ 	last_c = this_c;
+ 	this_c = Getchar();
+-	if (isdigit(this_c) && !isdigit(last_c))
++	if (this_c < 256 && isdigit(this_c) && !isdigit(last_c))
+ 	    value = 0;
+ 
+-	switch (this_c) {
++	switch (this_c) {
++	case CTRL('b'):
++	case KEY_PPAGE:
++	    if (current > 0)
++		current -= (page_size - 1);
++	    else
++		beep();
++	    break;
++
++	case CTRL('f'):
++	case KEY_NPAGE:
++	    if (current < (max_colors - 1))
++		current += (page_size - 1);
++	    else
++		beep();
++	    break;
++
++	case CTRL('p'):
+ 	case KEY_UP:
+ 	    current = (current == 0 ? (max_colors - 1) : current - 1);
+ 	    break;
+ 
++	case CTRL('n'):
+ 	case KEY_DOWN:
+ 	    current = (current == (max_colors - 1) ? 0 : current + 1);
+ 	    break;
+@@ -1407,12 +2221,19 @@
+ 	    P("To increment or decrement a value, use the same procedure, but finish");
+ 	    P("with a `+' or `-'.");
+ 	    P("");
++	    P("Press 'm' to invoke the top-level menu with the current color settings.");
+ 	    P("To quit, do `x' or 'q'");
+ 
+ 	    Pause();
+ 	    erase();
+ 	    break;
+ 
++	case 'm':
++	    endwin();
++	    main_menu(FALSE);
++	    refresh();
++	    break;
++
+ 	case 'x':
+ 	case 'q':
+ 	    break;
+@@ -1421,12 +2242,28 @@
+ 	    beep();
+ 	    break;
+ 	}
+-	mvprintw(LINES - 2, 0, "Number: %d", value);
++
++	if (current < 0)
++	    current = 0;
++	if (current >= max_colors)
++	    current = max_colors - 1;
++	if (current < top_color)
++	    top_color = current;
++	if (current - top_color >= page_size)
++	    top_color = current - (page_size - 1);
++
++	mvprintw(LINES - 1, 0, "Number: %d", value);
+ 	clrtoeol();
+     } while
+ 	(this_c != 'x' && this_c != 'q');
+ 
+     erase();
++
++    /*
++     * ncurses does not reset each color individually when calling endwin().
++     */
++    init_all_colors();
++
+     endwin();
+ }
+ 
+@@ -1571,13 +2408,13 @@
+ #if HAVE_SLK_COLOR
+ 	case 'F':
+ 	    if (has_colors()) {
+-		fg = (fg + 1) % max_colors;
++		fg = (fg + 1) % COLORS;
+ 		new_color = TRUE;
+ 	    }
+ 	    break;
+ 	case 'B':
+ 	    if (has_colors()) {
+-		bg = (bg + 1) % max_colors;
++		bg = (bg + 1) % COLORS;
+ 		new_color = TRUE;
+ 	    }
+ 	    break;
+@@ -1595,12 +2432,13 @@
+ }
+ 
+ #if USE_WIDEC_SUPPORT
++#define SLKLEN 8
+ static void
+ wide_slk_test(void)
+ /* exercise the soft keys */
+ {
+     int c, fmt = 1;
+-    wchar_t buf[9];
++    wchar_t buf[SLKLEN + 1];
+     char *s;
+     short fg = COLOR_BLACK;
+     short bg = COLOR_WHITE;
+@@ -1670,14 +2508,30 @@
+ 	    (void) mvaddstr(SLK_WORK, 0, "Please enter the label value: ");
+ 	    *buf = 0;
+ 	    if ((s = slk_label(c - '0')) != 0) {
+-		int j;
+-		for (j = 0; j < 8; ++j) {
+-		    if ((buf[j] = UChar(s[j])) == 0)
++		char *temp = strdup(s);
++		size_t used = strlen(temp);
++		size_t want = SLKLEN;
++		size_t test;
++		mbstate_t state;
++
++		buf[0] = L'\0';
++		while (want > 0 && used != 0) {
++		    const char *base = s;
++		    memset(&state, 0, sizeof(state));
++		    test = mbsrtowcs(0, &base, 0, &state);
++		    if (test == (size_t) -1) {
++			temp[--used] = 0;
++		    } else if (test > want) {
++			temp[--used] = 0;
++		    } else {
++			memset(&state, 0, sizeof(state));
++			mbsrtowcs(buf, &base, want, &state);
+ 			break;
++		    }
+ 		}
+-		buf[j] = 0;
++		free(temp);
+ 	    }
+-	    wGet_wstring(stdscr, buf, 8);
++	    wGet_wstring(stdscr, buf, SLKLEN);
+ 	    slk_wset((c - '0'), buf, fmt);
+ 	    slk_refresh();
+ 	    move(SLK_WORK, 0);
+@@ -1690,13 +2544,13 @@
+ 
+ 	case 'F':
+ 	    if (has_colors()) {
+-		fg = (fg + 1) % max_colors;
++		fg = (fg + 1) % COLORS;
+ 		new_color = TRUE;
+ 	    }
+ 	    break;
+ 	case 'B':
+ 	    if (has_colors()) {
+-		bg = (bg + 1) % max_colors;
++		bg = (bg + 1) % COLORS;
+ 		new_color = TRUE;
+ 	    }
+ 	    break;
+@@ -1914,7 +2768,7 @@
+ }
+ 
+ static int
+-show_1_wacs(int n, const char *name, const cchar_t * code)
++show_1_wacs(int n, const char *name, const cchar_t *code)
+ {
+     const int height = 16;
+     int row = 4 + (n % height);
+@@ -2087,7 +2941,7 @@
+ 	    show_utf8_chars();
+ 	    break;
+ 	default:
+-	    if (isdigit(c))
++	    if (c < 256 && isdigit(c))
+ 		digit = (c - '0');
+ 	    else if (c == '+')
+ 		++digit;
+@@ -3057,6 +3911,10 @@
+ 	saywhat("d5; press any key to continue");
+ 	rmpanel(p5);
+ 	pflush();
++
++	rmpanel(p3);
++	pflush();
++
+ 	wait_a_while(nap_msec);
+ 	if (nap_msec == 1)
+ 	    break;
+@@ -3086,7 +3944,7 @@
+ 	"Use arrow keys (or U,D,L,R) to pan, q to quit, ! to shell-out.",
+ 	"Use +,- (or j,k) to grow/shrink the panner vertically.",
+ 	"Use <,> (or h,l) to grow/shrink the panner horizontally.",
+-	"Number repeats.  Toggle legend:?, timer:t, scroll mark:s."
++	"Number repeats.  Toggle legend:? filler:a timer:t scrollmark:s."
+     };
+     int n = (SIZEOF(legend) - (LINES - line));
+     if (line < LINES && (n >= 0)) {
+@@ -3114,6 +3972,35 @@
+ }
+ 
+ static void
++fill_pad(WINDOW *panpad, bool pan_lines)
++{
++    int y, x;
++    unsigned gridcount = 0;
++
++    wmove(panpad, 0, 0);
++    for (y = 0; y < getmaxy(panpad); y++) {
++	for (x = 0; x < getmaxx(panpad); x++) {
++	    if (y % GRIDSIZE == 0 && x % GRIDSIZE == 0) {
++		if (y == 0 && x == 0)
++		    waddch(panpad, pan_lines ? ACS_ULCORNER : '+');
++		else if (y == 0)
++		    waddch(panpad, pan_lines ? ACS_TTEE : '+');
++		else if (y == 0 || x == 0)
++		    waddch(panpad, pan_lines ? ACS_LTEE : '+');
++		else
++		    waddch(panpad, (chtype) ((pan_lines ? 'a' : 'A') +
++					     (gridcount++ % 26)));
++	    } else if (y % GRIDSIZE == 0)
++		waddch(panpad, pan_lines ? ACS_HLINE : '-');
++	    else if (x % GRIDSIZE == 0)
++		waddch(panpad, pan_lines ? ACS_VLINE : '|');
++	    else
++		waddch(panpad, ' ');
++	}
++    }
++}
++
++static void
+ panner(WINDOW *pad,
+        int top_x, int top_y, int porty, int portx,
+        int (*pgetc) (WINDOW *))
+@@ -3122,6 +4009,7 @@
+     struct timeval before, after;
+     bool timing = TRUE;
+ #endif
++    bool pan_lines = FALSE;
+     bool scrollers = TRUE;
+     int basex = 0;
+     int basey = 0;
+@@ -3160,6 +4048,12 @@
+ 	    panner_legend(LINES - 2);
+ 	    panner_legend(LINES - 1);
+ 	    break;
++	case 'a':
++	    pan_lines = !pan_lines;
++	    fill_pad(pad, pan_lines);
++	    pending_pan = FALSE;
++	    break;
++
+ #if HAVE_GETTIMEOFDAY
+ 	case 't':
+ 	    timing = !timing;
+@@ -3357,7 +4251,7 @@
+ 		gettimeofday(&after, 0);
+ 		elapsed = (after.tv_sec + after.tv_usec / 1.0e6)
+ 		    - (before.tv_sec + before.tv_usec / 1.0e6);
+-		move(LINES - 1, COLS - 20);
++		move(LINES - 1, COLS - 12);
+ 		printw("Secs: %2.03f", elapsed);
+ 		refresh();
+ 	    }
+@@ -3446,8 +4340,6 @@
+ demo_pad(void)
+ /* Demonstrate pads. */
+ {
+-    int i, j;
+-    unsigned gridcount = 0;
+     WINDOW *panpad = newpad(PAD_HIGH, PAD_WIDE);
+ 
+     if (panpad == 0) {
+@@ -3455,20 +4347,8 @@
+ 	return;
+     }
+ 
+-    for (i = 0; i < PAD_HIGH; i++) {
+-	for (j = 0; j < PAD_WIDE; j++)
+-	    if (i % GRIDSIZE == 0 && j % GRIDSIZE == 0) {
+-		if (i == 0 || j == 0)
+-		    waddch(panpad, '+');
+-		else
+-		    waddch(panpad, (chtype) ('A' + (gridcount++ % 26)));
+-	    } else if (i % GRIDSIZE == 0)
+-		waddch(panpad, '-');
+-	    else if (j % GRIDSIZE == 0)
+-		waddch(panpad, '|');
+-	    else
+-		waddch(panpad, ' ');
+-    }
++    fill_pad(panpad, FALSE);
++
+     panner_legend(LINES - 4);
+     panner_legend(LINES - 3);
+     panner_legend(LINES - 2);
+@@ -3626,7 +4506,19 @@
+ 
+ static const char *animals[] =
+ {
+-    "Lions", "Tigers", "Bears", "(Oh my!)", "Newts", "Platypi", "Lemurs",
++    "Lions",
++    "Tigers",
++    "Bears",
++    "(Oh my!)",
++    "Newts",
++    "Platypi",
++    "Lemurs",
++    "(Oh really?!)",
++    "Leopards",
++    "Panthers",
++    "Pumas",
++    "Lions, Tigers, Bears, (Oh my!), Newts, Platypi, Lemurs",
++    "Lions, Tigers, Bears, (Oh my!), Newts, Platypi, Lemurs, Lions, Tigers, Bears, (Oh my!), Newts, Platypi, Lemurs",
+     (char *) 0
+ };
+ 
+@@ -3670,6 +4562,8 @@
+     post_menu(m);
+ 
+     while ((c = menu_driver(m, menu_virtualize(wGetchar(menuwin)))) != E_UNKNOWN_COMMAND) {
++	if (c == E_NOT_POSTED)
++	    break;
+ 	if (c == E_REQUEST_DENIED)
+ 	    beep();
+ 	continue;
+@@ -3931,7 +4825,7 @@
+ 	strcpy(temp, field_buffer(me, 1));
+ 	len = (long) (char *) field_userptr(me);
+ 	if (c <= KEY_MAX) {
+-	    if (isgraph(c)) {
++	    if (isgraph(c) && (len + 1) < (int) sizeof(temp)) {
+ 		temp[len++] = c;
+ 		temp[len] = 0;
+ 		set_field_buffer(me, 1, temp);
+@@ -4102,12 +4996,14 @@
+     int c = wGetchar(w);
+     unsigned n;
+     FIELD *me = current_field(f);
++    bool current = TRUE;
+ 
+     if (c == CTRL(']')) {
+-	if (mode == REQ_INS_MODE)
++	if (mode == REQ_INS_MODE) {
+ 	    mode = REQ_OVL_MODE;
+-	else
++	} else {
+ 	    mode = REQ_INS_MODE;
++	}
+ 	c = mode;
+     } else {
+ 	for (n = 0; n < SIZEOF(lookup); n++) {
+@@ -4117,15 +5013,38 @@
+ 	    }
+ 	}
+     }
++    mvprintw(0, COLS - 6, "(%s)", mode == REQ_INS_MODE ? "INS" : "OVL");
+ 
+     /*
+      * Force the field that the user is typing into to be in reverse video,
+      * while the other fields are shown underlined.
+      */
+-    if (c <= KEY_MAX) {
++    switch (c) {
++    case REQ_BEG_FIELD:
++    case REQ_CLR_EOF:
++    case REQ_CLR_EOL:
++    case REQ_CLR_FIELD:
++    case REQ_DEL_CHAR:
++    case REQ_DEL_LINE:
++    case REQ_DEL_PREV:
++    case REQ_DEL_WORD:
++    case REQ_END_FIELD:
++    case REQ_INS_CHAR:
++    case REQ_INS_LINE:
++    case REQ_LEFT_CHAR:
++    case REQ_LEFT_FIELD:
++    case REQ_NEXT_WORD:
++    case REQ_RIGHT_CHAR:
++	current = TRUE;
++	break;
++    default:
++	current = (c < KEY_MAX);
++	break;
++    }
++    if (current) {
+ 	c = edit_secure(me, c);
+ 	set_field_back(me, A_REVERSE);
+-    } else if (c <= MAX_FORM_COMMAND) {
++    } else {
+ 	c = edit_secure(me, c);
+ 	set_field_back(me, A_UNDERLINE);
+     }
+@@ -4222,7 +5141,7 @@
+     unsigned n = 0;
+ 
+     move(18, 0);
+-    addstr("Defined form-traversal keys:   ^Q/ESC- exit form\n");
++    addstr("Defined edit/traversal keys:   ^Q/ESC- exit form\n");
+     addstr("^N   -- go to next field       ^P  -- go to previous field\n");
+     addstr("Home -- go to first field      End -- go to last field\n");
+     addstr("^L   -- go to field to left    ^R  -- go to field to right\n");
+@@ -4232,7 +5151,7 @@
+     addstr("^H   -- delete previous char   ^Y  -- delete line\n");
+     addstr("^G   -- delete current word    ^C  -- clear to end of line\n");
+     addstr("^K   -- clear to end of field  ^X  -- clear field\n");
+-    addstr("Arrow keys move within a field as you would expect.");
++    addstr("Arrow keys move within a field as you would expect. ^] toggles overlay mode.");
+ 
+     mvaddstr(4, 57, "Forms Entry Test");
+ 
+@@ -4290,6 +5209,8 @@
+     free_form(form);
+     for (c = 0; f[c] != 0; c++)
+ 	free_field(f[c]);
++    free_fieldtype(fty_middle);
++    free_fieldtype(fty_passwd);
+     noraw();
+     nl();
+ }
+@@ -4436,6 +5357,12 @@
+ 	attr_test();
+ 	break;
+ 
++#if USE_WIDEC_SUPPORT
++    case 'B':
++	wide_attr_test();
++	break;
++#endif
++
+     case 'c':
+ 	if (!has_colors())
+ 	    Cannot("does not support color.");
+@@ -4443,6 +5370,15 @@
+ 	    color_test();
+ 	break;
+ 
++#if USE_WIDEC_SUPPORT
++    case 'C':
++	if (!has_colors())
++	    Cannot("does not support color.");
++	else
++	    wide_color_test();
++	break;
++#endif
++
+     case 'd':
+ 	if (!has_colors())
+ 	    Cannot("does not support color.");
+@@ -4542,7 +5478,10 @@
+ 	,"  -e fmt   specify format for soft-keys test (e)"
+ 	,"  -f       rip-off footer line (can repeat)"
+ 	,"  -h       rip-off header line (can repeat)"
++	,"  -p file  rgb values to use in 'd' rather than ncurses's builtin"
++#if USE_LIBPANEL
+ 	,"  -s msec  specify nominal time for panel-demo (default: 1, to hold)"
++#endif
+ #ifdef TRACE
+ 	,"  -t mask  specify default trace-level (may toggle with ^T)"
+ #endif
+@@ -4594,14 +5533,122 @@
+     return OK;
+ }
+ 
++static void
++main_menu(bool top)
++{
++    int command;
++
++    do {
++	(void) puts("This is the ncurses main menu");
++	(void) puts("a = keyboard and mouse input test");
++#if USE_WIDEC_SUPPORT
++	(void) puts("A = wide-character keyboard and mouse input test");
++#endif
++	(void) puts("b = character attribute test");
++#if USE_WIDEC_SUPPORT
++	(void) puts("B = wide-character attribute test");
++#endif
++	(void) puts("c = color test pattern");
++#if USE_WIDEC_SUPPORT
++	(void) puts("C = color test pattern using wide-character calls");
++#endif
++	if (top)
++	    (void) puts("d = edit RGB color values");
++	(void) puts("e = exercise soft keys");
++#if USE_WIDEC_SUPPORT
++	(void) puts("E = exercise soft keys using wide-characters");
++#endif
++	(void) puts("f = display ACS characters");
++#if USE_WIDEC_SUPPORT
++	(void) puts("F = display Wide-ACS characters");
++#endif
++	(void) puts("g = display windows and scrolling");
++	(void) puts("i = test of flushinp()");
++	(void) puts("k = display character attributes");
++#if USE_LIBMENU
++	(void) puts("m = menu code test");
++#endif
++#if USE_LIBPANEL
++	(void) puts("o = exercise panels library");
++	(void) puts("p = exercise pad features");
++	(void) puts("q = quit");
++#endif
++#if USE_LIBFORM
++	(void) puts("r = exercise forms code");
++#endif
++	(void) puts("s = overlapping-refresh test");
++#if USE_LIBMENU && defined(TRACE)
++	(void) puts("t = set trace level");
++#endif
++	(void) puts("? = repeat this command summary");
++
++	(void) fputs("> ", stdout);
++	(void) fflush(stdout);	/* necessary under SVr4 curses */
++
++	/*
++	 * This used to be an 'fgets()' call.  However (on Linux, at least)
++	 * mixing stream I/O and 'read()' (used in the library) causes the
++	 * input stream to be flushed when switching between the two.
++	 */
++	command = 0;
++	for (;;) {
++	    char ch;
++	    if (read(fileno(stdin), &ch, 1) <= 0) {
++		if (command == 0)
++		    command = 'q';
++		break;
++	    } else if (command == 0 && !isspace(UChar(ch))) {
++		command = ch;
++	    } else if (ch == '\n' || ch == '\r') {
++		if ((command == 'd') && !top) {
++		    (void) fputs("Do not nest test-d\n", stdout);
++		    command = 0;
++		}
++		if (command != 0)
++		    break;
++		(void) fputs("> ", stdout);
++		(void) fflush(stdout);
++	    }
++	}
++
++	if (do_single_test(command)) {
++	    /*
++	     * This may be overkill; it's intended to reset everything back
++	     * to the initial terminal modes so that tests don't get in
++	     * each other's way.
++	     */
++	    flushinp();
++	    set_terminal_modes();
++	    reset_prog_mode();
++	    clear();
++	    refresh();
++	    endwin();
++	    if (command == '?') {
++		(void) puts("This is the ncurses capability tester.");
++		(void)
++		    puts("You may select a test from the main menu by typing the");
++		(void)
++		    puts("key letter of the choice (the letter to left of the =)");
++		(void)
++		    puts("at the > prompt.  The commands `x' or `q' will exit.");
++	    }
++	    continue;
++	}
++    } while
++	(command != 'q');
++}
++
+ /*+-------------------------------------------------------------------------
+ 	main(argc,argv)
+ --------------------------------------------------------------------------*/
+ 
++#define okCOLOR(n) ((n) >= 0 && (n) < max_colors)
++#define okRGB(n)   ((n) >= 0 && (n) <= 1000)
++
+ int
+ main(int argc, char *argv[])
+ {
+-    int command, c;
++    int c;
+     int my_e_param = 1;
+ #ifdef NCURSES_VERSION
+     int default_fg = COLOR_WHITE;
+@@ -4609,10 +5656,11 @@
+     bool assumed_colors = FALSE;
+     bool default_colors = FALSE;
+ #endif
++    char *palette_file = 0;
+ 
+     setlocale(LC_ALL, "");
+ 
+-    while ((c = getopt(argc, argv, "a:de:fhs:t:")) != EOF) {
++    while ((c = getopt(argc, argv, "a:de:fhp:s:t:")) != EOF) {
+ 	switch (c) {
+ #ifdef NCURSES_VERSION
+ 	case 'a':
+@@ -4639,6 +5687,9 @@
+ 	case 'h':
+ 	    ripoffline(1, rip_header);
+ 	    break;
++	case 'p':
++	    palette_file = optarg;
++	    break;
+ #if USE_LIBPANEL
+ 	case 's':
+ 	    nap_msec = atol(optarg);
+@@ -4646,7 +5697,7 @@
+ #endif
+ #ifdef TRACE
+ 	case 't':
+-	    save_trace = atoi(optarg);
++	    save_trace = strtol(optarg, 0, 0);
+ 	    break;
+ #endif
+ 	default:
+@@ -4685,21 +5736,57 @@
+     if (has_colors()) {
+ 	start_color();
+ #ifdef NCURSES_VERSION_PATCH
+-	max_colors = COLORS > 16 ? 16 : COLORS;
++	max_colors = COLORS;	/* was > 16 ? 16 : COLORS */
+ #if HAVE_USE_DEFAULT_COLORS
+-	if (default_colors)
++	if (default_colors) {
+ 	    use_default_colors();
++	    min_colors = -1;
++	}
+ #if NCURSES_VERSION_PATCH >= 20000708
+ 	else if (assumed_colors)
+ 	    assume_default_colors(default_fg, default_bg);
+ #endif
+ #endif
+ #else /* normal SVr4 curses */
+-	max_colors = COLORS > 8 ? 8 : COLORS;
++	max_colors = COLORS;	/* was > 8 ? 8 : COLORS */
+ #endif
+-	max_pairs = (max_colors * max_colors);
+-	if (max_pairs < COLOR_PAIRS)
+-	    max_pairs = COLOR_PAIRS;
++	max_pairs = COLOR_PAIRS;	/* was > 256 ? 256 : COLOR_PAIRS */
++
++	if (can_change_color()) {
++	    all_colors = (RGB_DATA *) malloc(max_colors * sizeof(RGB_DATA));
++	    for (c = 0; c < max_colors; ++c) {
++		color_content(c,
++			      &all_colors[c].red,
++			      &all_colors[c].green,
++			      &all_colors[c].blue);
++	    }
++	    if (palette_file != 0) {
++		FILE *fp = fopen(palette_file, "r");
++		if (fp != 0) {
++		    char buffer[BUFSIZ];
++		    int red, green, blue;
++		    int scale = 1000;
++		    while (fgets(buffer, sizeof(buffer), fp) != 0) {
++			if (sscanf(buffer, "scale:%d", &c) == 1) {
++			    scale = c;
++			} else if (sscanf(buffer, "%d:%d %d %d",
++					  &c,
++					  &red,
++					  &green,
++					  &blue) == 4
++				   && okCOLOR(c)
++				   && okRGB(red)
++				   && okRGB(green)
++				   && okRGB(blue)) {
++			    all_colors[c].red = (red * 1000) / scale;
++			    all_colors[c].green = (green * 1000) / scale;
++			    all_colors[c].blue = (blue * 1000) / scale;
++			}
++		    }
++		    fclose(fp);
++		}
++	    }
++	}
+     }
+     set_terminal_modes();
+     def_prog_mode();
+@@ -4721,93 +5808,7 @@
+     (void) puts("Welcome to ncurses.  Press ? for help.");
+ #endif
+ 
+-    do {
+-	(void) puts("This is the ncurses main menu");
+-	(void) puts("a = keyboard and mouse input test");
+-#if USE_WIDEC_SUPPORT
+-	(void) puts("A = wide-character keyboard and mouse input test");
+-#endif
+-	(void) puts("b = character attribute test");
+-	(void) puts("c = color test pattern");
+-	(void) puts("d = edit RGB color values");
+-	(void) puts("e = exercise soft keys");
+-#if USE_WIDEC_SUPPORT
+-	(void) puts("E = exercise soft keys using wide-characters");
+-#endif
+-	(void) puts("f = display ACS characters");
+-#if USE_WIDEC_SUPPORT
+-	(void) puts("F = display Wide-ACS characters");
+-#endif
+-	(void) puts("g = display windows and scrolling");
+-	(void) puts("i = test of flushinp()");
+-	(void) puts("k = display character attributes");
+-#if USE_LIBMENU
+-	(void) puts("m = menu code test");
+-#endif
+-#if USE_LIBPANEL
+-	(void) puts("o = exercise panels library");
+-	(void) puts("p = exercise pad features");
+-	(void) puts("q = quit");
+-#endif
+-#if USE_LIBFORM
+-	(void) puts("r = exercise forms code");
+-#endif
+-	(void) puts("s = overlapping-refresh test");
+-#if USE_LIBMENU && defined(TRACE)
+-	(void) puts("t = set trace level");
+-#endif
+-	(void) puts("? = repeat this command summary");
+-
+-	(void) fputs("> ", stdout);
+-	(void) fflush(stdout);	/* necessary under SVr4 curses */
+-
+-	/*
+-	 * This used to be an 'fgets()' call.  However (on Linux, at least)
+-	 * mixing stream I/O and 'read()' (used in the library) causes the
+-	 * input stream to be flushed when switching between the two.
+-	 */
+-	command = 0;
+-	for (;;) {
+-	    char ch;
+-	    if (read(fileno(stdin), &ch, 1) <= 0) {
+-		if (command == 0)
+-		    command = 'q';
+-		break;
+-	    } else if (command == 0 && !isspace(UChar(ch))) {
+-		command = ch;
+-	    } else if (ch == '\n' || ch == '\r') {
+-		if (command != 0)
+-		    break;
+-		(void) fputs("> ", stdout);
+-		(void) fflush(stdout);
+-	    }
+-	}
+-
+-	if (do_single_test(command)) {
+-	    /*
+-	     * This may be overkill; it's intended to reset everything back
+-	     * to the initial terminal modes so that tests don't get in
+-	     * each other's way.
+-	     */
+-	    flushinp();
+-	    set_terminal_modes();
+-	    reset_prog_mode();
+-	    clear();
+-	    refresh();
+-	    endwin();
+-	    if (command == '?') {
+-		(void) puts("This is the ncurses capability tester.");
+-		(void)
+-		    puts("You may select a test from the main menu by typing the");
+-		(void)
+-		    puts("key letter of the choice (the letter to left of the =)");
+-		(void)
+-		    puts("at the > prompt.  The commands `x' or `q' will exit.");
+-	    }
+-	    continue;
+-	}
+-    } while
+-	(command != 'q');
++    main_menu(TRUE);
+ 
+     ExitProgram(EXIT_SUCCESS);
+ }
+Index: test/newdemo.c
+Prereq:  1.24 
+--- ncurses-5.4-20040208/test/newdemo.c	2002-06-29 23:32:18.000000000 +0000
++++ ncurses-5.4-20050319/test/newdemo.c	2004-12-04 15:43:16.000000000 +0000
+@@ -2,7 +2,7 @@
+  *  newdemo.c	-	A demo program using PDCurses. The program illustrate
+  *  	 		the use of colours for text output.
+  *
+- * $Id: newdemo.c,v 1.24 2002/06/29 23:32:18 tom Exp $
++ * $Id: newdemo.c,v 1.25 2004/12/04 15:43:16 tom Exp $
+  */
+ 
+ #include <time.h>
+@@ -14,7 +14,7 @@
+ /*
+  *  The Australian map
+  */
+-const char *AusMap[16] =
++static const char *AusMap[16] =
+ {
+     "           A           A ",
+     "    N.T. AAAAA       AAAA ",
+@@ -35,7 +35,7 @@
+  */
+ #define NMESSAGES   6
+ 
+-NCURSES_CONST char *messages[] =
++static NCURSES_CONST char *messages[] =
+ {
+     "Hello from the Land Down Under",
+     "The Land of crocs. and a big Red Rock",
+Index: test/test.priv.h
+Prereq:  1.46 
+--- ncurses-5.4-20040208/test/test.priv.h	2003-10-19 00:04:24.000000000 +0000
++++ ncurses-5.4-20050319/test/test.priv.h	2004-04-10 20:11:37.000000000 +0000
+@@ -29,7 +29,7 @@
+ /****************************************************************************
+  *  Author: Thomas E. Dickey <dickey@clark.net> 1996                        *
+  ****************************************************************************/
+-/* $Id: test.priv.h,v 1.46 2003/10/19 00:04:24 tom Exp $ */
++/* $Id: test.priv.h,v 1.48 2004/04/10 20:11:37 tom Exp $ */
+ 
+ #ifndef __TEST_PRIV_H
+ #define __TEST_PRIV_H 1
+@@ -136,6 +136,10 @@
+ #include <term.h>
+ #endif
+ 
++#ifdef NCURSES_VERSION
++#define HAVE_COLOR_SET 1
++#endif
++
+ #if NCURSES_NOMACROS
+ #include <nomacros.h>
+ #endif
+@@ -276,12 +280,12 @@
+ #endif
+ 
+ /* out-of-band values for representing absent capabilities */
+-#define ABSENT_BOOLEAN		(-1)		/* 255 */
++#define ABSENT_BOOLEAN		((signed char)-1)	/* 255 */
+ #define ABSENT_NUMERIC		(-1)
+ #define ABSENT_STRING		(char *)0
+ 
+ /* out-of-band values for representing cancels */
+-#define CANCELLED_BOOLEAN	(char)(-2)	/* 254 */
++#define CANCELLED_BOOLEAN	((signed char)-2)	/* 254 */
+ #define CANCELLED_NUMERIC	(-2)
+ #define CANCELLED_STRING	(char *)(-1)
+ 
+Index: test/testcurs.c
+Prereq:  1.32 
+--- ncurses-5.4-20040208/test/testcurs.c	2002-10-19 22:11:24.000000000 +0000
++++ ncurses-5.4-20050319/test/testcurs.c	2004-12-04 16:40:44.000000000 +0000
+@@ -7,7 +7,7 @@
+  *  wrs(5/28/93) -- modified to be consistent (perform identically) with either
+  *                  PDCurses or under Unix System V, R4
+  *
+- * $Id: testcurs.c,v 1.32 2002/10/19 22:11:24 tom Exp $
++ * $Id: testcurs.c,v 1.33 2004/12/04 16:40:44 tom Exp $
+  */
+ 
+ #include <test.priv.h>
+@@ -33,7 +33,7 @@
+ };
+ typedef struct commands COMMAND;
+ 
+-const COMMAND command[] =
++static const COMMAND command[] =
+ {
+     {"General Test", introTest},
+     {"Pad Test", padTest},
+@@ -58,7 +58,7 @@
+ }
+ #endif /* not HAVE_STRDUP */
+ 
+-int width, height;
++static int width, height;
+ 
+ int
+ main(
+@@ -400,7 +400,8 @@
+ 
+     repeat = 0;
+     do {
+-	static const char *fmt[] = {
++	static const char *fmt[] =
++	{
+ 	    "%d %10s",
+ 	    "%d %[a-zA-Z]s",
+ 	    "%d %[][a-zA-Z]s",
+Index: test/tracemunch
+Prereq:  1.3 
+--- ncurses-5.4-20040208/test/tracemunch	2002-09-22 16:31:18.000000000 +0000
++++ ncurses-5.4-20050319/test/tracemunch	2005-03-12 21:48:23.000000000 +0000
+@@ -1,7 +1,7 @@
+ #!/usr/bin/perl -w
+-# $Id: tracemunch,v 1.3 2002/09/22 16:31:18 tom Exp $
++# $Id: tracemunch,v 1.6 2005/03/12 21:48:23 tom Exp $
+ ##############################################################################
+-# Copyright (c) 1998,2002 Free Software Foundation, Inc.                     #
++# Copyright (c) 1998-2002,2005 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"), #
+@@ -32,22 +32,27 @@
+ # The error logs produced by ncurses with tracing enabled can be very tedious
+ # to wade through.  This script helps by compacting runs of log lines that
+ # can be conveniently expressed as higher-level operations.
+-#
++use strict;
+ 
+-$putattr="PutAttrChar\\('(.)' = 0x.., {A_NORMAL}\\) at \\(([0-9]+), ([0-9]+)\\)";
+-$waddnstr="waddnstr\\(0x([0-9a-f]+),\"([^\"]+)\",[0-9]+\\) called {A_NORMAL}";
++our $putattr="PutAttrChar\\({{ '(.)' = 0[0-7]+ }}\\) at \\(([0-9]+), ([0-9]+)\\)";
++our $waddnstr="waddnstr\\(0x([0-9a-f]+),\"([^\"]+)\",[0-9]+\\) called {A_NORMAL}";
+ 
+-$win_nums=0;
++our $win_nums=0;
++our $curscr="";
++our $newscr="";
++our $stdscr="";
++our @win_addr;
+ 
+ sub transaddr
+ {
+-    $arg = $_[0];
++    my $n;
++    my $arg = $_[0];
+ 
+-    $arg =~ s/$curscr/curscr/ if ($curscr);
+-    $arg =~ s/$newscr/newscr/ if ($newscr);
+-    $arg =~ s/$stdscr/stdscr/ if ($stdscr);
++    $arg =~ s/$curscr/curscr/g if ($curscr);
++    $arg =~ s/$newscr/newscr/g if ($newscr);
++    $arg =~ s/$stdscr/stdscr/g if ($stdscr);
+     for $n (0..$#win_addr) {
+-	$arg =~ s/$win_addr[$n]/window$n/ if $win_addr[$n];
++	$arg =~ s/$win_addr[$n]/window$n/g if $win_addr[$n];
+     }
+ 
+     return $arg;
+@@ -55,6 +60,10 @@
+ 
+ while (<STDIN>)
+ {
++	my $addr;
++	my $n;
++	my $awaiting;
++
+ CLASSIFY: {
+ 	# Transform window pointer addresses so it's easier to compare logs
+ 	$awaiting = "curscr" if ($_ =~ /creating curscr/);
+@@ -75,6 +84,7 @@
+ 	    $awaiting = "";
+ 	} elsif ($_ =~ /^\.\.\.deleted win=0x([0-9a-f]+)/) {
+ 	    $addr = "0x$1";
++	    $_ = &transaddr($_);
+ 	    if ($addr eq $curscr) {
+ 		$curscr = "";
+ 	    } elsif ($addr eq $newscr) {
+@@ -93,9 +103,9 @@
+ 	# Compactify runs of PutAttrChar calls (TR_CHARPUT)
+ 	if ($_ =~ /$putattr/)
+ 	{
+-		$putattr_chars = $1;
+-		$starty = $2;
+-		$startx = $3;
++		my $putattr_chars = $1;
++		my $starty = $2;
++		my $startx = $3;
+ 		while (<STDIN>)
+ 		{
+ 			if ($_ =~ /$putattr/) {
+@@ -111,8 +121,8 @@
+ 	# Compactify runs of waddnstr calls (TR_CALLS)
+ 	if ($_ =~ /$waddnstr/)
+ 	{
+-		$waddnstr_chars = $2;
+-		$winaddr = $1;
++		my $waddnstr_chars = $2;
++		my $winaddr = $1;
+ 		while (<STDIN>)
+ 		{
+ 			if ($_ =~ /$waddnstr/ && $1 eq $winaddr) {
+@@ -121,7 +131,7 @@
+ 				last;
+ 			}
+ 		}
+-		$winaddstr = &transaddr($winaddr);
++		my $winaddstr = &transaddr($winaddr);
+ 		print "RUN of waddnstr()s: $winaddr, \"$waddnstr_chars\"\n";
+ 		redo CLASSIFY;
+ 	}
+@@ -129,8 +139,8 @@
+ 	# More transformations can go here
+ 
+ 	# Repeated runs of anything
+-	$anyline = &transaddr($_);
+-	$repeatcount = 1;
++	my $anyline = &transaddr($_);
++	my $repeatcount = 1;
+ 	while (<STDIN>) {
+ 	    if (&transaddr($_) eq $anyline) {
+ 		$repeatcount++;
+Index: test/view.c
+Prereq:  1.57 
+--- ncurses-5.4-20040208/test/view.c	2003-05-17 21:58:43.000000000 +0000
++++ ncurses-5.4-20050319/test/view.c	2004-09-25 20:16:11.000000000 +0000
+@@ -23,13 +23,15 @@
+  * scroll operation worked, and the refresh() code only had to do a
+  * partial repaint.
+  *
+- * $Id: view.c,v 1.57 2003/05/17 21:58:43 tom Exp $
++ * $Id: view.c,v 1.60 2004/09/25 20:16:11 tom Exp $
+  */
+ 
+ #include <time.h>
+ 
+ #include <test.priv.h>
+ 
++#undef CTRL			/* conflict on AIX 5.2 with <sys/ioctl.h> */
++
+ #if HAVE_TERMIOS_H
+ # include <termios.h>
+ #else
+@@ -69,8 +71,9 @@
+ static bool try_color = FALSE;
+ 
+ static char *fname;
+-static NCURSES_CH_T **my_lines;
++static NCURSES_CH_T **vec_lines;
+ static NCURSES_CH_T **lptr;
++static int num_lines;
+ 
+ static void
+ usage(void)
+@@ -164,7 +167,8 @@
+ 	if (setcchar(dst + k, wstr, 0, 0, NULL) == OK)
+ 	    ++k;
+     }
+-    setcchar(dst + k, L"", 0, 0, NULL);
++    wstr[0] = L'\0';
++    setcchar(dst + k, wstr, 0, 0, NULL);
+ #else
+     dst[k] = 0;
+ #endif
+@@ -180,7 +184,6 @@
+     int i;
+     int my_delay = 0;
+     NCURSES_CH_T **olptr;
+-    int length = 0;
+     int value = 0;
+     bool done = FALSE;
+     bool got_number = FALSE;
+@@ -233,7 +236,7 @@
+     if (optind + 1 != argc)
+ 	usage();
+ 
+-    if ((my_lines = typeMalloc(NCURSES_CH_T *, MAXLINES + 2)) == 0)
++    if ((vec_lines = typeMalloc(NCURSES_CH_T *, MAXLINES + 2)) == 0)
+ 	usage();
+ 
+     fname = argv[optind];
+@@ -247,7 +250,7 @@
+ #endif
+ 
+     /* slurp the file */
+-    for (lptr = &my_lines[0]; (lptr - my_lines) < MAXLINES; lptr++) {
++    for (lptr = &vec_lines[0]; (lptr - vec_lines) < MAXLINES; lptr++) {
+ 	char temp[BUFSIZ], *s, *d;
+ 	int col;
+ 
+@@ -280,7 +283,7 @@
+ 	*lptr = ch_dup(temp);
+     }
+     (void) fclose(fp);
+-    length = lptr - my_lines;
++    num_lines = lptr - vec_lines;
+ 
+     (void) initscr();		/* initialize the curses library */
+     keypad(stdscr, TRUE);	/* enable keyboard mapping */
+@@ -300,7 +303,7 @@
+ 	}
+     }
+ 
+-    lptr = my_lines;
++    lptr = vec_lines;
+     while (!done) {
+ 	int n, c;
+ 
+@@ -342,7 +345,7 @@
+ 	case 'n':
+ 	    olptr = lptr;
+ 	    for (i = 0; i < n; i++)
+-		if ((lptr - my_lines) < (length - LINES + 1))
++		if ((lptr - vec_lines) < (num_lines - LINES + 1))
+ 		    lptr++;
+ 		else
+ 		    break;
+@@ -353,7 +356,7 @@
+ 	case 'p':
+ 	    olptr = lptr;
+ 	    for (i = 0; i < n; i++)
+-		if (lptr > my_lines)
++		if (lptr > vec_lines)
+ 		    lptr--;
+ 		else
+ 		    break;
+@@ -362,15 +365,15 @@
+ 
+ 	case 'h':
+ 	case KEY_HOME:
+-	    lptr = my_lines;
++	    lptr = vec_lines;
+ 	    break;
+ 
+ 	case 'e':
+ 	case KEY_END:
+-	    if (length > LINES)
+-		lptr = my_lines + length - LINES + 1;
++	    if (num_lines > LINES)
++		lptr = vec_lines + num_lines - LINES + 1;
+ 	    else
+-		lptr = my_lines;
++		lptr = vec_lines;
+ 	    break;
+ 
+ 	case 'r':
+@@ -428,6 +431,15 @@
+ finish(int sig)
+ {
+     endwin();
++#if NO_LEAKS
++    if (vec_lines != 0) {
++	int n;
++	for (n = 0; n < num_lines; ++n) {
++	    free(vec_lines[n]);
++	}
++	free(vec_lines);
++    }
++#endif
+     ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
+ }
+ 
+@@ -491,7 +503,7 @@
+     scrollok(stdscr, FALSE);	/* prevent screen from moving */
+     for (i = 1; i < LINES; i++) {
+ 	move(i, 0);
+-	printw("%3ld:", (long) (lptr + i - my_lines));
++	printw("%3ld:", (long) (lptr + i - vec_lines));
+ 	clrtoeol();
+ 	if ((s = lptr[i - 1]) != 0) {
+ 	    int len = ch_len(s);
+Index: test/worm.c
+Prereq:  1.37 
+--- ncurses-5.4-20040208/test/worm.c	2002-06-29 23:32:18.000000000 +0000
++++ ncurses-5.4-20050319/test/worm.c	2004-08-07 16:07:52.000000000 +0000
+@@ -34,7 +34,7 @@
+   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.37 2002/06/29 23:32:18 tom Exp $
++  $Id: worm.c,v 1.38 2004/08/07 16:07:52 tom Exp $
+ */
+ 
+ #include <test.priv.h>
+@@ -361,7 +361,7 @@
+ #endif
+ 	    /*
+ 	     * Make it simple to put this into single-step mode, or resume
+-	     * normal operation -TD
++	     * normal operation -T.Dickey
+ 	     */
+ 	    if (ch == 'q') {
+ 		cleanup();
+Index: test/xterm-16color.dat
+--- /dev/null	2004-09-12 00:40:36.000000000 +0000
++++ ncurses-5.4-20050319/test/xterm-16color.dat	2004-05-22 23:14:42.000000000 +0000
+@@ -0,0 +1,26 @@
++# $Id: xterm-16color.dat,v 1.1 2004/05/22 23:14:42 tom Exp $
++# This illustrates the predefined colors for XFree86 xterm's "xterm-16color". 
++# If you set $TERM to "xterm-88color" (and have xterm compiled to support the
++# 88-color or 256-color feature), you can use the ncurses 'd' screen to
++# manipulate the colors shown in the screen.  The 'd' screen is limited to
++# the first 16 colors, and xterm happens to use the same first 16 colors in
++# the extended color models that support initc.
++#
++# The colors shown are for xterm patch #189.
++scale:255
++0:	  0   0   0		black
++1:	205   0	  0		red3
++2:	  0 205	  0		green3
++3:	205 205	  0		yellow3
++4:	 30 144 255		DodgerBlue1
++5:	205   0 205		magenta3
++6:	  0 205 205		cyan3
++7:	229 229 229 		gray90
++8:	127 127 127 		gray50
++9:	255   0   0		red
++10:	  0 255   0		green
++11:	255 255   0		yellow
++12:	 99 184 255		SteelBlue1
++13:	255   0 255		magenta
++14:	  0 255 255		cyan
++15:	255 255 255		white
+Index: test/xterm-88color.dat
+--- /dev/null	2004-09-12 00:40:36.000000000 +0000
++++ ncurses-5.4-20050319/test/xterm-88color.dat	2005-01-28 21:11:53.000000000 +0000
+@@ -0,0 +1,98 @@
++# $Id: xterm-88color.dat,v 1.1 2005/01/28 21:11:53 tom Exp $
++# This illustrates the predefined colors for XFree86 xterm's "xterm-16color". 
++# If you set $TERM to "xterm-88color" (and have xterm compiled to support the
++# 88-color or 256-color feature), you can use the ncurses 'd' screen to
++# manipulate the colors shown in the screen.  The 'd' screen is limited to
++# the first 16 colors, and xterm happens to use the same first 16 colors in
++# the extended color models that support initc.
++#
++# The colors shown are for xterm patch #189.
++scale:255
++0:	  0   0   0		black
++1:	205   0	  0		red3
++2:	  0 205	  0		green3
++3:	205 205	  0		yellow3
++4:	 30 144 255		DodgerBlue1
++5:	205   0 205		magenta3
++6:	  0 205 205		cyan3
++7:	229 229 229 		gray90
++8:	127 127 127 		gray50
++9:	255   0   0		red
++10:	  0 255   0		green
++11:	255 255   0		yellow
++12:	 99 184 255		SteelBlue1
++13:	255   0 255		magenta
++14:	  0 255 255		cyan
++15:	255 255 255		white
++16:	  0   0   0
++17:	  0   0 139
++18:	  0   0 205
++19:	  0   0 255
++20:	  0 139   0
++21:	  0 139 139
++22:	  0 139 205
++23:	  0 139 255
++24:	  0 205   0
++25:	  0 205 139
++26:	  0 205 205
++27:	  0 205 255
++28:	  0 255   0
++29:	  0 255 139
++30:	  0 255 205
++31:	  0 255 255
++32:	139   0   0
++33:	139   0 139
++34:	139   0 205
++35:	139   0 255
++36:	139 139   0
++37:	139 139 139
++38:	139 139 205
++39:	139 139 255
++40:	139 205   0
++41:	139 205 139
++42:	139 205 205
++43:	139 205 255
++44:	139 255   0
++45:	139 255 139
++46:	139 255 205
++47:	139 255 255
++48:	205   0   0
++49:	205   0 139
++50:	205   0 205
++51:	205   0 255
++52:	205 139   0
++53:	205 139 139
++54:	205 139 205
++55:	205 139 255
++56:	205 205   0
++57:	205 205 139
++58:	205 205 205
++59:	205 205 255
++60:	205 255   0
++61:	205 255 139
++62:	205 255 205
++63:	205 255 255
++64:	255   0   0
++65:	255   0 139
++66:	255   0 205
++67:	255   0 255
++68:	255 139   0
++69:	255 139 139
++70:	255 139 205
++71:	255 139 255
++72:	255 205   0
++73:	255 205 139
++74:	255 205 205
++75:	255 205 255
++76:	255 255   0
++77:	255 255 139
++78:	255 255 205
++79:	255 255 255
++80:	 46  46  46
++81:	 92  92  92
++82:	113 113 113
++83:	139 139 139
++84:	162 162 162
++85:	185 185 185
++86:	208 208 208
++87:	231 231 231
diff -Naur ncurses-5.4.orig/panel/llib-lpanel ncurses-5.4/panel/llib-lpanel
--- ncurses-5.4.orig/panel/llib-lpanel	2002-08-31 20:02:07.000000000 +0000
+++ ncurses-5.4/panel/llib-lpanel	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2002 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2002,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 1997,2002                   *
+ *  Author: Thomas E. Dickey        1997,2002,2005                          *
  ****************************************************************************/
 /* LINTLIBRARY */
 
@@ -35,6 +35,11 @@
 
 #include "panel.priv.h"
 
+#undef _nc_retrace_panel
+PANEL	*_nc_retrace_panel(
+		PANEL	*pan)
+		{ return(*(PANEL **)0); }
+
 #undef _nc_my_visbuf
 const char *_nc_my_visbuf(
 		const void *ptr)
diff -Naur ncurses-5.4.orig/panel/llib-lpanelw ncurses-5.4/panel/llib-lpanelw
--- ncurses-5.4.orig/panel/llib-lpanelw	2002-08-31 21:55:11.000000000 +0000
+++ ncurses-5.4/panel/llib-lpanelw	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2002 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2002,2005 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            *
@@ -27,7 +27,7 @@
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Thomas E. Dickey <dickey@clark.net> 2002                        *
+ *  Author: Thomas E. Dickey                    2002,2005                   *
  ****************************************************************************/
 /* LINTLIBRARY */
 
@@ -35,6 +35,11 @@
 
 #include "panel.priv.h"
 
+#undef _nc_retrace_panel
+PANEL	*_nc_retrace_panel(
+		PANEL	*pan)
+		{ return(*(PANEL **)0); }
+
 #undef _nc_my_visbuf
 const char *_nc_my_visbuf(
 		const void *ptr)
diff -Naur ncurses-5.4.orig/panel/p_above.c ncurses-5.4/panel/p_above.c
--- ncurses-5.4.orig/panel/p_above.c	2000-12-10 02:20:44.000000000 +0000
+++ ncurses-5.4/panel/p_above.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -35,17 +35,18 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_above.c,v 1.4 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_above.c,v 1.6 2005/02/19 16:44:57 tom Exp $")
 
 NCURSES_EXPORT(PANEL *)
-panel_above (const PANEL *pan)
+panel_above(const PANEL * pan)
 {
-  if(!pan)
+  T((T_CALLED("panel_above(%p)"), pan));
+  if (!pan)
     {
       /* if top and bottom are equal, we have no or only the pseudo panel;
-	 if not, we return the panel above the pseudo panel */
-      return(EMPTY_STACK() ? (PANEL*)0 : _nc_bottom_panel->above);
+         if not, we return the panel above the pseudo panel */
+      returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_bottom_panel->above);
     }
   else
-    return(pan->above);
+    returnPanel(pan->above);
 }
diff -Naur ncurses-5.4.orig/panel/p_below.c ncurses-5.4/panel/p_below.c
--- ncurses-5.4.orig/panel/p_below.c	2000-12-10 02:20:44.000000000 +0000
+++ ncurses-5.4/panel/p_below.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -35,19 +35,20 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_below.c,v 1.4 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_below.c,v 1.6 2005/02/19 16:45:10 tom Exp $")
 
-NCURSES_EXPORT(PANEL*)
-panel_below (const PANEL *pan)
+NCURSES_EXPORT(PANEL *)
+panel_below(const PANEL * pan)
 {
-  if(!pan)
+  T((T_CALLED("panel_below(%p)"), pan));
+  if (!pan)
     {
       /* if top and bottom are equal, we have no or only the pseudo panel */
-      return(EMPTY_STACK() ? (PANEL*)0 : _nc_top_panel);
+      returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_top_panel);
     }
   else
     {
       /* we must not return the pseudo panel */
-      return(Is_Pseudo(pan->below) ? (PANEL*) 0 : pan->below);
+      returnPanel(Is_Pseudo(pan->below) ? (PANEL *) 0 : pan->below);
     }
 }
diff -Naur ncurses-5.4.orig/panel/p_bottom.c ncurses-5.4/panel/p_bottom.c
--- ncurses-5.4.orig/panel/p_bottom.c	2001-02-24 23:46:33.000000000 +0000
+++ ncurses-5.4/panel/p_bottom.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,35 +36,37 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_bottom.c,v 1.9 2001/02/24 23:46:33 tom Exp $")
+MODULE_ID("$Id: p_bottom.c,v 1.11 2005/02/19 16:38:16 tom Exp $")
 
 NCURSES_EXPORT(int)
-bottom_panel (PANEL *pan)
+bottom_panel(PANEL * pan)
 {
   int err = OK;
 
-  if (pan) {
+  T((T_CALLED("bottom_panel(%p)"), pan));
+  if (pan)
+    {
+      if (!Is_Bottom(pan))
+	{
+
+	  dBug(("--> bottom_panel %s", USER_PTR(pan->user)));
+
+	  HIDE_PANEL(pan, err, OK);
+	  assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
+
+	  dStack("<lb%d>", 1, pan);
+
+	  pan->below = _nc_bottom_panel;
+	  pan->above = _nc_bottom_panel->above;
+	  if (pan->above)
+	    pan->above->below = pan;
+	  _nc_bottom_panel->above = pan;
 
-    if(!Is_Bottom(pan)) {
-      
-      dBug(("--> bottom_panel %s", USER_PTR(pan->user)));
-     
-      HIDE_PANEL(pan,err,OK);
-      assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
-      
-      dStack("<lb%d>",1,pan);      
-      
-      pan->below = _nc_bottom_panel;
-      pan->above = _nc_bottom_panel->above;
-      if (pan->above)
-	pan->above->below = pan;
-      _nc_bottom_panel->above = pan;
-      
-      dStack("<lb%d>",9,pan);
+	  dStack("<lb%d>", 9, pan);
+	}
     }
-  }
   else
     err = ERR;
-  
-  return(err);
+
+  returnCode(err);
 }
diff -Naur ncurses-5.4.orig/panel/p_delete.c ncurses-5.4/panel/p_delete.c
--- ncurses-5.4.orig/panel/p_delete.c	2001-02-24 23:46:41.000000000 +0000
+++ ncurses-5.4/panel/p_delete.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,19 +36,22 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_delete.c,v 1.6 2001/02/24 23:46:41 tom Exp $")
+MODULE_ID("$Id: p_delete.c,v 1.8 2005/02/19 16:38:45 tom Exp $")
 
 NCURSES_EXPORT(int)
-del_panel (PANEL *pan)
+del_panel(PANEL * pan)
 {
   int err = OK;
-  if(pan)
+
+  T((T_CALLED("del_panel(%p)"), pan));
+  if (pan)
     {
       dBug(("--> del_panel %s", USER_PTR(pan->user)));
-      HIDE_PANEL(pan,err,OK);
+      HIDE_PANEL(pan, err, OK);
       free((void *)pan);
     }
   else
     err = ERR;
-  return(err);
+
+  returnCode(err);
 }
diff -Naur ncurses-5.4.orig/panel/p_hidden.c ncurses-5.4/panel/p_hidden.c
--- ncurses-5.4.orig/panel/p_hidden.c	2000-12-10 02:20:44.000000000 +0000
+++ ncurses-5.4/panel/p_hidden.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,12 +36,13 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_hidden.c,v 1.5 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_hidden.c,v 1.7 2005/02/19 16:39:17 tom Exp $")
 
 NCURSES_EXPORT(int)
-panel_hidden (const PANEL *pan)
+panel_hidden(const PANEL * pan)
 {
-  if(!pan)
-    return(ERR);
-  return(IS_LINKED(pan) ? FALSE : TRUE);
-} 
+  T((T_CALLED("panel_hidden(%p)"), pan));
+  if (!pan)
+    returnCode(ERR);
+  returnCode(IS_LINKED(pan) ? FALSE : TRUE);
+}
diff -Naur ncurses-5.4.orig/panel/p_hide.c ncurses-5.4/panel/p_hide.c
--- ncurses-5.4.orig/panel/p_hide.c	2001-02-24 23:46:45.000000000 +0000
+++ ncurses-5.4/panel/p_hide.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,22 +36,23 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_hide.c,v 1.7 2001/02/24 23:46:45 tom Exp $")
+MODULE_ID("$Id: p_hide.c,v 1.9 2005/02/19 16:39:41 tom Exp $")
 
 NCURSES_EXPORT(int)
-hide_panel (register PANEL *pan)
+hide_panel(register PANEL * pan)
 {
   int err = OK;
 
-  if(!pan)
-    return(ERR);
+  T((T_CALLED("hide_panel(%p)"), pan));
+  if (!pan)
+    returnCode(ERR);
 
   dBug(("--> hide_panel %s", USER_PTR(pan->user)));
-  dStack("<u%d>",1,pan);
+  dStack("<u%d>", 1, pan);
 
-  HIDE_PANEL(pan,err,ERR);
+  HIDE_PANEL(pan, err, ERR);
 
-  dStack("<u%d>",9,pan);
+  dStack("<u%d>", 9, pan);
 
-  return(err);
+  returnCode(err);
 }
diff -Naur ncurses-5.4.orig/panel/p_move.c ncurses-5.4/panel/p_move.c
--- ncurses-5.4.orig/panel/p_move.c	2001-02-24 23:41:35.000000000 +0000
+++ ncurses-5.4/panel/p_move.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,21 +36,21 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_move.c,v 1.7 2001/02/24 23:41:35 tom Exp $")
+MODULE_ID("$Id: p_move.c,v 1.9 2005/02/19 16:46:49 tom Exp $")
 
 NCURSES_EXPORT(int)
-move_panel (PANEL *pan, int starty, int startx)
+move_panel(PANEL * pan, int starty, int startx)
 {
-  if(!pan)
-    return(ERR);
+  T((T_CALLED("move_panel(%p,%d,%d)"), pan, starty, startx));
 
-  if (IS_LINKED(pan)) {
-    Touchpan(pan);
-    PANEL_UPDATE(pan,(PANEL*)0);
-  }
+  if (!pan)
+    returnCode(ERR);
 
-  if (mvwin(pan->win,starty,startx))
-    return(ERR);
+  if (IS_LINKED(pan))
+    {
+      Touchpan(pan);
+      PANEL_UPDATE(pan, (PANEL *) 0);
+    }
 
-  return(OK);
+  returnCode(mvwin(pan->win, starty, startx));
 }
diff -Naur ncurses-5.4.orig/panel/p_new.c ncurses-5.4/panel/p_new.c
--- ncurses-5.4.orig/panel/p_new.c	2000-12-10 02:20:44.000000000 +0000
+++ ncurses-5.4/panel/p_new.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,61 +36,65 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_new.c,v 1.6 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_new.c,v 1.8 2005/02/19 16:41:03 tom Exp $")
 
 #ifdef TRACE
-static char* stdscr_id;
-static char* new_id;
+static char *stdscr_id;
+static char *new_id;
 #endif
 
 /*+-------------------------------------------------------------------------
   Get root (i.e. stdscr's) panel.
   Establish the pseudo panel for stdscr if necessary.
 --------------------------------------------------------------------------*/
-static PANEL*
+static PANEL *
 root_panel(void)
 {
-  if(_nc_stdscr_pseudo_panel == (PANEL*)0)
+  if (_nc_stdscr_pseudo_panel == (PANEL *) 0)
     {
-      
+
       assert(stdscr && !_nc_bottom_panel && !_nc_top_panel);
-      _nc_stdscr_pseudo_panel = (PANEL*)malloc(sizeof(PANEL));
-      if (_nc_stdscr_pseudo_panel != 0) {
-	PANEL* pan  = _nc_stdscr_pseudo_panel;
-	WINDOW* win = stdscr;
-	pan->win = win;
-	pan->below   = (PANEL*)0;
-	pan->above   = (PANEL*)0;
+      _nc_stdscr_pseudo_panel = (PANEL *) malloc(sizeof(PANEL));
+      if (_nc_stdscr_pseudo_panel != 0)
+	{
+	  PANEL *pan = _nc_stdscr_pseudo_panel;
+	  WINDOW *win = stdscr;
+
+	  pan->win = win;
+	  pan->below = (PANEL *) 0;
+	  pan->above = (PANEL *) 0;
 #ifdef TRACE
-	if (!stdscr_id)
-	  stdscr_id = strdup("stdscr");
-	pan->user = stdscr_id;
+	  if (!stdscr_id)
+	    stdscr_id = strdup("stdscr");
+	  pan->user = stdscr_id;
 #else
-	pan->user = (void*)0;
+	  pan->user = (void *)0;
 #endif
-	_nc_bottom_panel = _nc_top_panel = pan;
-      }
+	  _nc_bottom_panel = _nc_top_panel = pan;
+	}
     }
   return _nc_stdscr_pseudo_panel;
 }
 
 NCURSES_EXPORT(PANEL *)
-new_panel (WINDOW *win)
+new_panel(WINDOW *win)
 {
-  PANEL *pan = (PANEL*)0;
+  PANEL *pan = (PANEL *) 0;
+
+  T((T_CALLED("new_panel(%p)"), win));
 
   if (!win)
-    return(pan);
+    returnPanel(pan);
 
   if (!_nc_stdscr_pseudo_panel)
     (void)root_panel();
   assert(_nc_stdscr_pseudo_panel);
 
-  if (!(win->_flags & _ISPAD) && (pan = (PANEL*)malloc(sizeof(PANEL))))
+  if (!(win->_flags & _ISPAD) && (pan = (PANEL *) malloc(sizeof(PANEL))))
     {
       pan->win = win;
-      pan->above = (PANEL *)0;
-      pan->below = (PANEL *)0;
+      pan->above = (PANEL *) 0;
+      pan->below = (PANEL *) 0;
 #ifdef TRACE
       if (!new_id)
 	new_id = strdup("new");
@@ -100,5 +104,5 @@
 #endif
       (void)show_panel(pan);
     }
-  return(pan);
+  returnPanel(pan);
 }
diff -Naur ncurses-5.4.orig/panel/p_replace.c ncurses-5.4/panel/p_replace.c
--- ncurses-5.4.orig/panel/p_replace.c	2001-02-24 23:41:38.000000000 +0000
+++ ncurses-5.4/panel/p_replace.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,20 +36,23 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_replace.c,v 1.7 2001/02/24 23:41:38 tom Exp $")
+MODULE_ID("$Id: p_replace.c,v 1.9 2005/02/19 16:41:31 tom Exp $")
 
 NCURSES_EXPORT(int)
-replace_panel (PANEL *pan, WINDOW *win)
+replace_panel(PANEL * pan, WINDOW *win)
 {
-  if(!pan)
-    return(ERR);
+  T((T_CALLED("replace_panel(%p,%p)"), pan, win));
+
+  if (!pan)
+    returnCode(ERR);
+
+  if (IS_LINKED(pan))
+    {
+      Touchpan(pan);
+      PANEL_UPDATE(pan, (PANEL *) 0);
+    }
 
-  if (IS_LINKED(pan)) {
-    Touchpan(pan);
-    PANEL_UPDATE(pan,(PANEL*)0);
-  }
-  
   pan->win = win;
 
-  return(OK);
+  returnCode(OK);
 }
diff -Naur ncurses-5.4.orig/panel/p_show.c ncurses-5.4/panel/p_show.c
--- ncurses-5.4.orig/panel/p_show.c	2001-02-24 23:46:50.000000000 +0000
+++ ncurses-5.4/panel/p_show.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,32 +36,34 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_show.c,v 1.9 2001/02/24 23:46:50 tom Exp $")
+MODULE_ID("$Id: p_show.c,v 1.11 2005/02/19 16:42:02 tom Exp $")
 
 NCURSES_EXPORT(int)
-show_panel (PANEL *pan)
-{ 
+show_panel(PANEL * pan)
+{
   int err = OK;
 
-  if(!pan)
-    return(ERR);
+  T((T_CALLED("show_panel(%p)"), pan));
+
+  if (!pan)
+    returnCode(ERR);
 
   if (Is_Top(pan))
-    return(OK);
+    returnCode(OK);
 
   dBug(("--> show_panel %s", USER_PTR(pan->user)));
 
-  HIDE_PANEL(pan,err,OK);
+  HIDE_PANEL(pan, err, OK);
 
-  dStack("<lt%d>",1,pan);
+  dStack("<lt%d>", 1, pan);
   assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
 
   _nc_top_panel->above = pan;
-  pan->below = _nc_top_panel;  
-  pan->above = (PANEL *)0;
+  pan->below = _nc_top_panel;
+  pan->above = (PANEL *) 0;
   _nc_top_panel = pan;
-  
-  dStack("<lt%d>",9,pan);
 
-  return(OK);
+  dStack("<lt%d>", 9, pan);
+
+  returnCode(OK);
 }
diff -Naur ncurses-5.4.orig/panel/p_top.c ncurses-5.4/panel/p_top.c
--- ncurses-5.4.orig/panel/p_top.c	2000-12-10 02:20:44.000000000 +0000
+++ ncurses-5.4/panel/p_top.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,10 +36,11 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_top.c,v 1.3 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_top.c,v 1.5 2005/02/19 16:42:23 tom Exp $")
 
 NCURSES_EXPORT(int)
-top_panel (PANEL *pan)
+top_panel(PANEL * pan)
 {
-  return(show_panel(pan));
+  T((T_CALLED("top_panel(%p)"), pan));
+  returnCode(show_panel(pan));
 }
diff -Naur ncurses-5.4.orig/panel/p_update.c ncurses-5.4/panel/p_update.c
--- ncurses-5.4.orig/panel/p_update.c	2001-02-24 23:41:42.000000000 +0000
+++ ncurses-5.4/panel/p_update.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,18 +36,19 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_update.c,v 1.7 2001/02/24 23:41:42 tom Exp $")
+MODULE_ID("$Id: p_update.c,v 1.9 2005/02/19 16:49:47 tom Exp $")
 
 NCURSES_EXPORT(void)
-update_panels (void)
+update_panels(void)
 {
   PANEL *pan;
 
+  T((T_CALLED("update_panels()")));
   dBug(("--> update_panels"));
   pan = _nc_bottom_panel;
-  while(pan && pan->above)
+  while (pan && pan->above)
     {
-      PANEL_UPDATE(pan,pan->above);
+      PANEL_UPDATE(pan, pan->above);
       pan = pan->above;
     }
 
@@ -57,4 +58,6 @@
       Wnoutrefresh(pan);
       pan = pan->above;
     }
+
+  returnVoid;
 }
diff -Naur ncurses-5.4.orig/panel/p_user.c ncurses-5.4/panel/p_user.c
--- ncurses-5.4.orig/panel/p_user.c	2000-12-10 02:20:44.000000000 +0000
+++ ncurses-5.4/panel/p_user.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,21 +36,21 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_user.c,v 1.4 2000/12/10 02:20:44 tom Exp $")
+MODULE_ID("$Id: p_user.c,v 1.6 2005/02/19 16:52:44 tom Exp $")
 
 NCURSES_EXPORT(int)
-set_panel_userptr
-(PANEL *pan, NCURSES_CONST void *uptr)
+set_panel_userptr(PANEL * pan, NCURSES_CONST void *uptr)
 {
-  if(!pan)
-    return(ERR);
+  T((T_CALLED("set_panel_userptr(%p,%p)"), pan, uptr));
+  if (!pan)
+    returnCode(ERR);
   pan->user = uptr;
-  return(OK);
+  returnCode(OK);
 }
 
-NCURSES_EXPORT(NCURSES_CONST void*)
-panel_userptr (const PANEL *pan)
+NCURSES_EXPORT(NCURSES_CONST void *)
+panel_userptr(const PANEL * pan)
 {
-  return(pan ? pan->user : (NCURSES_CONST void *)0);
+  T((T_CALLED("panel_userptr(%p)"), pan));
+  returnCVoidPtr(pan ? pan->user : (NCURSES_CONST void *)0);
 }
-
diff -Naur ncurses-5.4.orig/panel/p_win.c ncurses-5.4/panel/p_win.c
--- ncurses-5.4.orig/panel/p_win.c	2000-12-10 02:20:43.000000000 +0000
+++ ncurses-5.4/panel/p_win.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2000,2005 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            *
@@ -36,14 +36,11 @@
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_win.c,v 1.3 2000/12/10 02:20:43 tom Exp $")
+MODULE_ID("$Id: p_win.c,v 1.5 2005/02/19 16:44:16 tom Exp $")
 
 NCURSES_EXPORT(WINDOW *)
-panel_window (const PANEL *pan)
+panel_window(const PANEL * pan)
 {
-  return(pan ? pan->win : (WINDOW *)0);
+  T((T_CALLED("panel_window(%p)"), pan));
+  returnWin(pan ? pan->win : (WINDOW *)0);
 }
-
-
-
-
diff -Naur ncurses-5.4.orig/panel/panel.c ncurses-5.4/panel/panel.c
--- ncurses-5.4.orig/panel/panel.c	2001-02-24 23:17:26.000000000 +0000
+++ ncurses-5.4/panel/panel.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2004,2005 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,37 +34,51 @@
 /* panel.c -- implementation of panels library, some core routines */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: panel.c,v 1.20 2001/02/24 23:17:26 tom Exp $")
+MODULE_ID("$Id: panel.c,v 1.23 2005/02/19 18:04:31 tom Exp $")
 
+/*+-------------------------------------------------------------------------
+	_nc_retrace_panel (pan)
+--------------------------------------------------------------------------*/
+#ifdef TRACE
+NCURSES_EXPORT(PANEL *)
+_nc_retrace_panel(PANEL * pan)
+{
+  T((T_RETURN("%p"), pan));
+  return pan;
+}
+#endif
+
+/*+-------------------------------------------------------------------------
+	_nc_my_visbuf(ptr)
+--------------------------------------------------------------------------*/
 #ifdef TRACE
 #ifndef TRACE_TXT
 NCURSES_EXPORT(const char *)
-_nc_my_visbuf (const void *ptr)
+_nc_my_visbuf(const void *ptr)
 {
-	char temp[32];
-	if (ptr != 0)
-		sprintf(temp, "ptr:%p", ptr);
-	else
-		strcpy(temp, "<null>");
-	return _nc_visbuf(temp);
+  char temp[32];
+
+  if (ptr != 0)
+    sprintf(temp, "ptr:%p", ptr);
+  else
+    strcpy(temp, "<null>");
+  return _nc_visbuf(temp);
 }
 #endif
 #endif
 
-
 /*+-------------------------------------------------------------------------
 	dPanel(text,pan)
 --------------------------------------------------------------------------*/
 #ifdef TRACE
 NCURSES_EXPORT(void)
-_nc_dPanel 
-(const char *text, const PANEL *pan)
+_nc_dPanel(const char *text, const PANEL * pan)
 {
-	_tracef("%s id=%s b=%s a=%s y=%d x=%d",
-		text, USER_PTR(pan->user),
-		(pan->below) ?  USER_PTR(pan->below->user) : "--",
-		(pan->above) ?  USER_PTR(pan->above->user) : "--",
-		PSTARTY(pan), PSTARTX(pan));
+  _tracef("%s id=%s b=%s a=%s y=%d x=%d",
+	  text, USER_PTR(pan->user),
+	  (pan->below) ? USER_PTR(pan->below->user) : "--",
+	  (pan->above) ? USER_PTR(pan->above->user) : "--",
+	  PSTARTY(pan), PSTARTX(pan));
 }
 #endif
 
@@ -73,21 +87,20 @@
 --------------------------------------------------------------------------*/
 #ifdef TRACE
 NCURSES_EXPORT(void)
-_nc_dStack 
-(const char *fmt, int num, const PANEL *pan)
+_nc_dStack(const char *fmt, int num, const PANEL * pan)
 {
   char s80[80];
 
-  sprintf(s80,fmt,num,pan);
-  _tracef("%s b=%s t=%s",s80,
-	  (_nc_bottom_panel) ?  USER_PTR(_nc_bottom_panel->user) : "--",
-	  (_nc_top_panel)    ?  USER_PTR(_nc_top_panel->user)    : "--");
-  if(pan)
+  sprintf(s80, fmt, num, pan);
+  _tracef("%s b=%s t=%s", s80,
+	  (_nc_bottom_panel) ? USER_PTR(_nc_bottom_panel->user) : "--",
+	  (_nc_top_panel) ? USER_PTR(_nc_top_panel->user) : "--");
+  if (pan)
     _tracef("pan id=%s", USER_PTR(pan->user));
   pan = _nc_bottom_panel;
-  while(pan)
+  while (pan)
     {
-      dPanel("stk",pan);
+      dPanel("stk", pan);
       pan = pan->above;
     }
 }
@@ -98,9 +111,9 @@
 --------------------------------------------------------------------------*/
 #ifdef TRACE
 NCURSES_EXPORT(void)
-_nc_Wnoutrefresh (const PANEL *pan)
+_nc_Wnoutrefresh(const PANEL * pan)
 {
-  dPanel("wnoutrefresh",pan);
+  dPanel("wnoutrefresh", pan);
   wnoutrefresh(pan->win);
 }
 #endif
@@ -110,9 +123,9 @@
 --------------------------------------------------------------------------*/
 #ifdef TRACE
 NCURSES_EXPORT(void)
-_nc_Touchpan (const PANEL *pan)
+_nc_Touchpan(const PANEL * pan)
 {
-  dPanel("Touchpan",pan);
+  dPanel("Touchpan", pan);
   touchwin(pan->win);
 }
 #endif
@@ -122,19 +135,23 @@
 --------------------------------------------------------------------------*/
 #ifdef TRACE
 NCURSES_EXPORT(void)
-_nc_Touchline 
-(const PANEL *pan, int start, int count)
+_nc_Touchline(const PANEL * pan, int start, int count)
 {
   char s80[80];
-  sprintf(s80,"Touchline s=%d c=%d",start,count);
-  dPanel(s80,pan);
-  touchline(pan->win,start,count);
+
+  sprintf(s80, "Touchline s=%d c=%d", start, count);
+  dPanel(s80, pan);
+  touchline(pan->win, start, count);
 }
 #endif
 
 #ifndef TRACE
 #  ifndef __GNUC__
      /* Some C compilers need something defined in a source file */
-     void _nc_dummy_panel(void) { }
+extern void _nc_dummy_panel(void);
+void
+_nc_dummy_panel(void)
+{
+}
 #  endif
 #endif
diff -Naur ncurses-5.4.orig/panel/panel.priv.h ncurses-5.4/panel/panel.priv.h
--- ncurses-5.4.orig/panel/panel.priv.h	2001-06-02 23:31:05.000000000 +0000
+++ ncurses-5.4/panel/panel.priv.h	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2000 Free Software Foundation, Inc.                        *
+ * Copyright (c) 1998-2001,2005 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            *
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 
-/* $Id: panel.priv.h,v 1.19 2001/06/02 23:31:05 tom Exp $ */
+/* $Id: panel.priv.h,v 1.20 2005/02/19 17:16:54 tom Exp $ */
 
 #ifndef NCURSES_PANEL_PRIV_H
 #define NCURSES_PANEL_PRIV_H 1
@@ -72,6 +72,9 @@
 #    define USER_PTR(ptr) _nc_my_visbuf((const char *)ptr)
 #  endif
 
+#  define returnPanel(code)	TRACE_RETURN(code,panel)
+
+   extern NCURSES_EXPORT(PANEL *) _nc_retrace_panel (PANEL *);
    extern NCURSES_EXPORT(void) _nc_dPanel (const char*, const PANEL*);
    extern NCURSES_EXPORT(void) _nc_dStack (const char*, int, const PANEL*);
    extern NCURSES_EXPORT(void) _nc_Wnoutrefresh (const PANEL*);
@@ -85,6 +88,7 @@
 #  define Touchpan(pan) _nc_Touchpan(pan)
 #  define Touchline(pan,start,count) _nc_Touchline(pan,start,count)
 #else /* !TRACE */
+#  define returnPanel(code)	return code
 #  define dBug(x)
 #  define dPanel(text,pan)
 #  define dStack(fmt,num,pan)
@@ -98,7 +102,7 @@
 #define _nc_bottom_panel _nc_panelhook()->bottom_panel
 
 #define EMPTY_STACK() (_nc_top_panel==_nc_bottom_panel)
-#define Is_Bottom(p)  (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_bottom_panel->above==(p))) 
+#define Is_Bottom(p)  (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_bottom_panel->above==(p)))
 #define Is_Top(p) (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_top_panel==(p)))
 #define Is_Pseudo(p) ((p) && ((p)==_nc_bottom_panel))
 
@@ -138,9 +142,9 @@
 /*+-------------------------------------------------------------------------
 	Walk through the panel stack starting at the given location and
         check for intersections; overlapping panels are "touched", so they
-        are incrementally overwriting cells that should be hidden. 
+        are incrementally overwriting cells that should be hidden.
         If the "touch" flag is set, the panel gets touched before it is
-        updated. 
+        updated.
 ---------------------------------------------------------------------------*/
 #define PANEL_UPDATE(pan,panstart)\
 {  PANEL* pan2 = ((panstart) ? (panstart) : _nc_bottom_panel);\
diff -Naur ncurses-5.4.orig/progs/Makefile.in ncurses-5.4/progs/Makefile.in
--- ncurses-5.4.orig/progs/Makefile.in	2003-11-01 22:45:57.000000000 +0000
+++ ncurses-5.4/progs/Makefile.in	2005-05-13 04:09:51.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.62 2003/11/01 22:45:57 tom Exp $
+# $Id: Makefile.in,v 1.64 2005/01/22 20:11:48 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2003,2005 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"), #
@@ -95,7 +95,7 @@
 LD		= @LD@
 LINK		= @LINK_PROGS@ $(LIBTOOL_LINK) $(CC)
 LDFLAGS		= @EXTRA_LDFLAGS@ \
-		@PROG_ARGS@ @LDFLAGS@ @LD_MODEL@ @LIBS@ @EXTRA_LIBS@
+		@TINFO_ARGS@ @LDFLAGS@ @LD_MODEL@ @LIBS@
 
 LDFLAGS_LIBTOOL	= $(LDFLAGS) $(CFLAGS_LIBTOOL)
 LDFLAGS_NORMAL	= $(LDFLAGS) $(CFLAGS_NORMAL)
diff -Naur ncurses-5.4.orig/progs/dump_entry.c ncurses-5.4/progs/dump_entry.c
--- ncurses-5.4.orig/progs/dump_entry.c	2003-05-24 22:43:59.000000000 +0000
+++ ncurses-5.4/progs/dump_entry.c	2005-05-13 04:09:59.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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            *
@@ -39,7 +39,7 @@
 #include "termsort.c"		/* this C file is generated */
 #include <parametrized.h>	/* so is this */
 
-MODULE_ID("$Id: dump_entry.c,v 1.66 2003/05/24 22:43:59 tom Exp $")
+MODULE_ID("$Id: dump_entry.c,v 1.69 2005/05/07 20:26:10 tom Exp $")
 
 #define INDENT			8
 #define DISCARD(string) string = ABSENT_STRING
@@ -63,7 +63,7 @@
 static DYNBUF tmpbuf;
 
 /* indirection pointers for implementing sort and display modes */
-static const int *bool_indirect, *num_indirect, *str_indirect;
+static const PredIdx *bool_indirect, *num_indirect, *str_indirect;
 static NCURSES_CONST char *const *bool_names;
 static NCURSES_CONST char *const *num_names;
 static NCURSES_CONST char *const *str_names;
@@ -262,7 +262,7 @@
 static TERMTYPE *cur_type;
 
 static int
-dump_predicate(int type, int idx)
+dump_predicate(PredType type, PredIdx idx)
 /* predicate function to use for ordinary decompilation */
 {
     switch (type) {
@@ -282,7 +282,7 @@
     return (FALSE);		/* pacify compiler */
 }
 
-static void set_obsolete_termcaps(TERMTYPE * tp);
+static void set_obsolete_termcaps(TERMTYPE *tp);
 
 /* is this the index of a function key string? */
 #define FNKEY(i)	(((i)<= 65 && (i)>= 75) || ((i)<= 216 && (i)>= 268))
@@ -296,7 +296,7 @@
 #define STR_IDX(name)  (&(name) - &(CUR Strings[0]))
 
 static bool
-version_filter(int type, int idx)
+version_filter(PredType type, PredIdx idx)
 /* filter out capabilities we may want to suppress */
 {
     switch (tversion) {
@@ -499,20 +499,20 @@
 }
 
 int
-fmt_entry(TERMTYPE * tterm,
-	  int (*pred) (int type, int idx),
+fmt_entry(TERMTYPE *tterm,
+	  PredFunc pred,
 	  bool content_only,
 	  bool suppress_untranslatable,
 	  bool infodump,
 	  int numbers)
 {
-    int i, j;
+    PredIdx i, j;
     char buffer[MAX_TERMINFO_LENGTH];
     NCURSES_CONST char *name;
     int predval, len;
-    int num_bools = 0;
-    int num_values = 0;
-    int num_strings = 0;
+    PredIdx num_bools = 0;
+    PredIdx num_values = 0;
+    PredIdx num_strings = 0;
     bool outcount = 0;
 
 #define WRAP_CONCAT	\
@@ -613,6 +613,15 @@
 	else if (isObsolete(outform, name))
 	    continue;
 
+#if NCURSES_XNAMES
+	/*
+	 * Extended names can be longer than 2 characters, but termcap programs
+	 * cannot read those (filter them out).
+	 */
+	if (outform == F_TERMCAP && (strlen(name) > 2))
+	    continue;
+#endif
+
 	/*
 	 * Some older versions of vi want rmir/smir to be defined
 	 * for ich/ich1 to work.  If they're not defined, force
@@ -786,7 +795,7 @@
 }
 
 static bool
-kill_string(TERMTYPE * tterm, char *cap)
+kill_string(TERMTYPE *tterm, char *cap)
 {
     int n;
     for (n = 0; n < NUM_STRINGS(tterm); ++n) {
@@ -799,9 +808,9 @@
 }
 
 static char *
-find_string(TERMTYPE * tterm, char *name)
+find_string(TERMTYPE *tterm, char *name)
 {
-    int n;
+    PredIdx n;
     for (n = 0; n < NUM_STRINGS(tterm); ++n) {
 	if (version_filter(STRING, n)
 	    && !strcmp(name, strnames[n])) {
@@ -820,7 +829,7 @@
  * make it smaller.
  */
 static int
-kill_labels(TERMTYPE * tterm, int target)
+kill_labels(TERMTYPE *tterm, int target)
 {
     int n;
     int result = 0;
@@ -845,7 +854,7 @@
  * make it smaller.
  */
 static int
-kill_fkeys(TERMTYPE * tterm, int target)
+kill_fkeys(TERMTYPE *tterm, int target)
 {
     int n;
     int result = 0;
@@ -874,12 +883,12 @@
 #define SHOW_WHY if (!already_used) PRINTF
 
 int
-dump_entry(TERMTYPE * tterm,
+dump_entry(TERMTYPE *tterm,
 	   bool suppress_untranslatable,
 	   bool limited,
 	   int already_used,
 	   int numbers,
-	   int (*pred) (int type, int idx))
+	   PredFunc pred)
 /* dump a single entry */
 {
     int len, critlen;
@@ -915,6 +924,29 @@
 	    char *oldacsc = acs_chars;
 	    bool changed = FALSE;
 
+#if NCURSES_XNAMES
+	    /*
+	     * Extended names are most likely function-key definitions.  Drop
+	     * those first.
+	     */
+	    int n;
+	    for (n = STRCOUNT; n < NUM_STRINGS(tterm); n++) {
+		char *name = ExtStrname(tterm, n, strnames);
+
+		if (VALID_STRING(tterm->Strings[n])) {
+		    set_attributes = ABSENT_STRING;
+		    /* we remove long names anyway - only report the short */
+		    if (strlen(name) <= 2) {
+			SHOW_WHY("# (%s removed to fit entry within %d bytes)\n",
+				 name,
+				 critlen);
+		    }
+		    changed = TRUE;
+		    if ((len = FMT_ENTRY()) <= critlen)
+			break;
+		}
+	    }
+#endif
 	    if (VALID_STRING(set_attributes)) {
 		set_attributes = ABSENT_STRING;
 		SHOW_WHY("# (sgr removed to fit entry within %d bytes)\n",
@@ -982,11 +1014,12 @@
 }
 
 void
-compare_entry(void (*hook) (int t, int i, const char *name), TERMTYPE * tp
-	      GCC_UNUSED, bool quiet)
+compare_entry(void (*hook) (PredType t, PredIdx i, const char *name),
+	      TERMTYPE *tp GCC_UNUSED,
+	      bool quiet)
 /* compare two entries */
 {
-    int i, j;
+    PredIdx i, j;
     NCURSES_CONST char *name;
 
     if (!quiet)
@@ -1041,7 +1074,7 @@
 #define CUR tp->
 
 static void
-set_obsolete_termcaps(TERMTYPE * tp)
+set_obsolete_termcaps(TERMTYPE *tp)
 {
 #include "capdefaults.c"
 }
@@ -1051,7 +1084,7 @@
  * unique.
  */
 void
-repair_acsc(TERMTYPE * tp)
+repair_acsc(TERMTYPE *tp)
 {
     if (VALID_STRING(acs_chars)) {
 	size_t n, m;
diff -Naur ncurses-5.4.orig/progs/dump_entry.h ncurses-5.4/progs/dump_entry.h
--- ncurses-5.4.orig/progs/dump_entry.h	2002-08-11 00:19:45.000000000 +0000
+++ ncurses-5.4/progs/dump_entry.h	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,1999 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2002,2004 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,13 +29,19 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 
 /*
+ * $Id: dump_entry.h,v 1.27 2004/12/04 15:37:17 tom Exp $
+ *
  * Dump control definitions and variables
  */
 
+#ifndef DUMP_ENTRY_H
+#define DUMP_ENTRY_H 1
+
 /* capability output formats */
 #define F_TERMINFO	0	/* use terminfo names */
 #define F_VARIABLE	1	/* use C variable names */
@@ -56,12 +62,18 @@
 #define CMP_STRING	2	/* comparison on strings */
 #define CMP_USE		3	/* comparison on use capabilities */
 
+typedef unsigned PredType;
+typedef int PredIdx;
+typedef int (*PredFunc)(PredType, PredIdx);
+
 extern NCURSES_CONST char *nametrans(const char *);
 extern void dump_init(const char *, int, int, int, int, bool);
-extern int fmt_entry(TERMTYPE *, int (*)(int, int), bool, bool, bool, int);
-extern int dump_entry(TERMTYPE *, bool, bool, int, int, int (*)(int, int));
+extern int fmt_entry(TERMTYPE *, PredFunc, bool, bool, bool, int);
+extern int dump_entry(TERMTYPE *, bool, bool, int, int, PredFunc);
 extern int dump_uses(const char *, bool);
-extern void compare_entry(void (*)(int, int, const char *), TERMTYPE *, bool);
+extern void compare_entry(void (*)(PredType, PredIdx, const char *), TERMTYPE *, bool);
 extern void repair_acsc(TERMTYPE * tp);
 
 #define FAIL	-1
+
+#endif /* DUMP_ENTRY_H */
diff -Naur ncurses-5.4.orig/progs/infocmp.c ncurses-5.4/progs/infocmp.c
--- ncurses-5.4.orig/progs/infocmp.c	2003-10-18 18:01:54.000000000 +0000
+++ ncurses-5.4/progs/infocmp.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -41,7 +42,7 @@
 #include <term_entry.h>
 #include <dump_entry.h>
 
-MODULE_ID("$Id: infocmp.c,v 1.71 2003/10/18 18:01:54 tom Exp $")
+MODULE_ID("$Id: infocmp.c,v 1.78 2005/04/16 16:58:16 tom Exp $")
 
 #define L_CURL "{"
 #define R_CURL "}"
@@ -66,6 +67,7 @@
 
 static bool limited = TRUE;	/* "-r" option is not set */
 static bool quiet = FALSE;
+static bool literal = FALSE;
 static const char *bool_sep = ":";
 static const char *s_absent = "NULL";
 static const char *s_cancel = "NULL";
@@ -87,11 +89,10 @@
 
 #if NO_LEAKS
 #undef ExitProgram
-static void
-ExitProgram(int code) GCC_NORETURN;
+static void ExitProgram(int code) GCC_NORETURN;
 /* prototype is to get gcc to accept the noreturn attribute */
-     static void
-       ExitProgram(int code)
+static void
+ExitProgram(int code)
 {
     while (termcount-- > 0)
 	_nc_free_termtype(&entries[termcount].tterm);
@@ -120,7 +121,7 @@
  ***************************************************************************/
 
 static int
-capcmp(unsigned idx, const char *s, const char *t)
+capcmp(PredIdx idx, const char *s, const char *t)
 /* capability comparison function */
 {
     if (!VALID_STRING(s) && !VALID_STRING(t))
@@ -135,7 +136,7 @@
 }
 
 static int
-use_predicate(int type, int idx)
+use_predicate(unsigned type, PredIdx idx)
 /* predicate function to use for use decompilation */
 {
     ENTRY *ep;
@@ -245,7 +246,7 @@
 }
 
 static bool
-entryeq(TERMTYPE * t1, TERMTYPE * t2)
+entryeq(TERMTYPE *t1, TERMTYPE *t2)
 /* are two entries equivalent? */
 {
     unsigned i;
@@ -259,7 +260,7 @@
 	    return (FALSE);
 
     for (i = 0; i < NUM_STRINGS(t1); i++)
-	if (capcmp(i, t1->Strings[i], t2->Strings[i]))
+	if (capcmp((PredIdx) i, t1->Strings[i], t2->Strings[i]))
 	    return (FALSE);
 
     return (TRUE);
@@ -332,7 +333,7 @@
 }
 
 static void
-compare_predicate(int type, int idx, const char *name)
+compare_predicate(PredType type, PredIdx idx, const char *name)
 /* predicate function to use for entry difference reports */
 {
     register ENTRY *e1 = &entries[0];
@@ -474,14 +475,26 @@
     {"\033)A", "ISO UK G1"},	/* enable UK chars for G1 */
     {"\033)B", "ISO US G1"},	/* enable US chars for G1 */
 
-    /* these are DEC private modes widely supported by emulators */
+    /* these are DEC private controls widely supported by emulators */
     {"\033=", "DECPAM"},	/* application keypad mode */
     {"\033>", "DECPNM"},	/* normal keypad mode */
     {"\033<", "DECANSI"},	/* enter ANSI mode */
+    {"\033[!p", "DECSTR"},	/* soft reset */
+    {"\033 F", "S7C1T"},	/* 7-bit controls */
 
     {(char *) 0, (char *) 0}
 };
 
+static const assoc std_modes[] =
+/* ECMA \E[ ... [hl] modes recognized by many emulators */
+{
+    {"2", "AM"},		/* keyboard action mode */
+    {"4", "IRM"},		/* insert/replace mode */
+    {"12", "SRM"},		/* send/receive mode */
+    {"20", "LNM"},		/* linefeed mode */
+    {(char *) 0, (char *) 0}
+};
+
 static const assoc private_modes[] =
 /* DEC \E[ ... [hl] modes recognized by many emulators */
 {
@@ -532,13 +545,25 @@
     {(char *) 0, (char *) 0}
 };
 
+static int
+skip_csi(const char *cap)
+{
+    int result = 0;
+    if (cap[0] == '\033' && cap[1] == '[')
+	result = 2;
+    else if (UChar(cap[0]) == 0233)
+	result = 1;
+    return result;
+}
+
 static void
-analyze_string(const char *name, const char *cap, TERMTYPE * tp)
+analyze_string(const char *name, const char *cap, TERMTYPE *tp)
 {
     char buf[MAX_TERMINFO_LENGTH];
     char buf2[MAX_TERMINFO_LENGTH];
     const char *sp, *ep;
     const assoc *ap;
+    int tp_lines = tp->Numbers[2];
 
     if (cap == ABSENT_STRING || cap == CANCELLED_STRING)
 	return;
@@ -547,6 +572,7 @@
     buf[0] = '\0';
     for (sp = cap; *sp; sp++) {
 	int i;
+	int csi;
 	size_t len = 0;
 	const char *expansion = 0;
 
@@ -586,26 +612,68 @@
 	}
 
 	/* now check the standard capabilities */
-	if (!expansion)
+	if (!expansion) {
+	    csi = skip_csi(sp);
 	    for (ap = std_caps; ap->from; ap++) {
-		len = strlen(ap->from);
+		size_t adj = csi ? 2 : 0;
 
-		if (strncmp(ap->from, sp, len) == 0) {
+		len = strlen(ap->from);
+		if (len > adj
+		    && strncmp(ap->from + adj, sp + csi, len - adj) == 0) {
 		    expansion = ap->to;
+		    len -= adj;
+		    len += csi;
 		    break;
 		}
 	    }
+	}
+
+	/* now check for standard-mode sequences */
+	if (!expansion
+	    && (csi = skip_csi(sp)) != 0
+	    && (len = strspn(sp + csi, "0123456789;"))
+	    && ((sp[csi + len] == 'h') || (sp[csi + len] == 'l'))) {
+	    char buf3[MAX_TERMINFO_LENGTH];
+
+	    (void) strcpy(buf2, (sp[csi + len] == 'h') ? "ECMA+" : "ECMA-");
+	    (void) strncpy(buf3, sp + csi, len);
+	    len += csi + 1;
+	    buf3[len] = '\0';
+
+	    ep = strtok(buf3, ";");
+	    do {
+		bool found = FALSE;
+
+		for (ap = std_modes; ap->from; ap++) {
+		    size_t tlen = strlen(ap->from);
+
+		    if (strncmp(ap->from, ep, tlen) == 0) {
+			(void) strcat(buf2, ap->to);
+			found = TRUE;
+			break;
+		    }
+		}
+
+		if (!found)
+		    (void) strcat(buf2, ep);
+		(void) strcat(buf2, ";");
+	    } while
+		((ep = strtok((char *) 0, ";")));
+	    buf2[strlen(buf2) - 1] = '\0';
+	    expansion = buf2;
+	}
 
 	/* now check for private-mode sequences */
 	if (!expansion
-	    && sp[0] == '\033' && sp[1] == '[' && sp[2] == '?'
-	    && (len = strspn(sp + 3, "0123456789;"))
-	    && ((sp[3 + len] == 'h') || (sp[3 + len] == 'l'))) {
+	    && (csi = skip_csi(sp)) != 0
+	    && sp[csi] == '?'
+	    && (len = strspn(sp + csi + 1, "0123456789;"))
+	    && ((sp[csi + 1 + len] == 'h') || (sp[csi + 1 + len] == 'l'))) {
 	    char buf3[MAX_TERMINFO_LENGTH];
 
-	    (void) strcpy(buf2, (sp[3 + len] == 'h') ? "DEC+" : "DEC-");
-	    (void) strncpy(buf3, sp + 3, len);
-	    len += 4;
+	    (void) strcpy(buf2, (sp[csi + 1 + len] == 'h') ? "DEC+" : "DEC-");
+	    (void) strncpy(buf3, sp + csi + 1, len);
+	    len += csi + 2;
 	    buf3[len] = '\0';
 
 	    ep = strtok(buf3, ";");
@@ -633,14 +701,14 @@
 
 	/* now check for ECMA highlight sequences */
 	if (!expansion
-	    && sp[0] == '\033' && sp[1] == '['
-	    && (len = strspn(sp + 2, "0123456789;"))
-	    && sp[2 + len] == 'm') {
+	    && (csi = skip_csi(sp)) != 0
+	    && (len = strspn(sp + csi, "0123456789;")) != 0
+	    && sp[csi + len] == 'm') {
 	    char buf3[MAX_TERMINFO_LENGTH];
 
 	    (void) strcpy(buf2, "SGR:");
-	    (void) strncpy(buf3, sp + 2, len);
-	    len += 3;
+	    (void) strncpy(buf3, sp + csi, len);
+	    len += csi + 1;
 	    buf3[len] = '\0';
 
 	    ep = strtok(buf3, ";");
@@ -666,20 +734,46 @@
 	    buf2[strlen(buf2) - 1] = '\0';
 	    expansion = buf2;
 	}
+
+	if (!expansion
+	    && (csi = skip_csi(sp)) != 0
+	    && sp[csi] == 'm') {
+	    len = csi + 1;
+	    (void) strcpy(buf2, "SGR:");
+	    strcat(buf2, ecma_highlights[0].to);
+	    expansion = buf2;
+	}
+
 	/* now check for scroll region reset */
-	if (!expansion) {
-	    (void) sprintf(buf2, "\033[1;%dr", tp->Numbers[2]);
-	    len = strlen(buf2);
-	    if (strncmp(buf2, sp, len) == 0)
+	if (!expansion
+	    && (csi = skip_csi(sp)) != 0) {
+	    if (sp[csi] == 'r') {
 		expansion = "RSR";
+		len = 1;
+	    } else {
+		(void) sprintf(buf2, "1;%dr", tp_lines);
+		len = strlen(buf2);
+		if (strncmp(buf2, sp + csi, len) == 0)
+		    expansion = "RSR";
+	    }
+	    len += csi;
 	}
 
 	/* now check for home-down */
-	if (!expansion) {
-	    (void) sprintf(buf2, "\033[%d;1H", tp->Numbers[2]);
+	if (!expansion
+	    && (csi = skip_csi(sp)) != 0) {
+	    (void) sprintf(buf2, "%d;1H", tp_lines);
 	    len = strlen(buf2);
-	    if (strncmp(buf2, sp, len) == 0)
+	    if (strncmp(buf2, sp + csi, len) == 0) {
 		expansion = "LL";
+	    } else {
+		(void) sprintf(buf2, "%dH", tp_lines);
+		len = strlen(buf2);
+		if (strncmp(buf2, sp + csi, len) == 0) {
+		    expansion = "LL";
+		}
+	    }
+	    len += csi;
 	}
 
 	/* now look at the expansion we got, if any */
@@ -723,13 +817,13 @@
 
 	/* parse entries out of the source file */
 	_nc_set_source(argv[n]);
-	_nc_read_entry_source(stdin, NULL, TRUE, FALSE, NULLHOOK);
+	_nc_read_entry_source(stdin, NULL, TRUE, literal, NULLHOOK);
 
 	if (itrace)
 	    (void) fprintf(stderr, "Resolving file %d...\n", n - 0);
 
 	/* maybe do use resolution */
-	if (!_nc_resolve_uses(!limited)) {
+	if (!_nc_resolve_uses2(!limited, literal)) {
 	    (void) fprintf(stderr,
 			   "There are unresolved use entries in %s:\n",
 			   argv[n]);
@@ -898,6 +992,7 @@
 	,"  -L    use long names"
 	,"  -R subset (see manpage)"
 	,"  -T    eliminate size limits (test)"
+	,"  -U    eliminate post-processing of entries"
 	,"  -V    print version"
 #if NCURSES_XNAMES
 	,"  -a    with -F, list commented-out caps"
@@ -923,6 +1018,9 @@
 	,"  -u    produce source with 'use='"
 	,"  -v number  (verbose)"
 	,"  -w number  (width)"
+#if NCURSES_XNAMES
+	,"  -x    treat unknown capabilities as user-defined"
+#endif
     };
     const size_t first = 3;
     const size_t last = SIZEOF(tbl);
@@ -973,7 +1071,7 @@
 
 /* dump C initializers for the terminal type */
 static void
-dump_initializers(TERMTYPE * term)
+dump_initializers(TERMTYPE *term)
 {
     unsigned n;
     int size;
@@ -1030,7 +1128,7 @@
 	    str = "CANCELLED_BOOLEAN";
 	    break;
 	}
-	(void) printf("\t/* %3d: %-8s */\t%s,\n",
+	(void) printf("\t/* %3u: %-8s */\t%s,\n",
 		      n, ExtBoolname(term, n, boolnames), str);
     }
     (void) printf("%s;\n", R_CURL);
@@ -1051,14 +1149,14 @@
 	    str = buf;
 	    break;
 	}
-	(void) printf("\t/* %3d: %-8s */\t%s,\n", n,
+	(void) printf("\t/* %3u: %-8s */\t%s,\n", n,
 		      ExtNumname(term, n, numnames), str);
     }
     (void) printf("%s;\n", R_CURL);
 
-    size = sizeof(TERMTYPE)
-	+ (NUM_BOOLEANS(term) * sizeof(term->Booleans[0]))
-	+ (NUM_NUMBERS(term) * sizeof(term->Numbers[0]));
+    size = (sizeof(TERMTYPE)
+	    + (NUM_BOOLEANS(term) * sizeof(term->Booleans[0]))
+	    + (NUM_NUMBERS(term) * sizeof(term->Numbers[0])));
 
     (void) printf("static char * %s[] = %s\n", name_initializer("string"), L_CURL);
 
@@ -1071,7 +1169,7 @@
 	else {
 	    str = string_variable(ExtStrname(term, n, strnames));
 	}
-	(void) printf("\t/* %3d: %-8s */\t%s,\n", n,
+	(void) printf("\t/* %3u: %-8s */\t%s,\n", n,
 		      ExtStrname(term, n, strnames), str);
     }
     (void) printf("%s;\n", R_CURL);
@@ -1083,15 +1181,15 @@
 	(void) printf("static char * %s[] = %s\n",
 		      name_initializer("string_ext"), L_CURL);
 	for (n = BOOLCOUNT; n < NUM_BOOLEANS(term); ++n) {
-	    (void) printf("\t/* %3d: bool */\t\"%s\",\n",
+	    (void) printf("\t/* %3u: bool */\t\"%s\",\n",
 			  n, ExtBoolname(term, n, boolnames));
 	}
 	for (n = NUMCOUNT; n < NUM_NUMBERS(term); ++n) {
-	    (void) printf("\t/* %3d: num */\t\"%s\",\n",
+	    (void) printf("\t/* %3u: num */\t\"%s\",\n",
 			  n, ExtNumname(term, n, numnames));
 	}
 	for (n = STRCOUNT; n < NUM_STRINGS(term); ++n) {
-	    (void) printf("\t/* %3d: str */\t\"%s\",\n",
+	    (void) printf("\t/* %3u: str */\t\"%s\",\n",
 			  n, ExtStrname(term, n, strnames));
 	}
 	(void) printf("%s;\n", R_CURL);
@@ -1101,7 +1199,7 @@
 
 /* dump C initializers for the terminal type */
 static void
-dump_termtype(TERMTYPE * term)
+dump_termtype(TERMTYPE *term)
 {
     (void) printf("\t%s\n\t\t%s,\n", L_CURL, name_initializer("alias"));
     (void) printf("\t\t(char *)0,\t/* pointer to string table */\n");
@@ -1186,9 +1284,13 @@
     /* where is the terminfo database location going to default to? */
     restdir = firstdir = 0;
 
+#if NCURSES_XNAMES
+    use_extended_names(FALSE);
+#endif
+
     while ((c = getopt(argc,
 		       argv,
-		       "1A:aB:CcdEeFfGgIiLlnpqR:rs:TtuVv:w:")) != EOF)
+		       "1A:aB:CcdEeFfGgIiLlnpqR:rs:TtUuVv:w:x")) != EOF)
 	switch (c) {
 	case '1':
 	    mwidth = 0;
@@ -1319,6 +1421,10 @@
 	    break;
 #endif
 
+	case 'U':
+	    literal = TRUE;
+	    break;
+
 	case 'u':
 	    compare = C_USEALL;
 	    break;
@@ -1336,6 +1442,12 @@
 	    mwidth = optarg_to_number();
 	    break;
 
+#if NCURSES_XNAMES
+	case 'x':
+	    use_extended_names(TRUE);
+	    break;
+#endif
+
 	default:
 	    usage();
 	}
diff -Naur ncurses-5.4.orig/progs/tic.c ncurses-5.4/progs/tic.c
--- ncurses-5.4.orig/progs/tic.c	2003-12-06 17:36:57.000000000 +0000
+++ ncurses-5.4/progs/tic.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2003,2004 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,20 +45,46 @@
 #include <term_entry.h>
 #include <transform.h>
 
-MODULE_ID("$Id: tic.c,v 1.109 2003/12/06 17:36:57 tom Exp $")
+MODULE_ID("$Id: tic.c,v 1.117 2004/12/04 15:35:59 tom Exp $")
 
 const char *_nc_progname = "tic";
 
 static FILE *log_fp;
 static FILE *tmp_fp;
+static bool capdump = FALSE;	/* running as infotocap? */
+static bool infodump = FALSE;	/* running as captoinfo? */
 static bool showsummary = FALSE;
 static const char *to_remove;
-static int tparm_errs;
 
-static void (*save_check_termtype) (TERMTYPE *);
-static void check_termtype(TERMTYPE * tt);
+static void (*save_check_termtype) (TERMTYPE *, bool);
+static void check_termtype(TERMTYPE *tt, bool);
 
-static const char usage_string[] = "[-V] [-v[n]] [-e names] [-o dir] [-R name] [-CILNTcfrswx1] source-file\n";
+static const char usage_string[] = "\
+[-e names] \
+[-o dir] \
+[-R name] \
+[-v[n]] \
+[-V] \
+[-w[n]] \
+[-\
+1\
+a\
+C\
+c\
+f\
+G\
+g\
+I\
+L\
+N\
+r\
+s\
+T\
+t\
+U\
+x\
+] \
+source-file\n";
 
 static void
 cleanup(void)
@@ -109,6 +135,7 @@
 #if NCURSES_XNAMES
 	"  -t         suppress commented-out capabilities",
 #endif
+	"  -U         suppress post-processing of entries",
 	"  -V         print version",
 	"  -v[n]      set verbosity level",
 	"  -w[n]      set format width for translation output",
@@ -381,7 +408,7 @@
     if (showsummary) {
 	fprintf(log_fp, "Entries that will be compiled:\n");
 	for (n = 0; dst[n] != 0; n++)
-	    fprintf(log_fp, "%d:%s\n", n + 1, dst[n]);
+	    fprintf(log_fp, "%u:%s\n", n + 1, dst[n]);
     }
     return dst;
 }
@@ -436,9 +463,8 @@
 
     int width = 60;
     bool formatted = FALSE;	/* reformat complex strings? */
+    bool literal = FALSE;	/* suppress post-processing? */
     int numbers = 0;		/* format "%'char'" to/from "%{number}" */
-    bool infodump = FALSE;	/* running as captoinfo? */
-    bool capdump = FALSE;	/* running as infotocap? */
     bool forceresolve = FALSE;	/* force resolution */
     bool limited = TRUE;
     char *tversion = (char *) NULL;
@@ -470,7 +496,7 @@
      * be optional.
      */
     while ((this_opt = getopt(argc, argv,
-			      "0123456789CILNR:TVace:fGgo:rstvwx")) != EOF) {
+			      "0123456789CILNR:TUVace:fGgo:rstvwx")) != EOF) {
 	if (isdigit(this_opt)) {
 	    switch (last_opt) {
 	    case 'v':
@@ -505,6 +531,7 @@
 	    break;
 	case 'N':
 	    smart_defaults = FALSE;
+	    literal = TRUE;
 	    break;
 	case 'R':
 	    tversion = optarg;
@@ -512,6 +539,9 @@
 	case 'T':
 	    limited = FALSE;
 	    break;
+	case 'U':
+	    literal = TRUE;
+	    break;
 	case 'V':
 	    puts(curses_version());
 	    return EXIT_SUCCESS;
@@ -567,8 +597,8 @@
     set_trace_level(debug_level);
 
     if (_nc_tracing) {
-	save_check_termtype = _nc_check_termtype;
-	_nc_check_termtype = check_termtype;
+	save_check_termtype = _nc_check_termtype2;
+	_nc_check_termtype2 = check_termtype;
     }
 #if !HAVE_BIG_CORE
     /*
@@ -585,7 +615,7 @@
 	(void) fprintf(stderr,
 		       "Sorry, -e can't be used without -I or -C\n");
 	cleanup();
-	return EXIT_FAILURE;
+	ExitProgram(EXIT_FAILURE);
     }
 #endif /* HAVE_BIG_CORE */
 
@@ -597,7 +627,7 @@
 		    _nc_progname,
 		    _nc_progname,
 		    usage_string);
-	    return EXIT_FAILURE;
+	    ExitProgram(EXIT_FAILURE);
 	}
     } else {
 	if (infodump == TRUE) {
@@ -628,7 +658,7 @@
 		    _nc_progname,
 		    usage_string);
 	    cleanup();
-	    return EXIT_FAILURE;
+	    ExitProgram(EXIT_FAILURE);
 	}
     }
 
@@ -653,14 +683,16 @@
 	_nc_set_writedir(outdir);
 #endif /* HAVE_BIG_CORE */
     _nc_read_entry_source(tmp_fp, (char *) NULL,
-			  !smart_defaults, FALSE,
-			  (check_only || infodump || capdump) ? NULLHOOK : immedhook);
+			  !smart_defaults || literal, FALSE,
+			  ((check_only || infodump || capdump)
+			   ? NULLHOOK
+			   : immedhook));
 
     /* do use resolution */
     if (check_only || (!infodump && !capdump) || forceresolve) {
-	if (!_nc_resolve_uses(TRUE) && !check_only) {
+	if (!_nc_resolve_uses2(TRUE, literal) && !check_only) {
 	    cleanup();
-	    return EXIT_FAILURE;
+	    ExitProgram(EXIT_FAILURE);
 	}
     }
 
@@ -754,7 +786,7 @@
 	    fprintf(log_fp, "No entries written\n");
     }
     cleanup();
-    return (EXIT_SUCCESS);
+    ExitProgram(EXIT_SUCCESS);
 }
 
 /*
@@ -772,7 +804,7 @@
  * Check if the alternate character-set capabilities are consistent.
  */
 static void
-check_acs(TERMTYPE * tp)
+check_acs(TERMTYPE *tp)
 {
     if (VALID_STRING(acs_chars)) {
 	const char *boxes = "lmkjtuvwqxn";
@@ -808,7 +840,7 @@
  * Check if the color capabilities are consistent
  */
 static void
-check_colors(TERMTYPE * tp)
+check_colors(TERMTYPE *tp)
 {
     if ((max_colors > 0) != (max_pairs > 0)
 	|| ((max_colors > max_pairs) && (initialize_pair == 0)))
@@ -821,12 +853,12 @@
 
     if (VALID_STRING(set_foreground)
 	&& VALID_STRING(set_a_foreground)
-	&& !strcmp(set_foreground, set_a_foreground))
+	&& !_nc_capcmp(set_foreground, set_a_foreground))
 	_nc_warning("expected setf/setaf to be different");
 
     if (VALID_STRING(set_background)
 	&& VALID_STRING(set_a_background)
-	&& !strcmp(set_background, set_a_background))
+	&& !_nc_capcmp(set_background, set_a_background))
 	_nc_warning("expected setb/setab to be different");
 
     /* see: has_colors() */
@@ -877,7 +909,7 @@
  * is mapped inconsistently.
  */
 static void
-check_keypad(TERMTYPE * tp)
+check_keypad(TERMTYPE *tp)
 {
     char show[80];
 
@@ -1075,7 +1107,7 @@
  * markers.
  */
 static void
-check_params(TERMTYPE * tp, const char *name, char *value)
+check_params(TERMTYPE *tp, const char *name, char *value)
 {
     int expected = expected_params(name);
     int actual = 0;
@@ -1200,20 +1232,22 @@
     return TRUE;
 }
 
-static void
-check_sgr(TERMTYPE * tp, char *zero, int num, char *cap, const char *name)
+static char *
+check_sgr(TERMTYPE *tp, char *zero, int num, char *cap, const char *name)
 {
-    char *test = tparm(set_attributes,
-		       num == 1,
-		       num == 2,
-		       num == 3,
-		       num == 4,
-		       num == 5,
-		       num == 6,
-		       num == 7,
-		       num == 8,
-		       num == 9);
-    tparm_errs += _nc_tparm_err;
+    char *test;
+
+    _nc_tparm_err = 0;
+    test = tparm(set_attributes,
+		 num == 1,
+		 num == 2,
+		 num == 3,
+		 num == 4,
+		 num == 5,
+		 num == 6,
+		 num == 7,
+		 num == 8,
+		 num == 9);
     if (test != 0) {
 	if (PRESENT(cap)) {
 	    if (!similar_sgr(num, test, cap)) {
@@ -1222,12 +1256,15 @@
 			    name, _nc_visbuf2(1, cap),
 			    num, _nc_visbuf2(2, test));
 	    }
-	} else if (strcmp(test, zero)) {
+	} else if (_nc_capcmp(test, zero)) {
 	    _nc_warning("sgr(%d) present, but not %s", num, name);
 	}
     } else if (PRESENT(cap)) {
 	_nc_warning("sgr(%d) missing, but %s present", num, name);
     }
+    if (_nc_tparm_err)
+	_nc_warning("stack error in sgr(%d) string", num);
+    return test;
 }
 
 #define CHECK_SGR(num,name) check_sgr(tp, zero, num, name, #name)
@@ -1236,7 +1273,7 @@
  * logic that reads a terminfo entry)
  */
 static void
-check_termtype(TERMTYPE * tp)
+check_termtype(TERMTYPE *tp, bool literal)
 {
     bool conflict = FALSE;
     unsigned j, k;
@@ -1247,37 +1284,39 @@
      * a given string (e.g., KEY_END and KEY_LL).  But curses will only
      * return one (the last one assigned).
      */
-    memset(fkeys, 0, sizeof(fkeys));
-    for (j = 0; _nc_tinfo_fkeys[j].code; j++) {
-	char *a = tp->Strings[_nc_tinfo_fkeys[j].offset];
-	bool first = TRUE;
-	if (!VALID_STRING(a))
-	    continue;
-	for (k = j + 1; _nc_tinfo_fkeys[k].code; k++) {
-	    char *b = tp->Strings[_nc_tinfo_fkeys[k].offset];
-	    if (!VALID_STRING(b)
-		|| fkeys[k])
+    if (!(_nc_syntax == SYN_TERMCAP && capdump)) {
+	memset(fkeys, 0, sizeof(fkeys));
+	for (j = 0; _nc_tinfo_fkeys[j].code; j++) {
+	    char *a = tp->Strings[_nc_tinfo_fkeys[j].offset];
+	    bool first = TRUE;
+	    if (!VALID_STRING(a))
 		continue;
-	    if (!strcmp(a, b)) {
-		fkeys[j] = 1;
-		fkeys[k] = 1;
-		if (first) {
-		    if (!conflict) {
-			_nc_warning("Conflicting key definitions (using the last)");
-			conflict = TRUE;
+	    for (k = j + 1; _nc_tinfo_fkeys[k].code; k++) {
+		char *b = tp->Strings[_nc_tinfo_fkeys[k].offset];
+		if (!VALID_STRING(b)
+		    || fkeys[k])
+		    continue;
+		if (!_nc_capcmp(a, b)) {
+		    fkeys[j] = 1;
+		    fkeys[k] = 1;
+		    if (first) {
+			if (!conflict) {
+			    _nc_warning("Conflicting key definitions (using the last)");
+			    conflict = TRUE;
+			}
+			fprintf(stderr, "... %s is the same as %s",
+				keyname((int) _nc_tinfo_fkeys[j].code),
+				keyname((int) _nc_tinfo_fkeys[k].code));
+			first = FALSE;
+		    } else {
+			fprintf(stderr, ", %s",
+				keyname((int) _nc_tinfo_fkeys[k].code));
 		    }
-		    fprintf(stderr, "... %s is the same as %s",
-			    keyname(_nc_tinfo_fkeys[j].code),
-			    keyname(_nc_tinfo_fkeys[k].code));
-		    first = FALSE;
-		} else {
-		    fprintf(stderr, ", %s",
-			    keyname(_nc_tinfo_fkeys[k].code));
 		}
 	    }
+	    if (!first)
+		fprintf(stderr, "\n");
 	}
-	if (!first)
-	    fprintf(stderr, "\n");
     }
 
     for (j = 0; j < NUM_STRINGS(tp); j++) {
@@ -1298,7 +1337,7 @@
     ANDMISSING(cursor_visible, cursor_normal);
 
     if (PRESENT(cursor_visible) && PRESENT(cursor_normal)
-	&& !strcmp(cursor_visible, cursor_normal))
+	&& !_nc_capcmp(cursor_visible, cursor_normal))
 	_nc_warning("cursor_visible is same as cursor_normal");
 
     /*
@@ -1309,23 +1348,36 @@
     ANDMISSING(change_scroll_region, save_cursor);
     ANDMISSING(change_scroll_region, restore_cursor);
 
-    tparm_errs = 0;
     if (PRESENT(set_attributes)) {
-	char *zero = tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+	char *zero = 0;
 
-	zero = strdup(zero);
-	CHECK_SGR(1, enter_standout_mode);
-	CHECK_SGR(2, enter_underline_mode);
-	CHECK_SGR(3, enter_reverse_mode);
-	CHECK_SGR(4, enter_blink_mode);
-	CHECK_SGR(5, enter_dim_mode);
-	CHECK_SGR(6, enter_bold_mode);
-	CHECK_SGR(7, enter_secure_mode);
-	CHECK_SGR(8, enter_protected_mode);
-	CHECK_SGR(9, enter_alt_charset_mode);
-	free(zero);
-	if (tparm_errs)
-	    _nc_warning("stack error in sgr string");
+	_nc_tparm_err = 0;
+	if (PRESENT(exit_attribute_mode)) {
+	    zero = strdup(CHECK_SGR(0, exit_attribute_mode));
+	} else {
+	    zero = strdup(tparm(set_attributes, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+	}
+	if (_nc_tparm_err)
+	    _nc_warning("stack error in sgr(0) string");
+
+	if (zero != 0) {
+	    CHECK_SGR(1, enter_standout_mode);
+	    CHECK_SGR(2, enter_underline_mode);
+	    CHECK_SGR(3, enter_reverse_mode);
+	    CHECK_SGR(4, enter_blink_mode);
+	    CHECK_SGR(5, enter_dim_mode);
+	    CHECK_SGR(6, enter_bold_mode);
+	    CHECK_SGR(7, enter_secure_mode);
+	    CHECK_SGR(8, enter_protected_mode);
+	    CHECK_SGR(9, enter_alt_charset_mode);
+	    free(zero);
+	} else {
+	    _nc_warning("sgr(0) did not return a value");
+	}
+    } else if (PRESENT(exit_attribute_mode) &&
+	       set_attributes != CANCELLED_STRING) {
+	if (_nc_syntax == SYN_TERMINFO)
+	    _nc_warning("missing sgr string");
     }
 
     /*
@@ -1343,5 +1395,5 @@
      * Finally, do the non-verbose checks
      */
     if (save_check_termtype != 0)
-	save_check_termtype(tp);
+	save_check_termtype(tp, literal);
 }
diff -Naur ncurses-5.4.orig/progs/tput.c ncurses-5.4/progs/tput.c
--- ncurses-5.4.orig/progs/tput.c	2004-01-16 23:23:11.000000000 +0000
+++ ncurses-5.4/progs/tput.c	2005-05-13 04:09:56.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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 @@
 #endif
 #include <transform.h>
 
-MODULE_ID("$Id: tput.c,v 1.34 2004/01/16 23:23:11 Daniel.Jacobowitz Exp $")
+MODULE_ID("$Id: tput.c,v 1.35 2005/04/03 14:25:32 tom Exp $")
 
 #define PUTS(s)		fputs(s, stdout)
 #define PUTCHAR(c)	putchar(c)
@@ -151,7 +151,6 @@
     int i, j, c;
     int status;
     FILE *f;
-    int token = UNDEF;
 
     if ((name = argv[0]) == 0)
 	name = "";
@@ -295,7 +294,6 @@
     } else if ((s = tigetstr(name)) == CANCELLED_STRING) {
 	quit(4, "unknown terminfo capability '%s'", name);
     } else if (s != ABSENT_STRING) {
-	token = STRING;
 	if (argc > 1) {
 	    int k;
 	    int popcount;
@@ -360,7 +358,6 @@
     int c;
     char buf[BUFSIZ];
     int result = 0;
-    int err;
 
     check_aliases(prg_name = _nc_rootname(argv[0]));
 
@@ -428,7 +425,7 @@
 	argvec[argnum] = 0;
 
 	if (argnum != 0
-	    && (err = tput(argnum, argvec)) != 0) {
+	    && tput(argnum, argvec) != 0) {
 	    if (result == 0)
 		result = 4;	/* will return value >4 */
 	    ++result;
diff -Naur ncurses-5.4.orig/progs/tset.c ncurses-5.4/progs/tset.c
--- ncurses-5.4.orig/progs/tset.c	2003-12-06 17:21:01.000000000 +0000
+++ ncurses-5.4/progs/tset.c	2005-05-13 04:09:52.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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                 *
  ****************************************************************************/
 
 /*
@@ -103,7 +104,7 @@
 #include <dump_entry.h>
 #include <transform.h>
 
-MODULE_ID("$Id: tset.c,v 0.56 2003/12/06 17:21:01 tom Exp $")
+MODULE_ID("$Id: tset.c,v 1.59 2005/03/20 17:48:22 tom Exp $")
 
 extern char **environ;
 
@@ -114,6 +115,9 @@
 
 static TTY mode, oldmode, original;
 
+static bool opt_c;		/* set control-chars */
+static bool opt_w;		/* set window-size */
+
 static bool can_restore = FALSE;
 static bool isreset = FALSE;	/* invoked as reset */
 static int terasechar = -1;	/* new erase character */
@@ -151,7 +155,7 @@
 {
     va_list ap;
     va_start(ap, fmt);
-    (void) fprintf(stderr, "tset: ");
+    (void) fprintf(stderr, "%s: ", _nc_progname);
     (void) vfprintf(stderr, fmt, ap);
     va_end(ap);
     exit_error();
@@ -162,7 +166,15 @@
 failed(const char *msg)
 {
     char temp[BUFSIZ];
-    perror(strncat(strcpy(temp, "tset: "), msg, sizeof(temp) - 10));
+    unsigned len = strlen(_nc_progname) + 2;
+
+    if (len < sizeof(temp) - 12) {
+	strcpy(temp, _nc_progname);
+	strcat(temp, ": ");
+    } else {
+	strcpy(temp, "tset: ");
+    }
+    perror(strncat(temp, msg, sizeof(temp) - strlen(temp) - 2));
     exit_error();
     /* NOTREACHED */
 }
@@ -603,13 +615,13 @@
     while (setupterm((NCURSES_CONST char *) ttype, STDOUT_FILENO, &errret)
 	   != OK) {
 	if (errret == 0) {
-	    (void) fprintf(stderr, "tset: unknown terminal type %s\n",
-			   ttype);
+	    (void) fprintf(stderr, "%s: unknown terminal type %s\n",
+			   _nc_progname, ttype);
 	    ttype = 0;
 	} else {
 	    (void) fprintf(stderr,
-			   "tset: can't initialize terminal type %s (error %d)\n",
-			   ttype, errret);
+			   "%s: can't initialize terminal type %s (error %d)\n",
+			   _nc_progname, ttype, errret);
 	    ttype = 0;
 	}
 	ttype = askuser(ttype);
@@ -972,10 +984,10 @@
 	     * used to try a bunch of half-clever things
 	     * with cup and hpa, for an average saving of
 	     * somewhat less than two character times per
-	     * tab stop, less that .01 sec at 2400cps. We
+	     * tab stop, less than .01 sec at 2400cps. We
 	     * lost all this cruft because it seemed to be
 	     * introducing some odd bugs.
-	     * ----------12345678----------- */
+	     * -----------12345678----------- */
 	    (void) fputs("        ", stderr);
 	    tputs(set_tab, 0, outc);
 	}
@@ -1021,9 +1033,9 @@
 	(void) fprintf(stderr, "backspace.\n");
     else if (newer < 040) {
 	newer ^= 0100;
-	(void) fprintf(stderr, "control-%c (^%c).\n", newer, newer);
+	(void) fprintf(stderr, "control-%c (^%c).\n", UChar(newer), UChar(newer));
     } else
-	(void) fprintf(stderr, "%c.\n", newer);
+	(void) fprintf(stderr, "%c.\n", UChar(newer));
 }
 #endif
 
@@ -1062,10 +1074,28 @@
 }
 
 static void
-usage(const char *pname)
+usage(void)
 {
-    (void) fprintf(stderr,
-		   "usage: %s [-IQVrs] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]", pname);
+    static const char *tbl[] =
+    {
+	""
+	,"Options:"
+	,"  -c          set control characters"
+	,"  -e ch       erase character"
+	,"  -I          no initialization strings"
+	,"  -i ch       interrupt character"
+	,"  -k ch       kill character"
+	,"  -m mapping  map identifier to type"
+	,"  -Q          do not output control key settings"
+	,"  -r          display term on stderr"
+	,"  -s          output TERM set command"
+	,"  -V          print curses-version"
+	,"  -w          set window-size"
+    };
+    unsigned n;
+    (void) fprintf(stderr, "Usage: %s [options] [terminal]\n", _nc_progname);
+    for (n = 0; n < sizeof(tbl) / sizeof(tbl[0]); ++n)
+	fprintf(stderr, "%s\n", tbl[n]);
     exit_error();
     /* NOTREACHED */
 }
@@ -1088,28 +1118,12 @@
     const char *p;
     const char *ttype;
 
-    if (GET_TTY(STDERR_FILENO, &mode) < 0)
-	failed("standard error");
-    can_restore = TRUE;
-    original = oldmode = mode;
-#ifdef TERMIOS
-    ospeed = cfgetospeed(&mode);
-#else
-    ospeed = mode.sg_ospeed;
-#endif
-
-    p = _nc_rootname(*argv);
-    if (!strcmp(p, PROG_RESET)) {
-	isreset = TRUE;
-	reset_mode();
-    }
-
     obsolete(argv);
     noinit = noset = quiet = Sflag = sflag = showterm = 0;
-    while ((ch = getopt(argc, argv, "a:d:e:Ii:k:m:np:qQSrsV")) != EOF) {
+    while ((ch = getopt(argc, argv, "a:cd:e:Ii:k:m:np:qQSrsVw")) != EOF) {
 	switch (ch) {
-	case 'q':		/* display term only */
-	    noset = 1;
+	case 'c':		/* set control-chars */
+	    opt_c = TRUE;
 	    break;
 	case 'a':		/* OBSOLETE: map identifier to type */
 	    add_mapping("arpanet", optarg);
@@ -1140,28 +1154,54 @@
 	case 'Q':		/* don't output control key settings */
 	    quiet = 1;
 	    break;
-	case 'S':		/* OBSOLETE: output TERM & TERMCAP */
-	    Sflag = 1;
+	case 'q':		/* display term only */
+	    noset = 1;
 	    break;
 	case 'r':		/* display term on stderr */
 	    showterm = 1;
 	    break;
+	case 'S':		/* OBSOLETE: output TERM & TERMCAP */
+	    Sflag = 1;
+	    break;
 	case 's':		/* output TERM set command */
 	    sflag = 1;
 	    break;
-	case 'V':
+	case 'V':		/* print curses-version */
 	    puts(curses_version());
 	    return EXIT_SUCCESS;
+	case 'w':		/* set window-size */
+	    opt_w = TRUE;
+	    break;
 	case '?':
 	default:
-	    usage(*argv);
+	    usage();
 	}
     }
+
+    _nc_progname = _nc_rootname(*argv);
     argc -= optind;
     argv += optind;
 
     if (argc > 1)
-	usage(*argv);
+	usage();
+
+    if (!opt_c && !opt_w)
+	opt_c = opt_w = TRUE;
+
+    if (GET_TTY(STDERR_FILENO, &mode) < 0)
+	failed("standard error");
+    can_restore = TRUE;
+    original = oldmode = mode;
+#ifdef TERMIOS
+    ospeed = cfgetospeed(&mode);
+#else
+    ospeed = mode.sg_ospeed;
+#endif
+
+    if (!strcmp(_nc_progname, PROG_RESET)) {
+	isreset = TRUE;
+	reset_mode();
+    }
 
     ttype = get_termcap_entry(*argv);
 
@@ -1170,24 +1210,28 @@
 	tlines = lines;
 
 #if defined(TIOCGWINSZ) && defined(TIOCSWINSZ)
-	/* Set window size */
-	(void) ioctl(STDERR_FILENO, TIOCGWINSZ, &win);
-	if (win.ws_row == 0 && win.ws_col == 0 &&
-	    tlines > 0 && tcolumns > 0) {
-	    win.ws_row = tlines;
-	    win.ws_col = tcolumns;
-	    (void) ioctl(STDERR_FILENO, TIOCSWINSZ, &win);
+	if (opt_w) {
+	    /* Set window size */
+	    (void) ioctl(STDERR_FILENO, TIOCGWINSZ, &win);
+	    if (win.ws_row == 0 && win.ws_col == 0 &&
+		tlines > 0 && tcolumns > 0) {
+		win.ws_row = tlines;
+		win.ws_col = tcolumns;
+		(void) ioctl(STDERR_FILENO, TIOCSWINSZ, &win);
+	    }
 	}
 #endif
-	set_control_chars();
-	set_conversions();
-
-	if (!noinit)
-	    set_init();
-
-	/* Set the modes if they've changed. */
-	if (memcmp(&mode, &oldmode, sizeof(mode))) {
-	    SET_TTY(STDERR_FILENO, &mode);
+	if (opt_c) {
+	    set_control_chars();
+	    set_conversions();
+
+	    if (!noinit)
+		set_init();
+
+	    /* Set the modes if they've changed. */
+	    if (memcmp(&mode, &oldmode, sizeof(mode))) {
+		SET_TTY(STDERR_FILENO, &mode);
+	    }
 	}
     }
 
diff -Naur ncurses-5.4.orig/tack/Makefile.in ncurses-5.4/tack/Makefile.in
--- ncurses-5.4.orig/tack/Makefile.in	2003-11-01 22:46:24.000000000 +0000
+++ ncurses-5.4/tack/Makefile.in	2005-05-13 04:09:51.000000000 +0000
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.31 2003/11/01 22:46:24 tom Exp $
+# $Id: Makefile.in,v 1.33 2005/01/22 20:03:05 tom Exp $
 # Makefile for tack
 #
 # The variable 'srcdir' refers to the source-distribution, and can be set with
@@ -64,7 +64,7 @@
 LD		= @LD@
 LINK		= @LINK_PROGS@ $(LIBTOOL_LINK) $(CC)
 LDFLAGS		= @EXTRA_LDFLAGS@ \
-		@PROG_ARGS@ @LDFLAGS@ @LD_MODEL@ @LIBS@ @EXTRA_LIBS@
+		@TINFO_ARGS@ @LDFLAGS@ @LD_MODEL@ @LIBS@
 
 LDFLAGS_LIBTOOL	= $(LDFLAGS) $(CFLAGS_LIBTOOL)
 LDFLAGS_NORMAL	= $(LDFLAGS) $(CFLAGS_NORMAL)
diff -Naur ncurses-5.4.orig/tack/charset.c ncurses-5.4/tack/charset.c
--- ncurses-5.4.orig/tack/charset.c	2001-06-18 18:44:26.000000000 +0000
+++ ncurses-5.4/tack/charset.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,18 +1,18 @@
 /*
 ** Copyright (C) 1991, 1997-2000 Free Software Foundation, Inc.
-** 
+**
 ** This file is part of TACK.
-** 
+**
 ** TACK is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
 ** the Free Software Foundation; either version 2, or (at your option)
 ** any later version.
-** 
+**
 ** TACK is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
-** 
+**
 ** You should have received a copy of the GNU General Public License
 ** along with TACK; see the file COPYING.  If not, write to
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
@@ -21,7 +21,7 @@
 
 #include <tack.h>
 
-MODULE_ID("$Id: charset.c,v 1.8 2001/06/18 18:44:26 tom Exp $")
+MODULE_ID("$Id: charset.c,v 1.9 2004/09/25 21:52:42 tom Exp $")
 
 /*
 	Menu definitions for alternate character set and SGR tests.
@@ -194,7 +194,7 @@
 }
 
 
-void 
+void
 eat_cookie(void)
 {				/* put a blank if this is not a magic cookie
 				   terminal */
@@ -203,7 +203,7 @@
 }
 
 
-void 
+void
 put_mode(char *s)
 {				/* send the attribute string (with or without
 				   % execution) */
@@ -285,7 +285,7 @@
 	}
 	put_crlf();
 
-#ifdef max_attributes 
+#ifdef max_attributes
 	if (max_attributes >= 0) {
 		sprintf(temp, "(ma) Maximum attributes %d  ", max_attributes);
 		ptext(temp);
@@ -488,20 +488,20 @@
 #ifdef ACS_ULCORNER
 	maybe_wait(5);
 	put_mode(enter_alt_charset_mode);
-	put_this(ACS_ULCORNER);
-	put_this(ACS_TTEE);
-	put_this(ACS_URCORNER);
-	put_this(ACS_ULCORNER);
-	put_this(ACS_HLINE);
-	put_this(ACS_URCORNER);
+	put_that(ACS_ULCORNER);
+	put_that(ACS_TTEE);
+	put_that(ACS_URCORNER);
+	put_that(ACS_ULCORNER);
+	put_that(ACS_HLINE);
+	put_that(ACS_URCORNER);
 	char_count += 6;
 	put_mode(exit_alt_charset_mode);
 	put_crlf();
 	put_mode(enter_alt_charset_mode);
-	put_this(ACS_LTEE);
-	put_this(ACS_PLUS);
-	put_this(ACS_RTEE);
-	put_this(ACS_VLINE);
+	put_that(ACS_LTEE);
+	put_that(ACS_PLUS);
+	put_that(ACS_RTEE);
+	put_that(ACS_VLINE);
 	if (magic_cookie_glitch >= 1)
 		put_this(' ');
 	else {
@@ -509,18 +509,18 @@
 		put_this(' ');
 		put_mode(enter_alt_charset_mode);
 	}
-	put_this(ACS_VLINE);
+	put_that(ACS_VLINE);
 	char_count += 6;
 	put_mode(exit_alt_charset_mode);
 	put_str("   Here are 2 boxes");
 	put_crlf();
 	put_mode(enter_alt_charset_mode);
-	put_this(ACS_LLCORNER);
-	put_this(ACS_BTEE);
-	put_this(ACS_LRCORNER);
-	put_this(ACS_LLCORNER);
-	put_this(ACS_HLINE);
-	put_this(ACS_LRCORNER);
+	put_that(ACS_LLCORNER);
+	put_that(ACS_BTEE);
+	put_that(ACS_LRCORNER);
+	put_that(ACS_LLCORNER);
+	put_that(ACS_HLINE);
+	put_that(ACS_LRCORNER);
 	char_count += 6;
 	put_mode(exit_alt_charset_mode);
 	put_crlf();
diff -Naur ncurses-5.4.orig/tack/control.c ncurses-5.4/tack/control.c
--- ncurses-5.4.orig/tack/control.c	2000-03-04 21:10:59.000000000 +0000
+++ ncurses-5.4/tack/control.c	2005-05-13 04:09:57.000000000 +0000
@@ -25,7 +25,7 @@
 #include <sys/time.h>
 #endif
 
-MODULE_ID("$Id: control.c,v 1.3 2000/03/04 21:10:59 tom Exp $")
+MODULE_ID("$Id: control.c,v 1.6 2005/04/16 16:29:18 tom Exp $")
 
 /* terminfo test program control subroutines */
 
@@ -40,11 +40,11 @@
 
 char txt_longer_test_time[80];	/* +) use longer time */
 char txt_shorter_test_time[80];	/* -) use shorter time */
-int pad_test_duration = 1;	/* number of seconds for a pad test */
+static int pad_test_duration = 1;	/* number of seconds for a pad test */
 int auto_pad_mode;		/* run the time tests */
 int no_alarm_event;		/* TRUE if the alarm has not gone off yet */
-int usec_run_time;		/* length of last test in microseconds */
-MY_TIMER stop_watch[MAX_TIMERS]; /* Hold the start timers */
+unsigned long usec_run_time;	/* length of last test in microseconds */
+static MY_TIMER stop_watch[MAX_TIMERS]; /* Hold the start timers */
 
 char txt_longer_augment[80];	/* >) use bigger augment */
 char txt_shorter_augment[80];	/* <) use smaller augment */
@@ -66,16 +66,13 @@
 int tx_delay[TT_MAX];		/* Number of milliseconds delay */
 int txp;			/* number of entries used */
 int tx_characters;		/* printing characters sent by test */
-int tx_cps;			/* characters per second */
-struct test_list *tx_source;	/* The test that generated this data */
-
-extern struct test_menu pad_menu;	/* Pad menu structure */
-extern struct test_list pad_test_list[];
+unsigned long tx_cps;		/* characters per second */
+static struct test_list *tx_source;	/* The test that generated this data */
 
 #define RESULT_BLOCK		1024
 static int blocks;		/* number of result blocks available */
 static struct test_results *results;	/* pointer to next available */
-struct test_results *pads[STRCOUNT];	/* save pad results here */
+static struct test_results *pads[STRCOUNT];	/* save pad results here */
 
 /*
 **	event_start(number)
@@ -365,7 +362,7 @@
 sliding_scale(
 	int dividend,
 	int factor,
-	int divisor)
+	unsigned long divisor)
 {
 	double d = dividend;
 
@@ -500,7 +497,7 @@
 		ptext(temp);
 		while (r) {
 			sprintf(temp, "$<%d>", r->delay / 1000);
-			put_columns(temp, strlen(temp), 10);
+			put_columns(temp, (int) strlen(temp), 10);
 			r = r->next;
 		}
 		r = pads[x];
@@ -508,7 +505,7 @@
 			if (r->reps > 1) {
 				delay = r->delay / (r->reps * 100);
 				sprintf(temp, "$<%d.%d*>", delay / 10, delay % 10);
-				put_columns(temp, strlen(temp), 10);
+				put_columns(temp, (int) strlen(temp), 10);
 			}
 			r = r->next;
 		}
@@ -544,9 +541,9 @@
 			put_crlf();
 		}
 	}
-	sprintf(tbuf, "%011u", usec_run_time);
-	sprintf(temp, "Test time: %d.%s, characters per second %d, characters %d",
-		usec_run_time / 1000000, &tbuf[5], tx_cps, tx_characters);
+	sprintf(tbuf, "%011lu", usec_run_time);
+	sprintf(temp, "Test time: %lu.%s, characters per second %ld, characters %d",
+		usec_run_time / 1000000UL, &tbuf[5], tx_cps, tx_characters);
 	ptextln(temp);
 	for (i = 0; i < txp; i++) {
 		if ((j = get_string_cap_byvalue(tx_cap[i])) >= 0) {
diff -Naur ncurses-5.4.orig/tack/edit.c ncurses-5.4/tack/edit.c
--- ncurses-5.4.orig/tack/edit.c	2001-06-18 18:44:32.000000000 +0000
+++ ncurses-5.4/tack/edit.c	2005-05-13 04:09:51.000000000 +0000
@@ -23,7 +23,7 @@
 #include <time.h>
 #include <tic.h>
 
-MODULE_ID("$Id: edit.c,v 1.8 2001/06/18 18:44:32 tom Exp $")
+MODULE_ID("$Id: edit.c,v 1.9 2004/12/04 16:09:20 tom Exp $")
 
 /*
  * Terminfo edit features
@@ -52,7 +52,7 @@
 };
 
 static char change_pad_text[MAX_CHANGES][80];
-struct test_list change_pad_list[MAX_CHANGES] = {
+static struct test_list change_pad_list[MAX_CHANGES] = {
 	{MENU_LAST, 0, 0, 0, 0, 0, 0}
 };
 
@@ -65,15 +65,13 @@
 	build_change_menu, change_pad_list, 0, 0, 0
 };
 
-extern struct test_results *pads[STRCOUNT];	/* save pad results here */
-
 static TERMTYPE	original_term;		/* terminal type description */
 
 static char flag_boolean[BOOLCOUNT];	/* flags for booleans */
 static char flag_numerics[NUMCOUNT];	/* flags for numerics */
 static char flag_strings[STRCOUNT];	/* flags for strings */
 static int xon_index;			/* Subscript for (xon) */
-int xon_shadow;
+static int xon_shadow;
 
 static int start_display;		/* the display has just started */
 static int display_lines;		/* number of lines displayed */
diff -Naur ncurses-5.4.orig/tack/fun.c ncurses-5.4/tack/fun.c
--- ncurses-5.4.orig/tack/fun.c	2000-03-04 20:29:21.000000000 +0000
+++ ncurses-5.4/tack/fun.c	2005-05-13 04:09:51.000000000 +0000
@@ -21,7 +21,7 @@
 
 #include <tack.h>
 
-MODULE_ID("$Id: fun.c,v 1.3 2000/03/04 20:29:21 tom Exp $")
+MODULE_ID("$Id: fun.c,v 1.5 2004/12/04 16:03:41 tom Exp $")
 
 /*
  * Test the function keys on the terminal.  The code for echo tests
@@ -58,10 +58,6 @@
 
 #define MAX_STRINGS STRCOUNT
 
-/* scan code externals */
-extern int scan_max;		/* length of longest scan code */
-extern char **scan_up, **scan_down, **scan_name;
-extern int *scan_tested, *scan_length;
 
 /* local definitions */
 static const char *fk_name[MAX_STRINGS];
@@ -102,7 +98,7 @@
 			if (fk_label[i]) {
 				sprintf(outbuf, "%s %s",
 					fk_name[i] ? fk_name[i] : "??", fk_label[i]);
-				put_columns(outbuf, strlen(outbuf), 16);
+				put_columns(outbuf, (int) strlen(outbuf), 16);
 			}
 		}
 		put_newlines(2);
diff -Naur ncurses-5.4.orig/tack/init.c ncurses-5.4/tack/init.c
--- ncurses-5.4.orig/tack/init.c	2003-09-20 19:40:57.000000000 +0000
+++ ncurses-5.4/tack/init.c	2005-05-13 04:09:51.000000000 +0000
@@ -22,7 +22,7 @@
 
 #include <tack.h>
 
-MODULE_ID("$Id: init.c,v 1.4 2003/09/20 19:40:57 tom Exp $")
+MODULE_ID("$Id: init.c,v 1.5 2004/12/04 16:11:46 tom Exp $")
 
 #if NCURSES_VERSION_MAJOR >= 5 || NCURSES_VERSION_PATCH >= 981219
 #define _nc_get_curterm(p) _nc_get_tty_mode(p)
@@ -170,7 +170,11 @@
 	report_cap("ACK   (u8)", user8);
 #endif
 
-	sprintf(temp, "\nTerminal size: %d x %d.  Baud rate: %ld.  Frame size: %d.%d", columns, lines, tty_baud_rate, tty_frame_size >> 1, (tty_frame_size & 1) * 5);
+	sprintf(temp, "\nTerminal size: %d x %d.  Baud rate: %u.  Frame size: %d.%d",
+		columns, lines,
+		tty_baud_rate,
+		tty_frame_size >> 1,
+		(tty_frame_size & 1) * 5);
 	putln(temp);
 }
 
diff -Naur ncurses-5.4.orig/tack/output.c ncurses-5.4/tack/output.c
--- ncurses-5.4.orig/tack/output.c	2003-10-25 20:43:43.000000000 +0000
+++ ncurses-5.4/tack/output.c	2005-05-13 04:09:51.000000000 +0000
@@ -23,7 +23,7 @@
 #include <tack.h>
 #include <time.h>
 
-MODULE_ID("$Id: output.c,v 1.8 2003/10/25 20:43:43 tom Exp $")
+MODULE_ID("$Id: output.c,v 1.9 2004/12/04 15:41:31 tom Exp $")
 
 /* globals */
 long char_sent;			/* number of characters sent */
@@ -34,7 +34,7 @@
 int can_go_home;		/* TRUE if we can fashion a home command */
 int can_clear_screen;		/* TRUE if we can somehow clear the screen */
 int raw_characters_sent;	/* Total output characters */
-int log_count;			/* Number of characters on a log line */
+static int log_count;		/* Number of characters on a log line */
 
 /* translate mode default strings */
 #define TM_carriage_return	TM_string[0].value
diff -Naur ncurses-5.4.orig/tack/pad.c ncurses-5.4/tack/pad.c
--- ncurses-5.4.orig/tack/pad.c	2003-10-18 22:11:29.000000000 +0000
+++ ncurses-5.4/tack/pad.c	2005-05-13 04:09:51.000000000 +0000
@@ -21,7 +21,7 @@
 
 #include <tack.h>
 
-MODULE_ID("$Id: pad.c,v 1.3 2003/10/18 22:11:29 tom Exp $")
+MODULE_ID("$Id: pad.c,v 1.5 2004/12/04 16:09:20 tom Exp $")
 
 /* test the pad counts on the terminal */
 
@@ -61,8 +61,6 @@
 static void pad_smacs(struct test_list *, int *, int *);
 static void pad_crash(struct test_list *, int *, int *);
 
-extern struct test_menu change_pad_menu;
-
 /*
    Any command found in this list, executed from a "Done" prompt
    will force the default action to repeat rather than next.
@@ -168,10 +166,8 @@
 	{MENU_LAST, 0, 0, 0, 0, 0, 0}
 };
 
-extern int test_complete;	/* counts number of tests completed */
-
 /* globals */
-int hzcc;			/* horizontal character count */
+static int hzcc;		/* horizontal character count */
 char letter;			/* current character being displayed */
 int letter_number;		/* points into letters[] */
 int augment, repeats;		/* number of characters (or lines) effected */
@@ -1759,7 +1755,7 @@
 			put_str(every_line);
 		}
 		tt_putparm(change_scroll_region, 1, 0, lines - 1);
-		tt_putparm(cursor_address, 1, lines - 1, strlen(every_line));
+		tt_putparm(cursor_address, 1, lines - 1, (int) strlen(every_line));
 	} while(still_testing());
 	pad_test_shutdown(t, 0);
 	put_str("  ");
diff -Naur ncurses-5.4.orig/tack/scan.c ncurses-5.4/tack/scan.c
--- ncurses-5.4.orig/tack/scan.c	1999-08-21 23:09:35.000000000 +0000
+++ ncurses-5.4/tack/scan.c	2005-05-13 04:09:51.000000000 +0000
@@ -22,24 +22,25 @@
 
 #include <tack.h>
 
-MODULE_ID("$Id: scan.c,v 1.2 1999/08/21 23:09:35 tom Exp $")
+MODULE_ID("$Id: scan.c,v 1.4 2004/12/04 16:06:02 tom Exp $")
 
-int scan_max;			/* length of longest scan code */
+unsigned scan_max;		/* length of longest scan code */
 char **scan_up, **scan_down, **scan_name;
-int *scan_tested, *scan_length, *scan_value;
+unsigned *scan_tested, *scan_length;
+static unsigned *scan_value;
 
 static int shift_state;
 static char *str;
 static int debug_char_count;
 
-#define SHIFT_KEY 0x100
+#define SHIFT_KEY   0x100
 #define CONTROL_KEY 0x200
-#define META_KEY 0x400
-#define CAPS_LOCK 0x800
+#define META_KEY    0x400
+#define CAPS_LOCK   0x800
 
 static const struct {
 	const char *name;
-	int type;
+	unsigned type;
 }  scan_special[] = {
 	{"<shift>", SHIFT_KEY},
 	{"<left shift>", SHIFT_KEY},
@@ -102,6 +103,7 @@
 	char *s, *sl;
 	FILE *fp;
 	int ch, i, j;
+	unsigned len;
 	char home[512];
 
 	if ((str = getenv("HOME")))
@@ -140,9 +142,9 @@
 	scan_up = (char **) malloc(sizeof(char *) * MAX_SCAN);
 	scan_down = (char **) malloc(sizeof(char *) * MAX_SCAN);
 	scan_name = (char **) malloc(sizeof(char *) * MAX_SCAN);
-	scan_tested = (int *) malloc(sizeof(int *) * MAX_SCAN);
-	scan_length = (int *) malloc(sizeof(int *) * MAX_SCAN);
-	scan_value = (int *) malloc(sizeof(int *) * MAX_SCAN);
+	scan_tested = (unsigned *) malloc(sizeof(unsigned *) * MAX_SCAN);
+	scan_length = (unsigned *) malloc(sizeof(unsigned *) * MAX_SCAN);
+	scan_value = (unsigned *) malloc(sizeof(unsigned *) * MAX_SCAN);
 	scan_up[0] = scan_down[0] = scan_name[0] = (char *) 0;
 	str = (char *) malloc(4096);	/* buffer space */
 	sl = str + 4000;	/* an upper limit */
@@ -165,11 +167,11 @@
 		scan_name[i] = str;
 
 		scan_length[i] = strlen(scan_down[i]);
-		ch = strlen(scan_up[i]) + scan_length[i];
-		if (ch > scan_max)
-			scan_max = ch;
+		len = strlen(scan_up[i]) + scan_length[i];
+		if (len > scan_max)
+			scan_max = len;
 
-		scan_value[i] = scan_name[i][0];
+		scan_value[i] = UChar(scan_name[i][0]);
 		if (scan_name[i][1])	/* multi-character name */
 			for (j = 0; scan_special[j].name; j++) {
 				if (!strcmp(scan_name[i], scan_special[j].name)) {
@@ -202,7 +204,8 @@
 scan_key(void)
 {				/* read a key and translate scan mode to
 				   ASCII */
-	int i, j, ch;
+	unsigned i;
+	int j, ch;
 	char buf[64];
 
 	for (i = 1;; i++) {
diff -Naur ncurses-5.4.orig/tack/sync.c ncurses-5.4/tack/sync.c
--- ncurses-5.4.orig/tack/sync.c	2001-06-16 17:55:48.000000000 +0000
+++ ncurses-5.4/tack/sync.c	2005-05-13 04:09:57.000000000 +0000
@@ -22,7 +22,7 @@
 #include <tack.h>
 #include <time.h>
 
-MODULE_ID("$Id: sync.c,v 1.3 2001/06/16 17:55:48 tom Exp $")
+MODULE_ID("$Id: sync.c,v 1.5 2005/04/16 16:29:41 tom Exp $")
 
 /* terminal-synchronization and performance tests */
 
@@ -31,7 +31,7 @@
 static void sync_clear(struct test_list *, int *, int *);
 static void sync_summary(struct test_list *, int *, int *);
 
-struct test_list sync_test_list[] = {
+static struct test_list sync_test_list[] = {
 	{MENU_NEXT, 0, 0, 0, "b) baud rate test", sync_home, 0},
 	{MENU_NEXT, 0, 0, 0, "l) scroll performance", sync_lines, 0},
 	{MENU_NEXT, 0, 0, 0, "c) clear screen performance", sync_clear, 0},
@@ -48,16 +48,16 @@
 };
 
 int tty_can_sync;		/* TRUE if tty_sync_error() returned FALSE */
-int tty_newline_rate;		/* The number of newlines per second */
-int tty_clear_rate;		/* The number of clear-screens per second */
-int tty_cps;			/* The number of characters per second */
+static int tty_newline_rate;	/* The number of newlines per second */
+static int tty_clear_rate;	/* The number of clear-screens per second */
+unsigned long tty_cps;		/* The number of characters per second */
 
 #define TTY_ACK_SIZE 64
 
-int ACK_terminator;		/* terminating ACK character */
-int ACK_length;			/* length of ACK string */
-const char *tty_ENQ;		/* enquire string */
-char tty_ACK[TTY_ACK_SIZE];	/* ACK response, set by tty_sync_error() */
+static int ACK_terminator;	/* terminating ACK character */
+static int ACK_length;		/* length of ACK string */
+static const char *tty_ENQ;	/* enquire string */
+static char tty_ACK[TTY_ACK_SIZE]; /* ACK response, set by tty_sync_error() */
 
 /*****************************************************************************
  *
@@ -299,7 +299,7 @@
 	if (tx_cps > tty_cps) {
 		tty_cps = tx_cps;
 	}
-	sprintf(temp, "%d characters per second.  Baudrate %d  ", tx_cps, j);
+	sprintf(temp, "%ld characters per second.  Baudrate %d  ", tx_cps, j);
 	ptext(temp);
 	generic_done_message(t, state, ch);
 }
@@ -395,7 +395,7 @@
 	put_crlf();
 	ptextln("Terminal  size    characters/sec linefeeds/sec  clears/sec");
 	sprintf(size, "%dx%d", columns, lines);
-	sprintf(temp, "%-10s%-11s%11d   %11d %11d", tty_basename, size,
+	sprintf(temp, "%-10s%-11s%11ld   %11d %11d", tty_basename, size,
 		tty_cps, tty_newline_rate, tty_clear_rate);
 	ptextln(temp);
 	generic_done_message(t, state, ch);
diff -Naur ncurses-5.4.orig/tack/sysdep.c ncurses-5.4/tack/sysdep.c
--- ncurses-5.4.orig/tack/sysdep.c	2002-04-21 19:40:43.000000000 +0000
+++ ncurses-5.4/tack/sysdep.c	2005-05-13 04:09:51.000000000 +0000
@@ -46,7 +46,7 @@
 #endif
 #endif
 
-MODULE_ID("$Id: sysdep.c,v 1.11 2002/04/21 19:40:43 tom Exp $")
+MODULE_ID("$Id: sysdep.c,v 1.13 2004/12/04 16:06:42 tom Exp $")
 
 #if DECL_ERRNO
 extern int errno;
@@ -60,7 +60,7 @@
 
 /* globals */
 int tty_frame_size;		/* asynch frame size times 2 */
-unsigned long tty_baud_rate;	/* baud rate - bits per second */
+unsigned tty_baud_rate;		/* baud rate - bits per second */
 int not_a_tty;			/* TRUE if output is not a tty (i.e. pipe) */
 int nodelay_read;		/* TRUE if NDELAY is set */
 
@@ -179,8 +179,8 @@
 #endif	/* NL1 */
 		break;
 	}
-	if (!(new_modes.c_oflag & ~OPOST))
-		new_modes.c_oflag &= ~OPOST;
+	if (!(new_modes.c_oflag & (unsigned long) ~OPOST))
+		new_modes.c_oflag &= (unsigned long) ~OPOST;
 #else
 	new_modes.sg_flags |= RAW;
 	if (not_a_tty)
@@ -396,7 +396,7 @@
 		if (ask > max) {
 			ask = max;
 		}
-		if ((got = read(fileno(stdin), s, ask))) {
+		if ((got = read(fileno(stdin), s, (unsigned) ask))) {
 			s += got;
 		} else {
 			break;
@@ -497,5 +497,5 @@
 {
 	signal(SIGALRM, alarm_event);
 	no_alarm_event = 1;
-	(void) alarm(seconds);
+	(void) alarm((unsigned) seconds);
 }
diff -Naur ncurses-5.4.orig/tack/tack.c ncurses-5.4/tack/tack.c
--- ncurses-5.4.orig/tack/tack.c	2001-10-28 01:05:35.000000000 +0000
+++ ncurses-5.4/tack/tack.c	2005-05-13 04:09:51.000000000 +0000
@@ -21,7 +21,7 @@
 
 #include <tack.h>
 
-MODULE_ID("$Id: tack.c,v 1.2 2001/10/28 01:05:35 tom Exp $")
+MODULE_ID("$Id: tack.c,v 1.3 2004/12/04 16:12:06 tom Exp $")
 
 /*
    This program is designed to test terminfo, not curses.  Therefore
@@ -62,14 +62,12 @@
  *
  *****************************************************************************/
 
-extern struct test_menu sync_menu;
-
 static void tools_hex_echo(struct test_list *, int *, int *);
 static void tools_debug(struct test_list *, int *, int *);
 
 static char hex_echo_menu_entry[80];
 
-struct test_list tools_test_list[] = {
+static struct test_list tools_test_list[] = {
 	{0, 0, 0, 0, "s) ANSI status reports", tools_status, 0},
 	{0, 0, 0, 0, "g) ANSI SGR modes (bold, underline, reverse)", tools_sgr, 0},
 	{0, 0, 0, 0, "c) ANSI character sets", tools_charset, 0},
@@ -83,7 +81,7 @@
 	{MENU_LAST, 0, 0, 0, 0, 0, 0}
 };
 
-struct test_menu tools_menu = {
+static struct test_menu tools_menu = {
 	0, 'q', 0, "Tools Menu", "tools",
 	0, 0, tools_test_list, 0, 0, 0
 };
@@ -115,24 +113,18 @@
 	tty_show_state, tty_test_list, 0, 0, 0
 };
 
-extern struct test_list edit_test_list[];
-
 struct test_menu edit_menu = {
 	0, 'q', 0, "Edit terminfo menu",
 	"edit", 0,
 	0, edit_test_list, 0, 0, 0
 };
 
-extern struct test_list mode_test_list[];
-
-struct test_menu mode_menu = {
+static struct test_menu mode_menu = {
 	0, 'n', 0, "Test modes and glitches:",
 	"mode", "n) run standard tests",
 	0, mode_test_list, 0, 0, 0
 };
 
-extern struct test_list acs_test_list[];
-
 static struct test_menu acs_menu = {
 	0, 'n', 0,
 	"Test alternate character set and graphics rendition:",
@@ -140,17 +132,13 @@
 	0, acs_test_list, 0, 0, 0
 };
 
-extern struct test_list color_test_list[];
-
-struct test_menu color_menu = {
+static struct test_menu color_menu = {
 	0, 'n', 0,
 	"Test color:",
 	"color", "n) run standard tests",
 	0, color_test_list, 0, 0, 0
 };
 
-extern struct test_list crum_test_list[];
-
 static struct test_menu crum_menu = {
 	0, 'n', 0,
 	"Test cursor movement:",
@@ -158,8 +146,6 @@
 	0, crum_test_list, 0, 0, 0
 };
 
-extern struct test_list funkey_test_list[];
-
 static struct test_menu funkey_menu = {
 	0, 'n', 0,
 	"Test function keys:",
@@ -167,8 +153,6 @@
 	sync_test, funkey_test_list, 0, 0, 0
 };
 
-extern struct test_list printer_test_list[];
-
 static struct test_menu printer_menu = {
 	0, 'n', 0,
 	"Test printer:",
@@ -177,7 +161,6 @@
 };
 
 static void pad_gen(struct test_list *, int *, int *);
-extern struct test_list pad_test_list[];
 
 static struct test_menu pad_menu = {
 	0, 'n', 0,
@@ -203,7 +186,7 @@
 };
 
 
-struct test_menu normal_menu = {
+static struct test_menu normal_menu = {
 	0, 'n', 0, "Main test menu",
 	"test", "n) run standard tests",
 	0, normal_test_list, 0, 0, 0
@@ -216,7 +199,7 @@
 
 static char logging_menu_entry[80] = "l) start logging";
 
-struct test_list start_test_list[] = {
+static struct test_list start_test_list[] = {
 	{0, 0, 0, 0, "b) display basic information", start_basic, 0},
 	{0, 0, 0, 0, "m) change modes", start_modes, 0},
 	{0, 0, 0, 0, "t) tools", start_tools, 0},
@@ -226,7 +209,7 @@
 };
 	
 
-struct test_menu start_menu = {
+static struct test_menu start_menu = {
 	0, 'n', 0, "Main Menu", "tack", 0,
 	0, start_test_list, 0, 0, 0
 };
@@ -319,7 +302,7 @@
 {
 	put_crlf();
 	(void) sprintf(temp,
-		"Accepting %d bits, UNIX delays %d, XON/XOFF %sabled, speed %ld, translate %s, scan-code mode %s.",
+		"Accepting %d bits, UNIX delays %d, XON/XOFF %sabled, speed %u, translate %s, scan-code mode %s.",
 		(char_mask == ALLOW_PARITY) ? 8 : 7,
 		select_delay_type,
 		select_xon_xoff ? "en" : "dis",
diff -Naur ncurses-5.4.orig/tack/tack.h ncurses-5.4/tack/tack.h
--- ncurses-5.4.orig/tack/tack.h	2003-10-18 22:26:59.000000000 +0000
+++ ncurses-5.4/tack/tack.h	2005-05-13 04:09:57.000000000 +0000
@@ -19,7 +19,7 @@
 ** Boston, MA 02111-1307, USA.
 */
 
-/* $Id: tack.h,v 1.10 2003/10/18 22:26:59 tom Exp $ */
+/* $Id: tack.h,v 1.13 2005/04/16 16:28:42 tom Exp $ */
 
 #ifndef NCURSES_TACK_H_incl
 #define NCURSES_TACK_H_incl 1
@@ -77,9 +77,9 @@
 extern int tty_can_sync;
 extern int total_pads_sent;	/* count pad characters sent */
 extern int total_caps_sent;	/* count caps sent */
-extern int total_printing_characters;	/* count printing characters sent */
+extern int total_printing_characters; /* count printing characters sent */
 extern int no_alarm_event;	/* TRUE if the alarm has not gone off yet */
-extern int usec_run_time;	/* length of last test in microseconds */
+extern unsigned long usec_run_time; /* length of last test in microseconds */
 extern int raw_characters_sent;	/* Total output characters */
 
 /* Stopwatch event timers */
@@ -129,8 +129,8 @@
 extern int select_xon_xoff;
 
 extern int tty_frame_size;
-extern unsigned long tty_baud_rate;
-extern int tty_cps;		/* The number of characters per second */
+extern unsigned tty_baud_rate;
+extern unsigned long tty_cps;	/* The number of characters per second */
 extern int not_a_tty, nodelay_read;
 extern int send_reset_init;
 
@@ -194,7 +194,7 @@
 extern int tx_index[TT_MAX];	/* String index */
 extern int txp;			/* number of entries used */
 extern int tx_characters;	/* printing characters sent by test */
-extern int tx_cps;		/* characters per second */
+extern unsigned long tx_cps;	/* characters per second */
 
 /*
 	Menu control for tack.
@@ -268,138 +268,156 @@
 
 #define REQUEST_PROMPT 256
 
-extern char prompt_string[80];	/* menu prompt storage */
-extern struct test_menu edit_menu;
-extern struct test_list *augment_test;
-
 /* tack.c */
+extern struct test_menu edit_menu;
 extern void show_usage(char *);
 extern void print_version(void);
 
 /* output.c */
-extern void tt_tputs(const char *, int);
-extern void tt_putp(const char *);
-extern void tt_putparm(NCURSES_CONST char *, int, int, int);
-extern int tc_putp(const char *);
+extern char *expand(const char *);
+extern char *expand_command(const char *);
+extern char *expand_to(char *, int);
+extern char *hex_expand_to(char *, int);
+extern char *print_expand(char *);
+extern int getchp(int);
+extern int getnext(int);
 extern int tc_putch(int);
-extern void putchp(int);
+extern int tc_putp(const char *);
+extern int wait_here(void);
+extern void go_home(void);
+extern void home_down(void);
+extern void maybe_wait(int);
+extern void ptext(const char *);
+extern void ptextln(const char *);
+extern void put_clear(void);
+extern void put_columns(const char *, int, int);
 extern void put_cr(void);
 extern void put_crlf(void);
-extern void put_clear(void);
 extern void put_dec(char *, int);
-extern void put_str(const char *);
-extern void put_lf(void);
 extern void put_ind(void);
+extern void put_lf(void);
 extern void put_newlines(int);
-extern void put_columns(const char *, int, int);
+extern void put_str(const char *);
 extern void put_this(int);
+extern void putchp(int);
 extern void putln(const char *);
-extern void ptext(const char *);
-extern void ptextln(const char *);
-extern void home_down(void);
-extern void go_home(void);
-extern void three_digit(char *, int);
-extern int getchp(int);
-extern char *expand(const char *);
-extern char *expand_to(char *, int);
-extern char *expand_command(const char *);
-extern char *hex_expand_to(char *, int);
-extern char *print_expand(char *);
-extern void maybe_wait(int);
-extern int wait_here(void);
 extern void read_string(char *, int);
-extern int getnext(int);
+extern void three_digit(char *, int);
+extern void tt_putp(const char *);
+extern void tt_putparm(NCURSES_CONST char *, int, int, int);
+extern void tt_tputs(const char *, int);
+
+#define put_that(n) put_this((int) (n))
 
 /* control.c */
-extern void event_start(int);
-extern long event_time(int);
+extern struct test_list color_test_list[];
 extern char *liberated(char *);
-extern void page_loop(void);
-extern void control_init(void);
+extern char txt_longer_augment[80];
+extern char txt_longer_test_time[80];
+extern char txt_shorter_augment[80];
+extern char txt_shorter_test_time[80];
 extern int msec_cost(const char *const, int);
 extern int skip_pad_test(struct test_list *, int *, int *, const char *);
-extern void pad_test_startup(int);
+extern int sliding_scale(int, int, unsigned long);
 extern int still_testing(void);
-extern void pad_test_shutdown(struct test_list *, int);
+extern long event_time(int);
+extern void control_init(void);
 extern void dump_test_stats(struct test_list *, int *, int *);
+extern void event_start(int);
+extern void longer_augment(struct test_list *, int *, int *);
 extern void longer_test_time(struct test_list *, int *, int *);
-extern void shorter_test_time(struct test_list *, int *, int *);
-extern char txt_longer_test_time[80];
-extern char txt_shorter_test_time[80];
+extern void pad_test_shutdown(struct test_list *, int);
+extern void pad_test_startup(int);
+extern void page_loop(void);
 extern void set_augment_txt(void);
-extern void longer_augment(struct test_list *, int *, int *);
 extern void shorter_augment(struct test_list *, int *, int *);
-extern char txt_longer_augment[80];
-extern char txt_shorter_augment[80];
-extern int sliding_scale(int, int, int);
-
-/* sync.c */
-extern void verify_time(void);
-extern int tty_sync_error(void);
-extern void flush_input(void);
-extern void sync_test(struct test_menu *);
-extern void sync_handshake(struct test_list *, int *, int *);
+extern void shorter_test_time(struct test_list *, int *, int *);
 
 /* charset.c */
+extern struct test_list acs_test_list[];
 extern void set_attr(int);
 extern void eat_cookie(void);
 extern void put_mode(char *);
 
-/* init.c */
-extern void reset_init(void);
-extern void display_basic(void);
-extern void put_name(const char *, const char *);
-extern void charset_can_test(void);
-extern void curses_setup(char *);
-extern void bye_kids(int);
-
-/* scan.c */
-extern int scan_key(void);
-extern void scan_init(char *fn);
+/* crum.c */
+extern struct test_list crum_test_list[];
 
 /* ansi.c */
 extern void tools_status(struct test_list *, int *, int *);
 extern void tools_charset(struct test_list *, int *, int *);
 extern void tools_sgr(struct test_list *, int *, int *);
 
-/* pad.c */
+/* edit.c */
+extern struct test_menu change_pad_menu;
+extern struct test_list edit_test_list[];
+extern char *get_string_cap_byname(const char *, const char **);
+extern int cap_match(const char *names, const char *cap);
+extern int get_string_cap_byvalue(const char *);
+extern int user_modified(void);
+extern void can_test(const char *, int);
+extern void cap_index(const char *, int *);
+extern void edit_init(void);
+extern void save_info(struct test_list *, int *, int *);
+extern void show_report(struct test_list *, int *, int *);
 
 /* fun.c */
+extern struct test_list funkey_test_list[];
+extern struct test_list printer_test_list[];
 extern void enter_key(const char *, char *, char *);
 extern int tty_meta_prep(void);
 extern void tools_report(struct test_list *, int *, int *);
 
+/* init.c */
+extern void reset_init(void);
+extern void display_basic(void);
+extern void put_name(const char *, const char *);
+extern void charset_can_test(void);
+extern void curses_setup(char *);
+extern void bye_kids(int);
+
+/* scan.c */
+extern char **scan_up, **scan_down, **scan_name;
+extern int scan_key(void);
+extern unsigned scan_max;	/* length of longest scan code */
+extern unsigned *scan_tested, *scan_length;
+extern void scan_init(char *fn);
+
 /* sysdep.c */
-extern void tty_set(void);
-extern void tty_raw(int, int);
-extern void tty_init(void);
-extern void tty_reset(void);
-extern void spin_flush(void);
+extern int initial_stty_query(int);
+extern int stty_query(int);
+extern void ignoresig(void);
 extern void read_key(char *, int);
 extern void set_alarm_clock(int);
-extern void ignoresig(void);
-extern int stty_query(int);
-extern int initial_stty_query(int);
-
-/* edit.c */
-extern int user_modified(void);
-extern void save_info(struct test_list *, int *, int *);
-extern void can_test(const char *, int);
-extern void cap_index(const char *, int *);
-extern int cap_match(const char *names, const char *cap);
-extern void edit_init(void);
-extern char *get_string_cap_byname(const char *, const char **);
-extern int get_string_cap_byvalue(const char *);
-extern void show_report(struct test_list *, int *, int *);
+extern void spin_flush(void);
+extern void tty_init(void);
+extern void tty_raw(int, int);
+extern void tty_reset(void);
+extern void tty_set(void);
 
 /* menu.c */
-extern void menu_prompt(void);
-extern void menu_can_scan(const struct test_menu *);
-extern void menu_display(struct test_menu *, int *);
+extern char prompt_string[80];	/* menu prompt storage */
+extern int subtest_menu(struct test_list *, int *, int *);
+extern struct test_list *augment_test;
 extern void generic_done_message(struct test_list *, int *, int *);
-extern void pad_done_message(struct test_list *, int *, int *);
+extern void menu_can_scan(const struct test_menu *);
 extern void menu_clear_screen(struct test_list *, int *, int *);
+extern void menu_display(struct test_menu *, int *);
+extern void menu_prompt(void);
 extern void menu_reset_init(struct test_list *, int *, int *);
-extern int subtest_menu(struct test_list *, int *, int *);
+extern void pad_done_message(struct test_list *, int *, int *);
+
+/* modes.c */
+extern struct test_list mode_test_list[];
+
+/* pad.c */
+extern struct test_list pad_test_list[];
+
+/* sync.c */
+extern struct test_menu sync_menu;
+extern int tty_sync_error(void);
+extern void flush_input(void);
+extern void sync_handshake(struct test_list *, int *, int *);
+extern void sync_test(struct test_menu *);
+extern void verify_time(void);
 
 #endif /* NCURSES_TACK_H_incl */
diff -Naur ncurses-5.4.orig/test/Makefile.in ncurses-5.4/test/Makefile.in
--- ncurses-5.4.orig/test/Makefile.in	2003-12-07 01:36:16.000000000 +0000
+++ ncurses-5.4/test/Makefile.in	2005-05-13 04:09:58.000000000 +0000
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.77 2003/12/07 01:36:16 tom Exp $
+# $Id: Makefile.in,v 1.82 2005/04/30 14:08:25 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2003,2005 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"), #
@@ -77,7 +77,7 @@
 LD		= @LD@
 LINK		= @LINK_TESTS@ $(LIBTOOL_LINK) $(CC) $(CFLAGS)
 
-LDFLAGS		= @LD_MODEL@ @TEST_ARGS@ @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
+LDFLAGS		= @LD_MODEL@ @LOCAL_LDFLAGS@ @LDFLAGS@
 
 LDFLAGS_LIBTOOL	= $(LDFLAGS) $(CFLAGS_LIBTOOL)
 LDFLAGS_NORMAL	= $(LDFLAGS) $(CFLAGS_NORMAL)
@@ -85,7 +85,17 @@
 LDFLAGS_PROFILE	= $(LDFLAGS) $(CFLAGS_PROFILE)
 LDFLAGS_SHARED	= $(LDFLAGS) $(CFLAGS_SHARED) @LD_SHARED_OPTS@
 
-LDFLAGS_DEFAULT	= $(LDFLAGS_@DFT_UPR_MODEL@)
+# use these for linking with all of the libraries
+LIBS_DEFAULT	= @TEST_ARGS@ @LIBS@
+LDFLAGS_DEFAULT	= $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_DEFAULT)
+
+# use these for linking with the (n)curses library
+LIBS_CURSES	= `echo "@TEST_ARGS@ @LIBS@" | sed -e 's/-lform.*-lpanel[^ ]*//'`
+LDFLAGS_CURSES	= $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_CURSES)
+
+# use these for linking with the tinfo library if we have it, or curses library if not
+LIBS_TINFO	= @TINFO_ARGS@ @LIBS@
+LDFLAGS_TINFO	= $(LDFLAGS_@DFT_UPR_MODEL@) $(LIBS_TINFO)
 
 LINT		= @LINT@
 LINT_OPTS	= @LINT_OPTS@
@@ -102,6 +112,7 @@
 	demo_keyok$x \
 	demo_menus$x \
 	demo_panels$x \
+	demo_termcap$x \
 	ditto$x \
 	dots$x \
 	filter$x \
@@ -131,29 +142,32 @@
 
 sources:
 
+tags:
+	ctags *.[ch]
+
 background$x: $(MODEL)/background$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/background$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/background$o $(LDFLAGS_CURSES)
 
 blue$x: $(MODEL)/blue$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/blue$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/blue$o $(LDFLAGS_CURSES)
 
 bs$x: $(MODEL)/bs$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/bs$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/bs$o $(LDFLAGS_CURSES)
 
 cardfile$x: $(MODEL)/cardfile$o $(LOCAL_LIBS)
 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/cardfile$o $(LDFLAGS_DEFAULT)
 
 color_set$x: $(MODEL)/color_set$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/color_set$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/color_set$o $(LDFLAGS_CURSES)
 
 demo_defkey$x: $(MODEL)/demo_defkey$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_defkey$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_defkey$o $(LDFLAGS_CURSES)
 
 demo_forms$x: $(MODEL)/demo_forms$o $(MODEL)/edit_field$o $(LOCAL_LIBS)
 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_forms$o $(MODEL)/edit_field$o $(LDFLAGS_DEFAULT)
 
 demo_keyok$x: $(MODEL)/demo_keyok$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_keyok$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_keyok$o $(LDFLAGS_CURSES)
 
 demo_menus$x: $(MODEL)/demo_menus$o $(LOCAL_LIBS)
 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_menus$o $(LDFLAGS_DEFAULT)
@@ -161,77 +175,80 @@
 demo_panels$x: $(MODEL)/demo_panels$o $(LOCAL_LIBS)
 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_panels$o $(LDFLAGS_DEFAULT)
 
+demo_termcap$x: $(MODEL)/demo_termcap$o $(LOCAL_LIBS)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/demo_termcap$o $(LDFLAGS_TINFO)
+
 ditto$x: $(MODEL)/ditto$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ditto$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ditto$o $(LDFLAGS_CURSES)
 
 dots$x: $(MODEL)/dots$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/dots$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/dots$o $(LDFLAGS_TINFO)
 
 filter$x: $(MODEL)/filter$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/filter$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/filter$o $(LDFLAGS_CURSES)
 
 firework$x: $(MODEL)/firework$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/firework$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/firework$o $(LDFLAGS_CURSES)
 
 firstlast$x: $(MODEL)/firstlast$o $(LOCAL_LIBS)
 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/firstlast$o $(LDFLAGS_DEFAULT)
 
 gdc$x: $(MODEL)/gdc$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/gdc$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/gdc$o $(LDFLAGS_CURSES)
 
 hanoi$x: $(MODEL)/hanoi$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hanoi$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hanoi$o $(LDFLAGS_CURSES)
 
 hashtest$x: $(MODEL)/hashtest$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hashtest$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/hashtest$o $(LDFLAGS_CURSES)
 
 inserts$x: $(MODEL)/inserts$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/inserts$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/inserts$o $(LDFLAGS_CURSES)
 
 ins_wide$x: $(MODEL)/ins_wide$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ins_wide$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ins_wide$o $(LDFLAGS_CURSES)
 
 keynames$x: $(MODEL)/keynames$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/keynames$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/keynames$o $(LDFLAGS_TINFO)
 
 knight$x: $(MODEL)/knight$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/knight$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/knight$o $(LDFLAGS_CURSES)
 
 lrtest$x: $(MODEL)/lrtest$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/lrtest$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/lrtest$o $(LDFLAGS_CURSES)
 
 ncurses$x: $(MODEL)/ncurses$o $(LOCAL_LIBS)
 	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/ncurses$o $(LDFLAGS_DEFAULT)
 
 newdemo$x: $(MODEL)/newdemo$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/newdemo$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/newdemo$o $(LDFLAGS_CURSES)
 
 rain$x: $(MODEL)/rain$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/rain$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/rain$o $(LDFLAGS_CURSES)
 
 railroad$x: $(MODEL)/railroad$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/railroad$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/railroad$o $(LDFLAGS_TINFO)
 
 tclock$x: $(MODEL)/tclock$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/tclock$o $(LDFLAGS_DEFAULT) $(MATH_LIB)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/tclock$o $(LDFLAGS_CURSES) $(MATH_LIB)
 
 testaddch$x: $(MODEL)/testaddch$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testaddch$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testaddch$o $(LDFLAGS_CURSES)
 
 testcurs$x: $(MODEL)/testcurs$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testcurs$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testcurs$o $(LDFLAGS_CURSES)
 
 testscanw$x: $(MODEL)/testscanw$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testscanw$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/testscanw$o $(LDFLAGS_CURSES)
 
 view$x: $(MODEL)/view$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/view$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/view$o $(LDFLAGS_CURSES)
 
 worm$x: $(MODEL)/worm$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/worm$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/worm$o $(LDFLAGS_CURSES)
 
 xmas$x: $(MODEL)/xmas$o $(LOCAL_LIBS)
-	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/xmas$o $(LDFLAGS_DEFAULT)
+	@ECHO_LINK@ $(LINK) -o $@ $(MODEL)/xmas$o $(LDFLAGS_CURSES)
 
 libs \
 install \
diff -Naur ncurses-5.4.orig/test/README ncurses-5.4/test/README
--- ncurses-5.4.orig/test/README	2003-07-05 19:17:49.000000000 +0000
+++ ncurses-5.4/test/README	2005-05-13 04:09:57.000000000 +0000
@@ -1,4 +1,4 @@
--- $Id: README,v 1.15 2003/07/05 19:17:49 tom Exp $
+-- $Id: README,v 1.23 2005/04/16 23:21:41 tom Exp $
 -------------------------------------------------------------------------------
 
 The programs in this directory are designed to test your newest toy :-)
@@ -36,14 +36,14 @@
 TYPE_ALPHA			test: demo_forms ncurses
 TYPE_ENUM			test: demo_forms
 TYPE_INTEGER			test: demo_forms
-TYPE_IPV4			-
+TYPE_IPV4			test: demo_forms
 TYPE_NUMERIC			test: demo_forms
 TYPE_REGEXP			test: demo_forms
 current_field			test: demo_forms edit_field ncurses
-data_ahead			-
-data_behind			-
+data_ahead			test: demo_forms
+data_behind			test: demo_forms
 dup_field			-
-dynamic_field_info		-
+dynamic_field_info		test: demo_forms
 field_arg			-
 field_back			-
 field_buffer			test: cardfile demo_forms edit_field ncurses
@@ -54,7 +54,7 @@
 field_init			-
 field_just			-
 field_opts			test: demo_forms ncurses
-field_opts_off			test: cardfile
+field_opts_off			test: cardfile demo_forms
 field_opts_on			-
 field_pad			-
 field_status			-
@@ -75,7 +75,7 @@
 form_userptr			-
 form_win			test: cardfile demo_forms edit_field ncurses
 free_field			test: cardfile demo_forms ncurses
-free_fieldtype			-
+free_fieldtype			test: ncurses
 free_form			test: cardfile demo_forms ncurses
 link_field			-
 link_fieldtype			-
@@ -109,18 +109,18 @@
 set_form_term			-
 set_form_userptr		-
 set_form_win			test: cardfile demo_forms ncurses
-set_max_field			-
+set_max_field			test: demo_forms
 set_new_page			test: demo_forms
 unpost_form			test: cardfile demo_forms ncurses
 
 libmenu:
 -------
-current_item			test: ncurses
+current_item			test: demo_menus ncurses
 free_item			test: ncurses
-free_menu			test: ncurses
-item_count			-
+free_menu			test: demo_menus ncurses
+item_count			test: demo_menus
 item_description		-
-item_index			test: ncurses
+item_index			test: demo_menus ncurses
 item_init			-
 item_name			test: ncurses
 item_opts			-
@@ -128,54 +128,54 @@
 item_opts_on			-
 item_term			-
 item_userptr			-
-item_value			test: ncurses
+item_value			test: demo_menus ncurses
 item_visible			-
 menu_back			-
-menu_driver			test: ncurses
+menu_driver			test: demo_menus ncurses
 menu_fore			-
 menu_format			-
 menu_grey			-
 menu_init			-
-menu_items			test: ncurses
+menu_items			test: demo_menus ncurses
 menu_mark			-
 menu_opts			-
-menu_opts_off			test: ncurses
-menu_opts_on			-
+menu_opts_off			test: demo_menus ncurses
+menu_opts_on			test: demo_menus
 menu_pad			-
 menu_pattern			-
 menu_request_by_name		-
 menu_request_name		-
-menu_spacing			-
+menu_spacing			test: demo_menus
 menu_sub			-
 menu_term			-
 menu_userptr			-
-menu_win			test: ncurses
-new_item			test: ncurses
-new_menu			test: ncurses
+menu_win			test: demo_menus ncurses
+new_item			test: demo_menus ncurses
+new_menu			test: demo_menus ncurses
 pos_menu_cursor			lib: menu
-post_menu			test: ncurses
-scale_menu			test: ncurses
+post_menu			test: demo_menus ncurses
+scale_menu			test: demo_menus ncurses
 set_current_item		-
 set_item_init			-
 set_item_opts			-
 set_item_term			-
 set_item_userptr		-
-set_item_value			test: ncurses
-set_menu_back			-
-set_menu_fore			-
-set_menu_format			test: ncurses
+set_item_value			test: demo_menus ncurses
+set_menu_back			test: demo_menus
+set_menu_fore			test: demo_menus
+set_menu_format			test: demo_menus ncurses
 set_menu_grey			-
 set_menu_init			-
 set_menu_items			-
-set_menu_mark			-
+set_menu_mark			test: demo_menus
 set_menu_opts			-
 set_menu_pad			-
 set_menu_pattern		-
 set_menu_spacing		-
-set_menu_sub			test: ncurses
+set_menu_sub			test: demo_menus ncurses
 set_menu_term			-
 set_menu_userptr		-
-set_menu_win			test: ncurses
+set_menu_win			test: demo_menus ncurses
 set_top_row			-
 top_row				-
 unpost_menu			test: ncurses
@@ -184,18 +184,18 @@
 ----------
 BC				-
 COLORS				test: ncurses xmas
-COLOR_PAIR			test: blue bs demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
+COLOR_PAIR			test: background blue bs cardfile demo_forms demo_menus filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
 COLOR_PAIRS			test: ncurses newdemo
-COLS				test: cardfile demo_defkey demo_forms demo_keyok edit_field firework hashtest ins_wide inserts lrtest ncurses newdemo rain tclock testcurs view worm
+COLS				test: cardfile demo_defkey demo_forms demo_keyok demo_menus edit_field firework hashtest ins_wide inserts lrtest ncurses newdemo rain tclock testcurs view worm
 ESCDELAY			lib: ncurses
-LINES				test: cardfile demo_defkey demo_keyok edit_field firework hanoi hashtest ins_wide inserts lrtest ncurses newdemo rain tclock testcurs view worm xmas
-PAIR_NUMBER			lib: ncurses
+LINES				test: cardfile demo_defkey demo_keyok demo_menus edit_field firework hanoi hashtest ins_wide inserts lrtest ncurses newdemo rain tclock testcurs view worm xmas
+PAIR_NUMBER			test: ncurses
 PC				lib: ncurses
 SP				lib: ncurses
 TABSIZE				lib: menu
 UP				-
 acs_map				test: gdc ins_wide inserts knight ncurses newdemo testcurs
-add_wch				-
+add_wch				test: ncurses
 add_wchnstr			test: ncurses
 add_wchstr			test: view
 addch				test: blue bs ditto hashtest ncurses testaddch view worm
@@ -204,37 +204,37 @@
 addnstr				-
 addnwstr			-
 addstr				test: blue bs cardfile gdc hanoi lrtest ncurses
-addwstr				-
+addwstr				test: ncurses
 assume_default_colors		test: ncurses
-attr_get			-
+attr_get			test: ncurses
 attr_off			test: ncurses
 attr_on				test: ncurses
-attr_set			-
+attr_set			test: ncurses
 attroff				test: filter gdc ncurses tclock
 attron				test: bs filter gdc ncurses
 attrset				test: bs firework gdc hanoi ncurses rain tclock testaddch testcurs
 baudrate			lib: ncurses
-beep				test: blue bs cardfile demo_forms edit_field hanoi ins_wide inserts knight ncurses tclock testcurs view xmas
-bkgd				test: demo_forms ncurses tclock view
-bkgdset				test: ncurses testaddch
-bkgrnd				-
-bkgrndset			-
+beep				test: blue bs cardfile demo_forms demo_menus edit_field hanoi ins_wide inserts knight ncurses tclock testcurs view xmas
+bkgd				test: background cardfile demo_forms ncurses tclock view
+bkgdset				test: background ncurses testaddch
+bkgrnd				test: ncurses
+bkgrndset			test: ncurses
 boolcodes			progs: dump_entry
 boolfnames			progs: dump_entry
 boolnames			progs: dump_entry infocmp
 border				-
 border_set			-
-box				test: cardfile demo_forms edit_field ins_wide inserts lrtest ncurses newdemo testcurs
+box				test: cardfile demo_forms demo_menus edit_field ins_wide inserts lrtest ncurses newdemo testcurs
 box_set				test: ncurses
 can_change_color		test: ncurses
-cbreak				test: blue bs cardfile demo_defkey demo_forms demo_keyok ditto filter firework gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo tclock testcurs view worm xmas
+cbreak				test: background blue bs cardfile color_set demo_defkey demo_forms demo_keyok demo_menus ditto filter firework gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo tclock testcurs view worm xmas
 chgat				-
 clear				test: blue bs gdc ncurses testcurs xmas
 clearok				test: bs knight
-clrtobot			test: ncurses
+clrtobot			test: demo_menus ncurses
 clrtoeol			test: blue bs hanoi hashtest ncurses view
 color_content			test: ncurses
-color_set			-
+color_set			test: color_set ncurses
 copywin				test: testcurs
 cur_term			test: dots lrtest progs: clear tic tput tset
 curs_set			test: firework gdc hanoi lrtest newdemo rain tclock testcurs worm xmas
@@ -248,14 +248,14 @@
 delch				-
 deleteln			-
 delscreen			-
-delwin				test: cardfile demo_forms edit_field ncurses newdemo testcurs
-derwin				test: cardfile demo_forms ncurses
+delwin				test: cardfile demo_forms demo_menus edit_field ins_wide inserts ncurses newdemo testcurs
+derwin				test: cardfile demo_forms demo_menus ins_wide inserts ncurses
 doupdate			test: cardfile edit_field ins_wide inserts knight ncurses
 dupwin				test: edit_field
 echo				test: bs hanoi ncurses testcurs testscanw
 echo_wchar			test: ncurses
 echochar			test: ncurses
-endwin				test: blue bs cardfile demo_defkey demo_forms demo_keyok ditto filter firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo rain tclock testaddch testcurs testscanw view worm xmas
+endwin				test: background blue bs cardfile color_set demo_defkey demo_forms demo_keyok demo_menus ditto filter firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo rain tclock testaddch testcurs testscanw view worm xmas
 erase				test: cardfile filter firework firstlast hanoi lrtest ncurses tclock testcurs
 erasechar			lib: ncurses
 erasewchar			-
@@ -265,16 +265,16 @@
 get_wch				-
 get_wstr			-
 getbkgd				test: ncurses
-getbkgrnd			-
-getcchar			test: view
-getch				test: blue bs ditto firework firstlast hanoi hashtest lrtest rain tclock testaddch testcurs view worm xmas
+getbkgrnd			test: ncurses
+getcchar			test: ncurses view
+getch				test: background blue bs color_set ditto firework firstlast hanoi hashtest lrtest rain tclock testaddch testcurs view worm xmas
 getmouse			test: bs knight ncurses
 getn_wstr			-
 getnstr				test: filter ncurses
 getstr				-
 getwin				test: ncurses
 halfdelay			test: view
-has_colors			test: bs demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testcurs view worm xmas
+has_colors			test: background bs cardfile color_set demo_forms demo_menus filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testcurs view worm xmas
 has_ic				test: lrtest
 has_il				lib: ncurses
 has_key				lib: ncurses
@@ -290,18 +290,18 @@
 inchnstr			-
 inchstr				-
 init_color			test: ncurses
-init_pair			test: blue bs demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
-initscr				test: blue bs cardfile demo_defkey demo_forms demo_keyok firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo rain tclock testaddch testcurs testscanw view worm xmas
+init_pair			test: background blue bs cardfile color_set demo_forms demo_menus filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
+initscr				test: background blue bs cardfile color_set demo_defkey demo_forms demo_keyok demo_menus firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses newdemo rain tclock testaddch testcurs testscanw view worm xmas
 innstr				-
 innwstr				-
-ins_nwstr			-
-ins_wch				-
-ins_wstr			-
-insch				-
+ins_nwstr			test: ins_wide
+ins_wch				test: ins_wide
+ins_wstr			test: ins_wide
+insch				test: ins_wide inserts
 insdelln			-
 insertln			-
-insnstr				-
-insstr				-
+insnstr				test: inserts
+insstr				test: inserts
 instr				-
 intrflush			test: demo_forms
 inwstr				-
@@ -314,17 +314,17 @@
 keybound			test: demo_defkey
 keyname				test: demo_defkey demo_keyok edit_field keynames ncurses testcurs view progs: tic
 keyok				test: demo_keyok
-keypad				test: bs cardfile demo_defkey demo_forms demo_keyok edit_field filter firework hashtest ins_wide inserts knight lrtest ncurses tclock testcurs testscanw view
+keypad				test: bs cardfile demo_defkey demo_forms demo_keyok demo_menus edit_field filter firework hashtest ins_wide inserts knight lrtest ncurses tclock testcurs testscanw view
 killchar			lib: ncurses
 killwchar			-
 leaveok				test: hanoi
 longname			test: testcurs progs: tput
 mcprint				-
 meta				test: ncurses
-mouse_trafo			-
+mouse_trafo			lib: menu
 mouseinterval			-
-mousemask			test: bs knight ncurses
-move				test: blue bs cardfile gdc hanoi hashtest knight lrtest ncurses testscanw view worm xmas
+mousemask			test: bs demo_menus knight ncurses
+move				test: blue bs cardfile demo_menus gdc hanoi hashtest ins_wide inserts knight lrtest ncurses testscanw view worm xmas
 mvadd_wch			test: ncurses
 mvadd_wchnstr			-
 mvadd_wchstr			-
@@ -355,20 +355,20 @@
 mvinchstr			-
 mvinnstr			-
 mvinnwstr			-
-mvins_nwstr			-
-mvins_wch			-
-mvins_wstr			-
-mvinsch				-
-mvinsnstr			-
-mvinsstr			-
+mvins_nwstr			test: ins_wide
+mvins_wch			test: ins_wide
+mvins_wstr			test: ins_wide
+mvinsch				test: ins_wide inserts
+mvinsnstr			test: inserts
+mvinsstr			test: inserts
 mvinstr				-
 mvinwstr			-
-mvprintw			test: bs firework hanoi ncurses tclock view
+mvprintw			test: bs demo_menus firework hanoi ncurses tclock view
 mvscanw				-
 mvvline				test: ncurses
 mvvline_set			test: ncurses
 mvwadd_wch			-
-mvwadd_wchnstr			-
+mvwadd_wchnstr			lib: form
 mvwadd_wchstr			-
 mvwaddch			test: newdemo testcurs xmas
 mvwaddchnstr			-
@@ -389,18 +389,18 @@
 mvwhline_set			-
 mvwin				test: cardfile testcurs xmas
 mvwin_wch			-
-mvwin_wchnstr			-
+mvwin_wchnstr			lib: form
 mvwin_wchstr			-
 mvwinch				test: newdemo testcurs
 mvwinchnstr			-
 mvwinchstr			-
 mvwinnstr			test: testcurs
 mvwinnwstr			-
-mvwins_nwstr			-
+mvwins_nwstr			test: ins_wide
 mvwins_wch			test: ins_wide
 mvwins_wstr			test: ins_wide
 mvwinsch			test: ins_wide inserts
-mvwinsnstr			-
+mvwinsnstr			test: inserts
 mvwinsstr			test: inserts testcurs
 mvwinstr			-
 mvwinwstr			-
@@ -408,18 +408,18 @@
 mvwscanw			test: testcurs
 mvwvline			test: ins_wide inserts
 mvwvline_set			-
-napms				test: firework gdc hanoi lrtest ncurses newdemo railroad rain tclock testcurs view worm xmas progs: tset
+napms				test: dots firework gdc hanoi lrtest ncurses newdemo railroad rain tclock testcurs view worm xmas progs: tset
 newpad				test: edit_field ncurses testcurs
 newscr				lib: ncurses
 newterm				test: ditto filter gdc
-newwin				test: cardfile demo_defkey demo_forms demo_keyok edit_field firstlast ins_wide inserts knight ncurses newdemo testcurs xmas
+newwin				test: cardfile demo_defkey demo_forms demo_keyok demo_menus edit_field firstlast ins_wide inserts knight ncurses newdemo testcurs xmas
 nl				test: demo_forms ncurses rain testcurs
 nocbreak			test: testcurs
 nodelay				test: firework gdc lrtest ncurses newdemo rain tclock view xmas
-noecho				test: bs cardfile demo_defkey demo_forms demo_keyok ditto firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses rain tclock testcurs view worm xmas
+noecho				test: background bs cardfile color_set demo_defkey demo_forms demo_keyok demo_menus ditto firework firstlast gdc hanoi hashtest ins_wide inserts knight lrtest ncurses rain tclock testcurs view worm xmas
 nonl				test: bs demo_forms hashtest ncurses view worm xmas
 noqiflush			-
-noraw				test: demo_forms ncurses testcurs
+noraw				test: demo_forms demo_menus ncurses testcurs
 notimeout			-
 numcodes			progs: dump_entry
 numfnames			progs: dump_entry
@@ -427,17 +427,18 @@
 ospeed				progs: tset
 overlay				test: testcurs xmas
 overwrite			test: ncurses
-pair_content			lib: ncurses
+pair_content			test: background color_set
+pecho_wchar			-
 pechochar			-
 pnoutrefresh			test: edit_field ncurses
 prefresh			test: testcurs
-printw				test: blue bs demo_defkey demo_keyok filter ncurses testcurs testscanw view
+printw				test: background blue bs color_set demo_defkey demo_keyok filter ncurses testcurs testscanw view
 putp				progs: tput
 putwin				test: ncurses
 qiflush				-
 raw				test: demo_forms ncurses testcurs
 redrawwin			-
-refresh				test: blue bs demo_defkey demo_forms demo_keyok ditto filter firstlast gdc hanoi hashtest lrtest ncurses tclock testcurs view worm xmas
+refresh				test: blue bs demo_defkey demo_forms demo_keyok demo_menus ditto filter firstlast gdc hanoi hashtest lrtest ncurses tclock testcurs view worm xmas
 reset_prog_mode			test: filter ncurses
 reset_shell_mode		test: bs filter
 resetty				-
@@ -478,7 +479,7 @@
 slk_wset			test: ncurses
 standend			test: blue gdc ncurses worm
 standout			test: blue ncurses
-start_color			test: blue bs demo_forms filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
+start_color			test: background blue bs cardfile color_set demo_forms demo_menus filter firework gdc hanoi ins_wide inserts knight ncurses newdemo rain tclock testaddch testcurs view worm xmas
 stdscr				test: bs demo_forms ditto filter firework gdc hanoi hashtest ins_wide inserts knight lrtest ncurses rain tclock testcurs testscanw view xmas
 strcodes			progs: dump_entry
 strfnames			progs: dump_entry
@@ -486,7 +487,7 @@
 subpad				test: testcurs
 subwin				test: ncurses newdemo testcurs
 syncok				-
-term_attrs			-
+term_attrs			test: ncurses
 termattrs			test: ncurses testcurs
 termname			test: testcurs
 tgetent				test: railroad
@@ -499,17 +500,17 @@
 tigetstr			test: blue demo_defkey testcurs progs: tput
 timeout				test: rain
 touchline			lib: ncurses
-touchwin			test: edit_field filter firstlast ncurses xmas
+touchwin			test: demo_menus edit_field filter firstlast ins_wide inserts ncurses xmas
 tparm				test: dots progs: tic tput
 tputs				test: dots railroad progs: clear tset
-trace				test: hanoi hashtest lrtest ncurses testcurs view worm
+trace				test: demo_menus hanoi hashtest lrtest ncurses testcurs view worm
 ttytype				lib: ncurses
 typeahead			test: testcurs
 unctrl				test: ncurses testcurs
 unget_wch			-
 ungetch				test: bs knight
 ungetmouse			-
-untouchwin			-
+untouchwin			lib: form
 use_default_colors		test: filter firework gdc hanoi knight ncurses rain tclock worm xmas
 use_env				progs: tput
 use_extended_names		progs: infocmp tic
@@ -524,23 +525,23 @@
 vwprintw			lib: ncurses
 vwscanw				lib: ncurses
 wadd_wch			lib: ncurses
-wadd_wchnstr			lib: ncurses
+wadd_wchnstr			lib: form
 wadd_wchstr			-
-waddch				test: firstlast knight ncurses
+waddch				test: demo_forms firstlast knight ncurses
 waddchnstr			lib: ncurses
 waddchstr			-
-waddnstr			lib: form
+waddnstr			lib: menu
 waddnwstr			test: ncurses
 waddstr				test: demo_forms edit_field firstlast ins_wide knight ncurses testcurs
 waddwstr			test: ins_wide
 wattr_get			-
-wattr_off			lib: menu
-wattr_on			lib: menu
+wattr_off			lib: ncurses
+wattr_on			lib: ncurses
 wattr_set			-
 wattroff			test: demo_forms ncurses testcurs xmas
 wattron				test: testcurs xmas
 wattrset			test: demo_forms ncurses newdemo testcurs xmas
-wbkgd				test: demo_forms ncurses newdemo testcurs
+wbkgd				test: cardfile demo_forms ncurses newdemo testcurs
 wbkgdset			test: ins_wide inserts ncurses
 wbkgrnd				lib: ncurses
 wbkgrndset			lib: ncurses
@@ -560,28 +561,28 @@
 werase				test: cardfile demo_forms edit_field firstlast knight ncurses newdemo testcurs xmas
 wget_wch			test: ins_wide ncurses
 wget_wstr			-
-wgetch				test: cardfile demo_defkey demo_keyok edit_field gdc inserts knight ncurses newdemo testcurs
+wgetch				test: cardfile demo_defkey demo_keyok demo_menus edit_field gdc inserts knight ncurses newdemo testcurs
 wgetn_wstr			test: ncurses
 wgetnstr			test: ncurses
 wgetstr				-
 whline				test: testcurs
 whline_set			lib: ncurses
-win_wch				lib: ncurses
-win_wchnstr			lib: ncurses
+win_wch				lib: form
+win_wchnstr			lib: form
 win_wchstr			-
 winch				test: knight testcurs
 winchnstr			lib: ncurses
 winchstr			-
 winnstr				test: demo_defkey
 winnwstr			lib: ncurses
-wins_nwstr			lib: ncurses
-wins_wch			lib: ncurses
-wins_wstr			-
-winsch				test: testcurs
-winsdelln			lib: form
+wins_nwstr			test: ins_wide
+wins_wch			test: ins_wide
+wins_wstr			test: ins_wide
+winsch				test: ins_wide inserts testcurs
+winsdelln			lib: ncurses
 winsertln			test: testcurs
-winsnstr			lib: form
-winsstr				-
+winsnstr			test: inserts
+winsstr				test: inserts
 winstr				-
 winwstr				lib: ncurses
 wmouse_trafo			lib: menu
@@ -589,7 +590,7 @@
 wnoutrefresh			test: edit_field ins_wide inserts knight ncurses
 wprintw				test: demo_defkey demo_forms demo_keyok edit_field ins_wide inserts knight ncurses testcurs
 wredrawln			lib: ncurses
-wrefresh			test: demo_forms demo_keyok edit_field firstlast knight lrtest ncurses newdemo tclock testcurs view xmas
+wrefresh			test: demo_forms demo_keyok demo_menus edit_field firstlast knight lrtest ncurses newdemo tclock testcurs view xmas
 wresize				test: cardfile ncurses
 wscanw				test: testcurs
 wscrl				test: ncurses testcurs view
@@ -599,7 +600,7 @@
 wsyncdown			lib: ncurses
 wsyncup				lib: form
 wtimeout			test: ncurses
-wtouchln			lib: form
+wtouchln			lib: ncurses
 wunctrl				-
 wvline				test: testcurs
 wvline_set			lib: ncurses
diff -Naur ncurses-5.4.orig/test/aclocal.m4 ncurses-5.4/test/aclocal.m4
--- ncurses-5.4.orig/test/aclocal.m4	2003-10-19 00:09:23.000000000 +0000
+++ ncurses-5.4/test/aclocal.m4	2005-05-13 04:09:51.000000000 +0000
@@ -1,6 +1,88 @@
-dnl $Id: aclocal.m4,v 1.6 2003/10/19 00:09:23 tom Exp $
+dnl $Id: aclocal.m4,v 1.8 2005/02/27 00:02:01 tom Exp $
 dnl ---------------------------------------------------------------------------
 dnl ---------------------------------------------------------------------------
+dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30
+dnl -------------
+dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
+dnl The second parameter if given makes this macro verbose.
+dnl
+dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
+dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
+dnl confused by the quotes (which require backslashes to keep them usable).
+AC_DEFUN([CF_ADD_CFLAGS],
+[
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $1
+do
+case $cf_fix_cppflags in
+no)
+	case $cf_add_cflags in #(vi
+	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+		case $cf_add_cflags in
+		-D*)
+			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
+
+			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+			&& test -z "${cf_tst_cflags}" \
+			&& cf_fix_cppflags=yes
+
+			if test $cf_fix_cppflags = yes ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		*$cf_add_cflags) #(vi
+			;;
+		*) #(vi
+			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+			;;
+		esac
+		;;
+	*)
+		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+		;;
+	esac
+	;;
+yes)
+	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
+
+	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+	&& test -z "${cf_tst_cflags}" \
+	&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+	ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
+	CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+	ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
+	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+	ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
+	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+AC_SUBST(EXTRA_CPPFLAGS)
+
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_ADD_INCDIR version: 4 updated: 2002/12/21 14:25:52
 dnl -------------
 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
@@ -39,7 +121,77 @@
 done
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CHECK_CACHE version: 7 updated: 2001/12/19 00:50:10
+dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
+dnl ----------------
+dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
+dnl in the sharutils 4.2 distribution.
+AC_DEFUN([CF_ANSI_CC_CHECK],
+[
+AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
+cf_cv_ansi_cc=no
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX			-qlanglvl=ansi
+# Ultrix and OSF/1	-std1
+# HP-UX			-Aa -D_HPUX_SOURCE
+# SVR4			-Xc
+# UnixWare 1.2		(cannot use -Xc, since ANSI/POSIX clashes)
+for cf_arg in "-DCC_HAS_PROTOS" \
+	"" \
+	-qlanglvl=ansi \
+	-std1 \
+	-Ae \
+	"-Aa -D_HPUX_SOURCE" \
+	-Xc
+do
+	CF_ADD_CFLAGS($cf_arg)
+	AC_TRY_COMPILE(
+[
+#ifndef CC_HAS_PROTOS
+#if !defined(__STDC__) || (__STDC__ != 1)
+choke me
+#endif
+#endif
+],[
+	int test (int i, double x);
+	struct s1 {int (*f) (int a);};
+	struct s2 {int (*f) (double a);};],
+	[cf_cv_ansi_cc="$cf_arg"; break])
+done
+CFLAGS="$cf_save_CFLAGS"
+CPPFLAGS="$cf_save_CPPFLAGS"
+])
+
+if test "$cf_cv_ansi_cc" != "no"; then
+if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
+	CF_ADD_CFLAGS($cf_cv_ansi_cc)
+else
+	AC_DEFINE(CC_HAS_PROTOS)
+fi
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44
+dnl ---------------
+dnl For programs that must use an ANSI compiler, obtain compiler options that
+dnl will make it recognize prototypes.  We'll do preprocessor checks in other
+dnl macros, since tools such as unproto can fake prototypes, but only part of
+dnl the preprocessor.
+AC_DEFUN([CF_ANSI_CC_REQD],
+[AC_REQUIRE([CF_ANSI_CC_CHECK])
+if test "$cf_cv_ansi_cc" = "no"; then
+	AC_ERROR(
+[Your compiler does not appear to recognize prototypes.
+You have the following choices:
+	a. adjust your compiler options
+	b. get an up-to-date compiler
+	c. use a wrapper such as unproto])
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
 dnl --------------
 dnl Check if we're accidentally using a cache from a different machine.
 dnl Derive the system name, as a check for reusing the autoconf cache.
@@ -48,9 +200,12 @@
 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
 dnl which is useful in cross-compiles.
+dnl
+dnl Note: we would use $ac_config_sub, but that is one of the places where
+dnl autoconf 2.5x broke compatibility with autoconf 2.13
 AC_DEFUN([CF_CHECK_CACHE],
 [
-if test -f $srcdir/config.guess ; then
+if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
 	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
 	system_name="$host_os"
 else
@@ -157,12 +312,13 @@
 
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_LIBS version: 22 updated: 2002/10/27 18:21:42
+dnl CF_CURSES_LIBS version: 23 updated: 2003/11/06 19:59:57
 dnl --------------
 dnl Look for the curses libraries.  Older curses implementations may require
 dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
 AC_DEFUN([CF_CURSES_LIBS],[
 
+AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
 AC_MSG_CHECKING(if we have identified curses libraries)
 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
 	[initscr(); tgoto("?", 0,0)],
@@ -281,7 +437,7 @@
 dnl "dirname" is not portable, so we fake it with a shell script.
 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_FIND_LIBRARY version: 7 updated: 2000/04/13 21:38:04
+dnl CF_FIND_LIBRARY version: 8 updated: 2004/11/23 20:14:58
 dnl ---------------
 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
 dnl prefer a standard location, and use -L options only if we do not find the
@@ -291,7 +447,7 @@
 dnl	$3 = includes
 dnl	$4 = code fragment to compile/link
 dnl	$5 = corresponding function-name
-dnl	$6 = flag, nonnull if failure causes an error-exit
+dnl	$6 = flag, nonnull if failure should not cause an error-exit
 dnl
 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
 dnl to use a -L option.
@@ -353,7 +509,7 @@
 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_GNU_SOURCE version: 3 updated: 2000/10/29 23:30:53
+dnl CF_GNU_SOURCE version: 4 updated: 2004/12/03 20:43:00
 dnl -------------
 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
@@ -363,6 +519,9 @@
 dnl Well, yes we could work around it...
 AC_DEFUN([CF_GNU_SOURCE],
 [
+AC_REQUIRE([CF_INTEL_COMPILER])
+
+if test "$INTEL_COMPILER" = no ; then
 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
 AC_TRY_COMPILE([#include <sys/types.h>],[
 #ifndef _XOPEN_SOURCE
@@ -381,6 +540,7 @@
 	])
 ])
 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+fi
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
@@ -412,12 +572,54 @@
 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_INTEL_COMPILER version: 1 updated: 2004/12/03 20:27:48
+dnl -----------------
+dnl Check if the given compiler is really the Intel compiler for Linux.
+dnl It tries to imitate gcc, but does not return an error when it finds a
+dnl mismatch between prototypes, e.g., as exercised by CF_MISSING_CHECK.
+dnl
+dnl This macro should be run "soon" after AC_PROG_CC, to ensure that it is
+dnl not mistaken for gcc.
+AC_DEFUN([CF_INTEL_COMPILER],[
+AC_REQUIRE([AC_PROG_CC])
+
+INTEL_COMPILER=no
+
+if test "$GCC" = yes ; then
+	case $host_os in
+	linux*|gnu*)
+		AC_MSG_CHECKING(if this is really Intel compiler)
+		cf_save_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS -no-gcc"
+		AC_TRY_COMPILE([],[
+#ifdef __INTEL_COMPILER
+#else
+make an error
+#endif
+],[INTEL_COMPILER=yes
+cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
+],[])
+		CFLAGS="$cf_save_CFLAGS"
+		AC_MSG_RESULT($INTEL_COMPILER)
+		;;
+	esac
+fi
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
 dnl ---------------
 dnl Construct a search-list for a nonstandard library-file
 AC_DEFUN([CF_LIBRARY_PATH],
 [CF_SUBDIR_PATH($1,$2,lib)])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
+dnl ----------
+dnl Write a debug message to config.log, along with the line number in the
+dnl configure script.
+AC_DEFUN([CF_MSG_LOG],[
+echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_NCURSES_CC_CHECK version: 3 updated: 2003/01/12 18:59:28
 dnl -------------------
 dnl Check if we can compile with ncurses' header file
@@ -451,7 +653,7 @@
 	,[$1=no])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_CPPFLAGS version: 16 updated: 2002/12/29 18:30:46
+dnl CF_NCURSES_CPPFLAGS version: 17 updated: 2003/11/06 19:59:57
 dnl -------------------
 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
 dnl the CPPFLAGS variable so we can include its header.
@@ -475,6 +677,7 @@
 AC_DEFUN([CF_NCURSES_CPPFLAGS],
 [AC_REQUIRE([CF_WITH_CURSES_DIR])
 
+AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
 
 test -n "$cf_cv_curses_dir" && \
@@ -549,7 +752,7 @@
 CF_NCURSES_VERSION
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_LIBS version: 11 updated: 2002/12/22 14:22:25
+dnl CF_NCURSES_LIBS version: 12 updated: 2004/04/27 16:26:05
 dnl ---------------
 dnl Look for the ncurses library.  This is a little complicated on Linux,
 dnl because it may be linked with the gpm (general purpose mouse) library.
@@ -579,7 +782,9 @@
 freebsd*)
 	# This is only necessary if you are linking against an obsolete
 	# version of ncurses (but it should do no harm, since it's static).
-	AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
+	if test "$cf_nculib_root" = ncurses ; then
+		AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
+	fi
 	;;
 esac
 
@@ -615,13 +820,14 @@
 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_VERSION version: 10 updated: 2002/10/27 18:21:42
+dnl CF_NCURSES_VERSION version: 11 updated: 2003/11/06 19:59:57
 dnl ------------------
 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
 AC_DEFUN([CF_NCURSES_VERSION],
 [
+AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
 	cf_cv_ncurses_version=no
 	cf_tempfile=out$$
@@ -707,37 +913,63 @@
 esac
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_PREDEFINE version: 1 updated: 2003/07/26 17:53:56
-dnl ------------
-dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
-dnl
-dnl $1 = symbol to test
-dnl $2 = value (if any) to use for a predefinition
-AC_DEFUN([CF_PREDEFINE],
+dnl CF_POSIX_C_SOURCE version: 3 updated: 2005/02/04 06:56:22
+dnl -----------------
+dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
+dnl
+dnl	POSIX.1-1990				_POSIX_SOURCE
+dnl	POSIX.1-1990 and			_POSIX_SOURCE and
+dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
+dnl		Bindings Option
+dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
+dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
+dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
+dnl
+dnl Parameters:
+dnl	$1 is the nominal value for _POSIX_C_SOURCE
+AC_DEFUN([CF_POSIX_C_SOURCE],
 [
-AC_MSG_CHECKING(if we must define $1)
-AC_TRY_COMPILE([#include <sys/types.h>
-],[
-#ifndef $1
+cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
+AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
+	CF_MSG_LOG(if the symbol is already defined go no further)
+	AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _POSIX_C_SOURCE
 make an error
-#endif],[cf_result=no],[cf_result=yes])
-AC_MSG_RESULT($cf_result)
-
-if test "$cf_result" = yes ; then
-	CPPFLAGS="$CPPFLAGS ifelse($2,,-D$1,[-D$1=$2])"
-elif test "x$2" != "x" ; then
-	AC_MSG_CHECKING(checking for compatible value versus $2)
-	AC_TRY_COMPILE([#include <sys/types.h>
-],[
-#if $1-$2 < 0
+#endif],
+	[cf_cv_posix_c_source=no],
+	[cf_want_posix_source=no
+	 case .$cf_POSIX_C_SOURCE in
+	 .[[12]]??*)
+		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+		;;
+	 .2)
+		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+		cf_want_posix_source=yes
+		;;
+	 .*)
+		cf_want_posix_source=yes
+		;;
+	 esac
+	 if test "$cf_want_posix_source" = yes ; then
+		AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifdef _POSIX_SOURCE
 make an error
-#endif],[cf_result=yes],[cf_result=no])
-	AC_MSG_RESULT($cf_result)
-	if test "$cf_result" = no ; then
-		# perhaps we can override it - try...
-		CPPFLAGS="$CPPFLAGS -D$1=$2"
-	fi
-fi
+#endif],[],
+		cf_cv_posix_c_source="$cf_cv_posix_c_source -U_POSIX_SOURCE -D_POSIX_SOURCE")
+	 fi
+	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
+	 cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
+	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
+	 AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif],,
+	[cf_cv_posix_c_source=no])
+	CPPFLAGS="$cf_save"
+	])
+])
+test "$cf_cv_posix_c_source" != no && CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl CF_SUBDIR_PATH version: 3 updated: 2002/12/29 18:30:46
@@ -862,6 +1094,13 @@
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14
+dnl ----------
+dnl Use AC_VERBOSE w/o the warnings
+AC_DEFUN([CF_VERBOSE],
+[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
 dnl ------------------
 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
@@ -873,3 +1112,79 @@
 	 cf_cv_curses_dir=$withval],
 	[cf_cv_curses_dir=no])
 ])dnl
+dnl ---------------------------------------------------------------------------
+dnl CF_XOPEN_SOURCE version: 17 updated: 2005/02/06 12:07:45
+dnl ---------------
+dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
+dnl or adapt to the vendor's definitions to get equivalent functionality.
+dnl
+dnl Parameters:
+dnl	$1 is the nominal value for _XOPEN_SOURCE
+dnl	$2 is the nominal value for _POSIX_C_SOURCE
+AC_DEFUN([CF_XOPEN_SOURCE],[
+
+cf_XOPEN_SOURCE=ifelse($1,,500,$1)
+cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
+
+case $host_os in #(vi
+aix[[45]]*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
+	;;
+freebsd*) #(vi
+	# 5.x headers associate
+	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
+	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
+	cf_POSIX_C_SOURCE=200112L
+	cf_XOPEN_SOURCE=600
+	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+	;;
+hpux*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
+	;;
+irix[[56]].*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
+	;;
+linux*|gnu*) #(vi
+	CF_GNU_SOURCE
+	;;
+mirbsd*) #(vi
+	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
+	;;
+netbsd*) #(vi
+	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
+	;;
+openbsd*) #(vi
+	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+	;;
+osf[[45]]*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
+	;;
+sco*) #(vi
+	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+	;;
+solaris*) #(vi
+	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
+	;;
+*)
+	AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
+	AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifndef _XOPEN_SOURCE
+make an error
+#endif],
+	[cf_cv_xopen_source=no],
+	[cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+	 AC_TRY_COMPILE([#include <sys/types.h>],[
+#ifdef _XOPEN_SOURCE
+make an error
+#endif],
+	[cf_cv_xopen_source=no],
+	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
+	CPPFLAGS="$cf_save"
+	])
+])
+test "$cf_cv_xopen_source" != no && CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE -D_XOPEN_SOURCE=$cf_cv_xopen_source"
+	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
+	;;
+esac
+])
diff -Naur ncurses-5.4.orig/test/bs.c ncurses-5.4/test/bs.c
--- ncurses-5.4.orig/test/bs.c	2003-12-06 18:10:13.000000000 +0000
+++ ncurses-5.4/test/bs.c	2005-05-13 04:09:51.000000000 +0000
@@ -7,7 +7,7 @@
  * v2.0 featuring strict ANSI/POSIX conformance, November 1993.
  * v2.1 with ncurses mouse support, September 1995
  *
- * $Id: bs.c,v 1.39 2003/12/06 18:10:13 tom Exp $
+ * $Id: bs.c,v 1.40 2004/04/11 00:00:53 tom Exp $
  */
 
 #include <time.h>
@@ -249,7 +249,7 @@
 
 /* VARARGS1 */
 static void
-prompt(int n, const char *f, const char *s)
+prompt(int n, NCURSES_CONST char *f, const char *s)
 /* print a message at the prompt line */
 {
     (void) move(PROMPTLINE + n, 0);
diff -Naur ncurses-5.4.orig/test/cardfile.c ncurses-5.4/test/cardfile.c
--- ncurses-5.4.orig/test/cardfile.c	2003-04-26 16:43:56.000000000 +0000
+++ ncurses-5.4/test/cardfile.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2003,2004 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            *
@@ -27,9 +27,9 @@
  ****************************************************************************/
 
 /*
- * Author: Thomas E. Dickey <dickey@clark.net> 1999
+ * Author: Thomas E. Dickey
  *
- * $Id: cardfile.c,v 1.23 2003/04/26 16:43:56 tom Exp $
+ * $Id: cardfile.c,v 1.27 2004/11/06 19:33:39 tom Exp $
  *
  * File format: text beginning in column 1 is a title; other text is content.
  */
@@ -43,6 +43,10 @@
 
 #define VISIBLE_CARDS 10
 #define OFFSET_CARD 2
+#define pair_1 1
+#define pair_2 2
+
+#define isVisible(cardp) ((cardp)->panel != 0)
 
 enum {
     MY_CTRL_x = MAX_FORM_COMMAND
@@ -61,6 +65,7 @@
 } CARD;
 
 static CARD *all_cards;
+static bool try_color = FALSE;
 static char default_name[] = "cardfile.dat";
 
 #if !HAVE_STRDUP
@@ -238,7 +243,8 @@
     if (first) {
 	if (depth && first->link)
 	    order_cards(first->link, depth - 1);
-	top_panel(first->panel);
+	if (isVisible(first))
+	    top_panel(first->panel);
     }
 }
 
@@ -248,8 +254,13 @@
 static CARD *
 next_card(CARD * now)
 {
-    if (now->link)
-	now = now->link;
+    if (now->link != 0) {
+	CARD *tst = now->link;
+	if (isVisible(tst))
+	    now = tst;
+	else
+	    tst = next_card(tst);
+    }
     return now;
 }
 
@@ -260,9 +271,24 @@
 prev_card(CARD * now)
 {
     CARD *p;
-    for (p = all_cards; p != 0; p = p->link)
-	if (p->link == now)
+    for (p = all_cards; p != 0; p = p->link) {
+	if (p->link == now) {
+	    if (!isVisible(p))
+		p = prev_card(p);
 	    return p;
+	}
+    }
+    return now;
+}
+
+/*
+ * Returns the first card in the list that we will display.
+ */
+static CARD *
+first_card(CARD * now)
+{
+    if (!isVisible(now))
+	now = next_card(now);
     return now;
 }
 
@@ -355,23 +381,38 @@
     WINDOW *win;
     CARD *p;
     CARD *top_card;
-    int visible_cards = count_cards();
-    int panel_wide = COLS - (visible_cards * OFFSET_CARD);
-    int panel_high = LINES - (visible_cards * OFFSET_CARD) - 5;
-    int form_wide = panel_wide - 2;
-    int form_high = panel_high - 2;
-    int y = (visible_cards - 1) * OFFSET_CARD;
-    int x = 0;
+    int visible_cards;
+    int panel_wide;
+    int panel_high;
+    int form_wide;
+    int form_high;
+    int y;
+    int x;
     int ch = ERR;
     int last_ch;
     int finished = FALSE;
 
     show_legend();
 
+    /* decide how many cards we can display */
+    visible_cards = count_cards();
+    while (
+	      (panel_wide = COLS - (visible_cards * OFFSET_CARD)) < 10 ||
+	      (panel_high = LINES - (visible_cards * OFFSET_CARD) - 5) < 5) {
+	--visible_cards;
+    }
+    form_wide = panel_wide - 2;
+    form_high = panel_high - 2;
+    y = (visible_cards - 1) * OFFSET_CARD;
+    x = 0;
+
     /* make a panel for each CARD */
     for (p = all_cards; p != 0; p = p->link) {
 
-	win = newwin(panel_high, panel_wide, y, x);
+	if ((win = newwin(panel_high, panel_wide, y, x)) == 0)
+	    break;
+
+	wbkgd(win, COLOR_PAIR(pair_2));
 	keypad(win, TRUE);
 	p->panel = new_panel(win);
 	box(win, 0, 0);
@@ -385,7 +426,8 @@
 	x += OFFSET_CARD;
     }
 
-    order_cards(top_card = all_cards, visible_cards);
+    top_card = first_card(all_cards);
+    order_cards(top_card, visible_cards);
 
     while (!finished) {
 	update_panels();
@@ -432,6 +474,8 @@
 		    FIELD **oldf = form_fields(p->form);
 		    WINDOW *olds = form_sub(p->form);
 
+		    if (!isVisible(p))
+			continue;
 		    win = form_win(p->form);
 
 		    /* move and resize the card as needed
@@ -483,15 +527,17 @@
 	p = all_cards;
 	all_cards = all_cards->link;
 
-	f = form_fields(p->form);
-	count = field_count(p->form);
+	if (isVisible(p)) {
+	    f = form_fields(p->form);
+	    count = field_count(p->form);
 
-	unpost_form(p->form);	/* ...so we can free it */
-	free_form(p->form);	/* this also disconnects the fields */
+	    unpost_form(p->form);	/* ...so we can free it */
+	    free_form(p->form);	/* this also disconnects the fields */
 
-	free_form_fields(f);
+	    free_form_fields(f);
 
-	del_panel(p->panel);
+	    del_panel(p->panel);
+	}
 	free(p->title);
 	free(p->content);
 	free(p);
@@ -499,6 +545,22 @@
 #endif
 }
 
+static void
+usage(void)
+{
+    static const char *msg[] =
+    {
+	"Usage: view [options] file"
+	,""
+	,"Options:"
+	," -c       use color if terminal supports it"
+    };
+    size_t n;
+    for (n = 0; n < SIZEOF(msg); n++)
+	fprintf(stderr, "%s\n", msg[n]);
+    ExitProgram(EXIT_FAILURE);
+}
+
 /*******************************************************************************/
 
 int
@@ -508,11 +570,32 @@
 
     setlocale(LC_ALL, "");
 
+    while ((n = getopt(argc, argv, "c")) != EOF) {
+	switch (n) {
+	case 'c':
+	    try_color = TRUE;
+	    break;
+	default:
+	    usage();
+	}
+    }
+
     initscr();
     cbreak();
     noecho();
 
-    if (argc > 1) {
+    if (try_color) {
+	if (has_colors()) {
+	    start_color();
+	    init_pair(pair_1, COLOR_WHITE, COLOR_BLUE);
+	    init_pair(pair_2, COLOR_WHITE, COLOR_CYAN);
+	    bkgd(COLOR_PAIR(pair_1));
+	} else {
+	    try_color = FALSE;
+	}
+    }
+
+    if (optind + 1 == argc) {
 	for (n = 1; n < argc; n++)
 	    read_data(argv[n]);
 	if (count_cards() == 0)
diff -Naur ncurses-5.4.orig/test/color_set.c ncurses-5.4/test/color_set.c
--- ncurses-5.4.orig/test/color_set.c	2003-12-07 00:08:47.000000000 +0000
+++ ncurses-5.4/test/color_set.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,9 +1,11 @@
 /*
- * $Id: color_set.c,v 1.2 2003/12/07 00:08:47 tom Exp $
+ * $Id: color_set.c,v 1.3 2004/04/10 20:10:28 tom Exp $
  */
 
 #include <test.priv.h>
 
+#ifdef HAVE_COLOR_SET
+
 #define SHOW(n) ((n) == ERR ? "ERR" : "OK")
 
 int
@@ -53,3 +55,11 @@
 
     ExitProgram(EXIT_SUCCESS);
 }
+#else
+int
+main(void)
+{
+    printf("This program requires the curses color_set function\n");
+    ExitProgram(EXIT_FAILURE);
+}
+#endif
diff -Naur ncurses-5.4.orig/test/configure ncurses-5.4/test/configure
--- ncurses-5.4.orig/test/configure	2004-01-31 00:07:15.000000000 +0000
+++ ncurses-5.4/test/configure	2005-05-13 04:09:51.000000000 +0000
@@ -553,7 +553,7 @@
 ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
 
 
-if test -f $srcdir/config.guess ; then
+if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
 	
 # Make sure we can run config.sub.
 if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
@@ -945,7 +945,6 @@
 DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'`	
 DFT_UPR_MODEL="NORMAL"			
 ECHO_LINK='@ echo linking $@ ... ;'	
-EXTRA_LIBS=""				
 LD="ld"					
 LDFLAGS_SHARED=""			
 LD_MODEL=""				
@@ -963,6 +962,7 @@
 MATH_LIB="-lm"				
 TEST_ARGS=""				
 TEST_DEPS=""				
+TINFO_ARGS='$(LIBS_CURSES)'		
 cf_cv_abi_version=""			
 cf_cv_rel_version=""			
 
@@ -1089,14 +1089,304 @@
 ac_objext=$ac_cv_objext
 
 
+
+echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6
+echo "configure:1095: checking for ${CC-cc} option to accept ANSI C" >&5
+if eval "test \"`echo '$''{'cf_cv_ansi_cc'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+cf_cv_ansi_cc=no
+cf_save_CFLAGS="$CFLAGS"
+cf_save_CPPFLAGS="$CPPFLAGS"
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX			-qlanglvl=ansi
+# Ultrix and OSF/1	-std1
+# HP-UX			-Aa -D_HPUX_SOURCE
+# SVR4			-Xc
+# UnixWare 1.2		(cannot use -Xc, since ANSI/POSIX clashes)
+for cf_arg in "-DCC_HAS_PROTOS" \
+	"" \
+	-qlanglvl=ansi \
+	-std1 \
+	-Ae \
+	"-Aa -D_HPUX_SOURCE" \
+	-Xc
+do
+	
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_arg
+do
+case $cf_fix_cppflags in
+no)
+	case $cf_add_cflags in #(vi
+	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+		case $cf_add_cflags in
+		-D*)
+			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+			&& test -z "${cf_tst_cflags}" \
+			&& cf_fix_cppflags=yes
+
+			if test $cf_fix_cppflags = yes ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		*$cf_add_cflags) #(vi
+			;;
+		*) #(vi
+			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+			;;
+		esac
+		;;
+	*)
+		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+		;;
+	esac
+	;;
+yes)
+	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+	&& test -z "${cf_tst_cflags}" \
+	&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+	
+	CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+	
+	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+	
+	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+
+
+
+	cat > conftest.$ac_ext <<EOF
+#line 1191 "configure"
+#include "confdefs.h"
+
+#ifndef CC_HAS_PROTOS
+#if !defined(__STDC__) || (__STDC__ != 1)
+choke me
+#endif
+#endif
+
+int main() {
+
+	int test (int i, double x);
+	struct s1 {int (*f) (int a);};
+	struct s2 {int (*f) (double a);};
+; return 0; }
+EOF
+if { (eval echo configure:1207: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  cf_cv_ansi_cc="$cf_arg"; break
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+CFLAGS="$cf_save_CFLAGS"
+CPPFLAGS="$cf_save_CPPFLAGS"
+
+fi
+
+echo "$ac_t""$cf_cv_ansi_cc" 1>&6
+
+if test "$cf_cv_ansi_cc" != "no"; then
+if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
+	
+cf_fix_cppflags=no
+cf_new_cflags=
+cf_new_cppflags=
+cf_new_extra_cppflags=
+
+for cf_add_cflags in $cf_cv_ansi_cc
+do
+case $cf_fix_cppflags in
+no)
+	case $cf_add_cflags in #(vi
+	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
+		case $cf_add_cflags in
+		-D*)
+			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[^=]*='\''\"[^"]*//'`
+
+			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+			&& test -z "${cf_tst_cflags}" \
+			&& cf_fix_cppflags=yes
+
+			if test $cf_fix_cppflags = yes ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			elif test "${cf_tst_cflags}" = "\"'" ; then
+				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+				continue
+			fi
+			;;
+		esac
+		case "$CPPFLAGS" in
+		*$cf_add_cflags) #(vi
+			;;
+		*) #(vi
+			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
+			;;
+		esac
+		;;
+	*)
+		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
+		;;
+	esac
+	;;
+yes)
+	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
+
+	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[^"]*"'\''//'`
+
+	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
+	&& test -z "${cf_tst_cflags}" \
+	&& cf_fix_cppflags=no
+	;;
+esac
+done
+
+if test -n "$cf_new_cflags" ; then
+	
+	CFLAGS="$CFLAGS $cf_new_cflags"
+fi
+
+if test -n "$cf_new_cppflags" ; then
+	
+	CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
+fi
+
+if test -n "$cf_new_extra_cppflags" ; then
+	
+	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
+fi
+
+
+
+
+else
+	cat >> confdefs.h <<\EOF
+#define CC_HAS_PROTOS 1
+EOF
+
+fi
+fi
+
+
+if test "$cf_cv_ansi_cc" = "no"; then
+	{ echo "configure: error: Your compiler does not appear to recognize prototypes.
+You have the following choices:
+	a. adjust your compiler options
+	b. get an up-to-date compiler
+	c. use a wrapper such as unproto" 1>&2; exit 1; }
+fi
+
+
+
+
+INTEL_COMPILER=no
+
+if test "$GCC" = yes ; then
+	case $host_os in
+	linux*|gnu*)
+		echo $ac_n "checking if this is really Intel compiler""... $ac_c" 1>&6
+echo "configure:1323: checking if this is really Intel compiler" >&5
+		cf_save_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS -no-gcc"
+		cat > conftest.$ac_ext <<EOF
+#line 1327 "configure"
+#include "confdefs.h"
+
+int main() {
+
+#ifdef __INTEL_COMPILER
+#else
+make an error
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1339: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  INTEL_COMPILER=yes
+cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
+
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+		CFLAGS="$cf_save_CFLAGS"
+		echo "$ac_t""$INTEL_COMPILER" 1>&6
+		;;
+	esac
+fi
+
+
+
+cf_XOPEN_SOURCE=500
+cf_POSIX_C_SOURCE=199506L
+
+case $host_os in #(vi
+aix[45]*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
+	;;
+freebsd*) #(vi
+	# 5.x headers associate
+	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
+	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
+	cf_POSIX_C_SOURCE=200112L
+	cf_XOPEN_SOURCE=600
+	CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+	;;
+hpux*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
+	;;
+irix[56].*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
+	;;
+linux*|gnu*) #(vi
+	
+
+
+if test "$INTEL_COMPILER" = no ; then
 echo $ac_n "checking if we must define _GNU_SOURCE""... $ac_c" 1>&6
-echo "configure:1094: checking if we must define _GNU_SOURCE" >&5
+echo "configure:1384: checking if we must define _GNU_SOURCE" >&5
 if eval "test \"`echo '$''{'cf_cv_gnu_source'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 1100 "configure"
+#line 1390 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int main() {
@@ -1106,7 +1396,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:1110: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1400: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_gnu_source=no
 else
@@ -1116,7 +1406,7 @@
   cf_save="$CPPFLAGS"
 	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
 	 cat > conftest.$ac_ext <<EOF
-#line 1120 "configure"
+#line 1410 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 int main() {
@@ -1126,7 +1416,7 @@
 #endif
 ; return 0; }
 EOF
-if { (eval echo configure:1130: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1420: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_gnu_source=no
 else
@@ -1145,6 +1435,189 @@
 
 echo "$ac_t""$cf_cv_gnu_source" 1>&6
 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+fi
+
+	;;
+mirbsd*) #(vi
+	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
+	;;
+netbsd*) #(vi
+	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
+	;;
+openbsd*) #(vi
+	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
+	;;
+osf[45]*) #(vi
+	CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
+	;;
+sco*) #(vi
+	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
+	;;
+solaris*) #(vi
+	CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
+	;;
+*)
+	echo $ac_n "checking if we should define _XOPEN_SOURCE""... $ac_c" 1>&6
+echo "configure:1462: checking if we should define _XOPEN_SOURCE" >&5
+if eval "test \"`echo '$''{'cf_cv_xopen_source'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+	cat > conftest.$ac_ext <<EOF
+#line 1468 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int main() {
+
+#ifndef _XOPEN_SOURCE
+make an error
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1478: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  cf_cv_xopen_source=no
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
+	 cat > conftest.$ac_ext <<EOF
+#line 1488 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int main() {
+
+#ifdef _XOPEN_SOURCE
+make an error
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1498: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  cf_cv_xopen_source=no
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  cf_cv_xopen_source=$cf_XOPEN_SOURCE
+fi
+rm -f conftest*
+	CPPFLAGS="$cf_save"
+	
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$cf_cv_xopen_source" 1>&6
+test "$cf_cv_xopen_source" != no && CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE -D_XOPEN_SOURCE=$cf_cv_xopen_source"
+	
+cf_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE
+echo $ac_n "checking if we should define _POSIX_C_SOURCE""... $ac_c" 1>&6
+echo "configure:1520: checking if we should define _POSIX_C_SOURCE" >&5
+if eval "test \"`echo '$''{'cf_cv_posix_c_source'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+	
+echo "(line 1526) testing if the symbol is already defined go no further ..." 1>&5
+
+	cat > conftest.$ac_ext <<EOF
+#line 1529 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int main() {
+
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1539: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  cf_cv_posix_c_source=no
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  cf_want_posix_source=no
+	 case .$cf_POSIX_C_SOURCE in
+	 .[12]??*)
+		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+		;;
+	 .2)
+		cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
+		cf_want_posix_source=yes
+		;;
+	 .*)
+		cf_want_posix_source=yes
+		;;
+	 esac
+	 if test "$cf_want_posix_source" = yes ; then
+		cat > conftest.$ac_ext <<EOF
+#line 1561 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int main() {
+
+#ifdef _POSIX_SOURCE
+make an error
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1571: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  :
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  cf_cv_posix_c_source="$cf_cv_posix_c_source -U_POSIX_SOURCE -D_POSIX_SOURCE"
+fi
+rm -f conftest*
+	 fi
+	 
+echo "(line 1582) testing ifdef from value $cf_POSIX_C_SOURCE ..." 1>&5
+
+	 cf_save="$CPPFLAGS"
+	 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
+	 
+echo "(line 1587) testing if the second compile does not leave our definition intact error ..." 1>&5
+
+	 cat > conftest.$ac_ext <<EOF
+#line 1590 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+int main() {
+
+#ifndef _POSIX_C_SOURCE
+make an error
+#endif
+; return 0; }
+EOF
+if { (eval echo configure:1600: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  :
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  cf_cv_posix_c_source=no
+fi
+rm -f conftest*
+	CPPFLAGS="$cf_save"
+	
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$cf_cv_posix_c_source" 1>&6
+test "$cf_cv_posix_c_source" != no && CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
+
+	;;
+esac
+
 
 
 
@@ -1212,7 +1685,7 @@
 	
 
 echo $ac_n "checking for extra include directories""... $ac_c" 1>&6
-echo "configure:1216: checking for extra include directories" >&5
+echo "configure:1689: checking for extra include directories" >&5
 if eval "test \"`echo '$''{'cf_cv_curses_incdir'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1236,7 +1709,7 @@
 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
 
 echo $ac_n "checking if we have identified curses headers""... $ac_c" 1>&6
-echo "configure:1240: checking if we have identified curses headers" >&5
+echo "configure:1713: checking if we have identified curses headers" >&5
 if eval "test \"`echo '$''{'cf_cv_ncurses_header'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1249,14 +1722,14 @@
 	ncurses/ncurses.h
 do
 cat > conftest.$ac_ext <<EOF
-#line 1253 "configure"
+#line 1726 "configure"
 #include "confdefs.h"
 #include <${cf_header}>
 int main() {
 initscr(); tgoto("?", 0,0)
 ; return 0; }
 EOF
-if { (eval echo configure:1260: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1733: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_ncurses_header=$cf_header; break
 else
@@ -1279,17 +1752,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1283: checking for $ac_hdr" >&5
+echo "configure:1756: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1288 "configure"
+#line 1761 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1293: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1766: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1319,7 +1792,7 @@
 
 	
 echo $ac_n "checking for ncurses version""... $ac_c" 1>&6
-echo "configure:1323: checking for ncurses version" >&5
+echo "configure:1796: checking for ncurses version" >&5
 if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1345,7 +1818,7 @@
 #endif
 EOF
 	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
-	{ (eval echo configure:1349: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
+	{ (eval echo configure:1822: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
 	if test -f conftest.out ; then
 		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
@@ -1354,7 +1827,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 1358 "configure"
+#line 1831 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header-curses.h}>
@@ -1378,7 +1851,7 @@
 	exit(0);
 }
 EOF
-if { (eval echo configure:1382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	cf_cv_ncurses_version=`cat $cf_tempfile`
@@ -1402,16 +1875,16 @@
 	
 
 echo $ac_n "checking if we have identified curses libraries""... $ac_c" 1>&6
-echo "configure:1406: checking if we have identified curses libraries" >&5
+echo "configure:1879: checking if we have identified curses libraries" >&5
 cat > conftest.$ac_ext <<EOF
-#line 1408 "configure"
+#line 1881 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr(); tgoto("?", 0,0)
 ; return 0; }
 EOF
-if { (eval echo configure:1415: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1888: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_result=yes
 else
@@ -1427,7 +1900,7 @@
 case $host_os in #(vi
 freebsd*) #(vi
 	echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
-echo "configure:1431: checking for tgoto in -lmytinfo" >&5
+echo "configure:1904: checking for tgoto in -lmytinfo" >&5
 ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1435,7 +1908,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lmytinfo  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1439 "configure"
+#line 1912 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1446,7 +1919,7 @@
 tgoto()
 ; return 0; }
 EOF
-if { (eval echo configure:1450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1923: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1469,7 +1942,7 @@
 	;;
 hpux10.*|hpux11.*) #(vi
 	echo $ac_n "checking for initscr in -lcur_colr""... $ac_c" 1>&6
-echo "configure:1473: checking for initscr in -lcur_colr" >&5
+echo "configure:1946: checking for initscr in -lcur_colr" >&5
 ac_lib_var=`echo cur_colr'_'initscr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1477,7 +1950,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lcur_colr  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1481 "configure"
+#line 1954 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1488,7 +1961,7 @@
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:1492: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1511,7 +1984,7 @@
   echo "$ac_t""no" 1>&6
 
 	echo $ac_n "checking for initscr in -lHcurses""... $ac_c" 1>&6
-echo "configure:1515: checking for initscr in -lHcurses" >&5
+echo "configure:1988: checking for initscr in -lHcurses" >&5
 ac_lib_var=`echo Hcurses'_'initscr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1519,7 +1992,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lHcurses  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1523 "configure"
+#line 1996 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1530,7 +2003,7 @@
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:1534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2007: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1583,12 +2056,12 @@
 	# Check for library containing tgoto.  Do this before curses library
 	# because it may be needed to link the test-case for initscr.
 	echo $ac_n "checking for tgoto""... $ac_c" 1>&6
-echo "configure:1587: checking for tgoto" >&5
+echo "configure:2060: checking for tgoto" >&5
 if eval "test \"`echo '$''{'ac_cv_func_tgoto'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1592 "configure"
+#line 2065 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char tgoto(); below.  */
@@ -1611,7 +2084,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2088: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_tgoto=yes"
 else
@@ -1632,7 +2105,7 @@
 		for cf_term_lib in $cf_check_list termcap termlib unknown
 		do
 			echo $ac_n "checking for tgoto in -l$cf_term_lib""... $ac_c" 1>&6
-echo "configure:1636: checking for tgoto in -l$cf_term_lib" >&5
+echo "configure:2109: checking for tgoto in -l$cf_term_lib" >&5
 ac_lib_var=`echo $cf_term_lib'_'tgoto | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1640,7 +2113,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-l$cf_term_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1644 "configure"
+#line 2117 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1651,7 +2124,7 @@
 tgoto()
 ; return 0; }
 EOF
-if { (eval echo configure:1655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2128: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1681,7 +2154,7 @@
 	for cf_curs_lib in $cf_check_list xcurses jcurses unknown
 	do
 		echo $ac_n "checking for initscr in -l$cf_curs_lib""... $ac_c" 1>&6
-echo "configure:1685: checking for initscr in -l$cf_curs_lib" >&5
+echo "configure:2158: checking for initscr in -l$cf_curs_lib" >&5
 ac_lib_var=`echo $cf_curs_lib'_'initscr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1689,7 +2162,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-l$cf_curs_lib  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 1693 "configure"
+#line 2166 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -1700,7 +2173,7 @@
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:1704: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -1726,16 +2199,16 @@
 	LIBS="-l$cf_curs_lib $cf_save_LIBS"
 	if test "$cf_term_lib" = unknown ; then
 		echo $ac_n "checking if we can link with $cf_curs_lib library""... $ac_c" 1>&6
-echo "configure:1730: checking if we can link with $cf_curs_lib library" >&5
+echo "configure:2203: checking if we can link with $cf_curs_lib library" >&5
 		cat > conftest.$ac_ext <<EOF
-#line 1732 "configure"
+#line 2205 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:1739: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_result=yes
 else
@@ -1751,16 +2224,16 @@
 		:
 	elif test "$cf_term_lib" != predefined ; then
 		echo $ac_n "checking if we need both $cf_curs_lib and $cf_term_lib libraries""... $ac_c" 1>&6
-echo "configure:1755: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
+echo "configure:2228: checking if we need both $cf_curs_lib and $cf_term_lib libraries" >&5
 		cat > conftest.$ac_ext <<EOF
-#line 1757 "configure"
+#line 2230 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr(); tgoto((char *)0, 0, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:1764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2237: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_result=no
 else
@@ -1770,14 +2243,14 @@
   
 			LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
 			cat > conftest.$ac_ext <<EOF
-#line 1774 "configure"
+#line 2247 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:1781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2254: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_result=yes
 else
@@ -1807,7 +2280,7 @@
 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
 
 echo $ac_n "checking for $cf_ncuhdr_root header in include-path""... $ac_c" 1>&6
-echo "configure:1811: checking for $cf_ncuhdr_root header in include-path" >&5
+echo "configure:2284: checking for $cf_ncuhdr_root header in include-path" >&5
 if eval "test \"`echo '$''{'cf_cv_ncurses_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1818,7 +2291,7 @@
 	do
 		
 	cat > conftest.$ac_ext <<EOF
-#line 1822 "configure"
+#line 2295 "configure"
 #include "confdefs.h"
 
 
@@ -1839,7 +2312,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:1843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2316: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_ncurses_h=$cf_header
 	
@@ -1862,7 +2335,7 @@
 	cf_cv_ncurses_header=$cf_cv_ncurses_h
 else
 echo $ac_n "checking for $cf_ncuhdr_root include-path""... $ac_c" 1>&6
-echo "configure:1866: checking for $cf_ncuhdr_root include-path" >&5
+echo "configure:2339: checking for $cf_ncuhdr_root include-path" >&5
 if eval "test \"`echo '$''{'cf_cv_ncurses_h2'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1957,14 +2430,14 @@
 				cf_save_CPPFLAGS="$CPPFLAGS"
 				CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 				cat > conftest.$ac_ext <<EOF
-#line 1961 "configure"
+#line 2434 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() {
 printf("Hello")
 ; return 0; }
 EOF
-if { (eval echo configure:1968: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2441: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -1991,7 +2464,7 @@
 		do
 			
 	cat > conftest.$ac_ext <<EOF
-#line 1995 "configure"
+#line 2468 "configure"
 #include "confdefs.h"
 
 
@@ -2012,7 +2485,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:2016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2489: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_ncurses_h2=$cf_header
 	
@@ -2059,14 +2532,14 @@
 				cf_save_CPPFLAGS="$CPPFLAGS"
 				CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 				cat > conftest.$ac_ext <<EOF
-#line 2063 "configure"
+#line 2536 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() {
 printf("Hello")
 ; return 0; }
 EOF
-if { (eval echo configure:2070: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2543: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -2121,7 +2594,7 @@
 
 
 echo $ac_n "checking for ncurses version""... $ac_c" 1>&6
-echo "configure:2125: checking for ncurses version" >&5
+echo "configure:2598: checking for ncurses version" >&5
 if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2147,7 +2620,7 @@
 #endif
 EOF
 	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
-	{ (eval echo configure:2151: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
+	{ (eval echo configure:2624: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
 	if test -f conftest.out ; then
 		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
@@ -2156,7 +2629,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 2160 "configure"
+#line 2633 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header-curses.h}>
@@ -2180,7 +2653,7 @@
 	exit(0);
 }
 EOF
-if { (eval echo configure:2184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	cf_cv_ncurses_version=`cat $cf_tempfile`
@@ -2211,7 +2684,7 @@
 cf_ncurses_LIBS=""
 cf_ncurses_SAVE="$LIBS"
 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
-echo "configure:2215: checking for Gpm_Open in -lgpm" >&5
+echo "configure:2688: checking for Gpm_Open in -lgpm" >&5
 ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2219,7 +2692,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lgpm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2223 "configure"
+#line 2696 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2230,7 +2703,7 @@
 Gpm_Open()
 ; return 0; }
 EOF
-if { (eval echo configure:2234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2246,7 +2719,7 @@
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   echo $ac_n "checking for initscr in -lgpm""... $ac_c" 1>&6
-echo "configure:2250: checking for initscr in -lgpm" >&5
+echo "configure:2723: checking for initscr in -lgpm" >&5
 ac_lib_var=`echo gpm'_'initscr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2254,7 +2727,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lgpm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2258 "configure"
+#line 2731 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2265,7 +2738,7 @@
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:2269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2295,8 +2768,9 @@
 freebsd*)
 	# This is only necessary if you are linking against an obsolete
 	# version of ncurses (but it should do no harm, since it's static).
-	echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
-echo "configure:2300: checking for tgoto in -lmytinfo" >&5
+	if test "$cf_nculib_root" = ncurses ; then
+		echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
+echo "configure:2774: checking for tgoto in -lmytinfo" >&5
 ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2304,7 +2778,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lmytinfo  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2308 "configure"
+#line 2782 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2315,7 +2789,7 @@
 tgoto()
 ; return 0; }
 EOF
-if { (eval echo configure:2319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2335,6 +2809,7 @@
   echo "$ac_t""no" 1>&6
 fi
 
+	fi
 	;;
 esac
 
@@ -2348,12 +2823,12 @@
 	eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
 	cf_libdir=""
 	echo $ac_n "checking for initscr""... $ac_c" 1>&6
-echo "configure:2352: checking for initscr" >&5
+echo "configure:2827: checking for initscr" >&5
 if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2357 "configure"
+#line 2832 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char initscr(); below.  */
@@ -2376,7 +2851,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:2380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_initscr=yes"
 else
@@ -2396,17 +2871,17 @@
 
 		cf_save_LIBS="$LIBS"
 		echo $ac_n "checking for initscr in -l$cf_nculib_root""... $ac_c" 1>&6
-echo "configure:2400: checking for initscr in -l$cf_nculib_root" >&5
+echo "configure:2875: checking for initscr in -l$cf_nculib_root" >&5
 		LIBS="-l$cf_nculib_root $LIBS"
 		cat > conftest.$ac_ext <<EOF
-#line 2403 "configure"
+#line 2878 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:2410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 			 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
@@ -2475,17 +2950,17 @@
 			for cf_libdir in $cf_search
 			do
 				echo $ac_n "checking for -l$cf_nculib_root in $cf_libdir""... $ac_c" 1>&6
-echo "configure:2479: checking for -l$cf_nculib_root in $cf_libdir" >&5
+echo "configure:2954: checking for -l$cf_nculib_root in $cf_libdir" >&5
 				LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
 				cat > conftest.$ac_ext <<EOF
-#line 2482 "configure"
+#line 2957 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:2489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 			 		 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
@@ -2516,7 +2991,7 @@
 
 if test -n "$cf_ncurses_LIBS" ; then
 	echo $ac_n "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS""... $ac_c" 1>&6
-echo "configure:2520: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
+echo "configure:2995: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
 	cf_ncurses_SAVE="$LIBS"
 	for p in $cf_ncurses_LIBS ; do
 		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
@@ -2525,14 +3000,14 @@
 		fi
 	done
 	cat > conftest.$ac_ext <<EOF
-#line 2529 "configure"
+#line 3004 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:2536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -2559,14 +3034,14 @@
 	cf_cv_libtype=w
 	
 echo $ac_n "checking for multibyte character support""... $ac_c" 1>&6
-echo "configure:2563: checking for multibyte character support" >&5
+echo "configure:3038: checking for multibyte character support" >&5
 if eval "test \"`echo '$''{'cf_cv_utf8_lib'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 	cf_save_LIBS="$LIBS"
 	cat > conftest.$ac_ext <<EOF
-#line 2570 "configure"
+#line 3045 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -2574,7 +3049,7 @@
 putwc(0,0);
 ; return 0; }
 EOF
-if { (eval echo configure:2578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_cv_utf8_lib=yes
 else
@@ -2583,7 +3058,7 @@
   rm -rf conftest*
   LIBS="-lutf8 $LIBS"
 	 cat > conftest.$ac_ext <<EOF
-#line 2587 "configure"
+#line 3062 "configure"
 #include "confdefs.h"
 
 #include <libutf8.h>
@@ -2591,7 +3066,7 @@
 putwc(0,0);
 ; return 0; }
 EOF
-if { (eval echo configure:2595: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_cv_utf8_lib=add-on
 else
@@ -2620,128 +3095,6 @@
 fi
 
 	
-echo $ac_n "checking if we must define _XOPEN_SOURCE""... $ac_c" 1>&6
-echo "configure:2625: checking if we must define _XOPEN_SOURCE" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2627 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-
-int main() {
-
-#ifndef _XOPEN_SOURCE
-make an error
-#endif
-; return 0; }
-EOF
-if { (eval echo configure:2638: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  cf_result=no
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  cf_result=yes
-fi
-rm -f conftest*
-echo "$ac_t""$cf_result" 1>&6
-
-if test "$cf_result" = yes ; then
-	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
-elif test "x500" != "x" ; then
-	echo $ac_n "checking checking for compatible value versus 500""... $ac_c" 1>&6
-echo "configure:2654: checking checking for compatible value versus 500" >&5
-	cat > conftest.$ac_ext <<EOF
-#line 2656 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-
-int main() {
-
-#if _XOPEN_SOURCE-500 < 0
-make an error
-#endif
-; return 0; }
-EOF
-if { (eval echo configure:2667: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  cf_result=yes
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  cf_result=no
-fi
-rm -f conftest*
-	echo "$ac_t""$cf_result" 1>&6
-	if test "$cf_result" = no ; then
-		# perhaps we can override it - try...
-		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
-	fi
-fi
-
-	
-echo $ac_n "checking if we must define _XOPEN_SOURCE_EXTENDED""... $ac_c" 1>&6
-echo "configure:2686: checking if we must define _XOPEN_SOURCE_EXTENDED" >&5
-cat > conftest.$ac_ext <<EOF
-#line 2688 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-
-int main() {
-
-#ifndef _XOPEN_SOURCE_EXTENDED
-make an error
-#endif
-; return 0; }
-EOF
-if { (eval echo configure:2699: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  cf_result=no
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  cf_result=yes
-fi
-rm -f conftest*
-echo "$ac_t""$cf_result" 1>&6
-
-if test "$cf_result" = yes ; then
-	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
-elif test "x" != "x" ; then
-	echo $ac_n "checking checking for compatible value versus ""... $ac_c" 1>&6
-echo "configure:2715: checking checking for compatible value versus " >&5
-	cat > conftest.$ac_ext <<EOF
-#line 2717 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-
-int main() {
-
-#if _XOPEN_SOURCE_EXTENDED- < 0
-make an error
-#endif
-; return 0; }
-EOF
-if { (eval echo configure:2728: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  cf_result=yes
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  cf_result=no
-fi
-rm -f conftest*
-	echo "$ac_t""$cf_result" 1>&6
-	if test "$cf_result" = no ; then
-		# perhaps we can override it - try...
-		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED="
-	fi
-fi
-
-	
 
 cf_ncuhdr_root=ncursesw
 
@@ -2750,7 +3103,7 @@
 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
 
 echo $ac_n "checking for $cf_ncuhdr_root header in include-path""... $ac_c" 1>&6
-echo "configure:2754: checking for $cf_ncuhdr_root header in include-path" >&5
+echo "configure:3107: checking for $cf_ncuhdr_root header in include-path" >&5
 if eval "test \"`echo '$''{'cf_cv_ncurses_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2761,7 +3114,7 @@
 	do
 		
 	cat > conftest.$ac_ext <<EOF
-#line 2765 "configure"
+#line 3118 "configure"
 #include "confdefs.h"
 
 
@@ -2790,7 +3143,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:2794: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3147: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_ncurses_h=$cf_header
 	
@@ -2813,7 +3166,7 @@
 	cf_cv_ncurses_header=$cf_cv_ncurses_h
 else
 echo $ac_n "checking for $cf_ncuhdr_root include-path""... $ac_c" 1>&6
-echo "configure:2817: checking for $cf_ncuhdr_root include-path" >&5
+echo "configure:3170: checking for $cf_ncuhdr_root include-path" >&5
 if eval "test \"`echo '$''{'cf_cv_ncurses_h2'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2908,14 +3261,14 @@
 				cf_save_CPPFLAGS="$CPPFLAGS"
 				CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 				cat > conftest.$ac_ext <<EOF
-#line 2912 "configure"
+#line 3265 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() {
 printf("Hello")
 ; return 0; }
 EOF
-if { (eval echo configure:2919: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -2942,7 +3295,7 @@
 		do
 			
 	cat > conftest.$ac_ext <<EOF
-#line 2946 "configure"
+#line 3299 "configure"
 #include "confdefs.h"
 
 
@@ -2971,7 +3324,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:2975: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3328: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_ncurses_h2=$cf_header
 	
@@ -3018,14 +3371,14 @@
 				cf_save_CPPFLAGS="$CPPFLAGS"
 				CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
 				cat > conftest.$ac_ext <<EOF
-#line 3022 "configure"
+#line 3375 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() {
 printf("Hello")
 ; return 0; }
 EOF
-if { (eval echo configure:3029: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3382: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   :
 else
   echo "configure: failed program was:" >&5
@@ -3080,7 +3433,7 @@
 
 
 echo $ac_n "checking for ncurses version""... $ac_c" 1>&6
-echo "configure:3084: checking for ncurses version" >&5
+echo "configure:3437: checking for ncurses version" >&5
 if eval "test \"`echo '$''{'cf_cv_ncurses_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3106,7 +3459,7 @@
 #endif
 EOF
 	cf_try="$ac_cpp conftest.$ac_ext 2>&5 | grep '^Autoconf ' >conftest.out"
-	{ (eval echo configure:3110: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
+	{ (eval echo configure:3463: \"$cf_try\") 1>&5; (eval $cf_try) 2>&5; }
 	if test -f conftest.out ; then
 		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[^"]*"%%' -e 's%".*%%'`
 		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
@@ -3115,7 +3468,7 @@
 
 else
   cat > conftest.$ac_ext <<EOF
-#line 3119 "configure"
+#line 3472 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header-curses.h}>
@@ -3139,7 +3492,7 @@
 	exit(0);
 }
 EOF
-if { (eval echo configure:3143: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
 	cf_cv_ncurses_version=`cat $cf_tempfile`
@@ -3170,7 +3523,7 @@
 cf_ncurses_LIBS=""
 cf_ncurses_SAVE="$LIBS"
 echo $ac_n "checking for Gpm_Open in -lgpm""... $ac_c" 1>&6
-echo "configure:3174: checking for Gpm_Open in -lgpm" >&5
+echo "configure:3527: checking for Gpm_Open in -lgpm" >&5
 ac_lib_var=`echo gpm'_'Gpm_Open | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3178,7 +3531,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lgpm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3182 "configure"
+#line 3535 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3189,7 +3542,7 @@
 Gpm_Open()
 ; return 0; }
 EOF
-if { (eval echo configure:3193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3205,7 +3558,7 @@
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   echo $ac_n "checking for initscr in -lgpm""... $ac_c" 1>&6
-echo "configure:3209: checking for initscr in -lgpm" >&5
+echo "configure:3562: checking for initscr in -lgpm" >&5
 ac_lib_var=`echo gpm'_'initscr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3213,7 +3566,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lgpm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3217 "configure"
+#line 3570 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3224,7 +3577,7 @@
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:3228: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3581: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3254,8 +3607,9 @@
 freebsd*)
 	# This is only necessary if you are linking against an obsolete
 	# version of ncurses (but it should do no harm, since it's static).
-	echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
-echo "configure:3259: checking for tgoto in -lmytinfo" >&5
+	if test "$cf_nculib_root" = ncurses ; then
+		echo $ac_n "checking for tgoto in -lmytinfo""... $ac_c" 1>&6
+echo "configure:3613: checking for tgoto in -lmytinfo" >&5
 ac_lib_var=`echo mytinfo'_'tgoto | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3263,7 +3617,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lmytinfo  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3267 "configure"
+#line 3621 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3274,7 +3628,7 @@
 tgoto()
 ; return 0; }
 EOF
-if { (eval echo configure:3278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3294,6 +3648,7 @@
   echo "$ac_t""no" 1>&6
 fi
 
+	fi
 	;;
 esac
 
@@ -3307,12 +3662,12 @@
 	eval 'cf_cv_have_lib_'$cf_nculib_root'=no'
 	cf_libdir=""
 	echo $ac_n "checking for initscr""... $ac_c" 1>&6
-echo "configure:3311: checking for initscr" >&5
+echo "configure:3666: checking for initscr" >&5
 if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3316 "configure"
+#line 3671 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char initscr(); below.  */
@@ -3335,7 +3690,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3339: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_initscr=yes"
 else
@@ -3355,17 +3710,17 @@
 
 		cf_save_LIBS="$LIBS"
 		echo $ac_n "checking for initscr in -l$cf_nculib_root""... $ac_c" 1>&6
-echo "configure:3359: checking for initscr in -l$cf_nculib_root" >&5
+echo "configure:3714: checking for initscr in -l$cf_nculib_root" >&5
 		LIBS="-l$cf_nculib_root $LIBS"
 		cat > conftest.$ac_ext <<EOF
-#line 3362 "configure"
+#line 3717 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:3369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3724: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 			 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
@@ -3434,17 +3789,17 @@
 			for cf_libdir in $cf_search
 			do
 				echo $ac_n "checking for -l$cf_nculib_root in $cf_libdir""... $ac_c" 1>&6
-echo "configure:3438: checking for -l$cf_nculib_root in $cf_libdir" >&5
+echo "configure:3793: checking for -l$cf_nculib_root in $cf_libdir" >&5
 				LIBS="-L$cf_libdir -l$cf_nculib_root $cf_save_LIBS"
 				cat > conftest.$ac_ext <<EOF
-#line 3441 "configure"
+#line 3796 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr()
 ; return 0; }
 EOF
-if { (eval echo configure:3448: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 			 		 eval 'cf_cv_have_lib_'$cf_nculib_root'=yes'
@@ -3475,7 +3830,7 @@
 
 if test -n "$cf_ncurses_LIBS" ; then
 	echo $ac_n "checking if we can link $cf_nculib_root without $cf_ncurses_LIBS""... $ac_c" 1>&6
-echo "configure:3479: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
+echo "configure:3834: checking if we can link $cf_nculib_root without $cf_ncurses_LIBS" >&5
 	cf_ncurses_SAVE="$LIBS"
 	for p in $cf_ncurses_LIBS ; do
 		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
@@ -3484,14 +3839,14 @@
 		fi
 	done
 	cat > conftest.$ac_ext <<EOF
-#line 3488 "configure"
+#line 3843 "configure"
 #include "confdefs.h"
 #include <${cf_cv_ncurses_header-curses.h}>
 int main() {
 initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:3495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -3518,27 +3873,27 @@
 
 
 
-echo $ac_n "checking for form_driver in -lform$cf_cv_libtype""... $ac_c" 1>&6
-echo "configure:3523: checking for form_driver in -lform$cf_cv_libtype" >&5
-ac_lib_var=`echo form$cf_cv_libtype'_'form_driver | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for new_panel in -lpanel$cf_cv_libtype""... $ac_c" 1>&6
+echo "configure:3878: checking for new_panel in -lpanel$cf_cv_libtype" >&5
+ac_lib_var=`echo panel$cf_cv_libtype'_'new_panel | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lform$cf_cv_libtype  $LIBS"
+LIBS="-lpanel$cf_cv_libtype  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3531 "configure"
+#line 3886 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char form_driver();
+char new_panel();
 
 int main() {
-form_driver()
+new_panel()
 ; return 0; }
 EOF
-if { (eval echo configure:3542: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3553,20 +3908,20 @@
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-    ac_tr_lib=HAVE_LIB`echo form$cf_cv_libtype | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    ac_tr_lib=HAVE_LIB`echo panel$cf_cv_libtype | sed -e 's/[^a-zA-Z0-9_]/_/g' \
     -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_lib 1
 EOF
 
-  LIBS="-lform$cf_cv_libtype $LIBS"
+  LIBS="-lpanel$cf_cv_libtype $LIBS"
 
 else
   echo "$ac_t""no" 1>&6
 fi
 
 echo $ac_n "checking for menu_driver in -lmenu$cf_cv_libtype""... $ac_c" 1>&6
-echo "configure:3570: checking for menu_driver in -lmenu$cf_cv_libtype" >&5
+echo "configure:3925: checking for menu_driver in -lmenu$cf_cv_libtype" >&5
 ac_lib_var=`echo menu$cf_cv_libtype'_'menu_driver | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3574,7 +3929,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lmenu$cf_cv_libtype  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3578 "configure"
+#line 3933 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3585,7 +3940,7 @@
 menu_driver()
 ; return 0; }
 EOF
-if { (eval echo configure:3589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3944: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3612,27 +3967,27 @@
   echo "$ac_t""no" 1>&6
 fi
 
-echo $ac_n "checking for new_panel in -lpanel$cf_cv_libtype""... $ac_c" 1>&6
-echo "configure:3617: checking for new_panel in -lpanel$cf_cv_libtype" >&5
-ac_lib_var=`echo panel$cf_cv_libtype'_'new_panel | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for form_driver in -lform$cf_cv_libtype""... $ac_c" 1>&6
+echo "configure:3972: checking for form_driver in -lform$cf_cv_libtype" >&5
+ac_lib_var=`echo form$cf_cv_libtype'_'form_driver | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LIBS="$LIBS"
-LIBS="-lpanel$cf_cv_libtype  $LIBS"
+LIBS="-lform$cf_cv_libtype  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3625 "configure"
+#line 3980 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
-char new_panel();
+char form_driver();
 
 int main() {
-new_panel()
+form_driver()
 ; return 0; }
 EOF
-if { (eval echo configure:3636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3647,13 +4002,13 @@
 fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
-    ac_tr_lib=HAVE_LIB`echo panel$cf_cv_libtype | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+    ac_tr_lib=HAVE_LIB`echo form$cf_cv_libtype | sed -e 's/[^a-zA-Z0-9_]/_/g' \
     -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
   cat >> confdefs.h <<EOF
 #define $ac_tr_lib 1
 EOF
 
-  LIBS="-lpanel$cf_cv_libtype $LIBS"
+  LIBS="-lform$cf_cv_libtype $LIBS"
 
 else
   echo "$ac_t""no" 1>&6
@@ -3661,12 +4016,12 @@
 
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3665: checking return type of signal handlers" >&5
+echo "configure:4020: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3670 "configure"
+#line 4025 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -3683,7 +4038,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:3687: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4042: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -3703,12 +4058,12 @@
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:3707: checking for ANSI C header files" >&5
+echo "configure:4062: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3712 "configure"
+#line 4067 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -3716,7 +4071,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3720: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4075: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3733,7 +4088,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3737 "configure"
+#line 4092 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -3751,7 +4106,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 3755 "configure"
+#line 4110 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -3772,7 +4127,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 3776 "configure"
+#line 4131 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -3783,7 +4138,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:3787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4142: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -3807,12 +4162,12 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:3811: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:4166: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3816 "configure"
+#line 4171 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -3821,7 +4176,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:3825: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4180: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -3858,17 +4213,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3862: checking for $ac_hdr" >&5
+echo "configure:4217: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3867 "configure"
+#line 4222 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3872: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4227: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3911,12 +4266,12 @@
 
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3915: checking for $ac_func" >&5
+echo "configure:4270: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3920 "configure"
+#line 4275 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3939,7 +4294,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3943: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4298: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -3965,7 +4320,7 @@
 
 
 cat > conftest.$ac_ext <<EOF
-#line 3969 "configure"
+#line 4324 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header-curses.h}>
@@ -3986,7 +4341,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:3990: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define NCURSES_EXT_FUNCS 1
@@ -4000,13 +4355,13 @@
 
 
 echo $ac_n "checking if sys/time.h works with sys/select.h""... $ac_c" 1>&6
-echo "configure:4004: checking if sys/time.h works with sys/select.h" >&5
+echo "configure:4359: checking if sys/time.h works with sys/select.h" >&5
 if eval "test \"`echo '$''{'cf_cv_sys_time_select'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
 cat > conftest.$ac_ext <<EOF
-#line 4010 "configure"
+#line 4365 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -4021,7 +4376,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4025: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4380: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_cv_sys_time_select=yes
 else
@@ -4042,7 +4397,7 @@
 
 
 echo $ac_n "checking for function curses_version""... $ac_c" 1>&6
-echo "configure:4046: checking for function curses_version" >&5
+echo "configure:4401: checking for function curses_version" >&5
 if eval "test \"`echo '$''{'cf_cv_func_curses_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4051,7 +4406,7 @@
   cf_cv_func_curses_version=unknown
 else
   cat > conftest.$ac_ext <<EOF
-#line 4055 "configure"
+#line 4410 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header-curses.h}>
@@ -4063,7 +4418,7 @@
 }
 
 EOF
-if { (eval echo configure:4067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4422: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cf_cv_func_curses_version=yes
 
@@ -4088,7 +4443,7 @@
 
 
 echo $ac_n "checking for alternate character set array""... $ac_c" 1>&6
-echo "configure:4092: checking for alternate character set array" >&5
+echo "configure:4447: checking for alternate character set array" >&5
 if eval "test \"`echo '$''{'cf_cv_curses_acs_map'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4097,7 +4452,7 @@
 for name in acs_map _acs_map __acs_map _nc_acs_map
 do
 cat > conftest.$ac_ext <<EOF
-#line 4101 "configure"
+#line 4456 "configure"
 #include "confdefs.h"
 
 #include <${cf_cv_ncurses_header-curses.h}>
@@ -4108,7 +4463,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4467: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_cv_curses_acs_map=$name; break
 else
@@ -4129,7 +4484,7 @@
 
 
 echo $ac_n "checking for wide alternate character set array""... $ac_c" 1>&6
-echo "configure:4133: checking for wide alternate character set array" >&5
+echo "configure:4488: checking for wide alternate character set array" >&5
 if eval "test \"`echo '$''{'cf_cv_curses_wacs_map'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4138,7 +4493,7 @@
 	for name in wacs_map _wacs_map __wacs_map _nc_wacs
 	do
 	cat > conftest.$ac_ext <<EOF
-#line 4142 "configure"
+#line 4497 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -4149,7 +4504,7 @@
 $name['k'] = *WACS_PLUS
 ; return 0; }
 EOF
-if { (eval echo configure:4153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   cf_cv_curses_wacs_map=$name
 	 break
@@ -4165,9 +4520,9 @@
 
 
 echo $ac_n "checking for type attr_t in ${cf_cv_ncurses_header-curses.h}""... $ac_c" 1>&6
-echo "configure:4169: checking for type attr_t in ${cf_cv_ncurses_header-curses.h}" >&5
+echo "configure:4524: checking for type attr_t in ${cf_cv_ncurses_header-curses.h}" >&5
 cat > conftest.$ac_ext <<EOF
-#line 4171 "configure"
+#line 4526 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -4180,7 +4535,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4184: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4539: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_result=yes
 else
@@ -4208,9 +4563,9 @@
 
 
 echo $ac_n "checking for type mbstate_t in ${cf_cv_ncurses_header-curses.h}""... $ac_c" 1>&6
-echo "configure:4212: checking for type mbstate_t in ${cf_cv_ncurses_header-curses.h}" >&5
+echo "configure:4567: checking for type mbstate_t in ${cf_cv_ncurses_header-curses.h}" >&5
 cat > conftest.$ac_ext <<EOF
-#line 4214 "configure"
+#line 4569 "configure"
 #include "confdefs.h"
 
 #ifndef _XOPEN_SOURCE_EXTENDED
@@ -4223,7 +4578,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4227: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4582: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cf_result=yes
 else
@@ -4250,6 +4605,9 @@
 fi
 
 
+TEST_ARGS="$LIBS"
+LIBS=
+
 
 trap '' 1 2 15
 cat > confcache <<\EOF
@@ -4397,7 +4755,6 @@
 s%@DFT_OBJ_SUBDIR@%$DFT_OBJ_SUBDIR%g
 s%@DFT_UPR_MODEL@%$DFT_UPR_MODEL%g
 s%@ECHO_LINK@%$ECHO_LINK%g
-s%@EXTRA_LIBS@%$EXTRA_LIBS%g
 s%@LD@%$LD%g
 s%@LDFLAGS_SHARED@%$LDFLAGS_SHARED%g
 s%@LD_MODEL@%$LD_MODEL%g
@@ -4415,10 +4772,12 @@
 s%@MATH_LIB@%$MATH_LIB%g
 s%@TEST_ARGS@%$TEST_ARGS%g
 s%@TEST_DEPS@%$TEST_DEPS%g
+s%@TINFO_ARGS@%$TINFO_ARGS%g
 s%@cf_cv_abi_version@%$cf_cv_abi_version%g
 s%@cf_cv_rel_version@%$cf_cv_rel_version%g
 s%@EXEEXT@%$EXEEXT%g
 s%@OBJEXT@%$OBJEXT%g
+s%@EXTRA_CPPFLAGS@%$EXTRA_CPPFLAGS%g
 
 CEOF
 EOF
diff -Naur ncurses-5.4.orig/test/configure.in ncurses-5.4/test/configure.in
--- ncurses-5.4.orig/test/configure.in	2004-01-31 00:07:01.000000000 +0000
+++ ncurses-5.4/test/configure.in	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 dnl***************************************************************************
-dnl Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+dnl Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
 dnl                                                                          *
 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
 dnl copy of this software and associated documentation files (the            *
@@ -28,7 +28,7 @@
 dnl
 dnl Author: Thomas E. Dickey 1996, etc.
 dnl
-dnl $Id: configure.in,v 1.47 2004/01/31 00:07:01 tom Exp $
+dnl $Id: configure.in,v 1.51 2005/02/26 23:58:27 tom Exp $
 dnl This is a simple configuration-script for the ncurses test programs that
 dnl allows the test-directory to be separately configured against a reference
 dnl system (i.e., sysvr4 curses)
@@ -58,7 +58,6 @@
 DFT_OBJ_SUBDIR=`pwd|sed -e's:.*/::'`	AC_SUBST(DFT_OBJ_SUBDIR)
 DFT_UPR_MODEL="NORMAL"			AC_SUBST(DFT_UPR_MODEL)
 ECHO_LINK='@ echo linking $@ ... ;'	AC_SUBST(ECHO_LINK)
-EXTRA_LIBS=""				AC_SUBST(EXTRA_LIBS)
 LD="ld"					AC_SUBST(LD)
 LDFLAGS_SHARED=""			AC_SUBST(LDFLAGS_SHARED)
 LD_MODEL=""				AC_SUBST(LD_MODEL)
@@ -76,6 +75,7 @@
 MATH_LIB="-lm"				AC_SUBST(MATH_LIB)
 TEST_ARGS=""				AC_SUBST(TEST_ARGS)
 TEST_DEPS=""				AC_SUBST(TEST_DEPS)
+TINFO_ARGS='$(LIBS_CURSES)'		AC_SUBST(TINFO_ARGS)
 cf_cv_abi_version=""			AC_SUBST(cf_cv_abi_version)
 cf_cv_rel_version=""			AC_SUBST(cf_cv_rel_version)
 
@@ -84,7 +84,10 @@
 
 AC_EXEEXT
 AC_OBJEXT
-CF_GNU_SOURCE
+
+CF_ANSI_CC_REQD
+CF_XOPEN_SOURCE
+
 CF_WITH_CURSES_DIR
 
 dnl SunOS 4.x
@@ -118,8 +121,6 @@
 ncursesw)
 	cf_cv_libtype=w
 	CF_UTF8_LIB
-	CF_PREDEFINE(_XOPEN_SOURCE,500)
-	CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
 	CF_NCURSES_CPPFLAGS(ncursesw)
 	CF_NCURSES_LIBS(ncursesw)
 	LIB_NAME=ncursesw
@@ -131,9 +132,9 @@
 
 dnl Autoconf builds up the $LIBS in reverse order
 
-AC_CHECK_LIB(form$cf_cv_libtype,form_driver)
-AC_CHECK_LIB(menu$cf_cv_libtype,menu_driver)
 AC_CHECK_LIB(panel$cf_cv_libtype,new_panel)
+AC_CHECK_LIB(menu$cf_cv_libtype,menu_driver)
+AC_CHECK_LIB(form$cf_cv_libtype,form_driver)
 
 AC_TYPE_SIGNAL
 
@@ -193,6 +194,9 @@
 CF_CURSES_CHECK_TYPE(attr_t,long)
 CF_CURSES_CHECK_TYPE(mbstate_t,long)
 
+TEST_ARGS="$LIBS"
+LIBS=
+
 dnl ---------------------------------------------------------------------------
 
 AC_OUTPUT(Makefile,[
diff -Naur ncurses-5.4.orig/test/demo_forms.c ncurses-5.4/test/demo_forms.c
--- ncurses-5.4.orig/test/demo_forms.c	2003-05-03 22:08:20.000000000 +0000
+++ ncurses-5.4/test/demo_forms.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * $Id: demo_forms.c,v 1.3 2003/05/03 22:08:20 tom Exp $
+ * $Id: demo_forms.c,v 1.11 2005/04/16 16:31:25 tom Exp $
  *
  * Demonstrate a variety of functions from the form library.
  * Thomas Dickey - 2003/4/26
@@ -7,14 +7,8 @@
 /*
 TYPE_ALNUM			-
 TYPE_ENUM			-
-TYPE_INTEGER			-
-TYPE_IPV4			-
-TYPE_NUMERIC			-
 TYPE_REGEXP			-
-data_ahead			-
-data_behind			-
 dup_field			-
-dynamic_field_info		-
 field_arg			-
 field_back			-
 field_count			-
@@ -63,14 +57,18 @@
 
 #include <edit_field.h>
 
+static int d_option = 0;
+static int m_value = 0;
+static int o_value = 0;
+
 static FIELD *
 make_label(int frow, int fcol, NCURSES_CONST char *label)
 {
-    FIELD *f = new_field(1, strlen(label), frow, fcol, 0, 0);
+    FIELD *f = new_field(1, (int) strlen(label), frow, fcol, 0, 0);
 
     if (f) {
 	set_field_buffer(f, 0, label);
-	set_field_opts(f, field_opts(f) & ~O_ACTIVE);
+	set_field_opts(f, (int) (field_opts(f) & ~O_ACTIVE));
     }
     return (f);
 }
@@ -81,11 +79,15 @@
 static FIELD *
 make_field(int frow, int fcol, int rows, int cols)
 {
-    FIELD *f = new_field(rows, cols, frow, fcol, 0, 1);
+    FIELD *f = new_field(rows, cols, frow, fcol, o_value, 1);
 
     if (f) {
 	set_field_back(f, A_UNDERLINE);
 	set_field_userptr(f, (void *) 0);
+	if (d_option) {
+	    field_opts_off(f, O_STATIC);
+	    set_max_field(f, m_value);
+	}
     }
     return (f);
 }
@@ -151,12 +153,18 @@
     FIELDTYPE *type;
     char *buffer;
     int nbuf;
+    int field_rows, field_cols, field_max;
 
     if (has_colors()) {
 	wbkgd(win, COLOR_PAIR(1));
     }
     werase(win);
-    wprintw(win, "Cursor: %d,%d\n", form->currow, form->curcol);
+    wprintw(win, "Cursor: %d,%d", form->currow, form->curcol);
+    if (data_ahead(form))
+	waddstr(win, " ahead");
+    if (data_behind(form))
+	waddstr(win, " behind");
+    waddch(win, '\n');
     if ((field = current_field(form)) != 0) {
 	wprintw(win, "Field %d:", field_index(field));
 	if ((type = field_type(field)) != 0) {
@@ -168,6 +176,8 @@
 		waddstr(win, "ENUM");
 	    else if (type == TYPE_INTEGER)
 		waddstr(win, "INTEGER");
+	    else if (type == TYPE_IPV4)
+		waddstr(win, "IPV4");
 	    else if (type == TYPE_NUMERIC)
 		waddstr(win, "NUMERIC");
 	    else if (type == TYPE_REGEXP)
@@ -175,6 +185,11 @@
 	    else
 		waddstr(win, "other");
 	}
+	if (dynamic_field_info(field, &field_rows, &field_cols, &field_max)
+	    != ERR) {
+	    wprintw(win, " size %dx%d (max %d)",
+		    field_rows, field_cols, field_max);
+	}
 	waddstr(win, "\n");
 	for (nbuf = 0; nbuf <= 2; ++nbuf) {
 	    if ((buffer = field_buffer(field, nbuf)) != 0) {
@@ -207,23 +222,48 @@
     refresh();
 
     /* describe the form */
-    for (pg = 0; pg < 3; ++pg) {
+    for (pg = 0; pg < 4; ++pg) {
 	char label[80];
 	sprintf(label, "Sample Form Page %d", pg + 1);
 	f[n++] = make_label(0, 15, label);
 	set_new_page(f[n - 1], TRUE);
 
-	f[n++] = make_label(2, 0, "Last Name");
-	f[n++] = make_field(3, 0, 1, 18);
-	set_field_type(f[n - 1], TYPE_ALPHA, 1);
-
-	f[n++] = make_label(2, 20, "First Name");
-	f[n++] = make_field(3, 20, 1, 12);
-	set_field_type(f[n - 1], TYPE_ALPHA, 1);
-
-	f[n++] = make_label(2, 34, "Middle Name");
-	f[n++] = make_field(3, 34, 1, 12);
-	set_field_type(f[n - 1], TYPE_ALPHA, 1);
+	switch (pg) {
+	default:
+	    f[n++] = make_label(2, 0, "Last Name");
+	    f[n++] = make_field(3, 0, 1, 18);
+	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
+
+	    f[n++] = make_label(2, 20, "First Name");
+	    f[n++] = make_field(3, 20, 1, 12);
+	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
+
+	    f[n++] = make_label(2, 34, "Middle Name");
+	    f[n++] = make_field(3, 34, 1, 12);
+	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
+	    break;
+	case 2:
+	    f[n++] = make_label(2, 0, "Host Name");
+	    f[n++] = make_field(3, 0, 1, 18);
+	    set_field_type(f[n - 1], TYPE_ALPHA, 1);
+
+	    f[n++] = make_label(2, 20, "IP Address");
+	    f[n++] = make_field(3, 20, 1, 12);
+	    set_field_type(f[n - 1], TYPE_IPV4, 1);
+
+	    break;
+
+	case 3:
+	    f[n++] = make_label(2, 0, "Four digits");
+	    f[n++] = make_field(3, 0, 1, 18);
+	    set_field_type(f[n - 1], TYPE_INTEGER, 4, 0, 0);
+
+	    f[n++] = make_label(2, 20, "Numeric");
+	    f[n++] = make_field(3, 20, 1, 12);
+	    set_field_type(f[n - 1], TYPE_NUMERIC, 3, -10000.0, 100000000.0);
+
+	    break;
+	}
 
 	f[n++] = make_label(5, 0, "Comments");
 	f[n++] = make_field(6, 0, 4, 46);
@@ -262,9 +302,47 @@
     nl();
 }
 
+static void
+usage(void)
+{
+    static const char *tbl[] =
+    {
+	"Usage: demo_forms [options]"
+	,""
+	," -d        make fields dynamic"
+	," -m value  set maximum size of dynamic fields"
+	," -o value  specify number of offscreen rows in new_field()"
+    };
+    unsigned int j;
+    for (j = 0; j < SIZEOF(tbl); ++j)
+	fprintf(stderr, "%s\n", tbl[j]);
+    exit(EXIT_FAILURE);
+}
+
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
+    int ch;
+
+    setlocale(LC_ALL, "");
+
+    while ((ch = getopt(argc, argv, "dm:o:")) != EOF) {
+	switch (ch) {
+	case 'd':
+	    d_option = TRUE;
+	    break;
+	case 'm':
+	    m_value = atoi(optarg);
+	    break;
+	case 'o':
+	    o_value = atoi(optarg);
+	    break;
+	default:
+	    usage();
+
+	}
+    }
+
     initscr();
     cbreak();
     noecho();
@@ -283,7 +361,7 @@
     demo_forms();
 
     endwin();
-    return EXIT_SUCCESS;
+    ExitProgram(EXIT_SUCCESS);
 }
 #else
 int
diff -Naur ncurses-5.4.orig/test/demo_menus.c ncurses-5.4/test/demo_menus.c
--- ncurses-5.4.orig/test/demo_menus.c	2003-04-26 22:10:43.000000000 +0000
+++ ncurses-5.4/test/demo_menus.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,11 +1,10 @@
 /*
- * $Id: demo_menus.c,v 1.1 2003/04/26 22:10:43 tom Exp $
+ * $Id: demo_menus.c,v 1.11 2005/04/16 16:19:50 tom Exp $
  *
  * Demonstrate a variety of functions from the menu library.
- * Thomas Dickey - 2003/4/26
+ * Thomas Dickey - 2005/4/9
  */
 /*
-item_count			-
 item_description		-
 item_init			-
 item_opts			-
@@ -21,12 +20,10 @@
 menu_init			-
 menu_mark			-
 menu_opts			-
-menu_opts_on			-
 menu_pad			-
 menu_pattern			-
 menu_request_by_name		-
 menu_request_name		-
-menu_spacing			-
 menu_sub			-
 menu_term			-
 menu_userptr			-
@@ -35,12 +32,9 @@
 set_item_opts			-
 set_item_term			-
 set_item_userptr		-
-set_menu_back			-
-set_menu_fore			-
 set_menu_grey			-
 set_menu_init			-
 set_menu_items			-
-set_menu_mark			-
 set_menu_opts			-
 set_menu_pad			-
 set_menu_pattern		-
@@ -57,10 +51,634 @@
 
 #include <menu.h>
 
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifdef NCURSES_VERSION
+#ifdef TRACE
+static unsigned save_trace = TRACE_ORDINARY | TRACE_CALLS;
+extern unsigned _nc_tracing;
+static MENU *mpTrace;
+#endif
+#else
+#undef TRACE
+#endif
+
+typedef enum {
+    eFile
+    ,eSelect
+#ifdef TRACE
+    ,eTrace
+#endif
+} MenuNo;
+
+#define MENU_Y	1
+
+static MENU *mpBanner;
+static MENU *mpFile;
+static MENU *mpSelect;
+
+#if !HAVE_STRDUP
+#define strdup my_strdup
+static char *
+strdup(char *s)
+{
+    char *p = (char *) malloc(strlen(s) + 1);
+    if (p)
+	strcpy(p, s);
+    return (p);
+}
+#endif /* not HAVE_STRDUP */
+
+/* Common function to allow ^T to toggle trace-mode in the middle of a test
+ * so that trace-files can be made smaller.
+ */
+static int
+wGetchar(WINDOW *win)
+{
+    int c;
+#ifdef TRACE
+    while ((c = wgetch(win)) == CTRL('T')) {
+	if (_nc_tracing) {
+	    save_trace = _nc_tracing;
+	    _tracef("TOGGLE-TRACING OFF");
+	    _nc_tracing = 0;
+	} else {
+	    _nc_tracing = save_trace;
+	}
+	trace(_nc_tracing);
+	if (_nc_tracing)
+	    _tracef("TOGGLE-TRACING ON");
+    }
+#else
+    c = wgetch(win);
+#endif
+    return c;
+}
+#define Getchar() wGetchar(stdscr)
+
+static int
+menu_virtualize(int c)
+{
+    int result;
+
+    if (c == '\n' || c == KEY_EXIT)
+	result = (MAX_COMMAND + 1);
+    else if (c == 'u')
+	result = (REQ_SCR_ULINE);
+    else if (c == 'd')
+	result = (REQ_SCR_DLINE);
+    else if (c == 'b' || c == KEY_NPAGE)
+	result = (REQ_SCR_UPAGE);
+    else if (c == 'f' || c == KEY_PPAGE)
+	result = (REQ_SCR_DPAGE);
+    else if (c == 'l' || c == KEY_LEFT || c == KEY_BTAB)
+	result = (REQ_LEFT_ITEM);
+    else if (c == 'n' || c == KEY_DOWN)
+	result = (REQ_NEXT_ITEM);
+    else if (c == 'p' || c == KEY_UP)
+	result = (REQ_PREV_ITEM);
+    else if (c == 'r' || c == KEY_RIGHT || c == '\t')
+	result = (REQ_RIGHT_ITEM);
+    else if (c == ' ')
+	result = (REQ_TOGGLE_ITEM);
+    else {
+	if (c != KEY_MOUSE)
+	    beep();
+	result = (c);
+    }
+    return result;
+}
+
+static int
+menu_getc(MENU * m)
+{
+    return wGetchar(menu_win(m));
+}
+
+static int
+menu_offset(MenuNo number)
+{
+    int result = 0;
+
+    if ((int) number >= 0) {
+	int spc_desc, spc_rows, spc_cols;
+
+	menu_spacing(mpBanner, &spc_desc, &spc_rows, &spc_cols);
+
+	/* FIXME: MENU.itemlen seems the only way to get actual width of items */
+	result = number * (mpBanner->itemlen + spc_rows);
+    }
+    return result;
+}
+
+static MENU *
+menu_create(ITEM ** items, int count, int ncols, MenuNo number)
+{
+    MENU *result;
+    WINDOW *menuwin;
+    int mrows, mcols;
+    int y = ((int) number >= 0) ? MENU_Y : 0;
+    int x = menu_offset(number);
+    int margin = (y == MENU_Y) ? 1 : 0;
+    int maxcol = (ncols + x) < COLS ? ncols : (COLS - x - 1);
+    int maxrow = (count + 1) / ncols;
+
+    if ((maxrow + y) >= (LINES - 4))
+	maxrow = LINES - 4 - y;
+
+    result = new_menu(items);
+
+    if (has_colors()) {
+	set_menu_fore(result, COLOR_PAIR(1));
+	set_menu_back(result, COLOR_PAIR(2));
+    }
+
+    set_menu_format(result, maxrow, maxcol);
+    scale_menu(result, &mrows, &mcols);
+
+    if (mcols + (2 * margin + x) >= COLS)
+	mcols = COLS - (2 * margin + x);
+
+#ifdef TRACE
+    if (number == eTrace)
+	menu_opts_off(result, O_ONEVALUE);
+    else
+	menu_opts_on(result, O_ONEVALUE);
+#endif
+
+    menuwin = newwin(mrows + (2 * margin), mcols + (2 * margin), y, x);
+    set_menu_win(result, menuwin);
+    keypad(menuwin, TRUE);
+    if (margin)
+	box(menuwin, 0, 0);
+
+    set_menu_sub(result, derwin(menuwin, mrows, mcols, margin, margin));
+
+    post_menu(result);
+
+    return result;
+}
+
+static void
+menu_destroy(MENU * m)
+{
+    ITEM **ip;
+    int count;
+
+    if (m != 0) {
+	delwin(menu_win(m));
+
+	ip = menu_items(m);
+	count = item_count(m);
+
+	free_menu(m);
+#if 0
+	if (count > 0) {
+	    while (*ip) {
+		_tracef("freeing item %d:%d", ip - menu_items(m), count);
+		free_item(*ip++);
+	    }
+	}
+#endif
+    }
+}
+
+/* force the given menu to appear */
+static void
+menu_display(MENU * m)
+{
+    touchwin(menu_win(m));
+    wrefresh(menu_win(m));
+}
+
+/*****************************************************************************/
+
+static void
+build_file_menu(MenuNo number)
+{
+    static const char *labels[] =
+    {
+	"Exit",
+	(char *) 0
+    };
+    static ITEM *items[SIZEOF(labels)];
+
+    ITEM **ip = items;
+    const char **ap;
+
+    for (ap = labels; *ap; ap++)
+	*ip++ = new_item(*ap, "");
+    *ip = (ITEM *) 0;
+
+    mpFile = menu_create(items, SIZEOF(labels) - 1, 1, number);
+}
+
+static int
+perform_file_menu(int cmd)
+{
+    return menu_driver(mpFile, cmd);
+}
+
+/*****************************************************************************/
+
+static void
+build_select_menu(MenuNo number, char *filename)
+{
+    static const char *labels[] =
+    {
+	"Lions",
+	"Tigers",
+	"Bears",
+	"(Oh my!)",
+	"Newts",
+	"Platypi",
+	"Lemurs",
+	"(Oh really?!)",
+	"Leopards",
+	"Panthers",
+	"Pumas",
+	"Lions, Tigers, Bears, (Oh my!), Newts, Platypi, Lemurs",
+	"Lions, Tigers, Bears, (Oh my!), Newts, Platypi, Lemurs, Lions, Tigers, Bears, (Oh my!), Newts, Platypi, Lemurs",
+	(char *) 0
+    };
+    static ITEM **items;
+
+    ITEM **ip;
+    const char **ap = 0;
+    unsigned count = 0;
+
+    if (filename != 0) {
+	struct stat sb;
+	if (stat(filename, &sb) == 0
+	    && (sb.st_mode & S_IFMT) == S_IFREG
+	    && sb.st_size != 0) {
+	    unsigned size = sb.st_size;
+	    unsigned j, k;
+	    char *blob = malloc(size + 1);
+	    const char **list = (const char **) calloc(sizeof(*list), size + 1);
+
+	    items = (ITEM **) calloc(sizeof(ITEM *), size + 1);
+	    if (blob != 0 && list != 0) {
+		FILE *fp = fopen(filename, "r");
+		if (fp != 0) {
+		    if (fread(blob, sizeof(char), size, fp) == size) {
+			bool mark = TRUE;
+			for (j = k = 0; j < size; ++j) {
+			    if (mark) {
+				list[k++] = blob + j;
+				mark = FALSE;
+			    }
+			    if (blob[j] == '\n') {
+				blob[j] = '\0';
+				if (k > 0 && *list[k - 1] == '\0')
+				    --k;
+				mark = TRUE;
+			    } else if (blob[j] == '\t') {
+				blob[j] = ' ';	/* menu items are printable */
+			    }
+			}
+			list[k] = 0;
+			count = k;
+			ap = list;
+		    }
+		    fclose(fp);
+		}
+	    }
+	}
+    }
+    if (ap == 0) {
+	count = SIZEOF(labels) - 1;
+	items = (ITEM **) calloc(count + 1, sizeof(*items));
+	ap = labels;
+    }
+
+    ip = items;
+    while (*ap != 0)
+	*ip++ = new_item(*ap++, "");
+    *ip = 0;
+
+    mpSelect = menu_create(items, (int) count, 1, number);
+}
+
+static int
+perform_select_menu(int cmd)
+{
+    return menu_driver(mpSelect, cmd);
+}
+
+/*****************************************************************************/
+
+#ifdef TRACE
+#define T_TBL(name) { #name, name }
+static struct {
+    const char *name;
+    unsigned mask;
+} t_tbl[] = {
+
+    T_TBL(TRACE_DISABLE),
+	T_TBL(TRACE_TIMES),
+	T_TBL(TRACE_TPUTS),
+	T_TBL(TRACE_UPDATE),
+	T_TBL(TRACE_MOVE),
+	T_TBL(TRACE_CHARPUT),
+	T_TBL(TRACE_ORDINARY),
+	T_TBL(TRACE_CALLS),
+	T_TBL(TRACE_VIRTPUT),
+	T_TBL(TRACE_IEVENT),
+	T_TBL(TRACE_BITS),
+	T_TBL(TRACE_ICALLS),
+	T_TBL(TRACE_CCALLS),
+	T_TBL(TRACE_DATABASE),
+	T_TBL(TRACE_ATTRS),
+	T_TBL(TRACE_MAXIMUM),
+    {
+	(char *) 0, 0
+    }
+};
+
+static void
+build_trace_menu(MenuNo number)
+{
+    static ITEM *items[SIZEOF(t_tbl)];
+
+    ITEM **ip = items;
+    int n;
+
+    for (n = 0; t_tbl[n].name != 0; n++)
+	*ip++ = new_item(t_tbl[n].name, "");
+    *ip = (ITEM *) 0;
+
+    mpTrace = menu_create(items, SIZEOF(t_tbl) - 1, 2, number);
+}
+
+static char *
+tracetrace(unsigned tlevel)
+{
+    static char *buf;
+    int n;
+
+    if (buf == 0) {
+	size_t need = 12;
+	for (n = 0; t_tbl[n].name != 0; n++)
+	    need += strlen(t_tbl[n].name) + 2;
+	buf = (char *) malloc(need);
+    }
+    sprintf(buf, "0x%02x = {", tlevel);
+    if (tlevel == 0) {
+	sprintf(buf + strlen(buf), "%s, ", t_tbl[0].name);
+    } else {
+	for (n = 1; t_tbl[n].name != 0; n++)
+	    if ((tlevel & t_tbl[n].mask) == t_tbl[n].mask) {
+		strcat(buf, t_tbl[n].name);
+		strcat(buf, ", ");
+	    }
+    }
+    if (buf[strlen(buf) - 2] == ',')
+	buf[strlen(buf) - 2] = '\0';
+    return (strcat(buf, "}"));
+}
+
+/* fake a dynamically reconfigurable menu using the 0th entry to deselect
+ * the others
+ */
+static bool
+update_trace_menu(MENU * m)
+{
+    ITEM **items;
+    ITEM *i, **p;
+    bool changed = FALSE;
+
+    items = menu_items(m);
+    i = current_item(m);
+    if (i == items[0]) {
+	if (item_value(i)) {
+	    for (p = items + 1; *p != 0; p++)
+		if (item_value(*p)) {
+		    set_item_value(*p, FALSE);
+		    changed = TRUE;
+		}
+	}
+    }
+    return changed;
+}
+
+static int
+perform_trace_menu(int cmd)
+/* interactively set the trace level */
+{
+    ITEM **ip;
+    unsigned newtrace;
+    int result;
+
+    for (ip = menu_items(mpTrace); *ip; ip++) {
+	unsigned mask = t_tbl[item_index(*ip)].mask;
+	if (mask == 0)
+	    set_item_value(*ip, _nc_tracing == 0);
+	else if ((mask & _nc_tracing) == mask)
+	    set_item_value(*ip, TRUE);
+    }
+
+    result = menu_driver(mpTrace, cmd);
+
+    if (result == E_OK) {
+	if (update_trace_menu(mpTrace) || cmd == REQ_TOGGLE_ITEM) {
+	    newtrace = 0;
+	    for (ip = menu_items(mpTrace); *ip; ip++) {
+		if (item_value(*ip))
+		    newtrace |= t_tbl[item_index(*ip)].mask;
+	    }
+	    trace(newtrace);
+	    _tracef("trace level interactively set to %s", tracetrace(_nc_tracing));
+
+	    (void) mvprintw(LINES - 2, 0,
+			    "Trace level is %s\n", tracetrace(_nc_tracing));
+	    refresh();
+	}
+    }
+    return result;
+}
+#endif /* TRACE */
+
+/*****************************************************************************/
+
+static MenuNo
+menu_number(void)
+{
+    return item_index(current_item(mpBanner));
+}
+
+static MENU *
+current_menu(void)
+{
+    MENU *result;
+
+    switch (menu_number()) {
+    case eFile:
+	result = mpFile;
+	break;
+    case eSelect:
+	result = mpSelect;
+	break;
+#ifdef TRACE
+    case eTrace:
+	result = mpTrace;
+	break;
+#endif
+    default:
+	result = 0;
+	break;
+    }
+    return result;
+}
+
+static void
+build_menus(char *filename)
+{
+    static const char *labels[] =
+    {
+	"File",
+	"Select",
+#ifdef TRACE
+	"Trace",
+#endif
+	(char *) 0
+    };
+    static ITEM *items[SIZEOF(labels)];
+
+    ITEM **ip = items;
+    const char **ap;
+
+    for (ap = labels; *ap; ap++)
+	*ip++ = new_item(*ap, "");
+    *ip = (ITEM *) 0;
+
+    mpBanner = menu_create(items, SIZEOF(labels) - 1, SIZEOF(labels) - 1, -1);
+    set_menu_mark(mpBanner, ">");
+
+    build_file_menu(eFile);
+    build_select_menu(eSelect, filename);
+#ifdef TRACE
+    build_trace_menu(eTrace);
+#endif
+}
+
+static void
+perform_menus(void)
+{
+    MENU *this_menu;
+    MENU *last_menu = mpFile;
+    int code = E_UNKNOWN_COMMAND, cmd, ch;
+
+#ifdef NCURSES_MOUSE_VERSION
+    mousemask(ALL_MOUSE_EVENTS, (mmask_t *) 0);
+#endif
+
+    menu_display(last_menu);
+
+    for (;;) {
+	ch = menu_getc(mpBanner);
+	cmd = menu_virtualize(ch);
+
+	switch (cmd) {
+	    /*
+	     * The banner menu acts solely to select one of the other menus.
+	     * Move between its items, wrapping at the left/right limits.
+	     */
+	case REQ_LEFT_ITEM:
+	case REQ_RIGHT_ITEM:
+	    code = menu_driver(mpBanner, cmd);
+	    if (code == E_REQUEST_DENIED) {
+		if (menu_number() > 0)
+		    code = menu_driver(mpBanner, REQ_FIRST_ITEM);
+		else
+		    code = menu_driver(mpBanner, REQ_LAST_ITEM);
+	    }
+	    break;
+	default:
+	    switch (menu_number()) {
+	    case eFile:
+		code = perform_file_menu(cmd);
+		break;
+	    case eSelect:
+		code = perform_select_menu(cmd);
+		break;
+#ifdef TRACE
+	    case eTrace:
+		code = perform_trace_menu(cmd);
+		break;
+#endif
+	    }
+
+	    if ((code == E_REQUEST_DENIED) && (cmd == KEY_MOUSE)) {
+		code = menu_driver(mpBanner, cmd);
+	    }
+
+	    break;
+	}
+
+	if (code == E_OK) {
+	    this_menu = current_menu();
+	    if (this_menu != last_menu) {
+		move(1, 0);
+		clrtobot();
+		box(menu_win(this_menu), 0, 0);
+		refresh();
+
+		/* force the current menu to appear */
+		menu_display(this_menu);
+
+		last_menu = this_menu;
+	    }
+	}
+	wrefresh(menu_win(last_menu));
+	if (code == E_UNKNOWN_COMMAND
+	    || code == E_NOT_POSTED) {
+	    if (menu_number() == eFile)
+		break;
+	    beep();
+	}
+	if (code == E_REQUEST_DENIED)
+	    beep();
+	continue;
+    }
+
+#ifdef NCURSES_MOUSE_VERSION
+    mousemask(0, (mmask_t *) 0);
+#endif
+}
+
+static void
+destroy_menus(void)
+{
+    menu_destroy(mpFile);
+    menu_destroy(mpSelect);
+#ifdef TRACE
+    menu_destroy(mpTrace);
+#endif
+    menu_destroy(mpBanner);
+}
+
 int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
-    printf("Not implemented - demo for menu library\n");
+    setlocale(LC_ALL, "");
+
+    initscr();
+    noraw();
+    cbreak();
+    noecho();
+
+    if (has_colors()) {
+	start_color();
+	init_pair(1, COLOR_RED, COLOR_BLACK);
+	init_pair(2, COLOR_BLUE, COLOR_WHITE);
+    }
+    build_menus(argc > 1 ? argv[1] : 0);
+    perform_menus();
+    destroy_menus();
+
+    endwin();
     return EXIT_SUCCESS;
 }
 #else
diff -Naur ncurses-5.4.orig/test/demo_termcap.c ncurses-5.4/test/demo_termcap.c
--- ncurses-5.4.orig/test/demo_termcap.c	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/test/demo_termcap.c	2005-05-13 04:09:58.000000000 +0000
@@ -0,0 +1,157 @@
+/****************************************************************************
+ * Copyright (c) 2005 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"), to deal in the Software without restriction, including      *
+ * without limitation the rights to use, copy, modify, merge, publish,      *
+ * distribute, distribute with modifications, sublicense, and/or sell       *
+ * copies of the Software, and to permit persons to whom the Software is    *
+ * furnished to do so, subject to the following conditions:                 *
+ *                                                                          *
+ * The above copyright notice and this permission notice shall be included  *
+ * in all copies or substantial portions of the Software.                   *
+ *                                                                          *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
+ *                                                                          *
+ * Except as contained in this notice, the name(s) of the above copyright   *
+ * holders shall not be used in advertising or otherwise to promote the     *
+ * sale, use or other dealings in this Software without prior written       *
+ * authorization.                                                           *
+ ****************************************************************************/
+
+/*
+ * Author: Thomas E. Dickey
+ *
+ * $Id: demo_termcap.c,v 1.2 2005/04/30 14:57:54 tom Exp $
+ *
+ * A simple demo of the termcap interface.
+ */
+#include <test.priv.h>
+
+#define isCapName(c) (isgraph(c) && strchr("^#=:\\", c) == 0)
+
+static void
+dumpit(char *cap)
+{
+    /*
+     * One of the limitations of the termcap interface is that the library
+     * cannot determine the size of the buffer passed via tgetstr(), nor the
+     * amount of space remaining.  This demo simply reuses the whole buffer
+     * for each call; a normal termcap application would try to use the buffer
+     * to hold all of the strings extracted from the terminal entry.
+     */
+    char area[1024], *ap = area;
+    char *str;
+    int num;
+
+    if ((str = tgetstr(cap, &ap)) != 0) {
+	/*
+	 * Note that the strings returned are mostly terminfo format, since
+	 * ncurses does not convert except for a handful of special cases.
+	 */
+	printf("str %s = ", cap);
+	while (*str != 0) {
+	    int ch = UChar(*str++);
+	    switch (ch) {
+	    case '\177':
+		fputs("^?", stdout);
+		break;
+	    case '\033':
+		fputs("\\E", stdout);
+		break;
+	    case '\b':
+		fputs("\\b", stdout);
+		break;
+	    case '\f':
+		fputs("\\f", stdout);
+		break;
+	    case '\n':
+		fputs("\\n", stdout);
+		break;
+	    case '\r':
+		fputs("\\r", stdout);
+		break;
+	    case ' ':
+		fputs("\\s", stdout);
+		break;
+	    case '\t':
+		fputs("\\t", stdout);
+		break;
+	    case '^':
+		fputs("\\^", stdout);
+		break;
+	    case ':':
+		fputs("\\072", stdout);
+		break;
+	    case '\\':
+		fputs("\\\\", stdout);
+		break;
+	    default:
+		if (isgraph(ch))
+		    fputc(ch, stdout);
+		else if (ch < 32)
+		    printf("^%c", ch + '@');
+		else
+		    printf("\\%03o", ch);
+		break;
+	    }
+	}
+	printf("\n");
+    } else if ((num = tgetnum(cap)) >= 0) {
+	printf("num %s = %d\n", cap, num);
+    } else if ((num = tgetflag(cap)) != 0) {
+	printf("flg %s\n", cap);
+    }
+    fflush(stdout);
+}
+
+static void
+demo_termcap(char *name)
+{
+    char buffer[1024];
+
+    printf("Terminal type %s\n", name);
+    if (tgetent(buffer, name)) {
+	char cap[3];
+	int c1, c2;
+
+	cap[2] = 0;
+	for (c1 = 0; c1 < 256; ++c1) {
+	    cap[0] = c1;
+	    if (isCapName(c1)) {
+		for (c2 = 0; c2 < 256; ++c2) {
+		    cap[1] = c2;
+		    if (isCapName(c2)) {
+			dumpit(cap);
+		    }
+		}
+	    }
+	}
+    }
+}
+
+int
+main(int argc, char *argv[])
+{
+    int n;
+    char *name;
+
+    if (argc > 1) {
+	for (n = 1; n < argc; ++n) {
+	    demo_termcap(argv[n]);
+	}
+    } else if ((name = getenv("TERM")) != 0) {
+	demo_termcap(name);
+    } else {
+	demo_termcap("dumb");
+    }
+
+    ExitProgram(EXIT_SUCCESS);
+}
diff -Naur ncurses-5.4.orig/test/ditto.c ncurses-5.4/test/ditto.c
--- ncurses-5.4.orig/test/ditto.c	2001-09-15 21:53:37.000000000 +0000
+++ ncurses-5.4/test/ditto.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,2001 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2001,2005 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,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey <dickey@clark.net> 1998
  *
- * $Id: ditto.c,v 1.4 2001/09/15 21:53:37 tom Exp $
+ * $Id: ditto.c,v 1.5 2005/04/16 16:35:49 tom Exp $
  *
  * The program illustrates how to set up multiple screens from a single
  * program.  Invoke the program by specifying another terminal on the same
@@ -80,9 +80,8 @@
 }
 
 int
-main(
-	int argc GCC_UNUSED,
-	char *argv[]GCC_UNUSED)
+main(int argc GCC_UNUSED,
+     char *argv[]GCC_UNUSED)
 {
     int j;
     int active_tty = 0;
@@ -91,7 +90,7 @@
     if (argc <= 1)
 	usage();
 
-    if ((data = (DITTO *) calloc(argc, sizeof(DITTO))) == 0)
+    if ((data = (DITTO *) calloc((unsigned) argc, sizeof(DITTO))) == 0)
 	failed("calloc data");
 
     data[0].input = stdin;
@@ -107,10 +106,9 @@
      */
     for (j = 0; j < argc; j++) {
 	active_tty++;
-	data[j].screen = newterm(
-				    (char *) 0,		/* assume $TERM is the same */
-				    data[j].output,
-				    data[j].input);
+	data[j].screen = newterm((char *) 0,	/* assume $TERM is the same */
+				 data[j].output,
+				 data[j].input);
 	if (data[j].screen == 0)
 	    failed("newterm");
 	cbreak();
@@ -132,7 +130,7 @@
 	    break;
 	for (j = 0; j < argc; j++) {
 	    set_term(data[j].screen);
-	    addch(ch);
+	    addch(UChar(ch));
 	    refresh();
 	}
     }
diff -Naur ncurses-5.4.orig/test/dots.c ncurses-5.4/test/dots.c
--- ncurses-5.4.orig/test/dots.c	2002-04-06 21:33:42.000000000 +0000
+++ ncurses-5.4/test/dots.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1999-2001,2002 Free Software Foundation, Inc.              *
+ * Copyright (c) 1999-2002,2004 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,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey <dickey@clark.net> 1999
  *
- * $Id: dots.c,v 1.8 2002/04/06 21:33:42 tom Exp $
+ * $Id: dots.c,v 1.10 2005/04/16 16:33:04 tom Exp $
  *
  * A simple demo of the terminfo interface.
  */
@@ -101,7 +101,7 @@
 	if (signal(j, SIG_IGN) != SIG_IGN)
 	    signal(j, onsig);
 
-    srand(time(0));
+    srand((unsigned) time(0));
     setupterm((char *) 0, 1, (int *) 0);
     outs(clear_screen);
     outs(cursor_invisible);
@@ -127,12 +127,16 @@
 		tputs(tparm2(set_a_foreground, z), 1, outc);
 	    } else {
 		tputs(tparm2(set_a_background, z), 1, outc);
+		napms(1);
 	    }
 	} else if (valid(exit_attribute_mode)
 		   && valid(enter_reverse_mode)) {
-	    if (ranf() <= 0.01)
-		outs((ranf() > 0.6) ? enter_reverse_mode :
-		     exit_attribute_mode);
+	    if (ranf() <= 0.01) {
+		outs((ranf() > 0.6)
+		     ? enter_reverse_mode
+		     : exit_attribute_mode);
+		napms(1);
+	    }
 	}
 	outc(p);
 	fflush(stdout);
diff -Naur ncurses-5.4.orig/test/edit_field.c ncurses-5.4/test/edit_field.c
--- ncurses-5.4.orig/test/edit_field.c	2003-05-17 23:16:13.000000000 +0000
+++ ncurses-5.4/test/edit_field.c	2005-05-13 04:09:51.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * $Id: edit_field.c,v 1.7 2003/05/17 23:16:13 tom Exp $
+ * $Id: edit_field.c,v 1.8 2004/05/29 22:49:23 tom Exp $
  *
  * A wrapper for form_driver() which keeps track of the user's editing changes
  * for each field, and makes the result available as a null-terminated string
@@ -181,7 +181,7 @@
 
     keypad(help, TRUE);
     keypad(data, TRUE);
-    waddstr(data, "Defined form-traversal keys:\n");
+    waddstr(data, "Defined form edit/traversal keys:\n");
     for (n = 0; n < SIZEOF(commands); ++n) {
 	const char *name;
 #ifdef NCURSES_VERSION
diff -Naur ncurses-5.4.orig/test/filter.c ncurses-5.4/test/filter.c
--- ncurses-5.4.orig/test/filter.c	2002-03-23 23:02:15.000000000 +0000
+++ ncurses-5.4/test/filter.c	2005-05-13 04:09:51.000000000 +0000
@@ -29,7 +29,7 @@
 /*
  * Author:  Thomas E. Dickey <dickey@clark.net> 1998
  *
- * $Id: filter.c,v 1.7 2002/03/23 23:02:15 tom Exp $
+ * $Id: filter.c,v 1.8 2004/06/05 21:57:30 tom Exp $
  */
 #include <test.priv.h>
 
@@ -67,6 +67,8 @@
     char buffer[80];
     attr_t underline;
 
+    setlocale(LC_ALL, "");
+
     filter();
     (void) newterm((char *) 0, stdout, stdin);
     cbreak();
diff -Naur ncurses-5.4.orig/test/firstlast.c ncurses-5.4/test/firstlast.c
--- ncurses-5.4.orig/test/firstlast.c	2001-09-15 21:46:34.000000000 +0000
+++ ncurses-5.4/test/firstlast.c	2005-05-13 04:09:57.000000000 +0000
@@ -2,7 +2,7 @@
  * This test was written by Alexander V. Lukyanov to demonstrate difference
  * between ncurses 4.1 and SVR4 curses
  *
- * $Id: firstlast.c,v 1.3 2001/09/15 21:46:34 tom Exp $
+ * $Id: firstlast.c,v 1.4 2005/04/16 16:34:05 tom Exp $
  */
 
 #include <test.priv.h>
@@ -13,7 +13,7 @@
     const char *s;
     for (;;) {
 	for (s = str; *s; s++) {
-	    if (waddch(w, *s) == ERR) {
+	    if (waddch(w, UChar(*s)) == ERR) {
 		wmove(w, 0, 0);
 		return;
 	    }
@@ -22,9 +22,8 @@
 }
 
 int
-main(
-	int argc GCC_UNUSED,
-	char *argv[]GCC_UNUSED)
+main(int argc GCC_UNUSED,
+     char *argv[]GCC_UNUSED)
 {
     WINDOW *large, *small;
     initscr();
diff -Naur ncurses-5.4.orig/test/gdc.c ncurses-5.4/test/gdc.c
--- ncurses-5.4.orig/test/gdc.c	2002-08-10 19:20:14.000000000 +0000
+++ ncurses-5.4/test/gdc.c	2005-05-13 04:09:51.000000000 +0000
@@ -6,7 +6,7 @@
  * modified 10-18-89 for curses (jrl)
  * 10-18-89 added signal handling
  *
- * $Id: gdc.c,v 1.23 2002/08/10 19:20:14 tom Exp $
+ * $Id: gdc.c,v 1.25 2004/11/24 12:09:36 tom Exp $
  */
 
 #include <time.h>
@@ -18,6 +18,10 @@
 #define XLENGTH	54
 #define YDEPTH	5
 
+#define PAIR_DIGITS 1
+#define PAIR_OTHERS 2
+#define PAIR_FRAMES 3
+
 static short disp[11] =
 {
     075557, 011111, 071747, 071717, 055711,
@@ -41,13 +45,13 @@
 }
 
 static void
-drawbox(void)
+drawbox(bool scrolling)
 {
     chtype bottom[XLENGTH + 1];
     int n;
 
     if (hascolor)
-	attrset(COLOR_PAIR(3));
+	attrset(COLOR_PAIR(PAIR_FRAMES));
 
     mvaddch(YBASE - 1, XBASE - 1, ACS_ULCORNER);
     hline(ACS_HLINE, XLENGTH);
@@ -55,8 +59,11 @@
 
     mvaddch(YBASE + YDEPTH, XBASE - 1, ACS_LLCORNER);
     mvinchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH);
-    for (n = 0; n < XLENGTH; n++)
+    for (n = 0; n < XLENGTH; n++) {
+	if (!scrolling)
+	    bottom[n] &= ~A_COLOR;
 	bottom[n] = ACS_HLINE | (bottom[n] & (A_ATTRIBUTES | A_COLOR));
+    }
     mvaddchnstr(YBASE + YDEPTH, XBASE, bottom, XLENGTH);
     mvaddch(YBASE + YDEPTH, XBASE + XLENGTH, ACS_LRCORNER);
 
@@ -67,7 +74,7 @@
     vline(ACS_VLINE, YDEPTH);
 
     if (hascolor)
-	attrset(COLOR_PAIR(2));
+	attrset(COLOR_PAIR(PAIR_OTHERS));
 }
 
 static void
@@ -75,13 +82,13 @@
 {
     if (on) {
 	if (hascolor) {
-	    attron(COLOR_PAIR(1));
+	    attron(COLOR_PAIR(PAIR_DIGITS));
 	} else {
 	    attron(A_STANDOUT);
 	}
     } else {
 	if (hascolor) {
-	    attron(COLOR_PAIR(2));
+	    attron(COLOR_PAIR(PAIR_OTHERS));
 	} else {
 	    attroff(A_STANDOUT);
 	}
@@ -182,10 +189,10 @@
 	if (use_default_colors() == OK)
 	    bg = -1;
 #endif
-	init_pair(1, COLOR_BLACK, COLOR_RED);
-	init_pair(2, COLOR_RED, bg);
-	init_pair(3, COLOR_WHITE, bg);
-	attrset(COLOR_PAIR(2));
+	init_pair(PAIR_DIGITS, COLOR_BLACK, COLOR_RED);
+	init_pair(PAIR_OTHERS, COLOR_RED, bg);
+	init_pair(PAIR_FRAMES, COLOR_WHITE, bg);
+	attrset(COLOR_PAIR(PAIR_OTHERS));
     }
 
   restart:
@@ -193,7 +200,7 @@
 	older[j] = newer[j] = next[j] = 0;
 
     clear();
-    drawbox();
+    drawbox(FALSE);
 
     do {
 	char buf[30];
@@ -239,17 +246,17 @@
 		}
 		if (!s) {
 		    if (scrol)
-			drawbox();
+			drawbox(TRUE);
 		    refresh();
 		    /*
 		     * If we're scrolling, space out the refreshes to fake
 		     * movement.  That's 7 frames, or 6 intervals, which would
 		     * be 166 msec if we spread it out over a second.  It looks
-		     * better (but will well on a slow terminal, e.g., less
+		     * better (but will work on a slow terminal, e.g., less
 		     * than 9600bd) to squeeze that into a half-second, and use
 		     * half of 170 msec to ensure that the program doesn't eat
 		     * a lot of time when asking what time it is, at the top of
-		     * this loop -TD
+		     * this loop -T.Dickey
 		     */
 		    if (scrol)
 			napms(85);
@@ -263,7 +270,7 @@
 	mvaddstr(16, 30, buf);
 
 	move(6, 0);
-	drawbox();
+	drawbox(FALSE);
 	refresh();
 
 	/*
diff -Naur ncurses-5.4.orig/test/hashtest.c ncurses-5.4/test/hashtest.c
--- ncurses-5.4.orig/test/hashtest.c	2002-10-19 22:11:24.000000000 +0000
+++ ncurses-5.4/test/hashtest.c	2005-05-13 04:09:57.000000000 +0000
@@ -3,7 +3,7 @@
  *
  * Generate timing statistics for vertical-motion optimization.
  *
- * $Id: hashtest.c,v 1.23 2002/10/19 22:11:24 tom Exp $
+ * $Id: hashtest.c,v 1.24 2005/04/16 16:36:54 tom Exp $
  */
 
 #ifdef TRACE
@@ -63,11 +63,11 @@
     move(0, 0);
     for (i = 0; i < head_lines; i++)
 	for (j = 0; j < COLS; j++)
-	    addch((j % 8 == 0) ? ('A' + j / 8) : '-');
+	    addch(UChar((j % 8 == 0) ? ('A' + j / 8) : '-'));
 
     move(head_lines, 0);
     for (i = head_lines; i < LINES - foot_lines; i++) {
-	int c = (base - LO_CHAR + i) % (HI_CHAR - LO_CHAR + 1) + LO_CHAR;
+	chtype c = (base - LO_CHAR + i) % (HI_CHAR - LO_CHAR + 1) + LO_CHAR;
 	int hi = (extend_corner || (i < LINES - 1)) ? COLS : COLS - 1;
 	for (j = 0; j < hi; j++)
 	    addch(c);
@@ -76,7 +76,7 @@
     for (i = LINES - foot_lines; i < LINES; i++) {
 	move(i, 0);
 	for (j = 0; j < (extend_corner ? COLS : COLS - 1); j++)
-	    addch((j % 8 == 0) ? ('A' + j / 8) : '-');
+	    addch(UChar((j % 8 == 0) ? ('A' + j / 8) : '-'));
     }
 
     scrollok(stdscr, TRUE);
diff -Naur ncurses-5.4.orig/test/ins_wide.c ncurses-5.4/test/ins_wide.c
--- ncurses-5.4.orig/test/ins_wide.c	2003-08-09 22:07:23.000000000 +0000
+++ ncurses-5.4/test/ins_wide.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * $Id: ins_wide.c,v 1.3 2003/08/09 22:07:23 tom Exp $
+ * $Id: ins_wide.c,v 1.6 2005/04/16 17:45:17 tom Exp $
  *
  * Demonstrate the wins_wstr() and wins_wch functions.
  * Thomas Dickey - 2002/11/23
@@ -16,27 +16,66 @@
 
 #include <test.priv.h>
 
+#if USE_WIDEC_SUPPORT
+
+/* definitions to make it simpler to compare with inserts.c */
+#define InsNStr    ins_nwstr
+#define InsStr     ins_wstr
+#define MvInsNStr  mvins_nwstr
+#define MvInsStr   mvins_wstr
+#define MvWInsNStr mvwins_nwstr
+#define MvWInsStr  mvwins_wstr
+#define WInsNStr   wins_nwstr
+#define WInsStr    wins_wstr
+
 #define TABSIZE 8
 
-#if USE_WIDEC_SUPPORT
-static int margin = (2 * TABSIZE) - 1;
+typedef enum {
+    oDefault = 0,
+    oMove = 1,
+    oWindow = 2,
+    oMoveWindow = 3
+} Options;
+
+static bool m_opt = FALSE;
+static bool w_opt = FALSE;
+static int n_opt = -1;
 
 static void
-legend(WINDOW *win, wchar_t * buffer, int length)
+legend(WINDOW *win, int level, Options state, wchar_t *buffer, int length)
 {
+    NCURSES_CONST char *showstate;
+
+    switch (state) {
+    default:
+    case oDefault:
+	showstate = "";
+	break;
+    case oMove:
+	showstate = " (mvXXX)";
+	break;
+    case oWindow:
+	showstate = " (winXXX)";
+	break;
+    case oMoveWindow:
+	showstate = " (mvwinXXX)";
+	break;
+    }
+
     wmove(win, 0, 0);
     wprintw(win,
-	    "The Strings/Chars displays should match.  Enter any characters.\n");
+	    "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
-	    "Use down-arrow or ^N to repeat on the next line, 'q' to exit.\n");
+	    "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
     wclrtoeol(win);
-    wprintw(win, "Inserted %d characters <", length);
+    wprintw(win, "Level %d,%s inserted %d characters <", level,
+	    showstate, length);
     waddwstr(win, buffer);
     waddstr(win, ">");
 }
 
 static int
-ColOf(wchar_t * buffer, int length)
+ColOf(wchar_t *buffer, int length, int margin)
 {
     int n;
     int result;
@@ -63,7 +102,7 @@
 	    result += 2;
 	    break;
 	default:
-	    ++result;
+	    result += wcwidth(ch);
 	    if (ch < 32)
 		++result;
 	    break;
@@ -72,36 +111,126 @@
     return result;
 }
 
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+static int
+ConvertCh(chtype source, cchar_t *target)
 {
-    cchar_t tmp_cchar;
     wchar_t tmp_wchar[2];
+
+    tmp_wchar[0] = source;
+    tmp_wchar[1] = 0;
+    if (setcchar(target, tmp_wchar, A_NORMAL, 0, (void *) 0) == ERR) {
+	beep();
+	return FALSE;
+    }
+    return TRUE;
+}
+
+static int
+MvWInsCh(WINDOW *win, int y, int x, chtype ch)
+{
+    int code;
+    cchar_t tmp_cchar;
+
+    if (ConvertCh(ch, &tmp_cchar)) {
+	code = mvwins_wch(win, y, x, &tmp_cchar);
+    } else {
+	code = mvwinsch(win, y, x, ch);
+    }
+    return code;
+}
+
+static int
+MvInsCh(int y, int x, chtype ch)
+{
+    int code;
+    cchar_t tmp_cchar;
+
+    if (ConvertCh(ch, &tmp_cchar)) {
+	code = mvins_wch(y, x, &tmp_cchar);
+    } else {
+	code = mvinsch(y, x, ch);
+    }
+    return code;
+}
+
+static int
+WInsCh(WINDOW *win, chtype ch)
+{
+    int code;
+    cchar_t tmp_cchar;
+
+    if (ConvertCh(ch, &tmp_cchar)) {
+	code = wins_wch(win, &tmp_cchar);
+    } else {
+	code = winsch(win, ch);
+    }
+    return code;
+}
+
+static int
+InsCh(chtype ch)
+{
+    int code;
+    cchar_t tmp_cchar;
+
+    if (ConvertCh(ch, &tmp_cchar)) {
+	code = ins_wch(&tmp_cchar);
+    } else {
+	code = insch(ch);
+    }
+    return code;
+}
+
+#define LEN(n) ((length - (n) > n_opt) ? n_opt : (length - (n)))
+static void
+test_inserts(int level)
+{
+    static bool first = TRUE;
+
     wint_t ch;
     int code;
     int limit;
     int row = 1;
     int col;
+    int row2, col2;
     int length;
     wchar_t buffer[BUFSIZ];
-    WINDOW *work;
-    WINDOW *show;
-
-    putenv("TABSIZE=8");
-    initscr();
-    (void) cbreak();		/* take input chars one at a time, no wait for \n */
-    (void) noecho();		/* don't echo input */
-    keypad(stdscr, TRUE);
+    WINDOW *look = 0;
+    WINDOW *work = 0;
+    WINDOW *show = 0;
+    int margin = (2 * TABSIZE) - 1;
+    Options option = ((m_opt ? oMove : oDefault)
+		      | ((w_opt || (level > 0)) ? oWindow : oDefault));
+
+    if (first) {
+	static char cmd[80];
+	setlocale(LC_ALL, "");
+
+	putenv(strcpy(cmd, "TABSIZE=8"));
+
+	initscr();
+	(void) cbreak();	/* take input chars one at a time, no wait for \n */
+	(void) noecho();	/* don't echo input */
+	keypad(stdscr, TRUE);
+    }
 
     limit = LINES - 5;
-    work = newwin(limit, COLS, 0, 0);
-    show = newwin(4, COLS, limit + 1, 0);
+    if (level > 0) {
+	look = newwin(limit, COLS - (2 * (level - 1)), 0, level - 1);
+	work = newwin(limit - 2, COLS - (2 * level), 1, level);
+	show = newwin(4, COLS, limit + 1, 0);
+	box(look, 0, 0);
+	wnoutrefresh(look);
+	limit -= 2;
+    } else {
+	work = stdscr;
+	show = derwin(stdscr, 4, COLS, limit + 1, 0);
+    }
     keypad(work, TRUE);
 
     for (col = margin + 1; col < COLS; col += TABSIZE)
 	mvwvline(work, row, col, '.', limit - 2);
 
-    box(work, 0, 0);
     mvwvline(work, row, margin, ACS_VLINE, limit - 2);
     mvwvline(work, row, margin + 1, ACS_VLINE, limit - 2);
     limit /= 2;
@@ -111,7 +240,7 @@
     wnoutrefresh(work);
 
     buffer[length = 0] = '\0';
-    legend(show, buffer, length);
+    legend(show, level, option, buffer, length);
     wnoutrefresh(show);
 
     doupdate();
@@ -128,8 +257,7 @@
 
     while ((code = wget_wch(work, &ch)) != ERR) {
 
-	switch (code) {
-	case KEY_CODE_YES:
+	if (code == KEY_CODE_YES) {
 	    switch (ch) {
 	    case KEY_DOWN:
 		ch = CTRL('N');
@@ -141,70 +269,222 @@
 		beep();
 		continue;
 	    }
+	} else if (code == ERR) {
+	    beep();
 	    break;
 	}
 	if (ch == 'q')
 	    break;
 
 	wmove(work, row, margin + 1);
-	if (ch == CTRL('N')) {
+	switch (ch) {
+	case 'w':
+	    test_inserts(level + 1);
+
+	    touchwin(look);
+	    touchwin(work);
+	    touchwin(show);
+
+	    wnoutrefresh(look);
+	    wnoutrefresh(work);
+	    wnoutrefresh(show);
+
+	    doupdate();
+	    break;
+	case CTRL('N'):
 	    if (row < limit) {
 		++row;
 		/* put the whole string in, all at once */
-		mvwins_wstr(work, row, margin + 1, buffer);
+		col2 = margin + 1;
+		switch (option) {
+		case oDefault:
+		    if (n_opt > 1) {
+			for (col = 0; col < length; col += n_opt) {
+			    col2 = ColOf(buffer, col, margin);
+			    if (move(row, col2) != ERR) {
+				InsNStr(buffer + col, LEN(col));
+			    }
+			}
+		    } else {
+			if (move(row, col2) != ERR) {
+			    InsStr(buffer);
+			}
+		    }
+		    break;
+		case oMove:
+		    if (n_opt > 1) {
+			for (col = 0; col < length; col += n_opt) {
+			    col2 = ColOf(buffer, col, margin);
+			    MvInsNStr(row, col2, buffer + col, LEN(col));
+			}
+		    } else {
+			MvInsStr(row, col2, buffer);
+		    }
+		    break;
+		case oWindow:
+		    if (n_opt > 1) {
+			for (col = 0; col < length; col += n_opt) {
+			    col2 = ColOf(buffer, col, margin);
+			    if (wmove(work, row, col2) != ERR) {
+				WInsNStr(work, buffer + col, LEN(col));
+			    }
+			}
+		    } else {
+			if (wmove(work, row, col2) != ERR) {
+			    WInsStr(work, buffer);
+			}
+		    }
+		    break;
+		case oMoveWindow:
+		    if (n_opt > 1) {
+			for (col = 0; col < length; col += n_opt) {
+			    col2 = ColOf(buffer, col, margin);
+			    MvWInsNStr(work, row, col2, buffer + col, LEN(col));
+			}
+		    } else {
+			MvWInsStr(work, row, col2, buffer);
+		    }
+		    break;
+		}
 
 		/* do the corresponding single-character insertion */
+		row2 = limit + row;
 		for (col = 0; col < length; ++col) {
-		    memset(&tmp_cchar, 0, sizeof(tmp_cchar));
-		    if (setcchar(&tmp_cchar,
-				 &(buffer[col]),
-				 A_NORMAL,
-				 0,
-				 (void *) 0) != ERR) {
-			mvwins_wch(work, limit + row, ColOf(buffer, col), &tmp_cchar);
-		    } else {
-			beep();	/* even for tabs! */
-			mvwinsch(work,
-				 limit + row,
-				 ColOf(buffer, col), buffer[col]);
+		    col2 = ColOf(buffer, col, margin);
+		    switch (option) {
+		    case oDefault:
+			if (move(row2, col2) != ERR) {
+			    InsCh((chtype) buffer[col]);
+			}
+			break;
+		    case oMove:
+			MvInsCh(row2, col2, (chtype) buffer[col]);
+			break;
+		    case oWindow:
+			if (wmove(work, row2, col2) != ERR) {
+			    WInsCh(work, (chtype) buffer[col]);
+			}
+			break;
+		    case oMoveWindow:
+			MvWInsCh(work, row2, col2, (chtype) buffer[col]);
+			break;
 		    }
 		}
 	    } else {
 		beep();
 	    }
-	} else {
+	    break;
+	case KEY_BACKSPACE:
+	    ch = '\b';
+	    /* FALLTHRU */
+	default:
 	    buffer[length++] = ch;
 	    buffer[length] = '\0';
+
 	    /* put the string in, one character at a time */
-	    mvwins_wstr(work,
-			row,
-			ColOf(buffer, length - 1), buffer + length - 1);
+	    col = ColOf(buffer, length - 1, margin);
+	    switch (option) {
+	    case oDefault:
+		if (move(row, col) != ERR) {
+		    InsStr(buffer + length - 1);
+		}
+		break;
+	    case oMove:
+		MvInsStr(row, col, buffer + length - 1);
+		break;
+	    case oWindow:
+		if (wmove(work, row, col) != ERR) {
+		    WInsStr(work, buffer + length - 1);
+		}
+		break;
+	    case oMoveWindow:
+		MvWInsStr(work, row, col, buffer + length - 1);
+		break;
+	    }
 
 	    /* do the corresponding single-character insertion */
-	    tmp_wchar[0] = ch;
-	    tmp_wchar[1] = 0;
-	    if (setcchar(&tmp_cchar,
-			 tmp_wchar,
-			 A_NORMAL,
-			 0,
-			 (void *) 0) != ERR) {
-		mvwins_wch(work,
-			   limit + row,
-			   ColOf(buffer, length - 1), &tmp_cchar);
-	    } else {
-		beep();		/* even for tabs! */
-		mvwinsch(work,
-			 limit + row,
-			 ColOf(buffer, length - 1), ch);
+	    switch (option) {
+	    case oDefault:
+		if (move(limit + row, col) != ERR) {
+		    InsCh(ch);
+		}
+		break;
+	    case oMove:
+		MvInsCh(limit + row, col, ch);
+		break;
+	    case oWindow:
+		if (wmove(work, limit + row, col) != ERR) {
+		    WInsCh(work, ch);
+		}
+		break;
+	    case oMoveWindow:
+		MvWInsCh(work, limit + row, col, ch);
+		break;
 	    }
+
 	    wnoutrefresh(work);
 
-	    legend(show, buffer, length);
+	    legend(show, level, option, buffer, length);
 	    wnoutrefresh(show);
 
 	    doupdate();
+	    break;
+	}
+    }
+    if (level > 0) {
+	delwin(show);
+	delwin(work);
+	delwin(look);
+    }
+}
+
+static void
+usage(void)
+{
+    static const char *tbl[] =
+    {
+	"Usage: inserts [options]"
+	,""
+	,"Options:"
+	,"  -n NUM  limit string-inserts to NUM bytes on ^N replay"
+	,"  -m      perform wmove/move separately from insert-functions"
+	,"  -w      use window-parameter even when stdscr would be implied"
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(tbl); ++n)
+	fprintf(stderr, "%s\n", tbl[n]);
+    ExitProgram(EXIT_FAILURE);
+}
+
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+{
+    int ch;
+
+    setlocale(LC_ALL, "");
+
+    while ((ch = getopt(argc, argv, "mn:w")) != EOF) {
+	switch (ch) {
+	case 'm':
+	    m_opt = TRUE;
+	    break;
+	case 'n':
+	    n_opt = atoi(optarg);
+	    if (n_opt == 0)
+		n_opt = -1;
+	    break;
+	case 'w':
+	    w_opt = TRUE;
+	    break;
+	default:
+	    usage();
+	    break;
 	}
     }
+    if (optind < argc)
+	usage();
+
+    test_inserts(0);
     endwin();
     ExitProgram(EXIT_SUCCESS);
 }
diff -Naur ncurses-5.4.orig/test/inserts.c ncurses-5.4/test/inserts.c
--- ncurses-5.4.orig/test/inserts.c	2003-08-09 22:07:06.000000000 +0000
+++ ncurses-5.4/test/inserts.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * $Id: inserts.c,v 1.5 2003/08/09 22:07:06 tom Exp $
+ * $Id: inserts.c,v 1.13 2005/04/16 15:56:42 tom Exp $
  *
  * Demonstrate the winsstr() and winsch functions.
  * Thomas Dickey - 2002/10/19
@@ -7,24 +7,66 @@
 
 #include <test.priv.h>
 
+#define InsNStr    insnstr
+#define InsStr     insstr
+#define MvInsNStr  mvinsnstr
+#define MvInsStr   mvinsstr
+#define MvWInsNStr mvwinsnstr
+#define MvWInsStr  mvwinsstr
+#define WInsNStr   winsnstr
+#define WInsStr    winsstr
+
+#define InsCh      insch
+#define MvInsCh    mvinsch
+#define MvWInsCh   mvwinsch
+#define WInsCh     winsch
+
 #define TABSIZE 8
 
-static int margin = (2 * TABSIZE) - 1;
+typedef enum {
+    oDefault = 0,
+    oMove = 1,
+    oWindow = 2,
+    oMoveWindow = 3
+} Options;
+
+static bool m_opt = FALSE;
+static bool w_opt = FALSE;
+static int n_opt = -1;
 
 static void
-legend(WINDOW *win, char *buffer, int length)
+legend(WINDOW *win, int level, Options state, char *buffer, int length)
 {
+    NCURSES_CONST char *showstate;
+
+    switch (state) {
+    default:
+    case oDefault:
+	showstate = "";
+	break;
+    case oMove:
+	showstate = " (mvXXX)";
+	break;
+    case oWindow:
+	showstate = " (winXXX)";
+	break;
+    case oMoveWindow:
+	showstate = " (mvwinXXX)";
+	break;
+    }
+
     wmove(win, 0, 0);
     wprintw(win,
-	    "The Strings/Chars displays should match.  Enter any characters.\n");
+	    "The Strings/Chars displays should match.  Enter any characters, except:\n");
     wprintw(win,
-	    "Use down-arrow or ^N to repeat on the next line, 'q' to exit.\n");
+	    "down-arrow or ^N to repeat on next line, 'w' for inner window, 'q' to exit.\n");
     wclrtoeol(win);
-    wprintw(win, "Inserted %d characters <%s>", length, buffer);
+    wprintw(win, "Level %d,%s inserted %d characters <%s>", level,
+	    showstate, length, buffer);
 }
 
 static int
-ColOf(char *buffer, int length)
+ColOf(char *buffer, int length, int margin)
 {
     int n;
     int result;
@@ -60,33 +102,55 @@
     return result;
 }
 
-int
-main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+#define LEN(n) ((length - (n) > n_opt) ? n_opt : (length - (n)))
+static void
+test_inserts(int level)
 {
+    static bool first = TRUE;
+
     int ch;
     int limit;
     int row = 1;
     int col;
+    int row2, col2;
     int length;
     char buffer[BUFSIZ];
-    WINDOW *work;
-    WINDOW *show;
-
-    putenv("TABSIZE=8");
-    initscr();
-    (void) cbreak();		/* take input chars one at a time, no wait for \n */
-    (void) noecho();		/* don't echo input */
-    keypad(stdscr, TRUE);
+    WINDOW *look = 0;
+    WINDOW *work = 0;
+    WINDOW *show = 0;
+    int margin = (2 * TABSIZE) - 1;
+    Options option = ((m_opt ? oMove : oDefault)
+		      | ((w_opt || (level > 0)) ? oWindow : oDefault));
+
+    if (first) {
+	static char cmd[80];
+	setlocale(LC_ALL, "");
+
+	putenv(strcpy(cmd, "TABSIZE=8"));
+
+	initscr();
+	(void) cbreak();	/* take input chars one at a time, no wait for \n */
+	(void) noecho();	/* don't echo input */
+	keypad(stdscr, TRUE);
+    }
 
     limit = LINES - 5;
-    work = newwin(limit, COLS, 0, 0);
-    show = newwin(4, COLS, limit + 1, 0);
+    if (level > 0) {
+	look = newwin(limit, COLS - (2 * (level - 1)), 0, level - 1);
+	work = newwin(limit - 2, COLS - (2 * level), 1, level);
+	show = newwin(4, COLS, limit + 1, 0);
+	box(look, 0, 0);
+	wnoutrefresh(look);
+	limit -= 2;
+    } else {
+	work = stdscr;
+	show = derwin(stdscr, 4, COLS, limit + 1, 0);
+    }
     keypad(work, TRUE);
 
     for (col = margin + 1; col < COLS; col += TABSIZE)
 	mvwvline(work, row, col, '.', limit - 2);
 
-    box(work, 0, 0);
     mvwvline(work, row, margin, ACS_VLINE, limit - 2);
     mvwvline(work, row, margin + 1, ACS_VLINE, limit - 2);
     limit /= 2;
@@ -96,7 +160,7 @@
     wnoutrefresh(work);
 
     buffer[length = 0] = '\0';
-    legend(show, buffer, length);
+    legend(show, level, option, buffer, length);
     wnoutrefresh(show);
 
     doupdate();
@@ -112,18 +176,104 @@
     }
 
     while ((ch = wgetch(work)) != 'q') {
+	if (ch == ERR) {
+	    beep();
+	    break;
+	}
 	wmove(work, row, margin + 1);
 	switch (ch) {
+	case 'w':
+	    test_inserts(level + 1);
+
+	    touchwin(look);
+	    touchwin(work);
+	    touchwin(show);
+
+	    wnoutrefresh(look);
+	    wnoutrefresh(work);
+	    wnoutrefresh(show);
+
+	    doupdate();
+	    break;
 	case CTRL('N'):
 	case KEY_DOWN:
 	    if (row < limit) {
 		++row;
 		/* put the whole string in, all at once */
-		mvwinsstr(work, row, margin + 1, buffer);
+		col2 = margin + 1;
+		switch (option) {
+		case oDefault:
+		    if (n_opt > 1) {
+			for (col = 0; col < length; col += n_opt) {
+			    col2 = ColOf(buffer, col, margin);
+			    if (move(row, col2) != ERR) {
+				InsNStr(buffer + col, LEN(col));
+			    }
+			}
+		    } else {
+			if (move(row, col2) != ERR) {
+			    InsStr(buffer);
+			}
+		    }
+		    break;
+		case oMove:
+		    if (n_opt > 1) {
+			for (col = 0; col < length; col += n_opt) {
+			    col2 = ColOf(buffer, col, margin);
+			    MvInsNStr(row, col2, buffer + col, LEN(col));
+			}
+		    } else {
+			MvInsStr(row, col2, buffer);
+		    }
+		    break;
+		case oWindow:
+		    if (n_opt > 1) {
+			for (col = 0; col < length; col += n_opt) {
+			    col2 = ColOf(buffer, col, margin);
+			    if (wmove(work, row, col2) != ERR) {
+				WInsNStr(work, buffer + col, LEN(col));
+			    }
+			}
+		    } else {
+			if (wmove(work, row, col2) != ERR) {
+			    WInsStr(work, buffer);
+			}
+		    }
+		    break;
+		case oMoveWindow:
+		    if (n_opt > 1) {
+			for (col = 0; col < length; col += n_opt) {
+			    col2 = ColOf(buffer, col, margin);
+			    MvWInsNStr(work, row, col2, buffer + col, LEN(col));
+			}
+		    } else {
+			MvWInsStr(work, row, col2, buffer);
+		    }
+		    break;
+		}
 
 		/* do the corresponding single-character insertion */
+		row2 = limit + row;
 		for (col = 0; col < length; ++col) {
-		    mvwinsch(work, limit + row, ColOf(buffer, col), buffer[col]);
+		    col2 = ColOf(buffer, col, margin);
+		    switch (option) {
+		    case oDefault:
+			if (move(row2, col2) != ERR) {
+			    InsCh(UChar(buffer[col]));
+			}
+			break;
+		    case oMove:
+			MvInsCh(row2, col2, UChar(buffer[col]));
+			break;
+		    case oWindow:
+			if (wmove(work, row2, col2) != ERR) {
+			    WInsCh(work, UChar(buffer[col]));
+			}
+			break;
+		    case oMoveWindow:
+			MvWInsCh(work, row2, col2, UChar(buffer[col]));
+			break;
+		    }
 		}
 	    } else {
 		beep();
@@ -139,24 +289,111 @@
 	    }
 	    buffer[length++] = ch;
 	    buffer[length] = '\0';
+
 	    /* put the string in, one character at a time */
-	    mvwinsstr(work,
-		      row,
-		      ColOf(buffer, length - 1), buffer + length - 1);
+	    col = ColOf(buffer, length - 1, margin);
+	    switch (option) {
+	    case oDefault:
+		if (move(row, col) != ERR) {
+		    InsStr(buffer + length - 1);
+		}
+		break;
+	    case oMove:
+		MvInsStr(row, col, buffer + length - 1);
+		break;
+	    case oWindow:
+		if (wmove(work, row, col) != ERR) {
+		    WInsStr(work, buffer + length - 1);
+		}
+		break;
+	    case oMoveWindow:
+		MvWInsStr(work, row, col, buffer + length - 1);
+		break;
+	    }
 
 	    /* do the corresponding single-character insertion */
-	    mvwinsch(work,
-		     limit + row,
-		     ColOf(buffer, length - 1), ch);
+	    switch (option) {
+	    case oDefault:
+		if (move(limit + row, col) != ERR) {
+		    InsCh(UChar(ch));
+		}
+		break;
+	    case oMove:
+		MvInsCh(limit + row, col, UChar(ch));
+		break;
+	    case oWindow:
+		if (wmove(work, limit + row, col) != ERR) {
+		    WInsCh(work, UChar(ch));
+		}
+		break;
+	    case oMoveWindow:
+		MvWInsCh(work, limit + row, col, UChar(ch));
+		break;
+	    }
+
 	    wnoutrefresh(work);
 
-	    legend(show, buffer, length);
+	    legend(show, level, option, buffer, length);
 	    wnoutrefresh(show);
 
 	    doupdate();
 	    break;
 	}
     }
+    if (level > 0) {
+	delwin(show);
+	delwin(work);
+	delwin(look);
+    }
+}
+
+static void
+usage(void)
+{
+    static const char *tbl[] =
+    {
+	"Usage: inserts [options]"
+	,""
+	,"Options:"
+	,"  -n NUM  limit string-inserts to NUM bytes on ^N replay"
+	,"  -m      perform wmove/move separately from insert-functions"
+	,"  -w      use window-parameter even when stdscr would be implied"
+    };
+    unsigned n;
+    for (n = 0; n < SIZEOF(tbl); ++n)
+	fprintf(stderr, "%s\n", tbl[n]);
+    ExitProgram(EXIT_FAILURE);
+}
+
+int
+main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
+{
+    int ch;
+
+    setlocale(LC_ALL, "");
+
+    while ((ch = getopt(argc, argv, "mn:w")) != EOF) {
+	switch (ch) {
+	case 'm':
+	    m_opt = TRUE;
+	    break;
+	case 'n':
+	    n_opt = atoi(optarg);
+	    if (n_opt == 0)
+		n_opt = -1;
+	    break;
+	case 'w':
+	    w_opt = TRUE;
+	    break;
+	default:
+	    usage();
+	    break;
+	}
+    }
+    if (optind < argc)
+	usage();
+
+    test_inserts(0);
     endwin();
     ExitProgram(EXIT_SUCCESS);
 }
diff -Naur ncurses-5.4.orig/test/keynames.c ncurses-5.4/test/keynames.c
--- ncurses-5.4.orig/test/keynames.c	2003-05-17 23:18:49.000000000 +0000
+++ ncurses-5.4/test/keynames.c	2005-05-13 04:09:58.000000000 +0000
@@ -1,5 +1,5 @@
 /*
- * $Id: keynames.c,v 1.5 2003/05/17 23:18:49 tom Exp $
+ * $Id: keynames.c,v 1.7 2005/04/30 20:13:59 tom Exp $
  */
 
 #include <test.priv.h>
@@ -8,7 +8,17 @@
 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 {
     int n;
-    for (n = -1; n < 512; n++) {
+
+    /*
+     * Get the terminfo entry into memory, and tell ncurses that we want to
+     * use function keys.  That will make it add any user-defined keys that
+     * appear in the terminfo.
+     */
+    newterm(getenv("TERM"), stderr, stdin);
+    keypad(stdscr, TRUE);
+    endwin();
+
+    for (n = -1; n < KEY_MAX + 512; n++) {
 	const char *result = keyname(n);
 	if (result != 0)
 	    printf("%d(%5o):%s\n", n, n, result);
diff -Naur ncurses-5.4.orig/test/linux-color.dat ncurses-5.4/test/linux-color.dat
--- ncurses-5.4.orig/test/linux-color.dat	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/test/linux-color.dat	2005-05-13 04:09:51.000000000 +0000
@@ -0,0 +1,21 @@
+# $Id: linux-color.dat,v 1.1 2004/05/22 23:42:45 tom Exp $
+# These values are derived from linux/drivers/char/vt.c (default_red[],
+# default_grn[] and default_blu[]), commented
+/* the default colour table, for VGA+ colour systems */
+scale:255
+0:	  0	  0	  0
+1:	170	  0	  0
+2:	  0	170	  0
+3:	170	 85	  0
+4:	  0	  0	170
+5:	170	  0	170
+6:	  0	170	170
+7:	170	170	170
+8:	 85	 85	 85
+9:	255	 85	 85
+10:	 85	255	 85
+11:	255	255	 85
+12:	 85	 85	255
+13:	255	 85	255
+14:	 85	255	255
+15:	255	255	255
diff -Naur ncurses-5.4.orig/test/lrtest.c ncurses-5.4/test/lrtest.c
--- ncurses-5.4.orig/test/lrtest.c	2002-07-13 16:55:50.000000000 +0000
+++ ncurses-5.4/test/lrtest.c	2005-05-13 04:09:51.000000000 +0000
@@ -2,12 +2,12 @@
  * Test lower-right-hand corner access
  *
  * originally by Eric S. Raymond <esr@thyrsus.com>, written for animation
- * and resizing -TD
+ * and resizing -T.Dickey
  *
  * This can't be part of the ncurses test-program, because ncurses rips off the
  * bottom line to do labels.
  *
- * $Id: lrtest.c,v 1.19 2002/07/13 16:55:50 tom Exp $
+ * $Id: lrtest.c,v 1.20 2004/08/07 16:08:01 tom Exp $
  */
 
 #include <test.priv.h>
@@ -22,7 +22,7 @@
  * really write to all positions properly.
  */
 static void
-show(MARK * m)
+show(MARK *m)
 {
     mvaddch(m->y, m->x, m->value);
     if (m->mode == 0) {		/* along the x-direction */
@@ -120,7 +120,7 @@
 	    else if (ch == 'T')
 		trace(0);
 	    else if (ch == 't')
-		trace(TRACE_CALLS|TRACE_ICALLS|TRACE_UPDATE);
+		trace(TRACE_CALLS | TRACE_ICALLS | TRACE_UPDATE);
 #endif
 #ifdef KEY_RESIZE
 	    else if (ch == KEY_RESIZE) {
diff -Naur ncurses-5.4.orig/test/modules ncurses-5.4/test/modules
--- ncurses-5.4.orig/test/modules	2003-12-07 00:01:23.000000000 +0000
+++ ncurses-5.4/test/modules	2005-05-13 04:09:58.000000000 +0000
@@ -1,7 +1,7 @@
 # Test-Program modules
-# $Id: modules,v 1.20 2003/12/07 00:01:23 tom Exp $
+# $Id: modules,v 1.21 2005/04/30 14:34:52 tom Exp $
 ##############################################################################
-# Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.                #
+# Copyright (c) 1998-2003,2005 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"), #
@@ -42,6 +42,7 @@
 demo_forms	progs		$(srcdir)	../include/form.h
 demo_menus	progs		$(srcdir)	../include/menu.h
 demo_panels	progs		$(srcdir)	../include/panel.h
+demo_termcap	progs		$(srcdir)	../include/termcap.h
 ditto		progs		$(srcdir)
 dots		progs		$(srcdir)	../include/term.h
 edit_field	progs		$(srcdir)
diff -Naur ncurses-5.4.orig/test/ncurses.c ncurses-5.4/test/ncurses.c
--- ncurses-5.4.orig/test/ncurses.c	2004-02-07 20:24:08.000000000 +0000
+++ ncurses-5.4/test/ncurses.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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: Eric S. Raymond <esr@snark.thyrsus.com> 1993
            Thomas E. Dickey (beginning revision 1.27 in 1996).
 
-$Id: ncurses.c,v 1.202 2004/02/07 20:24:08 tom Exp $
+$Id: ncurses.c,v 1.250 2005/04/16 21:14:45 tom Exp $
 
 ***************************************************************************/
 
@@ -70,8 +70,8 @@
 #ifdef NCURSES_VERSION
 
 #ifdef TRACE
-static int save_trace = TRACE_ORDINARY | TRACE_CALLS;
-extern int _nc_tracing;
+static unsigned save_trace = TRACE_ORDINARY | TRACE_CALLS;
+extern unsigned _nc_tracing;
 #endif
 
 #else
@@ -114,10 +114,21 @@
 
 #undef max_colors
 static int max_colors;		/* the actual number of colors we'll use */
+static int min_colors;		/* the minimum color code */
 
 #undef max_pairs
 static int max_pairs;		/* ...and the number of color pairs */
 
+typedef struct {
+    short red;
+    short green;
+    short blue;
+} RGB_DATA;
+
+static RGB_DATA *all_colors;
+
+static void main_menu(bool);
+
 /* The behavior of mvhline, mvvline for negative/zero length is unspecified,
  * though we can rely on negative x/y values to stop the macro.
  */
@@ -135,6 +146,14 @@
 	mvvline(y, x, c, (to) - (y));
 }
 
+static void
+Repaint(void)
+{
+    touchwin(stdscr);
+    touchwin(curscr);
+    wrefresh(curscr);
+}
+
 /* Common function to allow ^T to toggle trace-mode in the middle of a test
  * so that trace-files can be made smaller.
  */
@@ -232,7 +251,7 @@
 
 #if USE_WIDEC_SUPPORT
 static int
-wGet_wchar(WINDOW *win, wint_t * result)
+wGet_wchar(WINDOW *win, wint_t *result)
 {
     int c;
 #ifdef TRACE
@@ -257,11 +276,12 @@
 
 /* replaces wgetn_wstr(), since we want to be able to edit values */
 static void
-wGet_wstring(WINDOW *win, wchar_t * buffer, int limit)
+wGet_wstring(WINDOW *win, wchar_t *buffer, int limit)
 {
     int y0, x0, x;
     wint_t ch;
     bool done = FALSE;
+    bool fkey = FALSE;
 
     echo();
     getyx(win, y0, x0);
@@ -271,32 +291,46 @@
     while (!done) {
 	if (x > (int) wcslen(buffer))
 	    x = (int) wcslen(buffer);
+
+	/* clear the "window' */
+	wmove(win, y0, x0);
+	wprintw(win, "%*s", limit, " ");
+
+	/* write the existing buffer contents */
 	wmove(win, y0, x0);
 	waddnwstr(win, buffer, limit);
-	if (x < limit)
-	    wprintw(win, "%*s", limit - x, " ");
-	wmove(win, y0, x0 + x);
+
+	/* positions the cursor past character 'x' */
+	wmove(win, y0, x0);
+	waddnwstr(win, buffer, x);
+
 	switch (wGet_wchar(win, &ch)) {
 	case KEY_CODE_YES:
+	    fkey = TRUE;
 	    switch (ch) {
 	    case KEY_ENTER:
 		ch = '\n';
+		fkey = FALSE;
 		break;
 	    case KEY_BACKSPACE:
 	    case KEY_DC:
 		ch = '\b';
+		fkey = FALSE;
 		break;
 	    case KEY_LEFT:
 	    case KEY_RIGHT:
 		break;
 	    default:
-		ch = (wint_t) - 1;
+		ch = (wint_t) -1;
 		break;
 	    }
+	    break;
 	case OK:
+	    fkey = FALSE;
 	    break;
 	default:
-	    ch = (wint_t) - 1;
+	    ch = (wint_t) -1;
+	    fkey = TRUE;
 	    break;
 	}
 
@@ -321,14 +355,14 @@
 	    if (x > 0) {
 		--x;
 	    } else {
-		flash();
+		beep();
 	    }
 	    break;
 	case KEY_RIGHT:
 	    ++x;
 	    break;
 	default:
-	    if (!isprint(ch) || ch >= KEY_MIN) {
+	    if (fkey) {
 		beep();
 	    } else if ((int) wcslen(buffer) < limit) {
 		int j;
@@ -337,7 +371,7 @@
 		}
 		buffer[x++] = ch;
 	    } else {
-		flash();
+		beep();
 	    }
 	}
     }
@@ -387,35 +421,57 @@
 		   ep->id, ep->x, ep->y, ep->z, ep->bstate);
 
 #define SHOW(m, s) if ((ep->bstate & m)==m) {strcat(buf,s); strcat(buf, ", ");}
+
     SHOW(BUTTON1_RELEASED, "release-1");
     SHOW(BUTTON1_PRESSED, "press-1");
     SHOW(BUTTON1_CLICKED, "click-1");
     SHOW(BUTTON1_DOUBLE_CLICKED, "doubleclick-1");
     SHOW(BUTTON1_TRIPLE_CLICKED, "tripleclick-1");
+#if NCURSES_MOUSE_VERSION == 1
     SHOW(BUTTON1_RESERVED_EVENT, "reserved-1");
+#endif
+
     SHOW(BUTTON2_RELEASED, "release-2");
     SHOW(BUTTON2_PRESSED, "press-2");
     SHOW(BUTTON2_CLICKED, "click-2");
     SHOW(BUTTON2_DOUBLE_CLICKED, "doubleclick-2");
     SHOW(BUTTON2_TRIPLE_CLICKED, "tripleclick-2");
+#if NCURSES_MOUSE_VERSION == 1
     SHOW(BUTTON2_RESERVED_EVENT, "reserved-2");
+#endif
+
     SHOW(BUTTON3_RELEASED, "release-3");
     SHOW(BUTTON3_PRESSED, "press-3");
     SHOW(BUTTON3_CLICKED, "click-3");
     SHOW(BUTTON3_DOUBLE_CLICKED, "doubleclick-3");
     SHOW(BUTTON3_TRIPLE_CLICKED, "tripleclick-3");
+#if NCURSES_MOUSE_VERSION == 1
     SHOW(BUTTON3_RESERVED_EVENT, "reserved-3");
+#endif
+
     SHOW(BUTTON4_RELEASED, "release-4");
     SHOW(BUTTON4_PRESSED, "press-4");
     SHOW(BUTTON4_CLICKED, "click-4");
     SHOW(BUTTON4_DOUBLE_CLICKED, "doubleclick-4");
     SHOW(BUTTON4_TRIPLE_CLICKED, "tripleclick-4");
+#if NCURSES_MOUSE_VERSION == 1
     SHOW(BUTTON4_RESERVED_EVENT, "reserved-4");
+#endif
+
+#if NCURSES_MOUSE_VERSION == 2
+    SHOW(BUTTON5_RELEASED, "release-5");
+    SHOW(BUTTON5_PRESSED, "press-5");
+    SHOW(BUTTON5_CLICKED, "click-5");
+    SHOW(BUTTON5_DOUBLE_CLICKED, "doubleclick-5");
+    SHOW(BUTTON5_TRIPLE_CLICKED, "tripleclick-5");
+#endif
+
     SHOW(BUTTON_CTRL, "ctrl");
     SHOW(BUTTON_SHIFT, "shift");
     SHOW(BUTTON_ALT, "alt");
     SHOW(ALL_MOUSE_EVENTS, "all-events");
     SHOW(REPORT_MOUSE_POSITION, "position");
+
 #undef SHOW
 
     if (buf[strlen(buf) - 1] == ' ')
@@ -525,7 +581,7 @@
  * Resize both and paint the box in the parent.
  */
 static void
-resize_boxes(int level, WINDOW *win)
+resize_boxes(unsigned level, WINDOW *win)
 {
     unsigned n;
     int base = 5;
@@ -540,7 +596,7 @@
     slk_clear();
     slk_noutrefresh();
 
-    for (n = 0; (int) n < level; ++n) {
+    for (n = 0; n < level; ++n) {
 	wresize(winstack[n].frame, high, wide);
 	wresize(winstack[n].text, high - 2, wide - 2);
 	high -= 2;
@@ -563,7 +619,7 @@
 #endif
 
 static void
-wgetch_test(int level, WINDOW *win, int delay)
+wgetch_test(unsigned level, WINDOW *win, int delay)
 {
     char buf[BUFSIZ];
     int first_y, first_x;
@@ -674,9 +730,9 @@
 #endif
 		(void) waddstr(win, keyname(c));
 	    } else if (c > 0x80) {
-		int c2 = (c & 0x7f);
+		unsigned c2 = (c & 0x7f);
 		if (isprint(c2))
-		    (void) wprintw(win, "M-%c", c2);
+		    (void) wprintw(win, "M-%c", UChar(c2));
 		else
 		    (void) wprintw(win, "M-%s", unctrl(c2));
 		waddstr(win, " (high-half character)");
@@ -685,7 +741,7 @@
 		    (void) wprintw(win, "%c (ASCII printable character)", c);
 		else
 		    (void) wprintw(win, "%s (ASCII control character)",
-				   unctrl(c));
+				   unctrl(UChar(c)));
 	    }
 	    wgetch_wrap(win, first_y);
 	}
@@ -749,7 +805,7 @@
  */
 #ifdef KEY_RESIZE
 static void
-resize_wide_boxes(int level, WINDOW *win)
+resize_wide_boxes(unsigned level, WINDOW *win)
 {
     unsigned n;
     int base = 5;
@@ -764,7 +820,7 @@
     slk_clear();
     slk_noutrefresh();
 
-    for (n = 0; (int) n < level; ++n) {
+    for (n = 0; n < level; ++n) {
 	wresize(winstack[n].frame, high, wide);
 	wresize(winstack[n].text, high - 2, wide - 2);
 	high -= 2;
@@ -785,7 +841,7 @@
 #endif /* KEY_RESIZE */
 
 static char *
-wcstos(const wchar_t * src)
+wcstos(const wchar_t *src)
 {
     int need;
     mbstate_t state;
@@ -794,9 +850,10 @@
 
     memset(&state, 0, sizeof(state));
     if ((need = wcsrtombs(0, &tmp, 0, &state)) > 0) {
-	result = (char *) calloc(need + 1, 1);
+	unsigned have = need;
+	result = (char *) calloc(have + 1, 1);
 	tmp = src;
-	if (wcsrtombs(result, &tmp, need, &state) != (size_t) need) {
+	if (wcsrtombs(result, &tmp, have, &state) != have) {
 	    free(result);
 	    result = 0;
 	}
@@ -805,9 +862,10 @@
 }
 
 static void
-wget_wch_test(int level, WINDOW *win, int delay)
+wget_wch_test(unsigned level, WINDOW *win, int delay)
 {
-    wchar_t buf[BUFSIZ];
+    wchar_t wchar_buf[BUFSIZ];
+    wint_t wint_buf[BUFSIZ];
     int first_y, first_x;
     wint_t c;
     int incount = 0;
@@ -850,13 +908,21 @@
 	} else if (c == 'g') {
 	    waddstr(win, "getstr test: ");
 	    echo();
-	    wgetn_wstr(win, (wint_t *) buf, sizeof(buf) - 1);
+	    code = wgetn_wstr(win, wint_buf, sizeof(wint_buf) - 1);
 	    noecho();
-	    if ((temp = wcstos(buf)) != 0) {
-		wprintw(win, "I saw %d characters:\n\t`%s'.", wcslen(buf), temp);
-		free(temp);
+	    if (code == ERR) {
+		wprintw(win, "wgetn_wstr returns an error.");
 	    } else {
-		wprintw(win, "I saw %d characters (cannot convert).", wcslen(buf));
+		int n;
+		for (n = 0; (wchar_buf[n] = wint_buf[n]) != 0; ++n) ;
+		if ((temp = wcstos(wchar_buf)) != 0) {
+		    wprintw(win, "I saw %d characters:\n\t`%s'.",
+			    wcslen(wchar_buf), temp);
+		    free(temp);
+		} else {
+		    wprintw(win, "I saw %d characters (cannot convert).",
+			    wcslen(wchar_buf));
+		}
 	    }
 	    wclrtoeol(win);
 	    wgetch_wrap(win, first_y);
@@ -919,7 +985,7 @@
 		    resize_wide_boxes(level, win);
 		}
 #endif
-		(void) waddstr(win, key_name(c));
+		(void) waddstr(win, key_name((wchar_t) c));
 	    } else {
 		if (c < 256 && iscntrl(c)) {
 		    (void) wprintw(win, "%s (control character)", unctrl(c));
@@ -954,7 +1020,99 @@
 #define MAX_ATTRSTRING 31
 #define LEN_ATTRSTRING 26
 
-static char attr_test_string[] = "abcde fghij klmno pqrst uvwxy z";
+static char attr_test_string[MAX_ATTRSTRING + 1];
+
+static void
+attr_legend(WINDOW *helpwin)
+{
+    int row = 1;
+    int col = 1;
+
+    mvwprintw(helpwin, row++, col,
+	      "q or ESC to exit.");
+    mvwprintw(helpwin, row++, col,
+	      "^L repaints.");
+    ++row;
+    mvwprintw(helpwin, row++, col,
+	      "Modify the test strings:");
+    mvwprintw(helpwin, row++, col,
+	      "  A digit sets gaps on each side of displayed attributes");
+    mvwprintw(helpwin, row++, col,
+	      "  </> shifts the text left/right. ");
+    ++row;
+    mvwprintw(helpwin, row++, col,
+	      "Toggles:");
+    if (has_colors()) {
+	mvwprintw(helpwin, row++, col,
+		  "  f/F/b/F toggle foreground/background background color");
+	mvwprintw(helpwin, row++, col,
+		  "  t/T     toggle text/background color attribute");
+    }
+    mvwprintw(helpwin, row++, col,
+	      "  a/A     toggle ACS (alternate character set) mapping");
+    mvwprintw(helpwin, row++, col,
+	      "  v/V     toggle video attribute to combine with each line");
+}
+
+static void
+show_color_attr(int fg, int bg, int tx)
+{
+    if (has_colors()) {
+	printw("  Colors (fg %d, bg %d", fg, bg);
+	if (tx >= 0)
+	    printw(", text %d", tx);
+	printw("),");
+    }
+}
+
+static bool
+cycle_color_attr(int ch, int *fg, int *bg, int *tx)
+{
+    bool error = FALSE;
+
+    if (has_colors()) {
+	switch (ch) {
+	case 'f':
+	    *fg = (*fg + 1);
+	    break;
+	case 'F':
+	    *fg = (*fg - 1);
+	    break;
+	case 'b':
+	    *bg = (*bg + 1);
+	    break;
+	case 'B':
+	    *bg = (*bg - 1);
+	    break;
+	case 't':
+	    *tx = (*tx + 1);
+	    break;
+	case 'T':
+	    *tx = (*tx - 1);
+	    break;
+	default:
+	    beep();
+	    error = TRUE;
+	    break;
+	}
+	if (*fg >= COLORS)
+	    *fg = min_colors;
+	if (*fg < min_colors)
+	    *fg = COLORS - 1;
+	if (*bg >= COLORS)
+	    *bg = min_colors;
+	if (*bg < min_colors)
+	    *bg = COLORS - 1;
+	if (*tx >= COLORS)
+	    *tx = -1;
+	if (*tx < -1)
+	    *tx = COLORS - 1;
+    } else {
+	beep();
+	error = TRUE;
+    }
+    return error;
+}
 
 static void
 adjust_attr_string(int adjust)
@@ -964,7 +1122,7 @@
 
     if (first >= ' ' && last <= '~') {	/* 32..126 */
 	int j, k;
-	for (j = 0, k = first; k <= last; ++j, ++k) {
+	for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
 	    attr_test_string[j] = k;
 	    if (((k + 1 - first) % 5) == 0) {
 		++j;
@@ -980,132 +1138,158 @@
     }
 }
 
+static void
+init_attr_string(void)
+{
+    attr_test_string[0] = 'a';
+    adjust_attr_string(0);
+}
+
 static int
-show_attr(int row, int skip, chtype attr, const char *name)
+show_attr(int row, int skip, bool arrow, chtype attr, const char *name)
 {
     int ncv = tigetnum("ncv");
     chtype test = attr & ~A_ALTCHARSET;
 
+    if (arrow)
+	mvprintw(row, 5, "-->");
     mvprintw(row, 8, "%s mode:", name);
     mvprintw(row, 24, "|");
     if (skip)
 	printw("%*s", skip, " ");
-    attrset(attr);
     /*
-     * If we're to write a string in the alternate character set, it is not
-     * sufficient to just set A_ALTCHARSET.  We have to perform the mapping
-     * that corresponds.  This is not needed for vt100-compatible devices
-     * because the acs_map[] is 1:1, but for PC-style devices such as Linux
-     * console, the acs_map[] is scattered about the range.
-     *
-     * The addch/addstr functions do not themselves do this mapping, since it
-     * is possible to turn off the A_ALTCHARSET flag for the characters which
-     * are added, and it would be an unexpected result to have the mapped
-     * characters visible on the screen.
+     * Just for testing, write text using the alternate character set one
+     * character at a time (to pass its rendition directly), and use the
+     * string operation for the other attributes.
      */
     if (attr & A_ALTCHARSET) {
 	const char *s;
-	int ch;
+	chtype ch;
 
 	for (s = attr_test_string; *s != '\0'; ++s) {
 	    ch = UChar(*s);
-	    addch(ch);
+	    addch(ch | attr);
 	}
     } else {
+	attrset(attr);
 	addstr(attr_test_string);
+	attroff(attr);
     }
-    attroff(attr);
     if (skip)
 	printw("%*s", skip, " ");
     printw("|");
     if (test != A_NORMAL) {
 	if (!(termattrs() & test)) {
 	    printw(" (N/A)");
-	} else if (ncv > 0 && (getbkgd(stdscr) & A_COLOR)) {
-	    static const chtype table[] =
-	    {
-		A_STANDOUT,
-		A_UNDERLINE,
-		A_REVERSE,
-		A_BLINK,
-		A_DIM,
-		A_BOLD,
-		A_INVIS,
-		A_PROTECT,
-		A_ALTCHARSET
-	    };
-	    unsigned n;
-	    bool found = FALSE;
-	    for (n = 0; n < SIZEOF(table); n++) {
-		if ((table[n] & attr) != 0
-		    && ((1 << n) & ncv) != 0) {
-		    found = TRUE;
-		    break;
+	} else {
+	    if (ncv > 0 && (getbkgd(stdscr) & A_COLOR)) {
+		static const chtype table[] =
+		{
+		    A_STANDOUT,
+		    A_UNDERLINE,
+		    A_REVERSE,
+		    A_BLINK,
+		    A_DIM,
+		    A_BOLD,
+		    A_INVIS,
+		    A_PROTECT,
+		    A_ALTCHARSET
+		};
+		unsigned n;
+		bool found = FALSE;
+		for (n = 0; n < SIZEOF(table); n++) {
+		    if ((table[n] & attr) != 0
+			&& ((1 << n) & ncv) != 0) {
+			found = TRUE;
+			break;
+		    }
 		}
+		if (found)
+		    printw(" (NCV)");
 	    }
-	    if (found)
-		printw(" (NCV)");
+	    if ((termattrs() & test) != test)
+		printw(" (Part)");
 	}
     }
     return row + 2;
 }
+/* *INDENT-OFF* */
+static const struct {
+    attr_t			attr;
+    NCURSES_CONST char *	name;
+} attrs_to_test[] = {
+    { A_STANDOUT,	"STANDOUT" },
+    { A_REVERSE,	"REVERSE" },
+    { A_BOLD,		"BOLD" },
+    { A_UNDERLINE,	"UNDERLINE" },
+    { A_DIM,		"DIM" },
+    { A_BLINK,		"BLINK" },
+    { A_PROTECT,	"PROTECT" },
+    { A_INVIS,		"INVISIBLE" },
+    { A_NORMAL,		"NORMAL" },
+};
+/* *INDENT-ON* */
 
 static bool
-attr_getc(int *skip, int *fg, int *bg, int *ac)
+attr_getc(int *skip, int *fg, int *bg, int *tx, int *ac, unsigned *kc)
 {
-    int ch = Getchar();
+    bool result = TRUE;
+    bool error = FALSE;
+    WINDOW *helpwin;
 
-    if (isdigit(ch)) {
-	*skip = (ch - '0');
-    } else if (ch == CTRL('L')) {
-	touchwin(stdscr);
-	touchwin(curscr);
-	wrefresh(curscr);
-    } else {
-	switch (ch) {
-	case 'a':
-	    *ac = 0;
-	    break;
-	case 'A':
-	    *ac = A_ALTCHARSET;
-	    break;
-	case '<':
-	    adjust_attr_string(-1);
-	    break;
-	case '>':
-	    adjust_attr_string(1);
-	    break;
-	default:
-	    if (has_colors()) {
-		switch (ch) {
-		case 'f':
-		    *fg = (*fg + 1);
-		    break;
-		case 'F':
-		    *fg = (*fg - 1);
-		    break;
-		case 'b':
-		    *bg = (*bg + 1);
-		    break;
-		case 'B':
-		    *bg = (*bg - 1);
-		    break;
-		default:
-		    return FALSE;
+    do {
+	int ch = Getchar();
+
+	error = FALSE;
+	if (ch < 256 && isdigit(ch)) {
+	    *skip = (ch - '0');
+	} else {
+	    switch (ch) {
+	    case CTRL('L'):
+		Repaint();
+		break;
+	    case '?':
+		if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
+		    box(helpwin, 0, 0);
+		    attr_legend(helpwin);
+		    wGetchar(helpwin);
+		    delwin(helpwin);
 		}
-		if (*fg >= max_colors)
-		    *fg = 0;
-		if (*fg < 0)
-		    *fg = max_colors - 1;
-		if (*bg >= max_colors)
-		    *bg = 0;
-		if (*bg < 0)
-		    *bg = max_colors - 1;
+		break;
+	    case 'a':
+		*ac = 0;
+		break;
+	    case 'A':
+		*ac = A_ALTCHARSET;
+		break;
+	    case 'v':
+		if (*kc == 0)
+		    *kc = SIZEOF(attrs_to_test) - 1;
+		else
+		    *kc -= 1;
+		break;
+	    case 'V':
+		*kc += 1;
+		if (*kc >= SIZEOF(attrs_to_test))
+		    *kc = 0;
+		break;
+	    case '<':
+		adjust_attr_string(-1);
+		break;
+	    case '>':
+		adjust_attr_string(1);
+		break;
+	    case 'q':
+	    case ESCAPE:
+		result = FALSE;
+		break;
+	    default:
+		error = cycle_color_attr(ch, fg, bg, tx);
+		break;
 	    }
-	    break;
 	}
-    }
-    return TRUE;
+    } while (error);
+    return result;
 }
 
 static void
@@ -1116,26 +1300,40 @@
     int skip = tigetnum("xmc");
     int fg = COLOR_BLACK;	/* color pair 0 is special */
     int bg = COLOR_BLACK;
+    int tx = -1;
     int ac = 0;
-    bool *pairs = (bool *) calloc(max_pairs, sizeof(bool));
-    pairs[0] = TRUE;
+    unsigned j, k;
 
     if (skip < 0)
 	skip = 0;
 
     n = skip;			/* make it easy */
+    k = SIZEOF(attrs_to_test) - 1;
+    init_attr_string();
 
     do {
 	int row = 2;
-	int normal = A_NORMAL | BLANK;
+	chtype normal = A_NORMAL | BLANK;
+	chtype extras = ac;
 
 	if (has_colors()) {
-	    int pair = (fg * max_colors) + bg;
-	    if (!pairs[pair]) {
-		init_pair(pair, fg, bg);
-		pairs[pair] = TRUE;
+	    int pair = (fg != COLOR_BLACK || bg != COLOR_BLACK);
+	    if (pair != 0) {
+		pair = 1;
+		if (init_pair(pair, fg, bg) == ERR) {
+		    beep();
+		} else {
+		    normal |= COLOR_PAIR(pair);
+		}
+	    }
+	    if (tx >= 0) {
+		pair = 2;
+		if (init_pair(pair, tx, bg) == ERR) {
+		    beep();
+		} else {
+		    extras |= COLOR_PAIR(pair);
+		}
 	    }
-	    normal |= COLOR_PAIR(pair);
 	}
 	bkgd(normal);
 	bkgdset(normal);
@@ -1144,38 +1342,303 @@
 	box(stdscr, 0, 0);
 	mvaddstr(0, 20, "Character attribute test display");
 
-	row = show_attr(row, n, ac | A_STANDOUT, "STANDOUT");
-	row = show_attr(row, n, ac | A_REVERSE, "REVERSE");
-	row = show_attr(row, n, ac | A_BOLD, "BOLD");
-	row = show_attr(row, n, ac | A_UNDERLINE, "UNDERLINE");
-	row = show_attr(row, n, ac | A_DIM, "DIM");
-	row = show_attr(row, n, ac | A_BLINK, "BLINK");
-	row = show_attr(row, n, ac | A_PROTECT, "PROTECT");
-	row = show_attr(row, n, ac | A_INVIS, "INVISIBLE");
-	row = show_attr(row, n, ac | A_NORMAL, "NORMAL");
+	for (j = 0; j < SIZEOF(attrs_to_test); ++j) {
+	    row = show_attr(row, n, j == k,
+			    extras |
+			    attrs_to_test[j].attr |
+			    attrs_to_test[k].attr,
+			    attrs_to_test[j].name);
+	}
 
 	mvprintw(row, 8,
 		 "This terminal does %shave the magic-cookie glitch",
 		 tigetnum("xmc") > -1 ? "" : "not ");
-	mvprintw(row + 1, 8,
-		 "Enter a digit to set gaps on each side of displayed attributes");
-	mvprintw(row + 2, 8,
-		 "^L repaints, </> shifts, ");
-	if (has_colors())
-	    printw("f/F/b/F toggle color (now %d/%d), a/A ACS (%d)",
-		   fg, bg, ac != 0);
-	else
-	    printw("a/A ACS (%d)", ac != 0);
+	mvprintw(row + 1, 8, "Enter '?' for help.");
+	show_color_attr(fg, bg, tx);
+	printw("  ACS (%d)", ac != 0);
 
 	refresh();
-    } while (attr_getc(&n, &fg, &bg, &ac));
+    } while (attr_getc(&n, &fg, &bg, &tx, &ac, &k));
 
-    free((char *) pairs);
     bkgdset(A_NORMAL | BLANK);
     erase();
     endwin();
 }
 
+#if USE_WIDEC_SUPPORT
+static wchar_t wide_attr_test_string[MAX_ATTRSTRING + 1];
+
+static void
+wide_adjust_attr_string(int adjust)
+{
+    int first = ((int) UChar(wide_attr_test_string[0])) + adjust;
+    int last = first + LEN_ATTRSTRING;
+
+    if (first >= ' ' && last <= '~') {	/* 32..126 */
+	int j, k;
+	for (j = 0, k = first; j < MAX_ATTRSTRING && k <= last; ++j, ++k) {
+	    wide_attr_test_string[j] = k;
+	    if (((k + 1 - first) % 5) == 0) {
+		++j;
+		if (j < MAX_ATTRSTRING)
+		    wide_attr_test_string[j] = ' ';
+	    }
+	}
+	while (j < MAX_ATTRSTRING)
+	    wide_attr_test_string[j++] = ' ';
+	wide_attr_test_string[j] = '\0';
+    } else {
+	beep();
+    }
+}
+
+static void
+wide_init_attr_string(void)
+{
+    wide_attr_test_string[0] = 'a';
+    wide_adjust_attr_string(0);
+}
+
+static void
+set_wide_background(short pair)
+{
+    cchar_t normal;
+    wchar_t blank[2];
+
+    blank[0] = ' ';
+    blank[1] = 0;
+    setcchar(&normal, blank, A_NORMAL, pair, 0);
+    bkgrnd(&normal);
+    bkgrndset(&normal);
+}
+
+static attr_t
+get_wide_background(void)
+{
+    attr_t result = A_NORMAL;
+    attr_t attr;
+    cchar_t ch;
+    short pair;
+    wchar_t wch;
+
+    if (getbkgrnd(&ch) != ERR) {
+	if (getcchar(&ch, &wch, &attr, &pair, 0) != ERR) {
+	    result = attr;
+	}
+    }
+    return result;
+}
+
+static int
+wide_show_attr(int row, int skip, bool arrow, chtype attr, short pair, const char *name)
+{
+    int ncv = tigetnum("ncv");
+    chtype test = attr & ~WA_ALTCHARSET;
+
+    if (arrow)
+	mvprintw(row, 5, "-->");
+    mvprintw(row, 8, "%s mode:", name);
+    mvprintw(row, 24, "|");
+    if (skip)
+	printw("%*s", skip, " ");
+
+    /*
+     * Just for testing, write text using the alternate character set one
+     * character at a time (to pass its rendition directly), and use the
+     * string operation for the other attributes.
+     */
+    if (attr & WA_ALTCHARSET) {
+	const wchar_t *s;
+	cchar_t ch;
+
+	for (s = wide_attr_test_string; *s != L'\0'; ++s) {
+	    wchar_t fill[2];
+	    fill[0] = *s;
+	    fill[1] = L'\0';
+	    setcchar(&ch, fill, attr, pair, 0);
+	    add_wch(&ch);
+	}
+    } else {
+	attr_t old_attr;
+	short old_pair;
+
+	attr_get(&old_attr, &old_pair, 0);
+	attr_set(attr, pair, 0);
+	addwstr(wide_attr_test_string);
+	attr_set(old_attr, old_pair, 0);
+    }
+    if (skip)
+	printw("%*s", skip, " ");
+    printw("|");
+    if (test != A_NORMAL) {
+	if (!(term_attrs() & test)) {
+	    printw(" (N/A)");
+	} else {
+	    if (ncv > 0 && (get_wide_background() & A_COLOR)) {
+		static const attr_t table[] =
+		{
+		    WA_STANDOUT,
+		    WA_UNDERLINE,
+		    WA_REVERSE,
+		    WA_BLINK,
+		    WA_DIM,
+		    WA_BOLD,
+		    WA_INVIS,
+		    WA_PROTECT,
+		    WA_ALTCHARSET
+		};
+		unsigned n;
+		bool found = FALSE;
+		for (n = 0; n < SIZEOF(table); n++) {
+		    if ((table[n] & attr) != 0
+			&& ((1 << n) & ncv) != 0) {
+			found = TRUE;
+			break;
+		    }
+		}
+		if (found)
+		    printw(" (NCV)");
+	    }
+	    if ((term_attrs() & test) != test)
+		printw(" (Part)");
+	}
+    }
+    return row + 2;
+}
+
+static bool
+wide_attr_getc(int *skip, int *fg, int *bg, int *tx, int *ac, unsigned *kc)
+{
+    bool result = TRUE;
+    bool error = FALSE;
+    WINDOW *helpwin;
+
+    do {
+	int ch = Getchar();
+
+	error = FALSE;
+	if (ch < 256 && isdigit(ch)) {
+	    *skip = (ch - '0');
+	} else {
+	    switch (ch) {
+	    case CTRL('L'):
+		Repaint();
+		break;
+	    case '?':
+		if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
+		    box_set(helpwin, 0, 0);
+		    attr_legend(helpwin);
+		    wGetchar(helpwin);
+		    delwin(helpwin);
+		}
+		break;
+	    case 'a':
+		*ac = 0;
+		break;
+	    case 'A':
+		*ac = A_ALTCHARSET;
+		break;
+	    case 'v':
+		if (*kc == 0)
+		    *kc = SIZEOF(attrs_to_test) - 1;
+		else
+		    *kc -= 1;
+		break;
+	    case 'V':
+		*kc += 1;
+		if (*kc >= SIZEOF(attrs_to_test))
+		    *kc = 0;
+		break;
+	    case '<':
+		wide_adjust_attr_string(-1);
+		break;
+	    case '>':
+		wide_adjust_attr_string(1);
+		break;
+	    case 'q':
+	    case ESCAPE:
+		result = FALSE;
+		break;
+	    default:
+		error = cycle_color_attr(ch, fg, bg, tx);
+		break;
+	    }
+	}
+    } while (error);
+    return result;
+}
+
+static void
+wide_attr_test(void)
+/* test text attributes using wide-character calls */
+{
+    int n;
+    int skip = tigetnum("xmc");
+    int fg = COLOR_BLACK;	/* color pair 0 is special */
+    int bg = COLOR_BLACK;
+    int tx = -1;
+    int ac = 0;
+    unsigned j, k;
+
+    if (skip < 0)
+	skip = 0;
+
+    n = skip;			/* make it easy */
+    k = SIZEOF(attrs_to_test) - 1;
+    wide_init_attr_string();
+
+    do {
+	int row = 2;
+	short pair = 0;
+	short extras = 0;
+
+	if (has_colors()) {
+	    pair = (fg != COLOR_BLACK || bg != COLOR_BLACK);
+	    if (pair != 0) {
+		pair = 1;
+		if (init_pair(pair, fg, bg) == ERR) {
+		    beep();
+		}
+	    }
+	    extras = pair;
+	    if (tx >= 0) {
+		extras = 2;
+		if (init_pair(extras, tx, bg) == ERR) {
+		    beep();
+		}
+	    }
+	}
+	set_wide_background(pair);
+	erase();
+
+	box_set(stdscr, 0, 0);
+	mvaddstr(0, 20, "Character attribute test display");
+
+	for (j = 0; j < SIZEOF(attrs_to_test); ++j) {
+	    row = wide_show_attr(row, n, j == k,
+				 ac |
+				 attrs_to_test[j].attr |
+				 attrs_to_test[k].attr,
+				 extras,
+				 attrs_to_test[j].name);
+	}
+
+	mvprintw(row, 8,
+		 "This terminal does %shave the magic-cookie glitch",
+		 tigetnum("xmc") > -1 ? "" : "not ");
+	mvprintw(row + 1, 8, "Enter '?' for help.");
+	show_color_attr(fg, bg, tx);
+	printw("  ACS (%d)", ac != 0);
+
+	refresh();
+    } while (wide_attr_getc(&n, &fg, &bg, &tx, &ac, &k));
+
+    set_wide_background(0);
+    erase();
+    endwin();
+}
+#endif
+
 /****************************************************************************
  *
  * Color support tests
@@ -1203,55 +1666,378 @@
 };
 
 static void
-show_color_name(int y, int x, int color)
+show_color_name(int y, int x, int color, bool wide)
 {
-    if (max_colors > 8)
-	mvprintw(y, x, "%02d   ", color);
-    else
-	mvaddstr(y, x, the_color_names[color]);
+    if (move(y, x) != ERR) {
+	char temp[80];
+	int width = 8;
+
+	if (wide) {
+	    sprintf(temp, "%02d", color);
+	    width = 4;
+	} else if (color >= 8) {
+	    sprintf(temp, "[%02d]", color);
+	} else {
+	    strcpy(temp, the_color_names[color]);
+	}
+	printw("%-*.*s", width, width, temp);
+    }
+}
+
+static void
+color_legend(WINDOW *helpwin)
+{
+    int row = 1;
+    int col = 1;
+
+    mvwprintw(helpwin, row++, col,
+	      "q or ESC to exit.");
+    ++row;
+    mvwprintw(helpwin, row++, col,
+	      "Use up/down arrow to scroll through the display if it is");
+    mvwprintw(helpwin, row++, col,
+	      "longer than one screen. Control/N and Control/P can be used");
+    mvwprintw(helpwin, row++, col,
+	      "in place up up/down arrow.  Use pageup/pagedown to scroll a");
+    mvwprintw(helpwin, row++, col,
+	      "full screen; control/B and control/F can be used here.");
+    ++row;
+    mvwprintw(helpwin, row++, col,
+	      "Toggles:");
+    mvwprintw(helpwin, row++, col,
+	      "  b/B     toggle bold off/on");
+    mvwprintw(helpwin, row++, col,
+	      "  n/N     toggle text/number on/off");
+    mvwprintw(helpwin, row++, col,
+	      "  w/W     toggle width between 8/16 colors");
 }
 
+#define set_color_test(name, value) if (name != value) { name = value; base_row = 0; }
+
+/* generate a color test pattern */
 static void
 color_test(void)
+{
+    int c;
+    int i;
+    int top = 0, width;
+    int base_row = 0;
+    int grid_top = top + 3;
+    int page_size = (LINES - grid_top);
+    int pairs_max = PAIR_NUMBER(A_COLOR) + 1;
+    int row_limit;
+    int per_row;
+    char numbered[80];
+    const char *hello;
+    bool done = FALSE;
+    bool opt_bold = FALSE;
+    bool opt_wide = FALSE;
+    bool opt_nums = FALSE;
+    WINDOW *helpwin;
+
+    if (pairs_max > COLOR_PAIRS)
+	pairs_max = COLOR_PAIRS;
+
+    while (!done) {
+	int shown = 0;
+
+	/* this assumes an 80-column line */
+	if (opt_wide) {
+	    width = 4;
+	    hello = "Test";
+	    per_row = (COLORS > 8) ? 16 : 8;
+	} else {
+	    width = 8;
+	    hello = "Hello";
+	    per_row = 8;
+	}
+
+	row_limit = (pairs_max + per_row - 1) / per_row;
+
+	move(0, 0);
+	(void) printw("There are %d color pairs and %d colors\n",
+		      pairs_max, COLORS);
+
+	clrtobot();
+	(void) mvprintw(top + 1, 0,
+			"%dx%d matrix of foreground/background colors, bold *%s*\n",
+			row_limit,
+			per_row,
+			opt_bold ? "on" : "off");
+
+	/* show color names/numbers across the top */
+	for (i = 0; i < per_row; i++)
+	    show_color_name(top + 2, (i + 1) * width, i, opt_wide);
+
+	/* show a grid of colors, with color names/ numbers on the left */
+	for (i = (base_row * per_row); i < pairs_max; i++) {
+	    int row = grid_top + (i / per_row) - base_row;
+	    int col = (i % per_row + 1) * width;
+	    int pair = i;
+
+	    if (row >= 0 && move(row, col) != ERR) {
+		init_pair(pair, i % COLORS, i / COLORS);
+		attron((attr_t) COLOR_PAIR(pair));
+		if (opt_bold)
+		    attron((attr_t) A_BOLD);
+
+		if (opt_nums) {
+		    sprintf(numbered, "{%02X}", i);
+		    hello = numbered;
+		}
+		printw("%-*.*s", width, width, hello);
+		attrset(A_NORMAL);
+
+		if ((i % per_row) == 0 && (i % COLORS) == 0) {
+		    show_color_name(row, 0, i / COLORS, opt_wide);
+		}
+		++shown;
+	    } else if (shown) {
+		break;
+	    }
+	}
+
+	switch (c = wGetchar(stdscr)) {
+	case 'b':
+	    opt_bold = FALSE;
+	    break;
+	case 'B':
+	    opt_bold = TRUE;
+	    break;
+	case 'n':
+	    opt_nums = FALSE;
+	    break;
+	case 'N':
+	    opt_nums = TRUE;
+	    break;
+	case ESCAPE:
+	case 'q':
+	    done = TRUE;
+	    continue;
+	case 'w':
+	    set_color_test(opt_wide, FALSE);
+	    break;
+	case 'W':
+	    set_color_test(opt_wide, TRUE);
+	    break;
+	case CTRL('p'):
+	case KEY_UP:
+	    if (base_row <= 0) {
+		beep();
+	    } else {
+		base_row -= 1;
+	    }
+	    break;
+	case CTRL('n'):
+	case KEY_DOWN:
+	    if (base_row + page_size >= row_limit) {
+		beep();
+	    } else {
+		base_row += 1;
+	    }
+	    break;
+	case CTRL('b'):
+	case KEY_PREVIOUS:
+	case KEY_PPAGE:
+	    if (base_row <= 0) {
+		beep();
+	    } else {
+		base_row -= (page_size - 1);
+		if (base_row < 0)
+		    base_row = 0;
+	    }
+	    break;
+	case CTRL('f'):
+	case KEY_NEXT:
+	case KEY_NPAGE:
+	    if (base_row + page_size >= row_limit) {
+		beep();
+	    } else {
+		base_row += page_size - 1;
+		if (base_row + page_size >= row_limit) {
+		    base_row = row_limit - page_size - 1;
+		}
+	    }
+	    break;
+	case '?':
+	    if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
+		box(helpwin, 0, 0);
+		color_legend(helpwin);
+		wGetchar(helpwin);
+		delwin(helpwin);
+	    }
+	    break;
+	default:
+	    beep();
+	    continue;
+	}
+    }
+
+    erase();
+    endwin();
+}
+
+#if USE_WIDEC_SUPPORT
 /* generate a color test pattern */
+static void
+wide_color_test(void)
 {
+    int c;
     int i;
-    int base, top, width;
+    int top = 0, width;
+    int base_row = 0;
+    int grid_top = top + 3;
+    int page_size = (LINES - grid_top);
+    int pairs_max = COLOR_PAIRS;
+    int row_limit;
+    int per_row;
+    char numbered[80];
     const char *hello;
+    bool done = FALSE;
+    bool opt_bold = FALSE;
+    bool opt_wide = FALSE;
+    bool opt_nums = FALSE;
+    WINDOW *helpwin;
 
-    refresh();
-    (void) printw("There are %d color pairs\n", COLOR_PAIRS);
+    while (!done) {
+	int shown = 0;
+
+	/* this assumes an 80-column line */
+	if (opt_wide) {
+	    width = 4;
+	    hello = "Test";
+	    per_row = (COLORS > 8) ? 16 : 8;
+	} else {
+	    width = 8;
+	    hello = "Hello";
+	    per_row = 8;
+	}
+
+	row_limit = (pairs_max + per_row - 1) / per_row;
 
-    width = (max_colors > 8) ? 4 : 8;
-    hello = (max_colors > 8) ? "Test" : "Hello";
+	move(0, 0);
+	(void) printw("There are %d color pairs and %d colors\n",
+		      pairs_max, COLORS);
 
-    for (base = 0; base < 2; base++) {
-	top = (max_colors > 8) ? 0 : base * (max_colors + 3);
 	clrtobot();
 	(void) mvprintw(top + 1, 0,
-			"%dx%d matrix of foreground/background colors, bright *%s*\n",
-			max_colors, max_colors,
-			base ? "on" : "off");
-	for (i = 0; i < max_colors; i++)
-	    show_color_name(top + 2, (i + 1) * width, i);
-	for (i = 0; i < max_colors; i++)
-	    show_color_name(top + 3 + i, 0, i);
-	for (i = 1; i < max_pairs; i++) {
-	    init_pair(i, i % max_colors, i / max_colors);
-	    attron((attr_t) COLOR_PAIR(i));
-	    if (base)
-		attron((attr_t) A_BOLD);
-	    mvaddstr(top + 3 + (i / max_colors), (i % max_colors + 1) *
-		     width, hello);
-	    attrset(A_NORMAL);
+			"%dx%d matrix of foreground/background colors, bold *%s*\n",
+			row_limit,
+			per_row,
+			opt_bold ? "on" : "off");
+
+	/* show color names/numbers across the top */
+	for (i = 0; i < per_row; i++)
+	    show_color_name(top + 2, (i + 1) * width, i, opt_wide);
+
+	/* show a grid of colors, with color names/ numbers on the left */
+	for (i = (base_row * per_row); i < pairs_max; i++) {
+	    int row = grid_top + (i / per_row) - base_row;
+	    int col = (i % per_row + 1) * width;
+	    int pair = i;
+
+	    if (row >= 0 && move(row, col) != ERR) {
+		init_pair(pair, i % COLORS, i / COLORS);
+		color_set(pair, NULL);
+		if (opt_bold)
+		    attr_on((attr_t) A_BOLD, NULL);
+
+		if (opt_nums) {
+		    sprintf(numbered, "{%02X}", i);
+		    hello = numbered;
+		}
+		printw("%-*.*s", width, width, hello);
+		attr_set(A_NORMAL, 0, NULL);
+
+		if ((i % per_row) == 0 && (i % COLORS) == 0) {
+		    show_color_name(row, 0, i / COLORS, opt_wide);
+		}
+		++shown;
+	    } else if (shown) {
+		break;
+	    }
+	}
+
+	switch (c = wGetchar(stdscr)) {
+	case 'b':
+	    opt_bold = FALSE;
+	    break;
+	case 'B':
+	    opt_bold = TRUE;
+	    break;
+	case 'n':
+	    opt_nums = FALSE;
+	    break;
+	case 'N':
+	    opt_nums = TRUE;
+	    break;
+	case ESCAPE:
+	case 'q':
+	    done = TRUE;
+	    continue;
+	case 'w':
+	    set_color_test(opt_wide, FALSE);
+	    break;
+	case 'W':
+	    set_color_test(opt_wide, TRUE);
+	    break;
+	case CTRL('p'):
+	case KEY_UP:
+	    if (base_row <= 0) {
+		beep();
+	    } else {
+		base_row -= 1;
+	    }
+	    break;
+	case CTRL('n'):
+	case KEY_DOWN:
+	    if (base_row + page_size >= row_limit) {
+		beep();
+	    } else {
+		base_row += 1;
+	    }
+	    break;
+	case CTRL('b'):
+	case KEY_PREVIOUS:
+	case KEY_PPAGE:
+	    if (base_row <= 0) {
+		beep();
+	    } else {
+		base_row -= (page_size - 1);
+		if (base_row < 0)
+		    base_row = 0;
+	    }
+	    break;
+	case CTRL('f'):
+	case KEY_NEXT:
+	case KEY_NPAGE:
+	    if (base_row + page_size >= row_limit) {
+		beep();
+	    } else {
+		base_row += page_size - 1;
+		if (base_row + page_size >= row_limit) {
+		    base_row = row_limit - page_size - 1;
+		}
+	    }
+	    break;
+	case '?':
+	    if ((helpwin = newwin(LINES - 1, COLS - 2, 0, 0)) != 0) {
+		box(helpwin, 0, 0);
+		color_legend(helpwin);
+		wGetchar(helpwin);
+		delwin(helpwin);
+	    }
+	    break;
+	default:
+	    beep();
+	    continue;
 	}
-	if ((max_colors > 8) || base)
-	    Pause();
     }
 
     erase();
     endwin();
 }
+#endif /* USE_WIDEC_SUPPORT */
 
 static void
 change_color(int current, int field, int value, int usebase)
@@ -1280,12 +2066,28 @@
 }
 
 static void
+init_all_colors(void)
+{
+    int c;
+    for (c = 0; c < COLORS; ++c)
+	init_color(c,
+		   all_colors[c].red,
+		   all_colors[c].green,
+		   all_colors[c].blue);
+}
+
+#define scaled_rgb(n) ((255 * (n)) / 1000)
+
+static void
 color_edit(void)
 /* display the color test pattern, without trying to edit colors */
 {
     int i, this_c = 0, value = 0, current = 0, field = 0;
     int last_c;
+    int top_color = 0;
+    int page_size = (LINES - 6);
 
+    init_all_colors();
     refresh();
 
     for (i = 0; i < max_colors; i++)
@@ -1300,23 +2102,19 @@
 	mvaddstr(0, 20, "Color RGB Value Editing");
 	attroff(A_BOLD);
 
-	for (i = 0; i < max_colors; i++) {
-	    mvprintw(2 + i, 0, "%c %-8s:",
+	for (i = top_color;
+	     (i - top_color < page_size)
+	     && (i < max_colors); i++) {
+	    char numeric[80];
+	    sprintf(numeric, "[%d]", i);
+	    mvprintw(2 + i - top_color, 0, "%c %-8s:",
 		     (i == current ? '>' : ' '),
 		     (i < (int) SIZEOF(the_color_names)
-		      ? the_color_names[i] : ""));
+		      ? the_color_names[i] : numeric));
 	    attrset(COLOR_PAIR(i));
 	    addstr("        ");
 	    attrset(A_NORMAL);
 
-	    /*
-	     * Note: this refresh should *not* be necessary!  It works around
-	     * a bug in attribute handling that apparently causes the A_NORMAL
-	     * attribute sets to interfere with the actual emission of the
-	     * color setting somehow.  This needs to be fixed.
-	     */
-	    refresh();
-
 	    color_content(i, &red, &green, &blue);
 	    addstr("   R = ");
 	    if (current == i && field == 0)
@@ -1337,26 +2135,47 @@
 	    if (current == i && field == 2)
 		attrset(A_NORMAL);
 	    attrset(A_NORMAL);
-	    addstr(")");
+	    printw(" ( %3d %3d %3d )",
+		   scaled_rgb(red),
+		   scaled_rgb(green),
+		   scaled_rgb(blue));
 	}
 
-	mvaddstr(max_colors + 3, 0,
+	mvaddstr(LINES - 3, 0,
 		 "Use up/down to select a color, left/right to change fields.");
-	mvaddstr(max_colors + 4, 0,
+	mvaddstr(LINES - 2, 0,
 		 "Modify field by typing nnn=, nnn-, or nnn+.  ? for help.");
 
-	move(2 + current, 0);
+	move(2 + current - top_color, 0);
 
 	last_c = this_c;
 	this_c = Getchar();
-	if (isdigit(this_c) && !isdigit(last_c))
+	if (this_c < 256 && isdigit(this_c) && !isdigit(last_c))
 	    value = 0;
 
 	switch (this_c) {
+	case CTRL('b'):
+	case KEY_PPAGE:
+	    if (current > 0)
+		current -= (page_size - 1);
+	    else
+		beep();
+	    break;
+
+	case CTRL('f'):
+	case KEY_NPAGE:
+	    if (current < (max_colors - 1))
+		current += (page_size - 1);
+	    else
+		beep();
+	    break;
+
+	case CTRL('p'):
 	case KEY_UP:
 	    current = (current == 0 ? (max_colors - 1) : current - 1);
 	    break;
 
+	case CTRL('n'):
 	case KEY_DOWN:
 	    current = (current == (max_colors - 1) ? 0 : current + 1);
 	    break;
@@ -1407,12 +2226,19 @@
 	    P("To increment or decrement a value, use the same procedure, but finish");
 	    P("with a `+' or `-'.");
 	    P("");
+	    P("Press 'm' to invoke the top-level menu with the current color settings.");
 	    P("To quit, do `x' or 'q'");
 
 	    Pause();
 	    erase();
 	    break;
 
+	case 'm':
+	    endwin();
+	    main_menu(FALSE);
+	    refresh();
+	    break;
+
 	case 'x':
 	case 'q':
 	    break;
@@ -1421,12 +2247,28 @@
 	    beep();
 	    break;
 	}
-	mvprintw(LINES - 2, 0, "Number: %d", value);
+
+	if (current < 0)
+	    current = 0;
+	if (current >= max_colors)
+	    current = max_colors - 1;
+	if (current < top_color)
+	    top_color = current;
+	if (current - top_color >= page_size)
+	    top_color = current - (page_size - 1);
+
+	mvprintw(LINES - 1, 0, "Number: %d", value);
 	clrtoeol();
     } while
 	(this_c != 'x' && this_c != 'q');
 
     erase();
+
+    /*
+     * ncurses does not reset each color individually when calling endwin().
+     */
+    init_all_colors();
+
     endwin();
 }
 
@@ -1571,13 +2413,13 @@
 #if HAVE_SLK_COLOR
 	case 'F':
 	    if (has_colors()) {
-		fg = (fg + 1) % max_colors;
+		fg = (fg + 1) % COLORS;
 		new_color = TRUE;
 	    }
 	    break;
 	case 'B':
 	    if (has_colors()) {
-		bg = (bg + 1) % max_colors;
+		bg = (bg + 1) % COLORS;
 		new_color = TRUE;
 	    }
 	    break;
@@ -1595,12 +2437,13 @@
 }
 
 #if USE_WIDEC_SUPPORT
+#define SLKLEN 8
 static void
 wide_slk_test(void)
 /* exercise the soft keys */
 {
     int c, fmt = 1;
-    wchar_t buf[9];
+    wchar_t buf[SLKLEN + 1];
     char *s;
     short fg = COLOR_BLACK;
     short bg = COLOR_WHITE;
@@ -1670,14 +2513,30 @@
 	    (void) mvaddstr(SLK_WORK, 0, "Please enter the label value: ");
 	    *buf = 0;
 	    if ((s = slk_label(c - '0')) != 0) {
-		int j;
-		for (j = 0; j < 8; ++j) {
-		    if ((buf[j] = UChar(s[j])) == 0)
+		char *temp = strdup(s);
+		size_t used = strlen(temp);
+		size_t want = SLKLEN;
+		size_t test;
+		mbstate_t state;
+
+		buf[0] = L'\0';
+		while (want > 0 && used != 0) {
+		    const char *base = s;
+		    memset(&state, 0, sizeof(state));
+		    test = mbsrtowcs(0, &base, 0, &state);
+		    if (test == (size_t) -1) {
+			temp[--used] = 0;
+		    } else if (test > want) {
+			temp[--used] = 0;
+		    } else {
+			memset(&state, 0, sizeof(state));
+			mbsrtowcs(buf, &base, want, &state);
 			break;
+		    }
 		}
-		buf[j] = 0;
+		free(temp);
 	    }
-	    wGet_wstring(stdscr, buf, 8);
+	    wGet_wstring(stdscr, buf, SLKLEN);
 	    slk_wset((c - '0'), buf, fmt);
 	    slk_refresh();
 	    move(SLK_WORK, 0);
@@ -1690,13 +2549,13 @@
 
 	case 'F':
 	    if (has_colors()) {
-		fg = (fg + 1) % max_colors;
+		fg = (fg + 1) % COLORS;
 		new_color = TRUE;
 	    }
 	    break;
 	case 'B':
 	    if (has_colors()) {
-		bg = (bg + 1) % max_colors;
+		bg = (bg + 1) % COLORS;
 		new_color = TRUE;
 	    }
 	    break;
@@ -1723,11 +2582,11 @@
  * terminal to perform functions.  The remaining codes can be graphic.
  */
 static void
-show_upper_chars(int first)
+show_upper_chars(unsigned first)
 {
     bool C1 = (first == 128);
-    int code;
-    int last = first + 31;
+    unsigned code;
+    unsigned last = first + 31;
     int reply;
 
     erase();
@@ -1749,7 +2608,7 @@
 	if (C1) {
 	    /* (yes, this _is_ crude) */
 	    while ((reply = Getchar()) != ERR) {
-		addch(reply);
+		addch(UChar(reply));
 		napms(10);
 	    }
 	    nodelay(stdscr, FALSE);
@@ -1850,6 +2709,9 @@
 
     do {
 	switch (c) {
+	case CTRL('L'):
+	    Repaint();
+	    break;
 	case 'a':
 	    show_acs_chars();
 	    break;
@@ -1860,7 +2722,7 @@
 	case '1':
 	case '2':
 	case '3':
-	    show_upper_chars((c - '0') * 32 + 128);
+	    show_upper_chars((unsigned) ((c - '0') * 32 + 128));
 	    break;
 	}
 	mvprintw(LINES - 3, 0,
@@ -1877,7 +2739,7 @@
 
 #if USE_WIDEC_SUPPORT
 static void
-show_upper_widechars(int first, int repeat)
+show_upper_widechars(int first, int repeat, int space)
 {
     cchar_t temp;
     wchar_t code;
@@ -1903,6 +2765,14 @@
 	setcchar(&temp, codes, attrs, 0, 0);
 	do {
 	    /*
+	     * Give non-spacing characters something to combine with.  If we
+	     * don't, they'll bunch up in a heap on the space after the ":".
+	     * Mark them with reverse-video to make them simpler to find on
+	     * the display.
+	     */
+	    if (wcwidth(code) == 0)
+		addch(space | A_REVERSE);
+	    /*
 	     * This could use add_wch(), but is done for comparison with the
 	     * normal 'f' test (and to make a test-case for echo_wchar()).
 	     * The screen will flicker because the erase() at the top of the
@@ -1914,7 +2784,7 @@
 }
 
 static int
-show_1_wacs(int n, const char *name, const cchar_t * code)
+show_1_wacs(int n, const char *name, const cchar_t *code)
 {
     const int height = 16;
     int row = 4 + (n % height);
@@ -2074,9 +2944,13 @@
     int c = 'a';
     int digit = 0;
     int repeat = 0;
+    int space = ' ';
 
     do {
 	switch (c) {
+	case CTRL('L'):
+	    Repaint();
+	    break;
 	case 'a':
 	    show_wacs_chars();
 	    break;
@@ -2087,7 +2961,7 @@
 	    show_utf8_chars();
 	    break;
 	default:
-	    if (isdigit(c))
+	    if (c < 256 && isdigit(c))
 		digit = (c - '0');
 	    else if (c == '+')
 		++digit;
@@ -2097,11 +2971,13 @@
 		++repeat;
 	    else if (c == '<' && repeat > 0)
 		--repeat;
+	    else if (c == '_')
+		space = (space == ' ') ? '_' : ' ';
 	    else {
 		beep();
 		break;
 	    }
-	    show_upper_widechars(digit * 32 + 128, repeat);
+	    show_upper_widechars(digit * 32 + 128, repeat, space);
 	    break;
 	}
 	mvprintw(LINES - 2, 0,
@@ -2125,7 +3001,7 @@
     int pass;
 
     for (pass = 0; pass < 2; pass++) {
-	int normal = ((pass == 0 ? A_NORMAL : A_REVERSE)) | BLANK;
+	chtype normal = ((pass == 0 ? A_NORMAL : A_REVERSE)) | BLANK;
 
 	/* Use non-default colors if possible to exercise bce a little */
 	if (has_colors()) {
@@ -2740,7 +3616,7 @@
  ****************************************************************************/
 
 #if USE_LIBPANEL
-static unsigned long nap_msec = 1;
+static int nap_msec = 1;
 
 static NCURSES_CONST char *mod[] =
 {
@@ -2756,7 +3632,7 @@
 	wait_a_while(msec)
 --------------------------------------------------------------------------*/
 static void
-wait_a_while(unsigned long msec GCC_UNUSED)
+wait_a_while(int msec GCC_UNUSED)
 {
 #if HAVE_NAPMS
     if (nap_msec == 1)
@@ -2766,8 +3642,8 @@
 #else
     if (nap_msec == 1)
 	wGetchar(stdscr);
-    else if (msec > 1000L)
-	sleep((int) msec / 1000L);
+    else if (msec > 1000)
+	sleep((unsigned) msec / 1000);
     else
 	sleep(1);
 #endif
@@ -2788,7 +3664,7 @@
 	mkpanel(rows,cols,tly,tlx) - alloc a win and panel and associate them
 --------------------------------------------------------------------------*/
 static PANEL *
-mkpanel(int color, int rows, int cols, int tly, int tlx)
+mkpanel(unsigned color, int rows, int cols, int tly, int tlx)
 {
     WINDOW *win;
     PANEL *pan = 0;
@@ -2846,7 +3722,7 @@
     for (y = 2; y < getmaxy(win) - 1; y++) {
 	for (x = 1; x < getmaxx(win) - 1; x++) {
 	    wmove(win, y, x);
-	    waddch(win, num);
+	    waddch(win, UChar(num));
 	}
     }
 }				/* end of fill_panel */
@@ -3057,6 +3933,10 @@
 	saywhat("d5; press any key to continue");
 	rmpanel(p5);
 	pflush();
+
+	rmpanel(p3);
+	pflush();
+
 	wait_a_while(nap_msec);
 	if (nap_msec == 1)
 	    break;
@@ -3086,7 +3966,7 @@
 	"Use arrow keys (or U,D,L,R) to pan, q to quit, ! to shell-out.",
 	"Use +,- (or j,k) to grow/shrink the panner vertically.",
 	"Use <,> (or h,l) to grow/shrink the panner horizontally.",
-	"Number repeats.  Toggle legend:?, timer:t, scroll mark:s."
+	"Number repeats.  Toggle legend:? filler:a timer:t scrollmark:s."
     };
     int n = (SIZEOF(legend) - (LINES - line));
     if (line < LINES && (n >= 0)) {
@@ -3114,6 +3994,35 @@
 }
 
 static void
+fill_pad(WINDOW *panpad, bool pan_lines)
+{
+    int y, x;
+    unsigned gridcount = 0;
+
+    wmove(panpad, 0, 0);
+    for (y = 0; y < getmaxy(panpad); y++) {
+	for (x = 0; x < getmaxx(panpad); x++) {
+	    if (y % GRIDSIZE == 0 && x % GRIDSIZE == 0) {
+		if (y == 0 && x == 0)
+		    waddch(panpad, pan_lines ? ACS_ULCORNER : '+');
+		else if (y == 0)
+		    waddch(panpad, pan_lines ? ACS_TTEE : '+');
+		else if (y == 0 || x == 0)
+		    waddch(panpad, pan_lines ? ACS_LTEE : '+');
+		else
+		    waddch(panpad, (chtype) ((pan_lines ? 'a' : 'A') +
+					     (gridcount++ % 26)));
+	    } else if (y % GRIDSIZE == 0)
+		waddch(panpad, pan_lines ? ACS_HLINE : '-');
+	    else if (x % GRIDSIZE == 0)
+		waddch(panpad, pan_lines ? ACS_VLINE : '|');
+	    else
+		waddch(panpad, ' ');
+	}
+    }
+}
+
+static void
 panner(WINDOW *pad,
        int top_x, int top_y, int porty, int portx,
        int (*pgetc) (WINDOW *))
@@ -3122,6 +4031,7 @@
     struct timeval before, after;
     bool timing = TRUE;
 #endif
+    bool pan_lines = FALSE;
     bool scrollers = TRUE;
     int basex = 0;
     int basey = 0;
@@ -3160,6 +4070,12 @@
 	    panner_legend(LINES - 2);
 	    panner_legend(LINES - 1);
 	    break;
+	case 'a':
+	    pan_lines = !pan_lines;
+	    fill_pad(pad, pan_lines);
+	    pending_pan = FALSE;
+	    break;
+
 #if HAVE_GETTIMEOFDAY
 	case 't':
 	    timing = !timing;
@@ -3357,7 +4273,7 @@
 		gettimeofday(&after, 0);
 		elapsed = (after.tv_sec + after.tv_usec / 1.0e6)
 		    - (before.tv_sec + before.tv_usec / 1.0e6);
-		move(LINES - 1, COLS - 20);
+		move(LINES - 1, COLS - 12);
 		printw("Secs: %2.03f", elapsed);
 		refresh();
 	    }
@@ -3446,8 +4362,6 @@
 demo_pad(void)
 /* Demonstrate pads. */
 {
-    int i, j;
-    unsigned gridcount = 0;
     WINDOW *panpad = newpad(PAD_HIGH, PAD_WIDE);
 
     if (panpad == 0) {
@@ -3455,20 +4369,8 @@
 	return;
     }
 
-    for (i = 0; i < PAD_HIGH; i++) {
-	for (j = 0; j < PAD_WIDE; j++)
-	    if (i % GRIDSIZE == 0 && j % GRIDSIZE == 0) {
-		if (i == 0 || j == 0)
-		    waddch(panpad, '+');
-		else
-		    waddch(panpad, (chtype) ('A' + (gridcount++ % 26)));
-	    } else if (i % GRIDSIZE == 0)
-		waddch(panpad, '-');
-	    else if (j % GRIDSIZE == 0)
-		waddch(panpad, '|');
-	    else
-		waddch(panpad, ' ');
-    }
+    fill_pad(panpad, FALSE);
+
     panner_legend(LINES - 4);
     panner_legend(LINES - 3);
     panner_legend(LINES - 2);
@@ -3626,7 +4528,19 @@
 
 static const char *animals[] =
 {
-    "Lions", "Tigers", "Bears", "(Oh my!)", "Newts", "Platypi", "Lemurs",
+    "Lions",
+    "Tigers",
+    "Bears",
+    "(Oh my!)",
+    "Newts",
+    "Platypi",
+    "Lemurs",
+    "(Oh really?!)",
+    "Leopards",
+    "Panthers",
+    "Pumas",
+    "Lions, Tigers, Bears, (Oh my!), Newts, Platypi, Lemurs",
+    "Lions, Tigers, Bears, (Oh my!), Newts, Platypi, Lemurs, Lions, Tigers, Bears, (Oh my!), Newts, Platypi, Lemurs",
     (char *) 0
 };
 
@@ -3670,6 +4584,8 @@
     post_menu(m);
 
     while ((c = menu_driver(m, menu_virtualize(wGetchar(menuwin)))) != E_UNKNOWN_COMMAND) {
+	if (c == E_NOT_POSTED)
+	    break;
 	if (c == E_REQUEST_DENIED)
 	    beep();
 	continue;
@@ -3695,7 +4611,7 @@
 #define T_TBL(name) { #name, name }
 static struct {
     const char *name;
-    int mask;
+    unsigned mask;
 } t_tbl[] = {
 
     T_TBL(TRACE_DISABLE),
@@ -3720,7 +4636,7 @@
 };
 
 static char *
-tracetrace(int tlevel)
+tracetrace(unsigned tlevel)
 {
     static char *buf;
     int n;
@@ -3792,7 +4708,8 @@
     MENU *m;
     ITEM *items[SIZEOF(t_tbl)];
     ITEM **ip = items;
-    int mrows, mcols, newtrace;
+    int mrows, mcols;
+    unsigned newtrace;
     int n;
     WINDOW *menuwin;
 
@@ -3824,7 +4741,7 @@
     post_menu(m);
 
     for (ip = menu_items(m); *ip; ip++) {
-	int mask = t_tbl[item_index(*ip)].mask;
+	unsigned mask = t_tbl[item_index(*ip)].mask;
 	if (mask == 0)
 	    set_item_value(*ip, _nc_tracing == 0);
 	else if ((mask & _nc_tracing) == mask)
@@ -3865,11 +4782,11 @@
 static FIELD *
 make_label(int frow, int fcol, NCURSES_CONST char *label)
 {
-    FIELD *f = new_field(1, strlen(label), frow, fcol, 0, 0);
+    FIELD *f = new_field(1, (int) strlen(label), frow, fcol, 0, 0);
 
     if (f) {
 	set_field_buffer(f, 0, label);
-	set_field_opts(f, field_opts(f) & ~O_ACTIVE);
+	set_field_opts(f, (int) (field_opts(f) & ~O_ACTIVE));
     }
     return (f);
 }
@@ -3931,7 +4848,7 @@
 	strcpy(temp, field_buffer(me, 1));
 	len = (long) (char *) field_userptr(me);
 	if (c <= KEY_MAX) {
-	    if (isgraph(c)) {
+	    if (isgraph(c) && (len + 1) < (int) sizeof(temp)) {
 		temp[len++] = c;
 		temp[len] = 0;
 		set_field_buffer(me, 1, temp);
@@ -4102,12 +5019,14 @@
     int c = wGetchar(w);
     unsigned n;
     FIELD *me = current_field(f);
+    bool current = TRUE;
 
     if (c == CTRL(']')) {
-	if (mode == REQ_INS_MODE)
+	if (mode == REQ_INS_MODE) {
 	    mode = REQ_OVL_MODE;
-	else
+	} else {
 	    mode = REQ_INS_MODE;
+	}
 	c = mode;
     } else {
 	for (n = 0; n < SIZEOF(lookup); n++) {
@@ -4117,15 +5036,38 @@
 	    }
 	}
     }
+    mvprintw(0, COLS - 6, "(%s)", mode == REQ_INS_MODE ? "INS" : "OVL");
 
     /*
      * Force the field that the user is typing into to be in reverse video,
      * while the other fields are shown underlined.
      */
-    if (c <= KEY_MAX) {
+    switch (c) {
+    case REQ_BEG_FIELD:
+    case REQ_CLR_EOF:
+    case REQ_CLR_EOL:
+    case REQ_CLR_FIELD:
+    case REQ_DEL_CHAR:
+    case REQ_DEL_LINE:
+    case REQ_DEL_PREV:
+    case REQ_DEL_WORD:
+    case REQ_END_FIELD:
+    case REQ_INS_CHAR:
+    case REQ_INS_LINE:
+    case REQ_LEFT_CHAR:
+    case REQ_LEFT_FIELD:
+    case REQ_NEXT_WORD:
+    case REQ_RIGHT_CHAR:
+	current = TRUE;
+	break;
+    default:
+	current = (c < KEY_MAX);
+	break;
+    }
+    if (current) {
 	c = edit_secure(me, c);
 	set_field_back(me, A_REVERSE);
-    } else if (c <= MAX_FORM_COMMAND) {
+    } else {
 	c = edit_secure(me, c);
 	set_field_back(me, A_UNDERLINE);
     }
@@ -4222,7 +5164,7 @@
     unsigned n = 0;
 
     move(18, 0);
-    addstr("Defined form-traversal keys:   ^Q/ESC- exit form\n");
+    addstr("Defined edit/traversal keys:   ^Q/ESC- exit form\n");
     addstr("^N   -- go to next field       ^P  -- go to previous field\n");
     addstr("Home -- go to first field      End -- go to last field\n");
     addstr("^L   -- go to field to left    ^R  -- go to field to right\n");
@@ -4232,7 +5174,7 @@
     addstr("^H   -- delete previous char   ^Y  -- delete line\n");
     addstr("^G   -- delete current word    ^C  -- clear to end of line\n");
     addstr("^K   -- clear to end of field  ^X  -- clear field\n");
-    addstr("Arrow keys move within a field as you would expect.");
+    addstr("Arrow keys move within a field as you would expect. ^] toggles overlay mode.");
 
     mvaddstr(4, 57, "Forms Entry Test");
 
@@ -4290,6 +5232,8 @@
     free_form(form);
     for (c = 0; f[c] != 0; c++)
 	free_field(f[c]);
+    free_fieldtype(fty_middle);
+    free_fieldtype(fty_passwd);
     noraw();
     nl();
 }
@@ -4311,7 +5255,7 @@
     for (y = 0; y < y1; y++) {
 	wmove(win, y, 0);
 	for (x = 0; x < x1; x++)
-	    waddch(win, ch);
+	    waddch(win, UChar(ch));
     }
 }
 
@@ -4327,7 +5271,7 @@
 	    if (((x > (x1 - 1) / 3) && (x <= (2 * (x1 - 1)) / 3))
 		|| (((y > (y1 - 1) / 3) && (y <= (2 * (y1 - 1)) / 3)))) {
 		wmove(win, y, x);
-		waddch(win, ch);
+		waddch(win, UChar(ch));
 	    }
     }
 }
@@ -4436,6 +5380,12 @@
 	attr_test();
 	break;
 
+#if USE_WIDEC_SUPPORT
+    case 'B':
+	wide_attr_test();
+	break;
+#endif
+
     case 'c':
 	if (!has_colors())
 	    Cannot("does not support color.");
@@ -4443,6 +5393,15 @@
 	    color_test();
 	break;
 
+#if USE_WIDEC_SUPPORT
+    case 'C':
+	if (!has_colors())
+	    Cannot("does not support color.");
+	else
+	    wide_color_test();
+	break;
+#endif
+
     case 'd':
 	if (!has_colors())
 	    Cannot("does not support color.");
@@ -4542,7 +5501,10 @@
 	,"  -e fmt   specify format for soft-keys test (e)"
 	,"  -f       rip-off footer line (can repeat)"
 	,"  -h       rip-off header line (can repeat)"
+	,"  -p file  rgb values to use in 'd' rather than ncurses's builtin"
+#if USE_LIBPANEL
 	,"  -s msec  specify nominal time for panel-demo (default: 1, to hold)"
+#endif
 #ifdef TRACE
 	,"  -t mask  specify default trace-level (may toggle with ^T)"
 #endif
@@ -4594,14 +5556,122 @@
     return OK;
 }
 
+static void
+main_menu(bool top)
+{
+    int command;
+
+    do {
+	(void) puts("This is the ncurses main menu");
+	(void) puts("a = keyboard and mouse input test");
+#if USE_WIDEC_SUPPORT
+	(void) puts("A = wide-character keyboard and mouse input test");
+#endif
+	(void) puts("b = character attribute test");
+#if USE_WIDEC_SUPPORT
+	(void) puts("B = wide-character attribute test");
+#endif
+	(void) puts("c = color test pattern");
+#if USE_WIDEC_SUPPORT
+	(void) puts("C = color test pattern using wide-character calls");
+#endif
+	if (top)
+	    (void) puts("d = edit RGB color values");
+	(void) puts("e = exercise soft keys");
+#if USE_WIDEC_SUPPORT
+	(void) puts("E = exercise soft keys using wide-characters");
+#endif
+	(void) puts("f = display ACS characters");
+#if USE_WIDEC_SUPPORT
+	(void) puts("F = display Wide-ACS characters");
+#endif
+	(void) puts("g = display windows and scrolling");
+	(void) puts("i = test of flushinp()");
+	(void) puts("k = display character attributes");
+#if USE_LIBMENU
+	(void) puts("m = menu code test");
+#endif
+#if USE_LIBPANEL
+	(void) puts("o = exercise panels library");
+	(void) puts("p = exercise pad features");
+	(void) puts("q = quit");
+#endif
+#if USE_LIBFORM
+	(void) puts("r = exercise forms code");
+#endif
+	(void) puts("s = overlapping-refresh test");
+#if USE_LIBMENU && defined(TRACE)
+	(void) puts("t = set trace level");
+#endif
+	(void) puts("? = repeat this command summary");
+
+	(void) fputs("> ", stdout);
+	(void) fflush(stdout);	/* necessary under SVr4 curses */
+
+	/*
+	 * This used to be an 'fgets()' call.  However (on Linux, at least)
+	 * mixing stream I/O and 'read()' (used in the library) causes the
+	 * input stream to be flushed when switching between the two.
+	 */
+	command = 0;
+	for (;;) {
+	    char ch;
+	    if (read(fileno(stdin), &ch, 1) <= 0) {
+		if (command == 0)
+		    command = 'q';
+		break;
+	    } else if (command == 0 && !isspace(UChar(ch))) {
+		command = ch;
+	    } else if (ch == '\n' || ch == '\r') {
+		if ((command == 'd') && !top) {
+		    (void) fputs("Do not nest test-d\n", stdout);
+		    command = 0;
+		}
+		if (command != 0)
+		    break;
+		(void) fputs("> ", stdout);
+		(void) fflush(stdout);
+	    }
+	}
+
+	if (do_single_test(command)) {
+	    /*
+	     * This may be overkill; it's intended to reset everything back
+	     * to the initial terminal modes so that tests don't get in
+	     * each other's way.
+	     */
+	    flushinp();
+	    set_terminal_modes();
+	    reset_prog_mode();
+	    clear();
+	    refresh();
+	    endwin();
+	    if (command == '?') {
+		(void) puts("This is the ncurses capability tester.");
+		(void)
+		    puts("You may select a test from the main menu by typing the");
+		(void)
+		    puts("key letter of the choice (the letter to left of the =)");
+		(void)
+		    puts("at the > prompt.  The commands `x' or `q' will exit.");
+	    }
+	    continue;
+	}
+    } while
+	(command != 'q');
+}
+
 /*+-------------------------------------------------------------------------
 	main(argc,argv)
 --------------------------------------------------------------------------*/
 
+#define okCOLOR(n) ((n) >= 0 && (n) < max_colors)
+#define okRGB(n)   ((n) >= 0 && (n) <= 1000)
+
 int
 main(int argc, char *argv[])
 {
-    int command, c;
+    int c;
     int my_e_param = 1;
 #ifdef NCURSES_VERSION
     int default_fg = COLOR_WHITE;
@@ -4609,10 +5679,11 @@
     bool assumed_colors = FALSE;
     bool default_colors = FALSE;
 #endif
+    char *palette_file = 0;
 
     setlocale(LC_ALL, "");
 
-    while ((c = getopt(argc, argv, "a:de:fhs:t:")) != EOF) {
+    while ((c = getopt(argc, argv, "a:de:fhp:s:t:")) != EOF) {
 	switch (c) {
 #ifdef NCURSES_VERSION
 	case 'a':
@@ -4639,6 +5710,9 @@
 	case 'h':
 	    ripoffline(1, rip_header);
 	    break;
+	case 'p':
+	    palette_file = optarg;
+	    break;
 #if USE_LIBPANEL
 	case 's':
 	    nap_msec = atol(optarg);
@@ -4646,7 +5720,7 @@
 #endif
 #ifdef TRACE
 	case 't':
-	    save_trace = atoi(optarg);
+	    save_trace = strtol(optarg, 0, 0);
 	    break;
 #endif
 	default:
@@ -4685,21 +5759,57 @@
     if (has_colors()) {
 	start_color();
 #ifdef NCURSES_VERSION_PATCH
-	max_colors = COLORS > 16 ? 16 : COLORS;
+	max_colors = COLORS;	/* was > 16 ? 16 : COLORS */
 #if HAVE_USE_DEFAULT_COLORS
-	if (default_colors)
+	if (default_colors) {
 	    use_default_colors();
+	    min_colors = -1;
+	}
 #if NCURSES_VERSION_PATCH >= 20000708
 	else if (assumed_colors)
 	    assume_default_colors(default_fg, default_bg);
 #endif
 #endif
 #else /* normal SVr4 curses */
-	max_colors = COLORS > 8 ? 8 : COLORS;
+	max_colors = COLORS;	/* was > 8 ? 8 : COLORS */
 #endif
-	max_pairs = (max_colors * max_colors);
-	if (max_pairs < COLOR_PAIRS)
-	    max_pairs = COLOR_PAIRS;
+	max_pairs = COLOR_PAIRS;	/* was > 256 ? 256 : COLOR_PAIRS */
+
+	if (can_change_color()) {
+	    all_colors = (RGB_DATA *) malloc(max_colors * sizeof(RGB_DATA));
+	    for (c = 0; c < max_colors; ++c) {
+		color_content(c,
+			      &all_colors[c].red,
+			      &all_colors[c].green,
+			      &all_colors[c].blue);
+	    }
+	    if (palette_file != 0) {
+		FILE *fp = fopen(palette_file, "r");
+		if (fp != 0) {
+		    char buffer[BUFSIZ];
+		    int red, green, blue;
+		    int scale = 1000;
+		    while (fgets(buffer, sizeof(buffer), fp) != 0) {
+			if (sscanf(buffer, "scale:%d", &c) == 1) {
+			    scale = c;
+			} else if (sscanf(buffer, "%d:%d %d %d",
+					  &c,
+					  &red,
+					  &green,
+					  &blue) == 4
+				   && okCOLOR(c)
+				   && okRGB(red)
+				   && okRGB(green)
+				   && okRGB(blue)) {
+			    all_colors[c].red = (red * 1000) / scale;
+			    all_colors[c].green = (green * 1000) / scale;
+			    all_colors[c].blue = (blue * 1000) / scale;
+			}
+		    }
+		    fclose(fp);
+		}
+	    }
+	}
     }
     set_terminal_modes();
     def_prog_mode();
@@ -4721,93 +5831,7 @@
     (void) puts("Welcome to ncurses.  Press ? for help.");
 #endif
 
-    do {
-	(void) puts("This is the ncurses main menu");
-	(void) puts("a = keyboard and mouse input test");
-#if USE_WIDEC_SUPPORT
-	(void) puts("A = wide-character keyboard and mouse input test");
-#endif
-	(void) puts("b = character attribute test");
-	(void) puts("c = color test pattern");
-	(void) puts("d = edit RGB color values");
-	(void) puts("e = exercise soft keys");
-#if USE_WIDEC_SUPPORT
-	(void) puts("E = exercise soft keys using wide-characters");
-#endif
-	(void) puts("f = display ACS characters");
-#if USE_WIDEC_SUPPORT
-	(void) puts("F = display Wide-ACS characters");
-#endif
-	(void) puts("g = display windows and scrolling");
-	(void) puts("i = test of flushinp()");
-	(void) puts("k = display character attributes");
-#if USE_LIBMENU
-	(void) puts("m = menu code test");
-#endif
-#if USE_LIBPANEL
-	(void) puts("o = exercise panels library");
-	(void) puts("p = exercise pad features");
-	(void) puts("q = quit");
-#endif
-#if USE_LIBFORM
-	(void) puts("r = exercise forms code");
-#endif
-	(void) puts("s = overlapping-refresh test");
-#if USE_LIBMENU && defined(TRACE)
-	(void) puts("t = set trace level");
-#endif
-	(void) puts("? = repeat this command summary");
-
-	(void) fputs("> ", stdout);
-	(void) fflush(stdout);	/* necessary under SVr4 curses */
-
-	/*
-	 * This used to be an 'fgets()' call.  However (on Linux, at least)
-	 * mixing stream I/O and 'read()' (used in the library) causes the
-	 * input stream to be flushed when switching between the two.
-	 */
-	command = 0;
-	for (;;) {
-	    char ch;
-	    if (read(fileno(stdin), &ch, 1) <= 0) {
-		if (command == 0)
-		    command = 'q';
-		break;
-	    } else if (command == 0 && !isspace(UChar(ch))) {
-		command = ch;
-	    } else if (ch == '\n' || ch == '\r') {
-		if (command != 0)
-		    break;
-		(void) fputs("> ", stdout);
-		(void) fflush(stdout);
-	    }
-	}
-
-	if (do_single_test(command)) {
-	    /*
-	     * This may be overkill; it's intended to reset everything back
-	     * to the initial terminal modes so that tests don't get in
-	     * each other's way.
-	     */
-	    flushinp();
-	    set_terminal_modes();
-	    reset_prog_mode();
-	    clear();
-	    refresh();
-	    endwin();
-	    if (command == '?') {
-		(void) puts("This is the ncurses capability tester.");
-		(void)
-		    puts("You may select a test from the main menu by typing the");
-		(void)
-		    puts("key letter of the choice (the letter to left of the =)");
-		(void)
-		    puts("at the > prompt.  The commands `x' or `q' will exit.");
-	    }
-	    continue;
-	}
-    } while
-	(command != 'q');
+    main_menu(TRUE);
 
     ExitProgram(EXIT_SUCCESS);
 }
diff -Naur ncurses-5.4.orig/test/newdemo.c ncurses-5.4/test/newdemo.c
--- ncurses-5.4.orig/test/newdemo.c	2002-06-29 23:32:18.000000000 +0000
+++ ncurses-5.4/test/newdemo.c	2005-05-13 04:09:57.000000000 +0000
@@ -2,7 +2,7 @@
  *  newdemo.c	-	A demo program using PDCurses. The program illustrate
  *  	 		the use of colours for text output.
  *
- * $Id: newdemo.c,v 1.24 2002/06/29 23:32:18 tom Exp $
+ * $Id: newdemo.c,v 1.26 2005/04/16 16:10:12 tom Exp $
  */
 
 #include <time.h>
@@ -14,7 +14,7 @@
 /*
  *  The Australian map
  */
-const char *AusMap[16] =
+static const char *AusMap[16] =
 {
     "           A           A ",
     "    N.T. AAAAA       AAAA ",
@@ -35,7 +35,7 @@
  */
 #define NMESSAGES   6
 
-NCURSES_CONST char *messages[] =
+static NCURSES_CONST char *messages[] =
 {
     "Hello from the Land Down Under",
     "The Land of crocs. and a big Red Rock",
@@ -90,8 +90,8 @@
     }
 }
 
-static int
-use_colors(WINDOW *win, int pair, int attrs)
+static chtype
+use_colors(WINDOW *win, int pair, chtype attrs)
 {
     if (has_colors()) {
 	if (pair > COLOR_PAIRS)
diff -Naur ncurses-5.4.orig/test/tclock.c ncurses-5.4/test/tclock.c
--- ncurses-5.4.orig/test/tclock.c	2002-12-29 01:40:30.000000000 +0000
+++ ncurses-5.4/test/tclock.c	2005-05-13 04:09:57.000000000 +0000
@@ -1,4 +1,4 @@
-/* $Id: tclock.c,v 1.24 2002/12/29 01:40:30 tom Exp $ */
+/* $Id: tclock.c,v 1.25 2005/04/16 16:39:27 tom Exp $ */
 
 #include <test.priv.h>
 
@@ -229,7 +229,7 @@
 	    lastbeep = t->tm_sec;
 	    if (has_colors()) {
 		odd = !odd;
-		bkgd(odd ? COLOR_PAIR(4) : COLOR_PAIR(0));
+		bkgd((chtype) (odd ? COLOR_PAIR(4) : COLOR_PAIR(0)));
 	    }
 	    beep();
 	}
diff -Naur ncurses-5.4.orig/test/test.priv.h ncurses-5.4/test/test.priv.h
--- ncurses-5.4.orig/test/test.priv.h	2003-10-19 00:04:24.000000000 +0000
+++ ncurses-5.4/test/test.priv.h	2005-05-13 04:09:51.000000000 +0000
@@ -29,7 +29,7 @@
 /****************************************************************************
  *  Author: Thomas E. Dickey <dickey@clark.net> 1996                        *
  ****************************************************************************/
-/* $Id: test.priv.h,v 1.46 2003/10/19 00:04:24 tom Exp $ */
+/* $Id: test.priv.h,v 1.48 2004/04/10 20:11:37 tom Exp $ */
 
 #ifndef __TEST_PRIV_H
 #define __TEST_PRIV_H 1
@@ -136,6 +136,10 @@
 #include <term.h>
 #endif
 
+#ifdef NCURSES_VERSION
+#define HAVE_COLOR_SET 1
+#endif
+
 #if NCURSES_NOMACROS
 #include <nomacros.h>
 #endif
@@ -276,12 +280,12 @@
 #endif
 
 /* out-of-band values for representing absent capabilities */
-#define ABSENT_BOOLEAN		(-1)		/* 255 */
+#define ABSENT_BOOLEAN		((signed char)-1)	/* 255 */
 #define ABSENT_NUMERIC		(-1)
 #define ABSENT_STRING		(char *)0
 
 /* out-of-band values for representing cancels */
-#define CANCELLED_BOOLEAN	(char)(-2)	/* 254 */
+#define CANCELLED_BOOLEAN	((signed char)-2)	/* 254 */
 #define CANCELLED_NUMERIC	(-2)
 #define CANCELLED_STRING	(char *)(-1)
 
diff -Naur ncurses-5.4.orig/test/testcurs.c ncurses-5.4/test/testcurs.c
--- ncurses-5.4.orig/test/testcurs.c	2002-10-19 22:11:24.000000000 +0000
+++ ncurses-5.4/test/testcurs.c	2005-05-13 04:09:57.000000000 +0000
@@ -7,7 +7,7 @@
  *  wrs(5/28/93) -- modified to be consistent (perform identically) with either
  *                  PDCurses or under Unix System V, R4
  *
- * $Id: testcurs.c,v 1.32 2002/10/19 22:11:24 tom Exp $
+ * $Id: testcurs.c,v 1.34 2005/04/16 16:19:12 tom Exp $
  */
 
 #include <test.priv.h>
@@ -33,7 +33,7 @@
 };
 typedef struct commands COMMAND;
 
-const COMMAND command[] =
+static const COMMAND command[] =
 {
     {"General Test", introTest},
     {"Pad Test", padTest},
@@ -58,7 +58,7 @@
 }
 #endif /* not HAVE_STRDUP */
 
-int width, height;
+static int width, height;
 
 int
 main(
@@ -158,7 +158,7 @@
     int x1 = getmaxx(win);
     int y0 = y1 < 10 ? y1 : 10;
     int x0 = 1;
-    long save;
+    chtype save;
 
     save = mvwinch(win, y0, x1 - 1);
 
@@ -358,7 +358,7 @@
 	else if (isprint(c))
 	    wprintw(win, "Key Pressed: %c", c);
 	else
-	    wprintw(win, "Key Pressed: %s", unctrl(c));
+	    wprintw(win, "Key Pressed: %s", unctrl(UChar(c)));
 #if defined(PDCURSES)
 	if (c == KEY_MOUSE) {
 	    int button = 0;
@@ -400,7 +400,8 @@
 
     repeat = 0;
     do {
-	static const char *fmt[] = {
+	static const char *fmt[] =
+	{
 	    "%d %10s",
 	    "%d %[a-zA-Z]s",
 	    "%d %[][a-zA-Z]s",
@@ -689,12 +690,12 @@
 static void
 display_menu(int old_option, int new_option)
 {
-    register size_t i;
+    int i;
 
     attrset(A_NORMAL);
     mvaddstr(3, 20, "PDCurses Test Program");
 
-    for (i = 0; i < MAX_OPTIONS; i++)
+    for (i = 0; i < (int) MAX_OPTIONS; i++)
 	mvaddstr(5 + i, 25, command[i].text);
     if (old_option != (-1))
 	mvaddstr(5 + old_option, 25, command[old_option].text);
diff -Naur ncurses-5.4.orig/test/tracemunch ncurses-5.4/test/tracemunch
--- ncurses-5.4.orig/test/tracemunch	2002-09-22 16:31:18.000000000 +0000
+++ ncurses-5.4/test/tracemunch	2005-05-13 04:09:51.000000000 +0000
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -w
-# $Id: tracemunch,v 1.3 2002/09/22 16:31:18 tom Exp $
+# $Id: tracemunch,v 1.6 2005/03/12 21:48:23 tom Exp $
 ##############################################################################
-# Copyright (c) 1998,2002 Free Software Foundation, Inc.                     #
+# Copyright (c) 1998-2002,2005 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"), #
@@ -32,22 +32,27 @@
 # The error logs produced by ncurses with tracing enabled can be very tedious
 # to wade through.  This script helps by compacting runs of log lines that
 # can be conveniently expressed as higher-level operations.
-#
+use strict;
 
-$putattr="PutAttrChar\\('(.)' = 0x.., {A_NORMAL}\\) at \\(([0-9]+), ([0-9]+)\\)";
-$waddnstr="waddnstr\\(0x([0-9a-f]+),\"([^\"]+)\",[0-9]+\\) called {A_NORMAL}";
+our $putattr="PutAttrChar\\({{ '(.)' = 0[0-7]+ }}\\) at \\(([0-9]+), ([0-9]+)\\)";
+our $waddnstr="waddnstr\\(0x([0-9a-f]+),\"([^\"]+)\",[0-9]+\\) called {A_NORMAL}";
 
-$win_nums=0;
+our $win_nums=0;
+our $curscr="";
+our $newscr="";
+our $stdscr="";
+our @win_addr;
 
 sub transaddr
 {
-    $arg = $_[0];
+    my $n;
+    my $arg = $_[0];
 
-    $arg =~ s/$curscr/curscr/ if ($curscr);
-    $arg =~ s/$newscr/newscr/ if ($newscr);
-    $arg =~ s/$stdscr/stdscr/ if ($stdscr);
+    $arg =~ s/$curscr/curscr/g if ($curscr);
+    $arg =~ s/$newscr/newscr/g if ($newscr);
+    $arg =~ s/$stdscr/stdscr/g if ($stdscr);
     for $n (0..$#win_addr) {
-	$arg =~ s/$win_addr[$n]/window$n/ if $win_addr[$n];
+	$arg =~ s/$win_addr[$n]/window$n/g if $win_addr[$n];
     }
 
     return $arg;
@@ -55,6 +60,10 @@
 
 while (<STDIN>)
 {
+	my $addr;
+	my $n;
+	my $awaiting;
+
 CLASSIFY: {
 	# Transform window pointer addresses so it's easier to compare logs
 	$awaiting = "curscr" if ($_ =~ /creating curscr/);
@@ -75,6 +84,7 @@
 	    $awaiting = "";
 	} elsif ($_ =~ /^\.\.\.deleted win=0x([0-9a-f]+)/) {
 	    $addr = "0x$1";
+	    $_ = &transaddr($_);
 	    if ($addr eq $curscr) {
 		$curscr = "";
 	    } elsif ($addr eq $newscr) {
@@ -93,9 +103,9 @@
 	# Compactify runs of PutAttrChar calls (TR_CHARPUT)
 	if ($_ =~ /$putattr/)
 	{
-		$putattr_chars = $1;
-		$starty = $2;
-		$startx = $3;
+		my $putattr_chars = $1;
+		my $starty = $2;
+		my $startx = $3;
 		while (<STDIN>)
 		{
 			if ($_ =~ /$putattr/) {
@@ -111,8 +121,8 @@
 	# Compactify runs of waddnstr calls (TR_CALLS)
 	if ($_ =~ /$waddnstr/)
 	{
-		$waddnstr_chars = $2;
-		$winaddr = $1;
+		my $waddnstr_chars = $2;
+		my $winaddr = $1;
 		while (<STDIN>)
 		{
 			if ($_ =~ /$waddnstr/ && $1 eq $winaddr) {
@@ -121,7 +131,7 @@
 				last;
 			}
 		}
-		$winaddstr = &transaddr($winaddr);
+		my $winaddstr = &transaddr($winaddr);
 		print "RUN of waddnstr()s: $winaddr, \"$waddnstr_chars\"\n";
 		redo CLASSIFY;
 	}
@@ -129,8 +139,8 @@
 	# More transformations can go here
 
 	# Repeated runs of anything
-	$anyline = &transaddr($_);
-	$repeatcount = 1;
+	my $anyline = &transaddr($_);
+	my $repeatcount = 1;
 	while (<STDIN>) {
 	    if (&transaddr($_) eq $anyline) {
 		$repeatcount++;
diff -Naur ncurses-5.4.orig/test/view.c ncurses-5.4/test/view.c
--- ncurses-5.4.orig/test/view.c	2003-05-17 21:58:43.000000000 +0000
+++ ncurses-5.4/test/view.c	2005-05-13 04:09:57.000000000 +0000
@@ -23,13 +23,15 @@
  * scroll operation worked, and the refresh() code only had to do a
  * partial repaint.
  *
- * $Id: view.c,v 1.57 2003/05/17 21:58:43 tom Exp $
+ * $Id: view.c,v 1.61 2005/04/16 16:32:49 tom Exp $
  */
 
 #include <time.h>
 
 #include <test.priv.h>
 
+#undef CTRL			/* conflict on AIX 5.2 with <sys/ioctl.h> */
+
 #if HAVE_TERMIOS_H
 # include <termios.h>
 #else
@@ -69,8 +71,9 @@
 static bool try_color = FALSE;
 
 static char *fname;
-static NCURSES_CH_T **my_lines;
+static NCURSES_CH_T **vec_lines;
 static NCURSES_CH_T **lptr;
+static int num_lines;
 
 static void
 usage(void)
@@ -164,7 +167,8 @@
 	if (setcchar(dst + k, wstr, 0, 0, NULL) == OK)
 	    ++k;
     }
-    setcchar(dst + k, L"", 0, 0, NULL);
+    wstr[0] = L'\0';
+    setcchar(dst + k, wstr, 0, 0, NULL);
 #else
     dst[k] = 0;
 #endif
@@ -180,7 +184,6 @@
     int i;
     int my_delay = 0;
     NCURSES_CH_T **olptr;
-    int length = 0;
     int value = 0;
     bool done = FALSE;
     bool got_number = FALSE;
@@ -220,7 +223,7 @@
 #endif
 #ifdef TRACE
 	case 'T':
-	    trace(atoi(optarg));
+	    trace((unsigned) atoi(optarg));
 	    break;
 	case 't':
 	    trace(TRACE_CALLS);
@@ -233,7 +236,7 @@
     if (optind + 1 != argc)
 	usage();
 
-    if ((my_lines = typeMalloc(NCURSES_CH_T *, MAXLINES + 2)) == 0)
+    if ((vec_lines = typeMalloc(NCURSES_CH_T *, MAXLINES + 2)) == 0)
 	usage();
 
     fname = argv[optind];
@@ -247,7 +250,7 @@
 #endif
 
     /* slurp the file */
-    for (lptr = &my_lines[0]; (lptr - my_lines) < MAXLINES; lptr++) {
+    for (lptr = &vec_lines[0]; (lptr - vec_lines) < MAXLINES; lptr++) {
 	char temp[BUFSIZ], *s, *d;
 	int col;
 
@@ -280,7 +283,7 @@
 	*lptr = ch_dup(temp);
     }
     (void) fclose(fp);
-    length = lptr - my_lines;
+    num_lines = lptr - vec_lines;
 
     (void) initscr();		/* initialize the curses library */
     keypad(stdscr, TRUE);	/* enable keyboard mapping */
@@ -300,7 +303,7 @@
 	}
     }
 
-    lptr = my_lines;
+    lptr = vec_lines;
     while (!done) {
 	int n, c;
 
@@ -323,7 +326,7 @@
 		    mvprintw(0, 0, "Count: ");
 		    clrtoeol();
 		}
-		addch(c);
+		addch(UChar(c));
 		value = 10 * value + (c - '0');
 		got_number = TRUE;
 	    } else
@@ -342,7 +345,7 @@
 	case 'n':
 	    olptr = lptr;
 	    for (i = 0; i < n; i++)
-		if ((lptr - my_lines) < (length - LINES + 1))
+		if ((lptr - vec_lines) < (num_lines - LINES + 1))
 		    lptr++;
 		else
 		    break;
@@ -353,7 +356,7 @@
 	case 'p':
 	    olptr = lptr;
 	    for (i = 0; i < n; i++)
-		if (lptr > my_lines)
+		if (lptr > vec_lines)
 		    lptr--;
 		else
 		    break;
@@ -362,15 +365,15 @@
 
 	case 'h':
 	case KEY_HOME:
-	    lptr = my_lines;
+	    lptr = vec_lines;
 	    break;
 
 	case 'e':
 	case KEY_END:
-	    if (length > LINES)
-		lptr = my_lines + length - LINES + 1;
+	    if (num_lines > LINES)
+		lptr = vec_lines + num_lines - LINES + 1;
 	    else
-		lptr = my_lines;
+		lptr = vec_lines;
 	    break;
 
 	case 'r':
@@ -428,6 +431,15 @@
 finish(int sig)
 {
     endwin();
+#if NO_LEAKS
+    if (vec_lines != 0) {
+	int n;
+	for (n = 0; n < num_lines; ++n) {
+	    free(vec_lines[n]);
+	}
+	free(vec_lines);
+    }
+#endif
     ExitProgram(sig != 0 ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
@@ -491,7 +503,7 @@
     scrollok(stdscr, FALSE);	/* prevent screen from moving */
     for (i = 1; i < LINES; i++) {
 	move(i, 0);
-	printw("%3ld:", (long) (lptr + i - my_lines));
+	printw("%3ld:", (long) (lptr + i - vec_lines));
 	clrtoeol();
 	if ((s = lptr[i - 1]) != 0) {
 	    int len = ch_len(s);
diff -Naur ncurses-5.4.orig/test/worm.c ncurses-5.4/test/worm.c
--- ncurses-5.4.orig/test/worm.c	2002-06-29 23:32:18.000000000 +0000
+++ ncurses-5.4/test/worm.c	2005-05-13 04:09:51.000000000 +0000
@@ -34,7 +34,7 @@
   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.37 2002/06/29 23:32:18 tom Exp $
+  $Id: worm.c,v 1.38 2004/08/07 16:07:52 tom Exp $
 */
 
 #include <test.priv.h>
@@ -361,7 +361,7 @@
 #endif
 	    /*
 	     * Make it simple to put this into single-step mode, or resume
-	     * normal operation -TD
+	     * normal operation -T.Dickey
 	     */
 	    if (ch == 'q') {
 		cleanup();
diff -Naur ncurses-5.4.orig/test/xmas.c ncurses-5.4/test/xmas.c
--- ncurses-5.4.orig/test/xmas.c	2002-06-29 23:32:18.000000000 +0000
+++ ncurses-5.4/test/xmas.c	2005-05-13 04:09:57.000000000 +0000
@@ -92,7 +92,7 @@
 /******************************************************************************/
 
 /*
- * $Id: xmas.c,v 1.19 2002/06/29 23:32:18 tom Exp $
+ * $Id: xmas.c,v 1.20 2005/04/16 16:34:38 tom Exp $
  */
 #include <test.priv.h>
 
@@ -156,7 +156,7 @@
 	static bool *pairs;
 	int n = (color + 1);
 	if (pairs == 0)
-	    pairs = (bool *) calloc(COLORS + 1, sizeof(bool));
+	    pairs = (bool *) calloc((unsigned) (COLORS + 1), sizeof(bool));
 	if (!pairs[n]) {
 	    init_pair(n, color, my_bg);
 	    pairs[n] = TRUE;
diff -Naur ncurses-5.4.orig/test/xterm-16color.dat ncurses-5.4/test/xterm-16color.dat
--- ncurses-5.4.orig/test/xterm-16color.dat	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/test/xterm-16color.dat	2005-05-13 04:09:51.000000000 +0000
@@ -0,0 +1,26 @@
+# $Id: xterm-16color.dat,v 1.1 2004/05/22 23:14:42 tom Exp $
+# This illustrates the predefined colors for XFree86 xterm's "xterm-16color". 
+# If you set $TERM to "xterm-88color" (and have xterm compiled to support the
+# 88-color or 256-color feature), you can use the ncurses 'd' screen to
+# manipulate the colors shown in the screen.  The 'd' screen is limited to
+# the first 16 colors, and xterm happens to use the same first 16 colors in
+# the extended color models that support initc.
+#
+# The colors shown are for xterm patch #189.
+scale:255
+0:	  0   0   0		black
+1:	205   0	  0		red3
+2:	  0 205	  0		green3
+3:	205 205	  0		yellow3
+4:	 30 144 255		DodgerBlue1
+5:	205   0 205		magenta3
+6:	  0 205 205		cyan3
+7:	229 229 229 		gray90
+8:	127 127 127 		gray50
+9:	255   0   0		red
+10:	  0 255   0		green
+11:	255 255   0		yellow
+12:	 99 184 255		SteelBlue1
+13:	255   0 255		magenta
+14:	  0 255 255		cyan
+15:	255 255 255		white
diff -Naur ncurses-5.4.orig/test/xterm-88color.dat ncurses-5.4/test/xterm-88color.dat
--- ncurses-5.4.orig/test/xterm-88color.dat	1970-01-01 00:00:00.000000000 +0000
+++ ncurses-5.4/test/xterm-88color.dat	2005-05-13 04:09:51.000000000 +0000
@@ -0,0 +1,98 @@
+# $Id: xterm-88color.dat,v 1.1 2005/01/28 21:11:53 tom Exp $
+# This illustrates the predefined colors for XFree86 xterm's "xterm-16color". 
+# If you set $TERM to "xterm-88color" (and have xterm compiled to support the
+# 88-color or 256-color feature), you can use the ncurses 'd' screen to
+# manipulate the colors shown in the screen.  The 'd' screen is limited to
+# the first 16 colors, and xterm happens to use the same first 16 colors in
+# the extended color models that support initc.
+#
+# The colors shown are for xterm patch #189.
+scale:255
+0:	  0   0   0		black
+1:	205   0	  0		red3
+2:	  0 205	  0		green3
+3:	205 205	  0		yellow3
+4:	 30 144 255		DodgerBlue1
+5:	205   0 205		magenta3
+6:	  0 205 205		cyan3
+7:	229 229 229 		gray90
+8:	127 127 127 		gray50
+9:	255   0   0		red
+10:	  0 255   0		green
+11:	255 255   0		yellow
+12:	 99 184 255		SteelBlue1
+13:	255   0 255		magenta
+14:	  0 255 255		cyan
+15:	255 255 255		white
+16:	  0   0   0
+17:	  0   0 139
+18:	  0   0 205
+19:	  0   0 255
+20:	  0 139   0
+21:	  0 139 139
+22:	  0 139 205
+23:	  0 139 255
+24:	  0 205   0
+25:	  0 205 139
+26:	  0 205 205
+27:	  0 205 255
+28:	  0 255   0
+29:	  0 255 139
+30:	  0 255 205
+31:	  0 255 255
+32:	139   0   0
+33:	139   0 139
+34:	139   0 205
+35:	139   0 255
+36:	139 139   0
+37:	139 139 139
+38:	139 139 205
+39:	139 139 255
+40:	139 205   0
+41:	139 205 139
+42:	139 205 205
+43:	139 205 255
+44:	139 255   0
+45:	139 255 139
+46:	139 255 205
+47:	139 255 255
+48:	205   0   0
+49:	205   0 139
+50:	205   0 205
+51:	205   0 255
+52:	205 139   0
+53:	205 139 139
+54:	205 139 205
+55:	205 139 255
+56:	205 205   0
+57:	205 205 139
+58:	205 205 205
+59:	205 205 255
+60:	205 255   0
+61:	205 255 139
+62:	205 255 205
+63:	205 255 255
+64:	255   0   0
+65:	255   0 139
+66:	255   0 205
+67:	255   0 255
+68:	255 139   0
+69:	255 139 139
+70:	255 139 205
+71:	255 139 255
+72:	255 205   0
+73:	255 205 139
+74:	255 205 205
+75:	255 205 255
+76:	255 255   0
+77:	255 255 139
+78:	255 255 205
+79:	255 255 255
+80:	 46  46  46
+81:	 92  92  92
+82:	113 113 113
+83:	139 139 139
+84:	162 162 162
+85:	185 185 185
+86:	208 208 208
+87:	231 231 231
