Skip to content

Commit 1cad537

Browse files
authored
Merge pull request #187 from boostorg/test_standalone
Add testing of standalone mode.
2 parents 2a8e6d9 + 39e5c86 commit 1cad537

File tree

10 files changed

+138
-17
lines changed

10 files changed

+138
-17
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,31 @@ jobs:
6464
- name: Test
6565
run: ../../../b2 toolset=$TOOLSET
6666
working-directory: ../boost-root/libs/regex/test
67+
ubuntu-jammy-standalone:
68+
runs-on: ubuntu-22.04
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
compiler: [ g++ ]
73+
standard: [ c++11, c++14, c++17, c++2a ]
74+
steps:
75+
- uses: actions/checkout@v2
76+
with:
77+
fetch-depth: '0'
78+
- uses: mstachniuk/ci-skip@v1
79+
with:
80+
commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE]'
81+
commit-filter-separator: ';'
82+
fail-fast: true
83+
- name: Set TOOLSET
84+
run: echo ${{ matrix.compiler }} | awk '/^g/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV
85+
- name: Add repository
86+
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
87+
- name: Install packages
88+
run: sudo apt install libicu-dev
89+
- name: Test
90+
run: ${{ matrix.compiler }} -std=${{ matrix.standard }} -I../../include *.cpp ../../src/*.cpp -o regress && ./regress
91+
working-directory: ./test/regress
6792
ubuntu-bionic:
6893
runs-on: ubuntu-18.04
6994
strategy:
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4+
<title>Use in Standalone Mode (without the rest of Boost)</title>
5+
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6+
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7+
<link rel="home" href="../../index.html" title="Boost.Regex 7.0.1">
8+
<link rel="up" href="../configuration.html" title="Configuration">
9+
<link rel="prev" href="compiler.html" title="Compiler Setup">
10+
<link rel="next" href="locale.html" title="Locale and traits class selection">
11+
</head>
12+
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13+
<table cellpadding="2" width="100%"><tr>
14+
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15+
<td align="center"><a href="../../../../../../index.html">Home</a></td>
16+
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17+
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18+
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19+
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20+
</tr></table>
21+
<hr>
22+
<div class="spirit-nav">
23+
<a accesskey="p" href="compiler.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="locale.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24+
</div>
25+
<div class="section">
26+
<div class="titlepage"><div><div><h3 class="title">
27+
<a name="boost_regex.configuration.standalone"></a><a class="link" href="standalone.html" title="Use in Standalone Mode (without the rest of Boost)">Use in Standalone
28+
Mode (without the rest of Boost)</a>
29+
</h3></div></div></div>
30+
<p>
31+
This library may now be used in "standalone" mode without the rest
32+
of the Boost C++ libraries, in order to do this you must either:
33+
</p>
34+
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
35+
<li class="listitem">
36+
Have a C++17 compiler that supports <code class="computeroutput"><span class="identifier">__has_include</span></code>,
37+
in this case if <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">config</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code> is <span class="bold"><strong>not</strong></span>
38+
present then the library will automoatically enter standalone mode. Or:
39+
</li>
40+
<li class="listitem">
41+
Define BOOST_REGEX_STANDALONE when building.
42+
</li>
43+
</ul></div>
44+
<p>
45+
The main difference between the 2 modes, is that when Boost.Config is present
46+
the library will automatically configure itself around various compiler defects.
47+
In particular in order to use the library with exception support turned off,
48+
you will either need a copy of Boost.Config in your include path, or else
49+
manually define BOOST_NO_EXCEPTIONS when building.
50+
</p>
51+
</div>
52+
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
53+
<td align="left"></td>
54+
<td align="right"><div class="copyright-footer">Copyright © 1998-2013 John Maddock<p>
55+
Distributed under the Boost Software License, Version 1.0. (See accompanying
56+
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
57+
</p>
58+
</div></td>
59+
</tr></table>
60+
<hr>
61+
<div class="spirit-nav">
62+
<a accesskey="p" href="compiler.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../configuration.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="locale.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
63+
</div>
64+
</body>
65+
</html>

doc/html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
</p>
216216
</div>
217217
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
218-
<td align="left"><p><small>Last revised: March 08, 2022 at 11:25:00 GMT</small></p></td>
218+
<td align="left"><p><small>Last revised: December 09, 2022 at 16:44:04 GMT</small></p></td>
219219
<td align="right"><div class="copyright-footer"></div></td>
220220
</tr></table>
221221
<hr>

src/posix_api.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818

1919
#define BOOST_REGEX_SOURCE
2020

21-
#include <boost/config.hpp>
2221
#include <boost/regex.hpp>
2322
#include <boost/cregex.hpp>
24-
#include <boost/cstdint.hpp>
2523
#include <cstdio>
2624

2725
#if defined(BOOST_NO_STDC_NAMESPACE)
@@ -32,6 +30,11 @@ namespace std{
3230
}
3331
#endif
3432

33+
#ifndef BOOST_WORKAROUND
34+
#define BOOST_WORKAROUND(x, y) false
35+
#endif
36+
37+
3538

3639
namespace boost{
3740

@@ -88,7 +91,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
8891
return REG_E_MEMORY;
8992
#endif
9093
// set default flags:
91-
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic);
94+
unsigned flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? regex::extended : regex::basic);
9295
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
9396
// and translate those that are actually set:
9497

@@ -177,7 +180,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
177180
// We're converting an integer i to a string, and since i <= REG_E_UNKNOWN
178181
// a five character string is *always* large enough:
179182
//
180-
#if BOOST_CXX_VERSION >= 201103
183+
#if !defined(BOOST_CXX_VERSION) || (BOOST_CXX_VERSION >= 201103)
181184
int r = (std::snprintf)(localbuf, 5, "%d", i);
182185
#elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
183186
int r = (::sprintf_s)(localbuf, 5, "%d", i);
@@ -191,7 +194,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA*
191194
return std::strlen(localbuf) + 1;
192195
}
193196
}
194-
#if BOOST_CXX_VERSION >= 201103
197+
#if !defined(BOOST_CXX_VERSION) || (BOOST_CXX_VERSION >= 201103)
195198
int r = (::snprintf)(localbuf, 5, "%d", 0);
196199
#elif BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE)
197200
int r = (::sprintf_s)(localbuf, 5, "%d", 0);

src/wide_posix_api.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424

2525
#include <boost/regex.hpp>
2626
#include <boost/cregex.hpp>
27-
#include <boost/cstdint.hpp>
27+
28+
#ifndef BOOST_WORKAROUND
29+
#define BOOST_WORKAROUND(x, y) false
30+
#endif
2831

2932
#include <cstdio>
3033
#include <cstring>
@@ -98,7 +101,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
98101
return REG_E_MEMORY;
99102
#endif
100103
// set default flags:
101-
boost::uint_fast32_t flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic);
104+
unsigned flags = (f & REG_PERLEX) ? 0 : ((f & REG_EXTENDED) ? wregex::extended : wregex::basic);
102105
expression->eflags = (f & REG_NEWLINE) ? match_not_dot_newline : match_default;
103106

104107
// and translate those that are actually set:

test/regress/basic_tests.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
* DESCRIPTION: main regex test declarations.
1717
*/
1818

