Deleted Added
full compact
parse.c (281812) parse.c (289842)
1/* $NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $ */
1/* $NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $ */
2
3/*
4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.
9 *

--- 54 unchanged lines hidden (view full) ---

64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE.
69 */
70
71#ifndef MAKE_NATIVE
2
3/*
4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.
9 *

--- 54 unchanged lines hidden (view full) ---

64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE.
69 */
70
71#ifndef MAKE_NATIVE
72static char rcsid[] = "$NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $";
72static char rcsid[] = "$NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $";
73#else
74#include <sys/cdefs.h>
75#ifndef lint
76#if 0
77static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
78#else
73#else
74#include <sys/cdefs.h>
75#ifndef lint
76#if 0
77static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
78#else
79__RCSID("$NetBSD: parse.c,v 1.204 2014/09/18 08:06:13 dholland Exp $");
79__RCSID("$NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $");
80#endif
81#endif /* not lint */
82#endif
83
84/*-
85 * parse.c --
86 * Functions to parse a makefile.
87 *

--- 719 unchanged lines hidden (view full) ---

807
808 while (isalpha((u_char)*line))
809 line++;
810 if (!isspace((u_char)*line))
811 return FALSE; /* not for us */
812 while (isspace((u_char)*line))
813 line++;
814
80#endif
81#endif /* not lint */
82#endif
83
84/*-
85 * parse.c --
86 * Functions to parse a makefile.
87 *

--- 719 unchanged lines hidden (view full) ---

807
808 while (isalpha((u_char)*line))
809 line++;
810 if (!isspace((u_char)*line))
811 return FALSE; /* not for us */
812 while (isspace((u_char)*line))
813 line++;
814
815 line = Var_Subst(NULL, line, VAR_CMD, 0);
815 line = Var_Subst(NULL, line, VAR_CMD, FALSE, TRUE);
816 Parse_Error(mtype, "%s", line);
817 free(line);
818
819 if (mtype == PARSE_FATAL) {
820 /* Terminate immediately. */
821 exit(1);
822 }
823 return TRUE;

--- 400 unchanged lines hidden (view full) ---

1224 * otherwise), so call the Var module to parse the puppy
1225 * so we can safely advance beyond it...There should be
1226 * no errors in this, as they would have been discovered
1227 * in the initial Var_Subst and we wouldn't be here.
1228 */
1229 int length;
1230 void *freeIt;
1231
816 Parse_Error(mtype, "%s", line);
817 free(line);
818
819 if (mtype == PARSE_FATAL) {
820 /* Terminate immediately. */
821 exit(1);
822 }
823 return TRUE;

--- 400 unchanged lines hidden (view full) ---

1224 * otherwise), so call the Var module to parse the puppy
1225 * so we can safely advance beyond it...There should be
1226 * no errors in this, as they would have been discovered
1227 * in the initial Var_Subst and we wouldn't be here.
1228 */
1229 int length;
1230 void *freeIt;
1231
1232 (void)Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt);
1232 (void)Var_Parse(cp, VAR_CMD, TRUE, TRUE, &length, &freeIt);
1233 if (freeIt)
1234 free(freeIt);
1235 cp += length-1;
1236 }
1237 }
1238
1239 /*
1240 * If the word is followed by a left parenthesis, it's the

--- 698 unchanged lines hidden (view full) ---

1939
1940 /*
1941 * make sure that we set the variable the first time to nothing
1942 * so that it gets substituted!
1943 */
1944 if (!Var_Exists(line, ctxt))
1945 Var_Set(line, "", ctxt, 0);
1946
1233 if (freeIt)
1234 free(freeIt);
1235 cp += length-1;
1236 }
1237 }
1238
1239 /*
1240 * If the word is followed by a left parenthesis, it's the

--- 698 unchanged lines hidden (view full) ---

1939
1940 /*
1941 * make sure that we set the variable the first time to nothing
1942 * so that it gets substituted!
1943 */
1944 if (!Var_Exists(line, ctxt))
1945 Var_Set(line, "", ctxt, 0);
1946
1947 cp = Var_Subst(NULL, cp, ctxt, FALSE);
1947 cp = Var_Subst(NULL, cp, ctxt, FALSE, TRUE);
1948 oldVars = oldOldVars;
1949 freeCp = TRUE;
1950
1951 Var_Set(line, cp, ctxt, 0);
1952 } else if (type == VAR_SHELL) {
1953 char *res;
1954 const char *error;
1955
1956 if (strchr(cp, '$') != NULL) {
1957 /*
1958 * There's a dollar sign in the command, so perform variable
1959 * expansion on the whole thing. The resulting string will need
1960 * freeing when we're done, so set freeCmd to TRUE.
1961 */
1948 oldVars = oldOldVars;
1949 freeCp = TRUE;
1950
1951 Var_Set(line, cp, ctxt, 0);
1952 } else if (type == VAR_SHELL) {
1953 char *res;
1954 const char *error;
1955
1956 if (strchr(cp, '$') != NULL) {
1957 /*
1958 * There's a dollar sign in the command, so perform variable
1959 * expansion on the whole thing. The resulting string will need
1960 * freeing when we're done, so set freeCmd to TRUE.
1961 */
1962 cp = Var_Subst(NULL, cp, VAR_CMD, TRUE);
1962 cp = Var_Subst(NULL, cp, VAR_CMD, TRUE, TRUE);
1963 freeCp = TRUE;
1964 }
1965
1966 res = Cmd_Exec(cp, &error);
1967 Var_Set(line, res, ctxt, 0);
1968 free(res);
1969
1970 if (error)

--- 322 unchanged lines hidden (view full) ---

2293 return;
2294 }
2295 *cp = '\0';
2296
2297 /*
2298 * Substitute for any variables in the file name before trying to
2299 * find the thing.
2300 */
1963 freeCp = TRUE;
1964 }
1965
1966 res = Cmd_Exec(cp, &error);
1967 Var_Set(line, res, ctxt, 0);
1968 free(res);
1969
1970 if (error)

