OSDN Git Service

bug fix.
authorvisor <visor@users.sourceforge.jp>
Wed, 26 Mar 2014 15:24:46 +0000 (00:24 +0900)
committervisor <visor@users.sourceforge.jp>
Wed, 26 Mar 2014 15:24:46 +0000 (00:24 +0900)
20 files changed:
lib/app.cc
lib/app.h
lib/http.cc
lib/ml.cc
lib/mlenv.h
lib/motorenv.cc
lib/motorenv.h
lib/motoroutput.cc
lib/util_string.cc
lib/util_tcp.cc
lib/util_tcp.h
modules/ml-http.cc
modules/ml-imagesize.cc
modules/ml-include.cc
modules/ml-struct.cc
wiki/wikiattrib.cc
wiki/wikicmd.cc
wiki/wikiformat.cc
wiki/wikiformat.h
wiki/wikimotor.cc

index 7347e9d..375beab 100644 (file)
@@ -155,9 +155,11 @@ void  AppEnv::setDefault () {
        cacheControl = CC_COOKIE;
 }
 
+#if 0
 ustring  AppEnv::scriptName () {
     return getenvString (kSCRIPT_FILENAME);
 }
+#endif
 
 void  AppEnv::dump (std::ostream& out) {
     out << arg0 << "\n";
@@ -209,6 +211,7 @@ void  AppEnv::dump (std::ostream& out) {
     case CC_NOCACHE:
        out << "        no-cache\n";
        break;
+    default:;
     }
     switch (frameOpt) {
     case FOPT_NONE:
index 7a3a2d7..e0b8f01 100644 (file)
--- a/lib/app.h
+++ b/lib/app.h
@@ -48,7 +48,7 @@ class  AppEnv {
 
     virtual void  readOption (int argc, char** argv, MotorEnv* env);
     virtual void  setDefault ();
-    virtual ustring  scriptName ();
+//    virtual ustring  scriptName ();
     virtual void  dump (std::ostream& out);
     virtual void  setErrorLog (const ustring& path, bool fappend = false);
 };
index 6b84a5a..dc2a443 100644 (file)
@@ -576,7 +576,7 @@ void  HTTPSend::writeQueryForm (MNode* e, TcpClient& out) {
 
     if (e && e->isCons ()) {
        while (e) {
-           if (a = e->car ()) {
+           if ((a = e->car ())) {
                ustring  u;
                if (c > 0)
                    u.append (uAmp);
@@ -599,7 +599,7 @@ void  HTTPSend::appendQueryForm (MNode* e, ustring& out) {
 
     if (e && e->isCons ()) {
        while (e) {
-           if (a = e->car ()) {
+           if ((a = e->car ())) {
                if (c > 0)
                    out.append (uAmp);
                out.append (percentEncode (cv (to_string (a->car ()))));
@@ -621,7 +621,7 @@ size_t  HTTPSend::queryFormSize (MNode* e) {
 
     if (e && e->isCons ()) {
        while (e) {
-           if (a = e->car ()) {
+           if ((a = e->car ())) {
                if (c > 0)
                    ans += uAmp.length ();
                ans += percentEncode (cv (to_string (a->car ()))).length ();
@@ -654,7 +654,7 @@ size_t  HTTPSend::writeFileForm (TcpClient* out, MlEnv* mlenv) {
     e = params ();
     if (e && e->isCons ()) {
        while (e) {
-           if (a = e->car ()) {
+           if ((a = e->car ())) {
                name = to_string (a->car ());
                val = to_string (a->cdr ());
                ans += writeFileFormPart_text (out, name, val);
@@ -667,7 +667,7 @@ size_t  HTTPSend::writeFileForm (TcpClient* out, MlEnv* mlenv) {
     e = fileparams_store ();
     if (e && e->isCons ()) {
        while (e) {
-           if (a = e->car ()) {
+           if ((a = e->car ())) {
                name = to_string (a->car ());
                val = to_string (a->cdr ());
                path = mlenv->env->path_store_file (val);
@@ -681,7 +681,7 @@ size_t  HTTPSend::writeFileForm (TcpClient* out, MlEnv* mlenv) {
     e = fileparams_storage ();
     if (e && e->isCons ()) {
        while (e) {
-           if (a = e->car ()) {
+           if ((a = e->car ())) {
                name = to_string (a->car ());
                val = to_string (a->cdr ());
                path = mlenv->env->path_storage_file (val);
@@ -695,7 +695,7 @@ size_t  HTTPSend::writeFileForm (TcpClient* out, MlEnv* mlenv) {
     e = fileparams_static ();
     if (e && e->isCons ()) {
        while (e) {
-           if (a = e->car ()) {
+           if ((a = e->car ())) {
                name = to_string (a->car ());
                val = to_string (a->cdr ());
                path = mlenv->env->path_static_file (val);
@@ -797,7 +797,6 @@ size_t  HTTPSend::writeFile (TcpClient* out, const ustring& path) {
 
 int  HTTPSend::readReplyHead (TcpClient& client, TcpBuf& buf) {
     ustring  line;
-    bool  rc;
     uiterator  b, e, m1, m2;
 
     if (status != HTTP_QUERY)
@@ -813,7 +812,7 @@ int  HTTPSend::readReplyHead (TcpClient& client, TcpBuf& buf) {
        ustring::size_type  p2 = line.find (' ', p1 + 1);
        responseCode = strtoul (line.substr (p1 + 1, p2));
     }
-    while (rc = buf.getln (client, line)) {
+    while (buf.getln (client, line)) {
        if (line.empty ())
            break;
        // ヘッダ内の制御文字は削除されるが,ヘッダ名の大小文字は保存される。
index 37cac80..49c79d8 100644 (file)
--- a/lib/ml.cc
+++ b/lib/ml.cc
@@ -45,6 +45,7 @@ void  MNode::fdelete () {
        delete sym;
        sym = NULL;
        break;
+    default:;
     }
     type = MC_DELETED;
 }
index 12ecfa1..31f0c4e 100644 (file)
@@ -123,7 +123,7 @@ class  MlEnv {
        mlPool->setStartTime ();
     };
     virtual bool  qtimeup () {
-       mlPool->qtimeup (log);
+       return mlPool->qtimeup (log);
     };
     virtual void  resetProg () {
        mlPool->resetProg ();
@@ -135,7 +135,7 @@ class  MlEnv {
        mlPool->inclIncCount ();
     };
     virtual bool  inclIncCount_nothrow () {
-       mlPool->inclIncCount_nothrow ();
+       return mlPool->inclIncCount_nothrow ();
     };
     virtual void  declIncCount () {
        mlPool->declIncCount ();
index 620cbc5..168cc28 100644 (file)
@@ -26,7 +26,7 @@ MotorEnv::MotorEnv (AppEnv* ae, CGIFormFile* fm, HTMLMotor* m, MotorOutput* out)
     output = out;
     wikioutput = NULL;
     log = &std::cerr;
-    setRequestEnv ();
+//    setRequestEnv ();
     mlPool = new MlPool;
     mlFTable = new MlFTable;
     mlenv = new MlEnv (mlPool, mlFTable);
@@ -39,6 +39,9 @@ MotorEnv::MotorEnv (AppEnv* ae, CGIFormFile* fm, HTMLMotor* m, MotorOutput* out)
     errflag = false;
     responseDone = false;
     currentPath = NULL;
+    scriptName = getenvString (kSCRIPT_NAME);
+    documentRoot = getenvString (kDOCUMENT_ROOT);
+    scriptFilename = getenvString (kSCRIPT_FILENAME);
 }
 
 MotorEnv::~MotorEnv () {
@@ -48,9 +51,11 @@ MotorEnv::~MotorEnv () {
     delete mlFTable;
 }
 
+#if 0
 void  MotorEnv::setRequestEnv () {
     scriptName = getenvString (kSCRIPT_NAME);
 }
+#endif
 
 void  MotorEnv::setErrorFlag () {
 //    mlenv->breakProg ();
@@ -72,6 +77,7 @@ void  MotorEnv::setErrorVar (const ustring& name) {
 bool  MotorEnv::getErrorVar (const ustring& name) {
     if (mlenv->validName (name))
        return errorvar.getVar (name);
+    return false;
 }
 
 void  MotorEnv::motorItem (const ustring& name) {
@@ -90,7 +96,6 @@ void  MotorEnv::motorText (const ustring& text) {
 
 bool  MotorEnv::path_resource (const ustring& name, ustring& ans) {
     ustring  r;
-    ustring  root = getenvString (kDOCUMENT_ROOT);
     ustring  top;
 
 #ifdef cDocTop
@@ -100,7 +105,7 @@ bool  MotorEnv::path_resource (const ustring& name, ustring& ans) {
        top.assign (CharConst (cDocTop));
     }
 #else
-    top = root;
+    top = documentRoot;
 #endif
     
     if (isAbsolutePath (name)) {
@@ -125,7 +130,7 @@ bool  MotorEnv::path_resource (const ustring& name, ustring& ans) {
     } else {
        /* name is a relative path. */
        if (currentPath == NULL) {
-           r = getenvString (kSCRIPT_FILENAME);
+           r = scriptFilename;
        } else {
            r = *currentPath;
        }
@@ -164,8 +169,8 @@ bool  MotorEnv::path_resource (const ustring& name, ustring& ans) {
 #ifdef DEBUG
 //     std::cerr << "searchName:" << r << "\n";
 #endif /* DEBUG */
-       if (root.length () > 0 && r.length () > 0) {
-           r = root + uSlash + r + uSlash + name;
+       if (documentRoot.length () > 0 && r.length () > 0) {
+           r = documentRoot + uSlash + r + uSlash + name;
            shapePath (r);
            if (matchHead (r, top) && checkAbsoluteResourceName (r) && isPlainFile (r)) {
                ans = r;
@@ -315,6 +320,7 @@ void  MotorEnv::setDefault () {
     case CGIForm::M_NONE:
        htmlFile = appenv->getHtml;
        break;
+    default:;
     }
     errorHtmlFile = appenv->errorHtml;
     mimetype = appenv->mimetype;
@@ -374,6 +380,7 @@ void  MotorEnv::readFormVar () {
                form->read_post (appenv->postlimit);
            }
            break;
+       default:;
        }
     }
 }
@@ -414,7 +421,6 @@ void  MotorEnv::doML () {
 
 void  MotorEnv::doML (const ustring& file) {
     ustring  b;
-    ustring  f;
     bool  rc;
     bool  dash;
 
@@ -422,18 +428,19 @@ void  MotorEnv::doML (const ustring& file) {
        return;
 
     if (file == uDash) {
-       f = appenv->scriptName ();
-       if (f.size () == 0)
+       if (scriptFilename.size () == 0)
            return;
-       rc = readFile (f, b);
+       rc = readFile (scriptFilename, b);
        dash = true;
     } else {
+       ustring  f;
        if (! path_resource (file, f))
            return;
        rc = readFile (f, b);
        dash = false;
     }
     if (rc) {
+       ustring  f;
        MotorSexp  ml (mlenv);
        AutoBackupPtr<ustring>  autoStr (&currentPath, &f);
 
@@ -473,10 +480,9 @@ void  MotorEnv::doMotor (const ustring& file, const ustring& type, MotorOutput*
     ustring  f;
 
     if (file == uDash) {
-       f = appenv->scriptName ();
-       if (f.size () == 0)
+       if (scriptFilename.size () == 0)
            return;
-       doMotorFile (f, true, type, out);
+       doMotorFile (scriptFilename, true, type, out);
     } else if (path_resource (file, f)) {
        if (f.size () == 0)
            return;
index 5c56e50..28b57ac 100644 (file)
@@ -29,7 +29,6 @@ class  MotorEnv {
     WikiMotorOutputString*  wikioutput;
     HTTPResponse  http;
 
-    ustring  scriptName;
     ustring  datastore;
     ustring  htmlFile;
     ustring  errorHtmlFile;
@@ -46,11 +45,14 @@ class  MotorEnv {
     bool  responseDone;
     std::ostream*  log;
     ustring*  currentPath;
+    ustring  scriptName;
+    ustring  documentRoot;
+    ustring  scriptFilename;
 
     MotorEnv (AppEnv* ae, CGIFormFile* fm, HTMLMotor* m, MotorOutput* out);
     virtual  ~MotorEnv ();
 
-    virtual void  setRequestEnv ();
+//    virtual void  setRequestEnv ();
     virtual void  setErrorFlag ();
     virtual void  setErrorVar (const ustring& name);
     virtual bool  getErrorVar (const ustring& name);
index c165686..9d0217c 100644 (file)
@@ -139,10 +139,12 @@ MotorOutput*  MotorOutput::outamp_nw (const ustring& t) {
     } else {
        outNbsp ();
     }
+    return this;
 }
 
 MotorOutput*  MotorOutput::outamp_c3 (const ustring& t) {
     outamp (c3 (t));
+    return this;
 }
 
 /* ============================================================ */
index 7bbdaca..b560866 100644 (file)
@@ -126,7 +126,7 @@ static int  hex (char c1, char c2) {
 static char  hexchar (int c) {
     if (0 <= c && c <= 9)
        return '0' + c;
-    else if (10 <= c <= 15)
+    else if (10 <= c && c <= 15)
        return 'a' - 10 + c;
     else
        return '0';
@@ -135,7 +135,7 @@ static char  hexchar (int c) {
 static char  hexchar_c (int c) {
     if (0 <= c && c <= 9)
        return '0' + c;
-    else if (10 <= c <= 15)
+    else if (10 <= c && c <= 15)
        return 'A' - 10 + c;
     else
        return '0';
index 5104834..e42d4b9 100644 (file)
@@ -506,7 +506,7 @@ ssize_t  SslClient::write2 (struct iovec* iov, int iovcnt) {
     if (sslmode) {
        return SSL_write(ssl.get (), iov->iov_base, iov->iov_len);
     } else {
-       TcpClient::write2 (iov, iovcnt);
+       return TcpClient::write2 (iov, iovcnt);
     }
 }
 
@@ -514,7 +514,7 @@ ssize_t  SslClient::read2 (void* buf, size_t nbytes) {
     if (sslmode) {
        return SSL_read (ssl.get (), buf, nbytes);
     } else {
-       TcpClient::read2 (buf, nbytes);
+       return TcpClient::read2 (buf, nbytes);
     }
 }
 
@@ -548,7 +548,6 @@ int  ProxySslClient::readReplyHead () {
     TcpBuf  buf;
     ustring  line;
     int  responseCode = 0;
-    int  rc;
     umatch  m;
     static uregex  re_crlf ("\\r\\n");
 
@@ -564,7 +563,7 @@ int  ProxySslClient::readReplyHead () {
        ustring::size_type  p1 = line.find (' ', 0);
        ustring::size_type  p2 = line.find (' ', p1 + 1);
        responseCode = strtoul (line.substr (p1 + 1, p2));
-       while (rc = buf.getln2 (*this, line)) {
+       while (buf.getln2 (*this, line)) {
            // XXX
            if (line.empty ())
                break;
index d89bf2c..e523491 100644 (file)
@@ -192,7 +192,7 @@ class  SslClient: public TcpClient {
     const HostSpec*  ephost;
     SSL_autoptr  ssl;
     SSL_CTX_autoptr  ssl_ctx;
-    SSL_METHOD*  ssl_meth;
+    const SSL_METHOD*  ssl_meth;
     bool  fnoverify;
     bool  sslmode;
 
index 733a642..c92f133 100644 (file)
@@ -107,7 +107,7 @@ static void  request_cookie (MNode* cookie, HTTPSend* http) {
 
     if (cookie && cookie->isCons ()) {
        while (cookie) {
-           if (a = cookie->car ()) {
+           if ((a = cookie->car ())) {
                if (a->isCons ()) {
                    http->cookie.push_back (HTTPSend::mapelem (to_string (a->car ()), to_string (a->cdr ())));
                } else {
@@ -129,7 +129,7 @@ static void  request_headerquery (MNode* headerquery, HTTPSend* http) {
 
     if (headerquery && headerquery->isCons ()) {
        while (headerquery) {
-           if (a = headerquery->car ()) {
+           if ((a = headerquery->car ())) {
                if (a->isCons ()) {
                    http->header_req.push_back (HTTPSend::mapelem (to_string (a->car ()), to_string (a->cdr ())));
                } else {
@@ -494,7 +494,7 @@ MNode*  ml_build_query (MNode* cell, MlEnv* mlenv) {
     e = query ();
     if (e && e->isCons ()) {
        while (e) {
-           if (a = e->car ()) {
+           if ((a = e->car ())) {
                if (c > 0)
                    ans.append (uAmp);
                ans.append (percentEncode (to_string (a->car ())));
index 0e3797a..53a6614 100644 (file)
@@ -57,6 +57,7 @@ static bool  jpegSize (ustring* data, size_t& x, size_t& y) {
        }
        csr.skip (n - 2);
     }
+    return false;
 }
 
 static bool  pngSize (ustring* data, size_t& x, size_t& y) {
index 83a246f..af017cd 100644 (file)
@@ -40,9 +40,7 @@ MNode*  ml_include (MNode* cell, MlEnv* mlenv) {
            ustring  b;
            bool  rc;
 
-//         if (fforce || ! mlenv->includedFile.get (f)) {
            if (fforce || ! mlenv->includedFile (f)) {
-//             mlenv->includedFile.set (f);
                mlenv->setIncludedFile (f);
                rc = readFile (f, b);
                if (rc) {
@@ -56,7 +54,6 @@ MNode*  ml_include (MNode* cell, MlEnv* mlenv) {
                    std::cerr << "\n";
 #endif /* DEBUG */
                    autoIncl.inc ();
-//                 mlenv->inclIncCount ();
                    if (ml.top.isCons ()) {
                        ans = progn (&ml.top, mlenv);
                        if (mlenv->breaksym ()) {
@@ -64,7 +61,6 @@ MNode*  ml_include (MNode* cell, MlEnv* mlenv) {
                            rest = NULL;
                        }
                    }
-//                 mlenv->declIncCount ();
                } else {
                    throw (file + uErrorNotFound);
                }
index 1e761cf..eeeba98 100644 (file)
@@ -22,6 +22,7 @@ static MNode*  symquote (MNode* v) {
        case MNode::MC_CONS:
            v = newMNode_quote (v);
            break;
+       default:;
        }
     }
     return v;
index ab3f13f..1ae61ad 100644 (file)
@@ -544,6 +544,7 @@ void  WikiAttribTable::outputMore (MotorOutput* out) {
     case HAlignRight:
        out->out_raw (CharConst (" align=\"right\""));
        break;
+    default:;
     }
     wiki->outputName (out, CharConst ("width"), width);
     wiki->outputName (out, CharConst ("height"), height);
@@ -569,6 +570,7 @@ void  WikiAttribTable::outputMore (MotorOutput* out) {
        case VAlignBottom:
            out->out_raw (CharConst (" valign=\"bottom\""));
            break;
+       default:;
        }
        wiki->outputFlag (out, CharConst ("nowrap"), fnowrap);
        break;
index e05c452..7cac87c 100644 (file)
@@ -841,7 +841,7 @@ void  wc_call_defun (WikiLine* wl, WikiFormat* wiki) {
 
     if (fx && (wf = wiki->env->wikienv->wikiCmd.getVar (name))) { // Wiki Command
        call_defun_wikicmd (name, wf, objv2, wl, wiki);
-    } else if (mf = wiki->env->wikienv->wikiMacro.getVar (name)) { // Wiki Macro. macroは誰でも実行できる。
+    } else if ((mf = wiki->env->wikienv->wikiMacro.getVar (name))) { // Wiki Macro. macroは誰でも実行できる。
 //     std::cerr << "macro:" << name << "\n";
        call_defun_macro (name, mf, objv2, wl, wiki);
     } else {                   // 処理なし
index 28cfbea..ad2d0ab 100644 (file)
@@ -272,8 +272,10 @@ WikiBlock::closeType  WikiBlockH::closeLine (uiterator b, uiterator e) {
                            wiki->cur->close ();
                        wiki->cur = NULL;
                        return CloseTrue;
+                   default:;
                    }
                }
+           default:;
            }
        }
        // no opening point.
@@ -1692,6 +1694,7 @@ bool  WikiFormat::checkClose (uiterator b, uiterator e) {
            return true;
        case WikiBlock::CloseFalse:
            return false;
+       default:;
        }
     }
     return false;
@@ -1834,7 +1837,7 @@ void  WikiFormat::compileLine (WikiLineScanner& scanner) {
 void  WikiFormat::compileLines (WikiLineScanner& scanner, bool (*fn)(WikiLine& spp, WikiLineScanner& scanner, WikiFormat* wiki, void* par), void* par) {
     WikiLine*  wl;
 
-    while (wl = scanner.next ()) {
+    while ((wl = scanner.next ())) {
        if (fn && fn (*scanner.cur (), scanner, this, par)) {
            break;
        } else {
index 33b3966..b2b0835 100644 (file)
@@ -556,7 +556,7 @@ class  WikiFormat {
 
     virtual bool  checkClose (uiterator b, uiterator e);
     virtual void  compileLine (WikiLineScanner& scanner);
-    virtual void  compileLines (WikiLineScanner& scanner, bool (*fn)(WikiLine& spp, WikiLineScanner& scanner, WikiFormat* wiki, void* par) = false, void* par = false);
+    virtual void  compileLines (WikiLineScanner& scanner, bool (*fn)(WikiLine& spp, WikiLineScanner& scanner, WikiFormat* wiki, void* par) = NULL, void* par = NULL);
     virtual void  pushBlockRaw (uiterator b, uiterator e);
     virtual void  push_block (boost::ptr_vector<WikiBlock>* b) {
        bstack.push_back (cur);
index 7d9df96..18c4fe3 100644 (file)
@@ -313,6 +313,7 @@ bool  WikiMotorObjVec::splitChar_keyword (WikiFormat* wiki, ustring::value_type
     WikiMotorObjVec  v;
     bool  ans = splitChar_keyword (ch, name, v);
     value = v.textOut (wiki);
+    return ans;
 }
 
 bool  WikiMotorObjVec::splitChar (WikiFormat* wiki, ustring::value_type ch, ustring& name, ustring& value) {
@@ -1445,6 +1446,7 @@ void  WikiMotor::compile_7 (WikiMotorObjVec& out, const ustring& name) {  // [[NA
                sp.shiftCursor ();
            }
            return;
+       default:;
        }
     } else if ((wd = wiki->env->wikienv->wikiFunc2.getVar (name))) {
        WikiMotorObjFuncM2*  obj = new WikiMotorObjFuncM2 (name, wd);