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