Changeset 35834 in project


Ignore:
Timestamp:
07/10/18 02:31:40 (6 days ago)
Author:
kon
Message:

i had a reason

Location:
release/5/string-utils/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • release/5/string-utils/trunk/string-hexadecimal.scm

    r35791 r35834  
    33;;;; Kon Lovett, Aug '17
    44;;;; Kon Lovett, Aug '10
    5 
    6 #>
    7 static void
    8 bv_to_hex( uint8_t *out, uint8_t *in, int off, int len )
    9 {
    10   static char digits[] = "0123456789abcdef";
    11 
    12   in += off;
    13   while( len-- ) {
    14     *out++ = digits[ *in >> 4 ];
    15     *out++ = digits[ *in++ & 0x0f ];
    16   }
    17 }
    18 
    19 static void
    20 hex_to_bv( uint8_t *out, uint8_t *in, int off, int len )
    21 {
    22 # define hex_nibble(c)  (isdigit(c) ? ((c) - '0') : (((c) - 'a') + 10))
    23 
    24   in += off;
    25   while( 0 <= (len -= 2) ) {
    26     unsigned char in0 = tolower( in[0] );
    27     unsigned char in1 = tolower( in[1] );
    28     *out++ = (hex_nibble( in0 ) << 4) | hex_nibble( in1 );
    29     in += 2;
    30   }
    31 
    32 # undef hex_nibble
    33 }
    34 <#
    355
    366(declare
     
    4212
    4313(;export
    44   ;
    45   mem_to_hex
    46   s8vec_to_hex
    47   u8vec_to_hex
    48   blob_to_hex
    49   str_to_hex
    50   ;
    51   hex_to_str
    52   hex_to_blob
    53   ;
    5414  string->hex *string->hex
    5515  hex->string *hex->string)
     
    6121  (chicken foreign)
    6222  (chicken memory representation)
     23  to-hex
    6324  (only type-checks check-natural-fixnum check-string))
    6425
     
    7637      (check-natural-fixnum loc end 'end))
    7738    (##sys#signal-hook #:bounds-error loc "illegal subvector specification" start end) ) )
    78 
    79 ;;
    80 
    81 (define C_str_to_hex
    82   (foreign-lambda void "bv_to_hex" nonnull-scheme-pointer nonnull-scheme-pointer int int))
    83 
    84 (define C_blob_to_hex
    85   (foreign-lambda void "bv_to_hex" nonnull-scheme-pointer nonnull-blob int int))
    86 
    87 (define C_u8vec_to_hex
    88   (foreign-lambda void "bv_to_hex" nonnull-scheme-pointer nonnull-u8vector int int))
    89 
    90 (define C_s8vec_to_hex
    91   (foreign-lambda*
    92       void ((nonnull-scheme-pointer out) (nonnull-s8vector in) (int off) (int len))
    93     "bv_to_hex( out, ((uint8_t *) in), off, len );"))
    94 
    95 (define C_mem_to_hex
    96   (foreign-lambda void "bv_to_hex" nonnull-scheme-pointer nonnull-c-pointer int int))
    97 
    98 ;;
    99 
    100 (define C_hex_to_str
    101   (foreign-lambda void "hex_to_bv" nonnull-scheme-pointer nonnull-scheme-pointer int int))
    102 
    103 ;;
    104 
    105 (: str_to_hex (string string fixnum fixnum -> string))
    106 ;
    107 (define (str_to_hex out in off len)
    108   (C_str_to_hex out in off len)
    109   out )
    110 
    111 (: blob_to_hex (string blob fixnum fixnum -> string))
    112 ;
    113 (define (blob_to_hex out in off len)
    114   (C_blob_to_hex out in off len)
    115   out )
    116 
    117 (: u8vec_to_hex (string u8vector fixnum fixnum -> string))
    118 ;
    119 (define (u8vec_to_hex out in off len)
    120   (C_u8vec_to_hex out in off len)
    121   out )
    122 
    123 (: s8vec_to_hex (string s8vector fixnum fixnum -> string))
    124 ;
    125 (define (s8vec_to_hex out in off len)
    126   (C_s8vec_to_hex out in off len)
    127   out )
    128 
    129 (: mem_to_hex (string pointer fixnum fixnum -> string))
    130 ;
    131 (define (mem_to_hex out in off len)
    132   (C_mem_to_hex out in off len)
    133   out )
    134 
    135 ;;
    136 
    137 (: hex_to_str (string string fixnum fixnum -> string))
    138 ;
    139 (define (hex_to_str out in off len)
    140   (C_hex_to_str out in off len)
    141   out )
    142 
    143 (: hex_to_blob (blob string fixnum fixnum -> blob))
    144 ;
    145 (define (hex_to_blob out in off len)
    146   (C_hex_to_str out in off len)
    147   out )
    148 
    14939
    15040;;
  • release/5/string-utils/trunk/string-utils.egg

    r35814 r35834  
    33
    44((synopsis "String Utilities")
    5  (version "2.0.4")
     5 (version "2.0.5")
    66 (category data)
    77 (author "[[kon lovett]]")
     
    1515 (test-dependencies test)
    1616 (components
     17  (extension to-hex
     18    #;(inline-file)
     19    (types-file)
     20    (csc-options "-O3" "-d1" "-no-procedure-checks") )
    1721  (extension string-hexadecimal
    1822    #;(inline-file)
    1923    (types-file)
     24    (component-dependencies to-hex)
    2025    (csc-options "-O3" "-d1" "-no-procedure-checks") )
    2126  (extension unicode-utils
  • release/5/string-utils/trunk/tests/string-utils-test.scm

    r35810 r35834  
    99;;;
    1010
    11 (import unicode-utils string-hexadecimal)
     11(import unicode-utils to-hex string-hexadecimal)
    1212
    1313(test-group "Unicode"
Note: See TracChangeset for help on using the changeset viewer.