mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Completes refactor & clean-up. Implements full conv flag parsing.
- All conv flags now parsed (full functionality is TODO) - Changes functionality of eg. conv=ebcdic,ucase to match gnudd
This commit is contained in:
@@ -4,6 +4,45 @@
|
||||
// obtained by treating the ASCII representation as a number.
|
||||
pub type ConversionTable = [u8; 256];
|
||||
|
||||
pub const ASCII_UCASE_TO_LCASE: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
];
|
||||
|
||||
pub const ASCII_LCASE_TO_UCASE: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2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0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
|
||||
];
|
||||
|
||||
pub const ASCII_TO_EBCDIC: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
@@ -23,6 +62,44 @@ pub const ASCII_TO_EBCDIC: ConversionTable = [
|
||||
0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
];
|
||||
|
||||
pub const ASCII_TO_EBCDIC_UCASE_TO_LCASE: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
|
||||
0x7c, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xad, 0xe0, 0xbd, 0x9a, 0x6d,
|
||||
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0x5f, 0x07,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
|
||||
0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1,
|
||||
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
|
||||
0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x6a, 0x9b, 0x9c, 0x9d, 0x9e,
|
||||
0x9f, 0xa0, 0xaa, 0xab, 0xac, 0x4a, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xa1, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb,
|
||||
0xdc, 0xdd, 0x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a, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1,
|
||||
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
|
||||
0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x6a, 0x9b, 0x9c, 0x9d, 0x9e,
|
||||
0x9f, 0xa0, 0xaa, 0xab, 0xac, 0x4a, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xa1, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb,
|
||||
0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
];
|
||||
|
||||
pub const ASCII_TO_IBM: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
@@ -42,6 +119,45 @@ pub const ASCII_TO_IBM: ConversionTable = [
|
||||
0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
];
|
||||
|
||||
pub const ASCII_TO_IBM_UCASE_TO_LCASE: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
|
||||
0x7c, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d,
|
||||
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
|
||||
0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1,
|
||||
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
|
||||
0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e,
|
||||
0x9f, 0xa0, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb,
|
||||
0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
];
|
||||
|
||||
|
||||
pub const ASCII_TO_IBM_LCASE_TO_UCASE: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
|
||||
0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
|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fe, 0xff,
|
||||
];
|
||||
|
||||
pub const EBCDIC_TO_ASCII: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x9c, 0x09, 0x86, 0x7f, 0x97, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x9d, 0x85, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8f, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
@@ -61,79 +177,42 @@ pub const EBCDIC_TO_ASCII: ConversionTable = [
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
];
|
||||
|
||||
pub const ASCII_LCASE_TO_UCASE: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
|
||||
];
|
||||
|
||||
pub const ASCII_UCASE_TO_LCASE: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0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, 0x9a, 0x6d,
|
||||
0x79, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
|
||||
0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xc0, 0x4f, 0xd0, 0x5f, 0x07,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
|
||||
0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1,
|
||||
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
|
||||
0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x6a, 0x9b, 0x9c, 0x9d, 0x9e,
|
||||
0x9f, 0xa0, 0xaa, 0xab, 0xac, 0x4a, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xa1, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb,
|
||||
0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
];
|
||||
|
||||
pub const EBCDIC_UCASE_TO_LCASE: ConversionTable = [
|
||||
pub const EBCDIC_TO_ASCII_UCASE_TO_LCASE: ConversionTable = [
|
||||
0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, 0x16, 0x05, 0x25, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,
|
||||
0x7c, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xad, 0xe0, 0xbd, 0x9a, 0x6d,
|
||||
0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d,
|
||||
0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0x5f, 0x07,
|
||||
0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x1b,
|
||||
0x30, 0x31, 0x1a, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3a, 0x3b, 0x04, 0x14, 0x3e, 0xe1,
|
||||
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
|
||||
0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x6a, 0x9b, 0x9c, 0x9d, 0x9e,
|
||||
0x9f, 0xa0, 0xaa, 0xab, 0xac, 0x4a, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xa1, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb,
|
||||
0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e,
|
||||
0x9f, 0xa0, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb,
|
||||
0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
];
|
||||
|
||||
pub const EBCDIC_TO_ASCII_LCASE_TO_UCASE: ConversionTable = [
|
||||
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0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
|
||||
0x76, 0x77, 0x78, 0x80, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e,
|
||||
0x9f, 0xa0, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xda, 0xdb,
|
||||
0xdc, 0xdd, 0xde, 0xdf, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
];
|
||||
|
||||
|
||||
+73
-58
@@ -17,7 +17,6 @@ mod parseargs;
|
||||
mod conversion_tables;
|
||||
|
||||
use conversion_tables::*;
|
||||
use parseargs::*;
|
||||
|
||||
use std::error::Error;
|
||||
use std::fs::File;
|
||||
@@ -32,6 +31,8 @@ const SYNTAX: &str = "dd [OPERAND]...\ndd OPTION";
|
||||
const SUMMARY: &str = "convert, and optionally copy, a file";
|
||||
const LONG_HELP: &str = "";
|
||||
|
||||
const DEFAULT_FILL_BYTE: u8 = 0xDD;
|
||||
|
||||
const RTN_SUCCESS: i32 = 0;
|
||||
const RTN_FAILURE: i32 = 1;
|
||||
|
||||
@@ -42,6 +43,39 @@ enum SrcStat
|
||||
EOF,
|
||||
}
|
||||
|
||||
/// Captures all Conv Flags that apply to the input
|
||||
pub struct ConvFlagInput
|
||||
{
|
||||
ctable: Option<ConversionTable>,
|
||||
block: bool,
|
||||
unblock: bool,
|
||||
swab: bool,
|
||||
sync: bool,
|
||||
noerror: bool,
|
||||
}
|
||||
|
||||
/// Captures all Conv Flags that apply to the output
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ConvFlagOutput
|
||||
{
|
||||
sparse: bool,
|
||||
excl: bool,
|
||||
nocreat: bool,
|
||||
notrunc: bool,
|
||||
fdatasync: bool,
|
||||
fsync: bool,
|
||||
}
|
||||
|
||||
/// The value of the status cl-option.
|
||||
/// Controls printing of transfer stats
|
||||
#[derive(PartialEq)]
|
||||
pub enum StatusLevel
|
||||
{
|
||||
Progress,
|
||||
Noxfer,
|
||||
None,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum InternalError
|
||||
{
|
||||
@@ -62,13 +96,25 @@ struct Input<R: Read>
|
||||
{
|
||||
src: R,
|
||||
ibs: usize,
|
||||
xfer_stats: StatusLevel,
|
||||
cf: ConvFlagInput,
|
||||
}
|
||||
|
||||
impl<R: Read> Read for Input<R>
|
||||
{
|
||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize>
|
||||
fn read(&mut self, mut buf: &mut [u8]) -> io::Result<usize>
|
||||
{
|
||||
self.src.read(buf)
|
||||
let len = self.src.read(&mut buf)?;
|
||||
|
||||
if let Some(ct) = self.cf.ctable
|
||||
{
|
||||
for idx in 0..len
|
||||
{
|
||||
buf[idx] = ct[buf[idx] as usize];
|
||||
}
|
||||
}
|
||||
|
||||
Ok(len)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,12 +122,16 @@ impl Input<io::Stdin>
|
||||
{
|
||||
fn new(matches: &getopts::Matches) -> Result<Self, Box<dyn Error>>
|
||||
{
|
||||
let ibs: usize = parseargs::parse_ibs(matches)?;
|
||||
let ibs = parseargs::parse_ibs(matches)?;
|
||||
let xfer_stats = parseargs::parse_status_level(matches)?;
|
||||
let cf = parseargs::parse_conv_flag_input(matches)?;
|
||||
|
||||
Ok(
|
||||
Input {
|
||||
src: io::stdin(),
|
||||
ibs,
|
||||
xfer_stats,
|
||||
cf,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -92,13 +142,17 @@ impl Input<File>
|
||||
{
|
||||
fn new(matches: &getopts::Matches) -> Result<Self, Box<dyn Error>>
|
||||
{
|
||||
let ibs: usize = parseargs::parse_ibs(matches)?;
|
||||
let ibs = parseargs::parse_ibs(matches)?;
|
||||
let xfer_stats = parseargs::parse_status_level(matches)?;
|
||||
let cf = parseargs::parse_conv_flag_input(matches)?;
|
||||
|
||||
if let Some(fname) = matches.opt_str("if")
|
||||
{
|
||||
Ok(Input {
|
||||
src: File::open(fname)?,
|
||||
ibs,
|
||||
xfer_stats,
|
||||
cf,
|
||||
})
|
||||
}
|
||||
else
|
||||
@@ -139,17 +193,20 @@ struct Output<W: Write>
|
||||
{
|
||||
dst: W,
|
||||
obs: usize,
|
||||
cf: ConvFlagOutput,
|
||||
}
|
||||
|
||||
impl Output<io::Stdout> {
|
||||
fn new(matches: &getopts::Matches) -> Result<Self, Box<dyn Error>>
|
||||
{
|
||||
let obs: usize = parseargs::parse_obs(matches)?;
|
||||
let obs = parseargs::parse_obs(matches)?;
|
||||
let cf = parseargs::parse_conv_flag_output(matches)?;
|
||||
|
||||
Ok(
|
||||
Output {
|
||||
dst: io::stdout(),
|
||||
obs,
|
||||
cf,
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -158,13 +215,15 @@ impl Output<io::Stdout> {
|
||||
impl Output<File> {
|
||||
fn new(matches: &getopts::Matches) -> Result<Self, Box<dyn Error>>
|
||||
{
|
||||
let obs: usize = parseargs::parse_obs(matches)?;
|
||||
let obs = parseargs::parse_obs(matches)?;
|
||||
let cf = parseargs::parse_conv_flag_output(matches)?;
|
||||
|
||||
if let Some(fname) = matches.opt_str("if")
|
||||
{
|
||||
Ok(Output {
|
||||
dst: File::open(fname)?,
|
||||
obs,
|
||||
cf,
|
||||
})
|
||||
}
|
||||
else
|
||||
@@ -178,21 +237,7 @@ impl<W: Write> Write for Output<W>
|
||||
{
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize>
|
||||
{
|
||||
if let Some(ct) = self.conv_table
|
||||
{
|
||||
let mut cbuf = vec![0; buf.len()];
|
||||
|
||||
for (idx, byte) in buf.iter().enumerate()
|
||||
{
|
||||
cbuf[idx] = ct[*byte as usize]
|
||||
}
|
||||
|
||||
self.dst.write(&cbuf)
|
||||
}
|
||||
else
|
||||
{
|
||||
self.dst.write(buf)
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()>
|
||||
@@ -201,33 +246,6 @@ impl<W: Write> Write for Output<W>
|
||||
}
|
||||
}
|
||||
|
||||
struct Options
|
||||
{
|
||||
conv: Option<ConversionOptions>,
|
||||
status_level: StatusLevel,
|
||||
// ...
|
||||
}
|
||||
|
||||
struct ConversionOptions
|
||||
{
|
||||
table: Option<ConversionTable>,
|
||||
block: bool,
|
||||
unblock: bool,
|
||||
lcase: bool,
|
||||
ucase: bool,
|
||||
sparse: bool,
|
||||
swab: bool,
|
||||
sync: bool,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum StatusLevel
|
||||
{
|
||||
Progress,
|
||||
Noxfer,
|
||||
None,
|
||||
}
|
||||
|
||||
fn gen_prog_updater(rx: mpsc::Receiver<usize>) -> impl Fn() -> ()
|
||||
{
|
||||
move || {
|
||||
@@ -251,9 +269,9 @@ fn gen_prog_updater(rx: mpsc::Receiver<usize>) -> impl Fn() -> ()
|
||||
}
|
||||
}
|
||||
|
||||
fn dd<R: Read, W: Write>(mut i: Input<R>, mut o: Output<W>, opts: Options) -> Result<(usize, usize), Box<dyn Error>>
|
||||
fn dd<R: Read, W: Write>(mut i: Input<R>, mut o: Output<W>) -> Result<(usize, usize), Box<dyn Error>>
|
||||
{
|
||||
let prog_tx = if opts.status_level == StatusLevel::Progress
|
||||
let prog_tx = if i.xfer_stats == StatusLevel::Progress
|
||||
{
|
||||
let (prog_tx, prog_rx) = mpsc::channel();
|
||||
|
||||
@@ -271,7 +289,7 @@ fn dd<R: Read, W: Write>(mut i: Input<R>, mut o: Output<W>, opts: Options) -> Re
|
||||
|
||||
loop
|
||||
{
|
||||
let mut buf = vec![0xDD; o.obs];
|
||||
let mut buf = vec![DEFAULT_FILL_BYTE; o.obs];
|
||||
let r_len =
|
||||
match i.fill_n(&mut buf, o.obs)? {
|
||||
SrcStat::Read(len) =>
|
||||
@@ -355,9 +373,6 @@ pub fn uumain(args: impl uucore::Args) -> i32
|
||||
|
||||
let matches = build_app!().parse(dashed_args);
|
||||
|
||||
let opts = parse_options(&matches)
|
||||
.expect("TODO: Return correct error code");
|
||||
|
||||
let result = match (matches.opt_present("if"), matches.opt_present("of"))
|
||||
{
|
||||
(true, true) =>
|
||||
@@ -367,7 +382,7 @@ pub fn uumain(args: impl uucore::Args) -> i32
|
||||
let o = Output::<File>::new(&matches)
|
||||
.expect("TODO: Return correct error code");
|
||||
|
||||
dd(i, o, opts)
|
||||
dd(i,o)
|
||||
},
|
||||
(true, false) =>
|
||||
{
|
||||
@@ -376,7 +391,7 @@ pub fn uumain(args: impl uucore::Args) -> i32
|
||||
let o = Output::<io::Stdout>::new(&matches)
|
||||
.expect("TODO: Return correct error code");
|
||||
|
||||
dd(i, o, opts)
|
||||
dd(i,o)
|
||||
},
|
||||
(false, true) =>
|
||||
{
|
||||
@@ -385,7 +400,7 @@ pub fn uumain(args: impl uucore::Args) -> i32
|
||||
let o = Output::<File>::new(&matches)
|
||||
.expect("TODO: Return correct error code");
|
||||
|
||||
dd(i, o, opts)
|
||||
dd(i,o)
|
||||
},
|
||||
(false, false) =>
|
||||
{
|
||||
@@ -394,7 +409,7 @@ pub fn uumain(args: impl uucore::Args) -> i32
|
||||
let o = Output::<io::Stdout>::new(&matches)
|
||||
.expect("TODO: Return correct error code");
|
||||
|
||||
dd(i, o, opts)
|
||||
dd(i,o)
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
+310
-163
File diff suppressed because it is too large
Load Diff
+156
-209
@@ -3,88 +3,51 @@ use super::*;
|
||||
use std::io::prelude::*;
|
||||
use std::io::BufReader;
|
||||
use std::fs;
|
||||
// use md5::{ Md5, Digest, };
|
||||
// use hex_literal::hex;
|
||||
use md5::{ Md5, Digest, };
|
||||
use hex_literal::hex;
|
||||
|
||||
// use tempfile::tempfile;
|
||||
// TODO: (Maybe) Use tempfiles in the tests.
|
||||
|
||||
//macro_rules! make_hash_test (
|
||||
// ( $test_id:ident, $test_name:expr, $src:expr, $exp:expr ) =>
|
||||
// {
|
||||
// #[test]
|
||||
// fn $test_id()
|
||||
// {
|
||||
// let tmp_fname = format!("./test-resources/FAILED-{}.test", $test_name);
|
||||
//
|
||||
// let i = Input {
|
||||
// src: $src,
|
||||
// ibs: 256,
|
||||
// output_progress: false,
|
||||
// };
|
||||
//
|
||||
// let o = Output {
|
||||
// dst: File::create(&tmp_fname).unwrap(),
|
||||
// obs: 1024,
|
||||
// conv_table: None,
|
||||
// };
|
||||
//
|
||||
// dd(i,o).unwrap();
|
||||
//
|
||||
// let res = {
|
||||
// let res = File::open(&tmp_fname).unwrap();
|
||||
// let res = BufReader::new(res);
|
||||
//
|
||||
// let mut h = Md5::new();
|
||||
// for b in res.bytes()
|
||||
// {
|
||||
// h.update([b.unwrap()]);
|
||||
// }
|
||||
//
|
||||
// h.finalize()
|
||||
// };
|
||||
//
|
||||
// assert_eq!(hex!($exp), res[..]);
|
||||
//
|
||||
// fs::remove_file(&tmp_fname).unwrap();
|
||||
// }
|
||||
// };
|
||||
// ( $test_id:ident, $test_name:expr, $i:expr, $o:expr, $exp:expr ) =>
|
||||
// {
|
||||
// #[test]
|
||||
// fn $test_id()
|
||||
// {
|
||||
// let tmp_fname = format!("./test-resources/FAILED-{}.test", $test_name);
|
||||
//
|
||||
// let o = Output {
|
||||
// dst: File::create(&tmp_fname).unwrap(),
|
||||
// obs: $o.obs,
|
||||
// };
|
||||
//
|
||||
// dd($i,o).unwrap();
|
||||
//
|
||||
// let res = {
|
||||
// let res = File::open(&tmp_fname).unwrap();
|
||||
// let res = BufReader::new(res);
|
||||
//
|
||||
// let mut h = Md5::new();
|
||||
// for b in res.bytes()
|
||||
// {
|
||||
// h.update([b.unwrap()]);
|
||||
// }
|
||||
//
|
||||
// h.finalize()
|
||||
// };
|
||||
//
|
||||
// assert_eq!(hex!($exp), res[..]);
|
||||
//
|
||||
// fs::remove_file(&tmp_fname).unwrap();
|
||||
// }
|
||||
// };
|
||||
//);
|
||||
const DEFAULT_CFO: ConvFlagOutput = ConvFlagOutput {
|
||||
sparse: false,
|
||||
excl: false,
|
||||
nocreat: false,
|
||||
notrunc: false,
|
||||
fdatasync: false,
|
||||
fsync: false,
|
||||
};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! cfi (
|
||||
() =>
|
||||
{
|
||||
cfi!(None)
|
||||
};
|
||||
( $ctable:expr ) =>
|
||||
{
|
||||
ConvFlagInput {
|
||||
ctable: $ctable,
|
||||
block: false,
|
||||
unblock: false,
|
||||
swab: false,
|
||||
sync: false,
|
||||
noerror: false,
|
||||
}
|
||||
};
|
||||
);
|
||||
|
||||
macro_rules! make_spec_test (
|
||||
( $test_id:ident, $test_name:expr, $src:expr ) =>
|
||||
{
|
||||
// When spec not given, output should match input
|
||||
make_spec_test!($test_id, $test_name, $src, None, $src);
|
||||
};
|
||||
( $test_id:ident, $test_name:expr, $src:expr, $spec:expr ) =>
|
||||
{
|
||||
make_spec_test!($test_id, $test_name, $src, None, $spec);
|
||||
};
|
||||
( $test_id:ident, $test_name:expr, $src:expr, $ctable:expr, $spec:expr ) =>
|
||||
{
|
||||
#[test]
|
||||
fn $test_id()
|
||||
@@ -94,70 +57,17 @@ macro_rules! make_spec_test (
|
||||
let i = Input {
|
||||
src: $src,
|
||||
ibs: 512,
|
||||
xfer_stats: StatusLevel::None,
|
||||
cf: cfi!($ctable),
|
||||
};
|
||||
|
||||
let o = Output {
|
||||
dst: File::create(&tmp_fname).unwrap(),
|
||||
obs: 512,
|
||||
cf: DEFAULT_CFO,
|
||||
};
|
||||
|
||||
let opts = Options {
|
||||
conv: Some(ConversionOptions {
|
||||
table: None,
|
||||
block: false,
|
||||
unblock: false,
|
||||
lcase: false,
|
||||
ucase: false,
|
||||
sparse: false,
|
||||
swab: false,
|
||||
sync: false,
|
||||
}),
|
||||
status_level: None,
|
||||
};
|
||||
|
||||
dd($i,o,opts).unwrap();
|
||||
|
||||
let res = File::open(&tmp_fname).unwrap();
|
||||
let res = BufReader::new(res);
|
||||
|
||||
let spec = BufReader::new($spec);
|
||||
|
||||
for (b_res, b_spec) in res.bytes().zip(spec.bytes())
|
||||
{
|
||||
assert_eq!(b_res.unwrap(),
|
||||
b_spec.unwrap());
|
||||
}
|
||||
|
||||
fs::remove_file(&tmp_fname).unwrap();
|
||||
}
|
||||
};
|
||||
( $test_id:ident, $test_name:expr, $i:expr, $o:expr, $conv:expr, $spec:expr ) =>
|
||||
{
|
||||
#[test]
|
||||
fn $test_id()
|
||||
{
|
||||
let tmp_fname = format!("./test-resources/FAILED-{}.test", $test_name);
|
||||
|
||||
let o = Output {
|
||||
dst: File::create(&tmp_fname).unwrap(),
|
||||
obs: $o.obs,
|
||||
};
|
||||
|
||||
let opts = Options {
|
||||
conv: Some(ConversionOptions {
|
||||
table: $conv,
|
||||
block: false,
|
||||
unblock: false,
|
||||
lcase: false,
|
||||
ucase: false,
|
||||
sparse: false,
|
||||
swab: false,
|
||||
sync: false,
|
||||
}),
|
||||
status_level: None,
|
||||
};
|
||||
|
||||
dd($i,o,opts).unwrap();
|
||||
dd(i,o).unwrap();
|
||||
|
||||
let res = File::open(&tmp_fname).unwrap();
|
||||
let res = BufReader::new(res);
|
||||
@@ -175,45 +85,56 @@ macro_rules! make_spec_test (
|
||||
};
|
||||
);
|
||||
|
||||
make_spec_test!(
|
||||
#[test]
|
||||
fn test_input_parser()
|
||||
{
|
||||
let args = vec![
|
||||
String::from("ketchup"),
|
||||
String::from("mustard"),
|
||||
String::from("--conv=ibm"),
|
||||
String::from("relish"),
|
||||
];
|
||||
|
||||
let matches = build_app!().parse(args);
|
||||
// ...
|
||||
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_output_parser()
|
||||
{
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
make_spec_test!(
|
||||
zeros_4k_test,
|
||||
"zeros-4k",
|
||||
File::open("./test-resources/zeros-620f0b67a91f7f74151bc5be745b7110.test").unwrap(),
|
||||
File::open("./test-resources/zeros-620f0b67a91f7f74151bc5be745b7110.test").unwrap()
|
||||
);
|
||||
|
||||
make_spec_test!(
|
||||
ones_4k_test,
|
||||
"ones-4k",
|
||||
File::open("./test-resources/ones-6ae59e64850377ee5470c854761551ea.test").unwrap(),
|
||||
File::open("./test-resources/ones-6ae59e64850377ee5470c854761551ea.test").unwrap()
|
||||
);
|
||||
|
||||
make_spec_test!(
|
||||
deadbeef_32k_test,
|
||||
"deadbeef-32k",
|
||||
File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap(),
|
||||
File::open("./test-resources/deadbeef-18d99661a1de1fc9af21b0ec2cd67ba3.test").unwrap()
|
||||
);
|
||||
|
||||
make_spec_test!(
|
||||
random_73k_test,
|
||||
"random-73k",
|
||||
File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap(),
|
||||
File::open("./test-resources/random-5828891cb1230748e146f34223bbd3b5.test").unwrap()
|
||||
);
|
||||
|
||||
make_spec_test!(
|
||||
atoe_conv_spec_test,
|
||||
"atoe-conv-spec-test",
|
||||
Input {
|
||||
src: File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
ibs: 512,
|
||||
},
|
||||
Output {
|
||||
dst: Vec::new(), // unused!
|
||||
obs: 512,
|
||||
},
|
||||
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
Some(ASCII_TO_EBCDIC),
|
||||
File::open("./test-resources/gnudd-conv-atoe-seq-byte-values.spec").unwrap()
|
||||
);
|
||||
@@ -221,14 +142,7 @@ make_spec_test!(
|
||||
make_spec_test!(
|
||||
etoa_conv_spec_test,
|
||||
"etoa-conv-spec-test",
|
||||
Input {
|
||||
src: File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
ibs: 512,
|
||||
},
|
||||
Output {
|
||||
dst: Vec::new(), // unused!
|
||||
obs: 512,
|
||||
},
|
||||
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
Some(EBCDIC_TO_ASCII),
|
||||
File::open("./test-resources/gnudd-conv-etoa-seq-byte-values.spec").unwrap()
|
||||
);
|
||||
@@ -236,14 +150,7 @@ make_spec_test!(
|
||||
make_spec_test!(
|
||||
atoibm_conv_spec_test,
|
||||
"atoibm-conv-spec-test",
|
||||
Input {
|
||||
src: File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
ibs: 512,
|
||||
},
|
||||
Output {
|
||||
dst: Vec::new(), // unused!
|
||||
obs: 512,
|
||||
},
|
||||
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
Some(ASCII_TO_IBM),
|
||||
File::open("./test-resources/gnudd-conv-atoibm-seq-byte-values.spec").unwrap()
|
||||
);
|
||||
@@ -251,33 +158,95 @@ make_spec_test!(
|
||||
make_spec_test!(
|
||||
lcase_ascii_to_ucase_ascii,
|
||||
"lcase_ascii_to_ucase_ascii",
|
||||
Input {
|
||||
src: File::open("./test-resources/lcase-ascii.test").unwrap(),
|
||||
ibs: 512,
|
||||
},
|
||||
Output {
|
||||
dst: Vec::new(), // unused!
|
||||
obs: 512,
|
||||
},
|
||||
Some(LCASE_TO_UCASE),
|
||||
File::open("./test-resources/lcase-ascii.test").unwrap(),
|
||||
Some(ASCII_LCASE_TO_UCASE),
|
||||
File::open("./test-resources/ucase-ascii.test").unwrap()
|
||||
);
|
||||
|
||||
make_spec_test!(
|
||||
ucase_ascii_to_lcase_ascii,
|
||||
"ucase_ascii_to_lcase_ascii",
|
||||
Input {
|
||||
src: File::open("./test-resources/ucase-ascii.test").unwrap(),
|
||||
ibs: 512,
|
||||
},
|
||||
Output {
|
||||
dst: Vec::new(), // unused!
|
||||
obs: 512,
|
||||
},
|
||||
Some(UCASE_TO_LCASE),
|
||||
File::open("./test-resources/ucase-ascii.test").unwrap(),
|
||||
Some(ASCII_UCASE_TO_LCASE),
|
||||
File::open("./test-resources/lcase-ascii.test").unwrap()
|
||||
);
|
||||
|
||||
// // ***
|
||||
// make_spec_test!(
|
||||
// lcase_ebcdic_to_ucase_ebcdic,
|
||||
// "lcase_ebcdic_to_ucase_ebcdic",
|
||||
// File::open("./test-resources/lcase-ebcdic.test").unwrap(),
|
||||
// None,
|
||||
// Some(EBCDIC_LCASE_TO_UCASE),
|
||||
// File::open("./test-resources/ucase-ebcdic.test").unwrap()
|
||||
// );
|
||||
//
|
||||
// // ***
|
||||
// make_spec_test!(
|
||||
// ucase_ebcdic_to_lcase_ebcdic,
|
||||
// "ucase_ebcdic_to_lcase_ebcdic",
|
||||
// File::open("./test-resources/ucase-ebcdic.test").unwrap(),
|
||||
// None,
|
||||
// Some(EBCDIC_UCASE_TO_LCASE),
|
||||
// File::open("./test-resources/lcase-ebcdic.test").unwrap()
|
||||
// );
|
||||
//
|
||||
// // ***
|
||||
// make_spec_test!(
|
||||
// lcase_ibm_to_ucase_ibm,
|
||||
// "lcase_ibm_to_ucase_ibm",
|
||||
// File::open("./test-resources/lcase-ibm.test").unwrap(),
|
||||
// None,
|
||||
// Some(IBM_LCASE_TO_UCASE),
|
||||
// File::open("./test-resources/ucase-ibm.test").unwrap()
|
||||
// );
|
||||
//
|
||||
// // ***
|
||||
// make_spec_test!(
|
||||
// ucase_ibm_to_lcase_ibm,
|
||||
// "ucase_ibm_to_lcase_ibm",
|
||||
// File::open("./test-resources/ucase-ibm.test").unwrap(),
|
||||
// None,
|
||||
// Some(IBM_UCASE_TO_LCASE),
|
||||
// File::open("./test-resources/lcase-ibm.test").unwrap()
|
||||
// );
|
||||
|
||||
make_spec_test!(
|
||||
// conv=ebcdic,ucase
|
||||
atoe_and_ucase_conv_spec_test,
|
||||
"atoe-and-ucase-conv-spec-test",
|
||||
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
Some(ASCII_TO_EBCDIC_LCASE_TO_UCASE),
|
||||
File::open("./test-resources/ucase-ebcdic.test").unwrap()
|
||||
);
|
||||
|
||||
make_spec_test!(
|
||||
// conv=ebcdic,lcase
|
||||
atoe_and_lcase_conv_spec_test,
|
||||
"atoe-and-lcase-conv-spec-test",
|
||||
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
Some(ASCII_TO_EBCDIC_UCASE_TO_LCASE),
|
||||
File::open("./test-resources/lcase-ebcdic.test").unwrap()
|
||||
);
|
||||
|
||||
make_spec_test!(
|
||||
// conv=ibm,ucase
|
||||
atoibm_and_ucase_conv_spec_test,
|
||||
"atoibm-and-ucase-conv-spec-test",
|
||||
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
Some(ASCII_TO_IBM_UCASE_TO_LCASE),
|
||||
File::open("./test-resources/lcase-ibm.test").unwrap()
|
||||
);
|
||||
|
||||
make_spec_test!(
|
||||
// conv=ibm,lcase
|
||||
atoibm_and_lcase_conv_spec_test,
|
||||
"atoibm-and-lcase-conv-spec-test",
|
||||
File::open("./test-resources/seq-byte-values-b632a992d3aed5d8d1a59cc5a5a455ba.test").unwrap(),
|
||||
Some(ASCII_TO_IBM_LCASE_TO_UCASE),
|
||||
File::open("./test-resources/ucase-ibm.test").unwrap()
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn all_valid_ascii_ebcdic_ascii_roundtrip_conv_test()
|
||||
{
|
||||
@@ -288,28 +257,17 @@ fn all_valid_ascii_ebcdic_ascii_roundtrip_conv_test()
|
||||
let i = Input {
|
||||
src: File::open("./test-resources/all-valid-ascii-chars-37eff01866ba3f538421b30b7cbefcac.test").unwrap(),
|
||||
ibs: 256,
|
||||
xfer_stats: StatusLevel::None,
|
||||
cf: cfi!(Some(ASCII_TO_EBCDIC)),
|
||||
};
|
||||
|
||||
let o = Output {
|
||||
dst: File::create(&tmp_fname_ae).unwrap(),
|
||||
obs: 1024,
|
||||
cf: DEFAULT_CFO,
|
||||
};
|
||||
|
||||
let opts = Options {
|
||||
conv: Some(ConversionOptions {
|
||||
table: Some(ASCII_TO_EBCDIC),
|
||||
block: false,
|
||||
unblock: false,
|
||||
lcase: false,
|
||||
ucase: false,
|
||||
sparse: false,
|
||||
swab: false,
|
||||
sync: false,
|
||||
}),
|
||||
status_level: None,
|
||||
};
|
||||
|
||||
dd(i,o,opts).unwrap();
|
||||
dd(i,o).unwrap();
|
||||
|
||||
// EBCDIC->ASCII
|
||||
let test_name = "all-valid-ebcdic-to-ascii";
|
||||
@@ -318,28 +276,17 @@ fn all_valid_ascii_ebcdic_ascii_roundtrip_conv_test()
|
||||
let i = Input {
|
||||
src: File::open(&tmp_fname_ae).unwrap(),
|
||||
ibs: 256,
|
||||
xfer_stats: StatusLevel::None,
|
||||
cf: cfi!(Some(EBCDIC_TO_ASCII)),
|
||||
};
|
||||
|
||||
let o = Output {
|
||||
dst: File::create(&tmp_fname_ea).unwrap(),
|
||||
obs: 1024,
|
||||
cf: DEFAULT_CFO,
|
||||
};
|
||||
|
||||
let opts = Options {
|
||||
conv: Some(ConversionOptions {
|
||||
table: Some(ASCII_TO_EBCDIC),
|
||||
block: false,
|
||||
unblock: false,
|
||||
lcase: false,
|
||||
ucase: false,
|
||||
sparse: false,
|
||||
swab: false,
|
||||
sync: false,
|
||||
}),
|
||||
status_level: None,
|
||||
};
|
||||
|
||||
dd(i,o,opts).unwrap();
|
||||
dd(i,o).unwrap();
|
||||
|
||||
let res = {
|
||||
let res = File::open(&tmp_fname_ea).unwrap();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user