<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《GLIBC strlen源代码分析》的评论</title>
	<atom:link href="http://tonybai.com/2009/04/11/glibc-strlen-source-analysis/feed/" rel="self" type="application/rss+xml" />
	<link>https://tonybai.com/2009/04/11/glibc-strlen-source-analysis/</link>
	<description>一个程序员的心路历程</description>
	<lastBuildDate>Wed, 25 Mar 2026 09:21:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>作者：于小鱼</title>
		<link>https://tonybai.com/2009/04/11/glibc-strlen-source-analysis/#comment-904</link>
		<dc:creator>于小鱼</dc:creator>
		<pubDate>Sat, 16 Nov 2013 17:20:21 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/2009/04/11/glibc-strlen%e6%ba%90%e4%bb%a3%e7%a0%81%e5%88%86%e6%9e%90/#comment-904</guid>
		<description>用ASCII 解释的部分是错的，你想复杂了。有一些值通过这个测试，但是没有全零字节是没问题的，因为它还会通过下面检查每个字节的测试， 显然不会通过，所以循环继续。</description>
		<content:encoded><![CDATA[<p>用ASCII 解释的部分是错的，你想复杂了。有一些值通过这个测试，但是没有全零字节是没问题的，因为它还会通过下面检查每个字节的测试， 显然不会通过，所以循环继续。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：gzm55</title>
		<link>https://tonybai.com/2009/04/11/glibc-strlen-source-analysis/#comment-381</link>
		<dc:creator>gzm55</dc:creator>
		<pubDate>Sun, 12 Apr 2009 15:17:02 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/2009/04/11/glibc-strlen%e6%ba%90%e4%bb%a3%e7%a0%81%e5%88%86%e6%9e%90/#comment-381</guid>
		<description>HD的确是本百读不厌的书, 不过我也没看完, 今天中午特意看了下他对这部分的做法, 也相当精妙.

越界问题应该&quot;几乎&quot;不会出问题, 只是&quot;标准&quot;中说越界读取后果可能不可预知, 单对我们, 仅仅读取最多三个字节的垃圾数据, 我想最坏的后果是段错误, 读取非法内存. 但是段边界现在好像都需要4或8字节对齐了吧?</description>
		<content:encoded><![CDATA[<p>HD的确是本百读不厌的书, 不过我也没看完, 今天中午特意看了下他对这部分的做法, 也相当精妙.</p>
<p>越界问题应该&quot;几乎&quot;不会出问题, 只是&quot;标准&quot;中说越界读取后果可能不可预知, 单对我们, 仅仅读取最多三个字节的垃圾数据, 我想最坏的后果是段错误, 读取非法内存. 但是段边界现在好像都需要4或8字节对齐了吧?</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：gzm55</title>
		<link>https://tonybai.com/2009/04/11/glibc-strlen-source-analysis/#comment-382</link>
		<dc:creator>gzm55</dc:creator>
		<pubDate>Sun, 12 Apr 2009 14:15:21 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/2009/04/11/glibc-strlen%e6%ba%90%e4%bb%a3%e7%a0%81%e5%88%86%e6%9e%90/#comment-382</guid>
		<description>仔细看了下代码, 对于扩展ascii字符和&quot;\1\0&quot;这种特殊情况, 虽然能通过那个条件, 但在37行开始的程序会将这些情况过滤掉.

看来代码的作者是假设char *里面的数据绝大部分是可读的标准ascii字符, 并对此做判断, 对于不满足假设的字符需要逐个检查. 这样的写法大部分情况下会比Hacker&#039;s Delight里面介绍的精确判定非零方法快.</description>
		<content:encoded><![CDATA[<p>仔细看了下代码, 对于扩展ascii字符和&quot;\1\0&quot;这种特殊情况, 虽然能通过那个条件, 但在37行开始的程序会将这些情况过滤掉.</p>
<p>看来代码的作者是假设char *里面的数据绝大部分是可读的标准ascii字符, 并对此做判断, 对于不满足假设的字符需要逐个检查. 这样的写法大部分情况下会比Hacker&#8217;s Delight里面介绍的精确判定非零方法快.</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：gzm55</title>
		<link>https://tonybai.com/2009/04/11/glibc-strlen-source-analysis/#comment-383</link>
		<dc:creator>gzm55</dc:creator>
		<pubDate>Sun, 12 Apr 2009 11:14:05 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/2009/04/11/glibc-strlen%e6%ba%90%e4%bb%a3%e7%a0%81%e5%88%86%e6%9e%90/#comment-383</guid>
		<description>在贴一个bstr lib给出的各个字符串库的比较

http://bstring.sourceforge.net/features.html</description>
		<content:encoded><![CDATA[<p>在贴一个bstr lib给出的各个字符串库的比较</p>
<p><a href="http://bstring.sourceforge.net/features.html" rel="nofollow">http://bstring.sourceforge.net/features.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：gzm55</title>
		<link>https://tonybai.com/2009/04/11/glibc-strlen-source-analysis/#comment-384</link>
		<dc:creator>gzm55</dc:creator>
		<pubDate>Sun, 12 Apr 2009 11:12:07 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/2009/04/11/glibc-strlen%e6%ba%90%e4%bb%a3%e7%a0%81%e5%88%86%e6%9e%90/#comment-384</guid>
		<description>两个问题:
1. 这种方法要求最高位为零, 然后判断每个字节是否为正. 这种方法对于其他使用扩展ASCII编码的欧洲语系字符串怎么办呢? 字符串会以任何高位为1的字符结束(-128除外)~

2. 移植性问题. 35行这句 longword = *longword_ptr++; 把字符串看成uint数组来读取, 当遇到字串结尾的时候, 有可能越界读取. 这显然不合标准, 在某些情况下会出错吧?</description>
		<content:encoded><![CDATA[<p>两个问题:<br />
1. 这种方法要求最高位为零, 然后判断每个字节是否为正. 这种方法对于其他使用扩展ASCII编码的欧洲语系字符串怎么办呢? 字符串会以任何高位为1的字符结束(-128除外)~</p>
<p>2. 移植性问题. 35行这句 longword = *longword_ptr++; 把字符串看成uint数组来读取, 当遇到字串结尾的时候, 有可能越界读取. 这显然不合标准, 在某些情况下会出错吧?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
