[ttssh2-commit] [9491] DeleteCommentW() 追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 10月 23日 (土) 01:10:10 JST


Revision: 9491
          https://osdn.net/projects/ttssh2/scm/svn/commits/9491
Author:   zmatsuo
Date:     2021-10-23 01:10:10 +0900 (Sat, 23 Oct 2021)
Log Message:
-----------
DeleteCommentW() 追加

- DeleteComment() の Unicode版

Modified Paths:
--------------
    trunk/teraterm/common/ttlib.h
    trunk/teraterm/common/ttlib_static_cpp.cpp

-------------- next part --------------
Modified: trunk/teraterm/common/ttlib.h
===================================================================
--- trunk/teraterm/common/ttlib.h	2021-10-22 16:10:01 UTC (rev 9490)
+++ trunk/teraterm/common/ttlib.h	2021-10-22 16:10:10 UTC (rev 9491)
@@ -139,6 +139,7 @@
 DllExport wchar_t * PASCAL GetParam(wchar_t *buff, size_t size, wchar_t *param);
 DllExport void PASCAL DequoteParam(wchar_t *dest, size_t dest_len, wchar_t *src);
 void PASCAL DeleteComment(PCHAR dest, int dest_size, PCHAR src);
+wchar_t *DeleteCommentW(const wchar_t *src);
 
 void split_buffer(char *buffer, int delimiter, char **head, char **body);
 BOOL GetPositionOnWindow(

Modified: trunk/teraterm/common/ttlib_static_cpp.cpp
===================================================================
--- trunk/teraterm/common/ttlib_static_cpp.cpp	2021-10-22 16:10:01 UTC (rev 9490)
+++ trunk/teraterm/common/ttlib_static_cpp.cpp	2021-10-22 16:10:10 UTC (rev 9491)
@@ -1318,3 +1318,32 @@
 {
 	return IsWindowsVerOrLater(5, 1);
 }
+
+/**
+ *	DeleteComment \x82\xCC wchar_t \x94\xC5
+ */
+wchar_t *DeleteCommentW(const wchar_t *src)
+{
+	size_t dest_size = wcslen(src);
+	wchar_t *dest = (wchar_t *)malloc(sizeof(wchar_t) * (dest_size + 1));
+	wchar_t *dest_top = dest;
+	BOOL quoted = FALSE;
+	wchar_t *dest_end = dest + dest_size - 1;
+
+	while (*src != '\0' && dest < dest_end && (quoted || *src != ';')) {
+		*dest++ = *src;
+
+		if (*src++ == '"') {
+			if (*src == '"' && dest < dest_end) {
+				*dest++ = *src++;
+			}
+			else {
+				quoted = !quoted;
+			}
+		}
+	}
+
+	*dest = '\0';
+
+	return dest_top;
+}


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