--- 322 unchanged lines hidden (view full) ---

2293 return;
2294 }
2295 *cp = '\0';
2296
2297 /*
2298 * Substitute for any variables in the file name before trying to
2299 * find the thing.
2300 */
2301 file = Var_Subst(NULL, file, VAR_CMD, FALSE);
2301 file = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE);
2302
2303 Parse_include_file(file, endc == '>', silent);
2304 free(file);
2305}
2306
2307
2308/*-
2309 *---------------------------------------------------------------------

--- 209 unchanged lines hidden (view full) ---

2519 */
2520 while (isspace((unsigned char)*file))
2521 file++;
2522
2523 /*
2524 * Substitute for any variables in the file name before trying to
2525 * find the thing.
2526 */
2302
2303 Parse_include_file(file, endc == '>', silent);
2304 free(file);
2305}
2306
2307
2308/*-
2309 *---------------------------------------------------------------------

--- 209 unchanged lines hidden (view full) ---

2519 */
2520 while (isspace((unsigned char)*file))
2521 file++;
2522
2523 /*
2524 * Substitute for any variables in the file name before trying to
2525 * find the thing.
2526 */
2527 all_files = Var_Subst(NULL, file, VAR_CMD, FALSE);
2527 all_files = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE);
2528
2529 if (*file == '\0') {
2530 Parse_Error(PARSE_FATAL,
2531 "Filename missing from \"include\"");
2532 return;
2533 }
2534
2535 for (file = all_files; !done; file = cp + 1) {

--- 51 unchanged lines hidden (view full) ---

2587 "Variable/Value missing from \"export\"");
2588 return;
2589 }
2590 *value++ = '\0'; /* terminate variable */
2591
2592 /*
2593 * Expand the value before putting it in the environment.
2594 */
2528
2529 if (*file == '\0') {
2530 Parse_Error(PARSE_FATAL,
2531 "Filename missing from \"include\"");
2532 return;
2533 }
2534
2535 for (file = all_files; !done; file = cp + 1) {

--- 51 unchanged lines hidden (view full) ---

2587 "Variable/Value missing from \"export\"");
2588 return;
2589 }
2590 *value++ = '\0'; /* terminate variable */
2591
2592 /*
2593 * Expand the value before putting it in the environment.
2594 */
2595 value = Var_Subst(NULL, value, VAR_CMD, FALSE);
2595 value = Var_Subst(NULL, value, VAR_CMD, FALSE, TRUE);
2596 setenv(variable, value, 1);
2597}
2598#endif
2599
2600/*-
2601 *---------------------------------------------------------------------
2602 * ParseEOF --
2603 * Called when EOF is reached in the current file. If we were reading

--- 532 unchanged lines hidden (view full) ---

3136 else
3137 cp = NULL;
3138
3139 /*
3140 * We now know it's a dependency line so it needs to have all
3141 * variables expanded before being parsed. Tell the variable
3142 * module to complain if some variable is undefined...
3143 */
2596 setenv(variable, value, 1);
2597}
2598#endif
2599
2600/*-
2601 *---------------------------------------------------------------------
2602 * ParseEOF --
2603 * Called when EOF is reached in the current file. If we were reading

--- 532 unchanged lines hidden (view full) ---

3136 else
3137 cp = NULL;
3138
3139 /*
3140 * We now know it's a dependency line so it needs to have all
3141 * variables expanded before being parsed. Tell the variable
3142 * module to complain if some variable is undefined...
3143 */
3144 line = Var_Subst(NULL, line, VAR_CMD, TRUE);
3144 line = Var_Subst(NULL, line, VAR_CMD, TRUE, TRUE);
3145
3146 /*
3147 * Need a non-circular list for the target nodes
3148 */
3149 if (targets)
3150 Lst_Destroy(targets, NULL);
3151
3152 targets = Lst_Init(FALSE);

--- 116 unchanged lines hidden ---
3145
3146 /*
3147 * Need a non-circular list for the target nodes
3148 */
3149 if (targets)
3150 Lst_Destroy(targets, NULL);
3151
3152 targets = Lst_Init(FALSE);

--- 116 unchanged lines hidden ---