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         wide_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 #define UNICODE
21 #define _UNICODE
22 
23 #include <stdio.h>
24 #include <string.h>
25 #include <assert.h>
26 #include <stdlib.h>
27 #include <boost/regex.h>
28 #include <wchar.h>
29 #include <iostream>
30 #include <iomanip>
31 
32 #ifndef BOOST_NO_WREGEX
33 
34 const wchar_t* expression = L"^";
35 const wchar_t* text = L"\n      ";
36 regmatch_t matches[1];
37 int flags = REG_EXTENDED | REG_BASIC | REG_NOSPEC | REG_ICASE | REG_NOSUB |
38             REG_NEWLINE | REG_PEND | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS |
39             REG_NEWLINE_ALT | REG_PERL | REG_AWK | REG_GREP | REG_EGREP;
40 
41 
main()42 int main()
43 {
44    regex_t re;
45    unsigned result;
46    result = regcomp(&re, expression, REG_AWK);
47    if(result > REG_NOERROR)
48    {
49       wchar_t buf[256];
50       regerror(result, &re, buf, sizeof(buf));
51       char nbuf[256];
52       for(int i = 0; i < 256; ++i)
53          nbuf[i] = static_cast<char>(buf[i]);
54       printf("%s", nbuf);
55       return result;
56    }
57    if(re.re_nsub != 0)
58    {
59       regfree(&re);
60       exit(-1);
61    }
62    matches[0].rm_so = 0;
63    matches[0].rm_eo = wcslen(text);
64    result = regexec(&re, text, 1, matches, REG_NOTBOL | REG_NOTEOL | REG_STARTEND);
65    if(result > REG_NOERROR)
66    {
67       wchar_t buf[256];
68       regerror(result, &re, buf, sizeof(buf));
69       char nbuf[256];
70       for(int i = 0; i < 256; ++i)
71          nbuf[i] = static_cast<char>(buf[i]);
72       printf("%s", nbuf);
73       regfree(&re);
74       return result;
75    }
76    if((matches[0].rm_so != matches[0].rm_eo) || (matches[0].rm_eo != 1))
77    {
78       regfree(&re);
79       exit(-1);
80    }
81    regfree(&re);
82    printf("%s", "no errors found\n");
83    return 0;
84 }
85 
86 #else
87 
88 #include <iostream>
89 
main()90 int main()
91 {
92    std::cout <<
93    "\n<note>\n"
94    "This platform does not provide the needed wide character support for this test.\n"
95    "</note>\n";
96    return 0;
97 }
98 #endif
99 
100 
101 
102 
103