Skip to content

Commit

Permalink
fix part of #11988
Browse files Browse the repository at this point in the history
Strip a leading "\r\n" or "\n" from triple-quoted strings.
  • Loading branch information
nolta committed Jul 2, 2015
1 parent b6ae1df commit b824dc9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1688,9 +1688,14 @@
(parse-string-literal- 0 p s custom))))

(define (strip-leading-newline s)
(if (and (> (sizeof s) 0) (eqv? (string.char s 0) #\newline))
(string.tail s 1)
s))
(let ((n (sizeof s)))
(cond
((and (> n 0) (eqv? (string.char s 0) #\newline))
(string.tail s 1))
((and (> n 1) (eqv? (string.char s 0) #\return)
(eqv? (string.char s 1) #\newline))
(string.tail s 2))
(else s))))

(define (dedent-triplequoted-string lst)
(let ((prefix (triplequoted-string-indentation lst)))
Expand Down

0 comments on commit b824dc9

Please sign in to comment.