svnno****@sourc*****
svnno****@sourc*****
2010年 8月 11日 (水) 01:05:54 JST
Revision: 3980 http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3980 Author: yutakapon Date: 2010-08-11 01:05:54 +0900 (Wed, 11 Aug 2010) Log Message: ----------- ãã±ãã #22781 http://sourceforge.jp/ticket/browse.php?group_id=1412&tid=22781 Ticket Links: :----------- http://sourceforge.jp/projects/ttssh2/tracker/detail/22781 Modified Paths: -------------- trunk/teraterm/ttpmacro/ttl.c trunk/teraterm/ttpmacro/ttmparse.c trunk/teraterm/ttpmacro/ttmparse.h -------------- next part -------------- Modified: trunk/teraterm/ttpmacro/ttl.c =================================================================== --- trunk/teraterm/ttpmacro/ttl.c 2010-08-09 15:11:07 UTC (rev 3979) +++ trunk/teraterm/ttpmacro/ttl.c 2010-08-10 16:05:54 UTC (rev 3980) @@ -3381,6 +3381,78 @@ return Err; } +WORD TTLStrInsert() +{ + WORD Err, VarId; + int Index; + TStrVal Str; + int srclen, addlen; + char *srcptr, *np; + + Err = 0; + GetStrVar(&VarId,&Err); + GetIntVal(&Index,&Err); + GetStrVal(Str,&Err); + if ((Err==0) && (GetFirstChar()!=0)) + Err = ErrSyntax; + if (Err!=0) return Err; + + srcptr = StrVarPtr(VarId); + srclen = strlen(srcptr); + if (Index <= 0 || Index > srclen+1) { + Err = ErrSyntax; + } + addlen = strlen(Str); + if (srclen + addlen + 1 > MaxStrLen) { + Err = ErrSyntax; + } + if (Err!=0) return Err; + + // ܸÍ}ü³êéÓÈ~Ìf[^ðAãëÉÚ®·éB + np = srcptr + (Index - 1); + memmove_s(np + addlen, MaxStrLen, np, srclen - (Index - 1)); + + // ¶ñð}ü·é + memcpy(np, Str, addlen); + + // null-terminate + srcptr[srclen + addlen] = '\0'; + + return Err; +} + +WORD TTLStrRemove() +{ + WORD Err, VarId; + int Index, Len; + int srclen; + char *srcptr, *np; + + Err = 0; + GetStrVar(&VarId,&Err); + GetIntVal(&Index,&Err); + GetIntVal(&Len,&Err); + if ((Err==0) && (GetFirstChar()!=0)) + Err = ErrSyntax; + if (Err!=0) return Err; + + srcptr = StrVarPtr(VarId); + srclen = strlen(srcptr); + if (Len <=0 || Index <= 0 || (Index-1 + Len) > srclen) { + Err = ErrSyntax; + } + if (Err!=0) return Err; + + // ¶ñðí·é + np = srcptr + (Index - 1); + memmove_s(np, MaxStrLen, np + Len, srclen - Len); + + // null-terminate + srcptr[srclen - Len] = '\0'; + + return Err; +} + WORD TTLTestLink() { if (GetFirstChar()!=0) @@ -4219,10 +4291,14 @@ Err = TTLStrConcat(); break; case RsvStrCopy: Err = TTLStrCopy(); break; + case RsvStrInsert: + Err = TTLStrInsert(); break; case RsvStrLen: Err = TTLStrLen(); break; case RsvStrMatch: Err = TTLStrMatch(); break; + case RsvStrRemove: + Err = TTLStrRemove(); break; case RsvStrScan: Err = TTLStrScan(); break; case RsvTestLink: Modified: trunk/teraterm/ttpmacro/ttmparse.c =================================================================== --- trunk/teraterm/ttpmacro/ttmparse.c 2010-08-09 15:11:07 UTC (rev 3979) +++ trunk/teraterm/ttpmacro/ttmparse.c 2010-08-10 16:05:54 UTC (rev 3980) @@ -288,8 +288,10 @@ else if (_stricmp(Str,"strcompare")==0) *WordId = RsvStrCompare; else if (_stricmp(Str,"strconcat")==0) *WordId = RsvStrConcat; else if (_stricmp(Str,"strcopy")==0) *WordId = RsvStrCopy; + else if (_stricmp(Str,"strinsert")==0) *WordId = RsvStrInsert; else if (_stricmp(Str,"strlen")==0) *WordId = RsvStrLen; else if (_stricmp(Str,"strmatch")==0) *WordId = RsvStrMatch; + else if (_stricmp(Str,"strremove")==0) *WordId = RsvStrRemove; else if (_stricmp(Str,"strscan")==0) *WordId = RsvStrScan; break; case 't': Modified: trunk/teraterm/ttpmacro/ttmparse.h =================================================================== --- trunk/teraterm/ttpmacro/ttmparse.h 2010-08-09 15:11:07 UTC (rev 3979) +++ trunk/teraterm/ttpmacro/ttmparse.h 2010-08-10 16:05:54 UTC (rev 3980) @@ -195,6 +195,8 @@ #define RsvYmodemSend 177 #define RsvFileStat 178 #define RsvFileTruncate 179 +#define RsvStrInsert 180 +#define RsvStrRemove 181 #define RsvOperator 1000 #define RsvBNot 1001