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:

TRE_CONFIG_APPROX
The result is an integer that is set to one if approximate matching support is available, zero if not.
TRE_CONFIG_WCHAR
The result is an integer that is set to one if wide character support is available, zero if not.
TRE_CONFIG_MULTIBYTE
The result is an integer that is set to one if multibyte character set support is available, zero if not.
TRE_CONFIG_SYSTEM_ABI
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.
TRE_CONFIG_VERSION
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.

Preprocessor definitions

The header <tre/regex.h> defines certain C preprocessor symbols.

Version information

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.

TRE_VERSION
The version string.
TRE_VERSION_1
The major version number (first part of version string).
TRE_VERSION_2
The minor version number (second part of version string).
TRE_VERSION_3
The micro version number (third part of version string).

Features

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.

TRE_APPROX
This is defined if approximate matching support is enabled. The prototypes for approximate matching functions are defined only if TRE_APPROX is defined.
TRE_WCHAR
This is defined if wide character support is enabled. The prototypes for wide character matching functions are defined only if TRE_WCHAR is defined.
TRE_MULTIBYTE
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.

Deprecated API

#include <tre/regex.h>

This header defines most functions without the tre_ prefix. New code should not include this header.