From a40464038e1e42fc18a6830f4b6f5b8d6c9cd835 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 9 Apr 2002 04:05:02 +0000 Subject: [PATCH] dummy [SVN r13407] --- historic/jam/src/command.c | 30 ++++++++++++++++++++++-------- jam_src/command.c | 30 ++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/historic/jam/src/command.c b/historic/jam/src/command.c index 7d1e81ca0..e6f190db5 100644 --- a/historic/jam/src/command.c +++ b/historic/jam/src/command.c @@ -25,6 +25,7 @@ # include "command.h" # include +# include /* * cmd_new() - return a new CMD or 0 if too many args @@ -39,7 +40,7 @@ cmd_new( { CMD *cmd = (CMD *)malloc( sizeof( CMD ) ); /* lift line-length limitation entirely when JAMSHELL is just "%" */ - int expand_line = ( shell && !strcmp(shell->string,"%") && !list_next(shell) ); + int no_limit = ( shell && !strcmp(shell->string,"%") && !list_next(shell) ); int max_line = MAXLINE; int allocated = -1; @@ -65,14 +66,27 @@ cmd_new( max_line = max_line * 2; } - while( expand_line && allocated < 0 && max_line < INT_MAX / 2 ); - - /* Bail if the result won't fit in MAXLINE */ - /* We don't free targets/sources/shell if bailing. */ - if( allocated < 0 ) + while( allocated < 0 && max_line < INT_MAX / 2 ); + + if ( !no_limit ) { - cmd_free( cmd ); - cmd = 0; + /* Bail if the result won't fit in MAXLINE */ + char *s = cmd->buf; + while ( *s ) + { + size_t l = strcspn( s, "\n" ); + + if ( l > MAXLINE ) + { + /* We don't free targets/sources/shell if bailing. */ + cmd_free( cmd ); + return 0; + } + + s += l; + if ( *s ) + ++s; + } } return cmd; diff --git a/jam_src/command.c b/jam_src/command.c index 7d1e81ca0..e6f190db5 100644 --- a/jam_src/command.c +++ b/jam_src/command.c @@ -25,6 +25,7 @@ # include "command.h" # include +# include /* * cmd_new() - return a new CMD or 0 if too many args @@ -39,7 +40,7 @@ cmd_new( { CMD *cmd = (CMD *)malloc( sizeof( CMD ) ); /* lift line-length limitation entirely when JAMSHELL is just "%" */ - int expand_line = ( shell && !strcmp(shell->string,"%") && !list_next(shell) ); + int no_limit = ( shell && !strcmp(shell->string,"%") && !list_next(shell) ); int max_line = MAXLINE; int allocated = -1; @@ -65,14 +66,27 @@ cmd_new( max_line = max_line * 2; } - while( expand_line && allocated < 0 && max_line < INT_MAX / 2 ); - - /* Bail if the result won't fit in MAXLINE */ - /* We don't free targets/sources/shell if bailing. */ - if( allocated < 0 ) + while( allocated < 0 && max_line < INT_MAX / 2 ); + + if ( !no_limit ) { - cmd_free( cmd ); - cmd = 0; + /* Bail if the result won't fit in MAXLINE */ + char *s = cmd->buf; + while ( *s ) + { + size_t l = strcspn( s, "\n" ); + + if ( l > MAXLINE ) + { + /* We don't free targets/sources/shell if bailing. */ + cmd_free( cmd ); + return 0; + } + + s += l; + if ( *s ) + ++s; + } } return cmd;