Returns a string that describes the ErrCode parameter.
Standard C Library (libc. a)
#include <regex.h>
size_t regerror (ErrCode, Preg, ErrBuf, ErrBuf_Size)
int ErrCode;
const regex_t * Preg;
char * ErrBuf;
size_t ErrBuf_Size;
The regerror subroutine provides a mapping from error codes returned by the regcomp and regexec subroutines to printable strings. It generates a string corresponding to the value of the ErrCode parameter, which is the last nonzero value returned by the regcomp or regexec subroutine with the given value of the Preg parameter. If the ErrCode parameter is not such a value, the content of the generated string is unspecified. The string generated is obtained from the regex.cat message catalog.
If the ErrBuf_Size parameter is not 0, the regerror subroutine places the generated string into the buffer specifier by the ErrBuf parameter, whose size in bytes is specified by the ErrBuf_Size parameter. If the string (including the terminating null character) cannot fit in the buffer, the regerror subroutine truncates the string and null terminates the result.
The regerror subroutine returns the size of the buffer needed to hold the entire generated string, including the null termination. If the return value is greater than the value of the ErrBuf_Size variable, the string returned in the ErrBuf buffer is truncated.
If the ErrBuf_Size value is 0, the regerror subroutine ignores the ErrBuf parameter, but returns the one of the following error codes. These error codes defined in the regex.h file.
If the Preg parameter passed to the regexec subroutine is not a compiled basic or extended regular expression returned by the regcomp subroutine, the result is undefined.
An application can use the regerror subroutine (with the parameters (Code, Preg, null, (size_t) 0) passed to it) to determine the size of buffer needed for the generated string, call the malloc subroutine to allocate a buffer to hold the string, and then call the regerror subroutine again to get the string. Alternately, this subroutine can allocate a fixed, static buffer that is large enough to hold most strings (perhaps 128 bytes), and then call the malloc subroutine to allocate a larger buffer if necessary.
The regcomp (regcomp Subroutine) subroutine, regexec (regexec Subroutine) subroutine, regfree (regfree Subroutine) subroutine.
Subroutines Overview and Understanding Internationalized Regular Expression Subroutines in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.