[Ttssh2-commit] [8868] crc16 マクロコマンドの説明を修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2020年 8月 4日 (火) 23:22:59 JST


Revision: 8868
          https://osdn.net/projects/ttssh2/scm/svn/commits/8868
Author:   nmaya
Date:     2020-08-04 23:22:58 +0900 (Tue, 04 Aug 2020)
Log Message:
-----------
crc16 マクロコマンドの説明を修正

MFT: r8867

ticket #40615

ヘルプ
  実装に使われているのは CRC-16-IBM ではなく CRC-16-CCITT なので説明を修正
  crc16 の多項式を修正・表現を crc32 に合わせてビット列にした
  アルゴリズム説明のソースの関数名・定数を実装のソースコードに合わせて修正
  マクロのサンプルコードの ja/en の違いを吸収
ソースコード
  コメントの typo を修正

Revision Links:
--------------
    https://osdn.net/projects/ttssh2/scm/svn/commits/8867

Ticket Links:
------------
    https://osdn.net/projects/ttssh2/tracker/detail/40615

Modified Paths:
--------------
    branches/4-stable/doc/en/html/macro/command/crc16.html
    branches/4-stable/doc/en/html/macro/command/crc32.html
    branches/4-stable/doc/ja/html/macro/command/crc16.html
    branches/4-stable/doc/ja/html/macro/command/crc32.html
    branches/4-stable/teraterm/ttpmacro/ttl.c

Property Changed:
----------------
    branches/4-stable/
    branches/4-stable/TTProxy/
    branches/4-stable/TTXKanjiMenu/
    branches/4-stable/TTXSamples/
    branches/4-stable/cygterm/
    branches/4-stable/teraterm/
    branches/4-stable/ttpmenu/

-------------- next part --------------
Index: branches/4-stable
===================================================================
--- branches/4-stable	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable	2020-08-04 14:22:58 UTC (rev 8868)

Property changes on: branches/4-stable
___________________________________________________________________
Modified: svn:mergeinfo
## -9,4 +9,5 ##
 /branches/ttssh_improved:8027,8036,8040,8044,8053-8054,8058,8060,8063,8081,8085
 /branches/unicode_buf:8270
 /branches/vs2015_warn:6194-6285
-/tags/teraterm-4_89:6182
\ No newline at end of property
+/tags/teraterm-4_89:6182
+/trunk:8867
\ No newline at end of property
Index: branches/4-stable/TTProxy
===================================================================
--- branches/4-stable/TTProxy	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/TTProxy	2020-08-04 14:22:58 UTC (rev 8868)

Property changes on: branches/4-stable/TTProxy
___________________________________________________________________
Modified: svn:mergeinfo
## -2,4 +2,5 ##
 /branches/openssl_1_1_1_v3/TTProxy:8258
 /branches/ttproxy_improved/TTProxy:8041,8055-8056
 /branches/ttssh_improved/TTProxy:8040
-/branches/vs2015_warn/TTProxy:6194-6285
\ No newline at end of property
+/branches/vs2015_warn/TTProxy:6194-6285
+/trunk/TTProxy:8867
\ No newline at end of property
Index: branches/4-stable/TTXKanjiMenu
===================================================================
--- branches/4-stable/TTXKanjiMenu	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/TTXKanjiMenu	2020-08-04 14:22:58 UTC (rev 8868)

Property changes on: branches/4-stable/TTXKanjiMenu
___________________________________________________________________
Modified: svn:mergeinfo
## -1 +1,2 ##
-/branches/vs2015_warn/TTXKanjiMenu:6194-6285
\ No newline at end of property
+/branches/vs2015_warn/TTXKanjiMenu:6194-6285
+/trunk/TTXKanjiMenu:8867
\ No newline at end of property
Index: branches/4-stable/TTXSamples
===================================================================
--- branches/4-stable/TTXSamples	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/TTXSamples	2020-08-04 14:22:58 UTC (rev 8868)

Property changes on: branches/4-stable/TTXSamples
___________________________________________________________________
Modified: svn:mergeinfo
## -1 +1,2 ##
-/branches/vs2015_warn/TTXSamples:6194-6285
\ No newline at end of property
+/branches/vs2015_warn/TTXSamples:6194-6285
+/trunk/TTXSamples:8867
\ No newline at end of property
Index: branches/4-stable/cygterm
===================================================================
--- branches/4-stable/cygterm	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/cygterm	2020-08-04 14:22:58 UTC (rev 8868)

Property changes on: branches/4-stable/cygterm
___________________________________________________________________
Modified: svn:mergeinfo
## -1 +1,2 ##
-/branches/openssl_1_1_1_v3/cygterm:8284
\ No newline at end of property
+/branches/openssl_1_1_1_v3/cygterm:8284
+/trunk/cygterm:8867
\ No newline at end of property
Modified: branches/4-stable/doc/en/html/macro/command/crc16.html
===================================================================
--- branches/4-stable/doc/en/html/macro/command/crc16.html	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/doc/en/html/macro/command/crc16.html	2020-08-04 14:22:58 UTC (rev 8868)
@@ -14,7 +14,7 @@
 <h1>crc16, crc16file</h1>
 
 <p>
