From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- pkg/utilities/nttools/tmatch/rowname.x | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 pkg/utilities/nttools/tmatch/rowname.x (limited to 'pkg/utilities/nttools/tmatch/rowname.x') diff --git a/pkg/utilities/nttools/tmatch/rowname.x b/pkg/utilities/nttools/tmatch/rowname.x new file mode 100644 index 00000000..484fcd75 --- /dev/null +++ b/pkg/utilities/nttools/tmatch/rowname.x @@ -0,0 +1,61 @@ +#* HISTORY * +#* B.Simon 26-Aug-94 + +# ROWNAME -- Create name for table row by concatenating column values + +procedure rowname (in, irow, ncol, col, name, namelen) + +pointer in # i: table descriptor +int irow # i: table row number +int ncol # i: number of table columns +pointer col[ARB] # i: table column pointers +char name[ARB] # o: concatenated values of columns +int namelen # i: maximum name length +#-- +int ic, jc, icol +pointer sp, value + +begin + # Allocate memory for column buffer + + call smark (sp) + call salloc (value, SZ_LINE, TY_CHAR) + + # Concatenate column values into name string + + jc = 0 + icol = 0 + for (ic = 1; ic <= namelen; ic = ic + 1) { + + # A value of zero is a flag to read the next coumn + + if (jc == 0) { + icol = icol + 1 + if (icol > ncol) { + if (ic > 1) + ic = ic - 1 # remove trailing blank + + break + } + + call tbegtt (in, col[icol], irow, Memc[value], SZ_LINE) + } + + # Copy a single character from the buffer to the output string + # until the buffer is exhausted. At this point we copy a blank + # as a spacer and set the value of jc as a flag to read the + # next column. + + if (Memc[value+jc] == EOS) { + name[ic] = ' ' + jc = 0 + } else { + name[ic] = Memc[value+jc] + jc = jc + 1 + } + } + + name[ic] = EOS + call sfree (sp) +end + -- cgit