~haaaad/geany/master

« back to all changes in this revision

Viewing changes to scintilla/src/RESearch.cxx

  • Committer: elextr
  • Author(s): Colomban Wendling
  • Date: 2017-07-24 23:24:05 UTC
  • Revision ID: git-v1:18360460abb4f4bec23dff127031ecf4e9120f7f
Update Scintilla to version 3.7.5 (#1503)

* Update Scintilla to version 3.7.5

This now requires a C++11-capable compiler.

Closes #1308.

* Test using newer dist on Travis

Since Scintilla needs C++11

* Add debugging code for when configure fails

* Workaround a pkg-config-corsswrapper bug on Ubuntu 14.04

See https://bugs.launchpad.net/ubuntu/+source/mingw-w64/+bug/1327242

Show diffs side-by-side

added added

removed removed

Lines of Context:
200
200
 *  matches:    foo-foo fo-fo fob-fob foobar-foobar ...
201
201
 */
202
202
 
203
 
#include <stdlib.h>
 
203
#include <cstdlib>
204
204
 
205
205
#include <stdexcept>
206
206
#include <string>
256
256
        charClass = charClassTable;
257
257
        sta = NOP;                  /* status of lastpat */
258
258
        bol = 0;
259
 
        std::fill(bittab, bittab + BITBLK, 0);
 
259
        std::fill(bittab, bittab + BITBLK, static_cast<unsigned char>(0));
260
260
        std::fill(tagstk, tagstk + MAXTAG, 0);
261
 
        std::fill(nfa, nfa + MAXNFA, 0);
 
261
        std::fill(nfa, nfa + MAXNFA, '\0');
262
262
        Clear();
263
263
}
264
264
 
277
277
void RESearch::GrabMatches(CharacterIndexer &ci) {
278
278
        for (unsigned int i = 0; i < MAXTAG; i++) {
279
279
                if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) {
280
 
                        unsigned int len = eopat[i] - bopat[i];
 
280
                        Sci::Position len = eopat[i] - bopat[i];
281
281
                        pat[i].resize(len);
282
 
                        for (unsigned int j = 0; j < len; j++)
 
282
                        for (Sci::Position j = 0; j < len; j++)
283
283
                                pat[i][j] = ci.CharAt(bopat[i] + j);
284
284
                }
285
285
        }
358
358
        incr = 0;       // Most of the time, will skip the char "naturally".
359
359
        int c;
360
360
        int result = -1;
361
 
        unsigned char bsc = *pattern;
 
361
        const unsigned char bsc = *pattern;
362
362
        if (!bsc) {
363
363
                // Avoid overrun
364
364
                result = '\\';  // \ at end of pattern, take it literally
376
376
                result = escapeValue(bsc);
377
377
                break;
378
378
        case 'x': {
379
 
                        unsigned char hd1 = *(pattern + 1);
380
 
                        unsigned char hd2 = *(pattern + 2);
381
 
                        int hexValue = GetHexaChar(hd1, hd2);
 
379
                        const unsigned char hd1 = *(pattern + 1);
 
380
                        const unsigned char hd2 = *(pattern + 2);
 
381
                        const int hexValue = GetHexaChar(hd1, hd2);
382
382
                        if (hexValue >= 0) {
383
383
                                result = hexValue;
384
384
                                incr = 2;       // Must skip the digits
434
434
        return result;
435
435
}
436
436
 
437
 
const char *RESearch::Compile(const char *pattern, int length, bool caseSensitive, bool posix) {
 
437
const char *RESearch::Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) {
438
438
        char *mp=nfa;          /* nfa pointer       */
439
439
        char *lp;              /* saved pointer     */
440
440
        char *sp=nfa;          /* another one       */
755
755
 *  respectively.
756
756
 *
757
757
 */
758
 
int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
 
758
int RESearch::Execute(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp) {
759
759
        unsigned char c;
760
 
        int ep = NOTFOUND;
 
760
        Sci::Position ep = NOTFOUND;
761
761
        char *ap = nfa;
762
762
 
763
763
        bol = lp;
844
844
#define CHRSKIP 3       /* [CLO] CHR chr END      */
845
845
#define CCLSKIP 34      /* [CLO] CCL 32 bytes END */
846
846
 
847
 
int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) {
 
847
Sci::Position RESearch::PMatch(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, char *ap) {
848
848
        int op, c, n;
849
 
        int e;          /* extra pointer for CLO  */
850
 
        int bp;         /* beginning of subpat... */
851
 
        int ep;         /* ending of subpat...    */
852
 
        int are;        /* to save the line ptr.  */
853
 
        int llp;        /* lazy lp for LCLO       */
 
849
        Sci::Position e;                /* extra pointer for CLO  */
 
850
        Sci::Position bp;               /* beginning of subpat... */
 
851
        Sci::Position ep;               /* ending of subpat...    */
 
852
        Sci::Position are;      /* to save the line ptr.  */
 
853
        Sci::Position llp;      /* lazy lp for LCLO       */
854
854
 
855
855
        while ((op = *ap++) != END)
856
856
                switch (op) {
940
940
                        llp = lp;
941
941
                        e = NOTFOUND;
942
942
                        while (llp >= are) {
943
 
                                int q;
 
943
                                Sci::Position q;
944
944
                                if ((q = PMatch(ci, llp, endp, ap)) != NOTFOUND) {
945
945
                                        e = q;
946
946
                                        lp = llp;