-Calculates the CRC-16-IBM of a string or a file.
+Calculates the CRC-16-CCITT of a string or a file.
 </p>
 
 <pre class="macro-syntax">
@@ -28,7 +28,7 @@
 This macro function calculates the CRC(Cyclic Redundancy Checking) of a string or a file. The polynomial expression(right rotation) is as follows:
 <br><br>
 
-0xA001 (x<sup>16</sup>+x<sup>15</sup>+x<sup>2</sup>+x<sup>0</sup>)
+10001000000100001 (x<sup>16</sup>+x<sup>12</sup>+x<sup>5</sup>+x<sup>0</sup>)
 <br><br>
 
 The calculated value stores the variable "intvar" as mathematical value.<br>
@@ -40,8 +40,8 @@
 <code>
 static unsigned int crc16(int n, unsigned char c[])
 {
+#define CRC16POLY1  0x1021U
 #define CRC16POLY2  0x8408U  /* left-right reversal */
-
 	int i, j;
 	unsigned long r;
 
@@ -60,19 +60,19 @@
 <h2>Example</h2>
 
 <pre class="macro-example">
-str = 'this is a test string to be crc16ed'
+str = 'this is a test string to be CRC16ed'
 crc16 crc str
 
-; Display crc16 result asHEX
+; Display CRC16 result asHEX
 sprintf '0x%08X' crc
-messagebox inputstr 'crc16 = '
+messagebox inputstr 'CRC16 = '
 
 crc16file crc 'foo.bin'
 if result = -1 then
-    messagebox 'file open error' 'crc16 = '
+    messagebox 'file open error' 'CRC16 = '
 else
     sprintf '0x%08X' crc
-    messagebox inputstr 'crc16 = '
+    messagebox inputstr 'CRC16 = '
 endif
 </pre>
 

Modified: branches/4-stable/doc/en/html/macro/command/crc32.html
===================================================================
--- branches/4-stable/doc/en/html/macro/command/crc32.html	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/doc/en/html/macro/command/crc32.html	2020-08-04 14:22:58 UTC (rev 8868)
@@ -39,10 +39,10 @@
 This algorithm is often used as the Ethernet FCS(Frame Check Sequence).
 <pre>
 <code>
-#define CRCPOLY2 0xEDB88320UL  /* left-right reversal */
-
-static unsigned long crc2(int n, unsigned char c[])
+static unsigned long crc32(int n, unsigned char c[])
 {
+#define CRC32POLY1 0x04C11DB7UL
+#define CRC32POLY2 0xEDB88320UL  /* left-right reversal */
 	int i, j;
 	unsigned long r;
 
@@ -50,7 +50,7 @@
 	for (i = 0; i < n; i++) {
 		r ^= c[i];
 		for (j = 0; j < CHAR_BIT; j++)
-			if (r & 1) r = (r >> 1) ^ CRCPOLY2;
+			if (r & 1) r = (r >> 1) ^ CRC32POLY2;
 			else       r >>= 1;
 	}
 	return r ^ 0xFFFFFFFFUL;

Modified: branches/4-stable/doc/ja/html/macro/command/crc16.html
===================================================================
--- branches/4-stable/doc/ja/html/macro/command/crc16.html	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/doc/ja/html/macro/command/crc16.html	2020-08-04 14:22:58 UTC (rev 8868)
@@ -14,7 +14,7 @@
 <h1>crc16, crc16file</h1>
 
 <p>
-CRC-16-IBM\x82\xF0\x8Cv\x8EZ\x82\xB7\x82\xE9\x81B
+CRC-16-CCITT\x82\xF0\x8Cv\x8EZ\x82\xB7\x82\xE9\x81B
 </p>
 
 <pre class="macro-syntax">
@@ -28,7 +28,7 @@
 \x88\xF8\x90\x94\x82̕\xB6\x8E\x9A\x97񂨂\xE6\x82уt\x83@\x83C\x83\x8B\x82\xA9\x82\xE7CRC(Cyclic Redundancy Checking)\x82\xF0\x8Cv\x8EZ\x82\xB7\x82\xE9\x81B\x91\xBD\x8D\x80\x8E\xAE\x81i\x89E\x89\xF1\x82\xE8\x81j\x82͈ȉ\xBA\x82̂Ƃ\xA8\x82\xE8\x81B
 <br><br>
 
-0xA001 (x<sup>16</sup>+x<sup>15</sup>+x<sup>2</sup>+x<sup>0</sup>)
+10001000000100001 (x<sup>16</sup>+x<sup>12</sup>+x<sup>5</sup>+x<sup>0</sup>)
 <br><br>
 
 \x8Cv\x8EZ\x8C\x8B\x89ʂ\xCD intvar \x95ϐ\x94\x82ɐ\x94\x92l\x82Ƃ\xB5\x82Ċi\x94[\x82\xB3\x82\xEA\x82\xE9\x81B<br>
@@ -40,8 +40,8 @@
 <code>
 static unsigned int crc16(int n, unsigned char c[])
 {
+#define CRC16POLY1  0x1021U
 #define CRC16POLY2  0x8408U  /* \x8D\xB6\x89E\x8Bt\x93] */
-
 	int i, j;
 	unsigned long r;
 

Modified: branches/4-stable/doc/ja/html/macro/command/crc32.html
===================================================================
--- branches/4-stable/doc/ja/html/macro/command/crc32.html	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/doc/ja/html/macro/command/crc32.html	2020-08-04 14:22:58 UTC (rev 8868)
@@ -38,10 +38,10 @@
 CRC\x83A\x83\x8B\x83S\x83\x8A\x83Y\x83\x80\x82̎\xC0\x91\x95\x81iC\x8C\xBE\x8C\xEA\x81j\x82\xF0\x88ȉ\xBA\x82Ɏ\xA6\x82\xB7\x81B\x82\xB1\x82̃A\x83\x8B\x83S\x83\x8A\x83Y\x83\x80\x82́AEthernet\x82\xCCFCS(Frame Check Sequence)\x82ɓK\x97p\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x81B
 <pre>
 <code>
-#define CRCPOLY2 0xEDB88320UL  /* \x8D\xB6\x89E\x8Bt\x93] */
-
-static unsigned long crc2(int n, unsigned char c[])
+static unsigned long crc32(int n, unsigned char c[])
 {
+#define CRC32POLY1 0x04C11DB7UL
+#define CRC32POLY2 0xEDB88320UL  /* \x8D\xB6\x89E\x8Bt\x93] */
 	int i, j;
 	unsigned long r;
 
@@ -49,7 +49,7 @@
 	for (i = 0; i < n; i++) {
 		r ^= c[i];
 		for (j = 0; j < CHAR_BIT; j++)
-			if (r & 1) r = (r >> 1) ^ CRCPOLY2;
+			if (r & 1) r = (r >> 1) ^ CRC32POLY2;
 			else       r >>= 1;
 	}
 	return r ^ 0xFFFFFFFFUL;

Index: branches/4-stable/teraterm
===================================================================
--- branches/4-stable/teraterm	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/teraterm	2020-08-04 14:22:58 UTC (rev 8868)

Property changes on: branches/4-stable/teraterm
___________________________________________________________________
Modified: svn:mergeinfo
## -3,4 +3,5 ##
 /branches/openssl_1_1_1_v2/teraterm:7819-7822,7829,7832-7834,7838-7843,7846-7847,7855-7856,7858,7861-7863,7979-7980
 /branches/openssl_1_1_1_v3/teraterm:8258
 /branches/serial_port_improved/teraterm:8119,8140-8141,8144,8150,8158-8160,8163,8170,8172,8183,8185,8204,8209,8212-8215
-/branches/vs2015_warn/teraterm:6194-6285
\ No newline at end of property
+/branches/vs2015_warn/teraterm:6194-6285
+/trunk/teraterm:8867
\ No newline at end of property
Modified: branches/4-stable/teraterm/ttpmacro/ttl.c
===================================================================
--- branches/4-stable/teraterm/ttpmacro/ttl.c	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/teraterm/ttpmacro/ttl.c	2020-08-04 14:22:58 UTC (rev 8868)
@@ -810,7 +810,7 @@
 static unsigned long crc32(int n, unsigned char c[])
 {
 #define CRC32POLY1 0x04C11DB7UL
-	/* x^{32}+x^{26}+x^{23}+x^{22}+x^{16}+x^{12}+x^{11]+
+	/* x^{32}+x^{26}+x^{23}+x^{22}+x^{16}+x^{12}+x^{11}+
 	   x^{10}+x^8+x^7+x^5+x^4+x^2+x^1+1 */
 #define CRC32POLY2 0xEDB88320UL  /* \x8D\xB6\x89E\x8Bt\x93] */
 	int i, j;

Index: branches/4-stable/ttpmenu
===================================================================
--- branches/4-stable/ttpmenu	2020-08-04 14:13:46 UTC (rev 8867)
+++ branches/4-stable/ttpmenu	2020-08-04 14:22:58 UTC (rev 8868)

Property changes on: branches/4-stable/ttpmenu
___________________________________________________________________
Modified: svn:mergeinfo
## -1 +1,2 ##
-/branches/vs2015_warn/ttpmenu:6194-6285
\ No newline at end of property
+/branches/vs2015_warn/ttpmenu:6194-6285
+/trunk/ttpmenu:8867
\ No newline at end of property


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