annotate src/of-miscellaneous-1-fixes.patch @ 4043:b54e00ea56bc

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