View | Details | Raw Unified | Return to issue 67589
Collapse All | Expand All

(-)dmake/make.c (-5 / +6 lines)
Lines 1137-1148 Link Here
1137
	 /* Append_line() calls Print_cmnd(). */
1137
	 /* Append_line() calls Print_cmnd(). */
1138
         Append_line( cmnd, TRUE, tmpfile, cp->CE_NAME, trace, 0 );
1138
         Append_line( cmnd, TRUE, tmpfile, cp->CE_NAME, trace, 0 );
1139
      else {
1139
      else {
1140
	 /* Don't execute cmnd if it is empty or contains only whitespaces. */
1140
	 /* Don't print empty recipe lines. .ROOT and .TARGETS
1141
	 if( *DmStrSpn(cmnd, " \t") != '\0' )
1141
	  * deliberately might have empty "" recipes and we don't want
1142
	  * to output empty recipe lines for them. */
1143
	 if ( *cmnd ) {
1144
	    /* Print command and remove continuation sequence from cmnd. */
1142
	    Print_cmnd(cmnd, !(do_it && (l_attr & A_SILENT)), 0);
1145
	    Print_cmnd(cmnd, !(do_it && (l_attr & A_SILENT)), 0);
1143
	 else
1146
	 }
1144
	    do_it = FALSE;
1145
1146
	 rval=Do_cmnd(cmnd,FALSE,do_it,cp,(l_attr&A_IGNORE)!=0, shell,
1147
	 rval=Do_cmnd(cmnd,FALSE,do_it,cp,(l_attr&A_IGNORE)!=0, shell,
1147
		      rp->st_next == NIL(STRING) );
1148
		      rp->st_next == NIL(STRING) );
1148
      }
1149
      }
(-)dmake/sysintf.c (+2 lines)
Lines 259-264 Link Here
259
259
260
   if( !do_it ) {
260
   if( !do_it ) {
261
      if( last && !Doing_bang ) {
261
      if( last && !Doing_bang ) {
262
	 /* Don't execute, just update the target when using '-t'
263
	  * switch. */
262
         Update_time_stamp( target );
264
         Update_time_stamp( target );
263
      }
265
      }
264
      return(0);
266
      return(0);
(-)dmake/unix/runargv.c (-16 / +79 lines)
Lines 119-125 Link Here
119
static int  _abort_flg= FALSE;
119
static int  _abort_flg= FALSE;
120
static int  _use_i    = -1;
120
static int  _use_i    = -1;
121
121
122
static  void	_add_child ANSI((int, CELLPTR, int, int));
122
static  int	_add_child ANSI((int, CELLPTR, int, int));
123
static  void	_attach_cmd ANSI((char *, int, int, CELLPTR, int, int));
123
static  void	_attach_cmd ANSI((char *, int, int, CELLPTR, int, int));
124
static  void    _finished_child ANSI((int, int));
124
static  void    _finished_child ANSI((int, int));
125
static  int     _running ANSI((CELLPTR));
125
static  int     _running ANSI((CELLPTR));
Lines 164-172 Link Here
164
   int          st_pq = 0; /* Current _exec_shell target process index */
164
   int          st_pq = 0; /* Current _exec_shell target process index */
165
   char         **argv;
165
   char         **argv;
166
166
167
#if ENABLE_SPAWN && ( HAVE_SPAWN_H || __CYGWIN__ )
167
   int old_stdout;   /* For internal echo and spawn. */
168
   int old_stdout;
168
   int internal = 0; /* Used to indicate internal command. */
169
#endif
170
169
171
   /* Special handling for the shell function macro is required. If the currend
170
   /* Special handling for the shell function macro is required. If the currend
172
    * command is called as part of a shell escape in a recipe make sure that all
171
    * command is called as part of a shell escape in a recipe make sure that all
Lines 198-205 Link Here
198
      }
197
      }
199
   }
198
   }
200
199
200
   /* remove leading whitespace */
201
   while( iswhite(*cmd) ) ++cmd;
202
203
   /* Return immediately for empty line or noop command. */
204
   if ( !*cmd ||				/* empty line */
205
	( strncmp(cmd, "noop", 4) == 0 &&	/* noop command */
206
	  (iswhite(cmd[4]) || cmd[4] == '\0')) ) {
207
      internal = 1;
208
   }
209
   else if( !shell &&  /* internal echo only if not in shell */
210
	    strncmp(cmd, "echo", 4) == 0 &&
211
	    (iswhite(cmd[4]) || cmd[4] == '\0') ) {
212
      int nl = 1;
213
214
      cmd = cmd+4;
215
      while( iswhite(*cmd) ) ++cmd;
216
      if ( strncmp(cmd,"-n",2 ) == 0) {
217
	 nl = 0;
218
	 cmd = cmd+2;
219
	 while( iswhite(*cmd) ) ++cmd;
220
      }
221
222
      if( Is_exec_shell ) {
223
	 old_stdout = dup(1);
224
	 close(1);
225
	 dup( fileno(stdout_redir) );
226
      }
227
      printf("%s%s", cmd, nl ? "\n" : "");
228
      fflush(stdout);
229
      if( Is_exec_shell ) {
230
	 close(1);
231
	 dup(old_stdout);
232
      }
233
234
      internal = 1;
235
   }
236
   if ( internal ) {
237
      /* Use _add_child() / _finished_child() with internal command. */
238
      int cur_proc = _add_child(-1, target, ignore, last);
239
      _finished_child(-1, cur_proc);
240
      return 0;
241
   }
242
243
   /* Pack cmd in argument vector. */
201
   argv = Pack_argv( group, shell, cmd );
244
   argv = Pack_argv( group, shell, cmd );
202
245
246
   /* Really spawn or fork a child. */
203
#if ENABLE_SPAWN && ( HAVE_SPAWN_H || __CYGWIN__ )
247
#if ENABLE_SPAWN && ( HAVE_SPAWN_H || __CYGWIN__ )
204
   /* As no other childs are started while the output is redirected this
248
   /* As no other childs are started while the output is redirected this
205
    * is save. */
249
    * is save. */
Lines 239-245 Link Here
239
   case 0:  /* child */
283
   case 0:  /* child */
240
      /* redirect stdout for _exec_shell */
284
      /* redirect stdout for _exec_shell */
241
      if( Is_exec_shell ) {
285
      if( Is_exec_shell ) {
242
	 /* org_out = dup(1); */
286
	 /* old_stdout = dup(1); */
243
         close(1);
287
         close(1);
244
         dup( fileno(stdout_redir) );
288
         dup( fileno(stdout_redir) );
245
      }
289
      }
Lines 322-333 Link Here
322
}
366
}
323
367
324
368
325
static void
369
static int
326
_add_child( pid, target, ignore, last )/*
370
_add_child( pid, target, ignore, last )/*
327
=========================================
371
=========================================
328
  Creates/amend a process array entry and enters the child parameters.
372
  Creates/amend a process array entry and enters the child parameters.
329
  The pid == -1 represents an internal command.
373
  The pid == -1 represents an internal command and the function returns
330
  The function returns the used process array index.
374
  the used process array index. For non-internal commands the function
375
  returns -1.
331
*/
376
*/
332
int	pid;
377
int	pid;
333
CELLPTR target;
378
CELLPTR target;
Lines 351-356 Link Here
351
	 if( !_procs[i].pr_valid )
