2 blkcpy, copy - copy items from a structure to a structure
5 blkcpy(dst, src [, num [, dsi [, ssi]]]
6 copy(src, dest [, [ssi [, num [, dsi]]])
9 src block, file, string, matrix, or list
10 dest block, file, matrix or list - compatible with src
12 ssi nonnegative integer, defaults to zero
13 num nonnegative integer, defaults to maximum possible
14 dsi nonnegative integer, defaults to datalen for a block, filepos
15 for a file, zero for other structures
17 return null if successful, error value otherwise
22 blkcpy(dst, src, num, dsi, ssi)
24 attempts to copy 'num' consecutive items (octets or values) starting
25 from the source item 'src' with index 'ssi'. By default, 'num'
26 is the maximum possible and 'ssi' is 0.
30 copy(src, dst, ssi, num, dsi)
32 does the same thing, but with a different arg order.
34 A copy fails if ssi or num is too large for the number of items in
35 the source, if sdi is too large for the number of positions
36 available in the destination, or, in cases involving a file stream,
37 if the file is not open in the required mode. The source and
38 destination need not be of the same type, e.g. when a block is
39 copied to a matrix the octets are converted to numbers.
41 The following pairs of source-type, destination-type are permitted:
68 In the above table, int refers to integer values. However if a
69 rational value is supplied, only the numerator is copied.
71 Each copied octet or value replaces the octet or value in the
72 corresponding place in the destination structure. When copying values
73 to values, the new values are stored in a buffer, the old values are
74 removed, and the new values copied from the buffer to the destination.
75 This permits movement of data within one matrix or list, and copying
76 of an element of structure to the structure.
78 Except for copying to files or blocks, the destination is already to have
79 sufficient memory allocated for the copying. For example, to copy
80 a matrix M of size 100 to a newly created list, one may use:
88 For copying from a block B (named or unnamed), the total number of octets
89 available for copying is taken to the datalen for that block,
90 so that num can be at most size(B) - ssi.
92 For copying to a block B (named or unnamed), reallocation will be
93 required if dsi + num > sizeof(B). (This will not be permitted if
94 protect(B) has bit 4 set.)
96 For copying from a file stream fs, num can be at most size(fs) - ssi.
98 For copying from a string str, the string is taken to include the
99 terminating '\0', so the total number of octets available is
100 strlen(str) + 1 and num can be at most strlen(str) + 1 - ssi.
101 If num <= strlen(str) - ssi, the '\0' is not copied.
103 For copying from or to a matrix M, the total number of values in
104 M is size(M), so in the source case, num <= size(M) - ssi, and
105 in the destination case, num <= size(M) - dsi. The indices ssi
106 and dsi refer to the double-bracket method of indexing, i.e. the
107 matrix is as if its elements were indexed 0, 1, ..., size(M) - 1.
111 ; A = blk() = {1,2,3,4}
115 chunksize = 256, maxsize = 256, datalen = 4
119 chunksize = 256, maxsize = 256, datalen = 8
121 ; blkcpy(B, A, 2, 10)
123 chunksize = 256, maxsize = 256, datalen = 12
124 010203040102030400000102
127 chunksize = 256, maxsize = 256, datalen = 16
128 010203040102030400000102ff7f0000
132 mat [2,2] (4 elements, 4 nonzero):
139 mat [2,2] (4 elements, 4 nonzero):
145 ; A = blk() = {1,2,3,4}
149 chunksize = 256, maxsize = 256, datalen = 4
153 chunksize = 256, maxsize = 256, datalen = 8
157 chunksize = 256, maxsize = 256, datalen = 10
162 mat [2,2] (4 elements, 4 nonzero):
170 mat [2,2] (4 elements, 4 nonzero):
178 mat [2,2] (4 elements, 4 nonzero):
191 blk, mat, file, list, str
193 ## Copyright (C) 1999-2006 Landon Curt Noll
195 ## Calc is open software; you can redistribute it and/or modify it under
196 ## the terms of the version 2.1 of the GNU Lesser General Public License
197 ## as published by the Free Software Foundation.
199 ## Calc is distributed in the hope that it will be useful, but WITHOUT
200 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
201 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
202 ## Public License for more details.
204 ## A copy of version 2.1 of the GNU Lesser General Public License is
205 ## distributed with calc under the filename COPYING-LGPL. You should have
206 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
207 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
209 ## @(#) $Revision: 30.2 $
210 ## @(#) $Id: blkcpy,v 30.2 2013/08/11 01:08:32 chongo Exp $
211 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/blkcpy,v $
213 ## Under source code control: 1997/04/05 14:08:50
214 ## File existed as early as: 1997
216 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
217 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/