<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/blag/templates/default/atom.css" type="text/css" ?>

<feed 
   xmlns="http://www.w3.org/2005/Atom"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    
    <link href="http://www.frank-busse.de/blag/feeds/atom.xml" rel="self" title="FBlag" type="application/atom+xml" />
    <link href="http://www.frank-busse.de/blag/"                        rel="alternate"    title="FBlag" type="text/html" />
    <link href="http://www.frank-busse.de/blag/rss.php?version=2.0"     rel="alternate"    title="FBlag" type="application/rss+xml" />
    <title type="html">FBlag</title>
    <subtitle type="html">It's time you started living like the Pieceofschmidt you are.</subtitle>
    
    <id>http://www.frank-busse.de/blag/</id>
    <updated>2011-09-07T16:39:19Z</updated>
    <generator uri="http://www.s9y.org/" version="1.6">Serendipity 1.6 - http://www.s9y.org/</generator>
    <dc:language>de</dc:language>

    <entry>
        <link href="http://www.frank-busse.de/blag/archives/522-Xmonad-and-uzbl-browser.html" rel="alternate" title="Xmonad and uzbl-browser" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-09-06T18:14:17Z</published>
        <updated>2011-09-07T16:39:19Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=522</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=522</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/2-Informatik" label="Informatik" term="Informatik" />
    
        <id>http://www.frank-busse.de/blag/archives/522-guid.html</id>
        <title type="html">Xmonad and uzbl-browser</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Every release of <a href="http://www.opera.com/">Opera</a> seems to add more bugs¹ and useless features², whereas <a href="http://www.mozilla.org/">Firefox</a> is featureless and slow without or feature-rich and ineffable slow with Add-ons. Time for an alternative! What I want is a small browser with external configurable handlers. What I don't need is qt-bloat, a Firefox clone or something with lua in it. <a href="http://uzbl.org/">uzbl</a> seems to fit, but I'm tired of learning new shortcuts for tabbing implementations. Everyone and his brother integrate tabs (terminal multiplexer, terminal, browser, editor...) but only one application should obviously manage tabs - the window manager. It turned out that my original configuration of xmonad wasn't the optimal solution. I'd like to have the following behaviour:<br />
<br />
First workspace: keep master, switch focus to new window<br />
<pre style="line-height:0.7em;"><br />
+---------------+    +-----------+---+<br />
|               |    |           | 2 |<br />
|               |    |           |   |<br />
|       1       | -> |     1     | f |<br />
|    (focus)    |    |           | o |<br />
|               |    |           | c |<br />
|               |    |           | . |<br />
+---------------+    +-----------+---+<br />
</pre><br />
<br />
Second to fourth workspace: switch master and focus<br />
<pre style="line-height:0.7em;"><br />
+---------------+    +-----------+---+<br />
|               |    |           | 1 |<br />
|               |    |           |   |<br />
|       1       | -> |     2     |   |<br />
|    (focus)    |    |  (focus)  |   |<br />
|               |    |           |   |<br />
|               |    |           |   |<br />
+---------------+    +-----------+---+<br />
</pre><br />
<br />
Fifth workspace (for browsing): keep master and focus and use tabbed layout (open new links/tabs in background)<br />
<pre style="line-height:0.7em;"><br />
+---------------+    +-------+-------+<br />
+---------------+    +-------+-------+<br />
|               |    |               |<br />
|       1       | -> |       1       |<br />
|    (focus)    |    |    (focus)    |<br />
|               |    |               |<br />
|               |    |               |<br />
+---------------+    +---------------+<br />
</pre><br />
<br />
These are the steps that were necessary to achieve this:<br />
<br />
1. copy xmonad-contrib-0.9.2/XMonad/Hooks/InsertPosition.hs to ./xmonad/lib/<br />
2. apply the patch (sorry, no google account and no desire to install darcs again):<br />
<div class="diff geshi" style="text-align: left"><br /><span style="color: #888822;">--- InsertPosition.hs</span><br /><span style="color: #888822;">+++ InsertPositionNew.hs</span><br /><span style="color: #440088;">@@ -16,15 +16,16 @@</span><br />&#160;module XMonad.Hooks.InsertPosition <span style="">&#40;</span><br />&#160; &#160; &#160;-- * Usage<br />&#160; &#160; &#160;-- $usage<br /><span style="color: #991111;">- &#160; &#160;insertPosition</span><br /><span style="color: #00b000;">+ &#160; &#160;insertPosition,</span><br /><span style="color: #00b000;">+ &#160; &#160;insertPositionPerWorkspace</span><br />&#160; &#160; &#160;,Focus<span style="">&#40;</span>..<span style="">&#41;</span>, Position<span style="">&#40;</span>..<span style="">&#41;</span><br />&#160; &#160; &#160;<span style="">&#41;</span> where<br /><br /><span style="color: #991111;">-import XMonad<span style="">&#40;</span>ManageHook, MonadReader<span style="">&#40;</span>ask<span style="">&#41;</span><span style="">&#41;</span></span><br /><span style="color: #00b000;">+import XMonad<span style="">&#40;</span>ManageHook, MonadReader<span style="">&#40;</span>ask<span style="">&#41;</span>, WorkspaceId<span style="">&#41;</span></span><br />&#160;import qualified XMonad.StackSet as W<br />&#160;import Control.Applicative<span style="">&#40;</span><span style="">&#40;</span>&lt;$&gt;<span style="">&#41;</span><span style="">&#41;</span><br />&#160;import Data.Maybe<span style="">&#40;</span>fromMaybe<span style="">&#41;</span><br /><span style="color: #991111;">-import Data.List<span style="">&#40;</span>find<span style="">&#41;</span></span><br /><span style="color: #00b000;">+import Data.List<span style="">&#40;</span>find,lookup<span style="">&#41;</span></span><br />&#160;import Data.Monoid<span style="">&#40;</span>Endo<span style="">&#40;</span>Endo<span style="">&#41;</span><span style="">&#41;</span><br /><br />&#160;-- $usage<br /><span style="color: #440088;">@@ -44,26 +45,30 @@</span><br />&#160;-- | insertPosition. A manage hook for placing new windows. XMonad's default is<br />&#160;-- the same as using: @insertPosition Above Newer@.<br />&#160;insertPosition :: Position -&gt; Focus -&gt; ManageHook<br /><span style="color: #991111;">-insertPosition pos foc = Endo . g &lt;$&gt; ask</span><br /><span style="color: #00b000;">+insertPosition = insertPositionPerWorkspace <span style="">&#91;</span><span style="">&#93;</span></span><br /><span style="color: #00b000;">+</span><br /><span style="color: #00b000;">+-- | Specify an insertPosition for a particular Workspace.</span><br /><span style="color: #00b000;">+insertPositionPerWorkspace :: <span style="">&#91;</span><span style="">&#40;</span>WorkspaceId, <span style="">&#40;</span>Position, Focus<span style="">&#41;</span><span style="">&#41;</span><span style="">&#93;</span> -&gt; Position -&gt; Focus -&gt; ManageHook</span><br /><span style="color: #00b000;">+insertPositionPerWorkspace l pos foc = Endo . g &lt;$&gt; ask</span><br />&#160; &#160;where<br /><span style="color: #991111;">- &#160; &#160;g w = viewingWs w <span style="">&#40;</span>updateFocus w . ins w . W.delete w<span style="">&#41;</span></span><br /><span style="color: #991111;">- &#160; &#160;ins w = <span style="">&#40;</span>\f ws -&gt; fromMaybe id <span style="">&#40;</span>W.focusWindow &lt;$&gt; W.peek ws<span style="">&#41;</span> $ f ws<span style="">&#41;</span> $</span><br /><span style="color: #991111;">- &#160; &#160; &#160; &#160;case pos of</span><br /><span style="color: #00b000;">+ &#160; &#160;g w = viewingWs w <span style="">&#40;</span>\i -&gt; updateFocus i w . ins i w . W.delete w<span style="">&#41;</span></span><br /><span style="color: #00b000;">+ &#160; &#160;ins i w = <span style="">&#40;</span>\f ws -&gt; fromMaybe id <span style="">&#40;</span>W.focusWindow &lt;$&gt; W.peek ws<span style="">&#41;</span> $ f ws<span style="">&#41;</span> $</span><br /><span style="color: #00b000;">+ &#160; &#160; &#160; &#160;case fst $ fromMaybe <span style="">&#40;</span>pos,foc<span style="">&#41;</span> <span style="">&#40;</span>lookup i l<span style="">&#41;</span> of</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160;Master -&gt; W.insertUp w . W.focusMaster<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160;End &#160; &#160;-&gt; insertDown w . W.modify' focusLast'<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160;Above &#160;-&gt; W.insertUp w<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160;Below &#160;-&gt; insertDown w<br /><span style="color: #991111;">- &#160; &#160;updateFocus =</span><br /><span style="color: #991111;">- &#160; &#160; &#160; &#160;case foc of</span><br /><span style="color: #00b000;">+ &#160; &#160;updateFocus i =</span><br /><span style="color: #00b000;">+ &#160; &#160; &#160; &#160;case snd $ fromMaybe <span style="">&#40;</span>pos,foc<span style="">&#41;</span> <span style="">&#40;</span>lookup i l<span style="">&#41;</span> of</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160;Older -&gt; const id<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160;Newer -&gt; W.focusWindow<br /><br />&#160;-- | Modify the StackSet when the workspace containing w is focused<br /><span style="color: #991111;">-viewingWs :: <span style="">&#40;</span>Eq a, Eq s, Eq i, Show i<span style="">&#41;</span> =&gt;a-&gt; <span style="">&#40;</span>W.StackSet i l a s sd -&gt; W.StackSet i l a s sd<span style="">&#41;</span>-&gt; W.StackSet i l a s sd-&gt; W.StackSet i l a s sd</span><br /><span style="color: #00b000;">+viewingWs :: <span style="">&#40;</span>Eq a, Eq s, Eq i, Show i<span style="">&#41;</span> =&gt;a-&gt; <span style="">&#40;</span>i -&gt; W.StackSet i l a s sd -&gt; W.StackSet i l a s sd<span style="">&#41;</span>-&gt; W.StackSet i l a s sd-&gt; W.StackSet i l a s sd</span><br />&#160;viewingWs w f = do<br />&#160; &#160; &#160;i &lt;- W.tag . W.workspace . W.current<br />&#160; &#160; &#160;ws &lt;- find <span style="">&#40;</span>elem w . W.integrate' . W.stack<span style="">&#41;</span> . W.workspaces<br /><span style="color: #991111;">- &#160; &#160;maybe id <span style="">&#40;</span>fmap <span style="">&#40;</span>W.view i . f<span style="">&#41;</span> . W.view . W.tag<span style="">&#41;</span> ws</span><br /><span style="color: #00b000;">+ &#160; &#160;maybe id <span style="">&#40;</span>fmap <span style="">&#40;</span>W.view i . f i<span style="">&#41;</span> . W.view . W.tag<span style="">&#41;</span> ws</span><br /><br />&#160;-- | 'insertDown' and 'focusLast' belong in XMonad.StackSet?<br />&#160;insertDown :: <span style="">&#40;</span>Eq a<span style="">&#41;</span> =&gt; a -&gt; W.StackSet i l a s sd -&gt; W.StackSet i l a s sd<br />&#160;</div><br />
3. reconfigure ./xmonad/xmonad.hs<br />
<br />
add imports:<br />
<div class="haskell geshi" style="text-align: left"><br /><span style="color: #06c; font-weight: bold;">import</span> InsertPositionNew<br /><span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Hooks<span style="color: #339933; font-weight: bold;">.</span>ManageHelpers<br /><span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Layout<span style="color: #339933; font-weight: bold;">.</span>PerWorkspace<br />&#160;</div><br />
<br />
add shortcut for uzbl-browser:<br />
<div class="haskell geshi" style="text-align: left"><br />&#160; &#160; <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>modm<span style="color: #339933; font-weight: bold;">,</span> &#160; &#160; &#160; &#160; &#160; &#160; &#160; xK<span style="color: #339933; font-weight: bold;">_</span>u<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> spawn <span style="background-color: #3cb371;">&quot;uzbl-browser&quot;</span><span style="color: green;">&#41;</span><br />&#160;</div><br />
<br />
change layout hook:<br />
<div class="haskell geshi" style="text-align: left"><br />myLayout <span style="color: #339933; font-weight: bold;">=</span><br />&#160; modWorkspaces myWorkspaces avoidStruts <span style="color: #339933; font-weight: bold;">$</span><br />&#160; onWorkspace <span style="background-color: #3cb371;">&quot;5:www&quot;</span> simpleTabbedAlways <span style="color: #339933; font-weight: bold;">$</span><br />&#160; tiled <span style="color: #339933; font-weight: bold;">|||</span> Mirror tiled <span style="color: #339933; font-weight: bold;">|||</span> simpleTabbedAlways <span style="color: #339933; font-weight: bold;">|||</span> Full<br />&#160; <span style="color: #06c; font-weight: bold;">where</span><br />&#160; &#160; &#160;<span style="color: #5d478b; font-style: italic;">-- default tiling algorithm partitions the screen into two panes</span><br />&#160; &#160; &#160;tiled &#160; <span style="color: #339933; font-weight: bold;">=</span> Tall nmaster delta ratio<br /><br />&#160; &#160; &#160;<span style="color: #5d478b; font-style: italic;">-- The default number of windows in the master pane</span><br />&#160; &#160; &#160;nmaster <span style="color: #339933; font-weight: bold;">=</span> <span style="color: red;">1</span><br /><br />&#160; &#160; &#160;<span style="color: #5d478b; font-style: italic;">-- Default proportion of screen occupied by master pane</span><br />&#160; &#160; &#160;<span style="color: #5d478b; font-style: italic;">-- ratio &#160; = 1/2</span><br />&#160; &#160; &#160;ratio &#160; <span style="color: #339933; font-weight: bold;">=</span> <span style="color: red;">7</span><span style="color: #339933; font-weight: bold;">/</span><span style="color: red;">10</span><br /><br />&#160; &#160; &#160;<span style="color: #5d478b; font-style: italic;">-- Percent of screen to increment by when resizing panes</span><br />&#160; &#160; &#160;<span style="color: #5d478b; font-style: italic;">-- delta &#160; = 3/100</span><br />&#160; &#160; &#160;delta &#160; <span style="color: #339933; font-weight: bold;">=</span> <span style="color: red;">5</span><span style="color: #339933; font-weight: bold;">/</span><span style="color: red;">100</span><br />&#160;</div><br />
<br />
create manage hooks<br />
<div class="haskell geshi" style="text-align: left"><br />myManageHookFloat <span style="color: #339933; font-weight: bold;">=</span> composeAll<br />&#160; &#160; <span style="color: green;">&#91;</span> className <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;Gimp&quot;</span> &#160; &#160; &#160; &#160; &#160; <span style="color: #339933; font-weight: bold;">--&gt;</span> doFloat<br />&#160; &#160; <span style="color: #339933; font-weight: bold;">,</span> className <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;MPlayer&quot;</span> &#160; &#160; &#160; &#160;<span style="color: #339933; font-weight: bold;">--&gt;</span> doFloat<br />&#160; &#160; <span style="color: #339933; font-weight: bold;">,</span><span style="color: green;">&#40;</span>className <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;Firefox&quot;</span> <span style="color: #339933; font-weight: bold;">&lt;&amp;&amp;&gt;</span> role <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;Manager&quot;</span> <span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doFloat<br />&#160; &#160; <span style="color: green;">&#93;</span> <span style="color: #339933; font-weight: bold;">&lt;+&gt;</span> composeOne <span style="color: green;">&#91;</span><br />&#160; &#160; &#160; isDialog <span style="color: #339933; font-weight: bold;">-?&gt;</span> doCenterFloat<br />&#160; &#160; <span style="color: green;">&#93;</span><br />&#160; &#160; <span style="color: #06c; font-weight: bold;">where</span> role <span style="color: #339933; font-weight: bold;">=</span> stringProperty <span style="background-color: #3cb371;">&quot;WM_WINDOW_ROLE&quot;</span><br /><br />myManageHookShift <span style="color: #339933; font-weight: bold;">=</span> composeAll<br />&#160; &#160; <span style="color: green;">&#91;</span> className <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;Uzbl-core&quot;</span> &#160; &#160; &#160;<span style="color: #339933; font-weight: bold;">--&gt;</span> doShift <span style="background-color: #3cb371;">&quot;5:www&quot;</span><br />&#160; &#160; <span style="color: #339933; font-weight: bold;">,</span> className <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;Firefox&quot;</span> &#160; &#160; &#160; &#160;<span style="color: #339933; font-weight: bold;">--&gt;</span> doShift <span style="background-color: #3cb371;">&quot;5:www&quot;</span> <span style="color: green;">&#93;</span><br /><br />myManageHookPosition <span style="color: #339933; font-weight: bold;">=</span> insertPositionPerWorkspace <span style="color: green;">&#91;</span><span style="color: green;">&#40;</span><span style="background-color: #3cb371;">&quot;1&quot;</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: green;">&#40;</span>Below<span style="color: #339933; font-weight: bold;">,</span>Newer<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: green;">&#40;</span><span style="background-color: #3cb371;">&quot;5:www&quot;</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: green;">&#40;</span>Below<span style="color: #339933; font-weight: bold;">,</span>Older<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: green;">&#93;</span> Above Newer<br />&#160;</div><br />
<br />
combine manage hooks and override the default config:<br />
<div class="haskell geshi" style="text-align: left"><br />&#160; &#160; &#160; &#160; manageHook &#160; &#160; &#160; &#160; <span style="color: #339933; font-weight: bold;">=</span> myManageHookFloat <span style="color: #339933; font-weight: bold;">&lt;+&gt;</span> myManageHookPosition <span style="color: #339933; font-weight: bold;">&lt;+&gt;</span> myManageHookShift<span style="color: #339933; font-weight: bold;">,</span><br />&#160;</div><br />
<br />
Done.<br />
<br />
<a href="http://frank-busse.de/bilder/rechner/uzbl_xmonad.png"><img src="http://frank-busse.de/bilder/rechner/uzbl_xmonad_small.png" alt="multiple uzbl-browser windows within xmonad tabbed layout" /></a><br />
<br />
¹ last one: the bookmark menu needs 30s to load all bookmarks<br />
² webserver(!), torrent- and unusable mail client 
            </div>
        </content>
        <dc:subject>Firefox</dc:subject>
