Index: trunk/extensions/AbuseFilter/parser_native/parser.cpp |
— | — | @@ -151,8 +151,22 @@ |
152 | 152 | return datum::from_double(args[0].toFloat()); |
153 | 153 | } |
154 | 154 | |
| 155 | +datum |
| 156 | +f_append(datum const &a, char b) |
| 157 | +{ |
| 158 | + return datum::from_string(a.toString() + b); |
155 | 159 | } |
156 | 160 | |
| 161 | +datum |
| 162 | +f_strip_last(datum const &a) |
| 163 | +{ |
| 164 | + std::string s(a.toString()); |
| 165 | + s.resize(s.size() - 1); |
| 166 | + return datum::from_string(s); |
| 167 | +} |
| 168 | + |
| 169 | +} |
| 170 | + |
157 | 171 | /* |
158 | 172 | * This is the closure types for functions. 'val' stores the final result of |
159 | 173 | * the function call; func and args store the function object and the parsed |
— | — | @@ -261,9 +275,15 @@ |
262 | 276 | | bin_p[value.val = bind(&datum::from_int)(arg1)] >> 'b' |
263 | 277 | | int_p[value.val = bind(&datum::from_int)(arg1)] |
264 | 278 | ] |
265 | | - | confix_p('"', *c_escape_ch_p, '"')[ |
266 | | - value.val = bind(&datum::from_string)(construct_<std::string>(arg1 + 1, arg2 - 1)) |
267 | | - ] |
| 279 | + /* |
| 280 | + * config_p can't be used here, because it will rewrite |
| 281 | + * *(c_escape_ch_p[x]) into (*c_escape_ch_p)[x] |
| 282 | + */ |
| 283 | + | ( |
| 284 | + ch_p('"')[value.val = ""] |
| 285 | + >> *((c_escape_ch_p[value.val = bind(&f_append)(value.val, arg1)] - '"')) |
| 286 | + >> ch_p('"')[value.val = bind(&f_strip_last)(value.val)] |
| 287 | + ) |
268 | 288 | ; |
269 | 289 | |
270 | 290 | /* |