Changeset 12124 in project


Ignore:
Timestamp:
10/08/08 12:51:27 (12 years ago)
Author:
felix winkelmann
Message:

added irregex code and tests

Location:
chicken/branches/irregular
Files:
4 added
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • chicken/branches/irregular/README

    r11646 r12124  
    161161          <http://chicken.wiki.br/cross-compilation>.
    162162
    163         USE_HOST_PCRE=
    164           The PCRE library is included with the CHICKEN
    165           distribution to remove external dependencies and to avoid
    166           incompatibilities with any previously installed version. If
    167           you want to link with an installed libpcre, set this
    168           variable to a non-empty value. Only use this feature if you
    169           know what you are doing.
    170 
    171163        SRCDIR=
    172164          Specifies that CHICKEN should be built outside of its source
  • chicken/branches/irregular/defaults.make

    r12021 r12124  
    154154# options
    155155
    156 ifneq ($(USE_HOST_PCRE),)
    157 LIBRARIES += -lpcre
    158 PCRE_INCLUDES =
    159 C_COMPILER_PCRE_OPTIONS =
    160 PCRE_OBJECTS_1 =
    161 else
    162 ifdef WINDOWS
    163 ifneq ($(HOSTSYSTEM),mingw32)
    164 PCRE_DIR ?= $(SRCDIR)pcre\\
    165 else
    166 endif
    167 PCRE_DIR ?= $(SRCDIR)pcre/
    168 else
    169 PCRE_DIR ?= $(SRCDIR)pcre/
    170 endif
    171 C_COMPILER_PCRE_OPTIONS = -DPCRE_STATIC -DHAVE_CONFIG_H
    172 PCRE_INCLUDES = $(INCLUDES) -I$(PCRE_DIR)
    173 endif
    174156ifndef NOPTABLES
    175157C_COMPILER_PTABLES_OPTIONS ?= -DC_ENABLE_PTABLES
     
    322304CHICKEN_IMPORT_LIBRARY_OPTIONS = $(CHICKEN_DYNAMIC_OPTIONS)
    323305
    324 ifneq ($(USE_HOST_PCRE),)
    325 CHICKEN_PCRE_LIBRARY_OPTIONS =
    326 else
    327 CHICKEN_PCRE_LIBRARY_OPTIONS = -include-path $(SRCDIR)pcre
    328 endif
    329 
    330306# targets
    331307
     
    339315CHICKEN_BUG_PROGRAM = $(PROGRAM_PREFIX)chicken-bug$(PROGRAM_SUFFIX)
    340316IMPORT_LIBRARIES = chicken lolevel srfi-1 srfi-4 data-structures ports files posix srfi-13 srfi-69 extras \
    341         regex srfi-14 tcp foreign scheme srfi-18 utils csi
     317        regex srfi-14 tcp foreign scheme srfi-18 utils csi irregex
    342318IMPORT_LIBRARIES += setup-api setup-download setup-utils
    343319
     
    379355buildsvnrevision:
    380356        sh $(SRCDIR)/svnrevision.sh
    381 ifeq ($(USE_HOST_PCRE),)
    382         $(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) pcre
    383 endif
    384357
    385358# generic part of chicken-config.h
  • chicken/branches/irregular/distribution/manifest

    r12117 r12124  
    209209tests/ec-tests.scm
    210210tests/test-chained-modules.scm
     211tests/test-irregex.scm
     212tests/re-tests.txt
    211213tweaks.scm
    212214utils.scm
    213 pcre/AUTHORS
    214 pcre/config.h
    215 pcre/COPYING
    216 pcre/dftables.c
    217 pcre/LICENCE
    218 pcre/NON-UNIX-USE
    219 pcre/pcre_chartables.c
    220 pcre/pcre_compile.c
    221 pcre/pcre_config.c
    222 pcre/pcre_dfa_exec.c
    223 pcre/pcre_exec.c
    224 pcre/pcre_fullinfo.c
    225 pcre/pcre_get.c
    226 pcre/pcre_globals.c
    227 pcre/pcre_info.c
    228 pcre/pcre_internal.h
    229 pcre/pcre_maketables.c
    230 pcre/pcre_newline.c
    231 pcre/pcre_ord2utf8.c
    232 pcre/pcre_refcount.c
    233 pcre/pcre_study.c
    234 pcre/pcre_tables.c
    235 pcre/pcre_try_flipped.c
    236 pcre/pcre_ucd.c
    237 pcre/pcre_ucp_findchar.c
    238 pcre/pcre_valid_utf8.c
    239 pcre/pcre_version.c
    240 pcre/pcre_xclass.c
    241 pcre/pcre.h
    242 pcre/ucp.h
     215irregex.scm
     216irregex.import.scm
     217irregex.import.c
    243218apply-hack.x86.s
    244219apply-hack.x86-64.s
  • chicken/branches/irregular/library.scm

    r11989 r12124  
    32503250                   (if (##sys#fudge 35) " applyhook" "")
    32513251                   (if (##sys#fudge 22) " lockts" "")
    3252                    (if (##sys#fudge 37) " hostpcre" "")
    32533252                   (if (##sys#fudge 39) " cross" "") ) ) )
    32543253        (string-append
  • chicken/branches/irregular/manual/Acknowledgements

    r11646 r12124  
    4242Zidlicky and Houman Zolfaghari for bug-fixes, tips and suggestions.
    4343
    44 CHICKEN uses the PCRE regular expression package ([[http://www.pcre.org]]),
    45 which is written by Philip Hazel.
     44CHICKEN uses the "irregex" regular expression package written by Alex Shinn.
    4645
    4746Special thanks to Brandon van Every for contributing the (now defunct)
  • chicken/branches/irregular/manual/Unit regex

    r10872 r12124  
    55
    66This library unit provides support for regular expressions. The regular
    7 expression package used is {{PCRE}} (''Perl Compatible Regular Expressions'')
    8 written by Philip Hazel. See [[http://www.pcre.org]] for information about
    9 the particular regexp flavor and extensions provided by this library.
    10 
    11 To test that PCRE support has been built into Chicken properly, try:
    12 
    13 <enscript highlight=scheme>
    14 (require 'regex)
    15 (test-feature? 'pcre) => t
    16 </enscript>
     7expression package used is {{irregex}}
     8written by Alex Shinn. Irregex supports most Perl-extensions and is
     9written completely in Scheme.
     10
     11This library unit exposes two APIs: the one listed below and the
     12original irregex API. To use the latter, import from the {{irregex}} module.
    1713
    1814
  • chicken/branches/irregular/regex.scm

    r11258 r12124  
    1 ;;;; regex.scm - Unit for using the PCRE regex package
     1;;;; regex.scm
    22;
    33; Copyright (c) 2000-2007, Felix L. Winkelmann
     
    3333  (usual-integrations)
    3434  (disable-interrupts)
    35   (generic) ; PCRE options use lotsa bits
    3635  (disable-warning var)
    37   (bound-to-procedure
    38     ;; Forward reference
    39     regex-chardef-table? make-anchored-pattern
    40     ;; Imports
    41     get-output-string open-output-string
    42     string->list list->string string-length string-ref substring make-string string-append
    43     reverse list-ref
    44     char=? char-alphabetic? char-numeric? char->integer
    45     set-finalizer!
    46     ##sys#pointer?
    47     ##sys#slot ##sys#setslot ##sys#size
    48     ##sys#make-structure ##sys#structure?
    49     ##sys#error ##sys#signal-hook
    50     ##sys#substring ##sys#fragments->string ##sys#make-c-string ##sys#string-append
    51     ##sys#write-char-0 )
    5236  (export
    53     regex-chardef-table? regex-chardef-table
    54     regexp? regexp regexp*
    55     regexp-optimize
    56     make-anchored-pattern
     37    regexp? regexp
    5738    string-match string-match-positions string-search string-search-positions
    5839    string-split-fields string-substitute string-substitute*
    5940    glob? glob->regexp
    6041    grep
    61     regexp-escape ) )
     42    regexp-escape
     43
     44    irregex string->irregex sre->irregex irregex? irregex-match-data?
     45    irregex-new-matches irregex-reset-matches!
     46    irregex-match-start irregex-match-end irregex-match-substring
     47    irregex-search irregex-search/matches irregex-match irregex-match-string
     48    irregex-replace irregex-replace/all
     49    irregex-dfa irregex-dfa/search irregex-dfa/extract
     50    irregex-nfa irregex-flags irregex-submatches irregex-lengths irregex-names
     51    ))
    6252
    6353(cond-expand
     
    7060(include "unsafe-declarations.scm")
    7161
    72 (cond-expand
    73  ((not unsafe)
    74   (define (##sys#check-chardef-table x loc)
    75     (unless (regex-chardef-table? x)
    76       (##sys#error loc "invalid character definition tables structure" x) ) )
    77   (declare
    78     (bound-to-procedure
    79       ;; Imports
    80       ##sys#check-string ##sys#check-list ##sys#check-exact ##sys#check-vector
    81       ##sys#check-structure ##sys#check-symbol ##sys#check-blob ##sys#check-integer )
    82     (export
    83       ##sys#check-chardef-table )))
    84  (else))
    85 
    86 
    87 ;;;
    88 
    89 #>#include "pcre.h"<#
    90 
    91 
    92 ;;;
    93 
    94 (register-feature! 'regex 'pcre)
    95 
    96 
    97 ;;; From unit lolevel:
    98 
    99 (define-inline (%tag-pointer ptr tag)
    100   (let ([tp (##sys#make-tagged-pointer tag)])
    101     (##core#inline "C_copy_pointer" ptr tp)
    102     tp ) )
    103 
    104 (define-inline (%tagged-pointer? x tag)
    105   (and (##core#inline "C_blockp" x)
    106        (##core#inline "C_taggedpointerp" x)
    107        (eq? tag (##sys#slot x 1)) ) )
    108 
    109 
    110 ;;; PCRE Types:
    111 
    112 (define-foreign-type pcre (c-pointer "pcre"))
    113 (define-foreign-type nonnull-pcre (nonnull-c-pointer "pcre"))
    114 
    115 (define-foreign-type pcre_extra (c-pointer "pcre_extra"))
    116 (define-foreign-type nonnull-pcre_extra (nonnull-c-pointer "pcre_extra"))
    117 
    118 (define-foreign-variable PCRE_CASELESS unsigned-integer)
    119 (define-foreign-variable PCRE_EXTENDED unsigned-integer)
    120 (define-foreign-variable PCRE_UTF8 unsigned-integer)
    121 (define-foreign-variable PCRE_MULTILINE unsigned-integer)
    122 (define-foreign-variable PCRE_DOTALL unsigned-integer)
    123 (define-foreign-variable PCRE_ANCHORED unsigned-integer)
    124 (define-foreign-variable PCRE_DOLLAR_ENDONLY unsigned-integer)
    125 (define-foreign-variable PCRE_EXTRA unsigned-integer)
    126 (define-foreign-variable PCRE_NOTBOL unsigned-integer)
    127 (define-foreign-variable PCRE_NOTEOL unsigned-integer)
    128 (define-foreign-variable PCRE_UNGREEDY unsigned-integer)
    129 (define-foreign-variable PCRE_NOTEMPTY unsigned-integer)
    130 (define-foreign-variable PCRE_NO_AUTO_CAPTURE unsigned-integer)
    131 (define-foreign-variable PCRE_NO_UTF8_CHECK unsigned-integer)
    132 (define-foreign-variable PCRE_AUTO_CALLOUT unsigned-integer)
    133 (define-foreign-variable PCRE_PARTIAL unsigned-integer)
    134 (define-foreign-variable PCRE_DFA_SHORTEST unsigned-integer)
    135 (define-foreign-variable PCRE_DFA_RESTART unsigned-integer)
    136 (define-foreign-variable PCRE_FIRSTLINE unsigned-integer)
    137 (define-foreign-variable PCRE_DUPNAMES unsigned-integer)
    138 (define-foreign-variable PCRE_NEWLINE_CR unsigned-integer)
    139 (define-foreign-variable PCRE_NEWLINE_LF unsigned-integer)
    140 (define-foreign-variable PCRE_NEWLINE_CRLF unsigned-integer)
    141 (define-foreign-variable PCRE_NEWLINE_ANY unsigned-integer)
    142 (define-foreign-variable PCRE_NEWLINE_ANYCRLF unsigned-integer)
    143 (define-foreign-variable PCRE_BSR_ANYCRLF unsigned-integer)
    144 (define-foreign-variable PCRE_BSR_UNICODE unsigned-integer)
    145 
    146 (declare (hide pcre-option->number))
    147 
    148 (define (pcre-option->number opt)
    149   (case opt
    150     ((caseless)             PCRE_CASELESS)
    151     ((multiline)            PCRE_MULTILINE)
    152     ((dotall)               PCRE_DOTALL)
    153     ((extended)             PCRE_EXTENDED)
    154     ((anchored)             PCRE_ANCHORED)
    155     ((dollar-endonly)       PCRE_DOLLAR_ENDONLY)
    156     ((extra)                PCRE_EXTRA)
    157     ((notbol)               PCRE_NOTBOL)
    158     ((noteol)               PCRE_NOTEOL)
    159     ((ungreedy)             PCRE_UNGREEDY)
    160     ((notempty)             PCRE_NOTEMPTY)
    161     ((utf8)                 PCRE_UTF8)
    162     ((no-auto-capture)      PCRE_NO_AUTO_CAPTURE)
    163     ((no-utf8-check)        PCRE_NO_UTF8_CHECK)
    164     ((auto-callout)         PCRE_AUTO_CALLOUT)
    165     ((partial)              PCRE_PARTIAL)
    166     ((dfa-shortest)         PCRE_DFA_SHORTEST)
    167     ((dfa-restart)          PCRE_DFA_RESTART)
    168     ((firstline)            PCRE_FIRSTLINE)
    169     ((dupnames)             PCRE_DUPNAMES)
    170     ((newline-cr)           PCRE_NEWLINE_CR)
    171     ((newline-lf)           PCRE_NEWLINE_LF)
    172     ((newline-crlf)         PCRE_NEWLINE_CRLF)
    173     ((newline-any)          PCRE_NEWLINE_ANY)
    174     ((newline-anycrlf)      PCRE_NEWLINE_ANYCRLF)
    175     ((bsr-anycrlf)          PCRE_BSR_ANYCRLF)
    176     ((bsr-unicode)          PCRE_BSR_UNICODE)
    177     (else                   0) ) )
    178 
    179 (declare (hide pcre-options->number))
    180 
    181 (define (pcre-options->number opts)
    182   (let loop ([opts opts] [opt 0])
    183     (if (null? opts)
    184         opt
    185         (loop (cdr opts) (+ opt (pcre-option->number (car opts)))) ) ) )
    186 
    187 ;;; The regexp structure primitives:
    188 
    189 (define re-finalizer
    190   (foreign-lambda void "pcre_free" c-pointer) )
    191 
    192 (define-inline (%make-regexp code)
    193   (set-finalizer! code re-finalizer)
    194   (##sys#make-structure 'regexp code #f 0) )
    195 
    196 (define-inline (%regexp? x)
    197   (##sys#structure? x 'regexp) )
    198 
    199 (define-inline (%regexp-code rx)
    200   (##sys#slot rx 1) )
    201 
    202 (define-inline (%regexp-extra rx)
    203   (##sys#slot rx 2) )
    204 
    205 (define-inline (%regexp-options rx)
    206   (##sys#slot rx 3) )
    207 
    208 (define-inline (%regexp-extra-set! rx extra)
    209   (when extra (set-finalizer! extra re-finalizer))
    210   (##sys#setslot rx 2 extra) )
    211 
    212 (define-inline (%regexp-options-set! rx options)
    213   (##sys#setslot rx 3 options) )
    214 
    215 
    216 ;;; Character Definition Tables:
    217 
    218 ;; The minimum necessary to handle chardef table parameters.
    219 
    220 ;;
    221 
    222 (define (regex-chardef-table? x)
    223   (%tagged-pointer? x 'chardef-table) )
    224 
    225 ;; Get a character definitions tables structure for the current locale.
    226 
    227 (define regex-chardef-table
    228   (let ([re-maketables
    229           (foreign-lambda* (c-pointer unsigned-char) ()
    230             "return (pcre_maketables ());")]
    231         [re-make-chardef-table-type
    232           (lambda (tables)
    233             (%tag-pointer tables 'chardef-table) ) ] )
    234     (lambda (#!optional tables)
    235       ; Using this to type tag a ref is a bit of a hack but beats
    236       ; having another public variable.
    237       (if tables
    238           ; then existing reference so just tag it
    239           (if (##sys#pointer? tables)
    240               (re-make-chardef-table-type tables)
    241               (##sys#signal-hook #:type-error 'regex-chardef-table
    242                "bad argument type - not a pointer" tables) )
    243           ; else make a new chardef tables
    244           (let ([tables (re-maketables)])
    245             (if tables
    246                 (let ([tables (re-make-chardef-table-type tables)])
    247                   (set-finalizer! tables re-finalizer)
    248                   tables )
    249                 (##sys#error-hook 6 'regex-chardef-table) ) ) ) ) ) )
    250 
    251 
    252 ;;; Regexp record:
    253 
    254 (define (regexp? x)
    255   (%regexp? x) )
    256 
    257 
    258 ;;; PCRE errors:
    259 
    260 #>
    261 static const char *C_regex_error;
    262 static int C_regex_error_offset;
    263 <#
    264 
    265 (define-foreign-variable C_regex_error c-string)
    266 (define-foreign-variable C_regex_error_offset int)
    267 
    268 (define re-error
    269   (let ([string-append string-append])
    270     (lambda (loc msg . args)
    271       (apply ##sys#error loc (string-append msg " - " C_regex_error) args) ) ) )
    272 
    273 ;;; Compile regular expression:
    274 
    275 ;FIXME nonnull-unsigned-c-string causes problems - converted string is too long!
    276 
    277 (define re-compile
    278   (foreign-lambda* pcre ((nonnull-c-string patt) (unsigned-integer options) ((const (c-pointer unsigned-char)) tables))
    279     "return(pcre_compile(patt, options, &C_regex_error, &C_regex_error_offset, tables));") )
    280 
    281 (define (re-checked-compile pattern options tables loc)
    282   (##sys#check-string pattern loc)
    283   (or (re-compile pattern options #f)
    284       (re-error loc "cannot compile regular expression" pattern C_regex_error_offset) ) )
    285 
    286 ;; Compile with subset of options and no tables
    287 
    288 (define regexp
    289   (let ([optspatt '(caseless extended utf8)])
    290     (lambda (pattern . options)
    291       (let ([options->integer
    292               (lambda ()
    293                 (pcre-options->number (map (lambda (i o) (if i o 'zero)) options optspatt)))])
    294         (%make-regexp (re-checked-compile pattern (options->integer) #f 'regexp)) ) ) ) )
    295 
    296 ;; Compile with full options and tables available
    297 
    298 (define (regexp* pattern . args)
    299   (let-optionals args ([options '()] [tables #f])
    300     (##sys#check-string pattern 'regexp*)
    301     (##sys#check-list options 'regexp*)
    302     (when tables (##sys#check-chardef-table tables 'regexp*))
    303     (%make-regexp (re-checked-compile pattern (pcre-options->number options) tables 'regexp*)) ) )
    304 
    305 
    306 ;;; Optimize compiled regular expression:
    307 
    308 ;; Invoke optimizer
    309 
    310 (define re-study
    311   (foreign-lambda* pcre_extra (((const nonnull-pcre) code))
    312     "return(pcre_study(code, 0, &C_regex_error));"))
    313 
    314 ;; Optimize compiled regular expression
    315 ;; Returns whether optimization performed
    316 
    317 (define (regexp-optimize rx)
    318   (##sys#check-structure rx 'regexp 'regexp-optimize)
    319   (let ([extra (re-study (%regexp-code rx))])
    320     (cond [C_regex_error
    321             (re-error 'regexp-optimize "cannot optimize regular expression" rx)]
    322           [extra
    323             (%regexp-extra-set! rx extra)
    324             #t]
    325           [else
    326             #f] ) ) )
    327 
    328 
    329 ;;; Captured results vector:
    330 
    331 ;; Match positions vector (PCRE ovector)
    332 
    333 #>
    334 #define OVECTOR_LENGTH_MULTIPLE 3
    335 #define STATIC_OVECTOR_LEN 256
    336 static int C_regex_ovector[OVECTOR_LENGTH_MULTIPLE * STATIC_OVECTOR_LEN];
    337 <#
    338 
    339 ;;
    340 
    341 (define ovector-start-ref
    342   (foreign-lambda* int ((int i))
    343     "return(C_regex_ovector[i * 2]);") )
    344 
    345 (define ovector-end-ref
    346   (foreign-lambda* int ((int i))
    347     "return(C_regex_ovector[(i * 2) + 1]);") )
    348 
    349 
    350 ;;; Gather matched result strings or positions:
    351 
    352 (define (gather-result-positions result)
    353   (let ([mc (car result)]
    354         [cc (cadr result)])
    355     (and (fx> mc 0)
    356          (let loop ([i 0])
    357            (cond [(fx>= i cc)
    358                    '()]
    359                  [(fx>= i mc)
    360                    (cons #f (loop (fx+ i 1)))]
    361                  [else
    362                   (let ([start (ovector-start-ref i)])
    363                     (cons (and (fx>= start 0)
    364                                (list start (ovector-end-ref i)))
    365                           (loop (fx+ i 1)) ) ) ] ) ) ) ) )
    366 
    367 (define gather-results
    368   (let ([substring substring])
    369     (lambda (str result)
    370       (let ([ps (gather-result-positions result)])
    371         (and ps
    372              (##sys#map (lambda (poss) (and poss (apply substring str poss))) ps) ) ) ) ) )
    373 
    374 
    375 ;;; Common match string with compile regular expression:
    376 
    377 (define re-match
    378   (foreign-lambda* int (((const nonnull-pcre) code) ((const pcre_extra) extra)
    379                         (nonnull-scheme-pointer str) (int start) (int range)
    380                         (unsigned-integer options))
    381     "return(pcre_exec(code, extra, str, start + range, start, options, C_regex_ovector, STATIC_OVECTOR_LEN * OVECTOR_LENGTH_MULTIPLE));") )
    382 
    383 (define re-match-capture-count
    384   (foreign-lambda* int (((const nonnull-pcre) code) ((const pcre_extra) extra))
    385     "int cc;"
    386     "pcre_fullinfo(code, extra, PCRE_INFO_CAPTURECOUNT, &cc);"
    387     "return(cc + 1);") )
    388 
    389 (define (perform-match rgxp str si ri loc)
    390   (let* ([extra #f]
    391          [options 0]
    392          [rx
    393           (cond [(string? rgxp)
    394                   (re-checked-compile rgxp 0 #f loc)]
    395                 [(%regexp? rgxp)
    396                   (set! extra (%regexp-extra rgxp))
    397                   (set! options (%regexp-options rgxp))
    398                   (%regexp-code rgxp)]
    399                 [else
    400                   (##sys#signal-hook #:type-error
    401                                      loc
    402                                      "bad argument type - not a string or compiled regular expression"
    403                                      rgxp)] )]
    404          [cc (re-match-capture-count rx extra)]
    405          [mc (re-match rx extra str si ri options)])
    406     (when (string? rgxp) (re-finalizer rx))
    407     (list mc cc) ) )
    408 
    409 
    410 ;;; Match string with regular expression:
    411 
    412 ;; Note that start is a BYTE offset
    413 
    414 (define string-match)
    415 (define string-match-positions)
    416 (let ()
    417 
    418   (define (prepare-match rgxp str start loc)
    419     (##sys#check-string str loc)
    420     (let ([si (if (pair? start) (car start) 0)])
    421       (##sys#check-exact si loc)
    422       (perform-match (if (string? rgxp)
    423                          (make-anchored-pattern rgxp (fx< 0 si))
    424                          rgxp)
    425                      str si (fx- (##sys#size str) si)
    426                      loc) ) )
    427 
    428   (set! string-match
    429     (lambda (rgxp str . start)
    430       (gather-results str (prepare-match rgxp str start 'string-match)) ) )
    431 
    432   (set! string-match-positions
    433     (lambda (rgxp str . start)
    434       (gather-result-positions (prepare-match rgxp str start 'string-match-positions)) ) ) )
    435 
    436 
    437 ;;; Search string with regular expression:
    438 
    439 ;; Note that start & range are BYTE offsets
    440 
    441 
    442 (define string-search)
    443 (define string-search-positions)
    444 (let ()
    445 
    446   (define (prepare-search rgxp str start-and-range loc)
    447     (##sys#check-string str loc)
    448     (let* ([range (and (pair? start-and-range) (cdr start-and-range)) ]
    449            [si (if range (car start-and-range) 0)]
    450            [ri (if (pair? range) (car range) (fx- (##sys#size str) si))] )
    451       (##sys#check-exact si loc)
    452       (##sys#check-exact ri loc)
    453       (perform-match rgxp str si ri loc) ) )
    454 
    455   (set! string-search
    456     (lambda (rgxp str . start-and-range)
    457       (gather-results str (prepare-search rgxp str start-and-range 'string-search)) ) )
    458 
    459   (set! string-search-positions
    460     (lambda (rgxp str . start-and-range)
    461       (gather-result-positions (prepare-search rgxp str start-and-range 'string-search-positions)) ) ) )
     62(register-feature! 'regex 'irregex)
     63
     64(include "irregex.scm")
     65
     66(define-record regexp x)
     67
     68(define (regexp pat #!optional caseless extended utf8)
     69  (make-regexp
     70   (apply
     71    irregex
     72    pat
     73    (let ((opts '()))
     74      (when caseless (set! opts (cons 'i opts)))
     75      (when utf8 (set! opts (cons 'utf8 opts)))
     76      opts))) )
     77
     78(define (string-match rx str)
     79  (let ((rx (irregex rx)))
     80    (and-let* ((m (irregex-match rx str)))
     81      (let ((n (irregex-submatches rx)))
     82        (cons
     83         str
     84         (let loop ((i 0))
     85           (if (fx>= i n)
     86               '()
     87               (cons (irregex-match-substring m i) (loop (fx+ i 1))))))))))
     88
     89(define (string-match-positions rx str)
     90  (let ((rx (irregex rx)))
     91    (and-let* ((m (irregex-match rx str)))
     92      (let ((n (irregex-submatches m)))
     93        (cons
     94         (list (%irregex-match-start m 0)
     95               (%irregex-match-end m 0))
     96         (let loop ((i 0))
     97           (if (fx>= i n)
     98               '()
     99               (cons (list (irregex-match-start m i)
     100                           (irregex-match-end m i))
     101                     (loop (fx+ i 1))))))))))
     102
     103(define (string-search rx str #!optional (start 0) (range (string-length str)))
     104  (let ((rx (irregex rx)))
     105    (and-let* ((m (irregex-search rx str start (fx+ start range))))
     106      (let loop ((i (irregex-submatches rx))
     107                 (res (list (irregex-match-string m))))
     108        (if (fx< i 0)
     109            res
     110            (loop (fx- i 1)
     111                  (cons (irregex-match-substring m i) res)))))))
     112
     113(define (string-search-positions rx str #!optional (start 0) (range (string-length str)))
     114  (let ((rx (irregex rx)))
     115    (and-let* ((m (irregex-search rx str start (fx+ start range))))
     116      (let loop ((i (irregex-submatches rx))
     117                 (res (list (list (%irregex-match-start m 0)
     118                                  (%irregex-match-end m 0)))))
     119          (if (fx< i 0)
     120              '()
     121              (loop (fx- i 1)
     122                    (cons (list (irregex-match-start m i)
     123                                (irregex-match-end m i))
     124                          res)))))))
     125
    462126
    463127
     
    644308      (let ([out (open-output-string)]
    645309            [len (##sys#size str)] )
    646         (let loop ([i 0])
    647           (cond [(fx>= i len) (get-output-string out)]
     310        (let loop ([i 0])
     311          (cond [(fx>= i len) (get-output-string out)]
    648312                [(memq (##core#inline "C_subchar" str i)
    649313                       '(#\. #\\ #\? #\* #\+ #\^ #\$ #\( #\) #\[ #\] #\| #\{ #\}))
     
    654318                 (##sys#write-char-0 (##core#inline "C_subchar" str i) out)
    655319                 (loop (fx+ i 1)) ] ) ) ) ) ) )
    656 
    657 
    658 ;;; Anchored pattern:
    659 
    660 (define make-anchored-pattern
    661   (let ([string-append string-append])
    662     (lambda (rgxp . args)
    663       (let-optionals args ([nos #f] [noe #f])
    664         (cond [(string? rgxp)
    665                 (string-append (if nos "" "^") rgxp (if noe "" "$"))]
    666               [else
    667                 (##sys#check-structure rgxp 'regexp 'make-anchored-pattern)
    668                 (when (or nos noe)
    669                   (warning 'make-anchored-pattern
    670                            "cannot select partial anchor for compiled regular expression") )
    671                 (%regexp-options-set! rgxp
    672                                       (+ (%regexp-options regexp) (pcre-option->number 'anchored)))
    673                 rgxp] ) ) ) ) )
  • chicken/branches/irregular/rules.make

    r12117 r12124  
    2525# POSSIBILITY OF SUCH DAMAGE.
    2626
    27 VPATH=$(SRCDIR):$(SRCDIR)pcre
     27VPATH=$(SRCDIR)
    2828
    2929# object files
     
    5050LIBCHICKENGUI_STATIC_OBJECTS = $(LIBCHICKENGUI_OBJECTS_1:=-static$(O))
    5151
    52 ifeq ($(USE_HOST_PCRE),)
    53 PCRE_OBJECTS_1 ?= \
    54        $(PCRE_DIR)pcre_chartables \
    55        $(PCRE_DIR)pcre_compile \
    56        $(PCRE_DIR)pcre_config \
    57        $(PCRE_DIR)pcre_dfa_exec \
    58        $(PCRE_DIR)pcre_exec \
    59        $(PCRE_DIR)pcre_fullinfo \
    60        $(PCRE_DIR)pcre_get \
    61        $(PCRE_DIR)pcre_globals \
    62        $(PCRE_DIR)pcre_info \
    63        $(PCRE_DIR)pcre_maketables \
    64        $(PCRE_DIR)pcre_newline \
    65        $(PCRE_DIR)pcre_ord2utf8 \
    66        $(PCRE_DIR)pcre_refcount \
    67        $(PCRE_DIR)pcre_study \
    68        $(PCRE_DIR)pcre_tables \
    69        $(PCRE_DIR)pcre_try_flipped \
    70        $(PCRE_DIR)pcre_ucd \
    71        $(PCRE_DIR)pcre_valid_utf8 \
    72        $(PCRE_DIR)pcre_version \
    73        $(PCRE_DIR)pcre_xclass
    74 PCRE_SHARED_OBJECTS = $(PCRE_OBJECTS_1:=$(O))
    75 PCRE_STATIC_OBJECTS = $(PCRE_OBJECTS_1:=-static$(O))
    76 endif
    77 
    7852COMPILER_OBJECTS_1 = \
    7953       chicken batch-driver compiler optimizer support \
     
    139113          $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT)
    140114regex$(O): regex.c chicken.h $(CHICKEN_CONFIG_H)
    141         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) $(PCRE_INCLUDES) \
    142           $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) \
    143           $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $(C_COMPILER_PCRE_OPTIONS) $< $(C_COMPILER_OUTPUT)
     115        $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) \
     116          $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) \
     117          $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT)
    144118scheduler$(O): scheduler.c chicken.h $(CHICKEN_CONFIG_H)
    145119        $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) $(INCLUDES) \
     
    224198          $(C_COMPILER_BUILD_UNSAFE_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT)
    225199uregex$(O): uregex.c chicken.h $(CHICKEN_CONFIG_H)
    226         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) $(PCRE_INCLUDES) \
    227           $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) \
    228           $(C_COMPILER_BUILD_UNSAFE_RUNTIME_OPTIONS) $(C_COMPILER_PCRE_OPTIONS) $< $(C_COMPILER_OUTPUT)
     200        $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) \
     201          $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) \
     202          $(C_COMPILER_BUILD_UNSAFE_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT)
    229203usrfi-1$(O): usrfi-1.c chicken.h $(CHICKEN_CONFIG_H)
    230         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) $(PCRE_INCLUDES) \
     204        $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) \
    231205          $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) \
    232206          $(C_COMPILER_BUILD_UNSAFE_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT)
     
    314288          $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT)
    315289regex-static$(O): regex.c chicken.h $(CHICKEN_CONFIG_H)
    316         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) $(PCRE_INCLUDES) \
    317           $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) \
    318           $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $(C_COMPILER_PCRE_OPTIONS) $< $(C_COMPILER_OUTPUT)
     290        $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) \
     291          $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) \
     292          $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT)
    319293scheduler-static$(O): scheduler.c chicken.h $(CHICKEN_CONFIG_H)
    320294        $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) $(INCLUDES) \
     
    400374uregex-static$(O): uregex.c chicken.h $(CHICKEN_CONFIG_H)
    401375        $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) $(INCLUDES) \
    402           $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $(PCRE_INCLUDES) \
    403           $(C_COMPILER_BUILD_UNSAFE_RUNTIME_OPTIONS) $(C_COMPILER_PCRE_OPTIONS) $< $(C_COMPILER_OUTPUT)
     376          $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) \
     377          $(C_COMPILER_BUILD_UNSAFE_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT)
    404378usrfi-1-static$(O): usrfi-1.c chicken.h $(CHICKEN_CONFIG_H)
    405379        $(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_PTABLES_OPTIONS) $(INCLUDES) \
     
    595569          $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $< $(C_COMPILER_OUTPUT)
    596570
    597 # pcre objects
    598 
    599 $(PCRE_DIR)pcre_compile$(O): pcre_compile.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    600         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    601           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    602           $(C_COMPILER_PCRE_OPTIONS)
    603 $(PCRE_DIR)pcre_config$(O): pcre_config.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    604         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    605           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    606           $(C_COMPILER_PCRE_OPTIONS)
    607 $(PCRE_DIR)pcre_dfa_exec$(O): pcre_dfa_exec.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    608         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    609           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    610           $(C_COMPILER_PCRE_OPTIONS)
    611 $(PCRE_DIR)pcre_exec$(O): pcre_exec.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    612         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    613           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    614           $(C_COMPILER_PCRE_OPTIONS)
    615 $(PCRE_DIR)pcre_fullinfo$(O): pcre_fullinfo.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    616         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    617           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    618           $(C_COMPILER_PCRE_OPTIONS)
    619 $(PCRE_DIR)pcre_get$(O): pcre_get.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    620         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    621           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    622           $(C_COMPILER_PCRE_OPTIONS)
    623 $(PCRE_DIR)pcre_globals$(O): pcre_globals.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    624         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    625           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    626           $(C_COMPILER_PCRE_OPTIONS)
    627 $(PCRE_DIR)pcre_info$(O): pcre_info.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    628         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    629           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    630           $(C_COMPILER_PCRE_OPTIONS)
    631 $(PCRE_DIR)pcre_maketables$(O): pcre_maketables.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    632         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    633           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    634           $(C_COMPILER_PCRE_OPTIONS)
    635 $(PCRE_DIR)pcre_newline$(O): pcre_newline.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    636         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    637           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    638           $(C_COMPILER_PCRE_OPTIONS)
    639 $(PCRE_DIR)pcre_ord2utf8$(O): pcre_ord2utf8.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    640         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    641           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    642           $(C_COMPILER_PCRE_OPTIONS)
    643 $(PCRE_DIR)pcre_refcount$(O): pcre_refcount.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    644         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    645           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    646           $(C_COMPILER_PCRE_OPTIONS)
    647 $(PCRE_DIR)pcre_study$(O): pcre_study.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    648         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    649           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    650           $(C_COMPILER_PCRE_OPTIONS)
    651 $(PCRE_DIR)pcre_tables$(O): pcre_tables.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    652         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    653           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    654           $(C_COMPILER_PCRE_OPTIONS)
    655 $(PCRE_DIR)pcre_try_flipped$(O): pcre_try_flipped.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    656         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    657           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    658           $(C_COMPILER_PCRE_OPTIONS)
    659 $(PCRE_DIR)pcre_ucd$(O): pcre_ucd.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    660         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    661           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    662           $(C_COMPILER_PCRE_OPTIONS)
    663 $(PCRE_DIR)pcre_valid_utf8$(O): pcre_valid_utf8.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    664         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    665           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    666           $(C_COMPILER_PCRE_OPTIONS)
    667 $(PCRE_DIR)pcre_version$(O): pcre_version.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    668         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    669           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    670           $(C_COMPILER_PCRE_OPTIONS)
    671 $(PCRE_DIR)pcre_xclass$(O): pcre_xclass.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    672         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    673           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    674           $(C_COMPILER_PCRE_OPTIONS)
    675 $(PCRE_DIR)pcre_chartables$(O): pcre_chartables.c pcre_internal.h config.h $(CHICKEN_CONFIG_H)
    676         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    677           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    678           $(C_COMPILER_PCRE_OPTIONS)
    679 
    680 # static pcre objects
    681 
    682 $(PCRE_DIR)pcre_compile-static$(O): pcre_compile.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    683         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    684           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    685           $(C_COMPILER_PCRE_OPTIONS)
    686 $(PCRE_DIR)pcre_config-static$(O): pcre_config.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    687         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    688           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    689           $(C_COMPILER_PCRE_OPTIONS)
    690 $(PCRE_DIR)pcre_dfa_exec-static$(O): pcre_dfa_exec.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    691         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    692           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    693           $(C_COMPILER_PCRE_OPTIONS)
    694 $(PCRE_DIR)pcre_exec-static$(O): pcre_exec.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    695         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    696           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    697           $(C_COMPILER_PCRE_OPTIONS)
    698 $(PCRE_DIR)pcre_fullinfo-static$(O): pcre_fullinfo.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    699         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    700           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    701           $(C_COMPILER_PCRE_OPTIONS)
    702 $(PCRE_DIR)pcre_get-static$(O): pcre_get.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    703         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    704           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    705           $(C_COMPILER_PCRE_OPTIONS)
    706 $(PCRE_DIR)pcre_globals-static$(O): pcre_globals.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    707         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    708           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    709           $(C_COMPILER_PCRE_OPTIONS)
    710 $(PCRE_DIR)pcre_info-static$(O): pcre_info.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    711         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    712           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    713           $(C_COMPILER_PCRE_OPTIONS)
    714 $(PCRE_DIR)pcre_maketables-static$(O): pcre_maketables.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    715         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    716           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    717           $(C_COMPILER_PCRE_OPTIONS)
    718 $(PCRE_DIR)pcre_newline-static$(O): pcre_newline.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    719         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    720           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    721           $(C_COMPILER_PCRE_OPTIONS)
    722 $(PCRE_DIR)pcre_ord2utf8-static$(O): pcre_ord2utf8.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    723         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    724           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    725           $(C_COMPILER_PCRE_OPTIONS)
    726 $(PCRE_DIR)pcre_refcount-static$(O): pcre_refcount.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    727         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    728           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    729           $(C_COMPILER_PCRE_OPTIONS)
    730 $(PCRE_DIR)pcre_study-static$(O): pcre_study.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    731         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    732           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    733           $(C_COMPILER_PCRE_OPTIONS)
    734 $(PCRE_DIR)pcre_tables-static$(O): pcre_tables.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    735         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    736           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    737           $(C_COMPILER_PCRE_OPTIONS)
    738 $(PCRE_DIR)pcre_try_flipped-static$(O): pcre_try_flipped.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    739         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    740           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    741           $(C_COMPILER_PCRE_OPTIONS)
    742 $(PCRE_DIR)pcre_ucd-static$(O): pcre_ucd.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    743         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    744           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    745           $(C_COMPILER_PCRE_OPTIONS)
    746 $(PCRE_DIR)pcre_valid_utf8-static$(O): pcre_valid_utf8.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    747         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    748           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    749           $(C_COMPILER_PCRE_OPTIONS)
    750 $(PCRE_DIR)pcre_version-static$(O): pcre_version.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    751         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    752           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    753           $(C_COMPILER_PCRE_OPTIONS)
    754 $(PCRE_DIR)pcre_xclass-static$(O): pcre_xclass.c pcre_internal.h config.h $(CHICKEN_CONFIG_H) pcre.h ucp.h
    755         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    756           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    757           $(C_COMPILER_PCRE_OPTIONS)
    758 $(PCRE_DIR)pcre_chartables-static$(O): pcre_chartables.c pcre_internal.h config.h $(CHICKEN_CONFIG_H)
    759         $(C_COMPILER) $(C_COMPILER_OPTIONS) $(PCRE_INCLUDES) $(C_COMPILER_COMPILE_OPTION) \
    760           $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) $< $(C_COMPILER_OUTPUT) \
    761           $(C_COMPILER_PCRE_OPTIONS)
    762 
    763571# assembler objects
    764572
     
    804612libs: $(TARGETLIBS)
    805613
    806 libchicken$(SO)$(SONAME_VERSION): $(LIBCHICKEN_SHARED_OBJECTS) $(PCRE_SHARED_OBJECTS) $(APPLY_HACK_OBJECT)
     614libchicken$(SO)$(SONAME_VERSION): $(LIBCHICKEN_SHARED_OBJECTS) $(APPLY_HACK_OBJECT)
    807615        $(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_LINKER_OPTIONS) \
    808616          $(LINKER_OUTPUT) $^ $(LIBCHICKEN_SO_LIBRARIES)
     
    812620
    813621
    814 libuchicken$(SO)$(SONAME_VERSION): $(LIBUCHICKEN_SHARED_OBJECTS) $(PCRE_SHARED_OBJECTS) $(APPLY_HACK_OBJECT)
     622libuchicken$(SO)$(SONAME_VERSION): $(LIBUCHICKEN_SHARED_OBJECTS) $(APPLY_HACK_OBJECT)
    815623        $(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_LIBRARY_OPTIONS) $(LIBUCHICKEN_SO_LINKER_OPTIONS) \
    816624          $(LINKER_OUTPUT) $^ $(LIBUCHICKEN_SO_LIBRARIES)
     
    819627endif
    820628
    821 cygchicken-0.dll: $(LIBCHICKEN_SHARED_OBJECTS) $(PCRE_SHARED_OBJECTS) $(APPLY_HACK_OBJECT)
     629cygchicken-0.dll: $(LIBCHICKEN_SHARED_OBJECTS) $(APPLY_HACK_OBJECT)
    822630        gcc -shared -o $(LIBCHICKEN_SO_FILE) -Wl,--dll -Wl,--add-stdcall-alias \
    823631            -Wl,--enable-stdcall-fixup -Wl,--warn-unresolved-symbols \
     
    826634            -Wl,--out-implib=libchicken.dll.a -Wl,--export-all-symbols \
    827635            -Wl,--enable-auto-import \
    828             -Wl,--whole-archive $(LIBCHICKEN_SHARED_OBJECTS) $(PCRE_SHARED_OBJECTS) $(APPLY_HACK_OBJECT) \
     636            -Wl,--whole-archive $(LIBCHICKEN_SHARED_OBJECTS) $(APPLY_HACK_OBJECT) \
    829637            -Wl,--no-whole-archive $(LIBCHICKEN_SO_LIBRARIES)
    830638
    831 cyguchicken-0.dll: $(LIBUCHICKEN_SHARED_OBJECTS) $(PCRE_SHARED_OBJECTS) $(APPLY_HACK_OBJECT)
     639cyguchicken-0.dll: $(LIBUCHICKEN_SHARED_OBJECTS) $(APPLY_HACK_OBJECT)
    832640        gcc -shared -o $(LIBUCHICKEN_SO_FILE) -Wl,--dll -Wl,--add-stdcall-alias \
    833641            -Wl,--enable-stdcall-fixup -Wl,--warn-unresolved-symbols \
     
    836644            -Wl,--out-implib=libuchicken.dll.a -Wl,--export-all-symbols \
    837645            -Wl,--enable-auto-import \
    838             -Wl,--whole-archive $(LIBUCHICKEN_SHARED_OBJECTS) $(PCRE_SHARED_OBJECTS) $(APPLY_HACK_OBJECT) \
     646            -Wl,--whole-archive $(LIBUCHICKEN_SHARED_OBJECTS) $(APPLY_HACK_OBJECT) \
    839647            -Wl,--no-whole-archive $(LIBUCHICKEN_SO_LIBRARIES)
    840648
    841649
    842 libchickengui$(SO): $(APPLY_HACK_OBJECT) $(LIBCHICKENGUI_SHARED_OBJECTS) $(PCRE_SHARED_OBJECTS)
     650libchickengui$(SO): $(APPLY_HACK_OBJECT) $(LIBCHICKENGUI_SHARED_OBJECTS)
    843651        $(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_LIBRARY_OPTIONS) $(LIBCHICKENGUI_SO_LINKER_OPTIONS) \
    844652        $(LINKER_OUTPUT) $^ $(LIBCHICKENGUI_SO_LIBRARIES)
    845653
    846 libchicken$(A): $(APPLY_HACK_OBJECT) $(LIBCHICKEN_STATIC_OBJECTS) $(PCRE_STATIC_OBJECTS)
     654libchicken$(A): $(APPLY_HACK_OBJECT) $(LIBCHICKEN_STATIC_OBJECTS)
    847655        $(LIBRARIAN) $(LIBRARIAN_OPTIONS) $(LIBRARIAN_OUTPUT) $^
    848656
    849 libuchicken$(A): $(APPLY_HACK_OBJECT) $(LIBUCHICKEN_STATIC_OBJECTS) $(PCRE_STATIC_OBJECTS)
     657libuchicken$(A): $(APPLY_HACK_OBJECT) $(LIBUCHICKEN_STATIC_OBJECTS)
    850658        $(LIBRARIAN) $(LIBRARIAN_OPTIONS) $(LIBRARIAN_OUTPUT) $^
    851659
    852 libchickengui$(A): $(APPLY_HACK_OBJECT) $(LIBCHICKENGUI_STATIC_OBJECTS) $(PCRE_STATIC_OBJECTS)
     660libchickengui$(A): $(APPLY_HACK_OBJECT) $(LIBCHICKENGUI_STATIC_OBJECTS)
    853661        $(LIBRARIAN) $(LIBRARIAN_OPTIONS) $(LIBRARIAN_OUTPUT) $^
    854662
     
    1158966        $(CHICKEN) $< $(CHICKEN_LIBRARY_OPTIONS) -output-file $@
    1159967regex.c: $(SRCDIR)regex.scm
    1160         $(CHICKEN) $< $(CHICKEN_LIBRARY_OPTIONS) $(CHICKEN_PCRE_LIBRARY_OPTIONS) -output-file $@
     968        $(CHICKEN) $< $(CHICKEN_LIBRARY_OPTIONS) -output-file $@
    1161969scheduler.c: $(SRCDIR)scheduler.scm
    1162970        $(CHICKEN) $< $(CHICKEN_LIBRARY_OPTIONS) -output-file $@
     
    12011009        $(CHICKEN) $< $(CHICKEN_LIBRARY_OPTIONS) $(CHICKEN_UNSAFE_OPTIONS) -output-file $@
    12021010uregex.c: $(SRCDIR)regex.scm $(SRCDIR)unsafe-declarations.scm
    1203         $(CHICKEN) $< $(CHICKEN_LIBRARY_OPTIONS) $(CHICKEN_PCRE_LIBRARY_OPTIONS) $(CHICKEN_UNSAFE_OPTIONS) -output-file $@
     1011        $(CHICKEN) $< $(CHICKEN_LIBRARY_OPTIONS) $(CHICKEN_UNSAFE_OPTIONS) -output-file $@
    12041012
    12051013chicken.import.c: $(SRCDIR)chicken.import.scm
     
    13071115
    13081116ifeq ($(PLATFORM),mingw)
    1309 CLEAN_PCRE = $(PCRE_DIR)*$(O)
    13101117CLEAN_MINGW_LIBS = libchickengui.a libchickengui.dll libchickengui.dll.a
    13111118else
    1312 CLEAN_PCRE = $(PCRE_DIR)*$(O)
    13131119CLEAN_MINGW_LIBS =
    13141120endif
     
    13221128          libchicken$(A) libuchicken$(A) libchickengui$(A) libchicken$(SO) $(PROGRAM_IMPORT_LIBRARIES) \
    13231129          $(IMPORT_LIBRARIES:=.import.so) $(LIBCHICKEN_IMPORT_LIBRARY) $(LIBUCHICKEN_IMPORT_LIBRARY) $(LIBCHICKENGUI_IMPORT_LIBRARY)  \
    1324           $(MSVC_CHICKEN_EXPORT_FILES) chicken.info $(CLEAN_PCRE) $(CLEAN_MINGW_LIBS) \
     1130          $(MSVC_CHICKEN_EXPORT_FILES) chicken.info $(CLEAN_MINGW_LIBS) \
    13251131          $(CLEAN_MANIFESTS)
    13261132confclean:
  • chicken/branches/irregular/tests/runtests.sh

    r12114 r12124  
    7979$compile path-tests.scm && ./a.out
    8080
     81echo "======================================== regular expression tests ..."
     82$interpret -bnq test-irregex.scm
     83
    8184echo "======================================== r4rstest ..."
    8285$interpret -e '(set! ##sys#procedure->string (constantly "#<procedure>"))' \
Note: See TracChangeset for help on using the changeset viewer.