⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcre_exec.cpp

📁 Google浏览器V8内核代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                /* First, ensure the minimum number of matches are present. */                                for (int i = 1; i <= min; i++) {                    if (!matchRef(stack.currentFrame->locals.offset, stack.currentFrame->args.subjectPtr, stack.currentFrame->locals.length, md))                        RRETURN_NO_MATCH;                    stack.currentFrame->args.subjectPtr += stack.currentFrame->locals.length;                }                                /* If min = max, continue at the same level without recursion.                 They are not both allowed to be zero. */                                if (min == stack.currentFrame->locals.max)                    NEXT_OPCODE;                                /* If minimizing, keep trying and advancing the pointer */                                if (minimize) {                    for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) {                        RECURSIVE_MATCH(20, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain);                        if (isMatch)                            RRETURN;                        if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || !matchRef(stack.currentFrame->locals.offset, stack.currentFrame->args.subjectPtr, stack.currentFrame->locals.length, md))                            RRETURN;                        stack.currentFrame->args.subjectPtr += stack.currentFrame->locals.length;                    }                    /* Control never reaches here */                }                                /* If maximizing, find the longest string and work backwards */                                else {                    stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr;                    for (int i = min; i < stack.currentFrame->locals.max; i++) {                        if (!matchRef(stack.currentFrame->locals.offset, stack.currentFrame->args.subjectPtr, stack.currentFrame->locals.length, md))                            break;                        stack.currentFrame->args.subjectPtr += stack.currentFrame->locals.length;                    }                    while (stack.currentFrame->args.subjectPtr >= stack.currentFrame->locals.subjectPtrAtStartOfInstruction) {                        RECURSIVE_MATCH(21, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain);                        if (isMatch)                            RRETURN;                        stack.currentFrame->args.subjectPtr -= stack.currentFrame->locals.length;                    }                    RRETURN_NO_MATCH;                }                /* Control never reaches here */                            /* Match a bit-mapped character class, possibly repeatedly. This op code is             used when all the characters in the class have values in the range 0-255,             and either the matching is caseful, or the characters are in the range             0-127 when UTF-8 processing is enabled. The only difference between             OP_CLASS and OP_NCLASS occurs when a data character outside the range is             encountered.                          First, look past the end of the item to see if there is repeat information             following. Then obey similar code to character type repeats - written out             again for speed. */                            BEGIN_OPCODE(NCLASS):            BEGIN_OPCODE(CLASS):                stack.currentFrame->locals.data = stack.currentFrame->args.instructionPtr + 1;                /* Save for matching */                stack.currentFrame->args.instructionPtr += 33;                     /* Advance past the item */                                switch (*stack.currentFrame->args.instructionPtr) {                    case OP_CRSTAR:                    case OP_CRMINSTAR:                    case OP_CRPLUS:                    case OP_CRMINPLUS:                    case OP_CRQUERY:                    case OP_CRMINQUERY:                        repeatInformationFromInstructionOffset(*stack.currentFrame->args.instructionPtr++ - OP_CRSTAR, minimize, min, stack.currentFrame->locals.max);                        break;                                            case OP_CRRANGE:                    case OP_CRMINRANGE:                        minimize = (*stack.currentFrame->args.instructionPtr == OP_CRMINRANGE);                        min = get2ByteValue(stack.currentFrame->args.instructionPtr + 1);                        stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 3);                        if (stack.currentFrame->locals.max == 0)                            stack.currentFrame->locals.max = INT_MAX;                        stack.currentFrame->args.instructionPtr += 5;                        break;                                            default:               /* No repeat follows */                        min = stack.currentFrame->locals.max = 1;                        break;                }                                /* First, ensure the minimum number of matches are present. */                                for (int i = 1; i <= min; i++) {                    if (stack.currentFrame->args.subjectPtr >= md.endSubject)                        RRETURN_NO_MATCH;                    int c = *stack.currentFrame->args.subjectPtr++;                    if (c > 255) {                        if (stack.currentFrame->locals.data[-1] == OP_CLASS)                            RRETURN_NO_MATCH;                    } else {                        if (!(stack.currentFrame->locals.data[c / 8] & (1 << (c & 7))))                            RRETURN_NO_MATCH;                    }                }                                /* If max == min we can continue with the main loop without the                 need to recurse. */                                if (min == stack.currentFrame->locals.max)                    NEXT_OPCODE;                                      /* If minimizing, keep testing the rest of the expression and advancing                 the pointer while it matches the class. */                if (minimize) {                    for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) {                        RECURSIVE_MATCH(22, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain);                        if (isMatch)                            RRETURN;                        if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject)                            RRETURN;                        int c = *stack.currentFrame->args.subjectPtr++;                        if (c > 255) {                            if (stack.currentFrame->locals.data[-1] == OP_CLASS)                                RRETURN;                        } else {                            if ((stack.currentFrame->locals.data[c/8] & (1 << (c&7))) == 0)                                RRETURN;                        }                    }                    /* Control never reaches here */                }                /* If maximizing, find the longest possible run, then work backwards. */                else {                    stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr;                                        for (int i = min; i < stack.currentFrame->locals.max; i++) {                        if (stack.currentFrame->args.subjectPtr >= md.endSubject)                            break;                        int c = *stack.currentFrame->args.subjectPtr;                        if (c > 255) {                            if (stack.currentFrame->locals.data[-1] == OP_CLASS)                                break;                        } else {                            if (!(stack.currentFrame->locals.data[c / 8] & (1 << (c & 7))))                                break;                        }                        ++stack.currentFrame->args.subjectPtr;                    }                    for (;;) {                        RECURSIVE_MATCH(24, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain);                        if (isMatch)                            RRETURN;                        if (stack.currentFrame->args.subjectPtr-- == stack.currentFrame->locals.subjectPtrAtStartOfInstruction)                            break;        /* Stop if tried at original pos */                    }                                        RRETURN;                }                /* Control never reaches here */                            /* Match an extended character class. */                            BEGIN_OPCODE(XCLASS):                stack.currentFrame->locals.data = stack.currentFrame->args.instructionPtr + 1 + LINK_SIZE;                /* Save for matching */                stack.currentFrame->args.instructionPtr += getLinkValue(stack.currentFrame->args.instructionPtr + 1);                      /* Advance past the item */                                switch (*stack.currentFrame->args.instructionPtr) {                    case OP_CRSTAR:                    case OP_CRMINSTAR:                    case OP_CRPLUS:                    case OP_CRMINPLUS:                    case OP_CRQUERY:                    case OP_CRMINQUERY:                        repeatInformationFromInstructionOffset(*stack.currentFrame->args.instructionPtr++ - OP_CRSTAR, minimize, min, stack.currentFrame->locals.max);                        break;                                            case OP_CRRANGE:                    case OP_CRMINRANGE:                        minimize = (*stack.currentFrame->args.instructionPtr == OP_CRMINRANGE);                        min = get2ByteValue(stack.currentFrame->args.instructionPtr + 1);                        stack.currentFrame->locals.max = get2ByteValue(stack.currentFrame->args.instructionPtr + 3);                        if (stack.currentFrame->locals.max == 0)                            stack.currentFrame->locals.max = INT_MAX;                        stack.currentFrame->args.instructionPtr += 5;                        break;                                            default:               /* No repeat follows */                        min = stack.currentFrame->locals.max = 1;                }                                /* First, ensure the minimum number of matches are present. */                                for (int i = 1; i <= min; i++) {                    if (stack.currentFrame->args.subjectPtr >= md.endSubject)                        RRETURN_NO_MATCH;                    int c = *stack.currentFrame->args.subjectPtr++;                    if (!kjs_pcre_xclass(c, stack.currentFrame->locals.data))                        RRETURN_NO_MATCH;                }                                /* If max == min we can continue with the main loop without the                 need to recurse. */                                if (min == stack.currentFrame->locals.max)                    NEXT_OPCODE;                                /* If minimizing, keep testing the rest of the expression and advancing                 the pointer while it matches the class. */                                if (minimize) {                    for (stack.currentFrame->locals.fi = min;; stack.currentFrame->locals.fi++) {                        RECURSIVE_MATCH(26, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain);                        if (isMatch)                            RRETURN;                        if (stack.currentFrame->locals.fi >= stack.currentFrame->locals.max || stack.currentFrame->args.subjectPtr >= md.endSubject)                            RRETURN;                        int c = *stack.currentFrame->args.subjectPtr++;                        if (!kjs_pcre_xclass(c, stack.currentFrame->locals.data))                            RRETURN;                    }                    /* Control never reaches here */                }                                /* If maximizing, find the longest possible run, then work backwards. */                                else {                    stack.currentFrame->locals.subjectPtrAtStartOfInstruction = stack.currentFrame->args.subjectPtr;                    for (int i = min; i < stack.currentFrame->locals.max; i++) {                        if (stack.currentFrame->args.subjectPtr >= md.endSubject)                            break;                        int c = *stack.currentFrame->args.subjectPtr;                        if (!kjs_pcre_xclass(c, stack.currentFrame->locals.data))                            break;                        ++stack.currentFrame->args.subjectPtr;                    }                    for(;;) {                        RECURSIVE_MATCH(27, stack.currentFrame->args.instructionPtr, stack.currentFrame->args.bracketChain);                        if (isMatch)                            RRETURN;                        if (stack.currentFrame->args.subjectPtr-- == stack.currentFrame->locals.subjectPtrAtStartOfInstruction)                            break;        /* Stop if tried at original pos */                    }                    RRETURN;                }                                /* Control never reaches here */                            /* Match a single character, casefully */                            BEGIN_OPCODE(CHAR):                stack.currentFrame->locals.length = 1;                stack.currentFrame->args.instructionPtr++;                getUTF8CharAndIncrementLength(stack.currentFrame->locals.fc, stack.currentFrame->args.instructionPtr, stack.currentFrame->locals.length);                stack.currentFrame->args.instructionPtr += stack.currentFrame->locals.length;                if (stack.currentFrame->args.subjectPtr >= md.endSubject)                    RRETURN_NO_MATCH;                if (stack.currentFrame->locals.fc != *stack.currentFrame->args.subjectPtr++)                    RRETURN_NO_MATCH;                NEXT_OPCODE;                            /* Match a single character, caselessly */                            BEGIN_OPCODE(CHAR_IGNORING_CASE): {                stack.currentFrame->locals.length = 1;                stack.currentFrame->args.instructionPtr++;                getUTF8CharAndIncrementLength(stack.currentFrame->locals.fc, stack.currentFrame->args.instructionPtr, stack.currentFrame->locals.length);                stack.currentFrame->args.instructionPtr += stack.currentFrame->locals.length;                if (stack.currentFrame->args.subjectPtr >= md.endSubject)                    RRETURN_NO_MATCH;                int dc = *stack.currentFrame->args.subjectPtr++;                if (stack.currentFrame->locals.fc != dc && kjs_pcre_ucp_othercase(stack.currentFrame->locals.fc) != dc)                    RRETURN_NO_MATCH;                NEXT_OPCODE;            }                

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -