You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2013/03/11 22:52:48 UTC
[lucy-commits] [11/18] git commit: refs/heads/master - Add Charmonizer probe for
regular expressions
Add Charmonizer probe for regular expressions
* Check headers for POSIX regexes and PCRE library.
* Check for OS X enhanced regexes (similar to GNU extensions).
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/049bd827
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/049bd827
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/049bd827
Branch: refs/heads/master
Commit: 049bd827f2113bad5d075cfa228ac653910a6931
Parents: c2f5daa
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Mar 2 17:50:22 2013 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Mar 9 17:51:55 2013 +0100
----------------------------------------------------------------------
charmonizer/src/Charmonizer/Probe/Headers.c | 1 +
.../src/Charmonizer/Probe/RegularExpressions.c | 57 +++++++++++++++
.../src/Charmonizer/Probe/RegularExpressions.h | 38 ++++++++++
common/charmonizer.main | 1 +
4 files changed, 97 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/049bd827/charmonizer/src/Charmonizer/Probe/Headers.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe/Headers.c b/charmonizer/src/Charmonizer/Probe/Headers.c
index 18974f3..69103ef 100644
--- a/charmonizer/src/Charmonizer/Probe/Headers.c
+++ b/charmonizer/src/Charmonizer/Probe/Headers.c
@@ -171,6 +171,7 @@ chaz_Headers_probe_posix(void) {
"fcntl.h",
"grp.h",
"pwd.h",
+ "regex.h",
"sys/stat.h",
"sys/times.h",
"sys/types.h",
http://git-wip-us.apache.org/repos/asf/lucy/blob/049bd827/charmonizer/src/Charmonizer/Probe/RegularExpressions.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe/RegularExpressions.c b/charmonizer/src/Charmonizer/Probe/RegularExpressions.c
new file mode 100644
index 0000000..60a9034
--- /dev/null
+++ b/charmonizer/src/Charmonizer/Probe/RegularExpressions.c
@@ -0,0 +1,57 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Charmonizer/Core/HeaderChecker.h"
+#include "Charmonizer/Core/ConfWriter.h"
+#include "Charmonizer/Probe/RegularExpressions.h"
+
+void
+chaz_RegularExpressions_run(void) {
+ int has_regex_h = chaz_HeadCheck_check_header("regex.h");
+ int has_pcre_h = chaz_HeadCheck_check_header("pcre.h");
+ int has_pcreposix_h = chaz_HeadCheck_check_header("pcreposix.h");
+
+ chaz_ConfWriter_start_module("RegularExpressions");
+
+ /* PCRE headers. */
+ if (has_pcre_h) {
+ chaz_ConfWriter_add_def("HAS_PCRE_H", NULL);
+ }
+ if (has_pcreposix_h) {
+ chaz_ConfWriter_add_def("HAS_PCREPOSIX_H", NULL);
+ }
+
+ /* Check for OS X enhanced regexes. */
+ if (has_regex_h) {
+ const char *reg_enhanced_code =
+ CHAZ_QUOTE( #include <regex.h> )
+ CHAZ_QUOTE( int main(int argc, char **argv) { )
+ CHAZ_QUOTE( regex_t re; )
+ CHAZ_QUOTE( if (regcomp(&re, "^", REG_ENHANCED)) { )
+ CHAZ_QUOTE( return 1; )
+ CHAZ_QUOTE( } )
+ CHAZ_QUOTE( return 0; )
+ CHAZ_QUOTE( } );
+
+ if (chaz_CC_test_compile(reg_enhanced_code)) {
+ chaz_ConfWriter_add_def("HAS_REG_ENHANCED", NULL);
+ }
+ }
+
+ chaz_ConfWriter_end_module();
+}
+
+
http://git-wip-us.apache.org/repos/asf/lucy/blob/049bd827/charmonizer/src/Charmonizer/Probe/RegularExpressions.h
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe/RegularExpressions.h b/charmonizer/src/Charmonizer/Probe/RegularExpressions.h
new file mode 100644
index 0000000..7bf6ec1
--- /dev/null
+++ b/charmonizer/src/Charmonizer/Probe/RegularExpressions.h
@@ -0,0 +1,38 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Charmonizer/Probe/RegularExpressions.h -- regular expressions.
+ */
+
+#ifndef H_CHAZ_REGULAREXPRESSIONS
+#define H_CHAZ_REGULAREXPRESSIONS
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Run the RegularExpressions module.
+ */
+void chaz_RegularExpressions_run(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_CHAZ_REGULAREXPRESSIONS */
+
+
+
http://git-wip-us.apache.org/repos/asf/lucy/blob/049bd827/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/common/charmonizer.main b/common/charmonizer.main
index 3567ce6..83de908 100644
--- a/common/charmonizer.main
+++ b/common/charmonizer.main
@@ -331,6 +331,7 @@ int main(int argc, const char **argv) {
chaz_Floats_run();
chaz_LargeFiles_run();
chaz_Memory_run();
+ chaz_RegularExpressions_run();
chaz_SymbolVisibility_run();
chaz_UnusedVars_run();
chaz_VariadicMacros_run();