author | ar <ar> | 2004-05-27 22:04:46 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-27 22:04:46 (UTC) |
commit | 4f7c3c4d0d634706d13950b3827714b168e279e3 (patch) (side-by-side diff) | |
tree | 2df448e7a4dcd538c26365873e194be2b55e83b7 | |
parent | 46f81a089ba8febdb79e0d150b69f74bb1ea7d18 (diff) | |
download | opie-4f7c3c4d0d634706d13950b3827714b168e279e3.zip opie-4f7c3c4d0d634706d13950b3827714b168e279e3.tar.gz opie-4f7c3c4d0d634706d13950b3827714b168e279e3.tar.bz2 |
- convert qDebug to odebug
-rw-r--r-- | noncore/apps/keyz-cfg/zkb.cpp | 716 | ||||
-rw-r--r-- | noncore/apps/opie-gutenbrowser/gutenbrowser.cpp | 15 | ||||
-rw-r--r-- | noncore/apps/opie-reader/BuffDoc.h | 116 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CEncoding.h | 16 | ||||
-rw-r--r-- | noncore/apps/opie-reader/CExpander.h | 140 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Filedata.h | 56 | ||||
-rw-r--r-- | noncore/apps/opie-reader/FontControl.h | 178 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Palm2QImage.cpp | 125 | ||||
-rw-r--r-- | noncore/apps/opie-reader/QTReader.h | 124 | ||||
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.h | 112 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katedocument.h | 14 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp | 2282 |
12 files changed, 1957 insertions, 1937 deletions
diff --git a/noncore/apps/keyz-cfg/zkb.cpp b/noncore/apps/keyz-cfg/zkb.cpp index 58bde2a..c9e1dc5 100644 --- a/noncore/apps/keyz-cfg/zkb.cpp +++ b/noncore/apps/keyz-cfg/zkb.cpp @@ -1,2 +1,6 @@ #include "zkb.h" + +/* OPIE */ +#include <opie2/odebug.h> + #include <stdio.h> @@ -8,3 +12,3 @@ Action::Action():state(0), keycode(0), unicode(0), flags(0) { Action::Action(State* s, ushort kc, ushort uni, int f): - state(s), keycode(kc), unicode(uni), flags(f) { + state(s), keycode(kc), unicode(uni), flags(f) { } @@ -15,3 +19,3 @@ Action::~Action() { State* Action::getState() const { - return state; + return state; } @@ -19,4 +23,4 @@ State* Action::getState() const { void Action::setState(State* s) { - state = s; - setDefined(true); + state = s; + setDefined(true); } @@ -24,3 +28,3 @@ void Action::setState(State* s) { bool Action::hasEvent() const { - return flags & Event; + return flags & Event; } @@ -28,11 +32,11 @@ bool Action::hasEvent() const { void Action::setEvent(bool e) { - flags = (flags & ~Event) | ((e) ? Event : 0); + flags = (flags & ~Event) | ((e) ? Event : 0); - if (e) { - setDefined(true); - } else { - if (state == 0) { - setDefined(false); - } - } + if (e) { + setDefined(true); + } else { + if (state == 0) { + setDefined(false); + } + } } @@ -40,3 +44,3 @@ void Action::setEvent(bool e) { bool Action::isDefined() const { - return flags & Defined; + return flags & Defined; } @@ -44,3 +48,3 @@ bool Action::isDefined() const { void Action::setDefined(bool d) { - flags = (flags & ~Defined) | ((d) ? Defined : 0); + flags = (flags & ~Defined) | ((d) ? Defined : 0); } @@ -48,3 +52,3 @@ void Action::setDefined(bool d) { int Action::getKeycode() const { - return keycode; + return keycode; } @@ -52,4 +56,4 @@ int Action::getKeycode() const { void Action::setKeycode(int c) { - keycode = (ushort) c; - setEvent(true); + keycode = (ushort) c; + setEvent(true); } @@ -57,3 +61,3 @@ void Action::setKeycode(int c) { int Action::getUnicode() const { - return unicode; + return unicode; } @@ -61,4 +65,4 @@ int Action::getUnicode() const { void Action::setUnicode(int u) { - unicode = (ushort) u; - setEvent(true); + unicode = (ushort) u; + setEvent(true); } @@ -66,20 +70,20 @@ void Action::setUnicode(int u) { int Action::getModifiers() const { - int ret = 0; - if (flags & Shift_Mod) { - ret |= Qt::ShiftButton; - } + int ret = 0; + if (flags & Shift_Mod) { + ret |= Qt::ShiftButton; + } - if (flags & Ctrl_Mod) { - ret |= Qt::ControlButton; - } + if (flags & Ctrl_Mod) { + ret |= Qt::ControlButton; + } - if (flags & Alt_Mod) { - ret |= Qt::AltButton; - } + if (flags & Alt_Mod) { + ret |= Qt::AltButton; + } - if (flags & Keypad_Mod) { - ret |= Qt::Keypad; - } + if (flags & Keypad_Mod) { + ret |= Qt::Keypad; + } - return ret; + return ret; } @@ -87,22 +91,22 @@ int Action::getModifiers() const { void Action::setModifiers(int m) { - int n = 0; + int n = 0; - if (m & Qt::ShiftButton) { - n |= Shift_Mod; - } + if (m & Qt::ShiftButton) { + n |= Shift_Mod; + } - if (m & Qt::ControlButton) { - n |= Ctrl_Mod; - } + if (m & Qt::ControlButton) { + n |= Ctrl_Mod; + } - if (m & Qt::AltButton) { - n |= Alt_Mod; - } + if (m & Qt::AltButton) { + n |= Alt_Mod; + } - if (m & Qt::Keypad) { - n |= Keypad_Mod; - } + if (m & Qt::Keypad) { + n |= Keypad_Mod; + } - flags = flags & ~Mod_Bits | n; - setEvent(true); + flags = flags & ~Mod_Bits | n; + setEvent(true); } @@ -110,3 +114,3 @@ void Action::setModifiers(int m) { bool Action::isPressed() const { - return (flags & Press) != 0; + return (flags & Press) != 0; } @@ -114,4 +118,4 @@ bool Action::isPressed() const { void Action::setPressed(bool p) { - flags = (flags & ~Press) | ((p) ? Press : 0); - setEvent(true); + flags = (flags & ~Press) | ((p) ? Press : 0); + setEvent(true); } @@ -119,3 +123,3 @@ void Action::setPressed(bool p) { bool Action::isAutorepeat() const { - return (flags & Autorepeat) != 0; + return (flags & Autorepeat) != 0; } @@ -123,4 +127,4 @@ bool Action::isAutorepeat() const { void Action::setAutorepeat(bool p) { - flags = (flags & ~Autorepeat) | ((p) ? Autorepeat : 0); - setEvent(true); + flags = (flags & ~Autorepeat) | ((p) ? Autorepeat : 0); + setEvent(true); } @@ -129,14 +133,14 @@ void Action::setAutorepeat(bool p) { const short State::x1[] = { /* from 0x20 to 0x5f */ - 31, 0, 28, 3, 5, 6, 9, 28, /* 0x20 - 0x27 */ - 11, 26, 10, 13, 26, 1, 29, 27, /* 0x28 - 0x2f */ - 15, 16, 22, 4, 17, 19, 24, 20, /* 0x30 - 0x37 */ - 8, 14, 29, 26, 29, 12, 32, 27, /* 0x38 - 0x3f */ - 18, 0, 1, 2, 3, 4, 5, 6, /* 0x40 - 0x47 */ - 7, 8, 9, 10, 11, 12, 13, 14, /* 0x48 - 0x4f */ - 15, 16, 17, 18, 19, 20, 21, 22, /* 0x50 - 0x57 */ - 23, 24, 25, 30, -1, 26, 28, 7, /* 0x58 - 0x5f */ - 31, -1, -1, -1, -1, -1, -1, -1, /* 0x60 - 0x67 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x68 - 0x6f */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x70 - 0x77 */ - -1, -1, -1, 29, 31, 32, 32, 28, /* 0x78 - 0x7f */ + 31, 0, 28, 3, 5, 6, 9, 28, /* 0x20 - 0x27 */ + 11, 26, 10, 13, 26, 1, 29, 27, /* 0x28 - 0x2f */ + 15, 16, 22, 4, 17, 19, 24, 20, /* 0x30 - 0x37 */ + 8, 14, 29, 26, 29, 12, 32, 27, /* 0x38 - 0x3f */ + 18, 0, 1, 2, 3, 4, 5, 6, /* 0x40 - 0x47 */ + 7, 8, 9, 10, 11, 12, 13, 14, /* 0x48 - 0x4f */ + 15, 16, 17, 18, 19, 20, 21, 22, /* 0x50 - 0x57 */ + 23, 24, 25, 30, -1, 26, 28, 7, /* 0x58 - 0x5f */ + 31, -1, -1, -1, -1, -1, -1, -1, /* 0x60 - 0x67 */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x68 - 0x6f */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x70 - 0x77 */ + -1, -1, -1, 29, 31, 32, 32, 28, /* 0x78 - 0x7f */ }; @@ -144,17 +148,17 @@ const short State::x1[] = { /* from 0x20 to 0x5f */ const short State::x2[] = { /* from 0x1000 to 0x1057*/ - 42, 36, -1, 30, 32, -1, -1, -1, /* 0x1000 - 0x1007 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1008 - 0x100f */ - -1, -1, 44, 45, 46, 47, -1, -1, /* 0x1010 - 0x1017 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1018 - 0x101f */ - 33, 35, 34, -1, 36, 27, -1, -1, /* 0x1020 - 0x1027 */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1028 - 0x102f */ - -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1030 - 0x1037 */ - 37, 38, 40, 39, 41, -1, -1, -1, /* 0x1038 - 0x103f */ - -1, -1, -1, -1, -1, 35, -1, -1, /* 0x1040 - 0x1047 */ - -1, -1, -1, -1, -1, 48, -1, -1, /* 0x1048 - 0x104f */ - 43, 49, 50, -1, -1, -1, -1, -1, /* 0x1050 - 0x1057 */ + 42, 36, -1, 30, 32, -1, -1, -1, /* 0x1000 - 0x1007 */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1008 - 0x100f */ + -1, -1, 44, 45, 46, 47, -1, -1, /* 0x1010 - 0x1017 */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1018 - 0x101f */ + 33, 35, 34, -1, 36, 27, -1, -1, /* 0x1020 - 0x1027 */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1028 - 0x102f */ + -1, -1, -1, -1, -1, -1, -1, -1, /* 0x1030 - 0x1037 */ + 37, 38, 40, 39, 41, -1, -1, -1, /* 0x1038 - 0x103f */ + -1, -1, -1, -1, -1, 35, -1, -1, /* 0x1040 - 0x1047 */ + -1, -1, -1, -1, -1, 48, -1, -1, /* 0x1048 - 0x104f */ + 43, 49, 50, -1, -1, -1, -1, -1, /* 0x1050 - 0x1057 */ }; - + State::State(State* p):parent(p), keys(0) { - keys = new Action[Key_Max * 2 + 1]; + keys = new Action[Key_Max * 2 + 1]; } @@ -162,5 +166,5 @@ State::State(State* p):parent(p), keys(0) { State::State(const State& s) { - parent = s.parent; - keys = new Action[Key_Max * 2 + 1]; - memcpy(keys, s.keys, sizeof(Action) * (Key_Max * 2 + 1)); + parent = s.parent; + keys = new Action[Key_Max * 2 + 1]; + memcpy(keys, s.keys, sizeof(Action) * (Key_Max * 2 + 1)); } @@ -168,5 +172,5 @@ State::State(const State& s) { State::~State() { - if (keys!=0) { - delete [] keys; - } + if (keys!=0) { + delete [] keys; + } } @@ -174,19 +178,19 @@ State::~State() { Action* State::get(int keycode, bool pressed, bool follow) const { - Action* ret = 0; - int n = translateKeycode(keycode); + Action* ret = 0; + int n = translateKeycode(keycode); - if (n != -1 && keys != 0) { - if (pressed) { - n += Key_Max; - } - ret = &keys[n]; - } + if (n != -1 && keys != 0) { + if (pressed) { + n += Key_Max; + } + ret = &keys[n]; + } - if (ret==0 || !ret->isDefined()) { - if (follow && parent!=0) { - ret = parent->get(keycode, pressed, follow); - } - } + if (ret==0 || !ret->isDefined()) { + if (follow && parent!=0) { + ret = parent->get(keycode, pressed, follow); + } + } - return ret; + return ret; } @@ -194,14 +198,14 @@ Action* State::get(int keycode, bool pressed, bool follow) const { bool State::set(int keycode, bool pressed, Action& action) { - int n = translateKeycode(keycode); + int n = translateKeycode(keycode); - if (n==-1 || keys==0) { - return false; - } + if (n==-1 || keys==0) { + return false; + } - if (pressed) { - n += Key_Max + 1; - } + if (pressed) { + n += Key_Max + 1; + } - keys[n] = action; - return true; + keys[n] = action; + return true; } @@ -209,3 +213,3 @@ bool State::set(int keycode, bool pressed, Action& action) { State* State::getParent() const { - return parent; + return parent; } @@ -213,3 +217,3 @@ State* State::getParent() const { void State::setParent(State* s) { - parent = s; + parent = s; } @@ -217,19 +221,19 @@ void State::setParent(State* s) { int State::translateKeycode(int keycode) const { - if (keycode < 0x20) { - return -1; - } + if (keycode < 0x20) { + return -1; + } - if (keycode < 0x80) { - return x1[keycode - 0x20]; - } + if (keycode < 0x80) { + return x1[keycode - 0x20]; + } - if (keycode < 0x1000) { - return -1; - } + if (keycode < 0x1000) { + return -1; + } - if (keycode < 0x1057) { - return x2[keycode - 0x1000]; - } + if (keycode < 0x1057) { + return x2[keycode - 0x1000]; + } - return -1; + return -1; } @@ -238,5 +242,5 @@ int State::translateKeycode(int keycode) const { Keymap::Keymap():enabled(true), currentState(0), autoRepeatAction(0), repeater(this) { - repeatDelay=400; - repeatPeriod=80; - connect(&repeater, SIGNAL(timeout()), this, SLOT(autoRepeat())); + repeatDelay=400; + repeatPeriod=80; + connect(&repeater, SIGNAL(timeout()), this, SLOT(autoRepeat())); } @@ -244,7 +248,7 @@ Keymap::Keymap():enabled(true), currentState(0), autoRepeatAction(0), repeater(t Keymap::~Keymap() { - QMap<QString, State*>::Iterator it; - for(it = states.begin(); it != states.end(); ++it) { - delete it.data(); - } - states.clear(); + QMap<QString, State*>::Iterator it; + for(it = states.begin(); it != states.end(); ++it) { + delete it.data(); + } + states.clear(); } @@ -252,55 +256,53 @@ Keymap::~Keymap() { bool Keymap::filter(int unicode, int keycode, int modifiers, - bool isPress, bool autoRepeat) { + bool isPress, bool autoRepeat) { - qDebug("filter: >>> unicode=%x, keycode=%x, modifiers=%x, " - "ispressed=%x\n", unicode, keycode, modifiers, isPress); + odebug << "filter: >>> unicode=" << unicode << ", keycode=" << keycode + << ", modifiers=" << modifiers << ", ispressed=" << isPress << oendl; - if (!enabled) { - return false; - } + if (!enabled) { + return false; + } - // the second check is workaround to make suspend work if - // the user pressed it right after he did resume. for some - // reason the event sent by qt has autoRepeat true in this - // case - if (autoRepeat && keycode != 4177) { - return true; - } + // the second check is workaround to make suspend work if + // the user pressed it right after he did resume. for some + // reason the event sent by qt has autoRepeat true in this + // case + if (autoRepeat && keycode != 4177) { + return true; + } - (void) unicode; (void) modifiers; + (void) unicode; (void) modifiers; - Action* action = currentState->get(keycode, isPress, true); - if (action==0 || !action->isDefined()) { - return true; - } + Action* action = currentState->get(keycode, isPress, true); + if (action==0 || !action->isDefined()) { + return true; + } - if (action->hasEvent()) { - qDebug("filter:<<< unicode=%x, keycode=%x, modifiers=%x, " - "ispressed=%x\n", action->getUnicode(), - action->getKeycode(), action->getModifiers(), - action->isPressed()); + if (action->hasEvent()) { + odebug << "filter:<<< unicode=" << action->getUnicode() << ", keycode=" << action->getKeycode() + << ", modifiers=" << action->getModifiers() << ", ispressed=" << action->isPressed() << oendl; - QWSServer::sendKeyEvent(action->getUnicode(), - action->getKeycode(), action->getModifiers(), - action->isPressed(), false); - } + QWSServer::sendKeyEvent(action->getUnicode(), + action->getKeycode(), action->getModifiers(), + action->isPressed(), false); + } - if (action->isAutorepeat()) { - autoRepeatAction = action; - repeater.start(repeatDelay, TRUE); - } else { - autoRepeatAction = 0; - } + if (action->isAutorepeat()) { + autoRepeatAction = action; + repeater.start(repeatDelay, TRUE); + } else { + autoRepeatAction = 0; + } - State* nstate = action->getState(); - if (nstate != 0) { - setCurrentState(nstate); - QString lbl = getCurrentLabel(); - if (!lbl.isEmpty()) { - emit stateChanged(lbl); - } - } + State* nstate = action->getState(); + if (nstate != 0) { + setCurrentState(nstate); + QString lbl = getCurrentLabel(); + if (!lbl.isEmpty()) { + emit stateChanged(lbl); + } + } - return true; + return true; } @@ -308,3 +310,3 @@ bool Keymap::filter(int unicode, int keycode, int modifiers, void Keymap::enable() { - enabled = true; + enabled = true; } @@ -312,3 +314,3 @@ void Keymap::enable() { void Keymap::disable() { - enabled = false; + enabled = false; } @@ -316,10 +318,10 @@ void Keymap::disable() { QStringList Keymap::listStates() { - QStringList ret; + QStringList ret; - QMap<QString, State*>::Iterator it; - for(it = states.begin(); it != states.end(); ++it) { - ret.append(it.key()); - } + QMap<QString, State*>::Iterator it; + for(it = states.begin(); it != states.end(); ++it) { + ret.append(it.key()); + } - return ret; + return ret; } @@ -327,9 +329,9 @@ QStringList Keymap::listStates() { State* Keymap::getStateByName(const QString& name) { - QMap<QString, State*>::Iterator it = states.find(name); + QMap<QString, State*>::Iterator it = states.find(name); - if (it == states.end()) { - return 0; - } + if (it == states.end()) { + return 0; + } - return it.data(); + return it.data(); } @@ -337,9 +339,9 @@ State* Keymap::getStateByName(const QString& name) { QStringList Keymap::listLabels() { - QStringList ret; + QStringList ret; - for(uint i = 0; i < labelList.count(); i++) { - ret.append(*labelList.at(i)); - } + for(uint i = 0; i < labelList.count(); i++) { + ret.append(*labelList.at(i)); + } - return ret; + return ret; } @@ -347,28 +349,28 @@ QStringList Keymap::listLabels() { State* Keymap::getStateByLabel(const QString& label) { - QMap<QString, QString>::Iterator lit = labels.find(label); - State* state = 0; + QMap<QString, QString>::Iterator lit = labels.find(label); + State* state = 0; - if (lit == labels.end()) { - return 0; - } + if (lit == labels.end()) { + return 0; + } - QString name = lit.data(); + QString name = lit.data(); - int n = name.find(":*"); - if (n>=0 && n==(int)(name.length()-2)) { - name=name.left(name.length() - 1); + int n = name.find(":*"); + if (n>=0 && n==(int)(name.length()-2)) { + name=name.left(name.length() - 1); - n = currentStateName.findRev(":"); - if (n >= 0) { - name += currentStateName.mid(n+1); - } - } + n = currentStateName.findRev(":"); + if (n >= 0) { + name += currentStateName.mid(n+1); + } + } -// odebug << "look for: " << name.utf8() << "\n" << oendl; - QMap<QString, State*>::Iterator sit = states.find(name); - if (sit != states.end()) { - state = sit.data(); - } +// odebug << "look for: " << name.utf8() << "\n" << oendl; + QMap<QString, State*>::Iterator sit = states.find(name); + if (sit != states.end()) { + state = sit.data(); + } - return state; + return state; } @@ -376,14 +378,14 @@ State* Keymap::getStateByLabel(const QString& label) { bool Keymap::addState(const QString& name, State* state) { - if (states.find(name) != states.end()) { - return false; - } + if (states.find(name) != states.end()) { + return false; + } - states.insert(name, state); - lsmapInSync = false; + states.insert(name, state); + lsmapInSync = false; - if (currentState == 0) { - setCurrentState(state); - } + if (currentState == 0) { + setCurrentState(state); + } - return true; + return true; } @@ -391,3 +393,3 @@ bool Keymap::addState(const QString& name, State* state) { State* Keymap::getCurrentState() const { - return currentState; + return currentState; } @@ -395,3 +397,3 @@ State* Keymap::getCurrentState() const { QString Keymap::getCurrentLabel() { - return currentLabel; + return currentLabel; } @@ -399,30 +401,29 @@ QString Keymap::getCurrentLabel() { bool Keymap::setCurrentState(State* state) { - QMap<QString, State*>::Iterator it; - for(it = states.begin(); it != states.end(); ++it) { - State* s = it.data(); - if (s == state) { - currentState = s; - currentStateName = it.key(); + QMap<QString, State*>::Iterator it; + for(it = states.begin(); it != states.end(); ++it) { + State* s = it.data(); + if (s == state) { + currentState = s; + currentStateName = it.key(); - qDebug("state changed: %s\n", (const char*) - currentStateName.utf8()); + odebug << "state changed: " << (const char*)currentStateName.utf8() << oendl; - if (!lsmapInSync) { - generateLabelStateMaps(); - } + if (!lsmapInSync) { + generateLabelStateMaps(); + } - QMap<State*, QString>::Iterator tit; - tit = stateLabelMap.find(state); - if (tit != stateLabelMap.end()) { - currentLabel = tit.data(); - } else { -// odebug << "no label for: " + currentStateName + "\n" << oendl; - currentLabel = ""; - } + QMap<State*, QString>::Iterator tit; + tit = stateLabelMap.find(state); + if (tit != stateLabelMap.end()) { + currentLabel = tit.data(); + } else { +// odebug << "no label for: " + currentStateName + "\n" << oendl; + currentLabel = ""; + } - return true; - } - } + return true; + } + } - return false; + return false; } @@ -430,33 +431,33 @@ bool Keymap::setCurrentState(State* state) { bool Keymap::removeState(const QString& name, bool force) { - QMap<QString, State*>::Iterator it = states.find(name); + QMap<QString, State*>::Iterator it = states.find(name); - if (it == states.end()) { - return false; - } + if (it == states.end()) { + return false; + } - State* state = it.data(); - QList<Action> acts = findStateUsage(state); + State* state = it.data(); + QList<Action> acts = findStateUsage(state); - if (!acts.isEmpty()) { - if (!force) { - return false; - } else { - for(Action* a = acts.first(); a != 0; a = acts.next()) { - a->setState(0); - } - } - } + if (!acts.isEmpty()) { + if (!force) { + return false; + } else { + for(Action* a = acts.first(); a != 0; a = acts.next()) { + a->setState(0); + } + } + } - if (state == currentState) { - if (states.begin() != states.end()) { - setCurrentState(states.begin().data()); - } - } + if (state == currentState) { + if (states.begin() != states.end()) { + setCurrentState(states.begin().data()); + } + } - states.remove(it); - delete state; + states.remove(it); + delete state; - lsmapInSync = false; + lsmapInSync = false; - return true; + return true; } @@ -464,16 +465,15 @@ bool Keymap::removeState(const QString& name, bool force) { void Keymap::autoRepeat() { - if (autoRepeatAction != 0) { - qDebug("filter:<<< unicode=%x, keycode=%x, modifiers=%x, " - "ispressed=%x\n", autoRepeatAction->getUnicode(), - autoRepeatAction->getKeycode(), - autoRepeatAction->getModifiers(), - autoRepeatAction->isPressed()); + if (autoRepeatAction != 0) { + odebug << "filter:<<< unicode=" << autoRepeatAction->getUnicode() + << ", keycode=" << autoRepeatAction->getKeycode() + << ", modifiers=" << autoRepeatAction->getModifiers() + << "ispressed=" << autoRepeatAction->isPressed() << oendl; - QWSServer::sendKeyEvent(autoRepeatAction->getUnicode(), - autoRepeatAction->getKeycode(), - autoRepeatAction->getModifiers(), - autoRepeatAction->isPressed(), true); - } + QWSServer::sendKeyEvent(autoRepeatAction->getUnicode(), + autoRepeatAction->getKeycode(), + autoRepeatAction->getModifiers(), + autoRepeatAction->isPressed(), true); + } - repeater.start(repeatPeriod, TRUE); + repeater.start(repeatPeriod, TRUE); } @@ -481,17 +481,17 @@ void Keymap::autoRepeat() { bool Keymap::addLabel(const QString& label, const QString& state, int index) { - if (labels.find(label) != labels.end()) { - return false; - } + if (labels.find(label) != labels.end()) { + return false; + } - labels.insert(label, state); - const QString& l = labels.find(label).key(); - if (index == -1) { - labelList.append(l); - } else { - labelList.insert(labelList.at(index), l); - } + labels.insert(label, state); + const QString& l = labels.find(label).key(); + if (index == -1) { + labelList.append(l); + } else { + labelList.insert(labelList.at(index), l); + } - lsmapInSync = false; + lsmapInSync = false; - return true; + return true; } @@ -500,15 +500,15 @@ bool Keymap::removeLabel(const QString& label) { - if (labels.find(label) == labels.end()) { - return false; - } + if (labels.find(label) == labels.end()) { + return false; + } - labels.remove(label); - labelList.remove(label); - lsmapInSync = false; + labels.remove(label); + labelList.remove(label); + lsmapInSync = false; - if (label == currentLabel) { - currentLabel = ""; - } + if (label == currentLabel) { + currentLabel = ""; + } - return true; + return true; } @@ -516,3 +516,3 @@ bool Keymap::removeLabel(const QString& label) { int Keymap::getAutorepeatDelay() const { - return repeatDelay; + return repeatDelay; } @@ -520,3 +520,3 @@ int Keymap::getAutorepeatDelay() const { void Keymap::setAutorepeatDelay(int n) { - repeatDelay = n; + repeatDelay = n; } @@ -524,3 +524,3 @@ void Keymap::setAutorepeatDelay(int n) { int Keymap::getAutorepeatPeriod() const { - return repeatPeriod; + return repeatPeriod; } @@ -528,3 +528,3 @@ int Keymap::getAutorepeatPeriod() const { void Keymap::setAutorepeatPeriod(int n) { - repeatPeriod = n; + repeatPeriod = n; } @@ -532,22 +532,22 @@ void Keymap::setAutorepeatPeriod(int n) { QList<Action> Keymap::findStateUsage(State* s) { - QList<Action> ret; + QList<Action> ret; - QMap<QString, State*>::Iterator it; - for(it = states.begin(); it != states.end(); ++it) { - State* state = it.data(); + QMap<QString, State*>::Iterator it; + for(it = states.begin(); it != states.end(); ++it) { + State* state = it.data(); - for(int i = 0; i < 0x1100; i++) { - Action* action = state->get(i, false); - if (action!=0 && action->getState()==s) { - ret.append(action); - } + for(int i = 0; i < 0x1100; i++) { + Action* action = state->get(i, false); + if (action!=0 && action->getState()==s) { + ret.append(action); + } - action = state->get(i, true); - if (action!=0 && action->getState()==s) { - ret.append(action); - } - } - } + action = state->get(i, true); + if (action!=0 && action->getState()==s) { + ret.append(action); + } + } + } - return ret; + return ret; } @@ -555,35 +555,35 @@ QList<Action> Keymap::findStateUsage(State* s) { void Keymap::generateLabelStateMaps() { - stateLabelMap.clear(); - - QMap<QString, QString>::Iterator lit; - for(lit = labels.begin(); lit != labels.end(); ++lit) { - QString label = lit.key(); - QString name = lit.data(); - - bool wc = false; - int n = name.find("*"); - if (n>=0 && n==(int)(name.length()-1)) { - name=name.left(name.length() - 1); - wc = true; - } - - QMap<QString, State*>::Iterator sit; - for(sit = states.begin(); sit != states.end(); ++sit) { - QString sname = sit.key(); - State* state = sit.data(); - - if (sname.length() < name.length()) { - continue; - } - - if (sname.left(name.length()) == name) { - if (wc || sname.length()==name.length()) { - stateLabelMap.insert(state, label); - } - - } - } - } - - lsmapInSync = true; + stateLabelMap.clear(); + + QMap<QString, QString>::Iterator lit; + for(lit = labels.begin(); lit != labels.end(); ++lit) { + QString label = lit.key(); + QString name = lit.data(); + + bool wc = false; + int n = name.find("*"); + if (n>=0 && n==(int)(name.length()-1)) { + name=name.left(name.length() - 1); + wc = true; + } + + QMap<QString, State*>::Iterator sit; + for(sit = states.begin(); sit != states.end(); ++sit) { + QString sname = sit.key(); + State* state = sit.data(); + + if (sname.length() < name.length()) { + continue; + } + + if (sname.left(name.length()) == name) { + if (wc || sname.length()==name.length()) { + stateLabelMap.insert(state, label); + } + + } + } + } + + lsmapInSync = true; } diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp index be2b897..f14080f 100644 --- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp +++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp @@ -423,4 +423,5 @@ void Gutenbrowser::ForwardBtn() { pageStopArray[i_pageNum ] = currentFilePos; - // qDebug("%d current page is number %d, pagesize %d, length %d, current %d", - // currentFilePos, i_pageNum, pageSize, Lview->length(), pageStopArray[i_pageNum] ); + // odebug << currentFilePos << " current page is number " << i_pageNum + // << ", pagesize " << pageSize << ", length " << Lview->length() + // << ", current " << pageStopArray[i_pageNum] << oendl; setStatus(); @@ -457,4 +458,5 @@ void Gutenbrowser::BackBtn() { - // qDebug("%d move back to %d, current page number %d, %d, length %d", - // currentFilePos, pageStopArray[i_pageNum - 1 ], i_pageNum, pageSize, Lview->length() ); + // odebug << currentFilePos << " move back to " << pageStopArray[i_pageNum - 1 ] + // << ", current page number " << i_pageNum + // << ", " << pageSize << ", length " << Lview->length() << oendl; @@ -801,4 +803,5 @@ bool Gutenbrowser::load( const char *fileName) { - qDebug("<<<<<<<<<<<%d current page is number %d, length %d, current %d, pageSize %d", - currentFilePos, i_pageNum, Lview->length(), pageStopArray[i_pageNum], Lview->PageSize() ); + odebug << "<<<<<<<<<<<" << currentFilePos << " current page is number " << i_pageNum + << ", length " << Lview->length() << ", current " << pageStopArray[i_pageNum] + << ", pageSize " << Lview->PageSize() << oendl; diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h index 29d0329..61531c0 100644 --- a/noncore/apps/opie-reader/BuffDoc.h +++ b/noncore/apps/opie-reader/BuffDoc.h @@ -23,20 +23,20 @@ class BuffDoc void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) - { - if (exp == NULL) - { - data = NULL; - len = 0; - } - else - { - exp->setSaveData(data, len, src, srclen); - } - } + { + if (exp == NULL) + { + data = NULL; + len = 0; + } + else + { + exp->setSaveData(data, len, src, srclen); + } + } void putSaveData(unsigned char*& src, unsigned short& srclen) - { - if (exp != NULL) - { - exp->putSaveData(src, srclen); - } - } + { + if (exp != NULL) + { + exp->putSaveData(src, srclen); + } + } #ifdef USEQPE @@ -49,20 +49,20 @@ class BuffDoc ~BuffDoc() - { - delete filt; - delete exp; - } + { + delete filt; + delete exp; + } BuffDoc() - { - exp = NULL; - filt = NULL; - lastword.empty(); -// // qDebug("Buffdoc created"); - } + { + exp = NULL; + filt = NULL; + lastword.empty(); + // odebug << "Buffdoc created" << oendl; + } bool empty() { return (exp == NULL); } void setfilter(CFilterChain* _f) - { - if (filt != NULL) delete filt; - filt = _f; - filt->setsource(exp); - } + { + if (filt != NULL) delete filt; + filt = _f; + filt->setsource(exp); + } CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } @@ -72,20 +72,20 @@ class BuffDoc tchar getch() - { - tchar ch = UEOF; - CStyle sty; - if (exp != NULL) - { - filt->getch(ch, sty); - } - return ch; - } + { + tchar ch = UEOF; + CStyle sty; + if (exp != NULL) + { + filt->getch(ch, sty); + } + return ch; + } void getch(tchar& ch, CStyle& sty) - { - if (exp != NULL) - { - filt->getch(ch, sty); - } - else - ch = UEOF; - } + { + if (exp != NULL) + { + filt->getch(ch, sty); + } + else + ch = UEOF; + } void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } @@ -105,11 +105,11 @@ class BuffDoc int getpara(CBuffer& buff) - { - tchar ch; - int i = 0; - while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; - buff[i] = '\0'; - if (i == 0 && ch == UEOF) i = -1; - laststartline = exp->locate(); - return i; - } + { + tchar ch; + int i = 0; + while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; + buff[i] = '\0'; + if (i == 0 && ch == UEOF) i = -1; + laststartline = exp->locate(); + return i; + } void saveposn(size_t posn) { exp->saveposn(posn); } diff --git a/noncore/apps/opie-reader/CEncoding.h b/noncore/apps/opie-reader/CEncoding.h index 463fba9..df0104a 100644 --- a/noncore/apps/opie-reader/CEncoding.h +++ b/noncore/apps/opie-reader/CEncoding.h @@ -62,11 +62,11 @@ class CGeneral8Bit : public CEncoding CGeneral8Bit(int _i) : m_index(_i) - { -// qDebug("8Bit:%d", _i); -// qDebug("%s", unicodetable::iterator(_i)->mime); - } + { +// odebug << "8Bit: " << _i << oendl; +// odebug << unicodetable::iterator(_i)->mime << oendl; + } void getch(tchar& ch, CStyle& sty) - { - parent->getch(ch, sty); - ch = unicodetable::unicodevalue(m_index, ch); - } + { + parent->getch(ch, sty); + ch = unicodetable::unicodevalue(m_index, ch); + } }; diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index 7b21d3e..9fae245 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h @@ -42,3 +42,3 @@ class CExpander #ifdef USEQPE - virtual void suspend() = 0; + virtual void suspend() = 0; virtual void unsuspend() = 0; @@ -49,7 +49,7 @@ class CExpander int openfile(const char *src) - { - bSuspended = false; - fname = strdup(src); - return OpenFile(src); - } + { + bSuspended = false; + fname = strdup(src); + return OpenFile(src); + } virtual int OpenFile(const char *src) = 0; @@ -61,13 +61,13 @@ class CExpander virtual void getch(tchar& ch, CStyle& sty) - { - int ich = getch(); - ch = (ich == EOF) ? UEOF : ich; - sty.unset(); - } + { + int ich = getch(); + ch = (ich == EOF) ? UEOF : ich; + sty.unset(); + } virtual int getch() = 0; virtual linkType hyperlink(unsigned int n, QString& wrd) - { - locate(n); - return eLink; - } + { + locate(n); + return eLink; + } virtual MarkupType PreferredMarkup() = 0; @@ -79,25 +79,25 @@ class CExpander unsigned long startSection() - { - unsigned long current = locate(); - if (m_currentstart > current || current > m_currentend) - { - start2endSection(); - } - return m_currentstart; - } + { + unsigned long current = locate(); + if (m_currentstart > current || current > m_currentend) + { + start2endSection(); + } + return m_currentstart; + } unsigned long endSection() - { - unsigned long current = locate(); - if (m_currentstart > current || current > m_currentend) - { - start2endSection(); - } - return m_currentend; - } + { + unsigned long current = locate(); + if (m_currentstart > current || current > m_currentend) + { + start2endSection(); + } + return m_currentend; + } virtual void start2endSection() - { - m_currentstart = 0; - unsigned long file; - sizes(file, m_currentend); - } + { + m_currentstart = 0; + unsigned long file; + sizes(file, m_currentend); + } virtual QImage* getPicture(unsigned long tgt) { return NULL; } @@ -107,7 +107,7 @@ class CExpander { - bSuspended = true; - suspos = ftell(fin); - fclose(fin); - fin = NULL; - sustime = time(NULL); + bSuspended = true; + suspos = ftell(fin); + fclose(fin); + fin = NULL; + sustime = time(NULL); } @@ -115,20 +115,20 @@ class CExpander { - if (bSuspended) - { - bSuspended = false; - int delay = time(NULL) - sustime; - if (delay < 10) sleep(10-delay); - fin = fopen(fname, "rb"); - for (int i = 0; fin == NULL && i < 5; i++) - { - sleep(5); - fin = fopen(fname, "rb"); - } - if (fin == NULL) - { - QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); - exit(0); - } - suspos = fseek(fin, suspos, SEEK_SET); - } + if (bSuspended) + { + bSuspended = false; + int delay = time(NULL) - sustime; + if (delay < 10) sleep(10-delay); + fin = fopen(fname, "rb"); + for (int i = 0; fin == NULL && i < 5; i++) + { + sleep(5); + fin = fopen(fname, "rb"); + } + if (fin == NULL) + { + QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); + exit(0); + } + suspos = fseek(fin, suspos, SEEK_SET); + } } @@ -136,14 +136,14 @@ class CExpander virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) - { - len = srclen; - data = new unsigned char[len]; - memcpy(data, src, len); - } + { + len = srclen; + data = new unsigned char[len]; + memcpy(data, src, len); + } virtual void putSaveData(unsigned char*& src, unsigned short& srclen) - { - if (srclen != 0) - { - qDebug("Don't know what to do with non-zero save data"); - } - } + { + if (srclen != 0) + { + qDebug("Don't know what to do with non-zero save data"); + } + } void setwidth(int w) { m_scrWidth = w; } diff --git a/noncore/apps/opie-reader/Filedata.h b/noncore/apps/opie-reader/Filedata.h index 096dd31..1b85b71 100644 --- a/noncore/apps/opie-reader/Filedata.h +++ b/noncore/apps/opie-reader/Filedata.h @@ -11,26 +11,26 @@ class CFiledata CFiledata(tchar* d) - { - data = (unsigned char*)d; - m_own = false; - } + { + data = (unsigned char*)d; + m_own = false; + } CFiledata(time_t dt, tchar* nm) - { - int nlen = ustrlen(nm)+1; - data = new unsigned char[sizeof(time_t)+sizeof(tchar)*nlen]; - *((time_t *)data) = dt; - memcpy(data+sizeof(time_t), nm, sizeof(tchar)*nlen); - m_own = true; - } + { + int nlen = ustrlen(nm)+1; + data = new unsigned char[sizeof(time_t)+sizeof(tchar)*nlen]; + *((time_t *)data) = dt; + memcpy(data+sizeof(time_t), nm, sizeof(tchar)*nlen); + m_own = true; + } ~CFiledata() - { - if (m_own && data != NULL) - { - delete [] data; -// qDebug("~Filedata: deleting"); - } - else - { -// qDebug("~Filedata: not deleting"); - } - } + { + if (m_own && data != NULL) + { + delete [] data; +// odebug << "~Filedata: deleting" << oendl; + } + else + { +// odebug << "~Filedata: not deleting" << oendl; + } + } tchar* name() const { return (tchar*)(data+sizeof(time_t)); } @@ -41,9 +41,9 @@ class CFiledata bool operator==(const CFiledata& rhs) - { - return ((length() == rhs.length()) && (memcmp(data, rhs.data, length()) == 0)); - } + { + return ((length() == rhs.length()) && (memcmp(data, rhs.data, length()) == 0)); + } bool samename(const CFiledata& rhs) - { - return (ustrcmp((tchar *)(data+sizeof(time_t)),(tchar *)(rhs.data+sizeof(time_t))) == 0); - } + { + return (ustrcmp((tchar *)(data+sizeof(time_t)),(tchar *)(rhs.data+sizeof(time_t))) == 0); + } }; diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h index 5681496..e56b619 100644 --- a/noncore/apps/opie-reader/FontControl.h +++ b/noncore/apps/opie-reader/FontControl.h @@ -22,16 +22,16 @@ class FontControl FontControl(QString n = "helvetica", int size = 10) - : - m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0) + : + m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0) { - ChangeFont(n, size); + ChangeFont(n, size); } ~FontControl() - { - if (m_fontsizes != NULL) delete [] m_fontsizes; - } + { + if (m_fontsizes != NULL) delete [] m_fontsizes; + } void hasCourier(bool _b, const QString& _nm) - { - m_hasCourier = _b; - m_fixedfontname = _nm; - } + { + m_hasCourier = _b; + m_fixedfontname = _nm; + } QString& fixedfontname() { return m_fixedfontname; } @@ -41,19 +41,19 @@ class FontControl int getsize(const CStyle& size) - { - int tgt = m_size+size.getFontSize(); - if (tgt < 0) - { - tgt = 0; - } - if (tgt >= m_maxsize) - { - tgt = m_maxsize - 1; - } - return m_fontsizes[tgt]; - } + { + int tgt = m_size+size.getFontSize(); + if (tgt < 0) + { + tgt = 0; + } + if (tgt >= m_maxsize) + { + tgt = m_maxsize - 1; + } + return m_fontsizes[tgt]; + } int ascent() { - QFont f(name(), currentsize()); - QFontMetrics fm(f); - return fm.ascent(); + QFont f(name(), currentsize()); + QFontMetrics fm(f); + return fm.ascent(); } @@ -61,5 +61,5 @@ class FontControl { - QFont f(name(), getsize(ch)); - QFontMetrics fm(f); - return fm.ascent(); + QFont f(name(), getsize(ch)); + QFontMetrics fm(f); + return fm.ascent(); } @@ -67,5 +67,5 @@ class FontControl { - QFont f(name(), currentsize()); - QFontMetrics fm(f); - return fm.descent(); + QFont f(name(), currentsize()); + QFontMetrics fm(f); + return fm.descent(); } @@ -73,5 +73,5 @@ class FontControl { - QFont f(name(), getsize(ch)); - QFontMetrics fm(f); - return fm.descent(); + QFont f(name(), getsize(ch)); + QFontMetrics fm(f); + return fm.descent(); } @@ -79,5 +79,5 @@ class FontControl { - QFont f(name(), currentsize()); - QFontMetrics fm(f); - return fm.lineSpacing(); + QFont f(name(), currentsize()); + QFontMetrics fm(f); + return fm.lineSpacing(); } @@ -85,67 +85,67 @@ class FontControl { - QFont f(name(), getsize(ch)); - QFontMetrics fm(f); - return fm.lineSpacing(); + QFont f(name(), getsize(ch)); + QFontMetrics fm(f); + return fm.lineSpacing(); } bool decreasesize() - { + { /* - if (--m_size < 0) - { - m_size = 0; - return false; - } - else return true; + if (--m_size < 0) + { + m_size = 0; + return false; + } + else return true; */ - if (g_size-- == m_size) - { - if (--m_size < 0) - { - m_size = 0; - } - } -// qDebug("Font:%d Graphics:%d", m_size, g_size); - return true; - } + if (g_size-- == m_size) + { + if (--m_size < 0) + { + m_size = 0; + } + } +// odebug << "Font:" << m_size << " Graphics:" << g_size << oendl; + return true; + } bool increasesize() - { + { /* - if (++m_size >= m_maxsize) - { - m_size = m_maxsize - 1; - return false; - } - else return true; + if (++m_size >= m_maxsize) + { + m_size = m_maxsize - 1; + return false; + } + else return true; */ - if (g_size++ == m_size) - { - if (++m_size >= m_maxsize) - { - m_size = m_maxsize - 1; - } - } -// qDebug("Font:%d Graphics:%d", m_size, g_size); - return true; - } + if (g_size++ == m_size) + { + if (++m_size >= m_maxsize) + { + m_size = m_maxsize - 1; + } + } +// odebug << "Font:" << m_size << " Graphics:" << g_size << oendl; + return true; + } bool ChangeFont(QString& n) - { - return ChangeFont(n, currentsize()); - } + { + return ChangeFont(n, currentsize()); + } bool ChangeFont(QString& n, int tgt); void setlead(int _lead) - { - m_leading = _lead; - } + { + m_leading = _lead; + } int getlead() - { - return m_leading; - } + { + return m_leading; + } void setextraspace(int _lead) - { - m_extraspace = _lead; - } + { + m_extraspace = _lead; + } int getextraspace() - { - return m_extraspace; - } + { + return m_extraspace; + } }; diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp index 9339595..b0d4e00 100644 --- a/noncore/apps/opie-reader/Palm2QImage.cpp +++ b/noncore/apps/opie-reader/Palm2QImage.cpp @@ -1,2 +1,10 @@ /* -*- mode: c; indent-tabs-mode: nil; -*- */ + +/* OPIE */ +#include <opie2/odebug.h> + +/* QT */ +#include <qimage.h> + +/* STD */ #include <stdio.h> @@ -11,3 +19,2 @@ -#include <qimage.h> @@ -44,6 +51,6 @@ typedef struct { static ColorMapEntry Palm8BitColormap[] = { - { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, - { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, - { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, - { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, + { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, + { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, + { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, + { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, @@ -141,5 +148,7 @@ QImage* Palm2QImage /* bytes 14 and 15 are reserved by Palm and always 0 */ - + #if 0 -// qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); +// odebug << "Palm image is " << width << "x" << height +// << ", " << bits_per_pixel << " bpp, version " << version +// << ", flags 0x" << flags << ", compression " << compression_type << oendl; #endif @@ -147,3 +156,3 @@ QImage* Palm2QImage if (compression_type == PALM_COMPRESSION_PACKBITS) { -// qDebug ("Image uses packbits compression; not yet supported"); +// odebug << "Image uses packbits compression; not yet supported" << oendl; return NULL; @@ -152,3 +161,3 @@ QImage* Palm2QImage (compression_type != PALM_COMPRESSION_SCANLINE)) { -// qDebug ("Image uses unknown compression, code 0x%x", compression_type); +// odebug << "Image uses unknown compression, code 0x" << compression_type << oendl; return NULL; @@ -157,3 +166,3 @@ QImage* Palm2QImage /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: - + 1, 2, or 4 bit grayscale @@ -162,6 +171,6 @@ QImage* Palm2QImage 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue - + Each of these can be compressed with one of four compression schemes, "RLE", "Scanline", "PackBits", or none. - + We begin by constructing the colormap. @@ -170,3 +179,3 @@ QImage* Palm2QImage if (flags & PALM_HAS_COLORMAP_FLAG) { -// qDebug("Palm images with custom colormaps are not currently supported.\n"); +// odebug << "Palm images with custom colormaps are not currently supported." << oendl; return NULL; @@ -189,5 +198,6 @@ QImage* Palm2QImage palm_blue_bits = palmimage[18]; -// qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); +// odebug << "Bits:" << palm_red_bits << ", " << palm_green_bits << ", " << palm_blue_bits << oendl; if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { -// qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); +// odebug << "Can't handle this format DirectColor image -- too wide in some color (" +// << palm_red_bits << ":" << palm_green_bits << ":" << palm_blue_bits << oendl; return NULL; @@ -195,3 +205,4 @@ QImage* Palm2QImage if (bits_per_pixel > (8 * sizeof(unsigned long))) { -// qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); +// odebug << "Can't handle this format DirectColor image -- too many bits per pixel (" +// << bits_per_pixel << ")" << oendl; return NULL; @@ -200,3 +211,3 @@ QImage* Palm2QImage } else { -// qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); +// odebug << "Unknown bits-per-pixel of " << bits_per_pixel << " encountered" << oendl; return NULL; @@ -215,3 +226,4 @@ QImage* Palm2QImage for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { -// qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); +// odebug << "inval:" << inval << " palm_ptr:" << palm_ptr << " x_ptr:" << x_ptr +// << " bpr:" << bytes_per_row << oendl; @@ -220,6 +232,6 @@ QImage* Palm2QImage for (j = 0; j < bytes_per_row; ) { - incount = *palm_ptr++; - inval = *palm_ptr++; - memset(rowbuf + j, inval, incount); - j += incount; + incount = *palm_ptr++; + inval = *palm_ptr++; + memset(rowbuf + j, inval, incount); + j += incount; } @@ -227,10 +239,10 @@ QImage* Palm2QImage for (j = 0; j < bytes_per_row; j += 8) { - incount = *palm_ptr++; - inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; - for (inbit = 0; inbit < inval; inbit += 1) { - if (incount & (1 << (7 - inbit))) - rowbuf[j + inbit] = *palm_ptr++; - else - rowbuf[j + inbit] = lastrow[j + inbit]; - } + incount = *palm_ptr++; + inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; + for (inbit = 0; inbit < inval; inbit += 1) { + if (incount & (1 << (7 - inbit))) + rowbuf[j + inbit] = *palm_ptr++; + else + rowbuf[j + inbit] = lastrow[j + inbit]; + } } @@ -245,8 +257,8 @@ QImage* Palm2QImage else { - qDebug("Case 4"); - qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); - qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); - qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); - qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); - qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); + odebug << "Case 4" << oendl; + odebug << "Is compressed:" << (((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true") << oendl; + odebug << "Has colourmap:" << (((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true") << oendl; + odebug << "Has transparency:" << (((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true") << oendl; + odebug << "Direct colour:" << (((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true") << oendl; + odebug << "four byte field:" << (((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true") << oendl; memcpy (rowbuf, palm_ptr, bytes_per_row); @@ -258,14 +270,14 @@ QImage* Palm2QImage for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { - inval = ((*inbyte) & (mask << inbit)) >> inbit; - /* correct for oddity of the 8-bit color Palm pixmap... */ - if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; - /* now lookup the correct color and set the pixel in the GTK bitmap */ - QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); + inval = ((*inbyte) & (mask << inbit)) >> inbit; + /* correct for oddity of the 8-bit color Palm pixmap... */ + if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; + /* now lookup the correct color and set the pixel in the GTK bitmap */ + QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); qimage->setPixel(j, i, colour); - if (!inbit) { - ++inbyte; - inbit = 8 - bits_per_pixel; - } else { - inbit -= bits_per_pixel; - } + if (!inbit) { + ++inbyte; + inbit = 8 - bits_per_pixel; + } else { + inbit -= bits_per_pixel; + } } @@ -274,13 +286,12 @@ QImage* Palm2QImage for (inbyte = rowbuf, j = 0; j < width; ++j) { - inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; + inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; /* - qDebug ("pixel is %d,%d (%d:%d:%d)", - j, i, - ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), - ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), - ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); + odebug << "pixel is " << j << "," << i << " (" + << (((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits)) << ":" + << (((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits)) << ":" + << (((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)) << ")" << oendl; */ - QRgb colour = qRgb( - ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), + QRgb colour = qRgb( + ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), @@ -288,3 +299,3 @@ QImage* Palm2QImage qimage->setPixel(j, i, colour); - inbyte += 2; + inbyte += 2; } @@ -301,3 +312,3 @@ QImage* hRule(int w, int h, unsigned char r, unsigned char g, unsigned char b) { -//// qDebug("hrule [%d, %d]", w, h); +// odebug << "hrule [" << w << ", " << h << "]" << oendl; QPixmap* qimage = new QPixmap(w, h); diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index dfbdfb9..f89de63 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h @@ -23,4 +23,4 @@ class QTReader : public QWidget - static tchar pluckernextpart[]; - static tchar jplucknextpart[]; + static tchar pluckernextpart[]; + static tchar jplucknextpart[]; friend class QTReaderApp; @@ -61,9 +61,9 @@ public: void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) - { - buffdoc.setSaveData(data, len, src, srclen); - } + { + buffdoc.setSaveData(data, len, src, srclen); + } void putSaveData(unsigned char*& src, unsigned short& srclen) - { - buffdoc.putSaveData(src, srclen); - } + { + buffdoc.putSaveData(src, srclen); + } bool empty(); @@ -77,3 +77,3 @@ public: size_t nd = locate(); - jumpto(m_mark); + jumpto(m_mark); QString text; @@ -93,11 +93,11 @@ public: { - if (oldfile) - { - m_string = m_lastfile; - load_file((const tchar*)m_string); - } - else - { - m_string = QString::null; - } + if (oldfile) + { + m_string = m_lastfile; + load_file((const tchar*)m_string); + } + else + { + m_string = QString::null; + } }; @@ -105,20 +105,20 @@ public: void setlead(int _lead) - { - m_fontControl.setlead(_lead); - } + { + m_fontControl.setlead(_lead); + } int getlead() - { - return m_fontControl.getlead(); - } + { + return m_fontControl.getlead(); + } void setextraspace(int _lead) - { - m_fontControl.setextraspace(_lead); - } + { + m_fontControl.setextraspace(_lead); + } int getextraspace() - { - return m_fontControl.getextraspace(); - } + { + return m_fontControl.getextraspace(); + } void setpagemode(bool _b) { - m_bpagemode = _b; + m_bpagemode = _b; } @@ -126,36 +126,36 @@ public: { - m_bMonoSpaced = _b; - ChangeFont(m_fontControl.currentsize()); - locate(pagelocate()); + m_bMonoSpaced = _b; + ChangeFont(m_fontControl.currentsize()); + locate(pagelocate()); } void setencoding(int _f) - { - m_encd = _f; - setfilter(getfilter()); - } + { + m_encd = _f; + setfilter(getfilter()); + } MarkupType PreferredMarkup(); CEncoding* getencoding() - { -// qDebug("m_encd:%d", m_encd); - switch (m_encd) - { - case 4: -// qDebug("palm"); - return new CPalm; - case 1: -// qDebug("utf8"); - return new CUtf8; - case 2: -// qDebug("ucs16be"); - return new CUcs16be; - case 3: -// qDebug("ucs16le"); - return new CUcs16le; - case 0: -// qDebug("ascii"); - return new CAscii; - default: - return new CGeneral8Bit(m_encd-MAX_ENCODING+1); - } - } + { +// odebug << "m_encd:" << m_encd << oendl; + switch (m_encd) + { + case 4: +// odebug << "palm" << oendl; + return new CPalm; + case 1: +// odebug << "utf8" << oendl; + return new CUtf8; + case 2: +// odebug << "ucs16be" << oendl; + return new CUcs16be; + case 3: +// odebug << "ucs16le" << oendl; + return new CUcs16le; + case 0: +// odebug << "ascii" << oendl; + return new CAscii; + default: + return new CGeneral8Bit(m_encd-MAX_ENCODING+1); + } + } CFilterChain* getfilter() @@ -191,3 +191,3 @@ private slots: void goForward(); - void doscroll(); + void doscroll(); void drawIt( QPainter * ); diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h index ab6f60e..fe3eebf 100644 --- a/noncore/apps/opie-reader/QTReaderApp.h +++ b/noncore/apps/opie-reader/QTReaderApp.h @@ -45,5 +45,5 @@ class QPopupMenu; class QToolBar; -#ifdef USEQPE
+#ifdef USEQPE class QToolBar; -class QMenuBar;
+class QMenuBar; #endif @@ -142,3 +142,3 @@ class QTReaderApp : public QMainWindow - unsigned long m_savedpos; + unsigned long m_savedpos; int m_debounce; @@ -151,3 +151,3 @@ class QTReaderApp : public QMainWindow - public: + public: QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); @@ -157,5 +157,5 @@ class QTReaderApp : public QMainWindow void hideEvent(QHideEvent*) - { - suspend(); - } + { + suspend(); + } @@ -173,13 +173,13 @@ class QTReaderApp : public QMainWindow void closeEvent( QCloseEvent *e ); - void readbkmks(); - void do_mono(const QString&); - void do_jump(const QString&); - void do_settarget(const QString&); + void readbkmks(); + void do_mono(const QString&); + void do_jump(const QString&); + void do_settarget(const QString&); #ifdef _SCROLLPIPE -// void do_setpipetarget(const QString&); +// void do_setpipetarget(const QString&); #endif - void do_saveconfig(const QString&, bool); - bool readconfig(const QString&, bool); - bool PopulateConfig(const char*); - ActionTypes ActNameToInt(const QString&); + void do_saveconfig(const QString&, bool); + bool readconfig(const QString&, bool); + bool PopulateConfig(const char*); + ActionTypes ActNameToInt(const QString&); bool m_doAnnotation; @@ -190,3 +190,3 @@ class QTReaderApp : public QMainWindow public: - void saveprefs(); + void saveprefs(); public slots: @@ -209,13 +209,13 @@ private slots: void OnAnnotation(bool _b) - { - m_doAnnotation = _b; - } + { + m_doAnnotation = _b; + } void OnDictionary(bool _b) - { - m_doDictionary = _b; - } + { + m_doDictionary = _b; + } void OnClipboard(bool _b) - { - m_doClipboard = _b; - } + { + m_doClipboard = _b; + } void OnWordSelected(const QString&, size_t, const QString&); @@ -228,26 +228,26 @@ private slots: void do_setencoding(int i); - void do_setfont(const QString&); - void buttonActionSelected(QAction*); -// void msgHandler(const QCString&, const QByteArray&); - void monospace(bool); - void jump(); - void settarget(); + void do_setfont(const QString&); + void buttonActionSelected(QAction*); +// void msgHandler(const QCString&, const QByteArray&); + void monospace(bool); + void jump(); + void settarget(); #ifdef _SCROLLPIPE -// void setpipetarget(); -// void setpause(bool); +// void setpipetarget(); +// void setpause(bool); #endif -// void setspacing(); - void setfont(); - void clearBkmkList(); - void listBkmkFiles(); - void editMark(); - void autoScroll(bool); - void addbkmk(); - void savebkmks(); -// void importFiles(); - void showprefs(); - void showtoolbarprefs(); - void infoClose(); - // void oldFile(); - void showinfo(); +// void setspacing(); + void setfont(); + void clearBkmkList(); + void listBkmkFiles(); + void editMark(); + void autoScroll(bool); + void addbkmk(); + void savebkmks(); +// void importFiles(); + void showprefs(); + void showtoolbarprefs(); + void infoClose(); + // void oldFile(); + void showinfo(); @@ -369,3 +369,3 @@ private slots: ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, - m_upTarget, m_downTarget; + m_upTarget, m_downTarget; bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; @@ -384,7 +384,7 @@ private slots: QToolBar *menubar, *fileBar, *navBar, *viewBar, *markBar; -#ifdef USEQPE
- QMenuBar *mb;
-#else
- QMenuBar *mb;
-#endif
+#ifdef USEQPE + QMenuBar *mb; +#else + QMenuBar *mb; +#endif QFloatBar *searchBar, *regBar/*, *m_fontBar*/; @@ -401,4 +401,4 @@ private slots: { -// qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); -// qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); +// odebug << "resize:(" << r->oldSize().width() << "," << r->oldSize().height() << ")" << oendl; +// odebug << "resize:(" << r->size().width() << "," << r->size().height() << ")" << oendl; // bgroup->move( width()-bgroup->width(), 0 ); diff --git a/noncore/apps/tinykate/libkate/document/katedocument.h b/noncore/apps/tinykate/libkate/document/katedocument.h index 9d8ec6a..969be87 100644 --- a/noncore/apps/tinykate/libkate/document/katedocument.h +++ b/noncore/apps/tinykate/libkate/document/katedocument.h @@ -8,3 +8,3 @@ jowenn@kde.org - + ***************************************************************************/ @@ -78,3 +78,3 @@ public: if (!wa) { - // qDebug("create row: %d",row); + // odebug << "create row: " << row << oendl; wa=warray[row]=new short[256]; @@ -181,3 +181,3 @@ class KateDocument: public Kate::Document void remove_Line(int line,bool update=true); - void replaceLine(const QString& s,int line=-1); + void replaceLine(const QString& s,int line=-1); virtual void insertAt( const QString &s, int line, int col, bool mark = FALSE ); @@ -536,4 +536,4 @@ class KateDocument: public Kate::Document }; - - + + // BCI: Add a real d-pointer in the next BIC release @@ -544,3 +544,3 @@ static void cleanup_d_ptr() } - + KateDocPrivate* d( const KateDocument* foo ) @@ -558,3 +558,3 @@ KateDocPrivate* d( const KateDocument* foo ) } - + void delete_d( const KateDocument* foo ) diff --git a/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp b/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp index a2c680f..78635b2 100644 --- a/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp +++ b/noncore/apps/tinykate/libkate/qt3back/qregexp3.cpp @@ -40,7 +40,2 @@ -#include "qarray.h" -#include "qbitarray.h" -#include "qcache.h" -#include "qintdict.h" -#include "qmap.h" #if QT_VERSION < 300 @@ -50,6 +45,17 @@ #endif -#include "qstring.h" -#include "qtl.h" -#include "qvector.h" +/* OPIE */ +#include <opie2/odebug.h> + +/* QT */ +#include <qarray.h> +#include <qbitarray.h> +#include <qcache.h> +#include <qintdict.h> +#include <qmap.h> +#include <qstring.h> +#include <qtl.h> +#include <qvector.h> + +/* STD */ #include <limits.h> @@ -517,6 +523,6 @@ \code - QRegExp rx( "^\\d\\d?$" ); // Match integers 0 to 99 - rx.search( "123" ); // Returns -1 (no match) - rx.search( "-6" ); // Returns -1 (no match) - rx.search( "6" ); // Returns 0 (matched as position 0) + QRegExp rx( "^\\d\\d?$" ); // Match integers 0 to 99 + rx.search( "123" ); // Returns -1 (no match) + rx.search( "-6" ); // Returns -1 (no match) + rx.search( "6" ); // Returns 0 (matched as position 0) \endcode @@ -527,5 +533,5 @@ \code - QRegExp rx( "^\\S+$" ); // Match strings which have no whitespace - rx.search( "Hello world" ); // Returns -1 (no match) - rx.search( "This_is-OK" ); // Returns 0 (matched at position 0) + QRegExp rx( "^\\S+$" ); // Match strings which have no whitespace + rx.search( "Hello world" ); // Returns -1 (no match) + rx.search( "This_is-OK" ); // Returns 0 (matched at position 0) \endcode @@ -542,3 +548,3 @@ QRegExp rx( "\\b(mail|letter|correspondence)\\b" ); - rx.search( "I sent you an email" ); // Returns -1 (no match) + rx.search( "I sent you an email" ); // Returns -1 (no match) rx.search( "Please write the letter" ); // Returns 17 (matched at position 17) @@ -560,3 +566,3 @@ \code - QRegExp rx( "&(?!amp;)" ); // Match ampersands but not & + QRegExp rx( "&(?!amp;)" ); // Match ampersands but not & QString line1 = "This & that"; @@ -574,3 +580,3 @@ QString str = "One Eric another Eirik, and an Ericsson. How many Eiriks, Eric?"; - QRegExp rx( "\\b(Eric|Eirik)\\b" ); // Match Eric or Eirik + QRegExp rx( "\\b(Eric|Eirik)\\b" ); // Match Eric or Eirik int pos = 0; // Where we are in the string @@ -578,7 +584,7 @@ while ( pos >= 0 ) { - pos = rx.search( str, pos ); - if ( pos >= 0 ) { - pos++; // Move along in str - count++; // Count our Eric or Eirik - } + pos = rx.search( str, pos ); + if ( pos >= 0 ) { + pos++; // Move along in str + count++; // Count our Eric or Eirik + } } @@ -603,5 +609,5 @@ if ( rx.search( str ) != -1 ) { - company = rx.cap( 1 ); - web = rx.cap( 2 ); - country = rx.cap( 3 ); + company = rx.cap( 1 ); + web = rx.cap( 2 ); + country = rx.cap( 3 ); } @@ -626,7 +632,7 @@ \code - QRegExp rx( "*.html" ); // Invalid regexp: * doesn't quantify anything - rx.setWildcard( TRUE ); // Now its a valid wildcard regexp - rx.search( "index.html" ); // Returns 0 (matched at position 0) - rx.search( "default.htm" ); // Returns -1 (no match) - rx.search( "readme.txt" ); // Returns -1 (no match) + QRegExp rx( "*.html" ); // Invalid regexp: * doesn't quantify anything + rx.setWildcard( TRUE ); // Now its a valid wildcard regexp + rx.search( "index.html" ); // Returns 0 (matched at position 0) + rx.search( "default.htm" ); // Returns -1 (no match) + rx.search( "readme.txt" ); // Returns -1 (no match) \endcode @@ -678,32 +684,32 @@ static void mergeInto( QArray<int> *a, const QArray<int>& b ) if ( asize == 0 ) { - *a = b.copy(); + *a = b.copy(); #ifndef QT_NO_REGEXP_OPTIM } else if ( bsize == 1 && (*a)[asize - 1] < b[0] ) { - a->resize( asize + 1 ); - (*a)[asize] = b[0]; + a->resize( asize + 1 ); + (*a)[asize] = b[0]; #endif } else if ( bsize >= 1 ) { - int csize = asize + bsize; - QArray<int> c( csize ); - int i = 0, j = 0, k = 0; - while ( i < asize ) { - if ( j < bsize ) { - if ( (*a)[i] == b[j] ) { - i++; - csize--; - } else if ( (*a)[i] < b[j] ) { - c[k++] = (*a)[i++]; - } else { - c[k++] = b[j++]; - } - } else { - memcpy( c.data() + k, (*a).data() + i, - (asize - i) * sizeof(int) ); - break; - } - } - c.resize( csize ); - if ( j < bsize ) - memcpy( c.data() + k, b.data() + j, (bsize - j) * sizeof(int) ); - *a = c; + int csize = asize + bsize; + QArray<int> c( csize ); + int i = 0, j = 0, k = 0; + while ( i < asize ) { + if ( j < bsize ) { + if ( (*a)[i] == b[j] ) { + i++; + csize--; + } else if ( (*a)[i] < b[j] ) { + c[k++] = (*a)[i++]; + } else { + c[k++] = b[j++]; + } + } else { + memcpy( c.data() + k, (*a).data() + i, + (asize - i) * sizeof(int) ); + break; + } + } + c.resize( csize ); + if ( j < bsize ) + memcpy( c.data() + k, b.data() + j, (bsize - j) * sizeof(int) ); + *a = c; } @@ -719,3 +725,3 @@ static void mergeInto( QMap<int, int> *a, const QMap<int, int>& b ) for ( it = b.begin(); it != b.end(); ++it ) - a->insert( it.key(), *it ); + a->insert( it.key(), *it ); } @@ -730,5 +736,5 @@ static int at( const QMap<int, int>& m, int k ) if ( it == m.end() ) - return 0; + return 0; else - return *it; + return *it; } @@ -746,40 +752,40 @@ static QString wc2rx( const QString& wc ) while ( i < wclen ) { - QChar c = wc[i++]; - switch ( c.unicode() ) { - case '*': - rx += QString::fromLatin1( ".*" ); - break; - case '?': - rx += QChar( '.' ); - break; - case '$': - case '(': - case ')': - case '+': - case '.': - case '\\': - case '^': - case '{': - case '|': - case '}': - rx += QChar( '\\' ); - rx += c; - break; - case '[': - rx += c; - if ( wc[i] == QChar('^') ) - rx += wc[i++]; - if ( i < wclen ) { - if ( rx[i] == ']' ) - rx += wc[i++]; - while ( i < wclen && wc[i] != QChar(']') ) { - if ( wc[i] == '\\' ) - rx += QChar( '\\' ); - rx += wc[i++]; - } - } - break; - default: - rx += c; - } + QChar c = wc[i++]; + switch ( c.unicode() ) { + case '*': + rx += QString::fromLatin1( ".*" ); + break; + case '?': + rx += QChar( '.' ); + break; + case '$': + case '(': + case ')': + case '+': + case '.': + case '\\': + case '^': + case '{': + case '|': + case '}': + rx += QChar( '\\' ); + rx += c; + break; + case '[': + rx += c; + if ( wc[i] == QChar('^') ) + rx += wc[i++]; + if ( i < wclen ) { + if ( rx[i] == ']' ) + rx += wc[i++]; + while ( i < wclen && wc[i] != QChar(']') ) { + if ( wc[i] == '\\' ) + rx += QChar( '\\' ); + rx += wc[i++]; + } + } + break; + default: + rx += c; + } } @@ -804,17 +810,17 @@ public: public: - CharClass(); - CharClass( const CharClass& cc ) { operator=( cc ); } + CharClass(); + CharClass( const CharClass& cc ) { operator=( cc ); } - CharClass& operator=( const CharClass& cc ); + CharClass& operator=( const CharClass& cc ); - void clear(); - bool negative() const { return n; } - void setNegative( bool negative ); - void addCategories( int cats ); - void addRange( ushort from, ushort to ); - void addSingleton( ushort ch ) { addRange( ch, ch ); } + void clear(); + bool negative() const { return n; } + void setNegative( bool negative ); + void addCategories( int cats ); + void addRange( ushort from, ushort to ); + void addSingleton( ushort ch ) { addRange( ch, ch ); } - bool in( QChar ch ) const; + bool in( QChar ch ) const; #ifndef QT_NO_REGEXP_OPTIM - const QArray<int>& firstOccurrence() const { return occ1; } + const QArray<int>& firstOccurrence() const { return occ1; } #endif @@ -822,3 +828,3 @@ public: #if defined(QT_DEBUG) - void dump() const; + void dump() const; #endif @@ -826,17 +832,17 @@ public: private: - /* - The struct Range represents a range of characters (e.g., [0-9] denotes - range 48 to 57). - */ - struct Range - { - ushort from; // 48 - ushort to; // 57 - }; - - int c; // character classes - QArray<Range> r; // character ranges - bool n; // negative? + /* + The struct Range represents a range of characters (e.g., [0-9] denotes + range 48 to 57). + */ + struct Range + { + ushort from; // 48 + ushort to; // 57 + }; + + int c; // character classes + QArray<Range> r; // character ranges + bool n; // negative? #ifndef QT_NO_REGEXP_OPTIM - QArray<int> occ1; // first-occurrence array + QArray<int> occ1; // first-occurrence array #endif @@ -846,8 +852,8 @@ public: { - int x; // dummy + int x; // dummy #ifndef QT_NO_REGEXP_OPTIM - const QArray<int>& firstOccurrence() const { - return *firstOccurrenceAtZero; - } + const QArray<int>& firstOccurrence() const { + return *firstOccurrenceAtZero; + } #endif @@ -866,3 +872,3 @@ public: QArray<int> match( const QString& str, int pos, bool minimal, - bool oneTest ); + bool oneTest ); int matchedLength() const { return mmMatchedLen; } @@ -878,3 +884,3 @@ public: void addPlusTransitions( const QArray<int>& from, const QArray<int>& to, - int atom ); + int atom ); #endif @@ -892,3 +898,3 @@ public: void setupGoodStringHeuristic( int earlyStart, int lateStart, - const QString& str ); + const QString& str ); void setupBadCharHeuristic( int minLen, const QArray<int>& firstOcc ); @@ -912,17 +918,17 @@ private: #ifndef QT_NO_REGEXP_CAPTURE - int atom; // which atom does this state belong to? + int atom; // which atom does this state belong to? #endif - int match; // what does it match? (see CharClassBit and BackRefBit) - QArray<int> outs; // out-transitions - QMap<int, int> *reenter; // atoms reentered when transiting out - QMap<int, int> *anchors; // anchors met when transiting out + int match; // what does it match? (see CharClassBit and BackRefBit) + QArray<int> outs; // out-transitions + QMap<int, int> *reenter; // atoms reentered when transiting out + QMap<int, int> *anchors; // anchors met when transiting out #ifndef QT_NO_REGEXP_CAPTURE - State( int a, int m ) - : atom( a ), match( m ), reenter( 0 ), anchors( 0 ) { } + State( int a, int m ) + : atom( a ), match( m ), reenter( 0 ), anchors( 0 ) { } #else - State( int m ) - : match( m ), reenter( 0 ), anchors( 0 ) { } + State( int m ) + : match( m ), reenter( 0 ), anchors( 0 ) { } #endif - ~State() { delete reenter; delete anchors; } + ~State() { delete reenter; delete anchors; } }; @@ -936,8 +942,8 @@ private: { - QRegExpEngine *eng; // NFA representing the embedded regular expression - bool neg; // negative lookahead? + QRegExpEngine *eng; // NFA representing the embedded regular expression + bool neg; // negative lookahead? - Lookahead( QRegExpEngine *eng0, bool neg0 ) - : eng( eng0 ), neg( neg0 ) { } - ~Lookahead() { delete eng; } + Lookahead( QRegExpEngine *eng0, bool neg0 ) + : eng( eng0 ), neg( neg0 ) { } + ~Lookahead() { delete eng; } }; @@ -952,4 +958,4 @@ private: { - int parent; // index of parent in array of atoms - int capture; // index of capture, from 1 to ncap + int parent; // index of parent in array of atoms + int capture; // index of capture, from 1 to ncap }; @@ -964,4 +970,4 @@ private: { - int a; // this anchor... - int b; // ...or this one + int a; // this anchor... + int b; // ...or this one }; @@ -978,10 +984,10 @@ private: enum { Anchor_Dollar = 0x00000001, Anchor_Caret = 0x00000002, - Anchor_Word = 0x00000004, Anchor_NonWord = 0x00000008, - Anchor_FirstLookahead = 0x00000010, - Anchor_BackRef1Empty = Anchor_FirstLookahead << MaxLookaheads, - Anchor_BackRef0Empty = Anchor_BackRef1Empty >> 1, - Anchor_Alternation = Anchor_BackRef1Empty << MaxBackRefs, - - Anchor_LookaheadMask = ( Anchor_FirstLookahead - 1 ) ^ - ( (Anchor_FirstLookahead << MaxLookaheads) - 1 ) }; + Anchor_Word = 0x00000004, Anchor_NonWord = 0x00000008, + Anchor_FirstLookahead = 0x00000010, + Anchor_BackRef1Empty = Anchor_FirstLookahead << MaxLookaheads, + Anchor_BackRef0Empty = Anchor_BackRef1Empty >> 1, + Anchor_Alternation = Anchor_BackRef1Empty << MaxBackRefs, + + Anchor_LookaheadMask = ( Anchor_FirstLookahead - 1 ) ^ + ( (Anchor_FirstLookahead << MaxLookaheads) - 1 ) }; #ifndef QT_NO_REGEXP_CAPTURE @@ -997,3 +1003,3 @@ private: bool isBetterCapture( const int *begin1, const int *end1, const int *begin2, - const int *end2 ); + const int *end2 ); #endif @@ -1057,21 +1063,21 @@ private: public: - Box( QRegExpEngine *engine ); - Box( const Box& b ) { operator=( b ); } + Box( QRegExpEngine *engine ); + Box( const Box& b ) { operator=( b ); } - Box& operator=( const Box& b ); + Box& operator=( const Box& b ); - void clear() { operator=(Box(eng)); } - void set( QChar ch ); - void set( const CharClass& cc ); + void clear() { operator=(Box(eng)); } + void set( QChar ch ); + void set( const CharClass& cc ); #ifndef QT_NO_REGEXP_BACKREF - void set( int bref ); + void set( int bref ); #endif - void cat( const Box& b ); - void orx( const Box& b ); - void plus( int atom ); - void opt(); - void catAnchor( int a ); + void cat( const Box& b ); + void orx( const Box& b ); + void plus( int atom ); + void opt(); + void catAnchor( int a ); #ifndef QT_NO_REGEXP_OPTIM - void setupHeuristics(); + void setupHeuristics(); #endif @@ -1079,3 +1085,3 @@ private: #if defined(QT_DEBUG) - void dump() const; + void dump() const; #endif @@ -1083,23 +1089,23 @@ private: private: - void addAnchorsToEngine( const Box& to ) const; + void addAnchorsToEngine( const Box& to ) const; - QRegExpEngine *eng; // the automaton under construction - QArray<int> ls; // the left states (firstpos) - QArray<int> rs; // the right states (lastpos) - QMap<int, int> lanchors; // the left anchors - QMap<int, int> ranchors; // the right anchors - int skipanchors; // the anchors to match if the box is skipped + QRegExpEngine *eng; // the automaton under construction + QArray<int> ls; // the left states (firstpos) + QArray<int> rs; // the right states (lastpos) + QMap<int, int> lanchors; // the left anchors + QMap<int, int> ranchors; // the right anchors + int skipanchors; // the anchors to match if the box is skipped #ifndef QT_NO_REGEXP_OPTIM - int earlyStart; // the index where str can first occur - int lateStart; // the index where str can last occur - QString str; // a string that has to occur in any match - QString leftStr; // a string occurring at the left of this box - QString rightStr; // a string occurring at the right of this box - int maxl; // the maximum length of this box (possibly InftyLen) + int earlyStart; // the index where str can first occur + int lateStart; // the index where str can last occur + QString str; // a string that has to occur in any match + QString leftStr; // a string occurring at the left of this box + QString rightStr; // a string occurring at the right of this box + int maxl; // the maximum length of this box (possibly InftyLen) #endif - int minl; // the minimum length of this box + int minl; // the minimum length of this box #ifndef QT_NO_REGEXP_OPTIM - QArray<int> occ1; // first-occurrence array + QArray<int> occ1; // first-occurrence array #endif @@ -1112,5 +1118,5 @@ private: enum { Tok_Eos, Tok_Dollar, Tok_LeftParen, Tok_MagicLeftParen, - Tok_PosLookahead, Tok_NegLookahead, Tok_RightParen, Tok_CharClass, - Tok_Caret, Tok_Quantifier, Tok_Bar, Tok_Word, Tok_NonWord, - Tok_Char = 0x10000, Tok_BackRef = 0x20000 }; + Tok_PosLookahead, Tok_NegLookahead, Tok_RightParen, Tok_CharClass, + Tok_Caret, Tok_Quantifier, Tok_Bar, Tok_Word, Tok_NonWord, + Tok_Char = 0x10000, Tok_BackRef = 0x20000 }; int getChar(); @@ -1191,6 +1197,6 @@ QRegExpEngine::~QRegExpEngine() if ( --engCount == 0 ) { - delete noOccurrences; - noOccurrences = 0; - delete firstOccurrenceAtZero; - firstOccurrenceAtZero = 0; + delete noOccurrences; + noOccurrences = 0; + delete firstOccurrenceAtZero; + firstOccurrenceAtZero = 0; } @@ -1204,3 +1210,3 @@ QRegExpEngine::~QRegExpEngine() QArray<int> QRegExpEngine::match( const QString& str, int pos, bool minimal, - bool oneTest ) + bool oneTest ) { @@ -1209,3 +1215,3 @@ QArray<int> QRegExpEngine::match( const QString& str, int pos, bool minimal, if ( mmIn == 0 ) - mmIn = &QChar::null; + mmIn = &QChar::null; mmPos = pos; @@ -1218,12 +1224,12 @@ QArray<int> QRegExpEngine::match( const QString& str, int pos, bool minimal, #ifndef QT_NO_REGEXP_OPTIM - if ( mmPos <= mmLen - minl ) { - if ( caretAnchored || oneTest ) - matched = matchHere(); - else if ( useGoodStringHeuristic ) - matched = goodStringMatch(); - else - matched = badCharMatch(); - } + if ( mmPos <= mmLen - minl ) { + if ( caretAnchored || oneTest ) + matched = matchHere(); + else if ( useGoodStringHeuristic ) + matched = goodStringMatch(); + else + matched = badCharMatch(); + } #else - matched = oneTest ? matchHere() : bruteMatch(); + matched = oneTest ? matchHere() : bruteMatch(); #endif @@ -1232,13 +1238,13 @@ QArray<int> QRegExpEngine::match( const QString& str, int pos, bool minimal, if ( matched ) { - mmCaptured.detach(); - mmCaptured[0] = mmPos; - mmCaptured[1] = mmMatchedLen; - for ( int j = 0; j < realncap; j++ ) { - int len = mmCapEnd[j] - mmCapBegin[j]; - mmCaptured[2 + 2 * j] = len > 0 ? mmPos + mmCapBegin[j] : 0; - mmCaptured[2 + 2 * j + 1] = len; - } - return mmCaptured; + mmCaptured.detach(); + mmCaptured[0] = mmPos; + mmCaptured[1] = mmMatchedLen; + for ( int j = 0; j < realncap; j++ ) { + int len = mmCapEnd[j] - mmCapBegin[j]; + mmCaptured[2 + 2 * j] = len > 0 ? mmPos + mmCapBegin[j] : 0; + mmCaptured[2 + 2 * j + 1] = len; + } + return mmCaptured; } else { - return mmCapturedNoMatch; + return mmCapturedNoMatch; } @@ -1273,7 +1279,7 @@ int QRegExpEngine::createState( int bref ) if ( bref > nbrefs ) { - nbrefs = bref; - if ( nbrefs > MaxBackRefs ) { - yyError = TRUE; - return 0; - } + nbrefs = bref; + if ( nbrefs > MaxBackRefs ) { + yyError = TRUE; + return 0; + } } @@ -1291,7 +1297,7 @@ int QRegExpEngine::createState( int bref ) void QRegExpEngine::addCatTransitions( const QArray<int>& from, - const QArray<int>& to ) + const QArray<int>& to ) { for ( int i = 0; i < (int) from.size(); i++ ) { - State *st = s[from[i]]; - mergeInto( &st->outs, to ); + State *st = s[from[i]]; + mergeInto( &st->outs, to ); } @@ -1301,17 +1307,17 @@ void QRegExpEngine::addCatTransitions( const QArray<int>& from, void QRegExpEngine::addPlusTransitions( const QArray<int>& from, - const QArray<int>& to, int atom ) + const QArray<int>& to, int atom ) { for ( int i = 0; i < (int) from.size(); i++ ) { - State *st = s[from[i]]; - QArray<int> oldOuts = st->outs.copy(); - mergeInto( &st->outs, to ); - if ( f[atom].capture >= 0 ) { - if ( st->reenter == 0 ) - st->reenter = new QMap<int, int>; - for ( int j = 0; j < (int) to.size(); j++ ) { - if ( !st->reenter->contains(to[j]) && - oldOuts.bsearch(to[j]) < 0 ) - st->reenter->insert( to[j], atom ); - } - } + State *st = s[from[i]]; + QArray<int> oldOuts = st->outs.copy(); + mergeInto( &st->outs, to ); + if ( f[atom].capture >= 0 ) { + if ( st->reenter == 0 ) + st->reenter = new QMap<int, int>; + for ( int j = 0; j < (int) to.size(); j++ ) { + if ( !st->reenter->contains(to[j]) && + oldOuts.bsearch(to[j]) < 0 ) + st->reenter->insert( to[j], atom ); + } + } } @@ -1327,3 +1333,3 @@ int QRegExpEngine::anchorAlternation( int a, int b ) if ( ((a & b) == a || (a & b) == b) && ((a | b) & Anchor_Alternation) == 0 ) - return a & b; + return a & b; @@ -1342,5 +1348,5 @@ int QRegExpEngine::anchorConcatenation( int a, int b ) if ( ((a | b) & Anchor_Alternation) == 0 ) - return a | b; + return a | b; if ( (b & Anchor_Alternation) != 0 ) - qSwap( a, b ); + qSwap( a, b ); int aprime = anchorConcatenation( aa[a ^ Anchor_Alternation].a, b ); @@ -1358,5 +1364,5 @@ void QRegExpEngine::addAnchors( int from, int to, int a ) if ( st->anchors == 0 ) - st->anchors = new QMap<int, int>; + st->anchors = new QMap<int, int>; if ( st->anchors->contains(to) ) - a = anchorAlternation( (*st->anchors)[to], a ); + a = anchorAlternation( (*st->anchors)[to], a ); st->anchors->insert( to, a ); @@ -1371,3 +1377,3 @@ void QRegExpEngine::addAnchors( int from, int to, int a ) void QRegExpEngine::setupGoodStringHeuristic( int earlyStart, int lateStart, - const QString& str ) + const QString& str ) { @@ -1379,3 +1385,3 @@ void QRegExpEngine::setupGoodStringHeuristic( int earlyStart, int lateStart, void QRegExpEngine::setupBadCharHeuristic( int minLen, - const QArray<int>& firstOcc ) + const QArray<int>& firstOcc ) { @@ -1402,3 +1408,3 @@ void QRegExpEngine::heuristicallyChooseHeuristic() if ( minl == 0 ) - return; + return; @@ -1409,3 +1415,3 @@ void QRegExpEngine::heuristicallyChooseHeuristic() int goodStringScore = ( 64 * goodStr.length() / minl ) - - ( goodLateStart - goodEarlyStart ); + ( goodLateStart - goodEarlyStart ); @@ -1418,6 +1424,6 @@ void QRegExpEngine::heuristicallyChooseHeuristic() for ( i = 1; i < NumBadChars; i += step ) { - if ( occ1[i] == NoOccurrence ) - badCharScore += minl; - else - badCharScore += occ1[i]; + if ( occ1[i] == NoOccurrence ) + badCharScore += minl; + else + badCharScore += occ1[i]; } @@ -1433,34 +1439,35 @@ void QRegExpEngine::dump() const int i, j; - qDebug( "Case %ssensitive engine", cs ? "" : "in" ); - qDebug( " States" ); + odebug << "Case " << (cs ? "" : "in") << "sensitive engine" << oendl; + odebug << " States" << oendl; for ( i = 0; i < ns; i++ ) { - qDebug( " %d%s", i, - i == InitialState ? " (initial)" : - i == FinalState ? " (final)" : "" ); + odebug << " " << i + << (i == InitialState ? " (initial)" : i == FinalState ? " (final)" : "") << oendl; + #ifndef QT_NO_REGEXP_CAPTURE - qDebug( " in atom %d", s[i]->atom ); + odebug << " in atom " << s[i]->atom << oendl; #endif - int m = s[i]->match; - if ( (m & CharClassBit) != 0 ) { - qDebug( " match character class %d", m ^ CharClassBit ); + int m = s[i]->match; + if ( (m & CharClassBit) != 0 ) { + odebug << " match character class " << (m ^ CharClassBit) << oendl; #ifndef QT_NO_REGEXP_CCLASS - cl[m ^ CharClassBit]->dump(); + cl[m ^ CharClassBit]->dump(); #else - qDebug( " negative character class" ); -#endif - } else if ( (m & BackRefBit) != 0 ) { - qDebug( " match back-reference %d", m ^ BackRefBit ); - } else if ( m >= 0x20 && m <= 0x7e ) { - qDebug( " match 0x%.4x (%c)", m, m ); - } else { - qDebug( " match 0x%.4x", m ); - } - for ( j = 0; j < (int) s[i]->outs.size(); j++ ) { - int next = s[i]->outs[j]; - qDebug( " -> %d", next ); - if ( s[i]->reenter != 0 && s[i]->reenter->contains(next) ) - qDebug( " [reenter %d]", (*s[i]->reenter)[next] ); - if ( s[i]->anchors != 0 && at(*s[i]->anchors, next) != 0 ) - qDebug( " [anchors 0x%.8x]", (*s[i]->anchors)[next] ); - } + odebug << " negative character class" << oendl; +#endif + } else if ( (m & BackRefBit) != 0 ) { + odebug << " match back-reference " << (m ^ BackRefBit) << oendl; + } else if ( m >= 0x20 && m <= 0x7e ) { + odebug << " match " << QString().sprintf( "0x%.4x", m) << " (" << m << ")" << oendl; + + } else { + odebug << " match " << QString().sprintf( "0x%.4x", m) << oendl; + } + for ( j = 0; j < (int) s[i]->outs.size(); j++ ) { + int next = s[i]->outs[j]; + odebug << " -> " << next << oendl; + if ( s[i]->reenter != 0 && s[i]->reenter->contains(next) ) + odebug << " [reenter " << (*s[i]->reenter)[next] << "]" << oendl; + if ( s[i]->anchors != 0 && at(*s[i]->anchors, next) != 0 ) + odebug << " [anchors " << QString().sprintf( "0x%.8x]", (*s[i]->anchors)[next] ) << oendl; + } } @@ -1468,5 +1475,5 @@ void QRegExpEngine::dump() const if ( nf > 0 ) { - qDebug( " Atom Parent Capture" ); - for ( i = 0; i < nf; i++ ) - qDebug( " %6d %6d %6d", i, f[i].parent, f[i].capture ); + odebug << " Atom Parent Capture" << oendl; + for ( i = 0; i < nf; i++ ) + odebug << QString().sprintf(" %6d %6d %6d", i, f[i].parent, f[i].capture ) << oendl; } @@ -1475,4 +1482,3 @@ void QRegExpEngine::dump() const for ( i = 0; i < (int) aa.size(); i++ ) - qDebug( " Anchor alternation 0x%.8x: 0x%.8x 0x%.9x", i, aa[i].a, - aa[i].b ); + odebug << QString().sprintf(" Anchor alternation 0x%.8x: 0x%.8x 0x%.9x", i, aa[i].a, aa[i].b ) << oendl; #endif @@ -1485,6 +1491,6 @@ void QRegExpEngine::setup( bool caseSensitive ) if ( engCount++ == 0 ) { - noOccurrences = new QArray<int>( NumBadChars ); - firstOccurrenceAtZero = new QArray<int>( NumBadChars ); - noOccurrences->fill( NoOccurrence ); - firstOccurrenceAtZero->fill( 0 ); + noOccurrences = new QArray<int>( NumBadChars ); + firstOccurrenceAtZero = new QArray<int>( NumBadChars ); + noOccurrences->fill( NoOccurrence ); + firstOccurrenceAtZero->fill( 0 ); } @@ -1526,3 +1532,3 @@ int QRegExpEngine::setupState( int match ) if ( (ns & (ns + 1)) == 0 && ns + 1 >= (int) s.size() ) - s.resize( (ns + 1) << 1 ); + s.resize( (ns + 1) << 1 ); #ifndef QT_NO_REGEXP_CAPTURE @@ -1544,3 +1550,3 @@ int QRegExpEngine::startAtom( bool capture ) if ( (nf & (nf + 1)) == 0 && nf + 1 >= (int) f.size() ) - f.resize( (nf + 1) << 1 ); + f.resize( (nf + 1) << 1 ); f[nf].parent = cf; @@ -1560,4 +1566,4 @@ int QRegExpEngine::addLookahead( QRegExpEngine *eng, bool negative ) if ( n == MaxLookaheads ) { - yyError = TRUE; - return 0; + yyError = TRUE; + return 0; } @@ -1574,11 +1580,11 @@ int QRegExpEngine::addLookahead( QRegExpEngine *eng, bool negative ) bool QRegExpEngine::isBetterCapture( const int *begin1, const int *end1, - const int *begin2, const int *end2 ) + const int *begin2, const int *end2 ) { for ( int i = 0; i < ncap; i++ ) { - int delta = begin2[i] - begin1[i]; // it has to start early... - if ( delta == 0 ) - delta = end1[i] - end2[i]; // ...and end late (like a party) + int delta = begin2[i] - begin1[i]; // it has to start early... + if ( delta == 0 ) + delta = end1[i] - end2[i]; // ...and end late (like a party) - if ( delta != 0 ) - return delta > 0; + if ( delta != 0 ) + return delta > 0; } @@ -1598,4 +1604,4 @@ bool QRegExpEngine::testAnchor( int i, int a, const int *capBegin ) if ( (a & Anchor_Alternation) != 0 ) { - return testAnchor( i, aa[a ^ Anchor_Alternation].a, capBegin ) || - testAnchor( i, aa[a ^ Anchor_Alternation].b, capBegin ); + return testAnchor( i, aa[a ^ Anchor_Alternation].a, capBegin ) || + testAnchor( i, aa[a ^ Anchor_Alternation].b, capBegin ); } @@ -1604,8 +1610,8 @@ bool QRegExpEngine::testAnchor( int i, int a, const int *capBegin ) if ( (a & Anchor_Caret) != 0 ) { - if ( mmPos + i != 0 ) - return FALSE; + if ( mmPos + i != 0 ) + return FALSE; } if ( (a & Anchor_Dollar) != 0 ) { - if ( mmPos + i != mmLen ) - return FALSE; + if ( mmPos + i != mmLen ) + return FALSE; } @@ -1613,11 +1619,11 @@ bool QRegExpEngine::testAnchor( int i, int a, const int *capBegin ) if ( (a & (Anchor_Word | Anchor_NonWord)) != 0 ) { - bool before = FALSE, after = FALSE; - if ( mmPos + i != 0 ) - before = mmIn[mmPos + i - 1].isLetterOrNumber(); - if ( mmPos + i != mmLen ) - after = mmIn[mmPos + i].isLetterOrNumber(); - if ( (a & Anchor_Word) != 0 && (before == after) ) - return FALSE; - if ( (a & Anchor_NonWord) != 0 && (before != after) ) - return FALSE; + bool before = FALSE, after = FALSE; + if ( mmPos + i != 0 ) + before = mmIn[mmPos + i - 1].isLetterOrNumber(); + if ( mmPos + i != mmLen ) + after = mmIn[mmPos + i].isLetterOrNumber(); + if ( (a & Anchor_Word) != 0 && (before == after) ) + return FALSE; + if ( (a & Anchor_NonWord) != 0 && (before != after) ) + return FALSE; } @@ -1628,12 +1634,12 @@ bool QRegExpEngine::testAnchor( int i, int a, const int *capBegin ) if ( (a & Anchor_LookaheadMask) != 0 ) { - QConstString cstr = QConstString( (QChar *) mmIn + mmPos + i, - mmLen - mmPos - i ); - for ( j = 0; j < (int) ahead.size(); j++ ) { - if ( (a & (Anchor_FirstLookahead << j)) != 0 ) { - catchx = ( ahead[j]->eng->match(cstr.string(), 0, TRUE, - TRUE)[0] == 0 ); - if ( catchx == ahead[j]->neg ) - return FALSE; - } - } + QConstString cstr = QConstString( (QChar *) mmIn + mmPos + i, + mmLen - mmPos - i ); + for ( j = 0; j < (int) ahead.size(); j++ ) { + if ( (a & (Anchor_FirstLookahead << j)) != 0 ) { + catchx = ( ahead[j]->eng->match(cstr.string(), 0, TRUE, + TRUE)[0] == 0 ); + if ( catchx == ahead[j]->neg ) + return FALSE; + } + } } @@ -1643,6 +1649,6 @@ bool QRegExpEngine::testAnchor( int i, int a, const int *capBegin ) for ( j = 0; j < nbrefs; j++ ) { - if ( (a & (Anchor_BackRef1Empty << j)) != 0 ) { - if ( capBegin[j] != EmptyCapture ) - return FALSE; - } + if ( (a & (Anchor_BackRef1Empty << j)) != 0 ) { + if ( capBegin[j] != EmptyCapture ) + return FALSE; + } } @@ -1665,13 +1671,13 @@ bool QRegExpEngine::goodStringMatch() while ( (k = mmStr->find(goodStr, k, cs)) != -1 ) { - int from = k - goodLateStart; - int to = k - goodEarlyStart; - if ( from > mmPos ) - mmPos = from; - - while ( mmPos <= to ) { - if ( matchHere() ) - return TRUE; - mmPos++; - } - k++; + int from = k - goodLateStart; + int to = k - goodEarlyStart; + if ( from > mmPos ) + mmPos = from; + + while ( mmPos <= to ) { + if ( matchHere() ) + return TRUE; + mmPos++; + } + k++; } @@ -1693,14 +1699,14 @@ bool QRegExpEngine::badCharMatch() for ( i = 0; i < minl; i++ ) { - int sk = occ1[BadChar(mmIn[mmPos + i])]; - if ( sk == NoOccurrence ) - sk = i + 1; - if ( sk > 0 ) { - int k = i + 1 - sk; - if ( k < 0 ) { - sk = i + 1; - k = 0; - } - if ( sk > mmSlideTab[k] ) - mmSlideTab[k] = sk; - } + int sk = occ1[BadChar(mmIn[mmPos + i])]; + if ( sk == NoOccurrence ) + sk = i + 1; + if ( sk > 0 ) { + int k = i + 1 - sk; + if ( k < 0 ) { + sk = i + 1; + k = 0; + } + if ( sk > mmSlideTab[k] ) + mmSlideTab[k] = sk; + } } @@ -1708,35 +1714,35 @@ bool QRegExpEngine::badCharMatch() if ( mmPos > lastPos ) - return FALSE; + return FALSE; while ( TRUE ) { - if ( ++slideNext >= mmSlideTabSize ) - slideNext = 0; - if ( mmSlideTab[slideHead] > 0 ) { - if ( mmSlideTab[slideHead] - 1 > mmSlideTab[slideNext] ) - mmSlideTab[slideNext] = mmSlideTab[slideHead] - 1; - mmSlideTab[slideHead] = 0; - } else { - if ( matchHere() ) - return TRUE; - } - - if ( mmPos == lastPos ) - break; - - /* - Update the slide table. This code has much in common with the - initialization code. - */ - int sk = occ1[BadChar(mmIn[mmPos + minl])]; - if ( sk == NoOccurrence ) { - mmSlideTab[slideNext] = minl; - } else if ( sk > 0 ) { - int k = slideNext + minl - sk; - if ( k >= mmSlideTabSize ) - k -= mmSlideTabSize; - if ( sk > mmSlideTab[k] ) - mmSlideTab[k] = sk; - } - slideHead = slideNext; - mmPos++; + if ( ++slideNext >= mmSlideTabSize ) + slideNext = 0; + if ( mmSlideTab[slideHead] > 0 ) { + if ( mmSlideTab[slideHead] - 1 > mmSlideTab[slideNext] ) + mmSlideTab[slideNext] = mmSlideTab[slideHead] - 1; + mmSlideTab[slideHead] = 0; + } else { + if ( matchHere() ) + return TRUE; + } + + if ( mmPos == lastPos ) + break; + + /* + Update the slide table. This code has much in common with the + initialization code. + */ + int sk = occ1[BadChar(mmIn[mmPos + minl])]; + if ( sk == NoOccurrence ) { + mmSlideTab[slideNext] = minl; + } else if ( sk > 0 ) { + int k = slideNext + minl - sk; + if ( k >= mmSlideTabSize ) + k -= mmSlideTabSize; + if ( sk > mmSlideTab[k] ) + mmSlideTab[k] = sk; + } + slideHead = slideNext; + mmPos++; } @@ -1748,5 +1754,5 @@ bool QRegExpEngine::bruteMatch() while ( mmPos <= mmLen ) { - if ( matchHere() ) - return TRUE; - mmPos++; + if ( matchHere() ) + return TRUE; + mmPos++; } @@ -1770,6 +1776,6 @@ bool QRegExpEngine::matchHere() if ( ncap > 0 ) { - for ( j = 0; j < ncap; j++ ) { - mmCurCapBegin[j] = EmptyCapture; - mmCurCapEnd[j] = EmptyCapture; - } + for ( j = 0; j < ncap; j++ ) { + mmCurCapBegin[j] = EmptyCapture; + mmCurCapEnd[j] = EmptyCapture; + } } @@ -1781,3 +1787,3 @@ bool QRegExpEngine::matchHere() while ( (ncur > 0 || mmSleeping.count() > 0) && i <= mmLen - mmPos && - !match ) + !match ) #else @@ -1786,302 +1792,302 @@ bool QRegExpEngine::matchHere() { - int ch = ( i < mmLen - mmPos ) ? mmIn[mmPos + i].unicode() : 0; - for ( j = 0; j < ncur; j++ ) { - int cur = mmCurStack[j]; - State *scur = s[cur]; - QArray<int>& outs = scur->outs; - for ( k = 0; k < (int) outs.size(); k++ ) { - int next = outs[k]; - State *snext = s[next]; - bool in = TRUE; + int ch = ( i < mmLen - mmPos ) ? mmIn[mmPos + i].unicode() : 0; + for ( j = 0; j < ncur; j++ ) { + int cur = mmCurStack[j]; + State *scur = s[cur]; + QArray<int>& outs = scur->outs; + for ( k = 0; k < (int) outs.size(); k++ ) { + int next = outs[k]; + State *snext = s[next]; + bool in = TRUE; #ifndef QT_NO_REGEXP_BACKREF - int needSomeSleep = 0; -#endif - - /* - First, check if the anchors are anchored properly. - */ - if ( scur->anchors != 0 ) { - int a = at( *scur->anchors, next ); - if ( a != 0 && !testAnchor(i, a, mmCurCapBegin + j * ncap) ) - in = FALSE; - } - /* - If indeed they are, check if the input character is correct - for this transition. - */ - if ( in ) { - m = snext->match; - if ( (m & (CharClassBit | BackRefBit)) == 0 ) { - if ( cs ) - in = ( m == ch ); - else - in = ( QChar(m).lower() == QChar(ch).lower() ); - } else if ( next == FinalState ) { - mmMatchedLen = i; - match = mmMinimal; - in = TRUE; - } else if ( (m & CharClassBit) != 0 ) { + int needSomeSleep = 0; +#endif + + /* + First, check if the anchors are anchored properly. + */ + if ( scur->anchors != 0 ) { + int a = at( *scur->anchors, next ); + if ( a != 0 && !testAnchor(i, a, mmCurCapBegin + j * ncap) ) + in = FALSE; + } + /* + If indeed they are, check if the input character is correct + for this transition. + */ + if ( in ) { + m = snext->match; + if ( (m & (CharClassBit | BackRefBit)) == 0 ) { + if ( cs ) + in = ( m == ch ); + else + in = ( QChar(m).lower() == QChar(ch).lower() ); + } else if ( next == FinalState ) { + mmMatchedLen = i; + match = mmMinimal; + in = TRUE; + } else if ( (m & CharClassBit) != 0 ) { #ifndef QT_NO_REGEXP_CCLASS - const CharClass *cc = cl[m ^ CharClassBit]; - if ( cs ) - in = cc->in( ch ); - else if ( cc->negative() ) - in = cc->in( QChar(ch).lower() ) && - cc->in( QChar(ch).upper() ); - else - in = cc->in( QChar(ch).lower() ) || - cc->in( QChar(ch).upper() ); + const CharClass *cc = cl[m ^ CharClassBit]; + if ( cs ) + in = cc->in( ch ); + else if ( cc->negative() ) + in = cc->in( QChar(ch).lower() ) && + cc->in( QChar(ch).upper() ); + else + in = cc->in( QChar(ch).lower() ) || + cc->in( QChar(ch).upper() ); #endif #ifndef QT_NO_REGEXP_BACKREF - } else { /* ( (m & BackRefBit) != 0 ) */ - int bref = m ^ BackRefBit; - int ell = j * ncap + ( bref - 1 ); - - in = bref <= ncap && mmCurCapBegin[ell] != EmptyCapture; - if ( in ) { - if ( cs ) - in = ( mmIn[mmPos + mmCurCapBegin[ell]] - == QChar(ch) ); - else - in = ( mmIn[mmPos + mmCurCapBegin[ell]].lower() - == QChar(ch).lower() ); - } - - if ( in ) { - int delta; - if ( mmCurCapEnd[ell] == EmptyCapture ) - delta = i - mmCurCapBegin[ell]; - else - delta = mmCurCapEnd[ell] - mmCurCapBegin[ell]; - - in = ( delta <= mmLen - mmPos ); - if ( in && delta > 1 ) { - int n; - if ( cs ) { - for ( n = 1; n < delta; n++ ) { - if ( mmIn[mmPos + - mmCurCapBegin[ell] + n] != - mmIn[mmPos + i + n] ) - break; - } - } else { - for ( n = 1; n < delta; n++ ) { - QChar a = mmIn[mmPos + - mmCurCapBegin[ell] + n]; - QChar b = mmIn[mmPos + i + n]; - if ( a.lower() != b.lower() ) - break; - } - } - in = ( n == delta ); - if ( in ) - needSomeSleep = delta - 1; - } - } -#endif - } - } - - /* - All is right. We must now update our data structures. - */ - if ( in ) { + } else { /* ( (m & BackRefBit) != 0 ) */ + int bref = m ^ BackRefBit; + int ell = j * ncap + ( bref - 1 ); + + in = bref <= ncap && mmCurCapBegin[ell] != EmptyCapture; + if ( in ) { + if ( cs ) + in = ( mmIn[mmPos + mmCurCapBegin[ell]] + == QChar(ch) ); + else + in = ( mmIn[mmPos + mmCurCapBegin[ell]].lower() + == QChar(ch).lower() ); + } + + if ( in ) { + int delta; + if ( mmCurCapEnd[ell] == EmptyCapture ) + delta = i - mmCurCapBegin[ell]; + else + delta = mmCurCapEnd[ell] - mmCurCapBegin[ell]; + + in = ( delta <= mmLen - mmPos ); + if ( in && delta > 1 ) { + int n; + if ( cs ) { + for ( n = 1; n < delta; n++ ) { + if ( mmIn[mmPos + + mmCurCapBegin[ell] + n] != + mmIn[mmPos + i + n] ) + break; + } + } else { + for ( n = 1; n < delta; n++ ) { + QChar a = mmIn[mmPos + + mmCurCapBegin[ell] + n]; + QChar b = mmIn[mmPos + i + n]; + if ( a.lower() != b.lower() ) + break; + } + } + in = ( n == delta ); + if ( in ) + needSomeSleep = delta - 1; + } + } +#endif + } + } + + /* + All is right. We must now update our data structures. + */ + if ( in ) { #ifndef QT_NO_REGEXP_CAPTURE - int *capBegin, *capEnd; -#endif - /* - If the next state was not encountered yet, all is fine. - */ - if ( (m = mmInNextStack[next]) == -1 ) { - m = nnext++; - mmNextStack[m] = next; - mmInNextStack[next] = m; + int *capBegin, *capEnd; +#endif + /* + If the next state was not encountered yet, all is fine. + */ + if ( (m = mmInNextStack[next]) == -1 ) { + m = nnext++; + mmNextStack[m] = next; + mmInNextStack[next] = m; #ifndef QT_NO_REGEXP_CAPTURE - capBegin = mmNextCapBegin + m * ncap; - capEnd = mmNextCapEnd + m * ncap; + capBegin = mmNextCapBegin + m * ncap; + capEnd = mmNextCapEnd + m * ncap; - /* - Otherwise, we'll first maintain captures in temporary - arrays, and decide at the end whether it's best to keep - the previous capture zones or the new ones. - */ - } else { - capBegin = mmTempCapBegin; - capEnd = mmTempCapEnd; + /* + Otherwise, we'll first maintain captures in temporary + arrays, and decide at the end whether it's best to keep + the previous capture zones or the new ones. + */ + } else { + capBegin = mmTempCapBegin; + capEnd = mmTempCapEnd; #endif - } + } #ifndef QT_NO_REGEXP_CAPTURE - /* - Updating the capture zones is much of a task. - */ - if ( ncap > 0 ) { - memcpy( capBegin, mmCurCapBegin + j * ncap, - ncap * sizeof(int) ); - memcpy( capEnd, mmCurCapEnd + j * ncap, - ncap * sizeof(int) ); - int c = scur->atom, n = snext->atom; - int p = -1, q = -1; - int cap; - - /* - Lemma 1. For any x in the range [0..nf), we have - f[x].parent < x. - - Proof. By looking at startAtom(), it is clear that - cf < nf holds all the time, and thus that - f[nf].parent < nf. - */ - - /* - If we are reentering an atom, we empty all capture - zones inside it. - */ - if ( scur->reenter != 0 && - (q = at(*scur->reenter, next)) != 0 ) { - QBitArray b; - b.fill( FALSE, nf ); - b.setBit( q, TRUE ); - for ( int ell = q + 1; ell < nf; ell++ ) { - if ( b.testBit(f[ell].parent) ) { - b.setBit( ell, TRUE ); - cap = f[ell].capture; - if ( cap >= 0 ) { - capBegin[cap] = EmptyCapture; - capEnd[cap] = EmptyCapture; - } - } - } - p = f[q].parent; - - /* - Otherwise, close the capture zones we are leaving. - We are leaving f[c].capture, f[f[c].parent].capture, - f[f[f[c].parent].parent].capture, ..., until - f[x].capture, with x such that f[x].parent is the - youngest common ancestor for c and n. - - We go up along c's and n's ancestry until we find x. - */ - } else { - p = c; - q = n; - while ( p != q ) { - if ( p > q ) { - cap = f[p].capture; - if ( cap >= 0 ) { - if ( capBegin[cap] == i ) { - capBegin[cap] = EmptyCapture; - capEnd[cap] = EmptyCapture; - } else { - capEnd[cap] = i; - } - } - p = f[p].parent; - } else { - q = f[q].parent; - } - } - } - - /* - In any case, we now open the capture zones we are - entering. We work upwards from n until we reach p - (the parent of the atom we reenter or the youngest - common ancestor). - */ - while ( n > p ) { - cap = f[n].capture; - if ( cap >= 0 ) { - capBegin[cap] = i; - capEnd[cap] = EmptyCapture; - } - n = f[n].parent; - } - /* - If the next state was already in mmNextStack, we must - choose carefully which capture zones we want to keep. - */ - if ( capBegin == mmTempCapBegin && - isBetterCapture(capBegin, capEnd, - mmNextCapBegin + m * ncap, - mmNextCapEnd + m * ncap) ) { - memcpy( mmNextCapBegin + m * ncap, capBegin, - ncap * sizeof(int) ); - memcpy( mmNextCapEnd + m * ncap, capEnd, - ncap * sizeof(int) ); - } - } + /* + Updating the capture zones is much of a task. + */ + if ( ncap > 0 ) { + memcpy( capBegin, mmCurCapBegin + j * ncap, + ncap * sizeof(int) ); + memcpy( capEnd, mmCurCapEnd + j * ncap, + ncap * sizeof(int) ); + int c = scur->atom, n = snext->atom; + int p = -1, q = -1; + int cap; + + /* + Lemma 1. For any x in the range [0..nf), we have + f[x].parent < x. + + Proof. By looking at startAtom(), it is clear that + cf < nf holds all the time, and thus that + f[nf].parent < nf. + */ + + /* + If we are reentering an atom, we empty all capture + zones inside it. + */ + if ( scur->reenter != 0 && + (q = at(*scur->reenter, next)) != 0 ) { + QBitArray b; + b.fill( FALSE, nf ); + b.setBit( q, TRUE ); + for ( int ell = q + 1; ell < nf; ell++ ) { + if ( b.testBit(f[ell].parent) ) { + b.setBit( ell, TRUE ); + cap = f[ell].capture; + if ( cap >= 0 ) { + capBegin[cap] = EmptyCapture; + capEnd[cap] = EmptyCapture; + } + } + } + p = f[q].parent; + + /* + Otherwise, close the capture zones we are leaving. + We are leaving f[c].capture, f[f[c].parent].capture, + f[f[f[c].parent].parent].capture, ..., until + f[x].capture, with x such that f[x].parent is the + youngest common ancestor for c and n. + + We go up along c's and n's ancestry until we find x. + */ + } else { + p = c; + q = n; + while ( p != q ) { + if ( p > q ) { + cap = f[p].capture; + if ( cap >= 0 ) { + if ( capBegin[cap] == i ) { + capBegin[cap] = EmptyCapture; + capEnd[cap] = EmptyCapture; + } else { + capEnd[cap] = i; + } + } + p = f[p].parent; + } else { + q = f[q].parent; + } + } + } + + /* + In any case, we now open the capture zones we are + entering. We work upwards from n until we reach p + (the parent of the atom we reenter or the youngest + common ancestor). + */ + while ( n > p ) { + cap = f[n].capture; + if ( cap >= 0 ) { + capBegin[cap] = i; + capEnd[cap] = EmptyCapture; + } + n = f[n].parent; + } + /* + If the next state was already in mmNextStack, we must + choose carefully which capture zones we want to keep. + */ + if ( capBegin == mmTempCapBegin && + isBetterCapture(capBegin, capEnd, + mmNextCapBegin + m * ncap, + mmNextCapEnd + m * ncap) ) { + memcpy( mmNextCapBegin + m * ncap, capBegin, + ncap * sizeof(int) ); + memcpy( mmNextCapEnd + m * ncap, capEnd, + ncap * sizeof(int) ); + } + } #ifndef QT_NO_REGEXP_BACKREF - /* - We are done with updating the capture zones. It's now - time to put the next state to sleep, if it needs to, and - to remove it from mmNextStack. - */ - if ( needSomeSleep > 0 ) { - zzZ = new int[1 + 2 * ncap]; - zzZ[0] = next; - if ( ncap > 0 ) { - memcpy( zzZ + 1, capBegin, ncap * sizeof(int) ); - memcpy( zzZ + 1 + ncap, capEnd, - ncap * sizeof(int) ); - } - mmInNextStack[mmNextStack[--nnext]] = -1; - mmSleeping.insert( i + needSomeSleep, zzZ ); - } -#endif -#endif - } - } - } + /* + We are done with updating the capture zones. It's now + time to put the next state to sleep, if it needs to, and + to remove it from mmNextStack. + */ + if ( needSomeSleep > 0 ) { + zzZ = new int[1 + 2 * ncap]; + zzZ[0] = next; + if ( ncap > 0 ) { + memcpy( zzZ + 1, capBegin, ncap * sizeof(int) ); + memcpy( zzZ + 1 + ncap, capEnd, + ncap * sizeof(int) ); + } + mmInNextStack[mmNextStack[--nnext]] = -1; + mmSleeping.insert( i + needSomeSleep, zzZ ); + } +#endif +#endif + } + } + } #ifndef QT_NO_REGEXP_CAPTURE - /* - If we reached the final state, hurray! Copy the captured zone. - */ - if ( ncap > 0 && (m = mmInNextStack[FinalState]) != -1 ) { - memcpy( mmCapBegin, mmNextCapBegin + m * ncap, ncap * sizeof(int) ); - memcpy( mmCapEnd, mmNextCapEnd + m * ncap, ncap * sizeof(int) ); - } + /* + If we reached the final state, hurray! Copy the captured zone. + */ + if ( ncap > 0 && (m = mmInNextStack[FinalState]) != -1 ) { + memcpy( mmCapBegin, mmNextCapBegin + m * ncap, ncap * sizeof(int) ); + memcpy( mmCapEnd, mmNextCapEnd + m * ncap, ncap * sizeof(int) ); + } #ifndef QT_NO_REGEXP_BACKREF - /* - It's time to wake up the sleepers. - */ - if ( mmSleeping.count() > 0 ) { - while ( (zzZ = mmSleeping.take(i)) != 0 ) { - int next = zzZ[0]; - int *capBegin = zzZ + 1; - int *capEnd = zzZ + 1 + ncap; - bool copyOver = TRUE; - - if ( (m = mmInNextStack[zzZ[0]]) == -1 ) { - m = nnext++; - mmNextStack[m] = next; - mmInNextStack[next] = m; - } else { - copyOver = isBetterCapture( mmNextCapBegin + m * ncap, - mmNextCapEnd + m * ncap, - capBegin, capEnd ); - } - if ( copyOver ) { - memcpy( mmNextCapBegin + m * ncap, capBegin, - ncap * sizeof(int) ); - memcpy( mmNextCapEnd + m * ncap, capEnd, - ncap * sizeof(int) ); - } - delete[] zzZ; - } - } -#endif -#endif - for ( j = 0; j < nnext; j++ ) - mmInNextStack[mmNextStack[j]] = -1; - - qSwap( mmCurStack, mmNextStack ); + /* + It's time to wake up the sleepers. + */ + if ( mmSleeping.count() > 0 ) { + while ( (zzZ = mmSleeping.take(i)) != 0 ) { + int next = zzZ[0]; + int *capBegin = zzZ + 1; + int *capEnd = zzZ + 1 + ncap; + bool copyOver = TRUE; + + if ( (m = mmInNextStack[zzZ[0]]) == -1 ) { + m = nnext++; + mmNextStack[m] = next; + mmInNextStack[next] = m; + } else { + copyOver = isBetterCapture( mmNextCapBegin + m * ncap, + mmNextCapEnd + m * ncap, + capBegin, capEnd ); + } + if ( copyOver ) { + memcpy( mmNextCapBegin + m * ncap, capBegin, + ncap * sizeof(int) ); + memcpy( mmNextCapEnd + m * ncap, capEnd, + ncap * sizeof(int) ); + } + delete[] zzZ; + } + } +#endif +#endif + for ( j = 0; j < nnext; j++ ) + mmInNextStack[mmNextStack[j]] = -1; + + qSwap( mmCurStack, mmNextStack ); #ifndef QT_NO_REGEXP_CAPTURE - qSwap( mmCurCapBegin, mmNextCapBegin ); - qSwap( mmCurCapEnd, mmNextCapEnd ); + qSwap( mmCurCapBegin, mmNextCapBegin ); + qSwap( mmCurCapEnd, mmNextCapEnd ); #endif - ncur = nnext; - nnext = 0; - i++; + ncur = nnext; + nnext = 0; + i++; } @@ -2093,4 +2099,4 @@ bool QRegExpEngine::matchHere() while ( !mmSleeping.isEmpty() ) { - zzZ = mmSleeping.take( *QIntDictIterator<int>(mmSleeping) ); - delete[] zzZ; + zzZ = mmSleeping.take( *QIntDictIterator<int>(mmSleeping) ); + delete[] zzZ; } @@ -2100,3 +2106,3 @@ bool QRegExpEngine::matchHere() if ( !match ) - mmMatchedLen = i - 1; + mmMatchedLen = i - 1; return match; @@ -2115,3 +2121,3 @@ QRegExpEngine::CharClass::CharClass() QRegExpEngine::CharClass& QRegExpEngine::CharClass::operator=( - const CharClass& cc ) + const CharClass& cc ) { @@ -2152,3 +2158,3 @@ void QRegExpEngine::CharClass::addRange( ushort from, ushort to ) if ( from > to ) - qSwap( from, to ); + qSwap( from, to ); int n = r.size(); @@ -2162,14 +2168,14 @@ void QRegExpEngine::CharClass::addRange( ushort from, ushort to ) if ( to - from < NumBadChars ) { - occ1.detach(); - if ( from % NumBadChars <= to % NumBadChars ) { - for ( i = from % NumBadChars; i <= to % NumBadChars; i++ ) - occ1[i] = 0; - } else { - for ( i = 0; i <= to % NumBadChars; i++ ) - occ1[i] = 0; - for ( i = from % NumBadChars; i < NumBadChars; i++ ) - occ1[i] = 0; - } + occ1.detach(); + if ( from % NumBadChars <= to % NumBadChars ) { + for ( i = from % NumBadChars; i <= to % NumBadChars; i++ ) + occ1[i] = 0; } else { - occ1 = *firstOccurrenceAtZero; + for ( i = 0; i <= to % NumBadChars; i++ ) + occ1[i] = 0; + for ( i = from % NumBadChars; i < NumBadChars; i++ ) + occ1[i] = 0; + } + } else { + occ1 = *firstOccurrenceAtZero; } @@ -2182,3 +2188,3 @@ bool QRegExpEngine::CharClass::in( QChar ch ) const if ( occ1[BadChar(ch)] == NoOccurrence ) - return n; + return n; #endif @@ -2186,6 +2192,6 @@ bool QRegExpEngine::CharClass::in( QChar ch ) const if ( c != 0 && (c & (1 << (int) ch.category())) != 0 ) - return !n; + return !n; for ( int i = 0; i < (int) r.size(); i++ ) { - if ( ch.unicode() >= r[i].from && ch.unicode() <= r[i].to ) - return !n; + if ( ch.unicode() >= r[i].from && ch.unicode() <= r[i].to ) + return !n; } @@ -2198,9 +2204,9 @@ void QRegExpEngine::CharClass::dump() const int i; - qDebug( " %stive character class", n ? "nega" : "posi" ); + odebug << " " << (n ? "nega" : "posi") << "tive character class" << oendl; #ifndef QT_NO_REGEXP_CCLASS if ( c != 0 ) - qDebug( " categories 0x%.8x", c ); + odebug << QString().sprintf(" categories 0x%.8x", c ) << oendl; #endif for ( i = 0; i < (int) r.size(); i++ ) - qDebug( " 0x%.4x through 0x%.4x", r[i].from, r[i].to ); + odebug << QString().sprintf(" 0x%.4x through 0x%.4x", r[i].from, r[i].to ) << oendl; } @@ -2277,3 +2283,3 @@ void QRegExpEngine::Box::set( int bref ) if ( bref >= 1 && bref <= MaxBackRefs ) - skipanchors = Anchor_BackRef0Empty << bref; + skipanchors = Anchor_BackRef0Empty << bref; #ifndef QT_NO_REGEXP_OPTIM @@ -2290,25 +2296,25 @@ void QRegExpEngine::Box::cat( const Box& b ) if ( minl == 0 ) { - mergeInto( &lanchors, b.lanchors ); - if ( skipanchors != 0 ) { - for ( int i = 0; i < (int) b.ls.size(); i++ ) { - int a = eng->anchorConcatenation( at(lanchors, b.ls[i]), - skipanchors ); - lanchors.insert( b.ls[i], a ); - } - } - mergeInto( &ls, b.ls ); + mergeInto( &lanchors, b.lanchors ); + if ( skipanchors != 0 ) { + for ( int i = 0; i < (int) b.ls.size(); i++ ) { + int a = eng->anchorConcatenation( at(lanchors, b.ls[i]), + skipanchors ); + lanchors.insert( b.ls[i], a ); + } + } + mergeInto( &ls, b.ls ); } if ( b.minl == 0 ) { - mergeInto( &ranchors, b.ranchors ); - if ( b.skipanchors != 0 ) { - for ( int i = 0; i < (int) rs.size(); i++ ) { - int a = eng->anchorConcatenation( at(ranchors, rs[i]), - b.skipanchors ); - ranchors.insert( rs[i], a ); - } - } - mergeInto( &rs, b.rs ); + mergeInto( &ranchors, b.ranchors ); + if ( b.skipanchors != 0 ) { + for ( int i = 0; i < (int) rs.size(); i++ ) { + int a = eng->anchorConcatenation( at(ranchors, rs[i]), + b.skipanchors ); + ranchors.insert( rs[i], a ); + } + } + mergeInto( &rs, b.rs ); } else { - ranchors = b.ranchors; - rs = b.rs; + ranchors = b.ranchors; + rs = b.rs; } @@ -2317,12 +2323,12 @@ void QRegExpEngine::Box::cat( const Box& b ) if ( maxl != InftyLen ) { - if ( rightStr.length() + b.leftStr.length() > - QMAX(str.length(), b.str.length()) ) { - earlyStart = minl - rightStr.length(); - lateStart = maxl - rightStr.length(); - str = rightStr + b.leftStr; - } else if ( b.str.length() > str.length() ) { - earlyStart = minl + b.earlyStart; - lateStart = maxl + b.lateStart; - str = b.str; - } + if ( rightStr.length() + b.leftStr.length() > + QMAX(str.length(), b.str.length()) ) { + earlyStart = minl - rightStr.length(); + lateStart = maxl - rightStr.length(); + str = rightStr + b.leftStr; + } else if ( b.str.length() > str.length() ) { + earlyStart = minl + b.earlyStart; + lateStart = maxl + b.lateStart; + str = b.str; + } } @@ -2330,12 +2336,12 @@ void QRegExpEngine::Box::cat( const Box& b ) if ( (int) leftStr.length() == maxl ) - leftStr += b.leftStr; + leftStr += b.leftStr; if ( (int) b.rightStr.length() == b.maxl ) - rightStr += b.rightStr; + rightStr += b.rightStr; else - rightStr = b.rightStr; + rightStr = b.rightStr; if ( maxl == InftyLen || b.maxl == InftyLen ) - maxl = InftyLen; + maxl = InftyLen; else - maxl += b.maxl; + maxl += b.maxl; @@ -2343,4 +2349,4 @@ void QRegExpEngine::Box::cat( const Box& b ) for ( int i = 0; i < NumBadChars; i++ ) { - if ( b.occ1[i] != NoOccurrence && minl + b.occ1[i] < occ1[i] ) - occ1[i] = minl + b.occ1[i]; + if ( b.occ1[i] != NoOccurrence && minl + b.occ1[i] < occ1[i] ) + occ1[i] = minl + b.occ1[i]; } @@ -2350,5 +2356,5 @@ void QRegExpEngine::Box::cat( const Box& b ) if ( minl == 0 ) - skipanchors = eng->anchorConcatenation( skipanchors, b.skipanchors ); + skipanchors = eng->anchorConcatenation( skipanchors, b.skipanchors ); else - skipanchors = 0; + skipanchors = 0; } @@ -2366,4 +2372,4 @@ void QRegExpEngine::Box::orx( const Box& b ) for ( int i = 0; i < NumBadChars; i++ ) { - if ( occ1[i] > b.occ1[i] ) - occ1[i] = b.occ1[i]; + if ( occ1[i] > b.occ1[i] ) + occ1[i] = b.occ1[i]; } @@ -2375,6 +2381,6 @@ void QRegExpEngine::Box::orx( const Box& b ) if ( b.maxl > maxl ) - maxl = b.maxl; + maxl = b.maxl; #endif if ( b.minl < minl ) - minl = b.minl; + minl = b.minl; } @@ -2411,8 +2417,8 @@ void QRegExpEngine::Box::catAnchor( int a ) if ( a != 0 ) { - for ( int i = 0; i < (int) rs.size(); i++ ) { - a = eng->anchorConcatenation( at(ranchors, rs[i]), a ); - ranchors.insert( rs[i], a ); - } - if ( minl == 0 ) - skipanchors = eng->anchorConcatenation( skipanchors, a ); + for ( int i = 0; i < (int) rs.size(); i++ ) { + a = eng->anchorConcatenation( at(ranchors, rs[i]), a ); + ranchors.insert( rs[i], a ); + } + if ( minl == 0 ) + skipanchors = eng->anchorConcatenation( skipanchors, a ); } @@ -2435,4 +2441,4 @@ void QRegExpEngine::Box::setupHeuristics() for ( int i = 0; i < NumBadChars; i++ ) { - if ( occ1[i] != NoOccurrence && occ1[i] >= minl ) - occ1[i] = minl; + if ( occ1[i] != NoOccurrence && occ1[i] >= minl ) + occ1[i] = minl; } @@ -2448,18 +2454,18 @@ void QRegExpEngine::Box::dump() const int i; - qDebug( "Box of at least %d character%s", minl, minl == 1 ? "" : "s" ); - qDebug( " Left states:" ); + odebug << "Box of at least " << minl << " character" << (minl == 1 ? "" : "s") << oendl; + odebug << " Left states:" << oendl; for ( i = 0; i < (int) ls.size(); i++ ) { - if ( at(lanchors, ls[i]) == 0 ) - qDebug( " %d", ls[i] ); - else - qDebug( " %d [anchors 0x%.8x]", ls[i], lanchors[ls[i]] ); + if ( at(lanchors, ls[i]) == 0 ) + odebug << " " << ls[i] << oendl; + else + odebug << " " << ls[i] << QString().sprintf(" [anchors 0x%.8x]", lanchors[ls[i]]) << oendl; } - qDebug( " Right states:" ); + odebug << " Right states:" << oendl; for ( i = 0; i < (int) rs.size(); i++ ) { - if ( at(ranchors, ls[i]) == 0 ) - qDebug( " %d", rs[i] ); - else - qDebug( " %d [anchors 0x%.8x]", rs[i], ranchors[rs[i]] ); + if ( at(ranchors, ls[i]) == 0 ) + odebug << " " << rs[i] << oendl; + else + odebug << " " << rs[i] << QString().sprintf(" [anchors 0x%.8x]", ranchors[rs[i]]) << oendl; } - qDebug( " Skip anchors: 0x%.8x", skipanchors ); + odebug << QString().sprintf(" Skip anchors: 0x%.8x", skipanchors) << oendl; } @@ -2470,7 +2476,7 @@ void QRegExpEngine::Box::addAnchorsToEngine( const Box& to ) const for ( int i = 0; i < (int) to.ls.size(); i++ ) { - for ( int j = 0; j < (int) rs.size(); j++ ) { - int a = eng->anchorConcatenation( at(ranchors, rs[j]), - at(to.lanchors, to.ls[i]) ); - eng->addAnchors( rs[j], to.ls[i], a ); - } + for ( int j = 0; j < (int) rs.size(); j++ ) { + int a = eng->anchorConcatenation( at(ranchors, rs[j]), + at(to.lanchors, to.ls[i]) ); + eng->addAnchors( rs[j], to.ls[i], a ); + } } @@ -2495,4 +2501,4 @@ int QRegExpEngine::getEscape() if ( prevCh == EOS ) { - yyError = TRUE; - return Tok_Char | '\\'; + yyError = TRUE; + return Tok_Char | '\\'; } @@ -2501,5 +2507,5 @@ int QRegExpEngine::getEscape() if ( (prevCh & ~0xff) == 0 ) { - const char *p = strchr( tab, prevCh ); - if ( p != 0 ) - return Tok_Char | backTab[p - tab]; + const char *p = strchr( tab, prevCh ); + if ( p != 0 ) + return Tok_Char | backTab[p - tab]; } @@ -2510,13 +2516,13 @@ int QRegExpEngine::getEscape() case '0': - val = 0; - for ( i = 0; i < 3; i++ ) { - if ( yyCh >= '0' && yyCh <= '7' ) - val = ( val << 3 ) | ( yyCh - '0' ); - else - break; - yyCh = getChar(); - } - if ( (val & ~0377) != 0 ) - yyError = TRUE; - return Tok_Char | val; + val = 0; + for ( i = 0; i < 3; i++ ) { + if ( yyCh >= '0' && yyCh <= '7' ) + val = ( val << 3 ) | ( yyCh - '0' ); + else + break; + yyCh = getChar(); + } + if ( (val & ~0377) != 0 ) + yyError = TRUE; + return Tok_Char | val; #endif @@ -2524,3 +2530,3 @@ int QRegExpEngine::getEscape() case 'B': - return Tok_NonWord; + return Tok_NonWord; #endif @@ -2528,16 +2534,16 @@ int QRegExpEngine::getEscape() case 'D': - // see QChar::isDigit() - yyCharClass->addCategories( 0x7fffffef ); - return Tok_CharClass; + // see QChar::isDigit() + yyCharClass->addCategories( 0x7fffffef ); + return Tok_CharClass; case 'S': - // see QChar::isSpace() - yyCharClass->addCategories( 0x7ffff87f ); - yyCharClass->addRange( 0x0000, 0x0008 ); - yyCharClass->addRange( 0x000e, 0x001f ); - yyCharClass->addRange( 0x007f, 0x009f ); - return Tok_CharClass; + // see QChar::isSpace() + yyCharClass->addCategories( 0x7ffff87f ); + yyCharClass->addRange( 0x0000, 0x0008 ); + yyCharClass->addRange( 0x000e, 0x001f ); + yyCharClass->addRange( 0x007f, 0x009f ); + return Tok_CharClass; case 'W': - // see QChar::isLetterOrNumber() - yyCharClass->addCategories( 0x7ff07f8f ); - return Tok_CharClass; + // see QChar::isLetterOrNumber() + yyCharClass->addCategories( 0x7ff07f8f ); + return Tok_CharClass; #endif @@ -2545,3 +2551,3 @@ int QRegExpEngine::getEscape() case 'b': - return Tok_Word; + return Tok_Word; #endif @@ -2549,14 +2555,14 @@ int QRegExpEngine::getEscape() case 'd': - // see QChar::isDigit() - yyCharClass->addCategories( 0x00000010 ); - return Tok_CharClass; + // see QChar::isDigit() + yyCharClass->addCategories( 0x00000010 ); + return Tok_CharClass; case 's': - // see QChar::isSpace() - yyCharClass->addCategories( 0x00000380 ); - yyCharClass->addRange( 0x0009, 0x000d ); - return Tok_CharClass; + // see QChar::isSpace() + yyCharClass->addCategories( 0x00000380 ); + yyCharClass->addRange( 0x0009, 0x000d ); + return Tok_CharClass; case 'w': - // see QChar::isLetterOrNumber() - yyCharClass->addCategories( 0x000f8070 ); - return Tok_CharClass; + // see QChar::isLetterOrNumber() + yyCharClass->addCategories( 0x000f8070 ); + return Tok_CharClass; #endif @@ -2564,29 +2570,29 @@ int QRegExpEngine::getEscape() case 'x': - val = 0; - for ( i = 0; i < 4; i++ ) { - low = QChar( yyCh ).lower(); - if ( low >= '0' && low <= '9' ) - val = ( val << 4 ) | ( low - '0' ); - else if ( low >= 'a' && low <= 'f' ) - val = ( val << 4 ) | ( low - 'a' + 10 ); - else - break; - yyCh = getChar(); - } - return Tok_Char | val; + val = 0; + for ( i = 0; i < 4; i++ ) { + low = QChar( yyCh ).lower(); + if ( low >= '0' && low <= '9' ) + val = ( val << 4 ) | ( low - '0' ); + else if ( low >= 'a' && low <= 'f' ) + val = ( val << 4 ) | ( low - 'a' + 10 ); + else + break; + yyCh = getChar(); + } + return Tok_Char | val; #endif default: - if ( prevCh >= '1' && prevCh <= '9' ) { + if ( prevCh >= '1' && prevCh <= '9' ) { #ifndef QT_NO_REGEXP_BACKREF - val = prevCh - '0'; - while ( yyCh >= '0' && yyCh <= '9' ) { - val = ( val *= 10 ) | ( yyCh - '0' ); - yyCh = getChar(); - } - return Tok_BackRef | val; + val = prevCh - '0'; + while ( yyCh >= '0' && yyCh <= '9' ) { + val = ( val *= 10 ) | ( yyCh - '0' ); + yyCh = getChar(); + } + return Tok_BackRef | val; #else - yyError = TRUE; + yyError = TRUE; #endif - } - return Tok_Char | prevCh; + } + return Tok_Char | prevCh; } @@ -2598,14 +2604,14 @@ int QRegExpEngine::getRep( int def ) if ( yyCh >= '0' && yyCh <= '9' ) { - int rep = 0; - do { - rep = 10 * rep + yyCh - '0'; - if ( rep >= InftyRep ) { - yyError = TRUE; - rep = def; - } - yyCh = getChar(); - } while ( yyCh >= '0' && yyCh <= '9' ); - return rep; + int rep = 0; + do { + rep = 10 * rep + yyCh - '0'; + if ( rep >= InftyRep ) { + yyError = TRUE; + rep = def; + } + yyCh = getChar(); + } while ( yyCh >= '0' && yyCh <= '9' ); + return rep; } else { - return def; + return def; } @@ -2618,4 +2624,4 @@ void QRegExpEngine::skipChars( int n ) if ( n > 0 ) { - yyPos += n - 1; - yyCh = getChar(); + yyPos += n - 1; + yyCh = getChar(); } @@ -2656,137 +2662,137 @@ int QRegExpEngine::getToken() case EOS: - yyPos0 = yyPos; - return Tok_Eos; + yyPos0 = yyPos; + return Tok_Eos; case '$': - return Tok_Dollar; + return Tok_Dollar; case '(': - if ( yyCh == '?' ) { - prevCh = getChar(); - yyCh = getChar(); - switch ( prevCh ) { + if ( yyCh == '?' ) { + prevCh = getChar(); + yyCh = getChar(); + switch ( prevCh ) { #ifndef QT_NO_REGEXP_LOOKAHEAD - case '!': - return Tok_NegLookahead; - case '=': - return Tok_PosLookahead; -#endif - case ':': - return Tok_MagicLeftParen; - default: - yyError = TRUE; - return Tok_MagicLeftParen; - } - } else { - return Tok_LeftParen; - } + case '!': + return Tok_NegLookahead; + case '=': + return Tok_PosLookahead; +#endif + case ':': + return Tok_MagicLeftParen; + default: + yyError = TRUE; + return Tok_MagicLeftParen; + } + } else { + return Tok_LeftParen; + } case ')': - return Tok_RightParen; + return Tok_RightParen; case '*': - yyMinRep = 0; - yyMaxRep = InftyRep; - return Tok_Quantifier; + yyMinRep = 0; + yyMaxRep = InftyRep; + return Tok_Quantifier; case '+': - yyMinRep = 1; - yyMaxRep = InftyRep; - return Tok_Quantifier; + yyMinRep = 1; + yyMaxRep = InftyRep; + return Tok_Quantifier; case '.': #ifndef QT_NO_REGEXP_CCLASS - yyCharClass->setNegative( TRUE ); + yyCharClass->setNegative( TRUE ); #endif - return Tok_CharClass; + return Tok_CharClass; case '?': - yyMinRep = 0; - yyMaxRep = 1; - return Tok_Quantifier; + yyMinRep = 0; + yyMaxRep = 1; + return Tok_Quantifier; case '[': #ifndef QT_NO_REGEXP_CCLASS - if ( yyCh == '^' ) { - yyCharClass->setNegative( TRUE ); - yyCh = getChar(); - } - charPending = FALSE; - rangePending = FALSE; - do { - if ( yyCh == '-' && charPending && !rangePending ) { - rangePending = TRUE; - yyCh = getChar(); - } else { - if ( charPending && !rangePending ) { - yyCharClass->addSingleton( pendingCh ); - charPending = FALSE; - } - if ( yyCh == '\\' ) { - yyCh = getChar(); - tok = getEscape(); - if ( tok == Tok_Word ) - tok = '\b'; - } else { - tok = Tok_Char | yyCh; - yyCh = getChar(); - } - if ( tok == Tok_CharClass ) { - if ( rangePending ) { - yyCharClass->addSingleton( '-' ); - yyCharClass->addSingleton( pendingCh ); - charPending = FALSE; - rangePending = FALSE; - } - } else if ( (tok & Tok_Char) != 0 ) { - if ( rangePending ) { - yyCharClass->addRange( pendingCh, tok ^ Tok_Char ); - charPending = FALSE; - rangePending = FALSE; - } else { - pendingCh = tok ^ Tok_Char; - charPending = TRUE; - } - } else { - yyError = TRUE; - } - } - } while ( yyCh != ']' && yyCh != EOS ); - if ( rangePending ) - yyCharClass->addSingleton( '-' ); - if ( charPending ) - yyCharClass->addSingleton( pendingCh ); - if ( yyCh == EOS ) - yyError = TRUE; - else - yyCh = getChar(); - return Tok_CharClass; + if ( yyCh == '^' ) { + yyCharClass->setNegative( TRUE ); + yyCh = getChar(); + } + charPending = FALSE; + rangePending = FALSE; + do { + if ( yyCh == '-' && charPending && !rangePending ) { + rangePending = TRUE; + yyCh = getChar(); + } else { + if ( charPending && !rangePending ) { + yyCharClass->addSingleton( pendingCh ); + charPending = FALSE; + } + if ( yyCh == '\\' ) { + yyCh = getChar(); + tok = getEscape(); + if ( tok == Tok_Word ) + tok = '\b'; + } else { + tok = Tok_Char | yyCh; + yyCh = getChar(); + } + if ( tok == Tok_CharClass ) { + if ( rangePending ) { + yyCharClass->addSingleton( '-' ); + yyCharClass->addSingleton( pendingCh ); + charPending = FALSE; + rangePending = FALSE; + } + } else if ( (tok & Tok_Char) != 0 ) { + if ( rangePending ) { + yyCharClass->addRange( pendingCh, tok ^ Tok_Char ); + charPending = FALSE; + rangePending = FALSE; + } else { + pendingCh = tok ^ Tok_Char; + charPending = TRUE; + } + } else { + yyError = TRUE; + } + } + } while ( yyCh != ']' && yyCh != EOS ); + if ( rangePending ) + yyCharClass->addSingleton( '-' ); + if ( charPending ) + yyCharClass->addSingleton( pendingCh ); + if ( yyCh == EOS ) + yyError = TRUE; + else + yyCh = getChar(); + return Tok_CharClass; #else - yyError = TRUE; - return Tok_Char | '['; + yyError = TRUE; + return Tok_Char | '['; #endif case '\\': - return getEscape(); + return getEscape(); case ']': - yyError = TRUE; - return Tok_Char | ']'; + yyError = TRUE; + return Tok_Char | ']'; case '^': - return Tok_Caret; + return Tok_Caret; #ifndef QT_NO_REGEXP_INTERVAL case '{': - yyMinRep = getRep( 0 ); - yyMaxRep = yyMinRep; - if ( yyCh == ',' ) { - yyCh = getChar(); - yyMaxRep = getRep( InftyRep ); - } - if ( yyMaxRep < yyMinRep ) - qSwap( yyMinRep, yyMaxRep ); - if ( yyCh != '}' ) - yyError = TRUE; - yyCh = getChar(); - return Tok_Quantifier; + yyMinRep = getRep( 0 ); + yyMaxRep = yyMinRep; + if ( yyCh == ',' ) { + yyCh = getChar(); + yyMaxRep = getRep( InftyRep ); + } + if ( yyMaxRep < yyMinRep ) + qSwap( yyMinRep, yyMaxRep ); + if ( yyCh != '}' ) + yyError = TRUE; + yyCh = getChar(); + return Tok_Quantifier; #else - yyError = TRUE; - return Tok_Char | '{'; + yyError = TRUE; + return Tok_Char | '{'; #endif case '|': - return Tok_Bar; + return Tok_Bar; case '}': - yyError = TRUE; - return Tok_Char | '}'; + yyError = TRUE; + return Tok_Char | '}'; default: - return Tok_Char | prevCh; + return Tok_Char | prevCh; } @@ -2830,3 +2836,3 @@ int QRegExpEngine::parse( const QChar *pattern, int len ) if ( nbrefs > ncap ) - ncap = nbrefs; + ncap = nbrefs; #endif @@ -2865,3 +2871,3 @@ int QRegExpEngine::parse( const QChar *pattern, int len ) if ( yyError ) - return -1; + return -1; @@ -2871,14 +2877,14 @@ int QRegExpEngine::parse( const QChar *pattern, int len ) if ( caretAnchored ) { - QMap<int, int>& anchors = *sinit->anchors; - QMap<int, int>::ConstIterator a; - for ( a = anchors.begin(); a != anchors.end(); ++a ) { + QMap<int, int>& anchors = *sinit->anchors; + QMap<int, int>::ConstIterator a; + for ( a = anchors.begin(); a != anchors.end(); ++a ) { #ifndef QT_NO_REGEXP_ANCHOR_ALT - if ( (*a & Anchor_Alternation) != 0 ) - break; + if ( (*a & Anchor_Alternation) != 0 ) + break; #endif - if ( (*a & Anchor_Caret) == 0 ) { - caretAnchored = FALSE; - break; - } - } + if ( (*a & Anchor_Caret) == 0 ) { + caretAnchored = FALSE; + break; + } + } } @@ -2898,7 +2904,7 @@ void QRegExpEngine::parseAtom( Box *box ) case Tok_Dollar: - box->catAnchor( Anchor_Dollar ); - break; + box->catAnchor( Anchor_Dollar ); + break; case Tok_Caret: - box->catAnchor( Anchor_Caret ); - break; + box->catAnchor( Anchor_Caret ); + break; #ifndef QT_NO_REGEXP_LOOKAHEAD @@ -2906,14 +2912,14 @@ void QRegExpEngine::parseAtom( Box *box ) case Tok_NegLookahead: - neg = ( yyTok == Tok_NegLookahead ); - eng = new QRegExpEngine( cs ); - len = eng->parse( yyIn + yyPos - 1, yyLen - yyPos + 1 ); - if ( len >= 0 ) - skipChars( len ); - else - yyError = TRUE; - box->catAnchor( addLookahead(eng, neg) ); - yyTok = getToken(); - if ( yyTok != Tok_RightParen ) - yyError = TRUE; - break; + neg = ( yyTok == Tok_NegLookahead ); + eng = new QRegExpEngine( cs ); + len = eng->parse( yyIn + yyPos - 1, yyLen - yyPos + 1 ); + if ( len >= 0 ) + skipChars( len ); + else + yyError = TRUE; + box->catAnchor( addLookahead(eng, neg) ); + yyTok = getToken(); + if ( yyTok != Tok_RightParen ) + yyError = TRUE; + break; #endif @@ -2921,7 +2927,7 @@ void QRegExpEngine::parseAtom( Box *box ) case Tok_Word: - box->catAnchor( Anchor_Word ); - break; + box->catAnchor( Anchor_Word ); + break; case Tok_NonWord: - box->catAnchor( Anchor_NonWord ); - break; + box->catAnchor( Anchor_NonWord ); + break; #endif @@ -2929,19 +2935,19 @@ void QRegExpEngine::parseAtom( Box *box ) case Tok_MagicLeftParen: - yyTok = getToken(); - parseExpression( box ); - if ( yyTok != Tok_RightParen ) - yyError = TRUE; - break; + yyTok = getToken(); + parseExpression( box ); + if ( yyTok != Tok_RightParen ) + yyError = TRUE; + break; case Tok_CharClass: - box->set( *yyCharClass ); - break; + box->set( *yyCharClass ); + break; default: - if ( (yyTok & Tok_Char) != 0 ) - box->set( QChar(yyTok ^ Tok_Char) ); + if ( (yyTok & Tok_Char) != 0 ) + box->set( QChar(yyTok ^ Tok_Char) ); #ifndef QT_NO_REGEXP_BACKREF - else if ( (yyTok & Tok_BackRef) != 0 ) - box->set( yyTok ^ Tok_BackRef ); + else if ( (yyTok & Tok_BackRef) != 0 ) + box->set( yyTok ^ Tok_BackRef ); #endif - else - yyError = TRUE; + else + yyError = TRUE; } @@ -2960,4 +2966,4 @@ void QRegExpEngine::parseFactor( Box *box ) #define YYREDO() \ - yyIn = in, yyPos0 = pos0, yyPos = pos, yyLen = len, yyCh = ch, \ - *yyCharClass = charClass, yyMinRep = 0, yyMaxRep = 0, yyTok = tok + yyIn = in, yyPos0 = pos0, yyPos = pos, yyLen = len, yyCh = ch, \ + *yyCharClass = charClass, yyMinRep = 0, yyMaxRep = 0, yyTok = tok @@ -2970,3 +2976,3 @@ void QRegExpEngine::parseFactor( Box *box ) if ( yyTok == Tok_CharClass ) - charClass = *yyCharClass; + charClass = *yyCharClass; int tok = yyTok; @@ -2981,41 +2987,41 @@ void QRegExpEngine::parseFactor( Box *box ) if ( yyTok == Tok_Quantifier ) { - if ( yyMaxRep == InftyRep ) { - box->plus( atom ); + if ( yyMaxRep == InftyRep ) { + box->plus( atom ); #ifndef QT_NO_REGEXP_INTERVAL - } else if ( yyMaxRep == 0 ) { - box->clear(); + } else if ( yyMaxRep == 0 ) { + box->clear(); #endif - } - if ( yyMinRep == 0 ) - box->opt(); + } + if ( yyMinRep == 0 ) + box->opt(); #ifndef QT_NO_REGEXP_INTERVAL - yyMayCapture = FALSE; - int alpha = ( yyMinRep == 0 ) ? 0 : yyMinRep - 1; - int beta = ( yyMaxRep == InftyRep ) ? 0 : yyMaxRep - ( alpha + 1 ); - - Box rightBox( this ); - int i; - - for ( i = 0; i < beta; i++ ) { - YYREDO(); - Box leftBox( this ); - parseAtom( &leftBox ); - leftBox.cat( rightBox ); - leftBox.opt(); - rightBox = leftBox; - } - for ( i = 0; i < alpha; i++ ) { - YYREDO(); - Box leftBox( this ); - parseAtom( &leftBox ); - leftBox.cat( rightBox ); - rightBox = leftBox; - } - rightBox.cat( *box ); - *box = rightBox; -#endif - yyTok = getToken(); + yyMayCapture = FALSE; + int alpha = ( yyMinRep == 0 ) ? 0 : yyMinRep - 1; + int beta = ( yyMaxRep == InftyRep ) ? 0 : yyMaxRep - ( alpha + 1 ); + + Box rightBox( this ); + int i; + + for ( i = 0; i < beta; i++ ) { + YYREDO(); + Box leftBox( this ); + parseAtom( &leftBox ); + leftBox.cat( rightBox ); + leftBox.opt(); + rightBox = leftBox; + } + for ( i = 0; i < alpha; i++ ) { + YYREDO(); + Box leftBox( this ); + parseAtom( &leftBox ); + leftBox.cat( rightBox ); + rightBox = leftBox; + } + rightBox.cat( *box ); + *box = rightBox; +#endif + yyTok = getToken(); #ifndef QT_NO_REGEXP_INTERVAL - yyMayCapture = mayCapture; + yyMayCapture = mayCapture; #endif @@ -3029,8 +3035,8 @@ void QRegExpEngine::parseTerm( Box *box ) if ( yyTok != Tok_Eos && yyTok != Tok_RightParen && yyTok != Tok_Bar ) - parseFactor( box ); + parseFactor( box ); #endif while ( yyTok != Tok_Eos && yyTok != Tok_RightParen && yyTok != Tok_Bar ) { - Box rightBox( this ); - parseFactor( &rightBox ); - box->cat( rightBox ); + Box rightBox( this ); + parseFactor( &rightBox ); + box->cat( rightBox ); } @@ -3042,6 +3048,6 @@ void QRegExpEngine::parseExpression( Box *box ) while ( yyTok == Tok_Bar ) { - Box rightBox( this ); - yyTok = getToken(); - parseTerm( &rightBox ); - box->orx( rightBox ); + Box rightBox( this ); + yyTok = getToken(); + parseTerm( &rightBox ); + box->orx( rightBox ); } @@ -3079,9 +3085,9 @@ static QRegExpEngine *newEngine( const QString& pattern, bool caseSensitive ) if ( engineCache != 0 ) { - QRegExpEngine *eng = engineCache->take( pattern ); - if ( eng == 0 || eng->caseSensitive() != caseSensitive ) { - delete eng; - } else { - eng->ref(); - return eng; - } + QRegExpEngine *eng = engineCache->take( pattern ); + if ( eng == 0 || eng->caseSensitive() != caseSensitive ) { + delete eng; + } else { + eng->ref(); + return eng; + } } @@ -3095,13 +3101,13 @@ static void derefEngine( QRegExpEngine *eng, const QString& pattern ) #ifndef QT_NO_REGEXP_OPTIM - if ( engineCache == 0 ) { - engineCache = new QCache<QRegExpEngine>; - engineCache->setAutoDelete( TRUE ); - } - if ( !pattern.isNull() && - engineCache->insert(pattern, eng, 4 + pattern.length() / 4) ) - return; + if ( engineCache == 0 ) { + engineCache = new QCache<QRegExpEngine>; + engineCache->setAutoDelete( TRUE ); + } + if ( !pattern.isNull() && + engineCache->insert(pattern, eng, 4 + pattern.length() / 4) ) + return; #else - Q_UNUSED( pattern ); + Q_UNUSED( pattern ); #endif - delete eng; + delete eng; } @@ -3203,7 +3209,7 @@ bool QRegExp3::operator==( const QRegExp3& rx ) const return priv->pattern == rx.priv->pattern && - eng->caseSensitive() == rx.eng->caseSensitive() && + eng->caseSensitive() == rx.eng->caseSensitive() && #ifndef QT_NO_REGEXP_WILDCARD - priv->wc == rx.priv->wc && + priv->wc == rx.priv->wc && #endif - priv->min == rx.priv->min; + priv->min == rx.priv->min; } @@ -3274,4 +3280,4 @@ void QRegExp3::setPattern( const QString& pattern ) if ( priv->pattern != pattern ) { - priv->pattern = pattern; - compile( caseSensitive() ); + priv->pattern = pattern; + compile( caseSensitive() ); } @@ -3301,3 +3307,3 @@ void QRegExp3::setCaseSensitive( bool sensitive ) if ( sensitive != eng->caseSensitive() ) - compile( sensitive ); + compile( sensitive ); } @@ -3330,4 +3336,4 @@ void QRegExp3::setWildcard( bool wildcard ) if ( wildcard != priv->wc ) { - priv->wc = wildcard; - compile( caseSensitive() ); + priv->wc = wildcard; + compile( caseSensitive() ); } @@ -3393,8 +3399,8 @@ bool QRegExp3::exactMatch( const QString& str ) if ( priv->captured[1] == (int) str.length() ) { - return TRUE; + return TRUE; } else { - priv->captured.detach(); - priv->captured[0] = 0; - priv->captured[1] = eng->matchedLength(); - return FALSE; + priv->captured.detach(); + priv->captured[0] = 0; + priv->captured[1] = eng->matchedLength(); + return FALSE; } @@ -3409,3 +3415,3 @@ bool QRegExp3::exactMatch( const QString& str ) const return eng->match(str, 0, priv->min, TRUE)[0] == 0 && - eng->matchedLength() == (int) str.length(); + eng->matchedLength() == (int) str.length(); } @@ -3431,3 +3437,3 @@ bool QRegExp3::exactMatch( const QString& str ) const if ( pos != -1 ) - pos += index; + pos += index; int len = rx.matchedLength(); @@ -3435,5 +3441,5 @@ bool QRegExp3::exactMatch( const QString& str ) const */ -#ifndef QT_NO_COMPAT +#ifndef QT_NO_COMPAT int QRegExp3::match( const QString& str, int index, int *len, - bool indexIsStart ) + bool indexIsStart ) { @@ -3441,15 +3447,15 @@ int QRegExp3::match( const QString& str, int index, int *len, if ( indexIsStart ) { - pos = search( str.mid(index) ); - if ( pos >= 0 ) { - pos += index; - if ( len != 0 ) - *len = matchedLength(); - } else { - if ( len != 0 ) - *len = 0; - } + pos = search( str.mid(index) ); + if ( pos >= 0 ) { + pos += index; + if ( len != 0 ) + *len = matchedLength(); + } else { + if ( len != 0 ) + *len = 0; + } } else { - pos = search( str, index ); - if ( len != 0 ) - *len = matchedLength(); + pos = search( str, index ); + if ( len != 0 ) + *len = matchedLength(); } @@ -3476,4 +3482,4 @@ int QRegExp3::match( const QString& str, int index, int *len, while ( pos >= 0 ) { - pos = rx.search( str, pos ); - count++; + pos = rx.search( str, pos ); + count++; } @@ -3490,7 +3496,7 @@ const QString makeString(const QChar *str) // A sentinel value checked in case the QChar *ptr is never null terminated - const uint MAXLENGTH=65535; + const uint MAXLENGTH=65535; - const QChar *s=str; - uint i=0; - while(i < MAXLENGTH && *s != QChar::null) { i++;s++ ;} + const QChar *s=str; + uint i=0; + while(i < MAXLENGTH && *s != QChar::null) { i++;s++ ;} return QString(str,i); @@ -3500,3 +3506,3 @@ int QRegExp3::search(const QChar *str,int start) { - return search(makeString(str),start); + return search(makeString(str),start); } @@ -3504,3 +3510,3 @@ int QRegExp3::search(const QChar *str,int start) const { - return search(makeString(str),start); + return search(makeString(str),start); } @@ -3508,3 +3514,3 @@ int QRegExp3::searchRev(const QChar *str,int start) { - return searchRev(makeString(str),start); + return searchRev(makeString(str),start); } @@ -3512,3 +3518,3 @@ int QRegExp3::searchRev(const QChar *str,int start) const { - return searchRev(makeString(str),start); + return searchRev(makeString(str),start); } @@ -3516,3 +3522,3 @@ bool QRegExp3::exactMatch(const QChar *str) { - return exactMatch(makeString(str)); + return exactMatch(makeString(str)); } @@ -3520,3 +3526,3 @@ bool QRegExp3::exactMatch(const QChar *str) const { - return exactMatch(makeString(str)); + return exactMatch(makeString(str)); } @@ -3527,3 +3533,3 @@ int QRegExp3::search( const QString& str, int start ) if ( start < 0 ) - start += str.length(); + start += str.length(); #ifndef QT_NO_REGEXP_CAPTURE @@ -3543,3 +3549,3 @@ int QRegExp3::search( const QString& str, int start ) const if ( start < 0 ) - start += str.length(); + start += str.length(); return eng->match( str, start, priv->min, FALSE )[0]; @@ -3561,3 +3567,3 @@ int QRegExp3::searchRev( const QString& str, int start ) if ( start < 0 ) - start += str.length(); + start += str.length(); #ifndef QT_NO_REGEXP_CAPTURE @@ -3567,5 +3573,5 @@ int QRegExp3::searchRev( const QString& str, int start ) if ( start < 0 || start > (int) str.length() ) { - priv->captured.detach(); - priv->captured.fill( -1 ); - return -1; + priv->captured.detach(); + priv->captured.fill( -1 ); + return -1; } @@ -3573,6 +3579,6 @@ int QRegExp3::searchRev( const QString& str, int start ) while ( start >= 0 ) { - priv->captured = eng->match( str, start, priv->min, TRUE ); - if ( priv->captured[0] == start ) - return start; - start--; + priv->captured = eng->match( str, start, priv->min, TRUE ); + if ( priv->captured[0] == start ) + return start; + start--; } @@ -3588,10 +3594,10 @@ int QRegExp3::searchRev( const QString& str, int start ) const if ( start < 0 ) - start += str.length(); + start += str.length(); if ( start < 0 || start > (int) str.length() ) - return -1; + return -1; while ( start >= 0 ) { - if ( eng->match(str, start, priv->min, TRUE)[0] == start ) - return start; - start--; + if ( eng->match(str, start, priv->min, TRUE)[0] == start ) + return start; + start--; } @@ -3658,12 +3664,12 @@ QStringList QRegExp3::capturedTexts() if ( priv->capturedCache.isEmpty() ) { - for ( int i = 0; i < (int) priv->captured.size(); i += 2 ) { - QString m; - if ( priv->captured[i + 1] == 0 ) - m = QString::fromLatin1( "" ); - else if ( priv->captured[i] >= 0 ) - m = priv->t.mid( priv->captured[i], - priv->captured[i + 1] ); - priv->capturedCache.append( m ); - } - priv->t = QString::null; + for ( int i = 0; i < (int) priv->captured.size(); i += 2 ) { + QString m; + if ( priv->captured[i + 1] == 0 ) + m = QString::fromLatin1( "" ); + else if ( priv->captured[i] >= 0 ) + m = priv->t.mid( priv->captured[i], + priv->captured[i + 1] ); + priv->capturedCache.append( m ); + } + priv->t = QString::null; } @@ -3680,5 +3686,5 @@ QStringList QRegExp3::capturedTexts() if ( pos > -1 ) { - QString value = rxlen.cap( 1 ); // "189" - QString unit = rxlen.cap( 2 ); // "cm" - // ... + QString value = rxlen.cap( 1 ); // "189" + QString unit = rxlen.cap( 2 ); // "cm" + // ... } @@ -3696,7 +3702,7 @@ QStringList QRegExp3::capturedTexts() while ( pos >= 0 ) { - pos = rx.search( str, pos ); - if ( pos > -1 ) { - list += rx.cap( 1 ); - pos += rx.matchedLength(); - } + pos = rx.search( str, pos ); + if ( pos > -1 ) { + list += rx.cap( 1 ); + pos += rx.matchedLength(); + } } @@ -3716,5 +3722,5 @@ QString QRegExp3::cap( int nth ) if ( nth < 0 || nth >= (int) priv->captured.size() / 2 ) - return QString::null; + return QString::null; else - return capturedTexts()[nth]; + return capturedTexts()[nth]; } @@ -3728,3 +3734,3 @@ QString QRegExp3::cap( int nth ) QRegExp3 rx( "/([a-z]+)/([a-z]+)" ); - rx.search( "Output /dev/null" ); // Returns 7 (position of /dev/null) + rx.search( "Output /dev/null" ); // Returns 7 (position of /dev/null) rx.pos( 0 ); // Returns 7 (position of /dev/null) @@ -3743,5 +3749,5 @@ int QRegExp3::pos( int nth ) if ( nth < 0 || nth >= (int) priv->captured.size() / 2 ) - return -1; + return -1; else - return priv->captured[2 * nth]; + return priv->captured[2 * nth]; } @@ -3754,7 +3760,7 @@ void QRegExp3::compile( bool caseSensitive ) if ( priv->wc ) - priv->rxpattern = wc2rx( priv->pattern ); + priv->rxpattern = wc2rx( priv->pattern ); else #endif - priv->rxpattern = priv->pattern.isNull() ? QString::fromLatin1( "" ) - : priv->pattern; + priv->rxpattern = priv->pattern.isNull() ? QString::fromLatin1( "" ) + : priv->pattern; eng = newEngine( priv->rxpattern, caseSensitive ); |