ardupilot/libraries/doc/html/vprintf_8cpp_source.html

561 lines
60 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>ArduPilot Libraries: vprintf.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.7.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul class="tablist">
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<h1>vprintf.cpp</h1> </div>
</div>
<div class="contents">
<a href="vprintf_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// -*- Mode: C++; c-basic-offset: 8; indent-tabs-mode: nil -*-</span>
<a name="l00002"></a>00002 <span class="comment">/*</span>
<a name="l00003"></a>00003 <span class="comment"> Adapted from the avr-libc vfprintf:</span>
<a name="l00004"></a>00004 <span class="comment"></span>
<a name="l00005"></a>00005 <span class="comment"> Copyright (c) 2002, Alexander Popov (sasho@vip.bg)</span>
<a name="l00006"></a>00006 <span class="comment"> Copyright (c) 2002,2004,2005 Joerg Wunsch</span>
<a name="l00007"></a>00007 <span class="comment"> Copyright (c) 2005, Helmut Wallner</span>
<a name="l00008"></a>00008 <span class="comment"> Copyright (c) 2007, Dmitry Xmelkov</span>
<a name="l00009"></a>00009 <span class="comment"> All rights reserved.</span>
<a name="l00010"></a>00010 <span class="comment"></span>
<a name="l00011"></a>00011 <span class="comment"> Redistribution and use in source and binary forms, with or without</span>
<a name="l00012"></a>00012 <span class="comment"> modification, are permitted provided that the following conditions are met:</span>
<a name="l00013"></a>00013 <span class="comment"></span>
<a name="l00014"></a>00014 <span class="comment"> * Redistributions of source code must retain the above copyright</span>
<a name="l00015"></a>00015 <span class="comment"> notice, this list of conditions and the following disclaimer.</span>
<a name="l00016"></a>00016 <span class="comment"> * Redistributions in binary form must reproduce the above copyright</span>
<a name="l00017"></a>00017 <span class="comment"> notice, this list of conditions and the following disclaimer in</span>
<a name="l00018"></a>00018 <span class="comment"> the documentation and/or other materials provided with the</span>
<a name="l00019"></a>00019 <span class="comment"> distribution.</span>
<a name="l00020"></a>00020 <span class="comment"> * Neither the name of the copyright holders nor the names of</span>
<a name="l00021"></a>00021 <span class="comment"> contributors may be used to endorse or promote products derived</span>
<a name="l00022"></a>00022 <span class="comment"> from this software without specific prior written permission.</span>
<a name="l00023"></a>00023 <span class="comment"></span>
<a name="l00024"></a>00024 <span class="comment"> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;</span>
<a name="l00025"></a>00025 <span class="comment"> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span>
<a name="l00026"></a>00026 <span class="comment"> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE</span>
<a name="l00027"></a>00027 <span class="comment"> ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE</span>
<a name="l00028"></a>00028 <span class="comment"> LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR</span>
<a name="l00029"></a>00029 <span class="comment"> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF</span>
<a name="l00030"></a>00030 <span class="comment"> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS</span>
<a name="l00031"></a>00031 <span class="comment"> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN</span>
<a name="l00032"></a>00032 <span class="comment"> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)</span>
<a name="l00033"></a>00033 <span class="comment"> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE</span>
<a name="l00034"></a>00034 <span class="comment"> POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00035"></a>00035 <span class="comment">*/</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="comment">/* From: Id: printf_p_new.c,v 1.1.1.9 2002/10/15 20:10:28 joerg_wunsch Exp */</span>
<a name="l00038"></a>00038 <span class="comment">/* $Id: vfprintf.c,v 1.18.2.1 2009/04/01 23:12:06 arcanum Exp $ */</span>
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="preprocessor">#include &quot;<a class="code" href="_better_stream_8h.html">BetterStream.h</a>&quot;</span>
<a name="l00041"></a>00041
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;avr/pgmspace.h&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;stdarg.h&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00045"></a>00045 <span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00046"></a>00046 <span class="preprocessor">#include &quot;<a class="code" href="ftoa__engine_8h.html">ftoa_engine.h</a>&quot;</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include &quot;<a class="code" href="ntz_8h.html">ntz.h</a>&quot;</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include &quot;<a class="code" href="xtoa__fast_8h.html">xtoa_fast.h</a>&quot;</span>
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050
<a name="l00051"></a>00051 <span class="comment">// workaround for GCC bug c++/34734</span>
<a name="l00052"></a>00052 <span class="preprocessor">#undef PROGMEM </span>
<a name="l00053"></a><a class="code" href="vprintf_8cpp.html#a75acaba9e781937468d0911423bc0c35">00053</a> <span class="preprocessor"></span><span class="preprocessor">#define PROGMEM __attribute__(( section(&quot;.progmem.data&quot;) )) </span>
<a name="l00054"></a>00054 <span class="preprocessor"></span><span class="preprocessor">#undef PSTR </span>
<a name="l00055"></a><a class="code" href="vprintf_8cpp.html#a05ca900ebf7cd121be73c654d9ccb3eb">00055</a> <span class="preprocessor"></span><span class="preprocessor">#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &amp;__c[0];})) </span>
<a name="l00056"></a>00056 <span class="preprocessor"></span>
<a name="l00057"></a><a class="code" href="vprintf_8cpp.html#a594135840cf97491063107face7966e4">00057</a> <span class="preprocessor">#define GETBYTE(flag, mask, pnt) ({ \</span>
<a name="l00058"></a>00058 <span class="preprocessor"> unsigned char __c; \</span>
<a name="l00059"></a>00059 <span class="preprocessor"> asm ( \</span>
<a name="l00060"></a>00060 <span class="preprocessor"> &quot;sbrc %2,%3 \n\t&quot; \</span>
<a name="l00061"></a>00061 <span class="preprocessor"> &quot;lpm %0,Z+ \n\t&quot; \</span>
<a name="l00062"></a>00062 <span class="preprocessor"> &quot;sbrs %2,%3 \n\t&quot; \</span>
<a name="l00063"></a>00063 <span class="preprocessor"> &quot;ld %0,Z+ &quot; \</span>
<a name="l00064"></a>00064 <span class="preprocessor"> : &quot;=r&quot; (__c), \</span>
<a name="l00065"></a>00065 <span class="preprocessor"> &quot;+z&quot; (pnt) \</span>
<a name="l00066"></a>00066 <span class="preprocessor"> : &quot;r&quot; (flag), \</span>
<a name="l00067"></a>00067 <span class="preprocessor"> &quot;I&quot; (ntz(mask)) \</span>
<a name="l00068"></a>00068 <span class="preprocessor"> ); \</span>
<a name="l00069"></a>00069 <span class="preprocessor"> __c; \</span>
<a name="l00070"></a>00070 <span class="preprocessor"> })</span>
<a name="l00071"></a>00071 <span class="preprocessor"></span><span class="comment">/*</span>
<a name="l00072"></a>00072 <span class="comment">#define GETBYTE(flag, mask, pnt) ({ \</span>
<a name="l00073"></a>00073 <span class="comment"> unsigned char __c; \</span>
<a name="l00074"></a>00074 <span class="comment"> __c = ((flag) &amp; (mask)) \</span>
<a name="l00075"></a>00075 <span class="comment"> ? pgm_read_byte(pnt) : *pnt; \</span>
<a name="l00076"></a>00076 <span class="comment"> pnt++; \</span>
<a name="l00077"></a>00077 <span class="comment"> __c; \</span>
<a name="l00078"></a>00078 <span class="comment">})</span>
<a name="l00079"></a>00079 <span class="comment">*/</span>
<a name="l00080"></a>00080
<a name="l00081"></a><a class="code" href="vprintf_8cpp.html#aaad70046054194bb1cbe0673b3c212f2">00081</a> <span class="preprocessor">#define FL_ZFILL 0x01</span>
<a name="l00082"></a><a class="code" href="vprintf_8cpp.html#a5052dbb513e79cafd4cb51a474526318">00082</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_PLUS 0x02</span>
<a name="l00083"></a><a class="code" href="vprintf_8cpp.html#ab75bdf743821eb031641f604ef84291a">00083</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_SPACE 0x04</span>
<a name="l00084"></a><a class="code" href="vprintf_8cpp.html#af952bbf75b391b81f9fcd24834117c6d">00084</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_LPAD 0x08</span>
<a name="l00085"></a><a class="code" href="vprintf_8cpp.html#a58b1ac5446b292c77043f99558eb07cb">00085</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_ALT 0x10</span>
<a name="l00086"></a><a class="code" href="vprintf_8cpp.html#a1dec6f2986dc2f1055bfc39ed745500e">00086</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_WIDTH 0x20</span>
<a name="l00087"></a><a class="code" href="vprintf_8cpp.html#a8c134b2f4722f9b59d3851d0be28dda9">00087</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_PREC 0x40</span>
<a name="l00088"></a><a class="code" href="vprintf_8cpp.html#aba9eba8db439010ca11f2fb7607c7c6e">00088</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_LONG 0x80</span>
<a name="l00089"></a>00089 <span class="preprocessor"></span>
<a name="l00090"></a><a class="code" href="vprintf_8cpp.html#a95045f8d69f7ad062c5d2bd4b4e4b6b4">00090</a> <span class="preprocessor">#define FL_PGMSTRING FL_LONG</span>
<a name="l00091"></a><a class="code" href="vprintf_8cpp.html#a753650881115de6d78f9755bfcc777f0">00091</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_NEGATIVE FL_LONG</span>
<a name="l00092"></a>00092 <span class="preprocessor"></span>
<a name="l00093"></a><a class="code" href="vprintf_8cpp.html#a41bcbafa8f3d8487945b6a6ede5df7a2">00093</a> <span class="preprocessor">#define FL_ALTUPP FL_PLUS</span>
<a name="l00094"></a><a class="code" href="vprintf_8cpp.html#ab6ee3505eb9bc230d1d3dc2f8c83e67f">00094</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_ALTHEX FL_SPACE</span>
<a name="l00095"></a>00095 <span class="preprocessor"></span>
<a name="l00096"></a><a class="code" href="vprintf_8cpp.html#a220f13ec366247f858df3eb7962a8340">00096</a> <span class="preprocessor">#define FL_FLTUPP FL_ALT</span>
<a name="l00097"></a><a class="code" href="vprintf_8cpp.html#a4118c3d3af25daa2c39fb4aa1d5a4462">00097</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_FLTEXP FL_PREC</span>
<a name="l00098"></a><a class="code" href="vprintf_8cpp.html#a15e99332e501376914ddb0ccde08800f">00098</a> <span class="preprocessor"></span><span class="preprocessor">#define FL_FLTFIX FL_LONG</span>
<a name="l00099"></a>00099 <span class="preprocessor"></span>
<a name="l00100"></a>00100 <span class="keywordtype">void</span>
<a name="l00101"></a>00101 BetterStream::_vprintf (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> in_progmem, <span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, va_list ap)
<a name="l00102"></a>00102 {
<a name="l00103"></a>00103 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> c; <span class="comment">/* holds a char from the format string */</span>
<a name="l00104"></a>00104 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> flags;
<a name="l00105"></a>00105 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> width;
<a name="l00106"></a>00106 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> prec;
<a name="l00107"></a>00107 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> buf[11]; <span class="comment">/* size for -1 in octal, without &#39;\0&#39; */</span>
<a name="l00108"></a>00108
<a name="l00109"></a>00109 <span class="keywordflow">for</span> (;;) {
<a name="l00110"></a>00110
<a name="l00111"></a>00111 <span class="comment">/*</span>
<a name="l00112"></a>00112 <span class="comment"> * Process non-format characters</span>
<a name="l00113"></a>00113 <span class="comment"> */</span>
<a name="l00114"></a>00114 <span class="keywordflow">for</span> (;;) {
<a name="l00115"></a>00115 c = <a class="code" href="vprintf_8cpp.html#a594135840cf97491063107face7966e4">GETBYTE</a> (in_progmem, 1, fmt);
<a name="l00116"></a>00116 <span class="keywordflow">if</span> (!c) <span class="keywordflow">return</span>;
<a name="l00117"></a>00117 <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;%&#39;</span>) {
<a name="l00118"></a>00118 c = <a class="code" href="vprintf_8cpp.html#a594135840cf97491063107face7966e4">GETBYTE</a> (in_progmem, 1, fmt);
<a name="l00119"></a>00119 <span class="keywordflow">if</span> (c != <span class="charliteral">&#39;%&#39;</span>) <span class="keywordflow">break</span>;
<a name="l00120"></a>00120 }
<a name="l00121"></a>00121 <span class="comment">/* emit cr before lf to make most terminals happy */</span>
<a name="l00122"></a>00122 <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;\n&#39;</span>)
<a name="l00123"></a>00123 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39;\r&#39;</span>);
<a name="l00124"></a>00124 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(c);
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126
<a name="l00127"></a>00127 flags = 0;
<a name="l00128"></a>00128 width = 0;
<a name="l00129"></a>00129 prec = 0;
<a name="l00130"></a>00130
<a name="l00131"></a>00131 <span class="comment">/*</span>
<a name="l00132"></a>00132 <span class="comment"> * Process format adjustment characters, precision, width.</span>
<a name="l00133"></a>00133 <span class="comment"> */</span>
<a name="l00134"></a>00134 <span class="keywordflow">do</span> {
<a name="l00135"></a>00135 <span class="keywordflow">if</span> (flags &lt; <a class="code" href="vprintf_8cpp.html#a1dec6f2986dc2f1055bfc39ed745500e">FL_WIDTH</a>) {
<a name="l00136"></a>00136 <span class="keywordflow">switch</span> (c) {
<a name="l00137"></a>00137 <span class="keywordflow">case</span> <span class="charliteral">&#39;0&#39;</span>:
<a name="l00138"></a>00138 flags |= FL_ZFILL;
<a name="l00139"></a>00139 <span class="keywordflow">continue</span>;
<a name="l00140"></a>00140 <span class="keywordflow">case</span> <span class="charliteral">&#39;+&#39;</span>:
<a name="l00141"></a>00141 flags |= FL_PLUS;
<a name="l00142"></a>00142 <span class="comment">/* FALLTHROUGH */</span>
<a name="l00143"></a>00143 <span class="keywordflow">case</span> <span class="charliteral">&#39; &#39;</span>:
<a name="l00144"></a>00144 flags |= FL_SPACE;
<a name="l00145"></a>00145 <span class="keywordflow">continue</span>;
<a name="l00146"></a>00146 <span class="keywordflow">case</span> <span class="charliteral">&#39;-&#39;</span>:
<a name="l00147"></a>00147 flags |= FL_LPAD;
<a name="l00148"></a>00148 <span class="keywordflow">continue</span>;
<a name="l00149"></a>00149 <span class="keywordflow">case</span> <span class="charliteral">&#39;#&#39;</span>:
<a name="l00150"></a>00150 flags |= FL_ALT;
<a name="l00151"></a>00151 <span class="keywordflow">continue</span>;
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153 }
<a name="l00154"></a>00154
<a name="l00155"></a>00155 <span class="keywordflow">if</span> (flags &lt; <a class="code" href="vprintf_8cpp.html#aba9eba8db439010ca11f2fb7607c7c6e">FL_LONG</a>) {
<a name="l00156"></a>00156 <span class="keywordflow">if</span> (c &gt;= <span class="charliteral">&#39;0&#39;</span> &amp;&amp; c &lt;= <span class="charliteral">&#39;9&#39;</span>) {
<a name="l00157"></a>00157 c -= <span class="charliteral">&#39;0&#39;</span>;
<a name="l00158"></a>00158 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a8c134b2f4722f9b59d3851d0be28dda9">FL_PREC</a>) {
<a name="l00159"></a>00159 prec = 10*prec + c;
<a name="l00160"></a>00160 <span class="keywordflow">continue</span>;
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 width = 10*width + c;
<a name="l00163"></a>00163 flags |= FL_WIDTH;
<a name="l00164"></a>00164 <span class="keywordflow">continue</span>;
<a name="l00165"></a>00165 }
<a name="l00166"></a>00166 <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;.&#39;</span>) {
<a name="l00167"></a>00167 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a8c134b2f4722f9b59d3851d0be28dda9">FL_PREC</a>)
<a name="l00168"></a>00168 <span class="keywordflow">return</span>;
<a name="l00169"></a>00169 flags |= FL_PREC;
<a name="l00170"></a>00170 <span class="keywordflow">continue</span>;
<a name="l00171"></a>00171 }
<a name="l00172"></a>00172 <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;l&#39;</span>) {
<a name="l00173"></a>00173 flags |= FL_LONG;
<a name="l00174"></a>00174 <span class="keywordflow">continue</span>;
<a name="l00175"></a>00175 }
<a name="l00176"></a>00176 <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;h&#39;</span>)
<a name="l00177"></a>00177 <span class="keywordflow">continue</span>;
<a name="l00178"></a>00178 }
<a name="l00179"></a>00179
<a name="l00180"></a>00180 <span class="keywordflow">break</span>;
<a name="l00181"></a>00181 } <span class="keywordflow">while</span> ( (c = <a class="code" href="vprintf_8cpp.html#a594135840cf97491063107face7966e4">GETBYTE</a> (in_progmem, 1, fmt)) != 0);
<a name="l00182"></a>00182
<a name="l00183"></a>00183 <span class="comment">/*</span>
<a name="l00184"></a>00184 <span class="comment"> * Handle floating-point formats E, F, G, e, f, g.</span>
<a name="l00185"></a>00185 <span class="comment"> */</span>
<a name="l00186"></a>00186 <span class="keywordflow">if</span> (c &gt;= <span class="charliteral">&#39;E&#39;</span> &amp;&amp; c &lt;= <span class="charliteral">&#39;G&#39;</span>) {
<a name="l00187"></a>00187 flags |= FL_FLTUPP;
<a name="l00188"></a>00188 c += <span class="charliteral">&#39;e&#39;</span> - <span class="charliteral">&#39;E&#39;</span>;
<a name="l00189"></a>00189 <span class="keywordflow">goto</span> flt_oper;
<a name="l00190"></a>00190
<a name="l00191"></a>00191 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (c &gt;= <span class="charliteral">&#39;e&#39;</span> &amp;&amp; c &lt;= <span class="charliteral">&#39;g&#39;</span>) {
<a name="l00192"></a>00192
<a name="l00193"></a>00193 <span class="keywordtype">int</span> exp; <span class="comment">/* exponent of master decimal digit */</span>
<a name="l00194"></a>00194 <span class="keywordtype">int</span> n;
<a name="l00195"></a>00195 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> vtype; <span class="comment">/* result of float value parse */</span>
<a name="l00196"></a>00196 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> sign; <span class="comment">/* sign character (or 0) */</span>
<a name="l00197"></a>00197 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> ndigs;
<a name="l00198"></a>00198
<a name="l00199"></a>00199 flags &amp;= ~FL_FLTUPP;
<a name="l00200"></a>00200
<a name="l00201"></a>00201 flt_oper:
<a name="l00202"></a>00202 <span class="keywordflow">if</span> (!(flags &amp; <a class="code" href="vprintf_8cpp.html#a8c134b2f4722f9b59d3851d0be28dda9">FL_PREC</a>))
<a name="l00203"></a>00203 prec = 6;
<a name="l00204"></a>00204 flags &amp;= ~(<a class="code" href="vprintf_8cpp.html#a4118c3d3af25daa2c39fb4aa1d5a4462">FL_FLTEXP</a> | FL_FLTFIX);
<a name="l00205"></a>00205 <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;e&#39;</span>)
<a name="l00206"></a>00206 flags |= FL_FLTEXP;
<a name="l00207"></a>00207 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;f&#39;</span>)
<a name="l00208"></a>00208 flags |= FL_FLTFIX;
<a name="l00209"></a>00209 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (prec &gt; 0)
<a name="l00210"></a>00210 prec -= 1;
<a name="l00211"></a>00211
<a name="l00212"></a>00212 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a15e99332e501376914ddb0ccde08800f">FL_FLTFIX</a>) {
<a name="l00213"></a>00213 vtype = 7; <span class="comment">/* &#39;prec&#39; arg for &#39;ftoa_engine&#39; */</span>
<a name="l00214"></a>00214 ndigs = prec &lt; 60 ? prec + 1 : 60;
<a name="l00215"></a>00215 } <span class="keywordflow">else</span> {
<a name="l00216"></a>00216 <span class="keywordflow">if</span> (prec &gt; 7) prec = 7;
<a name="l00217"></a>00217 vtype = prec;
<a name="l00218"></a>00218 ndigs = 0;
<a name="l00219"></a>00219 }
<a name="l00220"></a>00220 exp = <a class="code" href="ftoa__engine_8h.html#a0700887e129ad889bdff83eac78c8797">__ftoa_engine</a> (va_arg(ap,<span class="keywordtype">double</span>), (<span class="keywordtype">char</span> *)buf, vtype, ndigs);
<a name="l00221"></a>00221 vtype = buf[0];
<a name="l00222"></a>00222
<a name="l00223"></a>00223 sign = 0;
<a name="l00224"></a>00224 <span class="keywordflow">if</span> ((vtype &amp; <a class="code" href="ftoa__engine_8h.html#ae08813ed12ab2add31bd7237b2a21eee">FTOA_MINUS</a>) &amp;&amp; !(vtype &amp; <a class="code" href="ftoa__engine_8h.html#a3880068e0d3d33e895afb7bffce62b04">FTOA_NAN</a>))
<a name="l00225"></a>00225 sign = <span class="charliteral">&#39;-&#39;</span>;
<a name="l00226"></a>00226 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a5052dbb513e79cafd4cb51a474526318">FL_PLUS</a>)
<a name="l00227"></a>00227 sign = <span class="charliteral">&#39;+&#39;</span>;
<a name="l00228"></a>00228 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#ab75bdf743821eb031641f604ef84291a">FL_SPACE</a>)
<a name="l00229"></a>00229 sign = <span class="charliteral">&#39; &#39;</span>;
<a name="l00230"></a>00230
<a name="l00231"></a>00231 <span class="keywordflow">if</span> (vtype &amp; (FTOA_NAN | <a class="code" href="ftoa__engine_8h.html#a00844b2d34d094b2ff96684bcbfac309">FTOA_INF</a>)) {
<a name="l00232"></a>00232 <span class="keyword">const</span> <span class="keywordtype">char</span> *p;
<a name="l00233"></a>00233 ndigs = sign ? 4 : 3;
<a name="l00234"></a>00234 <span class="keywordflow">if</span> (width &gt; ndigs) {
<a name="l00235"></a>00235 width -= ndigs;
<a name="l00236"></a>00236 <span class="keywordflow">if</span> (!(flags &amp; <a class="code" href="vprintf_8cpp.html#af952bbf75b391b81f9fcd24834117c6d">FL_LPAD</a>)) {
<a name="l00237"></a>00237 <span class="keywordflow">do</span> {
<a name="l00238"></a>00238 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39; &#39;</span>);
<a name="l00239"></a>00239 } <span class="keywordflow">while</span> (--width);
<a name="l00240"></a>00240 }
<a name="l00241"></a>00241 } <span class="keywordflow">else</span> {
<a name="l00242"></a>00242 width = 0;
<a name="l00243"></a>00243 }
<a name="l00244"></a>00244 <span class="keywordflow">if</span> (sign)
<a name="l00245"></a>00245 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(sign);
<a name="l00246"></a>00246 p = <a class="code" href="vprintf_8cpp.html#a05ca900ebf7cd121be73c654d9ccb3eb">PSTR</a>(<span class="stringliteral">&quot;inf&quot;</span>);
<a name="l00247"></a>00247 <span class="keywordflow">if</span> (vtype &amp; FTOA_NAN)
<a name="l00248"></a>00248 p = <a class="code" href="vprintf_8cpp.html#a05ca900ebf7cd121be73c654d9ccb3eb">PSTR</a>(<span class="stringliteral">&quot;nan&quot;</span>);
<a name="l00249"></a>00249 <span class="keywordflow">while</span> ( (ndigs = pgm_read_byte(p)) != 0) {
<a name="l00250"></a>00250 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a220f13ec366247f858df3eb7962a8340">FL_FLTUPP</a>)
<a name="l00251"></a>00251 ndigs += <span class="charliteral">&#39;I&#39;</span> - <span class="charliteral">&#39;i&#39;</span>;
<a name="l00252"></a>00252 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(ndigs);
<a name="l00253"></a>00253 p++;
<a name="l00254"></a>00254 }
<a name="l00255"></a>00255 <span class="keywordflow">goto</span> tail;
<a name="l00256"></a>00256 }
<a name="l00257"></a>00257
<a name="l00258"></a>00258 <span class="comment">/* Output format adjustment, number of decimal digits in buf[] */</span>
<a name="l00259"></a>00259 <span class="keywordflow">if</span> (flags &amp; FL_FLTFIX) {
<a name="l00260"></a>00260 ndigs += exp;
<a name="l00261"></a>00261 <span class="keywordflow">if</span> ((vtype &amp; <a class="code" href="ftoa__engine_8h.html#a75a869972a95fb4f23067f5267ea860f">FTOA_CARRY</a>) &amp;&amp; buf[1] == <span class="charliteral">&#39;1&#39;</span>)
<a name="l00262"></a>00262 ndigs -= 1;
<a name="l00263"></a>00263 <span class="keywordflow">if</span> ((<span class="keywordtype">signed</span> <span class="keywordtype">char</span>)ndigs &lt; 1)
<a name="l00264"></a>00264 ndigs = 1;
<a name="l00265"></a>00265 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ndigs &gt; 8)
<a name="l00266"></a>00266 ndigs = 8;
<a name="l00267"></a>00267 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!(flags &amp; <a class="code" href="vprintf_8cpp.html#a4118c3d3af25daa2c39fb4aa1d5a4462">FL_FLTEXP</a>)) { <span class="comment">/* &#39;g(G)&#39; format */</span>
<a name="l00268"></a>00268 <span class="keywordflow">if</span> (exp &lt;= prec &amp;&amp; exp &gt;= -4)
<a name="l00269"></a>00269 flags |= FL_FLTFIX;
<a name="l00270"></a>00270 <span class="keywordflow">while</span> (prec &amp;&amp; buf[1+prec] == <span class="charliteral">&#39;0&#39;</span>)
<a name="l00271"></a>00271 prec--;
<a name="l00272"></a>00272 <span class="keywordflow">if</span> (flags &amp; FL_FLTFIX) {
<a name="l00273"></a>00273 ndigs = prec + 1; <span class="comment">/* number of digits in buf */</span>
<a name="l00274"></a>00274 prec = prec &gt; exp
<a name="l00275"></a>00275 ? prec - exp : 0; <span class="comment">/* fractional part length */</span>
<a name="l00276"></a>00276 }
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278
<a name="l00279"></a>00279 <span class="comment">/* Conversion result length, width := free space length */</span>
<a name="l00280"></a>00280 <span class="keywordflow">if</span> (flags &amp; FL_FLTFIX)
<a name="l00281"></a>00281 n = (exp&gt;0 ? exp+1 : 1);
<a name="l00282"></a>00282 <span class="keywordflow">else</span>
<a name="l00283"></a>00283 n = 5; <span class="comment">/* 1e+00 */</span>
<a name="l00284"></a>00284 <span class="keywordflow">if</span> (sign) n += 1;
<a name="l00285"></a>00285 <span class="keywordflow">if</span> (prec) n += prec + 1;
<a name="l00286"></a>00286 width = width &gt; n ? width - n : 0;
<a name="l00287"></a>00287
<a name="l00288"></a>00288 <span class="comment">/* Output before first digit */</span>
<a name="l00289"></a>00289 <span class="keywordflow">if</span> (!(flags &amp; (<a class="code" href="vprintf_8cpp.html#af952bbf75b391b81f9fcd24834117c6d">FL_LPAD</a> | <a class="code" href="vprintf_8cpp.html#aaad70046054194bb1cbe0673b3c212f2">FL_ZFILL</a>))) {
<a name="l00290"></a>00290 <span class="keywordflow">while</span> (width) {
<a name="l00291"></a>00291 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39; &#39;</span>);
<a name="l00292"></a>00292 width--;
<a name="l00293"></a>00293 }
<a name="l00294"></a>00294 }
<a name="l00295"></a>00295 <span class="keywordflow">if</span> (sign) <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(sign);
<a name="l00296"></a>00296 <span class="keywordflow">if</span> (!(flags &amp; <a class="code" href="vprintf_8cpp.html#af952bbf75b391b81f9fcd24834117c6d">FL_LPAD</a>)) {
<a name="l00297"></a>00297 <span class="keywordflow">while</span> (width) {
<a name="l00298"></a>00298 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39;0&#39;</span>);
<a name="l00299"></a>00299 width--;
<a name="l00300"></a>00300 }
<a name="l00301"></a>00301 }
<a name="l00302"></a>00302
<a name="l00303"></a>00303 <span class="keywordflow">if</span> (flags &amp; FL_FLTFIX) { <span class="comment">/* &#39;f&#39; format */</span>
<a name="l00304"></a>00304
<a name="l00305"></a>00305 n = exp &gt; 0 ? exp : 0; <span class="comment">/* exponent of left digit */</span>
<a name="l00306"></a>00306 <span class="keywordflow">do</span> {
<a name="l00307"></a>00307 <span class="keywordflow">if</span> (n == -1)
<a name="l00308"></a>00308 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39;.&#39;</span>);
<a name="l00309"></a>00309 flags = (n &lt;= exp &amp;&amp; n &gt; exp - ndigs)
<a name="l00310"></a>00310 ? buf[exp - n + 1] : <span class="charliteral">&#39;0&#39;</span>;
<a name="l00311"></a>00311 <span class="keywordflow">if</span> (--n &lt; -prec)
<a name="l00312"></a>00312 <span class="keywordflow">break</span>;
<a name="l00313"></a>00313 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(flags);
<a name="l00314"></a>00314 } <span class="keywordflow">while</span> (1);
<a name="l00315"></a>00315 <span class="keywordflow">if</span> (n == exp
<a name="l00316"></a>00316 &amp;&amp; (buf[1] &gt; <span class="charliteral">&#39;5&#39;</span>
<a name="l00317"></a>00317 || (buf[1] == <span class="charliteral">&#39;5&#39;</span> &amp;&amp; !(vtype &amp; <a class="code" href="ftoa__engine_8h.html#a75a869972a95fb4f23067f5267ea860f">FTOA_CARRY</a>))) )
<a name="l00318"></a>00318 {
<a name="l00319"></a>00319 flags = <span class="charliteral">&#39;1&#39;</span>;
<a name="l00320"></a>00320 }
<a name="l00321"></a>00321 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(flags);
<a name="l00322"></a>00322
<a name="l00323"></a>00323 } <span class="keywordflow">else</span> { <span class="comment">/* &#39;e(E)&#39; format */</span>
<a name="l00324"></a>00324
<a name="l00325"></a>00325 <span class="comment">/* mantissa */</span>
<a name="l00326"></a>00326 <span class="keywordflow">if</span> (buf[1] != <span class="charliteral">&#39;1&#39;</span>)
<a name="l00327"></a>00327 vtype &amp;= ~FTOA_CARRY;
<a name="l00328"></a>00328 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(buf[1]);
<a name="l00329"></a>00329 <span class="keywordflow">if</span> (prec) {
<a name="l00330"></a>00330 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39;.&#39;</span>);
<a name="l00331"></a>00331 sign = 2;
<a name="l00332"></a>00332 <span class="keywordflow">do</span> {
<a name="l00333"></a>00333 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(buf[sign++]);
<a name="l00334"></a>00334 } <span class="keywordflow">while</span> (--prec);
<a name="l00335"></a>00335 }
<a name="l00336"></a>00336
<a name="l00337"></a>00337 <span class="comment">/* exponent */</span>
<a name="l00338"></a>00338 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(flags &amp; <a class="code" href="vprintf_8cpp.html#a220f13ec366247f858df3eb7962a8340">FL_FLTUPP</a> ? <span class="charliteral">&#39;E&#39;</span> : <span class="charliteral">&#39;e&#39;</span>);
<a name="l00339"></a>00339 ndigs = <span class="charliteral">&#39;+&#39;</span>;
<a name="l00340"></a>00340 <span class="keywordflow">if</span> (exp &lt; 0 || (exp == 0 &amp;&amp; (vtype &amp; <a class="code" href="ftoa__engine_8h.html#a75a869972a95fb4f23067f5267ea860f">FTOA_CARRY</a>) != 0)) {
<a name="l00341"></a>00341 exp = -exp;
<a name="l00342"></a>00342 ndigs = <span class="charliteral">&#39;-&#39;</span>;
<a name="l00343"></a>00343 }
<a name="l00344"></a>00344 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(ndigs);
<a name="l00345"></a>00345 <span class="keywordflow">for</span> (ndigs = <span class="charliteral">&#39;0&#39;</span>; exp &gt;= 10; exp -= 10)
<a name="l00346"></a>00346 ndigs += 1;
<a name="l00347"></a>00347 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(ndigs);
<a name="l00348"></a>00348 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39;0&#39;</span> + exp);
<a name="l00349"></a>00349 }
<a name="l00350"></a>00350
<a name="l00351"></a>00351 <span class="keywordflow">goto</span> tail;
<a name="l00352"></a>00352 }
<a name="l00353"></a>00353
<a name="l00354"></a>00354 <span class="comment">/*</span>
<a name="l00355"></a>00355 <span class="comment"> * Handle string formats c, s, S.</span>
<a name="l00356"></a>00356 <span class="comment"> */</span>
<a name="l00357"></a>00357 {
<a name="l00358"></a>00358 <span class="keyword">const</span> <span class="keywordtype">char</span> * pnt;
<a name="l00359"></a>00359 <span class="keywordtype">size_t</span> size;
<a name="l00360"></a>00360
<a name="l00361"></a>00361 <span class="keywordflow">switch</span> (c) {
<a name="l00362"></a>00362
<a name="l00363"></a>00363 <span class="keywordflow">case</span> <span class="charliteral">&#39;c&#39;</span>:
<a name="l00364"></a>00364 buf[0] = va_arg (ap, <span class="keywordtype">int</span>);
<a name="l00365"></a>00365 pnt = (<span class="keywordtype">char</span> *)buf;
<a name="l00366"></a>00366 size = 1;
<a name="l00367"></a>00367 <span class="keywordflow">goto</span> no_pgmstring;
<a name="l00368"></a>00368
<a name="l00369"></a>00369 <span class="keywordflow">case</span> <span class="charliteral">&#39;s&#39;</span>:
<a name="l00370"></a>00370 pnt = va_arg (ap, <span class="keywordtype">char</span> *);
<a name="l00371"></a>00371 size = strnlen (pnt, (flags &amp; <a class="code" href="vprintf_8cpp.html#a8c134b2f4722f9b59d3851d0be28dda9">FL_PREC</a>) ? prec : ~0);
<a name="l00372"></a>00372 no_pgmstring:
<a name="l00373"></a>00373 flags &amp;= ~FL_PGMSTRING;
<a name="l00374"></a>00374 <span class="keywordflow">goto</span> str_lpad;
<a name="l00375"></a>00375
<a name="l00376"></a>00376 <span class="keywordflow">case</span> <span class="charliteral">&#39;S&#39;</span>:
<a name="l00377"></a>00377 pgmstring:
<a name="l00378"></a>00378 pnt = va_arg (ap, <span class="keywordtype">char</span> *);
<a name="l00379"></a>00379 size = strnlen_P (pnt, (flags &amp; FL_PREC) ? prec : ~0);
<a name="l00380"></a>00380 flags |= FL_PGMSTRING;
<a name="l00381"></a>00381
<a name="l00382"></a>00382 str_lpad:
<a name="l00383"></a>00383 <span class="keywordflow">if</span> (!(flags &amp; <a class="code" href="vprintf_8cpp.html#af952bbf75b391b81f9fcd24834117c6d">FL_LPAD</a>)) {
<a name="l00384"></a>00384 <span class="keywordflow">while</span> (size &lt; width) {
<a name="l00385"></a>00385 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39; &#39;</span>);
<a name="l00386"></a>00386 width--;
<a name="l00387"></a>00387 }
<a name="l00388"></a>00388 }
<a name="l00389"></a>00389 <span class="keywordflow">while</span> (size) {
<a name="l00390"></a>00390 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<a class="code" href="vprintf_8cpp.html#a594135840cf97491063107face7966e4">GETBYTE</a> (flags, <a class="code" href="vprintf_8cpp.html#a95045f8d69f7ad062c5d2bd4b4e4b6b4">FL_PGMSTRING</a>, pnt));
<a name="l00391"></a>00391 <span class="keywordflow">if</span> (width) width -= 1;
<a name="l00392"></a>00392 size -= 1;
<a name="l00393"></a>00393 }
<a name="l00394"></a>00394 <span class="keywordflow">goto</span> tail;
<a name="l00395"></a>00395 }
<a name="l00396"></a>00396 }
<a name="l00397"></a>00397
<a name="l00398"></a>00398 <span class="comment">/*</span>
<a name="l00399"></a>00399 <span class="comment"> * Handle integer formats variations for d/i, u, o, p, x, X.</span>
<a name="l00400"></a>00400 <span class="comment"> */</span>
<a name="l00401"></a>00401 <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;d&#39;</span> || c == <span class="charliteral">&#39;i&#39;</span>) {
<a name="l00402"></a>00402 <span class="keywordtype">long</span> x = (flags &amp; FL_LONG) ? va_arg(ap,<span class="keywordtype">long</span>) : va_arg(ap,<span class="keywordtype">int</span>);
<a name="l00403"></a>00403 flags &amp;= ~(<a class="code" href="vprintf_8cpp.html#a753650881115de6d78f9755bfcc777f0">FL_NEGATIVE</a> | FL_ALT);
<a name="l00404"></a>00404 <span class="keywordflow">if</span> (x &lt; 0) {
<a name="l00405"></a>00405 x = -x;
<a name="l00406"></a>00406 flags |= FL_NEGATIVE;
<a name="l00407"></a>00407 }
<a name="l00408"></a>00408 c = <a class="code" href="xtoa__fast_8h.html#a119673a72c9ad0beec652c19541d1b43">__ultoa_invert</a> (x, (<span class="keywordtype">char</span> *)buf, 10) - (<span class="keywordtype">char</span> *)buf;
<a name="l00409"></a>00409
<a name="l00410"></a>00410 } <span class="keywordflow">else</span> {
<a name="l00411"></a>00411 <span class="keywordtype">int</span> base;
<a name="l00412"></a>00412
<a name="l00413"></a>00413 <span class="keywordflow">if</span> (c == <span class="charliteral">&#39;u&#39;</span>) {
<a name="l00414"></a>00414 flags &amp;= ~FL_ALT;
<a name="l00415"></a>00415 base = 10;
<a name="l00416"></a>00416 <span class="keywordflow">goto</span> ultoa;
<a name="l00417"></a>00417 }
<a name="l00418"></a>00418
<a name="l00419"></a>00419 flags &amp;= ~(<a class="code" href="vprintf_8cpp.html#a5052dbb513e79cafd4cb51a474526318">FL_PLUS</a> | FL_SPACE);
<a name="l00420"></a>00420
<a name="l00421"></a>00421 <span class="keywordflow">switch</span> (c) {
<a name="l00422"></a>00422 <span class="keywordflow">case</span> <span class="charliteral">&#39;o&#39;</span>:
<a name="l00423"></a>00423 base = 8;
<a name="l00424"></a>00424 <span class="keywordflow">goto</span> ultoa;
<a name="l00425"></a>00425 <span class="keywordflow">case</span> <span class="charliteral">&#39;p&#39;</span>:
<a name="l00426"></a>00426 flags |= FL_ALT;
<a name="l00427"></a>00427 <span class="comment">/* no break */</span>
<a name="l00428"></a>00428 <span class="keywordflow">case</span> <span class="charliteral">&#39;x&#39;</span>:
<a name="l00429"></a>00429 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a58b1ac5446b292c77043f99558eb07cb">FL_ALT</a>)
<a name="l00430"></a>00430 flags |= FL_ALTHEX;
<a name="l00431"></a>00431 base = 16;
<a name="l00432"></a>00432 <span class="keywordflow">goto</span> ultoa;
<a name="l00433"></a>00433 <span class="keywordflow">case</span> <span class="charliteral">&#39;X&#39;</span>:
<a name="l00434"></a>00434 <span class="keywordflow">if</span> (flags &amp; FL_ALT)
<a name="l00435"></a>00435 flags |= (<a class="code" href="vprintf_8cpp.html#ab6ee3505eb9bc230d1d3dc2f8c83e67f">FL_ALTHEX</a> | FL_ALTUPP);
<a name="l00436"></a>00436 base = 16 | XTOA_UPPER;
<a name="l00437"></a>00437 ultoa:
<a name="l00438"></a>00438 c = <a class="code" href="xtoa__fast_8h.html#a119673a72c9ad0beec652c19541d1b43">__ultoa_invert</a> ((flags &amp; <a class="code" href="vprintf_8cpp.html#aba9eba8db439010ca11f2fb7607c7c6e">FL_LONG</a>)
<a name="l00439"></a>00439 ? va_arg(ap, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span>)
<a name="l00440"></a>00440 : va_arg(ap, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>),
<a name="l00441"></a>00441 (<span class="keywordtype">char</span> *)buf, base) - (<span class="keywordtype">char</span> *)buf;
<a name="l00442"></a>00442 flags &amp;= ~FL_NEGATIVE;
<a name="l00443"></a>00443 <span class="keywordflow">break</span>;
<a name="l00444"></a>00444
<a name="l00445"></a>00445 <span class="keywordflow">default</span>:
<a name="l00446"></a>00446 <span class="keywordflow">return</span>;
<a name="l00447"></a>00447 }
<a name="l00448"></a>00448 }
<a name="l00449"></a>00449
<a name="l00450"></a>00450 <span class="comment">/*</span>
<a name="l00451"></a>00451 <span class="comment"> * Format integers.</span>
<a name="l00452"></a>00452 <span class="comment"> */</span>
<a name="l00453"></a>00453 {
<a name="l00454"></a>00454 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> len;
<a name="l00455"></a>00455
<a name="l00456"></a>00456 len = c;
<a name="l00457"></a>00457 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a8c134b2f4722f9b59d3851d0be28dda9">FL_PREC</a>) {
<a name="l00458"></a>00458 flags &amp;= ~FL_ZFILL;
<a name="l00459"></a>00459 <span class="keywordflow">if</span> (len &lt; prec) {
<a name="l00460"></a>00460 len = prec;
<a name="l00461"></a>00461 <span class="keywordflow">if</span> ((flags &amp; <a class="code" href="vprintf_8cpp.html#a58b1ac5446b292c77043f99558eb07cb">FL_ALT</a>) &amp;&amp; !(flags &amp; FL_ALTHEX))
<a name="l00462"></a>00462 flags &amp;= ~FL_ALT;
<a name="l00463"></a>00463 }
<a name="l00464"></a>00464 }
<a name="l00465"></a>00465 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a58b1ac5446b292c77043f99558eb07cb">FL_ALT</a>) {
<a name="l00466"></a>00466 <span class="keywordflow">if</span> (buf[c-1] == <span class="charliteral">&#39;0&#39;</span>) {
<a name="l00467"></a>00467 flags &amp;= ~(FL_ALT | <a class="code" href="vprintf_8cpp.html#ab6ee3505eb9bc230d1d3dc2f8c83e67f">FL_ALTHEX</a> | FL_ALTUPP);
<a name="l00468"></a>00468 } <span class="keywordflow">else</span> {
<a name="l00469"></a>00469 len += 1;
<a name="l00470"></a>00470 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#ab6ee3505eb9bc230d1d3dc2f8c83e67f">FL_ALTHEX</a>)
<a name="l00471"></a>00471 len += 1;
<a name="l00472"></a>00472 }
<a name="l00473"></a>00473 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (flags &amp; (<a class="code" href="vprintf_8cpp.html#a753650881115de6d78f9755bfcc777f0">FL_NEGATIVE</a> | <a class="code" href="vprintf_8cpp.html#a5052dbb513e79cafd4cb51a474526318">FL_PLUS</a> | <a class="code" href="vprintf_8cpp.html#ab75bdf743821eb031641f604ef84291a">FL_SPACE</a>)) {
<a name="l00474"></a>00474 len += 1;
<a name="l00475"></a>00475 }
<a name="l00476"></a>00476
<a name="l00477"></a>00477 <span class="keywordflow">if</span> (!(flags &amp; <a class="code" href="vprintf_8cpp.html#af952bbf75b391b81f9fcd24834117c6d">FL_LPAD</a>)) {
<a name="l00478"></a>00478 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#aaad70046054194bb1cbe0673b3c212f2">FL_ZFILL</a>) {
<a name="l00479"></a>00479 prec = c;
<a name="l00480"></a>00480 <span class="keywordflow">if</span> (len &lt; width) {
<a name="l00481"></a>00481 prec += width - len;
<a name="l00482"></a>00482 len = width;
<a name="l00483"></a>00483 }
<a name="l00484"></a>00484 }
<a name="l00485"></a>00485 <span class="keywordflow">while</span> (len &lt; width) {
<a name="l00486"></a>00486 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39; &#39;</span>);
<a name="l00487"></a>00487 len++;
<a name="l00488"></a>00488 }
<a name="l00489"></a>00489 }
<a name="l00490"></a>00490
<a name="l00491"></a>00491 width = (len &lt; width) ? width - len : 0;
<a name="l00492"></a>00492
<a name="l00493"></a>00493 <span class="keywordflow">if</span> (flags &amp; FL_ALT) {
<a name="l00494"></a>00494 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39;0&#39;</span>);
<a name="l00495"></a>00495 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#ab6ee3505eb9bc230d1d3dc2f8c83e67f">FL_ALTHEX</a>)
<a name="l00496"></a>00496 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(flags &amp; <a class="code" href="vprintf_8cpp.html#a41bcbafa8f3d8487945b6a6ede5df7a2">FL_ALTUPP</a> ? <span class="charliteral">&#39;X&#39;</span> : <span class="charliteral">&#39;x&#39;</span>);
<a name="l00497"></a>00497 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (flags &amp; (<a class="code" href="vprintf_8cpp.html#a753650881115de6d78f9755bfcc777f0">FL_NEGATIVE</a> | <a class="code" href="vprintf_8cpp.html#a5052dbb513e79cafd4cb51a474526318">FL_PLUS</a> | <a class="code" href="vprintf_8cpp.html#ab75bdf743821eb031641f604ef84291a">FL_SPACE</a>)) {
<a name="l00498"></a>00498 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> z = <span class="charliteral">&#39; &#39;</span>;
<a name="l00499"></a>00499 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a5052dbb513e79cafd4cb51a474526318">FL_PLUS</a>) z = <span class="charliteral">&#39;+&#39;</span>;
<a name="l00500"></a>00500 <span class="keywordflow">if</span> (flags &amp; <a class="code" href="vprintf_8cpp.html#a753650881115de6d78f9755bfcc777f0">FL_NEGATIVE</a>) z = <span class="charliteral">&#39;-&#39;</span>;
<a name="l00501"></a>00501 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(z);
<a name="l00502"></a>00502 }
<a name="l00503"></a>00503
<a name="l00504"></a>00504 <span class="keywordflow">while</span> (prec &gt; c) {
<a name="l00505"></a>00505 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39;0&#39;</span>);
<a name="l00506"></a>00506 prec--;
<a name="l00507"></a>00507 }
<a name="l00508"></a>00508
<a name="l00509"></a>00509 <span class="keywordflow">do</span> {
<a name="l00510"></a>00510 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(buf[--c]);
<a name="l00511"></a>00511 } <span class="keywordflow">while</span> (c);
<a name="l00512"></a>00512 }
<a name="l00513"></a>00513
<a name="l00514"></a>00514 tail:
<a name="l00515"></a>00515 <span class="comment">/* Tail is possible. */</span>
<a name="l00516"></a>00516 <span class="keywordflow">while</span> (width) {
<a name="l00517"></a>00517 <a class="code" href="class_stream.html#a46cd2d80c276134f30300d619416d5c8">write</a>(<span class="charliteral">&#39; &#39;</span>);
<a name="l00518"></a>00518 width--;
<a name="l00519"></a>00519 }
<a name="l00520"></a>00520 } <span class="comment">/* for (;;) */</span>
<a name="l00521"></a>00521 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated for ArduPilot Libraries by&nbsp;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.png" alt="doxygen"/></a></small></address>
</body>
</html>