<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Feedback wanted for a C function</title>
	<atom:link href="http://blog.ghcoders.net/2007/10/16/feedback-wanted-for-a-c-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ghcoders.net/2007/10/16/feedback-wanted-for-a-c-function/</link>
	<description></description>
	<pubDate>Wed, 07 Jan 2009 04:32:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Jeremy Fincher</title>
		<link>http://blog.ghcoders.net/2007/10/16/feedback-wanted-for-a-c-function/#comment-16</link>
		<dc:creator>Jeremy Fincher</dc:creator>
		<pubDate>Tue, 13 Nov 2007 22:43:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ghcoders.net/2007/10/16/feedback-wanted-for-a-c-function/#comment-16</guid>
		<description>First, the function is too long.  Write another function to skip leading whitespace (or, for extra credit, write a function to skip leading chars matching a certain predicate) and use that.

Second, I wouldn't use strlen at all.  It doesn't significantly simplify your function and it results in making two passes over the string rather than one.  Instead, just use a while loop like "while (c = *s++)".

You could write it in a more state machine style, if you want, but it's not necessary.</description>
		<content:encoded><![CDATA[<p>First, the function is too long.  Write another function to skip leading whitespace (or, for extra credit, write a function to skip leading chars matching a certain predicate) and use that.</p>
<p>Second, I wouldn&#8217;t use strlen at all.  It doesn&#8217;t significantly simplify your function and it results in making two passes over the string rather than one.  Instead, just use a while loop like &#8220;while (c = *s++)&#8221;.</p>
<p>You could write it in a more state machine style, if you want, but it&#8217;s not necessary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jamessan</title>
		<link>http://blog.ghcoders.net/2007/10/16/feedback-wanted-for-a-c-function/#comment-10</link>
		<dc:creator>jamessan</dc:creator>
		<pubDate>Tue, 16 Oct 2007 13:59:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.ghcoders.net/2007/10/16/feedback-wanted-for-a-c-function/#comment-10</guid>
		<description>Just as a matter of course, the first thing I'd do in such a function is:
&lt;pre&gt;
&lt;code&gt;
if (s == NULL &#124;&#124; strlen(s) == 0)
    return 0;
&lt;/code&gt;
&lt;/pre&gt;

The inconsistency between your use of post-increment and pre-increment is a little odd.  Other than that, it looks good.</description>
		<content:encoded><![CDATA[<p>Just as a matter of course, the first thing I&#8217;d do in such a function is:</p>
<pre>
<code>
if (s == NULL || strlen(s) == 0)
    return 0;
</code>
</pre>
<p>The inconsistency between your use of post-increment and pre-increment is a little odd.  Other than that, it looks good.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
