this is the OSD cap line which fails this test, please note the starting TAB.
"\tallow\nwx\tpool \n taco\t",
and we have following BNF for this sort of rule, defined by OSDCapParser
:
grant := SP* "allow" (capspec match|match capspec) SP*
sep := SP* (";" | ",") SP*
grants := grant (sep grant)*
and following method call is used to parse the grants line:
qi::phrase_parse(iter, end, g, ascii::space, *this)
where ascii::space
is the skipper which is used to skip white spaces. but for ascii, TAB is indeed whitespace, per /usr/include/boost/spirit/home/support/char_encoding/ascii.hpp
. but the interesting thing in boost 1.41/spirit v2.1, is that the skipper does not skip the beginning spaces. i changed the ascii.pp in boost to verify my guess:
--- /tmp/ascii.hpp 2015-02-11 21:58:43.561343634 +0800
+++ /usr/include/boost/spirit/home/support/char_encoding/ascii.hpp 2015-02-11 20:46:49.829164797 +0800
@@ -15,6 +15,7 @@
#include <climits>
#include <boost/assert.hpp>
#include <boost/cstdint.hpp>
+#include <stdio.h>
///////////////////////////////////////////////////////////////////////////////
// constants used to classify the single characters
@@ -253,6 +254,7 @@
static int
isspace(int ch)
{
+ printf("===%c====", ch);
BOOST_ASSERT(isascii_(ch));
return (ascii_char_types[ch] & BOOST_CC_SPACE);
}
following is the output of ./unittest_osd_osdcap --gtest_filter='OSDCap.ParseGood'
:
compiled with boost 1.55 on debian sid:
Running main() from gmock_main.cc
Note: Google Test filter = OSDCap.ParseGood
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from OSDCap
[ RUN ] OSDCap.ParseGood
Testing good input: ' allow
wx pool
taco '
=== =======a======= ====[ OK ] OSDCap.ParseGood (0 ms)
[----------] 1 test from OSDCap (0 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (0 ms total)
[ PASSED ] 1 test.
compiled with boost 1.41 on centos 6.6
Running main() from gmock_main.cc
Note: Google Test filter = OSDCap.ParseGood
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from OSDCap
[ RUN ] OSDCap.ParseGood
Testing good input: ' allow
wx pool
taco '
osdcap parse failed, stopped at ' allow
wx pool
taco ' of ' allow
wx pool
taco '
test/osd/osdcap.cc:86: Failure
Value of: cap.parse(str, &cout)
Actual: false
Expected: true
[ FAILED ] OSDCap.ParseGood (0 ms)
i checked the changelog of spirit, but it doesn't mention the pre-skip of qi::phrase_parse
.