[Ttssh2-commit] [8879] 行末を検出するcheckeolを追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2020年 8月 6日 (木) 00:06:29 JST


Revision: 8879
          https://osdn.net/projects/ttssh2/scm/svn/commits/8879
Author:   zmatsuo
Date:     2020-08-06 00:06:29 +0900 (Thu, 06 Aug 2020)
Log Message:
-----------
行末を検出するcheckeolを追加

Modified Paths:
--------------
    branches/filesys_log/teraterm/teraterm/CMakeLists.txt
    branches/filesys_log/teraterm/teraterm/ttermpro.v16.vcxproj
    branches/filesys_log/teraterm/teraterm/ttermpro.v16.vcxproj.filters
    branches/filesys_log/teraterm/teraterm/ttermpro.vcproj

Added Paths:
-----------
    branches/filesys_log/teraterm/teraterm/checkeol.cpp
    branches/filesys_log/teraterm/teraterm/checkeol.h

-------------- next part --------------
Modified: branches/filesys_log/teraterm/teraterm/CMakeLists.txt
===================================================================
--- branches/filesys_log/teraterm/teraterm/CMakeLists.txt	2020-08-05 15:06:21 UTC (rev 8878)
+++ branches/filesys_log/teraterm/teraterm/CMakeLists.txt	2020-08-05 15:06:29 UTC (rev 8879)
@@ -15,6 +15,8 @@
   broadcast.h
   buffer.c
   buffer.h
+  checkeol.cpp
+  checkeol.h
   clipboar.c
   clipboar.h
   coding_pp.cpp

Added: branches/filesys_log/teraterm/teraterm/checkeol.cpp
===================================================================
--- branches/filesys_log/teraterm/teraterm/checkeol.cpp	                        (rev 0)
+++ branches/filesys_log/teraterm/teraterm/checkeol.cpp	2020-08-05 15:06:29 UTC (rev 8879)
@@ -0,0 +1,78 @@
+
+#include <stdlib.h>
+#include <windows.h>
+
+#include "checkeol.h"
+
+// tttypes.h
+#define CR   0x0D
+#define LF   0x0A
+
+struct CheckEOLData_st {
+	BOOL cr_hold;
+};
+
+CheckEOLData_t *CheckEOLCreate(void)
+{
+	CheckEOLData_t *self = (CheckEOLData_t *)calloc(sizeof(CheckEOLData_t), 1);
+	return self;
+}
+
+void CheckEOLDestroy(CheckEOLData_t *self)
+{
+	free(self);
+}
+
+void CheckEOLClear(CheckEOLData_t *self)
+{
+	self->cr_hold = FALSE;
+}
+
+/**
+ *	\x8E\x9F\x82\xC9EOL(\x89\xFC\x8Ds), u32 \x82\xF0\x8Fo\x97͂\xB7\x82邩\x92\xB2\x82ׂ\xE9
+ *
+ *	\x96߂\xE8\x92l\x82\xCD CheckEOLRet \x82\xCC OR \x82ŕԂ\xE9
+ *
+ *	@retval	CheckEOLNoOutput	\x89\xBD\x82\xE0\x8Fo\x97͂\xB5\x82Ȃ\xA2
+ *	@retval	CheckEOLOutputEOL	\x89\xFC\x8Ds\x83R\x81[\x83h\x82\xF0\x8Fo\x97͂\xB7\x82\xE9
+ *	@retval	CheckEOLOutputChar	u32\x82\xF0\x82\xBB\x82̂܂܏o\x97͂\xB7\x82\xE9
+ */
+CheckEOLRet CheckEOLCheck(CheckEOLData_t *self, unsigned int u32)
+{
+   	// \x93\xFC\x97͂\xAA\x89\xFC\x8Ds(CR or LF)\x82̏ꍇ\x81A
+	// \x89\xFC\x8Ds\x82̎\xED\x97\xDE(CR or LF or CR+LF)\x82\xF0\x8E\xA9\x93\xAE\x82Ŕ\xBB\x92肵\x82\xC4
+	// OutputLogNewLine() \x82ʼn\xFC\x8Ds\x82\xF0\x8Fo\x97͂\xB7\x82\xE9
+	//		\x93\xFC\x97\xCD    CR hold     \x89\xFC\x8Ds\x8Fo\x97\xCD   	CR hold \x95ύX
+   	// 		+-------+-----------+-----------+------------
+	//		CR      \x82Ȃ\xB5        \x82\xB5\x82Ȃ\xA2		\x83Z\x83b\x83g\x82\xB7\x82\xE9
+	//		LF      \x82Ȃ\xB5        \x82\xB7\x82\xE9		\x95ω\xBB\x82Ȃ\xB5
+	//		\x82\xBB\x82̑\xBC  \x82Ȃ\xB5        \x82\xB5\x82Ȃ\xA2		\x95ω\xBB\x82Ȃ\xB5
+	//		CR      \x82\xA0\x82\xE8        \x82\xB7\x82\xE9		\x95ω\xBB\x82Ȃ\xB5(\x83z\x81[\x83\x8B\x83h\x82\xB5\x82\xBD\x82܂\xDC)
+	//		LF      \x82\xA0\x82\xE8        \x82\xB7\x82\xE9		\x83N\x83\x8A\x83A\x82\xB7\x82\xE9
+	//		\x82\xBB\x82̑\xBC  \x82\xA0\x82\xE8        \x82\xB7\x82\xE9		\x83N\x83\x8A\x83A\x82\xB7\x82\xE9
+	if (self->cr_hold == FALSE) {
+		if (u32 == CR) {
+			self->cr_hold = TRUE;
+			return CheckEOLNoOutput;
+		}
+		else if (u32 == LF) {
+			return CheckEOLOutputEOL;
+		}
+		else {
+			return CheckEOLOutputChar;
+		}
+	}
+	else {
+		if (u32 == CR) {
+			return CheckEOLOutputEOL;
+		}
+		else if (u32 == LF) {
+			self->cr_hold = FALSE;
+			return CheckEOLOutputEOL;
+		}
+		else {
+			self->cr_hold = FALSE;
+			return (CheckEOLRet)(CheckEOLOutputEOL | CheckEOLOutputChar);
+		}
+	}
+}

