| 晓斌's profile黄晓斌的个人空间BlogLists | Help |
|
April 26 Muttrc, 对付gb.*, utf-8mutt? 对付恼火的gb*以及utf-8。 我的locale: LANG=en_US.UTF-8 LC_CTYPE=zh_CN.UTF-8 在muttrc中写上: charset-hook !(gb.*|utf-8) gb2312 #所有非gb.*标记和非utf-8标记的都当作gb2312 iconv-hook gb.* utf-8 #再把gb2312转为utf-8 set locale="zh_CN.UTF-8" set send_charset="us-ascii:iso-8859-1:gb2312:utf-8" set charset="utf-8" 前两行是重点... 如果直接当作utf-8来处理的话,由于编码不同,导致什么都显示不出来... March 23 申请到了Google Page Creator迅雷打算进入Linux平台了迅雷这一套下载系统(所以为系统,因其并不只是下载),点子并不怎么新颖,但是它的确把这个点子做得非常好。
迅雷使用的多资源超线程技术基于网格原理,能够将网络上存在的服务器和计算机资源进行有效的整合,构成独特的迅雷网络,通过迅雷网络各种数据文件能够以最快的速度进行传递。 多资源超线程技术还具有互联网下载负载均衡功能,在不降低用户体验的前提下,迅雷网络可以对服务器资源进行均衡,有效降低了服务器负载。 有关CVS的第三方代码追踪对于第三方代码,我以前的习惯是,使用本地仓库的main trunk来追踪,而使用vendor branch来开发自己的patch版本。
昨天阅读了Hellwolf的《实践CVS和Subversion ...》(未完成),他使用vendor branch来进行追踪,而主干用来开发自己的版本。
仔细想了一下这两种管理方案,对比之下,我觉得hw叙述的方案更加适合。其中最大的好处是: checkout的时候不用使用-r来stick branch tag,trunk的HEAD即是最新修改的代码。
hw现在正在写svn的部分,加油吧!
非常棒的Ion3我会因新加入的mod_sp感谢Ion3的作者,它非常完美的让Ion3拥有了一个QuakeConsole,不用我自己动手动脚了。 一直很欣赏fvwm-crystal的QuakeConsole,想在Ion3下面用脚本实现一个,未果。这次Ion3-20060305-r1,让我十足爽了一把,mod_sp,status_bar的新style,快速的query…… ps. Ion3和Fvwm是我最喜欢的wm。Ion3的简洁,Fvwm随意,正符合我的胃口。 March 18 Unicode Mutt参照Unicode Mutt将Mutt安装至系统。 查看html,w3m在Unicode的支持上做得不错(lynx我总没有办法让它显示正确),下载,编译并安装至系统。 编辑~/.mailcap文件,加入,或者修改text/html一行为: text/html; w3m -dump %s; needsterminal; copiousoutput; nametemplate=%s.html 当然,也可以用任何浏览器打开。 编辑.muttrc 加入,或修改charset为: set charset="utf-8" 现在mutt可以非常漂亮的工作了。 March 15 Evaluate Order在[SICP 1.3]中有如下的规则: To evaluate a combination, do the following: 1. Evaluate the subexpressions of the combination. 2. Apply the procedure that is the value of the leftmost subexpression (the operator) to the arguments that are the values of the other subexpressions (the operands). 在[R5RS 4.1.3]中说明,Scheme对组合式的求值强调的是未定义的顺序,并且以任何顺序,或者并发执行的结果,与某一特定顺序求值的结果是一样的。 是否我对[SICP]中,首先求值operator,然后是其他的以任意顺序求值operands的规则理解错了,有待考证。 About the SugarSyntactic
sugar causes cancer of the semicolon. --Alan Perlis 在Lua中,可以找到 t = {} t.f = function(self, params, ...) ... end 通过语法上的甜头可以写为 function t:f(params, ...) ... end 拥有默认的self参数,作为t的一个引用. 那么对于t.f的调用 在使用者看来,就有两种 t:f(params,...) t.f(t, params,...) 如果没有清楚的文档,不敢保证用户会按照你想的方式来调用。 自[SICP, footnote.11]: 语法上的甜头(syntactic sugar)只不过为那些完全可以使用统一形式表述的语法增加另一种表现形式而已。 如果一个语言的语法上的甜头过多,程序员使用过滥的话,只会白白的增加代码的复杂性而已。 如上面的Lua代码,使用``:''省略掉一个self参数,如果不写明t是一个对象,或者不指出t.f应该使用t:f进行调用,在不参考代码的情况下,虽然Lua的track back infomation会指出试图引用一个nil元素,也难保不会杀死用户的脑细胞。 Lisp,hmm,是藐视语法的;^) March 03 Mechanisms of Languages[SICP]
Every powerful language has three mechanisms for accomplishing this:
February 28 LUA: Incompatibilities with the Previous Version[refman-5.1]Here we list the incompatibilities that may be found when moving a program from Lua 5.0 to Lua 5.1. You can avoid most of the incompatibilities compiling Lua with appropriate options (see file luaconf.h). However, all these compatibility options will be removed in the next version of Lua.
Incompatibilities with version 5.0MChanges in the LanguageThe vararg system changed from the pseudo-argument arg with a table with the extra arguments to the vararg expression. (Option LUA_COMPAT_VARARG in luaconf.h.)There was a subtle change in the scope of the implicit variables of the for statement and for the repeat statement. The long string/long comment syntax ([[...]]) does not allow nesting. You can use the new syntax ([=[...]=]) in these cases. (Option LUA_COMPAT_LSTR in luaconf.h.)
Changes in the LibrariesFunction string.gfind was renamed string.gmatch. (Option LUA_COMPAT_GFIND)When string.gsub is called with a function as its third argument, whenever this function returns nil or false the replacement string is the whole match, instead of the empty string. Function table.setn was deprecated. Function table.getn corresponds to the new length operator (#); use the operator instead of the function. (Option LUA_COMPAT_GETN) Function loadlib was renamed package.loadlib. (Option LUA_COMPAT_LOADLIB) Function math.mod was renamed math.fmod. (Option LUA_COMPAT_MOD) Functions table.foreach and table.foreachi are deprecated. You can use a for loop with pairs or ipairs instead. There were substantial changes in function require due to the new module system. However, the new behavior is mostly compatible with the old, but require gets the path from package.path instead of from LUA_PATH. Function collectgarbage has different arguments. Function gcinfo is deprecated; use collectgarbage("count") instead.
hanges in the APIThe luaopen_* functions (to open libraries) cannot be called directly, like a regular C function. They must be called through Lua, like a Lua function.Function lua_open was replaced by lua_newstate to allow the user to set a memory allocation function. You can use luaL_newstate from the standard library to create a state with a standard allocation function (based on realloc). Functions luaL_getn and luaL_setn (from the auxiliary library) are deprecated. Use lua_objlen instead of luaL_getn and nothing instead of luaL_setn. Function luaL_openlib was replaced by luaL_register. 基本上看完了refman,不过没发现令人激动的序列化相关的lib或者package(除了chunk外),要序列化一个table,还得自己一个一个的来.上lua-users.org看看,或许会发现一些power patch. February 24 Lua 5.1目前看到的,比较醒目的变化是require, module 函数和 package library,比以前的LUA_PATH清爽多了。
另外,API 和 AuxLib 现在给人的感觉比较清爽,某些kernel api可能会被取消或者转入AuxLib。table.foreach(i)也成了deprecated function。
让人费解的是 operator #
"len": the # operation.
function len_event (op)
if type(op) == "string" then return strlen(op) -- primitive string length elseif type(op) == "table" then return #op -- primitive table length else local h = metatable(op).__len if h then -- call the handler with the operand return h(op) else -- no handler available: default behavior error("...") end end end 不过当看了:
[5.0.2 refman] Every table and userdata object in Lua may have a metatable.
[5.1 refman] Every value in Lua may have a metatable.
就明白了~~
这点算是比较大的变化吧
还有,改变非table的metatable时应该:
[5.1 refman] You can replace the metatable of tables through the setmetatable function. You cannot change the metatable of other types from Lua (except using the debug library); you must use the C API for that.
February 23 Lua二三事一、Lua 5.1 发布了,文档还没有仔细读,看ChangeLog,似乎增加了一些东西
二、在对Lua element 做 clone 操作时发现:
看来, lua_State只是一个堆栈, 虚拟机还隐藏在背后. 所有的lua element都携带有虚拟机信息, 跟使用的stack无关. xmove也只是copy了ref到新的stack, 并没有复制对象.
如果在20行处,重新lua_pushstring(L2, "test_key")当作key, 这时候key携带的是L2的信息, 对表操作时,将会得到与之关联的nil, 而不是L1中所关联的值.
现在问题变成了,如何简便地复制一个Lua对象. 在Lua中只有'= 文字量', '{}' (表构造)能创建对象实例, 此外其他的, 都是ref February 19 Python newbie开始了解Python 单从Python tut和Dive into Python来看,跟Lua(由于我是先接触Lua)有很大的相似之处。 比如closures,对象(如果称Lua的table为类,使用creator返回的table为对象的话)的观点,还有coroutine的 yeild等等。 def foo(): x = ... def y(): return x return y 或者 def foo(): x = ... return lambda : x 跟 function foo() x = ... return function() return x end end January 24 厌烦了Makefile写了许久的Makefile,终于厌烦了 终于通读了一遍info autoconf 和 info automake 然而又陷入另一个漩涡... 不过比起M$的那套IDE,AutoTools还是可爱许多。 M$似乎不知道programmmmmers的需要,以为programer只会点点鼠标,做几个宏,写几个assist。或者,是我太笨不会用的原因。 M$总是将简单的事情变复杂,复杂的事情变繁琐。(结论自 `Linux is NOT Windoz', 以及我的眼睛和手指头) 谁来教我用一下VS200x!为自己的代码们贴上.vcproj的标签,耗费了很多精力阿--; 此外,VS assist,这个东西,不得不特别点名表扬一下,当然,是作为代码粉碎软件。 January 22 2038年1月19日11时19分07秒dot99@hardcoreX ~ $ touch -t 203801191114.07 file dot99@hardcoreX ~ $ touch -t 203801191114.08 file touch: invalid date format `203801191114.08' time_t overflow了... 看来某个时候time_t需要换下血...Y2038问题.. http://www.linuxfans.org/nuke/modules.php?name=News&file=article&sid=2995&mode=&order=0&thold=0 January 17 lunit -- Lua unit test suite, a TDD tool of Lua--[[-------------------------------------------------------------------------- This file is part of lunit 0.3 (alpha). For Details about lunit look at: http://www.nessie.de/mroth/lunit/ Author: Michael Roth <mroth@nessie.de> Copyright (c) 2004 Michael Roth <mroth@nessie.de> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --]]-------------------------------------------------------------------------- ----------------------- -- Intialize package -- ----------------------- local P = { } lunit = P -- Import local type = type local print = print local ipairs = ipairs local pairs = pairs local string = string local table = table local pcall = pcall local xpcall = xpcall local traceback = debug.traceback local error = error local setmetatable = setmetatable local rawset = rawset local orig_assert = assert local getfenv = getfenv local setfenv = setfenv local tostring = tostring -- Start package scope setfenv(1, P) -------------------------------- -- Private data and functions -- -------------------------------- local run_testcase local do_assert, check_msg local stats = { } local testcases = { } local stats_inc, tc_mt -------------------------- -- Type check functions -- -------------------------- function is_nil(x) return type(x) == "nil" end function is_boolean(x) return type(x) == "boolean" end function is_number(x) return type(x) == "number" end function is_string(x) return type(x) == "string" end function is_table(x) return type(x) == "table" end function is_function(x) return type(x) == "function" end function is_thread(x) return type(x) == "thread" end function is_userdata(x) return type(x) == "userdata" end ---------------------- -- Assert functions -- ---------------------- function assert(assertion, msg) stats_inc("assertions") check_msg("assert", msg) do_assert(not not assertion, "assertion failed (was: "..tostring(assertion)..")", msg) -- (convert assertion to bool) return assertion end function assert_fail(msg) stats_inc("assertions") check_msg("assert_fail", msg) do_assert(false, "failure", msg) end function assert_true(actual, msg) stats_inc("assertions") check_msg("assert_true", msg) do_assert(is_boolean(actual), "true expected but was a "..type(actual), msg) do_assert(actual == true, "true expected but was false", msg) return actual end function assert_false(actual, msg) stats_inc("assertions") check_msg("assert_false", msg) do_assert(is_boolean(actual), "false expected but was a "..type(actual), msg) do_assert(actual == false, "false expected but was true", msg) return actual end function assert_equal(expected, actual, msg) stats_inc("assertions") check_msg("assert_equal", msg) do_assert(expected == actual, "expected '"..tostring(expected).."' but was '"..tostring(actual).."'", msg) return actual end function assert_not_equal(unexpected, actual, msg) stats_inc("assertions") check_msg("assert_not_equal", msg) do_assert(unexpected ~= actual, "'"..tostring(expected).."' not expected but was one", msg) return actual end function assert_match(pattern, actual, msg) stats_inc("assertions") check_msg("assert_match", msg) do_assert(is_string(pattern), "assert_match expects the pattern as a string") do_assert(is_string(actual), "expected a string to match pattern '"..pattern.."' but was a '"..type(actual).."'", msg) do_assert(not not string.find(actual, pattern), "expected '"..actual.."' to match pattern '"..pattern.."' but doesn't", msg) return actual end function assert_not_match(pattern, actual, msg) stats_inc("assertions") check_msg("assert_not_match", msg) do_assert(is_string(actual), "expected a string to not match pattern '"..pattern.."' but was a '"..type(actual).."'", msg) do_assert(string.find(actual, pattern) == nil, "expected '"..actual.."' to not match pattern '"..pattern.."' but it does", msg) return actual end function assert_nil(actual, msg) stats_inc("assertions") check_msg("assert_nil", msg) do_assert(is_nil(actual), "nil expected but was a "..type(actual), msg) return actual end function assert_not_nil(actual, msg) stats_inc("assertions") check_msg("assert_not_nil", msg) do_assert(not is_nil(actual), "nil not expected but was one", msg) return actual end function assert_boolean(actual, msg) stats_inc("assertions") check_msg("assert_boolean", msg) do_assert(is_boolean(actual), "boolean expected but was a "..type(actual), msg) return actual end function assert_not_boolean(actual, msg) stats_inc("assertions") check_msg("assert_not_boolean", msg) do_assert(not is_boolean(actual), "boolean not expected but was one", msg) return actual end function assert_number(actual, msg) stats_inc("assertions") check_msg("assert_number", msg) do_assert(is_number(actual), "number expected but was a "..type(actual), msg) return actual end function assert_not_number(actual, msg) stats_inc("assertions") check_msg("assert_not_number", msg) do_assert(not is_number(actual), "number not expected but was one", msg) return actual end function assert_string(actual, msg) stats_inc("assertions") check_msg("assert_string", msg) do_assert(is_string(actual), "string expected but was a "..type(actual), msg) return actual end function assert_not_string(actual, msg) stats_inc("assertions") check_msg("assert_not_string", msg) do_assert(not is_string(actual), "string not expected but was one", msg) return actual end function assert_table(actual, msg) stats_inc("assertions") check_msg("assert_table", msg) do_assert(is_table(actual), "table expected but was a "..type(actual), msg) return actual end function assert_not_table(actual, msg) stats_inc("assertions") check_msg("assert_not_table", msg) do_assert(not is_table(actual), "table not expected but was one", msg) return actual end function assert_function(actual, msg) stats_inc("assertions") check_msg("assert_function", msg) do_assert(is_function(actual), "function expected but was a "..type(actual), msg) return actual end function assert_not_function(actual, msg) stats_inc("assertions") check_msg("assert_not_function", msg) do_assert(not is_function(actual), "function not expected but was one", msg) return actual end function assert_thread(actual, msg) stats_inc("assertions") check_msg("assert_thread", msg) do_assert(is_thread(actual), "thread expected but was a "..type(actual), msg) return actual end function assert_not_thread(actual, msg) stats_inc("assertions") check_msg("assert_not_thread", msg) do_assert(not is_thread(actual), "thread not expected but was one", msg) return actual end function assert_userdata(actual, msg) stats_inc("assertions") check_msg("assert_userdata", msg) do_assert(is_userdata(actual), "userdata expected but was a "..type(actual), msg) return actual end function assert_not_userdata(actual, msg) stats_inc("assertions") check_msg("assert_not_userdata", msg) do_assert(not is_userdata(actual), "userdata not expected but was one", msg) return actual end function assert_error(msg, func) stats_inc("assertions") if is_nil(func) then func, msg = msg, nil end check_msg("assert_error", msg) do_assert(is_function(func), "assert_error expects a function as the last argument but it was a "..type(func)) local ok, errmsg = pcall(func) do_assert(ok == false, "error expected but no error occurred", msg) end function assert_pass(msg, func) stats_inc("assertions") if is_nil(func) then func, msg = msg, nil end check_msg("assert_pass", msg) do_assert(is_function(func), "assert_pass expects a function as the last argument but it was a "..type(func)) local ok, errmsg = pcall(func) if not ok then do_assert(ok == true, "no error expected but error was: "..errmsg, msg) end end ----------------------------------------------------------- -- Assert implementation that assumes it was called from -- -- lunit code which was called directly from user code. -- ----------------------------------------------------------- function do_assert(assertion, base_msg, user_msg) orig_assert(is_boolean(assertion)) orig_assert(is_string(base_msg)) orig_assert(is_string(user_msg) or is_nil(user_msg)) if not assertion then if user_msg then error(base_msg..": "..user_msg, 3) else error(base_msg.."!", 3) end end end ------------------------------------------- -- Checks the msg argument in assert_xxx -- ------------------------------------------- function check_msg(name, msg) orig_assert(is_string(name)) if not (is_nil(msg) or is_string(msg)) then error("lunit."..name.."() expects the optional message as a string but it was a "..type(msg).."!" ,3) end end ------------------------------------- -- Creates a new TestCase 'Object' -- ------------------------------------- function TestCase(name) do_assert(is_string(name), "lunit.TestCase() needs a string as an argument") local tc = { __lunit_name = name; __lunit_setup = nil; __lunit_tests = { }; __lunit_teardown = nil; } setmetatable(tc, tc_mt) table.insert(testcases, tc) return tc end tc_mt = { __newindex = function(tc, key, value) rawset(tc, key, value) if is_string(key) and is_function(value) then local name = string.lower(key) if string.find(name, "^test") or string.find(name, "test$") then table.insert(tc.__lunit_tests, key) elseif name == "setup" then tc.__lunit_setup = value elseif name == "teardown" then tc.__lunit_teardown = value end end end } ----------------------------------------- -- Wrap Functions in a TestCase object -- ----------------------------------------- function wrap(name, ...) if is_function(name) then table.insert(arg, 1, name) name = "Anonymous Testcase" end local tc = TestCase(name) for index, test in ipairs(arg) do tc["Test #"..tostring(index)] = test end return tc end ---------------------------------- -- Runs the complete Test Suite -- ---------------------------------- function run() --------------------------- -- Initialize statistics -- --------------------------- stats.testcases = 0 -- Total number of Test Cases stats.tests = 0 -- Total number of all Tests in all Test Cases stats.run = 0 -- Number of Tests run stats.notrun = 0 -- Number of Tests not run stats.failed = 0 -- Number of Tests failed stats.passed = 0 -- Number of Test passed stats.assertions = 0 -- Number of all assertions made in all Test in all Test Cases -------------------------------- -- Count Test Cases and Tests -- -------------------------------- stats.testcases = table.getn(testcases) for _, tc in ipairs(testcases) do stats_inc("tests" , table.getn(tc.__lunit_tests)) end ------------------ -- Print Header -- ------------------ print() print("#### Test Suite with "..stats.tests.." Tests in "..stats.testcases.." Test Cases loaded.") ------------------------ -- Run all Test Cases -- ------------------------ for _, tc in ipairs(testcases) do run_testcase(tc) end ------------------ -- Print Footer -- ------------------ print() print("#### Test Suite finished.") local msg_assertions = stats.assertions.." Assertions checked. " local msg_passed = stats.passed == stats.tests and "All Tests passed" or stats.passed.." Tests passed" local msg_failed = stats.failed > 0 and ", "..stats.failed.." failed" or "" local msg_run = stats.notrun > 0 and ", "..stats.notrun.." not run" or "" print() print(msg_assertions..msg_passed..msg_failed..msg_run.."!") ----------------- -- Return code -- ----------------- if stats.passed == stats.tests then return 0 else return 1 end end ----------------------------- -- Runs a single Test Case -- ----------------------------- function run_testcase(tc) orig_assert(is_table(tc)) orig_assert(is_table(tc.__lunit_tests)) orig_assert(is_string(tc.__lunit_name)) orig_assert(is_nil(tc.__lunit_setup) or is_function(tc.__lunit_setup)) orig_assert(is_nil(tc.__lunit_teardown) or is_function(tc.__lunit_teardown)) -------------------------------------------- -- Protected call to a Test Case function -- -------------------------------------------- local function call(errprefix, func) orig_assert(is_string(errprefix)) orig_assert(is_function(func)) local ok, errmsg = xpcall(function() func(tc) end, traceback) if not ok then print() print(errprefix..": "..errmsg) end return ok end ------------------------------------ -- Calls setup() on the Test Case -- ------------------------------------ local function setup() if tc.__lunit_setup then return call("ERROR: setup() failed", tc.__lunit_setup) else return true end end ------------------------------------------ -- Calls a single Test on the Test Case -- ------------------------------------------ local function run(testname) orig_assert(is_string(testname)) orig_assert(is_function(tc[testname])) local ok = call("FAIL: "..testname, tc[testname]) if not ok then stats_inc("failed") else stats_inc("passed") end return ok end --------------------------------------- -- Calls teardown() on the Test Case -- --------------------------------------- local function teardown() if tc.__lunit_teardown then call("WARNING: teardown() failed", tc.__lunit_teardown) end end --------------------------------- -- Run all Tests on a TestCase -- --------------------------------- print() print("#### Running '"..tc.__lunit_name.."' ("..table.getn(tc.__lunit_tests).." Tests)...") for _, testname in ipairs(tc.__lunit_tests) do if setup() then run(testname) stats_inc("run") teardown() else print("WARN: Skipping '"..testname.."'...") stats_inc("notrun") end end end --------------------- -- Import function -- --------------------- function import(name) do_assert(is_string(name), "lunit.import() expects a single string as argument") local user_env = getfenv(2) -------------------------------------------------- -- Installs a specific function in the user env -- -------------------------------------------------- local function install(funcname) user_env[funcname] = P[funcname] end ---------------------------------------------------------- -- Install functions matching a pattern in the user env -- ---------------------------------------------------------- local function install_pattern(pattern) for funcname, _ in pairs(P) do if string.find(funcname, pattern) then install(funcname) end end end ------------------------------------------------------------ -- Installs assert() and all assert_xxx() in the user env -- ------------------------------------------------------------ local function install_asserts() install_pattern("^assert.*") end ------------------------------------------- -- Installs all is_xxx() in the user env -- ------------------------------------------- local function install_tests() install_pattern("^is_.+") end if name == "asserts" or name == "assertions" then install_asserts() elseif name == "tests" or name == "checks" then install_tests() elseif name == "all" then install_asserts() install_tests() install("TestCase") elseif string.find(name, "^assert.*") and P[name] then install(name) elseif string.find(name, "^is_.+") and P[name] then install(name) elseif name == "TestCase" then install("TestCase") else error("luniit.import(): invalid function '"..name.."' to import", 2) end end -------------------------------------------------- -- Installs a private environment on the caller -- -------------------------------------------------- function setprivfenv() local new_env = { } local new_env_mt = { __index = getfenv(2) } setmetatable(new_env, new_env_mt) setfenv(2, new_env) end -------------------------------------------------- -- Increments a counter in the statistics table -- -------------------------------------------------- function stats_inc(varname, value) orig_assert(is_table(stats)) orig_assert(is_string(varname)) orig_assert(is_nil(value) or is_number(value)) if not stats[varname] then return end stats[varname] = stats[varname] + (value or 1) end December 22 异常,还是异常<<Exceptional C++>>, GotW#21
-- 指出以下代码有多少条执行路径
... ...
commit-or-rollback 语义保证异常的安全(其中一种方法) December 17 skyeye.conf------------------------------------------------------------------------------------------ APPENDIX A: the content of skyeye.conf #-------------------------------------------------------------------------------- # memmap.conf and skyeye.conf are all skyeye's hareware coinfigure files. # memmap.conf is for skyeye-v0.2.5- # skyeye.conf is for skyeye-v0.2.5+ # usually you needn't to chang them. # for example, a AT91's configure file is shown below: #-------------------------------------------------------------------------------- # below is the cpu config info # cpu maybe arm7tdmi or arm720t cpu: arm7tdmi #-------------------------------------------------------------------------------- # below is the machine(develop board) config info # machine(develop board) maybe at91 or ep7312 mach: at91 #------------------------------------------------------------------------------- #NOTICE: this parameter is useless for skyeye-V0.3.1+ # have 7 memory bank (include RAM, ROM, mapped IO space) # below is the memory config info mem_num: 7 # map=M means ram/rom, map=I means mapped IO space, # type=RW means can be read or written, # type=R means read only, # addr=0x..... means the mem bank's beginning address, # size=0x..... means the mem bank's memory size, # file=... is the filesystem image file, used for uclinux4skyeye or armlinux4skyeye mem_bank: map=M, type=RW, addr=0x00000000, size=0x00004000 mem_bank: map=M, type=RW, addr=0x01000000, size=0x00400000 mem_bank: map=M, type=R, addr=0x01400000, size=0x00400000, file=./boot.rom mem_bank: map=M, type=RW, addr=0x02000000, size=0x00400000 mem_bank: map=M, type=RW, addr=0x02400000, size=0x00008000 mem_bank: map=M, type=RW, addr=0x04000000, size=0x00400000 mem_bank: map=I, type=RW, addr=0xf0000000, size=0x10000000 #now, add more options on mem_bank mem_bank: map=M, type=RW, addr=0x10000000, size=0x00000800, file=./loader.bin,boot=yes #start binary program at 0x100000000 #---------------------------------------------------------------------------------- # below is the net config info # state=on/off means simulated NIC is wired or not, # mac=.... means the mac addr in simulated NIC, # ethmod=tuntap/vnet means the virtual driver used in host evnironment, # hostip=... means the ip address in host environment to interactive with skyeye. # format: state=on/off mac=xx:xx:xx:xx:xx:xx ethmod=tuntap/vnet hostip=dd.dd.dd.dd # *********NOTICE********** #If you run two more skyeyes at the same time, # please use different skyeye.conf for each skyeye instance, and only one # skyeye run first and related skyeye.conf content has hostip value: # ...... # net: ... ethmod=vnet, hostip=ddd.ddd.ddd.ddd # other skyeye.conf should has content(hostip[0] should be 0): # ...... # net: ... ethmod=vnet, hostip=0.ddd.ddd.ddd net: state=on, mac=0:4:3:2:1:f, ethmod=tuntap, hostip=10.0.0.1 #------------------------------------------------------------------------------------ #uart: use it to read/write characters in another terminal #now you can use them to connect real serial port. #you can add an option to skyeye.conf as below: uart: fd_in=/dev/ttyS0, fd_out=/dev/ttyS0 #then use a terminal connect host's COM1, you can see the output in the terminal. #----------------------------------------------------------------------------------- #add log parameter which is used to recode the instr. flow and regs when #program are running. log: logon=0, logfile=/tmp/sk1.log, start=100000, end=200000 #logon = 0 or 1 0:doesn't log, 1 do log #logfile: the filename which have the log info #start: the start point of instruction flow to log, should >=0 #end: the end point of instructio flow to log #----------------------------------------------------------------- # below is the lcd config info # state=on/off means simulated LCD is wired or not lcd: state=on |
|
|