[Ttssh2-commit] [3427] TTXParseParam の処理を書き直し

svnno****@sourc***** svnno****@sourc*****
2009年 5月 30日 (土) 00:40:00 JST


Revision: 3427
          http://svn.sourceforge.jp/view?root=ttssh2&view=rev&rev=3427
Author:   maya
Date:     2009-05-30 00:40:00 +0900 (Sat, 30 May 2009)

Log Message:
-----------
TTXParseParam の処理を書き直し
  =直後の"でも、パラメータの種類によらずデクォート処理をするようにした
  @@ を @ として扱う処理は変更していない

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/ttxssh.c


-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/ttxssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.c	2009-05-28 15:27:35 UTC (rev 3426)
+++ trunk/ttssh2/ttxssh/ttxssh.c	2009-05-29 15:40:00 UTC (rev 3427)
@@ -1742,6 +1742,127 @@
 static void FAR PASCAL TTXParseParam(PCHAR param, PTTSet ts,
                                      PCHAR DDETopic)
 {
+#if 1
+	int i;
+	BOOL inParam = FALSE;
+	BOOL inQuotes = FALSE;
+	BOOL inEqual = FALSE;
+	int param_len=strlen(param);
+	PCHAR start = NULL;
+	char *buf = (char *)calloc(param_len+1, sizeof(char));
+	int buflen = 0;
+
+	if (pvar->hostdlg_activated) {
+		pvar->settings.Enabled = pvar->hostdlg_Enabled;
+	}
+
+	for (i = 0; i < param_len; i++) {
+		if (inQuotes) {
+			// Œ»ÝˆÊ’u‚ª"‚Ì’†
+			if (param[i] == '"') {
+#if 0
+// "‚ð•\‚·‚½‚ß‚É""‚ð“n‚·Žd—l‚É‚·‚éê‡
+				if (param[i+1] == '"') {
+					buf[buf_len] = param[i];
+					buf_len++;
+					i++;
+				}
+				else {
+#else
+				{
+#endif
+					// ƒNƒH[ƒg‚µ‚Ä‚¢‚é‚Æ‚«‚Í‚±‚±‚ŏI‚í‚è
+					// "‚ðbuf‚É“ü‚ꂸ‚ɉðÍ‚É“n‚·
+					switch (parse_option(pvar, buf)) {
+					  case OPTION_CLEAR:
+						memset(start, ' ', (param + i) - start + 1);
+						break;
+					  case OPTION_REPLACE:
+						memset(start, ' ', (param + i) - start + 1);
+						buflen = strlen(buf);
+						memcpy(start, buf, buflen);
+						break;
+					}
+					inParam = FALSE;
+					inEqual = FALSE;
+					start = NULL;
+					memset(buf, 0, param_len);
+					buflen = 0;
+					inQuotes = FALSE;
+				}
+			}
+			else {
+				buf[buflen] = param[i];
+				buflen++;
+			}
+		}
+		else {
+			if (!inParam) {
+				// ‚Ü‚¾ƒpƒ‰ƒ[ƒ^‚Ì’†‚É‚¢‚È‚¢
+				if (param[i] == '"') {
+					// " ‚ÅŽn‚Ü‚é
+					start = param + i;
+					inParam = TRUE;
+					inQuotes = TRUE;
+				}
+				else if (param[i] != ' ' && param[i] != '\t') {
+					// •’Ê‚ÉŽn‚Ü‚é
+					buf[buflen] = param[i];
+					buflen++;
+					start = param + i;
+					inParam = TRUE;
+				}
+			}
+			else {
+				// Œ»ÝˆÊ’u‚ªƒpƒ‰ƒ[ƒ^‚Ì’†
+				if (param[i] == ' ' || param[i] == '\t') {
+					// ƒNƒH[ƒg‚µ‚Ä‚¢‚È‚¢‚Æ‚«‚Í‚±‚±‚ŏI‚í‚è
+					switch (parse_option(pvar, buf)) {
+					  case OPTION_CLEAR:
+						memset(start, ' ', (param + i) - start + 1);
+						break;
+					  case OPTION_REPLACE:
+						memset(start, ' ', (param + i) - start + 1);
+						buflen = strlen(buf);
+						memcpy(start, buf, buflen);
+						break;
+					}
+					inParam = FALSE;
+					inEqual = FALSE;
+					start = NULL;
+					memset(buf, 0, param_len);
+					buflen = 0;
+				}
+				else {
+					buf[buflen] = param[i];
+					buflen++;
+					if (!inEqual && param[i] == '=') {
+						inEqual = TRUE;
+						if (param[i+1] == '"') {
+							inQuotes = TRUE;
+							i++;
+						}
+					}
+				}
+			}
+		}
+	}
+
+	// buf ‚ÉŽc‚肪‚ ‚ê‚ΉðÍ‚É“n‚·
+	if (strlen(buf) > 0) {
+		switch (parse_option(pvar, buf)) {
+		  case OPTION_CLEAR:
+			memset(start, ' ', (param + i) - start + 1);
+			break;
+		  case OPTION_REPLACE:
+			memset(start, ' ', (param + i) - start + 1);
+			buflen = strlen(buf);
+			memcpy(start, buf, buflen);
+			break;
+		}
+	}
+	free(buf);
+#else
 	// ƒXƒy[ƒX‚ðŠÜ‚Þƒtƒ@ƒCƒ‹–¼‚ð”FŽ¯‚·‚é‚悤‚ɏC³ (2006.10.7 maya)
 	int i, buflen;
 	BOOL inParam = FALSE;
@@ -1858,6 +1979,7 @@
 			}
 		}
 	}
+#endif
 
 	FWDUI_load_settings(pvar);
 



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