/usr/share/octave/packages/io-2.4.5/private/__OCT_merge_data__.m is in octave-io 2.4.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | ## Copyright (C) 2014-2016 Philip Nienhuis
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {@var{retval} =} __OCT_merge_data__ (@var{input1}, @var{input2})
## Internal function meant for merging existing sheet data and new data
##
## @end deftypefn
## Author: Philip Nienhuis <prnienhuis at users sf net>
## Created: 2014-01-29
function [rawarr, lims, onr, onc] = __OCT_merge_data__ (rawarr, lims, obj, obj_dims)
## C . If required, adapt current data array size to disjoint new data
if (! isempty (rawarr))
## Merge new & current data. Assess where to augment/overwrite current data
[onr, onc] = size (rawarr);
if (obj_dims.tr < lims(2, 1))
## New data requested above current data. Add rows above current data
rawarr = [ cell(lims(2, 1) - obj_dims.tr, onc) ; rawarr];
lims(2, 1) = obj_dims.tr;
endif
if (obj_dims.br > lims(2, 2))
## New data requested below current data. Add rows below current data
rawarr = [rawarr ; cell(obj_dims.br - lims(2, 2), onc)];
lims (2, 2) = obj_dims.br;
endif
## Update number of rawarr rows
onr = size (rawarr, 1);
if (obj_dims.lc < lims(1, 1))
## New data requested to left of curremnt data; prepend columns
rawarr = [cell(onr, lims(1, 1) - obj_dims.lc), rawarr];
lims(1, 1) = obj_dims.lc;
endif
if (obj_dims.rc > lims(1, 2))
## New data to right of current data; append columns
rawarr = [rawarr, cell(onr, obj_dims.rc - lims(1, 2))];
lims(1, 2) = obj_dims.rc;
endif
## Update number of columns
onc = size (rawarr, 2);
## Copy new data into place
objtr = obj_dims.tr - lims(2, 1) + 1;
objbr = obj_dims.br - lims(2, 1) + 1;
objlc = obj_dims.lc - lims(1, 1) + 1;
objrc = obj_dims.rc - lims(1, 1) + 1;
rawarr(objtr:objbr, objlc:objrc) = obj;
else
## New sheet
lims = [obj_dims.lc, obj_dims.rc; obj_dims.tr, obj_dims.br];
onc = obj_dims.nc;
onr = obj_dims.nr;
rawarr = obj;
endif
endfunction
|