mirror of
https://projects.vdr-developer.org/git/vdr-plugin-tvguide.git
synced 2023-10-05 15:01:48 +02:00
Some cosmetic changes
This commit is contained in:
parent
a8ca6f19da
commit
f7e5ac3208
@ -22,18 +22,6 @@ cSwitchTimer::cSwitchTimer(const cEvent* Event) {
|
||||
}
|
||||
}
|
||||
|
||||
#if VDRVERSNUM >= 20305
|
||||
cSwitchTimer& cSwitchTimer::operator= (const cSwitchTimer &SwitchTimer)
|
||||
{
|
||||
this->eventID = SwitchTimer.eventID;
|
||||
this->startTime = SwitchTimer.startTime;
|
||||
this->channelID = SwitchTimer.channelID;
|
||||
this->switchMinsBefore = SwitchTimer.switchMinsBefore;
|
||||
this->announceOnly = SwitchTimer.announceOnly;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
bool cSwitchTimer::Parse(const char *s) {
|
||||
char *line;
|
||||
char *pos;
|
||||
|
@ -12,7 +12,15 @@ public:
|
||||
int announceOnly;
|
||||
#if VDRVERSNUM >= 20305
|
||||
cSwitchTimer(const cSwitchTimer &SwitchTimer) { *this = SwitchTimer; };
|
||||
cSwitchTimer& operator= (const cSwitchTimer &SwitchTimer);
|
||||
cSwitchTimer& operator= (const cSwitchTimer &SwitchTimer)
|
||||
{
|
||||
this->eventID = SwitchTimer.eventID;
|
||||
this->startTime = SwitchTimer.startTime;
|
||||
this->channelID = SwitchTimer.channelID;
|
||||
this->switchMinsBefore = SwitchTimer.switchMinsBefore;
|
||||
this->announceOnly = SwitchTimer.announceOnly;
|
||||
return *this;
|
||||
};
|
||||
#endif
|
||||
cSwitchTimer(void);
|
||||
cSwitchTimer(const cEvent* Event);
|
||||
|
@ -71,7 +71,7 @@ void cTVGuideTimerConflicts::AddConflict(std::string epgSearchConflictLine) {
|
||||
splitstring s3(flds2[2].c_str());
|
||||
std::vector<std::string> flds3 = s3.split('#');
|
||||
std::vector<int> timerIDs;
|
||||
for (int k = 0; k < flds3.size(); k++) {
|
||||
for (int k = 0; k < (int)flds3.size(); k++) {
|
||||
timerIDs.push_back(atoi(flds3[k].c_str()) - 1);
|
||||
}
|
||||
conflict->timerIDs = timerIDs;
|
||||
@ -80,18 +80,17 @@ void cTVGuideTimerConflicts::AddConflict(std::string epgSearchConflictLine) {
|
||||
|
||||
void cTVGuideTimerConflicts::CalculateConflicts(void) {
|
||||
numConflicts = conflicts.size();
|
||||
// time_t startTime = 0;
|
||||
// time_t endTime = 0;
|
||||
for (int i=0; i < numConflicts; i++) {
|
||||
cTimeInterval *unionSet = NULL;
|
||||
int numTimers = conflicts[i]->timerIDs.size();
|
||||
for (int j=0; j < numTimers; j++) {
|
||||
#if VDRVERSNUM >= 20301
|
||||
LOCK_TIMERS_READ;
|
||||
const cTimer *timer = Timers->Get(conflicts[i]->timerIDs[j]);
|
||||
LOCK_TIMERS_READ;
|
||||
const cTimers* timers = Timers;
|
||||
#else
|
||||
const cTimer *timer = Timers.Get(conflicts[i]->timerIDs[j]);
|
||||
const cTimers* timers = &Timers;
|
||||
#endif
|
||||
for (int j=0; j < numTimers; j++) {
|
||||
const cTimer *timer = timers->Get(conflicts[i]->timerIDs[j]);
|
||||
if (timer) {
|
||||
if (!unionSet) {
|
||||
unionSet = new cTimeInterval(timer->StartTime(), timer->StopTime());
|
||||
@ -110,12 +109,7 @@ void cTVGuideTimerConflicts::CalculateConflicts(void) {
|
||||
|
||||
cTimeInterval *intersect = NULL;
|
||||
for (int j=0; j < numTimers; j++) {
|
||||
#if VDRVERSNUM >= 20301
|
||||
LOCK_TIMERS_READ;
|
||||
const cTimer *timer = Timers->Get(conflicts[i]->timerIDs[j]);
|
||||
#else
|
||||
const cTimer *timer = Timers.Get(conflicts[i]->timerIDs[j]);
|
||||
#endif
|
||||
const cTimer *timer = timers->Get(conflicts[i]->timerIDs[j]);
|
||||
if (timer) {
|
||||
if (!intersect) {
|
||||
intersect = new cTimeInterval(timer->StartTime(), timer->StopTime());
|
||||
|
428
tools.c
428
tools.c
@ -144,7 +144,7 @@ std::vector<std::string>& splitstring::split(char delim, int rep) {
|
||||
std::string work = data();
|
||||
std::string buf = "";
|
||||
int i = 0;
|
||||
while (i < work.length()) {
|
||||
while (i < (int)work.length()) {
|
||||
if (work[i] != delim)
|
||||
buf += work[i];
|
||||
else if (rep == 1) {
|
||||
@ -179,61 +179,61 @@ int FindIgnoreCase(const std::string& expr, const std::string& query)
|
||||
* GetAuxValue
|
||||
****************************************************************************************/
|
||||
char* GetAuxValue(const char* aux, const char* name) {
|
||||
if (isempty(aux))
|
||||
return NULL;
|
||||
if (isempty(aux))
|
||||
return NULL;
|
||||
|
||||
char* descr = strdup(aux);
|
||||
char* beginaux = strstr(descr, "<epgsearch>");
|
||||
char* endaux = strstr(descr, "</epgsearch>");
|
||||
if (!beginaux || !endaux) {
|
||||
char* descr = strdup(aux);
|
||||
char* beginaux = strstr(descr, "<epgsearch>");
|
||||
char* endaux = strstr(descr, "</epgsearch>");
|
||||
if (!beginaux || !endaux) {
|
||||
free(descr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
beginaux += 11; // strlen("<epgsearch>");
|
||||
endaux[0] = 0;
|
||||
memmove(descr, beginaux, endaux - beginaux + 1);
|
||||
|
||||
if (strcmp(name, "epgsearch") == 0)
|
||||
return descr; // full aux
|
||||
|
||||
int namelen = strlen(name);
|
||||
char catname[100] = "";
|
||||
catname[0] = '<';
|
||||
memcpy(catname + 1, name, namelen);
|
||||
catname[1 + namelen] = '>';
|
||||
catname[2 + namelen] = 0;
|
||||
|
||||
char* cat = strcasestr(descr, catname);
|
||||
if (!cat) {
|
||||
free(descr);
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cat += namelen + 2;
|
||||
char* end = strstr(cat, "</");
|
||||
if (!end) {
|
||||
free(descr);
|
||||
return NULL;
|
||||
beginaux += 11; // strlen("<epgsearch>");
|
||||
endaux[0] = 0;
|
||||
memmove(descr, beginaux, endaux - beginaux + 1);
|
||||
|
||||
if (strcmp(name, "epgsearch") == 0)
|
||||
return descr; // full aux
|
||||
|
||||
int namelen = strlen(name);
|
||||
char catname[100] = "";
|
||||
catname[0] = '<';
|
||||
memcpy(catname + 1, name, namelen);
|
||||
catname[1 + namelen] = '>';
|
||||
catname[2 + namelen] = 0;
|
||||
|
||||
char* cat = strcasestr(descr, catname);
|
||||
if (!cat) {
|
||||
free(descr);
|
||||
return NULL;
|
||||
}
|
||||
end[0] = 0;
|
||||
|
||||
int catlen = end - cat + 1;
|
||||
char* value = (char *) malloc(catlen);
|
||||
memcpy(value, cat, catlen);
|
||||
cat += namelen + 2;
|
||||
char* end = strstr(cat, "</");
|
||||
if (!end) {
|
||||
free(descr);
|
||||
return NULL;
|
||||
}
|
||||
end[0] = 0;
|
||||
|
||||
free(descr);
|
||||
return value;
|
||||
int catlen = end - cat + 1;
|
||||
char* value = (char *) malloc(catlen);
|
||||
memcpy(value, cat, catlen);
|
||||
|
||||
free(descr);
|
||||
return value;
|
||||
}
|
||||
|
||||
char* GetAuxValue(const cRecording *recording, const char* name) {
|
||||
if (!recording || !recording->Info())
|
||||
if (!recording || !recording->Info())
|
||||
return NULL;
|
||||
return GetAuxValue(recording->Info()->Aux(), name);
|
||||
}
|
||||
|
||||
char* GetAuxValue(const cTimer *timer, const char* name) {
|
||||
if (!timer || !timer->Aux())
|
||||
if (!timer || !timer->Aux())
|
||||
return NULL;
|
||||
return GetAuxValue(timer->Aux(), name);
|
||||
}
|
||||
@ -244,239 +244,239 @@ char* GetAuxValue(const cTimer *timer, const char* name) {
|
||||
|
||||
/******************************************************************************
|
||||
FUNCTION afuzzy_init()
|
||||
Initialization of the fuzzy search routine. This applies to the consequent
|
||||
calls of the afuzzy_CheckRTR (whole string matching) and afuzzy_CheckSUB
|
||||
(substring match) routines. afuzzy_init() should be called for each
|
||||
new pattern or error length. The search is case sensitive
|
||||
Initialization of the fuzzy search routine. This applies to the consequent
|
||||
calls of the afuzzy_CheckRTR (whole string matching) and afuzzy_CheckSUB
|
||||
(substring match) routines. afuzzy_init() should be called for each
|
||||
new pattern or error length. The search is case sensitive
|
||||
|
||||
ARGUMENTS:
|
||||
p Pattern
|
||||
kerr Number of possible errors. Shouldn't exceed pattern length
|
||||
UseFilter Use agrep filter algorithm that speeds up search.
|
||||
fuzzy pointer to the structure that will be later passes to Check*
|
||||
(the first 6 elements should be NULLs for the first call)
|
||||
p Pattern
|
||||
kerr Number of possible errors. Shouldn't exceed pattern length
|
||||
UseFilter Use agrep filter algorithm that speeds up search.
|
||||
fuzzy pointer to the structure that will be later passes to Check*
|
||||
(the first 6 elements should be NULLs for the first call)
|
||||
|
||||
RETURN VALUE:
|
||||
none
|
||||
none
|
||||
|
||||
ALGORITHM
|
||||
see. the article on agrep algorithms.
|
||||
The only change is accounting transpositions as one edit operation .
|
||||
see. the article on agrep algorithms.
|
||||
The only change is accounting transpositions as one edit operation .
|
||||
******************************************************************************/
|
||||
void afuzzy_init(const char *p, int kerr, int UseFilter, AFUZZY *fuzzy)
|
||||
{
|
||||
int cnt, p_len, i, j, l, d, m, dd;
|
||||
char PatFilter[sizeof(Uint)*8 + 1];
|
||||
int cnt, p_len, i, j, l, d, m, dd;
|
||||
char PatFilter[sizeof(Uint)*8 + 1];
|
||||
|
||||
fuzzy->k = kerr;
|
||||
m = strlen(p);
|
||||
fuzzy->FilterSet = 0;
|
||||
memset(fuzzy->Map, 0 , sizeof(fuzzy->Map) );
|
||||
fuzzy->k = kerr;
|
||||
m = strlen(p);
|
||||
fuzzy->FilterSet = 0;
|
||||
memset(fuzzy->Map, 0 , sizeof(fuzzy->Map) );
|
||||
|
||||
if (fuzzy->S)
|
||||
free(fuzzy->S);
|
||||
if (fuzzy->R)
|
||||
free(fuzzy->R);
|
||||
if (fuzzy->R1)
|
||||
free(fuzzy->R1);
|
||||
if (fuzzy->RP)
|
||||
free(fuzzy->RP);
|
||||
if (fuzzy->RI)
|
||||
free(fuzzy->RI);
|
||||
if (fuzzy->FilterS)
|
||||
free(fuzzy->FilterS);
|
||||
if (fuzzy->S)
|
||||
free(fuzzy->S);
|
||||
if (fuzzy->R)
|
||||
free(fuzzy->R);
|
||||
if (fuzzy->R1)
|
||||
free(fuzzy->R1);
|
||||
if (fuzzy->RP)
|
||||
free(fuzzy->RP);
|
||||
if (fuzzy->RI)
|
||||
free(fuzzy->RI);
|
||||
if (fuzzy->FilterS)
|
||||
free(fuzzy->FilterS);
|
||||
|
||||
fuzzy->FilterS = NULL;
|
||||
fuzzy->S = (Uint *)calloc(m + 1, sizeof(Uint));
|
||||
fuzzy->R = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
|
||||
fuzzy->R1 = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
|
||||
fuzzy->RI = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
|
||||
fuzzy->RP = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
|
||||
fuzzy->FilterS = NULL;
|
||||
fuzzy->S = (Uint *)calloc(m + 1, sizeof(Uint));
|
||||
fuzzy->R = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
|
||||
fuzzy->R1 = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
|
||||
fuzzy->RI = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
|
||||
fuzzy->RP = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
|
||||
|
||||
for (i = 0, cnt = 0; i < m; i++)
|
||||
{
|
||||
l = fuzzy->Map[(unsigned char)p[i]];
|
||||
if (!l)
|
||||
{
|
||||
l = fuzzy->Map[(unsigned char)p[i]] = ++cnt;
|
||||
fuzzy->S[l] = 0;
|
||||
}
|
||||
fuzzy->S[l] |= 1 << i;
|
||||
}
|
||||
for (i = 0, cnt = 0; i < m; i++)
|
||||
{
|
||||
l = fuzzy->Map[(unsigned char)p[i]];
|
||||
if (!l)
|
||||
{
|
||||
l = fuzzy->Map[(unsigned char)p[i]] = ++cnt;
|
||||
fuzzy->S[l] = 0;
|
||||
}
|
||||
fuzzy->S[l] |= 1 << i;
|
||||
}
|
||||
|
||||
|
||||
for (d = 0; d <= fuzzy->k; d++)
|
||||
fuzzy->RI[d] = (1 << d) - 1;
|
||||
for (d = 0; d <= fuzzy->k; d++)
|
||||
fuzzy->RI[d] = (1 << d) - 1;
|
||||
|
||||
fuzzy->mask_ok = (1 << (m - 1));
|
||||
fuzzy->r_size = sizeof(Uint) * (fuzzy->k + 1);
|
||||
p_len = m;
|
||||
fuzzy->mask_ok = (1 << (m - 1));
|
||||
fuzzy->r_size = sizeof(Uint) * (fuzzy->k + 1);
|
||||
p_len = m;
|
||||
|
||||
if (p_len > (int) sizeof(Uint)*8)
|
||||
p_len = (int) sizeof(Uint)*8;
|
||||
if (p_len > (int) sizeof(Uint)*8)
|
||||
p_len = (int) sizeof(Uint)*8;
|
||||
|
||||
/* If k is zero then no filter is needed! */
|
||||
if (fuzzy->k && (p_len >= 2*(fuzzy->k + 1)) )
|
||||
{
|
||||
if (UseFilter)
|
||||
{
|
||||
fuzzy->FilterSet = 1;
|
||||
memset(fuzzy->FilterMap, 0 , sizeof(fuzzy->FilterMap) );
|
||||
fuzzy->FilterS = (Uint *)calloc(m + 1, sizeof(Uint));
|
||||
/* If k is zero then no filter is needed! */
|
||||
if (fuzzy->k && (p_len >= 2*(fuzzy->k + 1)) )
|
||||
{
|
||||
if (UseFilter)
|
||||
{
|
||||
fuzzy->FilterSet = 1;
|
||||
memset(fuzzy->FilterMap, 0 , sizeof(fuzzy->FilterMap) );
|
||||
fuzzy->FilterS = (Uint *)calloc(m + 1, sizeof(Uint));
|
||||
|
||||
/* Not let's fill the interleaved pattern */
|
||||
dd = p_len / (fuzzy->k + 1);
|
||||
p_len = dd * (fuzzy->k + 1);
|
||||
/* Not let's fill the interleaved pattern */
|
||||
dd = p_len / (fuzzy->k + 1);
|
||||
p_len = dd * (fuzzy->k + 1);
|
||||
|
||||
for (i = 0, cnt = 0; i < dd; i++)
|
||||
for (j = 0; j < fuzzy->k + 1; j++, cnt++)
|
||||
PatFilter[cnt] = (unsigned char)p[j*dd + i];
|
||||
PatFilter[p_len] = 0;
|
||||
for (i = 0, cnt = 0; i < dd; i++)
|
||||
for (j = 0; j < fuzzy->k + 1; j++, cnt++)
|
||||
PatFilter[cnt] = (unsigned char)p[j*dd + i];
|
||||
PatFilter[p_len] = 0;
|
||||
|
||||
for (i = 0, cnt = 0; i < p_len; i++)
|
||||
{
|
||||
l = fuzzy->FilterMap[(unsigned char)PatFilter[i]];
|
||||
if (!l)
|
||||
{
|
||||
l = fuzzy->FilterMap[(unsigned char)PatFilter[i]] = ++cnt;
|
||||
fuzzy->FilterS[l] = 0;
|
||||
}
|
||||
fuzzy->FilterS[l] |= 1 << i;
|
||||
}
|
||||
fuzzy->filter_ok = 0;
|
||||
for (i = p_len - fuzzy->k - 1; i <= p_len - 1; i++) /* k+1 times */
|
||||
fuzzy->filter_ok |= 1 << i;
|
||||
for (i = 0, cnt = 0; i < p_len; i++)
|
||||
{
|
||||
l = fuzzy->FilterMap[(unsigned char)PatFilter[i]];
|
||||
if (!l)
|
||||
{
|
||||
l = fuzzy->FilterMap[(unsigned char)PatFilter[i]] = ++cnt;
|
||||
fuzzy->FilterS[l] = 0;
|
||||
}
|
||||
fuzzy->FilterS[l] |= 1 << i;
|
||||
}
|
||||
fuzzy->filter_ok = 0;
|
||||
for (i = p_len - fuzzy->k - 1; i <= p_len - 1; i++) /* k+1 times */
|
||||
fuzzy->filter_ok |= 1 << i;
|
||||
|
||||
/* k+1 first bits set to 1 */
|
||||
fuzzy->filter_shift = (1 << (fuzzy->k + 2)) - 1;
|
||||
}
|
||||
}
|
||||
/* k+1 first bits set to 1 */
|
||||
fuzzy->filter_shift = (1 << (fuzzy->k + 2)) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
FUNCTION afuzzy_free()
|
||||
Cleaning up after previous afuzzy_init() call.
|
||||
Cleaning up after previous afuzzy_init() call.
|
||||
|
||||
ARGUMENTS:
|
||||
fuzzy pointer to the afuzzy parameters structure
|
||||
fuzzy pointer to the afuzzy parameters structure
|
||||
|
||||
RETURN VALUE:
|
||||
none
|
||||
none
|
||||
******************************************************************************/
|
||||
void afuzzy_free(AFUZZY *fuzzy)
|
||||
{
|
||||
if (fuzzy->S)
|
||||
{
|
||||
free(fuzzy->S);
|
||||
fuzzy->S = NULL;
|
||||
}
|
||||
if (fuzzy->R)
|
||||
{
|
||||
free(fuzzy->R);
|
||||
fuzzy->R = NULL;
|
||||
}
|
||||
if (fuzzy->R1)
|
||||
{
|
||||
free(fuzzy->R1);
|
||||
fuzzy->R1 = NULL;
|
||||
}
|
||||
if (fuzzy->RP)
|
||||
{
|
||||
free(fuzzy->RP);
|
||||
fuzzy->RP = NULL;
|
||||
}
|
||||
if (fuzzy->RI)
|
||||
{
|
||||
free(fuzzy->RI);
|
||||
fuzzy->RI = NULL;
|
||||
}
|
||||
if (fuzzy->FilterS)
|
||||
{
|
||||
free(fuzzy->FilterS);
|
||||
fuzzy->FilterS = NULL;
|
||||
}
|
||||
if (fuzzy->S)
|
||||
{
|
||||
free(fuzzy->S);
|
||||
fuzzy->S = NULL;
|
||||
}
|
||||
if (fuzzy->R)
|
||||
{
|
||||
free(fuzzy->R);
|
||||
fuzzy->R = NULL;
|
||||
}
|
||||
if (fuzzy->R1)
|
||||
{
|
||||
free(fuzzy->R1);
|
||||
fuzzy->R1 = NULL;
|
||||
}
|
||||
if (fuzzy->RP)
|
||||
{
|
||||
free(fuzzy->RP);
|
||||
fuzzy->RP = NULL;
|
||||
}
|
||||
if (fuzzy->RI)
|
||||
{
|
||||
free(fuzzy->RI);
|
||||
fuzzy->RI = NULL;
|
||||
}
|
||||
if (fuzzy->FilterS)
|
||||
{
|
||||
free(fuzzy->FilterS);
|
||||
fuzzy->FilterS = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
FUNCTION afuzzy_CheckSUB()
|
||||
Perform a fuzzy pattern substring matching. afuzzy_init() should be
|
||||
called previously to initialize the pattern and error length.
|
||||
Positive result means that some part of the string given matches the
|
||||
pattern with no more than afuzzy->k errors (1 error = 1 letter
|
||||
replacement or transposition)
|
||||
Perform a fuzzy pattern substring matching. afuzzy_init() should be
|
||||
called previously to initialize the pattern and error length.
|
||||
Positive result means that some part of the string given matches the
|
||||
pattern with no more than afuzzy->k errors (1 error = 1 letter
|
||||
replacement or transposition)
|
||||
|
||||
ARGUMENTS:
|
||||
t the string to test
|
||||
fuzzy pointer to the afuzzy parameters structure
|
||||
t the string to test
|
||||
fuzzy pointer to the afuzzy parameters structure
|
||||
|
||||
RETURN VALUE:
|
||||
0 - no match
|
||||
> 0 - strings match
|
||||
0 - no match
|
||||
> 0 - strings match
|
||||
|
||||
ALGORITHM
|
||||
????????????????
|
||||
????????????????
|
||||
******************************************************************************/
|
||||
int afuzzy_checkSUB(const char *t, AFUZZY *fuzzy)
|
||||
{
|
||||
register char c;
|
||||
register int j, d;
|
||||
register char c;
|
||||
register int j, d;
|
||||
|
||||
/* For eficciency this case should be little bit optimized */
|
||||
if (!fuzzy->k)
|
||||
{
|
||||
Uint R = 0, R1;
|
||||
/* For eficciency this case should be little bit optimized */
|
||||
if (!fuzzy->k)
|
||||
{
|
||||
Uint R = 0, R1;
|
||||
|
||||
for (j = 0; (c = t[j]) != '\0'; j++)
|
||||
{
|
||||
R1 = ( ((R<<1) | 1) & fuzzy->S[fuzzy->Map[(unsigned char)c]]);
|
||||
R = R1;
|
||||
for (j = 0; (c = t[j]) != '\0'; j++)
|
||||
{
|
||||
R1 = ( ((R<<1) | 1) & fuzzy->S[fuzzy->Map[(unsigned char)c]]);
|
||||
R = R1;
|
||||
|
||||
if (R1 & fuzzy->mask_ok)
|
||||
return 1;
|
||||
} /* end for (register int j = 0 ... */
|
||||
return 0;
|
||||
}
|
||||
if (R1 & fuzzy->mask_ok)
|
||||
return 1;
|
||||
} /* end for (register int j = 0 ... */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fuzzy->FilterSet && !afuzzy_checkFLT(t, fuzzy))
|
||||
return 0;
|
||||
if (fuzzy->FilterSet && !afuzzy_checkFLT(t, fuzzy))
|
||||
return 0;
|
||||
|
||||
memcpy(fuzzy->R, fuzzy->RI, fuzzy->r_size); /* R = RI */
|
||||
memcpy(fuzzy->R, fuzzy->RI, fuzzy->r_size); /* R = RI */
|
||||
|
||||
for (j = 0; (c = t[j]); j++)
|
||||
{
|
||||
for (d = 0; d <= fuzzy->k; d++)
|
||||
{
|
||||
fuzzy->R1[d] = (((fuzzy->R[d]<<1) | 1) &
|
||||
fuzzy->S[fuzzy->Map[(unsigned char)c]]);
|
||||
if (d > 0)
|
||||
fuzzy->R1[d] |= ((fuzzy->R[d-1] | fuzzy->R1[d-1])<<1) | 1 |
|
||||
fuzzy->R[d-1];
|
||||
}
|
||||
if (fuzzy->R1[fuzzy->k] & fuzzy->mask_ok)
|
||||
return j;
|
||||
for (j = 0; (c = t[j]); j++)
|
||||
{
|
||||
for (d = 0; d <= fuzzy->k; d++)
|
||||
{
|
||||
fuzzy->R1[d] = (((fuzzy->R[d]<<1) | 1) &
|
||||
fuzzy->S[fuzzy->Map[(unsigned char)c]]);
|
||||
if (d > 0)
|
||||
fuzzy->R1[d] |= ((fuzzy->R[d-1] | fuzzy->R1[d-1])<<1) | 1 |
|
||||
fuzzy->R[d-1];
|
||||
}
|
||||
if (fuzzy->R1[fuzzy->k] & fuzzy->mask_ok)
|
||||
return j;
|
||||
|
||||
memcpy(fuzzy->R, fuzzy->R1, fuzzy->r_size);
|
||||
memcpy(fuzzy->R, fuzzy->R1, fuzzy->r_size);
|
||||
|
||||
} /* end for (register int j = 0 ... */
|
||||
} /* end for (register int j = 0 ... */
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int afuzzy_checkFLT(const char *t, AFUZZY *fuzzy)
|
||||
{
|
||||
register Uint FilterR = 0;
|
||||
register Uint FilterR1;
|
||||
register int j;
|
||||
register Uint FilterR = 0;
|
||||
register Uint FilterR1;
|
||||
register int j;
|
||||
|
||||
for (j = 0; t[j] != '\0'; j++)
|
||||
{
|
||||
FilterR1 = ( ((FilterR<<(fuzzy->k+1)) | fuzzy->filter_shift) &
|
||||
fuzzy->FilterS[fuzzy->FilterMap[(unsigned char)t[j]]]);
|
||||
if (FilterR1 & fuzzy->filter_ok)
|
||||
return 1;
|
||||
FilterR = FilterR1;
|
||||
} /* end for (register int j = 0 ... */
|
||||
for (j = 0; t[j] != '\0'; j++)
|
||||
{
|
||||
FilterR1 = ( ((FilterR<<(fuzzy->k+1)) | fuzzy->filter_shift) &
|
||||
fuzzy->FilterS[fuzzy->FilterMap[(unsigned char)t[j]]]);
|
||||
if (FilterR1 & fuzzy->filter_ok)
|
||||
return 1;
|
||||
FilterR = FilterR1;
|
||||
} /* end for (register int j = 0 ... */
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
28
tools.h
28
tools.h
@ -45,21 +45,21 @@ typedef unsigned int Uint;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Uint *R,
|
||||
*R1,
|
||||
*RP,
|
||||
*S,
|
||||
*RI;
|
||||
Uint *FilterS;
|
||||
Uint *R,
|
||||
*R1,
|
||||
*RP,
|
||||
*S,
|
||||
*RI;
|
||||
Uint *FilterS;
|
||||
|
||||
int Map[256];
|
||||
int FilterMap[256];
|
||||
int k;
|
||||
Uint mask_ok;
|
||||
Uint filter_ok;
|
||||
Uint filter_shift;
|
||||
int r_size;
|
||||
int FilterSet;
|
||||
int Map[256];
|
||||
int FilterMap[256];
|
||||
int k;
|
||||
Uint mask_ok;
|
||||
Uint filter_ok;
|
||||
Uint filter_shift;
|
||||
int r_size;
|
||||
int FilterSet;
|
||||
} AFUZZY;
|
||||
|
||||
void afuzzy_init(const char *p, int kerr, int UseFilter, AFUZZY *fuzzy);
|
||||
|
Loading…
Reference in New Issue
Block a user