summaryrefslogtreecommitdiff
path: root/src/dd.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-05-06 18:38:09 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-05-06 18:38:46 -0700
commit3974c0932df8281f4e0fa34c36c07a9d72f1155d (patch)
tree11ac3df3d1ed48724732d1cf747ae61d05236c3c /src/dd.c
parent8840a00cd79b8beae72b1a0ec6b9e64912633c13 (diff)
downloadcoreutils-3974c0932df8281f4e0fa34c36c07a9d72f1155d.tar.xz
dd: fix conv=ascii, conv=ebcdic, conv=ibm to match POSIX
Problem reported by Don Baggett in <http:/bugs.gnu.org/17422>. * NEWS: * doc/coreutils.texi (dd invocation): Document this. * src/dd.c (conversions): conv=ascii implies conv=unblock. conv=ebcdic and conv=ibm imply conv=block. (ascii_to_ebcdic, ebcdic_to_ascii): Correct to match POSIX 1003.1-2013. * tests/dd/ascii.sh: New file. * tests/local.mk (all_tests): Add it.
Diffstat (limited to 'src/dd.c')
-rw-r--r--src/dd.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/dd.c b/src/dd.c
index c7909e725..1e387f3d8 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -274,9 +274,9 @@ struct symbol_value
/* Conversion symbols, for conv="...". */
static struct symbol_value const conversions[] =
{
- {"ascii", C_ASCII | C_TWOBUFS}, /* EBCDIC to ASCII. */
- {"ebcdic", C_EBCDIC | C_TWOBUFS}, /* ASCII to EBCDIC. */
- {"ibm", C_IBM | C_TWOBUFS}, /* Slightly different ASCII to EBCDIC. */
+ {"ascii", C_ASCII | C_UNBLOCK | C_TWOBUFS}, /* EBCDIC to ASCII. */
+ {"ebcdic", C_EBCDIC | C_BLOCK | C_TWOBUFS}, /* ASCII to EBCDIC. */
+ {"ibm", C_IBM | C_BLOCK | C_TWOBUFS}, /* Different ASCII to EBCDIC. */
{"block", C_BLOCK | C_TWOBUFS}, /* Variable to fixed length records. */
{"unblock", C_UNBLOCK | C_TWOBUFS}, /* Fixed to variable length records. */
{"lcase", C_LCASE | C_TWOBUFS}, /* Translate upper to lower case. */
@@ -381,24 +381,29 @@ static struct symbol_value const statuses[] =
/* Translation table formed by applying successive transformations. */
static unsigned char trans_table[256];
+/* Standard translation tables, taken from POSIX 1003.1-2013.
+ Beware of imitations; there are lots of ASCII<->EBCDIC tables
+ floating around the net, perhaps valid for some applications but
+ not correct here. */
+
static char const ascii_to_ebcdic[] =
{
'\000', '\001', '\002', '\003', '\067', '\055', '\056', '\057',
'\026', '\005', '\045', '\013', '\014', '\015', '\016', '\017',
'\020', '\021', '\022', '\023', '\074', '\075', '\062', '\046',
'\030', '\031', '\077', '\047', '\034', '\035', '\036', '\037',
- '\100', '\117', '\177', '\173', '\133', '\154', '\120', '\175',
+ '\100', '\132', '\177', '\173', '\133', '\154', '\120', '\175',
'\115', '\135', '\134', '\116', '\153', '\140', '\113', '\141',
'\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
'\370', '\371', '\172', '\136', '\114', '\176', '\156', '\157',
'\174', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
'\310', '\311', '\321', '\322', '\323', '\324', '\325', '\326',
'\327', '\330', '\331', '\342', '\343', '\344', '\345', '\346',
- '\347', '\350', '\351', '\112', '\340', '\132', '\137', '\155',
+ '\347', '\350', '\351', '\255', '\340', '\275', '\232', '\155',
'\171', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
'\210', '\211', '\221', '\222', '\223', '\224', '\225', '\226',
'\227', '\230', '\231', '\242', '\243', '\244', '\245', '\246',
- '\247', '\250', '\251', '\300', '\152', '\320', '\241', '\007',
+ '\247', '\250', '\251', '\300', '\117', '\320', '\137', '\007',
'\040', '\041', '\042', '\043', '\044', '\025', '\006', '\027',
'\050', '\051', '\052', '\053', '\054', '\011', '\012', '\033',
'\060', '\061', '\032', '\063', '\064', '\065', '\066', '\010',
@@ -408,10 +413,10 @@ static char const ascii_to_ebcdic[] =
'\130', '\131', '\142', '\143', '\144', '\145', '\146', '\147',
'\150', '\151', '\160', '\161', '\162', '\163', '\164', '\165',
'\166', '\167', '\170', '\200', '\212', '\213', '\214', '\215',
- '\216', '\217', '\220', '\232', '\233', '\234', '\235', '\236',
- '\237', '\240', '\252', '\253', '\254', '\255', '\256', '\257',
+ '\216', '\217', '\220', '\152', '\233', '\234', '\235', '\236',
+ '\237', '\240', '\252', '\253', '\254', '\112', '\256', '\257',
'\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
+ '\270', '\271', '\272', '\273', '\274', '\241', '\276', '\277',
'\312', '\313', '\314', '\315', '\316', '\317', '\332', '\333',
'\334', '\335', '\336', '\337', '\352', '\353', '\354', '\355',
'\356', '\357', '\372', '\373', '\374', '\375', '\376', '\377'
@@ -464,21 +469,21 @@ static char const ebcdic_to_ascii[] =
'\220', '\221', '\026', '\223', '\224', '\225', '\226', '\004',
'\230', '\231', '\232', '\233', '\024', '\025', '\236', '\032',
'\040', '\240', '\241', '\242', '\243', '\244', '\245', '\246',
- '\247', '\250', '\133', '\056', '\074', '\050', '\053', '\041',
+ '\247', '\250', '\325', '\056', '\074', '\050', '\053', '\174',
'\046', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\135', '\044', '\052', '\051', '\073', '\136',
+ '\260', '\261', '\041', '\044', '\052', '\051', '\073', '\176',
'\055', '\057', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\174', '\054', '\045', '\137', '\076', '\077',
+ '\270', '\271', '\313', '\054', '\045', '\137', '\076', '\077',
'\272', '\273', '\274', '\275', '\276', '\277', '\300', '\301',
'\302', '\140', '\072', '\043', '\100', '\047', '\075', '\042',
'\303', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
'\150', '\151', '\304', '\305', '\306', '\307', '\310', '\311',
'\312', '\152', '\153', '\154', '\155', '\156', '\157', '\160',
- '\161', '\162', '\313', '\314', '\315', '\316', '\317', '\320',
- '\321', '\176', '\163', '\164', '\165', '\166', '\167', '\170',
- '\171', '\172', '\322', '\323', '\324', '\325', '\326', '\327',
+ '\161', '\162', '\136', '\314', '\315', '\316', '\317', '\320',
+ '\321', '\345', '\163', '\164', '\165', '\166', '\167', '\170',
+ '\171', '\172', '\322', '\323', '\324', '\133', '\326', '\327',
'\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
+ '\340', '\341', '\342', '\343', '\344', '\135', '\346', '\347',
'\173', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
'\110', '\111', '\350', '\351', '\352', '\353', '\354', '\355',
'\175', '\112', '\113', '\114', '\115', '\116', '\117', '\120',