summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-08-04 08:34:04 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-08-04 08:34:04 -0700
commit7b226277f9ab1d27c657e80e4a44c43c0bedf002 (patch)
tree1f971f10d80119d3b8ddc89d7140697cc8cee07c
parentc595d3043110cf1820d22e17454e4cf787562894 (diff)
downloadtxr-7b226277f9ab1d27c657e80e4a44c43c0bedf002.tar.gz
txr-7b226277f9ab1d27c657e80e4a44c43c0bedf002.tar.bz2
txr-7b226277f9ab1d27c657e80e4a44c43c0bedf002.zip
* stream.c (indent_mode_put_string): Function removed,
logic hoisted into put_string. (put_string, put_char): Always count column, indent mode or not. * tests/009/json.expected: Updated.
-rw-r--r--ChangeLog8
-rw-r--r--stream.c21
-rw-r--r--tests/009/json.expected94
3 files changed, 59 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index ba297dcd..60f541e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-08-04 Kaz Kylheku <kaz@kylheku.com>
+
+ * stream.c (indent_mode_put_string): Function removed,
+ logic hoisted into put_string.
+ (put_string, put_char): Always count column, indent mode or not.
+
+ * tests/009/json.expected: Updated.
+
2015-08-03 Kaz Kylheku <kaz@kylheku.com>
Define TXR_DBG macro when compiling debug build.
diff --git a/stream.c b/stream.c
index 6e85012f..a741676d 100644
--- a/stream.c
+++ b/stream.c
@@ -2559,9 +2559,11 @@ static val put_indent(val stream, struct strm_ops *ops, cnum chars)
return t;
}
-static val indent_mode_put_string(val stream, val string,
- struct strm_ops *ops, struct strm_base *s)
+val put_string(val string, val stream_in)
{
+ val stream = default_arg(stream_in, std_output);
+ struct strm_ops *ops = coerce(struct strm_ops *, cobj_ops(stream, stream_s));
+ struct strm_base *s = coerce(struct strm_base *, stream->co.handle);
cnum col = s->column;
const wchar_t *str = c_str(string), *p = str;
val ret;
@@ -2587,18 +2589,6 @@ static val indent_mode_put_string(val stream, val string,
return ret;
}
-val put_string(val string, val stream_in)
-{
- val stream = default_arg(stream_in, std_output);
- struct strm_ops *ops = coerce(struct strm_ops *, cobj_ops(stream, stream_s));
- struct strm_base *s = coerce(struct strm_base *, stream->co.handle);
-
- if (s->indent_mode == indent_off)
- return ops->put_string(stream, string);
-
- return indent_mode_put_string(stream, string, ops, s);
-}
-
val put_char(val ch, val stream_in)
{
val stream = default_arg(stream_in, std_output);
@@ -2606,9 +2596,6 @@ val put_char(val ch, val stream_in)
struct strm_base *s = coerce(struct strm_base *, stream->co.handle);
wint_t cch = c_chr(ch);
- if (s->indent_mode == indent_off)
- return ops->put_char(stream, ch);
-
switch (cch) {
case L'\n':
if (ops->put_char(stream, ch) &&
diff --git a/tests/009/json.expected b/tests/009/json.expected
index 643ed5b7..eea65fb8 100644
--- a/tests/009/json.expected
+++ b/tests/009/json.expected
@@ -1,55 +1,55 @@
AST: #H((:equal-based) ("web-app" #H((:equal-based) ("servlet-mapping" #H((:equal-based) ("cofaxTools" "/tools/*") ("cofaxCDS" "/") ("cofaxAdmin" "/admin/*")
- ("cofaxEmail" "/cofaxutil/aemail/*") ("fileServlet" "/static/*")))
- ("servlet" #(#H((:equal-based) ("servlet-class" "org.cofax.cds.CDSServlet") ("init-param" #H((:equal-based) ("defaultFileTemplate" "articleTemplate.htm")
- ("configGlossary:installationAt" "Philadelphia, PA") ("templateOverridePath" "")
- ("dataStoreLogLevel" "debug") ("searchEngineListTemplate" "forSearchEnginesList.htm")
- ("dataStoreClass" "org.cofax.SqlDataStore") ("configGlossary:poweredBy" "Cofax")
- ("jspFileTemplate" "articleTemplate.jsp") ("cacheTemplatesTrack" 100.0)
- ("cacheTemplatesStore" 50.0) ("templateProcessorClass" "org.cofax.WysiwygTemplate")
- ("dataStoreUser" "sa") ("redirectionClass" "org.cofax.SqlRedirection")
- ("dataStoreConnUsageLimit" 100.0) ("dataStoreMaxConns" 100.0)
- ("jspListTemplate" "listTemplate.jsp") ("useJSP" :false) ("configGlossary:poweredByIcon" "/images/cofax.gif")
- ("templateLoaderClass" "org.cofax.FilesTemplateLoader") ("cacheTemplatesRefresh" 15.0)
- ("cachePagesDirtyRead" 10.0) ("searchEngineRobotsDb" "WEB-INF/robots.db")
- ("cachePagesStore" 100.0) ("dataStoreTestQuery" "SET NOCOUNT ON;select test='test';")
- ("configGlossary:adminEmail" "ksm@pobox.com") ("configGlossary:staticPath" "/content/static")
- ("dataStoreInitConns" 10.0) ("cachePagesTrack" 200.0) ("dataStorePassword" "dataStoreTestQuery")
- ("defaultListTemplate" "listTemplate.htm") ("dataStoreLogFile" "/usr/local/tomcat/logs/datastore.log")
- ("maxUrlLength" 500.0) ("dataStoreDriver" "com.microsoft.jdbc.sqlserver.SQLServerDriver")
- ("dataStoreName" "cofax") ("cachePackageTagsRefresh" 60.0) ("templatePath" "templates")
- ("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((:equal-based) ("servlet-class" "org.cofax.cds.EmailServlet")
- ("init-param" #H((:equal-based) ("mailHost" "mail1") ("mailHostOverride" "mail2")))
- ("servlet-name" "cofaxEmail"))
- #H((:equal-based) ("servlet-class" "org.cofax.cds.AdminServlet")
- ("servlet-name" "cofaxAdmin")) #H((:equal-based) ("servlet-class" "org.cofax.cds.FileServlet")
- ("servlet-name" "fileServlet"))
- #H((:equal-based) ("servlet-class" "org.cofax.cms.CofaxToolsServlet")
- ("init-param" #H((:equal-based) ("lookInContext" 1.0) ("removePageCache" "/content/admin/remove?cache=pages&id=")
- ("logMaxSize" "") ("dataLogMaxSize" "") ("removeTemplateCache" "/content/admin/remove?cache=templates&id=")
- ("dataLog" 1.0) ("logLocation" "/usr/local/tomcat/logs/CofaxTools.log")
- ("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((:equal-based) ("taglib-uri" "cofax.tld") ("taglib-location" "/WEB-INF/tlds/cofax.tld"))))))
+ ("cofaxEmail" "/cofaxutil/aemail/*") ("fileServlet" "/static/*")))
+ ("servlet" #(#H((:equal-based) ("servlet-class" "org.cofax.cds.CDSServlet") ("init-param" #H((:equal-based) ("defaultFileTemplate" "articleTemplate.htm")
+ ("configGlossary:installationAt" "Philadelphia, PA") ("templateOverridePath" "")
+ ("dataStoreLogLevel" "debug") ("searchEngineListTemplate" "forSearchEnginesList.htm")
+ ("dataStoreClass" "org.cofax.SqlDataStore") ("configGlossary:poweredBy" "Cofax")
+ ("jspFileTemplate" "articleTemplate.jsp") ("cacheTemplatesTrack" 100.0)
+ ("cacheTemplatesStore" 50.0) ("templateProcessorClass" "org.cofax.WysiwygTemplate")
+ ("dataStoreUser" "sa") ("redirectionClass" "org.cofax.SqlRedirection")
+ ("dataStoreConnUsageLimit" 100.0) ("dataStoreMaxConns" 100.0)
+ ("jspListTemplate" "listTemplate.jsp") ("useJSP" :false) ("configGlossary:poweredByIcon" "/images/cofax.gif")
+ ("templateLoaderClass" "org.cofax.FilesTemplateLoader") ("cacheTemplatesRefresh" 15.0)
+ ("cachePagesDirtyRead" 10.0) ("searchEngineRobotsDb" "WEB-INF/robots.db")
+ ("cachePagesStore" 100.0) ("dataStoreTestQuery" "SET NOCOUNT ON;select test='test';")
+ ("configGlossary:adminEmail" "ksm@pobox.com") ("configGlossary:staticPath" "/content/static")
+ ("dataStoreInitConns" 10.0) ("cachePagesTrack" 200.0) ("dataStorePassword" "dataStoreTestQuery")
+ ("defaultListTemplate" "listTemplate.htm") ("dataStoreLogFile" "/usr/local/tomcat/logs/datastore.log")
+ ("maxUrlLength" 500.0) ("dataStoreDriver" "com.microsoft.jdbc.sqlserver.SQLServerDriver")
+ ("dataStoreName" "cofax") ("cachePackageTagsRefresh" 60.0) ("templatePath" "templates")
+ ("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((:equal-based) ("servlet-class" "org.cofax.cds.EmailServlet")
+ ("init-param" #H((:equal-based) ("mailHost" "mail1") ("mailHostOverride" "mail2")))
+ ("servlet-name" "cofaxEmail"))
+ #H((:equal-based) ("servlet-class" "org.cofax.cds.AdminServlet")
+ ("servlet-name" "cofaxAdmin")) #H((:equal-based) ("servlet-class" "org.cofax.cds.FileServlet")
+ ("servlet-name" "fileServlet"))
+ #H((:equal-based) ("servlet-class" "org.cofax.cms.CofaxToolsServlet")
+ ("init-param" #H((:equal-based) ("lookInContext" 1.0) ("removePageCache" "/content/admin/remove?cache=pages&id=")
+ ("logMaxSize" "") ("dataLogMaxSize" "") ("removeTemplateCache" "/content/admin/remove?cache=templates&id=")
+ ("dataLog" 1.0) ("logLocation" "/usr/local/tomcat/logs/CofaxTools.log")
+ ("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((:equal-based) ("taglib-uri" "cofax.tld") ("taglib-location" "/WEB-INF/tlds/cofax.tld"))))))
Unmatched junk: ""
AST: #("JSON Test Pattern pass1" #H((:equal-based) ("object with 1 member" #("array with 1 element")))
- #H((:equal-based)) #() -42.0 :true :false :null #H((:equal-based) ("" 2.3456789012e76) ("digit" "0123456789") ("\\/\\\\\"쫾몾ꮘﳞ볚\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" "A key can be any string")
- ("null" :null) ("one" 1.0) ("E" 1.23456789e34) ("special" "`1~!@#$%^&*()_+-={':[,]}|;.</>?")
- ("e" 1.23456789e-13) ("comment" "// /* <!-- --") ("# -- --> */" " ")
- ("real" -9876.54321) ("backslash" "\\\\") ("array" #()) ("url" "http://www.JSON.org/")
- ("zero" 0.0) ("false" :false) ("space" " ") ("slash" "/ & \\/")
- ("address" "50 St. James Street") ("compact" #(1.0 2.0 3.0 4.0 5.0 6.0 7.0))
- ("object" #H((:equal-based))) ("quote" "\"") ("jsontext" "{\"object with 1 member\":[\"array with 1 element\"]}")
- ("true" :true) ("integer" 1234567890.0) ("ALPHA" "ABCDEFGHIJKLMNOPQRSTUVWYZ")
- ("quotes" "&#34; \" %22 0x22 034 &#x22;") ("hex" "ģ䕧覫췯ꯍ") ("0123456789" "digit")
- ("controls" "\b\f\n\r\t") ("alpha" "abcdefghijklmnopqrstuvwyz")
- (" s p a c e d " #(1.0 2.0 3.0 4.0 5.0 6.0 7.0)))
- 0.5 98.6 99.44 1066.0 10.0 1.0 0.1 1.0 2.0 2.0 "rosebud")
+ #H((:equal-based)) #() -42.0 :true :false :null #H((:equal-based) ("" 2.3456789012e76) ("digit" "0123456789") ("\\/\\\\\"쫾몾ꮘﳞ볚\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" "A key can be any string")
+ ("null" :null) ("one" 1.0) ("E" 1.23456789e34) ("special" "`1~!@#$%^&*()_+-={':[,]}|;.</>?")
+ ("e" 1.23456789e-13) ("comment" "// /* <!-- --") ("# -- --> */" " ")
+ ("real" -9876.54321) ("backslash" "\\\\") ("array" #()) ("url" "http://www.JSON.org/")
+ ("zero" 0.0) ("false" :false) ("space" " ") ("slash" "/ & \\/")
+ ("address" "50 St. James Street") ("compact" #(1.0 2.0 3.0 4.0 5.0 6.0 7.0))
+ ("object" #H((:equal-based))) ("quote" "\"") ("jsontext" "{\"object with 1 member\":[\"array with 1 element\"]}")
+ ("true" :true) ("integer" 1234567890.0) ("ALPHA" "ABCDEFGHIJKLMNOPQRSTUVWYZ")
+ ("quotes" "&#34; \" %22 0x22 034 &#x22;") ("hex" "ģ䕧覫췯ꯍ") ("0123456789" "digit")
+ ("controls" "\b\f\n\r\t") ("alpha" "abcdefghijklmnopqrstuvwyz")
+ (" s p a c e d " #(1.0 2.0 3.0 4.0 5.0 6.0 7.0)))
+ 0.5 98.6 99.44 1066.0 10.0 1.0 0.1 1.0 2.0 2.0 "rosebud")
Unmatched junk: ""