X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=form%2Ffld_max.c;h=510c3f1c9321ccd66232ff57d2528f894df96c48;hp=6f72a388d266521aebdb5ceb28f594d1b7f60cec;hb=cb4427a16794d98049b4d790b810d62217501f9f;hpb=ba39fbc2e0cee4681395df4079d9e61c27262132 diff --git a/form/fld_max.c b/form/fld_max.c index 6f72a388..510c3f1c 100644 --- a/form/fld_max.c +++ b/form/fld_max.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc. * + * Copyright (c) 1998-2013,2019 Free 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.11 2012/03/11 00:37:16 tom Exp $") +MODULE_ID("$Id: fld_max.c,v 1.15 2019/01/26 22:18:08 Leon.Winter Exp $") /*--------------------------------------------------------------------------- | Facility : libnform @@ -57,18 +57,23 @@ set_max_field(FIELD *field, int maxgrow) if (maxgrow > 0) { - if ((single_line_field && (maxgrow < field->dcols)) || - (!single_line_field && (maxgrow < field->drows))) + if (((single_line_field && (maxgrow < field->dcols)) || + (!single_line_field && (maxgrow < field->drows))) && + !Field_Has_Option(field, O_INPUT_LIMIT)) RETURN(E_BAD_ARGUMENT); } field->maxgrow = maxgrow; - field->status &= (unsigned short) (~_MAY_GROW); - if (!(field->opts & O_STATIC)) + /* shrink */ + if (maxgrow > 0 && Field_Has_Option(field, O_INPUT_LIMIT) && + field->dcols > maxgrow) + field->dcols = maxgrow; + 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);