templeos-info/public/Wb/Adam/DolDoc/DocTree.HC.HTML

275 lines
28 KiB
Plaintext
Raw Normal View History

2024-03-24 21:24:44 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;DolDoc/Tree&quot;</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocTreeFind</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *haystack_doc,</span><span class=cF1>U8</span><span class=cF0> *needle_path,
<a name="l4"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> **_tree_entry=</span><span class=cF3>NULL</span><span class=cF0>,
<a name="l5"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> **_start_indent=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF9>CDocEntry</span><span class=cF0> **_end_indent=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l6"></a>{</span><span class=cF2>//Find tree widget start and end.</span><span class=cF0>
<a name="l7"></a> </span><span class=cF9>I64</span><span class=cF0> i=0,k=0;
<a name="l8"></a> </span><span class=cF1>U8</span><span class=cF0> *st1=</span><span class=cF5>StrNew</span><span class=cF0>(needle_path),*st2=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>needle_path</span><span class=cF7>)</span><span class=cF0>+1);
<a name="l9"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>FALSE</span><span class=cF0>,unlock_doc=</span><span class=cF5>DocLock</span><span class=cF0>(haystack_doc);
<a name="l10"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e=haystack_doc-&gt;head.next;
<a name="l11"></a> </span><span class=cF1>if</span><span class=cF0> (_tree_entry) *_tree_entry=haystack_doc;
<a name="l12"></a> </span><span class=cF1>if</span><span class=cF0> (_start_indent) *_start_indent=haystack_doc;
<a name="l13"></a> </span><span class=cF1>if</span><span class=cF0> (_end_indent) *_end_indent=haystack_doc;
<a name="l14"></a> </span><span class=cF1>while</span><span class=cF0> (*st1 &amp;&amp; doc_e!=haystack_doc) </span><span class=cF7>{</span><span class=cF0>
<a name="l15"></a> </span><span class=cF5>StrFirstRem</span><span class=cF0>(st1,</span><span class=cF6>&quot;/&quot;</span><span class=cF0>,st2);
<a name="l16"></a> </span><span class=cF1>if</span><span class=cF0> (*st2) {
<a name="l17"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=haystack_doc) </span><span class=cF7>{</span><span class=cF0>
<a name="l18"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;type_u8==</span><span class=cF3>DOCT_INDENT</span><span class=cF0>)
<a name="l19"></a> i+=doc_e-&gt;attr;
<a name="l20"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i==k &amp;&amp; doc_e-&gt;de_flags&amp;</span><span class=cF3>DOCEF_TREE</span><span class=cF0> &amp;&amp;
<a name="l21"></a> !</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>doc_e-&gt;tag+3,st2</span><span class=cF7>)</span><span class=cF0>) {
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (*st1)
<a name="l23"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l24"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l25"></a> </span><span class=cF1>if</span><span class=cF0> (_tree_entry) *_tree_entry=doc_e;
<a name="l26"></a> i=0;
<a name="l27"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=haystack_doc &amp;&amp; doc_e-&gt;type_u8!=</span><span class=cF3>DOCT_INDENT</span><span class=cF0>)
<a name="l28"></a> doc_e=doc_e-&gt;next;
<a name="l29"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e!=haystack_doc) {
<a name="l30"></a> i=doc_e-&gt;attr;
<a name="l31"></a> </span><span class=cF1>if</span><span class=cF0> (_start_indent) *_start_indent=doc_e;
<a name="l32"></a> doc_e=doc_e-&gt;next;
<a name="l33"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=haystack_doc &amp;&amp; i&gt;0) </span><span class=cF7>{</span><span class=cF0>
<a name="l34"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;type_u8==</span><span class=cF3>DOCT_INDENT</span><span class=cF0>) {
<a name="l35"></a> i+=doc_e-&gt;attr;
<a name="l36"></a> </span><span class=cF1>if</span><span class=cF0> (i&lt;=0) </span><span class=cF7>{</span><span class=cF0>
<a name="l37"></a> </span><span class=cF1>if</span><span class=cF0> (_end_indent) *_end_indent=doc_e;
<a name="l38"></a> res=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l39"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l40"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l41"></a> }
<a name="l42"></a> doc_e=doc_e-&gt;next;
<a name="l43"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l44"></a> }
<a name="l45"></a> </span><span class=cF1>goto</span><span class=cF0> ft_done;
<a name="l46"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l47"></a> }
<a name="l48"></a> doc_e=doc_e-&gt;next;
<a name="l49"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l50"></a> k+=2;
<a name="l51"></a> }
<a name="l52"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l53"></a>ft_done:
<a name="l54"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_doc)
<a name="l55"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(haystack_doc);
<a name="l56"></a> </span><span class=cF5>Free</span><span class=cF0>(st1);
<a name="l57"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
<a name="l58"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l59"></a>}
<a name="l60"></a>
<a name="l61"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocTreeFFind</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *name,</span><span class=cF1>U8</span><span class=cF0> *path)
<a name="l62"></a>{</span><span class=cF2>//Find tree widget in file.</span><span class=cF0>
<a name="l63"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocRead</span><span class=cF0>(name);
<a name="l64"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF5>DocTreeFind</span><span class=cF0>(doc,path);
<a name="l65"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l66"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l67"></a>}
<a name="l68"></a>
<a name="l69"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocTreeMake</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF1>U8</span><span class=cF0> *path)
<a name="l70"></a>{</span><span class=cF2>//Make tree widget.</span><span class=cF0>
<a name="l71"></a> </span><span class=cF9>I64</span><span class=cF0> i=0,j=</span><span class=cF3>I64_MIN</span><span class=cF0>,k=0;
<a name="l72"></a> </span><span class=cF1>U8</span><span class=cF0> *st1=</span><span class=cF5>StrNew</span><span class=cF0>(path),
<a name="l73"></a> *st2=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>path</span><span class=cF7>)</span><span class=cF0>+1),
<a name="l74"></a> *st3=</span><span class=cF5>StrNew</span><span class=cF0>(path);
<a name="l75"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF3>TRUE</span><span class=cF0>,unlock_doc=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
<a name="l76"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e=doc-&gt;head.next;
<a name="l77"></a> doc-&gt;cur_entry=doc;
<a name="l78"></a> doc-&gt;cur_col=0;
<a name="l79"></a> </span><span class=cF1>while</span><span class=cF0> (*st1 &amp;&amp; doc_e!=doc) </span><span class=cF7>{</span><span class=cF0>
<a name="l80"></a> </span><span class=cF5>StrFirstRem</span><span class=cF0>(st1,</span><span class=cF6>&quot;/&quot;</span><span class=cF0>,st2);
<a name="l81"></a> </span><span class=cF1>if</span><span class=cF0> (*st2) {
<a name="l82"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=doc) </span><span class=cF7>{</span><span class=cF0>
<a name="l83"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;type_u8==</span><span class=cF3>DOCT_INDENT</span><span class=cF0>) {
<a name="l84"></a> i+=doc_e-&gt;attr;
<a name="l85"></a> </span><span class=cF1>if</span><span class=cF0> (i==j) </span><span class=cF7>{</span><span class=cF0>
<a name="l86"></a> doc-&gt;cur_entry=doc_e;
<a name="l87"></a> doc-&gt;cur_col=0;
<a name="l88"></a> </span><span class=cF1>goto</span><span class=cF0> mt_done;
<a name="l89"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l90"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i==k &amp;&amp; doc_e-&gt;de_flags&amp;</span><span class=cF3>DOCEF_TREE</span><span class=cF0> &amp;&amp;
<a name="l91"></a> !</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>doc_e-&gt;tag+3,st2</span><span class=cF7>)</span><span class=cF0>) {
<a name="l92"></a> </span><span class=cF5>Free</span><span class=cF0>(st3);
<a name="l93"></a> st3=</span><span class=cF5>StrNew</span><span class=cF0>(st1);
<a name="l94"></a> j=i;
<a name="l95"></a> </span><span class=cF1>if</span><span class=cF0> (!*st1)
<a name="l96"></a> res=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l97"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l98"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l99"></a> }
<a name="l100"></a> doc_e=doc_e-&gt;next;
<a name="l101"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l102"></a> k+=2;
<a name="l103"></a> }
<a name="l104"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l105"></a>mt_done:
<a name="l106"></a> </span><span class=cF1>if</span><span class=cF0> (res) </span><span class=cF7>{</span><span class=cF0>
<a name="l107"></a> </span><span class=cF1>while</span><span class=cF0> (*st3) {
<a name="l108"></a> </span><span class=cF5>StrFirstRem</span><span class=cF0>(st3,</span><span class=cF6>&quot;/&quot;</span><span class=cF0>,st2);
<a name="l109"></a> </span><span class=cF1>if</span><span class=cF0> (*st2) </span><span class=cF7>{</span><span class=cF0>
<a name="l110"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;$TR+C,\&quot;%s\&quot;$\n$ID,2$&quot;</span><span class=cF0>,st2);
<a name="l111"></a> doc-&gt;cur_entry=</span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;$ID,-2$&quot;</span><span class=cF0>);
<a name="l112"></a> doc-&gt;cur_col=0;
<a name="l113"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l114"></a> }
<a name="l115"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l116"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_doc)
<a name="l117"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
<a name="l118"></a> </span><span class=cF5>Free</span><span class=cF0>(st1);
<a name="l119"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
<a name="l120"></a> </span><span class=cF5>Free</span><span class=cF0>(st3);
<a name="l121"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l122"></a>}
<a name="l123"></a>
<a name="l124"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocTreeWriteJoin</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF1>U8</span><span class=cF0> *path,</span><span class=cF1>Bool</span><span class=cF0> write,</span><span class=cF1>U8</span><span class=cF0> *fmt,</span><span class=cF9>I64</span><span class=cF0> argc,</span><span class=cF9>I64</span><span class=cF0> *argv)
<a name="l125"></a>{</span><span class=cF2>//Rewrite doc tree branch.</span><span class=cF0>
<a name="l126"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *tree_branch,*start_indent,*end_indent;
<a name="l127"></a> </span><span class=cF1>U8</span><span class=cF0> *buf=</span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>,fmt,argc,argv);
<a name="l128"></a> </span><span class=cF1>Bool</span><span class=cF0> res,unlock_doc=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
<a name="l129"></a> </span><span class=cF1>if</span><span class=cF0> (res=</span><span class=cF5>DocTreeFind</span><span class=cF7>(</span><span class=cF0>doc,path,
<a name="l130"></a> &amp;tree_branch,&amp;start_indent,&amp;end_indent</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l131"></a> </span><span class=cF5>DocCut</span><span class=cF0>(doc,start_indent-&gt;next,end_indent-&gt;last);
<a name="l132"></a> doc-&gt;cur_entry=start_indent-&gt;next;
<a name="l133"></a> doc-&gt;cur_col=doc-&gt;cur_entry-&gt;min_col;
<a name="l134"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l135"></a> </span><span class=cF5>DocTreeMake</span><span class=cF0>(doc,path);
<a name="l136"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;%s&quot;</span><span class=cF0>,buf);
<a name="l137"></a> </span><span class=cF1>if</span><span class=cF0> (write &amp;&amp; </span><span class=cF5>DrvIsWritable</span><span class=cF7>(</span><span class=cF0>*doc-&gt;filename.name</span><span class=cF7>)</span><span class=cF0>)
<a name="l138"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
<a name="l139"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_doc)
<a name="l140"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
<a name="l141"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l142"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l143"></a>}
<a name="l144"></a>
<a name="l145"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocTreeAppendJoin</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF1>U8</span><span class=cF0> *path,</span><span class=cF1>Bool</span><span class=cF0> write,</span><span class=cF1>U8</span><span class=cF0> *fmt,</span><span class=cF9>I64</span><span class=cF0> argc,</span><span class=cF9>I64</span><span class=cF0> *argv)
<a name="l146"></a>{</span><span class=cF2>//Append to doc tree branch.</span><span class=cF0>
<a name="l147"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *tree_branch,*start_indent,*end_indent;
<a name="l148"></a> </span><span class=cF1>U8</span><span class=cF0> *buf=</span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>,fmt,argc,argv);
<a name="l149"></a> </span><span class=cF1>Bool</span><span class=cF0> res,unlock_doc=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
<a name="l150"></a> </span><span class=cF1>if</span><span class=cF0> (res=</span><span class=cF5>DocTreeFind</span><span class=cF7>(</span><span class=cF0>doc,path,
<a name="l151"></a> &amp;tree_branch,&amp;start_indent,&amp;end_indent</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l152"></a> doc-&gt;cur_entry=end_indent;
<a name="l153"></a> doc-&gt;cur_col=doc-&gt;cur_entry-&gt;min_col;
<a name="l154"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l155"></a> </span><span class=cF5>DocTreeMake</span><span class=cF0>(doc,path);
<a name="l156"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;%s&quot;</span><span class=cF0>,buf);
<a name="l157"></a> </span><span class=cF1>if</span><span class=cF0> (write &amp;&amp; </span><span class=cF5>DrvIsWritable</span><span class=cF7>(</span><span class=cF0>*doc-&gt;filename.name</span><span class=cF7>)</span><span class=cF0>)
<a name="l158"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
<a name="l159"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_doc)
<a name="l160"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
<a name="l161"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l162"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l163"></a>}
<a name="l164"></a>
<a name="l165"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocTreeWrite</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF1>U8</span><span class=cF0> *path,</span><span class=cF1>Bool</span><span class=cF0> write=</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
<a name="l166"></a>{</span><span class=cF2>//Rewrite doc tree branch.</span><span class=cF0>
<a name="l167"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>DocTreeWriteJoin</span><span class=cF0>(doc,path,write,fmt,argc,argv);
<a name="l168"></a>}
<a name="l169"></a>
<a name="l170"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocTreeAppend</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF1>U8</span><span class=cF0> *path,</span><span class=cF1>Bool</span><span class=cF0> write=</span><span class=cF3>TRUE</span><span class=cF0>,</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
<a name="l171"></a>{</span><span class=cF2>//Append to doc tree branch.</span><span class=cF0>
<a name="l172"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>DocTreeAppendJoin</span><span class=cF0>(doc,path,write,fmt,argc,argv);
<a name="l173"></a>}
<a name="l174"></a>
<a name="l175"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocTreeFWrite</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *name,</span><span class=cF1>U8</span><span class=cF0> *path,</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
<a name="l176"></a>{</span><span class=cF2>//Rewrite doc tree branch in file.</span><span class=cF0>
<a name="l177"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocRead</span><span class=cF0>(name);
<a name="l178"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF5>DocTreeWriteJoin</span><span class=cF0>(doc,path,</span><span class=cF3>TRUE</span><span class=cF0>,fmt,argc,argv);
<a name="l179"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l180"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l181"></a>}
<a name="l182"></a>
<a name="l183"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>DocTreeFAppend</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *name,</span><span class=cF1>U8</span><span class=cF0> *path,</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
<a name="l184"></a>{</span><span class=cF2>//Append to doc tree branch in file.</span><span class=cF0>
<a name="l185"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocRead</span><span class=cF0>(name);
<a name="l186"></a> </span><span class=cF1>Bool</span><span class=cF0> res=</span><span class=cF5>DocTreeAppendJoin</span><span class=cF0>(doc,path,</span><span class=cF3>TRUE</span><span class=cF0>,fmt,argc,argv);
<a name="l187"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l188"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l189"></a>}
<a name="l190"></a>
<a name="l191"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;DolDoc/Compiler;Compiler&quot;</span><span class=cF0>
<a name="l192"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>ExeDoc</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF9>I64</span><span class=cF0> ccf_flags=0)
<a name="l193"></a>{</span><span class=cF2>//JIT Compile and execute a document.</span><span class=cF0>
<a name="l194"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l195"></a> </span><span class=cF1>Bool</span><span class=cF0> okay=</span><span class=cF3>TRUE</span><span class=cF0>,unlock_doc=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
<a name="l196"></a> </span><span class=cF9>CCmpCtrl</span><span class=cF0> *cc=</span><span class=cF5>CmpCtrlNew</span><span class=cF0>(,ccf_flags|</span><span class=cF3>CCF_DONT_FREE_BUF</span><span class=cF0>);
<a name="l197"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>-&gt;last_cc!=&amp;</span><span class=cF5>Fs</span><span class=cF0>-&gt;next_cc)
<a name="l198"></a> cc-&gt;opts=</span><span class=cF5>Fs</span><span class=cF0>-&gt;last_cc-&gt;opts;
<a name="l199"></a> </span><span class=cF5>QueIns</span><span class=cF0>(cc,</span><span class=cF5>Fs</span><span class=cF0>-&gt;last_cc);
<a name="l200"></a> </span><span class=cF5>LexAttachDoc</span><span class=cF0>(cc,,doc);
<a name="l201"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l202"></a> </span><span class=cF5>Lex</span><span class=cF0>(cc);
<a name="l203"></a> res=</span><span class=cF5>ExeCmdLine</span><span class=cF0>(cc);
<a name="l204"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l205"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>-&gt;except_ch==</span><span class=cF6>'Compiler'</span><span class=cF0> || </span><span class=cF5>Fs</span><span class=cF0>-&gt;except_ch==</span><span class=cF6>'Break'</span><span class=cF0>) {
<a name="l206"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l207"></a> okay=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l208"></a> res=0;
<a name="l209"></a> }
<a name="l210"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l211"></a> </span><span class=cF5>QueRem</span><span class=cF0>(cc);
<a name="l212"></a> </span><span class=cF1>if</span><span class=cF0> (okay)
<a name="l213"></a> </span><span class=cF5>CmpCtrlDel</span><span class=cF0>(cc); </span><span class=cF2>//TODO: can crash</span><span class=cF0>
<a name="l214"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_doc)
<a name="l215"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
<a name="l216"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l217"></a>}
<a name="l218"></a>
<a name="l219"></a>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;DolDoc/Tree;DolDoc/Compiler;Compiler&quot;</span><span class=cF0>
<a name="l220"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DocTreeExe</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc,</span><span class=cF1>U8</span><span class=cF0> *path)
<a name="l221"></a>{</span><span class=cF2>//Execute doc tree branch.</span><span class=cF0>
<a name="l222"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc2;
<a name="l223"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock_doc=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
<a name="l224"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *tree_branch,*start_indent,*end_indent;
<a name="l225"></a> </span><span class=cF9>I64</span><span class=cF0> res=0;
<a name="l226"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>DocTreeFind</span><span class=cF7>(</span><span class=cF0>doc,path,&amp;tree_branch,&amp;start_indent,&amp;end_indent</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l227"></a> doc2=</span><span class=cF5>DocCopy</span><span class=cF0>(doc,tree_branch,end_indent);
<a name="l228"></a> res=</span><span class=cF5>ExeDoc</span><span class=cF0>(doc2);
<a name="l229"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc2);
<a name="l230"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l231"></a> </span><span class=cF1>if</span><span class=cF0> (unlock_doc)
<a name="l232"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
<a name="l233"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l234"></a>}
<a name="l235"></a>
<a name="l236"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DocTreeFExe</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *name,</span><span class=cF1>U8</span><span class=cF0> *path)
<a name="l237"></a>{</span><span class=cF2>//Execute doc tree branch in file.</span><span class=cF0>
<a name="l238"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l239"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocRead</span><span class=cF0>(name);
<a name="l240"></a> res=</span><span class=cF5>DocTreeExe</span><span class=cF0>(doc,path);
<a name="l241"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l242"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l243"></a>}
</span></pre></body>
</html>