• 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

Revision06d49b2c8b74fa86d461c88ed00c006286732b95 (tree)
Time2014-01-03 14:46:59
AuthorJoel Matthew Rees <reiisi@user...>
CommiterJoel Matthew Rees

Log Message

getting real close to ready for hexdump

Change Summary

Incremental Difference

--- a/sjhexdump.c
+++ b/sjhexdump.c
@@ -21,7 +21,7 @@ char chbuff[ BUFFSIZE ];
2121 char hexbuff[ BUFFSIZE * 3 ];
2222
2323
24-#define TOHEX( c ) ( (char) ( ( (c) <= 9 ) ? (c) + '0' : (c) + 'A' - 1 ) )
24+#define TOHEX( c ) ( (char) ( ( (c) <= 9 ) ? (c) + '0' : (c) + 'A' - 10 ) )
2525
2626 int formatHexByte( int byte, char * target )
2727 {
@@ -35,7 +35,7 @@ int formatHexByte( int byte, char * target )
3535 }
3636
3737
38-int main( void )
38+int main( int argc, char * argv[] )
3939 {
4040 FILE * in = stdin;
4141 unsigned long address = 0; /* 4ギガより小さいファイル。 */
@@ -44,6 +44,15 @@ int main( void )
4444 int hexcolumn = 0;
4545 int ch;
4646
47+ if ( argc > 1 )
48+ {
49+ in = fopen( argv[ 1 ], "rb" );
50+ if ( in == NULL )
51+ {
52+ return EXIT_FAILURE;
53+ }
54+ }
55+
4756 do
4857 {
4958 if ( ( ch = fgetc( in ) ) != EOF )
@@ -54,7 +63,10 @@ int main( void )
5463 if ( ( column >= columnLimit ) || ( ch == EOF ) )
5564 {
5665 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 );
5870 column = 0;
5971 hexcolumn = 0;
6072 address += columnLimit;