regex: Fixes for Como compiler in strict mode, plus some signed/unsigned conversions

[SVN r8780]
This commit is contained in:
John Maddock
2001-01-27 11:34:53 +00:00
parent b5dcded581
commit 1afe49fdbf
2 changed files with 51 additions and 18 deletions

View File

@ -309,7 +309,11 @@ template <class charT, class traits, class Allocator>
charT BOOST_RE_CALL reg_expression<charT, traits, Allocator>::parse_escape(const charT*& first, const charT* last)
{
charT c(*first);
switch(traits_inst.syntax_type(*first))
traits_size_type c_unsigned = (traits_size_type)(traits_uchar_type)*first;
// this is only used for the switch(), but cannot be folded in
// due to a bug in Comeau 4.2.44beta3
traits_size_type syntax = traits_inst.syntax_type(c_unsigned);
switch(syntax)
{
case traits_type::syntax_a:
c = '\a';
@ -343,7 +347,7 @@ charT BOOST_RE_CALL reg_expression<charT, traits, Allocator>::parse_escape(const
break;
}
// maybe have \x{ddd}
if(traits_inst.syntax_type(*first) == traits_type::syntax_open_brace)
if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*first)) == traits_type::syntax_open_brace)
{
++first;
if(first == last)
@ -357,7 +361,7 @@ charT BOOST_RE_CALL reg_expression<charT, traits, Allocator>::parse_escape(const
break;
}
c = (charT)traits_inst.toi(first, last, -16);
if((first == last) || (traits_inst.syntax_type(*first) != traits_type::syntax_close_brace))
if((first == last) || (traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*first)) != traits_type::syntax_close_brace))
{
fail(REG_BADBR);
}
@ -675,7 +679,10 @@ re_detail::re_syntax_base* BOOST_RE_CALL reg_expression<charT, traits, Allocator
while((first != last) && !done)
{
traits_size_type c = (traits_size_type)(traits_uchar_type)*first;
switch(traits_inst.syntax_type(c))
// this is only used for the switch(), but cannot be folded in
// due to a bug in Comeau 4.2.44beta3
traits_size_type syntax = traits_inst.syntax_type(c);
switch(syntax)
{
case traits_type::syntax_caret:
if(!started && !isnot)
@ -697,7 +704,10 @@ re_detail::re_syntax_base* BOOST_RE_CALL reg_expression<charT, traits, Allocator
}
// check to see if we really have a class:
const charT* base = first;
switch(parse_inner_set(first, last))
// this is only used for the switch(), but cannot be folded in
// due to a bug in Comeau 4.2.44beta3
unsigned int inner_set = parse_inner_set(first, last);
switch(inner_set)
{
case traits_type::syntax_colon:
{
@ -836,7 +846,11 @@ re_detail::re_syntax_base* BOOST_RE_CALL reg_expression<charT, traits, Allocator
++first;
if(first == last)
continue;
switch(traits_inst.syntax_type(*first))
traits_size_type c = (traits_size_type)(traits_uchar_type)*first;
// this is only used for the switch(), but cannot be folded in
// due to a bug in Comeau 4.2.44beta3
traits_size_type syntax = traits_inst.syntax_type(c);
switch(syntax)
{
case traits_type::syntax_w:
if(l == last_dash)
@ -1261,7 +1275,10 @@ unsigned int BOOST_RE_CALL reg_expression<charT, traits, Allocator>::set_express
while (ptr < end)
{
c = (traits_size_type)(traits_uchar_type)*ptr;
switch(traits_inst.syntax_type(c))
// this is only used for the switch(), but cannot be folded in
// due to a bug in Comeau 4.2.44beta3
traits_size_type syntax = traits_inst.syntax_type(c);
switch(syntax)
{
case traits_type::syntax_open_bracket:
if(_flags & bk_parens)
@ -1284,7 +1301,10 @@ unsigned int BOOST_RE_CALL reg_expression<charT, traits, Allocator>::set_express
{
++ptr;
c = (traits_size_type)(traits_uchar_type)*ptr;
switch(traits_inst.syntax_type(c))
// this is only used for the switch(), but cannot be folded in
// due to a bug in Comeau 4.2.44beta3
traits_size_type syntax = traits_inst.syntax_type(c);
switch(syntax)
{
case traits_type::syntax_colon:
((re_detail::re_brace*)dat)->index = 0;
@ -1370,13 +1390,17 @@ unsigned int BOOST_RE_CALL reg_expression<charT, traits, Allocator>::set_express
++ptr;
break;
case traits_type::syntax_slash:
{
if(++ptr == end)
{
fail(REG_EESCAPE);
return error_code();
}
c = (traits_size_type)(traits_uchar_type)*ptr;
switch(traits_inst.syntax_type(c))
// this is only used for the switch(), but cannot be folded in
// due to a bug in Comeau 4.2.44beta3
traits_size_type syntax = traits_inst.syntax_type(c);
switch(syntax)
{
case traits_type::syntax_open_bracket:
if(_flags & bk_parens)
@ -1546,6 +1570,7 @@ unsigned int BOOST_RE_CALL reg_expression<charT, traits, Allocator>::set_express
dat = add_literal(dat, (charT)c);
++ptr;
break;
}
case traits_type::syntax_dollar:
dat = add_simple(dat, re_detail::syntax_element_end_line, sizeof(re_detail::re_syntax_base));
++ptr;

View File

@ -64,11 +64,15 @@ void BOOST_RE_CALL re_skip_format(const charT*& fmt, const traits_type& traits_i
// dwa 9/13/00 - suppress incorrect unused parameter warning for MSVC
(void)traits_inst;
typedef typename traits_type::size_type traits_size_type;
typedef typename traits_type::uchar_type traits_uchar_type;
typedef typename traits_type::string_type traits_string_type;
unsigned int parens = 0;
unsigned int c;
while(*fmt)
{
c = traits_inst.syntax_type(*fmt);
c = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt));
if((c == traits_type::syntax_colon) && (parens == 0))
{
++fmt;
@ -148,9 +152,13 @@ OutputIterator BOOST_RE_CALL _reg_format_aux(OutputIterator out,
const charT* fmt_end = fmt;
while(*fmt_end) ++ fmt_end;
typedef typename traits_type::size_type traits_size_type;
typedef typename traits_type::uchar_type traits_uchar_type;
typedef typename traits_type::string_type traits_string_type;
while(*fmt)
{
switch(traits_inst.syntax_type(*fmt))
switch(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)))
{
case traits_type::syntax_dollar:
if(flags & format_sed)
@ -167,7 +175,7 @@ OutputIterator BOOST_RE_CALL _reg_format_aux(OutputIterator out,
++out;
return out;
}
switch(traits_inst.syntax_type(*fmt))
switch(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)))
{
case traits_type::syntax_start_buffer:
oi_assign(&out, re_copy_out(out, iterator(m[-1].first), iterator(m[-1].second)));
@ -213,7 +221,7 @@ expand_sub:
++fmt;
return out;
}
switch(traits_inst.syntax_type(*fmt))
switch(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)))
{
case traits_type::syntax_a:
c = '\a';
@ -248,7 +256,7 @@ expand_sub:
return out;
}
// maybe have \x{ddd}
if(traits_inst.syntax_type(*fmt) == traits_type::syntax_open_brace)
if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)) == traits_type::syntax_open_brace)
{
++fmt;
if(fmt == fmt_end)
@ -268,9 +276,9 @@ expand_sub:
continue;
}
c = (charT)traits_inst.toi(fmt, fmt_end, -16);
if(traits_inst.syntax_type(*fmt) != traits_type::syntax_close_brace)
if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)) != traits_type::syntax_close_brace)
{
while(traits_inst.syntax_type(*fmt) != traits_type::syntax_slash)
while(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*fmt)) != traits_type::syntax_slash)
--fmt;
++fmt;
*out = *fmt;
@ -394,13 +402,13 @@ expand_sub:
if(m[id].matched)
{
oi_assign(&out, _reg_format_aux(out, m, fmt, flags | format_is_if, traits_inst));
if(traits_inst.syntax_type(*(fmt-1)) == traits_type::syntax_colon)
if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*(fmt-1))) == traits_type::syntax_colon)
re_skip_format(fmt, traits_inst);
}
else
{
re_skip_format(fmt, traits_inst);
if(traits_inst.syntax_type(*(fmt-1)) == traits_type::syntax_colon)
if(traits_inst.syntax_type((traits_size_type)(traits_uchar_type)(*(fmt-1))) == traits_type::syntax_colon)
oi_assign(&out, _reg_format_aux(out, m, fmt, flags | format_is_if, traits_inst));
}
return out;