Changeset 35184 in project


Ignore:
Timestamp:
02/23/18 19:11:29 (10 months ago)
Author:
kon
Message:

add string-utils-extensions

Location:
release/4/string-utils
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • release/4/string-utils/trunk/memoized-string.scm

    r35129 r35184  
    1515
    1616(import scheme chicken)
    17 
    1817(use
    1918  (only srfi-1 every)
     
    3635
    3736(: global-string (string -> string))
     37;
    3838(define (global-string str)
    3939  (*make-string+ (check-string 'global-string str)) )
     
    4141;;
    4242
    43 (: string+ (#!rest (list-of char) -> string))
     43(: string+ (#!rest char -> string))
     44;
    4445(define (string+ . chars)
    4546  (let ((len (length chars)))
     
    5455;len - length of string in chars
    5556(: make-string+ (number #!optional char -> string))
     57;
    5658(define (make-string+ len #!optional (fill #\space))
    5759  (*make-string+
     
    6264
    6365(: *make-string+ (#!rest -> string))
     66;
    6467(define *make-string+
    6568  (let ((+global-strings+ (make-hash-table equal?)))
    6669    ;
    67     (define (addTop len ch dat)
     70    (define (ensureIndexEntry len ch dat)
    6871      (let ((key `(,len . ,ch)))
    6972        (or
     
    7376            dat ) ) ) )
    7477    ;
    75     (define (addStr len ch str)
     78    (define (ensureStringEntry len ch str)
    7679      (let (
    77         (strtbl (addTop len ch (delay (make-hash-table string=? string-hash))) )
     80        (strtbl (ensureIndexEntry len ch (delay (make-hash-table string=? string-hash))) )
    7881        (str (force str) ) )
    79         ;
    8082        (or
    8183          (hash-table-ref/default strtbl str #f)
     
    9698        (if (fx= 0 len)
    9799          *empty-string*
    98           (addStr len ch str) ) ) ) ) )
     100          (ensureStringEntry len ch str) ) ) ) ) )
    99101
    100102;DEPRECATED
     103
    101104(define memorize-string global-string)
    102105(define make-string* make-string+)
  • release/4/string-utils/trunk/string-hexadecimal.scm

    r35129 r35184  
    1010
    1111(import scheme chicken)
    12 
    1312(use
    1413  (only lolevel number-of-bytes)
     
    4039
    4140(: string->hex (string #!optional fixnum (or boolean fixnum) --> string))
     41;
    4242(define (string->hex str #!optional (start 0) (end #f))
    4343  (check-string 'string->hex str)
     
    4747
    4848(: hex->string (string #!optional fixnum --> string))
     49;
    4950(define (hex->string str #!optional (start 0) (end #f))
    5051  (let ((len (number-of-bytes (check-string 'hex->string str))))
     
    5859
    5960(: *string->hex (string fixnum fixnum --> string))
     61;
    6062(define (*string->hex str start end)
    6163  (let ((len (fx- end start)))
     
    6567
    6668(: *hex->string (string fixnum fixnum --> string))
     69;
    6770(define (*hex->string str start end)
    6871  (let ((len (fx- end start)))
  • release/4/string-utils/trunk/string-utils.meta

    r34809 r35184  
    1919  "unicode-utils.scm"
    2020  "memoized-string.scm"
     21  "string-utils-extensions.scm"
    2122  "string-interpolation-syntax.scm"
    2223  "string-interpolation.scm" "utf8-string-interpolation.scm" "string-interpolation-body.scm"
  • release/4/string-utils/trunk/string-utils.scm

    r34823 r35184  
    44(module string-utils ()
    55
    6 (import scheme)
    7 
    8 (import chicken)
    9 
     6(import scheme chicken)
    107(reexport
    118  memoized-string
    129  unicode-utils
    13   string-hexadecimal)
     10  string-hexadecimal
     11  string-utils-extensions)
    1412(require-library
    1513  memoized-string
    1614  unicode-utils
    17   string-hexadecimal)
     15  string-hexadecimal
     16  string-utils-extensions)
    1817
    1918) ;module string-utils
  • release/4/string-utils/trunk/string-utils.setup

    r35129 r35184  
    55(verify-extension-name "string-utils")
    66
    7 (setup-shared-extension-module 'string-interpolation-syntax (extension-version "1.5.6")
     7(setup-shared-extension-module 'string-interpolation-syntax (extension-version "1.6.0")
    88  ;#:inline? #t
    99  #:types? #t
     
    1313    -no-procedure-checks))
    1414
    15 (setup-shared-extension-module 'string-interpolation (extension-version "1.5.6")
     15(setup-shared-extension-module 'string-interpolation (extension-version "1.6.0")
    1616  ;#:inline? #t
    1717  #:types? #t
     
    2121    -no-procedure-checks))
    2222
    23 (setup-shared-extension-module 'utf8-string-interpolation (extension-version "1.5.6")
     23(setup-shared-extension-module 'utf8-string-interpolation (extension-version "1.6.0")
    2424  ;#:inline? #t
    2525  #:types? #t
     
    2929    -no-procedure-checks))
    3030
    31 (setup-shared-extension-module 'unicode-utils (extension-version "1.5.6")
     31(setup-shared-extension-module 'unicode-utils (extension-version "1.6.0")
    3232  #:inline? #t
    3333  #:types? #t
     
    3838    -no-procedure-checks))
    3939
    40 (setup-shared-extension-module 'memoized-string (extension-version "1.5.6")
     40(setup-shared-extension-module 'memoized-string (extension-version "1.6.0")
    4141  #:inline? #t
    4242  #:types? #t
     
    4848    -no-procedure-checks))
    4949
    50 (setup-shared-extension-module 'to-hex (extension-version "1.5.6"))
     50(setup-shared-extension-module 'to-hex (extension-version "1.6.0"))
    5151
    52 (setup-shared-extension-module 'string-hexadecimal (extension-version "1.5.6")
     52(setup-shared-extension-module 'string-hexadecimal (extension-version "1.6.0")
    5353  #:inline? #t
    5454  #:types? #t
     
    5959    -no-procedure-checks))
    6060
    61 (setup-shared-extension-module 'string-utils (extension-version "1.5.6")
     61(setup-shared-extension-module 'string-utils-extensions (extension-version "1.6.0")
    6262  #:inline? #t
    6363  #:types? #t
     
    6767    -O3 -d1
    6868    -no-procedure-checks))
     69
     70(setup-shared-extension-module 'string-utils (extension-version "1.6.0")
     71  #:inline? #t
     72  #:types? #t
     73  #:compile-options '(
     74    -scrutinize
     75    -fixnum-arithmetic
     76    -O3 -d1
     77    -no-procedure-checks))
  • release/4/string-utils/trunk/tests/string-utils-test.scm

    r34809 r35184  
    9595  (test '("foo 3 bar") (list (call-with-input-string "#\"foo ${(+ 1 2)} bar\"" read)))
    9696  (set-sharp-string-interpolation-syntax #f)
    97 (test-end)
     97(test-end "String Interpolation SYNTAX")
    9898
    99 (test-end)
     99;;
     100
     101(use string-utils-extensions)
     102
     103(test-group "string-utils-extensions"
     104        (let* (
     105          (str "12345f")
     106          (res (string-copy-over! "abcde" str)) )
     107          (test-assert "string-copy-over! return" (eq? str res))
     108          (test "string-copy-over! operation" "abcdef" res) )
     109        (test "23" (string-copy* "12345f" 1 3))
     110        (test "2345f0000" (string-copy* "12345f" 1 10 #\0))
     111        (test 0 (string-count* (lambda (a b) (char=? a b)) "ac" "bdq"))
     112        (test 2 (string-count* (lambda (a b) (char=? a b)) "aca" "adaq"))
     113        (test #\z (string-any* (lambda (a b) (and (char=? a b) a)) "aczq" "bdz"))
     114        (test #\z (string-every* (lambda (a b) (and (char=? a b) a)) "az" "azq"))
     115)
     116
     117;;
     118
     119(test-end "String Utils")
    100120
    101121(test-exit)
  • release/4/string-utils/trunk/unicode-utils.scm

    r35129 r35184  
    1818
    1919(import scheme chicken)
    20 
    2120(use
    2221  (only srfi-1 every make-list)
     
    3433
    3534(: ascii-codepoint? (* -> boolean : char))
     35;
    3636(define (ascii-codepoint? ch)
    3737  (and
     
    4141
    4242(: unicode-char->string (char --> string))
     43;
    4344(define (unicode-char->string ch)
    4445  (##sys#char->utf8-string (check-char 'unicode-char->string ch)) )
     
    4647;inefficient
    4748(: unicode-string (#!rest (list-of char) --> string))
     49;
    4850(define (unicode-string . chs)
    4951  (if (null? chs)
     
    5658
    5759(: generic-make-string (fixnum char --> string))
     60;
    5861(define (generic-make-string len ch)
    5962  (if (ascii-codepoint? ch)
     
    6265
    6366(: unicode-make-string (fixnum #!optional char --> string))
     67;
    6468(define (unicode-make-string len #!optional (fill #\space))
    6569  (*unicode-make-string
     
    6872
    6973(: unicode-surrogate? (* -> boolean : fixnum))
     74;
    7075(define (unicode-surrogate? n)
    7176  (and
     
    7479
    7580(: unicode-surrogates->codepoint (fixnum fixnum --> (or boolean fixnum)))
     81;
    7682(define (unicode-surrogates->codepoint hi lo)
    7783  (##sys#surrogates->codepoint
     
    8086
    8187(: *unicode-make-string (fixnum char --> string))
     88;
    8289(define (*unicode-make-string len fill)
    8390  (cond
     
    9198;inefficient
    9299(: *unicode-string ((list-of char) --> string))
     100;
    93101(define (*unicode-string chs)
    94102  (cond
Note: See TracChangeset for help on using the changeset viewer.