2 * Copyright 1993, 1995 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
7 * command.c - maintain lists of commands
9 * 01/20/00 (seiwald) - Upgraded from K&R to ANSI C
10 * 09/08/00 (seiwald) - bulletproof PIECEMEAL size computation
25 * cmd_new() - return a new CMD or 0 if too many args
27 CMD
*cmd_new (RULE
*rule
, LIST
*targets
, LIST
*sources
, LIST
*shell
, int maxline
) {
28 CMD
*cmd
= (CMD
*)malloc(sizeof(CMD
));
30 kStringNew(&cmd
->buf
);
35 lol_add(&cmd
->args
, targets
);
36 lol_add(&cmd
->args
, sources
);
37 /* bail if the result won't fit in maxline */
38 /* we don't free targets/sources/shell if bailing */
39 if (var_string(rule
->actions
, &cmd
->buf
, &cmd
->args
, ' ') < 0) { cmd_free(cmd
); return 0; }
45 * cmd_free() - free a CMD
47 void cmd_free (CMD
*cmd
) {
48 kStringFree(&cmd
->buf
);
50 list_free(cmd
->shell
);