ZealOS/docs/System/Utils/StrUtils.CC.html

270 lines
26 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V1.00">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;Cmd Line (Typically)&quot;</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DEPtrCompare</span><span class=cF0>(</span><span class=cF9>CDocEntry</span><span class=cF0> **e1, </span><span class=cF9>CDocEntry</span><span class=cF0> **e2)
<a name="l4"></a>{
<a name="l5"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrCompare</span><span class=cF0>(</span><span class=cF7>(</span><span class=cF0>*e1</span><span class=cF7>)</span><span class=cF0>-&gt;tag, </span><span class=cF7>(</span><span class=cF0>*e2</span><span class=cF7>)</span><span class=cF0>-&gt;tag);
<a name="l6"></a>}
<a name="l7"></a>
<a name="l8"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>Sort</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *_in_name, </span><span class=cF1>U8</span><span class=cF0> *_out_name=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> entry_lines=</span><span class=cFE>1</span><span class=cF0>, </span><span class=cF1>Bool</span><span class=cF0> unique=</span><span class=cF3>FALSE</span><span class=cF0>)
<a name="l9"></a>{</span><span class=cF2>//Sort lines of a text file. Removes blank lines.</span><span class=cF0>
<a name="l10"></a> </span><span class=cF1>U8</span><span class=cF0> *in_name, *out_name, *st;
<a name="l11"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc;
<a name="l12"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e, *doc_e1, **a;
<a name="l13"></a> </span><span class=cF9>I64</span><span class=cF0> i, j, count = </span><span class=cFE>0</span><span class=cF0>, res;
<a name="l14"></a>
<a name="l15"></a> </span><span class=cF1>if</span><span class=cF0> (!_in_name)
<a name="l16"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFE>0</span><span class=cF0>;
<a name="l17"></a> in_name = </span><span class=cF5>ExtDefault</span><span class=cF0>(_in_name, </span><span class=cF6>&quot;.DD&quot;</span><span class=cF0>);
<a name="l18"></a> </span><span class=cF1>if</span><span class=cF0> (_out_name)
<a name="l19"></a> out_name = </span><span class=cF5>ExtDefault</span><span class=cF0>(_out_name, </span><span class=cF6>&quot;.DD&quot;</span><span class=cF0>);
<a name="l20"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l21"></a> out_name = </span><span class=cF5>StrNew</span><span class=cF0>(in_name);
<a name="l22"></a>
<a name="l23"></a> doc = </span><span class=cF5>DocRead</span><span class=cF0>(in_name, </span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0> | </span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>);
<a name="l24"></a> doc_e = doc-&gt;head.next;
<a name="l25"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc)
<a name="l26"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l27"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;type_u8 == </span><span class=cF3>DOCT_TEXT</span><span class=cF0>)
<a name="l28"></a> count++;
<a name="l29"></a> doc_e = doc_e-&gt;next;
<a name="l30"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l31"></a> a = </span><span class=cF5>MAlloc</span><span class=cF0>(count * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocEntry</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>);
<a name="l32"></a> doc_e = doc-&gt;head.next;
<a name="l33"></a> i = </span><span class=cFE>0</span><span class=cF0>;
<a name="l34"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc)
<a name="l35"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l36"></a> doc_e1 = doc_e-&gt;next;
<a name="l37"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;type_u8 == </span><span class=cF3>DOCT_TEXT</span><span class=cF0>)
<a name="l38"></a> {
<a name="l39"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(doc_e);
<a name="l40"></a> a[i++] = doc_e;
<a name="l41"></a> }
<a name="l42"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l43"></a> </span><span class=cF5>DocEntryDel</span><span class=cF0>(doc, doc_e);
<a name="l44"></a> doc_e = doc_e1;
<a name="l45"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l46"></a> </span><span class=cF5>QuickSort</span><span class=cF0>(a, count / entry_lines, entry_lines * </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CDocEntry</span><span class=cF0> *</span><span class=cF7>)</span><span class=cF0>, &amp;</span><span class=cF5>DEPtrCompare</span><span class=cF0>);
<a name="l47"></a>
<a name="l48"></a> res = </span><span class=cFE>0</span><span class=cF0>;
<a name="l49"></a> st = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l50"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; count;)
<a name="l51"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l52"></a> </span><span class=cF1>if</span><span class=cF0> (!unique || !st || </span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>a[i]-&gt;tag, st</span><span class=cF7>)</span><span class=cF0>)
<a name="l53"></a> {
<a name="l54"></a> st = a[i]-&gt;tag;
<a name="l55"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; entry_lines &amp;&amp; i &lt; count; j++, i++)
<a name="l56"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l57"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(a[i], doc-&gt;head.last);
<a name="l58"></a> doc-&gt;cur_entry = &amp;doc-&gt;head;
<a name="l59"></a> doc-&gt;cur_col = </span><span class=cFE>0</span><span class=cF0>;
<a name="l60"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc,</span><span class=cF6>&quot;\n&quot;</span><span class=cF0>);
<a name="l61"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l62"></a> res++;
<a name="l63"></a> }
<a name="l64"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l65"></a> </span><span class=cF1>for</span><span class=cF0> (j = </span><span class=cFE>0</span><span class=cF0>; j &lt; entry_lines &amp;&amp; i &lt; count; j++, i++)
<a name="l66"></a> {
<a name="l67"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(a[i], doc-&gt;head.last);
<a name="l68"></a> </span><span class=cF5>DocEntryDel</span><span class=cF0>(doc, a[i]);
<a name="l69"></a> }
<a name="l70"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l71"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(doc-&gt;filename.name, out_name);
<a name="l72"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
<a name="l73"></a>
<a name="l74"></a> </span><span class=cF5>Free</span><span class=cF0>(a);
<a name="l75"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l76"></a> </span><span class=cF5>Free</span><span class=cF0>(in_name);
<a name="l77"></a> </span><span class=cF5>Free</span><span class=cF0>(out_name);
<a name="l78"></a>
<a name="l79"></a> </span><span class=cF1>return</span><span class=cF0> res; </span><span class=cF2>//Num Entries</span><span class=cF0>
<a name="l80"></a>}
<a name="l81"></a>
<a name="l82"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DocWordsFile</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc_out=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *filename, </span><span class=cF9>U32</span><span class=cF0> *char_bmp)
<a name="l83"></a>{
<a name="l84"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr, *ptr2;
<a name="l85"></a> </span><span class=cF9>I64</span><span class=cF0> res = </span><span class=cFE>0</span><span class=cF0>, ch;
<a name="l86"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc_in = </span><span class=cF5>DocRead</span><span class=cF0>(filename);
<a name="l87"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e = doc_in-&gt;head.next;
<a name="l88"></a>
<a name="l89"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc_in)
<a name="l90"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l91"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;de_flags &amp; </span><span class=cF3>DOCEF_TAG</span><span class=cF0>)
<a name="l92"></a> {
<a name="l93"></a> ptr = doc_e-&gt;tag;
<a name="l94"></a> </span><span class=cF1>while</span><span class=cF0> (*ptr)
<a name="l95"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l96"></a> </span><span class=cF1>while</span><span class=cF0> (*ptr &amp;&amp; !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>char_bmp, *ptr</span><span class=cF7>)</span><span class=cF0>)
<a name="l97"></a> ptr++;
<a name="l98"></a>
<a name="l99"></a> ptr2 = ptr;
<a name="l100"></a> </span><span class=cF1>while</span><span class=cF0> (*ptr &amp;&amp; </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>char_bmp, *ptr</span><span class=cF7>)</span><span class=cF0>)
<a name="l101"></a> ptr++;
<a name="l102"></a>
<a name="l103"></a> ch = *ptr;
<a name="l104"></a> *ptr = </span><span class=cFE>0</span><span class=cF0>;
<a name="l105"></a> </span><span class=cF1>if</span><span class=cF0> (*ptr2)
<a name="l106"></a> {
<a name="l107"></a> </span><span class=cF5>DocPrint</span><span class=cF0>(doc_out, </span><span class=cF6>&quot;%s\n&quot;</span><span class=cF0>, ptr2);
<a name="l108"></a> res++;
<a name="l109"></a> }
<a name="l110"></a> *ptr = ch;
<a name="l111"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l112"></a> }
<a name="l113"></a> doc_e = doc_e-&gt;next;
<a name="l114"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l115"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc_in);
<a name="l116"></a>
<a name="l117"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l118"></a>}
<a name="l119"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>Words</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask=</span><span class=cF6>&quot;*&quot;</span><span class=cF0>, </span><span class=cF9>U32</span><span class=cF0> *char_bmp=</span><span class=cFB>char_bmp_alpha</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l120"></a>{</span><span class=cF2>//Break file into list of not-unique words.</span><span class=cF0>
<a name="l121"></a> </span><span class=cF9>I64</span><span class=cF0> fuf_flags = </span><span class=cFE>0</span><span class=cF0>, res = </span><span class=cFE>0</span><span class=cF0>;
<a name="l122"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc_out = </span><span class=cF5>DocNew</span><span class=cF0>;
<a name="l123"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde, *tmpde1;
<a name="l124"></a>
<a name="l125"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF6>&quot;+r+f+F+T&quot;</span><span class=cF0>);
<a name="l126"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, fu_flags);
<a name="l127"></a> tmpde = tmpde1 = </span><span class=cF5>FilesFind</span><span class=cF0>(files_find_mask, fuf_flags);
<a name="l128"></a>
<a name="l129"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde)
<a name="l130"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l131"></a> res += </span><span class=cF5>DocWordsFile</span><span class=cF0>(doc_out, tmpde-&gt;full_name, char_bmp);
<a name="l132"></a> tmpde = tmpde-&gt;next;
<a name="l133"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l134"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
<a name="l135"></a> </span><span class=cF5>DocInsDoc</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>, doc_out);
<a name="l136"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc_out);
<a name="l137"></a>
<a name="l138"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l139"></a>}
<a name="l140"></a>
<a name="l141"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>LongLinesFile</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename, </span><span class=cF9>I64</span><span class=cF0> cols)
<a name="l142"></a>{
<a name="l143"></a> </span><span class=cF9>I64</span><span class=cF0> res = </span><span class=cFE>0</span><span class=cF0>;
<a name="l144"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc = </span><span class=cF5>DocRead</span><span class=cF0>(filename);
<a name="l145"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e = doc-&gt;head.next;
<a name="l146"></a>
<a name="l147"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc)
<a name="l148"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l149"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;type_u8 == </span><span class=cF3>DOCT_NEW_LINE</span><span class=cF0> &amp;&amp; doc_e-&gt;x &gt;= cols + </span><span class=cFE>1</span><span class=cF0>)
<a name="l150"></a> res++;
<a name="l151"></a> doc_e = doc_e-&gt;next;
<a name="l152"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l153"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l154"></a> </span><span class=cF1>if</span><span class=cF0> (res)
<a name="l155"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l156"></a> </span><span class=cF6>&quot;%04d &quot;</span><span class=cF0>, res;
<a name="l157"></a> </span><span class=cF5>PutFileLink</span><span class=cF0>(filename);
<a name="l158"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l159"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l160"></a>
<a name="l161"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l162"></a>}
<a name="l163"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>LongLines</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask=</span><span class=cF6>&quot;*&quot;</span><span class=cF0>, </span><span class=cF9>I64</span><span class=cF0> cols=</span><span class=cFE>128</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l164"></a>{</span><span class=cF2>//Report files with lines of too many cols.</span><span class=cF0>
<a name="l165"></a> </span><span class=cF9>I64</span><span class=cF0> res = </span><span class=cFE>0</span><span class=cF0>, fuf_flags = </span><span class=cFE>0</span><span class=cF0>;
<a name="l166"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde, *tmpde1;
<a name="l167"></a>
<a name="l168"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF6>&quot;+r+f+F+S&quot;</span><span class=cF0>);
<a name="l169"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, fu_flags);
<a name="l170"></a> tmpde = tmpde1 = </span><span class=cF5>FilesFind</span><span class=cF0>(files_find_mask, fuf_flags);
<a name="l171"></a>
<a name="l172"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde)
<a name="l173"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l174"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>LongLinesFile</span><span class=cF7>(</span><span class=cF0>tmpde-&gt;full_name, cols</span><span class=cF7>)</span><span class=cF0>)
<a name="l175"></a> res++;
<a name="l176"></a> tmpde = tmpde-&gt;next;
<a name="l177"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l178"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
<a name="l179"></a>
<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>U0</span><span class=cF0> </span><span class=cF5>SUFile</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF9>I64</span><span class=cF0> suf_flags,</span><span class=cF1>F64</span><span class=cF0> indent_scale_factor)
<a name="l184"></a>{</span><span class=cF2>//String utility on a single file</span><span class=cF0>
<a name="l185"></a></span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4378"><span class=cF4>SU Flags</span></a><span class=cF0>
<a name="l186"></a> </span><span class=cF1>U8</span><span class=cF0> *dst;
<a name="l187"></a> </span><span class=cF1>Bool</span><span class=cF0> chged = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l188"></a> </span><span class=cF9>I64</span><span class=cF0> reduced = </span><span class=cFE>0</span><span class=cF0>;
<a name="l189"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc = </span><span class=cF5>DocRead</span><span class=cF0>(filename, </span><span class=cF3>DOCF_PLAIN_TEXT_TABS</span><span class=cF0> | </span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>);
<a name="l190"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e = doc-&gt;head.next;
<a name="l191"></a>
<a name="l192"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc)
<a name="l193"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l194"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;type_u8 == </span><span class=cF3>DOCT_TEXT</span><span class=cF0>)
<a name="l195"></a> {
<a name="l196"></a> dst = </span><span class=cF5>MStrUtil</span><span class=cF0>(doc_e-&gt;tag, suf_flags, indent_scale_factor);
<a name="l197"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>dst, doc_e-&gt;tag</span><span class=cF7>)</span><span class=cF0>)
<a name="l198"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l199"></a> reduced += </span><span class=cF5>StrLen</span><span class=cF0>(doc_e-&gt;tag) - </span><span class=cF5>StrLen</span><span class=cF0>(dst);
<a name="l200"></a> chged = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l201"></a> </span><span class=cF5>Free</span><span class=cF0>(doc_e-&gt;tag);
<a name="l202"></a> doc_e-&gt;tag = dst;
<a name="l203"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l204"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l205"></a> </span><span class=cF5>Free</span><span class=cF0>(dst);
<a name="l206"></a> }
<a name="l207"></a> doc_e = doc_e-&gt;next;
<a name="l208"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l209"></a> </span><span class=cF1>if</span><span class=cF0> (chged)
<a name="l210"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l211"></a> </span><span class=cF6>&quot;Reduced %s by %d chars\n&quot;</span><span class=cF0>, filename, reduced;
<a name="l212"></a> </span><span class=cF5>DocWrite</span><span class=cF0>(doc);
<a name="l213"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l214"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l215"></a>}
<a name="l216"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>SU</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask, </span><span class=cF9>I64</span><span class=cF0> suf_flags, </span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF3>NULL</span><span class=cF0>, </span><span class=cF1>F64</span><span class=cF0> indent_scale_factor=</span><span class=cFE>0</span><span class=cF0>)
<a name="l217"></a>{</span><span class=cF2>//Apply </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/StrA.CC.html#l528"><span class=cF4>StrUtil</span></a><span class=cF2>() on files.</span><span class=cF0>
<a name="l218"></a></span><span class=cF2>//You can convert spaces to tabs, for example,</span><span class=cF0>
<a name="l219"></a> </span><span class=cF2>//or removing trailing spaces on lines.</span><span class=cF0>
<a name="l220"></a> </span><span class=cF2>//See </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4378"><span class=cF4>SUF Flags</span></a><span class=cF2>.</span><span class=cF0>
<a name="l221"></a> </span><span class=cF9>I64</span><span class=cF0> fuf_flags = </span><span class=cFE>0</span><span class=cF0>;
<a name="l222"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde, *tmpde1;
<a name="l223"></a>
<a name="l224"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF6>&quot;+f+F+T&quot;</span><span class=cF0>);
<a name="l225"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, fu_flags);
<a name="l226"></a> tmpde = tmpde1 = </span><span class=cF5>FilesFind</span><span class=cF0>(files_find_mask, fuf_flags);
<a name="l227"></a>
<a name="l228"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde)
<a name="l229"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l230"></a> </span><span class=cF5>SUFile</span><span class=cF0>(tmpde-&gt;full_name, suf_flags, indent_scale_factor);
<a name="l231"></a> tmpde = tmpde-&gt;next;
<a name="l232"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l233"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
<a name="l234"></a>}
<a name="l235"></a>
<a name="l236"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>S2T</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask, </span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l237"></a>{</span><span class=cF2>//Spaces to tabs.</span><span class=cF0>
<a name="l238"></a></span><span class=cF2>//Use &quot;Hard Space&quot; (SHIFT-SPACE) for spaces</span><span class=cF0>
<a name="l239"></a> </span><span class=cF2>//in string consts in your code.</span><span class=cF0>
<a name="l240"></a> </span><span class=cF5>SU</span><span class=cF0>(files_find_mask, </span><span class=cF3>SUF_S2T</span><span class=cF0> | </span><span class=cF3>SUF_REM_TRAILING</span><span class=cF0>, fu_flags);
<a name="l241"></a>}
</span></pre></body>
</html>