コード例 #1
0
        private static int gmatch_aux(LuaState L, GMatchAuxData auxdata)
        {
            MatchState ms = new MatchState();
            uint       ls = auxdata.LS;
            CharPtr    s  = auxdata.S;
            CharPtr    p  = auxdata.P;
            CharPtr    src;

            ms.L          = L;
            ms.matchdepth = MAXCCALLS;
            ms.src_init   = s;
            ms.src_end    = s + ls;
            for (src = s + auxdata.POS;
                 src <= ms.src_end;
                 src = src.next())
            {
                CharPtr e;
                ms.level = 0;
                //LuaAssert(ms.matchdepth == MAXCCALLS);
                ms.matchdepth = MAXCCALLS;

                if ((e = match(ms, src, p)) != null)
                {
                    lua_Integer newstart = e - s;
                    if (e == src)
                    {
                        newstart++;                                /* empty match? go at least one position */
                    }
                    auxdata.POS = (uint)newstart;
                    return(push_captures(ms, src, e));
                }
            }
            return(0);             /* not found */
        }
コード例 #2
0
ファイル: KopiLua_StrLib.cs プロジェクト: eddy5641/moonsharp
        private static int gmatch_aux(LuaState L, GMatchAuxData auxdata)
        {
            var ms = new MatchState();
            var ls = auxdata.LS;
            var s = auxdata.S;
            var p = auxdata.P;
            CharPtr src;
            ms.L = L;
            ms.matchdepth = MAXCCALLS;
            ms.src_init = s;
            ms.src_end = s + ls;
            for (src = s + auxdata.POS;
                src <= ms.src_end;
                src = src.next())
            {
                CharPtr e;
                ms.level = 0;
                //LuaAssert(ms.matchdepth == MAXCCALLS);
                ms.matchdepth = MAXCCALLS;

                if ((e = match(ms, src, p)) != null)
                {
                    var newstart = e - s;
                    if (e == src) newstart++; /* empty match? go at least one position */
                    auxdata.POS = (uint) newstart;
                    return push_captures(ms, src, e);
                }
            }
            return 0; /* not found */
        }