summaryrefslogtreecommitdiff
path: root/form
diff options
context:
space:
mode:
Diffstat (limited to 'form')
-rw-r--r--form/Makefile.in18
-rw-r--r--form/fld_arg.c6
-rw-r--r--form/fld_def.c29
-rw-r--r--form/fld_dup.c8
-rw-r--r--form/fld_ftchoice.c6
-rw-r--r--form/fld_ftlink.c10
-rw-r--r--form/fld_just.c6
-rw-r--r--form/fld_link.c8
-rw-r--r--form/fld_max.c10
-rw-r--r--form/fld_move.c8
-rw-r--r--form/fld_page.c8
-rw-r--r--form/fld_stat.c8
-rw-r--r--form/form.h12
-rw-r--r--form/form.priv.h29
-rw-r--r--form/frm_data.c6
-rw-r--r--form/frm_def.c24
-rw-r--r--form/frm_driver.c500
-rw-r--r--form/frm_hook.c6
-rw-r--r--form/frm_opts.c18
-rw-r--r--form/frm_page.c6
-rw-r--r--form/frm_post.c8
-rw-r--r--form/frm_req_name.c21
-rw-r--r--form/fty_generic.c6
-rw-r--r--form/fty_int.c7
-rw-r--r--form/fty_num.c7
-rw-r--r--form/fty_regex.c17
-rw-r--r--form/llib-lformtw11
-rw-r--r--form/llib-lformw11
28 files changed, 580 insertions, 234 deletions
diff --git a/form/Makefile.in b/form/Makefile.in
index 1a07e14..e5680cd 100644
--- a/form/Makefile.in
+++ b/form/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.53 2010/11/27 21:45:27 tom Exp $
+# $Id: Makefile.in,v 1.60 2014/12/20 20:27:55 tom Exp $
##############################################################################
-# Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. #
+# Copyright (c) 1998-2013,2014 Free 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"), #
@@ -51,14 +51,21 @@ o = .@OBJEXT@
MODEL = @DFT_LWR_MODEL@
DESTDIR = @DESTDIR@
+top_srcdir = @top_srcdir@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
includedir = @includedir@
+includesubdir = @includesubdir@
+
+INCLUDEDIR = $(DESTDIR)$(includedir)$(includesubdir)
+
+PACKAGE = @PACKAGE@
LIBTOOL = @LIBTOOL@
+LIBTOOL_OPTS = @LIBTOOL_OPTS@ @EXPORT_SYMS@
LIBTOOL_CLEAN = @LIB_CLEAN@
LIBTOOL_COMPILE = @LIB_COMPILE@
LIBTOOL_LINK = @LIB_LINK@
@@ -84,7 +91,7 @@ CC = @CC@
CPP = @CPP@
CFLAGS = @CFLAGS@
-CPPFLAGS = -I@top_srcdir@/ncurses -DHAVE_CONFIG_H @CPPFLAGS@
+CPPFLAGS = -I${top_srcdir}/ncurses -DHAVE_CONFIG_H @CPPFLAGS@
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
@@ -102,6 +109,9 @@ LDFLAGS = @LDFLAGS@ @LD_MODEL@ @LIBS@
SHLIB_DIRS = -L../lib
SHLIB_LIST = $(SHLIB_DIRS) -lncurses@LIB_SUFFIX@ @SHLIB_LIST@
+RPATH_LIST = @RPATH_LIST@
+RESULTING_SYMS = @RESULTING_SYMS@
+VERSIONED_SYMS = @VERSIONED_SYMS@
MK_SHARED_LIB = @MK_SHARED_LIB@
NCURSES_MAJOR = @NCURSES_MAJOR@
@@ -111,7 +121,7 @@ ABI_VERSION = @cf_cv_abi_version@
RANLIB = @LIB_PREP@
-LIBRARIES = @LIBS_TO_MAKE@
+LIBRARIES = @Libs_To_Make@
LINT = @LINT@
LINT_OPTS = @LINT_OPTS@
diff --git a/form/fld_arg.c b/form/fld_arg.c
index a07bdb1..001c1d1 100644
--- a/form/fld_arg.c
+++ b/form/fld_arg.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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_arg.c,v 1.12 2010/01/23 21:14:35 tom Exp $")
+MODULE_ID("$Id: fld_arg.c,v 1.13 2012/06/10 00:27:49 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -71,7 +71,7 @@ set_fieldtype_arg(FIELDTYPE *typ,
if (typ != 0 && make_arg != (void *)0)
{
- typ->status |= _HAS_ARGS;
+ SetStatus(typ, _HAS_ARGS);
typ->makearg = make_arg;
typ->copyarg = copy_arg;
typ->freearg = free_arg;
diff --git a/form/fld_def.c b/form/fld_def.c
index 6d7bd34..b18462f 100644
--- a/form/fld_def.c
+++ b/form/fld_def.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2007,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2012,2014 Free 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_def.c,v 1.38 2010/01/23 21:14:35 tom Exp $")
+MODULE_ID("$Id: fld_def.c,v 1.41 2014/07/26 21:08:55 tom Exp $")
/* this can't be readonly */
static FIELD default_field =
@@ -53,7 +53,7 @@ static FIELD default_field =
(int)' ', /* pad */
A_NORMAL, /* fore */
A_NORMAL, /* back */
- ALL_FIELD_OPTS, /* opts */
+ STD_FIELD_OPTS, /* opts */
(FIELD *)0, /* snext */
(FIELD *)0, /* sprev */
(FIELD *)0, /* link */
@@ -65,8 +65,7 @@ static FIELD default_field =
NCURSES_FIELD_EXTENSION
};
-NCURSES_EXPORT_VAR(FIELD *)
-_nc_Default_Field = &default_field;
+NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field = &default_field;
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -186,10 +185,12 @@ _nc_Free_Argument(const FIELDTYPE *typ, TypeArgument *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);
+ if (argp != 0)
+ {
+ _nc_Free_Argument(typ->left, argp->left);
+ _nc_Free_Argument(typ->right, argp->right);
+ free(argp);
+ }
}
else
{
@@ -293,14 +294,14 @@ new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
{
T((T_CREATE("field %p"), (void *)New_Field));
*New_Field = default_field;
- New_Field->rows = rows;
- New_Field->cols = cols;
+ New_Field->rows = (short)rows;
+ New_Field->cols = (short)cols;
New_Field->drows = rows + nrow;
New_Field->dcols = cols;
- New_Field->frow = frow;
- New_Field->fcol = fcol;
+ New_Field->frow = (short)frow;
+ New_Field->fcol = (short)fcol;
New_Field->nrow = nrow;
- New_Field->nbuf = nbuf;
+ New_Field->nbuf = (short)nbuf;
New_Field->link = New_Field;
#if USE_WIDEC_SUPPORT
diff --git a/form/fld_dup.c b/form/fld_dup.c
index b8e501b..2df40ee 100644
--- a/form/fld_dup.c
+++ b/form/fld_dup.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2007,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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_dup.c,v 1.13 2010/01/23 21:14:35 tom Exp $")
+MODULE_ID("$Id: fld_dup.c,v 1.14 2012/03/11 00:37:16 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -60,8 +60,8 @@ dup_field(FIELD *field, int frow, int fcol)
{
T((T_CREATE("field %p"), (void *)New_Field));
*New_Field = *_nc_Default_Field;
- New_Field->frow = frow;
- New_Field->fcol = fcol;
+ New_Field->frow = (short) frow;
+ New_Field->fcol = (short) fcol;
New_Field->link = New_Field;
New_Field->rows = field->rows;
New_Field->cols = field->cols;
diff --git a/form/fld_ftchoice.c b/form/fld_ftchoice.c
index 3aac5be..0901306 100644
--- a/form/fld_ftchoice.c
+++ b/form/fld_ftchoice.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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.12 2010/01/23 21:14:35 tom Exp $")
+MODULE_ID("$Id: fld_ftchoice.c,v 1.13 2012/06/10 00:27:49 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -56,7 +56,7 @@ set_fieldtype_choice(FIELDTYPE *typ,
if (!typ || !next_choice || !prev_choice)
RETURN(E_BAD_ARGUMENT);
- typ->status |= _HAS_CHOICE;
+ SetStatus(typ, _HAS_CHOICE);
#if NCURSES_INTEROP_FUNCS
typ->enum_next.onext = next_choice;
typ->enum_prev.oprev = prev_choice;
diff --git a/form/fld_ftlink.c b/form/fld_ftlink.c
index c2cd251..e7b1440 100644
--- a/form/fld_ftlink.c
+++ b/form/fld_ftlink.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2007,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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.14 2010/01/23 21:14:35 tom Exp $")
+MODULE_ID("$Id: fld_ftlink.c,v 1.15 2012/06/10 00:27:49 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -62,11 +62,11 @@ link_fieldtype(FIELDTYPE *type1, FIELDTYPE *type2)
{
T((T_CREATE("fieldtype %p"), (void *)nftyp));
*nftyp = *_nc_Default_FieldType;
- nftyp->status |= _LINKED_TYPE;
+ SetStatus(nftyp, _LINKED_TYPE);
if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS))
- nftyp->status |= _HAS_ARGS;
+ SetStatus(nftyp, _HAS_ARGS);
if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE))
- nftyp->status |= _HAS_CHOICE;
+ SetStatus(nftyp, _HAS_CHOICE);
nftyp->left = type1;
nftyp->right = type2;
type1->ref++;
diff --git a/form/fld_just.c b/form/fld_just.c
index 58a1750..dea20b7 100644
--- a/form/fld_just.c
+++ b/form/fld_just.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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.12 2010/01/23 21:14:35 tom Exp $")
+MODULE_ID("$Id: fld_just.c,v 1.13 2012/03/11 00:37:16 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -59,7 +59,7 @@ set_field_just(FIELD *field, int just)
Normalize_Field(field);
if (field->just != just)
{
- field->just = just;
+ field->just = (short) just;
res = _nc_Synchronize_Attributes(field);
}
else
diff --git a/form/fld_link.c b/form/fld_link.c
index 18103be..b6c4768 100644
--- a/form/fld_link.c
+++ b/form/fld_link.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2007,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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.12 2010/01/23 21:14:35 tom Exp $")
+MODULE_ID("$Id: fld_link.c,v 1.13 2012/03/11 00:37:16 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -61,8 +61,8 @@ link_field(FIELD *field, int frow, int fcol)
{
T((T_CREATE("field %p"), (void *)New_Field));
*New_Field = *_nc_Default_Field;
- New_Field->frow = frow;
- New_Field->fcol = fcol;
+ New_Field->frow = (short) frow;
+ New_Field->fcol = (short) fcol;
New_Field->link = field->link;
field->link = New_Field;
diff --git a/form/fld_max.c b/form/fld_max.c
index 5ce918e..6c7fe72 100644
--- a/form/fld_max.c
+++ b/form/fld_max.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2012,2013 Free 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.10 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: fld_max.c,v 1.13 2013/08/24 22:59:28 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -62,13 +62,13 @@ set_max_field(FIELD *field, int maxgrow)
RETURN(E_BAD_ARGUMENT);
}
field->maxgrow = maxgrow;
- field->status &= ~_MAY_GROW;
- if (!(field->opts & O_STATIC))
+ ClrStatus(field, _MAY_GROW);
+ if (!((unsigned)field->opts & O_STATIC))
{
if ((maxgrow == 0) ||
(single_line_field && (field->dcols < maxgrow)) ||
(!single_line_field && (field->drows < maxgrow)))
- field->status |= _MAY_GROW;
+ SetStatus(field, _MAY_GROW);
}
}
RETURN(E_OK);
diff --git a/form/fld_move.c b/form/fld_move.c
index dfba22d..99f5490 100644
--- a/form/fld_move.c
+++ b/form/fld_move.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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.10 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: fld_move.c,v 1.11 2012/03/11 00:37:16 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -56,8 +56,8 @@ move_field(FIELD *field, int frow, int fcol)
if (field->form)
RETURN(E_CONNECTED);
- field->frow = frow;
- field->fcol = fcol;
+ field->frow = (short) frow;
+ field->fcol = (short) fcol;
RETURN(E_OK);
}
diff --git a/form/fld_page.c b/form/fld_page.c
index e4d18c5..bcce4cf 100644
--- a/form/fld_page.c
+++ b/form/fld_page.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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.10 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: fld_page.c,v 1.12 2012/06/10 00:12:47 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -54,9 +54,9 @@ set_new_page(FIELD *field, bool new_page_flag)
RETURN(E_CONNECTED);
if (new_page_flag)
- field->status |= _NEWPAGE;
+ SetStatus(field, _NEWPAGE);
else
- field->status &= ~_NEWPAGE;
+ ClrStatus(field, _NEWPAGE);
RETURN(E_OK);
}
diff --git a/form/fld_stat.c b/form/fld_stat.c
index 46f89e6..9bbe76e 100644
--- a/form/fld_stat.c
+++ b/form/fld_stat.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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.12 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: fld_stat.c,v 1.14 2012/06/10 00:13:09 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -51,9 +51,9 @@ set_field_status(FIELD *field, bool status)
Normalize_Field(field);
if (status)
- field->status |= _CHANGED;
+ SetStatus(field, _CHANGED);
else
- field->status &= ~_CHANGED;
+ ClrStatus(field, _CHANGED);
RETURN(E_OK);
}
diff --git a/form/form.h b/form/form.h
index f52893b..09856dc 100644
--- a/form/form.h
+++ b/form/form.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2013,2014 Free 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,10 +30,11 @@
* Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
-/* $Id: form.h,v 0.21 2009/11/07 19:31:11 tom Exp $ */
+/* $Id: form.h,v 0.24 2014/07/26 20:52:28 tom Exp $ */
#ifndef FORM_H
#define FORM_H
+/* *INDENT-OFF*/
#include <curses.h>
#include <eti.h>
@@ -203,6 +204,7 @@ typedef void (*Form_Hook)(FORM *);
#define O_NULLOK (0x0080U)
#define O_PASSOK (0x0100U)
#define O_STATIC (0x0200U)
+#define O_DYNAMIC_JUSTIFY (0x0400U) /* ncurses extension */
/* form options */
#define O_NL_OVERLOAD (0x0001U)
@@ -396,6 +398,9 @@ extern NCURSES_EXPORT(int) post_form (FORM *);
extern NCURSES_EXPORT(int) unpost_form (FORM *);
extern NCURSES_EXPORT(int) pos_form_cursor (FORM *);
extern NCURSES_EXPORT(int) form_driver (FORM *,int);
+# if NCURSES_WIDECHAR
+extern NCURSES_EXPORT(int) form_driver_w (FORM *,int,wchar_t);
+# endif
extern NCURSES_EXPORT(int) set_form_userptr (FORM *,void *);
extern NCURSES_EXPORT(int) set_form_opts (FORM *,Form_Options);
extern NCURSES_EXPORT(int) form_opts_on (FORM *,Form_Options);
@@ -418,5 +423,6 @@ extern NCURSES_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **);
#ifdef __cplusplus
}
#endif
+/* *INDENT-ON*/
-#endif /* FORM_H */
+#endif /* FORM_H */
diff --git a/form/form.priv.h b/form/form.priv.h
index 49250b4..4d1dfe7 100644
--- a/form/form.priv.h
+++ b/form/form.priv.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2012,2014 Free 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,11 +30,11 @@
* Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
-/* $Id: form.priv.h,v 0.32 2009/11/07 21:26:43 tom Exp $ */
+/* $Id: form.priv.h,v 0.38 2014/11/01 13:56:14 tom Exp $ */
#ifndef FORM_PRIV_H
#define FORM_PRIV_H 1
-
+/* *INDENT-OFF*/
#include "curses.priv.h"
#include "mf_common.h"
@@ -119,12 +119,14 @@ extern NCURSES_EXPORT_VAR(FIELDTYPE *) _nc_Default_FieldType;
/* Calculate the total size of all buffers for this field */
#define Total_Buffer_Size(field) \
- ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) * sizeof(FIELD_CELL) )
+ ( (size_t)(Buffer_Length(field) + 1) * (size_t)(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)
+#define Field_Has_Option(f,o) ((((unsigned)(f)->opts) & o) != 0)
+
/* Logic to determine whether or not a field is 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)
@@ -146,7 +148,7 @@ TypeArgument;
O_NL_OVERLOAD |\
O_BS_OVERLOAD )
-#define ALL_FIELD_OPTS (Field_Options)( \
+#define STD_FIELD_OPTS (Field_Options)( \
O_VISIBLE |\
O_ACTIVE |\
O_PUBLIC |\
@@ -156,7 +158,11 @@ TypeArgument;
O_AUTOSKIP|\
O_NULLOK |\
O_PASSOK |\
- O_STATIC )
+ O_STATIC)
+
+#define ALL_FIELD_OPTS (Field_Options)( \
+ STD_FIELD_OPTS |\
+ O_DYNAMIC_JUSTIFY)
#define C_BLANK ' '
#define is_blank(c) ((c)==C_BLANK)
@@ -214,11 +220,11 @@ extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *);
#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)
+#define returnField(code) TRACE_RETURN1(code,field)
+#define returnFieldPtr(code) TRACE_RETURN1(code,field_ptr)
+#define returnForm(code) TRACE_RETURN1(code,form)
+#define returnFieldType(code) TRACE_RETURN1(code,field_type)
+#define returnFormHook(code) TRACE_RETURN1(code,form_hook)
extern NCURSES_EXPORT(FIELD **) _nc_retrace_field_ptr (FIELD **);
extern NCURSES_EXPORT(FIELD *) _nc_retrace_field (FIELD *);
@@ -293,5 +299,6 @@ extern NCURSES_EXPORT(Form_Hook) _nc_retrace_form_hook (Form_Hook);
result = ((*buffer || (l < width)) ? FALSE : TRUE); \
}
#endif
+/* *INDENT-ON*/
#endif /* FORM_PRIV_H */
diff --git a/form/frm_data.c b/form/frm_data.c
index 93917d5..a936060 100644
--- a/form/frm_data.c
+++ b/form/frm_data.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2013 Free 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.15 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: frm_data.c,v 1.16 2013/08/24 22:44:05 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -103,7 +103,7 @@ Only_Padding(WINDOW *w, int len, int pad)
}
}
#else
- cell = winch(w);
+ cell = (FIELD_CELL) winch(w);
if (ChCharOf(cell) != ChCharOf(pad))
{
result = FALSE;
diff --git a/form/frm_def.c b/form/frm_def.c
index 86500f2..fd7b56a 100644
--- a/form/frm_def.c
+++ b/form/frm_def.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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_def.c,v 1.25 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: frm_def.c,v 1.26 2012/03/11 00:37:16 tom Exp $")
/* this can't be readonly */
static FORM default_form =
@@ -199,14 +199,14 @@ Connect_Fields(FORM *form, FIELD **fields)
for (j = 0; j < field_cnt; j++)
{
if (j == 0)
- pg->pmin = j;
+ pg->pmin = (short) j;
else
{
if (fields[j]->status & _NEWPAGE)
{
- pg->pmax = j - 1;
+ pg->pmax = (short) (j - 1);
pg++;
- pg->pmin = j;
+ pg->pmin = (short) j;
}
}
@@ -214,14 +214,14 @@ Connect_Fields(FORM *form, FIELD **fields)
maximum_col_in_field = fields[j]->fcol + fields[j]->cols;
if (form->rows < maximum_row_in_field)
- form->rows = maximum_row_in_field;
+ form->rows = (short) maximum_row_in_field;
if (form->cols < maximum_col_in_field)
- form->cols = maximum_col_in_field;
+ form->cols = (short) maximum_col_in_field;
}
- pg->pmax = field_cnt - 1;
- form->maxfield = field_cnt;
- form->maxpage = page_nr;
+ pg->pmax = (short) (field_cnt - 1);
+ form->maxfield = (short) field_cnt;
+ form->maxpage = (short) page_nr;
/* Sort fields on form pages */
for (page_nr = 0; page_nr < form->maxpage; page_nr++)
@@ -230,8 +230,8 @@ Connect_Fields(FORM *form, FIELD **fields)
for (j = form->page[page_nr].pmin; j <= form->page[page_nr].pmax; j++)
{
- fields[j]->index = j;
- fields[j]->page = page_nr;
+ fields[j]->index = (short) j;
+ fields[j]->page = (short) page_nr;
fld = Insert_Field_By_Position(fields[j], fld);
}
if (fld)
diff --git a/form/frm_driver.c b/form/frm_driver.c
index e0892bf..eebde42 100644
--- a/form/frm_driver.c
+++ b/form/frm_driver.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2013,2014 Free 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_driver.c,v 1.98 2010/05/01 21:11:43 tom Exp $")
+MODULE_ID("$Id: frm_driver.c,v 1.115 2014/09/25 21:55:24 tom Exp $")
/*----------------------------------------------------------------------------
This is the core module of the form library. It contains the majority
@@ -172,29 +172,30 @@ static int FE_Delete_Previous(FORM *);
instead of a derived window because it contains invisible parts.
This is true for non-public fields and for scrollable fields. */
#define Has_Invisible_Parts(field) \
- (!((field)->opts & O_PUBLIC) || \
+ (!(Field_Has_Option(field, O_PUBLIC)) || \
Is_Scroll_Field(field))
/* Logic to decide whether or not a field needs justification */
#define Justification_Allowed(field) \
(((field)->just != NO_JUSTIFICATION) && \
(Single_Line_Field(field)) && \
- (((field)->dcols == (field)->cols) && \
- ((field)->opts & O_STATIC)) )
+ ((Field_Has_Option(field, O_STATIC) && \
+ ((field)->dcols == (field)->cols)) || \
+ Field_Has_Option(field, O_DYNAMIC_JUSTIFY)))
/* Logic to determine whether or not a dynamic field may still grow */
#define Growable(field) ((field)->status & _MAY_GROW)
/* Macro to set the attributes for a fields window */
#define Set_Field_Window_Attributes(field,win) \
-( wbkgdset((win),(chtype)((field)->pad | (field)->back)), \
- (void) wattrset((win),(field)->fore) )
+( wbkgdset((win),(chtype)((chtype)((field)->pad) | (field)->back)), \
+ (void) wattrset((win), (int)(field)->fore) )
/* Logic to decide whether or not a field really appears on the form */
#define Field_Really_Appears(field) \
((field->form) &&\
(field->form->status & _POSTED) &&\
- (field->opts & O_VISIBLE) &&\
+ (Field_Has_Option(field, O_VISIBLE)) &&\
(field->page == field->form->curpage))
/* Logic to determine whether or not we are on the first position in the
@@ -601,8 +602,8 @@ Synchronize_Buffer(FORM *form)
{
if (form->status & _WINDOW_MODIFIED)
{
- form->status &= ~_WINDOW_MODIFIED;
- form->status |= _FCHECK_REQUIRED;
+ ClrStatus(form, _WINDOW_MODIFIED);
+ SetStatus(form, _FCHECK_REQUIRED);
Window_To_Buffer(form, form->current);
wmove(form->w, form->currow, form->curcol);
}
@@ -653,7 +654,7 @@ Field_Grown(FIELD *field, int amount)
growth = Minimum(field->maxgrow - field->dcols, growth);
field->dcols += growth;
if (field->dcols == field->maxgrow)
- field->status &= ~_MAY_GROW;
+ ClrStatus(field, _MAY_GROW);
}
else
{
@@ -662,7 +663,7 @@ Field_Grown(FIELD *field, int amount)
growth = Minimum(field->maxgrow - field->drows, growth);
field->drows += growth;
if (field->drows == field->maxgrow)
- field->status &= ~_MAY_GROW;
+ ClrStatus(field, _MAY_GROW);
}
/* drows, dcols changed, so we get really the new buffer length */
new_buflen = Buffer_Length(field);
@@ -674,7 +675,7 @@ Field_Grown(FIELD *field, int amount)
field->drows = old_drows;
if ((single_line_field && (field->dcols != field->maxgrow)) ||
(!single_line_field && (field->drows != field->maxgrow)))
- field->status |= _MAY_GROW;
+ SetStatus(field, _MAY_GROW);
}
else
{
@@ -753,7 +754,7 @@ Field_Grown(FIELD *field, int amount)
(field->dcols != field->maxgrow)) ||
(!single_line_field &&
(field->drows != field->maxgrow)))
- field->status |= _MAY_GROW;
+ SetStatus(field, _MAY_GROW);
free(newbuf);
}
}
@@ -860,7 +861,7 @@ _nc_Refresh_Current_Field(FORM *form)
field = form->current;
formwin = Get_Form_Window(form);
- if (field->opts & O_PUBLIC)
+ if (Field_Has_Option(field, O_PUBLIC))
{
if (Is_Scroll_Field(field))
{
@@ -897,19 +898,19 @@ _nc_Refresh_Current_Field(FORM *form)
if (form->currow < form->toprow)
{
form->toprow = form->currow;
- field->status |= _NEWTOP;
+ SetStatus(field, _NEWTOP);
}
if (form->currow >= row_after_bottom)
{
form->toprow = form->currow - field->rows + 1;
- field->status |= _NEWTOP;
+ SetStatus(field, _NEWTOP);
}
if (field->status & _NEWTOP)
{
/* means we have to copy whole range */
first_modified_row = form->toprow;
first_unmodified_row = first_modified_row + field->rows;
- field->status &= ~_NEWTOP;
+ ClrStatus(field, _NEWTOP);
}
else
{
@@ -983,21 +984,22 @@ Perform_Justification(FIELD *field, WINDOW *win)
if (len > 0)
{
- assert(win && (field->drows == 1) && (field->dcols == field->cols));
+ assert(win && (field->drows == 1));
- switch (field->just)
- {
- case JUSTIFY_LEFT:
- break;
- case JUSTIFY_CENTER:
- col = (field->cols - len) / 2;
- break;
- case JUSTIFY_RIGHT:
- col = field->cols - len;
- break;
- default:
- break;
- }
+ if (field->cols - len >= 0)
+ switch (field->just)
+ {
+ case JUSTIFY_LEFT:
+ break;
+ case JUSTIFY_CENTER:
+ col = (field->cols - len) / 2;
+ break;
+ case JUSTIFY_RIGHT:
+ col = field->cols - len;
+ break;
+ default:
+ break;
+ }
wmove(win, 0, col);
myADDNSTR(win, bp, len);
@@ -1111,27 +1113,27 @@ Display_Or_Erase_Field(FIELD *field, bool bEraseFlag)
return E_SYSTEM_ERROR;
else
{
- if (field->opts & O_VISIBLE)
+ if (Field_Has_Option(field, O_VISIBLE))
{
Set_Field_Window_Attributes(field, win);
}
else
{
- (void)wattrset(win, WINDOW_ATTRS(fwin));
+ (void)wattrset(win, (int)WINDOW_ATTRS(fwin));
}
werase(win);
}
if (!bEraseFlag)
{
- if (field->opts & O_PUBLIC)
+ if (Field_Has_Option(field, O_PUBLIC))
{
if (Justification_Allowed(field))
Perform_Justification(field, win);
else
Buffer_To_Window(field, win);
}
- field->status &= ~_NEWTOP;
+ ClrStatus(field, _NEWTOP);
}
wsyncup(win);
delwin(win);
@@ -1170,18 +1172,18 @@ Synchronize_Field(FIELD *field)
form->currow = form->curcol = form->toprow = form->begincol = 0;
werase(form->w);
- if ((field->opts & O_PUBLIC) && Justification_Allowed(field))
+ if ((Field_Has_Option(field, O_PUBLIC)) && Justification_Allowed(field))
Undo_Justification(field, form->w);
else
Buffer_To_Window(field, form->w);
- field->status |= _NEWTOP;
+ SetStatus(field, _NEWTOP);
res = _nc_Refresh_Current_Field(form);
}
else
res = Display_Field(field);
}
- field->status |= _CHANGED;
+ SetStatus(field, _CHANGED);
return (res);
}
@@ -1211,7 +1213,7 @@ Synchronize_Linked_Fields(FIELD *field)
return (E_SYSTEM_ERROR);
for (linked_field = field->link;
- linked_field != field;
+ (linked_field != field) && (linked_field != 0);
linked_field = linked_field->link)
{
if (((syncres = Synchronize_Field(linked_field)) != E_OK) &&
@@ -1256,7 +1258,7 @@ _nc_Synchronize_Attributes(FIELD *field)
werase(form->w);
wmove(form->w, form->currow, form->curcol);
- if (field->opts & O_PUBLIC)
+ if (Field_Has_Option(field, O_PUBLIC))
{
if (Justification_Allowed(field))
Undo_Justification(field, form->w);
@@ -1272,7 +1274,7 @@ _nc_Synchronize_Attributes(FIELD *field)
field->rows - 1, field->cols - 1, 0);
wsyncup(formwin);
Buffer_To_Window(field, form->w);
- field->status |= _NEWTOP; /* fake refresh to paint all */
+ SetStatus(field, _NEWTOP); /* fake refresh to paint all */
_nc_Refresh_Current_Field(form);
}
}
@@ -1326,34 +1328,34 @@ _nc_Synchronize_Options(FIELD *field, Field_Options newopts)
field->opts = oldopts;
returnCode(E_CURRENT);
}
- if ((form->curpage == field->page))
+ if (form->curpage == field->page)
{
- if (changed_opts & O_VISIBLE)
+ if ((unsigned)changed_opts & O_VISIBLE)
{
- if (newopts & O_VISIBLE)
+ if ((unsigned)newopts & O_VISIBLE)
res = Display_Field(field);
else
res = Erase_Field(field);
}
else
{
- if ((changed_opts & O_PUBLIC) &&
- (newopts & O_VISIBLE))
+ if (((unsigned)changed_opts & O_PUBLIC) &&
+ ((unsigned)newopts & O_VISIBLE))
res = Display_Field(field);
}
}
}
}
- if (changed_opts & O_STATIC)
+ if ((unsigned)changed_opts & O_STATIC)
{
bool single_line_field = Single_Line_Field(field);
int res2 = E_OK;
- if (newopts & O_STATIC)
+ if ((unsigned)newopts & O_STATIC)
{
/* the field becomes now static */
- field->status &= ~_MAY_GROW;
+ ClrStatus(field, _MAY_GROW);
/* if actually we have no hidden columns, justification may
occur again */
if (single_line_field &&
@@ -1371,7 +1373,7 @@ _nc_Synchronize_Options(FIELD *field, Field_Options newopts)
(single_line_field && (field->dcols < field->maxgrow)) ||
(!single_line_field && (field->drows < field->maxgrow)))
{
- field->status |= _MAY_GROW;
+ SetStatus(field, _MAY_GROW);
/* a field with justification now changes its behavior,
so we must redisplay it */
if (single_line_field &&
@@ -1424,18 +1426,18 @@ _nc_Set_Current_Field(FORM *form, FIELD *newfield)
!(form->status & _POSTED))
{
if ((form->w) &&
- (field->opts & O_VISIBLE) &&
+ (Field_Has_Option(field, O_VISIBLE)) &&
(field->form->curpage == field->page))
{
_nc_Refresh_Current_Field(form);
- if (field->opts & O_PUBLIC)
+ if (Field_Has_Option(field, O_PUBLIC))
{
if (field->drows > field->rows)
{
if (form->toprow == 0)
- field->status &= ~_NEWTOP;
+ ClrStatus(field, _NEWTOP);
else
- field->status |= _NEWTOP;
+ SetStatus(field, _NEWTOP);
}
else
{
@@ -1444,7 +1446,24 @@ _nc_Set_Current_Field(FORM *form, FIELD *newfield)
Window_To_Buffer(form, field);
werase(form->w);
Perform_Justification(field, form->w);
- wsyncup(form->w);
+ if (Field_Has_Option(field, O_DYNAMIC_JUSTIFY) &&
+ (form->w->_parent == 0))
+ {
+ copywin(form->w,
+ Get_Form_Window(form),
+ 0,
+ 0,
+ field->frow,
+ field->fcol,
+ field->frow,
+ field->cols + field->fcol - 1,
+ 0);
+ wsyncup(Get_Form_Window(form));
+ }
+ else
+ {
+ wsyncup(form->w);
+ }
}
}
}
@@ -1469,7 +1488,7 @@ _nc_Set_Current_Field(FORM *form, FIELD *newfield)
delwin(form->w);
form->w = new_window;
- form->status &= ~_WINDOW_MODIFIED;
+ ClrStatus(form, _WINDOW_MODIFIED);
Set_Field_Window_Attributes(field, form->w);
if (Has_Invisible_Parts(field))
@@ -1998,7 +2017,7 @@ Vertical_Scrolling(int (*const fct) (FORM *), FORM *form)
{
res = fct(form);
if (res == E_OK)
- form->current->status |= _NEWTOP;
+ SetStatus(form->current, _NEWTOP);
}
return (res);
}
@@ -2430,7 +2449,7 @@ Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM *form)
int result = E_REQUEST_DENIED;
bool Last_Row = ((field->drows - 1) == form->currow);
- if ((field->opts & O_WRAP) && /* wrapping wanted */
+ if ((Field_Has_Option(field, 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 */
@@ -2513,7 +2532,7 @@ Field_Editing(int (*const fct) (FORM *), FORM *form)
editable fields.
*/
if ((fct == FE_Delete_Previous) &&
- (form->opts & O_BS_OVERLOAD) &&
+ ((unsigned)form->opts & O_BS_OVERLOAD) &&
First_Position_In_Current_Field(form))
{
res = Inter_Field_Navigation(FN_Previous_Field, form);
@@ -2522,7 +2541,7 @@ Field_Editing(int (*const fct) (FORM *), FORM *form)
{
if (fct == FE_New_Line)
{
- if ((form->opts & O_NL_OVERLOAD) &&
+ if (((unsigned)form->opts & O_NL_OVERLOAD) &&
First_Position_In_Current_Field(form))
{
res = Inter_Field_Navigation(FN_Next_Field, form);
@@ -2534,11 +2553,11 @@ Field_Editing(int (*const fct) (FORM *), FORM *form)
else
{
/* From now on, everything must be editable */
- if (form->current->opts & O_EDIT)
+ if ((unsigned)form->current->opts & O_EDIT)
{
res = fct(form);
if (res == E_OK)
- form->status |= _WINDOW_MODIFIED;
+ SetStatus(form, _WINDOW_MODIFIED);
}
}
}
@@ -2571,7 +2590,7 @@ FE_New_Line(FORM *form)
if (Last_Row &&
(!(Growable(field) && !Single_Line_Field(field))))
{
- if (!(form->opts & O_NL_OVERLOAD))
+ if (!((unsigned)form->opts & O_NL_OVERLOAD))
returnCode(E_REQUEST_DENIED);
wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
@@ -2579,7 +2598,7 @@ FE_New_Line(FORM *form)
handled in the generic routine. The reason is,
that FN_Next_Field may fail, but the form is
definitively changed */
- form->status |= _WINDOW_MODIFIED;
+ SetStatus(form, _WINDOW_MODIFIED);
returnCode(Inter_Field_Navigation(FN_Next_Field, form));
}
else
@@ -2595,7 +2614,7 @@ FE_New_Line(FORM *form)
wclrtoeol(form->w);
form->currow++;
form->curcol = 0;
- form->status |= _WINDOW_MODIFIED;
+ SetStatus(form, _WINDOW_MODIFIED);
returnCode(E_OK);
}
}
@@ -2605,7 +2624,7 @@ FE_New_Line(FORM *form)
if (Last_Row &&
!(Growable(field) && !Single_Line_Field(field)))
{
- if (!(form->opts & O_NL_OVERLOAD))
+ if (!((unsigned)form->opts & O_NL_OVERLOAD))
returnCode(E_REQUEST_DENIED);
returnCode(Inter_Field_Navigation(FN_Next_Field, form));
}
@@ -2627,7 +2646,7 @@ FE_New_Line(FORM *form)
wmove(form->w, form->currow, form->curcol);
winsertln(form->w);
myADDNSTR(form->w, bp, (int)(t - bp));
- form->status |= _WINDOW_MODIFIED;
+ SetStatus(form, _WINDOW_MODIFIED);
returnCode(E_OK);
}
}
@@ -2926,7 +2945,7 @@ static int
EM_Overlay_Mode(FORM *form)
{
T((T_CALLED("EM_Overlay_Mode(%p)"), (void *)form));
- form->status |= _OVLMODE;
+ SetStatus(form, _OVLMODE);
returnCode(E_OK);
}
@@ -2942,7 +2961,7 @@ static int
EM_Insert_Mode(FORM *form)
{
T((T_CALLED("EM_Insert_Mode(%p)"), (void *)form));
- form->status &= ~_OVLMODE;
+ ClrStatus(form, _OVLMODE);
returnCode(E_OK);
}
@@ -3111,7 +3130,7 @@ Check_Field(FORM *form, FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
if (typ)
{
- if (field->opts & O_NULLOK)
+ if (Field_Has_Option(field, O_NULLOK))
{
FIELD_CELL *bp = field->buf;
@@ -3168,12 +3187,12 @@ _nc_Internal_Validation(FORM *form)
Synchronize_Buffer(form);
if ((form->status & _FCHECK_REQUIRED) ||
- (!(field->opts & O_PASSOK)))
+ (!(Field_Has_Option(field, O_PASSOK))))
{
if (!Check_Field(form, field->type, field, (TypeArgument *)(field->arg)))
return FALSE;
- form->status &= ~_FCHECK_REQUIRED;
- field->status |= _CHANGED;
+ ClrStatus(form, _FCHECK_REQUIRED);
+ SetStatus(field, _CHANGED);
Synchronize_Linked_Fields(field);
}
return TRUE;
@@ -3273,14 +3292,15 @@ _nc_First_Active_Field(FORM *form)
do
{
field = (field == last_on_page) ? first : field + 1;
- if (((*field)->opts & O_VISIBLE))
+ if (Field_Has_Option(*field, O_VISIBLE))
break;
}
while (proposed != (*field));
proposed = *field;
- if ((proposed == *last_on_page) && !(proposed->opts & O_VISIBLE))
+ if ((proposed == *last_on_page) &&
+ !((unsigned)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...
@@ -3816,11 +3836,11 @@ _nc_Set_Form_Page(FORM *form, int page, FIELD *field)
FIELD *last_field, *field_on_page;
werase(Get_Form_Window(form));
- form->curpage = page;
+ form->curpage = (short)page;
last_field = field_on_page = form->field[form->page[page].smin];
do
{
- if (field_on_page->opts & O_VISIBLE)
+ if ((unsigned)field_on_page->opts & O_VISIBLE)
if ((res = Display_Field(field_on_page)) != E_OK)
return (res);
field_on_page = field_on_page->snext;
@@ -3981,6 +4001,94 @@ PN_Last_Page(FORM *form)
Helper routines for the core form driver.
--------------------------------------------------------------------------*/
+# if USE_WIDEC_SUPPORT
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static int Data_Entry_w(FORM * form, wchar_t c)
+|
+| Description : Enter the wide character c into at the current
+| position of the current field of the form.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - driver could not process the request
+| E_SYSTEM_ERROR -
++--------------------------------------------------------------------------*/
+static int
+Data_Entry_w(FORM *form, wchar_t c)
+{
+ FIELD *field = form->current;
+ int result = E_REQUEST_DENIED;
+
+ T((T_CALLED("Data_Entry(%p,%s)"), (void *)form, _tracechtype((chtype)c)));
+ if ((Field_Has_Option(field, O_EDIT))
+#if FIX_FORM_INACTIVE_BUG
+ && (Field_Has_Option(field, O_ACTIVE))
+#endif
+ )
+ {
+ wchar_t given[2];
+ cchar_t temp_ch;
+
+ given[0] = c;
+ given[1] = 1;
+ setcchar(&temp_ch, given, 0, 0, (void *)0);
+ if ((Field_Has_Option(field, O_BLANK)) &&
+ First_Position_In_Current_Field(form) &&
+ !(form->status & _FCHECK_REQUIRED) &&
+ !(form->status & _WINDOW_MODIFIED))
+ werase(form->w);
+
+ if (form->status & _OVLMODE)
+ {
+ wadd_wch(form->w, &temp_ch);
+ }
+ 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);
+
+ if (!There_Is_Room && !Field_Grown(field, 1))
+ RETURN(E_SYSTEM_ERROR);
+
+ wins_wch(form->w, &temp_ch);
+ }
+
+ 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));
+
+ form->status |= _WINDOW_MODIFIED;
+ if (End_Of_Field && !Growable(field) && (Field_Has_Option(field, O_AUTOSKIP)))
+ result = Inter_Field_Navigation(FN_Next_Field, form);
+ else
+ {
+ if (End_Of_Field && Growable(field) && !Field_Grown(field, 1))
+ result = E_SYSTEM_ERROR;
+ else
+ {
+ /*
+ * 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);
+
+ result = E_OK;
+ }
+ }
+ }
+ }
+ RETURN(result);
+}
+# endif
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static int Data_Entry(FORM * form,int c)
@@ -3999,13 +4107,13 @@ Data_Entry(FORM *form, int c)
int result = E_REQUEST_DENIED;
T((T_CALLED("Data_Entry(%p,%s)"), (void *)form, _tracechtype((chtype)c)));
- if ((field->opts & O_EDIT)
+ if ((Field_Has_Option(field, O_EDIT))
#if FIX_FORM_INACTIVE_BUG
- && (field->opts & O_ACTIVE)
+ && (Field_Has_Option(field, O_ACTIVE))
#endif
)
{
- if ((field->opts & O_BLANK) &&
+ if ((Field_Has_Option(field, O_BLANK)) &&
First_Position_In_Current_Field(form) &&
!(form->status & _FCHECK_REQUIRED) &&
!(form->status & _WINDOW_MODIFIED))
@@ -4035,8 +4143,8 @@ Data_Entry(FORM *form, int c)
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))
+ SetStatus(form, _WINDOW_MODIFIED);
+ if (End_Of_Field && !Growable(field) && (Field_Has_Option(field, O_AUTOSKIP)))
result = Inter_Field_Navigation(FN_Next_Field, form);
else
{
@@ -4228,7 +4336,10 @@ form_driver(FORM *form, int c)
if ((c >= MIN_FORM_COMMAND && c <= MAX_FORM_COMMAND) &&
((bindings[c - MIN_FORM_COMMAND].keycode & Key_Mask) == c))
- BI = &(bindings[c - MIN_FORM_COMMAND]);
+ {
+ TR(TRACE_CALLS, ("form_request %s", form_request_name(c)));
+ BI = &(bindings[c - MIN_FORM_COMMAND]);
+ }
if (BI)
{
@@ -4246,7 +4357,7 @@ form_driver(FORM *form, int c)
NULL /* Choice Request is generic */
};
size_t nMethods = (sizeof(Generic_Methods) / sizeof(Generic_Methods[0]));
- size_t method = (BI->keycode >> ID_Shft) & 0xffff; /* see ID_Mask */
+ size_t method = (size_t) ((BI->keycode >> ID_Shft) & 0xffff); /* see ID_Mask */
if ((method >= nMethods) || !(BI->cmd))
res = E_SYSTEM_ERROR;
@@ -4255,9 +4366,13 @@ form_driver(FORM *form, int c)
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);
+ }
}
}
#ifdef NCURSES_MOUSE_VERSION
@@ -4360,6 +4475,195 @@ form_driver(FORM *form, int c)
RETURN(res);
}
+# if USE_WIDEC_SUPPORT
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int form_driver_w(FORM * form,int type,wchar_t c)
+|
+| Description : This is the workhorse of the forms system.
+|
+| Input is either a key code (request) or a wide char
+| returned by e.g. get_wch (). The type must be passed
+| as well,so that we are able to determine whether the char
+| is a multibyte char or a request.
+
+| If it is a request, the form driver executes
+| the request and returns the result. If it is data
+| (printable character), it enters the data into the
+| current position in the current field. If it is not
+| recognized, the form driver assumes it is an application
+| defined command and returns E_UNKNOWN_COMMAND.
+| Application defined command should be defined relative
+| to MAX_FORM_COMMAND, the maximum value of a request.
+|
+| Return Values : E_OK - success
+| E_SYSTEM_ERROR - system error
+| E_BAD_ARGUMENT - an argument is incorrect
+| E_NOT_POSTED - form is not posted
+| E_INVALID_FIELD - field contents are invalid
+| E_BAD_STATE - called from inside a hook routine
+| E_REQUEST_DENIED - request failed
+| E_NOT_CONNECTED - no fields are connected to the form
+| E_UNKNOWN_COMMAND - command not known
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+form_driver_w(FORM *form, int type, wchar_t c)
+{
+ const Binding_Info *BI = (Binding_Info *) 0;
+ int res = E_UNKNOWN_COMMAND;
+
+ T((T_CALLED("form_driver(%p,%d)"), (void *)form, (int)c));
+
+ if (!form)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (!(form->field))
+ RETURN(E_NOT_CONNECTED);
+
+ assert(form->page);
+
+ if (c == (wchar_t)FIRST_ACTIVE_MAGIC)
+ {
+ form->current = _nc_First_Active_Field(form);
+ RETURN(E_OK);
+ }
+
+ assert(form->current &&
+ form->current->buf &&
+ (form->current->form == form)
+ );
+
+ if (form->status & _IN_DRIVER)
+ RETURN(E_BAD_STATE);
+
+ if (!(form->status & _POSTED))
+ RETURN(E_NOT_POSTED);
+
+ /* check if this is a keycode or a (wide) char */
+ if (type == KEY_CODE_YES)
+ {
+ 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 = (size_t) (BI->keycode >> ID_Shft) & 0xffff; /* see ID_Mask */
+
+ if ((method >= nMethods) || !(BI->cmd))
+ res = E_SYSTEM_ERROR;
+ else
+ {
+ Generic_Method fct = Generic_Methods[method];
+
+ if (fct)
+ res = fct(BI->cmd, form);
+ else
+ res = (BI->cmd) (form);
+ }
+ }
+#ifdef NCURSES_MOUSE_VERSION
+ else if (KEY_MOUSE == c)
+ {
+ MEVENT event;
+ WINDOW *win = form->win ? form->win : StdScreen(Get_Form_Screen(form));
+ WINDOW *sub = form->sub ? form->sub : win;
+
+ getmouse(&event);
+ if ((event.bstate & (BUTTON1_CLICKED |
+ BUTTON1_DOUBLE_CLICKED |
+ BUTTON1_TRIPLE_CLICKED))
+ && wenclose(win, event.y, event.x))
+ { /* we react only if the click was in the userwin, that means
+ * inside the form display area or at the decoration window.
+ */
+ int ry = event.y, rx = event.x; /* screen coordinates */
+
+ res = 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)
+ res = form_driver(form, REQ_PREV_FIELD);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ res = form_driver(form, REQ_PREV_PAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ res = form_driver(form, REQ_FIRST_FIELD);
+ }
+ 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)
+ res = form_driver(form, REQ_NEXT_FIELD);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ res = form_driver(form, REQ_NEXT_PAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ res = form_driver(form, REQ_LAST_FIELD);
+ }
+ else if (wenclose(sub, event.y, event.x))
+ { /* Inside the area we try to find the hit item */
+ int i;
+
+ ry = event.y;
+ rx = event.x;
+ if (wmouse_trafo(sub, &ry, &rx, FALSE))
+ {
+ int min_field = form->page[form->curpage].pmin;
+ int max_field = form->page[form->curpage].pmax;
+
+ for (i = min_field; i <= max_field; ++i)
+ {
+ FIELD *field = form->field[i];
+
+ if (Field_Is_Selectable(field)
+ && Field_encloses(field, ry, rx) == E_OK)
+ {
+ res = _nc_Set_Current_Field(form, field);
+ if (res == E_OK)
+ res = _nc_Position_Form_Cursor(form);
+ if (res == E_OK
+ && (event.bstate & BUTTON1_DOUBLE_CLICKED))
+ res = E_UNKNOWN_COMMAND;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ res = E_REQUEST_DENIED;
+ }
+#endif /* NCURSES_MOUSE_VERSION */
+ else if (type == OK)
+ {
+ res = Data_Entry_w(form, c);
+ }
+
+ _nc_Refresh_Current_Field(form);
+ RETURN(res);
+}
+# endif /* USE_WIDEC_SUPPORT */
+
/*----------------------------------------------------------------------------
Field-Buffer manipulation routines.
The effects of setting a buffer are tightly coupled to the core of the form
@@ -4389,8 +4693,8 @@ set_field_buffer(FIELD *field, int buffer, const char *value)
{
FIELD_CELL *p;
int res = E_OK;
- unsigned int i;
- unsigned int len;
+ int i;
+ int len;
#if USE_WIDEC_SUPPORT
FIELD_CELL *widevalue = 0;
@@ -4408,7 +4712,7 @@ set_field_buffer(FIELD *field, int buffer, const char *value)
/* for a growable field we must assume zero terminated strings, because
somehow we have to detect the length of what should be copied.
*/
- unsigned int vlen = strlen(value);
+ int vlen = (int)strlen(value);
if (vlen > len)
{
@@ -4448,10 +4752,10 @@ set_field_buffer(FIELD *field, int buffer, const char *value)
}
else
{
- for (i = 0; i < (unsigned)field->drows; ++i)
+ for (i = 0; i < field->drows; ++i)
{
- (void)mvwin_wchnstr(field->working, 0, i * field->dcols,
- widevalue + (i * field->dcols),
+ (void)mvwin_wchnstr(field->working, 0, (int)i * field->dcols,
+ widevalue + ((int)i * field->dcols),
field->dcols);
}
for (i = 0; i < len; ++i)
@@ -4512,7 +4816,7 @@ field_buffer(const FIELD *field, int buffer)
{
#if USE_WIDEC_SUPPORT
FIELD_CELL *data = Address_Of_Nth_Buffer(field, buffer);
- unsigned need = 0;
+ size_t need = 0;
int size = Buffer_Length(field);
int n;
@@ -4526,7 +4830,7 @@ field_buffer(const FIELD *field, int buffer)
init_mb(state);
next = _nc_wcrtomb(0, data[n].chars[0], &state);
- if (!isEILSEQ(next))
+ if (next > 0)
need += next;
}
}
@@ -4613,14 +4917,14 @@ _nc_Widen_String(char *source, int *lengthp)
{
result[need] = wch;
}
- passed += status;
+ passed += (size_t) status;
++need;
}
else
{
if (pass)
{
- result[need] = source[passed];
+ result[need] = (wchar_t)source[passed];
}
++need;
++passed;
@@ -4633,7 +4937,7 @@ _nc_Widen_String(char *source, int *lengthp)
break;
result = typeCalloc(wchar_t, need);
- *lengthp = need;
+ *lengthp = (int)need;
if (result == 0)
break;
}
diff --git a/form/frm_hook.c b/form/frm_hook.c
index 7daa396..23850bf 100644
--- a/form/frm_hook.c
+++ b/form/frm_hook.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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 "form.priv.h"
-MODULE_ID("$Id: frm_hook.c,v 1.15 2010/01/23 21:12:08 tom Exp $")
+MODULE_ID("$Id: frm_hook.c,v 1.16 2012/03/11 00:37:16 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));\
+ T((T_CALLED("set_" #typ"_"#name"(%p,%p)"), (void *) form, func));\
(Normalize_Form( form ) -> typ ## name) = func ;\
RETURN(E_OK);\
}
diff --git a/form/frm_opts.c b/form/frm_opts.c
index 3557fcd..42d6267 100644
--- a/form/frm_opts.c
+++ b/form/frm_opts.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2005,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2012,2013 Free 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.15 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: frm_opts.c,v 1.17 2013/08/24 22:58:47 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -49,8 +49,8 @@ set_form_opts(FORM *form, Form_Options opts)
{
T((T_CALLED("set_form_opts(%p,%d)"), (void *)form, opts));
- opts &= ALL_FORM_OPTS;
- if (opts & ~ALL_FORM_OPTS)
+ opts &= (Form_Options) ALL_FORM_OPTS;
+ if ((unsigned)opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
@@ -71,7 +71,7 @@ NCURSES_EXPORT(Form_Options)
form_opts(const FORM *form)
{
T((T_CALLED("form_opts(%p)"), (const void *)form));
- returnCode((int)(Normalize_Form(form)->opts & ALL_FORM_OPTS));
+ returnCode((Form_Options) ((unsigned)Normalize_Form(form)->opts & ALL_FORM_OPTS));
}
/*---------------------------------------------------------------------------
@@ -89,8 +89,8 @@ form_opts_on(FORM *form, Form_Options opts)
{
T((T_CALLED("form_opts_on(%p,%d)"), (void *)form, opts));
- opts &= ALL_FORM_OPTS;
- if (opts & ~ALL_FORM_OPTS)
+ opts &= (Form_Options) ALL_FORM_OPTS;
+ if ((unsigned)opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
@@ -114,8 +114,8 @@ form_opts_off(FORM *form, Form_Options opts)
{
T((T_CALLED("form_opts_off(%p,%d)"), (void *)form, opts));
- opts &= ALL_FORM_OPTS;
- if (opts & ~ALL_FORM_OPTS)
+ opts &= (Form_Options) ALL_FORM_OPTS;
+ if ((unsigned)opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
diff --git a/form/frm_page.c b/form/frm_page.c
index 5a76ca9..13520da 100644
--- a/form/frm_page.c
+++ b/form/frm_page.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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.11 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: frm_page.c,v 1.12 2012/06/10 00:28:04 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -58,7 +58,7 @@ set_form_page(FORM *form, int page)
if (!(form->status & _POSTED))
{
- form->curpage = page;
+ form->curpage = (short)page;
form->current = _nc_First_Active_Field(form);
}
else
diff --git a/form/frm_post.c b/form/frm_post.c
index 8e29aff..31568b2 100644
--- a/form/frm_post.c
+++ b/form/frm_post.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2004,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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.10 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: frm_post.c,v 1.11 2012/06/10 00:27:49 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -77,7 +77,7 @@ post_form(FORM *form)
if ((err = _nc_Set_Form_Page(form, page, form->current)) != E_OK)
RETURN(err);
- form->status |= _POSTED;
+ SetStatus(form, _POSTED);
Call_Hook(form, forminit);
Call_Hook(form, fieldinit);
@@ -117,7 +117,7 @@ unpost_form(FORM *form)
werase(Get_Form_Window(form));
delwin(form->w);
form->w = (WINDOW *)0;
- form->status &= ~_POSTED;
+ ClrStatus(form, _POSTED);
RETURN(E_OK);
}
diff --git a/form/frm_req_name.c b/form/frm_req_name.c
index 99abd7e..c24db1a 100644
--- a/form/frm_req_name.c
+++ b/form/frm_req_name.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2009,2012 Free 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 "form.priv.h"
-MODULE_ID("$Id: frm_req_name.c,v 1.17 2009/10/10 16:17:01 tom Exp $")
+MODULE_ID("$Id: frm_req_name.c,v 1.18 2012/07/21 23:17:23 tom Exp $")
static const char *request_names[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{
@@ -144,23 +144,26 @@ 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];
+ size_t i = 0;
+ char buf[16]; /* longest name is 10 chars */
T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
- if (str)
+ if (str != 0 && (i = strlen(str)) != 0)
{
- strncpy(buf, str, sizeof(buf));
- while ((i < sizeof(buf)) && (buf[i] != '\0'))
+ if (i > sizeof(buf) - 2)
+ i = sizeof(buf) - 2;
+ memcpy(buf, str, i);
+ buf[i] = '\0';
+
+ for (i = 0; buf[i] != '\0'; ++i)
{
buf[i] = (char)toupper(UChar(buf[i]));
- i++;
}
for (i = 0; i < A_SIZE; i++)
{
- if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
+ if (strcmp(request_names[i], buf) == 0)
returnCode(MIN_FORM_COMMAND + (int)i);
}
}
diff --git a/form/fty_generic.c b/form/fty_generic.c
index 3e7a575..429ceac 100644
--- a/form/fty_generic.c
+++ b/form/fty_generic.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2008-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 2008-2010,2012 Free 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 "form.priv.h"
-MODULE_ID("$Id: fty_generic.c,v 1.5 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: fty_generic.c,v 1.6 2012/06/10 00:27:49 tom Exp $")
/*
* This is not a full implementation of a field type, but adds some
@@ -119,7 +119,7 @@ _nc_generic_fieldtype(bool (*const field_check) (FORM *, FIELD *, const void *),
if (res)
{
*res = *_nc_Default_FieldType;
- res->status |= (_HAS_ARGS | _GENERIC);
+ SetStatus(res, (_HAS_ARGS | _GENERIC));
res->fieldcheck.gfcheck = field_check;
res->charcheck.gccheck = char_check;
res->genericarg = Generic_This_Type;
diff --git a/form/fty_int.c b/form/fty_int.c
index e643ad9..1e43874 100644
--- a/form/fty_int.c
+++ b/form/fty_int.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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 "form.priv.h"
-MODULE_ID("$Id: fty_int.c,v 1.25 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: fty_int.c,v 1.26 2012/02/23 10:02:15 tom Exp $")
#if USE_WIDEC_SUPPORT
#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
@@ -233,7 +233,8 @@ Check_This_Field(FIELD *field, const void *argp)
}
if (result)
{
- sprintf(buf, "%.*ld", (prec > 0 ? prec : 0), val);
+ _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
+ "%.*ld", (prec > 0 ? prec : 0), val);
set_field_buffer(field, 0, buf);
}
}
diff --git a/form/fty_num.c b/form/fty_num.c
index 4bd7132..8cce43f 100644
--- a/form/fty_num.c
+++ b/form/fty_num.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 Free 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 "form.priv.h"
-MODULE_ID("$Id: fty_num.c,v 1.28 2010/01/23 21:14:36 tom Exp $")
+MODULE_ID("$Id: fty_num.c,v 1.29 2012/02/23 10:02:15 tom Exp $")
#if HAVE_LOCALE_H
#include <locale.h>
@@ -271,7 +271,8 @@ Check_This_Field(FIELD *field, const void *argp)
}
if (result)
{
- sprintf(buf, "%.*f", (prec > 0 ? prec : 0), val);
+ _nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf))
+ "%.*f", (prec > 0 ? prec : 0), val);
set_field_buffer(field, 0, buf);
}
}
diff --git a/form/fty_regex.c b/form/fty_regex.c
index 2c0a4ca..194a52e 100644
--- a/form/fty_regex.c
+++ b/form/fty_regex.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2012,2015 Free 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 "form.priv.h"
-MODULE_ID("$Id: fty_regex.c,v 1.24 2010/01/23 21:14:37 tom Exp $")
+MODULE_ID("$Id: fty_regex.c,v 1.26 2015/01/10 17:10:25 tom Exp $")
#if HAVE_REGEX_H_FUNCS /* We prefer POSIX regex */
#include <regex.h>
@@ -113,7 +113,7 @@ Generic_RegularExpression_Type(void *arg MAYBE_UNUSED)
if (rx)
{
- preg = typeMalloc(RegExp_Arg, 1);
+ preg = typeCalloc(RegExp_Arg, 1);
if (preg)
{
@@ -123,9 +123,8 @@ Generic_RegularExpression_Type(void *arg MAYBE_UNUSED)
(REG_EXTENDED | REG_NOSUB | REG_NEWLINE)))
{
T((T_CREATE("regex_t %p"), (void *)preg->pRegExp));
- preg->refCount = typeMalloc(unsigned long, 1);
-
- *(preg->refCount) = 1;
+ if ((preg->refCount = typeMalloc(unsigned long, 1)) != 0)
+ *(preg->refCount) = 1;
}
else
{
@@ -151,9 +150,8 @@ Generic_RegularExpression_Type(void *arg MAYBE_UNUSED)
T((T_CREATE("RegExp_Arg %p"), pArg));
pArg->compiled_expression = NULL;
- pArg->refCount = typeMalloc(unsigned long, 1);
-
- *(pArg->refCount) = 1;
+ if ((pArg->refCount = typeMalloc(unsigned long, 1)) != 0)
+ *(pArg->refCount) = 1;
do
{
@@ -266,6 +264,7 @@ Free_RegularExpression_Type(void *argp MAYBE_UNUSED)
{
free(ap->refCount);
regfree(ap->pRegExp);
+ free(ap->pRegExp);
}
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
if (ap->compiled_expression)
diff --git a/form/llib-lformtw b/form/llib-lformtw
index 1063949..6e9cd13 100644
--- a/form/llib-lformtw
+++ b/form/llib-lformtw
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2010 Free Software Foundation, Inc. *
+ * Copyright (c) 2010,2013 Free 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 2010 *
+ * Author: Thomas E. Dickey 2010-on *
****************************************************************************/
/* LINTLIBRARY */
@@ -494,6 +494,13 @@ int form_driver(
int c)
{ return(*(int *)0); }
+#undef form_driver_w
+int form_driver_w(
+ FORM *form,
+ int type,
+ wchar_t c)
+ { return(*(int *)0); }
+
#undef set_field_buffer
int set_field_buffer(
FIELD *field,
diff --git a/form/llib-lformw b/form/llib-lformw
index 30c24b5..04cbe2b 100644
--- a/form/llib-lformw
+++ b/form/llib-lformw
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2002-2005,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 2002-2010,2013 Free 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-2005,2010 *
+ * Author: Thomas E. Dickey 2002-on *
****************************************************************************/
/* LINTLIBRARY */
@@ -494,6 +494,13 @@ int form_driver(
int c)
{ return(*(int *)0); }
+#undef form_driver_w
+int form_driver_w(
+ FORM *form,
+ int type,
+ wchar_t c)
+ { return(*(int *)0); }
+
#undef set_field_buffer
int set_field_buffer(
FIELD *field,