Skip to content

Commit e7712ab

Browse files
authored
Merge pull request #35 from mvslovers/issue-34-fix-atoe-lf-to-nel
Fix IBM-1047 atoe: map ASCII LF (0x0A) to EBCDIC NEL (0x15)
2 parents d324f4d + 71b21b3 commit e7712ab

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/httpxlat.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,21 @@ static const unsigned char cp037_etoa[256] = {
145145
/* ------------------------------------------------------------------ */
146146
/* IBM Code Page 1047 (Latin-1 / Open Systems) */
147147
/* */
148-
/* Asymmetric NL/LF mapping (the well-known 1047 problem): */
149-
/* ASCII LF (0x0A) -> EBCDIC LF (0x25) */
150-
/* EBCDIC NEL(0x15) -> ASCII LF (0x0A) <- NB: NOT symmetric */
151-
/* EBCDIC LF (0x25) -> ASCII NEL (0x85) <- NB: NOT symmetric */
148+
/* NL/LF mapping — modified from pure IBM-1047: */
149+
/* ASCII LF (0x0A) -> EBCDIC NEL (0x15) <- override for ecosystem */
150+
/* EBCDIC NEL(0x15) -> ASCII LF (0x0A) <- symmetric roundtrip */
151+
/* EBCDIC LF (0x25) -> ASCII NEL (0x85) <- unchanged */
152152
/* */
153-
/* Tables from mvsMF (verified, in production). */
153+
/* Pure IBM-1047 maps ASCII LF to EBCDIC LF (0x25), but the */
154+
/* mvslovers ecosystem uses NEL (0x15) as newline: c2asm370 '\n', */
155+
/* crent370 printf, and all UFS files written by C programs emit */
156+
/* 0x15. This override makes atoe consistent with that convention. */
157+
/* z/OS USS applies the same override internally. */
154158
/* ------------------------------------------------------------------ */
155159

156160
static const unsigned char ibm1047_atoe[256] = {
157161
/* 0x00-0x07 */ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F,
158-
/* 0x08-0x0F */ 0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
162+
/* 0x08-0x0F */ 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
159163
/* 0x10-0x17 */ 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26,
160164
/* 0x18-0x1F */ 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F,
161165
/* 0x20-0x27 sp ! " # $ % & ' */

0 commit comments

Comments
 (0)