Changeset 34886 in project


Ignore:
Timestamp:
11/11/17 23:10:15 (3 years ago)
Author:
Kon Lovett
Message:

re-flow

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/csv-xml/trunk/csv-out.impl

    r34884 r34886  
    123123
    124124(define (make-csv-line-writer loc out writer-spec)
    125 ;(print "make-csv-line-writer: " writer-spec)
    126   (let ((writer-spec
    127           (check-csv-writer-spec loc writer-spec) )
    128         (newline-obj
    129           (select-newline-object loc (alist-ref 'newline-char writer-spec eq?)) )
    130         (separator-char
    131           (alist-ref 'separator-char writer-spec eq?) )
    132         (quote-char
    133           (alist-ref 'quote-char writer-spec eq?) )
    134         (comment-char
    135           (alist-ref 'comment-char writer-spec eq?) )
    136         (quote-doubling-escapes?
    137           (alist-ref 'quote-doubling-escapes? writer-spec eq?) )
    138         (quote-controls?
    139           (alist-ref 'quote-controls? writer-spec eq?) )
    140         (always-quote?
    141           (alist-ref 'always-quote? writer-spec eq?) ) )
     125  (let (
     126    (writer-spec
     127      (check-csv-writer-spec loc writer-spec) )
     128    (newline-obj
     129      (select-newline-object loc (alist-ref 'newline-char writer-spec eq?)) )
     130    (separator-char
     131      (alist-ref 'separator-char writer-spec eq?) )
     132    (quote-char
     133      (alist-ref 'quote-char writer-spec eq?) )
     134    (comment-char
     135      (alist-ref 'comment-char writer-spec eq?) )
     136    (quote-doubling-escapes?
     137      (alist-ref 'quote-doubling-escapes? writer-spec eq?) )
     138    (quote-controls?
     139      (alist-ref 'quote-controls? writer-spec eq?) )
     140    (always-quote?
     141      (alist-ref 'always-quote? writer-spec eq?) ) )
     142    ;
    142143    (let* (
    143144      (quote-char-str (unicode-char->string quote-char) )
    144145      (quote-char-str-2 (string-append quote-char-str quote-char-str)) )
    145146      ;
     147      (define (csv-line-object->string obj)
     148        ;
     149        (define (quote-doubling? str)
     150          (and quote-doubling-escapes? (string-index str quote-char)) )
     151        ;
     152        (define (quoting? str)
     153          (or
     154            always-quote?
     155            (quote-doubling? str)
     156            (and quote-controls? (string-index str char-set:iso-control))) )
     157        ;
     158        (type-case obj
     159          ((char)
     160            (csv-line-object->string (unicode-char->string obj)) )
     161          ((symbol)
     162            (csv-line-object->string (symbol->string obj)) )
     163          ((string)
     164            (if (and quote-char (quoting? obj))
     165              (let (
     166                (str
     167                  (if (quote-doubling? obj)
     168                    (string-translate* obj `((,quote-char-str . ,quote-char-str-2)))
     169                    obj ) ) )
     170                ;
     171                (conc quote-char str quote-char) )
     172              obj ) )
     173          (number
     174            (csv-line-object->string (number->string obj)) )
     175          (else
     176            (->string obj) ) ) )
     177      ;
    146178      (lambda (obj)
    147         ;
    148         (define (csv-line-object->string obj)
    149           ;
    150           (define (quote-doubling? str)
    151             (and quote-doubling-escapes? (string-index str quote-char)) )
    152           ;
    153           (define (quoting? str)
    154             (or
    155               always-quote?
    156               (quote-doubling? str)
    157               (and quote-controls? (string-index str char-set:iso-control))) )
    158           ;
    159           (type-case obj
    160             ((char)
    161               (csv-line-object->string (unicode-char->string obj)) )
    162             ((symbol)
    163               (csv-line-object->string (symbol->string obj)) )
    164             ((string)
    165               (if (and quote-char (quoting? obj))
    166                 (let (
    167                   (str
    168                     (if (quote-doubling? obj)
    169                       (string-translate* obj `((,quote-char-str . ,quote-char-str-2)))
    170                       obj ) ) )
    171                   ;
    172                   (conc quote-char str quote-char) )
    173                 obj ) )
    174             (number
    175               (csv-line-object->string (number->string obj)) )
    176             (else
    177               (->string obj) ) ) )
    178         ;
    179         (let* (
     179        (let (
    180180          ;build row to output as a string with a line-ending sequence
    181181          (lin
Note: See TracChangeset for help on using the changeset viewer.