<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Advogato blog for mitr</title>
    <link>http://www.advogato.org/person/mitr/</link>
    <description>Advogato blog for mitr</description>
    <language>en-us</language>
    <generator>mod_virgule</generator>
    <pubDate>Mon, 8 Sep 2008 00:12:16 GMT</pubDate>
    <item>
      <pubDate>Sun, 7 Nov 2004 22:15:59 GMT</pubDate>
      <title>7 Nov 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=9</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=9</guid>
      <description>&lt;p&gt;I have seen one too many instances of checking &lt;tt&gt;strtol ()&lt;/tt&gt; results wrong, so, for the record:

&lt;p&gt; &lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Sigh, two too many, a portable check for
empty input added.

&lt;p&gt; &lt;p&gt;To convert &lt;tt&gt;const char *str&lt;/tt&gt; to a &lt;tt&gt;long&lt;/tt&gt;,
properly checking for overflow, invalid trailing characters and empty input, it is necessary to do the following:

&lt;p&gt; &lt;p&gt; &lt;blockquote&gt;&lt;pre&gt;char *p;
errno = 0;
result = strtol(str, &amp;amp;p, base);
if (errno != 0 || *p != 0 || p == str)
  error_handling ();&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt; &lt;p&gt; It is necessary to check &lt;em&gt;both&lt;/em&gt; &lt;tt&gt;errno&lt;/tt&gt; and &lt;tt&gt;*p&lt;/tt&gt;; if
you don't check &lt;tt&gt;errno&lt;/tt&gt;, you get 0 for empty input and
&lt;tt&gt;LONG_MAX&lt;/tt&gt; or &lt;tt&gt;LONG_MIN&lt;/tt&gt; for overflow or underflow. On empty input the return value is 0 and &lt;tt&gt;errno&lt;/tt&gt; &lt;em&gt;might&lt;/em&gt; be set to &lt;tt&gt;EINVAL&lt;/tt&gt;;
the portable way of checking for empty input is comparing
&lt;tt&gt;p&lt;/tt&gt; and &lt;tt&gt;str&lt;/tt&gt;.

&lt;p&gt; &lt;p&gt; &lt;p&gt;This will still accept strings that start with white space; check for &lt;tt&gt;!isspace((unsigned char)*str)&lt;/tt&gt;
if you want to reject them.

&lt;p&gt; &lt;p&gt; &lt;p&gt;I hope that helps someone.</description>
    </item>
    <item>
      <pubDate>Mon, 12 Apr 2004 11:51:58 GMT</pubDate>
      <title>12 Apr 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=8</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=8</guid>
      <description>&lt;p&gt;I was cleaning up &lt;a href="http://www.advogato.org/proj/cereal/" &gt;cereal&lt;/a&gt; a bit and I contemplated replacing db2* (using openjade and DSSSL) with xmlto (using passivetex and XSLT). HTML generation went down from 6 s to 4 s, PDF generation up from 30 s to about 5 min.

&lt;p&gt; &lt;p&gt;Needless to say I'm staying with the DSSSL styles. At least I got a chance to fix some errors caught by the stricter XML parser used by xmlto.</description>
    </item>
    <item>
      <pubDate>Mon, 5 Apr 2004 13:22:11 GMT</pubDate>
      <title>5 Apr 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=7</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=7</guid>
      <description>Well, we (Charles University Prague) didn't &lt;a href="http://icpc.baylor.edu/icpc/Finals/finals.html" &gt;win&lt;/a&gt;
the ACM ICPC this year. I had fun anyway.</description>
    </item>
    <item>
      <pubDate>Thu, 11 Mar 2004 17:16:52 GMT</pubDate>
      <title>11 Mar 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=6</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=6</guid>
      <description>&lt;p&gt;Installed current CVS &lt;a href="http://gnome.org" &gt;GNOME&lt;/a&gt; and checked the translations (which turned out to be mostly fine). New GNOME looks really good. I can't wait for FC 2 with  Bluecurvized GNOME 2.6; my eyes are too accustomed to the theme, which makes the work with Simple a bit uncomfortable.
</description>
    </item>
    <item>
      <pubDate>Wed, 25 Feb 2004 06:06:26 GMT</pubDate>
      <title>25 Feb 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=5</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=5</guid>
      <description>&lt;p&gt;A new release of &lt;a href="http://cereal.sourceforge.net/" &gt;&lt;tt&gt;cereal&lt;/tt&gt;&lt;/a&gt; after six months, again with virtually no code changes.

&lt;p&gt; &lt;p&gt;Hopefully it will make the one or two people trying to build &lt;tt&gt;cereal&lt;/tt&gt; on Gentoo happy.</description>
    </item>
    <item>
      <pubDate>Mon, 23 Feb 2004 19:30:03 GMT</pubDate>
      <title>23 Feb 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=4</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=4</guid>
      <description>&lt;p&gt;Writing what is supposed to be a noddy program and finding a bug in &lt;tt&gt;glibc&lt;/tt&gt; during the process does not happen every day :).</description>
    </item>
    <item>
      <pubDate>Mon, 23 Feb 2004 08:33:16 GMT</pubDate>
      <title>23 Feb 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=3</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=3</guid>
      <description>&lt;p&gt;I have spent the weekend writing a GUI in Python. It's not too bad, but not that great either.

&lt;p&gt; &lt;p&gt; &lt;p&gt;Using Python is quite easy and I'm sure I couldn't have written the same application in C as fast. The automatic memory management helps a lot too.

&lt;p&gt; &lt;p&gt; &lt;p&gt;Fast as the development is, it is also quite painful for someone (me) used to static syntax and type checking. The ten edit-test cycles needed to fix a stupid error (defining a variable that shadows a built-in function) certainly were not faster than ten edit-compile cycles in C.

