comparison scn2k/scn2k_cmd.cc @ 13:a05bf0823154

Fixes SubStr (RLdev's strsub/strrsub)
author thib
date Wed, 06 Aug 2008 12:34:34 +0000
parents 223b71206888
children d1bb7b365816
comparison
equal deleted inserted replaced
12:2e6a92ed913b 13:a05bf0823154
421 cmd.clear(); 421 cmd.clear();
422 break; } 422 break; }
423 case 5: // substring, index from left 423 case 5: // substring, index from left
424 case 6: // substring, index from right 424 case 6: // substring, index from right
425 // 全角対応らしい 425 // 全角対応らしい
426 //FIXME: Make sure it works properly
426 { int offset = cmd.args[2].value; 427 { int offset = cmd.args[2].value;
427 int len = strlen(cmd.Str(cmd.args[1])); 428 int len = strlen(cmd.Str(cmd.args[1]));
428 string str = cmd.Str(cmd.args[1]); 429 string str = cmd.Str(cmd.args[1]);
429 const char* s = str.c_str(); 430 const char* s = str.c_str();
430 if (cmd.cmd3 == 6) offset = len - offset; 431 if (cmd.cmd3 == 6) offset = len - offset;
437 else offset_top += 1; 438 else offset_top += 1;
438 } 439 }
439 if (s[offset_top] == 0) { 440 if (s[offset_top] == 0) {
440 SetStr(arg1, ""); 441 SetStr(arg1, "");
441 } else if (cmd.cmd4 == 0) { // 長さ制限なし 442 } else if (cmd.cmd4 == 0) { // 長さ制限なし
442 SetStr(arg1, string(s, offset_top)); 443 SetStr(arg1, string(s, offset_top, len-offset_top));
443 } else { // cmd.cmd4 == 1 444 } else { // cmd.cmd4 == 1
444 int slen = cmd.args[3].value; 445 int slen = cmd.args[3].value;
445 int offset_end = offset_top; 446 int offset_end = offset_top;
446 for (i=0; i<slen && s[offset_end] != 0; i++) { 447 for (i=0; i<slen && s[offset_end] != 0; i++) {
447 if (s[offset_end] < 0 && s[offset_end]+1 != 0) offset_end += 2; 448 if (s[offset_end] < 0 && s[offset_end]+1 != 0) offset_end += 2;