[Ttssh2-commit] [7332] Merge branch 'trunk' into cmake

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2018年 12月 18日 (火) 23:46:19 JST


Revision: 7332
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7332
Author:   zmatsuo
Date:     2018-12-18 23:46:19 +0900 (Tue, 18 Dec 2018)
Log Message:
-----------
Merge branch 'trunk' into cmake

Modified Paths:
--------------
    branches/cmake/TTProxy/YCL/include/YCL/Window.h
    branches/cmake/teraterm/common/codeconv.cpp
    branches/cmake/teraterm/common/codeconv.h
    branches/cmake/teraterm/ttpmacro/ttl.c
    branches/cmake/teraterm/ttpmacro/ttmbuff.c
    branches/cmake/teraterm/ttpmacro/ttpmacro.v10.vcxproj
    branches/cmake/teraterm/ttpmacro/ttpmacro.v11.vcxproj
    branches/cmake/teraterm/ttpmacro/ttpmacro.v12.vcxproj
    branches/cmake/teraterm/ttpmacro/ttpmacro.v14.vcxproj
    branches/cmake/teraterm/ttpmacro/ttpmacro.v15.vcxproj
    branches/cmake/teraterm/ttpmacro/ttpmacro.v15.vcxproj.filters
    branches/cmake/teraterm/ttpmacro/ttpmacro.v9.vcproj

Added Paths:
-----------
    branches/cmake/teraterm/ttpmacro/fileread.cpp
    branches/cmake/teraterm/ttpmacro/fileread.h
    branches/cmake/tests/code_cp932.ttl
    branches/cmake/tests/code_utf16be-bom.ttl
    branches/cmake/tests/code_utf16le-bom.ttl
    branches/cmake/tests/code_utf8-bom.ttl
    branches/cmake/tests/code_utf8.ttl

-------------- next part --------------
Modified: branches/cmake/TTProxy/YCL/include/YCL/Window.h
===================================================================
--- branches/cmake/TTProxy/YCL/include/YCL/Window.h	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/TTProxy/YCL/include/YCL/Window.h	2018-12-18 14:46:19 UTC (rev 7332)
@@ -204,15 +204,15 @@
 	bool GetScrollInfo(int type, SCROLLINFO& info)const {
 		return ::GetScrollInfo(window, type, &info) != FALSE;
 	}
