author | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
---|---|---|
committer | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
commit | 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (side-by-side diff) | |
tree | 96e66fdc18dca4d4ab8611133e072f57dea224b9 /noncore/apps/opie-reader/CRegExp.cpp | |
parent | 279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff) | |
download | opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.zip opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.gz opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.bz2 |
new opie-reader sources with support for ArriereGo, Reb input and flite output plugins
Diffstat (limited to 'noncore/apps/opie-reader/CRegExp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CRegExp.cpp | 170 |
1 files changed, 85 insertions, 85 deletions
diff --git a/noncore/apps/opie-reader/CRegExp.cpp b/noncore/apps/opie-reader/CRegExp.cpp index 77dc2dc..6318d28 100644 --- a/noncore/apps/opie-reader/CRegExp.cpp +++ b/noncore/apps/opie-reader/CRegExp.cpp @@ -40,307 +40,307 @@ tchar CRegExpFilt::escapedchar(tchar c) return c; break; } } void CRegExpFilt::regchar(tchar c, bool insens) { if (insens) { tchar t = upper(c); CV[t] = 0; t = lower(c); CV[t] = 0; } else { CV[c] = 0; } } void CRegExpFilt::prepreprocessing(const QString& pat, bool insens) { for (unsigned int p = 0; p < pat.length(); p++) { -#ifdef _WINDOWS
- switch (pat.at(p).unicode())
-#else
- switch (pat[p].unicode())
-#endif
+#ifdef _WINDOWS + switch (pat.at(p).unicode()) +#else + switch (pat[p].unicode()) +#endif { case '{': { break; } case '}': { break; } case '^': { break; } case '.' : { break; } case '#': { - p++;
+ p++; #ifdef _WINDOWS - while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9')
-#else
- while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9')
-#endif
+ while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') +#else + while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') +#endif { } p--; break; } case '\\' : - {
+ { #ifdef _WINDOWS - tchar c = escapedchar(pat.at(++p).unicode());
-#else
- tchar c = escapedchar(pat[++p].unicode());
-#endif
+ tchar c = escapedchar(pat.at(++p).unicode()); +#else + tchar c = escapedchar(pat[++p].unicode()); +#endif regchar(c, insens); break; } case '[' : { tchar clast; bool invert = false; - tchar c;
+ tchar c; #ifdef _WINDOWS - if (pat.at(p+1).unicode() == '^')
-#else
- if (pat[p+1].unicode() == '^')
-#endif
+ if (pat.at(p+1).unicode() == '^') +#else + if (pat[p+1].unicode() == '^') +#endif { p++; invert = true; - }
+ } #ifdef _WINDOWS - while ((c = pat.at(++p).unicode()) != ']')
-#else
- while ((c = pat[++p].unicode()) != ']')
-#endif
+ while ((c = pat.at(++p).unicode()) != ']') +#else + while ((c = pat[++p].unicode()) != ']') +#endif { if (c == '\\') - {
+ { #ifdef _WINDOWS - c = escapedchar(pat.at(++p).unicode());
-#else
- c = escapedchar(pat[++p].unicode());
-#endif
+ c = escapedchar(pat.at(++p).unicode()); +#else + c = escapedchar(pat[++p].unicode()); +#endif if (c == ']') break; } if (c == '-') - {
+ { #ifdef _WINDOWS - c = pat.at(++p).unicode();
-#else
- c = pat[++p].unicode();
-#endif
+ c = pat.at(++p).unicode(); +#else + c = pat[++p].unicode(); +#endif for (tchar j = clast; j <= c; j++) { regchar(j, insens); } } else { regchar(c, insens); } clast = c; } break; } default : - {
+ { #ifdef _WINDOWS - regchar(pat.at(p).unicode(), insens);
-#else
- regchar(pat[p].unicode(), insens);
-#endif
+ regchar(pat.at(p).unicode(), insens); +#else + regchar(pat[p].unicode(), insens); +#endif break; } } } /* for (iter i = CV.begin(); i != CV.end(); ++i) { printf("Pre: [%u]\n", i.first()); } */ CV[0] = 0; } unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) { prepreprocessing(pat, insens); qDebug("PrePreProcessing done"); unsigned int p, m; bool inkeep = false; keep = 0; replace = 0; for (unsigned int j = 0; j < WORD_SIZE; j++) { bit[j] = (1 << (WORD_SIZE -j -1)); lfcnt[j] = 0; } for (p = 0, m = 0; p < pat.length(); p++) { qDebug("m is %u", m); - if (inkeep) keep |= bit[m];
+ if (inkeep) keep |= bit[m]; #ifdef _WINDOWS - switch (pat.at(p).unicode())
-#else
- switch (pat[p].unicode())
-#endif
+ switch (pat.at(p).unicode()) +#else + switch (pat[p].unicode()) +#endif { case '{': { inkeep = true; break; } case '}': { keep ^= bit[m]; inkeep = false; break; } case '^': { replace |= bit[m]; lfcnt[m]++; break; } case '.' : { for (iter j = CV.begin(); j != CV.end(); ++j) CV[j.first()] |= bit[m]; m++; break; } case '#': { if (m > 0) { p++; - int count = 0;
+ int count = 0; #ifdef _WINDOWS - while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9')
-#else
- while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9')
-#endif
- {
+ while ('0' <= pat.at(p).unicode() && pat.at(p).unicode() <= '9') +#else + while ('0' <= pat[p].unicode() && pat[p].unicode() <= '9') +#endif + { #ifdef _WINDOWS - count = 10*count + pat.at(p++).unicode() - '0';
-#else
- count = 10*count + pat[p++].unicode() - '0';
-#endif
+ count = 10*count + pat.at(p++).unicode() - '0'; +#else + count = 10*count + pat[p++].unicode() - '0'; +#endif } p--; count = count-1; unsigned int mask = 0; for (unsigned int i = m; i < m+count; i++) { mask |= bit[i]; } for (iter it = CV.begin(); it != CV.end(); ++it) { if (CV[it.first()] & bit[m-1]) { CV[it.first()] |= mask; } } if (keep & bit[m-1]) keep |= mask; m += count; } else { p++; } break; } case '\\' : - {
+ { #ifdef _WINDOWS - tchar c = escapedchar(pat.at(++p).unicode());
-#else
- tchar c = escapedchar(pat[++p].unicode());
-#endif
+ tchar c = escapedchar(pat.at(++p).unicode()); +#else + tchar c = escapedchar(pat[++p].unicode()); +#endif if (insens) { CV[upper(c)] |= bit[m]; CV[lower(c)] |= bit[m]; } else { CV[c] |= bit[m]; } m++; break; } case '[' : { tchar c, clast; - bool invert = false;
+ bool invert = false; #ifdef _WINDOWS - if (pat.at(p+1).unicode() == '^')
-#else
- if (pat[p+1].unicode() == '^')
-#endif
+ if (pat.at(p+1).unicode() == '^') +#else + if (pat[p+1].unicode() == '^') +#endif { p++; invert = true; - }
+ } #ifdef _WINDOWS - while ((c = pat.at(++p).unicode()) != ']')
-#else
- while ((c = pat[++p].unicode()) != ']')
-#endif
+ while ((c = pat.at(++p).unicode()) != ']') +#else + while ((c = pat[++p].unicode()) != ']') +#endif { if (c == '\\') - {
+ { #ifdef _WINDOWS - c = escapedchar(pat.at(++p).unicode());
-#else
- c = escapedchar(pat[++p].unicode());
-#endif
+ c = escapedchar(pat.at(++p).unicode()); +#else + c = escapedchar(pat[++p].unicode()); +#endif if (c == ']') break; } if (c == '-') - {
+ { #ifdef _WINDOWS - c = pat.at(++p).unicode();
-#else
- c = pat[++p].unicode();
-#endif
+ c = pat.at(++p).unicode(); +#else + c = pat[++p].unicode(); +#endif for (tchar j = clast; j <= c; j++) { if (insens) { iter it; if ((it = CV.find(upper(j))) != CV.end()) CV[it] |= bit[m]; else CV[0] |= bit[m]; if ((it = CV.find(lower(j))) != CV.end()) CV[it] |= bit[m]; else CV[0] |= bit[m]; } else { iter it; if ((it = CV.find(j)) != CV.end()) CV[it] |= bit[m]; else { CV[0] |= bit[m]; } } @@ -361,54 +361,54 @@ unsigned int CRegExpFilt::preprocessing(const QString& pat, bool insens) CV[0] |= bit[m]; } else { iter it; if ((it = CV.find(c)) != CV.end()) CV[it] |= bit[m]; else CV[0] |= bit[m]; } } clast = c; } if (invert) { for (iter i = CV.begin(); i != CV.end(); ++i) { CV[i.first()] ^= bit[m]; } } m++; break; } default : - {
+ { #ifdef _WINDOWS - tchar c = pat.at(p).unicode();
-#else
- tchar c = pat[p].unicode();
-#endif
+ tchar c = pat.at(p).unicode(); +#else + tchar c = pat[p].unicode(); +#endif if (insens) { CV[upper(c)] |= bit[m]; CV[lower(c)] |= bit[m]; } else CV[c] |= bit[m]; m++; break; } } } qDebug("Returning:%u",m); return m; } bool CRegExpFilt::empty() { return m_outQueue.empty(); } tchar CRegExpFilt::pop() { return m_outQueue.pop(); } |