From e69a99cc4c183a98dd380fdaf47a5a1dcb5d68a0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 5 Apr 2018 06:53:24 -0700 Subject: printer: improve object formatting. There is an issue with the printer in that it produces output whereby objects continue on the same line after a multi-line object, e.g: (foo (foobly bar xyzzy quux) (oops same line)) rather than: (foo (foobly bar xyzzy quux) (oops same line)) There is a simple fix for this: set a flag to force a line break on the next width-check operation whenever an object has been broken into multiple lines. width-check can return a Boolean indication whether it generated a line break, and so aggregate object printing routines can tell whether their object has been broken into lines, and set the flag. * stream.h (struct strm_base): New member, force_break. (force_break): Declared. * stream.c (strm_base_init): Extent initializer to cover force_break flag. (put_string, put_char): Clear the force_break flag whenever we hit column zero. (width_check): If indent mode is on, and force_break is true, generate a break. Clear force_break. (force_break): New function. (stream_init): Register force-break intrinsic. * buf.c (buf_print): Set the force break flag if the buffer was broken into multiple lines. * hash.c (hash_print_op): Set the force break flag if the hash was broken into multiple lines. * lib.c (obj_print_impl): Same logic for lists. * struct.c (struct_inst_print): Same logic for structs. * tests/009/json.expected, tests/011/macros-2.expected, tests/012/struct.tl, tests/017/glob-zarray.expected: Update expected textual output to reflect new formatting. --- tests/009/json.expected | 8 +++++--- tests/011/macros-2.expected | 5 +++-- tests/012/struct.tl | 6 ++++-- tests/017/glob-zarray.expected | 3 ++- 4 files changed, 14 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/009/json.expected b/tests/009/json.expected index 8bc4ab9a..8c3fc4c6 100644 --- a/tests/009/json.expected +++ b/tests/009/json.expected @@ -19,8 +19,9 @@ AST: #H(() ("web-app" #H(() ("servlet-mapping" #H(() ("cofaxTools" "/tools/*") ( ("dataStoreUrl" "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon") ("useDataStore" :true) ("cachePackageTagsTrack" 200.0) ("searchEngineFileTemplate" "forSearchEngines.htm") ("cachePackageTagsStore" 200.0) ("cachePagesRefresh" 10.0))) - ("servlet-name" "cofaxCDS")) #H(() ("servlet-class" "org.cofax.cds.EmailServlet") ("init-param" #H(() ("mailHost" "mail1") ("mailHostOverride" "mail2"))) - ("servlet-name" "cofaxEmail")) + ("servlet-name" "cofaxCDS")) + #H(() ("servlet-class" "org.cofax.cds.EmailServlet") ("init-param" #H(() ("mailHost" "mail1") ("mailHostOverride" "mail2"))) + ("servlet-name" "cofaxEmail")) #H(() ("servlet-class" "org.cofax.cds.AdminServlet") ("servlet-name" "cofaxAdmin")) #H(() ("servlet-class" "org.cofax.cds.FileServlet") ("servlet-name" "fileServlet")) #H(() ("servlet-class" "org.cofax.cms.CofaxToolsServlet") ("init-param" #H(() ("lookInContext" 1.0) ("removePageCache" "/content/admin/remove?cache=pages&id=") @@ -29,7 +30,8 @@ AST: #H(() ("web-app" #H(() ("servlet-mapping" #H(() ("cofaxTools" "/tools/*") ( ("log" 1.0) ("adminGroupID" 4.0) ("templatePath" "toolstemplates/") ("betaServer" :true) ("dataLogLocation" "/usr/local/tomcat/logs/dataLog.log") ("fileTransferFolder" "/usr/local/tomcat/webapps/content/fileTransferFolder"))) - ("servlet-name" "cofaxTools")))) ("taglib" #H(() ("taglib-uri" "cofax.tld") ("taglib-location" "/WEB-INF/tlds/cofax.tld")))))) + ("servlet-name" "cofaxTools")))) + ("taglib" #H(() ("taglib-uri" "cofax.tld") ("taglib-location" "/WEB-INF/tlds/cofax.tld")))))) Unmatched junk: "" diff --git a/tests/011/macros-2.expected b/tests/011/macros-2.expected index 7dad1247..0e4cb622 100644 --- a/tests/011/macros-2.expected +++ b/tests/011/macros-2.expected @@ -14,8 +14,9 @@ ((< i 100) ()) () (block #:cnt-blk-0001 (if (< (sys:setq i (succ i)) - 20) (return-from - #:cnt-blk-0001)) + 20) + (return-from + #:cnt-blk-0001)) (if (> i 30) (return-from #:brk-blk-0002)) diff --git a/tests/012/struct.tl b/tests/012/struct.tl index 7b0b7fd8..99b2a3eb 100644 --- a/tests/012/struct.tl +++ b/tests/012/struct.tl @@ -50,11 +50,13 @@ (set *gensym-counter* 0) (stest (ignwarn (sys:expand 's.(a).d)) "(slot (call (slot s 'a)\n \ - \ s) 'd)") + \ s)\n \ + \ 'd)") (set *gensym-counter* 0) (stest (ignwarn (sys:expand 's.(a b c).d)) "(slot (call (slot s 'a)\n \ - \ s b c)\n 'd)") + \ s b c)\n \ + \ 'd)") (test s.a 100) diff --git a/tests/017/glob-zarray.expected b/tests/017/glob-zarray.expected index 4bfc0810..cd54b421 100644 --- a/tests/017/glob-zarray.expected +++ b/tests/017/glob-zarray.expected @@ -1,3 +1,4 @@ 0 #S(glob-t pathc 4 pathv #("tests/001/query-1.txr" "tests/001/query-2.txr" "tests/001/query-3.txr" - "tests/001/query-4.txr") reserve 0) + "tests/001/query-4.txr") + reserve 0) -- cgit v1.2.3