• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

This is a slow ctype library for sjis characters. 高速ではない シフトジス用の ctype 文字類識別ライブラリです。


Commit MetaInfo

Révision7ee41ca246cb6a1028b6e02f416708e5861ce91a (tree)
l'heure2014-01-03 14:48:47
AuteurJoel Matthew Rees <reiisi@user...>
CommiterJoel Matthew Rees

Message de Log

Now we have some shift JIS hexdump

Change Summary

Modification

--- a/sjhexdump.c
+++ b/sjhexdump.c
@@ -11,6 +11,9 @@
1111 #include <ctype.h>
1212
1313
14+#include "slowsjctype.h"
15+
16+
1417 #define DEFAULTWIDTH 16
1518
1619 #define READSIZE 128
@@ -25,11 +28,11 @@ char hexbuff[ BUFFSIZE * 3 ];
2528
2629 int formatHexByte( int byte, char * target )
2730 {
28- char out = (char) ( ( byte & 0xf0 ) >> 4 );
31+ char outch = (char) ( ( byte & 0xf0 ) >> 4 );
2932
30- * target++ = TOHEX( out );
31- out = (char) ( byte & 0x0f );
32- * target++ = TOHEX( out );
33+ * target++ = TOHEX( outch );
34+ outch = (char) ( byte & 0x0f );
35+ * target++ = TOHEX( outch );
3336 * target++ = ' ';
3437 return 3;
3538 }
@@ -42,6 +45,7 @@ int main( int argc, char * argv[] )
4245 int column = 0;
4346 int columnLimit = DEFAULTWIDTH;
4447 int hexcolumn = 0;
48+ int offset = 0;
4549 int ch;
4650
4751 if ( argc > 1 )
@@ -56,13 +60,36 @@ int main( int argc, char * argv[] )
5660 do
5761 {
5862 if ( ( ch = fgetc( in ) ) != EOF )
59- { hexcolumn += formatHexByte( ch, hexbuff + hexcolumn );
60- chbuff[ column ] = (char) ( isprint( ch ) ? ch : '.' );
61- ++column;
63+ {
64+ hexcolumn += formatHexByte( ch, hexbuff + hexcolumn );
65+ chbuff[ column++ ] = (char) ch;
6266 }
6367 if ( ( column >= columnLimit ) || ( ch == EOF ) )
6468 {
65- hexbuff[ hexcolumn ] = chbuff[ column ] = '\0';
69+ int scan;
70+ hexbuff[ hexcolumn ] = '\0'; /* 念のため、ここ */
71+ chbuff[ column ] = '\0';
72+ /* 表示のための置き換え */
73+ for ( scan = offset; scan < columnLimit; ++scan )
74+ {
75+ if ( slowsjIsPOneByte( &chbuff[ scan ] ) )
76+ {
77+ if ( !isprint( chbuff[ scan ] ) )
78+ {
79+ chbuff[ scan ] = '.';
80+ }
81+ }
82+ else if ( slowsjIsP2Byte( &chbuff[ scan ] ) )
83+ {
84+ ++scan;
85+ }
86+ else
87+ {
88+ chbuff[ scan ] = '.';
89+ }
90+ }
91+ /* 最後のバイトがしつこい。 */
92+ /* 置き換え完了 */
6693 printf( "0x%08x: %*s %*s\n",
6794 address,
6895 -columnLimit * 3, hexbuff,