From a9cb9acffa15330ab89fc07bd2f7e5772bff1cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 4 Apr 2005 18:16:00 +0000 Subject: [PATCH] MacOS is also a unix that doesn't define __unix__/unix While here, rewrite this part of the function to not modify that string, but rather take a copy of it and them modify is, all this just to pacify gcc git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14739 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/cmds.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/appl/ftp/ftp/cmds.c b/appl/ftp/ftp/cmds.c index 86b58ca1b..e9602627b 100644 --- a/appl/ftp/ftp/cmds.c +++ b/appl/ftp/ftp/cmds.c @@ -142,7 +142,7 @@ setpeer(int argc, char **argv) if (autologin) login(argv[1]); -#if (defined(unix) || defined(__unix__) || defined(__unix) || defined(_AIX) || defined(_CRAY) || defined(__NetBSD__)) && NBBY == 8 +#if (defined(unix) || defined(__unix__) || defined(__unix) || defined(_AIX) || defined(_CRAY) || defined(__NetBSD__) || defined(__APPLE__)) && NBBY == 8 /* * this ifdef is to keep someone form "porting" this to an incompatible * system and not checking this out. This way they have to think about it. @@ -150,22 +150,23 @@ setpeer(int argc, char **argv) overbose = verbose; if (debug == 0) verbose = -1; - if (command("SYST") == COMPLETE && overbose) { - char *cp, c; - cp = strchr(reply_string+4, ' '); + if (command("SYST") == COMPLETE && overbose && strlen(reply_string) > 4) { + char *cp, *p; + + cp = strdup(reply_string + 4); if (cp == NULL) - cp = strchr(reply_string+4, '\r'); - if (cp) { - if (cp[-1] == '.') - cp--; - c = *cp; - *cp = '\0'; + errx(1, "strdup: out of memory"); + p = strchr(cp, ' '); + if (p == NULL) + p = strchr(cp, '\r'); + if (p) { + if (p[-1] == '.') + p--; + *p = '\0'; } - printf("Remote system type is %s.\n", - reply_string+4); - if (cp) - *cp = c; + printf("Remote system type is %s.\n", cp); + free(cp); } if (!strncmp(reply_string, "215 UNIX Type: L8", 17)) { if (proxy)