Utility Functions and Macros
Inspecting regex objects
#include <tre/tre.h> int tre_have_backrefs(const regex_t *preg); int tre_have_approx(const regex_t *preg);
The tre_have_backrefs() and tre_have_approx() functions return 1 if the compiled pattern has back references or uses approximate matching, respectively, and 0 if not.
Checking build time options
#include <tre/tre.h> char *tre_version(void); int tre_config(int query, void *result);
The tre_config() function can be used to retrieve information of which optional features have been compiled into the TRE library and information of other parameters that may change between releases.
The query argument is an integer telling what information is requested for. The result argument is a pointer to a variable where the information is returned. The return value of a call to tre_config() is zero if query was recognized, REG_NOMATCH otherwise.
The following values are recognized for query:
- The result is an integer that is set to one if approximate matching support is available, zero if not.
- The result is an integer that is set to one if wide character support is available, zero if not.
- The result is an integer that is set to one if multibyte character set support is available, zero if not.
- The result is an integer that is set to one if TRE has been compiled to be compatible with the system regex ABI, zero if not.
- The result is a pointer to a static character string that gives the version of the TRE library.
The tre_version() function returns a short human readable character string which shows the software name, version, and license.
<tre/regex.h> defines certain C preprocessor symbols.
The following definitions may be useful for checking whether a new enough version is being used. Note that it is recommended to use the pkg-config tool for version and other checks in Autoconf scripts.
- The version string.
- The major version number (first part of version string).
- The minor version number (second part of version string).
- The micro version number (third part of version string).
The following definitions may be useful for checking whether all necessary features are enabled. Use these only if compile time checking suffices (linking statically with TRE). When linking dynamically tre_config() should be used instead.
- This is defined if approximate matching support is enabled. The prototypes for approximate matching functions are defined only if TRE_APPROX is defined.
- This is defined if wide character support is enabled. The prototypes for wide character matching functions are defined only if TRE_WCHAR is defined.
- This is defined if multibyte character set support is enabled. If this is not set any locale settings are ignored, and the default locale is used when parsing regexps and matching strings.
This header defines most functions without the
tre_ prefix. New code should not include this header.