From 83f044fbe0cb45fd08438f328351d48c33196d4a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 6 Apr 2004 22:48:12 +0000 Subject: [PATCH] Use strchr and strlen more often; also use strchr in the init code. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@842 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 3 +-- kernel/config.c | 21 +++++++-------------- kernel/init-mod.h | 6 ++++-- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 77d304b..0edc43c 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -335,8 +335,6 @@ dostrlen: jmp short pascal_return -%ifndef _INIT - ;************************************************************ ; strchr (BYTE *src , int ch); @@ -369,6 +367,7 @@ strchr_found1: jmp short pascal_return +%ifndef _INIT ;***** ; fstrchr (BYTE far *src , int ch); diff --git a/kernel/config.c b/kernel/config.c index 0c5803f..8e284af 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -80,13 +80,10 @@ STATIC void WriteMenuLine(int MenuSelected) iregs r; unsigned char attr = (unsigned char)MenuColor; char *pText = MenuStruct[MenuSelected].Text; - size_t len = 0; if (pText[0] == 0) return; - do len++; while (pText[len]); - if(MenuStruct[MenuSelected].bSelected==1) attr = ((attr << 4) | (attr >> 4)); @@ -95,7 +92,7 @@ STATIC void WriteMenuLine(int MenuSelected) r.b.b.h = attr; r.c.b.l = r.d.b.l = MenuStruct[MenuSelected].x; r.c.b.h = r.d.b.h = MenuStruct[MenuSelected].y; - r.d.b.l += len - 1; + r.d.b.l += strlen(pText) - 1; init_call_intr(0x10, &r); /* set cursor position: */ @@ -952,15 +949,13 @@ STATIC VOID sysScreenMode(BYTE * pLine) STATIC VOID sysVersion(BYTE * pLine) { COUNT major, minor; - char *p; + char *p = strchr(pLine, '.'); - p = pLine; - while (*p && *p != '.') - p++; - - if (*p++ == '\0') + if (p == NULL) return; + p++; + /* Get major number */ if (GetNumArg(pLine, &major) == (BYTE *) 0) return; @@ -2561,10 +2556,8 @@ STATIC VOID InstallExec(struct instCmds *icmd) *d = 0; args--; - *args = 0; - while (args[*args+1]) - ++*args; - args[*args+1] = '\r'; + *args = strlen(&args[1]); + args[*args+1] = '\r'; args[*args+2] = 0; exb.exec.env_seg = 0; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index b9b769d..1acb9da 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -58,10 +58,11 @@ VOID ASMPASCAL fmemcpy( void FAR *d, const void FAR *s, size_t n); VOID ASMPASCAL strcpy(char *d, const char *s); size_t ASMPASCAL strlen(const char *s); size_t ASMPASCAL fstrlen(const char FAR *s); +char * ASMPASCAL strchr(const char *s, int ch); #ifdef __WATCOMC__ -/* dx and es not used or clobbered for all asmsupt.asm functions except - (f)memchr/(f)strchr (which preserve es) */ +/* bx, cx, dx and es not used or clobbered for all asmsupt.asm functions except + (f)memchr/(f)strchr (which clobber dx) */ #pragma aux (pascal) pascal_ax modify exact [ax] #pragma aux (pascal_ax) init_memset #pragma aux (pascal_ax) init_fmemset @@ -72,6 +73,7 @@ size_t ASMPASCAL fstrlen(const char FAR *s); #pragma aux (pascal_ax) init_strcpy #pragma aux (pascal_ax) init_strlen modify nomemory #pragma aux (pascal_ax) init_fstrlen modify nomemory +#pragma aux (pascal) init_strchr modify exact [ax dx] nomemory #endif #undef LINESIZE