From c266fd5a08ef8d523ff79dce9ad9247b064d4960 Mon Sep 17 00:00:00 2001
From: Thomas Chou <thomas@wytron.com.tw>
Date: Sun, 2 Dec 2007 16:29:30 +0800
Subject: [PATCH] ftp: replace legacy bcopy/bzero/bcmp/index/rindex

bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3.
They are replaced as proposed by SuSv3.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 user/ftp/ftp/cmds.c      |   10 +++++-----
 user/ftp/ftp/ftp.c       |    4 ++--
 user/ftp/ftp/main.c      |    2 +-
 user/ftp/ftp/ruserpass.c |    4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/user/ftp/ftp/cmds.c b/user/ftp/ftp/cmds.c
index a98dfa3..cdf101d 100644
--- a/user/ftp/ftp/cmds.c
+++ b/user/ftp/ftp/cmds.c
@@ -243,9 +243,9 @@ setpeer(int argc, char *argv[])
 			verbose = -1;
 		if (command("SYST") == COMPLETE && overbose) {
 			register char *cp, c = 0;
-			cp = index(reply_string+4, ' ');
+			cp = strchr(reply_string+4, ' ');
 			if (cp == NULL)
-				cp = index(reply_string+4, '\r');
+				cp = strchr(reply_string+4, '\r');
 			if (cp) {
 				if (cp[-1] == '.')
 					cp--;
@@ -946,7 +946,7 @@ remglob(char *argv[], int doswitch)
 		(void) fclose(ftemp), ftemp = NULL;
 		return (NULL);
 	}
-	if ((cp = index(buf, '\n')) != NULL)
+	if ((cp = strchr(buf, '\n')) != NULL)
 		*cp = '\0';
 	return (buf);
 }
@@ -2008,11 +2008,11 @@ setnmap(int argc, char *argv[])
 	}
 	mapflag = 1;
 	code = 1;
-	cp = index(altarg, ' ');
+	cp = strchr(altarg, ' ');
 	if (proxy) {
 		while(*++cp == ' ');
 		altarg = cp;
-		cp = index(altarg, ' ');
+		cp = strchr(altarg, ' ');
 	}
 	*cp = '\0';
 	(void) strncpy(mapin, altarg, PATH_MAX - 1);
diff --git a/user/ftp/ftp/ftp.c b/user/ftp/ftp/ftp.c
index e9269d2..d53b799 100644
--- a/user/ftp/ftp/ftp.c
+++ b/user/ftp/ftp/ftp.c
@@ -794,7 +794,7 @@ recvrequest(const char *cmd,
 	oldintr = signal(SIGINT, abortrecv);
 	if (strcmp(local, "-") && *local != '|') {
 		if (access(local, W_OK) < 0) {
-			char *dir = rindex(local, '/');
+			char *dir = strrchr(local, '/');
 
 			if (errno != ENOENT && errno != EACCES) {
 				fprintf(stderr, "local: %s: %s\n", local,
@@ -1553,7 +1553,7 @@ static char *
 gunique(char *local)
 {
 	static char new[MAXPATHLEN];
-	char *cp = rindex(local, '/');
+	char *cp = strrchr(local, '/');
 	int d, count=0;
 	char ext = '1';
 
diff --git a/user/ftp/ftp/main.c b/user/ftp/ftp/main.c
index b930a9f..982f5d7 100644
--- a/user/ftp/ftp/main.c
+++ b/user/ftp/ftp/main.c
@@ -273,7 +273,7 @@ tail(filename)
 	register char *s;
 	
 	while (*filename) {
-		s = rindex(filename, '/');
+		s = strrchr(filename, '/');
 		if (s == NULL)
 			break;
 		if (s[1])
diff --git a/user/ftp/ftp/ruserpass.c b/user/ftp/ftp/ruserpass.c
index 22a93ce..4179c23 100644
--- a/user/ftp/ftp/ruserpass.c
+++ b/user/ftp/ftp/ruserpass.c
@@ -118,12 +118,12 @@ next:
 				goto match;
 			if (strcasecmp(hostname, tokval) == 0)
 				goto match;
-			if ((tmp = index(hostname, '.')) != NULL &&
+			if ((tmp = strchr(hostname, '.')) != NULL &&
 			    strcasecmp(tmp, mydomain) == 0 &&
 			    strncasecmp(hostname, tokval, tmp-hostname) == 0 &&
 			    tokval[tmp - hostname] == '\0')
 				goto match;
-			if ((tmp = index(host, '.')) != NULL &&
+			if ((tmp = strchr(host, '.')) != NULL &&
 			    strcasecmp(tmp, mydomain) == 0 &&
 			    strncasecmp(host, tokval, tmp - host) == 0 &&
 			    tokval[tmp - host] == '\0')
-- 
1.5.3.3

