952 lines
90 KiB
Plaintext
952 lines
90 KiB
Plaintext
|
<!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>U0</span><span class=cF0> </span><span class=cFD>SPutChar</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> **_dst,</span><span class=cF1>U8</span><span class=cF0> ch,</span><span class=cF1>U8</span><span class=cF0> **_buf)
|
||
|
<a name="l2"></a>{
|
||
|
<a name="l3"></a> </span><span class=cF9>I64</span><span class=cF0> i;
|
||
|
<a name="l4"></a> </span><span class=cF1>U8</span><span class=cF0> *dst=*_dst,*buf;
|
||
|
<a name="l5"></a> </span><span class=cF1>if</span><span class=cF0> (_buf) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l6"></a> buf=*_buf;
|
||
|
<a name="l7"></a> i=dst-buf;
|
||
|
<a name="l8"></a> </span><span class=cF1>if</span><span class=cF0> (i>=</span><span class=cF5>MSize</span><span class=cF7>(</span><span class=cF0>buf</span><span class=cF7>)</span><span class=cF0>) {
|
||
|
<a name="l9"></a> buf=</span><span class=cF5>MAlloc</span><span class=cF0>(i<<1+1);
|
||
|
<a name="l10"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(buf,*_buf,i);
|
||
|
<a name="l11"></a> </span><span class=cF5>Free</span><span class=cF0>(*_buf);
|
||
|
<a name="l12"></a> dst=buf+i;
|
||
|
<a name="l13"></a> *_buf=buf;
|
||
|
<a name="l14"></a> }
|
||
|
<a name="l15"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l16"></a> *dst++=ch;
|
||
|
<a name="l17"></a> *_dst=dst;
|
||
|
<a name="l18"></a>}
|
||
|
<a name="l19"></a>
|
||
|
<a name="l20"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>OutStr</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *ptr,</span><span class=cF1>U8</span><span class=cF0> **_buf,</span><span class=cF1>U8</span><span class=cF0> **_dst,</span><span class=cF9>I64</span><span class=cF0> len,</span><span class=cF9>I64</span><span class=cF0> flags)
|
||
|
<a name="l21"></a>{
|
||
|
<a name="l22"></a> </span><span class=cF9>I64</span><span class=cF0> i,j;
|
||
|
<a name="l23"></a> </span><span class=cF1>if</span><span class=cF0> (!ptr)
|
||
|
<a name="l24"></a> i=0;
|
||
|
<a name="l25"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l26"></a> i=</span><span class=cF5>StrLen</span><span class=cF0>(ptr);
|
||
|
<a name="l27"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF0> && i>len)
|
||
|
<a name="l28"></a> i=len;
|
||
|
<a name="l29"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_LEFT_JUSTIFY</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l30"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<i;j++)
|
||
|
<a name="l31"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,*ptr++,_buf);
|
||
|
<a name="l32"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<len-i;j++)
|
||
|
<a name="l33"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF3>CH_SPACE</span><span class=cF0>,_buf);
|
||
|
<a name="l34"></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="l35"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<len-i;j++)
|
||
|
<a name="l36"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF3>CH_SPACE</span><span class=cF0>,_buf);
|
||
|
<a name="l37"></a> </span><span class=cF1>for</span><span class=cF0> (j=len-i;j<len;j++)
|
||
|
<a name="l38"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,*ptr++,_buf);
|
||
|
<a name="l39"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l40"></a>}
|
||
|
<a name="l41"></a>
|
||
|
<a name="l42"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>MPrintTime</span><span class=cF0>(</span><span class=cF9>CDate</span><span class=cF0> cdt)
|
||
|
<a name="l43"></a>{
|
||
|
<a name="l44"></a> </span><span class=cF9>CDateStruct</span><span class=cF0> ds;
|
||
|
<a name="l45"></a> </span><span class=cF5>Date2Struct</span><span class=cF0>(&ds,cdt+</span><span class=cFB>local_time_offset</span><span class=cF0>);
|
||
|
<a name="l46"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%02d:%02d:%02d"</span><span class=cF0>,ds.hour,ds.min,ds.sec);
|
||
|
<a name="l47"></a>}
|
||
|
<a name="l48"></a>
|
||
|
<a name="l49"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>MPrintDate</span><span class=cF0>(</span><span class=cF9>CDate</span><span class=cF0> cdt)
|
||
|
<a name="l50"></a>{
|
||
|
<a name="l51"></a> </span><span class=cF9>CDateStruct</span><span class=cF0> ds;
|
||
|
<a name="l52"></a> </span><span class=cF5>Date2Struct</span><span class=cF0>(&ds,cdt+</span><span class=cFB>local_time_offset</span><span class=cF0>);
|
||
|
<a name="l53"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>"%02d/%02d/%02d"</span><span class=cF0>,ds.mon,ds.day_of_mon,ds.year%100);
|
||
|
<a name="l54"></a>}
|
||
|
<a name="l55"></a>
|
||
|
<a name="l56"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cFD>MPrintQ</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *ptr,</span><span class=cF9>I64</span><span class=cF0> flags)
|
||
|
<a name="l57"></a>{
|
||
|
<a name="l58"></a> </span><span class=cF1>U8</span><span class=cF0> **_buf,*buf,**_dst,*dst,buf2[8],*ptr2;
|
||
|
<a name="l59"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
|
||
|
<a name="l60"></a> buf=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF3>STR_LEN</span><span class=cF0>);
|
||
|
<a name="l61"></a> _buf=&buf;
|
||
|
<a name="l62"></a> dst=buf;
|
||
|
<a name="l63"></a> _dst=&dst;
|
||
|
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (ptr)
|
||
|
<a name="l65"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*ptr++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l66"></a> </span><span class=cF1>switch</span><span class=cF0> (ch) {
|
||
|
<a name="l67"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'$'</span><span class=cF0>:
|
||
|
<a name="l68"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_DOLLAR</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l69"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\\'</span><span class=cF0>,_buf);
|
||
|
<a name="l70"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'d'</span><span class=cF0>,_buf);
|
||
|
<a name="l71"></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="l72"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l73"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l74"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l75"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l76"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'%'</span><span class=cF0>:
|
||
|
<a name="l77"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l78"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_SLASH</span><span class=cF0>)
|
||
|
<a name="l79"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l80"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l81"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
|
||
|
<a name="l82"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\\'</span><span class=cF0>,_buf);
|
||
|
<a name="l83"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'n'</span><span class=cF0>,_buf);
|
||
|
<a name="l84"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l85"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\r'</span><span class=cF0>:
|
||
|
<a name="l86"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\\'</span><span class=cF0>,_buf);
|
||
|
<a name="l87"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'r'</span><span class=cF0>,_buf);
|
||
|
<a name="l88"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l89"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\t'</span><span class=cF0>:
|
||
|
<a name="l90"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\\'</span><span class=cF0>,_buf);
|
||
|
<a name="l91"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'t'</span><span class=cF0>,_buf);
|
||
|
<a name="l92"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l93"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'"'</span><span class=cF0>:
|
||
|
<a name="l94"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\\'</span><span class=cF0>:
|
||
|
<a name="l95"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\\'</span><span class=cF0>,_buf);
|
||
|
<a name="l96"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l97"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l98"></a> </span><span class=cF1>default</span><span class=cF0>:
|
||
|
<a name="l99"></a> </span><span class=cF1>if</span><span class=cF0> (ch>=</span><span class=cF3>CH_SHIFT_SPACE</span><span class=cF0> && ch!=0x7F)
|
||
|
<a name="l100"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l101"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l102"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(buf2,</span><span class=cF6>"\\x%02X"</span><span class=cF0>,ch);
|
||
|
<a name="l103"></a> ptr2=buf2;
|
||
|
<a name="l104"></a> </span><span class=cF1>while</span><span class=cF0> (*ptr2)
|
||
|
<a name="l105"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,*ptr2++,_buf);
|
||
|
<a name="l106"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l107"></a> }
|
||
|
<a name="l108"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l109"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,0,_buf);
|
||
|
<a name="l110"></a> </span><span class=cF1>return</span><span class=cF0> buf;
|
||
|
<a name="l111"></a>}
|
||
|
<a name="l112"></a>
|
||
|
<a name="l113"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cFD>MPrintq</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *ptr,</span><span class=cF9>I64</span><span class=cF0> flags)
|
||
|
<a name="l114"></a>{
|
||
|
<a name="l115"></a> </span><span class=cF1>U8</span><span class=cF0> **_buf,*buf,**_dst,*dst;
|
||
|
<a name="l116"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,ch,ch1;
|
||
|
<a name="l117"></a> buf=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF3>STR_LEN</span><span class=cF0>);
|
||
|
<a name="l118"></a> _buf=&buf;
|
||
|
<a name="l119"></a> dst=buf;
|
||
|
<a name="l120"></a> _dst=&dst;
|
||
|
<a name="l121"></a> </span><span class=cF1>if</span><span class=cF0> (ptr)
|
||
|
<a name="l122"></a> </span><span class=cF1>while</span><span class=cF0> (ch=*ptr++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l123"></a> ch1=*ptr;
|
||
|
<a name="l124"></a> </span><span class=cF1>switch</span><span class=cF0> (ch) {
|
||
|
<a name="l125"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\\'</span><span class=cF0>:
|
||
|
<a name="l126"></a> </span><span class=cF1>switch</span><span class=cF0> (ch1) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l127"></a> </span><span class=cF1>start</span><span class=cF0>:
|
||
|
<a name="l128"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'0'</span><span class=cF0>:
|
||
|
<a name="l129"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,0,_buf);
|
||
|
<a name="l130"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l131"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\''</span><span class=cF0>:
|
||
|
<a name="l132"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\''</span><span class=cF0>,_buf);
|
||
|
<a name="l133"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l134"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\`'</span><span class=cF0>:
|
||
|
<a name="l135"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\`'</span><span class=cF0>,_buf);
|
||
|
<a name="l136"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l137"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'"'</span><span class=cF0>:
|
||
|
<a name="l138"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'"'</span><span class=cF0>,_buf);
|
||
|
<a name="l139"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l140"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\\'</span><span class=cF0>:
|
||
|
<a name="l141"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\\'</span><span class=cF0>,_buf);
|
||
|
<a name="l142"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l143"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'d'</span><span class=cF0>:
|
||
|
<a name="l144"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'$'</span><span class=cF0>,_buf);
|
||
|
<a name="l145"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l146"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'n'</span><span class=cF0>:
|
||
|
<a name="l147"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\n'</span><span class=cF0>,_buf);
|
||
|
<a name="l148"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l149"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'r'</span><span class=cF0>:
|
||
|
<a name="l150"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\r'</span><span class=cF0>,_buf);
|
||
|
<a name="l151"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l152"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'t'</span><span class=cF0>:
|
||
|
<a name="l153"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'\t'</span><span class=cF0>,_buf);
|
||
|
<a name="l154"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l155"></a> </span><span class=cF1>end</span><span class=cF0>:
|
||
|
<a name="l156"></a> ptr++;
|
||
|
<a name="l157"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l158"></a>
|
||
|
<a name="l159"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'x'</span><span class=cF0>:
|
||
|
<a name="l160"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'X'</span><span class=cF0>:
|
||
|
<a name="l161"></a> i=0;
|
||
|
<a name="l162"></a> ptr++;
|
||
|
<a name="l163"></a> </span><span class=cF1>for</span><span class=cF0> (j=0;j<2;j++) {
|
||
|
<a name="l164"></a> ch1=</span><span class=cF5>ToUpper</span><span class=cF0>(*ptr++);
|
||
|
<a name="l165"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>char_bmp_hex_numeric</span><span class=cF0>,ch1</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l166"></a> </span><span class=cF1>if</span><span class=cF0> (ch1<=</span><span class=cF6>'9'</span><span class=cF0>)
|
||
|
<a name="l167"></a> i=i<<4+ch1-</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l168"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l169"></a> i=i<<4+ch1-</span><span class=cF6>'A'</span><span class=cF0>+10;
|
||
|
<a name="l170"></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="l171"></a> ptr--;
|
||
|
<a name="l172"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l173"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l174"></a> }
|
||
|
<a name="l175"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,i,_buf);
|
||
|
<a name="l176"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l177"></a>
|
||
|
<a name="l178"></a> </span><span class=cF1>default</span><span class=cF0>:
|
||
|
<a name="l179"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l180"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l181"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l182"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'$'</span><span class=cF0>:
|
||
|
<a name="l183"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l184"></a> </span><span class=cF1>if</span><span class=cF0> (ch1==</span><span class=cF6>'$'</span><span class=cF0>)
|
||
|
<a name="l185"></a> ptr++;
|
||
|
<a name="l186"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l187"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'%'</span><span class=cF0>:
|
||
|
<a name="l188"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l189"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_SLASH</span><span class=cF0> && ch1==</span><span class=cF6>'%'</span><span class=cF0>)
|
||
|
<a name="l190"></a> ptr++;
|
||
|
<a name="l191"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l192"></a> </span><span class=cF1>default</span><span class=cF0>:
|
||
|
<a name="l193"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l194"></a> }
|
||
|
<a name="l195"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l196"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,0,_buf);
|
||
|
<a name="l197"></a> </span><span class=cF1>return</span><span class=cF0> buf;
|
||
|
<a name="l198"></a>}
|
||
|
<a name="l199"></a>
|
||
|
<a name="l200"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cFD>sys_pos_pows_lets</span><span class=cF0>=</span><span class=cF6>" KMGTPEZY"</span><span class=cF0>,
|
||
|
<a name="l201"></a> *</span><span class=cFD>sys_neg_pows_lets</span><span class=cF0>=</span><span class=cF6>" munpfazy"</span><span class=cF0>,
|
||
|
<a name="l202"></a> *</span><span class=cFD>sys_pos_pows_lst</span><span class=cF0>=</span><span class=cF6>"kilo\0mega\0giga\0tera\0peta\0exa\0zetta\0yotta\0"</span><span class=cF0>,
|
||
|
<a name="l203"></a> *</span><span class=cFD>sys_neg_pows_lst</span><span class=cF0>=</span><span class=cF6>"milli\0micro\0nano\0pico\0femto\0atto\0zepto\0yocto\0"</span><span class=cF0>;
|
||
|
<a name="l204"></a>
|
||
|
<a name="l205"></a>#</span><span class=cF1>define</span><span class=cF0> TMP_BUF_LEN 256
|
||
|
<a name="l206"></a>#</span><span class=cF1>define</span><span class=cF0> SLOP 8
|
||
|
<a name="l207"></a>
|
||
|
<a name="l208"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *dst,</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="l209"></a>{</span><span class=cF2>/*</span><a href="/Wb/Doc/Print.DD.HTML#l1"><span class=cF4>Print("") Fmt Strings</span></a><span class=cF0>
|
||
|
<a name="l210"></a></span><span class=cF2>In float formatting, do not exceed 18-digits</span><span class=cF0>
|
||
|
<a name="l211"></a></span><span class=cF2>before or after the decimal point</span><span class=cF0>
|
||
|
<a name="l212"></a></span><span class=cF2>because the numbers before and after</span><span class=cF0>
|
||
|
<a name="l213"></a></span><span class=cF2>the decimal point are stored</span><span class=cF0>
|
||
|
<a name="l214"></a></span><span class=cF2>in 64-bits. Use exponentiated forms</span><span class=cF0>
|
||
|
<a name="l215"></a></span><span class=cF2>to avoid this.</span><span class=cF0>
|
||
|
<a name="l216"></a></span><span class=cF2>*/</span><span class=cF0>
|
||
|
<a name="l217"></a> </span><span class=cF9>I64</span><span class=cF0> i,j,l,ch,k,k0,n,n0,len,dec_len,flags,old_flags,
|
||
|
<a name="l218"></a> aux_fmt_num,comma_cnt,comma_fmt_cnt,cur_arg=0;
|
||
|
<a name="l219"></a> </span><span class=cF9>U64</span><span class=cF0> m;
|
||
|
<a name="l220"></a> </span><span class=cF1>F64</span><span class=cF0> d,d1;
|
||
|
<a name="l221"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc;
|
||
|
<a name="l222"></a> </span><span class=cF1>U8</span><span class=cF0> *ptr,**_buf,*buf,**_dst,tmp_buf[TMP_BUF_LEN],tmp_buf2[TMP_BUF_LEN*2];
|
||
|
<a name="l223"></a>
|
||
|
<a name="l224"></a> </span><span class=cF1>if</span><span class=cF0> (!fmt)
|
||
|
<a name="l225"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l226"></a> </span><span class=cF1>if</span><span class=cF0> (dst) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l227"></a> _buf=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l228"></a> buf=dst;
|
||
|
<a name="l229"></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="l230"></a> buf=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF3>STR_LEN</span><span class=cF0>);
|
||
|
<a name="l231"></a> _buf=&buf;
|
||
|
<a name="l232"></a> dst=buf;
|
||
|
<a name="l233"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l234"></a> _dst=&dst;
|
||
|
<a name="l235"></a>
|
||
|
<a name="l236"></a> </span><span class=cF1>while</span><span class=cF0> (ch = *fmt++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l237"></a> </span><span class=cF1>if</span><span class=cF0> (ch==</span><span class=cF6>'%'</span><span class=cF0>) {
|
||
|
<a name="l238"></a> flags=0;
|
||
|
<a name="l239"></a> </span><span class=cF1>if</span><span class=cF0> (*fmt==</span><span class=cF6>'-'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l240"></a> flags|=</span><span class=cF3>PRTF_LEFT_JUSTIFY</span><span class=cF0>;
|
||
|
<a name="l241"></a> fmt++;
|
||
|
<a name="l242"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l243"></a> </span><span class=cF1>if</span><span class=cF0> (*fmt==</span><span class=cF6>'0'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l244"></a> flags|=</span><span class=cF3>PRTF_PAD_ZERO</span><span class=cF0>;
|
||
|
<a name="l245"></a> fmt++;
|
||
|
<a name="l246"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l247"></a> len=0;
|
||
|
<a name="l248"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF6>'0'</span><span class=cF0><=*fmt<=</span><span class=cF6>'9'</span><span class=cF0>)
|
||
|
<a name="l249"></a> len=len*10+ *fmt++ -</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l250"></a> </span><span class=cF1>if</span><span class=cF0> (*fmt==</span><span class=cF6>'*'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l251"></a> fmt++;
|
||
|
<a name="l252"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l253"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l254"></a> len=argv[cur_arg++];
|
||
|
<a name="l255"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l256"></a> dec_len=0;
|
||
|
<a name="l257"></a> </span><span class=cF1>if</span><span class=cF0> (*fmt==</span><span class=cF6>'.'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l258"></a> fmt++;
|
||
|
<a name="l259"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF6>'0'</span><span class=cF0><=*fmt<=</span><span class=cF6>'9'</span><span class=cF0>)
|
||
|
<a name="l260"></a> dec_len=dec_len*10+ *fmt++ -</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l261"></a> </span><span class=cF1>if</span><span class=cF0> (*fmt==</span><span class=cF6>'*'</span><span class=cF0>) {
|
||
|
<a name="l262"></a> fmt++;
|
||
|
<a name="l263"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l264"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l265"></a> dec_len=argv[cur_arg++];
|
||
|
<a name="l266"></a> }
|
||
|
<a name="l267"></a> flags|=</span><span class=cF3>PRTF_DECIMAL</span><span class=cF0>;
|
||
|
<a name="l268"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l269"></a>
|
||
|
<a name="l270"></a> aux_fmt_num=0;
|
||
|
<a name="l271"></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="l272"></a> </span><span class=cF1>switch</span><span class=cF0> (*fmt) {
|
||
|
<a name="l273"></a> </span><span class=cF1>start</span><span class=cF0>:
|
||
|
<a name="l274"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'$'</span><span class=cF0>:
|
||
|
<a name="l275"></a> flags|=</span><span class=cF3>PRTF_DOLLAR</span><span class=cF0>;
|
||
|
<a name="l276"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l277"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'/'</span><span class=cF0>:
|
||
|
<a name="l278"></a> flags|=</span><span class=cF3>PRTF_SLASH</span><span class=cF0>;
|
||
|
<a name="l279"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l280"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>','</span><span class=cF0>:
|
||
|
<a name="l281"></a> flags|=</span><span class=cF3>PRTF_COMMA</span><span class=cF0>;
|
||
|
<a name="l282"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l283"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'t'</span><span class=cF0>:
|
||
|
<a name="l284"></a> flags|=</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF0>;
|
||
|
<a name="l285"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l286"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'l'</span><span class=cF0>: </span><span class=cF2>//harmless</span><span class=cF0>
|
||
|
<a name="l287"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l288"></a> </span><span class=cF1>end</span><span class=cF0>:
|
||
|
<a name="l289"></a> fmt++;
|
||
|
<a name="l290"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l291"></a>
|
||
|
<a name="l292"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'h'</span><span class=cF0>:
|
||
|
<a name="l293"></a> fmt++;
|
||
|
<a name="l294"></a> flags|=</span><span class=cF3>PRTF_AUX_FMT_NUM</span><span class=cF0>;
|
||
|
<a name="l295"></a> </span><span class=cF1>if</span><span class=cF0> (*fmt==</span><span class=cF6>'?'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l296"></a> fmt++;
|
||
|
<a name="l297"></a> flags|=</span><span class=cF3>PRTF_QUESTION</span><span class=cF0>;
|
||
|
<a name="l298"></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="l299"></a> </span><span class=cF1>if</span><span class=cF0> (*fmt==</span><span class=cF6>'*'</span><span class=cF0>) {
|
||
|
<a name="l300"></a> fmt++;
|
||
|
<a name="l301"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l302"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l303"></a> aux_fmt_num=argv[cur_arg++];
|
||
|
<a name="l304"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l305"></a> </span><span class=cF1>if</span><span class=cF0> (*fmt==</span><span class=cF6>'-'</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l306"></a> fmt++;
|
||
|
<a name="l307"></a> flags|=</span><span class=cF3>PRTF_NEG_AUX_FMT_NUM</span><span class=cF0>;
|
||
|
<a name="l308"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l309"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF6>'0'</span><span class=cF0><=*fmt<=</span><span class=cF6>'9'</span><span class=cF0>)
|
||
|
<a name="l310"></a> aux_fmt_num=aux_fmt_num*10+ *fmt++ -</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l311"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG_AUX_FMT_NUM</span><span class=cF0>)
|
||
|
<a name="l312"></a> aux_fmt_num=-aux_fmt_num;
|
||
|
<a name="l313"></a> }
|
||
|
<a name="l314"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l315"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l316"></a> </span><span class=cF1>default</span><span class=cF0>:
|
||
|
<a name="l317"></a> </span><span class=cF1>goto</span><span class=cF0> sp_arg;
|
||
|
<a name="l318"></a> }
|
||
|
<a name="l319"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l320"></a>
|
||
|
<a name="l321"></a> sp_arg:
|
||
|
<a name="l322"></a> k=0;
|
||
|
<a name="l323"></a> </span><span class=cF1>switch</span><span class=cF0> (*fmt++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l324"></a> </span><span class=cF1>start</span><span class=cF0>:
|
||
|
<a name="l325"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'F'</span><span class=cF0>:
|
||
|
<a name="l326"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l327"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l328"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_DOLLAR</span><span class=cF0>) {
|
||
|
<a name="l329"></a> doc=argv[cur_arg++];
|
||
|
<a name="l330"></a> old_flags=doc->flags;
|
||
|
<a name="l331"></a> doc->flags|=</span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>;
|
||
|
<a name="l332"></a> ptr=</span><span class=cF5>DocSave</span><span class=cF0>(doc);
|
||
|
<a name="l333"></a> doc->flags=old_flags;
|
||
|
<a name="l334"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l335"></a> ptr=</span><span class=cF5>FileRead</span><span class=cF0>(argv[cur_arg++]);
|
||
|
<a name="l336"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l337"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'Q'</span><span class=cF0>:
|
||
|
<a name="l338"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l339"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l340"></a> ptr=</span><span class=cFD>MPrintQ</span><span class=cF0>(argv[cur_arg++],flags);
|
||
|
<a name="l341"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l342"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'q'</span><span class=cF0>:
|
||
|
<a name="l343"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l344"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l345"></a> ptr=</span><span class=cFD>MPrintq</span><span class=cF0>(argv[cur_arg++],flags);
|
||
|
<a name="l346"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l347"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'D'</span><span class=cF0>:
|
||
|
<a name="l348"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l349"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l350"></a> ptr=</span><span class=cF5>MPrintDate</span><span class=cF0>(argv[cur_arg++]);
|
||
|
<a name="l351"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l352"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'T'</span><span class=cF0>:
|
||
|
<a name="l353"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l354"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l355"></a> ptr=</span><span class=cF5>MPrintTime</span><span class=cF0>(argv[cur_arg++]);
|
||
|
<a name="l356"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l357"></a> </span><span class=cF1>end</span><span class=cF0>:
|
||
|
<a name="l358"></a> </span><span class=cFD>OutStr</span><span class=cF0>(ptr,_buf,_dst,len,flags);
|
||
|
<a name="l359"></a> </span><span class=cF5>Free</span><span class=cF0>(ptr);
|
||
|
<a name="l360"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l361"></a>
|
||
|
<a name="l362"></a> </span><span class=cF1>start</span><span class=cF0>:
|
||
|
<a name="l363"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'s'</span><span class=cF0>:
|
||
|
<a name="l364"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l365"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l366"></a> ptr=argv[cur_arg++];
|
||
|
<a name="l367"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l368"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'S'</span><span class=cF0>:
|
||
|
<a name="l369"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l370"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l371"></a> ptr=</span><span class=cF5>Define</span><span class=cF0>(argv[cur_arg++]);
|
||
|
<a name="l372"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l373"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'z'</span><span class=cF0>:
|
||
|
<a name="l374"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg+1>=argc)
|
||
|
<a name="l375"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l376"></a> ptr=</span><span class=cF5>LstSub</span><span class=cF0>(argv[cur_arg],argv[cur_arg+1]);
|
||
|
<a name="l377"></a> cur_arg=cur_arg+2;
|
||
|
<a name="l378"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l379"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'Z'</span><span class=cF0>:
|
||
|
<a name="l380"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg+1>=argc)
|
||
|
<a name="l381"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l382"></a> ptr=</span><span class=cF5>DefineSub</span><span class=cF0>(argv[cur_arg],argv[cur_arg+1]);
|
||
|
<a name="l383"></a> cur_arg=cur_arg+2;
|
||
|
<a name="l384"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l385"></a> </span><span class=cF1>end</span><span class=cF0>:
|
||
|
<a name="l386"></a> </span><span class=cFD>OutStr</span><span class=cF0>(ptr,_buf,_dst,len,flags);
|
||
|
<a name="l387"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l388"></a>
|
||
|
<a name="l389"></a> </span><span class=cF1>start</span><span class=cF0>:
|
||
|
<a name="l390"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'c'</span><span class=cF0>:
|
||
|
<a name="l391"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l392"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l393"></a> tmp_buf[0](</span><span class=cF9>I64</span><span class=cF0>)=argv[cur_arg++];
|
||
|
<a name="l394"></a> tmp_buf[8]=0;
|
||
|
<a name="l395"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l396"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'C'</span><span class=cF0>:
|
||
|
<a name="l397"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l398"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l399"></a> tmp_buf[0](</span><span class=cF9>I64</span><span class=cF0>)=argv[cur_arg++];
|
||
|
<a name="l400"></a> tmp_buf[8]=0;
|
||
|
<a name="l401"></a> ptr=tmp_buf;
|
||
|
<a name="l402"></a> </span><span class=cF1>while</span><span class=cF0> (*ptr) {
|
||
|
<a name="l403"></a> *ptr=</span><span class=cF5>ToUpper</span><span class=cF0>(*ptr);
|
||
|
<a name="l404"></a> ptr++;
|
||
|
<a name="l405"></a> }
|
||
|
<a name="l406"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l407"></a> </span><span class=cF1>end</span><span class=cF0>:
|
||
|
<a name="l408"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>flags&</span><span class=cF3>PRTF_AUX_FMT_NUM</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l409"></a> aux_fmt_num=1;
|
||
|
<a name="l410"></a> </span><span class=cF1>while</span><span class=cF0> (aux_fmt_num-->0)
|
||
|
<a name="l411"></a> </span><span class=cFD>OutStr</span><span class=cF0>(tmp_buf,_buf,_dst,len,flags);
|
||
|
<a name="l412"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l413"></a>
|
||
|
<a name="l414"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'p'</span><span class=cF0>:
|
||
|
<a name="l415"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l416"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l417"></a> </span><span class=cFD>StrPrintFunSeg</span><span class=cF0>(tmp_buf,argv[cur_arg++],len,flags);
|
||
|
<a name="l418"></a> </span><span class=cFD>OutStr</span><span class=cF0>(tmp_buf,_buf,_dst,len,flags);
|
||
|
<a name="l419"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l420"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'P'</span><span class=cF0>:
|
||
|
<a name="l421"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l422"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l423"></a> </span><span class=cFD>StrPrintFunSeg</span><span class=cF0>(tmp_buf,argv[cur_arg],len,flags);
|
||
|
<a name="l424"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>IsRaw</span><span class=cF0> || !_buf) {
|
||
|
<a name="l425"></a> </span><span class=cF5>StrPrint</span><span class=cF0>(tmp_buf2,</span><span class=cF6>"$LK,\"%s\",A=\"AD:0x%X\"$"</span><span class=cF0>,
|
||
|
<a name="l426"></a> tmp_buf,argv[cur_arg]);
|
||
|
<a name="l427"></a> </span><span class=cFD>OutStr</span><span class=cF0>(tmp_buf2,_buf,_dst,len,flags);
|
||
|
<a name="l428"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l429"></a> </span><span class=cFD>OutStr</span><span class=cF0>(tmp_buf,_buf,_dst,len,flags);
|
||
|
<a name="l430"></a> cur_arg++;
|
||
|
<a name="l431"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l432"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'d'</span><span class=cF0>:
|
||
|
<a name="l433"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l434"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l435"></a> m=argv[cur_arg++];
|
||
|
<a name="l436"></a> </span><span class=cF1>if</span><span class=cF0> (m</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0><0) {
|
||
|
<a name="l437"></a> flags|=</span><span class=cF3>PRTF_NEG</span><span class=cF0>;
|
||
|
<a name="l438"></a> m=-m;
|
||
|
<a name="l439"></a> }
|
||
|
<a name="l440"></a>sp_out_dec:
|
||
|
<a name="l441"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_AUX_FMT_NUM</span><span class=cF0>) {
|
||
|
<a name="l442"></a> </span><span class=cF1>if</span><span class=cF0> (!len) len=12;
|
||
|
<a name="l443"></a> d=m;
|
||
|
<a name="l444"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_eng;
|
||
|
<a name="l445"></a> }
|
||
|
<a name="l446"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_COMMA</span><span class=cF0>) {
|
||
|
<a name="l447"></a> comma_fmt_cnt=comma_cnt=3;
|
||
|
<a name="l448"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l449"></a> tmp_buf[k++]=</span><span class=cF5>ModU64</span><span class=cF0>(&m,10)+</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l450"></a> </span><span class=cF1>if</span><span class=cF0> (!m) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l451"></a> </span><span class=cF1>if</span><span class=cF0> (!--comma_cnt) {
|
||
|
<a name="l452"></a> tmp_buf[k++]=</span><span class=cF6>','</span><span class=cF0>;
|
||
|
<a name="l453"></a> comma_cnt=3;
|
||
|
<a name="l454"></a> }
|
||
|
<a name="l455"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l456"></a>sp_out_comma_num:
|
||
|
<a name="l457"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l458"></a> i=1;
|
||
|
<a name="l459"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l460"></a> i=0;
|
||
|
<a name="l461"></a> </span><span class=cF1>if</span><span class=cF0> (len<0)
|
||
|
<a name="l462"></a> len=0;
|
||
|
<a name="l463"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF0> && k+i>len)
|
||
|
<a name="l464"></a> k=len-i;
|
||
|
<a name="l465"></a> </span><span class=cF1>if</span><span class=cF0> (k<0)
|
||
|
<a name="l466"></a> k=0;
|
||
|
<a name="l467"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_PAD_ZERO</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l468"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l469"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'-'</span><span class=cF0>,_buf);
|
||
|
<a name="l470"></a> comma_cnt=(len-k-i+comma_fmt_cnt-comma_cnt+1)
|
||
|
<a name="l471"></a> %(comma_fmt_cnt+1)+1;
|
||
|
<a name="l472"></a> </span><span class=cF1>for</span><span class=cF0> (;i<len-k;i++) {
|
||
|
<a name="l473"></a> </span><span class=cF1>if</span><span class=cF0> (!--comma_cnt) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l474"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>','</span><span class=cF0>,_buf);
|
||
|
<a name="l475"></a> comma_cnt=comma_fmt_cnt;
|
||
|
<a name="l476"></a> </span><span class=cF1>if</span><span class=cF0> (++i>=len-k)
|
||
|
<a name="l477"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l478"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l479"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'0'</span><span class=cF0>,_buf);
|
||
|
<a name="l480"></a> }
|
||
|
<a name="l481"></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="l482"></a> </span><span class=cF1>for</span><span class=cF0> (;i<len-k;i++)
|
||
|
<a name="l483"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF3>CH_SPACE</span><span class=cF0>,_buf);
|
||
|
<a name="l484"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l485"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'-'</span><span class=cF0>,_buf);
|
||
|
<a name="l486"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l487"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l488"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l489"></a> tmp_buf[k++]=</span><span class=cF5>ModU64</span><span class=cF0>(&m,10)+</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l490"></a> </span><span class=cF1>if</span><span class=cF0> (!m) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l491"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l492"></a>sp_out_num:
|
||
|
<a name="l493"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l494"></a> i=1;
|
||
|
<a name="l495"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l496"></a> i=0;
|
||
|
<a name="l497"></a> </span><span class=cF1>if</span><span class=cF0> (len<0)
|
||
|
<a name="l498"></a> len=0;
|
||
|
<a name="l499"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF0> && k+i>len)
|
||
|
<a name="l500"></a> k=len-i;
|
||
|
<a name="l501"></a> </span><span class=cF1>if</span><span class=cF0> (k<0)
|
||
|
<a name="l502"></a> k=0;
|
||
|
<a name="l503"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_PAD_ZERO</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l504"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l505"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'-'</span><span class=cF0>,_buf);
|
||
|
<a name="l506"></a> </span><span class=cF1>for</span><span class=cF0> (;i<len-k;i++)
|
||
|
<a name="l507"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'0'</span><span class=cF0>,_buf);
|
||
|
<a name="l508"></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="l509"></a> </span><span class=cF1>for</span><span class=cF0> (;i<len-k;i++)
|
||
|
<a name="l510"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF3>CH_SPACE</span><span class=cF0>,_buf);
|
||
|
<a name="l511"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l512"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'-'</span><span class=cF0>,_buf);
|
||
|
<a name="l513"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l514"></a> }
|
||
|
<a name="l515"></a> </span><span class=cF1>for</span><span class=cF0> (i=k-1;i>=0;i--)
|
||
|
<a name="l516"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,tmp_buf[i],_buf);
|
||
|
<a name="l517"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l518"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'u'</span><span class=cF0>:
|
||
|
<a name="l519"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l520"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l521"></a> m=argv[cur_arg++];
|
||
|
<a name="l522"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_dec;
|
||
|
<a name="l523"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'f'</span><span class=cF0>:
|
||
|
<a name="l524"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l525"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l526"></a> d=argv[cur_arg++](</span><span class=cF1>F64</span><span class=cF0>);
|
||
|
<a name="l527"></a> </span><span class=cF1>if</span><span class=cF0> (d<0) {
|
||
|
<a name="l528"></a> flags|=</span><span class=cF3>PRTF_NEG</span><span class=cF0>;
|
||
|
<a name="l529"></a> d=-d;
|
||
|
<a name="l530"></a> }
|
||
|
<a name="l531"></a>
|
||
|
<a name="l532"></a> </span><span class=cF1>if</span><span class=cF0> (d==</span><span class=cF3>inf</span><span class=cF0>) {
|
||
|
<a name="l533"></a>sp_out_inf:
|
||
|
<a name="l534"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l535"></a> i=1;
|
||
|
<a name="l536"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l537"></a> i=0;
|
||
|
<a name="l538"></a> k=1;
|
||
|
<a name="l539"></a> </span><span class=cF1>if</span><span class=cF0> (len<0)
|
||
|
<a name="l540"></a> len=0;
|
||
|
<a name="l541"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF0> && k+i>len)
|
||
|
<a name="l542"></a> k=len-i;
|
||
|
<a name="l543"></a> </span><span class=cF1>if</span><span class=cF0> (k<0)
|
||
|
<a name="l544"></a> k=0;
|
||
|
<a name="l545"></a> </span><span class=cF1>for</span><span class=cF0> (;i<len-k;i++)
|
||
|
<a name="l546"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF3>CH_SPACE</span><span class=cF0>,_buf);
|
||
|
<a name="l547"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l548"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'-'</span><span class=cF0>,_buf);
|
||
|
<a name="l549"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<k;i++)
|
||
|
<a name="l550"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'inf'</span><span class=cF0>,_buf);
|
||
|
<a name="l551"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l552"></a> }
|
||
|
<a name="l553"></a>
|
||
|
<a name="l554"></a> sp_out_f:
|
||
|
<a name="l555"></a> </span><span class=cF1>if</span><span class=cF0> (dec_len<0)
|
||
|
<a name="l556"></a> dec_len=0;
|
||
|
<a name="l557"></a> n=</span><span class=cF5>Log10</span><span class=cF0>(d);
|
||
|
<a name="l558"></a> </span><span class=cF1>if</span><span class=cF0> (i=dec_len) {
|
||
|
<a name="l559"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_COMMA</span><span class=cF0>)
|
||
|
<a name="l560"></a> i=i-i/4;
|
||
|
<a name="l561"></a> </span><span class=cF1>if</span><span class=cF0> (n+i>17) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l562"></a> n+=i-17;
|
||
|
<a name="l563"></a> d*=</span><span class=cF5>Pow10I64</span><span class=cF0>(i-n);
|
||
|
<a name="l564"></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="l565"></a> n=0;
|
||
|
<a name="l566"></a> d*=</span><span class=cF5>Pow10I64</span><span class=cF0>(i);
|
||
|
<a name="l567"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l568"></a> i=dec_len;
|
||
|
<a name="l569"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (n>17) {
|
||
|
<a name="l570"></a> n-=17;
|
||
|
<a name="l571"></a> d*=</span><span class=cF5>Pow10I64</span><span class=cF0>(-n);
|
||
|
<a name="l572"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l573"></a> n=0;
|
||
|
<a name="l574"></a>
|
||
|
<a name="l575"></a> m=</span><span class=cF5>Round</span><span class=cF0>(d);
|
||
|
<a name="l576"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_COMMA</span><span class=cF0>) {
|
||
|
<a name="l577"></a> comma_cnt=i&3;
|
||
|
<a name="l578"></a> </span><span class=cF1>while</span><span class=cF0> (i-- && k<TMP_BUF_LEN-SLOP) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l579"></a> </span><span class=cF1>if</span><span class=cF0> (i>2 && !comma_cnt--) {
|
||
|
<a name="l580"></a> tmp_buf[k++]=</span><span class=cF6>','</span><span class=cF0>;
|
||
|
<a name="l581"></a> comma_cnt=2;
|
||
|
<a name="l582"></a> </span><span class=cF1>if</span><span class=cF0> (!--i) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l583"></a> }
|
||
|
<a name="l584"></a> </span><span class=cF1>if</span><span class=cF0> (n) {
|
||
|
<a name="l585"></a> n--;
|
||
|
<a name="l586"></a> tmp_buf[k++]=</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l587"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l588"></a> tmp_buf[k++]=</span><span class=cF5>ModU64</span><span class=cF0>(&m,10)+</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l589"></a> </span><span class=cF1>if</span><span class=cF0> (!i) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l590"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l591"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l592"></a> </span><span class=cF1>while</span><span class=cF0> (i-- && k<TMP_BUF_LEN-SLOP) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l593"></a> </span><span class=cF1>if</span><span class=cF0> (n) {
|
||
|
<a name="l594"></a> n--;
|
||
|
<a name="l595"></a> tmp_buf[k++]=</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l596"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l597"></a> tmp_buf[k++]=</span><span class=cF5>ModU64</span><span class=cF0>(&m,10)+</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l598"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l599"></a> }
|
||
|
<a name="l600"></a> </span><span class=cF1>if</span><span class=cF0> (dec_len)
|
||
|
<a name="l601"></a> tmp_buf[k++]=</span><span class=cF6>'.'</span><span class=cF0>;
|
||
|
<a name="l602"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_COMMA</span><span class=cF0>) {
|
||
|
<a name="l603"></a> comma_cnt=3;
|
||
|
<a name="l604"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l605"></a> </span><span class=cF1>if</span><span class=cF0> (n) {
|
||
|
<a name="l606"></a> n--;
|
||
|
<a name="l607"></a> tmp_buf[k++]=</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l608"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l609"></a> tmp_buf[k++]=</span><span class=cF5>ModU64</span><span class=cF0>(&m,10)+</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l610"></a> </span><span class=cF1>if</span><span class=cF0> (!m) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l611"></a> </span><span class=cF1>if</span><span class=cF0> (!--comma_cnt) {
|
||
|
<a name="l612"></a> tmp_buf[k++]=</span><span class=cF6>','</span><span class=cF0>;
|
||
|
<a name="l613"></a> comma_cnt=3;
|
||
|
<a name="l614"></a> }
|
||
|
<a name="l615"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l616"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l617"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l618"></a> </span><span class=cF1>if</span><span class=cF0> (n) {
|
||
|
<a name="l619"></a> n--;
|
||
|
<a name="l620"></a> tmp_buf[k++]=</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l621"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l622"></a> tmp_buf[k++]=</span><span class=cF5>ModU64</span><span class=cF0>(&m,10)+</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l623"></a> </span><span class=cF1>if</span><span class=cF0> (!m) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l624"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l625"></a> }
|
||
|
<a name="l626"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_num;
|
||
|
<a name="l627"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'e'</span><span class=cF0>:
|
||
|
<a name="l628"></a> </span><span class=cF1>if</span><span class=cF0> (!len) len=12;
|
||
|
<a name="l629"></a> flags|=</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF0>;
|
||
|
<a name="l630"></a>
|
||
|
<a name="l631"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l632"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l633"></a> d=argv[cur_arg++](</span><span class=cF1>F64</span><span class=cF0>);
|
||
|
<a name="l634"></a> </span><span class=cF1>if</span><span class=cF0> (d<0) {
|
||
|
<a name="l635"></a> flags|=</span><span class=cF3>PRTF_NEG</span><span class=cF0>;
|
||
|
<a name="l636"></a> d=-d;
|
||
|
<a name="l637"></a> }
|
||
|
<a name="l638"></a> </span><span class=cF1>if</span><span class=cF0> (d==</span><span class=cF3>inf</span><span class=cF0>) </span><span class=cF1>goto</span><span class=cF0> sp_out_inf;
|
||
|
<a name="l639"></a>
|
||
|
<a name="l640"></a> </span><span class=cF1>if</span><span class=cF0> (d)
|
||
|
<a name="l641"></a> n=</span><span class=cF5>Floor</span><span class=cF0>(</span><span class=cF5>Log10</span><span class=cF7>(</span><span class=cF0>d</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l642"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l643"></a> n=0;
|
||
|
<a name="l644"></a>sp_out_e:
|
||
|
<a name="l645"></a> d/=</span><span class=cF5>Pow10I64</span><span class=cF0>(n);
|
||
|
<a name="l646"></a>
|
||
|
<a name="l647"></a> k0=k;
|
||
|
<a name="l648"></a> </span><span class=cF1>for</span><span class=cF0> (l=0;l<2;l++) {
|
||
|
<a name="l649"></a> n0=n;
|
||
|
<a name="l650"></a> </span><span class=cF1>if</span><span class=cF0> (n<0) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l651"></a> n=-n;
|
||
|
<a name="l652"></a> flags|=</span><span class=cF3>PRTF_NEG_E</span><span class=cF0>;
|
||
|
<a name="l653"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l654"></a> flags&=~</span><span class=cF3>PRTF_NEG_E</span><span class=cF0>;
|
||
|
<a name="l655"></a>
|
||
|
<a name="l656"></a> i=3;
|
||
|
<a name="l657"></a> </span><span class=cF1>do</span><span class=cF0> tmp_buf[k++]=</span><span class=cF5>ModU64</span><span class=cF0>(&n,10)+</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l658"></a> </span><span class=cF1>while</span><span class=cF0> (n && i--);
|
||
|
<a name="l659"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG_E</span><span class=cF0>)
|
||
|
<a name="l660"></a> tmp_buf[k++]=</span><span class=cF6>'-'</span><span class=cF0>;
|
||
|
<a name="l661"></a> tmp_buf[k++]=</span><span class=cF6>'e'</span><span class=cF0>;
|
||
|
<a name="l662"></a> dec_len=len-k-2;
|
||
|
<a name="l663"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l664"></a> dec_len--;
|
||
|
<a name="l665"></a>
|
||
|
<a name="l666"></a> </span><span class=cF1>if</span><span class=cF0> (d) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l667"></a> d1=d+</span><span class=cF5>Pow10I64</span><span class=cF0>(-dec_len)/2;
|
||
|
<a name="l668"></a> </span><span class=cF1>if</span><span class=cF0> (d1<1.0) {
|
||
|
<a name="l669"></a> d*=10;
|
||
|
<a name="l670"></a> n=n0-1;
|
||
|
<a name="l671"></a> k=k0;
|
||
|
<a name="l672"></a> } </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (d1>=10) {
|
||
|
<a name="l673"></a> d/=10;
|
||
|
<a name="l674"></a> n=n0+1;
|
||
|
<a name="l675"></a> k=k0;
|
||
|
<a name="l676"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l677"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l678"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l679"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l680"></a> }
|
||
|
<a name="l681"></a>
|
||
|
<a name="l682"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_f;
|
||
|
<a name="l683"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'g'</span><span class=cF0>:
|
||
|
<a name="l684"></a> </span><span class=cF1>if</span><span class=cF0> (!len) len=12;
|
||
|
<a name="l685"></a> flags|=</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF0>;
|
||
|
<a name="l686"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l687"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l688"></a> d=argv[cur_arg++](</span><span class=cF1>F64</span><span class=cF0>);
|
||
|
<a name="l689"></a> </span><span class=cF1>if</span><span class=cF0> (d<0) {
|
||
|
<a name="l690"></a> flags|=</span><span class=cF3>PRTF_NEG</span><span class=cF0>;
|
||
|
<a name="l691"></a> d=-d;
|
||
|
<a name="l692"></a> }
|
||
|
<a name="l693"></a> </span><span class=cF1>if</span><span class=cF0> (d==</span><span class=cF3>inf</span><span class=cF0>) </span><span class=cF1>goto</span><span class=cF0> sp_out_inf;
|
||
|
<a name="l694"></a> </span><span class=cF1>if</span><span class=cF0> (d)
|
||
|
<a name="l695"></a> n=</span><span class=cF5>Floor</span><span class=cF0>(</span><span class=cF5>Log10</span><span class=cF7>(</span><span class=cF0>d</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l696"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l697"></a> n=0;
|
||
|
<a name="l698"></a> </span><span class=cF1>if</span><span class=cF0> (n>=len-1-dec_len || n<-</span><span class=cF7>(</span><span class=cF0>dec_len-1</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l699"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_e;
|
||
|
<a name="l700"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l701"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_f;
|
||
|
<a name="l702"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'n'</span><span class=cF0>:
|
||
|
<a name="l703"></a> </span><span class=cF1>if</span><span class=cF0> (!len) len=12;
|
||
|
<a name="l704"></a> flags|=</span><span class=cF3>PRTF_TRUNCATE</span><span class=cF0>;
|
||
|
<a name="l705"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l706"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l707"></a> d=argv[cur_arg++](</span><span class=cF1>F64</span><span class=cF0>);
|
||
|
<a name="l708"></a> </span><span class=cF1>if</span><span class=cF0> (d<0) {
|
||
|
<a name="l709"></a> flags|=</span><span class=cF3>PRTF_NEG</span><span class=cF0>;
|
||
|
<a name="l710"></a> d=-d;
|
||
|
<a name="l711"></a> }
|
||
|
<a name="l712"></a>sp_out_eng: </span><span class=cF2>//Engineering notation</span><span class=cF0>
|
||
|
<a name="l713"></a> </span><span class=cF1>if</span><span class=cF0> (d==</span><span class=cF3>inf</span><span class=cF0>) </span><span class=cF1>goto</span><span class=cF0> sp_out_inf;
|
||
|
<a name="l714"></a> </span><span class=cF1>if</span><span class=cF0> (d)
|
||
|
<a name="l715"></a> n=</span><span class=cF5>FloorI64</span><span class=cF0>(</span><span class=cF5>Floor</span><span class=cF7>(</span><span class=cF5>Log10</span><span class=cF0>(d)</span><span class=cF7>)</span><span class=cF0>,3);
|
||
|
<a name="l716"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l717"></a> n=0;
|
||
|
<a name="l718"></a> d/=</span><span class=cF5>Pow10I64</span><span class=cF0>(n);
|
||
|
<a name="l719"></a>
|
||
|
<a name="l720"></a> </span><span class=cF1>if</span><span class=cF0> (n<0) {
|
||
|
<a name="l721"></a> n=-n;
|
||
|
<a name="l722"></a> flags|=</span><span class=cF3>PRTF_NEG_E</span><span class=cF0>;
|
||
|
<a name="l723"></a> }
|
||
|
<a name="l724"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_AUX_FMT_NUM</span><span class=cF0> && -24<=n<=24) {
|
||
|
<a name="l725"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_QUESTION</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l726"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG_E</span><span class=cF0>)
|
||
|
<a name="l727"></a> i=-n/3;
|
||
|
<a name="l728"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l729"></a> i=n/3;
|
||
|
<a name="l730"></a> j=0;
|
||
|
<a name="l731"></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="l732"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG_E</span><span class=cF0>)
|
||
|
<a name="l733"></a> j=-n-aux_fmt_num;
|
||
|
<a name="l734"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l735"></a> j=n-aux_fmt_num;
|
||
|
<a name="l736"></a> d*=</span><span class=cF5>Pow10I64</span><span class=cF0>(j);
|
||
|
<a name="l737"></a> i=aux_fmt_num/3;
|
||
|
<a name="l738"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l739"></a> </span><span class=cF1>if</span><span class=cF0> (i<0)
|
||
|
<a name="l740"></a> tmp_buf[k++]=</span><span class=cFD>sys_neg_pows_lets</span><span class=cF0>[-i];
|
||
|
<a name="l741"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (i>0)
|
||
|
<a name="l742"></a> tmp_buf[k++]=</span><span class=cFD>sys_pos_pows_lets</span><span class=cF0>[i];
|
||
|
<a name="l743"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (len!=0)
|
||
|
<a name="l744"></a> tmp_buf[k++]=</span><span class=cF3>CH_SPACE</span><span class=cF0>;
|
||
|
<a name="l745"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>flags&</span><span class=cF3>PRTF_DECIMAL</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l746"></a> dec_len=len-k-2;
|
||
|
<a name="l747"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l748"></a> dec_len--;
|
||
|
<a name="l749"></a> </span><span class=cF1>if</span><span class=cF0> (j>0) {
|
||
|
<a name="l750"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_COMMA</span><span class=cF0>)
|
||
|
<a name="l751"></a> dec_len-=4*j/3;
|
||
|
<a name="l752"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l753"></a> dec_len-=j;
|
||
|
<a name="l754"></a> }
|
||
|
<a name="l755"></a> d1=d+</span><span class=cF5>Pow10I64</span><span class=cF0>(-dec_len+1)/2;
|
||
|
<a name="l756"></a> </span><span class=cF1>if</span><span class=cF0> (d1>=10) {
|
||
|
<a name="l757"></a> dec_len--;
|
||
|
<a name="l758"></a> </span><span class=cF1>if</span><span class=cF0> (d1>=100)
|
||
|
<a name="l759"></a> dec_len--;
|
||
|
<a name="l760"></a> }
|
||
|
<a name="l761"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l762"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l763"></a> i=3;
|
||
|
<a name="l764"></a> </span><span class=cF1>do</span><span class=cF0> tmp_buf[k++]=</span><span class=cF5>ModU64</span><span class=cF0>(&n,10)+</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l765"></a> </span><span class=cF1>while</span><span class=cF0> (n && i--);
|
||
|
<a name="l766"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG_E</span><span class=cF0>)
|
||
|
<a name="l767"></a> tmp_buf[k++]=</span><span class=cF6>'-'</span><span class=cF0>;
|
||
|
<a name="l768"></a> tmp_buf[k++]=</span><span class=cF6>'e'</span><span class=cF0>;
|
||
|
<a name="l769"></a> </span><span class=cF1>if</span><span class=cF0> (!dec_len) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l770"></a> dec_len=len-k-2;
|
||
|
<a name="l771"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_NEG</span><span class=cF0>)
|
||
|
<a name="l772"></a> dec_len--;
|
||
|
<a name="l773"></a> d1=d+</span><span class=cF5>Pow10I64</span><span class=cF0>(-dec_len+1)/2;
|
||
|
<a name="l774"></a> </span><span class=cF1>if</span><span class=cF0> (d1>=10) {
|
||
|
<a name="l775"></a> dec_len--;
|
||
|
<a name="l776"></a> </span><span class=cF1>if</span><span class=cF0> (d1>=100)
|
||
|
<a name="l777"></a> dec_len--;
|
||
|
<a name="l778"></a> }
|
||
|
<a name="l779"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l780"></a> }
|
||
|
<a name="l781"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_COMMA</span><span class=cF0>) {
|
||
|
<a name="l782"></a> </span><span class=cF1>if</span><span class=cF0> (len && dec_len>0 && !</span><span class=cF7>(</span><span class=cF0>dec_len&3</span><span class=cF7>)</span><span class=cF0>)
|
||
|
<a name="l783"></a> tmp_buf[k++]=</span><span class=cF6>','</span><span class=cF0>;
|
||
|
<a name="l784"></a> dec_len-=dec_len/4;
|
||
|
<a name="l785"></a> }
|
||
|
<a name="l786"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_f;
|
||
|
<a name="l787"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'X'</span><span class=cF0>:
|
||
|
<a name="l788"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l789"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l790"></a> m=argv[cur_arg++];
|
||
|
<a name="l791"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_COMMA</span><span class=cF0>) {
|
||
|
<a name="l792"></a> comma_fmt_cnt=comma_cnt=4;
|
||
|
<a name="l793"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l794"></a> tmp_buf[k]= m&15 +</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l795"></a> </span><span class=cF1>if</span><span class=cF0> (tmp_buf[k]></span><span class=cF6>'9'</span><span class=cF0>) tmp_buf[k]+=</span><span class=cF6>'A'</span><span class=cF0>-0x3A;
|
||
|
<a name="l796"></a> k++;
|
||
|
<a name="l797"></a> m>>=4;
|
||
|
<a name="l798"></a> </span><span class=cF1>if</span><span class=cF0> (!m) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l799"></a> </span><span class=cF1>if</span><span class=cF0> (!--comma_cnt) {
|
||
|
<a name="l800"></a> tmp_buf[k++]=</span><span class=cF6>','</span><span class=cF0>;
|
||
|
<a name="l801"></a> comma_cnt=4;
|
||
|
<a name="l802"></a> }
|
||
|
<a name="l803"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l804"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_comma_num;
|
||
|
<a name="l805"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l806"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l807"></a> tmp_buf[k]= m&15 +</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l808"></a> </span><span class=cF1>if</span><span class=cF0> (tmp_buf[k]></span><span class=cF6>'9'</span><span class=cF0>) tmp_buf[k]+=</span><span class=cF6>'A'</span><span class=cF0>-0x3A;
|
||
|
<a name="l809"></a> k++;
|
||
|
<a name="l810"></a> m>>=4;
|
||
|
<a name="l811"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (m && k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l812"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_num;
|
||
|
<a name="l813"></a> }
|
||
|
<a name="l814"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'x'</span><span class=cF0>:
|
||
|
<a name="l815"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l816"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l817"></a> m=argv[cur_arg++];
|
||
|
<a name="l818"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_COMMA</span><span class=cF0>) {
|
||
|
<a name="l819"></a> comma_fmt_cnt=comma_cnt=4;
|
||
|
<a name="l820"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l821"></a> tmp_buf[k]= m&15 +</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l822"></a> </span><span class=cF1>if</span><span class=cF0> (tmp_buf[k]></span><span class=cF6>'9'</span><span class=cF0>) tmp_buf[k]+=</span><span class=cF6>'a'</span><span class=cF0>-0x3A;
|
||
|
<a name="l823"></a> k++;
|
||
|
<a name="l824"></a> m>>=4;
|
||
|
<a name="l825"></a> </span><span class=cF1>if</span><span class=cF0> (!m) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l826"></a> </span><span class=cF1>if</span><span class=cF0> (!--comma_cnt) {
|
||
|
<a name="l827"></a> tmp_buf[k++]=</span><span class=cF6>','</span><span class=cF0>;
|
||
|
<a name="l828"></a> comma_cnt=4;
|
||
|
<a name="l829"></a> }
|
||
|
<a name="l830"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l831"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_comma_num;
|
||
|
<a name="l832"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l833"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l834"></a> tmp_buf[k]= m&15 +</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l835"></a> </span><span class=cF1>if</span><span class=cF0> (tmp_buf[k]></span><span class=cF6>'9'</span><span class=cF0>) tmp_buf[k]+=</span><span class=cF6>'a'</span><span class=cF0>-0x3A;
|
||
|
<a name="l836"></a> k++;
|
||
|
<a name="l837"></a> m>>=4;
|
||
|
<a name="l838"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (m && k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l839"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_num;
|
||
|
<a name="l840"></a> }
|
||
|
<a name="l841"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'b'</span><span class=cF0>:
|
||
|
<a name="l842"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'B'</span><span class=cF0>:
|
||
|
<a name="l843"></a> </span><span class=cF1>if</span><span class=cF0> (cur_arg>=argc)
|
||
|
<a name="l844"></a> </span><span class=cF5>throw</span><span class=cF0>(</span><span class=cF6>'StrPrint'</span><span class=cF0>);
|
||
|
<a name="l845"></a> m=argv[cur_arg++];
|
||
|
<a name="l846"></a> </span><span class=cF1>if</span><span class=cF0> (flags&</span><span class=cF3>PRTF_COMMA</span><span class=cF0>) {
|
||
|
<a name="l847"></a> comma_fmt_cnt=comma_cnt=4;
|
||
|
<a name="l848"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l849"></a> tmp_buf[k++]= m&1 +</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l850"></a> m>>=1;
|
||
|
<a name="l851"></a> </span><span class=cF1>if</span><span class=cF0> (!m) </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l852"></a> </span><span class=cF1>if</span><span class=cF0> (!--comma_cnt) {
|
||
|
<a name="l853"></a> tmp_buf[k++]=</span><span class=cF6>','</span><span class=cF0>;
|
||
|
<a name="l854"></a> comma_cnt=4;
|
||
|
<a name="l855"></a> }
|
||
|
<a name="l856"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l857"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_comma_num;
|
||
|
<a name="l858"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
||
|
<a name="l859"></a> </span><span class=cF1>do</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l860"></a> tmp_buf[k++]= m&1 +</span><span class=cF6>'0'</span><span class=cF0>;
|
||
|
<a name="l861"></a> m>>=1;
|
||
|
<a name="l862"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>while</span><span class=cF0> (m && k<TMP_BUF_LEN-SLOP);
|
||
|
<a name="l863"></a> </span><span class=cF1>goto</span><span class=cF0> sp_out_num;
|
||
|
<a name="l864"></a> }
|
||
|
<a name="l865"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'%'</span><span class=cF0>:
|
||
|
<a name="l866"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,</span><span class=cF6>'%'</span><span class=cF0>,_buf);
|
||
|
<a name="l867"></a> </span><span class=cF1>break</span><span class=cF0>;
|
||
|
<a name="l868"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l869"></a> } </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l870"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,ch,_buf);
|
||
|
<a name="l871"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l872"></a> </span><span class=cFD>SPutChar</span><span class=cF0>(_dst,0,_buf);
|
||
|
<a name="l873"></a> </span><span class=cF1>return</span><span class=cF0> buf;
|
||
|
<a name="l874"></a>}
|
||
|
<a name="l875"></a>
|
||
|
<a name="l876"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>StrPrint</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *dst,</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
|
||
|
<a name="l877"></a>{</span><span class=cF2>//See </span><a href="/Wb/Kernel/StrPrint.HC.HTML#l208"><span class=cF4>StrPrintJoin</span></a><span class=cF2>().</span><span class=cF0>
|
||
|
<a name="l878"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrPrintJoin</span><span class=cF0>(dst,fmt,argc,argv);
|
||
|
<a name="l879"></a>}
|
||
|
<a name="l880"></a>
|
||
|
<a name="l881"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>CatPrint</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *_dst,</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
|
||
|
<a name="l882"></a>{</span><span class=cF2>//StrCat(). See </span><a href="/Wb/Kernel/StrPrint.HC.HTML#l208"><span class=cF4>StrPrintJoin</span></a><span class=cF2>().</span><span class=cF0>
|
||
|
<a name="l883"></a> </span><span class=cF1>U8</span><span class=cF0> *dst=_dst;
|
||
|
<a name="l884"></a> </span><span class=cF1>while</span><span class=cF0> (*dst)
|
||
|
<a name="l885"></a> dst++;
|
||
|
<a name="l886"></a> </span><span class=cF5>StrPrintJoin</span><span class=cF0>(dst,fmt,argc,argv);
|
||
|
<a name="l887"></a> </span><span class=cF1>return</span><span class=cF0> _dst;
|
||
|
<a name="l888"></a>}
|
||
|
<a name="l889"></a>
|
||
|
<a name="l890"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>Print</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
|
||
|
<a name="l891"></a>{</span><span class=cF2>//</span><a href="/Wb/Doc/Print.DD.HTML#l1"><span class=cF4>Print("") Fmt Strings</span></a><span class=cF2>. See </span><a href="/Wb/Kernel/StrPrint.HC.HTML#l208"><span class=cF4>StrPrintJoin</span></a><span class=cF2>().</span><span class=cF0>
|
||
|
<a name="l892"></a></span><span class=cF2>//Don't use this. </span><a href="/Wb/Doc/HolyC.DD.HTML#l48"><span class=cF4>See Print() shortcut.</span></a><span class=cF0>
|
||
|
<a name="l893"></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="l894"></a> </span><span class=cF5>PutS</span><span class=cF0>(buf);</span><span class=cF2>//Don't use PutS(). </span><a href="/Wb/Doc/HolyC.DD.HTML#l48"><span class=cF4>See Print() shortcut.</span></a><span class=cF0>
|
||
|
<a name="l895"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
||
|
<a name="l896"></a>}
|
||
|
<a name="l897"></a>
|
||
|
<a name="l898"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
|
||
|
<a name="l899"></a>{</span><span class=cF2>//MAlloc StrPrint. See </span><a href="/Wb/Kernel/StrPrint.HC.HTML#l208"><span class=cF4>StrPrintJoin</span></a><span class=cF2>().</span><span class=cF0>
|
||
|
<a name="l900"></a> </span><span class=cF1>U8</span><span class=cF0> *res,*buf=</span><span class=cF5>StrPrintJoin</span><span class=cF0>(</span><span class=cF3>NULL</span><span class=cF0>,fmt,argc,argv);
|
||
|
<a name="l901"></a> res=</span><span class=cF5>StrNew</span><span class=cF0>(buf);
|
||
|
<a name="l902"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
||
|
<a name="l903"></a> </span><span class=cF1>return</span><span class=cF0> res;
|
||
|
<a name="l904"></a>}
|
||
|
<a name="l905"></a>
|
||
|
<a name="l906"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>PrintErr</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
|
||
|
<a name="l907"></a>{</span><span class=cF2>//Print "Err:" and msg in blinking red.</span><span class=cF0>
|
||
|
<a name="l908"></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="l909"></a> </span><span class=cF5>GetOutOfDollar</span><span class=cF0>;
|
||
|
<a name="l910"></a> </span><span class=cF6>"%,p %,p %,p %,p "</span><span class=cF0> </span><span class=cF3>ST_ERR_ST</span><span class=cF0> </span><span class=cF6>"%s"</span><span class=cF0>,</span><span class=cF5>Caller</span><span class=cF0>,</span><span class=cF5>Caller</span><span class=cF0>(2),</span><span class=cF5>Caller</span><span class=cF0>(3),</span><span class=cF5>Caller</span><span class=cF0>(4),buf;
|
||
|
<a name="l911"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
||
|
<a name="l912"></a>}
|
||
|
<a name="l913"></a>
|
||
|
<a name="l914"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>PrintWarn</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *fmt,...)
|
||
|
<a name="l915"></a>{</span><span class=cF2>//Print "Warn:" and msg in blinking red.</span><span class=cF0>
|
||
|
<a name="l916"></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="l917"></a> </span><span class=cF5>GetOutOfDollar</span><span class=cF0>;
|
||
|
<a name="l918"></a> </span><span class=cF6>"%,p %,p %,p %,p "</span><span class=cF0> </span><span class=cF3>ST_WARN_ST</span><span class=cF0> </span><span class=cF6>"%s"</span><span class=cF0>,</span><span class=cF5>Caller</span><span class=cF0>,</span><span class=cF5>Caller</span><span class=cF0>(2),</span><span class=cF5>Caller</span><span class=cF0>(3),</span><span class=cF5>Caller</span><span class=cF0>(4),buf;
|
||
|
<a name="l919"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
||
|
<a name="l920"></a>}
|
||
|
</span></pre></body>
|
||
|
</html>
|