<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>GCCFeli.cn</title> <atom:link href="http://gccfeli.cn/feed" rel="self" type="application/rss+xml" /><link>http://gccfeli.cn</link> <description></description> <lastBuildDate>Tue, 17 Aug 2010 01:05:43 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <atom:link rel='hub' href='http://gccfeli.cn/?pushpress=hub'/> <item><title>C# 线程终止(Abort)的原理</title><link>http://gccfeli.cn/2010/08/c-%e7%ba%bf%e7%a8%8b%e7%bb%88%e6%ad%a2abort%e7%9a%84%e5%8e%9f%e7%90%86.html</link> <comments>http://gccfeli.cn/2010/08/c-%e7%ba%bf%e7%a8%8b%e7%bb%88%e6%ad%a2abort%e7%9a%84%e5%8e%9f%e7%90%86.html#comments</comments> <pubDate>Tue, 17 Aug 2010 00:37:19 +0000</pubDate> <dc:creator>Felicia</dc:creator> <category><![CDATA[C#]]></category> <category><![CDATA[C# 多线程]]></category><guid
isPermaLink="false">http://gccfeli.cn/2010/08/c-%e7%ba%bf%e7%a8%8b%e7%bb%88%e6%ad%a2abort%e7%9a%84%e5%8e%9f%e7%90%86.html</guid> <description><![CDATA[假设有两个线程A和B，A调用了b.Abort，这句的作用就是，无论B运行到哪里了，在B中当前运行点上抛出ThreadAbortException，A中无法catch到这个Exception，因为它根本不在A中。B可以用catch探测到这个异常，但这个异常会在B的每层catch的末尾自动重新抛出，所以实际上无法被B的任何catch语句真的catch住，他会一直抛出到B的最顶层，使得B被中断。
综上所述，不是将要终结B线程时用ThreadAbortException通知B，而是B就是被这个ThreadAbortException本身终结的，这个异常就是终结线程的原理。通知只是其附加功能。不是因为终结是非正常或者什么什么其他原因所以才要抛这个异常，而是就通过此异常终结线程，没有这个异常就不能使线程终结。
]]></description> <content:encoded><![CDATA[<p>假设有两个线程A和B，A调用了b.Abort，这句的作用就是，无论B运行到哪里了，在B中当前运行点上抛出ThreadAbortException，A中无法catch到这个Exception，因为它根本不在A中。B可以用catch探测到这个异常，但这个异常会在B的每层catch的末尾自动重新抛出，所以实际上无法被B的任何catch语句真的catch住，他会一直抛出到B的最顶层，使得B被中断。</p><p>综上所述，不是将要终结B线程时用ThreadAbortException通知B，而是B就是被这个ThreadAbortException本身终结的，这个异常就是终结线程的原理。通知只是其附加功能。不是因为终结是非正常或者什么什么其他原因所以才要抛这个异常，而是就通过此异常终结线程，没有这个异常就不能使线程终结。</p> ]]></content:encoded> <wfw:commentRss>http://gccfeli.cn/2010/08/c-%e7%ba%bf%e7%a8%8b%e7%bb%88%e6%ad%a2abort%e7%9a%84%e5%8e%9f%e7%90%86.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>我现在用的服务器</title><link>http://gccfeli.cn/2010/07/my-server.html</link> <comments>http://gccfeli.cn/2010/07/my-server.html#comments</comments> <pubDate>Mon, 12 Jul 2010 09:16:20 +0000</pubDate> <dc:creator>Felicia</dc:creator> <category><![CDATA[心情日记]]></category> <category><![CDATA[服务器]]></category><guid
isPermaLink="false">http://gccfeli.cn/2010/07/%e6%88%91%e7%8e%b0%e5%9c%a8%e7%94%a8%e7%9a%84%e6%9c%8d%e5%8a%a1%e5%99%a8.html</guid> <description><![CDATA[
]]></description> <content:encoded><![CDATA[<p><a
href="http://gccfeli.cn/wp-content/uploads/2010/07/good.jpg"><img
class="alignnone size-full wp-image-820" title="牛逼的性能：16核2.5G CPU，25G内存" src="http://gccfeli.cn/wp-content/uploads/2010/07/good.jpg" alt="" width="400" height="300" /></a></p> ]]></content:encoded> <wfw:commentRss>http://gccfeli.cn/2010/07/my-server.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>我绑架了你的证据 嘿嘿</title><link>http://gccfeli.cn/2010/05/%e6%88%91%e7%bb%91%e6%9e%b6%e4%ba%86%e4%bd%a0%e7%9a%84%e8%af%81%e6%8d%ae-%e5%98%bf%e5%98%bf.html</link> <comments>http://gccfeli.cn/2010/05/%e6%88%91%e7%bb%91%e6%9e%b6%e4%ba%86%e4%bd%a0%e7%9a%84%e8%af%81%e6%8d%ae-%e5%98%bf%e5%98%bf.html#comments</comments> <pubDate>Sun, 09 May 2010 15:24:57 +0000</pubDate> <dc:creator>Ader</dc:creator> <category><![CDATA[心情日记]]></category><guid
isPermaLink="false">http://gccfeli.cn/2010/05/%e6%88%91%e7%bb%91%e6%9e%b6%e4%ba%86%e4%bd%a0%e7%9a%84%e8%af%81%e6%8d%ae-%e5%98%bf%e5%98%bf.html</guid> <description><![CDATA[
]]></description> <content:encoded><![CDATA[<p><a
href="http://gccfeli.cn/wp-content/uploads/2010/07/untitled.bmp"><img
class="alignnone size-full wp-image-815" src="http://gccfeli.cn/wp-content/uploads/2010/07/untitled.bmp" alt="" /></a></p> ]]></content:encoded> <wfw:commentRss>http://gccfeli.cn/2010/05/%e6%88%91%e7%bb%91%e6%9e%b6%e4%ba%86%e4%bd%a0%e7%9a%84%e8%af%81%e6%8d%ae-%e5%98%bf%e5%98%bf.html/feed</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>避免sprintf目标缓冲区溢出</title><link>http://gccfeli.cn/2010/04/avoid-sprintf-buffer-overflow.html</link> <comments>http://gccfeli.cn/2010/04/avoid-sprintf-buffer-overflow.html#comments</comments> <pubDate>Mon, 26 Apr 2010 11:18:06 +0000</pubDate> <dc:creator>Felicia</dc:creator> <category><![CDATA[雕虫小技]]></category> <category><![CDATA[GNU C]]></category><guid
isPermaLink="false">http://gccfeli.cn/2010/04/%e9%81%bf%e5%85%8dsprintf%e7%9b%ae%e6%a0%87%e7%bc%93%e5%86%b2%e5%8c%ba%e6%ba%a2%e5%87%ba.html</guid> <description><![CDATA[如果为sprintf准备的缓冲区大小不足，那么有可能导致缓冲区溢出后改写其他区域，这是非常危险的。
我目前的解决方案是用snprintf计算出目标缓冲区大小，然后分配一个合适的缓冲区，再打印进去。
代码如下：//字符串后面有个\0，所以要在snprintf计算出来的长度上加1int buf_len = snprintf(NULL, 0, format, foo, bar) + 1;char *buf = (char *)malloc(buf_len);sprintf(buf, format, foo, bar);do_somthing();free(buf);]]></description> <content:encoded><![CDATA[<p>如果为sprintf准备的缓冲区大小不足，那么有可能导致缓冲区溢出后改写其他区域，这是非常危险的。</p><p>我目前的解决方案是用snprintf计算出目标缓冲区大小，然后分配一个合适的缓冲区，再打印进去。</p><p>代码如下：</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main"><span
class="hl-comment">//字符串后面有个\0，所以要在snprintf计算出来的长度上加1</span><span
class="hl-code"><br
/></span><span
class="hl-types">int</span><span
class="hl-code"> </span><span
class="hl-identifier">buf_len</span><span
class="hl-code"> = </span><span
class="hl-identifier">snprintf</span><span
class="hl-brackets">(</span><span
class="hl-prepro">NULL</span><span
class="hl-code">, </span><span
class="hl-number">0</span><span
class="hl-code">, </span><span
class="hl-identifier">format</span><span
class="hl-code">, </span><span
class="hl-identifier">foo</span><span
class="hl-code">, </span><span
class="hl-identifier">bar</span><span
class="hl-brackets">)</span><span
class="hl-code"> + </span><span
class="hl-number">1</span><span
class="hl-code">;<br
/></span><span
class="hl-types">char</span><span
class="hl-code"> *</span><span
class="hl-identifier">buf</span><span
class="hl-code"> = </span><span
class="hl-brackets">(</span><span
class="hl-types">char</span><span
class="hl-code"> *</span><span
class="hl-brackets">)</span><span
class="hl-identifier">malloc</span><span
class="hl-brackets">(</span><span
class="hl-identifier">buf_len</span><span
class="hl-brackets">)</span><span
class="hl-code">;<br
/></span><span
class="hl-identifier">sprintf</span><span
class="hl-brackets">(</span><span
class="hl-identifier">buf</span><span
class="hl-code">, </span><span
class="hl-identifier">format</span><span
class="hl-code">, </span><span
class="hl-identifier">foo</span><span
class="hl-code">, </span><span
class="hl-identifier">bar</span><span
class="hl-brackets">)</span><span
class="hl-code">;<br
/></span><span
class="hl-identifier">do_somthing</span><span
class="hl-brackets">()</span><span
class="hl-code">;<br
/></span><span
class="hl-identifier">free</span><span
class="hl-brackets">(</span><span
class="hl-identifier">buf</span><span
class="hl-brackets">)</span><span
class="hl-code">;</span></div></div></div> ]]></content:encoded> <wfw:commentRss>http://gccfeli.cn/2010/04/avoid-sprintf-buffer-overflow.html/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Vim 查找和替换</title><link>http://gccfeli.cn/2010/04/vim-search-and-find.html</link> <comments>http://gccfeli.cn/2010/04/vim-search-and-find.html#comments</comments> <pubDate>Sun, 18 Apr 2010 06:30:48 +0000</pubDate> <dc:creator>Felicia</dc:creator> <category><![CDATA[雕虫小技]]></category> <category><![CDATA[GVIM]]></category><guid
isPermaLink="false">http://gccfeli.cn/?p=812</guid> <description><![CDATA[简单替换表达式
替换命令可以在全文中用一个单词替换另一个单词：:%s/four/4/g&#8220;%&#8221; 范围前缀表示在所有行中执行替换。最后的  &#8220;g&#8221; 标记表示替换行中的所有匹配点。如果仅仅对当前行进行操作，那么只要去掉%即可
如果你有一个象 &#8220;thirtyfour&#8221; 这样的单词，上面的命令会出错。这种情况下，这个单词会被替换成&#8221;thirty4&#8243;。要解决这个问题，用  &#8220;\&#60;&#8221; 来指定匹配单词开头：:%s/\&#38;lt;four/4/g显然，这样在处理  &#8220;fourty&#8221; 的时候还是会出错。用  &#8220;\&#62;&#8221; 来解决这个问题：:%s/\&#38;lt;four\&#38;gt;/4/g如果你在编码，你可能只想替换注释中的  &#8220;four&#8221;，而保留代码中的。由于这很难指定，可以在替换命令中加一个 &#8220;c&#8221; 标 记，这样，Vim  会在每次替换前提示你：:%s/\&#38;lt;four\&#38;gt;/4/gc删除多余的空格
要删除这些每行后面多余的空格，可以执行如下命令：:%s/\s\+$//命令前面指明范围是  &#8220;%&#8221;，所以这会作用于整个文件。&#8221;substitute&#8221; 命令的匹配模式是&#8221;\s\+$&#8221;。这表示行末（$）前的 一个或者多个（\+）空格（\s）。替换命令的  &#8220;to&#8221; 部分是空的：&#8221;//&#8221;。这样就会删除那些匹配的空白字符。
匹配重复性模式
星号项  &#8220;*&#8221; 规定在它前面的项可以重复任意次。因此:/a*匹配 &#8220;a&#8221;，&#8221;aa&#8221;，&#8221;aaa&#8221;，等等。但也匹配 &#8220;&#8221; (空字串)，因为零次也包含在内。星号 &#8220;*&#8221; 仅 仅应用于那个紧邻在它前面的项。因此  &#8220;ab*&#8221; 匹配 &#8220;a&#8221;，&#8221;ab&#8221;，&#8221;abb&#8221;,&#8221;abbb&#8221;，等等。如要多次重复整个字 符串，那么该字符串必须被组成一个项。组成一项的方法就是在它前面加 &#8220;\(&#8220;， 后面加 &#8220;\)&#8221;。因此这个命令:/\(ab\)*匹配: &#8220;ab&#8221;，&#8221;abab&#8221;，&#8221;ababab&#8221;，等等。而且也匹配 &#8220;&#8221;。
要避免匹配空字串，使用 &#8220;\+&#8221;。这表示前面一项可以被匹配一次或多次。/ab\+匹配 &#8220;ab&#8221;，&#8221;abb&#8221;，&#8221;abbb&#8221;，等等。它不匹配 后面没 有跟随 &#8220;b&#8221; 的 [...]]]></description> <content:encoded><![CDATA[<h3>简单替换表达式</h3><p>替换命令可以在全文中用一个单词替换另一个单词：</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">:%s/four/4/g</div></div></div><p>&#8220;%&#8221; 范围前缀表示在所有行中执行替换。最后的  &#8220;g&#8221; 标记表示替换行中的所有匹配点。如果仅仅对当前行进行操作，那么只要去掉%即可</p><p>如果你有一个象 &#8220;thirtyfour&#8221; 这样的单词，上面的命令会出错。这种情况下，这个单词会被替换成&#8221;thirty4&#8243;。要解决这个问题，用  &#8220;\&lt;&#8221; 来指定匹配单词开头：</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">:%s/\&amp;lt;four/4/g</div></div></div><p>显然，这样在处理  &#8220;fourty&#8221; 的时候还是会出错。用  &#8220;\&gt;&#8221; 来解决这个问题：</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">:%s/\&amp;lt;four\&amp;gt;/4/g</div></div></div><p>如果你在编码，你可能只想替换注释中的  &#8220;four&#8221;，而保留代码中的。由于这很难指定，可以在替换命令中加一个 &#8220;c&#8221; 标 记，这样，Vim  会在每次替换前提示你：</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">:%s/\&amp;lt;four\&amp;gt;/4/gc</div></div></div><h3>删除多余的空格</h3><p>要删除这些每行后面多余的空格，可以执行如下命令：</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">:%s/\s\+$//</div></div></div><p>命令前面指明范围是  &#8220;%&#8221;，所以这会作用于整个文件。&#8221;substitute&#8221; 命令的匹配模式是&#8221;\s\+$&#8221;。这表示行末（$）前的 一个或者多个（\+）空格（\s）。替换命令的  &#8220;to&#8221; 部分是空的：&#8221;//&#8221;。这样就会删除那些匹配的空白字符。</p><h3>匹配重复性模式</h3><p>星号项  &#8220;*&#8221; 规定在它前面的项可以重复任意次。因此:</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">/a*</div></div></div><p>匹配 &#8220;a&#8221;，&#8221;aa&#8221;，&#8221;aaa&#8221;，等等。但也匹配 &#8220;&#8221; (空字串)，因为零次也包含在内。星号 &#8220;*&#8221; 仅 仅应用于那个紧邻在它前面的项。因此  &#8220;ab*&#8221; 匹配 &#8220;a&#8221;，&#8221;ab&#8221;，&#8221;abb&#8221;,&#8221;abbb&#8221;，等等。如要多次重复整个字 符串，那么该字符串必须被组成一个项。组成一项的方法就是在它前面加 &#8220;\(&#8220;， 后面加 &#8220;\)&#8221;。因此这个命令:</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">/\(ab\)*</div></div></div><p>匹配: &#8220;ab&#8221;，&#8221;abab&#8221;，&#8221;ababab&#8221;，等等。而且也匹配 &#8220;&#8221;。</p><p>要避免匹配空字串，使用 &#8220;\+&#8221;。这表示前面一项可以被匹配一次或多次。</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">/ab\+</div></div></div><p>匹配 &#8220;ab&#8221;，&#8221;abb&#8221;，&#8221;abbb&#8221;，等等。它不匹配 后面没 有跟随 &#8220;b&#8221; 的 &#8220;a&#8221;。</p><p>要匹配一个可选项，用  &#8220;\=&#8221;。 例如:</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">/folders\=</div></div></div><p>匹配 &#8220;folder&#8221; 和 &#8220;folders&#8221;。</p><h3>指定重复次数</h3><p>要匹配某一项的特定次数重复，使用  &#8220;\{n,m}&#8221; 这样的形式。其中 &#8220;n&#8221; 和 &#8220;m&#8221; 都是数字。在它前面的那个项将被重复  &#8220;n&#8221; 到 &#8220;m&#8221; 次 (|inclusive| 包含  &#8220;n&#8221; 和 &#8220;m&#8221;)。例如:</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">/ab\{3,5}</div></div></div><p>匹配 &#8220;abbb&#8221;，&#8221;abbbb&#8221; 以及  &#8220;abbbbb&#8221;。</p><p>当 &#8220;n&#8221; 省略时，被默认为零。当  &#8220;m&#8221; 省略时，被默认为无限大。当  &#8220;,m&#8221; 省略时，就表示重复正好  &#8220;n&#8221; 次。例如:</p><p>模式           匹配次数</p><p>\{,4}           0，1，2，3 或 4</p><p>\{3,}           3，4，5，等等</p><p>\{0,1}          0  或 1，同 \=</p><p>\{0,}           0  或 更多， 同 *</p><p>\{1,}           1  或 更多， 同 \+</p><p>\{3}            3</p><h3>多选一匹配</h3><p>在一个查找模式中，&#8221;或&#8221; 运算符是  &#8220;\|&#8221;。例如:</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">/foo\|bar</div></div></div><p>这个命令匹配了 &#8220;foo&#8221; 或 &#8220;bar&#8221;。更多的抉择可以连在后面:</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">/one\|two\|three</div></div></div><p>匹配 &#8220;one&#8221;，&#8221;two&#8221; 或  &#8220;three&#8221;。</p><p>如要匹配其多次重复，那么整个抉择结构须置于  &#8220;\(&#8221; 和 &#8220;\)&#8221; 之间:</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">/\(foo\|bar\)\+</div></div></div><p>这个命令匹配  &#8220;foo&#8221;，&#8221;foobar&#8221;，&#8221;foofoo&#8221;，&#8221;barfoobar&#8221;，等等。</p><p>再举个例子:</p><div
class="hl-wrapper"><div
class="hl-surround"><div
class="hl-main">/end\(if\|while\|for\)</div></div></div><p>这个命令匹配  &#8220;endif&#8221;，&#8221;endwhile&#8221; 和 &#8220;endfor&#8221;。</p> ]]></content:encoded> <wfw:commentRss>http://gccfeli.cn/2010/04/vim-search-and-find.html/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 3/14 queries in 0.003 seconds using disk

Served from: gccfeli.cn @ 2010-09-10 00:38:01 -->