From b7491eba32da1dc11781a56d7457e42d94b2aa5c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 27 Jan 2004 19:26:58 +0000 Subject: [PATCH] Expand tabs for int21/ah=2,9 even in raw device modes and if stdout is redirected. This solves bug 1737 (grep2msg problem) This copy&paste exercise is to be cleaned up a bit later! git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@759 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 28 +++++++++++++++++++++++++++- kernel/inthndlr.c | 11 +++++------ 2 files changed, 32 insertions(+), 7 deletions(-) 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;