24 #if defined (HAVE_CONFIG_H) 36 #include "builtin-defun-decls.h" 45 #define ORD(ch) static_cast<unsigned char>(ch) 46 #define TABSIZE (std::numeric_limits<unsigned char>::max () + 1) 54 const char *
x = needle.
data ();
69 const char *
x = needle.
data ();
71 const char *
y = haystack.
data ();
76 std::deque<octave_idx_type> accum;
93 if (
y[
i] ==
x[0] &&
y[
i+1] ==
x[1])
101 if (
y[
i] ==
x[0] &&
y[
i+1] ==
x[1])
102 accum.push_back (
i++);
115 if (std::equal (
x,
x + m,
y + j))
117 j += table[
ORD(
y[j + m])];
124 if (std::equal (
x,
x + m,
y + j))
130 j += table[
ORD(
y[j + m])];
134 if (j == n - m && std::equal (
x,
x + m,
y + j))
142 for (
const auto& idx : accum)
148 DEFUN (strfind, args, ,
192 int nargin = args.length ();
197 bool overlaps =
true;
201 error (
"strfind: invalid optional arguments");
205 if (opt ==
"overlaps")
206 overlaps = args(3).bool_value ();
208 error (
"strfind: unknown option: %s", opt.c_str ());
231 else if (argstr.
iscell ())
241 error (
"strfind: each element of CELLSTR must be a string");
255 error (
"strfind: first argument must be a string or cell array of strings");
257 else if (argpat.
iscell ())
260 error (
"strfind: PATTERN must be a string or cell array of strings");
286 bool overlaps =
true)
322 retsiz = siz + nidx * (rsiz - psiz);
329 const char *src =
str.data ();
330 const char *reps =
rep.data ();
338 dest = std::copy (src +
k, src + j, dest);
339 dest = std::copy (reps, reps + rsiz, dest);
343 std::copy (src +
k, src + siz, dest);
351 DEFUN (strrep, args, ,
378 int nargin = args.length ();
383 bool overlaps =
true;
388 error (
"strrep: invalid optional arguments");
391 if (opt ==
"overlaps")
392 overlaps = args(4).bool_value ();
394 error (
"strrep: unknown option: %s", opt.c_str ());
414 else if (argstr.
iscell ())
427 error (
"strrep: each element of S must be a string");
433 error (
"strrep: S must be a string or cell array of strings");
438 error (
"strrep: PTN and REP arguments must be strings or cell arrays of strings");
const T * data(void) const
OCTINTERP_API void print_usage(void)
const T * fortran_vec(void) const
static Array< octave_idx_type > qs_search(const Array< char > &needle, const Array< char > &haystack, const octave_idx_type *table, bool overlaps=true)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
virtual octave_idx_type numel(const octave_value_list &)
OCTAVE_EXPORT octave_value_list Fstrfind(const octave_value_list &args, int) or if ar
octave_base_value * rep
The real representation.
charNDArray char_array_value(bool frc_str_conv=false) const
With real return the complex result
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
OCTINTERP_API octave_value_list do_simple_cellfun(octave_value_list(*fun)(const octave_value_list &, int), const char *fun_name, const octave_value_list &args, int nargout)
the element is set to zero In other the statement xample y
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
bool is_string(void) const
static void qs_preprocess(const Array< char > &needle, octave_idx_type *table)
octave_idx_type numel(void) const
Number of elements in the array.
Vector representing the dimensions (size) of an Array.
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
bool is_scalar_type(void) const
Cell cell_value(void) const
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
charNDArray min(char d, const charNDArray &m)