| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: parse.c,v 1.157 2009/01/23 21:26:30 dsl Exp $ */ | | 1 | /* $NetBSD: parse.c,v 1.158 2009/10/07 16:40:30 sjg Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988, 1989, 1990, 1993 | | 4 | * Copyright (c) 1988, 1989, 1990, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Adam de Boor. | | 8 | * Adam de Boor. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -59,34 +59,34 @@ | | | @@ -59,34 +59,34 @@ |
59 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 59 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
60 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 60 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
61 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 61 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
62 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 62 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
63 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 63 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
64 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 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 | | 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 | | 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 | | 67 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
68 | * SUCH DAMAGE. | | 68 | * SUCH DAMAGE. |
69 | */ | | 69 | */ |
70 | | | 70 | |
71 | #ifndef MAKE_NATIVE | | 71 | #ifndef MAKE_NATIVE |
72 | static char rcsid[] = "$NetBSD: parse.c,v 1.157 2009/01/23 21:26:30 dsl Exp $"; | | 72 | static char rcsid[] = "$NetBSD: parse.c,v 1.158 2009/10/07 16:40:30 sjg Exp $"; |
73 | #else | | 73 | #else |
74 | #include <sys/cdefs.h> | | 74 | #include <sys/cdefs.h> |
75 | #ifndef lint | | 75 | #ifndef lint |
76 | #if 0 | | 76 | #if 0 |
77 | static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; | | 77 | static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; |
78 | #else | | 78 | #else |
79 | __RCSID("$NetBSD: parse.c,v 1.157 2009/01/23 21:26:30 dsl Exp $"); | | 79 | __RCSID("$NetBSD: parse.c,v 1.158 2009/10/07 16:40:30 sjg Exp $"); |
80 | #endif | | 80 | #endif |
81 | #endif /* not lint */ | | 81 | #endif /* not lint */ |
82 | #endif | | 82 | #endif |
83 | | | 83 | |
84 | /*- | | 84 | /*- |
85 | * parse.c -- | | 85 | * parse.c -- |
86 | * Functions to parse a makefile. | | 86 | * Functions to parse a makefile. |
87 | * | | 87 | * |
88 | * One function, Parse_Init, must be called before any functions | | 88 | * One function, Parse_Init, must be called before any functions |
89 | * in this module are used. After that, the function Parse_File is the | | 89 | * in this module are used. After that, the function Parse_File is the |
90 | * main entry point and controls most of the other functions in this | | 90 | * main entry point and controls most of the other functions in this |
91 | * module. | | 91 | * module. |
92 | * | | 92 | * |
| @@ -2580,35 +2580,50 @@ Parse_File(const char *name, int fd) | | | @@ -2580,35 +2580,50 @@ Parse_File(const char *name, int fd) |
2580 | if (inLine) { | | 2580 | if (inLine) { |
2581 | Parse_Error(PARSE_WARNING, | | 2581 | Parse_Error(PARSE_WARNING, |
2582 | "Shell command needs a leading tab"); | | 2582 | "Shell command needs a leading tab"); |
2583 | goto shellCommand; | | 2583 | goto shellCommand; |
2584 | } | | 2584 | } |
2585 | } | | 2585 | } |
2586 | } | | 2586 | } |
2587 | #endif | | 2587 | #endif |
2588 | ParseFinishLine(); | | 2588 | ParseFinishLine(); |
2589 | | | 2589 | |
2590 | /* | | 2590 | /* |
2591 | * For some reason - probably to make the parser impossible - | | 2591 | * For some reason - probably to make the parser impossible - |
2592 | * a ';' can be used to separate commands from dependencies. | | 2592 | * a ';' can be used to separate commands from dependencies. |
2593 | * No attempt is made to avoid ';' inside substitution patterns. | | 2593 | * Attempt to avoid ';' inside substitution patterns. |
2594 | */ | | 2594 | */ |
2595 | for (cp = line; *cp != 0; cp++) { | | 2595 | { |
2596 | if (*cp == '\\' && cp[1] != 0) { | | 2596 | int level = 0; |
2597 | cp++; | | 2597 | |
2598 | continue; | | 2598 | for (cp = line; *cp != 0; cp++) { |
| | | 2599 | if (*cp == '\\' && cp[1] != 0) { |
| | | 2600 | cp++; |
| | | 2601 | continue; |
| | | 2602 | } |
| | | 2603 | if (*cp == '$' && |
| | | 2604 | (cp[1] == '(' || cp[1] == '{')) { |
| | | 2605 | level++; |
| | | 2606 | continue; |
| | | 2607 | } |
| | | 2608 | if (level > 0) { |
| | | 2609 | if (*cp == ')' || *cp == '}') { |
| | | 2610 | level--; |
| | | 2611 | continue; |
| | | 2612 | } |
| | | 2613 | } else if (*cp == ';') { |
| | | 2614 | break; |
| | | 2615 | } |
2599 | } | | 2616 | } |
2600 | if (*cp == ';') | | | |
2601 | break; | | | |
2602 | } | | 2617 | } |
2603 | if (*cp != 0) | | 2618 | if (*cp != 0) |
2604 | /* Terminate the dependency list at the ';' */ | | 2619 | /* Terminate the dependency list at the ';' */ |
2605 | *cp++ = 0; | | 2620 | *cp++ = 0; |
2606 | else | | 2621 | else |
2607 | cp = NULL; | | 2622 | cp = NULL; |
2608 | | | 2623 | |
2609 | /* | | 2624 | /* |
2610 | * We now know it's a dependency line so it needs to have all | | 2625 | * We now know it's a dependency line so it needs to have all |
2611 | * variables expanded before being parsed. Tell the variable | | 2626 | * variables expanded before being parsed. Tell the variable |
2612 | * module to complain if some variable is undefined... | | 2627 | * module to complain if some variable is undefined... |
2613 | */ | | 2628 | */ |
2614 | line = Var_Subst(NULL, line, VAR_CMD, TRUE); | | 2629 | line = Var_Subst(NULL, line, VAR_CMD, TRUE); |