This is a slow ctype library for sjis characters. 高速ではない シフトジス用の ctype 文字類識別ライブラリです。
Revision | b204e9d92a326dbb973d530c928cca6e96b3cb49 (tree) |
---|---|
Zeit | 2014-01-03 14:49:26 |
Autor | Joel Matthew Rees <reiisi@user...> |
Commiter | Joel Matthew Rees |
Improvemements to the shift JIS hexdump
@@ -70,25 +70,54 @@ int main( int argc, char * argv[] ) | ||
70 | 70 | hexbuff[ hexcolumn ] = '\0'; /* 念のため、ここ */ |
71 | 71 | chbuff[ column ] = '\0'; |
72 | 72 | /* 表示のための置き換え */ |
73 | - for ( scan = offset; scan < columnLimit; ++scan ) | |
73 | + for ( scan = 0; scan < column; ++scan ) | |
74 | 74 | { |
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 ] ) ) | |
76 | 81 | { |
77 | 82 | if ( !isprint( chbuff[ scan ] ) ) |
78 | 83 | { |
79 | 84 | chbuff[ scan ] = '.'; |
80 | 85 | } |
81 | 86 | } |
82 | - else if ( slowsjIsP2Byte( &chbuff[ scan ] ) ) | |
87 | + else if ( slowsjIsPHighByte( &chbuff[ scan ] ) ) | |
83 | 88 | { |
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 | + } | |
85 | 114 | } |
86 | 115 | else |
87 | 116 | { |
88 | 117 | chbuff[ scan ] = '.'; |
89 | 118 | } |
90 | 119 | } |
91 | - /* 最後のバイトがしつこい。 */ | |
120 | + /* 最後のバイトがしつこいかも知れません。 */ | |
92 | 121 | /* 置き換え完了 */ |
93 | 122 | printf( "0x%08x: %*s %*s\n", |
94 | 123 | address, |