Added: branches/filesys_log/teraterm/teraterm/checkeol.h
===================================================================
--- branches/filesys_log/teraterm/teraterm/checkeol.h	                        (rev 0)
+++ branches/filesys_log/teraterm/teraterm/checkeol.h	2020-08-05 15:06:29 UTC (rev 8879)
@@ -0,0 +1,23 @@
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct CheckEOLData_st CheckEOLData_t;
+
+typedef enum {
+	CheckEOLNoOutput = 0x00,	// \x89\xBD\x82\xE0\x8Fo\x97͂\xB5\x82Ȃ\xA2
+	CheckEOLOutputEOL = 0x01,	// EOL\x82\xF0\x8Fo\x97͂\xB7\x82\xE9
+	CheckEOLOutputChar = 0x02,	// \x82\xBB\x82̂܂܏o\x97͂\xB7\x82\xE9
+} CheckEOLRet;
+
+CheckEOLData_t *CheckEOLCreate(void);
+void CheckEOLDestroy(CheckEOLData_t *self);
+void CheckEOLClear(CheckEOLData_t *self);
+CheckEOLRet CheckEOLCheck(CheckEOLData_t *self, unsigned int u32);
+
+#ifdef __cplusplus
+}
+#endif

Modified: branches/filesys_log/teraterm/teraterm/ttermpro.v16.vcxproj
===================================================================
--- branches/filesys_log/teraterm/teraterm/ttermpro.v16.vcxproj	2020-08-05 15:06:21 UTC (rev 8878)
+++ branches/filesys_log/teraterm/teraterm/ttermpro.v16.vcxproj	2020-08-05 15:06:29 UTC (rev 8879)
@@ -140,6 +140,7 @@
     <ClCompile Include="addsetting.cpp" />
     <ClCompile Include="broadcast.cpp" />
     <ClCompile Include="buffer.c" />
+    <ClCompile Include="checkeol.cpp" />
     <ClCompile Include="clipboar.c" />
     <ClCompile Include="coding_pp.cpp" />
     <ClCompile Include="commlib.c" />
@@ -177,6 +178,7 @@
     <ClInclude Include="../ttpdlg/ttdlg.h" />
     <ClInclude Include="..\susie_plugin\libsusieplugin.h" />
     <ClInclude Include="broadcast.h" />
+    <ClInclude Include="checkeol.h" />
     <ClInclude Include="coding_pp.h" />
     <ClInclude Include="coding_pp_res.h" />
     <ClInclude Include="filesys_log_res.h" />

Modified: branches/filesys_log/teraterm/teraterm/ttermpro.v16.vcxproj.filters
===================================================================
--- branches/filesys_log/teraterm/teraterm/ttermpro.v16.vcxproj.filters	2020-08-05 15:06:21 UTC (rev 8878)
+++ branches/filesys_log/teraterm/teraterm/ttermpro.v16.vcxproj.filters	2020-08-05 15:06:29 UTC (rev 8879)
@@ -150,6 +150,9 @@
     <ClCompile Include="filesys_log.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="checkeol.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Image Include="..\..\cygterm\cygterm.ico">
@@ -381,5 +384,8 @@
     <ClInclude Include="filesys_log_res.h">
       <Filter>Source Files</Filter>
     </ClInclude>
+    <ClInclude Include="checkeol.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
\ No newline at end of file

Modified: branches/filesys_log/teraterm/teraterm/ttermpro.vcproj
===================================================================
--- branches/filesys_log/teraterm/teraterm/ttermpro.vcproj	2020-08-05 15:06:21 UTC (rev 8878)
+++ branches/filesys_log/teraterm/teraterm/ttermpro.vcproj	2020-08-05 15:06:29 UTC (rev 8879)
@@ -213,6 +213,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\checkeol.cpp"
+				>
+			</File>
+			<File
 				RelativePath="filesys.cpp"
 				>
 			</File>
@@ -399,6 +403,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\checkeol.h"
+				>
+			</File>
+			<File
 				RelativePath=".\clipboar.h"
 				>
 			</File>


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