[BACK]Return to parse.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / make

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/usr.bin/make/parse.c between version 1.185.2.1 and 1.185.2.2

version 1.185.2.1, 2013/06/23 06:29:00 version 1.185.2.2, 2014/08/20 00:05:00
Line 361  static int ParseAddCmd(void *, void *);
Line 361  static int ParseAddCmd(void *, void *);
 static void ParseHasCommands(void *);  static void ParseHasCommands(void *);
 static void ParseDoInclude(char *);  static void ParseDoInclude(char *);
 static void ParseSetParseFile(const char *);  static void ParseSetParseFile(const char *);
   static void ParseSetIncludedFile(void);
 #ifdef SYSVINCLUDE  #ifdef SYSVINCLUDE
 static void ParseTraditionalInclude(char *);  static void ParseTraditionalInclude(char *);
 #endif  #endif
Line 845  ParseLinkSrc(void *pgnp, void *cgnp)
Line 846  ParseLinkSrc(void *pgnp, void *cgnp)
             (void)Lst_AtEnd(cgn->parents, pgn);              (void)Lst_AtEnd(cgn->parents, pgn);
     pgn->unmade += 1;      pgn->unmade += 1;
     if (DEBUG(PARSE)) {      if (DEBUG(PARSE)) {
         fprintf(debug_file, "# ParseLinkSrc: added child %s - %s\n", pgn->name, cgn->name);          fprintf(debug_file, "# %s: added child %s - %s\n", __func__,
               pgn->name, cgn->name);
         Targ_PrintNode(pgn, 0);          Targ_PrintNode(pgn, 0);
         Targ_PrintNode(cgn, 0);          Targ_PrintNode(cgn, 0);
     }      }
Line 1020  ParseDoSrc(int tOp, const char *src)
Line 1022  ParseDoSrc(int tOp, const char *src)
             (void)Lst_AtEnd(predecessor->order_succ, gn);              (void)Lst_AtEnd(predecessor->order_succ, gn);
             (void)Lst_AtEnd(gn->order_pred, predecessor);              (void)Lst_AtEnd(gn->order_pred, predecessor);
             if (DEBUG(PARSE)) {              if (DEBUG(PARSE)) {
                 fprintf(debug_file, "# ParseDoSrc: added Order dependency %s - %s\n",                  fprintf(debug_file, "# %s: added Order dependency %s - %s\n",
                         predecessor->name, gn->name);                      __func__, predecessor->name, gn->name);
                 Targ_PrintNode(predecessor, 0);                  Targ_PrintNode(predecessor, 0);
                 Targ_PrintNode(gn, 0);                  Targ_PrintNode(gn, 0);
             }              }
Line 1206  ParseDoDependency(char *line)
Line 1208  ParseDoDependency(char *line)
                  */                   */
                 int     length;                  int     length;
                 void    *freeIt;                  void    *freeIt;
                 char    *result;  
   
                 result = Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);                  (void)Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);
                 if (freeIt)                  if (freeIt)
                     free(freeIt);                      free(freeIt);
                 cp += length-1;                  cp += length-1;
Line 1741  Parse_IsVar(char *line)
Line 1742  Parse_IsVar(char *line)
             ch = *line++;              ch = *line++;
             wasSpace = TRUE;              wasSpace = TRUE;
         }          }
   #ifdef SUNSHCMD
           if (ch == ':' && strncmp(line, "sh", 2) == 0) {
               line += 2;
               continue;
           }
   #endif
         if (ch == '=')          if (ch == '=')
             return TRUE;              return TRUE;
         if (*line == '=' && ISEQOPERATOR(ch))          if (*line == '=' && ISEQOPERATOR(ch))
