~ubuntu-branches/ubuntu/precise/xerces-c/precise-updates

« back to all changes in this revision

Viewing changes to src/xercesc/util/regx/RegularExpression.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jay Berkenbilt
  • Date: 2009-12-05 14:58:32 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091205145832-378dg3x72mdzfzup
Tags: 3.1.0~rc1-1
* New upstream release; public release candidate uploaded at request of
  upstream.
* Updated source format to '3.0 (quilt)'

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 */
17
17
 
18
18
/*
19
 
 * $Id: RegularExpression.cpp 695949 2008-09-16 15:57:44Z borisk $
 
19
 * $Id: RegularExpression.cpp 822158 2009-10-06 07:52:59Z amassari $
20
20
 */
21
21
 
22
22
// ---------------------------------------------------------------------------
140
140
    }
141
141
    if(src->fMatch)
142
142
    {
143
 
        fMatch=new Match(*src->fMatch);
 
143
        fMatch=new (fMemoryManager) Match(*src->fMatch);
144
144
        fAdoptMatch=true;
145
145
    }
146
146
}
152
152
        fStart=other.fStart;
153
153
        fLimit=other.fLimit;
154
154
        fLength=other.fLength;
155
 
        fSize=other.fSize;
156
155
        fStringMaxLen=other.fStringMaxLen;
157
156
        fString=other.fString;
158
157
        fOptions=other.fOptions;
159
 
        if (fOffsets)
160
 
            fMemoryManager->deallocate(fOffsets);//delete [] fOffsets;
161
 
        fOffsets=0;
162
 
        if (fAdoptMatch)
163
 
            delete fMatch;
164
 
        fMatch=0;
165
 
        fAdoptMatch=false;
166
 
 
167
 
        fMemoryManager=other.fMemoryManager;
168
 
        if(other.fOffsets)
169
 
        {
170
 
            fOffsets = (int*) fMemoryManager->allocate(fSize* sizeof(int));
 
158
 
 
159
        // if offset and match are already allocated with the right size, reuse them 
 
160
        // (fMatch can be provided by the user to get the data back)
 
161
        if(fMatch && other.fMatch && fMatch->getNoGroups()==other.fMatch->getNoGroups())
 
162
            *fMatch=*other.fMatch;
 
163
        else
 
164
        {
 
165
            if (fAdoptMatch)
 
166
                delete fMatch;
 
167
            fMatch=0;
 
168
            if(other.fMatch)
 
169
            {
 
170
                fMatch=new (other.fMemoryManager) Match(*other.fMatch);
 
171
                fAdoptMatch=true;
 
172
            }
 
173
        }
 
174
 
 
175
        if (fOffsets && other.fOffsets && fSize==other.fSize)
 
176
        {
171
177
            for (int i = 0; i< fSize; i++)
172
178
                fOffsets[i] = other.fOffsets[i];
173
179
        }
174
 
        if(other.fMatch)
 
180
        else
175
181
        {
176
 
            fMatch=new Match(*other.fMatch);
177
 
            fAdoptMatch=true;
 
182
            if(fOffsets)
 
183
                fMemoryManager->deallocate(fOffsets);//delete [] fOffsets;
 
184
            fOffsets=0;
 
185
            fSize=other.fSize;
 
186
            if(other.fOffsets)
 
187
            {
 
188
                fOffsets = (int*) other.fMemoryManager->allocate(fSize* sizeof(int));
 
189
                for (int i = 0; i< fSize; i++)
 
190
                    fOffsets[i] = other.fOffsets[i];
 
191
            }
178
192
        }
 
193
 
 
194
        fMemoryManager=other.fMemoryManager;
179
195
    }
180
196
 
181
197
    return *this;
552
568
 
553
569
            if (context.fMatch != 0) {
554
570
                context.fMatch->setStartPos(0, ret);
555
 
                context.fMatch->setEndPos(0, (int)(ret + strLength));
 
571
                context.fMatch->setEndPos(0, (int)(ret + XMLString::stringLen(fPattern)));
556
572
            }
557
573
            return true;
558
574
        }
1430
1446
 
1431
1447
    switch(tokenType) {
1432
1448
    case Token::T_DOT:
 
1449
        ret = fOpFactory.createDotOp();
 
1450
        ret->setNextOp(next);
 
1451
        break;
1433
1452
    case Token::T_CHAR:
 
1453
        ret = fOpFactory.createCharOp(token->getChar());
 
1454
        ret->setNextOp(next);
 
1455
        break;
1434
1456
    case Token::T_ANCHOR:
 
1457
        ret = fOpFactory.createAnchorOp(token->getChar());
 
1458
        ret->setNextOp(next);
 
1459
        break;
1435
1460
    case Token::T_RANGE:
1436
1461
    case Token::T_NRANGE:
 
1462
        ret = fOpFactory.createRangeOp(token);
 
1463
        ret->setNextOp(next);
 
1464
        break;
1437
1465
    case Token::T_STRING:
 
1466
        ret = fOpFactory.createStringOp(token->getString());
 
1467
        ret->setNextOp(next);
 
1468
        break;
1438
1469
    case Token::T_BACKREFERENCE:
 
1470
        ret = fOpFactory.createBackReferenceOp(token->getReferenceNo());
 
1471
        ret->setNextOp(next);
 
1472
        break;
1439
1473
    case Token::T_EMPTY:
1440
 
        ret = compileSingle(token, next, tokenType);
 
1474
        ret = next;
1441
1475
        break;
1442
1476
    case Token::T_CONCAT:
1443
1477
        ret = compileConcat(token, next, reverse);