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