&lt;p&gt; &lt;p&gt; &lt;p&gt;I'm also a bit worried about shipping an application without a way to make sure there are no "obvious" typos in the notoriously hard-to-test error-checking paths.
&lt;a href="http://www.livejournal.com/users/alikins_code/" &gt;Adrian&lt;/a&gt; probably knows what I mean.

&lt;p&gt; &lt;p&gt; &lt;p&gt;And yes, I know about &lt;a href="http://pychecker.sourceforge.net/" &gt;pychecker&lt;/a&gt;. It helps somewhat, but it executes all code outside of class definitions and class &lt;tt&gt;__init__&lt;/tt&gt; methods, which breaks horribly if the code fails a check and calls &lt;tt&gt;sys.exit&lt;/tt&gt;.
 </description>
    </item>
    <item>
      <pubDate>Mon, 2 Feb 2004 19:08:13 GMT</pubDate>
      <title>2 Feb 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=2</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=2</guid>
      <description>&lt;p&gt;Now &lt;em&gt;that&lt;/em&gt; is an useful &lt;tt&gt;ChangeLog&lt;/tt&gt; entry:

&lt;p&gt; &lt;pre&gt;2004-02-01  &lt;i&gt;somebody&lt;/i&gt;
        * &lt;i&gt;project&lt;/i&gt;/*:
        * extra/*:
        * testing/*: Lots of bug fixes and improvements.&lt;br&gt;
2003-09-29  &lt;i&gt;somebody other&lt;/i&gt;&lt;/pre&gt;

&lt;p&gt; &lt;p&gt;(details hidden to protect the guilty party).</description>
    </item>
    <item>
      <pubDate>Fri, 30 Jan 2004 08:16:59 GMT</pubDate>
      <title>30 Jan 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=1</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=1</guid>
      <description>Want some silly fun? Do a competition with your roommates in Minesweeper!</description>
    </item>
    <item>
      <pubDate>Wed, 21 Jan 2004 19:26:18 GMT</pubDate>
      <title>21 Jan 2004</title>
      <link>http://www.advogato.org/person/mitr/diary.html?start=0</link>
      <guid>http://www.advogato.org/person/mitr/diary.html?start=0</guid>
      <description>&lt;p&gt;Out of curiosity I have checked all files that get bundled in a tarball of an autoconfiscated project. I haven't found anything interesting among them, but noticed &lt;tt&gt;gettext.h&lt;/tt&gt; (copied from the &lt;tt&gt;gettext&lt;/tt&gt; package, as suggested in the manual), which is under LGPL.

&lt;p&gt; &lt;p&gt;The project is licensed under OSL 2.0, so I got curious
about the combination. LGPL paragraph 6 requires that with each binary of my project the distributor must "give prominent
notice that the Library is used in it" ..., "supply a copy
of this License", "include the copyright notice of the Library" and "a reference directing the user to the copy of this License".

&lt;p&gt; &lt;p&gt;So, apparently I can ship &lt;tt&gt;gettext.h&lt;/tt&gt; in the tarball
as long as I also ship &lt;tt&gt;COPYING.LIB&lt;/tt&gt;. But &lt;em&gt;anyone&lt;/em&gt; distributing a binary must make sure there is a "prominent notice" and modify the program to add the
copyright notice for gettext and a pointer to &lt;tt&gt;COPYING.LIB&lt;/tt&gt;.
I ended up rewriting &lt;tt&gt;gettext.h&lt;/tt&gt; from scratch; I don't want to "accidentaly" put such requirements on users of my software.

&lt;p&gt; &lt;p&gt;It gets worse, though. Reading &lt;tt&gt;/usr/include/string.h&lt;/tt&gt; from glibc you see that
if you compile with &lt;tt&gt;gcc -O&lt;/tt&gt; (and don't define &lt;tt&gt;__NO_STRING_INLINES&lt;/tt&gt;), &lt;tt&gt;#include &amp;lt;string.h&amp;gt;&lt;/tt&gt; pulls also &lt;tt&gt;/usr/include/bits/string2.h&lt;/tt&gt;, which contains
&lt;em&gt;very large&lt;/em&gt; inline functions that can not be considered trivial (due to the C aliasing model they can not even be written in strictly conforming C99). So &lt;em&gt;any executable&lt;/em&gt; that uses the functions from glibc is clearly a derived work of glibc and falls under LGPL paragraph 6.
(Even though LGPL paragraph 6 seems to indicate that they consider executables using shared linking to still be derived works of the library, I can imagine the judge would disagree; but the string inlines are not a case of shared linking.)

&lt;p&gt; &lt;p&gt;What does it mean? Since &lt;tt&gt;gcc&lt;/tt&gt; is the canonical compiler on Linux, almost everybody is using optimization and almost every program calls &lt;tt&gt;memset ()&lt;/tt&gt;, &lt;tt&gt;strcpy ()&lt;/tt&gt;, &lt;tt&gt;strncpy ()&lt;/tt&gt; or &lt;tt&gt;strcmp ()&lt;/tt&gt; (this list is not exhaustive), &lt;strong&gt;almost any program for Linux distributed in binary form&lt;/strong&gt; must be shipped &lt;strong&gt;acompanied with &lt;tt&gt;COPYING.LIB&lt;/tt&gt;&lt;/strong&gt;, must give a &lt;strong&gt;prominent notice it uses glibc&lt;/strong&gt; and must &lt;strong&gt;contain the glibc copyright notice along with other copyright notices.&lt;/strong&gt;

&lt;p&gt; &lt;p&gt;I find it quite surprising. In fact I don't know about any program that does that.</description>
    </item>
  </channel>
</rss>
