Changeset 8629 in project


Ignore:
Timestamp:
02/22/08 16:29:43 (12 years ago)
Author:
Kon Lovett
Message:

James Bailey's Feb 22, '08 fix for blank string decode.

Location:
release/3/base64
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/3/base64/base64.html

    r2615 r8629  
    1616<h3>Version:</h3>
    1717<ul>
     18<li>2.0
     19Fix for blank string decoding [James Bailey]
    1820<li>1.3
    19 Replaced implementation which a much faster version by James Bailey
     21Replaced implementation with a much faster version [James Bailey]
    2022<li>1.2
    2123removed read syntax
  • release/3/base64/base64.scm

    r8105 r8629  
    7777    int i, o, r;
    7878    for (i = 0, o = 0, r = len; i < len; i += 4, o += 3, r -= 3) {
    79         int n = dec_table[src[i]] << 18  | dec_table[src[i+1]] << 12 |
    80                 dec_table[src[i+2]] << 6 | dec_table[src[i+3]];
     79        int n = dec_table[(int) src[i]] << 18  | dec_table[(int) src[i+1]] << 12 |
     80                dec_table[(int) src[i+2]] << 6 | dec_table[(int) src[i+3]];
    8181        dst[o] = (n >> 16) & 255;
    8282        if (r > 1) {
     
    101101(define (base64:decode str)
    102102  (define base64_decode (foreign-lambda void base64_decode pointer c-string int))
    103   (let* ((len (string-length str))
    104          (result-len (- (* 3 (/ len 4))
    105                         (cond ((char=? (string-ref str (- len 2)) #\=) 2)
    106                               ((char=? (string-ref str (- len 1)) #\=) 1)
    107                               (else 0))))
    108          (buf (##sys#make-string result-len #f)))
    109     (base64_decode buf str len)
    110     buf))
     103  (let ((len (string-length str)))
     104    (if (zero? len)
     105      ""
     106      (let* ((result-len (- (* 3 (/ len 4))
     107                            (cond ((char=? (string-ref str (- len 2)) #\=) 2)
     108                                  ((char=? (string-ref str (- len 1)) #\=) 1)
     109                                  (else 0))))
     110             (buf (##sys#make-string result-len #f)))
     111        (base64_decode buf str len)
     112        buf))))
  • release/3/base64/base64.setup

    r8105 r8629  
    1 (compile -s -O2 -d1 base64.scm -emit-exports base64.exports)
     1(compile -s -O2 -d1 base64.scm -check-imports -emit-exports base64.exports)
    22(install-extension
    33 'base64
Note: See TracChangeset for help on using the changeset viewer.