• 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

Revisionb204e9d92a326dbb973d530c928cca6e96b3cb49 (tree)
Zeit2014-01-03 14:49:26
AutorJoel Matthew Rees <reiisi@user...>
CommiterJoel Matthew Rees

Log Message

Improvemements to the shift JIS hexdump

Ändern Zusammenfassung

Diff

--- a/sjhexdump.c
+++ b/sjhexdump.c
@@ -70,25 +70,54 @@ int main( int argc, char * argv[] )
7070 hexbuff[ hexcolumn ] = '\0'; /* 念のため、ここ */
7171 chbuff[ column ] = '\0';
7272 /* 表示のための置き換え */
73- for ( scan = offset; scan < columnLimit; ++scan )
73+ for ( scan = 0; scan < column; ++scan )
7474 {
75- if ( slowsjIsPOneByte( &chbuff[ scan ] ) )
75+ if ( ( scan == 0 ) && ( offset > 0 ) )
76+ {
77+ chbuff[ scan ] = '.'; /* 前の行の末尾 */
78+ offset = 0;
79+ }
80+ else if ( slowsjIsPOneByte( &chbuff[ scan ] ) )
7681 {
7782 if ( !isprint( chbuff[ scan ] ) )
7883 {
7984 chbuff[ scan ] = '.';
8085 }
8186 }
82- else if ( slowsjIsP2Byte( &chbuff[ scan ] ) )
87+ else if ( slowsjIsPHighByte( &chbuff[ scan ] ) )
8388 {
84- ++scan;
89+ if ( scan == column - 1 )
90+ {
91+ if ( ( ch = fgetc( in ) ) != EOF )
92+ {
93+ chbuff[ scan + 1 ] = (char) ch; /* 行の末尾 */
94+ ungetc( ch, in );
95+ chbuff[ scan + 2 ] = '\0';
96+ }
97+ }
98+ if ( slowsjIsP2Byte( &chbuff[ scan ] ) )
99+ {
100+ if ( scan < column - 1 )
101+ {
102+ ++scan;
103+ }
104+ else
105+ {
106+ offset = 1; /* 末尾在り */
107+ }
108+ }
109+ else
110+ {
111+ chbuff[ scan ] = '.';
112+ chbuff[ scan + 1 ] = '\0';
113+ }
85114 }
86115 else
87116 {
88117 chbuff[ scan ] = '.';
89118 }
90119 }
91- /* 最後のバイトがしつこい。 */
120+ /* 最後のバイトがしつこいかも知れません。 */
92121 /* 置き換え完了 */
93122 printf( "0x%08x: %*s %*s\n",
94123 address,