OSDN Git Service

misc update.
authorvisor <visor@users.sourceforge.jp>
Sun, 4 Dec 2011 13:49:21 +0000 (22:49 +0900)
committervisor <visor@users.sourceforge.jp>
Sun, 4 Dec 2011 13:49:21 +0000 (22:49 +0900)
modules/ml-http.cc
modules/ml-store.cc
wiki/wikiattrib.cc
wiki/wikimotor.cc
wiki/wikimotor.h

index d9e6661..b7f702e 100644 (file)
@@ -208,25 +208,43 @@ static void  request_headerquery (MNode* headerquery, HTTPSend* http) {
 */
 /*DOC:
 ===error===
- (error [#continue | :continue BOOL]) -> NIL
+ (error [#continue | :continue BOOL] [:error-var VARIABLE]) -> NIL
 
 */
 //#AFUNC       error   ml_error
 MNode*  ml_error (MNode* cell, MlEnv* mlenv) {
     MNode*  arg = cell->cdr ();
     bool  cflag = false;
+    MNodePtr  ev;
     std::vector<MNode*>  params;
     std::vector<MNode*>  keywords;
     static paramList  kwlist[] = {
        {CharConst ("continue"), true},
+       {CharConst ("error-var"), false},
        {NULL, 0, 0}
     };
 
     setParams (arg, 0, &params, kwlist, &keywords, NULL);
     if (keywords[0] && eval_bool (keywords[0], mlenv))
        cflag = true;
+    if (keywords[1]) {
+       ev = eval (keywords[1], mlenv);
+    }
 
-    mlenv->env->setErrorFlag ();
+    if (mlenv->env) {
+       mlenv->env->setErrorFlag ();
+       if (ev ()) {
+           if (ev ()->isCons ()) {
+               MNode*  a = ev ();
+               while (a && a->isCons ()) {
+                   mlenv->env->setErrorVar (to_string (a->car ()));
+                   nextNode (a);
+               }
+           } else {
+               mlenv->env->setErrorVar (to_string (ev ()));
+           }
+       }
+    }
 
     if (! cflag)
        mlenv->breakProg ();
index 80fd39f..877193a 100644 (file)
@@ -1131,7 +1131,11 @@ public:
        }
 
        if (type.empty ()) {
-           type = mimetype (getExt (filename));
+           if (! fmotor && dispname.length () > 0) {
+               type = mimetype (getExt (dispname));
+           } else {
+               type = mimetype (getExt (filename));
+           }
        } else if (! checkMimeType (type)) {
            type = mimetype (type);
        }
index 7041c5d..0aee5c9 100644 (file)
@@ -184,6 +184,7 @@ bool  WikiAttrib1::readLink (WikiMotorObjVecVec::const_iterator& b, const WikiMo
     bool  ferr = false;
     bool  rc;
     WikiMotorObjVec*  cell;
+    static uregex  re (CharConst ("^[a-z]{3,6}$"));
 
     if (b == e)
        return false;
@@ -193,7 +194,8 @@ bool  WikiAttrib1::readLink (WikiMotorObjVecVec::const_iterator& b, const WikiMo
        fscript = true;
        b ++;
        return true;
-    } else if (rc && cell->match (CharConst ("http"), CharConst ("https"))) {
+//    } else if (rc && cell->match (CharConst ("http"), CharConst ("https"))) {
+    } else if (rc && cell->regmatch (re)) {
        ustring  proto = cell->dump ();
        b ++;
        cell = b->get ();
index 8c9856c..bed654e 100644 (file)
@@ -165,6 +165,14 @@ bool  WikiMotorObjVec::matchHead (const char* t, size_t s) {
     return false;
 }
 
+bool  WikiMotorObjVec::regmatch (const uregex& re) {
+    if (size () == 1) {
+       WikiMotorObj*  a = operator [] (0).get ();
+       return a->regmatch (re);
+    }
+    return false;
+}
+
 void  WikiMotorObjVec::splitCharA (ustring::value_type ch, WikiMotorObjVecVec& out) {
     int  i;
     WikiMotorObjVecPtr  v;
index a8a3e16..1703d09 100644 (file)
@@ -33,6 +33,7 @@ class  WikiMotorObjVec: public std::vector<WikiMotorObjPtr> {
     virtual bool  match (const ustring& t);
     virtual bool  match (const ustring& t1, const ustring& t2);
     virtual bool  matchHead (const char* t, size_t s);
+    virtual bool  regmatch (const uregex& re);
     virtual void  splitCharA (ustring::value_type ch, WikiMotorObjVecVec& out);
     virtual bool  splitChar_keyword (ustring::value_type ch, ustring& name, WikiMotorObjVec& vvalue);
     virtual ustring::value_type  splitChar_keyword (ustring::value_type ch1, ustring::value_type ch2, ustring& name, WikiMotorObjVec& vvalue);
@@ -120,6 +121,9 @@ class  WikiMotorObj {
     virtual bool  matchHead (const char* t, size_t s) {
        return false;
     };
+    virtual bool  regmatch (const uregex& re) {
+       return false;
+    };
     virtual ustring  typeName () = 0;
 };
 
@@ -145,6 +149,10 @@ class  WikiMotorObjText: public WikiMotorObj {
     virtual bool  matchHead (const char* t, size_t s) {
        return ::matchHead (text, t, s);
     };
+    virtual bool  regmatch (const uregex& re) {
+       umatch  m;
+       return usearch (text, m, re);
+    };
     virtual ustring  typeName () {
        return ustring (CharConst ("text"));
     };
@@ -388,6 +396,10 @@ class  WikiMotorObjHtml: public WikiMotorObj {
     virtual bool  matchHead (const char* t, size_t s) {
        return ::matchHead (html, t, s);
     };
+    virtual bool  regmatch (const uregex& re) {
+       umatch  m;
+       return usearch (html, m, re);
+    };
     virtual ustring  typeName () {
        return ustring (CharConst ("html"));
     };