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 | |
29 | #ifndef BOOST_NO_WREGEX |
30 | #include <wchar.h> |
31 | |
32 | const wchar_t* expression = L"^" ; |
33 | const wchar_t* text = L"\n " ; |
34 | regmatch_t matches[1]; |
35 | int flags = REG_EXTENDED | REG_BASIC | REG_NOSPEC | REG_ICASE | REG_NOSUB | |
36 | REG_NEWLINE | REG_PEND | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS | |
37 | REG_NEWLINE_ALT | REG_PERL | REG_AWK | REG_GREP | REG_EGREP; |
38 | |
39 | |
40 | int main() |
41 | { |
42 | regex_t re; |
43 | int result; |
44 | wchar_t buf[256]; |
45 | char nbuf[256]; |
46 | int i; |
47 | result = regcomp(&re, expression, REG_AWK); |
48 | if(result > (int)REG_NOERROR) |
49 | { |
50 | regerror(result, &re, buf, sizeof(buf)); |
51 | for(i = 0; i < 256; ++i) |
52 | nbuf[i] = (char)(buf[i]); |
53 | printf(format: nbuf); |
54 | return result; |
55 | } |
56 | if(re.re_nsub != 0) |
57 | { |
58 | regfree(&re); |
59 | exit(status: -1); |
60 | } |
61 | matches[0].rm_so = 0; |
62 | matches[0].rm_eo = wcslen(s: text); |
63 | result = regexec(&re, text, 1, matches, REG_NOTBOL | REG_NOTEOL | REG_STARTEND); |
64 | if(result > (int)REG_NOERROR) |
65 | { |
66 | regerror(result, &re, buf, sizeof(buf)); |
67 | for(i = 0; i < 256; ++i) |
68 | nbuf[i] = (char)(buf[i]); |
69 | printf(format: nbuf); |
70 | regfree(&re); |
71 | return result; |
72 | } |
73 | if((matches[0].rm_so != matches[0].rm_eo) || (matches[0].rm_eo != 1)) |
74 | { |
75 | regfree(&re); |
76 | exit(status: -1); |
77 | } |
78 | regfree(&re); |
79 | printf(format: "no errors found\n" ); |
80 | return 0; |
81 | } |
82 | |
83 | #else |
84 | # error "This library has not been configured for wide character support" |
85 | #endif |
86 | |
87 | |
88 | |
89 | |
90 | |