about summary refs log tree commit diff stats
path: root/WWW
diff options
context:
space:
mode:
Diffstat (limited to 'WWW')
-rw-r--r--WWW/Library/Implementation/HTDOS.c92
-rw-r--r--WWW/Library/Implementation/HTVMSUtils.c2
2 files changed, 46 insertions, 48 deletions
diff --git a/WWW/Library/Implementation/HTDOS.c b/WWW/Library/Implementation/HTDOS.c
index df506cd2..f6697249 100644
--- a/WWW/Library/Implementation/HTDOS.c
+++ b/WWW/Library/Implementation/HTDOS.c
@@ -5,6 +5,18 @@
 #include <HTUtils.h>
 #include <HTDOS.h>
 
+/*
+ * Make a copy of the source argument in the result, allowing some extra
+ * space so we can append directly onto the result without reallocating.
+ */
+PRIVATE char * copy_plus ARGS2(char **, result, char *, source)
+{
+    int length = strlen(source);
+    HTSprintf0(result, "%-*s", length+10, source);
+    (*result)[length] = 0;
+    return (*result);
+}
+
 /* PUBLIC							HTDOS_wwwName()
 **		CONVERTS DOS Name into WWW Name
 ** ON ENTRY:
@@ -16,29 +28,22 @@
 */
 char * HTDOS_wwwName ARGS1(char *, dosname)
 {
-	static char wwwname[1024];
-	char *cp_url = wwwname;
-
-	strcpy(wwwname,dosname);
+    static char *wwwname;
+    char *cp_url = copy_plus(&wwwname, dosname);
 
-	for ( ; *cp_url != '\0' ; cp_url++)
-	  if(*cp_url == '\\') *cp_url = '/';   /* convert dos backslash to unix-style */
+    for ( ; *cp_url != '\0' ; cp_url++)
+	if(*cp_url == '\\')
+	    *cp_url = '/';   /* convert dos backslash to unix-style */
 
-	if(strlen(wwwname) > 3 && *cp_url == '/')
-		*cp_url = '\0';
+    if(strlen(wwwname) > 3 && *cp_url == '/')
+	*cp_url = '\0';
 
-	if(*cp_url == ':')
-	{
-		cp_url++;
-		*cp_url = '/';
-	}
+    if(*cp_url == ':') {
+	cp_url++;
+	*cp_url = '/';
+    }
 
-/*
-	if((strlen(wwwname)>2)&&(wwwname[1]==':')) wwwname[1]='|';
-	printf("\n\nwww: %s\n\ndos: %s\n\n",wwwname,dosname);
-	sleep(5);
-*/
-	return(wwwname);
+    return(wwwname);
 }
 
 
@@ -49,41 +54,36 @@ char * HTDOS_wwwName ARGS1(char *, dosname)
 **
 ** ON EXIT:
 **	returns 	DOS file specification
-**
-** Bug(?):	Returns pointer to input string, which is modified
 */
 char * HTDOS_name ARGS1(char *, wwwname)
 {
-	static char cp_url[1024];
-	int joe;
+    static char *cp_url;
+    char *result;
+    int joe;
 
-	memset(cp_url, 0, 1023);
-	sprintf(cp_url, "%s",wwwname);
+    copy_plus(&cp_url, wwwname);
 
-	for(joe = 0; cp_url[joe] != '\0'; joe++)	{
-		if(cp_url[joe] == '/')	{
-			cp_url[joe] = '\\';
-		}
+    for (joe = 0; cp_url[joe] != '\0'; joe++)	{
+	if (cp_url[joe] == '/')	{
+	    cp_url[joe] = '\\';
 	}
+    }
 
-	/* Needed to surf the root of a local drive. */
+    /* Needed to surf the root of a local drive. */
 
-	if(strlen(cp_url) < 4) cp_url[2] = ':';
-	if(strlen(cp_url) == 3) cp_url[3] = '\\';
-	if(strlen(cp_url) == 4) cp_url[4] = '.';
+    if(strlen(cp_url) < 4) cp_url[2] = ':';
+    if(strlen(cp_url) == 3) strcpy(cp_url+3, "\\");
+    if(strlen(cp_url) == 4) strcpy(cp_url+4, ".");
 
-	if((strlen(cp_url) > 2) && (cp_url[1] == '|'))
-		cp_url[1] = ':';
+    if((strlen(cp_url) > 2) && (cp_url[1] == '|'))
+	cp_url[1] = ':';
 
-	if((cp_url[1] == '\\') || (cp_url[0]  != '\\'))
-	{
-		CTRACE(tfp, "HTDOS_name changed `%s' to `%s'\n",
-			wwwname, cp_url);
-		strcpy(wwwname, cp_url); /* return(cp_url); */
-	} else {
-		CTRACE(tfp, "HTDOS_name changed `%s' to `%s'\n",
-			wwwname, cp_url+1);
-		strcpy(wwwname, cp_url+1); /* return(cp_url+1); */
-	}
-	return (wwwname);
+    if((cp_url[1] == '\\') || (cp_url[0]  != '\\')) {
+	result = cp_url;
+    } else {
+	result = cp_url+1;
+    }
+
+    CTRACE(tfp, "HTDOS_name changed `%s' to `%s'\n", wwwname, result);
+    return (result);
 }
diff --git a/WWW/Library/Implementation/HTVMSUtils.c b/WWW/Library/Implementation/HTVMSUtils.c
index 7c599386..ae103082 100644
--- a/WWW/Library/Implementation/HTVMSUtils.c
+++ b/WWW/Library/Implementation/HTVMSUtils.c
@@ -33,8 +33,6 @@
 #include <LYUtils.h>
 #include <LYLeaks.h>
 
-#define FREE(x) if (x) {free(x); x = NULL;}
-
 #define INFINITY 512            	/* File name length @@ FIXME */
 
 PUBLIC BOOL HTVMSFileVersions=FALSE; /* Include version numbers in listing? */