Skip to content

Commit

Permalink
Fix bug in regex within multi-table-dictionary
Browse files Browse the repository at this point in the history
Report de la correction effectuee en V10

Probleme:
- les regex ne fonctionne pas dans certains cas (en release, dans le cas multi-table)
- du a une compilation des regex uniquement dans la methode CheckCompletness

Correction:
- compilation des regex dans la methode dediee KWDRRegex::Compile

Jeu de test dedie: LearningTest\TestKhiops\Rules\BugMultiTableRegexRules
  • Loading branch information
marcboulle committed Dec 15, 2023
1 parent a23a937 commit f36995b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Learning/KWDRRuleLibrary/KWDRString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,23 @@ boolean KWDRRegex::CheckCompleteness(const KWClass* kwcOwnerClass) const
return bOk;
}

void KWDRRegex::Compile(KWClass* kwcOwnerClass)
{
int nRegexOperandIndex;

// Appel de la methode ancetre
KWDerivationRule::Compile(kwcOwnerClass);

// Acces a l'index de l'operande de regex: 2, sauf pour pour la regle Match
nRegexOperandIndex = 2;
if (GetOperandNumber() <= nRegexOperandIndex)
nRegexOperandIndex = GetOperandNumber() - 1;

// On ne verifie pas l'expression si elle a deja ete validee
if (not regEx.IsValid() or regEx.GetRegex() != GetOperandAt(nRegexOperandIndex)->GetSymbolConstant().GetValue())
regEx.Initialize(GetOperandAt(nRegexOperandIndex)->GetSymbolConstant().GetValue(), this);
}

//////////////////////////////////////////////////////////////////////////////////////

KWDRRegexMatch::KWDRRegexMatch()
Expand Down
3 changes: 3 additions & 0 deletions src/Learning/KWDRRuleLibrary/KWDRString.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ class KWDRRegex : public KWDRStringRule
// Verification qu'une regle est completement renseignee et compilable
boolean CheckCompleteness(const KWClass* kwcOwnerClass) const override;

// Compilation pour optimiser la gestion du format
void Compile(KWClass* kwcOwnerClass) override;

///////////////////////////////////////////
///// Implementation
protected:
Expand Down

0 comments on commit f36995b

Please sign in to comment.