From 68eac5bea84863bec266808dfc760c003f0651e9 Mon Sep 17 00:00:00 2001 From: visor Date: Sat, 30 Jul 2011 23:22:18 +0900 Subject: [PATCH] fix. --- wiki/wikiattrib.cc | 22 +++++++++++++++------- wiki/wikiattrib.h | 27 +++++++++++++++++++-------- wiki/wikiformat.cc | 12 ++++++++---- wiki/wikiformat.h | 15 ++++++++++----- wiki/wikiline.cc | 6 ++++-- 5 files changed, 56 insertions(+), 26 deletions(-) diff --git a/wiki/wikiattrib.cc b/wiki/wikiattrib.cc index 418e6e0..43ba094 100644 --- a/wiki/wikiattrib.cc +++ b/wiki/wikiattrib.cc @@ -10,7 +10,8 @@ bool WikiAttrib1::readAttrib1 (WikiMotorObjVec* cell, bool& rc) { bool ferr = false; if (cell->size () == 0) { - if (fwhole) +// if (fwhole) + if (mode == M_ATTRIB || mode == M_ATTRIB_TEXT) return true; else return false; @@ -42,7 +43,8 @@ bool WikiAttrib1::readAttrib1 (WikiMotorObjVec* cell, bool& rc) { wiki->paramTargetBody (key, vval.textOut (wiki), target, ferr); } else if (readAttribMore (key, vval, ferr)) { } else { - if (fwhole) { +// if (fwhole) { + if (mode == M_ATTRIB) { wiki->errorMsg.append (cell->dump ()).append (CharConst (": bad attribute.\n")); rc = false; } @@ -61,7 +63,8 @@ bool WikiAttrib1::readAttrib1 (WikiMotorObjVec* cell, bool& rc) { } else if ((selector & SEL_SCRIPT2) && checkScript (*cell, script, ferr)) { } else if (readAttribMore2 (key, *cell, ferr)) { } else { - if (fwhole) { +// if (fwhole) { + if (mode == M_ATTRIB) { wiki->errorMsg.append (cell->dump ()).append (CharConst (": bad attribute.\n")); rc = false; } @@ -84,7 +87,8 @@ bool WikiAttrib1::shiftAttrib (WikiMotorObjVecPtr& vec) { WikiMotorObjVec cell; v2 = WikiMotorObjVecPtr (new WikiMotorObjVec); - if (vec->splitChar (':', cell, *v2) || fwhole) { +// if (vec->splitChar (':', cell, *v2) || fwhole) { + if (vec->splitChar (':', cell, *v2) || mode == M_ATTRIB || mode == M_ATTRIB_TEXT) { if (! readAttrib1 (&cell, rc)) return rc; vec = v2; @@ -503,12 +507,16 @@ bool WikiAttribButton::readAttrib (WikiMotorObjVecVec::const_iterator& b, const if (b < e) { WikiMotorObjVec* cell = b->get (); - bool bf = fwhole; - fwhole = false; +// bool bf = fwhole; +// fwhole = false; + mode_t bm = mode; + + mode = M_NORMAL; if (! readAttrib1 (cell, rc)) { name = cell->textOut (wiki); } - fwhole = bf; +// fwhole = bf; + mode = bm; b ++; } while (b < e) { diff --git a/wiki/wikiattrib.h b/wiki/wikiattrib.h index 0e1107c..ba26c7e 100644 --- a/wiki/wikiattrib.h +++ b/wiki/wikiattrib.h @@ -19,9 +19,15 @@ class WikiAttrib1 { static const uint32_t SEL_DEFAULT2 = 0x0080; static const uint32_t SEL_MULTIPLE2 = 0x0100; static const uint32_t SEL_SCRIPT2 = 0x0200; + typedef enum { + M_NORMAL, + M_ATTRIB, + M_ATTRIB_TEXT, + } mode_t; uint32_t selector; - bool fwhole; +// bool fwhole; + mode_t mode; WikiFormat* wiki; bool ferr; ustring id; @@ -36,10 +42,12 @@ class WikiAttrib1 { bool fdefault; /* no output */ ustring script; /* no output */ - WikiAttrib1 (WikiFormat* _wiki, uint32_t _selector, bool _fwhole = false) { +// WikiAttrib1 (WikiFormat* _wiki, uint32_t _selector, bool _fwhole = false) { + WikiAttrib1 (WikiFormat* _wiki, uint32_t _selector, mode_t _mode = M_NORMAL) { wiki = _wiki; selector = _selector; - fwhole = _fwhole; +// fwhole = _fwhole; + mode = _mode; // elsize = 0; fdefault = false; fmultiple = false; @@ -100,7 +108,8 @@ class WikiAttribTable: public WikiAttrib1 { bool fnowhite; bool fturn; - WikiAttribTable (WikiFormat* _wiki, selector_t _selector2, bool _inheader): WikiAttrib1 (_wiki, SEL_ID, _inheader) { +// WikiAttribTable (WikiFormat* _wiki, selector_t _selector2, bool _inheader): WikiAttrib1 (_wiki, SEL_ID, _inheader) { + WikiAttribTable (WikiFormat* _wiki, selector_t _selector2, mode_t _mode): WikiAttrib1 (_wiki, SEL_ID, _mode) { selector2 = _selector2; init (); }; @@ -119,7 +128,8 @@ class WikiAttribImg: public WikiAttrib1 { ustring height; ustring alt; - WikiAttribImg (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_ID, true) {}; +// WikiAttribImg (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_ID, true) {}; + WikiAttribImg (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_ID, M_ATTRIB) {}; virtual ~WikiAttribImg () {}; private: virtual bool readAttribMore (const ustring& key, WikiMotorObjVec& vval, bool& ferr); @@ -145,8 +155,8 @@ class WikiAttribInput: public WikiAttrib1 { W_OFF, W_SOFT, W_HARD, } pwrap; -// WikiAttribInput (WikiFormat* _wiki, uint32_t _sel2): WikiAttrib1 (_wiki, SEL_ID, true) { - WikiAttribInput (WikiFormat* _wiki, uint32_t _sel2): WikiAttrib1 (_wiki, SEL_MULTIPLE2, true) { +// WikiAttribInput (WikiFormat* _wiki, uint32_t _sel2): WikiAttrib1 (_wiki, SEL_MULTIPLE2, true) { + WikiAttribInput (WikiFormat* _wiki, uint32_t _sel2): WikiAttrib1 (_wiki, SEL_MULTIPLE2, M_ATTRIB) { selector2 = _sel2; elsize = 0; pdefault = false; @@ -164,7 +174,8 @@ class WikiAttribButton: public WikiAttrib1 { public: ustring name; - WikiAttribButton (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_SCRIPT2, true) {}; +// WikiAttribButton (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_SCRIPT2, true) {}; + WikiAttribButton (WikiFormat* _wiki): WikiAttrib1 (_wiki, SEL_SCRIPT2, M_ATTRIB) {}; virtual ~WikiAttribButton () {}; virtual bool readAttrib (WikiMotorObjVecVec::const_iterator& b, const WikiMotorObjVecVec::const_iterator& e); }; diff --git a/wiki/wikiformat.cc b/wiki/wikiformat.cc index 80c316e..462e5f0 100644 --- a/wiki/wikiformat.cc +++ b/wiki/wikiformat.cc @@ -856,13 +856,15 @@ void WikiBlockTable::addLine_head (uiterator b, uiterator e) { objvv.pop_back (); attrib.shiftAttrib (objvv[0]); - cell = new TableCell (wiki, false); +// cell = new TableCell (wiki, false); + cell = new TableCell (wiki, WikiAttrib1::M_NORMAL); cell->cellBody (objvv[0].get (), this, 0); captionHtml = cell->html; delete cell; for (i = 1; i < objvv.size (); i ++) { - cell = new TableCell (wiki, true); +// cell = new TableCell (wiki, true); + cell = new TableCell (wiki, WikiAttrib1::M_ATTRIB); cell->cellattrib.shiftAttrib (objvv[i]); defaultList.push_back (cell); } @@ -962,7 +964,8 @@ void WikiBlockTable::addLine_body (uiterator b, uiterator e) { } WikiBlockTable::TableCell* WikiBlockTable::newCell (int idx) { - TableCell* ans = new TableCell (wiki, false); +// TableCell* ans = new TableCell (wiki, false); + TableCell* ans = new TableCell (wiki, WikiAttrib1::M_NORMAL); if (idx < defaultList.size ()) ans->cellattrib.copyFrom (defaultList[idx].cellattrib); @@ -970,7 +973,8 @@ WikiBlockTable::TableCell* WikiBlockTable::newCell (int idx) { } WikiBlockTable::TableCell* WikiBlockTable::newCell (WikiAttribTable& rowattrib) { - TableCell* ans = new TableCell (wiki, false); +// TableCell* ans = new TableCell (wiki, false); + TableCell* ans = new TableCell (wiki, WikiAttrib1::M_NORMAL); ans->cellattrib.copyFrom (rowattrib); return ans; diff --git a/wiki/wikiformat.h b/wiki/wikiformat.h index b8453a2..23eecb7 100644 --- a/wiki/wikiformat.h +++ b/wiki/wikiformat.h @@ -314,7 +314,8 @@ class WikiBlockTable: public WikiBlock { int colspan; bool spanmatch; - TableCell (WikiFormat* _wiki, bool inheader): cellattrib (_wiki, WikiAttribTable::SEL_TD, inheader) { +// TableCell (WikiFormat* _wiki, bool inheader): cellattrib (_wiki, WikiAttribTable::SEL_TD, inheader) { + TableCell (WikiFormat* _wiki, WikiAttrib1::mode_t _mode): cellattrib (_wiki, WikiAttribTable::SEL_TD, _mode) { fcolspan = false; frowspan = false; rowspan = 1; @@ -332,7 +333,8 @@ class WikiBlockTable: public WikiBlock { public: WikiAttribTable rowattrib; - CellList_t (WikiFormat* _wiki): rowattrib (_wiki, WikiAttribTable::SEL_TR, true) {}; +// CellList_t (WikiFormat* _wiki): rowattrib (_wiki, WikiAttribTable::SEL_TR, true) {}; + CellList_t (WikiFormat* _wiki): rowattrib (_wiki, WikiAttribTable::SEL_TR, WikiAttrib1::M_ATTRIB) {}; virtual ~CellList_t () {}; }; typedef boost::ptr_vector TableAry_t; @@ -345,7 +347,8 @@ class WikiBlockTable: public WikiBlock { TableAry_t ary; ustring captionHtml; - WikiBlockTable (WikiFormat* _wiki): WikiBlock (BlockTable, _wiki), attrib (_wiki, WikiAttribTable::SEL_TABLE, false), defaultList (_wiki) { +// WikiBlockTable (WikiFormat* _wiki): WikiBlock (BlockTable, _wiki), attrib (_wiki, WikiAttribTable::SEL_TABLE, true), defaultList (_wiki) { + WikiBlockTable (WikiFormat* _wiki): WikiBlock (BlockTable, _wiki), attrib (_wiki, WikiAttribTable::SEL_TABLE, WikiAttrib1::M_ATTRIB_TEXT), defaultList (_wiki) { n = 0; cont = false; ccont = 0; @@ -416,7 +419,8 @@ class WikiBlockDiv: public WikiBlockComplex { public: WikiAttrib1 attrib; - WikiBlockDiv (WikiFormat* w): WikiBlockComplex (BlockDiv, w), attrib (w, WikiAttrib1::SEL_CLASS2, true) {}; +// WikiBlockDiv (WikiFormat* w): WikiBlockComplex (BlockDiv, w), attrib (w, WikiAttrib1::SEL_CLASS2, true) {}; + WikiBlockDiv (WikiFormat* w): WikiBlockComplex (BlockDiv, w), attrib (w, WikiAttrib1::SEL_CLASS2, WikiAttrib1::M_ATTRIB) {}; virtual ~WikiBlockDiv () {}; virtual bool nextLine (uiterator b, uiterator e); @@ -437,7 +441,8 @@ class WikiBlockForm: public WikiBlockComplex { bool fscript; bool qfileform; - WikiBlockForm (WikiFormat* w): WikiBlockComplex (BlockForm, w), attrib (w, WikiAttrib1::SEL_TARGET, true) { +// WikiBlockForm (WikiFormat* w): WikiBlockComplex (BlockForm, w), attrib (w, WikiAttrib1::SEL_TARGET, true) { + WikiBlockForm (WikiFormat* w): WikiBlockComplex (BlockForm, w), attrib (w, WikiAttrib1::SEL_TARGET, WikiAttrib1::M_ATTRIB) { method = M_NONE; fscript = false; qfileform = false; diff --git a/wiki/wikiline.cc b/wiki/wikiline.cc index ad6e403..9169120 100644 --- a/wiki/wikiline.cc +++ b/wiki/wikiline.cc @@ -168,7 +168,8 @@ bool wl_bolditalic (WikiMotorObjVec* arg2, WikiMotorObjVec& out, WikiFormat* wi static bool wl_http_sub (bool newwin, WikiMotorObjVecVec* args, WikiMotorObjVec* arg2, WikiMotorObjVec& out, WikiFormat* wiki) { ustring url; bool fscript = false; - WikiAttrib1 attrib (wiki, WikiAttrib1::SEL_TARGET | WikiAttrib1::SEL_TARGET2, true); +// WikiAttrib1 attrib (wiki, WikiAttrib1::SEL_TARGET | WikiAttrib1::SEL_TARGET2, true); + WikiAttrib1 attrib (wiki, WikiAttrib1::SEL_TARGET | WikiAttrib1::SEL_TARGET2, WikiAttrib1::M_ATTRIB); WikiMotorObjVecVec::const_iterator b = args->begin (); WikiMotorObjVecVec::const_iterator e = args->end (); MotorOutputString html; @@ -358,7 +359,8 @@ bool wl_anchor (WikiMotorObjVec* arg, WikiMotorObjVec& out, WikiFormat* wiki) { bool wl_span (WikiMotorObjVecVec* args, WikiMotorObjVec* arg2, WikiMotorObjVec& out, WikiFormat* wiki) { WikiMotorObjVecVec::const_iterator b = args->begin (); WikiMotorObjVecVec::const_iterator e = args->end (); - WikiAttrib1 attrib (wiki, WikiAttrib1::SEL_CLASS2, true); +// WikiAttrib1 attrib (wiki, WikiAttrib1::SEL_CLASS2, true); + WikiAttrib1 attrib (wiki, WikiAttrib1::SEL_CLASS2, WikiAttrib1::M_ATTRIB); MotorOutputString html; if (! attrib.readAttrib (b, e)) -- 2.11.0