From 78fc7a1e6ddea0a573dd8c1580c4e190174c053c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 13 Jun 2009 04:01:01 +0000 Subject: [PATCH] Remove dosnames.c and inline ParseDosName, because there is only one user left (split_path()) which only uses it to find out if the path ends in a backslash and the length of the directory part. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1442 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosnames.c | 83 ----------------------------------------------- kernel/fatfs.c | 10 ++++-- kernel/makefile | 3 +- kernel/proto.h | 3 -- 4 files changed, 9 insertions(+), 90 deletions(-) delete mode 100644 kernel/dosnames.c diff --git a/kernel/dosnames.c b/kernel/dosnames.c deleted file mode 100644 index a040d46..0000000 --- a/kernel/dosnames.c +++ /dev/null @@ -1,83 +0,0 @@ -/****************************************************************/ -/* */ -/* dosnames.c */ -/* DOS-C */ -/* */ -/* Generic parsing functions for file name specifications */ -/* */ -/* Copyright (c) 1994 */ -/* Pasquale J. Villani */ -/* All Rights Reserved */ -/* */ -/* This file is part of DOS-C. */ -/* */ -/* DOS-C is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License */ -/* as published by the Free Software Foundation; either version */ -/* 2, or (at your option) any later version. */ -/* */ -/* DOS-C is distributed in the hope that it will be useful, but */ -/* WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ -/* the GNU General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU General Public */ -/* License along with DOS-C; see the file COPYING. If not, */ -/* write to the Free Software Foundation, 675 Mass Ave, */ -/* Cambridge, MA 02139, USA. */ -/* */ -/****************************************************************/ - -#include "portab.h" - -#ifdef VERSION_STRINGS -static BYTE *dosnamesRcsId = - "$Id$"; -#endif - -#include "globals.h" - -/* - MSD durring an FindFirst search string looks like this; - (*), & (.) == Current directory *.* - (\) == Root directory *.* - (..) == Back one directory *.* - - This always has a "truename" as input, so we may do some shortcuts - - returns number of characters in the directory component (up to the - last backslash, including d:) or negative if error - */ -int ParseDosName(const char *filename) -{ - int nDirCnt; - const char *lpszLclDir, *lpszLclFile; - - /* Initialize the users data fields */ - nDirCnt = 0; - - /* NB: this code assumes ASCII */ - - /* Now see how long a directory component we have. */ - lpszLclDir = lpszLclFile = filename; - filename += 2; - - while (*filename) - { - if (*filename == '\\') - lpszLclFile = filename + 1; - ++filename; - } - nDirCnt = lpszLclFile - lpszLclDir; - - /* Parse out the file name portion. */ - filename = lpszLclFile; - while (*filename) - ++filename; - - if (filename == lpszLclFile) - return DE_PATHNOTFND; - - return nDirCnt; -} - diff --git a/kernel/fatfs.c b/kernel/fatfs.c index f1fe74d..8fbe40b 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -257,9 +257,15 @@ COUNT dos_close(COUNT fd) f_node_ptr split_path(char * path, f_node_ptr fnp) { /* Start off by parsing out the components. */ - int dirlength = ParseDosName(path); + int i = 2, dirlength = 3; - if (dirlength < SUCCESS) + /* Now see how long a directory component we have. */ + while (path[i]) + if (path[i++] == '\\') + dirlength = i; + + /* check if the path ends in a backslash */ + if (path[dirlength] == '\0') return (f_node_ptr) 0; /* 11/29/99 jt diff --git a/kernel/makefile b/kernel/makefile index 45e0076..85cefc4 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -21,7 +21,7 @@ OBJS3=apisupt.obj intr.obj irqstack.obj blockio.obj chario.obj systime.obj \ error.obj OBJS4=break.obj dosfns.obj fatdir.obj fatfs.obj fattab.obj fcbfns.obj \ inthndlr.obj -OBJS5=ioctl.obj dosnames.obj memmgr.obj task.obj newstuff.obj nls.obj network.obj +OBJS5=ioctl.obj memmgr.obj task.obj newstuff.obj nls.obj network.obj OBJS6=prf.obj misc.obj strings.obj syspack.obj lfnapi.obj iasmsupt.obj OBJS7=main.obj config.obj initoem.obj inithma.obj dyninit.obj iprf.obj \ initdisk.obj initclk.obj @@ -97,7 +97,6 @@ blockio.obj: blockio.c $(HEADERS) $(TARGET).lnk break.obj: break.c $(HEADERS) $(TARGET).lnk chario.obj: chario.c $(HEADERS) $(TARGET).lnk dosfns.obj: dosfns.c $(HEADERS) $(TARGET).lnk -dosnames.obj: dosnames.c $(HEADERS) $(TARGET).lnk dsk.obj: dsk.c $(HEADERS) $(TARGET).lnk error.obj: error.c $(HEADERS) $(TARGET).lnk fatdir.obj: fatdir.c $(HEADERS) $(TARGET).lnk diff --git a/kernel/proto.h b/kernel/proto.h index 2c1a4d7..682f1cd 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -129,9 +129,6 @@ VOID ASMCFUNC DosIdle_hlt(void); #pragma aux (cdecl) DosIdle_hlt modify exact [] #endif -/* dosnames.c */ -int ParseDosName(const char *); - /* error.c */ VOID dump(void); VOID panic(BYTE * s);