diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-10-12 09:48:47 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-10-12 09:48:47 -0700 |
commit | 3b158194a8fe2ea49843303a78649e0f5fac1320 (patch) | |
tree | 833d85d7411ce9018ffa070b73ac623149b72019 /html/subx/010core.cc.html | |
parent | d331cded4ddfecef7f72a4ff1a6f1c7040515e3b (diff) | |
download | mu-3b158194a8fe2ea49843303a78649e0f5fac1320.tar.gz |
4028
Diffstat (limited to 'html/subx/010core.cc.html')
-rw-r--r-- | html/subx/010core.cc.html | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/html/subx/010core.cc.html b/html/subx/010core.cc.html index ce74e6e8..606d4dec 100644 --- a/html/subx/010core.cc.html +++ b/html/subx/010core.cc.html @@ -155,10 +155,10 @@ if ('onhashchange' in window) { <span id="L92" class="LineNr"> 92 </span><span class="Delimiter">}</span> <span id="L93" class="LineNr"> 93 </span> <span id="L94" class="LineNr"> 94 </span><span class="Normal">void</span> load_program<span class="Delimiter">(</span><span class="Normal">const</span> string& text_bytes<span class="Delimiter">)</span> <span class="Delimiter">{</span> -<span id="L95" class="LineNr"> 95 </span> <span class="Comment">// now, to read the hex bytes in ASCII, we'll use C's strtol</span> -<span id="L96" class="LineNr"> 96 </span> <span class="Comment">// strtol needs a char*, so we grab the buffer backing the string object</span> -<span id="L97" class="LineNr"> 97 </span> <span class="Normal">uint32_t</span> addr = <span class="Constant">1</span><span class="Delimiter">;</span> -<span id="L98" class="LineNr"> 98 </span> <span class="Normal">char</span>* curr = <span class="Normal">const_cast</span><<span class="Normal">char</span>*><span class="Delimiter">(</span>&text_bytes[<span class="Constant">0</span>]<span class="Delimiter">);</span> <span class="Comment">// non-standard approach, but blessed by Herb Sutter (<a href="http://herbsutter.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/#comment-483)">http://herbsutter.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/#comment-483)</a></span> +<span id="L95" class="LineNr"> 95 </span> <span class="Normal">uint32_t</span> addr = <span class="Constant">1</span><span class="Delimiter">;</span> +<span id="L96" class="LineNr"> 96 </span> <span class="Comment">// we'll use C's 'strtol` to parse ASCII hex bytes</span> +<span id="L97" class="LineNr"> 97 </span> <span class="Comment">// strtol needs a char*, so we grab the buffer backing the string object</span> +<span id="L98" class="LineNr"> 98 </span> <span class="Normal">char</span>* curr = <span class="Normal">const_cast</span><<span class="Normal">char</span>*><span class="Delimiter">(</span>&text_bytes[<span class="Constant">0</span>]<span class="Delimiter">);</span> <span class="Comment">// non-portable, but blessed by Herb Sutter (<a href="http://herbsutter.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/#comment-483)">http://herbsutter.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/#comment-483)</a></span> <span id="L99" class="LineNr"> 99 </span> <span class="Normal">char</span>* max = curr + strlen<span class="Delimiter">(</span>curr<span class="Delimiter">);</span> <span id="L100" class="LineNr">100 </span> <span class="Normal">while</span> <span class="Delimiter">(</span>curr < max<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span id="L101" class="LineNr">101 </span> <span class="Conceal">¦</span> <span class="Comment">// skip whitespace</span> |