[Ttssh2-commit] [6962] 対応するサブオプションの数が増えてきたので、switch を使うようにした。

scmno****@osdn***** scmno****@osdn*****
2017年 10月 27日 (金) 18:40:50 JST


Revision: 6962
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6962
Author:   doda
Date:     2017-10-27 18:40:50 +0900 (Fri, 27 Oct 2017)
Log Message:
-----------
対応するサブオプションの数が増えてきたので、switch を使うようにした。

Modified Paths:
--------------
    trunk/teraterm/teraterm/telnet.c

-------------- next part --------------
Modified: trunk/teraterm/teraterm/telnet.c
===================================================================
--- trunk/teraterm/teraterm/telnet.c	2017-10-27 09:40:46 UTC (rev 6961)
+++ trunk/teraterm/teraterm/telnet.c	2017-10-27 09:40:50 UTC (rev 6962)
@@ -242,49 +242,54 @@
 		tr.SubOptIAC = FALSE;
 		switch (b) {
 		case SE:
-			if ((tr.MyOpt[TERMTYPE].Status == Yes) &&
-			    (tr.SubOptCount >= 2) &&
-			    (tr.SubOptBuff[0] == TERMTYPE) &&
-			    (tr.SubOptBuff[1] == 1))
-			{
-				_snprintf_s(TmpStr, sizeof(TmpStr), _TRUNCATE, "%c%c%c%c%s%c%c",
-				            IAC, SB, TERMTYPE, 0, ts.TermType, IAC, SE);
-				// 4 \x83o\x83C\x83g\x96ڂ\xC9 0 \x82\xAA\x93\xFC\x82\xE9\x82̂ŁA\x82\xB8\x82炵\x82Ē\xB7\x82\xB3\x82\xF0\x82Ƃ\xE9
-				i = strlen(TmpStr + 4) + 4;
-				CommRawOut(&cv, TmpStr, i);
+			if (tr.SubOptCount <= 1) {
+				// \x83p\x83\x89\x83\x81\x81[\x83^\x82Ȃ\xB5\x82\xCC Sub Option \x82͖\xB3\x82\xA2\x82Ǝv\x82\xED\x82\xEA\x82\xE9\x82̂ł\xB1\x82\xB1\x82ł͂\xB6\x82\xAD
+				tr.SubOptCount = 0;
+				TelStatus = TelIdle;
+				return ;
+			}
 
-				if (tr.LogFile)
-					TelWriteLog(TmpStr, i);
+			switch (tr.SubOptBuff[0]) {
+			case TERMTYPE:
+				if ((tr.MyOpt[TERMTYPE].Status == Yes) && (tr.SubOptBuff[1] == 1)) {
+					_snprintf_s(TmpStr, sizeof(TmpStr), _TRUNCATE, "%c%c%c%c%s%c%c",
+						IAC, SB, TERMTYPE, 0, ts.TermType, IAC, SE);
+					// 4 \x83o\x83C\x83g\x96ڂ\xC9 0 \x82\xAA\x93\xFC\x82\xE9\x82̂ŁA\x82\xB8\x82炵\x82Ē\xB7\x82\xB3\x82\xF0\x82Ƃ\xE9
+					i = strlen(TmpStr + 4) + 4;
+					CommRawOut(&cv, TmpStr, i);
+
+					if (tr.LogFile)
+						TelWriteLog(TmpStr, i);
+				}
+				break;
+
+			case NAWS:
+				if ( /* (tr.HisOpt[NAWS].Status == Yes) && */ (tr.SubOptCount >= 5)) {
+					tr.WinSize.x = tr.SubOptBuff[1]*256 + tr.SubOptBuff[2];
+					tr.WinSize.y = tr.SubOptBuff[3]*256 + tr.SubOptBuff[4];
+					tr.ChangeWinSize = TRUE;
+				}
+				break;
+
+			case TERMSPEED:
+				if ((tr.MyOpt[TERMSPEED].Status == Yes) && (tr.SubOptBuff[1] == 1)) {
+					_snprintf_s(TmpStr, sizeof(TmpStr), _TRUNCATE,
+						"%c%c%c%c%d,%d%c%c", IAC, SB, TERMSPEED, 0,
+						ts.TerminalInputSpeed, ts.TerminalOutputSpeed, IAC, SE);
+					// 4 \x83o\x83C\x83g\x96ڂ\xC9 0 \x82\xAA\x93\xFC\x82\xE9\x82̂ŁA\x82\xB8\x82炵\x82Ē\xB7\x82\xB3\x82\xF0\x82Ƃ\xE9
+					i = strlen(TmpStr + 4) + 4;
+					CommRawOut(&cv, TmpStr, i);
+
+					if (tr.LogFile)
+						TelWriteLog(TmpStr, i);
+				}
+				break;
 			}
-			else if ( /* (tr.HisOpt[NAWS].Status == Yes) && */
-			        (tr.SubOptCount >= 5) &&
-			        (tr.SubOptBuff[0] == NAWS))
-			{
-				tr.WinSize.x = tr.SubOptBuff[1]*256+ tr.SubOptBuff[2];
-				tr.WinSize.y = tr.SubOptBuff[3]*256+ tr.SubOptBuff[4];
-				tr.ChangeWinSize = TRUE;
-			}
-			else if ((tr.MyOpt[TERMSPEED].Status == Yes) &&
-			         (tr.SubOptCount >= 2) &&
-			         (tr.SubOptBuff[0] == TERMSPEED) &&
-			         (tr.SubOptBuff[1] == 1))
-			{
-				_snprintf_s(TmpStr, sizeof(TmpStr),
-					_TRUNCATE, "%c%c%c%c%d,%d%c%c",
-					IAC, SB, TERMSPEED, 0,
-					ts.TerminalInputSpeed,
-					ts.TerminalOutputSpeed,
-					IAC, SE);
-				// 4 \x83o\x83C\x83g\x96ڂ\xC9 0 \x82\xAA\x93\xFC\x82\xE9\x82̂ŁA\x82\xB8\x82炵\x82Ē\xB7\x82\xB3\x82\xF0\x82Ƃ\xE9
-				i = strlen(TmpStr + 4) + 4;
-				CommRawOut(&cv, TmpStr, i);
 
-				if (tr.LogFile)
-					TelWriteLog(TmpStr, i);
-			}
 			tr.SubOptCount = 0;
 			TelStatus = TelIdle;
 			return ;
+
 		/* case IAC: braek; */
 		default:
 			if (tr.SubOptCount >= sizeof(tr.SubOptBuff)-1) {



Ttssh2-commit メーリングリストの案内