Hello community,
here is the log from the commit of package octave-forge-io for openSUSE:Factory
checked in at 2018-11-26 10:29:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/octave-forge-io (Old)
and /work/SRC/openSUSE:Factory/.octave-forge-io.new.19453 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "octave-forge-io"
Mon Nov 26 10:29:00 2018 rev:12 rq:651308 version:2.4.12
Changes:
--------
--- /work/SRC/openSUSE:Factory/octave-forge-io/octave-forge-io.changes
2018-06-29 22:26:01.346500717 +0200
+++
/work/SRC/openSUSE:Factory/.octave-forge-io.new.19453/octave-forge-io.changes
2018-11-26 10:29:15.905101248 +0100
@@ -1,0 +2,18 @@
+Wed Nov 21 10:56:19 UTC 2018 - [email protected]
+
+- Update to version 2.4.12:
+ * Bug fixes:
+ - dbfwrite.m: avoid crash and vectorize writing data to file
+ (bug #53899)
+ - dbfwrite.m: add unwind_protect block to be able to avoid
+ dangling file handles in case of errors; better checks on
+ data column homogeneity; texinfo (help) header fixes
+ - A little more robust Java check
+ - csv2cell: improper string indexing (bug #54407), fix by
+ Orion Paplowski
+ * Code improvements:
+ - POI interface: adapt to POI-4.0.0 (new getCelltype enums)
+ - POI: overhaul cell type handling when reading and writing
+ - dbfread.m: improve speed when reading a subset of data
+
+-------------------------------------------------------------------
Old:
----
io-2.4.11.tar.gz
New:
----
io-2.4.12.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ octave-forge-io.spec ++++++
--- /var/tmp/diff_new_pack.cTSRde/_old 2018-11-26 10:29:16.329100750 +0100
+++ /var/tmp/diff_new_pack.cTSRde/_new 2018-11-26 10:29:16.333100746 +0100
@@ -18,7 +18,7 @@
%define octpkg io
Name: octave-forge-%{octpkg}
-Version: 2.4.11
+Version: 2.4.12
Release: 0
Summary: Input/Output in external formats from Octave
License: GPL-3.0-or-later AND BSD-2-Clause
++++++ io-2.4.11.tar.gz -> io-2.4.12.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/DESCRIPTION new/io-2.4.12/DESCRIPTION
--- old/io-2.4.11/DESCRIPTION 2018-04-30 00:08:17.763416702 +0200
+++ new/io-2.4.12/DESCRIPTION 2018-11-16 09:40:37.308363032 +0100
@@ -1,6 +1,6 @@
Name: io
-Version: 2.4.11
-Date: 2018-04-18
+Version: 2.4.12
+Date: 2018-10-28
Author: various authors
Maintainer: Philip Nienhuis <[email protected]>
Title: Input/Output
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/NEWS new/io-2.4.12/NEWS
--- old/io-2.4.11/NEWS 2018-04-30 00:08:17.767416687 +0200
+++ new/io-2.4.12/NEWS 2018-11-16 09:40:37.312363007 +0100
@@ -1,6 +1,24 @@
Summary of important user-visible changes for releases of the io package
===============================================================================
+io-2.4.12 Release Date: 2018-10-28 Release Manager: Philip Nienhuis
+===============================================================================
+
+*** Bug fixes:
+ - dbfwrite.m: avoid crash and vectorize writing data to file (bug #53899)
+ by Matthew Parkan
+ - dbfwrite.m: add unwind_protect block to be able to avoid dangling file
+ handles in case of errors; better checks on data column homogeneity;
+ texinfo (help) header fixes
+ - A little more robust Java check
+ - csv2cell: improper string indexing (bug #54407), fix by Orion Paplowski
+
+*** Code improvements:
+ - POI interface: adapt to POI-4.0.0 (new getCelltype enums)
+ - POI: overhaul cell type handling when reading and writing
+ - dbfread.m: improve speed when reading a subset of data
+
+===============================================================================
io-2.4.11 Release Date: 2018-04-18 Release Manager: Philip Nienhuis
===============================================================================
@@ -30,7 +48,7 @@
- Remove leftover stanza in configure.ac (bug #52830)
- col2num: make input argument case-insensitive
- *** Code improvements:
+*** Code improvements:
- csv2cell: now reads files with varying number of fields per line. The
number of fields in the first line (assumed to contain column titles)
is assumed to be the nr. of columns in the file.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/dbfread.m new/io-2.4.12/inst/dbfread.m
--- old/io-2.4.11/inst/dbfread.m 2018-04-30 00:08:17.771416670 +0200
+++ new/io-2.4.12/inst/dbfread.m 2018-11-16 09:40:37.316362981 +0100
@@ -118,7 +118,7 @@
## http://www.dbf2002.com/dbf-file-format.html
## http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm
-function [data, datinfo] = dbfread (fname, recs=[], cols=[], rd_erased='')
+function [data, datinfo] = dbfread (fname, recs=[], cols=[], rd_erased="")
## Check file name
if (ischar (fname))
@@ -146,8 +146,9 @@
elseif (islogical (recs))
recs = find (recs);
endif
- endif
-
+ recs = sort (recs);
+ endif
+
## Check cols arg. If needed turn into indices
if (! isempty (cols))
if (! (isnumeric (cols) || ischar (cols) || iscellstr (cols) || islogical
(cols)))
@@ -170,7 +171,7 @@
if (! isempty (rd_erased) && ! (islogical (rd_erased) || isnumeric
(rd_erased)))
error ("dbfread: numeric or logical value expected for arg # 4\n");
endif
-
+
## Open file
fid = fopen (fname, "r");
if (fid < 0)
@@ -178,7 +179,7 @@
endif
## Rewind, just to be sure
fseek (fid, 0, "bof");
-
+
## First check proper type
fbyte = uint8 (fread (fid, 1, "uint8"));
## Provisional type check.
@@ -200,7 +201,7 @@
nrecs = fread (fid, 1, "uint32");
lhdr = fread (fid, 1, "uint16");
recl = fread (fid, 1, "uint16");
-
+
## Field descriptors
nfields = 0;
fseek (fid, 32, "bof");
@@ -219,12 +220,12 @@
until (ftell (fid) >= lhdr)
## Seek to position after header terminator byte
fseek (fid, lhdr, "bof");
-
+
## Read rest of data. Skip if no records need be read. Turn into char array
- if (recs > 0 || isempty (recs))
+ if (isempty (recs))
txt = fread (fid, [recl, nrecs], "char=>char")';
else
- txt = "";
+ txt = fread (fid, [recl, recs(end)], "char=>char")';
endif
## .dbf file is no longer needed
fclose (fid);
@@ -234,7 +235,6 @@
data(1, :) = {dbf.fldnam};
## If required, select requested records. Beware; truncate indices > nrecs
- recs = sort (recs);
if (any (recs > nrecs))
recs (find (recs > nrecs)) = [];
## Check if we still have a selection...
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/dbfwrite.m
new/io-2.4.12/inst/dbfwrite.m
--- old/io-2.4.11/inst/dbfwrite.m 2018-04-30 00:08:17.771416670 +0200
+++ new/io-2.4.12/inst/dbfwrite.m 2018-11-16 09:40:37.320362956 +0100
@@ -1,4 +1,5 @@
## Copyright (C) 2015-2018 Philip Nienhuis
+## Copyright (C) 2018 Matthew Parkan
##
## 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
@@ -19,20 +20,22 @@
##
## @var{fname} must be a valid file name, optionally with '.dbf' suffix.
## @var{data} should be a cell array of which the top row contains column
-## names (character strings). Each column must contain only one class of data,
-## except of course the top entry (the column header).
-## Value type that can be written are character (text sring), numeric
-## (integer and float, the latter with 6 decimal places), and logical.
+## names (character strings, each max. 10 characters). Each column must
+## contain only one class of data, except of course the top entry (the column
+## header). Integers interspersed in double type colums will be written as
+## doubles. Data types that can be written are character (text string),
+## numeric (integer and float, the latter with 6 decimal places), and logical.
##
-## Ouput argument @var{status} is 1 if the file was written successfully, 0
+## Output argument @var{status} is 1 if the file was written successfully, 0
## otherwise.
##
-## Provisionally only dBase v. III+ files can be written without memos.
+## Provisionally only dBase v. III+ files without memos can be written.
##
## @seealso{dbfread}
## @end deftypefn
-## Author: Philip Nienhuis <[email protected]>
+## Authors: Philip Nienhuis <[email protected]>,whos
+## Matthew Parkan <[email protected]>
## Created: 2014-12-24
function [status] = dbfwrite (fname, data)
@@ -78,102 +81,135 @@
error ("dbfwrite: file name should have a '.dbf' suffix\n");
endif
## Try to open file
- fid = fopen (fname, "w+");
+ fid = fopen (fname, "w", "ieee-le");
if (fid < 0)
error ("dbfwrite: could not open file %s\n", fname);
endif
- ## Start writing header
- ## Provisionally assume dbase III+ w/o memos
- fwrite (fid, 3, "uint8");
- upd = datevec (date);
- fwrite (fid, upd(1) - 1900, "uint8");
- fwrite (fid, upd(2), "uint8");
- fwrite (fid, upd(3), "uint8");
- fwrite (fid, nrecs, "uint32");
- ## The next two uint16 fields are to be written later, just fill temporarily
- pos_lhdr = ftell (fid);
- fwrite (fid, 0, "uint32");
- ## Another place holder, write enough to allow next fseek to succeed
- fwrite (fid, uint32 (zeros (1, 7)), "uint32");
-
- ## Write record descriptors
- nfields = size (data, 2);
- fldtyp = "";
- fldlngs = {};
- reclen = 1; ## "Erased" byte
first
- fseek (fid, 32, "bof");
- for ii=1:nfields
- decpl = 0;
- recdesc = sprintf ("%d", uint32 (zeros (1, 8)));
- recdesc(1:10) = strjust (sprintf ("%10s", data{1, ii}), "left"); ## Field
name
- if (isnumeric ([data{tr:end, ii}]))
- if (isinteger ([data{tr:end, ii}]) ||
- all ([data{tr:end, ii}] - floor([data{tr:end, ii}]) < eps))
- ftype = "N";
- decpl = 0;
+ unwind_protect
+ ## Start writing header
+ ## Provisionally assume dbase III+ w/o memos
+ fwrite (fid, 3, "uint8");
+
+ ## Date of last update (YYMMDD), with YY the number of years since 1900
+ t = now;
+ upd = datevec(t) - [1900, 0, 0, 0, 0, 0];
+ fwrite (fid, uint8(upd(1:3)), "uint8");
+
+ ## Number of records in the table
+ fwrite (fid, nrecs, "uint32");
+ ## The next two uint16 fields are to be written later, just fill
temporarily
+ pos_lhdr = ftell(fid);
+
+ fwrite (fid, 0, "uint32");
+
+ ## Another place holder, write enough to allow next fseek to succeed
+ fwrite (fid, uint32 (zeros (1, 7)), "uint32");
+
+ ## Write record descriptors
+ nfields = size (data, 2);
+ fldtyp = "";
+ fldlngs = {};
+ reclen = 1; ## "Erased" byte
first
+ fseek (fid, 32, "bof");
+
+ RR = zeros (32, nfields, "uint8");
+ for ii=1:nfields
+ decpl = 0;
+ recdesc = sprintf ("%d", uint32 (zeros (1, 8)));
+ recdesc(1:10) = strjust (sprintf ("%10s", data{1, ii}), "left"); ##
Field name
+ ## Be strict on mixing char and numeric; this implies logicals
+ ## interspersed in numeric type column won't be accepted either
+ if (all (cellfun (@isnumeric, data(tr:end, ii), "uni", 1)))
+ ## We're lax on interspersed integers, they'll be cast to double
+ if (isinteger ([data{tr:end, ii}]) ||
+ all ([data{tr:end, ii}] - floor([data{tr:end, ii}]) < eps))
+ ftype = "N";
+ decpl = 0;
+ else
+ ftype = "F";
+ ## ML compatibility for .dbf/.shp file: 6 decimal places
+ decpl = 6;
+ endif
+ fldlng = 20;
+ elseif (all (cellfun (@ischar, data(tr:end, ii), "uni", 1)))
+ ftype = "C";
+ fldlng = max (cellfun (@(x) length(x), data(tr:end, ii)));
+ elseif (all (cellfun (@islogical, (data(tr:end, ii)), "uni", 1)))
+ ftype = "L";
+ fldlng = 1;
else
- ftype = "F";
- ## ML compatibility for .dbf/.shp file: 6 decimal places
- decpl = 6;
+ error ("dbfwrite: heterogeneous data types in column %d", ii);
+ ## unwind_protect_cleanup takes care of closing & wiping file
endif
- fldlng = 20;
- elseif (ischar ([data{tr:end, ii}]))
- ftype = "C";
- fldlng = max (cellfun (@(x) length(x), data(tr:end, ii)));
- elseif (islogical ([data{tr:end, ii}]))
- ftype = "L";
- fldlng = 1;
- endif
- recdesc(12) = ftype; ## Field type
- fldtyp = [ fldtyp ftype ];
- recdesc(17) = uint8 (fldlng); ## Field length
- recdesc(18) = uint8 (decpl); ## Decimal places
- recdesc(32) = "\0"; ## Fill to byte# 32
- fwrite (fid, recdesc, "char");
- reclen += fldlng;
- fldlngs = [ fldlngs; sprintf("%d", fldlng) ];
- endfor
- ## Write header record terminator
- fwrite (fid, 13, "uint8");
- ## Remember position
- fpos_data = ftell (fid);
- ## Write missing data in header
- fseek (fid, pos_lhdr, "bof");
- fwrite (fid, fpos_data, "uint16");
- fwrite (fid, reclen, "uint16");
-
- ## Write data2
- fseek (fid, fpos_data, "bof");
- ## FIXME replace by vectorized code (num2str etc) & concatenating columns
- ## for speeding up
- for ii=tr:nrecs+tr-1
- ## Write "erased" byte
- fwrite (fid, "\0", "uint8");
- for jj=1:nfields
- switch fldtyp(jj)
- case "C"
- txt = sprintf (["%" fldlngs{jj} "s"], data{ii, jj});
- case "N"
- txt = sprintf (["%" fldlngs{jj} "d"], data{ii, jj});
- case "L"
- if (data{ii, jj})
- txt = "Y";
- else
- txt = "N";
- endif
- case "F"
- txt = sprintf (["%" fldlngs{jj} "f"], data{ii, jj});
- case "D"
- % txt = sprintf (["%" fldlngs{jj} "s"], data{ii, jj});
- otherwise
- endswitch
- fwrite (fid, txt, "char");
+ recdesc(12) = ftype; ## Field type
+ fldtyp = [ fldtyp ftype ];
+ recdesc(17) = uint8 (fldlng); ## Field length
+ recdesc(18) = uint8 (decpl); ## Decimal places
+ recdesc(32) = "\0"; ## Fill to byte#
32
+
+ RR(:, ii) = recdesc';
+ reclen += fldlng;
+ fldlngs = [ fldlngs; sprintf("%d", fldlng) ];
endfor
- endfor
- ## Close file
- fclose (fid);
- status = 1;
+ fwrite (fid, RR, "char");
+
+ ## Write header record terminator
+ fwrite (fid, 13, "uint8");
+ ## Remember position
+ fpos_data = ftell (fid);
+ ## Write missing data in header
+ fseek (fid, pos_lhdr, "bof");
+ fwrite (fid, fpos_data, "uint16");
+ fwrite (fid, reclen, "uint16");
+
+ ## Write data2
+ fseek (fid, fpos_data, "bof");
+
+ ## Determine data record format. "Erased byte" is first char of format
+ fmt = "\0";
+ for j = 1:nfields
+ switch fldtyp(j)
+ case "C" ## character
+ txt = ["%", fldlngs{j}, "s"];
+ case "N" ## numeric
+ txt = ["%" fldlngs{j} "d"];
+ case "L" ## logical
+ txt = ["%", fldlngs{j}, "c"];
+ case "F" ## float
+ txt = ["%" fldlngs{j} "f"];
+ case "D" ## date;
currently inactive
+ ## txt = sprintf (["%" fldlngs{jj} "s"], data{ii, jj});
+ otherwise
+ end
+ fmt = [fmt, txt]; ## append format
+ end
+
+ ## Convert boolean attributes to Y/N characters
+ str_logical = {"N", "Y"};
+ for jj = find (fldtyp == "L")
+ data(2:end, jj) = str_logical (double ([data{2:end, jj}] + 1))';
+ end
+
+ ## Write data in ~100 MB chunks to avoid overflow. First find an optimal
+ ## chunk size as max. nr. of records in a chunk= (= nr.of rows in data)
+ chunk_sz = floor (1e8 / reclen);
+ for ii=2 : chunk_sz : nrecs
+ ## Reshape chunk of data matrix
+ T = [data(ii:min (ii+chunk_sz-1, nrecs+1), :)'(:)];
+ blob = sprintf (fmt, T{:});
+ ## Write blob to file
+ fwrite (fid, blob, "char");
+ endfor
+ status = 1;
+
+ unwind_protect_cleanup
+ fclose (fid);
+ if (! status)
+ printf ("dbfwrite: removing incomplete file %s.\n", fname);
+ unlink (fname);
+ endif
+ end_unwind_protect
endfunction
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/__JXL_oct2spsh__.m
new/io-2.4.12/inst/private/__JXL_oct2spsh__.m
--- old/io-2.4.11/inst/private/__JXL_oct2spsh__.m 2018-04-30
00:08:17.783416622 +0200
+++ new/io-2.4.12/inst/private/__JXL_oct2spsh__.m 2018-11-16
09:40:37.348362780 +0100
@@ -42,123 +42,124 @@
function [ xls, rstatus ] = __JXL_oct2spsh__ (obj, xls, wsh, crange, spsh_opts)
- ## Preliminary sanity checks
- if (strcmpi (xls.filename(end-4:end-1), ".xls")) ## No OOXML in
JXL
- error ("JXL interface can only process Excel .xls files")
- endif
-
- persistent ctype;
- if (isempty (ctype))
- ctype = [1, 2, 3, 4, 5];
- ## Number, Boolean, String, Formula, Empty
- endif
- ## scratch vars
- rstatus = 0; f_errs = 0;
-
- ## Prepare workbook pointer if needed
- if (xls.changed == 0) ## Only for 1st call of octxls
after xlsopen
- ## Create writable copy of workbook. If >2 a writable wb was
made in xlsopen
- xlsout = javaObject ("java.io.File", xls.filename);
- wb = javaMethod ("createWorkbook", "jxl.Workbook", xlsout,
xls.workbook);
- ## Catch JExcelAPI bug/"feature": when switching to write mode,
the file on disk
- ## is affected and the memory file MUST be written to disk to
save earlier data
- xls.changed = 1;
- xls.workbook = wb;
- else
- wb = xls.workbook;
- endif
- ## Check if requested worksheet exists in the file & if so, get pointer
- nr_of_sheets = xls.workbook.getNumberOfSheets (); ## 1 based !!
- if (isnumeric (wsh))
- if (wsh > nr_of_sheets)
- ## Watch out as a sheet called Sheet%d can exist with a
lower index...
- strng = sprintf ("Sheet%d", wsh);
- ii = 1;
- while (~isempty (wb.getSheet (strng)) && (ii < 5))
- strng = ["_" strng];
- ++ii;
- endwhile
- if (ii >= 5)
+ ## Preliminary sanity checks
+ if (strcmpi (xls.filename(end-4:end-1), ".xls")) ## No OOXML in JXL
+ error ("JXL interface can only process Excel .xls files")
+ endif
+
+ persistent ctype;
+ if (isempty (ctype))
+ ctype = [1, 2, 3, 4, 5];
+ ## Number, Boolean, String, Formula, Empty
+ endif
+ ## scratch vars
+ rstatus = 0;
+ f_errs = 0;
+
+ ## Prepare workbook pointer if needed
+ if (xls.changed == 0) ## Only for 1st call of octxls after xlsopen
+ ## Create writable copy of workbook. If >2 a writable wb was made in
xlsopen
+ xlsout = javaObject ("java.io.File", xls.filename);
+ wb = javaMethod ("createWorkbook", "jxl.Workbook", xlsout, xls.workbook);
+ ## Catch JExcelAPI bug/"feature": when switching to write mode, the file
on disk
+ ## is affected and the memory file MUST be written to disk to save earlier
data
+ xls.changed = 1;
+ xls.workbook = wb;
+ else
+ wb = xls.workbook;
+ endif
+ ## Check if requested worksheet exists in the file & if so, get pointer
+ nr_of_sheets = xls.workbook.getNumberOfSheets (); ## 1 based !!
+ if (isnumeric (wsh))
+ if (wsh > nr_of_sheets)
+ ## Watch out as a sheet called Sheet%d can exist with a lower index...
+ strng = sprintf ("Sheet%d", wsh);
+ ii = 1;
+ while (~isempty (wb.getSheet (strng)) && (ii < 5))
+ strng = ["_" strng];
+ ++ii;
+ endwhile
+ if (ii >= 5)
error (sprintf( " > 5 sheets named [_]Sheet%d already present!", wsh));
endif
- sh = wb.createSheet (strng, nr_of_sheets);
++nr_of_sheets;
- xls.changed = min (xls.changed, 2); ## Keep
a 2 in case of new file
- else
- sh = wb.getSheet (wsh - 1);
## JXL sheet count 0-based
- endif
- shnames = char (wb.getSheetNames ());
- printf ("(Writing to worksheet %s)\n", shnames {nr_of_sheets,
1});
- else
- sh = wb.getSheet (wsh);
- if (isempty(sh))
- ## Sheet not found, just create it
- sh = wb.createSheet (wsh, nr_of_sheets);
- ++nr_of_sheets;
- xls.changed = min (xls.changed, 2); ## Keep
a 2 for new file
- endif
- endif
-
- ## Parse date ranges
- [nr, nc] = size (obj);
- [topleft, nrows, ncols, trow, lcol] = ...
+ sh = wb.createSheet (strng, nr_of_sheets); ++nr_of_sheets;
+ xls.changed = min (xls.changed, 2); ## Keep a 2 in case of new file
+ else
+ sh = wb.getSheet (wsh - 1); ## JXL sheet count 0-based
+ endif
+ shnames = char (wb.getSheetNames ());
+ printf ("(Writing to worksheet %s)\n", shnames {nr_of_sheets, 1});
+ else
+ sh = wb.getSheet (wsh);
+ if (isempty(sh))
+ ## Sheet not found, just create it
+ sh = wb.createSheet (wsh, nr_of_sheets);
+ ++nr_of_sheets;
+ xls.changed = min (xls.changed, 2); ## Keep a 2 for new file
+ endif
+ endif
+
+ ## Parse date ranges
+ [nr, nc] = size (obj);
+ [topleft, nrows, ncols, trow, lcol] = ...
spsh_chkrange (crange, nr, nc, xls.xtype, xls.filename);
- if (nrows < nr || ncols < nc)
- warning ("Array truncated to fit in range\n");
- obj = obj(1:nrows, 1:ncols);
- endif
-
- ## Prepare type array
- typearr = spsh_prstype (obj, nrows, ncols, ctype, spsh_opts);
- if (! spsh_opts.formulas_as_text)
- ## Remove leading '=' from formula strings
- fptr = ! (4 * (ones (size (typearr))) .- typearr);
- obj(fptr) = cellfun (@(x) x(2:end), obj(fptr), "Uniformoutput",
false);
- endif
- clear fptr
-
- ## Write date to worksheet
- for ii=1:nrows
- ll = ii + trow - 2; ## Java JExcelAPI's row count =
0-based
- for jj=1:ncols
- kk = jj + lcol - 2; ## JExcelAPI's column
count is also 0-based
- switch typearr(ii, jj)
- case 1 ## Numerical
- tmp = javaObject ("jxl.write.Number",
kk, ll, obj{ii, jj});
- sh.addCell (tmp);
- case 2 ## Boolean
- tmp = javaObject ("jxl.write.Boolean",
kk, ll, obj{ii, jj});
- sh.addCell (tmp);
- case 3 ## String
- tmp = javaObject ("jxl.write.Label",
kk, ll, obj{ii, jj});
- sh.addCell (tmp);
- case 4 ## Formula
- ## First make sure formula functions
are all uppercase
- obj{ii, jj} = toupper (obj{ii, jj});
- ## There's no guarantee for formula
correctness, so....
- try ## Actually JExcelAPI
flags formula errors as mere warnings :-(
- tmp = javaObject
("jxl.write.Formula", kk, ll, obj{ii, jj});
- ## ... while errors are
actually detected in addCell(), so
- ## that should be within
the try-catch
- sh.addCell (tmp);
- catch
- ++f_errs;
- ## Formula error. Enter formula
as text string instead
- tmp = javaObject
("jxl.write.Label", kk, ll, obj{ii, jj});
- sh.addCell (tmp);
- end_try_catch
- case 5 ## Empty or NaN
- tmp = javaObject ("jxl.write.Blank",
kk, ll);
- sh.addCell (tmp);
- otherwise
- ## Just skip
- endswitch
- endfor
- endfor
-
- if (f_errs)
- printf ("%d formula errors encountered - please check input
array\n", f_errs);
- endif
- xls.changed = max (xls.changed, 1); ## Preserve 2 for new
files
- rstatus = 1;
-
+ if (nrows < nr || ncols < nc)
+ warning ("Array truncated to fit in range\n");
+ obj = obj(1:nrows, 1:ncols);
+ endif
+
+ ## Prepare type array
+ typearr = spsh_prstype (obj, nrows, ncols, ctype, spsh_opts);
+ if (! spsh_opts.formulas_as_text)
+ ## Remove leading '=' from formula strings
+ fptr = ! (4 * (ones (size (typearr))) .- typearr);
+ obj(fptr) = cellfun (@(x) x(2:end), obj(fptr), "Uniformoutput", false);
+ endif
+ clear fptr
+
+ ## Write date to worksheet
+ for ii=1:nrows
+ ll = ii + trow - 2; ## Java JExcelAPI's row count = 0-based
+ for jj=1:ncols
+ kk = jj + lcol - 2; ## JExcelAPI's column count is also 0-based
+ switch typearr(ii, jj)
+ case 1 ## Numerical
+ tmp = javaObject ("jxl.write.Number", kk, ll, obj{ii, jj});
+ sh.addCell (tmp);
+ case 2 ## Boolean
+ tmp = javaObject ("jxl.write.Boolean", kk, ll, obj{ii, jj});
+ sh.addCell (tmp);
+ case 3 ## String
+ tmp = javaObject ("jxl.write.Label", kk, ll, obj{ii, jj});
+ sh.addCell (tmp);
+ case 4 ## Formula
+ ## First make sure formula functions are all uppercase
+ obj{ii, jj} = toupper (obj{ii, jj});
+ ## There's no guarantee for formula correctness, so....
+ try ## Actually JExcelAPI flags formula errors as mere warnings
:-(
+ tmp = javaObject ("jxl.write.Formula", kk, ll, obj{ii, jj});
+ ## ... while errors are actually detected in addCell(), so
+ ## that should be within the try-catch
+ sh.addCell (tmp);
+ catch
+ ++f_errs;
+ ## Formula error. Enter formula as text string instead
+ tmp = javaObject ("jxl.write.Label", kk, ll, obj{ii, jj});
+ sh.addCell (tmp);
+ end_try_catch
+ case 5 ## Empty or NaN
+ tmp = javaObject ("jxl.write.Blank", kk, ll);
+ sh.addCell (tmp);
+ otherwise
+ ## Just skip
+ endswitch
+ endfor
+ endfor
+
+ if (f_errs)
+ printf ("%d formula errors encountered - please check input array\n",
f_errs);
+ endif
+ xls.changed = max (xls.changed, 1); ## Preserve 2 for new files
+ rstatus = 1;
+
endfunction
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/__JXL_spsh2oct__.m
new/io-2.4.12/inst/private/__JXL_spsh2oct__.m
--- old/io-2.4.11/inst/private/__JXL_spsh2oct__.m 2018-04-30
00:08:17.787416606 +0200
+++ new/io-2.4.12/inst/private/__JXL_spsh2oct__.m 2018-11-16
09:40:37.348362780 +0100
@@ -40,21 +40,21 @@
function [ rawarr, xls, rstatus ] = __JXL_spsh2oct__ (xls, wsh, cellrange,
spsh_opts)
- persistent ctype; persistent months;
+ persistent ctype months;
if (isempty (ctype))
ctype = cell (11, 1);
## Get enumerated cell types. Beware as they start at 0 not 1
- ctype( 1) = (__java_get__ ("jxl.CellType", "BOOLEAN")).toString ();
- ctype( 2) = (__java_get__ ("jxl.CellType", "BOOLEAN_FORMULA")).toString ();
- ctype( 3) = (__java_get__ ("jxl.CellType", "DATE")).toString ();
- ctype( 4) = (__java_get__ ("jxl.CellType", "DATE_FORMULA")).toString ();
- ctype( 5) = (__java_get__ ("jxl.CellType", "EMPTY")).toString ();
- ctype( 6) = (__java_get__ ("jxl.CellType", "ERROR")).toString ();
- ctype( 7) = (__java_get__ ("jxl.CellType", "FORMULA_ERROR")).toString ();
- ctype( 8) = (__java_get__ ("jxl.CellType", "NUMBER")).toString ();
- ctype( 9) = (__java_get__ ("jxl.CellType", "LABEL")).toString ();
- ctype(10) = (__java_get__ ("jxl.CellType", "NUMBER_FORMULA")).toString ();
- ctype(11) = (__java_get__ ("jxl.CellType", "STRING_FORMULA")).toString ();
+ ctype( 1) = (__java_get__ ("jxl.CellType", "BOOLEAN")).toString ();
##
+ ctype( 2) = (__java_get__ ("jxl.CellType", "BOOLEAN_FORMULA")).toString
(); ##
+ ctype( 3) = (__java_get__ ("jxl.CellType", "DATE")).toString ();
##
+ ctype( 4) = (__java_get__ ("jxl.CellType", "DATE_FORMULA")).toString ();
##
+ ctype( 5) = (__java_get__ ("jxl.CellType", "EMPTY")).toString ();
##
+ ctype( 6) = (__java_get__ ("jxl.CellType", "ERROR")).toString ();
##
+ ctype( 7) = (__java_get__ ("jxl.CellType", "FORMULA_ERROR")).toString ();
##
+ ctype( 8) = (__java_get__ ("jxl.CellType", "NUMBER")).toString ();
##
+ ctype( 9) = (__java_get__ ("jxl.CellType", "LABEL")).toString ();
##
+ ctype(10) = (__java_get__ ("jxl.CellType", "NUMBER_FORMULA")).toString ();
##
+ ctype(11) = (__java_get__ ("jxl.CellType", "STRING_FORMULA")).toString ();
##
months = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP",
"OCT", "NOV", "DEC"};
endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/__JXL_spsh_info__.m
new/io-2.4.12/inst/private/__JXL_spsh_info__.m
--- old/io-2.4.11/inst/private/__JXL_spsh_info__.m 2018-04-30
00:08:17.787416606 +0200
+++ new/io-2.4.12/inst/private/__JXL_spsh_info__.m 2018-11-16
09:40:37.348362780 +0100
@@ -36,7 +36,7 @@
if (sh_cnt > 0)
fformat = "xlWorkbookNormal";
else
- fformat = '';
+ fformat = "";
endif
endfunction
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/__OCT_oct2gnm__.m
new/io-2.4.12/inst/private/__OCT_oct2gnm__.m
--- old/io-2.4.11/inst/private/__OCT_oct2gnm__.m 2018-04-30
00:08:17.787416606 +0200
+++ new/io-2.4.12/inst/private/__OCT_oct2gnm__.m 2018-11-16
09:40:37.356362730 +0100
@@ -79,7 +79,7 @@
## C. Create a temporary file to hold the new sheet xml
## Open sheet file (new or old)
- tmpfil = tmpnam;
+ tmpfil = tempname;
fid = fopen (tmpfil, "w+");
if (fid < 0)
error ("oct2ods/xls: unable to write to tmp file %s\n", tmpfil);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/__POI_chk_sprt__.m
new/io-2.4.12/inst/private/__POI_chk_sprt__.m
--- old/io-2.4.11/inst/private/__POI_chk_sprt__.m 2018-04-30
00:08:17.799416558 +0200
+++ new/io-2.4.12/inst/private/__POI_chk_sprt__.m 2018-11-16
09:40:37.380362578 +0100
@@ -31,7 +31,7 @@
printf ("\nBasic POI (.xls) <poi-3> <poi-ooxml>:\n");
endif
## Below entries1 order = vital
- entries1 = {{"apache-poi.", "poi-3"}, {"apache-poi-ooxml.", "poi-ooxml-3"}};
+ entries1 = {{"apache-poi.", "poi-3", "poi-4"}, {"apache-poi-ooxml.",
"poi-ooxml-3", "poi-ooxml-4"}};
## Only under *nix we might use brute force: e.g., strfind (javaclasspath,
classname)
## as javaclasspath is one long string. Under Windows however classpath is a
cell array
## so we need the following more subtle, platform-independent approach:
@@ -51,13 +51,14 @@
printf ("\nPOI OOXML (.xlsx) <xbean/xmlbean> <poi-ooxml-schemas>
<dom4j>:\n");
endif
entries2 = {{"xbean", "xmlbean"}, {"apache-poi-ooxml-schemas", ...
- "poi-ooxml-schemas"}, "dom4j", "commons-collections4"};
+ "poi-ooxml-schemas"}, "dom4j", "commons-collections4", ...
+ "commons-compress-1.18"};
[jpchk2, missing2] = chk_jar_entries (jcp, entries2, dbug);
missing2 = entries2 (find (missing2));
## Check if common-collections4 is req'd (only for POI >= 3.15)
try ## ...cause POI may not yet be in the javaclasspath ...
poiv = javaObject ("org.apache.poi.Version").getVersion();
- if (compare_versions (poiv, "3.14", "<=") &&
+ if (compare_versions (poiv, "3.14", "<=") && ...
strncmpi (missing2, "commons-collections4", 8))
## Remove commons-collections from missing2
ic = find (cellfun (@ischar, missing2));
@@ -68,6 +69,17 @@
printf (" commons-collections4 not needed for POI <= 3.14\n");
endif
endif
+ if (compare_versions (poiv, "4.0", "<=") && ...
+ strncmpi (missing2, "commons-compress", 8))
+ ## Remove commons-compress from missing2
+ ic = find (cellfun (@ischar, missing2));
+ id = strmatch ("commons-compress", missing2(ic));
+ missing2(ic(id)) = [];
+ jpchk2++;
+ if (dbug > 2)
+ printf (" commons-compress not needed for POI <= 3.14\n");
+ endif
+ endif
end_try_catch
if (jpchk2 >= numel (entries2))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/__POI_getusedrange__.m
new/io-2.4.12/inst/private/__POI_getusedrange__.m
--- old/io-2.4.11/inst/private/__POI_getusedrange__.m 2018-04-30
00:08:17.799416558 +0200
+++ new/io-2.4.12/inst/private/__POI_getusedrange__.m 2018-11-16
09:40:37.380362578 +0100
@@ -20,8 +20,14 @@
function [ trow, brow, lcol, rcol ] = __POI_getusedrange__ (xls, ii)
- persistent cblnk;
- cblnk = __java_get__ ("org.apache.poi.ss.usermodel.Cell", "CELL_TYPE_BLANK");
+ persistent cblnk poiv4;
+ try
+ cblnk = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BLANK");
+ poiv4 = false;
+ catch
+ cblnk = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"BLANK").ordinal ();
+ poiv4 = true;
+ end_try_catch
sh = xls.workbook.getSheetAt (ii-1); ## Java POI starts counting at
0
@@ -41,8 +47,13 @@
ecol = irow.getLastCellNum - 1;
rcol = max (rcol, ecol);
## Keep track of lowermost non-empty row as getLastRowNum() is
unreliable
- if (! (irow.getCell(scol).getCellType () == cblnk ...
- && irow.getCell(ecol).getCellType () == cblnk))
+ cst = irow.getCell(scol).getCellType ();
+ cet = irow.getCell(ecol).getCellType ();
+ if (poiv4)
+ cst = cst.ordinal ();
+ cet = cet.ordinal ();
+ endif
+ if (! (cst == cblnk && cet == cblnk))
botrow = jj;
endif
endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/__POI_oct2spsh__.m
new/io-2.4.12/inst/private/__POI_oct2spsh__.m
--- old/io-2.4.11/inst/private/__POI_oct2spsh__.m 2018-04-30
00:08:17.799416558 +0200
+++ new/io-2.4.12/inst/private/__POI_oct2spsh__.m 2018-11-16
09:40:37.380362578 +0100
@@ -47,17 +47,40 @@
error ("POI interface can only write to Excel .xls or .xlsx files")
endif
- persistent ctype;
+ persistent ctype poiv4 p4ctype;
if (isempty (ctype))
- ## Get cell types. Beware as they start at 0 not 1
- ctype(1) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_NUMERIC"); ## 0
- ctype(2) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BOOLEAN"); ## 4
- ctype(3) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_STRING"); ## 1
- ctype(4) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_FORMULA"); ## 2
- ctype(5) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BLANK"); ## 3
+ ## Get enumerated cell types. Beware as they start at 0 not 1
+ try
+ ## POI < 4
+ ctype(1) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_NUMERIC");## 0
+ ctype(2) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BOOLEAN");## 4
+ ctype(3) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_STRING"); ## 1
+ ctype(4) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_FORMULA");## 2
+ ctype(5) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BLANK"); ## 3
+ poiv4 = false;
+ catch
+ ## POI >= 4
+ p4ctype.enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"NUMERIC");
+ ctype(1) = p4ctype.enum.ordinal;
+ p4ctype.name = "numeric";
+ p4ctype(2).enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"BOOLEAN");
+ ctype(2) = p4ctype(2).enum.ordinal;
+ p4ctype(2).name = "boolean";
+ p4ctype(3).enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"STRING");
+ ctype(3) = p4ctype(3).enum.ordinal;
+ p4ctype(3).name = "string";
+ p4ctype(4).enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"FORMULA");
+ ctype(4) = p4ctype(4).enum.ordinal;
+ p4ctype(4).name = "formula";
+ p4ctype(5).enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"BLANK");
+ ctype(5) = p4ctype(5).enum.ordinal;
+ p4ctype(5).name = "blank";
+ poiv4 = true;
+ end_try_catch
endif
## scratch vars
- rstatus = 0; f_errs = 0;
+ rstatus = 0;
+ f_errs = 0;
## Check if requested worksheet exists in the file & if so, get pointer
try
@@ -101,12 +124,9 @@
## Prepare type array
typearr = spsh_prstype (obj, nrows, ncols, ctype, spsh_opts);
- if (! spsh_opts.formulas_as_text)
- ## Remove leading "=" from formula strings
- ## FIXME should be easier using typearr<4> info
- fptr = (! (2 * (ones (size (typearr))) .- typearr));
- obj(fptr) = cellfun (@(x) x(2:end), obj(fptr), "Uniformoutput", false);
- endif
+ ## Remove leading "=" from formula strings
+ fptr = (typearr == 4);
+ obj(fptr) = cellfun (@(x) x(2:end), obj(fptr), "Uniformoutput", false);
## Create formula evaluator
frm_eval = xls.workbook.getCreationHelper ().createFormulaEvaluator ();
@@ -119,20 +139,37 @@
endif
for jj=1:ncols
kk = jj + lcol - 2; ## POI's column count is
0-based
- if (typearr(ii, jj) == ctype(5)) ## Empty cells
- cell = row.createCell (kk, ctype(5));
- elseif (typearr(ii, jj) == ctype(4)) ## Formulas
+ if (typearr(ii, jj) == 5) ## Empty cells
+ if (poiv4)
+ cell = row.createCell (kk, p4ctype(5).enum);
+ else
+ cell = row.createCell (kk, ctype(5));
+ endif
+ elseif (typearr(ii, jj) == 4) ## Formulas
## Try-catch needed as there's no guarantee for formula correctness
try
- cell = row.createCell (kk, ctype(4));
+ if (poiv4)
+ cell = row.createCell (kk, p4ctype(4).enum);
+ else
+ cell = row.createCell (kk, ctype(4));
+ endif
cell.setCellFormula (obj{ii,jj});
catch
++f_errs;
- cell.setCellType (ctype (3)); ## Enter formula as text
+ ## Enter formula as text
+ if (poiv4)
+ cell.setCellType (p4ctype(3).enum);
+ else
+ cell.setCellType (ctype (3));
+ endif
cell.setCellValue (obj{ii, jj});
end_try_catch
else
- cell = row.createCell (kk, typearr(ii,jj));
+ if (poiv4)
+ cell = row.createCell (kk, p4ctype(typearr(ii,jj)).enum);
+ else
+ cell = row.createCell (kk, ctype(typearr(ii,jj)));
+ endif
if (isnumeric (obj{ii, jj}))
cell.setCellValue (obj{ii, jj});
else
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/__POI_spsh2oct__.m
new/io-2.4.12/inst/private/__POI_spsh2oct__.m
--- old/io-2.4.11/inst/private/__POI_spsh2oct__.m 2018-04-30
00:08:17.803416542 +0200
+++ new/io-2.4.12/inst/private/__POI_spsh2oct__.m 2018-11-16
09:40:37.380362578 +0100
@@ -39,15 +39,36 @@
function [ rawarr, xls, rstatus ] = __POI_spsh2oct__ (xls, wsh, cellrange,
spsh_opts)
- persistent ctype;
+ persistent ctype poiv4 p4ctype;
if (isempty (ctype))
## Get enumerated cell types. Beware as they start at 0 not 1
- ctype(1) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_NUMERIC");
- ctype(2) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_STRING");
- ctype(3) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_FORMULA");
- ctype(4) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BLANK");
- ctype(5) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BOOLEAN");
- ctype(6) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_ERROR");
+ try
+ ## POI < 4
+ ctype(1) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_NUMERIC");
+ ctype(2) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BOOLEAN");
+ ctype(3) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_STRING");
+ ctype(4) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_FORMULA");
+ ctype(5) = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BLANK");
+ poiv4 = false;
+ catch
+ ## POI >= 4
+ p4ctype.enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"NUMERIC");
+ ctype(1) = p4ctype.enum.ordinal;
+ p4ctype.name = "numeric";
+ p4ctype(2).enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"BOOLEAN");
+ ctype(2) = p4ctype(2).enum.ordinal;
+ p4ctype(2).name = "boolean";
+ p4ctype(3).enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"STRING");
+ ctype(3) = p4ctype(3).enum.ordinal;
+ p4ctype(3).name = "string";
+ p4ctype(4).enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"FORMULA");
+ ctype(4) = p4ctype(4).enum.ordinal;
+ p4ctype(4).name = "formula";
+ p4ctype(5).enum = __java_get__ ("org.apache.poi.ss.usermodel.CellType",
"BLANK");
+ ctype(5) = p4ctype(5).enum.ordinal;
+ p4ctype(5).name = "blank";
+ poiv4 = true;
+ end_try_catch
endif
rstatus = 0; jerror = 0;
@@ -111,12 +132,18 @@
if (! isempty (scell))
## Explore cell contents
type_of_cell = scell.getCellType ();
- if (type_of_cell == ctype(3)) ## Formula
+ if (poiv4)
+ type_of_cell = type_of_cell.ordinal ();
+ endif
+ if (type_of_cell == ctype(4)) ## Formula
if (! spsh_opts.formulas_as_text)
try
## Because not al Excel formulas have been implemented in POI
cvalue = frm_eval.evaluate (scell);
type_of_cell = cvalue.getCellType();
+ if (poiv4)
+ type_of_cell = type_of_cell.ordinal ();
+ endif
## Separate switch because form.eval. yields different type
switch type_of_cell
case ctype (1) ## Numeric
@@ -141,20 +168,20 @@
endif
## Preparations done, get data values into data array
switch type_of_cell
- case ctype(1) ## 0 Numeric
+ case ctype(1) ## 1 Numeric
rawarr {ii+1-firstrow, jj+1-lcol} = scell.getNumericCellValue ();
- case ctype(2) ## 1 String
+ case ctype(2) ## 2 Boolean
+ rawarr {ii+1-firstrow, jj+1-lcol} = scell.getBooleanCellValue ();
+ case ctype(3) ## 3 String
rawarr {ii+1-firstrow, jj+1-lcol} = ...
char (scell.getRichStringCellValue ());
- case ctype(3)
+ case ctype(4)
if (spsh_opts.formulas_as_text)
tmp = char (scell.getCellFormula ());
rawarr {ii+1-firstrow, jj+1-lcol} = ["=" tmp];
endif
- case ctype(4) ## 3 Blank
+ case ctype(5) ## 4 Blank
## Blank; ignore until further notice
- case ctype(5) ## 4 Boolean
- rawarr {ii+1-firstrow, jj+1-lcol} = scell.getBooleanCellValue ();
otherwise ## 5 Error
## Ignore
endswitch
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/__POI_spsh_info__.m
new/io-2.4.12/inst/private/__POI_spsh_info__.m
--- old/io-2.4.11/inst/private/__POI_spsh_info__.m 2018-04-30
00:08:17.803416542 +0200
+++ new/io-2.4.12/inst/private/__POI_spsh_info__.m 2018-11-16
09:40:37.384362554 +0100
@@ -21,9 +21,9 @@
function [sh_names] = __POI_spsh_info__ (xls)
- persistent cblnk; cblnk = __java_get__ ("org.apache.poi.ss.usermodel.Cell",
"CELL_TYPE_BLANK");
sh_cnt = xls.workbook.getNumberOfSheets();
- sh_names = cell (sh_cnt, 2); nsrows = zeros (sh_cnt, 1);
+ sh_names = cell (sh_cnt, 2);
+ nsrows = zeros (sh_cnt, 1);
for ii=1:sh_cnt
sh = xls.workbook.getSheetAt (ii-1); # Java POI starts counting at
0
sh_names(ii, 1) = char (sh.getSheetName());
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/getxlsinterfaces.m
new/io-2.4.12/inst/private/getxlsinterfaces.m
--- old/io-2.4.11/inst/private/getxlsinterfaces.m 2018-04-30
00:08:17.807416525 +0200
+++ new/io-2.4.12/inst/private/getxlsinterfaces.m 2018-11-16
09:40:37.400362453 +0100
@@ -67,14 +67,19 @@
tmp1 = [];
elseif (has_java)
## Renew jcp (javaclasspath) as it may have been updated since last call
- jcp = javaclasspath ("-all"); ## For java pkg >= 1.2.8
- if (isempty (jcp))
- ## For java pkg < 1.2.8
- jcp = javaclasspath;
- endif
- if (isunix && ! iscell (jcp));
- jcp = strsplit (char (jcp), pathsep ());
- endif
+ try
+ jcp = javaclasspath ("-all"); ## For java pkg >=
1.2.8
+ if (isempty (jcp))
+ ## For java pkg < 1.2.8
+ jcp = javaclasspath;
+ endif
+ if (isunix && ! iscell (jcp));
+ jcp = strsplit (char (jcp), pathsep ());
+ endif
+ catch
+ warning ("getxlsinterfaces: Java system found but unusable\n");
+ has_java = 0;
+ end_try_catch
endif
endif
## deflt signals that some default interface has been selected. Just used
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/inst/private/spsh_prstype.m
new/io-2.4.12/inst/private/spsh_prstype.m
--- old/io-2.4.11/inst/private/spsh_prstype.m 2018-04-30 00:08:17.811416509
+0200
+++ new/io-2.4.12/inst/private/spsh_prstype.m 2018-11-16 09:40:37.400362453
+0100
@@ -33,43 +33,43 @@
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) = -1;
## Add in a filler value for 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 "=")
- fptr = cellfun (@(x) ischar (x) && strncmp (x, "=", 1), obj);
- typearr(fptr) = ctype(4);
## FORMULA
- endif
+ ## 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) = 3; ; ## Save strings in a safe place
+
+ emptr = cellfun ("isempty", obj);
+ obj(emptr) = 5; ## Set empty cells to EMPTY
+
+ lptr = cellfun ("islogical" , obj); ## Find logicals...
+ obj2(lptr) = obj(lptr); ## .. and set them to BOOLEAN
+
+ ptr = ! cellfun ("isfinite", obj); ## Find NaNs,Infs & set to BLANK
+ typearr(ptr) = 5; ## FIXME: do we need isfinite ()?
+ typearr(! ptr) = 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) = -1; ## Add in a filler value for
empty cells
+
+ typearr(txtptr) = 3; ## ...and clean up
+ typearr(emptr) = 5; ## EMPTY
+ typearr(lptr) = 2; ## BOOLEAN
+
+ if (! spsh_opts.formulas_as_text)
+ ## Find formulas (designated by a string starting with "=")
+ fptr = cellfun (@(x) ischar (x) && strncmp (x, "=", 1), obj);
+ typearr(fptr) = 4; ## FORMULA
+ endif
endfunction
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/src/cell2csv.cc
new/io-2.4.12/src/cell2csv.cc
--- old/io-2.4.11/src/cell2csv.cc 2018-04-30 00:08:17.819416477 +0200
+++ new/io-2.4.12/src/cell2csv.cc 2018-11-16 09:40:37.416362352 +0100
@@ -22,7 +22,7 @@
%! for ii=1:size (arr, 1)
%! arr1(ii, ii) = sprintf ("\"Val = %f\"", arr{ii, ii});
%! endfor
-%! f = tmpnam();
+%! f = tempname();
%! cell2csv (f, arr1);
%! arr2 = csv2cell (f);
%! unlink (f);
@@ -37,7 +37,7 @@
%! arr1(ii, ii) = sprintf ("Val = %f", arr{ii, ii});
%! endfor
%! arr1(2, 2) = [arr1{2, 2} ";"];
-%! f = tmpnam();
+%! f = tempname();
%! cell2csv (f, arr1, ";", "&");
%! arr2 = csv2cell (f, ";", "&");
%! unlink (f);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/io-2.4.11/src/csv2cell.cc
new/io-2.4.12/src/csv2cell.cc
--- old/io-2.4.11/src/csv2cell.cc 2018-04-30 00:08:17.819416477 +0200
+++ new/io-2.4.12/src/csv2cell.cc 2018-11-16 09:40:37.420362327 +0100
@@ -18,7 +18,7 @@
%% Check EOF w/o preceding EOL & text fields in 1st column disguised as
numeric str
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! fprintf (fid, "\"1\"");
%! fclose (fid);
@@ -27,7 +27,7 @@
%! assert (s, "1");
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! csvwrite(f, "\"1\",2", "DELIMITER", "");
%! s = csv2cell(f);
%! unlink (f);
@@ -35,7 +35,7 @@
%! assert (s{2}, 2);
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! csvwrite(f, "3,\"1\"", "DELIMITER", "");
%! s = csv2cell(f);
%! unlink (f);
@@ -45,7 +45,7 @@
%% Check proper string protection
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! str = ['01/03/2012,"H (Mar, 12)",26.750000,2584' "\n"];
%! str = [str '"01/04/2012",H (Mar, 12),2330' "\n"];
@@ -64,7 +64,7 @@
%% Check separator and string protection arguments
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! str = ['01/03/2012;$H (Mar; 12)$;26.750000;2584' "\n"];
%! str = [str '$01/04/2012$;H (Mar; 12);2330' "\n"];
@@ -83,7 +83,7 @@
%% Check headerlines,
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! fprintf (fid, "A, B\n 1, 2\n 3, 4\n 5, 6\n");
%! fclose (fid);
@@ -103,7 +103,7 @@
%% Check surplus headerlines w EOF before final EOL
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! fprintf (fid, "A, B\n 1, 2\n 3, 4\n 5, 6");
%! fclose (fid);
@@ -113,7 +113,7 @@
%% Check if csv2cell ignores trailing CR's in cells
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! fprintf (fid, "a\r\n1\r\nc\n4\n");
%! fclose (fid);
@@ -124,7 +124,7 @@
%% Check spreadsheet style range arg
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! fprintf (fid,
'1,2,3\n11,12,13,"14",15,16\n,22\n31,32,"33",34\n41,"42",,44,45\n51,52,53');
%! fclose (fid);
@@ -136,7 +136,7 @@
%% Check files with uneven line length w/o range arg
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! fprintf (fid,
'a,b,c,d,e,f\n11,12,13,"14",15,16\n,22\n31,32,"33",34\n41,"42",,44,45\n51,52,53');
%! fclose (fid);
@@ -151,7 +151,7 @@
%% Check ":" separator
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! fprintf (fid, "1:2\n3:4\n5:6");
%! fclose (fid);
@@ -161,7 +161,7 @@
%% Check ":" separator and spreadsheet style range combi
%!test
-%! f = tmpnam ();
+%! f = tempname ();
%! fid = fopen (f, 'w+');
%! fprintf (fid, "1:2:3\n4:5:6\n7:8:9\n");
%! fclose (fid);
@@ -386,7 +386,7 @@
for (int i = 0, len = str.length (); i <= len; i++)
if (i == len || ((str[i] == sep || str[i] == 10) && ! inside))
nbcolumns++;
- else if ((inside) && (str[i] == prot) && ((i < len) && (str[i+1] == prot)))
+ else if ((inside) && (str[i] == prot) && ((i+1 < len) && (str[i+1] ==
prot)))
++i;
else if (str[i] == prot)
inside = !inside;
@@ -475,7 +475,7 @@
break;
}
/* Check for last char to be 13 (CR) and remove if found */
- if (word[word.length ()-1] == char(13))
+ if (word.length () && word[word.length ()-1] == char(13))
word.resize (word.size () - 1);
/* Check if scalar */
const char *word_str = word.c_str ();
@@ -491,7 +491,7 @@
word = "";
oinside = false;
}
- else if ((inside) && (str[k] == prot) && ((k < len) && (str[k+1] ==
prot)))
+ else if ((inside) && (str[k] == prot) && ((k+1 < len) && (str[k+1]
== prot)))
{
/* Inside a string */
word += prot;