~ubuntu-branches/ubuntu/natty/geany/natty

« back to all changes in this revision

Viewing changes to scintilla/RESearch.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2009-01-01 18:40:50 UTC
  • mfrom: (1.1.8 upstream) (3.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20090101184050-u635kualu7amyt4a
Tags: 0.15-1ubuntu1
* Merge from debian experimental, remaining change:
  - patches/20_add_debdiff_as_diff_type.dpatch: Also recognize .dpatch files
    as diff's
  - debian/geany.xpm: Replace icon with a .xpm of the new one

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 * Interfaces:
34
34
 *  RESearch::Compile:      compile a regular expression into a NFA.
35
35
 *
36
 
 *          const char *RESearch::Compile(const char *pat, int length,
 
36
 *          const char *RESearch::Compile(const char *pattern, int length,
37
37
 *                                        bool caseSensitive, bool posix)
38
38
 *
39
39
 * Returns a short error string if they fail.
347
347
/**
348
348
 * Called when the parser finds a backslash not followed
349
349
 * by a valid expression (like \( in non-Posix mode).
350
 
 * @param pat: pointer on the char after the backslash.
 
350
 * @param pattern: pointer on the char after the backslash.
351
351
 * @param incr: (out) number of chars to skip after expression evaluation.
352
352
 * @return the char if it resolves to a simple char,
353
353
 * or -1 for a char class. In this case, bittab is changed.
354
354
 */
355
355
int RESearch::GetBackslashExpression(
356
 
                const char *pat,
 
356
                const char *pattern,
357
357
                int &incr) {
358
358
        // Since error reporting is primitive and messages are not used anyway,
359
359
        // I choose to interpret unexpected syntax in a logical way instead
361
361
        incr = 0;       // Most of the time, will skip the char "naturally".
362
362
        int c;
363
363
        int result = -1;
364
 
        unsigned char bsc = *pat;
 
364
        unsigned char bsc = *pattern;
365
365
        if (!bsc) {
366
366
                // Avoid overrun
367
367
                result = '\\';  // \ at end of pattern, take it literally
379
379
                result = escapeValue(bsc);
380
380
                break;
381
381
        case 'x': {
382
 
                        unsigned char hd1 = *(pat + 1);
383
 
                        unsigned char hd2 = *(pat + 2);
 
382
                        unsigned char hd1 = *(pattern + 1);
 
383
                        unsigned char hd2 = *(pattern + 2);
384
384
                        int hexValue = GetHexaChar(hd1, hd2);
385
385
                        if (hexValue >= 0) {
386
386
                                result = hexValue;
436
436
        return result;
437
437
}
438
438
 
439
 
const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, bool posix) {
 
439
const char *RESearch::Compile(const char *pattern, int length, bool caseSensitive, bool posix) {
440
440
        char *mp=nfa;          /* nfa pointer       */
441
441
        char *lp;              /* saved pointer     */
442
442
        char *sp=nfa;          /* another one       */
449
449
        char mask;             /* xor mask -CCL/NCL */
450
450
        int c1, c2, prevChar;
451
451
 
452
 
        if (!pat || !length)
 
452
        if (!pattern || !length)
453
453
                if (sta)
454
454
                        return 0;
455
455
                else
456
456
                        return badpat("No previous regular expression");
457
457
        sta = NOP;
458
458
 
459
 
        const char *p=pat;     /* pattern pointer   */
 
459
        const char *p=pattern;     /* pattern pointer   */
460
460
        for (int i=0; i<length; i++, p++) {
461
461
                if (mp > mpMax)
462
462
                        return badpat("Pattern too long");
468
468
                        break;
469
469
 
470
470
                case '^':               /* match beginning */
471
 
                        if (p == pat)
 
471
                        if (p == pattern)
472
472
                                *mp++ = BOL;
473
473
                        else {
474
474
                                *mp++ = CHR;
588
588
 
589
589
                case '*':               /* match 0 or more... */
590
590
                case '+':               /* match 1 or more... */
591
 
                        if (p == pat)
 
591
                        if (p == pattern)
592
592
                                return badpat("Empty closure");
593
593
                        lp = sp;                /* previous opcode */
594
594
                        if (*lp == CLO)         /* equivalence... */
853
853
                                return NOTFOUND;
854
854
                        break;
855
855
                case CCL:
 
856
                        if (lp >= endp)
 
857
                                return NOTFOUND;
856
858
                        c = ci.CharAt(lp++);
857
859
                        if (!isinset(ap,c))
858
860
                                return NOTFOUND;