GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libform/fld_link.c Lines: 0 27 0.0 %
Date: 2017-11-07 Branches: 0 8 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: fld_link.c,v 1.6 2015/01/23 22:48:51 krw Exp $	*/
2
/****************************************************************************
3
 * Copyright (c) 1998-2004,2007 Free Software Foundation, Inc.              *
4
 *                                                                          *
5
 * Permission is hereby granted, free of charge, to any person obtaining a  *
6
 * copy of this software and associated documentation files (the            *
7
 * "Software"), to deal in the Software without restriction, including      *
8
 * without limitation the rights to use, copy, modify, merge, publish,      *
9
 * distribute, distribute with modifications, sublicense, and/or sell       *
10
 * copies of the Software, and to permit persons to whom the Software is    *
11
 * furnished to do so, subject to the following conditions:                 *
12
 *                                                                          *
13
 * The above copyright notice and this permission notice shall be included  *
14
 * in all copies or substantial portions of the Software.                   *
15
 *                                                                          *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19
 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23
 *                                                                          *
24
 * Except as contained in this notice, the name(s) of the above copyright   *
25
 * holders shall not be used in advertising or otherwise to promote the     *
26
 * sale, use or other dealings in this Software without prior written       *
27
 * authorization.                                                           *
28
 ****************************************************************************/
29
30
/****************************************************************************
31
 *   Author:  Juergen Pfeifer, 1995,1997                                    *
32
 ****************************************************************************/
33
34
#include "form.priv.h"
35
36
MODULE_ID("$Id: fld_link.c,v 1.6 2015/01/23 22:48:51 krw Exp $")
37
38
/*---------------------------------------------------------------------------
39
|   Facility      :  libnform
40
|   Function      :  FIELD *link_field(FIELD *field, int frow, int fcol)
41
|
42
|   Description   :  Duplicates the field at the specified position. The
43
|                    new field shares its buffers with the original one,
44
|                    the attributes are independent.
45
|                    If an error occurs, errno is set to
46
|
47
|                    E_BAD_ARGUMENT - invalid argument
48
|                    E_SYSTEM_ERROR - system error
49
|
50
|   Return Values :  Pointer to the new field or NULL if failure
51
+--------------------------------------------------------------------------*/
52
NCURSES_EXPORT(FIELD *)
53
link_field(FIELD *field, int frow, int fcol)
54
{
55
  FIELD *New_Field = (FIELD *)0;
56
  int err = E_BAD_ARGUMENT;
57
58
  T((T_CALLED("link_field(%p,%d,%d)"), field, frow, fcol));
59
  if (field && (frow >= 0) && (fcol >= 0) &&
60
      ((err = E_SYSTEM_ERROR) != 0) &&	/* trick: this resets the default error */
61
      (New_Field = typeMalloc(FIELD, 1)))
62
    {
63
      T((T_CREATE("field %p"), New_Field));
64
      *New_Field = *_nc_Default_Field;
65
      New_Field->frow = frow;
66
      New_Field->fcol = fcol;
67
68
      New_Field->link = field->link;
69
      field->link = New_Field;
70
71
      New_Field->buf = field->buf;
72
      New_Field->rows = field->rows;
73
      New_Field->cols = field->cols;
74
      New_Field->nrow = field->nrow;
75
      New_Field->nbuf = field->nbuf;
76
      New_Field->drows = field->drows;
77
      New_Field->dcols = field->dcols;
78
      New_Field->maxgrow = field->maxgrow;
79
      New_Field->just = field->just;
80
      New_Field->fore = field->fore;
81
      New_Field->back = field->back;
82
      New_Field->pad = field->pad;
83
      New_Field->opts = field->opts;
84
      New_Field->usrptr = field->usrptr;
85
86
      if (_nc_Copy_Type(New_Field, field))
87
	returnField(New_Field);
88
    }
89
90
  if (New_Field)
91
    free_field(New_Field);
92
93
  SET_ERROR(err);
94
  returnField((FIELD *)0);
95
}
96
97
/* fld_link.c ends here */