作者ric2k1 (Ric)
看板EE_DSnP
標題Re: [問題] MSET 指令
時間Wed Nov 22 10:57:43 2006
※ 引述《samuelduan ()》之銘言:
: ※ 引述《ric2k1 (Ric)》之銘言:
: : 搞笑了... 居然把 "else if" 括錯地方...
: : In cmdParser.cpp ---
: : bool
: : CmdExec::lexSingleOption
: : (const string& option, string& token, bool optional) const
: : {
: : size_t n = myStrGetTok(option, token);
: : if (!optional) {
: : if (token.size() == 0) {
: : errorOption(CMD_OPT_MISSING, "");
: : return false;
: : }
: : else if (n != string::npos) {
: : errorOption(CMD_OPT_EXTRA, option.substr(n));
: : return false;
: : } // 這個括弧放錯了.... orz
: : }
: : return true;
: : }
: 這樣改了之後 如果我以下面的方式執行
: e.g
: mcalc> help help 3 5 7
: Usage: HELp [(string cmd)]
: 它就不會去管後面的部份是否全部正確 而會照常執行
: 其他使用到 lexSingleOption 的好像都會有同樣的情形
: 我記得還沒改之前 似乎都可偵測的到 ...
我的天呀... 真是太 embarrasing 了...
CmdExec::lexSingleOption 應該是要改成 ---
bool
CmdExec::lexSingleOption
(const string& option, string& token, bool optional) const
{
size_t n = myStrGetTok(option, token);
if (!optional) {
if (token.size() == 0) {
errorOption(CMD_OPT_MISSING, "");
return false;
}
}
// No matter it is optional or not, n should be the end
if (n != string::npos) {
errorOption(CMD_OPT_EXTRA, option.substr(n));
return false;
}
return true;
}
-------
應該是沒錯了吧?
好吧, 這部分的 code 我會請助教特別注意, 不要扣大家的分數...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.21.240
推 davidlue:有點不敢upload了XD 11/22 13:14
→ davidlue:請問這次沒有測資嗎? 看同學抓出這麼多問題 11/22 13:14
→ davidlue:真的很怕自己寫的東西還有地方錯orz 11/22 13:14