diff --git a/kernel/chario.c b/kernel/chario.c index 12b2e19..9864058 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -277,7 +277,33 @@ void write_char(int c, int sft_idx) void write_char_stdout(int c) { - write_char(c, get_sft_idx(STDOUT)); + unsigned char scrpos = scr_pos; + unsigned char count = 1; + unsigned flags = get_sft(STDOUT)->sft_flags & (SFT_FDEVICE | SFT_FBINARY); + + /* ah=2, ah=9 should expand tabs even for raw devices and disk files */ + if (flags != SFT_FDEVICE) + { + if (c == CR) + scrpos = 0; + else if (c == BS) { + if (scrpos > 0) + scrpos--; + } else if (c != LF && c != BELL) { + if (c == HT) { + count = 8 - (scrpos & 7); + c = ' '; + } + scrpos += count; + } + /* for raw devices already updated in dosfns.c */ + if (!(flags & SFT_FDEVICE)) + scr_pos = scrpos; + } + + do { + write_char(c, get_sft_idx(STDOUT)); + } while (--count != 0); } #define iscntrl(c) ((unsigned char)(c) < ' ') diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index e9e9cf8..97f7112 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -482,14 +482,13 @@ dispatch: /* Display String */ case 0x09: { - size_t count = 0; - char FAR *bp = FP_DS_DX; + unsigned char c; + unsigned char FAR *bp = FP_DS_DX; - while (bp[count] != '$') - count++; + while ((c = *bp++) != '$') + write_char_stdout(c); - DosWrite(STDOUT, count, bp); - lr.AL = '$'; + lr.AL = c; } break;