Fixes arbitrary selection of regex implementation#8
Open
GaidaiIgor wants to merge 2 commits intoSCM-NV:masterfrom
Open
Fixes arbitrary selection of regex implementation#8GaidaiIgor wants to merge 2 commits intoSCM-NV:masterfrom
GaidaiIgor wants to merge 2 commits intoSCM-NV:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Issue #7.
Here's the issue. In
ftlRegex.F90you have declared interfaces to C functionsregexecand others. When you link your program with-lpcre -lpcreposix, the linker has two implementations ofregexecavailable to it: one from the standard C library, which is linked automatically, and another one fromlibpcreposix. Which one does it bind to? I wasn't able to find any rules that regulate this, so I assume that this is undefined and implementation dependent.This is exactly what happened to me in Issue #7: I have compiled the library with USE_PCRE=true (default) and linked with
-lpcre -lpcreposix, but the linker still chose to bind to the implementation from<regex.h>and everything crashed.Here's what I propose to fix it: instead of binding directly to the library function
regexecand leaving it up to the linker to decide which one, let's create our own dummy C interface and bind to it. This way we can have full control over what implementation is used by conditionally including either<regex.h>or<pcreposix.h>. This is what I implemented in the fileftlRegex_c.c. Theexternal "C"block is necessary for successful binding, since it prevents name mangling in case this file is compiled as a c++ file. The functions in that file have the same names as Fortran interfaces to them, so simply removing thenameattribute inftlRegex.F90is sufficient to select them as binding targets. Finally, I have also modifiedmakefileto include compilation of the new C file.