Line 1945  Parse_DoVar(char *line, GNode *ctxt)
Line 1952  Parse_DoVar(char *line, GNode *ctxt)
 }  }
   
   
   /*
    * ParseMaybeSubMake --
    *      Scan the command string to see if it a possible submake node
    * Input:
    *      cmd             the command to scan
    * Results:
    *      TRUE if the command is possibly a submake, FALSE if not.
    */
   static Boolean
   ParseMaybeSubMake(const char *cmd)
   {
       size_t i;
       static struct {
           const char *name;
           size_t len;
       } vals[] = {
   #define MKV(A)  {       A, sizeof(A) - 1        }
           MKV("${MAKE}"),
           MKV("${.MAKE}"),
           MKV("$(MAKE)"),
           MKV("$(.MAKE)"),
           MKV("make"),
       };
       for (i = 0; i < sizeof(vals)/sizeof(vals[0]); i++) {
           char *ptr;
           if ((ptr = strstr(cmd, vals[i].name)) == NULL)
               continue;
           if ((ptr == cmd || !isalnum((unsigned char)ptr[-1]))
               && !isalnum((unsigned char)ptr[vals[i].len]))
               return TRUE;
       }
       return FALSE;
   }
   
 /*-  /*-
  * ParseAddCmd  --   * ParseAddCmd  --
  *      Lst_ForEach function to add a command line to all targets   *      Lst_ForEach function to add a command line to all targets
Line 1957  Parse_DoVar(char *line, GNode *ctxt)
Line 1998  Parse_DoVar(char *line, GNode *ctxt)
  *      Always 0   *      Always 0
  *   *
  * Side Effects:   * Side Effects:
  *      A new element is added to the commands list of the node.   *      A new element is added to the commands list of the node,
    *      and the node can be marked as a submake node if the command is
    *      determined to be that.
  */   */
 static int  static int
 ParseAddCmd(void *gnp, void *cmd)  ParseAddCmd(void *gnp, void *cmd)
