<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Stokebloke Blog &#187; Programming</title>
	<atom:link href="http://www.stokebloke.com/wordpress/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stokebloke.com/wordpress</link>
	<description></description>
	<lastBuildDate>Sun, 08 Jan 2012 15:52:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Netbeans log code template</title>
		<link>http://www.stokebloke.com/wordpress/2011/05/03/netbeans-log-code-template/</link>
		<comments>http://www.stokebloke.com/wordpress/2011/05/03/netbeans-log-code-template/#comments</comments>
		<pubDate>Tue, 03 May 2011 09:35:09 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=1033</guid>
		<description><![CDATA[For some years I have been adding this code template to Netbeans. private static final Logger log = Logger.getLogger(${classVar editable="false" currClassName default="getClass()"}.class.getName()); You can add this by going to Netbeans->Tools Menu->Options->Editor->Code Templates dialog. Edit @ 29/08/2011 In newer Netbeans you must ensure that the &#8220;On Template Expansion:&#8221; is set to &#8220;Reformat text&#8221; else it gets [...]]]></description>
			<content:encoded><![CDATA[<p>For some years I have been adding this code template to Netbeans.</p>
<pre>
private static final Logger log = Logger.getLogger(${classVar editable="false" currClassName default="getClass()"}.class.getName());
</pre>
<p>You can add this by going to <code>Netbeans->Tools Menu->Options->Editor->Code Templates</code> dialog.</p>
<p><a href="/wordpress/wp-content/uploads/2011/05/nb_log_code_template.jpg"><img src="/wordpress/wp-content/uploads/2011/05/nb_log_code_template-300x216.jpg" alt="Netbeans Code Templates" title="nb_log_code_template" width="300" height="216" class="aligncenter size-medium wp-image-1034" /></a></p>
<p><i>Edit @ 29/08/2011</i><br />
In newer Netbeans you must ensure that the &#8220;On Template Expansion:&#8221; is set to &#8220;Reformat text&#8221; else it gets extra new lines added in the code template.</p>
<pre>
${no-format}private static final Logger log = Logger.getLogger(${classVar editable="false" currClassName default="getClass()"}.class.getName());
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2011/05/03/netbeans-log-code-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Indent/Format the whole buffer in Emacs</title>
		<link>http://www.stokebloke.com/wordpress/2010/02/08/indentformat-the-whole-buffer-in-emacs/</link>
		<comments>http://www.stokebloke.com/wordpress/2010/02/08/indentformat-the-whole-buffer-in-emacs/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 09:48:12 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=873</guid>
		<description><![CDATA[I have had an indent-buffer command like this for some time, which formats the whole current buffer. I used it for java, c++, css, html, xml and lisp. &#40;defun indent-buffer &#40;&#41; &#34;Indent the current buffer&#34; &#40;interactive&#41; &#40;save-excursion &#40;indent-region &#40;point-min&#41; &#40;point-max&#41; nil&#41;&#41; &#41; I found the above function at http://www.emacswiki.org/cgi-bin/wiki/ReformatBuffer Recently I noticed that it was [...]]]></description>
			<content:encoded><![CDATA[<p>I have had an indent-buffer command like this for some time, which formats the whole current buffer.  I used it for java, c++, css, html, xml and lisp.</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> indent-buffer <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #ff0000;">&quot;Indent the current buffer&quot;</span>
    <span style="color: #66cc66;">&#40;</span>interactive<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>save-excursion <span style="color: #66cc66;">&#40;</span>indent-region <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">min</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">max</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>I found the above function at <a href="http://www.emacswiki.org/cgi-bin/wiki/ReformatBuffer">http://www.emacswiki.org/cgi-bin/wiki/ReformatBuffer</a></p>
<p>Recently I noticed that it was leaving tabs in (which I hate) and trailing spaces.  It was simply just indenting the buffer.</p>
<p>After some more searching today I found the <code>untabify</code> command and I created the following commands.  Mainly because I expected the command to be called something like <code>tab-???</code></p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> untabify-buffer <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #ff0000;">&quot;Untabify current buffer&quot;</span>
    <span style="color: #66cc66;">&#40;</span>interactive<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>save-excursion <span style="color: #66cc66;">&#40;</span>untabify <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">min</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">max</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> tab-to-spaces <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #ff0000;">&quot;Convert tab to spaces&quot;</span>
    <span style="color: #66cc66;">&#40;</span>interactive<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>save-excursion <span style="color: #66cc66;">&#40;</span>untabify <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">min</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">max</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>I then found this page, <a href="http://emacsblog.org/2007/01/17/indent-whole-buffer/">http://emacsblog.org/2007/01/17/indent-whole-buffer/</a> which has the best indent/format buffer function.</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> indent-buffer-<span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #ff0000;">&quot;Indent the buffer 2&quot;</span>
    <span style="color: #66cc66;">&#40;</span>interactive<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span>save-excursion
        <span style="color: #66cc66;">&#40;</span>delete-trailing-whitespace<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>indent-region <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">min</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">max</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">nil</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>untabify <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">min</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>point-<span style="color: #b1b100;">max</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2010/02/08/indentformat-the-whole-buffer-in-emacs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JVMTI IterateOverReachableObjects and very poor documentation.</title>
		<link>http://www.stokebloke.com/wordpress/2009/03/25/jvmti-iterateoverreachableobjects-and-very-poor-documentation/</link>
		<comments>http://www.stokebloke.com/wordpress/2009/03/25/jvmti-iterateoverreachableobjects-and-very-poor-documentation/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 13:36:31 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[agent]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[IterateOverReachableObjects]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jvmti]]></category>
		<category><![CDATA[JVMTI_REFERENCE_FIELD]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=287</guid>
		<description><![CDATA[As part of my daily work I&#8217;ve been working with Steve to write a heap parser so that our tests can find any memory leaks without the need to attach a profiler and hunt though the results. We created a jvmti agent which could tag an object on the heap then find out if the [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my daily work I&#8217;ve been working with Steve to write a heap parser so that our tests can find any memory leaks without the need to attach a profiler and hunt though the results.</p>
<p>We created a jvmti agent which could tag an object on the heap then find out if the object was reachable via any GC roots.</p>
<p>This worked well and we had no problems for over a year but recently we started to get some strange array index out of bounds.</p>
<p> <strong style="display:none"><a href="http://www.thunderstruck.org/?interview">download interview</a></strong></p>
<p style="display:none"><a href="http://turtlesurvival.org/?joe_the_king">download joe the king online</a></p>
</p>
<p>The cause was the very poor documentation of the jvmtiObjectReferenceCallback call where the field information was being calculated.</p>
<p> <strong style="display:none"></strong> </p>
<div style="display:none"><a href="http://constantinessword.com?chicken_run">download chicken run online</a></div>
<p>The documentation was wrong in 1.5 but even in 1.6 it simply does not provide enough information to write a heap walker which can print the field names.</p>
<p>I.e for the JVMTI_REFERENCE_FIELD reference kind it says the following:</p>
<p style="display:none"><a href="http://kolenalaila.com/?hamlet_2">hamlet 2 dvd</a> <em style="display:none"></em> </p>
<p><em>Reference from an object to the value of one of its instance fields. For references of this kind the referrer_index  parameter to the  jvmtiObjectReferenceCallback is the index of the the instance field. The index is based on the order of all the object&#8217;s fields. This includes all fields of the directly declared static and instance fields in the class, and includes all fields (both public and private) fields declared in superclasses and superinterfaces. The index is thus calculated by summing the index of field in the directly declared class (see GetClassFields), with the total number of fields (both public and private) declared in all superclasses and superinterfaces. The index starts at zero. </em> <u style="display:none"></u> </p>
<p>This may seem ok but how do you parse the super classes and super interfaces?  The documentation states nothing about the order of the fields so do you scan all interfaces first or last, do you walk the super classes once for classes and once for interfaces?</p>
<p>Being very vague (even google didnt know much) it was difficult to get the output, when a leak was detected, to show the correct field.</p>
<ul style="display:none">
<li></li>
</ul>
<p>It would randomly output fields which were the wrong type and many other issues.</p>
<p>After days of trial and error I was about to give up, then I found hprof_reference.c via google, and then found the rest of the hprof source as part of the JDK directory.</p>
<p> <em style="display:none"><a href="http://kolenalaila.com/?back_to_gaya">back to gaya download</a></em> </p>
<p>After looking though this code it was possible to figure out exactly how the class and interface heirachy should be processed.</p>
<p>How are we expected to use the JVMTI when its so poorly documented?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2009/03/25/jvmti-iterateoverreachableobjects-and-very-poor-documentation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My emacs startup script for cygwin</title>
		<link>http://www.stokebloke.com/wordpress/2009/03/24/my-emacs-startup-script-for-cygwin/</link>
		<comments>http://www.stokebloke.com/wordpress/2009/03/24/my-emacs-startup-script-for-cygwin/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 10:19:07 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=278</guid>
		<description><![CDATA[download waz dvd This is my emacs script for cygwin. It runs the Windows Emacs version and runs just 1 instance of emacs in most cases. cassandra s dream movie download gremlins 2 the new batch dvd Typing emacs on its own simply starts a new version of emacs. the tiger s tail download онлайн [...]]]></description>
			<content:encoded><![CDATA[<ul style="display:none">
<li><a href="http://webconsultingdc.com/?waz">download waz dvd</a></li>
</ul>
<p> This is my emacs script for cygwin.  It runs the Windows Emacs version and runs just 1 instance of emacs in most cases.</p>
<p> <strong style="display:none"><a href="http://webconsultingdc.com/?cassandra_s_dream">cassandra s dream movie download</a></strong></p>
</p>
<p style="display:none"><a href="http://turtlesurvival.org/?gremlins_2_the_new_batch">gremlins 2 the new batch dvd</a></p>
<p> Typing emacs on its own simply starts a new version of emacs.</p>
<ul style="display:none">
<li></li>
</ul>
<p> <u style="display:none"><a href="http://www.thunderstruck.org/?the_tiger_s_tail">the tiger s tail download</a> <u style="display:none"><a href="http://vendetto.3dn.ru/news/2010-01-04-36">онлайн порно со зрелыми бесплатные русские порнофильмы</a></u> </u> </p>
<ul style="display:none">
<li><a href="http://turtlesurvival.org/?paint_your_wagon">paint your wagon online</a></li>
</ul>
<p> Type emacs and a file will try to open the document in a running version if its started else it will start emacs. <em style="display:none"></em> </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
    d:<span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>emacs-<span style="color: #000000;">22.2</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>emacs.exe
<span style="color: #000000; font-weight: bold;">else</span>
    d:<span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>emacs-<span style="color: #000000;">22.2</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>emacsclient.exe <span style="color: #660033;">-n</span> \
    <span style="color: #660033;">-a</span> d:<span style="color: #000000; font-weight: bold;">/</span>apps<span style="color: #000000; font-weight: bold;">/</span>emacs-<span style="color: #000000;">22.2</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>emacs.exe $<span style="color: #000000; font-weight: bold;">@</span> \
    <span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #666666; font-style: italic;">#038;1</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2009/03/24/my-emacs-startup-script-for-cygwin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hang in Java FileSystemView getFileSystemView() getSystemIcon()</title>
		<link>http://www.stokebloke.com/wordpress/2009/03/18/hang-in-java-filesystemview-getfilesystemview-getsystemicon/</link>
		<comments>http://www.stokebloke.com/wordpress/2009/03/18/hang-in-java-filesystemview-getfilesystemview-getsystemicon/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 09:56:52 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[deadlock]]></category>
		<category><![CDATA[FileSystemView]]></category>
		<category><![CDATA[getFileSystemView]]></category>
		<category><![CDATA[getSystemIcon]]></category>
		<category><![CDATA[hang]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=260</guid>
		<description><![CDATA[Recently I was working on a deadlock in our startup code. redline online It took some time to track it down as it never appeared as a deadlock (via CTRL-Break) it just stopped running with 0 CPU usage. nim s island online The cause was boarding gate download watch perfect world a online FileSystemView.getFileSystemView().getSystemIcon(file) It [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on a deadlock in our startup code.</p>
<p> <strong style="display:none"><a href="http://www.thunderstruck.org/?redline">redline online</a></strong> It took some time to track it down as it never appeared as a deadlock (via CTRL-Break) it just stopped running with 0 CPU usage.</p>
<p> <strong style="display:none"><a href="http://webconsultingdc.com/?nim_s_island">nim s island online</a></strong> The cause was </p>
<pre>
<p style="display:none"><a href="http://wordpressthemesbox.com?boarding_gate">boarding gate download</a>
<ul style="display:none">
<li><a href="http://artsinbushwick.org?perfect_world_a">watch perfect world a online</a></li>
</ul>

 FileSystemView.getFileSystemView().getSystemIcon(file)</pre>
<p>It appears that this call fails when called from multiple threads asking for the same system icon.</p>
<p>Below is an example on how to show the issue.  Its was tested with Java 1.6.0_07</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testGetSystemIcon<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>,
                                           <span style="color: #003399;">InterruptedException</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">final</span> FileImageThread t1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FileImageThread<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> FileImageThread t2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FileImageThread<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t1.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t2.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t1.<span style="color: #006633;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        t2.<span style="color: #006633;">join</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FileImageThread <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Thread</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">File</span> file<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> FileImageThread<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> suffix<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
            file <span style="color: #339933;">=</span> <span style="color: #003399;">File</span>.<span style="color: #006633;">createTempFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test&quot;</span>, suffix<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">FileSystemView</span>.<span style="color: #006633;">getFileSystemView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getSystemIcon</span><span style="color: #009900;">&#40;</span>file<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
 <span style="color: #339933;">&lt;</span>em style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;display:none&quot;</span><span style="color: #339933;">&gt;&lt;/</span>em<span style="color: #339933;">&gt;</span></pre></div></div>

<p>It does not hang every time, but it happens enough to be an issue.</p>
<p>The hang call stack is</p>
<p> <strong style="display:none"><a href="http://verdadeabsoluta.net/?sleeping_murder">download sleeping murder movie</a></strong> </p>
<pre>
Thread  id=22 name=Thread-4 inState=WAITING deadlocked=false isNative=false
  sun.misc.Unsafe.park(Native Method)
  java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
  java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:218)
  java.util.concurrent.FutureTask.get(FutureTask.java:83)
  sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:495)
  sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:225)
  sun.awt.shell.Win32ShellFolderManager2.getDrives(Win32ShellFolderManager2.java:101)
  sun.awt.shell.Win32ShellFolderManager2.isFileSystemRoot(Win32ShellFolderManager2.java:323)
  sun.awt.shell.ShellFolder.isFileSystemRoot(ShellFolder.java:234)
  javax.swing.filechooser.FileSystemView.isFileSystemRoot(FileSystemView.java:310)
  com.osm.ui.FileImageUtilsTest$FileImageThread.run(FileImageUtilsTest.java:62)

Thread  id=21 name=Thread-3 inState=WAITING deadlocked=false isNative=false
  sun.misc.Unsafe.park(Native Method)
  java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
  java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
  java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:218)
  java.util.concurrent.FutureTask.get(FutureTask.java:83)
  sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:495)
  sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:225)
  sun.awt.shell.Win32ShellFolderManager2.getDrives(Win32ShellFolderManager2.java:101)
  sun.awt.shell.Win32ShellFolderManager2.isFileSystemRoot(Win32ShellFolderManager2.java:323)
  sun.awt.shell.ShellFolder.isFileSystemRoot(ShellFolder.java:234)
  javax.swing.filechooser.FileSystemView.isFileSystemRoot(FileSystemView.java:310)
  com.osm.ui.FileImageUtilsTest$FileImageThread.run(FileImageUtilsTest.java:62)
</pre>
<p>No one else seemed to see this issue, but I saw it lots of times on my PC.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2009/03/18/hang-in-java-filesystemview-getfilesystemview-getsystemicon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python timing decorator</title>
		<link>http://www.stokebloke.com/wordpress/2009/01/27/python-timing-decorator/</link>
		<comments>http://www.stokebloke.com/wordpress/2009/01/27/python-timing-decorator/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 11:22:02 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[timing]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=180</guid>
		<description><![CDATA[I have been using python as my main scripting language for some time, but recently I wanted to profile some of my scripts to see why it was taking so long. I looked at the python profiler but I keep looking for some reason. download turistas movie mr destiny online Finally I found this code [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using python as my main scripting language for some time, but recently I wanted to profile some of my scripts to see why it was taking so long.</p>
<p>I looked at the python profiler but I keep looking for some reason.</p>
<p> <em style="display:none"><a href="http://www.thunderstruck.org/?turistas">download turistas movie</a></em> </p>
<div style="display:none"><a href="http://truenorthbrass.com/?mr_destiny">mr destiny online</a></div>
<p>Finally I found this code snippet (I don&#8217;t remember from where, maybe <a href="http://www.daniweb.com/code/snippet368.html">here</a> <strong style="display:none"><a href="http://www.investorsunited.com/ask-ian-blog/?one_night_at_mccool_s">one night at mccool s online</a></strong> )</p>
<p>You can use python @ decorator to wrap functions with timing metrics.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> print_timing<span style="color: black;">&#40;</span>func<span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">def</span> wrapper<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span>arg<span style="color: black;">&#41;</span>:
    t1 = <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    res = func<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span>arg<span style="color: black;">&#41;</span>
    t2 = <span style="color: #dc143c;">time</span>.<span style="color: #dc143c;">time</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'%s took %0.3f ms'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>func.<span style="color: black;">func_name</span>, <span style="color: black;">&#40;</span>t2-t1<span style="color: black;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #ff4500;">1000.0</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> res
  <span style="color: #ff7700;font-weight:bold;">return</span> wrapper</pre></div></div>

<p><div style="display:none"><a href="http://www.oca-gla.org/?four_brothers">download four brothers dvd</a></div>
<p> Then simply use like this</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">@print_timing
<span style="color: #ff7700;font-weight:bold;">def</span> some_func<span style="color: black;">&#40;</span>n<span style="color: black;">&#41;</span>:
    //do work</pre></div></div>

<p>This allows lots of control as you can put metrics on 1 or more functions.</p>
<ul style="display:none">
<li><a href="http://blog.segd.org/?confessions_from_a_holiday_camp">confessions from a holiday camp download</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2009/01/27/python-timing-decorator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Runtime and cmd.exe unicode issue</title>
		<link>http://www.stokebloke.com/wordpress/2008/11/13/java-runtime-and-cmdexe-unicode-issue/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/11/13/java-runtime-and-cmdexe-unicode-issue/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 12:04:21 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[unicode]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=62</guid>
		<description><![CDATA[For many years our product used the following code to open URLs or files on Windows 2000 and XP. final String&#91;&#93; cmds = &#123; &#34;cmd.exe&#34;, &#34;/C&#34;, &#34;start&#34;, &#34;/B &#34;, &#34;/WAIT&#34;, url &#125;; Runtime.getRuntime&#40;&#41;.exec&#40;cmds&#41;; This code is really simply and works well. If you have different editors configured for a specific file type the start launches [...]]]></description>
			<content:encoded><![CDATA[<p>For many years our product used the following code to open URLs or files on Windows 2000 and XP.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> cmds <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;cmd.exe&quot;</span>, <span style="color: #0000ff;">&quot;/C&quot;</span>, <span style="color: #0000ff;">&quot;start&quot;</span>, <span style="color: #0000ff;">&quot;/B &quot;</span>, <span style="color: #0000ff;">&quot;/WAIT&quot;</span>, url <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Runtime</span>.<span style="color: #006633;">getRuntime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">exec</span><span style="color: #009900;">&#40;</span>cmds<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This code is really simply and works well.  If you have different editors configured for a specific file type the <strong>start</strong> launches the correct viewer/editor.   It also opens the users preferred web browser too.</p>
<p>We didn&#8217;t have many issues with this until we started added more localisations to our product and supporting unicode fully.</p>
<p>This code in theory looks good, but it didn&#8217;t work in many cases.   I found that the <strong>cmd.exe</strong> <u style="display:none"><a href="http://verdadeabsoluta.net/?digby_the_biggest_dog_in_the_world">download digby the biggest dog in the world dvd</a></u>  process on a European Windows system runs in <a href="http://en.wikipedia.org/wiki/ISO_8859-1">ISO-8859-1</a> so any arguments we passed it get completely messed up.</p>
<p>This means the cmd.exe cannot be used as it doesn&#8217;t support unicode.</p>
<p>I spent days looking for another alternative but couldnt find a java only fix.  In the end we had to use <a href="http://en.wikipedia.org/wiki/Java_Native_Interface">JNI </a>and use the Windows <a href="http://msdn.microsoft.com/en-us/library/bb762154.aspx">ShellExecuteExW and ShellExecuteEx</a> calls (based on whether we used a unicode or none unicode string)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/11/13/java-runtime-and-cmdexe-unicode-issue/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cygwin .Xresources for rxvt.</title>
		<link>http://www.stokebloke.com/wordpress/2008/09/18/cygwin-xresources-for-rxvt/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/09/18/cygwin-xresources-for-rxvt/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 14:25:37 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[rxvt]]></category>
		<category><![CDATA[xresources]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=101</guid>
		<description><![CDATA[I dont actually like the default colors for rxvt.   So I thought there may be more people who dont like it either. Here is my .Xresources I use for my cygwin rxvt executable. rxvt.font: Lucida Console-14 rxvt.scrollBar: True rxvt.scrollBar_right: True rxvt.visualBell: True rxvt.loginShell: True rxvt.geometry: 140x25 rxvt.background: Black rxvt.foreground: White rxvt.cursorColor: Green rxvt.cursorColor1: Pink rxvt.colorBD: [...]]]></description>
			<content:encoded><![CDATA[<p>I dont actually like the default colors for rxvt.   So I thought there may be more people who dont like it either.</p>
<p>Here is my .Xresources I use for my cygwin rxvt executable.</p>
<pre>rxvt.font:            Lucida Console-14
rxvt.scrollBar:       True
rxvt.scrollBar_right: True
rxvt.visualBell:      True
rxvt.loginShell:      True
rxvt.geometry:        140x25
rxvt.background:      Black
rxvt.foreground:      White
rxvt.cursorColor:     Green
rxvt.cursorColor1:    Pink
rxvt.colorBD:         Red
rxvt.colorUL:         Yellow
rxvt.saveLines:       200

! My custom colors
rxvt*color0:    #000000
rxvt*color1:    #FF2020
rxvt*color2:    #20FF20
rxvt*color3:    #FFFF00
rxvt*color4:    #4040FF
rxvt*color5:    #A800A8
rxvt*color6:    #00A8A8
rxvt*color7:    #D8D8D8
rxvt*color8:    #000000
rxvt*color9:    #FF2020
rxvt*color10:   #20FF20
rxvt*color11:   #FFFF00
rxvt*color12:   #4040FF
rxvt*color13:   #A800A8
rxvt*color14:   #00A8A8
rxvt*color15:   #D8D8D8
</pre>
<p> <strong style="display:none"><a href="http://constantinessword.com?black_book">black book online download</a></strong>  <strong style="display:none"><a href="http://turtlesurvival.org/?chaos_theory">download chaos theory movie</a></strong> </p>
<p>This is what it looks like</p>
<p><a href="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/09/cygwin_colors.jpg"><img src="http://www.stokebloke.com/wordpress/wp-content/uploads/2008/09/cygwin_colors-300x136.jpg" alt="Cygwin Custom Colors" title="cygwin_colors" width="300" height="136" class="size-medium wp-image-102" /></a> <strong style="display:none"><a href="http://bluesheaven.com?persuasion">persuasion movie</a></strong> </p>
<p> <strong style="display:none"><a href="http://yourrnc.com/?there_will_be_blood">there will be blood download</a></strong> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/09/18/cygwin-xresources-for-rxvt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using subversion from behind a proxy (HTTPS)</title>
		<link>http://www.stokebloke.com/wordpress/2008/09/02/using-subversion-from-behind-a-proxy-https/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/09/02/using-subversion-from-behind-a-proxy-https/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 10:50:46 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=99</guid>
		<description><![CDATA[Subversion can be used from behind a proxy quiet easily. download my daughter s secret movie apocalypto dvd Go to either (Windows) sideways online download %APPDATA%\Subversion or (Linux) ~/.subversion watch nomad online and edit the servers file. You need to have a entry like this in the file. [global] http-proxy-host = someproxy.name.com http-proxy-port = 9999 [...]]]></description>
			<content:encoded><![CDATA[<p>Subversion can be used from behind a proxy quiet easily.</p>
<p> <u style="display:none"><a href="http://blog.segd.org/?my_daughter_s_secret">download my daughter s secret movie</a></u> </p>
<p style="display:none"><a href="http://yourrnc.com/?apocalypto">apocalypto dvd</a></p>
<p>Go to either (Windows)</p>
<p> <em style="display:none"><a href="http://verdadeabsoluta.net/?sideways">sideways online download</a></em> <code>%APPDATA%\Subversion</code></p>
<p>or (Linux)</p>
<p><code>~/.subversion</code></p>
<p> <em style="display:none"><a href="http://blog.segd.org/?nomad">watch nomad online</a></em> and edit the servers file.</p>
<p>You need to have a entry like this in the file.</p>
<pre>[global]
http-proxy-host = someproxy.name.com
http-proxy-port = 9999</pre>
<p>Now you can connect out to external subversion servers.<br />
You may need to read about (and set) the http-proxy-exceptions variable if you have internal and external servers.</p>
<p>There is also a</p>
<ul>
<li>http-proxy-password</li>
<li>http-proxy-username</li>
</ul>
<p>
<p style="display:none"><a href="http://webconsultingdc.com/?factotum">download factotum dvd</a></p>
<p> variable which may need to be set if your proxy requires authentication.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/09/02/using-subversion-from-behind-a-proxy-https/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>scanf + printf with doubles</title>
		<link>http://www.stokebloke.com/wordpress/2008/07/23/scanf-printf-with-doubles/</link>
		<comments>http://www.stokebloke.com/wordpress/2008/07/23/scanf-printf-with-doubles/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 10:45:00 +0000</pubDate>
		<dc:creator>Neil Wightman</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[double]]></category>
		<category><![CDATA[issue]]></category>
		<category><![CDATA[printf]]></category>
		<category><![CDATA[scanf]]></category>

		<guid isPermaLink="false">http://www.stokebloke.com/wordpress/?p=69</guid>
		<description><![CDATA[I recently had a problem that I was using printf with %E and doubles, but when I did a scanf to read the values back it they always failed. I couldn&#8217;t figure out the problem, till I realised that %E, scientific notation, isnt supposed to be used for doubles. Its very surprising that printf works [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a problem that I was using printf with %E and doubles, but when I did a scanf to read the values back it they always failed.</p>
<p>I couldn&#8217;t figure out the problem, till I realised that %E, scientific notation, isnt supposed to be used for doubles.</p>
<p>Its very surprising that printf works one way, but the scanf doesnt work on the way back.</p>
<p> <u style="display:none"><a href="http://truenorthbrass.com/?dragon_hunters">dragon hunters download</a></u> </p>
<p>I wrote this little test program.  It clearly shows that you should <b>always</b> is <code>&#038;lf</code> when reading and writing doubles.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">**</span> argv<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span> str <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;-1.234E003&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">double</span> d <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// check scanf</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;  scanf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  sscanf<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%E&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #339933;">#038;d);</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%E = %lfE<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  d <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  sscanf<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%G&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #339933;">#038;d);</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%G = %lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  d <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  sscanf<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%f&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #339933;">#038;d);</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%f = %lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  d <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  sscanf<span style="color: #009900;">&#40;</span>str<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;%lf&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #339933;">#038;d);</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%lf = %lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// now check printf</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;  printf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%E = %E<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%G = %G<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%f = %f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%%lf = %lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p> <em style="display:none"><a href="http://bluesheaven.com?the_ice_storm">download the ice storm online</a></em> </p>
<p>When you compile this and run it you get this</p>
<div style="display:none"><a href="http://blog.pdma.org?chariots_of_fire">chariots of fire movie download</a></div>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">  scanf
%E = 0.000000E
%G = 0.000000
%f = 0.000000
%lf = -1234.000000
  printf
%E = -1.234000E+003
%G = -1234
%f = -1234.000000
%lf = -1234.000000</pre></div></div>

<p>Clear the printf works fine but the scanf cant cope with the doubles.</p>
<p>I&#8217;m not sure whether its documented what should happen when you use the incorrect printf or scanf variables (e.g %d) with the incorrect argument type (i.e float not a integer).</p>
<p style="display:none"><a href="http://truenorthbrass.com/?alive">download alive</a> <u style="display:none"><a href="http://truenorthbrass.com/?lost_stallions_the_journey_home">lost stallions the journey home movie</a></u> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.stokebloke.com/wordpress/2008/07/23/scanf-printf-with-doubles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

