* minor size optimizations in chario.c, dosfns.c;
asmsupt.asm: correct fmemchr (all n's) and *memset/*memcpy (n==0) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@590 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
439cc495e4
commit
5210965831
@ -119,6 +119,7 @@ domemcpy:
|
||||
; And do the built-in byte copy, but do a 16-bit transfer
|
||||
; whenever possible.
|
||||
shr cx,1
|
||||
jcxz memcpy_return
|
||||
rep movsw
|
||||
jnc memcpy_return
|
||||
movsb
|
||||
@ -183,6 +184,7 @@ domemset:
|
||||
mov ah, al
|
||||
|
||||
shr cx,1
|
||||
jcxz pascal_return
|
||||
rep stosw
|
||||
jnc pascal_return
|
||||
stosb
|
||||
@ -391,11 +393,11 @@ FMEMCHR:
|
||||
|
||||
mov bl, 8
|
||||
|
||||
jcxz strchr_retzero
|
||||
repne scasb
|
||||
jne strchr_retzero
|
||||
mov dx, es
|
||||
mov ax, di
|
||||
dec ax
|
||||
jmp short strchr_found1
|
||||
|
||||
;**********************************************************************
|
||||
|
@ -218,6 +218,7 @@ STATIC int raw_put_char(int sft_idx, int c)
|
||||
STATIC int cooked_put_char(int sft_idx, int c)
|
||||
{
|
||||
int err = 0;
|
||||
unsigned char scrpos = scr_pos;
|
||||
|
||||
/* Test for hold char */
|
||||
con_hold(sft_idx);
|
||||
@ -225,23 +226,24 @@ STATIC int cooked_put_char(int sft_idx, int c)
|
||||
switch (c)
|
||||
{
|
||||
case CR:
|
||||
scr_pos = 0;
|
||||
scrpos = 0;
|
||||
break;
|
||||
case LF:
|
||||
case BELL:
|
||||
break;
|
||||
case BS:
|
||||
if (scr_pos > 0)
|
||||
scr_pos--;
|
||||
if (scrpos > 0)
|
||||
scrpos--;
|
||||
break;
|
||||
case HT:
|
||||
do
|
||||
err = raw_put_char(sft_idx, ' ');
|
||||
while (err >= 0 && ((++scr_pos) & 7));
|
||||
while (err >= 0 && ((++scrpos) & 7));
|
||||
break;
|
||||
default:
|
||||
scr_pos++;
|
||||
scrpos++;
|
||||
}
|
||||
scr_pos = scrpos;
|
||||
if (c != HT)
|
||||
err = raw_put_char(sft_idx, c);
|
||||
return err;
|
||||
|
@ -239,23 +239,25 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode)
|
||||
{
|
||||
size_t cnt = (size_t)rc;
|
||||
const char FAR *p = bp;
|
||||
unsigned char scrpos = scr_pos;
|
||||
while (cnt--)
|
||||
{
|
||||
switch (*p++)
|
||||
{
|
||||
case CR:
|
||||
scr_pos = 0;
|
||||
scrpos = 0;
|
||||
break;
|
||||
case LF:
|
||||
case BELL:
|
||||
break;
|
||||
case BS:
|
||||
--scr_pos;
|
||||
--scrpos;
|
||||
break;
|
||||
default:
|
||||
++scr_pos;
|
||||
++scrpos;
|
||||
}
|
||||
}
|
||||
scr_pos = scrpos;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@ -398,14 +400,9 @@ ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode)
|
||||
STATIC long get_free_hndl(void)
|
||||
{
|
||||
psp FAR *p = MK_FP(cu_psp, 0);
|
||||
unsigned hndl;
|
||||
|
||||
for (hndl = 0; hndl < p->ps_maxfiles; hndl++)
|
||||
{
|
||||
if (p->ps_filetab[hndl] == 0xff)
|
||||
return hndl;
|
||||
}
|
||||
return DE_TOOMANY;
|
||||
UBYTE FAR *q = p->ps_filetab;
|
||||
UBYTE FAR *r = fmemchr(q, 0xff, p->ps_maxfiles);
|
||||
return FP_OFF(r) == 0 ? DE_TOOMANY : r - q;
|
||||
}
|
||||
|
||||
STATIC sft FAR *get_free_sft(COUNT * sft_idx)
|
||||
@ -442,18 +439,19 @@ STATIC sft FAR *get_free_sft(COUNT * sft_idx)
|
||||
const char FAR *get_root(const char FAR * fname)
|
||||
{
|
||||
/* find the end */
|
||||
register unsigned length = fstrlen(fname) - 1;
|
||||
register unsigned length = fstrlen(fname);
|
||||
char c;
|
||||
|
||||
/* now back up to first path seperator or start */
|
||||
while (length != (unsigned)-1)
|
||||
fname += length;
|
||||
while (length)
|
||||
{
|
||||
c = fname[length];
|
||||
length--;
|
||||
c = *--fname;
|
||||
if (c == '/' || c == '\\' || c == ':')
|
||||
break;
|
||||
--length;
|
||||
}
|
||||
return fname + length + 1;
|
||||
return fname;
|
||||
}
|
||||
|
||||
/* initialize SFT fields (for open/creat) for character devices */
|
||||
|
Loading…
Reference in New Issue
Block a user