1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
25 * AT&T Bell Laboratories
27 * string vector argv insertion
35 * insert the string vector vec between
36 * (*argvp)[0] and (*argvp)[1], sliding (*argvp)[1] ... over
37 * null and blank args are deleted
39 * vecfree always called
41 * -1 returned if insertion failed
45 vecargs(register char** vec
, int* argcp
, char*** argvp
)
48 register char** oargv
;
54 if ((num
= (char**)(*(vec
- 1)) - vec
) > 0)
56 if (!(argv
= newof(0, char*, num
+ *argcp
+ 1, 0)))
65 while (s
= *argv
= *vec
++)
67 while (isspace(*s
)) s
++;
71 while (*argv
= *oargv
++) argv
++;
72 *argcp
= argv
- *argvp
;