View | Details | Raw Unified | Return to bug 19422 | Differences between
and this patch

Collapse All | Expand All

(-)fmt.c (-4 / +8 lines)
Lines 61-67 Link Here
61
shquote(argv)
61
shquote(argv)
62
	char **argv;
62
	char **argv;
63
{
63
{
64
	long arg_max;
64
	static long arg_max = -1;
65
	long len;
65
	char **p, *dst, *src;
66
	char **p, *dst, *src;
66
	static char *buf = NULL;
67
	static char *buf = NULL;
67
68
Lines 80-92 Link Here
80
	for (p = argv; (src = *p++) != 0; ) {
81
	for (p = argv; (src = *p++) != 0; ) {
81
		if (*src == 0)
82
		if (*src == 0)
82
			continue;
83
			continue;
83
		strvis(dst, src, VIS_NL | VIS_CSTYLE);
84
		len = (4 * arg_max - (dst - buf)) / 4;
85
		strvisx(dst, src, strlen(src) < len ? strlen(src) : len,
86
		    VIS_NL | VIS_CSTYLE);
84
		while (*dst)
87
		while (*dst)
85
			dst++;
88
			dst++;
86
		*dst++ = ' ';
89
		if ((4 * arg_max - (dst - buf)) / 4 > 0)
90
			*dst++ = ' ';
87
	}
91
	}
88
	/* Chop off trailing space */
92
	/* Chop off trailing space */
89
	if (dst != buf)
93
	if (dst != buf && dst[-1] == ' ')
90
		dst--;
94
		dst--;
91
	*dst = '\0';
95
	*dst = '\0';
92
	return (buf);
96
	return (buf);

Return to bug 19422