Cleanup code so that long lines to be quoted don't get truncated.
PR: 5679 Reviewed by: Bruce Evans <bde@zeta.org.au>
This commit is contained in:
parent
5884281637
commit
70962efd65
@ -1,4 +1,4 @@
|
|||||||
/* $Id: cmds.c,v 1.12 1997/12/13 20:38:12 pst Exp $ */
|
/* $Id: cmds.c,v 1.13 1998/01/09 13:45:11 msmith Exp $ */
|
||||||
/* $NetBSD: cmds.c,v 1.30.2.1 1997/11/18 00:58:26 mellon Exp $ */
|
/* $NetBSD: cmds.c,v 1.30.2.1 1997/11/18 00:58:26 mellon Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -39,7 +39,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
|
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$Id: cmds.c,v 1.12 1997/12/13 20:38:12 pst Exp $");
|
__RCSID("$Id: cmds.c,v 1.13 1998/01/09 13:45:11 msmith Exp $");
|
||||||
__RCSID_SOURCE("$NetBSD: cmds.c,v 1.30.2.1 1997/11/18 00:58:26 mellon Exp $");
|
__RCSID_SOURCE("$NetBSD: cmds.c,v 1.30.2.1 1997/11/18 00:58:26 mellon Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
@ -1448,19 +1448,17 @@ quote1(initial, argc, argv)
|
|||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
int i, len;
|
int i, len, len1;
|
||||||
char buf[BUFSIZ]; /* must be >= sizeof(line) */
|
char buf[BUFSIZ]; /* must be >= sizeof(line) */
|
||||||
|
|
||||||
(void)strncpy(buf, initial, sizeof(buf) - 1);
|
len = snprintf(buf, sizeof(buf), "%s", initial);
|
||||||
buf[sizeof(buf) - 1] = '\0';
|
if (len >= 0 && len < sizeof(buf)) {
|
||||||
if (argc > 1) {
|
for (i = 1; i < argc; i++) {
|
||||||
len = strlen(buf);
|
len1 = snprintf(&buf[len], sizeof(buf) - len,
|
||||||
len += strlen(strncpy(&buf[len], argv[1],
|
i == 1 ? "%s" : " %s", argv[i]);
|
||||||
sizeof(buf) - len - 1));
|
if (len1 < 0 || len1 > sizeof(buf) - len)
|
||||||
for (i = 2; i < argc && len < sizeof(buf); i++) {
|
break;
|
||||||
buf[len++] = ' ';
|
len += len1;
|
||||||
len += strlen(strncpy(&buf[len], argv[i],
|
|
||||||
sizeof(buf) - len) - 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (command(buf) == PRELIM) {
|
if (command(buf) == PRELIM) {
|
||||||
|
Loading…
Reference in New Issue
Block a user