<dc:subject>Opera</dc:subject>
<dc:subject>lua</dc:subject>
<dc:subject>uzbl</dc:subject>
<dc:subject>xmonad</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/521-Verweisaktualisierung.html" rel="alternate" title="Verweisaktualisierung" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-09-03T17:24:48Z</published>
        <updated>2011-09-03T17:24:48Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=521</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=521</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/3-Netzseite" label="Netzseite" term="Netzseite" />
    
        <id>http://www.frank-busse.de/blag/archives/521-guid.html</id>
        <title type="html">Verweisaktualisierung</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <h2>Auswahl</h2><br />
-<a href="http://www.userfriendly.org/">userfriendly.org</a><br />
<br />
<h2>Bücher</h2><br />
-<a href="http://webster.cs.ucr.edu/AoA/DOS/AoADosIndex.html">The Art of Assembly Language Programming</a><br />
+<a href="http://www.arl.wustl.edu/~lockwood/class/cs306/books/artofasm/toc.html">The Art of Assembly Language Programming</a><br />
<br />
<h2>Software</h2><br />
-<a href="http://www.remote-exploit.org/backtrack.html">BackTrack</a><br />
-<a href="http://www.linuxfromscratch.org/">Linux From Scratch</a><br />
-<a href="http://tudos.org/">TUD:OS</a><br />
-<a href="http://ipython.scipy.org/">IPython</a><br />
-<a href="http://kodos.sourceforge.net/">Kodos</a><br />
-<a href="http://www.robert-tolksdorf.de/vmlanguages.html">Languages for the Java VM</a> (<a href="http://www.erights.org/">E</a>,<a href="http://mindprod.com/jgloss/jgloss.html">Glossary</a>)<br />
-<a href="http://php.net/">PHP :|</a><br />
-<a href="http://processing.org/">Processing</a> <a href="http://complexification.net/">(Complexification)</a><br />
-<a href="http://www.scala-lang.org/">Scala</a> (<a href="http://www.simplyscala.com/">Simply Scala</a>)<br />
-<a href="http://ettercap.sourceforge.net/">Ettercap</a><br />
-<a href="http://www.mozilla.com/firefox/">Firefox</a><br />
-<a href="http://madwifi.org/">Madwifi</a><br />
-<a href="http://www.opera.com/">Opera</a> (<a href="https://bugs.opera.com/wizard/">Bug Report</a>, <a href="http://my.opera.com/desktopteam/blog/">Desktop-Team</a>)<br />
-<a href="http://vsftpd.beasts.org/">vsftpd</a><br />
-<a href="http://www.research.att.com/sw/tools/wsp/">Web Scraping Proxy</a><br />
-<a href="http://www.wireshark.org/">Wireshark</a><br />
+<a href="http://www.uzbl.org">uzbl</a><br />
-<a href="http://www.bootchart.org/">bootchart</a><br />
-<a href="http://www.chkrootkit.org/">chrootkit</a><br />
-<a href="http://forums.gentoo.org/viewtopic-t-142475.html">gentoo:dep</a><br />
-<a href="http://www.openwall.com/john/">John the Ripper</a><br />
-<a href="http://materm.sourceforge.net/wiki/pmwiki.php">mrxvt</a><br />
-<a href="http://research.mupad.de/">Mupad</a><br />
-<a href="http://www.mysql.com/">Mysql</a><br />
-<a href="http://www.insecure.org/nmap/">Nmap</a><br />
-<a href="http://www.rootkit.nl/">rootkit hunter</a><br />
-<a href="http://www.openwall.com/scanlogd/">scanlogd</a><br />
-<a href="http://www.vim.org/">vim</a> (<a href="http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-c.html">colour schemes</a>, <a href="http://www.viemu.com/a-why-vi-vim.html">why</a>, <a href="http://www.oualline.com/vim-cook.html">Cookbook</a>)<br />
-<a href="http://www.hping.org/visitors/">Visitors</a><br />
-<a href="http://xxdiff.sourceforge.net/">xxdiff</a><br />
-<a href="http://yafc.sourceforge.net/index.php">Yafc</a><br />
-<a href="http://www.strcat.de/blog/categories/9-Zsh">Weblog</a><br />
-<a href="http://www.gnome.org/projects/dia/">Dia</a><br />
-<a href="http://dwm.suckless.org/">dwm</a><br />
-<a href="http://gqview.sourceforge.net/">GQview</a><br />
-<a href="http://savannah.gnu.org/projects/gv/">gv</a><br />
-<a href="http://www.mpg123.de/">mpg123</a><br />
-<a href="http://wwwhome.cs.utwente.nl/~tcm/">TCM</a><br />
-<a href="http://xchm.sourceforge.net">xchm</a><br />
-<a href="http://xinehq.de/">xine</a><br />
-<a href="http://www.big-boards.com/">Big Boards</a><br />
-<a href="http://ulm.ccc.de/chaos-seminar/personal-firewalls/recording.html">Chaosseminar: Personal Firewalls</a><br />
-<a href="http://www.skymind.com/~ocrow/python_string/">Efficient String Concatenation in Python</a><br />
-<a href="http://felinemenace.org/papers.html">felinemenace</a><br />
-<a href="http://www.shelldorado.com/">Heiner's SHELLdorado</a><br />
-<a href="http://java-decompiler.com/">Java Decompiler</a><br />
-<a href="http://www.milw0rm.org/">milw0rm</a><br />
-<a href="http://www.tigernt.com/tools/Java/index.shtml">Online Java Decompiler</a><br />
-<a href="http://p-nand-q.com/">p nand q</a><br />
-<a href="http://www.packetstormsecurity.org/">packet storm</a><br />
-<a href="http://www.reportlab.org/rl_toolkit.html">ReportLab Toolkit</a><br />
-<a href="http://www.rootkit.com/">rootkit.com</a><br />
-<a href="http://searchirc.com/">SearchIRC</a><br />
-<a href="http://www.securiteam.com/">SecuriTeam</a><br />
-<a href="http://www.securitytube.net/">SecurityTube</a><br />
-<a href="http://shellcode.org/">shellcode</a><br />
-<a href="http://www.technicalinfo.net/papers/index.html">Technical info</a><br />
-<a href="http://jendryschik.de/misc/disclaimer">Warum Disclaimer dem WWW schaden</a><br />
<br />
<h2>Sonstiges</h2><br />
-<a href="http://www.duden.de/sprachspiele/besserwisser/index.php">DUDEN - Besserwisserspiel</a><br />
-<a href="http://blogs.msdn.com/andrewkennedy/">Andrew Kennedy</a><br />
-<a href="http://www.bildblog.de/">BILDblog</a><br />
-<a href="http://strcat.de/blog/">Christian</a><br />
+<a href="http://blog.ezyang.com/">Edward Z. Yang</a><br />
-<a href="http://blogs.23.nu/ilja/">Ilja</a><br />
-<a href="http://weblogs.asp.net/podwysocki/">Matthew Podwysocki</a><br />
-<a href="http://www.catonmat.net/">Peteris Krumins</a><br />
-<a href="http://steel.twoday.net/">vs-geheim</a> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/520-ne-keycodes.html" rel="alternate" title="ne keycodes" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-08-24T17:55:20Z</published>
        <updated>2011-09-07T13:44:06Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=520</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=520</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/2-Informatik" label="Informatik" term="Informatik" />
    
        <id>http://www.frank-busse.de/blag/archives/520-guid.html</id>
        <title type="html">ne keycodes</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                To get expected behaviour for home, end and backspace in ne with rxvt-unicode, start ne (the "<a href="http://ne.dsi.unimi.it/">nice editor</a>"), press Ctrl+k for the command prompt, enter kc and in the new prompt press the specific key for the key code. Afterwards adjust the config file:<br />
<div class="bash geshi" style="text-align: left"><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> .ne<span style="color: #000000; font-weight: bold;">/</span>.keys<br />KEY <span style="color: #000000;">105</span> MoveSOL<br />KEY <span style="color: #000000;">106</span> MoveEOL<br />KEY &#160;7f Backspace</div> 
            </div>
        </content>
        <dc:subject>keycode</dc:subject>
<dc:subject>ne</dc:subject>
<dc:subject>urxvt</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/519-Ich-war-der-Fahrer-von-Rommel.html" rel="alternate" title="Ich war der Fahrer von Rommel" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-08-23T15:19:12Z</published>
        <updated>2011-08-23T15:19:12Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=519</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=519</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/1-Geschichte" label="Geschichte" term="Geschichte" />
    
        <id>http://www.frank-busse.de/blag/archives/519-guid.html</id>
        <title type="html">Ich war der Fahrer von Rommel</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <a href="http://www.sz-online.de/nachrichten/artikel.asp?id=2843052">Ich war der Fahrer von Rommel</a><br />
<blockquote>Vor 70 Jahren marschierte die Wehrmacht unter Erwin Rommel in Nordafrika ein. Rudolf Schneider aus Stauchitz war dessen Frontfahrer.</blockquote><blockquote>Schneider ist Träger des <b>Eisernen Kreuzes 1. Klasse – die dritthöchste Auszeichnung für Wehrmachtssoldaten</b>.</blockquote><br />
Gleich nach Deutschem Kreuz und Ritterkreuz oder wie? m( 
            </div>
        </content>
        <dc:subject>Eisernes Kreuz</dc:subject>
<dc:subject>Rommel</dc:subject>
<dc:subject>Schneider</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/517-UNO-bekraeftigt-das-Recht-auf-Gotteslaesterung.html" rel="alternate" title="UNO bekräftigt das Recht auf Gotteslästerung" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-08-15T17:20:00Z</published>
        <updated>2011-08-15T17:20:00Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=517</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=517</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/5-Kramkiste" label="Kramkiste" term="Kramkiste" />
    
        <id>http://www.frank-busse.de/blag/archives/517-guid.html</id>
        <title type="html">UNO bekräftigt das Recht auf Gotteslästerung</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <a href="http://hpd.de/node/11837">UNO bekräftigt das Recht auf Gotteslästerung</a><br />
<br />
<blockquote>Die Stellungnahme kam vom Menschenrechtskomitee, dem Gremium aus achtzehn unabhängigen Experten, die damit beauftragt wurden, Beschwerden hinsichtlich des Internationalen Pakts über Bürgerliche und Politische Rechte (ICCPR, International Covenant on Civil and Political Rights), das Menschenrechtsabkommen von 1966, das für Meinungsfreiheit und Ausdrucksfreiheit sorgt, sowie für andere fundamentale Rechte zu bewerten. [...] Anders als die weit veröffentlichten Resolutionen, die vom Menschenrechtsrat und der Generalversammlung produziert werden, sind die Vorschriften des ICCPR für seine über 165 Mitglieder juristisch bindend.</blockquote><br />
<blockquote>Laut Paragraph 48 „sind Verbote von Darstellungen mangelnden Respekts vor einer Religion oder anderen Glaubenssystemen, einschließlich Blasphemiegesetzen, mit dem Vertrag inkompatibel, außer in den bestimmten Umständen, wie sie in Artikel 20, Absatz 2 des Vertrags vorausgesehen sind.“ Der Artikel 20, Absatz 2 ruft Staaten dazu auf, Folgendes zu verbieten: „Die Verfechtung nationalen, rassistischen oder religiösen Hasses, welche zur Diskriminierung, Feindseligkeit oder Gewalt anstiftet.“ Der Kommentar verlangt mit Bedacht, dass keine Restriktion die Garantien des Abkommens auf Gleichberechtigung vor dem Gesetz (Artikel 26) und der Freiheit des Denkens, des Gewissens und der Religion (Artikel 18) verletzen darf.</blockquote><br />
Da haben die Sekten wohl vergessen einige Posten zu unterwandern.<br />
<br />
<a href="http://www2.ohchr.org/english/bodies/hrc/docs/gc34.pdf">General Comment No. 34</a> 
            </div>
        </content>
        <dc:subject>ICCPR</dc:subject>
<dc:subject>Sekte</dc:subject>
<dc:subject>UNO</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/518-Religionsdebatte-in-der-SPD.html" rel="alternate" title="Religionsdebatte in der SPD" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-08-14T17:25:00Z</published>
        <updated>2011-08-14T17:25:00Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=518</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=518</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/5-Kramkiste" label="Kramkiste" term="Kramkiste" />
    
        <id>http://www.frank-busse.de/blag/archives/518-guid.html</id>
        <title type="html">Religionsdebatte in der SPD</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <a href="http://www.spiegel.de/politik/deutschland/0,1518,777968,00.html">Trennung von Staat und Kirche? Um Gottes Willen!</a><br />
<br />
<blockquote><strong>Die Domain</strong> www.spd-laizisten.de <strong>wurde ihnen von der Parteiführung untersagt</strong>, jetzt sind sie unter www.laizistische-sozis.de zu erreichen. Ganz schön viel Repression gegen einen Verband, dem mit Ingrid Matthäus-Maier, Rolf Schwanitz und Doris Barnett auch einige prominentere Sozialdemokraten angehören. <strong>Die SPD will die Laizisten jedenfalls nicht einmal als offiziellen Arbeitskreis anerkennen.</strong></blockquote><br />
Die Insiderberichte von Mobbing und vom Abschneiden vom Informationsfluss, sobald man sich als Laizist zu erkennen gibt, scheinen also zu stimmen.<br />
<br />
<blockquote>Sehr zur Freude von Wolfgang Thierse, dem Sprecher des Arbeitskreises "Christen in der SPD". Der hatte schon zuvor die Befürchtung geäußert, seine Partei werde durch die 500 eingetragenen Laizisten "thematisch eingeengt." Was Lösch zu der Frage bringt, "wo denn die Einengung ist, wenn es uns nicht geben darf, aber einen Arbeitskreis Christen?"</blockquote><br />
Gerade Thierse, der mit seinem mangelnden Demokratieverständnis hier in Dresden alljährlich im Februar auffällt. Ein Toleranzverständnis, wie es in den Kirchen gepredigt wird und das an der eigenen Pforte aufhört.<br />
<br />
<blockquote>Auch die Bundestagsabgeordnete Kerstin Griese habe sich gegen den Verband ausgesprochen mit der Behauptung, der Laizismus widerspreche Teilen des SPD-Programms.</blockquote><br />
Die SPD ist eh unwählbar, ob die jetzt auch noch die Kirche als Parteiführung haben, spielt keine Rolle mehr. 
            </div>
        </content>
        <dc:subject>Barnett</dc:subject>
<dc:subject>Griese</dc:subject>
<dc:subject>Lindner</dc:subject>
<dc:subject>Lösch</dc:subject>
<dc:subject>Matthäus-Maier</dc:subject>
<dc:subject>SPD</dc:subject>
<dc:subject>Schwanitz</dc:subject>
<dc:subject>Sekte</dc:subject>
<dc:subject>Thierse</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/516-checking-string-routines-with-Klee.html" rel="alternate" title="checking string routines with Klee" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-08-09T17:14:29Z</published>
        <updated>2011-08-21T15:01:06Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=516</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=516</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/2-Informatik" label="Informatik" term="Informatik" />
    
        <id>http://www.frank-busse.de/blag/archives/516-guid.html</id>
        <title type="html">checking string routines with Klee</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Two months ago I discovered some bugs in <a href="http://www.libpng.org/pub/png/libpng.html">libpng</a> (<a href="http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2011-2501">CVE-2011-2501</a>, <a href="http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2011-2692">CVE-2011-2692</a>). In the <a href="http://sourceforge.net/mailarchive/message.php?msg_id=27625024">discussion</a>¹ of the second bug I have criticized that libpng is often too permissive in the chunk validation. An example was the unchecked use of strtod(), which allows "infinity" or "nan" as valid values in the ASCII floating point representation in sCAL or pCAL chunks.<br />
<br />
These chunks contain byte strings in a quite <a href="http://www.libmng.com/pub/png/spec/register/pngext-1.3.0-pdg.txt.gz">simple format</a>:<br />
<blockquote><h2>1.2. Floating-point values</h2><br />
<br />
The core of PNG does not use floating-point numbers anywhere; it uses integers or, where applicable, fixed-point fractional values. However, special-purpose chunks may need to represent values that do not fit comfortably in fixed-point notation. The textual floating-point notation defined here is recommended for use in all such cases. This representation is simple, has no a priori limits on range or precision, and is portable across all machines.<br />
<br />
A floating-point value in this notation is represented by an ASCII text string in a standardized decimal floating-point format. The string is variable-length and must be terminated by a null (zero) character unless it is the last item in its chunk. The string consists of an optional sign ("+" or "-"), an integer part, a fraction part beginning with a decimal point ("."), and an exponent part beginning with an "E" or "e" and optional sign. The integer, fraction, and exponent parts each contain one or more digits (ASCII "0" to "9"). Either the integer part or the fraction part, but not both, may be omitted. A decimal point is allowed, but not required, if there is no fraction part. The exponent part may be omitted. No spaces or any other character besides those specified may appear.<br />
<br />
Note in particular that C-language "F" and "L" suffixes are not allowed, the string "." is not allowed as a shorthand for 0 as in some other programming languages, and no commas or underscores are allowed. This format ought to be easily readable in all programming environments. </blockquote><br />
<br />
Later I wondered, if I can use <a href="http://klee.llvm.org/">KLEE</a> to find specification mismatches in string handling routines. And what should I say, it worked. I just tested in one direction: if strtod() returns without an error, the string should be valid according to the PNG specification. Of course that's wrong, but this assumption should reveal the cases where the strtod() implementation and the PNG specification differ.<br />
<br />
<div class="c geshi" style="text-align: left"><br /><span style="color: #339933;">#include &lt;assert.h&gt;</span><br /><span style="color: #339933;">#include &lt;ctype.h&gt;</span><br /><span style="color: #339933;">#include &lt;errno.h&gt;</span><br /><span style="color: #339933;">#include &lt;math.h&gt;</span><br /><span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br /><span style="color: #339933;">#include &lt;string.h&gt;</span><br /><br /><span style="color: #339933;">#include &lt;klee/klee.h&gt;</span><br /><br /><span style="color: #993333;">int</span> is_png_fp<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span> p<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">*</span> pe<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&#160; &#160; &#160; &#160; <span style="color: #993333;">int</span> cs<span style="color: #339933;">;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #339933;">%%</span><span style="color: #009900;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; machine png_fp<span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; write data<span style="color: #339933;">;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; main <span style="color: #339933;">:=</span> <span style="color: #009900;">&#91;</span><span style="color: #339933;">+</span>\<span style="color: #339933;">-</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span> <span style="color: #ff0000;">'.'</span><span style="color: #339933;">?</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span> <span style="color: #ff0000;">'.'</span> <span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'.'</span> <span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>Ee<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">+</span>\<span style="color: #339933;">-</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; write init<span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; write exec<span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; <span style="color: #009900;">&#125;</span><span style="color: #339933;">%%</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> cs <span style="color: #339933;">&gt;=</span> png_fp_first_final<span style="color: #339933;">;</span><br /><span style="color: #009900;">&#125;</span><br /><br /><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><br />&#160; &#160; &#160; &#160; <span style="color: #993333;">double</span> d<span style="color: #339933;">;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #666666; font-style: italic;">// create symbolic string</span><br />&#160; &#160; &#160; &#160; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>s &#160;<span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;____&quot;</span><span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; klee_make_symbolic<span style="color: #009900;">&#40;</span>s<span style="color: #339933;">,</span><span style="color: #0000dd;">5</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;s&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; s<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>se <span style="color: #339933;">=</span> s <span style="color: #339933;">+</span> <a href="http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span style="color: #000066;">strlen</span></a><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>se_<span style="color: #339933;">=</span> se<span style="color: #339933;">;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #666666; font-style: italic;">// call strtod and omit error cases</span><br />&#160; &#160; &#160; &#160; errno <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; d <span style="color: #339933;">=</span> <a href="http://www.opengroup.org/onlinepubs/009695399/functions/strtod.html"><span style="color: #000066;">strtod</span></a><span style="color: #009900;">&#40;</span>s<span style="color: #339933;">,&amp;</span>se_<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>errno <span style="color: #339933;">!=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>s <span style="color: #339933;">==</span> se_<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; klee_silent_exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&#160; &#160; &#160; &#160; <span style="color: #009900;">&#125;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #666666; font-style: italic;">// ---- mismatches ----</span><br />&#160; &#160; &#160; &#160; <span style="color: #666666; font-style: italic;">// data: '0z\x00\x00\x00' (allowed trailing characters)</span><br />&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>se_ <span style="color: #339933;">!=</span> <span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> klee_silent_exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #666666; font-style: italic;">// data: '\x0c0\x00\x00\x00' (allowed leading whitespace)</span><br />&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.opengroup.org/onlinepubs/009695399/functions/isspace.html"><span style="color: #000066;">isspace</span></a><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> klee_silent_exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #666666; font-style: italic;">// data: 'iNF\x00\x00' (infinity)</span><br />&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>isinf<span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> klee_silent_exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #666666; font-style: italic;">// data: 'nAN\x00\x00' (not a number)</span><br />&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>isnan<span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> klee_silent_exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #666666; font-style: italic;">// assertion: s is in png ascii floating point format</span><br />&#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/assert.html"><span style="color: #000066;">assert</span></a><span style="color: #009900;">&#40;</span>is_png_fp<span style="color: #009900;">&#40;</span>s<span style="color: #339933;">,</span>se<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br /><span style="color: #009900;">&#125;</span></div><br />
<br />
For the description of the floating point strings I used a regular expression. In is_png_fp() this regular expression is converted into an automaton via <a href="http://www.complang.org/ragel/">ragel</a> to forgo unnecessary regex-libraries. If one runs the example code with KLEE, the cases in the "mismatches"-section break the assertion. Leading whitespaces, trailing characters, infinity and not a number - all valid in C99/POSIX/GNU but not in PNG. At first I missed the hexadecimal representation but then I realized, that the uclibc I use with KLEE was build without hex-support.<br />
<br />
A quick sample run with commented mismatch section in example.c for those who want to follow my short notes. ;)<br />
<div class="bash geshi" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&gt;</span>ragel <span style="color: #660033;">-m</span> <span style="color: #660033;">-o</span> gen.c example.c<br /><span style="color: #000000; font-weight: bold;">&gt;</span>llvm-gcc <span style="color: #660033;">-c</span> <span style="color: #660033;">-emit-llvm</span> -I<span style="color: #000000; font-weight: bold;">&lt;</span>path to klee<span style="color: #000000; font-weight: bold;">&gt;/</span>include gen.c <span style="color: #660033;">-o</span> genc<br /><span style="color: #000000; font-weight: bold;">&gt;</span>klee <span style="color: #660033;">--libc</span>=uclibc <span style="color: #660033;">--optimize</span> <span style="color: #660033;">--only-output-states-covering-new</span> .<span style="color: #000000; font-weight: bold;">/</span>genc<br />KLEE: output directory = <span style="color: #ff0000;">&quot;klee-out-37&quot;</span><br />WARNING: While resolving call to <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #ff0000;">'__user_main'</span> arguments were dropped<span style="color: #000000; font-weight: bold;">!</span><br />KLEE: WARNING: undefined reference to function: _stdio_term<br />KLEE: WARNING: undefined reference to function: fcntl<br />KLEE: WARNING: undefined reference to function: fstat<br />KLEE: WARNING: undefined reference to function: open<br />KLEE: WARNING: executable has module level assembly <span style="color: #7a0874; font-weight: bold;">&#40;</span>ignoring<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />KLEE: WARNING: silently concretizing <span style="color: #7a0874; font-weight: bold;">&#40;</span>reason: floating point<span style="color: #7a0874; font-weight: bold;">&#41;</span> expression <span style="color: #7a0874; font-weight: bold;">&#40;</span>Add w32 <span style="color: #000000;">4294967248</span><br />&#160; &#160; &#160; &#160; &#160;<span style="color: #7a0874; font-weight: bold;">&#40;</span>SExt w32 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Read w8 <span style="color: #000000;">0</span> arr1<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> to value <span style="color: #000000;">7</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>:<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />KLEE: ERROR: ASSERTION FAIL: is_png_fp<span style="color: #7a0874; font-weight: bold;">&#40;</span>s,se<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />KLEE: NOTE: now ignoring this error at this location<br /><br />KLEE: done: total instructions = <span style="color: #000000;">154995</span><br />KLEE: done: completed paths = <span style="color: #000000;">645</span><br />KLEE: done: generated tests = <span style="color: #000000;">13</span></div><br />
<br />
The first found case are the trailing characters:<br />
<div class="bash geshi" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&gt;</span>ktest-tool klee-last<span style="color: #000000; font-weight: bold;">/</span>test000002.ktest<br />ktest <span style="color: #c20cb9; font-weight: bold;">file</span> : <span style="color: #ff0000;">'klee-last/test000002.ktest'</span><br />args &#160; &#160; &#160; : <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'./genc'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />num objects: <span style="color: #000000;">1</span><br />object &#160; &#160;<span style="color: #000000;">0</span>: name: <span style="color: #ff0000;">'s'</span><br />object &#160; &#160;<span style="color: #000000;">0</span>: size: <span style="color: #000000;">5</span><br />object &#160; &#160;<span style="color: #000000;">0</span>: data: <span style="color: #ff0000;">'777z\x00'</span></div><br />
<br />
A satisfying regular expression is:<br />
<div class="c geshi" style="text-align: left"><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; dec &#160; &#160;<span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #339933;">+</span>\<span style="color: #339933;">-</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span> <span style="color: #ff0000;">'.'</span><span style="color: #339933;">?</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span> <span style="color: #ff0000;">'.'</span> <span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'.'</span> <span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>Ee<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">+</span>\<span style="color: #339933;">-</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">-</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; main &#160;<span style="color: #339933;">:=</span> space<span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>inf<span style="color: #339933;">/</span>i <span style="color: #339933;">|</span> <span style="color: #339933;">/</span>nan<span style="color: #339933;">/</span>i <span style="color: #339933;">|</span> dec<span style="color: #009900;">&#41;</span> any<span style="color: #339933;">*;</span></div><br />
Keep in mind, that this is no equivalence check. The defined language could be a superset of the language of the accepted strings of strtod().<br />
<br />
The corresponding automata images were generated with <a href="http://www.graphviz.org/">dot</a>:<br />
<div class="bash geshi" style="text-align: left"><span style="color: #000000; font-weight: bold;">&gt;</span>ragel <span style="color: #660033;">-mpV</span> example.c <span style="color: #000000; font-weight: bold;">|</span> dot <span style="color: #660033;">-Tgif</span> <span style="color: #660033;">-o</span> ragel_strtod.gif</div><br />
<br />
strtod():<br />
<a href="http://frank-busse.de/bilder/rechner/ragel_strtod.gif"><img src="http://frank-busse.de/bilder/rechner/ragel_strtod_small.gif" alt="strtod automaton" /></a><br />
<br />
png floating point:<br />
<a href="http://frank-busse.de/bilder/rechner/ragel_pngfp.gif"><img src="http://frank-busse.de/bilder/rechner/ragel_pngfp_small.gif" alt="png floating point automaton" /></a><br />
<br />
Papers you might be interested in:<br />
<ul><br />
<li><a href="http://people.csail.mit.edu/akiezun/issta54-kiezun.pdf">A. Kiezun, V. Ganesh, P. J. Guo. HAMPI: A Solver for String Constraints</a></li><br />
<li><a href="http://www.usenix.org/event/osdi08/tech/full_papers/cadar/cadar.pdf">C. Cadar, D. Dunbar, D. Engler. KLEE: Unassisted and Automatic Generation of High-Coverage Tests for Complex Systems Programs</a></li><br />
<li><a href="http://keeda.stanford.edu/~daramos/papers/ucklee-cav-2011.pdf">D. Ramos, D. Engler. Practical, low-effort equivalence verification of real code</a></li><br />
<li><a href="http://www3.nccu.edu.tw/~yuf/spin08.pdf">F. Yu, T. Bultan, M. Cova, O. Ibarra. Symbolic String Verification: An Automata-based Approach</a></li><br />
</ul><br />
<br />
¹ No, I still don't know their definition of "non-positive". 
            </div>
        </content>
        <dc:subject>C</dc:subject>
<dc:subject>Klee</dc:subject>
<dc:subject>dot</dc:subject>
<dc:subject>ragel</dc:subject>
<dc:subject>regular expression</dc:subject>
<dc:subject>strtod</dc:subject>
<dc:subject>uclibc</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/515-33.-Kirchentag.html" rel="alternate" title="33. Kirchentag" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-06-05T10:21:00Z</published>
        <updated>2011-06-13T21:56:54Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=515</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=515</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/5-Kramkiste" label="Kramkiste" term="Kramkiste" />
    
        <id>http://www.frank-busse.de/blag/archives/515-guid.html</id>
        <title type="html">33. Kirchentag</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <img src="http://frank-busse.de/bilder/dresden/kirchentag_kirche_ueberfuellt.jpeg" alt="Frauenkirche überfüllt" /><br />
<br />
Endlich überstanden. Bei all den Opfern klerikaler Gehirnwäsche konnte man gar nicht so schnell zwischen Mitleid und Fremdschämen wechseln, wie es angebracht war. In jeder Straße, auf jedem Platz, in jedem Saal nur grüne Schals und violette Werbung. Der Gang durch die Innenstadt wurde zur Tortur: langweilige Predigten, schlechte Musikanten und dazwischen evangelikale Menschenfänger und debil grinsende Handzettelverteiler. Besonders deprimierend war es, wieder einmal vor Augen gehalten zu bekommen, wie unterwandert die Gesellschaft von diesem Menschheitsvirus ist. Sämtliche Parteien gaben sich ein Stelldichein, die Uni machte mit, das Rathaus flaggte, hohe Medienvertreter kamen und auch unsere politische Führung folgte dem Ruf der Sekten: Günter Beckstein, Joachim Gauck, Katrin Göring-Eckardt, Reinhard Höppner, Hannelore Kraft, Renate Künast, Hans Leyendecker, Thomas de Maizière, Angela Merkel, Andrea Nahles, Claudia Roth, Norbert Röttgen, Annette Schavan, Frank-Walter Steinmeier, Stanislaw Tillich, Christian Wulff usw. usf.<br />
<br />
<img src="http://frank-busse.de/bilder/dresden/kirchentag_rathaus.jpeg" alt="Rathaus" /><br />
<br />
Man machte auch keinen Hehl daraus:<br />
<br />
<img src="http://frank-busse.de/bilder/dresden/kirchentag_sz.png" alt="sz" /><br />
<br />
und kam mit gefälligen Themen, wie dem Atomausstieg, ein bisschen Umwelt- und Friedenspolitik und dem bösen Rechtsextremismus. Captain Obvious kam viel zu oft zu Wort.<br />
<br />
Die konfessionslosen Dresdner (80%) machten einen großen Bogen um die Innenstadt und ärgern sich über die 7,9Mio. Euro Steuergelder, die für diese unnütze Vereinsfeier aus dem Fenster geworfen wurden.<br />
<br />
Baden im Ganges:<br />
<img src="http://frank-busse.de/bilder/dresden/kirchentag_elbufer.jpeg" alt="Baden im Ganges" /><br />
<br />
Jesus mit Fahrrad:<br />
<img src="http://frank-busse.de/bilder/dresden/kirchentag_fahrrad.jpeg" alt="Jesus mit Fahrrad" /><br />
<br />
Martin Luther höchstpersönlich:<br />
<img src="http://frank-busse.de/bilder/dresden/kirchentag_martin_luther.jpeg" alt="Martin Luther" /><br />
<br />
Ökopolitik:<br />
<img src="http://frank-busse.de/bilder/dresden/kirchentag_solarkreuz.jpeg" alt="Ökopolitik" /><br />
<br />
Werner "Glauben Sie, dass Ihr Opa ein Affe war?" Nachtigal:<br />
<img src="http://frank-busse.de/bilder/dresden/kirchentag_wanderprediger.jpeg" alt="Wanderprediger" /><br />
<br />
Wir befinden uns im Jahre 2011 n. Chr. Ganz Dresden ist von Sektierern besetzt. Ganz Dresden? Nein! Eine von <a href="http://www.gbsdd.de/">unbeugsamen Humanisten</a> bevölkerte <a href="http://www.schauburg-dresden.de/">Burg</a> hört nicht auf, dem Eindringling Widerstand zu leisten.<br />
<br />
Zum Glück gab es die Veranstaltungen des GeFAHR eV. um den violetten Stumpfsinn zumindest kurzzeitig zu vergessen. Es kamen ua. <a href="http://www.carstenfrerk.de/">Carsten Frerk</a>, <a href="http://www.jesuswahn.de/">Heinz-Werner Kubitza</a> und <a href="http://www.schmidt-salomon.de/">Michael Schmidt-Salomon</a>.<br />
<br />
<img src="http://frank-busse.de/bilder/dresden/kirchentag_vortraege.jpeg" alt="Vorträge GeFAHR eV." /><br />
<br />
<strong>Zitate:</strong><br />
<blockquote>"Durch zwei Diktaturen hat die Weitergabe des Glaubens im Osten einen Bruch erlebt", analysiert Dietrich Bauer, Dezernent für Gemeindeaufbau in der Evangelisch-lutherischen Landeskirche Sachsens. "Die Menschen sagen, sie seien ohne christlichen Glauben glücklich und <b>könnten</b> Probleme lösen."</blockquote><br />
<blockquote>Genauso erklärt auch Albrecht Steinäuser die große Schere zwischen Werten und Glauben: "Viele Menschen verbinden nichts mehr mit christlichem Glauben und führen die Werte nicht unbedingt auf das Christentum zurück."</blockquote><br />
(<a href="http://www.evangelisch.de/themen/religion/missionsfeld-ostdeutschland-kirchentag-zur-richtigen-zeit41195">evangelisch.de</a>)<br />
<br />
<blockquote>Derzeit hat die [Giordano-Bruno-]Stiftung mehr als 2.500 Fördermitglieder. Das ist auf den ersten Blick nicht viel. Was hier zählt, ist jedoch weniger die Zahl der Unterstützer als vielmehr <b>deren politischer Einfluss</b>. So hat vor einiger Zeit Ingrid Matthäus-Maier, viele Jahre stellvertretende Vorsitzende der SPD-Bundestagsfraktion, ihre Mitarbeit erklärt. Über sie laufen die Bemühungen, einen sogenannten "Laizistischen Arbeitskreis in der SPD" zu gründen. Vorerst hat der SPD-Parteivorstand dieses Ansinnen abgelehnt. Aber was nicht ist, kann Dank reger Kontaktpflege ja noch werden.</blockquote><br />
(<a href="http://www.evangelisch.de/themen/religion/bizarre-ideen-derbe-polemik-kirchenkritiker-machen-mobil34371">evangelisch.de</a>) 
            </div>
        </content>
        <dc:subject>Beckstein</dc:subject>
<dc:subject>DEKT</dc:subject>
<dc:subject>Dresden</dc:subject>
<dc:subject>Frerk</dc:subject>
<dc:subject>Gauck</dc:subject>
<dc:subject>Göring-Eckardt</dc:subject>
<dc:subject>Höppner</dc:subject>
<dc:subject>Kirchentag</dc:subject>
<dc:subject>Kraft</dc:subject>
<dc:subject>Kubitza</dc:subject>
<dc:subject>Künast</dc:subject>
<dc:subject>Leyendecker</dc:subject>
<dc:subject>Maizière</dc:subject>
<dc:subject>Nahles</dc:subject>
<dc:subject>Roth</dc:subject>
<dc:subject>Röttgen</dc:subject>
<dc:subject>Schavan</dc:subject>
<dc:subject>Schmidt-Salomon</dc:subject>
<dc:subject>Sekte</dc:subject>
<dc:subject>Steinmeier</dc:subject>
<dc:subject>Tillich</dc:subject>
<dc:subject>Wulff</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/514-resort-PNG-chunks.html" rel="alternate" title="resort PNG chunks" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-04-05T15:09:43Z</published>
        <updated>2011-04-05T16:41:11Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=514</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=514</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/2-Informatik" label="Informatik" term="Informatik" />
    
        <id>http://www.frank-busse.de/blag/archives/514-guid.html</id>
        <title type="html">resort PNG chunks</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                If you ever needed to resort or drop chunks in a png file or to repair the signature and crc values, this one-evening-hack might be useful next time.<br />
<br />
Resort chunks:<br />
<div class="bash geshi" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&gt;</span>.<span style="color: #000000; font-weight: bold;">/</span>png_resort.py brokensuite<span style="color: #000000; font-weight: bold;">/</span>hist_after_idat.png foo.png<br />File: brokensuite<span style="color: #000000; font-weight: bold;">/</span>hist_after_idat.png<br />No. Type <span style="color: #7a0874; font-weight: bold;">&#40;</span>Position,Length<span style="color: #7a0874; font-weight: bold;">&#41;</span><br /><span style="color: #660033;">--------------------------</span><br />&#160;<span style="color: #000000;">0</span>. IHDR <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">8</span>,<span style="color: #000000;">25</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">1</span>. gAMA <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">33</span>,<span style="color: #000000;">16</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">2</span>. sBIT <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">49</span>,<span style="color: #000000;">15</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">3</span>. PLTE <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">64</span>,<span style="color: #000000;">57</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">4</span>. IDAT <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">121</span>,<span style="color: #000000;">83</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">5</span>. hIST <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">204</span>,<span style="color: #000000;">42</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">6</span>. IEND <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">246</span>,<span style="color: #000000;">12</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />Enter new order <span style="color: #7a0874; font-weight: bold;">&#40;</span>p.ex.: <span style="color: #000000;">0</span>,<span style="color: #000000;">3</span>..<span style="color: #000000;">5</span>,<span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #000000;">0</span>..<span style="color: #000000;">3</span>,<span style="color: #000000;">5</span>,<span style="color: #000000;">4</span>,<span style="color: #000000;">6</span><br />New order: <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>, <span style="color: #000000;">1</span>, <span style="color: #000000;">2</span>, <span style="color: #000000;">3</span>, <span style="color: #000000;">5</span>, <span style="color: #000000;">4</span>, <span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />&#160;</div><br />
<br />
Drop chunks and repair crc:<br />
<div class="bash geshi" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&gt;</span>.<span style="color: #000000; font-weight: bold;">/</span>png_resort.py brokensuite<span style="color: #000000; font-weight: bold;">/</span>chunk_crc.png bar.png<br />File: brokensuite<span style="color: #000000; font-weight: bold;">/</span>chunk_crc.png<br />No. Type <span style="color: #7a0874; font-weight: bold;">&#40;</span>Position,Length<span style="color: #7a0874; font-weight: bold;">&#41;</span><br /><span style="color: #660033;">--------------------------</span><br /><span style="color: #7a0874; font-weight: bold;">&#91;</span>Error<span style="color: #7a0874; font-weight: bold;">&#93;</span> Test failed: chunk crc<br />repair crc <span style="color: #7a0874; font-weight: bold;">&#91;</span>y<span style="color: #000000; font-weight: bold;">|</span>n<span style="color: #7a0874; font-weight: bold;">&#93;</span>:y<br />&#160;<span style="color: #000000;">0</span>. IHDR <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">8</span>,<span style="color: #000000;">25</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">1</span>. gAMA <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">33</span>,<span style="color: #000000;">16</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">2</span>. PLTE <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">49</span>,<span style="color: #000000;">780</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">3</span>. IDAT <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">829</span>,<span style="color: #000000;">445</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />&#160;<span style="color: #000000;">4</span>. IEND <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1274</span>,<span style="color: #000000;">12</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />Enter new order <span style="color: #7a0874; font-weight: bold;">&#40;</span>p.ex.: <span style="color: #000000;">0</span>,<span style="color: #000000;">3</span>..<span style="color: #000000;">5</span>,<span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #000000;">0</span>,<span style="color: #000000;">2</span>..<span style="color: #000000;">4</span><br />New order: <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>, <span style="color: #000000;">2</span>, <span style="color: #000000;">3</span>, <span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />&#160;</div><br />
<br />
For huge chunks you have to implement a more intelligent buffering (see read_bytes and writing).<br />
<br />
<div class="python geshi" style="text-align: left"><br /><span style="color: #808080; font-style: italic;">#!/usr/bin/python3</span><br /><br /><span style="color: #808080; font-style: italic;"># select chunks from infile.png and write them resorted to outfile.png</span><br /><br /><span style="color: #808080; font-style: italic;"># usage: png_resort.py &lt;infile.png&gt; &lt;outfile.png&gt;</span><br /><span style="color: #808080; font-style: italic;"># user input:</span><br /><span style="color: #808080; font-style: italic;"># &#160; comma separated list of chunk indices or index ranges</span><br /><span style="color: #808080; font-style: italic;"># &#160; &#160; p.ex.: 0,2..4,1,5</span><br /><span style="color: #808080; font-style: italic;"># &#160; or 'exit'</span><br /><br /><span style="color: #808080; font-style: italic;"># Literature</span><br /><span style="color: #808080; font-style: italic;"># ----------</span><br /><span style="color: #808080; font-style: italic;"># Portable Network Graphics (PNG) Specification (Second Edition)</span><br /><br /><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">readline</span><span style="color: #66cc66;">,</span><span style="color: #dc143c;">struct</span><span style="color: #66cc66;">,</span><span style="color: #dc143c;">sys</span><span style="color: #66cc66;">,</span><span style="color: #dc143c;">zlib</span> <span style="color: #808080; font-style: italic;"># drop readline for less dependencies and comfort</span><br /><span style="color: #ff7700;font-weight:bold;">from</span> functools <span style="color: #ff7700;font-weight:bold;">import</span> *<br /><span style="color: #ff7700;font-weight:bold;">from</span> io <span style="color: #ff7700;font-weight:bold;">import</span> *<br /><br /><br /><br />png_signature <span style="color: #66cc66;">=</span> b<span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\x</span>89<span style="color: #000099; font-weight: bold;">\x</span>50<span style="color: #000099; font-weight: bold;">\x</span>4e<span style="color: #000099; font-weight: bold;">\x</span>47<span style="color: #000099; font-weight: bold;">\x</span>0d<span style="color: #000099; font-weight: bold;">\x</span>0a<span style="color: #000099; font-weight: bold;">\x</span>1a<span style="color: #000099; font-weight: bold;">\x</span>0a'</span><br /><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> print_error<span style="color: black;">&#40;</span>*msgs<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;print highlighted error message(s)&quot;&quot;&quot;</span><br /><br />&#160; &#160; &#160; &#160; msgs <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">' '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: #66cc66;">,</span>msgs<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[1;31m[Error] {0}<span style="color: #000099; font-weight: bold;">\0</span>33[1;m'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>msgs<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br /><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span>title<span style="color: #66cc66;">,</span>condition<span style="color: #66cc66;">,</span>val<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;test condition, if false print test title and (maybe) val&quot;&quot;&quot;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> condition: <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; s <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'Test failed: {0} ({1})'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>title<span style="color: #66cc66;">,</span>s<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">if</span> val <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: #483d8b;">'Test failed: {0}'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>title<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span><br /><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> check_png_signature<span style="color: black;">&#40;</span>f<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;read and validate png file signature&quot;&quot;&quot;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># file signature (5.2)</span><br />&#160; &#160; &#160; &#160; sig <span style="color: #66cc66;">=</span> f.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">8</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> \<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'signature length'</span><span style="color: #66cc66;">,</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>sig<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">8</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> \<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'signature'</span><span style="color: #66cc66;">,</span>sig <span style="color: #66cc66;">==</span> png_signature<span style="color: black;">&#41;</span><br /><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> is_png_uint32<span style="color: black;">&#40;</span>val<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># (7.1)</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #ff4500;">0</span> <span style="color: #66cc66;">&lt;=</span> val <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">2</span>**<span style="color: #ff4500;">31</span><br /><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> png_chunks<span style="color: black;">&#40;</span>f<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;file -&gt; [{'type','pos','length'[,'crc']}]&quot;&quot;&quot;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># chunk layout (5.3)</span><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># +-------------------------------------------------+</span><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># | length (4) | type (4) | data (length) | crc (4) |</span><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># +-------------------------------------------------+</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">def</span> read_bytes<span style="color: black;">&#40;</span>name<span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;read length bytes&quot;&quot;&quot;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; val <span style="color: #66cc66;">=</span> f.<span style="color: black;">read</span><span style="color: black;">&#40;</span>length<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>val<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span> length:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span><span style="color: #483d8b;">'{0} &lt; {1}'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>name<span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">raise</span> <span style="color: #008000;">ValueError</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>: <span style="color: #ff7700;font-weight:bold;">return</span> val<br /><br /><br />&#160; &#160; &#160; &#160; ret <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />&#160; &#160; &#160; &#160; cnt <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'No. Type (Position,Length)<span style="color: #000099; font-weight: bold;">\n</span>'</span>+<span style="color: #483d8b;">'-'</span>*<span style="color: #ff4500;">26</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># read chunk</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; pos <span style="color: #66cc66;">=</span> f.<span style="color: black;">tell</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; length_ <span style="color: #66cc66;">=</span> f.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>length_<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">4</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: black;">&#40;</span>length<span style="color: #66cc66;">,</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">struct</span>.<span style="color: black;">unpack_from</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'!I'</span><span style="color: #66cc66;">,</span>length_<span style="color: #66cc66;">,</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; type_ <span style="color: #66cc66;">=</span> read_bytes<span style="color: black;">&#40;</span><span style="color: #483d8b;">'chunk type'</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; data &#160;<span style="color: #66cc66;">=</span> read_bytes<span style="color: black;">&#40;</span><span style="color: #483d8b;">'chunk data'</span><span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">if</span> length <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span> <span style="color: #ff7700;font-weight:bold;">else</span> b<span style="color: #483d8b;">''</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; crc__ <span style="color: #66cc66;">=</span> read_bytes<span style="color: black;">&#40;</span><span style="color: #483d8b;">'chunk crc'</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">except</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span><span style="color: #483d8b;">'defective chunk'</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">break</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #008000;">type</span> <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">''</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #008000;">type</span> <span style="color: #66cc66;">=</span> type_.<span style="color: black;">decode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'ascii'</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">except</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span><span style="color: #483d8b;">'non-ascii characters in type'</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #008000;">type</span> <span style="color: #66cc66;">=</span> type_.<span style="color: black;">decode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'ascii'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'replace'</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: black;">&#40;</span>crc_<span style="color: #66cc66;">,</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">struct</span>.<span style="color: black;">unpack_from</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'!I'</span><span style="color: #66cc66;">,</span>crc__<span style="color: #66cc66;">,</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; zcrc <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">zlib</span>.<span style="color: black;">crc32</span><span style="color: black;">&#40;</span>type_+data<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; crc <span style="color: #66cc66;">=</span> crc_ <span style="color: #66cc66;">==</span> zcrc<br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; chunk_attrs <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">'type'</span>:<span style="color: #008000;">type</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'pos'</span>:pos<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'length'</span>:length+<span style="color: #ff4500;">12</span><span style="color: black;">&#125;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># (5.1)</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'chunk length limit'</span><span style="color: #66cc66;">,</span>is_png_uint32<span style="color: black;">&#40;</span>length<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>length<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># check crc and repair</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'chunk crc'</span><span style="color: #66cc66;">,</span>crc<span style="color: #66cc66;">,</span>crc<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; c <span style="color: #66cc66;">=</span> <span style="color: #008000;">input</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'repair crc [y|n]:'</span><span style="color: black;">&#41;</span>.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> c <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'y'</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; chunk_attrs<span style="color: black;">&#91;</span><span style="color: #483d8b;">'crc'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">struct</span>.<span style="color: black;">pack</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'!I'</span><span style="color: #66cc66;">,</span>zcrc<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">break</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">elif</span> c <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'n'</span>: <span style="color: #ff7700;font-weight:bold;">break</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>: print_error<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;wrong input, just y or n&quot;</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; ret.<span style="color: black;">append</span><span style="color: black;">&#40;</span>chunk_attrs<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'{3:&gt;2}. {0} ({1},{2})'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span><span style="color: #008000;">type</span><span style="color: #66cc66;">,</span>pos<span style="color: #66cc66;">,</span>length+<span style="color: #ff4500;">12</span><span style="color: #66cc66;">,</span>cnt<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; cnt +<span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># eof</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>length_<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">0</span>: <span style="color: #ff7700;font-weight:bold;">break</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># error</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span><span style="color: #483d8b;">'defective chunk length'</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">break</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> ret<br /><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> order_from_string<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;create list of numbers from string s&quot;&quot;&quot;</span><br /><br />&#160; &#160; &#160; &#160; err <span style="color: #66cc66;">=</span> <span style="color: #008000;">False</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">def</span> convert<span style="color: black;">&#40;</span>si<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">nonlocal</span> err<br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> si <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">''</span>: <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># simple integer conversion</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; i <span style="color: #66cc66;">=</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>si<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">except</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># range notation</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; a<span style="color: #66cc66;">,</span>b <span style="color: #66cc66;">=</span> si.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'..'</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; c<span style="color: #66cc66;">,</span>d <span style="color: #66cc66;">=</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>a<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>b<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; l &#160; <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> c <span style="color: #66cc66;">&lt;</span> d:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; l <span style="color: #66cc66;">=</span> <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: #008000;">range</span><span style="color: black;">&#40;</span>c<span style="color: #66cc66;">,</span>d+<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; l <span style="color: #66cc66;">=</span> <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: #008000;">range</span><span style="color: black;">&#40;</span>d<span style="color: #66cc66;">,</span>c+<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; l.<span style="color: black;">reverse</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">except</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span><span style="color: #483d8b;">'unknown representation:'</span><span style="color: #66cc66;">,</span>si<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; err <span style="color: #66cc66;">=</span> <span style="color: #008000;">True</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>: <span style="color: #ff7700;font-weight:bold;">return</span> l<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>: <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><br /><br /><br />&#160; &#160; &#160; &#160; order <span style="color: #66cc66;">=</span> <span style="color: #008000;">reduce</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x<span style="color: #66cc66;">,</span>i:x+convert<span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>s.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">','</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> order <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> err <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: #008000;">None</span><br /><br /><br /><br /><span style="color: #ff7700;font-weight:bold;">if</span> __name__ <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'__main__'</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># command line arguments</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">!=</span> <span style="color: #ff4500;">3</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span><span style="color: #483d8b;">'Incorrect number of arguments.<span style="color: #000099; font-weight: bold;">\n</span>'</span> \<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #483d8b;">'usage: png_resort.py &lt;infile.png&gt; &lt;outfile.png&gt;'</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; exit<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># read file</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; infile_name <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\0</span>33[1;32mFile: {0}<span style="color: #000099; font-weight: bold;">\0</span>33[1;m'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>infile_name<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">with</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>infile_name<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'rb'</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">as</span> infile:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># read signature</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; check_png_signature<span style="color: black;">&#40;</span>infile<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># read chunks</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; chunks <span style="color: #66cc66;">=</span> png_chunks<span style="color: black;">&#40;</span>infile<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>chunks<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">0</span>: exit<span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># ask for new order</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #dc143c;">cmd</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">input</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Enter new order (p.ex.: 0,3..5,2): '</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #dc143c;">cmd</span> <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">cmd</span>.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">cmd</span> <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'exit'</span>: exit<span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; order <span style="color: #66cc66;">=</span> order_from_string<span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> order <span style="color: #66cc66;">==</span> <span style="color: #008000;">None</span>: <span style="color: #ff7700;font-weight:bold;">continue</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'New order: {0}'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>order<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># check new order</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">reduce</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> b<span style="color: #66cc66;">,</span>v: b <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #ff4500;">0</span> <span style="color: #66cc66;">&lt;=</span> v <span style="color: #66cc66;">&lt;</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>chunks<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>order<span style="color: #66cc66;">,</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span><span style="color: #483d8b;">'unknown chunk indices in new order'</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>: <span style="color: #ff7700;font-weight:bold;">break</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># write new file</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; outfile_name <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">with</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>outfile_name<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'wb'</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">as</span> outfile:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># write signature</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; outfile.<span style="color: black;">write</span><span style="color: black;">&#40;</span>png_signature<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># write chunks</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">for</span> chunk_no <span style="color: #ff7700;font-weight:bold;">in</span> order:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; c <span style="color: #66cc66;">=</span> chunks<span style="color: black;">&#91;</span>chunk_no<span style="color: black;">&#93;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; infile.<span style="color: black;">seek</span><span style="color: black;">&#40;</span>c<span style="color: black;">&#91;</span><span style="color: #483d8b;">'pos'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>SEEK_SET<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;"># !!! needs advanced buffering for big files</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; data <span style="color: #66cc66;">=</span> infile.<span style="color: black;">read</span><span style="color: black;">&#40;</span>c<span style="color: black;">&#91;</span><span style="color: #483d8b;">'length'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; data <span style="color: #66cc66;">=</span> data <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #483d8b;">'crc'</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> c <span style="color: #ff7700;font-weight:bold;">else</span> data<span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span>+c<span style="color: black;">&#91;</span><span style="color: #483d8b;">'crc'</span><span style="color: black;">&#93;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; written <span style="color: #66cc66;">=</span> outfile.<span style="color: black;">write</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> c<span style="color: black;">&#91;</span><span style="color: #483d8b;">'length'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">==</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> written:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span><span style="color: #483d8b;">'copy error'</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; exit<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">IOError</span> <span style="color: #ff7700;font-weight:bold;">as</span> err:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_error<span style="color: black;">&#40;</span>err<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; exit<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; exit<span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span><br />&#160;</div> 
            </div>
        </content>
        <dc:subject>PNG</dc:subject>
<dc:subject>Python</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/513-Sektenverweise.html" rel="alternate" title="Sektenverweise" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-03-07T09:44:32Z</published>
        <updated>2011-03-07T09:55:56Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=513</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=513</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/5-Kramkiste" label="Kramkiste" term="Kramkiste" />
    
        <id>http://www.frank-busse.de/blag/archives/513-guid.html</id>
        <title type="html">Sektenverweise</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Die Zeit ist knapp, die Verweisliste voll, daher gesammelt in einem Beitrag:<br />
<br />
Sekten und Politik:<br />
<a href="http://www.heise.de/tp/r4/artikel/32/32996/1.html">Ursula von der Leyen und die religiösen Fanatiker</a><br />
<blockquote>Die religiöse Rechte scheint eine besondere Anziehungskraft auf Politiker auszuüben, die offensiv mit ihrem christlichen Glauben umgehen und versuchen, diesen in Politik, vor allem aber in Wählerstimmen umzusetzen. Ein gelegentlicher Auftritt am "äußerst rechten Rand" des Christentums kann die bibeltreuen Christen bei der nächsten Wahl gewogen stimmen, die restliche Bevölkerung wird diesen Ausflug zu den Fundamentalisten nicht bemerken, so scheint das Kalkül. So fand sich beispielsweise Christian Wulff im Kuratorium von ProChrist wieder [...], einem Missionierungsverein, der Experten wie der Journalistin und Theologin Kirsten Dietrich als fundamentalistisch gilt.</blockquote><br />
Neben Wulff mit von der Partie: Annette Schavan, Franz Josef Jung, Volker Kauder und Ursula von der Leyen.<br />
<br />
<a href="http://www.spiegel.de/politik/deutschland/0,1518,727683,00.html">Staat stützt Kirchen mit Milliarden</a><br />
<blockquote>Das Buch dürfte die Debatte um die künftige Finanzierung der Kirchen anheizen. Nach Frerk betragen die direkten und indirekten Leistungen, die der Staat Katholiken und Protestanten und deren Einrichtungen bisher gewährt, jährlich insgesamt rund 19 Milliarden Euro. Diese Summe enthält nicht die neun Milliarden Euro Kirchensteuern und die schätzungsweise 45 Milliarden für Caritas und Diakonie.</blockquote><br />
<br />
Sekten und Geldwäsche:<br />
<a href="http://www.heise.de/tp/r4/artikel/33/33415/1.html">Glasnost bei der Vatikanbank?</a><br />
<blockquote>Die Vatikanbank darf von der Polizei nicht durchsucht, ihre Telefone nicht abgehört und ihre Mitarbeiter nicht verhört werden. Für sie galten bis vor kurzer Zeit weder die Kontrollbestimmungen im Bankenverkehr noch die internationalen Regeln zum Schutz vor Geldwäschepraktiken. Ihre Bilanzen unterliegen striktester Geheimhaltung. Um Informationen über die Geschäfte dieser Bank zu erlangen, muss ein Staatsanwalt ein Rechtshilfeersuchen stellen, das in der Regel nicht gewährt wird. Ihre leitenden Mitarbeiter genießen weitgehend Immunität. Außerdem sind ihre Kapitalerträge von der Steuer befreit.</blockquote><br />
<br />
Sekten und Missbrauch:<br />
<a href="http://www.guardian.co.uk/world/2010/sep/10/belgium-child-abuse-catholic-church">Belgian child abuse report exposes Catholic clergy</a><br />
<blockquote>Paedophilia expert unveils harrowing testimony and documents cases in almost every diocese</blockquote><br />
<br />
<a href="http://www.spiegel.de/panorama/justiz/0,1518,748348,00.html">Missbrauchsopfern droht der Maulkorb</a><br />
<blockquote>Drei Bundesministerinnen, 60 Experten: Am Runden Tisch zum Missbrauch stehen die Interessen von Institutionen und Parteien im Zentrum, nicht die der Opfer. Jetzt geht es um mögliche Entschädigungen. Etliche Betroffene haben ganz andere Probleme: Sie sehen sich Klagen mutmaßlicher Täter ausgesetzt.</blockquote><br />
<br />
<a href="http://www.br-online.de/aktuell/kirche-und-missbrauch-DID1268906638345/missbrauchsbericht-kirche-erzbistum-ID1291214862446.xml">"Auffälligkeiten" und Vertuschungen</a><br />
<blockquote>159 "auffällige" Priester, hohe Dunkelziffer, systematische Vertuschung: Das ist das Ergebnis einer Untersuchung des Bistums München und Freising zu den Missbrauchsfällen der Vergangenheit. Die Gutachterin bemängelte ein "klerikales Selbstverständnis", Skandale zu vermeiden.</blockquote> 
            </div>
        </content>
        <dc:subject>Geldwäsche</dc:subject>
<dc:subject>Jung</dc:subject>
<dc:subject>Kauder</dc:subject>
<dc:subject>Leyen</dc:subject>
<dc:subject>Missbrauch</dc:subject>
<dc:subject>Schavan</dc:subject>
<dc:subject>Sekte</dc:subject>
<dc:subject>Wulff</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/512-Die-boese-NVA.html" rel="alternate" title="Die böse NVA" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-03-07T09:04:53Z</published>
        <updated>2011-04-05T16:43:46Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=512</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=512</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/5-Kramkiste" label="Kramkiste" term="Kramkiste" />
    
        <id>http://www.frank-busse.de/blag/archives/512-guid.html</id>
        <title type="html">Die böse NVA</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <a href="http://www.tagesspiegel.de/berlin/empoerung-ueber-nva-feier-im-tierpark/3921350.html">Empörung über NVA-Feier im Tierpark</a><br />
<blockquote>100 Veteranen der DDR-Truppe marschierten am Samstag in Uniform zum Armeejubiläum im Tierpark auf. Landespolitiker distanzieren sich von dem DDR-Gedenkfest, die SPD fordert Konsequenzen.</blockquote><br />
Wieder ein schöner Grund sich aufzuplustern. Ob sich Traditionsverbände der Wehrmacht, Hiag-Ableger, OdR usw. treffen ist vollkommen egal (mir auch), aber bei der NVA ist Schluss! Böse, böse Armee - die hat ja nicht einmal Krieg geführt!1elf<br />
<br />
Die üblichen Beteiligten mit Blockwartsyndrom:<br />
<blockquote>Die Leitung von Zoo und Tierpark verurteilten das Treffen gestern scharf. [...] Der Cafeteria-Betreiber wie auch ein Tierpark-Mitarbeiter, der von dem Treffen gewusst, die Geschäftsführung aber nicht informiert habe, <strong>erhalten eine Abmahnung</strong>, kündigte sie an.</blockquote><br />
<blockquote>[...] der Verfassungsschutzexperte der SPD, Tom Schreiber. Der Tierpark erhalte Landesgelder. „Die Verantwortlichen müssen ein klares Signal setzen und den Cafeteria-Pächter abmahnen.“</blockquote><br />
<br />
Dass Text und Zitat nicht zusammen passen ignorieren wir mal:<br />
<blockquote>Auch die Linkspartei distanzierte sich am Sonntag am Rande ihrer Klausurtagung <strong>entschieden</strong> von den NVA-Veteranen. „Diese Gruppierung hat <strong>keinerlei politische Relevanz in unserer Partei</strong>“, sagte Landeschef Klaus Lederer.</blockquote><br />
<br />
<blockquote>„Es kann doch nicht sein, dass der Tierpark seine Tore für Systemträger einer Diktatur öffnet“, sagte der Vize-Bundesvorsitzende der Vereinigung der Verfolgten des Stalinismus (VOS), Ronald Lässig. Zugleich forderte er, <strong>Uniformen und Symbole der DDR müssten in der Öffentlichkeit ebenso verboten sein wie nationalsozialistische Relikte</strong>.</blockquote><br />
Am besten gleich alle Anwesenden wegsperren, oder? Das Verbot irgendwelcher Symbole an sich ist schon bescheuert.<br />
<br />
Einer bringt es auf den Punkt:<br />
<blockquote>Die NVA ist laut dem Justiziar der Polizei, Oliver Tölle, keine verbotene Organisation. Ihre Uniform zu tragen, sei deshalb keine strafbare Handlung. Da die NVA nicht mehr als Armee existiere, begingen die Uniformträger auch keine Amtsanmaßung.</blockquote><br />
Gegen die Abmahnung würde ich mich wehren...<br />
<br />
Um die geht es: <a href="http://www.traditionsverband-nva.de/">Traditionsverband Nationale Volksarmee</a>. 
            </div>
        </content>
        <dc:subject>Lässig</dc:subject>
<dc:subject>NVA</dc:subject>
<dc:subject>Schreiber</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/511-Verweisaktualisierung.html" rel="alternate" title="Verweisaktualisierung" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-02-18T11:17:24Z</published>
        <updated>2011-02-18T11:20:21Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=511</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=511</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/3-Netzseite" label="Netzseite" term="Netzseite" />
    
        <id>http://www.frank-busse.de/blag/archives/511-guid.html</id>
        <title type="html">Verweisaktualisierung</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <h2>Bücher</h2><br />
+<a href="http://ldeniau.web.cern.ch/ldeniau/cos.html">Object Oriented Programming in C</a><br />
+<a href="http://people.cis.ksu.edu/~schmidt/text/densem.html">Denotational Semantics: A Methodology for Language Development</a><br />
+<a href="http://learnyouahaskell.com/">Learn You a Haskell for Great Good!</a><br />
-<a href="http://www.professionelle-softwareentwicklung-mit-php5.de/">Professionelle Softwareentwicklung mit PHP 5</a><br />
+<a href="http://cheat.errtheblog.com/s/git">Git Cheat Sheet</a><br />
+<a href="http://book.git-scm.com/">Git Community Book</a><br />
<br />
<h2>Geschichte</h2><br />
-<a href="http://net.lib.byu.edu/~rdh7/wwi/memoir/Deserter/GermanTC.htm">German Deserter's War Experience</a><br />
+<a href="http://www.beeldbankwo2.nl/">Beeldbank</a><br />
+<a href="http://collections.yadvashem.org/photosarchive">Yad Vashem Photo Archive</a><br />
+<a href="http://www.straty.pl/">Polnische Staatsbürger - Opfer und Verfolgte unter der deutschen Besatzung</a><br />
+<a href="http://forum.hidden-places.de/">Digitales Gedächtnis zu Orten der Zeitgeschichte</a><br />
+<a href="http://digital.slub-dresden.de/sammlungen/werkansicht/30409217Z/0/">Dresden - Adressbuch 43/44</a><br />
+<a href="http://landtagsprotokolle.sachsendigital.de/">historische Landtagsprotokolle</a><br />
+<a href="http://militaria-fundforum.com/showthread.php?t=51941">Kampfräume, Gefangenentransporte und Lager im Osten</a><br />
+<a href="http://www.fortiff.be/regelbau/">Regelbauten</a><br />
+<a href="http://wwi.lib.byu.edu/index.php/Main_Page">WW I Document Archive</a><br />
-<a href="http://www.gramuenzki.de/03_geldscheine/banknote1971.html">Geldscheine der DDR</a><br />
+<a href="http://www.numismatischer-verein.eu/gramuenzki_de/geldschein_ddr_scheine.php">Geldscheine der DDR</a><br />
<br />
<h2>KFZ</h3><br />
+<a href="http://bowdenfix.de/shop/">Bowdenfix</a><br />
+<a href="http://www.classicbikeshed.com/">Classic Bike Shed</a><br />
+<a href="http://www.cmsnl.com/">CMS</a><br />
+<a href="http://www.davidsilverspares.co.uk/">David Silver Spares</a><br />
+<a href="http://shop.etel-tuning.de/">Etel-Tuning</a> ;)<br />
-<a href="http://www.tacho-gabriel.de/">Gabriel Tachometer</a><br />
-<a href="http://www.linien-von-meisterhand.de/">Linien von Meisterhand</a><br />
+<a href="http://lelebeck.de/">Lelebeck</a><br />
+<a href="http://www.stossdaempfer-schwarz.de/">Stoßdämpferservice Technischer Handel</a><br />
+<a href="http://www.yesterdays.nl/">Yesterdays</a><br />
+<a href="http://www.honda-board.de/vb/">Honda-Board</a><br />
-<a href="http://motorang.heim.at/motorrad/mz.htm">Motorang (MZ)</a><br />
<br />
<h2>Software</h2><br />
+<a href="http://gpo.zugaina.org/">Overlays</a><br />
-<a href="http://www.steve.org.uk/Software/tscreen/">tscreen</a><br />
+<a href="http://www.brain-dump.org/projects/dvtm/">dvtm</a><br />
+<a href="http://tmux.sourceforge.net/">tmux</a><br />
-<a href="http://www.ruhr.de/home/smallo/award.html">Useless Use of ... Award</a><br />
<br />
<h2>Sonstiges</h2><br />
-<a href="http://www.gujian.net/woogle/">Woogle</a><br />
+<a href="http://docs.google.com/viewer">Docs Viewer</a><br />
-<a href="http://keepvid.com/">Keepvid</a><br />
+<a href="http://home.comcast.net/~jpittman2/pacman/pacmandossier.html">The Pac-Man Dossier</a><br />
+<a href="http://comonad.com/reader/">Edward Kmett</a><br />
+<a href="http://professor-fish.blogspot.com/">Ralf Lämmel</a> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/510-Verweissalat-2.html" rel="alternate" title="Verweissalat 2" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-02-18T10:58:22Z</published>
        <updated>2011-02-18T10:58:22Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=510</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=510</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/2-Informatik" label="Informatik" term="Informatik" />
            <category scheme="http://www.frank-busse.de/blag/categories/5-Kramkiste" label="Kramkiste" term="Kramkiste" />
    
        <id>http://www.frank-busse.de/blag/archives/510-guid.html</id>
        <title type="html">Verweissalat 2</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <h2>Programmiersprachen</h2><br />