Line 1971  ParseAddCmd(void *gnp, void *cmd)
Line 2014  ParseAddCmd(void *gnp, void *cmd)
     /* if target already supplied, ignore commands */      /* if target already supplied, ignore commands */
     if (!(gn->type & OP_HAS_COMMANDS)) {      if (!(gn->type & OP_HAS_COMMANDS)) {
         (void)Lst_AtEnd(gn->commands, cmd);          (void)Lst_AtEnd(gn->commands, cmd);
           if (ParseMaybeSubMake(cmd))
               gn->type |= OP_SUBMAKE;
         ParseMark(gn);          ParseMark(gn);
     } else {      } else {
 #ifdef notyet  #ifdef notyet
Line 2159  Parse_include_file(char *file, Boolean i
Line 2204  Parse_include_file(char *file, Boolean i
     /* load it */      /* load it */
     lf = loadfile(fullname, fd);      lf = loadfile(fullname, fd);
   
       ParseSetIncludedFile();
     /* Start reading from this file next */      /* Start reading from this file next */
     Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf);      Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf);
     curFile->lf = lf;      curFile->lf = lf;
Line 2218  ParseDoInclude(char *line)
Line 2264  ParseDoInclude(char *line)
   
 /*-  /*-
  *---------------------------------------------------------------------   *---------------------------------------------------------------------
    * ParseSetIncludedFile  --
    *      Set the .INCLUDEDFROMFILE variable to the contents of .PARSEFILE
    *      and the .INCLUDEDFROMDIR variable to the contents of .PARSEDIR
    *
    * Results:
    *      None
    *
    * Side Effects:
    *      The .INCLUDEDFROMFILE variable is overwritten by the contents
    *      of .PARSEFILE and the .INCLUDEDFROMDIR variable is overwriten
    *      by the contents of .PARSEDIR
    *---------------------------------------------------------------------
    */
   static void
   ParseSetIncludedFile(void)
   {
       char *pf, *fp = NULL;
       char *pd, *dp = NULL;
   
       pf = Var_Value(".PARSEFILE", VAR_GLOBAL, &fp);
       Var_Set(".INCLUDEDFROMFILE", pf, VAR_GLOBAL, 0);
       pd = Var_Value(".PARSEDIR", VAR_GLOBAL, &dp);
       Var_Set(".INCLUDEDFROMDIR", pd, VAR_GLOBAL, 0);
   
       if (DEBUG(PARSE))
           fprintf(debug_file, "%s: ${.INCLUDEDFROMDIR} = `%s' "
               "${.INCLUDEDFROMFILE} = `%s'\n", __func__, pd, pf);
   
       if (fp)
           free(fp);
       if (dp)
           free(dp);
   }
   /*-
    *---------------------------------------------------------------------
  * ParseSetParseFile  --   * ParseSetParseFile  --
  *      Set the .PARSEDIR and .PARSEFILE variables to the dirname and   *      Set the .PARSEDIR and .PARSEFILE variables to the dirname and
  *      basename of the given filename   *      basename of the given filename
Line 2251  ParseSetParseFile(const char *filename)
Line 2332  ParseSetParseFile(const char *filename)
         Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL, 0);          Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL, 0);
     }      }
     if (DEBUG(PARSE))      if (DEBUG(PARSE))
         fprintf(debug_file, "ParseSetParseFile: ${.PARSEDIR} = `%s' "          fprintf(debug_file, "%s: ${.PARSEDIR} = `%s' ${.PARSEFILE} = `%s'\n",
             "${.PARSEFILE} = `%s'\n", pd, pf);              __func__, pd, pf);
     free(dirname);      free(dirname);
 }  }
   
Line 2314  Parse_SetInput(const char *name, int lin
Line 2395  Parse_SetInput(const char *name, int lin
         ParseTrackInput(name);          ParseTrackInput(name);
   
     if (DEBUG(PARSE))      if (DEBUG(PARSE))
         fprintf(debug_file, "Parse_SetInput: file %s, line %d, fd %d, nextbuf %p, arg %p\n",          fprintf(debug_file, "%s: file %s, line %d, fd %d, nextbuf %p, arg %p\n",
                 name, line, fd, nextbuf, arg);              __func__, name, line, fd, nextbuf, arg);
   
     if (fd == -1 && nextbuf == NULL)      if (fd == -1 && nextbuf == NULL)
         /* sanity */          /* sanity */
Line 2387  ParseTraditionalInclude(char *line)
Line 2468  ParseTraditionalInclude(char *line)
     char          *all_files;      char          *all_files;
   
     if (DEBUG(PARSE)) {      if (DEBUG(PARSE)) {
             fprintf(debug_file, "ParseTraditionalInclude: %s\n", file);              fprintf(debug_file, "%s: %s\n", __func__, file);
     }      }
   
     /*      /*
Line 2446  ParseGmakeExport(char *line)
Line 2527  ParseGmakeExport(char *line)
     char          *value;      char          *value;
   
     if (DEBUG(PARSE)) {      if (DEBUG(PARSE)) {
             fprintf(debug_file, "ParseGmakeExport: %s\n", variable);              fprintf(debug_file, "%s: %s\n", __func__, variable);
     }      }
   
     /*      /*
Line 2526  ParseEOF(void)
Line 2607  ParseEOF(void)
         /* We've run out of input */          /* We've run out of input */
         Var_Delete(".PARSEDIR", VAR_GLOBAL);          Var_Delete(".PARSEDIR", VAR_GLOBAL);
         Var_Delete(".PARSEFILE", VAR_GLOBAL);          Var_Delete(".PARSEFILE", VAR_GLOBAL);
           Var_Delete(".INCLUDEDFROMDIR", VAR_GLOBAL);
           Var_Delete(".INCLUDEDFROMFILE", VAR_GLOBAL);
         return DONE;          return DONE;
     }      }
   
Line 2572  ParseGetLine(int flags, int *length)
Line 2655  ParseGetLine(int flags, int *length)
                 if (cf->P_end == NULL)                  if (cf->P_end == NULL)
                     /* End of string (aka for loop) data */                      /* End of string (aka for loop) data */
                     break;                      break;
                   /* see if there is more we can parse */
                   while (ptr++ < cf->P_end) {
                       if ((ch = *ptr) == '\n') {
                           if (ptr > line && ptr[-1] == '\\')
                               continue;
                           Parse_Error(PARSE_WARNING,
                               "Zero byte read from file, skipping rest of line.");
                           break;
                       }
                   }
                 if (cf->nextbuf != NULL) {                  if (cf->nextbuf != NULL) {
                     /*                      /*
                      * End of this buffer; return EOF and outer logic                       * End of this buffer; return EOF and outer logic

Legend:
Removed from v.1.185.2.1  
changed lines
  Added in v.1.185.2.2

CVSweb <webmaster@jp.NetBSD.org>