-	long SetLayeredWindowAttributes(long reserved, int parameters, long attribute) {
+	long SetLayeredWindowAttributes(COLORREF crKey, BYTE bAlpha, DWORD dwFlags) {
 		static const char USER32[] = "user32.dll";
 		static const char APINAME[] = "SetLayeredWindowAttributes";
-		static DWORD (WINAPI* api)(HWND, DWORD, BYTE, DWORD)
-			= (DWORD (WINAPI*)(HWND, DWORD, BYTE, DWORD)) ::GetProcAddress(::GetModuleHandleA(USER32), APINAME);
-		return api != NULL ? (*api)(window, reserved, parameters, attribute) : 0;
+		static BOOL (WINAPI* api)(HWND, COLORREF, BYTE, DWORD)
+			= (BOOL (WINAPI*)(HWND, COLORREF, BYTE, DWORD)) ::GetProcAddress(::GetModuleHandleA(USER32), APINAME);
+		return api != NULL ? (*api)(window, crKey, bAlpha, dwFlags) : 0;
 	}
-	long SetLayeredWindowAttributes(int parameters, long attribute) {
-		return SetLayeredWindowAttributes(0, parameters, attribute);
+	long SetLayeredWindowAttributes(BYTE bAlpha, DWORD dwFlags) {
+		return SetLayeredWindowAttributes(0, bAlpha, dwFlags);
 	}
 	HWND SetClipboardViewer() {
 		return ::SetClipboardViewer(window);
@@ -311,7 +311,7 @@
 #ifndef WS_EX_LAYERED
 #define WS_EX_LAYERED 0x80000
 #endif
-	void setAlpha(int alpha) {
+	void setAlpha(BYTE alpha) {
 		long exStyle = getExStyle();
 		if ((exStyle & WS_EX_LAYERED) == 0)
 			setExStyle(exStyle | WS_EX_LAYERED);

Modified: branches/cmake/teraterm/common/codeconv.cpp
===================================================================
--- branches/cmake/teraterm/common/codeconv.cpp	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/common/codeconv.cpp	2018-12-18 14:46:19 UTC (rev 7332)
@@ -1,10 +1,42 @@
-
-#include <stdio.h>
+/*
+ * Copyright (C) 2018 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #include <windows.h>
-#include <memory>
+#include <string.h>
+#include <crtdbg.h>
 
 #include "codeconv.h"
 
+#ifdef _DEBUG
+#define malloc(l)     _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)       _free_dbg((p), _NORMAL_BLOCK)
+#endif
+
 /**
  *	wchar_t文字列をマルチバイト文字列へ変換
  *	@param[in]	*wstr_ptr	wchar_t文字列
@@ -78,7 +110,7 @@
 	}
 	len = ::MultiByteToWideChar(code_page, flags,
 								str_ptr, (int)str_len,
-		wstr_ptr, len);
+								wstr_ptr, len);
 	if (len == 0) {
 		free(wstr_ptr);
 		return NULL;
@@ -89,25 +121,34 @@
 	return wstr_ptr;
 }
 
-const TCHAR *ToTcharA(const char *strA)
+//#if defined(UNICODE)
+const char *ToCharW(const wchar_t *strW)
 {
-#if defined(UNICODE)
-	wchar_t *strW = _MultiByteToWideChar(strA, 0, CP_ACP, NULL);
-	return strW;
-#else
+	const char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL);
+	return strA;
+}
+//#endif
+
+const char *ToCharA(const char *strA)
+{
 	return _strdup(strA);
-#endif
 }
 
-const TCHAR *ToTcharU8(const char *strU8)
+const char *ToCharU8(const char *strU8)
 {
 	const wchar_t *strW = _MultiByteToWideChar(strU8, 0, CP_UTF8, NULL);
+	const char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL);
+	free((void *)strW);
+	return strA;
+}
+
+const TCHAR *ToTcharA(const char *strA)
+{
 #if defined(UNICODE)
+	wchar_t *strW = _MultiByteToWideChar(strA, 0, CP_ACP, NULL);
 	return strW;
 #else
-	const char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL);
-	free((void *)strW);
-	return strA;
+	return ToCharA(strA);
 #endif
 }
 
@@ -116,22 +157,20 @@
 #if defined(UNICODE)
 	return _wcsdup(strW);
 #else
-	char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL);
-	return strA;
+	return ToCharW(strW);
 #endif
 }
 
+const TCHAR *ToTcharU8(const char *strU8)
+{
+	const wchar_t *strW = _MultiByteToWideChar(strU8, 0, CP_UTF8, NULL);
 #if defined(UNICODE)
-const char *ToCharW(const wchar_t *strW)
-{
+	return strW;
+#else
 	const char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL);
+	free((void *)strW);
 	return strA;
-}
 #endif
-
-const char *ToCharA(const char *strA)
-{
-	return _strdup(strA);
 }
 
 const char *ToU8W(const wchar_t *strW)
@@ -143,6 +182,9 @@
 const char *ToU8A(const char *strA)
 {
 	const wchar_t *strW = _MultiByteToWideChar(strA, 0, CP_ACP, NULL);
+	if (strW == NULL) {
+		return NULL;
+	}
 	const char *strU8 = _WideCharToMultiByte(strW, 0, CP_UTF8, NULL);
 	free((void *)strW);
 	return strU8;
@@ -155,22 +197,22 @@
 	u8str_ = NULL;
 }
 
-u8::u8(const char *astr)
+u8::u8(const char *strA)
 {
 	u8str_ = NULL;
-	assign(astr, CP_ACP);
+	assign(strA, CP_ACP);
 }
 
-u8::u8(const char *astr, int cpage)
+u8::u8(const char *strA, int cpage)
 {
 	u8str_ = NULL;
-	assign(astr, cpage);
+	assign(strA, cpage);
 }
 
-u8::u8(const wchar_t *wstr)
+u8::u8(const wchar_t *strW)
 {
 	u8str_ = NULL;
-	assign(wstr);
+	assign(strW);
 }
 
 u8::u8(const u8 &obj)
@@ -193,15 +235,15 @@
 	}
 }
 
-u8& u8::operator=(const char *astr)
+u8& u8::operator=(const char *strA)
 {
-	assign(astr, CP_ACP);
+	assign(strA, CP_ACP);
 	return *this;
 }
 
-u8& u8::operator=(const wchar_t *wstr)
+u8& u8::operator=(const wchar_t *strW)
 {
-	assign(wstr);
+	assign(strW);
 	return *this;
 }
 
@@ -232,26 +274,26 @@
 	return u8str_;
 }
 
-void u8::assign(const char *astr, int code_page)
+void u8::assign(const char *strA, int code_page)
 {
 	if (u8str_ != NULL) {
 		free(u8str_);
 	}
-	wchar_t *wstr = _MultiByteToWideChar(astr, 0, code_page, NULL);
-	if (wstr != NULL) {
-		assign(wstr);
-		free(wstr);
+	wchar_t *strW = _MultiByteToWideChar(strA, 0, code_page, NULL);
+	if (strW != NULL) {
+		assign(strW);
+		free(strW);
 	} else {
 		u8str_ = NULL;
 	}
 }
 
-void u8::assign(const wchar_t *wstr)
+void u8::assign(const wchar_t *strW)
 {
 	if (u8str_ != NULL) {
 		free(u8str_);
 	}
-	char *u8str = _WideCharToMultiByte(wstr, 0, CP_UTF8, NULL);
+	char *u8str = _WideCharToMultiByte(strW, 0, CP_UTF8, NULL);
 	if (u8str != NULL) {
 		u8str_ = u8str;
 	} else {
@@ -285,33 +327,36 @@
 	tstr_ = NULL;
 }
 
-tc::tc(const char *astr)
+tc::tc(const char *strA)
 {
 	tstr_ = NULL;
-	assign(astr, CP_ACP);
+	assign(strA, CP_ACP);
 }
 
-tc::tc(const char *astr, int code_page)
+tc::tc(const char *strA, int code_page)
 {
 	tstr_ = NULL;
-	assign(astr, code_page);
+	assign(strA, code_page);
 }
 
-tc::tc(const wchar_t *wstr)
+tc::tc(const wchar_t *strW)
 {
 	tstr_ = NULL;
-	assign(wstr, CP_ACP);
+	assign(strW);
 }
 
-tc::tc(const wchar_t *wstr, int code_page)
+#if 0
+tc::tc(const wchar_t *strW, int code_page)
 {
 	tstr_ = NULL;
-	assign(wstr, code_page);
+	assign(strW, code_page);
 }
+#endif
 
 #if defined(MOVE_CONSTRUCTOR_ENABLE)
 tc::tc(tc &&obj) noexcept
 {
+	tstr_ = NULL;
 	move(obj);
 }
 #endif
@@ -323,33 +368,28 @@
 	}
 }
 
-tc& tc::operator=(const char *astr)
+tc& tc::operator=(const char *strA)
 {
-	assign(astr, CP_ACP);
+	assign(strA, CP_ACP);
 	return *this;
 }
 
-tc& tc::operator=(const wchar_t *wstr)
+tc& tc::operator=(const wchar_t *strW)
 {
-	assign(wstr, CP_ACP);
+	assign(strW);
 	return *this;
 }
 
-const TCHAR *tc::fromUtf8(const char *u8str)
+tc tc::fromUtf8(const char *strU8)
 {
-	if (tstr_ != NULL) {
-		free(tstr_);
-	}
-	tstr_ = NULL;
-	wchar_t *wstr = _MultiByteToWideChar(u8str, 0, CP_UTF8, NULL);
-	if (wstr != NULL) {
-		assign(wstr, CP_ACP);
-		free(wstr);
-	}
-	return cstr();
+	const wchar_t *strW = _MultiByteToWideChar(strU8, 0, CP_UTF8, NULL);
+	tc _tc = strW;
+	return _tc;
 }
 
-tc::operator const TCHAR *() const
+// voidなしが一般的と思われるが、
+// VS2005でリンクエラーが出てしまうため void 追加
+tc::operator const TCHAR *(void) const
 {
 	return cstr();
 }
@@ -362,7 +402,7 @@
 	return tstr_;
 }
 
-void tc::assign(const char *astr, int code_page)
+void tc::assign(const char *strA, int code_page)
 {
 	if (tstr_ != NULL) {
 		free(tstr_);
@@ -369,11 +409,11 @@
 	}
 #if !defined(UNICODE)
 	(void)code_page;
-	tstr_ = _strdup(astr);
+	tstr_ = _strdup(strA);
 #else
-	wchar_t *wstr = _MultiByteToWideChar(astr, 0, code_page, NULL);
-	if (wstr != NULL) {
-		tstr_ = wstr;
+	wchar_t *strW = _MultiByteToWideChar(strA, 0, code_page, NULL);
+	if (strW != NULL) {
+		tstr_ = strW;
 	} else {
 		tstr_ = NULL;
 	}
@@ -380,18 +420,17 @@
 #endif
 }
 
-void tc::assign(const wchar_t *wstr, int code_page)
+void tc::assign(const wchar_t *strW)
 {
 	if (tstr_ != NULL) {
 		free(tstr_);
 	}
 #if defined(UNICODE)
-	(void)code_page;
-	tstr_ = _wcsdup(wstr);
+	tstr_ = _wcsdup(strW);
 #else
-	char *astr = _WideCharToMultiByte(wstr, 0, code_page, NULL);
-	if (astr != NULL) {
-		tstr_ = astr;
+	char *strA = _WideCharToMultiByte(strW, 0, CP_ACP, NULL);
+	if (strA != NULL) {
+		tstr_ = strA;
 	} else {
 		tstr_ = NULL;
 	}

Modified: branches/cmake/teraterm/common/codeconv.h
===================================================================
--- branches/cmake/teraterm/common/codeconv.h	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/common/codeconv.h	2018-12-18 14:46:19 UTC (rev 7332)
@@ -1,4 +1,31 @@
-
+/*
+ * Copyright (C) 2018 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #pragma once
 
 #include <tchar.h>
@@ -9,11 +36,13 @@
 
 char *_WideCharToMultiByte(const wchar_t *wstr_ptr, size_t wstr_len, int code_page, size_t *mb_len_);
 wchar_t *_MultiByteToWideChar(const char *str_ptr, size_t str_len, int code_page, size_t *w_len_);
+
 const TCHAR *ToTcharA(const char *strA);
+const TCHAR *ToTcharW(const wchar_t *strW);
 const TCHAR *ToTcharU8(const char *strU8);
-const TCHAR *ToTcharW(const wchar_t *strW);
+const char *ToCharA(const char *strA);
 const char *ToCharW(const wchar_t *strW);
-const char *ToCharA(const char *strA);
+const char *ToCharU8(const char *strU8);
 const wchar_t *ToWcharA(const char *strA);
 const char *ToU8A(const char *strA);
 const char *ToU8W(const wchar_t *strW);
@@ -20,10 +49,10 @@
 
 #if defined(_UNICODE)
 #define ToCharT(s)	ToCharW(s)
-#define	ToU8T(s)	ToU8W(s)
+#define ToU8T(s)	ToU8W(s)
 #else
 #define ToCharT(s)	ToCharA(s)
-#define	ToU8T(s)	ToU8A(s)
+#define ToU8T(s)	ToU8A(s)
 #endif
 
 #ifdef __cplusplus
@@ -46,16 +75,16 @@
 {
 public:
 	u8();
-	u8(const char *astr);
-	u8(const char *astr, int code_page);
-	u8(const wchar_t *wstr);
+	u8(const char *strA);
+	u8(const char *strA, int code_page);
+	u8(const wchar_t *strW);
 	u8(const u8 &obj);
 #if defined(MOVE_CONSTRUCTOR_ENABLE)
 	u8(u8 &&obj) noexcept;
 #endif
 	~u8();
-	u8& operator=(const char *astr);
-	u8& operator=(const wchar_t *wstr);
+	u8& operator=(const char *strA);
+	u8& operator=(const wchar_t *strW);
 	u8& operator=(const u8 &obj);
 #if defined(MOVE_CONSTRUCTOR_ENABLE)
 	u8& operator=(u8 &&obj) noexcept;
@@ -64,8 +93,8 @@
 	const char *cstr() const;
 private:
 	char *u8str_;
-	void assign(const char *astr, int code_page);
-	void assign(const wchar_t *wstr);
+	void assign(const char *strA, int code_page);
+	void assign(const wchar_t *strW);
 	void copy(const u8 &obj);
 	void move(u8 &obj);
 };
@@ -74,31 +103,28 @@
 {
 public:
 	tc();
-	tc(const char *astr);
-	tc(const char *astr, int code_page);
-	tc(const wchar_t *wstr);
-	tc(const wchar_t *wstr, int code_page);
+	tc(const char *strA);
+	tc(const char *strA, int code_page);
+	tc(const wchar_t *strW);
 	tc(const tc &obj);
 #if defined(MOVE_CONSTRUCTOR_ENABLE)
 	tc(tc &&obj) noexcept;
 #endif
 	~tc();
-	tc& operator=(const char *astr);
-	tc& operator=(const wchar_t *wstr);
+	tc& operator=(const char *strA);
+	tc& operator=(const wchar_t *strW);
 	tc& operator=(const tc &obj);
 #if defined(MOVE_CONSTRUCTOR_ENABLE)
 	tc& operator=(tc &&obj) noexcept;
 #endif
-	const TCHAR *fromUtf8(const char *u8str);
+	static tc fromUtf8(const char *strU8);
 	operator const TCHAR *() const;
 	const TCHAR *cstr() const;
 private:
 	TCHAR *tstr_;
-	void assign(const char *astr, int code_page);
-	void assign(const wchar_t *astr, int code_page);
+	void assign(const char *strA, int code_page);
+	void assign(const wchar_t *strW);
 	void copy(const tc &obj);
 	void move(tc &obj);
 };
 #endif
-
-

Added: branches/cmake/teraterm/ttpmacro/fileread.cpp
===================================================================
--- branches/cmake/teraterm/ttpmacro/fileread.cpp	                        (rev 0)
+++ branches/cmake/teraterm/ttpmacro/fileread.cpp	2018-12-18 14:46:19 UTC (rev 7332)
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2018 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#if (defined(_MSC_VER) && (_MSC_VER >= 1600)) || !defined(_MSC_VER)
+#include <stdint.h>
+#endif
+#include <windows.h>
+#include <tchar.h>
+#include "codeconv.h"
+#include "fileread.h"
+
+#if defined(_MSC_VER) && (_MSC_VER < 1600)
+typedef unsigned char uint8_t;
+#endif
+
+/**
+ *	ファイルをメモリに読み込む
+ *	@param[out]	*_len	サイズ(最後に付加される"\0\0"を含む)
+ *	@retval		ファイルの中身へのポインタ(使用後free()すること)
+ *				NULL=エラー
+ */
+static void *LoadRawFile(FILE *fp, size_t *_len)
+{
+    fseek(fp, 0L, SEEK_END);
+	fpos_t pos;
+	fgetpos(fp, &pos);
+    fseek(fp, 0L, SEEK_SET);
+	size_t len = (size_t)pos;
+	char *buf = (char *)malloc(len + 2);
+	buf[len] = 0;
+	buf[len+1] = 0;		// UTF-16対策
+	fread(buf, 1, len, fp);
+	len += 2;
+	*_len = len;
+	return buf;
+}
+
+/**
+ *	ファイルをメモリに読み込む
+ *	中身はUTF-8に変換される
+ *	ファイルの最後は '\0'でターミネートされている
+ *
+ *	@param[out]	*_len	サイズ(最後に付加される"\0"を含む)
+ *	@retval		ファイルの中身へのポインタ(使用後free()すること)
+ *				NULL=エラー
+ */
+char *LoadFileU8(FILE *fp, size_t *_len)
+{
+	size_t len;
+	void *vbuf = LoadRawFile(fp, &len);
+	if (vbuf == NULL) {
+		*_len = 0;
+		return NULL;
+	}
+
+	uint8_t *buf = (uint8_t *)vbuf;
+	if (len >= 3 && (buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf)) {
+		// UTF-8 BOM
+		//		trim BOM
+		len -= 3;
+		memmove(&buf[0], &buf[3], len);
+	} else if(len >= 2 && (buf[0] == 0xff && buf[1] == 0xfe)) {
+		// UTF-16LE BOM
+		//		UTF-16LE -> UTF-8
+		const char *u8 = ToU8W((wchar_t *)&buf[2]);
+
+		free(buf);
+		buf = (uint8_t *)u8;
+	} else if(len >= 2 && (buf[0] == 0xfe && buf[1] == 0xff)) {
+		// UTF-16BE BOM
+		//		UTF-16BE -> UTF-16LE
+		{
+			uint8_t *p = &buf[2];
+			len -= 2;
+			len /= 2;
+			for (size_t i=0; i<len; i++) {
+				uint8_t t = *p;
+				*p = *(p+1);
+				*(p+1) = t;
+				p += 2;
+			};
+		}
+		//		UTF-16LE -> UTF-8
+		const char *u8 = ToU8W((wchar_t *)&buf[2]);
+
+		free(buf);
+		buf = (uint8_t *)u8;
+	} else {
+		// ACP? -> UTF-8
+		const char *u8 = ToU8A((char *)buf);
+		if (u8 != NULL) {
+			// ACP -> UTF-8
+			free(buf);
+			buf = (uint8_t *)u8;
+		}
+	}
+
+	*_len = strlen((char *)buf)+1;	// 改めて長さを計る
+	return (char *)buf;
+}
+
+/**
+ *	ファイルをメモリに読み込む
+ *	中身はUTF-8に変換される
+ *
+ *	@param[out]	*_len	サイズ(最後に付加される"\0"を含む)
+ *	@retval		ファイルの中身へのポインタ(使用後free()すること)
+ *				NULL=エラー
+ */
+char *LoadFileU8A(const char *FileName, size_t *_len)
+{
+	*_len = 0;
+	FILE *fp = fopen(FileName, "rb");
+	if (fp == NULL) {
+		return NULL;
+	}
+	size_t len;
+	char *u8 = LoadFileU8(fp, &len);
+	fclose(fp);
+	if (u8 == NULL) {
+		return NULL;
+	}
+	*_len = len;
+	return u8;
+}
+
+char *LoadFileAA(const char *FileName, size_t *_len)
+{
+	*_len = 0;
+	size_t len;
+	char *u8 = LoadFileU8A(FileName, &len);
+	if (u8 == NULL) {
+		return NULL;
+	}
+	char *strA = (char *)ToCharU8(u8);
+	free(u8);
+	if (strA == NULL) {
+		return NULL;
+	}
+	len = strlen(strA);
+	*_len = len;
+	return strA;
+}

Added: branches/cmake/teraterm/ttpmacro/fileread.h
===================================================================
--- branches/cmake/teraterm/ttpmacro/fileread.h	                        (rev 0)
+++ branches/cmake/teraterm/ttpmacro/fileread.h	2018-12-18 14:46:19 UTC (rev 7332)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif//__cplusplus
+
+char *LoadFileU8A(const char *FileName, size_t *_len);
+char *LoadFileU8T(const TCHAR *FileName, size_t *_len);
+char *LoadFileAA(const char *FileName, size_t *_len);
+
+#ifdef __cplusplus
+}
+#endif//__cplusplus

Modified: branches/cmake/teraterm/ttpmacro/ttl.c
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttl.c	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/ttpmacro/ttl.c	2018-12-18 14:46:19 UTC (rev 7332)
@@ -93,8 +93,7 @@
 static intptr_t DirHandle[NumDirHandle] = {-1,-1, -1, -1, -1, -1, -1, -1};
 /* for "FileMarkPtr" and "FileSeekBack" commands */
 #define NumFHandle 16
-//static HANDLE FHandle[NumFHandle];
-static HANDLE FHandle_[NumFHandle];
+static HANDLE FHandle[NumFHandle];
 static long FPointer[NumFHandle];
 
 // forward declaration
@@ -103,8 +102,8 @@
 static void HandleInit()
 {
 	int i;
-	for (i=0; i<_countof(FHandle_); i++) {
-		FHandle_[i] = INVALID_HANDLE_VALUE;
+	for (i=0; i<_countof(FHandle); i++) {
+		FHandle[i] = INVALID_HANDLE_VALUE;
 	}
 }
 
@@ -118,9 +117,10 @@
 	if (FH == INVALID_HANDLE_VALUE) {
 		return -1;
 	}
-	for (i=0; i<_countof(FHandle_); i++) {
-		if (FHandle_[i] == INVALID_HANDLE_VALUE) {
-			FHandle_[i] = FH;
+	for (i=0; i<_countof(FHandle); i++) {
+		if (FHandle[i] == INVALID_HANDLE_VALUE) {
+			FHandle[i] = FH;
+			FPointer[i] = 0;
 			return i;
 		}
 	}
@@ -129,15 +129,15 @@
 
 static HANDLE HandleGet(int fhi)
 {
-	if (fhi < 0 || _countof(FHandle_) < fhi) {
+	if (fhi < 0 || _countof(FHandle) < fhi) {
 		return INVALID_HANDLE_VALUE;
 	}
-	return FHandle_[fhi];
+	return FHandle[fhi];
 }
 
 static void HandleFree(int fhi)
 {
-	FHandle_[fhi] = INVALID_HANDLE_VALUE;
+	FHandle[fhi] = INVALID_HANDLE_VALUE;
 }
 
 BOOL InitTTL(HWND HWin)

Modified: branches/cmake/teraterm/ttpmacro/ttmbuff.c
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttmbuff.c	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/ttpmacro/ttmbuff.c	2018-12-18 14:46:19 UTC (rev 7332)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (C) 1994-1998 T. Teranishi
  * (C) 2005-2017 TeraTerm Project
  * All rights reserved.
@@ -32,30 +32,35 @@
 #include "teraterm.h"
 #include <string.h>
 #include <stdlib.h>
+#include <crtdbg.h>
 #include "ttmparse.h"
 #include "ttlib.h"
-#include "win16api.h"
+#include "fileread.h"
 
 #include "ttmbuff.h"
 
+#ifdef _DEBUG
+#define malloc(l)     _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
+#define free(p)       _free_dbg((p), _NORMAL_BLOCK)
+#endif
+
 int EndWhileFlag;
 int BreakFlag;
 BOOL ContinueFlag;
 
-#define MAXBUFFLEN 2147483647
+#define MAXBUFFLEN 2147483647	// 0x7FFF_FFFF‬
 
 #define MAXNESTLEVEL 10
 
-#define MAXFILENAME 128   // .ttl\x83t\x83@\x83C\x83\x8B\x96\xBC\x82̍ő\xE5\x83T\x83C\x83Y
+#define MAXFILENAME 128   // .ttlファイル名の最大サイズ
 
 static int INest;
-static HANDLE BuffHandle[MAXNESTLEVEL];
-static CHAR BuffHandleFileName[MAXNESTLEVEL][MAXFILENAME];  // \x8Ae\x8AK\x91w\x82\xCC.ttl\x83t\x83@\x83C\x83\x8B\x96\xBC
+static CHAR BuffHandleFileName[MAXNESTLEVEL][MAXFILENAME];  // 各階層の.ttlファイル名
 static PCHAR Buff[MAXNESTLEVEL];
 static BINT BuffLen[MAXNESTLEVEL];
 static BINT BuffPtr[MAXNESTLEVEL];
 
-// \x8Ds\x8F\xEE\x95\xF1\x94z\x97\xF1
+// 行情報配列
 #define MAX_LINENO 100000
 static BINT *BuffLineNo[MAXNESTLEVEL];
 static BINT BuffLineNoMaxIndex[MAXNESTLEVEL];
@@ -100,12 +105,12 @@
 	return (p);
 }
 
-// \x83}\x83N\x83\x8D\x83E\x83B\x83\x93\x83h\x83E\x82ɕ\\x8E\xA6\x82\xB7\x82\xE9\x83R\x83}\x83\x93\x83h\x82\xA9\x82ǂ\xA4\x82\xA9\x94\xBB\x95ʂ\xB7\x82\xE9 (2006.2.24 yutaka)
+// マクロウィンドウに表示するコマンドかどうか判別する (2006.2.24 yutaka)
 int IsUpdateMacroCommand(void)
 {
 	char *p = GetLineBuffer();
 
-	// \x8C\xB4\x91\xA5\x82Ƃ\xB5\x82ăE\x83F\x83C\x83g\x81E\x83X\x83\x8A\x81[\x83v\x8Cn\x83R\x83}\x83\x93\x83h\x82\xF0\x91ΏۂƂ\xB7\x82\xE9
+	// 原則としてウェイト・スリープ系コマンドを対象とする
 	if (_strnicmp(p, "wait", 4) == 0)
 		return 1;
 
@@ -119,120 +124,70 @@
 }
 
 
-// \x83}\x83N\x83\x8D\x83t\x83@\x83C\x83\x8B\x82̐擪\x82ɂ\xA0\x82\xE9 BOM \x82\xF0\x8F\x9C\x8B\x8E\x82\xB7\x82\xE9\x81B
-static void TrimUnicodeBOM(CHAR *pbuf, BINT *plen)
-{
-	BYTE *buf = pbuf;
-	BINT len = *plen;
-
-	// UTF-8 BOM
-	if (len > 3) {
-		if (buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF) {
-			memmove_s(&buf[0], len, &buf[3], len - 3);
-			*plen = len - 3;
-		}
-	}
-}
-
-
 BOOL LoadMacroFile(PCHAR FileName, int IBuff)
 {
-	HANDLE F;
-	int dummy_read = 0;
 	char basename[MAX_PATH];
-	unsigned int i, n;
+	size_t Len;
 
 	if ((FileName[0]==0) || (IBuff>MAXNESTLEVEL-1)) {
 		return FALSE;
 	}
-	if (BuffHandle[IBuff]!=0) {
-		return FALSE;
-	}
 
-	// include\x82ɐ\xAC\x8C\x{1C2D42}\xBD\x83t\x83@\x83C\x83\x8B\x82\xA9\x82\xE7\x81A\x83t\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x8BL\x98^\x82\xB7\x82\xE9\x81B
-	// \x83}\x83N\x83\x8D\x82̃G\x83\x89\x81[\x83_\x83C\x83A\x83\x8D\x83O\x82ŁA\x83t\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x95\\x8E\xA6\x82\xB5\x82\xBD\x82\xA2\x82\xBD\x82߁B
+	// includeに成功したファイルから、ファイル名を記録する。
+	// マクロのエラーダイアログで、ファイル名を表示したいため。
 	// (2013.9.8 yutaka)
-	if (GetFileTitle(FileName, basename, sizeof(basename)) != 0) 
+	if (GetFileTitleA(FileName, basename, sizeof(basename)) != 0)
 		strncpy_s(basename, sizeof(basename), FileName, _TRUNCATE);
 	strncpy_s(&BuffHandleFileName[IBuff][0], MAXFILENAME, basename, _TRUNCATE);
 
 	BuffPtr[IBuff] = 0;
 
-	// get file length
-	BuffLen[IBuff] = GetFSize(FileName);
-#if 1
-	// include\x82Ŏw\x92肳\x82ꂽ\x83}\x83N\x83\x8D\x83t\x83@\x83C\x83\x8B\x82\xAA\x8B\xF3\x82̏ꍇ\x82ɃG\x83\x89\x81[\x82ɂ͂\xB5\x82Ȃ\xA2\x81B(2007.6.8 yutaka)
-	if (BuffLen[IBuff]==0) {
-		// GlobalLock()\x82̈\x{4140AA}\x83[\x83\x8D\x82\xBE\x82\xC6 NULL \x82\xAA\x95Ԃ\xC1\x82Ă\xAD\x82\xE9\x82̂ŁA\x83_\x83~\x81[\x82ŋ󔒂\xF0\x93\xFC\x82\xEA\x82\xE9\x81B
-		BuffLen[IBuff] = 2;
-		dummy_read = 1;
-	}
-#endif
-	if (BuffLen[IBuff]>MAXBUFFLEN) {
+	Buff[IBuff] = LoadFileAA(FileName, &Len);
+//	Buff[IBuff] = LoadFileU8A(FileName, &Len);
+	if (Buff[IBuff] == NULL) {
+		BuffLen[IBuff] = 0;
 		return FALSE;
 	}
-
-	if (BuffLineNo[IBuff] == NULL) {
-		BuffLineNo[IBuff] = malloc(MAX_LINENO * sizeof(BINT));
-	}
-
-	F = _lopen(FileName,OF_READ);
-	if (F == INVALID_HANDLE_VALUE) {
+	if (Len>MAXBUFFLEN) {
 		return FALSE;
 	}
-	BuffHandle[IBuff] = GlobalAlloc(GMEM_MOVEABLE, BuffLen[IBuff]);
-	if (BuffHandle[IBuff]!=NULL) {
-		Buff[IBuff] = GlobalLock(BuffHandle[IBuff]);
-		if (Buff[IBuff]!=NULL) {
-			_lread(F, Buff[IBuff], BuffLen[IBuff]);
-			if (dummy_read == 1) {
-				Buff[IBuff][0] = ' ';
-				Buff[IBuff][1] = '\0';
-			}
-			_lclose(F);
+	BuffLen[IBuff] = Len;
 
-			// for UTF-8 BOM
-			// (2015.5.15 yutaka)
-			TrimUnicodeBOM(Buff[IBuff], &BuffLen[IBuff]);
+	// 行番号配列を作る。これにより、バッファのインデックスから行番号への変換が
+	// O(N)->O(logN)で検索できるようになる。
+	// (2014.1.18 yutaka)
+	{
+		unsigned int i, n;
+		n = 0;
+		if (BuffLineNo[IBuff] == NULL) {
+			BuffLineNo[IBuff] = malloc(MAX_LINENO * sizeof(BINT));
+		}
+		BuffLineNo[IBuff][n] = 0;
+		for (i = 0 ; i < BuffLen[IBuff] ; i++) {
+			if (Buff[IBuff][i] == 0x0A) {
+				if (i == BuffLen[IBuff] - 1) {
+					// バッファの最後が改行コードだった場合、もう次の行番号は存在しない。
 
-			// \x8Ds\x94ԍ\x86\x94z\x97\xF1\x82\xF0\x8D\xEC\x82\xE9\x81B\x82\xB1\x82\xEA\x82ɂ\xE6\x82\xE8\x81A\x83o\x83b\x83t\x83@\x82̃C\x83\x93\x83f\x83b\x83N\x83X\x82\xA9\x82\xE7\x8Ds\x94ԍ\x86\x82ւ̕ϊ\xB7\x82\xAA
-			// O(N)->O(logN)\x82Ō\x9F\x8D\xF5\x82ł\xAB\x82\xE9\x82悤\x82ɂȂ\xE9\x81B
-			// (2014.1.18 yutaka)
-			n = 0;
-			BuffLineNo[IBuff][n] = 0;
-			for (i = 0 ; i < BuffLen[IBuff] ; i++) {
-				if (Buff[IBuff][i] == 0x0A) {
-					if (i == BuffLen[IBuff] - 1) {
-						// \x83o\x83b\x83t\x83@\x82̍Ōオ\x89\xFC\x8Ds\x83R\x81[\x83h\x82\xBE\x82\xC1\x82\xBD\x8Fꍇ\x81A\x82\xE0\x82\xA4\x8E\x9F\x82̍s\x94ԍ\x86\x82͑\xB6\x8D݂\xB5\x82Ȃ\xA2\x81B
-
+				} else {
+					if (n < MAX_LINENO - 1) {
+						n++;
+						BuffLineNo[IBuff][n] = i + 1;
 					} else {
-						if (n < MAX_LINENO - 1) {
-							n++;
-							BuffLineNo[IBuff][n] = i + 1;
-						} else {
-							// Out of memory
+						// Out of memory
 
-						}
 					}
 				}
 			}
-			BuffLineNoMaxIndex[IBuff] = n + 1;
+		}
 
-			GlobalUnlock(BuffHandle[IBuff]);
-			return TRUE;
-		}
-		else {
-			GlobalFree(BuffHandle[IBuff]);
-			BuffHandle[IBuff] = 0;
-		}
+		BuffLineNoMaxIndex[IBuff] = n + 1;
 	}
-	_lclose(F);
 
-	return FALSE;
+	return TRUE;
 }
 
 
-// \x8C\xBB\x8Dݎ\xC0\x8Ds\x92\x86\x82̃}\x83N\x83\x8D\x83t\x83@\x83C\x83\x8B\x82̃t\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x95Ԃ\xB7
+// 現在実行中のマクロファイルのファイル名を返す
 char *GetMacroFileName(void)
 {
 	return &BuffHandleFileName[INest][0];
@@ -239,7 +194,7 @@
 }
 
 
-// \x8C\xBB\x8Dݎ\xC0\x8Ds\x92\x86\x82̃}\x83N\x83\x8D\x83t\x83@\x83C\x83\x8B\x82̍s\x94ԍ\x86\x82\xF0\x95Ԃ\xB7 (2005.7.18 yutaka)
+// 現在実行中のマクロファイルの行番号を返す (2005.7.18 yutaka)
 static int getCurrentLineNumber(BINT curpos, BINT *lineno, BINT linenomax)
 {
 	BINT i, no;
@@ -251,7 +206,7 @@
 			break;
 		}
 	}
-	// \x8DŌ\xE3\x82̍s\x82\xF0\x83p\x81[\x83X\x82\xB5\x82\xBD\x8DہA\x8Ds\x94ԍ\x86\x82\xF0\x95Ԃ\xB9\x82Ă\xA2\x82Ȃ\xA9\x82\xC1\x82\xBD\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B
+	// 最後の行をパースした際、行番号を返せていなかった問題を修正した。
 	// (2014.7.6 yutaka)
 	if (no == 0 && i == linenomax) {
 		no = linenomax;
@@ -267,7 +222,6 @@
 	BYTE b;
 
 	LineStart = BuffPtr[INest];
-	Buff[INest] = GlobalLock(BuffHandle[INest]);
 	if (Buff[INest]==NULL) return FALSE;
 
 	if (BuffPtr[INest]<BuffLen[INest])
@@ -278,12 +232,12 @@
 	while ((BuffPtr[INest]<BuffLen[INest]) &&
 		((b>=0x20) || (b==0x09)))
 	{
-		// LineBuff[]\x82̃o\x83b\x83t\x83@\x83T\x83C\x83Y\x82𒴂\xA6\x82\xE9\x8Fꍇ\x82̓G\x83\x89\x81[\x82Ƃ\xB7\x82\xE9\x81B
-		// \x82\xBD\x82\xBE\x82\xB5\x81A\x83}\x83N\x83\x8D\x82\xAA\x82\xA2\x82\xAB\x82Ȃ\xE8\x8FI\x97\xB9\x82\xB7\x82\xE9\x82̂Ń_\x83C\x83A\x83\x8D\x83O\x82\xF0\x95\\x8E\xA6\x82\xB7\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x82ق\xA4\x82\xAA
-		// \x82\xA2\x82\xA2\x82\xA9\x82\xE0\x82\xB5\x82\xEA\x82Ȃ\xA2\x81B
+		// LineBuff[]のバッファサイズを超える場合はエラーとする。
+		// ただし、マクロがいきなり終了するのでダイアログを表示するようにしたほうが
+		// いいかもしれない。
 		// (2007.6.6 yutaka)
-		// \x83o\x83b\x83t\x83@\x83T\x83C\x83Y\x82Ɏ\xFB\x82܂\xE9\x94͈͂ŃR\x83s\x81[\x82\xB7\x82\xE9\x81B
-		// break \x82\xB7\x82\xE9\x82Ƃ\xA0\x82ӂꂽ\x95\xAA\x82\xAA\x8E\x9F\x82̍s\x82Ƃ\xB5\x82Ĉ\xB5\x82\xED\x82\xEA\x82\xE9\x82̂\xC5 break \x82\xB5\x82Ȃ\xA2\x81B
+		// バッファサイズに収まる範囲でコピーする。
+		// break するとあふれた分が次の行として扱われるので break しない。
 		// (2007.6.9 maya)
 		if (i < MaxLineLen-1) {
 			LineBuff[i] = b;
@@ -298,8 +252,8 @@
 	LineParsePtr = 0;
 
 	// current line number (2005.7.18 yutaka)
-	// \x83o\x83b\x83t\x83@\x82̃C\x83\x93\x83f\x83b\x83N\x83X\x82\xA9\x82獂\x91\xAC\x82ɍs\x94ԍ\x86\x82\xF0\x88\xF8\x82\xAF\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B(2014.1.18 yutaka)
-	LineNo = getCurrentLineNumber(BuffPtr[INest], BuffLineNo[INest], BuffLineNoMaxIndex[INest]); 
+	// バッファのインデックスから高速に行番号を引けるようにした。(2014.1.18 yutaka)
+	LineNo = getCurrentLineNumber(BuffPtr[INest], BuffLineNo[INest], BuffLineNoMaxIndex[INest]);
 
 	while ((BuffPtr[INest]<BuffLen[INest]) &&
 		(b<0x20) && (b!=0x09))
@@ -308,7 +262,6 @@
 		if (BuffPtr[INest]<BuffLen[INest])
 			b = (Buff[INest])[BuffPtr[INest]];
 	}
-	GlobalUnlock(BuffHandle[INest]);
 	return ((LineLen>0) || (BuffPtr[INest]<BuffLen[INest]));
 }
 
@@ -343,7 +296,6 @@
 	TVarId VarId;
 	TStrVal tmp;
 
-	Buff[IBuff] = GlobalLock(BuffHandle[IBuff]);
 	if (Buff[IBuff]==NULL) {
 		return FALSE;
 	}
@@ -372,7 +324,7 @@
 		    LinePtr--;
 		}
 
-		/* \x8E\x9F\x82̍s\x82ֈڂ\xB7\x91O\x82ɁAC\x8C\xBE\x8C\xEA\x83R\x83\x81\x83\x93\x83g\x82\xF0\x92T\x82\xB7\x82\xBD\x82߁A\x8Ds\x96\x96\x82܂ŃX\x83L\x83\x83\x83\x93\x82\xB7\x82\xE9\x81B*/
+		/* 次の行へ移す前に、C言語コメントを探すため、行末までスキャンする。*/
 		while ((b=GetFirstChar()) != 0) {
 			if (b=='"' || b=='\'' || b=='#') {
 				LinePtr--;
@@ -391,7 +343,6 @@
 
 	BuffPtr[IBuff] = 0;
 	InitLineNo(); // (2005.7.18 yutaka)
-	GlobalUnlock(BuffHandle[IBuff]);
 	return TRUE;
 }
 
@@ -404,7 +355,7 @@
 	EndWhileFlag = 0;
 	BreakFlag = 0;
 	for (i=0 ; i<=MAXNESTLEVEL-1 ; i++) {
-		BuffHandle[i] = 0;
+		Buff[i] = NULL;
 	}
 	INest = 0;
 	if (! LoadMacroFile(FileName, INest)) {
@@ -422,14 +373,8 @@
 
 	DelLabVar((WORD)IBuff);
 	for (i=IBuff ; i<=MAXNESTLEVEL-1 ; i++) {
-		if (BuffHandle[i]!=NULL) {
-			GlobalUnlock(BuffHandle[i]);
-			GlobalFree(BuffHandle[i]);
-		}
-		BuffHandle[i] = NULL;
-
 		free(BuffLineNo[i]);
-		/* \x83|\x83C\x83\x93\x83^\x82̏\x89\x8A\xFA\x89\xBB\x98R\x82\xEA\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B4.81\x82ł̃f\x83O\x83\x8C\x81[\x83h\x81B
+		/* ポインタの初期化漏れを修正した。4.81でのデグレード。
 		 * (2014.3.4 yutaka)
 		 */
 		BuffLineNo[i] = NULL;

Modified: branches/cmake/teraterm/ttpmacro/ttpmacro.v10.vcxproj
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttpmacro.v10.vcxproj	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/ttpmacro/ttpmacro.v10.vcxproj	2018-12-18 14:46:19 UTC (rev 7332)
@@ -126,6 +126,7 @@
   <ItemGroup>
     <ClCompile Include="..\common\win16api.c" />
     <ClCompile Include="errdlg.cpp" />
+    <ClCompile Include="fileread.cpp" />
     <ClCompile Include="inpdlg.cpp" />
     <ClCompile Include="ListDlg.cpp" />
     <ClCompile Include="msgdlg.cpp" />

Modified: branches/cmake/teraterm/ttpmacro/ttpmacro.v11.vcxproj
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttpmacro.v11.vcxproj	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/ttpmacro/ttpmacro.v11.vcxproj	2018-12-18 14:46:19 UTC (rev 7332)
@@ -126,6 +126,7 @@
   <ItemGroup>
     <ClCompile Include="..\common\win16api.c" />
     <ClCompile Include="errdlg.cpp" />
+    <ClCompile Include="fileread.cpp" />
     <ClCompile Include="inpdlg.cpp" />
     <ClCompile Include="ListDlg.cpp" />
     <ClCompile Include="msgdlg.cpp" />

Modified: branches/cmake/teraterm/ttpmacro/ttpmacro.v12.vcxproj
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttpmacro.v12.vcxproj	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/ttpmacro/ttpmacro.v12.vcxproj	2018-12-18 14:46:19 UTC (rev 7332)
@@ -126,11 +126,13 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="..\common\codeconv.cpp" />
     <ClCompile Include="..\common\i18n.c" />
     <ClCompile Include="..\common\stdafx.cpp" />
     <ClCompile Include="..\common\ttlib.c" />
     <ClCompile Include="..\common\win16api.c" />
     <ClCompile Include="errdlg.cpp" />
+    <ClCompile Include="fileread.cpp" />
     <ClCompile Include="inpdlg.cpp" />
     <ClCompile Include="ListDlg.cpp" />
     <ClCompile Include="msgdlg.cpp" />
@@ -147,14 +149,18 @@
     <ClCompile Include="wait4all.c" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\common\codeconv.h" />
+    <ClInclude Include="..\common\ttddecmnd.h" />
     <ClInclude Include="..\common\ttlib.h" />
+    <ClInclude Include="..\common\win16api.h" />
+    <ClInclude Include="..\common\ttddecmnd.h" />
     <ClInclude Include="errdlg.h" />
+    <ClInclude Include="fileread.h" />
     <ClInclude Include="inpdlg.h" />
     <ClInclude Include="ListDlg.h" />
     <ClInclude Include="msgdlg.h" />
     <ClInclude Include="statdlg.h" />
     <ClInclude Include="stdafx.h" />
-    <ClInclude Include="..\common\ttddecmnd.h" />
     <ClInclude Include="ttl.h" />
     <ClInclude Include="ttmacro.h" />
     <ClInclude Include="ttmbuff.h" />

Modified: branches/cmake/teraterm/ttpmacro/ttpmacro.v14.vcxproj
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttpmacro.v14.vcxproj	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/ttpmacro/ttpmacro.v14.vcxproj	2018-12-18 14:46:19 UTC (rev 7332)
@@ -126,11 +126,13 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="..\common\codeconv.cpp" />
     <ClCompile Include="..\common\i18n.c" />
     <ClCompile Include="..\common\stdafx.cpp" />
     <ClCompile Include="..\common\ttlib.c" />
     <ClCompile Include="..\common\win16api.c" />
     <ClCompile Include="errdlg.cpp" />
+    <ClCompile Include="fileread.cpp" />
     <ClCompile Include="inpdlg.cpp" />
     <ClCompile Include="ListDlg.cpp" />
     <ClCompile Include="msgdlg.cpp" />
@@ -147,9 +149,13 @@
     <ClCompile Include="wait4all.c" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\common\codeconv.h" />
     <ClInclude Include="..\common\ttddecmnd.h" />
     <ClInclude Include="..\common\ttlib.h" />
+    <ClInclude Include="..\common\win16api.h" />
+    <ClInclude Include="..\common\ttddecmnd.h" />
     <ClInclude Include="errdlg.h" />
+    <ClInclude Include="fileread.h" />
     <ClInclude Include="inpdlg.h" />
     <ClInclude Include="ListDlg.h" />
     <ClInclude Include="msgdlg.h" />

Modified: branches/cmake/teraterm/ttpmacro/ttpmacro.v15.vcxproj
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttpmacro.v15.vcxproj	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/ttpmacro/ttpmacro.v15.vcxproj	2018-12-18 14:46:19 UTC (rev 7332)
@@ -129,11 +129,13 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="..\common\codeconv.cpp" />
     <ClCompile Include="..\common\i18n.c" />
     <ClCompile Include="..\common\stdafx.cpp" />
     <ClCompile Include="..\common\ttlib.c" />
     <ClCompile Include="..\common\win16api.c" />
     <ClCompile Include="errdlg.cpp" />
+    <ClCompile Include="fileread.cpp" />
     <ClCompile Include="inpdlg.cpp" />
     <ClCompile Include="ListDlg.cpp" />
     <ClCompile Include="msgdlg.cpp" />
@@ -150,10 +152,13 @@
     <ClCompile Include="wait4all.c" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\common\codeconv.h" />
     <ClInclude Include="..\common\ttddecmnd.h" />
     <ClInclude Include="..\common\ttlib.h" />
     <ClInclude Include="..\common\win16api.h" />
+    <ClInclude Include="..\common\ttddecmnd.h" />
     <ClInclude Include="errdlg.h" />
+    <ClInclude Include="fileread.h" />
     <ClInclude Include="inpdlg.h" />
     <ClInclude Include="ListDlg.h" />
     <ClInclude Include="msgdlg.h" />

Modified: branches/cmake/teraterm/ttpmacro/ttpmacro.v15.vcxproj.filters
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttpmacro.v15.vcxproj.filters	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/ttpmacro/ttpmacro.v15.vcxproj.filters	2018-12-18 14:46:19 UTC (rev 7332)
@@ -76,6 +76,12 @@
     <ClCompile Include="..\common\win16api.c">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\common\codeconv.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="fileread.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="errdlg.h">
@@ -138,6 +144,12 @@
     <ClInclude Include="..\common\win16api.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\common\codeconv.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="fileread.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Image Include="ttmacro.ico">

Modified: branches/cmake/teraterm/ttpmacro/ttpmacro.v9.vcproj
===================================================================
--- branches/cmake/teraterm/ttpmacro/ttpmacro.v9.vcproj	2018-12-18 14:31:04 UTC (rev 7331)
+++ branches/cmake/teraterm/ttpmacro/ttpmacro.v9.vcproj	2018-12-18 14:46:19 UTC (rev 7332)
@@ -399,6 +399,10 @@
 				RelativePath="..\common\win16api.c"
 				>
 			</File>
+			<File
+				RelativePath="fileread.cpp"
+				>
+			</File>
 		</Filter>
 	</Files>
 	<Globals>

Added: branches/cmake/tests/code_cp932.ttl
===================================================================
--- branches/cmake/tests/code_cp932.ttl	                        (rev 0)
+++ branches/cmake/tests/code_cp932.ttl	2018-12-18 14:46:19 UTC (rev 7332)
@@ -0,0 +1,4 @@
+;; -*- coding: cp932 -*-
+
+messagebox "code cp932" "check code ttl"
+messagebox "\x82\xB1\x82\xF1\x82ɂ\xBF\x82\xCD" "check code ttl"

Added: branches/cmake/tests/code_utf16be-bom.ttl
===================================================================
--- branches/cmake/tests/code_utf16be-bom.ttl	                        (rev 0)
+++ branches/cmake/tests/code_utf16be-bom.ttl	2018-12-18 14:46:19 UTC (rev 7332)
@@ -0,0 +1,8 @@
+\xFE\xFF ; ;   - * -   c o d i n g :   u t f - 1 6 b e - w i t h - s i g n a t u r e   - * - 
+ 
+ 
+ 
+ m e s s a g e b o x   " c o d e   u t f 1 6 b e   b o m "   " c h e c k   c o d e   t t l " 
+ 
+ m e s s a g e b o x   "0S0\x930k0a0o ,  \xC5H\xB1U\xD5X\xC18Ɣ ,  \xE9\xDC\xD5\xDD ,   u t f 8   c o d e "   " c h e c k   c o d e   t t l " 
+ 

Added: branches/cmake/tests/code_utf16le-bom.ttl
===================================================================
--- branches/cmake/tests/code_utf16le-bom.ttl	                        (rev 0)
+++ branches/cmake/tests/code_utf16le-bom.ttl	2018-12-18 14:46:19 UTC (rev 7332)
@@ -0,0 +1,9 @@
+\xFF\xFE; ;   - * -   c o d i n g :   u t f - 1 6 l e - w i t h - s i g n a t u r e   - * - 
+ 
+ 
+ 
+ m e s s a g e b o x   " c o d e   u t f 1 6 l e   b o m "   " c h e c k   c o d e   t t l " 
+ 
+ m e s s a g e b o x   " S0\x930k0a0o0,   H\xC5U\xB1X\xD58\xC1\x94\xC6,   \xE9\xDC\xD5\xDD,   u t f 8   c o d e "   " c h e c k   c o d e   t t l " 
+ 
+ 
\ No newline at end of file

Added: branches/cmake/tests/code_utf8-bom.ttl
===================================================================
--- branches/cmake/tests/code_utf8-bom.ttl	                        (rev 0)
+++ branches/cmake/tests/code_utf8-bom.ttl	2018-12-18 14:46:19 UTC (rev 7332)
@@ -0,0 +1,4 @@
+;; -*- coding: utf-8-with-signature -*-
+
+messagebox "code utf8-bom" "check code ttl"
+messagebox "こんにちは, 안녕하세요, שלום, utf8 code" "check code ttl"

Added: branches/cmake/tests/code_utf8.ttl
===================================================================
--- branches/cmake/tests/code_utf8.ttl	                        (rev 0)
+++ branches/cmake/tests/code_utf8.ttl	2018-12-18 14:46:19 UTC (rev 7332)
@@ -0,0 +1,4 @@
+;; -*- coding: utf-8 -*-
+
+messagebox "code utf8 (no bom)" "check code ttl"
+messagebox "こんにちは, 안녕하세요, שלום, utf8 code" "check code ttl"


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