aboutsummaryrefslogtreecommitdiff
path: root/pkg/tbtables/tbcchg.x
blob: 5b381adcb144189c359ab4d58e6f4b96c4a04ddc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
include <tbset.h>
include "tbtables.h"
include "tblerr.h"

# tbcchg -- change allocated row length
# This procedure is for changing the number of allocated columns, i.e.
# the row length.
# The allocated space for column descriptors will also be increased, if
# necessary, to allow defining a single-precision column for each SZ_REAL
# added to the row length.
# For column-ordered tables this procedure does nothing.
#
# Phil Hodge,  6-Feb-1992  Include only section for row ordered.

procedure tbcchg (tp, rowlen)

pointer tp			# Pointer to table descriptor
int	rowlen			# The new value for the row length in SZ_CHAR

int	maxcols			# New value for TB_MAXCOLS
errchk	tbtchs

begin
	if (TB_TYPE(tp) == TBL_TYPE_S_ROW) {
	    if (TB_IS_OPEN(tp)) {
		maxcols = TB_NCOLS(tp) + (rowlen - TB_COLUSED(tp)) / SZ_REAL
		# maxcols < 0 means that tbtchs should not change TB_MAXCOLS.
		if (maxcols <= TB_MAXCOLS(tp))
		    maxcols = -1
		call tbtchs (tp, -1, maxcols, rowlen, -1)
	    } else {
		TB_ROWLEN(tp) = rowlen
	    }
	}
end