~ubuntu-branches/ubuntu/lucid/cmake/lucid

« back to all changes in this revision

Viewing changes to Source/kwsys/RegularExpression.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2009-12-16 11:11:54 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091216111154-6accvv6yq86h2hkc
Tags: 2.8.0-5ubuntu1
* Merge from debian testing (LP: #497349). Remaining changes:
  - Keep the Replaces: on cmake-data to cover the Kubuntu version from
    Jaunty in case someone decides to do an (unsupported) Jaunty->Lucid
    upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*=========================================================================
2
 
 
3
 
  Program:   KWSys - Kitware System Library
4
 
  Module:    $RCSfile: RegularExpression.cxx,v $
5
 
 
6
 
  Copyright (c) Kitware, Inc., Insight Consortium.  All rights reserved.
7
 
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8
 
 
9
 
     This software is distributed WITHOUT ANY WARRANTY; without even
10
 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11
 
     PURPOSE.  See the above copyright notices for more information.
12
 
 
13
 
=========================================================================*/
 
1
/*============================================================================
 
2
  KWSys - Kitware System Library
 
3
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
 
4
 
 
5
  Distributed under the OSI-approved BSD License (the "License");
 
6
  see accompanying file Copyright.txt for details.
 
7
 
 
8
  This software is distributed WITHOUT ANY WARRANTY; without even the
 
9
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
10
  See the License for more information.
 
11
============================================================================*/
14
12
//
15
13
// Copyright (C) 1991 Texas Instruments Incorporated.
16
14
//
269
267
 * Utility definitions.
270
268
 */
271
269
 
272
 
#define UCHARAT(p)      ((const unsigned char*)(p))[0]
 
270
#define UCHARAT(p)      (reinterpret_cast<const unsigned char*>(p))[0]
273
271
 
274
272
 
275
273
#define FAIL(m) { regerror(m); return(0); }
316
314
static       char* regnode (char);
317
315
static const char* regnext (register const char*);
318
316
static       char* regnext (register char*);
319
 
static void        regc (unsigned char);
 
317
static void        regc (char);
320
318
static void        reginsert (char, char*);
321
319
static void        regtail (char*, const char*);
322
320
static void        regoptail (char*, const char*);
348
346
bool RegularExpression::compile (const char* exp) {
349
347
    register const char* scan;
350
348
    register const char* longest;
351
 
    register unsigned long len;
 
349
    register size_t len;
352
350
             int         flags;
353
351
 
354
352
    if (exp == 0) {
362
360
    regnpar = 1;
363
361
    regsize = 0L;
364
362
    regcode = &regdummy;
365
 
    regc(MAGIC);
 
363
    regc(static_cast<char>(MAGIC));
366
364
    if(!reg(0, &flags))
367
365
      {
368
366
        printf ("RegularExpression::compile(): Error in compile.\n");
394
392
    regparse = exp;
395
393
    regnpar = 1;
396
394
    regcode = this->program;
397
 
    regc(MAGIC);
 
395
    regc(static_cast<char>(MAGIC));
398
396
    reg(0, &flags);
399
397
 
400
398
    // Dig out information for optimizations.
426
424
            for (; scan != 0; scan = regnext(scan))
427
425
                if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
428
426
                    longest = OPERAND(scan);
429
 
                    len = int(strlen(OPERAND(scan)));
 
427
                    len = strlen(OPERAND(scan));
430
428
                }
431
429
            this->regmust = longest;
432
430
            this->regmlen = len;
675
673
                               return 0;
676
674
                            }
677
675
                            for (; rxpclass <= rxpclassend; rxpclass++)
678
 
                                regc(static_cast<unsigned char>(rxpclass));
 
676
                              regc(static_cast<char>(rxpclass));
679
677
                            regparse++;
680
678
                        }
681
679
                    }
778
776
/*
779
777
 - regc - emit (if appropriate) a byte of code
780
778
 */
781
 
static void regc (unsigned char b) {
 
779
static void regc (char b) {
782
780
    if (regcode != &regdummy)
783
781
        *regcode++ = b;
784
782
    else
1018
1016
                reginput++;
1019
1017
                break;
1020
1018
            case EXACTLY:{
1021
 
                    register int         len;
 
1019
                    register size_t len;
1022
1020
                    register const char* opnd;
1023
1021
 
1024
1022
                    opnd = OPERAND(scan);
1025
1023
                    // Inline the first character, for speed.
1026
1024
                    if (*opnd != *reginput)
1027
1025
                        return (0);
1028
 
                    len = int(strlen(opnd));
 
1026
                    len = strlen(opnd);
1029
1027
                    if (len > 1 && strncmp(opnd, reginput, len) != 0)
1030
1028
                        return (0);
1031
1029
                    reginput += len;
1234
1232
        return (p + offset);
1235
1233
}
1236
1234
 
1237
 
 
1238
1235
static char* regnext (register char* p) {
1239
1236
    register int offset;
1240
1237