Update to SQUIRREL 3.0.4
[supertux.git] / external / squirrel / sqstdlib / sqstdrex.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 8eebb27..20aa57d
@@ -3,7 +3,7 @@
 #include <string.h>\r
 #include <ctype.h>\r
 #include <setjmp.h>\r
-#include "sqstdstring.h"\r
+#include <sqstdstring.h>\r
 \r
 #ifdef _UINCODE\r
 #define scisprint iswprint\r
@@ -263,7 +263,6 @@ static SQInteger sqstd_rex_element(SQRex *exp)
        }\r
 \r
 \r
-       SQInteger op;\r
        SQBool isgreedy = SQFalse;\r
        unsigned short p0 = 0, p1 = 0;\r
        switch(*exp->_p){\r
@@ -297,7 +296,6 @@ static SQInteger sqstd_rex_element(SQRex *exp)
        }\r
        if(isgreedy) {\r
                SQInteger nnode = sqstd_rex_newnode(exp,OP_GREEDY);\r
-               op = OP_GREEDY;\r
                exp->_nodes[nnode].left = ret;\r
                exp->_nodes[nnode].right = ((p0)<<16)|p1;\r
                ret = nnode;\r
@@ -461,7 +459,7 @@ static const SQChar *sqstd_rex_matchnode(SQRex* exp,SQRexNode *node,const SQChar
                                exp->_matches[capture].begin = cur;\r
                                exp->_currsubexp++;\r
                        }\r
-                       \r
+                       int tempcap = exp->_currsubexp;\r
                        do {\r
                                SQRexNode *subnext = NULL;\r
                                if(n->next != -1) {\r
@@ -478,12 +476,13 @@ static const SQChar *sqstd_rex_matchnode(SQRex* exp,SQRexNode *node,const SQChar
                                }\r
                        } while((n->next != -1) && (n = &exp->_nodes[n->next]));\r
 \r
+                       exp->_currsubexp = tempcap;\r
                        if(capture != -1) \r
                                exp->_matches[capture].len = cur - exp->_matches[capture].begin;\r
                        return cur;\r
        }                                \r
        case OP_WB:\r
-               if(str == exp->_bol && !isspace(*str)\r
+               if((str == exp->_bol && !isspace(*str))\r
                 || (str == exp->_eol && !isspace(*(str-1)))\r
                 || (!isspace(*str) && isspace(*(str+1)))\r
                 || (isspace(*str) && !isspace(*(str+1))) ) {\r
@@ -497,25 +496,25 @@ static const SQChar *sqstd_rex_matchnode(SQRex* exp,SQRexNode *node,const SQChar
                if(str == exp->_eol) return str;\r
                return NULL;\r
        case OP_DOT:{\r
-               *str++;\r
+               str++;\r
                                }\r
                return str;\r
        case OP_NCLASS:\r
        case OP_CLASS:\r
                if(sqstd_rex_matchclass(exp,&exp->_nodes[node->left],*str)?(type == OP_CLASS?SQTrue:SQFalse):(type == OP_NCLASS?SQTrue:SQFalse)) {\r
-                       *str++;\r
+                       str++;\r
                        return str;\r
                }\r
                return NULL;\r
        case OP_CCLASS:\r
                if(sqstd_rex_matchcclass(node->left,*str)) {\r
-                       *str++;\r
+                       str++;\r
                        return str;\r
                }\r
                return NULL;\r
        default: /* char */\r
                if(*str != node->type) return NULL;\r
-               *str++;\r
+               str++;\r
                return str;\r
        }\r
        return NULL;\r
@@ -605,7 +604,7 @@ SQBool sqstd_rex_searchrange(SQRex* exp,const SQChar* text_begin,const SQChar* t
                                break;\r
                        node = exp->_nodes[node].next;\r
                }\r
-               *text_begin++;\r
+               text_begin++;\r
        } while(cur == NULL && text_begin != text_end);\r
 \r
        if(cur == NULL)\r