Mercurial > hg > octave-nkf
annotate src/strfns.cc @ 8710:739141cde75a ss-3-1-52
fix typo in Array-f.cc
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 09 Feb 2009 21:51:31 +0100 |
parents | 937921654627 |
children | 732cb0236488 |
rev | line source |
---|---|
807 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 1999, 2002, 2003, 2004, 2005, |
4 2006, 2007 John W. Eaton | |
807 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
807 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
807 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
1192 | 25 #include <config.h> |
807 | 26 #endif |
27 | |
1355 | 28 #include <cctype> |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
29 |
8463
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
30 #include <queue> |
5765 | 31 #include <sstream> |
807 | 32 |
33 #include "dMatrix.h" | |
34 | |
5416 | 35 #include "Cell.h" |
1355 | 36 #include "defun.h" |
807 | 37 #include "error.h" |
38 #include "gripes.h" | |
2366 | 39 #include "ov.h" |
1355 | 40 #include "oct-obj.h" |
4457 | 41 #include "unwind-prot.h" |
807 | 42 #include "utils.h" |
43 | |
4358 | 44 DEFUN (char, args, , |
45 "-*- texinfo -*-\n\ | |
46 @deftypefn {Built-in Function} {} char (@var{x})\n\ | |
47 @deftypefnx {Built-in Function} {} char (@var{cell_array})\n\ | |
48 @deftypefnx {Built-in Function} {} char (@var{s1}, @var{s2}, @dots{})\n\ | |
8461
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
49 Create a string array from one or more numeric matrices, character\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
50 matrices or cell arrays. For numerical input, each element is converted\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
51 to the corresponding ASCII character. The arguments (and elements of\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
52 cell array(s)) are concatenated vertically.\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
53 The returned values are padded with blanks as needed to make each row\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
54 of the string array have the same length. Empty strings are not removed.\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
55 For example,\n\ |
4358 | 56 \n\ |
57 @example\n\ | |
58 @group\n\ | |
8461
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
59 char ([97, 98, 99], \"\", @{\"98\", \"99\", 100@}, [\"num\", \"bers\"])\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
60 @result{} [\"abc \"\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
61 \" \"\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
62 \"98 \"\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
63 \"99 \"\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
64 \"d \"\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
65 \"numbers\"]\n\ |
4358 | 66 @end group\n\ |
67 @end example\n\ | |
68 \n\ | |
69 @end deftypefn") | |
70 { | |
71 octave_value retval; | |
72 | |
73 int nargin = args.length (); | |
74 | |
75 if (nargin == 1) | |
5281 | 76 retval = args(0).convert_to_str (true, true, |
77 args(0).is_dq_string () ? '"' : '\''); | |
4358 | 78 else if (nargin > 1) |
79 { | |
80 int n_elts = 0; | |
81 | |
82 int max_len = 0; | |
83 | |
8463
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
84 std::queue<string_vector> args_as_strings; |
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
85 |
4358 | 86 for (int i = 0; i < nargin; i++) |
87 { | |
5707 | 88 string_vector s = args(i).all_strings (); |
4358 | 89 |
90 if (error_state) | |
91 { | |
4457 | 92 error ("char: unable to convert some args to strings"); |
4358 | 93 return retval; |
94 } | |
95 | |
8353
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
96 if (s.length () > 0) |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
97 n_elts += s.length (); |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
98 else |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
99 n_elts += 1; |
4358 | 100 |
101 int s_max_len = s.max_length (); | |
102 | |
103 if (s_max_len > max_len) | |
104 max_len = s_max_len; | |
8463
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
105 |
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
106 args_as_strings.push (s); |
4358 | 107 } |
108 | |
109 string_vector result (n_elts); | |
110 | |
111 int k = 0; | |
112 | |
113 for (int i = 0; i < nargin; i++) | |
114 { | |
8464
cb48e594a441
Fchar, Fstrvcat: use queue correctly
John W. Eaton <jwe@octave.org>
parents:
8463
diff
changeset
|
115 string_vector s = args_as_strings.front (); |
cb48e594a441
Fchar, Fstrvcat: use queue correctly
John W. Eaton <jwe@octave.org>
parents:
8463
diff
changeset
|
116 args_as_strings.pop (); |
4358 | 117 |
118 int n = s.length (); | |
119 | |
8353
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
120 if (n > 0) |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
121 { |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
122 for (int j = 0; j < n; j++) |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
123 { |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
124 std::string t = s[j]; |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
125 int t_len = t.length (); |
4358 | 126 |
8353
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
127 if (max_len > t_len) |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
128 t += std::string (max_len - t_len, ' '); |
4358 | 129 |
8353
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
130 result[k++] = t; |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
131 } |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
132 } |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
133 else |
8463
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
134 result[k++] = std::string (max_len, ' '); |
4358 | 135 } |
136 | |
5280 | 137 retval = octave_value (result, '\''); |
4358 | 138 } |
139 else | |
5823 | 140 print_usage (); |
4358 | 141 |
142 return retval; | |
143 } | |
144 | |
8353
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
145 /* |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
146 %!error <Invalid call to char> char() |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
147 %!assert (char (100) == "d"); |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
148 %!assert (all(char (100,100) == ["d";"d"])); |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
149 %!assert (all(char ({100,100}) == ["d";"d"])); |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
150 %!assert (all(char ([100,100]) == ["dd"])); |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
151 %!assert (all(char ({100,{100}}) == ["d";"d"])); |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
152 %!assert (all(char (100, [], 100) == ["d";" ";"d"])) |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
153 %!assert (all(char ({100, [], 100}) == ["d";" ";"d"])) |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
154 %!assert (all(char ({100,{100, {""}}}) == ["d";"d";" "])) |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
155 %!assert (all(char (["a";"be"], {"c", 100}) == ["a";"be";"c";"d"])) |
8372
8dff9cba15fe
move str2mat to deprecated and make it a simple wrapper around char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8353
diff
changeset
|
156 %!assert(strcmp (char ("a", "bb", "ccc"), ["a "; "bb "; "ccc"])); |
8353
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
157 */ |
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
158 |
8462
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
159 DEFUN (strvcat, args, , |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
160 "-*- texinfo -*-\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
161 @deftypefn {Built-in Function} {} strvcat (@var{x})\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
162 @deftypefnx {Built-in Function} {} strvcat (@var{cell_array})\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
163 @deftypefnx {Built-in Function} {} strvcat (@var{s1}, @var{s2}, @dots{})\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
164 Create a character array from one or more numeric matrices, character\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
165 matrices or cell arrays. For numerical input, each element is converted\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
166 to the corresponding ASCII character. The arguments (and elements of\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
167 cell array(s)) are concatenated vertically.\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
168 The returned values are padded with blanks as needed to make each row\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
169 of the string array have the same length. Unlike @code{char}, empty\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
170 strings are removed.\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
171 For example,\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
172 \n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
173 @example\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
174 @group\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
175 strvcat ([97, 98, 99], \"\", @{\"98\", \"99\", 100@}, [\"num\", \"bers\"])\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
176 @result{} [\"abc \"\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
177 \"98 \"\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
178 \"99 \"\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
179 \"d \"\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
180 \"numbers\"]\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
181 @end group\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
182 @end example\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
183 \n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
184 @seealso{char, strcat, cstrcat}\n\ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
185 @end deftypefn") |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
186 { |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
187 octave_value retval; |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
188 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
189 int nargin = args.length (); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
190 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
191 if (nargin > 0) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
192 { |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
193 int n_elts = 0; |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
194 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
195 int max_len = 0; |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
196 |
8463
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
197 std::queue<string_vector> args_as_strings; |
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
198 |
8462
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
199 for (int i = 0; i < nargin; i++) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
200 { |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
201 string_vector s = args(i).all_strings (); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
202 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
203 if (error_state) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
204 { |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
205 error ("strvcat: unable to convert some args to strings"); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
206 return retval; |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
207 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
208 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
209 int n = s.length (); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
210 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
211 // do not count empty strings in calculation of number of elements |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
212 if (n > 0) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
213 { |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
214 for (int j = 0; j < n; j++) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
215 { |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
216 if (s[j].length () > 0) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
217 n_elts++; |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
218 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
219 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
220 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
221 int s_max_len = s.max_length (); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
222 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
223 if (s_max_len > max_len) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
224 max_len = s_max_len; |
8463
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
225 |
a74871446af7
Fchar, Fstrvcat: use queue to avoid duplicate calls to all_strings
John W. Eaton <jwe@octave.org>
parents:
8462
diff
changeset
|
226 args_as_strings.push (s); |
8462
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
227 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
228 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
229 string_vector result (n_elts); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
230 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
231 int k = 0; |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
232 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
233 for (int i = 0; i < nargin; i++) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
234 { |
8464
cb48e594a441
Fchar, Fstrvcat: use queue correctly
John W. Eaton <jwe@octave.org>
parents:
8463
diff
changeset
|
235 string_vector s = args_as_strings.front (); |
cb48e594a441
Fchar, Fstrvcat: use queue correctly
John W. Eaton <jwe@octave.org>
parents:
8463
diff
changeset
|
236 args_as_strings.pop (); |
8462
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
237 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
238 int n = s.length (); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
239 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
240 if (n > 0) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
241 { |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
242 for (int j = 0; j < n; j++) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
243 { |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
244 std::string t = s[j]; |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
245 if (t.length () > 0) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
246 { |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
247 int t_len = t.length (); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
248 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
249 if (max_len > t_len) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
250 t += std::string (max_len - t_len, ' '); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
251 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
252 result[k++] = t; |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
253 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
254 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
255 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
256 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
257 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
258 retval = octave_value (result, '\''); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
259 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
260 else |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
261 print_usage (); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
262 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
263 return retval; |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
264 } |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
265 |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
266 /* |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
267 %!error <Invalid call to strvcat> strvcat() |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
268 %!assert (strvcat (""), ""); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
269 %!assert (strvcat (100) == "d"); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
270 %!assert (all(strvcat (100,100) == ["d";"d"])); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
271 %!assert (all(strvcat ({100,100}) == ["d";"d"])); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
272 %!assert (all(strvcat ([100,100]) == ["dd"])); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
273 %!assert (all(strvcat ({100,{100}}) == ["d";"d"])); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
274 %!assert (all(strvcat (100, [], 100) == ["d";"d"])) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
275 %!assert (all(strvcat ({100, [], 100}) == ["d";"d"])) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
276 %!assert (all(strvcat ({100,{100, {""}}}) == ["d";"d"])) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
277 %!assert (all(strvcat (["a";"be"], {"c", 100}) == ["a";"be";"c";"d"])) |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
278 %!assert(strcmp (strvcat ("a", "bb", "ccc"), ["a "; "bb "; "ccc"])); |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
279 */ |
ebdf1e058d85
Make strvcat an internal function
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8461
diff
changeset
|
280 |
8353
349a555729a9
keep empty strings in char
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
7528
diff
changeset
|
281 |
4535 | 282 DEFUN (ischar, args, , |
3361 | 283 "-*- texinfo -*-\n\ |
4535 | 284 @deftypefn {Built-in Function} {} ischar (@var{a})\n\ |
8461
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
285 Return 1 if @var{a} is a character array. Otherwise, return 0.\n\ |
3361 | 286 @end deftypefn") |
807 | 287 { |
4233 | 288 octave_value retval; |
807 | 289 |
290 int nargin = args.length (); | |
291 | |
292 if (nargin == 1 && args(0).is_defined ()) | |
4233 | 293 retval = args(0).is_string (); |
807 | 294 else |
5823 | 295 print_usage (); |
807 | 296 |
297 return retval; | |
298 } | |
299 | |
8461
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
300 /* |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
301 |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
302 %!assert (ischar ("a"), logical (1)); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
303 %!assert (ischar (["ab";"cd"]), logical (1)); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
304 %!assert (ischar ({"ab"}), logical (0)); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
305 %!assert (ischar (1), logical (0)); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
306 %!error <Invalid call to ischar.*> ischar (); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
307 |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
308 */ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
309 |
5415 | 310 DEFUN (strcmp, args, , |
311 "-*- texinfo -*-\n\ | |
6678 | 312 @deftypefn {Built-in Function} {} strcmp (@var{s1}, @var{s2})\n\ |
5415 | 313 Return 1 if the character strings @var{s1} and @var{s2} are the same,\n\ |
314 and 0 otherwise.\n\ | |
5674 | 315 \n\ |
316 If either @var{s1} or @var{s2} is a cell array of strings, then an array\n\ | |
317 of the same size is returned, containing the values described above for\n\ | |
318 every member of the cell array. The other argument may also be a cell\n\ | |
319 array of strings (of the same size or with only one element), char matrix\n\ | |
320 or character string.\n\ | |
321 \n\ | |
322 @strong{Caution:} For compatibility with @sc{Matlab}, Octave's strcmp\n\ | |
323 function returns 1 if the character strings are equal, and 0 otherwise.\n\ | |
324 This is just the opposite of the corresponding C library function.\n\ | |
325 @seealso{strcmpi, strncmp, strncmpi}\n\ | |
5415 | 326 @end deftypefn") |
327 { | |
5531 | 328 octave_value retval; |
5415 | 329 |
5416 | 330 if (args.length () == 2) |
331 { | |
332 bool s1_string = args(0).is_string (); | |
333 bool s1_cell = args(0).is_cell (); | |
334 bool s2_string = args(1).is_string (); | |
335 bool s2_cell = args(1).is_cell (); | |
5415 | 336 |
5416 | 337 if (s1_string && s2_string) |
338 { | |
339 // Must match exactly in all dimensions. | |
340 | |
341 const dim_vector dv1 = args(0).dims (); | |
342 const dim_vector dv2 = args(1).dims (); | |
5415 | 343 |
5416 | 344 if (dv1.length () == dv2.length ()) |
345 { | |
346 for (int i = 0; i < dv1.length (); i++) | |
347 { | |
348 if (dv1(i) != dv2(i)) | |
349 { | |
350 retval = false; | |
351 return retval; | |
352 } | |
353 } | |
5415 | 354 |
5416 | 355 if (dv1(0) == 0) |
356 retval = true; | |
357 else | |
358 { | |
359 charNDArray s1 = args(0).char_array_value (); | |
360 charNDArray s2 = args(1).char_array_value (); | |
5415 | 361 |
5416 | 362 for (int i = 0; i < dv1.numel (); i++) |
363 { | |
364 if (s1(i) != s2(i)) | |
365 { | |
366 retval = false; | |
367 return retval; | |
368 } | |
369 } | |
5415 | 370 |
5416 | 371 retval = true; |
372 } | |
5415 | 373 } |
374 } | |
5416 | 375 else if ((s1_string && s2_cell) || (s1_cell && s2_string)) |
5415 | 376 { |
5416 | 377 string_vector str; |
378 Cell cell; | |
379 int r; | |
5415 | 380 |
5416 | 381 if (s1_string) |
382 { | |
383 str = args(0).all_strings (); | |
384 r = args(0).rows (); | |
385 cell = args(1).cell_value (); | |
386 } | |
387 else | |
388 { | |
389 str = args(1).all_strings (); | |
390 r = args(1).rows (); | |
391 cell = args(0).cell_value (); | |
392 } | |
393 | |
5862 | 394 if (r == 0 || r == 1) |
5416 | 395 { |
396 // Broadcast the string. | |
397 | |
8524
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8472
diff
changeset
|
398 boolNDArray output (cell.dims (), false); |
5415 | 399 |
5862 | 400 std::string s = r == 0 ? std::string () : str[0]; |
401 | |
5416 | 402 for (int i = 0; i < cell.length (); i++) |
6250 | 403 { |
404 if (cell(i).is_string ()) | |
405 output(i) = (cell(i).string_value () == s); | |
406 } | |
5416 | 407 |
408 retval = output; | |
409 } | |
410 else if (r > 1) | |
5415 | 411 { |
5416 | 412 if (cell.length () == 1) |
5415 | 413 { |
5416 | 414 // Broadcast the cell. |
415 | |
416 const dim_vector dv (r, 1); | |
8472
5451f7460ea6
strfns.cc (Fstrcmp, Fstrncmp): initialize all elements of output with constructor arg
John W. Eaton <jwe@octave.org>
parents:
8464
diff
changeset
|
417 boolNDArray output (dv, false); |
5416 | 418 |
419 if (cell(0).is_string ()) | |
420 { | |
421 const std::string str2 = cell(0).string_value (); | |
5415 | 422 |
5416 | 423 for (int i = 0; i < r; i++) |
424 output(i) = (str[i] == str2); | |
425 } | |
426 | |
427 retval = output; | |
5415 | 428 } |
429 else | |
430 { | |
5416 | 431 // Must match in all dimensions. |
432 | |
8524
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8472
diff
changeset
|
433 boolNDArray output (cell.dims (), false); |
5415 | 434 |
5416 | 435 if (cell.length () == r) |
436 { | |
437 for (int i = 0; i < r; i++) | |
6250 | 438 { |
439 if (cell(i).is_string ()) | |
440 output(i) = (str[i] == cell(i).string_value ()); | |
441 } | |
5415 | 442 |
5416 | 443 retval = output; |
444 } | |
445 else | |
446 retval = false; | |
5415 | 447 } |
448 } | |
449 } | |
5416 | 450 else if (s1_cell && s2_cell) |
5415 | 451 { |
5416 | 452 Cell cell1; |
453 Cell cell2; | |
5415 | 454 |
5416 | 455 int r1 = args(0).numel (); |
456 int r2; | |
457 | |
458 if (r1 == 1) | |
459 { | |
460 // Make the singleton cell2. | |
5415 | 461 |
5416 | 462 cell1 = args(1).cell_value (); |
463 cell2 = args(0).cell_value (); | |
464 r1 = cell1.length (); | |
465 r2 = 1; | |
466 } | |
467 else | |
468 { | |
469 cell1 = args(0).cell_value (); | |
470 cell2 = args(1).cell_value (); | |
471 r2 = cell2.length (); | |
472 } | |
5415 | 473 |
8524
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8472
diff
changeset
|
474 const dim_vector size1 = cell1.dims (); |
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8472
diff
changeset
|
475 const dim_vector size2 = cell2.dims (); |
5416 | 476 |
8472
5451f7460ea6
strfns.cc (Fstrcmp, Fstrncmp): initialize all elements of output with constructor arg
John W. Eaton <jwe@octave.org>
parents:
8464
diff
changeset
|
477 boolNDArray output (size1, false); |
5416 | 478 |
479 if (r2 == 1) | |
480 { | |
481 // Broadcast cell2. | |
482 | |
8472
5451f7460ea6
strfns.cc (Fstrcmp, Fstrncmp): initialize all elements of output with constructor arg
John W. Eaton <jwe@octave.org>
parents:
8464
diff
changeset
|
483 if (cell2(0).is_string ()) |
5416 | 484 { |
485 const std::string str2 = cell2(0).string_value (); | |
486 | |
487 for (int i = 0; i < r1; i++) | |
488 { | |
489 if (cell1(i).is_string ()) | |
490 { | |
491 const std::string str1 = cell1(i).string_value (); | |
492 output(i) = (str1 == str2); | |
493 } | |
494 } | |
495 } | |
5415 | 496 } |
5416 | 497 else |
498 { | |
499 if (size1 != size2) | |
500 { | |
501 error ("strcmp: nonconformant cell arrays"); | |
502 return retval; | |
503 } | |
504 | |
505 for (int i = 0; i < r1; i++) | |
506 { | |
507 if (cell1(i).is_string () && cell2(i).is_string ()) | |
508 { | |
509 const std::string str1 = cell1(i).string_value (); | |
510 const std::string str2 = cell2(i).string_value (); | |
511 output(i) = (str1 == str2); | |
512 } | |
513 } | |
514 } | |
515 | |
516 retval = output; | |
5415 | 517 } |
5531 | 518 else |
519 retval = false; | |
5415 | 520 } |
5416 | 521 else |
5823 | 522 print_usage (); |
5415 | 523 |
524 return retval; | |
525 } | |
526 | |
5862 | 527 /* |
528 %!shared x | |
529 %! x = char (zeros (0, 2)); | |
530 %!assert (strcmp ('', x) == false); | |
531 %!assert (strcmp (x, '') == false); | |
532 %!assert (strcmp (x, x) == true); | |
5911 | 533 ## %!assert (strcmp ({''}, x) == false); |
534 ## %!assert (strcmp ({x}, '') == false); | |
535 ## %!assert (strcmp ({x}, x) == true); | |
536 ## %!assert (strcmp ('', {x}) == false); | |
537 ## %!assert (strcmp (x, {''}) == false); | |
538 ## %!assert (strcmp (x, {x}) == true); | |
539 ## %!assert (all (strcmp ({x; x}, '') == [false; false])); | |
540 ## %!assert (all (strcmp ({x; x}, {''}) == [false; false])); | |
541 ## %!assert (all (strcmp ('', {x; x}) == [false; false])); | |
542 ## %!assert (all (strcmp ({''}, {x; x}) == [false; false])); | |
5862 | 543 %!assert (strcmp ({'foo'}, x) == false); |
544 %!assert (strcmp ({'foo'}, 'foo') == true); | |
545 %!assert (strcmp ({'foo'}, x) == false); | |
546 %!assert (strcmp (x, {'foo'}) == false); | |
547 %!assert (strcmp ('foo', {'foo'}) == true); | |
548 %!assert (strcmp (x, {'foo'}) == false); | |
549 %!shared y | |
550 %! y = char (zeros (2, 0)); | |
551 %!assert (strcmp ('', y) == false); | |
552 %!assert (strcmp (y, '') == false); | |
553 %!assert (strcmp (y, y) == true); | |
554 %!assert (all (strcmp ({''}, y) == [true; true])); | |
555 %!assert (strcmp ({y}, '') == true); | |
556 %!assert (all (strcmp ({y}, y) == [true; true])); | |
557 %!assert (all (strcmp ('', {y}) == [true; true])); | |
558 %!assert (all (strcmp (y, {''}) == [true; true])); | |
559 %!assert (all (strcmp (y, {y}) == [true; true])); | |
5911 | 560 ## %!assert (all (strcmp ({y; y}, '') == [false; false])); |
561 ## %!assert (all (strcmp ({y; y}, {''}) == [false; false])); | |
562 ## %!assert (all (strcmp ('', {y; y}) == [false; false])); | |
563 ## %!assert (all (strcmp ({''}, {y; y}) == [false; false])); | |
5862 | 564 %!assert (all (strcmp ({'foo'}, y) == [false; false])); |
565 %!assert (all (strcmp ({'foo'}, y) == [false; false])); | |
566 %!assert (all (strcmp (y, {'foo'}) == [false; false])); | |
567 %!assert (all (strcmp (y, {'foo'}) == [false; false])); | |
568 */ | |
569 | |
6250 | 570 DEFUN (strncmp, args, , |
571 "-*- texinfo -*-\n\ | |
6678 | 572 @deftypefn {Built-in Function} {} strncmp (@var{s1}, @var{s2}, @var{n})\n\ |
6250 | 573 Return 1 if the first @var{n} characters of strings @var{s1} and @var{s2} are the same,\n\ |
574 and 0 otherwise.\n\ | |
575 \n\ | |
576 @example\n\ | |
577 @group\n\ | |
578 strncmp (\"abce\", \"abcd\", 3)\n\ | |
579 @result{} 1\n\ | |
580 @end group\n\ | |
581 @end example\n\ | |
582 \n\ | |
583 If either @var{s1} or @var{s2} is a cell array of strings, then an array\n\ | |
584 of the same size is returned, containing the values described above for\n\ | |
585 every member of the cell array. The other argument may also be a cell\n\ | |
586 array of strings (of the same size or with only one element), char matrix\n\ | |
587 or character string.\n\ | |
588 \n\ | |
589 @example\n\ | |
590 @group\n\ | |
6256 | 591 strncmp (\"abce\", @{\"abcd\", \"bca\", \"abc\"@}, 3)\n\ |
6250 | 592 @result{} [1, 0, 1]\n\ |
593 @end group\n\ | |
594 @end example\n\ | |
595 \n\ | |
596 @strong{Caution:} For compatibility with @sc{Matlab}, Octave's strncmp\n\ | |
597 function returns 1 if the character strings are equal, and 0 otherwise.\n\ | |
598 This is just the opposite of the corresponding C library function.\n\ | |
599 @seealso{strncmpi, strcmp, strcmpi}\n\ | |
600 @end deftypefn") | |
601 { | |
602 octave_value retval; | |
603 | |
604 if (args.length () == 3) | |
605 { | |
606 bool s1_string = args(0).is_string (); | |
607 bool s1_cell = args(0).is_cell (); | |
608 bool s2_string = args(1).is_string (); | |
609 bool s2_cell = args(1).is_cell (); | |
610 | |
611 // Match only first n strings. | |
612 int n = args(2).int_value (); | |
613 | |
614 if (n <= 0) | |
615 { | |
616 error ("strncmp: N must be greater than 0"); | |
617 return retval; | |
618 } | |
619 | |
620 if (s1_string && s2_string) | |
621 { | |
622 // The only restriction here is that each string has equal or | |
623 // greater than n characters | |
624 | |
625 const dim_vector dv1 = args(0).dims (); | |
626 const dim_vector dv2 = args(1).dims (); | |
627 | |
628 if (dv1.numel () >= n && dv2.numel () >= n) | |
629 { | |
630 // Follow Matlab in the sense that the first n characters of | |
631 // the two strings (in column major order) need to be the same. | |
632 charNDArray s1 = args(0).char_array_value (); | |
633 charNDArray s2 = args(1).char_array_value (); | |
634 | |
635 for (int i = 0; i < n; i++) | |
636 { | |
637 if (s1(i) != s2(i)) | |
638 { | |
639 retval = false; | |
640 return retval; | |
641 } | |
642 } | |
643 | |
644 retval = true; | |
645 } | |
646 else | |
647 retval = false; | |
648 } | |
649 else if ((s1_string && s2_cell) || (s1_cell && s2_string)) | |
650 { | |
651 string_vector str; | |
652 Cell cell; | |
653 int r, c; | |
654 | |
655 if (s1_string) | |
656 { | |
657 str = args(0).all_strings (); | |
658 r = args(0).rows (); | |
659 c = args(0).columns (); | |
660 cell = args(1).cell_value (); | |
661 } | |
662 else | |
663 { | |
664 str = args(1).all_strings (); | |
665 r = args(1).rows (); | |
666 c = args(1).columns (); | |
667 cell = args(0).cell_value (); | |
668 } | |
669 | |
670 if (r == 1) | |
671 { | |
672 // Broadcast the string. | |
673 | |
8524
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8472
diff
changeset
|
674 boolNDArray output (cell.dims (), false); |
6250 | 675 |
676 if (c < n) | |
677 { | |
678 for (int i = 0; i < cell.length (); i++) | |
679 output(i) = false; | |
680 } | |
681 else | |
682 { | |
683 for (int i = 0; i < cell.length (); i++) | |
684 { | |
685 if (cell(i).is_string ()) | |
686 { | |
687 const std::string str2 = cell(i).string_value (); | |
688 | |
8472
5451f7460ea6
strfns.cc (Fstrcmp, Fstrncmp): initialize all elements of output with constructor arg
John W. Eaton <jwe@octave.org>
parents:
8464
diff
changeset
|
689 if (str2.length() >= n |
5451f7460ea6
strfns.cc (Fstrcmp, Fstrncmp): initialize all elements of output with constructor arg
John W. Eaton <jwe@octave.org>
parents:
8464
diff
changeset
|
690 && str2.compare (0, n, str[0], 0, n) == 0) |
6250 | 691 output(i) = true; |
692 } | |
693 } | |
694 } | |
695 | |
696 retval = output; | |
697 } | |
698 else if (r > 1) | |
699 { | |
700 if (cell.length () == 1) | |
701 { | |
702 // Broadcast the cell. | |
703 | |
704 const dim_vector dv (r, 1); | |
8472
5451f7460ea6
strfns.cc (Fstrcmp, Fstrncmp): initialize all elements of output with constructor arg
John W. Eaton <jwe@octave.org>
parents:
8464
diff
changeset
|
705 boolNDArray output (dv, false); |
6250 | 706 |
707 if (cell(0).is_string () && c >= n) | |
708 { | |
709 const std::string str2 = cell(0).string_value (); | |
710 | |
711 if (str2.length () >= n) | |
712 { | |
713 for (int i = 0; i < r; i++) | |
714 { | |
715 if (str[i].compare (0, n, str2, 0, n) == 0) | |
716 output(i) = true; | |
717 } | |
718 } | |
719 } | |
720 | |
721 retval = output; | |
722 } | |
723 else | |
724 { | |
725 // Must match in all dimensions. | |
726 | |
8524
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8472
diff
changeset
|
727 boolNDArray output (cell.dims (), false); |
6250 | 728 |
729 if (cell.numel () == r) | |
730 { | |
731 for (int i = 0; i < r; i++) | |
732 { | |
733 if (cell(i).is_string () && c >= n) | |
734 { | |
735 std::string str2 = cell(i).string_value (); | |
736 | |
737 if (str2.length () >= n | |
738 && str2.compare (0, n, str[i], 0, n) == 0) | |
739 output(i) = true; | |
740 } | |
741 } | |
742 | |
743 retval = output; | |
744 } | |
745 else | |
746 { | |
747 error ("strncmp: the number of rows of the string matrix must match the number of elements in the cell"); | |
748 return retval; | |
749 } | |
750 } | |
751 } | |
752 } | |
753 else if (s1_cell && s2_cell) | |
754 { | |
755 Cell cell1; | |
756 Cell cell2; | |
757 | |
758 int r1 = args(0).numel (); | |
759 int r2; | |
760 | |
761 if (r1 == 1) | |
762 { | |
763 // Make the singleton cell2. | |
764 | |
765 cell1 = args(1).cell_value (); | |
766 cell2 = args(0).cell_value (); | |
767 r1 = cell1.length (); | |
768 r2 = 1; | |
769 } | |
770 else | |
771 { | |
772 cell1 = args(0).cell_value (); | |
773 cell2 = args(1).cell_value (); | |
774 r2 = cell2.length (); | |
775 } | |
776 | |
8524
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8472
diff
changeset
|
777 const dim_vector size1 = cell1.dims (); |
937921654627
clean up Array and DiagArray2
Jaroslav Hajek <highegg@gmail.com>
parents:
8472
diff
changeset
|
778 const dim_vector size2 = cell2.dims (); |
6250 | 779 |
8472
5451f7460ea6
strfns.cc (Fstrcmp, Fstrncmp): initialize all elements of output with constructor arg
John W. Eaton <jwe@octave.org>
parents:
8464
diff
changeset
|
780 boolNDArray output (size1, false); |
6250 | 781 |
782 if (r2 == 1) | |
783 { | |
784 // Broadcast cell2. | |
785 | |
8472
5451f7460ea6
strfns.cc (Fstrcmp, Fstrncmp): initialize all elements of output with constructor arg
John W. Eaton <jwe@octave.org>
parents:
8464
diff
changeset
|
786 if (cell2(0).is_string ()) |
6250 | 787 { |
788 const std::string str2 = cell2(0).string_value (); | |
789 | |
790 for (int i = 0; i < r1; i++) | |
791 { | |
792 if (cell1(i).is_string ()) | |
793 { | |
794 const std::string str1 = cell1(i).string_value (); | |
795 | |
796 if (str1.length () >= n && str2.length () >= n | |
797 && str1.compare (0, n, str2, 0, n) == 0) | |
798 output(i) = true; | |
799 } | |
800 } | |
801 } | |
802 } | |
803 else | |
804 { | |
805 if (size1 != size2) | |
806 { | |
807 error ("strncmp: nonconformant cell arrays"); | |
808 return retval; | |
809 } | |
810 | |
811 for (int i = 0; i < r1; i++) | |
812 { | |
813 if (cell1(i).is_string () && cell2(i).is_string ()) | |
814 { | |
815 const std::string str1 = cell1(i).string_value (); | |
816 const std::string str2 = cell2(i).string_value (); | |
817 | |
818 if (str1.length () >= n && str2.length () >= n | |
819 && str1.compare (0, n, str2, 0, n) == 0) | |
820 output(i) = true; | |
821 } | |
822 } | |
823 } | |
824 | |
825 retval = output; | |
826 } | |
827 else | |
828 retval = false; | |
829 } | |
830 else | |
831 print_usage (); | |
832 | |
833 return retval; | |
834 } | |
835 | |
8461
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
836 /* |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
837 %!error <Invalid call to strncmp.*> strncmp (); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
838 %!error <Invalid call to strncmp.*> strncmp ("abc", "def"); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
839 %!assert (strncmp ("abce", "abc", 3) == 1) |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
840 %!assert (strncmp (100, 100, 1) == 0) |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
841 %!assert (all (strncmp ("abce", {"abcd", "bca", "abc"}, 3) == [1, 0, 1])) |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
842 %!assert (all (strncmp ("abc", {"abcd", "bca", "abc"}, 4) == [0, 0, 0])) |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
843 %!assert (all (strncmp ({"abcd", "bca", "abc"},"abce", 3) == [1, 0, 1])) |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
844 %!assert (all (strncmp ({"abcd", "bca", "abc"},{"abcd", "bca", "abe"}, 3) == [1, 1, 0])) |
8472
5451f7460ea6
strfns.cc (Fstrcmp, Fstrncmp): initialize all elements of output with constructor arg
John W. Eaton <jwe@octave.org>
parents:
8464
diff
changeset
|
845 %!assert (all (strncmp("abc", {"abcd", 10}, 2) == [1, 0])) |
8461
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
846 */ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
847 |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
848 |
5690 | 849 DEFUN (list_in_columns, args, , |
850 "-*- texinfo -*-\n\ | |
851 @deftypefn {Built-in Function} {} list_in_columns (@var{arg}, @var{width})\n\ | |
852 Return a string containing the elements of @var{arg} listed in\n\ | |
853 columns with an overall maximum width of @var{width}. The argument\n\ | |
854 @var{arg} must be a cell array of character strings or a character array.\n\ | |
855 If @var{width} is not specified, the width of the terminal screen is used.\n\ | |
8461
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
856 Newline characters are used to break the lines in the output string.\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
857 For example:\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
858 \n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
859 @example\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
860 @group\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
861 list_in_columns (@{\"abc\", \"def\", \"ghijkl\", \"mnop\", \"qrs\", \"tuv\"@}, 20)\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
862 @result{} ans = abc mnop\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
863 def qrs\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
864 ghijkl tuv\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
865 \n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
866 whos ans\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
867 @result{}\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
868 Variables in the current scope:\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
869 \n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
870 Attr Name Size Bytes Class\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
871 ==== ==== ==== ===== =====\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
872 ans 1x37 37 char\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
873 \n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
874 Total is 37 elements using 37 bytes\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
875 @end group\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
876 @end example\n\ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
877 \n\ |
5690 | 878 @seealso{terminal_size}\n\ |
879 @end deftypefn") | |
880 { | |
881 octave_value retval; | |
882 | |
883 int nargin = args.length (); | |
884 | |
885 if (nargin == 1 || nargin == 2) | |
886 { | |
887 string_vector s = args(0).all_strings (); | |
888 | |
889 if (! error_state) | |
890 { | |
5765 | 891 std::ostringstream buf; |
5690 | 892 |
893 if (nargin == 1) | |
894 // Let list_in_columns query terminal width. | |
895 s.list_in_columns (buf); | |
896 else | |
897 { | |
898 int width = args(1).int_value (); | |
899 | |
900 if (! error_state) | |
901 s.list_in_columns (buf, width); | |
902 else | |
903 error ("list_in_columns: expecting width to be an integer"); | |
904 } | |
905 | |
5765 | 906 retval = buf.str (); |
5690 | 907 } |
908 else | |
909 error ("list_in_columns: expecting cellstr or char array"); | |
910 } | |
911 else | |
5823 | 912 print_usage (); |
5690 | 913 |
914 return retval; | |
915 } | |
916 | |
807 | 917 /* |
8461
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
918 %!error <Invalid call to list_in_columns.*> list_in_columns (); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
919 %!error <Invalid call to list_in_columns.*> list_in_columns (["abc", "def"], 20, 2); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
920 %!error <invalid conversion from string to real scalar.*> list_in_columns (["abc", "def"], "a"); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
921 %!test |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
922 %! input = {"abc", "def", "ghijkl", "mnop", "qrs", "tuv"}; |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
923 %! result = "abc mnop\ndef qrs\nghijkl tuv\n"; |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
924 %! assert (list_in_columns (input, 20) == result); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
925 %!test |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
926 %! input = ["abc"; "def"; "ghijkl"; "mnop"; "qrs"; "tuv"]; |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
927 %! result = "abc mnop \ndef qrs \nghijkl tuv \n"; |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
928 %! assert (list_in_columns (input, 20) == result); |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
929 */ |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
930 |
9d456730b7a8
strfns.cc: improve documentation strings, add examples and tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8372
diff
changeset
|
931 /* |
807 | 932 ;;; Local Variables: *** |
933 ;;; mode: C++ *** | |
934 ;;; End: *** | |
935 */ |