<a href="http://jashkenas.github.com/coffee-script/">CoffeeScript</a> (js)<br />
<a href="http://coherence-lang.org/">Coherence</a><br />
<a href="http://futureboy.us/frinkdocs/">Frink</a><br />
<a href="http://gosu-lang.org/">Gosu</a> (jvm)<br />
<a href="http://ooc-lang.org/">ooc</a><br />
<a href="http://sass-lang.com/">Sass</a> (css)<br />
<a href="http://onilabs.com/stratifiedjs">StratifiedJS</a> (js)<br />
<a href="http://thyrd.org/thyrd/">Thyrd</a><br />
<a href="http://www.impredicative.com/ur/">Ur</a><br />
<br />
Bei Löschpedia werden gerade AliceML, Factor, Ioke, Joy, Nemerle, Pure... entfernt. Keine Relevanz für die engstirnigen Blockwarte.<br />
<br />
<h2>Software</h2><br />
<a href="https://www.mlstate.com/opa/">OPA</a> (web)<br />
<a href="http://surfraw.alioth.debian.org/">surfraw</a><br />
<a href="http://xzgv.sourceforge.net/">xzgv</a><br />
<br />
<h2>Kram</h2><br />
<a href="http://www.foundphotos.net/">Foundphotos</a><br />
<a href="http://www.gen-evolu.de/">Genevolu</a> (Namensverteilung)<br />
<a href="http://en.wikipedia.org/wiki/List_of_cognitive_biases">List of cognitive biases</a><br />
<a href="http://staffwww.dcs.shef.ac.uk/people/S.Chapman/stringmetrics.html">String Metrics</a><br />
<a href="http://zmievski.org/2010/08/the-prime-that-wasnt">The Prime That Wasn't</a><br />
<a href="http://sillyskynet.blogspot.com/2009/11/typefuck.html">Typefuck - Brainfuck in Haskell type checker</a><br />
<a href="http://mitworld.mit.edu/video/33">Walter Lewins Regenbögen</a> (eng., Video) 
            </div>
        </content>
        <dc:subject>Programmiersprache</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/509-Konferenzen-2010.html" rel="alternate" title="Konferenzen 2010" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-02-18T10:56:11Z</published>
        <updated>2011-02-18T10:56:11Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=509</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=509</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/2-Informatik" label="Informatik" term="Informatik" />
    
        <id>http://www.frank-busse.de/blag/archives/509-guid.html</id>
        <title type="html">Konferenzen 2010</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <a href="http://events.ccc.de/congress/2010/wiki/Documentation">27C3</a><br />
