svnno****@sourc*****
svnno****@sourc*****
2010年 8月 16日 (月) 00:42:03 JST
Revision: 4002 http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4002 Author: yutakapon Date: 2010-08-16 00:42:03 +0900 (Mon, 16 Aug 2010) Log Message: ----------- strsplit ãã¯ãã³ãã³ãã追å ããã Modified Paths: -------------- trunk/teraterm/common/helpid.h trunk/teraterm/ttpmacro/ttl.c trunk/teraterm/ttpmacro/ttmparse.c trunk/teraterm/ttpmacro/ttmparse.h -------------- next part -------------- Modified: trunk/teraterm/common/helpid.h =================================================================== --- trunk/teraterm/common/helpid.h 2010-08-15 14:41:40 UTC (rev 4001) +++ trunk/teraterm/common/helpid.h 2010-08-15 15:42:03 UTC (rev 4002) @@ -288,7 +288,8 @@ #define HlpMacroCommandStrremove 92181 #define HlpMacroCommandStrreplcae 92182 #define HlpMacroCommandStrscan 92096 -#define HlpMacroCommandStrtrim 92183 +#define HlpMacroCommandStrsplit 92184 +#define HlpMacroCommandStrtrim 92183 #define HlpMacroCommandTestlink 92097 #define HlpMacroCommandTolower 92118 #define HlpMacroCommandToupper 92119 Modified: trunk/teraterm/ttpmacro/ttl.c =================================================================== --- trunk/teraterm/ttpmacro/ttl.c 2010-08-15 14:41:40 UTC (rev 4001) +++ trunk/teraterm/ttpmacro/ttl.c 2010-08-15 15:42:03 UTC (rev 4002) @@ -3612,6 +3612,62 @@ return Err; } +WORD TTLStrSplit() +{ +#define MAXVARNUM 9 + TStrVal delimchars; + WORD Err, VarId; + int maxvar, sp; + int srclen; + int i; + char *srcptr; + char *last, *tok[MAXVARNUM]; + + Err = 0; + GetStrVar(&VarId,&Err); + GetStrVal(delimchars,&Err); + GetIntVal(&maxvar,&Err); + // get 3rd arg(optional) if given + if (CheckParameterGiven()) { + GetIntVal(&sp, &Err); + } else { + sp = 0; + } + if ((Err==0) && (GetFirstChar()!=0)) + Err = ErrSyntax; + if (Err!=0) return Err; + + if (maxvar < 1 || maxvar > MAXVARNUM) + return ErrSyntax; + + if (sp) { + // üsR[hðÏ··é + RestoreNewLine(delimchars); + } + + srcptr = StrVarPtr(VarId); + srclen = strlen(srcptr); + + // g[NÌØèoµðs¤B + memset(tok, 0, sizeof(tok)); + tok[0] = strtok_s(srcptr, delimchars, &last); + for (i = 1 ; i < MAXVARNUM ; i++) { + tok[i] = strtok_s(NULL, delimchars, &last); + if (tok[i] == NULL) + break; + } + + // ÊÌi[ + for (i = 0 ; i < MAXVARNUM ; i++) { + LockVar(); + SetGroupMatchStr(i+1, tok[i]); + UnlockVar(); + } + + return Err; +#undef MAXVARNUM +} + WORD TTLTestLink() { if (GetFirstChar()!=0) @@ -4462,6 +4518,8 @@ Err = TTLStrReplace(); break; case RsvStrScan: Err = TTLStrScan(); break; + case RsvStrSplit: + Err = TTLStrSplit(); break; case RsvStrTrim: Err = TTLStrTrim(); break; case RsvTestLink: @@ -4601,12 +4659,18 @@ { WORD VarType, VarId; char buf[128]; + char *p; + if (Str == NULL) + p = ""; + else + p = Str; + _snprintf_s(buf, sizeof(buf), _TRUNCATE, "groupmatchstr%d", no); if (CheckVar(buf,&VarType,&VarId) && (VarType==TypString)) - SetStrVal(VarId,Str); + SetStrVal(VarId,p); } void SetInputStr(PCHAR Str) Modified: trunk/teraterm/ttpmacro/ttmparse.c =================================================================== --- trunk/teraterm/ttpmacro/ttmparse.c 2010-08-15 14:41:40 UTC (rev 4001) +++ trunk/teraterm/ttpmacro/ttmparse.c 2010-08-15 15:42:03 UTC (rev 4002) @@ -294,6 +294,7 @@ else if (_stricmp(Str,"strremove")==0) *WordId = RsvStrRemove; else if (_stricmp(Str,"strreplace")==0) *WordId = RsvStrReplace; else if (_stricmp(Str,"strscan")==0) *WordId = RsvStrScan; + else if (_stricmp(Str,"strsplit")==0) *WordId = RsvStrSplit; else if (_stricmp(Str,"strtrim")==0) *WordId = RsvStrTrim; break; case 't': Modified: trunk/teraterm/ttpmacro/ttmparse.h =================================================================== --- trunk/teraterm/ttpmacro/ttmparse.h 2010-08-15 14:41:40 UTC (rev 4001) +++ trunk/teraterm/ttpmacro/ttmparse.h 2010-08-15 15:42:03 UTC (rev 4002) @@ -199,6 +199,7 @@ #define RsvStrRemove 181 #define RsvStrReplace 182 #define RsvStrTrim 183 +#define RsvStrSplit 184 #define RsvOperator 1000 #define RsvBNot 1001