396
	 if( !_procs[i].pr_valid )
352
	    break;
397
	    break;
353
   }
398
   }
399
   else {
400
      /* If the process index is reused free the pointer before using
401
       * it again below. */
402
      FREE( _procs[i].pr_dir );
403
   }
354
404
355
   pp = _procs+i;
405
   pp = _procs+i;
356
406
Lines 359-371 Link Here
359
   pp->pr_target = target;
409
   pp->pr_target = target;
360
   pp->pr_ignore = ignore;
410
   pp->pr_ignore = ignore;
361
   pp->pr_last   = last;
411
   pp->pr_last   = last;
412
   /* Freed above and after the last recipe in _finished child(). */
362
   pp->pr_dir    = DmStrDup(Get_current_dir());
413
   pp->pr_dir    = DmStrDup(Get_current_dir());
363
414
364
   Current_target = NIL(CELL);
415
   Current_target = NIL(CELL);
365
416
366
   _proc_cnt++;
417
   _proc_cnt++;
367
418
368
   if( Wait_for_completion ) Wait_for_child( FALSE, pid );
419
   if( pid != -1 ) {
420
      if( Wait_for_completion )
421
	 Wait_for_child( FALSE, pid );
422
      return -1;
423
   } else
424
      return i;
369
}
425
}
370
426
371
427
Lines 381-393 Link Here
381
   register int i;
437
   register int i;
382
   char     *dir;
438
   char     *dir;
383
439
384
   for( i=0; i<Max_proc; i++ )
440
   if(pid == -1) {
385
      if( _procs[i].pr_valid && _procs[i].pr_pid == pid )
441
      /* internal command */
386
	 break;
442
      i = status;
387
443
      status = 0;
388
   /* Some children we didn't make esp true if using /bin/sh to execute a
444
   }
389
    * a pipe and feed the output as a makefile into dmake. */
445
   else {
390
   if( i == Max_proc ) return;
446
      for( i=0; i<Max_proc; i++ )
447
	 if( _procs[i].pr_valid && _procs[i].pr_pid == pid )
448
	    break;
449
450
      /* Some children we didn't make esp true if using /bin/sh to execute a
451
       * a pipe and feed the output as a makefile into dmake. */
452
      if( i == Max_proc ) return;
453
   }
391
454
392
   _procs[i].pr_valid = 0; /* Not a running process anymore. */
455
   _procs[i].pr_valid = 0; /* Not a running process anymore. */
393
   if( Measure & M_RECIPE )
456
   if( Measure & M_RECIPE )

Return to issue 67589