This is a slow ctype library for sjis characters. 高速ではない シフトジス用の ctype 文字類識別ライブラリです。
リビジョン | 06d49b2c8b74fa86d461c88ed00c006286732b95 (tree) |
---|---|
日時 | 2014-01-03 14:46:59 |
作者 | Joel Matthew Rees <reiisi@user...> |
コミッター | Joel Matthew Rees |
getting real close to ready for hexdump
@@ -21,7 +21,7 @@ char chbuff[ BUFFSIZE ]; | ||
21 | 21 | char hexbuff[ BUFFSIZE * 3 ]; |
22 | 22 | |
23 | 23 | |
24 | -#define TOHEX( c ) ( (char) ( ( (c) <= 9 ) ? (c) + '0' : (c) + 'A' - 1 ) ) | |
24 | +#define TOHEX( c ) ( (char) ( ( (c) <= 9 ) ? (c) + '0' : (c) + 'A' - 10 ) ) | |
25 | 25 | |
26 | 26 | int formatHexByte( int byte, char * target ) |
27 | 27 | { |
@@ -35,7 +35,7 @@ int formatHexByte( int byte, char * target ) | ||
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | -int main( void ) | |
38 | +int main( int argc, char * argv[] ) | |
39 | 39 | { |
40 | 40 | FILE * in = stdin; |
41 | 41 | unsigned long address = 0; /* 4ギガより小さいファイル。 */ |
@@ -44,6 +44,15 @@ int main( void ) | ||
44 | 44 | int hexcolumn = 0; |
45 | 45 | int ch; |
46 | 46 | |
47 | + if ( argc > 1 ) | |
48 | + { | |
49 | + in = fopen( argv[ 1 ], "rb" ); | |
50 | + if ( in == NULL ) | |
51 | + { | |
52 | + return EXIT_FAILURE; | |
53 | + } | |
54 | + } | |
55 | + | |
47 | 56 | do |
48 | 57 | { |
49 | 58 | if ( ( ch = fgetc( in ) ) != EOF ) |
@@ -54,7 +63,10 @@ int main( void ) | ||
54 | 63 | if ( ( column >= columnLimit ) || ( ch == EOF ) ) |
55 | 64 | { |
56 | 65 | hexbuff[ hexcolumn ] = chbuff[ column ] = '\0'; |
57 | - printf( "0x%08x: %s %s\n", address, hexbuff, chbuff ); | |
66 | + printf( "0x%08x: %*s %*s\n", | |
67 | + address, | |
68 | + -columnLimit * 3, hexbuff, | |
69 | + -columnLimit, chbuff ); | |
58 | 70 | column = 0; |
59 | 71 | hexcolumn = 0; |
60 | 72 | address += columnLimit; |