19-
#include <boost/detail/workaround.hpp>
20-
21-
#if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x560)
22-
// we get unresolved externals from basic_string
23-
// unless we do this, a well known Borland bug:
24-
#define _RWSTD_COMPILE_INSTANTIATE
25-
#endif
26-
2719
#include "test.hpp"
2820

2921
#ifdef BOOST_MSVC

test/regress/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ int main(int argc, char * argv[])
217217
return cpp_main(argc, argv);
218218
}
219219

220+
#elif defined(BOOST_REGEX_STANDALONE)
221+
222+
int main(int argc, char* argv[])
223+
{
224+
return cpp_main(argc, argv);
225+
}
226+
220227
#else
221228

222229
#include <boost/detail/lightweight_main.hpp>

test/regress/test.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@
2727
#pragma warning(disable:1418 981 383 1419 7)
2828
#endif
2929

30+
#ifndef BOOST_WORKAROUND
31+
#define BOOST_WORKAROUND(x, y) false
32+
#endif
33+
#ifdef BOOST_REGEX_STANDALONE
34+
#include <cstdint>
35+
36+
namespace boost { using std::uint32_t; }
37+
38+
#define BOOST_JOIN(X, Y) BOOST_DO_JOIN(X, Y)
39+
#define BOOST_DO_JOIN(X, Y) BOOST_DO_JOIN2(X,Y)
40+
#define BOOST_DO_JOIN2(X, Y) X##Y
41+
42+
#define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X)
43+
#define BOOST_DO_STRINGIZE(X) #X
44+
45+
#endif
46+
3047
#include <typeinfo>
3148
#include "test_not_regex.hpp"
3249
#include "test_regex_search.hpp"

test/regress/test_icu.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,19 @@
2020
// We can only build this if we have ICU support:
2121
//
2222
#include <boost/regex/config.hpp>
23+
2324
#if defined(BOOST_HAS_ICU) && !defined(BOOST_NO_STD_WSTRING)
2425

2526
#include <boost/regex/icu.hpp>
27+
#ifndef BOOST_REGEX_STANDALONE
2628
#include <boost/mpl/int.hpp>
29+
#else
30+
#include <type_traits>
31+
namespace boost { namespace mpl {
32+
template <int I>
33+
using int_ = ::std::integral_constant<int, I>;
34+
} }
35+
#endif
2736
#include "test.hpp"
2837

2938
namespace unnecessary_fix{

test/regress/test_mfc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//
2020
// We can only build this if we have ATL support:
2121
//
22-
#include <boost/config.hpp>
22+
#include <boost/regex/config.hpp>
2323

2424
#ifdef TEST_MFC
2525

0 commit comments

Comments
 (0)