From 3972ee78953f9860dc44584d0b3d990418614969 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 3 Jul 2003 01:11:35 +0000
Subject: [PATCH] Changed BACKSLASH macro to (unbiased) PATH_DELIM. Created
 IS_PATH_DELIM() macro (stole websrvr.c->is_slash macro). Defines BSD
 _PATH_TMP and _PATH_DEVNULL macros for all platforms.

---
 src/xpdev/dirwrap.c | 10 +++++-----
 src/xpdev/dirwrap.h | 19 +++++++++++++++++--
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c
index bb8985ea76..1054ff8c51 100644
--- a/src/xpdev/dirwrap.c
+++ b/src/xpdev/dirwrap.c
@@ -513,7 +513,7 @@ BOOL DLLCALL isdir(const char *filename)
 	SAFECOPY(path,filename);
 
 	p=lastchar(path);
-	if(p!=path && (*p=='/' || *p==BACKSLASH)) {	/* chop off trailing slash */
+	if(p!=path && IS_PATH_DELIM(*p)) {	/* chop off trailing slash */
 #if !defined(__unix__)
 		if(*(p-1)!=':')		/* Don't change C:\ to C: */
 #endif
@@ -564,8 +564,8 @@ ulong DLLCALL delfiles(char *inpath, char *spec)
 	glob_t	g;
 
 	lastch=*lastchar(inpath);
-	if(lastch!='/' && lastch!='\\')
-		sprintf(path,"%s%c",inpath,BACKSLASH);
+	if(!IS_PATH_DELIM(lastch))
+		sprintf(path,"%s%c",inpath,PATH_DELIM);
 	else
 		strcpy(path,inpath);
 	strcat(path,spec);
@@ -734,7 +734,7 @@ char * DLLCALL _fullpath(char *target, const char *path, size_t size)  {
 #endif
 
 /****************************************************************************/
-/* Adds a trailing slash/backslash on path strings 							*/
+/* Adds a trailing slash/backslash (path delimiter) on path strings 		*/
 /****************************************************************************/
 char* DLLCALL backslash(char* path)
 {
@@ -743,7 +743,7 @@ char* DLLCALL backslash(char* path)
 	p=lastchar(path);
 
 	if(*p!='/' && *p!='\\') {
-		*(++p)=BACKSLASH;
+		*(++p)=PATH_DELIM;
 		*(++p)=0;
 	}
 	return(path);
diff --git a/src/xpdev/dirwrap.h b/src/xpdev/dirwrap.h
index 135f6b2c7d..f93051faae 100644
--- a/src/xpdev/dirwrap.h
+++ b/src/xpdev/dirwrap.h
@@ -158,9 +158,24 @@ extern "C" {
 #endif
 
 #if defined(__unix__)
-	#define BACKSLASH	'/'
+	#define PATH_DELIM			'/'
+	#define IS_PATH_DELIM(x)	(x=='/')
+
+	/* These may be pre-defined in paths.h (BSD) */
+	#ifndef _PATH_TMP
+	#define _PATH_TMP			"/tmp/"
+	#endif
+	#ifndef _PATH_DEVNULL
+	#define _PATH_DEVNULL		"/dev/null"
+	#endif
+
 #else /* MS-DOS based OS */
-	#define BACKSLASH	'\\'
+
+	#define PATH_DELIM			'\\'
+	#define IS_PATH_DELIM(x)	((x)=='/' || (x)=='\\')
+	#define _PATH_TMP			getenv("TEMP")
+	#define _PATH_DEVNULL		"NUL"
+
 #endif
 
 #if !defined(MAX_PATH)	/* maximum path length */
-- 
GitLab