From de02319cfa7b4bbff8c111bda02be1a7c6591555 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 5 Jan 2020 20:17:17 -0500 Subject: dlang safe default imminent, look ahead - @safe @trusted & @system, reconsider @trusted --- org/out_xmls.org | 190 +++++++++++++++++++++++++++---------------------------- 1 file changed, 95 insertions(+), 95 deletions(-) (limited to 'org/out_xmls.org') diff --git a/org/out_xmls.org b/org/out_xmls.org index 9738c23..ed3c92a 100644 --- a/org/out_xmls.org +++ b/org/out_xmls.org @@ -58,10 +58,10 @@ import #+name: xhtml_format_objects #+BEGIN_SRC d -string div_delimit( +@safe string div_delimit( string part, return ref string previous_part -) @safe { +) { string delimit = ""; string delimit_ = ""; if (part != previous_part) { @@ -94,7 +94,7 @@ string div_delimit( #+name: xhtml_format_objects #+BEGIN_SRC d -string special_characters_text(string _txt) @safe { +@safe string special_characters_text(string _txt) { _txt = _txt .replaceAll(rgx.xhtml_ampersand, "&") .replaceAll(rgx.xhtml_quotation, """) @@ -109,9 +109,9 @@ string special_characters_text(string _txt) @safe { #+name: xhtml_format_objects #+BEGIN_SRC d -string special_characters(O)( +@safe string special_characters(O)( const O obj, -) @safe { +) { string _txt = special_characters_text(obj.text); if (!(obj.metainfo.is_a == "code")) { _txt = (_txt) @@ -125,7 +125,7 @@ string special_characters(O)( #+name: xhtml_format_objects #+BEGIN_SRC d -string font_face(string _txt) @safe { +@safe string font_face(string _txt) { _txt = _txt .replaceAll(rgx.inline_emphasis, ("$1")) .replaceAll(rgx.inline_bold, ("$1")) @@ -145,7 +145,7 @@ string font_face(string _txt) @safe { #+name: xhtml_format_objects #+BEGIN_SRC d -string _xhtml_anchor_tags(O)(O obj) @safe { +@safe string _xhtml_anchor_tags(O)(O obj) { const(string[]) anchor_tags = obj.tags.anchor_tags; string tags=""; if (anchor_tags.length > 0) { @@ -164,9 +164,9 @@ string _xhtml_anchor_tags(O)(O obj) @safe { #+name: xhtml_format_objects #+BEGIN_SRC d -string header_metadata(M)( +@safe string header_metadata(M)( M doc_matters, -) @safe { +) { string _publisher="Publisher"; // TODO string o; o = format(q"┃ @@ -207,9 +207,9 @@ string header_metadata(M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string site_info_button(M)( +@safe string site_info_button(M)( M doc_matters, -) @safe { +) { string _locations; if (doc_matters.conf_make_meta.make.home_button_text.length > 0) { _locations = (doc_matters.conf_make_meta.make.home_button_text) @@ -237,9 +237,9 @@ string site_info_button(M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string inline_search_form(M)( +@safe string inline_search_form(M)( M doc_matters, -) @safe { +) { string _action="http://www.sisudoc.org/cgi-bin/search.cgi"; string _db="spine.7a.manual"; string o; @@ -274,7 +274,7 @@ string inline_search_form(M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string html_head(M)( +@safe string html_head(M)( M doc_matters, string type, ) { @@ -330,9 +330,9 @@ string html_head(M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string epub3_seg_head(M)( +@safe string epub3_seg_head(M)( M doc_matters, -) @safe { +) { string html_base = format(q"┃ ┃", ); @@ -404,7 +404,7 @@ string epub3_seg_head(M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string tail() @safe { +@safe string tail() { string o; o = format(q"┃ @@ -420,13 +420,13 @@ string tail() @safe { #+name: xhtml_format_objects #+BEGIN_SRC d -string inline_images(O,M)( +@safe string inline_images(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", -) @safe { +) { string _img_pth; switch (_xml_type) { case "epub": _img_pth = "image/"; break; @@ -453,13 +453,13 @@ string inline_images(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string inline_links(O,M)( +@safe string inline_links(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", -) @safe { +) { string seg_lvs; if (obj.has.inline_links) { if (obj.metainfo.is_a != "code") { @@ -551,11 +551,11 @@ string inline_links(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string inline_notes_scroll(O,M)( +@safe string inline_notes_scroll(O,M)( string _txt, const O obj, M doc_matters, -) @safe { +) { if (obj.has.inline_notes_reg) { _txt = font_face(_txt); _txt = _txt.replaceAll( @@ -588,11 +588,11 @@ string inline_notes_scroll(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -Tuple!(string, string[]) inline_notes_seg(O,M)( +@safe Tuple!(string, string[]) inline_notes_seg(O,M)( string _txt, const O obj, M doc_matters, -) @safe { +) { string[] _endnotes; if (obj.has.inline_notes_star) { _txt = font_face(_txt); @@ -659,12 +659,12 @@ Tuple!(string, string[]) inline_notes_seg(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string inline_markup_scroll(O,M)( +@safe string inline_markup_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", -) @safe { +) { if (obj.metainfo.dummy_heading && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) { _txt = ""; @@ -681,13 +681,13 @@ string inline_markup_scroll(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto inline_markup_seg(O,M)( +@safe auto inline_markup_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "seg", -) @safe { +) { if (obj.metainfo.dummy_heading && ((_xml_type == "epub" && (obj.metainfo.is_a == "toc" || obj.metainfo.is_a == "heading")) @@ -708,10 +708,10 @@ auto inline_markup_seg(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string lev4_heading_subtoc(O,M)( +@safe string lev4_heading_subtoc(O,M)( const O obj, M doc_matters, -) @safe { +) { char[] lev4_subtoc; lev4_subtoc ~= "
\n"; foreach (subtoc; obj.tags.lev4_subtoc) { @@ -741,10 +741,10 @@ string lev4_heading_subtoc(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -auto nav_pre_next_svg(O,M)( +@safe auto nav_pre_next_svg(O,M)( const O obj, M doc_matters, -) @safe { +) { string prev, next, toc; if (obj.tags.segment_anchor_tag_epub == "toc") { toc = ""; @@ -824,12 +824,12 @@ auto nav_pre_next_svg(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string heading(O,M)( +@safe string heading(O,M)( string _txt, const O obj, M doc_matters, string _xml_type = "html", -) @safe { +) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -895,12 +895,12 @@ string heading(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string heading_scroll(O,M)( +@safe string heading_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", -) @safe { +) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = heading(_txt, obj, doc_matters); return o; @@ -911,13 +911,13 @@ string heading_scroll(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -Tuple!(string, string[]) heading_seg(O,M)( +@safe Tuple!(string, string[]) heading_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", -) @safe { +) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0]; string[] _endnotes = t[1]; @@ -935,11 +935,11 @@ Tuple!(string, string[]) heading_seg(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string para(O,M)( +@safe string para(O,M)( string _txt, const O obj, M doc_matters, -) @safe { +) { assert(obj.metainfo.is_of_part == "body" || "frontmatter" || "backmatter"); assert(obj.metainfo.is_of_section == "body" || "toc" || "endnotes" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "para"); @@ -991,12 +991,12 @@ string para(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string para_scroll(O,M)( +@safe string para_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", -) @safe { +) { if (obj.metainfo.is_a == "toc" && _txt.match(rgx.inline_link_toc_to_backmatter)) { _txt = _txt.replaceAll(rgx.inline_link_toc_to_backmatter, "┤#section_$1├"); } @@ -1010,13 +1010,13 @@ string para_scroll(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -Tuple!(string, string[]) para_seg(O,M)( +@safe Tuple!(string, string[]) para_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", -) @safe { +) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -1034,11 +1034,11 @@ Tuple!(string, string[]) para_seg(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string quote(O,M)( +@safe string quote(O,M)( string _txt, const O obj, M doc_matters, -) @safe { +) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -1076,12 +1076,12 @@ string quote(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string quote_scroll(O,M)( +@safe string quote_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", -) @safe { +) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = quote(_txt, obj, doc_matters); return o; @@ -1092,13 +1092,13 @@ string quote_scroll(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -Tuple!(string, string[]) quote_seg(O,M)( +@safe Tuple!(string, string[]) quote_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", -) @safe { +) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -1116,11 +1116,11 @@ Tuple!(string, string[]) quote_seg(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string group(O,M)( +@safe string group(O,M)( string _txt, const O obj, M doc_matters, -) @safe { +) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -1158,13 +1158,13 @@ string group(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string group_scroll(O,M)( +@safe string group_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", -) @safe { +) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = group(_txt, obj, doc_matters); return o; @@ -1175,13 +1175,13 @@ string group_scroll(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -Tuple!(string, string[]) group_seg(O,M)( +@safe Tuple!(string, string[]) group_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", -) @safe { +) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -1199,11 +1199,11 @@ Tuple!(string, string[]) group_seg(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string block(O,M)( +@safe string block(O,M)( string _txt, const O obj, M doc_matters, -) @safe { +) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -1237,13 +1237,13 @@ string block(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string block_scroll(O,M)( +@safe string block_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", -) @safe { +) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = block(_txt, obj, doc_matters); return o; @@ -1254,13 +1254,13 @@ string block_scroll(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -Tuple!(string, string[]) block_seg(O,M)( +@safe Tuple!(string, string[]) block_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", -) @safe { +) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -1278,11 +1278,11 @@ Tuple!(string, string[]) block_seg(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string verse(O,M)( +@safe string verse(O,M)( string _txt, const O obj, M doc_matters, -) @safe { +) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body" || "glossary" || "bibliography" || "bookindex" || "blurb"); assert(obj.metainfo.is_of_type == "block"); @@ -1316,13 +1316,13 @@ string verse(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -string verse_scroll(O,M)( +@safe string verse_scroll(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", -) @safe { +) { _txt = inline_markup_scroll(_txt, obj, doc_matters, _suffix); string o = verse(_txt, obj, doc_matters); return o; @@ -1333,13 +1333,13 @@ string verse_scroll(O,M)( #+name: xhtml_format_objects #+BEGIN_SRC d -Tuple!(string, string[]) verse_seg(O,M)( +@safe Tuple!(string, string[]) verse_seg(O,M)( string _txt, const O obj, M doc_matters, string _suffix = ".html", string _xml_type = "html", -) @safe { +) { auto t = inline_markup_seg(_txt, obj, doc_matters, _suffix, _xml_type); _txt = t[0].to!string; string[] _endnotes = t[1]; @@ -1356,11 +1356,11 @@ Tuple!(string, string[]) verse_seg(O,M)( #+name: xhtml_format_objects_code #+BEGIN_SRC d -string code(O,M)( +@safe string code(O,M)( string _txt, const O obj, M doc_matters, -) @safe { +) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); @@ -1428,10 +1428,10 @@ align="left|right|center" #+name: xhtml_format_objects #+BEGIN_SRC d -Tuple!(string, string) tablarize(O)( +@safe Tuple!(string, string) tablarize(O)( string _txt, const O obj, -) @safe { +) { string[] _table_rows = (_txt).split(rgx.table_delimiter_row); string[] _table_cols; string _table; @@ -1467,11 +1467,11 @@ Tuple!(string, string) tablarize(O)( #+name: xhtml_format_objects #+BEGIN_SRC d -string table(O,M)( +@safe string table(O,M)( string _txt, const O obj, M doc_matters, -) @safe { +) { assert(obj.metainfo.is_of_part == "body"); assert(obj.metainfo.is_of_section == "body"); assert(obj.metainfo.is_of_type == "block"); @@ -1523,10 +1523,10 @@ template outputHTML() { #+name: output_html_scroll #+BEGIN_SRC d -void scroll(D,M)( +@safe void scroll(D,M)( const D doc_abstraction, M doc_matters, -) @safe { +) { mixin spineOutputRgxInit; auto xhtml_format = outputXHTMLs(); static auto rgx = Rgx(); @@ -1729,10 +1729,10 @@ void scroll(D,M)( #+name: output_html_scroll #+BEGIN_SRC d -void scroll_write_output(D,M)( +@trusted void scroll_write_output(D,M)( D doc, M doc_matters, -) @trusted { +) { debug(asserts) { static assert(is(typeof(doc) == string[])); } @@ -1759,10 +1759,10 @@ void scroll_write_output(D,M)( #+name: output_html_seg #+BEGIN_SRC d -void seg(D,M)( +@safe void seg(D,M)( const D doc_abstraction, M doc_matters, -) @safe { +) { mixin spineOutputRgxInit; static auto rgx = Rgx(); auto xhtml_format = outputXHTMLs(); @@ -2060,11 +2060,11 @@ void seg(D,M)( #+name: output_html_seg #+BEGIN_SRC d -void seg_write_output(D,E,M)( +@trusted void seg_write_output(D,E,M)( // @system? D doc_html, E doc_html_endnotes, M doc_matters, -) @trusted { // @system? +) { debug(asserts) { static assert(is(typeof(doc_html) == string[][string])); } @@ -2100,7 +2100,7 @@ void seg_write_output(D,E,M)( #+name: output_html_css #+BEGIN_SRC d -void css(M)(M doc_matters) @safe { +@safe void css(M)(M doc_matters) { auto css = spineCss(doc_matters); auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); try { @@ -2121,9 +2121,9 @@ void css(M)(M doc_matters) @safe { #+name: copy_html_images #+BEGIN_SRC d -void images_cp(M)( +@trusted void images_cp(M)( // @system M doc_matters, -) @trusted { // @system +) { { /+ (copy html images) +/ auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); @@ -2190,7 +2190,7 @@ template outputEPub3() { #+name: output_epub3_fixed #+BEGIN_SRC d -string epub3_mimetypes() @safe { +@safe string epub3_mimetypes() { string o; o = format(q"┃application/epub+zip┃") ~ "\n"; return o; @@ -2203,7 +2203,7 @@ string epub3_mimetypes() @safe { #+name: output_epub3_fixed #+BEGIN_SRC d -string epub3_container_xml() @safe { +@safe string epub3_container_xml() { string o; o = format(q"┃┃") ~ "\n"; o ~= format(q"┃ #+name: output_epub3_constructs #+BEGIN_SRC d -string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) @safe { +@safe string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) { auto xhtml_format = outputXHTMLs(); auto pth_epub3 = spinePathsEPUB!()(doc_matters.output_path, doc_matters.src.language); string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! @@ -2331,7 +2331,7 @@ string epub3_oebps_content(D,M,P)(D doc_abstraction, M doc_matters, P parts) @sa #+name: output_epub3_constructs #+BEGIN_SRC d -string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) @safe { +@safe string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) { enum DomTags { none, open, close, close_and_open, open_still, } auto markup = InlineMarkup(); static auto rgx = Rgx(); @@ -2419,7 +2419,7 @@ string epub3_oebps_toc_nav_xhtml(D,I)(D doc_abstraction, I doc_matters) @safe { #+name: output_epub3_constructs #+BEGIN_SRC d -string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) @safe { +@safe string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) { int counter = 0; string _uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO shared elsewhere auto markup = InlineMarkup(); @@ -2515,10 +2515,10 @@ string epub2_oebps_toc_ncx(D,I)(D doc_abstraction, I doc_matters) @safe { #+name: output_epub3_xhtml_seg #+BEGIN_SRC d -void outputEPub3(D,I)( +@system void outputEPub3(D,I)( const D doc_abstraction, I doc_matters, -) { // @trusted +) { mixin spineOutputRgxInit; auto xhtml_format = outputXHTMLs(); static auto rgx = Rgx(); @@ -2872,10 +2872,10 @@ void outputEPub3(D,I)( #+name: output_epub3_xhtml_seg #+BEGIN_SRC d -void epub3_write_output_files(W,M)( +@system void epub3_write_output_files(W,M)( W epub_write, M doc_matters, -) { // @trusted +) { debug(asserts) { static assert(is(typeof(epub_write.doc_epub3) == string[][string])); static assert(is(typeof(epub_write.mimetypes) == string)); -- cgit v1.2.3