• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright (c) 1998-2002
4  * John Maddock
5  *
6  * Use, modification and distribution are subject to the
7  * Boost Software License, Version 1.0. (See accompanying file
8  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9  *
10  */
11 
12  /*
13   *   LOCATION:    see http://www.boost.org for most recent version.
14   *   FILE         posix_api_compiler_check.c
15   *   VERSION      see <boost/version.hpp>
16   *   DESCRIPTION: Verify that POSIX API calls compile: note this is a compile
17   *                time check only.
18   */
19 
20 #include <stdio.h>
21 #include <string.h>
22 #include <boost/assert.hpp>
23 #include <boost/regex.h>
24 #include "../test_macros.hpp"
25 
26 const char* expression = "^";
27 const char* text = "\n      ";
28 regmatch_t matches[1];
29 int flags = REG_EXTENDED | REG_BASIC | REG_NOSPEC | REG_ICASE | REG_NOSUB |
30             REG_NEWLINE | REG_PEND | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS |
31             REG_NEWLINE_ALT | REG_PERL | REG_AWK | REG_GREP | REG_EGREP;
32 
33 
main()34 int main()
35 {
36    regex_tA re;
37    unsigned int result;
38    result = regcompA(&re, expression, REG_AWK);
39    if(result > REG_NOERROR)
40    {
41       char buf[256];
42       regerrorA(result, &re, buf, sizeof(buf));
43       printf("%s", buf);
44       return result;
45    }
46    BOOST_CHECK(re.re_nsub == 0);
47    matches[0].rm_so = 0;
48    matches[0].rm_eo = strlen(text);
49    result = regexecA(&re, text, 1, matches, REG_NOTBOL | REG_NOTEOL | REG_STARTEND);
50    if(result > REG_NOERROR)
51    {
52       char buf[256];
53       regerrorA(result, &re, buf, sizeof(buf));
54       printf("%s", buf);
55       regfreeA(&re);
56       return result;
57    }
58    BOOST_CHECK(matches[0].rm_so == matches[0].rm_eo);
59    regfreeA(&re);
60    printf("no errors found\n");
61    return boost::report_errors();
62 }
63 
64 
65 
66