<a href="http://emerginglangs.com/">Emerging Languages Camp 2010</a> (<a href="http://confreaks.net/events/elcamp2010">videos</a>)<br />
<a href="http://cufp.org/news/2011/cufp-2010-videos-now-available-online">CUFP 2010 - videos</a><br />
<a href="http://www.haskell.org/haskell-symposium/2010/accepted.html">Haskell Symposium 2010</a><br />
<a href="http://www.icfpconference.org/icfp2010/program.html">ICFP 2010</a> (<a href="http://vimeo.com/album/1468571">videos</a>)<br />
<a href="http://www.cse.psu.edu/popl/10/">Principles of Programming Languages 2010</a> (<a href="http://portal.acm.org/citation.cfm?id=1706299&picked=prox&CFID=9299946&CFTOKEN=78743509">papers</a>) 
            </div>
        </content>
        <dc:subject>27C3</dc:subject>
<dc:subject>CUFP</dc:subject>
<dc:subject>ICFP</dc:subject>
<dc:subject>POPL</dc:subject>

    </entry>
    <entry>
        <link href="http://www.frank-busse.de/blag/archives/508-dfa-minimisation-in-Python.html" rel="alternate" title="dfa minimisation in Python" />
        <author>
            <name>Frank</name>
                    </author>
    
        <published>2011-02-11T18:40:18Z</published>
        <updated>2011-02-11T20:02:04Z</updated>
        <wfw:comment>http://www.frank-busse.de/blag/wfwcomment.php?cid=508</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.frank-busse.de/blag/rss.php?version=atom1.0&amp;type=comments&amp;cid=508</wfw:commentRss>
    
            <category scheme="http://www.frank-busse.de/blag/categories/2-Informatik" label="Informatik" term="Informatik" />
    
        <id>http://www.frank-busse.de/blag/archives/508-guid.html</id>
        <title type="html">dfa minimisation in Python</title>
        <content type="xhtml" xml:base="http://www.frank-busse.de/blag/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Recently I stumbled upon a paper by Marco Almeida, Nelma Moreira and Rogerio Reis: <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.170.7222">Incremental DFA minimisation</a>. Beside some minor flaws, like e.g. the missing "ICDFA" definition (already present in the predecessor: <a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.65.4680">On the performance of automata minimization algorithms</a>) and the slightly strange pseudo code, I'm still not convinced about their normalisation-function.<br />
<br />
They argue (section 4 below listing 1.1 resp. proof of lemma 1) that this function reduces the considered pairs to n²/2 - n. If we take all pairs p,q, we obviously get n² pairs. After sorting and removing the duplicates we get (n²+n)/2 pairs, without identities (n²-n)/2...<br />
<br />
In order to better understand some parts of the algorithm, I reimplemented it in Python. I left out most optimizations and tried to stay close to the original pseudo code. It works at least for two examples. ;)<br />
<br />
<div class="python geshi" style="text-align: left"><br /><span style="color: #808080; font-style: italic;">#!/usr/bin/python3</span><br /><br /><span style="color: #808080; font-style: italic;"># Implementation of the MIN-INCR ICDFA minimisation algorithm without(!)</span><br /><span style="color: #808080; font-style: italic;"># optimized data structures.</span><br /><span style="color: #808080; font-style: italic;">#</span><br /><span style="color: #808080; font-style: italic;"># Use minimalIncremental() from FAdo Project for your projects.</span><br /><br /><br /><span style="color: #808080; font-style: italic;"># Literature</span><br /><span style="color: #808080; font-style: italic;"># ----------</span><br /><span style="color: #808080; font-style: italic;">#</span><br /><span style="color: #808080; font-style: italic;"># [idm] Almeida, Moreira, Reis: Incremental DFA minimisation</span><br /><span style="color: #808080; font-style: italic;"># [ufa] Tarjan: Efficiency of a Good But Not Linear Set Union Algorithm</span><br /><span style="color: #808080; font-style: italic;">#</span><br /><span style="color: #808080; font-style: italic;">#</span><br /><span style="color: #808080; font-style: italic;"># Links</span><br /><span style="color: #808080; font-style: italic;"># -----</span><br /><span style="color: #808080; font-style: italic;">#</span><br /><span style="color: #808080; font-style: italic;"># FAdo Project:</span><br /><span style="color: #808080; font-style: italic;"># &#160; - http://www.ncc.up.pt/FAdo/</span><br /><span style="color: #808080; font-style: italic;"># &#160; - http://fado.dcc.fc.up.pt/FAdo/</span><br /><br /><br />verbose <span style="color: #66cc66;">=</span> <span style="color: #008000;">False</span><br /><br /><br /><br /><span style="color: #808080; font-style: italic;"># ==== fake union-find ==== ([ufa])</span><br /><br /><span style="color: #dc143c;">sets</span> <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> make<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;creates new singleton set {x}&quot;&quot;&quot;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">global</span> <span style="color: #dc143c;">sets</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #dc143c;">sets</span><span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> find_<span style="color: black;">&#40;</span><span style="color: #dc143c;">sets</span><span style="color: #66cc66;">,</span>x<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;returns representative element of set containing x&quot;&quot;&quot;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">id</span><span style="color: #66cc66;">,</span>s <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">sets</span>.<span style="color: black;">items</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> x <span style="color: #ff7700;font-weight:bold;">in</span> s:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">id</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> find<span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;wrapper for find_&quot;&quot;&quot;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">global</span> <span style="color: #dc143c;">sets</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> find_<span style="color: black;">&#40;</span><span style="color: #dc143c;">sets</span><span style="color: #66cc66;">,</span>x<span style="color: black;">&#41;</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> union<span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;combines a and b&quot;&quot;&quot;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">global</span> <span style="color: #dc143c;">sets</span><br /><br />&#160; &#160; &#160; &#160; a<span style="color: #66cc66;">,</span>b <span style="color: #66cc66;">=</span> normalise<span style="color: black;">&#40;</span>find<span style="color: black;">&#40;</span>p<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>find<span style="color: black;">&#40;</span>q<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> a <span style="color: #66cc66;">!=</span> b:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #dc143c;">sets</span><span style="color: black;">&#91;</span>a<span style="color: black;">&#93;</span> |<span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sets</span><span style="color: black;">&#91;</span>b<span style="color: black;">&#93;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">del</span> <span style="color: #dc143c;">sets</span><span style="color: black;">&#91;</span>b<span style="color: black;">&#93;</span><br /><br /><br /><br /><span style="color: #808080; font-style: italic;"># ==== minimisation ==== ([idm])</span><br /><br />neq &#160; <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />equiv <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />path &#160;<span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />dfa &#160; <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br /><br /><span style="color: #808080; font-style: italic;"># (idm L1.1)</span><br /><span style="color: #ff7700;font-weight:bold;">def</span> normalise<span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">if</span> p<span style="color: #66cc66;">&lt;</span>q <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: black;">&#40;</span>q<span style="color: #66cc66;">,</span>p<span style="color: black;">&#41;</span><br /><br /><br /><span style="color: #808080; font-style: italic;"># (idm L1.4) - just use python's set implementation</span><br /><span style="color: #ff7700;font-weight:bold;">def</span> set_make<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> set_insert<span style="color: black;">&#40;</span>v<span style="color: #66cc66;">,</span>s<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; s.<span style="color: black;">add</span><span style="color: black;">&#40;</span>v<span style="color: black;">&#41;</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> set_remove<span style="color: black;">&#40;</span>v<span style="color: #66cc66;">,</span>s<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; s.<span style="color: black;">remove</span><span style="color: black;">&#40;</span>v<span style="color: black;">&#41;</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> set_search<span style="color: black;">&#40;</span>v<span style="color: #66cc66;">,</span>s<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> v <span style="color: #ff7700;font-weight:bold;">in</span> s<br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> set_elements<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> s<br /><br /><br /><span style="color: #808080; font-style: italic;"># (idm L1.3)</span><br /><span style="color: #ff7700;font-weight:bold;">def</span> equiv_p<span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;tests equivalence of p and q&quot;&quot;&quot;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">global</span> neq<span style="color: #66cc66;">,</span> equiv<span style="color: #66cc66;">,</span> path<span style="color: #66cc66;">,</span> dfa<span style="color: #66cc66;">,</span> verbose<br />&#160; &#160; &#160; &#160; d <span style="color: #66cc66;">=</span> dfa<br /><br />&#160; &#160; &#160; &#160; print_<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;equiv: {0}<span style="color: #000099; font-weight: bold;">\n</span>path : {1}<span style="color: #000099; font-weight: bold;">\n</span>neq &#160;: {2}<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>equiv<span style="color: #66cc66;">,</span>path<span style="color: #66cc66;">,</span>neq<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">in</span> neq:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> set_search<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>path<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span><br /><br />&#160; &#160; &#160; &#160; set_insert<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>path<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">for</span> a <span style="color: #ff7700;font-weight:bold;">in</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Sigma'</span><span style="color: black;">&#93;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; print_<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;p,a,q:&quot;</span><span style="color: #66cc66;">,</span>p<span style="color: #66cc66;">,</span>a<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: black;">&#40;</span>p_<span style="color: #66cc66;">,</span>q_<span style="color: black;">&#41;</span> <span style="color: #66cc66;">=</span> normalise<span style="color: black;">&#40;</span>find<span style="color: black;">&#40;</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'delta'</span><span style="color: black;">&#93;</span><span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>a<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>find<span style="color: black;">&#40;</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'delta'</span><span style="color: black;">&#93;</span><span style="color: black;">&#40;</span>q<span style="color: #66cc66;">,</span>a<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> p_ <span style="color: #66cc66;">!=</span> q_ <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #ff7700;font-weight:bold;">not</span> set_search<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>p_<span style="color: #66cc66;">,</span>q_<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>equiv<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; set_insert<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>p_<span style="color: #66cc66;">,</span>q_<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>equiv<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> equiv_p<span style="color: black;">&#40;</span>p_<span style="color: #66cc66;">,</span>q_<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; set_remove<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>p_<span style="color: #66cc66;">,</span>q_<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>path<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; set_insert<span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span>equiv<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">True</span><br /><br /><br /><span style="color: #808080; font-style: italic;"># (idm Theorem 2)</span><br /><span style="color: #ff7700;font-weight:bold;">def</span> joinstates<span style="color: black;">&#40;</span>d<span style="color: #66cc66;">,</span>classes<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #483d8b;">&quot;&quot;&quot;returns new dfa based on equivalence classes&quot;&quot;&quot;</span><br /><br />&#160; &#160; &#160; &#160; Q <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span>classes.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; Sigma <span style="color: #66cc66;">=</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Sigma'</span><span style="color: black;">&#93;</span><br />&#160; &#160; &#160; &#160; delta <span style="color: #66cc66;">=</span> <span style="color: #ff7700;font-weight:bold;">lambda</span> p<span style="color: #66cc66;">,</span>a: find_<span style="color: black;">&#40;</span>classes<span style="color: #66cc66;">,</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'delta'</span><span style="color: black;">&#93;</span><span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>a<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; q0 <span style="color: #66cc66;">=</span> find_<span style="color: black;">&#40;</span>classes<span style="color: #66cc66;">,</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'q0'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; F <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: find_<span style="color: black;">&#40;</span>classes<span style="color: #66cc66;">,</span>x<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #008000;">list</span><span style="color: black;">&#40;</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'F'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">'Q'</span>:Q<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Sigma'</span>:Sigma<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'delta'</span>:delta<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'q0'</span>:q0<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'F'</span>:F<span style="color: black;">&#125;</span><br /><br /><br /><span style="color: #808080; font-style: italic;"># (idm L1.2)</span><br /><span style="color: #ff7700;font-weight:bold;">def</span> min_incr<span style="color: black;">&#40;</span>d<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">global</span> neq<span style="color: #66cc66;">,</span> equiv<span style="color: #66cc66;">,</span> path<span style="color: #66cc66;">,</span> dfa<br />&#160; &#160; &#160; &#160; dfa <span style="color: #66cc66;">=</span> d<br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">for</span> q <span style="color: #ff7700;font-weight:bold;">in</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Q'</span><span style="color: black;">&#93;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; make<span style="color: black;">&#40;</span>q<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; neq <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>normalise<span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> p <span style="color: #ff7700;font-weight:bold;">in</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'F'</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">for</span> q <span style="color: #ff7700;font-weight:bold;">in</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Q'</span><span style="color: black;">&#93;</span> - d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'F'</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">for</span> p <span style="color: #ff7700;font-weight:bold;">in</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Q'</span><span style="color: black;">&#93;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">for</span> q <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#91;</span>x <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Q'</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">if</span> x <span style="color: #66cc66;">&gt;</span> p<span style="color: black;">&#93;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">in</span> neq:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">continue</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> find<span style="color: black;">&#40;</span>p<span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> find<span style="color: black;">&#40;</span>q<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">continue</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; equiv <span style="color: #66cc66;">=</span> set_make<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; path &#160;<span style="color: #66cc66;">=</span> set_make<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> equiv_p<span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>q<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: black;">&#40;</span>p_<span style="color: #66cc66;">,</span>q_<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">in</span> set_elements<span style="color: black;">&#40;</span>equiv<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; union<span style="color: black;">&#40;</span>p_<span style="color: #66cc66;">,</span>q_<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; neq |<span style="color: #66cc66;">=</span> path<br /><br />&#160; &#160; &#160; &#160; classes <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">for</span> p <span style="color: #ff7700;font-weight:bold;">in</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Q'</span><span style="color: black;">&#93;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; lider <span style="color: #66cc66;">=</span> find<span style="color: black;">&#40;</span>p<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; classes<span style="color: black;">&#91;</span>lider<span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> classes<span style="color: black;">&#91;</span>lider<span style="color: black;">&#93;</span> | <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>p<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">if</span> lider <span style="color: #ff7700;font-weight:bold;">in</span> classes <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>p<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; print_<span style="color: black;">&#40;</span><span style="color: #483d8b;">'classes:'</span><span style="color: #66cc66;">,</span>classes<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> joinstates<span style="color: black;">&#40;</span>d<span style="color: #66cc66;">,</span>classes<span style="color: black;">&#41;</span><br /><br /><br /><br /><span style="color: #808080; font-style: italic;"># ==== I/O ====</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> print_<span style="color: black;">&#40;</span>*args<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">global</span> verbose<br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">if</span> verbose:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span>*args<span style="color: black;">&#41;</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> print_dfa<span style="color: black;">&#40;</span>name<span style="color: #66cc66;">,</span>d<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'{0}<span style="color: #000099; font-weight: bold;">\n</span>{1}'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>name<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'='</span>*<span style="color: #008000;">len</span><span style="color: black;">&#40;</span>name<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Q &#160; &#160;: {0}<span style="color: #000099; font-weight: bold;">\n</span>Sigma: {1}<span style="color: #000099; font-weight: bold;">\n</span>delta:'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Q'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Sigma'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">for</span> q<span style="color: #66cc66;">,</span>a <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>q<span style="color: #66cc66;">,</span>a<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> q <span style="color: #ff7700;font-weight:bold;">in</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Q'</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">for</span> a <span style="color: #ff7700;font-weight:bold;">in</span> d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Sigma'</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span>:<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">' '</span>*<span style="color: #ff4500;">6</span><span style="color: #66cc66;">,</span>q<span style="color: #66cc66;">,</span>a<span style="color: #66cc66;">,</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'delta'</span><span style="color: black;">&#93;</span><span style="color: black;">&#40;</span>q<span style="color: #66cc66;">,</span>a<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'q0 &#160; : {0}<span style="color: #000099; font-weight: bold;">\n</span>F &#160; &#160;: {1}<span style="color: #000099; font-weight: bold;">\n</span>'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'q0'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span>d<span style="color: black;">&#91;</span><span style="color: #483d8b;">'F'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br /><br /><br /><br /><span style="color: #808080; font-style: italic;"># ==== examples ====</span><br /><br /><span style="color: #808080; font-style: italic;"># DFA d={q,s,d,q0,f}</span><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> dfa_01_d<span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>a<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; tab <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">0</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span><span style="color: #66cc66;">,</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">1</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">4</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span><span style="color: #66cc66;">,</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">2</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">3</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span><span style="color: #66cc66;">,</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">3</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">4</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span><span style="color: #66cc66;">,</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">4</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">4</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">4</span><span style="color: black;">&#125;</span><span style="color: black;">&#125;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> tab<span style="color: black;">&#91;</span>p<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>a<span style="color: black;">&#93;</span><br /><br />dfa_01 <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">'Q'</span>:<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">2</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">3</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Sigma'</span>:<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'a'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'delta'</span>:dfa_01_d<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'q0'</span>:<span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'F'</span>:<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span><br /><br /><br /><span style="color: #ff7700;font-weight:bold;">def</span> dfa_02_d<span style="color: black;">&#40;</span>p<span style="color: #66cc66;">,</span>a<span style="color: black;">&#41;</span>:<br />&#160; &#160; &#160; &#160; tab <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">0</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">4</span><span style="color: black;">&#125;</span><span style="color: #66cc66;">,</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">1</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">2</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">5</span><span style="color: black;">&#125;</span><span style="color: #66cc66;">,</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">2</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">3</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span><span style="color: #66cc66;">,</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">3</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">3</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#125;</span><span style="color: #66cc66;">,</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">4</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">5</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">0</span><span style="color: black;">&#125;</span><span style="color: #66cc66;">,</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #ff4500;">5</span>:<span style="color: black;">&#123;</span><span style="color: #483d8b;">'a'</span>:<span style="color: #ff4500;">4</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span>:<span style="color: #ff4500;">1</span><span style="color: black;">&#125;</span><span style="color: black;">&#125;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #ff7700;font-weight:bold;">return</span> tab<span style="color: black;">&#91;</span>p<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span>a<span style="color: black;">&#93;</span><br /><br />dfa_02 <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: #483d8b;">'Q'</span>:<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">6</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'Sigma'</span>:<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'a'</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'b'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'delta'</span>:dfa_02_d<span style="color: #66cc66;">,</span><span style="color: #483d8b;">'q0'</span>:<span style="color: #ff4500;">0</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'F'</span>:<span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">3</span><span style="color: #66cc66;">,</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span><br /><br /><br /><span style="color: #808080; font-style: italic;"># ==== main ====</span><br /><br /><span style="color: #ff7700;font-weight:bold;">if</span> __name__ <span style="color: #66cc66;">==</span> <span style="color: #483d8b;">'__main__'</span>:<br />&#160; &#160; &#160; &#160; print_dfa<span style="color: black;">&#40;</span><span style="color: #483d8b;">'DFA 01'</span><span style="color: #66cc66;">,</span>dfa_01<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; dfa_01_min <span style="color: #66cc66;">=</span> min_incr<span style="color: black;">&#40;</span>dfa_01<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; print_dfa<span style="color: black;">&#40;</span><span style="color: #483d8b;">'DFA 01 min'</span><span style="color: #66cc66;">,</span>dfa_01_min<span style="color: black;">&#41;</span><br /><br />&#160; &#160; &#160; &#160; print_dfa<span style="color: black;">&#40;</span><span style="color: #483d8b;">'DFA 02'</span><span style="color: #66cc66;">,</span>dfa_02<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; dfa_02_min <span style="color: #66cc66;">=</span> min_incr<span style="color: black;">&#40;</span>dfa_02<span style="color: black;">&#41;</span><br />&#160; &#160; &#160; &#160; print_dfa<span style="color: black;">&#40;</span><span style="color: #483d8b;">'DFA 02 min'</span><span style="color: #66cc66;">,</span>dfa_02_min<span style="color: black;">&#41;</span></div><br />
<br />
Feel free to play around with it. 
            </div>
        </content>
        <dc:subject>Minimierung</dc:subject>
<dc:subject>Python</dc:subject>
<dc:subject>dfa</dc:subject>
<dc:subject>icdfa</dc:subject>
<dc:subject>minimisation</dc:subject>

    </entry>

</feed>
