Mercurial > jwe > octave
diff libinterp/corefcn/regexp.cc @ 21966:112b20240c87
move docstrings in C++ files out of C strings and into comments
* __contourc__.cc, __dispatch__.cc, __dsearchn__.cc, __ichol__.cc,
__ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc,
__pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc,
bitfcns.cc, bsxfun.cc, cellfun.cc, colloc.cc, conv2.cc, daspk.cc,
dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, det.cc, dirfns.cc,
dlmread.cc, dot.cc, eig.cc, ellipj.cc, error.cc, fft.cc, fft2.cc,
fftn.cc, file-io.cc, filter.cc, find.cc, gammainc.cc, gcd.cc,
getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, graphics.cc,
hash.cc, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, kron.cc,
load-path.cc, load-save.cc, lookup.cc, ls-oct-text.cc, lsode.cc,
lu.cc, mappers.cc, matrix_type.cc, max.cc, mgorth.cc, nproc.cc,
oct-hist.cc, octave-link.cc, ordschur.cc, pager.cc, pinv.cc,
pr-output.cc, profiler.cc, psi.cc, pt-jit.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc,
sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc,
sub2ind.cc, svd.cc, sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc,
time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, urlwrite.cc,
utils.cc, variables.cc, __delaunayn__.cc, __eigs__.cc,
__fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc,
audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc,
convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc,
ov-base.cc, ov-bool-mat.cc, ov-cell.cc, ov-class.cc, ov-classdef.cc,
ov-fcn-handle.cc, ov-fcn-inline.cc, ov-flt-re-mat.cc, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-null-mat.cc,
ov-oncleanup.cc, ov-range.cc, ov-re-mat.cc, ov-struct.cc,
ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc,
ov-usr-fcn.cc, ov.cc, octave.cc, pt-arg-list.cc, pt-binop.cc,
pt-eval.cc, pt-mat.cc, lex.ll, oct-parse.in.yy:
Docstrings are now comments instead of C strings.
* build-aux/mk-opts.pl: Emit docstrings as comments instead of C
strings.
* DASPK-opts.in, LSODE-opts.in: Don't quote " in docstring fragments.
* builtins.h: Include builtin-defun-decls.h unconditionally.
* defun.h (DEFUN, DEFUNX, DEFCONSTFUN): Simply emit declaration.
(DEFALIAS): Always expand to nothing.
* defun-dld.h: No special macro expansions for MAKE_BUILTINS.
(DEFUN_DLD): Use FORWARD_DECLARE_FUN.
(DEFUNX_DLD): Use FORWARD_DECLARE_FUNX.
* defun-int.h: No special macro expansions for MAKE_BUILTINS.
(FORWARD_DECLARE_FUN, FORWARD_DECLARE_FUNX): New macros.
(DEFINE_FUN_INSTALLER_FUN): If compiling an Octave source file, pass
"external-doc" to DEFINE_FUNX_INSTALLER_FUN.
(DEFUN_INTERNAL, DEFCONSTFUN_INTERNAL, DEFUNX_INTERNAL,
DEFALIAS_INTERNAL): Delete.
* common.mk (move_if_change_rule): New macro.
(simple_move_if_change_rule): Define using move_if_change_rule.
* find-defun-files.sh (DEFUN_PATTERN): Update. Don't transform file
name extension to ".df".
* libinterp/mk-pkg-add, gendoc.pl: Operate directly on source files.
* mkbuiltins: New argument, SRCDIR. Operate directly on source files.
* mkdefs: Delete.
* libinterp/module.mk (BUILT_SOURCES): Update list to contain only
files included in other source files.
(GENERATED_MAKE_BUILTINS_INCS, DEF_FILES): Delete.
(LIBINTERP_BUILT_DISTFILES): Include $(OPT_HANDLERS) here.
(LIBINTERP_BUILT_NODISTFILES): Not here. Remove $(ALL_DEF_FILES from
the list.
(libinterp_EXTRA_DIST): Remove mkdefs from the list.
(FOUND_DEFUN_FILES): Rename from SRC_DEF_FILES.
(DLDFCN_DEFUN_FILES): Rename from DLDFCN_DEF_FILES.
(SRC_DEFUN_FILES): Rename from SRC_DEF_FILES.
(ALL_DEFUN_FILES): Rename from ALL_DEF_FILES.
(%.df: %.cc): Delete pattern rule.
(libinterp/build-env-features.cc, libinterp/builtins.cc,
libinterp/dldfcn/PKG_ADD): Use mv instead of move-if-change.
(libinterp/builtins.cc, libinterp/builtin-defun-decls.h):
Update mkbuiltins command.
($(srcdir)/libinterp/DOCSTRINGS): Update gendoc.pl command.
* liboctave/module.mk (BUILT_SOURCES): Don't include
liboctave-build-info.cc in the list.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 21 Jun 2016 16:07:51 -0400 |
parents | aba2e6293dd8 |
children | e43d83253e28 |
line wrap: on
line diff
--- a/libinterp/corefcn/regexp.cc Tue Jun 21 13:08:25 2016 -0700 +++ b/libinterp/corefcn/regexp.cc Tue Jun 21 16:07:51 2016 -0400 @@ -645,210 +645,210 @@ } DEFUN (regexp, args, nargout, - "-*- texinfo -*-\n\ -@deftypefn {} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}, @var{sp}] =} regexp (@var{str}, @var{pat})\n\ -@deftypefnx {} {[@dots{}] =} regexp (@var{str}, @var{pat}, \"@var{opt1}\", @dots{})\n\ -Regular expression string matching.\n\ -\n\ -Search for @var{pat} in @var{str} and return the positions and substrings of\n\ -any matches, or empty values if there are none.\n\ -\n\ -The matched pattern @var{pat} can include any of the standard regex\n\ -operators, including:\n\ -\n\ -@table @code\n\ -@item .\n\ -Match any character\n\ -\n\ -@item * + ? @{@}\n\ -Repetition operators, representing\n\ -\n\ -@table @code\n\ -@item *\n\ -Match zero or more times\n\ -\n\ -@item +\n\ -Match one or more times\n\ -\n\ -@item ?\n\ -Match zero or one times\n\ -\n\ -@item @{@var{n}@}\n\ -Match exactly @var{n} times\n\ -\n\ -@item @{@var{n},@}\n\ -Match @var{n} or more times\n\ -\n\ -@item @{@var{m},@var{n}@}\n\ -Match between @var{m} and @var{n} times\n\ -@end table\n\ -\n\ -@item [@dots{}] [^@dots{}]\n\ -\n\ -List operators. The pattern will match any character listed between \"[\"\n\ -and \"]\". If the first character is \"^\" then the pattern is inverted and\n\ -any character except those listed between brackets will match.\n\ -\n\ -Escape sequences defined below can also be used inside list operators. For\n\ -example, a template for a floating point number might be @code{[-+.\\d]+}.\n\ -\n\ -@item () (?:)\n\ -Grouping operator. The first form, parentheses only, also creates a token.\n\ -\n\ -@item |\n\ -Alternation operator. Match one of a choice of regular expressions. The\n\ -alternatives must be delimited by the grouping operator @code{()} above.\n\ -\n\ -@item ^ $\n\ -Anchoring operators. Requires pattern to occur at the start (@code{^}) or\n\ -end (@code{$}) of the string.\n\ -@end table\n\ -\n\ -In addition, the following escaped characters have special meaning.\n\ -\n\ -@table @code\n\ -\n\ -@item \\d\n\ -Match any digit\n\ -\n\ -@item \\D\n\ -Match any non-digit\n\ -\n\ -@item \\s\n\ -Match any whitespace character\n\ -\n\ -@item \\S\n\ -Match any non-whitespace character\n\ -\n\ -@item \\w\n\ -Match any word character\n\ -\n\ -@item \\W\n\ -Match any non-word character\n\ -\n\ -@item \\<\n\ -Match the beginning of a word\n\ -\n\ -@item \\>\n\ -Match the end of a word\n\ -\n\ -@item \\B\n\ -Match within a word\n\ -@end table\n\ -\n\ -Implementation Note: For compatibility with @sc{matlab}, escape sequences\n\ -in @var{pat} (e.g., @qcode{\"@xbackslashchar{}n\"} => newline) are expanded\n\ -even when @var{pat} has been defined with single quotes. To disable\n\ -expansion use a second backslash before the escape sequence (e.g.,\n\ -\"@xbackslashchar{}@xbackslashchar{}n\") or use the @code{regexptranslate}\n\ -function.\n\ -\n\ -The outputs of @code{regexp} default to the order given below\n\ -\n\ -@table @var\n\ -@item s\n\ -The start indices of each matching substring\n\ -\n\ -@item e\n\ -The end indices of each matching substring\n\ -\n\ -@item te\n\ -The extents of each matched token surrounded by @code{(@dots{})} in\n\ -@var{pat}\n\ -\n\ -@item m\n\ -A cell array of the text of each match\n\ -\n\ -@item t\n\ -A cell array of the text of each token matched\n\ -\n\ -@item nm\n\ -A structure containing the text of each matched named token, with the name\n\ -being used as the fieldname. A named token is denoted by\n\ -@code{(?<name>@dots{})}.\n\ -\n\ -@item sp\n\ -A cell array of the text not returned by match, i.e., what remains if you\n\ -split the string based on @var{pat}.\n\ -@end table\n\ -\n\ -Particular output arguments, or the order of the output arguments, can be\n\ -selected by additional @var{opt} arguments. These are strings and the\n\ -correspondence between the output arguments and the optional argument\n\ -are\n\ -\n\ -@multitable @columnfractions 0.2 0.3 0.3 0.2\n\ -@item @tab @qcode{'start'} @tab @var{s} @tab\n\ -@item @tab @qcode{'end'} @tab @var{e} @tab\n\ -@item @tab @qcode{'tokenExtents'} @tab @var{te} @tab\n\ -@item @tab @qcode{'match'} @tab @var{m} @tab\n\ -@item @tab @qcode{'tokens'} @tab @var{t} @tab\n\ -@item @tab @qcode{'names'} @tab @var{nm} @tab\n\ -@item @tab @qcode{'split'} @tab @var{sp} @tab\n\ -@end multitable\n\ -\n\ -Additional arguments are summarized below.\n\ -\n\ -@table @samp\n\ -@item once\n\ -Return only the first occurrence of the pattern.\n\ -\n\ -@item matchcase\n\ -Make the matching case sensitive. (default)\n\ -\n\ -Alternatively, use (?-i) in the pattern.\n\ -\n\ -@item ignorecase\n\ -Ignore case when matching the pattern to the string.\n\ -\n\ -Alternatively, use (?i) in the pattern.\n\ -\n\ -@item stringanchors\n\ -Match the anchor characters at the beginning and end of the string.\n\ -(default)\n\ -\n\ -Alternatively, use (?-m) in the pattern.\n\ -\n\ -@item lineanchors\n\ -Match the anchor characters at the beginning and end of the line.\n\ -\n\ -Alternatively, use (?m) in the pattern.\n\ -\n\ -@item dotall\n\ -The pattern @code{.} matches all characters including the newline character.\n\ - (default)\n\ -\n\ -Alternatively, use (?s) in the pattern.\n\ -\n\ -@item dotexceptnewline\n\ -The pattern @code{.} matches all characters except the newline character.\n\ -\n\ -Alternatively, use (?-s) in the pattern.\n\ -\n\ -@item literalspacing\n\ -All characters in the pattern, including whitespace, are significant and are\n\ -used in pattern matching. (default)\n\ -\n\ -Alternatively, use (?-x) in the pattern.\n\ -\n\ -@item freespacing\n\ -The pattern may include arbitrary whitespace and also comments beginning\n\ -with the character @samp{#}.\n\ -\n\ -Alternatively, use (?x) in the pattern.\n\ -\n\ -@item noemptymatch\n\ -Zero-length matches are not returned. (default)\n\ -\n\ -@item emptymatch\n\ -Return zero-length matches.\n\ -\n\ -@code{regexp ('a', 'b*', 'emptymatch')} returns @code{[1 2]} because there\n\ -are zero or more @qcode{'b'} characters at positions 1 and end-of-string.\n\ -\n\ -@end table\n\ -@seealso{regexpi, strfind, regexprep}\n\ -@end deftypefn") + doc: /* -*- texinfo -*- +@deftypefn {} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}, @var{sp}] =} regexp (@var{str}, @var{pat}) +@deftypefnx {} {[@dots{}] =} regexp (@var{str}, @var{pat}, "@var{opt1}", @dots{}) +Regular expression string matching. + +Search for @var{pat} in @var{str} and return the positions and substrings of +any matches, or empty values if there are none. + +The matched pattern @var{pat} can include any of the standard regex +operators, including: + +@table @code +@item . +Match any character + +@item * + ? @{@} +Repetition operators, representing + +@table @code +@item * +Match zero or more times + +@item + +Match one or more times + +@item ? +Match zero or one times + +@item @{@var{n}@} +Match exactly @var{n} times + +@item @{@var{n},@} +Match @var{n} or more times + +@item @{@var{m},@var{n}@} +Match between @var{m} and @var{n} times +@end table + +@item [@dots{}] [^@dots{}] + +List operators. The pattern will match any character listed between "[" +and "]". If the first character is "^" then the pattern is inverted and +any character except those listed between brackets will match. + +Escape sequences defined below can also be used inside list operators. For +example, a template for a floating point number might be @code{[-+.\d]+}. + +@item () (?:) +Grouping operator. The first form, parentheses only, also creates a token. + +@item | +Alternation operator. Match one of a choice of regular expressions. The +alternatives must be delimited by the grouping operator @code{()} above. + +@item ^ $ +Anchoring operators. Requires pattern to occur at the start (@code{^}) or +end (@code{$}) of the string. +@end table + +In addition, the following escaped characters have special meaning. + +@table @code + +@item \d +Match any digit + +@item \D +Match any non-digit + +@item \s +Match any whitespace character + +@item \S +Match any non-whitespace character + +@item \w +Match any word character + +@item \W +Match any non-word character + +@item \< +Match the beginning of a word + +@item \> +Match the end of a word + +@item \B +Match within a word +@end table + +Implementation Note: For compatibility with @sc{matlab}, escape sequences +in @var{pat} (e.g., @qcode{"@xbackslashchar{}n"} => newline) are expanded +even when @var{pat} has been defined with single quotes. To disable +expansion use a second backslash before the escape sequence (e.g., +"@xbackslashchar{}@xbackslashchar{}n") or use the @code{regexptranslate} +function. + +The outputs of @code{regexp} default to the order given below + +@table @var +@item s +The start indices of each matching substring + +@item e +The end indices of each matching substring + +@item te +The extents of each matched token surrounded by @code{(@dots{})} in +@var{pat} + +@item m +A cell array of the text of each match + +@item t +A cell array of the text of each token matched + +@item nm +A structure containing the text of each matched named token, with the name +being used as the fieldname. A named token is denoted by +@code{(?<name>@dots{})}. + +@item sp +A cell array of the text not returned by match, i.e., what remains if you +split the string based on @var{pat}. +@end table + +Particular output arguments, or the order of the output arguments, can be +selected by additional @var{opt} arguments. These are strings and the +correspondence between the output arguments and the optional argument +are + +@multitable @columnfractions 0.2 0.3 0.3 0.2 +@item @tab @qcode{'start'} @tab @var{s} @tab +@item @tab @qcode{'end'} @tab @var{e} @tab +@item @tab @qcode{'tokenExtents'} @tab @var{te} @tab +@item @tab @qcode{'match'} @tab @var{m} @tab +@item @tab @qcode{'tokens'} @tab @var{t} @tab +@item @tab @qcode{'names'} @tab @var{nm} @tab +@item @tab @qcode{'split'} @tab @var{sp} @tab +@end multitable + +Additional arguments are summarized below. + +@table @samp +@item once +Return only the first occurrence of the pattern. + +@item matchcase +Make the matching case sensitive. (default) + +Alternatively, use (?-i) in the pattern. + +@item ignorecase +Ignore case when matching the pattern to the string. + +Alternatively, use (?i) in the pattern. + +@item stringanchors +Match the anchor characters at the beginning and end of the string. +(default) + +Alternatively, use (?-m) in the pattern. + +@item lineanchors +Match the anchor characters at the beginning and end of the line. + +Alternatively, use (?m) in the pattern. + +@item dotall +The pattern @code{.} matches all characters including the newline character. + (default) + +Alternatively, use (?s) in the pattern. + +@item dotexceptnewline +The pattern @code{.} matches all characters except the newline character. + +Alternatively, use (?-s) in the pattern. + +@item literalspacing +All characters in the pattern, including whitespace, are significant and are +used in pattern matching. (default) + +Alternatively, use (?-x) in the pattern. + +@item freespacing +The pattern may include arbitrary whitespace and also comments beginning +with the character @samp{#}. + +Alternatively, use (?x) in the pattern. + +@item noemptymatch +Zero-length matches are not returned. (default) + +@item emptymatch +Return zero-length matches. + +@code{regexp ('a', 'b*', 'emptymatch')} returns @code{[1 2]} because there +are zero or more @qcode{'b'} characters at positions 1 and end-of-string. + +@end table +@seealso{regexpi, strfind, regexprep} +@end deftypefn */) { if (args.length () < 2) print_usage (); @@ -1132,17 +1132,17 @@ */ DEFUN (regexpi, args, nargout, - "-*- texinfo -*-\n\ -@deftypefn {} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}, @var{sp}] =} regexpi (@var{str}, @var{pat})\n\ -@deftypefnx {} {[@dots{}] =} regexpi (@var{str}, @var{pat}, \"@var{opt1}\", @dots{})\n\ -\n\ -Case insensitive regular expression string matching.\n\ -\n\ -Search for @var{pat} in @var{str} and return the positions and substrings of\n\ -any matches, or empty values if there are none. @xref{XREFregexp,,regexp},\n\ -for details on the syntax of the search pattern.\n\ -@seealso{regexp}\n\ -@end deftypefn") + doc: /* -*- texinfo -*- +@deftypefn {} {[@var{s}, @var{e}, @var{te}, @var{m}, @var{t}, @var{nm}, @var{sp}] =} regexpi (@var{str}, @var{pat}) +@deftypefnx {} {[@dots{}] =} regexpi (@var{str}, @var{pat}, "@var{opt1}", @dots{}) + +Case insensitive regular expression string matching. + +Search for @var{pat} in @var{str} and return the positions and substrings of +any matches, or empty values if there are none. @xref{XREFregexp,,regexp}, +for details on the syntax of the search pattern. +@seealso{regexp} +@end deftypefn */) { if (args.length () < 2) print_usage (); @@ -1332,44 +1332,44 @@ } DEFUN (regexprep, args, , - "-*- texinfo -*-\n\ -@deftypefn {} {@var{outstr} =} regexprep (@var{string}, @var{pat}, @var{repstr})\n\ -@deftypefnx {} {@var{outstr} =} regexprep (@var{string}, @var{pat}, @var{repstr}, \"@var{opt1}\", @dots{})\n\ -Replace occurrences of pattern @var{pat} in @var{string} with @var{repstr}.\n\ -\n\ -The pattern is a regular expression as documented for @code{regexp}.\n\ -@xref{XREFregexp,,regexp}.\n\ -\n\ -The replacement string may contain @code{$i}, which substitutes for the ith\n\ -set of parentheses in the match string. For example,\n\ -\n\ -@example\n\ -regexprep (\"Bill Dunn\", '(\\w+) (\\w+)', '$2, $1')\n\ -@end example\n\ -\n\ -@noindent\n\ -returns \"Dunn, Bill\"\n\ -\n\ -Options in addition to those of @code{regexp} are\n\ -\n\ -@table @samp\n\ -\n\ -@item once\n\ -Replace only the first occurrence of @var{pat} in the result.\n\ -\n\ -@item warnings\n\ -This option is present for compatibility but is ignored.\n\ -\n\ -@end table\n\ -\n\ -Implementation Note: For compatibility with @sc{matlab}, escape sequences\n\ -in @var{pat} (e.g., @qcode{\"@xbackslashchar{}n\"} => newline) are expanded\n\ -even when @var{pat} has been defined with single quotes. To disable\n\ -expansion use a second backslash before the escape sequence (e.g.,\n\ -\"@xbackslashchar{}@xbackslashchar{}n\") or use the @code{regexptranslate}\n\ -function.\n\ -@seealso{regexp, regexpi, strrep}\n\ -@end deftypefn") + doc: /* -*- texinfo -*- +@deftypefn {} {@var{outstr} =} regexprep (@var{string}, @var{pat}, @var{repstr}) +@deftypefnx {} {@var{outstr} =} regexprep (@var{string}, @var{pat}, @var{repstr}, "@var{opt1}", @dots{}) +Replace occurrences of pattern @var{pat} in @var{string} with @var{repstr}. + +The pattern is a regular expression as documented for @code{regexp}. +@xref{XREFregexp,,regexp}. + +The replacement string may contain @code{$i}, which substitutes for the ith +set of parentheses in the match string. For example, + +@example +regexprep ("Bill Dunn", '(\w+) (\w+)', '$2, $1') +@end example + +@noindent +returns "Dunn, Bill" + +Options in addition to those of @code{regexp} are + +@table @samp + +@item once +Replace only the first occurrence of @var{pat} in the result. + +@item warnings +This option is present for compatibility but is ignored. + +@end table + +Implementation Note: For compatibility with @sc{matlab}, escape sequences +in @var{pat} (e.g., @qcode{"@xbackslashchar{}n"} => newline) are expanded +even when @var{pat} has been defined with single quotes. To disable +expansion use a second backslash before the escape sequence (e.g., +"@xbackslashchar{}@xbackslashchar{}n") or use the @code{regexptranslate} +function. +@seealso{regexp, regexpi, strrep} +@end deftypefn */) { if (args.length () < 3) print_usage ();