Commit adbfed7f authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixed issues with predefined function 'regexp' (bug 565852)


Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I77f08130f7187b16a82b2ea87c78d5b955d09a7c
parent efc0f62f
......@@ -571,7 +571,7 @@ void QuadSet::do_negate() {
case QSET_QUAD:
q2 = it->u.p_quad->get_value() - 1;
qs->add_negate_interval(q1, q2);
q1 = q2.get_value() + 1;
q1 = it->u.p_quad->get_value() + 1;
break;
case QSET_INTERVAL:
q2 = it->u.p_interval->get_lower().get_value() - 1;
......
......@@ -317,6 +317,10 @@ RE_Multiply_Statement:
{
$$ = mcopystr("+");
}
| '#' '(' ')'
{
$$ = mcopystr("*");
}
| '#' '(' ',' ')'
{
$$ = mcopystr("*");
......
......@@ -236,13 +236,13 @@ RE_Concat_Elem:
| RE_Multiply_Elem RE_Multiply_Statement
{
if ($1 != NULL && $2 != NULL) {
$$ = mputstr($1, $2);
Free($2);
} else {
Free($1);
Free($2);
$$ = mprintf("(%s)%s", $1, $2);
}
else {
$$ = NULL;
}
Free($1);
Free($2);
}
| '*' {$$=mcopystr("(........)*");}
;
......@@ -275,6 +275,10 @@ RE_Multiply_Statement:
{
$$ = mcopystr("+");
}
| '#' '(' ')'
{
$$ = mcopystr("*");
}
| '#' '(' ',' ')'
{
$$ = mcopystr("*");
......
......@@ -1682,6 +1682,18 @@ UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
return regexp(instr, expression, (int)groupno, nocase);
}
CHARSTRING regexp(const CHARSTRING& instr, const UNIVERSAL_CHARSTRING& expression,
int groupno, boolean nocase)
{
return regexp((UNIVERSAL_CHARSTRING)instr, expression, groupno, nocase);
}
CHARSTRING regexp(const CHARSTRING& instr, const UNIVERSAL_CHARSTRING& expression,
const INTEGER& groupno, boolean nocase)
{
return regexp((UNIVERSAL_CHARSTRING)instr, expression, groupno, nocase);
}
// regexp() on templates
CHARSTRING regexp(const CHARSTRING_template& instr,
......
......@@ -193,6 +193,10 @@ extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
extern UNIVERSAL_CHARSTRING regexp(const UNIVERSAL_CHARSTRING& instr,
const CHARSTRING& expression, const INTEGER& groupno,
boolean nocase);
extern CHARSTRING regexp(const CHARSTRING& instr,
const UNIVERSAL_CHARSTRING& expression, int groupno, boolean nocase);
extern CHARSTRING regexp(const CHARSTRING& instr,
const UNIVERSAL_CHARSTRING& expression, const INTEGER& groupno, boolean nocase);
// regexp on templates
extern CHARSTRING regexp(const CHARSTRING_template& instr,
const CHARSTRING_template& expression, int groupno, boolean nocase);
......
......@@ -174,10 +174,39 @@ testcase regexp_nocase() runs on PDTestComponent {
setverdict(pass);
}
testcase Bug_565852() runs on PDTestComponent {
// issue #1: Titan does not support the notation '#()'
var charstring cs_input := "xxxxaaaxxxx";
var charstring cs_pattern := "x#()(a#(1,))x#()";
var charstring cs_result := regexp(cs_input, cs_pattern, 0);
var charstring cs_expected := "aaa";
if (cs_result != cs_expected) {
setverdict(fail, "Test #1 failed. Expected: ", cs_expected, ", got: ", cs_result);
}
// issue #2: '[^a]' and 'a#(...)' do not work for unversal charstrings
var universal charstring us_input := "xxxxaaaxxxx";
var universal charstring us_pattern := "*[^a](a#(1,))[^a]*";
var universal charstring us_result := regexp(us_input, us_pattern, 0);
var universal charstring us_expected := "aaa";
if (us_result != us_expected) {
setverdict(fail, "Test #2 failed. Expected: ", us_expected, ", got: ", us_result);
}
// extra issue: regexp(<charstring>, <universal charstring>, ...) generates incorrect code
var universal charstring mixed_result := regexp(cs_input, us_pattern, 0);
var universal charstring mixed_expected := "aaa";
if (mixed_result != mixed_expected) {
setverdict(fail, "Test #3 failed. Expected: ", mixed_expected, ", got: ", mixed_result);
}
setverdict(pass);
}
control {
execute (regexp_char());
execute (regexp_degen());
execute (regexp_nocase());
execute (Bug_565852());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment