comparison src/of-dataframe-1-fixes.patch @ 3912:52abc9be09fa

of-dataframe: add to mxe * src/of-dataframe.mk: new file * src/of-dataframe-1-fixes.patch: new file * dist-files.mk: add of-dataframe.mk of-dataframe--fixes.patch * index.html: add of-dataframe * Makefile.am: add of-dataframe * build_packages.m: add dataframe package
author John Donoghue <john.donoghue@ieee.org>
date Wed, 22 Apr 2015 19:15:12 -0400
parents
children
comparison
equal deleted inserted replaced
3911:006263ce4905 3912:52abc9be09fa
1 diff -urN dataframe-1.1.0.orig/inst/@dataframe/private/strsplit.m dataframe-1.1.0/inst/@dataframe/private/strsplit.m
2 --- dataframe-1.1.0.orig/inst/@dataframe/private/strsplit.m 2015-04-22 19:07:16.000000000 -0400
3 +++ dataframe-1.1.0/inst/@dataframe/private/strsplit.m 1969-12-31 19:00:00.000000000 -0500
4 @@ -1,125 +0,0 @@
5 -## Copyright (C) 2009-2012 Jaroslav Hajek
6 -##
7 -## This file is part of Octave.
8 -##
9 -## Octave is free software; you can redistribute it and/or modify it
10 -## under the terms of the GNU General Public License as published by
11 -## the Free Software Foundation; either version 3 of the License, or (at
12 -## your option) any later version.
13 -##
14 -## Octave is distributed in the hope that it will be useful, but
15 -## WITHOUT ANY WARRANTY; without even the implied warranty of
16 -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 -## General Public License for more details.
18 -##
19 -## You should have received a copy of the GNU General Public License
20 -## along with Octave; see the file COPYING. If not, see
21 -## <http://www.gnu.org/licenses/>.
22 -##
23 -## FIXME: this file is here to avoid conflicts with new Octave versions. Matlab
24 -## has recently added strplit function (used to exist in Octave only) but
25 -## their syntax is not compatible with ours. Rather than timing the
26 -## release of each octave forge package that used strsplit, a copy of the
27 -## old version was placed as private. Once the new Octave version is
28 -## released, this file can be removed, and the calls to strsplit fixed.
29 -
30 -## -*- texinfo -*-
31 -## @deftypefn {Function File} {[@var{cstr}] =} strsplit (@var{s}, @var{sep})
32 -## @deftypefnx {Function File} {[@var{cstr}] =} strsplit (@var{s}, @var{sep}, @var{strip_empty})
33 -## Split the string @var{s} using one or more separators @var{sep} and return
34 -## a cell array of strings. Consecutive separators and separators at
35 -## boundaries result in empty strings, unless @var{strip_empty} is true.
36 -## The default value of @var{strip_empty} is false.
37 -##
38 -## 2-D character arrays are split at separators and at the original column
39 -## boundaries.
40 -##
41 -## Example:
42 -##
43 -## @example
44 -## @group
45 -## strsplit ("a,b,c", ",")
46 -## @result{}
47 -## @{
48 -## [1,1] = a
49 -## [1,2] = b
50 -## [1,3] = c
51 -## @}
52 -##
53 -## strsplit (["a,b" ; "cde"], ",")
54 -## @result{}
55 -## @{
56 -## [1,1] = a
57 -## [1,2] = b
58 -## [1,3] = cde
59 -## @}
60 -## @end group
61 -## @end example
62 -## @seealso{strtok}
63 -## @end deftypefn
64 -
65 -function cstr = strsplit (s, sep, strip_empty = false)
66 -
67 - if (nargin < 2 || nargin > 3)
68 - print_usage ();
69 - elseif (! ischar (s) || ! ischar (sep))
70 - error ("strsplit: S and SEP must be string values");
71 - elseif (! isscalar (strip_empty))
72 - error ("strsplit: STRIP_EMPTY must be a scalar value");
73 - endif
74 -
75 - if (isempty (s))
76 - cstr = cell (size (s));
77 - else
78 - if (rows (s) > 1)
79 - ## For 2-D arrays, add separator character at line boundaries
80 - ## and transform to single string
81 - s(:, end+1) = sep(1);
82 - s = reshape (s.', 1, numel (s));
83 - s(end) = [];
84 - endif
85 -
86 - ## Split s according to delimiter
87 - if (isscalar (sep))
88 - ## Single separator
89 - idx = find (s == sep);
90 - else
91 - ## Multiple separators
92 - idx = strchr (s, sep);
93 - endif
94 -
95 - ## Get substring lengths.
96 - if (isempty (idx))
97 - strlens = length (s);
98 - else
99 - strlens = [idx(1)-1, diff(idx)-1, numel(s)-idx(end)];
100 - endif
101 - ## Remove separators.
102 - s(idx) = [];
103 - if (strip_empty)
104 - ## Omit zero lengths.
105 - strlens = strlens(strlens != 0);
106 - endif
107 -
108 - ## Convert!
109 - cstr = mat2cell (s, 1, strlens);
110 - endif
111 -
112 -endfunction
113 -
114 -
115 -%!assert (strsplit ("road to hell", " "), {"road", "to", "hell"})
116 -%!assert (strsplit ("road to^hell", " ^"), {"road", "to", "hell"})
117 -%!assert (strsplit ("road to--hell", " -", true), {"road", "to", "hell"})
118 -%!assert (strsplit (["a,bc";",de"], ","), {"a", "bc", char(ones(1,0)), "de "})
119 -%!assert (strsplit (["a,bc";",de"], ",", true), {"a", "bc", "de "})
120 -%!assert (strsplit (["a,bc";",de"], ", ", true), {"a", "bc", "de"})
121 -
122 -%% Test input validation
123 -%!error strsplit ()
124 -%!error strsplit ("abc")
125 -%!error strsplit ("abc", "b", true, 4)
126 -%!error <S and SEP must be string values> strsplit (123, "b")
127 -%!error <S and SEP must be string values> strsplit ("abc", 1)
128 -%!error <STRIP_EMPTY must be a scalar value> strsplit ("abc", "def", ones (3,3))
129 -