2. If you compile with -DSMALL, using -U will produce an error. This
does not follow the common, IMO questionable, practice of just
ignoring the switches. However I find it a totally reasonable
for most unavailable switches (possibly -C aside).
OK?
/Alexander
Index: fetch.c
===================================================================
RCS file: /cvs/src/usr.bin/ftp/fetch.c,v
retrieving revision 1.124
diff -u -p -r1.124 fetch.c
--- fetch.c 11 Jul 2014 03:31:52 -0000 1.124
+++ fetch.c 11 Jul 2014 10:18:25 -0000
@@ -1284,9 +1284,6 @@ auto_fetch(int argc, char *argv[], char
char *cp, *url, *host, *dir, *file, *portnum;
char *username, *pass, *pathstart;
char *ftpproxy, *httpproxy;
-#ifndef SMALL
- char *uagent = NULL;
-#endif /* !SMALL */
int rval, xargc;
volatile int argpos;
int dirhasglob, filehasglob, oautologin;
@@ -1307,13 +1304,6 @@ auto_fetch(int argc, char *argv[], char
if ((httpproxy = getenv(HTTP_PROXY)) != NULL && *httpproxy == '\0')
httpproxy = NULL;
- if (httpuseragent == NULL)
- httpuseragent = HTTP_USER_AGENT;
-#ifndef SMALL
- else
- uagent = httpuseragent;
-#endif /* !SMALL */
-
/*
* Loop through as long as there's files to fetch.
*/
@@ -1590,9 +1580,6 @@ bad_ftp_url:
}
if (connected && rval != -1)
disconnect(0, NULL);
-#ifndef SMALL
- free(uagent);
-#endif /* !SMALL */
return (rval);
}
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/ftp/main.c,v
retrieving revision 1.88
diff -u -p -r1.88 main.c
--- main.c 11 Jul 2014 03:31:52 -0000 1.88
+++ main.c 11 Jul 2014 10:18:25 -0000
@@ -362,19 +362,17 @@ main(volatile int argc, char *argv[])
trace = 1;
break;
- case 'U':
#ifndef SMALL
- if (httpuseragent)
- errx(1, "User-Agent was already defined");
- /* Ensure that User-Agent value is in a single line. */
+ case 'U':
+ free (httpuseragent);
if (strcspn(optarg, "\r\n") != strlen(optarg))
errx(1, "Invalid User-Agent: %s.", optarg);
if (asprintf(&httpuseragent, "User-Agent: %s",
optarg) == -1)
errx(1, "Can't allocate memory for HTTP(S) "
"User-Agent");
-#endif /* !SMALL */
break;
+#endif /* !SMALL */
case 'v':
verbose = 1;
@@ -394,6 +392,8 @@ main(volatile int argc, char *argv[])
#ifndef SMALL
cookie_load();
#endif /* !SMALL */
+ if (httpuseragent == NULL)
+ httpuseragent = HTTP_USER_AGENT;
cpend = 0; /* no pending replies */
proxy = 0; /* proxy not active */