diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index 5219c79f6..ed7a767a7 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -37,9 +37,6 @@ #include #include #include -#if defined(_WIN32) -#include -#endif /* common */ #include "chartype.h" @@ -49,6 +46,7 @@ #include "xmalloc.h" #include "strpool.h" #include "abend.h" +#include "pathutil.h" /* cc65 */ #include "codegen.h" @@ -2970,31 +2968,6 @@ static void DoLine (void) MLine = InitLine (MLine); } -/** - * Determines the absolute path of the given relative path. - * The absolute path for the file is stored in a malloced buffer. - * Returns NULL if some error occured. - */ -char *FindAbsolutePath (const char *path); - - -#if defined(_WIN32) - -char *FindAbsolutePath (const char *path) { - return _fullpath (NULL, path, MAX_PATH); -} - -#else - -extern char* realpath (const char* path, char* resolved_path); - -/* this uses the POSIX1.-2008 version of the function, - which solves the problem of finding a maximum path length for the file */ -char* FindAbsolutePath (const char* path) { - return realpath (path, NULL); -} - -#endif /* Possible outcomes of preprocessing a pragma */ typedef enum { diff --git a/src/common.vcxproj b/src/common.vcxproj index 6098c98a0..5a6855208 100644 --- a/src/common.vcxproj +++ b/src/common.vcxproj @@ -1,4 +1,4 @@ - + @@ -110,6 +110,7 @@ + @@ -155,6 +156,7 @@ + @@ -171,4 +173,4 @@ - \ No newline at end of file + diff --git a/src/common/pathutil.c b/src/common/pathutil.c new file mode 100644 index 000000000..ce4a63106 --- /dev/null +++ b/src/common/pathutil.c @@ -0,0 +1,25 @@ + +#include + + +#if defined(_WIN32) +# include +#endif + +#if defined(_WIN32) + +char *FindAbsolutePath (const char *path) { + return _fullpath (NULL, path, MAX_PATH); +} + +#else + +extern char* realpath (const char* path, char* resolved_path); + +/* this uses the POSIX1.-2008 version of the function, + which solves the problem of finding a maximum path length for the file */ +char* FindAbsolutePath (const char* path) { + return realpath (path, NULL); +} + +#endif diff --git a/src/common/pathutil.h b/src/common/pathutil.h new file mode 100644 index 000000000..0efd6490a --- /dev/null +++ b/src/common/pathutil.h @@ -0,0 +1,56 @@ +/*****************************************************************************/ +/* */ +/* pathutil.h */ +/* Path manipulation utilities */ +/* */ +/* */ +/* */ +/* (C) 2003-2008 Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef PATHUTIL_H +#define PATHUTIL_H + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + +/** + * Determines the absolute path of the given relative path. + * The absolute path for the file is stored in a malloced buffer. + * Returns NULL if some error occured. + * The returned path's separator is system specific. + */ +char *FindAbsolutePath (const char *path); + + + +/* End of pathutil.h */ + +#endif