/usr/share/octave/packages/3.2/io-1.0.14/spsh_prstype.m is in octave-io 1.0.14-2.
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 73 74 75 | ## Copyright (C) 2010 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 2 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 Octave; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} [ @var{type-array} ] = spsh_prstype ( @var{iarray}, @var{rowsize}, @var{colsize}, @var{celltypes}, @var{options})
## (Internal function) Return rectangular array with codes for cell types in rectangular input cell array @var{iarray}.
## Codes are contained in input vector in order of Numeric, Boolean, Text, Formula and Empty, resp.
##
## spsh_prstype should not be invoked directly but rather through oct2xls or oct2ods.
##
## Example:
##
## @example
## typarr = spsh_chkrange (cellarray, nr, nc, ctypes, options);
## @end example
##
## @end deftypefn
## Author: Philip Nienhuis, <prnienhuis@users.sf.net>
## Created: 2010-08-02
## Updates:
## 2010-08-25 Corrected help text (square -> rectangular; stressed "internal" use)
function [ typearr ] = spsh_prstype (obj, nrows, ncols, ctype, spsh_opts)
# ctype index:
# 1 = numeric
# 2 = boolean
# 3 = text
# 4 = formula
# 5 = error / NaN / empty
typearr = ctype(5) * ones (nrows, ncols); # type "EMPTY", provisionally
obj2 = cell (size (obj)); # Temporary storage for strings
txtptr = cellfun ('isclass', obj, 'char'); # type "STRING" replaced by "NUMERIC"
obj2(txtptr) = obj(txtptr); obj(txtptr) = ctype(3); # Save strings in a safe place
emptr = cellfun ("isempty", obj);
obj(emptr) = ctype(5); # Set empty cells to NUMERIC
lptr = cellfun ("islogical" , obj); # Find logicals...
obj2(lptr) = obj(lptr); # .. and set them to BOOLEAN
ptr = cellfun ("isnan", obj); # Find NaNs & set to BLANK
typearr(ptr) = ctype(5); typearr(~ptr) = ctype(1); # All other cells are now numeric
obj(txtptr) = obj2(txtptr); # Copy strings back into place
obj(lptr) = obj2(lptr); # Same for logicals
obj(emptr) = []; # And empty cells
typearr(txtptr) = ctype(3); # ...and clean up
typearr(emptr) = ctype(5); # EMPTY
typearr(lptr) = ctype(2); # BOOLEAN
if ~(spsh_opts.formulas_as_text)
# Find formulas (designated by a string starting with "=" and ending in ")")
fptr = cellfun (@(x) ischar (x) && strncmp (x, "=", 1) && strncmp (x(end:end), ")", 1), obj);
typearr(fptr) = ctype(4); # FORMULA
endif
endfunction
|