Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes arbitrary selection of regex implementation #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ cleanall:

# Shared library of non-template components:

$(BUILDDIR)/libftl.so: $(BUILDDIR)/ftlKinds.o $(BUILDDIR)/ftlString.o $(BUILDDIR)/ftlHash.o $(BUILDDIR)/ftlRegex.o
$(BUILDDIR)/libftl.so: $(BUILDDIR)/ftlKinds.o $(BUILDDIR)/ftlString.o $(BUILDDIR)/ftlHash.o $(BUILDDIR)/ftlRegex.o $(BUILDDIR)/ftlRegex_c.o
$(COMPILER) $(FLAGS) $(INCLUDES) $(DEFINES) $^ $(LDFLAGS) $(SOLDFLAGS) -o $@


Expand Down Expand Up @@ -155,7 +155,7 @@ $(BUILDDIR)/ftlSharedPtrTests.o: tests/ftlSharedPtrTests.F90 $(BUILDDIR)/ftlShar
$(BUILDDIR)/ftlStringTests.o: tests/ftlStringTests.F90 $(BUILDDIR)/ftlString.o $(BUILDDIR)/ftlDynArrayString.o $(BUILDDIR)/Animals.o | $(BUILDDIR)
$(COMPILER) $(FLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@

$(BUILDDIR)/ftlRegexTests.o: tests/ftlRegexTests.F90 $(BUILDDIR)/ftlRegex.o | $(BUILDDIR)
$(BUILDDIR)/ftlRegexTests.o: tests/ftlRegexTests.F90 $(BUILDDIR)/ftlRegex.o $(BUILDDIR)/ftlRegex_c.o | $(BUILDDIR)
$(COMPILER) $(FLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@


Expand Down Expand Up @@ -248,6 +248,9 @@ $(BUILDDIR)/ftlString.o: src/ftlString.F90 $(BUILDDIR)/ftlHash.o $(BUILDDIR)/ftl
$(BUILDDIR)/ftlRegex.o: src/ftlRegex.F90 src/configure_ftlRegex.inc $(BUILDDIR)/ftlString.o | $(BUILDDIR)
$(COMPILER) $(FLAGS) $(INCLUDES) $(DEFINES) $(SOFLAGS) -c $< -o $@

$(BUILDDIR)/ftlRegex_c.o: src/ftlRegex_c.c | $(BUILDDIR)
$(CXXCOMPILER) $(DEFINES) -c $< -o $@

src/configure_ftlRegex.inc: configure/configure_ftlRegex.c
$(CXXCOMPILER) $(DEFINES) configure/configure_ftlRegex.c -o configure/configure_ftlRegex
./configure/configure_ftlRegex | tee src/configure_ftlRegex.inc
Expand Down
8 changes: 4 additions & 4 deletions src/ftlRegex.F90
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,20 @@ module ftlRegexModule

interface

function C_regcomp(preg, pattern, flags) result(status) bind(C,name='regcomp')
function C_regcomp(preg, pattern, flags) result(status) bind(C)
import
type(C_ptr) , intent(in), value :: preg
character(kind=C_char), intent(in) :: pattern(*)
integer(C_int) , intent(in), value :: flags
integer(C_int) :: status
end function

subroutine C_regfree(preg) bind(C,name='regfree')
subroutine C_regfree(preg) bind(C)
import
type(C_ptr), intent(in), value :: preg
end subroutine

function C_regerror(errcode, preg, errbuf, errbuf_size) result(errlen) bind(C,name='regerror')
function C_regerror(errcode, preg, errbuf, errbuf_size) result(errlen) bind(C)
import
integer(C_int) , intent(in) , value :: errcode
type(C_ptr) , intent(in) , value :: preg
Expand All @@ -132,7 +132,7 @@ function C_regerror(errcode, preg, errbuf, errbuf_size) result(errlen) bind(C,na
integer(C_size_t) :: errlen
end function

function C_regexec(preg, string, nmatch, pmatch, eflags) result(status) bind(C,name='regexec')
function C_regexec(preg, string, nmatch, pmatch, eflags) result(status) bind(C)
import
type(C_ptr) , intent(in) , value :: preg
character(kind=C_char), intent(in) :: string(*)
Expand Down
24 changes: 24 additions & 0 deletions src/ftlRegex_c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifdef USE_PCRE
#include <pcreposix.h>
#else
#include <regex.h>
#endif

extern "C" {
int c_regcomp(regex_t* preg, const char* pattern, int cflags) {
return regcomp(preg, pattern, cflags);
}

void c_regfree(regex_t* preg) {
regfree(preg);
}

size_t c_regerror(int errcode, const regex_t* preg, char* errbuf, size_t errbuf_size) {
return regerror(errcode, preg, errbuf, errbuf_size);
}

int c_regexec(const regex_t* preg, const char* string, size_t nmatch, regmatch_t pmatch[], int eflags) {
return regexec(preg, string, nmatch, pmatch, eflags);
}
}