=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/parse.c,v retrieving revision 1.104 retrieving revision 1.105 diff -c -r1.104 -r1.105 *** src/usr.bin/make/parse.c 2012/04/20 13:28:11 1.104 --- src/usr.bin/make/parse.c 2012/09/21 07:55:20 1.105 *************** *** 1,4 **** ! /* $OpenBSD: parse.c,v 1.104 2012/04/20 13:28:11 espie Exp $ */ /* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: parse.c,v 1.105 2012/09/21 07:55:20 espie Exp $ */ /* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */ /* *************** *** 547,554 **** gn->type &= ~OP_DUMMY; } ! if (gn != NULL) ! Array_AtEnd(>argets, gn); } static void --- 547,560 ---- gn->type &= ~OP_DUMMY; } ! /* try to find a proper location for a target in a file, by ! * filling it repeatedly until the target has commands.. ! * This is not perfect for .USE targets... ! */ ! if ((gn->type & OP_HAS_COMMANDS) == 0) ! Parse_FillLocation(&gn->origin); ! ! Array_AtEnd(>argets, gn); } static void *************** *** 1040,1050 **** { GNode *gn = (GNode *)gnp; /* if target already supplied, ignore commands */ ! if (!(gn->type & OP_HAS_COMMANDS)) { Lst_AtEnd(&gn->commands, cmd); - if (!gn->origin.lineno) - Parse_FillLocation(&gn->origin); - } } /*- --- 1046,1053 ---- { GNode *gn = (GNode *)gnp; /* if target already supplied, ignore commands */ ! if (!(gn->type & OP_HAS_COMMANDS)) Lst_AtEnd(&gn->commands, cmd); } /*- *************** *** 1441,1448 **** { /* add the command to the list of * commands of all targets in the dependency spec */ - char *cmd = estrdup(line); Array_ForEach(targets, ParseAddCmd, cmd); #ifdef CLEANUP Lst_AtEnd(&targCmds, cmd); --- 1444,1458 ---- { /* add the command to the list of * commands of all targets in the dependency spec */ + struct command *cmd; + size_t len = strlen(line); + + cmd = emalloc(sizeof(struct command) + len); + memcpy(&cmd->string, line, len+1); + Parse_FillLocation(&cmd->location); + + Array_ForEach(targets, ParseAddCmd, cmd); #ifdef CLEANUP Lst_AtEnd(&targCmds, cmd); *************** *** 1486,1498 **** size_t pos; char *end; char *cp; ! char *dep; /* let's start a new set of commands */ Array_Reset(targets); /* XXX this is a dirty heuristic to handle target: dep ; commands */ ! dep = NULL; /* First we need to find eventual dependencies */ pos = strcspn(stripped, ":!"); /* go over :!, and find ; */ --- 1496,1508 ---- size_t pos; char *end; char *cp; ! char *cmd; /* let's start a new set of commands */ Array_Reset(targets); /* XXX this is a dirty heuristic to handle target: dep ; commands */ ! cmd = NULL; /* First we need to find eventual dependencies */ pos = strcspn(stripped, ":!"); /* go over :!, and find ; */ *************** *** 1501,1509 **** if (line != stripped) /* find matching ; in original... The * original might be slightly longer. */ ! dep = strchr(line+(end-stripped), ';'); else ! dep = end; /* kill end of line. */ *end = '\0'; } --- 1511,1519 ---- if (line != stripped) /* find matching ; in original... The * original might be slightly longer. */ ! cmd = strchr(line+(end-stripped), ';'); else ! cmd = end; /* kill end of line. */ *end = '\0'; } *************** *** 1514,1526 **** ParseDoDependency(cp); free(cp); ! /* Parse dependency if it's not empty. */ ! if (dep != NULL) { do { ! dep++; ! } while (isspace(*dep)); ! if (*dep != '\0') ! parse_commands(targets, dep); } } --- 1524,1536 ---- ParseDoDependency(cp); free(cp); ! /* Parse command if it's not empty. */ ! if (cmd != NULL) { do { ! cmd++; ! } while (isspace(*cmd)); ! if (*cmd != '\0') ! parse_commands(targets, cmd); } }