This commit is contained in:
@@ -42,6 +42,7 @@ public class FTDft {
|
||||
private boolean dftEof = false;
|
||||
private boolean messageFlag = false;
|
||||
private long bytesTransferred = 0;
|
||||
private int pendingByte = -1;
|
||||
|
||||
// Savebuf for Read Modified retransmit
|
||||
private byte[] dftSaveBuf = null;
|
||||
@@ -92,6 +93,7 @@ public class FTDft {
|
||||
dftSaveBuf = null;
|
||||
dftSaveBufLen = 0;
|
||||
lastCr = false;
|
||||
pendingByte = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,7 +405,7 @@ public class FTDft {
|
||||
|
||||
try {
|
||||
while (!dftEof && totalRead < numbytes) {
|
||||
if (config.isAscii() && (config.isRemapFlag() || config.isCrFlag())) {
|
||||
if (config.isAscii()) {
|
||||
int b = dftAsciiRead(config);
|
||||
if (b == -1) {
|
||||
dftEof = true;
|
||||
@@ -490,6 +492,12 @@ public class FTDft {
|
||||
* Matching x3270 dft_ascii_read logic.
|
||||
*/
|
||||
private int dftAsciiRead(FTConfig config) throws IOException {
|
||||
if (pendingByte != -1) {
|
||||
int b = pendingByte;
|
||||
pendingByte = -1;
|
||||
return b;
|
||||
}
|
||||
|
||||
if (inputStream == null) return -1;
|
||||
|
||||
int c = inputStream.read();
|
||||
@@ -497,15 +505,18 @@ public class FTDft {
|
||||
|
||||
if (config.isCrFlag() && !lastCr && c == '\n') {
|
||||
lastCr = false;
|
||||
// Expand \n to \r\n: return \r byte now
|
||||
int rEbc = translator.unicodeToEbcdic('\r');
|
||||
if (rEbc < 0) rEbc = 0x0D;
|
||||
return config.isRemapFlag() ? FT2ASC[rEbc & 0xFF] : rEbc;
|
||||
// Expand \n to \r\n: buffer \n in pendingByte, return \r now
|
||||
pendingByte = convertAsciiByte('\n', config);
|
||||
return convertAsciiByte('\r', config);
|
||||
}
|
||||
lastCr = (c == '\r');
|
||||
|
||||
return convertAsciiByte((char) c, config);
|
||||
}
|
||||
|
||||
private int convertAsciiByte(char c, FTConfig config) {
|
||||
if (!config.isRemapFlag()) {
|
||||
int ebc = translator.unicodeToEbcdic((char) c);
|
||||
int ebc = translator.unicodeToEbcdic(c);
|
||||
return ebc >= 0 ? ebc : 0x40;
|
||||
}
|
||||
|
||||
@@ -519,7 +530,7 @@ public class FTDft {
|
||||
} else if (c == 0x9F) {
|
||||
ebc = 0xFF;
|
||||
} else {
|
||||
ebc = translator.unicodeToEbcdic((char) c);
|
||||
ebc = translator.unicodeToEbcdic(c);
|
||||
}
|
||||
if (ebc < 0) ebc = 0x40;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user