summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorrhaas <rhaas@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-06-05 01:21:05 +0000
committerrhaas <rhaas@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-06-05 01:21:05 +0000
commitebd9d3057b889f2fe224c7cd7a0c539aa33a4d5c (patch)
tree90810093d4c416d77aff036ad0a4c321580284a4 /doc
parentfe89bb0b6590b24f4c8c6cee06b26a985661ef5a (diff)
have CCTK_RegexMatch return a distinct error code if patterns is invalid
This patch changes the return value in the "does not compile" case to -1 and updates all source files that I could find that use it. Note that this patch changes behaviour of a routine. It used to return 0 for non-compiling patterns so thorns that test for C-like true would interpret invalid patterns as does-not-match, but will interpret the -1 return value as does-match. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4831 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'doc')
-rw-r--r--doc/ReferenceManual.pdfbin1186265 -> 916133 bytes
-rw-r--r--doc/ReferenceManual/CCTKReference.tex69
2 files changed, 69 insertions, 0 deletions
diff --git a/doc/ReferenceManual.pdf b/doc/ReferenceManual.pdf
index a90197c4..3e657e12 100644
--- a/doc/ReferenceManual.pdf
+++ b/doc/ReferenceManual.pdf
Binary files differ
diff --git a/doc/ReferenceManual/CCTKReference.tex b/doc/ReferenceManual/CCTKReference.tex
index 1908547b..e1b86845 100644
--- a/doc/ReferenceManual/CCTKReference.tex
+++ b/doc/ReferenceManual/CCTKReference.tex
@@ -659,6 +659,9 @@ from Fortran.
\item[\code{CCTK\_ReductionHandle}] [\pageref{CCTK-ReductionHandle}]
Get the handle for a registered reduction operator
+\item[\code{CCTK\_RegexMatch}] [\pageref{CCTK-RegexMatch}]
+ Perform a regular expression match of string against pattern
+
\item[\code{CCTK\_RegisterBanner}] [\pageref{CCTK-RegisterBanner}]
Register a banner for a thorn
@@ -10647,6 +10650,72 @@ call CCTK_ReductionHandle(handle,"maximum")
\end{ExampleSection}
\end{FunctionDescription}
+% Misc.c
+\begin{FunctionDescription}{CCTK\_RegexMatch}{Perform a regular expression match of string against pattern}
+\label{CCTK-RegexMatch}
+\begin{SynopsisSection}
+\begin{Synopsis}{C}
+\begin{verbatim}success = CCTK_RegexMatch( const char *string, const char *pattern,
+ const int nmatch, regmatch_t *pmatch)\end{verbatim}
+\end{Synopsis}
+\end{SynopsisSection}
+\begin{ParameterSection}
+\begin{Parameter}{string}
+String to match against
+\end{Parameter}
+\begin{Parameter}{pattern}
+Regex pattern
+\end{Parameter}
+\begin{Parameter}{nmatch}
+The size of the pmatch array
+\end{Parameter}
+\begin{Parameter}{pmatch}
+Array in which to place the matches
+\end{Parameter}
+\end{ParameterSection}
+\begin{ResultSection}
+\begin{Result}{0} pattern does not match\end{Result}
+\begin{Result}{1} pattern matches\end{Result}
+\begin{Result}{< 0} indicates an error condition (pattern did not compile as a
+ regular expression) \end{Result}
+\end{ResultSection}
+\begin{Discussion}
+Perform a regular expression match of string against pattern.
+Also returns the specified number of matched substrings as
+give by regexec.
+This is a modified form of the example routine given in the SGI
+man page for regcomp.
+\end{Discussion}
+\begin{ExampleSection}
+\begin{Example}{C}
+\begin{verbatim}
+#define R_BEGIN "(\\[|\\()?"
+#define R_VALUE "([^]):]*)"
+#define R_SEP ":"
+#define R_END "(\\]|\\))?"
+#define R_MAYBE(x) "(" x ")?"
+
+ int matched;
+ const char pattern[] =
+ R_BEGIN
+ R_VALUE
+ R_MAYBE(R_SEP R_VALUE R_MAYBE(R_SEP R_VALUE))
+ R_END;
+
+ if( (matched = CCTK_RegexMatch(range, pattern, 8, pmatch)) > 0) {
+ CCTK_VInfo(CCTK_THORNSTRING, "'%s' is a valid range specifier",
+ range);
+ } else if(!matched) {
+ CCTK_VInfo(CCTK_THORNSTRING, "'%s' is not a valid range specifier",
+ range);
+ } else {
+ CCTK_VInfo(CCTK_THORNSTRING, "invalid pattern '%s'", pattern);
+ }
+\end{verbatim}
+\end{Example}
+\end{ExampleSection}
+\end{FunctionDescription}
+
% Coord.c
\begin{FunctionDescription}{CCTK\_RegisterBanner}{Register a banner for a thorn}
\label{CCTK-RegisterBanner}