- mouring@cvs.openbsd.org 2001/05/03 23:09:53
     [misc.c misc.h scp.c sftp.c]
     Move colon() and cleanhost() to misc.c where I should I have put it in
     the first place
diff --git a/misc.c b/misc.c
index feeacb8..e949ded 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: misc.c,v 1.5 2001/04/12 20:09:37 stevesk Exp $	*/
+/*	$OpenBSD: misc.c,v 1.6 2001/05/03 23:09:52 mouring Exp $	*/
 
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.5 2001/04/12 20:09:37 stevesk Exp $");
+RCSID("$OpenBSD: misc.c,v 1.6 2001/05/03 23:09:52 mouring Exp $");
 
 #include "misc.h"
 #include "log.h"
@@ -131,6 +131,39 @@
 	return port;
 }
 
+char *
+cleanhostname(char *host)
+{
+	if (*host == '[' && host[strlen(host) - 1] == ']') {
+		host[strlen(host) - 1] = '\0';
+		return (host + 1);
+	} else
+		return host;
+}
+
+char *
+colon(char *cp)
+{
+	int flag = 0;
+
+	if (*cp == ':')		/* Leading colon is part of file name. */
+		return (0);
+	if (*cp == '[')
+		flag = 1;
+
+	for (; *cp; ++cp) {
+		if (*cp == '@' && *(cp+1) == '[')
+			flag = 1;
+		if (*cp == ']' && *(cp+1) == ':' && flag)
+			return (cp+1);
+		if (*cp == ':' && !flag)
+			return (cp);
+		if (*cp == '/')
+			return (0);
+	}
+	return (0);
+}
+
 mysig_t
 mysignal(int sig, mysig_t act)
 {