219 lines
19 KiB
HTML
Executable File
219 lines
19 KiB
HTML
Executable File
<!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=cF1>U8</span><span class=cF0> *</span><span class=cF5>Tabs2Spaces</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src)
|
|
<a name="l2"></a>{</span><span class=cF2>//MAlloc str with tabs to spaces.</span><span class=cF0>
|
|
<a name="l3"></a> </span><span class=cF9>I64</span><span class=cF0> ch,i,j,l=</span><span class=cF5>StrLen</span><span class=cF0>(src)<<1+2,col=0;
|
|
<a name="l4"></a> </span><span class=cF1>U8</span><span class=cF0> *dst=</span><span class=cF5>MAlloc</span><span class=cF0>(l),*tmp;
|
|
<a name="l5"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*src++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l6"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'\t'</span><span class=cF0>) {
|
|
<a name="l7"></a> j=(col+8) & ~7;
|
|
<a name="l8"></a> </span><span class=cF1>for</span><span class=cF0> (i=col;i<j;i++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l9"></a> dst[i]=</span><span class=cF3>CH_SPACE</span><span class=cF0>;
|
|
<a name="l10"></a> </span><span class=cF1>if</span><span class=cF0> (i>=l-2) {
|
|
<a name="l11"></a> tmp=</span><span class=cF5>MAlloc</span><span class=cF0>(l<<1);
|
|
<a name="l12"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(tmp,dst,i+1);
|
|
<a name="l13"></a> </span><span class=cF5>Free</span><span class=cF0>(dst);
|
|
<a name="l14"></a> l<<=1;
|
|
<a name="l15"></a> dst=tmp;
|
|
<a name="l16"></a> }
|
|
<a name="l17"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l18"></a> col=j;
|
|
<a name="l19"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l20"></a> dst[col]=ch;
|
|
<a name="l21"></a> </span><span class=cF1>if</span><span class=cF0> (col>=l-2) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l22"></a> tmp=</span><span class=cF5>MAlloc</span><span class=cF0>(l<<1);
|
|
<a name="l23"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(tmp,dst,col+1);
|
|
<a name="l24"></a> </span><span class=cF5>Free</span><span class=cF0>(dst);
|
|
<a name="l25"></a> l<<=1;
|
|
<a name="l26"></a> dst=tmp;
|
|
<a name="l27"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l28"></a> col++;
|
|
<a name="l29"></a> }
|
|
<a name="l30"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l31"></a> dst[col]=0;
|
|
<a name="l32"></a> </span><span class=cF1>return</span><span class=cF0> dst;
|
|
<a name="l33"></a>}
|
|
<a name="l34"></a>
|
|
<a name="l35"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>ScaleIndent</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src,</span><span class=cF1>F64</span><span class=cF0> indent_scale_factor)
|
|
<a name="l36"></a>{</span><span class=cF2>//MAlloced str. 8*0.25-->2 or 8*2.0-->16</span><span class=cF0>
|
|
<a name="l37"></a> </span><span class=cF9>I64</span><span class=cF0> ch,i,col=0;
|
|
<a name="l38"></a> </span><span class=cF1>U8</span><span class=cF0> *dst,*dst2;
|
|
<a name="l39"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*src++) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l40"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'\t'</span><span class=cF0>)
|
|
<a name="l41"></a> col=(col+8) & -0x8;
|
|
<a name="l42"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF3>CH_SPACE</span><span class=cF0>)
|
|
<a name="l43"></a> col++;
|
|
<a name="l44"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l45"></a> </span><span class=cF1>break</span><span class=cF0>;
|
|
<a name="l46"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l47"></a> src--;
|
|
<a name="l48"></a> col=</span><span class=cF5>Round</span><span class=cF0>(indent_scale_factor*col);
|
|
<a name="l49"></a> dst=dst2=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>src</span><span class=cF7>)</span><span class=cF0>+col/8+col&7+1);
|
|
<a name="l50"></a> </span><span class=cF1>for</span><span class=cF0> (i=col/8;i>0;i--)
|
|
<a name="l51"></a> *dst2++=</span><span class=cF6>'\t'</span><span class=cF0>;
|
|
<a name="l52"></a> </span><span class=cF1>for</span><span class=cF0> (i=col&7;i>0;i--)
|
|
<a name="l53"></a> *dst2++=</span><span class=cF3>CH_SPACE</span><span class=cF0>;
|
|
<a name="l54"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(dst2,src);
|
|
<a name="l55"></a> </span><span class=cF1>return</span><span class=cF0> dst;
|
|
<a name="l56"></a>}
|
|
<a name="l57"></a>
|
|
<a name="l58"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>MStrUtil</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *src,</span><span class=cF9>I64</span><span class=cF0> flags,</span><span class=cF1>F64</span><span class=cF0> indent_scale_factor=0)
|
|
<a name="l59"></a>{</span><span class=cF2>//MAlloc </span><a href="/Wb/Kernel/StrA.HC.HTML#l519"><span class=cF4>StrUtil</span></a><span class=cF2>().</span><span class=cF0>
|
|
<a name="l60"></a> </span><span class=cF1>U8</span><span class=cF0> *dst=</span><span class=cF5>StrNew</span><span class=cF0>(src),*dst2,*tmp;
|
|
<a name="l61"></a> </span><span class=cF5>StrUtil</span><span class=cF0>(dst,flags);
|
|
<a name="l62"></a> </span><span class=cF1>if</span><span class=cF0> (flags & </span><span class=cF3>SUF_T2S</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l63"></a> tmp=</span><span class=cF5>Tabs2Spaces</span><span class=cF0>(dst);
|
|
<a name="l64"></a> </span><span class=cF5>Free</span><span class=cF0>(dst);
|
|
<a name="l65"></a> dst=tmp;
|
|
<a name="l66"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l67"></a> </span><span class=cF1>if</span><span class=cF0> (flags & </span><span class=cF3>SUF_SCALE_INDENT</span><span class=cF0>)
|
|
<a name="l68"></a> dst2=</span><span class=cF5>ScaleIndent</span><span class=cF0>(dst,indent_scale_factor);
|
|
<a name="l69"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l70"></a> dst2=</span><span class=cF5>StrNew</span><span class=cF0>(dst); </span><span class=cF2>//Shorten to just right size.</span><span class=cF0>
|
|
<a name="l71"></a> </span><span class=cF5>Free</span><span class=cF0>(dst);
|
|
<a name="l72"></a> </span><span class=cF1>return</span><span class=cF0> dst2;
|
|
<a name="l73"></a>}
|
|
<a name="l74"></a>
|
|
<a name="l75"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>GetOutOfDollar</span><span class=cF0>()
|
|
<a name="l76"></a>{</span><span class=cF2>//If a $ has been printed, print another $ to exit mode.</span><span class=cF0>
|
|
<a name="l77"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc;
|
|
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsRaw</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l79"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>text</span><span class=cF0>.raw_flags&</span><span class=cF3>RWF_IN_DOLLAR</span><span class=cF0>)
|
|
<a name="l80"></a> </span><span class=cF6>'$'</span><span class=cF0>;
|
|
<a name="l81"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l82"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>fp_doc_put</span><span class=cF0> && </span><span class=cF7>(</span><span class=cF0>doc=(*</span><span class=cFB>fp_doc_put</span><span class=cF0>)(</span><span class=cF5>Fs</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0> && doc->flags&</span><span class=cF3>DOCF_IN_DOLLAR</span><span class=cF0>)
|
|
<a name="l83"></a> </span><span class=cF6>'$'</span><span class=cF0>;
|
|
<a name="l84"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l85"></a>}
|
|
<a name="l86"></a>
|
|
<a name="l87"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>YorN</span><span class=cF0>()
|
|
<a name="l88"></a>{</span><span class=cF2>//Wait for user to answer Y or N.</span><span class=cF0>
|
|
<a name="l89"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
|
|
<a name="l90"></a> </span><span class=cF6>"(y or n)? "</span><span class=cF0>;
|
|
<a name="l91"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF3>TRUE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l92"></a> ch=</span><span class=cF5>ToUpper</span><span class=cF0>(</span><span class=cF5>GetChar</span><span class=cF7>(</span><span class=cF0>,</span><span class=cF3>FALSE</span><span class=cF7>)</span><span class=cF0>);
|
|
<a name="l93"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'Y'</span><span class=cF0>) {
|
|
<a name="l94"></a> </span><span class=cF6>"$PT$YES$FG$\n"</span><span class=cF0>;
|
|
<a name="l95"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>TRUE</span><span class=cF0>;
|
|
<a name="l96"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'N'</span><span class=cF0>) {
|
|
<a name="l97"></a> </span><span class=cF6>"$PT$NO$FG$\n"</span><span class=cF0>;
|
|
<a name="l98"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>FALSE</span><span class=cF0>;
|
|
<a name="l99"></a> }
|
|
<a name="l100"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l101"></a>}
|
|
<a name="l102"></a>
|
|
<a name="l103"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>PressAKey</span><span class=cF0>()
|
|
<a name="l104"></a>{</span><span class=cF2>//Print "Press a key" and wait for non-zero </span><a href="/Wb/Kernel/KernelA.HH.HTML#l3426"><span class=cF4>ASCII</span></a><span class=cF2> key.</span><span class=cF0>
|
|
<a name="l105"></a> </span><span class=cF6>"$BK,1$PRESS A KEY$BK,0$\n"</span><span class=cF0>;
|
|
<a name="l106"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>GetChar</span><span class=cF0>(,</span><span class=cF3>FALSE</span><span class=cF0>);
|
|
<a name="l107"></a>}
|
|
<a name="l108"></a>
|
|
<a name="l109"></a></span><span class=cF1>Bool</span><span class=cF0> </span><span class=cF5>AreYouSure</span><span class=cF0>()
|
|
<a name="l110"></a>{</span><span class=cF2>//Print "Are you sure" and waits for Y or N.</span><span class=cF0>
|
|
<a name="l111"></a> </span><span class=cF6>"ARE YOU SURE "</span><span class=cF0>;
|
|
<a name="l112"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>YorN</span><span class=cF0>;
|
|
<a name="l113"></a>}
|
|
<a name="l114"></a>
|
|
<a name="l115"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Help</span><span class=cF0>()
|
|
<a name="l116"></a>{</span><span class=cF2>//Dbg help or master help index file.</span><span class=cF0>
|
|
<a name="l117"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>IsDbgMode</span><span class=cF0>)
|
|
<a name="l118"></a> </span><span class=cFD>DbgHelp</span><span class=cF0>;
|
|
<a name="l119"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l120"></a> </span><span class=cF5>PopUp</span><span class=cF0>(</span><span class=cF6>"Type(\"::/Doc/HelpIndex.DD\");DocTop;View;"</span><span class=cF0>);
|
|
<a name="l121"></a>}
|
|
<a name="l122"></a>
|
|
<a name="l123"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>ScanFlags</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *_dst_flags,</span><span class=cF1>U8</span><span class=cF0> *lst,</span><span class=cF1>U8</span><span class=cF0> *src)
|
|
<a name="l124"></a>{</span><span class=cF2>/*More than 64 flags. Flags passed by ref.</span><span class=cF0>
|
|
<a name="l125"></a>
|
|
<a name="l126"></a></span><span class=cF2>Examples:</span><span class=cF4>
|
|
<a name="l127"></a></span><a href="/Wb/Adam/Opt/Utils/Diff.HC.HTML#l330"><span class=cF4>ScanFlags</span></a><span class=cF2>(&fuf_flags,Define("ST_FILE_UTIL_FLAGS"),fu_flags);</span><span class=cF0>
|
|
<a name="l128"></a>
|
|
<a name="l129"></a></span><span class=cF2>I64 flags=0;</span><span class=cF0>
|
|
<a name="l130"></a></span><span class=cF2>ScanFlags(&flags,"R\0L\0Dump\0Scan\0","+Dump-R"); //Sets Bit#2, Clears Bit#0.</span><span class=cF0>
|
|
<a name="l131"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l132"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l133"></a> </span><span class=cF1>U8</span><span class=cF0> *buf,*ptr;
|
|
<a name="l134"></a> </span><span class=cF1>if</span><span class=cF0> (src) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l135"></a> buf=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>src</span><span class=cF7>)</span><span class=cF0>+1);
|
|
<a name="l136"></a> </span><span class=cF1>while</span><span class=cF0> (*src) {
|
|
<a name="l137"></a> </span><span class=cF1>while</span><span class=cF0> (*src && *src!=</span><span class=cF6>'+'</span><span class=cF0> && *src!=</span><span class=cF6>'-'</span><span class=cF0>)
|
|
<a name="l138"></a> src++;
|
|
<a name="l139"></a> </span><span class=cF1>if</span><span class=cF0> (*src==</span><span class=cF6>'+'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l140"></a> src++;
|
|
<a name="l141"></a> </span><span class=cF1>if</span><span class=cF0> (*src) {
|
|
<a name="l142"></a> ptr=buf;
|
|
<a name="l143"></a> </span><span class=cF1>while</span><span class=cF0> (*src && *src!=</span><span class=cF6>'+'</span><span class=cF0> && *src!=</span><span class=cF6>'-'</span><span class=cF0> &&
|
|
<a name="l144"></a> *src!=</span><span class=cF3>CH_SPACE</span><span class=cF0> && *src!=</span><span class=cF3>CH_SHIFT_SPACE</span><span class=cF0>)
|
|
<a name="l145"></a> *ptr++=*src++;
|
|
<a name="l146"></a> *ptr=0;
|
|
<a name="l147"></a> i=</span><span class=cF5>LstMatch</span><span class=cF0>(buf,lst);
|
|
<a name="l148"></a> </span><span class=cF1>if</span><span class=cF0> (i>=0)
|
|
<a name="l149"></a> </span><span class=cF5>LBts</span><span class=cF0>(_dst_flags,i);
|
|
<a name="l150"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l151"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l152"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'ScanFlag'</span><span class=cF0>);
|
|
<a name="l153"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l154"></a> }
|
|
<a name="l155"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (*src==</span><span class=cF6>'-'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l156"></a> src++;
|
|
<a name="l157"></a> </span><span class=cF1>if</span><span class=cF0> (*src) {
|
|
<a name="l158"></a> ptr=buf;
|
|
<a name="l159"></a> </span><span class=cF1>while</span><span class=cF0> (*src && *src!=</span><span class=cF6>'+'</span><span class=cF0> && *src!=</span><span class=cF6>'-'</span><span class=cF0> &&
|
|
<a name="l160"></a> *src!=</span><span class=cF3>CH_SPACE</span><span class=cF0> && *src!=</span><span class=cF3>CH_SHIFT_SPACE</span><span class=cF0>)
|
|
<a name="l161"></a> *ptr++=*src++;
|
|
<a name="l162"></a> *ptr=0;
|
|
<a name="l163"></a> i=</span><span class=cF5>LstMatch</span><span class=cF0>(buf,lst);
|
|
<a name="l164"></a> </span><span class=cF1>if</span><span class=cF0> (i>=0)
|
|
<a name="l165"></a> </span><span class=cF5>LBtr</span><span class=cF0>(_dst_flags,i);
|
|
<a name="l166"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l167"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l168"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'ScanFlag'</span><span class=cF0>);
|
|
<a name="l169"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l170"></a> }
|
|
<a name="l171"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l172"></a> }
|
|
<a name="l173"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
|
<a name="l174"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l175"></a>}
|
|
<a name="l176"></a>
|
|
<a name="l177"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>StrPrintFlags</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *dst,</span><span class=cF1>U8</span><span class=cF0> *lst,</span><span class=cF9>I64</span><span class=cF0> flags)
|
|
<a name="l178"></a>{</span><span class=cF2>//Only 64 flags. Flags passed by value.</span><span class=cF0>
|
|
<a name="l179"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
|
<a name="l180"></a> *dst=0;
|
|
<a name="l181"></a> </span><span class=cF1>while</span><span class=cF0> (flags) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l182"></a> i=</span><span class=cF5>Bsf</span><span class=cF0>(flags);
|
|
<a name="l183"></a> </span><span class=cF5>Btr</span><span class=cF0>(&flags,i);
|
|
<a name="l184"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(dst,</span><span class=cF6>"+%z"</span><span class=cF0>,i,lst);
|
|
<a name="l185"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l186"></a> </span><span class=cF1>return</span><span class=cF0> dst;
|
|
<a name="l187"></a>}
|
|
</span></pre></body>
|
|
</html>
|