/* * 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 | |
---|---|---|---|---|---|
#2 | 72 | Laura Wingerd |
Mark Baushke's fix for command block too long. In Mark's words: "Due to a deep tree hierarchy, I was running into the 'fatal error: Clean command block too long (max 10240)' in cmd_new(). "I do not believe there should be a fatal error just because the guess at a chunk size was not a good guess, so I have created a patch to cmd_new() to return NULL in the event that the text will not fit into the CMDBUF sized buffer. I have also changed make1cmds() to notice that cmd_new() returned a NULL and if possible to adjust the value of chunk until it finds a value that works. If the smallest possible value (chunk=1) fails, then it will still generate the fatal error. If chunk starts out as zero, then no attempt is made to adjust the chunk value to different sizes, it will just generate a fatal error." |
||
#1 | 58 | Laura Wingerd | Branching jam @jam2.2.4 | ||
//guest/perforce_software/jam/src/command.c | |||||
#1 | 2 | laura | Add Jam/MR 2.2 source |