Changed multiline text support to deal properly with double backslashes, for example '\\\\n' on command line gives '\\n' which should print '\n' not act as a newline

This commit is contained in:
John Whitington 2013-10-18 11:52:01 +01:00
parent 97928bc5a0
commit c02f47cf4f
3 changed files with 38 additions and 8 deletions

View File

@ -1707,6 +1707,7 @@ let addtext
let split_at_newline t =
let rec split_at_newline_inner prev = function
| [] -> rev (map implode (map rev prev))
| '\\'::'\\'::'n'::t -> split_at_newline_inner (('n'::'\\'::'\\'::hd prev)::tl prev) t
| '\\'::'n'::t -> split_at_newline_inner ([]::prev) t
| h::t -> split_at_newline_inner ((h::hd prev)::tl prev) t
in
@ -1716,7 +1717,8 @@ let rec unescape_chars prev = function
| [] -> rev prev
| '\\'::('0'..'9' as a)::('0'..'9' as b)::('0'..'9' as c)::t ->
let chr = char_of_int (int_of_string ("0o" ^ implode [a;b;c])) in
unescape_chars (chr::prev) t
unescape_chars (chr::prev) t
| '\\'::'\\'::t -> unescape_chars ('\\'::prev) t
| '\\'::c::t when c <> 'n' -> unescape_chars (c::prev) t
| h::t -> unescape_chars (h::prev) t
@ -1753,9 +1755,8 @@ let
flprint "\n";*)
ops_metrics := [];
let text = winansi_of_utf8 text in
let text = unescape_string text in
let lines = split_at_newline text
and pdf = ref pdf in
let lines = map unescape_string (split_at_newline text) in
let pdf = ref pdf in
let voffset =
match position with
| Bottom _ | BottomLeft _ | BottomRight _ ->

View File

@ -1,9 +1,9 @@
(* cpdf command line tools *)
let demo = false
and noncomp = true
and major_version = 1
and minor_version = 8
and version_date = "(unreleased)"
let noncomp = false
let major_version = 1
let minor_version = 8
let version_date = "(unreleased)"
open Pdfutil
open Pdfio

29
hello.pdf Normal file
View File

@ -0,0 +1,29 @@
%PDF-1.1
%€<>ƒ
1 0 obj
<</Type/Page/Parent 3 0 R/Resources<</Font<</F0<</Type/Font/Subtype/Type1/BaseFont/Times-Italic>>>>>>/MediaBox[0 0 595.275590551 841.88976378]/Rotate 0/Contents[4 0 R]>>
endobj
2 0 obj
<</Type/Catalog/Pages 3 0 R>>
endobj
3 0 obj
<</Type/Pages/Kids[1 0 R]/Count 1>>
endobj
4 0 obj
<</Length 53>>
stream
1 0 0 1 50 770 cm BT /F0 36 Tf (Hello, World!) Tj ET
endstream
endobj
xref
0 5
0000000000 65535 f
0000000015 00000 n
0000000200 00000 n
0000000245 00000 n
0000000296 00000 n
trailer
<</Size 5/Root 2 0 R/ID[(Š´DU~b™ÀŒ<C380>X&)(Š´DU~b™ÀŒ<C380>X&)]>>
startxref
397
%%EOF