[Ttssh2-commit] [3570] Borisから指摘されたケースにおいても、正しくC言語コメントが働くように修正した。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 7月 2日 (木) 23:04:54 JST


Revision: 3570
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3570
Author:   yutakapon
Date:     2009-07-02 23:04:54 +0900 (Thu, 02 Jul 2009)

Log Message:
-----------
Borisから指摘されたケースにおいても、正しくC言語コメントが働くように修正した。
ただし、Test7のようにセミコロンが先に来るケースは救えない。
http://logmett.com/forum/viewtopic.php?f=2&t=1145

おおむね問題ないので、C言語コメントを有効化する。

Modified Paths:
--------------
    trunk/teraterm/ttpmacro/ttmbuff.c
    trunk/teraterm/ttpmacro/ttmparse.c
    trunk/teraterm/ttpmacro/ttmparse.h


-------------- next part --------------
Modified: trunk/teraterm/ttpmacro/ttmbuff.c
===================================================================
--- trunk/teraterm/ttpmacro/ttmbuff.c	2009-07-02 13:28:07 UTC (rev 3569)
+++ trunk/teraterm/ttpmacro/ttmbuff.c	2009-07-02 14:04:54 UTC (rev 3570)
@@ -261,6 +261,11 @@
 			DispErr(Err);
 		}
 	}
+
+	if (!IsCommentClosed()) {
+		DispErr(ErrCloseComment);
+	}
+
 	BuffPtr[IBuff] = 0;
 	InitLineNo(); // (2005.7.18 yutaka)
 	GlobalUnlock(BuffHandle[IBuff]);

Modified: trunk/teraterm/ttpmacro/ttmparse.c
===================================================================
--- trunk/teraterm/ttpmacro/ttmparse.c	2009-07-02 13:28:07 UTC (rev 3569)
+++ trunk/teraterm/ttpmacro/ttmparse.c	2009-07-02 14:04:54 UTC (rev 3570)
@@ -12,7 +12,8 @@
 #include "ttmparse.h"
 
 /* CŒ¾ŒêƒXƒ^ƒCƒ‹‚̃Rƒƒ“ƒg‚ðƒTƒ|[ƒg‚·‚é‚©‚Ç‚¤‚© (2009.7.2 yutaka) */
-//#define SUPPORT_C_STYLE_COMMENT
+#define SUPPORT_C_STYLE_COMMENT
+static int commenting = 0;   /* CŒ¾ŒêƒRƒƒ“ƒg */
 
 WORD TTLStatus = 0;
 char LineBuff[MaxLineLen]; // sƒoƒbƒtƒ@‚̃TƒCƒY‚ðŠg’£‚µ‚½B(2007.6.9 maya)
@@ -42,7 +43,6 @@
 static PCHAR StrBuff;
 static WORD IntVarCount, StrVarCount, LabVarCount;
 
-
 BOOL InitVar()
 {
 	HNameBuff = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT,NameBuffLen);
@@ -87,6 +87,7 @@
 		case ErrTooManyVar: strncpy_s(Msg, sizeof(Msg),"Too many variables.", _TRUNCATE); break;
 		case ErrTypeMismatch: strncpy_s(Msg, sizeof(Msg),"Type mismatch.", _TRUNCATE); break;
 		case ErrVarNotInit: strncpy_s(Msg, sizeof(Msg),"Variable not initialized.", _TRUNCATE); break;
+		case ErrCloseComment: strncpy_s(Msg, sizeof(Msg),"\"*/\" expected.", _TRUNCATE); break;
 	}
 
 	i = OpenErrDlg(Msg,LineBuff);
@@ -329,9 +330,14 @@
 	return (*WordId!=0);
 }
 
+/* CŒ¾ŒêƒRƒƒ“ƒg‚ª•Â‚¶‚ç‚ê‚Ä‚¢‚é‚©‚Ç‚¤‚© */
+int IsCommentClosed(void)
+{
+	return (commenting == 0);
+}
+
 BYTE GetFirstChar()
 {
-	static int commenting = 0;
 	BYTE b;
 	int comment_starting = 0;
 
@@ -364,6 +370,12 @@
 			b = LineBuff[LinePtr];
 		else
 			b = 0;
+
+		while ((LinePtr<LineLen) && ((b==' ') || (b=='\t')))
+		{
+			LinePtr++;
+			if (LinePtr<LineLen) b = LineBuff[LinePtr];
+		}
 	}
 
 	/* CŒ¾ŒêƒRƒƒ“ƒg‚ÌŽn‚Ü‚è */
@@ -379,11 +391,18 @@
 			}
 			LinePtr++;
 		}
+
 		if (LinePtr < LineLen) 
 			b = LineBuff[LinePtr];
 		else
 			b = 0;
 
+		while ((LinePtr<LineLen) && ((b==' ') || (b=='\t')))
+		{
+			LinePtr++;
+			if (LinePtr<LineLen) b = LineBuff[LinePtr];
+		}
+
 		/* ƒRƒƒ“ƒg‚̏I‚í‚肪ˆês‚É“oê‚µ‚È‚¢ê‡‚́A‰i‘±“I‚É‹L˜^‚·‚éB*/
 		if (comment_starting)
 			commenting = 1;

Modified: trunk/teraterm/ttpmacro/ttmparse.h
===================================================================
--- trunk/teraterm/ttpmacro/ttmparse.h	2009-07-02 13:28:07 UTC (rev 3569)
+++ trunk/teraterm/ttpmacro/ttmparse.h	2009-07-02 14:04:54 UTC (rev 3570)
@@ -33,6 +33,7 @@
 #define ErrTooManyVar       13
 #define ErrTypeMismatch     14
 #define ErrVarNotInit       15
+#define ErrCloseComment     16
 
 #define TypUnknown  0
 #define TypInteger  1
@@ -236,6 +237,7 @@
 void DispErr(WORD Err);
 void LockVar();
 void UnlockVar();
+int IsCommentClosed(void);
 BYTE GetFirstChar();
 BOOL CheckParameterGiven();
 BOOL GetIdentifier(PCHAR Name);



Ttssh2-commit メーリングリストの案内
Back to archive index