command.c #2

  • //
  • guest/
  • perforce_software/
  • jam/
  • src/
  • command.c
  • View
  • Commits
  • Open Download .zip Download (2 KB)
/*
 * Copyright 1993, 1995 Christopher Seiwald.
 *
 * This file is part of Jam - see jam.c for Copyright information.
 */

/*
 * command.c - maintain lists of commands
 *
 * Each target has a list of actions that are to be applied to it, but due
 * to modifications on the actions they do not map one-to-one to the commands
 * that are the be executed against the target.  The CMD datatype holds
 * a single command that is to be executed against a target, and they can
 * chain together to represent the full collection of commands used to
 * update a target.
 *
 * External routines:
 *	cmd_new() - make a new CMD and chain it
 *	cmd_free() - free a CMD
 *
 * Macros:
 *	cmd_next() - follow chain of CMDs	
 */

# include "jam.h"

# include "lists.h"
# include "parse.h"
# include "variable.h"
# include "rules.h"

# include "command.h"

/*
 * cmd_new() - make a new CMD and chain it
 */

CMD *
cmd_new( chain, rule, targets, sources, shell, chunk )
CMD	*chain;
RULE	*rule;
LIST	*targets;
LIST	*sources;
LIST	*shell;
int	chunk;
{
	int     len;

	CMD *cmd = (CMD *)malloc( sizeof( CMD ) );

	cmd->rule = rule;
	cmd->shell = shell;

	lol_init( &cmd->args );
	lol_add( &cmd->args, targets );
	lol_add( &cmd->args, sources );

	len = var_string( rule->actions, cmd->buf, CMDBUF, &cmd->args );
	
	if( len < 0 )
	{
	    if ( chunk == 1 ) {
		printf( "fatal error: %s command block too long (max %d)\n", 
			rule->name, CMDBUF );
		exit( EXITBAD );
	    }
	    free( cmd );
	    return NULL;
	}

	if( !chain ) chain = cmd;
	else chain->tail->next = cmd;
	chain->tail = cmd;
	cmd->next = 0;

	return chain;
}

/*
 * cmd_free() - free a CMD
 */

void
cmd_free( cmd )
CMD	*cmd;
{
	lol_free( &cmd->args );
	list_free( cmd->shell );
	free( (char *)cmd );
}
# Change User Description Committed
#6 9896 Perforce staff Maximum command line length now determined by execmax() function,
which still just returns the compiled-in MAXLINE.


p4transfer.py: Transferred from production
#5 3065 Perforce staff Support for 'actions ...
maxline value', to set a command
specific maxline (rather than the OS-specific maximum).

Undocumented.
#4 2493 rmg Rewrite the past: update all jam's source with comments to
reflect changes since about 2.3, very early 2001.

Whitespace only change.

=== computer:1666: Change 37660 by seiwald@play-seiwald on 2002/11/06 22:41:35

Note: I regenerated jamgram.c on my linux 7.3 system prior to
the submit, since patch was so unhappy trying to lay down the
changes from Christopher's change. Presumably this is just due to
different yacc/bison/whatever particulars on the system where
Christopher made the changes originally. - rmg
#3 486 Perforce staff Jam 2.3.
 See RELNOTES for a list of changes from 2.2.x.

Just about every source file was touched when jam got ANSI-fied.
#2 76 Laura Wingerd Integrate command-block-too-long fix, plus minor doc
updates. Jam/MR release level is now 2.2.5.
(change 72, change 73, change 74, change 75)
#1 2 laura Add Jam/MR 2.2 source