www.delorie.com/gnu/docs/regex/regex_58.html   search  
 
Buy the book!


Regex

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2.4 Reporting Errors

If either regcomp or regexec fail, they return a nonzero error code, the possibilities for which are defined in `regex.h'. See section 7.2.2 POSIX Regular Expression Compiling, and 7.2.3 POSIX Matching, for what these codes mean. To get an error string corresponding to these codes, you can use:

 
size_t
regerror (int errcode,
          const regex_t *preg,
          char *errbuf,
          size_t errbuf_size)

errcode is an error code, preg is the address of the pattern buffer which provoked the error, errbuf is the error buffer, and errbuf_size is errbuf's size.

regerror returns the size in bytes of the error string corresponding to errcode (including its terminating null). If errbuf and errbuf_size are nonzero, it also returns in errbuf the first errbuf_size - 1 characters of the error string, followed by a null. errbuf_size must be a nonnegative number less than or equal to the size in bytes of errbuf.

You can call regerror with a null errbuf and a zero errbuf_size to determine how large errbuf need be to accommodate regerror's error string.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003