[BACK]Return to compat.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/compat.c between version 1.11 and 1.12

version 1.11, 1998/05/13 06:54:58 version 1.12, 1998/12/05 00:06:27
Line 114 
Line 114 
         char      *file = Var_Value (TARGET, curTarg, &p1);          char      *file = Var_Value (TARGET, curTarg, &p1);
   
         if (!noExecute && eunlink(file) != -1) {          if (!noExecute && eunlink(file) != -1) {
             printf ("*** %s removed\n", file);              Error("*** %s removed\n", file);
         }          }
         if (p1)          efree(p1);
             free(p1);  
   
         /*          /*
          * Run .INTERRUPT only if hit with interrupt signal           * Run .INTERRUPT only if hit with interrupt signal
Line 138 
Line 137 
  * shellneed --   * shellneed --
  *   *
  * Results:   * Results:
  *      Returns 1 if a specified line must be executed by the shell,   *      Returns 1 if a specified set of arguments
  *      0 if it can be run via execve, and -1 if the command is a no-op.   *      must be executed by the shell,
    *      0 if it can be run via execve, and -1 if the command can be
    *      handled internally
  *   *
  * Side Effects:   * Side Effects:
  *      None.   *      May modify the process umask
  *   *
  *-----------------------------------------------------------------------   *-----------------------------------------------------------------------
  */   */
 static int  static int
 shellneed (cmd)  shellneed (av)
         char *cmd;          char **av;
 {  {
         char *runsh[] = {          char *runsh[] = {
                 "alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit",                  "alias", "cd", "eval", "exec", "exit", "read", "set", "ulimit",
                 "unalias", "unset", "wait", ":",                  "unalias", "unset", "wait",
                 NULL                  NULL
         };          };
   
         char **av, **p;          char **p;
         int ac;  
   
         av = brk_string(cmd, &ac, TRUE);          /* FIXME most of these ARE actual no-ops */
   
         for (p = runsh; *p; p++)          for (p = runsh; *p; p++)
                 if (strcmp(av[1], *p) == 0)                  if (strcmp(av[0], *p) == 0)
                         return (1);                          return (1);
   
         if (strcmp(av[1], "umask") == 0) {          if (strcmp(av[0], "umask") == 0) {
                 long umi;                  long umi;
                 char *ep = NULL;                  char *ep = NULL;
                 mode_t um;                  mode_t um;
   
                 if (av[2] != NULL) {                  if (av[1] != NULL) {
                         umi = strtol(av[2], &ep, 8);                          umi = strtol(av[1], &ep, 8);
                         if (ep == NULL)                          if (ep == NULL)
                                 return (1);                                  return (1);
                         um = umi;                          um = umi;
                         (void) umask(um);  
                         return (-1);  
                 }                  }
                 um = umask(0);                  else {
                           um = umask(0);
                           printf("%o\n", um);
                   }
                 (void) umask(um);                  (void) umask(um);
                 printf("%o\n", um);  
                 return (-1);                  return (-1);
         }          }
   
Line 207 
Line 206 
     ClientData    gnp;          /* Node from which the command came */      ClientData    gnp;          /* Node from which the command came */
 {  {
     char          *cmdStart;    /* Start of expanded command */      char          *cmdStart;    /* Start of expanded command */
     register char *cp;      char *cp, *bp = NULL;
     Boolean       silent,       /* Don't print command */      Boolean       silent,       /* Don't print command */
                   errCheck;     /* Check errors */                    errCheck;     /* Check errors */
     int           reason;       /* Reason for child's death */      int           reason;       /* Reason for child's death */
Line 220 
Line 219 
                                  * dynamically allocated */                                   * dynamically allocated */
     Boolean       local;        /* TRUE if command should be executed      Boolean       local;        /* TRUE if command should be executed
                                  * locally */                                   * locally */
     int           internal;     /* Various values.. */  
     char          *cmd = (char *) cmdp;      char          *cmd = (char *) cmdp;
     GNode         *gn = (GNode *) gnp;      GNode         *gn = (GNode *) gnp;
       static char *shargv[4] = { "/bin/sh" };
   
     /*      /*
      * Avoid clobbered variable warnings by forcing the compiler       * Avoid clobbered variable warnings by forcing the compiler
Line 239 
Line 238 
     cmdStart = Var_Subst (NULL, cmd, gn, FALSE);      cmdStart = Var_Subst (NULL, cmd, gn, FALSE);
   
     /*      /*
      * brk_string will return an argv with a NULL in av[1], thus causing       * brk_string will return an argv with a NULL in av[0], thus causing
      * execvp to choke and die horribly. Besides, how can we execute a null       * execvp to choke and die horribly. Besides, how can we execute a null
      * command? In any case, we warn the user that the command expanded to       * command? In any case, we warn the user that the command expanded to
      * nothing (is this the right thing to do?).       * nothing (is this the right thing to do?).
Line 307 
Line 306 
          * -e flag as well as -c if it's supposed to exit when it hits an           * -e flag as well as -c if it's supposed to exit when it hits an
          * error.           * error.
          */           */
         static char     *shargv[4] = { "/bin/sh" };  
   
         shargv[1] = (errCheck ? "-ec" : "-c");          shargv[1] = (errCheck ? "-ec" : "-c");
         shargv[2] = cmd;          shargv[2] = cmd;
         shargv[3] = (char *)NULL;          shargv[3] = (char *)NULL;
         av = shargv;          av = shargv;
         argc = 0;          argc = 0;
     } else if ((internal = shellneed(cmd))) {  
         /*  
          * This command must be passed by the shell for other reasons..  
          * or.. possibly not at all.  
          */  
         static char     *shargv[4] = { "/bin/sh" };  
   
         if (internal == -1) {  
                 /* Command does not need to be executed */  
                 return (0);  
         }  
   
         shargv[1] = (errCheck ? "-ec" : "-c");  
         shargv[2] = cmd;  
         shargv[3] = (char *)NULL;  
         av = shargv;  
         argc = 0;  
     } else {      } else {
         /*          /*
          * No meta-characters, so no need to exec a shell. Break the command           * No meta-characters, so probably no need to exec a shell.
          * into words to form an argument vector we can execute.           * Break the command into words to form an argument vector
          * brk_string sticks our name in av[0], so we have to           * we can execute.
          * skip over it...  
          */           */
         av = brk_string(cmd, &argc, TRUE);          av = brk_string(cmd, &argc, TRUE, &bp);
         av += 1;          switch(shellneed(av)) {
           case -1: /* handled internally */
                   free(bp);
                   free(av);
                   return 0;
           case 1:
                   shargv[1] = (errCheck ? "-ec" : "-c");
                   shargv[2] = cmd;
                   shargv[3] = (char *)NULL;
                   av = shargv;
                   argc = 0;
                   break;
           default: /* nothing needed */
                   break;
           }
     }      }
   
     local = TRUE;      local = TRUE;
Line 361 
Line 355 
         }          }
         _exit(1);          _exit(1);
     }      }
       if (bp) {
           free(av);
           free(bp);
       }
     free(cmdStart);      free(cmdStart);
     Lst_Replace (cmdNode, (ClientData) NULL);      Lst_Replace (cmdNode, (ClientData) NULL);
   
Line 468 
Line 466 
         if (Lst_Member (gn->iParents, pgn) != NILLNODE) {          if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
             char *p1;              char *p1;
             Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);              Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
             if (p1)              efree(p1);
                 free(p1);  
         }          }
   
         /*          /*
Line 606 
Line 603 
         } else if (keepgoing) {          } else if (keepgoing) {
             pgn->make = FALSE;              pgn->make = FALSE;
         } else {          } else {
             printf ("\n\nStop.\n");              char *p1;
   
               printf ("\n\nStop in %s.\n", Var_Value(".CURDIR", gn, &p1));
               efree(p1);
             exit (1);              exit (1);
         }          }
     } else if (gn->made == ERROR) {      } else if (gn->made == ERROR) {
Line 619 
Line 619 
         if (Lst_Member (gn->iParents, pgn) != NILLNODE) {          if (Lst_Member (gn->iParents, pgn) != NILLNODE) {
             char *p1;              char *p1;
             Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);              Var_Set (IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
             if (p1)              efree(p1);
                 free(p1);  
         }          }
         switch(gn->made) {          switch(gn->made) {
             case BEINGMADE:              case BEINGMADE:

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12