Inline cooked_write_char() into cooked_write().

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1413 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2009-06-01 13:41:03 +00:00
parent c14e9df8bb
commit eb318177c1

View File

@ -176,65 +176,46 @@ void update_scr_pos(unsigned char c, unsigned char count)
STATIC int raw_get_char(struct dhdr FAR **pdev, BOOL check_break); STATIC int raw_get_char(struct dhdr FAR **pdev, BOOL check_break);
/* writes a character in cooked mode; maybe with printer echo;
handles TAB expansion */
STATIC int cooked_write_char(struct dhdr FAR **pdev,
unsigned char c,
unsigned char *fast_counter)
{
unsigned char count = 1;
if (c == HT) {
count = 8 - (scr_pos & 7);
c = ' ';
}
update_scr_pos(c, count);
do {
/* if not fast then < 0x80; always check
otherwise check every 32 characters */
if (*fast_counter <= 0x80 && check_handle_break(pdev) == CTL_S)
/* Test for hold char and ctl_c */
raw_get_char(pdev, TRUE);
*fast_counter += 1;
*fast_counter &= 0x9f;
if (PrinterEcho)
DosWrite(STDPRN, 1, &c);
if (*fast_counter & 0x80)
{
fast_put_char(c);
}
else
{
int err = CharIO(pdev, c, C_OUTPUT);
if (err < 0)
return err;
}
} while (--count != 0);
return SUCCESS;
}
long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp) long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp)
{ {
size_t xfer = 0; size_t xfer;
unsigned char fast_counter;
/* bit 7 means fastcon; low 5 bits count number of characters */ /* bit 7 means fastcon; low 5 bits count number of characters */
fast_counter = ((*pdev)->dh_attr & ATTR_FASTCON) << 3; unsigned char fast_counter = ((*pdev)->dh_attr & ATTR_FASTCON) << 3;
for (xfer = 0; xfer < n; xfer++) for (xfer = 0; xfer < n; xfer++)
{ {
int err; int err;
unsigned char c = *bp++; unsigned char count = 1, c = *bp++;
if (c == CTL_Z) if (c == CTL_Z)
break; break;
err = cooked_write_char(pdev, c, &fast_counter); /* write a character in cooked mode; maybe with printer echo;
if (err < 0) handles TAB expansion */
return err; if (c == HT) {
count = 8 - (scr_pos & 7);
c = ' ';
}
update_scr_pos(c, count);
do {
/* if not fast then < 0x80; always check
otherwise check every 32 characters */
if (fast_counter <= 0x80 && check_handle_break(pdev) == CTL_S)
raw_get_char(pdev, TRUE); /* Test for hold char and ctl_c */
fast_counter++;
fast_counter &= 0x9f;
if (PrinterEcho)
DosWrite(STDPRN, 1, &c);
if (fast_counter & 0x80)
fast_put_char(c);
else
{
err = CharIO(pdev, c, C_OUTPUT);
if (err < 0)
return err;
}
} while (--count != 0);
} }
return xfer; return xfer;
} }